From f069b713748eb92cf8a7468d1fee4f99787c99d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A1=E8=8B=A5?= Date: Tue, 24 Mar 2026 12:29:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=E5=AF=8C=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E4=B8=8E=E5=86=85=E5=AE=B9=E7=AE=A1=E7=90=86=E9=A1=B5=E8=B0=83?= =?UTF-8?q?=E6=95=B4=EF=BC=9B=E9=93=BE=E6=8E=A5=E6=A0=87=E7=AD=BE=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E4=B8=8E=20db=20=E5=90=8C=E6=AD=A5=EF=BC=9B=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=20dist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Made-with: Cursor --- .../{index-Dv-LWSbq.js => index-Dz0mx7au.js} | 160 +++++++++--------- ...{index-DXojA1Za.css => index-qjssBjc3.css} | 2 +- soul-admin/dist/index.html | 4 +- soul-admin/src/components/RichEditor.tsx | 4 +- soul-admin/src/pages/content/ContentPage.tsx | 128 +++++++++++--- soul-api/internal/handler/db.go | 13 +- soul-api/internal/handler/db_link_tag.go | 112 +++++++----- soul-api/internal/model/link_tag.go | 2 + 8 files changed, 272 insertions(+), 153 deletions(-) rename soul-admin/dist/assets/{index-Dv-LWSbq.js => index-Dz0mx7au.js} (79%) rename soul-admin/dist/assets/{index-DXojA1Za.css => index-qjssBjc3.css} (92%) diff --git a/soul-admin/dist/assets/index-Dv-LWSbq.js b/soul-admin/dist/assets/index-Dz0mx7au.js similarity index 79% rename from soul-admin/dist/assets/index-Dv-LWSbq.js rename to soul-admin/dist/assets/index-Dz0mx7au.js index 7a88f837..947b3405 100644 --- a/soul-admin/dist/assets/index-Dv-LWSbq.js +++ b/soul-admin/dist/assets/index-Dz0mx7au.js @@ -1,4 +1,4 @@ -function IT(t,e){for(var n=0;nr[a]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=n(a);fetch(a.href,i)}})();function cj(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Xm={exports:{}},gd={},Zm={exports:{}},Nt={};/** +function IT(t,e){for(var n=0;nr[a]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=n(a);fetch(a.href,i)}})();function cj(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Xm={exports:{}},xd={},Zm={exports:{}},Nt={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ function IT(t,e){for(var n=0;n>>1,U=R[_];if(0>>1;_a(me,G))Ya(le,me)?(R[_]=le,R[Y]=G,_=Y):(R[_]=me,R[K]=G,_=K);else if(Ya(le,G))R[_]=le,R[Y]=G,_=Y;else break e}}return oe}function a(R,oe){var G=R.sortIndex-oe.sortIndex;return G!==0?G:R.id-oe.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,c=o.now();t.unstable_now=function(){return o.now()-c}}var u=[],h=[],f=1,m=null,g=3,y=!1,N=!1,w=!1,j=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function T(R){for(var oe=n(h);oe!==null;){if(oe.callback===null)r(h);else if(oe.startTime<=R)r(h),oe.sortIndex=oe.expirationTime,e(u,oe);else break;oe=n(h)}}function P(R){if(w=!1,T(R),!N)if(n(u)!==null)N=!0,$(O);else{var oe=n(h);oe!==null&&D(P,oe.startTime-R)}}function O(R,oe){N=!1,w&&(w=!1,S(V),V=-1),y=!0;var G=g;try{for(T(oe),m=n(u);m!==null&&(!(m.expirationTime>oe)||R&&!Q());){var _=m.callback;if(typeof _=="function"){m.callback=null,g=m.priorityLevel;var U=_(m.expirationTime<=oe);oe=t.unstable_now(),typeof U=="function"?m.callback=U:m===n(u)&&r(u),T(oe)}else r(u);m=n(u)}if(m!==null)var H=!0;else{var K=n(h);K!==null&&D(P,K.startTime-oe),H=!1}return H}finally{m=null,g=G,y=!1}}var q=!1,z=null,V=-1,I=5,te=-1;function Q(){return!(t.unstable_now()-teR||125_?(R.sortIndex=G,e(h,R),n(u)===null&&R===n(h)&&(w?(S(V),V=-1):w=!0,D(P,G-_))):(R.sortIndex=U,e(u,R),N||y||(N=!0,$(O))),R},t.unstable_shouldYield=Q,t.unstable_wrapCallback=function(R){var oe=g;return function(){var G=g;g=oe;try{return R.apply(this,arguments)}finally{g=G}}}})(ng)),ng}var Wv;function DT(){return Wv||(Wv=1,tg.exports=LT()),tg.exports}/** + */var Uv;function LT(){return Uv||(Uv=1,(function(t){function e(R,oe){var G=R.length;R.push(oe);e:for(;0>>1,U=R[_];if(0>>1;_a(me,G))Ya(le,me)?(R[_]=le,R[Y]=G,_=Y):(R[_]=me,R[K]=G,_=K);else if(Ya(le,G))R[_]=le,R[Y]=G,_=Y;else break e}}return oe}function a(R,oe){var G=R.sortIndex-oe.sortIndex;return G!==0?G:R.id-oe.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,y=!1,N=!1,w=!1,j=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function T(R){for(var oe=n(h);oe!==null;){if(oe.callback===null)r(h);else if(oe.startTime<=R)r(h),oe.sortIndex=oe.expirationTime,e(u,oe);else break;oe=n(h)}}function P(R){if(w=!1,T(R),!N)if(n(u)!==null)N=!0,$(O);else{var oe=n(h);oe!==null&&D(P,oe.startTime-R)}}function O(R,oe){N=!1,w&&(w=!1,S(V),V=-1),y=!0;var G=x;try{for(T(oe),m=n(u);m!==null&&(!(m.expirationTime>oe)||R&&!Q());){var _=m.callback;if(typeof _=="function"){m.callback=null,x=m.priorityLevel;var U=_(m.expirationTime<=oe);oe=t.unstable_now(),typeof U=="function"?m.callback=U:m===n(u)&&r(u),T(oe)}else r(u);m=n(u)}if(m!==null)var H=!0;else{var K=n(h);K!==null&&D(P,K.startTime-oe),H=!1}return H}finally{m=null,x=G,y=!1}}var q=!1,z=null,V=-1,I=5,te=-1;function Q(){return!(t.unstable_now()-teR||125_?(R.sortIndex=G,e(h,R),n(u)===null&&R===n(h)&&(w?(S(V),V=-1):w=!0,D(P,G-_))):(R.sortIndex=U,e(u,R),N||y||(N=!0,$(O))),R},t.unstable_shouldYield=Q,t.unstable_wrapCallback=function(R){var oe=x;return function(){var G=x;x=oe;try{return R.apply(this,arguments)}finally{x=G}}}})(nx)),nx}var Wv;function DT(){return Wv||(Wv=1,tx.exports=LT()),tx.exports}/** * @license React * react-dom.production.min.js * @@ -30,14 +30,14 @@ function IT(t,e){for(var n=0;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},m={};function g(l){return u.call(m,l)?!0:u.call(f,l)?!1:h.test(l)?m[l]=!0:(f[l]=!0,!1)}function y(l,d,p,x){if(p!==null&&p.type===0)return!1;switch(typeof d){case"function":case"symbol":return!0;case"boolean":return x?!1:p!==null?!p.acceptsBooleans:(l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-");default:return!1}}function N(l,d,p,x){if(d===null||typeof d>"u"||y(l,d,p,x))return!0;if(x)return!1;if(p!==null)switch(p.type){case 3:return!d;case 4:return d===!1;case 5:return isNaN(d);case 6:return isNaN(d)||1>d}return!1}function w(l,d,p,x,k,C,M){this.acceptsBooleans=d===2||d===3||d===4,this.attributeName=x,this.attributeNamespace=k,this.mustUseProperty=p,this.propertyName=l,this.type=d,this.sanitizeURL=C,this.removeEmptyString=M}var j={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){j[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];j[d]=new w(d,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){j[l]=new w(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){j[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){j[l]=new w(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){j[l]=new w(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){j[l]=new w(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){j[l]=new w(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){j[l]=new w(l,5,!1,l.toLowerCase(),null,!1,!1)});var S=/[\-:]([a-z])/g;function E(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(S,E);j[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(S,E);j[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(S,E);j[d]=new w(d,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){j[l]=new w(l,1,!1,l.toLowerCase(),null,!1,!1)}),j.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){j[l]=new w(l,1,!1,l.toLowerCase(),null,!0,!0)});function T(l,d,p,x){var k=j.hasOwnProperty(d)?j[d]:null;(k!==null?k.type!==0:x||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},m={};function x(l){return u.call(m,l)?!0:u.call(f,l)?!1:h.test(l)?m[l]=!0:(f[l]=!0,!1)}function y(l,d,p,g){if(p!==null&&p.type===0)return!1;switch(typeof d){case"function":case"symbol":return!0;case"boolean":return g?!1:p!==null?!p.acceptsBooleans:(l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-");default:return!1}}function N(l,d,p,g){if(d===null||typeof d>"u"||y(l,d,p,g))return!0;if(g)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,g,k,C,M){this.acceptsBooleans=d===2||d===3||d===4,this.attributeName=g,this.attributeNamespace=k,this.mustUseProperty=p,this.propertyName=l,this.type=d,this.sanitizeURL=C,this.removeEmptyString=M}var j={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){j[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];j[d]=new w(d,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){j[l]=new w(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){j[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){j[l]=new w(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){j[l]=new w(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){j[l]=new w(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){j[l]=new w(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){j[l]=new w(l,5,!1,l.toLowerCase(),null,!1,!1)});var S=/[\-:]([a-z])/g;function E(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(S,E);j[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(S,E);j[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(S,E);j[d]=new w(d,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){j[l]=new w(l,1,!1,l.toLowerCase(),null,!1,!1)}),j.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){j[l]=new w(l,1,!1,l.toLowerCase(),null,!0,!0)});function T(l,d,p,g){var k=j.hasOwnProperty(d)?j[d]:null;(k!==null?k.type!==0:g||!(2W||k[M]!==C[W]){var Z=` -`+k[M].replace(" at new "," at ");return l.displayName&&Z.includes("")&&(Z=Z.replace("",l.displayName)),Z}while(1<=M&&0<=W);break}}}finally{H=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?U(l):""}function me(l){switch(l.tag){case 5:return U(l.type);case 16:return U("Lazy");case 13:return U("Suspense");case 19:return U("SuspenseList");case 0:case 2:case 15:return l=K(l.type,!1),l;case 11:return l=K(l.type.render,!1),l;case 1:return l=K(l.type,!0),l;default:return""}}function Y(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 z:return"Fragment";case q:return"Portal";case I:return"Profiler";case V:return"StrictMode";case re:return"Suspense";case ae:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case Q:return(l.displayName||"Context")+".Consumer";case te:return(l._context.displayName||"Context")+".Provider";case F:var d=l.render;return l=l.displayName,l||(l=d.displayName||d.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case J:return d=l.displayName||null,d!==null?d:Y(l.type)||"Memo";case $:d=l._payload,l=l._init;try{return Y(l(d))}catch{}}return null}function le(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 Y(d);case 8:return d===V?"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 ce(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function ve(l){var d=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function ye(l){var d=ve(l)?"checked":"value",p=Object.getOwnPropertyDescriptor(l.constructor.prototype,d),x=""+l[d];if(!l.hasOwnProperty(d)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var k=p.get,C=p.set;return Object.defineProperty(l,d,{configurable:!0,get:function(){return k.call(this)},set:function(M){x=""+M,C.call(this,M)}}),Object.defineProperty(l,d,{enumerable:p.enumerable}),{getValue:function(){return x},setValue:function(M){x=""+M},stopTracking:function(){l._valueTracker=null,delete l[d]}}}}function ke(l){l._valueTracker||(l._valueTracker=ye(l))}function ze(l){if(!l)return!1;var d=l._valueTracker;if(!d)return!0;var p=d.getValue(),x="";return l&&(x=ve(l)?l.checked?"true":"false":l.value),l=x,l!==p?(d.setValue(l),!0):!1}function ht(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 G({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??l._wrapperState.initialChecked})}function dt(l,d){var p=d.defaultValue==null?"":d.defaultValue,x=d.checked!=null?d.checked:d.defaultChecked;p=ce(d.value!=null?d.value:p),l._wrapperState={initialChecked:x,initialValue:p,controlled:d.type==="checkbox"||d.type==="radio"?d.checked!=null:d.value!=null}}function Rt(l,d){d=d.checked,d!=null&&T(l,"checked",d,!1)}function Tt(l,d){Rt(l,d);var p=ce(d.value),x=d.type;if(p!=null)x==="number"?(p===0&&l.value===""||l.value!=p)&&(l.value=""+p):l.value!==""+p&&(l.value=""+p);else if(x==="submit"||x==="reset"){l.removeAttribute("value");return}d.hasOwnProperty("value")?mn(l,d.type,p):d.hasOwnProperty("defaultValue")&&mn(l,d.type,ce(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(l.defaultChecked=!!d.defaultChecked)}function Tn(l,d,p){if(d.hasOwnProperty("value")||d.hasOwnProperty("defaultValue")){var x=d.type;if(!(x!=="submit"&&x!=="reset"||d.value!==void 0&&d.value!==null))return;d=""+l._wrapperState.initialValue,p||d===l.value||(l.value=d),l.defaultValue=d}p=l.name,p!==""&&(l.name=""),l.defaultChecked=!!l._wrapperState.initialChecked,p!==""&&(l.name=p)}function mn(l,d,p){(d!=="number"||ht(l.ownerDocument)!==l)&&(p==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+p&&(l.defaultValue=""+p))}var Ft=Array.isArray;function qt(l,d,p,x){if(l=l.options,d){d={};for(var k=0;k"+d.valueOf().toString()+"",d=xe.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;d.firstChild;)l.appendChild(d.firstChild)}});function $e(l,d){if(d){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=d;return}}l.textContent=d}var Xe={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},jt=["Webkit","ms","Moz","O"];Object.keys(Xe).forEach(function(l){jt.forEach(function(d){d=d+l.charAt(0).toUpperCase()+l.substring(1),Xe[d]=Xe[l]})});function xt(l,d,p){return d==null||typeof d=="boolean"||d===""?"":p||typeof d!="number"||d===0||Xe.hasOwnProperty(l)&&Xe[l]?(""+d).trim():d+"px"}function L(l,d){l=l.style;for(var p in d)if(d.hasOwnProperty(p)){var x=p.indexOf("--")===0,k=xt(p,d[p],x);p==="float"&&(p="cssFloat"),x?l.setProperty(p,k):l[p]=k}}var Me=G({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ft(l,d){if(d){if(Me[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 Et(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 ut=null;function tt(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var Pt=null,Wt=null,en=null;function ts(l){if(l=td(l)){if(typeof Pt!="function")throw Error(n(280));var d=l.stateNode;d&&(d=Nu(d),Pt(l.stateNode,l.type,d))}}function Js(l){Wt?en?en.push(l):en=[l]:Wt=l}function bi(){if(Wt){var l=Wt,d=en;if(en=Wt=null,ts(l),d)for(l=0;l>>=0,l===0?32:31-(Cl(l)/Pr|0)|0}var wi=64,Ra=4194304;function ra(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 aa(l,d){var p=l.pendingLanes;if(p===0)return 0;var x=0,k=l.suspendedLanes,C=l.pingedLanes,M=p&268435455;if(M!==0){var W=M&~k;W!==0?x=ra(W):(C&=M,C!==0&&(x=ra(C)))}else M=p&~k,M!==0?x=ra(M):C!==0&&(x=ra(C));if(x===0)return 0;if(d!==0&&d!==x&&(d&k)===0&&(k=x&-x,C=d&-d,k>=C||k===16&&(C&4194240)!==0))return d;if((x&4)!==0&&(x|=p&16),d=l.entangledLanes,d!==0)for(l=l.entanglements,d&=x;0p;p++)d.push(l);return d}function En(l,d,p){l.pendingLanes|=d,d!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,d=31-qn(d),l[d]=p}function Pa(l,d){var p=l.pendingLanes&~d;l.pendingLanes=d,l.suspendedLanes=0,l.pingedLanes=0,l.expiredLanes&=d,l.mutableReadLanes&=d,l.entangledLanes&=d,d=l.entanglements;var x=l.eventTimes;for(l=l.expirationTimes;0=Kc),Py=" ",Oy=!1;function Ly(l,d){switch(l){case"keyup":return C4.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Dy(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Il=!1;function E4(l,d){switch(l){case"compositionend":return Dy(d);case"keypress":return d.which!==32?null:(Oy=!0,Py);case"textInput":return l=d.data,l===Py&&Oy?null:l;default:return null}}function M4(l,d){if(Il)return l==="compositionend"||!Rp&&Ly(l,d)?(l=Po(),Ba=Ro=mr=null,Il=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(d.ctrlKey||d.altKey||d.metaKey)||d.ctrlKey&&d.altKey){if(d.char&&1=d)return{node:p,offset:d-l};l=x}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=Hy(p)}}function Wy(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?Wy(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function Ky(){for(var l=window,d=ht();d instanceof l.HTMLIFrameElement;){try{var p=typeof d.contentWindow.location.href=="string"}catch{p=!1}if(p)l=d.contentWindow;else break;d=ht(l.document)}return d}function Lp(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 z4(l){var d=Ky(),p=l.focusedElem,x=l.selectionRange;if(d!==p&&p&&p.ownerDocument&&Wy(p.ownerDocument.documentElement,p)){if(x!==null&&Lp(p)){if(d=x.start,l=x.end,l===void 0&&(l=d),"selectionStart"in p)p.selectionStart=d,p.selectionEnd=Math.min(l,p.value.length);else if(l=(d=p.ownerDocument||document)&&d.defaultView||window,l.getSelection){l=l.getSelection();var k=p.textContent.length,C=Math.min(x.start,k);x=x.end===void 0?C:Math.min(x.end,k),!l.extend&&C>x&&(k=x,x=C,C=k),k=Uy(p,C);var M=Uy(p,x);k&&M&&(l.rangeCount!==1||l.anchorNode!==k.node||l.anchorOffset!==k.offset||l.focusNode!==M.node||l.focusOffset!==M.offset)&&(d=d.createRange(),d.setStart(k.node,k.offset),l.removeAllRanges(),C>x?(l.addRange(d),l.extend(M.node,M.offset)):(d.setEnd(M.node,M.offset),l.addRange(d)))}}for(d=[],l=p;l=l.parentNode;)l.nodeType===1&&d.push({element:l,left:l.scrollLeft,top:l.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p=document.documentMode,Rl=null,Dp=null,Qc=null,_p=!1;function qy(l,d,p){var x=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;_p||Rl==null||Rl!==ht(x)||(x=Rl,"selectionStart"in x&&Lp(x)?x={start:x.selectionStart,end:x.selectionEnd}:(x=(x.ownerDocument&&x.ownerDocument.defaultView||window).getSelection(),x={anchorNode:x.anchorNode,anchorOffset:x.anchorOffset,focusNode:x.focusNode,focusOffset:x.focusOffset}),Qc&&Jc(Qc,x)||(Qc=x,x=yu(Dp,"onSelect"),0_l||(l.current=Jp[_l],Jp[_l]=null,_l--)}function tn(l,d){_l++,Jp[_l]=l.current,l.current=d}var Pi={},ms=Ri(Pi),$s=Ri(!1),Do=Pi;function zl(l,d){var p=l.type.contextTypes;if(!p)return Pi;var x=l.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===d)return x.__reactInternalMemoizedMaskedChildContext;var k={},C;for(C in p)k[C]=d[C];return x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=d,l.__reactInternalMemoizedMaskedChildContext=k),k}function Fs(l){return l=l.childContextTypes,l!=null}function wu(){on($s),on(ms)}function lb(l,d,p){if(ms.current!==Pi)throw Error(n(168));tn(ms,d),tn($s,p)}function cb(l,d,p){var x=l.stateNode;if(d=d.childContextTypes,typeof x.getChildContext!="function")return p;x=x.getChildContext();for(var k in x)if(!(k in d))throw Error(n(108,le(l)||"Unknown",k));return G({},p,x)}function ju(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||Pi,Do=ms.current,tn(ms,l),tn($s,$s.current),!0}function db(l,d,p){var x=l.stateNode;if(!x)throw Error(n(169));p?(l=cb(l,d,Do),x.__reactInternalMemoizedMergedChildContext=l,on($s),on(ms),tn(ms,l)):on($s),tn($s,p)}var Wa=null,ku=!1,Qp=!1;function ub(l){Wa===null?Wa=[l]:Wa.push(l)}function Q4(l){ku=!0,ub(l)}function Oi(){if(!Qp&&Wa!==null){Qp=!0;var l=0,d=kt;try{var p=Wa;for(kt=1;l>=M,k-=M,Ka=1<<32-qn(d)+k|p<lt?(Qn=st,st=null):Qn=st.sibling;var Ot=Ce(he,st,fe[lt],Re);if(Ot===null){st===null&&(st=Qn);break}l&&st&&Ot.alternate===null&&d(he,st),ne=C(Ot,ne,lt),nt===null?Je=Ot:nt.sibling=Ot,nt=Ot,st=Qn}if(lt===fe.length)return p(he,st),hn&&zo(he,lt),Je;if(st===null){for(;ltlt?(Qn=st,st=null):Qn=st.sibling;var Hi=Ce(he,st,Ot.value,Re);if(Hi===null){st===null&&(st=Qn);break}l&&st&&Hi.alternate===null&&d(he,st),ne=C(Hi,ne,lt),nt===null?Je=Hi:nt.sibling=Hi,nt=Hi,st=Qn}if(Ot.done)return p(he,st),hn&&zo(he,lt),Je;if(st===null){for(;!Ot.done;lt++,Ot=fe.next())Ot=Ae(he,Ot.value,Re),Ot!==null&&(ne=C(Ot,ne,lt),nt===null?Je=Ot:nt.sibling=Ot,nt=Ot);return hn&&zo(he,lt),Je}for(st=x(he,st);!Ot.done;lt++,Ot=fe.next())Ot=Be(st,he,lt,Ot.value,Re),Ot!==null&&(l&&Ot.alternate!==null&&st.delete(Ot.key===null?lt:Ot.key),ne=C(Ot,ne,lt),nt===null?Je=Ot:nt.sibling=Ot,nt=Ot);return l&&st.forEach(function(AT){return d(he,AT)}),hn&&zo(he,lt),Je}function Mn(he,ne,fe,Re){if(typeof fe=="object"&&fe!==null&&fe.type===z&&fe.key===null&&(fe=fe.props.children),typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case O:e:{for(var Je=fe.key,nt=ne;nt!==null;){if(nt.key===Je){if(Je=fe.type,Je===z){if(nt.tag===7){p(he,nt.sibling),ne=k(nt,fe.props.children),ne.return=he,he=ne;break e}}else if(nt.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===$&&xb(Je)===nt.type){p(he,nt.sibling),ne=k(nt,fe.props),ne.ref=nd(he,nt,fe),ne.return=he,he=ne;break e}p(he,nt);break}else d(he,nt);nt=nt.sibling}fe.type===z?(ne=Ko(fe.props.children,he.mode,Re,fe.key),ne.return=he,he=ne):(Re=Xu(fe.type,fe.key,fe.props,null,he.mode,Re),Re.ref=nd(he,ne,fe),Re.return=he,he=Re)}return M(he);case q:e:{for(nt=fe.key;ne!==null;){if(ne.key===nt)if(ne.tag===4&&ne.stateNode.containerInfo===fe.containerInfo&&ne.stateNode.implementation===fe.implementation){p(he,ne.sibling),ne=k(ne,fe.children||[]),ne.return=he,he=ne;break e}else{p(he,ne);break}else d(he,ne);ne=ne.sibling}ne=qm(fe,he.mode,Re),ne.return=he,he=ne}return M(he);case $:return nt=fe._init,Mn(he,ne,nt(fe._payload),Re)}if(Ft(fe))return Ue(he,ne,fe,Re);if(oe(fe))return qe(he,ne,fe,Re);Eu(he,fe)}return typeof fe=="string"&&fe!==""||typeof fe=="number"?(fe=""+fe,ne!==null&&ne.tag===6?(p(he,ne.sibling),ne=k(ne,fe),ne.return=he,he=ne):(p(he,ne),ne=Km(fe,he.mode,Re),ne.return=he,he=ne),M(he)):p(he,ne)}return Mn}var Vl=yb(!0),bb=yb(!1),Mu=Ri(null),Au=null,Hl=null,nm=null;function sm(){nm=Hl=Au=null}function rm(l){var d=Mu.current;on(Mu),l._currentValue=d}function am(l,d,p){for(;l!==null;){var x=l.alternate;if((l.childLanes&d)!==d?(l.childLanes|=d,x!==null&&(x.childLanes|=d)):x!==null&&(x.childLanes&d)!==d&&(x.childLanes|=d),l===p)break;l=l.return}}function Ul(l,d){Au=l,nm=Hl=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(Bs=!0),l.firstContext=null)}function yr(l){var d=l._currentValue;if(nm!==l)if(l={context:l,memoizedValue:d,next:null},Hl===null){if(Au===null)throw Error(n(308));Hl=l,Au.dependencies={lanes:0,firstContext:l}}else Hl=Hl.next=l;return d}var $o=null;function im(l){$o===null?$o=[l]:$o.push(l)}function vb(l,d,p,x){var k=d.interleaved;return k===null?(p.next=p,im(d)):(p.next=k.next,k.next=p),d.interleaved=p,Ga(l,x)}function Ga(l,d){l.lanes|=d;var p=l.alternate;for(p!==null&&(p.lanes|=d),p=l,l=l.return;l!==null;)l.childLanes|=d,p=l.alternate,p!==null&&(p.childLanes|=d),p=l,l=l.return;return p.tag===3?p.stateNode:null}var Li=!1;function om(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Nb(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 Ja(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function Di(l,d,p){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,(It&2)!==0){var k=x.pending;return k===null?d.next=d:(d.next=k.next,k.next=d),x.pending=d,Ga(l,p)}return k=x.interleaved,k===null?(d.next=d,im(x)):(d.next=k.next,k.next=d),x.interleaved=d,Ga(l,p)}function Iu(l,d,p){if(d=d.updateQueue,d!==null&&(d=d.shared,(p&4194240)!==0)){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,Ls(l,p)}}function wb(l,d){var p=l.updateQueue,x=l.alternate;if(x!==null&&(x=x.updateQueue,p===x)){var k=null,C=null;if(p=p.firstBaseUpdate,p!==null){do{var M={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};C===null?k=C=M:C=C.next=M,p=p.next}while(p!==null);C===null?k=C=d:C=C.next=d}else k=C=d;p={baseState:x.baseState,firstBaseUpdate:k,lastBaseUpdate:C,shared:x.shared,effects:x.effects},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=d:l.next=d,p.lastBaseUpdate=d}function Ru(l,d,p,x){var k=l.updateQueue;Li=!1;var C=k.firstBaseUpdate,M=k.lastBaseUpdate,W=k.shared.pending;if(W!==null){k.shared.pending=null;var Z=W,pe=Z.next;Z.next=null,M===null?C=pe:M.next=pe,M=Z;var Te=l.alternate;Te!==null&&(Te=Te.updateQueue,W=Te.lastBaseUpdate,W!==M&&(W===null?Te.firstBaseUpdate=pe:W.next=pe,Te.lastBaseUpdate=Z))}if(C!==null){var Ae=k.baseState;M=0,Te=pe=Z=null,W=C;do{var Ce=W.lane,Be=W.eventTime;if((x&Ce)===Ce){Te!==null&&(Te=Te.next={eventTime:Be,lane:0,tag:W.tag,payload:W.payload,callback:W.callback,next:null});e:{var Ue=l,qe=W;switch(Ce=d,Be=p,qe.tag){case 1:if(Ue=qe.payload,typeof Ue=="function"){Ae=Ue.call(Be,Ae,Ce);break e}Ae=Ue;break e;case 3:Ue.flags=Ue.flags&-65537|128;case 0:if(Ue=qe.payload,Ce=typeof Ue=="function"?Ue.call(Be,Ae,Ce):Ue,Ce==null)break e;Ae=G({},Ae,Ce);break e;case 2:Li=!0}}W.callback!==null&&W.lane!==0&&(l.flags|=64,Ce=k.effects,Ce===null?k.effects=[W]:Ce.push(W))}else Be={eventTime:Be,lane:Ce,tag:W.tag,payload:W.payload,callback:W.callback,next:null},Te===null?(pe=Te=Be,Z=Ae):Te=Te.next=Be,M|=Ce;if(W=W.next,W===null){if(W=k.shared.pending,W===null)break;Ce=W,W=Ce.next,Ce.next=null,k.lastBaseUpdate=Ce,k.shared.pending=null}}while(!0);if(Te===null&&(Z=Ae),k.baseState=Z,k.firstBaseUpdate=pe,k.lastBaseUpdate=Te,d=k.shared.interleaved,d!==null){k=d;do M|=k.lane,k=k.next;while(k!==d)}else C===null&&(k.shared.lanes=0);Vo|=M,l.lanes=M,l.memoizedState=Ae}}function jb(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;dp?p:4,l(!0);var x=hm.transition;hm.transition={};try{l(!1),d()}finally{kt=p,hm.transition=x}}function Vb(){return br().memoizedState}function eT(l,d,p){var x=Fi(l);if(p={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null},Hb(l))Ub(d,p);else if(p=vb(l,d,p,x),p!==null){var k=Ms();Wr(p,l,x,k),Wb(p,d,x)}}function tT(l,d,p){var x=Fi(l),k={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null};if(Hb(l))Ub(d,k);else{var C=l.alternate;if(l.lanes===0&&(C===null||C.lanes===0)&&(C=d.lastRenderedReducer,C!==null))try{var M=d.lastRenderedState,W=C(M,p);if(k.hasEagerState=!0,k.eagerState=W,Fr(W,M)){var Z=d.interleaved;Z===null?(k.next=k,im(d)):(k.next=Z.next,Z.next=k),d.interleaved=k;return}}catch{}finally{}p=vb(l,d,k,x),p!==null&&(k=Ms(),Wr(p,l,x,k),Wb(p,d,x))}}function Hb(l){var d=l.alternate;return l===yn||d!==null&&d===yn}function Ub(l,d){id=Lu=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function Wb(l,d,p){if((p&4194240)!==0){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,Ls(l,p)}}var zu={readContext:yr,useCallback:gs,useContext:gs,useEffect:gs,useImperativeHandle:gs,useInsertionEffect:gs,useLayoutEffect:gs,useMemo:gs,useReducer:gs,useRef:gs,useState:gs,useDebugValue:gs,useDeferredValue:gs,useTransition:gs,useMutableSource:gs,useSyncExternalStore:gs,useId:gs,unstable_isNewReconciler:!1},nT={readContext:yr,useCallback:function(l,d){return fa().memoizedState=[l,d===void 0?null:d],l},useContext:yr,useEffect:Ob,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,Du(4194308,4,_b.bind(null,d,l),p)},useLayoutEffect:function(l,d){return Du(4194308,4,l,d)},useInsertionEffect:function(l,d){return Du(4,2,l,d)},useMemo:function(l,d){var p=fa();return d=d===void 0?null:d,l=l(),p.memoizedState=[l,d],l},useReducer:function(l,d,p){var x=fa();return d=p!==void 0?p(d):d,x.memoizedState=x.baseState=d,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:d},x.queue=l,l=l.dispatch=eT.bind(null,yn,l),[x.memoizedState,l]},useRef:function(l){var d=fa();return l={current:l},d.memoizedState=l},useState:Rb,useDebugValue:bm,useDeferredValue:function(l){return fa().memoizedState=l},useTransition:function(){var l=Rb(!1),d=l[0];return l=Z4.bind(null,l[1]),fa().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var x=yn,k=fa();if(hn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),Jn===null)throw Error(n(349));(Bo&30)!==0||Tb(x,d,p)}k.memoizedState=p;var C={value:p,getSnapshot:d};return k.queue=C,Ob(Mb.bind(null,x,C,l),[l]),x.flags|=2048,cd(9,Eb.bind(null,x,C,p,d),void 0,null),p},useId:function(){var l=fa(),d=Jn.identifierPrefix;if(hn){var p=qa,x=Ka;p=(x&~(1<<32-qn(x)-1)).toString(32)+p,d=":"+d+"R"+p,p=od++,0")&&(Z=Z.replace("",l.displayName)),Z}while(1<=M&&0<=W);break}}}finally{H=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?U(l):""}function me(l){switch(l.tag){case 5:return U(l.type);case 16:return U("Lazy");case 13:return U("Suspense");case 19:return U("SuspenseList");case 0:case 2:case 15:return l=K(l.type,!1),l;case 11:return l=K(l.type.render,!1),l;case 1:return l=K(l.type,!0),l;default:return""}}function Y(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 z:return"Fragment";case q:return"Portal";case I:return"Profiler";case V:return"StrictMode";case re:return"Suspense";case ie:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case Q:return(l.displayName||"Context")+".Consumer";case te:return(l._context.displayName||"Context")+".Provider";case F:var d=l.render;return l=l.displayName,l||(l=d.displayName||d.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case J:return d=l.displayName||null,d!==null?d:Y(l.type)||"Memo";case $:d=l._payload,l=l._init;try{return Y(l(d))}catch{}}return null}function le(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 Y(d);case 8:return d===V?"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 de(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function ve(l){var d=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function ye(l){var d=ve(l)?"checked":"value",p=Object.getOwnPropertyDescriptor(l.constructor.prototype,d),g=""+l[d];if(!l.hasOwnProperty(d)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var k=p.get,C=p.set;return Object.defineProperty(l,d,{configurable:!0,get:function(){return k.call(this)},set:function(M){g=""+M,C.call(this,M)}}),Object.defineProperty(l,d,{enumerable:p.enumerable}),{getValue:function(){return g},setValue:function(M){g=""+M},stopTracking:function(){l._valueTracker=null,delete l[d]}}}}function ke(l){l._valueTracker||(l._valueTracker=ye(l))}function ze(l){if(!l)return!1;var d=l._valueTracker;if(!d)return!0;var p=d.getValue(),g="";return l&&(g=ve(l)?l.checked?"true":"false":l.value),l=g,l!==p?(d.setValue(l),!0):!1}function ft(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 G({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??l._wrapperState.initialChecked})}function dt(l,d){var p=d.defaultValue==null?"":d.defaultValue,g=d.checked!=null?d.checked:d.defaultChecked;p=de(d.value!=null?d.value:p),l._wrapperState={initialChecked:g,initialValue:p,controlled:d.type==="checkbox"||d.type==="radio"?d.checked!=null:d.value!=null}}function Rt(l,d){d=d.checked,d!=null&&T(l,"checked",d,!1)}function Tt(l,d){Rt(l,d);var p=de(d.value),g=d.type;if(p!=null)g==="number"?(p===0&&l.value===""||l.value!=p)&&(l.value=""+p):l.value!==""+p&&(l.value=""+p);else if(g==="submit"||g==="reset"){l.removeAttribute("value");return}d.hasOwnProperty("value")?mn(l,d.type,p):d.hasOwnProperty("defaultValue")&&mn(l,d.type,de(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(l.defaultChecked=!!d.defaultChecked)}function Tn(l,d,p){if(d.hasOwnProperty("value")||d.hasOwnProperty("defaultValue")){var g=d.type;if(!(g!=="submit"&&g!=="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 mn(l,d,p){(d!=="number"||ft(l.ownerDocument)!==l)&&(p==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+p&&(l.defaultValue=""+p))}var Ft=Array.isArray;function qt(l,d,p,g){if(l=l.options,d){d={};for(var k=0;k"+d.valueOf().toString()+"",d=ge.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;d.firstChild;)l.appendChild(d.firstChild)}});function $e(l,d){if(d){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=d;return}}l.textContent=d}var Xe={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},jt=["Webkit","ms","Moz","O"];Object.keys(Xe).forEach(function(l){jt.forEach(function(d){d=d+l.charAt(0).toUpperCase()+l.substring(1),Xe[d]=Xe[l]})});function gt(l,d,p){return d==null||typeof d=="boolean"||d===""?"":p||typeof d!="number"||d===0||Xe.hasOwnProperty(l)&&Xe[l]?(""+d).trim():d+"px"}function L(l,d){l=l.style;for(var p in d)if(d.hasOwnProperty(p)){var g=p.indexOf("--")===0,k=gt(p,d[p],g);p==="float"&&(p="cssFloat"),g?l.setProperty(p,k):l[p]=k}}var Me=G({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function pt(l,d){if(d){if(Me[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 Et(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 ht=null;function tt(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var Pt=null,Wt=null,en=null;function ts(l){if(l=td(l)){if(typeof Pt!="function")throw Error(n(280));var d=l.stateNode;d&&(d=Nu(d),Pt(l.stateNode,l.type,d))}}function Qs(l){Wt?en?en.push(l):en=[l]:Wt=l}function bi(){if(Wt){var l=Wt,d=en;if(en=Wt=null,ts(l),d)for(l=0;l>>=0,l===0?32:31-(Cl(l)/Pr|0)|0}var wi=64,Ra=4194304;function ra(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 aa(l,d){var p=l.pendingLanes;if(p===0)return 0;var g=0,k=l.suspendedLanes,C=l.pingedLanes,M=p&268435455;if(M!==0){var W=M&~k;W!==0?g=ra(W):(C&=M,C!==0&&(g=ra(C)))}else M=p&~k,M!==0?g=ra(M):C!==0&&(g=ra(C));if(g===0)return 0;if(d!==0&&d!==g&&(d&k)===0&&(k=g&-g,C=d&-d,k>=C||k===16&&(C&4194240)!==0))return d;if((g&4)!==0&&(g|=p&16),d=l.entangledLanes,d!==0)for(l=l.entanglements,d&=g;0p;p++)d.push(l);return d}function En(l,d,p){l.pendingLanes|=d,d!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,d=31-qn(d),l[d]=p}function Pa(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 g=l.eventTimes;for(l=l.expirationTimes;0=Kc),Py=" ",Oy=!1;function Ly(l,d){switch(l){case"keyup":return C4.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Dy(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Il=!1;function E4(l,d){switch(l){case"compositionend":return Dy(d);case"keypress":return d.which!==32?null:(Oy=!0,Py);case"textInput":return l=d.data,l===Py&&Oy?null:l;default:return null}}function M4(l,d){if(Il)return l==="compositionend"||!Rp&&Ly(l,d)?(l=Po(),Ba=Ro=mr=null,Il=!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=g}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=Hy(p)}}function Wy(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?Wy(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function Ky(){for(var l=window,d=ft();d instanceof l.HTMLIFrameElement;){try{var p=typeof d.contentWindow.location.href=="string"}catch{p=!1}if(p)l=d.contentWindow;else break;d=ft(l.document)}return d}function Lp(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 z4(l){var d=Ky(),p=l.focusedElem,g=l.selectionRange;if(d!==p&&p&&p.ownerDocument&&Wy(p.ownerDocument.documentElement,p)){if(g!==null&&Lp(p)){if(d=g.start,l=g.end,l===void 0&&(l=d),"selectionStart"in p)p.selectionStart=d,p.selectionEnd=Math.min(l,p.value.length);else if(l=(d=p.ownerDocument||document)&&d.defaultView||window,l.getSelection){l=l.getSelection();var k=p.textContent.length,C=Math.min(g.start,k);g=g.end===void 0?C:Math.min(g.end,k),!l.extend&&C>g&&(k=g,g=C,C=k),k=Uy(p,C);var M=Uy(p,g);k&&M&&(l.rangeCount!==1||l.anchorNode!==k.node||l.anchorOffset!==k.offset||l.focusNode!==M.node||l.focusOffset!==M.offset)&&(d=d.createRange(),d.setStart(k.node,k.offset),l.removeAllRanges(),C>g?(l.addRange(d),l.extend(M.node,M.offset)):(d.setEnd(M.node,M.offset),l.addRange(d)))}}for(d=[],l=p;l=l.parentNode;)l.nodeType===1&&d.push({element:l,left:l.scrollLeft,top:l.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p=document.documentMode,Rl=null,Dp=null,Qc=null,_p=!1;function qy(l,d,p){var g=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;_p||Rl==null||Rl!==ft(g)||(g=Rl,"selectionStart"in g&&Lp(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),Qc&&Jc(Qc,g)||(Qc=g,g=yu(Dp,"onSelect"),0_l||(l.current=Jp[_l],Jp[_l]=null,_l--)}function tn(l,d){_l++,Jp[_l]=l.current,l.current=d}var Pi={},ms=Ri(Pi),$s=Ri(!1),Do=Pi;function zl(l,d){var p=l.type.contextTypes;if(!p)return Pi;var g=l.stateNode;if(g&&g.__reactInternalMemoizedUnmaskedChildContext===d)return g.__reactInternalMemoizedMaskedChildContext;var k={},C;for(C in p)k[C]=d[C];return g&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=d,l.__reactInternalMemoizedMaskedChildContext=k),k}function Fs(l){return l=l.childContextTypes,l!=null}function wu(){on($s),on(ms)}function lb(l,d,p){if(ms.current!==Pi)throw Error(n(168));tn(ms,d),tn($s,p)}function cb(l,d,p){var g=l.stateNode;if(d=d.childContextTypes,typeof g.getChildContext!="function")return p;g=g.getChildContext();for(var k in g)if(!(k in d))throw Error(n(108,le(l)||"Unknown",k));return G({},p,g)}function ju(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||Pi,Do=ms.current,tn(ms,l),tn($s,$s.current),!0}function db(l,d,p){var g=l.stateNode;if(!g)throw Error(n(169));p?(l=cb(l,d,Do),g.__reactInternalMemoizedMergedChildContext=l,on($s),on(ms),tn(ms,l)):on($s),tn($s,p)}var Wa=null,ku=!1,Qp=!1;function ub(l){Wa===null?Wa=[l]:Wa.push(l)}function Q4(l){ku=!0,ub(l)}function Oi(){if(!Qp&&Wa!==null){Qp=!0;var l=0,d=kt;try{var p=Wa;for(kt=1;l>=M,k-=M,Ka=1<<32-qn(d)+k|p<lt?(Qn=st,st=null):Qn=st.sibling;var Ot=Ce(he,st,fe[lt],Re);if(Ot===null){st===null&&(st=Qn);break}l&&st&&Ot.alternate===null&&d(he,st),ne=C(Ot,ne,lt),nt===null?Qe=Ot:nt.sibling=Ot,nt=Ot,st=Qn}if(lt===fe.length)return p(he,st),hn&&zo(he,lt),Qe;if(st===null){for(;ltlt?(Qn=st,st=null):Qn=st.sibling;var Hi=Ce(he,st,Ot.value,Re);if(Hi===null){st===null&&(st=Qn);break}l&&st&&Hi.alternate===null&&d(he,st),ne=C(Hi,ne,lt),nt===null?Qe=Hi:nt.sibling=Hi,nt=Hi,st=Qn}if(Ot.done)return p(he,st),hn&&zo(he,lt),Qe;if(st===null){for(;!Ot.done;lt++,Ot=fe.next())Ot=Ae(he,Ot.value,Re),Ot!==null&&(ne=C(Ot,ne,lt),nt===null?Qe=Ot:nt.sibling=Ot,nt=Ot);return hn&&zo(he,lt),Qe}for(st=g(he,st);!Ot.done;lt++,Ot=fe.next())Ot=Be(st,he,lt,Ot.value,Re),Ot!==null&&(l&&Ot.alternate!==null&&st.delete(Ot.key===null?lt:Ot.key),ne=C(Ot,ne,lt),nt===null?Qe=Ot:nt.sibling=Ot,nt=Ot);return l&&st.forEach(function(AT){return d(he,AT)}),hn&&zo(he,lt),Qe}function Mn(he,ne,fe,Re){if(typeof fe=="object"&&fe!==null&&fe.type===z&&fe.key===null&&(fe=fe.props.children),typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case O:e:{for(var Qe=fe.key,nt=ne;nt!==null;){if(nt.key===Qe){if(Qe=fe.type,Qe===z){if(nt.tag===7){p(he,nt.sibling),ne=k(nt,fe.props.children),ne.return=he,he=ne;break e}}else if(nt.elementType===Qe||typeof Qe=="object"&&Qe!==null&&Qe.$$typeof===$&&gb(Qe)===nt.type){p(he,nt.sibling),ne=k(nt,fe.props),ne.ref=nd(he,nt,fe),ne.return=he,he=ne;break e}p(he,nt);break}else d(he,nt);nt=nt.sibling}fe.type===z?(ne=Ko(fe.props.children,he.mode,Re,fe.key),ne.return=he,he=ne):(Re=Xu(fe.type,fe.key,fe.props,null,he.mode,Re),Re.ref=nd(he,ne,fe),Re.return=he,he=Re)}return M(he);case q:e:{for(nt=fe.key;ne!==null;){if(ne.key===nt)if(ne.tag===4&&ne.stateNode.containerInfo===fe.containerInfo&&ne.stateNode.implementation===fe.implementation){p(he,ne.sibling),ne=k(ne,fe.children||[]),ne.return=he,he=ne;break e}else{p(he,ne);break}else d(he,ne);ne=ne.sibling}ne=qm(fe,he.mode,Re),ne.return=he,he=ne}return M(he);case $:return nt=fe._init,Mn(he,ne,nt(fe._payload),Re)}if(Ft(fe))return We(he,ne,fe,Re);if(oe(fe))return Ge(he,ne,fe,Re);Eu(he,fe)}return typeof fe=="string"&&fe!==""||typeof fe=="number"?(fe=""+fe,ne!==null&&ne.tag===6?(p(he,ne.sibling),ne=k(ne,fe),ne.return=he,he=ne):(p(he,ne),ne=Km(fe,he.mode,Re),ne.return=he,he=ne),M(he)):p(he,ne)}return Mn}var Vl=yb(!0),bb=yb(!1),Mu=Ri(null),Au=null,Hl=null,nm=null;function sm(){nm=Hl=Au=null}function rm(l){var d=Mu.current;on(Mu),l._currentValue=d}function am(l,d,p){for(;l!==null;){var g=l.alternate;if((l.childLanes&d)!==d?(l.childLanes|=d,g!==null&&(g.childLanes|=d)):g!==null&&(g.childLanes&d)!==d&&(g.childLanes|=d),l===p)break;l=l.return}}function Ul(l,d){Au=l,nm=Hl=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(Bs=!0),l.firstContext=null)}function yr(l){var d=l._currentValue;if(nm!==l)if(l={context:l,memoizedValue:d,next:null},Hl===null){if(Au===null)throw Error(n(308));Hl=l,Au.dependencies={lanes:0,firstContext:l}}else Hl=Hl.next=l;return d}var $o=null;function im(l){$o===null?$o=[l]:$o.push(l)}function vb(l,d,p,g){var k=d.interleaved;return k===null?(p.next=p,im(d)):(p.next=k.next,k.next=p),d.interleaved=p,Ga(l,g)}function Ga(l,d){l.lanes|=d;var p=l.alternate;for(p!==null&&(p.lanes|=d),p=l,l=l.return;l!==null;)l.childLanes|=d,p=l.alternate,p!==null&&(p.childLanes|=d),p=l,l=l.return;return p.tag===3?p.stateNode:null}var Li=!1;function om(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Nb(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 Ja(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function Di(l,d,p){var g=l.updateQueue;if(g===null)return null;if(g=g.shared,(It&2)!==0){var k=g.pending;return k===null?d.next=d:(d.next=k.next,k.next=d),g.pending=d,Ga(l,p)}return k=g.interleaved,k===null?(d.next=d,im(g)):(d.next=k.next,k.next=d),g.interleaved=d,Ga(l,p)}function Iu(l,d,p){if(d=d.updateQueue,d!==null&&(d=d.shared,(p&4194240)!==0)){var g=d.lanes;g&=l.pendingLanes,p|=g,d.lanes=p,Ls(l,p)}}function wb(l,d){var p=l.updateQueue,g=l.alternate;if(g!==null&&(g=g.updateQueue,p===g)){var k=null,C=null;if(p=p.firstBaseUpdate,p!==null){do{var M={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};C===null?k=C=M:C=C.next=M,p=p.next}while(p!==null);C===null?k=C=d:C=C.next=d}else k=C=d;p={baseState:g.baseState,firstBaseUpdate:k,lastBaseUpdate:C,shared:g.shared,effects:g.effects},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=d:l.next=d,p.lastBaseUpdate=d}function Ru(l,d,p,g){var k=l.updateQueue;Li=!1;var C=k.firstBaseUpdate,M=k.lastBaseUpdate,W=k.shared.pending;if(W!==null){k.shared.pending=null;var Z=W,pe=Z.next;Z.next=null,M===null?C=pe:M.next=pe,M=Z;var Te=l.alternate;Te!==null&&(Te=Te.updateQueue,W=Te.lastBaseUpdate,W!==M&&(W===null?Te.firstBaseUpdate=pe:W.next=pe,Te.lastBaseUpdate=Z))}if(C!==null){var Ae=k.baseState;M=0,Te=pe=Z=null,W=C;do{var Ce=W.lane,Be=W.eventTime;if((g&Ce)===Ce){Te!==null&&(Te=Te.next={eventTime:Be,lane:0,tag:W.tag,payload:W.payload,callback:W.callback,next:null});e:{var We=l,Ge=W;switch(Ce=d,Be=p,Ge.tag){case 1:if(We=Ge.payload,typeof We=="function"){Ae=We.call(Be,Ae,Ce);break e}Ae=We;break e;case 3:We.flags=We.flags&-65537|128;case 0:if(We=Ge.payload,Ce=typeof We=="function"?We.call(Be,Ae,Ce):We,Ce==null)break e;Ae=G({},Ae,Ce);break e;case 2:Li=!0}}W.callback!==null&&W.lane!==0&&(l.flags|=64,Ce=k.effects,Ce===null?k.effects=[W]:Ce.push(W))}else Be={eventTime:Be,lane:Ce,tag:W.tag,payload:W.payload,callback:W.callback,next:null},Te===null?(pe=Te=Be,Z=Ae):Te=Te.next=Be,M|=Ce;if(W=W.next,W===null){if(W=k.shared.pending,W===null)break;Ce=W,W=Ce.next,Ce.next=null,k.lastBaseUpdate=Ce,k.shared.pending=null}}while(!0);if(Te===null&&(Z=Ae),k.baseState=Z,k.firstBaseUpdate=pe,k.lastBaseUpdate=Te,d=k.shared.interleaved,d!==null){k=d;do M|=k.lane,k=k.next;while(k!==d)}else C===null&&(k.shared.lanes=0);Vo|=M,l.lanes=M,l.memoizedState=Ae}}function jb(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;dp?p:4,l(!0);var g=hm.transition;hm.transition={};try{l(!1),d()}finally{kt=p,hm.transition=g}}function Vb(){return br().memoizedState}function eT(l,d,p){var g=Fi(l);if(p={lane:g,action:p,hasEagerState:!1,eagerState:null,next:null},Hb(l))Ub(d,p);else if(p=vb(l,d,p,g),p!==null){var k=Ms();Wr(p,l,g,k),Wb(p,d,g)}}function tT(l,d,p){var g=Fi(l),k={lane:g,action:p,hasEagerState:!1,eagerState:null,next:null};if(Hb(l))Ub(d,k);else{var C=l.alternate;if(l.lanes===0&&(C===null||C.lanes===0)&&(C=d.lastRenderedReducer,C!==null))try{var M=d.lastRenderedState,W=C(M,p);if(k.hasEagerState=!0,k.eagerState=W,Fr(W,M)){var Z=d.interleaved;Z===null?(k.next=k,im(d)):(k.next=Z.next,Z.next=k),d.interleaved=k;return}}catch{}finally{}p=vb(l,d,k,g),p!==null&&(k=Ms(),Wr(p,l,g,k),Wb(p,d,g))}}function Hb(l){var d=l.alternate;return l===yn||d!==null&&d===yn}function Ub(l,d){id=Lu=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function Wb(l,d,p){if((p&4194240)!==0){var g=d.lanes;g&=l.pendingLanes,p|=g,d.lanes=p,Ls(l,p)}}var zu={readContext:yr,useCallback:xs,useContext:xs,useEffect:xs,useImperativeHandle:xs,useInsertionEffect:xs,useLayoutEffect:xs,useMemo:xs,useReducer:xs,useRef:xs,useState:xs,useDebugValue:xs,useDeferredValue:xs,useTransition:xs,useMutableSource:xs,useSyncExternalStore:xs,useId:xs,unstable_isNewReconciler:!1},nT={readContext:yr,useCallback:function(l,d){return fa().memoizedState=[l,d===void 0?null:d],l},useContext:yr,useEffect:Ob,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,Du(4194308,4,_b.bind(null,d,l),p)},useLayoutEffect:function(l,d){return Du(4194308,4,l,d)},useInsertionEffect:function(l,d){return Du(4,2,l,d)},useMemo:function(l,d){var p=fa();return d=d===void 0?null:d,l=l(),p.memoizedState=[l,d],l},useReducer:function(l,d,p){var g=fa();return d=p!==void 0?p(d):d,g.memoizedState=g.baseState=d,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:d},g.queue=l,l=l.dispatch=eT.bind(null,yn,l),[g.memoizedState,l]},useRef:function(l){var d=fa();return l={current:l},d.memoizedState=l},useState:Rb,useDebugValue:bm,useDeferredValue:function(l){return fa().memoizedState=l},useTransition:function(){var l=Rb(!1),d=l[0];return l=Z4.bind(null,l[1]),fa().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var g=yn,k=fa();if(hn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),Jn===null)throw Error(n(349));(Bo&30)!==0||Tb(g,d,p)}k.memoizedState=p;var C={value:p,getSnapshot:d};return k.queue=C,Ob(Mb.bind(null,g,C,l),[l]),g.flags|=2048,cd(9,Eb.bind(null,g,C,p,d),void 0,null),p},useId:function(){var l=fa(),d=Jn.identifierPrefix;if(hn){var p=qa,g=Ka;p=(g&~(1<<32-qn(g)-1)).toString(32)+p,d=":"+d+"R"+p,p=od++,0<\/script>",l=l.removeChild(l.firstChild)):typeof x.is=="string"?l=M.createElement(p,{is:x.is}):(l=M.createElement(p),p==="select"&&(M=l,x.multiple?M.multiple=!0:x.size&&(M.size=x.size))):l=M.createElementNS(l,p),l[ua]=d,l[ed]=x,uv(l,d,!1,!1),d.stateNode=l;e:{switch(M=Et(p,x),p){case"dialog":an("cancel",l),an("close",l),k=x;break;case"iframe":case"object":case"embed":an("load",l),k=x;break;case"video":case"audio":for(k=0;kJl&&(d.flags|=128,x=!0,dd(C,!1),d.lanes=4194304)}else{if(!x)if(l=Pu(M),l!==null){if(d.flags|=128,x=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),dd(C,!0),C.tail===null&&C.tailMode==="hidden"&&!M.alternate&&!hn)return xs(d),null}else 2*Mt()-C.renderingStartTime>Jl&&p!==1073741824&&(d.flags|=128,x=!0,dd(C,!1),d.lanes=4194304);C.isBackwards?(M.sibling=d.child,d.child=M):(p=C.last,p!==null?p.sibling=M:d.child=M,C.last=M)}return C.tail!==null?(d=C.tail,C.rendering=d,C.tail=d.sibling,C.renderingStartTime=Mt(),d.sibling=null,p=xn.current,tn(xn,x?p&1|2:p&1),d):(xs(d),null);case 22:case 23:return Hm(),x=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==x&&(d.flags|=8192),x&&(d.mode&1)!==0?(nr&1073741824)!==0&&(xs(d),d.subtreeFlags&6&&(d.flags|=8192)):xs(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function dT(l,d){switch(Xp(d),d.tag){case 1:return Fs(d.type)&&wu(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return Wl(),on($s),on(ms),um(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return cm(d),null;case 13:if(on(xn),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));Bl()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return on(xn),null;case 4:return Wl(),null;case 10:return rm(d.type._context),null;case 22:case 23:return Hm(),null;case 24:return null;default:return null}}var Vu=!1,ys=!1,uT=typeof WeakSet=="function"?WeakSet:Set,He=null;function ql(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(x){Nn(l,d,x)}else p.current=null}function Im(l,d,p){try{p()}catch(x){Nn(l,d,x)}}var pv=!1;function hT(l,d){if(Hp=$a,l=Ky(),Lp(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var x=p.getSelection&&p.getSelection();if(x&&x.rangeCount!==0){p=x.anchorNode;var k=x.anchorOffset,C=x.focusNode;x=x.focusOffset;try{p.nodeType,C.nodeType}catch{p=null;break e}var M=0,W=-1,Z=-1,pe=0,Te=0,Ae=l,Ce=null;t:for(;;){for(var Be;Ae!==p||k!==0&&Ae.nodeType!==3||(W=M+k),Ae!==C||x!==0&&Ae.nodeType!==3||(Z=M+x),Ae.nodeType===3&&(M+=Ae.nodeValue.length),(Be=Ae.firstChild)!==null;)Ce=Ae,Ae=Be;for(;;){if(Ae===l)break t;if(Ce===p&&++pe===k&&(W=M),Ce===C&&++Te===x&&(Z=M),(Be=Ae.nextSibling)!==null)break;Ae=Ce,Ce=Ae.parentNode}Ae=Be}p=W===-1||Z===-1?null:{start:W,end:Z}}else p=null}p=p||{start:0,end:0}}else p=null;for(Up={focusedElem:l,selectionRange:p},$a=!1,He=d;He!==null;)if(d=He,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,He=l;else for(;He!==null;){d=He;try{var Ue=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(Ue!==null){var qe=Ue.memoizedProps,Mn=Ue.memoizedState,he=d.stateNode,ne=he.getSnapshotBeforeUpdate(d.elementType===d.type?qe:Vr(d.type,qe),Mn);he.__reactInternalSnapshotBeforeUpdate=ne}break;case 3:var fe=d.stateNode.containerInfo;fe.nodeType===1?fe.textContent="":fe.nodeType===9&&fe.documentElement&&fe.removeChild(fe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Re){Nn(d,d.return,Re)}if(l=d.sibling,l!==null){l.return=d.return,He=l;break}He=d.return}return Ue=pv,pv=!1,Ue}function ud(l,d,p){var x=d.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var k=x=x.next;do{if((k.tag&l)===l){var C=k.destroy;k.destroy=void 0,C!==void 0&&Im(d,p,C)}k=k.next}while(k!==x)}}function Hu(l,d){if(d=d.updateQueue,d=d!==null?d.lastEffect:null,d!==null){var p=d=d.next;do{if((p.tag&l)===l){var x=p.create;p.destroy=x()}p=p.next}while(p!==d)}}function Rm(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 mv(l){var d=l.alternate;d!==null&&(l.alternate=null,mv(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[ua],delete d[ed],delete d[Gp],delete d[G4],delete d[J4])),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 gv(l){return l.tag===5||l.tag===3||l.tag===4}function xv(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||gv(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 Pm(l,d,p){var x=l.tag;if(x===5||x===6)l=l.stateNode,d?p.nodeType===8?p.parentNode.insertBefore(l,d):p.insertBefore(l,d):(p.nodeType===8?(d=p.parentNode,d.insertBefore(l,p)):(d=p,d.appendChild(l)),p=p._reactRootContainer,p!=null||d.onclick!==null||(d.onclick=vu));else if(x!==4&&(l=l.child,l!==null))for(Pm(l,d,p),l=l.sibling;l!==null;)Pm(l,d,p),l=l.sibling}function Om(l,d,p){var x=l.tag;if(x===5||x===6)l=l.stateNode,d?p.insertBefore(l,d):p.appendChild(l);else if(x!==4&&(l=l.child,l!==null))for(Om(l,d,p),l=l.sibling;l!==null;)Om(l,d,p),l=l.sibling}var rs=null,Hr=!1;function _i(l,d,p){for(p=p.child;p!==null;)yv(l,d,p),p=p.sibling}function yv(l,d,p){if(ns&&typeof ns.onCommitFiberUnmount=="function")try{ns.onCommitFiberUnmount(na,p)}catch{}switch(p.tag){case 5:ys||ql(p,d);case 6:var x=rs,k=Hr;rs=null,_i(l,d,p),rs=x,Hr=k,rs!==null&&(Hr?(l=rs,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):rs.removeChild(p.stateNode));break;case 18:rs!==null&&(Hr?(l=rs,p=p.stateNode,l.nodeType===8?qp(l.parentNode,p):l.nodeType===1&&qp(l,p),Dr(l)):qp(rs,p.stateNode));break;case 4:x=rs,k=Hr,rs=p.stateNode.containerInfo,Hr=!0,_i(l,d,p),rs=x,Hr=k;break;case 0:case 11:case 14:case 15:if(!ys&&(x=p.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){k=x=x.next;do{var C=k,M=C.destroy;C=C.tag,M!==void 0&&((C&2)!==0||(C&4)!==0)&&Im(p,d,M),k=k.next}while(k!==x)}_i(l,d,p);break;case 1:if(!ys&&(ql(p,d),x=p.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=p.memoizedProps,x.state=p.memoizedState,x.componentWillUnmount()}catch(W){Nn(p,d,W)}_i(l,d,p);break;case 21:_i(l,d,p);break;case 22:p.mode&1?(ys=(x=ys)||p.memoizedState!==null,_i(l,d,p),ys=x):_i(l,d,p);break;default:_i(l,d,p)}}function bv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new uT),d.forEach(function(x){var k=NT.bind(null,l,x);p.has(x)||(p.add(x),x.then(k,k))})}}function Ur(l,d){var p=d.deletions;if(p!==null)for(var x=0;xk&&(k=M),x&=~C}if(x=k,x=Mt()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*pT(x/1960))-x,10l?16:l,$i===null)var x=!1;else{if(l=$i,$i=null,Gu=0,(It&6)!==0)throw Error(n(331));var k=It;for(It|=4,He=l.current;He!==null;){var C=He,M=C.child;if((He.flags&16)!==0){var W=C.deletions;if(W!==null){for(var Z=0;ZMt()-_m?Uo(l,0):Dm|=p),Hs(l,d)}function Rv(l,d){d===0&&((l.mode&1)===0?d=1:(d=Ra,Ra<<=1,(Ra&130023424)===0&&(Ra=4194304)));var p=Ms();l=Ga(l,d),l!==null&&(En(l,d,p),Hs(l,p))}function vT(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),Rv(l,p)}function NT(l,d){var p=0;switch(l.tag){case 13:var x=l.stateNode,k=l.memoizedState;k!==null&&(p=k.retryLane);break;case 19:x=l.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(d),Rv(l,p)}var Pv;Pv=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||$s.current)Bs=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return Bs=!1,lT(l,d,p);Bs=(l.flags&131072)!==0}else Bs=!1,hn&&(d.flags&1048576)!==0&&hb(d,Cu,d.index);switch(d.lanes=0,d.tag){case 2:var x=d.type;Bu(l,d),l=d.pendingProps;var k=zl(d,ms.current);Ul(d,p),k=pm(null,d,x,l,k,p);var C=mm();return d.flags|=1,typeof k=="object"&&k!==null&&typeof k.render=="function"&&k.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,Fs(x)?(C=!0,ju(d)):C=!1,d.memoizedState=k.state!==null&&k.state!==void 0?k.state:null,om(d),k.updater=$u,d.stateNode=k,k._reactInternals=d,Nm(d,x,l,p),d=Sm(null,d,x,!0,C,p)):(d.tag=0,hn&&C&&Yp(d),Es(null,d,k,p),d=d.child),d;case 16:x=d.elementType;e:{switch(Bu(l,d),l=d.pendingProps,k=x._init,x=k(x._payload),d.type=x,k=d.tag=jT(x),l=Vr(x,l),k){case 0:d=km(null,d,x,l,p);break e;case 1:d=av(null,d,x,l,p);break e;case 11:d=ev(null,d,x,l,p);break e;case 14:d=tv(null,d,x,Vr(x.type,l),p);break e}throw Error(n(306,x,""))}return d;case 0:return x=d.type,k=d.pendingProps,k=d.elementType===x?k:Vr(x,k),km(l,d,x,k,p);case 1:return x=d.type,k=d.pendingProps,k=d.elementType===x?k:Vr(x,k),av(l,d,x,k,p);case 3:e:{if(iv(d),l===null)throw Error(n(387));x=d.pendingProps,C=d.memoizedState,k=C.element,Nb(l,d),Ru(d,x,null,p);var M=d.memoizedState;if(x=M.element,C.isDehydrated)if(C={element:x,isDehydrated:!1,cache:M.cache,pendingSuspenseBoundaries:M.pendingSuspenseBoundaries,transitions:M.transitions},d.updateQueue.baseState=C,d.memoizedState=C,d.flags&256){k=Kl(Error(n(423)),d),d=ov(l,d,x,p,k);break e}else if(x!==k){k=Kl(Error(n(424)),d),d=ov(l,d,x,p,k);break e}else for(tr=Ii(d.stateNode.containerInfo.firstChild),er=d,hn=!0,Br=null,p=bb(d,null,x,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Bl(),x===k){d=Qa(l,d,p);break e}Es(l,d,x,p)}d=d.child}return d;case 5:return kb(d),l===null&&em(d),x=d.type,k=d.pendingProps,C=l!==null?l.memoizedProps:null,M=k.children,Wp(x,k)?M=null:C!==null&&Wp(x,C)&&(d.flags|=32),rv(l,d),Es(l,d,M,p),d.child;case 6:return l===null&&em(d),null;case 13:return lv(l,d,p);case 4:return lm(d,d.stateNode.containerInfo),x=d.pendingProps,l===null?d.child=Vl(d,null,x,p):Es(l,d,x,p),d.child;case 11:return x=d.type,k=d.pendingProps,k=d.elementType===x?k:Vr(x,k),ev(l,d,x,k,p);case 7:return Es(l,d,d.pendingProps,p),d.child;case 8:return Es(l,d,d.pendingProps.children,p),d.child;case 12:return Es(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(x=d.type._context,k=d.pendingProps,C=d.memoizedProps,M=k.value,tn(Mu,x._currentValue),x._currentValue=M,C!==null)if(Fr(C.value,M)){if(C.children===k.children&&!$s.current){d=Qa(l,d,p);break e}}else for(C=d.child,C!==null&&(C.return=d);C!==null;){var W=C.dependencies;if(W!==null){M=C.child;for(var Z=W.firstContext;Z!==null;){if(Z.context===x){if(C.tag===1){Z=Ja(-1,p&-p),Z.tag=2;var pe=C.updateQueue;if(pe!==null){pe=pe.shared;var Te=pe.pending;Te===null?Z.next=Z:(Z.next=Te.next,Te.next=Z),pe.pending=Z}}C.lanes|=p,Z=C.alternate,Z!==null&&(Z.lanes|=p),am(C.return,p,d),W.lanes|=p;break}Z=Z.next}}else if(C.tag===10)M=C.type===d.type?null:C.child;else if(C.tag===18){if(M=C.return,M===null)throw Error(n(341));M.lanes|=p,W=M.alternate,W!==null&&(W.lanes|=p),am(M,p,d),M=C.sibling}else M=C.child;if(M!==null)M.return=C;else for(M=C;M!==null;){if(M===d){M=null;break}if(C=M.sibling,C!==null){C.return=M.return,M=C;break}M=M.return}C=M}Es(l,d,k.children,p),d=d.child}return d;case 9:return k=d.type,x=d.pendingProps.children,Ul(d,p),k=yr(k),x=x(k),d.flags|=1,Es(l,d,x,p),d.child;case 14:return x=d.type,k=Vr(x,d.pendingProps),k=Vr(x.type,k),tv(l,d,x,k,p);case 15:return nv(l,d,d.type,d.pendingProps,p);case 17:return x=d.type,k=d.pendingProps,k=d.elementType===x?k:Vr(x,k),Bu(l,d),d.tag=1,Fs(x)?(l=!0,ju(d)):l=!1,Ul(d,p),qb(d,x,k),Nm(d,x,k,p),Sm(null,d,x,!0,l,p);case 19:return dv(l,d,p);case 22:return sv(l,d,p)}throw Error(n(156,d.tag))};function Ov(l,d){return To(l,d)}function wT(l,d,p,x){this.tag=l,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=d,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=x,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Nr(l,d,p,x){return new wT(l,d,p,x)}function Wm(l){return l=l.prototype,!(!l||!l.isReactComponent)}function jT(l){if(typeof l=="function")return Wm(l)?1:0;if(l!=null){if(l=l.$$typeof,l===F)return 11;if(l===J)return 14}return 2}function Vi(l,d){var p=l.alternate;return p===null?(p=Nr(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 Xu(l,d,p,x,k,C){var M=2;if(x=l,typeof l=="function")Wm(l)&&(M=1);else if(typeof l=="string")M=5;else e:switch(l){case z:return Ko(p.children,k,C,d);case V:M=8,k|=8;break;case I:return l=Nr(12,p,d,k|2),l.elementType=I,l.lanes=C,l;case re:return l=Nr(13,p,d,k),l.elementType=re,l.lanes=C,l;case ae:return l=Nr(19,p,d,k),l.elementType=ae,l.lanes=C,l;case D:return Zu(p,k,C,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case te:M=10;break e;case Q:M=9;break e;case F:M=11;break e;case J:M=14;break e;case $:M=16,x=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=Nr(M,p,d,k),d.elementType=l,d.type=x,d.lanes=C,d}function Ko(l,d,p,x){return l=Nr(7,l,x,d),l.lanes=p,l}function Zu(l,d,p,x){return l=Nr(22,l,x,d),l.elementType=D,l.lanes=p,l.stateNode={isHidden:!1},l}function Km(l,d,p){return l=Nr(6,l,null,d),l.lanes=p,l}function qm(l,d,p){return d=Nr(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function kT(l,d,p,x,k){this.tag=d,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Os(0),this.expirationTimes=Os(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Os(0),this.identifierPrefix=x,this.onRecoverableError=k,this.mutableSourceEagerHydrationData=null}function Gm(l,d,p,x,k,C,M,W,Z){return l=new kT(l,d,p,W,Z),d===1?(d=1,C===!0&&(d|=8)):d=0,C=Nr(3,null,null,d),l.current=C,C.stateNode=l,C.memoizedState={element:x,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},om(C),l}function ST(l,d,p){var x=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),eg.exports=_T(),eg.exports}var Gv;function zT(){if(Gv)return ih;Gv=1;var t=dj();return ih.createRoot=t.createRoot,ih.hydrateRoot=t.hydrateRoot,ih}var $T=zT(),au=dj();const uj=cj(au);/** +`+C.stack}return{value:l,source:d,stack:k,digest:null}}function wm(l,d,p){return{value:l,source:null,stack:p??null,digest:d??null}}function jm(l,d){try{console.error(d.value)}catch(p){setTimeout(function(){throw p})}}var aT=typeof WeakMap=="function"?WeakMap:Map;function Jb(l,d,p){p=Ja(-1,p),p.tag=3,p.payload={element:null};var g=d.value;return p.callback=function(){Ku||(Ku=!0,zm=g),jm(l,d)},p}function Qb(l,d,p){p=Ja(-1,p),p.tag=3;var g=l.type.getDerivedStateFromError;if(typeof g=="function"){var k=d.value;p.payload=function(){return g(k)},p.callback=function(){jm(l,d)}}var C=l.stateNode;return C!==null&&typeof C.componentDidCatch=="function"&&(p.callback=function(){jm(l,d),typeof g!="function"&&(zi===null?zi=new Set([this]):zi.add(this));var M=d.stack;this.componentDidCatch(d.value,{componentStack:M!==null?M:""})}),p}function Yb(l,d,p){var g=l.pingCache;if(g===null){g=l.pingCache=new aT;var k=new Set;g.set(d,k)}else k=g.get(d),k===void 0&&(k=new Set,g.set(d,k));k.has(p)||(k.add(p),l=bT.bind(null,l,d,p),d.then(l,l))}function Xb(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 Zb(l,d,p,g,k){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=Ja(-1,1),d.tag=2,Di(p,d,1))),p.lanes|=1),l):(l.flags|=65536,l.lanes=k,l)}var iT=P.ReactCurrentOwner,Bs=!1;function Es(l,d,p,g){d.child=l===null?bb(d,null,p,g):Vl(d,l.child,p,g)}function ev(l,d,p,g,k){p=p.render;var C=d.ref;return Ul(d,k),g=pm(l,d,p,g,C,k),p=mm(),l!==null&&!Bs?(d.updateQueue=l.updateQueue,d.flags&=-2053,l.lanes&=~k,Qa(l,d,k)):(hn&&p&&Yp(d),d.flags|=1,Es(l,d,g,k),d.child)}function tv(l,d,p,g,k){if(l===null){var C=p.type;return typeof C=="function"&&!Wm(C)&&C.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(d.tag=15,d.type=C,nv(l,d,C,g,k)):(l=Xu(p.type,null,g,d,d.mode,k),l.ref=d.ref,l.return=d,d.child=l)}if(C=l.child,(l.lanes&k)===0){var M=C.memoizedProps;if(p=p.compare,p=p!==null?p:Jc,p(M,g)&&l.ref===d.ref)return Qa(l,d,k)}return d.flags|=1,l=Vi(C,g),l.ref=d.ref,l.return=d,d.child=l}function nv(l,d,p,g,k){if(l!==null){var C=l.memoizedProps;if(Jc(C,g)&&l.ref===d.ref)if(Bs=!1,d.pendingProps=g=C,(l.lanes&k)!==0)(l.flags&131072)!==0&&(Bs=!0);else return d.lanes=l.lanes,Qa(l,d,k)}return km(l,d,p,g,k)}function sv(l,d,p){var g=d.pendingProps,k=g.children,C=l!==null?l.memoizedState:null;if(g.mode==="hidden")if((d.mode&1)===0)d.memoizedState={baseLanes:0,cachePool:null,transitions:null},tn(Gl,sr),sr|=p;else{if((p&1073741824)===0)return l=C!==null?C.baseLanes|p:p,d.lanes=d.childLanes=1073741824,d.memoizedState={baseLanes:l,cachePool:null,transitions:null},d.updateQueue=null,tn(Gl,sr),sr|=l,null;d.memoizedState={baseLanes:0,cachePool:null,transitions:null},g=C!==null?C.baseLanes:p,tn(Gl,sr),sr|=g}else C!==null?(g=C.baseLanes|p,d.memoizedState=null):g=p,tn(Gl,sr),sr|=g;return Es(l,d,k,p),d.child}function rv(l,d){var p=d.ref;(l===null&&p!==null||l!==null&&l.ref!==p)&&(d.flags|=512,d.flags|=2097152)}function km(l,d,p,g,k){var C=Fs(p)?Do:ms.current;return C=zl(d,C),Ul(d,k),p=pm(l,d,p,g,C,k),g=mm(),l!==null&&!Bs?(d.updateQueue=l.updateQueue,d.flags&=-2053,l.lanes&=~k,Qa(l,d,k)):(hn&&g&&Yp(d),d.flags|=1,Es(l,d,p,k),d.child)}function av(l,d,p,g,k){if(Fs(p)){var C=!0;ju(d)}else C=!1;if(Ul(d,k),d.stateNode===null)Bu(l,d),qb(d,p,g),Nm(d,p,g,k),g=!0;else if(l===null){var M=d.stateNode,W=d.memoizedProps;M.props=W;var Z=M.context,pe=p.contextType;typeof pe=="object"&&pe!==null?pe=yr(pe):(pe=Fs(p)?Do:ms.current,pe=zl(d,pe));var Te=p.getDerivedStateFromProps,Ae=typeof Te=="function"||typeof M.getSnapshotBeforeUpdate=="function";Ae||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(W!==g||Z!==pe)&&Gb(d,M,g,pe),Li=!1;var Ce=d.memoizedState;M.state=Ce,Ru(d,g,M,k),Z=d.memoizedState,W!==g||Ce!==Z||$s.current||Li?(typeof Te=="function"&&(vm(d,p,Te,g),Z=d.memoizedState),(W=Li||Kb(d,p,W,g,Ce,Z,pe))?(Ae||typeof M.UNSAFE_componentWillMount!="function"&&typeof M.componentWillMount!="function"||(typeof M.componentWillMount=="function"&&M.componentWillMount(),typeof M.UNSAFE_componentWillMount=="function"&&M.UNSAFE_componentWillMount()),typeof M.componentDidMount=="function"&&(d.flags|=4194308)):(typeof M.componentDidMount=="function"&&(d.flags|=4194308),d.memoizedProps=g,d.memoizedState=Z),M.props=g,M.state=Z,M.context=pe,g=W):(typeof M.componentDidMount=="function"&&(d.flags|=4194308),g=!1)}else{M=d.stateNode,Nb(l,d),W=d.memoizedProps,pe=d.type===d.elementType?W:Vr(d.type,W),M.props=pe,Ae=d.pendingProps,Ce=M.context,Z=p.contextType,typeof Z=="object"&&Z!==null?Z=yr(Z):(Z=Fs(p)?Do:ms.current,Z=zl(d,Z));var Be=p.getDerivedStateFromProps;(Te=typeof Be=="function"||typeof M.getSnapshotBeforeUpdate=="function")||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(W!==Ae||Ce!==Z)&&Gb(d,M,g,Z),Li=!1,Ce=d.memoizedState,M.state=Ce,Ru(d,g,M,k);var We=d.memoizedState;W!==Ae||Ce!==We||$s.current||Li?(typeof Be=="function"&&(vm(d,p,Be,g),We=d.memoizedState),(pe=Li||Kb(d,p,pe,g,Ce,We,Z)||!1)?(Te||typeof M.UNSAFE_componentWillUpdate!="function"&&typeof M.componentWillUpdate!="function"||(typeof M.componentWillUpdate=="function"&&M.componentWillUpdate(g,We,Z),typeof M.UNSAFE_componentWillUpdate=="function"&&M.UNSAFE_componentWillUpdate(g,We,Z)),typeof M.componentDidUpdate=="function"&&(d.flags|=4),typeof M.getSnapshotBeforeUpdate=="function"&&(d.flags|=1024)):(typeof M.componentDidUpdate!="function"||W===l.memoizedProps&&Ce===l.memoizedState||(d.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||W===l.memoizedProps&&Ce===l.memoizedState||(d.flags|=1024),d.memoizedProps=g,d.memoizedState=We),M.props=g,M.state=We,M.context=Z,g=pe):(typeof M.componentDidUpdate!="function"||W===l.memoizedProps&&Ce===l.memoizedState||(d.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||W===l.memoizedProps&&Ce===l.memoizedState||(d.flags|=1024),g=!1)}return Sm(l,d,p,g,C,k)}function Sm(l,d,p,g,k,C){rv(l,d);var M=(d.flags&128)!==0;if(!g&&!M)return k&&db(d,p,!1),Qa(l,d,C);g=d.stateNode,iT.current=d;var W=M&&typeof p.getDerivedStateFromError!="function"?null:g.render();return d.flags|=1,l!==null&&M?(d.child=Vl(d,l.child,null,C),d.child=Vl(d,null,W,C)):Es(l,d,W,C),d.memoizedState=g.state,k&&db(d,p,!0),d.child}function iv(l){var d=l.stateNode;d.pendingContext?lb(l,d.pendingContext,d.pendingContext!==d.context):d.context&&lb(l,d.context,!1),lm(l,d.containerInfo)}function ov(l,d,p,g,k){return Bl(),tm(k),d.flags|=256,Es(l,d,p,g),d.child}var Cm={dehydrated:null,treeContext:null,retryLane:0};function Tm(l){return{baseLanes:l,cachePool:null,transitions:null}}function lv(l,d,p){var g=d.pendingProps,k=gn.current,C=!1,M=(d.flags&128)!==0,W;if((W=M)||(W=l!==null&&l.memoizedState===null?!1:(k&2)!==0),W?(C=!0,d.flags&=-129):(l===null||l.memoizedState!==null)&&(k|=1),tn(gn,k&1),l===null)return em(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):(M=g.children,l=g.fallback,C?(g=d.mode,C=d.child,M={mode:"hidden",children:M},(g&1)===0&&C!==null?(C.childLanes=0,C.pendingProps=M):C=Zu(M,g,0,null),l=Ko(l,g,p,null),C.return=d,l.return=d,C.sibling=l,d.child=C,d.child.memoizedState=Tm(p),d.memoizedState=Cm,l):Em(d,M));if(k=l.memoizedState,k!==null&&(W=k.dehydrated,W!==null))return oT(l,d,M,g,W,k,p);if(C){C=g.fallback,M=d.mode,k=l.child,W=k.sibling;var Z={mode:"hidden",children:g.children};return(M&1)===0&&d.child!==k?(g=d.child,g.childLanes=0,g.pendingProps=Z,d.deletions=null):(g=Vi(k,Z),g.subtreeFlags=k.subtreeFlags&14680064),W!==null?C=Vi(W,C):(C=Ko(C,M,p,null),C.flags|=2),C.return=d,g.return=d,g.sibling=C,d.child=g,g=C,C=d.child,M=l.child.memoizedState,M=M===null?Tm(p):{baseLanes:M.baseLanes|p,cachePool:null,transitions:M.transitions},C.memoizedState=M,C.childLanes=l.childLanes&~p,d.memoizedState=Cm,g}return C=l.child,l=C.sibling,g=Vi(C,{mode:"visible",children:g.children}),(d.mode&1)===0&&(g.lanes=p),g.return=d,g.sibling=null,l!==null&&(p=d.deletions,p===null?(d.deletions=[l],d.flags|=16):p.push(l)),d.child=g,d.memoizedState=null,g}function Em(l,d){return d=Zu({mode:"visible",children:d},l.mode,0,null),d.return=l,l.child=d}function Fu(l,d,p,g){return g!==null&&tm(g),Vl(d,l.child,null,p),l=Em(d,d.pendingProps.children),l.flags|=2,d.memoizedState=null,l}function oT(l,d,p,g,k,C,M){if(p)return d.flags&256?(d.flags&=-257,g=wm(Error(n(422))),Fu(l,d,M,g)):d.memoizedState!==null?(d.child=l.child,d.flags|=128,null):(C=g.fallback,k=d.mode,g=Zu({mode:"visible",children:g.children},k,0,null),C=Ko(C,k,M,null),C.flags|=2,g.return=d,C.return=d,g.sibling=C,d.child=g,(d.mode&1)!==0&&Vl(d,l.child,null,M),d.child.memoizedState=Tm(M),d.memoizedState=Cm,C);if((d.mode&1)===0)return Fu(l,d,M,null);if(k.data==="$!"){if(g=k.nextSibling&&k.nextSibling.dataset,g)var W=g.dgst;return g=W,C=Error(n(419)),g=wm(C,g,void 0),Fu(l,d,M,g)}if(W=(M&l.childLanes)!==0,Bs||W){if(g=Jn,g!==null){switch(M&-M){case 4:k=2;break;case 16:k=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:k=32;break;case 536870912:k=268435456;break;default:k=0}k=(k&(g.suspendedLanes|M))!==0?0:k,k!==0&&k!==C.retryLane&&(C.retryLane=k,Ga(l,k),Wr(g,l,k,-1))}return Um(),g=wm(Error(n(421))),Fu(l,d,M,g)}return k.data==="$?"?(d.flags|=128,d.child=l.child,d=vT.bind(null,l),k._reactRetry=d,null):(l=C.treeContext,nr=Ii(k.nextSibling),tr=d,hn=!0,Br=null,l!==null&&(xr[gr++]=Ka,xr[gr++]=qa,xr[gr++]=_o,Ka=l.id,qa=l.overflow,_o=d),d=Em(d,g.children),d.flags|=4096,d)}function cv(l,d,p){l.lanes|=d;var g=l.alternate;g!==null&&(g.lanes|=d),am(l.return,d,p)}function Mm(l,d,p,g,k){var C=l.memoizedState;C===null?l.memoizedState={isBackwards:d,rendering:null,renderingStartTime:0,last:g,tail:p,tailMode:k}:(C.isBackwards=d,C.rendering=null,C.renderingStartTime=0,C.last=g,C.tail=p,C.tailMode=k)}function dv(l,d,p){var g=d.pendingProps,k=g.revealOrder,C=g.tail;if(Es(l,d,g.children,p),g=gn.current,(g&2)!==0)g=g&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&&cv(l,p,d);else if(l.tag===19)cv(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}g&=1}if(tn(gn,g),(d.mode&1)===0)d.memoizedState=null;else switch(k){case"forwards":for(p=d.child,k=null;p!==null;)l=p.alternate,l!==null&&Pu(l)===null&&(k=p),p=p.sibling;p=k,p===null?(k=d.child,d.child=null):(k=p.sibling,p.sibling=null),Mm(d,!1,k,p,C);break;case"backwards":for(p=null,k=d.child,d.child=null;k!==null;){if(l=k.alternate,l!==null&&Pu(l)===null){d.child=k;break}l=k.sibling,k.sibling=p,p=k,k=l}Mm(d,!0,p,null,C);break;case"together":Mm(d,!1,null,null,void 0);break;default:d.memoizedState=null}return d.child}function Bu(l,d){(d.mode&1)===0&&l!==null&&(l.alternate=null,d.alternate=null,d.flags|=2)}function Qa(l,d,p){if(l!==null&&(d.dependencies=l.dependencies),Vo|=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=Vi(l,l.pendingProps),d.child=p,p.return=d;l.sibling!==null;)l=l.sibling,p=p.sibling=Vi(l,l.pendingProps),p.return=d;p.sibling=null}return d.child}function lT(l,d,p){switch(d.tag){case 3:iv(d),Bl();break;case 5:kb(d);break;case 1:Fs(d.type)&&ju(d);break;case 4:lm(d,d.stateNode.containerInfo);break;case 10:var g=d.type._context,k=d.memoizedProps.value;tn(Mu,g._currentValue),g._currentValue=k;break;case 13:if(g=d.memoizedState,g!==null)return g.dehydrated!==null?(tn(gn,gn.current&1),d.flags|=128,null):(p&d.child.childLanes)!==0?lv(l,d,p):(tn(gn,gn.current&1),l=Qa(l,d,p),l!==null?l.sibling:null);tn(gn,gn.current&1);break;case 19:if(g=(p&d.childLanes)!==0,(l.flags&128)!==0){if(g)return dv(l,d,p);d.flags|=128}if(k=d.memoizedState,k!==null&&(k.rendering=null,k.tail=null,k.lastEffect=null),tn(gn,gn.current),g)break;return null;case 22:case 23:return d.lanes=0,sv(l,d,p)}return Qa(l,d,p)}var uv,Am,hv,fv;uv=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}},Am=function(){},hv=function(l,d,p,g){var k=l.memoizedProps;if(k!==g){l=d.stateNode,Fo(ha.current);var C=null;switch(p){case"input":k=wt(l,k),g=wt(l,g),C=[];break;case"select":k=G({},k,{value:void 0}),g=G({},g,{value:void 0}),C=[];break;case"textarea":k=vn(l,k),g=vn(l,g),C=[];break;default:typeof k.onClick!="function"&&typeof g.onClick=="function"&&(l.onclick=vu)}pt(p,g);var M;p=null;for(pe in k)if(!g.hasOwnProperty(pe)&&k.hasOwnProperty(pe)&&k[pe]!=null)if(pe==="style"){var W=k[pe];for(M in W)W.hasOwnProperty(M)&&(p||(p={}),p[M]="")}else pe!=="dangerouslySetInnerHTML"&&pe!=="children"&&pe!=="suppressContentEditableWarning"&&pe!=="suppressHydrationWarning"&&pe!=="autoFocus"&&(a.hasOwnProperty(pe)?C||(C=[]):(C=C||[]).push(pe,null));for(pe in g){var Z=g[pe];if(W=k!=null?k[pe]:void 0,g.hasOwnProperty(pe)&&Z!==W&&(Z!=null||W!=null))if(pe==="style")if(W){for(M in W)!W.hasOwnProperty(M)||Z&&Z.hasOwnProperty(M)||(p||(p={}),p[M]="");for(M in Z)Z.hasOwnProperty(M)&&W[M]!==Z[M]&&(p||(p={}),p[M]=Z[M])}else p||(C||(C=[]),C.push(pe,p)),p=Z;else pe==="dangerouslySetInnerHTML"?(Z=Z?Z.__html:void 0,W=W?W.__html:void 0,Z!=null&&W!==Z&&(C=C||[]).push(pe,Z)):pe==="children"?typeof Z!="string"&&typeof Z!="number"||(C=C||[]).push(pe,""+Z):pe!=="suppressContentEditableWarning"&&pe!=="suppressHydrationWarning"&&(a.hasOwnProperty(pe)?(Z!=null&&pe==="onScroll"&&an("scroll",l),C||W===Z||(C=[])):(C=C||[]).push(pe,Z))}p&&(C=C||[]).push("style",p);var pe=C;(d.updateQueue=pe)&&(d.flags|=4)}},fv=function(l,d,p,g){p!==g&&(d.flags|=4)};function dd(l,d){if(!hn)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 g=null;p!==null;)p.alternate!==null&&(g=p),p=p.sibling;g===null?d||l.tail===null?l.tail=null:l.tail.sibling=null:g.sibling=null}}function gs(l){var d=l.alternate!==null&&l.alternate.child===l.child,p=0,g=0;if(d)for(var k=l.child;k!==null;)p|=k.lanes|k.childLanes,g|=k.subtreeFlags&14680064,g|=k.flags&14680064,k.return=l,k=k.sibling;else for(k=l.child;k!==null;)p|=k.lanes|k.childLanes,g|=k.subtreeFlags,g|=k.flags,k.return=l,k=k.sibling;return l.subtreeFlags|=g,l.childLanes=p,d}function cT(l,d,p){var g=d.pendingProps;switch(Xp(d),d.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return gs(d),null;case 1:return Fs(d.type)&&wu(),gs(d),null;case 3:return g=d.stateNode,Wl(),on($s),on(ms),um(),g.pendingContext&&(g.context=g.pendingContext,g.pendingContext=null),(l===null||l.child===null)&&(Tu(d)?d.flags|=4:l===null||l.memoizedState.isDehydrated&&(d.flags&256)===0||(d.flags|=1024,Br!==null&&(Bm(Br),Br=null))),Am(l,d),gs(d),null;case 5:cm(d);var k=Fo(ad.current);if(p=d.type,l!==null&&d.stateNode!=null)hv(l,d,p,g,k),l.ref!==d.ref&&(d.flags|=512,d.flags|=2097152);else{if(!g){if(d.stateNode===null)throw Error(n(166));return gs(d),null}if(l=Fo(ha.current),Tu(d)){g=d.stateNode,p=d.type;var C=d.memoizedProps;switch(g[ua]=d,g[ed]=C,l=(d.mode&1)!==0,p){case"dialog":an("cancel",g),an("close",g);break;case"iframe":case"object":case"embed":an("load",g);break;case"video":case"audio":for(k=0;k<\/script>",l=l.removeChild(l.firstChild)):typeof g.is=="string"?l=M.createElement(p,{is:g.is}):(l=M.createElement(p),p==="select"&&(M=l,g.multiple?M.multiple=!0:g.size&&(M.size=g.size))):l=M.createElementNS(l,p),l[ua]=d,l[ed]=g,uv(l,d,!1,!1),d.stateNode=l;e:{switch(M=Et(p,g),p){case"dialog":an("cancel",l),an("close",l),k=g;break;case"iframe":case"object":case"embed":an("load",l),k=g;break;case"video":case"audio":for(k=0;kJl&&(d.flags|=128,g=!0,dd(C,!1),d.lanes=4194304)}else{if(!g)if(l=Pu(M),l!==null){if(d.flags|=128,g=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),dd(C,!0),C.tail===null&&C.tailMode==="hidden"&&!M.alternate&&!hn)return gs(d),null}else 2*Mt()-C.renderingStartTime>Jl&&p!==1073741824&&(d.flags|=128,g=!0,dd(C,!1),d.lanes=4194304);C.isBackwards?(M.sibling=d.child,d.child=M):(p=C.last,p!==null?p.sibling=M:d.child=M,C.last=M)}return C.tail!==null?(d=C.tail,C.rendering=d,C.tail=d.sibling,C.renderingStartTime=Mt(),d.sibling=null,p=gn.current,tn(gn,g?p&1|2:p&1),d):(gs(d),null);case 22:case 23:return Hm(),g=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==g&&(d.flags|=8192),g&&(d.mode&1)!==0?(sr&1073741824)!==0&&(gs(d),d.subtreeFlags&6&&(d.flags|=8192)):gs(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function dT(l,d){switch(Xp(d),d.tag){case 1:return Fs(d.type)&&wu(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return Wl(),on($s),on(ms),um(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return cm(d),null;case 13:if(on(gn),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));Bl()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return on(gn),null;case 4:return Wl(),null;case 10:return rm(d.type._context),null;case 22:case 23:return Hm(),null;case 24:return null;default:return null}}var Vu=!1,ys=!1,uT=typeof WeakSet=="function"?WeakSet:Set,He=null;function ql(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(g){Nn(l,d,g)}else p.current=null}function Im(l,d,p){try{p()}catch(g){Nn(l,d,g)}}var pv=!1;function hT(l,d){if(Hp=$a,l=Ky(),Lp(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var g=p.getSelection&&p.getSelection();if(g&&g.rangeCount!==0){p=g.anchorNode;var k=g.anchorOffset,C=g.focusNode;g=g.focusOffset;try{p.nodeType,C.nodeType}catch{p=null;break e}var M=0,W=-1,Z=-1,pe=0,Te=0,Ae=l,Ce=null;t:for(;;){for(var Be;Ae!==p||k!==0&&Ae.nodeType!==3||(W=M+k),Ae!==C||g!==0&&Ae.nodeType!==3||(Z=M+g),Ae.nodeType===3&&(M+=Ae.nodeValue.length),(Be=Ae.firstChild)!==null;)Ce=Ae,Ae=Be;for(;;){if(Ae===l)break t;if(Ce===p&&++pe===k&&(W=M),Ce===C&&++Te===g&&(Z=M),(Be=Ae.nextSibling)!==null)break;Ae=Ce,Ce=Ae.parentNode}Ae=Be}p=W===-1||Z===-1?null:{start:W,end:Z}}else p=null}p=p||{start:0,end:0}}else p=null;for(Up={focusedElem:l,selectionRange:p},$a=!1,He=d;He!==null;)if(d=He,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,He=l;else for(;He!==null;){d=He;try{var We=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(We!==null){var Ge=We.memoizedProps,Mn=We.memoizedState,he=d.stateNode,ne=he.getSnapshotBeforeUpdate(d.elementType===d.type?Ge:Vr(d.type,Ge),Mn);he.__reactInternalSnapshotBeforeUpdate=ne}break;case 3:var fe=d.stateNode.containerInfo;fe.nodeType===1?fe.textContent="":fe.nodeType===9&&fe.documentElement&&fe.removeChild(fe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Re){Nn(d,d.return,Re)}if(l=d.sibling,l!==null){l.return=d.return,He=l;break}He=d.return}return We=pv,pv=!1,We}function ud(l,d,p){var g=d.updateQueue;if(g=g!==null?g.lastEffect:null,g!==null){var k=g=g.next;do{if((k.tag&l)===l){var C=k.destroy;k.destroy=void 0,C!==void 0&&Im(d,p,C)}k=k.next}while(k!==g)}}function Hu(l,d){if(d=d.updateQueue,d=d!==null?d.lastEffect:null,d!==null){var p=d=d.next;do{if((p.tag&l)===l){var g=p.create;p.destroy=g()}p=p.next}while(p!==d)}}function Rm(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 mv(l){var d=l.alternate;d!==null&&(l.alternate=null,mv(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[ua],delete d[ed],delete d[Gp],delete d[G4],delete d[J4])),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 xv(l){return l.tag===5||l.tag===3||l.tag===4}function gv(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||xv(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 Pm(l,d,p){var g=l.tag;if(g===5||g===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=vu));else if(g!==4&&(l=l.child,l!==null))for(Pm(l,d,p),l=l.sibling;l!==null;)Pm(l,d,p),l=l.sibling}function Om(l,d,p){var g=l.tag;if(g===5||g===6)l=l.stateNode,d?p.insertBefore(l,d):p.appendChild(l);else if(g!==4&&(l=l.child,l!==null))for(Om(l,d,p),l=l.sibling;l!==null;)Om(l,d,p),l=l.sibling}var rs=null,Hr=!1;function _i(l,d,p){for(p=p.child;p!==null;)yv(l,d,p),p=p.sibling}function yv(l,d,p){if(ns&&typeof ns.onCommitFiberUnmount=="function")try{ns.onCommitFiberUnmount(na,p)}catch{}switch(p.tag){case 5:ys||ql(p,d);case 6:var g=rs,k=Hr;rs=null,_i(l,d,p),rs=g,Hr=k,rs!==null&&(Hr?(l=rs,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):rs.removeChild(p.stateNode));break;case 18:rs!==null&&(Hr?(l=rs,p=p.stateNode,l.nodeType===8?qp(l.parentNode,p):l.nodeType===1&&qp(l,p),Dr(l)):qp(rs,p.stateNode));break;case 4:g=rs,k=Hr,rs=p.stateNode.containerInfo,Hr=!0,_i(l,d,p),rs=g,Hr=k;break;case 0:case 11:case 14:case 15:if(!ys&&(g=p.updateQueue,g!==null&&(g=g.lastEffect,g!==null))){k=g=g.next;do{var C=k,M=C.destroy;C=C.tag,M!==void 0&&((C&2)!==0||(C&4)!==0)&&Im(p,d,M),k=k.next}while(k!==g)}_i(l,d,p);break;case 1:if(!ys&&(ql(p,d),g=p.stateNode,typeof g.componentWillUnmount=="function"))try{g.props=p.memoizedProps,g.state=p.memoizedState,g.componentWillUnmount()}catch(W){Nn(p,d,W)}_i(l,d,p);break;case 21:_i(l,d,p);break;case 22:p.mode&1?(ys=(g=ys)||p.memoizedState!==null,_i(l,d,p),ys=g):_i(l,d,p);break;default:_i(l,d,p)}}function bv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new uT),d.forEach(function(g){var k=NT.bind(null,l,g);p.has(g)||(p.add(g),g.then(k,k))})}}function Ur(l,d){var p=d.deletions;if(p!==null)for(var g=0;gk&&(k=M),g&=~C}if(g=k,g=Mt()-g,g=(120>g?120:480>g?480:1080>g?1080:1920>g?1920:3e3>g?3e3:4320>g?4320:1960*pT(g/1960))-g,10l?16:l,$i===null)var g=!1;else{if(l=$i,$i=null,Gu=0,(It&6)!==0)throw Error(n(331));var k=It;for(It|=4,He=l.current;He!==null;){var C=He,M=C.child;if((He.flags&16)!==0){var W=C.deletions;if(W!==null){for(var Z=0;ZMt()-_m?Uo(l,0):Dm|=p),Hs(l,d)}function Rv(l,d){d===0&&((l.mode&1)===0?d=1:(d=Ra,Ra<<=1,(Ra&130023424)===0&&(Ra=4194304)));var p=Ms();l=Ga(l,d),l!==null&&(En(l,d,p),Hs(l,p))}function vT(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),Rv(l,p)}function NT(l,d){var p=0;switch(l.tag){case 13:var g=l.stateNode,k=l.memoizedState;k!==null&&(p=k.retryLane);break;case 19:g=l.stateNode;break;default:throw Error(n(314))}g!==null&&g.delete(d),Rv(l,p)}var Pv;Pv=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||$s.current)Bs=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return Bs=!1,lT(l,d,p);Bs=(l.flags&131072)!==0}else Bs=!1,hn&&(d.flags&1048576)!==0&&hb(d,Cu,d.index);switch(d.lanes=0,d.tag){case 2:var g=d.type;Bu(l,d),l=d.pendingProps;var k=zl(d,ms.current);Ul(d,p),k=pm(null,d,g,l,k,p);var C=mm();return d.flags|=1,typeof k=="object"&&k!==null&&typeof k.render=="function"&&k.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,Fs(g)?(C=!0,ju(d)):C=!1,d.memoizedState=k.state!==null&&k.state!==void 0?k.state:null,om(d),k.updater=$u,d.stateNode=k,k._reactInternals=d,Nm(d,g,l,p),d=Sm(null,d,g,!0,C,p)):(d.tag=0,hn&&C&&Yp(d),Es(null,d,k,p),d=d.child),d;case 16:g=d.elementType;e:{switch(Bu(l,d),l=d.pendingProps,k=g._init,g=k(g._payload),d.type=g,k=d.tag=jT(g),l=Vr(g,l),k){case 0:d=km(null,d,g,l,p);break e;case 1:d=av(null,d,g,l,p);break e;case 11:d=ev(null,d,g,l,p);break e;case 14:d=tv(null,d,g,Vr(g.type,l),p);break e}throw Error(n(306,g,""))}return d;case 0:return g=d.type,k=d.pendingProps,k=d.elementType===g?k:Vr(g,k),km(l,d,g,k,p);case 1:return g=d.type,k=d.pendingProps,k=d.elementType===g?k:Vr(g,k),av(l,d,g,k,p);case 3:e:{if(iv(d),l===null)throw Error(n(387));g=d.pendingProps,C=d.memoizedState,k=C.element,Nb(l,d),Ru(d,g,null,p);var M=d.memoizedState;if(g=M.element,C.isDehydrated)if(C={element:g,isDehydrated:!1,cache:M.cache,pendingSuspenseBoundaries:M.pendingSuspenseBoundaries,transitions:M.transitions},d.updateQueue.baseState=C,d.memoizedState=C,d.flags&256){k=Kl(Error(n(423)),d),d=ov(l,d,g,p,k);break e}else if(g!==k){k=Kl(Error(n(424)),d),d=ov(l,d,g,p,k);break e}else for(nr=Ii(d.stateNode.containerInfo.firstChild),tr=d,hn=!0,Br=null,p=bb(d,null,g,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Bl(),g===k){d=Qa(l,d,p);break e}Es(l,d,g,p)}d=d.child}return d;case 5:return kb(d),l===null&&em(d),g=d.type,k=d.pendingProps,C=l!==null?l.memoizedProps:null,M=k.children,Wp(g,k)?M=null:C!==null&&Wp(g,C)&&(d.flags|=32),rv(l,d),Es(l,d,M,p),d.child;case 6:return l===null&&em(d),null;case 13:return lv(l,d,p);case 4:return lm(d,d.stateNode.containerInfo),g=d.pendingProps,l===null?d.child=Vl(d,null,g,p):Es(l,d,g,p),d.child;case 11:return g=d.type,k=d.pendingProps,k=d.elementType===g?k:Vr(g,k),ev(l,d,g,k,p);case 7:return Es(l,d,d.pendingProps,p),d.child;case 8:return Es(l,d,d.pendingProps.children,p),d.child;case 12:return Es(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(g=d.type._context,k=d.pendingProps,C=d.memoizedProps,M=k.value,tn(Mu,g._currentValue),g._currentValue=M,C!==null)if(Fr(C.value,M)){if(C.children===k.children&&!$s.current){d=Qa(l,d,p);break e}}else for(C=d.child,C!==null&&(C.return=d);C!==null;){var W=C.dependencies;if(W!==null){M=C.child;for(var Z=W.firstContext;Z!==null;){if(Z.context===g){if(C.tag===1){Z=Ja(-1,p&-p),Z.tag=2;var pe=C.updateQueue;if(pe!==null){pe=pe.shared;var Te=pe.pending;Te===null?Z.next=Z:(Z.next=Te.next,Te.next=Z),pe.pending=Z}}C.lanes|=p,Z=C.alternate,Z!==null&&(Z.lanes|=p),am(C.return,p,d),W.lanes|=p;break}Z=Z.next}}else if(C.tag===10)M=C.type===d.type?null:C.child;else if(C.tag===18){if(M=C.return,M===null)throw Error(n(341));M.lanes|=p,W=M.alternate,W!==null&&(W.lanes|=p),am(M,p,d),M=C.sibling}else M=C.child;if(M!==null)M.return=C;else for(M=C;M!==null;){if(M===d){M=null;break}if(C=M.sibling,C!==null){C.return=M.return,M=C;break}M=M.return}C=M}Es(l,d,k.children,p),d=d.child}return d;case 9:return k=d.type,g=d.pendingProps.children,Ul(d,p),k=yr(k),g=g(k),d.flags|=1,Es(l,d,g,p),d.child;case 14:return g=d.type,k=Vr(g,d.pendingProps),k=Vr(g.type,k),tv(l,d,g,k,p);case 15:return nv(l,d,d.type,d.pendingProps,p);case 17:return g=d.type,k=d.pendingProps,k=d.elementType===g?k:Vr(g,k),Bu(l,d),d.tag=1,Fs(g)?(l=!0,ju(d)):l=!1,Ul(d,p),qb(d,g,k),Nm(d,g,k,p),Sm(null,d,g,!0,l,p);case 19:return dv(l,d,p);case 22:return sv(l,d,p)}throw Error(n(156,d.tag))};function Ov(l,d){return To(l,d)}function wT(l,d,p,g){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=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Nr(l,d,p,g){return new wT(l,d,p,g)}function Wm(l){return l=l.prototype,!(!l||!l.isReactComponent)}function jT(l){if(typeof l=="function")return Wm(l)?1:0;if(l!=null){if(l=l.$$typeof,l===F)return 11;if(l===J)return 14}return 2}function Vi(l,d){var p=l.alternate;return p===null?(p=Nr(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 Xu(l,d,p,g,k,C){var M=2;if(g=l,typeof l=="function")Wm(l)&&(M=1);else if(typeof l=="string")M=5;else e:switch(l){case z:return Ko(p.children,k,C,d);case V:M=8,k|=8;break;case I:return l=Nr(12,p,d,k|2),l.elementType=I,l.lanes=C,l;case re:return l=Nr(13,p,d,k),l.elementType=re,l.lanes=C,l;case ie:return l=Nr(19,p,d,k),l.elementType=ie,l.lanes=C,l;case D:return Zu(p,k,C,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case te:M=10;break e;case Q:M=9;break e;case F:M=11;break e;case J:M=14;break e;case $:M=16,g=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=Nr(M,p,d,k),d.elementType=l,d.type=g,d.lanes=C,d}function Ko(l,d,p,g){return l=Nr(7,l,g,d),l.lanes=p,l}function Zu(l,d,p,g){return l=Nr(22,l,g,d),l.elementType=D,l.lanes=p,l.stateNode={isHidden:!1},l}function Km(l,d,p){return l=Nr(6,l,null,d),l.lanes=p,l}function qm(l,d,p){return d=Nr(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function kT(l,d,p,g,k){this.tag=d,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Os(0),this.expirationTimes=Os(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Os(0),this.identifierPrefix=g,this.onRecoverableError=k,this.mutableSourceEagerHydrationData=null}function Gm(l,d,p,g,k,C,M,W,Z){return l=new kT(l,d,p,W,Z),d===1?(d=1,C===!0&&(d|=8)):d=0,C=Nr(3,null,null,d),l.current=C,C.stateNode=l,C.memoizedState={element:g,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},om(C),l}function ST(l,d,p){var g=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),ex.exports=_T(),ex.exports}var Gv;function zT(){if(Gv)return ih;Gv=1;var t=dj();return ih.createRoot=t.createRoot,ih.hydrateRoot=t.hydrateRoot,ih}var $T=zT(),au=dj();const uj=cj(au);/** * @remix-run/router v1.23.2 * * Copyright (c) Remix Software Inc. @@ -46,7 +46,7 @@ Error generating stack: `+C.message+` * LICENSE.md file in the root directory of this source tree. * * @license MIT - */function Vd(){return Vd=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function u0(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function BT(){return Math.random().toString(36).substr(2,8)}function Qv(t,e){return{usr:t.state,key:t.key,idx:e}}function ex(t,e,n,r){return n===void 0&&(n=null),Vd({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?Rc(e):e,{state:n,key:e&&e.key||r||BT()})}function Wh(t){let{pathname:e="/",search:n="",hash:r=""}=t;return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function Rc(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));let r=t.indexOf("?");r>=0&&(e.search=t.substr(r),t=t.substr(0,r)),t&&(e.pathname=t)}return e}function VT(t,e,n,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:i=!1}=r,o=a.history,c=to.Pop,u=null,h=f();h==null&&(h=0,o.replaceState(Vd({},o.state,{idx:h}),""));function f(){return(o.state||{idx:null}).idx}function m(){c=to.Pop;let j=f(),S=j==null?null:j-h;h=j,u&&u({action:c,location:w.location,delta:S})}function g(j,S){c=to.Push;let E=ex(w.location,j,S);h=f()+1;let T=Qv(E,h),P=w.createHref(E);try{o.pushState(T,"",P)}catch(O){if(O instanceof DOMException&&O.name==="DataCloneError")throw O;a.location.assign(P)}i&&u&&u({action:c,location:w.location,delta:1})}function y(j,S){c=to.Replace;let E=ex(w.location,j,S);h=f();let T=Qv(E,h),P=w.createHref(E);o.replaceState(T,"",P),i&&u&&u({action:c,location:w.location,delta:0})}function N(j){let S=a.location.origin!=="null"?a.location.origin:a.location.href,E=typeof j=="string"?j:Wh(j);return E=E.replace(/ $/,"%20"),Rn(S,"No window.location.(origin|href) available to create URL for href: "+E),new URL(E,S)}let w={get action(){return c},get location(){return t(a,o)},listen(j){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(Jv,m),u=j,()=>{a.removeEventListener(Jv,m),u=null}},createHref(j){return e(a,j)},createURL:N,encodeLocation(j){let S=N(j);return{pathname:S.pathname,search:S.search,hash:S.hash}},push:g,replace:y,go(j){return o.go(j)}};return w}var Yv;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(Yv||(Yv={}));function HT(t,e,n){return n===void 0&&(n="/"),UT(t,e,n)}function UT(t,e,n,r){let a=typeof e=="string"?Rc(e):e,i=h0(a.pathname||"/",n);if(i==null)return null;let o=hj(t);WT(o);let c=null;for(let u=0;c==null&&u{let u={relativePath:c===void 0?i.path||"":c,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};u.relativePath.startsWith("/")&&(Rn(u.relativePath.startsWith(r),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(r.length));let h=io([r,u.relativePath]),f=n.concat(u);i.children&&i.children.length>0&&(Rn(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),hj(i.children,e,f,h)),!(i.path==null&&!i.index)&&e.push({path:h,score:XT(h,i.index),routesMeta:f})};return t.forEach((i,o)=>{var c;if(i.path===""||!((c=i.path)!=null&&c.includes("?")))a(i,o);else for(let u of fj(i.path))a(i,o,u)}),e}function fj(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let o=fj(r.join("/")),c=[];return c.push(...o.map(u=>u===""?i:[i,u].join("/"))),a&&c.push(...o),c.map(u=>t.startsWith("/")&&u===""?"/":u)}function WT(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:ZT(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const KT=/^:[\w-]+$/,qT=3,GT=2,JT=1,QT=10,YT=-2,Xv=t=>t==="*";function XT(t,e){let n=t.split("/"),r=n.length;return n.some(Xv)&&(r+=YT),e&&(r+=GT),n.filter(a=>!Xv(a)).reduce((a,i)=>a+(KT.test(i)?qT:i===""?JT:QT),r)}function ZT(t,e){return t.length===e.length&&t.slice(0,-1).every((r,a)=>r===e[a])?t[t.length-1]-e[e.length-1]:0}function eE(t,e,n){let{routesMeta:r}=t,a={},i="/",o=[];for(let c=0;c{let{paramName:g,isOptional:y}=f;if(g==="*"){let w=c[m]||"";o=i.slice(0,i.length-w.length).replace(/(.)\/+$/,"$1")}const N=c[m];return y&&!N?h[g]=void 0:h[g]=(N||"").replace(/%2F/g,"/"),h},{}),pathname:i,pathnameBase:o,pattern:t}}function nE(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),u0(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let r=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,c,u)=>(r.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(r.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,e?void 0:"i"),r]}function sE(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return u0(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+e+").")),t}}function h0(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}const rE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,aE=t=>rE.test(t);function iE(t,e){e===void 0&&(e="/");let{pathname:n,search:r="",hash:a=""}=typeof t=="string"?Rc(t):t,i;if(n)if(aE(n))i=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),u0(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?i=Zv(n.substring(1),"/"):i=Zv(n,e)}else i=e;return{pathname:i,search:cE(r),hash:dE(a)}}function Zv(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function sg(t,e,n,r){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function oE(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function f0(t,e){let n=oE(t);return e?n.map((r,a)=>a===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function p0(t,e,n,r){r===void 0&&(r=!1);let a;typeof t=="string"?a=Rc(t):(a=Vd({},t),Rn(!a.pathname||!a.pathname.includes("?"),sg("?","pathname","search",a)),Rn(!a.pathname||!a.pathname.includes("#"),sg("#","pathname","hash",a)),Rn(!a.search||!a.search.includes("#"),sg("#","search","hash",a)));let i=t===""||a.pathname==="",o=i?"/":a.pathname,c;if(o==null)c=n;else{let m=e.length-1;if(!r&&o.startsWith("..")){let g=o.split("/");for(;g[0]==="..";)g.shift(),m-=1;a.pathname=g.join("/")}c=m>=0?e[m]:"/"}let u=iE(a,c),h=o&&o!=="/"&&o.endsWith("/"),f=(i||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||f)&&(u.pathname+="/"),u}const io=t=>t.join("/").replace(/\/\/+/g,"/"),lE=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),cE=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,dE=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function uE(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const pj=["post","put","patch","delete"];new Set(pj);const hE=["get",...pj];new Set(hE);/** + */function Vd(){return Vd=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function u0(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function BT(){return Math.random().toString(36).substr(2,8)}function Qv(t,e){return{usr:t.state,key:t.key,idx:e}}function eg(t,e,n,r){return n===void 0&&(n=null),Vd({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?Rc(e):e,{state:n,key:e&&e.key||r||BT()})}function Wh(t){let{pathname:e="/",search:n="",hash:r=""}=t;return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function Rc(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));let r=t.indexOf("?");r>=0&&(e.search=t.substr(r),t=t.substr(0,r)),t&&(e.pathname=t)}return e}function VT(t,e,n,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:i=!1}=r,o=a.history,c=to.Pop,u=null,h=f();h==null&&(h=0,o.replaceState(Vd({},o.state,{idx:h}),""));function f(){return(o.state||{idx:null}).idx}function m(){c=to.Pop;let j=f(),S=j==null?null:j-h;h=j,u&&u({action:c,location:w.location,delta:S})}function x(j,S){c=to.Push;let E=eg(w.location,j,S);h=f()+1;let T=Qv(E,h),P=w.createHref(E);try{o.pushState(T,"",P)}catch(O){if(O instanceof DOMException&&O.name==="DataCloneError")throw O;a.location.assign(P)}i&&u&&u({action:c,location:w.location,delta:1})}function y(j,S){c=to.Replace;let E=eg(w.location,j,S);h=f();let T=Qv(E,h),P=w.createHref(E);o.replaceState(T,"",P),i&&u&&u({action:c,location:w.location,delta:0})}function N(j){let S=a.location.origin!=="null"?a.location.origin:a.location.href,E=typeof j=="string"?j:Wh(j);return E=E.replace(/ $/,"%20"),Rn(S,"No window.location.(origin|href) available to create URL for href: "+E),new URL(E,S)}let w={get action(){return c},get location(){return t(a,o)},listen(j){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(Jv,m),u=j,()=>{a.removeEventListener(Jv,m),u=null}},createHref(j){return e(a,j)},createURL:N,encodeLocation(j){let S=N(j);return{pathname:S.pathname,search:S.search,hash:S.hash}},push:x,replace:y,go(j){return o.go(j)}};return w}var Yv;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(Yv||(Yv={}));function HT(t,e,n){return n===void 0&&(n="/"),UT(t,e,n)}function UT(t,e,n,r){let a=typeof e=="string"?Rc(e):e,i=h0(a.pathname||"/",n);if(i==null)return null;let o=hj(t);WT(o);let c=null;for(let u=0;c==null&&u{let u={relativePath:c===void 0?i.path||"":c,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};u.relativePath.startsWith("/")&&(Rn(u.relativePath.startsWith(r),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(r.length));let h=io([r,u.relativePath]),f=n.concat(u);i.children&&i.children.length>0&&(Rn(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),hj(i.children,e,f,h)),!(i.path==null&&!i.index)&&e.push({path:h,score:XT(h,i.index),routesMeta:f})};return t.forEach((i,o)=>{var c;if(i.path===""||!((c=i.path)!=null&&c.includes("?")))a(i,o);else for(let u of fj(i.path))a(i,o,u)}),e}function fj(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let o=fj(r.join("/")),c=[];return c.push(...o.map(u=>u===""?i:[i,u].join("/"))),a&&c.push(...o),c.map(u=>t.startsWith("/")&&u===""?"/":u)}function WT(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:ZT(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const KT=/^:[\w-]+$/,qT=3,GT=2,JT=1,QT=10,YT=-2,Xv=t=>t==="*";function XT(t,e){let n=t.split("/"),r=n.length;return n.some(Xv)&&(r+=YT),e&&(r+=GT),n.filter(a=>!Xv(a)).reduce((a,i)=>a+(KT.test(i)?qT:i===""?JT:QT),r)}function ZT(t,e){return t.length===e.length&&t.slice(0,-1).every((r,a)=>r===e[a])?t[t.length-1]-e[e.length-1]:0}function eE(t,e,n){let{routesMeta:r}=t,a={},i="/",o=[];for(let c=0;c{let{paramName:x,isOptional:y}=f;if(x==="*"){let w=c[m]||"";o=i.slice(0,i.length-w.length).replace(/(.)\/+$/,"$1")}const N=c[m];return y&&!N?h[x]=void 0:h[x]=(N||"").replace(/%2F/g,"/"),h},{}),pathname:i,pathnameBase:o,pattern:t}}function nE(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),u0(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let r=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,c,u)=>(r.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(r.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,e?void 0:"i"),r]}function sE(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return u0(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+e+").")),t}}function h0(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}const rE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,aE=t=>rE.test(t);function iE(t,e){e===void 0&&(e="/");let{pathname:n,search:r="",hash:a=""}=typeof t=="string"?Rc(t):t,i;if(n)if(aE(n))i=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),u0(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?i=Zv(n.substring(1),"/"):i=Zv(n,e)}else i=e;return{pathname:i,search:cE(r),hash:dE(a)}}function Zv(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function sx(t,e,n,r){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function oE(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function f0(t,e){let n=oE(t);return e?n.map((r,a)=>a===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function p0(t,e,n,r){r===void 0&&(r=!1);let a;typeof t=="string"?a=Rc(t):(a=Vd({},t),Rn(!a.pathname||!a.pathname.includes("?"),sx("?","pathname","search",a)),Rn(!a.pathname||!a.pathname.includes("#"),sx("#","pathname","hash",a)),Rn(!a.search||!a.search.includes("#"),sx("#","search","hash",a)));let i=t===""||a.pathname==="",o=i?"/":a.pathname,c;if(o==null)c=n;else{let m=e.length-1;if(!r&&o.startsWith("..")){let x=o.split("/");for(;x[0]==="..";)x.shift(),m-=1;a.pathname=x.join("/")}c=m>=0?e[m]:"/"}let u=iE(a,c),h=o&&o!=="/"&&o.endsWith("/"),f=(i||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||f)&&(u.pathname+="/"),u}const io=t=>t.join("/").replace(/\/\/+/g,"/"),lE=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),cE=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,dE=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function uE(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const pj=["post","put","patch","delete"];new Set(pj);const hE=["get",...pj];new Set(hE);/** * React Router v6.30.3 * * Copyright (c) Remix Software Inc. @@ -55,7 +55,7 @@ Error generating stack: `+C.message+` * LICENSE.md file in the root directory of this source tree. * * @license MIT - */function Hd(){return Hd=Object.assign?Object.assign.bind():function(t){for(var e=1;e{c.current=!0}),b.useCallback(function(h,f){if(f===void 0&&(f={}),!c.current)return;if(typeof h=="number"){r.go(h);return}let m=p0(h,JSON.parse(o),i,f.relative==="path");t==null&&e!=="/"&&(m.pathname=m.pathname==="/"?e:io([e,m.pathname])),(f.replace?r.replace:r.push)(m,f.state,f)},[e,r,o,i,t])}const gE=b.createContext(null);function xE(t){let e=b.useContext(xi).outlet;return e&&b.createElement(gE.Provider,{value:t},e)}function xj(t,e){let{relative:n}=e===void 0?{}:e,{future:r}=b.useContext(bo),{matches:a}=b.useContext(xi),{pathname:i}=vo(),o=JSON.stringify(f0(a,r.v7_relativeSplatPath));return b.useMemo(()=>p0(t,JSON.parse(o),i,n==="path"),[t,o,i,n])}function yE(t,e){return bE(t,e)}function bE(t,e,n,r){Pc()||Rn(!1);let{navigator:a}=b.useContext(bo),{matches:i}=b.useContext(xi),o=i[i.length-1],c=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let h=vo(),f;if(e){var m;let j=typeof e=="string"?Rc(e):e;u==="/"||(m=j.pathname)!=null&&m.startsWith(u)||Rn(!1),f=j}else f=h;let g=f.pathname||"/",y=g;if(u!=="/"){let j=u.replace(/^\//,"").split("/");y="/"+g.replace(/^\//,"").split("/").slice(j.length).join("/")}let N=HT(t,{pathname:y}),w=kE(N&&N.map(j=>Object.assign({},j,{params:Object.assign({},c,j.params),pathname:io([u,a.encodeLocation?a.encodeLocation(j.pathname).pathname:j.pathname]),pathnameBase:j.pathnameBase==="/"?u:io([u,a.encodeLocation?a.encodeLocation(j.pathnameBase).pathname:j.pathnameBase])})),i,n,r);return e&&w?b.createElement(Xf.Provider,{value:{location:Hd({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:to.Pop}},w):w}function vE(){let t=EE(),e=uE(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return b.createElement(b.Fragment,null,b.createElement("h2",null,"Unexpected Application Error!"),b.createElement("h3",{style:{fontStyle:"italic"}},e),n?b.createElement("pre",{style:a},n):null,null)}const NE=b.createElement(vE,null);class wE extends b.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,n){return n.location!==e.location||n.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:n.error,location:n.location,revalidation:e.revalidation||n.revalidation}}componentDidCatch(e,n){console.error("React Router caught the following error during render",e,n)}render(){return this.state.error!==void 0?b.createElement(xi.Provider,{value:this.props.routeContext},b.createElement(mj.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function jE(t){let{routeContext:e,match:n,children:r}=t,a=b.useContext(m0);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),b.createElement(xi.Provider,{value:e},r)}function kE(t,e,n,r){var a;if(e===void 0&&(e=[]),n===void 0&&(n=null),r===void 0&&(r=null),t==null){var i;if(!n)return null;if(n.errors)t=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let o=t,c=(a=n)==null?void 0:a.errors;if(c!=null){let f=o.findIndex(m=>m.route.id&&(c==null?void 0:c[m.route.id])!==void 0);f>=0||Rn(!1),o=o.slice(0,Math.min(o.length,f+1))}let u=!1,h=-1;if(n&&r&&r.v7_partialHydration)for(let f=0;f=0?o=o.slice(0,h+1):o=[o[0]];break}}}return o.reduceRight((f,m,g)=>{let y,N=!1,w=null,j=null;n&&(y=c&&m.route.id?c[m.route.id]:void 0,w=m.route.errorElement||NE,u&&(h<0&&g===0?(AE("route-fallback"),N=!0,j=null):h===g&&(N=!0,j=m.route.hydrateFallbackElement||null)));let S=e.concat(o.slice(0,g+1)),E=()=>{let T;return y?T=w:N?T=j:m.route.Component?T=b.createElement(m.route.Component,null):m.route.element?T=m.route.element:T=f,b.createElement(jE,{match:m,routeContext:{outlet:f,matches:S,isDataRoute:n!=null},children:T})};return n&&(m.route.ErrorBoundary||m.route.errorElement||g===0)?b.createElement(wE,{location:n.location,revalidation:n.revalidation,component:w,error:y,children:E(),routeContext:{outlet:null,matches:S,isDataRoute:!0}}):E()},null)}var yj=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(yj||{}),bj=(function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t})(bj||{});function SE(t){let e=b.useContext(m0);return e||Rn(!1),e}function CE(t){let e=b.useContext(fE);return e||Rn(!1),e}function TE(t){let e=b.useContext(xi);return e||Rn(!1),e}function vj(t){let e=TE(),n=e.matches[e.matches.length-1];return n.route.id||Rn(!1),n.route.id}function EE(){var t;let e=b.useContext(mj),n=CE(),r=vj();return e!==void 0?e:(t=n.errors)==null?void 0:t[r]}function ME(){let{router:t}=SE(yj.UseNavigateStable),e=vj(bj.UseNavigateStable),n=b.useRef(!1);return gj(()=>{n.current=!0}),b.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,Hd({fromRouteId:e},i)))},[t,e])}const e1={};function AE(t,e,n){e1[t]||(e1[t]=!0)}function IE(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function oh(t){let{to:e,replace:n,state:r,relative:a}=t;Pc()||Rn(!1);let{future:i,static:o}=b.useContext(bo),{matches:c}=b.useContext(xi),{pathname:u}=vo(),h=Sa(),f=p0(e,f0(c,i.v7_relativeSplatPath),u,a==="path"),m=JSON.stringify(f);return b.useEffect(()=>h(JSON.parse(m),{replace:n,state:r,relative:a}),[h,m,a,n,r]),null}function RE(t){return xE(t.context)}function nn(t){Rn(!1)}function PE(t){let{basename:e="/",children:n=null,location:r,navigationType:a=to.Pop,navigator:i,static:o=!1,future:c}=t;Pc()&&Rn(!1);let u=e.replace(/^\/*/,"/"),h=b.useMemo(()=>({basename:u,navigator:i,static:o,future:Hd({v7_relativeSplatPath:!1},c)}),[u,c,i,o]);typeof r=="string"&&(r=Rc(r));let{pathname:f="/",search:m="",hash:g="",state:y=null,key:N="default"}=r,w=b.useMemo(()=>{let j=h0(f,u);return j==null?null:{location:{pathname:j,search:m,hash:g,state:y,key:N},navigationType:a}},[u,f,m,g,y,N,a]);return w==null?null:b.createElement(bo.Provider,{value:h},b.createElement(Xf.Provider,{children:n,value:w}))}function OE(t){let{children:e,location:n}=t;return yE(tx(e),n)}new Promise(()=>{});function tx(t,e){e===void 0&&(e=[]);let n=[];return b.Children.forEach(t,(r,a)=>{if(!b.isValidElement(r))return;let i=[...e,a];if(r.type===b.Fragment){n.push.apply(n,tx(r.props.children,i));return}r.type!==nn&&Rn(!1),!r.props.index||!r.props.children||Rn(!1);let o={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=tx(r.props.children,i)),n.push(o)}),n}/** + */function Hd(){return Hd=Object.assign?Object.assign.bind():function(t){for(var e=1;e{c.current=!0}),b.useCallback(function(h,f){if(f===void 0&&(f={}),!c.current)return;if(typeof h=="number"){r.go(h);return}let m=p0(h,JSON.parse(o),i,f.relative==="path");t==null&&e!=="/"&&(m.pathname=m.pathname==="/"?e:io([e,m.pathname])),(f.replace?r.replace:r.push)(m,f.state,f)},[e,r,o,i,t])}const xE=b.createContext(null);function gE(t){let e=b.useContext(gi).outlet;return e&&b.createElement(xE.Provider,{value:t},e)}function gj(t,e){let{relative:n}=e===void 0?{}:e,{future:r}=b.useContext(bo),{matches:a}=b.useContext(gi),{pathname:i}=vo(),o=JSON.stringify(f0(a,r.v7_relativeSplatPath));return b.useMemo(()=>p0(t,JSON.parse(o),i,n==="path"),[t,o,i,n])}function yE(t,e){return bE(t,e)}function bE(t,e,n,r){Pc()||Rn(!1);let{navigator:a}=b.useContext(bo),{matches:i}=b.useContext(gi),o=i[i.length-1],c=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let h=vo(),f;if(e){var m;let j=typeof e=="string"?Rc(e):e;u==="/"||(m=j.pathname)!=null&&m.startsWith(u)||Rn(!1),f=j}else f=h;let x=f.pathname||"/",y=x;if(u!=="/"){let j=u.replace(/^\//,"").split("/");y="/"+x.replace(/^\//,"").split("/").slice(j.length).join("/")}let N=HT(t,{pathname:y}),w=kE(N&&N.map(j=>Object.assign({},j,{params:Object.assign({},c,j.params),pathname:io([u,a.encodeLocation?a.encodeLocation(j.pathname).pathname:j.pathname]),pathnameBase:j.pathnameBase==="/"?u:io([u,a.encodeLocation?a.encodeLocation(j.pathnameBase).pathname:j.pathnameBase])})),i,n,r);return e&&w?b.createElement(Xf.Provider,{value:{location:Hd({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:to.Pop}},w):w}function vE(){let t=EE(),e=uE(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return b.createElement(b.Fragment,null,b.createElement("h2",null,"Unexpected Application Error!"),b.createElement("h3",{style:{fontStyle:"italic"}},e),n?b.createElement("pre",{style:a},n):null,null)}const NE=b.createElement(vE,null);class wE extends b.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,n){return n.location!==e.location||n.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:n.error,location:n.location,revalidation:e.revalidation||n.revalidation}}componentDidCatch(e,n){console.error("React Router caught the following error during render",e,n)}render(){return this.state.error!==void 0?b.createElement(gi.Provider,{value:this.props.routeContext},b.createElement(mj.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function jE(t){let{routeContext:e,match:n,children:r}=t,a=b.useContext(m0);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),b.createElement(gi.Provider,{value:e},r)}function kE(t,e,n,r){var a;if(e===void 0&&(e=[]),n===void 0&&(n=null),r===void 0&&(r=null),t==null){var i;if(!n)return null;if(n.errors)t=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let o=t,c=(a=n)==null?void 0:a.errors;if(c!=null){let f=o.findIndex(m=>m.route.id&&(c==null?void 0:c[m.route.id])!==void 0);f>=0||Rn(!1),o=o.slice(0,Math.min(o.length,f+1))}let u=!1,h=-1;if(n&&r&&r.v7_partialHydration)for(let f=0;f=0?o=o.slice(0,h+1):o=[o[0]];break}}}return o.reduceRight((f,m,x)=>{let y,N=!1,w=null,j=null;n&&(y=c&&m.route.id?c[m.route.id]:void 0,w=m.route.errorElement||NE,u&&(h<0&&x===0?(AE("route-fallback"),N=!0,j=null):h===x&&(N=!0,j=m.route.hydrateFallbackElement||null)));let S=e.concat(o.slice(0,x+1)),E=()=>{let T;return y?T=w:N?T=j:m.route.Component?T=b.createElement(m.route.Component,null):m.route.element?T=m.route.element:T=f,b.createElement(jE,{match:m,routeContext:{outlet:f,matches:S,isDataRoute:n!=null},children:T})};return n&&(m.route.ErrorBoundary||m.route.errorElement||x===0)?b.createElement(wE,{location:n.location,revalidation:n.revalidation,component:w,error:y,children:E(),routeContext:{outlet:null,matches:S,isDataRoute:!0}}):E()},null)}var yj=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(yj||{}),bj=(function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t})(bj||{});function SE(t){let e=b.useContext(m0);return e||Rn(!1),e}function CE(t){let e=b.useContext(fE);return e||Rn(!1),e}function TE(t){let e=b.useContext(gi);return e||Rn(!1),e}function vj(t){let e=TE(),n=e.matches[e.matches.length-1];return n.route.id||Rn(!1),n.route.id}function EE(){var t;let e=b.useContext(mj),n=CE(),r=vj();return e!==void 0?e:(t=n.errors)==null?void 0:t[r]}function ME(){let{router:t}=SE(yj.UseNavigateStable),e=vj(bj.UseNavigateStable),n=b.useRef(!1);return xj(()=>{n.current=!0}),b.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,Hd({fromRouteId:e},i)))},[t,e])}const e1={};function AE(t,e,n){e1[t]||(e1[t]=!0)}function IE(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function oh(t){let{to:e,replace:n,state:r,relative:a}=t;Pc()||Rn(!1);let{future:i,static:o}=b.useContext(bo),{matches:c}=b.useContext(gi),{pathname:u}=vo(),h=Sa(),f=p0(e,f0(c,i.v7_relativeSplatPath),u,a==="path"),m=JSON.stringify(f);return b.useEffect(()=>h(JSON.parse(m),{replace:n,state:r,relative:a}),[h,m,a,n,r]),null}function RE(t){return gE(t.context)}function nn(t){Rn(!1)}function PE(t){let{basename:e="/",children:n=null,location:r,navigationType:a=to.Pop,navigator:i,static:o=!1,future:c}=t;Pc()&&Rn(!1);let u=e.replace(/^\/*/,"/"),h=b.useMemo(()=>({basename:u,navigator:i,static:o,future:Hd({v7_relativeSplatPath:!1},c)}),[u,c,i,o]);typeof r=="string"&&(r=Rc(r));let{pathname:f="/",search:m="",hash:x="",state:y=null,key:N="default"}=r,w=b.useMemo(()=>{let j=h0(f,u);return j==null?null:{location:{pathname:j,search:m,hash:x,state:y,key:N},navigationType:a}},[u,f,m,x,y,N,a]);return w==null?null:b.createElement(bo.Provider,{value:h},b.createElement(Xf.Provider,{children:n,value:w}))}function OE(t){let{children:e,location:n}=t;return yE(tg(e),n)}new Promise(()=>{});function tg(t,e){e===void 0&&(e=[]);let n=[];return b.Children.forEach(t,(r,a)=>{if(!b.isValidElement(r))return;let i=[...e,a];if(r.type===b.Fragment){n.push.apply(n,tg(r.props.children,i));return}r.type!==nn&&Rn(!1),!r.props.index||!r.props.children||Rn(!1);let o={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=tg(r.props.children,i)),n.push(o)}),n}/** * React Router DOM v6.30.3 * * Copyright (c) Remix Software Inc. @@ -64,7 +64,7 @@ Error generating stack: `+C.message+` * LICENSE.md file in the root directory of this source tree. * * @license MIT - */function nx(){return nx=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(n[a]=t[a]);return n}function DE(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function _E(t,e){return t.button===0&&(!e||e==="_self")&&!DE(t)}function sx(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let r=t[n];return e.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function zE(t,e){let n=sx(t);return e&&e.forEach((r,a)=>{n.has(a)||e.getAll(a).forEach(i=>{n.append(a,i)})}),n}const $E=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],FE="6";try{window.__reactRouterVersion=FE}catch{}const BE="startTransition",t1=Yf[BE];function VE(t){let{basename:e,children:n,future:r,window:a}=t,i=b.useRef();i.current==null&&(i.current=FT({window:a,v5Compat:!0}));let o=i.current,[c,u]=b.useState({action:o.action,location:o.location}),{v7_startTransition:h}=r||{},f=b.useCallback(m=>{h&&t1?t1(()=>u(m)):u(m)},[u,h]);return b.useLayoutEffect(()=>o.listen(f),[o,f]),b.useEffect(()=>IE(r),[r]),b.createElement(PE,{basename:e,children:n,location:c.location,navigationType:c.action,navigator:o,future:r})}const HE=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",UE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,bc=b.forwardRef(function(e,n){let{onClick:r,relative:a,reloadDocument:i,replace:o,state:c,target:u,to:h,preventScrollReset:f,viewTransition:m}=e,g=LE(e,$E),{basename:y}=b.useContext(bo),N,w=!1;if(typeof h=="string"&&UE.test(h)&&(N=h,HE))try{let T=new URL(window.location.href),P=h.startsWith("//")?new URL(T.protocol+h):new URL(h),O=h0(P.pathname,y);P.origin===T.origin&&O!=null?h=O+P.search+P.hash:w=!0}catch{}let j=pE(h,{relative:a}),S=WE(h,{replace:o,state:c,target:u,preventScrollReset:f,relative:a,viewTransition:m});function E(T){r&&r(T),T.defaultPrevented||S(T)}return b.createElement("a",nx({},g,{href:N||j,onClick:w||i?r:E,ref:n,target:u}))});var n1;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(n1||(n1={}));var s1;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(s1||(s1={}));function WE(t,e){let{target:n,replace:r,state:a,preventScrollReset:i,relative:o,viewTransition:c}=e===void 0?{}:e,u=Sa(),h=vo(),f=xj(t,{relative:o});return b.useCallback(m=>{if(_E(m,n)){m.preventDefault();let g=r!==void 0?r:Wh(h)===Wh(f);u(t,{replace:g,state:a,preventScrollReset:i,relative:o,viewTransition:c})}},[h,u,f,r,a,n,t,i,o,c])}function g0(t){let e=b.useRef(sx(t)),n=b.useRef(!1),r=vo(),a=b.useMemo(()=>zE(r.search,n.current?null:e.current),[r.search]),i=Sa(),o=b.useCallback((c,u)=>{const h=sx(typeof c=="function"?c(a):c);n.current=!0,i("?"+h,u)},[i,a]);return[a,o]}/** + */function ng(){return ng=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(n[a]=t[a]);return n}function DE(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function _E(t,e){return t.button===0&&(!e||e==="_self")&&!DE(t)}function sg(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let r=t[n];return e.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function zE(t,e){let n=sg(t);return e&&e.forEach((r,a)=>{n.has(a)||e.getAll(a).forEach(i=>{n.append(a,i)})}),n}const $E=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],FE="6";try{window.__reactRouterVersion=FE}catch{}const BE="startTransition",t1=Yf[BE];function VE(t){let{basename:e,children:n,future:r,window:a}=t,i=b.useRef();i.current==null&&(i.current=FT({window:a,v5Compat:!0}));let o=i.current,[c,u]=b.useState({action:o.action,location:o.location}),{v7_startTransition:h}=r||{},f=b.useCallback(m=>{h&&t1?t1(()=>u(m)):u(m)},[u,h]);return b.useLayoutEffect(()=>o.listen(f),[o,f]),b.useEffect(()=>IE(r),[r]),b.createElement(PE,{basename:e,children:n,location:c.location,navigationType:c.action,navigator:o,future:r})}const HE=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",UE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,bc=b.forwardRef(function(e,n){let{onClick:r,relative:a,reloadDocument:i,replace:o,state:c,target:u,to:h,preventScrollReset:f,viewTransition:m}=e,x=LE(e,$E),{basename:y}=b.useContext(bo),N,w=!1;if(typeof h=="string"&&UE.test(h)&&(N=h,HE))try{let T=new URL(window.location.href),P=h.startsWith("//")?new URL(T.protocol+h):new URL(h),O=h0(P.pathname,y);P.origin===T.origin&&O!=null?h=O+P.search+P.hash:w=!0}catch{}let j=pE(h,{relative:a}),S=WE(h,{replace:o,state:c,target:u,preventScrollReset:f,relative:a,viewTransition:m});function E(T){r&&r(T),T.defaultPrevented||S(T)}return b.createElement("a",ng({},x,{href:N||j,onClick:w||i?r:E,ref:n,target:u}))});var n1;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(n1||(n1={}));var s1;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(s1||(s1={}));function WE(t,e){let{target:n,replace:r,state:a,preventScrollReset:i,relative:o,viewTransition:c}=e===void 0?{}:e,u=Sa(),h=vo(),f=gj(t,{relative:o});return b.useCallback(m=>{if(_E(m,n)){m.preventDefault();let x=r!==void 0?r:Wh(h)===Wh(f);u(t,{replace:x,state:a,preventScrollReset:i,relative:o,viewTransition:c})}},[h,u,f,r,a,n,t,i,o,c])}function x0(t){let e=b.useRef(sg(t)),n=b.useRef(!1),r=vo(),a=b.useMemo(()=>zE(r.search,n.current?null:e.current),[r.search]),i=Sa(),o=b.useCallback((c,u)=>{const h=sg(typeof c=="function"?c(a):c);n.current=!0,i("?"+h,u)},[i,a]);return[a,o]}/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -89,7 +89,7 @@ Error generating stack: `+C.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const YE=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],rg=Ee("arrow-up-down",YE);/** + */const YE=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],rx=Ee("arrow-up-down",YE);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -109,12 +109,12 @@ Error generating stack: `+C.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const s5=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],qs=Ee("book-open",s5);/** + */const s5=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Gs=Ee("book-open",s5);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const r5=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],rx=Ee("calendar",r5);/** + */const r5=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],rg=Ee("calendar",r5);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -144,7 +144,7 @@ Error generating stack: `+C.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const u5=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],ax=Ee("chevron-up",u5);/** + */const u5=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],ag=Ee("chevron-up",u5);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -154,7 +154,7 @@ Error generating stack: `+C.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const f5=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],ag=Ee("circle-check-big",f5);/** + */const f5=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],ax=Ee("circle-check-big",f5);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -169,17 +169,17 @@ Error generating stack: `+C.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const g5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]],lh=Ee("circle-user",g5);/** + */const x5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]],lh=Ee("circle-user",x5);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const x5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Sj=Ee("circle-x",x5);/** + */const g5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Sj=Ee("circle-x",g5);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const y5=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ix=Ee("clock",y5);/** + */const y5=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ig=Ee("clock",y5);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -244,7 +244,7 @@ Error generating stack: `+C.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const O5=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],ox=Ee("gift",O5);/** + */const O5=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],og=Ee("gift",O5);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -254,7 +254,7 @@ Error generating stack: `+C.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const _5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],lx=Ee("globe",_5);/** + */const _5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],lg=Ee("globe",_5);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -314,7 +314,7 @@ Error generating stack: `+C.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const nM=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],cx=Ee("key",nM);/** + */const nM=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],cg=Ee("key",nM);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -334,7 +334,7 @@ Error generating stack: `+C.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const lM=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],dx=Ee("link",lM);/** + */const lM=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],dg=Ee("link",lM);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -354,12 +354,12 @@ Error generating stack: `+C.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const mM=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],gM=Ee("log-out",mM);/** + */const mM=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],xM=Ee("log-out",mM);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const xM=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],Aj=Ee("map-pin",xM);/** + */const gM=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],Aj=Ee("map-pin",gM);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -529,7 +529,7 @@ Error generating stack: `+C.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const hA=[["path",{d:"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978",key:"1n3hpd"}],["path",{d:"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978",key:"rfe1zi"}],["path",{d:"M18 9h1.5a1 1 0 0 0 0-5H18",key:"7xy6bh"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z",key:"1mhfuq"}],["path",{d:"M6 9H4.5a1 1 0 0 1 0-5H6",key:"tex48p"}]],ux=Ee("trophy",hA);/** + */const hA=[["path",{d:"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978",key:"1n3hpd"}],["path",{d:"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978",key:"rfe1zi"}],["path",{d:"M18 9h1.5a1 1 0 0 0 0-5H18",key:"7xy6bh"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z",key:"1mhfuq"}],["path",{d:"M6 9H4.5a1 1 0 0 1 0-5H6",key:"tex48p"}]],ug=Ee("trophy",hA);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -544,12 +544,12 @@ Error generating stack: `+C.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const gA=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Jh=Ee("upload",gA);/** + */const xA=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Jh=Ee("upload",xA);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const xA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],hc=Ee("user-plus",xA);/** + */const gA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],hc=Ee("user-plus",gA);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -584,7 +584,7 @@ Error generating stack: `+C.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const CA=[["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"}]],pi=Ee("zap",CA),x0="admin_token";function iu(){try{return localStorage.getItem(x0)}catch{return null}}function TA(t){try{localStorage.setItem(x0,t)}catch{}}function ig(){try{localStorage.removeItem(x0)}catch{}}const EA="https://soulapi.quwanzhi.com",MA=15e3,h1=6e4,AA=()=>{const t="https://soulapi.quwanzhi.com";{const e=t.trim();if(e.length>0)return e.replace(/\/$/,"")}return EA};function wc(t){const e=AA(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function ep(t,e={}){const{data:n,...r}=e,a=wc(t),i=new Headers(r.headers),o=iu();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??MA,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)),g=m.headers.get("Content-Type")||"";let y;if(g.includes("application/json"))try{y=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 j=w,S=((j==null?void 0:j.message)||(j==null?void 0:j.error)||"").toString();(S.includes("可提现金额不足")||S.includes("可提现不足")||S.includes("余额不足"))&&window.dispatchEvent(new CustomEvent("recharge-alert",{detail:S}))};if(!m.ok){N(y);const w=new Error((y==null?void 0:y.error)||`HTTP ${m.status}`);throw w.status=m.status,w.data=y,w}return N(y),y}function Pe(t,e){return ep(t,{...e,method:"GET"})}function Ct(t,e,n){return ep(t,{...n,method:"POST",data:e})}function Gt(t,e,n){return ep(t,{...n,method:"PUT",data:e})}function li(t,e){return ep(t,{...e,method:"DELETE"})}function IA(){const[t,e]=b.useState(!1),[n,r]=b.useState("");return b.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(wj,{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(Yn,{className:"w-4 h-4"})})]}):null}const RA=[{icon:rM,label:"数据概览",href:"/dashboard"},{icon:qs,label:"内容管理",href:"/content"},{icon:In,label:"用户管理",href:"/users"},{icon:D5,label:"找伙伴",href:"/find-partner"},{icon:Nc,label:"推广中心",href:"/distribution"}];function PA(){const t=vo(),e=Sa(),[n,r]=b.useState(!1),[a,i]=b.useState(!1);b.useEffect(()=>{r(!0)},[]),b.useEffect(()=>{if(!n)return;i(!1);let c=!1;if(!iu()){e("/login",{replace:!0});return}return Pe("/api/admin").then(u=>{c||(u&&u.success!==!1?i(!0):(ig(),e("/login",{replace:!0,state:{from:t.pathname}})))}).catch(()=>{c||(ig(),e("/login",{replace:!0,state:{from:t.pathname}}))}),()=>{c=!0}},[t.pathname,n,e]);const o=async()=>{ig();try{await Ct("/api/admin/logout",{})}catch{}e("/login",{replace:!0})};return!n||!a?s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsx("div",{className:"w-64 bg-[#0f2137] border-r border-gray-700/50"}),s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("div",{className:"text-[#38bdac]",children:"加载中..."})})]}):s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsxs("div",{className:"w-64 bg-[#0f2137] flex flex-col border-r border-gray-700/50 shadow-xl",children:[s.jsxs("div",{className:"p-6 border-b border-gray-700/50",children:[s.jsx("h1",{className:"text-xl font-bold text-[#38bdac]",children:"管理后台"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Soul创业派对"})]}),s.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[RA.map(c=>{const u=t.pathname===c.href;return s.jsxs(bc,{to:c.href,className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${u?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[s.jsx(c.icon,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:c.label})]},c.href)}),s.jsx("div",{className:"pt-4 mt-4 border-t border-gray-700/50",children:s.jsxs(bc,{to:"/settings",className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${t.pathname==="/settings"?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[s.jsx(no,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:"系统设置"})]})})]}),s.jsx("div",{className:"p-4 border-t border-gray-700/50 space-y-1",children:s.jsxs("button",{type:"button",onClick:o,className:"w-full flex items-center gap-3 px-4 py-3 text-gray-400 hover:text-white rounded-lg hover:bg-gray-700/50 transition-colors",children:[s.jsx(gM,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm",children:"退出登录"})]})})]}),s.jsxs("div",{className:"flex-1 overflow-auto bg-[#0a1628] min-w-0 flex flex-col",children:[s.jsx(IA,{}),s.jsx("div",{className:"w-full min-w-[1024px] min-h-full flex-1",children:s.jsx(RE,{})})]})]})}function f1(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function y0(...t){return e=>{let n=!1;const r=t.map(a=>{const i=f1(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a{let{children:i,...o}=r;Rj(i)&&typeof Qh=="function"&&(i=Qh(i._payload));const c=b.Children.toArray(i),u=c.find(zA);if(u){const h=u.props.children,f=c.map(m=>m===u?b.Children.count(h)>1?b.Children.only(null):b.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:a,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}var Oj=Pj("Slot");function DA(t){const e=b.forwardRef((n,r)=>{let{children:a,...i}=n;if(Rj(a)&&typeof Qh=="function"&&(a=Qh(a._payload)),b.isValidElement(a)){const o=FA(a),c=$A(i,a.props);return a.type!==b.Fragment&&(c.ref=r?y0(r,o):o),b.cloneElement(a,c)}return b.Children.count(a)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var _A=Symbol("radix.slottable");function zA(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===_A}function $A(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 FA(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 Lj(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,m1=Dj,_j=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return m1(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:a,defaultVariants:i}=e,o=Object.keys(a).map(h=>{const f=n==null?void 0:n[h],m=i==null?void 0:i[h];if(f===null)return null;const g=p1(f)||p1(m);return a[h][g]}),c=n&&Object.entries(n).reduce((h,f)=>{let[m,g]=f;return g===void 0||(h[m]=g),h},{}),u=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((h,f)=>{let{class:m,className:g,...y}=f;return Object.entries(y).every(N=>{let[w,j]=N;return Array.isArray(j)?j.includes({...i,...c}[w]):{...i,...c}[w]===j})?[...h,m,g]:h},[]);return m1(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},BA=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r({classGroupId:t,validator:e}),zj=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),Yh="-",g1=[],HA="arbitrary..",UA=t=>{const e=KA(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return WA(o);const c=o.split(Yh),u=c[0]===""&&c.length>1?1:0;return $j(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=r[o],h=n[o];return u?h?BA(h,u):u:h||g1}return n[o]||g1}}},$j=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const a=t[e],i=n.nextPart.get(a);if(i){const h=$j(t,e+1,i);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(Yh):t.slice(e).join(Yh),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?HA+r:void 0})(),KA=t=>{const{theme:e,classGroups:n}=t;return qA(n,e)},qA=(t,e)=>{const n=zj();for(const r in t){const a=t[r];b0(a,n,r,e)}return n},b0=(t,e,n,r)=>{const a=t.length;for(let i=0;i{if(typeof t=="string"){JA(t,e,n);return}if(typeof t=="function"){QA(t,e,n,r);return}YA(t,e,n,r)},JA=(t,e,n)=>{const r=t===""?e:Fj(e,t);r.classGroupId=n},QA=(t,e,n,r)=>{if(XA(t)){b0(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(VA(n,t))},YA=(t,e,n,r)=>{const a=Object.entries(t),i=a.length;for(let o=0;o{let n=t;const r=e.split(Yh),a=r.length;for(let i=0;i"isThemeGetter"in t&&t.isThemeGetter===!0,ZA=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)}}},hx="!",x1=":",eI=[],y1=(t,e,n,r,a)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:a}),tI=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 y1(i,y,g,N)};if(e){const a=e+x1,i=r;r=o=>o.startsWith(a)?i(o.slice(a.length)):y1(eI,!1,o,void 0,!0)}if(n){const a=r;r=i=>n({className:i,parseClassName:a})}return r},nI=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}},sI=t=>({cache:ZA(t.cacheSize),parseClassName:tI(t),sortModifiers:nI(t),...UA(t)}),rI=/\s+/,aI=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:i}=e,o=[],c=t.trim().split(rI);let u="";for(let h=c.length-1;h>=0;h-=1){const f=c[h],{isExternal:m,modifiers:g,hasImportantModifier:y,baseClassName:N,maybePostfixModifierPosition:w}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let j=!!w,S=r(j?N.substring(0,w):N);if(!S){if(!j){u=f+(u.length>0?" "+u:u);continue}if(S=r(N),!S){u=f+(u.length>0?" "+u:u);continue}j=!1}const E=g.length===0?"":g.length===1?g[0]:i(g).join(":"),T=y?E+hx:E,P=T+S;if(o.indexOf(P)>-1)continue;o.push(P);const O=a(S,j);for(let q=0;q0?" "+u:u)}return u},iI=(...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=sI(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=aI(u,n);return a(u,f),f};return i=o,(...u)=>i(iI(...u))},lI=[],Wn=t=>{const e=n=>n[t]||lI;return e.isThemeGetter=!0,e},Vj=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Hj=/^\((?:(\w[\w-]*):)?(.+)\)$/i,cI=/^\d+\/\d+$/,dI=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,uI=/\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$/,hI=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,fI=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,pI=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Yl=t=>cI.test(t),yt=t=>!!t&&!Number.isNaN(Number(t)),Ui=t=>!!t&&Number.isInteger(Number(t)),og=t=>t.endsWith("%")&&yt(t.slice(0,-1)),Za=t=>dI.test(t),mI=()=>!0,gI=t=>uI.test(t)&&!hI.test(t),Uj=()=>!1,xI=t=>fI.test(t),yI=t=>pI.test(t),bI=t=>!We(t)&&!Ke(t),vI=t=>Oc(t,qj,Uj),We=t=>Vj.test(t),qo=t=>Oc(t,Gj,gI),lg=t=>Oc(t,SI,yt),b1=t=>Oc(t,Wj,Uj),NI=t=>Oc(t,Kj,yI),uh=t=>Oc(t,Jj,xI),Ke=t=>Hj.test(t),xd=t=>Lc(t,Gj),wI=t=>Lc(t,CI),v1=t=>Lc(t,Wj),jI=t=>Lc(t,qj),kI=t=>Lc(t,Kj),hh=t=>Lc(t,Jj,!0),Oc=(t,e,n)=>{const r=Vj.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},Lc=(t,e,n=!1)=>{const r=Hj.exec(t);return r?r[1]?e(r[1]):n:!1},Wj=t=>t==="position"||t==="percentage",Kj=t=>t==="image"||t==="url",qj=t=>t==="length"||t==="size"||t==="bg-size",Gj=t=>t==="length",SI=t=>t==="number",CI=t=>t==="family-name",Jj=t=>t==="shadow",TI=()=>{const t=Wn("color"),e=Wn("font"),n=Wn("text"),r=Wn("font-weight"),a=Wn("tracking"),i=Wn("leading"),o=Wn("breakpoint"),c=Wn("container"),u=Wn("spacing"),h=Wn("radius"),f=Wn("shadow"),m=Wn("inset-shadow"),g=Wn("text-shadow"),y=Wn("drop-shadow"),N=Wn("blur"),w=Wn("perspective"),j=Wn("aspect"),S=Wn("ease"),E=Wn("animate"),T=()=>["auto","avoid","all","avoid-page","page","left","right","column"],P=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],O=()=>[...P(),Ke,We],q=()=>["auto","hidden","clip","visible","scroll"],z=()=>["auto","contain","none"],V=()=>[Ke,We,u],I=()=>[Yl,"full","auto",...V()],te=()=>[Ui,"none","subgrid",Ke,We],Q=()=>["auto",{span:["full",Ui,Ke,We]},Ui,Ke,We],F=()=>[Ui,"auto",Ke,We],re=()=>["auto","min","max","fr",Ke,We],ae=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],J=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...V()],D=()=>[Yl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...V()],R=()=>[t,Ke,We],oe=()=>[...P(),v1,b1,{position:[Ke,We]}],G=()=>["no-repeat",{repeat:["","x","y","space","round"]}],_=()=>["auto","cover","contain",jI,vI,{size:[Ke,We]}],U=()=>[og,xd,qo],H=()=>["","none","full",h,Ke,We],K=()=>["",yt,xd,qo],me=()=>["solid","dashed","dotted","double"],Y=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],le=()=>[yt,og,v1,b1],ce=()=>["","none",N,Ke,We],ve=()=>["none",yt,Ke,We],ye=()=>["none",yt,Ke,We],ke=()=>[yt,Ke,We],ze=()=>[Yl,"full",...V()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Za],breakpoint:[Za],color:[mI],container:[Za],"drop-shadow":[Za],ease:["in","out","in-out"],font:[bI],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Za],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Za],shadow:[Za],spacing:["px",yt],text:[Za],"text-shadow":[Za],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Yl,We,Ke,j]}],container:["container"],columns:[{columns:[yt,We,Ke,c]}],"break-after":[{"break-after":T()}],"break-before":[{"break-before":T()}],"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:O()}],overflow:[{overflow:q()}],"overflow-x":[{"overflow-x":q()}],"overflow-y":[{"overflow-y":q()}],overscroll:[{overscroll:z()}],"overscroll-x":[{"overscroll-x":z()}],"overscroll-y":[{"overscroll-y":z()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{start:I()}],end:[{end:I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[Ui,"auto",Ke,We]}],basis:[{basis:[Yl,"full","auto",c,...V()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[yt,Yl,"auto","initial","none",We]}],grow:[{grow:["",yt,Ke,We]}],shrink:[{shrink:["",yt,Ke,We]}],order:[{order:[Ui,"first","last","none",Ke,We]}],"grid-cols":[{"grid-cols":te()}],"col-start-end":[{col:Q()}],"col-start":[{"col-start":F()}],"col-end":[{"col-end":F()}],"grid-rows":[{"grid-rows":te()}],"row-start-end":[{row:Q()}],"row-start":[{"row-start":F()}],"row-end":[{"row-end":F()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":re()}],"auto-rows":[{"auto-rows":re()}],gap:[{gap:V()}],"gap-x":[{"gap-x":V()}],"gap-y":[{"gap-y":V()}],"justify-content":[{justify:[...ae(),"normal"]}],"justify-items":[{"justify-items":[...J(),"normal"]}],"justify-self":[{"justify-self":["auto",...J()]}],"align-content":[{content:["normal",...ae()]}],"align-items":[{items:[...J(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...J(),{baseline:["","last"]}]}],"place-content":[{"place-content":ae()}],"place-items":[{"place-items":[...J(),"baseline"]}],"place-self":[{"place-self":["auto",...J()]}],p:[{p:V()}],px:[{px:V()}],py:[{py:V()}],ps:[{ps:V()}],pe:[{pe:V()}],pt:[{pt:V()}],pr:[{pr:V()}],pb:[{pb:V()}],pl:[{pl:V()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":V()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":V()}],"space-y-reverse":["space-y-reverse"],size:[{size:D()}],w:[{w:[c,"screen",...D()]}],"min-w":[{"min-w":[c,"screen","none",...D()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...D()]}],h:[{h:["screen","lh",...D()]}],"min-h":[{"min-h":["screen","lh","none",...D()]}],"max-h":[{"max-h":["screen","lh",...D()]}],"font-size":[{text:["base",n,xd,qo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Ke,lg]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",og,We]}],"font-family":[{font:[wI,We,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,Ke,We]}],"line-clamp":[{"line-clamp":[yt,"none",Ke,lg]}],leading:[{leading:[i,...V()]}],"list-image":[{"list-image":["none",Ke,We]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ke,We]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:R()}],"text-color":[{text:R()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...me(),"wavy"]}],"text-decoration-thickness":[{decoration:[yt,"from-font","auto",Ke,qo]}],"text-decoration-color":[{decoration:R()}],"underline-offset":[{"underline-offset":[yt,"auto",Ke,We]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:V()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ke,We]}],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",Ke,We]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:oe()}],"bg-repeat":[{bg:G()}],"bg-size":[{bg:_()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ui,Ke,We],radial:["",Ke,We],conic:[Ui,Ke,We]},kI,NI]}],"bg-color":[{bg:R()}],"gradient-from-pos":[{from:U()}],"gradient-via-pos":[{via:U()}],"gradient-to-pos":[{to:U()}],"gradient-from":[{from:R()}],"gradient-via":[{via:R()}],"gradient-to":[{to:R()}],rounded:[{rounded:H()}],"rounded-s":[{"rounded-s":H()}],"rounded-e":[{"rounded-e":H()}],"rounded-t":[{"rounded-t":H()}],"rounded-r":[{"rounded-r":H()}],"rounded-b":[{"rounded-b":H()}],"rounded-l":[{"rounded-l":H()}],"rounded-ss":[{"rounded-ss":H()}],"rounded-se":[{"rounded-se":H()}],"rounded-ee":[{"rounded-ee":H()}],"rounded-es":[{"rounded-es":H()}],"rounded-tl":[{"rounded-tl":H()}],"rounded-tr":[{"rounded-tr":H()}],"rounded-br":[{"rounded-br":H()}],"rounded-bl":[{"rounded-bl":H()}],"border-w":[{border:K()}],"border-w-x":[{"border-x":K()}],"border-w-y":[{"border-y":K()}],"border-w-s":[{"border-s":K()}],"border-w-e":[{"border-e":K()}],"border-w-t":[{"border-t":K()}],"border-w-r":[{"border-r":K()}],"border-w-b":[{"border-b":K()}],"border-w-l":[{"border-l":K()}],"divide-x":[{"divide-x":K()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":K()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...me(),"hidden","none"]}],"divide-style":[{divide:[...me(),"hidden","none"]}],"border-color":[{border:R()}],"border-color-x":[{"border-x":R()}],"border-color-y":[{"border-y":R()}],"border-color-s":[{"border-s":R()}],"border-color-e":[{"border-e":R()}],"border-color-t":[{"border-t":R()}],"border-color-r":[{"border-r":R()}],"border-color-b":[{"border-b":R()}],"border-color-l":[{"border-l":R()}],"divide-color":[{divide:R()}],"outline-style":[{outline:[...me(),"none","hidden"]}],"outline-offset":[{"outline-offset":[yt,Ke,We]}],"outline-w":[{outline:["",yt,xd,qo]}],"outline-color":[{outline:R()}],shadow:[{shadow:["","none",f,hh,uh]}],"shadow-color":[{shadow:R()}],"inset-shadow":[{"inset-shadow":["none",m,hh,uh]}],"inset-shadow-color":[{"inset-shadow":R()}],"ring-w":[{ring:K()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:R()}],"ring-offset-w":[{"ring-offset":[yt,qo]}],"ring-offset-color":[{"ring-offset":R()}],"inset-ring-w":[{"inset-ring":K()}],"inset-ring-color":[{"inset-ring":R()}],"text-shadow":[{"text-shadow":["none",g,hh,uh]}],"text-shadow-color":[{"text-shadow":R()}],opacity:[{opacity:[yt,Ke,We]}],"mix-blend":[{"mix-blend":[...Y(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Y()}],"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":[yt]}],"mask-image-linear-from-pos":[{"mask-linear-from":le()}],"mask-image-linear-to-pos":[{"mask-linear-to":le()}],"mask-image-linear-from-color":[{"mask-linear-from":R()}],"mask-image-linear-to-color":[{"mask-linear-to":R()}],"mask-image-t-from-pos":[{"mask-t-from":le()}],"mask-image-t-to-pos":[{"mask-t-to":le()}],"mask-image-t-from-color":[{"mask-t-from":R()}],"mask-image-t-to-color":[{"mask-t-to":R()}],"mask-image-r-from-pos":[{"mask-r-from":le()}],"mask-image-r-to-pos":[{"mask-r-to":le()}],"mask-image-r-from-color":[{"mask-r-from":R()}],"mask-image-r-to-color":[{"mask-r-to":R()}],"mask-image-b-from-pos":[{"mask-b-from":le()}],"mask-image-b-to-pos":[{"mask-b-to":le()}],"mask-image-b-from-color":[{"mask-b-from":R()}],"mask-image-b-to-color":[{"mask-b-to":R()}],"mask-image-l-from-pos":[{"mask-l-from":le()}],"mask-image-l-to-pos":[{"mask-l-to":le()}],"mask-image-l-from-color":[{"mask-l-from":R()}],"mask-image-l-to-color":[{"mask-l-to":R()}],"mask-image-x-from-pos":[{"mask-x-from":le()}],"mask-image-x-to-pos":[{"mask-x-to":le()}],"mask-image-x-from-color":[{"mask-x-from":R()}],"mask-image-x-to-color":[{"mask-x-to":R()}],"mask-image-y-from-pos":[{"mask-y-from":le()}],"mask-image-y-to-pos":[{"mask-y-to":le()}],"mask-image-y-from-color":[{"mask-y-from":R()}],"mask-image-y-to-color":[{"mask-y-to":R()}],"mask-image-radial":[{"mask-radial":[Ke,We]}],"mask-image-radial-from-pos":[{"mask-radial-from":le()}],"mask-image-radial-to-pos":[{"mask-radial-to":le()}],"mask-image-radial-from-color":[{"mask-radial-from":R()}],"mask-image-radial-to-color":[{"mask-radial-to":R()}],"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":P()}],"mask-image-conic-pos":[{"mask-conic":[yt]}],"mask-image-conic-from-pos":[{"mask-conic-from":le()}],"mask-image-conic-to-pos":[{"mask-conic-to":le()}],"mask-image-conic-from-color":[{"mask-conic-from":R()}],"mask-image-conic-to-color":[{"mask-conic-to":R()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:oe()}],"mask-repeat":[{mask:G()}],"mask-size":[{mask:_()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ke,We]}],filter:[{filter:["","none",Ke,We]}],blur:[{blur:ce()}],brightness:[{brightness:[yt,Ke,We]}],contrast:[{contrast:[yt,Ke,We]}],"drop-shadow":[{"drop-shadow":["","none",y,hh,uh]}],"drop-shadow-color":[{"drop-shadow":R()}],grayscale:[{grayscale:["",yt,Ke,We]}],"hue-rotate":[{"hue-rotate":[yt,Ke,We]}],invert:[{invert:["",yt,Ke,We]}],saturate:[{saturate:[yt,Ke,We]}],sepia:[{sepia:["",yt,Ke,We]}],"backdrop-filter":[{"backdrop-filter":["","none",Ke,We]}],"backdrop-blur":[{"backdrop-blur":ce()}],"backdrop-brightness":[{"backdrop-brightness":[yt,Ke,We]}],"backdrop-contrast":[{"backdrop-contrast":[yt,Ke,We]}],"backdrop-grayscale":[{"backdrop-grayscale":["",yt,Ke,We]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[yt,Ke,We]}],"backdrop-invert":[{"backdrop-invert":["",yt,Ke,We]}],"backdrop-opacity":[{"backdrop-opacity":[yt,Ke,We]}],"backdrop-saturate":[{"backdrop-saturate":[yt,Ke,We]}],"backdrop-sepia":[{"backdrop-sepia":["",yt,Ke,We]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":V()}],"border-spacing-x":[{"border-spacing-x":V()}],"border-spacing-y":[{"border-spacing-y":V()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ke,We]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[yt,"initial",Ke,We]}],ease:[{ease:["linear","initial",S,Ke,We]}],delay:[{delay:[yt,Ke,We]}],animate:[{animate:["none",E,Ke,We]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,Ke,We]}],"perspective-origin":[{"perspective-origin":O()}],rotate:[{rotate:ve()}],"rotate-x":[{"rotate-x":ve()}],"rotate-y":[{"rotate-y":ve()}],"rotate-z":[{"rotate-z":ve()}],scale:[{scale:ye()}],"scale-x":[{"scale-x":ye()}],"scale-y":[{"scale-y":ye()}],"scale-z":[{"scale-z":ye()}],"scale-3d":["scale-3d"],skew:[{skew:ke()}],"skew-x":[{"skew-x":ke()}],"skew-y":[{"skew-y":ke()}],transform:[{transform:[Ke,We,"","none","gpu","cpu"]}],"transform-origin":[{origin:O()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ze()}],"translate-x":[{"translate-x":ze()}],"translate-y":[{"translate-y":ze()}],"translate-z":[{"translate-z":ze()}],"translate-none":["translate-none"],accent:[{accent:R()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:R()}],"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",Ke,We]}],"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":V()}],"scroll-mx":[{"scroll-mx":V()}],"scroll-my":[{"scroll-my":V()}],"scroll-ms":[{"scroll-ms":V()}],"scroll-me":[{"scroll-me":V()}],"scroll-mt":[{"scroll-mt":V()}],"scroll-mr":[{"scroll-mr":V()}],"scroll-mb":[{"scroll-mb":V()}],"scroll-ml":[{"scroll-ml":V()}],"scroll-p":[{"scroll-p":V()}],"scroll-px":[{"scroll-px":V()}],"scroll-py":[{"scroll-py":V()}],"scroll-ps":[{"scroll-ps":V()}],"scroll-pe":[{"scroll-pe":V()}],"scroll-pt":[{"scroll-pt":V()}],"scroll-pr":[{"scroll-pr":V()}],"scroll-pb":[{"scroll-pb":V()}],"scroll-pl":[{"scroll-pl":V()}],"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",Ke,We]}],fill:[{fill:["none",...R()]}],"stroke-w":[{stroke:[yt,xd,qo,lg]}],stroke:[{stroke:["none",...R()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},EI=oI(TI);function Ut(...t){return EI(Dj(t))}function fo(t){if(!t)return"";let e=t.trim();return e?(e=e.replace(/^(https?)\/\//,"$1://"),e):""}const MI=_j("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function X({className:t,variant:e,size:n,asChild:r=!1,...a}){const i=r?Oj:"button";return s.jsx(i,{"data-slot":"button",className:Ut(MI({variant:e,size:n,className:t})),...a})}function de({className:t,type:e,...n}){return s.jsx("input",{type:e,"data-slot":"input",className:Ut("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 AI(){const t=Sa(),[e,n]=b.useState(""),[r,a]=b.useState(""),[i,o]=b.useState(""),[c,u]=b.useState(!1);b.useEffect(()=>{iu()&&t("/dashboard",{replace:!0})},[t]);const h=async()=>{o(""),u(!0);try{const f=await Ct("/api/admin",{username:e.trim(),password:r});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){TA(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(dc,{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(oi,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(de,{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(pM,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(de,{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(X,{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 Oe=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ut("rounded-xl border bg-card text-card-foreground shadow",t),...e}));Oe.displayName="Card";const rt=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ut("flex flex-col space-y-1.5 p-6",t),...e}));rt.displayName="CardHeader";const at=b.forwardRef(({className:t,...e},n)=>s.jsx("h3",{ref:n,className:Ut("font-semibold leading-none tracking-tight",t),...e}));at.displayName="CardTitle";const Kt=b.forwardRef(({className:t,...e},n)=>s.jsx("p",{ref:n,className:Ut("text-sm text-muted-foreground",t),...e}));Kt.displayName="CardDescription";const Le=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ut("p-6 pt-0",t),...e}));Le.displayName="CardContent";const II=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ut("flex items-center p-6 pt-0",t),...e}));II.displayName="CardFooter";const RI={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function cg(t,e="info",n=3e3){const r=`toast-${Date.now()}`,a=RI[e],i=document.createElement("div");i.id=r,i.setAttribute("role","alert"),Object.assign(i.style,{position:"fixed",top:"24px",right:"24px",zIndex:"9999",display:"flex",alignItems:"center",gap:"10px",padding:"12px 18px",borderRadius:"10px",background:a.bg,border:`1.5px solid ${a.border}`,boxShadow:"0 4px 20px rgba(0,0,0,.12)",fontSize:"14px",color:"#1a1a1a",fontWeight:"500",maxWidth:"380px",lineHeight:"1.5",opacity:"0",transform:"translateY(-8px)",transition:"opacity .22s ease, transform .22s ease",pointerEvents:"none"});const o=document.createElement("span");Object.assign(o.style,{width:"20px",height:"20px",borderRadius:"50%",background:a.border,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"700",flexShrink:"0"}),o.textContent=a.icon;const c=document.createElement("span");c.textContent=t,i.appendChild(o),i.appendChild(c),document.body.appendChild(i),requestAnimationFrame(()=>{i.style.opacity="1",i.style.transform="translateY(0)"});const u=setTimeout(()=>h(r),n);function h(f){clearTimeout(u);const m=document.getElementById(f);m&&(m.style.opacity="0",m.style.transform="translateY(-8px)",setTimeout(()=>{var g;return(g=m.parentNode)==null?void 0:g.removeChild(m)},250))}}const se={success:(t,e)=>cg(t,"success",e),error:(t,e)=>cg(t,"error",e),info:(t,e)=>cg(t,"info",e)};function mt(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 PI(t,e){const n=b.createContext(e),r=i=>{const{children:o,...c}=i,u=b.useMemo(()=>c,Object.values(c));return s.jsx(n.Provider,{value:u,children:o})};r.displayName=t+"Provider";function a(i){const o=b.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[r,a]}function No(t,e=[]){let n=[];function r(i,o){const c=b.createContext(o),u=n.length;n=[...n,o];const h=m=>{var S;const{scope:g,children:y,...N}=m,w=((S=g==null?void 0:g[t])==null?void 0:S[u])||c,j=b.useMemo(()=>N,Object.values(N));return s.jsx(w.Provider,{value:j,children:y})};h.displayName=i+"Provider";function f(m,g){var w;const y=((w=g==null?void 0:g[t])==null?void 0:w[u])||c,N=b.useContext(y);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${i}\``)}return[h,f]}const a=()=>{const i=n.map(o=>b.createContext(o));return function(c){const u=(c==null?void 0:c[t])||i;return b.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return a.scopeName=t,[r,OI(a,...e)]}function OI(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((c,{useScope:u,scopeName:h})=>{const m=u(i)[`__scope${h}`];return{...c,...m}},{});return b.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var Ns=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},LI=Yf[" useId ".trim().toString()]||(()=>{}),DI=0;function oo(t){const[e,n]=b.useState(LI());return Ns(()=>{n(r=>r??String(DI++))},[t]),e?`radix-${e}`:""}var _I=Yf[" useInsertionEffect ".trim().toString()]||Ns;function cl({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[a,i,o]=zI({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:a;{const f=b.useRef(t!==void 0);b.useEffect(()=>{const m=f.current;m!==c&&console.warn(`${r} is changing from ${m?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=c},[c,r])}const h=b.useCallback(f=>{var m;if(c){const g=$I(f)?f(t):f;g!==t&&((m=o.current)==null||m.call(o,g))}else i(f)},[c,t,i,o]);return[u,h]}function zI({defaultProp:t,onChange:e}){const[n,r]=b.useState(t),a=b.useRef(n),i=b.useRef(e);return _I(()=>{i.current=e},[e]),b.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,r,i]}function $I(t){return typeof t=="function"}function Ud(t){const e=FI(t),n=b.forwardRef((r,a)=>{const{children:i,...o}=r,c=b.Children.toArray(i),u=c.find(VI);if(u){const h=u.props.children,f=c.map(m=>m===u?b.Children.count(h)>1?b.Children.only(null):b.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:a,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function FI(t){const e=b.forwardRef((n,r)=>{const{children:a,...i}=n;if(b.isValidElement(a)){const o=UI(a),c=HI(i,a.props);return a.type!==b.Fragment&&(c.ref=r?y0(r,o):o),b.cloneElement(a,c)}return b.Children.count(a)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var BI=Symbol("radix.slottable");function VI(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===BI}function HI(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 UI(t){var r,a;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var WI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],bt=WI.reduce((t,e)=>{const n=Ud(`Primitive.${e}`),r=b.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function KI(t,e){t&&au.flushSync(()=>t.dispatchEvent(e))}function po(t){const e=b.useRef(t);return b.useEffect(()=>{e.current=t}),b.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function qI(t,e=globalThis==null?void 0:globalThis.document){const n=po(t);b.useEffect(()=>{const r=a=>{a.key==="Escape"&&n(a)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var GI="DismissableLayer",fx="dismissableLayer.update",JI="dismissableLayer.pointerDownOutside",QI="dismissableLayer.focusOutside",N1,Qj=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),v0=b.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:c,...u}=t,h=b.useContext(Qj),[f,m]=b.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=b.useState({}),N=Ht(e,z=>m(z)),w=Array.from(h.layers),[j]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),S=w.indexOf(j),E=f?w.indexOf(f):-1,T=h.layersWithOutsidePointerEventsDisabled.size>0,P=E>=S,O=ZI(z=>{const V=z.target,I=[...h.branches].some(te=>te.contains(V));!P||I||(a==null||a(z),o==null||o(z),z.defaultPrevented||c==null||c())},g),q=eR(z=>{const V=z.target;[...h.branches].some(te=>te.contains(V))||(i==null||i(z),o==null||o(z),z.defaultPrevented||c==null||c())},g);return qI(z=>{E===h.layers.size-1&&(r==null||r(z),!z.defaultPrevented&&c&&(z.preventDefault(),c()))},g),b.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(N1=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),w1(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=N1)}},[f,g,n,h]),b.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),w1())},[f,h]),b.useEffect(()=>{const z=()=>y({});return document.addEventListener(fx,z),()=>document.removeEventListener(fx,z)},[]),s.jsx(bt.div,{...u,ref:N,style:{pointerEvents:T?P?"auto":"none":void 0,...t.style},onFocusCapture:mt(t.onFocusCapture,q.onFocusCapture),onBlurCapture:mt(t.onBlurCapture,q.onBlurCapture),onPointerDownCapture:mt(t.onPointerDownCapture,O.onPointerDownCapture)})});v0.displayName=GI;var YI="DismissableLayerBranch",XI=b.forwardRef((t,e)=>{const n=b.useContext(Qj),r=b.useRef(null),a=Ht(e,r);return b.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(bt.div,{...t,ref:a})});XI.displayName=YI;function ZI(t,e=globalThis==null?void 0:globalThis.document){const n=po(t),r=b.useRef(!1),a=b.useRef(()=>{});return b.useEffect(()=>{const i=c=>{if(c.target&&!r.current){let u=function(){Yj(JI,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 eR(t,e=globalThis==null?void 0:globalThis.document){const n=po(t),r=b.useRef(!1);return b.useEffect(()=>{const a=i=>{i.target&&!r.current&&Yj(QI,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 w1(){const t=new CustomEvent(fx);document.dispatchEvent(t)}function Yj(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?KI(a,i):a.dispatchEvent(i)}var dg="focusScope.autoFocusOnMount",ug="focusScope.autoFocusOnUnmount",j1={bubbles:!1,cancelable:!0},tR="FocusScope",N0=b.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[c,u]=b.useState(null),h=po(a),f=po(i),m=b.useRef(null),g=Ht(e,w=>u(w)),y=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(r){let w=function(T){if(y.paused||!c)return;const P=T.target;c.contains(P)?m.current=P:qi(m.current,{select:!0})},j=function(T){if(y.paused||!c)return;const P=T.relatedTarget;P!==null&&(c.contains(P)||qi(m.current,{select:!0}))},S=function(T){if(document.activeElement===document.body)for(const O of T)O.removedNodes.length>0&&qi(c)};document.addEventListener("focusin",w),document.addEventListener("focusout",j);const E=new MutationObserver(S);return c&&E.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",j),E.disconnect()}}},[r,c,y.paused]),b.useEffect(()=>{if(c){S1.add(y);const w=document.activeElement;if(!c.contains(w)){const S=new CustomEvent(dg,j1);c.addEventListener(dg,h),c.dispatchEvent(S),S.defaultPrevented||(nR(oR(Xj(c)),{select:!0}),document.activeElement===w&&qi(c))}return()=>{c.removeEventListener(dg,h),setTimeout(()=>{const S=new CustomEvent(ug,j1);c.addEventListener(ug,f),c.dispatchEvent(S),S.defaultPrevented||qi(w??document.body,{select:!0}),c.removeEventListener(ug,f),S1.remove(y)},0)}}},[c,h,f,y]);const N=b.useCallback(w=>{if(!n&&!r||y.paused)return;const j=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,S=document.activeElement;if(j&&S){const E=w.currentTarget,[T,P]=sR(E);T&&P?!w.shiftKey&&S===P?(w.preventDefault(),n&&qi(T,{select:!0})):w.shiftKey&&S===T&&(w.preventDefault(),n&&qi(P,{select:!0})):S===E&&w.preventDefault()}},[n,r,y.paused]);return s.jsx(bt.div,{tabIndex:-1,...o,ref:g,onKeyDown:N})});N0.displayName=tR;function nR(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(qi(r,{select:e}),document.activeElement!==n)return}function sR(t){const e=Xj(t),n=k1(e,t),r=k1(e.reverse(),t);return[n,r]}function Xj(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 k1(t,e){for(const n of t)if(!rR(n,{upTo:e}))return n}function rR(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 aR(t){return t instanceof HTMLInputElement&&"select"in t}function qi(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&aR(t)&&e&&t.select()}}var S1=iR();function iR(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=C1(t,e),t.unshift(e)},remove(e){var n;t=C1(t,e),(n=t[0])==null||n.resume()}}}function C1(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function oR(t){return t.filter(e=>e.tagName!=="A")}var lR="Portal",w0=b.forwardRef((t,e)=>{var c;const{container:n,...r}=t,[a,i]=b.useState(!1);Ns(()=>i(!0),[]);const o=n||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?uj.createPortal(s.jsx(bt.div,{...r,ref:e}),o):null});w0.displayName=lR;function cR(t,e){return b.useReducer((n,r)=>e[n][r]??n,t)}var ou=t=>{const{present:e,children:n}=t,r=dR(e),a=typeof n=="function"?n({present:r.isPresent}):b.Children.only(n),i=Ht(r.ref,uR(a));return typeof n=="function"||r.isPresent?b.cloneElement(a,{ref:i}):null};ou.displayName="Presence";function dR(t){const[e,n]=b.useState(),r=b.useRef(null),a=b.useRef(t),i=b.useRef("none"),o=t?"mounted":"unmounted",[c,u]=cR(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const h=fh(r.current);i.current=c==="mounted"?h:"none"},[c]),Ns(()=>{const h=r.current,f=a.current;if(f!==t){const g=i.current,y=fh(h);t?u("MOUNT"):y==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&g!==y?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,u]),Ns(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=y=>{const w=fh(r.current).includes(CSS.escape(y.animationName));if(y.target===e&&w&&(u("ANIMATION_END"),!a.current)){const j=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=j)})}},g=y=>{y.target===e&&(i.current=fh(r.current))};return e.addEventListener("animationstart",g),e.addEventListener("animationcancel",m),e.addEventListener("animationend",m),()=>{f.clearTimeout(h),e.removeEventListener("animationstart",g),e.removeEventListener("animationcancel",m),e.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[e,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:b.useCallback(h=>{r.current=h?getComputedStyle(h):null,n(h)},[])}}function fh(t){return(t==null?void 0:t.animationName)||"none"}function uR(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 hg=0;function Zj(){b.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??T1()),document.body.insertAdjacentElement("beforeend",t[1]??T1()),hg++,()=>{hg===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),hg--}},[])}function T1(){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 xa=function(){return xa=Object.assign||function(e){for(var n,r=1,a=arguments.length;r"u")return ER;var e=MR(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])}},IR=sk(),mc="data-scroll-locked",RR=function(t,e,n,r){var a=t.left,i=t.top,o=t.right,c=t.gap;return n===void 0&&(n="margin"),` + */const CA=[["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"}]],pi=Ee("zap",CA),g0="admin_token";function iu(){try{return localStorage.getItem(g0)}catch{return null}}function TA(t){try{localStorage.setItem(g0,t)}catch{}}function ix(){try{localStorage.removeItem(g0)}catch{}}const EA="https://soulapi.quwanzhi.com",MA=15e3,h1=6e4,AA=()=>{const t="https://soulapi.quwanzhi.com";{const e=t.trim();if(e.length>0)return e.replace(/\/$/,"")}return EA};function wc(t){const e=AA(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function ep(t,e={}){const{data:n,...r}=e,a=wc(t),i=new Headers(r.headers),o=iu();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??MA,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 y;if(x.includes("application/json"))try{y=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 j=w,S=((j==null?void 0:j.message)||(j==null?void 0:j.error)||"").toString();(S.includes("可提现金额不足")||S.includes("可提现不足")||S.includes("余额不足"))&&window.dispatchEvent(new CustomEvent("recharge-alert",{detail:S}))};if(!m.ok){N(y);const w=new Error((y==null?void 0:y.error)||`HTTP ${m.status}`);throw w.status=m.status,w.data=y,w}return N(y),y}function Pe(t,e){return ep(t,{...e,method:"GET"})}function Ct(t,e,n){return ep(t,{...n,method:"POST",data:e})}function Gt(t,e,n){return ep(t,{...n,method:"PUT",data:e})}function li(t,e){return ep(t,{...e,method:"DELETE"})}function IA(){const[t,e]=b.useState(!1),[n,r]=b.useState("");return b.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(wj,{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(Yn,{className:"w-4 h-4"})})]}):null}const RA=[{icon:rM,label:"数据概览",href:"/dashboard"},{icon:Gs,label:"内容管理",href:"/content"},{icon:In,label:"用户管理",href:"/users"},{icon:D5,label:"找伙伴",href:"/find-partner"},{icon:Nc,label:"推广中心",href:"/distribution"}];function PA(){const t=vo(),e=Sa(),[n,r]=b.useState(!1),[a,i]=b.useState(!1);b.useEffect(()=>{r(!0)},[]),b.useEffect(()=>{if(!n)return;i(!1);let c=!1;if(!iu()){e("/login",{replace:!0});return}return Pe("/api/admin").then(u=>{c||(u&&u.success!==!1?i(!0):(ix(),e("/login",{replace:!0,state:{from:t.pathname}})))}).catch(()=>{c||(ix(),e("/login",{replace:!0,state:{from:t.pathname}}))}),()=>{c=!0}},[t.pathname,n,e]);const o=async()=>{ix();try{await Ct("/api/admin/logout",{})}catch{}e("/login",{replace:!0})};return!n||!a?s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsx("div",{className:"w-64 bg-[#0f2137] border-r border-gray-700/50"}),s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("div",{className:"text-[#38bdac]",children:"加载中..."})})]}):s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsxs("div",{className:"w-64 bg-[#0f2137] flex flex-col border-r border-gray-700/50 shadow-xl",children:[s.jsxs("div",{className:"p-6 border-b border-gray-700/50",children:[s.jsx("h1",{className:"text-xl font-bold text-[#38bdac]",children:"管理后台"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Soul创业派对"})]}),s.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[RA.map(c=>{const u=t.pathname===c.href;return s.jsxs(bc,{to:c.href,className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${u?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[s.jsx(c.icon,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:c.label})]},c.href)}),s.jsx("div",{className:"pt-4 mt-4 border-t border-gray-700/50",children:s.jsxs(bc,{to:"/settings",className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${t.pathname==="/settings"?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[s.jsx(no,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:"系统设置"})]})})]}),s.jsx("div",{className:"p-4 border-t border-gray-700/50 space-y-1",children:s.jsxs("button",{type:"button",onClick:o,className:"w-full flex items-center gap-3 px-4 py-3 text-gray-400 hover:text-white rounded-lg hover:bg-gray-700/50 transition-colors",children:[s.jsx(xM,{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(IA,{}),s.jsx("div",{className:"w-full min-w-[1024px] min-h-full flex-1",children:s.jsx(RE,{})})]})]})}function f1(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function y0(...t){return e=>{let n=!1;const r=t.map(a=>{const i=f1(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a{let{children:i,...o}=r;Rj(i)&&typeof Qh=="function"&&(i=Qh(i._payload));const c=b.Children.toArray(i),u=c.find(zA);if(u){const h=u.props.children,f=c.map(m=>m===u?b.Children.count(h)>1?b.Children.only(null):b.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:a,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}var Oj=Pj("Slot");function DA(t){const e=b.forwardRef((n,r)=>{let{children:a,...i}=n;if(Rj(a)&&typeof Qh=="function"&&(a=Qh(a._payload)),b.isValidElement(a)){const o=FA(a),c=$A(i,a.props);return a.type!==b.Fragment&&(c.ref=r?y0(r,o):o),b.cloneElement(a,c)}return b.Children.count(a)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var _A=Symbol("radix.slottable");function zA(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===_A}function $A(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 FA(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 Lj(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,m1=Dj,_j=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return m1(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=p1(f)||p1(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,...y}=f;return Object.entries(y).every(N=>{let[w,j]=N;return Array.isArray(j)?j.includes({...i,...c}[w]):{...i,...c}[w]===j})?[...h,m,x]:h},[]);return m1(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},BA=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r({classGroupId:t,validator:e}),zj=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),Yh="-",x1=[],HA="arbitrary..",UA=t=>{const e=KA(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return WA(o);const c=o.split(Yh),u=c[0]===""&&c.length>1?1:0;return $j(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=r[o],h=n[o];return u?h?BA(h,u):u:h||x1}return n[o]||x1}}},$j=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const a=t[e],i=n.nextPart.get(a);if(i){const h=$j(t,e+1,i);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(Yh):t.slice(e).join(Yh),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?HA+r:void 0})(),KA=t=>{const{theme:e,classGroups:n}=t;return qA(n,e)},qA=(t,e)=>{const n=zj();for(const r in t){const a=t[r];b0(a,n,r,e)}return n},b0=(t,e,n,r)=>{const a=t.length;for(let i=0;i{if(typeof t=="string"){JA(t,e,n);return}if(typeof t=="function"){QA(t,e,n,r);return}YA(t,e,n,r)},JA=(t,e,n)=>{const r=t===""?e:Fj(e,t);r.classGroupId=n},QA=(t,e,n,r)=>{if(XA(t)){b0(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(VA(n,t))},YA=(t,e,n,r)=>{const a=Object.entries(t),i=a.length;for(let o=0;o{let n=t;const r=e.split(Yh),a=r.length;for(let i=0;i"isThemeGetter"in t&&t.isThemeGetter===!0,ZA=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),r=Object.create(null);const a=(i,o)=>{n[i]=o,e++,e>t&&(e=0,r=n,n=Object.create(null))};return{get(i){let o=n[i];if(o!==void 0)return o;if((o=r[i])!==void 0)return a(i,o),o},set(i,o){i in n?n[i]=o:a(i,o)}}},hg="!",g1=":",eI=[],y1=(t,e,n,r,a)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:a}),tI=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 y1(i,y,x,N)};if(e){const a=e+g1,i=r;r=o=>o.startsWith(a)?i(o.slice(a.length)):y1(eI,!1,o,void 0,!0)}if(n){const a=r;r=i=>n({className:i,parseClassName:a})}return r},nI=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}},sI=t=>({cache:ZA(t.cacheSize),parseClassName:tI(t),sortModifiers:nI(t),...UA(t)}),rI=/\s+/,aI=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:i}=e,o=[],c=t.trim().split(rI);let u="";for(let h=c.length-1;h>=0;h-=1){const f=c[h],{isExternal:m,modifiers:x,hasImportantModifier:y,baseClassName:N,maybePostfixModifierPosition:w}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let j=!!w,S=r(j?N.substring(0,w):N);if(!S){if(!j){u=f+(u.length>0?" "+u:u);continue}if(S=r(N),!S){u=f+(u.length>0?" "+u:u);continue}j=!1}const E=x.length===0?"":x.length===1?x[0]:i(x).join(":"),T=y?E+hg:E,P=T+S;if(o.indexOf(P)>-1)continue;o.push(P);const O=a(S,j);for(let q=0;q0?" "+u:u)}return u},iI=(...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=sI(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=aI(u,n);return a(u,f),f};return i=o,(...u)=>i(iI(...u))},lI=[],Wn=t=>{const e=n=>n[t]||lI;return e.isThemeGetter=!0,e},Vj=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Hj=/^\((?:(\w[\w-]*):)?(.+)\)$/i,cI=/^\d+\/\d+$/,dI=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,uI=/\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$/,hI=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,fI=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,pI=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Yl=t=>cI.test(t),yt=t=>!!t&&!Number.isNaN(Number(t)),Ui=t=>!!t&&Number.isInteger(Number(t)),ox=t=>t.endsWith("%")&&yt(t.slice(0,-1)),Za=t=>dI.test(t),mI=()=>!0,xI=t=>uI.test(t)&&!hI.test(t),Uj=()=>!1,gI=t=>fI.test(t),yI=t=>pI.test(t),bI=t=>!Ke(t)&&!qe(t),vI=t=>Oc(t,qj,Uj),Ke=t=>Vj.test(t),qo=t=>Oc(t,Gj,xI),lx=t=>Oc(t,SI,yt),b1=t=>Oc(t,Wj,Uj),NI=t=>Oc(t,Kj,yI),uh=t=>Oc(t,Jj,gI),qe=t=>Hj.test(t),gd=t=>Lc(t,Gj),wI=t=>Lc(t,CI),v1=t=>Lc(t,Wj),jI=t=>Lc(t,qj),kI=t=>Lc(t,Kj),hh=t=>Lc(t,Jj,!0),Oc=(t,e,n)=>{const r=Vj.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},Lc=(t,e,n=!1)=>{const r=Hj.exec(t);return r?r[1]?e(r[1]):n:!1},Wj=t=>t==="position"||t==="percentage",Kj=t=>t==="image"||t==="url",qj=t=>t==="length"||t==="size"||t==="bg-size",Gj=t=>t==="length",SI=t=>t==="number",CI=t=>t==="family-name",Jj=t=>t==="shadow",TI=()=>{const t=Wn("color"),e=Wn("font"),n=Wn("text"),r=Wn("font-weight"),a=Wn("tracking"),i=Wn("leading"),o=Wn("breakpoint"),c=Wn("container"),u=Wn("spacing"),h=Wn("radius"),f=Wn("shadow"),m=Wn("inset-shadow"),x=Wn("text-shadow"),y=Wn("drop-shadow"),N=Wn("blur"),w=Wn("perspective"),j=Wn("aspect"),S=Wn("ease"),E=Wn("animate"),T=()=>["auto","avoid","all","avoid-page","page","left","right","column"],P=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],O=()=>[...P(),qe,Ke],q=()=>["auto","hidden","clip","visible","scroll"],z=()=>["auto","contain","none"],V=()=>[qe,Ke,u],I=()=>[Yl,"full","auto",...V()],te=()=>[Ui,"none","subgrid",qe,Ke],Q=()=>["auto",{span:["full",Ui,qe,Ke]},Ui,qe,Ke],F=()=>[Ui,"auto",qe,Ke],re=()=>["auto","min","max","fr",qe,Ke],ie=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],J=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...V()],D=()=>[Yl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...V()],R=()=>[t,qe,Ke],oe=()=>[...P(),v1,b1,{position:[qe,Ke]}],G=()=>["no-repeat",{repeat:["","x","y","space","round"]}],_=()=>["auto","cover","contain",jI,vI,{size:[qe,Ke]}],U=()=>[ox,gd,qo],H=()=>["","none","full",h,qe,Ke],K=()=>["",yt,gd,qo],me=()=>["solid","dashed","dotted","double"],Y=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],le=()=>[yt,ox,v1,b1],de=()=>["","none",N,qe,Ke],ve=()=>["none",yt,qe,Ke],ye=()=>["none",yt,qe,Ke],ke=()=>[yt,qe,Ke],ze=()=>[Yl,"full",...V()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Za],breakpoint:[Za],color:[mI],container:[Za],"drop-shadow":[Za],ease:["in","out","in-out"],font:[bI],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Za],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Za],shadow:[Za],spacing:["px",yt],text:[Za],"text-shadow":[Za],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Yl,Ke,qe,j]}],container:["container"],columns:[{columns:[yt,Ke,qe,c]}],"break-after":[{"break-after":T()}],"break-before":[{"break-before":T()}],"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:O()}],overflow:[{overflow:q()}],"overflow-x":[{"overflow-x":q()}],"overflow-y":[{"overflow-y":q()}],overscroll:[{overscroll:z()}],"overscroll-x":[{"overscroll-x":z()}],"overscroll-y":[{"overscroll-y":z()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{start:I()}],end:[{end:I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[Ui,"auto",qe,Ke]}],basis:[{basis:[Yl,"full","auto",c,...V()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[yt,Yl,"auto","initial","none",Ke]}],grow:[{grow:["",yt,qe,Ke]}],shrink:[{shrink:["",yt,qe,Ke]}],order:[{order:[Ui,"first","last","none",qe,Ke]}],"grid-cols":[{"grid-cols":te()}],"col-start-end":[{col:Q()}],"col-start":[{"col-start":F()}],"col-end":[{"col-end":F()}],"grid-rows":[{"grid-rows":te()}],"row-start-end":[{row:Q()}],"row-start":[{"row-start":F()}],"row-end":[{"row-end":F()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":re()}],"auto-rows":[{"auto-rows":re()}],gap:[{gap:V()}],"gap-x":[{"gap-x":V()}],"gap-y":[{"gap-y":V()}],"justify-content":[{justify:[...ie(),"normal"]}],"justify-items":[{"justify-items":[...J(),"normal"]}],"justify-self":[{"justify-self":["auto",...J()]}],"align-content":[{content:["normal",...ie()]}],"align-items":[{items:[...J(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...J(),{baseline:["","last"]}]}],"place-content":[{"place-content":ie()}],"place-items":[{"place-items":[...J(),"baseline"]}],"place-self":[{"place-self":["auto",...J()]}],p:[{p:V()}],px:[{px:V()}],py:[{py:V()}],ps:[{ps:V()}],pe:[{pe:V()}],pt:[{pt:V()}],pr:[{pr:V()}],pb:[{pb:V()}],pl:[{pl:V()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":V()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":V()}],"space-y-reverse":["space-y-reverse"],size:[{size:D()}],w:[{w:[c,"screen",...D()]}],"min-w":[{"min-w":[c,"screen","none",...D()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...D()]}],h:[{h:["screen","lh",...D()]}],"min-h":[{"min-h":["screen","lh","none",...D()]}],"max-h":[{"max-h":["screen","lh",...D()]}],"font-size":[{text:["base",n,gd,qo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,qe,lx]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ox,Ke]}],"font-family":[{font:[wI,Ke,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,qe,Ke]}],"line-clamp":[{"line-clamp":[yt,"none",qe,lx]}],leading:[{leading:[i,...V()]}],"list-image":[{"list-image":["none",qe,Ke]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",qe,Ke]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:R()}],"text-color":[{text:R()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...me(),"wavy"]}],"text-decoration-thickness":[{decoration:[yt,"from-font","auto",qe,qo]}],"text-decoration-color":[{decoration:R()}],"underline-offset":[{"underline-offset":[yt,"auto",qe,Ke]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:V()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",qe,Ke]}],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",qe,Ke]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:oe()}],"bg-repeat":[{bg:G()}],"bg-size":[{bg:_()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ui,qe,Ke],radial:["",qe,Ke],conic:[Ui,qe,Ke]},kI,NI]}],"bg-color":[{bg:R()}],"gradient-from-pos":[{from:U()}],"gradient-via-pos":[{via:U()}],"gradient-to-pos":[{to:U()}],"gradient-from":[{from:R()}],"gradient-via":[{via:R()}],"gradient-to":[{to:R()}],rounded:[{rounded:H()}],"rounded-s":[{"rounded-s":H()}],"rounded-e":[{"rounded-e":H()}],"rounded-t":[{"rounded-t":H()}],"rounded-r":[{"rounded-r":H()}],"rounded-b":[{"rounded-b":H()}],"rounded-l":[{"rounded-l":H()}],"rounded-ss":[{"rounded-ss":H()}],"rounded-se":[{"rounded-se":H()}],"rounded-ee":[{"rounded-ee":H()}],"rounded-es":[{"rounded-es":H()}],"rounded-tl":[{"rounded-tl":H()}],"rounded-tr":[{"rounded-tr":H()}],"rounded-br":[{"rounded-br":H()}],"rounded-bl":[{"rounded-bl":H()}],"border-w":[{border:K()}],"border-w-x":[{"border-x":K()}],"border-w-y":[{"border-y":K()}],"border-w-s":[{"border-s":K()}],"border-w-e":[{"border-e":K()}],"border-w-t":[{"border-t":K()}],"border-w-r":[{"border-r":K()}],"border-w-b":[{"border-b":K()}],"border-w-l":[{"border-l":K()}],"divide-x":[{"divide-x":K()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":K()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...me(),"hidden","none"]}],"divide-style":[{divide:[...me(),"hidden","none"]}],"border-color":[{border:R()}],"border-color-x":[{"border-x":R()}],"border-color-y":[{"border-y":R()}],"border-color-s":[{"border-s":R()}],"border-color-e":[{"border-e":R()}],"border-color-t":[{"border-t":R()}],"border-color-r":[{"border-r":R()}],"border-color-b":[{"border-b":R()}],"border-color-l":[{"border-l":R()}],"divide-color":[{divide:R()}],"outline-style":[{outline:[...me(),"none","hidden"]}],"outline-offset":[{"outline-offset":[yt,qe,Ke]}],"outline-w":[{outline:["",yt,gd,qo]}],"outline-color":[{outline:R()}],shadow:[{shadow:["","none",f,hh,uh]}],"shadow-color":[{shadow:R()}],"inset-shadow":[{"inset-shadow":["none",m,hh,uh]}],"inset-shadow-color":[{"inset-shadow":R()}],"ring-w":[{ring:K()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:R()}],"ring-offset-w":[{"ring-offset":[yt,qo]}],"ring-offset-color":[{"ring-offset":R()}],"inset-ring-w":[{"inset-ring":K()}],"inset-ring-color":[{"inset-ring":R()}],"text-shadow":[{"text-shadow":["none",x,hh,uh]}],"text-shadow-color":[{"text-shadow":R()}],opacity:[{opacity:[yt,qe,Ke]}],"mix-blend":[{"mix-blend":[...Y(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Y()}],"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":[yt]}],"mask-image-linear-from-pos":[{"mask-linear-from":le()}],"mask-image-linear-to-pos":[{"mask-linear-to":le()}],"mask-image-linear-from-color":[{"mask-linear-from":R()}],"mask-image-linear-to-color":[{"mask-linear-to":R()}],"mask-image-t-from-pos":[{"mask-t-from":le()}],"mask-image-t-to-pos":[{"mask-t-to":le()}],"mask-image-t-from-color":[{"mask-t-from":R()}],"mask-image-t-to-color":[{"mask-t-to":R()}],"mask-image-r-from-pos":[{"mask-r-from":le()}],"mask-image-r-to-pos":[{"mask-r-to":le()}],"mask-image-r-from-color":[{"mask-r-from":R()}],"mask-image-r-to-color":[{"mask-r-to":R()}],"mask-image-b-from-pos":[{"mask-b-from":le()}],"mask-image-b-to-pos":[{"mask-b-to":le()}],"mask-image-b-from-color":[{"mask-b-from":R()}],"mask-image-b-to-color":[{"mask-b-to":R()}],"mask-image-l-from-pos":[{"mask-l-from":le()}],"mask-image-l-to-pos":[{"mask-l-to":le()}],"mask-image-l-from-color":[{"mask-l-from":R()}],"mask-image-l-to-color":[{"mask-l-to":R()}],"mask-image-x-from-pos":[{"mask-x-from":le()}],"mask-image-x-to-pos":[{"mask-x-to":le()}],"mask-image-x-from-color":[{"mask-x-from":R()}],"mask-image-x-to-color":[{"mask-x-to":R()}],"mask-image-y-from-pos":[{"mask-y-from":le()}],"mask-image-y-to-pos":[{"mask-y-to":le()}],"mask-image-y-from-color":[{"mask-y-from":R()}],"mask-image-y-to-color":[{"mask-y-to":R()}],"mask-image-radial":[{"mask-radial":[qe,Ke]}],"mask-image-radial-from-pos":[{"mask-radial-from":le()}],"mask-image-radial-to-pos":[{"mask-radial-to":le()}],"mask-image-radial-from-color":[{"mask-radial-from":R()}],"mask-image-radial-to-color":[{"mask-radial-to":R()}],"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":P()}],"mask-image-conic-pos":[{"mask-conic":[yt]}],"mask-image-conic-from-pos":[{"mask-conic-from":le()}],"mask-image-conic-to-pos":[{"mask-conic-to":le()}],"mask-image-conic-from-color":[{"mask-conic-from":R()}],"mask-image-conic-to-color":[{"mask-conic-to":R()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:oe()}],"mask-repeat":[{mask:G()}],"mask-size":[{mask:_()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",qe,Ke]}],filter:[{filter:["","none",qe,Ke]}],blur:[{blur:de()}],brightness:[{brightness:[yt,qe,Ke]}],contrast:[{contrast:[yt,qe,Ke]}],"drop-shadow":[{"drop-shadow":["","none",y,hh,uh]}],"drop-shadow-color":[{"drop-shadow":R()}],grayscale:[{grayscale:["",yt,qe,Ke]}],"hue-rotate":[{"hue-rotate":[yt,qe,Ke]}],invert:[{invert:["",yt,qe,Ke]}],saturate:[{saturate:[yt,qe,Ke]}],sepia:[{sepia:["",yt,qe,Ke]}],"backdrop-filter":[{"backdrop-filter":["","none",qe,Ke]}],"backdrop-blur":[{"backdrop-blur":de()}],"backdrop-brightness":[{"backdrop-brightness":[yt,qe,Ke]}],"backdrop-contrast":[{"backdrop-contrast":[yt,qe,Ke]}],"backdrop-grayscale":[{"backdrop-grayscale":["",yt,qe,Ke]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[yt,qe,Ke]}],"backdrop-invert":[{"backdrop-invert":["",yt,qe,Ke]}],"backdrop-opacity":[{"backdrop-opacity":[yt,qe,Ke]}],"backdrop-saturate":[{"backdrop-saturate":[yt,qe,Ke]}],"backdrop-sepia":[{"backdrop-sepia":["",yt,qe,Ke]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":V()}],"border-spacing-x":[{"border-spacing-x":V()}],"border-spacing-y":[{"border-spacing-y":V()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",qe,Ke]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[yt,"initial",qe,Ke]}],ease:[{ease:["linear","initial",S,qe,Ke]}],delay:[{delay:[yt,qe,Ke]}],animate:[{animate:["none",E,qe,Ke]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,qe,Ke]}],"perspective-origin":[{"perspective-origin":O()}],rotate:[{rotate:ve()}],"rotate-x":[{"rotate-x":ve()}],"rotate-y":[{"rotate-y":ve()}],"rotate-z":[{"rotate-z":ve()}],scale:[{scale:ye()}],"scale-x":[{"scale-x":ye()}],"scale-y":[{"scale-y":ye()}],"scale-z":[{"scale-z":ye()}],"scale-3d":["scale-3d"],skew:[{skew:ke()}],"skew-x":[{"skew-x":ke()}],"skew-y":[{"skew-y":ke()}],transform:[{transform:[qe,Ke,"","none","gpu","cpu"]}],"transform-origin":[{origin:O()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ze()}],"translate-x":[{"translate-x":ze()}],"translate-y":[{"translate-y":ze()}],"translate-z":[{"translate-z":ze()}],"translate-none":["translate-none"],accent:[{accent:R()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:R()}],"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",qe,Ke]}],"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":V()}],"scroll-mx":[{"scroll-mx":V()}],"scroll-my":[{"scroll-my":V()}],"scroll-ms":[{"scroll-ms":V()}],"scroll-me":[{"scroll-me":V()}],"scroll-mt":[{"scroll-mt":V()}],"scroll-mr":[{"scroll-mr":V()}],"scroll-mb":[{"scroll-mb":V()}],"scroll-ml":[{"scroll-ml":V()}],"scroll-p":[{"scroll-p":V()}],"scroll-px":[{"scroll-px":V()}],"scroll-py":[{"scroll-py":V()}],"scroll-ps":[{"scroll-ps":V()}],"scroll-pe":[{"scroll-pe":V()}],"scroll-pt":[{"scroll-pt":V()}],"scroll-pr":[{"scroll-pr":V()}],"scroll-pb":[{"scroll-pb":V()}],"scroll-pl":[{"scroll-pl":V()}],"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",qe,Ke]}],fill:[{fill:["none",...R()]}],"stroke-w":[{stroke:[yt,gd,qo,lx]}],stroke:[{stroke:["none",...R()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},EI=oI(TI);function Ut(...t){return EI(Dj(t))}function fo(t){if(!t)return"";let e=t.trim();return e?(e=e.replace(/^(https?)\/\//,"$1://"),e):""}const MI=_j("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function X({className:t,variant:e,size:n,asChild:r=!1,...a}){const i=r?Oj:"button";return s.jsx(i,{"data-slot":"button",className:Ut(MI({variant:e,size:n,className:t})),...a})}function ce({className:t,type:e,...n}){return s.jsx("input",{type:e,"data-slot":"input",className:Ut("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 AI(){const t=Sa(),[e,n]=b.useState(""),[r,a]=b.useState(""),[i,o]=b.useState(""),[c,u]=b.useState(!1);b.useEffect(()=>{iu()&&t("/dashboard",{replace:!0})},[t]);const h=async()=>{o(""),u(!0);try{const f=await Ct("/api/admin",{username:e.trim(),password:r});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){TA(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(dc,{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(oi,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(ce,{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(pM,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(ce,{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(X,{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 Oe=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ut("rounded-xl border bg-card text-card-foreground shadow",t),...e}));Oe.displayName="Card";const rt=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ut("flex flex-col space-y-1.5 p-6",t),...e}));rt.displayName="CardHeader";const at=b.forwardRef(({className:t,...e},n)=>s.jsx("h3",{ref:n,className:Ut("font-semibold leading-none tracking-tight",t),...e}));at.displayName="CardTitle";const Kt=b.forwardRef(({className:t,...e},n)=>s.jsx("p",{ref:n,className:Ut("text-sm text-muted-foreground",t),...e}));Kt.displayName="CardDescription";const Le=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ut("p-6 pt-0",t),...e}));Le.displayName="CardContent";const II=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ut("flex items-center p-6 pt-0",t),...e}));II.displayName="CardFooter";const RI={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function cx(t,e="info",n=3e3){const r=`toast-${Date.now()}`,a=RI[e],i=document.createElement("div");i.id=r,i.setAttribute("role","alert"),Object.assign(i.style,{position:"fixed",top:"24px",right:"24px",zIndex:"9999",display:"flex",alignItems:"center",gap:"10px",padding:"12px 18px",borderRadius:"10px",background:a.bg,border:`1.5px solid ${a.border}`,boxShadow:"0 4px 20px rgba(0,0,0,.12)",fontSize:"14px",color:"#1a1a1a",fontWeight:"500",maxWidth:"380px",lineHeight:"1.5",opacity:"0",transform:"translateY(-8px)",transition:"opacity .22s ease, transform .22s ease",pointerEvents:"none"});const o=document.createElement("span");Object.assign(o.style,{width:"20px",height:"20px",borderRadius:"50%",background:a.border,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"700",flexShrink:"0"}),o.textContent=a.icon;const c=document.createElement("span");c.textContent=t,i.appendChild(o),i.appendChild(c),document.body.appendChild(i),requestAnimationFrame(()=>{i.style.opacity="1",i.style.transform="translateY(0)"});const u=setTimeout(()=>h(r),n);function h(f){clearTimeout(u);const m=document.getElementById(f);m&&(m.style.opacity="0",m.style.transform="translateY(-8px)",setTimeout(()=>{var x;return(x=m.parentNode)==null?void 0:x.removeChild(m)},250))}}const se={success:(t,e)=>cx(t,"success",e),error:(t,e)=>cx(t,"error",e),info:(t,e)=>cx(t,"info",e)};function mt(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 PI(t,e){const n=b.createContext(e),r=i=>{const{children:o,...c}=i,u=b.useMemo(()=>c,Object.values(c));return s.jsx(n.Provider,{value:u,children:o})};r.displayName=t+"Provider";function a(i){const o=b.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[r,a]}function No(t,e=[]){let n=[];function r(i,o){const c=b.createContext(o),u=n.length;n=[...n,o];const h=m=>{var S;const{scope:x,children:y,...N}=m,w=((S=x==null?void 0:x[t])==null?void 0:S[u])||c,j=b.useMemo(()=>N,Object.values(N));return s.jsx(w.Provider,{value:j,children:y})};h.displayName=i+"Provider";function f(m,x){var w;const y=((w=x==null?void 0:x[t])==null?void 0:w[u])||c,N=b.useContext(y);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${i}\``)}return[h,f]}const a=()=>{const i=n.map(o=>b.createContext(o));return function(c){const u=(c==null?void 0:c[t])||i;return b.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return a.scopeName=t,[r,OI(a,...e)]}function OI(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((c,{useScope:u,scopeName:h})=>{const m=u(i)[`__scope${h}`];return{...c,...m}},{});return b.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var Ns=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},LI=Yf[" useId ".trim().toString()]||(()=>{}),DI=0;function oo(t){const[e,n]=b.useState(LI());return Ns(()=>{n(r=>r??String(DI++))},[t]),e?`radix-${e}`:""}var _I=Yf[" useInsertionEffect ".trim().toString()]||Ns;function cl({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[a,i,o]=zI({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:a;{const f=b.useRef(t!==void 0);b.useEffect(()=>{const m=f.current;m!==c&&console.warn(`${r} is changing from ${m?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=c},[c,r])}const h=b.useCallback(f=>{var m;if(c){const x=$I(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 zI({defaultProp:t,onChange:e}){const[n,r]=b.useState(t),a=b.useRef(n),i=b.useRef(e);return _I(()=>{i.current=e},[e]),b.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,r,i]}function $I(t){return typeof t=="function"}function Ud(t){const e=FI(t),n=b.forwardRef((r,a)=>{const{children:i,...o}=r,c=b.Children.toArray(i),u=c.find(VI);if(u){const h=u.props.children,f=c.map(m=>m===u?b.Children.count(h)>1?b.Children.only(null):b.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:a,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function FI(t){const e=b.forwardRef((n,r)=>{const{children:a,...i}=n;if(b.isValidElement(a)){const o=UI(a),c=HI(i,a.props);return a.type!==b.Fragment&&(c.ref=r?y0(r,o):o),b.cloneElement(a,c)}return b.Children.count(a)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var BI=Symbol("radix.slottable");function VI(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===BI}function HI(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 UI(t){var r,a;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var WI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],bt=WI.reduce((t,e)=>{const n=Ud(`Primitive.${e}`),r=b.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function KI(t,e){t&&au.flushSync(()=>t.dispatchEvent(e))}function po(t){const e=b.useRef(t);return b.useEffect(()=>{e.current=t}),b.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function qI(t,e=globalThis==null?void 0:globalThis.document){const n=po(t);b.useEffect(()=>{const r=a=>{a.key==="Escape"&&n(a)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var GI="DismissableLayer",fg="dismissableLayer.update",JI="dismissableLayer.pointerDownOutside",QI="dismissableLayer.focusOutside",N1,Qj=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),v0=b.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:c,...u}=t,h=b.useContext(Qj),[f,m]=b.useState(null),x=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=b.useState({}),N=Ht(e,z=>m(z)),w=Array.from(h.layers),[j]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),S=w.indexOf(j),E=f?w.indexOf(f):-1,T=h.layersWithOutsidePointerEventsDisabled.size>0,P=E>=S,O=ZI(z=>{const V=z.target,I=[...h.branches].some(te=>te.contains(V));!P||I||(a==null||a(z),o==null||o(z),z.defaultPrevented||c==null||c())},x),q=eR(z=>{const V=z.target;[...h.branches].some(te=>te.contains(V))||(i==null||i(z),o==null||o(z),z.defaultPrevented||c==null||c())},x);return qI(z=>{E===h.layers.size-1&&(r==null||r(z),!z.defaultPrevented&&c&&(z.preventDefault(),c()))},x),b.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(N1=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),w1(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=N1)}},[f,x,n,h]),b.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),w1())},[f,h]),b.useEffect(()=>{const z=()=>y({});return document.addEventListener(fg,z),()=>document.removeEventListener(fg,z)},[]),s.jsx(bt.div,{...u,ref:N,style:{pointerEvents:T?P?"auto":"none":void 0,...t.style},onFocusCapture:mt(t.onFocusCapture,q.onFocusCapture),onBlurCapture:mt(t.onBlurCapture,q.onBlurCapture),onPointerDownCapture:mt(t.onPointerDownCapture,O.onPointerDownCapture)})});v0.displayName=GI;var YI="DismissableLayerBranch",XI=b.forwardRef((t,e)=>{const n=b.useContext(Qj),r=b.useRef(null),a=Ht(e,r);return b.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(bt.div,{...t,ref:a})});XI.displayName=YI;function ZI(t,e=globalThis==null?void 0:globalThis.document){const n=po(t),r=b.useRef(!1),a=b.useRef(()=>{});return b.useEffect(()=>{const i=c=>{if(c.target&&!r.current){let u=function(){Yj(JI,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 eR(t,e=globalThis==null?void 0:globalThis.document){const n=po(t),r=b.useRef(!1);return b.useEffect(()=>{const a=i=>{i.target&&!r.current&&Yj(QI,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 w1(){const t=new CustomEvent(fg);document.dispatchEvent(t)}function Yj(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?KI(a,i):a.dispatchEvent(i)}var dx="focusScope.autoFocusOnMount",ux="focusScope.autoFocusOnUnmount",j1={bubbles:!1,cancelable:!0},tR="FocusScope",N0=b.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[c,u]=b.useState(null),h=po(a),f=po(i),m=b.useRef(null),x=Ht(e,w=>u(w)),y=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(r){let w=function(T){if(y.paused||!c)return;const P=T.target;c.contains(P)?m.current=P:qi(m.current,{select:!0})},j=function(T){if(y.paused||!c)return;const P=T.relatedTarget;P!==null&&(c.contains(P)||qi(m.current,{select:!0}))},S=function(T){if(document.activeElement===document.body)for(const O of T)O.removedNodes.length>0&&qi(c)};document.addEventListener("focusin",w),document.addEventListener("focusout",j);const E=new MutationObserver(S);return c&&E.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",j),E.disconnect()}}},[r,c,y.paused]),b.useEffect(()=>{if(c){S1.add(y);const w=document.activeElement;if(!c.contains(w)){const S=new CustomEvent(dx,j1);c.addEventListener(dx,h),c.dispatchEvent(S),S.defaultPrevented||(nR(oR(Xj(c)),{select:!0}),document.activeElement===w&&qi(c))}return()=>{c.removeEventListener(dx,h),setTimeout(()=>{const S=new CustomEvent(ux,j1);c.addEventListener(ux,f),c.dispatchEvent(S),S.defaultPrevented||qi(w??document.body,{select:!0}),c.removeEventListener(ux,f),S1.remove(y)},0)}}},[c,h,f,y]);const N=b.useCallback(w=>{if(!n&&!r||y.paused)return;const j=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,S=document.activeElement;if(j&&S){const E=w.currentTarget,[T,P]=sR(E);T&&P?!w.shiftKey&&S===P?(w.preventDefault(),n&&qi(T,{select:!0})):w.shiftKey&&S===T&&(w.preventDefault(),n&&qi(P,{select:!0})):S===E&&w.preventDefault()}},[n,r,y.paused]);return s.jsx(bt.div,{tabIndex:-1,...o,ref:x,onKeyDown:N})});N0.displayName=tR;function nR(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(qi(r,{select:e}),document.activeElement!==n)return}function sR(t){const e=Xj(t),n=k1(e,t),r=k1(e.reverse(),t);return[n,r]}function Xj(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 k1(t,e){for(const n of t)if(!rR(n,{upTo:e}))return n}function rR(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 aR(t){return t instanceof HTMLInputElement&&"select"in t}function qi(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&aR(t)&&e&&t.select()}}var S1=iR();function iR(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=C1(t,e),t.unshift(e)},remove(e){var n;t=C1(t,e),(n=t[0])==null||n.resume()}}}function C1(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function oR(t){return t.filter(e=>e.tagName!=="A")}var lR="Portal",w0=b.forwardRef((t,e)=>{var c;const{container:n,...r}=t,[a,i]=b.useState(!1);Ns(()=>i(!0),[]);const o=n||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?uj.createPortal(s.jsx(bt.div,{...r,ref:e}),o):null});w0.displayName=lR;function cR(t,e){return b.useReducer((n,r)=>e[n][r]??n,t)}var ou=t=>{const{present:e,children:n}=t,r=dR(e),a=typeof n=="function"?n({present:r.isPresent}):b.Children.only(n),i=Ht(r.ref,uR(a));return typeof n=="function"||r.isPresent?b.cloneElement(a,{ref:i}):null};ou.displayName="Presence";function dR(t){const[e,n]=b.useState(),r=b.useRef(null),a=b.useRef(t),i=b.useRef("none"),o=t?"mounted":"unmounted",[c,u]=cR(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const h=fh(r.current);i.current=c==="mounted"?h:"none"},[c]),Ns(()=>{const h=r.current,f=a.current;if(f!==t){const x=i.current,y=fh(h);t?u("MOUNT"):y==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&x!==y?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,u]),Ns(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=y=>{const w=fh(r.current).includes(CSS.escape(y.animationName));if(y.target===e&&w&&(u("ANIMATION_END"),!a.current)){const j=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=j)})}},x=y=>{y.target===e&&(i.current=fh(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:b.useCallback(h=>{r.current=h?getComputedStyle(h):null,n(h)},[])}}function fh(t){return(t==null?void 0:t.animationName)||"none"}function uR(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 hx=0;function Zj(){b.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??T1()),document.body.insertAdjacentElement("beforeend",t[1]??T1()),hx++,()=>{hx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),hx--}},[])}function T1(){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 ga=function(){return ga=Object.assign||function(e){for(var n,r=1,a=arguments.length;r"u")return ER;var e=MR(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])}},IR=sk(),mc="data-scroll-locked",RR=function(t,e,n,r){var a=t.left,i=t.top,o=t.right,c=t.gap;return n===void 0&&(n="margin"),` .`.concat(fR,` { overflow: hidden `).concat(r,`; padding-right: `).concat(c,"px ").concat(r,`; @@ -621,15 +621,15 @@ Error generating stack: `+C.message+` body[`).concat(mc,`] { `).concat(pR,": ").concat(c,`px; } -`)},M1=function(){var t=parseInt(document.body.getAttribute(mc)||"0",10);return isFinite(t)?t:0},PR=function(){b.useEffect(function(){return document.body.setAttribute(mc,(M1()+1).toString()),function(){var t=M1()-1;t<=0?document.body.removeAttribute(mc):document.body.setAttribute(mc,t.toString())}},[])},OR=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,a=r===void 0?"margin":r;PR();var i=b.useMemo(function(){return AR(a)},[a]);return b.createElement(IR,{styles:RR(i,!e,a,n?"":"!important")})},px=!1;if(typeof window<"u")try{var ph=Object.defineProperty({},"passive",{get:function(){return px=!0,!0}});window.addEventListener("test",ph,ph),window.removeEventListener("test",ph,ph)}catch{px=!1}var Xl=px?{passive:!1}:!1,LR=function(t){return t.tagName==="TEXTAREA"},rk=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!LR(t)&&n[e]==="visible")},DR=function(t){return rk(t,"overflowY")},_R=function(t){return rk(t,"overflowX")},A1=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=ak(t,r);if(a){var i=ik(t,r),o=i[1],c=i[2];if(o>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},zR=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},$R=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},ak=function(t,e){return t==="v"?DR(e):_R(e)},ik=function(t,e){return t==="v"?zR(e):$R(e)},FR=function(t,e){return t==="h"&&e==="rtl"?-1:1},BR=function(t,e,n,r,a){var i=FR(t,window.getComputedStyle(e).direction),o=i*r,c=n.target,u=e.contains(c),h=!1,f=o>0,m=0,g=0;do{if(!c)break;var y=ik(t,c),N=y[0],w=y[1],j=y[2],S=w-j-i*N;(N||S)&&ak(t,c)&&(m+=S,g+=N);var E=c.parentNode;c=E&&E.nodeType===Node.DOCUMENT_FRAGMENT_NODE?E.host:E}while(!u&&c!==document.body||u&&(e.contains(c)||e===c));return(f&&Math.abs(m)<1||!f&&Math.abs(g)<1)&&(h=!0),h},mh=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},I1=function(t){return[t.deltaX,t.deltaY]},R1=function(t){return t&&"current"in t?t.current:t},VR=function(t,e){return t[0]===e[0]&&t[1]===e[1]},HR=function(t){return` +`)},M1=function(){var t=parseInt(document.body.getAttribute(mc)||"0",10);return isFinite(t)?t:0},PR=function(){b.useEffect(function(){return document.body.setAttribute(mc,(M1()+1).toString()),function(){var t=M1()-1;t<=0?document.body.removeAttribute(mc):document.body.setAttribute(mc,t.toString())}},[])},OR=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,a=r===void 0?"margin":r;PR();var i=b.useMemo(function(){return AR(a)},[a]);return b.createElement(IR,{styles:RR(i,!e,a,n?"":"!important")})},pg=!1;if(typeof window<"u")try{var ph=Object.defineProperty({},"passive",{get:function(){return pg=!0,!0}});window.addEventListener("test",ph,ph),window.removeEventListener("test",ph,ph)}catch{pg=!1}var Xl=pg?{passive:!1}:!1,LR=function(t){return t.tagName==="TEXTAREA"},rk=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!LR(t)&&n[e]==="visible")},DR=function(t){return rk(t,"overflowY")},_R=function(t){return rk(t,"overflowX")},A1=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=ak(t,r);if(a){var i=ik(t,r),o=i[1],c=i[2];if(o>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},zR=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},$R=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},ak=function(t,e){return t==="v"?DR(e):_R(e)},ik=function(t,e){return t==="v"?zR(e):$R(e)},FR=function(t,e){return t==="h"&&e==="rtl"?-1:1},BR=function(t,e,n,r,a){var i=FR(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 y=ik(t,c),N=y[0],w=y[1],j=y[2],S=w-j-i*N;(N||S)&&ak(t,c)&&(m+=S,x+=N);var E=c.parentNode;c=E&&E.nodeType===Node.DOCUMENT_FRAGMENT_NODE?E.host:E}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},mh=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},I1=function(t){return[t.deltaX,t.deltaY]},R1=function(t){return t&&"current"in t?t.current:t},VR=function(t,e){return t[0]===e[0]&&t[1]===e[1]},HR=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} -`)},UR=0,Zl=[];function WR(t){var e=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),a=b.useState(UR++)[0],i=b.useState(sk)[0],o=b.useRef(t);b.useEffect(function(){o.current=t},[t]),b.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var w=hR([t.lockRef.current],(t.shards||[]).map(R1),!0).filter(Boolean);return w.forEach(function(j){return j.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),w.forEach(function(j){return j.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var c=b.useCallback(function(w,j){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!o.current.allowPinchZoom;var S=mh(w),E=n.current,T="deltaX"in w?w.deltaX:E[0]-S[0],P="deltaY"in w?w.deltaY:E[1]-S[1],O,q=w.target,z=Math.abs(T)>Math.abs(P)?"h":"v";if("touches"in w&&z==="h"&&q.type==="range")return!1;var V=window.getSelection(),I=V&&V.anchorNode,te=I?I===q||I.contains(q):!1;if(te)return!1;var Q=A1(z,q);if(!Q)return!0;if(Q?O=z:(O=z==="v"?"h":"v",Q=A1(z,q)),!Q)return!1;if(!r.current&&"changedTouches"in w&&(T||P)&&(r.current=O),!O)return!0;var F=r.current||O;return BR(F,j,w,F==="h"?T:P)},[]),u=b.useCallback(function(w){var j=w;if(!(!Zl.length||Zl[Zl.length-1]!==i)){var S="deltaY"in j?I1(j):mh(j),E=e.current.filter(function(O){return O.name===j.type&&(O.target===j.target||j.target===O.shadowParent)&&VR(O.delta,S)})[0];if(E&&E.should){j.cancelable&&j.preventDefault();return}if(!E){var T=(o.current.shards||[]).map(R1).filter(Boolean).filter(function(O){return O.contains(j.target)}),P=T.length>0?c(j,T[0]):!o.current.noIsolation;P&&j.cancelable&&j.preventDefault()}}},[]),h=b.useCallback(function(w,j,S,E){var T={name:w,delta:j,target:S,should:E,shadowParent:KR(S)};e.current.push(T),setTimeout(function(){e.current=e.current.filter(function(P){return P!==T})},1)},[]),f=b.useCallback(function(w){n.current=mh(w),r.current=void 0},[]),m=b.useCallback(function(w){h(w.type,I1(w),w.target,c(w,t.lockRef.current))},[]),g=b.useCallback(function(w){h(w.type,mh(w),w.target,c(w,t.lockRef.current))},[]);b.useEffect(function(){return Zl.push(i),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:g}),document.addEventListener("wheel",u,Xl),document.addEventListener("touchmove",u,Xl),document.addEventListener("touchstart",f,Xl),function(){Zl=Zl.filter(function(w){return w!==i}),document.removeEventListener("wheel",u,Xl),document.removeEventListener("touchmove",u,Xl),document.removeEventListener("touchstart",f,Xl)}},[]);var y=t.removeScrollBar,N=t.inert;return b.createElement(b.Fragment,null,N?b.createElement(i,{styles:HR(a)}):null,y?b.createElement(OR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function KR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const qR=NR(nk,WR);var j0=b.forwardRef(function(t,e){return b.createElement(tp,xa({},t,{ref:e,sideCar:qR}))});j0.classNames=tp.classNames;var GR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},ec=new WeakMap,gh=new WeakMap,xh={},gg=0,ok=function(t){return t&&(t.host||ok(t.parentNode))},JR=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=ok(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})},QR=function(t,e,n,r){var a=JR(e,Array.isArray(t)?t:[t]);xh[n]||(xh[n]=new WeakMap);var i=xh[n],o=[],c=new Set,u=new Set(a),h=function(m){!m||c.has(m)||(c.add(m),h(m.parentNode))};a.forEach(h);var f=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(g){if(c.has(g))f(g);else try{var y=g.getAttribute(r),N=y!==null&&y!=="false",w=(ec.get(g)||0)+1,j=(i.get(g)||0)+1;ec.set(g,w),i.set(g,j),o.push(g),w===1&&N&&gh.set(g,!0),j===1&&g.setAttribute(n,"true"),N||g.setAttribute(r,"true")}catch(S){console.error("aria-hidden: cannot operate on ",g,S)}})};return f(e),c.clear(),gg++,function(){o.forEach(function(m){var g=ec.get(m)-1,y=i.get(m)-1;ec.set(m,g),i.set(m,y),g||(gh.has(m)||m.removeAttribute(r),gh.delete(m)),y||m.removeAttribute(n)}),gg--,gg||(ec=new WeakMap,ec=new WeakMap,gh=new WeakMap,xh={})}},lk=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),a=GR(t);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),QR(r,a,n,"aria-hidden")):function(){return null}},np="Dialog",[ck]=No(np),[YR,Xr]=ck(np),dk=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,c=b.useRef(null),u=b.useRef(null),[h,f]=cl({prop:r,defaultProp:a??!1,onChange:i,caller:np});return s.jsx(YR,{scope:e,triggerRef:c,contentRef:u,contentId:oo(),titleId:oo(),descriptionId:oo(),open:h,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};dk.displayName=np;var uk="DialogTrigger",XR=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Xr(uk,n),i=Ht(e,a.triggerRef);return s.jsx(bt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":C0(a.open),...r,ref:i,onClick:mt(t.onClick,a.onOpenToggle)})});XR.displayName=uk;var k0="DialogPortal",[ZR,hk]=ck(k0,{forceMount:void 0}),fk=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:a}=t,i=Xr(k0,e);return s.jsx(ZR,{scope:e,forceMount:n,children:b.Children.map(r,o=>s.jsx(ou,{present:n||i.open,children:s.jsx(w0,{asChild:!0,container:a,children:o})}))})};fk.displayName=k0;var Xh="DialogOverlay",pk=b.forwardRef((t,e)=>{const n=hk(Xh,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=Xr(Xh,t.__scopeDialog);return i.modal?s.jsx(ou,{present:r||i.open,children:s.jsx(tP,{...a,ref:e})}):null});pk.displayName=Xh;var eP=Ud("DialogOverlay.RemoveScroll"),tP=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Xr(Xh,n);return s.jsx(j0,{as:eP,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(bt.div,{"data-state":C0(a.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),dl="DialogContent",mk=b.forwardRef((t,e)=>{const n=hk(dl,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=Xr(dl,t.__scopeDialog);return s.jsx(ou,{present:r||i.open,children:i.modal?s.jsx(nP,{...a,ref:e}):s.jsx(sP,{...a,ref:e})})});mk.displayName=dl;var nP=b.forwardRef((t,e)=>{const n=Xr(dl,t.__scopeDialog),r=b.useRef(null),a=Ht(e,n.contentRef,r);return b.useEffect(()=>{const i=r.current;if(i)return lk(i)},[]),s.jsx(gk,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:mt(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:mt(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&i.preventDefault()}),onFocusOutside:mt(t.onFocusOutside,i=>i.preventDefault())})}),sP=b.forwardRef((t,e)=>{const n=Xr(dl,t.__scopeDialog),r=b.useRef(!1),a=b.useRef(!1);return s.jsx(gk,{...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()}})}),gk=b.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,c=Xr(dl,n),u=b.useRef(null),h=Ht(e,u);return Zj(),s.jsxs(s.Fragment,{children:[s.jsx(N0,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:s.jsx(v0,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":C0(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(rP,{titleId:c.titleId}),s.jsx(iP,{contentRef:u,descriptionId:c.descriptionId})]})]})}),S0="DialogTitle",xk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Xr(S0,n);return s.jsx(bt.h2,{id:a.titleId,...r,ref:e})});xk.displayName=S0;var yk="DialogDescription",bk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Xr(yk,n);return s.jsx(bt.p,{id:a.descriptionId,...r,ref:e})});bk.displayName=yk;var vk="DialogClose",Nk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Xr(vk,n);return s.jsx(bt.button,{type:"button",...r,ref:e,onClick:mt(t.onClick,()=>a.onOpenChange(!1))})});Nk.displayName=vk;function C0(t){return t?"open":"closed"}var wk="DialogTitleWarning",[PV,jk]=PI(wk,{contentName:dl,titleName:S0,docsSlug:"dialog"}),rP=({titleId:t})=>{const e=jk(wk),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users. +`)},UR=0,Zl=[];function WR(t){var e=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),a=b.useState(UR++)[0],i=b.useState(sk)[0],o=b.useRef(t);b.useEffect(function(){o.current=t},[t]),b.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var w=hR([t.lockRef.current],(t.shards||[]).map(R1),!0).filter(Boolean);return w.forEach(function(j){return j.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),w.forEach(function(j){return j.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var c=b.useCallback(function(w,j){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!o.current.allowPinchZoom;var S=mh(w),E=n.current,T="deltaX"in w?w.deltaX:E[0]-S[0],P="deltaY"in w?w.deltaY:E[1]-S[1],O,q=w.target,z=Math.abs(T)>Math.abs(P)?"h":"v";if("touches"in w&&z==="h"&&q.type==="range")return!1;var V=window.getSelection(),I=V&&V.anchorNode,te=I?I===q||I.contains(q):!1;if(te)return!1;var Q=A1(z,q);if(!Q)return!0;if(Q?O=z:(O=z==="v"?"h":"v",Q=A1(z,q)),!Q)return!1;if(!r.current&&"changedTouches"in w&&(T||P)&&(r.current=O),!O)return!0;var F=r.current||O;return BR(F,j,w,F==="h"?T:P)},[]),u=b.useCallback(function(w){var j=w;if(!(!Zl.length||Zl[Zl.length-1]!==i)){var S="deltaY"in j?I1(j):mh(j),E=e.current.filter(function(O){return O.name===j.type&&(O.target===j.target||j.target===O.shadowParent)&&VR(O.delta,S)})[0];if(E&&E.should){j.cancelable&&j.preventDefault();return}if(!E){var T=(o.current.shards||[]).map(R1).filter(Boolean).filter(function(O){return O.contains(j.target)}),P=T.length>0?c(j,T[0]):!o.current.noIsolation;P&&j.cancelable&&j.preventDefault()}}},[]),h=b.useCallback(function(w,j,S,E){var T={name:w,delta:j,target:S,should:E,shadowParent:KR(S)};e.current.push(T),setTimeout(function(){e.current=e.current.filter(function(P){return P!==T})},1)},[]),f=b.useCallback(function(w){n.current=mh(w),r.current=void 0},[]),m=b.useCallback(function(w){h(w.type,I1(w),w.target,c(w,t.lockRef.current))},[]),x=b.useCallback(function(w){h(w.type,mh(w),w.target,c(w,t.lockRef.current))},[]);b.useEffect(function(){return Zl.push(i),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:x}),document.addEventListener("wheel",u,Xl),document.addEventListener("touchmove",u,Xl),document.addEventListener("touchstart",f,Xl),function(){Zl=Zl.filter(function(w){return w!==i}),document.removeEventListener("wheel",u,Xl),document.removeEventListener("touchmove",u,Xl),document.removeEventListener("touchstart",f,Xl)}},[]);var y=t.removeScrollBar,N=t.inert;return b.createElement(b.Fragment,null,N?b.createElement(i,{styles:HR(a)}):null,y?b.createElement(OR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function KR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const qR=NR(nk,WR);var j0=b.forwardRef(function(t,e){return b.createElement(tp,ga({},t,{ref:e,sideCar:qR}))});j0.classNames=tp.classNames;var GR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},ec=new WeakMap,xh=new WeakMap,gh={},xx=0,ok=function(t){return t&&(t.host||ok(t.parentNode))},JR=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=ok(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})},QR=function(t,e,n,r){var a=JR(e,Array.isArray(t)?t:[t]);gh[n]||(gh[n]=new WeakMap);var i=gh[n],o=[],c=new Set,u=new Set(a),h=function(m){!m||c.has(m)||(c.add(m),h(m.parentNode))};a.forEach(h);var f=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(x){if(c.has(x))f(x);else try{var y=x.getAttribute(r),N=y!==null&&y!=="false",w=(ec.get(x)||0)+1,j=(i.get(x)||0)+1;ec.set(x,w),i.set(x,j),o.push(x),w===1&&N&&xh.set(x,!0),j===1&&x.setAttribute(n,"true"),N||x.setAttribute(r,"true")}catch(S){console.error("aria-hidden: cannot operate on ",x,S)}})};return f(e),c.clear(),xx++,function(){o.forEach(function(m){var x=ec.get(m)-1,y=i.get(m)-1;ec.set(m,x),i.set(m,y),x||(xh.has(m)||m.removeAttribute(r),xh.delete(m)),y||m.removeAttribute(n)}),xx--,xx||(ec=new WeakMap,ec=new WeakMap,xh=new WeakMap,gh={})}},lk=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),a=GR(t);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),QR(r,a,n,"aria-hidden")):function(){return null}},np="Dialog",[ck]=No(np),[YR,Xr]=ck(np),dk=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,c=b.useRef(null),u=b.useRef(null),[h,f]=cl({prop:r,defaultProp:a??!1,onChange:i,caller:np});return s.jsx(YR,{scope:e,triggerRef:c,contentRef:u,contentId:oo(),titleId:oo(),descriptionId:oo(),open:h,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};dk.displayName=np;var uk="DialogTrigger",XR=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Xr(uk,n),i=Ht(e,a.triggerRef);return s.jsx(bt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":C0(a.open),...r,ref:i,onClick:mt(t.onClick,a.onOpenToggle)})});XR.displayName=uk;var k0="DialogPortal",[ZR,hk]=ck(k0,{forceMount:void 0}),fk=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:a}=t,i=Xr(k0,e);return s.jsx(ZR,{scope:e,forceMount:n,children:b.Children.map(r,o=>s.jsx(ou,{present:n||i.open,children:s.jsx(w0,{asChild:!0,container:a,children:o})}))})};fk.displayName=k0;var Xh="DialogOverlay",pk=b.forwardRef((t,e)=>{const n=hk(Xh,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=Xr(Xh,t.__scopeDialog);return i.modal?s.jsx(ou,{present:r||i.open,children:s.jsx(tP,{...a,ref:e})}):null});pk.displayName=Xh;var eP=Ud("DialogOverlay.RemoveScroll"),tP=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Xr(Xh,n);return s.jsx(j0,{as:eP,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(bt.div,{"data-state":C0(a.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),dl="DialogContent",mk=b.forwardRef((t,e)=>{const n=hk(dl,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=Xr(dl,t.__scopeDialog);return s.jsx(ou,{present:r||i.open,children:i.modal?s.jsx(nP,{...a,ref:e}):s.jsx(sP,{...a,ref:e})})});mk.displayName=dl;var nP=b.forwardRef((t,e)=>{const n=Xr(dl,t.__scopeDialog),r=b.useRef(null),a=Ht(e,n.contentRef,r);return b.useEffect(()=>{const i=r.current;if(i)return lk(i)},[]),s.jsx(xk,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:mt(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:mt(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&i.preventDefault()}),onFocusOutside:mt(t.onFocusOutside,i=>i.preventDefault())})}),sP=b.forwardRef((t,e)=>{const n=Xr(dl,t.__scopeDialog),r=b.useRef(!1),a=b.useRef(!1);return s.jsx(xk,{...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()}})}),xk=b.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,c=Xr(dl,n),u=b.useRef(null),h=Ht(e,u);return Zj(),s.jsxs(s.Fragment,{children:[s.jsx(N0,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:s.jsx(v0,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":C0(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(rP,{titleId:c.titleId}),s.jsx(iP,{contentRef:u,descriptionId:c.descriptionId})]})]})}),S0="DialogTitle",gk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Xr(S0,n);return s.jsx(bt.h2,{id:a.titleId,...r,ref:e})});gk.displayName=S0;var yk="DialogDescription",bk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Xr(yk,n);return s.jsx(bt.p,{id:a.descriptionId,...r,ref:e})});bk.displayName=yk;var vk="DialogClose",Nk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Xr(vk,n);return s.jsx(bt.button,{type:"button",...r,ref:e,onClick:mt(t.onClick,()=>a.onOpenChange(!1))})});Nk.displayName=vk;function C0(t){return t?"open":"closed"}var wk="DialogTitleWarning",[PV,jk]=PI(wk,{contentName:dl,titleName:S0,docsSlug:"dialog"}),rP=({titleId:t})=>{const e=jk(wk),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component. -For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return b.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},aP="DialogDescriptionWarning",iP=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${jk(aP).contentName}}.`;return b.useEffect(()=>{var i;const a=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");e&&a&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},oP=dk,lP=fk,cP=pk,dP=mk,uP=xk,hP=bk,fP=Nk;function Dt(t){return s.jsx(oP,{"data-slot":"dialog",...t})}function pP(t){return s.jsx(lP,{...t})}const kk=b.forwardRef(({className:t,...e},n)=>s.jsx(cP,{ref:n,className:Ut("fixed inset-0 z-50 bg-black/50",t),...e}));kk.displayName="DialogOverlay";const Lt=b.forwardRef(({className:t,children:e,showCloseButton:n=!0,...r},a)=>s.jsxs(pP,{children:[s.jsx(kk,{}),s.jsxs(dP,{ref:a,"aria-describedby":void 0,className:Ut("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(fP,{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(Yn,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Lt.displayName="DialogContent";function _t({className:t,...e}){return s.jsx("div",{className:Ut("flex flex-col gap-2 text-center sm:text-left",t),...e})}function fn({className:t,...e}){return s.jsx("div",{className:Ut("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function zt(t){return s.jsx(uP,{className:"text-lg font-semibold leading-none",...t})}function Zh(t){return s.jsx(hP,{className:"text-sm text-muted-foreground",...t})}const mP=_j("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 transition-colors",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ve({className:t,variant:e,asChild:n=!1,...r}){const a=n?Oj:"span";return s.jsx(a,{className:Ut(mP({variant:e}),t),...r})}var gP=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],xP=gP.reduce((t,e)=>{const n=Pj(`Primitive.${e}`),r=b.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),yP="Label",Sk=b.forwardRef((t,e)=>s.jsx(xP.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())}}));Sk.displayName=yP;var Ck=Sk;const ee=b.forwardRef(({className:t,...e},n)=>s.jsx(Ck,{ref:n,className:Ut("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));ee.displayName=Ck.displayName;function T0(t){const e=t+"CollectionProvider",[n,r]=No(e),[a,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:j,children:S}=w,E=As.useRef(null),T=As.useRef(new Map).current;return s.jsx(a,{scope:j,itemMap:T,collectionRef:E,children:S})};o.displayName=e;const c=t+"CollectionSlot",u=Ud(c),h=As.forwardRef((w,j)=>{const{scope:S,children:E}=w,T=i(c,S),P=Ht(j,T.collectionRef);return s.jsx(u,{ref:P,children:E})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",g=Ud(f),y=As.forwardRef((w,j)=>{const{scope:S,children:E,...T}=w,P=As.useRef(null),O=Ht(j,P),q=i(f,S);return As.useEffect(()=>(q.itemMap.set(P,{ref:P,...T}),()=>void q.itemMap.delete(P))),s.jsx(g,{[m]:"",ref:O,children:E})});y.displayName=f;function N(w){const j=i(t+"CollectionConsumer",w);return As.useCallback(()=>{const E=j.collectionRef.current;if(!E)return[];const T=Array.from(E.querySelectorAll(`[${m}]`));return Array.from(j.itemMap.values()).sort((q,z)=>T.indexOf(q.ref.current)-T.indexOf(z.ref.current))},[j.collectionRef,j.itemMap])}return[{Provider:o,Slot:h,ItemSlot:y},N,r]}var bP=b.createContext(void 0);function sp(t){const e=b.useContext(bP);return t||e||"ltr"}var xg="rovingFocusGroup.onEntryFocus",vP={bubbles:!1,cancelable:!0},lu="RovingFocusGroup",[mx,Tk,NP]=T0(lu),[wP,Ek]=No(lu,[NP]),[jP,kP]=wP(lu),Mk=b.forwardRef((t,e)=>s.jsx(mx.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(mx.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(SP,{...t,ref:e})})}));Mk.displayName=lu;var SP=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...m}=t,g=b.useRef(null),y=Ht(e,g),N=sp(i),[w,j]=cl({prop:o,defaultProp:c??null,onChange:u,caller:lu}),[S,E]=b.useState(!1),T=po(h),P=Tk(n),O=b.useRef(!1),[q,z]=b.useState(0);return b.useEffect(()=>{const V=g.current;if(V)return V.addEventListener(xg,T),()=>V.removeEventListener(xg,T)},[T]),s.jsx(jP,{scope:n,orientation:r,dir:N,loop:a,currentTabStopId:w,onItemFocus:b.useCallback(V=>j(V),[j]),onItemShiftTab:b.useCallback(()=>E(!0),[]),onFocusableItemAdd:b.useCallback(()=>z(V=>V+1),[]),onFocusableItemRemove:b.useCallback(()=>z(V=>V-1),[]),children:s.jsx(bt.div,{tabIndex:S||q===0?-1:0,"data-orientation":r,...m,ref:y,style:{outline:"none",...t.style},onMouseDown:mt(t.onMouseDown,()=>{O.current=!0}),onFocus:mt(t.onFocus,V=>{const I=!O.current;if(V.target===V.currentTarget&&I&&!S){const te=new CustomEvent(xg,vP);if(V.currentTarget.dispatchEvent(te),!te.defaultPrevented){const Q=P().filter($=>$.focusable),F=Q.find($=>$.active),re=Q.find($=>$.id===w),J=[F,re,...Q].filter(Boolean).map($=>$.ref.current);Rk(J,f)}}O.current=!1}),onBlur:mt(t.onBlur,()=>E(!1))})})}),Ak="RovingFocusGroupItem",Ik=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...c}=t,u=oo(),h=i||u,f=kP(Ak,n),m=f.currentTabStopId===h,g=Tk(n),{onFocusableItemAdd:y,onFocusableItemRemove:N,currentTabStopId:w}=f;return b.useEffect(()=>{if(r)return y(),()=>N()},[r,y,N]),s.jsx(mx.ItemSlot,{scope:n,id:h,focusable:r,active:a,children:s.jsx(bt.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:mt(t.onMouseDown,j=>{r?f.onItemFocus(h):j.preventDefault()}),onFocus:mt(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:mt(t.onKeyDown,j=>{if(j.key==="Tab"&&j.shiftKey){f.onItemShiftTab();return}if(j.target!==j.currentTarget)return;const S=EP(j,f.orientation,f.dir);if(S!==void 0){if(j.metaKey||j.ctrlKey||j.altKey||j.shiftKey)return;j.preventDefault();let T=g().filter(P=>P.focusable).map(P=>P.ref.current);if(S==="last")T.reverse();else if(S==="prev"||S==="next"){S==="prev"&&T.reverse();const P=T.indexOf(j.currentTarget);T=f.loop?MP(T,P+1):T.slice(P+1)}setTimeout(()=>Rk(T))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:w!=null}):o})})});Ik.displayName=Ak;var CP={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function TP(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function EP(t,e,n){const r=TP(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return CP[r]}function Rk(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function MP(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var AP=Mk,IP=Ik,rp="Tabs",[RP]=No(rp,[Ek]),Pk=Ek(),[PP,E0]=RP(rp),Ok=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=sp(c),[m,g]=cl({prop:r,onChange:a,defaultProp:i??"",caller:rp});return s.jsx(PP,{scope:n,baseId:oo(),value:m,onValueChange:g,orientation:o,dir:f,activationMode:u,children:s.jsx(bt.div,{dir:f,"data-orientation":o,...h,ref:e})})});Ok.displayName=rp;var Lk="TabsList",Dk=b.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...a}=t,i=E0(Lk,n),o=Pk(n);return s.jsx(AP,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(bt.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:e})})});Dk.displayName=Lk;var _k="TabsTrigger",zk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...i}=t,o=E0(_k,n),c=Pk(n),u=Bk(o.baseId,r),h=Vk(o.baseId,r),f=r===o.value;return s.jsx(IP,{asChild:!0,...c,focusable:!a,active:f,children:s.jsx(bt.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:mt(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(r):m.preventDefault()}),onKeyDown:mt(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(r)}),onFocus:mt(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!a&&m&&o.onValueChange(r)})})})});zk.displayName=_k;var $k="TabsContent",Fk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=t,c=E0($k,n),u=Bk(c.baseId,r),h=Vk(c.baseId,r),f=r===c.value,m=b.useRef(f);return b.useEffect(()=>{const g=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(g)},[]),s.jsx(ou,{present:a||f,children:({present:g})=>s.jsx(bt.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!g,id:h,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:m.current?"0s":void 0},children:g&&i})})});Fk.displayName=$k;function Bk(t,e){return`${t}-trigger-${e}`}function Vk(t,e){return`${t}-content-${e}`}var OP=Ok,Hk=Dk,Uk=zk,Wk=Fk;const jc=OP,ul=b.forwardRef(({className:t,...e},n)=>s.jsx(Hk,{ref:n,className:Ut("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));ul.displayName=Hk.displayName;const Qt=b.forwardRef(({className:t,...e},n)=>s.jsx(Uk,{ref:n,className:Ut("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}));Qt.displayName=Uk.displayName;const Yt=b.forwardRef(({className:t,...e},n)=>s.jsx(Wk,{ref:n,className:Ut("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));Yt.displayName=Wk.displayName;function M0(t){const e=b.useRef({value:t,previous:t});return b.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function A0(t){const[e,n]=b.useState(void 0);return Ns(()=>{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 ap="Switch",[LP]=No(ap),[DP,_P]=LP(ap),Kk=b.forwardRef((t,e)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:i,required:o,disabled:c,value:u="on",onCheckedChange:h,form:f,...m}=t,[g,y]=b.useState(null),N=Ht(e,T=>y(T)),w=b.useRef(!1),j=g?f||!!g.closest("form"):!0,[S,E]=cl({prop:a,defaultProp:i??!1,onChange:h,caller:ap});return s.jsxs(DP,{scope:n,checked:S,disabled:c,children:[s.jsx(bt.button,{type:"button",role:"switch","aria-checked":S,"aria-required":o,"data-state":Qk(S),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:N,onClick:mt(t.onClick,T=>{E(P=>!P),j&&(w.current=T.isPropagationStopped(),w.current||T.stopPropagation())})}),j&&s.jsx(Jk,{control:g,bubbles:!w.current,name:r,value:u,checked:S,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});Kk.displayName=ap;var qk="SwitchThumb",Gk=b.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,a=_P(qk,n);return s.jsx(bt.span,{"data-state":Qk(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:e})});Gk.displayName=qk;var zP="SwitchBubbleInput",Jk=b.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...a},i)=>{const o=b.useRef(null),c=Ht(o,i),u=M0(n),h=A0(e);return b.useEffect(()=>{const f=o.current;if(!f)return;const m=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(m,"checked").set;if(u!==n&&y){const N=new Event("click",{bubbles:r});y.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}})});Jk.displayName=zP;function Qk(t){return t?"checked":"unchecked"}var Yk=Kk,$P=Gk;const $t=b.forwardRef(({className:t,...e},n)=>s.jsx(Yk,{className:Ut("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($P,{className:Ut("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")})}));$t.displayName=Yk.displayName;const FP={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 BP(t){return FP[t]||t||"行为"}function VP(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 I0({open:t,onClose:e,userId:n,onUserUpdated:r}){var Ea,Qs,Ss,Ys,ur,Cs;const[a,i]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState({}),[f,m]=b.useState([]),[g,y]=b.useState(null),[N,w]=b.useState(null),[j,S]=b.useState(!1),[E,T]=b.useState(!1),[P,O]=b.useState(!1),[q,z]=b.useState("info"),[V,I]=b.useState(""),[te,Q]=b.useState(""),[F,re]=b.useState(""),[ae,J]=b.useState([]),[$,D]=b.useState(""),[R,oe]=b.useState(""),[G,_]=b.useState(""),[U,H]=b.useState(!1),[K,me]=b.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[Y,le]=b.useState([]),[ce,ve]=b.useState(!1),[ye,ke]=b.useState(""),[ze,ht]=b.useState(""),[wt,dt]=b.useState(!1),[Rt,Tt]=b.useState(!1),[Tn,mn]=b.useState(null),[Ft,qt]=b.useState(null),[vn,On]=b.useState(""),[$n,St]=b.useState(""),[cn,gn]=b.useState(""),[xe,Se]=b.useState(!1),[$e,Xe]=b.useState(null),[jt,xt]=b.useState(!1),[L,Me]=b.useState({}),[ft,Et]=b.useState([]);b.useEffect(()=>{t&&n&&(xt(!1),z("info"),mn(null),qt(null),Xe(null),oe(""),_(""),tt(),Pe("/api/db/vip-roles").then(ie=>{ie!=null&&ie.success&&ie.data&&le(ie.data)}).catch(()=>{}))},[t,n]),b.useEffect(()=>{t&&Pe("/api/admin/mbti-avatars").then(ie=>{ie!=null&&ie.avatars&&typeof ie.avatars=="object"?Me(ie.avatars):Me({})}).catch(()=>Me({}))},[t]);const ut=(ie,ge)=>{const Qe=(ie||"").trim();if(Qe)return fo(Qe);const pt=(ge||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(pt)?(L[pt]||"").trim():""};async function tt(){if(n){S(!0);try{const ie=await Pe(`/api/db/users?id=${encodeURIComponent(n)}`);if(ie!=null&&ie.success&&ie.user){const ge=ie.user;i(ge),I(ge.phone||""),Q(ge.wechatId||""),re(ge.nickname||""),On(ge.phone||""),St(ge.wechatId||""),gn(ge.openId||"");try{J(typeof ge.tags=="string"?JSON.parse(ge.tags||"[]"):[])}catch{J([])}me({isVip:!!(ge.isVip??!1),vipExpireDate:ge.vipExpireDate?String(ge.vipExpireDate).slice(0,10):"",vipRole:String(ge.vipRole??""),vipName:String(ge.vipName??""),vipProject:String(ge.vipProject??""),vipContact:String(ge.vipContact??""),vipBio:String(ge.vipBio??"")})}try{const ge=await Pe(`/api/admin/user/track?userId=${encodeURIComponent(n)}&limit=100`);if(ge!=null&&ge.success){h(ge.stats&&typeof ge.stats=="object"?ge.stats:{});const Qe=ge.tracks||[];c(Qe.map(pt=>({...pt,actionLabel:pt.actionLabel||pt.action,timeAgo:pt.timeAgo||""})))}else h({}),c([])}catch{h({}),c([])}try{const ge=await Pe(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);ge!=null&&ge.success?(m(ge.referrals||[]),y(ge.inboundSource||null)):(m([]),y(null))}catch{m([]),y(null)}try{const ge=await Pe(`/api/admin/users/${encodeURIComponent(n)}/balance`);ge!=null&&ge.success&&ge.data?w(ge.data):w(null)}catch{w(null)}try{const ge=await Pe(`/api/orders?userId=${encodeURIComponent(n)}&status=paid&pageSize=50`);ge!=null&&ge.success&&ge.orders?Et(ge.orders):Et([])}catch{Et([])}}catch(ie){console.error("Load user detail error:",ie)}finally{S(!1)}}}async function Pt(){if(!(a!=null&&a.phone)){se.info("用户未绑定手机号,无法同步");return}T(!0);try{const ie=await Ct("/api/ckb/sync",{action:"full_sync",phone:a.phone,userId:a.id});ie!=null&&ie.success?(se.success("同步成功"),tt()):se.error("同步失败: "+(ie==null?void 0:ie.error))}catch(ie){console.error("Sync CKB error:",ie),se.error("同步失败")}finally{T(!1)}}async function Wt(){if(a){if(K.isVip&&!K.vipExpireDate.trim()){se.error("开启 VIP 请填写有效到期日");return}O(!0);try{const ie={id:a.id,phone:V.trim()||void 0,wechatId:te.trim(),nickname:F||void 0,tags:JSON.stringify(ae),isVip:K.isVip,vipExpireDate:K.isVip?K.vipExpireDate:void 0,vipRole:K.vipRole||void 0,vipName:K.vipName||void 0,vipProject:K.vipProject||void 0,vipContact:K.vipContact||void 0,vipBio:K.vipBio||void 0},ge=await Gt("/api/db/users",ie);ge!=null&&ge.success?(se.success("保存成功"),tt(),r==null||r()):se.error("保存失败: "+(ge==null?void 0:ge.error))}catch(ie){console.error("Save user error:",ie),se.error("保存失败")}finally{O(!1)}}}const en=()=>{$&&!ae.includes($)&&(J([...ae,$]),D(""))},ts=ie=>J(ae.filter(ge=>ge!==ie));async function Js(){if(a){if(!R){se.error("请输入新密码");return}if(R!==G){se.error("两次密码不一致");return}if(R.length<6){se.error("密码至少 6 位");return}H(!0);try{const ie=await Gt("/api/db/users",{id:a.id,password:R});ie!=null&&ie.success?(se.success("修改成功"),oe(""),_("")):se.error("修改失败: "+((ie==null?void 0:ie.error)||""))}catch{se.error("修改失败")}finally{H(!1)}}}async function bi(){if(!a)return;const ie=parseFloat(ye);if(Number.isNaN(ie)||ie===0){se.error("请输入有效金额(正数增加、负数扣减)");return}dt(!0);try{const ge=await Ct(`/api/admin/users/${a.id}/balance/adjust`,{amount:ie,remark:ze||void 0});ge!=null&&ge.success?(se.success("余额已调整"),ve(!1),ke(""),ht(""),tt(),r==null||r()):se.error("调整失败: "+((ge==null?void 0:ge.error)||""))}catch{se.error("调整失败")}finally{dt(!1)}}async function ea(){if(!vn&&!cn&&!$n){qt("请至少输入手机号、微信号或 OpenID 中的一项");return}Tt(!0),qt(null),mn(null);try{const ie=new URLSearchParams;vn&&ie.set("phone",vn),cn&&ie.set("openId",cn),$n&&ie.set("wechatId",$n);const ge=await Pe(`/api/admin/shensheshou/query?${ie}`);ge!=null&&ge.success&&ge.data?(mn(ge.data),a&&await ta(ge.data)):qt((ge==null?void 0:ge.error)||"未查询到数据,该用户可能未在神射手收录")}catch(ie){console.error("SSS query error:",ie),qt("请求失败,请检查神射手接口配置")}finally{Tt(!1)}}async function ta(ie){if(a)try{await Ct("/api/admin/shensheshou/enrich",{userId:a.id,phone:vn||a.phone||"",openId:cn||a.openId||"",wechatId:$n||a.wechatId||""}),tt()}catch(ge){console.error("SSS enrich error:",ge)}}async function Er(){if(a){Se(!0),Xe(null);try{const ie=Array.from(new Set(o.filter(Ps=>Ps.action==="view_chapter"||Ps.action==="purchase"||Ps.action==="first_pay").map(Ps=>(Ps.chapterTitle||Ps.target||"").trim()).filter(Boolean))).slice(0,12),ge={viewChapter:u.view_chapter||0,purchase:u.purchase||0,firstPay:u.first_pay||0},Qe=ie.length>0?`意向章节:${ie.join("、")}`:"",pt={users:[{phone:a.phone||"",name:a.nickname||"",openId:a.openId||"",tags:ae,purchaseIntent:ge,purchaseIntentChapters:ie,remark:Qe}]},Fn=await Ct("/api/admin/shensheshou/ingest",pt);Fn!=null&&Fn.success&&Fn.data?Xe(Fn.data):Xe({error:(Fn==null?void 0:Fn.error)||"推送失败"})}catch(ie){console.error("SSS ingest error:",ie),Xe({error:"请求失败"})}finally{Se(!1)}}}const Mr=ie=>{const Qe={view_chapter:qs,purchase:Md,match:In,login:oi,register:oi,share:ya,bind_phone:d1,bind_wechat:NM,fill_profile:Ad,fill_avatar:oi,visit_page:qr,first_pay:Md,vip_activate:pc,click_super:In,lead_submit:d1,withdraw:cx,referral_bind:ya,card_click:oi,btn_click:pi,tab_click:qr,nav_click:qr,page_view:qr,search:qr}[ie]||ix;return s.jsx(Qe,{className:"w-4 h-4"})};function Ar(ie){const ge=String(ie||"").trim();return ge.length>22&&/^[a-zA-Z0-9_-]+$/.test(ge)}const cr=b.useMemo(()=>VP(u,a),[u,a]);function dr(){const ie=[...ae];for(const ge of cr)ie.includes(ge)||ie.push(ge);J(ie),se.success("已将旅程推断标签合并到已选")}return t?s.jsxs(s.Fragment,{children:[s.jsx(Dt,{open:t,onOpenChange:()=>e(),children:s.jsxs(Lt,{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(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(oi,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(a==null?void 0:a.phone)&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(a==null?void 0:a.isVip)&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),j?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Fe,{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:ut(a.avatar,a.mbti)&&!jt?s.jsx("img",{src:ut(a.avatar,a.mbti),className:"w-full h-full rounded-full object-cover",alt:"",onError:()=>xt(!0)}):((Ea=a.nickname)==null?void 0:Ea.charAt(0))||"?"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("h3",{className:"text-base font-bold text-white leading-tight",children:a.nickname}),a.isAdmin&&s.jsx(Ve,{className:"bg-purple-500/20 text-purple-400 border-0 text-[10px] py-0",children:"管理员"}),a.hasFullBook&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"全书已购"}),a.vipRole&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0",children:a.vipRole})]}),a.referralCode&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-0.5",children:["推荐码 ",s.jsx("code",{className:"text-[#38bdac]",children:a.referralCode})]}),s.jsxs("div",{className:"mt-1 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-1.5 text-[11px]",children:[s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"昵称"}),s.jsx("p",{className:"text-white truncate",children:F||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:V||"—"})]}),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:te||"—"})]}),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(X,{type:"button",size:"sm",variant:"ghost",className:"h-5 px-1 text-[9px] text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>{ke(""),ht(""),ve(!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(jc,{value:q,onValueChange:z,className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[s.jsxs(ul,{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(Qt,{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(Qt,{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(qr,{className:"w-3 h-3 mr-0.5"}),"旅程与轨迹"]}),s.jsx(Qt,{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(Qt,{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(Yt,{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(ee,{className:"text-gray-400 text-[11px]",children:"昵称"}),s.jsx(de,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"昵称",value:F,onChange:ie=>re(ie.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-400 text-[11px]",children:"手机号(可改,点底部保存生效)"}),s.jsx(de,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"11 位手机号",value:V,onChange:ie=>I(ie.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-400 text-[11px]",children:"微信标识(微信号/wxid,非 OpenID)"}),s.jsx(de,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"如 wxid_xxx 或自定义微信号",value:te,onChange:ie=>Q(ie.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(Aj,{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(pc,{className:"w-3.5 h-3.5 text-amber-400 shrink-0"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"超级个体"}),a.isVip&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0 shrink-0",children:a.vipRole||"VIP"})]}),s.jsx($t,{className:"scale-90",checked:K.isVip,onCheckedChange:ie=>me(ge=>({...ge,isVip:ie}))})]}),K.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(ee,{className:"text-gray-500 text-[10px]",children:"到期日"}),s.jsx(de,{type:"date",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",value:K.vipExpireDate,onChange:ie=>me(ge=>({...ge,vipExpireDate:ie.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ee,{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:K.vipRole,onChange:ie=>me(ge=>({...ge,vipRole:ie.target.value})),children:[s.jsx("option",{value:"",children:"请选择"}),Y.map(ie=>s.jsx("option",{value:ie.name,children:ie.name},ie.id))]})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ee,{className:"text-gray-500 text-[10px]",children:"展示名"}),s.jsx(de,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"展示名",value:K.vipName,onChange:ie=>me(ge=>({...ge,vipName:ie.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ee,{className:"text-gray-500 text-[10px]",children:"项目"}),s.jsx(de,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"项目",value:K.vipProject,onChange:ie=>me(ge=>({...ge,vipProject:ie.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ee,{className:"text-gray-500 text-[10px]",children:"联系方式"}),s.jsx(de,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"微信/手机",value:K.vipContact,onChange:ie=>me(ge=>({...ge,vipContact:ie.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5 sm:col-span-2",children:[s.jsx(ee,{className:"text-gray-500 text-[10px]",children:"简介"}),s.jsx(de,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"简短介绍",value:K.vipBio,onChange:ie=>me(ge=>({...ge,vipBio:ie.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(pi,{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(de,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:手机",value:vn,onChange:ie=>On(ie.target.value)}),s.jsx(de,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:微信号",value:$n,onChange:ie=>St(ie.target.value)}),s.jsx(de,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:OpenID",value:cn,onChange:ie=>gn(ie.target.value)})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsxs(X,{size:"sm",className:"h-7 text-[11px] px-2 bg-[#38bdac] hover:bg-[#2da396]",onClick:ea,disabled:Rt,children:[Rt?s.jsx(Fe,{className:"w-3 h-3 animate-spin"}):s.jsx(va,{className:"w-3 h-3 mr-0.5"}),"查询回填"]}),s.jsx(X,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2 border-purple-500/40 text-purple-300",onClick:Er,disabled:xe||!a.phone,children:xe?"推送…":"推神射手"}),s.jsx(X,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2",onClick:Pt,disabled:E||!a.phone,children:E?"同步…":"存客宝同步"})]}),a.ckbSyncedAt&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-1",children:["最近存客宝同步:",new Date(a.ckbSyncedAt).toLocaleString()]}),Ft&&s.jsx("p",{className:"mt-1 text-red-400 text-[11px]",children:Ft}),Tn&&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:Tn.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:Tn.user_level??"—"})]})]}),$e&&s.jsx("p",{className:"mt-1 text-[11px]",children:$e.error?s.jsx("span",{className:"text-red-400",children:String($e.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(cx,{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(de,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"新密码 ≥6 位",value:R,onChange:ie=>oe(ie.target.value)}),s.jsx(de,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"确认密码",value:G,onChange:ie=>_(ie.target.value)}),s.jsx(X,{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:Js,disabled:U||!R||!G,children:U?"保存中":"确认修改"})]})]})]}),s.jsxs(Yt,{value:"journey",className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-0.5",children:[ft.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(Md,{className:"w-3.5 h-3.5 text-amber-400"}),s.jsxs("span",{className:"text-white text-xs font-medium",children:["购买清单(",ft.length," 笔)"]})]}),s.jsx("div",{className:"space-y-1 max-h-[120px] overflow-y-auto",children:ft.map((ie,ge)=>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:ie.productType==="fullbook"||ie.productType==="vip"?"全书/VIP":`章节 ${ie.productId||""}`}),s.jsxs("span",{className:"text-gray-500 ml-2",children:["¥",Number(ie.amount||0).toFixed(2)]})]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:ie.createdAt?new Date(ie.createdAt).toLocaleString("zh-CN"):""})]},ie.orderSn||ge))})]}),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(qr,{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((ie,ge)=>ge[1]-ie[1]).map(([ie,ge])=>s.jsxs(Ve,{variant:"outline",className:"text-[10px] border-gray-600 text-gray-300 bg-[#162840] py-0 h-5",children:[BP(ie)," ×",ge]},ie))})]}),s.jsx("div",{className:"space-y-1.5",children:o.length>0?o.map((ie,ge)=>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:Mr(ie.action)}),ge0?((g==null?void 0:g.visits)||[]).map((ie,ge)=>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:["第 ",ie.seq||ge+1," 次 · ",ie.referrerNickname||"微信用户",ie.referrerId?`(${ie.referrerId})`:""]}),ie.page?s.jsx("p",{className:"text-gray-500 text-[10px] truncate",children:ie.page}):null]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:ie.visitedAt?new Date(ie.visitedAt).toLocaleString():""})]},`${ie.referrerId||"unknown"}_${ge}`)):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(ya,{className:"w-3.5 h-3.5 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"推荐的用户"})]}),s.jsxs(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 text-[10px]",children:["共 ",f.length," 人"]})]}),s.jsx("div",{className:"space-y-1 max-h-[min(280px,40vh)] overflow-y-auto",children:f.length>0?f.map((ie,ge)=>{var pt;const Qe=ie;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:((pt=Qe.nickname)==null?void 0:pt.charAt(0))||"?"}),s.jsx("span",{className:"text-white truncate",children:Qe.nickname})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[Qe.status==="vip"&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"已购"}),s.jsx("span",{className:"text-gray-500 text-[10px]",children:Qe.createdAt?new Date(Qe.createdAt).toLocaleDateString():""})]})]},Qe.id||ge)}):s.jsx("p",{className:"text-gray-500 text-sm text-center py-3",children:"暂无推荐用户"})})]})]}),s.jsxs(Yt,{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(Ad,{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(jj,{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(X,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-cyan-500/40 text-cyan-200 hover:bg-cyan-500/10",disabled:cr.length===0,onClick:dr,children:"合并到已选"})]}),cr.length>0?s.jsx("div",{className:"flex flex-wrap gap-1",children:cr.map(ie=>s.jsxs(Ve,{variant:"outline",className:`text-[10px] py-0 h-5 border-cyan-500/30 ${ae.includes(ie)?"bg-cyan-500/15 text-cyan-200":"text-gray-300"}`,children:[ae.includes(ie)?"✓ ":"",ie]},ie))}):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(ie=>s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-[11px] mb-1",children:ie.category}),s.jsx("div",{className:"flex flex-wrap gap-1",children:ie.tags.map(ge=>s.jsxs("button",{type:"button",onClick:()=>{ae.includes(ge)?ts(ge):J([...ae,ge])},className:`px-1.5 py-0.5 rounded text-[11px] border transition-all ${ae.includes(ge)?"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:[ae.includes(ge)?"✓ ":"",ge]},ge))})]},ie.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:[ae.map((ie,ge)=>s.jsxs(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1 text-[11px] py-0",children:[ie,s.jsx("button",{type:"button",onClick:()=>ts(ie),className:"ml-1 hover:text-red-400",children:s.jsx(Yn,{className:"w-3 h-3"})})]},ge)),ae.length===0&&s.jsx("span",{className:"text-gray-600 text-xs",children:"暂未选择"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(de,{className:"bg-[#162840] border-gray-700 text-white flex-1 h-8 text-xs",placeholder:"自定义标签,回车添加",value:$,onChange:ie=>D(ie.target.value),onKeyDown:ie=>ie.key==="Enter"&&en()}),s.jsx(X,{onClick:en,className:"bg-[#38bdac] hover:bg-[#2da396] h-8 text-xs px-3",children:"添加"})]})]})]}),(()=>{const ie=a.tags||a.ckbTags||"";let ge=[];try{const pt=typeof ie=="string"?JSON.parse(ie||"[]"):[];ge=Array.isArray(pt)?pt:typeof ie=="string"?ie.split(","):[]}catch{ge=typeof ie=="string"?ie.split(","):[]}const Qe=ge.map(pt=>String(pt).trim()).filter(Boolean);return Qe.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(Ad,{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:Qe.map((pt,Fn)=>s.jsx(Ve,{className:"bg-purple-500/20 text-purple-400 border-0 text-[11px] py-0",children:pt},Fn))})]})})()]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3 shrink-0",children:[s.jsxs(X,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"关闭"]}),s.jsxs(X,{onClick:Wt,disabled:P,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),P?"保存中...":"保存修改"]})]})]}):s.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}),s.jsx(Dt,{open:ce,onOpenChange:ve,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsx(_t,{children:s.jsx(zt,{children:"调整余额"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"调整金额(元)"}),s.jsx(de,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"正数增加,负数扣减,如 10 或 -5",value:ye,onChange:ie=>ke(ie.target.value)})]}),s.jsxs("div",{children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"备注(可选)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"如:活动补偿",value:ze,onChange:ie=>ht(ie.target.value)})]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(X,{variant:"outline",onClick:()=>ve(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(X,{onClick:bi,disabled:wt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:wt?"提交中...":"确认调整"})]})]})})]}):null}function HP(){const t=Sa(),[e,n]=b.useState(!0),[r,a]=b.useState(!0),[i,o]=b.useState(!0),[c,u]=b.useState([]),[h,f]=b.useState([]),[m,g]=b.useState(0),[y,N]=b.useState(0),[w,j]=b.useState(0),[S,E]=b.useState(0),[T,P]=b.useState(null),[O,q]=b.useState(null),[z,V]=b.useState(!1),[I,te]=b.useState(0),[Q,F]=b.useState(!1),[re,ae]=b.useState(null),[J,$]=b.useState("overview"),[D,R]=b.useState([]),[oe,G]=b.useState(!1),[_,U]=b.useState("today"),[H,K]=b.useState(null),[me,Y]=b.useState(!1),[le,ce]=b.useState(!0),[ve,ye]=b.useState(null),[ke,ze]=b.useState(null),[ht,wt]=b.useState([]),dt=xe=>{const Se=xe;if((Se==null?void 0:Se.status)===401)P("登录已过期,请重新登录");else{if((Se==null?void 0:Se.name)==="AbortError")return;P("加载失败,请检查网络或联系管理员")}};async function Rt(xe){var jt,xt;const Se=xe?{signal:xe}:void 0;n(!0),P(null);try{const L=await Pe("/api/admin/dashboard/stats",Se);L!=null&&L.success&&(g(L.totalUsers??0),N(L.paidOrderCount??0),j(L.totalRevenue??0),E(L.conversionRate??0))}catch(L){if((L==null?void 0:L.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",L);try{const Me=await Pe("/api/admin/dashboard/overview",Se);Me!=null&&Me.success&&(g(Me.totalUsers??0),N(Me.paidOrderCount??0),j(Me.totalRevenue??0),E(Me.conversionRate??0))}catch(Me){dt(Me)}}}finally{n(!1)}try{const L=await Pe("/api/admin/balance/summary",Se);L!=null&&L.success&&L.data&&te(L.data.totalGifted??0)}catch{}try{const L=await Pe("/api/db/ckb-plan-stats",Se);L!=null&&L.success&&L.data?ae({ckbTotal:L.data.ckbTotal??0,withContact:L.data.withContact??0}):ae(null)}catch{ae(null)}ce(!0);try{const[L,Me]=await Promise.allSettled([Pe("/api/db/match-records?stats=true",Se),Pe("/api/admin/distribution/overview",Se)]);L.status==="fulfilled"&&((jt=L.value)!=null&&jt.success)&&L.value.data?ye({totalMatches:L.value.data.totalMatches??0,todayMatches:L.value.data.todayMatches??0,uniqueUsers:L.value.data.uniqueUsers??0,paidMatchCount:L.value.data.paidMatchCount??0}):ye(null),Me.status==="fulfilled"&&((xt=Me.value)!=null&&xt.success)&&Me.value.overview?ze({todayClicks:Me.value.overview.todayClicks??0,todayBindings:Me.value.overview.todayBindings??0,todayConversions:Me.value.overview.todayConversions??0,monthClicks:Me.value.overview.monthClicks??0,monthBindings:Me.value.overview.monthBindings??0,monthConversions:Me.value.overview.monthConversions??0,totalClicks:Me.value.overview.totalClicks??0,totalBindings:Me.value.overview.totalBindings??0,totalConversions:Me.value.overview.totalConversions??0,conversionRate:Me.value.overview.conversionRate}):ze(null)}catch{ye(null),ze(null)}finally{ce(!1)}try{const L=await Pe("/api/db/vip-members?limit=500",Se);L!=null&&L.success&&Array.isArray(L.data)?wt(L.data):wt([])}catch{wt([])}a(!0),o(!0);const $e=async()=>{try{const L=await Pe("/api/admin/dashboard/recent-orders?limit=10",Se);if(L!=null&&L.success&&L.recentOrders)f(L.recentOrders);else throw new Error("no data")}catch(L){if((L==null?void 0:L.name)!=="AbortError")try{const Me=await Pe("/api/admin/orders?page=1&pageSize=20&status=paid",Se),Et=((Me==null?void 0:Me.orders)??[]).filter(ut=>["paid","completed","success"].includes(ut.status||""));f(Et.slice(0,5))}catch{f([])}}finally{a(!1)}},Xe=async()=>{try{const L=await Pe("/api/admin/dashboard/new-users",Se);if(L!=null&&L.success&&L.newUsers)u(L.newUsers);else throw new Error("no data")}catch(L){if((L==null?void 0:L.name)!=="AbortError")try{const Me=await Pe("/api/db/users?page=1&pageSize=10",Se);u((Me==null?void 0:Me.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([$e(),Xe()])}async function Tt(xe){const Se=xe||_;Y(!0);try{const $e=await Pe(`/api/admin/track/stats?period=${Se}`);$e!=null&&$e.success&&K({total:$e.total??0,byModule:$e.byModule??{}})}catch{K(null)}finally{Y(!1)}}const Tn={home:"首页",chapters:"目录",read:"阅读页",my:"我的",vip:"超级个体",wallet:"钱包",match:"找伙伴",referral:"推广中心",search:"搜索",settings:"设置",about:"关于",member_detail:"成员详情",other:"其他"},mn={btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",page_view:"页面浏览",share:"分享",purchase:"购买",register:"注册",rule_trigger:"规则触发",view_chapter:"浏览章节",link_click:"链接点击"},Ft=xe=>xe?xe.replace(/^part-/,"").replace(/^soulvip_/,"").replace(/^super_?/,"").replace(/^user_/,"").replace(/[_-]+/g," ").trim():"",qt=xe=>{if(!xe)return"";const Se=xe.trim().toLowerCase();if(!Se)return"";const $e=ht.find(jt=>{const xt=String(jt.id||"").toLowerCase();return xt===Se||xt.includes(Se)||Se.includes(xt)});if($e)return $e.name||$e.nickname||"";const Xe=ht.find(jt=>{const xt=String(jt.token||"").toLowerCase();return xt&&(xt===Se||xt.includes(Se)||Se.includes(xt))});return Xe&&(Xe.name||Xe.nickname)||""},vn=xe=>{if(!xe)return"未命名点击";const Se=xe.trim(),$e=Se.toLowerCase();if(/^链接头像[_-]/.test(Se)){const jt=Ft(Se.replace(/^链接头像[_-]/,""));return jt?`头像:${jt}`:"头像点击"}if(/^member[_-]?detail$/i.test($e)||$e.includes("member detail"))return"成员详情";if(/^giftpay$/i.test($e)||$e.includes("gift pay"))return"代付入口";if(/^part[-_]/i.test($e))return`章节:${Ft(Se)}`;if($e.includes("soulvip")||$e.includes("super")){const jt=Se.replace(/^超级个体[::]?/i,"").replace(/^super[_-]?/i,"").replace(/^soulvip[_-]?/i,"").replace(/^user[_-]?/i,"").trim(),xt=qt(jt)||qt(Ft(jt));return xt?`超级个体:${xt}`:`超级个体:${Ft(jt)}`}if($e.includes("qgdtw")||$e.includes("token")||$e.includes("0000"))return`对象:${Ft(Se)}`;const Xe={开始匹配:"开始匹配",mentor:"导师顾问",team:"团队招募",investor:"资源对接",充值:"充值",退款:"退款",wallet:"钱包",设置:"设置",VIP:"VIP会员",推广:"推广中心",目录:"目录",搜索:"搜索",匹配:"找伙伴",settings:"设置",expired:"已过期",active:"活跃",converted:"已转化",fill_profile:"完善资料",register:"注册",purchase:"购买",链接卡若:"链接卡若",更多分享:"更多分享",分享朋友圈文案:"分享朋友圈",选择金额10:"选择金额10元",member_detail:"成员详情",giftPay:"代付入口"};return Xe[Se]?Xe[Se]:/^[a-z0-9_-]+$/i.test(Se)&&Ft(Se)||Se},On=xe=>{const Se=Tn[xe.module]||Tn[xe.page]||xe.module||xe.page||"其他",$e=mn[xe.action]||xe.action||"点击",Xe=vn(xe.target);return`${Se} · ${$e} · ${Xe}`};async function $n(){G(!0);try{const xe=await Pe("/api/admin/super-individual/stats");xe!=null&&xe.success&&Array.isArray(xe.data)&&R(xe.data)}catch{}finally{G(!1)}}b.useEffect(()=>{const xe=new AbortController;return Rt(xe.signal),Tt(),$n(),()=>{xe.abort()}},[]);const St=m,cn=xe=>{const Se=xe.productType||"",$e=xe.description||"";if(Se==="balance_recharge")return{title:`余额充值 ¥${typeof xe.amount=="number"?xe.amount.toFixed(2):parseFloat(String(xe.amount||"0")).toFixed(2)}`,subtitle:"余额充值"};if(Se==="gift_pay")return{title:`代付 ¥${typeof xe.amount=="number"?xe.amount.toFixed(2):parseFloat(String(xe.amount||"0")).toFixed(2)}`,subtitle:"好友代付"};if(Se==="gift_pay_batch"){const Xe=typeof xe.amount=="number"?xe.amount.toFixed(2):parseFloat(String(xe.amount||"0")).toFixed(2);return{title:$e||`代付分享 ¥${Xe}`,subtitle:"代付分享"}}if(Se==="section"&&$e.includes("代付领取"))return{title:$e.replace("代付领取 - ",""),subtitle:"代付领取"};if($e){if(Se==="section"&&$e.includes("章节")){if($e.includes("-")){const Xe=$e.split("-");if(Xe.length>=3)return{title:`第${Xe[1]}章 第${Xe[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:$e,subtitle:"章节购买"}}return Se==="fullbook"||$e.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:Se==="vip"||$e.includes("VIP")?{title:"超级个体开通费用",subtitle:"超级个体"}:Se==="match"||$e.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:$e,subtitle:Se==="section"?"单章":Se==="fullbook"?"全书":"其他"}}return Se==="section"?{title:`章节 ${xe.productId||""}`,subtitle:"单章购买"}:Se==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:Se==="vip"?{title:"超级个体开通费用",subtitle:"超级个体"}:Se==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:Se||"其他"}},gn=[{title:"总用户数",value:e?null:St,sub:null,icon:In,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:e?null:`¥${(w??0).toFixed(2)}`,sub:I>0?`含代付 ¥${I.toFixed(2)}`:null,icon:Gh,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:y,sub:null,icon:Md,color:"text-purple-400",bg:"bg-purple-500/20",link:"/orders"},{title:"转化率",value:e?null:`${typeof S=="number"?S.toFixed(1):0}%`,sub:null,icon:qs,color:"text-orange-400",bg:"bg-orange-500/20",link:"/distribution"},{title:"存客宝获客",value:re?re.ckbTotal??0:null,sub:(re==null?void 0:re.withContact)!=null?`含联系方式 ${re.withContact} 人`:null,icon:hc,color:"text-cyan-400",bg:"bg-cyan-500/20",link:"/users?tab=leads"},{title:"伙伴&推广协同",value:le?null:((ve==null?void 0:ve.totalMatches)??0)+((ke==null?void 0:ke.totalClicks)??0),sub:le?null:`找伙伴 ${(ve==null?void 0:ve.totalMatches)??0} / 推广 ${(ke==null?void 0:ke.totalClicks)??0}`,icon:rc,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:"数据概览"}),T&&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:T}),s.jsx("button",{type:"button",onClick:()=>Rt(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),s.jsx("div",{className:"flex flex-nowrap gap-6 mb-8 overflow-x-auto pb-1",children:gn.map((xe,Se)=>s.jsxs(Oe,{className:"min-w-[220px] flex-1 bg-[#0f2137] border-gray-700/50 shadow-xl cursor-pointer hover:border-[#38bdac]/50 transition-colors group",onClick:()=>xe.link&&t(xe.link),children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsx(at,{className:"text-sm font-medium text-gray-400",children:xe.title}),s.jsx("div",{className:`p-2 rounded-lg ${xe.bg}`,children:s.jsx(xe.icon,{className:`w-4 h-4 ${xe.color}`})})]}),s.jsx(Le,{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:xe.value!=null?xe.value:s.jsxs("span",{className:"inline-flex items-center gap-2 text-gray-500",children:[s.jsx(Fe,{className:"w-4 h-4 animate-spin"}),"加载中"]})}),xe.sub&&s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:xe.sub})]}),s.jsx(Xo,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},Se))}),s.jsxs("div",{className:"flex gap-2 mb-6 mt-2",children:[s.jsx("button",{type:"button",onClick:()=>$("overview"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${J==="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:()=>$("tags"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${J==="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:()=>$("super"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${J==="super"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"超级个体统计"})]}),J==="overview"&&s.jsxs("div",{className:"space-y-8",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between",children:[s.jsx(at,{className:"text-white",children:"找伙伴 × 推广中心(共统计)"}),s.jsxs("button",{type:"button",onClick:()=>Rt(),disabled:le,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新共统计",children:[s.jsx(Fe,{className:`w-3.5 h-3.5 ${le?"animate-spin":""}`}),"刷新"]})]}),s.jsxs(Le,{children:[le&&!ve&&!ke?s.jsxs("div",{className:"flex items-center justify-center py-10 text-gray-500",children:[s.jsx(Fe,{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:(ve==null?void 0:ve.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:(ve==null?void 0:ve.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:(ve==null?void 0:ve.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:(ke==null?void 0:ke.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:(ke==null?void 0:ke.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:(ke==null?void 0:ke.totalConversions)??0})]})]}),(ke==null?void 0:ke.conversionRate)&&s.jsxs("p",{className:"text-xs text-gray-500 mt-3",children:["推广转化率:",ke.conversionRate]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between",children:[s.jsx(at,{className:"text-white",children:"最近订单"}),s.jsxs("button",{type:"button",onClick:()=>Rt(),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(Fe,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(Fe,{className:"w-3.5 h-3.5"}),"刷新"]})]}),s.jsx(Le,{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(Fe,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[h.slice(0,Q?10:4).map(xe=>{var xt;const Se=xe.referrerId?c.find(L=>L.id===xe.referrerId):void 0,$e=xe.referralCode||(Se==null?void 0:Se.referralCode)||(Se==null?void 0:Se.nickname)||(xe.referrerId?String(xe.referrerId).slice(0,8):""),Xe=cn(xe),jt=xe.userNickname||((xt=c.find(L=>L.id===xe.userId))==null?void 0:xt.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:[xe.userAvatar?s.jsx("img",{src:xe.userAvatar,alt:jt,className:"w-9 h-9 rounded-full object-cover shrink-0 mt-0.5",onError:L=>{L.currentTarget.style.display="none";const Me=L.currentTarget.nextElementSibling;Me&&Me.classList.remove("hidden")}}):null,s.jsx("div",{className:`w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] shrink-0 mt-0.5 ${xe.userAvatar?"hidden":""}`,children:jt.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:()=>{xe.userId&&(q(xe.userId),V(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:jt}),s.jsx("span",{className:"text-gray-600",children:"·"}),s.jsx("span",{className:"text-sm font-medium text-white truncate",title:Xe.title,children:Xe.title})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[Xe.subtitle&&Xe.subtitle!=="章节购买"&&s.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:Xe.subtitle}),s.jsx("span",{children:new Date(xe.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),$e&&s.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",$e]})]})]}),s.jsxs("div",{className:"text-right ml-4 shrink-0",children:[s.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(xe.amount).toFixed(2)]}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:xe.paymentMethod||"微信"})]})]},xe.id)}),h.length>4&&!Q&&s.jsx("button",{type:"button",onClick:()=>F(!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(Md,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(rt,{children:s.jsx(at,{className:"text-white",children:"新注册用户"})}),s.jsx(Le,{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(Fe,{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(xe=>{var Se;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:((Se=xe.nickname)==null?void 0:Se.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("button",{type:"button",onClick:()=>{q(xe.id),V(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:xe.nickname||"匿名用户"}),s.jsx("p",{className:"text-xs text-gray-500",children:xe.phone||"未绑定手机"})]})]}),s.jsx("p",{className:"text-xs text-gray-400",children:xe.createdAt?new Date(xe.createdAt).toLocaleDateString():"-"})]},xe.id)}),c.length===0&&!i&&s.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})})]})]})]}),J==="tags"&&s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between",children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(rc,{className:"w-5 h-5 text-[#38bdac]"}),"分类标签点击统计"]}),s.jsx("div",{className:"flex items-center gap-2",children:["today","week","month","all"].map(xe=>s.jsx("button",{type:"button",onClick:()=>{U(xe),Tt(xe)},className:`px-3 py-1 text-xs rounded-full transition-colors ${_===xe?"bg-[#38bdac] text-white":"bg-gray-700/50 text-gray-400 hover:bg-gray-700"}`,children:{today:"今日",week:"本周",month:"本月",all:"全部"}[xe]},xe))})]}),s.jsx(Le,{children:me&&!H?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(Fe,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):H&&Object.keys(H.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:H.total})," 次"]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Object.entries(H.byModule).sort((xe,Se)=>Se[1].reduce(($e,Xe)=>$e+Xe.count,0)-xe[1].reduce(($e,Xe)=>$e+Xe.count,0)).slice(0,5).map(([xe,Se])=>{const $e=Se.reduce((Xe,jt)=>Xe+jt.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:Tn[xe]||xe}),s.jsxs("span",{className:"text-xs text-gray-500",children:[$e," 次"]})]}),s.jsx("div",{className:"space-y-2",children:Se.sort((Xe,jt)=>jt.count-Xe.count).slice(0,8).map((Xe,jt)=>{const xt=On(Xe);return s.jsxs("div",{className:"flex items-center justify-between text-xs",children:[s.jsx("span",{className:"text-gray-300 truncate mr-2",title:xt,children:xt}),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:`${$e>0?Xe.count/$e*100:0}%`}})}),s.jsx("span",{className:"text-gray-400 w-8 text-right",children:Xe.count})]})]},jt)})})]},xe)})})]}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(rc,{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:"小程序端接入埋点后,数据将在此实时展示"})]})})]}),J==="super"&&s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between",children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(rc,{className:"w-5 h-5 text-amber-400"}),"超级个体点击统计"]}),s.jsxs(X,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300 h-8",onClick:$n,disabled:oe,children:[s.jsx(Fe,{className:`w-3.5 h-3.5 mr-1 ${oe?"animate-spin":""}`}),"刷新"]})]}),s.jsx(Le,{children:oe&&D.length===0?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(Fe,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):D.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:D.map((xe,Se)=>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:Se+1}),s.jsx("td",{className:"py-2 px-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[xe.avatar?s.jsx("img",{src:xe.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(xe.nickname||xe.userId)}`),title:"点击跳转用户管理",children:xe.nickname||xe.userId})]})}),s.jsx("td",{className:"py-2 px-3 text-center text-white font-bold",children:xe.clicks}),s.jsx("td",{className:"py-2 px-3 text-center text-[#38bdac]",children:xe.uniqueClicks}),s.jsx("td",{className:"py-2 px-3 text-center text-gray-400",children:xe.uniqueClicks>0?(xe.clicks/xe.uniqueClicks).toFixed(1):"-"}),s.jsx("td",{className:"py-2 px-3 text-center text-green-400 text-xs font-medium",children:typeof xe.leadCount=="number"?xe.leadCount:0}),s.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs",children:xe.phone||"-"})]},xe.userId))})]})}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(rc,{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(I0,{open:z,onClose:()=>{V(!1),q(null)},userId:O,onUserUpdated:()=>Rt()})]})}const ds=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx("table",{ref:n,className:Ut("w-full caption-bottom text-sm",t),...e})}));ds.displayName="Table";const us=b.forwardRef(({className:t,...e},n)=>s.jsx("thead",{ref:n,className:Ut("[&_tr]:border-b",t),...e}));us.displayName="TableHeader";const hs=b.forwardRef(({className:t,...e},n)=>s.jsx("tbody",{ref:n,className:Ut("[&_tr:last-child]:border-0",t),...e}));hs.displayName="TableBody";const ct=b.forwardRef(({className:t,...e},n)=>s.jsx("tr",{ref:n,className:Ut("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));ct.displayName="TableRow";const je=b.forwardRef(({className:t,...e},n)=>s.jsx("th",{ref:n,className:Ut("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));je.displayName="TableHead";const be=b.forwardRef(({className:t,...e},n)=>s.jsx("td",{ref:n,className:Ut("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));be.displayName="TableCell";function ef(t,e){const[n,r]=b.useState(t);return b.useEffect(()=>{const a=setTimeout(()=>r(t),e);return()=>clearTimeout(a)},[t,e]),n}function Ks({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 UP(){const[t,e]=b.useState([]),[n,r]=b.useState([]),[a,i]=b.useState(0),[o,c]=b.useState(0),[u,h]=b.useState(0),[f,m]=b.useState(1),[g,y]=b.useState(10),[N,w]=b.useState(""),j=ef(N,300),[S,E]=b.useState("all"),[T,P]=b.useState(!0),[O,q]=b.useState(null),[z,V]=b.useState(null),[I,te]=b.useState(""),[Q,F]=b.useState(!1);async function re(){P(!0),q(null);try{const G=S==="all"?"":S==="completed"?"completed":S,_=new URLSearchParams({page:String(f),pageSize:String(g),...G&&{status:G},...j&&{search:j}}),[U,H]=await Promise.all([Pe(`/api/admin/orders?${_}`),Pe("/api/db/users?page=1&pageSize=500")]);U!=null&&U.success&&(e(U.orders||[]),i(U.total??0),c(U.totalRevenue??0),h(U.todayRevenue??0)),H!=null&&H.success&&H.users&&r(H.users)}catch(G){console.error("加载订单失败",G),q("加载订单失败,请检查网络后重试")}finally{P(!1)}}b.useEffect(()=>{m(1)},[j,S]),b.useEffect(()=>{re()},[f,g,j,S]);const ae=G=>{var _;return G.userNickname||((_=n.find(U=>U.id===G.userId))==null?void 0:_.nickname)||"匿名用户"},J=G=>{var _;return((_=n.find(U=>U.id===G))==null?void 0:_.phone)||"-"},$=G=>{const _=G.productType||G.type||"",U=G.description||"";if(_==="balance_recharge")return{name:`余额充值 ¥${Number(G.amount||0).toFixed(2)}`,type:"余额充值"};if(U){if(_==="section"&&(U.includes("章节")||U.includes("代付领取"))){if(U.includes("代付领取"))return{name:U.replace("代付领取 - ",""),type:"代付领取"};if(U.includes("-")){const H=U.split("-");if(H.length>=3)return{name:`第${H[1]}章 第${H[2]}节`,type:"《一场Soul的创业实验》"}}return{name:U,type:"章节购买"}}return _==="fullbook"||U.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:_==="vip"||U.includes("VIP")?{name:"超级个体开通费用",type:"超级个体"}:_==="match"||U.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:U,type:"其他"}}return _==="section"?{name:`章节 ${G.productId||G.sectionId||""}`,type:"单章"}:_==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:_==="vip"?{name:"超级个体开通费用",type:"超级个体"}:_==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:_||"其他"}},D=Math.ceil(a/g)||1;async function R(){var G;if(!(!(z!=null&&z.orderSn)&&!(z!=null&&z.id))){F(!0),q(null);try{const _=await Gt("/api/admin/orders/refund",{orderSn:z.orderSn||z.id,reason:I||void 0});_!=null&&_.success?(V(null),te(""),re()):q((_==null?void 0:_.error)||"退款失败")}catch(_){const U=_;q(((G=U==null?void 0:U.data)==null?void 0:G.error)||"退款失败,请检查网络后重试")}finally{F(!1)}}}function oe(){if(t.length===0){se.info("暂无数据可导出");return}const G=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],_=t.map(Y=>{const le=$(Y);return[Y.orderSn||Y.id||"",ae(Y),J(Y.userId),le.name,Number(Y.amount||0).toFixed(2),Y.paymentMethod==="wechat"?"微信支付":Y.paymentMethod==="balance"?"余额支付":Y.paymentMethod==="alipay"?"支付宝":Y.paymentMethod||"微信支付",Y.status==="refunded"?"已退款":Y.status==="paid"||Y.status==="completed"?"已完成":Y.status==="pending"||Y.status==="created"?"待支付":"已失败",Y.status==="refunded"&&Y.refundReason?Y.refundReason:"-",Y.referrerEarnings?Number(Y.referrerEarnings).toFixed(2):"-",Y.createdAt?new Date(Y.createdAt).toLocaleString("zh-CN"):""].join(",")}),U="\uFEFF"+[G.join(","),..._].join(` -`),H=new Blob([U],{type:"text/csv;charset=utf-8"}),K=URL.createObjectURL(H),me=document.createElement("a");me.href=K,me.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,me.click(),URL.revokeObjectURL(K)}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:()=>q(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(X,{variant:"outline",onClick:re,disabled:T,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${T?"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(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(de,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:N,onChange:G=>w(G.target.value)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ej,{className:"w-4 h-4 text-gray-400"}),s.jsxs("select",{value:S,onChange:G=>E(G.target.value),className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"pending",children:"待支付"}),s.jsx("option",{value:"created",children:"已创建"}),s.jsx("option",{value:"failed",children:"已失败"}),s.jsx("option",{value:"refunded",children:"已退款"})]})]}),s.jsxs(X,{variant:"outline",onClick:oe,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(T5,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:T?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Fe,{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(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"订单号"}),s.jsx(je,{className:"text-gray-400",children:"用户"}),s.jsx(je,{className:"text-gray-400",children:"商品"}),s.jsx(je,{className:"text-gray-400",children:"金额"}),s.jsx(je,{className:"text-gray-400",children:"支付方式"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-gray-400",children:"退款原因"}),s.jsx(je,{className:"text-gray-400",children:"分销佣金"}),s.jsx(je,{className:"text-gray-400",children:"下单时间"}),s.jsx(je,{className:"text-gray-400",children:"操作"})]})}),s.jsxs(hs,{children:[t.map(G=>{const _=$(G);return s.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsxs(be,{className:"font-mono text-xs text-gray-400",children:[(G.orderSn||G.id||"").slice(0,12),"..."]}),s.jsx(be,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[ae(G),G.paymentMethod==="gift_pay"&&s.jsx(Ve,{className:"bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 border-0 text-xs",children:"代付领取"}),G.payerUserId&&G.paymentMethod!=="gift_pay"&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"代付"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:J(G.userId)}),G.payerUserId&&G.payerNickname&&s.jsxs("p",{className:"text-amber-400/80 text-xs mt-0.5",children:[G.paymentMethod==="gift_pay"?"赠送人:":"代付人:",G.payerNickname]})]})}),s.jsx(be,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[_.name,(G.productType||G.type)==="vip"&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"超级个体"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:_.type})]})}),s.jsxs(be,{className:"text-[#38bdac] font-bold",children:["¥",Number(G.amount||0).toFixed(2)]}),s.jsx(be,{className:"text-gray-300",children:G.paymentMethod==="wechat"?"微信支付":G.paymentMethod==="balance"?"余额支付":G.paymentMethod==="alipay"?"支付宝":G.paymentMethod||"微信支付"}),s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[G.status==="refunded"?s.jsx(Ve,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):G.status==="paid"||G.status==="completed"?s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):G.status==="pending"||G.status==="created"?s.jsx(Ve,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):s.jsx(Ve,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"}),(G.status==="paid"||G.status==="completed")&&(G.webhookPushStatus==="sent"?s.jsx(Ve,{className:"bg-emerald-500/20 text-emerald-300 hover:bg-emerald-500/20 border-0",children:"已推送"}):s.jsx(Ve,{className:"bg-orange-500/20 text-orange-300 hover:bg-orange-500/20 border-0",children:"待补推"}))]})}),s.jsx(be,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:G.refundReason,children:G.status==="refunded"&&G.refundReason?G.refundReason:"-"}),s.jsx(be,{className:"text-[#FFD700]",children:G.referrerEarnings?`¥${Number(G.referrerEarnings).toFixed(2)}`:"-"}),s.jsx(be,{className:"text-gray-400 text-sm",children:new Date(G.createdAt).toLocaleString("zh-CN")}),s.jsx(be,{children:(G.status==="paid"||G.status==="completed")&&G.paymentMethod!=="balance"&&s.jsxs(X,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{V(G),te("")},children:[s.jsx(Ij,{className:"w-3 h-3 mr-1"}),"退款"]})})]},G.id)}),t.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),s.jsx(Ks,{page:f,totalPages:D,total:a,pageSize:g,onPageChange:m,onPageSizeChange:G=>{y(G),m(1)}})]})})}),s.jsx(Dt,{open:!!z,onOpenChange:G=>!G&&V(null),children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(_t,{children:s.jsx(zt,{className:"text-white",children:"订单退款"})}),z&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",z.orderSn||z.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(z.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(de,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:I,onChange:G=>te(G.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>V(null),disabled:Q,children:"取消"}),s.jsx(X,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:R,disabled:Q,children:Q?"退款中...":"确认退款"})]})]})})]})}const hl=b.forwardRef(({className:t,...e},n)=>s.jsx("textarea",{className:Ut("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}));hl.displayName="Textarea";const P1=["INTJ","INTP","ENTJ","ENTP","INFJ","INFP","ENFJ","ENFP","ISTJ","ISFJ","ESTJ","ESFJ","ISTP","ISFP","ESTP","ESFP"],Xk={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 WP(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 KP(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 qP(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 O1(t){const e=Xk[t],n=WP(e.group),r=KP(e.mood),a=qP(e.mood),i=` +For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return b.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},aP="DialogDescriptionWarning",iP=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${jk(aP).contentName}}.`;return b.useEffect(()=>{var i;const a=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");e&&a&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},oP=dk,lP=fk,cP=pk,dP=mk,uP=gk,hP=bk,fP=Nk;function Dt(t){return s.jsx(oP,{"data-slot":"dialog",...t})}function pP(t){return s.jsx(lP,{...t})}const kk=b.forwardRef(({className:t,...e},n)=>s.jsx(cP,{ref:n,className:Ut("fixed inset-0 z-50 bg-black/50",t),...e}));kk.displayName="DialogOverlay";const Lt=b.forwardRef(({className:t,children:e,showCloseButton:n=!0,...r},a)=>s.jsxs(pP,{children:[s.jsx(kk,{}),s.jsxs(dP,{ref:a,"aria-describedby":void 0,className:Ut("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(fP,{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(Yn,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Lt.displayName="DialogContent";function _t({className:t,...e}){return s.jsx("div",{className:Ut("flex flex-col gap-2 text-center sm:text-left",t),...e})}function fn({className:t,...e}){return s.jsx("div",{className:Ut("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function zt(t){return s.jsx(uP,{className:"text-lg font-semibold leading-none",...t})}function Zh(t){return s.jsx(hP,{className:"text-sm text-muted-foreground",...t})}const mP=_j("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 transition-colors",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ve({className:t,variant:e,asChild:n=!1,...r}){const a=n?Oj:"span";return s.jsx(a,{className:Ut(mP({variant:e}),t),...r})}var xP=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],gP=xP.reduce((t,e)=>{const n=Pj(`Primitive.${e}`),r=b.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),yP="Label",Sk=b.forwardRef((t,e)=>s.jsx(gP.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())}}));Sk.displayName=yP;var Ck=Sk;const ee=b.forwardRef(({className:t,...e},n)=>s.jsx(Ck,{ref:n,className:Ut("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));ee.displayName=Ck.displayName;function T0(t){const e=t+"CollectionProvider",[n,r]=No(e),[a,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:j,children:S}=w,E=As.useRef(null),T=As.useRef(new Map).current;return s.jsx(a,{scope:j,itemMap:T,collectionRef:E,children:S})};o.displayName=e;const c=t+"CollectionSlot",u=Ud(c),h=As.forwardRef((w,j)=>{const{scope:S,children:E}=w,T=i(c,S),P=Ht(j,T.collectionRef);return s.jsx(u,{ref:P,children:E})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",x=Ud(f),y=As.forwardRef((w,j)=>{const{scope:S,children:E,...T}=w,P=As.useRef(null),O=Ht(j,P),q=i(f,S);return As.useEffect(()=>(q.itemMap.set(P,{ref:P,...T}),()=>void q.itemMap.delete(P))),s.jsx(x,{[m]:"",ref:O,children:E})});y.displayName=f;function N(w){const j=i(t+"CollectionConsumer",w);return As.useCallback(()=>{const E=j.collectionRef.current;if(!E)return[];const T=Array.from(E.querySelectorAll(`[${m}]`));return Array.from(j.itemMap.values()).sort((q,z)=>T.indexOf(q.ref.current)-T.indexOf(z.ref.current))},[j.collectionRef,j.itemMap])}return[{Provider:o,Slot:h,ItemSlot:y},N,r]}var bP=b.createContext(void 0);function sp(t){const e=b.useContext(bP);return t||e||"ltr"}var gx="rovingFocusGroup.onEntryFocus",vP={bubbles:!1,cancelable:!0},lu="RovingFocusGroup",[mg,Tk,NP]=T0(lu),[wP,Ek]=No(lu,[NP]),[jP,kP]=wP(lu),Mk=b.forwardRef((t,e)=>s.jsx(mg.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(mg.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(SP,{...t,ref:e})})}));Mk.displayName=lu;var SP=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...m}=t,x=b.useRef(null),y=Ht(e,x),N=sp(i),[w,j]=cl({prop:o,defaultProp:c??null,onChange:u,caller:lu}),[S,E]=b.useState(!1),T=po(h),P=Tk(n),O=b.useRef(!1),[q,z]=b.useState(0);return b.useEffect(()=>{const V=x.current;if(V)return V.addEventListener(gx,T),()=>V.removeEventListener(gx,T)},[T]),s.jsx(jP,{scope:n,orientation:r,dir:N,loop:a,currentTabStopId:w,onItemFocus:b.useCallback(V=>j(V),[j]),onItemShiftTab:b.useCallback(()=>E(!0),[]),onFocusableItemAdd:b.useCallback(()=>z(V=>V+1),[]),onFocusableItemRemove:b.useCallback(()=>z(V=>V-1),[]),children:s.jsx(bt.div,{tabIndex:S||q===0?-1:0,"data-orientation":r,...m,ref:y,style:{outline:"none",...t.style},onMouseDown:mt(t.onMouseDown,()=>{O.current=!0}),onFocus:mt(t.onFocus,V=>{const I=!O.current;if(V.target===V.currentTarget&&I&&!S){const te=new CustomEvent(gx,vP);if(V.currentTarget.dispatchEvent(te),!te.defaultPrevented){const Q=P().filter($=>$.focusable),F=Q.find($=>$.active),re=Q.find($=>$.id===w),J=[F,re,...Q].filter(Boolean).map($=>$.ref.current);Rk(J,f)}}O.current=!1}),onBlur:mt(t.onBlur,()=>E(!1))})})}),Ak="RovingFocusGroupItem",Ik=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...c}=t,u=oo(),h=i||u,f=kP(Ak,n),m=f.currentTabStopId===h,x=Tk(n),{onFocusableItemAdd:y,onFocusableItemRemove:N,currentTabStopId:w}=f;return b.useEffect(()=>{if(r)return y(),()=>N()},[r,y,N]),s.jsx(mg.ItemSlot,{scope:n,id:h,focusable:r,active:a,children:s.jsx(bt.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:mt(t.onMouseDown,j=>{r?f.onItemFocus(h):j.preventDefault()}),onFocus:mt(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:mt(t.onKeyDown,j=>{if(j.key==="Tab"&&j.shiftKey){f.onItemShiftTab();return}if(j.target!==j.currentTarget)return;const S=EP(j,f.orientation,f.dir);if(S!==void 0){if(j.metaKey||j.ctrlKey||j.altKey||j.shiftKey)return;j.preventDefault();let T=x().filter(P=>P.focusable).map(P=>P.ref.current);if(S==="last")T.reverse();else if(S==="prev"||S==="next"){S==="prev"&&T.reverse();const P=T.indexOf(j.currentTarget);T=f.loop?MP(T,P+1):T.slice(P+1)}setTimeout(()=>Rk(T))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:w!=null}):o})})});Ik.displayName=Ak;var CP={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function TP(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function EP(t,e,n){const r=TP(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return CP[r]}function Rk(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function MP(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var AP=Mk,IP=Ik,rp="Tabs",[RP]=No(rp,[Ek]),Pk=Ek(),[PP,E0]=RP(rp),Ok=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=sp(c),[m,x]=cl({prop:r,onChange:a,defaultProp:i??"",caller:rp});return s.jsx(PP,{scope:n,baseId:oo(),value:m,onValueChange:x,orientation:o,dir:f,activationMode:u,children:s.jsx(bt.div,{dir:f,"data-orientation":o,...h,ref:e})})});Ok.displayName=rp;var Lk="TabsList",Dk=b.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...a}=t,i=E0(Lk,n),o=Pk(n);return s.jsx(AP,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(bt.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:e})})});Dk.displayName=Lk;var _k="TabsTrigger",zk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...i}=t,o=E0(_k,n),c=Pk(n),u=Bk(o.baseId,r),h=Vk(o.baseId,r),f=r===o.value;return s.jsx(IP,{asChild:!0,...c,focusable:!a,active:f,children:s.jsx(bt.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:mt(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(r):m.preventDefault()}),onKeyDown:mt(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(r)}),onFocus:mt(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!a&&m&&o.onValueChange(r)})})})});zk.displayName=_k;var $k="TabsContent",Fk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=t,c=E0($k,n),u=Bk(c.baseId,r),h=Vk(c.baseId,r),f=r===c.value,m=b.useRef(f);return b.useEffect(()=>{const x=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(x)},[]),s.jsx(ou,{present:a||f,children:({present:x})=>s.jsx(bt.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})})});Fk.displayName=$k;function Bk(t,e){return`${t}-trigger-${e}`}function Vk(t,e){return`${t}-content-${e}`}var OP=Ok,Hk=Dk,Uk=zk,Wk=Fk;const jc=OP,ul=b.forwardRef(({className:t,...e},n)=>s.jsx(Hk,{ref:n,className:Ut("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));ul.displayName=Hk.displayName;const Qt=b.forwardRef(({className:t,...e},n)=>s.jsx(Uk,{ref:n,className:Ut("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}));Qt.displayName=Uk.displayName;const Yt=b.forwardRef(({className:t,...e},n)=>s.jsx(Wk,{ref:n,className:Ut("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));Yt.displayName=Wk.displayName;function M0(t){const e=b.useRef({value:t,previous:t});return b.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function A0(t){const[e,n]=b.useState(void 0);return Ns(()=>{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 ap="Switch",[LP]=No(ap),[DP,_P]=LP(ap),Kk=b.forwardRef((t,e)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:i,required:o,disabled:c,value:u="on",onCheckedChange:h,form:f,...m}=t,[x,y]=b.useState(null),N=Ht(e,T=>y(T)),w=b.useRef(!1),j=x?f||!!x.closest("form"):!0,[S,E]=cl({prop:a,defaultProp:i??!1,onChange:h,caller:ap});return s.jsxs(DP,{scope:n,checked:S,disabled:c,children:[s.jsx(bt.button,{type:"button",role:"switch","aria-checked":S,"aria-required":o,"data-state":Qk(S),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:N,onClick:mt(t.onClick,T=>{E(P=>!P),j&&(w.current=T.isPropagationStopped(),w.current||T.stopPropagation())})}),j&&s.jsx(Jk,{control:x,bubbles:!w.current,name:r,value:u,checked:S,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});Kk.displayName=ap;var qk="SwitchThumb",Gk=b.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,a=_P(qk,n);return s.jsx(bt.span,{"data-state":Qk(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:e})});Gk.displayName=qk;var zP="SwitchBubbleInput",Jk=b.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...a},i)=>{const o=b.useRef(null),c=Ht(o,i),u=M0(n),h=A0(e);return b.useEffect(()=>{const f=o.current;if(!f)return;const m=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(m,"checked").set;if(u!==n&&y){const N=new Event("click",{bubbles:r});y.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}})});Jk.displayName=zP;function Qk(t){return t?"checked":"unchecked"}var Yk=Kk,$P=Gk;const $t=b.forwardRef(({className:t,...e},n)=>s.jsx(Yk,{className:Ut("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($P,{className:Ut("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")})}));$t.displayName=Yk.displayName;const FP={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 BP(t){return FP[t]||t||"行为"}function VP(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 I0({open:t,onClose:e,userId:n,onUserUpdated:r}){var Ea,Ys,Ss,Xs,ur,Cs;const[a,i]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState({}),[f,m]=b.useState([]),[x,y]=b.useState(null),[N,w]=b.useState(null),[j,S]=b.useState(!1),[E,T]=b.useState(!1),[P,O]=b.useState(!1),[q,z]=b.useState("info"),[V,I]=b.useState(""),[te,Q]=b.useState(""),[F,re]=b.useState(""),[ie,J]=b.useState([]),[$,D]=b.useState(""),[R,oe]=b.useState(""),[G,_]=b.useState(""),[U,H]=b.useState(!1),[K,me]=b.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[Y,le]=b.useState([]),[de,ve]=b.useState(!1),[ye,ke]=b.useState(""),[ze,ft]=b.useState(""),[wt,dt]=b.useState(!1),[Rt,Tt]=b.useState(!1),[Tn,mn]=b.useState(null),[Ft,qt]=b.useState(null),[vn,On]=b.useState(""),[$n,St]=b.useState(""),[cn,xn]=b.useState(""),[ge,Se]=b.useState(!1),[$e,Xe]=b.useState(null),[jt,gt]=b.useState(!1),[L,Me]=b.useState({}),[pt,Et]=b.useState([]);b.useEffect(()=>{t&&n&&(gt(!1),z("info"),mn(null),qt(null),Xe(null),oe(""),_(""),tt(),Pe("/api/db/vip-roles").then(ae=>{ae!=null&&ae.success&&ae.data&&le(ae.data)}).catch(()=>{}))},[t,n]),b.useEffect(()=>{t&&Pe("/api/admin/mbti-avatars").then(ae=>{ae!=null&&ae.avatars&&typeof ae.avatars=="object"?Me(ae.avatars):Me({})}).catch(()=>Me({}))},[t]);const ht=(ae,xe)=>{const Ue=(ae||"").trim();if(Ue)return fo(Ue);const ut=(xe||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(ut)?(L[ut]||"").trim():""};async function tt(){if(n){S(!0);try{const ae=await Pe(`/api/db/users?id=${encodeURIComponent(n)}`);if(ae!=null&&ae.success&&ae.user){const xe=ae.user;i(xe),I(xe.phone||""),Q(xe.wechatId||""),re(xe.nickname||""),On(xe.phone||""),St(xe.wechatId||""),xn(xe.openId||"");try{J(typeof xe.tags=="string"?JSON.parse(xe.tags||"[]"):[])}catch{J([])}me({isVip:!!(xe.isVip??!1),vipExpireDate:xe.vipExpireDate?String(xe.vipExpireDate).slice(0,10):"",vipRole:String(xe.vipRole??""),vipName:String(xe.vipName??""),vipProject:String(xe.vipProject??""),vipContact:String(xe.vipContact??""),vipBio:String(xe.vipBio??"")})}try{const xe=await Pe(`/api/admin/user/track?userId=${encodeURIComponent(n)}&limit=100`);if(xe!=null&&xe.success){h(xe.stats&&typeof xe.stats=="object"?xe.stats:{});const Ue=xe.tracks||[];c(Ue.map(ut=>({...ut,actionLabel:ut.actionLabel||ut.action,timeAgo:ut.timeAgo||""})))}else h({}),c([])}catch{h({}),c([])}try{const xe=await Pe(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);xe!=null&&xe.success?(m(xe.referrals||[]),y(xe.inboundSource||null)):(m([]),y(null))}catch{m([]),y(null)}try{const xe=await Pe(`/api/admin/users/${encodeURIComponent(n)}/balance`);xe!=null&&xe.success&&xe.data?w(xe.data):w(null)}catch{w(null)}try{const xe=await Pe(`/api/orders?userId=${encodeURIComponent(n)}&status=paid&pageSize=50`);xe!=null&&xe.success&&xe.orders?Et(xe.orders):Et([])}catch{Et([])}}catch(ae){console.error("Load user detail error:",ae)}finally{S(!1)}}}async function Pt(){if(!(a!=null&&a.phone)){se.info("用户未绑定手机号,无法同步");return}T(!0);try{const ae=await Ct("/api/ckb/sync",{action:"full_sync",phone:a.phone,userId:a.id});ae!=null&&ae.success?(se.success("同步成功"),tt()):se.error("同步失败: "+(ae==null?void 0:ae.error))}catch(ae){console.error("Sync CKB error:",ae),se.error("同步失败")}finally{T(!1)}}async function Wt(){if(a){if(K.isVip&&!K.vipExpireDate.trim()){se.error("开启 VIP 请填写有效到期日");return}O(!0);try{const ae={id:a.id,phone:V.trim()||void 0,wechatId:te.trim(),nickname:F||void 0,tags:JSON.stringify(ie),isVip:K.isVip,vipExpireDate:K.isVip?K.vipExpireDate:void 0,vipRole:K.vipRole||void 0,vipName:K.vipName||void 0,vipProject:K.vipProject||void 0,vipContact:K.vipContact||void 0,vipBio:K.vipBio||void 0},xe=await Gt("/api/db/users",ae);xe!=null&&xe.success?(se.success("保存成功"),tt(),r==null||r()):se.error("保存失败: "+(xe==null?void 0:xe.error))}catch(ae){console.error("Save user error:",ae),se.error("保存失败")}finally{O(!1)}}}const en=()=>{$&&!ie.includes($)&&(J([...ie,$]),D(""))},ts=ae=>J(ie.filter(xe=>xe!==ae));async function Qs(){if(a){if(!R){se.error("请输入新密码");return}if(R!==G){se.error("两次密码不一致");return}if(R.length<6){se.error("密码至少 6 位");return}H(!0);try{const ae=await Gt("/api/db/users",{id:a.id,password:R});ae!=null&&ae.success?(se.success("修改成功"),oe(""),_("")):se.error("修改失败: "+((ae==null?void 0:ae.error)||""))}catch{se.error("修改失败")}finally{H(!1)}}}async function bi(){if(!a)return;const ae=parseFloat(ye);if(Number.isNaN(ae)||ae===0){se.error("请输入有效金额(正数增加、负数扣减)");return}dt(!0);try{const xe=await Ct(`/api/admin/users/${a.id}/balance/adjust`,{amount:ae,remark:ze||void 0});xe!=null&&xe.success?(se.success("余额已调整"),ve(!1),ke(""),ft(""),tt(),r==null||r()):se.error("调整失败: "+((xe==null?void 0:xe.error)||""))}catch{se.error("调整失败")}finally{dt(!1)}}async function ea(){if(!vn&&!cn&&!$n){qt("请至少输入手机号、微信号或 OpenID 中的一项");return}Tt(!0),qt(null),mn(null);try{const ae=new URLSearchParams;vn&&ae.set("phone",vn),cn&&ae.set("openId",cn),$n&&ae.set("wechatId",$n);const xe=await Pe(`/api/admin/shensheshou/query?${ae}`);xe!=null&&xe.success&&xe.data?(mn(xe.data),a&&await ta(xe.data)):qt((xe==null?void 0:xe.error)||"未查询到数据,该用户可能未在神射手收录")}catch(ae){console.error("SSS query error:",ae),qt("请求失败,请检查神射手接口配置")}finally{Tt(!1)}}async function ta(ae){if(a)try{await Ct("/api/admin/shensheshou/enrich",{userId:a.id,phone:vn||a.phone||"",openId:cn||a.openId||"",wechatId:$n||a.wechatId||""}),tt()}catch(xe){console.error("SSS enrich error:",xe)}}async function Er(){if(a){Se(!0),Xe(null);try{const ae=Array.from(new Set(o.filter(Ps=>Ps.action==="view_chapter"||Ps.action==="purchase"||Ps.action==="first_pay").map(Ps=>(Ps.chapterTitle||Ps.target||"").trim()).filter(Boolean))).slice(0,12),xe={viewChapter:u.view_chapter||0,purchase:u.purchase||0,firstPay:u.first_pay||0},Ue=ae.length>0?`意向章节:${ae.join("、")}`:"",ut={users:[{phone:a.phone||"",name:a.nickname||"",openId:a.openId||"",tags:ie,purchaseIntent:xe,purchaseIntentChapters:ae,remark:Ue}]},Fn=await Ct("/api/admin/shensheshou/ingest",ut);Fn!=null&&Fn.success&&Fn.data?Xe(Fn.data):Xe({error:(Fn==null?void 0:Fn.error)||"推送失败"})}catch(ae){console.error("SSS ingest error:",ae),Xe({error:"请求失败"})}finally{Se(!1)}}}const Mr=ae=>{const Ue={view_chapter:Gs,purchase:Md,match:In,login:oi,register:oi,share:ya,bind_phone:d1,bind_wechat:NM,fill_profile:Ad,fill_avatar:oi,visit_page:qr,first_pay:Md,vip_activate:pc,click_super:In,lead_submit:d1,withdraw:cg,referral_bind:ya,card_click:oi,btn_click:pi,tab_click:qr,nav_click:qr,page_view:qr,search:qr}[ae]||ig;return s.jsx(Ue,{className:"w-4 h-4"})};function Ar(ae){const xe=String(ae||"").trim();return xe.length>22&&/^[a-zA-Z0-9_-]+$/.test(xe)}const cr=b.useMemo(()=>VP(u,a),[u,a]);function dr(){const ae=[...ie];for(const xe of cr)ae.includes(xe)||ae.push(xe);J(ae),se.success("已将旅程推断标签合并到已选")}return t?s.jsxs(s.Fragment,{children:[s.jsx(Dt,{open:t,onOpenChange:()=>e(),children:s.jsxs(Lt,{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(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(oi,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(a==null?void 0:a.phone)&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(a==null?void 0:a.isVip)&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),j?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Fe,{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:ht(a.avatar,a.mbti)&&!jt?s.jsx("img",{src:ht(a.avatar,a.mbti),className:"w-full h-full rounded-full object-cover",alt:"",onError:()=>gt(!0)}):((Ea=a.nickname)==null?void 0:Ea.charAt(0))||"?"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("h3",{className:"text-base font-bold text-white leading-tight",children:a.nickname}),a.isAdmin&&s.jsx(Ve,{className:"bg-purple-500/20 text-purple-400 border-0 text-[10px] py-0",children:"管理员"}),a.hasFullBook&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"全书已购"}),a.vipRole&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0",children:a.vipRole})]}),a.referralCode&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-0.5",children:["推荐码 ",s.jsx("code",{className:"text-[#38bdac]",children:a.referralCode})]}),s.jsxs("div",{className:"mt-1 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-1.5 text-[11px]",children:[s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"昵称"}),s.jsx("p",{className:"text-white truncate",children:F||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:V||"—"})]}),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:te||"—"})]}),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(X,{type:"button",size:"sm",variant:"ghost",className:"h-5 px-1 text-[9px] text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>{ke(""),ft(""),ve(!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(jc,{value:q,onValueChange:z,className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[s.jsxs(ul,{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(Qt,{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(Qt,{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(qr,{className:"w-3 h-3 mr-0.5"}),"旅程与轨迹"]}),s.jsx(Qt,{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(Qt,{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(Yt,{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(ee,{className:"text-gray-400 text-[11px]",children:"昵称"}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"昵称",value:F,onChange:ae=>re(ae.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-400 text-[11px]",children:"手机号(可改,点底部保存生效)"}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"11 位手机号",value:V,onChange:ae=>I(ae.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-400 text-[11px]",children:"微信标识(微信号/wxid,非 OpenID)"}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"如 wxid_xxx 或自定义微信号",value:te,onChange:ae=>Q(ae.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(Aj,{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(pc,{className:"w-3.5 h-3.5 text-amber-400 shrink-0"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"超级个体"}),a.isVip&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0 shrink-0",children:a.vipRole||"VIP"})]}),s.jsx($t,{className:"scale-90",checked:K.isVip,onCheckedChange:ae=>me(xe=>({...xe,isVip:ae}))})]}),K.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(ee,{className:"text-gray-500 text-[10px]",children:"到期日"}),s.jsx(ce,{type:"date",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",value:K.vipExpireDate,onChange:ae=>me(xe=>({...xe,vipExpireDate:ae.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ee,{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:K.vipRole,onChange:ae=>me(xe=>({...xe,vipRole:ae.target.value})),children:[s.jsx("option",{value:"",children:"请选择"}),Y.map(ae=>s.jsx("option",{value:ae.name,children:ae.name},ae.id))]})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ee,{className:"text-gray-500 text-[10px]",children:"展示名"}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"展示名",value:K.vipName,onChange:ae=>me(xe=>({...xe,vipName:ae.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ee,{className:"text-gray-500 text-[10px]",children:"项目"}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"项目",value:K.vipProject,onChange:ae=>me(xe=>({...xe,vipProject:ae.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ee,{className:"text-gray-500 text-[10px]",children:"联系方式"}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"微信/手机",value:K.vipContact,onChange:ae=>me(xe=>({...xe,vipContact:ae.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5 sm:col-span-2",children:[s.jsx(ee,{className:"text-gray-500 text-[10px]",children:"简介"}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"简短介绍",value:K.vipBio,onChange:ae=>me(xe=>({...xe,vipBio:ae.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(pi,{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(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:手机",value:vn,onChange:ae=>On(ae.target.value)}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:微信号",value:$n,onChange:ae=>St(ae.target.value)}),s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:OpenID",value:cn,onChange:ae=>xn(ae.target.value)})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsxs(X,{size:"sm",className:"h-7 text-[11px] px-2 bg-[#38bdac] hover:bg-[#2da396]",onClick:ea,disabled:Rt,children:[Rt?s.jsx(Fe,{className:"w-3 h-3 animate-spin"}):s.jsx(va,{className:"w-3 h-3 mr-0.5"}),"查询回填"]}),s.jsx(X,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2 border-purple-500/40 text-purple-300",onClick:Er,disabled:ge||!a.phone,children:ge?"推送…":"推神射手"}),s.jsx(X,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2",onClick:Pt,disabled:E||!a.phone,children:E?"同步…":"存客宝同步"})]}),a.ckbSyncedAt&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-1",children:["最近存客宝同步:",new Date(a.ckbSyncedAt).toLocaleString()]}),Ft&&s.jsx("p",{className:"mt-1 text-red-400 text-[11px]",children:Ft}),Tn&&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:Tn.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:Tn.user_level??"—"})]})]}),$e&&s.jsx("p",{className:"mt-1 text-[11px]",children:$e.error?s.jsx("span",{className:"text-red-400",children:String($e.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(cg,{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(ce,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"新密码 ≥6 位",value:R,onChange:ae=>oe(ae.target.value)}),s.jsx(ce,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"确认密码",value:G,onChange:ae=>_(ae.target.value)}),s.jsx(X,{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:Qs,disabled:U||!R||!G,children:U?"保存中":"确认修改"})]})]})]}),s.jsxs(Yt,{value:"journey",className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-0.5",children:[pt.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(Md,{className:"w-3.5 h-3.5 text-amber-400"}),s.jsxs("span",{className:"text-white text-xs font-medium",children:["购买清单(",pt.length," 笔)"]})]}),s.jsx("div",{className:"space-y-1 max-h-[120px] overflow-y-auto",children:pt.map((ae,xe)=>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:ae.productType==="fullbook"||ae.productType==="vip"?"全书/VIP":`章节 ${ae.productId||""}`}),s.jsxs("span",{className:"text-gray-500 ml-2",children:["¥",Number(ae.amount||0).toFixed(2)]})]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:ae.createdAt?new Date(ae.createdAt).toLocaleString("zh-CN"):""})]},ae.orderSn||xe))})]}),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(qr,{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((ae,xe)=>xe[1]-ae[1]).map(([ae,xe])=>s.jsxs(Ve,{variant:"outline",className:"text-[10px] border-gray-600 text-gray-300 bg-[#162840] py-0 h-5",children:[BP(ae)," ×",xe]},ae))})]}),s.jsx("div",{className:"space-y-1.5",children:o.length>0?o.map((ae,xe)=>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:Mr(ae.action)}),xe0?((x==null?void 0:x.visits)||[]).map((ae,xe)=>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:["第 ",ae.seq||xe+1," 次 · ",ae.referrerNickname||"微信用户",ae.referrerId?`(${ae.referrerId})`:""]}),ae.page?s.jsx("p",{className:"text-gray-500 text-[10px] truncate",children:ae.page}):null]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:ae.visitedAt?new Date(ae.visitedAt).toLocaleString():""})]},`${ae.referrerId||"unknown"}_${xe}`)):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(ya,{className:"w-3.5 h-3.5 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"推荐的用户"})]}),s.jsxs(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 text-[10px]",children:["共 ",f.length," 人"]})]}),s.jsx("div",{className:"space-y-1 max-h-[min(280px,40vh)] overflow-y-auto",children:f.length>0?f.map((ae,xe)=>{var ut;const Ue=ae;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:((ut=Ue.nickname)==null?void 0:ut.charAt(0))||"?"}),s.jsx("span",{className:"text-white truncate",children:Ue.nickname})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[Ue.status==="vip"&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"已购"}),s.jsx("span",{className:"text-gray-500 text-[10px]",children:Ue.createdAt?new Date(Ue.createdAt).toLocaleDateString():""})]})]},Ue.id||xe)}):s.jsx("p",{className:"text-gray-500 text-sm text-center py-3",children:"暂无推荐用户"})})]})]}),s.jsxs(Yt,{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(Ad,{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(jj,{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(X,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-cyan-500/40 text-cyan-200 hover:bg-cyan-500/10",disabled:cr.length===0,onClick:dr,children:"合并到已选"})]}),cr.length>0?s.jsx("div",{className:"flex flex-wrap gap-1",children:cr.map(ae=>s.jsxs(Ve,{variant:"outline",className:`text-[10px] py-0 h-5 border-cyan-500/30 ${ie.includes(ae)?"bg-cyan-500/15 text-cyan-200":"text-gray-300"}`,children:[ie.includes(ae)?"✓ ":"",ae]},ae))}):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(ae=>s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-[11px] mb-1",children:ae.category}),s.jsx("div",{className:"flex flex-wrap gap-1",children:ae.tags.map(xe=>s.jsxs("button",{type:"button",onClick:()=>{ie.includes(xe)?ts(xe):J([...ie,xe])},className:`px-1.5 py-0.5 rounded text-[11px] border transition-all ${ie.includes(xe)?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-transparent border-gray-700 text-gray-500 hover:border-gray-500 hover:text-gray-300"}`,children:[ie.includes(xe)?"✓ ":"",xe]},xe))})]},ae.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:[ie.map((ae,xe)=>s.jsxs(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1 text-[11px] py-0",children:[ae,s.jsx("button",{type:"button",onClick:()=>ts(ae),className:"ml-1 hover:text-red-400",children:s.jsx(Yn,{className:"w-3 h-3"})})]},xe)),ie.length===0&&s.jsx("span",{className:"text-gray-600 text-xs",children:"暂未选择"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white flex-1 h-8 text-xs",placeholder:"自定义标签,回车添加",value:$,onChange:ae=>D(ae.target.value),onKeyDown:ae=>ae.key==="Enter"&&en()}),s.jsx(X,{onClick:en,className:"bg-[#38bdac] hover:bg-[#2da396] h-8 text-xs px-3",children:"添加"})]})]})]}),(()=>{const ae=a.tags||a.ckbTags||"";let xe=[];try{const ut=typeof ae=="string"?JSON.parse(ae||"[]"):[];xe=Array.isArray(ut)?ut:typeof ae=="string"?ae.split(","):[]}catch{xe=typeof ae=="string"?ae.split(","):[]}const Ue=xe.map(ut=>String(ut).trim()).filter(Boolean);return Ue.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(Ad,{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:Ue.map((ut,Fn)=>s.jsx(Ve,{className:"bg-purple-500/20 text-purple-400 border-0 text-[11px] py-0",children:ut},Fn))})]})})()]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3 shrink-0",children:[s.jsxs(X,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"关闭"]}),s.jsxs(X,{onClick:Wt,disabled:P,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),P?"保存中...":"保存修改"]})]})]}):s.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}),s.jsx(Dt,{open:de,onOpenChange:ve,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsx(_t,{children:s.jsx(zt,{children:"调整余额"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"调整金额(元)"}),s.jsx(ce,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"正数增加,负数扣减,如 10 或 -5",value:ye,onChange:ae=>ke(ae.target.value)})]}),s.jsxs("div",{children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"备注(可选)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"如:活动补偿",value:ze,onChange:ae=>ft(ae.target.value)})]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(X,{variant:"outline",onClick:()=>ve(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(X,{onClick:bi,disabled:wt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:wt?"提交中...":"确认调整"})]})]})})]}):null}function HP(){const t=Sa(),[e,n]=b.useState(!0),[r,a]=b.useState(!0),[i,o]=b.useState(!0),[c,u]=b.useState([]),[h,f]=b.useState([]),[m,x]=b.useState(0),[y,N]=b.useState(0),[w,j]=b.useState(0),[S,E]=b.useState(0),[T,P]=b.useState(null),[O,q]=b.useState(null),[z,V]=b.useState(!1),[I,te]=b.useState(0),[Q,F]=b.useState(!1),[re,ie]=b.useState(null),[J,$]=b.useState("overview"),[D,R]=b.useState([]),[oe,G]=b.useState(!1),[_,U]=b.useState("today"),[H,K]=b.useState(null),[me,Y]=b.useState(!1),[le,de]=b.useState(!0),[ve,ye]=b.useState(null),[ke,ze]=b.useState(null),[ft,wt]=b.useState([]),dt=ge=>{const Se=ge;if((Se==null?void 0:Se.status)===401)P("登录已过期,请重新登录");else{if((Se==null?void 0:Se.name)==="AbortError")return;P("加载失败,请检查网络或联系管理员")}};async function Rt(ge){var jt,gt;const Se=ge?{signal:ge}:void 0;n(!0),P(null);try{const L=await Pe("/api/admin/dashboard/stats",Se);L!=null&&L.success&&(x(L.totalUsers??0),N(L.paidOrderCount??0),j(L.totalRevenue??0),E(L.conversionRate??0))}catch(L){if((L==null?void 0:L.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",L);try{const Me=await Pe("/api/admin/dashboard/overview",Se);Me!=null&&Me.success&&(x(Me.totalUsers??0),N(Me.paidOrderCount??0),j(Me.totalRevenue??0),E(Me.conversionRate??0))}catch(Me){dt(Me)}}}finally{n(!1)}try{const L=await Pe("/api/admin/balance/summary",Se);L!=null&&L.success&&L.data&&te(L.data.totalGifted??0)}catch{}try{const L=await Pe("/api/db/ckb-plan-stats",Se);L!=null&&L.success&&L.data?ie({ckbTotal:L.data.ckbTotal??0,withContact:L.data.withContact??0}):ie(null)}catch{ie(null)}de(!0);try{const[L,Me]=await Promise.allSettled([Pe("/api/db/match-records?stats=true",Se),Pe("/api/admin/distribution/overview",Se)]);L.status==="fulfilled"&&((jt=L.value)!=null&&jt.success)&&L.value.data?ye({totalMatches:L.value.data.totalMatches??0,todayMatches:L.value.data.todayMatches??0,uniqueUsers:L.value.data.uniqueUsers??0,paidMatchCount:L.value.data.paidMatchCount??0}):ye(null),Me.status==="fulfilled"&&((gt=Me.value)!=null&>.success)&&Me.value.overview?ze({todayClicks:Me.value.overview.todayClicks??0,todayBindings:Me.value.overview.todayBindings??0,todayConversions:Me.value.overview.todayConversions??0,monthClicks:Me.value.overview.monthClicks??0,monthBindings:Me.value.overview.monthBindings??0,monthConversions:Me.value.overview.monthConversions??0,totalClicks:Me.value.overview.totalClicks??0,totalBindings:Me.value.overview.totalBindings??0,totalConversions:Me.value.overview.totalConversions??0,conversionRate:Me.value.overview.conversionRate}):ze(null)}catch{ye(null),ze(null)}finally{de(!1)}try{const L=await Pe("/api/db/vip-members?limit=500",Se);L!=null&&L.success&&Array.isArray(L.data)?wt(L.data):wt([])}catch{wt([])}a(!0),o(!0);const $e=async()=>{try{const L=await Pe("/api/admin/dashboard/recent-orders?limit=10",Se);if(L!=null&&L.success&&L.recentOrders)f(L.recentOrders);else throw new Error("no data")}catch(L){if((L==null?void 0:L.name)!=="AbortError")try{const Me=await Pe("/api/admin/orders?page=1&pageSize=20&status=paid",Se),Et=((Me==null?void 0:Me.orders)??[]).filter(ht=>["paid","completed","success"].includes(ht.status||""));f(Et.slice(0,5))}catch{f([])}}finally{a(!1)}},Xe=async()=>{try{const L=await Pe("/api/admin/dashboard/new-users",Se);if(L!=null&&L.success&&L.newUsers)u(L.newUsers);else throw new Error("no data")}catch(L){if((L==null?void 0:L.name)!=="AbortError")try{const Me=await Pe("/api/db/users?page=1&pageSize=10",Se);u((Me==null?void 0:Me.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([$e(),Xe()])}async function Tt(ge){const Se=ge||_;Y(!0);try{const $e=await Pe(`/api/admin/track/stats?period=${Se}`);$e!=null&&$e.success&&K({total:$e.total??0,byModule:$e.byModule??{}})}catch{K(null)}finally{Y(!1)}}const Tn={home:"首页",chapters:"目录",read:"阅读页",my:"我的",vip:"超级个体",wallet:"钱包",match:"找伙伴",referral:"推广中心",search:"搜索",settings:"设置",about:"关于",member_detail:"成员详情",other:"其他"},mn={btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",page_view:"页面浏览",share:"分享",purchase:"购买",register:"注册",rule_trigger:"规则触发",view_chapter:"浏览章节",link_click:"链接点击"},Ft=ge=>ge?ge.replace(/^part-/,"").replace(/^soulvip_/,"").replace(/^super_?/,"").replace(/^user_/,"").replace(/[_-]+/g," ").trim():"",qt=ge=>{if(!ge)return"";const Se=ge.trim().toLowerCase();if(!Se)return"";const $e=ft.find(jt=>{const gt=String(jt.id||"").toLowerCase();return gt===Se||gt.includes(Se)||Se.includes(gt)});if($e)return $e.name||$e.nickname||"";const Xe=ft.find(jt=>{const gt=String(jt.token||"").toLowerCase();return gt&&(gt===Se||gt.includes(Se)||Se.includes(gt))});return Xe&&(Xe.name||Xe.nickname)||""},vn=ge=>{if(!ge)return"未命名点击";const Se=ge.trim(),$e=Se.toLowerCase();if(/^链接头像[_-]/.test(Se)){const jt=Ft(Se.replace(/^链接头像[_-]/,""));return jt?`头像:${jt}`:"头像点击"}if(/^member[_-]?detail$/i.test($e)||$e.includes("member detail"))return"成员详情";if(/^giftpay$/i.test($e)||$e.includes("gift pay"))return"代付入口";if(/^part[-_]/i.test($e))return`章节:${Ft(Se)}`;if($e.includes("soulvip")||$e.includes("super")){const jt=Se.replace(/^超级个体[::]?/i,"").replace(/^super[_-]?/i,"").replace(/^soulvip[_-]?/i,"").replace(/^user[_-]?/i,"").trim(),gt=qt(jt)||qt(Ft(jt));return gt?`超级个体:${gt}`:`超级个体:${Ft(jt)}`}if($e.includes("qgdtw")||$e.includes("token")||$e.includes("0000"))return`对象:${Ft(Se)}`;const Xe={开始匹配:"开始匹配",mentor:"导师顾问",team:"团队招募",investor:"资源对接",充值:"充值",退款:"退款",wallet:"钱包",设置:"设置",VIP:"VIP会员",推广:"推广中心",目录:"目录",搜索:"搜索",匹配:"找伙伴",settings:"设置",expired:"已过期",active:"活跃",converted:"已转化",fill_profile:"完善资料",register:"注册",purchase:"购买",链接卡若:"链接卡若",更多分享:"更多分享",分享朋友圈文案:"分享朋友圈",选择金额10:"选择金额10元",member_detail:"成员详情",giftPay:"代付入口"};return Xe[Se]?Xe[Se]:/^[a-z0-9_-]+$/i.test(Se)&&Ft(Se)||Se},On=ge=>{const Se=Tn[ge.module]||Tn[ge.page]||ge.module||ge.page||"其他",$e=mn[ge.action]||ge.action||"点击",Xe=vn(ge.target);return`${Se} · ${$e} · ${Xe}`};async function $n(){G(!0);try{const ge=await Pe("/api/admin/super-individual/stats");ge!=null&&ge.success&&Array.isArray(ge.data)&&R(ge.data)}catch{}finally{G(!1)}}b.useEffect(()=>{const ge=new AbortController;return Rt(ge.signal),Tt(),$n(),()=>{ge.abort()}},[]);const St=m,cn=ge=>{const Se=ge.productType||"",$e=ge.description||"";if(Se==="balance_recharge")return{title:`余额充值 ¥${typeof ge.amount=="number"?ge.amount.toFixed(2):parseFloat(String(ge.amount||"0")).toFixed(2)}`,subtitle:"余额充值"};if(Se==="gift_pay")return{title:`代付 ¥${typeof ge.amount=="number"?ge.amount.toFixed(2):parseFloat(String(ge.amount||"0")).toFixed(2)}`,subtitle:"好友代付"};if(Se==="gift_pay_batch"){const Xe=typeof ge.amount=="number"?ge.amount.toFixed(2):parseFloat(String(ge.amount||"0")).toFixed(2);return{title:$e||`代付分享 ¥${Xe}`,subtitle:"代付分享"}}if(Se==="section"&&$e.includes("代付领取"))return{title:$e.replace("代付领取 - ",""),subtitle:"代付领取"};if($e){if(Se==="section"&&$e.includes("章节")){if($e.includes("-")){const Xe=$e.split("-");if(Xe.length>=3)return{title:`第${Xe[1]}章 第${Xe[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:$e,subtitle:"章节购买"}}return Se==="fullbook"||$e.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:Se==="vip"||$e.includes("VIP")?{title:"超级个体开通费用",subtitle:"超级个体"}:Se==="match"||$e.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:$e,subtitle:Se==="section"?"单章":Se==="fullbook"?"全书":"其他"}}return Se==="section"?{title:`章节 ${ge.productId||""}`,subtitle:"单章购买"}:Se==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:Se==="vip"?{title:"超级个体开通费用",subtitle:"超级个体"}:Se==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:Se||"其他"}},xn=[{title:"总用户数",value:e?null:St,sub:null,icon:In,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:e?null:`¥${(w??0).toFixed(2)}`,sub:I>0?`含代付 ¥${I.toFixed(2)}`:null,icon:Gh,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:y,sub:null,icon:Md,color:"text-purple-400",bg:"bg-purple-500/20",link:"/orders"},{title:"转化率",value:e?null:`${typeof S=="number"?S.toFixed(1):0}%`,sub:null,icon:Gs,color:"text-orange-400",bg:"bg-orange-500/20",link:"/distribution"},{title:"存客宝获客",value:re?re.ckbTotal??0:null,sub:(re==null?void 0:re.withContact)!=null?`含联系方式 ${re.withContact} 人`:null,icon:hc,color:"text-cyan-400",bg:"bg-cyan-500/20",link:"/users?tab=leads"},{title:"伙伴&推广协同",value:le?null:((ve==null?void 0:ve.totalMatches)??0)+((ke==null?void 0:ke.totalClicks)??0),sub:le?null:`找伙伴 ${(ve==null?void 0:ve.totalMatches)??0} / 推广 ${(ke==null?void 0:ke.totalClicks)??0}`,icon:rc,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:"数据概览"}),T&&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:T}),s.jsx("button",{type:"button",onClick:()=>Rt(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),s.jsx("div",{className:"flex flex-nowrap gap-6 mb-8 overflow-x-auto pb-1",children:xn.map((ge,Se)=>s.jsxs(Oe,{className:"min-w-[220px] flex-1 bg-[#0f2137] border-gray-700/50 shadow-xl cursor-pointer hover:border-[#38bdac]/50 transition-colors group",onClick:()=>ge.link&&t(ge.link),children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsx(at,{className:"text-sm font-medium text-gray-400",children:ge.title}),s.jsx("div",{className:`p-2 rounded-lg ${ge.bg}`,children:s.jsx(ge.icon,{className:`w-4 h-4 ${ge.color}`})})]}),s.jsx(Le,{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:ge.value!=null?ge.value:s.jsxs("span",{className:"inline-flex items-center gap-2 text-gray-500",children:[s.jsx(Fe,{className:"w-4 h-4 animate-spin"}),"加载中"]})}),ge.sub&&s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:ge.sub})]}),s.jsx(Xo,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},Se))}),s.jsxs("div",{className:"flex gap-2 mb-6 mt-2",children:[s.jsx("button",{type:"button",onClick:()=>$("overview"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${J==="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:()=>$("tags"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${J==="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:()=>$("super"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${J==="super"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"超级个体统计"})]}),J==="overview"&&s.jsxs("div",{className:"space-y-8",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between",children:[s.jsx(at,{className:"text-white",children:"找伙伴 × 推广中心(共统计)"}),s.jsxs("button",{type:"button",onClick:()=>Rt(),disabled:le,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新共统计",children:[s.jsx(Fe,{className:`w-3.5 h-3.5 ${le?"animate-spin":""}`}),"刷新"]})]}),s.jsxs(Le,{children:[le&&!ve&&!ke?s.jsxs("div",{className:"flex items-center justify-center py-10 text-gray-500",children:[s.jsx(Fe,{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:(ve==null?void 0:ve.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:(ve==null?void 0:ve.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:(ve==null?void 0:ve.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:(ke==null?void 0:ke.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:(ke==null?void 0:ke.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:(ke==null?void 0:ke.totalConversions)??0})]})]}),(ke==null?void 0:ke.conversionRate)&&s.jsxs("p",{className:"text-xs text-gray-500 mt-3",children:["推广转化率:",ke.conversionRate]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between",children:[s.jsx(at,{className:"text-white",children:"最近订单"}),s.jsxs("button",{type:"button",onClick:()=>Rt(),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(Fe,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(Fe,{className:"w-3.5 h-3.5"}),"刷新"]})]}),s.jsx(Le,{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(Fe,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[h.slice(0,Q?10:4).map(ge=>{var gt;const Se=ge.referrerId?c.find(L=>L.id===ge.referrerId):void 0,$e=ge.referralCode||(Se==null?void 0:Se.referralCode)||(Se==null?void 0:Se.nickname)||(ge.referrerId?String(ge.referrerId).slice(0,8):""),Xe=cn(ge),jt=ge.userNickname||((gt=c.find(L=>L.id===ge.userId))==null?void 0:gt.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:[ge.userAvatar?s.jsx("img",{src:ge.userAvatar,alt:jt,className:"w-9 h-9 rounded-full object-cover shrink-0 mt-0.5",onError:L=>{L.currentTarget.style.display="none";const Me=L.currentTarget.nextElementSibling;Me&&Me.classList.remove("hidden")}}):null,s.jsx("div",{className:`w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] shrink-0 mt-0.5 ${ge.userAvatar?"hidden":""}`,children:jt.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:()=>{ge.userId&&(q(ge.userId),V(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:jt}),s.jsx("span",{className:"text-gray-600",children:"·"}),s.jsx("span",{className:"text-sm font-medium text-white truncate",title:Xe.title,children:Xe.title})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[Xe.subtitle&&Xe.subtitle!=="章节购买"&&s.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:Xe.subtitle}),s.jsx("span",{children:new Date(ge.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),$e&&s.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",$e]})]})]}),s.jsxs("div",{className:"text-right ml-4 shrink-0",children:[s.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(ge.amount).toFixed(2)]}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:ge.paymentMethod||"微信"})]})]},ge.id)}),h.length>4&&!Q&&s.jsx("button",{type:"button",onClick:()=>F(!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(Md,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(rt,{children:s.jsx(at,{className:"text-white",children:"新注册用户"})}),s.jsx(Le,{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(Fe,{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(ge=>{var Se;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:((Se=ge.nickname)==null?void 0:Se.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("button",{type:"button",onClick:()=>{q(ge.id),V(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:ge.nickname||"匿名用户"}),s.jsx("p",{className:"text-xs text-gray-500",children:ge.phone||"未绑定手机"})]})]}),s.jsx("p",{className:"text-xs text-gray-400",children:ge.createdAt?new Date(ge.createdAt).toLocaleDateString():"-"})]},ge.id)}),c.length===0&&!i&&s.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})})]})]})]}),J==="tags"&&s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between",children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(rc,{className:"w-5 h-5 text-[#38bdac]"}),"分类标签点击统计"]}),s.jsx("div",{className:"flex items-center gap-2",children:["today","week","month","all"].map(ge=>s.jsx("button",{type:"button",onClick:()=>{U(ge),Tt(ge)},className:`px-3 py-1 text-xs rounded-full transition-colors ${_===ge?"bg-[#38bdac] text-white":"bg-gray-700/50 text-gray-400 hover:bg-gray-700"}`,children:{today:"今日",week:"本周",month:"本月",all:"全部"}[ge]},ge))})]}),s.jsx(Le,{children:me&&!H?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(Fe,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):H&&Object.keys(H.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:H.total})," 次"]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Object.entries(H.byModule).sort((ge,Se)=>Se[1].reduce(($e,Xe)=>$e+Xe.count,0)-ge[1].reduce(($e,Xe)=>$e+Xe.count,0)).slice(0,5).map(([ge,Se])=>{const $e=Se.reduce((Xe,jt)=>Xe+jt.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:Tn[ge]||ge}),s.jsxs("span",{className:"text-xs text-gray-500",children:[$e," 次"]})]}),s.jsx("div",{className:"space-y-2",children:Se.sort((Xe,jt)=>jt.count-Xe.count).slice(0,8).map((Xe,jt)=>{const gt=On(Xe);return s.jsxs("div",{className:"flex items-center justify-between text-xs",children:[s.jsx("span",{className:"text-gray-300 truncate mr-2",title:gt,children:gt}),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:`${$e>0?Xe.count/$e*100:0}%`}})}),s.jsx("span",{className:"text-gray-400 w-8 text-right",children:Xe.count})]})]},jt)})})]},ge)})})]}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(rc,{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:"小程序端接入埋点后,数据将在此实时展示"})]})})]}),J==="super"&&s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between",children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(rc,{className:"w-5 h-5 text-amber-400"}),"超级个体点击统计"]}),s.jsxs(X,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300 h-8",onClick:$n,disabled:oe,children:[s.jsx(Fe,{className:`w-3.5 h-3.5 mr-1 ${oe?"animate-spin":""}`}),"刷新"]})]}),s.jsx(Le,{children:oe&&D.length===0?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(Fe,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):D.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:D.map((ge,Se)=>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:Se+1}),s.jsx("td",{className:"py-2 px-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[ge.avatar?s.jsx("img",{src:ge.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(ge.nickname||ge.userId)}`),title:"点击跳转用户管理",children:ge.nickname||ge.userId})]})}),s.jsx("td",{className:"py-2 px-3 text-center text-white font-bold",children:ge.clicks}),s.jsx("td",{className:"py-2 px-3 text-center text-[#38bdac]",children:ge.uniqueClicks}),s.jsx("td",{className:"py-2 px-3 text-center text-gray-400",children:ge.uniqueClicks>0?(ge.clicks/ge.uniqueClicks).toFixed(1):"-"}),s.jsx("td",{className:"py-2 px-3 text-center text-green-400 text-xs font-medium",children:typeof ge.leadCount=="number"?ge.leadCount:0}),s.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs",children:ge.phone||"-"})]},ge.userId))})]})}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(rc,{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(I0,{open:z,onClose:()=>{V(!1),q(null)},userId:O,onUserUpdated:()=>Rt()})]})}const ds=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx("table",{ref:n,className:Ut("w-full caption-bottom text-sm",t),...e})}));ds.displayName="Table";const us=b.forwardRef(({className:t,...e},n)=>s.jsx("thead",{ref:n,className:Ut("[&_tr]:border-b",t),...e}));us.displayName="TableHeader";const hs=b.forwardRef(({className:t,...e},n)=>s.jsx("tbody",{ref:n,className:Ut("[&_tr:last-child]:border-0",t),...e}));hs.displayName="TableBody";const ct=b.forwardRef(({className:t,...e},n)=>s.jsx("tr",{ref:n,className:Ut("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));ct.displayName="TableRow";const je=b.forwardRef(({className:t,...e},n)=>s.jsx("th",{ref:n,className:Ut("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));je.displayName="TableHead";const be=b.forwardRef(({className:t,...e},n)=>s.jsx("td",{ref:n,className:Ut("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));be.displayName="TableCell";function ef(t,e){const[n,r]=b.useState(t);return b.useEffect(()=>{const a=setTimeout(()=>r(t),e);return()=>clearTimeout(a)},[t,e]),n}function qs({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 UP(){const[t,e]=b.useState([]),[n,r]=b.useState([]),[a,i]=b.useState(0),[o,c]=b.useState(0),[u,h]=b.useState(0),[f,m]=b.useState(1),[x,y]=b.useState(10),[N,w]=b.useState(""),j=ef(N,300),[S,E]=b.useState("all"),[T,P]=b.useState(!0),[O,q]=b.useState(null),[z,V]=b.useState(null),[I,te]=b.useState(""),[Q,F]=b.useState(!1);async function re(){P(!0),q(null);try{const G=S==="all"?"":S==="completed"?"completed":S,_=new URLSearchParams({page:String(f),pageSize:String(x),...G&&{status:G},...j&&{search:j}}),[U,H]=await Promise.all([Pe(`/api/admin/orders?${_}`),Pe("/api/db/users?page=1&pageSize=500")]);U!=null&&U.success&&(e(U.orders||[]),i(U.total??0),c(U.totalRevenue??0),h(U.todayRevenue??0)),H!=null&&H.success&&H.users&&r(H.users)}catch(G){console.error("加载订单失败",G),q("加载订单失败,请检查网络后重试")}finally{P(!1)}}b.useEffect(()=>{m(1)},[j,S]),b.useEffect(()=>{re()},[f,x,j,S]);const ie=G=>{var _;return G.userNickname||((_=n.find(U=>U.id===G.userId))==null?void 0:_.nickname)||"匿名用户"},J=G=>{var _;return((_=n.find(U=>U.id===G))==null?void 0:_.phone)||"-"},$=G=>{const _=G.productType||G.type||"",U=G.description||"";if(_==="balance_recharge")return{name:`余额充值 ¥${Number(G.amount||0).toFixed(2)}`,type:"余额充值"};if(U){if(_==="section"&&(U.includes("章节")||U.includes("代付领取"))){if(U.includes("代付领取"))return{name:U.replace("代付领取 - ",""),type:"代付领取"};if(U.includes("-")){const H=U.split("-");if(H.length>=3)return{name:`第${H[1]}章 第${H[2]}节`,type:"《一场Soul的创业实验》"}}return{name:U,type:"章节购买"}}return _==="fullbook"||U.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:_==="vip"||U.includes("VIP")?{name:"超级个体开通费用",type:"超级个体"}:_==="match"||U.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:U,type:"其他"}}return _==="section"?{name:`章节 ${G.productId||G.sectionId||""}`,type:"单章"}:_==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:_==="vip"?{name:"超级个体开通费用",type:"超级个体"}:_==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:_||"其他"}},D=Math.ceil(a/x)||1;async function R(){var G;if(!(!(z!=null&&z.orderSn)&&!(z!=null&&z.id))){F(!0),q(null);try{const _=await Gt("/api/admin/orders/refund",{orderSn:z.orderSn||z.id,reason:I||void 0});_!=null&&_.success?(V(null),te(""),re()):q((_==null?void 0:_.error)||"退款失败")}catch(_){const U=_;q(((G=U==null?void 0:U.data)==null?void 0:G.error)||"退款失败,请检查网络后重试")}finally{F(!1)}}}function oe(){if(t.length===0){se.info("暂无数据可导出");return}const G=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],_=t.map(Y=>{const le=$(Y);return[Y.orderSn||Y.id||"",ie(Y),J(Y.userId),le.name,Number(Y.amount||0).toFixed(2),Y.paymentMethod==="wechat"?"微信支付":Y.paymentMethod==="balance"?"余额支付":Y.paymentMethod==="alipay"?"支付宝":Y.paymentMethod||"微信支付",Y.status==="refunded"?"已退款":Y.status==="paid"||Y.status==="completed"?"已完成":Y.status==="pending"||Y.status==="created"?"待支付":"已失败",Y.status==="refunded"&&Y.refundReason?Y.refundReason:"-",Y.referrerEarnings?Number(Y.referrerEarnings).toFixed(2):"-",Y.createdAt?new Date(Y.createdAt).toLocaleString("zh-CN"):""].join(",")}),U="\uFEFF"+[G.join(","),..._].join(` +`),H=new Blob([U],{type:"text/csv;charset=utf-8"}),K=URL.createObjectURL(H),me=document.createElement("a");me.href=K,me.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,me.click(),URL.revokeObjectURL(K)}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:()=>q(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(X,{variant:"outline",onClick:re,disabled:T,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${T?"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(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(ce,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:N,onChange:G=>w(G.target.value)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ej,{className:"w-4 h-4 text-gray-400"}),s.jsxs("select",{value:S,onChange:G=>E(G.target.value),className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"pending",children:"待支付"}),s.jsx("option",{value:"created",children:"已创建"}),s.jsx("option",{value:"failed",children:"已失败"}),s.jsx("option",{value:"refunded",children:"已退款"})]})]}),s.jsxs(X,{variant:"outline",onClick:oe,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(T5,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:T?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Fe,{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(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"订单号"}),s.jsx(je,{className:"text-gray-400",children:"用户"}),s.jsx(je,{className:"text-gray-400",children:"商品"}),s.jsx(je,{className:"text-gray-400",children:"金额"}),s.jsx(je,{className:"text-gray-400",children:"支付方式"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-gray-400",children:"退款原因"}),s.jsx(je,{className:"text-gray-400",children:"分销佣金"}),s.jsx(je,{className:"text-gray-400",children:"下单时间"}),s.jsx(je,{className:"text-gray-400",children:"操作"})]})}),s.jsxs(hs,{children:[t.map(G=>{const _=$(G);return s.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsxs(be,{className:"font-mono text-xs text-gray-400",children:[(G.orderSn||G.id||"").slice(0,12),"..."]}),s.jsx(be,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[ie(G),G.paymentMethod==="gift_pay"&&s.jsx(Ve,{className:"bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 border-0 text-xs",children:"代付领取"}),G.payerUserId&&G.paymentMethod!=="gift_pay"&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"代付"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:J(G.userId)}),G.payerUserId&&G.payerNickname&&s.jsxs("p",{className:"text-amber-400/80 text-xs mt-0.5",children:[G.paymentMethod==="gift_pay"?"赠送人:":"代付人:",G.payerNickname]})]})}),s.jsx(be,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[_.name,(G.productType||G.type)==="vip"&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"超级个体"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:_.type})]})}),s.jsxs(be,{className:"text-[#38bdac] font-bold",children:["¥",Number(G.amount||0).toFixed(2)]}),s.jsx(be,{className:"text-gray-300",children:G.paymentMethod==="wechat"?"微信支付":G.paymentMethod==="balance"?"余额支付":G.paymentMethod==="alipay"?"支付宝":G.paymentMethod||"微信支付"}),s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[G.status==="refunded"?s.jsx(Ve,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):G.status==="paid"||G.status==="completed"?s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):G.status==="pending"||G.status==="created"?s.jsx(Ve,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):s.jsx(Ve,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"}),(G.status==="paid"||G.status==="completed")&&(G.webhookPushStatus==="sent"?s.jsx(Ve,{className:"bg-emerald-500/20 text-emerald-300 hover:bg-emerald-500/20 border-0",children:"已推送"}):s.jsx(Ve,{className:"bg-orange-500/20 text-orange-300 hover:bg-orange-500/20 border-0",children:"待补推"}))]})}),s.jsx(be,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:G.refundReason,children:G.status==="refunded"&&G.refundReason?G.refundReason:"-"}),s.jsx(be,{className:"text-[#FFD700]",children:G.referrerEarnings?`¥${Number(G.referrerEarnings).toFixed(2)}`:"-"}),s.jsx(be,{className:"text-gray-400 text-sm",children:new Date(G.createdAt).toLocaleString("zh-CN")}),s.jsx(be,{children:(G.status==="paid"||G.status==="completed")&&G.paymentMethod!=="balance"&&s.jsxs(X,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{V(G),te("")},children:[s.jsx(Ij,{className:"w-3 h-3 mr-1"}),"退款"]})})]},G.id)}),t.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),s.jsx(qs,{page:f,totalPages:D,total:a,pageSize:x,onPageChange:m,onPageSizeChange:G=>{y(G),m(1)}})]})})}),s.jsx(Dt,{open:!!z,onOpenChange:G=>!G&&V(null),children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(_t,{children:s.jsx(zt,{className:"text-white",children:"订单退款"})}),z&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",z.orderSn||z.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(z.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(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:I,onChange:G=>te(G.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>V(null),disabled:Q,children:"取消"}),s.jsx(X,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:R,disabled:Q,children:Q?"退款中...":"确认退款"})]})]})})]})}const hl=b.forwardRef(({className:t,...e},n)=>s.jsx("textarea",{className:Ut("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}));hl.displayName="Textarea";const P1=["INTJ","INTP","ENTJ","ENTP","INFJ","INFP","ENFJ","ENFP","ISTJ","ISFJ","ESTJ","ESFJ","ISTP","ISFP","ESTP","ESFP"],Xk={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 WP(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 KP(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 qP(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 O1(t){const e=Xk[t],n=WP(e.group),r=KP(e.mood),a=qP(e.mood),i=` @@ -655,15 +655,15 @@ For more information, see https://radix-ui.com/primitives/docs/components/${e.do -`;return`data:image/svg+xml;utf8,${encodeURIComponent(i)}`}function GP(){const[t,e]=b.useState({}),[n,r]=b.useState(!0),[a,i]=b.useState(!1),[o,c]=b.useState(!1),u=b.useCallback(async()=>{r(!0);try{const g=await Pe("/api/admin/mbti-avatars");g!=null&&g.avatars?e(g.avatars):e({})}catch{se.error("加载 MBTI 头像配置失败")}finally{r(!1)}},[]);b.useEffect(()=>{u()},[u]);const h=async()=>{i(!0);try{const g=await Ct("/api/admin/mbti-avatars",{avatars:t});if(!g||g.success===!1){se.error((g==null?void 0:g.error)||"保存失败");return}se.success("已保存,后台与小程序默认头像同步生效"),u()}catch{se.error("保存失败")}finally{i(!1)}},f=g=>{const y=O1(g);e(N=>({...N,[g]:y})),se.success(`${g} 已生成`)},m=()=>{c(!0);try{const g={...t};P1.forEach(y=>{g[y]=O1(y)}),e(g),se.success("16 型头像已生成(仅人物)")}finally{c(!1)}};return n?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-400",children:[s.jsx(Fe,{className:"w-5 h-5 mr-2 animate-spin text-[#38bdac]"}),"加载配置…"]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-[#38bdac]/25 shadow-xl",children:[s.jsxs(rt,{className:"pb-2",children:[s.jsxs(at,{className:"text-white flex items-center gap-2 text-lg",children:[s.jsx(tA,{className:"w-5 h-5 text-[#38bdac]"}),"MBTI 头像库"]}),s.jsx(Kt,{className:"text-gray-400 text-sm leading-relaxed",children:"采用人物化风格,按 MBTI 性格自动生成。头像内不显示中英文,仅显示人物形象,颜色与站点主题融合。"})]}),s.jsxs(Le,{className:"flex flex-wrap gap-2",children:[s.jsxs(X,{type:"button",size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396]",onClick:m,disabled:o,children:[s.jsx(kA,{className:"w-3.5 h-3.5 mr-1"}),o?"生成中…":"一键生成16头像"]}),s.jsxs(X,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-300",onClick:u,children:[s.jsx(Fe,{className:"w-3.5 h-3.5 mr-1"}),"重新加载"]}),s.jsxs(X,{type:"button",size:"sm",className:"bg-emerald-600 hover:bg-emerald-500",onClick:h,disabled:a,children:[s.jsx(bn,{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:P1.map(g=>{const y=t[g]??"",N=Xk[g];return s.jsxs("div",{className:"rounded-xl border border-gray-700/60 bg-[#0a1628] p-3 flex flex-col gap-2 hover:border-[#38bdac]/35 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 font-mono text-xs",children:g}),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:y?s.jsx("img",{src:y,alt:g,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(de,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"https://... 或 data:image/...",value:y,onChange:w=>e(j=>({...j,[g]:w.target.value}))})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(X,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-[#38bdac]/40 text-[#38bdac]",onClick:()=>f(g),children:"生成这张"}),s.jsx(X,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-[11px] text-gray-400",onClick:()=>e(w=>({...w,[g]:""})),children:"清空"})]})]},g)})})]})}const L1=[{value:"after_login",label:"注册/登录成功",group:"用户状态"},{value:"bind_phone",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:"用户状态"}],D1=[{value:"popup",label:"弹窗提示",desc:"在小程序内弹窗引导用户完成下一步"},{value:"navigate",label:"跳转页面",desc:"引导用户跳转到指定页面"},{value:"webhook",label:"推送飞书群",desc:"触发后推送消息到飞书群Webhook"},{value:"tag",label:"自动打标签",desc:"触发后自动给用户打上指定标签"}],JP=[{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:"待激活"}],tc=[{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 _1(t){return confirm(`确定删除该${t}?此操作不可恢复。`)?window.prompt(`请输入「删除」以确认删除${t}`)==="删除":!1}function QP(){var Ei,zr,Mi,Va,Ha,$r,da;const[t,e]=g0(),n=t.get("pool"),r=t.get("tab")||"users",a=["users","journey","rules","vip-roles","leads"].includes(r)?r:"users",[i,o]=b.useState([]),[c,u]=b.useState(0),[h,f]=b.useState(1),[m,g]=b.useState(10),[y,N]=b.useState(""),w=ef(y,300),j=n==="vip"?"vip":n==="complete"?"complete":"all",[S,E]=b.useState(j),[T,P]=b.useState(!0),[O,q]=b.useState(!1),[z,V]=b.useState(null),[I,te]=b.useState(!1),[Q,F]=b.useState(!1),[re,ae]=b.useState("desc");b.useEffect(()=>{n==="vip"?E("vip"):n==="complete"?E("complete"):n==="all"&&E("all")},[n]);const[J,$]=b.useState(!1),[D,R]=b.useState(null),[oe,G]=b.useState(!1),[_,U]=b.useState(!1),[H,K]=b.useState({referrals:[],stats:{}}),[me,Y]=b.useState(!1),[le,ce]=b.useState(null),[ve,ye]=b.useState(!1),[ke,ze]=b.useState(null),[ht,wt]=b.useState(!1),[dt,Rt]=b.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[Tt,Tn]=b.useState([]),[mn,Ft]=b.useState(!1),[qt,vn]=b.useState(!1),[On,$n]=b.useState(null),[St,cn]=b.useState({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),[gn,xe]=b.useState([]),[Se,$e]=b.useState(!1),[Xe,jt]=b.useState(null),[xt,L]=b.useState(null),[Me,ft]=b.useState({}),[Et,ut]=b.useState(!1),[tt,Pt]=b.useState(null),[Wt,en]=b.useState([]),[ts,Js]=b.useState(!1),[bi,ea]=b.useState(null),[ta,Er]=b.useState(""),[Mr,Ar]=b.useState([]),[cr,dr]=b.useState(!1),[Ea,Qs]=b.useState({}),[Ss,Ys]=b.useState([]),[ur,Cs]=b.useState(0),[ie,ge]=b.useState(1),[Qe]=b.useState(20),[pt,Fn]=b.useState(!1),[Ps,Ma]=b.useState(null),[Aa,To]=b.useState(""),Xs=ef(Aa,300),[Ts,vi]=b.useState(""),[Mt,Bc]=b.useState({}),Ir=b.useCallback(async(v,A)=>{Fn(!0),Ma(null);try{const B=new URLSearchParams({mode:"contact",page:String(ie),pageSize:String(Qe)}),ue=v??Xs;ue&&B.set("search",ue);const we=A??Ts;we&&B.set("source",we);const De=await Pe(`/api/db/ckb-leads?${B}`);if(De!=null&&De.success)Ys(De.records||[]),Cs(De.total??0),De.stats&&Bc(De.stats);else{const it=(De==null?void 0:De.error)||"加载获客列表失败";Ma(it),se.error(it),Ys([]),Cs(0)}}catch(B){const ue=B instanceof Error?B.message:"网络错误";Ma(ue),se.error("加载获客列表失败: "+ue),Ys([]),Cs(0)}finally{Fn(!1)}},[ie,Qe,Xs,Ts]),Ni=b.useCallback(async()=>{try{const v=await Pe("/api/admin/mbti-avatars"),A=v!=null&&v.avatars&&typeof v.avatars=="object"?v.avatars:{};Qs(A)}catch{Qs({})}},[]);b.useEffect(()=>{t.get("tab")==="leads"&&Ir()},[t.get("tab"),ie,Ir]),b.useEffect(()=>{Ni()},[Ni]);const Rr=b.useCallback((v,A)=>{const B=(v||"").trim();if(B)return B;const ue=(A||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(ue)?(Ea[ue]||"").trim():""},[Ea]),Vc=b.useCallback(v=>{const A=!!v.hasFullBook,B=Number(v.purchasedSectionCount||0);return A?{tone:"vip",main:"已购全书",sub:B>0?`另购单章 ${B} 章`:"购买项:VIP / 全书"}:B>0?{tone:"paid",main:`已购 ${B} 章`,sub:"购买项:章节"}:{tone:"free",main:"未购买",sub:""}},[]),[Ia,na]=b.useState(null),ns=b.useCallback(async()=>{try{const v=await Pe("/api/admin/users/online-stats");v!=null&&v.success&&typeof v.onlineCount=="number"?na(v.onlineCount):na(0)}catch{na(null)}},[]);b.useEffect(()=>{ns();const v=setInterval(ns,1e4);return()=>clearInterval(v)},[ns]);async function sa(v=!1){var A;P(!0),v&&q(!0),V(null);try{if(I){const B=new URLSearchParams({search:w,limit:String(m*5)}),ue=await Pe(`/api/db/users/rfm?${B}`);if(ue!=null&&ue.success){let we=ue.users||[];re==="asc"&&(we=[...we].reverse());const De=(h-1)*m;o(we.slice(De,De+m)),u(((A=ue.users)==null?void 0:A.length)??0),we.length===0&&(te(!1),V("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else te(!1),V((ue==null?void 0:ue.error)||"RFM 加载失败,已切回普通模式")}else{const B=new URLSearchParams({page:String(h),pageSize:String(m),search:w,...S==="vip"&&{vip:"true"},...S==="complete"&&{pool:"complete"}}),ue=await Pe(`/api/db/users?${B}`);ue!=null&&ue.success?(o(ue.users||[]),u(ue.total??0)):V((ue==null?void 0:ue.error)||"加载失败")}}catch(B){console.error("Load users error:",B),V("网络错误")}finally{P(!1),v&&q(!1)}}b.useEffect(()=>{f(1)},[w,S,I]),b.useEffect(()=>{sa()},[h,m,w,S,I,re]);const qn=Math.ceil(c/m)||1,Cl=()=>{I?re==="desc"?ae("asc"):(te(!1),ae("desc")):(te(!0),ae("desc"))},Pr=v=>({S:"bg-amber-500/20 text-amber-400",A:"bg-green-500/20 text-green-400",B:"bg-blue-500/20 text-blue-400",C:"bg-gray-500/20 text-gray-400",D:"bg-red-500/20 text-red-400"})[v||""]||"bg-gray-500/20 text-gray-400";async function Hc(v){var A;if(!_1("用户")){se.info("已取消删除");return}try{const B=await li(`/api/db/users?id=${encodeURIComponent(v)}`);B!=null&&B.success?(se.success("已删除"),sa()):se.error("删除失败: "+((B==null?void 0:B.error)||"未知错误"))}catch(B){const ue=B,we=((A=ue==null?void 0:ue.data)==null?void 0:A.error)||(ue==null?void 0:ue.message)||"网络错误";se.error("删除失败: "+we)}}const wi=v=>{R(v),Rt({phone:v.phone||"",nickname:v.nickname||"",password:"",isAdmin:!!(v.isAdmin??!1),hasFullBook:!!(v.hasFullBook??!1)}),$(!0)},Ra=()=>{R(null),Rt({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),$(!0)};async function ra(){if(!dt.phone||!dt.nickname){se.error("请填写手机号和昵称");return}G(!0);try{if(D){const v=await Gt("/api/db/users",{id:D.id,phone:dt.phone||void 0,nickname:dt.nickname,isAdmin:dt.isAdmin,hasFullBook:dt.hasFullBook,...dt.password&&{password:dt.password}});if(!(v!=null&&v.success)){se.error("更新失败: "+((v==null?void 0:v.error)||""));return}}else{const v=await Ct("/api/db/users",{phone:dt.phone,nickname:dt.nickname,password:dt.password,isAdmin:dt.isAdmin});if(!(v!=null&&v.success)){se.error("创建失败: "+((v==null?void 0:v.error)||""));return}}$(!1),sa()}catch{se.error("保存失败")}finally{G(!1)}}async function aa(v){ce(v),U(!0),Y(!0);try{const A=await Pe(`/api/db/users/referrals?userId=${encodeURIComponent(v.id)}`);A!=null&&A.success?K({referrals:A.referrals||[],stats:A.stats||{}}):K({referrals:[],stats:{}})}catch{K({referrals:[],stats:{}})}finally{Y(!1)}}const ia=b.useCallback(async()=>{Ft(!0);try{const v=await Pe("/api/db/user-rules");v!=null&&v.success&&Tn(v.rules||[])}catch{}finally{Ft(!1)}},[]);async function ji(){if(!St.title){se.error("请填写规则标题");return}G(!0);try{if(On){const v=await Gt("/api/db/user-rules",{id:On.id,...St});if(!(v!=null&&v.success)){se.error("更新失败: "+((v==null?void 0:v.error)||""));return}}else{const v=await Ct("/api/db/user-rules",St);if(!(v!=null&&v.success)){se.error("创建失败: "+((v==null?void 0:v.error)||""));return}}vn(!1),ia()}catch{se.error("保存失败")}finally{G(!1)}}async function ki(v){if(!_1("规则")){se.info("已取消删除");return}try{const A=await li(`/api/db/user-rules?id=${v}`);A!=null&&A.success&&ia()}catch{}}async function Eo(v){try{await Gt("/api/db/user-rules",{id:v.id,enabled:!v.enabled}),ia()}catch{}}const Os=b.useCallback(async()=>{$e(!0);try{const v=await Pe("/api/db/vip-members?limit=500");if(v!=null&&v.success&&v.data){const A=[...v.data].map((B,ue)=>({...B,vipSort:typeof B.vipSort=="number"?B.vipSort:ue+1}));A.sort((B,ue)=>(B.vipSort??999999)-(ue.vipSort??999999)),xe(A)}else v&&v.error&&se.error(v.error)}catch{se.error("加载超级个体列表失败")}finally{$e(!1)}},[]),[En,Pa]=b.useState(!1),[Ls,kt]=b.useState(null),[oa,Ln]=b.useState(""),[hr,Mo]=b.useState(!1),[Tl,Oa]=b.useState(!1),[fr,la]=b.useState(null),[Ds,Bn]=b.useState(""),[Vn,Or]=b.useState(!1),ca=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],ps=v=>{kt(v),Ln(v.vipRole||""),Pa(!0)},La=v=>{la(v),Bn((v.webhookUrl||"").trim()),Oa(!0)},Da=async v=>{const A=v.trim();if(Ls){if(!A){se.error("请选择或输入标签");return}Mo(!0);try{const B=await Gt("/api/db/users",{id:Ls.id,vipRole:A});if(!(B!=null&&B.success)){se.error((B==null?void 0:B.error)||"更新超级个体标签失败");return}se.success("已更新超级个体标签"),Pa(!1),kt(null),await Os()}catch{se.error("更新超级个体标签失败")}finally{Mo(!1)}}},_a=async()=>{if(!fr)return;const v=Ds.trim();if(v&&!/^https?:\/\//i.test(v)){se.error("Webhook 地址需以 http/https 开头");return}Or(!0);try{const A=await Gt("/api/db/vip-members/webhook",{userId:fr.id,webhookUrl:v});if(!(A!=null&&A.success)){se.error((A==null?void 0:A.error)||"保存飞书群 Webhook 失败");return}se.success(v?"已保存该超级个体的飞书群 Webhook":"已清空该超级个体的飞书群 Webhook"),Oa(!1),la(null),await Os()}catch{se.error("保存飞书群 Webhook 失败")}finally{Or(!1)}},[za,_s]=b.useState(!1),[Zs,zs]=b.useState(null),[El,Lr]=b.useState(""),[Dr,pr]=b.useState(!1),$a=v=>{zs(v),Lr(v.vipSort!=null?String(v.vipSort):""),_s(!0)},Uc=async()=>{if(!Zs)return;const v=Number(El);if(!Number.isFinite(v)){se.error("请输入有效的数字序号");return}pr(!0);try{const A=await Gt("/api/db/users",{id:Zs.id,vipSort:v});if(!(A!=null&&A.success)){se.error((A==null?void 0:A.error)||"更新排序序号失败");return}se.success("已更新排序序号"),_s(!1),zs(null),await Os()}catch{se.error("更新排序序号失败")}finally{pr(!1)}},Ml=(v,A)=>{v.dataTransfer.effectAllowed="move",v.dataTransfer.setData("text/plain",A),jt(A)},Fa=(v,A)=>{v.preventDefault(),xt!==A&&L(A)},Si=()=>{jt(null),L(null)},Ao=async(v,A)=>{v.preventDefault();const B=v.dataTransfer.getData("text/plain")||Xe;if(jt(null),L(null),!B||B===A)return;const ue=gn.find(Ge=>Ge.id===B),we=gn.find(Ge=>Ge.id===A);if(!ue||!we)return;const De=ue.vipSort??gn.findIndex(Ge=>Ge.id===B)+1,it=we.vipSort??gn.findIndex(Ge=>Ge.id===A)+1;xe(Ge=>{const vt=[...Ge],At=vt.findIndex(Wc=>Wc.id===B),dn=vt.findIndex(Wc=>Wc.id===A);if(At===-1||dn===-1)return Ge;const un=[...vt],[Al,Ap]=[un[At],un[dn]];return un[At]={...Ap,vipSort:De},un[dn]={...Al,vipSort:it},un});try{const[Ge,vt]=await Promise.all([Gt("/api/db/users",{id:B,vipSort:it}),Gt("/api/db/users",{id:A,vipSort:De})]);if(!(Ge!=null&&Ge.success)||!(vt!=null&&vt.success)){se.error((Ge==null?void 0:Ge.error)||(vt==null?void 0:vt.error)||"更新排序失败"),await Os();return}se.success("已更新排序"),await Os()}catch{se.error("更新排序失败"),await Os()}},Io=b.useCallback(async()=>{ut(!0);try{const v=await Pe("/api/db/users/journey-stats");v!=null&&v.success&&v.stats&&ft(v.stats)}catch{}finally{ut(!1)}},[]),mr=b.useCallback(async v=>{Pt(v),Js(!0);try{const A=await Pe(`/api/db/users/journey-users?stage=${v}&limit=50`);A!=null&&A.success&&A.users&&en(A.users)}catch{}finally{Js(!1)}},[]),Ro=b.useCallback(async(v,A)=>{ea(v),Er(A),dr(!0);try{const B=await Pe(`/api/db/users/tracks?userId=${v}&limit=50`);B!=null&&B.success&&B.tracks&&Ar(B.tracks)}catch{}finally{dr(!1)}},[]),[Ba,Po]=b.useState(!1),Ci=async()=>{Po(!0);try{const v=await Ct("/api/admin/shensheshou/batch-enrich",{limit:20});v!=null&&v.success?(se.success(`批量补全完成:${v.enriched} 人已补全,${v.skipped} 人跳过`),sa()):se.error((v==null?void 0:v.error)||"批量补全失败")}catch{se.error("批量补全请求失败")}finally{Po(!1)}},Ti=v=>{const A=[v.phone,v.nickname,v.avatar,v.wechatId,v.mbti,v.industry,v.region,v.position],B=A.filter(ue=>ue!=null&&ue!=="").length;return Math.round(B/A.length*100)},{leadsRows:Oo,leadsRawCount:ss,leadsDeduped:_r}=b.useMemo(()=>{const v=Ge=>(Ge||"").replace(/\D/g,"")||"",A=Ge=>{const vt=v(Ge.phone);if(vt)return`phone:${vt}`;const At=(Ge.userId||"").trim();if(At)return`user:${At}`;const dn=(Ge.wechatId||"").trim();return dn?`wechat:${dn}`:`row:${Ge.id}`},B=Xs.trim().toLowerCase();let ue=Ss;B&&(ue=Ss.filter(Ge=>[Ge.userNickname,Ge.name,Ge.phone,Ge.wechatId,Ge.personName,Ge.source,String(Ge.ckbPlanId??"")].filter(Boolean).join(" ").toLowerCase().includes(B)));const we=[...ue].sort((Ge,vt)=>{const At=Ge.createdAt?new Date(Ge.createdAt).getTime():0;return(vt.createdAt?new Date(vt.createdAt).getTime():0)-At}),De=new Set,it=[];for(const Ge of we){const vt=A(Ge);De.has(vt)||(De.add(vt),it.push(Ge))}return{leadsRows:it,leadsRawCount:ue.length,leadsDeduped:ue.length-it.length}},[Ss,Xs]);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:()=>V(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:["共 ",c," 位注册用户",Ia!==null&&s.jsxs("span",{className:"text-[#38bdac] ml-1",children:["· 在线 ",Ia," 人"]}),I&&" · RFM 排序中"]})]}),s.jsx(Oe,{className:"shrink-0 w-full max-w-md border-[#38bdac]/35 bg-[#0f2137]/90",children:s.jsxs(Le,{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:()=>F(v=>!v),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":Q,children:[s.jsx(Gh,{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:Q?"RFM · Are you good(用户价值分层)":"RFM · 点击展开说明"})]}),Q?s.jsx(ax,{className:"w-4 h-4 text-gray-400 shrink-0"}):s.jsx(vc,{className:"w-4 h-4 text-gray-400 shrink-0"})]}),s.jsx(X,{type:"button",variant:"outline",size:"sm",onClick:Cl,className:"border-[#38bdac]/50 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent shrink-0",children:I?re==="desc"?"RFM 降序":"RFM 升序":"按 RFM 排序"})]}),Q&&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:JP.map(({level:v,range:A,label:B})=>s.jsxs(Ve,{variant:"outline",className:`text-[10px] border-0 ${Pr(v)}`,children:[v," ",A," · ",B]},v))})]})]})})]}),s.jsxs(jc,{value:a,onValueChange:v=>{const A=new URLSearchParams(t);v==="users"?A.delete("tab"):A.set("tab",v),e(A)},className:"w-full",children:[s.jsxs(ul,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[s.jsxs(Qt,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[s.jsx(In,{className:"w-4 h-4"})," 用户列表"]}),s.jsxs(Qt,{value:"leads",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:()=>Ir(),children:[s.jsx(hc,{className:"w-4 h-4"})," 获客列表"]}),s.jsxs(Qt,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Io,children:[s.jsx(qr,{className:"w-4 h-4"})," 用户旅程总览"]}),s.jsxs(Qt,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:ia,children:[s.jsx(no,{className:"w-4 h-4"})," 规则配置"]}),s.jsxs(Qt,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Os,children:[s.jsx(pc,{className:"w-4 h-4"})," 超级个体列表"]})]}),s.jsxs(Yt,{value:"users",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[s.jsxs(X,{variant:"outline",onClick:Ci,disabled:Ba,className:"border-purple-500/50 text-purple-400 hover:bg-purple-500/10 bg-transparent",title:"批量调用神射手补全有手机号用户的资料",children:[Ba?s.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):s.jsx(pi,{className:"w-4 h-4 mr-2"}),"批量补全"]}),s.jsxs(X,{variant:"outline",onClick:()=>sa(!0),disabled:O,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${O?"animate-spin":""}`})," 刷新"]}),s.jsxs("select",{value:S,onChange:v=>{const A=v.target.value;E(A),f(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:I,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(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(de,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:y,onChange:v=>N(v.target.value)})]}),s.jsxs(X,{onClick:Ra,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(hc,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:T?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Fe,{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(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"用户信息"}),s.jsx(je,{className:"text-gray-400",children:"绑定信息"}),s.jsx(je,{className:"text-gray-400",children:"购买状态"}),s.jsx(je,{className:"text-gray-400",children:"分销收益"}),s.jsxs(je,{className:"text-gray-400 cursor-pointer select-none",onClick:Cl,children:[s.jsxs("div",{className:"flex items-center gap-1 group",children:[s.jsx(Gh,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:"RFM分值"}),I?re==="desc"?s.jsx(vc,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(ax,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(rg,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),I&&s.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),s.jsx(je,{className:"text-gray-400",children:"资料完善"}),s.jsx(je,{className:"text-gray-400",children:"注册时间"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(hs,{children:[i.map(v=>{var A,B,ue;return s.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[(()=>{var it;const we=Rr(v.avatar,v.mbti),De=((it=v.nickname)==null?void 0:it.charAt(0))||"?";return s.jsx("button",{type:"button",title:"点击管理 MBTI 默认头像库",onClick:()=>wt(!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:we?s.jsx("img",{src:we,className:"w-full h-full rounded-full object-cover",alt:"",onError:Ge=>{var dn;const vt=Ge.target;if(vt.style.display="none",vt.nextElementSibling)return;const At=document.createElement("span");At.textContent=De,(dn=vt.parentElement)==null||dn.appendChild(At)}}):De})})(),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",onClick:()=>{ze(v.id),ye(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left truncate max-w-[120px]",children:v.nickname}),v.isAdmin&&s.jsx(Ve,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),v.openId&&!((A=v.id)!=null&&A.startsWith("user_"))&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),s.jsxs("p",{className:"text-xs text-gray-500 font-mono truncate max-w-[140px]",title:v.id,children:[(B=v.id)==null?void 0:B.slice(0,16),(((ue=v.id)==null?void 0:ue.length)??0)>16?"…":""]})]})]})}),s.jsx(be,{children:s.jsxs("div",{className:"space-y-1",children:[v.phone&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"📱"}),s.jsx("span",{className:"text-gray-300",children:v.phone})]}),v.wechatId&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"💬"}),s.jsx("span",{className:"text-gray-300",children:v.wechatId})]}),!v.phone&&!v.wechatId&&s.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),s.jsx(be,{children:(()=>{const we=Vc(v);return we.tone==="vip"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:we.main}),we.sub&&s.jsx("p",{className:"text-[11px] text-amber-300/80",children:we.sub})]}):we.tone==="paid"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(Ve,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:we.main}),we.sub&&s.jsx("p",{className:"text-[11px] text-blue-300/80",children:we.sub})]}):s.jsx(Ve,{variant:"outline",className:"text-gray-500 border-gray-600",children:we.main})})()}),s.jsx(be,{children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(v.earnings||0)).toFixed(2)]}),parseFloat(String(v.pendingEarnings||0))>0&&s.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(v.pendingEarnings||0)).toFixed(2)]}),s.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>aa(v),role:"button",tabIndex:0,onKeyDown:we=>we.key==="Enter"&&aa(v),children:[s.jsx(In,{className:"w-3 h-3"})," 绑定",v.referralCount||0,"人"]})]})}),s.jsx(be,{children:v.rfmScore!=null&&v.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:v.rfmScore}),s.jsx(Ve,{className:`border-0 text-xs ${Pr(v.rfmLevel)}`,children:v.rfmLevel})]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"无订单"})}),s.jsx(be,{children:(()=>{const we=Ti(v),De=we>=75?"text-green-400":we>=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 ${we>=75?"bg-green-500":we>=50?"bg-yellow-500":"bg-gray-500"}`,style:{width:`${we}%`}})}),s.jsxs("span",{className:`text-xs ${De}`,children:[we,"%"]})]})})()}),s.jsx(be,{className:"text-gray-400",children:v.createdAt?new Date(v.createdAt).toLocaleDateString():"-"}),s.jsx(be,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>{ze(v.id),ye(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:s.jsx(qh,{className:"w-4 h-4"})}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>wi(v),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:s.jsx(Jt,{className:"w-4 h-4"})}),s.jsx(X,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>Hc(v.id),title:"删除",children:s.jsx(bs,{className:"w-4 h-4"})})]})})]},v.id)}),i.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),s.jsx(Ks,{page:h,totalPages:qn,total:c,pageSize:m,onPageChange:f,onPageSizeChange:v=>{g(v),f(1)}})]})})})]}),s.jsxs(Yt,{value:"leads",children:[Ps&&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:Ps}),s.jsx("button",{type:"button",className:"shrink-0 ml-2",onClick:()=>Ma(null),"aria-label":"关闭",children:"×"})]}),!pt&&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:ur})]}),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:Mt.uniqueUsers??0})]}),(Mt.sourceStats&&Mt.sourceStats.length>0?Mt.sourceStats.slice(0,2):[]).map(v=>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:["来源:",v.source]}),s.jsx("p",{className:"text-xl font-bold text-purple-400",children:v.cnt})]},v.source))]}),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(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(de,{placeholder:"搜索昵称/手机/微信/@人/来源…",value:Aa,onChange:v=>To(v.target.value),className:"pl-9 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"})]}),Mt.sourceStats&&Mt.sourceStats.length>0&&s.jsxs("select",{value:Ts,onChange:v=>{vi(v.target.value),ge(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部来源"}),Mt.sourceStats.map(v=>s.jsxs("option",{value:v.source,children:[v.source,"(",v.cnt,")"]},v.source))]}),s.jsxs("span",{className:"text-xs text-gray-500 whitespace-nowrap max-w-[min(100%,20rem)]",title:"同一页内:相同手机号或相同用户 ID(含微信侧标识)只保留最近一条",children:["本页 ",ss," 条",_r>0?` · 已合并 ${_r} 条重复`:""]})]}),s.jsxs(X,{variant:"outline",onClick:()=>Ir(),disabled:pt,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${pt?"animate-spin":""}`})," 刷新"]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:pt?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Fe,{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(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"昵称"}),s.jsx(je,{className:"text-gray-400",children:"手机号"}),s.jsx(je,{className:"text-gray-400",children:"微信号"}),s.jsx(je,{className:"text-gray-400",children:"对应 @人"}),s.jsx(je,{className:"text-gray-400",children:"获客计划"}),s.jsx(je,{className:"text-gray-400",children:"来源"}),s.jsx(je,{className:"text-gray-400",children:"时间"})]})}),s.jsxs(hs,{children:[Oo.map(v=>s.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:v.userNickname||v.name||"-"}),s.jsx(be,{className:"text-gray-300",children:v.phone||"-"}),s.jsx(be,{className:"text-gray-300",children:v.wechatId||"-"}),s.jsx(be,{className:"text-[#38bdac]",children:v.personName||"-"}),s.jsx(be,{className:"text-gray-400",children:v.ckbPlanId?`#${v.ckbPlanId}`:"-"}),s.jsx(be,{children:s.jsx(Ve,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:v.source||"未知"})}),s.jsx(be,{className:"text-gray-400",children:v.createdAt?new Date(v.createdAt).toLocaleString():"-"})]},v.id)),Oo.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:7,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(hc,{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:Xs.trim()||Ts?"当前搜索或来源筛选下没有匹配记录,可清空条件后重试。":"存客宝场景产生的手机号 / 微信留资会出现在此列表。请确认获客计划已开启,并有用户完成留资。"}),s.jsxs(X,{type:"button",variant:"outline",onClick:()=>Ir(),disabled:pt,className:"border-[#38bdac]/40 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${pt?"animate-spin":""}`}),"重新加载"]})]})})})]})]}),s.jsx(Ks,{page:ie,totalPages:Math.ceil(ur/Qe)||1,total:ur,pageSize:Qe,onPageChange:ge,onPageSizeChange:()=>{}})]})})})]}),s.jsxs(Yt,{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(X,{variant:"outline",onClick:Io,disabled:Et,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${Et?"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:tc.map((v,A)=>s.jsxs("div",{className:"relative flex flex-col items-center",children:[s.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${v.color} text-center cursor-pointer hover:opacity-80 transition-opacity ${tt===v.id?"ring-2 ring-[#38bdac]":""}`,onClick:()=>mr(v.id),title:`点击查看「${v.label}」阶段的用户`,children:[s.jsx("div",{className:"text-2xl mb-1",children:v.icon}),s.jsx("div",{className:`text-xs font-medium ${v.color.split(" ").find(B=>B.startsWith("text-"))}`,children:v.label}),Me[v.id]!==void 0&&s.jsxs("div",{className:"mt-1.5 text-xs text-gray-400",children:[s.jsx("span",{className:"font-bold text-white",children:Me[v.id]})," 人"]}),s.jsx("div",{className:"absolute -top-2.5 -left-2.5 w-5 h-5 rounded-full bg-[#0a1628] border border-gray-700 flex items-center justify-center text-[10px] text-gray-500",children:A+1})]}),As.jsxs("div",{className:"flex items-start gap-3 p-2 bg-[#0a1628] rounded",children:[s.jsx("span",{className:"text-[#38bdac] font-mono text-xs shrink-0 mt-0.5",children:v.step}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-300",children:v.action}),s.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",v.next]})]})]},v.step))})]}),s.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(qs,{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:"实时更新"})]}),Et?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Fe,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(Me).length>0?s.jsx("div",{className:"space-y-2",children:tc.map(v=>{const A=Me[v.id]||0,B=Math.max(...tc.map(we=>Me[we.id]||0),1),ue=Math.round(A/B*100);return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-gray-500 text-xs w-20 shrink-0",children:[v.icon," ",v.label]}),s.jsx("div",{className:"flex-1 h-2 bg-[#0a1628] rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac]/60 rounded-full transition-all",style:{width:`${ue}%`}})}),s.jsx("span",{className:"text-gray-400 text-xs w-10 text-right",children:A})]},v.id)})}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]}),tt&&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(In,{className:"w-4 h-4 text-[#38bdac]"}),s.jsxs("span",{className:"text-white font-medium",children:[(Ei=tc.find(v=>v.id===tt))==null?void 0:Ei.icon," ",(zr=tc.find(v=>v.id===tt))==null?void 0:zr.label," 阶段用户"]}),s.jsxs(Ve,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:[Wt.length," 人"]})]}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>Pt(null),className:"text-gray-400 hover:text-white",children:s.jsx(Yn,{className:"w-4 h-4"})})]}),ts?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Fe,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Wt.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"该阶段暂无用户"}):s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"昵称"}),s.jsx(je,{className:"text-gray-400",children:"手机号"}),s.jsx(je,{className:"text-gray-400",children:"注册时间"}),s.jsx(je,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsx(hs,{children:Wt.map(v=>s.jsxs(ct,{className:"border-gray-700/50 hover:bg-[#0a1628]",children:[s.jsx(be,{className:"text-white",children:v.nickname||"微信用户"}),s.jsx(be,{className:"text-gray-300",children:v.phone||"-"}),s.jsx(be,{className:"text-gray-400 text-xs",children:v.createdAt?new Date(v.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx(be,{className:"text-right",children:s.jsxs(X,{variant:"ghost",size:"sm",className:"text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>Ro(v.id,v.nickname||"微信用户"),children:[s.jsx(qh,{className:"w-4 h-4 mr-1"})," 行为轨迹"]})})]},v.id))})]})]}),s.jsx(Dt,{open:!!bi,onOpenChange:v=>{v||ea(null)},children:s.jsxs(Lt,{className:"sm:max-w-[600px] bg-[#0f2137] border-gray-700 text-white max-h-[80vh] overflow-y-auto",children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(qr,{className:"w-5 h-5 text-[#38bdac]"}),ta," 的行为轨迹"]})}),cr?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Mr.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"}),Mr.map((v,A)=>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:v.actionLabel}),v.module&&s.jsx(Ve,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[10px]",children:v.module})]}),(v.chapterTitle||v.target)&&s.jsx("p",{className:"text-gray-400 text-xs mt-0.5 truncate",children:v.chapterTitle||v.target}),s.jsxs("p",{className:"text-gray-600 text-[10px] mt-0.5",children:[v.timeAgo," · ",v.createdAt?new Date(v.createdAt).toLocaleString("zh-CN"):""]})]})]},v.id||A))]})]})})]}),s.jsxs(Yt,{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(X,{variant:"outline",onClick:ia,disabled:mn,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${mn?"animate-spin":""}`})," 刷新"]}),s.jsxs(X,{onClick:()=>{$n(null),cn({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),vn(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(An,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),mn?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Tt.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(qs,{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(X,{onClick:ia,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Fe,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):s.jsx("div",{className:"space-y-2",children:Tt.map(v=>{var A;return s.jsxs("div",{className:`p-3 rounded-lg border transition-all ${v.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:[s.jsxs("div",{className:"flex items-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:["#",v.sort]}),s.jsx(Jt,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),s.jsx("span",{className:"text-white font-medium text-sm truncate",children:v.title}),v.trigger&&s.jsx(Ve,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-[10px] shrink-0",children:v.trigger}),(v.triggerConditions||[]).length>0&&s.jsxs("div",{className:"flex flex-wrap gap-0.5 ml-1",children:[(v.triggerConditions||[]).slice(0,3).map(B=>{const ue=L1.find(we=>we.value===B);return s.jsx(Ve,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[9px]",children:(ue==null?void 0:ue.label)||B},B)}),(v.triggerConditions||[]).length>3&&s.jsxs("span",{className:"text-gray-500 text-[9px]",children:["+",(v.triggerConditions||[]).length-3]})]}),v.actionType&&v.actionType!=="popup"&&s.jsx(Ve,{className:"bg-amber-500/10 text-amber-400 border border-amber-500/30 text-[9px] shrink-0",children:((A=D1.find(B=>B.value===v.actionType))==null?void 0:A.label)||v.actionType})]}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-3 shrink-0",children:[s.jsx($t,{checked:v.enabled,onCheckedChange:()=>Eo(v)}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>{$n(v),cn({title:v.title,description:v.description,trigger:v.trigger,triggerConditions:v.triggerConditions||[],actionType:v.actionType||"popup",sort:v.sort,enabled:v.enabled}),vn(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10 h-7 w-7 p-0",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>ki(v.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 h-7 w-7 p-0",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]}),v.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:["(",v.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:v.description})]})]},v.id)})})]}),s.jsxs(Yt,{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(X,{variant:"outline",onClick:Os,disabled:Se,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${Se?"animate-spin":""}`})," ","刷新"]})})]}),Se?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):gn.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(pc,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400 w-12",children:"序号"}),s.jsx(je,{className:"text-gray-400",children:"成员"}),s.jsx(je,{className:"text-gray-400 min-w-40",children:"超级个体标签"}),s.jsx(je,{className:"text-gray-400 w-16 text-center",children:"头像点击"}),s.jsx(je,{className:"text-gray-400 w-16 text-center",children:"获客数"}),s.jsx(je,{className:"text-gray-400 w-20",children:"排序值"}),s.jsx(je,{className:"text-gray-400 w-36",children:"飞书群"}),s.jsx(je,{className:"text-gray-400 w-36 text-right",children:"操作"})]})}),s.jsx(hs,{children:gn.map((v,A)=>{var we;const B=Xe===v.id,ue=xt===v.id;return s.jsxs(ct,{draggable:!0,onDragStart:De=>Ml(De,v.id),onDragOver:De=>Fa(De,v.id),onDrop:De=>Ao(De,v.id),onDragEnd:Si,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${B?"opacity-60":""} ${ue?"bg-[#38bdac]/10":""}`,children:[s.jsx(be,{className:"text-gray-300",children:A+1}),s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[Rr(v.avatar,v.mbti)?s.jsx("img",{src:Rr(v.avatar,v.mbti),className:"w-8 h-8 rounded-full object-cover border border-amber-400/60",alt:"",onError:De=>{var Ge,vt;De.target.style.display="none";const it=document.createElement("div");it.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",it.textContent=((Ge=v.name)==null?void 0:Ge[0])||"创",(vt=De.target.parentElement)==null||vt.appendChild(it)}}):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:((we=v.name)==null?void 0:we[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:v.name})})]})}),s.jsx(be,{className:"text-gray-300 whitespace-nowrap",children:v.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置)"})}),s.jsx(be,{className:"text-center text-blue-400 text-xs font-mono",children:v.clickCount!=null?String(v.clickCount):"-"}),s.jsx(be,{className:"text-center text-green-400 text-xs font-mono",children:v.leadCount!=null?String(v.leadCount):"-"}),s.jsx(be,{className:"text-gray-300",children:v.vipSort??A+1}),s.jsx(be,{className:"text-xs",children:v.webhookUrl?s.jsx("span",{className:"text-[#38bdac] truncate block max-w-[180px]",title:v.webhookUrl,children:"已配置"}):s.jsx("span",{className:"text-gray-500",children:"未配置"})}),s.jsx(be,{className:"text-right text-xs text-gray-300",children:s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>ps(v),title:"设置超级个体标签",children:s.jsx(Ad,{className:"w-3.5 h-3.5"})}),s.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-[#38bdac] hover:text-[#5fe0cd]",onClick:()=>La(v),title:"编辑飞书群Webhook",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),s.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>$a(v),title:"设置排序序号",children:s.jsx(rg,{className:"w-3.5 h-3.5"})})]})})]},v.id)})})]})})})]})]}),s.jsx(Dt,{open:ht,onOpenChange:wt,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-6xl",children:[s.jsx(_t,{children:s.jsx(zt,{className:"text-white",children:"MBTI 默认头像库"})}),s.jsx(GP,{})]})}),s.jsx(Dt,{open:za,onOpenChange:v=>{_s(v),v||zs(null)},children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(rg,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",Zs==null?void 0:Zs.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),s.jsx(de,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:El,onChange:v=>Lr(v.target.value)})]}),s.jsxs(fn,{children:[s.jsxs(X,{variant:"outline",onClick:()=>_s(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(X,{onClick:Uc,disabled:Dr,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),Dr?"保存中...":"保存"]})]})]})}),s.jsx(Dt,{open:En,onOpenChange:v=>{Pa(v),v||kt(null)},children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(pc,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",Ls==null?void 0:Ls.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:ca.map(v=>s.jsx(X,{variant:oa===v?"default":"outline",size:"sm",className:oa===v?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>Ln(v),children:v},v))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"或手动输入"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:oa,onChange:v=>Ln(v.target.value)})]})]}),s.jsxs(fn,{children:[s.jsxs(X,{variant:"outline",onClick:()=>Pa(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(X,{onClick:()=>Da(oa),disabled:hr,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),hr?"保存中...":"保存"]})]})]})}),s.jsx(Dt,{open:Tl,onOpenChange:v=>{Oa(v),v||la(null)},children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-xl",children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(Jt,{className:"w-5 h-5 text-[#38bdac]"}),"设置飞书群 Webhook — ",fr==null?void 0:fr.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"VOX Webhook 地址(留空即清空)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",value:Ds,onChange:v=>Bn(v.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"当用户点击该超级个体头像并提交链接时,线索将优先推送到这里配置的飞书群。"})]}),s.jsxs(fn,{children:[s.jsxs(X,{variant:"outline",onClick:()=>Oa(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(X,{onClick:_a,disabled:Vn,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),Vn?"保存中...":"保存"]})]})]})}),s.jsx(Dt,{open:J,onOpenChange:$,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[D?s.jsx(Jt,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(hc,{className:"w-5 h-5 text-[#38bdac]"}),D?"编辑用户":"添加用户"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"手机号"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:dt.phone,onChange:v=>Rt({...dt,phone:v.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"昵称"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:dt.nickname,onChange:v=>Rt({...dt,nickname:v.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:D?"新密码 (留空则不修改)":"密码"}),s.jsx(de,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:D?"留空则不修改":"请输入密码",value:dt.password,onChange:v=>Rt({...dt,password:v.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(ee,{className:"text-gray-300",children:"管理员权限"}),s.jsx($t,{checked:dt.isAdmin,onCheckedChange:v=>Rt({...dt,isAdmin:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(ee,{className:"text-gray-300",children:"已购全书"}),s.jsx($t,{checked:dt.hasFullBook,onCheckedChange:v=>Rt({...dt,hasFullBook:v})})]})]}),s.jsxs(fn,{children:[s.jsxs(X,{variant:"outline",onClick:()=>$(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(X,{onClick:ra,disabled:oe,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),oe?"保存中...":"保存"]})]})]})}),s.jsx(Dt,{open:qt,onOpenChange:vn,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[90vh] overflow-y-auto",children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(Jt,{className:"w-5 h-5 text-[#38bdac]"}),On?"编辑规则":"添加规则"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"规则标题 *"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:St.title,onChange:v=>cn({...St,title:v.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"规则描述"}),s.jsx(hl,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[60px] resize-none",placeholder:"弹窗内容/推送文案...",value:St.description,onChange:v=>cn({...St,description:v.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"触发条件(可多选)"}),s.jsx("div",{className:"space-y-2",children:["用户状态","阅读行为","付费行为","社交行为","分销行为"].map(v=>{const A=L1.filter(B=>B.group===v);return A.length===0?null:s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-gray-500 mb-1",children:v}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:A.map(B=>{const ue=(St.triggerConditions||[]).includes(B.value);return s.jsx("button",{type:"button",className:`px-2.5 py-1 rounded-md text-xs border transition-colors ${ue?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-[#0a1628] border-gray-700 text-gray-400 hover:border-gray-500"}`,onClick:()=>{const we=St.triggerConditions||[],De=ue?we.filter(it=>it!==B.value):[...we,B.value];cn({...St,triggerConditions:De})},children:B.label},B.value)})})]},v)})}),(St.triggerConditions||[]).length>0&&s.jsxs("p",{className:"text-[10px] text-[#38bdac]",children:["已选 ",(St.triggerConditions||[]).length," 个触发条件(满足任一即触发)"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"兼容触发标识(旧版)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white text-xs h-8",placeholder:"例:after_login、after_pay(兼容现有小程序 ruleEngine)",value:St.trigger,onChange:v=>cn({...St,trigger:v.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"推送动作"}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:D1.map(v=>s.jsxs("button",{type:"button",className:`p-2 rounded-lg border text-left transition-colors ${St.actionType===v.value?"bg-[#38bdac]/15 border-[#38bdac]/50":"bg-[#0a1628] border-gray-700 hover:border-gray-500"}`,onClick:()=>cn({...St,actionType:v.value}),children:[s.jsx("span",{className:`text-xs font-medium ${St.actionType===v.value?"text-[#38bdac]":"text-gray-300"}`,children:v.label}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5",children:v.desc})]},v.value))})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{children:s.jsx(ee,{className:"text-gray-300",children:"启用状态"})}),s.jsx($t,{checked:St.enabled,onCheckedChange:v=>cn({...St,enabled:v})})]})]}),s.jsxs(fn,{children:[s.jsxs(X,{variant:"outline",onClick:()=>vn(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(X,{onClick:ji,disabled:oe,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),oe?"保存中...":"保存"]})]})]})}),s.jsx(Dt,{open:_,onOpenChange:U,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(In,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",le==null?void 0:le.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:((Mi=H.stats)==null?void 0:Mi.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:((Va=H.stats)==null?void 0:Va.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:["¥",(((Ha=H.stats)==null?void 0:Ha.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:["¥",((($r=H.stats)==null?void 0:$r.pendingEarnings)||0).toFixed(2)]}),s.jsx("div",{className:"text-xs text-gray-400",children:"待提现"})]})]}),me?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Fe,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((da=H.referrals)==null?void 0:da.length)??0)>0?s.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(H.referrals??[]).map((v,A)=>{var ue;const B=v;return s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:((ue=B.nickname)==null?void 0:ue.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white text-sm",children:B.nickname}),s.jsx("div",{className:"text-xs text-gray-500",children:B.phone||(B.hasOpenId?"微信用户":"未绑定")})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[B.status==="vip"&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),B.status==="paid"&&s.jsxs(Ve,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",B.purchasedSections,"章"]}),B.status==="free"&&s.jsx(Ve,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),s.jsx("span",{className:"text-xs text-gray-500",children:B.createdAt?new Date(B.createdAt).toLocaleDateString():""})]})]},B.id||A)})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),s.jsx(fn,{children:s.jsx(X,{variant:"outline",onClick:()=>U(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),s.jsx(I0,{open:ve,onClose:()=>ye(!1),userId:ke,onUserUpdated:sa})]})}function tf(t,[e,n]){return Math.min(n,Math.max(e,t))}var Zk=["PageUp","PageDown"],e2=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],t2={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Dc="Slider",[gx,YP,XP]=T0(Dc),[n2]=No(Dc,[XP]),[ZP,ip]=n2(Dc),s2=b.forwardRef((t,e)=>{const{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:u=0,defaultValue:h=[r],value:f,onValueChange:m=()=>{},onValueCommit:g=()=>{},inverted:y=!1,form:N,...w}=t,j=b.useRef(new Set),S=b.useRef(0),T=o==="horizontal"?e8:t8,[P=[],O]=cl({prop:f,defaultProp:h,onChange:Q=>{var re;(re=[...j.current][S.current])==null||re.focus(),m(Q)}}),q=b.useRef(P);function z(Q){const F=i8(P,Q);te(Q,F)}function V(Q){te(Q,S.current)}function I(){const Q=q.current[S.current];P[S.current]!==Q&&g(P)}function te(Q,F,{commit:re}={commit:!1}){const ae=d8(i),J=u8(Math.round((Q-r)/i)*i+r,ae),$=tf(J,[r,a]);O((D=[])=>{const R=r8(D,$,F);if(c8(R,u*i)){S.current=R.indexOf($);const oe=String(R)!==String(D);return oe&&re&&g(R),oe?R:D}else return D})}return s.jsx(ZP,{scope:t.__scopeSlider,name:n,disabled:c,min:r,max:a,valueIndexToChangeRef:S,thumbs:j.current,values:P,orientation:o,form:N,children:s.jsx(gx.Provider,{scope:t.__scopeSlider,children:s.jsx(gx.Slot,{scope:t.__scopeSlider,children:s.jsx(T,{"aria-disabled":c,"data-disabled":c?"":void 0,...w,ref:e,onPointerDown:mt(w.onPointerDown,()=>{c||(q.current=P)}),min:r,max:a,inverted:y,onSlideStart:c?void 0:z,onSlideMove:c?void 0:V,onSlideEnd:c?void 0:I,onHomeKeyDown:()=>!c&&te(r,0,{commit:!0}),onEndKeyDown:()=>!c&&te(a,P.length-1,{commit:!0}),onStepKeyDown:({event:Q,direction:F})=>{if(!c){const J=Zk.includes(Q.key)||Q.shiftKey&&e2.includes(Q.key)?10:1,$=S.current,D=P[$],R=i*J*F;te(D+R,$,{commit:!0})}}})})})})});s2.displayName=Dc;var[r2,a2]=n2(Dc,{startEdge:"left",endEdge:"right",size:"width",direction:1}),e8=b.forwardRef((t,e)=>{const{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,g]=b.useState(null),y=Ht(e,T=>g(T)),N=b.useRef(void 0),w=sp(a),j=w==="ltr",S=j&&!i||!j&&i;function E(T){const P=N.current||m.getBoundingClientRect(),O=[0,P.width],z=R0(O,S?[n,r]:[r,n]);return N.current=P,z(T-P.left)}return s.jsx(r2,{scope:t.__scopeSlider,startEdge:S?"left":"right",endEdge:S?"right":"left",direction:S?1:-1,size:"width",children:s.jsx(i2,{dir:w,"data-orientation":"horizontal",...f,ref:y,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:T=>{const P=E(T.clientX);o==null||o(P)},onSlideMove:T=>{const P=E(T.clientX);c==null||c(P)},onSlideEnd:()=>{N.current=void 0,u==null||u()},onStepKeyDown:T=>{const O=t2[S?"from-left":"from-right"].includes(T.key);h==null||h({event:T,direction:O?-1:1})}})})}),t8=b.forwardRef((t,e)=>{const{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=b.useRef(null),m=Ht(e,f),g=b.useRef(void 0),y=!a;function N(w){const j=g.current||f.current.getBoundingClientRect(),S=[0,j.height],T=R0(S,y?[r,n]:[n,r]);return g.current=j,T(w-j.top)}return s.jsx(r2,{scope:t.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:s.jsx(i2,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const j=N(w.clientY);i==null||i(j)},onSlideMove:w=>{const j=N(w.clientY);o==null||o(j)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:w=>{const S=t2[y?"from-bottom":"from-top"].includes(w.key);u==null||u({event:w,direction:S?-1:1})}})})}),i2=b.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=ip(Dc,n);return s.jsx(bt.span,{...h,ref:e,onKeyDown:mt(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):Zk.concat(e2).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:mt(t.onPointerDown,m=>{const g=m.target;g.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(g)?g.focus():r(m)}),onPointerMove:mt(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&a(m)}),onPointerUp:mt(t.onPointerUp,m=>{const g=m.target;g.hasPointerCapture(m.pointerId)&&(g.releasePointerCapture(m.pointerId),i(m))})})}),o2="SliderTrack",l2=b.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=ip(o2,n);return s.jsx(bt.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:e})});l2.displayName=o2;var xx="SliderRange",c2=b.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=ip(xx,n),i=a2(xx,n),o=b.useRef(null),c=Ht(e,o),u=a.values.length,h=a.values.map(g=>h2(g,a.min,a.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return s.jsx(bt.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:c,style:{...t.style,[i.startEdge]:f+"%",[i.endEdge]:m+"%"}})});c2.displayName=xx;var yx="SliderThumb",d2=b.forwardRef((t,e)=>{const n=YP(t.__scopeSlider),[r,a]=b.useState(null),i=Ht(e,c=>a(c)),o=b.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(n8,{...t,ref:i,index:o})}),n8=b.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:a,...i}=t,o=ip(yx,n),c=a2(yx,n),[u,h]=b.useState(null),f=Ht(e,E=>h(E)),m=u?o.form||!!u.closest("form"):!0,g=A0(u),y=o.values[r],N=y===void 0?0:h2(y,o.min,o.max),w=a8(r,o.values.length),j=g==null?void 0:g[c.size],S=j?o8(j,N,c.direction):0;return b.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),s.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${N}% + ${S}px)`},children:[s.jsx(gx.ItemSlot,{scope:t.__scopeSlider,children:s.jsx(bt.span,{role:"slider","aria-label":t["aria-label"]||w,"aria-valuemin":o.min,"aria-valuenow":y,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:f,style:y===void 0?{display:"none"}:t.style,onFocus:mt(t.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),m&&s.jsx(u2,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:y},r)]})});d2.displayName=yx;var s8="RadioBubbleInput",u2=b.forwardRef(({__scopeSlider:t,value:e,...n},r)=>{const a=b.useRef(null),i=Ht(a,r),o=M0(e);return b.useEffect(()=>{const c=a.current;if(!c)return;const u=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==e&&f){const m=new Event("input",{bubbles:!0});f.call(c,e),c.dispatchEvent(m)}},[o,e]),s.jsx(bt.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});u2.displayName=s8;function r8(t=[],e,n){const r=[...t];return r[n]=e,r.sort((a,i)=>a-i)}function h2(t,e,n){const i=100/(n-e)*(t-e);return tf(i,[0,100])}function a8(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function i8(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 o8(t,e,n){const r=t/2,i=R0([0,50],[0,r]);return(r-i(e)*n)*n}function l8(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function c8(t,e){if(e>0){const n=l8(t);return Math.min(...n)>=e}return!0}function R0(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 d8(t){return(String(t).split(".")[1]||"").length}function u8(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var h8=s2,f8=l2,p8=c2,m8=d2;function g8({className:t,defaultValue:e,value:n,min:r=0,max:a=100,...i}){const o=b.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[r,a],[n,e,r,a]);return s.jsxs(h8,{defaultValue:e,value:n,min:r,max:a,className:Ut("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(p8,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>s.jsx(m8,{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 x8={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,withdrawFee:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function f2(t){const e=!!(t!=null&&t.embedded),[n,r]=b.useState(x8),[a,i]=b.useState(!0),[o,c]=b.useState(!1);b.useEffect(()=>{Pe("/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 Ct("/api/admin/referral-settings",f);if(!m||m.success===!1){se.error("保存失败: "+(m&&typeof m=="object"&&"error"in m?m.error:""));return}se.success(`✅ 分销配置已保存成功! +`;return`data:image/svg+xml;utf8,${encodeURIComponent(i)}`}function GP(){const[t,e]=b.useState({}),[n,r]=b.useState(!0),[a,i]=b.useState(!1),[o,c]=b.useState(!1),u=b.useCallback(async()=>{r(!0);try{const x=await Pe("/api/admin/mbti-avatars");x!=null&&x.avatars?e(x.avatars):e({})}catch{se.error("加载 MBTI 头像配置失败")}finally{r(!1)}},[]);b.useEffect(()=>{u()},[u]);const h=async()=>{i(!0);try{const x=await Ct("/api/admin/mbti-avatars",{avatars:t});if(!x||x.success===!1){se.error((x==null?void 0:x.error)||"保存失败");return}se.success("已保存,后台与小程序默认头像同步生效"),u()}catch{se.error("保存失败")}finally{i(!1)}},f=x=>{const y=O1(x);e(N=>({...N,[x]:y})),se.success(`${x} 已生成`)},m=()=>{c(!0);try{const x={...t};P1.forEach(y=>{x[y]=O1(y)}),e(x),se.success("16 型头像已生成(仅人物)")}finally{c(!1)}};return n?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-400",children:[s.jsx(Fe,{className:"w-5 h-5 mr-2 animate-spin text-[#38bdac]"}),"加载配置…"]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-[#38bdac]/25 shadow-xl",children:[s.jsxs(rt,{className:"pb-2",children:[s.jsxs(at,{className:"text-white flex items-center gap-2 text-lg",children:[s.jsx(tA,{className:"w-5 h-5 text-[#38bdac]"}),"MBTI 头像库"]}),s.jsx(Kt,{className:"text-gray-400 text-sm leading-relaxed",children:"采用人物化风格,按 MBTI 性格自动生成。头像内不显示中英文,仅显示人物形象,颜色与站点主题融合。"})]}),s.jsxs(Le,{className:"flex flex-wrap gap-2",children:[s.jsxs(X,{type:"button",size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396]",onClick:m,disabled:o,children:[s.jsx(kA,{className:"w-3.5 h-3.5 mr-1"}),o?"生成中…":"一键生成16头像"]}),s.jsxs(X,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-300",onClick:u,children:[s.jsx(Fe,{className:"w-3.5 h-3.5 mr-1"}),"重新加载"]}),s.jsxs(X,{type:"button",size:"sm",className:"bg-emerald-600 hover:bg-emerald-500",onClick:h,disabled:a,children:[s.jsx(bn,{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:P1.map(x=>{const y=t[x]??"",N=Xk[x];return s.jsxs("div",{className:"rounded-xl border border-gray-700/60 bg-[#0a1628] p-3 flex flex-col gap-2 hover:border-[#38bdac]/35 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 font-mono text-xs",children:x}),s.jsx("span",{className:"text-xs text-gray-400 truncate",title:N.title,children:N.title})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-16 h-16 rounded-full shrink-0 overflow-hidden flex items-center justify-center bg-[#081322] ring-2 ring-[#38bdac]/40 ring-offset-2 ring-offset-[#0a1628]",children:y?s.jsx("img",{src:y,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(ce,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"https://... 或 data:image/...",value:y,onChange:w=>e(j=>({...j,[x]:w.target.value}))})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(X,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-[#38bdac]/40 text-[#38bdac]",onClick:()=>f(x),children:"生成这张"}),s.jsx(X,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-[11px] text-gray-400",onClick:()=>e(w=>({...w,[x]:""})),children:"清空"})]})]},x)})})]})}const L1=[{value:"after_login",label:"注册/登录成功",group:"用户状态"},{value:"bind_phone",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:"用户状态"}],D1=[{value:"popup",label:"弹窗提示",desc:"在小程序内弹窗引导用户完成下一步"},{value:"navigate",label:"跳转页面",desc:"引导用户跳转到指定页面"},{value:"webhook",label:"推送飞书群",desc:"触发后推送消息到飞书群Webhook"},{value:"tag",label:"自动打标签",desc:"触发后自动给用户打上指定标签"}],JP=[{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:"待激活"}],tc=[{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 _1(t){return confirm(`确定删除该${t}?此操作不可恢复。`)?window.prompt(`请输入「删除」以确认删除${t}`)==="删除":!1}function QP(){var Ei,zr,Mi,Va,Ha,$r,da;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,o]=b.useState([]),[c,u]=b.useState(0),[h,f]=b.useState(1),[m,x]=b.useState(10),[y,N]=b.useState(""),w=ef(y,300),j=n==="vip"?"vip":n==="complete"?"complete":"all",[S,E]=b.useState(j),[T,P]=b.useState(!0),[O,q]=b.useState(!1),[z,V]=b.useState(null),[I,te]=b.useState(!1),[Q,F]=b.useState(!1),[re,ie]=b.useState("desc");b.useEffect(()=>{n==="vip"?E("vip"):n==="complete"?E("complete"):n==="all"&&E("all")},[n]);const[J,$]=b.useState(!1),[D,R]=b.useState(null),[oe,G]=b.useState(!1),[_,U]=b.useState(!1),[H,K]=b.useState({referrals:[],stats:{}}),[me,Y]=b.useState(!1),[le,de]=b.useState(null),[ve,ye]=b.useState(!1),[ke,ze]=b.useState(null),[ft,wt]=b.useState(!1),[dt,Rt]=b.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[Tt,Tn]=b.useState([]),[mn,Ft]=b.useState(!1),[qt,vn]=b.useState(!1),[On,$n]=b.useState(null),[St,cn]=b.useState({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),[xn,ge]=b.useState([]),[Se,$e]=b.useState(!1),[Xe,jt]=b.useState(null),[gt,L]=b.useState(null),[Me,pt]=b.useState({}),[Et,ht]=b.useState(!1),[tt,Pt]=b.useState(null),[Wt,en]=b.useState([]),[ts,Qs]=b.useState(!1),[bi,ea]=b.useState(null),[ta,Er]=b.useState(""),[Mr,Ar]=b.useState([]),[cr,dr]=b.useState(!1),[Ea,Ys]=b.useState({}),[Ss,Xs]=b.useState([]),[ur,Cs]=b.useState(0),[ae,xe]=b.useState(1),[Ue]=b.useState(20),[ut,Fn]=b.useState(!1),[Ps,Ma]=b.useState(null),[Aa,To]=b.useState(""),Zs=ef(Aa,300),[Ts,vi]=b.useState(""),[Mt,Bc]=b.useState({}),Ir=b.useCallback(async(v,A)=>{Fn(!0),Ma(null);try{const B=new URLSearchParams({mode:"contact",page:String(ae),pageSize:String(Ue)}),ue=v??Zs;ue&&B.set("search",ue);const we=A??Ts;we&&B.set("source",we);const De=await Pe(`/api/db/ckb-leads?${B}`);if(De!=null&&De.success)Xs(De.records||[]),Cs(De.total??0),De.stats&&Bc(De.stats);else{const it=(De==null?void 0:De.error)||"加载获客列表失败";Ma(it),se.error(it),Xs([]),Cs(0)}}catch(B){const ue=B instanceof Error?B.message:"网络错误";Ma(ue),se.error("加载获客列表失败: "+ue),Xs([]),Cs(0)}finally{Fn(!1)}},[ae,Ue,Zs,Ts]),Ni=b.useCallback(async()=>{try{const v=await Pe("/api/admin/mbti-avatars"),A=v!=null&&v.avatars&&typeof v.avatars=="object"?v.avatars:{};Ys(A)}catch{Ys({})}},[]);b.useEffect(()=>{t.get("tab")==="leads"&&Ir()},[t.get("tab"),ae,Ir]),b.useEffect(()=>{Ni()},[Ni]);const Rr=b.useCallback((v,A)=>{const B=(v||"").trim();if(B)return B;const ue=(A||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(ue)?(Ea[ue]||"").trim():""},[Ea]),Vc=b.useCallback(v=>{const A=!!v.hasFullBook,B=Number(v.purchasedSectionCount||0);return A?{tone:"vip",main:"已购全书",sub:B>0?`另购单章 ${B} 章`:"购买项:VIP / 全书"}:B>0?{tone:"paid",main:`已购 ${B} 章`,sub:"购买项:章节"}:{tone:"free",main:"未购买",sub:""}},[]),[Ia,na]=b.useState(null),ns=b.useCallback(async()=>{try{const v=await Pe("/api/admin/users/online-stats");v!=null&&v.success&&typeof v.onlineCount=="number"?na(v.onlineCount):na(0)}catch{na(null)}},[]);b.useEffect(()=>{ns();const v=setInterval(ns,1e4);return()=>clearInterval(v)},[ns]);async function sa(v=!1){var A;P(!0),v&&q(!0),V(null);try{if(I){const B=new URLSearchParams({search:w,limit:String(m*5)}),ue=await Pe(`/api/db/users/rfm?${B}`);if(ue!=null&&ue.success){let we=ue.users||[];re==="asc"&&(we=[...we].reverse());const De=(h-1)*m;o(we.slice(De,De+m)),u(((A=ue.users)==null?void 0:A.length)??0),we.length===0&&(te(!1),V("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else te(!1),V((ue==null?void 0:ue.error)||"RFM 加载失败,已切回普通模式")}else{const B=new URLSearchParams({page:String(h),pageSize:String(m),search:w,...S==="vip"&&{vip:"true"},...S==="complete"&&{pool:"complete"}}),ue=await Pe(`/api/db/users?${B}`);ue!=null&&ue.success?(o(ue.users||[]),u(ue.total??0)):V((ue==null?void 0:ue.error)||"加载失败")}}catch(B){console.error("Load users error:",B),V("网络错误")}finally{P(!1),v&&q(!1)}}b.useEffect(()=>{f(1)},[w,S,I]),b.useEffect(()=>{sa()},[h,m,w,S,I,re]);const qn=Math.ceil(c/m)||1,Cl=()=>{I?re==="desc"?ie("asc"):(te(!1),ie("desc")):(te(!0),ie("desc"))},Pr=v=>({S:"bg-amber-500/20 text-amber-400",A:"bg-green-500/20 text-green-400",B:"bg-blue-500/20 text-blue-400",C:"bg-gray-500/20 text-gray-400",D:"bg-red-500/20 text-red-400"})[v||""]||"bg-gray-500/20 text-gray-400";async function Hc(v){var A;if(!_1("用户")){se.info("已取消删除");return}try{const B=await li(`/api/db/users?id=${encodeURIComponent(v)}`);B!=null&&B.success?(se.success("已删除"),sa()):se.error("删除失败: "+((B==null?void 0:B.error)||"未知错误"))}catch(B){const ue=B,we=((A=ue==null?void 0:ue.data)==null?void 0:A.error)||(ue==null?void 0:ue.message)||"网络错误";se.error("删除失败: "+we)}}const wi=v=>{R(v),Rt({phone:v.phone||"",nickname:v.nickname||"",password:"",isAdmin:!!(v.isAdmin??!1),hasFullBook:!!(v.hasFullBook??!1)}),$(!0)},Ra=()=>{R(null),Rt({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),$(!0)};async function ra(){if(!dt.phone||!dt.nickname){se.error("请填写手机号和昵称");return}G(!0);try{if(D){const v=await Gt("/api/db/users",{id:D.id,phone:dt.phone||void 0,nickname:dt.nickname,isAdmin:dt.isAdmin,hasFullBook:dt.hasFullBook,...dt.password&&{password:dt.password}});if(!(v!=null&&v.success)){se.error("更新失败: "+((v==null?void 0:v.error)||""));return}}else{const v=await Ct("/api/db/users",{phone:dt.phone,nickname:dt.nickname,password:dt.password,isAdmin:dt.isAdmin});if(!(v!=null&&v.success)){se.error("创建失败: "+((v==null?void 0:v.error)||""));return}}$(!1),sa()}catch{se.error("保存失败")}finally{G(!1)}}async function aa(v){de(v),U(!0),Y(!0);try{const A=await Pe(`/api/db/users/referrals?userId=${encodeURIComponent(v.id)}`);A!=null&&A.success?K({referrals:A.referrals||[],stats:A.stats||{}}):K({referrals:[],stats:{}})}catch{K({referrals:[],stats:{}})}finally{Y(!1)}}const ia=b.useCallback(async()=>{Ft(!0);try{const v=await Pe("/api/db/user-rules");v!=null&&v.success&&Tn(v.rules||[])}catch{}finally{Ft(!1)}},[]);async function ji(){if(!St.title){se.error("请填写规则标题");return}G(!0);try{if(On){const v=await Gt("/api/db/user-rules",{id:On.id,...St});if(!(v!=null&&v.success)){se.error("更新失败: "+((v==null?void 0:v.error)||""));return}}else{const v=await Ct("/api/db/user-rules",St);if(!(v!=null&&v.success)){se.error("创建失败: "+((v==null?void 0:v.error)||""));return}}vn(!1),ia()}catch{se.error("保存失败")}finally{G(!1)}}async function ki(v){if(!_1("规则")){se.info("已取消删除");return}try{const A=await li(`/api/db/user-rules?id=${v}`);A!=null&&A.success&&ia()}catch{}}async function Eo(v){try{await Gt("/api/db/user-rules",{id:v.id,enabled:!v.enabled}),ia()}catch{}}const Os=b.useCallback(async()=>{$e(!0);try{const v=await Pe("/api/db/vip-members?limit=500");if(v!=null&&v.success&&v.data){const A=[...v.data].map((B,ue)=>({...B,vipSort:typeof B.vipSort=="number"?B.vipSort:ue+1}));A.sort((B,ue)=>(B.vipSort??999999)-(ue.vipSort??999999)),ge(A)}else v&&v.error&&se.error(v.error)}catch{se.error("加载超级个体列表失败")}finally{$e(!1)}},[]),[En,Pa]=b.useState(!1),[Ls,kt]=b.useState(null),[oa,Ln]=b.useState(""),[hr,Mo]=b.useState(!1),[Tl,Oa]=b.useState(!1),[fr,la]=b.useState(null),[Ds,Bn]=b.useState(""),[Vn,Or]=b.useState(!1),ca=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],ps=v=>{kt(v),Ln(v.vipRole||""),Pa(!0)},La=v=>{la(v),Bn((v.webhookUrl||"").trim()),Oa(!0)},Da=async v=>{const A=v.trim();if(Ls){if(!A){se.error("请选择或输入标签");return}Mo(!0);try{const B=await Gt("/api/db/users",{id:Ls.id,vipRole:A});if(!(B!=null&&B.success)){se.error((B==null?void 0:B.error)||"更新超级个体标签失败");return}se.success("已更新超级个体标签"),Pa(!1),kt(null),await Os()}catch{se.error("更新超级个体标签失败")}finally{Mo(!1)}}},_a=async()=>{if(!fr)return;const v=Ds.trim();if(v&&!/^https?:\/\//i.test(v)){se.error("Webhook 地址需以 http/https 开头");return}Or(!0);try{const A=await Gt("/api/db/vip-members/webhook",{userId:fr.id,webhookUrl:v});if(!(A!=null&&A.success)){se.error((A==null?void 0:A.error)||"保存飞书群 Webhook 失败");return}se.success(v?"已保存该超级个体的飞书群 Webhook":"已清空该超级个体的飞书群 Webhook"),Oa(!1),la(null),await Os()}catch{se.error("保存飞书群 Webhook 失败")}finally{Or(!1)}},[za,_s]=b.useState(!1),[er,zs]=b.useState(null),[El,Lr]=b.useState(""),[Dr,pr]=b.useState(!1),$a=v=>{zs(v),Lr(v.vipSort!=null?String(v.vipSort):""),_s(!0)},Uc=async()=>{if(!er)return;const v=Number(El);if(!Number.isFinite(v)){se.error("请输入有效的数字序号");return}pr(!0);try{const A=await Gt("/api/db/users",{id:er.id,vipSort:v});if(!(A!=null&&A.success)){se.error((A==null?void 0:A.error)||"更新排序序号失败");return}se.success("已更新排序序号"),_s(!1),zs(null),await Os()}catch{se.error("更新排序序号失败")}finally{pr(!1)}},Ml=(v,A)=>{v.dataTransfer.effectAllowed="move",v.dataTransfer.setData("text/plain",A),jt(A)},Fa=(v,A)=>{v.preventDefault(),gt!==A&&L(A)},Si=()=>{jt(null),L(null)},Ao=async(v,A)=>{v.preventDefault();const B=v.dataTransfer.getData("text/plain")||Xe;if(jt(null),L(null),!B||B===A)return;const ue=xn.find(Je=>Je.id===B),we=xn.find(Je=>Je.id===A);if(!ue||!we)return;const De=ue.vipSort??xn.findIndex(Je=>Je.id===B)+1,it=we.vipSort??xn.findIndex(Je=>Je.id===A)+1;ge(Je=>{const vt=[...Je],At=vt.findIndex(Wc=>Wc.id===B),dn=vt.findIndex(Wc=>Wc.id===A);if(At===-1||dn===-1)return Je;const un=[...vt],[Al,Ap]=[un[At],un[dn]];return un[At]={...Ap,vipSort:De},un[dn]={...Al,vipSort:it},un});try{const[Je,vt]=await Promise.all([Gt("/api/db/users",{id:B,vipSort:it}),Gt("/api/db/users",{id:A,vipSort:De})]);if(!(Je!=null&&Je.success)||!(vt!=null&&vt.success)){se.error((Je==null?void 0:Je.error)||(vt==null?void 0:vt.error)||"更新排序失败"),await Os();return}se.success("已更新排序"),await Os()}catch{se.error("更新排序失败"),await Os()}},Io=b.useCallback(async()=>{ht(!0);try{const v=await Pe("/api/db/users/journey-stats");v!=null&&v.success&&v.stats&&pt(v.stats)}catch{}finally{ht(!1)}},[]),mr=b.useCallback(async v=>{Pt(v),Qs(!0);try{const A=await Pe(`/api/db/users/journey-users?stage=${v}&limit=50`);A!=null&&A.success&&A.users&&en(A.users)}catch{}finally{Qs(!1)}},[]),Ro=b.useCallback(async(v,A)=>{ea(v),Er(A),dr(!0);try{const B=await Pe(`/api/db/users/tracks?userId=${v}&limit=50`);B!=null&&B.success&&B.tracks&&Ar(B.tracks)}catch{}finally{dr(!1)}},[]),[Ba,Po]=b.useState(!1),Ci=async()=>{Po(!0);try{const v=await Ct("/api/admin/shensheshou/batch-enrich",{limit:20});v!=null&&v.success?(se.success(`批量补全完成:${v.enriched} 人已补全,${v.skipped} 人跳过`),sa()):se.error((v==null?void 0:v.error)||"批量补全失败")}catch{se.error("批量补全请求失败")}finally{Po(!1)}},Ti=v=>{const A=[v.phone,v.nickname,v.avatar,v.wechatId,v.mbti,v.industry,v.region,v.position],B=A.filter(ue=>ue!=null&&ue!=="").length;return Math.round(B/A.length*100)},{leadsRows:Oo,leadsRawCount:ss,leadsDeduped:_r}=b.useMemo(()=>{const v=Je=>(Je||"").replace(/\D/g,"")||"",A=Je=>{const vt=v(Je.phone);if(vt)return`phone:${vt}`;const At=(Je.userId||"").trim();if(At)return`user:${At}`;const dn=(Je.wechatId||"").trim();return dn?`wechat:${dn}`:`row:${Je.id}`},B=Zs.trim().toLowerCase();let ue=Ss;B&&(ue=Ss.filter(Je=>[Je.userNickname,Je.name,Je.phone,Je.wechatId,Je.personName,Je.source,String(Je.ckbPlanId??"")].filter(Boolean).join(" ").toLowerCase().includes(B)));const we=[...ue].sort((Je,vt)=>{const At=Je.createdAt?new Date(Je.createdAt).getTime():0;return(vt.createdAt?new Date(vt.createdAt).getTime():0)-At}),De=new Set,it=[];for(const Je of we){const vt=A(Je);De.has(vt)||(De.add(vt),it.push(Je))}return{leadsRows:it,leadsRawCount:ue.length,leadsDeduped:ue.length-it.length}},[Ss,Zs]);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:()=>V(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:["共 ",c," 位注册用户",Ia!==null&&s.jsxs("span",{className:"text-[#38bdac] ml-1",children:["· 在线 ",Ia," 人"]}),I&&" · RFM 排序中"]})]}),s.jsx(Oe,{className:"shrink-0 w-full max-w-md border-[#38bdac]/35 bg-[#0f2137]/90",children:s.jsxs(Le,{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:()=>F(v=>!v),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":Q,children:[s.jsx(Gh,{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:Q?"RFM · Are you good(用户价值分层)":"RFM · 点击展开说明"})]}),Q?s.jsx(ag,{className:"w-4 h-4 text-gray-400 shrink-0"}):s.jsx(vc,{className:"w-4 h-4 text-gray-400 shrink-0"})]}),s.jsx(X,{type:"button",variant:"outline",size:"sm",onClick:Cl,className:"border-[#38bdac]/50 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent shrink-0",children:I?re==="desc"?"RFM 降序":"RFM 升序":"按 RFM 排序"})]}),Q&&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:JP.map(({level:v,range:A,label:B})=>s.jsxs(Ve,{variant:"outline",className:`text-[10px] border-0 ${Pr(v)}`,children:[v," ",A," · ",B]},v))})]})]})})]}),s.jsxs(jc,{value:a,onValueChange:v=>{const A=new URLSearchParams(t);v==="users"?A.delete("tab"):A.set("tab",v),e(A)},className:"w-full",children:[s.jsxs(ul,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[s.jsxs(Qt,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[s.jsx(In,{className:"w-4 h-4"})," 用户列表"]}),s.jsxs(Qt,{value:"leads",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:()=>Ir(),children:[s.jsx(hc,{className:"w-4 h-4"})," 获客列表"]}),s.jsxs(Qt,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Io,children:[s.jsx(qr,{className:"w-4 h-4"})," 用户旅程总览"]}),s.jsxs(Qt,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:ia,children:[s.jsx(no,{className:"w-4 h-4"})," 规则配置"]}),s.jsxs(Qt,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Os,children:[s.jsx(pc,{className:"w-4 h-4"})," 超级个体列表"]})]}),s.jsxs(Yt,{value:"users",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[s.jsxs(X,{variant:"outline",onClick:Ci,disabled:Ba,className:"border-purple-500/50 text-purple-400 hover:bg-purple-500/10 bg-transparent",title:"批量调用神射手补全有手机号用户的资料",children:[Ba?s.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):s.jsx(pi,{className:"w-4 h-4 mr-2"}),"批量补全"]}),s.jsxs(X,{variant:"outline",onClick:()=>sa(!0),disabled:O,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${O?"animate-spin":""}`})," 刷新"]}),s.jsxs("select",{value:S,onChange:v=>{const A=v.target.value;E(A),f(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:I,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(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(ce,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:y,onChange:v=>N(v.target.value)})]}),s.jsxs(X,{onClick:Ra,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(hc,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:T?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Fe,{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(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"用户信息"}),s.jsx(je,{className:"text-gray-400",children:"绑定信息"}),s.jsx(je,{className:"text-gray-400",children:"购买状态"}),s.jsx(je,{className:"text-gray-400",children:"分销收益"}),s.jsxs(je,{className:"text-gray-400 cursor-pointer select-none",onClick:Cl,children:[s.jsxs("div",{className:"flex items-center gap-1 group",children:[s.jsx(Gh,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:"RFM分值"}),I?re==="desc"?s.jsx(vc,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(ag,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(rx,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),I&&s.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),s.jsx(je,{className:"text-gray-400",children:"资料完善"}),s.jsx(je,{className:"text-gray-400",children:"注册时间"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(hs,{children:[i.map(v=>{var A,B,ue;return s.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[(()=>{var it;const we=Rr(v.avatar,v.mbti),De=((it=v.nickname)==null?void 0:it.charAt(0))||"?";return s.jsx("button",{type:"button",title:"点击管理 MBTI 默认头像库",onClick:()=>wt(!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:we?s.jsx("img",{src:we,className:"w-full h-full rounded-full object-cover",alt:"",onError:Je=>{var dn;const vt=Je.target;if(vt.style.display="none",vt.nextElementSibling)return;const At=document.createElement("span");At.textContent=De,(dn=vt.parentElement)==null||dn.appendChild(At)}}):De})})(),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",onClick:()=>{ze(v.id),ye(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left truncate max-w-[120px]",children:v.nickname}),v.isAdmin&&s.jsx(Ve,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),v.openId&&!((A=v.id)!=null&&A.startsWith("user_"))&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),s.jsxs("p",{className:"text-xs text-gray-500 font-mono truncate max-w-[140px]",title:v.id,children:[(B=v.id)==null?void 0:B.slice(0,16),(((ue=v.id)==null?void 0:ue.length)??0)>16?"…":""]})]})]})}),s.jsx(be,{children:s.jsxs("div",{className:"space-y-1",children:[v.phone&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"📱"}),s.jsx("span",{className:"text-gray-300",children:v.phone})]}),v.wechatId&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"💬"}),s.jsx("span",{className:"text-gray-300",children:v.wechatId})]}),!v.phone&&!v.wechatId&&s.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),s.jsx(be,{children:(()=>{const we=Vc(v);return we.tone==="vip"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:we.main}),we.sub&&s.jsx("p",{className:"text-[11px] text-amber-300/80",children:we.sub})]}):we.tone==="paid"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(Ve,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:we.main}),we.sub&&s.jsx("p",{className:"text-[11px] text-blue-300/80",children:we.sub})]}):s.jsx(Ve,{variant:"outline",className:"text-gray-500 border-gray-600",children:we.main})})()}),s.jsx(be,{children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(v.earnings||0)).toFixed(2)]}),parseFloat(String(v.pendingEarnings||0))>0&&s.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(v.pendingEarnings||0)).toFixed(2)]}),s.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>aa(v),role:"button",tabIndex:0,onKeyDown:we=>we.key==="Enter"&&aa(v),children:[s.jsx(In,{className:"w-3 h-3"})," 绑定",v.referralCount||0,"人"]})]})}),s.jsx(be,{children:v.rfmScore!=null&&v.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:v.rfmScore}),s.jsx(Ve,{className:`border-0 text-xs ${Pr(v.rfmLevel)}`,children:v.rfmLevel})]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"无订单"})}),s.jsx(be,{children:(()=>{const we=Ti(v),De=we>=75?"text-green-400":we>=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 ${we>=75?"bg-green-500":we>=50?"bg-yellow-500":"bg-gray-500"}`,style:{width:`${we}%`}})}),s.jsxs("span",{className:`text-xs ${De}`,children:[we,"%"]})]})})()}),s.jsx(be,{className:"text-gray-400",children:v.createdAt?new Date(v.createdAt).toLocaleDateString():"-"}),s.jsx(be,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>{ze(v.id),ye(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:s.jsx(qh,{className:"w-4 h-4"})}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>wi(v),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:s.jsx(Jt,{className:"w-4 h-4"})}),s.jsx(X,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>Hc(v.id),title:"删除",children:s.jsx(bs,{className:"w-4 h-4"})})]})})]},v.id)}),i.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),s.jsx(qs,{page:h,totalPages:qn,total:c,pageSize:m,onPageChange:f,onPageSizeChange:v=>{x(v),f(1)}})]})})})]}),s.jsxs(Yt,{value:"leads",children:[Ps&&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:Ps}),s.jsx("button",{type:"button",className:"shrink-0 ml-2",onClick:()=>Ma(null),"aria-label":"关闭",children:"×"})]}),!ut&&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:ur})]}),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:Mt.uniqueUsers??0})]}),(Mt.sourceStats&&Mt.sourceStats.length>0?Mt.sourceStats.slice(0,2):[]).map(v=>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:["来源:",v.source]}),s.jsx("p",{className:"text-xl font-bold text-purple-400",children:v.cnt})]},v.source))]}),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(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(ce,{placeholder:"搜索昵称/手机/微信/@人/来源…",value:Aa,onChange:v=>To(v.target.value),className:"pl-9 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"})]}),Mt.sourceStats&&Mt.sourceStats.length>0&&s.jsxs("select",{value:Ts,onChange:v=>{vi(v.target.value),xe(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部来源"}),Mt.sourceStats.map(v=>s.jsxs("option",{value:v.source,children:[v.source,"(",v.cnt,")"]},v.source))]}),s.jsxs("span",{className:"text-xs text-gray-500 whitespace-nowrap max-w-[min(100%,20rem)]",title:"同一页内:相同手机号或相同用户 ID(含微信侧标识)只保留最近一条",children:["本页 ",ss," 条",_r>0?` · 已合并 ${_r} 条重复`:""]})]}),s.jsxs(X,{variant:"outline",onClick:()=>Ir(),disabled:ut,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${ut?"animate-spin":""}`})," 刷新"]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:ut?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Fe,{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(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"昵称"}),s.jsx(je,{className:"text-gray-400",children:"手机号"}),s.jsx(je,{className:"text-gray-400",children:"微信号"}),s.jsx(je,{className:"text-gray-400",children:"对应 @人"}),s.jsx(je,{className:"text-gray-400",children:"获客计划"}),s.jsx(je,{className:"text-gray-400",children:"来源"}),s.jsx(je,{className:"text-gray-400",children:"时间"})]})}),s.jsxs(hs,{children:[Oo.map(v=>s.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:v.userNickname||v.name||"-"}),s.jsx(be,{className:"text-gray-300",children:v.phone||"-"}),s.jsx(be,{className:"text-gray-300",children:v.wechatId||"-"}),s.jsx(be,{className:"text-[#38bdac]",children:v.personName||"-"}),s.jsx(be,{className:"text-gray-400",children:v.ckbPlanId?`#${v.ckbPlanId}`:"-"}),s.jsx(be,{children:s.jsx(Ve,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:v.source||"未知"})}),s.jsx(be,{className:"text-gray-400",children:v.createdAt?new Date(v.createdAt).toLocaleString():"-"})]},v.id)),Oo.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:7,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(hc,{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:Zs.trim()||Ts?"当前搜索或来源筛选下没有匹配记录,可清空条件后重试。":"存客宝场景产生的手机号 / 微信留资会出现在此列表。请确认获客计划已开启,并有用户完成留资。"}),s.jsxs(X,{type:"button",variant:"outline",onClick:()=>Ir(),disabled:ut,className:"border-[#38bdac]/40 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${ut?"animate-spin":""}`}),"重新加载"]})]})})})]})]}),s.jsx(qs,{page:ae,totalPages:Math.ceil(ur/Ue)||1,total:ur,pageSize:Ue,onPageChange:xe,onPageSizeChange:()=>{}})]})})})]}),s.jsxs(Yt,{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(X,{variant:"outline",onClick:Io,disabled:Et,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${Et?"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:tc.map((v,A)=>s.jsxs("div",{className:"relative flex flex-col items-center",children:[s.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${v.color} text-center cursor-pointer hover:opacity-80 transition-opacity ${tt===v.id?"ring-2 ring-[#38bdac]":""}`,onClick:()=>mr(v.id),title:`点击查看「${v.label}」阶段的用户`,children:[s.jsx("div",{className:"text-2xl mb-1",children:v.icon}),s.jsx("div",{className:`text-xs font-medium ${v.color.split(" ").find(B=>B.startsWith("text-"))}`,children:v.label}),Me[v.id]!==void 0&&s.jsxs("div",{className:"mt-1.5 text-xs text-gray-400",children:[s.jsx("span",{className:"font-bold text-white",children:Me[v.id]})," 人"]}),s.jsx("div",{className:"absolute -top-2.5 -left-2.5 w-5 h-5 rounded-full bg-[#0a1628] border border-gray-700 flex items-center justify-center text-[10px] text-gray-500",children:A+1})]}),As.jsxs("div",{className:"flex items-start gap-3 p-2 bg-[#0a1628] rounded",children:[s.jsx("span",{className:"text-[#38bdac] font-mono text-xs shrink-0 mt-0.5",children:v.step}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-300",children:v.action}),s.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",v.next]})]})]},v.step))})]}),s.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(Gs,{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:"实时更新"})]}),Et?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Fe,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(Me).length>0?s.jsx("div",{className:"space-y-2",children:tc.map(v=>{const A=Me[v.id]||0,B=Math.max(...tc.map(we=>Me[we.id]||0),1),ue=Math.round(A/B*100);return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-gray-500 text-xs w-20 shrink-0",children:[v.icon," ",v.label]}),s.jsx("div",{className:"flex-1 h-2 bg-[#0a1628] rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac]/60 rounded-full transition-all",style:{width:`${ue}%`}})}),s.jsx("span",{className:"text-gray-400 text-xs w-10 text-right",children:A})]},v.id)})}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]}),tt&&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(In,{className:"w-4 h-4 text-[#38bdac]"}),s.jsxs("span",{className:"text-white font-medium",children:[(Ei=tc.find(v=>v.id===tt))==null?void 0:Ei.icon," ",(zr=tc.find(v=>v.id===tt))==null?void 0:zr.label," 阶段用户"]}),s.jsxs(Ve,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:[Wt.length," 人"]})]}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>Pt(null),className:"text-gray-400 hover:text-white",children:s.jsx(Yn,{className:"w-4 h-4"})})]}),ts?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Fe,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Wt.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"该阶段暂无用户"}):s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"昵称"}),s.jsx(je,{className:"text-gray-400",children:"手机号"}),s.jsx(je,{className:"text-gray-400",children:"注册时间"}),s.jsx(je,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsx(hs,{children:Wt.map(v=>s.jsxs(ct,{className:"border-gray-700/50 hover:bg-[#0a1628]",children:[s.jsx(be,{className:"text-white",children:v.nickname||"微信用户"}),s.jsx(be,{className:"text-gray-300",children:v.phone||"-"}),s.jsx(be,{className:"text-gray-400 text-xs",children:v.createdAt?new Date(v.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx(be,{className:"text-right",children:s.jsxs(X,{variant:"ghost",size:"sm",className:"text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>Ro(v.id,v.nickname||"微信用户"),children:[s.jsx(qh,{className:"w-4 h-4 mr-1"})," 行为轨迹"]})})]},v.id))})]})]}),s.jsx(Dt,{open:!!bi,onOpenChange:v=>{v||ea(null)},children:s.jsxs(Lt,{className:"sm:max-w-[600px] bg-[#0f2137] border-gray-700 text-white max-h-[80vh] overflow-y-auto",children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(qr,{className:"w-5 h-5 text-[#38bdac]"}),ta," 的行为轨迹"]})}),cr?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Mr.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"}),Mr.map((v,A)=>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:v.actionLabel}),v.module&&s.jsx(Ve,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[10px]",children:v.module})]}),(v.chapterTitle||v.target)&&s.jsx("p",{className:"text-gray-400 text-xs mt-0.5 truncate",children:v.chapterTitle||v.target}),s.jsxs("p",{className:"text-gray-600 text-[10px] mt-0.5",children:[v.timeAgo," · ",v.createdAt?new Date(v.createdAt).toLocaleString("zh-CN"):""]})]})]},v.id||A))]})]})})]}),s.jsxs(Yt,{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(X,{variant:"outline",onClick:ia,disabled:mn,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${mn?"animate-spin":""}`})," 刷新"]}),s.jsxs(X,{onClick:()=>{$n(null),cn({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),vn(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(An,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),mn?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Tt.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(Gs,{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(X,{onClick:ia,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Fe,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):s.jsx("div",{className:"space-y-2",children:Tt.map(v=>{var A;return s.jsxs("div",{className:`p-3 rounded-lg border transition-all ${v.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:[s.jsxs("div",{className:"flex items-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:["#",v.sort]}),s.jsx(Jt,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),s.jsx("span",{className:"text-white font-medium text-sm truncate",children:v.title}),v.trigger&&s.jsx(Ve,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-[10px] shrink-0",children:v.trigger}),(v.triggerConditions||[]).length>0&&s.jsxs("div",{className:"flex flex-wrap gap-0.5 ml-1",children:[(v.triggerConditions||[]).slice(0,3).map(B=>{const ue=L1.find(we=>we.value===B);return s.jsx(Ve,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[9px]",children:(ue==null?void 0:ue.label)||B},B)}),(v.triggerConditions||[]).length>3&&s.jsxs("span",{className:"text-gray-500 text-[9px]",children:["+",(v.triggerConditions||[]).length-3]})]}),v.actionType&&v.actionType!=="popup"&&s.jsx(Ve,{className:"bg-amber-500/10 text-amber-400 border border-amber-500/30 text-[9px] shrink-0",children:((A=D1.find(B=>B.value===v.actionType))==null?void 0:A.label)||v.actionType})]}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-3 shrink-0",children:[s.jsx($t,{checked:v.enabled,onCheckedChange:()=>Eo(v)}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>{$n(v),cn({title:v.title,description:v.description,trigger:v.trigger,triggerConditions:v.triggerConditions||[],actionType:v.actionType||"popup",sort:v.sort,enabled:v.enabled}),vn(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10 h-7 w-7 p-0",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>ki(v.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 h-7 w-7 p-0",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]}),v.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:["(",v.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:v.description})]})]},v.id)})})]}),s.jsxs(Yt,{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(X,{variant:"outline",onClick:Os,disabled:Se,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${Se?"animate-spin":""}`})," ","刷新"]})})]}),Se?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):xn.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(pc,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400 w-12",children:"序号"}),s.jsx(je,{className:"text-gray-400",children:"成员"}),s.jsx(je,{className:"text-gray-400 min-w-40",children:"超级个体标签"}),s.jsx(je,{className:"text-gray-400 w-16 text-center",children:"头像点击"}),s.jsx(je,{className:"text-gray-400 w-16 text-center",children:"获客数"}),s.jsx(je,{className:"text-gray-400 w-20",children:"排序值"}),s.jsx(je,{className:"text-gray-400 w-36",children:"飞书群"}),s.jsx(je,{className:"text-gray-400 w-36 text-right",children:"操作"})]})}),s.jsx(hs,{children:xn.map((v,A)=>{var we;const B=Xe===v.id,ue=gt===v.id;return s.jsxs(ct,{draggable:!0,onDragStart:De=>Ml(De,v.id),onDragOver:De=>Fa(De,v.id),onDrop:De=>Ao(De,v.id),onDragEnd:Si,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${B?"opacity-60":""} ${ue?"bg-[#38bdac]/10":""}`,children:[s.jsx(be,{className:"text-gray-300",children:A+1}),s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[Rr(v.avatar,v.mbti)?s.jsx("img",{src:Rr(v.avatar,v.mbti),className:"w-8 h-8 rounded-full object-cover border border-amber-400/60",alt:"",onError:De=>{var Je,vt;De.target.style.display="none";const it=document.createElement("div");it.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",it.textContent=((Je=v.name)==null?void 0:Je[0])||"创",(vt=De.target.parentElement)==null||vt.appendChild(it)}}):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:((we=v.name)==null?void 0:we[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:v.name})})]})}),s.jsx(be,{className:"text-gray-300 whitespace-nowrap",children:v.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置)"})}),s.jsx(be,{className:"text-center text-blue-400 text-xs font-mono",children:v.clickCount!=null?String(v.clickCount):"-"}),s.jsx(be,{className:"text-center text-green-400 text-xs font-mono",children:v.leadCount!=null?String(v.leadCount):"-"}),s.jsx(be,{className:"text-gray-300",children:v.vipSort??A+1}),s.jsx(be,{className:"text-xs",children:v.webhookUrl?s.jsx("span",{className:"text-[#38bdac] truncate block max-w-[180px]",title:v.webhookUrl,children:"已配置"}):s.jsx("span",{className:"text-gray-500",children:"未配置"})}),s.jsx(be,{className:"text-right text-xs text-gray-300",children:s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>ps(v),title:"设置超级个体标签",children:s.jsx(Ad,{className:"w-3.5 h-3.5"})}),s.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-[#38bdac] hover:text-[#5fe0cd]",onClick:()=>La(v),title:"编辑飞书群Webhook",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),s.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>$a(v),title:"设置排序序号",children:s.jsx(rx,{className:"w-3.5 h-3.5"})})]})})]},v.id)})})]})})})]})]}),s.jsx(Dt,{open:ft,onOpenChange:wt,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-6xl",children:[s.jsx(_t,{children:s.jsx(zt,{className:"text-white",children:"MBTI 默认头像库"})}),s.jsx(GP,{})]})}),s.jsx(Dt,{open:za,onOpenChange:v=>{_s(v),v||zs(null)},children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(rx,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",er==null?void 0:er.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),s.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:El,onChange:v=>Lr(v.target.value)})]}),s.jsxs(fn,{children:[s.jsxs(X,{variant:"outline",onClick:()=>_s(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(X,{onClick:Uc,disabled:Dr,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),Dr?"保存中...":"保存"]})]})]})}),s.jsx(Dt,{open:En,onOpenChange:v=>{Pa(v),v||kt(null)},children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(pc,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",Ls==null?void 0:Ls.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:ca.map(v=>s.jsx(X,{variant:oa===v?"default":"outline",size:"sm",className:oa===v?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>Ln(v),children:v},v))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"或手动输入"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:oa,onChange:v=>Ln(v.target.value)})]})]}),s.jsxs(fn,{children:[s.jsxs(X,{variant:"outline",onClick:()=>Pa(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(X,{onClick:()=>Da(oa),disabled:hr,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),hr?"保存中...":"保存"]})]})]})}),s.jsx(Dt,{open:Tl,onOpenChange:v=>{Oa(v),v||la(null)},children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-xl",children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(Jt,{className:"w-5 h-5 text-[#38bdac]"}),"设置飞书群 Webhook — ",fr==null?void 0:fr.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"VOX Webhook 地址(留空即清空)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",value:Ds,onChange:v=>Bn(v.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"当用户点击该超级个体头像并提交链接时,线索将优先推送到这里配置的飞书群。"})]}),s.jsxs(fn,{children:[s.jsxs(X,{variant:"outline",onClick:()=>Oa(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(X,{onClick:_a,disabled:Vn,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),Vn?"保存中...":"保存"]})]})]})}),s.jsx(Dt,{open:J,onOpenChange:$,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[D?s.jsx(Jt,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(hc,{className:"w-5 h-5 text-[#38bdac]"}),D?"编辑用户":"添加用户"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"手机号"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:dt.phone,onChange:v=>Rt({...dt,phone:v.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"昵称"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:dt.nickname,onChange:v=>Rt({...dt,nickname:v.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:D?"新密码 (留空则不修改)":"密码"}),s.jsx(ce,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:D?"留空则不修改":"请输入密码",value:dt.password,onChange:v=>Rt({...dt,password:v.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(ee,{className:"text-gray-300",children:"管理员权限"}),s.jsx($t,{checked:dt.isAdmin,onCheckedChange:v=>Rt({...dt,isAdmin:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(ee,{className:"text-gray-300",children:"已购全书"}),s.jsx($t,{checked:dt.hasFullBook,onCheckedChange:v=>Rt({...dt,hasFullBook:v})})]})]}),s.jsxs(fn,{children:[s.jsxs(X,{variant:"outline",onClick:()=>$(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(X,{onClick:ra,disabled:oe,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),oe?"保存中...":"保存"]})]})]})}),s.jsx(Dt,{open:qt,onOpenChange:vn,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[90vh] overflow-y-auto",children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(Jt,{className:"w-5 h-5 text-[#38bdac]"}),On?"编辑规则":"添加规则"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"规则标题 *"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:St.title,onChange:v=>cn({...St,title:v.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"规则描述"}),s.jsx(hl,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[60px] resize-none",placeholder:"弹窗内容/推送文案...",value:St.description,onChange:v=>cn({...St,description:v.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"触发条件(可多选)"}),s.jsx("div",{className:"space-y-2",children:["用户状态","阅读行为","付费行为","社交行为","分销行为"].map(v=>{const A=L1.filter(B=>B.group===v);return A.length===0?null:s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-gray-500 mb-1",children:v}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:A.map(B=>{const ue=(St.triggerConditions||[]).includes(B.value);return s.jsx("button",{type:"button",className:`px-2.5 py-1 rounded-md text-xs border transition-colors ${ue?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-[#0a1628] border-gray-700 text-gray-400 hover:border-gray-500"}`,onClick:()=>{const we=St.triggerConditions||[],De=ue?we.filter(it=>it!==B.value):[...we,B.value];cn({...St,triggerConditions:De})},children:B.label},B.value)})})]},v)})}),(St.triggerConditions||[]).length>0&&s.jsxs("p",{className:"text-[10px] text-[#38bdac]",children:["已选 ",(St.triggerConditions||[]).length," 个触发条件(满足任一即触发)"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"兼容触发标识(旧版)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white text-xs h-8",placeholder:"例:after_login、after_pay(兼容现有小程序 ruleEngine)",value:St.trigger,onChange:v=>cn({...St,trigger:v.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"推送动作"}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:D1.map(v=>s.jsxs("button",{type:"button",className:`p-2 rounded-lg border text-left transition-colors ${St.actionType===v.value?"bg-[#38bdac]/15 border-[#38bdac]/50":"bg-[#0a1628] border-gray-700 hover:border-gray-500"}`,onClick:()=>cn({...St,actionType:v.value}),children:[s.jsx("span",{className:`text-xs font-medium ${St.actionType===v.value?"text-[#38bdac]":"text-gray-300"}`,children:v.label}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5",children:v.desc})]},v.value))})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{children:s.jsx(ee,{className:"text-gray-300",children:"启用状态"})}),s.jsx($t,{checked:St.enabled,onCheckedChange:v=>cn({...St,enabled:v})})]})]}),s.jsxs(fn,{children:[s.jsxs(X,{variant:"outline",onClick:()=>vn(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(X,{onClick:ji,disabled:oe,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),oe?"保存中...":"保存"]})]})]})}),s.jsx(Dt,{open:_,onOpenChange:U,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(In,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",le==null?void 0:le.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:((Mi=H.stats)==null?void 0:Mi.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:((Va=H.stats)==null?void 0:Va.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:["¥",(((Ha=H.stats)==null?void 0:Ha.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:["¥",((($r=H.stats)==null?void 0:$r.pendingEarnings)||0).toFixed(2)]}),s.jsx("div",{className:"text-xs text-gray-400",children:"待提现"})]})]}),me?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Fe,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((da=H.referrals)==null?void 0:da.length)??0)>0?s.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(H.referrals??[]).map((v,A)=>{var ue;const B=v;return s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:((ue=B.nickname)==null?void 0:ue.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white text-sm",children:B.nickname}),s.jsx("div",{className:"text-xs text-gray-500",children:B.phone||(B.hasOpenId?"微信用户":"未绑定")})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[B.status==="vip"&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),B.status==="paid"&&s.jsxs(Ve,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",B.purchasedSections,"章"]}),B.status==="free"&&s.jsx(Ve,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),s.jsx("span",{className:"text-xs text-gray-500",children:B.createdAt?new Date(B.createdAt).toLocaleDateString():""})]})]},B.id||A)})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),s.jsx(fn,{children:s.jsx(X,{variant:"outline",onClick:()=>U(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),s.jsx(I0,{open:ve,onClose:()=>ye(!1),userId:ke,onUserUpdated:sa})]})}function tf(t,[e,n]){return Math.min(n,Math.max(e,t))}var Zk=["PageUp","PageDown"],e2=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],t2={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Dc="Slider",[xg,YP,XP]=T0(Dc),[n2]=No(Dc,[XP]),[ZP,ip]=n2(Dc),s2=b.forwardRef((t,e)=>{const{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:u=0,defaultValue:h=[r],value:f,onValueChange:m=()=>{},onValueCommit:x=()=>{},inverted:y=!1,form:N,...w}=t,j=b.useRef(new Set),S=b.useRef(0),T=o==="horizontal"?e8:t8,[P=[],O]=cl({prop:f,defaultProp:h,onChange:Q=>{var re;(re=[...j.current][S.current])==null||re.focus(),m(Q)}}),q=b.useRef(P);function z(Q){const F=i8(P,Q);te(Q,F)}function V(Q){te(Q,S.current)}function I(){const Q=q.current[S.current];P[S.current]!==Q&&x(P)}function te(Q,F,{commit:re}={commit:!1}){const ie=d8(i),J=u8(Math.round((Q-r)/i)*i+r,ie),$=tf(J,[r,a]);O((D=[])=>{const R=r8(D,$,F);if(c8(R,u*i)){S.current=R.indexOf($);const oe=String(R)!==String(D);return oe&&re&&x(R),oe?R:D}else return D})}return s.jsx(ZP,{scope:t.__scopeSlider,name:n,disabled:c,min:r,max:a,valueIndexToChangeRef:S,thumbs:j.current,values:P,orientation:o,form:N,children:s.jsx(xg.Provider,{scope:t.__scopeSlider,children:s.jsx(xg.Slot,{scope:t.__scopeSlider,children:s.jsx(T,{"aria-disabled":c,"data-disabled":c?"":void 0,...w,ref:e,onPointerDown:mt(w.onPointerDown,()=>{c||(q.current=P)}),min:r,max:a,inverted:y,onSlideStart:c?void 0:z,onSlideMove:c?void 0:V,onSlideEnd:c?void 0:I,onHomeKeyDown:()=>!c&&te(r,0,{commit:!0}),onEndKeyDown:()=>!c&&te(a,P.length-1,{commit:!0}),onStepKeyDown:({event:Q,direction:F})=>{if(!c){const J=Zk.includes(Q.key)||Q.shiftKey&&e2.includes(Q.key)?10:1,$=S.current,D=P[$],R=i*J*F;te(D+R,$,{commit:!0})}}})})})})});s2.displayName=Dc;var[r2,a2]=n2(Dc,{startEdge:"left",endEdge:"right",size:"width",direction:1}),e8=b.forwardRef((t,e)=>{const{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,x]=b.useState(null),y=Ht(e,T=>x(T)),N=b.useRef(void 0),w=sp(a),j=w==="ltr",S=j&&!i||!j&&i;function E(T){const P=N.current||m.getBoundingClientRect(),O=[0,P.width],z=R0(O,S?[n,r]:[r,n]);return N.current=P,z(T-P.left)}return s.jsx(r2,{scope:t.__scopeSlider,startEdge:S?"left":"right",endEdge:S?"right":"left",direction:S?1:-1,size:"width",children:s.jsx(i2,{dir:w,"data-orientation":"horizontal",...f,ref:y,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:T=>{const P=E(T.clientX);o==null||o(P)},onSlideMove:T=>{const P=E(T.clientX);c==null||c(P)},onSlideEnd:()=>{N.current=void 0,u==null||u()},onStepKeyDown:T=>{const O=t2[S?"from-left":"from-right"].includes(T.key);h==null||h({event:T,direction:O?-1:1})}})})}),t8=b.forwardRef((t,e)=>{const{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=b.useRef(null),m=Ht(e,f),x=b.useRef(void 0),y=!a;function N(w){const j=x.current||f.current.getBoundingClientRect(),S=[0,j.height],T=R0(S,y?[r,n]:[n,r]);return x.current=j,T(w-j.top)}return s.jsx(r2,{scope:t.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:s.jsx(i2,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const j=N(w.clientY);i==null||i(j)},onSlideMove:w=>{const j=N(w.clientY);o==null||o(j)},onSlideEnd:()=>{x.current=void 0,c==null||c()},onStepKeyDown:w=>{const S=t2[y?"from-bottom":"from-top"].includes(w.key);u==null||u({event:w,direction:S?-1:1})}})})}),i2=b.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=ip(Dc,n);return s.jsx(bt.span,{...h,ref:e,onKeyDown:mt(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):Zk.concat(e2).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:mt(t.onPointerDown,m=>{const x=m.target;x.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(x)?x.focus():r(m)}),onPointerMove:mt(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&a(m)}),onPointerUp:mt(t.onPointerUp,m=>{const x=m.target;x.hasPointerCapture(m.pointerId)&&(x.releasePointerCapture(m.pointerId),i(m))})})}),o2="SliderTrack",l2=b.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=ip(o2,n);return s.jsx(bt.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:e})});l2.displayName=o2;var gg="SliderRange",c2=b.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=ip(gg,n),i=a2(gg,n),o=b.useRef(null),c=Ht(e,o),u=a.values.length,h=a.values.map(x=>h2(x,a.min,a.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return s.jsx(bt.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:c,style:{...t.style,[i.startEdge]:f+"%",[i.endEdge]:m+"%"}})});c2.displayName=gg;var yg="SliderThumb",d2=b.forwardRef((t,e)=>{const n=YP(t.__scopeSlider),[r,a]=b.useState(null),i=Ht(e,c=>a(c)),o=b.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(n8,{...t,ref:i,index:o})}),n8=b.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:a,...i}=t,o=ip(yg,n),c=a2(yg,n),[u,h]=b.useState(null),f=Ht(e,E=>h(E)),m=u?o.form||!!u.closest("form"):!0,x=A0(u),y=o.values[r],N=y===void 0?0:h2(y,o.min,o.max),w=a8(r,o.values.length),j=x==null?void 0:x[c.size],S=j?o8(j,N,c.direction):0;return b.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),s.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${N}% + ${S}px)`},children:[s.jsx(xg.ItemSlot,{scope:t.__scopeSlider,children:s.jsx(bt.span,{role:"slider","aria-label":t["aria-label"]||w,"aria-valuemin":o.min,"aria-valuenow":y,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:f,style:y===void 0?{display:"none"}:t.style,onFocus:mt(t.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),m&&s.jsx(u2,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:y},r)]})});d2.displayName=yg;var s8="RadioBubbleInput",u2=b.forwardRef(({__scopeSlider:t,value:e,...n},r)=>{const a=b.useRef(null),i=Ht(a,r),o=M0(e);return b.useEffect(()=>{const c=a.current;if(!c)return;const u=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==e&&f){const m=new Event("input",{bubbles:!0});f.call(c,e),c.dispatchEvent(m)}},[o,e]),s.jsx(bt.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});u2.displayName=s8;function r8(t=[],e,n){const r=[...t];return r[n]=e,r.sort((a,i)=>a-i)}function h2(t,e,n){const i=100/(n-e)*(t-e);return tf(i,[0,100])}function a8(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function i8(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 o8(t,e,n){const r=t/2,i=R0([0,50],[0,r]);return(r-i(e)*n)*n}function l8(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function c8(t,e){if(e>0){const n=l8(t);return Math.min(...n)>=e}return!0}function R0(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 d8(t){return(String(t).split(".")[1]||"").length}function u8(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var h8=s2,f8=l2,p8=c2,m8=d2;function x8({className:t,defaultValue:e,value:n,min:r=0,max:a=100,...i}){const o=b.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[r,a],[n,e,r,a]);return s.jsxs(h8,{defaultValue:e,value:n,min:r,max:a,className:Ut("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(p8,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>s.jsx(m8,{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 g8={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,withdrawFee:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function f2(t){const e=!!(t!=null&&t.embedded),[n,r]=b.useState(g8),[a,i]=b.useState(!0),[o,c]=b.useState(!1);b.useEffect(()=>{Pe("/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 Ct("/api/admin/referral-settings",f);if(!m||m.success===!1){se.error("保存失败: "+(m&&typeof m=="object"&&"error"in m?m.error:""));return}se.success(`✅ 分销配置已保存成功! • 小程序与网站的推广规则会一起生效 • 绑定关系会使用新的天数配置 • 佣金比例会立即应用到新订单 -如有缓存,请刷新前台/小程序页面。`)}catch(f){console.error(f),se.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{c(!1)}},h=f=>m=>{const g=parseFloat(m.target.value||"0");r(y=>({...y,[f]:isNaN(g)?0:g}))};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(Nc,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置(与系统设置中的「推广功能」开关配合:开关在"," ",s.jsx(bc,{to:"/settings",className:"text-[#38bdac] underline hover:text-[#5ee0d1]",children:"系统设置 → 功能开关"}),")。"]})]}),s.jsxs(X,{onClick:u,disabled:o||a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),o?"保存中...":"保存配置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"flex items-center gap-2 text-white",children:[s.jsx(RM,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),s.jsx(Kt,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),s.jsx(Le,{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(ee,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(ch,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),s.jsx(de,{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(ee,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(In,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(g8,{className:"flex-1",min:10,max:100,step:1,value:[n.distributorShare],onValueChange:([f])=>r(m=>({...m,distributorShare:f}))}),s.jsx(de,{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(ee,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(ch,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),s.jsx(de,{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(ee,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(ch,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),s.jsx(de,{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(ee,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(In,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),s.jsx(de,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"flex items-center gap-2 text-white",children:[s.jsx(Nc,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),s.jsx(Kt,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),s.jsx(Le,{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(ee,{className:"text-gray-300",children:"最低提现金额(元)"}),s.jsx(de,{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(ee,{className:"text-gray-300",children:"提现手续费(%)"}),s.jsx(de,{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(ee,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",s.jsx(Ve,{variant:"outline",className:"border-[#38bdac]/40 text-[#38bdac] text-[10px]",children:"预留"})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[s.jsx($t,{checked:n.enableAutoWithdraw,onCheckedChange:f=>r(m=>({...m,enableAutoWithdraw:f}))}),s.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(rt,{children:s.jsxs(at,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[s.jsx(ch,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),s.jsxs(Le,{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 y8(){const[t]=g0(),[e,n]=b.useState("overview"),[r,a]=b.useState("orders"),[i,o]=b.useState([]),[c,u]=b.useState(null),[h,f]=b.useState([]),[m,g]=b.useState([]),[y,N]=b.useState([]),[w,j]=b.useState(!0),[S,E]=b.useState(null),[T,P]=b.useState(""),[O,q]=b.useState("all"),[z,V]=b.useState(1),[I,te]=b.useState(10),[Q,F]=b.useState(0),[re,ae]=b.useState(new Set),[J,$]=b.useState(null),[D,R]=b.useState(""),[oe,G]=b.useState(!1),[_,U]=b.useState(null),[H,K]=b.useState(""),[me,Y]=b.useState(!1),[le,ce]=b.useState(!1),[ve,ye]=b.useState(!1),[ke,ze]=b.useState([]),[ht,wt]=b.useState(1),[dt,Rt]=b.useState(0),[Tt,Tn]=b.useState("");b.useEffect(()=>{mn()},[]),b.useEffect(()=>{const L=t.get("tab");(L==="overview"||L==="orders"||L==="bindings"||L==="withdrawals"||L==="settings")&&n(L)},[t]),b.useEffect(()=>{V(1)},[e,O]),b.useEffect(()=>{Ft(e)},[e]),b.useEffect(()=>{if(e==="orders"&&r==="giftpay"){Ft("giftPay",!0);return}["orders","bindings","withdrawals"].includes(e)&&Ft(e,!0)},[z,I,O,T,e,r,ht,Tt]),b.useEffect(()=>{e==="withdrawals"&&St()},[e]);async function mn(){E(null);try{const L=await Pe("/api/admin/distribution/overview");L!=null&&L.success&&L.overview&&u(L.overview)}catch(L){console.error("[Admin] 概览接口异常:",L),E("加载概览失败")}try{const L=await Pe("/api/db/users");N((L==null?void 0:L.users)||[])}catch(L){console.error("[Admin] 用户数据加载失败:",L)}}async function Ft(L,Me=!1){var ft;if(!(!Me&&re.has(L))){j(!0);try{const Et=y;switch(L){case"overview":break;case"orders":{try{const ut=new URLSearchParams({page:String(z),pageSize:String(I),...O!=="all"&&{status:O},...T&&{search:T}}),tt=await Pe(`/api/admin/orders?${ut}`);if(tt!=null&&tt.success&&tt.orders){const Pt=tt.orders.map(Wt=>{const en=Et.find(Js=>Js.id===Wt.userId),ts=Wt.referrerId?Et.find(Js=>Js.id===Wt.referrerId):null;return{...Wt,amount:parseFloat(String(Wt.amount))||0,userNickname:(en==null?void 0:en.nickname)||Wt.userNickname||"未知用户",userPhone:(en==null?void 0:en.phone)||Wt.userPhone||"-",referrerNickname:(ts==null?void 0:ts.nickname)||null,referrerCode:(ts==null?void 0:ts.referralCode)??null,type:Wt.productType||Wt.type}});o(Pt),F(tt.total??Pt.length)}else o([]),F(0)}catch(ut){console.error(ut),E("加载订单失败"),o([])}break}case"bindings":{try{const ut=new URLSearchParams({page:String(z),pageSize:String(I),...O!=="all"&&{status:O}}),tt=await Pe(`/api/db/distribution?${ut}`);f((tt==null?void 0:tt.bindings)||[]),F((tt==null?void 0:tt.total)??((ft=tt==null?void 0:tt.bindings)==null?void 0:ft.length)??0)}catch(ut){console.error(ut),E("加载绑定数据失败"),f([])}break}case"withdrawals":{try{const ut=O==="completed"?"success":O==="rejected"?"failed":O,tt=new URLSearchParams({...ut&&ut!=="all"&&{status:ut},page:String(z),pageSize:String(I)}),Pt=await Pe(`/api/admin/withdrawals?${tt}`);if(Pt!=null&&Pt.success&&Pt.withdrawals){const Wt=Pt.withdrawals.map(en=>({...en,account:en.account??"未绑定微信号",status:en.status==="success"?"completed":en.status==="failed"?"rejected":en.status}));g(Wt),F((Pt==null?void 0:Pt.total)??Wt.length)}else Pt!=null&&Pt.success||E(`获取提现记录失败: ${(Pt==null?void 0:Pt.error)||"未知错误"}`),g([])}catch(ut){console.error(ut),E("加载提现数据失败"),g([])}break}case"giftPay":{try{const ut=new URLSearchParams({page:String(ht),pageSize:"20",...Tt&&{status:Tt}}),tt=await Pe(`/api/admin/gift-pay-requests?${ut}`);tt!=null&&tt.success&&tt.data?(ze(tt.data),Rt(tt.total??tt.data.length)):(ze([]),Rt(0))}catch(ut){console.error(ut),E("加载代付请求失败"),ze([])}break}}ae(ut=>new Set(ut).add(L))}catch(Et){console.error(Et)}finally{j(!1)}}}async function qt(){E(null),ae(L=>{const Me=new Set(L);return Me.delete(e),e==="orders"&&r==="giftpay"&&Me.delete("giftPay"),Me}),e==="overview"&&mn(),e==="orders"&&r==="giftpay"?await Ft("giftPay",!0):await Ft(e,!0)}async function vn(L){if(confirm("确认审核通过并打款?"))try{const Me=await Gt("/api/admin/withdrawals",{id:L,action:"approve"});if(!(Me!=null&&Me.success)){const ft=(Me==null?void 0:Me.message)||(Me==null?void 0:Me.error)||"操作失败";se.error(ft);return}await qt()}catch(Me){console.error(Me),se.error("操作失败")}}function On(L){U(L),K("")}async function $n(){const L=_;if(!L)return;const Me=H.trim();if(!Me){se.error("请填写拒绝原因");return}Y(!0);try{const ft=await Gt("/api/admin/withdrawals",{id:L,action:"reject",errorMessage:Me});if(!(ft!=null&&ft.success)){se.error((ft==null?void 0:ft.error)||"操作失败");return}se.success("已拒绝该提现申请"),U(null),K(""),await qt()}catch(ft){console.error(ft),se.error("操作失败")}finally{Y(!1)}}async function St(){try{const L=await Pe("/api/admin/withdrawals/auto-approve");L!=null&&L.success&&typeof L.enableAutoApprove=="boolean"&&ce(L.enableAutoApprove)}catch{}}async function cn(L){ye(!0);try{const Me=await Gt("/api/admin/withdrawals/auto-approve",{enableAutoApprove:L});Me!=null&&Me.success?(ce(L),se.success(L?"已开启自动审批,新提现将自动打款":"已关闭自动审批")):se.error("更新失败: "+((Me==null?void 0:Me.error)??""))}catch{se.error("更新失败")}finally{ye(!1)}}function gn(){_&&se.info("已取消操作"),U(null),K("")}async function xe(){var L;if(!(!(J!=null&&J.orderSn)&&!(J!=null&&J.id))){G(!0),E(null);try{const Me=await Gt("/api/admin/orders/refund",{orderSn:J.orderSn||J.id,reason:D||void 0});Me!=null&&Me.success?($(null),R(""),await Ft("orders",!0)):E((Me==null?void 0:Me.error)||"退款失败")}catch(Me){const ft=Me;E(((L=ft==null?void 0:ft.data)==null?void 0:L.error)||"退款失败,请检查网络后重试")}finally{G(!1)}}}function Se(L){const Me={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"},ft={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return s.jsx(Ve,{className:`${Me[L]||"bg-gray-500/20 text-gray-400"} border-0`,children:ft[L]||L})}const $e=Math.ceil(Q/I)||1,Xe=i,jt=h.filter(L=>{var ft,Et,ut,tt;if(!T)return!0;const Me=T.toLowerCase();return((ft=L.refereeNickname)==null?void 0:ft.toLowerCase().includes(Me))||((Et=L.refereePhone)==null?void 0:Et.includes(Me))||((ut=L.referrerName)==null?void 0:ut.toLowerCase().includes(Me))||((tt=L.referrerCode)==null?void 0:tt.toLowerCase().includes(Me))}),xt=m.filter(L=>{var ft;if(!T)return!0;const Me=T.toLowerCase();return((ft=L.userName)==null?void 0:ft.toLowerCase().includes(Me))||L.account&&L.account.toLowerCase().includes(Me)});return s.jsxs("div",{className:"p-8 w-full",children:[S&&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:S}),s.jsx("button",{type:"button",onClick:()=>E(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-semibold text-white",children:"推广中心"}),s.jsx("p",{className:"text-gray-500 text-sm mt-0.5",children:"分销绑定、提现审核、推广设置"})]}),s.jsxs(X,{onClick:qt,disabled:w,variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[s.jsx(Fe,{className:`w-3.5 h-3.5 mr-1.5 ${w?"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:Gh},{key:"orders",label:"订单与代付",icon:Kh},{key:"bindings",label:"绑定管理",icon:ya},{key:"withdrawals",label:"提现审核",icon:Nc},{key:"settings",label:"推广设置",icon:no}].map(L=>s.jsxs("button",{type:"button",onClick:()=>{n(L.key),q("all"),P(""),L.key!=="orders"&&a("orders")},className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2 rounded-md text-sm transition-all ${e===L.key?"bg-[#38bdac] text-white shadow-md":"text-gray-400 hover:text-white hover:bg-gray-700/40"}`,children:[s.jsx(L.icon,{className:"w-3.5 h-3.5"}),L.label]},L.key))}),w?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Fe,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[e==="overview"&&c&&s.jsxs("div",{className:"space-y-6",children:[s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Le,{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(pi,{className:"w-4 h-4 text-amber-400"}),"推广转化漏斗"]}),s.jsx(X,{type:"button",size:"sm",variant:"ghost",onClick:()=>void qt(),disabled:w,className:"text-gray-400 h-7",children:s.jsx(Fe,{className:`w-3.5 h-3.5 ${w?"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(qh,{className:"w-4 h-4 text-blue-400"}),"点击数"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:c.todayClicks}),s.jsx("td",{className:"py-2.5 text-right",children:c.monthClicks}),s.jsx("td",{className:"py-2.5 text-right",children:c.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(ya,{className:"w-4 h-4 text-green-400"}),"绑定关系"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:c.todayBindings}),s.jsx("td",{className:"py-2.5 text-right",children:c.monthBindings}),s.jsx("td",{className:"py-2.5 text-right",children:c.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(ag,{className:"w-4 h-4 text-purple-400"}),"付款转化"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:c.todayConversions}),s.jsx("td",{className:"py-2.5 text-right",children:c.monthConversions}),s.jsx("td",{className:"py-2.5 text-right",children:c.totalConversions})]}),s.jsxs("tr",{children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(Kh,{className:"w-4 h-4 text-[#38bdac]"}),"佣金收入"]}),s.jsxs("td",{className:"py-2.5 text-right font-bold text-[#38bdac]",children:["¥",(c.todayEarnings??0).toFixed(0)]}),s.jsxs("td",{className:"py-2.5 text-right text-[#38bdac]",children:["¥",(c.monthEarnings??0).toFixed(0)]}),s.jsxs("td",{className:"py-2.5 text-right text-[#38bdac]",children:["¥",(c.totalEarnings??0).toFixed(0)]})]})]})]})}),c.conversionRate&&s.jsxs("p",{className:"text-xs text-gray-500 mt-3 text-right",children:["综合转化率 ",c.conversionRate]})]})}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(Oe,{className:"bg-orange-500/10 border-orange-500/30",children:s.jsx(Le,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(ix,{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:[c.expiringBindings," ",s.jsx("span",{className:"text-sm font-normal text-orange-300/60",children:"个 · 7天内"})]})]})]})})}),s.jsx(Oe,{className:"bg-blue-500/10 border-blue-500/30",children:s.jsx(Le,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Nc,{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:[c.pendingWithdrawals," ",s.jsxs("span",{className:"text-sm font-normal text-blue-300/60",children:["笔 · ¥",(c.pendingWithdrawAmount??0).toFixed(0)]})]})]}),s.jsx(X,{onClick:()=>n("withdrawals"),variant:"outline",size:"sm",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20 shrink-0",children:"去审核"})]})})})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Le,{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(In,{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:c.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(ag,{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:c.activeDistributors}),s.jsx("p",{className:"text-[10px] text-gray-500",children:"有收益用户"})]})]})]})})})]}),e==="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 ${r==="orders"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,onClick:()=>a("orders"),children:"普通订单"}),s.jsxs("button",{type:"button",className:`px-3 py-1.5 rounded-md text-xs font-medium transition-all ${r==="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:()=>{a("giftpay"),Ft("giftPay",!0)},children:[s.jsx(ox,{className:"w-3 h-3 inline mr-1"}),"代付请求"]})]}),r==="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(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(de,{value:T,onChange:L=>P(L.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:O,onChange:L=>q(L.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(X,{type:"button",variant:"outline",onClick:()=>void qt(),disabled:w,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${w?"animate-spin":""}`}),"刷新"]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Le,{className:"p-0",children:[i.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:Xe.map(L=>{var Me,ft;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:[(Me=L.id)==null?void 0:Me.slice(0,12),"..."]}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:L.userNickname}),s.jsx("p",{className:"text-gray-500 text-xs",children:L.userPhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:(()=>{const Et=L.productType||L.type,ut=L.description||"",tt=String(L.productId||L.sectionId||""),Pt=Et==="vip"||ut.includes("VIP")||ut.toLowerCase().includes("vip")||tt.toLowerCase().includes("vip");return Et==="balance_recharge"?`余额充值 ¥${typeof L.amount=="number"?L.amount.toFixed(2):parseFloat(String(L.amount||"0")).toFixed(2)}`:Pt?"超级个体开通费用":Et==="fullbook"?`${L.bookName||"《底层逻辑》"} - 全本`:Et==="match"?"匹配次数购买":`${L.bookName||"《底层逻辑》"} - ${L.sectionTitle||L.chapterTitle||`章节${L.productId||L.sectionId||""}`}`})()}),s.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const Et=L.productType||L.type,ut=L.description||"",tt=String(L.productId||L.sectionId||""),Pt=Et==="vip"||ut.includes("VIP")||ut.toLowerCase().includes("vip")||tt.toLowerCase().includes("vip");return Et==="balance_recharge"?"余额充值":Pt?"超级个体":Et==="fullbook"?"全书解锁":Et==="match"?"功能权益":L.chapterTitle||"单章购买"})()})]})}),s.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof L.amount=="number"?L.amount.toFixed(2):parseFloat(String(L.amount||"0")).toFixed(2)]}),s.jsx("td",{className:"p-4 text-gray-300",children:L.paymentMethod==="wechat"?"微信支付":L.paymentMethod==="balance"?"余额支付":L.paymentMethod==="alipay"?"支付宝":L.paymentMethod||"微信支付"}),s.jsx("td",{className:"p-4",children:L.status==="refunded"?s.jsx(Ve,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):L.status==="completed"||L.status==="paid"?s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):L.status==="pending"||L.status==="created"?s.jsx(Ve,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):s.jsx(Ve,{className:"bg-red-500/20 text-red-400 border-0",children:"已失败"})}),s.jsx("td",{className:"p-4 text-gray-400 text-sm max-w-[120px]",title:L.refundReason,children:L.status==="refunded"&&L.refundReason?L.refundReason:"-"}),s.jsx("td",{className:"p-4 text-gray-300 text-sm",children:L.referrerId||L.referralCode?s.jsxs("span",{title:L.referralCode||L.referrerCode||L.referrerId||"",children:[L.referrerNickname||L.referralCode||L.referrerCode||((ft=L.referrerId)==null?void 0:ft.slice(0,8)),(L.referralCode||L.referrerCode)&&` (${L.referralCode||L.referrerCode})`]}):"-"}),s.jsx("td",{className:"p-4 text-[#FFD700]",children:L.referrerEarnings?`¥${(typeof L.referrerEarnings=="number"?L.referrerEarnings:parseFloat(String(L.referrerEarnings))).toFixed(2)}`:"-"}),s.jsx("td",{className:"p-4 text-gray-400 text-sm",children:L.createdAt?new Date(L.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:(L.status==="paid"||L.status==="completed")&&s.jsxs(X,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{$(L),R("")},children:[s.jsx(Ij,{className:"w-3 h-3 mr-1"}),"退款"]})})]},L.id)})})]})}),e==="orders"&&s.jsx(Ks,{page:z,totalPages:$e,total:Q,pageSize:I,onPageChange:V,onPageSizeChange:L=>{te(L),V(1)}})]})})]}),r==="giftpay"&&s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(rt,{children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[s.jsx(at,{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:Tt,onChange:L=>{Tn(L.target.value),wt(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(X,{size:"sm",variant:"outline",onClick:()=>void Ft("giftPay",!0),disabled:w,className:"border-gray-600 text-gray-300",children:[s.jsx(Fe,{className:`w-3.5 h-3.5 mr-1 ${w?"animate-spin":""}`}),"刷新"]})]})]})}),s.jsxs(Le,{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:ke.map(L=>s.jsxs("tr",{className:"hover:bg-[#0a1628]",children:[s.jsx("td",{className:"p-3 font-mono text-xs text-gray-400",children:L.requestSn}),s.jsx("td",{className:"p-3 text-white text-sm",children:L.initiatorNick||L.initiatorUserId}),s.jsxs("td",{className:"p-3",children:[s.jsxs("p",{className:"text-white",children:[L.productType," · ¥",L.amount.toFixed(2)]}),L.description&&s.jsx("p",{className:"text-gray-500 text-xs",children:L.description})]}),s.jsx("td",{className:"p-3 text-gray-400",children:(L.quantity??1)>1?`${L.quantity}份 / 已领${L.redeemedCount??0}`:"-"}),s.jsx("td",{className:"p-3 text-gray-400",children:L.payerNick||(L.payerUserId?L.payerUserId:"-")}),s.jsx("td",{className:"p-3",children:s.jsx(Ve,{className:L.status==="paid"?"bg-green-500/20 text-green-400 border-0":L.status==="pending"||L.status==="pending_pay"?"bg-amber-500/20 text-amber-400 border-0":L.status==="refunded"?"bg-red-500/20 text-red-400 border-0":"bg-gray-500/20 text-gray-400 border-0",children:L.status==="paid"?"已支付":L.status==="pending"||L.status==="pending_pay"?"待支付":L.status==="refunded"?"已退款":L.status==="cancelled"?"已取消":"已过期"})}),s.jsx("td",{className:"p-3 text-gray-400 text-xs",children:L.createdAt?new Date(L.createdAt).toLocaleString("zh-CN"):"-"})]},L.id))})]})}),ke.length===0&&!w&&s.jsx("p",{className:"text-center py-8 text-gray-500",children:"暂无代付请求"}),dt>20&&s.jsx("div",{className:"mt-4 flex justify-center",children:s.jsx(Ks,{page:ht,totalPages:Math.ceil(dt/20),total:dt,pageSize:20,onPageChange:wt,onPageSizeChange:()=>{}})})]})]})]}),e==="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(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(de,{value:T,onChange:L=>P(L.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:O,onChange:L=>q(L.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(X,{type:"button",variant:"outline",onClick:()=>void qt(),disabled:w,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${w?"animate-spin":""}`}),"刷新"]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Le,{className:"p-0",children:[jt.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:jt.map(L=>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:L.refereeNickname||"匿名用户"}),s.jsx("p",{className:"text-gray-500 text-xs",children:L.refereePhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:L.referrerName||"-"}),s.jsx("p",{className:"text-gray-500 text-xs font-mono",children:L.referrerCode})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:L.boundAt?new Date(L.boundAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:L.expiresAt?new Date(L.expiresAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:Se(L.status)}),s.jsx("td",{className:"p-4",children:L.commission?s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",L.commission.toFixed(2)]}):s.jsx("span",{className:"text-gray-500",children:"-"})})]},L.id))})]})}),e==="bindings"&&s.jsx(Ks,{page:z,totalPages:$e,total:Q,pageSize:I,onPageChange:V,onPageSizeChange:L=>{te(L),V(1)}})]})})]}),e==="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(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(de,{value:T,onChange:L=>P(L.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:O,onChange:L=>q(L.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(pi,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-sm text-gray-300",children:"自动审批"}),s.jsx($t,{checked:le,onCheckedChange:cn,disabled:ve,className:"data-[state=checked]:bg-[#38bdac]"})]}),s.jsxs(X,{type:"button",variant:"outline",onClick:()=>void qt(),disabled:w,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${w?"animate-spin":""}`}),"刷新"]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Le,{className:"p-0",children:[xt.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:xt.map(L=>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:[L.userAvatar?s.jsx("img",{src:L.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:(L.userName||L.name||"?").slice(0,1)}),s.jsx("p",{className:"text-white font-medium",children:L.userName||L.name})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",L.amount.toFixed(2)]})}),s.jsx("td",{className:"p-4",children:s.jsx(Ve,{className:L.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:L.method==="wechat"?"微信":"支付宝"})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-mono text-xs",children:L.account}),s.jsx("p",{className:"text-gray-500 text-xs",children:L.name})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:L.createdAt?new Date(L.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:Se(L.status)}),s.jsx("td",{className:"p-4 max-w-[160px]",children:s.jsx("span",{className:`text-xs ${L.status==="rejected"||L.status==="failed"?"text-red-400":"text-gray-400"}`,title:L.remark,children:L.remark||"-"})}),s.jsx("td",{className:"p-4 text-right",children:L.status==="pending"&&s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsxs(X,{size:"sm",onClick:()=>vn(L.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(ag,{className:"w-4 h-4 mr-1"}),"通过"]}),s.jsxs(X,{size:"sm",variant:"outline",onClick:()=>On(L.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[s.jsx(Sj,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},L.id))})]})}),e==="withdrawals"&&s.jsx(Ks,{page:z,totalPages:$e,total:Q,pageSize:I,onPageChange:V,onPageSizeChange:L=>{te(L),V(1)}})]})})]})]}),s.jsx(Dt,{open:!!J,onOpenChange:L=>!L&&$(null),children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(_t,{children:s.jsx(zt,{className:"text-white",children:"订单退款"})}),J&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",J.orderSn||J.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof J.amount=="number"?J.amount.toFixed(2):parseFloat(String(J.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(de,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:D,onChange:L=>R(L.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>$(null),disabled:oe,children:"取消"}),s.jsx(X,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:xe,disabled:oe,children:oe?"退款中...":"确认退款"})]})]})}),s.jsx(Dt,{open:!!_,onOpenChange:L=>!L&&gn(),children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(_t,{children:s.jsx(zt,{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(de,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:H,onChange:L=>K(L.target.value)})})]})]}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:gn,disabled:me,children:"取消"}),s.jsx(X,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:$n,disabled:me||!H.trim(),children:me?"提交中...":"确认拒绝"})]})]})}),e==="settings"&&s.jsx("div",{className:"-mx-8 -mt-6",children:s.jsx(f2,{embedded:!0})})]})}function b8(){const[t,e]=b.useState([]),[n,r]=b.useState({total:0,pendingCount:0,pendingAmount:0,successCount:0,successAmount:0,failedCount:0}),[a,i]=b.useState(!0),[o,c]=b.useState(null),[u,h]=b.useState("all"),[f,m]=b.useState(1),[g,y]=b.useState(10),[N,w]=b.useState(0),[j,S]=b.useState(null),[E,T]=b.useState(null),[P,O]=b.useState(""),[q,z]=b.useState(!1);async function V(){var J,$,D,R,oe,G,_;i(!0),c(null);try{const U=new URLSearchParams({status:u,page:String(f),pageSize:String(g)}),H=await Pe(`/api/admin/withdrawals?${U}`);if(H!=null&&H.success){const K=H.withdrawals||[];e(K),w(H.total??((J=H.stats)==null?void 0:J.total)??K.length),r({total:(($=H.stats)==null?void 0:$.total)??H.total??K.length,pendingCount:((D=H.stats)==null?void 0:D.pendingCount)??0,pendingAmount:((R=H.stats)==null?void 0:R.pendingAmount)??0,successCount:((oe=H.stats)==null?void 0:oe.successCount)??0,successAmount:((G=H.stats)==null?void 0:G.successAmount)??0,failedCount:((_=H.stats)==null?void 0:_.failedCount)??0})}else c("加载提现记录失败")}catch(U){console.error("Load withdrawals error:",U),c("加载失败,请检查网络后重试")}finally{i(!1)}}b.useEffect(()=>{m(1)},[u]),b.useEffect(()=>{V()},[u,f,g]);const I=Math.ceil(N/g)||1;async function te(J){const $=t.find(D=>D.id===J);if($!=null&&$.userCommissionInfo&&$.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${$.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。 +如有缓存,请刷新前台/小程序页面。`)}catch(f){console.error(f),se.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{c(!1)}},h=f=>m=>{const x=parseFloat(m.target.value||"0");r(y=>({...y,[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(Nc,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置(与系统设置中的「推广功能」开关配合:开关在"," ",s.jsx(bc,{to:"/settings",className:"text-[#38bdac] underline hover:text-[#5ee0d1]",children:"系统设置 → 功能开关"}),")。"]})]}),s.jsxs(X,{onClick:u,disabled:o||a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),o?"保存中...":"保存配置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"flex items-center gap-2 text-white",children:[s.jsx(RM,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),s.jsx(Kt,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),s.jsx(Le,{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(ee,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(ch,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),s.jsx(ce,{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(ee,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(In,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(x8,{className:"flex-1",min:10,max:100,step:1,value:[n.distributorShare],onValueChange:([f])=>r(m=>({...m,distributorShare:f}))}),s.jsx(ce,{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(ee,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(ch,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),s.jsx(ce,{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(ee,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(ch,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),s.jsx(ce,{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(ee,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(In,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),s.jsx(ce,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"flex items-center gap-2 text-white",children:[s.jsx(Nc,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),s.jsx(Kt,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),s.jsx(Le,{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(ee,{className:"text-gray-300",children:"最低提现金额(元)"}),s.jsx(ce,{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(ee,{className:"text-gray-300",children:"提现手续费(%)"}),s.jsx(ce,{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(ee,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",s.jsx(Ve,{variant:"outline",className:"border-[#38bdac]/40 text-[#38bdac] text-[10px]",children:"预留"})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[s.jsx($t,{checked:n.enableAutoWithdraw,onCheckedChange:f=>r(m=>({...m,enableAutoWithdraw:f}))}),s.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(rt,{children:s.jsxs(at,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[s.jsx(ch,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),s.jsxs(Le,{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 y8(){const[t]=x0(),[e,n]=b.useState("overview"),[r,a]=b.useState("orders"),[i,o]=b.useState([]),[c,u]=b.useState(null),[h,f]=b.useState([]),[m,x]=b.useState([]),[y,N]=b.useState([]),[w,j]=b.useState(!0),[S,E]=b.useState(null),[T,P]=b.useState(""),[O,q]=b.useState("all"),[z,V]=b.useState(1),[I,te]=b.useState(10),[Q,F]=b.useState(0),[re,ie]=b.useState(new Set),[J,$]=b.useState(null),[D,R]=b.useState(""),[oe,G]=b.useState(!1),[_,U]=b.useState(null),[H,K]=b.useState(""),[me,Y]=b.useState(!1),[le,de]=b.useState(!1),[ve,ye]=b.useState(!1),[ke,ze]=b.useState([]),[ft,wt]=b.useState(1),[dt,Rt]=b.useState(0),[Tt,Tn]=b.useState("");b.useEffect(()=>{mn()},[]),b.useEffect(()=>{const L=t.get("tab");(L==="overview"||L==="orders"||L==="bindings"||L==="withdrawals"||L==="settings")&&n(L)},[t]),b.useEffect(()=>{V(1)},[e,O]),b.useEffect(()=>{Ft(e)},[e]),b.useEffect(()=>{if(e==="orders"&&r==="giftpay"){Ft("giftPay",!0);return}["orders","bindings","withdrawals"].includes(e)&&Ft(e,!0)},[z,I,O,T,e,r,ft,Tt]),b.useEffect(()=>{e==="withdrawals"&&St()},[e]);async function mn(){E(null);try{const L=await Pe("/api/admin/distribution/overview");L!=null&&L.success&&L.overview&&u(L.overview)}catch(L){console.error("[Admin] 概览接口异常:",L),E("加载概览失败")}try{const L=await Pe("/api/db/users");N((L==null?void 0:L.users)||[])}catch(L){console.error("[Admin] 用户数据加载失败:",L)}}async function Ft(L,Me=!1){var pt;if(!(!Me&&re.has(L))){j(!0);try{const Et=y;switch(L){case"overview":break;case"orders":{try{const ht=new URLSearchParams({page:String(z),pageSize:String(I),...O!=="all"&&{status:O},...T&&{search:T}}),tt=await Pe(`/api/admin/orders?${ht}`);if(tt!=null&&tt.success&&tt.orders){const Pt=tt.orders.map(Wt=>{const en=Et.find(Qs=>Qs.id===Wt.userId),ts=Wt.referrerId?Et.find(Qs=>Qs.id===Wt.referrerId):null;return{...Wt,amount:parseFloat(String(Wt.amount))||0,userNickname:(en==null?void 0:en.nickname)||Wt.userNickname||"未知用户",userPhone:(en==null?void 0:en.phone)||Wt.userPhone||"-",referrerNickname:(ts==null?void 0:ts.nickname)||null,referrerCode:(ts==null?void 0:ts.referralCode)??null,type:Wt.productType||Wt.type}});o(Pt),F(tt.total??Pt.length)}else o([]),F(0)}catch(ht){console.error(ht),E("加载订单失败"),o([])}break}case"bindings":{try{const ht=new URLSearchParams({page:String(z),pageSize:String(I),...O!=="all"&&{status:O}}),tt=await Pe(`/api/db/distribution?${ht}`);f((tt==null?void 0:tt.bindings)||[]),F((tt==null?void 0:tt.total)??((pt=tt==null?void 0:tt.bindings)==null?void 0:pt.length)??0)}catch(ht){console.error(ht),E("加载绑定数据失败"),f([])}break}case"withdrawals":{try{const ht=O==="completed"?"success":O==="rejected"?"failed":O,tt=new URLSearchParams({...ht&&ht!=="all"&&{status:ht},page:String(z),pageSize:String(I)}),Pt=await Pe(`/api/admin/withdrawals?${tt}`);if(Pt!=null&&Pt.success&&Pt.withdrawals){const Wt=Pt.withdrawals.map(en=>({...en,account:en.account??"未绑定微信号",status:en.status==="success"?"completed":en.status==="failed"?"rejected":en.status}));x(Wt),F((Pt==null?void 0:Pt.total)??Wt.length)}else Pt!=null&&Pt.success||E(`获取提现记录失败: ${(Pt==null?void 0:Pt.error)||"未知错误"}`),x([])}catch(ht){console.error(ht),E("加载提现数据失败"),x([])}break}case"giftPay":{try{const ht=new URLSearchParams({page:String(ft),pageSize:"20",...Tt&&{status:Tt}}),tt=await Pe(`/api/admin/gift-pay-requests?${ht}`);tt!=null&&tt.success&&tt.data?(ze(tt.data),Rt(tt.total??tt.data.length)):(ze([]),Rt(0))}catch(ht){console.error(ht),E("加载代付请求失败"),ze([])}break}}ie(ht=>new Set(ht).add(L))}catch(Et){console.error(Et)}finally{j(!1)}}}async function qt(){E(null),ie(L=>{const Me=new Set(L);return Me.delete(e),e==="orders"&&r==="giftpay"&&Me.delete("giftPay"),Me}),e==="overview"&&mn(),e==="orders"&&r==="giftpay"?await Ft("giftPay",!0):await Ft(e,!0)}async function vn(L){if(confirm("确认审核通过并打款?"))try{const Me=await Gt("/api/admin/withdrawals",{id:L,action:"approve"});if(!(Me!=null&&Me.success)){const pt=(Me==null?void 0:Me.message)||(Me==null?void 0:Me.error)||"操作失败";se.error(pt);return}await qt()}catch(Me){console.error(Me),se.error("操作失败")}}function On(L){U(L),K("")}async function $n(){const L=_;if(!L)return;const Me=H.trim();if(!Me){se.error("请填写拒绝原因");return}Y(!0);try{const pt=await Gt("/api/admin/withdrawals",{id:L,action:"reject",errorMessage:Me});if(!(pt!=null&&pt.success)){se.error((pt==null?void 0:pt.error)||"操作失败");return}se.success("已拒绝该提现申请"),U(null),K(""),await qt()}catch(pt){console.error(pt),se.error("操作失败")}finally{Y(!1)}}async function St(){try{const L=await Pe("/api/admin/withdrawals/auto-approve");L!=null&&L.success&&typeof L.enableAutoApprove=="boolean"&&de(L.enableAutoApprove)}catch{}}async function cn(L){ye(!0);try{const Me=await Gt("/api/admin/withdrawals/auto-approve",{enableAutoApprove:L});Me!=null&&Me.success?(de(L),se.success(L?"已开启自动审批,新提现将自动打款":"已关闭自动审批")):se.error("更新失败: "+((Me==null?void 0:Me.error)??""))}catch{se.error("更新失败")}finally{ye(!1)}}function xn(){_&&se.info("已取消操作"),U(null),K("")}async function ge(){var L;if(!(!(J!=null&&J.orderSn)&&!(J!=null&&J.id))){G(!0),E(null);try{const Me=await Gt("/api/admin/orders/refund",{orderSn:J.orderSn||J.id,reason:D||void 0});Me!=null&&Me.success?($(null),R(""),await Ft("orders",!0)):E((Me==null?void 0:Me.error)||"退款失败")}catch(Me){const pt=Me;E(((L=pt==null?void 0:pt.data)==null?void 0:L.error)||"退款失败,请检查网络后重试")}finally{G(!1)}}}function Se(L){const Me={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"},pt={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return s.jsx(Ve,{className:`${Me[L]||"bg-gray-500/20 text-gray-400"} border-0`,children:pt[L]||L})}const $e=Math.ceil(Q/I)||1,Xe=i,jt=h.filter(L=>{var pt,Et,ht,tt;if(!T)return!0;const Me=T.toLowerCase();return((pt=L.refereeNickname)==null?void 0:pt.toLowerCase().includes(Me))||((Et=L.refereePhone)==null?void 0:Et.includes(Me))||((ht=L.referrerName)==null?void 0:ht.toLowerCase().includes(Me))||((tt=L.referrerCode)==null?void 0:tt.toLowerCase().includes(Me))}),gt=m.filter(L=>{var pt;if(!T)return!0;const Me=T.toLowerCase();return((pt=L.userName)==null?void 0:pt.toLowerCase().includes(Me))||L.account&&L.account.toLowerCase().includes(Me)});return s.jsxs("div",{className:"p-8 w-full",children:[S&&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:S}),s.jsx("button",{type:"button",onClick:()=>E(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-semibold text-white",children:"推广中心"}),s.jsx("p",{className:"text-gray-500 text-sm mt-0.5",children:"分销绑定、提现审核、推广设置"})]}),s.jsxs(X,{onClick:qt,disabled:w,variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[s.jsx(Fe,{className:`w-3.5 h-3.5 mr-1.5 ${w?"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:Gh},{key:"orders",label:"订单与代付",icon:Kh},{key:"bindings",label:"绑定管理",icon:ya},{key:"withdrawals",label:"提现审核",icon:Nc},{key:"settings",label:"推广设置",icon:no}].map(L=>s.jsxs("button",{type:"button",onClick:()=>{n(L.key),q("all"),P(""),L.key!=="orders"&&a("orders")},className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2 rounded-md text-sm transition-all ${e===L.key?"bg-[#38bdac] text-white shadow-md":"text-gray-400 hover:text-white hover:bg-gray-700/40"}`,children:[s.jsx(L.icon,{className:"w-3.5 h-3.5"}),L.label]},L.key))}),w?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Fe,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[e==="overview"&&c&&s.jsxs("div",{className:"space-y-6",children:[s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Le,{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(pi,{className:"w-4 h-4 text-amber-400"}),"推广转化漏斗"]}),s.jsx(X,{type:"button",size:"sm",variant:"ghost",onClick:()=>void qt(),disabled:w,className:"text-gray-400 h-7",children:s.jsx(Fe,{className:`w-3.5 h-3.5 ${w?"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(qh,{className:"w-4 h-4 text-blue-400"}),"点击数"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:c.todayClicks}),s.jsx("td",{className:"py-2.5 text-right",children:c.monthClicks}),s.jsx("td",{className:"py-2.5 text-right",children:c.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(ya,{className:"w-4 h-4 text-green-400"}),"绑定关系"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:c.todayBindings}),s.jsx("td",{className:"py-2.5 text-right",children:c.monthBindings}),s.jsx("td",{className:"py-2.5 text-right",children:c.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(ax,{className:"w-4 h-4 text-purple-400"}),"付款转化"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:c.todayConversions}),s.jsx("td",{className:"py-2.5 text-right",children:c.monthConversions}),s.jsx("td",{className:"py-2.5 text-right",children:c.totalConversions})]}),s.jsxs("tr",{children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(Kh,{className:"w-4 h-4 text-[#38bdac]"}),"佣金收入"]}),s.jsxs("td",{className:"py-2.5 text-right font-bold text-[#38bdac]",children:["¥",(c.todayEarnings??0).toFixed(0)]}),s.jsxs("td",{className:"py-2.5 text-right text-[#38bdac]",children:["¥",(c.monthEarnings??0).toFixed(0)]}),s.jsxs("td",{className:"py-2.5 text-right text-[#38bdac]",children:["¥",(c.totalEarnings??0).toFixed(0)]})]})]})]})}),c.conversionRate&&s.jsxs("p",{className:"text-xs text-gray-500 mt-3 text-right",children:["综合转化率 ",c.conversionRate]})]})}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(Oe,{className:"bg-orange-500/10 border-orange-500/30",children:s.jsx(Le,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(ig,{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:[c.expiringBindings," ",s.jsx("span",{className:"text-sm font-normal text-orange-300/60",children:"个 · 7天内"})]})]})]})})}),s.jsx(Oe,{className:"bg-blue-500/10 border-blue-500/30",children:s.jsx(Le,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Nc,{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:[c.pendingWithdrawals," ",s.jsxs("span",{className:"text-sm font-normal text-blue-300/60",children:["笔 · ¥",(c.pendingWithdrawAmount??0).toFixed(0)]})]})]}),s.jsx(X,{onClick:()=>n("withdrawals"),variant:"outline",size:"sm",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20 shrink-0",children:"去审核"})]})})})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Le,{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(In,{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:c.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(ax,{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:c.activeDistributors}),s.jsx("p",{className:"text-[10px] text-gray-500",children:"有收益用户"})]})]})]})})})]}),e==="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 ${r==="orders"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,onClick:()=>a("orders"),children:"普通订单"}),s.jsxs("button",{type:"button",className:`px-3 py-1.5 rounded-md text-xs font-medium transition-all ${r==="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:()=>{a("giftpay"),Ft("giftPay",!0)},children:[s.jsx(og,{className:"w-3 h-3 inline mr-1"}),"代付请求"]})]}),r==="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(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(ce,{value:T,onChange:L=>P(L.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:O,onChange:L=>q(L.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(X,{type:"button",variant:"outline",onClick:()=>void qt(),disabled:w,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${w?"animate-spin":""}`}),"刷新"]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Le,{className:"p-0",children:[i.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:Xe.map(L=>{var Me,pt;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:[(Me=L.id)==null?void 0:Me.slice(0,12),"..."]}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:L.userNickname}),s.jsx("p",{className:"text-gray-500 text-xs",children:L.userPhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:(()=>{const Et=L.productType||L.type,ht=L.description||"",tt=String(L.productId||L.sectionId||""),Pt=Et==="vip"||ht.includes("VIP")||ht.toLowerCase().includes("vip")||tt.toLowerCase().includes("vip");return Et==="balance_recharge"?`余额充值 ¥${typeof L.amount=="number"?L.amount.toFixed(2):parseFloat(String(L.amount||"0")).toFixed(2)}`:Pt?"超级个体开通费用":Et==="fullbook"?`${L.bookName||"《底层逻辑》"} - 全本`:Et==="match"?"匹配次数购买":`${L.bookName||"《底层逻辑》"} - ${L.sectionTitle||L.chapterTitle||`章节${L.productId||L.sectionId||""}`}`})()}),s.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const Et=L.productType||L.type,ht=L.description||"",tt=String(L.productId||L.sectionId||""),Pt=Et==="vip"||ht.includes("VIP")||ht.toLowerCase().includes("vip")||tt.toLowerCase().includes("vip");return Et==="balance_recharge"?"余额充值":Pt?"超级个体":Et==="fullbook"?"全书解锁":Et==="match"?"功能权益":L.chapterTitle||"单章购买"})()})]})}),s.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof L.amount=="number"?L.amount.toFixed(2):parseFloat(String(L.amount||"0")).toFixed(2)]}),s.jsx("td",{className:"p-4 text-gray-300",children:L.paymentMethod==="wechat"?"微信支付":L.paymentMethod==="balance"?"余额支付":L.paymentMethod==="alipay"?"支付宝":L.paymentMethod||"微信支付"}),s.jsx("td",{className:"p-4",children:L.status==="refunded"?s.jsx(Ve,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):L.status==="completed"||L.status==="paid"?s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):L.status==="pending"||L.status==="created"?s.jsx(Ve,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):s.jsx(Ve,{className:"bg-red-500/20 text-red-400 border-0",children:"已失败"})}),s.jsx("td",{className:"p-4 text-gray-400 text-sm max-w-[120px]",title:L.refundReason,children:L.status==="refunded"&&L.refundReason?L.refundReason:"-"}),s.jsx("td",{className:"p-4 text-gray-300 text-sm",children:L.referrerId||L.referralCode?s.jsxs("span",{title:L.referralCode||L.referrerCode||L.referrerId||"",children:[L.referrerNickname||L.referralCode||L.referrerCode||((pt=L.referrerId)==null?void 0:pt.slice(0,8)),(L.referralCode||L.referrerCode)&&` (${L.referralCode||L.referrerCode})`]}):"-"}),s.jsx("td",{className:"p-4 text-[#FFD700]",children:L.referrerEarnings?`¥${(typeof L.referrerEarnings=="number"?L.referrerEarnings:parseFloat(String(L.referrerEarnings))).toFixed(2)}`:"-"}),s.jsx("td",{className:"p-4 text-gray-400 text-sm",children:L.createdAt?new Date(L.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:(L.status==="paid"||L.status==="completed")&&s.jsxs(X,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{$(L),R("")},children:[s.jsx(Ij,{className:"w-3 h-3 mr-1"}),"退款"]})})]},L.id)})})]})}),e==="orders"&&s.jsx(qs,{page:z,totalPages:$e,total:Q,pageSize:I,onPageChange:V,onPageSizeChange:L=>{te(L),V(1)}})]})})]}),r==="giftpay"&&s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(rt,{children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[s.jsx(at,{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:Tt,onChange:L=>{Tn(L.target.value),wt(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(X,{size:"sm",variant:"outline",onClick:()=>void Ft("giftPay",!0),disabled:w,className:"border-gray-600 text-gray-300",children:[s.jsx(Fe,{className:`w-3.5 h-3.5 mr-1 ${w?"animate-spin":""}`}),"刷新"]})]})]})}),s.jsxs(Le,{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:ke.map(L=>s.jsxs("tr",{className:"hover:bg-[#0a1628]",children:[s.jsx("td",{className:"p-3 font-mono text-xs text-gray-400",children:L.requestSn}),s.jsx("td",{className:"p-3 text-white text-sm",children:L.initiatorNick||L.initiatorUserId}),s.jsxs("td",{className:"p-3",children:[s.jsxs("p",{className:"text-white",children:[L.productType," · ¥",L.amount.toFixed(2)]}),L.description&&s.jsx("p",{className:"text-gray-500 text-xs",children:L.description})]}),s.jsx("td",{className:"p-3 text-gray-400",children:(L.quantity??1)>1?`${L.quantity}份 / 已领${L.redeemedCount??0}`:"-"}),s.jsx("td",{className:"p-3 text-gray-400",children:L.payerNick||(L.payerUserId?L.payerUserId:"-")}),s.jsx("td",{className:"p-3",children:s.jsx(Ve,{className:L.status==="paid"?"bg-green-500/20 text-green-400 border-0":L.status==="pending"||L.status==="pending_pay"?"bg-amber-500/20 text-amber-400 border-0":L.status==="refunded"?"bg-red-500/20 text-red-400 border-0":"bg-gray-500/20 text-gray-400 border-0",children:L.status==="paid"?"已支付":L.status==="pending"||L.status==="pending_pay"?"待支付":L.status==="refunded"?"已退款":L.status==="cancelled"?"已取消":"已过期"})}),s.jsx("td",{className:"p-3 text-gray-400 text-xs",children:L.createdAt?new Date(L.createdAt).toLocaleString("zh-CN"):"-"})]},L.id))})]})}),ke.length===0&&!w&&s.jsx("p",{className:"text-center py-8 text-gray-500",children:"暂无代付请求"}),dt>20&&s.jsx("div",{className:"mt-4 flex justify-center",children:s.jsx(qs,{page:ft,totalPages:Math.ceil(dt/20),total:dt,pageSize:20,onPageChange:wt,onPageSizeChange:()=>{}})})]})]})]}),e==="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(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(ce,{value:T,onChange:L=>P(L.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:O,onChange:L=>q(L.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(X,{type:"button",variant:"outline",onClick:()=>void qt(),disabled:w,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${w?"animate-spin":""}`}),"刷新"]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Le,{className:"p-0",children:[jt.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:jt.map(L=>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:L.refereeNickname||"匿名用户"}),s.jsx("p",{className:"text-gray-500 text-xs",children:L.refereePhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:L.referrerName||"-"}),s.jsx("p",{className:"text-gray-500 text-xs font-mono",children:L.referrerCode})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:L.boundAt?new Date(L.boundAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:L.expiresAt?new Date(L.expiresAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:Se(L.status)}),s.jsx("td",{className:"p-4",children:L.commission?s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",L.commission.toFixed(2)]}):s.jsx("span",{className:"text-gray-500",children:"-"})})]},L.id))})]})}),e==="bindings"&&s.jsx(qs,{page:z,totalPages:$e,total:Q,pageSize:I,onPageChange:V,onPageSizeChange:L=>{te(L),V(1)}})]})})]}),e==="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(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(ce,{value:T,onChange:L=>P(L.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:O,onChange:L=>q(L.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(pi,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-sm text-gray-300",children:"自动审批"}),s.jsx($t,{checked:le,onCheckedChange:cn,disabled:ve,className:"data-[state=checked]:bg-[#38bdac]"})]}),s.jsxs(X,{type:"button",variant:"outline",onClick:()=>void qt(),disabled:w,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${w?"animate-spin":""}`}),"刷新"]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Le,{className:"p-0",children:[gt.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:gt.map(L=>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:[L.userAvatar?s.jsx("img",{src:L.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:(L.userName||L.name||"?").slice(0,1)}),s.jsx("p",{className:"text-white font-medium",children:L.userName||L.name})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",L.amount.toFixed(2)]})}),s.jsx("td",{className:"p-4",children:s.jsx(Ve,{className:L.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:L.method==="wechat"?"微信":"支付宝"})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-mono text-xs",children:L.account}),s.jsx("p",{className:"text-gray-500 text-xs",children:L.name})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:L.createdAt?new Date(L.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:Se(L.status)}),s.jsx("td",{className:"p-4 max-w-[160px]",children:s.jsx("span",{className:`text-xs ${L.status==="rejected"||L.status==="failed"?"text-red-400":"text-gray-400"}`,title:L.remark,children:L.remark||"-"})}),s.jsx("td",{className:"p-4 text-right",children:L.status==="pending"&&s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsxs(X,{size:"sm",onClick:()=>vn(L.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(ax,{className:"w-4 h-4 mr-1"}),"通过"]}),s.jsxs(X,{size:"sm",variant:"outline",onClick:()=>On(L.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[s.jsx(Sj,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},L.id))})]})}),e==="withdrawals"&&s.jsx(qs,{page:z,totalPages:$e,total:Q,pageSize:I,onPageChange:V,onPageSizeChange:L=>{te(L),V(1)}})]})})]})]}),s.jsx(Dt,{open:!!J,onOpenChange:L=>!L&&$(null),children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(_t,{children:s.jsx(zt,{className:"text-white",children:"订单退款"})}),J&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",J.orderSn||J.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof J.amount=="number"?J.amount.toFixed(2):parseFloat(String(J.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(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:D,onChange:L=>R(L.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>$(null),disabled:oe,children:"取消"}),s.jsx(X,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:ge,disabled:oe,children:oe?"退款中...":"确认退款"})]})]})}),s.jsx(Dt,{open:!!_,onOpenChange:L=>!L&&xn(),children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(_t,{children:s.jsx(zt,{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(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:H,onChange:L=>K(L.target.value)})})]})]}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:xn,disabled:me,children:"取消"}),s.jsx(X,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:$n,disabled:me||!H.trim(),children:me?"提交中...":"确认拒绝"})]})]})}),e==="settings"&&s.jsx("div",{className:"-mx-8 -mt-6",children:s.jsx(f2,{embedded:!0})})]})}function b8(){const[t,e]=b.useState([]),[n,r]=b.useState({total:0,pendingCount:0,pendingAmount:0,successCount:0,successAmount:0,failedCount:0}),[a,i]=b.useState(!0),[o,c]=b.useState(null),[u,h]=b.useState("all"),[f,m]=b.useState(1),[x,y]=b.useState(10),[N,w]=b.useState(0),[j,S]=b.useState(null),[E,T]=b.useState(null),[P,O]=b.useState(""),[q,z]=b.useState(!1);async function V(){var J,$,D,R,oe,G,_;i(!0),c(null);try{const U=new URLSearchParams({status:u,page:String(f),pageSize:String(x)}),H=await Pe(`/api/admin/withdrawals?${U}`);if(H!=null&&H.success){const K=H.withdrawals||[];e(K),w(H.total??((J=H.stats)==null?void 0:J.total)??K.length),r({total:(($=H.stats)==null?void 0:$.total)??H.total??K.length,pendingCount:((D=H.stats)==null?void 0:D.pendingCount)??0,pendingAmount:((R=H.stats)==null?void 0:R.pendingAmount)??0,successCount:((oe=H.stats)==null?void 0:oe.successCount)??0,successAmount:((G=H.stats)==null?void 0:G.successAmount)??0,failedCount:((_=H.stats)==null?void 0:_.failedCount)??0})}else c("加载提现记录失败")}catch(U){console.error("Load withdrawals error:",U),c("加载失败,请检查网络后重试")}finally{i(!1)}}b.useEffect(()=>{m(1)},[u]),b.useEffect(()=>{V()},[u,f,x]);const I=Math.ceil(N/x)||1;async function te(J){const $=t.find(D=>D.id===J);if($!=null&&$.userCommissionInfo&&$.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${$.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。 -确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;S(J);try{const D=await Gt("/api/admin/withdrawals",{id:J,action:"approve"});D!=null&&D.success?V():se.error("操作失败: "+((D==null?void 0:D.error)??""))}catch{se.error("操作失败")}finally{S(null)}}function Q(J){T(J),O("")}async function F(){const J=E;if(!J)return;const $=P.trim();if(!$){se.error("请填写拒绝原因");return}z(!0);try{const D=await Gt("/api/admin/withdrawals",{id:J,action:"reject",errorMessage:$});D!=null&&D.success?(se.success("已拒绝该提现申请"),T(null),O(""),V()):se.error("操作失败: "+((D==null?void 0:D.error)??""))}catch{se.error("操作失败")}finally{z(!1)}}function re(){E&&se.info("已取消操作"),T(null),O("")}function ae(J){switch(J){case"pending":return s.jsx(Ve,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return s.jsx(Ve,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return s.jsx(Ve,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return s.jsx(Ve,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return s.jsx(Ve,{className:"bg-gray-500/20 text-gray-400 border-0",children:J})}}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(X,{variant:"outline",onClick:V,disabled:a,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"刷新"]})]}),s.jsx(Oe,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:s.jsx(Le,{className:"p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Kh,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Le,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Le,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Le,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Le,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-red-400",children:n.failedCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"已拒绝"})]})})]}),s.jsx("div",{className:"flex gap-2 mb-4",children:["all","pending","success","failed"].map(J=>s.jsx(X,{variant:u===J?"default":"outline",size:"sm",onClick:()=>h(J),className:u===J?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:J==="all"?"全部":J==="pending"?"待处理":J==="success"?"已完成":"已拒绝"},J))}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:a?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Fe,{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(Nc,{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(J=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4 text-gray-400",children:new Date(J.createdAt??"").toLocaleString()}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[J.userAvatar?s.jsx("img",{src:fo(J.userAvatar),alt:J.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:(J.userName??"?").charAt(0)}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:J.userName??"未知"}),s.jsx("p",{className:"text-xs text-gray-500",children:J.userPhone??J.referralCode??(J.userId??"").slice(0,10)})]})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(J.amount).toFixed(2)]})}),s.jsx("td",{className:"p-4",children:J.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:["¥",J.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:["¥",J.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:["¥",J.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:J.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",J.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):s.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),s.jsx("td",{className:"p-4",children:ae(J.status)}),s.jsx("td",{className:"p-4 max-w-[180px]",children:s.jsx("span",{className:`text-xs ${J.status==="rejected"||J.status==="failed"?"text-red-400":"text-gray-400"}`,title:J.remark,children:J.remark||"-"})}),s.jsx("td",{className:"p-4 text-gray-400",children:J.processedAt?new Date(J.processedAt).toLocaleString():"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:J.userConfirmedAt?s.jsxs("span",{className:"text-green-400",title:J.userConfirmedAt,children:["已确认 ",new Date(J.userConfirmedAt).toLocaleString()]}):"-"}),s.jsxs("td",{className:"p-4 text-right",children:[(J.status==="pending"||J.status==="pending_confirm")&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(X,{size:"sm",onClick:()=>te(J.id),disabled:j===J.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[s.jsx(Zf,{className:"w-4 h-4 mr-1"}),"批准"]}),s.jsxs(X,{size:"sm",variant:"outline",onClick:()=>Q(J.id),disabled:j===J.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(Yn,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(J.status==="success"||J.status==="completed")&&J.transactionId&&s.jsx("span",{className:"text-xs text-gray-500 font-mono",children:J.transactionId})]})]},J.id))})]})}),s.jsx(Ks,{page:f,totalPages:I,total:N,pageSize:g,onPageChange:m,onPageSizeChange:J=>{y(J),m(1)}})]})})}),s.jsx(Dt,{open:!!E,onOpenChange:J=>!J&&re(),children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(_t,{children:s.jsx(zt,{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(de,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:P,onChange:J=>O(J.target.value)})})]})]}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:re,disabled:q,children:"取消"}),s.jsx(X,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:F,disabled:q||!P.trim(),children:q?"提交中...":"确认拒绝"})]})]})})]})}var yg={exports:{}},bg={};/** +确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;S(J);try{const D=await Gt("/api/admin/withdrawals",{id:J,action:"approve"});D!=null&&D.success?V():se.error("操作失败: "+((D==null?void 0:D.error)??""))}catch{se.error("操作失败")}finally{S(null)}}function Q(J){T(J),O("")}async function F(){const J=E;if(!J)return;const $=P.trim();if(!$){se.error("请填写拒绝原因");return}z(!0);try{const D=await Gt("/api/admin/withdrawals",{id:J,action:"reject",errorMessage:$});D!=null&&D.success?(se.success("已拒绝该提现申请"),T(null),O(""),V()):se.error("操作失败: "+((D==null?void 0:D.error)??""))}catch{se.error("操作失败")}finally{z(!1)}}function re(){E&&se.info("已取消操作"),T(null),O("")}function ie(J){switch(J){case"pending":return s.jsx(Ve,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return s.jsx(Ve,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return s.jsx(Ve,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return s.jsx(Ve,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return s.jsx(Ve,{className:"bg-gray-500/20 text-gray-400 border-0",children:J})}}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(X,{variant:"outline",onClick:V,disabled:a,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"刷新"]})]}),s.jsx(Oe,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:s.jsx(Le,{className:"p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Kh,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Le,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Le,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Le,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Le,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-red-400",children:n.failedCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"已拒绝"})]})})]}),s.jsx("div",{className:"flex gap-2 mb-4",children:["all","pending","success","failed"].map(J=>s.jsx(X,{variant:u===J?"default":"outline",size:"sm",onClick:()=>h(J),className:u===J?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:J==="all"?"全部":J==="pending"?"待处理":J==="success"?"已完成":"已拒绝"},J))}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:a?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Fe,{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(Nc,{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(J=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4 text-gray-400",children:new Date(J.createdAt??"").toLocaleString()}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[J.userAvatar?s.jsx("img",{src:fo(J.userAvatar),alt:J.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:(J.userName??"?").charAt(0)}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:J.userName??"未知"}),s.jsx("p",{className:"text-xs text-gray-500",children:J.userPhone??J.referralCode??(J.userId??"").slice(0,10)})]})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(J.amount).toFixed(2)]})}),s.jsx("td",{className:"p-4",children:J.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:["¥",J.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:["¥",J.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:["¥",J.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:J.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",J.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):s.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),s.jsx("td",{className:"p-4",children:ie(J.status)}),s.jsx("td",{className:"p-4 max-w-[180px]",children:s.jsx("span",{className:`text-xs ${J.status==="rejected"||J.status==="failed"?"text-red-400":"text-gray-400"}`,title:J.remark,children:J.remark||"-"})}),s.jsx("td",{className:"p-4 text-gray-400",children:J.processedAt?new Date(J.processedAt).toLocaleString():"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:J.userConfirmedAt?s.jsxs("span",{className:"text-green-400",title:J.userConfirmedAt,children:["已确认 ",new Date(J.userConfirmedAt).toLocaleString()]}):"-"}),s.jsxs("td",{className:"p-4 text-right",children:[(J.status==="pending"||J.status==="pending_confirm")&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(X,{size:"sm",onClick:()=>te(J.id),disabled:j===J.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[s.jsx(Zf,{className:"w-4 h-4 mr-1"}),"批准"]}),s.jsxs(X,{size:"sm",variant:"outline",onClick:()=>Q(J.id),disabled:j===J.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(Yn,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(J.status==="success"||J.status==="completed")&&J.transactionId&&s.jsx("span",{className:"text-xs text-gray-500 font-mono",children:J.transactionId})]})]},J.id))})]})}),s.jsx(qs,{page:f,totalPages:I,total:N,pageSize:x,onPageChange:m,onPageSizeChange:J=>{y(J),m(1)}})]})})}),s.jsx(Dt,{open:!!E,onOpenChange:J=>!J&&re(),children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(_t,{children:s.jsx(zt,{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(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:P,onChange:J=>O(J.target.value)})})]})]}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:re,disabled:q,children:"取消"}),s.jsx(X,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:F,disabled:q||!P.trim(),children:q?"提交中...":"确认拒绝"})]})]})})]})}var yx={exports:{}},bx={};/** * @license React * use-sync-external-store-shim.production.js * @@ -671,19 +671,19 @@ For more information, see https://radix-ui.com/primitives/docs/components/${e.do * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var z1;function v8(){if(z1)return bg;z1=1;var t=ru();function e(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,a=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function c(m,g){var y=g(),N=r({inst:{value:y,getSnapshot:g}}),w=N[0].inst,j=N[1];return i(function(){w.value=y,w.getSnapshot=g,u(w)&&j({inst:w})},[m,y,g]),a(function(){return u(w)&&j({inst:w}),m(function(){u(w)&&j({inst:w})})},[m]),o(y),y}function u(m){var g=m.getSnapshot;m=m.value;try{var y=g();return!n(m,y)}catch{return!0}}function h(m,g){return g()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return bg.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,bg}var $1;function p2(){return $1||($1=1,yg.exports=v8()),yg.exports}var m2=p2();function is(t){this.content=t}is.prototype={constructor:is,find:function(t){for(var e=0;e>1}};is.from=function(t){if(t instanceof is)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new is(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 x2(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 Ne(r,a)}cutByIndex(e,n){return e==n?Ne.empty:e==0&&n==this.content.length?this:new Ne(this.content.slice(e,n))}replaceChild(e,n){let 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 Ne(a,i)}addToStart(e){return new Ne([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Ne(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let a=this.child(n),i=r+a.nodeSize;if(i>=e)return i==e?yh(n+1,i):yh(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 Ne.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Ne(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Ne.empty;let n,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}};Zt.none=[];class sf extends Error{}class _e{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=b2(this.content,e+this.openStart,n);return r&&new _e(r,this.openStart,this.openEnd)}removeBetween(e,n){return new _e(y2(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 _e.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 _e(Ne.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 _e(e,r,a)}}_e.empty=new _e(Ne.empty,0,0);function y2(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(y2(i.content,e-a-1,n-a-1)))}function b2(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=b2(o.content,e-i-1,n,o);return c&&t.replaceChild(a,o.copy(c))}function N8(t,e,n){if(n.openStart>t.depth)throw new sf("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new sf("Inconsistent open depths");return v2(t,e,n,0)}function v2(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 Id(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&&(sl(t.nodeAfter,r),i++));for(let c=i;ca&&vx(t,e,a+1),o=r.depth>a&&vx(n,r,a+1),c=[];return Id(null,t,a,c),i&&o&&e.index(a)==n.index(a)?(N2(i,o),sl(rl(i,w2(t,e,n,r,a+1)),c)):(i&&sl(rl(i,rf(t,e,a+1)),c),Id(e,n,a,c),o&&sl(rl(o,rf(n,r,a+1)),c)),Id(r,null,a,c),new Ne(c)}function rf(t,e,n){let r=[];if(Id(null,t,n,r),t.depth>n){let a=vx(t,e,n+1);sl(rl(a,rf(t,e,n+1)),r)}return Id(e,null,n,r),new Ne(r)}function w8(t,e){let n=e.depth-t.openStart,a=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)a=e.node(i).copy(Ne.from(a));return{start:a.resolveNoCache(t.openStart+n),end:a.resolveNoCache(a.content.size-t.openEnd-n)}}class Wd{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 af(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 Wd(n,r,i)}static resolveCached(e,n){let r=F1.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()+")"),j2(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=Ne.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=Ne.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,a,r);return i.type.checkAttrs(i.attrs),i}};di.prototype.text=void 0;class of extends di{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):j2(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 of(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new of(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 j2(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class fl{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new C8(e,n);if(r.next==null)return fl.empty;let a=k2(r);r.next&&r.err("Unexpected trailing text");let i=P8(R8(a));return O8(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(` -`)}}fl.empty=new fl(!0);class C8{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 k2(t){let e=[];do e.push(T8(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function T8(t){let e=[];do e.push(E8(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function E8(t){let e=I8(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=M8(t,e);else break;return e}function B1(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function M8(t,e){let n=B1(t),r=n;return t.eat(",")&&(t.next!="}"?r=B1(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function A8(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 I8(t){if(t.eat("(")){let e=k2(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=A8(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 R8(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 fl(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:T2(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new di(this,this.computeAttrs(e),Ne.from(n),Zt.setFrom(r))}createChecked(e=null,n,r){return n=Ne.from(n),this.checkContent(n),new di(this,this.computeAttrs(e),n,Zt.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=Ne.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let a=this.contentMatch.matchFragment(n),i=a&&a.fillBefore(Ne.empty,!0);return i?new di(this,e,n.append(i),Zt.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 A2(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 L8(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 D8{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?L8(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class op{constructor(e,n,r,a){this.name=e,this.rank=n,this.schema=r,this.spec=a,this.attrs=M2(e,a.attrs),this.excluded=null;let i=C2(this.attrs);this.instance=i?new Zt(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Zt(this,T2(this.attrs,e))}static compile(e,n){let r=Object.create(null),a=0;return e.forEach((i,o)=>r[i]=new op(i,a++,n,o)),r}removeFromSet(e){for(var n=0;n-1}}class I2{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=is.from(e.nodes),n.marks=is.from(e.marks||{}),this.nodes=H1.compile(this.spec.nodes,this),this.marks=op.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]=fl.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?U1(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==""?[]:U1(this,o.split(" "))}this.nodeFromJSON=a=>di.fromJSON(this,a),this.markFromJSON=a=>Zt.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 H1){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 of(r,r.defaultAttrs,e,Zt.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 U1(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 _8(t){return t.tag!=null}function z8(t){return t.style!=null}class lo{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(a=>{if(_8(a))this.tags.push(a);else if(z8(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 K1(this,n,!1);return r.addAll(e,Zt.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new K1(this,n,!0);return r.addAll(e,Zt.none,n.from,n.to),_e.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=q1(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=q1(o)),o.node||o.ignore||o.mark||(o.node=a)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new lo(e,lo.schemaRules(e)))}}const R2={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},$8={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},P2={ol:!0,ul:!0},Kd=1,wx=2,Rd=4;function W1(t,e,n){return e!=null?(e?Kd:0)|(e==="full"?wx:0):t&&t.whitespace=="pre"?Kd|wx:n&~Rd}class bh{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=Zt.none,this.match=i||(o&Rd?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Ne.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let 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&Kd)){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=Ne.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Ne.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!R2.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class K1{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=W1(null,n.preserveWhitespace,0)|(r?Rd:0);a?i=new bh(a.type,a.attrs,Zt.none,!0,n.topMatch||a.type.contentMatch,o):r?i=new bh(null,null,Zt.none,!0,null,o):i=new bh(e.schema.topNodeType,null,Zt.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&wx?"full":this.localPreserveWS||(a.options&Kd)>0,{schema:o}=this.parser;if(i==="full"||a.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,` + */var z1;function v8(){if(z1)return bx;z1=1;var t=ru();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 y=x(),N=r({inst:{value:y,getSnapshot:x}}),w=N[0].inst,j=N[1];return i(function(){w.value=y,w.getSnapshot=x,u(w)&&j({inst:w})},[m,y,x]),a(function(){return u(w)&&j({inst:w}),m(function(){u(w)&&j({inst:w})})},[m]),o(y),y}function u(m){var x=m.getSnapshot;m=m.value;try{var y=x();return!n(m,y)}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 bx.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,bx}var $1;function p2(){return $1||($1=1,yx.exports=v8()),yx.exports}var m2=p2();function is(t){this.content=t}is.prototype={constructor:is,find:function(t){for(var e=0;e>1}};is.from=function(t){if(t instanceof is)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new is(e)};function x2(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=x2(a.content,i.content,n+1);if(o!=null)return o}n+=a.nodeSize}}function g2(t,e,n,r){for(let a=t.childCount,i=e.childCount;;){if(a==0||i==0)return a==i?null:{a:n,b:r};let o=t.child(--a),c=e.child(--i),u=o.nodeSize;if(o==c){n-=u,r-=u;continue}if(!o.sameMarkup(c))return{a:n,b:r};if(o.isText&&o.text!=c.text){let h=0,f=Math.min(o.text.length,c.text.length);for(;he&&r(u,a+c,i||null,o)!==!1&&u.content.size){let f=c+1;u.nodesBetween(Math.max(0,e-f),Math.min(u.content.size,n-f),r,a+f)}c=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,a){let i="",o=!0;return this.nodesBetween(e,n,(c,u)=>{let h=c.isText?c.text.slice(Math.max(e,u)-u,n-u):c.isLeaf?a?typeof a=="function"?a(c):a:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&h||c.isTextblock)&&r&&(o?o=!1:i+=r),i+=h},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,a=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(a[a.length-1]=n.withText(n.text+r.text),i=1);ie)for(let i=0,o=0;oe&&((on)&&(c.isText?c=c.cut(Math.max(0,e-o),Math.min(c.text.length,n-o)):c=c.cut(Math.max(0,e-o-1),Math.min(c.content.size,n-o-1))),r.push(c),a+=c.nodeSize),o=u}return new Ne(r,a)}cutByIndex(e,n){return e==n?Ne.empty:e==0&&n==this.content.length?this:new Ne(this.content.slice(e,n))}replaceChild(e,n){let 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 Ne(a,i)}addToStart(e){return new Ne([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Ne(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let a=this.child(n),i=r+a.nodeSize;if(i>=e)return i==e?yh(n+1,i):yh(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 Ne.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Ne(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Ne.empty;let n,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}};Zt.none=[];class sf extends Error{}class _e{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=b2(this.content,e+this.openStart,n);return r&&new _e(r,this.openStart,this.openEnd)}removeBetween(e,n){return new _e(y2(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 _e.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 _e(Ne.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 _e(e,r,a)}}_e.empty=new _e(Ne.empty,0,0);function y2(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(y2(i.content,e-a-1,n-a-1)))}function b2(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=b2(o.content,e-i-1,n,o);return c&&t.replaceChild(a,o.copy(c))}function N8(t,e,n){if(n.openStart>t.depth)throw new sf("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new sf("Inconsistent open depths");return v2(t,e,n,0)}function v2(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 Id(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&&(sl(t.nodeAfter,r),i++));for(let c=i;ca&&vg(t,e,a+1),o=r.depth>a&&vg(n,r,a+1),c=[];return Id(null,t,a,c),i&&o&&e.index(a)==n.index(a)?(N2(i,o),sl(rl(i,w2(t,e,n,r,a+1)),c)):(i&&sl(rl(i,rf(t,e,a+1)),c),Id(e,n,a,c),o&&sl(rl(o,rf(n,r,a+1)),c)),Id(r,null,a,c),new Ne(c)}function rf(t,e,n){let r=[];if(Id(null,t,n,r),t.depth>n){let a=vg(t,e,n+1);sl(rl(a,rf(t,e,n+1)),r)}return Id(e,null,n,r),new Ne(r)}function w8(t,e){let n=e.depth-t.openStart,a=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)a=e.node(i).copy(Ne.from(a));return{start:a.resolveNoCache(t.openStart+n),end:a.resolveNoCache(a.content.size-t.openEnd-n)}}class Wd{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 af(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 Wd(n,r,i)}static resolveCached(e,n){let r=F1.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()+")"),j2(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=Ne.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=Ne.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,a,r);return i.type.checkAttrs(i.attrs),i}};di.prototype.text=void 0;class of extends di{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):j2(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 of(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new of(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 j2(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class fl{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new C8(e,n);if(r.next==null)return fl.empty;let a=k2(r);r.next&&r.err("Unexpected trailing text");let i=P8(R8(a));return O8(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(` +`)}}fl.empty=new fl(!0);class C8{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 k2(t){let e=[];do e.push(T8(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function T8(t){let e=[];do e.push(E8(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function E8(t){let e=I8(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=M8(t,e);else break;return e}function B1(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function M8(t,e){let n=B1(t),r=n;return t.eat(",")&&(t.next!="}"?r=B1(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function A8(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 I8(t){if(t.eat("(")){let e=k2(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=A8(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 R8(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 fl(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:T2(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new di(this,this.computeAttrs(e),Ne.from(n),Zt.setFrom(r))}createChecked(e=null,n,r){return n=Ne.from(n),this.checkContent(n),new di(this,this.computeAttrs(e),n,Zt.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=Ne.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let a=this.contentMatch.matchFragment(n),i=a&&a.fillBefore(Ne.empty,!0);return i?new di(this,e,n.append(i),Zt.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 A2(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 L8(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 D8{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?L8(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class op{constructor(e,n,r,a){this.name=e,this.rank=n,this.schema=r,this.spec=a,this.attrs=M2(e,a.attrs),this.excluded=null;let i=C2(this.attrs);this.instance=i?new Zt(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Zt(this,T2(this.attrs,e))}static compile(e,n){let r=Object.create(null),a=0;return e.forEach((i,o)=>r[i]=new op(i,a++,n,o)),r}removeFromSet(e){for(var n=0;n-1}}class I2{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=is.from(e.nodes),n.marks=is.from(e.marks||{}),this.nodes=H1.compile(this.spec.nodes,this),this.marks=op.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]=fl.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?U1(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==""?[]:U1(this,o.split(" "))}this.nodeFromJSON=a=>di.fromJSON(this,a),this.markFromJSON=a=>Zt.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 H1){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 of(r,r.defaultAttrs,e,Zt.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 U1(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 _8(t){return t.tag!=null}function z8(t){return t.style!=null}class lo{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(a=>{if(_8(a))this.tags.push(a);else if(z8(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 K1(this,n,!1);return r.addAll(e,Zt.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new K1(this,n,!0);return r.addAll(e,Zt.none,n.from,n.to),_e.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=q1(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=q1(o)),o.node||o.ignore||o.mark||(o.node=a)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new lo(e,lo.schemaRules(e)))}}const R2={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},$8={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},P2={ol:!0,ul:!0},Kd=1,wg=2,Rd=4;function W1(t,e,n){return e!=null?(e?Kd:0)|(e==="full"?wg:0):t&&t.whitespace=="pre"?Kd|wg:n&~Rd}class bh{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=Zt.none,this.match=i||(o&Rd?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Ne.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let 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&Kd)){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=Ne.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Ne.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!R2.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class K1{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=W1(null,n.preserveWhitespace,0)|(r?Rd:0);a?i=new bh(a.type,a.attrs,Zt.none,!0,n.topMatch||a.type.contentMatch,o):r?i=new bh(null,null,Zt.none,!0,null,o):i=new bh(e.schema.topNodeType,null,Zt.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&wg?"full":this.localPreserveWS||(a.options&Kd)>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):G1(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new bh(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|=Kd)}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 F8(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&P2.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function B8(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function q1(t){let e={};for(let n in t)e[n]=t[n];return e}function G1(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&&_h(Ng(r),a(e,n),null,e.attrs)}static renderSpec(e,n,r=null,a){return _h(e,n,r,a)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new jl(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=J1(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return J1(e.marks)}}function J1(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Ng(t){return t.document||window.document}const Q1=new WeakMap;function V8(t){let e=Q1.get(t);return e===void 0&&Q1.set(t,e=H8(t)),e}function H8(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let a=0;a-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=a.indexOf(" ");o>0&&(n=a.slice(0,o),a=a.slice(o+1));let c,u=n?t.createElementNS(n,a):t.createElement(a),h=e[1],f=1;if(h&&typeof h=="object"&&h.nodeType==null&&!Array.isArray(h)){f=2;for(let m in h)if(h[m]!=null){let g=m.indexOf(" ");g>0?u.setAttributeNS(m.slice(0,g),m.slice(g+1),h[m]):m=="style"&&u.style?u.style.cssText=h[m]:u.setAttribute(m,h[m])}}for(let m=f;mf)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:y,contentDOM:N}=_h(t,g,n,r);if(u.appendChild(y),N){if(c)throw new RangeError("Multiple content holes");c=N}}}return{dom:u,contentDOM:c}}const O2=65535,L2=Math.pow(2,16);function U8(t,e){return t+e*L2}function Y1(t){return t&O2}function W8(t){return(t-(t&O2))/L2}const D2=1,_2=2,zh=4,z2=8;class jx{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&z2)>0}get deletedBefore(){return(this.delInfo&(D2|zh))>0}get deletedAfter(){return(this.delInfo&(_2|zh))>0}get deletedAcross(){return(this.delInfo&zh)>0}}class ar{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ar.empty)return ar.empty}recover(e){let n=0,r=Y1(e);if(!this.inverted)for(let a=0;ae)break;let h=this.ranges[c+i],f=this.ranges[c+o],m=u+h;if(e<=m){let g=h?e==u?-1:e==m?1:n:n,y=u+a+(g<0?0:f);if(r)return y;let N=e==(n<0?u:m)?null:U8(c/3,e-u),w=e==u?_2:e==m?D2:zh;return(n<0?e!=u:e!=m)&&(w|=z2),new jx(y,w,N)}a+=f-h}return r?e+a:new jx(e+a,0,null)}touches(e,n){let r=0,a=Y1(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 qd;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 _n.fromReplace(e,this.from,this.to,i)}invert(){return new Jr(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 so(n.pos,r.pos,this.mark)}merge(e){return e instanceof so&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new so(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 so(n.from,n.to,e.markFromJSON(n.mark))}}ks.jsonID("addMark",so);class Jr extends ks{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 _e(P0(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),e),n.openStart,n.openEnd);return _n.fromReplace(e,this.from,this.to,r)}invert(){return new so(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 Jr(n.pos,r.pos,this.mark)}merge(e){return e instanceof Jr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Jr(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 Jr(n.from,n.to,e.markFromJSON(n.mark))}}ks.jsonID("removeMark",Jr);class ro extends ks{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return _n.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return _n.fromReplace(e,this.pos,this.pos+1,new _e(Ne.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 Zn(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 Zn(n.from,n.to,n.gapFrom,n.gapTo,_e.fromJSON(e,n.slice),n.insert,!!n.structure)}}ks.jsonID("replaceAround",Zn);function kx(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 K8(t,e,n,r){let a=[],i=[],o,c;t.doc.nodesBetween(e,n,(u,h,f)=>{if(!u.isInline)return;let m=u.marks;if(!r.isInSet(m)&&f.type.allowsMarkType(r.type)){let g=Math.max(h,e),y=Math.min(h+u.nodeSize,n),N=r.addToSet(m);for(let w=0;wt.step(u)),i.forEach(u=>t.step(u))}function q8(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 op){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 Jr(o.from,o.to,o.style)))}function O0(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 G8(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function _c(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=Ne.from(r.node(N).copy(f)),m++):u--;let g=Ne.empty,y=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=Ne.from(n[o].type.create(n[o].attrs,r))}let a=e.start,i=e.end;t.step(new Zn(a,i,a,i,new _e(r,0,0),n.length,!0))}function Z8(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)&&eO(t.doc,t.mapping.slice(i).map(c),r)){let h=null;if(r.schema.linebreakReplacement){let y=r.whitespace=="pre",N=!!r.contentMatch.matchType(r.schema.linebreakReplacement);y&&!N?h=!1:!y&&N&&(h=!0)}h===!1&&F2(t,o,c,i),O0(t,t.mapping.slice(i).map(c,1),r,void 0,h===null);let f=t.mapping.slice(i),m=f.map(c,1),g=f.map(c+o.nodeSize,1);return t.step(new Zn(m,g,m+1,g-1,new _e(Ne.from(r.create(u,null,o.marks)),0,0),1,!0)),h===!0&&$2(t,o,c,i),!1}})}function $2(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 F2(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 eO(t,e,n){let r=t.resolve(e),a=r.index();return r.parent.canReplaceWith(a,a+1,n)}function tO(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 Zn(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new _e(Ne.from(o),0,0),1,!0))}function ui(t,e,n=1,r){let a=t.resolve(e),i=a.depth-n,o=r&&r[r.length-1]||a.parent;if(i<0||a.parent.type.spec.isolating||!a.parent.canReplace(a.index(),a.parent.childCount)||!o.type.validContent(a.parent.content.cutByIndex(a.index(),a.parent.childCount)))return!1;for(let h=a.depth-1,f=n-2;h>i;h--,f--){let m=a.node(h),g=a.index(h);if(m.type.spec.isolating)return!1;let y=m.content.cutByIndex(g,m.childCount),N=r&&r[f+1];N&&(y=y.replaceChild(0,N.type.create(N.attrs)));let w=r&&r[f]||m;if(!m.canReplace(g+1,m.childCount)||!w.type.validContent(y))return!1}let c=a.indexAfter(i),u=r&&r[0];return a.node(i).canReplaceWith(c,c,u?u.type:a.node(i+1).type)}function nO(t,e,n=1,r){let a=t.doc.resolve(e),i=Ne.empty,o=Ne.empty;for(let c=a.depth,u=a.depth-n,h=n-1;c>u;c--,h--){i=Ne.from(a.node(c).copy(i));let f=r&&r[h];o=Ne.from(f?f.type.create(f.attrs,o):a.node(c).copy(o))}t.step(new Xn(e,e,new _e(i.append(o),n,n),!0))}function wo(t,e){let n=t.resolve(e),r=n.index();return B2(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function sO(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&&B2(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 rO(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);F2(t,f.node(),f.before(),c)}o.inlineContent&&O0(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 Xn(h,u.map(e+n,-1),_e.empty,!0)),r===!0){let f=t.doc.resolve(h);$2(t,f.node(),f.before(),t.steps.length)}return t}function aO(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 cp(t,e,n=e,r=_e.empty){if(e==n&&!r.size)return null;let a=t.resolve(e),i=t.resolve(n);return H2(a,i,r)?new Xn(e,n,r):new iO(a,i,r).fit()}function H2(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class iO{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Ne.empty;for(let a=0;a<=e.depth;a++){let i=e.node(a);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(a))})}for(let a=e.depth;a>0;a--)this.placed=Ne.from(e.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let h=this.findFittable();h?this.placeNodes(h):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,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 _e(i,o,c);return e>-1?new Zn(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new Xn(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=jg(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(Ne.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=jg(e,n);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new _e(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=jg(e,n);if(a.childCount<=1&&n>0){let i=e.size-n<=n+a.size;this.unplaced=new _e(wd(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new _e(wd(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=j,f.push(U2(w.mark(g.allowedMarks(w.marks)),h==1?u:0,h==c.childCount?y:-1)))}let N=h==c.childCount;N||(y=-1),this.placed=jd(this.placed,n,Ne.from(f)),this.frontier[n].match=m,N&&y<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,j=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=kg(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=jd(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=jd(this.placed,this.depth,Ne.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Ne.empty,!0);n.childCount&&(this.placed=jd(this.placed,this.frontier.length,n))}}function wd(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(wd(t.firstChild.content,e-1,n)))}function jd(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(jd(t.lastChild.content,e-1,n)))}function jg(t,e){for(let n=0;n1&&(r=r.replaceChild(0,U2(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(Ne.empty,!0)))),t.copy(r)}function kg(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&&!oO(n,i.content,o)?c:null}function oO(t,e,n){for(let r=n;r0;g--,y--){let N=a.node(g).type.spec;if(N.defining||N.definingAsContext||N.isolating)break;o.indexOf(g)>-1?c=g:a.before(g)==y&&o.splice(1,0,-g)}let u=o.indexOf(c),h=[],f=r.openStart;for(let g=r.content,y=0;;y++){let N=g.firstChild;if(h.push(N),y==r.openStart)break;g=N.content}for(let g=f-1;g>=0;g--){let y=h[g],N=lO(y.type);if(N&&!y.sameMarkup(a.node(Math.abs(c)-1)))f=g;else if(N||!y.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let y=(g+f+1)%(r.openStart+1),N=h[y];if(N)for(let w=0;w=0&&(t.replace(e,n,r),!(t.steps.length>m));g--){let y=o[g];y<0||(e=a.before(y),n=i.after(y))}}function W2(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(Ne.empty,!0))}return t}function dO(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let a=aO(t.doc,e,r.type);a!=null&&(e=n=a)}t.replaceRange(e,n,new _e(Ne.from(r),0,0))}function uO(t,e,n){let r=t.doc.resolve(e),a=t.doc.resolve(n),i=K2(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 K2(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let a=r;a>=0;a--){let i=t.start(a);if(ie.pos+(e.depth-a)||t.node(a).type.spec.isolating||e.node(a).type.spec.isolating)break;(i==e.start(a)||a==t.depth&&a==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&a&&e.start(a-1)==i-1)&&n.push(a)}return n}class gc extends ks{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 _n.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 _n.fromReplace(e,this.pos,this.pos+1,new _e(Ne.from(a),0,n.isLeaf?0:1))}getMap(){return ar.empty}invert(e){return new gc(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new gc(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new gc(n.pos,n.attr,n.value)}}ks.jsonID("attr",gc);class Gd extends ks{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 _n.ok(r)}getMap(){return ar.empty}invert(e){return new Gd(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 Gd(n.attr,n.value)}}ks.jsonID("docAttr",Gd);let kc=class extends Error{};kc=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};kc.prototype=Object.create(Error.prototype);kc.prototype.constructor=kc;kc.prototype.name="TransformError";class D0{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new qd}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new kc(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=_e.empty){let a=cp(this.doc,e,n,r);return a&&this.step(a),this}replaceWith(e,n,r){return this.replace(e,n,new _e(Ne.from(r),0,0))}delete(e,n){return this.replace(e,n,_e.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return cO(this,e,n,r),this}replaceRangeWith(e,n,r){return dO(this,e,n,r),this}deleteRange(e,n){return uO(this,e,n),this}lift(e,n){return J8(this,e,n),this}join(e,n=1){return rO(this,e,n),this}wrap(e,n){return X8(this,e,n),this}setBlockType(e,n=e,r,a=null){return Z8(this,e,n,r,a),this}setNodeMarkup(e,n,r=null,a){return tO(this,e,n,r,a),this}setNodeAttribute(e,n,r){return this.step(new gc(e,n,r)),this}setDocAttribute(e,n){return this.step(new Gd(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 Zt)n.isInSet(r.marks)&&this.step(new pl(e,n));else{let a=r.marks,i,o=[];for(;i=n.isInSet(a);)o.push(new pl(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 nO(this,e,n,r),this}addMark(e,n,r){return K8(this,e,n,r),this}removeMark(e,n,r){return q8(this,e,n,r),this}clearIncompatible(e,n,r){return O0(this,e,n,r),this}}const Sg=Object.create(null);class ot{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new q2(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?ac(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):ac(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 or(e.node(0))}static atStart(e){return ac(e,e,0,0,1)||new or(e)}static atEnd(e){return ac(e,e,e.content.size,e.childCount,-1)||new or(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Sg[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 Sg)throw new RangeError("Duplicate use of selection JSON ID "+e);return Sg[e]=n,n.prototype.jsonID=e,n}getBookmark(){return et.between(this.$anchor,this.$head).getBookmark()}}ot.prototype.visible=!0;class q2{constructor(e,n){this.$from=e,this.$to=n}}let Z1=!1;function eN(t){!Z1&&!t.parent.inlineContent&&(Z1=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class et extends ot{constructor(e,n=e){eN(e),eN(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return ot.near(r);let a=e.resolve(n.map(this.anchor));return new et(a.parent.inlineContent?a:r,r)}replace(e,n=_e.empty){if(super.replace(e,n),n==_e.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof et&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new dp(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 et(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=ot.findFrom(n,r,!0)||ot.findFrom(n,-r,!0);if(i)n=i.$head;else return ot.near(n,r)}return e.parent.inlineContent||(a==0?e=n:(e=(ot.findFrom(e,-r,!0)||ot.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&&Ze.isSelectable(c))return Ze.create(t,n-(a<0?c.nodeSize:0))}else{let u=ac(t,c,n+a,a<0?c.childCount:0,a,i);if(u)return u}n+=c.nodeSize*a}return null}function tN(t,e,n){let r=t.steps.length-1;if(r{o==null&&(o=f)}),t.setSelection(ot.near(t.doc.resolve(o),n))}const nN=1,vh=2,sN=4;class fO extends D0{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|=vh,this}ensureMarks(e){return Zt.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&vh)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~vh,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)||Zt.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(ot.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|=sN,this}get scrolledIntoView(){return(this.updated&sN)>0}}function rN(t,e){return!e||!t?t:t.bind(e)}class kd{constructor(e,n,r){this.name=e,this.init=rN(n.init,r),this.apply=rN(n.apply,r)}}const pO=[new kd("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new kd("selection",{init(t,e){return t.selection||ot.atStart(e.doc)},apply(t){return t.selection}}),new kd("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new kd("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Cg{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=pO.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 kd(r.key,r.spec.state,r))})}}class fc{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 Cg(e.schema,e.plugins),i=new fc(a);return a.fields.forEach(o=>{if(o.name=="doc")i.doc=di.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=ot.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 G2(t,e,n){for(let r in t){let a=t[r];a instanceof Function?a=a.bind(e):r=="handleDOMEvents"&&(a=G2(a,e,{})),n[r]=a}return n}class rn{constructor(e){this.spec=e,this.props={},e.props&&G2(e.props,this,this.props),this.key=e.key?e.key.key:J2("plugin")}getState(e){return e[this.key]}}const Tg=Object.create(null);function J2(t){return t in Tg?t+"$"+ ++Tg[t]:(Tg[t]=0,t+"$")}class pn{constructor(e="key"){this.key=J2(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const z0=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Q2(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Y2=(t,e,n)=>{let r=Q2(t,n);if(!r)return!1;let a=$0(r);if(!a){let o=r.blockRange(),c=o&&_c(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let i=a.nodeBefore;if(iS(t,a,e,-1))return!0;if(r.parent.content.size==0&&(Sc(i,"end")||Ze.isSelectable(i)))for(let o=r.depth;;o--){let c=cp(t.doc,r.before(o),r.after(o),_e.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},mO=(t,e,n)=>{let r=Q2(t,n);if(!r)return!1;let a=$0(r);return a?X2(t,a,e):!1},gO=(t,e,n)=>{let r=eS(t,n);if(!r)return!1;let a=F0(r);return a?X2(t,a,e):!1};function X2(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=cp(t.doc,i,u,_e.empty);if(!h||h.from!=i||h instanceof Xn&&h.slice.size>=u-i)return!1;if(n){let f=t.tr.step(h);f.setSelection(et.create(f.doc,i)),n(f.scrollIntoView())}return!0}function Sc(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 Z2=(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=$0(r)}let o=i&&i.nodeBefore;return!o||!Ze.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Ze.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function $0(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 eS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=eS(t,n);if(!r)return!1;let a=F0(r);if(!a)return!1;let i=a.nodeAfter;if(iS(t,a,e,1))return!0;if(r.parent.content.size==0&&(Sc(i,"start")||Ze.isSelectable(i))){let o=cp(t.doc,r.before(),r.after(),_e.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 Ze,a;if(r){if(n.node.isTextblock||!wo(t.doc,n.from))return!1;a=n.from}else if(a=lp(t.doc,n.from,-1),a==null)return!1;if(e){let i=t.tr.join(a);r&&i.setSelection(Ze.create(i.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},yO=(t,e)=>{let n=t.selection,r;if(n instanceof Ze){if(n.node.isTextblock||!wo(t.doc,n.to))return!1;r=n.to}else if(r=lp(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},bO=(t,e)=>{let{$from:n,$to:r}=t.selection,a=n.blockRange(r),i=a&&_c(a);return i==null?!1:(e&&e(t.tr.lift(a,i).scrollIntoView()),!0)},sS=(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 B0(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=B0(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(ot.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},rS=(t,e)=>{let n=t.selection,{$from:r,$to:a}=n;if(n instanceof or||r.parent.inlineContent||a.parent.inlineContent)return!1;let i=B0(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(ui(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),a=r&&_c(r);return a==null?!1:(e&&e(t.tr.lift(r,a).scrollIntoView()),!0)};function NO(t){return(e,n)=>{let{$from:r,$to:a}=e.selection;if(e.selection instanceof Ze&&e.selection.node.isBlock)return!r.parentOffset||!ui(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,c,u=!1,h=!1;for(let y=r.depth;;y--)if(r.node(y).isBlock){u=r.end(y)==r.pos+(r.depth-y),h=r.start(y)==r.pos-(r.depth-y),c=B0(r.node(y-1).contentMatchAt(r.indexAfter(y-1))),i.unshift(u&&c?{type:c}:null),o=y;break}else{if(y==1)return!1;i.unshift(null)}let f=e.tr;(e.selection instanceof et||e.selection instanceof or)&&f.deleteSelection();let m=f.mapping.map(r.pos),g=ui(f.doc,m,i.length,i);if(g||(i[0]=c?{type:c}:null,g=ui(f.doc,m,i.length,i)),!g)return!1;if(f.split(m,i.length,i),!u&&h&&r.node(o).type!=c){let y=f.mapping.map(r.before(o)),N=f.doc.resolve(y);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 wO=NO(),jO=(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(Ze.create(t.doc,a))),!0)};function kO(t,e,n){let r=e.nodeBefore,a=e.nodeAfter,i=e.index();return!r||!a||!r.type.compatibleContent(a.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(a.isTextblock||wo(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function iS(t,e,n,r){let a=e.nodeBefore,i=e.nodeAfter,o,c,u=a.type.spec.isolating||i.type.spec.isolating;if(!u&&kO(t,e,n))return!0;let h=!u&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(o=(c=a.contentMatchAt(a.childCount)).findWrapping(i.type))&&c.matchType(o[0]||i.type).validEnd){if(n){let y=e.pos+i.nodeSize,N=Ne.empty;for(let S=o.length-1;S>=0;S--)N=Ne.from(o[S].create(null,N));N=Ne.from(a.copy(N));let w=t.tr.step(new Zn(e.pos-1,y,e.pos,y,new _e(N,1,0),o.length,!0)),j=w.doc.resolve(y+2*o.length);j.nodeAfter&&j.nodeAfter.type==a.type&&wo(w.doc,j.pos)&&w.join(j.pos),n(w.scrollIntoView())}return!0}let f=i.type.spec.isolating||r>0&&u?null:ot.findFrom(e,1),m=f&&f.$from.blockRange(f.$to),g=m&&_c(m);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(m,g).scrollIntoView()),!0;if(h&&Sc(i,"start",!0)&&Sc(a,"end")){let y=a,N=[];for(;N.push(y),!y.isTextblock;)y=y.lastChild;let w=i,j=1;for(;!w.isTextblock;w=w.firstChild)j++;if(y.canReplace(y.childCount,y.childCount,w.content)){if(n){let S=Ne.empty;for(let T=N.length-1;T>=0;T--)S=Ne.from(N[T].copy(S));let E=t.tr.step(new Zn(e.pos-N.length,e.pos+i.nodeSize,e.pos+j,e.pos+i.nodeSize-j,new _e(S,N.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function oS(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(et.create(e.doc,t<0?a.start(i):a.end(i)))),!0):!1}}const SO=oS(-1),CO=oS(1);function TO(t,e=null){return function(n,r){let{$from:a,$to:i}=n.selection,o=a.blockRange(i),c=o&&L0(o,t,e);return c?(r&&r(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function aN(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 af(u,u,e.depth),e.endIndex=0;f--)i=Ne.from(n[f].type.create(n[f].attrs,i));t.step(new Zn(e.start-(r?2:0),e.end,e.start,e.end,new _e(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?RO(e,n,t,i):PO(e,n,i):!0:!1}}function RO(t,e,n,r){let a=t.tr,i=r.end,o=r.$to.end(r.depth);iw;N--)y-=a.child(N).nodeSize,r.delete(y-1,y+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let c=n.startIndex==0,u=n.endIndex==a.childCount,h=i.node(-1),f=i.index(-1);if(!h.canReplace(f+(c?0:1),f+1,o.content.append(u?Ne.empty:Ne.from(a))))return!1;let m=i.pos,g=m+o.nodeSize;return r.step(new Zn(m-(c?1:0),g+(u?1:0),m+1,g-1,new _e((c?Ne.empty:Ne.from(a.copy(Ne.empty))).append(u?Ne.empty:Ne.from(a.copy(Ne.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function OO(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=Ne.from(h?t.create():null),m=new _e(Ne.from(t.create(null,Ne.from(c.type.create(null,f)))),h?3:1,0),g=i.start,y=i.end;n(e.tr.step(new Zn(g-(h?3:1),y,g,y,m,1,!0)).scrollIntoView())}return!0}}const ls=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Cc=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Sx=null;const ai=function(t,e,n){let r=Sx||(Sx=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},LO=function(){Sx=null},ml=function(t,e,n,r){return n&&(iN(t,e,n,r,-1)||iN(t,e,n,r,1))},DO=/^(img|br|input|textarea|hr)$/i;function iN(t,e,n,r,a){for(var i;;){if(t==n&&e==r)return!0;if(e==(a<0?0:Sr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||cu(t)||DO.test(t.nodeName)||t.contentEditable=="false")return!1;e=ls(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?Sr(t):0}else return!1}}function Sr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function _O(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=Sr(t)}else if(t.parentNode&&!cu(t))e=ls(t),t=t.parentNode;else return null}}function zO(t,e){for(;;){if(t.nodeType==3&&e2),kr=Tc||(wa?/Mac/.test(wa.platform):!1),dS=wa?/Win/.test(wa.platform):!1,ci=/Android \d/.test(jo),du=!!oN&&"webkitFontSmoothing"in oN.documentElement.style,VO=du?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function HO(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 ei(t,e){return typeof t=="number"?t:t[e]}function UO(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 lN(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=Cc(o);continue}let c=o,u=c==i.body,h=u?HO(i):UO(c),f=0,m=0;if(e.toph.bottom-ei(r,"bottom")&&(m=e.bottom-e.top>h.bottom-h.top?e.top+ei(a,"top")-h.top:e.bottom-h.bottom+ei(a,"bottom")),e.lefth.right-ei(r,"right")&&(f=e.right-h.right+ei(a,"right")),f||m)if(u)i.defaultView.scrollBy(f,m);else{let y=c.scrollLeft,N=c.scrollTop;m&&(c.scrollTop+=m),f&&(c.scrollLeft+=f);let w=c.scrollLeft-y,j=c.scrollTop-N;e={left:e.left-w,top:e.top-j,right:e.right-w,bottom:e.bottom-j}}let g=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(g))break;o=g=="absolute"?o.offsetParent:Cc(o)}}function WO(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:uS(t.dom)}}function uS(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Cc(r));return e}function KO({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;hS(n,r==0?0:r-e)}function hS(t,e){for(let n=0;n=c){o=Math.max(N.bottom,o),c=Math.min(N.top,c);let w=N.left>e.left?N.left-e.left:N.right=(N.left+N.right)/2?1:0));continue}}else N.top>e.top&&!u&&N.left<=e.left&&N.right>=e.left&&(u=f,h={left:Math.max(N.left,Math.min(N.right,e.left)),top:N.top});!n&&(e.left>=N.right&&e.top>=N.top||e.left>=N.left&&e.top>=N.bottom)&&(i=m+1)}}return!n&&u&&(n=u,a=h,r=0),n&&n.nodeType==3?GO(n,a):!n||r&&n.nodeType==1?{node:t,offset:i}:fS(n,a)}function GO(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 H0(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function JO(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 YO(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 pS(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&a++}let h;du&&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=YO(t,r,a,e))}c==null&&(c=QO(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function cN(t){return t.top=0&&a==r.nodeValue.length?(u--,f=1):n<0?u--:h++,yd(Gi(ai(r,u,h),f),f<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&a&&(n<0||a==Sr(r))){let u=r.childNodes[a-1];if(u.nodeType==1)return Eg(u.getBoundingClientRect(),!1)}if(i==null&&a=0)}if(i==null&&a&&(n<0||a==Sr(r))){let u=r.childNodes[a-1],h=u.nodeType==3?ai(u,Sr(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(h)return yd(Gi(h,1),!1)}if(i==null&&a=0)}function yd(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 Eg(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=mS(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=ai(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 nL(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(),g=c.caretBidiLevel;c.modify("move",n,"character");let y=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:N,focusOffset:w}=t.domSelectionRange(),j=N&&!y.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 g!=null&&(c.caretBidiLevel=g),j}):r.pos==r.start()||r.pos==r.end()}let dN=null,uN=null,hN=!1;function sL(t,e,n){return dN==e&&uN==n?hN:(dN=e,uN=n,hN=n=="up"||n=="down"?eL(t,e,n):nL(t,e,n))}const Tr=0,fN=1,Zo=2,ja=3;class uu{constructor(e,n,r,a){this.parent=e,this.children=n,this.dom=r,this.contentDOM=a,this.dirty=Tr,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;nls(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 yS){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 xS&&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?ls(i.dom)+1:0}}else{let i,o=!0;for(;i=r=f&&n<=h-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,n,f);e=o;for(let m=c;m>0;m--){let g=this.children[m-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){a=ls(g.dom)+1;break}e-=g.size}a==-1&&(a=0)}if(a>-1&&(h>n||c==this.children.length-1)){n=h;for(let f=c+1;fN&&on){let N=c;c=u,u=N}let y=document.createRange();y.setEnd(u.node,u.offset),y.setStart(c.node,c.offset),h.removeAllRanges(),h.addRange(y)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let 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?Zo:fN,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?Zo:ja}r=o}this.dirty=Zo}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Zo:fN;n.dirty{if(!i)return a;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let c=document.createElement("span");c.appendChild(o),o=c}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==Tr&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class rL extends uu{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 gl extends uu{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=jl.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new gl(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!=Tr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=Ax(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}=jl.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!m&&!n.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),n.type.spec.draggable&&(f.draggable=!0));let g=f;return f=NS(f,r,n),h?u=new aL(e,n,r,a,f,m||null,g,h,i,o+1):n.isText?new hp(e,n,r,a,f,g,i):new uo(e,n,r,a,f,m||null,g,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Ne.empty)}return e}matchesNode(e,n,r){return this.dirty==Tr&&e.eq(this.node)&&lf(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 oL(this,o&&o.node,e);dL(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?Zt.none:this.node.child(f).marks,r,e,f),u.placeWidget(h,e,a)},(h,f,m,g)=>{u.syncToMarks(h.marks,r,e,g);let y;u.findNodeMatch(h,f,m,g)||c&&e.state.selection.from>a&&e.state.selection.to-1&&u.updateNodeAt(h,f,m,y,e)||u.updateNextNode(h,f,m,e,g,a)||u.addNode(h,f,m,e,a),a+=h.nodeSize}),u.syncToMarks([],r,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==Zo)&&(o&&this.protectLocalComposition(e,o),bS(this.contentDOM,this.children,e),Tc&&uL(this.dom))}localCompositionInfo(e,n){let{from:r,to:a}=e.state.selection;if(!(e.state.selection instanceof et)||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=hL(this.node.content,o,r-n,a-n);return c<0?null:{node:i,pos:c,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:a}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new rL(this,i,n,a);e.input.compositionNodes.push(o),this.children=Ax(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=Tr}updateOuterDeco(e){if(lf(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=vS(this.dom,this.nodeDOM,Mx(this.outerDeco,this.node,n),Mx(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 pN(t,e,n,r,a){NS(r,e,t);let i=new uo(void 0,t,e,n,r,r,r,a,0);return i.contentDOM&&i.updateChildren(a,0),i}class hp extends uo{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!=Tr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Tr||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=Tr,!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 hp(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 yS extends uu{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Tr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class aL extends uo{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 bS(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=gl.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 gl)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 cL(t,e){return t.type.side-e.type.side}function dL(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+g.nodeSize;if(g.isText){let j=N;o!j.inline):c.slice();r(g,w,e.forChild(i,g),y),i=N}}function uL(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 hL(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 Ax(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 U0(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(up(n)){for(u=o;a&&!a.node;)a=a.parent;let m=a.node;if(a&&m.isAtom&&Ze.isSelectable(m)&&a.parent&&!(m.isInline&&$O(n.focusNode,n.focusOffset,a.dom))){let g=a.posBefore;h=new Ze(o==g?c:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=o,g=o;for(let y=0;y{(n.anchorNode!=r||n.anchorOffset!=a)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!wS(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function pL(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ls(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Gs&&co<=11&&(n.disabled=!0,n.disabled=!1)}function jS(t,e){if(e instanceof Ze){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(bN(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else bN(t)}function bN(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function W0(t,e,n,r){return t.someProp("createSelectionBetween",a=>a(t,e,n))||et.between(e,n,r)}function vN(t){return t.editable&&!t.hasFocus()?!1:kS(t)}function kS(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 mL(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return ml(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Ix(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&&ot.findFrom(i,e)}function Ji(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function NN(t,e,n){let r=t.state.selection;if(r instanceof et)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 Ji(t,new et(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let a=Ix(t.state,e);return a&&a instanceof Ze?Ji(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?Ze.isSelectable(i)?Ji(t,new Ze(e<0?t.state.doc.resolve(a.pos-i.nodeSize):a)):du?Ji(t,new et(t.state.doc.resolve(e<0?c:c+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ze&&r.node.isInline)return Ji(t,new et(e>0?r.$to:r.$from));{let a=Ix(t.state,e);return a?Ji(t,a):!1}}}function cf(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Od(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function sc(t,e){return e<0?gL(t):xL(t)}function gL(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let a,i,o=!1;for(Cr&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(Od(c,-1))a=n,i=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(SS(n))break;{let c=n.previousSibling;for(;c&&Od(c,-1);)a=n.parentNode,i=ls(c),c=c.previousSibling;if(c)n=c,r=cf(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Rx(t,n,r):a&&Rx(t,a,i)}function xL(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let a=cf(n),i,o;for(;;)if(r{t.state==a&&hi(t)},50)}function wN(t,e){let n=t.state.doc.resolve(e);if(!(fs||dS)&&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 jN(t,e,n){let r=t.state.selection;if(r instanceof et&&!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=Ix(t.state,e);if(o&&o instanceof Ze)return Ji(t,o)}if(!a.parent.inlineContent){let o=e<0?a:i,c=r instanceof or?ot.near(o,e):ot.findFrom(o,e);return c?Ji(t,c):!1}return!1}function kN(t,e){if(!(t.state.selection instanceof et))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 SN(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function vL(t){if(!ws||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;SN(t,r,"true"),setTimeout(()=>SN(t,r,"false"),20)}return!1}function NL(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function wL(t,e){let n=e.keyCode,r=NL(e);if(n==8||kr&&n==72&&r=="c")return kN(t,-1)||sc(t,-1);if(n==46&&!e.shiftKey||kr&&n==68&&r=="c")return kN(t,1)||sc(t,1);if(n==13||n==27)return!0;if(n==37||kr&&n==66&&r=="c"){let a=n==37?wN(t,t.state.selection.from)=="ltr"?-1:1:-1;return NN(t,a,r)||sc(t,a)}else if(n==39||kr&&n==70&&r=="c"){let a=n==39?wN(t,t.state.selection.from)=="ltr"?1:-1:1;return NN(t,a,r)||sc(t,a)}else{if(n==38||kr&&n==80&&r=="c")return jN(t,-1,r)||sc(t,-1);if(n==40||kr&&n==78&&r=="c")return vL(t)||jN(t,1,r)||sc(t,1);if(r==(kr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function K0(t,e){t.someProp("transformCopied",y=>{e=y(e,t)});let n=[],{content:r,openStart:a,openEnd:i}=e;for(;a>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){a--,i--;let y=r.firstChild;n.push(y.type.name,y.attrs!=y.type.defaultAttrs?y.attrs:null),r=y.content}let o=t.someProp("clipboardSerializer")||jl.fromSchema(t.state.schema),c=IS(),u=c.createElement("div");u.appendChild(o.serializeFragment(r,{document:c}));let h=u.firstChild,f,m=0;for(;h&&h.nodeType==1&&(f=AS[h.nodeName.toLowerCase()]);){for(let y=f.length-1;y>=0;y--){let N=c.createElement(f[y]);for(;u.firstChild;)N.appendChild(u.firstChild);u.appendChild(N),m++}h=u.firstChild}h&&h.nodeType==1&&h.setAttribute("data-pm-slice",`${a} ${i}${m?` -${m}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",y=>y(e,t))||e.content.textBetween(0,e.content.size,` +`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let 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):G1(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new bh(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|=Kd)}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 F8(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&P2.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function B8(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function q1(t){let e={};for(let n in t)e[n]=t[n];return e}function G1(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&&_h(Nx(r),a(e,n),null,e.attrs)}static renderSpec(e,n,r=null,a){return _h(e,n,r,a)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new jl(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=J1(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return J1(e.marks)}}function J1(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Nx(t){return t.document||window.document}const Q1=new WeakMap;function V8(t){let e=Q1.get(t);return e===void 0&&Q1.set(t,e=H8(t)),e}function H8(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:y,contentDOM:N}=_h(t,x,n,r);if(u.appendChild(y),N){if(c)throw new RangeError("Multiple content holes");c=N}}}return{dom:u,contentDOM:c}}const O2=65535,L2=Math.pow(2,16);function U8(t,e){return t+e*L2}function Y1(t){return t&O2}function W8(t){return(t-(t&O2))/L2}const D2=1,_2=2,zh=4,z2=8;class jg{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&z2)>0}get deletedBefore(){return(this.delInfo&(D2|zh))>0}get deletedAfter(){return(this.delInfo&(_2|zh))>0}get deletedAcross(){return(this.delInfo&zh)>0}}class ar{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ar.empty)return ar.empty}recover(e){let n=0,r=Y1(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,y=u+a+(x<0?0:f);if(r)return y;let N=e==(n<0?u:m)?null:U8(c/3,e-u),w=e==u?_2:e==m?D2:zh;return(n<0?e!=u:e!=m)&&(w|=z2),new jg(y,w,N)}a+=f-h}return r?e+a:new jg(e+a,0,null)}touches(e,n){let r=0,a=Y1(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 qd;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 _n.fromReplace(e,this.from,this.to,i)}invert(){return new Jr(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 so(n.pos,r.pos,this.mark)}merge(e){return e instanceof so&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new so(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 so(n.from,n.to,e.markFromJSON(n.mark))}}ks.jsonID("addMark",so);class Jr extends ks{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 _e(P0(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),e),n.openStart,n.openEnd);return _n.fromReplace(e,this.from,this.to,r)}invert(){return new so(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 Jr(n.pos,r.pos,this.mark)}merge(e){return e instanceof Jr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Jr(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 Jr(n.from,n.to,e.markFromJSON(n.mark))}}ks.jsonID("removeMark",Jr);class ro extends ks{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return _n.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return _n.fromReplace(e,this.pos,this.pos+1,new _e(Ne.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 Zn(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 Zn(n.from,n.to,n.gapFrom,n.gapTo,_e.fromJSON(e,n.slice),n.insert,!!n.structure)}}ks.jsonID("replaceAround",Zn);function kg(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 K8(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),y=Math.min(h+u.nodeSize,n),N=r.addToSet(m);for(let w=0;wt.step(u)),i.forEach(u=>t.step(u))}function q8(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 op){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 Jr(o.from,o.to,o.style)))}function O0(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 G8(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function _c(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=Ne.from(r.node(N).copy(f)),m++):u--;let x=Ne.empty,y=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=Ne.from(n[o].type.create(n[o].attrs,r))}let a=e.start,i=e.end;t.step(new Zn(a,i,a,i,new _e(r,0,0),n.length,!0))}function Z8(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)&&eO(t.doc,t.mapping.slice(i).map(c),r)){let h=null;if(r.schema.linebreakReplacement){let y=r.whitespace=="pre",N=!!r.contentMatch.matchType(r.schema.linebreakReplacement);y&&!N?h=!1:!y&&N&&(h=!0)}h===!1&&F2(t,o,c,i),O0(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 Zn(m,x,m+1,x-1,new _e(Ne.from(r.create(u,null,o.marks)),0,0),1,!0)),h===!0&&$2(t,o,c,i),!1}})}function $2(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 F2(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 eO(t,e,n){let r=t.resolve(e),a=r.index();return r.parent.canReplaceWith(a,a+1,n)}function tO(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 Zn(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new _e(Ne.from(o),0,0),1,!0))}function ui(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 y=m.content.cutByIndex(x,m.childCount),N=r&&r[f+1];N&&(y=y.replaceChild(0,N.type.create(N.attrs)));let w=r&&r[f]||m;if(!m.canReplace(x+1,m.childCount)||!w.type.validContent(y))return!1}let c=a.indexAfter(i),u=r&&r[0];return a.node(i).canReplaceWith(c,c,u?u.type:a.node(i+1).type)}function nO(t,e,n=1,r){let a=t.doc.resolve(e),i=Ne.empty,o=Ne.empty;for(let c=a.depth,u=a.depth-n,h=n-1;c>u;c--,h--){i=Ne.from(a.node(c).copy(i));let f=r&&r[h];o=Ne.from(f?f.type.create(f.attrs,o):a.node(c).copy(o))}t.step(new Xn(e,e,new _e(i.append(o),n,n),!0))}function wo(t,e){let n=t.resolve(e),r=n.index();return B2(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function sO(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&&B2(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 rO(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);F2(t,f.node(),f.before(),c)}o.inlineContent&&O0(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 Xn(h,u.map(e+n,-1),_e.empty,!0)),r===!0){let f=t.doc.resolve(h);$2(t,f.node(),f.before(),t.steps.length)}return t}function aO(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 cp(t,e,n=e,r=_e.empty){if(e==n&&!r.size)return null;let a=t.resolve(e),i=t.resolve(n);return H2(a,i,r)?new Xn(e,n,r):new iO(a,i,r).fit()}function H2(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class iO{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Ne.empty;for(let a=0;a<=e.depth;a++){let i=e.node(a);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(a))})}for(let a=e.depth;a>0;a--)this.placed=Ne.from(e.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let h=this.findFittable();h?this.placeNodes(h):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,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 _e(i,o,c);return e>-1?new Zn(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new Xn(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=jx(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(Ne.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=jx(e,n);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new _e(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=jx(e,n);if(a.childCount<=1&&n>0){let i=e.size-n<=n+a.size;this.unplaced=new _e(wd(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new _e(wd(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=j,f.push(U2(w.mark(x.allowedMarks(w.marks)),h==1?u:0,h==c.childCount?y:-1)))}let N=h==c.childCount;N||(y=-1),this.placed=jd(this.placed,n,Ne.from(f)),this.frontier[n].match=m,N&&y<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,j=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=kx(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=jd(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=jd(this.placed,this.depth,Ne.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Ne.empty,!0);n.childCount&&(this.placed=jd(this.placed,this.frontier.length,n))}}function wd(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(wd(t.firstChild.content,e-1,n)))}function jd(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(jd(t.lastChild.content,e-1,n)))}function jx(t,e){for(let n=0;n1&&(r=r.replaceChild(0,U2(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(Ne.empty,!0)))),t.copy(r)}function kx(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&&!oO(n,i.content,o)?c:null}function oO(t,e,n){for(let r=n;r0;x--,y--){let N=a.node(x).type.spec;if(N.defining||N.definingAsContext||N.isolating)break;o.indexOf(x)>-1?c=x:a.before(x)==y&&o.splice(1,0,-x)}let u=o.indexOf(c),h=[],f=r.openStart;for(let x=r.content,y=0;;y++){let N=x.firstChild;if(h.push(N),y==r.openStart)break;x=N.content}for(let x=f-1;x>=0;x--){let y=h[x],N=lO(y.type);if(N&&!y.sameMarkup(a.node(Math.abs(c)-1)))f=x;else if(N||!y.type.isTextblock)break}for(let x=r.openStart;x>=0;x--){let y=(x+f+1)%(r.openStart+1),N=h[y];if(N)for(let w=0;w=0&&(t.replace(e,n,r),!(t.steps.length>m));x--){let y=o[x];y<0||(e=a.before(y),n=i.after(y))}}function W2(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(Ne.empty,!0))}return t}function dO(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let a=aO(t.doc,e,r.type);a!=null&&(e=n=a)}t.replaceRange(e,n,new _e(Ne.from(r),0,0))}function uO(t,e,n){let r=t.doc.resolve(e),a=t.doc.resolve(n),i=K2(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 K2(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 xc extends ks{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 _n.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 _n.fromReplace(e,this.pos,this.pos+1,new _e(Ne.from(a),0,n.isLeaf?0:1))}getMap(){return ar.empty}invert(e){return new xc(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 xc(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 xc(n.pos,n.attr,n.value)}}ks.jsonID("attr",xc);class Gd extends ks{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 _n.ok(r)}getMap(){return ar.empty}invert(e){return new Gd(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 Gd(n.attr,n.value)}}ks.jsonID("docAttr",Gd);let kc=class extends Error{};kc=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};kc.prototype=Object.create(Error.prototype);kc.prototype.constructor=kc;kc.prototype.name="TransformError";class D0{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new qd}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new kc(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=_e.empty){let a=cp(this.doc,e,n,r);return a&&this.step(a),this}replaceWith(e,n,r){return this.replace(e,n,new _e(Ne.from(r),0,0))}delete(e,n){return this.replace(e,n,_e.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return cO(this,e,n,r),this}replaceRangeWith(e,n,r){return dO(this,e,n,r),this}deleteRange(e,n){return uO(this,e,n),this}lift(e,n){return J8(this,e,n),this}join(e,n=1){return rO(this,e,n),this}wrap(e,n){return X8(this,e,n),this}setBlockType(e,n=e,r,a=null){return Z8(this,e,n,r,a),this}setNodeMarkup(e,n,r=null,a){return tO(this,e,n,r,a),this}setNodeAttribute(e,n,r){return this.step(new xc(e,n,r)),this}setDocAttribute(e,n){return this.step(new Gd(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 Zt)n.isInSet(r.marks)&&this.step(new pl(e,n));else{let a=r.marks,i,o=[];for(;i=n.isInSet(a);)o.push(new pl(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 nO(this,e,n,r),this}addMark(e,n,r){return K8(this,e,n,r),this}removeMark(e,n,r){return q8(this,e,n,r),this}clearIncompatible(e,n,r){return O0(this,e,n,r),this}}const Sx=Object.create(null);class ot{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new q2(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?ac(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):ac(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 or(e.node(0))}static atStart(e){return ac(e,e,0,0,1)||new or(e)}static atEnd(e){return ac(e,e,e.content.size,e.childCount,-1)||new or(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Sx[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 Sx)throw new RangeError("Duplicate use of selection JSON ID "+e);return Sx[e]=n,n.prototype.jsonID=e,n}getBookmark(){return et.between(this.$anchor,this.$head).getBookmark()}}ot.prototype.visible=!0;class q2{constructor(e,n){this.$from=e,this.$to=n}}let Z1=!1;function eN(t){!Z1&&!t.parent.inlineContent&&(Z1=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class et extends ot{constructor(e,n=e){eN(e),eN(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return ot.near(r);let a=e.resolve(n.map(this.anchor));return new et(a.parent.inlineContent?a:r,r)}replace(e,n=_e.empty){if(super.replace(e,n),n==_e.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof et&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new dp(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 et(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=ot.findFrom(n,r,!0)||ot.findFrom(n,-r,!0);if(i)n=i.$head;else return ot.near(n,r)}return e.parent.inlineContent||(a==0?e=n:(e=(ot.findFrom(e,-r,!0)||ot.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&&Ze.isSelectable(c))return Ze.create(t,n-(a<0?c.nodeSize:0))}else{let u=ac(t,c,n+a,a<0?c.childCount:0,a,i);if(u)return u}n+=c.nodeSize*a}return null}function tN(t,e,n){let r=t.steps.length-1;if(r{o==null&&(o=f)}),t.setSelection(ot.near(t.doc.resolve(o),n))}const nN=1,vh=2,sN=4;class fO extends D0{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|=vh,this}ensureMarks(e){return Zt.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&vh)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~vh,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)||Zt.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(ot.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|=sN,this}get scrolledIntoView(){return(this.updated&sN)>0}}function rN(t,e){return!e||!t?t:t.bind(e)}class kd{constructor(e,n,r){this.name=e,this.init=rN(n.init,r),this.apply=rN(n.apply,r)}}const pO=[new kd("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new kd("selection",{init(t,e){return t.selection||ot.atStart(e.doc)},apply(t){return t.selection}}),new kd("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new kd("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Cx{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=pO.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 kd(r.key,r.spec.state,r))})}}class fc{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 Cx(e.schema,e.plugins),i=new fc(a);return a.fields.forEach(o=>{if(o.name=="doc")i.doc=di.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=ot.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 G2(t,e,n){for(let r in t){let a=t[r];a instanceof Function?a=a.bind(e):r=="handleDOMEvents"&&(a=G2(a,e,{})),n[r]=a}return n}class rn{constructor(e){this.spec=e,this.props={},e.props&&G2(e.props,this,this.props),this.key=e.key?e.key.key:J2("plugin")}getState(e){return e[this.key]}}const Tx=Object.create(null);function J2(t){return t in Tx?t+"$"+ ++Tx[t]:(Tx[t]=0,t+"$")}class pn{constructor(e="key"){this.key=J2(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const z0=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Q2(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Y2=(t,e,n)=>{let r=Q2(t,n);if(!r)return!1;let a=$0(r);if(!a){let o=r.blockRange(),c=o&&_c(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let i=a.nodeBefore;if(iS(t,a,e,-1))return!0;if(r.parent.content.size==0&&(Sc(i,"end")||Ze.isSelectable(i)))for(let o=r.depth;;o--){let c=cp(t.doc,r.before(o),r.after(o),_e.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},mO=(t,e,n)=>{let r=Q2(t,n);if(!r)return!1;let a=$0(r);return a?X2(t,a,e):!1},xO=(t,e,n)=>{let r=eS(t,n);if(!r)return!1;let a=F0(r);return a?X2(t,a,e):!1};function X2(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=cp(t.doc,i,u,_e.empty);if(!h||h.from!=i||h instanceof Xn&&h.slice.size>=u-i)return!1;if(n){let f=t.tr.step(h);f.setSelection(et.create(f.doc,i)),n(f.scrollIntoView())}return!0}function Sc(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 Z2=(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=$0(r)}let o=i&&i.nodeBefore;return!o||!Ze.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Ze.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function $0(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 eS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=eS(t,n);if(!r)return!1;let a=F0(r);if(!a)return!1;let i=a.nodeAfter;if(iS(t,a,e,1))return!0;if(r.parent.content.size==0&&(Sc(i,"start")||Ze.isSelectable(i))){let o=cp(t.doc,r.before(),r.after(),_e.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 Ze,a;if(r){if(n.node.isTextblock||!wo(t.doc,n.from))return!1;a=n.from}else if(a=lp(t.doc,n.from,-1),a==null)return!1;if(e){let i=t.tr.join(a);r&&i.setSelection(Ze.create(i.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},yO=(t,e)=>{let n=t.selection,r;if(n instanceof Ze){if(n.node.isTextblock||!wo(t.doc,n.to))return!1;r=n.to}else if(r=lp(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},bO=(t,e)=>{let{$from:n,$to:r}=t.selection,a=n.blockRange(r),i=a&&_c(a);return i==null?!1:(e&&e(t.tr.lift(a,i).scrollIntoView()),!0)},sS=(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 B0(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=B0(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(ot.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},rS=(t,e)=>{let n=t.selection,{$from:r,$to:a}=n;if(n instanceof or||r.parent.inlineContent||a.parent.inlineContent)return!1;let i=B0(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(ui(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),a=r&&_c(r);return a==null?!1:(e&&e(t.tr.lift(r,a).scrollIntoView()),!0)};function NO(t){return(e,n)=>{let{$from:r,$to:a}=e.selection;if(e.selection instanceof Ze&&e.selection.node.isBlock)return!r.parentOffset||!ui(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,c,u=!1,h=!1;for(let y=r.depth;;y--)if(r.node(y).isBlock){u=r.end(y)==r.pos+(r.depth-y),h=r.start(y)==r.pos-(r.depth-y),c=B0(r.node(y-1).contentMatchAt(r.indexAfter(y-1))),i.unshift(u&&c?{type:c}:null),o=y;break}else{if(y==1)return!1;i.unshift(null)}let f=e.tr;(e.selection instanceof et||e.selection instanceof or)&&f.deleteSelection();let m=f.mapping.map(r.pos),x=ui(f.doc,m,i.length,i);if(x||(i[0]=c?{type:c}:null,x=ui(f.doc,m,i.length,i)),!x)return!1;if(f.split(m,i.length,i),!u&&h&&r.node(o).type!=c){let y=f.mapping.map(r.before(o)),N=f.doc.resolve(y);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 wO=NO(),jO=(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(Ze.create(t.doc,a))),!0)};function kO(t,e,n){let r=e.nodeBefore,a=e.nodeAfter,i=e.index();return!r||!a||!r.type.compatibleContent(a.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(a.isTextblock||wo(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function iS(t,e,n,r){let a=e.nodeBefore,i=e.nodeAfter,o,c,u=a.type.spec.isolating||i.type.spec.isolating;if(!u&&kO(t,e,n))return!0;let h=!u&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(o=(c=a.contentMatchAt(a.childCount)).findWrapping(i.type))&&c.matchType(o[0]||i.type).validEnd){if(n){let y=e.pos+i.nodeSize,N=Ne.empty;for(let S=o.length-1;S>=0;S--)N=Ne.from(o[S].create(null,N));N=Ne.from(a.copy(N));let w=t.tr.step(new Zn(e.pos-1,y,e.pos,y,new _e(N,1,0),o.length,!0)),j=w.doc.resolve(y+2*o.length);j.nodeAfter&&j.nodeAfter.type==a.type&&wo(w.doc,j.pos)&&w.join(j.pos),n(w.scrollIntoView())}return!0}let f=i.type.spec.isolating||r>0&&u?null:ot.findFrom(e,1),m=f&&f.$from.blockRange(f.$to),x=m&&_c(m);if(x!=null&&x>=e.depth)return n&&n(t.tr.lift(m,x).scrollIntoView()),!0;if(h&&Sc(i,"start",!0)&&Sc(a,"end")){let y=a,N=[];for(;N.push(y),!y.isTextblock;)y=y.lastChild;let w=i,j=1;for(;!w.isTextblock;w=w.firstChild)j++;if(y.canReplace(y.childCount,y.childCount,w.content)){if(n){let S=Ne.empty;for(let T=N.length-1;T>=0;T--)S=Ne.from(N[T].copy(S));let E=t.tr.step(new Zn(e.pos-N.length,e.pos+i.nodeSize,e.pos+j,e.pos+i.nodeSize-j,new _e(S,N.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function oS(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(et.create(e.doc,t<0?a.start(i):a.end(i)))),!0):!1}}const SO=oS(-1),CO=oS(1);function TO(t,e=null){return function(n,r){let{$from:a,$to:i}=n.selection,o=a.blockRange(i),c=o&&L0(o,t,e);return c?(r&&r(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function aN(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 af(u,u,e.depth),e.endIndex=0;f--)i=Ne.from(n[f].type.create(n[f].attrs,i));t.step(new Zn(e.start-(r?2:0),e.end,e.start,e.end,new _e(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?RO(e,n,t,i):PO(e,n,i):!0:!1}}function RO(t,e,n,r){let a=t.tr,i=r.end,o=r.$to.end(r.depth);iw;N--)y-=a.child(N).nodeSize,r.delete(y-1,y+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let c=n.startIndex==0,u=n.endIndex==a.childCount,h=i.node(-1),f=i.index(-1);if(!h.canReplace(f+(c?0:1),f+1,o.content.append(u?Ne.empty:Ne.from(a))))return!1;let m=i.pos,x=m+o.nodeSize;return r.step(new Zn(m-(c?1:0),x+(u?1:0),m+1,x-1,new _e((c?Ne.empty:Ne.from(a.copy(Ne.empty))).append(u?Ne.empty:Ne.from(a.copy(Ne.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function OO(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=Ne.from(h?t.create():null),m=new _e(Ne.from(t.create(null,Ne.from(c.type.create(null,f)))),h?3:1,0),x=i.start,y=i.end;n(e.tr.step(new Zn(x-(h?3:1),y,x,y,m,1,!0)).scrollIntoView())}return!0}}const ls=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Cc=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Sg=null;const ai=function(t,e,n){let r=Sg||(Sg=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},LO=function(){Sg=null},ml=function(t,e,n,r){return n&&(iN(t,e,n,r,-1)||iN(t,e,n,r,1))},DO=/^(img|br|input|textarea|hr)$/i;function iN(t,e,n,r,a){for(var i;;){if(t==n&&e==r)return!0;if(e==(a<0?0:Sr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||cu(t)||DO.test(t.nodeName)||t.contentEditable=="false")return!1;e=ls(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?Sr(t):0}else return!1}}function Sr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function _O(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=Sr(t)}else if(t.parentNode&&!cu(t))e=ls(t),t=t.parentNode;else return null}}function zO(t,e){for(;;){if(t.nodeType==3&&e2),kr=Tc||(wa?/Mac/.test(wa.platform):!1),dS=wa?/Win/.test(wa.platform):!1,ci=/Android \d/.test(jo),du=!!oN&&"webkitFontSmoothing"in oN.documentElement.style,VO=du?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function HO(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 ei(t,e){return typeof t=="number"?t:t[e]}function UO(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 lN(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=Cc(o);continue}let c=o,u=c==i.body,h=u?HO(i):UO(c),f=0,m=0;if(e.toph.bottom-ei(r,"bottom")&&(m=e.bottom-e.top>h.bottom-h.top?e.top+ei(a,"top")-h.top:e.bottom-h.bottom+ei(a,"bottom")),e.lefth.right-ei(r,"right")&&(f=e.right-h.right+ei(a,"right")),f||m)if(u)i.defaultView.scrollBy(f,m);else{let y=c.scrollLeft,N=c.scrollTop;m&&(c.scrollTop+=m),f&&(c.scrollLeft+=f);let w=c.scrollLeft-y,j=c.scrollTop-N;e={left:e.left-w,top:e.top-j,right:e.right-w,bottom:e.bottom-j}}let x=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(x))break;o=x=="absolute"?o.offsetParent:Cc(o)}}function WO(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:uS(t.dom)}}function uS(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Cc(r));return e}function KO({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;hS(n,r==0?0:r-e)}function hS(t,e){for(let n=0;n=c){o=Math.max(N.bottom,o),c=Math.min(N.top,c);let w=N.left>e.left?N.left-e.left:N.right=(N.left+N.right)/2?1:0));continue}}else N.top>e.top&&!u&&N.left<=e.left&&N.right>=e.left&&(u=f,h={left:Math.max(N.left,Math.min(N.right,e.left)),top:N.top});!n&&(e.left>=N.right&&e.top>=N.top||e.left>=N.left&&e.top>=N.bottom)&&(i=m+1)}}return!n&&u&&(n=u,a=h,r=0),n&&n.nodeType==3?GO(n,a):!n||r&&n.nodeType==1?{node:t,offset:i}:fS(n,a)}function GO(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 H0(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function JO(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 YO(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 pS(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&a++}let h;du&&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=YO(t,r,a,e))}c==null&&(c=QO(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function cN(t){return t.top=0&&a==r.nodeValue.length?(u--,f=1):n<0?u--:h++,yd(Gi(ai(r,u,h),f),f<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&a&&(n<0||a==Sr(r))){let u=r.childNodes[a-1];if(u.nodeType==1)return Ex(u.getBoundingClientRect(),!1)}if(i==null&&a=0)}if(i==null&&a&&(n<0||a==Sr(r))){let u=r.childNodes[a-1],h=u.nodeType==3?ai(u,Sr(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(h)return yd(Gi(h,1),!1)}if(i==null&&a=0)}function yd(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 Ex(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 xS(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 xS(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=mS(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=ai(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 nL(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:xS(t,e,()=>{let{focusNode:u,focusOffset:h,anchorNode:f,anchorOffset:m}=t.domSelectionRange(),x=c.caretBidiLevel;c.modify("move",n,"character");let y=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:N,focusOffset:w}=t.domSelectionRange(),j=N&&!y.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),j}):r.pos==r.start()||r.pos==r.end()}let dN=null,uN=null,hN=!1;function sL(t,e,n){return dN==e&&uN==n?hN:(dN=e,uN=n,hN=n=="up"||n=="down"?eL(t,e,n):nL(t,e,n))}const Tr=0,fN=1,Zo=2,ja=3;class uu{constructor(e,n,r,a){this.parent=e,this.children=n,this.dom=r,this.contentDOM=a,this.dirty=Tr,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;nls(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 yS){a=e-i;break}i=c}if(a)return this.children[r].domFromPos(a-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof gS&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?ls(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=ls(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 y=document.createRange();y.setEnd(u.node,u.offset),y.setStart(c.node,c.offset),h.removeAllRanges(),h.addRange(y)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,a=0;a=r:er){let c=r+i.border,u=o-i.border;if(e>=c&&n<=u){this.dirty=e==r||n==o?Zo:fN,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?Zo:ja}r=o}this.dirty=Zo}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Zo:fN;n.dirty{if(!i)return a;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let c=document.createElement("span");c.appendChild(o),o=c}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==Tr&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class rL extends uu{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 xl extends uu{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=jl.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new xl(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!=Tr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=Ag(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}=jl.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=NS(f,r,n),h?u=new aL(e,n,r,a,f,m||null,x,h,i,o+1):n.isText?new hp(e,n,r,a,f,x,i):new uo(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=()=>Ne.empty)}return e}matchesNode(e,n,r){return this.dirty==Tr&&e.eq(this.node)&&lf(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 oL(this,o&&o.node,e);dL(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?Zt.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 y;u.findNodeMatch(h,f,m,x)||c&&e.state.selection.from>a&&e.state.selection.to-1&&u.updateNodeAt(h,f,m,y,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==Zo)&&(o&&this.protectLocalComposition(e,o),bS(this.contentDOM,this.children,e),Tc&&uL(this.dom))}localCompositionInfo(e,n){let{from:r,to:a}=e.state.selection;if(!(e.state.selection instanceof et)||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=hL(this.node.content,o,r-n,a-n);return c<0?null:{node:i,pos:c,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:a}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new rL(this,i,n,a);e.input.compositionNodes.push(o),this.children=Ag(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=Tr}updateOuterDeco(e){if(lf(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=vS(this.dom,this.nodeDOM,Mg(this.outerDeco,this.node,n),Mg(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 pN(t,e,n,r,a){NS(r,e,t);let i=new uo(void 0,t,e,n,r,r,r,a,0);return i.contentDOM&&i.updateChildren(a,0),i}class hp extends uo{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!=Tr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Tr||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=Tr,!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 hp(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 yS extends uu{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Tr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class aL extends uo{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 bS(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=xl.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 xl)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 cL(t,e){return t.type.side-e.type.side}function dL(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 j=N;o!j.inline):c.slice();r(x,w,e.forChild(i,x),y),i=N}}function uL(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 hL(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 Ag(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 U0(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(up(n)){for(u=o;a&&!a.node;)a=a.parent;let m=a.node;if(a&&m.isAtom&&Ze.isSelectable(m)&&a.parent&&!(m.isInline&&$O(n.focusNode,n.focusOffset,a.dom))){let x=a.posBefore;h=new Ze(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 y=0;y{(n.anchorNode!=r||n.anchorOffset!=a)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!wS(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function pL(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ls(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Js&&co<=11&&(n.disabled=!0,n.disabled=!1)}function jS(t,e){if(e instanceof Ze){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(bN(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else bN(t)}function bN(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function W0(t,e,n,r){return t.someProp("createSelectionBetween",a=>a(t,e,n))||et.between(e,n,r)}function vN(t){return t.editable&&!t.hasFocus()?!1:kS(t)}function kS(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 mL(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return ml(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Ig(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&&ot.findFrom(i,e)}function Ji(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function NN(t,e,n){let r=t.state.selection;if(r instanceof et)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 Ji(t,new et(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let a=Ig(t.state,e);return a&&a instanceof Ze?Ji(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?Ze.isSelectable(i)?Ji(t,new Ze(e<0?t.state.doc.resolve(a.pos-i.nodeSize):a)):du?Ji(t,new et(t.state.doc.resolve(e<0?c:c+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ze&&r.node.isInline)return Ji(t,new et(e>0?r.$to:r.$from));{let a=Ig(t.state,e);return a?Ji(t,a):!1}}}function cf(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Od(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function sc(t,e){return e<0?xL(t):gL(t)}function xL(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let a,i,o=!1;for(Cr&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(Od(c,-1))a=n,i=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(SS(n))break;{let c=n.previousSibling;for(;c&&Od(c,-1);)a=n.parentNode,i=ls(c),c=c.previousSibling;if(c)n=c,r=cf(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Rg(t,n,r):a&&Rg(t,a,i)}function gL(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let a=cf(n),i,o;for(;;)if(r{t.state==a&&hi(t)},50)}function wN(t,e){let n=t.state.doc.resolve(e);if(!(fs||dS)&&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 jN(t,e,n){let r=t.state.selection;if(r instanceof et&&!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=Ig(t.state,e);if(o&&o instanceof Ze)return Ji(t,o)}if(!a.parent.inlineContent){let o=e<0?a:i,c=r instanceof or?ot.near(o,e):ot.findFrom(o,e);return c?Ji(t,c):!1}return!1}function kN(t,e){if(!(t.state.selection instanceof et))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 SN(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function vL(t){if(!ws||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;SN(t,r,"true"),setTimeout(()=>SN(t,r,"false"),20)}return!1}function NL(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function wL(t,e){let n=e.keyCode,r=NL(e);if(n==8||kr&&n==72&&r=="c")return kN(t,-1)||sc(t,-1);if(n==46&&!e.shiftKey||kr&&n==68&&r=="c")return kN(t,1)||sc(t,1);if(n==13||n==27)return!0;if(n==37||kr&&n==66&&r=="c"){let a=n==37?wN(t,t.state.selection.from)=="ltr"?-1:1:-1;return NN(t,a,r)||sc(t,a)}else if(n==39||kr&&n==70&&r=="c"){let a=n==39?wN(t,t.state.selection.from)=="ltr"?1:-1:1;return NN(t,a,r)||sc(t,a)}else{if(n==38||kr&&n==80&&r=="c")return jN(t,-1,r)||sc(t,-1);if(n==40||kr&&n==78&&r=="c")return vL(t)||jN(t,1,r)||sc(t,1);if(r==(kr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function K0(t,e){t.someProp("transformCopied",y=>{e=y(e,t)});let n=[],{content:r,openStart:a,openEnd:i}=e;for(;a>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){a--,i--;let y=r.firstChild;n.push(y.type.name,y.attrs!=y.type.defaultAttrs?y.attrs:null),r=y.content}let o=t.someProp("clipboardSerializer")||jl.fromSchema(t.state.schema),c=IS(),u=c.createElement("div");u.appendChild(o.serializeFragment(r,{document:c}));let h=u.firstChild,f,m=0;for(;h&&h.nodeType==1&&(f=AS[h.nodeName.toLowerCase()]);){for(let y=f.length-1;y>=0;y--){let N=c.createElement(f[y]);for(;u.firstChild;)N.appendChild(u.firstChild);u.appendChild(N),m++}h=u.firstChild}h&&h.nodeType==1&&h.setAttribute("data-pm-slice",`${a} ${i}${m?` -${m}`:""} ${JSON.stringify(n)}`);let x=t.someProp("clipboardTextSerializer",y=>y(e,t))||e.content.textBetween(0,e.content.size,` -`);return{dom:u,text:g,slice:e}}function CS(t,e,n,r,a){let i=a.parent.type.spec.code,o,c;if(!n&&!e)return null;let u=!!e&&(r||i||!n);if(u){if(t.someProp("transformPastedText",g=>{e=g(e,i||r,t)}),i)return c=new _e(Ne.from(t.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0),t.someProp("transformPasted",g=>{c=g(c,t,!0)}),c;let m=t.someProp("clipboardTextParser",g=>g(e,a,r,t));if(m)c=m;else{let g=a.marks(),{schema:y}=t.state,N=jl.fromSchema(y);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let j=o.appendChild(document.createElement("p"));w&&j.appendChild(N.serializeNode(y.text(w,g)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=CL(n),du&&TL(o);let h=o&&o.querySelector("[data-pm-slice]"),f=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let m=+f[3];m>0;m--){let g=o.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;o=g}if(c||(c=(t.someProp("clipboardParser")||t.someProp("domParser")||lo.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||f),context:a,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!jL.test(g.parentNode.nodeName)?{ignore:!0}:null}})),f)c=EL(CN(c,+f[1],+f[2]),f[4]);else if(c=_e.maxOpen(kL(c.content,a),!0),c.openStart||c.openEnd){let m=0,g=0;for(let y=c.content.firstChild;m{c=m(c,t,u)}),c}const jL=/^(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 kL(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&&ES(u,i,c,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=MS(o[o.length-1],i.length));let f=TS(c,u);o.push(f),a=a.matchType(f.type),i=u}}),o)return Ne.from(o)}return t}function TS(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Ne.from(t));return t}function ES(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(Ne.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(c))}function CN(t,e,n){return en})),Ag.createHTML(t)):t}function CL(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=IS().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),a;if((a=r&&AS[r[1].toLowerCase()])&&(t=a.map(i=>"<"+i+">").join("")+t+a.map(i=>"").reverse().join("")),n.innerHTML=SL(t),a)for(let i=0;i=0;c-=2){let u=n.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;a=Ne.from(u.create(r[c+1],a)),i++,o++}return new _e(a,i,o)}const Is={},Rs={},ML={touchstart:!0,touchmove:!0};class AL{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 IL(t){for(let e in Is){let n=Is[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{PL(t,r)&&!q0(t,r)&&(t.editable||!(r.type in Rs))&&n(t,r)},ML[e]?{passive:!0}:void 0)}ws&&t.dom.addEventListener("input",()=>null),Ox(t)}function ao(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function RL(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Ox(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>q0(t,r))})}function q0(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function PL(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 OL(t,e){!q0(t,e)&&Is[e.type]&&(t.editable||!(e.type in Rs))&&Is[e.type](t,e)}Rs.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!PS(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(ci&&fs&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Tc&&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,Jo(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||wL(t,n)?n.preventDefault():ao(t,"key")};Rs.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Rs.keypress=(t,e)=>{let n=e;if(PS(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 et)||!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 fp(t){return{left:t.clientX,top:t.clientY}}function LL(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function G0(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 xc(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 DL(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Ze.isSelectable(r)?(xc(t,new Ze(n)),!0):!1}function _L(t,e){if(e==-1)return!1;let n=t.state.selection,r,a;n instanceof Ze&&(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(Ze.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?(xc(t,Ze.create(t.state.doc,a)),!0):!1}function zL(t,e,n,r,a){return G0(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(a?_L(t,n):DL(t,n))}function $L(t,e,n,r){return G0(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",a=>a(t,e,r))}function FL(t,e,n,r){return G0(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",a=>a(t,e,r))||BL(t,n,r)}function BL(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(xc(t,et.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)xc(t,et.create(r,c+1,c+1+o.content.size));else if(Ze.isSelectable(o))xc(t,Ze.create(r,c));else continue;return!0}}function J0(t){return df(t)}const RS=kr?"metaKey":"ctrlKey";Is.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=J0(t),a=Date.now(),i="singleClick";a-t.input.lastClick.time<500&&LL(n,t.input.lastClick)&&!n[RS]&&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(fp(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new VL(t,o,n,!!r)):(i=="doubleClick"?$L:FL)(t,o.pos,o.inside,n)?n.preventDefault():ao(t,"pointer"))};class VL{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[RS],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 Ze&&h.from<=o&&h.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Cr&&!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)),ao(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(()=>hi(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(fp(e))),this.updateAllowDefault(e),this.allowDefault||!n?ao(this.view,"pointer"):zL(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ws&&this.mightDrag&&!this.mightDrag.node.isAtom||fs&&!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)?(xc(this.view,ot.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):ao(this.view,"pointer")}move(e){this.updateAllowDefault(e),ao(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)}}Is.touchstart=t=>{t.input.lastTouch=Date.now(),J0(t),ao(t,"pointer")};Is.touchmove=t=>{t.input.lastTouch=Date.now(),ao(t,"pointer")};Is.contextmenu=t=>J0(t);function PS(t,e){return t.composing?!0:ws&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const HL=ci?5e3:-1;Rs.compositionstart=Rs.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof et&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||fs&&dS&&UL(t)))t.markCursor=t.state.storedMarks||n.marks(),df(t,!0),t.markCursor=null;else if(df(t,!e.selection.empty),Cr&&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}OS(t,HL)};function UL(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"}Rs.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++,OS(t,20))};function OS(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>df(t),e))}function LS(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=KL());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function WL(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=_O(e.focusNode,e.focusOffset),r=zO(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 KL(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function df(t,e=!1){if(!(ci&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),LS(t),e||t.docView&&t.docView.dirty){let n=U0(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 qL(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 Jd=Gs&&co<15||Tc&&VO<604;Is.copy=Rs.cut=(t,e)=>{let n=e,r=t.state.selection,a=n.type=="cut";if(r.empty)return;let i=Jd?null:n.clipboardData,o=r.content(),{dom:c,text:u}=K0(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",c.innerHTML),i.setData("text/plain",u)):qL(t,c),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function GL(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function JL(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?Qd(t,r.value,null,a,e):Qd(t,r.textContent,r.innerHTML,a,e)},50)}function Qd(t,e,n,r,a){let i=CS(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,a,i||_e.empty)))return!0;if(!i)return!1;let o=GL(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 DS(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," "):""}Rs.paste=(t,e)=>{let n=e;if(t.composing&&!ci)return;let r=Jd?null:n.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Qd(t,DS(r),r.getData("text/html"),a,n)?n.preventDefault():JL(t,n)};class _S{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const QL=kr?"altKey":"ctrlKey";function zS(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[QL]}Is.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(fp(n)),o;if(!(i&&i.pos>=a.from&&i.pos<=(a instanceof Ze?a.to-1:a.to))){if(r&&r.mightDrag)o=Ze.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=Ze.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:u,text:h,slice:f}=K0(t,c);(!n.dataTransfer.files.length||!fs||cS>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Jd?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Jd||n.dataTransfer.setData("text/plain",h),t.dragging=new _S(f,zS(t,n),o)};Is.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Rs.dragover=Rs.dragenter=(t,e)=>e.preventDefault();Rs.drop=(t,e)=>{try{YL(t,e,t.dragging)}finally{t.dragging=null}};function YL(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(fp(e));if(!r)return;let a=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",y=>{i=y(i,t,!1)}):i=CS(t,DS(e.dataTransfer),Jd?null:e.dataTransfer.getData("text/html"),!1,a);let o=!!(n&&zS(t,e));if(t.someProp("handleDrop",y=>y(t,e,i||_e.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let c=i?V2(t.state.doc,a.pos,i):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(o){let{node:y}=n;y?y.replace(u):u.deleteSelection()}let h=u.mapping.map(c),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,m=u.doc;if(f?u.replaceRangeWith(h,h,i.content.firstChild):u.replaceRange(h,h,i),u.doc.eq(m))return;let g=u.doc.resolve(h);if(f&&Ze.isSelectable(i.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(i.content.firstChild))u.setSelection(new Ze(g));else{let y=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((N,w,j,S)=>y=S),u.setSelection(W0(t,g,u.doc.resolve(y)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}Is.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())&&hi(t)},20))};Is.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)};Is.beforeinput=(t,e)=>{if(fs&&ci&&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,Jo(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 Rs)Is[t]=Rs[t];function Yd(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 uf{constructor(e,n){this.toDOM=e,this.spec=n||al,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 Kn(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof uf&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Yd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ho{constructor(e,n){this.attrs=e,this.spec=n||al}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 Kn(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==vs||e.maps.length==0?this:this.mapInner(e,n,0,0,r||al)}mapInner(e,n,r,a,i){let o;for(let c=0;c{let h=u+r,f;if(f=FS(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 ho){let h=Math.max(i,u.from)-i,f=Math.min(o,u.to)-i;ha.map(e,n,al));return Xi.from(r)}forChild(e,n){if(n.isLeaf)return Xt.empty;let r=[];for(let a=0;an instanceof Xt)?e:e.reduce((n,r)=>n.concat(r instanceof Xt?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let j=w-N-(y-g);for(let S=0;SE+f-m)continue;let T=c[S]+f-m;y>=T?c[S+1]=g<=T?-2:-1:g>=f&&j&&(c[S]+=j,c[S+1]+=j)}m+=j}),f=n.maps[h].map(f,-1)}let u=!1;for(let h=0;h=r.content.size){u=!0;continue}let g=n.map(t[h+1]+i,-1),y=g-a,{index:N,offset:w}=r.content.findIndex(m),j=r.maybeChild(N);if(j&&w==m&&w+j.nodeSize==y){let S=c[h+2].mapInner(n,j,f+1,t[h]+i+1,o);S!=vs?(c[h]=m,c[h+1]=y,c[h+2]=S):(c[h+1]=-2,u=!0)}else u=!0}if(u){let h=ZL(c,t,e,n,a,i,o),f=hf(h,r,0,o);e=f.local;for(let m=0;mn&&o.to{let h=FS(t,c,u+n);if(h){i=!0;let f=hf(h,c,n+u+1,r);f!=vs&&a.push(u,u+c.nodeSize,f)}});let o=$S(i?BS(t):t,-n).sort(il);for(let c=0;c0;)e++;t.splice(e,0,n)}function Ig(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=vs&&e.push(r)}),t.cursorWrapper&&e.push(Xt.create(t.state.doc,[t.cursorWrapper.deco])),Xi.from(e)}const e6={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},t6=Gs&&co<=11;class n6{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 s6{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new n6,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():ws&&e.composing&&r.some(a=>a.type=="childList"&&a.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),t6&&(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,e6)),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(vN(this.view)){if(this.suppressingSelectionUpdates)return hi(this.view);if(Gs&&co<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ml(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=Cc(i))n.add(i);for(let i=e.anchorNode;i;i=Cc(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)&&vN(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(Cr&&u.length){let f=u.filter(m=>m.nodeName=="BR");if(f.length==2){let[m,g]=f;m.parentNode&&m.parentNode.parentNode==g.parentNode?g.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let g of f){let y=g.parentNode;y&&y.nodeName=="LI"&&(!m||i6(e,m)!=y)&&g.remove()}}}let h=null;i<0&&a&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||a)&&(i>-1&&(e.docView.markDirty(i,o),r6(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,o6(e,u)),this.handleDOMChange(i,o,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||hi(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;j--){let S=r.childNodes[j-1],E=S.pmViewDesc;if(S.nodeName=="BR"&&!E){i=j;break}if(!E||E.size)break}let m=t.state.doc,g=t.someProp("domParser")||lo.fromSchema(t.state.schema),y=m.resolve(o),N=null,w=g.parse(r,{topNode:y.parent,topMatch:y.parent.contentMatchAt(y.index()),topOpen:!0,from:a,to:i,preserveWhitespace:y.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:c6,context:y});if(h&&h[0].pos!=null){let j=h[0].pos,S=h[1]&&h[1].pos;S==null&&(S=j),N={anchor:j+o,head:S+o}}return{doc:w,sel:N,from:o,to:c}}function c6(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ws&&/^(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||ws&&/^(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 d6=/^(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 u6(t,e,n,r,a){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let z=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,V=U0(t,z);if(V&&!t.state.selection.eq(V)){if(fs&&ci&&t.input.lastKeyCode===13&&Date.now()-100te(t,Jo(13,"Enter"))))return;let I=t.state.tr.setSelection(V);z=="pointer"?I.setMeta("pointer",!0):z=="key"&&I.scrollIntoView(),i&&I.setMeta("composition",i),t.dispatch(I)}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=l6(t,e,n),f=t.state.doc,m=f.slice(h.from,h.to),g,y;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||ci)&&a.some(z=>z.nodeType==1&&!d6.test(z.nodeName))&&(!N||N.endA>=N.endB)&&t.someProp("handleKeyDown",z=>z(t,Jo(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!N)if(r&&u instanceof et&&!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 z=RN(t,t.state.doc,h.sel);if(z&&!z.eq(t.state.selection)){let V=t.state.tr.setSelection(z);i&&V.setMeta("composition",i),t.dispatch(V)}}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)),Gs&&co<=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),j=h.doc.resolveNoCache(N.endB-h.from),S=f.resolve(N.start),E=w.sameParent(j)&&w.parent.inlineContent&&S.end()>=N.endA;if((Tc&&t.input.lastIOSEnter>Date.now()-225&&(!E||a.some(z=>z.nodeName=="DIV"||z.nodeName=="P"))||!E&&w.posz(t,Jo(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>N.start&&f6(f,N.start,N.endA,w,j)&&t.someProp("handleKeyDown",z=>z(t,Jo(8,"Backspace")))){ci&&fs&&t.domObserver.suppressSelectionUpdates();return}fs&&N.endB==N.start&&(t.input.lastChromeDelete=Date.now()),ci&&!E&&w.start()!=j.start()&&j.parentOffset==0&&w.depth==j.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==N.endA&&(N.endB-=2,j=h.doc.resolveNoCache(N.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function(z){return z(t,Jo(13,"Enter"))})},20));let T=N.start,P=N.endA,O=z=>{let V=z||t.state.tr.replace(T,P,h.doc.slice(N.start-h.from,N.endB-h.from));if(h.sel){let I=RN(t,V.doc,h.sel);I&&!(fs&&t.composing&&I.empty&&(N.start!=N.endB||t.input.lastChromeDeletehi(t),20));let z=O(t.state.tr.delete(T,P)),V=f.resolve(N.start).marksAcross(f.resolve(N.endA));V&&z.ensureMarks(V),t.dispatch(z)}else if(N.endA==N.endB&&(q=h6(w.parent.content.cut(w.parentOffset,j.parentOffset),S.parent.content.cut(S.parentOffset,N.endA-S.start())))){let z=O(t.state.tr);q.type=="add"?z.addMark(T,P,q.mark):z.removeMark(T,P,q.mark),t.dispatch(z)}else if(w.parent.child(w.index()).isText&&w.index()==j.index()-(j.textOffset?0:1)){let z=w.parent.textBetween(w.parentOffset,j.parentOffset),V=()=>O(t.state.tr.insertText(z,T,P));t.someProp("handleTextInput",I=>I(t,T,P,z,V))||t.dispatch(V())}else t.dispatch(O());else t.dispatch(O())}function RN(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:W0(t,e.resolve(n.anchor),e.resolve(n.head))}function h6(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||Rg(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 p6(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 VS{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 AL,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(zN),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=DN(this),LN(this),this.nodeViews=_N(this),this.docView=pN(this.state.doc,ON(this),Ig(this),this.dom,this),this.domObserver=new s6(this,(r,a,i,o)=>u6(this,r,a,i,o)),this.domObserver.start(),IL(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Ox(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(zN),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&&(LS(this),o=!0),this.state=e;let c=a.plugins!=e.plugins||this._props.plugins!=n.plugins;if(c||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let y=_N(this);g6(y,this.nodeViews)&&(this.nodeViews=y,i=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&Ox(this),this.editable=DN(this),LN(this);let u=Ig(this),h=ON(this),f=a.plugins!=e.plugins&&!a.doc.eq(e.doc)?"reset":e.scrollToSelection>a.scrollToSelection?"to selection":"preserve",m=i||!this.docView.matchesNode(e.doc,h,u);(m||!e.selection.eq(a.selection))&&(o=!0);let g=f=="preserve"&&o&&this.dom.style.overflowAnchor==null&&WO(this);if(o){this.domObserver.stop();let y=m&&(Gs||fs)&&!this.composing&&!a.selection.empty&&!e.selection.empty&&m6(a.selection,e.selection);if(m){let N=fs?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=WL(this)),(i||!this.docView.update(e.doc,h,u,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=pN(e.doc,h,u,this.dom,this)),N&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(y=!0)}y||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&mL(this))?hi(this,y):(jS(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(a),!((r=this.dragging)===null||r===void 0)&&r.node&&!a.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,a),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():g&&KO(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Ze){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&lN(this,n.getBoundingClientRect(),e)}else lN(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 _S(e.slice,e.move,a<0?void 0:Ze.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 XO(this,e)}coordsAtPos(e,n=1){return mS(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 sL(this,n||this.state,e)}pasteHTML(e,n){return Qd(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Qd(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return K0(this,e)}destroy(){this.docView&&(RL(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ig(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,LO())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return OL(this,e)}domSelectionRange(){let e=this.domSelection();return e?ws&&this.root.nodeType===11&&FO(this.dom.ownerDocument)==this.dom&&a6(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}VS.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function ON(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"),[Kn.node(0,t.state.doc.content.size,e)]}function LN(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:Kn.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function DN(t){return!t.someProp("editable",e=>e(t.state)===!1)}function m6(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 _N(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 g6(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 zN(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 mo={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:"'"},ff={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},x6=typeof navigator<"u"&&/Mac/.test(navigator.platform),y6=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var cs=0;cs<10;cs++)mo[48+cs]=mo[96+cs]=String(cs);for(var cs=1;cs<=24;cs++)mo[cs+111]="F"+cs;for(var cs=65;cs<=90;cs++)mo[cs]=String.fromCharCode(cs+32),ff[cs]=String.fromCharCode(cs);for(var Pg in mo)ff.hasOwnProperty(Pg)||(ff[Pg]=mo[Pg]);function b6(t){var e=x6&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||y6&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?ff:mo)[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 v6=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),N6=typeof navigator<"u"&&/Win/.test(navigator.platform);function w6(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)S6(t,n,{get:e[n],enumerable:!0})};function pp(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 mp=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:a}=n,i=this.buildProps(a);return Object.fromEntries(Object.entries(t).map(([o,c])=>[o,(...h)=>{const f=c(...h)(i);return!a.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(a),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:a}=this,{view:i}=r,o=[],c=!!t,u=t||a.tr,h=()=>(!c&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(u),o.every(m=>m===!0)),f={...Object.fromEntries(Object.entries(n).map(([m,g])=>[m,(...N)=>{const w=this.buildProps(u,e),j=g(...N)(w);return o.push(j),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:pp({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}},HS={};Z0(HS,{blur:()=>C6,clearContent:()=>T6,clearNodes:()=>E6,command:()=>M6,createParagraphNear:()=>A6,cut:()=>I6,deleteCurrentNode:()=>R6,deleteNode:()=>P6,deleteRange:()=>O6,deleteSelection:()=>L6,enter:()=>D6,exitCode:()=>_6,extendMarkRange:()=>z6,first:()=>$6,focus:()=>B6,forEach:()=>V6,insertContent:()=>H6,insertContentAt:()=>K6,joinBackward:()=>J6,joinDown:()=>G6,joinForward:()=>Q6,joinItemBackward:()=>Y6,joinItemForward:()=>X6,joinTextblockBackward:()=>Z6,joinTextblockForward:()=>eD,joinUp:()=>q6,keyboardShortcut:()=>nD,lift:()=>sD,liftEmptyBlock:()=>rD,liftListItem:()=>aD,newlineInCode:()=>iD,resetAttributes:()=>oD,scrollIntoView:()=>lD,selectAll:()=>cD,selectNodeBackward:()=>dD,selectNodeForward:()=>uD,selectParentNode:()=>hD,selectTextblockEnd:()=>fD,selectTextblockStart:()=>pD,setContent:()=>mD,setMark:()=>LD,setMeta:()=>DD,setNode:()=>_D,setNodeSelection:()=>zD,setTextDirection:()=>$D,setTextSelection:()=>FD,sinkListItem:()=>BD,splitBlock:()=>VD,splitListItem:()=>HD,toggleList:()=>UD,toggleMark:()=>WD,toggleNode:()=>KD,toggleWrap:()=>qD,undoInputRule:()=>GD,unsetAllMarks:()=>JD,unsetMark:()=>QD,unsetTextDirection:()=>YD,updateAttributes:()=>XD,wrapIn:()=>ZD,wrapInList:()=>e_});var C6=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),T6=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),E6=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:a}=r;return n&&a.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(c,u)=>{if(c.type.isText)return;const{doc:h,mapping:f}=e,m=h.resolve(f.map(u)),g=h.resolve(f.map(u+c.nodeSize)),y=m.blockRange(g);if(!y)return;const N=_c(y);if(c.type.isTextblock){const{defaultType:w}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(y.start,w)}(N||N===0)&&e.lift(y,N)})}),!0},M6=t=>e=>t(e),A6=()=>({state:t,dispatch:e})=>rS(t,e),I6=(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 et(r.doc.resolve(Math.max(o-1,0)))),!0},R6=()=>({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 zn(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 P6=t=>({tr:e,state:n,dispatch:r})=>{const a=zn(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},O6=t=>({tr:e,dispatch:n})=>{const{from:r,to:a}=t;return n&&e.delete(r,a),!0},L6=()=>({state:t,dispatch:e})=>z0(t,e),D6=()=>({commands:t})=>t.keyboardShortcut("Enter"),_6=()=>({state:t,dispatch:e})=>vO(t,e);function ey(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function pf(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(a=>n.strict?e[a]===t[a]:ey(e[a])?e[a].test(t[a]):e[a]===t[a]):!0}function US(t,e,n={}){return t.find(r=>r.type===e&&pf(Object.fromEntries(Object.keys(n).map(a=>[a,r.attrs[a]])),n))}function $N(t,e,n={}){return!!US(t,e,n)}function ty(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),!US([...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&&$N([...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=yi(t,r.schema),{doc:o,selection:c}=n,{$from:u,from:h,to:f}=c;if(a){const m=ty(u,i,e);if(m&&m.from<=h&&m.to>=f){const g=et.create(o,m.from,m.to);n.setSelection(g)}}return!0},$6=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=()=>{(mf()||FN())&&r.dom.focus(),F6()&&!mf()&&!FN()&&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&&!WS(n.state.selection))return o(),!0;const c=KS(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},V6=(t,e)=>n=>t.every((r,a)=>e(r,{...n,index:a})),H6=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),qS=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&&qS(r)}return t};function Nh(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 qS(n)}function Xd(t,e,n){if(t instanceof di||t instanceof Ne)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 Ne.fromArray(t.map(c=>e.nodeFromJSON(c)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),Xd("",e,n)}if(a){if(n.errorOnInvalidContent){let o=!1,c="";const u=new I2({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?lo.fromSchema(u).parseSlice(Nh(t),n.parseOptions):lo.fromSchema(u).parse(Nh(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const i=lo.fromSchema(e);return n.slice?i.parseSlice(Nh(t),n.parseOptions).content:i.parse(Nh(t),n.parseOptions)}return Xd("",e,n)}function U6(t,e,n){const r=t.steps.length-1;if(r{o===0&&(o=f)}),t.setSelection(ot.near(t.doc.resolve(o),n))}var W6=t=>!("type"in t),K6=(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=j=>{i.emit("contentError",{editor:i,error:j,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{Xd(e,i.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(j){u(j)}try{c=Xd(e,i.schema,{parseOptions:h,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(j){return u(j),!1}let{from:f,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,y=!0;if((W6(c)?c:[c]).forEach(j=>{j.check(),g=g?j.isText&&j.marks.length===0:!1,y=y?j.isBlock:!1}),f===m&&y){const{parent:j}=r.doc.resolve(f);j.isTextblock&&!j.type.spec.code&&!j.childCount&&(f-=1,m+=1)}let w;if(g){if(Array.isArray(e))w=e.map(j=>j.text||"").join("");else if(e instanceof Ne){let j="";e.forEach(S=>{S.text&&(j+=S.text)}),w=j}else typeof e=="object"&&e&&e.text?w=e.text:w=e;r.insertText(w,f,m)}else{w=c;const j=r.doc.resolve(f),S=j.node(),E=j.parentOffset===0,T=S.isText||S.isTextblock,P=S.content.size>0;E&&T&&P&&(f=Math.max(0,f-1)),r.replaceWith(f,m,w)}n.updateSelection&&U6(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},q6=()=>({state:t,dispatch:e})=>xO(t,e),G6=()=>({state:t,dispatch:e})=>yO(t,e),J6=()=>({state:t,dispatch:e})=>Y2(t,e),Q6=()=>({state:t,dispatch:e})=>tS(t,e),Y6=()=>({state:t,dispatch:e,tr:n})=>{try{const r=lp(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},X6=()=>({state:t,dispatch:e,tr:n})=>{try{const r=lp(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Z6=()=>({state:t,dispatch:e})=>mO(t,e),eD=()=>({state:t,dispatch:e})=>gO(t,e);function GS(){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?zn(e,t.schema):null,c=[];t.doc.nodesBetween(r,a,(m,g)=>{if(m.isText)return;const y=Math.max(r,g),N=Math.min(a,g+m.nodeSize);c.push({node:m,from:y,to:N})});const u=a-r,h=c.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>pf(m.node.attrs,n,{strict:!1}));return i?!!h.length:h.reduce((m,g)=>m+g.to-g.from,0)>=u}var sD=(t,e={})=>({state:n,dispatch:r})=>{const a=zn(t,n.schema);return go(n,a,e)?bO(n,r):!1},rD=()=>({state:t,dispatch:e})=>aS(t,e),aD=t=>({state:e,dispatch:n})=>{const r=zn(t,e.schema);return IO(r)(e,n)},iD=()=>({state:t,dispatch:e})=>sS(t,e);function gp(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function BN(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 oD=(t,e)=>({tr:n,state:r,dispatch:a})=>{let i=null,o=null;const c=gp(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=zn(t,r.schema)),c==="mark"&&(o=yi(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,BN(f.attrs,e))),o&&f.marks.length&&f.marks.forEach(g=>{o===g.type&&(u=!0,a&&n.addMark(m,m+f.nodeSize,o.create(BN(g.attrs,e))))})})}),u},lD=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),cD=()=>({tr:t,dispatch:e})=>{if(e){const n=new or(t.doc);t.setSelection(n)}return!0},dD=()=>({state:t,dispatch:e})=>Z2(t,e),uD=()=>({state:t,dispatch:e})=>nS(t,e),hD=()=>({state:t,dispatch:e})=>jO(t,e),fD=()=>({state:t,dispatch:e})=>CO(t,e),pD=()=>({state:t,dispatch:e})=>SO(t,e);function Lx(t,e,n={},r={}){return Xd(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var mD=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:a,tr:i,dispatch:o,commands:c})=>{const{doc:u}=i;if(r.preserveWhitespace!=="full"){const h=Lx(t,a.schema,r,{errorOnInvalidContent:e??a.options.enableContentCheck});return o&&i.replaceWith(0,u.content.size,h).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),c.insertContentAt({from:0,to:u.content.size},t,{parseOptions:r,errorOnInvalidContent:e??a.options.enableContentCheck})};function JS(t,e){const n=yi(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 QS(t,e){const n=new D0(t);return e.forEach(r=>{r.steps.forEach(a=>{n.step(a)})}),n}function gD(t){for(let e=0;e{n(a)&&r.push({node:a,pos:i})}),r}function YS(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 xp(t){return e=>YS(e.$from,t)}function Ye(t,e,n){return t.config[e]===void 0&&t.parent?Ye(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Ye(t.parent,e,n):null}):t.config[e]}function ny(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Ye(e,"addExtensions",n);return r?[e,...ny(r())]:e}).flat(10)}function sy(t,e){const n=jl.fromSchema(e).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(n),a.innerHTML}function XS(t){return typeof t=="function"}function Bt(t,e=void 0,...n){return XS(t)?e?t.bind(e)(...n):t(...n):t}function yD(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Ec(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 ZS(t){const e=[],{nodeExtensions:n,markExtensions:r}=Ec(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=Ye(h,"addGlobalAttributes",f);if(!m)return;m().forEach(y=>{let N;Array.isArray(y.types)?N=y.types:y.types==="*"?N=u:y.types==="nodes"?N=o:y.types==="marks"?N=c:N=[],N.forEach(w=>{Object.entries(y.attributes).forEach(([j,S])=>{e.push({type:w,name:j,attribute:{...i,...S}})})})})}),a.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage},m=Ye(h,"addAttributes",f);if(!m)return;const g=m();Object.entries(g).forEach(([y,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:y,attribute:w})})}),e}function bD(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 VN(t){const e=[],n=bD(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([...VN(r[a]),...VN(i)]);r[a]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[a]=i}),r},{})}function Zd(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)=>Vt(n,r),{})}function vD(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function HN(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):vD(n.getAttribute(o.name));return c==null?i:{...i,[o.name]:c}},{});return{...r,...a}}}}function UN(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&yD(n)?!1:n!=null))}function WN(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 ND(t,e){var n;const r=ZS(t),{nodeExtensions:a,markExtensions:i}=Ec(t),o=(n=a.find(h=>Ye(h,"topNode")))==null?void 0:n.name,c=Object.fromEntries(a.map(h=>{const f=r.filter(S=>S.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},g=t.reduce((S,E)=>{const T=Ye(E,"extendNodeSchema",m);return{...S,...T?T(h):{}}},{}),y=UN({...g,content:Bt(Ye(h,"content",m)),marks:Bt(Ye(h,"marks",m)),group:Bt(Ye(h,"group",m)),inline:Bt(Ye(h,"inline",m)),atom:Bt(Ye(h,"atom",m)),selectable:Bt(Ye(h,"selectable",m)),draggable:Bt(Ye(h,"draggable",m)),code:Bt(Ye(h,"code",m)),whitespace:Bt(Ye(h,"whitespace",m)),linebreakReplacement:Bt(Ye(h,"linebreakReplacement",m)),defining:Bt(Ye(h,"defining",m)),isolating:Bt(Ye(h,"isolating",m)),attrs:Object.fromEntries(f.map(WN))}),N=Bt(Ye(h,"parseHTML",m));N&&(y.parseDOM=N.map(S=>HN(S,f)));const w=Ye(h,"renderHTML",m);w&&(y.toDOM=S=>w({node:S,HTMLAttributes:Zd(S,f)}));const j=Ye(h,"renderText",m);return j&&(y.toText=j),[h.name,y]})),u=Object.fromEntries(i.map(h=>{const f=r.filter(j=>j.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},g=t.reduce((j,S)=>{const E=Ye(S,"extendMarkSchema",m);return{...j,...E?E(h):{}}},{}),y=UN({...g,inclusive:Bt(Ye(h,"inclusive",m)),excludes:Bt(Ye(h,"excludes",m)),group:Bt(Ye(h,"group",m)),spanning:Bt(Ye(h,"spanning",m)),code:Bt(Ye(h,"code",m)),attrs:Object.fromEntries(f.map(WN))}),N=Bt(Ye(h,"parseHTML",m));N&&(y.parseDOM=N.map(j=>HN(j,f)));const w=Ye(h,"renderHTML",m);return w&&(y.toDOM=j=>w({mark:j,HTMLAttributes:Zd(j,f)})),[h.name,y]}));return new I2({topNode:o,nodes:c,marks:u})}function wD(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Ld(t){return t.sort((n,r)=>{const a=Ye(n,"priority")||100,i=Ye(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 tC(t,e,n){const{from:r,to:a}=e,{blockSeparator:i=` +`);return{dom:u,text:x,slice:e}}function CS(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 _e(Ne.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:y}=t.state,N=jl.fromSchema(y);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let j=o.appendChild(document.createElement("p"));w&&j.appendChild(N.serializeNode(y.text(w,x)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=CL(n),du&&TL(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")||lo.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||f),context:a,ruleFromNode(x){return x.nodeName=="BR"&&!x.nextSibling&&x.parentNode&&!jL.test(x.parentNode.nodeName)?{ignore:!0}:null}})),f)c=EL(CN(c,+f[1],+f[2]),f[4]);else if(c=_e.maxOpen(kL(c.content,a),!0),c.openStart||c.openEnd){let m=0,x=0;for(let y=c.content.firstChild;m{c=m(c,t,u)}),c}const jL=/^(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 kL(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&&ES(u,i,c,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=MS(o[o.length-1],i.length));let f=TS(c,u);o.push(f),a=a.matchType(f.type),i=u}}),o)return Ne.from(o)}return t}function TS(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Ne.from(t));return t}function ES(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(Ne.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(c))}function CN(t,e,n){return en})),Ax.createHTML(t)):t}function CL(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=IS().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),a;if((a=r&&AS[r[1].toLowerCase()])&&(t=a.map(i=>"<"+i+">").join("")+t+a.map(i=>"").reverse().join("")),n.innerHTML=SL(t),a)for(let i=0;i=0;c-=2){let u=n.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;a=Ne.from(u.create(r[c+1],a)),i++,o++}return new _e(a,i,o)}const Is={},Rs={},ML={touchstart:!0,touchmove:!0};class AL{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 IL(t){for(let e in Is){let n=Is[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{PL(t,r)&&!q0(t,r)&&(t.editable||!(r.type in Rs))&&n(t,r)},ML[e]?{passive:!0}:void 0)}ws&&t.dom.addEventListener("input",()=>null),Og(t)}function ao(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function RL(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 Og(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>q0(t,r))})}function q0(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function PL(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 OL(t,e){!q0(t,e)&&Is[e.type]&&(t.editable||!(e.type in Rs))&&Is[e.type](t,e)}Rs.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!PS(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(ci&&fs&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Tc&&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,Jo(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||wL(t,n)?n.preventDefault():ao(t,"key")};Rs.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Rs.keypress=(t,e)=>{let n=e;if(PS(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 et)||!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 fp(t){return{left:t.clientX,top:t.clientY}}function LL(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function G0(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 gc(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 DL(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Ze.isSelectable(r)?(gc(t,new Ze(n)),!0):!1}function _L(t,e){if(e==-1)return!1;let n=t.state.selection,r,a;n instanceof Ze&&(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(Ze.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?(gc(t,Ze.create(t.state.doc,a)),!0):!1}function zL(t,e,n,r,a){return G0(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(a?_L(t,n):DL(t,n))}function $L(t,e,n,r){return G0(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",a=>a(t,e,r))}function FL(t,e,n,r){return G0(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",a=>a(t,e,r))||BL(t,n,r)}function BL(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(gc(t,et.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)gc(t,et.create(r,c+1,c+1+o.content.size));else if(Ze.isSelectable(o))gc(t,Ze.create(r,c));else continue;return!0}}function J0(t){return df(t)}const RS=kr?"metaKey":"ctrlKey";Is.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=J0(t),a=Date.now(),i="singleClick";a-t.input.lastClick.time<500&&LL(n,t.input.lastClick)&&!n[RS]&&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(fp(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new VL(t,o,n,!!r)):(i=="doubleClick"?$L:FL)(t,o.pos,o.inside,n)?n.preventDefault():ao(t,"pointer"))};class VL{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[RS],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 Ze&&h.from<=o&&h.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Cr&&!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)),ao(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(()=>hi(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(fp(e))),this.updateAllowDefault(e),this.allowDefault||!n?ao(this.view,"pointer"):zL(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ws&&this.mightDrag&&!this.mightDrag.node.isAtom||fs&&!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)?(gc(this.view,ot.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):ao(this.view,"pointer")}move(e){this.updateAllowDefault(e),ao(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)}}Is.touchstart=t=>{t.input.lastTouch=Date.now(),J0(t),ao(t,"pointer")};Is.touchmove=t=>{t.input.lastTouch=Date.now(),ao(t,"pointer")};Is.contextmenu=t=>J0(t);function PS(t,e){return t.composing?!0:ws&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const HL=ci?5e3:-1;Rs.compositionstart=Rs.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof et&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||fs&&dS&&UL(t)))t.markCursor=t.state.storedMarks||n.marks(),df(t,!0),t.markCursor=null;else if(df(t,!e.selection.empty),Cr&&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}OS(t,HL)};function UL(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"}Rs.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++,OS(t,20))};function OS(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>df(t),e))}function LS(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=KL());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function WL(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=_O(e.focusNode,e.focusOffset),r=zO(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 KL(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function df(t,e=!1){if(!(ci&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),LS(t),e||t.docView&&t.docView.dirty){let n=U0(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 qL(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 Jd=Js&&co<15||Tc&&VO<604;Is.copy=Rs.cut=(t,e)=>{let n=e,r=t.state.selection,a=n.type=="cut";if(r.empty)return;let i=Jd?null:n.clipboardData,o=r.content(),{dom:c,text:u}=K0(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",c.innerHTML),i.setData("text/plain",u)):qL(t,c),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function GL(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function JL(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?Qd(t,r.value,null,a,e):Qd(t,r.textContent,r.innerHTML,a,e)},50)}function Qd(t,e,n,r,a){let i=CS(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,a,i||_e.empty)))return!0;if(!i)return!1;let o=GL(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 DS(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," "):""}Rs.paste=(t,e)=>{let n=e;if(t.composing&&!ci)return;let r=Jd?null:n.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Qd(t,DS(r),r.getData("text/html"),a,n)?n.preventDefault():JL(t,n)};class _S{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const QL=kr?"altKey":"ctrlKey";function zS(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[QL]}Is.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(fp(n)),o;if(!(i&&i.pos>=a.from&&i.pos<=(a instanceof Ze?a.to-1:a.to))){if(r&&r.mightDrag)o=Ze.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=Ze.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:u,text:h,slice:f}=K0(t,c);(!n.dataTransfer.files.length||!fs||cS>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Jd?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Jd||n.dataTransfer.setData("text/plain",h),t.dragging=new _S(f,zS(t,n),o)};Is.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Rs.dragover=Rs.dragenter=(t,e)=>e.preventDefault();Rs.drop=(t,e)=>{try{YL(t,e,t.dragging)}finally{t.dragging=null}};function YL(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(fp(e));if(!r)return;let a=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",y=>{i=y(i,t,!1)}):i=CS(t,DS(e.dataTransfer),Jd?null:e.dataTransfer.getData("text/html"),!1,a);let o=!!(n&&zS(t,e));if(t.someProp("handleDrop",y=>y(t,e,i||_e.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let c=i?V2(t.state.doc,a.pos,i):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(o){let{node:y}=n;y?y.replace(u):u.deleteSelection()}let h=u.mapping.map(c),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,m=u.doc;if(f?u.replaceRangeWith(h,h,i.content.firstChild):u.replaceRange(h,h,i),u.doc.eq(m))return;let x=u.doc.resolve(h);if(f&&Ze.isSelectable(i.content.firstChild)&&x.nodeAfter&&x.nodeAfter.sameMarkup(i.content.firstChild))u.setSelection(new Ze(x));else{let y=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((N,w,j,S)=>y=S),u.setSelection(W0(t,x,u.doc.resolve(y)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}Is.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())&&hi(t)},20))};Is.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)};Is.beforeinput=(t,e)=>{if(fs&&ci&&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,Jo(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 Rs)Is[t]=Rs[t];function Yd(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 uf{constructor(e,n){this.toDOM=e,this.spec=n||al,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 Kn(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof uf&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Yd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ho{constructor(e,n){this.attrs=e,this.spec=n||al}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 Kn(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==vs||e.maps.length==0?this:this.mapInner(e,n,0,0,r||al)}mapInner(e,n,r,a,i){let o;for(let c=0;c{let h=u+r,f;if(f=FS(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 ho){let h=Math.max(i,u.from)-i,f=Math.min(o,u.to)-i;ha.map(e,n,al));return Xi.from(r)}forChild(e,n){if(n.isLeaf)return Xt.empty;let r=[];for(let a=0;an instanceof Xt)?e:e.reduce((n,r)=>n.concat(r instanceof Xt?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let j=w-N-(y-x);for(let S=0;SE+f-m)continue;let T=c[S]+f-m;y>=T?c[S+1]=x<=T?-2:-1:x>=f&&j&&(c[S]+=j,c[S+1]+=j)}m+=j}),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),y=x-a,{index:N,offset:w}=r.content.findIndex(m),j=r.maybeChild(N);if(j&&w==m&&w+j.nodeSize==y){let S=c[h+2].mapInner(n,j,f+1,t[h]+i+1,o);S!=vs?(c[h]=m,c[h+1]=y,c[h+2]=S):(c[h+1]=-2,u=!0)}else u=!0}if(u){let h=ZL(c,t,e,n,a,i,o),f=hf(h,r,0,o);e=f.local;for(let m=0;mn&&o.to{let h=FS(t,c,u+n);if(h){i=!0;let f=hf(h,c,n+u+1,r);f!=vs&&a.push(u,u+c.nodeSize,f)}});let o=$S(i?BS(t):t,-n).sort(il);for(let c=0;c0;)e++;t.splice(e,0,n)}function Ix(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=vs&&e.push(r)}),t.cursorWrapper&&e.push(Xt.create(t.state.doc,[t.cursorWrapper.deco])),Xi.from(e)}const e6={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},t6=Js&&co<=11;class n6{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 s6{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new n6,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():ws&&e.composing&&r.some(a=>a.type=="childList"&&a.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),t6&&(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,e6)),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(vN(this.view)){if(this.suppressingSelectionUpdates)return hi(this.view);if(Js&&co<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ml(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=Cc(i))n.add(i);for(let i=e.anchorNode;i;i=Cc(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)&&vN(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(Cr&&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 y=x.parentNode;y&&y.nodeName=="LI"&&(!m||i6(e,m)!=y)&&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),r6(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,o6(e,u)),this.handleDOMChange(i,o,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||hi(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;j--){let S=r.childNodes[j-1],E=S.pmViewDesc;if(S.nodeName=="BR"&&!E){i=j;break}if(!E||E.size)break}let m=t.state.doc,x=t.someProp("domParser")||lo.fromSchema(t.state.schema),y=m.resolve(o),N=null,w=x.parse(r,{topNode:y.parent,topMatch:y.parent.contentMatchAt(y.index()),topOpen:!0,from:a,to:i,preserveWhitespace:y.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:c6,context:y});if(h&&h[0].pos!=null){let j=h[0].pos,S=h[1]&&h[1].pos;S==null&&(S=j),N={anchor:j+o,head:S+o}}return{doc:w,sel:N,from:o,to:c}}function c6(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ws&&/^(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||ws&&/^(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 d6=/^(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 u6(t,e,n,r,a){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let z=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,V=U0(t,z);if(V&&!t.state.selection.eq(V)){if(fs&&ci&&t.input.lastKeyCode===13&&Date.now()-100te(t,Jo(13,"Enter"))))return;let I=t.state.tr.setSelection(V);z=="pointer"?I.setMeta("pointer",!0):z=="key"&&I.scrollIntoView(),i&&I.setMeta("composition",i),t.dispatch(I)}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=l6(t,e,n),f=t.state.doc,m=f.slice(h.from,h.to),x,y;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||ci)&&a.some(z=>z.nodeType==1&&!d6.test(z.nodeName))&&(!N||N.endA>=N.endB)&&t.someProp("handleKeyDown",z=>z(t,Jo(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!N)if(r&&u instanceof et&&!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 z=RN(t,t.state.doc,h.sel);if(z&&!z.eq(t.state.selection)){let V=t.state.tr.setSelection(z);i&&V.setMeta("composition",i),t.dispatch(V)}}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)),Js&&co<=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),j=h.doc.resolveNoCache(N.endB-h.from),S=f.resolve(N.start),E=w.sameParent(j)&&w.parent.inlineContent&&S.end()>=N.endA;if((Tc&&t.input.lastIOSEnter>Date.now()-225&&(!E||a.some(z=>z.nodeName=="DIV"||z.nodeName=="P"))||!E&&w.posz(t,Jo(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>N.start&&f6(f,N.start,N.endA,w,j)&&t.someProp("handleKeyDown",z=>z(t,Jo(8,"Backspace")))){ci&&fs&&t.domObserver.suppressSelectionUpdates();return}fs&&N.endB==N.start&&(t.input.lastChromeDelete=Date.now()),ci&&!E&&w.start()!=j.start()&&j.parentOffset==0&&w.depth==j.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==N.endA&&(N.endB-=2,j=h.doc.resolveNoCache(N.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function(z){return z(t,Jo(13,"Enter"))})},20));let T=N.start,P=N.endA,O=z=>{let V=z||t.state.tr.replace(T,P,h.doc.slice(N.start-h.from,N.endB-h.from));if(h.sel){let I=RN(t,V.doc,h.sel);I&&!(fs&&t.composing&&I.empty&&(N.start!=N.endB||t.input.lastChromeDeletehi(t),20));let z=O(t.state.tr.delete(T,P)),V=f.resolve(N.start).marksAcross(f.resolve(N.endA));V&&z.ensureMarks(V),t.dispatch(z)}else if(N.endA==N.endB&&(q=h6(w.parent.content.cut(w.parentOffset,j.parentOffset),S.parent.content.cut(S.parentOffset,N.endA-S.start())))){let z=O(t.state.tr);q.type=="add"?z.addMark(T,P,q.mark):z.removeMark(T,P,q.mark),t.dispatch(z)}else if(w.parent.child(w.index()).isText&&w.index()==j.index()-(j.textOffset?0:1)){let z=w.parent.textBetween(w.parentOffset,j.parentOffset),V=()=>O(t.state.tr.insertText(z,T,P));t.someProp("handleTextInput",I=>I(t,T,P,z,V))||t.dispatch(V())}else t.dispatch(O());else t.dispatch(O())}function RN(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:W0(t,e.resolve(n.anchor),e.resolve(n.head))}function h6(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||Rx(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 p6(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 VS{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 AL,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(zN),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=DN(this),LN(this),this.nodeViews=_N(this),this.docView=pN(this.state.doc,ON(this),Ix(this),this.dom,this),this.domObserver=new s6(this,(r,a,i,o)=>u6(this,r,a,i,o)),this.domObserver.start(),IL(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&&Og(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(zN),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&&(LS(this),o=!0),this.state=e;let c=a.plugins!=e.plugins||this._props.plugins!=n.plugins;if(c||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let y=_N(this);x6(y,this.nodeViews)&&(this.nodeViews=y,i=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&Og(this),this.editable=DN(this),LN(this);let u=Ix(this),h=ON(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&&WO(this);if(o){this.domObserver.stop();let y=m&&(Js||fs)&&!this.composing&&!a.selection.empty&&!e.selection.empty&&m6(a.selection,e.selection);if(m){let N=fs?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=WL(this)),(i||!this.docView.update(e.doc,h,u,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=pN(e.doc,h,u,this.dom,this)),N&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(y=!0)}y||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&mL(this))?hi(this,y):(jS(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&&KO(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 Ze){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&lN(this,n.getBoundingClientRect(),e)}else lN(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 _S(e.slice,e.move,a<0?void 0:Ze.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 XO(this,e)}coordsAtPos(e,n=1){return mS(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 sL(this,n||this.state,e)}pasteHTML(e,n){return Qd(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Qd(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return K0(this,e)}destroy(){this.docView&&(RL(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ix(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,LO())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return OL(this,e)}domSelectionRange(){let e=this.domSelection();return e?ws&&this.root.nodeType===11&&FO(this.dom.ownerDocument)==this.dom&&a6(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}VS.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function ON(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"),[Kn.node(0,t.state.doc.content.size,e)]}function LN(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:Kn.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function DN(t){return!t.someProp("editable",e=>e(t.state)===!1)}function m6(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 _N(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 x6(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 zN(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 mo={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:"'"},ff={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},g6=typeof navigator<"u"&&/Mac/.test(navigator.platform),y6=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var cs=0;cs<10;cs++)mo[48+cs]=mo[96+cs]=String(cs);for(var cs=1;cs<=24;cs++)mo[cs+111]="F"+cs;for(var cs=65;cs<=90;cs++)mo[cs]=String.fromCharCode(cs+32),ff[cs]=String.fromCharCode(cs);for(var Px in mo)ff.hasOwnProperty(Px)||(ff[Px]=mo[Px]);function b6(t){var e=g6&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||y6&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?ff:mo)[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 v6=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),N6=typeof navigator<"u"&&/Win/.test(navigator.platform);function w6(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)S6(t,n,{get:e[n],enumerable:!0})};function pp(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 mp=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),j=x(...N)(w);return o.push(j),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:pp({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}},HS={};Z0(HS,{blur:()=>C6,clearContent:()=>T6,clearNodes:()=>E6,command:()=>M6,createParagraphNear:()=>A6,cut:()=>I6,deleteCurrentNode:()=>R6,deleteNode:()=>P6,deleteRange:()=>O6,deleteSelection:()=>L6,enter:()=>D6,exitCode:()=>_6,extendMarkRange:()=>z6,first:()=>$6,focus:()=>B6,forEach:()=>V6,insertContent:()=>H6,insertContentAt:()=>K6,joinBackward:()=>J6,joinDown:()=>G6,joinForward:()=>Q6,joinItemBackward:()=>Y6,joinItemForward:()=>X6,joinTextblockBackward:()=>Z6,joinTextblockForward:()=>eD,joinUp:()=>q6,keyboardShortcut:()=>nD,lift:()=>sD,liftEmptyBlock:()=>rD,liftListItem:()=>aD,newlineInCode:()=>iD,resetAttributes:()=>oD,scrollIntoView:()=>lD,selectAll:()=>cD,selectNodeBackward:()=>dD,selectNodeForward:()=>uD,selectParentNode:()=>hD,selectTextblockEnd:()=>fD,selectTextblockStart:()=>pD,setContent:()=>mD,setMark:()=>LD,setMeta:()=>DD,setNode:()=>_D,setNodeSelection:()=>zD,setTextDirection:()=>$D,setTextSelection:()=>FD,sinkListItem:()=>BD,splitBlock:()=>VD,splitListItem:()=>HD,toggleList:()=>UD,toggleMark:()=>WD,toggleNode:()=>KD,toggleWrap:()=>qD,undoInputRule:()=>GD,unsetAllMarks:()=>JD,unsetMark:()=>QD,unsetTextDirection:()=>YD,updateAttributes:()=>XD,wrapIn:()=>ZD,wrapInList:()=>e_});var C6=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),T6=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),E6=()=>({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)),y=m.blockRange(x);if(!y)return;const N=_c(y);if(c.type.isTextblock){const{defaultType:w}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(y.start,w)}(N||N===0)&&e.lift(y,N)})}),!0},M6=t=>e=>t(e),A6=()=>({state:t,dispatch:e})=>rS(t,e),I6=(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 et(r.doc.resolve(Math.max(o-1,0)))),!0},R6=()=>({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 zn(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 P6=t=>({tr:e,state:n,dispatch:r})=>{const a=zn(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},O6=t=>({tr:e,dispatch:n})=>{const{from:r,to:a}=t;return n&&e.delete(r,a),!0},L6=()=>({state:t,dispatch:e})=>z0(t,e),D6=()=>({commands:t})=>t.keyboardShortcut("Enter"),_6=()=>({state:t,dispatch:e})=>vO(t,e);function ey(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function pf(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(a=>n.strict?e[a]===t[a]:ey(e[a])?e[a].test(t[a]):e[a]===t[a]):!0}function US(t,e,n={}){return t.find(r=>r.type===e&&pf(Object.fromEntries(Object.keys(n).map(a=>[a,r.attrs[a]])),n))}function $N(t,e,n={}){return!!US(t,e,n)}function ty(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),!US([...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&&$N([...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=yi(t,r.schema),{doc:o,selection:c}=n,{$from:u,from:h,to:f}=c;if(a){const m=ty(u,i,e);if(m&&m.from<=h&&m.to>=f){const x=et.create(o,m.from,m.to);n.setSelection(x)}}return!0},$6=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=()=>{(mf()||FN())&&r.dom.focus(),F6()&&!mf()&&!FN()&&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&&!WS(n.state.selection))return o(),!0;const c=KS(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},V6=(t,e)=>n=>t.every((r,a)=>e(r,{...n,index:a})),H6=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),qS=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&&qS(r)}return t};function Nh(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 qS(n)}function Xd(t,e,n){if(t instanceof di||t instanceof Ne)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 Ne.fromArray(t.map(c=>e.nodeFromJSON(c)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),Xd("",e,n)}if(a){if(n.errorOnInvalidContent){let o=!1,c="";const u=new I2({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?lo.fromSchema(u).parseSlice(Nh(t),n.parseOptions):lo.fromSchema(u).parse(Nh(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const i=lo.fromSchema(e);return n.slice?i.parseSlice(Nh(t),n.parseOptions).content:i.parse(Nh(t),n.parseOptions)}return Xd("",e,n)}function U6(t,e,n){const r=t.steps.length-1;if(r{o===0&&(o=f)}),t.setSelection(ot.near(t.doc.resolve(o),n))}var W6=t=>!("type"in t),K6=(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=j=>{i.emit("contentError",{editor:i,error:j,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{Xd(e,i.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(j){u(j)}try{c=Xd(e,i.schema,{parseOptions:h,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(j){return u(j),!1}let{from:f,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},x=!0,y=!0;if((W6(c)?c:[c]).forEach(j=>{j.check(),x=x?j.isText&&j.marks.length===0:!1,y=y?j.isBlock:!1}),f===m&&y){const{parent:j}=r.doc.resolve(f);j.isTextblock&&!j.type.spec.code&&!j.childCount&&(f-=1,m+=1)}let w;if(x){if(Array.isArray(e))w=e.map(j=>j.text||"").join("");else if(e instanceof Ne){let j="";e.forEach(S=>{S.text&&(j+=S.text)}),w=j}else typeof e=="object"&&e&&e.text?w=e.text:w=e;r.insertText(w,f,m)}else{w=c;const j=r.doc.resolve(f),S=j.node(),E=j.parentOffset===0,T=S.isText||S.isTextblock,P=S.content.size>0;E&&T&&P&&(f=Math.max(0,f-1)),r.replaceWith(f,m,w)}n.updateSelection&&U6(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},q6=()=>({state:t,dispatch:e})=>gO(t,e),G6=()=>({state:t,dispatch:e})=>yO(t,e),J6=()=>({state:t,dispatch:e})=>Y2(t,e),Q6=()=>({state:t,dispatch:e})=>tS(t,e),Y6=()=>({state:t,dispatch:e,tr:n})=>{try{const r=lp(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},X6=()=>({state:t,dispatch:e,tr:n})=>{try{const r=lp(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Z6=()=>({state:t,dispatch:e})=>mO(t,e),eD=()=>({state:t,dispatch:e})=>xO(t,e);function GS(){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 xo(t,e,n={}){const{from:r,to:a,empty:i}=t.selection,o=e?zn(e,t.schema):null,c=[];t.doc.nodesBetween(r,a,(m,x)=>{if(m.isText)return;const y=Math.max(r,x),N=Math.min(a,x+m.nodeSize);c.push({node:m,from:y,to:N})});const u=a-r,h=c.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>pf(m.node.attrs,n,{strict:!1}));return i?!!h.length:h.reduce((m,x)=>m+x.to-x.from,0)>=u}var sD=(t,e={})=>({state:n,dispatch:r})=>{const a=zn(t,n.schema);return xo(n,a,e)?bO(n,r):!1},rD=()=>({state:t,dispatch:e})=>aS(t,e),aD=t=>({state:e,dispatch:n})=>{const r=zn(t,e.schema);return IO(r)(e,n)},iD=()=>({state:t,dispatch:e})=>sS(t,e);function xp(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function BN(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 oD=(t,e)=>({tr:n,state:r,dispatch:a})=>{let i=null,o=null;const c=xp(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=zn(t,r.schema)),c==="mark"&&(o=yi(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,BN(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(BN(x.attrs,e))))})})}),u},lD=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),cD=()=>({tr:t,dispatch:e})=>{if(e){const n=new or(t.doc);t.setSelection(n)}return!0},dD=()=>({state:t,dispatch:e})=>Z2(t,e),uD=()=>({state:t,dispatch:e})=>nS(t,e),hD=()=>({state:t,dispatch:e})=>jO(t,e),fD=()=>({state:t,dispatch:e})=>CO(t,e),pD=()=>({state:t,dispatch:e})=>SO(t,e);function Lg(t,e,n={},r={}){return Xd(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var mD=(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=Lg(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 JS(t,e){const n=yi(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 QS(t,e){const n=new D0(t);return e.forEach(r=>{r.steps.forEach(a=>{n.step(a)})}),n}function xD(t){for(let e=0;e{n(a)&&r.push({node:a,pos:i})}),r}function YS(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 gp(t){return e=>YS(e.$from,t)}function Ye(t,e,n){return t.config[e]===void 0&&t.parent?Ye(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Ye(t.parent,e,n):null}):t.config[e]}function ny(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Ye(e,"addExtensions",n);return r?[e,...ny(r())]:e}).flat(10)}function sy(t,e){const n=jl.fromSchema(e).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(n),a.innerHTML}function XS(t){return typeof t=="function"}function Bt(t,e=void 0,...n){return XS(t)?e?t.bind(e)(...n):t(...n):t}function yD(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Ec(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 ZS(t){const e=[],{nodeExtensions:n,markExtensions:r}=Ec(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=Ye(h,"addGlobalAttributes",f);if(!m)return;m().forEach(y=>{let N;Array.isArray(y.types)?N=y.types:y.types==="*"?N=u:y.types==="nodes"?N=o:y.types==="marks"?N=c:N=[],N.forEach(w=>{Object.entries(y.attributes).forEach(([j,S])=>{e.push({type:w,name:j,attribute:{...i,...S}})})})})}),a.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage},m=Ye(h,"addAttributes",f);if(!m)return;const x=m();Object.entries(x).forEach(([y,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:y,attribute:w})})}),e}function bD(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 VN(t){const e=[],n=bD(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([...VN(r[a]),...VN(i)]);r[a]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[a]=i}),r},{})}function Zd(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)=>Vt(n,r),{})}function vD(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function HN(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):vD(n.getAttribute(o.name));return c==null?i:{...i,[o.name]:c}},{});return{...r,...a}}}}function UN(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&yD(n)?!1:n!=null))}function WN(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 ND(t,e){var n;const r=ZS(t),{nodeExtensions:a,markExtensions:i}=Ec(t),o=(n=a.find(h=>Ye(h,"topNode")))==null?void 0:n.name,c=Object.fromEntries(a.map(h=>{const f=r.filter(S=>S.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},x=t.reduce((S,E)=>{const T=Ye(E,"extendNodeSchema",m);return{...S,...T?T(h):{}}},{}),y=UN({...x,content:Bt(Ye(h,"content",m)),marks:Bt(Ye(h,"marks",m)),group:Bt(Ye(h,"group",m)),inline:Bt(Ye(h,"inline",m)),atom:Bt(Ye(h,"atom",m)),selectable:Bt(Ye(h,"selectable",m)),draggable:Bt(Ye(h,"draggable",m)),code:Bt(Ye(h,"code",m)),whitespace:Bt(Ye(h,"whitespace",m)),linebreakReplacement:Bt(Ye(h,"linebreakReplacement",m)),defining:Bt(Ye(h,"defining",m)),isolating:Bt(Ye(h,"isolating",m)),attrs:Object.fromEntries(f.map(WN))}),N=Bt(Ye(h,"parseHTML",m));N&&(y.parseDOM=N.map(S=>HN(S,f)));const w=Ye(h,"renderHTML",m);w&&(y.toDOM=S=>w({node:S,HTMLAttributes:Zd(S,f)}));const j=Ye(h,"renderText",m);return j&&(y.toText=j),[h.name,y]})),u=Object.fromEntries(i.map(h=>{const f=r.filter(j=>j.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},x=t.reduce((j,S)=>{const E=Ye(S,"extendMarkSchema",m);return{...j,...E?E(h):{}}},{}),y=UN({...x,inclusive:Bt(Ye(h,"inclusive",m)),excludes:Bt(Ye(h,"excludes",m)),group:Bt(Ye(h,"group",m)),spanning:Bt(Ye(h,"spanning",m)),code:Bt(Ye(h,"code",m)),attrs:Object.fromEntries(f.map(WN))}),N=Bt(Ye(h,"parseHTML",m));N&&(y.parseDOM=N.map(j=>HN(j,f)));const w=Ye(h,"renderHTML",m);return w&&(y.toDOM=j=>w({mark:j,HTMLAttributes:Zd(j,f)})),[h.name,y]}));return new I2({topNode:o,nodes:c,marks:u})}function wD(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Ld(t){return t.sort((n,r)=>{const a=Ye(n,"priority")||100,i=Ye(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 tC(t,e,n){const{from:r,to:a}=e,{blockSeparator:i=` -`,textSerializers:o={}}=n||{};let c="";return t.nodesBetween(r,a,(u,h,f,m)=>{var g;u.isBlock&&h>r&&(c+=i);const y=o==null?void 0:o[u.type.name];if(y)return f&&(c+=y({node:u,pos:h,parent:f,index:m,range:e})),!1;u.isText&&(c+=(g=u==null?void 0:u.text)==null?void 0:g.slice(Math.max(r,h)-h,a-h))}),c}function jD(t,e){const n={from:0,to:t.content.size};return tC(t,n,e)}function nC(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function kD(t,e){const n=zn(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 sC(t,e){const n=gp(typeof e=="string"?e:e.name,t.schema);return n==="node"?kD(t,e):n==="mark"?JS(t,e):{}}function SD(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 CD(t){const e=SD(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 rC(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((a,i)=>{const o=[];if(a.ranges.length)a.forEach((c,u)=>{o.push({from:c,to:u})});else{const{from:c,to:u}=n[i];if(c===void 0||u===void 0)return;o.push({from:c,to:u})}o.forEach(({from:c,to:u})=>{const h=e.slice(i).map(c,-1),f=e.slice(i).map(u),m=e.invert().map(h,-1),g=e.invert().map(f);r.push({oldRange:{from:m,to:g},newRange:{from:h,to:f}})})}),CD(r)}function ry(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(a=>{const i=n.resolve(t),o=ty(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 TD=(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 bd(t,e){return e.nodes[t]||e.marks[t]||null}function $h(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 ED=(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 Dx(t,e,n={}){const{empty:r,ranges:a}=t.selection,i=e?yi(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>pf(m.attrs,n,{strict:!1}));let o=0;const c=[];if(a.forEach(({$from:m,$to:g})=>{const y=m.pos,N=g.pos;t.doc.nodesBetween(y,N,(w,j)=>{if(i&&w.inlineContent&&!w.type.allowsMarkType(i))return!1;if(!w.isText&&!w.marks.length)return;const S=Math.max(y,j),E=Math.min(N,j+w.nodeSize),T=E-S;o+=T,c.push(...w.marks.map(P=>({mark:P,from:S,to:E})))})}),o===0)return!1;const u=c.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>pf(m.mark.attrs,n,{strict:!1})).reduce((m,g)=>m+g.to-g.from,0),h=c.filter(m=>i?m.mark.type!==i&&m.mark.type.excludes(i):!0).reduce((m,g)=>m+g.to-g.from,0);return(u>0?u+h:u)>=o}function MD(t,e,n={}){if(!e)return go(t,null,n)||Dx(t,null,n);const r=gp(e,t.schema);return r==="node"?go(t,e,n):r==="mark"?Dx(t,e,n):!1}var AD=(t,e)=>{const{$from:n,$to:r,$anchor:a}=t.selection;if(e){const i=xp(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 KN(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function qN(t,e){const{nodeExtensions:n}=Ec(e),r=n.find(o=>o.name===t);if(!r)return!1;const a={name:r.name,options:r.options,storage:r.storage},i=Bt(Ye(r,"group",a));return typeof i!="string"?!1:i.split(" ").includes("list")}function yp(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&&(yp(i,{ignoreWhitespace:n,checkChildren:e})||(a=!1))}),a}return!1}function aC(t){return t instanceof Ze}var iC=class oC{constructor(e){this.position=e}static fromJSON(e){return new oC(e.position)}toJSON(){return{position:this.position}}};function RD(t,e){const n=e.mapping.mapResult(t.position);return{position:new iC(n.pos),mapResult:n}}function PD(t){return new iC(t)}function OD(t,e,n){var r;const{selection:a}=e;let i=null;if(WS(a)&&(i=a.$cursor),i){const c=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(c)||!c.some(h=>h.type.excludes(n)))}const{ranges:o}=a;return o.some(({$from:c,$to:u})=>{let h=c.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(c.pos,u.pos,(f,m,g)=>{if(h)return!1;if(f.isInline){const y=!g||g.type.allowsMarkType(n),N=!!n.isInSet(f.marks)||!f.marks.some(w=>w.type.excludes(n));h=y&&N}return!h}),h})}var LD=(t,e={})=>({tr:n,state:r,dispatch:a})=>{const{selection:i}=n,{empty:o,ranges:c}=i,u=yi(t,r.schema);if(a)if(o){const h=JS(r,u);n.addStoredMark(u.create({...h,...e}))}else c.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;r.doc.nodesBetween(f,m,(g,y)=>{const N=Math.max(y,f),w=Math.min(y+g.nodeSize,m);g.marks.find(S=>S.type===u)?g.marks.forEach(S=>{u===S.type&&n.addMark(N,w,u.create({...S.attrs,...e}))}):n.addMark(N,w,u.create(e))})});return OD(r,n,u)},DD=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),_D=(t,e={})=>({state:n,dispatch:r,chain:a})=>{const i=zn(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})=>aN(i,{...o,...e})(n)?!0:c.clearNodes()).command(({state:c})=>aN(i,{...o,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},zD=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,a=tl(t,0,r.content.size),i=Ze.create(r,a);e.setSelection(i)}return!0},$D=(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},FD=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:a,to:i}=typeof t=="number"?{from:t,to:t}:t,o=et.atStart(r).from,c=et.atEnd(r).to,u=tl(a,o,c),h=tl(i,o,c),f=et.create(r,u,h);e.setSelection(f)}return!0},BD=t=>({state:e,dispatch:n})=>{const r=zn(t,e.schema);return OO(r)(e,n)};function GN(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 VD=({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=$h(h,c.node().type.name,c.node().attrs);if(i instanceof Ze&&i.node.isBlock)return!c.parentOffset||!ui(o,c.pos)?!1:(r&&(t&&GN(n,a.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const m=u.parentOffset===u.parent.content.size,g=c.depth===0?void 0:gD(c.node(-1).contentMatchAt(c.indexAfter(-1)));let y=m&&g?[{type:g,attrs:f}]:void 0,N=ui(e.doc,e.mapping.map(c.pos),1,y);if(!y&&!N&&ui(e.doc,e.mapping.map(c.pos),1,g?[{type:g}]:void 0)&&(N=!0,y=g?[{type:g,attrs:f}]:void 0),r){if(N&&(i instanceof et&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,y),g&&!m&&!c.parentOffset&&c.parent.type!==g)){const w=e.mapping.map(c.before()),j=e.doc.resolve(w);c.node(-1).canReplaceWith(j.index(),j.index()+1,g)&&e.setNodeMarkup(e.mapping.map(c.before()),g)}t&&GN(n,a.extensionManager.splittableMarks),e.scrollIntoView()}return N},HD=(t,e={})=>({tr:n,state:r,dispatch:a,editor:i})=>{var o;const c=zn(t,r.schema),{$from:u,$to:h}=r.selection,f=r.selection.node;if(f&&f.isBlock||u.depth<2||!u.sameParent(h))return!1;const m=u.node(-1);if(m.type!==c)return!1;const g=i.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==c||u.index(-2)!==u.node(-2).childCount-1)return!1;if(a){let S=Ne.empty;const E=u.index(-1)?1:u.index(-2)?2:3;for(let V=u.depth-E;V>=u.depth-3;V-=1)S=Ne.from(u.node(V).copy(S));const T=u.indexAfter(-1){if(z>-1)return!1;V.isTextblock&&V.content.size===0&&(z=I+1)}),z>-1&&n.setSelection(et.near(n.doc.resolve(z))),n.scrollIntoView()}return!0}const y=h.pos===u.end()?m.contentMatchAt(0).defaultType:null,N={...$h(g,m.type.name,m.attrs),...e},w={...$h(g,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,h.pos);const j=y?[{type:c,attrs:N},{type:y,attrs:w}]:[{type:c,attrs:N}];if(!ui(n.doc,u.pos,2))return!1;if(a){const{selection:S,storedMarks:E}=r,{splittableMarks:T}=i.extensionManager,P=E||S.$to.parentOffset&&S.$from.marks();if(n.split(u.pos,2,j).scrollIntoView(),!P||!a)return!0;const O=P.filter(q=>T.includes(q.type.name));n.ensureMarks(O)}return!0},Lg=(t,e)=>{const n=xp(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const a=t.doc.nodeAt(r);return n.node.type===(a==null?void 0:a.type)&&wo(t.doc,n.pos)&&t.join(n.pos),!0},Dg=(t,e)=>{const n=xp(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const a=t.doc.nodeAt(r);return n.node.type===(a==null?void 0:a.type)&&wo(t.doc,r)&&t.join(r),!0},UD=(t,e,n,r={})=>({editor:a,tr:i,state:o,dispatch:c,chain:u,commands:h,can:f})=>{const{extensions:m,splittableMarks:g}=a.extensionManager,y=zn(t,o.schema),N=zn(e,o.schema),{selection:w,storedMarks:j}=o,{$from:S,$to:E}=w,T=S.blockRange(E),P=j||w.$to.parentOffset&&w.$from.marks();if(!T)return!1;const O=xp(q=>qN(q.type.name,m))(w);if(T.depth>=1&&O&&T.depth-O.depth<=1){if(O.node.type===y)return h.liftListItem(N);if(qN(O.node.type.name,m)&&y.validContent(O.node.content)&&c)return u().command(()=>(i.setNodeMarkup(O.pos,y),!0)).command(()=>Lg(i,y)).command(()=>Dg(i,y)).run()}return!n||!P||!c?u().command(()=>f().wrapInList(y,r)?!0:h.clearNodes()).wrapInList(y,r).command(()=>Lg(i,y)).command(()=>Dg(i,y)).run():u().command(()=>{const q=f().wrapInList(y,r),z=P.filter(V=>g.includes(V.type.name));return i.ensureMarks(z),q?!0:h.clearNodes()}).wrapInList(y,r).command(()=>Lg(i,y)).command(()=>Dg(i,y)).run()},WD=(t,e={},n={})=>({state:r,commands:a})=>{const{extendEmptyMarkRange:i=!1}=n,o=yi(t,r.schema);return Dx(r,o,e)?a.unsetMark(o,{extendEmptyMarkRange:i}):a.setMark(o,e)},KD=(t,e,n={})=>({state:r,commands:a})=>{const i=zn(t,r.schema),o=zn(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})},qD=(t,e={})=>({state:n,commands:r})=>{const a=zn(t,n.schema);return go(n,a,e)?r.lift(a):r.wrapIn(a,e)},GD=()=>({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},JD=()=>({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},QD=(t,e={})=>({tr:n,state:r,dispatch:a})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:c}=n,u=yi(t,r.schema),{$from:h,empty:f,ranges:m}=c;if(!a)return!0;if(f&&o){let{from:g,to:y}=c;const N=(i=h.marks().find(j=>j.type===u))==null?void 0:i.attrs,w=ty(h,u,N);w&&(g=w.from,y=w.to),n.removeMark(g,y,u)}else m.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,u)});return n.removeStoredMark(u),!0},YD=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},XD=(t,e={})=>({tr:n,state:r,dispatch:a})=>{let i=null,o=null;const c=gp(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=zn(t,r.schema)),c==="mark"&&(o=yi(t,r.schema));let u=!1;return n.selection.ranges.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;let g,y,N,w;n.selection.empty?r.doc.nodesBetween(f,m,(j,S)=>{i&&i===j.type&&(u=!0,N=Math.max(S,f),w=Math.min(S+j.nodeSize,m),g=S,y=j)}):r.doc.nodesBetween(f,m,(j,S)=>{S=f&&S<=m&&(i&&i===j.type&&(u=!0,a&&n.setNodeMarkup(S,void 0,{...j.attrs,...e})),o&&j.marks.length&&j.marks.forEach(E=>{if(o===E.type&&(u=!0,a)){const T=Math.max(S,f),P=Math.min(S+j.nodeSize,m);n.addMark(T,P,o.create({...E.attrs,...e}))}}))}),y&&(g!==void 0&&a&&n.setNodeMarkup(g,void 0,{...y.attrs,...e}),o&&y.marks.length&&y.marks.forEach(j=>{o===j.type&&a&&n.addMark(N,w,o.create({...j.attrs,...e}))}))}),u},ZD=(t,e={})=>({state:n,dispatch:r})=>{const a=zn(t,n.schema);return TO(a,e)(n,r)},e_=(t,e={})=>({state:n,dispatch:r})=>{const a=zn(t,n.schema);return EO(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={}}},bp=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},n_=(t,e)=>{if(ey(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 wh(t){var e;const{editor:n,from:r,to:a,text:i,rules:o,plugin:c}=t,{view:u}=n;if(u.composing)return!1;const h=u.state.doc.resolve(r);if(h.parent.type.spec.code||(e=h.nodeBefore||h.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let f=!1;const m=ED(h)+i;return o.forEach(g=>{if(f)return;const y=n_(m,g.find);if(!y)return;const N=u.state.tr,w=pp({state:u.state,transaction:N}),j={from:r-(y[0].length-i.length),to:a},{commands:S,chain:E,can:T}=new mp({editor:n,state:w});g.handler({state:w,range:j,match:y,commands:S,chain:E,can:T})===null||!N.steps.length||(g.undoable&&N.setMeta(c,{transform:N,from:r,to:a,text:i}),u.dispatch(N),f=!0)}),f}function s_(t){const{editor:e,rules:n}=t,r=new rn({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=sy(Ne.from(f),o.schema);const{from:m}=u,g=m+f.length;wh({editor:e,from:m,to:g,text:f,rules:n,plugin:r})}),a.selectionSet||a.docChanged?null:i}},props:{handleTextInput(a,i,o,c){return wh({editor:e,from:i,to:o,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:i}=a.state.selection;i&&wh({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?wh({editor:e,from:o.pos,to:o.pos,text:` -`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function r_(t){return Object.prototype.toString.call(t).slice(8,-1)}function jh(t){return r_(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function lC(t,e){const n={...t};return jh(t)&&jh(e)&&Object.keys(e).forEach(r=>{jh(e[r])&&jh(t[r])?n[r]=lC(t[r],e[r]):n[r]=e[r]}),n}var ay=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{...Bt(Ye(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Bt(Ye(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>lC(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}},kl=class cC extends ay{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new cC(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 a_(t){return typeof t=="number"}var i_=class{constructor(t){this.find=t.find,this.handler=t.handler}},o_=(t,e,n)=>{if(ey(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 l_(t){const{editor:e,state:n,from:r,to:a,rule:i,pasteEvent:o,dropEvent:c}=t,{commands:u,chain:h,can:f}=new mp({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,a,(y,N)=>{var w,j,S,E,T;if((j=(w=y.type)==null?void 0:w.spec)!=null&&j.code||!(y.isText||y.isTextblock||y.isInline))return;const P=(T=(E=(S=y.content)==null?void 0:S.size)!=null?E:y.nodeSize)!=null?T:0,O=Math.max(r,N),q=Math.min(a,N+P);if(O>=q)return;const z=y.isText?y.text||"":y.textBetween(O-N,q-N,void 0,"");o_(z,i.find,o).forEach(I=>{if(I.index===void 0)return;const te=O+I.index+1,Q=te+I[0].length,F={from:n.tr.mapping.map(te),to:n.tr.mapping.map(Q)},re=i.handler({state:n,range:F,match:I,commands:u,chain:h,can:f,pasteEvent:o,dropEvent:c});m.push(re)})}),m.every(y=>y!==null)}var kh=null,c_=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function d_(t){const{editor:e,rules:n}=t;let r=null,a=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,c;try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}const u=({state:f,from:m,to:g,rule:y,pasteEvt:N})=>{const w=f.tr,j=pp({state:f,transaction:w});if(!(!l_({editor:e,state:j,from:Math.max(m-1,0),to:g.b-1,rule:y,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 rn({view(m){const g=N=>{var w;r=(w=m.dom.parentElement)!=null&&w.contains(N.target)?m.dom.parentElement:null,r&&(kh=e)},y=()=>{kh&&(kh=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",y),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",y)}}},props:{handleDOMEvents:{drop:(m,g)=>{if(i=r===m.dom.parentElement,c=g,!i){const y=kh;y!=null&&y.isEditable&&setTimeout(()=>{const N=y.state.selection;N&&y.commands.deleteRange({from:N.from,to:N.to})},10)}return!1},paste:(m,g)=>{var y;const N=(y=g.clipboardData)==null?void 0:y.getData("text/html");return o=g,a=!!(N!=null&&N.includes("data-pm-slice")),!1}}},appendTransaction:(m,g,y)=>{const N=m[0],w=N.getMeta("uiEvent")==="paste"&&!a,j=N.getMeta("uiEvent")==="drop"&&!i,S=N.getMeta("applyPasteRules"),E=!!S;if(!w&&!j&&!E)return;if(E){let{text:O}=S;typeof O=="string"?O=O:O=sy(Ne.from(O),y.schema);const{from:q}=S,z=q+O.length,V=c_(O);return u({rule:f,state:y,from:q,to:{b:z},pasteEvt:V})}const T=g.doc.content.findDiffStart(y.doc.content),P=g.doc.content.findDiffEnd(y.doc.content);if(!(!a_(T)||!P||T===P.b))return u({rule:f,state:y,from:T,to:P,pasteEvt:o})}}))}var vp=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=eC(t),this.schema=ND(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:bd(e.name,this.schema)},r=Ye(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Ld([...this.extensions].reverse()).flatMap(r=>{const a={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:bd(r.name,this.schema)},i=[],o=Ye(r,"addKeyboardShortcuts",a);let c={};if(r.type==="mark"&&Ye(r,"exitable",a)&&(c.ArrowRight=()=>kl.handleExit({editor:t,mark:r})),o){const g=Object.fromEntries(Object.entries(o()).map(([y,N])=>[y,()=>N({editor:t})]));c={...c,...g}}const u=k6(c);i.push(u);const h=Ye(r,"addInputRules",a);if(KN(r,t.options.enableInputRules)&&h){const g=h();if(g&&g.length){const y=s_({editor:t,rules:g}),N=Array.isArray(y)?y:[y];i.push(...N)}}const f=Ye(r,"addPasteRules",a);if(KN(r,t.options.enablePasteRules)&&f){const g=f();if(g&&g.length){const y=d_({editor:t,rules:g});i.push(...y)}}const m=Ye(r,"addProseMirrorPlugins",a);if(m){const g=m();i.push(...g)}return i})}get attributes(){return ZS(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Ec(this.extensions);return Object.fromEntries(e.filter(n=>!!Ye(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:zn(n.name,this.schema)},i=Ye(n,"addNodeView",a);if(!i)return[];const o=i();if(!o)return[];const c=(u,h,f,m,g)=>{const y=Zd(u,r);return o({node:u,view:h,getPos:f,decorations:m,innerDecorations:g,editor:t,extension:n,HTMLAttributes:y})};return[n.name,c]}))}dispatchTransaction(t){const{editor:e}=this;return Ld([...this.extensions].reverse()).reduceRight((r,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:bd(a.name,this.schema)},o=Ye(a,"dispatchTransaction",i);return o?c=>{o.call(i,{transaction:c,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return Ld([...this.extensions]).reduce((r,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:bd(a.name,this.schema)},o=Ye(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}=Ec(this.extensions);return Object.fromEntries(e.filter(n=>!!Ye(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:yi(n.name,this.schema)},i=Ye(n,"addMarkView",a);if(!i)return[];const o=(c,u,h)=>{const f=Zd(c,r);return i()({mark:c,view:u,inline:h,editor:t,extension:n,HTMLAttributes:f,updateAttributes:m=>{S_(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:bd(e.name,this.schema)};e.type==="mark"&&((n=Bt(Ye(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const a=Ye(e,"onBeforeCreate",r),i=Ye(e,"onCreate",r),o=Ye(e,"onUpdate",r),c=Ye(e,"onSelectionUpdate",r),u=Ye(e,"onTransaction",r),h=Ye(e,"onFocus",r),f=Ye(e,"onBlur",r),m=Ye(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)})}};vp.resolve=eC;vp.sort=Ld;vp.flatten=ny;var u_={};Z0(u_,{ClipboardTextSerializer:()=>uC,Commands:()=>hC,Delete:()=>fC,Drop:()=>pC,Editable:()=>mC,FocusEvents:()=>xC,Keymap:()=>yC,Paste:()=>bC,Tabindex:()=>vC,TextDirection:()=>NC,focusEventsPluginKey:()=>gC});var Cn=class dC extends ay{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new dC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},uC=Cn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new rn({key:new pn("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=nC(n);return tC(r,{from:o,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),hC=Cn.create({name:"commands",addCommands(){return{...HS}}}),fC=Cn.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=QS(t.before,[t,...e]);rC(f).forEach(y=>{f.mapping.mapResult(y.oldRange.from).deletedAfter&&f.mapping.mapResult(y.oldRange.to).deletedBefore&&f.before.nodesBetween(y.oldRange.from,y.oldRange.to,(N,w)=>{const j=w+N.nodeSize-2,S=y.oldRange.from<=w&&j<=y.oldRange.to;this.editor.emit("delete",{type:"node",node:N,from:w,to:j,newFrom:f.mapping.map(w),newTo:f.mapping.map(j),deletedRange:y.oldRange,newRange:y.newRange,partial:!S,editor:this.editor,transaction:t,combinedTransform:f})})});const g=f.mapping;f.steps.forEach((y,N)=>{var w,j;if(y instanceof Jr){const S=g.slice(N).map(y.from,-1),E=g.slice(N).map(y.to),T=g.invert().map(S,-1),P=g.invert().map(E),O=(w=f.doc.nodeAt(S-1))==null?void 0:w.marks.some(z=>z.eq(y.mark)),q=(j=f.doc.nodeAt(E))==null?void 0:j.marks.some(z=>z.eq(y.mark));this.editor.emit("delete",{type:"mark",mark:y.mark,from:y.from,to:y.to,deletedRange:{from:T,to:P},newRange:{from:S,to:E},partial:!!(q||O),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()}}),pC=Cn.create({name:"drop",addProseMirrorPlugins(){return[new rn({key:new pn("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),mC=Cn.create({name:"editable",addProseMirrorPlugins(){return[new rn({key:new pn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),gC=new pn("focusEvents"),xC=Cn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new rn({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}}}})]}}),yC=Cn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:c})=>{const{selection:u,doc:h}=c,{empty:f,$anchor:m}=u,{pos:g,parent:y}=m,N=m.parent.isTextblock&&g>0?c.doc.resolve(g-1):m,w=N.parent.type.spec.isolating,j=m.pos-m.parentOffset,S=w&&N.parent.childCount===1?j===m.pos:ot.atStart(h).from===g;return!f||!y.type.isTextblock||y.textContent.length||!S||S&&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 mf()||GS()?i:a},addProseMirrorPlugins(){return[new rn({key:new pn("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=ot.atStart(e.doc).from,h=ot.atEnd(e.doc).to;if(i||!(o===u&&c===h)||!yp(n.doc))return;const g=n.tr,y=pp({state:n,transaction:g}),{commands:N}=new mp({editor:this.editor,state:y});if(N.clearNodes(),!!g.steps.length)return g}})]}}),bC=Cn.create({name:"paste",addProseMirrorPlugins(){return[new rn({key:new pn("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),vC=Cn.create({name:"tabindex",addProseMirrorPlugins(){return[new rn({key:new pn("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),NC=Cn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Ec(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 rn({key:new pn("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),h_=class Sd{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 Sd(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Sd(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Sd(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,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 Sd(u,this.editor,a,a||o?n:null);a&&(h.actualDepth=this.depth+1),e.push(h)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let 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 y=o==null?void 0:o[u.type.name];if(y)return f&&(c+=y({node:u,pos:h,parent:f,index:m,range:e})),!1;u.isText&&(c+=(x=u==null?void 0:u.text)==null?void 0:x.slice(Math.max(r,h)-h,a-h))}),c}function jD(t,e){const n={from:0,to:t.content.size};return tC(t,n,e)}function nC(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function kD(t,e){const n=zn(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 sC(t,e){const n=xp(typeof e=="string"?e:e.name,t.schema);return n==="node"?kD(t,e):n==="mark"?JS(t,e):{}}function SD(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 CD(t){const e=SD(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 rC(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}})})}),CD(r)}function ry(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(a=>{const i=n.resolve(t),o=ty(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 TD=(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 bd(t,e){return e.nodes[t]||e.marks[t]||null}function $h(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 ED=(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 Dg(t,e,n={}){const{empty:r,ranges:a}=t.selection,i=e?yi(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>pf(m.attrs,n,{strict:!1}));let o=0;const c=[];if(a.forEach(({$from:m,$to:x})=>{const y=m.pos,N=x.pos;t.doc.nodesBetween(y,N,(w,j)=>{if(i&&w.inlineContent&&!w.type.allowsMarkType(i))return!1;if(!w.isText&&!w.marks.length)return;const S=Math.max(y,j),E=Math.min(N,j+w.nodeSize),T=E-S;o+=T,c.push(...w.marks.map(P=>({mark:P,from:S,to:E})))})}),o===0)return!1;const u=c.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>pf(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 MD(t,e,n={}){if(!e)return xo(t,null,n)||Dg(t,null,n);const r=xp(e,t.schema);return r==="node"?xo(t,e,n):r==="mark"?Dg(t,e,n):!1}var AD=(t,e)=>{const{$from:n,$to:r,$anchor:a}=t.selection;if(e){const i=gp(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 KN(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function qN(t,e){const{nodeExtensions:n}=Ec(e),r=n.find(o=>o.name===t);if(!r)return!1;const a={name:r.name,options:r.options,storage:r.storage},i=Bt(Ye(r,"group",a));return typeof i!="string"?!1:i.split(" ").includes("list")}function yp(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&&(yp(i,{ignoreWhitespace:n,checkChildren:e})||(a=!1))}),a}return!1}function aC(t){return t instanceof Ze}var iC=class oC{constructor(e){this.position=e}static fromJSON(e){return new oC(e.position)}toJSON(){return{position:this.position}}};function RD(t,e){const n=e.mapping.mapResult(t.position);return{position:new iC(n.pos),mapResult:n}}function PD(t){return new iC(t)}function OD(t,e,n){var r;const{selection:a}=e;let i=null;if(WS(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 y=!x||x.type.allowsMarkType(n),N=!!n.isInSet(f.marks)||!f.marks.some(w=>w.type.excludes(n));h=y&&N}return!h}),h})}var LD=(t,e={})=>({tr:n,state:r,dispatch:a})=>{const{selection:i}=n,{empty:o,ranges:c}=i,u=yi(t,r.schema);if(a)if(o){const h=JS(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,y)=>{const N=Math.max(y,f),w=Math.min(y+x.nodeSize,m);x.marks.find(S=>S.type===u)?x.marks.forEach(S=>{u===S.type&&n.addMark(N,w,u.create({...S.attrs,...e}))}):n.addMark(N,w,u.create(e))})});return OD(r,n,u)},DD=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),_D=(t,e={})=>({state:n,dispatch:r,chain:a})=>{const i=zn(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})=>aN(i,{...o,...e})(n)?!0:c.clearNodes()).command(({state:c})=>aN(i,{...o,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},zD=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,a=tl(t,0,r.content.size),i=Ze.create(r,a);e.setSelection(i)}return!0},$D=(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},FD=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:a,to:i}=typeof t=="number"?{from:t,to:t}:t,o=et.atStart(r).from,c=et.atEnd(r).to,u=tl(a,o,c),h=tl(i,o,c),f=et.create(r,u,h);e.setSelection(f)}return!0},BD=t=>({state:e,dispatch:n})=>{const r=zn(t,e.schema);return OO(r)(e,n)};function GN(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 VD=({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=$h(h,c.node().type.name,c.node().attrs);if(i instanceof Ze&&i.node.isBlock)return!c.parentOffset||!ui(o,c.pos)?!1:(r&&(t&&GN(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:xD(c.node(-1).contentMatchAt(c.indexAfter(-1)));let y=m&&x?[{type:x,attrs:f}]:void 0,N=ui(e.doc,e.mapping.map(c.pos),1,y);if(!y&&!N&&ui(e.doc,e.mapping.map(c.pos),1,x?[{type:x}]:void 0)&&(N=!0,y=x?[{type:x,attrs:f}]:void 0),r){if(N&&(i instanceof et&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,y),x&&!m&&!c.parentOffset&&c.parent.type!==x)){const w=e.mapping.map(c.before()),j=e.doc.resolve(w);c.node(-1).canReplaceWith(j.index(),j.index()+1,x)&&e.setNodeMarkup(e.mapping.map(c.before()),x)}t&&GN(n,a.extensionManager.splittableMarks),e.scrollIntoView()}return N},HD=(t,e={})=>({tr:n,state:r,dispatch:a,editor:i})=>{var o;const c=zn(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 S=Ne.empty;const E=u.index(-1)?1:u.index(-2)?2:3;for(let V=u.depth-E;V>=u.depth-3;V-=1)S=Ne.from(u.node(V).copy(S));const T=u.indexAfter(-1){if(z>-1)return!1;V.isTextblock&&V.content.size===0&&(z=I+1)}),z>-1&&n.setSelection(et.near(n.doc.resolve(z))),n.scrollIntoView()}return!0}const y=h.pos===u.end()?m.contentMatchAt(0).defaultType:null,N={...$h(x,m.type.name,m.attrs),...e},w={...$h(x,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,h.pos);const j=y?[{type:c,attrs:N},{type:y,attrs:w}]:[{type:c,attrs:N}];if(!ui(n.doc,u.pos,2))return!1;if(a){const{selection:S,storedMarks:E}=r,{splittableMarks:T}=i.extensionManager,P=E||S.$to.parentOffset&&S.$from.marks();if(n.split(u.pos,2,j).scrollIntoView(),!P||!a)return!0;const O=P.filter(q=>T.includes(q.type.name));n.ensureMarks(O)}return!0},Lx=(t,e)=>{const n=gp(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const a=t.doc.nodeAt(r);return n.node.type===(a==null?void 0:a.type)&&wo(t.doc,n.pos)&&t.join(n.pos),!0},Dx=(t,e)=>{const n=gp(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const a=t.doc.nodeAt(r);return n.node.type===(a==null?void 0:a.type)&&wo(t.doc,r)&&t.join(r),!0},UD=(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,y=zn(t,o.schema),N=zn(e,o.schema),{selection:w,storedMarks:j}=o,{$from:S,$to:E}=w,T=S.blockRange(E),P=j||w.$to.parentOffset&&w.$from.marks();if(!T)return!1;const O=gp(q=>qN(q.type.name,m))(w);if(T.depth>=1&&O&&T.depth-O.depth<=1){if(O.node.type===y)return h.liftListItem(N);if(qN(O.node.type.name,m)&&y.validContent(O.node.content)&&c)return u().command(()=>(i.setNodeMarkup(O.pos,y),!0)).command(()=>Lx(i,y)).command(()=>Dx(i,y)).run()}return!n||!P||!c?u().command(()=>f().wrapInList(y,r)?!0:h.clearNodes()).wrapInList(y,r).command(()=>Lx(i,y)).command(()=>Dx(i,y)).run():u().command(()=>{const q=f().wrapInList(y,r),z=P.filter(V=>x.includes(V.type.name));return i.ensureMarks(z),q?!0:h.clearNodes()}).wrapInList(y,r).command(()=>Lx(i,y)).command(()=>Dx(i,y)).run()},WD=(t,e={},n={})=>({state:r,commands:a})=>{const{extendEmptyMarkRange:i=!1}=n,o=yi(t,r.schema);return Dg(r,o,e)?a.unsetMark(o,{extendEmptyMarkRange:i}):a.setMark(o,e)},KD=(t,e,n={})=>({state:r,commands:a})=>{const i=zn(t,r.schema),o=zn(e,r.schema),c=xo(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})},qD=(t,e={})=>({state:n,commands:r})=>{const a=zn(t,n.schema);return xo(n,a,e)?r.lift(a):r.wrapIn(a,e)},GD=()=>({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},JD=()=>({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},QD=(t,e={})=>({tr:n,state:r,dispatch:a})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:c}=n,u=yi(t,r.schema),{$from:h,empty:f,ranges:m}=c;if(!a)return!0;if(f&&o){let{from:x,to:y}=c;const N=(i=h.marks().find(j=>j.type===u))==null?void 0:i.attrs,w=ty(h,u,N);w&&(x=w.from,y=w.to),n.removeMark(x,y,u)}else m.forEach(x=>{n.removeMark(x.$from.pos,x.$to.pos,u)});return n.removeStoredMark(u),!0},YD=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},XD=(t,e={})=>({tr:n,state:r,dispatch:a})=>{let i=null,o=null;const c=xp(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=zn(t,r.schema)),c==="mark"&&(o=yi(t,r.schema));let u=!1;return n.selection.ranges.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;let x,y,N,w;n.selection.empty?r.doc.nodesBetween(f,m,(j,S)=>{i&&i===j.type&&(u=!0,N=Math.max(S,f),w=Math.min(S+j.nodeSize,m),x=S,y=j)}):r.doc.nodesBetween(f,m,(j,S)=>{S=f&&S<=m&&(i&&i===j.type&&(u=!0,a&&n.setNodeMarkup(S,void 0,{...j.attrs,...e})),o&&j.marks.length&&j.marks.forEach(E=>{if(o===E.type&&(u=!0,a)){const T=Math.max(S,f),P=Math.min(S+j.nodeSize,m);n.addMark(T,P,o.create({...E.attrs,...e}))}}))}),y&&(x!==void 0&&a&&n.setNodeMarkup(x,void 0,{...y.attrs,...e}),o&&y.marks.length&&y.marks.forEach(j=>{o===j.type&&a&&n.addMark(N,w,o.create({...j.attrs,...e}))}))}),u},ZD=(t,e={})=>({state:n,dispatch:r})=>{const a=zn(t,n.schema);return TO(a,e)(n,r)},e_=(t,e={})=>({state:n,dispatch:r})=>{const a=zn(t,n.schema);return EO(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={}}},bp=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},n_=(t,e)=>{if(ey(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 wh(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=ED(h)+i;return o.forEach(x=>{if(f)return;const y=n_(m,x.find);if(!y)return;const N=u.state.tr,w=pp({state:u.state,transaction:N}),j={from:r-(y[0].length-i.length),to:a},{commands:S,chain:E,can:T}=new mp({editor:n,state:w});x.handler({state:w,range:j,match:y,commands:S,chain:E,can:T})===null||!N.steps.length||(x.undoable&&N.setMeta(c,{transform:N,from:r,to:a,text:i}),u.dispatch(N),f=!0)}),f}function s_(t){const{editor:e,rules:n}=t,r=new rn({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=sy(Ne.from(f),o.schema);const{from:m}=u,x=m+f.length;wh({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 wh({editor:e,from:i,to:o,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:i}=a.state.selection;i&&wh({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?wh({editor:e,from:o.pos,to:o.pos,text:` +`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function r_(t){return Object.prototype.toString.call(t).slice(8,-1)}function jh(t){return r_(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function lC(t,e){const n={...t};return jh(t)&&jh(e)&&Object.keys(e).forEach(r=>{jh(e[r])&&jh(t[r])?n[r]=lC(t[r],e[r]):n[r]=e[r]}),n}var ay=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{...Bt(Ye(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Bt(Ye(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>lC(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}},kl=class cC extends ay{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new cC(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 a_(t){return typeof t=="number"}var i_=class{constructor(t){this.find=t.find,this.handler=t.handler}},o_=(t,e,n)=>{if(ey(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 l_(t){const{editor:e,state:n,from:r,to:a,rule:i,pasteEvent:o,dropEvent:c}=t,{commands:u,chain:h,can:f}=new mp({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,a,(y,N)=>{var w,j,S,E,T;if((j=(w=y.type)==null?void 0:w.spec)!=null&&j.code||!(y.isText||y.isTextblock||y.isInline))return;const P=(T=(E=(S=y.content)==null?void 0:S.size)!=null?E:y.nodeSize)!=null?T:0,O=Math.max(r,N),q=Math.min(a,N+P);if(O>=q)return;const z=y.isText?y.text||"":y.textBetween(O-N,q-N,void 0,"");o_(z,i.find,o).forEach(I=>{if(I.index===void 0)return;const te=O+I.index+1,Q=te+I[0].length,F={from:n.tr.mapping.map(te),to:n.tr.mapping.map(Q)},re=i.handler({state:n,range:F,match:I,commands:u,chain:h,can:f,pasteEvent:o,dropEvent:c});m.push(re)})}),m.every(y=>y!==null)}var kh=null,c_=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function d_(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:y,pasteEvt:N})=>{const w=f.tr,j=pp({state:f,transaction:w});if(!(!l_({editor:e,state:j,from:Math.max(m-1,0),to:x.b-1,rule:y,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 rn({view(m){const x=N=>{var w;r=(w=m.dom.parentElement)!=null&&w.contains(N.target)?m.dom.parentElement:null,r&&(kh=e)},y=()=>{kh&&(kh=null)};return window.addEventListener("dragstart",x),window.addEventListener("dragend",y),{destroy(){window.removeEventListener("dragstart",x),window.removeEventListener("dragend",y)}}},props:{handleDOMEvents:{drop:(m,x)=>{if(i=r===m.dom.parentElement,c=x,!i){const y=kh;y!=null&&y.isEditable&&setTimeout(()=>{const N=y.state.selection;N&&y.commands.deleteRange({from:N.from,to:N.to})},10)}return!1},paste:(m,x)=>{var y;const N=(y=x.clipboardData)==null?void 0:y.getData("text/html");return o=x,a=!!(N!=null&&N.includes("data-pm-slice")),!1}}},appendTransaction:(m,x,y)=>{const N=m[0],w=N.getMeta("uiEvent")==="paste"&&!a,j=N.getMeta("uiEvent")==="drop"&&!i,S=N.getMeta("applyPasteRules"),E=!!S;if(!w&&!j&&!E)return;if(E){let{text:O}=S;typeof O=="string"?O=O:O=sy(Ne.from(O),y.schema);const{from:q}=S,z=q+O.length,V=c_(O);return u({rule:f,state:y,from:q,to:{b:z},pasteEvt:V})}const T=x.doc.content.findDiffStart(y.doc.content),P=x.doc.content.findDiffEnd(y.doc.content);if(!(!a_(T)||!P||T===P.b))return u({rule:f,state:y,from:T,to:P,pasteEvt:o})}}))}var vp=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=eC(t),this.schema=ND(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:bd(e.name,this.schema)},r=Ye(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Ld([...this.extensions].reverse()).flatMap(r=>{const a={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:bd(r.name,this.schema)},i=[],o=Ye(r,"addKeyboardShortcuts",a);let c={};if(r.type==="mark"&&Ye(r,"exitable",a)&&(c.ArrowRight=()=>kl.handleExit({editor:t,mark:r})),o){const x=Object.fromEntries(Object.entries(o()).map(([y,N])=>[y,()=>N({editor:t})]));c={...c,...x}}const u=k6(c);i.push(u);const h=Ye(r,"addInputRules",a);if(KN(r,t.options.enableInputRules)&&h){const x=h();if(x&&x.length){const y=s_({editor:t,rules:x}),N=Array.isArray(y)?y:[y];i.push(...N)}}const f=Ye(r,"addPasteRules",a);if(KN(r,t.options.enablePasteRules)&&f){const x=f();if(x&&x.length){const y=d_({editor:t,rules:x});i.push(...y)}}const m=Ye(r,"addProseMirrorPlugins",a);if(m){const x=m();i.push(...x)}return i})}get attributes(){return ZS(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Ec(this.extensions);return Object.fromEntries(e.filter(n=>!!Ye(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:zn(n.name,this.schema)},i=Ye(n,"addNodeView",a);if(!i)return[];const o=i();if(!o)return[];const c=(u,h,f,m,x)=>{const y=Zd(u,r);return o({node:u,view:h,getPos:f,decorations:m,innerDecorations:x,editor:t,extension:n,HTMLAttributes:y})};return[n.name,c]}))}dispatchTransaction(t){const{editor:e}=this;return Ld([...this.extensions].reverse()).reduceRight((r,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:bd(a.name,this.schema)},o=Ye(a,"dispatchTransaction",i);return o?c=>{o.call(i,{transaction:c,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return Ld([...this.extensions]).reduce((r,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:bd(a.name,this.schema)},o=Ye(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}=Ec(this.extensions);return Object.fromEntries(e.filter(n=>!!Ye(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:yi(n.name,this.schema)},i=Ye(n,"addMarkView",a);if(!i)return[];const o=(c,u,h)=>{const f=Zd(c,r);return i()({mark:c,view:u,inline:h,editor:t,extension:n,HTMLAttributes:f,updateAttributes:m=>{S_(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:bd(e.name,this.schema)};e.type==="mark"&&((n=Bt(Ye(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const a=Ye(e,"onBeforeCreate",r),i=Ye(e,"onCreate",r),o=Ye(e,"onUpdate",r),c=Ye(e,"onSelectionUpdate",r),u=Ye(e,"onTransaction",r),h=Ye(e,"onFocus",r),f=Ye(e,"onBlur",r),m=Ye(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)})}};vp.resolve=eC;vp.sort=Ld;vp.flatten=ny;var u_={};Z0(u_,{ClipboardTextSerializer:()=>uC,Commands:()=>hC,Delete:()=>fC,Drop:()=>pC,Editable:()=>mC,FocusEvents:()=>gC,Keymap:()=>yC,Paste:()=>bC,Tabindex:()=>vC,TextDirection:()=>NC,focusEventsPluginKey:()=>xC});var Cn=class dC extends ay{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new dC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},uC=Cn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new rn({key:new pn("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=nC(n);return tC(r,{from:o,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),hC=Cn.create({name:"commands",addCommands(){return{...HS}}}),fC=Cn.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=QS(t.before,[t,...e]);rC(f).forEach(y=>{f.mapping.mapResult(y.oldRange.from).deletedAfter&&f.mapping.mapResult(y.oldRange.to).deletedBefore&&f.before.nodesBetween(y.oldRange.from,y.oldRange.to,(N,w)=>{const j=w+N.nodeSize-2,S=y.oldRange.from<=w&&j<=y.oldRange.to;this.editor.emit("delete",{type:"node",node:N,from:w,to:j,newFrom:f.mapping.map(w),newTo:f.mapping.map(j),deletedRange:y.oldRange,newRange:y.newRange,partial:!S,editor:this.editor,transaction:t,combinedTransform:f})})});const x=f.mapping;f.steps.forEach((y,N)=>{var w,j;if(y instanceof Jr){const S=x.slice(N).map(y.from,-1),E=x.slice(N).map(y.to),T=x.invert().map(S,-1),P=x.invert().map(E),O=(w=f.doc.nodeAt(S-1))==null?void 0:w.marks.some(z=>z.eq(y.mark)),q=(j=f.doc.nodeAt(E))==null?void 0:j.marks.some(z=>z.eq(y.mark));this.editor.emit("delete",{type:"mark",mark:y.mark,from:y.from,to:y.to,deletedRange:{from:T,to:P},newRange:{from:S,to:E},partial:!!(q||O),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()}}),pC=Cn.create({name:"drop",addProseMirrorPlugins(){return[new rn({key:new pn("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),mC=Cn.create({name:"editable",addProseMirrorPlugins(){return[new rn({key:new pn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),xC=new pn("focusEvents"),gC=Cn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new rn({key:xC,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}}}})]}}),yC=Cn.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:y}=m,N=m.parent.isTextblock&&x>0?c.doc.resolve(x-1):m,w=N.parent.type.spec.isolating,j=m.pos-m.parentOffset,S=w&&N.parent.childCount===1?j===m.pos:ot.atStart(h).from===x;return!f||!y.type.isTextblock||y.textContent.length||!S||S&&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 mf()||GS()?i:a},addProseMirrorPlugins(){return[new rn({key:new pn("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=ot.atStart(e.doc).from,h=ot.atEnd(e.doc).to;if(i||!(o===u&&c===h)||!yp(n.doc))return;const x=n.tr,y=pp({state:n,transaction:x}),{commands:N}=new mp({editor:this.editor,state:y});if(N.clearNodes(),!!x.steps.length)return x}})]}}),bC=Cn.create({name:"paste",addProseMirrorPlugins(){return[new rn({key:new pn("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),vC=Cn.create({name:"tabindex",addProseMirrorPlugins(){return[new rn({key:new pn("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),NC=Cn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Ec(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 rn({key:new pn("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),h_=class Sd{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 Sd(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Sd(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Sd(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,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 Sd(u,this.editor,a,a||o?n:null);a&&(h.actualDepth=this.depth+1),e.push(h)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let 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; } @@ -753,24 +753,24 @@ img.ProseMirror-separator { .ProseMirror-focused .ProseMirror-gapcursor { display: block; -}`;function p_(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 m_=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:RD,createMappablePosition:PD},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=KS(e,this.options.autofocus);this.editorState=fc.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=p_(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=XS(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?[mC,uC.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),hC,xC,yC,vC,pC,bC,fC,NC.configure({direction:this.options.textDirection})].filter(a=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[a.name]!==!1:!0):[],...this.options.extensions].filter(a=>["extension","node","mark"].includes(a==null?void 0:a.type));this.extensionManager=new vp(r,this)}createCommandManager(){this.commandManager=new mp({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Lx(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=Lx(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),a=n?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(i);this.editorView=new VS(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 sC(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return MD(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return sy(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=` +}`;function p_(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 m_=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:RD,createMappablePosition:PD},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=KS(e,this.options.autofocus);this.editorState=fc.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=p_(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=XS(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?[mC,uC.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),hC,gC,yC,vC,pC,bC,fC,NC.configure({direction:this.options.textDirection})].filter(a=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[a.name]!==!1:!0):[],...this.options.extensions].filter(a=>["extension","node","mark"].includes(a==null?void 0:a.type));this.extensionManager=new vp(r,this)}createCommandManager(){this.commandManager=new mp({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Lg(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=Lg(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 VS(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 sC(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return MD(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return sy(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=` -`,textSerializers:n={}}=t||{};return jD(this.state.doc,{blockSeparator:e,textSerializers:{...nC(this.schema),...n}})}get isEmpty(){return yp(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 h_(e,this)}get $doc(){return this.$pos(0)}};function Mc(t){return new bp({find:t.find,handler:({state:e,range:n,match:r})=>{const a=Bt(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(ry(n.from,n.to,e.doc).filter(y=>y.mark.type.excluded.find(w=>w===t.type&&w!==y.mark.type)).filter(y=>y.to>h).length)return null;fn.from&&i.delete(n.from+u,h);const g=n.from+u+o.length;i.addMark(n.from+u,g,t.type.create(a||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function wC(t){return new bp({find:t.find,handler:({state:e,range:n,match:r})=>{const a=Bt(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 _x(t){return new bp({find:t.find,handler:({state:e,range:n,match:r})=>{const a=e.doc.resolve(n.from),i=Bt(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 Ac(t){return new bp({find:t.find,handler:({state:e,range:n,match:r,chain:a})=>{const i=Bt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),h=u&&L0(u,t.type,i);if(!h)return null;if(o.wrap(u,h),t.keepMarks&&t.editor){const{selection:m,storedMarks:g}=e,{splittableMarks:y}=t.editor.extensionManager,N=g||m.$to.parentOffset&&m.$from.marks();if(N){const w=N.filter(j=>y.includes(j.type.name));o.ensureMarks(w)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(m,i).run()}const f=o.doc.resolve(n.from-1).nodeBefore;f&&f.type===t.type&&wo(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,f))&&o.join(n.from-1)},undoable:t.undoable})}var g_=t=>"touches"in t,x_=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,g_(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 y_(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Ze){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 b_(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var v_={};Z0(v_,{createAtomBlockMarkdownSpec:()=>N_,createBlockMarkdownSpec:()=>w_,createInlineMarkdownSpec:()=>jC,parseAttributes:()=>iy,parseIndentedBlocks:()=>zx,renderNestedMarkdownContent:()=>ly,serializeAttributes:()=>oy});function iy(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,h=>(n.push(h),`__QUOTED_${n.length-1}__`)),a=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(a){const h=a.map(f=>f.trim().slice(1));e.class=h.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,h,f])=>{var m;const g=parseInt(((m=f.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),y=n[g];y&&(e[h]=y.slice(1,-1))});const u=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return u&&u.split(/\s+/).filter(Boolean).forEach(f=>{f.match(/^[a-zA-Z][\w-]*$/)&&(e[f]=!0)}),e}function oy(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 N_(t){const{nodeName:e,name:n,parseAttributes:r=iy,serializeAttributes:a=oy,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:c}=t,u=n||e,h=f=>{if(!c)return f;const m={};return c.forEach(g=>{g in f&&(m[g]=f[g])}),m};return{parseMarkdown:(f,m)=>{const g={...i,...f.attributes};return m.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(f){var m;const g=new RegExp(`^:::${u}(?:\\s|$)`,"m"),y=(m=f.match(g))==null?void 0:m.index;return y!==void 0?y:-1},tokenize(f,m,g){const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),N=f.match(y);if(!N)return;const w=N[1]||"",j=r(w);if(!o.find(E=>!(E in j)))return{type:e,raw:N[0],attributes:j}}},renderMarkdown:f=>{const m=h(f.attrs||{}),g=a(m),y=g?` {${g}}`:"";return`:::${u}${y} :::`}}}function w_(t){const{nodeName:e,name:n,getContent:r,parseAttributes:a=iy,serializeAttributes:i=oy,defaultAttributes:o={},content:c="block",allowedAttributes:u}=t,h=n||e,f=m=>{if(!u)return m;const g={};return u.forEach(y=>{y in m&&(g[y]=m[y])}),g};return{parseMarkdown:(m,g)=>{let y;if(r){const w=r(m);y=typeof w=="string"?[{type:"text",text:w}]:w}else c==="block"?y=g.parseChildren(m.tokens||[]):y=g.parseInline(m.tokens||[]);const N={...o,...m.attributes};return g.createNode(e,N,y)},markdownTokenizer:{name:e,level:"block",start(m){var g;const y=new RegExp(`^:::${h}`,"m"),N=(g=m.match(y))==null?void 0:g.index;return N!==void 0?N:-1},tokenize(m,g,y){var N;const w=new RegExp(`^:::${h}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),j=m.match(w);if(!j)return;const[S,E=""]=j,T=a(E);let P=1;const O=S.length;let q="";const z=/^:::([\w-]*)(\s.*)?/gm,V=m.slice(O);for(z.lastIndex=0;;){const I=z.exec(V);if(I===null)break;const te=I.index,Q=I[1];if(!((N=I[2])!=null&&N.endsWith(":::"))){if(Q)P+=1;else if(P-=1,P===0){const F=V.slice(0,te);q=F.trim();const re=m.slice(0,O+te+I[0].length);let ae=[];if(q)if(c==="block")for(ae=y.blockTokens(F),ae.forEach(J=>{J.text&&(!J.tokens||J.tokens.length===0)&&(J.tokens=y.inlineTokens(J.text))});ae.length>0;){const J=ae[ae.length-1];if(J.type==="paragraph"&&(!J.text||J.text.trim()===""))ae.pop();else break}else ae=y.inlineTokens(q);return{type:e,raw:re,attributes:T,content:q,tokens:ae}}}}}},renderMarkdown:(m,g)=>{const y=f(m.attrs||{}),N=i(y),w=N?` {${N}}`:"",j=g.renderChildren(m.content||[],` +`,textSerializers:n={}}=t||{};return jD(this.state.doc,{blockSeparator:e,textSerializers:{...nC(this.schema),...n}})}get isEmpty(){return yp(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 h_(e,this)}get $doc(){return this.$pos(0)}};function Mc(t){return new bp({find:t.find,handler:({state:e,range:n,match:r})=>{const a=Bt(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(ry(n.from,n.to,e.doc).filter(y=>y.mark.type.excluded.find(w=>w===t.type&&w!==y.mark.type)).filter(y=>y.to>h).length)return null;fn.from&&i.delete(n.from+u,h);const x=n.from+u+o.length;i.addMark(n.from+u,x,t.type.create(a||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function wC(t){return new bp({find:t.find,handler:({state:e,range:n,match:r})=>{const a=Bt(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 _g(t){return new bp({find:t.find,handler:({state:e,range:n,match:r})=>{const a=e.doc.resolve(n.from),i=Bt(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 Ac(t){return new bp({find:t.find,handler:({state:e,range:n,match:r,chain:a})=>{const i=Bt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),h=u&&L0(u,t.type,i);if(!h)return null;if(o.wrap(u,h),t.keepMarks&&t.editor){const{selection:m,storedMarks:x}=e,{splittableMarks:y}=t.editor.extensionManager,N=x||m.$to.parentOffset&&m.$from.marks();if(N){const w=N.filter(j=>y.includes(j.type.name));o.ensureMarks(w)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(m,i).run()}const f=o.doc.resolve(n.from-1).nodeBefore;f&&f.type===t.type&&wo(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,f))&&o.join(n.from-1)},undoable:t.undoable})}var x_=t=>"touches"in t,g_=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,x_(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 y_(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Ze){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 b_(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var v_={};Z0(v_,{createAtomBlockMarkdownSpec:()=>N_,createBlockMarkdownSpec:()=>w_,createInlineMarkdownSpec:()=>jC,parseAttributes:()=>iy,parseIndentedBlocks:()=>zg,renderNestedMarkdownContent:()=>ly,serializeAttributes:()=>oy});function iy(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),y=n[x];y&&(e[h]=y.slice(1,-1))});const u=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return u&&u.split(/\s+/).filter(Boolean).forEach(f=>{f.match(/^[a-zA-Z][\w-]*$/)&&(e[f]=!0)}),e}function oy(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 N_(t){const{nodeName:e,name:n,parseAttributes:r=iy,serializeAttributes:a=oy,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"),y=(m=f.match(x))==null?void 0:m.index;return y!==void 0?y:-1},tokenize(f,m,x){const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),N=f.match(y);if(!N)return;const w=N[1]||"",j=r(w);if(!o.find(E=>!(E in j)))return{type:e,raw:N[0],attributes:j}}},renderMarkdown:f=>{const m=h(f.attrs||{}),x=a(m),y=x?` {${x}}`:"";return`:::${u}${y} :::`}}}function w_(t){const{nodeName:e,name:n,getContent:r,parseAttributes:a=iy,serializeAttributes:i=oy,defaultAttributes:o={},content:c="block",allowedAttributes:u}=t,h=n||e,f=m=>{if(!u)return m;const x={};return u.forEach(y=>{y in m&&(x[y]=m[y])}),x};return{parseMarkdown:(m,x)=>{let y;if(r){const w=r(m);y=typeof w=="string"?[{type:"text",text:w}]:w}else c==="block"?y=x.parseChildren(m.tokens||[]):y=x.parseInline(m.tokens||[]);const N={...o,...m.attributes};return x.createNode(e,N,y)},markdownTokenizer:{name:e,level:"block",start(m){var x;const y=new RegExp(`^:::${h}`,"m"),N=(x=m.match(y))==null?void 0:x.index;return N!==void 0?N:-1},tokenize(m,x,y){var N;const w=new RegExp(`^:::${h}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),j=m.match(w);if(!j)return;const[S,E=""]=j,T=a(E);let P=1;const O=S.length;let q="";const z=/^:::([\w-]*)(\s.*)?/gm,V=m.slice(O);for(z.lastIndex=0;;){const I=z.exec(V);if(I===null)break;const te=I.index,Q=I[1];if(!((N=I[2])!=null&&N.endsWith(":::"))){if(Q)P+=1;else if(P-=1,P===0){const F=V.slice(0,te);q=F.trim();const re=m.slice(0,O+te+I[0].length);let ie=[];if(q)if(c==="block")for(ie=y.blockTokens(F),ie.forEach(J=>{J.text&&(!J.tokens||J.tokens.length===0)&&(J.tokens=y.inlineTokens(J.text))});ie.length>0;){const J=ie[ie.length-1];if(J.type==="paragraph"&&(!J.text||J.text.trim()===""))ie.pop();else break}else ie=y.inlineTokens(q);return{type:e,raw:re,attributes:T,content:q,tokens:ie}}}}}},renderMarkdown:(m,x)=>{const y=f(m.attrs||{}),N=i(y),w=N?` {${N}}`:"",j=x.renderChildren(m.content||[],` `);return`:::${h}${w} ${j} -:::`}}}function j_(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,a,i,o]=r;e[a]=i||o,r=n.exec(t)}return e}function k_(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function jC(t){const{nodeName:e,name:n,getContent:r,parseAttributes:a=j_,serializeAttributes:i=k_,defaultAttributes:o={},selfClosing:c=!1,allowedAttributes:u}=t,h=n||e,f=g=>{if(!u)return g;const y={};return u.forEach(N=>{const w=typeof N=="string"?N:N.name,j=typeof N=="string"?void 0:N.skipIfDefault;if(w in g){const S=g[w];if(j!==void 0&&S===j)return;y[w]=S}}),y},m=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,y)=>{const N={...o,...g.attributes};if(c)return y.createNode(e,N);const w=r?r(g):g.content||"";return w?y.createNode(e,N,[y.createTextNode(w)]):y.createNode(e,N,[])},markdownTokenizer:{name:e,level:"inline",start(g){const y=c?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),N=g.match(y),w=N==null?void 0:N.index;return w!==void 0?w:-1},tokenize(g,y,N){const w=c?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),j=g.match(w);if(!j)return;let S="",E="";if(c){const[,P]=j;E=P}else{const[,P,O]=j;E=P,S=O||""}const T=a(E.trim());return{type:e,raw:j[0],content:S.trim(),attributes:T}}},renderMarkdown:g=>{let y="";r?y=r(g):g.content&&g.content.length>0&&(y=g.content.filter(S=>S.type==="text").map(S=>S.text).join(""));const N=f(g.attrs||{}),w=i(N),j=w?` ${w}`:"";return c?`[${h}${j}]`:`[${h}${j}]${y}[/${h}]`}}}function zx(t,e,n){var r,a,i,o;const c=t.split(` -`),u=[];let h="",f=0;const m=e.baseIndentSize||2;for(;f0)break;if(g.trim()===""){f+=1,h=`${h}${g} -`;continue}else return}const N=e.extractItemData(y),{indentLevel:w,mainContent:j}=N;h=`${h}${g} +:::`}}}function j_(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,a,i,o]=r;e[a]=i||o,r=n.exec(t)}return e}function k_(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function jC(t){const{nodeName:e,name:n,getContent:r,parseAttributes:a=j_,serializeAttributes:i=k_,defaultAttributes:o={},selfClosing:c=!1,allowedAttributes:u}=t,h=n||e,f=x=>{if(!u)return x;const y={};return u.forEach(N=>{const w=typeof N=="string"?N:N.name,j=typeof N=="string"?void 0:N.skipIfDefault;if(w in x){const S=x[w];if(j!==void 0&&S===j)return;y[w]=S}}),y},m=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(x,y)=>{const N={...o,...x.attributes};if(c)return y.createNode(e,N);const w=r?r(x):x.content||"";return w?y.createNode(e,N,[y.createTextNode(w)]):y.createNode(e,N,[])},markdownTokenizer:{name:e,level:"inline",start(x){const y=c?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),N=x.match(y),w=N==null?void 0:N.index;return w!==void 0?w:-1},tokenize(x,y,N){const w=c?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),j=x.match(w);if(!j)return;let S="",E="";if(c){const[,P]=j;E=P}else{const[,P,O]=j;E=P,S=O||""}const T=a(E.trim());return{type:e,raw:j[0],content:S.trim(),attributes:T}}},renderMarkdown:x=>{let y="";r?y=r(x):x.content&&x.content.length>0&&(y=x.content.filter(S=>S.type==="text").map(S=>S.text).join(""));const N=f(x.attrs||{}),w=i(N),j=w?` ${w}`:"";return c?`[${h}${j}]`:`[${h}${j}]${y}[/${h}]`}}}function zg(t,e,n){var r,a,i,o;const c=t.split(` +`),u=[];let h="",f=0;const m=e.baseIndentSize||2;for(;f0)break;if(x.trim()===""){f+=1,h=`${h}${x} +`;continue}else return}const N=e.extractItemData(y),{indentLevel:w,mainContent:j}=N;h=`${h}${x} `;const S=[j];for(f+=1;fte.trim()!=="");if(z===-1)break;if((((a=(r=c[f+1+z].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:a.length)||0)>w){S.push(O),h=`${h}${O} `,f+=1;continue}else break}if((((o=(i=O.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>w)S.push(O),h=`${h}${O} `,f+=1;else break}let E;const T=S.slice(1);if(T.length>0){const O=T.map(q=>q.slice(w+m)).join(` `);O.trim()&&(e.customNestedParser?E=e.customNestedParser(O):E=n.blockTokens(O))}const P=e.createToken(N,E);u.push(P)}if(u.length!==0)return{items:u,raw:h}}function ly(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const a=typeof n=="function"?n(r):n,[i,...o]=t.content,c=e.renderChildren([i]),u=[`${a}${c}`];return o&&o.length>0&&o.forEach(h=>{const f=e.renderChildren([h]);if(f){const m=f.split(` -`).map(g=>g?e.indent(g):"").join(` +`).map(x=>x?e.indent(x):"").join(` `);u.push(m)}}),u.join(` -`)}function S_(t,e,n={}){const{state:r}=e,{doc:a,tr:i}=r,o=t;a.descendants((c,u)=>{const h=i.mapping.map(u),f=i.mapping.map(u)+c.nodeSize;let m=null;if(c.marks.forEach(y=>{if(y!==o)return!1;m=y}),!m)return;let g=!1;if(Object.keys(n).forEach(y=>{n[y]!==m.attrs[y]&&(g=!0)}),g){const y=t.type.create({...t.attrs,...n});i.removeMark(h,f,t.type),i.addMark(h,f,y)}}),i.docChanged&&e.view.dispatch(i)}var Pn=class kC extends ay{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new kC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function xl(t){return new i_({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:a})=>{const i=Bt(t.getAttributes,void 0,r,a);if(i===!1||i===null)return null;const{tr:o}=e,c=r[r.length-1],u=r[0];let h=n.to;if(c){const f=u.search(/\S/),m=n.from+u.indexOf(c),g=m+c.length;if(ry(n.from,n.to,e.doc).filter(N=>N.mark.type.excluded.find(j=>j===t.type&&j!==N.mark.type)).filter(N=>N.to>m).length)return null;gn.from&&o.delete(n.from+f,m),h=n.from+f+c.length,o.addMark(n.from+f,h,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:C_,getOwnPropertySymbols:T_}=Object,{hasOwnProperty:E_}=Object.prototype;function _g(t,e){return function(r,a,i){return t(r,a,i)&&e(r,a,i)}}function Sh(t){return function(n,r,a){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,a);const{cache:i}=a,o=i.get(n),c=i.get(r);if(o&&c)return o===r&&c===n;i.set(n,r),i.set(r,n);const u=t(n,r,a);return i.delete(n),i.delete(r),u}}function M_(t){return t!=null?t[Symbol.toStringTag]:void 0}function JN(t){return C_(t).concat(T_(t))}const A_=Object.hasOwn||((t,e)=>E_.call(t,e));function Sl(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const I_="__v",R_="__o",P_="_owner",{getOwnPropertyDescriptor:QN,keys:YN}=Object;function O_(t,e){return t.byteLength===e.byteLength&&gf(new Uint8Array(t),new Uint8Array(e))}function L_(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function D_(t,e){return t.byteLength===e.byteLength&&gf(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function __(t,e){return Sl(t.getTime(),e.getTime())}function z_(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function $_(t,e){return t===e}function XN(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const a=new Array(r),i=t.entries();let o,c,u=0;for(;(o=i.next())&&!o.done;){const h=e.entries();let f=!1,m=0;for(;(c=h.next())&&!c.done;){if(a[m]){m++;continue}const g=o.value,y=c.value;if(n.equals(g[0],y[0],u,m,t,e,n)&&n.equals(g[1],y[1],g[0],y[0],t,e,n)){f=a[m]=!0;break}m++}if(!f)return!1;u++}return!0}const F_=Sl;function B_(t,e,n){const r=YN(t);let a=r.length;if(YN(e).length!==a)return!1;for(;a-- >0;)if(!SC(t,e,n,r[a]))return!1;return!0}function vd(t,e,n){const r=JN(t);let a=r.length;if(JN(e).length!==a)return!1;let i,o,c;for(;a-- >0;)if(i=r[a],!SC(t,e,n,i)||(o=QN(t,i),c=QN(e,i),(o||c)&&(!o||!c||o.configurable!==c.configurable||o.enumerable!==c.enumerable||o.writable!==c.writable)))return!1;return!0}function V_(t,e){return Sl(t.valueOf(),e.valueOf())}function H_(t,e){return t.source===e.source&&t.flags===e.flags}function ZN(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const a=new Array(r),i=t.values();let o,c;for(;(o=i.next())&&!o.done;){const u=e.values();let h=!1,f=0;for(;(c=u.next())&&!c.done;){if(!a[f]&&n.equals(o.value,c.value,o.value,c.value,t,e,n)){h=a[f]=!0;break}f++}if(!h)return!1}return!0}function gf(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function U_(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function SC(t,e,n,r){return(r===P_||r===R_||r===I_)&&(t.$$typeof||e.$$typeof)?!0:A_(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const W_="[object ArrayBuffer]",K_="[object Arguments]",q_="[object Boolean]",G_="[object DataView]",J_="[object Date]",Q_="[object Error]",Y_="[object Map]",X_="[object Number]",Z_="[object Object]",e7="[object RegExp]",t7="[object Set]",n7="[object String]",s7={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},r7="[object URL]",a7=Object.prototype.toString;function i7({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:a,areFunctionsEqual:i,areMapsEqual:o,areNumbersEqual:c,areObjectsEqual:u,arePrimitiveWrappersEqual:h,areRegExpsEqual:f,areSetsEqual:m,areTypedArraysEqual:g,areUrlsEqual:y,unknownTagComparators:N}){return function(j,S,E){if(j===S)return!0;if(j==null||S==null)return!1;const T=typeof j;if(T!==typeof S)return!1;if(T!=="object")return T==="number"?c(j,S,E):T==="function"?i(j,S,E):!1;const P=j.constructor;if(P!==S.constructor)return!1;if(P===Object)return u(j,S,E);if(Array.isArray(j))return e(j,S,E);if(P===Date)return r(j,S,E);if(P===RegExp)return f(j,S,E);if(P===Map)return o(j,S,E);if(P===Set)return m(j,S,E);const O=a7.call(j);if(O===J_)return r(j,S,E);if(O===e7)return f(j,S,E);if(O===Y_)return o(j,S,E);if(O===t7)return m(j,S,E);if(O===Z_)return typeof j.then!="function"&&typeof S.then!="function"&&u(j,S,E);if(O===r7)return y(j,S,E);if(O===Q_)return a(j,S,E);if(O===K_)return u(j,S,E);if(s7[O])return g(j,S,E);if(O===W_)return t(j,S,E);if(O===G_)return n(j,S,E);if(O===q_||O===X_||O===n7)return h(j,S,E);if(N){let q=N[O];if(!q){const z=M_(j);z&&(q=N[z])}if(q)return q(j,S,E)}return!1}}function o7({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:O_,areArraysEqual:n?vd:L_,areDataViewsEqual:D_,areDatesEqual:__,areErrorsEqual:z_,areFunctionsEqual:$_,areMapsEqual:n?_g(XN,vd):XN,areNumbersEqual:F_,areObjectsEqual:n?vd:B_,arePrimitiveWrappersEqual:V_,areRegExpsEqual:H_,areSetsEqual:n?_g(ZN,vd):ZN,areTypedArraysEqual:n?_g(gf,vd):gf,areUrlsEqual:U_,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const a=Sh(r.areArraysEqual),i=Sh(r.areMapsEqual),o=Sh(r.areObjectsEqual),c=Sh(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:a,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:c})}return r}function l7(t){return function(e,n,r,a,i,o,c){return t(e,n,c)}}function c7({circular:t,comparator:e,createState:n,equals:r,strict:a}){if(n)return function(c,u){const{cache:h=t?new WeakMap:void 0,meta:f}=n();return e(c,u,{cache:h,equals:r,meta:f,strict:a})};if(t)return function(c,u){return e(c,u,{cache:new WeakMap,equals:r,meta:void 0,strict:a})};const i={cache:void 0,equals:r,meta:void 0,strict:a};return function(c,u){return e(c,u,i)}}const d7=ko();ko({strict:!0});ko({circular:!0});ko({circular:!0,strict:!0});ko({createInternalComparator:()=>Sl});ko({strict:!0,createInternalComparator:()=>Sl});ko({circular:!0,createInternalComparator:()=>Sl});ko({circular:!0,createInternalComparator:()=>Sl,strict:!0});function ko(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:a=!1}=t,i=o7(t),o=i7(i),c=n?n(o):l7(o);return c7({circular:e,comparator:o,createState:r,equals:c,strict:a})}var zg={exports:{}},$g={};/** +`)}function S_(t,e,n={}){const{state:r}=e,{doc:a,tr:i}=r,o=t;a.descendants((c,u)=>{const h=i.mapping.map(u),f=i.mapping.map(u)+c.nodeSize;let m=null;if(c.marks.forEach(y=>{if(y!==o)return!1;m=y}),!m)return;let x=!1;if(Object.keys(n).forEach(y=>{n[y]!==m.attrs[y]&&(x=!0)}),x){const y=t.type.create({...t.attrs,...n});i.removeMark(h,f,t.type),i.addMark(h,f,y)}}),i.docChanged&&e.view.dispatch(i)}var Pn=class kC extends ay{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new kC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function gl(t){return new i_({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:a})=>{const i=Bt(t.getAttributes,void 0,r,a);if(i===!1||i===null)return null;const{tr:o}=e,c=r[r.length-1],u=r[0];let h=n.to;if(c){const f=u.search(/\S/),m=n.from+u.indexOf(c),x=m+c.length;if(ry(n.from,n.to,e.doc).filter(N=>N.mark.type.excluded.find(j=>j===t.type&&j!==N.mark.type)).filter(N=>N.to>m).length)return null;xn.from&&o.delete(n.from+f,m),h=n.from+f+c.length,o.addMark(n.from+f,h,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:C_,getOwnPropertySymbols:T_}=Object,{hasOwnProperty:E_}=Object.prototype;function _x(t,e){return function(r,a,i){return t(r,a,i)&&e(r,a,i)}}function Sh(t){return function(n,r,a){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,a);const{cache:i}=a,o=i.get(n),c=i.get(r);if(o&&c)return o===r&&c===n;i.set(n,r),i.set(r,n);const u=t(n,r,a);return i.delete(n),i.delete(r),u}}function M_(t){return t!=null?t[Symbol.toStringTag]:void 0}function JN(t){return C_(t).concat(T_(t))}const A_=Object.hasOwn||((t,e)=>E_.call(t,e));function Sl(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const I_="__v",R_="__o",P_="_owner",{getOwnPropertyDescriptor:QN,keys:YN}=Object;function O_(t,e){return t.byteLength===e.byteLength&&xf(new Uint8Array(t),new Uint8Array(e))}function L_(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function D_(t,e){return t.byteLength===e.byteLength&&xf(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function __(t,e){return Sl(t.getTime(),e.getTime())}function z_(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function $_(t,e){return t===e}function XN(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const a=new Array(r),i=t.entries();let o,c,u=0;for(;(o=i.next())&&!o.done;){const h=e.entries();let f=!1,m=0;for(;(c=h.next())&&!c.done;){if(a[m]){m++;continue}const x=o.value,y=c.value;if(n.equals(x[0],y[0],u,m,t,e,n)&&n.equals(x[1],y[1],x[0],y[0],t,e,n)){f=a[m]=!0;break}m++}if(!f)return!1;u++}return!0}const F_=Sl;function B_(t,e,n){const r=YN(t);let a=r.length;if(YN(e).length!==a)return!1;for(;a-- >0;)if(!SC(t,e,n,r[a]))return!1;return!0}function vd(t,e,n){const r=JN(t);let a=r.length;if(JN(e).length!==a)return!1;let i,o,c;for(;a-- >0;)if(i=r[a],!SC(t,e,n,i)||(o=QN(t,i),c=QN(e,i),(o||c)&&(!o||!c||o.configurable!==c.configurable||o.enumerable!==c.enumerable||o.writable!==c.writable)))return!1;return!0}function V_(t,e){return Sl(t.valueOf(),e.valueOf())}function H_(t,e){return t.source===e.source&&t.flags===e.flags}function ZN(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const a=new Array(r),i=t.values();let o,c;for(;(o=i.next())&&!o.done;){const u=e.values();let h=!1,f=0;for(;(c=u.next())&&!c.done;){if(!a[f]&&n.equals(o.value,c.value,o.value,c.value,t,e,n)){h=a[f]=!0;break}f++}if(!h)return!1}return!0}function xf(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function U_(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function SC(t,e,n,r){return(r===P_||r===R_||r===I_)&&(t.$$typeof||e.$$typeof)?!0:A_(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const W_="[object ArrayBuffer]",K_="[object Arguments]",q_="[object Boolean]",G_="[object DataView]",J_="[object Date]",Q_="[object Error]",Y_="[object Map]",X_="[object Number]",Z_="[object Object]",e7="[object RegExp]",t7="[object Set]",n7="[object String]",s7={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},r7="[object URL]",a7=Object.prototype.toString;function i7({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:a,areFunctionsEqual:i,areMapsEqual:o,areNumbersEqual:c,areObjectsEqual:u,arePrimitiveWrappersEqual:h,areRegExpsEqual:f,areSetsEqual:m,areTypedArraysEqual:x,areUrlsEqual:y,unknownTagComparators:N}){return function(j,S,E){if(j===S)return!0;if(j==null||S==null)return!1;const T=typeof j;if(T!==typeof S)return!1;if(T!=="object")return T==="number"?c(j,S,E):T==="function"?i(j,S,E):!1;const P=j.constructor;if(P!==S.constructor)return!1;if(P===Object)return u(j,S,E);if(Array.isArray(j))return e(j,S,E);if(P===Date)return r(j,S,E);if(P===RegExp)return f(j,S,E);if(P===Map)return o(j,S,E);if(P===Set)return m(j,S,E);const O=a7.call(j);if(O===J_)return r(j,S,E);if(O===e7)return f(j,S,E);if(O===Y_)return o(j,S,E);if(O===t7)return m(j,S,E);if(O===Z_)return typeof j.then!="function"&&typeof S.then!="function"&&u(j,S,E);if(O===r7)return y(j,S,E);if(O===Q_)return a(j,S,E);if(O===K_)return u(j,S,E);if(s7[O])return x(j,S,E);if(O===W_)return t(j,S,E);if(O===G_)return n(j,S,E);if(O===q_||O===X_||O===n7)return h(j,S,E);if(N){let q=N[O];if(!q){const z=M_(j);z&&(q=N[z])}if(q)return q(j,S,E)}return!1}}function o7({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:O_,areArraysEqual:n?vd:L_,areDataViewsEqual:D_,areDatesEqual:__,areErrorsEqual:z_,areFunctionsEqual:$_,areMapsEqual:n?_x(XN,vd):XN,areNumbersEqual:F_,areObjectsEqual:n?vd:B_,arePrimitiveWrappersEqual:V_,areRegExpsEqual:H_,areSetsEqual:n?_x(ZN,vd):ZN,areTypedArraysEqual:n?_x(xf,vd):xf,areUrlsEqual:U_,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const a=Sh(r.areArraysEqual),i=Sh(r.areMapsEqual),o=Sh(r.areObjectsEqual),c=Sh(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:a,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:c})}return r}function l7(t){return function(e,n,r,a,i,o,c){return t(e,n,c)}}function c7({circular:t,comparator:e,createState:n,equals:r,strict:a}){if(n)return function(c,u){const{cache:h=t?new WeakMap:void 0,meta:f}=n();return e(c,u,{cache:h,equals:r,meta:f,strict:a})};if(t)return function(c,u){return e(c,u,{cache:new WeakMap,equals:r,meta:void 0,strict:a})};const i={cache:void 0,equals:r,meta:void 0,strict:a};return function(c,u){return e(c,u,i)}}const d7=ko();ko({strict:!0});ko({circular:!0});ko({circular:!0,strict:!0});ko({createInternalComparator:()=>Sl});ko({strict:!0,createInternalComparator:()=>Sl});ko({circular:!0,createInternalComparator:()=>Sl});ko({circular:!0,createInternalComparator:()=>Sl,strict:!0});function ko(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:a=!1}=t,i=o7(t),o=i7(i),c=n?n(o):l7(o);return c7({circular:e,comparator:o,createState:r,equals:c,strict:a})}var zx={exports:{}},$x={};/** * @license React * use-sync-external-store-shim/with-selector.production.js * @@ -778,48 +778,48 @@ ${j} * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var ew;function u7(){if(ew)return $g;ew=1;var t=ru(),e=p2();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 $g.useSyncExternalStoreWithSelector=function(h,f,m,g,y){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 S(q){if(!E){if(E=!0,T=q,q=g(q),y!==void 0&&w.hasValue){var z=w.value;if(y(z,q))return P=z}return P=q}if(z=P,r(T,q))return z;var V=g(q);return y!==void 0&&y(z,V)?(T=q,z):(T=q,P=V)}var E=!1,T,P,O=m===void 0?null:m;return[function(){return S(f())},O===null?void 0:function(){return S(O())}]},[f,m,g,y]);var j=a(h,N[0],N[1]);return o(function(){w.hasValue=!0,w.value=j},[j]),u(j),j},$g}var tw;function h7(){return tw||(tw=1,zg.exports=u7()),zg.exports}var f7=h7(),p7=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},m7=({contentComponent:t})=>{const e=m2.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function g7(){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]:uj.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 x7=class extends As.Component{constructor(t){var e;super(t),this.editorContentRef=As.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=g7(),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:p7(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&s.jsx(m7,{contentComponent:t.contentComponent})]})}},y7=b.forwardRef((t,e)=>{const n=As.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return As.createElement(x7,{key:n,innerRef:e,...t})}),CC=As.memo(y7),b7=typeof window<"u"?b.useLayoutEffect:b.useEffect,v7=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 N7(t){var e;const[n]=b.useState(()=>new v7(t.editor)),r=f7.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:d7);return b7(()=>n.watch(t.editor),[t.editor,n]),b.useDebugValue(r),r}var w7=!1,$x=typeof window>"u",j7=$x||!!(typeof window<"u"&&window.next),k7=class TC{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?$x||j7?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 m_(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?TC.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 S7(t={},e=[]){const n=b.useRef(t);n.current=t;const[r]=b.useState(()=>new k7(n)),a=m2.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return b.useDebugValue(a),b.useEffect(r.onRender(e)),N7({editor:a,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),a}var EC=b.createContext({editor:null});EC.Consumer;var C7=b.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),T7=()=>b.useContext(C7);As.forwardRef((t,e)=>{const{onDragStart:n}=T7(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});As.createContext({markViewContentRef:()=>{}});var cy=b.createContext({get editor(){throw new Error("useTiptap must be used within a provider")}});cy.displayName="TiptapContext";var E7=()=>b.useContext(cy);function MC({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const a=b.useMemo(()=>({editor:r}),[r]),i=b.useMemo(()=>({editor:r}),[r]);return s.jsx(EC.Provider,{value:i,children:s.jsx(cy.Provider,{value:a,children:n})})}MC.displayName="Tiptap";function AC({...t}){const{editor:e}=E7();return s.jsx(CC,{editor:e,...t})}AC.displayName="Tiptap.Content";Object.assign(MC,{Content:AC});var xf=(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]},M7=/^\s*>\s$/,A7=Pn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return xf("blockquote",{...Vt(this.options.HTMLAttributes,t),children:xf("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(a=>{const c=e.renderChildren([a]).split(` + */var ew;function u7(){if(ew)return $x;ew=1;var t=ru(),e=p2();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 $x.useSyncExternalStoreWithSelector=function(h,f,m,x,y){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 S(q){if(!E){if(E=!0,T=q,q=x(q),y!==void 0&&w.hasValue){var z=w.value;if(y(z,q))return P=z}return P=q}if(z=P,r(T,q))return z;var V=x(q);return y!==void 0&&y(z,V)?(T=q,z):(T=q,P=V)}var E=!1,T,P,O=m===void 0?null:m;return[function(){return S(f())},O===null?void 0:function(){return S(O())}]},[f,m,x,y]);var j=a(h,N[0],N[1]);return o(function(){w.hasValue=!0,w.value=j},[j]),u(j),j},$x}var tw;function h7(){return tw||(tw=1,zx.exports=u7()),zx.exports}var f7=h7(),p7=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},m7=({contentComponent:t})=>{const e=m2.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function x7(){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]:uj.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 g7=class extends As.Component{constructor(t){var e;super(t),this.editorContentRef=As.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=x7(),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:p7(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&s.jsx(m7,{contentComponent:t.contentComponent})]})}},y7=b.forwardRef((t,e)=>{const n=As.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return As.createElement(g7,{key:n,innerRef:e,...t})}),CC=As.memo(y7),b7=typeof window<"u"?b.useLayoutEffect:b.useEffect,v7=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 N7(t){var e;const[n]=b.useState(()=>new v7(t.editor)),r=f7.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:d7);return b7(()=>n.watch(t.editor),[t.editor,n]),b.useDebugValue(r),r}var w7=!1,$g=typeof window>"u",j7=$g||!!(typeof window<"u"&&window.next),k7=class TC{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?$g||j7?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 m_(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?TC.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 S7(t={},e=[]){const n=b.useRef(t);n.current=t;const[r]=b.useState(()=>new k7(n)),a=m2.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return b.useDebugValue(a),b.useEffect(r.onRender(e)),N7({editor:a,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),a}var EC=b.createContext({editor:null});EC.Consumer;var C7=b.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),T7=()=>b.useContext(C7);As.forwardRef((t,e)=>{const{onDragStart:n}=T7(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});As.createContext({markViewContentRef:()=>{}});var cy=b.createContext({get editor(){throw new Error("useTiptap must be used within a provider")}});cy.displayName="TiptapContext";var E7=()=>b.useContext(cy);function MC({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const a=b.useMemo(()=>({editor:r}),[r]),i=b.useMemo(()=>({editor:r}),[r]);return s.jsx(EC.Provider,{value:i,children:s.jsx(cy.Provider,{value:a,children:n})})}MC.displayName="Tiptap";function AC({...t}){const{editor:e}=E7();return s.jsx(CC,{editor:e,...t})}AC.displayName="Tiptap.Content";Object.assign(MC,{Content:AC});var gf=(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]},M7=/^\s*>\s$/,A7=Pn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return gf("blockquote",{...Vt(this.options.HTMLAttributes,t),children:gf("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(a=>{const c=e.renderChildren([a]).split(` `).map(u=>u.trim()===""?n:`${n} ${u}`);r.push(c.join(` `))}),r.join(` ${n} -`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Ac({find:M7,type:this.type})]}}),I7=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,R7=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,P7=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,O7=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,L7=kl.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return xf("strong",{...Vt(this.options.HTMLAttributes,t),children:xf("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Mc({find:I7,type:this.type}),Mc({find:P7,type:this.type})]},addPasteRules(){return[xl({find:R7,type:this.type}),xl({find:O7,type:this.type})]}}),D7=/(^|[^`])`([^`]+)`(?!`)$/,_7=/(^|[^`])`([^`]+)`(?!`)/g,z7=kl.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Vt(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Mc({find:D7,type:this.type})]},addPasteRules(){return[xl({find:_7,type:this.type})]}}),Fg=4,$7=/^```([a-z]+)?[\s\n]$/,F7=/^~~~([a-z]+)?[\s\n]$/,B7=Pn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Fg,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Vt(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&((r=t.raw)==null?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const a=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${a}`,e.renderChildren(t.content),"```"].join(` +`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Ac({find:M7,type:this.type})]}}),I7=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,R7=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,P7=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,O7=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,L7=kl.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return gf("strong",{...Vt(this.options.HTMLAttributes,t),children:gf("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Mc({find:I7,type:this.type}),Mc({find:P7,type:this.type})]},addPasteRules(){return[gl({find:R7,type:this.type}),gl({find:O7,type:this.type})]}}),D7=/(^|[^`])`([^`]+)`(?!`)$/,_7=/(^|[^`])`([^`]+)`(?!`)/g,z7=kl.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Vt(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Mc({find:D7,type:this.type})]},addPasteRules(){return[gl({find:_7,type:this.type})]}}),Fx=4,$7=/^```([a-z]+)?[\s\n]$/,F7=/^~~~([a-z]+)?[\s\n]$/,B7=Pn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Fx,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Vt(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&((r=t.raw)==null?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const a=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${a}`,e.renderChildren(t.content),"```"].join(` `):r=`\`\`\`${a} -\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Fg,{state:r}=t,{selection:a}=r,{$from:i,empty:o}=a;if(i.parent.type!==this.type)return!1;const c=" ".repeat(n);return o?t.commands.insertContent(c):t.commands.command(({tr:u})=>{const{from:h,to:f}=a,y=r.doc.textBetween(h,f,` +\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Fx,{state:r}=t,{selection:a}=r,{$from:i,empty:o}=a;if(i.parent.type!==this.type)return!1;const c=" ".repeat(n);return o?t.commands.insertContent(c):t.commands.command(({tr:u})=>{const{from:h,to:f}=a,y=r.doc.textBetween(h,f,` `,` `).split(` `).map(N=>c+N).join(` -`);return u.replaceWith(h,f,r.schema.text(y)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Fg,{state:r}=t,{selection:a}=r,{$from:i,empty:o}=a;return i.parent.type!==this.type?!1:o?t.commands.command(({tr:c})=>{var u;const{pos:h}=i,f=i.start(),m=i.end(),y=r.doc.textBetween(f,m,` +`);return u.replaceWith(h,f,r.schema.text(y)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Fx,{state:r}=t,{selection:a}=r,{$from:i,empty:o}=a;return i.parent.type!==this.type?!1:o?t.commands.command(({tr:c})=>{var u;const{pos:h}=i,f=i.start(),m=i.end(),y=r.doc.textBetween(f,m,` `,` `).split(` -`);let N=0,w=0;const j=h-f;for(let q=0;q=j){N=q;break}w+=y[q].length+1}const E=((u=y[N].match(/^ */))==null?void 0:u[0])||"",T=Math.min(E.length,n);if(T===0)return!0;let P=f;for(let q=0;q{const{from:u,to:h}=a,g=r.doc.textBetween(u,h,` +`);let N=0,w=0;const j=h-f;for(let q=0;q=j){N=q;break}w+=y[q].length+1}const E=((u=y[N].match(/^ */))==null?void 0:u[0])||"",T=Math.min(E.length,n);if(T===0)return!0;let P=f;for(let q=0;q{const{from:u,to:h}=a,x=r.doc.textBetween(u,h,` `,` `).split(` `).map(y=>{var N;const w=((N=y.match(/^ */))==null?void 0:N[0])||"",j=Math.min(w.length,n);return y.slice(j)}).join(` -`);return c.replaceWith(u,h,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:a}=n;if(!a||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` +`);return c.replaceWith(u,h,r.schema.text(x)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:a}=n;if(!a||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` -`);return!i||!o?!1:t.chain().command(({tr:c})=>(c.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:a,empty:i}=n;if(!i||a.parent.type!==this.type||!(a.parentOffset===a.parent.nodeSize-2))return!1;const c=a.after();return c===void 0?!1:r.nodeAt(c)?t.commands.command(({tr:h})=>(h.setSelection(ot.near(r.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[_x({find:$7,type:this.type,getAttributes:t=>({language:t[1]})}),_x({find:F7,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new rn({key:new pn("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),a=r?JSON.parse(r):void 0,i=a==null?void 0:a.mode;if(!n||!i)return!1;const{tr:o,schema:c}=t.state,u=c.text(n.replace(/\r\n?/g,` +`);return!i||!o?!1:t.chain().command(({tr:c})=>(c.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:a,empty:i}=n;if(!i||a.parent.type!==this.type||!(a.parentOffset===a.parent.nodeSize-2))return!1;const c=a.after();return c===void 0?!1:r.nodeAt(c)?t.commands.command(({tr:h})=>(h.setSelection(ot.near(r.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[_g({find:$7,type:this.type,getAttributes:t=>({language:t[1]})}),_g({find:F7,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new rn({key:new pn("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),a=r?JSON.parse(r):void 0,i=a==null?void 0:a.mode;if(!n||!i)return!1;const{tr:o,schema:c}=t.state,u=c.text(n.replace(/\r\n?/g,` `));return o.replaceSelectionWith(this.type.create({language:i},u)),o.selection.$from.parent.type!==this.type&&o.setSelection(et.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),V7=Pn.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` `):""}),H7=Pn.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",Vt(this.options.HTMLAttributes,t)]},renderText(){return` `},renderMarkdown:()=>` -`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:a,storedMarks:i}=n;if(a.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:c}=r.extensionManager,u=i||a.$to.parentOffset&&a.$from.marks();return e().insertContent({type:this.name}).command(({tr:h,dispatch:f})=>{if(f&&u&&o){const m=u.filter(g=>c.includes(g.type.name));h.ensureMarks(m)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),U7=Pn.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]}`,Vt(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=>_x({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),W7=Pn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Vt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!y_(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,a=t();return aC(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(et.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(Ze.create(o.doc,u.pos)):o.setSelection(et.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(et.create(o.doc,h+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[wC({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),K7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,q7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,G7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,J7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Q7=kl.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",Vt(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[Mc({find:K7,type:this.type}),Mc({find:G7,type:this.type})]},addPasteRules(){return[xl({find:q7,type:this.type}),xl({find:J7,type:this.type})]}});const Y7="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",X7="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Fx="numeric",Bx="ascii",Vx="alpha",Dd="asciinumeric",Cd="alphanumeric",Hx="domain",IC="emoji",Z7="scheme",ez="slashscheme",Bg="whitespace";function tz(t,e){return t in e||(e[t]=[]),e[t]}function nl(t,e,n){e[Fx]&&(e[Dd]=!0,e[Cd]=!0),e[Bx]&&(e[Dd]=!0,e[Vx]=!0),e[Dd]&&(e[Cd]=!0),e[Vx]&&(e[Cd]=!0),e[Cd]&&(e[Hx]=!0),e[IC]&&(e[Hx]=!0);for(const r in e){const a=tz(r,n);a.indexOf(t)<0&&a.push(t)}}function nz(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ws(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ws.groups={};Ws.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),wn=(t,e,n,r,a)=>t.tr(e,n,r,a),nw=(t,e,n,r,a)=>t.ts(e,n,r,a),Ie=(t,e,n,r,a)=>t.tt(e,n,r,a),si="WORD",Ux="UWORD",RC="ASCIINUMERICAL",PC="ALPHANUMERICAL",eu="LOCALHOST",Wx="TLD",Kx="UTLD",Fh="SCHEME",oc="SLASH_SCHEME",dy="NUM",qx="WS",uy="NL",_d="OPENBRACE",zd="CLOSEBRACE",yf="OPENBRACKET",bf="CLOSEBRACKET",vf="OPENPAREN",Nf="CLOSEPAREN",wf="OPENANGLEBRACKET",jf="CLOSEANGLEBRACKET",kf="FULLWIDTHLEFTPAREN",Sf="FULLWIDTHRIGHTPAREN",Cf="LEFTCORNERBRACKET",Tf="RIGHTCORNERBRACKET",Ef="LEFTWHITECORNERBRACKET",Mf="RIGHTWHITECORNERBRACKET",Af="FULLWIDTHLESSTHAN",If="FULLWIDTHGREATERTHAN",Rf="AMPERSAND",Pf="APOSTROPHE",Of="ASTERISK",Qi="AT",Lf="BACKSLASH",Df="BACKTICK",_f="CARET",Zi="COLON",hy="COMMA",zf="DOLLAR",ma="DOT",$f="EQUALS",fy="EXCLAMATION",jr="HYPHEN",$d="PERCENT",Ff="PIPE",Bf="PLUS",Vf="POUND",Fd="QUERY",py="QUOTE",OC="FULLWIDTHMIDDLEDOT",my="SEMI",ga="SLASH",Bd="TILDE",Hf="UNDERSCORE",LC="EMOJI",Uf="SYM";var DC=Object.freeze({__proto__:null,ALPHANUMERICAL:PC,AMPERSAND:Rf,APOSTROPHE:Pf,ASCIINUMERICAL:RC,ASTERISK:Of,AT:Qi,BACKSLASH:Lf,BACKTICK:Df,CARET:_f,CLOSEANGLEBRACKET:jf,CLOSEBRACE:zd,CLOSEBRACKET:bf,CLOSEPAREN:Nf,COLON:Zi,COMMA:hy,DOLLAR:zf,DOT:ma,EMOJI:LC,EQUALS:$f,EXCLAMATION:fy,FULLWIDTHGREATERTHAN:If,FULLWIDTHLEFTPAREN:kf,FULLWIDTHLESSTHAN:Af,FULLWIDTHMIDDLEDOT:OC,FULLWIDTHRIGHTPAREN:Sf,HYPHEN:jr,LEFTCORNERBRACKET:Cf,LEFTWHITECORNERBRACKET:Ef,LOCALHOST:eu,NL:uy,NUM:dy,OPENANGLEBRACKET:wf,OPENBRACE:_d,OPENBRACKET:yf,OPENPAREN:vf,PERCENT:$d,PIPE:Ff,PLUS:Bf,POUND:Vf,QUERY:Fd,QUOTE:py,RIGHTCORNERBRACKET:Tf,RIGHTWHITECORNERBRACKET:Mf,SCHEME:Fh,SEMI:my,SLASH:ga,SLASH_SCHEME:oc,SYM:Uf,TILDE:Bd,TLD:Wx,UNDERSCORE:Hf,UTLD:Kx,UWORD:Ux,WORD:si,WS:qx});const ti=/[a-z]/,Nd=new RegExp("\\p{L}","u"),Vg=new RegExp("\\p{Emoji}","u"),ni=/\d/,Hg=/\s/,sw="\r",Ug=` -`,sz="️",rz="‍",Wg="";let Ch=null,Th=null;function az(t=[]){const e={};Ws.groups=e;const n=new Ws;Ch==null&&(Ch=rw(Y7)),Th==null&&(Th=rw(X7)),Ie(n,"'",Pf),Ie(n,"{",_d),Ie(n,"}",zd),Ie(n,"[",yf),Ie(n,"]",bf),Ie(n,"(",vf),Ie(n,")",Nf),Ie(n,"<",wf),Ie(n,">",jf),Ie(n,"(",kf),Ie(n,")",Sf),Ie(n,"「",Cf),Ie(n,"」",Tf),Ie(n,"『",Ef),Ie(n,"』",Mf),Ie(n,"<",Af),Ie(n,">",If),Ie(n,"&",Rf),Ie(n,"*",Of),Ie(n,"@",Qi),Ie(n,"`",Df),Ie(n,"^",_f),Ie(n,":",Zi),Ie(n,",",hy),Ie(n,"$",zf),Ie(n,".",ma),Ie(n,"=",$f),Ie(n,"!",fy),Ie(n,"-",jr),Ie(n,"%",$d),Ie(n,"|",Ff),Ie(n,"+",Bf),Ie(n,"#",Vf),Ie(n,"?",Fd),Ie(n,'"',py),Ie(n,"/",ga),Ie(n,";",my),Ie(n,"~",Bd),Ie(n,"_",Hf),Ie(n,"\\",Lf),Ie(n,"・",OC);const r=wn(n,ni,dy,{[Fx]:!0});wn(r,ni,r);const a=wn(r,ti,RC,{[Dd]:!0}),i=wn(r,Nd,PC,{[Cd]:!0}),o=wn(n,ti,si,{[Bx]:!0});wn(o,ni,a),wn(o,ti,o),wn(a,ni,a),wn(a,ti,a);const c=wn(n,Nd,Ux,{[Vx]:!0});wn(c,ti),wn(c,ni,i),wn(c,Nd,c),wn(i,ni,i),wn(i,ti),wn(i,Nd,i);const u=Ie(n,Ug,uy,{[Bg]:!0}),h=Ie(n,sw,qx,{[Bg]:!0}),f=wn(n,Hg,qx,{[Bg]:!0});Ie(n,Wg,f),Ie(h,Ug,u),Ie(h,Wg,f),wn(h,Hg,f),Ie(f,sw),Ie(f,Ug),wn(f,Hg,f),Ie(f,Wg,f);const m=wn(n,Vg,LC,{[IC]:!0});Ie(m,"#"),wn(m,Vg,m),Ie(m,sz,m);const g=Ie(m,rz);Ie(g,"#"),wn(g,Vg,m);const y=[[ti,o],[ni,a]],N=[[ti,null],[Nd,c],[ni,i]];for(let w=0;ww[0]>j[0]?1:-1);for(let w=0;w=0?E[Hx]=!0:ti.test(j)?ni.test(j)?E[Dd]=!0:E[Bx]=!0:E[Fx]=!0,nw(n,j,j,E)}return nw(n,"localhost",eu,{ascii:!0}),n.jd=new Ws(Uf),{start:n,tokens:Object.assign({groups:e},DC)}}function _C(t,e){const n=iz(e.replace(/[A-Z]/g,c=>c.toLowerCase())),r=n.length,a=[];let i=0,o=0;for(;o=0&&(m+=n[o].length,g++),h+=n[o].length,i+=n[o].length,o++;i-=m,o-=g,h-=m,a.push({t:f.t,v:e.slice(i-h,i),s:i-h,e:i})}return a}function iz(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 Wi(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 tu={defaultProtocol:"http",events:null,format:aw,formatHref:aw,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function gy(t,e=null){let n=Object.assign({},tu);t&&(n=Object.assign(n,t instanceof gy?t.o:t));const r=n.ignoreTags,a=[];for(let i=0;in?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=tu.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 Np(t,e){class n extends zC{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 iw=Np("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),ow=Np("text"),oz=Np("nl"),Eh=Np("url",{isLink:!0,toHref(t=tu.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==eu&&t[1].t===Zi}}),wr=t=>new Ws(t);function lz({groups:t}){const e=t.domain.concat([Rf,Of,Qi,Lf,Df,_f,zf,$f,jr,dy,$d,Ff,Bf,Vf,ga,Uf,Bd,Hf]),n=[Pf,Zi,hy,ma,fy,$d,Fd,py,my,wf,jf,_d,zd,bf,yf,vf,Nf,kf,Sf,Cf,Tf,Ef,Mf,Af,If],r=[Rf,Pf,Of,Lf,Df,_f,zf,$f,jr,_d,zd,$d,Ff,Bf,Vf,Fd,ga,Uf,Bd,Hf],a=wr(),i=Ie(a,Bd);gt(i,r,i),gt(i,t.domain,i);const o=wr(),c=wr(),u=wr();gt(a,t.domain,o),gt(a,t.scheme,c),gt(a,t.slashscheme,u),gt(o,r,i),gt(o,t.domain,o);const h=Ie(o,Qi);Ie(i,Qi,h),Ie(c,Qi,h),Ie(u,Qi,h);const f=Ie(i,ma);gt(f,r,i),gt(f,t.domain,i);const m=wr();gt(h,t.domain,m),gt(m,t.domain,m);const g=Ie(m,ma);gt(g,t.domain,m);const y=wr(iw);gt(g,t.tld,y),gt(g,t.utld,y),Ie(h,eu,y);const N=Ie(m,jr);Ie(N,jr,N),gt(N,t.domain,m),gt(y,t.domain,m),Ie(y,ma,g),Ie(y,jr,N);const w=Ie(y,Zi);gt(w,t.numeric,iw);const j=Ie(o,jr),S=Ie(o,ma);Ie(j,jr,j),gt(j,t.domain,o),gt(S,r,i),gt(S,t.domain,o);const E=wr(Eh);gt(S,t.tld,E),gt(S,t.utld,E),gt(E,t.domain,o),gt(E,r,i),Ie(E,ma,S),Ie(E,jr,j),Ie(E,Qi,h);const T=Ie(E,Zi),P=wr(Eh);gt(T,t.numeric,P);const O=wr(Eh),q=wr();gt(O,e,O),gt(O,n,q),gt(q,e,O),gt(q,n,q),Ie(E,ga,O),Ie(P,ga,O);const z=Ie(c,Zi),V=Ie(u,Zi),I=Ie(V,ga),te=Ie(I,ga);gt(c,t.domain,o),Ie(c,ma,S),Ie(c,jr,j),gt(u,t.domain,o),Ie(u,ma,S),Ie(u,jr,j),gt(z,t.domain,O),Ie(z,ga,O),Ie(z,Fd,O),gt(te,t.domain,O),gt(te,e,O),Ie(te,ga,O);const Q=[[_d,zd],[yf,bf],[vf,Nf],[wf,jf],[kf,Sf],[Cf,Tf],[Ef,Mf],[Af,If]];for(let F=0;F=0&&g++,a++,f++;if(g<0)a-=f,a0&&(i.push(Kg(ow,e,o)),o=[]),a-=g,f-=g;const y=m.t,N=n.slice(a-f,a);i.push(Kg(y,e,N))}}return o.length>0&&i.push(Kg(ow,e,o)),i}function Kg(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 dz=typeof console<"u"&&console&&console.warn||(()=>{}),uz="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ln={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function hz(){return Ws.groups={},ln.scanner=null,ln.parser=null,ln.tokenQueue=[],ln.pluginQueue=[],ln.customSchemes=[],ln.initialized=!1,ln}function lw(t,e=!1){if(ln.initialized&&dz(`linkifyjs: already initialized - will not register custom scheme "${t}" ${uz}`),!/^[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()}}}),U7=Pn.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]}`,Vt(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=>_g({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),W7=Pn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Vt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!y_(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,a=t();return aC(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(et.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(Ze.create(o.doc,u.pos)):o.setSelection(et.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(et.create(o.doc,h+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[wC({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),K7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,q7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,G7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,J7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Q7=kl.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",Vt(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[Mc({find:K7,type:this.type}),Mc({find:G7,type:this.type})]},addPasteRules(){return[gl({find:q7,type:this.type}),gl({find:J7,type:this.type})]}});const Y7="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",X7="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Fg="numeric",Bg="ascii",Vg="alpha",Dd="asciinumeric",Cd="alphanumeric",Hg="domain",IC="emoji",Z7="scheme",ez="slashscheme",Bx="whitespace";function tz(t,e){return t in e||(e[t]=[]),e[t]}function nl(t,e,n){e[Fg]&&(e[Dd]=!0,e[Cd]=!0),e[Bg]&&(e[Dd]=!0,e[Vg]=!0),e[Dd]&&(e[Cd]=!0),e[Vg]&&(e[Cd]=!0),e[Cd]&&(e[Hg]=!0),e[IC]&&(e[Hg]=!0);for(const r in e){const a=tz(r,n);a.indexOf(t)<0&&a.push(t)}}function nz(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ks(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ks.groups={};Ks.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),wn=(t,e,n,r,a)=>t.tr(e,n,r,a),nw=(t,e,n,r,a)=>t.ts(e,n,r,a),Ie=(t,e,n,r,a)=>t.tt(e,n,r,a),si="WORD",Ug="UWORD",RC="ASCIINUMERICAL",PC="ALPHANUMERICAL",eu="LOCALHOST",Wg="TLD",Kg="UTLD",Fh="SCHEME",oc="SLASH_SCHEME",dy="NUM",qg="WS",uy="NL",_d="OPENBRACE",zd="CLOSEBRACE",yf="OPENBRACKET",bf="CLOSEBRACKET",vf="OPENPAREN",Nf="CLOSEPAREN",wf="OPENANGLEBRACKET",jf="CLOSEANGLEBRACKET",kf="FULLWIDTHLEFTPAREN",Sf="FULLWIDTHRIGHTPAREN",Cf="LEFTCORNERBRACKET",Tf="RIGHTCORNERBRACKET",Ef="LEFTWHITECORNERBRACKET",Mf="RIGHTWHITECORNERBRACKET",Af="FULLWIDTHLESSTHAN",If="FULLWIDTHGREATERTHAN",Rf="AMPERSAND",Pf="APOSTROPHE",Of="ASTERISK",Qi="AT",Lf="BACKSLASH",Df="BACKTICK",_f="CARET",Zi="COLON",hy="COMMA",zf="DOLLAR",ma="DOT",$f="EQUALS",fy="EXCLAMATION",jr="HYPHEN",$d="PERCENT",Ff="PIPE",Bf="PLUS",Vf="POUND",Fd="QUERY",py="QUOTE",OC="FULLWIDTHMIDDLEDOT",my="SEMI",xa="SLASH",Bd="TILDE",Hf="UNDERSCORE",LC="EMOJI",Uf="SYM";var DC=Object.freeze({__proto__:null,ALPHANUMERICAL:PC,AMPERSAND:Rf,APOSTROPHE:Pf,ASCIINUMERICAL:RC,ASTERISK:Of,AT:Qi,BACKSLASH:Lf,BACKTICK:Df,CARET:_f,CLOSEANGLEBRACKET:jf,CLOSEBRACE:zd,CLOSEBRACKET:bf,CLOSEPAREN:Nf,COLON:Zi,COMMA:hy,DOLLAR:zf,DOT:ma,EMOJI:LC,EQUALS:$f,EXCLAMATION:fy,FULLWIDTHGREATERTHAN:If,FULLWIDTHLEFTPAREN:kf,FULLWIDTHLESSTHAN:Af,FULLWIDTHMIDDLEDOT:OC,FULLWIDTHRIGHTPAREN:Sf,HYPHEN:jr,LEFTCORNERBRACKET:Cf,LEFTWHITECORNERBRACKET:Ef,LOCALHOST:eu,NL:uy,NUM:dy,OPENANGLEBRACKET:wf,OPENBRACE:_d,OPENBRACKET:yf,OPENPAREN:vf,PERCENT:$d,PIPE:Ff,PLUS:Bf,POUND:Vf,QUERY:Fd,QUOTE:py,RIGHTCORNERBRACKET:Tf,RIGHTWHITECORNERBRACKET:Mf,SCHEME:Fh,SEMI:my,SLASH:xa,SLASH_SCHEME:oc,SYM:Uf,TILDE:Bd,TLD:Wg,UNDERSCORE:Hf,UTLD:Kg,UWORD:Ug,WORD:si,WS:qg});const ti=/[a-z]/,Nd=new RegExp("\\p{L}","u"),Vx=new RegExp("\\p{Emoji}","u"),ni=/\d/,Hx=/\s/,sw="\r",Ux=` +`,sz="️",rz="‍",Wx="";let Ch=null,Th=null;function az(t=[]){const e={};Ks.groups=e;const n=new Ks;Ch==null&&(Ch=rw(Y7)),Th==null&&(Th=rw(X7)),Ie(n,"'",Pf),Ie(n,"{",_d),Ie(n,"}",zd),Ie(n,"[",yf),Ie(n,"]",bf),Ie(n,"(",vf),Ie(n,")",Nf),Ie(n,"<",wf),Ie(n,">",jf),Ie(n,"(",kf),Ie(n,")",Sf),Ie(n,"「",Cf),Ie(n,"」",Tf),Ie(n,"『",Ef),Ie(n,"』",Mf),Ie(n,"<",Af),Ie(n,">",If),Ie(n,"&",Rf),Ie(n,"*",Of),Ie(n,"@",Qi),Ie(n,"`",Df),Ie(n,"^",_f),Ie(n,":",Zi),Ie(n,",",hy),Ie(n,"$",zf),Ie(n,".",ma),Ie(n,"=",$f),Ie(n,"!",fy),Ie(n,"-",jr),Ie(n,"%",$d),Ie(n,"|",Ff),Ie(n,"+",Bf),Ie(n,"#",Vf),Ie(n,"?",Fd),Ie(n,'"',py),Ie(n,"/",xa),Ie(n,";",my),Ie(n,"~",Bd),Ie(n,"_",Hf),Ie(n,"\\",Lf),Ie(n,"・",OC);const r=wn(n,ni,dy,{[Fg]:!0});wn(r,ni,r);const a=wn(r,ti,RC,{[Dd]:!0}),i=wn(r,Nd,PC,{[Cd]:!0}),o=wn(n,ti,si,{[Bg]:!0});wn(o,ni,a),wn(o,ti,o),wn(a,ni,a),wn(a,ti,a);const c=wn(n,Nd,Ug,{[Vg]:!0});wn(c,ti),wn(c,ni,i),wn(c,Nd,c),wn(i,ni,i),wn(i,ti),wn(i,Nd,i);const u=Ie(n,Ux,uy,{[Bx]:!0}),h=Ie(n,sw,qg,{[Bx]:!0}),f=wn(n,Hx,qg,{[Bx]:!0});Ie(n,Wx,f),Ie(h,Ux,u),Ie(h,Wx,f),wn(h,Hx,f),Ie(f,sw),Ie(f,Ux),wn(f,Hx,f),Ie(f,Wx,f);const m=wn(n,Vx,LC,{[IC]:!0});Ie(m,"#"),wn(m,Vx,m),Ie(m,sz,m);const x=Ie(m,rz);Ie(x,"#"),wn(x,Vx,m);const y=[[ti,o],[ni,a]],N=[[ti,null],[Nd,c],[ni,i]];for(let w=0;ww[0]>j[0]?1:-1);for(let w=0;w=0?E[Hg]=!0:ti.test(j)?ni.test(j)?E[Dd]=!0:E[Bg]=!0:E[Fg]=!0,nw(n,j,j,E)}return nw(n,"localhost",eu,{ascii:!0}),n.jd=new Ks(Uf),{start:n,tokens:Object.assign({groups:e},DC)}}function _C(t,e){const n=iz(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 iz(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 Wi(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 tu={defaultProtocol:"http",events:null,format:aw,formatHref:aw,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function xy(t,e=null){let n=Object.assign({},tu);t&&(n=Object.assign(n,t instanceof xy?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=tu.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 Np(t,e){class n extends zC{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 iw=Np("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),ow=Np("text"),oz=Np("nl"),Eh=Np("url",{isLink:!0,toHref(t=tu.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==eu&&t[1].t===Zi}}),wr=t=>new Ks(t);function lz({groups:t}){const e=t.domain.concat([Rf,Of,Qi,Lf,Df,_f,zf,$f,jr,dy,$d,Ff,Bf,Vf,xa,Uf,Bd,Hf]),n=[Pf,Zi,hy,ma,fy,$d,Fd,py,my,wf,jf,_d,zd,bf,yf,vf,Nf,kf,Sf,Cf,Tf,Ef,Mf,Af,If],r=[Rf,Pf,Of,Lf,Df,_f,zf,$f,jr,_d,zd,$d,Ff,Bf,Vf,Fd,xa,Uf,Bd,Hf],a=wr(),i=Ie(a,Bd);xt(i,r,i),xt(i,t.domain,i);const o=wr(),c=wr(),u=wr();xt(a,t.domain,o),xt(a,t.scheme,c),xt(a,t.slashscheme,u),xt(o,r,i),xt(o,t.domain,o);const h=Ie(o,Qi);Ie(i,Qi,h),Ie(c,Qi,h),Ie(u,Qi,h);const f=Ie(i,ma);xt(f,r,i),xt(f,t.domain,i);const m=wr();xt(h,t.domain,m),xt(m,t.domain,m);const x=Ie(m,ma);xt(x,t.domain,m);const y=wr(iw);xt(x,t.tld,y),xt(x,t.utld,y),Ie(h,eu,y);const N=Ie(m,jr);Ie(N,jr,N),xt(N,t.domain,m),xt(y,t.domain,m),Ie(y,ma,x),Ie(y,jr,N);const w=Ie(y,Zi);xt(w,t.numeric,iw);const j=Ie(o,jr),S=Ie(o,ma);Ie(j,jr,j),xt(j,t.domain,o),xt(S,r,i),xt(S,t.domain,o);const E=wr(Eh);xt(S,t.tld,E),xt(S,t.utld,E),xt(E,t.domain,o),xt(E,r,i),Ie(E,ma,S),Ie(E,jr,j),Ie(E,Qi,h);const T=Ie(E,Zi),P=wr(Eh);xt(T,t.numeric,P);const O=wr(Eh),q=wr();xt(O,e,O),xt(O,n,q),xt(q,e,O),xt(q,n,q),Ie(E,xa,O),Ie(P,xa,O);const z=Ie(c,Zi),V=Ie(u,Zi),I=Ie(V,xa),te=Ie(I,xa);xt(c,t.domain,o),Ie(c,ma,S),Ie(c,jr,j),xt(u,t.domain,o),Ie(u,ma,S),Ie(u,jr,j),xt(z,t.domain,O),Ie(z,xa,O),Ie(z,Fd,O),xt(te,t.domain,O),xt(te,e,O),Ie(te,xa,O);const Q=[[_d,zd],[yf,bf],[vf,Nf],[wf,jf],[kf,Sf],[Cf,Tf],[Ef,Mf],[Af,If]];for(let F=0;F=0&&x++,a++,f++;if(x<0)a-=f,a0&&(i.push(Kx(ow,e,o)),o=[]),a-=x,f-=x;const y=m.t,N=n.slice(a-f,a);i.push(Kx(y,e,N))}}return o.length>0&&i.push(Kx(ow,e,o)),i}function Kx(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 dz=typeof console<"u"&&console&&console.warn||(()=>{}),uz="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ln={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function hz(){return Ks.groups={},ln.scanner=null,ln.parser=null,ln.tokenQueue=[],ln.pluginQueue=[],ln.customSchemes=[],ln.initialized=!1,ln}function lw(t,e=!1){if(ln.initialized&&dz(`linkifyjs: already initialized - will not register custom scheme "${t}" ${uz}`),!/^[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`);ln.customSchemes.push([t,e])}function fz(){ln.scanner=az(ln.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=QS(n.doc,[...e]);if(rC(c).forEach(({newRange:h})=>{const f=xD(r.doc,h,y=>y.isTextblock);let m,g;if(f.length>1)m=f[0],g=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(f.length){const y=r.doc.textBetween(h.from,h.to," "," ");if(!mz.test(y))return;m=f[0],g=r.doc.textBetween(m.pos,h.to,void 0," ")}if(m&&g){const y=g.split(pz).filter(Boolean);if(y.length<=0)return!1;const N=y[y.length-1],w=m.pos+g.lastIndexOf(N);if(!N)return!1;const j=xy(N).map(S=>S.toObject(t.defaultProtocol));if(!xz(j))return!1;j.filter(S=>S.isLink).map(S=>({...S,from:w+S.start+1,to:w+S.end+1})).filter(S=>r.schema.marks.code?!r.doc.rangeHasMark(S.from,S.to,r.schema.marks.code):!0).filter(S=>t.validate(S.value)).filter(S=>t.shouldAutoLink(S.value)).forEach(S=>{ry(S.from,S.to,r.doc).some(E=>E.mark.type===t.type)||o.addMark(S.from,S.to,t.type.create({href:S.href}))})}}),!!o.steps.length)return o}})}function bz(t){return new rn({key:new pn("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=sC(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 vz(t){return new rn({key:new pn("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=$C(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 Go(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(gz,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Nz=kl.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"){lw(t);return}lw(t.scheme,t.optionalSlashes)})},onDestroy(){hz()},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)=>!!Go(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=>!!Go(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=>!!Go(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Vt(this.options.HTMLAttributes,t),0]:["a",Vt(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=>!!Go(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=>!!Go(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[xl({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,a=$C(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!Go(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(yz({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:a=>!!Go(a,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(bz({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(vz({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),wz=Object.defineProperty,jz=(t,e)=>{for(var n in e)wz(t,n,{get:e[n],enumerable:!0})},kz="listItem",cw="textStyle",dw=/^\s*([-+*])\s$/,FC=Pn.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",Vt(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(kz,this.editor.getAttributes(cw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Ac({find:dw,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ac({find:dw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(cw),editor:this.editor})),[t]}}),BC=Pn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Vt(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)=>ly(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)}}}),Sz={};jz(Sz,{findListItemPos:()=>hu,getNextListDepth:()=>by,handleBackspace:()=>Gx,handleDelete:()=>Jx,hasListBefore:()=>VC,hasListItemAfter:()=>Cz,hasListItemBefore:()=>HC,listItemHasSubList:()=>UC,nextListIsDeeper:()=>WC,nextListIsHigher:()=>KC});var hu=(t,e)=>{const{$from:n}=e.selection,r=zn(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}},by=(t,e)=>{const n=hu(t,e);if(!n)return!1;const[,r]=TD(e,t,n.$pos.pos+4);return r},VC=(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))},HC=(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)},UC=(t,e,n)=>{if(!n)return!1;const r=zn(t,e.schema);let a=!1;return n.descendants(i=>{i.type===r&&(a=!0)}),a},Gx=(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)&&VC(t.state,e,n)){const{$anchor:c}=t.state.selection,u=t.state.doc.resolve(c.before()-1),h=[];u.node().descendants((g,y)=>{g.type.name===e&&h.push({node:g,pos:y})});const f=h.at(-1);if(!f)return!1;const m=t.state.doc.resolve(u.start()+f.pos+1);return t.chain().cut({from:c.start()-1,to:c.end()+1},m.end()).joinForward().run()}if(!go(t.state,e)||!ID(t.state))return!1;const r=hu(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=UC(e,t.state,i);return HC(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},WC=(t,e)=>{const n=by(t,e),r=hu(t,e);return!r||!n?!1:n>r.depth},KC=(t,e)=>{const n=by(t,e),r=hu(t,e);return!r||!n?!1:n{if(!go(t.state,e)||!AD(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:a}=n;return!n.empty&&r.sameParent(a)?!1:WC(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():KC(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},Cz=(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)},qC=Cn.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&&Jx(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&&Jx(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&&Gx(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&&Gx(t,n,r)&&(e=!0)}),e}}}}),uw=/^(\s*)(\d+)\.\s+(.*)$/,Tz=/^\s/;function Ez(t){const e=[];let n=0,r=0;for(;n{const a=e.some(h=>h.docChanged)&&!n.doc.eq(r.doc),i=e.some(h=>h.getMeta("preventAutolink"));if(!a||i)return;const{tr:o}=r,c=QS(n.doc,[...e]);if(rC(c).forEach(({newRange:h})=>{const f=gD(r.doc,h,y=>y.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 y=r.doc.textBetween(h.from,h.to," "," ");if(!mz.test(y))return;m=f[0],x=r.doc.textBetween(m.pos,h.to,void 0," ")}if(m&&x){const y=x.split(pz).filter(Boolean);if(y.length<=0)return!1;const N=y[y.length-1],w=m.pos+x.lastIndexOf(N);if(!N)return!1;const j=gy(N).map(S=>S.toObject(t.defaultProtocol));if(!gz(j))return!1;j.filter(S=>S.isLink).map(S=>({...S,from:w+S.start+1,to:w+S.end+1})).filter(S=>r.schema.marks.code?!r.doc.rangeHasMark(S.from,S.to,r.schema.marks.code):!0).filter(S=>t.validate(S.value)).filter(S=>t.shouldAutoLink(S.value)).forEach(S=>{ry(S.from,S.to,r.doc).some(E=>E.mark.type===t.type)||o.addMark(S.from,S.to,t.type.create({href:S.href}))})}}),!!o.steps.length)return o}})}function bz(t){return new rn({key:new pn("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=sC(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 vz(t){return new rn({key:new pn("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=$C(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 Go(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(xz,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Nz=kl.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"){lw(t);return}lw(t.scheme,t.optionalSlashes)})},onDestroy(){hz()},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)=>!!Go(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=>!!Go(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=>!!Go(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Vt(this.options.HTMLAttributes,t),0]:["a",Vt(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=>!!Go(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=>!!Go(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[gl({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,a=$C(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!Go(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(yz({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:a=>!!Go(a,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(bz({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(vz({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),wz=Object.defineProperty,jz=(t,e)=>{for(var n in e)wz(t,n,{get:e[n],enumerable:!0})},kz="listItem",cw="textStyle",dw=/^\s*([-+*])\s$/,FC=Pn.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",Vt(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(kz,this.editor.getAttributes(cw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Ac({find:dw,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ac({find:dw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(cw),editor:this.editor})),[t]}}),BC=Pn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Vt(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)=>ly(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)}}}),Sz={};jz(Sz,{findListItemPos:()=>hu,getNextListDepth:()=>by,handleBackspace:()=>Gg,handleDelete:()=>Jg,hasListBefore:()=>VC,hasListItemAfter:()=>Cz,hasListItemBefore:()=>HC,listItemHasSubList:()=>UC,nextListIsDeeper:()=>WC,nextListIsHigher:()=>KC});var hu=(t,e)=>{const{$from:n}=e.selection,r=zn(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}},by=(t,e)=>{const n=hu(t,e);if(!n)return!1;const[,r]=TD(e,t,n.$pos.pos+4);return r},VC=(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))},HC=(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)},UC=(t,e,n)=>{if(!n)return!1;const r=zn(t,e.schema);let a=!1;return n.descendants(i=>{i.type===r&&(a=!0)}),a},Gg=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!xo(t.state,e)&&VC(t.state,e,n)){const{$anchor:c}=t.state.selection,u=t.state.doc.resolve(c.before()-1),h=[];u.node().descendants((x,y)=>{x.type.name===e&&h.push({node:x,pos:y})});const f=h.at(-1);if(!f)return!1;const m=t.state.doc.resolve(u.start()+f.pos+1);return t.chain().cut({from:c.start()-1,to:c.end()+1},m.end()).joinForward().run()}if(!xo(t.state,e)||!ID(t.state))return!1;const r=hu(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=UC(e,t.state,i);return HC(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},WC=(t,e)=>{const n=by(t,e),r=hu(t,e);return!r||!n?!1:n>r.depth},KC=(t,e)=>{const n=by(t,e),r=hu(t,e);return!r||!n?!1:n{if(!xo(t.state,e)||!AD(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:a}=n;return!n.empty&&r.sameParent(a)?!1:WC(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():KC(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},Cz=(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)},qC=Cn.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&&Jg(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&&Jg(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&&Gg(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&&Gg(t,n,r)&&(e=!0)}),e}}}}),uw=/^(\s*)(\d+)\.\s+(.*)$/,Tz=/^\s/;function Ez(t){const e=[];let n=0,r=0;for(;ne;)g.push(t[m]),m+=1;if(g.length>0){const y=Math.min(...g.map(w=>w.indent)),N=GC(g,y,n);h.push({type:"list",ordered:!0,start:g[0].number,items:N,raw:g.map(w=>w.raw).join(` +`).trim();if(f){const y=n.blockTokens(f);h.push(...y)}let m=i+1;const x=[];for(;me;)x.push(t[m]),m+=1;if(x.length>0){const y=Math.min(...x.map(w=>w.indent)),N=GC(x,y,n);h.push({type:"list",ordered:!0,start:x[0].number,items:N,raw:x.map(w=>w.raw).join(` `)})}a.push({type:"list_item",raw:o.raw,tokens:h}),i=m}else i+=1}return a}function Mz(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(a=>{if(a.type==="paragraph"||a.type==="list"||a.type==="blockquote"||a.type==="code")r.push(...e.parseChildren([a]));else if(a.type==="text"&&a.tokens){const i=e.parseChildren([a]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([a]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var Az="listItem",hw="textStyle",fw=/^(\d+)\.\s$/,JC=Pn.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",Vt(this.options.HTMLAttributes,n),0]:["ol",Vt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?Mz(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e==null?void 0:e.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const a=t.split(` `),[i,o]=Ez(a);if(i.length===0)return;const c=GC(i,0,n);return c.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:c,raw:a.slice(0,o).join(` -`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Az,this.editor.getAttributes(hw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Ac({find:fw,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ac({find:fw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(hw)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Iz=/^\s*(\[([( |x])?\])\s$/,Rz=Pn.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",Vt(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 ly(t,e,a)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const a=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),c=document.createElement("input"),u=document.createElement("div"),h=m=>{var g,y;c.ariaLabel=((y=(g=this.options.a11y)==null?void 0:g.checkboxLabel)==null?void 0:y.call(g,m,c.checked))||`Task item checkbox for ${m.textContent||"empty task item"}`};h(t),i.contentEditable="false",c.type="checkbox",c.addEventListener("mousedown",m=>m.preventDefault()),c.addEventListener("change",m=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){c.checked=!c.checked;return}const{checked:g}=m.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:y})=>{const N=n();if(typeof N!="number")return!1;const w=y.doc.nodeAt(N);return y.setNodeMarkup(N,void 0,{...w==null?void 0:w.attrs,checked:g}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,g)||(c.checked=!c.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([m,g])=>{a.setAttribute(m,g)}),a.dataset.checked=t.attrs.checked,c.checked=t.attrs.checked,i.append(c,o),a.append(i,u),Object.entries(e).forEach(([m,g])=>{a.setAttribute(m,g)});let f=new Set(Object.keys(e));return{dom:a,contentDOM:u,update:m=>{if(m.type!==this.type)return!1;a.dataset.checked=m.attrs.checked,c.checked=m.attrs.checked,h(m);const g=r.extensionManager.attributes,y=Zd(m,g),N=new Set(Object.keys(y)),w=this.options.HTMLAttributes;return f.forEach(j=>{N.has(j)||(j in w?a.setAttribute(j,w[j]):a.removeAttribute(j))}),Object.entries(y).forEach(([j,S])=>{S==null?j in w?a.setAttribute(j,w[j]):a.removeAttribute(j):a.setAttribute(j,S)}),f=N,!0}}}},addInputRules(){return[Ac({find:Iz,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Pz=Pn.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",Vt(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=zx(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=zx(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()}}});Cn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(FC.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(BC.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(qC.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(JC.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Rz.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Pz.configure(this.options.taskList)),t}});var pw=" ",Oz=" ",Lz=Pn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Vt(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===pw||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?pw:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Dz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,_z=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,zz=kl.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",Vt(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[Mc({find:Dz,type:this.type})]},addPasteRules(){return[xl({find:_z,type:this.type})]}}),$z=Pn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Fz=kl.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",Vt(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 Bz(t={}){return new rn({view(e){return new Vz(e,t)}})}class Vz{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(a=>{let i=o=>{this[a](o)};return e.dom.addEventListener(a,i),{name:a,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,a=this.editorView.dom,i=a.getBoundingClientRect(),o=i.width/a.offsetWidth,c=i.height/a.offsetHeight;if(n){let m=e.nodeBefore,g=e.nodeAfter;if(m||g){let y=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(y){let N=y.getBoundingClientRect(),w=m?N.bottom:N.top;m&&g&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let j=this.width/2*c;r={left:N.left,right:N.right,top:w-j,bottom:w+j}}}}if(!r){let m=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*o;r={left:m.left-g,right:m.left+g,top:m.top,bottom:m.bottom}}let u=this.editorView.dom.offsetParent;this.element||(this.element=u.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let h,f;if(!u||u==document.body&&getComputedStyle(u).position=="static")h=-pageXOffset,f=-pageYOffset;else{let m=u.getBoundingClientRect(),g=m.width/u.offsetWidth,y=m.height/u.offsetHeight;h=m.left-u.scrollLeft*g,f=m.top-u.scrollTop*y}this.element.style.left=(r.left-h)/o+"px",this.element.style.top=(r.top-f)/c+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/c+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),a=r&&r.type.spec.disableDropCursor,i=typeof a=="function"?a(this.editorView,n,e):a;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=V2(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 kn extends ot{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return kn.valid(r)?new kn(r):ot.near(r)}content(){return _e.empty}eq(e){return e instanceof kn&&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 kn(e.resolve(n.pos))}getBookmark(){return new vy(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Hz(e)||!Uz(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&&kn.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(kn.valid(u))return u}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!Ze.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(kn.valid(c))return c}return null}}}kn.prototype.visible=!1;kn.findFrom=kn.findGapCursorFrom;ot.jsonID("gapcursor",kn);class vy{constructor(e){this.pos=e}map(e){return new vy(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return kn.valid(n)?new kn(n):ot.near(n)}}function QC(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Hz(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let a=r.child(n-1);;a=a.lastChild){if(a.childCount==0&&!a.inlineContent||QC(a.type))return!0;if(a.inlineContent)return!1}}return!0}function Uz(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||QC(a.type))return!0;if(a.inlineContent)return!1}}return!0}function Wz(){return new rn({props:{decorations:Jz,createSelectionBetween(t,e,n){return e.pos==n.pos&&kn.valid(n)?new kn(n):null},handleClick:qz,handleKeyDown:Kz,handleDOMEvents:{beforeinput:Gz}}})}const Kz=X0({ArrowLeft:Mh("horiz",-1),ArrowRight:Mh("horiz",1),ArrowUp:Mh("vert",-1),ArrowDown:Mh("vert",1)});function Mh(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 et){if(!i.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=r.doc.resolve(e>0?c.after():c.before())}let h=kn.findGapCursorFrom(c,e,u);return h?(a&&a(r.tr.setSelection(new kn(h))),!0):!1}}function qz(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!kn.valid(r))return!1;let a=t.posAtCoords({left:n.clientX,top:n.clientY});return a&&a.inside>-1&&Ze.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new kn(r))),!0)}function Gz(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof kn))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=Ne.empty;for(let o=r.length-1;o>=0;o--)a=Ne.from(r[o].createAndFill(null,a));let i=t.state.tr.replace(n.pos,n.pos,new _e(a,0,0));return i.setSelection(et.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function Jz(t){if(!(t.selection instanceof kn))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Xt.create(t.doc,[Kn.widget(t.selection.head,e,{key:"gapcursor"})])}var Wf=200,es=function(){};es.prototype.append=function(e){return e.length?(e=es.from(e),!this.length&&e||e.length=n?es.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};es.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};es.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)};es.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};es.from=function(e){return e instanceof es?e:e&&e.length?new YC(e):es.empty};var YC=(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<=Wf)return new e(this.values.concat(a.flatten()))},e.prototype.leafPrepend=function(a){if(this.length+a.length<=Wf)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})(es);es.empty=new YC([]);var Qz=(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})(es);const Yz=500;class Gr{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let a,i;n&&(a=this.remapping(r,this.items.length),i=a.maps.length);let o=e.tr,c,u,h=[],f=[];return this.items.forEach((m,g)=>{if(!m.step){a||(a=this.remapping(r,g+1),i=a.maps.length),i--,f.push(m);return}if(a){f.push(new Ki(m.map));let y=m.step.map(a.slice(i)),N;y&&o.maybeStep(y).doc&&(N=o.mapping.maps[o.mapping.maps.length-1],h.push(new Ki(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 Gr(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;fZz&&(c=Xz(c,h),o-=h),new Gr(c.append(i),o)}remapping(e,n){let r=new qd;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 Gr(this.items.append(e.map(n=>new Ki(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],a=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,c=this.eventCount;this.items.forEach(g=>{g.selection&&c--},a);let u=n;this.items.forEach(g=>{let y=i.getMirror(--u);if(y==null)return;o=Math.min(o,y);let N=i.maps[y];if(g.step){let w=e.steps[y].invert(e.docs[y]),j=g.selection&&g.selection.map(i.slice(u+1,y));j&&c++,r.push(new Ki(N,w,j))}else r.push(new Ki(N))},a);let h=[];for(let g=n;gYz&&(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 Ki(h.invert(),u,f),g,y=a.length-1;(g=a.length&&a[y].merge(m))?a[y]=g:a.push(m)}}else o.map&&r--},this.items.length,0),new Gr(es.from(a.reverse()),i)}}Gr.empty=new Gr(es.empty,0);function Xz(t,e){let n;return t.forEach((r,a)=>{if(r.selection&&e--==0)return n=a,!1}),t.slice(n)}let Ki=class XC{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 XC(n.getMap().invert(),n,this.selection)}}};class Yi{constructor(e,n,r,a,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=a,this.prevComposition=i}}const Zz=20;function e$(t,e,n,r){let a=n.getMeta(ol),i;if(a)return a.historyState;n.getMeta(s$)&&(t=new Yi(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(ol))return o.getMeta(ol).redo?new Yi(t.done.addTransform(n,void 0,r,Bh(e)),t.undone,mw(n.mapping.maps),t.prevTime,t.prevComposition):new Yi(t.done,t.undone.addTransform(n,void 0,r,Bh(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||!t$(n,t.prevRanges)),h=o?qg(t.prevRanges,n.mapping):mw(n.mapping.maps);return new Yi(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,Bh(e)),Gr.empty,h,n.time,c??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Yi(t.done.rebased(n,i),t.undone.rebased(n,i),qg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Yi(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),qg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function t$(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 mw(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 qg(t,e){if(!t)return null;let n=[];for(let r=0;r{let a=ol.getState(n);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(r){let i=n$(a,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const e3=ZC(!1,!0),t3=ZC(!0,!0);Cn.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 rn({key:new pn("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 a$=Cn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Bz(this.options)]}});Cn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new rn({key:new pn("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:a}=e,i=[];if(!n||!r)return Xt.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(Kn.node(h,h+u.nodeSize,{class:this.options.className}))}),Xt.create(t,i)}}})]}});var i$=Cn.create({name:"gapCursor",addProseMirrorPlugins(){return[Wz()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Bt(Ye(t,"allowGapCursor",n)))!=null?e:null}}}),xw="placeholder";function o$(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var l$=Cn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:xw,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${o$(this.options.dataAttribute)}`:`data-${xw}`;return[new rn({key:new pn("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&&yp(c);if((h||!this.options.showOnlyCurrent)&&f){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const g=Kn.node(u,u+c.nodeSize,{class:m.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:c,pos:u,hasAnchor:h}):this.options.placeholder});i.push(g)}return this.options.includeChildren}),Xt.create(e,i)}}})]}});Cn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new rn({key:new pn("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||aC(n.selection)||t.view.dragging?null:Xt.create(n.doc,[Kn.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function yw({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var c$=Cn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new pn(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 rn({key:e,appendTransaction:(a,i,o)=>{const{doc:c,tr:u,schema:h}=o,f=e.getState(o),m=c.content.size,g=h.nodes[n];if(f)return u.insert(m,g.create())},state:{init:(a,i)=>{const o=i.tr.doc.lastChild;return!yw({node:o,types:r})},apply:(a,i)=>{if(!a.docChanged||a.getMeta("__uniqueIDTransaction"))return i;const o=a.doc.lastChild;return!yw({node:o,types:r})}}})]}}),d$=Cn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>e3(t,e),redo:()=>({state:t,dispatch:e})=>t3(t,e)}},addProseMirrorPlugins(){return[r$(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()}}}),u$=Cn.create({name:"starterKit",addExtensions(){var t,e,n,r;const a=[];return this.options.bold!==!1&&a.push(L7.configure(this.options.bold)),this.options.blockquote!==!1&&a.push(A7.configure(this.options.blockquote)),this.options.bulletList!==!1&&a.push(FC.configure(this.options.bulletList)),this.options.code!==!1&&a.push(z7.configure(this.options.code)),this.options.codeBlock!==!1&&a.push(B7.configure(this.options.codeBlock)),this.options.document!==!1&&a.push(V7.configure(this.options.document)),this.options.dropcursor!==!1&&a.push(a$.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&a.push(i$.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&a.push(H7.configure(this.options.hardBreak)),this.options.heading!==!1&&a.push(U7.configure(this.options.heading)),this.options.undoRedo!==!1&&a.push(d$.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&a.push(W7.configure(this.options.horizontalRule)),this.options.italic!==!1&&a.push(Q7.configure(this.options.italic)),this.options.listItem!==!1&&a.push(BC.configure(this.options.listItem)),this.options.listKeymap!==!1&&a.push(qC.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&a.push(Nz.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&a.push(JC.configure(this.options.orderedList)),this.options.paragraph!==!1&&a.push(Lz.configure(this.options.paragraph)),this.options.strike!==!1&&a.push(zz.configure(this.options.strike)),this.options.text!==!1&&a.push($z.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(c$.configure((r=this.options)==null?void 0:r.trailingNode)),a}}),h$=u$,f$=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,p$=Pn.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",Vt(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,a,i,o;const c=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",u=(a=(r=t.attrs)==null?void 0:r.alt)!=null?a:"",h=(o=(i=t.attrs)==null?void 0:i.title)!=null?o:"";return h?`![${u}](${c} "${h}")`:`![${u}](${c})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:a,getPos:i,HTMLAttributes:o,editor:c})=>{const u=document.createElement("img");Object.entries(o).forEach(([m,g])=>{if(g!=null)switch(m){case"width":case"height":break;default:u.setAttribute(m,g);break}}),u.src=o.src;const h=new x_({element:u,editor:c,node:a,getPos:i,onResize:(m,g)=>{u.style.width=`${m}px`,u.style.height=`${g}px`},onCommit:(m,g)=>{const y=i();y!==void 0&&this.editor.chain().setNodeSelection(y).updateAttributes(this.name,{width:m,height:g}).run()},onUpdate:(m,g,y)=>m.type===a.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),f=h.dom;return f.style.visibility="hidden",f.style.pointerEvents="none",u.onload=()=>{f.style.visibility="",f.style.pointerEvents=""},h}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[wC({find:f$,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),m$=p$;function g$(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:c}=t,u=r&&!a,h=b_(n),f=new RegExp(`\\s${h}$`),m=o?"^":"",g=a?"":h,y=u?new RegExp(`${m}${h}.*?(?=\\s${g}|$)`,"gm"):new RegExp(`${m}(?:^)?${h}[^\\s${g}]*`,"gm"),N=((e=c.nodeBefore)==null?void 0:e.isText)&&c.nodeBefore.text;if(!N)return null;const w=c.pos-N.length,j=Array.from(N.matchAll(y)).pop();if(!j||j.input===void 0||j.index===void 0)return null;const S=j.input.slice(Math.max(0,j.index-1),j.index),E=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(S);if(i!==null&&!E)return null;const T=w+j.index;let P=T+j[0].length;return u&&f.test(N.slice(P-1,P+1))&&(j[0]+=" ",P+=1),T=c.pos?{range:{from:T,to:P},query:j[0].slice(n.length),text:j[0]}:null}var x$=new pn("suggestion");function y$({pluginKey:t=x$,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:a=!1,allowedPrefixes:i=[" "],startOfLine:o=!1,decorationTag:c="span",decorationClass:u="suggestion",decorationContent:h="",decorationEmptyClass:f="is-empty",command:m=()=>null,items:g=()=>[],render:y=()=>({}),allow:N=()=>!0,findSuggestionMatch:w=g$,shouldShow:j}){let S;const E=y==null?void 0:y(),T=()=>{const z=e.state.selection.$anchor.pos,V=e.view.coordsAtPos(z),{top:I,right:te,bottom:Q,left:F}=V;try{return new DOMRect(F,I,te-F,Q-I)}catch{return null}},P=(z,V)=>V?()=>{const I=t.getState(e.state),te=I==null?void 0:I.decorationId,Q=z.dom.querySelector(`[data-decoration-id="${te}"]`);return(Q==null?void 0:Q.getBoundingClientRect())||null}:T;function O(z,V){var I;try{const Q=t.getState(z.state),F=Q!=null&&Q.decorationId?z.dom.querySelector(`[data-decoration-id="${Q.decorationId}"]`):null,re={editor:e,range:(Q==null?void 0:Q.range)||{from:0,to:0},query:(Q==null?void 0:Q.query)||null,text:(Q==null?void 0:Q.text)||null,items:[],command:ae=>m({editor:e,range:(Q==null?void 0:Q.range)||{from:0,to:0},props:ae}),decorationNode:F,clientRect:P(z,F)};(I=E==null?void 0:E.onExit)==null||I.call(E,re)}catch{}const te=z.state.tr.setMeta(V,{exit:!0});z.dispatch(te)}const q=new rn({key:t,view(){return{update:async(z,V)=>{var I,te,Q,F,re,ae,J;const $=(I=this.key)==null?void 0:I.getState(V),D=(te=this.key)==null?void 0:te.getState(z.state),R=$.active&&D.active&&$.range.from!==D.range.from,oe=!$.active&&D.active,G=$.active&&!D.active,_=!oe&&!G&&$.query!==D.query,U=oe||R&&_,H=_||R,K=G||R&&_;if(!U&&!H&&!K)return;const me=K&&!U?$:D,Y=z.dom.querySelector(`[data-decoration-id="${me.decorationId}"]`);S={editor:e,range:me.range,query:me.query,text:me.text,items:[],command:le=>m({editor:e,range:me.range,props:le}),decorationNode:Y,clientRect:P(z,Y)},U&&((Q=E==null?void 0:E.onBeforeStart)==null||Q.call(E,S)),H&&((F=E==null?void 0:E.onBeforeUpdate)==null||F.call(E,S)),(H||U)&&(S.items=await g({editor:e,query:me.query})),K&&((re=E==null?void 0:E.onExit)==null||re.call(E,S)),H&&((ae=E==null?void 0:E.onUpdate)==null||ae.call(E,S)),U&&((J=E==null?void 0:E.onStart)==null||J.call(E,S))},destroy:()=>{var z;S&&((z=E==null?void 0:E.onExit)==null||z.call(E,S))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(z,V,I,te){const{isEditable:Q}=e,{composing:F}=e.view,{selection:re}=z,{empty:ae,from:J}=re,$={...V},D=z.getMeta(t);if(D&&D.exit)return $.active=!1,$.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null,$;if($.composing=F,Q&&(ae||e.view.composing)){(JV.range.to)&&!F&&!V.composing&&($.active=!1);const R=w({char:n,allowSpaces:r,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:re.$from}),oe=`id_${Math.floor(Math.random()*4294967295)}`;R&&N({editor:e,state:te,range:R.range,isActive:V.active})&&(!j||j({editor:e,range:R.range,query:R.query,text:R.text,transaction:z}))?($.active=!0,$.decorationId=V.decorationId?V.decorationId:oe,$.range=R.range,$.query=R.query,$.text=R.text):$.active=!1}else $.active=!1;return $.active||($.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null),$}},props:{handleKeyDown(z,V){var I,te,Q,F;const{active:re,range:ae}=q.getState(z.state);if(!re)return!1;if(V.key==="Escape"||V.key==="Esc"){const $=q.getState(z.state),D=(I=S==null?void 0:S.decorationNode)!=null?I:null,R=D??($!=null&&$.decorationId?z.dom.querySelector(`[data-decoration-id="${$.decorationId}"]`):null);if(((te=E==null?void 0:E.onKeyDown)==null?void 0:te.call(E,{view:z,event:V,range:$.range}))||!1)return!0;const G={editor:e,range:$.range,query:$.query,text:$.text,items:[],command:_=>m({editor:e,range:$.range,props:_}),decorationNode:R,clientRect:R?()=>R.getBoundingClientRect()||null:null};return(Q=E==null?void 0:E.onExit)==null||Q.call(E,G),O(z,t),!0}return((F=E==null?void 0:E.onKeyDown)==null?void 0:F.call(E,{view:z,event:V,range:ae}))||!1},decorations(z){const{active:V,range:I,decorationId:te,query:Q}=q.getState(z);if(!V)return null;const F=!(Q!=null&&Q.length),re=[u];return F&&re.push(f),Xt.create(z.doc,[Kn.inline(I.from,I.to,{nodeName:c,class:re.join(" "),"data-decoration-id":te,"data-decoration-content":h})])}}});return q}function b$({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const a=new pn;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 n3(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>b$({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function bw(t,e){const n=n3(t),r=n.find(a=>a.char===e);return r||(n.length?n[0]:null)}var v$=Pn.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",Vt(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=bw(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",Vt({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=Vt({"data-type":this.name},this.options.HTMLAttributes,e);const a=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof a=="string"?["span",Vt({"data-type":this.name},this.options.HTMLAttributes,e),a]:a},...jC({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:bw(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 di,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 n3(this).map(y$)}}),N$=v$,w$=l$;let Qx,Yx;if(typeof WeakMap<"u"){let t=new WeakMap;Qx=e=>t.get(e),Yx=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Qx=r=>{for(let a=0;a(n==10&&(n=0),t[n++]=r,t[n++]=a)}var Sn=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:S-T});break}const P=a+T*e;for(let O=0;Or&&(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 S$(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 T$(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 Zr(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 wp(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)||E$(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function E$(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 Xx(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function M$(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Ny(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function s3(t,e,n){const r=t.node(-1),a=Sn.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 bl(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 r3(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let a=0;af!=n.pos-i);u.unshift(n.pos-i);const h=u.map(f=>{const m=r.nodeAt(f);if(!m)throw new RangeError(`No cell with offset ${f} found`);const g=i+f+1;return new q2(c.resolve(g),c.resolve(g+m.content.size))});super(h[0].$from,h[0].$to,h),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),a=e.resolve(n.map(this.$headCell.pos));if(Xx(r)&&Xx(a)&&Ny(r,a)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?ri.rowSelection(r,a):i&&this.isColSelection()?ri.colSelection(r,a):new ri(r,a)}return et.between(r,a)}content(){const e=this.$anchorCell.node(-1),n=Sn.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||j>0){let S=N.attrs;if(w>0&&(S=bl(S,0,w)),j>0&&(S=bl(S,S.colspan-j,j)),y.lefta.bottom){const S={...N.attrs,rowspan:Math.min(y.bottom,a.bottom)-Math.max(y.top,a.top)};y.top0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,a=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,a)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),a=Sn.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 ri&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),a=Sn.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(Kn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Xt.create(t.doc,e)}function P$({$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 O$({$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 L$(t,e,n){const r=(e||t).selection,a=(e||t).doc;let i,o;if(r instanceof Ze&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=sn.create(a,r.from);else if(o=="row"){const c=a.resolve(r.from+1);i=sn.rowSelection(c,c)}else if(!n){const c=Sn.get(r.node),u=r.from+1,h=u+c.map[c.width*c.height-1];i=sn.create(a,u+1,h)}}else r instanceof et&&P$(r)?i=et.create(a,r.from):r instanceof et&&O$(r)&&(i=et.create(a,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const D$=new pn("fix-tables");function i3(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=_$(t,a,i,n))};return e?e.doc!=t.doc&&i3(e.doc,t.doc,0,r):t.doc.descendants(r),n}function _$(t,e,n,r){const a=Sn.get(e);if(!a.problems)return r;r||(r=t.tr);const i=[];for(let u=0;u0){let y="cell";f.firstChild&&(y=f.firstChild.type.spec.tableRole);const N=[];for(let j=0;j0?-1:0;A$(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;V$(e,r,a+c)&&(c=a==0||a==e.height?null:0);for(let h=0,f=e.width*a;h0&&a0&&m==e.map[f-e.width]){const g=n.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(c).map(m+r),null,{...g,rowspan:g.rowspan-1}),h+=g.colspan-1}else if(a0&&n[i]==n[i-1]||r.right0&&n[a]==n[a-t]||r.bottom0){const f=u+1+h.content.size,m=vw(h)?u+1:f;i.replaceWith(m+r.tableStart,f+r.tableStart,c)}i.setSelection(new sn(i.doc.resolve(u+r.tableStart))),e(i)}return!0}function ww(t,e){const n=js(t.schema);return G$(({node:r})=>n[r.type.spec.tableRole])(t,e)}function G$(t){return(e,n)=>{const r=e.selection;let a,i;if(r instanceof sn){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;a=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(a=T$(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=Ca(e),m=e.tr;for(let y=0;y{o.attrs[t]!==e&&i.setNodeMarkup(c,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(a.pos,null,{...a.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function Q$(t){return function(e,n){if(!Zr(e))return!1;if(n){const r=js(e.schema),a=Ca(e),i=e.tr,o=a.map.cellsInRect(t=="column"?{left:a.left,top:0,right:a.right,bottom:a.map.height}:t=="row"?{left:0,top:a.top,right:a.map.width,bottom:a.bottom}:a),c=o.map(u=>a.table.nodeAt(u));for(let u=0;u{const y=g+i.tableStart,N=o.doc.nodeAt(y);N&&o.setNodeMarkup(y,m,N.attrs)}),r(o)}return!0}}nu("row",{useDeprecatedLogic:!0});nu("column",{useDeprecatedLogic:!0});const Y$=nu("cell",{useDeprecatedLogic:!0});function X$(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 Ah(t,e){const n=t.selection;if(!(n instanceof sn))return!1;if(e){const r=t.tr,a=js(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 _e(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(Ne.empty),n[a]r&&(g=g.type.createChecked(bl(g.attrs,g.attrs.colspan,f+g.attrs.colspan-r),g.content)),h.push(g),f+=g.attrs.colspan;for(let y=1;ya&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,a-m.attrs.rowspan)},m.content)),u.push(m)}i.push(Ne.from(u))}n=i,e=a}return{width:t,height:e,rows:n}}function sF(t,e,n,r,a,i,o){const c=t.doc.type.schema,u=js(c);let h,f;if(a>e.width)for(let m=0,g=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(j?f||(f=u.header_cell.createAndFill()):h||(h=u.cell.createAndFill()))}const g=u.row.create(null,Ne.from(m)),y=[];for(let N=e.height;N{if(!a)return!1;const i=n.selection;if(i instanceof sn)return Vh(n,r,ot.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=d3(a,t,e);if(o==null)return!1;if(t=="horiz")return Vh(n,r,ot.near(n.doc.resolve(i.head+e),e));{const c=n.doc.resolve(o),u=s3(c,t,e);let h;return u?h=ot.near(u,1):e<0?h=ot.near(n.doc.resolve(c.before(-1)),-1):h=ot.near(n.doc.resolve(c.after(-1)),1),Vh(n,r,h)}}}function Rh(t,e){return(n,r,a)=>{if(!a)return!1;const i=n.selection;let o;if(i instanceof sn)o=i;else{const u=d3(a,t,e);if(u==null)return!1;o=new sn(n.doc.resolve(u))}const c=s3(o.$headCell,t,e);return c?Vh(n,r,new sn(o.$anchorCell,c)):!1}}function aF(t,e){const n=t.state.doc,r=yl(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new sn(r))),!0):!1}function iF(t,e,n){if(!Zr(t.state))return!1;let r=eF(n);const a=t.state.selection;if(a instanceof sn){r||(r={width:1,height:1,rows:[Ne.from(Zx(js(t.state.schema).cell,n))]});const i=a.$anchorCell.node(-1),o=a.$anchorCell.start(-1),c=Sn.get(i).rectBetween(a.$anchorCell.pos-o,a.$headCell.pos-o);return r=nF(r,c.right-c.left,c.bottom-c.top),Tw(t.state,t.dispatch,o,c,r),!0}else if(r){const i=wp(t.state),o=i.start(-1);return Tw(t.state,t.dispatch,o,Sn.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function oF(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=Ew(t,e.target);let a;if(e.shiftKey&&t.state.selection instanceof sn)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(a=yl(t.state.selection.$anchor))!=null&&((n=Jg(t,e))===null||n===void 0?void 0:n.pos)!=a.pos)i(a,e),e.preventDefault();else if(!r)return;function i(u,h){let f=Jg(t,h);const m=eo.getState(t.state)==null;if(!f||!Ny(u,f))if(m)f=u;else return;const g=new sn(u,f);if(m||!t.state.selection.eq(g)){const y=t.state.tr.setSelection(g);m&&y.setMeta(eo,u.pos),t.dispatch(y)}}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(Ew(t,h.target)!=r&&(m=Jg(t,e),!m))return o();m&&i(m,h)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",c)}function d3(t,e,n){if(!(t.state.selection instanceof et))return null;const{$head:r}=t.state.selection;for(let a=r.depth-1;a>=0;a--){const i=r.node(a);if((n<0?r.index(a):r.indexAfter(a))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=r.before(a),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?o:null}}return null}function Ew(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Jg(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:a}=n;return r>=0&&yl(t.state.doc.resolve(r))||yl(t.state.doc.resolve(a))}var lF=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")),e0(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,e0(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function e0(t,e,n,r,a,i){let o=0,c=!0,u=e.firstChild;const h=t.firstChild;if(h){for(let m=0,g=0;mnew r(m,n,g)),new dF(-1,!1)},apply(o,c){return c.apply(o)}},props:{attributes:o=>{const c=ir.getState(o);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,c)=>{uF(o,c,t,a)},mouseleave:o=>{hF(o)},mousedown:(o,c)=>{fF(o,c,e,n)}},decorations:o=>{const c=ir.getState(o);if(c&&c.activeHandle>-1)return yF(o,c.activeHandle)},nodeViews:{}}});return i}var dF=class Hh{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(ir);if(r&&r.setHandle!=null)return new Hh(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Hh(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let a=e.mapping.map(n.activeHandle,-1);return Xx(e.doc.resolve(a))||(a=-1),new Hh(a,n.dragging)}return n}};function uF(t,e,n,r){if(!t.editable)return;const a=ir.getState(t.state);if(a&&!a.dragging){const i=mF(e.target);let o=-1;if(i){const{left:c,right:u}=i.getBoundingClientRect();e.clientX-c<=n?o=Mw(t,e,"left",n):u-e.clientX<=n&&(o=Mw(t,e,"right",n))}if(o!=a.activeHandle){if(!r&&o!==-1){const c=t.state.doc.resolve(o),u=c.node(-1),h=Sn.get(u),f=c.start(-1);if(h.colCount(c.pos-f)+c.nodeAfter.attrs.colspan-1==h.width-1)return}u3(t,o)}}}function hF(t){if(!t.editable)return;const e=ir.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&u3(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=ir.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const c=t.state.doc.nodeAt(o.activeHandle),u=pF(t,o.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(ir,{setDragging:{startX:e.clientX,startWidth:u}}));function h(m){i.removeEventListener("mouseup",h),i.removeEventListener("mousemove",f);const g=ir.getState(t.state);g!=null&&g.dragging&&(gF(t,g.activeHandle,Aw(g.dragging,m,n)),t.dispatch(t.state.tr.setMeta(ir,{setDragging:null})))}function f(m){if(!m.which)return h(m);const g=ir.getState(t.state);if(g&&g.dragging){const y=Aw(g.dragging,m,n);Iw(t,g.activeHandle,y,r)}}return Iw(t,o.activeHandle,u,r),i.addEventListener("mouseup",h),i.addEventListener("mousemove",f),e.preventDefault(),!0}function pF(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",Vt(this.options.HTMLAttributes,t),0]}}),f3=Pn.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",Vt(this.options.HTMLAttributes,t),0]}}),p3=Pn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Vt(this.options.HTMLAttributes,t),0]}});function t0(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Rw(t,e,n,r,a,i){var o;let c=0,u=!0,h=e.firstChild;const f=t.firstChild;if(f!==null)for(let g=0,y=0;g{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function jF(t,e,n,r,a){const i=wF(t),o=[],c=[];for(let h=0;h{const{selection:e}=t.state;if(!kF(e))return!1;let n=0;const r=YS(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},SF="";function CF(t){return(t||"").replace(/\s+/g," ").trim()}function TF(t,e,n={}){var r;const a=(r=n.cellLineSeparator)!=null?r:SF;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(N=>{const w=[];N.content&&N.content.forEach(j=>{let S="";j.content&&Array.isArray(j.content)&&j.content.length>1?S=j.content.map(O=>e.renderChildren(O)).join(a):S=j.content?e.renderChildren(j.content):"";const E=CF(S),T=j.type==="tableHeader";w.push({text:E,isHeader:T})}),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 j=0;jc[j]&&(c[j]=E),c[j]<3&&(c[j]=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 g=new Array(o).fill(0).map((N,w)=>f&&h[w]&&h[w].text||"");return m+=`| ${g.map((N,w)=>u(N,c[w])).join(" | ")} | +`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Az,this.editor.getAttributes(hw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Ac({find:fw,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ac({find:fw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(hw)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Iz=/^\s*(\[([( |x])?\])\s$/,Rz=Pn.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",Vt(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 ly(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,y;c.ariaLabel=((y=(x=this.options.a11y)==null?void 0:x.checkboxLabel)==null?void 0:y.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:y})=>{const N=n();if(typeof N!="number")return!1;const w=y.doc.nodeAt(N);return y.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,y=Zd(m,x),N=new Set(Object.keys(y)),w=this.options.HTMLAttributes;return f.forEach(j=>{N.has(j)||(j in w?a.setAttribute(j,w[j]):a.removeAttribute(j))}),Object.entries(y).forEach(([j,S])=>{S==null?j in w?a.setAttribute(j,w[j]):a.removeAttribute(j):a.setAttribute(j,S)}),f=N,!0}}}},addInputRules(){return[Ac({find:Iz,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Pz=Pn.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",Vt(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=zg(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=zg(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()}}});Cn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(FC.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(BC.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(qC.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(JC.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Rz.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Pz.configure(this.options.taskList)),t}});var pw=" ",Oz=" ",Lz=Pn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Vt(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===pw||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?pw:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Dz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,_z=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,zz=kl.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",Vt(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[Mc({find:Dz,type:this.type})]},addPasteRules(){return[gl({find:_z,type:this.type})]}}),$z=Pn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Fz=kl.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",Vt(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 Bz(t={}){return new rn({view(e){return new Vz(e,t)}})}class Vz{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 y=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(y){let N=y.getBoundingClientRect(),w=m?N.bottom:N.top;m&&x&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let j=this.width/2*c;r={left:N.left,right:N.right,top:w-j,bottom:w+j}}}}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,y=m.height/u.offsetHeight;h=m.left-u.scrollLeft*x,f=m.top-u.scrollTop*y}this.element.style.left=(r.left-h)/o+"px",this.element.style.top=(r.top-f)/c+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/c+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),a=r&&r.type.spec.disableDropCursor,i=typeof a=="function"?a(this.editorView,n,e):a;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=V2(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 kn extends ot{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return kn.valid(r)?new kn(r):ot.near(r)}content(){return _e.empty}eq(e){return e instanceof kn&&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 kn(e.resolve(n.pos))}getBookmark(){return new vy(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Hz(e)||!Uz(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&&kn.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(kn.valid(u))return u}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!Ze.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(kn.valid(c))return c}return null}}}kn.prototype.visible=!1;kn.findFrom=kn.findGapCursorFrom;ot.jsonID("gapcursor",kn);class vy{constructor(e){this.pos=e}map(e){return new vy(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return kn.valid(n)?new kn(n):ot.near(n)}}function QC(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Hz(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let a=r.child(n-1);;a=a.lastChild){if(a.childCount==0&&!a.inlineContent||QC(a.type))return!0;if(a.inlineContent)return!1}}return!0}function Uz(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||QC(a.type))return!0;if(a.inlineContent)return!1}}return!0}function Wz(){return new rn({props:{decorations:Jz,createSelectionBetween(t,e,n){return e.pos==n.pos&&kn.valid(n)?new kn(n):null},handleClick:qz,handleKeyDown:Kz,handleDOMEvents:{beforeinput:Gz}}})}const Kz=X0({ArrowLeft:Mh("horiz",-1),ArrowRight:Mh("horiz",1),ArrowUp:Mh("vert",-1),ArrowDown:Mh("vert",1)});function Mh(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 et){if(!i.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=r.doc.resolve(e>0?c.after():c.before())}let h=kn.findGapCursorFrom(c,e,u);return h?(a&&a(r.tr.setSelection(new kn(h))),!0):!1}}function qz(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!kn.valid(r))return!1;let a=t.posAtCoords({left:n.clientX,top:n.clientY});return a&&a.inside>-1&&Ze.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new kn(r))),!0)}function Gz(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof kn))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=Ne.empty;for(let o=r.length-1;o>=0;o--)a=Ne.from(r[o].createAndFill(null,a));let i=t.state.tr.replace(n.pos,n.pos,new _e(a,0,0));return i.setSelection(et.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function Jz(t){if(!(t.selection instanceof kn))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Xt.create(t.doc,[Kn.widget(t.selection.head,e,{key:"gapcursor"})])}var Wf=200,es=function(){};es.prototype.append=function(e){return e.length?(e=es.from(e),!this.length&&e||e.length=n?es.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};es.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};es.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)};es.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};es.from=function(e){return e instanceof es?e:e&&e.length?new YC(e):es.empty};var YC=(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<=Wf)return new e(this.values.concat(a.flatten()))},e.prototype.leafPrepend=function(a){if(this.length+a.length<=Wf)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})(es);es.empty=new YC([]);var Qz=(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})(es);const Yz=500;class Gr{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 Ki(m.map));let y=m.step.map(a.slice(i)),N;y&&o.maybeStep(y).doc&&(N=o.mapping.maps[o.mapping.maps.length-1],h.push(new Ki(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 Gr(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;fZz&&(c=Xz(c,h),o-=h),new Gr(c.append(i),o)}remapping(e,n){let r=new qd;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 Gr(this.items.append(e.map(n=>new Ki(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 y=i.getMirror(--u);if(y==null)return;o=Math.min(o,y);let N=i.maps[y];if(x.step){let w=e.steps[y].invert(e.docs[y]),j=x.selection&&x.selection.map(i.slice(u+1,y));j&&c++,r.push(new Ki(N,w,j))}else r.push(new Ki(N))},a);let h=[];for(let x=n;xYz&&(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 Ki(h.invert(),u,f),x,y=a.length-1;(x=a.length&&a[y].merge(m))?a[y]=x:a.push(m)}}else o.map&&r--},this.items.length,0),new Gr(es.from(a.reverse()),i)}}Gr.empty=new Gr(es.empty,0);function Xz(t,e){let n;return t.forEach((r,a)=>{if(r.selection&&e--==0)return n=a,!1}),t.slice(n)}let Ki=class XC{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 XC(n.getMap().invert(),n,this.selection)}}};class Yi{constructor(e,n,r,a,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=a,this.prevComposition=i}}const Zz=20;function e$(t,e,n,r){let a=n.getMeta(ol),i;if(a)return a.historyState;n.getMeta(s$)&&(t=new Yi(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(ol))return o.getMeta(ol).redo?new Yi(t.done.addTransform(n,void 0,r,Bh(e)),t.undone,mw(n.mapping.maps),t.prevTime,t.prevComposition):new Yi(t.done,t.undone.addTransform(n,void 0,r,Bh(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||!t$(n,t.prevRanges)),h=o?qx(t.prevRanges,n.mapping):mw(n.mapping.maps);return new Yi(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,Bh(e)),Gr.empty,h,n.time,c??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Yi(t.done.rebased(n,i),t.undone.rebased(n,i),qx(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Yi(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),qx(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function t$(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 mw(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 qx(t,e){if(!t)return null;let n=[];for(let r=0;r{let a=ol.getState(n);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(r){let i=n$(a,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const e3=ZC(!1,!0),t3=ZC(!0,!0);Cn.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 rn({key:new pn("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 a$=Cn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Bz(this.options)]}});Cn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new rn({key:new pn("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:a}=e,i=[];if(!n||!r)return Xt.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(Kn.node(h,h+u.nodeSize,{class:this.options.className}))}),Xt.create(t,i)}}})]}});var i$=Cn.create({name:"gapCursor",addProseMirrorPlugins(){return[Wz()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Bt(Ye(t,"allowGapCursor",n)))!=null?e:null}}}),gw="placeholder";function o$(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var l$=Cn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:gw,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${o$(this.options.dataAttribute)}`:`data-${gw}`;return[new rn({key:new pn("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&&yp(c);if((h||!this.options.showOnlyCurrent)&&f){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const x=Kn.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}),Xt.create(e,i)}}})]}});Cn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new rn({key:new pn("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||aC(n.selection)||t.view.dragging?null:Xt.create(n.doc,[Kn.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function yw({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var c$=Cn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new pn(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 rn({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!yw({node:o,types:r})},apply:(a,i)=>{if(!a.docChanged||a.getMeta("__uniqueIDTransaction"))return i;const o=a.doc.lastChild;return!yw({node:o,types:r})}}})]}}),d$=Cn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>e3(t,e),redo:()=>({state:t,dispatch:e})=>t3(t,e)}},addProseMirrorPlugins(){return[r$(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()}}}),u$=Cn.create({name:"starterKit",addExtensions(){var t,e,n,r;const a=[];return this.options.bold!==!1&&a.push(L7.configure(this.options.bold)),this.options.blockquote!==!1&&a.push(A7.configure(this.options.blockquote)),this.options.bulletList!==!1&&a.push(FC.configure(this.options.bulletList)),this.options.code!==!1&&a.push(z7.configure(this.options.code)),this.options.codeBlock!==!1&&a.push(B7.configure(this.options.codeBlock)),this.options.document!==!1&&a.push(V7.configure(this.options.document)),this.options.dropcursor!==!1&&a.push(a$.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&a.push(i$.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&a.push(H7.configure(this.options.hardBreak)),this.options.heading!==!1&&a.push(U7.configure(this.options.heading)),this.options.undoRedo!==!1&&a.push(d$.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&a.push(W7.configure(this.options.horizontalRule)),this.options.italic!==!1&&a.push(Q7.configure(this.options.italic)),this.options.listItem!==!1&&a.push(BC.configure(this.options.listItem)),this.options.listKeymap!==!1&&a.push(qC.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&a.push(Nz.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&a.push(JC.configure(this.options.orderedList)),this.options.paragraph!==!1&&a.push(Lz.configure(this.options.paragraph)),this.options.strike!==!1&&a.push(zz.configure(this.options.strike)),this.options.text!==!1&&a.push($z.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(c$.configure((r=this.options)==null?void 0:r.trailingNode)),a}}),h$=u$,f$=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,p$=Pn.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",Vt(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 g_({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 y=i();y!==void 0&&this.editor.chain().setNodeSelection(y).updateAttributes(this.name,{width:m,height:x}).run()},onUpdate:(m,x,y)=>m.type===a.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),f=h.dom;return f.style.visibility="hidden",f.style.pointerEvents="none",u.onload=()=>{f.style.visibility="",f.style.pointerEvents=""},h}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[wC({find:f$,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),m$=p$;function x$(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:c}=t,u=r&&!a,h=b_(n),f=new RegExp(`\\s${h}$`),m=o?"^":"",x=a?"":h,y=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,j=Array.from(N.matchAll(y)).pop();if(!j||j.input===void 0||j.index===void 0)return null;const S=j.input.slice(Math.max(0,j.index-1),j.index),E=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(S);if(i!==null&&!E)return null;const T=w+j.index;let P=T+j[0].length;return u&&f.test(N.slice(P-1,P+1))&&(j[0]+=" ",P+=1),T=c.pos?{range:{from:T,to:P},query:j[0].slice(n.length),text:j[0]}:null}var g$=new pn("suggestion");function y$({pluginKey:t=g$,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:y=()=>({}),allow:N=()=>!0,findSuggestionMatch:w=x$,shouldShow:j}){let S;const E=y==null?void 0:y(),T=()=>{const z=e.state.selection.$anchor.pos,V=e.view.coordsAtPos(z),{top:I,right:te,bottom:Q,left:F}=V;try{return new DOMRect(F,I,te-F,Q-I)}catch{return null}},P=(z,V)=>V?()=>{const I=t.getState(e.state),te=I==null?void 0:I.decorationId,Q=z.dom.querySelector(`[data-decoration-id="${te}"]`);return(Q==null?void 0:Q.getBoundingClientRect())||null}:T;function O(z,V){var I;try{const Q=t.getState(z.state),F=Q!=null&&Q.decorationId?z.dom.querySelector(`[data-decoration-id="${Q.decorationId}"]`):null,re={editor:e,range:(Q==null?void 0:Q.range)||{from:0,to:0},query:(Q==null?void 0:Q.query)||null,text:(Q==null?void 0:Q.text)||null,items:[],command:ie=>m({editor:e,range:(Q==null?void 0:Q.range)||{from:0,to:0},props:ie}),decorationNode:F,clientRect:P(z,F)};(I=E==null?void 0:E.onExit)==null||I.call(E,re)}catch{}const te=z.state.tr.setMeta(V,{exit:!0});z.dispatch(te)}const q=new rn({key:t,view(){return{update:async(z,V)=>{var I,te,Q,F,re,ie,J;const $=(I=this.key)==null?void 0:I.getState(V),D=(te=this.key)==null?void 0:te.getState(z.state),R=$.active&&D.active&&$.range.from!==D.range.from,oe=!$.active&&D.active,G=$.active&&!D.active,_=!oe&&!G&&$.query!==D.query,U=oe||R&&_,H=_||R,K=G||R&&_;if(!U&&!H&&!K)return;const me=K&&!U?$:D,Y=z.dom.querySelector(`[data-decoration-id="${me.decorationId}"]`);S={editor:e,range:me.range,query:me.query,text:me.text,items:[],command:le=>m({editor:e,range:me.range,props:le}),decorationNode:Y,clientRect:P(z,Y)},U&&((Q=E==null?void 0:E.onBeforeStart)==null||Q.call(E,S)),H&&((F=E==null?void 0:E.onBeforeUpdate)==null||F.call(E,S)),(H||U)&&(S.items=await x({editor:e,query:me.query})),K&&((re=E==null?void 0:E.onExit)==null||re.call(E,S)),H&&((ie=E==null?void 0:E.onUpdate)==null||ie.call(E,S)),U&&((J=E==null?void 0:E.onStart)==null||J.call(E,S))},destroy:()=>{var z;S&&((z=E==null?void 0:E.onExit)==null||z.call(E,S))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(z,V,I,te){const{isEditable:Q}=e,{composing:F}=e.view,{selection:re}=z,{empty:ie,from:J}=re,$={...V},D=z.getMeta(t);if(D&&D.exit)return $.active=!1,$.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null,$;if($.composing=F,Q&&(ie||e.view.composing)){(JV.range.to)&&!F&&!V.composing&&($.active=!1);const R=w({char:n,allowSpaces:r,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:re.$from}),oe=`id_${Math.floor(Math.random()*4294967295)}`;R&&N({editor:e,state:te,range:R.range,isActive:V.active})&&(!j||j({editor:e,range:R.range,query:R.query,text:R.text,transaction:z}))?($.active=!0,$.decorationId=V.decorationId?V.decorationId:oe,$.range=R.range,$.query=R.query,$.text=R.text):$.active=!1}else $.active=!1;return $.active||($.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null),$}},props:{handleKeyDown(z,V){var I,te,Q,F;const{active:re,range:ie}=q.getState(z.state);if(!re)return!1;if(V.key==="Escape"||V.key==="Esc"){const $=q.getState(z.state),D=(I=S==null?void 0:S.decorationNode)!=null?I:null,R=D??($!=null&&$.decorationId?z.dom.querySelector(`[data-decoration-id="${$.decorationId}"]`):null);if(((te=E==null?void 0:E.onKeyDown)==null?void 0:te.call(E,{view:z,event:V,range:$.range}))||!1)return!0;const G={editor:e,range:$.range,query:$.query,text:$.text,items:[],command:_=>m({editor:e,range:$.range,props:_}),decorationNode:R,clientRect:R?()=>R.getBoundingClientRect()||null:null};return(Q=E==null?void 0:E.onExit)==null||Q.call(E,G),O(z,t),!0}return((F=E==null?void 0:E.onKeyDown)==null?void 0:F.call(E,{view:z,event:V,range:ie}))||!1},decorations(z){const{active:V,range:I,decorationId:te,query:Q}=q.getState(z);if(!V)return null;const F=!(Q!=null&&Q.length),re=[u];return F&&re.push(f),Xt.create(z.doc,[Kn.inline(I.from,I.to,{nodeName:c,class:re.join(" "),"data-decoration-id":te,"data-decoration-content":h})])}}});return q}function b$({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const a=new pn;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 n3(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>b$({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function bw(t,e){const n=n3(t),r=n.find(a=>a.char===e);return r||(n.length?n[0]:null)}var v$=Pn.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",Vt(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=bw(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",Vt({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=Vt({"data-type":this.name},this.options.HTMLAttributes,e);const a=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof a=="string"?["span",Vt({"data-type":this.name},this.options.HTMLAttributes,e),a]:a},...jC({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:bw(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 di,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 n3(this).map(y$)}}),N$=v$,w$=l$;let Qg,Yg;if(typeof WeakMap<"u"){let t=new WeakMap;Qg=e=>t.get(e),Yg=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Qg=r=>{for(let a=0;a(n==10&&(n=0),t[n++]=r,t[n++]=a)}var Sn=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:S-T});break}const P=a+T*e;for(let O=0;Or&&(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 S$(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 T$(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 Zr(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 wp(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)||E$(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function E$(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 Xg(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function M$(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Ny(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function s3(t,e,n){const r=t.node(-1),a=Sn.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 bl(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 r3(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 q2(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(Xg(r)&&Xg(a)&&Ny(r,a)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?ri.rowSelection(r,a):i&&this.isColSelection()?ri.colSelection(r,a):new ri(r,a)}return et.between(r,a)}content(){const e=this.$anchorCell.node(-1),n=Sn.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||j>0){let S=N.attrs;if(w>0&&(S=bl(S,0,w)),j>0&&(S=bl(S,S.colspan-j,j)),y.lefta.bottom){const S={...N.attrs,rowspan:Math.min(y.bottom,a.bottom)-Math.max(y.top,a.top)};y.top0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,a=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,a)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),a=Sn.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 ri&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),a=Sn.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(Kn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Xt.create(t.doc,e)}function P$({$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 O$({$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 L$(t,e,n){const r=(e||t).selection,a=(e||t).doc;let i,o;if(r instanceof Ze&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=sn.create(a,r.from);else if(o=="row"){const c=a.resolve(r.from+1);i=sn.rowSelection(c,c)}else if(!n){const c=Sn.get(r.node),u=r.from+1,h=u+c.map[c.width*c.height-1];i=sn.create(a,u+1,h)}}else r instanceof et&&P$(r)?i=et.create(a,r.from):r instanceof et&&O$(r)&&(i=et.create(a,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const D$=new pn("fix-tables");function i3(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=_$(t,a,i,n))};return e?e.doc!=t.doc&&i3(e.doc,t.doc,0,r):t.doc.descendants(r),n}function _$(t,e,n,r){const a=Sn.get(e);if(!a.problems)return r;r||(r=t.tr);const i=[];for(let u=0;u0){let y="cell";f.firstChild&&(y=f.firstChild.type.spec.tableRole);const N=[];for(let j=0;j0?-1:0;A$(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;V$(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=vw(h)?u+1:f;i.replaceWith(m+r.tableStart,f+r.tableStart,c)}i.setSelection(new sn(i.doc.resolve(u+r.tableStart))),e(i)}return!0}function ww(t,e){const n=js(t.schema);return G$(({node:r})=>n[r.type.spec.tableRole])(t,e)}function G$(t){return(e,n)=>{const r=e.selection;let a,i;if(r instanceof sn){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;a=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(a=T$(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=Ca(e),m=e.tr;for(let y=0;y{o.attrs[t]!==e&&i.setNodeMarkup(c,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(a.pos,null,{...a.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function Q$(t){return function(e,n){if(!Zr(e))return!1;if(n){const r=js(e.schema),a=Ca(e),i=e.tr,o=a.map.cellsInRect(t=="column"?{left:a.left,top:0,right:a.right,bottom:a.map.height}:t=="row"?{left:0,top:a.top,right:a.map.width,bottom:a.bottom}:a),c=o.map(u=>a.table.nodeAt(u));for(let u=0;u{const y=x+i.tableStart,N=o.doc.nodeAt(y);N&&o.setNodeMarkup(y,m,N.attrs)}),r(o)}return!0}}nu("row",{useDeprecatedLogic:!0});nu("column",{useDeprecatedLogic:!0});const Y$=nu("cell",{useDeprecatedLogic:!0});function X$(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 Ah(t,e){const n=t.selection;if(!(n instanceof sn))return!1;if(e){const r=t.tr,a=js(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 _e(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(Ne.empty),n[a]r&&(x=x.type.createChecked(bl(x.attrs,x.attrs.colspan,f+x.attrs.colspan-r),x.content)),h.push(x),f+=x.attrs.colspan;for(let y=1;ya&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,a-m.attrs.rowspan)},m.content)),u.push(m)}i.push(Ne.from(u))}n=i,e=a}return{width:t,height:e,rows:n}}function sF(t,e,n,r,a,i,o){const c=t.doc.type.schema,u=js(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(j?f||(f=u.header_cell.createAndFill()):h||(h=u.cell.createAndFill()))}const x=u.row.create(null,Ne.from(m)),y=[];for(let N=e.height;N{if(!a)return!1;const i=n.selection;if(i instanceof sn)return Vh(n,r,ot.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=d3(a,t,e);if(o==null)return!1;if(t=="horiz")return Vh(n,r,ot.near(n.doc.resolve(i.head+e),e));{const c=n.doc.resolve(o),u=s3(c,t,e);let h;return u?h=ot.near(u,1):e<0?h=ot.near(n.doc.resolve(c.before(-1)),-1):h=ot.near(n.doc.resolve(c.after(-1)),1),Vh(n,r,h)}}}function Rh(t,e){return(n,r,a)=>{if(!a)return!1;const i=n.selection;let o;if(i instanceof sn)o=i;else{const u=d3(a,t,e);if(u==null)return!1;o=new sn(n.doc.resolve(u))}const c=s3(o.$headCell,t,e);return c?Vh(n,r,new sn(o.$anchorCell,c)):!1}}function aF(t,e){const n=t.state.doc,r=yl(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new sn(r))),!0):!1}function iF(t,e,n){if(!Zr(t.state))return!1;let r=eF(n);const a=t.state.selection;if(a instanceof sn){r||(r={width:1,height:1,rows:[Ne.from(Zg(js(t.state.schema).cell,n))]});const i=a.$anchorCell.node(-1),o=a.$anchorCell.start(-1),c=Sn.get(i).rectBetween(a.$anchorCell.pos-o,a.$headCell.pos-o);return r=nF(r,c.right-c.left,c.bottom-c.top),Tw(t.state,t.dispatch,o,c,r),!0}else if(r){const i=wp(t.state),o=i.start(-1);return Tw(t.state,t.dispatch,o,Sn.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function oF(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=Ew(t,e.target);let a;if(e.shiftKey&&t.state.selection instanceof sn)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(a=yl(t.state.selection.$anchor))!=null&&((n=Jx(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=Jx(t,h);const m=eo.getState(t.state)==null;if(!f||!Ny(u,f))if(m)f=u;else return;const x=new sn(u,f);if(m||!t.state.selection.eq(x)){const y=t.state.tr.setSelection(x);m&&y.setMeta(eo,u.pos),t.dispatch(y)}}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(Ew(t,h.target)!=r&&(m=Jx(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 d3(t,e,n){if(!(t.state.selection instanceof et))return null;const{$head:r}=t.state.selection;for(let a=r.depth-1;a>=0;a--){const i=r.node(a);if((n<0?r.index(a):r.indexAfter(a))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=r.before(a),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?o:null}}return null}function Ew(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Jx(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 lF=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")),e0(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,e0(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function e0(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 dF(-1,!1)},apply(o,c){return c.apply(o)}},props:{attributes:o=>{const c=ir.getState(o);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,c)=>{uF(o,c,t,a)},mouseleave:o=>{hF(o)},mousedown:(o,c)=>{fF(o,c,e,n)}},decorations:o=>{const c=ir.getState(o);if(c&&c.activeHandle>-1)return yF(o,c.activeHandle)},nodeViews:{}}});return i}var dF=class Hh{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(ir);if(r&&r.setHandle!=null)return new Hh(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Hh(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let a=e.mapping.map(n.activeHandle,-1);return Xg(e.doc.resolve(a))||(a=-1),new Hh(a,n.dragging)}return n}};function uF(t,e,n,r){if(!t.editable)return;const a=ir.getState(t.state);if(a&&!a.dragging){const i=mF(e.target);let o=-1;if(i){const{left:c,right:u}=i.getBoundingClientRect();e.clientX-c<=n?o=Mw(t,e,"left",n):u-e.clientX<=n&&(o=Mw(t,e,"right",n))}if(o!=a.activeHandle){if(!r&&o!==-1){const c=t.state.doc.resolve(o),u=c.node(-1),h=Sn.get(u),f=c.start(-1);if(h.colCount(c.pos-f)+c.nodeAfter.attrs.colspan-1==h.width-1)return}u3(t,o)}}}function hF(t){if(!t.editable)return;const e=ir.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&u3(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=ir.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const c=t.state.doc.nodeAt(o.activeHandle),u=pF(t,o.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(ir,{setDragging:{startX:e.clientX,startWidth:u}}));function h(m){i.removeEventListener("mouseup",h),i.removeEventListener("mousemove",f);const x=ir.getState(t.state);x!=null&&x.dragging&&(xF(t,x.activeHandle,Aw(x.dragging,m,n)),t.dispatch(t.state.tr.setMeta(ir,{setDragging:null})))}function f(m){if(!m.which)return h(m);const x=ir.getState(t.state);if(x&&x.dragging){const y=Aw(x.dragging,m,n);Iw(t,x.activeHandle,y,r)}}return Iw(t,o.activeHandle,u,r),i.addEventListener("mouseup",h),i.addEventListener("mousemove",f),e.preventDefault(),!0}function pF(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",Vt(this.options.HTMLAttributes,t),0]}}),f3=Pn.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",Vt(this.options.HTMLAttributes,t),0]}}),p3=Pn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Vt(this.options.HTMLAttributes,t),0]}});function t0(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Rw(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,y=0;x{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function jF(t,e,n,r,a){const i=wF(t),o=[],c=[];for(let h=0;h{const{selection:e}=t.state;if(!kF(e))return!1;let n=0;const r=YS(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},SF="";function CF(t){return(t||"").replace(/\s+/g," ").trim()}function TF(t,e,n={}){var r;const a=(r=n.cellLineSeparator)!=null?r:SF;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(N=>{const w=[];N.content&&N.content.forEach(j=>{let S="";j.content&&Array.isArray(j.content)&&j.content.length>1?S=j.content.map(O=>e.renderChildren(O)).join(a):S=j.content?e.renderChildren(j.content):"";const E=CF(S),T=j.type==="tableHeader";w.push({text:E,isHeader:T})}),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 j=0;jc[j]&&(c[j]=E),c[j]<3&&(c[j]=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,j)=>u(N[j]&&N[j].text||"",c[j])).join(" | ")} | `}),m}var EF=TF,m3=Pn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:vF,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:a}=NF(t,this.options.cellMinWidth),i=e.style;function o(){return i||(r?`width: ${r}`:`min-width: ${a}`)}const c=["table",Vt(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},c]:c},parseMarkdown:(t,e)=>{const n=[];if(t.header){const r=[];t.header.forEach(a=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(a.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const a=[];r.forEach(i=>{a.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},a))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>EF(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:a,editor:i})=>{const o=jF(i.schema,t,e,n);if(a){const c=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(et.near(r.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>z$(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>$$(t,e),deleteColumn:()=>({state:t,dispatch:e})=>B$(t,e),addRowBefore:()=>({state:t,dispatch:e})=>H$(t,e),addRowAfter:()=>({state:t,dispatch:e})=>U$(t,e),deleteRow:()=>({state:t,dispatch:e})=>K$(t,e),deleteTable:()=>({state:t,dispatch:e})=>Z$(t,e),mergeCells:()=>({state:t,dispatch:e})=>Nw(t,e),splitCell:()=>({state:t,dispatch:e})=>ww(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>nu("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>nu("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>Y$(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Nw(t,e)?!0:ww(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>J$(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>kw(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>kw(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&o3(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=sn.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Ph,"Mod-Backspace":Ph,Delete:Ph,"Mod-Delete":Ph}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[cF({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],bF({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:Bt(Ye(t,"tableRole",e))}}});Cn.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(m3.configure(this.options.table)),this.options.tableCell!==!1&&t.push(h3.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(f3.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(p3.configure(this.options.tableRow)),t}});function MF(t){return t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}function AF(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'")}function IF(t){if(!t)return"";let e=t;return e=e.replace(/]*>(.*?)<\/h1>/gi,`# $1 @@ -843,15 +843,15 @@ ${y.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 RF=Pn.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 端全宽播放)"]]}}),PF=Pn.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",Vt(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 Lw(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}const OF=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)=>`
@${Lw(o.name)} ${Lw(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 LF(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=b.useRef(null),f=b.useRef(null),m=b.useRef(null),g=b.useRef(null),[y,N]=b.useState(""),[w,j]=b.useState(!1),S=b.useRef(Ow(t)),E=b.useCallback((Q,F)=>{var $;const re=g.current;if(!re||!n)return!1;const ae=LF(F);if(ae.length>0)return F.preventDefault(),(async()=>{for(const D of ae)try{const R=await n(D);R&&re.chain().focus().setImage({src:R}).run()}catch(R){console.error("粘贴图片上传失败",R)}})(),!0;const J=($=F.clipboardData)==null?void 0:$.getData("text/html");if(J&&/data:image\/[^;"']+;base64,/i.test(J)){F.preventDefault();const{from:D,to:R}=re.state.selection;return(async()=>{try{const oe=await zF(J,n);re.chain().focus().insertContentAt({from:D,to:R},oe).run()}catch(oe){console.error("粘贴 HTML 内 base64 转换失败",oe)}})(),!0}return!1},[n]),T=S7({extensions:[h$.configure({link:{openOnClick:!1,HTMLAttributes:{class:"rich-link"}}}),m$.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"rich-editor-img-thumb"}}),RF,N$.configure({HTMLAttributes:{class:"mention-tag"},suggestion:OF(a)}),PF,w$.configure({placeholder:o}),m3.configure({resizable:!0}),p3,h3,f3],content:S.current,onUpdate:({editor:Q})=>{e(Q.getHTML())},editorProps:{attributes:{class:"rich-editor-content"},handlePaste:E}});b.useEffect(()=>{g.current=T??null},[T]),b.useImperativeHandle(u,()=>({getHTML:()=>(T==null?void 0:T.getHTML())||"",getMarkdown:()=>IF((T==null?void 0:T.getHTML())||"")})),b.useEffect(()=>{if(T&&t!==T.getHTML()){const Q=Ow(t);Q!==T.getHTML()&&T.commands.setContent(Q)}},[t]);const P=b.useCallback(async Q=>{if(r)return r(Q);if(n)return n(Q);throw new Error("未配置上传")},[n,r]),O=b.useCallback(async Q=>{var re;const F=(re=Q.target.files)==null?void 0:re[0];if(!(!F||!T)){if(n){const ae=await n(F);ae&&T.chain().focus().setImage({src:ae}).run()}else{const ae=new FileReader;ae.onload=()=>{typeof ae.result=="string"&&T.chain().focus().setImage({src:ae.result}).run()},ae.readAsDataURL(F)}Q.target.value=""}},[T,n]),q=b.useCallback(async Q=>{var re;const F=(re=Q.target.files)==null?void 0:re[0];if(!(!F||!T)){try{const ae=await P(F);ae&&T.chain().focus().insertContent({type:"videoEmbed",attrs:{src:ae}}).run()}catch(ae){console.error(ae)}Q.target.value=""}},[T,P]),z=b.useCallback(async Q=>{var re;const F=(re=Q.target.files)==null?void 0:re[0];if(!(!F||!T)){try{const ae=await P(F);if(!ae)return;const J=F.name||"附件";T.chain().focus().insertContent(`

附件 ${MF(J)}

`).run()}catch(ae){console.error(ae)}Q.target.value=""}},[T,P]),V=b.useCallback(()=>{T&&T.chain().focus().insertContent("@").run()},[T]),I=b.useCallback(Q=>{T&&T.chain().focus().insertContent([{type:"linkTag",attrs:{label:Q.label,url:Q.url||"",tagType:Q.type||"url",tagId:Q.id||"",pagePath:Q.pagePath||"",appId:Q.appId||"",mpKey:Q.type==="miniprogram"&&Q.appId||""}},{type:"text",text:" "}]).run()},[T]),te=b.useCallback(()=>{!T||!y||(T.chain().focus().setLink({href:y}).run(),N(""),j(!1))},[T,y]);return T?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:()=>T.chain().focus().toggleBold().run(),className:T.isActive("bold")?"is-active":"",type:"button",children:s.jsx(n5,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().toggleItalic().run(),className:T.isActive("italic")?"is-active":"",type:"button",children:s.jsx(tM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().toggleStrike().run(),className:T.isActive("strike")?"is-active":"",type:"button",children:s.jsx(iA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().toggleCode().run(),className:T.isActive("code")?"is-active":"",type:"button",children:s.jsx(N5,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>T.chain().focus().toggleHeading({level:1}).run(),className:T.isActive("heading",{level:1})?"is-active":"",type:"button",children:s.jsx(W5,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().toggleHeading({level:2}).run(),className:T.isActive("heading",{level:2})?"is-active":"",type:"button",children:s.jsx(q5,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().toggleHeading({level:3}).run(),className:T.isActive("heading",{level:3})?"is-active":"",type:"button",children:s.jsx(J5,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>T.chain().focus().toggleBulletList().run(),className:T.isActive("bulletList")?"is-active":"",type:"button",children:s.jsx(hM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().toggleOrderedList().run(),className:T.isActive("orderedList")?"is-active":"",type:"button",children:s.jsx(dM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().toggleBlockquote().run(),className:T.isActive("blockquote")?"is-active":"",type:"button",children:s.jsx($M,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().setHorizontalRule().run(),type:"button",children:s.jsx(jM,{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:O,className:"hidden"}),s.jsx("input",{ref:f,type:"file",accept:"video/*",onChange:q,className:"hidden"}),s.jsx("input",{ref:m,type:"file",onChange:z,className:"hidden"}),s.jsx("button",{onClick:()=>{var Q;return(Q=h.current)==null?void 0:Q.click()},type:"button",title:"上传图片",children:s.jsx(Mj,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{var Q;return(Q=f.current)==null?void 0:Q.click()},type:"button",title:"上传视频",disabled:!r&&!n,children:s.jsx(NA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{var Q;return(Q=m.current)==null?void 0:Q.click()},type:"button",title:"上传附件(生成下载链接)",disabled:!r&&!n,children:s.jsx(EM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:V,type:"button",title:"插入 @ 并选择人物",className:a.length?"mention-trigger-btn":"",disabled:a.length===0,children:s.jsx(ZE,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>j(!w),className:T.isActive("link")?"is-active":"",type:"button",title:"链接",children:s.jsx(dx,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),type:"button",title:"表格",children:s.jsx(lA,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>T.chain().focus().undo().run(),disabled:!T.can().undo(),type:"button",children:s.jsx(mA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().redo().run(),disabled:!T.can().redo(),type:"button",children:s.jsx(BM,{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:Q=>{const F=i.find(re=>re.id===Q.target.value);F&&I(F),Q.target.value=""},defaultValue:"",children:[s.jsx("option",{value:"",disabled:!0,children:"# 插入链接标签"}),i.map(Q=>s.jsx("option",{value:Q.id,children:Q.label},Q.id))]})})]})]}),w&&s.jsxs("div",{className:"link-input-bar",children:[s.jsx("input",{type:"url",placeholder:"输入链接地址...",value:y,onChange:Q=>N(Q.target.value),onKeyDown:Q=>Q.key==="Enter"&&te(),className:"link-input"}),s.jsx("button",{onClick:te,className:"link-confirm",type:"button",children:"确定"}),s.jsx("button",{onClick:()=>{T.chain().focus().unsetLink().run(),j(!1)},className:"link-remove",type:"button",children:"移除"})]}),s.jsx(CC,{editor:T})]}):null});n0.displayName="RichEditor";const $F=["top","right","bottom","left"],xo=Math.min,rr=Math.max,Kf=Math.round,Oh=Math.floor,Na=t=>({x:t,y:t}),FF={left:"right",right:"left",bottom:"top",top:"bottom"},BF={start:"end",end:"start"};function s0(t,e,n){return rr(t,xo(e,n))}function mi(t,e){return typeof t=="function"?t(e):t}function gi(t){return t.split("-")[0]}function zc(t){return t.split("-")[1]}function wy(t){return t==="x"?"y":"x"}function jy(t){return t==="y"?"height":"width"}const VF=new Set(["top","bottom"]);function ba(t){return VF.has(gi(t))?"y":"x"}function ky(t){return wy(ba(t))}function HF(t,e,n){n===void 0&&(n=!1);const r=zc(t),a=ky(t),i=jy(a);let o=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=qf(o)),[o,qf(o)]}function UF(t){const e=qf(t);return[r0(t),e,r0(e)]}function r0(t){return t.replace(/start|end/g,e=>BF[e])}const Dw=["left","right"],_w=["right","left"],WF=["top","bottom"],KF=["bottom","top"];function qF(t,e,n){switch(t){case"top":case"bottom":return n?e?_w:Dw:e?Dw:_w;case"left":case"right":return e?WF:KF;default:return[]}}function GF(t,e,n,r){const a=zc(t);let i=qF(gi(t),n==="start",r);return a&&(i=i.map(o=>o+"-"+a),e&&(i=i.concat(i.map(r0)))),i}function qf(t){return t.replace(/left|right|bottom|top/g,e=>FF[e])}function JF(t){return{top:0,right:0,bottom:0,left:0,...t}}function g3(t){return typeof t!="number"?JF(t):{top:t,right:t,bottom:t,left:t}}function Gf(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 zw(t,e,n){let{reference:r,floating:a}=t;const i=ba(e),o=ky(e),c=jy(o),u=gi(e),h=i==="y",f=r.x+r.width/2-a.width/2,m=r.y+r.height/2-a.height/2,g=r[c]/2-a[c]/2;let y;switch(u){case"top":y={x:f,y:r.y-a.height};break;case"bottom":y={x:f,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:m};break;case"left":y={x:r.x-a.width,y:m};break;default:y={x:r.x,y:r.y}}switch(zc(e)){case"start":y[o]-=g*(n&&h?-1:1);break;case"end":y[o]+=g*(n&&h?-1:1);break}return y}async function QF(t,e){var n;e===void 0&&(e={});const{x:r,y:a,platform:i,rects:o,elements:c,strategy:u}=t,{boundary:h="clippingAncestors",rootBoundary:f="viewport",elementContext:m="floating",altBoundary:g=!1,padding:y=0}=mi(e,t),N=g3(y),j=c[g?m==="floating"?"reference":"floating":m],S=Gf(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(j)))==null||n?j:j.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:h,rootBoundary:f,strategy:u})),E=m==="floating"?{x:r,y:a,width:o.floating.width,height:o.floating.height}:o.reference,T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),P=await(i.isElement==null?void 0:i.isElement(T))?await(i.getScale==null?void 0:i.getScale(T))||{x:1,y:1}:{x:1,y:1},O=Gf(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:E,offsetParent:T,strategy:u}):E);return{top:(S.top-O.top+N.top)/P.y,bottom:(O.bottom-S.bottom+N.bottom)/P.y,left:(S.left-O.left+N.left)/P.x,right:(O.right-S.right+N.right)/P.x}}const YF=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}=zw(h,r,u),g=r,y={},N=0;for(let j=0;j({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:a,rects:i,platform:o,elements:c,middlewareData:u}=e,{element:h,padding:f=0}=mi(t,e)||{};if(h==null)return{};const m=g3(f),g={x:n,y:r},y=ky(a),N=jy(y),w=await o.getDimensions(h),j=y==="y",S=j?"top":"left",E=j?"bottom":"right",T=j?"clientHeight":"clientWidth",P=i.reference[N]+i.reference[y]-g[y]-i.floating[N],O=g[y]-i.reference[y],q=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let z=q?q[T]:0;(!z||!await(o.isElement==null?void 0:o.isElement(q)))&&(z=c.floating[T]||i.floating[N]);const V=P/2-O/2,I=z/2-w[N]/2-1,te=xo(m[S],I),Q=xo(m[E],I),F=te,re=z-w[N]-Q,ae=z/2-w[N]/2+V,J=s0(F,ae,re),$=!u.arrow&&zc(a)!=null&&ae!==J&&i.reference[N]/2-(aeae<=0)){var Q,F;const ae=(((Q=i.flip)==null?void 0:Q.index)||0)+1,J=z[ae];if(J&&(!(m==="alignment"?E!==ba(J):!1)||te.every(R=>ba(R.placement)===E?R.overflows[0]>0:!0)))return{data:{index:ae,overflows:te},reset:{placement:J}};let $=(F=te.filter(D=>D.overflows[0]<=0).sort((D,R)=>D.overflows[1]-R.overflows[1])[0])==null?void 0:F.placement;if(!$)switch(y){case"bestFit":{var re;const D=(re=te.filter(R=>{if(q){const oe=ba(R.placement);return oe===E||oe==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(oe=>oe>0).reduce((oe,G)=>oe+G,0)]).sort((R,oe)=>R[1]-oe[1])[0])==null?void 0:re[0];D&&($=D);break}case"initialPlacement":$=c;break}if(a!==$)return{reset:{placement:$}}}return{}}}};function $w(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Fw(t){return $F.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}=mi(t,e);switch(a){case"referenceHidden":{const o=await r.detectOverflow(e,{...i,elementContext:"reference"}),c=$w(o,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:Fw(c)}}}case"escaped":{const o=await r.detectOverflow(e,{...i,altBoundary:!0}),c=$w(o,n.floating);return{data:{escapedOffsets:c,escaped:Fw(c)}}}default:return{}}}}},x3=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=gi(n),c=zc(n),u=ba(n)==="y",h=x3.has(o)?-1:1,f=i&&u?-1:1,m=mi(e,t);let{mainAxis:g,crossAxis:y,alignmentAxis:N}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof N=="number"&&(y=c==="end"?N*-1:N),u?{x:y*f,y:g*h}:{x:g*h,y:y*f}}const nB=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}}}}},sB=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:S=>{let{x:E,y:T}=S;return{x:E,y:T}}},...h}=mi(t,e),f={x:n,y:r},m=await i.detectOverflow(e,h),g=ba(gi(a)),y=wy(g);let N=f[y],w=f[g];if(o){const S=y==="y"?"top":"left",E=y==="y"?"bottom":"right",T=N+m[S],P=N-m[E];N=s0(T,N,P)}if(c){const S=g==="y"?"top":"left",E=g==="y"?"bottom":"right",T=w+m[S],P=w-m[E];w=s0(T,w,P)}const j=u.fn({...e,[y]:N,[g]:w});return{...j,data:{x:j.x-n,y:j.y-r,enabled:{[y]:o,[g]:c}}}}}},rB=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:a,rects:i,middlewareData:o}=e,{offset:c=0,mainAxis:u=!0,crossAxis:h=!0}=mi(t,e),f={x:n,y:r},m=ba(a),g=wy(m);let y=f[g],N=f[m];const w=mi(c,e),j=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(u){const T=g==="y"?"height":"width",P=i.reference[g]-i.floating[T]+j.mainAxis,O=i.reference[g]+i.reference[T]-j.mainAxis;yO&&(y=O)}if(h){var S,E;const T=g==="y"?"width":"height",P=x3.has(gi(a)),O=i.reference[m]-i.floating[T]+(P&&((S=o.offset)==null?void 0:S[m])||0)+(P?0:j.crossAxis),q=i.reference[m]+i.reference[T]+(P?0:((E=o.offset)==null?void 0:E[m])||0)-(P?j.crossAxis:0);Nq&&(N=q)}return{[g]:y,[m]:N}}}},aB=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:a,rects:i,platform:o,elements:c}=e,{apply:u=()=>{},...h}=mi(t,e),f=await o.detectOverflow(e,h),m=gi(a),g=zc(a),y=ba(a)==="y",{width:N,height:w}=i.floating;let j,S;m==="top"||m==="bottom"?(j=m,S=g===(await(o.isRTL==null?void 0:o.isRTL(c.floating))?"start":"end")?"left":"right"):(S=m,j=g==="end"?"top":"bottom");const E=w-f.top-f.bottom,T=N-f.left-f.right,P=xo(w-f[j],E),O=xo(N-f[S],T),q=!e.middlewareData.shift;let z=P,V=O;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(V=T),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(z=E),q&&!g){const te=rr(f.left,0),Q=rr(f.right,0),F=rr(f.top,0),re=rr(f.bottom,0);y?V=N-2*(te!==0||Q!==0?te+Q:rr(f.left,f.right)):z=w-2*(F!==0||re!==0?F+re:rr(f.top,f.bottom))}await u({...e,availableWidth:V,availableHeight:z});const I=await o.getDimensions(c.floating);return N!==I.width||w!==I.height?{reset:{rects:!0}}:{}}}};function jp(){return typeof window<"u"}function $c(t){return y3(t)?(t.nodeName||"").toLowerCase():"#document"}function lr(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Ta(t){var e;return(e=(y3(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function y3(t){return jp()?t instanceof Node||t instanceof lr(t).Node:!1}function Qr(t){return jp()?t instanceof Element||t instanceof lr(t).Element:!1}function ka(t){return jp()?t instanceof HTMLElement||t instanceof lr(t).HTMLElement:!1}function Bw(t){return!jp()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof lr(t).ShadowRoot}const iB=new Set(["inline","contents"]);function fu(t){const{overflow:e,overflowX:n,overflowY:r,display:a}=Yr(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!iB.has(a)}const oB=new Set(["table","td","th"]);function lB(t){return oB.has($c(t))}const cB=[":popover-open",":modal"];function kp(t){return cB.some(e=>{try{return t.matches(e)}catch{return!1}})}const dB=["transform","translate","scale","rotate","perspective"],uB=["transform","translate","scale","rotate","perspective","filter"],hB=["paint","layout","strict","content"];function Sy(t){const e=Cy(),n=Qr(t)?Yr(t):t;return dB.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)||uB.some(r=>(n.willChange||"").includes(r))||hB.some(r=>(n.contain||"").includes(r))}function fB(t){let e=yo(t);for(;ka(e)&&!Ic(e);){if(Sy(e))return e;if(kp(e))return null;e=yo(e)}return null}function Cy(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const pB=new Set(["html","body","#document"]);function Ic(t){return pB.has($c(t))}function Yr(t){return lr(t).getComputedStyle(t)}function Sp(t){return Qr(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function yo(t){if($c(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Bw(t)&&t.host||Ta(t);return Bw(e)?e.host:e}function b3(t){const e=yo(t);return Ic(e)?t.ownerDocument?t.ownerDocument.body:t.body:ka(e)&&fu(e)?e:b3(e)}function su(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const a=b3(t),i=a===((r=t.ownerDocument)==null?void 0:r.body),o=lr(a);if(i){const c=a0(o);return e.concat(o,o.visualViewport||[],fu(a)?a:[],c&&n?su(c):[])}return e.concat(a,su(a,[],n))}function a0(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function v3(t){const e=Yr(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const a=ka(t),i=a?t.offsetWidth:n,o=a?t.offsetHeight:r,c=Kf(n)!==i||Kf(r)!==o;return c&&(n=i,r=o),{width:n,height:r,$:c}}function Ty(t){return Qr(t)?t:t.contextElement}function yc(t){const e=Ty(t);if(!ka(e))return Na(1);const n=e.getBoundingClientRect(),{width:r,height:a,$:i}=v3(e);let o=(i?Kf(n.width):n.width)/r,c=(i?Kf(n.height):n.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!c||!Number.isFinite(c))&&(c=1),{x:o,y:c}}const mB=Na(0);function N3(t){const e=lr(t);return!Cy()||!e.visualViewport?mB:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function gB(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==lr(t)?!1:e}function vl(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),i=Ty(t);let o=Na(1);e&&(r?Qr(r)&&(o=yc(r)):o=yc(t));const c=gB(i,n,r)?N3(i):Na(0);let u=(a.left+c.x)/o.x,h=(a.top+c.y)/o.y,f=a.width/o.x,m=a.height/o.y;if(i){const g=lr(i),y=r&&Qr(r)?lr(r):r;let N=g,w=a0(N);for(;w&&r&&y!==N;){const j=yc(w),S=w.getBoundingClientRect(),E=Yr(w),T=S.left+(w.clientLeft+parseFloat(E.paddingLeft))*j.x,P=S.top+(w.clientTop+parseFloat(E.paddingTop))*j.y;u*=j.x,h*=j.y,f*=j.x,m*=j.y,u+=T,h+=P,N=lr(w),w=a0(N)}}return Gf({width:f,height:m,x:u,y:h})}function Cp(t,e){const n=Sp(t).scrollLeft;return e?e.left+n:vl(Ta(t)).left+n}function w3(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Cp(t,n),a=n.top+e.scrollTop;return{x:r,y:a}}function xB(t){let{elements:e,rect:n,offsetParent:r,strategy:a}=t;const i=a==="fixed",o=Ta(r),c=e?kp(e.floating):!1;if(r===o||c&&i)return n;let u={scrollLeft:0,scrollTop:0},h=Na(1);const f=Na(0),m=ka(r);if((m||!m&&!i)&&(($c(r)!=="body"||fu(o))&&(u=Sp(r)),ka(r))){const y=vl(r);h=yc(r),f.x=y.x+r.clientLeft,f.y=y.y+r.clientTop}const g=o&&!m&&!i?w3(o,u):Na(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-u.scrollLeft*h.x+f.x+g.x,y:n.y*h.y-u.scrollTop*h.y+f.y+g.y}}function yB(t){return Array.from(t.getClientRects())}function bB(t){const e=Ta(t),n=Sp(t),r=t.ownerDocument.body,a=rr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=rr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Cp(t);const c=-n.scrollTop;return Yr(r).direction==="rtl"&&(o+=rr(e.clientWidth,r.clientWidth)-a),{width:a,height:i,x:o,y:c}}const Vw=25;function vB(t,e){const n=lr(t),r=Ta(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=Cy();(!f||f&&e==="fixed")&&(c=a.offsetLeft,u=a.offsetTop)}const h=Cp(r);if(h<=0){const f=r.ownerDocument,m=f.body,g=getComputedStyle(m),y=f.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,N=Math.abs(r.clientWidth-m.clientWidth-y);N<=Vw&&(i-=N)}else h<=Vw&&(i+=h);return{width:i,height:o,x:c,y:u}}const NB=new Set(["absolute","fixed"]);function wB(t,e){const n=vl(t,!0,e==="fixed"),r=n.top+t.clientTop,a=n.left+t.clientLeft,i=ka(t)?yc(t):Na(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 Hw(t,e,n){let r;if(e==="viewport")r=vB(t,n);else if(e==="document")r=bB(Ta(t));else if(Qr(e))r=wB(e,n);else{const a=N3(t);r={x:e.x-a.x,y:e.y-a.y,width:e.width,height:e.height}}return Gf(r)}function j3(t,e){const n=yo(t);return n===e||!Qr(n)||Ic(n)?!1:Yr(n).position==="fixed"||j3(n,e)}function jB(t,e){const n=e.get(t);if(n)return n;let r=su(t,[],!1).filter(c=>Qr(c)&&$c(c)!=="body"),a=null;const i=Yr(t).position==="fixed";let o=i?yo(t):t;for(;Qr(o)&&!Ic(o);){const c=Yr(o),u=Sy(o);!u&&c.position==="fixed"&&(a=null),(i?!u&&!a:!u&&c.position==="static"&&!!a&&NB.has(a.position)||fu(o)&&!u&&j3(t,o))?r=r.filter(f=>f!==o):a=c,o=yo(o)}return e.set(t,r),r}function kB(t){let{element:e,boundary:n,rootBoundary:r,strategy:a}=t;const o=[...n==="clippingAncestors"?kp(e)?[]:jB(e,this._c):[].concat(n),r],c=o[0],u=o.reduce((h,f)=>{const m=Hw(e,f,a);return h.top=rr(m.top,h.top),h.right=xo(m.right,h.right),h.bottom=xo(m.bottom,h.bottom),h.left=rr(m.left,h.left),h},Hw(e,c,a));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function SB(t){const{width:e,height:n}=v3(t);return{width:e,height:n}}function CB(t,e,n){const r=ka(e),a=Ta(e),i=n==="fixed",o=vl(t,!0,i,e);let c={scrollLeft:0,scrollTop:0};const u=Na(0);function h(){u.x=Cp(a)}if(r||!r&&!i)if(($c(e)!=="body"||fu(a))&&(c=Sp(e)),r){const y=vl(e,!0,i,e);u.x=y.x+e.clientLeft,u.y=y.y+e.clientTop}else a&&h();i&&!r&&a&&h();const f=a&&!r&&!i?w3(a,c):Na(0),m=o.left+c.scrollLeft-u.x-f.x,g=o.top+c.scrollTop-u.y-f.y;return{x:m,y:g,width:o.width,height:o.height}}function Qg(t){return Yr(t).position==="static"}function Uw(t,e){if(!ka(t)||Yr(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Ta(t)===n&&(n=n.ownerDocument.body),n}function k3(t,e){const n=lr(t);if(kp(t))return n;if(!ka(t)){let a=yo(t);for(;a&&!Ic(a);){if(Qr(a)&&!Qg(a))return a;a=yo(a)}return n}let r=Uw(t,e);for(;r&&lB(r)&&Qg(r);)r=Uw(r,e);return r&&Ic(r)&&Qg(r)&&!Sy(r)?n:r||fB(t)||n}const TB=async function(t){const e=this.getOffsetParent||k3,n=this.getDimensions,r=await n(t.floating);return{reference:CB(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function EB(t){return Yr(t).direction==="rtl"}const MB={convertOffsetParentRelativeRectToViewportRelativeRect:xB,getDocumentElement:Ta,getClippingRect:kB,getOffsetParent:k3,getElementRects:TB,getClientRects:yB,getDimensions:SB,getScale:yc,isElement:Qr,isRTL:EB};function S3(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function AB(t,e){let n=null,r;const a=Ta(t);function i(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function o(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),i();const h=t.getBoundingClientRect(),{left:f,top:m,width:g,height:y}=h;if(c||e(),!g||!y)return;const N=Oh(m),w=Oh(a.clientWidth-(f+g)),j=Oh(a.clientHeight-(m+y)),S=Oh(f),T={rootMargin:-N+"px "+-w+"px "+-j+"px "+-S+"px",threshold:rr(0,xo(1,u))||1};let P=!0;function O(q){const z=q[0].intersectionRatio;if(z!==u){if(!P)return o();z?o(!1,z):r=setTimeout(()=>{o(!1,1e-7)},1e3)}z===1&&!S3(h,t.getBoundingClientRect())&&o(),P=!1}try{n=new IntersectionObserver(O,{...T,root:a.ownerDocument})}catch{n=new IntersectionObserver(O,T)}n.observe(t)}return o(!0),i}function IB(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=Ty(t),f=a||i?[...h?su(h):[],...su(e)]:[];f.forEach(S=>{a&&S.addEventListener("scroll",n,{passive:!0}),i&&S.addEventListener("resize",n)});const m=h&&c?AB(h,n):null;let g=-1,y=null;o&&(y=new ResizeObserver(S=>{let[E]=S;E&&E.target===h&&y&&(y.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var T;(T=y)==null||T.observe(e)})),n()}),h&&!u&&y.observe(h),y.observe(e));let N,w=u?vl(t):null;u&&j();function j(){const S=vl(t);w&&!S3(w,S)&&n(),w=S,N=requestAnimationFrame(j)}return n(),()=>{var S;f.forEach(E=>{a&&E.removeEventListener("scroll",n),i&&E.removeEventListener("resize",n)}),m==null||m(),(S=y)==null||S.disconnect(),y=null,u&&cancelAnimationFrame(N)}}const RB=nB,PB=sB,OB=ZF,LB=aB,DB=eB,Ww=XF,_B=rB,zB=(t,e,n)=>{const r=new Map,a={platform:MB,...n},i={...a.platform,_c:r};return YF(t,e,{...a,platform:i})};var $B=typeof document<"u",FB=function(){},Uh=$B?b.useLayoutEffect:FB;function Jf(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(!Jf(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)&&!Jf(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function C3(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Kw(t,e){const n=C3(t);return Math.round(e*n)/n}function Yg(t){const e=b.useRef(t);return Uh(()=>{e.current=t}),e}function BB(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:a,elements:{reference:i,floating:o}={},transform:c=!0,whileElementsMounted:u,open:h}=t,[f,m]=b.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[g,y]=b.useState(r);Jf(g,r)||y(r);const[N,w]=b.useState(null),[j,S]=b.useState(null),E=b.useCallback(R=>{R!==q.current&&(q.current=R,w(R))},[]),T=b.useCallback(R=>{R!==z.current&&(z.current=R,S(R))},[]),P=i||N,O=o||j,q=b.useRef(null),z=b.useRef(null),V=b.useRef(f),I=u!=null,te=Yg(u),Q=Yg(a),F=Yg(h),re=b.useCallback(()=>{if(!q.current||!z.current)return;const R={placement:e,strategy:n,middleware:g};Q.current&&(R.platform=Q.current),zB(q.current,z.current,R).then(oe=>{const G={...oe,isPositioned:F.current!==!1};ae.current&&!Jf(V.current,G)&&(V.current=G,au.flushSync(()=>{m(G)}))})},[g,e,n,Q,F]);Uh(()=>{h===!1&&V.current.isPositioned&&(V.current.isPositioned=!1,m(R=>({...R,isPositioned:!1})))},[h]);const ae=b.useRef(!1);Uh(()=>(ae.current=!0,()=>{ae.current=!1}),[]),Uh(()=>{if(P&&(q.current=P),O&&(z.current=O),P&&O){if(te.current)return te.current(P,O,re);re()}},[P,O,re,te,I]);const J=b.useMemo(()=>({reference:q,floating:z,setReference:E,setFloating:T}),[E,T]),$=b.useMemo(()=>({reference:P,floating:O}),[P,O]),D=b.useMemo(()=>{const R={position:n,left:0,top:0};if(!$.floating)return R;const oe=Kw($.floating,f.x),G=Kw($.floating,f.y);return c?{...R,transform:"translate("+oe+"px, "+G+"px)",...C3($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:oe,top:G}},[n,c,$.floating,f.x,f.y]);return b.useMemo(()=>({...f,update:re,refs:J,elements:$,floatingStyles:D}),[f,re,J,$,D])}const VB=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?Ww({element:r.current,padding:a}).fn(n):{}:r?Ww({element:r,padding:a}).fn(n):{}}}},HB=(t,e)=>({...RB(t),options:[t,e]}),UB=(t,e)=>({...PB(t),options:[t,e]}),WB=(t,e)=>({..._B(t),options:[t,e]}),KB=(t,e)=>({...OB(t),options:[t,e]}),qB=(t,e)=>({...LB(t),options:[t,e]}),GB=(t,e)=>({...DB(t),options:[t,e]}),JB=(t,e)=>({...VB(t),options:[t,e]});var QB="Arrow",T3=b.forwardRef((t,e)=>{const{children:n,width:r=10,height:a=5,...i}=t;return s.jsx(bt.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"})})});T3.displayName=QB;var YB=T3,Ey="Popper",[E3,M3]=No(Ey),[XB,A3]=E3(Ey),I3=t=>{const{__scopePopper:e,children:n}=t,[r,a]=b.useState(null);return s.jsx(XB,{scope:e,anchor:r,onAnchorChange:a,children:n})};I3.displayName=Ey;var R3="PopperAnchor",P3=b.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...a}=t,i=A3(R3,n),o=b.useRef(null),c=Ht(e,o),u=b.useRef(null);return b.useEffect(()=>{const h=u.current;u.current=(r==null?void 0:r.current)||o.current,h!==u.current&&i.onAnchorChange(u.current)}),r?null:s.jsx(bt.div,{...a,ref:c})});P3.displayName=R3;var My="PopperContent",[ZB,e9]=E3(My),O3=b.forwardRef((t,e)=>{var le,ce,ve,ye,ke,ze;const{__scopePopper:n,side:r="bottom",sideOffset:a=0,align:i="center",alignOffset:o=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:h=[],collisionPadding:f=0,sticky:m="partial",hideWhenDetached:g=!1,updatePositionStrategy:y="optimized",onPlaced:N,...w}=t,j=A3(My,n),[S,E]=b.useState(null),T=Ht(e,ht=>E(ht)),[P,O]=b.useState(null),q=A0(P),z=(q==null?void 0:q.width)??0,V=(q==null?void 0:q.height)??0,I=r+(i!=="center"?"-"+i:""),te=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},Q=Array.isArray(h)?h:[h],F=Q.length>0,re={padding:te,boundary:Q.filter(n9),altBoundary:F},{refs:ae,floatingStyles:J,placement:$,isPositioned:D,middlewareData:R}=BB({strategy:"fixed",placement:I,whileElementsMounted:(...ht)=>IB(...ht,{animationFrame:y==="always"}),elements:{reference:j.anchor},middleware:[HB({mainAxis:a+V,alignmentAxis:o}),u&&UB({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?WB():void 0,...re}),u&&KB({...re}),qB({...re,apply:({elements:ht,rects:wt,availableWidth:dt,availableHeight:Rt})=>{const{width:Tt,height:Tn}=wt.reference,mn=ht.floating.style;mn.setProperty("--radix-popper-available-width",`${dt}px`),mn.setProperty("--radix-popper-available-height",`${Rt}px`),mn.setProperty("--radix-popper-anchor-width",`${Tt}px`),mn.setProperty("--radix-popper-anchor-height",`${Tn}px`)}}),P&&JB({element:P,padding:c}),s9({arrowWidth:z,arrowHeight:V}),g&&GB({strategy:"referenceHidden",...re})]}),[oe,G]=_3($),_=po(N);Ns(()=>{D&&(_==null||_())},[D,_]);const U=(le=R.arrow)==null?void 0:le.x,H=(ce=R.arrow)==null?void 0:ce.y,K=((ve=R.arrow)==null?void 0:ve.centerOffset)!==0,[me,Y]=b.useState();return Ns(()=>{S&&Y(window.getComputedStyle(S).zIndex)},[S]),s.jsx("div",{ref:ae.setFloating,"data-radix-popper-content-wrapper":"",style:{...J,transform:D?J.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:me,"--radix-popper-transform-origin":[(ye=R.transformOrigin)==null?void 0:ye.x,(ke=R.transformOrigin)==null?void 0:ke.y].join(" "),...((ze=R.hide)==null?void 0:ze.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(ZB,{scope:n,placedSide:oe,onArrowChange:O,arrowX:U,arrowY:H,shouldHideArrow:K,children:s.jsx(bt.div,{"data-side":oe,"data-align":G,...w,ref:T,style:{...w.style,animation:D?void 0:"none"}})})})});O3.displayName=My;var L3="PopperArrow",t9={top:"bottom",right:"left",bottom:"top",left:"right"},D3=b.forwardRef(function(e,n){const{__scopePopper:r,...a}=e,i=e9(L3,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(YB,{...a,ref:n,style:{...a.style,display:"block"}})})});D3.displayName=L3;function n9(t){return t!==null}var s9=t=>({name:"transformOrigin",options:t,fn(e){var j,S,E;const{placement:n,rects:r,middlewareData:a}=e,o=((j=a.arrow)==null?void 0:j.centerOffset)!==0,c=o?0:t.arrowWidth,u=o?0:t.arrowHeight,[h,f]=_3(n),m={start:"0%",center:"50%",end:"100%"}[f],g=(((S=a.arrow)==null?void 0:S.x)??0)+c/2,y=(((E=a.arrow)==null?void 0:E.y)??0)+u/2;let N="",w="";return h==="bottom"?(N=o?m:`${g}px`,w=`${-u}px`):h==="top"?(N=o?m:`${g}px`,w=`${r.floating.height+u}px`):h==="right"?(N=`${-u}px`,w=o?m:`${y}px`):h==="left"&&(N=`${r.floating.width+u}px`,w=o?m:`${y}px`),{data:{x:N,y:w}}}});function _3(t){const[e,n="center"]=t.split("-");return[e,n]}var r9=I3,a9=P3,i9=O3,o9=D3,z3=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"}),l9="VisuallyHidden",c9=b.forwardRef((t,e)=>s.jsx(bt.span,{...t,ref:e,style:{...z3,...t.style}}));c9.displayName=l9;var d9=[" ","Enter","ArrowUp","ArrowDown"],u9=[" ","Enter"],Nl="Select",[Tp,Ep,h9]=T0(Nl),[Fc]=No(Nl,[h9,M3]),Mp=M3(),[f9,So]=Fc(Nl),[p9,m9]=Fc(Nl),$3=t=>{const{__scopeSelect:e,children:n,open:r,defaultOpen:a,onOpenChange:i,value:o,defaultValue:c,onValueChange:u,dir:h,name:f,autoComplete:m,disabled:g,required:y,form:N}=t,w=Mp(e),[j,S]=b.useState(null),[E,T]=b.useState(null),[P,O]=b.useState(!1),q=sp(h),[z,V]=cl({prop:r,defaultProp:a??!1,onChange:i,caller:Nl}),[I,te]=cl({prop:o,defaultProp:c,onChange:u,caller:Nl}),Q=b.useRef(null),F=j?N||!!j.closest("form"):!0,[re,ae]=b.useState(new Set),J=Array.from(re).map($=>$.props.value).join(";");return s.jsx(r9,{...w,children:s.jsxs(f9,{required:y,scope:e,trigger:j,onTriggerChange:S,valueNode:E,onValueNodeChange:T,valueNodeHasChildren:P,onValueNodeHasChildrenChange:O,contentId:oo(),value:I,onValueChange:te,open:z,onOpenChange:V,dir:q,triggerPointerDownPosRef:Q,disabled:g,children:[s.jsx(Tp.Provider,{scope:e,children:s.jsx(p9,{scope:t.__scopeSelect,onNativeOptionAdd:b.useCallback($=>{ae(D=>new Set(D).add($))},[]),onNativeOptionRemove:b.useCallback($=>{ae(D=>{const R=new Set(D);return R.delete($),R})},[]),children:n})}),F?s.jsxs(o4,{"aria-hidden":!0,required:y,tabIndex:-1,name:f,autoComplete:m,value:I,onChange:$=>te($.target.value),disabled:g,form:N,children:[I===void 0?s.jsx("option",{value:""}):null,Array.from(re)]},J):null]})})};$3.displayName=Nl;var F3="SelectTrigger",B3=b.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...a}=t,i=Mp(n),o=So(F3,n),c=o.disabled||r,u=Ht(e,o.onTriggerChange),h=Ep(n),f=b.useRef("touch"),[m,g,y]=c4(w=>{const j=h().filter(T=>!T.disabled),S=j.find(T=>T.value===o.value),E=d4(j,w,S);E!==void 0&&o.onValueChange(E.value)}),N=w=>{c||(o.onOpenChange(!0),y()),w&&(o.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return s.jsx(a9,{asChild:!0,...i,children:s.jsx(bt.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":l4(o.value)?"":void 0,...a,ref:u,onClick:mt(a.onClick,w=>{w.currentTarget.focus(),f.current!=="mouse"&&N(w)}),onPointerDown:mt(a.onPointerDown,w=>{f.current=w.pointerType;const j=w.target;j.hasPointerCapture(w.pointerId)&&j.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(N(w),w.preventDefault())}),onKeyDown:mt(a.onKeyDown,w=>{const j=m.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&g(w.key),!(j&&w.key===" ")&&d9.includes(w.key)&&(N(),w.preventDefault())})})})});B3.displayName=F3;var V3="SelectValue",H3=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:a,children:i,placeholder:o="",...c}=t,u=So(V3,n),{onValueNodeHasChildrenChange:h}=u,f=i!==void 0,m=Ht(e,u.onValueNodeChange);return Ns(()=>{h(f)},[h,f]),s.jsx(bt.span,{...c,ref:m,style:{pointerEvents:"none"},children:l4(u.value)?s.jsx(s.Fragment,{children:o}):i})});H3.displayName=V3;var g9="SelectIcon",U3=b.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...a}=t;return s.jsx(bt.span,{"aria-hidden":!0,...a,ref:e,children:r||"▼"})});U3.displayName=g9;var x9="SelectPortal",W3=t=>s.jsx(w0,{asChild:!0,...t});W3.displayName=x9;var wl="SelectContent",K3=b.forwardRef((t,e)=>{const n=So(wl,t.__scopeSelect),[r,a]=b.useState();if(Ns(()=>{a(new DocumentFragment)},[]),!n.open){const i=r;return i?au.createPortal(s.jsx(q3,{scope:t.__scopeSelect,children:s.jsx(Tp.Slot,{scope:t.__scopeSelect,children:s.jsx("div",{children:t.children})})}),i):null}return s.jsx(G3,{...t,ref:e})});K3.displayName=wl;var Kr=10,[q3,Co]=Fc(wl),y9="SelectContentImpl",b9=Ud("SelectContent.RemoveScroll"),G3=b.forwardRef((t,e)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:o,side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:N,hideWhenDetached:w,avoidCollisions:j,...S}=t,E=So(wl,n),[T,P]=b.useState(null),[O,q]=b.useState(null),z=Ht(e,le=>P(le)),[V,I]=b.useState(null),[te,Q]=b.useState(null),F=Ep(n),[re,ae]=b.useState(!1),J=b.useRef(!1);b.useEffect(()=>{if(T)return lk(T)},[T]),Zj();const $=b.useCallback(le=>{const[ce,...ve]=F().map(ze=>ze.ref.current),[ye]=ve.slice(-1),ke=document.activeElement;for(const ze of le)if(ze===ke||(ze==null||ze.scrollIntoView({block:"nearest"}),ze===ce&&O&&(O.scrollTop=0),ze===ye&&O&&(O.scrollTop=O.scrollHeight),ze==null||ze.focus(),document.activeElement!==ke))return},[F,O]),D=b.useCallback(()=>$([V,T]),[$,V,T]);b.useEffect(()=>{re&&D()},[re,D]);const{onOpenChange:R,triggerPointerDownPosRef:oe}=E;b.useEffect(()=>{if(T){let le={x:0,y:0};const ce=ye=>{var ke,ze;le={x:Math.abs(Math.round(ye.pageX)-(((ke=oe.current)==null?void 0:ke.x)??0)),y:Math.abs(Math.round(ye.pageY)-(((ze=oe.current)==null?void 0:ze.y)??0))}},ve=ye=>{le.x<=10&&le.y<=10?ye.preventDefault():T.contains(ye.target)||R(!1),document.removeEventListener("pointermove",ce),oe.current=null};return oe.current!==null&&(document.addEventListener("pointermove",ce),document.addEventListener("pointerup",ve,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ce),document.removeEventListener("pointerup",ve,{capture:!0})}}},[T,R,oe]),b.useEffect(()=>{const le=()=>R(!1);return window.addEventListener("blur",le),window.addEventListener("resize",le),()=>{window.removeEventListener("blur",le),window.removeEventListener("resize",le)}},[R]);const[G,_]=c4(le=>{const ce=F().filter(ke=>!ke.disabled),ve=ce.find(ke=>ke.ref.current===document.activeElement),ye=d4(ce,le,ve);ye&&setTimeout(()=>ye.ref.current.focus())}),U=b.useCallback((le,ce,ve)=>{const ye=!J.current&&!ve;(E.value!==void 0&&E.value===ce||ye)&&(I(le),ye&&(J.current=!0))},[E.value]),H=b.useCallback(()=>T==null?void 0:T.focus(),[T]),K=b.useCallback((le,ce,ve)=>{const ye=!J.current&&!ve;(E.value!==void 0&&E.value===ce||ye)&&Q(le)},[E.value]),me=r==="popper"?i0:J3,Y=me===i0?{side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:N,hideWhenDetached:w,avoidCollisions:j}:{};return s.jsx(q3,{scope:n,content:T,viewport:O,onViewportChange:q,itemRefCallback:U,selectedItem:V,onItemLeave:H,itemTextRefCallback:K,focusSelectedItem:D,selectedItemText:te,position:r,isPositioned:re,searchRef:G,children:s.jsx(j0,{as:b9,allowPinchZoom:!0,children:s.jsx(N0,{asChild:!0,trapped:E.open,onMountAutoFocus:le=>{le.preventDefault()},onUnmountAutoFocus:mt(a,le=>{var ce;(ce=E.trigger)==null||ce.focus({preventScroll:!0}),le.preventDefault()}),children:s.jsx(v0,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:le=>le.preventDefault(),onDismiss:()=>E.onOpenChange(!1),children:s.jsx(me,{role:"listbox",id:E.contentId,"data-state":E.open?"open":"closed",dir:E.dir,onContextMenu:le=>le.preventDefault(),...S,...Y,onPlaced:()=>ae(!0),ref:z,style:{display:"flex",flexDirection:"column",outline:"none",...S.style},onKeyDown:mt(S.onKeyDown,le=>{const ce=le.ctrlKey||le.altKey||le.metaKey;if(le.key==="Tab"&&le.preventDefault(),!ce&&le.key.length===1&&_(le.key),["ArrowUp","ArrowDown","Home","End"].includes(le.key)){let ye=F().filter(ke=>!ke.disabled).map(ke=>ke.ref.current);if(["ArrowUp","End"].includes(le.key)&&(ye=ye.slice().reverse()),["ArrowUp","ArrowDown"].includes(le.key)){const ke=le.target,ze=ye.indexOf(ke);ye=ye.slice(ze+1)}setTimeout(()=>$(ye)),le.preventDefault()}})})})})})})});G3.displayName=y9;var v9="SelectItemAlignedPosition",J3=b.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...a}=t,i=So(wl,n),o=Co(wl,n),[c,u]=b.useState(null),[h,f]=b.useState(null),m=Ht(e,z=>f(z)),g=Ep(n),y=b.useRef(!1),N=b.useRef(!0),{viewport:w,selectedItem:j,selectedItemText:S,focusSelectedItem:E}=o,T=b.useCallback(()=>{if(i.trigger&&i.valueNode&&c&&h&&w&&j&&S){const z=i.trigger.getBoundingClientRect(),V=h.getBoundingClientRect(),I=i.valueNode.getBoundingClientRect(),te=S.getBoundingClientRect();if(i.dir!=="rtl"){const ke=te.left-V.left,ze=I.left-ke,ht=z.left-ze,wt=z.width+ht,dt=Math.max(wt,V.width),Rt=window.innerWidth-Kr,Tt=tf(ze,[Kr,Math.max(Kr,Rt-dt)]);c.style.minWidth=wt+"px",c.style.left=Tt+"px"}else{const ke=V.right-te.right,ze=window.innerWidth-I.right-ke,ht=window.innerWidth-z.right-ze,wt=z.width+ht,dt=Math.max(wt,V.width),Rt=window.innerWidth-Kr,Tt=tf(ze,[Kr,Math.max(Kr,Rt-dt)]);c.style.minWidth=wt+"px",c.style.right=Tt+"px"}const Q=g(),F=window.innerHeight-Kr*2,re=w.scrollHeight,ae=window.getComputedStyle(h),J=parseInt(ae.borderTopWidth,10),$=parseInt(ae.paddingTop,10),D=parseInt(ae.borderBottomWidth,10),R=parseInt(ae.paddingBottom,10),oe=J+$+re+R+D,G=Math.min(j.offsetHeight*5,oe),_=window.getComputedStyle(w),U=parseInt(_.paddingTop,10),H=parseInt(_.paddingBottom,10),K=z.top+z.height/2-Kr,me=F-K,Y=j.offsetHeight/2,le=j.offsetTop+Y,ce=J+$+le,ve=oe-ce;if(ce<=K){const ke=Q.length>0&&j===Q[Q.length-1].ref.current;c.style.bottom="0px";const ze=h.clientHeight-w.offsetTop-w.offsetHeight,ht=Math.max(me,Y+(ke?H:0)+ze+D),wt=ce+ht;c.style.height=wt+"px"}else{const ke=Q.length>0&&j===Q[0].ref.current;c.style.top="0px";const ht=Math.max(K,J+w.offsetTop+(ke?U:0)+Y)+ve;c.style.height=ht+"px",w.scrollTop=ce-K+w.offsetTop}c.style.margin=`${Kr}px 0`,c.style.minHeight=G+"px",c.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>y.current=!0)}},[g,i.trigger,i.valueNode,c,h,w,j,S,i.dir,r]);Ns(()=>T(),[T]);const[P,O]=b.useState();Ns(()=>{h&&O(window.getComputedStyle(h).zIndex)},[h]);const q=b.useCallback(z=>{z&&N.current===!0&&(T(),E==null||E(),N.current=!1)},[T,E]);return s.jsx(w9,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:y,onScrollButtonChange:q,children:s.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:P},children:s.jsx(bt.div,{...a,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});J3.displayName=v9;var N9="SelectPopperPosition",i0=b.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:a=Kr,...i}=t,o=Mp(n);return s.jsx(i9,{...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)"}})});i0.displayName=N9;var[w9,Ay]=Fc(wl,{}),o0="SelectViewport",Q3=b.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...a}=t,i=Co(o0,n),o=Ay(o0,n),c=Ht(e,i.onViewportChange),u=b.useRef(0);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),s.jsx(Tp.Slot,{scope:n,children:s.jsx(bt.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:mt(a.onScroll,h=>{const f=h.currentTarget,{contentWrapper:m,shouldExpandOnScrollRef:g}=o;if(g!=null&&g.current&&m){const y=Math.abs(u.current-f.scrollTop);if(y>0){const N=window.innerHeight-Kr*2,w=parseFloat(m.style.minHeight),j=parseFloat(m.style.height),S=Math.max(w,j);if(S0?P:0,m.style.justifyContent="flex-end")}}}u.current=f.scrollTop})})})]})});Q3.displayName=o0;var Y3="SelectGroup",[j9,k9]=Fc(Y3),S9=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=oo();return s.jsx(j9,{scope:n,id:a,children:s.jsx(bt.div,{role:"group","aria-labelledby":a,...r,ref:e})})});S9.displayName=Y3;var X3="SelectLabel",C9=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=k9(X3,n);return s.jsx(bt.div,{id:a.id,...r,ref:e})});C9.displayName=X3;var Qf="SelectItem",[T9,Z3]=Fc(Qf),e4=b.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:a=!1,textValue:i,...o}=t,c=So(Qf,n),u=Co(Qf,n),h=c.value===r,[f,m]=b.useState(i??""),[g,y]=b.useState(!1),N=Ht(e,E=>{var T;return(T=u.itemRefCallback)==null?void 0:T.call(u,E,r,a)}),w=oo(),j=b.useRef("touch"),S=()=>{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(T9,{scope:n,value:r,disabled:a,textId:w,isSelected:h,onItemTextChange:b.useCallback(E=>{m(T=>T||((E==null?void 0:E.textContent)??"").trim())},[]),children:s.jsx(Tp.ItemSlot,{scope:n,value:r,disabled:a,textValue:f,children:s.jsx(bt.div,{role:"option","aria-labelledby":w,"data-highlighted":g?"":void 0,"aria-selected":h&&g,"data-state":h?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:N,onFocus:mt(o.onFocus,()=>y(!0)),onBlur:mt(o.onBlur,()=>y(!1)),onClick:mt(o.onClick,()=>{j.current!=="mouse"&&S()}),onPointerUp:mt(o.onPointerUp,()=>{j.current==="mouse"&&S()}),onPointerDown:mt(o.onPointerDown,E=>{j.current=E.pointerType}),onPointerMove:mt(o.onPointerMove,E=>{var T;j.current=E.pointerType,a?(T=u.onItemLeave)==null||T.call(u):j.current==="mouse"&&E.currentTarget.focus({preventScroll:!0})}),onPointerLeave:mt(o.onPointerLeave,E=>{var T;E.currentTarget===document.activeElement&&((T=u.onItemLeave)==null||T.call(u))}),onKeyDown:mt(o.onKeyDown,E=>{var P;((P=u.searchRef)==null?void 0:P.current)!==""&&E.key===" "||(u9.includes(E.key)&&S(),E.key===" "&&E.preventDefault())})})})})});e4.displayName=Qf;var Td="SelectItemText",t4=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:a,...i}=t,o=So(Td,n),c=Co(Td,n),u=Z3(Td,n),h=m9(Td,n),[f,m]=b.useState(null),g=Ht(e,S=>m(S),u.onItemTextChange,S=>{var E;return(E=c.itemTextRefCallback)==null?void 0:E.call(c,S,u.value,u.disabled)}),y=f==null?void 0:f.textContent,N=b.useMemo(()=>s.jsx("option",{value:u.value,disabled:u.disabled,children:y},u.value),[u.disabled,u.value,y]),{onNativeOptionAdd:w,onNativeOptionRemove:j}=h;return Ns(()=>(w(N),()=>j(N)),[w,j,N]),s.jsxs(s.Fragment,{children:[s.jsx(bt.span,{id:u.textId,...i,ref:g}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?au.createPortal(i.children,o.valueNode):null]})});t4.displayName=Td;var n4="SelectItemIndicator",s4=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return Z3(n4,n).isSelected?s.jsx(bt.span,{"aria-hidden":!0,...r,ref:e}):null});s4.displayName=n4;var l0="SelectScrollUpButton",r4=b.forwardRef((t,e)=>{const n=Co(l0,t.__scopeSelect),r=Ay(l0,t.__scopeSelect),[a,i]=b.useState(!1),o=Ht(e,r.onScrollButtonChange);return Ns(()=>{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(i4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop-u.offsetHeight)}}):null});r4.displayName=l0;var c0="SelectScrollDownButton",a4=b.forwardRef((t,e)=>{const n=Co(c0,t.__scopeSelect),r=Ay(c0,t.__scopeSelect),[a,i]=b.useState(!1),o=Ht(e,r.onScrollButtonChange);return Ns(()=>{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(i4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop+u.offsetHeight)}}):null});a4.displayName=c0;var i4=b.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...a}=t,i=Co("SelectScrollButton",n),o=b.useRef(null),c=Ep(n),u=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>u(),[u]),Ns(()=>{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(bt.div,{"aria-hidden":!0,...a,ref:e,style:{flexShrink:0,...a.style},onPointerDown:mt(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:mt(a.onPointerMove,()=>{var h;(h=i.onItemLeave)==null||h.call(i),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:mt(a.onPointerLeave,()=>{u()})})}),E9="SelectSeparator",M9=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return s.jsx(bt.div,{"aria-hidden":!0,...r,ref:e})});M9.displayName=E9;var d0="SelectArrow",A9=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=Mp(n),i=So(d0,n),o=Co(d0,n);return i.open&&o.position==="popper"?s.jsx(o9,{...a,...r,ref:e}):null});A9.displayName=d0;var I9="SelectBubbleInput",o4=b.forwardRef(({__scopeSelect:t,value:e,...n},r)=>{const a=b.useRef(null),i=Ht(r,a),o=M0(e);return b.useEffect(()=>{const c=a.current;if(!c)return;const u=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==e&&f){const m=new Event("change",{bubbles:!0});f.call(c,e),c.dispatchEvent(m)}},[o,e]),s.jsx(bt.select,{...n,style:{...z3,...n.style},ref:i,defaultValue:e})});o4.displayName=I9;function l4(t){return t===""||t===void 0}function c4(t){const e=po(t),n=b.useRef(""),r=b.useRef(0),a=b.useCallback(o=>{const c=n.current+o;e(c),(function u(h){n.current=h,window.clearTimeout(r.current),h!==""&&(r.current=window.setTimeout(()=>u(""),1e3))})(c)},[e]),i=b.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,i]}function d4(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=R9(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 R9(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var P9=$3,u4=B3,O9=H3,L9=U3,D9=W3,h4=K3,_9=Q3,f4=e4,z9=t4,$9=s4,F9=r4,B9=a4;const lc=P9,cc=O9,Qo=b.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(u4,{ref:r,className:Ut("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(L9,{asChild:!0,children:s.jsx(vc,{className:"h-4 w-4 opacity-50"})})]}));Qo.displayName=u4.displayName;const Yo=b.forwardRef(({className:t,children:e,position:n="popper",...r},a)=>s.jsx(D9,{children:s.jsxs(h4,{ref:a,className:Ut("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(F9,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(ax,{className:"h-4 w-4"})}),s.jsx(_9,{className:"p-1",children:e}),s.jsx(B9,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(vc,{className:"h-4 w-4"})})]})}));Yo.displayName=h4.displayName;const sr=b.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(f4,{ref:r,className:Ut("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($9,{children:s.jsx(Zf,{className:"h-4 w-4"})})}),s.jsx(z9,{children:e})]}));sr.displayName=f4.displayName;const qw=["📖","📕","📗","📘","📙","📓","📔","📒","📚","📖"];function V9(t){return t.title==="序言"||t.title.includes("序言")}function Gw(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 Xg(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 H9({parts:t,expandedParts:e,onTogglePart:n,onReorder:r,onReadSection:a,onDeleteSection:i,onAddSectionInPart:o,onAddChapterInPart:c,onDeleteChapter:u,onEditPart:h,onDeletePart:f,onEditChapter:m,selectedSectionIds:g=[],onToggleSectionSelect:y,onShowSectionOrders:N,pinnedSectionIds:w=[]}){const[j,S]=b.useState(null),[E,T]=b.useState(null),P=(F,re)=>(j==null?void 0:j.type)===F&&(j==null?void 0:j.id)===re,O=(F,re)=>(E==null?void 0:E.type)===F&&(E==null?void 0:E.id)===re,q=b.useCallback(()=>{const F=[];for(const re of t)for(const ae of re.chapters)for(const J of ae.sections)F.push({id:J.id,partId:re.id,partTitle:re.title,chapterId:ae.id,chapterTitle:ae.title});return F},[t]),z=b.useCallback(async(F,re,ae,J)=>{var G;F.preventDefault(),F.stopPropagation();const $=F.dataTransfer.getData("text/plain"),D=Xg($);if(!D||D.type===re&&D.id===ae)return;const R=q(),oe=new Map(R.map(_=>[_.id,_]));if(D.type==="part"&&re==="part"){const _=t.map(Y=>Y.id),U=_.indexOf(D.id),H=_.indexOf(ae);if(U===-1||H===-1)return;const K=[..._];K.splice(U,1),K.splice(Uce.id===Y);if(le)for(const ce of le.chapters)for(const ve of ce.sections){const ye=oe.get(ve.id);ye&&me.push(ye)}}await r(me);return}if(D.type==="chapter"&&(re==="chapter"||re==="section"||re==="part")){const _=t.find(ye=>ye.chapters.some(ke=>ke.id===D.id)),U=_==null?void 0:_.chapters.find(ye=>ye.id===D.id);if(!_||!U)return;let H,K,me=null;if(re==="section"){const ye=oe.get(ae);if(!ye)return;H=ye.partId,K=ye.partTitle,me=ae}else if(re==="chapter"){const ye=t.find(ht=>ht.chapters.some(wt=>wt.id===ae)),ke=ye==null?void 0:ye.chapters.find(ht=>ht.id===ae);if(!ye||!ke)return;H=ye.id,K=ye.title;const ze=R.filter(ht=>ht.chapterId===ae).pop();me=(ze==null?void 0:ze.id)??null}else{const ye=t.find(ke=>ke.id===ae);if(!ye)return;if(H=ye.id,K=ye.title,ye.chapters[0]){const ke=R.filter(ze=>ze.partId===ye.id&&ze.chapterId===ye.chapters[0].id);me=((G=ke[ke.length-1])==null?void 0:G.id)??null}}const Y=U.sections.map(ye=>ye.id),le=R.filter(ye=>!Y.includes(ye.id));let ce=le.length;if(me){const ye=le.findIndex(ke=>ke.id===me);ye>=0&&(ce=ye+1)}const ve=Y.map(ye=>({...oe.get(ye),partId:H,partTitle:K,chapterId:U.id,chapterTitle:U.title}));await r([...le.slice(0,ce),...ve,...le.slice(ce)]);return}if(D.type==="section"&&(re==="section"||re==="chapter"||re==="part")){if(!J)return;const{partId:_,partTitle:U,chapterId:H,chapterTitle:K}=J;let me;if(re==="section")me=R.findIndex(ke=>ke.id===ae);else if(re==="chapter"){const ke=R.filter(ze=>ze.chapterId===ae).pop();me=ke?R.findIndex(ze=>ze.id===ke.id)+1:R.length}else{const ke=t.find(ze=>ze.id===ae);if(ke!=null&&ke.chapters[0]){const ze=R.filter(wt=>wt.partId===ke.id&&wt.chapterId===ke.chapters[0].id),ht=ze[ze.length-1];me=ht?R.findIndex(wt=>wt.id===ht.id)+1:R.length}else me=R.length}const Y=R.findIndex(ke=>ke.id===D.id);if(Y===-1)return;const le=R.filter(ke=>ke.id!==D.id),ce=Y({onDragEnter:J=>{J.preventDefault(),J.stopPropagation(),J.dataTransfer.dropEffect="move",T({type:F,id:re})},onDragOver:J=>{J.preventDefault(),J.stopPropagation(),J.dataTransfer.dropEffect="move",T({type:F,id:re})},onDragLeave:()=>T(null),onDrop:J=>{T(null);const $=Xg(J.dataTransfer.getData("text/plain"));$&&(F==="section"&&$.type==="section"&&$.id===re||(F==="part"?$.type==="part"?z(J,"part",re):ae&&z(J,"part",re,ae):F==="chapter"&&ae?($.type==="section"||$.type==="chapter")&&z(J,"chapter",re,ae):F==="section"&&ae&&z(J,"section",re,ae)))}}),I=F=>qw[F%qw.length],te=F=>t.slice(0,F).filter(re=>!V9(re)).length,Q=F=>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: ${F.id}`,children:F.id}),s.jsx("span",{className:"truncate",children:F.title})]});return s.jsx("div",{className:"space-y-3",children:t.map((F,re)=>{var U,H,K,me;const ae=F.title==="序言"||F.title.includes("序言"),J=F.title==="尾声"||F.title.includes("尾声"),$=F.title==="附录"||F.title.includes("附录"),D=O("part",F.id),R=e.includes(F.id),oe=F.chapters.length,G=F.chapters.reduce((Y,le)=>Y+le.sections.length,0);if(ae&&F.chapters.length===1&&F.chapters[0].sections.length===1){const Y=F.chapters[0].sections[0],le=O("section",Y.id),ce={partId:F.id,partTitle:F.title,chapterId:F.chapters[0].id,chapterTitle:F.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:ve=>{ve.stopPropagation(),ve.dataTransfer.setData("text/plain","section:"+Y.id),ve.dataTransfer.effectAllowed="move",S({type:"section",id:Y.id})},onDragEnd:()=>{S(null),T(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] ${le?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${P("section",Y.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...V("section",Y.id,ce),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(Xa,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ve=>ve.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(Y.id),onChange:()=>y(Y.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(qs,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[F.chapters[0].title," | ",Y.title]}),w.includes(Y.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(uc,{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:ve=>ve.stopPropagation(),onClick:ve=>ve.stopPropagation(),children:[Y.price===0||Y.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:["¥",Y.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",Y.clickCount??0," · 付款 ",Y.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(Y.hotScore??0).toFixed(1)," · 第",Y.hotRank&&Y.hotRank>0?Y.hotRank:"-","名"]}),N&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N(Y),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(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(Y),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(Y),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]})]},F.id)}if(F.title==="2026每日派对干货"||F.title.includes("2026每日派对干货")){const Y=O("part",F.id);return s.jsxs("div",{className:`rounded-xl border overflow-hidden transition-all duration-200 ${Y?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50 bg-[#1C1C1E]"}`,...V("part",F.id,{partId:F.id,partTitle:F.title,chapterId:((U=F.chapters[0])==null?void 0:U.id)??"",chapterTitle:((H=F.chapters[0])==null?void 0:H.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:le=>{le.stopPropagation(),le.dataTransfer.setData("text/plain","part:"+F.id),le.dataTransfer.effectAllowed="move",S({type:"part",id:F.id})},onDragEnd:()=>{S(null),T(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${P("part",F.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(Xa,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),s.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#38bdac]/80 flex items-center justify-center text-white font-bold shrink-0",children:"派"}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:F.title}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:Gw(F)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:le=>le.stopPropagation(),onClick:le=>le.stopPropagation(),children:[o&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(F),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(An,{className:"w-3.5 h-3.5"})}),h&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(F),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),f&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(F),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(bs,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[oe," 章 · ",G," 节"]}),s.jsx("button",{type:"button",draggable:!1,className:"p-1 rounded-md hover:bg-white/10 text-gray-500",title:R?"收起":"展开",onMouseDown:le=>le.stopPropagation(),onClick:le=>{le.stopPropagation(),n(F.id)},children:R?s.jsx(vc,{className:"w-5 h-5"}):s.jsx(Xo,{className:"w-5 h-5"})})]})]}),R&&F.chapters.length>0&&s.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:F.chapters.map(le=>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:le.title}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:ce=>ce.stopPropagation(),children:[m&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>m(F,le),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),c&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>c(F),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(An,{className:"w-3.5 h-3.5"})}),u&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>u(F,le),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:le.sections.map(ce=>{const ve=O("section",ce.id);return s.jsxs("div",{draggable:!0,onDragStart:ye=>{ye.stopPropagation(),ye.dataTransfer.setData("text/plain","section:"+ce.id),ye.dataTransfer.effectAllowed="move",S({type:"section",id:ce.id})},onDragEnd:()=>{S(null),T(null)},onClick:()=>a(ce),className:`flex items-center justify-between py-2 px-3 rounded-lg min-h-[40px] cursor-pointer select-none transition-all duration-200 ${ve?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${P("section",ce.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...V("section",ce.id,{partId:F.id,partTitle:F.title,chapterId:le.id,chapterTitle:le.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(Xa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ye=>ye.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(ce.id),onChange:()=>y(ce.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:Q(ce)}),w.includes(ce.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(uc,{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:ye=>ye.stopPropagation(),children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",ce.clickCount??0," · 付款 ",ce.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(ce.hotScore??0).toFixed(1)," · 第",ce.hotRank&&ce.hotRank>0?ce.hotRank:"-","名"]}),N&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>N(ce),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(ce),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(ce),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]},ce.id)})})]},le.id))})]},F.id)}if($)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:F.chapters.map((Y,le)=>Y.sections.length>0?Y.sections.map(ce=>{const ve=O("section",ce.id);return s.jsxs("div",{draggable:!0,onDragStart:ye=>{ye.stopPropagation(),ye.dataTransfer.setData("text/plain","section:"+ce.id),ye.dataTransfer.effectAllowed="move",S({type:"section",id:ce.id})},onDragEnd:()=>{S(null),T(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 ${ve?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${P("section",ce.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...V("section",ce.id,{partId:F.id,partTitle:F.title,chapterId:Y.id,chapterTitle:Y.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(Xa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ye=>ye.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(ce.id),onChange:()=>y(ce.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:["附录",le+1," | ",Y.title," | ",ce.title]}),w.includes(ce.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(uc,{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:["点击 ",ce.clickCount??0," · 付款 ",ce.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(ce.hotScore??0).toFixed(1)," · 第",ce.hotRank&&ce.hotRank>0?ce.hotRank:"-","名"]}),N&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>N(ce),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(X,{variant:"ghost",size:"sm",onClick:()=>a(ce),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>i(ce),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(Xo,{className:"w-4 h-4 text-gray-500 shrink-0"})]},ce.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:["附录",le+1," | ",Y.title,"(空)"]}),s.jsx(Xo,{className:"w-4 h-4 text-gray-500 shrink-0"})]},Y.id))})]},F.id);if(J&&F.chapters.length===1&&F.chapters[0].sections.length===1){const Y=F.chapters[0].sections[0],le=O("section",Y.id),ce={partId:F.id,partTitle:F.title,chapterId:F.chapters[0].id,chapterTitle:F.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:ve=>{ve.stopPropagation(),ve.dataTransfer.setData("text/plain","section:"+Y.id),ve.dataTransfer.effectAllowed="move",S({type:"section",id:Y.id})},onDragEnd:()=>{S(null),T(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] ${le?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${P("section",Y.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...V("section",Y.id,ce),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(Xa,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ve=>ve.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(Y.id),onChange:()=>y(Y.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(qs,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[F.chapters[0].title," | ",Y.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:ve=>ve.stopPropagation(),onClick:ve=>ve.stopPropagation(),children:[Y.price===0||Y.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:["¥",Y.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",Y.clickCount??0," · 付款 ",Y.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(Y.hotScore??0).toFixed(1)," · 第",Y.hotRank&&Y.hotRank>0?Y.hotRank:"-","名"]}),N&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N(Y),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(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(Y),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(Y),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]})]},F.id)}return J?s.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[s.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"尾声"}),s.jsx("div",{className:"space-y-3",children:F.chapters.map(Y=>Y.sections.map(le=>{const ce=O("section",le.id);return s.jsxs("div",{draggable:!0,onDragStart:ve=>{ve.stopPropagation(),ve.dataTransfer.setData("text/plain","section:"+le.id),ve.dataTransfer.effectAllowed="move",S({type:"section",id:le.id})},onDragEnd:()=>{S(null),T(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 ${ce?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${P("section",le.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...V("section",le.id,{partId:F.id,partTitle:F.title,chapterId:Y.id,chapterTitle:Y.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(Xa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ve=>ve.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(le.id),onChange:()=>y(le.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:[Y.title," | ",le.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",le.clickCount??0," · 付款 ",le.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(le.hotScore??0).toFixed(1)," · 第",le.hotRank&&le.hotRank>0?le.hotRank:"-","名"]}),N&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N(le),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(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(le),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(le),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]})]},le.id)}))})]},F.id):s.jsxs("div",{className:`rounded-xl border bg-[#1C1C1E] overflow-hidden transition-all duration-200 ${D?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50"}`,...V("part",F.id,{partId:F.id,partTitle:F.title,chapterId:((K=F.chapters[0])==null?void 0:K.id)??"",chapterTitle:((me=F.chapters[0])==null?void 0:me.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:Y=>{Y.stopPropagation(),Y.dataTransfer.setData("text/plain","part:"+F.id),Y.dataTransfer.effectAllowed="move",S({type:"part",id:F.id})},onDragEnd:()=>{S(null),T(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${P("part",F.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(Xa,{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:I(te(re))}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:F.title}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:Gw(F)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:Y=>Y.stopPropagation(),onClick:Y=>Y.stopPropagation(),children:[o&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(F),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(An,{className:"w-3.5 h-3.5"})}),h&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(F),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),f&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(F),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(bs,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[oe," 章 · ",G," 节"]}),s.jsx("button",{type:"button",draggable:!1,className:"p-1 rounded-md hover:bg-white/10 text-gray-500",title:R?"收起":"展开",onMouseDown:Y=>Y.stopPropagation(),onClick:Y=>{Y.stopPropagation(),n(F.id)},children:R?s.jsx(vc,{className:"w-5 h-5"}):s.jsx(Xo,{className:"w-5 h-5"})})]})]}),R&&s.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:F.chapters.map(Y=>{const le=O("chapter",Y.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:ce=>{ce.stopPropagation(),ce.dataTransfer.setData("text/plain","chapter:"+Y.id),ce.dataTransfer.effectAllowed="move",S({type:"chapter",id:Y.id})},onDragEnd:()=>{S(null),T(null)},onDragEnter:ce=>{ce.preventDefault(),ce.stopPropagation(),ce.dataTransfer.dropEffect="move",T({type:"chapter",id:Y.id})},onDragOver:ce=>{ce.preventDefault(),ce.stopPropagation(),ce.dataTransfer.dropEffect="move",T({type:"chapter",id:Y.id})},onDragLeave:()=>T(null),onDrop:ce=>{T(null);const ve=Xg(ce.dataTransfer.getData("text/plain"));if(!ve)return;const ye={partId:F.id,partTitle:F.title,chapterId:Y.id,chapterTitle:Y.title};(ve.type==="section"||ve.type==="chapter")&&z(ce,"chapter",Y.id,ye)},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 ${le?"bg-[#38bdac]/15 ring-1 ring-[#38bdac]/50":""} ${P("chapter",Y.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/30"}`,children:[s.jsx(Xa,{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:Y.title})]}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:ce=>ce.stopPropagation(),children:[m&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>m(F,Y),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),c&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>c(F),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(An,{className:"w-3.5 h-3.5"})}),u&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>u(F,Y),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:Y.sections.map(ce=>{const ve=O("section",ce.id);return s.jsxs("div",{draggable:!0,onDragStart:ye=>{ye.stopPropagation(),ye.dataTransfer.setData("text/plain","section:"+ce.id),ye.dataTransfer.effectAllowed="move",S({type:"section",id:ce.id})},onDragEnd:()=>{S(null),T(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 ${ve?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${P("section",ce.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] shadow-lg":"hover:bg-[#162840]/50"}`,...V("section",ce.id,{partId:F.id,partTitle:F.title,chapterId:Y.id,chapterTitle:Y.title}),children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ye=>ye.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(ce.id),onChange:()=>y(ce.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsx(Xa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${ce.price===0||ce.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:Q(ce)}),w.includes(ce.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(uc,{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:ye=>ye.stopPropagation(),onClick:ye=>ye.stopPropagation(),children:[ce.isNew&&s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"NEW"}),ce.price===0||ce.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:["¥",ce.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",title:"点击次数 · 付款笔数",children:["点击 ",ce.clickCount??0," · 付款 ",ce.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(ce.hotScore??0).toFixed(1)," · 第",ce.hotRank&&ce.hotRank>0?ce.hotRank:"-","名"]}),N&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>N(ce),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(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(ce),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(ce),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]})]},ce.id)})})]},Y.id)})})]},F.id)})})}function U9(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 Pe(r)}function W9(t){return Pe(`/api/db/person?personId=${encodeURIComponent(t)}`)}function K9(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 Pe(n?`/api/admin/ckb/plans?${n}`:"/api/admin/ckb/plans")}const p4=11,Jw={personId:"",name:"",boundUserId:"",aliases:"",label:"",sceneId:p4,ckbApiKey:"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:"phone",remarkFormat:"",addFriendInterval:1,startTime:"06:00",endTime:"22:00",deviceGroups:""};function q9({open:t,onOpenChange:e,editingPerson:n,onSubmit:r}){var $;const a=!!n,[i,o]=b.useState(Jw),[c,u]=b.useState(!1),[h,f]=b.useState(!1),[m,g]=b.useState([]),[y,N]=b.useState(!1),[w,j]=b.useState(""),[S,E]=b.useState([]),[T,P]=b.useState(!1),[O,q]=b.useState(""),[z,V]=b.useState(!1),[I,te]=b.useState({});b.useEffect(()=>{t&&(j(""),o(n?{personId:n.personId??n.name??"",name:n.name??"",boundUserId:n.userId??"",aliases:n.aliases??"",label:n.label??"",sceneId:p4,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??""}:{...Jw}),te({}),m.length===0&&Q(""),S.length===0&&F(""))},[t,n]);const Q=async D=>{N(!0);try{const R=await U9({page:1,limit:50,keyword:D});R!=null&&R.success&&Array.isArray(R.devices)?g(R.devices):R!=null&&R.error&&se.error(R.error)}catch(R){se.error(R instanceof Error?R.message:"加载设备列表失败")}finally{N(!1)}},F=async D=>{P(!0);try{const R=await K9({page:1,limit:100,keyword:D});R!=null&&R.success&&Array.isArray(R.plans)?E(R.plans):R!=null&&R.error&&se.error(R.error)}catch{se.error("加载计划列表失败")}finally{P(!1)}},re=D=>{const R=Array.isArray(D.deviceGroups)?D.deviceGroups.map(String).join(","):"";o(oe=>({...oe,ckbApiKey:D.apiKey||"",greeting:D.greeting||oe.greeting,tips:D.tips||oe.tips,remarkType:D.remarkType||oe.remarkType,remarkFormat:D.remarkFormat||oe.remarkFormat,addFriendInterval:D.addInterval||oe.addFriendInterval,startTime:D.startTime||oe.startTime,endTime:D.endTime||oe.endTime,deviceGroups:R||oe.deviceGroups})),V(!1),se.success(`已选择计划「${D.name}」,参数已覆盖`)},ae=O.trim()?S.filter(D=>(D.name||"").includes(O.trim())||String(D.id).includes(O.trim())):S,J=async()=>{var G;const D={};(!i.name||!String(i.name).trim())&&(D.name="请填写名称");const R=i.addFriendInterval;if((typeof R!="number"||R<1)&&(D.addFriendInterval="添加间隔至少为 1 分钟"),(((G=i.deviceGroups)==null?void 0:G.split(",").map(_=>_.trim()).filter(Boolean))??[]).length===0&&(D.deviceGroups="请至少选择 1 台设备"),te(D),Object.keys(D).length>0){se.error(D.name||D.addFriendInterval||D.deviceGroups||"请完善必填项");return}u(!0);try{await r(i),e(!1)}catch(_){se.error(_ instanceof Error?_.message:"保存失败")}finally{u(!1)}};return s.jsx(Dt,{open:t,onOpenChange:e,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-y-auto",children:[s.jsxs(_t,{children:[s.jsx(zt,{className:"text-[#38bdac]",children:a?"编辑人物":"添加人物 — 存客宝 API 获客"}),s.jsx(Zh,{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(ee,{className:"text-gray-400 text-xs",children:["名称 ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsx(de,{className:`bg-[#0a1628] text-white ${I.name?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,placeholder:"如 卡若",value:i.name,onChange:D=>{o(R=>({...R,name:D.target.value})),I.name&&te(R=>({...R,name:void 0}))}}),I.name&&s.jsx("p",{className:"text-xs text-red-400",children:I.name})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"人物ID(可选)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"自动生成",value:i.personId,onChange:D=>o(R=>({...R,personId:D.target.value})),disabled:a})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"标签(身份/角色)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 超级个体",value:i.label,onChange:D=>o(R=>({...R,label:D.target.value}))})]}),s.jsxs("div",{className:"space-y-1.5 col-span-3",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"绑定会员用户 ID(可选,与「用户管理」中用户 id 一致)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-xs",placeholder:"留空则不绑定;填写后获客统计可与超级个体对齐",value:i.boundUserId,onChange:D=>o(R=>({...R,boundUserId:D.target.value.trim()}))}),s.jsx("p",{className:"text-[11px] text-gray-500",children:"保存前请在用户管理中核对 id;同一会员只能绑定一个 @人物。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"别名(逗号分隔,@ 可匹配)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 卡卡, 若若",value:i.aliases,onChange:D=>o(R=>({...R,aliases:D.target.value}))})]})]})]}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-5",children:[s.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-4",children:"存客宝 API 获客配置"}),s.jsxs("div",{className:"grid grid-cols-2 gap-x-8 gap-y-4",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5 relative",children:[s.jsx(ee,{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:()=>V(!z),children:i.ckbApiKey?s.jsx("span",{className:"text-white truncate",children:(($=S.find(D=>D.apiKey===i.ckbApiKey))==null?void 0:$.name)||`获客计划 (${i.ckbApiKey.slice(0,8)}…)`}):s.jsx("span",{className:"text-gray-500",children:"点击选择已有计划 / 新建时自动创建"})}),s.jsx(X,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-200 shrink-0",onClick:()=>{F(O),V(!0)},disabled:T,children:T?"加载...":"刷新"})]}),z&&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(de,{className:"bg-[#050c18] border-gray-700 text-white h-8 text-xs",placeholder:"搜索计划名称...",value:O,onChange:D=>q(D.target.value),onKeyDown:D=>{D.key==="Enter"&&F(O)},autoFocus:!0})}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:ae.length===0?s.jsx("div",{className:"text-center py-4 text-gray-500 text-xs",children:T?"加载中...":"暂无计划"}):ae.map(D=>s.jsxs("div",{className:`px-3 py-2 cursor-pointer hover:bg-[#38bdac]/10 text-sm flex items-center justify-between ${i.ckbApiKey===D.apiKey?"bg-[#38bdac]/20 text-[#38bdac]":"text-white"}`,onClick:()=>re(D),children:[s.jsxs("div",{className:"truncate",children:[s.jsx("span",{className:"font-medium",children:D.name}),s.jsxs("span",{className:"text-xs text-gray-500 ml-2",children:["ID:",String(D.id)]})]}),D.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(D.id)))}),s.jsx("div",{className:"p-2 border-t border-gray-700/60 flex justify-end",children:s.jsx(X,{type:"button",size:"sm",variant:"ghost",className:"text-gray-400 h-7 text-xs",onClick:()=>V(!1),children:"关闭"})})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"选择计划后自动覆盖下方参数。新建人物时若不选择则自动创建新计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(ee,{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 ${I.deviceGroups?"border-red-500":"border-gray-700"}`,children:[s.jsx(de,{className:"bg-[#0a1628] border-0 text-white focus-visible:ring-0 focus-visible:ring-offset-0",placeholder:"未选择设备",readOnly:!0,value:i.deviceGroups?`已选择 ${i.deviceGroups.split(",").filter(Boolean).length} 个设备`:"",onClick:()=>f(!0)}),s.jsx(X,{type:"button",variant:"outline",className:"border-0 border-l border-inherit rounded-r-md text-gray-200",onClick:()=>f(!0),children:"选择"})]}),I.deviceGroups?s.jsx("p",{className:"text-xs text-red-400",children:I.deviceGroups}):s.jsx("p",{className:"text-xs text-gray-500",children:"从存客宝设备列表中选择,至少选择 1 台设备参与获客计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"好友备注"}),s.jsxs(lc,{value:i.remarkType,onValueChange:D=>o(R=>({...R,remarkType:D})),children:[s.jsx(Qo,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(cc,{placeholder:"选择备注类型"})}),s.jsxs(Yo,{children:[s.jsx(sr,{value:"phone",children:"手机号"}),s.jsx(sr,{value:"nickname",children:"昵称"}),s.jsx(sr,{value:"source",children:"来源"})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"备注格式(手机号+标签,标签不超过6字)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 {手机号}-{来源标签},总长不超过10字",value:i.remarkFormat,onChange:D=>o(R=>({...R,remarkFormat:D.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(ee,{className:"text-gray-400 text-xs",children:"打招呼语"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"你好,请通过",value:i.greeting,onChange:D=>o(R=>({...R,greeting:D.target.value}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"添加间隔(分钟)"}),s.jsx(de,{type:"number",min:1,className:`bg-[#0a1628] text-white ${I.addFriendInterval?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,value:i.addFriendInterval,onChange:D=>{o(R=>({...R,addFriendInterval:Number(D.target.value)||1})),I.addFriendInterval&&te(R=>({...R,addFriendInterval:void 0}))}}),I.addFriendInterval&&s.jsx("p",{className:"text-xs text-red-400",children:I.addFriendInterval})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"允许加人时间段"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(de,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:i.startTime,onChange:D=>o(R=>({...R,startTime:D.target.value}))}),s.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"至"}),s.jsx(de,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:i.endTime,onChange:D=>o(R=>({...R,endTime:D.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"获客成功提示"}),s.jsx(hl,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[72px] resize-none",placeholder:"请注意消息,稍后加你微信",value:i.tips,onChange:D=>o(R=>({...R,tips:D.target.value}))})]})]})]})]})]}),s.jsxs(fn,{className:"gap-3 pt-2",children:[s.jsx(X,{variant:"outline",onClick:()=>e(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(X,{onClick:J,disabled:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:c?"保存中...":a?"保存":"添加"})]}),h&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:s.jsxs("div",{className:"w-full max-w-3xl max-h-[80vh] bg-[#0b1828] border border-gray-700 rounded-xl shadow-xl flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-gray-700/60",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:"选择设备"}),s.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:"勾选需要参与本计划的设备,可多选"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(X,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>{const D=m.map(G=>String(G.id??"")),R=i.deviceGroups?i.deviceGroups.split(",").map(G=>G.trim()).filter(Boolean):[],oe=D.length>0&&D.every(G=>R.includes(G));o(G=>({...G,deviceGroups:oe?"":D.join(",")})),!oe&&D.length>0&&te(G=>({...G,deviceGroups:void 0}))},children:(()=>{const D=m.map(oe=>String(oe.id??"")),R=i.deviceGroups?i.deviceGroups.split(",").map(oe=>oe.trim()).filter(Boolean):[];return D.length>0&&D.every(oe=>R.includes(oe))?"取消全选":"全选"})()}),s.jsx(de,{className:"bg-[#050c18] border-gray-700 text-white h-8 w-52",placeholder:"搜索备注/微信号/IMEI",value:w,onChange:D=>j(D.target.value),onKeyDown:D=>{D.key==="Enter"&&Q(w)}}),s.jsx(X,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>Q(w),disabled:y,children:"刷新"}),s.jsx(X,{type:"button",size:"icon",variant:"outline",className:"border-gray-600 text-gray-300 h-8 w-8",onClick:()=>f(!1),children:"✕"})]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:y?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-400 text-sm",children:"正在加载设备列表…"}):m.length===0?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 text-sm",children:"暂无设备数据,请检查存客宝账号与开放 API 配置"}):s.jsx("div",{className:"p-4 space-y-2",children:m.map(D=>{const R=String(D.id??""),oe=i.deviceGroups?i.deviceGroups.split(",").map(U=>U.trim()).filter(Boolean):[],G=oe.includes(R),_=()=>{let U;G?U=oe.filter(H=>H!==R):U=[...oe,R],o(H=>({...H,deviceGroups:U.join(",")})),U.length>0&&te(H=>({...H,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:G,onChange:_}),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:D.memo||D.wechatId||`设备 ${R}`}),D.status==="online"&&s.jsx("span",{className:"rounded-full bg-emerald-500/20 text-emerald-400 text-[11px] px-2 py-0.5",children:"在线"}),D.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: ",R]}),D.wechatId&&s.jsxs("span",{className:"mr-3",children:["微信号: ",D.wechatId]}),typeof D.totalFriend=="number"&&s.jsxs("span",{children:["好友数: ",D.totalFriend]})]})]})]},R)})})}),s.jsxs("div",{className:"flex justify-between items-center px-5 py-3 border-t border-gray-700/60",children:[s.jsxs("span",{className:"text-xs text-gray-400",children:["已选择"," ",i.deviceGroups?i.deviceGroups.split(",").filter(Boolean).length:0," ","台设备"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(X,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 h-8 px-4",onClick:()=>f(!1),children:"取消"}),s.jsx(X,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da396] text-white h-8 px-4",onClick:()=>f(!1),children:"确定"})]})]})]})})]})})}function G9(t,e){const n=new Map;for(const i of t){const o=i.partId||"part-1",c=i.partTitle||"未分类",u=i.chapterId||"chapter-1",h=i.chapterTitle||"未分类";n.has(o)||n.set(o,{id:o,title:c,chapters:new Map});const f=n.get(o);f.chapters.has(u)||f.chapters.set(u,{id:u,title:h,sections:[]}),f.chapters.get(u).sections.push({id:i.id,mid:i.mid,title:i.title,price:i.price??1,filePath:i.filePath,isFree:i.isFree,isNew:i.isNew,clickCount:i.clickCount??0,payCount:i.payCount??0,hotScore:i.hotScore??0,hotRank:e.get(i.id)??0})}const r=Array.from(n.values()).map(i=>({...i,chapters:Array.from(i.chapters.values())})),a=new Map;for(let i=0;i{const c=a.get(i.id),u=a.get(o.id);return c!==void 0&&u!==void 0&&c!==u?c-u:c!==void 0&&u===void 0?-1:c===void 0&&u!==void 0?1:i.id.localeCompare(o.id)})}function J9(){var Ha,$r,da;const t=Sa(),[e,n]=b.useState([]),[r,a]=b.useState(!0),[i,o]=b.useState([]),[c,u]=b.useState(null),[h,f]=b.useState(!1),[m,g]=b.useState(!1),[y,N]=b.useState(!1),[w,j]=b.useState(""),[S,E]=b.useState([]),[T,P]=b.useState(!1),[O,q]=b.useState({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),[z,V]=b.useState(null),[I,te]=b.useState(!1),[Q,F]=b.useState(!1),[re,ae]=b.useState(null),[J,$]=b.useState(!1),[D,R]=b.useState([]),[oe,G]=b.useState(!1),[_,U]=b.useState(""),[H,K]=b.useState(""),[me,Y]=b.useState(!1),[le,ce]=b.useState(""),[ve,ye]=b.useState(!1),[ke,ze]=b.useState(null),[ht,wt]=b.useState(!1),[dt,Rt]=b.useState(!1),[Tt,Tn]=b.useState({readWeight:.5,recencyWeight:.3,payWeight:.2}),[mn,Ft]=b.useState(!1),[qt,vn]=b.useState(!1),[On,$n]=b.useState(1),[St,cn]=b.useState([]),[gn,xe]=b.useState(!1),[Se,$e]=b.useState([]),[Xe,jt]=b.useState(!1),[xt,L]=b.useState(20),[Me,ft]=b.useState(!1),[Et,ut]=b.useState(!1),[tt,Pt]=b.useState([]),[Wt,en]=b.useState([]),[ts,Js]=b.useState([]),[bi,ea]=b.useState(!1),[ta,Er]=b.useState(1),[Mr,Ar]=b.useState(20),[cr,dr]=b.useState(0),[Ea,Qs]=b.useState(1),[Ss,Ys]=b.useState(""),[ur,Cs]=b.useState(!1),[ie,ge]=b.useState(null),[Qe,pt]=b.useState({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",pagePath:""}),[Fn,Ps]=b.useState(!1),[Ma,Aa]=b.useState(!1),[To,Xs]=b.useState(null),[Ts,vi]=b.useState(null),[Mt,Bc]=b.useState({}),[Ir,Ni]=b.useState(!1),[Rr,Vc]=b.useState(""),[Ia,na]=b.useState(""),[ns,sa]=b.useState([]),[qn,Cl]=b.useState(0),[Pr,Hc]=b.useState(1),[wi,Ra]=b.useState(!1),[ra,aa]=b.useState(""),ia=b.useRef(null),ji=b.useCallback(async(v,A)=>{var De;const B=new FormData;B.append("file",v),B.append("folder",A);const we=await(await fetch(wc("/api/upload"),{method:"POST",body:B,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((De=we==null?void 0:we.data)==null?void 0:De.url)||(we==null?void 0:we.url)||""},[]),ki=b.useCallback(v=>ji(v,"book-images"),[ji]),Eo=b.useCallback(v=>{const A=v.type.startsWith("video/")?"book-videos":"book-attachments";return ji(v,A)},[ji]),Os=b.useMemo(()=>{const v=new Map;return St.forEach((A,B)=>{v.set(A.id,B+1)}),v},[St]),En=G9(e,Os),Pa=e.length,Ls=10,kt=Math.max(1,Math.ceil(St.length/Ls)),oa=St.slice((On-1)*Ls,On*Ls),Ln=async()=>{a(!0);try{const v=await Pe("/api/db/book?action=list",{cache:"no-store"});n(Array.isArray(v==null?void 0:v.sections)?v.sections:[])}catch(v){console.error(v),n([])}finally{a(!1)}},hr=async()=>{xe(!0);try{const v=await Pe("/api/db/book?action=ranking",{cache:"no-store"}),A=Array.isArray(v==null?void 0:v.sections)?v.sections:[];cn(A);const B=A.filter(ue=>ue.isPinned).map(ue=>ue.id);$e(B)}catch(v){console.error(v),cn([])}finally{xe(!1)}};b.useEffect(()=>{Ln(),hr()},[]);const Mo=v=>{o(A=>A.includes(v)?A.filter(B=>B!==v):[...A,v])},Tl=b.useCallback(v=>{const A=e,B=v.flatMap(ue=>{const we=A.find(De=>De.id===ue.id);return we?[{...we,partId:ue.partId,partTitle:ue.partTitle,chapterId:ue.chapterId,chapterTitle:ue.chapterTitle}]:[]});return n(B),Gt("/api/db/book",{action:"reorder",items:v}).then(ue=>{ue&&ue.success===!1&&(n(A),se.error("排序失败: "+(ue&&typeof ue=="object"&&"error"in ue?ue.error:"未知错误")))}).catch(ue=>{n(A),console.error("排序失败:",ue),se.error("排序失败: "+(ue instanceof Error?ue.message:"网络或服务异常"))}),Promise.resolve()},[e]),Oa=async v=>{if(confirm(`确定要删除章节「${v.title}」吗?此操作不可恢复。`))try{const A=await li(`/api/db/book?id=${encodeURIComponent(v.id)}`);A&&A.success!==!1?(se.success("已删除"),Ln(),hr()):se.error("删除失败: "+(A&&typeof A=="object"&&"error"in A?A.error:"未知错误"))}catch(A){console.error(A),se.error("删除失败")}},fr=b.useCallback(async()=>{Ft(!0);try{const v=await Pe("/api/db/config/full?key=article_ranking_weights",{cache:"no-store"}),A=v&&v.data;A&&typeof A.readWeight=="number"&&typeof A.recencyWeight=="number"&&typeof A.payWeight=="number"&&Tn({readWeight:Math.max(0,Math.min(1,A.readWeight)),recencyWeight:Math.max(0,Math.min(1,A.recencyWeight)),payWeight:Math.max(0,Math.min(1,A.payWeight))})}catch{}finally{Ft(!1)}},[]);b.useEffect(()=>{dt&&fr()},[dt,fr]);const la=async()=>{const{readWeight:v,recencyWeight:A,payWeight:B}=Tt,ue=v+A+B;if(Math.abs(ue-1)>.001){se.error("三个权重之和必须等于 1");return}vn(!0);try{const we=await Ct("/api/db/config",{key:"article_ranking_weights",value:{readWeight:v,recencyWeight:A,payWeight:B},description:"文章排名算法权重"});we&&we.success!==!1?(se.success("排名权重已保存"),Rt(!1),Ln(),hr()):se.error("保存失败: "+(we&&typeof we=="object"&&"error"in we?we.error:""))}catch(we){console.error(we),se.error("保存失败")}finally{vn(!1)}},Ds=b.useCallback(async()=>{jt(!0);try{const v=await Pe("/api/db/config/full?key=pinned_section_ids",{cache:"no-store"}),A=v&&v.data;Array.isArray(A)&&$e(A)}catch{}finally{jt(!1)}},[]),Bn=b.useCallback(async()=>{try{const v=await Pe("/api/db/persons");v!=null&&v.success&&v.persons&&Pt(v.persons.map(A=>{const B=A.deviceGroups,ue=Array.isArray(B)?B.join(","):B??"";return{id:A.token??A.personId??"",personId:A.personId,name:A.name,personSource:A.personSource??"",userId:A.userId,aliases:A.aliases??"",label:A.label??"",ckbApiKey:A.ckbApiKey??"",ckbPlanId:A.ckbPlanId,remarkType:A.remarkType,remarkFormat:A.remarkFormat,addFriendInterval:A.addFriendInterval,startTime:A.startTime,endTime:A.endTime,deviceGroups:ue}}))}catch{}},[]),Vn=b.useCallback(async()=>{try{const v=await Pe("/api/db/link-tags");v!=null&&v.success&&v.linkTags&&en(v.linkTags.map(A=>({id:A.tagId,label:A.label,url:A.url,type:A.type||"url",appId:A.appId||"",pagePath:A.pagePath||""})))}catch{}},[]),Or=b.useCallback(async()=>{try{const v=await Pe("/api/db/config/full?key=ckb_lead_webhook_url",{cache:"no-store"});v!=null&&v.success&&typeof v.data=="string"&&aa(v.data)}catch{}},[]),ca=b.useCallback(async()=>{try{const v=await Pe("/api/db/ckb-person-leads");if(v!=null&&v.success&&v.byPerson){const A={};for(const B of v.byPerson)A[B.token]=B.total;Bc(A)}}catch{}},[]),ps=b.useCallback(async(v,A,B=1)=>{Vc(v),na(A),Ni(!0),Hc(B),Ra(!0);try{const ue=await Pe(`/api/db/ckb-person-leads?token=${encodeURIComponent(v)}&page=${B}&pageSize=20`);ue!=null&&ue.success?(sa(ue.records||[]),Cl(ue.total||0)):se.error((ue==null?void 0:ue.error)||"加载获客详情失败")}catch(ue){se.error(ue instanceof Error?ue.message:"加载获客详情失败")}finally{Ra(!1)}},[]),La=b.useCallback(async()=>{ea(!0);try{const v=new URLSearchParams({page:String(ta),pageSize:String(Mr)}),A=Ss.trim();A&&v.set("search",A);const B=await Pe(`/api/db/link-tags?${v.toString()}`);if(B!=null&&B.success){const ue=Array.isArray(B.linkTags)?B.linkTags:[];Js(ue.map(we=>({id:we.tagId,label:we.label,aliases:we.aliases||"",url:we.url,type:we.type||"url",appId:we.appId||"",pagePath:we.pagePath||""}))),dr(typeof B.total=="number"?B.total:0),Qs(typeof B.totalPages=="number"&&B.totalPages>0?B.totalPages:1)}}catch(v){console.error(v),se.error("加载链接标签失败")}finally{ea(!1)}},[ta,Mr,Ss]),[Da,_a]=b.useState([]),[za,_s]=b.useState(""),[Zs,zs]=b.useState(!1),El=b.useRef(null),Lr=b.useCallback(async()=>{try{const v=await Pe("/api/admin/linked-miniprograms");v!=null&&v.success&&Array.isArray(v.data)&&_a(v.data.map(A=>({...A,key:A.key})))}catch{}},[]),Dr=Da.filter(v=>!za.trim()||v.name.toLowerCase().includes(za.toLowerCase())||v.key&&v.key.toLowerCase().includes(za.toLowerCase())||v.appId.toLowerCase().includes(za.toLowerCase())),pr=async v=>{const A=Se.includes(v)?Se.filter(B=>B!==v):[...Se,v];$e(A);try{await Ct("/api/db/config",{key:"pinned_section_ids",value:A,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"}),hr()}catch{$e(Se)}},$a=b.useCallback(async()=>{ft(!0);try{const v=await Pe("/api/db/config/full?key=unpaid_preview_percent",{cache:"no-store"}),A=v&&v.data;typeof A=="number"&&A>0&&A<=100&&L(A)}catch{}finally{ft(!1)}},[]),Uc=async()=>{if(xt<1||xt>100){se.error("预览比例需在 1~100 之间");return}ut(!0);try{const v=await Ct("/api/db/config",{key:"unpaid_preview_percent",value:xt,description:"小程序未付费内容默认预览比例(%)"});v&&v.success!==!1?se.success("预览比例已保存"):se.error("保存失败: "+(v.error||""))}catch{se.error("保存失败")}finally{ut(!1)}};b.useEffect(()=>{Ds(),$a(),Bn(),Vn(),ca(),Lr(),Or()},[Ds,$a,Bn,Vn,ca,Lr,Or]),b.useEffect(()=>{La()},[La]);const Ml=async v=>{ze({section:v,orders:[]}),wt(!0);try{const A=await Pe(`/api/db/book?action=section-orders&id=${encodeURIComponent(v.id)}`),B=A!=null&&A.success&&Array.isArray(A.orders)?A.orders:[];ze(ue=>ue?{...ue,orders:B}:null)}catch(A){console.error(A),ze(B=>B?{...B,orders:[]}:null)}finally{wt(!1)}},Fa=async v=>{g(!0);try{const A=v.mid!=null&&v.mid>0?`/api/db/book?action=read&mid=${v.mid}`:`/api/db/book?action=read&id=${encodeURIComponent(v.id)}`,B=await Pe(A);if(B!=null&&B.success&&B.section){const ue=B.section,we=ue.editionPremium===!0;u({id:v.id,originalId:v.id,title:B.section.title??v.title,price:B.section.price??v.price,content:B.section.content??"",filePath:v.filePath,isFree:v.isFree||v.price===0,isNew:ue.isNew??v.isNew,isPinned:Se.includes(v.id),hotScore:v.hotScore??0,editionStandard:we?!1:ue.editionStandard??!0,editionPremium:we})}else u({id:v.id,originalId:v.id,title:v.title,price:v.price,content:"",filePath:v.filePath,isFree:v.isFree,isNew:v.isNew,isPinned:Se.includes(v.id),hotScore:v.hotScore??0,editionStandard:!0,editionPremium:!1}),B&&!B.success&&se.error("无法读取文件内容: "+(B.error||"未知错误"))}catch(A){console.error(A),u({id:v.id,title:v.title,price:v.price,content:"",filePath:v.filePath,isFree:v.isFree})}finally{g(!1)}},Si=async()=>{var v;if(c){N(!0);try{let A=c.content||"";const B=[new RegExp(`^#+\\s*${c.id.replace(".","\\.")}\\s+.*$`,"gm"),new RegExp(`^#+\\s*${c.id.replace(".","\\.")}[::].*$`,"gm"),new RegExp(`^#\\s+.*${(v=c.title)==null?void 0:v.slice(0,10).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}.*$`,"gm")];for(const Ge of B)A=A.replace(Ge,"");A=A.replace(/^\s*\n+/,"").trim();const ue=c.originalId||c.id,we=c.id!==ue,De=await Gt("/api/db/book",{id:ue,...we?{newId:c.id}:{},title:c.title,price:c.isFree?0:c.price,content:A,isFree:c.isFree||c.price===0,isNew:c.isNew,hotScore:c.hotScore,previewPercent:c.previewPercent??null,editionStandard:c.editionPremium?!1:c.editionStandard??!0,editionPremium:c.editionPremium??!1,saveToFile:!0},{timeout:h1}),it=we?c.id:ue;c.isPinned!==Se.includes(it)&&await pr(it),De&&De.success!==!1?(se.success(`已保存:${c.title}`),u(null),Ln(),Bn(),Vn()):se.error("保存失败: "+(De&&typeof De=="object"&&"error"in De?De.error:"未知错误"))}catch(A){console.error(A);const B=A instanceof Error&&A.name==="AbortError"?"保存超时,请检查网络或稍后重试":"保存失败";se.error(B)}finally{N(!1)}}},Ao=async()=>{if(!O.id||!O.title){se.error("请填写章节ID和标题");return}N(!0);try{const v=En.find(ue=>ue.id===O.partId),A=v==null?void 0:v.chapters.find(ue=>ue.id===O.chapterId),B=await Gt("/api/db/book",{id:O.id,title:O.title,price:O.isFree?0:O.price,content:O.content||"",partId:O.partId,partTitle:(v==null?void 0:v.title)??"",chapterId:O.chapterId,chapterTitle:(A==null?void 0:A.title)??"",isFree:O.isFree,isNew:O.isNew,editionStandard:O.editionPremium?!1:O.editionStandard??!0,editionPremium:O.editionPremium??!1,hotScore:O.hotScore??0,saveToFile:!1},{timeout:h1});if(B&&B.success!==!1){if(O.isPinned){const ue=[...Se,O.id];$e(ue);try{await Ct("/api/db/config",{key:"pinned_section_ids",value:ue,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"})}catch{}}se.success(`章节创建成功:${O.title}`),f(!1),q({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),Ln(),Bn(),Vn()}else se.error("创建失败: "+(B&&typeof B=="object"&&"error"in B?B.error:"未知错误"))}catch(v){console.error(v),se.error("创建失败")}finally{N(!1)}},Io=v=>{q(A=>{var B;return{...A,partId:v.id,chapterId:((B=v.chapters[0])==null?void 0:B.id)??"chapter-1"}}),f(!0)},mr=v=>{V({id:v.id,title:v.title})},Ro=async()=>{var v;if((v=z==null?void 0:z.title)!=null&&v.trim()){te(!0);try{const A=e.map(ue=>({id:ue.id,partId:ue.partId||"part-1",partTitle:ue.partId===z.id?z.title.trim():ue.partTitle||"",chapterId:ue.chapterId||"chapter-1",chapterTitle:ue.chapterTitle||""})),B=await Gt("/api/db/book",{action:"reorder",items:A});if(B&&B.success!==!1){const ue=z.title.trim();n(we=>we.map(De=>De.partId===z.id?{...De,partTitle:ue}:De)),V(null),Ln()}else se.error("更新篇名失败: "+(B&&typeof B=="object"&&"error"in B?B.error:"未知错误"))}catch(A){console.error(A),se.error("更新篇名失败")}finally{te(!1)}}},Ba=v=>{const A=v.chapters.length+1,B=`chapter-${v.id}-${A}-${Date.now()}`;q({id:`${A}.1`,title:"新章节",price:1,partId:v.id,chapterId:B,content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),f(!0)},Po=(v,A)=>{const B=A.sections;let ue=1,we=!1,De=!1;if(B.length>0){const it=typeof B[0].price=="number"?B[0].price:Number(B[0].price)||1,Ge=!!(B[0].isFree||it===0);De=B.some(vt=>{const At=typeof vt.price=="number"?vt.price:Number(vt.price)||1,dn=!!(vt.isFree||At===0);return At!==it||dn!==Ge}),ue=Ge?0:it,we=Ge}ae({part:v,chapter:A,title:A.title,price:ue,isFree:we,priceMixed:De,initialTitle:A.title,initialPrice:ue,initialIsFree:we})},Ci=async()=>{var we;if(!((we=re==null?void 0:re.title)!=null&&we.trim()))return;const v=re,A=v.title.trim(),B=A!==v.initialTitle,ue=v.isFree!==v.initialIsFree||!v.isFree&&Number(v.price)!==Number(v.initialPrice);if(!B&&!ue){se.info("未修改任何内容"),ae(null);return}if(v.priceMixed&&ue){const De=v.chapter.sections.length,it=v.isFree?"全部设为免费":`全部设为 ¥${v.price}`;if(!confirm(`本章 ${De} 节当前定价不一致,保存后将${it},确定?`))return}$(!0);try{if(B){const De=e.map(At=>({id:At.id,partId:At.partId||v.part.id,partTitle:At.partId===v.part.id?v.part.title:At.partTitle||"",chapterId:At.chapterId||v.chapter.id,chapterTitle:At.partId===v.part.id&&At.chapterId===v.chapter.id?A:At.chapterTitle||""})),it=await Gt("/api/db/book",{action:"reorder",items:De});if(it&&it.success===!1){se.error("保存章节名失败: "+(it&&typeof it=="object"&&"error"in it?it.error:"未知错误"));return}const Ge=v.part.id,vt=v.chapter.id;n(At=>At.map(dn=>dn.partId===Ge&&dn.chapterId===vt?{...dn,chapterTitle:A}:dn))}if(ue){const De=await Gt("/api/db/book",{action:"update-chapter-pricing",partId:v.part.id,chapterId:v.chapter.id,price:v.isFree?0:Number(v.price)||0,isFree:v.isFree});if(De&&De.success===!1){se.error("保存定价失败: "+(De&&typeof De=="object"&&"error"in De?De.error:"未知错误")),B&&Ln();return}}ae(null),Ln(),se.success("已保存")}catch(De){console.error(De),se.error("保存失败")}finally{$(!1)}},Ti=async(v,A)=>{const B=A.sections.map(ue=>ue.id);if(B.length===0){se.info("该章下无小节,无需删除");return}if(confirm(`确定要删除「第${v.chapters.indexOf(A)+1}章 | ${A.title}」吗?将删除共 ${B.length} 节,此操作不可恢复。`))try{for(const ue of B)await li(`/api/db/book?id=${encodeURIComponent(ue)}`);Ln()}catch(ue){console.error(ue),se.error("删除失败")}},Oo=async()=>{if(!le.trim()){se.error("请输入篇名");return}ye(!0);try{const v=`part-new-${Date.now()}`,A="chapter-1",B=`part-placeholder-${Date.now()}`,ue=await Gt("/api/db/book",{id:B,title:"占位节(可编辑)",price:0,content:"",partId:v,partTitle:le.trim(),chapterId:A,chapterTitle:"第1章 | 待编辑",saveToFile:!1});ue&&ue.success!==!1?(se.success(`篇「${le}」创建成功`),F(!1),ce(""),Ln()):se.error("创建失败: "+(ue&&typeof ue=="object"&&"error"in ue?ue.error:"未知错误"))}catch(v){console.error(v),se.error("创建失败")}finally{ye(!1)}},ss=async()=>{if(D.length===0){se.error("请先勾选要移动的章节");return}const v=En.find(B=>B.id===_),A=v==null?void 0:v.chapters.find(B=>B.id===H);if(!v||!A||!_||!H){se.error("请选择目标篇和章");return}Y(!0);try{const B=()=>{const it=new Set(D),Ge=e.map(un=>({id:un.id,partId:un.partId||"",partTitle:un.partTitle||"",chapterId:un.chapterId||"",chapterTitle:un.chapterTitle||""})),vt=Ge.filter(un=>it.has(un.id)).map(un=>({...un,partId:_,partTitle:v.title||_,chapterId:H,chapterTitle:A.title||H})),At=Ge.filter(un=>!it.has(un.id));let dn=At.length;for(let un=At.length-1;un>=0;un-=1){const Al=At[un];if(Al.partId===_&&Al.chapterId===H){dn=un+1;break}}return[...At.slice(0,dn),...vt,...At.slice(dn)]},ue=async()=>{const it=B(),Ge=await Gt("/api/db/book",{action:"reorder",items:it});return Ge&&Ge.success!==!1?(se.success(`已移动 ${D.length} 节到「${v.title}」-「${A.title}」`),G(!1),R([]),await Ln(),!0):!1},we={action:"move-sections",sectionIds:D,targetPartId:_,targetChapterId:H,targetPartTitle:v.title||_,targetChapterTitle:A.title||H},De=await Gt("/api/db/book",we);if(De&&De.success!==!1)se.success(`已移动 ${De.count??D.length} 节到「${v.title}」-「${A.title}」`),G(!1),R([]),await Ln();else{const it=De&&typeof De=="object"&&"error"in De?De.error||"":"未知错误";if((it.includes("缺少 id")||it.includes("无效的 action"))&&await ue())return;se.error("移动失败: "+it)}}catch(B){console.error(B),se.error("移动失败: "+(B instanceof Error?B.message:"网络或服务异常"))}finally{Y(!1)}},_r=v=>{R(A=>A.includes(v)?A.filter(B=>B!==v):[...A,v])},Ei=async v=>{const A=e.filter(B=>B.partId===v.id).map(B=>B.id);if(A.length===0){se.info("该篇下暂无小节可删除");return}if(confirm(`确定要删除「${v.title}」整篇吗?将删除共 ${A.length} 节内容,此操作不可恢复。`))try{for(const B of A)await li(`/api/db/book?id=${encodeURIComponent(B)}`);Ln()}catch(B){console.error(B),se.error("删除失败")}},zr=async()=>{var v;if(w.trim()){P(!0);try{const A=await Pe(`/api/search?q=${encodeURIComponent(w)}`);A!=null&&A.success&&((v=A.data)!=null&&v.results)?E(A.data.results):(E([]),A&&!A.success&&se.error("搜索失败: "+A.error))}catch(A){console.error(A),E([]),se.error("搜索失败")}finally{P(!1)}}},Mi=En.find(v=>v.id===O.partId),Va=(Mi==null?void 0:Mi.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:["共 ",En.length," 篇 · ",Pa," 节内容"]})]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(X,{onClick:()=>Rt(!0),variant:"outline",className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(dh,{className:"w-4 h-4 mr-2"}),"排名算法"]})})]}),s.jsx(Dt,{open:h,onOpenChange:f,children:s.jsxs(Lt,{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(_t,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(An,{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(ee,{className:"text-gray-300",children:"章节ID *"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 9.15",value:O.id,onChange:v=>q({...O,id:v.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(de,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:O.isFree?0:O.price,onChange:v=>q({...O,price:Number(v.target.value),isFree:Number(v.target.value)===0}),disabled:O.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"免费"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:O.isFree,onChange:v=>q({...O,isFree:v.target.checked,price:v.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(ee,{className:"text-gray-300",children:"最新新增"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:O.isNew,onChange:v=>q({...O,isNew:v.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(ee,{className:"text-gray-300",children:"小程序直推"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:O.isPinned,onChange:v=>q({...O,isPinned:v.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(ee,{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:O.editionPremium!==!0,onChange:()=>q({...O,editionStandard:!0,editionPremium:!1}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"普通版"})]}),s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"new-edition-type",checked:O.editionPremium===!0,onChange:()=>q({...O,editionStandard:!1,editionPremium:!0}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"增值版"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"热度分"}),s.jsx(de,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:O.hotScore??0,onChange:v=>q({...O,hotScore:Math.max(0,parseFloat(v.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"章节标题 *"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入章节标题",value:O.title,onChange:v=>q({...O,title:v.target.value})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"所属篇"}),s.jsxs(lc,{value:O.partId,onValueChange:v=>{var B;const A=En.find(ue=>ue.id===v);q({...O,partId:v,chapterId:((B=A==null?void 0:A.chapters[0])==null?void 0:B.id)??"chapter-1"})},children:[s.jsx(Qo,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(cc,{})}),s.jsxs(Yo,{className:"bg-[#0f2137] border-gray-700",children:[En.map(v=>s.jsx(sr,{value:v.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:v.title},v.id)),En.length===0&&s.jsx(sr,{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(ee,{className:"text-gray-300",children:"所属章"}),s.jsxs(lc,{value:O.chapterId,onValueChange:v=>q({...O,chapterId:v}),children:[s.jsx(Qo,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(cc,{})}),s.jsxs(Yo,{className:"bg-[#0f2137] border-gray-700",children:[Va.map(v=>s.jsx(sr,{value:v.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:v.title},v.id)),Va.length===0&&s.jsx(sr,{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(ee,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),s.jsx(n0,{content:O.content||"",onChange:v=>q({...O,content:v}),onImageUpload:ki,onMediaUpload:Eo,persons:tt,linkTags:Wt,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(fn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[s.jsx(X,{variant:"outline",onClick:()=>f(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(X,{onClick:Ao,disabled:y||!O.id||!O.title,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:y?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(An,{className:"w-4 h-4 mr-2"}),"创建章节"]})})]})]})}),s.jsx(Dt,{open:!!z,onOpenChange:v=>!v&&V(null),children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(Jt,{className:"w-5 h-5 text-[#38bdac]"}),"编辑篇名"]})}),z&&s.jsx("div",{className:"space-y-4 py-4",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"篇名"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",value:z.title,onChange:v=>V({...z,title:v.target.value}),placeholder:"输入篇名"})]})}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",onClick:()=>V(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(X,{onClick:Ro,disabled:I||!((Ha=z==null?void 0:z.title)!=null&&Ha.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:I?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Dt,{open:!!re,onOpenChange:v=>!v&&ae(null),children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsxs(_t,{children:[s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(Jt,{className:"w-5 h-5 text-[#38bdac]"}),"章节设置"]}),s.jsx("p",{className:"text-gray-400 text-sm font-normal pt-1",children:"修改本章显示名称,或为本章下全部节设置统一金额(仍可在单节编辑里单独改某一节)。"})]}),re&&s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"章节名称(如:第8章|底层结构)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",value:re.title,onChange:v=>ae({...re,title:v.target.value}),placeholder:"输入章节名称"})]}),s.jsxs("div",{className:"space-y-2 border-t border-gray-700/60 pt-4",children:[s.jsxs(ee,{className:"text-gray-300",children:["本章统一定价(应用于本章全部 ",re.chapter.sections.length," 节)"]}),re.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(de,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:re.isFree?0:re.price,onChange:v=>ae({...re,price:Number(v.target.value),isFree:Number(v.target.value)===0}),disabled:re.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:re.isFree||re.price===0,onChange:v=>ae({...re,isFree:v.target.checked,price:v.target.checked?0:re.initialPrice>0?re.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(fn,{children:[s.jsx(X,{variant:"outline",onClick:()=>ae(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(X,{onClick:Ci,disabled:J||!(($r=re==null?void 0:re.title)!=null&&$r.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:J?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Dt,{open:oe,onOpenChange:v=>{var A;if(G(v),v&&En.length>0){const B=En[0];U(B.id),K(((A=B.chapters[0])==null?void 0:A.id)??"")}},children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(_t,{children:s.jsx(zt,{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:D.length})," 节,请选择目标篇与章。"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"目标篇"}),s.jsxs(lc,{value:_,onValueChange:v=>{var B;U(v);const A=En.find(ue=>ue.id===v);K(((B=A==null?void 0:A.chapters[0])==null?void 0:B.id)??"")},children:[s.jsx(Qo,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(cc,{placeholder:"选择篇"})}),s.jsx(Yo,{className:"bg-[#0f2137] border-gray-700",children:En.map(v=>s.jsx(sr,{value:v.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:v.title},v.id))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"目标章"}),s.jsxs(lc,{value:H,onValueChange:K,children:[s.jsx(Qo,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(cc,{placeholder:"选择章"})}),s.jsx(Yo,{className:"bg-[#0f2137] border-gray-700",children:(((da=En.find(v=>v.id===_))==null?void 0:da.chapters)??[]).map(v=>s.jsx(sr,{value:v.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:v.title},v.id))})]})]})]}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",onClick:()=>G(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(X,{onClick:ss,disabled:me||D.length===0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:me?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"移动中..."]}):"确认移动"})]})]})}),s.jsx(Dt,{open:!!ke,onOpenChange:v=>!v&&ze(null),children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",showCloseButton:!0,children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white",children:["付款记录 — ",(ke==null?void 0:ke.section.title)??""]})}),s.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:ht?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):ke&&ke.orders.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"暂无付款记录"}):ke?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:ke.orders.map(v=>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:`查看订单 ${v.orderSn}`,onClick:()=>window.open(`/orders?search=${v.orderSn??v.id??""}`,"_blank"),children:v.orderSn?v.orderSn.length>16?v.orderSn.slice(0,8)+"..."+v.orderSn.slice(-6):v.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:`查看用户 ${v.userId??v.openId??""}`,onClick:()=>window.open(`/users?search=${v.userId??v.openId??""}`,"_blank"),children:(()=>{const A=v.userId??v.openId??"-";return A.length>12?A.slice(0,6)+"..."+A.slice(-4):A})()})}),s.jsxs("td",{className:"py-2 pr-2 text-gray-300",children:["¥",v.amount??0]}),s.jsx("td",{className:"py-2 pr-2 text-gray-300",children:v.status??"-"}),s.jsx("td",{className:"py-2 pr-2 text-gray-500",children:v.payTime??v.createdAt??"-"})]},v.id??v.orderSn??""))})]}):null})]})}),s.jsx(Dt,{open:dt,onOpenChange:Rt,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(dh,{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)"}),mn?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(ee,{className:"text-gray-400 text-xs",children:"阅读权重"}),s.jsx(de,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Tt.readWeight,onChange:v=>Tn(A=>({...A,readWeight:Math.max(0,Math.min(1,parseFloat(v.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"新度权重"}),s.jsx(de,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Tt.recencyWeight,onChange:v=>Tn(A=>({...A,recencyWeight:Math.max(0,Math.min(1,parseFloat(v.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"付款权重"}),s.jsx(de,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Tt.payWeight,onChange:v=>Tn(A=>({...A,payWeight:Math.max(0,Math.min(1,parseFloat(v.target.value)||0))}))})]})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["当前之和: ",(Tt.readWeight+Tt.recencyWeight+Tt.payWeight).toFixed(1)]}),s.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs text-gray-400",children:[s.jsx("li",{children:"阅读量前 20 名:第1名=20分、第2名=19分...第20名=1分"}),s.jsx("li",{children:"最近更新前 30 篇:第1名=30分、第2名=29分...第30名=1分"}),s.jsx("li",{children:"付款数前 20 名:第1名=20分、第2名=19分...第20名=1分"}),s.jsx("li",{children:"热度分可在编辑章节中手动覆盖"})]}),s.jsx(X,{onClick:la,disabled:qt||Math.abs(Tt.readWeight+Tt.recencyWeight+Tt.payWeight-1)>.001,className:"w-full bg-amber-500 hover:bg-amber-600 text-white",children:qt?"保存中...":"保存权重"})]})]})]})}),s.jsx(Dt,{open:Q,onOpenChange:F,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(An,{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(ee,{className:"text-gray-300",children:"篇名(如:第六篇|真实的社会)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",value:le,onChange:v=>ce(v.target.value),placeholder:"输入篇名"})]})}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",onClick:()=>{F(!1),ce("")},className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(X,{onClick:Oo,disabled:ve||!le.trim(),className:"bg-amber-500 hover:bg-amber-600 text-white",children:ve?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(An,{className:"w-4 h-4 mr-2"}),"创建篇"]})})]})]})}),s.jsx(Dt,{open:!!c,onOpenChange:()=>u(null),children:s.jsxs(Lt,{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(_t,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(Jt,{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(ee,{className:"text-gray-300",children:"章节ID"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",value:c.id,onChange:v=>u({...c,id:v.target.value}),placeholder:"如: 9.15"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(de,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:c.isFree?0:c.price,onChange:v=>u({...c,price:Number(v.target.value),isFree:Number(v.target.value)===0}),disabled:c.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{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:v=>u({...c,isFree:v.target.checked,price:v.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(ee,{className:"text-gray-300",children:"预览%"}),s.jsx(de,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",placeholder:`全局 ${xt}%`,value:c.previewPercent??"",onChange:v=>{const A=v.target.value===""?void 0:Math.min(100,Math.max(0,Number(v.target.value)));u({...c,previewPercent:A})}})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{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:v=>u({...c,isNew:v.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(ee,{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:v=>u({...c,isPinned:v.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(ee,{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(ee,{className:"text-gray-300",children:"热度分"}),s.jsx(de,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:c.hotScore??0,onChange:v=>u({...c,hotScore:Math.max(0,parseFloat(v.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"章节标题"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",value:c.title,onChange:v=>u({...c,title:v.target.value})})]}),c.filePath&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"文件路径"}),s.jsx(de,{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(ee,{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(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(n0,{ref:ia,content:c.content||"",onChange:v=>u({...c,content:v}),onImageUpload:ki,onMediaUpload:Eo,persons:tt,linkTags:Wt,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(fn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[c&&s.jsxs(X,{variant:"outline",onClick:()=>Ml({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(qs,{className:"w-4 h-4 mr-2"}),"付款记录"]}),s.jsxs(X,{variant:"outline",onClick:()=>u(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsx(X,{onClick:Si,disabled:y,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:y?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),"保存修改"]})})]})]})}),s.jsxs(jc,{defaultValue:"chapters",className:"space-y-6",children:[s.jsxs(ul,{className:"bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(Qt,{value:"chapters",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(qs,{className:"w-4 h-4 mr-2"}),"章节管理"]}),s.jsxs(Qt,{value:"ranking",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(ux,{className:"w-4 h-4 mr-2"}),"内容排行榜"]}),s.jsxs(Qt,{value:"search",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(va,{className:"w-4 h-4 mr-2"}),"内容搜索"]}),s.jsxs(Qt,{value:"link-person",className:"data-[state=active]:bg-purple-500/20 data-[state=active]:text-purple-400 text-gray-400",children:[s.jsx(ya,{className:"w-4 h-4 mr-2"}),"链接人与事"]}),s.jsxs(Qt,{value:"link-tag",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(l1,{className:"w-4 h-4 mr-2"}),"链接标签"]})]}),s.jsxs(Yt,{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(qs,{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:Pa}),s.jsx("span",{className:"text-xs text-gray-500",children:"章节"})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(X,{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(An,{className:"w-4 h-4 mr-2"}),"新建章节"]}),s.jsxs(X,{onClick:()=>F(!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(An,{className:"w-4 h-4 mr-2"}),"新建篇"]}),s.jsxs(X,{variant:"outline",onClick:()=>G(!0),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:["批量移动(已选 ",D.length," 节)"]})]}),r?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(H9,{parts:En,expandedParts:i,onTogglePart:Mo,onReorder:Tl,onReadSection:Fa,onDeleteSection:Oa,onAddSectionInPart:Io,onAddChapterInPart:Ba,onDeleteChapter:Ti,onEditPart:mr,onDeletePart:Ei,onEditChapter:Po,selectedSectionIds:D,onToggleSectionSelect:_r,onShowSectionOrders:Ml,pinnedSectionIds:Se})]}),s.jsx(Yt,{value:"search",className:"space-y-4",children:s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(rt,{children:s.jsx(at,{className:"text-white",children:"内容搜索"})}),s.jsxs(Le,{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",placeholder:"搜索标题或内容...",value:w,onChange:v=>j(v.target.value),onKeyDown:v=>v.key==="Enter"&&zr()}),s.jsx(X,{onClick:zr,disabled:T||!w.trim(),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:T?s.jsx(Fe,{className:"w-4 h-4 animate-spin"}):s.jsx(va,{className:"w-4 h-4"})})]}),S.length>0&&s.jsxs("div",{className:"space-y-2 mt-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["找到 ",S.length," 个结果"]}),S.map(v=>s.jsxs("div",{className:"p-3 rounded-lg bg-[#162840] hover:bg-[#1a3050] cursor-pointer transition-colors",onClick:()=>Fa({id:v.id,mid:v.mid,title:v.title,price:v.price??1,filePath:""}),children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[#38bdac] font-mono text-xs",children:v.id}),s.jsx("span",{className:"text-white",children:v.title}),Se.includes(v.id)&&s.jsx(uc,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})]}),s.jsx(Ve,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:v.matchType==="title"?"标题匹配":"内容匹配"})]}),v.snippet&&s.jsx("p",{className:"text-gray-500 text-xs mt-2 line-clamp-2",children:v.snippet}),(v.partTitle||v.chapterTitle)&&s.jsxs("p",{className:"text-gray-600 text-xs mt-1",children:[v.partTitle," · ",v.chapterTitle]})]},v.id))]})]})]})}),s.jsxs(Yt,{value:"ranking",className:"space-y-4",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(rt,{className:"pb-3",children:s.jsxs(at,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(dh,{className:"w-4 h-4 text-[#38bdac]"}),"内容显示规则"]})}),s.jsx(Le,{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(ee,{className:"text-gray-400 text-sm whitespace-nowrap",children:"未付费预览比例"}),s.jsx(de,{type:"number",min:"1",max:"100",className:"bg-[#0a1628] border-gray-700 text-white w-20",value:xt,onChange:v=>L(Math.max(1,Math.min(100,Number(v.target.value)||20))),disabled:Me}),s.jsx("span",{className:"text-gray-500 text-sm",children:"%"})]}),s.jsx(X,{size:"sm",onClick:Uc,disabled:Et,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:Et?"保存中...":"保存"}),s.jsxs("span",{className:"text-xs text-gray-500",children:["小程序未付费用户默认显示文章前 ",xt,"% 内容"]})]})})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(rt,{className:"pb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(at,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(ux,{className:"w-4 h-4 text-amber-400"}),"内容排行榜",s.jsxs("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["按热度排行 · 共 ",St.length," 节"]})]}),s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>hr(),disabled:gn,className:"text-gray-400 hover:text-white h-7 w-7 p-0",title:"刷新排行榜",children:s.jsx(Fe,{className:`w-4 h-4 ${gn?"animate-spin":""}`})}),s.jsx(X,{variant:"ghost",size:"sm",disabled:On<=1||gn,onClick:()=>$n(v=>Math.max(1,v-1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(c5,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-gray-400 min-w-[60px] text-center",children:[On," / ",kt]}),s.jsx(X,{variant:"ghost",size:"sm",disabled:On>=kt||gn,onClick:()=>$n(v=>Math.min(kt,v+1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(Xo,{className:"w-4 h-4"})})]})]})}),s.jsx(Le,{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:"编辑"})]}),oa.map((v,A)=>{const B=(On-1)*Ls+A+1,ue=v.isPinned??Se.includes(v.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 ${ue?"bg-amber-500/5":""}`,children:[s.jsx("span",{className:`text-sm font-bold ${B<=3?"text-amber-400":"text-gray-500"}`,children:B<=3?["🥇","🥈","🥉"][B-1]:`#${B}`}),s.jsx(X,{variant:"ghost",size:"sm",className:`h-6 w-6 p-0 ${ue?"text-amber-400":"text-gray-600 hover:text-amber-400"}`,onClick:()=>pr(v.id),disabled:Xe,title:ue?"取消置顶":"强制置顶(精选推荐/首页最新更新)",children:ue?s.jsx(uc,{className:"w-3.5 h-3.5 fill-current"}):s.jsx(LM,{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:v.title}),s.jsxs("span",{className:"text-gray-600 text-xs",children:[v.partTitle," · ",v.chapterTitle]})]}),s.jsx("span",{className:"text-right text-sm text-blue-400 font-mono",children:v.clickCount??0}),s.jsx("span",{className:"text-right text-sm text-green-400 font-mono",children:v.payCount??0}),s.jsx("span",{className:"text-right text-sm text-amber-400 font-mono",children:(v.hotScore??0).toFixed(1)}),s.jsx("div",{className:"text-right",children:s.jsx(X,{variant:"ghost",size:"sm",className:"text-gray-500 hover:text-[#38bdac] h-6 px-1",onClick:()=>Fa({id:v.id,mid:v.mid,title:v.title,price:v.price,filePath:""}),title:"编辑文章",children:s.jsx(Jt,{className:"w-3 h-3"})})})]},v.id)}),oa.length===0&&s.jsx("div",{className:"py-8 text-center text-gray-500",children:"暂无数据"})]})})]})]}),s.jsxs(Yt,{value:"link-person",className:"space-y-4",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"pb-3",children:[s.jsxs(at,{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(Le,{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(X,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50",onClick:()=>{Bn()},title:"刷新",children:s.jsx(Fe,{className:"w-4 h-4"})}),s.jsxs(X,{size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:()=>{Xs(null),Aa(!0)},children:[s.jsx(An,{className:"w-4 h-4 mr-2"}),"添加"]})]})]}),s.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:tt.length>0?s.jsxs("table",{className:"w-full text-sm border-collapse",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-xs text-gray-500 border-b border-gray-700/50",children:[s.jsx("th",{className:"text-left py-1.5 px-3 w-[280px] font-normal",children:"token"}),s.jsx("th",{className:"text-left py-1.5 px-3 w-24 font-normal",children:"@的人"}),s.jsx("th",{className:"text-left py-1.5 px-3 w-[72px] font-normal text-xs",children:"来源"}),s.jsx("th",{className:"text-left py-1.5 px-3 w-[100px] font-normal text-xs",children:"会员"}),s.jsx("th",{className:"py-1.5 px-3 w-16 font-normal text-center",children:"获客数"}),s.jsx("th",{className:"text-left py-1.5 px-3 font-normal",children:"获客计划"}),s.jsx("th",{className:"text-left py-1.5 px-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:tt.map(v=>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:v.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:()=>{Mt[v.id]&&ps(v.id,v.name)},title:Mt[v.id]?"点击查看获客详情":v.name,children:v.name})}),s.jsx("td",{className:"py-2 px-3",children:v.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:v.userId?s.jsxs("div",{className:"flex flex-col gap-0.5 items-start max-w-[100px]",children:[v.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: ${v.userId}`,onClick:()=>t(`/users?search=${encodeURIComponent(v.userId||"")}`),children:v.name})]}):s.jsx("span",{className:"text-gray-600",children:"—"})}),(()=>{const A=Mt[v.id]||0;return s.jsx("td",{className:`py-2 px-3 shrink-0 w-16 text-center text-xs font-bold cursor-pointer ${A>0?"text-green-400 hover:text-green-300 hover:underline":"text-gray-600"}`,title:A>0?"点击查看获客详情":"暂无获客",onClick:()=>{A>0&&ps(v.id,v.name)},children:A})})(),s.jsx("td",{className:"py-2 px-3 text-white truncate max-w-[220px]",title:`planId: ${v.ckbPlanId??"-"}`,children:s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsx("span",{className:"truncate",children:v.ckbPlanId?v.personSource==="vip_sync"?"超级个体拉群(统一计划)":`SOUL链接人与事-${v.name}`:"—"})})}),s.jsx("td",{className:"py-2 px-3 text-center",children:v.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(X,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-[#38bdac] h-6 px-2",title:"编辑",onClick:async()=>{try{const A=await W9(v.personId||"");if(A!=null&&A.success&&A.person){const B=A.person;Xs({id:B.token??B.personId,personId:B.personId,name:B.name,personSource:B.personSource??"",userId:B.userId??"",label:B.label??"",ckbApiKey:B.ckbApiKey??"",remarkType:B.remarkType,remarkFormat:B.remarkFormat,addFriendInterval:B.addFriendInterval,startTime:B.startTime,endTime:B.endTime,deviceGroups:B.deviceGroups})}else Xs(v),A!=null&&A.error&&se.error(A.error)}catch(A){console.error(A),Xs(v),se.error(A instanceof Error?A.message:"加载人物详情失败")}Aa(!0)},children:s.jsx(c1,{className:"w-3 h-3"})}),s.jsx(X,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-green-400 h-6 px-2",title:"查看新客户",onClick:()=>ps(v.id,v.name),children:s.jsx(In,{className:"w-3 h-3"})}),s.jsx(X,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",title:v.personSource==="vip_sync"?"删除本地 @人物(不删统一获客计划)":"删除(同时删除存客宝对应获客计划)",onClick:()=>vi(v),children:s.jsx(Yn,{className:"w-3 h-3"})})]})})]},v.id))})]}):s.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无AI人物,添加后可在编辑器中 @链接"})})]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"pb-3",children:[s.jsxs(at,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(QM,{className:"w-4 h-4 text-[#38bdac]"}),"存客宝绑定"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"配置存客宝 API 后,文章中 @人物 或 #标签 点击可自动进入存客宝流量池"})]}),s.jsxs(Le,{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(ee,{className:"text-gray-400 text-xs",children:"存客宝 API 地址"}),s.jsx(de,{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(ee,{className:"text-gray-400 text-xs",children:"绑定计划"}),s.jsx(de,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"pb-3",children:[s.jsxs(at,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(dh,{className:"w-4 h-4 text-blue-400"}),"获客 Webhook 通知"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"配置后新获客线索将自动推送到群聊(支持企业微信/飞书 Webhook)"})]}),s.jsxs(Le,{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(ee,{className:"text-gray-400 text-xs",children:"Webhook URL"}),s.jsx(de,{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:ra,onChange:v=>aa(v.target.value)})]}),s.jsxs(X,{size:"sm",className:"bg-blue-500 hover:bg-blue-600 text-white h-8",onClick:async()=>{const v=ra.trim();try{const A=await Ct("/api/db/config",{key:"ckb_lead_webhook_url",value:v,description:"获客线索 Webhook 通知 URL(企微/飞书)"});A!=null&&A.success?se.success(v?"Webhook 已保存":"Webhook 已清除"):se.error((A==null?void 0:A.error)??"保存失败")}catch{se.error("保存失败")}},children:[s.jsx(bn,{className:"w-3.5 h-3.5 mr-1"}),"保存"]})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"配置企业微信或飞书群机器人 Webhook URL,获客成功后自动推送通知"})]})]})]}),s.jsxs(Yt,{value:"link-tag",className:"space-y-4",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"pb-3",children:[s.jsxs(at,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(l1,{className:"w-4 h-4 text-amber-400"}),"链接标签 — 链接事与物(编辑器内 #标签 可跳转链接/小程序/存客宝)"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"小程序端点击 #标签 可直接跳转对应链接,进入流量池"})]}),s.jsxs(Le,{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(ee,{className:"text-gray-400 text-xs",children:"搜索"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-48",placeholder:"按标签ID/显示文字搜索",value:Ss,onChange:v=>{Ys(v.target.value),Er(1)}})]}),s.jsx(X,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50 h-8",onClick:()=>{Vn(),La()},title:"刷新",children:s.jsx(Fe,{className:"w-4 h-4"})})]}),s.jsxs(X,{size:"sm",className:"bg-amber-500 hover:bg-amber-600 text-white h-8",onClick:()=>{ge(null),pt({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",pagePath:""}),_s(""),zs(!1),Cs(!0)},children:[s.jsx(An,{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:bi?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:"加载中..."})}):ts.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:"暂无链接标签,添加后可在编辑器中使用 #标签 跳转"})}):ts.map(v=>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:()=>{ge(v),pt({tagId:v.id,label:v.label,aliases:v.aliases??"",url:v.url,type:v.type,appId:v.appId??"",pagePath:v.pagePath??""}),_s(v.appId??""),zs(!1),Cs(!0)},title:"点击编辑标签",children:["#",v.label]})}),s.jsx("td",{className:"px-3 py-2 text-gray-500 text-xs truncate max-w-[120px]",title:v.aliases||"",children:v.aliases||"—"}),s.jsx("td",{className:"px-3 py-2",children:s.jsx(Ve,{variant:"secondary",className:`text-[10px] ${v.type==="ckb"?"bg-green-500/20 text-green-300 border-green-500/30":v.type==="miniprogram"?"bg-[#38bdac]/20 text-[#38bdac] border-[#38bdac]/30":"bg-gray-700 text-gray-300"}`,children:v.type==="url"?"网页":v.type==="ckb"?"存客宝":"小程序"})}),s.jsx("td",{className:"px-3 py-2 text-gray-300",children:v.type==="miniprogram"?s.jsxs("div",{className:"space-y-0.5",children:[(()=>{const A=Da.find(B=>B.key===v.appId);return s.jsxs(s.Fragment,{children:[A&&s.jsx("div",{className:"text-xs text-white",children:A.name}),s.jsxs("div",{className:"text-xs font-mono text-[#38bdac]",children:["AppID: ",(A==null?void 0:A.appId)||v.appId||"—"]})]})})(),v.pagePath&&s.jsx("div",{className:"text-xs text-gray-500 font-mono",children:v.pagePath})]}):v.url?s.jsxs("a",{href:v.url,target:"_blank",rel:"noreferrer",className:"text-blue-400 text-xs truncate max-w-[420px] hover:underline inline-flex items-center gap-1",children:[v.url," ",s.jsx(fi,{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(X,{variant:"ghost",size:"sm",className:"text-gray-300 hover:text-white h-7 px-2",onClick:()=>{ge(v),pt({tagId:v.id,label:v.label,aliases:v.aliases??"",url:v.url,type:v.type,appId:v.appId??"",pagePath:v.pagePath??""}),_s(v.appId??""),zs(!1),Cs(!0)},title:"编辑",children:s.jsx(c1,{className:"w-3 h-3"})}),s.jsx(X,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-7 px-2",onClick:async()=>{if(confirm(`确定要删除「#${v.label}」吗?`))try{const A=await li(`/api/db/link-tags?tagId=${encodeURIComponent(v.id)}`);A!=null&&A.success?(se.success("已删除"),Vn(),La()):se.error((A==null?void 0:A.error)??"删除失败")}catch(A){console.error(A),se.error("删除失败")}},title:"删除",children:s.jsx(Yn,{className:"w-3 h-3"})})]})})]},v.id))})]})}),s.jsx(Ks,{page:ta,pageSize:Mr,total:cr,totalPages:Ea,onPageChange:v=>Er(v),onPageSizeChange:v=>{Ar(v),Er(1)}})]})]})]}),s.jsx(Dt,{open:ur,onOpenChange:Cs,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg p-4 gap-3",children:[s.jsxs(_t,{className:"gap-1",children:[s.jsx(zt,{className:"text-base",children:ie?"编辑链接标签":"添加链接标签"}),s.jsx(Zh,{className:"text-gray-400 text-xs",children:"配置后可在富文本编辑器中通过 #标签 插入,并在小程序端点击跳转"})]}),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(ee,{className:"text-gray-300 text-sm",children:"标签ID"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"留空自动生成;或填 12位数字 / z开头12位",value:Qe.tagId,disabled:!!ie,onChange:v=>pt(A=>({...A,tagId:v.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"显示文字"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"如 神仙团队",value:Qe.label,onChange:v=>pt(A=>({...A,label:v.target.value}))})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"别名(多个用逗号分隔,同指向一个目标)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"如 团队招募, 团队合伙人",value:Qe.aliases,onChange:v=>pt(A=>({...A,aliases:v.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(ee,{className:"text-gray-300 text-sm",children:"类型"}),s.jsxs(lc,{value:Qe.type,onValueChange:v=>pt(A=>({...A,type:v})),children:[s.jsx(Qo,{className:"bg-[#0a1628] border-gray-700 text-white h-8",children:s.jsx(cc,{})}),s.jsxs(Yo,{className:"bg-[#0f2137] border-gray-700 text-white",children:[s.jsx(sr,{value:"url",children:"网页链接"}),s.jsx(sr,{value:"miniprogram",children:"小程序"}),s.jsx(sr,{value:"ckb",children:"存客宝"})]})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:Qe.type==="url"?"URL地址":Qe.type==="ckb"?"存客宝计划URL":"小程序(选密钥)"}),Qe.type==="miniprogram"&&Da.length>0?s.jsxs("div",{ref:El,className:"relative",children:[s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"搜索名称或密钥",value:Zs?za:Qe.appId,onChange:v=>{const A=v.target.value;_s(A),zs(!0),Da.some(B=>B.key===A)||pt(B=>({...B,appId:A}))},onFocus:()=>{_s(Qe.appId),zs(!0)},onBlur:()=>setTimeout(()=>zs(!1),150)}),Zs&&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:Dr.length===0?s.jsx("div",{className:"px-3 py-2 text-gray-500 text-xs",children:"无匹配,可手动输入密钥"}):Dr.map(v=>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:A=>{A.preventDefault(),pt(B=>({...B,appId:v.key,pagePath:v.path||""})),_s(""),zs(!1)},children:[s.jsx("span",{children:v.name}),s.jsx("span",{className:"text-xs text-gray-400 font-mono",children:v.key})]},v.key))})]}):s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:Qe.type==="url"?"https://...":Qe.type==="ckb"?"https://ckbapi.quwanzhi.com/...":"关联小程序的32位密钥",value:Qe.type==="url"||Qe.type==="ckb"?Qe.url:Qe.appId,onChange:v=>{Qe.type==="url"||Qe.type==="ckb"?pt(A=>({...A,url:v.target.value})):pt(A=>({...A,appId:v.target.value}))}})]})]}),Qe.type==="miniprogram"&&s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"页面路径(可选)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"pages/index/index",value:Qe.pagePath,onChange:v=>pt(A=>({...A,pagePath:v.target.value}))})]})]}),s.jsxs(fn,{className:"gap-2 pt-1",children:[s.jsx(X,{variant:"outline",onClick:()=>Cs(!1),className:"border-gray-600",children:"取消"}),s.jsx(X,{onClick:async()=>{const v={tagId:Qe.tagId.trim(),label:Qe.label.trim(),aliases:Qe.aliases.trim(),url:Qe.url.trim(),type:Qe.type,appId:Qe.appId.trim(),pagePath:Qe.pagePath.trim()};if(v.tagId&&!(/^\d{12}$/.test(v.tagId)||/^z[a-z0-9]{11}$/.test(v.tagId))){se.error("标签ID需为12位数字,或 z 开头的12位(z+11位小写字母数字)");return}if(!v.label){se.error("显示文字必填");return}v.type==="miniprogram"&&(v.url=""),Ps(!0);try{const A=await Ct("/api/db/link-tags",v);A!=null&&A.success?(se.success(ie?"已更新":"已添加"),Cs(!1),Vn(),La()):se.error((A==null?void 0:A.error)??"保存失败")}catch(A){console.error(A),se.error("保存失败")}finally{Ps(!1)}},disabled:Fn,className:"bg-amber-500 hover:bg-amber-600 text-white",children:Fn?"保存中...":"保存"})]})]})})]})]}),s.jsx(q9,{open:Ma,onOpenChange:Aa,editingPerson:To,onSubmit:async v=>{var ue;const A={personId:v.personId||v.name.toLowerCase().replace(/\s+/g,"_")+"_"+Date.now().toString(36),name:v.name,userId:v.boundUserId,aliases:v.aliases||void 0,label:v.label,ckbApiKey:v.ckbApiKey||void 0,greeting:v.greeting||void 0,tips:v.tips||void 0,remarkType:v.remarkType||void 0,remarkFormat:v.remarkFormat||void 0,addFriendInterval:v.addFriendInterval,startTime:v.startTime||void 0,endTime:v.endTime||void 0,deviceGroups:(ue=v.deviceGroups)!=null&&ue.trim()?v.deviceGroups.split(",").map(we=>parseInt(we.trim(),10)).filter(we=>!Number.isNaN(we)):void 0},B=await Ct("/api/db/persons",A);if(B&&B.success===!1){const we=B;we.ckbResponse&&console.log("存客宝返回",we.ckbResponse);const De=we.error||"操作失败";throw new Error(De)}if(Bn(),se.success(To?"已保存":"已添加"),B!=null&&B.ckbCreateResult&&Object.keys(B.ckbCreateResult).length>0){const we=B.ckbCreateResult;console.log("存客宝创建结果",we);const De=we.planId??we.id,it=De!=null?[`planId: ${De}`]:[];we.apiKey!=null&&it.push("apiKey: ***"),se.info(it.length?`存客宝创建结果:${it.join(",")}`:"存客宝创建结果见控制台")}}}),s.jsx(Dt,{open:!!Ts,onOpenChange:v=>{v||vi(null)},children:s.jsxs(Lt,{showCloseButton:!0,className:"bg-[#0f2137] border-gray-700 text-white max-w-md p-4 gap-3",children:[s.jsxs(_t,{className:"gap-1",children:[s.jsx(zt,{className:"text-white text-base",children:"确认删除"}),s.jsx(Zh,{className:"text-gray-400 text-sm leading-relaxed wrap-break-word",children:Ts&&s.jsxs(s.Fragment,{children:[Ts.personSource==="vip_sync"?s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:["确定删除超级个体「",Ts.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链接人与事-",Ts.name,"」?将同时删除存客宝对应获客计划。"]})}),s.jsxs("p",{className:"mt-1.5",children:["二次确认:删除后无法恢复,文章中的 @",Ts.name," 将无法正常跳转。"]})]})})]}),s.jsxs(fn,{className:"gap-2 sm:gap-2 pt-1",children:[s.jsx(X,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300",onClick:()=>vi(null),children:"取消"}),s.jsx(X,{variant:"destructive",size:"sm",className:"bg-red-600 hover:bg-red-700",onClick:async()=>{Ts&&(await li(`/api/db/persons?personId=${Ts.personId}`),vi(null),Bn(),se.success("已删除"))},children:"确定删除"})]})]})}),s.jsx(Dt,{open:Ir,onOpenChange:Ni,children:s.jsxs(Lt,{className:"max-w-2xl bg-[#0f2137] border-gray-700",children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(In,{className:"w-5 h-5 text-green-400"}),Ia," — 获客详情(共 ",qn," 条)"]})}),s.jsx("div",{className:"max-h-[450px] overflow-y-auto space-y-2",children:wi?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Fe,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):ns.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:"时间"})]}),ns.map((v,A)=>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:(Pr-1)*20+A+1}),s.jsx("span",{className:"text-white truncate",children:v.nickname||v.name||v.userId||"-"}),s.jsx("span",{className:"text-gray-300 text-xs",children:v.phone||"-"}),s.jsx("span",{className:"text-gray-300 text-xs truncate",children:v.wechatId||"-"}),s.jsx("span",{className:"text-xs",children:v.source==="article_mention"?s.jsx("span",{className:"text-purple-400",children:"文章@"}):v.source==="index_lead"?s.jsx("span",{className:"text-blue-400",children:"首页"}):s.jsx("span",{className:"text-gray-500",children:v.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:v.createdAt?new Date(v.createdAt).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-"})]},v.id))]})}),qn>20&&s.jsxs("div",{className:"flex items-center justify-center gap-2 pt-2",children:[s.jsx(X,{size:"sm",variant:"outline",disabled:Pr<=1,onClick:()=>ps(Rr,Ia,Pr-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:[Pr," / ",Math.ceil(qn/20)]}),s.jsx(X,{size:"sm",variant:"outline",disabled:Pr>=Math.ceil(qn/20),onClick:()=>ps(Rr,Ia,Pr+1),className:"border-gray-600 text-gray-300 bg-transparent h-7 px-3",children:"下一页"})]})]})})]})}const ii={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 Qw(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):ii.stats}function Yw(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?e:String(e??"")).filter(Boolean):ii.highlights}function Q9(){const[t,e]=b.useState(ii),[n,r]=b.useState(!0),[a,i]=b.useState(!1),[o,c]=b.useState(!1),u=b.useRef(null);b.useEffect(()=>{Pe("/api/admin/author-settings").then(S=>{const E=S==null?void 0:S.data;E&&typeof E=="object"&&e({name:String(E.name??ii.name),avatar:String(E.avatar??ii.avatar),avatarImg:String(E.avatarImg??""),title:String(E.title??ii.title),bio:String(E.bio??ii.bio),stats:Qw(E.stats).length?Qw(E.stats):ii.stats,highlights:Yw(E.highlights).length?Yw(E.highlights):ii.highlights})}).catch(console.error).finally(()=>r(!1))},[]);const h=async()=>{i(!0);try{const S={name:t.name,avatar:t.avatar||"K",avatarImg:t.avatarImg,title:t.title,bio:t.bio,stats:t.stats.filter(P=>P.label||P.value),highlights:t.highlights.filter(Boolean)},E=await Ct("/api/admin/author-settings",S);if(!E||E.success===!1){se.error("保存失败: "+(E&&typeof E=="object"&&"error"in E?E.error:""));return}i(!1);const T=document.createElement("div");T.className="fixed top-4 right-4 z-50 px-4 py-2 rounded-lg bg-[#38bdac] text-white text-sm shadow-lg",T.textContent="作者设置已保存",document.body.appendChild(T),setTimeout(()=>T.remove(),2e3)}catch(S){console.error(S),se.error("保存失败: "+(S instanceof Error?S.message:String(S)))}finally{i(!1)}},f=async S=>{var T;const E=(T=S.target.files)==null?void 0:T[0];if(E){c(!0);try{const P=new FormData;P.append("file",E),P.append("folder","avatars");const O=iu(),q={};O&&(q.Authorization=`Bearer ${O}`);const V=await(await fetch(wc("/api/upload"),{method:"POST",body:P,credentials:"include",headers:q})).json();V!=null&&V.success&&(V!=null&&V.url)?e(I=>({...I,avatarImg:V.url})):se.error("上传失败: "+((V==null?void 0:V.error)||"未知错误"))}catch(P){console.error(P),se.error("上传失败")}finally{c(!1),u.current&&(u.current.value="")}}},m=()=>e(S=>({...S,stats:[...S.stats,{label:"",value:""}]})),g=S=>e(E=>({...E,stats:E.stats.filter((T,P)=>P!==S)})),y=(S,E,T)=>e(P=>({...P,stats:P.stats.map((O,q)=>q===S?{...O,[E]:T}:O)})),N=()=>e(S=>({...S,highlights:[...S.highlights,""]})),w=S=>e(E=>({...E,highlights:E.highlights.filter((T,P)=>P!==S)})),j=(S,E)=>e(T=>({...T,highlights:T.highlights.map((P,O)=>O===S?E:P)}));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(oi,{className:"w-5 h-5 text-[#38bdac]"}),"作者详情"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置小程序「关于作者」页展示的作者信息,包括头像、简介、统计数据与亮点标签。"})]}),s.jsxs(X,{onClick:h,disabled:a||n,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"flex items-center gap-2 text-white",children:[s.jsx(oi,{className:"w-4 h-4 text-[#38bdac]"}),"基本信息"]}),s.jsx(Kt,{className:"text-gray-400",children:"作者姓名、头像、头衔与个人简介,将展示在「关于作者」页顶部。"})]}),s.jsxs(Le,{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(ee,{className:"text-gray-300",children:"姓名"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.name,onChange:S=>e(E=>({...E,name:S.target.value})),placeholder:"卡若"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"首字母占位(无头像时显示)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white w-20",value:t.avatar,onChange:S=>e(E=>({...E,avatar:S.target.value.slice(0,1)||"K"})),placeholder:"K"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ee,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Mj,{className:"w-3 h-3 text-[#38bdac]"}),"头像图片"]}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(de,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:t.avatarImg,onChange:S=>e(E=>({...E,avatarImg:S.target.value})),placeholder:"上传或粘贴 URL,如 /uploads/avatars/xxx.png"}),s.jsx("input",{ref:u,type:"file",accept:"image/*",className:"hidden",onChange:f}),s.jsxs(X,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:o,onClick:()=>{var S;return(S=u.current)==null?void 0:S.click()},children:[s.jsx(Jh,{className:"w-4 h-4 mr-2"}),o?"上传中...":"上传"]})]}),t.avatarImg&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:fo(t.avatarImg.startsWith("http")?t.avatarImg:wc(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(ee,{className:"text-gray-300",children:"头衔"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.title,onChange:S=>e(E=>({...E,title:S.target.value})),placeholder:"Soul派对房主理人 · 私域运营专家"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"个人简介"}),s.jsx(hl,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[120px]",value:t.bio,onChange:S=>e(E=>({...E,bio:S.target.value})),placeholder:"每天早上6点到9点..."})]})]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsx(at,{className:"text-white",children:"统计数据"}),s.jsx(Kt,{className:"text-gray-400",children:"展示在作者卡片中的数字指标,如「商业案例 62」「连续直播 365天」。第一个「商业案例」的值可由书籍统计自动更新。"})]}),s.jsxs(Le,{className:"space-y-3",children:[t.stats.map((S,E)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(de,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:S.label,onChange:T=>y(E,"label",T.target.value),placeholder:"标签"}),s.jsx(de,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:S.value,onChange:T=>y(E,"value",T.target.value),placeholder:"数值"}),s.jsx(X,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>g(E),children:s.jsx(Yn,{className:"w-4 h-4"})})]},E)),s.jsxs(X,{variant:"outline",size:"sm",onClick:m,className:"border-gray-600 text-gray-400",children:[s.jsx(An,{className:"w-4 h-4 mr-2"}),"添加统计项"]})]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsx(at,{className:"text-white",children:"亮点标签"}),s.jsx(Kt,{className:"text-gray-400",children:"作者优势或成就的简短描述,以标签形式展示。"})]}),s.jsxs(Le,{className:"space-y-3",children:[t.highlights.map((S,E)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(de,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:S,onChange:T=>j(E,T.target.value),placeholder:"5年私域运营经验"}),s.jsx(X,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>w(E),children:s.jsx(Yn,{className:"w-4 h-4"})})]},E)),s.jsxs(X,{variant:"outline",size:"sm",onClick:N,className:"border-gray-600 text-gray-400",children:[s.jsx(An,{className:"w-4 h-4 mr-2"}),"添加亮点"]})]})]})]})]})}function Y9(t){return confirm(`确定删除该${t}?此操作不可恢复。`)?window.prompt(`请输入「删除」以确认删除${t}`)==="删除":!1}function X9(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[a,i]=b.useState(1),[o]=b.useState(10),[c,u]=b.useState(0),[h,f]=b.useState(""),m=ef(h,300),[g,y]=b.useState(!0),[N,w]=b.useState(null),[j,S]=b.useState(!1),[E,T]=b.useState(null),[P,O]=b.useState(""),[q,z]=b.useState(""),[V,I]=b.useState(""),[te,Q]=b.useState("admin"),[F,re]=b.useState("active"),[ae,J]=b.useState(!1);async function $(){var U;y(!0),w(null);try{const H=new URLSearchParams({page:String(a),pageSize:String(o)});m.trim()&&H.set("search",m.trim());const K=await Pe(`/api/admin/users?${H}`);K!=null&&K.success?(e(K.records||[]),r(K.total??0),u(K.totalPages??0)):w(K.error||"加载失败")}catch(H){const K=H;w(K.status===403?"无权限访问":((U=K==null?void 0:K.data)==null?void 0:U.error)||"加载失败"),e([])}finally{y(!1)}}b.useEffect(()=>{$()},[a,o,m]);const D=()=>{T(null),O(""),z(""),I(""),Q("admin"),re("active"),S(!0)},R=U=>{T(U),O(U.username),z(""),I(U.name||""),Q(U.role==="super_admin"?"super_admin":"admin"),re(U.status==="disabled"?"disabled":"active"),S(!0)},oe=async()=>{var U;if(!P.trim()){w("用户名不能为空");return}if(!E&&!q){w("新建时密码必填,至少 6 位");return}if(q&&q.length<6){w("密码至少 6 位");return}w(null),J(!0);try{if(E){const H=await Gt("/api/admin/users",{id:E.id,password:q||void 0,name:V.trim(),role:te,status:F});H!=null&&H.success?(S(!1),$()):w((H==null?void 0:H.error)||"保存失败")}else{const H=await Ct("/api/admin/users",{username:P.trim(),password:q,name:V.trim(),role:te});H!=null&&H.success?(S(!1),$()):w((H==null?void 0:H.error)||"保存失败")}}catch(H){const K=H;w(((U=K==null?void 0:K.data)==null?void 0:U.error)||"保存失败")}finally{J(!1)}},G=async U=>{var H;if(!Y9("管理员")){w("已取消删除");return}try{const K=await li(`/api/admin/users?id=${U}`);K!=null&&K.success?$():w((K==null?void 0:K.error)||"删除失败")}catch(K){const me=K;w(((H=me==null?void 0:me.data)==null?void 0:H.error)||"删除失败")}},_=U=>{if(!U)return"-";try{const H=new Date(U);return isNaN(H.getTime())?U:H.toLocaleString("zh-CN")}catch{return U}};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(dc,{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(de,{placeholder:"搜索用户名/昵称",value:h,onChange:U=>f(U.target.value),className:"w-48 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"}),s.jsx(X,{variant:"outline",size:"sm",onClick:$,disabled:g,className:"border-gray-600 text-gray-300",children:s.jsx(Fe,{className:`w-4 h-4 ${g?"animate-spin":""}`})}),s.jsxs(X,{onClick:D,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(An,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Le,{className:"p-0",children:g?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(s.Fragment,{children:[s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"ID"}),s.jsx(je,{className:"text-gray-400",children:"用户名"}),s.jsx(je,{className:"text-gray-400",children:"昵称"}),s.jsx(je,{className:"text-gray-400",children:"角色"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-gray-400",children:"创建时间"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(hs,{children:[t.map(U=>s.jsxs(ct,{className:"border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:U.id}),s.jsx(be,{className:"text-white font-medium",children:U.username}),s.jsx(be,{className:"text-gray-400",children:U.name||"-"}),s.jsx(be,{children:s.jsx(Ve,{variant:"outline",className:U.role==="super_admin"?"border-amber-500/50 text-amber-400":"border-gray-600 text-gray-400",children:U.role==="super_admin"?"超级管理员":"管理员"})}),s.jsx(be,{children:s.jsx(Ve,{variant:"outline",className:U.status==="active"?"border-[#38bdac]/50 text-[#38bdac]":"border-gray-500 text-gray-500",children:U.status==="active"?"正常":"已禁用"})}),s.jsx(be,{className:"text-gray-500 text-sm",children:_(U.createdAt)}),s.jsxs(be,{className:"text-right",children:[s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>R(U),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(Jt,{className:"w-4 h-4"})}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>G(U.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(bs,{className:"w-4 h-4"})})]})]},U.id)),t.length===0&&!g&&s.jsx(ct,{children:s.jsx(be,{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(Ks,{page:a,pageSize:o,total:n,totalPages:c,onPageChange:i})})]})})}),s.jsx(Dt,{open:j,onOpenChange:S,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(_t,{children:s.jsx(zt,{className:"text-white",children:E?"编辑管理员":"新增管理员"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"用户名"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"登录用户名",value:P,onChange:U=>O(U.target.value),disabled:!!E}),E&&s.jsx("p",{className:"text-xs text-gray-500",children:"用户名不可修改"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:E?"新密码(留空不改)":"密码"}),s.jsx(de,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:E?"留空表示不修改":"至少 6 位",value:q,onChange:U=>z(U.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"昵称"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"显示名称",value:V,onChange:U=>I(U.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"角色"}),s.jsxs("select",{value:te,onChange:U=>Q(U.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:"超级管理员"})]})]}),E&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"状态"}),s.jsxs("select",{value:F,onChange:U=>re(U.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(fn,{children:[s.jsxs(X,{variant:"outline",onClick:()=>S(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(X,{onClick:oe,disabled:ae,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),ae?"保存中...":"保存"]})]})]})})]})}function jn({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 m4(){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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(rt,{className:"pb-3",children:s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(cx,{className:"w-5 h-5 text-[#38bdac]"}),"1. Authentication"]})}),s.jsx(Le,{className:"space-y-4",children:s.jsx(jn,{method:"POST",url:"/api/admin",desc:"登录,返回 JWT token",headers:["Content-Type: application/json"],body:`{ + `).join(""),e.querySelectorAll(".mention-item").forEach(o=>{o.addEventListener("click",()=>{const c=parseInt(o.getAttribute("data-index")||"0");a&&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 LF(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=b.useRef(null),f=b.useRef(null),m=b.useRef(null),x=b.useRef(null),[y,N]=b.useState(""),[w,j]=b.useState(!1),S=b.useRef(Ow(t)),E=b.useCallback((Q,F)=>{var $;const re=x.current;if(!re||!n)return!1;const ie=LF(F);if(ie.length>0)return F.preventDefault(),(async()=>{for(const D of ie)try{const R=await n(D);R&&re.chain().focus().setImage({src:R}).run()}catch(R){console.error("粘贴图片上传失败",R)}})(),!0;const J=($=F.clipboardData)==null?void 0:$.getData("text/html");if(J&&/data:image\/[^;"']+;base64,/i.test(J)){F.preventDefault();const{from:D,to:R}=re.state.selection;return(async()=>{try{const oe=await zF(J,n);re.chain().focus().insertContentAt({from:D,to:R},oe).run()}catch(oe){console.error("粘贴 HTML 内 base64 转换失败",oe)}})(),!0}return!1},[n]),T=S7({extensions:[h$.configure({link:{openOnClick:!1,HTMLAttributes:{class:"rich-link"}}}),m$.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"rich-editor-img-thumb"}}),RF,N$.configure({HTMLAttributes:{class:"mention-tag"},suggestion:OF(a)}),PF,w$.configure({placeholder:o}),m3.configure({resizable:!0}),p3,h3,f3],content:S.current,onUpdate:({editor:Q})=>{e(Q.getHTML())},editorProps:{attributes:{class:"rich-editor-content"},handlePaste:E}});b.useEffect(()=>{x.current=T??null},[T]),b.useImperativeHandle(u,()=>({getHTML:()=>(T==null?void 0:T.getHTML())||"",getMarkdown:()=>IF((T==null?void 0:T.getHTML())||"")})),b.useEffect(()=>{if(T&&t!==T.getHTML()){const Q=Ow(t);Q!==T.getHTML()&&T.commands.setContent(Q)}},[t]);const P=b.useCallback(async Q=>{if(r)return r(Q);if(n)return n(Q);throw new Error("未配置上传")},[n,r]),O=b.useCallback(async Q=>{var re;const F=(re=Q.target.files)==null?void 0:re[0];if(!(!F||!T)){if(n){const ie=await n(F);ie&&T.chain().focus().setImage({src:ie}).run()}else{const ie=new FileReader;ie.onload=()=>{typeof ie.result=="string"&&T.chain().focus().setImage({src:ie.result}).run()},ie.readAsDataURL(F)}Q.target.value=""}},[T,n]),q=b.useCallback(async Q=>{var re;const F=(re=Q.target.files)==null?void 0:re[0];if(!(!F||!T)){try{const ie=await P(F);ie&&T.chain().focus().insertContent({type:"videoEmbed",attrs:{src:ie}}).run()}catch(ie){console.error(ie)}Q.target.value=""}},[T,P]),z=b.useCallback(async Q=>{var re;const F=(re=Q.target.files)==null?void 0:re[0];if(!(!F||!T)){try{const ie=await P(F);if(!ie)return;const J=F.name||"附件";T.chain().focus().insertContent(`

附件 ${MF(J)}

`).run()}catch(ie){console.error(ie)}Q.target.value=""}},[T,P]),V=b.useCallback(()=>{T&&T.chain().focus().insertContent("@").run()},[T]),I=b.useCallback(Q=>{T&&T.chain().focus().insertContent([{type:"linkTag",attrs:{label:Q.label,url:Q.url||"",tagType:Q.type||"url",tagId:Q.id||"",pagePath:Q.pagePath||"",appId:Q.appId||"",mpKey:Q.type==="miniprogram"&&Q.appId||""}},{type:"text",text:" "}]).run()},[T]),te=b.useCallback(()=>{!T||!y||(T.chain().focus().setLink({href:y}).run(),N(""),j(!1))},[T,y]);return T?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:()=>T.chain().focus().toggleBold().run(),className:T.isActive("bold")?"is-active":"",type:"button",children:s.jsx(n5,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().toggleItalic().run(),className:T.isActive("italic")?"is-active":"",type:"button",children:s.jsx(tM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().toggleStrike().run(),className:T.isActive("strike")?"is-active":"",type:"button",children:s.jsx(iA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().toggleCode().run(),className:T.isActive("code")?"is-active":"",type:"button",children:s.jsx(N5,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>T.chain().focus().toggleHeading({level:1}).run(),className:T.isActive("heading",{level:1})?"is-active":"",type:"button",children:s.jsx(W5,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().toggleHeading({level:2}).run(),className:T.isActive("heading",{level:2})?"is-active":"",type:"button",children:s.jsx(q5,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().toggleHeading({level:3}).run(),className:T.isActive("heading",{level:3})?"is-active":"",type:"button",children:s.jsx(J5,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>T.chain().focus().toggleBulletList().run(),className:T.isActive("bulletList")?"is-active":"",type:"button",children:s.jsx(hM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().toggleOrderedList().run(),className:T.isActive("orderedList")?"is-active":"",type:"button",children:s.jsx(dM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().toggleBlockquote().run(),className:T.isActive("blockquote")?"is-active":"",type:"button",children:s.jsx($M,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().setHorizontalRule().run(),type:"button",children:s.jsx(jM,{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:O,className:"hidden"}),s.jsx("input",{ref:f,type:"file",accept:"video/*",onChange:q,className:"hidden"}),s.jsx("input",{ref:m,type:"file",onChange:z,className:"hidden"}),s.jsx("button",{onClick:()=>{var Q;return(Q=h.current)==null?void 0:Q.click()},type:"button",title:"上传图片",children:s.jsx(Mj,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{var Q;return(Q=f.current)==null?void 0:Q.click()},type:"button",title:"上传视频",disabled:!r&&!n,children:s.jsx(NA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{var Q;return(Q=m.current)==null?void 0:Q.click()},type:"button",title:"上传附件(生成下载链接)",disabled:!r&&!n,children:s.jsx(EM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:V,type:"button",title:"插入 @ 并选择人物",className:a.length?"mention-trigger-btn":"",disabled:a.length===0,children:s.jsx(ZE,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>j(!w),className:T.isActive("link")?"is-active":"",type:"button",title:"链接",children:s.jsx(dg,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),type:"button",title:"表格",children:s.jsx(lA,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>T.chain().focus().undo().run(),disabled:!T.can().undo(),type:"button",children:s.jsx(mA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>T.chain().focus().redo().run(),disabled:!T.can().redo(),type:"button",children:s.jsx(BM,{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:Q=>{const F=i.find(re=>re.id===Q.target.value);F&&I(F),Q.target.value=""},defaultValue:"",children:[s.jsx("option",{value:"",disabled:!0,children:"# 插入链接标签"}),i.map(Q=>s.jsx("option",{value:Q.id,children:Q.label},Q.id))]})})]})]}),w&&s.jsxs("div",{className:"link-input-bar",children:[s.jsx("input",{type:"url",placeholder:"输入链接地址...",value:y,onChange:Q=>N(Q.target.value),onKeyDown:Q=>Q.key==="Enter"&&te(),className:"link-input"}),s.jsx("button",{onClick:te,className:"link-confirm",type:"button",children:"确定"}),s.jsx("button",{onClick:()=>{T.chain().focus().unsetLink().run(),j(!1)},className:"link-remove",type:"button",children:"移除"})]}),s.jsx(CC,{editor:T})]}):null});n0.displayName="RichEditor";const $F=["top","right","bottom","left"],go=Math.min,rr=Math.max,Kf=Math.round,Oh=Math.floor,Na=t=>({x:t,y:t}),FF={left:"right",right:"left",bottom:"top",top:"bottom"},BF={start:"end",end:"start"};function s0(t,e,n){return rr(t,go(e,n))}function mi(t,e){return typeof t=="function"?t(e):t}function xi(t){return t.split("-")[0]}function zc(t){return t.split("-")[1]}function wy(t){return t==="x"?"y":"x"}function jy(t){return t==="y"?"height":"width"}const VF=new Set(["top","bottom"]);function ba(t){return VF.has(xi(t))?"y":"x"}function ky(t){return wy(ba(t))}function HF(t,e,n){n===void 0&&(n=!1);const r=zc(t),a=ky(t),i=jy(a);let o=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=qf(o)),[o,qf(o)]}function UF(t){const e=qf(t);return[r0(t),e,r0(e)]}function r0(t){return t.replace(/start|end/g,e=>BF[e])}const Dw=["left","right"],_w=["right","left"],WF=["top","bottom"],KF=["bottom","top"];function qF(t,e,n){switch(t){case"top":case"bottom":return n?e?_w:Dw:e?Dw:_w;case"left":case"right":return e?WF:KF;default:return[]}}function GF(t,e,n,r){const a=zc(t);let i=qF(xi(t),n==="start",r);return a&&(i=i.map(o=>o+"-"+a),e&&(i=i.concat(i.map(r0)))),i}function qf(t){return t.replace(/left|right|bottom|top/g,e=>FF[e])}function JF(t){return{top:0,right:0,bottom:0,left:0,...t}}function x3(t){return typeof t!="number"?JF(t):{top:t,right:t,bottom:t,left:t}}function Gf(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 zw(t,e,n){let{reference:r,floating:a}=t;const i=ba(e),o=ky(e),c=jy(o),u=xi(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 y;switch(u){case"top":y={x:f,y:r.y-a.height};break;case"bottom":y={x:f,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:m};break;case"left":y={x:r.x-a.width,y:m};break;default:y={x:r.x,y:r.y}}switch(zc(e)){case"start":y[o]-=x*(n&&h?-1:1);break;case"end":y[o]+=x*(n&&h?-1:1);break}return y}async function QF(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:y=0}=mi(e,t),N=x3(y),j=c[x?m==="floating"?"reference":"floating":m],S=Gf(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(j)))==null||n?j:j.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:h,rootBoundary:f,strategy:u})),E=m==="floating"?{x:r,y:a,width:o.floating.width,height:o.floating.height}:o.reference,T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),P=await(i.isElement==null?void 0:i.isElement(T))?await(i.getScale==null?void 0:i.getScale(T))||{x:1,y:1}:{x:1,y:1},O=Gf(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:E,offsetParent:T,strategy:u}):E);return{top:(S.top-O.top+N.top)/P.y,bottom:(O.bottom-S.bottom+N.bottom)/P.y,left:(S.left-O.left+N.left)/P.x,right:(O.right-S.right+N.right)/P.x}}const YF=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}=zw(h,r,u),x=r,y={},N=0;for(let j=0;j({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:a,rects:i,platform:o,elements:c,middlewareData:u}=e,{element:h,padding:f=0}=mi(t,e)||{};if(h==null)return{};const m=x3(f),x={x:n,y:r},y=ky(a),N=jy(y),w=await o.getDimensions(h),j=y==="y",S=j?"top":"left",E=j?"bottom":"right",T=j?"clientHeight":"clientWidth",P=i.reference[N]+i.reference[y]-x[y]-i.floating[N],O=x[y]-i.reference[y],q=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let z=q?q[T]:0;(!z||!await(o.isElement==null?void 0:o.isElement(q)))&&(z=c.floating[T]||i.floating[N]);const V=P/2-O/2,I=z/2-w[N]/2-1,te=go(m[S],I),Q=go(m[E],I),F=te,re=z-w[N]-Q,ie=z/2-w[N]/2+V,J=s0(F,ie,re),$=!u.arrow&&zc(a)!=null&&ie!==J&&i.reference[N]/2-(ieie<=0)){var Q,F;const ie=(((Q=i.flip)==null?void 0:Q.index)||0)+1,J=z[ie];if(J&&(!(m==="alignment"?E!==ba(J):!1)||te.every(R=>ba(R.placement)===E?R.overflows[0]>0:!0)))return{data:{index:ie,overflows:te},reset:{placement:J}};let $=(F=te.filter(D=>D.overflows[0]<=0).sort((D,R)=>D.overflows[1]-R.overflows[1])[0])==null?void 0:F.placement;if(!$)switch(y){case"bestFit":{var re;const D=(re=te.filter(R=>{if(q){const oe=ba(R.placement);return oe===E||oe==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(oe=>oe>0).reduce((oe,G)=>oe+G,0)]).sort((R,oe)=>R[1]-oe[1])[0])==null?void 0:re[0];D&&($=D);break}case"initialPlacement":$=c;break}if(a!==$)return{reset:{placement:$}}}return{}}}};function $w(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Fw(t){return $F.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}=mi(t,e);switch(a){case"referenceHidden":{const o=await r.detectOverflow(e,{...i,elementContext:"reference"}),c=$w(o,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:Fw(c)}}}case"escaped":{const o=await r.detectOverflow(e,{...i,altBoundary:!0}),c=$w(o,n.floating);return{data:{escapedOffsets:c,escaped:Fw(c)}}}default:return{}}}}},g3=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=xi(n),c=zc(n),u=ba(n)==="y",h=g3.has(o)?-1:1,f=i&&u?-1:1,m=mi(e,t);let{mainAxis:x,crossAxis:y,alignmentAxis:N}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof N=="number"&&(y=c==="end"?N*-1:N),u?{x:y*f,y:x*h}:{x:x*h,y:y*f}}const nB=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}}}}},sB=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:S=>{let{x:E,y:T}=S;return{x:E,y:T}}},...h}=mi(t,e),f={x:n,y:r},m=await i.detectOverflow(e,h),x=ba(xi(a)),y=wy(x);let N=f[y],w=f[x];if(o){const S=y==="y"?"top":"left",E=y==="y"?"bottom":"right",T=N+m[S],P=N-m[E];N=s0(T,N,P)}if(c){const S=x==="y"?"top":"left",E=x==="y"?"bottom":"right",T=w+m[S],P=w-m[E];w=s0(T,w,P)}const j=u.fn({...e,[y]:N,[x]:w});return{...j,data:{x:j.x-n,y:j.y-r,enabled:{[y]:o,[x]:c}}}}}},rB=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:a,rects:i,middlewareData:o}=e,{offset:c=0,mainAxis:u=!0,crossAxis:h=!0}=mi(t,e),f={x:n,y:r},m=ba(a),x=wy(m);let y=f[x],N=f[m];const w=mi(c,e),j=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(u){const T=x==="y"?"height":"width",P=i.reference[x]-i.floating[T]+j.mainAxis,O=i.reference[x]+i.reference[T]-j.mainAxis;yO&&(y=O)}if(h){var S,E;const T=x==="y"?"width":"height",P=g3.has(xi(a)),O=i.reference[m]-i.floating[T]+(P&&((S=o.offset)==null?void 0:S[m])||0)+(P?0:j.crossAxis),q=i.reference[m]+i.reference[T]+(P?0:((E=o.offset)==null?void 0:E[m])||0)-(P?j.crossAxis:0);Nq&&(N=q)}return{[x]:y,[m]:N}}}},aB=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:a,rects:i,platform:o,elements:c}=e,{apply:u=()=>{},...h}=mi(t,e),f=await o.detectOverflow(e,h),m=xi(a),x=zc(a),y=ba(a)==="y",{width:N,height:w}=i.floating;let j,S;m==="top"||m==="bottom"?(j=m,S=x===(await(o.isRTL==null?void 0:o.isRTL(c.floating))?"start":"end")?"left":"right"):(S=m,j=x==="end"?"top":"bottom");const E=w-f.top-f.bottom,T=N-f.left-f.right,P=go(w-f[j],E),O=go(N-f[S],T),q=!e.middlewareData.shift;let z=P,V=O;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(V=T),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(z=E),q&&!x){const te=rr(f.left,0),Q=rr(f.right,0),F=rr(f.top,0),re=rr(f.bottom,0);y?V=N-2*(te!==0||Q!==0?te+Q:rr(f.left,f.right)):z=w-2*(F!==0||re!==0?F+re:rr(f.top,f.bottom))}await u({...e,availableWidth:V,availableHeight:z});const I=await o.getDimensions(c.floating);return N!==I.width||w!==I.height?{reset:{rects:!0}}:{}}}};function jp(){return typeof window<"u"}function $c(t){return y3(t)?(t.nodeName||"").toLowerCase():"#document"}function lr(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Ta(t){var e;return(e=(y3(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function y3(t){return jp()?t instanceof Node||t instanceof lr(t).Node:!1}function Qr(t){return jp()?t instanceof Element||t instanceof lr(t).Element:!1}function ka(t){return jp()?t instanceof HTMLElement||t instanceof lr(t).HTMLElement:!1}function Bw(t){return!jp()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof lr(t).ShadowRoot}const iB=new Set(["inline","contents"]);function fu(t){const{overflow:e,overflowX:n,overflowY:r,display:a}=Yr(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!iB.has(a)}const oB=new Set(["table","td","th"]);function lB(t){return oB.has($c(t))}const cB=[":popover-open",":modal"];function kp(t){return cB.some(e=>{try{return t.matches(e)}catch{return!1}})}const dB=["transform","translate","scale","rotate","perspective"],uB=["transform","translate","scale","rotate","perspective","filter"],hB=["paint","layout","strict","content"];function Sy(t){const e=Cy(),n=Qr(t)?Yr(t):t;return dB.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)||uB.some(r=>(n.willChange||"").includes(r))||hB.some(r=>(n.contain||"").includes(r))}function fB(t){let e=yo(t);for(;ka(e)&&!Ic(e);){if(Sy(e))return e;if(kp(e))return null;e=yo(e)}return null}function Cy(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const pB=new Set(["html","body","#document"]);function Ic(t){return pB.has($c(t))}function Yr(t){return lr(t).getComputedStyle(t)}function Sp(t){return Qr(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function yo(t){if($c(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Bw(t)&&t.host||Ta(t);return Bw(e)?e.host:e}function b3(t){const e=yo(t);return Ic(e)?t.ownerDocument?t.ownerDocument.body:t.body:ka(e)&&fu(e)?e:b3(e)}function su(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const a=b3(t),i=a===((r=t.ownerDocument)==null?void 0:r.body),o=lr(a);if(i){const c=a0(o);return e.concat(o,o.visualViewport||[],fu(a)?a:[],c&&n?su(c):[])}return e.concat(a,su(a,[],n))}function a0(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function v3(t){const e=Yr(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const a=ka(t),i=a?t.offsetWidth:n,o=a?t.offsetHeight:r,c=Kf(n)!==i||Kf(r)!==o;return c&&(n=i,r=o),{width:n,height:r,$:c}}function Ty(t){return Qr(t)?t:t.contextElement}function yc(t){const e=Ty(t);if(!ka(e))return Na(1);const n=e.getBoundingClientRect(),{width:r,height:a,$:i}=v3(e);let o=(i?Kf(n.width):n.width)/r,c=(i?Kf(n.height):n.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!c||!Number.isFinite(c))&&(c=1),{x:o,y:c}}const mB=Na(0);function N3(t){const e=lr(t);return!Cy()||!e.visualViewport?mB:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function xB(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==lr(t)?!1:e}function vl(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),i=Ty(t);let o=Na(1);e&&(r?Qr(r)&&(o=yc(r)):o=yc(t));const c=xB(i,n,r)?N3(i):Na(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=lr(i),y=r&&Qr(r)?lr(r):r;let N=x,w=a0(N);for(;w&&r&&y!==N;){const j=yc(w),S=w.getBoundingClientRect(),E=Yr(w),T=S.left+(w.clientLeft+parseFloat(E.paddingLeft))*j.x,P=S.top+(w.clientTop+parseFloat(E.paddingTop))*j.y;u*=j.x,h*=j.y,f*=j.x,m*=j.y,u+=T,h+=P,N=lr(w),w=a0(N)}}return Gf({width:f,height:m,x:u,y:h})}function Cp(t,e){const n=Sp(t).scrollLeft;return e?e.left+n:vl(Ta(t)).left+n}function w3(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Cp(t,n),a=n.top+e.scrollTop;return{x:r,y:a}}function gB(t){let{elements:e,rect:n,offsetParent:r,strategy:a}=t;const i=a==="fixed",o=Ta(r),c=e?kp(e.floating):!1;if(r===o||c&&i)return n;let u={scrollLeft:0,scrollTop:0},h=Na(1);const f=Na(0),m=ka(r);if((m||!m&&!i)&&(($c(r)!=="body"||fu(o))&&(u=Sp(r)),ka(r))){const y=vl(r);h=yc(r),f.x=y.x+r.clientLeft,f.y=y.y+r.clientTop}const x=o&&!m&&!i?w3(o,u):Na(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 yB(t){return Array.from(t.getClientRects())}function bB(t){const e=Ta(t),n=Sp(t),r=t.ownerDocument.body,a=rr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=rr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Cp(t);const c=-n.scrollTop;return Yr(r).direction==="rtl"&&(o+=rr(e.clientWidth,r.clientWidth)-a),{width:a,height:i,x:o,y:c}}const Vw=25;function vB(t,e){const n=lr(t),r=Ta(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=Cy();(!f||f&&e==="fixed")&&(c=a.offsetLeft,u=a.offsetTop)}const h=Cp(r);if(h<=0){const f=r.ownerDocument,m=f.body,x=getComputedStyle(m),y=f.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,N=Math.abs(r.clientWidth-m.clientWidth-y);N<=Vw&&(i-=N)}else h<=Vw&&(i+=h);return{width:i,height:o,x:c,y:u}}const NB=new Set(["absolute","fixed"]);function wB(t,e){const n=vl(t,!0,e==="fixed"),r=n.top+t.clientTop,a=n.left+t.clientLeft,i=ka(t)?yc(t):Na(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 Hw(t,e,n){let r;if(e==="viewport")r=vB(t,n);else if(e==="document")r=bB(Ta(t));else if(Qr(e))r=wB(e,n);else{const a=N3(t);r={x:e.x-a.x,y:e.y-a.y,width:e.width,height:e.height}}return Gf(r)}function j3(t,e){const n=yo(t);return n===e||!Qr(n)||Ic(n)?!1:Yr(n).position==="fixed"||j3(n,e)}function jB(t,e){const n=e.get(t);if(n)return n;let r=su(t,[],!1).filter(c=>Qr(c)&&$c(c)!=="body"),a=null;const i=Yr(t).position==="fixed";let o=i?yo(t):t;for(;Qr(o)&&!Ic(o);){const c=Yr(o),u=Sy(o);!u&&c.position==="fixed"&&(a=null),(i?!u&&!a:!u&&c.position==="static"&&!!a&&NB.has(a.position)||fu(o)&&!u&&j3(t,o))?r=r.filter(f=>f!==o):a=c,o=yo(o)}return e.set(t,r),r}function kB(t){let{element:e,boundary:n,rootBoundary:r,strategy:a}=t;const o=[...n==="clippingAncestors"?kp(e)?[]:jB(e,this._c):[].concat(n),r],c=o[0],u=o.reduce((h,f)=>{const m=Hw(e,f,a);return h.top=rr(m.top,h.top),h.right=go(m.right,h.right),h.bottom=go(m.bottom,h.bottom),h.left=rr(m.left,h.left),h},Hw(e,c,a));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function SB(t){const{width:e,height:n}=v3(t);return{width:e,height:n}}function CB(t,e,n){const r=ka(e),a=Ta(e),i=n==="fixed",o=vl(t,!0,i,e);let c={scrollLeft:0,scrollTop:0};const u=Na(0);function h(){u.x=Cp(a)}if(r||!r&&!i)if(($c(e)!=="body"||fu(a))&&(c=Sp(e)),r){const y=vl(e,!0,i,e);u.x=y.x+e.clientLeft,u.y=y.y+e.clientTop}else a&&h();i&&!r&&a&&h();const f=a&&!r&&!i?w3(a,c):Na(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 Qx(t){return Yr(t).position==="static"}function Uw(t,e){if(!ka(t)||Yr(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Ta(t)===n&&(n=n.ownerDocument.body),n}function k3(t,e){const n=lr(t);if(kp(t))return n;if(!ka(t)){let a=yo(t);for(;a&&!Ic(a);){if(Qr(a)&&!Qx(a))return a;a=yo(a)}return n}let r=Uw(t,e);for(;r&&lB(r)&&Qx(r);)r=Uw(r,e);return r&&Ic(r)&&Qx(r)&&!Sy(r)?n:r||fB(t)||n}const TB=async function(t){const e=this.getOffsetParent||k3,n=this.getDimensions,r=await n(t.floating);return{reference:CB(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function EB(t){return Yr(t).direction==="rtl"}const MB={convertOffsetParentRelativeRectToViewportRelativeRect:gB,getDocumentElement:Ta,getClippingRect:kB,getOffsetParent:k3,getElementRects:TB,getClientRects:yB,getDimensions:SB,getScale:yc,isElement:Qr,isRTL:EB};function S3(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function AB(t,e){let n=null,r;const a=Ta(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:y}=h;if(c||e(),!x||!y)return;const N=Oh(m),w=Oh(a.clientWidth-(f+x)),j=Oh(a.clientHeight-(m+y)),S=Oh(f),T={rootMargin:-N+"px "+-w+"px "+-j+"px "+-S+"px",threshold:rr(0,go(1,u))||1};let P=!0;function O(q){const z=q[0].intersectionRatio;if(z!==u){if(!P)return o();z?o(!1,z):r=setTimeout(()=>{o(!1,1e-7)},1e3)}z===1&&!S3(h,t.getBoundingClientRect())&&o(),P=!1}try{n=new IntersectionObserver(O,{...T,root:a.ownerDocument})}catch{n=new IntersectionObserver(O,T)}n.observe(t)}return o(!0),i}function IB(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=Ty(t),f=a||i?[...h?su(h):[],...su(e)]:[];f.forEach(S=>{a&&S.addEventListener("scroll",n,{passive:!0}),i&&S.addEventListener("resize",n)});const m=h&&c?AB(h,n):null;let x=-1,y=null;o&&(y=new ResizeObserver(S=>{let[E]=S;E&&E.target===h&&y&&(y.unobserve(e),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var T;(T=y)==null||T.observe(e)})),n()}),h&&!u&&y.observe(h),y.observe(e));let N,w=u?vl(t):null;u&&j();function j(){const S=vl(t);w&&!S3(w,S)&&n(),w=S,N=requestAnimationFrame(j)}return n(),()=>{var S;f.forEach(E=>{a&&E.removeEventListener("scroll",n),i&&E.removeEventListener("resize",n)}),m==null||m(),(S=y)==null||S.disconnect(),y=null,u&&cancelAnimationFrame(N)}}const RB=nB,PB=sB,OB=ZF,LB=aB,DB=eB,Ww=XF,_B=rB,zB=(t,e,n)=>{const r=new Map,a={platform:MB,...n},i={...a.platform,_c:r};return YF(t,e,{...a,platform:i})};var $B=typeof document<"u",FB=function(){},Uh=$B?b.useLayoutEffect:FB;function Jf(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(!Jf(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)&&!Jf(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function C3(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Kw(t,e){const n=C3(t);return Math.round(e*n)/n}function Yx(t){const e=b.useRef(t);return Uh(()=>{e.current=t}),e}function BB(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:a,elements:{reference:i,floating:o}={},transform:c=!0,whileElementsMounted:u,open:h}=t,[f,m]=b.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[x,y]=b.useState(r);Jf(x,r)||y(r);const[N,w]=b.useState(null),[j,S]=b.useState(null),E=b.useCallback(R=>{R!==q.current&&(q.current=R,w(R))},[]),T=b.useCallback(R=>{R!==z.current&&(z.current=R,S(R))},[]),P=i||N,O=o||j,q=b.useRef(null),z=b.useRef(null),V=b.useRef(f),I=u!=null,te=Yx(u),Q=Yx(a),F=Yx(h),re=b.useCallback(()=>{if(!q.current||!z.current)return;const R={placement:e,strategy:n,middleware:x};Q.current&&(R.platform=Q.current),zB(q.current,z.current,R).then(oe=>{const G={...oe,isPositioned:F.current!==!1};ie.current&&!Jf(V.current,G)&&(V.current=G,au.flushSync(()=>{m(G)}))})},[x,e,n,Q,F]);Uh(()=>{h===!1&&V.current.isPositioned&&(V.current.isPositioned=!1,m(R=>({...R,isPositioned:!1})))},[h]);const ie=b.useRef(!1);Uh(()=>(ie.current=!0,()=>{ie.current=!1}),[]),Uh(()=>{if(P&&(q.current=P),O&&(z.current=O),P&&O){if(te.current)return te.current(P,O,re);re()}},[P,O,re,te,I]);const J=b.useMemo(()=>({reference:q,floating:z,setReference:E,setFloating:T}),[E,T]),$=b.useMemo(()=>({reference:P,floating:O}),[P,O]),D=b.useMemo(()=>{const R={position:n,left:0,top:0};if(!$.floating)return R;const oe=Kw($.floating,f.x),G=Kw($.floating,f.y);return c?{...R,transform:"translate("+oe+"px, "+G+"px)",...C3($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:oe,top:G}},[n,c,$.floating,f.x,f.y]);return b.useMemo(()=>({...f,update:re,refs:J,elements:$,floatingStyles:D}),[f,re,J,$,D])}const VB=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?Ww({element:r.current,padding:a}).fn(n):{}:r?Ww({element:r,padding:a}).fn(n):{}}}},HB=(t,e)=>({...RB(t),options:[t,e]}),UB=(t,e)=>({...PB(t),options:[t,e]}),WB=(t,e)=>({..._B(t),options:[t,e]}),KB=(t,e)=>({...OB(t),options:[t,e]}),qB=(t,e)=>({...LB(t),options:[t,e]}),GB=(t,e)=>({...DB(t),options:[t,e]}),JB=(t,e)=>({...VB(t),options:[t,e]});var QB="Arrow",T3=b.forwardRef((t,e)=>{const{children:n,width:r=10,height:a=5,...i}=t;return s.jsx(bt.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"})})});T3.displayName=QB;var YB=T3,Ey="Popper",[E3,M3]=No(Ey),[XB,A3]=E3(Ey),I3=t=>{const{__scopePopper:e,children:n}=t,[r,a]=b.useState(null);return s.jsx(XB,{scope:e,anchor:r,onAnchorChange:a,children:n})};I3.displayName=Ey;var R3="PopperAnchor",P3=b.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...a}=t,i=A3(R3,n),o=b.useRef(null),c=Ht(e,o),u=b.useRef(null);return b.useEffect(()=>{const h=u.current;u.current=(r==null?void 0:r.current)||o.current,h!==u.current&&i.onAnchorChange(u.current)}),r?null:s.jsx(bt.div,{...a,ref:c})});P3.displayName=R3;var My="PopperContent",[ZB,e9]=E3(My),O3=b.forwardRef((t,e)=>{var le,de,ve,ye,ke,ze;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:y="optimized",onPlaced:N,...w}=t,j=A3(My,n),[S,E]=b.useState(null),T=Ht(e,ft=>E(ft)),[P,O]=b.useState(null),q=A0(P),z=(q==null?void 0:q.width)??0,V=(q==null?void 0:q.height)??0,I=r+(i!=="center"?"-"+i:""),te=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},Q=Array.isArray(h)?h:[h],F=Q.length>0,re={padding:te,boundary:Q.filter(n9),altBoundary:F},{refs:ie,floatingStyles:J,placement:$,isPositioned:D,middlewareData:R}=BB({strategy:"fixed",placement:I,whileElementsMounted:(...ft)=>IB(...ft,{animationFrame:y==="always"}),elements:{reference:j.anchor},middleware:[HB({mainAxis:a+V,alignmentAxis:o}),u&&UB({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?WB():void 0,...re}),u&&KB({...re}),qB({...re,apply:({elements:ft,rects:wt,availableWidth:dt,availableHeight:Rt})=>{const{width:Tt,height:Tn}=wt.reference,mn=ft.floating.style;mn.setProperty("--radix-popper-available-width",`${dt}px`),mn.setProperty("--radix-popper-available-height",`${Rt}px`),mn.setProperty("--radix-popper-anchor-width",`${Tt}px`),mn.setProperty("--radix-popper-anchor-height",`${Tn}px`)}}),P&&JB({element:P,padding:c}),s9({arrowWidth:z,arrowHeight:V}),x&&GB({strategy:"referenceHidden",...re})]}),[oe,G]=_3($),_=po(N);Ns(()=>{D&&(_==null||_())},[D,_]);const U=(le=R.arrow)==null?void 0:le.x,H=(de=R.arrow)==null?void 0:de.y,K=((ve=R.arrow)==null?void 0:ve.centerOffset)!==0,[me,Y]=b.useState();return Ns(()=>{S&&Y(window.getComputedStyle(S).zIndex)},[S]),s.jsx("div",{ref:ie.setFloating,"data-radix-popper-content-wrapper":"",style:{...J,transform:D?J.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:me,"--radix-popper-transform-origin":[(ye=R.transformOrigin)==null?void 0:ye.x,(ke=R.transformOrigin)==null?void 0:ke.y].join(" "),...((ze=R.hide)==null?void 0:ze.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(ZB,{scope:n,placedSide:oe,onArrowChange:O,arrowX:U,arrowY:H,shouldHideArrow:K,children:s.jsx(bt.div,{"data-side":oe,"data-align":G,...w,ref:T,style:{...w.style,animation:D?void 0:"none"}})})})});O3.displayName=My;var L3="PopperArrow",t9={top:"bottom",right:"left",bottom:"top",left:"right"},D3=b.forwardRef(function(e,n){const{__scopePopper:r,...a}=e,i=e9(L3,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(YB,{...a,ref:n,style:{...a.style,display:"block"}})})});D3.displayName=L3;function n9(t){return t!==null}var s9=t=>({name:"transformOrigin",options:t,fn(e){var j,S,E;const{placement:n,rects:r,middlewareData:a}=e,o=((j=a.arrow)==null?void 0:j.centerOffset)!==0,c=o?0:t.arrowWidth,u=o?0:t.arrowHeight,[h,f]=_3(n),m={start:"0%",center:"50%",end:"100%"}[f],x=(((S=a.arrow)==null?void 0:S.x)??0)+c/2,y=(((E=a.arrow)==null?void 0:E.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:`${y}px`):h==="left"&&(N=`${r.floating.width+u}px`,w=o?m:`${y}px`),{data:{x:N,y:w}}}});function _3(t){const[e,n="center"]=t.split("-");return[e,n]}var r9=I3,a9=P3,i9=O3,o9=D3,z3=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"}),l9="VisuallyHidden",c9=b.forwardRef((t,e)=>s.jsx(bt.span,{...t,ref:e,style:{...z3,...t.style}}));c9.displayName=l9;var d9=[" ","Enter","ArrowUp","ArrowDown"],u9=[" ","Enter"],Nl="Select",[Tp,Ep,h9]=T0(Nl),[Fc]=No(Nl,[h9,M3]),Mp=M3(),[f9,So]=Fc(Nl),[p9,m9]=Fc(Nl),$3=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:y,form:N}=t,w=Mp(e),[j,S]=b.useState(null),[E,T]=b.useState(null),[P,O]=b.useState(!1),q=sp(h),[z,V]=cl({prop:r,defaultProp:a??!1,onChange:i,caller:Nl}),[I,te]=cl({prop:o,defaultProp:c,onChange:u,caller:Nl}),Q=b.useRef(null),F=j?N||!!j.closest("form"):!0,[re,ie]=b.useState(new Set),J=Array.from(re).map($=>$.props.value).join(";");return s.jsx(r9,{...w,children:s.jsxs(f9,{required:y,scope:e,trigger:j,onTriggerChange:S,valueNode:E,onValueNodeChange:T,valueNodeHasChildren:P,onValueNodeHasChildrenChange:O,contentId:oo(),value:I,onValueChange:te,open:z,onOpenChange:V,dir:q,triggerPointerDownPosRef:Q,disabled:x,children:[s.jsx(Tp.Provider,{scope:e,children:s.jsx(p9,{scope:t.__scopeSelect,onNativeOptionAdd:b.useCallback($=>{ie(D=>new Set(D).add($))},[]),onNativeOptionRemove:b.useCallback($=>{ie(D=>{const R=new Set(D);return R.delete($),R})},[]),children:n})}),F?s.jsxs(o4,{"aria-hidden":!0,required:y,tabIndex:-1,name:f,autoComplete:m,value:I,onChange:$=>te($.target.value),disabled:x,form:N,children:[I===void 0?s.jsx("option",{value:""}):null,Array.from(re)]},J):null]})})};$3.displayName=Nl;var F3="SelectTrigger",B3=b.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...a}=t,i=Mp(n),o=So(F3,n),c=o.disabled||r,u=Ht(e,o.onTriggerChange),h=Ep(n),f=b.useRef("touch"),[m,x,y]=c4(w=>{const j=h().filter(T=>!T.disabled),S=j.find(T=>T.value===o.value),E=d4(j,w,S);E!==void 0&&o.onValueChange(E.value)}),N=w=>{c||(o.onOpenChange(!0),y()),w&&(o.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return s.jsx(a9,{asChild:!0,...i,children:s.jsx(bt.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":l4(o.value)?"":void 0,...a,ref:u,onClick:mt(a.onClick,w=>{w.currentTarget.focus(),f.current!=="mouse"&&N(w)}),onPointerDown:mt(a.onPointerDown,w=>{f.current=w.pointerType;const j=w.target;j.hasPointerCapture(w.pointerId)&&j.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(N(w),w.preventDefault())}),onKeyDown:mt(a.onKeyDown,w=>{const j=m.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&x(w.key),!(j&&w.key===" ")&&d9.includes(w.key)&&(N(),w.preventDefault())})})})});B3.displayName=F3;var V3="SelectValue",H3=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:a,children:i,placeholder:o="",...c}=t,u=So(V3,n),{onValueNodeHasChildrenChange:h}=u,f=i!==void 0,m=Ht(e,u.onValueNodeChange);return Ns(()=>{h(f)},[h,f]),s.jsx(bt.span,{...c,ref:m,style:{pointerEvents:"none"},children:l4(u.value)?s.jsx(s.Fragment,{children:o}):i})});H3.displayName=V3;var x9="SelectIcon",U3=b.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...a}=t;return s.jsx(bt.span,{"aria-hidden":!0,...a,ref:e,children:r||"▼"})});U3.displayName=x9;var g9="SelectPortal",W3=t=>s.jsx(w0,{asChild:!0,...t});W3.displayName=g9;var wl="SelectContent",K3=b.forwardRef((t,e)=>{const n=So(wl,t.__scopeSelect),[r,a]=b.useState();if(Ns(()=>{a(new DocumentFragment)},[]),!n.open){const i=r;return i?au.createPortal(s.jsx(q3,{scope:t.__scopeSelect,children:s.jsx(Tp.Slot,{scope:t.__scopeSelect,children:s.jsx("div",{children:t.children})})}),i):null}return s.jsx(G3,{...t,ref:e})});K3.displayName=wl;var Kr=10,[q3,Co]=Fc(wl),y9="SelectContentImpl",b9=Ud("SelectContent.RemoveScroll"),G3=b.forwardRef((t,e)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:o,side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:x,collisionPadding:y,sticky:N,hideWhenDetached:w,avoidCollisions:j,...S}=t,E=So(wl,n),[T,P]=b.useState(null),[O,q]=b.useState(null),z=Ht(e,le=>P(le)),[V,I]=b.useState(null),[te,Q]=b.useState(null),F=Ep(n),[re,ie]=b.useState(!1),J=b.useRef(!1);b.useEffect(()=>{if(T)return lk(T)},[T]),Zj();const $=b.useCallback(le=>{const[de,...ve]=F().map(ze=>ze.ref.current),[ye]=ve.slice(-1),ke=document.activeElement;for(const ze of le)if(ze===ke||(ze==null||ze.scrollIntoView({block:"nearest"}),ze===de&&O&&(O.scrollTop=0),ze===ye&&O&&(O.scrollTop=O.scrollHeight),ze==null||ze.focus(),document.activeElement!==ke))return},[F,O]),D=b.useCallback(()=>$([V,T]),[$,V,T]);b.useEffect(()=>{re&&D()},[re,D]);const{onOpenChange:R,triggerPointerDownPosRef:oe}=E;b.useEffect(()=>{if(T){let le={x:0,y:0};const de=ye=>{var ke,ze;le={x:Math.abs(Math.round(ye.pageX)-(((ke=oe.current)==null?void 0:ke.x)??0)),y:Math.abs(Math.round(ye.pageY)-(((ze=oe.current)==null?void 0:ze.y)??0))}},ve=ye=>{le.x<=10&&le.y<=10?ye.preventDefault():T.contains(ye.target)||R(!1),document.removeEventListener("pointermove",de),oe.current=null};return oe.current!==null&&(document.addEventListener("pointermove",de),document.addEventListener("pointerup",ve,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",de),document.removeEventListener("pointerup",ve,{capture:!0})}}},[T,R,oe]),b.useEffect(()=>{const le=()=>R(!1);return window.addEventListener("blur",le),window.addEventListener("resize",le),()=>{window.removeEventListener("blur",le),window.removeEventListener("resize",le)}},[R]);const[G,_]=c4(le=>{const de=F().filter(ke=>!ke.disabled),ve=de.find(ke=>ke.ref.current===document.activeElement),ye=d4(de,le,ve);ye&&setTimeout(()=>ye.ref.current.focus())}),U=b.useCallback((le,de,ve)=>{const ye=!J.current&&!ve;(E.value!==void 0&&E.value===de||ye)&&(I(le),ye&&(J.current=!0))},[E.value]),H=b.useCallback(()=>T==null?void 0:T.focus(),[T]),K=b.useCallback((le,de,ve)=>{const ye=!J.current&&!ve;(E.value!==void 0&&E.value===de||ye)&&Q(le)},[E.value]),me=r==="popper"?i0:J3,Y=me===i0?{side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:x,collisionPadding:y,sticky:N,hideWhenDetached:w,avoidCollisions:j}:{};return s.jsx(q3,{scope:n,content:T,viewport:O,onViewportChange:q,itemRefCallback:U,selectedItem:V,onItemLeave:H,itemTextRefCallback:K,focusSelectedItem:D,selectedItemText:te,position:r,isPositioned:re,searchRef:G,children:s.jsx(j0,{as:b9,allowPinchZoom:!0,children:s.jsx(N0,{asChild:!0,trapped:E.open,onMountAutoFocus:le=>{le.preventDefault()},onUnmountAutoFocus:mt(a,le=>{var de;(de=E.trigger)==null||de.focus({preventScroll:!0}),le.preventDefault()}),children:s.jsx(v0,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:le=>le.preventDefault(),onDismiss:()=>E.onOpenChange(!1),children:s.jsx(me,{role:"listbox",id:E.contentId,"data-state":E.open?"open":"closed",dir:E.dir,onContextMenu:le=>le.preventDefault(),...S,...Y,onPlaced:()=>ie(!0),ref:z,style:{display:"flex",flexDirection:"column",outline:"none",...S.style},onKeyDown:mt(S.onKeyDown,le=>{const de=le.ctrlKey||le.altKey||le.metaKey;if(le.key==="Tab"&&le.preventDefault(),!de&&le.key.length===1&&_(le.key),["ArrowUp","ArrowDown","Home","End"].includes(le.key)){let ye=F().filter(ke=>!ke.disabled).map(ke=>ke.ref.current);if(["ArrowUp","End"].includes(le.key)&&(ye=ye.slice().reverse()),["ArrowUp","ArrowDown"].includes(le.key)){const ke=le.target,ze=ye.indexOf(ke);ye=ye.slice(ze+1)}setTimeout(()=>$(ye)),le.preventDefault()}})})})})})})});G3.displayName=y9;var v9="SelectItemAlignedPosition",J3=b.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...a}=t,i=So(wl,n),o=Co(wl,n),[c,u]=b.useState(null),[h,f]=b.useState(null),m=Ht(e,z=>f(z)),x=Ep(n),y=b.useRef(!1),N=b.useRef(!0),{viewport:w,selectedItem:j,selectedItemText:S,focusSelectedItem:E}=o,T=b.useCallback(()=>{if(i.trigger&&i.valueNode&&c&&h&&w&&j&&S){const z=i.trigger.getBoundingClientRect(),V=h.getBoundingClientRect(),I=i.valueNode.getBoundingClientRect(),te=S.getBoundingClientRect();if(i.dir!=="rtl"){const ke=te.left-V.left,ze=I.left-ke,ft=z.left-ze,wt=z.width+ft,dt=Math.max(wt,V.width),Rt=window.innerWidth-Kr,Tt=tf(ze,[Kr,Math.max(Kr,Rt-dt)]);c.style.minWidth=wt+"px",c.style.left=Tt+"px"}else{const ke=V.right-te.right,ze=window.innerWidth-I.right-ke,ft=window.innerWidth-z.right-ze,wt=z.width+ft,dt=Math.max(wt,V.width),Rt=window.innerWidth-Kr,Tt=tf(ze,[Kr,Math.max(Kr,Rt-dt)]);c.style.minWidth=wt+"px",c.style.right=Tt+"px"}const Q=x(),F=window.innerHeight-Kr*2,re=w.scrollHeight,ie=window.getComputedStyle(h),J=parseInt(ie.borderTopWidth,10),$=parseInt(ie.paddingTop,10),D=parseInt(ie.borderBottomWidth,10),R=parseInt(ie.paddingBottom,10),oe=J+$+re+R+D,G=Math.min(j.offsetHeight*5,oe),_=window.getComputedStyle(w),U=parseInt(_.paddingTop,10),H=parseInt(_.paddingBottom,10),K=z.top+z.height/2-Kr,me=F-K,Y=j.offsetHeight/2,le=j.offsetTop+Y,de=J+$+le,ve=oe-de;if(de<=K){const ke=Q.length>0&&j===Q[Q.length-1].ref.current;c.style.bottom="0px";const ze=h.clientHeight-w.offsetTop-w.offsetHeight,ft=Math.max(me,Y+(ke?H:0)+ze+D),wt=de+ft;c.style.height=wt+"px"}else{const ke=Q.length>0&&j===Q[0].ref.current;c.style.top="0px";const ft=Math.max(K,J+w.offsetTop+(ke?U:0)+Y)+ve;c.style.height=ft+"px",w.scrollTop=de-K+w.offsetTop}c.style.margin=`${Kr}px 0`,c.style.minHeight=G+"px",c.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>y.current=!0)}},[x,i.trigger,i.valueNode,c,h,w,j,S,i.dir,r]);Ns(()=>T(),[T]);const[P,O]=b.useState();Ns(()=>{h&&O(window.getComputedStyle(h).zIndex)},[h]);const q=b.useCallback(z=>{z&&N.current===!0&&(T(),E==null||E(),N.current=!1)},[T,E]);return s.jsx(w9,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:y,onScrollButtonChange:q,children:s.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:P},children:s.jsx(bt.div,{...a,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});J3.displayName=v9;var N9="SelectPopperPosition",i0=b.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:a=Kr,...i}=t,o=Mp(n);return s.jsx(i9,{...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)"}})});i0.displayName=N9;var[w9,Ay]=Fc(wl,{}),o0="SelectViewport",Q3=b.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...a}=t,i=Co(o0,n),o=Ay(o0,n),c=Ht(e,i.onViewportChange),u=b.useRef(0);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),s.jsx(Tp.Slot,{scope:n,children:s.jsx(bt.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:mt(a.onScroll,h=>{const f=h.currentTarget,{contentWrapper:m,shouldExpandOnScrollRef:x}=o;if(x!=null&&x.current&&m){const y=Math.abs(u.current-f.scrollTop);if(y>0){const N=window.innerHeight-Kr*2,w=parseFloat(m.style.minHeight),j=parseFloat(m.style.height),S=Math.max(w,j);if(S0?P:0,m.style.justifyContent="flex-end")}}}u.current=f.scrollTop})})})]})});Q3.displayName=o0;var Y3="SelectGroup",[j9,k9]=Fc(Y3),S9=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=oo();return s.jsx(j9,{scope:n,id:a,children:s.jsx(bt.div,{role:"group","aria-labelledby":a,...r,ref:e})})});S9.displayName=Y3;var X3="SelectLabel",C9=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=k9(X3,n);return s.jsx(bt.div,{id:a.id,...r,ref:e})});C9.displayName=X3;var Qf="SelectItem",[T9,Z3]=Fc(Qf),e4=b.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:a=!1,textValue:i,...o}=t,c=So(Qf,n),u=Co(Qf,n),h=c.value===r,[f,m]=b.useState(i??""),[x,y]=b.useState(!1),N=Ht(e,E=>{var T;return(T=u.itemRefCallback)==null?void 0:T.call(u,E,r,a)}),w=oo(),j=b.useRef("touch"),S=()=>{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(T9,{scope:n,value:r,disabled:a,textId:w,isSelected:h,onItemTextChange:b.useCallback(E=>{m(T=>T||((E==null?void 0:E.textContent)??"").trim())},[]),children:s.jsx(Tp.ItemSlot,{scope:n,value:r,disabled:a,textValue:f,children:s.jsx(bt.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:mt(o.onFocus,()=>y(!0)),onBlur:mt(o.onBlur,()=>y(!1)),onClick:mt(o.onClick,()=>{j.current!=="mouse"&&S()}),onPointerUp:mt(o.onPointerUp,()=>{j.current==="mouse"&&S()}),onPointerDown:mt(o.onPointerDown,E=>{j.current=E.pointerType}),onPointerMove:mt(o.onPointerMove,E=>{var T;j.current=E.pointerType,a?(T=u.onItemLeave)==null||T.call(u):j.current==="mouse"&&E.currentTarget.focus({preventScroll:!0})}),onPointerLeave:mt(o.onPointerLeave,E=>{var T;E.currentTarget===document.activeElement&&((T=u.onItemLeave)==null||T.call(u))}),onKeyDown:mt(o.onKeyDown,E=>{var P;((P=u.searchRef)==null?void 0:P.current)!==""&&E.key===" "||(u9.includes(E.key)&&S(),E.key===" "&&E.preventDefault())})})})})});e4.displayName=Qf;var Td="SelectItemText",t4=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:a,...i}=t,o=So(Td,n),c=Co(Td,n),u=Z3(Td,n),h=m9(Td,n),[f,m]=b.useState(null),x=Ht(e,S=>m(S),u.onItemTextChange,S=>{var E;return(E=c.itemTextRefCallback)==null?void 0:E.call(c,S,u.value,u.disabled)}),y=f==null?void 0:f.textContent,N=b.useMemo(()=>s.jsx("option",{value:u.value,disabled:u.disabled,children:y},u.value),[u.disabled,u.value,y]),{onNativeOptionAdd:w,onNativeOptionRemove:j}=h;return Ns(()=>(w(N),()=>j(N)),[w,j,N]),s.jsxs(s.Fragment,{children:[s.jsx(bt.span,{id:u.textId,...i,ref:x}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?au.createPortal(i.children,o.valueNode):null]})});t4.displayName=Td;var n4="SelectItemIndicator",s4=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return Z3(n4,n).isSelected?s.jsx(bt.span,{"aria-hidden":!0,...r,ref:e}):null});s4.displayName=n4;var l0="SelectScrollUpButton",r4=b.forwardRef((t,e)=>{const n=Co(l0,t.__scopeSelect),r=Ay(l0,t.__scopeSelect),[a,i]=b.useState(!1),o=Ht(e,r.onScrollButtonChange);return Ns(()=>{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(i4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop-u.offsetHeight)}}):null});r4.displayName=l0;var c0="SelectScrollDownButton",a4=b.forwardRef((t,e)=>{const n=Co(c0,t.__scopeSelect),r=Ay(c0,t.__scopeSelect),[a,i]=b.useState(!1),o=Ht(e,r.onScrollButtonChange);return Ns(()=>{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(i4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop+u.offsetHeight)}}):null});a4.displayName=c0;var i4=b.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...a}=t,i=Co("SelectScrollButton",n),o=b.useRef(null),c=Ep(n),u=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>u(),[u]),Ns(()=>{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(bt.div,{"aria-hidden":!0,...a,ref:e,style:{flexShrink:0,...a.style},onPointerDown:mt(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:mt(a.onPointerMove,()=>{var h;(h=i.onItemLeave)==null||h.call(i),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:mt(a.onPointerLeave,()=>{u()})})}),E9="SelectSeparator",M9=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return s.jsx(bt.div,{"aria-hidden":!0,...r,ref:e})});M9.displayName=E9;var d0="SelectArrow",A9=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=Mp(n),i=So(d0,n),o=Co(d0,n);return i.open&&o.position==="popper"?s.jsx(o9,{...a,...r,ref:e}):null});A9.displayName=d0;var I9="SelectBubbleInput",o4=b.forwardRef(({__scopeSelect:t,value:e,...n},r)=>{const a=b.useRef(null),i=Ht(r,a),o=M0(e);return b.useEffect(()=>{const c=a.current;if(!c)return;const u=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==e&&f){const m=new Event("change",{bubbles:!0});f.call(c,e),c.dispatchEvent(m)}},[o,e]),s.jsx(bt.select,{...n,style:{...z3,...n.style},ref:i,defaultValue:e})});o4.displayName=I9;function l4(t){return t===""||t===void 0}function c4(t){const e=po(t),n=b.useRef(""),r=b.useRef(0),a=b.useCallback(o=>{const c=n.current+o;e(c),(function u(h){n.current=h,window.clearTimeout(r.current),h!==""&&(r.current=window.setTimeout(()=>u(""),1e3))})(c)},[e]),i=b.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,i]}function d4(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=R9(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 R9(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var P9=$3,u4=B3,O9=H3,L9=U3,D9=W3,h4=K3,_9=Q3,f4=e4,z9=t4,$9=s4,F9=r4,B9=a4;const lc=P9,cc=O9,Qo=b.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(u4,{ref:r,className:Ut("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(L9,{asChild:!0,children:s.jsx(vc,{className:"h-4 w-4 opacity-50"})})]}));Qo.displayName=u4.displayName;const Yo=b.forwardRef(({className:t,children:e,position:n="popper",...r},a)=>s.jsx(D9,{children:s.jsxs(h4,{ref:a,className:Ut("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(F9,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(ag,{className:"h-4 w-4"})}),s.jsx(_9,{className:"p-1",children:e}),s.jsx(B9,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(vc,{className:"h-4 w-4"})})]})}));Yo.displayName=h4.displayName;const Ws=b.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(f4,{ref:r,className:Ut("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($9,{children:s.jsx(Zf,{className:"h-4 w-4"})})}),s.jsx(z9,{children:e})]}));Ws.displayName=f4.displayName;const qw=["📖","📕","📗","📘","📙","📓","📔","📒","📚","📖"];function V9(t){return t.title==="序言"||t.title.includes("序言")}function Gw(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 Xx(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 H9({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:y,onShowSectionOrders:N,pinnedSectionIds:w=[]}){const[j,S]=b.useState(null),[E,T]=b.useState(null),P=(F,re)=>(j==null?void 0:j.type)===F&&(j==null?void 0:j.id)===re,O=(F,re)=>(E==null?void 0:E.type)===F&&(E==null?void 0:E.id)===re,q=b.useCallback(()=>{const F=[];for(const re of t)for(const ie of re.chapters)for(const J of ie.sections)F.push({id:J.id,partId:re.id,partTitle:re.title,chapterId:ie.id,chapterTitle:ie.title});return F},[t]),z=b.useCallback(async(F,re,ie,J)=>{var G;F.preventDefault(),F.stopPropagation();const $=F.dataTransfer.getData("text/plain"),D=Xx($);if(!D||D.type===re&&D.id===ie)return;const R=q(),oe=new Map(R.map(_=>[_.id,_]));if(D.type==="part"&&re==="part"){const _=t.map(Y=>Y.id),U=_.indexOf(D.id),H=_.indexOf(ie);if(U===-1||H===-1)return;const K=[..._];K.splice(U,1),K.splice(Ude.id===Y);if(le)for(const de of le.chapters)for(const ve of de.sections){const ye=oe.get(ve.id);ye&&me.push(ye)}}await r(me);return}if(D.type==="chapter"&&(re==="chapter"||re==="section"||re==="part")){const _=t.find(ye=>ye.chapters.some(ke=>ke.id===D.id)),U=_==null?void 0:_.chapters.find(ye=>ye.id===D.id);if(!_||!U)return;let H,K,me=null;if(re==="section"){const ye=oe.get(ie);if(!ye)return;H=ye.partId,K=ye.partTitle,me=ie}else if(re==="chapter"){const ye=t.find(ft=>ft.chapters.some(wt=>wt.id===ie)),ke=ye==null?void 0:ye.chapters.find(ft=>ft.id===ie);if(!ye||!ke)return;H=ye.id,K=ye.title;const ze=R.filter(ft=>ft.chapterId===ie).pop();me=(ze==null?void 0:ze.id)??null}else{const ye=t.find(ke=>ke.id===ie);if(!ye)return;if(H=ye.id,K=ye.title,ye.chapters[0]){const ke=R.filter(ze=>ze.partId===ye.id&&ze.chapterId===ye.chapters[0].id);me=((G=ke[ke.length-1])==null?void 0:G.id)??null}}const Y=U.sections.map(ye=>ye.id),le=R.filter(ye=>!Y.includes(ye.id));let de=le.length;if(me){const ye=le.findIndex(ke=>ke.id===me);ye>=0&&(de=ye+1)}const ve=Y.map(ye=>({...oe.get(ye),partId:H,partTitle:K,chapterId:U.id,chapterTitle:U.title}));await r([...le.slice(0,de),...ve,...le.slice(de)]);return}if(D.type==="section"&&(re==="section"||re==="chapter"||re==="part")){if(!J)return;const{partId:_,partTitle:U,chapterId:H,chapterTitle:K}=J;let me;if(re==="section")me=R.findIndex(ke=>ke.id===ie);else if(re==="chapter"){const ke=R.filter(ze=>ze.chapterId===ie).pop();me=ke?R.findIndex(ze=>ze.id===ke.id)+1:R.length}else{const ke=t.find(ze=>ze.id===ie);if(ke!=null&&ke.chapters[0]){const ze=R.filter(wt=>wt.partId===ke.id&&wt.chapterId===ke.chapters[0].id),ft=ze[ze.length-1];me=ft?R.findIndex(wt=>wt.id===ft.id)+1:R.length}else me=R.length}const Y=R.findIndex(ke=>ke.id===D.id);if(Y===-1)return;const le=R.filter(ke=>ke.id!==D.id),de=Y({onDragEnter:J=>{J.preventDefault(),J.stopPropagation(),J.dataTransfer.dropEffect="move",T({type:F,id:re})},onDragOver:J=>{J.preventDefault(),J.stopPropagation(),J.dataTransfer.dropEffect="move",T({type:F,id:re})},onDragLeave:()=>T(null),onDrop:J=>{T(null);const $=Xx(J.dataTransfer.getData("text/plain"));$&&(F==="section"&&$.type==="section"&&$.id===re||(F==="part"?$.type==="part"?z(J,"part",re):ie&&z(J,"part",re,ie):F==="chapter"&&ie?($.type==="section"||$.type==="chapter")&&z(J,"chapter",re,ie):F==="section"&&ie&&z(J,"section",re,ie)))}}),I=F=>qw[F%qw.length],te=F=>t.slice(0,F).filter(re=>!V9(re)).length,Q=F=>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: ${F.id}`,children:F.id}),s.jsx("span",{className:"truncate",children:F.title})]});return s.jsx("div",{className:"space-y-3",children:t.map((F,re)=>{var U,H,K,me;const ie=F.title==="序言"||F.title.includes("序言"),J=F.title==="尾声"||F.title.includes("尾声"),$=F.title==="附录"||F.title.includes("附录"),D=O("part",F.id),R=e.includes(F.id),oe=F.chapters.length,G=F.chapters.reduce((Y,le)=>Y+le.sections.length,0);if(ie&&F.chapters.length===1&&F.chapters[0].sections.length===1){const Y=F.chapters[0].sections[0],le=O("section",Y.id),de={partId:F.id,partTitle:F.title,chapterId:F.chapters[0].id,chapterTitle:F.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:ve=>{ve.stopPropagation(),ve.dataTransfer.setData("text/plain","section:"+Y.id),ve.dataTransfer.effectAllowed="move",S({type:"section",id:Y.id})},onDragEnd:()=>{S(null),T(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] ${le?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${P("section",Y.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...V("section",Y.id,de),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(Xa,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ve=>ve.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes(Y.id),onChange:()=>y(Y.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(Gs,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[F.chapters[0].title," | ",Y.title]}),w.includes(Y.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(uc,{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:ve=>ve.stopPropagation(),onClick:ve=>ve.stopPropagation(),children:[Y.price===0||Y.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:["¥",Y.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",Y.clickCount??0," · 付款 ",Y.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(Y.hotScore??0).toFixed(1)," · 第",Y.hotRank&&Y.hotRank>0?Y.hotRank:"-","名"]}),N&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N(Y),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(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(Y),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(Y),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]})]},F.id)}if(F.title==="2026每日派对干货"||F.title.includes("2026每日派对干货")){const Y=O("part",F.id);return s.jsxs("div",{className:`rounded-xl border overflow-hidden transition-all duration-200 ${Y?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50 bg-[#1C1C1E]"}`,...V("part",F.id,{partId:F.id,partTitle:F.title,chapterId:((U=F.chapters[0])==null?void 0:U.id)??"",chapterTitle:((H=F.chapters[0])==null?void 0:H.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:le=>{le.stopPropagation(),le.dataTransfer.setData("text/plain","part:"+F.id),le.dataTransfer.effectAllowed="move",S({type:"part",id:F.id})},onDragEnd:()=>{S(null),T(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${P("part",F.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(Xa,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),s.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#38bdac]/80 flex items-center justify-center text-white font-bold shrink-0",children:"派"}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:F.title}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:Gw(F)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:le=>le.stopPropagation(),onClick:le=>le.stopPropagation(),children:[o&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(F),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(An,{className:"w-3.5 h-3.5"})}),h&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(F),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),f&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(F),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(bs,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[oe," 章 · ",G," 节"]}),s.jsx("button",{type:"button",draggable:!1,className:"p-1 rounded-md hover:bg-white/10 text-gray-500",title:R?"收起":"展开",onMouseDown:le=>le.stopPropagation(),onClick:le=>{le.stopPropagation(),n(F.id)},children:R?s.jsx(vc,{className:"w-5 h-5"}):s.jsx(Xo,{className:"w-5 h-5"})})]})]}),R&&F.chapters.length>0&&s.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:F.chapters.map(le=>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:le.title}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:de=>de.stopPropagation(),children:[m&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>m(F,le),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),c&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>c(F),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(An,{className:"w-3.5 h-3.5"})}),u&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>u(F,le),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:le.sections.map(de=>{const ve=O("section",de.id);return s.jsxs("div",{draggable:!0,onDragStart:ye=>{ye.stopPropagation(),ye.dataTransfer.setData("text/plain","section:"+de.id),ye.dataTransfer.effectAllowed="move",S({type:"section",id:de.id})},onDragEnd:()=>{S(null),T(null)},onClick:()=>a(de),className:`flex items-center justify-between py-2 px-3 rounded-lg min-h-[40px] cursor-pointer select-none transition-all duration-200 ${ve?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${P("section",de.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...V("section",de.id,{partId:F.id,partTitle:F.title,chapterId:le.id,chapterTitle:le.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(Xa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ye=>ye.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes(de.id),onChange:()=>y(de.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:Q(de)}),w.includes(de.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(uc,{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:ye=>ye.stopPropagation(),children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",de.clickCount??0," · 付款 ",de.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(de.hotScore??0).toFixed(1)," · 第",de.hotRank&&de.hotRank>0?de.hotRank:"-","名"]}),N&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>N(de),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(de),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(de),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]},de.id)})})]},le.id))})]},F.id)}if($)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:F.chapters.map((Y,le)=>Y.sections.length>0?Y.sections.map(de=>{const ve=O("section",de.id);return s.jsxs("div",{draggable:!0,onDragStart:ye=>{ye.stopPropagation(),ye.dataTransfer.setData("text/plain","section:"+de.id),ye.dataTransfer.effectAllowed="move",S({type:"section",id:de.id})},onDragEnd:()=>{S(null),T(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 ${ve?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${P("section",de.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...V("section",de.id,{partId:F.id,partTitle:F.title,chapterId:Y.id,chapterTitle:Y.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(Xa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ye=>ye.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes(de.id),onChange:()=>y(de.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:["附录",le+1," | ",Y.title," | ",de.title]}),w.includes(de.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(uc,{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:["点击 ",de.clickCount??0," · 付款 ",de.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(de.hotScore??0).toFixed(1)," · 第",de.hotRank&&de.hotRank>0?de.hotRank:"-","名"]}),N&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>N(de),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(X,{variant:"ghost",size:"sm",onClick:()=>a(de),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>i(de),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(Xo,{className:"w-4 h-4 text-gray-500 shrink-0"})]},de.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:["附录",le+1," | ",Y.title,"(空)"]}),s.jsx(Xo,{className:"w-4 h-4 text-gray-500 shrink-0"})]},Y.id))})]},F.id);if(J&&F.chapters.length===1&&F.chapters[0].sections.length===1){const Y=F.chapters[0].sections[0],le=O("section",Y.id),de={partId:F.id,partTitle:F.title,chapterId:F.chapters[0].id,chapterTitle:F.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:ve=>{ve.stopPropagation(),ve.dataTransfer.setData("text/plain","section:"+Y.id),ve.dataTransfer.effectAllowed="move",S({type:"section",id:Y.id})},onDragEnd:()=>{S(null),T(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] ${le?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${P("section",Y.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...V("section",Y.id,de),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(Xa,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ve=>ve.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes(Y.id),onChange:()=>y(Y.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(Gs,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[F.chapters[0].title," | ",Y.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:ve=>ve.stopPropagation(),onClick:ve=>ve.stopPropagation(),children:[Y.price===0||Y.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:["¥",Y.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",Y.clickCount??0," · 付款 ",Y.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(Y.hotScore??0).toFixed(1)," · 第",Y.hotRank&&Y.hotRank>0?Y.hotRank:"-","名"]}),N&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N(Y),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(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(Y),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(Y),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]})]},F.id)}return J?s.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[s.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"尾声"}),s.jsx("div",{className:"space-y-3",children:F.chapters.map(Y=>Y.sections.map(le=>{const de=O("section",le.id);return s.jsxs("div",{draggable:!0,onDragStart:ve=>{ve.stopPropagation(),ve.dataTransfer.setData("text/plain","section:"+le.id),ve.dataTransfer.effectAllowed="move",S({type:"section",id:le.id})},onDragEnd:()=>{S(null),T(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 ${de?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${P("section",le.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...V("section",le.id,{partId:F.id,partTitle:F.title,chapterId:Y.id,chapterTitle:Y.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(Xa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ve=>ve.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes(le.id),onChange:()=>y(le.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:[Y.title," | ",le.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",le.clickCount??0," · 付款 ",le.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(le.hotScore??0).toFixed(1)," · 第",le.hotRank&&le.hotRank>0?le.hotRank:"-","名"]}),N&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N(le),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(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(le),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(le),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]})]},le.id)}))})]},F.id):s.jsxs("div",{className:`rounded-xl border bg-[#1C1C1E] overflow-hidden transition-all duration-200 ${D?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50"}`,...V("part",F.id,{partId:F.id,partTitle:F.title,chapterId:((K=F.chapters[0])==null?void 0:K.id)??"",chapterTitle:((me=F.chapters[0])==null?void 0:me.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:Y=>{Y.stopPropagation(),Y.dataTransfer.setData("text/plain","part:"+F.id),Y.dataTransfer.effectAllowed="move",S({type:"part",id:F.id})},onDragEnd:()=>{S(null),T(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${P("part",F.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(Xa,{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:I(te(re))}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:F.title}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:Gw(F)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:Y=>Y.stopPropagation(),onClick:Y=>Y.stopPropagation(),children:[o&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(F),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(An,{className:"w-3.5 h-3.5"})}),h&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(F),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),f&&s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(F),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(bs,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[oe," 章 · ",G," 节"]}),s.jsx("button",{type:"button",draggable:!1,className:"p-1 rounded-md hover:bg-white/10 text-gray-500",title:R?"收起":"展开",onMouseDown:Y=>Y.stopPropagation(),onClick:Y=>{Y.stopPropagation(),n(F.id)},children:R?s.jsx(vc,{className:"w-5 h-5"}):s.jsx(Xo,{className:"w-5 h-5"})})]})]}),R&&s.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:F.chapters.map(Y=>{const le=O("chapter",Y.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:de=>{de.stopPropagation(),de.dataTransfer.setData("text/plain","chapter:"+Y.id),de.dataTransfer.effectAllowed="move",S({type:"chapter",id:Y.id})},onDragEnd:()=>{S(null),T(null)},onDragEnter:de=>{de.preventDefault(),de.stopPropagation(),de.dataTransfer.dropEffect="move",T({type:"chapter",id:Y.id})},onDragOver:de=>{de.preventDefault(),de.stopPropagation(),de.dataTransfer.dropEffect="move",T({type:"chapter",id:Y.id})},onDragLeave:()=>T(null),onDrop:de=>{T(null);const ve=Xx(de.dataTransfer.getData("text/plain"));if(!ve)return;const ye={partId:F.id,partTitle:F.title,chapterId:Y.id,chapterTitle:Y.title};(ve.type==="section"||ve.type==="chapter")&&z(de,"chapter",Y.id,ye)},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 ${le?"bg-[#38bdac]/15 ring-1 ring-[#38bdac]/50":""} ${P("chapter",Y.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/30"}`,children:[s.jsx(Xa,{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:Y.title})]}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:de=>de.stopPropagation(),children:[m&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>m(F,Y),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),c&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>c(F),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(An,{className:"w-3.5 h-3.5"})}),u&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>u(F,Y),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:Y.sections.map(de=>{const ve=O("section",de.id);return s.jsxs("div",{draggable:!0,onDragStart:ye=>{ye.stopPropagation(),ye.dataTransfer.setData("text/plain","section:"+de.id),ye.dataTransfer.effectAllowed="move",S({type:"section",id:de.id})},onDragEnd:()=>{S(null),T(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 ${ve?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${P("section",de.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] shadow-lg":"hover:bg-[#162840]/50"}`,...V("section",de.id,{partId:F.id,partTitle:F.title,chapterId:Y.id,chapterTitle:Y.title}),children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ye=>ye.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes(de.id),onChange:()=>y(de.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsx(Xa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${de.price===0||de.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:Q(de)}),w.includes(de.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(uc,{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:ye=>ye.stopPropagation(),onClick:ye=>ye.stopPropagation(),children:[de.isNew&&s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"NEW"}),de.price===0||de.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:["¥",de.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",title:"点击次数 · 付款笔数",children:["点击 ",de.clickCount??0," · 付款 ",de.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(de.hotScore??0).toFixed(1)," · 第",de.hotRank&&de.hotRank>0?de.hotRank:"-","名"]}),N&&s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>N(de),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(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(de),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(Jt,{className:"w-3.5 h-3.5"})}),s.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(de),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(bs,{className:"w-3.5 h-3.5"})})]})]})]},de.id)})})]},Y.id)})})]},F.id)})})}function U9(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 Pe(r)}function W9(t){return Pe(`/api/db/person?personId=${encodeURIComponent(t)}`)}function K9(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 Pe(n?`/api/admin/ckb/plans?${n}`:"/api/admin/ckb/plans")}const p4=11,Jw={personId:"",name:"",boundUserId:"",aliases:"",label:"",sceneId:p4,ckbApiKey:"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:"phone",remarkFormat:"",addFriendInterval:1,startTime:"06:00",endTime:"22:00",deviceGroups:""};function q9({open:t,onOpenChange:e,editingPerson:n,onSubmit:r}){var $;const a=!!n,[i,o]=b.useState(Jw),[c,u]=b.useState(!1),[h,f]=b.useState(!1),[m,x]=b.useState([]),[y,N]=b.useState(!1),[w,j]=b.useState(""),[S,E]=b.useState([]),[T,P]=b.useState(!1),[O,q]=b.useState(""),[z,V]=b.useState(!1),[I,te]=b.useState({});b.useEffect(()=>{t&&(j(""),o(n?{personId:n.personId??n.name??"",name:n.name??"",boundUserId:n.userId??"",aliases:n.aliases??"",label:n.label??"",sceneId:p4,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??""}:{...Jw}),te({}),m.length===0&&Q(""),S.length===0&&F(""))},[t,n]);const Q=async D=>{N(!0);try{const R=await U9({page:1,limit:50,keyword:D});R!=null&&R.success&&Array.isArray(R.devices)?x(R.devices):R!=null&&R.error&&se.error(R.error)}catch(R){se.error(R instanceof Error?R.message:"加载设备列表失败")}finally{N(!1)}},F=async D=>{P(!0);try{const R=await K9({page:1,limit:100,keyword:D});R!=null&&R.success&&Array.isArray(R.plans)?E(R.plans):R!=null&&R.error&&se.error(R.error)}catch{se.error("加载计划列表失败")}finally{P(!1)}},re=D=>{const R=Array.isArray(D.deviceGroups)?D.deviceGroups.map(String).join(","):"";o(oe=>({...oe,ckbApiKey:D.apiKey||"",greeting:D.greeting||oe.greeting,tips:D.tips||oe.tips,remarkType:D.remarkType||oe.remarkType,remarkFormat:D.remarkFormat||oe.remarkFormat,addFriendInterval:D.addInterval||oe.addFriendInterval,startTime:D.startTime||oe.startTime,endTime:D.endTime||oe.endTime,deviceGroups:R||oe.deviceGroups})),V(!1),se.success(`已选择计划「${D.name}」,参数已覆盖`)},ie=O.trim()?S.filter(D=>(D.name||"").includes(O.trim())||String(D.id).includes(O.trim())):S,J=async()=>{var G;const D={};(!i.name||!String(i.name).trim())&&(D.name="请填写名称");const R=i.addFriendInterval;if((typeof R!="number"||R<1)&&(D.addFriendInterval="添加间隔至少为 1 分钟"),(((G=i.deviceGroups)==null?void 0:G.split(",").map(_=>_.trim()).filter(Boolean))??[]).length===0&&(D.deviceGroups="请至少选择 1 台设备"),te(D),Object.keys(D).length>0){se.error(D.name||D.addFriendInterval||D.deviceGroups||"请完善必填项");return}u(!0);try{await r(i),e(!1)}catch(_){se.error(_ instanceof Error?_.message:"保存失败")}finally{u(!1)}};return s.jsx(Dt,{open:t,onOpenChange:e,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-y-auto",children:[s.jsxs(_t,{children:[s.jsx(zt,{className:"text-[#38bdac]",children:a?"编辑人物":"添加人物 — 存客宝 API 获客"}),s.jsx(Zh,{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(ee,{className:"text-gray-400 text-xs",children:["名称 ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsx(ce,{className:`bg-[#0a1628] text-white ${I.name?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,placeholder:"如 卡若",value:i.name,onChange:D=>{o(R=>({...R,name:D.target.value})),I.name&&te(R=>({...R,name:void 0}))}}),I.name&&s.jsx("p",{className:"text-xs text-red-400",children:I.name})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"人物ID(可选)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"自动生成",value:i.personId,onChange:D=>o(R=>({...R,personId:D.target.value})),disabled:a})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"标签(身份/角色)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 超级个体",value:i.label,onChange:D=>o(R=>({...R,label:D.target.value}))})]}),s.jsxs("div",{className:"space-y-1.5 col-span-3",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"绑定会员用户 ID(可选,与「用户管理」中用户 id 一致)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-xs",placeholder:"留空则不绑定;填写后获客统计可与超级个体对齐",value:i.boundUserId,onChange:D=>o(R=>({...R,boundUserId:D.target.value.trim()}))}),s.jsx("p",{className:"text-[11px] text-gray-500",children:"保存前请在用户管理中核对 id;同一会员只能绑定一个 @人物。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"别名(逗号分隔,@ 可匹配)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 卡卡, 若若",value:i.aliases,onChange:D=>o(R=>({...R,aliases:D.target.value}))})]})]})]}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-5",children:[s.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-4",children:"存客宝 API 获客配置"}),s.jsxs("div",{className:"grid grid-cols-2 gap-x-8 gap-y-4",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5 relative",children:[s.jsx(ee,{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:()=>V(!z),children:i.ckbApiKey?s.jsx("span",{className:"text-white truncate",children:(($=S.find(D=>D.apiKey===i.ckbApiKey))==null?void 0:$.name)||`获客计划 (${i.ckbApiKey.slice(0,8)}…)`}):s.jsx("span",{className:"text-gray-500",children:"点击选择已有计划 / 新建时自动创建"})}),s.jsx(X,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-200 shrink-0",onClick:()=>{F(O),V(!0)},disabled:T,children:T?"加载...":"刷新"})]}),z&&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(ce,{className:"bg-[#050c18] border-gray-700 text-white h-8 text-xs",placeholder:"搜索计划名称...",value:O,onChange:D=>q(D.target.value),onKeyDown:D=>{D.key==="Enter"&&F(O)},autoFocus:!0})}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:ie.length===0?s.jsx("div",{className:"text-center py-4 text-gray-500 text-xs",children:T?"加载中...":"暂无计划"}):ie.map(D=>s.jsxs("div",{className:`px-3 py-2 cursor-pointer hover:bg-[#38bdac]/10 text-sm flex items-center justify-between ${i.ckbApiKey===D.apiKey?"bg-[#38bdac]/20 text-[#38bdac]":"text-white"}`,onClick:()=>re(D),children:[s.jsxs("div",{className:"truncate",children:[s.jsx("span",{className:"font-medium",children:D.name}),s.jsxs("span",{className:"text-xs text-gray-500 ml-2",children:["ID:",String(D.id)]})]}),D.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(D.id)))}),s.jsx("div",{className:"p-2 border-t border-gray-700/60 flex justify-end",children:s.jsx(X,{type:"button",size:"sm",variant:"ghost",className:"text-gray-400 h-7 text-xs",onClick:()=>V(!1),children:"关闭"})})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"选择计划后自动覆盖下方参数。新建人物时若不选择则自动创建新计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(ee,{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 ${I.deviceGroups?"border-red-500":"border-gray-700"}`,children:[s.jsx(ce,{className:"bg-[#0a1628] border-0 text-white focus-visible:ring-0 focus-visible:ring-offset-0",placeholder:"未选择设备",readOnly:!0,value:i.deviceGroups?`已选择 ${i.deviceGroups.split(",").filter(Boolean).length} 个设备`:"",onClick:()=>f(!0)}),s.jsx(X,{type:"button",variant:"outline",className:"border-0 border-l border-inherit rounded-r-md text-gray-200",onClick:()=>f(!0),children:"选择"})]}),I.deviceGroups?s.jsx("p",{className:"text-xs text-red-400",children:I.deviceGroups}):s.jsx("p",{className:"text-xs text-gray-500",children:"从存客宝设备列表中选择,至少选择 1 台设备参与获客计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"好友备注"}),s.jsxs(lc,{value:i.remarkType,onValueChange:D=>o(R=>({...R,remarkType:D})),children:[s.jsx(Qo,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(cc,{placeholder:"选择备注类型"})}),s.jsxs(Yo,{children:[s.jsx(Ws,{value:"phone",children:"手机号"}),s.jsx(Ws,{value:"nickname",children:"昵称"}),s.jsx(Ws,{value:"source",children:"来源"})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"备注格式(手机号+标签,标签不超过6字)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 {手机号}-{来源标签},总长不超过10字",value:i.remarkFormat,onChange:D=>o(R=>({...R,remarkFormat:D.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(ee,{className:"text-gray-400 text-xs",children:"打招呼语"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"你好,请通过",value:i.greeting,onChange:D=>o(R=>({...R,greeting:D.target.value}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"添加间隔(分钟)"}),s.jsx(ce,{type:"number",min:1,className:`bg-[#0a1628] text-white ${I.addFriendInterval?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,value:i.addFriendInterval,onChange:D=>{o(R=>({...R,addFriendInterval:Number(D.target.value)||1})),I.addFriendInterval&&te(R=>({...R,addFriendInterval:void 0}))}}),I.addFriendInterval&&s.jsx("p",{className:"text-xs text-red-400",children:I.addFriendInterval})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"允许加人时间段"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ce,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:i.startTime,onChange:D=>o(R=>({...R,startTime:D.target.value}))}),s.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"至"}),s.jsx(ce,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:i.endTime,onChange:D=>o(R=>({...R,endTime:D.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"获客成功提示"}),s.jsx(hl,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[72px] resize-none",placeholder:"请注意消息,稍后加你微信",value:i.tips,onChange:D=>o(R=>({...R,tips:D.target.value}))})]})]})]})]})]}),s.jsxs(fn,{className:"gap-3 pt-2",children:[s.jsx(X,{variant:"outline",onClick:()=>e(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(X,{onClick:J,disabled:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:c?"保存中...":a?"保存":"添加"})]}),h&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:s.jsxs("div",{className:"w-full max-w-3xl max-h-[80vh] bg-[#0b1828] border border-gray-700 rounded-xl shadow-xl flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-gray-700/60",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:"选择设备"}),s.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:"勾选需要参与本计划的设备,可多选"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(X,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>{const D=m.map(G=>String(G.id??"")),R=i.deviceGroups?i.deviceGroups.split(",").map(G=>G.trim()).filter(Boolean):[],oe=D.length>0&&D.every(G=>R.includes(G));o(G=>({...G,deviceGroups:oe?"":D.join(",")})),!oe&&D.length>0&&te(G=>({...G,deviceGroups:void 0}))},children:(()=>{const D=m.map(oe=>String(oe.id??"")),R=i.deviceGroups?i.deviceGroups.split(",").map(oe=>oe.trim()).filter(Boolean):[];return D.length>0&&D.every(oe=>R.includes(oe))?"取消全选":"全选"})()}),s.jsx(ce,{className:"bg-[#050c18] border-gray-700 text-white h-8 w-52",placeholder:"搜索备注/微信号/IMEI",value:w,onChange:D=>j(D.target.value),onKeyDown:D=>{D.key==="Enter"&&Q(w)}}),s.jsx(X,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>Q(w),disabled:y,children:"刷新"}),s.jsx(X,{type:"button",size:"icon",variant:"outline",className:"border-gray-600 text-gray-300 h-8 w-8",onClick:()=>f(!1),children:"✕"})]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:y?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-400 text-sm",children:"正在加载设备列表…"}):m.length===0?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 text-sm",children:"暂无设备数据,请检查存客宝账号与开放 API 配置"}):s.jsx("div",{className:"p-4 space-y-2",children:m.map(D=>{const R=String(D.id??""),oe=i.deviceGroups?i.deviceGroups.split(",").map(U=>U.trim()).filter(Boolean):[],G=oe.includes(R),_=()=>{let U;G?U=oe.filter(H=>H!==R):U=[...oe,R],o(H=>({...H,deviceGroups:U.join(",")})),U.length>0&&te(H=>({...H,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:G,onChange:_}),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:D.memo||D.wechatId||`设备 ${R}`}),D.status==="online"&&s.jsx("span",{className:"rounded-full bg-emerald-500/20 text-emerald-400 text-[11px] px-2 py-0.5",children:"在线"}),D.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: ",R]}),D.wechatId&&s.jsxs("span",{className:"mr-3",children:["微信号: ",D.wechatId]}),typeof D.totalFriend=="number"&&s.jsxs("span",{children:["好友数: ",D.totalFriend]})]})]})]},R)})})}),s.jsxs("div",{className:"flex justify-between items-center px-5 py-3 border-t border-gray-700/60",children:[s.jsxs("span",{className:"text-xs text-gray-400",children:["已选择"," ",i.deviceGroups?i.deviceGroups.split(",").filter(Boolean).length:0," ","台设备"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(X,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 h-8 px-4",onClick:()=>f(!1),children:"取消"}),s.jsx(X,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da396] text-white h-8 px-4",onClick:()=>f(!1),children:"确定"})]})]})]})})]})})}function G9(t,e){const n=new Map;for(const i of t){const o=i.partId||"part-1",c=i.partTitle||"未分类",u=i.chapterId||"chapter-1",h=i.chapterTitle||"未分类";n.has(o)||n.set(o,{id:o,title:c,chapters:new Map});const f=n.get(o);f.chapters.has(u)||f.chapters.set(u,{id:u,title:h,sections:[]}),f.chapters.get(u).sections.push({id:i.id,mid:i.mid,title:i.title,price:i.price??1,filePath:i.filePath,isFree:i.isFree,isNew:i.isNew,clickCount:i.clickCount??0,payCount:i.payCount??0,hotScore:i.hotScore??0,hotRank:e.get(i.id)??0})}const r=Array.from(n.values()).map(i=>({...i,chapters:Array.from(i.chapters.values())})),a=new Map;for(let i=0;i{const c=a.get(i.id),u=a.get(o.id);return c!==void 0&&u!==void 0&&c!==u?c-u:c!==void 0&&u===void 0?-1:c===void 0&&u!==void 0?1:i.id.localeCompare(o.id)})}function J9(){var Ha,$r,da;const t=Sa(),[e,n]=b.useState([]),[r,a]=b.useState(!0),[i,o]=b.useState([]),[c,u]=b.useState(null),[h,f]=b.useState(!1),[m,x]=b.useState(!1),[y,N]=b.useState(!1),[w,j]=b.useState(""),[S,E]=b.useState([]),[T,P]=b.useState(!1),[O,q]=b.useState({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),[z,V]=b.useState(null),[I,te]=b.useState(!1),[Q,F]=b.useState(!1),[re,ie]=b.useState(null),[J,$]=b.useState(!1),[D,R]=b.useState([]),[oe,G]=b.useState(!1),[_,U]=b.useState(""),[H,K]=b.useState(""),[me,Y]=b.useState(!1),[le,de]=b.useState(""),[ve,ye]=b.useState(!1),[ke,ze]=b.useState(null),[ft,wt]=b.useState(!1),[dt,Rt]=b.useState(!1),[Tt,Tn]=b.useState({readWeight:.5,recencyWeight:.3,payWeight:.2}),[mn,Ft]=b.useState(!1),[qt,vn]=b.useState(!1),[On,$n]=b.useState(1),[St,cn]=b.useState([]),[xn,ge]=b.useState(!1),[Se,$e]=b.useState([]),[Xe,jt]=b.useState(!1),[gt,L]=b.useState(20),[Me,pt]=b.useState(!1),[Et,ht]=b.useState(!1),[tt,Pt]=b.useState([]),[Wt,en]=b.useState([]),[ts,Qs]=b.useState([]),[bi,ea]=b.useState(!1),[ta,Er]=b.useState(1),[Mr,Ar]=b.useState(20),[cr,dr]=b.useState(0),[Ea,Ys]=b.useState(1),[Ss,Xs]=b.useState(""),[ur,Cs]=b.useState(!1),[ae,xe]=b.useState(null),[Ue,ut]=b.useState({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",appSecret:"",pagePath:""}),[Fn,Ps]=b.useState(!1),[Ma,Aa]=b.useState(!1),[To,Zs]=b.useState(null),[Ts,vi]=b.useState(null),[Mt,Bc]=b.useState({}),[Ir,Ni]=b.useState(!1),[Rr,Vc]=b.useState(""),[Ia,na]=b.useState(""),[ns,sa]=b.useState([]),[qn,Cl]=b.useState(0),[Pr,Hc]=b.useState(1),[wi,Ra]=b.useState(!1),[ra,aa]=b.useState(""),ia=b.useRef(null),ji=b.useCallback(async(v,A)=>{var De;const B=new FormData;B.append("file",v),B.append("folder",A);const we=await(await fetch(wc("/api/upload"),{method:"POST",body:B,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((De=we==null?void 0:we.data)==null?void 0:De.url)||(we==null?void 0:we.url)||""},[]),ki=b.useCallback(v=>ji(v,"book-images"),[ji]),Eo=b.useCallback(v=>{const A=v.type.startsWith("video/")?"book-videos":"book-attachments";return ji(v,A)},[ji]),Os=b.useMemo(()=>{const v=new Map;return St.forEach((A,B)=>{v.set(A.id,B+1)}),v},[St]),En=G9(e,Os),Pa=e.length,Ls=10,kt=Math.max(1,Math.ceil(St.length/Ls)),oa=St.slice((On-1)*Ls,On*Ls),Ln=async()=>{a(!0);try{const v=await Pe("/api/db/book?action=list",{cache:"no-store"});n(Array.isArray(v==null?void 0:v.sections)?v.sections:[])}catch(v){console.error(v),n([])}finally{a(!1)}},hr=async()=>{ge(!0);try{const v=await Pe("/api/db/book?action=ranking",{cache:"no-store"}),A=Array.isArray(v==null?void 0:v.sections)?v.sections:[];cn(A);const B=A.filter(ue=>ue.isPinned).map(ue=>ue.id);$e(B)}catch(v){console.error(v),cn([])}finally{ge(!1)}};b.useEffect(()=>{Ln(),hr()},[]);const Mo=v=>{o(A=>A.includes(v)?A.filter(B=>B!==v):[...A,v])},Tl=b.useCallback(v=>{const A=e,B=v.flatMap(ue=>{const we=A.find(De=>De.id===ue.id);return we?[{...we,partId:ue.partId,partTitle:ue.partTitle,chapterId:ue.chapterId,chapterTitle:ue.chapterTitle}]:[]});return n(B),Gt("/api/db/book",{action:"reorder",items:v}).then(ue=>{ue&&ue.success===!1&&(n(A),se.error("排序失败: "+(ue&&typeof ue=="object"&&"error"in ue?ue.error:"未知错误")))}).catch(ue=>{n(A),console.error("排序失败:",ue),se.error("排序失败: "+(ue instanceof Error?ue.message:"网络或服务异常"))}),Promise.resolve()},[e]),Oa=async v=>{if(confirm(`确定要删除章节「${v.title}」吗?此操作不可恢复。`))try{const A=await li(`/api/db/book?id=${encodeURIComponent(v.id)}`);A&&A.success!==!1?(se.success("已删除"),Ln(),hr()):se.error("删除失败: "+(A&&typeof A=="object"&&"error"in A?A.error:"未知错误"))}catch(A){console.error(A),se.error("删除失败")}},fr=b.useCallback(async()=>{Ft(!0);try{const v=await Pe("/api/db/config/full?key=article_ranking_weights",{cache:"no-store"}),A=v&&v.data;A&&typeof A.readWeight=="number"&&typeof A.recencyWeight=="number"&&typeof A.payWeight=="number"&&Tn({readWeight:Math.max(0,Math.min(1,A.readWeight)),recencyWeight:Math.max(0,Math.min(1,A.recencyWeight)),payWeight:Math.max(0,Math.min(1,A.payWeight))})}catch{}finally{Ft(!1)}},[]);b.useEffect(()=>{dt&&fr()},[dt,fr]);const la=async()=>{const{readWeight:v,recencyWeight:A,payWeight:B}=Tt,ue=v+A+B;if(Math.abs(ue-1)>.001){se.error("三个权重之和必须等于 1");return}vn(!0);try{const we=await Ct("/api/db/config",{key:"article_ranking_weights",value:{readWeight:v,recencyWeight:A,payWeight:B},description:"文章排名算法权重"});we&&we.success!==!1?(se.success("排名权重已保存"),Rt(!1),Ln(),hr()):se.error("保存失败: "+(we&&typeof we=="object"&&"error"in we?we.error:""))}catch(we){console.error(we),se.error("保存失败")}finally{vn(!1)}},Ds=b.useCallback(async()=>{jt(!0);try{const v=await Pe("/api/db/config/full?key=pinned_section_ids",{cache:"no-store"}),A=v&&v.data;Array.isArray(A)&&$e(A)}catch{}finally{jt(!1)}},[]),Bn=b.useCallback(async()=>{try{const v=await Pe("/api/db/persons");v!=null&&v.success&&v.persons&&Pt(v.persons.map(A=>{const B=A.deviceGroups,ue=Array.isArray(B)?B.join(","):B??"";return{id:A.token??A.personId??"",personId:A.personId,name:A.name,personSource:A.personSource??"",userId:A.userId,aliases:A.aliases??"",label:A.label??"",ckbApiKey:A.ckbApiKey??"",ckbPlanId:A.ckbPlanId,remarkType:A.remarkType,remarkFormat:A.remarkFormat,addFriendInterval:A.addFriendInterval,startTime:A.startTime,endTime:A.endTime,deviceGroups:ue}}))}catch{}},[]),Vn=b.useCallback(async()=>{try{const v=await Pe("/api/db/link-tags");v!=null&&v.success&&v.linkTags&&en(v.linkTags.map(A=>({id:A.tagId,label:A.label,url:A.url,type:A.type||"url",appId:A.appId||"",pagePath:A.pagePath||"",hasAppSecret:!!A.hasAppSecret})))}catch{}},[]),Or=b.useCallback(async()=>{try{const v=await Pe("/api/db/config/full?key=ckb_lead_webhook_url",{cache:"no-store"});v!=null&&v.success&&typeof v.data=="string"&&aa(v.data)}catch{}},[]),ca=b.useCallback(async()=>{try{const v=await Pe("/api/db/ckb-person-leads");if(v!=null&&v.success&&v.byPerson){const A={};for(const B of v.byPerson)A[B.token]=B.total;Bc(A)}}catch{}},[]),ps=b.useCallback(async(v,A,B=1)=>{Vc(v),na(A),Ni(!0),Hc(B),Ra(!0);try{const ue=await Pe(`/api/db/ckb-person-leads?token=${encodeURIComponent(v)}&page=${B}&pageSize=20`);ue!=null&&ue.success?(sa(ue.records||[]),Cl(ue.total||0)):se.error((ue==null?void 0:ue.error)||"加载获客详情失败")}catch(ue){se.error(ue instanceof Error?ue.message:"加载获客详情失败")}finally{Ra(!1)}},[]),La=b.useCallback(async()=>{ea(!0);try{const v=new URLSearchParams({page:String(ta),pageSize:String(Mr)}),A=Ss.trim();A&&v.set("search",A);const B=await Pe(`/api/db/link-tags?${v.toString()}`);if(B!=null&&B.success){const ue=Array.isArray(B.linkTags)?B.linkTags:[];Qs(ue.map(we=>({id:we.tagId,label:we.label,aliases:we.aliases||"",url:we.url,type:we.type||"url",appId:we.appId||"",pagePath:we.pagePath||"",hasAppSecret:!!we.hasAppSecret}))),dr(typeof B.total=="number"?B.total:0),Ys(typeof B.totalPages=="number"&&B.totalPages>0?B.totalPages:1)}}catch(v){console.error(v),se.error("加载链接标签失败")}finally{ea(!1)}},[ta,Mr,Ss]),[Da,_a]=b.useState([]),[za,_s]=b.useState(""),[er,zs]=b.useState(!1),El=b.useRef(null),Lr=b.useCallback(async()=>{try{const v=await Pe("/api/admin/linked-miniprograms");v!=null&&v.success&&Array.isArray(v.data)&&_a(v.data.map(A=>({...A,key:A.key})))}catch{}},[]),Dr=Da.filter(v=>!za.trim()||v.name.toLowerCase().includes(za.toLowerCase())||v.key&&v.key.toLowerCase().includes(za.toLowerCase())||v.appId.toLowerCase().includes(za.toLowerCase())),pr=async v=>{const A=Se.includes(v)?Se.filter(B=>B!==v):[...Se,v];$e(A);try{await Ct("/api/db/config",{key:"pinned_section_ids",value:A,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"}),hr()}catch{$e(Se)}},$a=b.useCallback(async()=>{pt(!0);try{const v=await Pe("/api/db/config/full?key=unpaid_preview_percent",{cache:"no-store"}),A=v&&v.data;typeof A=="number"&&A>0&&A<=100&&L(A)}catch{}finally{pt(!1)}},[]),Uc=async()=>{if(gt<1||gt>100){se.error("预览比例需在 1~100 之间");return}ht(!0);try{const v=await Ct("/api/db/config",{key:"unpaid_preview_percent",value:gt,description:"小程序未付费内容默认预览比例(%)"});v&&v.success!==!1?se.success("预览比例已保存"):se.error("保存失败: "+(v.error||""))}catch{se.error("保存失败")}finally{ht(!1)}};b.useEffect(()=>{Ds(),$a(),Bn(),Vn(),ca(),Lr(),Or()},[Ds,$a,Bn,Vn,ca,Lr,Or]),b.useEffect(()=>{La()},[La]);const Ml=async v=>{ze({section:v,orders:[]}),wt(!0);try{const A=await Pe(`/api/db/book?action=section-orders&id=${encodeURIComponent(v.id)}`),B=A!=null&&A.success&&Array.isArray(A.orders)?A.orders:[];ze(ue=>ue?{...ue,orders:B}:null)}catch(A){console.error(A),ze(B=>B?{...B,orders:[]}:null)}finally{wt(!1)}},Fa=async v=>{x(!0);try{const A=v.mid!=null&&v.mid>0?`/api/db/book?action=read&mid=${v.mid}`:`/api/db/book?action=read&id=${encodeURIComponent(v.id)}`,B=await Pe(A);if(B!=null&&B.success&&B.section){const ue=B.section,we=ue.editionPremium===!0;u({id:v.id,originalId:v.id,title:B.section.title??v.title,price:B.section.price??v.price,content:B.section.content??"",filePath:v.filePath,isFree:v.isFree||v.price===0,isNew:ue.isNew??v.isNew,isPinned:Se.includes(v.id),hotScore:v.hotScore??0,editionStandard:we?!1:ue.editionStandard??!0,editionPremium:we})}else u({id:v.id,originalId:v.id,title:v.title,price:v.price,content:"",filePath:v.filePath,isFree:v.isFree,isNew:v.isNew,isPinned:Se.includes(v.id),hotScore:v.hotScore??0,editionStandard:!0,editionPremium:!1}),B&&!B.success&&se.error("无法读取文件内容: "+(B.error||"未知错误"))}catch(A){console.error(A),u({id:v.id,title:v.title,price:v.price,content:"",filePath:v.filePath,isFree:v.isFree})}finally{x(!1)}},Si=async()=>{var v;if(c){N(!0);try{let A=c.content||"";const B=[new RegExp(`^#+\\s*${c.id.replace(".","\\.")}\\s+.*$`,"gm"),new RegExp(`^#+\\s*${c.id.replace(".","\\.")}[::].*$`,"gm"),new RegExp(`^#\\s+.*${(v=c.title)==null?void 0:v.slice(0,10).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}.*$`,"gm")];for(const Je of B)A=A.replace(Je,"");A=A.replace(/^\s*\n+/,"").trim();const ue=c.originalId||c.id,we=c.id!==ue,De=await Gt("/api/db/book",{id:ue,...we?{newId:c.id}:{},title:c.title,price:c.isFree?0:c.price,content:A,isFree:c.isFree||c.price===0,isNew:c.isNew,hotScore:c.hotScore,previewPercent:c.previewPercent??null,editionStandard:c.editionPremium?!1:c.editionStandard??!0,editionPremium:c.editionPremium??!1,saveToFile:!0},{timeout:h1}),it=we?c.id:ue;c.isPinned!==Se.includes(it)&&await pr(it),De&&De.success!==!1?(se.success(`已保存:${c.title}`),u(null),Ln(),Bn(),Vn()):se.error("保存失败: "+(De&&typeof De=="object"&&"error"in De?De.error:"未知错误"))}catch(A){console.error(A);const B=A instanceof Error&&A.name==="AbortError"?"保存超时,请检查网络或稍后重试":"保存失败";se.error(B)}finally{N(!1)}}},Ao=async()=>{if(!O.id||!O.title){se.error("请填写章节ID和标题");return}N(!0);try{const v=En.find(ue=>ue.id===O.partId),A=v==null?void 0:v.chapters.find(ue=>ue.id===O.chapterId),B=await Gt("/api/db/book",{id:O.id,title:O.title,price:O.isFree?0:O.price,content:O.content||"",partId:O.partId,partTitle:(v==null?void 0:v.title)??"",chapterId:O.chapterId,chapterTitle:(A==null?void 0:A.title)??"",isFree:O.isFree,isNew:O.isNew,editionStandard:O.editionPremium?!1:O.editionStandard??!0,editionPremium:O.editionPremium??!1,hotScore:O.hotScore??0,saveToFile:!1},{timeout:h1});if(B&&B.success!==!1){if(O.isPinned){const ue=[...Se,O.id];$e(ue);try{await Ct("/api/db/config",{key:"pinned_section_ids",value:ue,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"})}catch{}}se.success(`章节创建成功:${O.title}`),f(!1),q({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),Ln(),Bn(),Vn()}else se.error("创建失败: "+(B&&typeof B=="object"&&"error"in B?B.error:"未知错误"))}catch(v){console.error(v),se.error("创建失败")}finally{N(!1)}},Io=v=>{q(A=>{var B;return{...A,partId:v.id,chapterId:((B=v.chapters[0])==null?void 0:B.id)??"chapter-1"}}),f(!0)},mr=v=>{V({id:v.id,title:v.title})},Ro=async()=>{var v;if((v=z==null?void 0:z.title)!=null&&v.trim()){te(!0);try{const A=e.map(ue=>({id:ue.id,partId:ue.partId||"part-1",partTitle:ue.partId===z.id?z.title.trim():ue.partTitle||"",chapterId:ue.chapterId||"chapter-1",chapterTitle:ue.chapterTitle||""})),B=await Gt("/api/db/book",{action:"reorder",items:A});if(B&&B.success!==!1){const ue=z.title.trim();n(we=>we.map(De=>De.partId===z.id?{...De,partTitle:ue}:De)),V(null),Ln()}else se.error("更新篇名失败: "+(B&&typeof B=="object"&&"error"in B?B.error:"未知错误"))}catch(A){console.error(A),se.error("更新篇名失败")}finally{te(!1)}}},Ba=v=>{const A=v.chapters.length+1,B=`chapter-${v.id}-${A}-${Date.now()}`;q({id:`${A}.1`,title:"新章节",price:1,partId:v.id,chapterId:B,content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),f(!0)},Po=(v,A)=>{const B=A.sections;let ue=1,we=!1,De=!1;if(B.length>0){const it=typeof B[0].price=="number"?B[0].price:Number(B[0].price)||1,Je=!!(B[0].isFree||it===0);De=B.some(vt=>{const At=typeof vt.price=="number"?vt.price:Number(vt.price)||1,dn=!!(vt.isFree||At===0);return At!==it||dn!==Je}),ue=Je?0:it,we=Je}ie({part:v,chapter:A,title:A.title,price:ue,isFree:we,priceMixed:De,initialTitle:A.title,initialPrice:ue,initialIsFree:we})},Ci=async()=>{var we;if(!((we=re==null?void 0:re.title)!=null&&we.trim()))return;const v=re,A=v.title.trim(),B=A!==v.initialTitle,ue=v.isFree!==v.initialIsFree||!v.isFree&&Number(v.price)!==Number(v.initialPrice);if(!B&&!ue){se.info("未修改任何内容"),ie(null);return}if(v.priceMixed&&ue){const De=v.chapter.sections.length,it=v.isFree?"全部设为免费":`全部设为 ¥${v.price}`;if(!confirm(`本章 ${De} 节当前定价不一致,保存后将${it},确定?`))return}$(!0);try{if(B){const De=e.map(At=>({id:At.id,partId:At.partId||v.part.id,partTitle:At.partId===v.part.id?v.part.title:At.partTitle||"",chapterId:At.chapterId||v.chapter.id,chapterTitle:At.partId===v.part.id&&At.chapterId===v.chapter.id?A:At.chapterTitle||""})),it=await Gt("/api/db/book",{action:"reorder",items:De});if(it&&it.success===!1){se.error("保存章节名失败: "+(it&&typeof it=="object"&&"error"in it?it.error:"未知错误"));return}const Je=v.part.id,vt=v.chapter.id;n(At=>At.map(dn=>dn.partId===Je&&dn.chapterId===vt?{...dn,chapterTitle:A}:dn))}if(ue){const De=await Gt("/api/db/book",{action:"update-chapter-pricing",partId:v.part.id,chapterId:v.chapter.id,price:v.isFree?0:Number(v.price)||0,isFree:v.isFree});if(De&&De.success===!1){se.error("保存定价失败: "+(De&&typeof De=="object"&&"error"in De?De.error:"未知错误")),B&&Ln();return}}ie(null),Ln(),se.success("已保存")}catch(De){console.error(De),se.error("保存失败")}finally{$(!1)}},Ti=async(v,A)=>{const B=A.sections.map(ue=>ue.id);if(B.length===0){se.info("该章下无小节,无需删除");return}if(confirm(`确定要删除「第${v.chapters.indexOf(A)+1}章 | ${A.title}」吗?将删除共 ${B.length} 节,此操作不可恢复。`))try{for(const ue of B)await li(`/api/db/book?id=${encodeURIComponent(ue)}`);Ln()}catch(ue){console.error(ue),se.error("删除失败")}},Oo=async()=>{if(!le.trim()){se.error("请输入篇名");return}ye(!0);try{const v=`part-new-${Date.now()}`,A="chapter-1",B=`part-placeholder-${Date.now()}`,ue=await Gt("/api/db/book",{id:B,title:"占位节(可编辑)",price:0,content:"",partId:v,partTitle:le.trim(),chapterId:A,chapterTitle:"第1章 | 待编辑",saveToFile:!1});ue&&ue.success!==!1?(se.success(`篇「${le}」创建成功`),F(!1),de(""),Ln()):se.error("创建失败: "+(ue&&typeof ue=="object"&&"error"in ue?ue.error:"未知错误"))}catch(v){console.error(v),se.error("创建失败")}finally{ye(!1)}},ss=async()=>{if(D.length===0){se.error("请先勾选要移动的章节");return}const v=En.find(B=>B.id===_),A=v==null?void 0:v.chapters.find(B=>B.id===H);if(!v||!A||!_||!H){se.error("请选择目标篇和章");return}Y(!0);try{const B=()=>{const it=new Set(D),Je=e.map(un=>({id:un.id,partId:un.partId||"",partTitle:un.partTitle||"",chapterId:un.chapterId||"",chapterTitle:un.chapterTitle||""})),vt=Je.filter(un=>it.has(un.id)).map(un=>({...un,partId:_,partTitle:v.title||_,chapterId:H,chapterTitle:A.title||H})),At=Je.filter(un=>!it.has(un.id));let dn=At.length;for(let un=At.length-1;un>=0;un-=1){const Al=At[un];if(Al.partId===_&&Al.chapterId===H){dn=un+1;break}}return[...At.slice(0,dn),...vt,...At.slice(dn)]},ue=async()=>{const it=B(),Je=await Gt("/api/db/book",{action:"reorder",items:it});return Je&&Je.success!==!1?(se.success(`已移动 ${D.length} 节到「${v.title}」-「${A.title}」`),G(!1),R([]),await Ln(),!0):!1},we={action:"move-sections",sectionIds:D,targetPartId:_,targetChapterId:H,targetPartTitle:v.title||_,targetChapterTitle:A.title||H},De=await Gt("/api/db/book",we);if(De&&De.success!==!1)se.success(`已移动 ${De.count??D.length} 节到「${v.title}」-「${A.title}」`),G(!1),R([]),await Ln();else{const it=De&&typeof De=="object"&&"error"in De?De.error||"":"未知错误";if((it.includes("缺少 id")||it.includes("无效的 action"))&&await ue())return;se.error("移动失败: "+it)}}catch(B){console.error(B),se.error("移动失败: "+(B instanceof Error?B.message:"网络或服务异常"))}finally{Y(!1)}},_r=v=>{R(A=>A.includes(v)?A.filter(B=>B!==v):[...A,v])},Ei=async v=>{const A=e.filter(B=>B.partId===v.id).map(B=>B.id);if(A.length===0){se.info("该篇下暂无小节可删除");return}if(confirm(`确定要删除「${v.title}」整篇吗?将删除共 ${A.length} 节内容,此操作不可恢复。`))try{for(const B of A)await li(`/api/db/book?id=${encodeURIComponent(B)}`);Ln()}catch(B){console.error(B),se.error("删除失败")}},zr=async()=>{var v;if(w.trim()){P(!0);try{const A=await Pe(`/api/search?q=${encodeURIComponent(w)}`);A!=null&&A.success&&((v=A.data)!=null&&v.results)?E(A.data.results):(E([]),A&&!A.success&&se.error("搜索失败: "+A.error))}catch(A){console.error(A),E([]),se.error("搜索失败")}finally{P(!1)}}},Mi=En.find(v=>v.id===O.partId),Va=(Mi==null?void 0:Mi.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:["共 ",En.length," 篇 · ",Pa," 节内容"]})]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(X,{onClick:()=>Rt(!0),variant:"outline",className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(dh,{className:"w-4 h-4 mr-2"}),"排名算法"]})})]}),s.jsx(Dt,{open:h,onOpenChange:f,children:s.jsxs(Lt,{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(_t,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(An,{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(ee,{className:"text-gray-300",children:"章节ID *"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 9.15",value:O.id,onChange:v=>q({...O,id:v.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:O.isFree?0:O.price,onChange:v=>q({...O,price:Number(v.target.value),isFree:Number(v.target.value)===0}),disabled:O.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"免费"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:O.isFree,onChange:v=>q({...O,isFree:v.target.checked,price:v.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(ee,{className:"text-gray-300",children:"最新新增"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:O.isNew,onChange:v=>q({...O,isNew:v.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(ee,{className:"text-gray-300",children:"小程序直推"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:O.isPinned,onChange:v=>q({...O,isPinned:v.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(ee,{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:O.editionPremium!==!0,onChange:()=>q({...O,editionStandard:!0,editionPremium:!1}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"普通版"})]}),s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"new-edition-type",checked:O.editionPremium===!0,onChange:()=>q({...O,editionStandard:!1,editionPremium:!0}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"增值版"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"热度分"}),s.jsx(ce,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:O.hotScore??0,onChange:v=>q({...O,hotScore:Math.max(0,parseFloat(v.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"章节标题 *"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入章节标题",value:O.title,onChange:v=>q({...O,title:v.target.value})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"所属篇"}),s.jsxs(lc,{value:O.partId,onValueChange:v=>{var B;const A=En.find(ue=>ue.id===v);q({...O,partId:v,chapterId:((B=A==null?void 0:A.chapters[0])==null?void 0:B.id)??"chapter-1"})},children:[s.jsx(Qo,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(cc,{})}),s.jsxs(Yo,{className:"bg-[#0f2137] border-gray-700",children:[En.map(v=>s.jsx(Ws,{value:v.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:v.title},v.id)),En.length===0&&s.jsx(Ws,{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(ee,{className:"text-gray-300",children:"所属章"}),s.jsxs(lc,{value:O.chapterId,onValueChange:v=>q({...O,chapterId:v}),children:[s.jsx(Qo,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(cc,{})}),s.jsxs(Yo,{className:"bg-[#0f2137] border-gray-700",children:[Va.map(v=>s.jsx(Ws,{value:v.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:v.title},v.id)),Va.length===0&&s.jsx(Ws,{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(ee,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),s.jsx(n0,{content:O.content||"",onChange:v=>q({...O,content:v}),onImageUpload:ki,onMediaUpload:Eo,persons:tt,linkTags:Wt,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(fn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[s.jsx(X,{variant:"outline",onClick:()=>f(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(X,{onClick:Ao,disabled:y||!O.id||!O.title,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:y?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(An,{className:"w-4 h-4 mr-2"}),"创建章节"]})})]})]})}),s.jsx(Dt,{open:!!z,onOpenChange:v=>!v&&V(null),children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(Jt,{className:"w-5 h-5 text-[#38bdac]"}),"编辑篇名"]})}),z&&s.jsx("div",{className:"space-y-4 py-4",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"篇名"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:z.title,onChange:v=>V({...z,title:v.target.value}),placeholder:"输入篇名"})]})}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",onClick:()=>V(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(X,{onClick:Ro,disabled:I||!((Ha=z==null?void 0:z.title)!=null&&Ha.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:I?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Dt,{open:!!re,onOpenChange:v=>!v&&ie(null),children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsxs(_t,{children:[s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(Jt,{className:"w-5 h-5 text-[#38bdac]"}),"章节设置"]}),s.jsx("p",{className:"text-gray-400 text-sm font-normal pt-1",children:"修改本章显示名称,或为本章下全部节设置统一金额(仍可在单节编辑里单独改某一节)。"})]}),re&&s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"章节名称(如:第8章|底层结构)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:re.title,onChange:v=>ie({...re,title:v.target.value}),placeholder:"输入章节名称"})]}),s.jsxs("div",{className:"space-y-2 border-t border-gray-700/60 pt-4",children:[s.jsxs(ee,{className:"text-gray-300",children:["本章统一定价(应用于本章全部 ",re.chapter.sections.length," 节)"]}),re.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(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:re.isFree?0:re.price,onChange:v=>ie({...re,price:Number(v.target.value),isFree:Number(v.target.value)===0}),disabled:re.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:re.isFree||re.price===0,onChange:v=>ie({...re,isFree:v.target.checked,price:v.target.checked?0:re.initialPrice>0?re.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(fn,{children:[s.jsx(X,{variant:"outline",onClick:()=>ie(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(X,{onClick:Ci,disabled:J||!(($r=re==null?void 0:re.title)!=null&&$r.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:J?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Dt,{open:oe,onOpenChange:v=>{var A;if(G(v),v&&En.length>0){const B=En[0];U(B.id),K(((A=B.chapters[0])==null?void 0:A.id)??"")}},children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(_t,{children:s.jsx(zt,{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:D.length})," 节,请选择目标篇与章。"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"目标篇"}),s.jsxs(lc,{value:_,onValueChange:v=>{var B;U(v);const A=En.find(ue=>ue.id===v);K(((B=A==null?void 0:A.chapters[0])==null?void 0:B.id)??"")},children:[s.jsx(Qo,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(cc,{placeholder:"选择篇"})}),s.jsx(Yo,{className:"bg-[#0f2137] border-gray-700",children:En.map(v=>s.jsx(Ws,{value:v.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:v.title},v.id))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"目标章"}),s.jsxs(lc,{value:H,onValueChange:K,children:[s.jsx(Qo,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(cc,{placeholder:"选择章"})}),s.jsx(Yo,{className:"bg-[#0f2137] border-gray-700",children:(((da=En.find(v=>v.id===_))==null?void 0:da.chapters)??[]).map(v=>s.jsx(Ws,{value:v.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:v.title},v.id))})]})]})]}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",onClick:()=>G(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(X,{onClick:ss,disabled:me||D.length===0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:me?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"移动中..."]}):"确认移动"})]})]})}),s.jsx(Dt,{open:!!ke,onOpenChange:v=>!v&&ze(null),children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",showCloseButton:!0,children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white",children:["付款记录 — ",(ke==null?void 0:ke.section.title)??""]})}),s.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:ft?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):ke&&ke.orders.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"暂无付款记录"}):ke?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:ke.orders.map(v=>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:`查看订单 ${v.orderSn}`,onClick:()=>window.open(`/orders?search=${v.orderSn??v.id??""}`,"_blank"),children:v.orderSn?v.orderSn.length>16?v.orderSn.slice(0,8)+"..."+v.orderSn.slice(-6):v.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:`查看用户 ${v.userId??v.openId??""}`,onClick:()=>window.open(`/users?search=${v.userId??v.openId??""}`,"_blank"),children:(()=>{const A=v.userId??v.openId??"-";return A.length>12?A.slice(0,6)+"..."+A.slice(-4):A})()})}),s.jsxs("td",{className:"py-2 pr-2 text-gray-300",children:["¥",v.amount??0]}),s.jsx("td",{className:"py-2 pr-2 text-gray-300",children:v.status??"-"}),s.jsx("td",{className:"py-2 pr-2 text-gray-500",children:v.payTime??v.createdAt??"-"})]},v.id??v.orderSn??""))})]}):null})]})}),s.jsx(Dt,{open:dt,onOpenChange:Rt,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(dh,{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)"}),mn?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(ee,{className:"text-gray-400 text-xs",children:"阅读权重"}),s.jsx(ce,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Tt.readWeight,onChange:v=>Tn(A=>({...A,readWeight:Math.max(0,Math.min(1,parseFloat(v.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"新度权重"}),s.jsx(ce,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Tt.recencyWeight,onChange:v=>Tn(A=>({...A,recencyWeight:Math.max(0,Math.min(1,parseFloat(v.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-400 text-xs",children:"付款权重"}),s.jsx(ce,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Tt.payWeight,onChange:v=>Tn(A=>({...A,payWeight:Math.max(0,Math.min(1,parseFloat(v.target.value)||0))}))})]})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["当前之和: ",(Tt.readWeight+Tt.recencyWeight+Tt.payWeight).toFixed(1)]}),s.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs text-gray-400",children:[s.jsx("li",{children:"阅读量前 20 名:第1名=20分、第2名=19分...第20名=1分"}),s.jsx("li",{children:"最近更新前 30 篇:第1名=30分、第2名=29分...第30名=1分"}),s.jsx("li",{children:"付款数前 20 名:第1名=20分、第2名=19分...第20名=1分"}),s.jsx("li",{children:"热度分可在编辑章节中手动覆盖"})]}),s.jsx(X,{onClick:la,disabled:qt||Math.abs(Tt.readWeight+Tt.recencyWeight+Tt.payWeight-1)>.001,className:"w-full bg-amber-500 hover:bg-amber-600 text-white",children:qt?"保存中...":"保存权重"})]})]})]})}),s.jsx(Dt,{open:Q,onOpenChange:F,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(An,{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(ee,{className:"text-gray-300",children:"篇名(如:第六篇|真实的社会)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:le,onChange:v=>de(v.target.value),placeholder:"输入篇名"})]})}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",onClick:()=>{F(!1),de("")},className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(X,{onClick:Oo,disabled:ve||!le.trim(),className:"bg-amber-500 hover:bg-amber-600 text-white",children:ve?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(An,{className:"w-4 h-4 mr-2"}),"创建篇"]})})]})]})}),s.jsx(Dt,{open:!!c,onOpenChange:()=>u(null),children:s.jsxs(Lt,{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(_t,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(Jt,{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(ee,{className:"text-gray-300",children:"章节ID"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:c.id,onChange:v=>u({...c,id:v.target.value}),placeholder:"如: 9.15"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:c.isFree?0:c.price,onChange:v=>u({...c,price:Number(v.target.value),isFree:Number(v.target.value)===0}),disabled:c.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{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:v=>u({...c,isFree:v.target.checked,price:v.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(ee,{className:"text-gray-300",children:"预览%"}),s.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",placeholder:`全局 ${gt}%`,value:c.previewPercent??"",onChange:v=>{const A=v.target.value===""?void 0:Math.min(100,Math.max(0,Number(v.target.value)));u({...c,previewPercent:A})}})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{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:v=>u({...c,isNew:v.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(ee,{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:v=>u({...c,isPinned:v.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(ee,{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(ee,{className:"text-gray-300",children:"热度分"}),s.jsx(ce,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:c.hotScore??0,onChange:v=>u({...c,hotScore:Math.max(0,parseFloat(v.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"章节标题"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:c.title,onChange:v=>u({...c,title:v.target.value})})]}),c.filePath&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"文件路径"}),s.jsx(ce,{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(ee,{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(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(n0,{ref:ia,content:c.content||"",onChange:v=>u({...c,content:v}),onImageUpload:ki,onMediaUpload:Eo,persons:tt,linkTags:Wt,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(fn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[c&&s.jsxs(X,{variant:"outline",onClick:()=>Ml({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(Gs,{className:"w-4 h-4 mr-2"}),"付款记录"]}),s.jsxs(X,{variant:"outline",onClick:()=>u(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsx(X,{onClick:Si,disabled:y,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:y?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),"保存修改"]})})]})]})}),s.jsxs(jc,{defaultValue:"chapters",className:"space-y-6",children:[s.jsxs(ul,{className:"bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(Qt,{value:"chapters",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(Gs,{className:"w-4 h-4 mr-2"}),"章节管理"]}),s.jsxs(Qt,{value:"ranking",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(ug,{className:"w-4 h-4 mr-2"}),"内容排行榜"]}),s.jsxs(Qt,{value:"search",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(va,{className:"w-4 h-4 mr-2"}),"内容搜索"]}),s.jsxs(Qt,{value:"link-person",className:"data-[state=active]:bg-purple-500/20 data-[state=active]:text-purple-400 text-gray-400",children:[s.jsx(ya,{className:"w-4 h-4 mr-2"}),"链接人与事"]}),s.jsxs(Qt,{value:"link-tag",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(l1,{className:"w-4 h-4 mr-2"}),"链接标签"]})]}),s.jsxs(Yt,{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(Gs,{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:Pa}),s.jsx("span",{className:"text-xs text-gray-500",children:"章节"})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(X,{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(An,{className:"w-4 h-4 mr-2"}),"新建章节"]}),s.jsxs(X,{onClick:()=>F(!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(An,{className:"w-4 h-4 mr-2"}),"新建篇"]}),s.jsxs(X,{variant:"outline",onClick:()=>G(!0),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:["批量移动(已选 ",D.length," 节)"]})]}),r?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(H9,{parts:En,expandedParts:i,onTogglePart:Mo,onReorder:Tl,onReadSection:Fa,onDeleteSection:Oa,onAddSectionInPart:Io,onAddChapterInPart:Ba,onDeleteChapter:Ti,onEditPart:mr,onDeletePart:Ei,onEditChapter:Po,selectedSectionIds:D,onToggleSectionSelect:_r,onShowSectionOrders:Ml,pinnedSectionIds:Se})]}),s.jsx(Yt,{value:"search",className:"space-y-4",children:s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(rt,{children:s.jsx(at,{className:"text-white",children:"内容搜索"})}),s.jsxs(Le,{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",placeholder:"搜索标题或内容...",value:w,onChange:v=>j(v.target.value),onKeyDown:v=>v.key==="Enter"&&zr()}),s.jsx(X,{onClick:zr,disabled:T||!w.trim(),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:T?s.jsx(Fe,{className:"w-4 h-4 animate-spin"}):s.jsx(va,{className:"w-4 h-4"})})]}),S.length>0&&s.jsxs("div",{className:"space-y-2 mt-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["找到 ",S.length," 个结果"]}),S.map(v=>s.jsxs("div",{className:"p-3 rounded-lg bg-[#162840] hover:bg-[#1a3050] cursor-pointer transition-colors",onClick:()=>Fa({id:v.id,mid:v.mid,title:v.title,price:v.price??1,filePath:""}),children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[#38bdac] font-mono text-xs",children:v.id}),s.jsx("span",{className:"text-white",children:v.title}),Se.includes(v.id)&&s.jsx(uc,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})]}),s.jsx(Ve,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:v.matchType==="title"?"标题匹配":"内容匹配"})]}),v.snippet&&s.jsx("p",{className:"text-gray-500 text-xs mt-2 line-clamp-2",children:v.snippet}),(v.partTitle||v.chapterTitle)&&s.jsxs("p",{className:"text-gray-600 text-xs mt-1",children:[v.partTitle," · ",v.chapterTitle]})]},v.id))]})]})]})}),s.jsxs(Yt,{value:"ranking",className:"space-y-4",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(rt,{className:"pb-3",children:s.jsxs(at,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(dh,{className:"w-4 h-4 text-[#38bdac]"}),"内容显示规则"]})}),s.jsx(Le,{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(ee,{className:"text-gray-400 text-sm whitespace-nowrap",children:"未付费预览比例"}),s.jsx(ce,{type:"number",min:"1",max:"100",className:"bg-[#0a1628] border-gray-700 text-white w-20",value:gt,onChange:v=>L(Math.max(1,Math.min(100,Number(v.target.value)||20))),disabled:Me}),s.jsx("span",{className:"text-gray-500 text-sm",children:"%"})]}),s.jsx(X,{size:"sm",onClick:Uc,disabled:Et,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:Et?"保存中...":"保存"}),s.jsxs("span",{className:"text-xs text-gray-500",children:["小程序未付费用户默认显示文章前 ",gt,"% 内容"]})]})})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(rt,{className:"pb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(at,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(ug,{className:"w-4 h-4 text-amber-400"}),"内容排行榜",s.jsxs("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["按热度排行 · 共 ",St.length," 节"]})]}),s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>hr(),disabled:xn,className:"text-gray-400 hover:text-white h-7 w-7 p-0",title:"刷新排行榜",children:s.jsx(Fe,{className:`w-4 h-4 ${xn?"animate-spin":""}`})}),s.jsx(X,{variant:"ghost",size:"sm",disabled:On<=1||xn,onClick:()=>$n(v=>Math.max(1,v-1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(c5,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-gray-400 min-w-[60px] text-center",children:[On," / ",kt]}),s.jsx(X,{variant:"ghost",size:"sm",disabled:On>=kt||xn,onClick:()=>$n(v=>Math.min(kt,v+1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(Xo,{className:"w-4 h-4"})})]})]})}),s.jsx(Le,{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:"编辑"})]}),oa.map((v,A)=>{const B=(On-1)*Ls+A+1,ue=v.isPinned??Se.includes(v.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 ${ue?"bg-amber-500/5":""}`,children:[s.jsx("span",{className:`text-sm font-bold ${B<=3?"text-amber-400":"text-gray-500"}`,children:B<=3?["🥇","🥈","🥉"][B-1]:`#${B}`}),s.jsx(X,{variant:"ghost",size:"sm",className:`h-6 w-6 p-0 ${ue?"text-amber-400":"text-gray-600 hover:text-amber-400"}`,onClick:()=>pr(v.id),disabled:Xe,title:ue?"取消置顶":"强制置顶(精选推荐/首页最新更新)",children:ue?s.jsx(uc,{className:"w-3.5 h-3.5 fill-current"}):s.jsx(LM,{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:v.title}),s.jsxs("span",{className:"text-gray-600 text-xs",children:[v.partTitle," · ",v.chapterTitle]})]}),s.jsx("span",{className:"text-right text-sm text-blue-400 font-mono",children:v.clickCount??0}),s.jsx("span",{className:"text-right text-sm text-green-400 font-mono",children:v.payCount??0}),s.jsx("span",{className:"text-right text-sm text-amber-400 font-mono",children:(v.hotScore??0).toFixed(1)}),s.jsx("div",{className:"text-right",children:s.jsx(X,{variant:"ghost",size:"sm",className:"text-gray-500 hover:text-[#38bdac] h-6 px-1",onClick:()=>Fa({id:v.id,mid:v.mid,title:v.title,price:v.price,filePath:""}),title:"编辑文章",children:s.jsx(Jt,{className:"w-3 h-3"})})})]},v.id)}),oa.length===0&&s.jsx("div",{className:"py-8 text-center text-gray-500",children:"暂无数据"})]})})]})]}),s.jsxs(Yt,{value:"link-person",className:"space-y-4",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"pb-3",children:[s.jsxs(at,{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(Le,{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(X,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50",onClick:()=>{Bn()},title:"刷新",children:s.jsx(Fe,{className:"w-4 h-4"})}),s.jsxs(X,{size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:()=>{Zs(null),Aa(!0)},children:[s.jsx(An,{className:"w-4 h-4 mr-2"}),"添加"]})]})]}),s.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:tt.length>0?s.jsxs("table",{className:"w-full text-sm border-collapse",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-xs text-gray-500 border-b border-gray-700/50",children:[s.jsx("th",{className:"text-left py-1.5 px-3 w-[280px] font-normal",children:"token"}),s.jsx("th",{className:"text-left py-1.5 px-3 w-24 font-normal",children:"@的人"}),s.jsx("th",{className:"text-left py-1.5 px-3 w-[72px] font-normal text-xs",children:"来源"}),s.jsx("th",{className:"text-left py-1.5 px-3 w-[100px] font-normal text-xs",children:"会员"}),s.jsx("th",{className:"py-1.5 px-3 w-16 font-normal text-center",children:"获客数"}),s.jsx("th",{className:"text-left py-1.5 px-3 font-normal",children:"获客计划"}),s.jsx("th",{className:"text-left py-1.5 px-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:tt.map(v=>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:v.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:()=>{Mt[v.id]&&ps(v.id,v.name)},title:Mt[v.id]?"点击查看获客详情":v.name,children:v.name})}),s.jsx("td",{className:"py-2 px-3",children:v.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:v.userId?s.jsxs("div",{className:"flex flex-col gap-0.5 items-start max-w-[100px]",children:[v.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: ${v.userId}`,onClick:()=>t(`/users?search=${encodeURIComponent(v.userId||"")}`),children:v.name})]}):s.jsx("span",{className:"text-gray-600",children:"—"})}),(()=>{const A=Mt[v.id]||0;return s.jsx("td",{className:`py-2 px-3 shrink-0 w-16 text-center text-xs font-bold cursor-pointer ${A>0?"text-green-400 hover:text-green-300 hover:underline":"text-gray-600"}`,title:A>0?"点击查看获客详情":"暂无获客",onClick:()=>{A>0&&ps(v.id,v.name)},children:A})})(),s.jsx("td",{className:"py-2 px-3 text-white truncate max-w-[220px]",title:`planId: ${v.ckbPlanId??"-"}`,children:s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsx("span",{className:"truncate",children:v.ckbPlanId?v.personSource==="vip_sync"?"超级个体拉群(统一计划)":`SOUL链接人与事-${v.name}`:"—"})})}),s.jsx("td",{className:"py-2 px-3 text-center",children:v.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(X,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-[#38bdac] h-6 px-2",title:"编辑",onClick:async()=>{try{const A=await W9(v.personId||"");if(A!=null&&A.success&&A.person){const B=A.person;Zs({id:B.token??B.personId,personId:B.personId,name:B.name,personSource:B.personSource??"",userId:B.userId??"",label:B.label??"",ckbApiKey:B.ckbApiKey??"",remarkType:B.remarkType,remarkFormat:B.remarkFormat,addFriendInterval:B.addFriendInterval,startTime:B.startTime,endTime:B.endTime,deviceGroups:B.deviceGroups})}else Zs(v),A!=null&&A.error&&se.error(A.error)}catch(A){console.error(A),Zs(v),se.error(A instanceof Error?A.message:"加载人物详情失败")}Aa(!0)},children:s.jsx(c1,{className:"w-3 h-3"})}),s.jsx(X,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-green-400 h-6 px-2",title:"查看新客户",onClick:()=>ps(v.id,v.name),children:s.jsx(In,{className:"w-3 h-3"})}),s.jsx(X,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",title:v.personSource==="vip_sync"?"删除本地 @人物(不删统一获客计划)":"删除(同时删除存客宝对应获客计划)",onClick:()=>vi(v),children:s.jsx(Yn,{className:"w-3 h-3"})})]})})]},v.id))})]}):s.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无AI人物,添加后可在编辑器中 @链接"})})]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"pb-3",children:[s.jsxs(at,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(QM,{className:"w-4 h-4 text-[#38bdac]"}),"存客宝绑定"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"配置存客宝 API 后,文章中 @人物 或 #标签 点击可自动进入存客宝流量池"})]}),s.jsxs(Le,{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(ee,{className:"text-gray-400 text-xs",children:"存客宝 API 地址"}),s.jsx(ce,{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(ee,{className:"text-gray-400 text-xs",children:"绑定计划"}),s.jsx(ce,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"pb-3",children:[s.jsxs(at,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(dh,{className:"w-4 h-4 text-blue-400"}),"获客 Webhook 通知"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"配置后新获客线索将自动推送到群聊(支持企业微信/飞书 Webhook)"})]}),s.jsxs(Le,{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(ee,{className:"text-gray-400 text-xs",children:"Webhook URL"}),s.jsx(ce,{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:ra,onChange:v=>aa(v.target.value)})]}),s.jsxs(X,{size:"sm",className:"bg-blue-500 hover:bg-blue-600 text-white h-8",onClick:async()=>{const v=ra.trim();try{const A=await Ct("/api/db/config",{key:"ckb_lead_webhook_url",value:v,description:"获客线索 Webhook 通知 URL(企微/飞书)"});A!=null&&A.success?se.success(v?"Webhook 已保存":"Webhook 已清除"):se.error((A==null?void 0:A.error)??"保存失败")}catch{se.error("保存失败")}},children:[s.jsx(bn,{className:"w-3.5 h-3.5 mr-1"}),"保存"]})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"配置企业微信或飞书群机器人 Webhook URL,获客成功后自动推送通知"})]})]})]}),s.jsxs(Yt,{value:"link-tag",className:"space-y-4",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"pb-3",children:[s.jsxs(at,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(l1,{className:"w-4 h-4 text-amber-400"}),"链接标签 — 链接事与物(编辑器内 #标签 可跳转链接/小程序/存客宝)"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"小程序端点击 #标签 可直接跳转对应链接,进入流量池"})]}),s.jsxs(Le,{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(ee,{className:"text-gray-400 text-xs",children:"搜索"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-48",placeholder:"按标签ID/显示文字搜索",value:Ss,onChange:v=>{Xs(v.target.value),Er(1)}})]}),s.jsx(X,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50 h-8",onClick:()=>{Vn(),La()},title:"刷新",children:s.jsx(Fe,{className:"w-4 h-4"})})]}),s.jsxs(X,{size:"sm",className:"bg-amber-500 hover:bg-amber-600 text-white h-8",onClick:()=>{xe(null),ut({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",appSecret:"",pagePath:""}),_s(""),zs(!1),Cs(!0)},children:[s.jsx(An,{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:bi?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:"加载中..."})}):ts.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:"暂无链接标签,添加后可在编辑器中使用 #标签 跳转"})}):ts.map(v=>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:()=>{xe(v),ut({tagId:v.id,label:v.label,aliases:v.aliases??"",url:v.url,type:v.type,appId:v.appId??"",appSecret:"",pagePath:v.pagePath??""}),_s(v.appId??""),zs(!1),Cs(!0)},title:"点击编辑标签",children:["#",v.label]})}),s.jsx("td",{className:"px-3 py-2 text-gray-500 text-xs truncate max-w-[120px]",title:v.aliases||"",children:v.aliases||"—"}),s.jsx("td",{className:"px-3 py-2",children:s.jsx(Ve,{variant:"secondary",className:`text-[10px] ${v.type==="ckb"?"bg-green-500/20 text-green-300 border-green-500/30":v.type==="miniprogram"||v.type==="wxlink"?"bg-[#38bdac]/20 text-[#38bdac] border-[#38bdac]/30":"bg-gray-700 text-gray-300"}`,children:v.type==="url"?"网页":v.type==="ckb"?"存客宝":v.type==="wxlink"?"小程序链接":"小程序"})}),s.jsx("td",{className:"px-3 py-2 text-gray-300",children:v.type==="miniprogram"?s.jsxs("div",{className:"space-y-0.5",children:[(()=>{const A=Da.find(B=>B.key===v.appId);return s.jsxs(s.Fragment,{children:[A&&s.jsx("div",{className:"text-xs text-white",children:A.name}),s.jsxs("div",{className:"text-xs font-mono text-[#38bdac]",children:["AppID: ",(A==null?void 0:A.appId)||v.appId||"—"]})]})})(),v.pagePath&&s.jsx("div",{className:"text-xs text-gray-500 font-mono",children:v.pagePath}),s.jsxs("div",{className:`text-xs ${v.hasAppSecret?"text-emerald-400/90":"text-amber-500/80"}`,children:["AppSecret:",v.hasAppSecret?"已保存(仅服务端)":"未配置"]})]}):v.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:v.url,children:v.url||"—"}),s.jsx("div",{className:"text-[11px] text-gray-500",children:"小程序内点击 → web-view 打开 → 自动唤起目标小程序"})]}):v.url?s.jsxs("a",{href:v.url,target:"_blank",rel:"noreferrer",className:"text-blue-400 text-xs truncate max-w-[420px] hover:underline inline-flex items-center gap-1",children:[v.url," ",s.jsx(fi,{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(X,{variant:"ghost",size:"sm",className:"text-gray-300 hover:text-white h-7 px-2",onClick:()=>{xe(v),ut({tagId:v.id,label:v.label,aliases:v.aliases??"",url:v.url,type:v.type,appId:v.appId??"",appSecret:"",pagePath:v.pagePath??""}),_s(v.appId??""),zs(!1),Cs(!0)},title:"编辑",children:s.jsx(c1,{className:"w-3 h-3"})}),s.jsx(X,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-7 px-2",onClick:async()=>{if(confirm(`确定要删除「#${v.label}」吗?`))try{const A=await li(`/api/db/link-tags?tagId=${encodeURIComponent(v.id)}`);A!=null&&A.success?(se.success("已删除"),Vn(),La()):se.error((A==null?void 0:A.error)??"删除失败")}catch(A){console.error(A),se.error("删除失败")}},title:"删除",children:s.jsx(Yn,{className:"w-3 h-3"})})]})})]},v.id))})]})}),s.jsx(qs,{page:ta,pageSize:Mr,total:cr,totalPages:Ea,onPageChange:v=>Er(v),onPageSizeChange:v=>{Ar(v),Er(1)}})]})]})]}),s.jsx(Dt,{open:ur,onOpenChange:Cs,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg p-4 gap-3",children:[s.jsxs(_t,{className:"gap-1",children:[s.jsx(zt,{className:"text-base",children:ae?"编辑链接标签":"添加链接标签"}),s.jsx(Zh,{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(ee,{className:"text-gray-300 text-sm",children:"标签ID"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"留空自动生成;或自定义短 ID(如 kr),最长 50 字符",value:Ue.tagId,disabled:!!ae,onChange:v=>ut(A=>({...A,tagId:v.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"显示文字"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"如 神仙团队",value:Ue.label,onChange:v=>ut(A=>({...A,label:v.target.value}))})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"别名(多个用逗号分隔,同指向一个目标)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"如 团队招募, 团队合伙人",value:Ue.aliases,onChange:v=>ut(A=>({...A,aliases:v.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(ee,{className:"text-gray-300 text-sm",children:"类型"}),s.jsxs(lc,{value:Ue.type,onValueChange:v=>ut(A=>({...A,type:v})),children:[s.jsx(Qo,{className:"bg-[#0a1628] border-gray-700 text-white h-8",children:s.jsx(cc,{})}),s.jsxs(Yo,{className:"bg-[#0f2137] border-gray-700 text-white",children:[s.jsx(Ws,{value:"url",children:"网页链接"}),s.jsx(Ws,{value:"miniprogram",children:"小程序(API跳转)"}),s.jsx(Ws,{value:"wxlink",children:"小程序链接(右上角复制)"}),s.jsx(Ws,{value:"ckb",children:"存客宝"})]})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:Ue.type==="url"?"URL地址":Ue.type==="ckb"?"存客宝计划URL":Ue.type==="wxlink"?"小程序链接":"小程序 mpKey / 微信 AppID"}),Ue.type==="wxlink"?s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"粘贴小程序右上角 ... → 复制链接 得到的 URL",value:Ue.url,onChange:v=>ut(A=>({...A,url:v.target.value}))}):Ue.type==="miniprogram"&&Da.length>0?s.jsxs("div",{ref:El,className:"relative",children:[s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"搜索名称或密钥",value:er?za:Ue.appId,onChange:v=>{const A=v.target.value;_s(A),zs(!0),Da.some(B=>B.key===A)||ut(B=>({...B,appId:A}))},onFocus:()=>{_s(Ue.appId),zs(!0)},onBlur:()=>setTimeout(()=>zs(!1),150)}),er&&s.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 max-h-48 overflow-y-auto rounded-md border border-gray-700 bg-[#0a1628] shadow-lg z-50",children:Dr.length===0?s.jsx("div",{className:"px-3 py-2 text-gray-500 text-xs",children:"无匹配,可手动输入密钥"}):Dr.map(v=>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:A=>{A.preventDefault(),ut(B=>({...B,appId:v.key,pagePath:v.path||""})),_s(""),zs(!1)},children:[s.jsx("span",{children:v.name}),s.jsx("span",{className:"text-xs text-gray-400 font-mono",children:v.key})]},v.key))})]}):s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:Ue.type==="url"?"https://...":Ue.type==="ckb"?"https://ckbapi.quwanzhi.com/...":"关联配置的 key,或直接填 wx 开头的 AppID",value:Ue.type==="url"||Ue.type==="ckb"?Ue.url:Ue.appId,onChange:v=>{Ue.type==="url"||Ue.type==="ckb"?ut(A=>({...A,url:v.target.value})):ut(A=>({...A,appId:v.target.value}))}})]})]}),Ue.type==="wxlink"&&s.jsx("p",{className:"text-[11px] text-amber-400/80 leading-snug px-0.5",children:"操作:打开目标小程序 → 右上角「...」→「复制链接」→ 粘贴到上面。小程序内点击此标签会在 web-view 中打开,微信自动唤起目标小程序,无需修改小程序版本。"}),Ue.type==="miniprogram"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"页面路径(可选)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"pages/index/index",value:Ue.pagePath,onChange:v=>ut(A=>({...A,pagePath:v.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-300 text-sm",children:"AppSecret(微信公众平台 · 仅服务端存储)"}),s.jsx(ce,{type:"password",autoComplete:"new-password",className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:ae!=null&&ae.hasAppSecret?"已保存密钥,留空不改;填写则覆盖":"粘贴目标小程序 AppSecret",value:Ue.appSecret,onChange:v=>ut(A=>({...A,appSecret:v.target.value}))}),s.jsx("p",{className:"text-[11px] text-gray-500 leading-snug",children:"与 AppID 成对落库;接口响应与小程序配置中均不会返回此字段。"})]})]})]}),s.jsxs(fn,{className:"gap-2 pt-1",children:[s.jsx(X,{variant:"outline",onClick:()=>Cs(!1),className:"border-gray-600",children:"取消"}),s.jsx(X,{onClick:async()=>{const v={tagId:Ue.tagId.trim(),label:Ue.label.trim(),aliases:Ue.aliases.trim(),url:Ue.url.trim(),type:Ue.type,appId:Ue.appId.trim(),appSecret:Ue.appSecret.trim(),pagePath:Ue.pagePath.trim()};if(v.tagId){const A=v.tagId;if([...A].length>50){se.error("标签ID 最长 50 个字符");return}if(/[#,\n\r\t]/.test(A)){se.error("标签ID 不能含 #、逗号或换行");return}}if(!v.label){se.error("显示文字必填");return}v.type==="miniprogram"&&(v.url=""),v.type==="wxlink"&&(v.appId="",v.pagePath=""),Ps(!0);try{const A=await Ct("/api/db/link-tags",v);A!=null&&A.success?(se.success(ae?"已更新":"已添加"),Cs(!1),Vn(),La()):se.error((A==null?void 0:A.error)??"保存失败")}catch(A){console.error(A),se.error("保存失败")}finally{Ps(!1)}},disabled:Fn,className:"bg-amber-500 hover:bg-amber-600 text-white",children:Fn?"保存中...":"保存"})]})]})})]})]}),s.jsx(q9,{open:Ma,onOpenChange:Aa,editingPerson:To,onSubmit:async v=>{var ue;const A={personId:v.personId||v.name.toLowerCase().replace(/\s+/g,"_")+"_"+Date.now().toString(36),name:v.name,userId:v.boundUserId,aliases:v.aliases||void 0,label:v.label,ckbApiKey:v.ckbApiKey||void 0,greeting:v.greeting||void 0,tips:v.tips||void 0,remarkType:v.remarkType||void 0,remarkFormat:v.remarkFormat||void 0,addFriendInterval:v.addFriendInterval,startTime:v.startTime||void 0,endTime:v.endTime||void 0,deviceGroups:(ue=v.deviceGroups)!=null&&ue.trim()?v.deviceGroups.split(",").map(we=>parseInt(we.trim(),10)).filter(we=>!Number.isNaN(we)):void 0},B=await Ct("/api/db/persons",A);if(B&&B.success===!1){const we=B;we.ckbResponse&&console.log("存客宝返回",we.ckbResponse);const De=we.error||"操作失败";throw new Error(De)}if(Bn(),se.success(To?"已保存":"已添加"),B!=null&&B.ckbCreateResult&&Object.keys(B.ckbCreateResult).length>0){const we=B.ckbCreateResult;console.log("存客宝创建结果",we);const De=we.planId??we.id,it=De!=null?[`planId: ${De}`]:[];we.apiKey!=null&&it.push("apiKey: ***"),se.info(it.length?`存客宝创建结果:${it.join(",")}`:"存客宝创建结果见控制台")}}}),s.jsx(Dt,{open:!!Ts,onOpenChange:v=>{v||vi(null)},children:s.jsxs(Lt,{showCloseButton:!0,className:"bg-[#0f2137] border-gray-700 text-white max-w-md p-4 gap-3",children:[s.jsxs(_t,{className:"gap-1",children:[s.jsx(zt,{className:"text-white text-base",children:"确认删除"}),s.jsx(Zh,{className:"text-gray-400 text-sm leading-relaxed wrap-break-word",children:Ts&&s.jsxs(s.Fragment,{children:[Ts.personSource==="vip_sync"?s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:["确定删除超级个体「",Ts.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链接人与事-",Ts.name,"」?将同时删除存客宝对应获客计划。"]})}),s.jsxs("p",{className:"mt-1.5",children:["二次确认:删除后无法恢复,文章中的 @",Ts.name," 将无法正常跳转。"]})]})})]}),s.jsxs(fn,{className:"gap-2 sm:gap-2 pt-1",children:[s.jsx(X,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300",onClick:()=>vi(null),children:"取消"}),s.jsx(X,{variant:"destructive",size:"sm",className:"bg-red-600 hover:bg-red-700",onClick:async()=>{Ts&&(await li(`/api/db/persons?personId=${Ts.personId}`),vi(null),Bn(),se.success("已删除"))},children:"确定删除"})]})]})}),s.jsx(Dt,{open:Ir,onOpenChange:Ni,children:s.jsxs(Lt,{className:"max-w-2xl bg-[#0f2137] border-gray-700",children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[s.jsx(In,{className:"w-5 h-5 text-green-400"}),Ia," — 获客详情(共 ",qn," 条)"]})}),s.jsx("div",{className:"max-h-[450px] overflow-y-auto space-y-2",children:wi?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Fe,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):ns.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:"时间"})]}),ns.map((v,A)=>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:(Pr-1)*20+A+1}),s.jsx("span",{className:"text-white truncate",children:v.nickname||v.name||v.userId||"-"}),s.jsx("span",{className:"text-gray-300 text-xs",children:v.phone||"-"}),s.jsx("span",{className:"text-gray-300 text-xs truncate",children:v.wechatId||"-"}),s.jsx("span",{className:"text-xs",children:v.source==="article_mention"?s.jsx("span",{className:"text-purple-400",children:"文章@"}):v.source==="index_lead"?s.jsx("span",{className:"text-blue-400",children:"首页"}):s.jsx("span",{className:"text-gray-500",children:v.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:v.createdAt?new Date(v.createdAt).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-"})]},v.id))]})}),qn>20&&s.jsxs("div",{className:"flex items-center justify-center gap-2 pt-2",children:[s.jsx(X,{size:"sm",variant:"outline",disabled:Pr<=1,onClick:()=>ps(Rr,Ia,Pr-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:[Pr," / ",Math.ceil(qn/20)]}),s.jsx(X,{size:"sm",variant:"outline",disabled:Pr>=Math.ceil(qn/20),onClick:()=>ps(Rr,Ia,Pr+1),className:"border-gray-600 text-gray-300 bg-transparent h-7 px-3",children:"下一页"})]})]})})]})}const ii={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 Qw(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):ii.stats}function Yw(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?e:String(e??"")).filter(Boolean):ii.highlights}function Q9(){const[t,e]=b.useState(ii),[n,r]=b.useState(!0),[a,i]=b.useState(!1),[o,c]=b.useState(!1),u=b.useRef(null);b.useEffect(()=>{Pe("/api/admin/author-settings").then(S=>{const E=S==null?void 0:S.data;E&&typeof E=="object"&&e({name:String(E.name??ii.name),avatar:String(E.avatar??ii.avatar),avatarImg:String(E.avatarImg??""),title:String(E.title??ii.title),bio:String(E.bio??ii.bio),stats:Qw(E.stats).length?Qw(E.stats):ii.stats,highlights:Yw(E.highlights).length?Yw(E.highlights):ii.highlights})}).catch(console.error).finally(()=>r(!1))},[]);const h=async()=>{i(!0);try{const S={name:t.name,avatar:t.avatar||"K",avatarImg:t.avatarImg,title:t.title,bio:t.bio,stats:t.stats.filter(P=>P.label||P.value),highlights:t.highlights.filter(Boolean)},E=await Ct("/api/admin/author-settings",S);if(!E||E.success===!1){se.error("保存失败: "+(E&&typeof E=="object"&&"error"in E?E.error:""));return}i(!1);const T=document.createElement("div");T.className="fixed top-4 right-4 z-50 px-4 py-2 rounded-lg bg-[#38bdac] text-white text-sm shadow-lg",T.textContent="作者设置已保存",document.body.appendChild(T),setTimeout(()=>T.remove(),2e3)}catch(S){console.error(S),se.error("保存失败: "+(S instanceof Error?S.message:String(S)))}finally{i(!1)}},f=async S=>{var T;const E=(T=S.target.files)==null?void 0:T[0];if(E){c(!0);try{const P=new FormData;P.append("file",E),P.append("folder","avatars");const O=iu(),q={};O&&(q.Authorization=`Bearer ${O}`);const V=await(await fetch(wc("/api/upload"),{method:"POST",body:P,credentials:"include",headers:q})).json();V!=null&&V.success&&(V!=null&&V.url)?e(I=>({...I,avatarImg:V.url})):se.error("上传失败: "+((V==null?void 0:V.error)||"未知错误"))}catch(P){console.error(P),se.error("上传失败")}finally{c(!1),u.current&&(u.current.value="")}}},m=()=>e(S=>({...S,stats:[...S.stats,{label:"",value:""}]})),x=S=>e(E=>({...E,stats:E.stats.filter((T,P)=>P!==S)})),y=(S,E,T)=>e(P=>({...P,stats:P.stats.map((O,q)=>q===S?{...O,[E]:T}:O)})),N=()=>e(S=>({...S,highlights:[...S.highlights,""]})),w=S=>e(E=>({...E,highlights:E.highlights.filter((T,P)=>P!==S)})),j=(S,E)=>e(T=>({...T,highlights:T.highlights.map((P,O)=>O===S?E:P)}));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(oi,{className:"w-5 h-5 text-[#38bdac]"}),"作者详情"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置小程序「关于作者」页展示的作者信息,包括头像、简介、统计数据与亮点标签。"})]}),s.jsxs(X,{onClick:h,disabled:a||n,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"flex items-center gap-2 text-white",children:[s.jsx(oi,{className:"w-4 h-4 text-[#38bdac]"}),"基本信息"]}),s.jsx(Kt,{className:"text-gray-400",children:"作者姓名、头像、头衔与个人简介,将展示在「关于作者」页顶部。"})]}),s.jsxs(Le,{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(ee,{className:"text-gray-300",children:"姓名"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.name,onChange:S=>e(E=>({...E,name:S.target.value})),placeholder:"卡若"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"首字母占位(无头像时显示)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white w-20",value:t.avatar,onChange:S=>e(E=>({...E,avatar:S.target.value.slice(0,1)||"K"})),placeholder:"K"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ee,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Mj,{className:"w-3 h-3 text-[#38bdac]"}),"头像图片"]}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(ce,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:t.avatarImg,onChange:S=>e(E=>({...E,avatarImg:S.target.value})),placeholder:"上传或粘贴 URL,如 /uploads/avatars/xxx.png"}),s.jsx("input",{ref:u,type:"file",accept:"image/*",className:"hidden",onChange:f}),s.jsxs(X,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:o,onClick:()=>{var S;return(S=u.current)==null?void 0:S.click()},children:[s.jsx(Jh,{className:"w-4 h-4 mr-2"}),o?"上传中...":"上传"]})]}),t.avatarImg&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:fo(t.avatarImg.startsWith("http")?t.avatarImg:wc(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(ee,{className:"text-gray-300",children:"头衔"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.title,onChange:S=>e(E=>({...E,title:S.target.value})),placeholder:"Soul派对房主理人 · 私域运营专家"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"个人简介"}),s.jsx(hl,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[120px]",value:t.bio,onChange:S=>e(E=>({...E,bio:S.target.value})),placeholder:"每天早上6点到9点..."})]})]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsx(at,{className:"text-white",children:"统计数据"}),s.jsx(Kt,{className:"text-gray-400",children:"展示在作者卡片中的数字指标,如「商业案例 62」「连续直播 365天」。第一个「商业案例」的值可由书籍统计自动更新。"})]}),s.jsxs(Le,{className:"space-y-3",children:[t.stats.map((S,E)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(ce,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:S.label,onChange:T=>y(E,"label",T.target.value),placeholder:"标签"}),s.jsx(ce,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:S.value,onChange:T=>y(E,"value",T.target.value),placeholder:"数值"}),s.jsx(X,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>x(E),children:s.jsx(Yn,{className:"w-4 h-4"})})]},E)),s.jsxs(X,{variant:"outline",size:"sm",onClick:m,className:"border-gray-600 text-gray-400",children:[s.jsx(An,{className:"w-4 h-4 mr-2"}),"添加统计项"]})]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsx(at,{className:"text-white",children:"亮点标签"}),s.jsx(Kt,{className:"text-gray-400",children:"作者优势或成就的简短描述,以标签形式展示。"})]}),s.jsxs(Le,{className:"space-y-3",children:[t.highlights.map((S,E)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(ce,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:S,onChange:T=>j(E,T.target.value),placeholder:"5年私域运营经验"}),s.jsx(X,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>w(E),children:s.jsx(Yn,{className:"w-4 h-4"})})]},E)),s.jsxs(X,{variant:"outline",size:"sm",onClick:N,className:"border-gray-600 text-gray-400",children:[s.jsx(An,{className:"w-4 h-4 mr-2"}),"添加亮点"]})]})]})]})]})}function Y9(t){return confirm(`确定删除该${t}?此操作不可恢复。`)?window.prompt(`请输入「删除」以确认删除${t}`)==="删除":!1}function X9(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[a,i]=b.useState(1),[o]=b.useState(10),[c,u]=b.useState(0),[h,f]=b.useState(""),m=ef(h,300),[x,y]=b.useState(!0),[N,w]=b.useState(null),[j,S]=b.useState(!1),[E,T]=b.useState(null),[P,O]=b.useState(""),[q,z]=b.useState(""),[V,I]=b.useState(""),[te,Q]=b.useState("admin"),[F,re]=b.useState("active"),[ie,J]=b.useState(!1);async function $(){var U;y(!0),w(null);try{const H=new URLSearchParams({page:String(a),pageSize:String(o)});m.trim()&&H.set("search",m.trim());const K=await Pe(`/api/admin/users?${H}`);K!=null&&K.success?(e(K.records||[]),r(K.total??0),u(K.totalPages??0)):w(K.error||"加载失败")}catch(H){const K=H;w(K.status===403?"无权限访问":((U=K==null?void 0:K.data)==null?void 0:U.error)||"加载失败"),e([])}finally{y(!1)}}b.useEffect(()=>{$()},[a,o,m]);const D=()=>{T(null),O(""),z(""),I(""),Q("admin"),re("active"),S(!0)},R=U=>{T(U),O(U.username),z(""),I(U.name||""),Q(U.role==="super_admin"?"super_admin":"admin"),re(U.status==="disabled"?"disabled":"active"),S(!0)},oe=async()=>{var U;if(!P.trim()){w("用户名不能为空");return}if(!E&&!q){w("新建时密码必填,至少 6 位");return}if(q&&q.length<6){w("密码至少 6 位");return}w(null),J(!0);try{if(E){const H=await Gt("/api/admin/users",{id:E.id,password:q||void 0,name:V.trim(),role:te,status:F});H!=null&&H.success?(S(!1),$()):w((H==null?void 0:H.error)||"保存失败")}else{const H=await Ct("/api/admin/users",{username:P.trim(),password:q,name:V.trim(),role:te});H!=null&&H.success?(S(!1),$()):w((H==null?void 0:H.error)||"保存失败")}}catch(H){const K=H;w(((U=K==null?void 0:K.data)==null?void 0:U.error)||"保存失败")}finally{J(!1)}},G=async U=>{var H;if(!Y9("管理员")){w("已取消删除");return}try{const K=await li(`/api/admin/users?id=${U}`);K!=null&&K.success?$():w((K==null?void 0:K.error)||"删除失败")}catch(K){const me=K;w(((H=me==null?void 0:me.data)==null?void 0:H.error)||"删除失败")}},_=U=>{if(!U)return"-";try{const H=new Date(U);return isNaN(H.getTime())?U:H.toLocaleString("zh-CN")}catch{return U}};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(dc,{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(ce,{placeholder:"搜索用户名/昵称",value:h,onChange:U=>f(U.target.value),className:"w-48 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"}),s.jsx(X,{variant:"outline",size:"sm",onClick:$,disabled:x,className:"border-gray-600 text-gray-300",children:s.jsx(Fe,{className:`w-4 h-4 ${x?"animate-spin":""}`})}),s.jsxs(X,{onClick:D,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(An,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Le,{className:"p-0",children:x?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(s.Fragment,{children:[s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"ID"}),s.jsx(je,{className:"text-gray-400",children:"用户名"}),s.jsx(je,{className:"text-gray-400",children:"昵称"}),s.jsx(je,{className:"text-gray-400",children:"角色"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-gray-400",children:"创建时间"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(hs,{children:[t.map(U=>s.jsxs(ct,{className:"border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:U.id}),s.jsx(be,{className:"text-white font-medium",children:U.username}),s.jsx(be,{className:"text-gray-400",children:U.name||"-"}),s.jsx(be,{children:s.jsx(Ve,{variant:"outline",className:U.role==="super_admin"?"border-amber-500/50 text-amber-400":"border-gray-600 text-gray-400",children:U.role==="super_admin"?"超级管理员":"管理员"})}),s.jsx(be,{children:s.jsx(Ve,{variant:"outline",className:U.status==="active"?"border-[#38bdac]/50 text-[#38bdac]":"border-gray-500 text-gray-500",children:U.status==="active"?"正常":"已禁用"})}),s.jsx(be,{className:"text-gray-500 text-sm",children:_(U.createdAt)}),s.jsxs(be,{className:"text-right",children:[s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>R(U),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(Jt,{className:"w-4 h-4"})}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>G(U.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(bs,{className:"w-4 h-4"})})]})]},U.id)),t.length===0&&!x&&s.jsx(ct,{children:s.jsx(be,{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(qs,{page:a,pageSize:o,total:n,totalPages:c,onPageChange:i})})]})})}),s.jsx(Dt,{open:j,onOpenChange:S,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(_t,{children:s.jsx(zt,{className:"text-white",children:E?"编辑管理员":"新增管理员"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"用户名"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"登录用户名",value:P,onChange:U=>O(U.target.value),disabled:!!E}),E&&s.jsx("p",{className:"text-xs text-gray-500",children:"用户名不可修改"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:E?"新密码(留空不改)":"密码"}),s.jsx(ce,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:E?"留空表示不修改":"至少 6 位",value:q,onChange:U=>z(U.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"昵称"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"显示名称",value:V,onChange:U=>I(U.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"角色"}),s.jsxs("select",{value:te,onChange:U=>Q(U.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:"超级管理员"})]})]}),E&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"状态"}),s.jsxs("select",{value:F,onChange:U=>re(U.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(fn,{children:[s.jsxs(X,{variant:"outline",onClick:()=>S(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(X,{onClick:oe,disabled:ie,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),ie?"保存中...":"保存"]})]})]})})]})}function jn({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 m4(){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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(rt,{className:"pb-3",children:s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(cg,{className:"w-5 h-5 text-[#38bdac]"}),"1. Authentication"]})}),s.jsx(Le,{className:"space-y-4",children:s.jsx(jn,{method:"POST",url:"/api/admin",desc:"登录,返回 JWT token",headers:["Content-Type: application/json"],body:`{ "username": "admin", "password": "your_password" }`,response:`{ "success": true, "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "expires_at": "2026-03-16T12:00:00Z" -}`})})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(rt,{className:"pb-3",children:s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(qs,{className:"w-5 h-5 text-[#38bdac]"}),"2. 章节管理 (Chapters)"]})}),s.jsxs(Le,{className:"space-y-4",children:[s.jsx(jn,{method:"GET",url:"/api/db/book?action=chapters",desc:"获取章节树",headers:t,response:`{ +}`})})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(rt,{className:"pb-3",children:s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(Gs,{className:"w-5 h-5 text-[#38bdac]"}),"2. 章节管理 (Chapters)"]})}),s.jsxs(Le,{className:"space-y-4",children:[s.jsx(jn,{method:"GET",url:"/api/db/book?action=chapters",desc:"获取章节树",headers:t,response:`{ "success": true, "data": [ { "id": "part-1", "title": "第一篇", "children": [...] }, @@ -965,7 +965,7 @@ ${y.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content: "titleMatches": [{ "id": "s1", "title": "...", "snippet": "..." }], "contentMatches": [{ "id": "s2", "title": "...", "snippet": "..." }] } -}`})})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(rt,{className:"pb-3",children:s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(ux,{className:"w-5 h-5 text-[#38bdac]"}),"6. 内容排行"]})}),s.jsx(Le,{className:"space-y-4",children:s.jsx(jn,{method:"GET",url:"/api/db/book?action=ranking",desc:"排行榜数据",headers:t,response:`{ +}`})})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(rt,{className:"pb-3",children:s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(ug,{className:"w-5 h-5 text-[#38bdac]"}),"6. 内容排行"]})}),s.jsx(Le,{className:"space-y-4",children:s.jsx(jn,{method:"GET",url:"/api/db/book?action=ranking",desc:"排行榜数据",headers:t,response:`{ "success": true, "data": [ { "id": "s1", "title": "...", "clickCount": 100, "payCount": 50, "hotScore": 120, "hotRank": 1 } @@ -994,13 +994,13 @@ ${y.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content: }`,response:`{ "success": true, "data": { "amount": 10.00, "balance": 120.50 } -}`})]})]}),s.jsx("p",{className:"text-gray-500 text-xs mt-6",children:"管理端主要使用 /api/admin/*、/api/db/*;富文本素材上传另用公共接口 /api/upload(与后台编辑器一致)。小程序使用 /api/miniprogram/*。完整实现见 soul-api 源码。"})]})}const Z9={appId:"wxb8bbb2b10dec74aa",withdrawSubscribeTmplId:"u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE",mchId:"1318592501",minWithdraw:10},eV={name:"卡若",startDate:"2025年10月15日",bio:"连续创业者,私域运营专家,每天早上6-9点在Soul派对房分享真实商业故事",liveTime:"06:00-09:00",platform:"Soul派对房",description:"连续创业者,私域运营专家"},tV={sectionPrice:1,baseBookPrice:9.9,distributorShare:90,authorInfo:{...eV},ckbLeadApiKey:""},nV={matchEnabled:!0,referralEnabled:!0,searchEnabled:!0,aboutEnabled:!0},sV={tabBar:{home:"首页",chapters:"目录",match:"找伙伴",my:"我的"},chaptersPage:{bookTitle:"一场SOUL的创业实验场",bookSubtitle:"来自Soul派对房的真实商业故事"},homePage:{logoTitle:"卡若创业派对",logoSubtitle:"来自派对房的真实故事",linkKaruoText:"点击链接卡若",linkKaruoAvatar:"",searchPlaceholder:"搜索章节标题或内容...",bannerTag:"推荐",bannerReadMoreText:"点击阅读",superSectionTitle:"超级个体",superSectionLinkText:"获客入口",superSectionLinkPath:"/pages/match/match",pickSectionTitle:"精选推荐",latestSectionTitle:"最新新增"},myPage:{cardLabel:"名片",vipLabelVip:"会员中心",vipLabelGuest:"成为会员",cardPath:"",vipPath:"/pages/vip/vip",readStatLabel:"已读章节",recentReadTitle:"最近阅读",readStatPath:"/pages/reading-records/reading-records?focus=all",recentReadPath:"/pages/reading-records/reading-records?focus=recent"}},rV=["system","author","admin","api-docs"],Xw=["basic","mp","oss","features"];function aV(){const[t,e]=g0(),n=t.get("tab")??"system",r=rV.includes(n)?n:"system",a=t.get("section")??"basic",i=Xw.includes(a)?a:"basic",[o,c]=b.useState(tV),[u,h]=b.useState(nV),[f,m]=b.useState(Z9),[g,y]=b.useState("{}"),[N,w]=b.useState({}),[j,S]=b.useState(!1),[E,T]=b.useState(!0),[P,O]=b.useState(!1),[q,z]=b.useState(""),[V,I]=b.useState(""),[te,Q]=b.useState(!1),[F,re]=b.useState(!1),ae=(H,K,me=!1)=>{z(H),I(K),Q(me),O(!0)};b.useEffect(()=>{(async()=>{try{const K=await Pe("/api/admin/settings");if(!K||K.success===!1)return;if(K.featureConfig&&Object.keys(K.featureConfig).length&&h(me=>({...me,...K.featureConfig})),K.mpConfig&&typeof K.mpConfig=="object"){const me={...K.mpConfig};m(le=>({...le,...me}));const Y=me.mpUi;y(JSON.stringify(Y!=null&&typeof Y=="object"&&!Array.isArray(Y)?Y:{},null,2))}if(K.ossConfig&&typeof K.ossConfig=="object"&&w(me=>({...me,...K.ossConfig})),K.siteSettings&&typeof K.siteSettings=="object"){const me=K.siteSettings;c(Y=>({...Y,...typeof me.sectionPrice=="number"&&{sectionPrice:me.sectionPrice},...typeof me.baseBookPrice=="number"&&{baseBookPrice:me.baseBookPrice},...typeof me.distributorShare=="number"&&{distributorShare:me.distributorShare},...me.authorInfo&&typeof me.authorInfo=="object"&&{authorInfo:{...Y.authorInfo,...me.authorInfo}},...typeof me.ckbLeadApiKey=="string"&&{ckbLeadApiKey:me.ckbLeadApiKey}}))}}catch(K){console.error("Load settings error:",K)}finally{T(!1)}})()},[]);const J=async(H,K)=>{re(!0);try{const me=await Ct("/api/admin/settings",{featureConfig:H});if(!me||me.success===!1){K(),ae("保存失败",(me==null?void 0:me.error)??"未知错误",!0);return}ae("已保存","功能开关已更新,相关入口将随之显示或隐藏。")}catch(me){console.error("Save feature config error:",me),K(),ae("保存失败",me instanceof Error?me.message:String(me),!0)}finally{re(!1)}},$=(H,K)=>{const me=u,Y={...me,[H]:K};h(Y),J(Y,()=>h(me))},[D,R]=b.useState(!1),oe=async H=>{const K=f,me={...K,auditMode:H};m(me),R(!0);try{const Y=await Ct("/api/admin/settings",{mpConfig:me});if(!Y||Y.success===!1){m(K),ae("保存失败",(Y==null?void 0:Y.error)??"未知错误",!0);return}ae("已保存",H?"审核模式已开启,小程序将隐藏所有支付入口。":"审核模式已关闭,支付功能已恢复。")}catch(Y){m(K),ae("保存失败",Y instanceof Error?Y.message:String(Y),!0)}finally{R(!1)}},G=async()=>{S(!0);try{let H={};try{const me=g.trim();if(me){const Y=JSON.parse(me);if(Y&&typeof Y=="object"&&!Array.isArray(Y))H=Y;else{ae("保存失败","小程序文案 mpUi 须为 JSON 对象(非数组)",!0),S(!1);return}}}catch{ae("保存失败","小程序文案 mpUi 不是合法 JSON",!0),S(!1);return}const K=await Ct("/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:H},ossConfig:Object.keys(N).length?{endpoint:N.endpoint??"",bucket:N.bucket??"",region:N.region??"",accessKeyId:N.accessKeyId??"",accessKeySecret:N.accessKeySecret??""}:void 0});if(!K||K.success===!1){ae("保存失败",(K==null?void 0:K.error)??"未知错误",!0);return}ae("已保存","设置已保存成功。")}catch(H){console.error("Save settings error:",H),ae("保存失败",H instanceof Error?H.message:String(H),!0)}finally{S(!1)}},_=H=>{if(H==="system"){const K=new URLSearchParams(t);K.delete("tab"),Xw.includes(K.get("section")||"basic")||K.set("section","basic"),e(K);return}e({tab:H})},U=H=>{const K=new URLSearchParams(t);K.delete("tab"),K.set("section",H),e(K)};return E?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(X,{onClick:G,disabled:j,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),j?"保存中...":"保存设置"]})]}),s.jsxs(jc,{value:r,onValueChange:_,className:"w-full",children:[s.jsxs(ul,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(Qt,{value:"system",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[s.jsx(no,{className:"w-4 h-4 mr-2"}),"系统设置"]}),s.jsxs(Qt,{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(lh,{className:"w-4 h-4 mr-2"}),"作者详情"]}),s.jsxs(Qt,{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(dc,{className:"w-4 h-4 mr-2"}),"管理员"]}),s.jsxs(Qt,{value:"api-docs",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",onClick:H=>{H.preventDefault(),window.open("/api-docs","_blank")},children:[s.jsx(Tj,{className:"w-4 h-4 mr-2"}),"API 文档 ↗"]})]}),s.jsxs(Yt,{value:"system",className:"mt-0",children:[s.jsxs("p",{className:"text-xs text-gray-500 mb-3",children:["MBTI 默认头像已迁至"," ",s.jsx(bc,{to:"/users",className:"text-[#38bdac] underline",children:"用户管理(用户列表点头像打开)"})]}),s.jsxs(jc,{value:i,onValueChange:U,className:"w-full",children:[s.jsxs(ul,{className:"mb-4 bg-[#0a1628] border border-gray-700/50 p-1 flex-wrap h-auto gap-1",children:[s.jsxs(Qt,{value:"basic",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(iM,{className:"w-3.5 h-3.5 mr-1"}),"基础与价格"]}),s.jsxs(Qt,{value:"mp",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(ll,{className:"w-3.5 h-3.5 mr-1"}),"小程序与审核"]}),s.jsxs(Qt,{value:"oss",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(i1,{className:"w-3.5 h-3.5 mr-1"}),"OSS"]}),s.jsxs(Qt,{value:"features",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(no,{className:"w-3.5 h-3.5 mr-1"}),"功能开关"]})]}),s.jsxs(Yt,{value:"basic",className:"space-y-6 mt-0",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(lh,{className:"w-5 h-5 text-[#38bdac]"}),"关于作者"]}),s.jsx(Kt,{className:"text-gray-400",children:'配置作者信息,将在"关于作者"页面显示'})]}),s.jsxs(Le,{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(ee,{htmlFor:"author-name",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(lh,{className:"w-3 h-3"}),"主理人名称"]}),s.jsx(de,{id:"author-name",className:"bg-[#0a1628] border-gray-700 text-white",value:o.authorInfo.name??"",onChange:H=>c(K=>({...K,authorInfo:{...K.authorInfo,name:H.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ee,{htmlFor:"start-date",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(rx,{className:"w-3 h-3"}),"开播日期"]}),s.jsx(de,{id:"start-date",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 2025年10月15日",value:o.authorInfo.startDate??"",onChange:H=>c(K=>({...K,authorInfo:{...K.authorInfo,startDate:H.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ee,{htmlFor:"live-time",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(rx,{className:"w-3 h-3"}),"直播时间"]}),s.jsx(de,{id:"live-time",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 06:00-09:00",value:o.authorInfo.liveTime??"",onChange:H=>c(K=>({...K,authorInfo:{...K.authorInfo,liveTime:H.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ee,{htmlFor:"platform",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Aj,{className:"w-3 h-3"}),"直播平台"]}),s.jsx(de,{id:"platform",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: Soul派对房",value:o.authorInfo.platform??"",onChange:H=>c(K=>({...K,authorInfo:{...K.authorInfo,platform:H.target.value}}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ee,{htmlFor:"description",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(qs,{className:"w-3 h-3"}),"简介描述"]}),s.jsx(de,{id:"description",className:"bg-[#0a1628] border-gray-700 text-white",value:o.authorInfo.description??"",onChange:H=>c(K=>({...K,authorInfo:{...K.authorInfo,description:H.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{htmlFor:"bio",className:"text-gray-300",children:"详细介绍"}),s.jsx(hl,{id:"bio",className:"bg-[#0a1628] border-gray-700 text-white min-h-[100px]",placeholder:"输入作者详细介绍...",value:o.authorInfo.bio??"",onChange:H=>c(K=>({...K,authorInfo:{...K.authorInfo,bio:H.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ee,{htmlFor:"ckb-lead-api-key",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ya,{className:"w-3 h-3"}),"链接卡若存客宝密钥"]}),s.jsx(de,{id:"ckb-lead-api-key",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 xxxxx-xxxxx-xxxxx-xxxxx(留空则用 .env 默认)",value:o.ckbLeadApiKey??"",onChange:H=>c(K=>({...K,ckbLeadApiKey:H.target.value}))}),s.jsx("p",{className:"text-xs text-gray-500",children:"小程序首页「链接卡若」留资接口使用的存客宝 API Key,优先于 .env 配置"})]}),s.jsxs("div",{className:"mt-4 p-4 rounded-xl bg-[#0a1628] border border-[#38bdac]/30",children:[s.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"预览效果"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-12 h-12 rounded-full bg-gradient-to-br from-[#00CED1] to-[#20B2AA] flex items-center justify-center text-xl font-bold text-white",children:(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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(Kh,{className:"w-5 h-5 text-[#38bdac]"}),"价格设置"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置书籍和章节的定价"})]}),s.jsx(Le,{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(ee,{className:"text-gray-300",children:"单节价格 (元)"}),s.jsx(de,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.sectionPrice,onChange:H=>c(K=>({...K,sectionPrice:Number.parseFloat(H.target.value)||1}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"整本价格 (元)"}),s.jsx(de,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.baseBookPrice,onChange:H=>c(K=>({...K,baseBookPrice:Number.parseFloat(H.target.value)||9.9}))})]})]})})]})]}),s.jsxs(Yt,{value:"mp",className:"space-y-6 mt-0",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(ll,{className:"w-5 h-5 text-[#38bdac]"}),"小程序配置"]}),s.jsx(Kt,{className:"text-gray-400",children:"订阅消息模板、支付商户号等,小程序从 /api/miniprogram/config 读取(API 地址由 app.js baseUrl 控制)"})]}),s.jsxs(Le,{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(ee,{className:"text-gray-300",children:"小程序 AppID"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"wxb8bbb2b10dec74aa",value:f.appId??"",onChange:H=>m(K=>({...K,appId:H.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"提现订阅模板 ID"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"用户申请提现时需授权",value:f.withdrawSubscribeTmplId??"",onChange:H=>m(K=>({...K,withdrawSubscribeTmplId:H.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"微信支付商户号"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"1318592501",value:f.mchId??"",onChange:H=>m(K=>({...K,mchId:H.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"最低提现金额 (元)"}),s.jsx(de,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:f.minWithdraw??10,onChange:H=>m(K=>({...K,minWithdraw:Number.parseFloat(H.target.value)||10}))})]})]}),s.jsxs("div",{className:"space-y-2 pt-2 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsx(ee,{className:"text-gray-300",children:"小程序界面文案 mpUi(JSON)"}),s.jsx(X,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-200",onClick:()=>y(JSON.stringify(sV,null,2)),children:"填入默认模板"})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"覆盖 Tab 文案、首页/目录标题、我的页名片与阅读记录路径等;仅填需要改的字段也可(与后端默认值深合并)。保存后小程序约 5 分钟内通过 config 缓存刷新。"}),s.jsx(hl,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm min-h-[280px]",spellCheck:!1,value:g,onChange:H=>y(H.target.value)})]})]})]}),s.jsxs(Oe,{className:`bg-[#0f2137] shadow-xl ${f.auditMode?"border-amber-500/50 border-2":"border-gray-700/50"}`,children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(dc,{className:"w-5 h-5 text-amber-400"}),"小程序审核模式"]}),s.jsx(Kt,{className:"text-gray-400",children:"提交微信审核前开启,审核通过后关闭即可恢复支付功能"})]}),s.jsx(Le,{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(dc,{className:`w-4 h-4 ${f.auditMode?"text-amber-400":"text-gray-400"}`}),s.jsx(ee,{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($t,{id:"audit-mode",checked:f.auditMode??!1,disabled:D,onCheckedChange:oe})]})})]})]}),s.jsx(Yt,{value:"oss",className:"space-y-6 mt-0",children:s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(i1,{className:"w-5 h-5 text-[#38bdac]"}),"OSS 配置(阿里云对象存储)"]}),s.jsx(Kt,{className:"text-gray-400",children:"endpoint、bucket、accessKey 等,用于图片/文件上传"})]}),s.jsx(Le,{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(ee,{className:"text-gray-300",children:"Endpoint"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou.aliyuncs.com",value:N.endpoint??"",onChange:H=>w(K=>({...K,endpoint:H.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"Bucket"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"bucket 名称",value:N.bucket??"",onChange:H=>w(K=>({...K,bucket:H.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"Region"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou",value:N.region??"",onChange:H=>w(K=>({...K,region:H.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"AccessKey ID"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey ID",value:N.accessKeyId??"",onChange:H=>w(K=>({...K,accessKeyId:H.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"AccessKey Secret"}),s.jsx(de,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey Secret",value:N.accessKeySecret??"",onChange:H=>w(K=>({...K,accessKeySecret:H.target.value}))})]})]})})]})}),s.jsxs(Yt,{value:"features",className:"space-y-6 mt-0",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(no,{className:"w-5 h-5 text-[#38bdac]"}),"功能开关"]}),s.jsx(Kt,{className:"text-gray-400",children:"控制各个功能模块的显示/隐藏"})]}),s.jsxs(Le,{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(In,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(ee,{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($t,{id:"match-enabled",checked:u.matchEnabled,disabled:F,onCheckedChange:H=>$("matchEnabled",H)})]}),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(ox,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(ee,{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(bc,{to:"/distribution?tab=settings",className:"underline mx-1 text-[#38bdac]",children:"推广中心 → 推广设置"}),"为同一套接口,在此仅控制是否展示入口。"]})]}),s.jsx($t,{id:"referral-enabled",checked:u.referralEnabled,disabled:F,onCheckedChange:H=>$("referralEnabled",H)})]}),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(qs,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(ee,{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($t,{id:"search-enabled",checked:u.searchEnabled,disabled:F,onCheckedChange:H=>$("searchEnabled",H)})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(no,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(ee,{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($t,{id:"about-enabled",checked:u.aboutEnabled,disabled:F,onCheckedChange:H=>$("aboutEnabled",H)})]})]}),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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(qh,{className:"w-5 h-5 text-[#38bdac]"}),"小程序模块显隐说明"]}),s.jsx(Kt,{className:"text-gray-400",children:"以下模块受上方开关和审核模式共同控制"})]}),s.jsx(Le,{children:s.jsx("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[{mod:"找伙伴",ctrl:"找伙伴功能开关",icon:s.jsx(In,{className:"w-3 h-3"})},{mod:"推广中心 / 推荐好友",ctrl:"推广功能开关",icon:s.jsx(ox,{className:"w-3 h-3"})},{mod:"搜索",ctrl:"搜索功能开关",icon:s.jsx(qs,{className:"w-3 h-3"})},{mod:"关于页面",ctrl:"关于页面开关",icon:s.jsx(lh,{className:"w-3 h-3"})},{mod:"支付 / VIP / 充值 / 收益",ctrl:"审核模式",icon:s.jsx(dc,{className:"w-3 h-3"})},{mod:"超级个体名片",ctrl:"审核模式",icon:s.jsx(sA,{className:"w-3 h-3"})},{mod:"首页获客入口",ctrl:"已移除",icon:s.jsx(A5,{className:"w-3 h-3"})}].map(H=>s.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#0a1628] border border-gray-700/30",children:[H.icon,s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:H.mod}),s.jsxs("span",{className:"text-gray-500 ml-1",children:["← ",H.ctrl]})]})]},H.mod))})})]})]})]})]}),s.jsx(Yt,{value:"author",className:"mt-0",children:s.jsx(Q9,{})}),s.jsx(Yt,{value:"admin",className:"mt-0",children:s.jsx(X9,{})}),s.jsx(Yt,{value:"api-docs",className:"mt-0",children:s.jsx(m4,{})})]}),s.jsx(Dt,{open:P,onOpenChange:O,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsxs(_t,{children:[s.jsx(zt,{className:te?"text-red-400":"text-[#38bdac]",children:q}),s.jsx(Zh,{className:"text-gray-400 whitespace-pre-wrap pt-2",children:V})]}),s.jsx(fn,{className:"mt-4",children:s.jsx(X,{onClick:()=>O(!1),className:te?"bg-gray-600 hover:bg-gray-500":"bg-[#38bdac] hover:bg-[#2da396]",children:"确定"})})]})})]})}const Zw={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 iV(){const[t,e]=b.useState(!1),[n,r]=b.useState(Zw),[a,i]=b.useState(""),o=async()=>{e(!0);try{const S=await Pe("/api/config");S!=null&&S.paymentMethods&&r({...Zw,...S.paymentMethods})}catch(S){console.error(S)}finally{e(!1)}};b.useEffect(()=>{o()},[]);const c=async()=>{e(!0);try{await Ct("/api/db/config",{key:"payment_methods",value:n,description:"支付方式配置"}),se.success("配置已保存!")}catch(S){console.error("保存失败:",S),se.error("保存失败: "+(S instanceof Error?S.message:String(S)))}finally{e(!1)}},u=(S,E)=>{navigator.clipboard.writeText(S),i(E),setTimeout(()=>i(""),2e3)},h=(S,E)=>{r(T=>({...T,wechat:{...T.wechat,[S]:E}}))},f=(S,E)=>{r(T=>({...T,alipay:{...T.alipay,[S]:E}}))},m=(S,E)=>{r(T=>({...T,usdt:{...T.usdt,[S]:E}}))},g=(S,E)=>{r(T=>({...T,paypal:{...T.paypal,[S]:E}}))},y=n.wechat,N=n.alipay,w=n.usdt,j=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(X,{variant:"outline",onClick:o,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"同步配置"]}),s.jsxs(X,{onClick:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{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(kj,{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(jc,{defaultValue:"wechat",className:"space-y-6",children:[s.jsxs(ul,{className:"bg-[#0f2137] border border-gray-700/50 p-1 grid grid-cols-4 w-full",children:[s.jsxs(Qt,{value:"wechat",className:"data-[state=active]:bg-[#07C160]/20 data-[state=active]:text-[#07C160] text-gray-400",children:[s.jsx(ll,{className:"w-4 h-4 mr-2"}),"微信"]}),s.jsxs(Qt,{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(Qt,{value:"usdt",className:"data-[state=active]:bg-[#26A17B]/20 data-[state=active]:text-[#26A17B] text-gray-400",children:[s.jsx(a1,{className:"w-4 h-4 mr-2"}),"USDT"]}),s.jsxs(Qt,{value:"paypal",className:"data-[state=active]:bg-[#003087]/20 data-[state=active]:text-[#169BD7] text-gray-400",children:[s.jsx(lx,{className:"w-4 h-4 mr-2"}),"PayPal"]})]}),s.jsx(Yt,{value:"wechat",className:"space-y-4",children:s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(at,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(ll,{className:"w-5 h-5"}),"微信支付配置"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置微信支付参数和跳转链接"})]}),s.jsx($t,{checked:!!y.enabled,onCheckedChange:S=>h("enabled",S)})]}),s.jsxs(Le,{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(ee,{className:"text-gray-300",children:"网站AppID"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.websiteAppId??""),onChange:S=>h("websiteAppId",S.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"商户号"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.merchantId??""),onChange:S=>h("merchantId",S.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(fi,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置(核心功能)"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"微信收款码/支付链接"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://收款码图片URL 或 weixin://支付链接",value:String(y.qrCode??""),onChange:S=>h("qrCode",S.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(ee,{className:"text-[#07C160] font-medium",children:"微信群跳转链接(支付成功后跳转)"}),s.jsx(de,{className:"bg-[#0a1628] border-[#07C160]/30 text-white placeholder:text-gray-500",placeholder:"https://weixin.qq.com/g/... 或微信群二维码图片URL",value:String(y.groupQrCode??""),onChange:S=>h("groupQrCode",S.target.value)}),s.jsx("p",{className:"text-xs text-[#07C160]/70",children:"用户支付成功后将自动跳转到此链接,进入指定微信群"})]})]})]})]})}),s.jsx(Yt,{value:"alipay",className:"space-y-4",children:s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(at,{className:"text-[#1677FF] flex items-center gap-2",children:[s.jsx(o1,{className:"w-5 h-5"}),"支付宝配置"]}),s.jsx(Kt,{className:"text-gray-400",children:"已加载真实支付宝参数"})]}),s.jsx($t,{checked:!!N.enabled,onCheckedChange:S=>f("enabled",S)})]}),s.jsxs(Le,{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(ee,{className:"text-gray-300",children:"合作者身份 (PID)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(N.partnerId??""),onChange:S=>f("partnerId",S.target.value)}),s.jsx(X,{size:"icon",variant:"outline",className:"border-gray-700 bg-transparent",onClick:()=>u(String(N.partnerId??""),"pid"),children:a==="pid"?s.jsx(Zf,{className:"w-4 h-4 text-green-500"}):s.jsx(Cj,{className:"w-4 h-4 text-gray-400"})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"安全校验码 (Key)"}),s.jsx(de,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(N.securityKey??""),onChange:S=>f("securityKey",S.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(fi,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"支付宝收款码/跳转链接"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://qr.alipay.com/... 或收款码图片URL",value:String(N.qrCode??""),onChange:S=>f("qrCode",S.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户点击支付宝支付后显示的二维码"})]})]})]})]})}),s.jsx(Yt,{value:"usdt",className:"space-y-4",children:s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(at,{className:"text-[#26A17B] flex items-center gap-2",children:[s.jsx(a1,{className:"w-5 h-5"}),"USDT配置"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置加密货币收款地址"})]}),s.jsx($t,{checked:!!w.enabled,onCheckedChange:S=>m("enabled",S)})]}),s.jsxs(Le,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{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:S=>m("network",S.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(ee,{className:"text-gray-300",children:"收款地址"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",placeholder:"T... (TRC20地址)",value:String(w.address??""),onChange:S=>m("address",S.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(de,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(w.exchangeRate)??7.2,onChange:S=>m("exchangeRate",Number.parseFloat(S.target.value)||7.2)})]})]})]})}),s.jsx(Yt,{value:"paypal",className:"space-y-4",children:s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(at,{className:"text-[#169BD7] flex items-center gap-2",children:[s.jsx(lx,{className:"w-5 h-5"}),"PayPal配置"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置PayPal收款账户"})]}),s.jsx($t,{checked:!!j.enabled,onCheckedChange:S=>g("enabled",S)})]}),s.jsxs(Le,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"PayPal邮箱"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"your@email.com",value:String(j.email??""),onChange:S=>g("email",S.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(de,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(j.exchangeRate)??7.2,onChange:S=>g("exchangeRate",Number(S.target.value)||7.2)})]})]})]})})]})]})}const oV={siteName:"卡若日记",siteTitle:"一场SOUL的创业实验场",siteDescription:"来自Soul派对房的真实商业故事",logo:"/logo.png",favicon:"/favicon.ico",primaryColor:"#00CED1"},lV={home:{enabled:!0,label:"首页"},chapters:{enabled:!0,label:"目录"},match:{enabled:!0,label:"匹配"},my:{enabled:!0,label:"我的"}},cV={homeTitle:"一场SOUL的创业实验场",homeSubtitle:"来自Soul派对房的真实商业故事",chaptersTitle:"我要看",matchTitle:"语音匹配",myTitle:"我的",aboutTitle:"关于作者"};function dV(){const[t,e]=b.useState({siteConfig:{...oV},menuConfig:{...lV},pageConfig:{...cV}}),[n,r]=b.useState(!1),[a,i]=b.useState(!1);b.useEffect(()=>{Pe("/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 Ct("/api/db/config",{key:"site_config",value:t.siteConfig,description:"网站基础配置"}),await Ct("/api/db/config",{key:"menu_config",value:t.menuConfig,description:"底部菜单配置"}),await Ct("/api/db/config",{key:"page_config",value:t.pageConfig,description:"页面标题配置"}),r(!0),setTimeout(()=>r(!1),2e3),se.success("配置已保存")}catch(f){console.error(f),se.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{i(!1)}},c=t.siteConfig,u=t.menuConfig,h=t.pageConfig;return 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(X,{onClick:o,disabled:a,className:`${n?"bg-green-500":"bg-[#00CED1]"} hover:bg-[#20B2AA] text-white transition-colors`,children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),a?"保存中...":n?"已保存":"保存设置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(lx,{className:"w-5 h-5 text-[#00CED1]"}),"网站基础信息"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置网站名称、标题和描述"})]}),s.jsxs(Le,{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(ee,{htmlFor:"site-name",className:"text-gray-300",children:"网站名称"}),s.jsx(de,{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(ee,{htmlFor:"site-title",className:"text-gray-300",children:"网站标题"}),s.jsx(de,{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(ee,{htmlFor:"site-desc",className:"text-gray-300",children:"网站描述"}),s.jsx(de,{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(ee,{htmlFor:"logo",className:"text-gray-300",children:"Logo地址"}),s.jsx(de,{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(ee,{htmlFor:"favicon",className:"text-gray-300",children:"Favicon地址"}),s.jsx(de,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(CM,{className:"w-5 h-5 text-[#00CED1]"}),"主题颜色"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置网站主题色"})]}),s.jsx(Le,{children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"space-y-2 flex-1",children:[s.jsx(ee,{htmlFor:"primary-color",className:"text-gray-300",children:"主色调"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(de,{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(de,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(bM,{className:"w-5 h-5 text-[#00CED1]"}),"底部菜单配置"]}),s.jsx(Kt,{className:"text-gray-400",children:"控制底部导航栏菜单的显示和名称"})]}),s.jsx(Le,{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($t,{checked:(m==null?void 0:m.enabled)??!0,onCheckedChange:g=>e(y=>({...y,menuConfig:{...y.menuConfig,[f]:{...m,enabled:g}}}))}),s.jsx("span",{className:"text-gray-300 w-16 capitalize",children:f}),s.jsx(de,{className:"bg-[#0f2137] border-gray-700 text-white max-w-[200px]",value:(m==null?void 0:m.label)??"",onChange:g=>e(y=>({...y,menuConfig:{...y.menuConfig,[f]:{...m,label:g.target.value}}}))})]}),s.jsx("span",{className:`text-sm ${m!=null&&m.enabled?"text-green-400":"text-gray-500"}`,children:m!=null&&m.enabled?"显示":"隐藏"})]},f))})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(Tj,{className:"w-5 h-5 text-[#00CED1]"}),"页面标题配置"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置各个页面的标题和副标题"})]}),s.jsxs(Le,{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(ee,{className:"text-gray-300",children:"首页标题"}),s.jsx(de,{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(ee,{className:"text-gray-300",children:"首页副标题"}),s.jsx(de,{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(ee,{className:"text-gray-300",children:"目录页标题"}),s.jsx(de,{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(ee,{className:"text-gray-300",children:"匹配页标题"}),s.jsx(de,{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(ee,{className:"text-gray-300",children:"我的页标题"}),s.jsx(de,{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(ee,{className:"text-gray-300",children:"关于作者标题"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.aboutTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,aboutTitle:f.target.value}}))})]})]})]})]})]})]})}function uV(){const[t,e]=b.useState(""),[n,r]=b.useState(""),[a,i]=b.useState(""),[o,c]=b.useState({}),u=async()=>{var y,N,w,j;try{const S=await Pe("/api/config"),E=(N=(y=S==null?void 0:S.liveQRCodes)==null?void 0:y[0])==null?void 0:N.urls;Array.isArray(E)&&e(E.join(` +}`})]})]}),s.jsx("p",{className:"text-gray-500 text-xs mt-6",children:"管理端主要使用 /api/admin/*、/api/db/*;富文本素材上传另用公共接口 /api/upload(与后台编辑器一致)。小程序使用 /api/miniprogram/*。完整实现见 soul-api 源码。"})]})}const Z9={appId:"wxb8bbb2b10dec74aa",withdrawSubscribeTmplId:"u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE",mchId:"1318592501",minWithdraw:10},eV={name:"卡若",startDate:"2025年10月15日",bio:"连续创业者,私域运营专家,每天早上6-9点在Soul派对房分享真实商业故事",liveTime:"06:00-09:00",platform:"Soul派对房",description:"连续创业者,私域运营专家"},tV={sectionPrice:1,baseBookPrice:9.9,distributorShare:90,authorInfo:{...eV},ckbLeadApiKey:""},nV={matchEnabled:!0,referralEnabled:!0,searchEnabled:!0,aboutEnabled:!0},sV={tabBar:{home:"首页",chapters:"目录",match:"找伙伴",my:"我的"},chaptersPage:{bookTitle:"一场SOUL的创业实验场",bookSubtitle:"来自Soul派对房的真实商业故事"},homePage:{logoTitle:"卡若创业派对",logoSubtitle:"来自派对房的真实故事",linkKaruoText:"点击链接卡若",linkKaruoAvatar:"",searchPlaceholder:"搜索章节标题或内容...",bannerTag:"推荐",bannerReadMoreText:"点击阅读",superSectionTitle:"超级个体",superSectionLinkText:"获客入口",superSectionLinkPath:"/pages/match/match",pickSectionTitle:"精选推荐",latestSectionTitle:"最新新增"},myPage:{cardLabel:"名片",vipLabelVip:"会员中心",vipLabelGuest:"成为会员",cardPath:"",vipPath:"/pages/vip/vip",readStatLabel:"已读章节",recentReadTitle:"最近阅读",readStatPath:"/pages/reading-records/reading-records?focus=all",recentReadPath:"/pages/reading-records/reading-records?focus=recent"}},rV=["system","author","admin","api-docs"],Xw=["basic","mp","oss","features"];function aV(){const[t,e]=x0(),n=t.get("tab")??"system",r=rV.includes(n)?n:"system",a=t.get("section")??"basic",i=Xw.includes(a)?a:"basic",[o,c]=b.useState(tV),[u,h]=b.useState(nV),[f,m]=b.useState(Z9),[x,y]=b.useState("{}"),[N,w]=b.useState({}),[j,S]=b.useState(!1),[E,T]=b.useState(!0),[P,O]=b.useState(!1),[q,z]=b.useState(""),[V,I]=b.useState(""),[te,Q]=b.useState(!1),[F,re]=b.useState(!1),ie=(H,K,me=!1)=>{z(H),I(K),Q(me),O(!0)};b.useEffect(()=>{(async()=>{try{const K=await Pe("/api/admin/settings");if(!K||K.success===!1)return;if(K.featureConfig&&Object.keys(K.featureConfig).length&&h(me=>({...me,...K.featureConfig})),K.mpConfig&&typeof K.mpConfig=="object"){const me={...K.mpConfig};m(le=>({...le,...me}));const Y=me.mpUi;y(JSON.stringify(Y!=null&&typeof Y=="object"&&!Array.isArray(Y)?Y:{},null,2))}if(K.ossConfig&&typeof K.ossConfig=="object"&&w(me=>({...me,...K.ossConfig})),K.siteSettings&&typeof K.siteSettings=="object"){const me=K.siteSettings;c(Y=>({...Y,...typeof me.sectionPrice=="number"&&{sectionPrice:me.sectionPrice},...typeof me.baseBookPrice=="number"&&{baseBookPrice:me.baseBookPrice},...typeof me.distributorShare=="number"&&{distributorShare:me.distributorShare},...me.authorInfo&&typeof me.authorInfo=="object"&&{authorInfo:{...Y.authorInfo,...me.authorInfo}},...typeof me.ckbLeadApiKey=="string"&&{ckbLeadApiKey:me.ckbLeadApiKey}}))}}catch(K){console.error("Load settings error:",K)}finally{T(!1)}})()},[]);const J=async(H,K)=>{re(!0);try{const me=await Ct("/api/admin/settings",{featureConfig:H});if(!me||me.success===!1){K(),ie("保存失败",(me==null?void 0:me.error)??"未知错误",!0);return}ie("已保存","功能开关已更新,相关入口将随之显示或隐藏。")}catch(me){console.error("Save feature config error:",me),K(),ie("保存失败",me instanceof Error?me.message:String(me),!0)}finally{re(!1)}},$=(H,K)=>{const me=u,Y={...me,[H]:K};h(Y),J(Y,()=>h(me))},[D,R]=b.useState(!1),oe=async H=>{const K=f,me={...K,auditMode:H};m(me),R(!0);try{const Y=await Ct("/api/admin/settings",{mpConfig:me});if(!Y||Y.success===!1){m(K),ie("保存失败",(Y==null?void 0:Y.error)??"未知错误",!0);return}ie("已保存",H?"审核模式已开启,小程序将隐藏所有支付入口。":"审核模式已关闭,支付功能已恢复。")}catch(Y){m(K),ie("保存失败",Y instanceof Error?Y.message:String(Y),!0)}finally{R(!1)}},G=async()=>{S(!0);try{let H={};try{const me=x.trim();if(me){const Y=JSON.parse(me);if(Y&&typeof Y=="object"&&!Array.isArray(Y))H=Y;else{ie("保存失败","小程序文案 mpUi 须为 JSON 对象(非数组)",!0),S(!1);return}}}catch{ie("保存失败","小程序文案 mpUi 不是合法 JSON",!0),S(!1);return}const K=await Ct("/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:H},ossConfig:Object.keys(N).length?{endpoint:N.endpoint??"",bucket:N.bucket??"",region:N.region??"",accessKeyId:N.accessKeyId??"",accessKeySecret:N.accessKeySecret??""}:void 0});if(!K||K.success===!1){ie("保存失败",(K==null?void 0:K.error)??"未知错误",!0);return}ie("已保存","设置已保存成功。")}catch(H){console.error("Save settings error:",H),ie("保存失败",H instanceof Error?H.message:String(H),!0)}finally{S(!1)}},_=H=>{if(H==="system"){const K=new URLSearchParams(t);K.delete("tab"),Xw.includes(K.get("section")||"basic")||K.set("section","basic"),e(K);return}e({tab:H})},U=H=>{const K=new URLSearchParams(t);K.delete("tab"),K.set("section",H),e(K)};return E?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(X,{onClick:G,disabled:j,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),j?"保存中...":"保存设置"]})]}),s.jsxs(jc,{value:r,onValueChange:_,className:"w-full",children:[s.jsxs(ul,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(Qt,{value:"system",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[s.jsx(no,{className:"w-4 h-4 mr-2"}),"系统设置"]}),s.jsxs(Qt,{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(lh,{className:"w-4 h-4 mr-2"}),"作者详情"]}),s.jsxs(Qt,{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(dc,{className:"w-4 h-4 mr-2"}),"管理员"]}),s.jsxs(Qt,{value:"api-docs",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",onClick:H=>{H.preventDefault(),window.open("/api-docs","_blank")},children:[s.jsx(Tj,{className:"w-4 h-4 mr-2"}),"API 文档 ↗"]})]}),s.jsxs(Yt,{value:"system",className:"mt-0",children:[s.jsxs("p",{className:"text-xs text-gray-500 mb-3",children:["MBTI 默认头像已迁至"," ",s.jsx(bc,{to:"/users",className:"text-[#38bdac] underline",children:"用户管理(用户列表点头像打开)"})]}),s.jsxs(jc,{value:i,onValueChange:U,className:"w-full",children:[s.jsxs(ul,{className:"mb-4 bg-[#0a1628] border border-gray-700/50 p-1 flex-wrap h-auto gap-1",children:[s.jsxs(Qt,{value:"basic",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(iM,{className:"w-3.5 h-3.5 mr-1"}),"基础与价格"]}),s.jsxs(Qt,{value:"mp",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(ll,{className:"w-3.5 h-3.5 mr-1"}),"小程序与审核"]}),s.jsxs(Qt,{value:"oss",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(i1,{className:"w-3.5 h-3.5 mr-1"}),"OSS"]}),s.jsxs(Qt,{value:"features",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(no,{className:"w-3.5 h-3.5 mr-1"}),"功能开关"]})]}),s.jsxs(Yt,{value:"basic",className:"space-y-6 mt-0",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(lh,{className:"w-5 h-5 text-[#38bdac]"}),"关于作者"]}),s.jsx(Kt,{className:"text-gray-400",children:'配置作者信息,将在"关于作者"页面显示'})]}),s.jsxs(Le,{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(ee,{htmlFor:"author-name",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(lh,{className:"w-3 h-3"}),"主理人名称"]}),s.jsx(ce,{id:"author-name",className:"bg-[#0a1628] border-gray-700 text-white",value:o.authorInfo.name??"",onChange:H=>c(K=>({...K,authorInfo:{...K.authorInfo,name:H.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ee,{htmlFor:"start-date",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(rg,{className:"w-3 h-3"}),"开播日期"]}),s.jsx(ce,{id:"start-date",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 2025年10月15日",value:o.authorInfo.startDate??"",onChange:H=>c(K=>({...K,authorInfo:{...K.authorInfo,startDate:H.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ee,{htmlFor:"live-time",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(rg,{className:"w-3 h-3"}),"直播时间"]}),s.jsx(ce,{id:"live-time",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 06:00-09:00",value:o.authorInfo.liveTime??"",onChange:H=>c(K=>({...K,authorInfo:{...K.authorInfo,liveTime:H.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ee,{htmlFor:"platform",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Aj,{className:"w-3 h-3"}),"直播平台"]}),s.jsx(ce,{id:"platform",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: Soul派对房",value:o.authorInfo.platform??"",onChange:H=>c(K=>({...K,authorInfo:{...K.authorInfo,platform:H.target.value}}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ee,{htmlFor:"description",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Gs,{className:"w-3 h-3"}),"简介描述"]}),s.jsx(ce,{id:"description",className:"bg-[#0a1628] border-gray-700 text-white",value:o.authorInfo.description??"",onChange:H=>c(K=>({...K,authorInfo:{...K.authorInfo,description:H.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{htmlFor:"bio",className:"text-gray-300",children:"详细介绍"}),s.jsx(hl,{id:"bio",className:"bg-[#0a1628] border-gray-700 text-white min-h-[100px]",placeholder:"输入作者详细介绍...",value:o.authorInfo.bio??"",onChange:H=>c(K=>({...K,authorInfo:{...K.authorInfo,bio:H.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ee,{htmlFor:"ckb-lead-api-key",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ya,{className:"w-3 h-3"}),"链接卡若存客宝密钥"]}),s.jsx(ce,{id:"ckb-lead-api-key",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 xxxxx-xxxxx-xxxxx-xxxxx(留空则用 .env 默认)",value:o.ckbLeadApiKey??"",onChange:H=>c(K=>({...K,ckbLeadApiKey:H.target.value}))}),s.jsx("p",{className:"text-xs text-gray-500",children:"小程序首页「链接卡若」留资接口使用的存客宝 API Key,优先于 .env 配置"})]}),s.jsxs("div",{className:"mt-4 p-4 rounded-xl bg-[#0a1628] border border-[#38bdac]/30",children:[s.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"预览效果"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-12 h-12 rounded-full bg-gradient-to-br from-[#00CED1] to-[#20B2AA] flex items-center justify-center text-xl font-bold text-white",children:(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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(Kh,{className:"w-5 h-5 text-[#38bdac]"}),"价格设置"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置书籍和章节的定价"})]}),s.jsx(Le,{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(ee,{className:"text-gray-300",children:"单节价格 (元)"}),s.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.sectionPrice,onChange:H=>c(K=>({...K,sectionPrice:Number.parseFloat(H.target.value)||1}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"整本价格 (元)"}),s.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.baseBookPrice,onChange:H=>c(K=>({...K,baseBookPrice:Number.parseFloat(H.target.value)||9.9}))})]})]})})]})]}),s.jsxs(Yt,{value:"mp",className:"space-y-6 mt-0",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(ll,{className:"w-5 h-5 text-[#38bdac]"}),"小程序配置"]}),s.jsx(Kt,{className:"text-gray-400",children:"订阅消息模板、支付商户号等,小程序从 /api/miniprogram/config 读取(API 地址由 app.js baseUrl 控制)"})]}),s.jsxs(Le,{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(ee,{className:"text-gray-300",children:"小程序 AppID"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"wxb8bbb2b10dec74aa",value:f.appId??"",onChange:H=>m(K=>({...K,appId:H.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"提现订阅模板 ID"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"用户申请提现时需授权",value:f.withdrawSubscribeTmplId??"",onChange:H=>m(K=>({...K,withdrawSubscribeTmplId:H.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"微信支付商户号"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"1318592501",value:f.mchId??"",onChange:H=>m(K=>({...K,mchId:H.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"最低提现金额 (元)"}),s.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:f.minWithdraw??10,onChange:H=>m(K=>({...K,minWithdraw:Number.parseFloat(H.target.value)||10}))})]})]}),s.jsxs("div",{className:"space-y-2 pt-2 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsx(ee,{className:"text-gray-300",children:"小程序界面文案 mpUi(JSON)"}),s.jsx(X,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-200",onClick:()=>y(JSON.stringify(sV,null,2)),children:"填入默认模板"})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"覆盖 Tab 文案、首页/目录标题、我的页名片与阅读记录路径等;仅填需要改的字段也可(与后端默认值深合并)。保存后小程序约 5 分钟内通过 config 缓存刷新。"}),s.jsx(hl,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm min-h-[280px]",spellCheck:!1,value:x,onChange:H=>y(H.target.value)})]})]})]}),s.jsxs(Oe,{className:`bg-[#0f2137] shadow-xl ${f.auditMode?"border-amber-500/50 border-2":"border-gray-700/50"}`,children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(dc,{className:"w-5 h-5 text-amber-400"}),"小程序审核模式"]}),s.jsx(Kt,{className:"text-gray-400",children:"提交微信审核前开启,审核通过后关闭即可恢复支付功能"})]}),s.jsx(Le,{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(dc,{className:`w-4 h-4 ${f.auditMode?"text-amber-400":"text-gray-400"}`}),s.jsx(ee,{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($t,{id:"audit-mode",checked:f.auditMode??!1,disabled:D,onCheckedChange:oe})]})})]})]}),s.jsx(Yt,{value:"oss",className:"space-y-6 mt-0",children:s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(i1,{className:"w-5 h-5 text-[#38bdac]"}),"OSS 配置(阿里云对象存储)"]}),s.jsx(Kt,{className:"text-gray-400",children:"endpoint、bucket、accessKey 等,用于图片/文件上传"})]}),s.jsx(Le,{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(ee,{className:"text-gray-300",children:"Endpoint"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou.aliyuncs.com",value:N.endpoint??"",onChange:H=>w(K=>({...K,endpoint:H.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"Bucket"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"bucket 名称",value:N.bucket??"",onChange:H=>w(K=>({...K,bucket:H.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"Region"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou",value:N.region??"",onChange:H=>w(K=>({...K,region:H.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"AccessKey ID"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey ID",value:N.accessKeyId??"",onChange:H=>w(K=>({...K,accessKeyId:H.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"AccessKey Secret"}),s.jsx(ce,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey Secret",value:N.accessKeySecret??"",onChange:H=>w(K=>({...K,accessKeySecret:H.target.value}))})]})]})})]})}),s.jsxs(Yt,{value:"features",className:"space-y-6 mt-0",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(no,{className:"w-5 h-5 text-[#38bdac]"}),"功能开关"]}),s.jsx(Kt,{className:"text-gray-400",children:"控制各个功能模块的显示/隐藏"})]}),s.jsxs(Le,{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(In,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(ee,{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($t,{id:"match-enabled",checked:u.matchEnabled,disabled:F,onCheckedChange:H=>$("matchEnabled",H)})]}),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(og,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(ee,{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(bc,{to:"/distribution?tab=settings",className:"underline mx-1 text-[#38bdac]",children:"推广中心 → 推广设置"}),"为同一套接口,在此仅控制是否展示入口。"]})]}),s.jsx($t,{id:"referral-enabled",checked:u.referralEnabled,disabled:F,onCheckedChange:H=>$("referralEnabled",H)})]}),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(Gs,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(ee,{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($t,{id:"search-enabled",checked:u.searchEnabled,disabled:F,onCheckedChange:H=>$("searchEnabled",H)})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(no,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(ee,{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($t,{id:"about-enabled",checked:u.aboutEnabled,disabled:F,onCheckedChange:H=>$("aboutEnabled",H)})]})]}),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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(qh,{className:"w-5 h-5 text-[#38bdac]"}),"小程序模块显隐说明"]}),s.jsx(Kt,{className:"text-gray-400",children:"以下模块受上方开关和审核模式共同控制"})]}),s.jsx(Le,{children:s.jsx("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[{mod:"找伙伴",ctrl:"找伙伴功能开关",icon:s.jsx(In,{className:"w-3 h-3"})},{mod:"推广中心 / 推荐好友",ctrl:"推广功能开关",icon:s.jsx(og,{className:"w-3 h-3"})},{mod:"搜索",ctrl:"搜索功能开关",icon:s.jsx(Gs,{className:"w-3 h-3"})},{mod:"关于页面",ctrl:"关于页面开关",icon:s.jsx(lh,{className:"w-3 h-3"})},{mod:"支付 / VIP / 充值 / 收益",ctrl:"审核模式",icon:s.jsx(dc,{className:"w-3 h-3"})},{mod:"超级个体名片",ctrl:"审核模式",icon:s.jsx(sA,{className:"w-3 h-3"})},{mod:"首页获客入口",ctrl:"已移除",icon:s.jsx(A5,{className:"w-3 h-3"})}].map(H=>s.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#0a1628] border border-gray-700/30",children:[H.icon,s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:H.mod}),s.jsxs("span",{className:"text-gray-500 ml-1",children:["← ",H.ctrl]})]})]},H.mod))})})]})]})]})]}),s.jsx(Yt,{value:"author",className:"mt-0",children:s.jsx(Q9,{})}),s.jsx(Yt,{value:"admin",className:"mt-0",children:s.jsx(X9,{})}),s.jsx(Yt,{value:"api-docs",className:"mt-0",children:s.jsx(m4,{})})]}),s.jsx(Dt,{open:P,onOpenChange:O,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsxs(_t,{children:[s.jsx(zt,{className:te?"text-red-400":"text-[#38bdac]",children:q}),s.jsx(Zh,{className:"text-gray-400 whitespace-pre-wrap pt-2",children:V})]}),s.jsx(fn,{className:"mt-4",children:s.jsx(X,{onClick:()=>O(!1),className:te?"bg-gray-600 hover:bg-gray-500":"bg-[#38bdac] hover:bg-[#2da396]",children:"确定"})})]})})]})}const Zw={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 iV(){const[t,e]=b.useState(!1),[n,r]=b.useState(Zw),[a,i]=b.useState(""),o=async()=>{e(!0);try{const S=await Pe("/api/config");S!=null&&S.paymentMethods&&r({...Zw,...S.paymentMethods})}catch(S){console.error(S)}finally{e(!1)}};b.useEffect(()=>{o()},[]);const c=async()=>{e(!0);try{await Ct("/api/db/config",{key:"payment_methods",value:n,description:"支付方式配置"}),se.success("配置已保存!")}catch(S){console.error("保存失败:",S),se.error("保存失败: "+(S instanceof Error?S.message:String(S)))}finally{e(!1)}},u=(S,E)=>{navigator.clipboard.writeText(S),i(E),setTimeout(()=>i(""),2e3)},h=(S,E)=>{r(T=>({...T,wechat:{...T.wechat,[S]:E}}))},f=(S,E)=>{r(T=>({...T,alipay:{...T.alipay,[S]:E}}))},m=(S,E)=>{r(T=>({...T,usdt:{...T.usdt,[S]:E}}))},x=(S,E)=>{r(T=>({...T,paypal:{...T.paypal,[S]:E}}))},y=n.wechat,N=n.alipay,w=n.usdt,j=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(X,{variant:"outline",onClick:o,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"同步配置"]}),s.jsxs(X,{onClick:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{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(kj,{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(jc,{defaultValue:"wechat",className:"space-y-6",children:[s.jsxs(ul,{className:"bg-[#0f2137] border border-gray-700/50 p-1 grid grid-cols-4 w-full",children:[s.jsxs(Qt,{value:"wechat",className:"data-[state=active]:bg-[#07C160]/20 data-[state=active]:text-[#07C160] text-gray-400",children:[s.jsx(ll,{className:"w-4 h-4 mr-2"}),"微信"]}),s.jsxs(Qt,{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(Qt,{value:"usdt",className:"data-[state=active]:bg-[#26A17B]/20 data-[state=active]:text-[#26A17B] text-gray-400",children:[s.jsx(a1,{className:"w-4 h-4 mr-2"}),"USDT"]}),s.jsxs(Qt,{value:"paypal",className:"data-[state=active]:bg-[#003087]/20 data-[state=active]:text-[#169BD7] text-gray-400",children:[s.jsx(lg,{className:"w-4 h-4 mr-2"}),"PayPal"]})]}),s.jsx(Yt,{value:"wechat",className:"space-y-4",children:s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(at,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(ll,{className:"w-5 h-5"}),"微信支付配置"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置微信支付参数和跳转链接"})]}),s.jsx($t,{checked:!!y.enabled,onCheckedChange:S=>h("enabled",S)})]}),s.jsxs(Le,{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(ee,{className:"text-gray-300",children:"网站AppID"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.websiteAppId??""),onChange:S=>h("websiteAppId",S.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"商户号"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.merchantId??""),onChange:S=>h("merchantId",S.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(fi,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置(核心功能)"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"微信收款码/支付链接"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://收款码图片URL 或 weixin://支付链接",value:String(y.qrCode??""),onChange:S=>h("qrCode",S.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(ee,{className:"text-[#07C160] font-medium",children:"微信群跳转链接(支付成功后跳转)"}),s.jsx(ce,{className:"bg-[#0a1628] border-[#07C160]/30 text-white placeholder:text-gray-500",placeholder:"https://weixin.qq.com/g/... 或微信群二维码图片URL",value:String(y.groupQrCode??""),onChange:S=>h("groupQrCode",S.target.value)}),s.jsx("p",{className:"text-xs text-[#07C160]/70",children:"用户支付成功后将自动跳转到此链接,进入指定微信群"})]})]})]})]})}),s.jsx(Yt,{value:"alipay",className:"space-y-4",children:s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(at,{className:"text-[#1677FF] flex items-center gap-2",children:[s.jsx(o1,{className:"w-5 h-5"}),"支付宝配置"]}),s.jsx(Kt,{className:"text-gray-400",children:"已加载真实支付宝参数"})]}),s.jsx($t,{checked:!!N.enabled,onCheckedChange:S=>f("enabled",S)})]}),s.jsxs(Le,{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(ee,{className:"text-gray-300",children:"合作者身份 (PID)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(N.partnerId??""),onChange:S=>f("partnerId",S.target.value)}),s.jsx(X,{size:"icon",variant:"outline",className:"border-gray-700 bg-transparent",onClick:()=>u(String(N.partnerId??""),"pid"),children:a==="pid"?s.jsx(Zf,{className:"w-4 h-4 text-green-500"}):s.jsx(Cj,{className:"w-4 h-4 text-gray-400"})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"安全校验码 (Key)"}),s.jsx(ce,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(N.securityKey??""),onChange:S=>f("securityKey",S.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(fi,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"支付宝收款码/跳转链接"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://qr.alipay.com/... 或收款码图片URL",value:String(N.qrCode??""),onChange:S=>f("qrCode",S.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户点击支付宝支付后显示的二维码"})]})]})]})]})}),s.jsx(Yt,{value:"usdt",className:"space-y-4",children:s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(at,{className:"text-[#26A17B] flex items-center gap-2",children:[s.jsx(a1,{className:"w-5 h-5"}),"USDT配置"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置加密货币收款地址"})]}),s.jsx($t,{checked:!!w.enabled,onCheckedChange:S=>m("enabled",S)})]}),s.jsxs(Le,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{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:S=>m("network",S.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(ee,{className:"text-gray-300",children:"收款地址"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",placeholder:"T... (TRC20地址)",value:String(w.address??""),onChange:S=>m("address",S.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(w.exchangeRate)??7.2,onChange:S=>m("exchangeRate",Number.parseFloat(S.target.value)||7.2)})]})]})]})}),s.jsx(Yt,{value:"paypal",className:"space-y-4",children:s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(at,{className:"text-[#169BD7] flex items-center gap-2",children:[s.jsx(lg,{className:"w-5 h-5"}),"PayPal配置"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置PayPal收款账户"})]}),s.jsx($t,{checked:!!j.enabled,onCheckedChange:S=>x("enabled",S)})]}),s.jsxs(Le,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"PayPal邮箱"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"your@email.com",value:String(j.email??""),onChange:S=>x("email",S.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(j.exchangeRate)??7.2,onChange:S=>x("exchangeRate",Number(S.target.value)||7.2)})]})]})]})})]})]})}const oV={siteName:"卡若日记",siteTitle:"一场SOUL的创业实验场",siteDescription:"来自Soul派对房的真实商业故事",logo:"/logo.png",favicon:"/favicon.ico",primaryColor:"#00CED1"},lV={home:{enabled:!0,label:"首页"},chapters:{enabled:!0,label:"目录"},match:{enabled:!0,label:"匹配"},my:{enabled:!0,label:"我的"}},cV={homeTitle:"一场SOUL的创业实验场",homeSubtitle:"来自Soul派对房的真实商业故事",chaptersTitle:"我要看",matchTitle:"语音匹配",myTitle:"我的",aboutTitle:"关于作者"};function dV(){const[t,e]=b.useState({siteConfig:{...oV},menuConfig:{...lV},pageConfig:{...cV}}),[n,r]=b.useState(!1),[a,i]=b.useState(!1);b.useEffect(()=>{Pe("/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 Ct("/api/db/config",{key:"site_config",value:t.siteConfig,description:"网站基础配置"}),await Ct("/api/db/config",{key:"menu_config",value:t.menuConfig,description:"底部菜单配置"}),await Ct("/api/db/config",{key:"page_config",value:t.pageConfig,description:"页面标题配置"}),r(!0),setTimeout(()=>r(!1),2e3),se.success("配置已保存")}catch(f){console.error(f),se.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{i(!1)}},c=t.siteConfig,u=t.menuConfig,h=t.pageConfig;return 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(X,{onClick:o,disabled:a,className:`${n?"bg-green-500":"bg-[#00CED1]"} hover:bg-[#20B2AA] text-white transition-colors`,children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),a?"保存中...":n?"已保存":"保存设置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(lg,{className:"w-5 h-5 text-[#00CED1]"}),"网站基础信息"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置网站名称、标题和描述"})]}),s.jsxs(Le,{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(ee,{htmlFor:"site-name",className:"text-gray-300",children:"网站名称"}),s.jsx(ce,{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(ee,{htmlFor:"site-title",className:"text-gray-300",children:"网站标题"}),s.jsx(ce,{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(ee,{htmlFor:"site-desc",className:"text-gray-300",children:"网站描述"}),s.jsx(ce,{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(ee,{htmlFor:"logo",className:"text-gray-300",children:"Logo地址"}),s.jsx(ce,{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(ee,{htmlFor:"favicon",className:"text-gray-300",children:"Favicon地址"}),s.jsx(ce,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(CM,{className:"w-5 h-5 text-[#00CED1]"}),"主题颜色"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置网站主题色"})]}),s.jsx(Le,{children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"space-y-2 flex-1",children:[s.jsx(ee,{htmlFor:"primary-color",className:"text-gray-300",children:"主色调"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(ce,{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(ce,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(bM,{className:"w-5 h-5 text-[#00CED1]"}),"底部菜单配置"]}),s.jsx(Kt,{className:"text-gray-400",children:"控制底部导航栏菜单的显示和名称"})]}),s.jsx(Le,{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($t,{checked:(m==null?void 0:m.enabled)??!0,onCheckedChange:x=>e(y=>({...y,menuConfig:{...y.menuConfig,[f]:{...m,enabled:x}}}))}),s.jsx("span",{className:"text-gray-300 w-16 capitalize",children:f}),s.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white max-w-[200px]",value:(m==null?void 0:m.label)??"",onChange:x=>e(y=>({...y,menuConfig:{...y.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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(Tj,{className:"w-5 h-5 text-[#00CED1]"}),"页面标题配置"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置各个页面的标题和副标题"})]}),s.jsxs(Le,{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(ee,{className:"text-gray-300",children:"首页标题"}),s.jsx(ce,{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(ee,{className:"text-gray-300",children:"首页副标题"}),s.jsx(ce,{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(ee,{className:"text-gray-300",children:"目录页标题"}),s.jsx(ce,{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(ee,{className:"text-gray-300",children:"匹配页标题"}),s.jsx(ce,{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(ee,{className:"text-gray-300",children:"我的页标题"}),s.jsx(ce,{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(ee,{className:"text-gray-300",children:"关于作者标题"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.aboutTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,aboutTitle:f.target.value}}))})]})]})]})]})]})]})}function uV(){const[t,e]=b.useState(""),[n,r]=b.useState(""),[a,i]=b.useState(""),[o,c]=b.useState({}),u=async()=>{var y,N,w,j;try{const S=await Pe("/api/config"),E=(N=(y=S==null?void 0:S.liveQRCodes)==null?void 0:y[0])==null?void 0:N.urls;Array.isArray(E)&&e(E.join(` `));const T=(j=(w=S==null?void 0:S.paymentMethods)==null?void 0:w.wechat)==null?void 0:j.groupQrCode;T&&r(T),c({paymentMethods:S==null?void 0:S.paymentMethods,liveQRCodes:S==null?void 0:S.liveQRCodes})}catch(S){console.error(S)}};b.useEffect(()=>{u()},[]);const h=(y,N)=>{navigator.clipboard.writeText(y),i(N),setTimeout(()=>i(""),2e3)},f=async()=>{try{const y=t.split(` -`).map(w=>w.trim()).filter(Boolean),N=[...o.liveQRCodes||[]];N[0]?N[0].urls=y:N.push({id:"live-1",name:"微信群活码",urls:y,clickCount:0}),await Ct("/api/db/config",{key:"live_qr_codes",value:N,description:"群活码配置"}),se.success("群活码配置已保存!"),await u()}catch(y){console.error(y),se.error("保存失败: "+(y instanceof Error?y.message:String(y)))}},m=async()=>{var y;try{await Ct("/api/db/config",{key:"payment_methods",value:{...o.paymentMethods||{},wechat:{...((y=o.paymentMethods)==null?void 0:y.wechat)||{},groupQrCode:n}},description:"支付方式配置"}),se.success("微信群链接已保存!用户支付成功后将自动跳转"),await u()}catch(N){console.error(N),se.error("保存失败: "+(N instanceof Error?N.message:String(N)))}},g=()=>{n?window.open(n,"_blank"):se.error("请先配置微信群链接")};return 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(kj,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(u1,{className:"w-5 h-5"}),"支付成功跳转链接(核心配置)"]}),s.jsx(Kt,{className:"text-gray-400",children:"用户支付完成后自动跳转到此链接,进入指定微信群"})]}),s.jsxs(Le,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ee,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(dx,{className:"w-4 h-4"}),"微信群链接 / 活码链接"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(de,{placeholder:"https://cli.im/xxxxx 或 https://weixin.qq.com/g/...",className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",value:n,onChange:y=>r(y.target.value)}),s.jsx(X,{variant:"outline",size:"icon",className:"border-gray-700 bg-transparent hover:bg-gray-700/50",onClick:()=>h(n,"group"),children:a==="group"?s.jsx(Zf,{className:"w-4 h-4 text-green-500"}):s.jsx(Cj,{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(fi,{className:"w-3 h-3"}),"支持格式:草料短链、微信群链接(https://weixin.qq.com/g/...)、企业微信链接等"]})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(X,{onClick:m,className:"flex-1 bg-[#07C160] hover:bg-[#06AD51] text-white",children:[s.jsx(Jh,{className:"w-4 h-4 mr-2"}),"保存配置"]}),s.jsxs(X,{onClick:g,variant:"outline",className:"border-[#07C160] text-[#07C160] hover:bg-[#07C160]/10 bg-transparent",children:[s.jsx(fi,{className:"w-4 h-4 mr-2"}),"测试跳转"]})]})]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(u1,{className:"w-5 h-5 text-[#38bdac]"}),"多群轮换(高级配置)"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置多个群链接,系统自动轮换分配,避免单群满员"})]}),s.jsxs(Le,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ee,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(dx,{className:"w-4 h-4"}),"多个群链接(每行一个)"]}),s.jsx(hl,{placeholder:"https://cli.im/group1\\nhttps://cli.im/group2",className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 min-h-[120px] font-mono text-sm",value:t,onChange:y=>e(y.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"每行填写一个群链接,系统将按顺序或随机分配"})]}),s.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[s.jsx("span",{className:"text-sm text-gray-400",children:"已配置群数量"}),s.jsxs("span",{className:"font-bold text-[#38bdac]",children:[t.split(` -`).filter(Boolean).length," 个"]})]}),s.jsxs(X,{onClick:f,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Jh,{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 ej={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}},hV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function fV(){const[t,e]=b.useState(ej),[n,r]=b.useState(!0),[a,i]=b.useState(!1),[o,c]=b.useState(!1),[u,h]=b.useState(null),[f,m]=b.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),g=async()=>{r(!0);try{const T=await Pe("/api/db/config/full?key=match_config"),P=(T==null?void 0:T.data)??(T==null?void 0:T.config);P&&e({...ej,...P})}catch(T){console.error("加载匹配配置失败:",T)}finally{r(!1)}};b.useEffect(()=>{g()},[]);const y=async()=>{i(!0);try{const T=await Ct("/api/db/config",{key:"match_config",value:t,description:"匹配功能配置"});T&&T.success!==!1?se.success("配置保存成功!"):se.error("保存失败: "+(T&&typeof T=="object"&&"error"in T?T.error:"未知错误"))}catch(T){console.error("保存配置失败:",T),se.error("保存失败")}finally{i(!1)}},N=T=>{h(T),m({id:T.id,label:T.label,matchLabel:T.matchLabel,icon:T.icon,matchFromDB:T.matchFromDB,showJoinAfterMatch:T.showJoinAfterMatch,price:T.price,enabled:T.enabled}),c(!0)},w=()=>{h(null),m({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),c(!0)},j=()=>{if(!f.id||!f.label){se.error("请填写类型ID和名称");return}const T=[...t.matchTypes];if(u){const P=T.findIndex(O=>O.id===u.id);P!==-1&&(T[P]={...f})}else{if(T.some(P=>P.id===f.id)){se.error("类型ID已存在");return}T.push({...f})}e({...t,matchTypes:T}),c(!1)},S=T=>{confirm("确定要删除这个匹配类型吗?")&&e({...t,matchTypes:t.matchTypes.filter(P=>P.id!==T)})},E=T=>{e({...t,matchTypes:t.matchTypes.map(P=>P.id===T?{...P,enabled:!P.enabled}:P)})};return s.jsxs("div",{className:"p-8 w-full space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(no,{className:"w-6 h-6 text-[#38bdac]"}),"匹配功能配置"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"管理找伙伴功能的匹配类型和价格"})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(X,{variant:"outline",onClick:g,disabled:n,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]}),s.jsxs(X,{onClick:y,disabled:a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存配置"]})]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(pi,{className:"w-5 h-5 text-yellow-400"}),"基础设置"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),s.jsxs(Le,{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(ee,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(de,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.freeMatchLimit,onChange:T=>e({...t,freeMatchLimit:parseInt(T.target.value,10)||0})}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户每天可免费匹配的次数"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(de,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:t.matchPrice,onChange:T=>e({...t,matchPrice:parseFloat(T.target.value)||1})}),s.jsx("p",{className:"text-xs text-gray-500",children:"免费次数用完后的单次匹配价格"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(de,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.settings.maxMatchesPerDay,onChange:T=>e({...t,settings:{...t.settings,maxMatchesPerDay:parseInt(T.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($t,{checked:t.settings.enableFreeMatches,onCheckedChange:T=>e({...t,settings:{...t.settings,enableFreeMatches:T}})}),s.jsx(ee,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($t,{checked:t.settings.enablePaidMatches,onCheckedChange:T=>e({...t,settings:{...t.settings,enablePaidMatches:T}})}),s.jsx(ee,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(In,{className:"w-5 h-5 text-[#38bdac]"}),"匹配类型管理"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(X,{onClick:w,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(An,{className:"w-4 h-4 mr-1"}),"添加类型"]})]}),s.jsx(Le,{children:s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"图标"}),s.jsx(je,{className:"text-gray-400",children:"类型ID"}),s.jsx(je,{className:"text-gray-400",children:"显示名称"}),s.jsx(je,{className:"text-gray-400",children:"匹配标签"}),s.jsx(je,{className:"text-gray-400",children:"价格"}),s.jsx(je,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(hs,{children:t.matchTypes.map(T=>s.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{children:s.jsx("span",{className:"text-2xl",children:T.icon})}),s.jsx(be,{className:"font-mono text-gray-300",children:T.id}),s.jsx(be,{className:"text-white font-medium",children:T.label}),s.jsx(be,{className:"text-gray-300",children:T.matchLabel}),s.jsx(be,{children:s.jsxs(Ve,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",T.price]})}),s.jsx(be,{children:T.matchFromDB?s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Ve,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(be,{children:s.jsx($t,{checked:T.enabled,onCheckedChange:()=>E(T.id)})}),s.jsx(be,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>N(T),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(Jt,{className:"w-4 h-4"})}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>S(T.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(bs,{className:"w-4 h-4"})})]})})]},T.id))})]})})]}),s.jsx(Dt,{open:o,onOpenChange:c,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[u?s.jsx(Jt,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(An,{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(ee,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:f.id,onChange:T=>m({...f,id:T.target.value}),disabled:!!u})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:hV.map(T=>s.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${f.icon===T?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>m({...f,icon:T}),children:T},T))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"显示名称"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业合伙",value:f.label,onChange:T=>m({...f,label:T.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"匹配标签"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业伙伴",value:f.matchLabel,onChange:T=>m({...f,matchLabel:T.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(de,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:f.price,onChange:T=>m({...f,price:parseFloat(T.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($t,{checked:f.matchFromDB,onCheckedChange:T=>m({...f,matchFromDB:T})}),s.jsx(ee,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($t,{checked:f.showJoinAfterMatch,onCheckedChange:T=>m({...f,showJoinAfterMatch:T})}),s.jsx(ee,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($t,{checked:f.enabled,onCheckedChange:T=>m({...f,enabled:T})}),s.jsx(ee,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(X,{onClick:j,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),"保存"]})]})]})})]})}const tj={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function pV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(""),[f,m]=b.useState(!0),[g,y]=b.useState(null);async function N(){m(!0),y(null);try{const j=new URLSearchParams({page:String(a),pageSize:String(o)});u&&j.set("matchType",u);const S=await Pe(`/api/db/match-records?${j}`);S!=null&&S.success?(e(S.records||[]),r(S.total??0)):y("加载匹配记录失败")}catch(j){console.error("加载匹配记录失败",j),y("加载失败,请检查网络后重试")}finally{m(!1)}}b.useEffect(()=>{N()},[a,u]);const w=Math.ceil(n/o)||1;return s.jsxs("div",{className:"p-8 w-full",children:[g&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[s.jsx("span",{children:g}),s.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"匹配记录"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["找伙伴匹配统计,共 ",n," 条记录"]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("select",{value:u,onChange:j=>{h(j.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(tj).map(([j,S])=>s.jsx("option",{value:j,children:S},j))]}),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(Fe,{className:`w-4 h-4 ${f?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:f?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Fe,{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(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"发起人"}),s.jsx(je,{className:"text-gray-400",children:"匹配到"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"联系方式"}),s.jsx(je,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(hs,{children:[t.map(j=>s.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 overflow-hidden",children:[j.userAvatar?s.jsx("img",{src:fo(j.userAvatar),alt:"",className:"w-full h-full object-cover",onError:S=>{S.currentTarget.style.display="none";const E=S.currentTarget.nextElementSibling;E&&E.classList.remove("hidden")}}):null,s.jsx("span",{className:j.userAvatar?"hidden":"",children:(j.userNickname||j.userId||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white",children:j.userNickname||j.userId}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[j.userId.slice(0,16),"..."]})]})]})}),s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 overflow-hidden",children:[j.matchedUserAvatar?s.jsx("img",{src:fo(j.matchedUserAvatar),alt:"",className:"w-full h-full object-cover",onError:S=>{S.currentTarget.style.display="none";const E=S.currentTarget.nextElementSibling;E&&E.classList.remove("hidden")}}):null,s.jsx("span",{className:j.matchedUserAvatar?"hidden":"",children:(j.matchedNickname||j.matchedUserId||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white",children:j.matchedNickname||j.matchedUserId}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[j.matchedUserId.slice(0,16),"..."]})]})]})}),s.jsx(be,{children:s.jsx(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:tj[j.matchType]||j.matchType})}),s.jsxs(be,{className:"text-gray-400 text-sm",children:[j.phone&&s.jsxs("div",{children:["📱 ",j.phone]}),j.wechatId&&s.jsxs("div",{children:["💬 ",j.wechatId]}),!j.phone&&!j.wechatId&&"-"]}),s.jsx(be,{className:"text-gray-400",children:j.createdAt?new Date(j.createdAt).toLocaleString():"-"})]},j.id)),t.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(Ks,{page:a,totalPages:w,total:n,pageSize:o,onPageChange:i,onPageSizeChange:j=>{c(j),i(1)}})]})})})]})}function mV(){const[t,e]=b.useState([]),[n,r]=b.useState(!0);async function a(){r(!0);try{const i=await Pe("/api/db/vip-members?limit=100");if(i!=null&&i.success&&i.data){const o=[...i.data].map((c,u)=>({...c,vipSort:typeof c.vipSort=="number"?c.vipSort:u+1}));o.sort((c,u)=>(c.vipSort??999999)-(u.vipSort??999999)),e(o)}}catch(i){console.error("Load VIP members error:",i),se.error("加载 VIP 成员失败")}finally{r(!1)}}return b.useEffect(()=>{a()},[]),s.jsxs("div",{className:"p-8 w-full",children:[s.jsx("div",{className:"flex justify-between items-center mb-8",children:s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(pc,{className:"w-5 h-5 text-amber-400"}),"用户管理 / 超级个体列表"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"这里展示所有有效超级个体用户,仅用于查看其基本信息与排序值。"})]})}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Le,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400 w-20",children:"序号"}),s.jsx(je,{className:"text-gray-400",children:"成员"}),s.jsx(je,{className:"text-gray-400 w-40",children:"超级个体"}),s.jsx(je,{className:"text-gray-400 w-28",children:"排序值"})]})}),s.jsxs(hs,{children:[t.map((i,o)=>{var c;return s.jsxs(ct,{className:"border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:o+1}),s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[i.avatar?s.jsx("img",{src:fo(i.avatar),className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",children:((c=i.name)==null?void 0:c[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:i.name})})]})}),s.jsx(be,{className:"text-gray-300",children:i.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置超级个体)"})}),s.jsx(be,{className:"text-gray-300",children:i.vipSort??o+1})]},i.id)}),t.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:5,className:"text-center py-12 text-gray-500",children:"当前没有有效的超级个体用户。"})})]})]})})})]})}function g4(t){const e=Sa(),[n,r]=b.useState([]),[a,i]=b.useState(!0),[o,c]=b.useState(!1),[u,h]=b.useState(null),[f,m]=b.useState({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:0,enabled:!0}),[g,y]=b.useState(!1),[N,w]=b.useState(!1),j=b.useRef(null),S=async I=>{var Q;const te=(Q=I.target.files)==null?void 0:Q[0];if(te){w(!0);try{const F=new FormData;F.append("file",te),F.append("folder","mentors");const re=iu(),ae={};re&&(ae.Authorization=`Bearer ${re}`);const $=await(await fetch(wc("/api/upload"),{method:"POST",body:F,credentials:"include",headers:ae})).json();$!=null&&$.success&&($!=null&&$.url)?m(D=>({...D,avatar:$.url})):se.error("上传失败: "+(($==null?void 0:$.error)||"未知错误"))}catch(F){console.error(F),se.error("上传失败")}finally{w(!1),j.current&&(j.current.value="")}}};async function E(){i(!0);try{const I=await Pe("/api/db/mentors");I!=null&&I.success&&I.data&&r(I.data)}catch(I){console.error("Load mentors error:",I)}finally{i(!1)}}b.useEffect(()=>{E()},[]);const T=()=>{m({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:n.length>0?Math.max(...n.map(I=>I.sort))+1:0,enabled:!0})},P=()=>{h(null),T(),c(!0)},O=I=>{h(I),m({name:I.name,avatar:I.avatar||"",intro:I.intro||"",tags:I.tags||"",priceSingle:I.priceSingle!=null?String(I.priceSingle):"",priceHalfYear:I.priceHalfYear!=null?String(I.priceHalfYear):"",priceYear:I.priceYear!=null?String(I.priceYear):"",quote:I.quote||"",whyFind:I.whyFind||"",offering:I.offering||"",judgmentStyle:I.judgmentStyle||"",sort:I.sort,enabled:I.enabled??!0}),c(!0)},q=async()=>{if(!f.name.trim()){se.error("导师姓名不能为空");return}y(!0);try{const I=Q=>Q===""?void 0:parseFloat(Q),te={name:f.name.trim(),avatar:f.avatar.trim()||void 0,intro:f.intro.trim()||void 0,tags:f.tags.trim()||void 0,priceSingle:I(f.priceSingle),priceHalfYear:I(f.priceHalfYear),priceYear:I(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 Q=await Gt("/api/db/mentors",{id:u.id,...te});Q!=null&&Q.success?(c(!1),E()):se.error("更新失败: "+(Q==null?void 0:Q.error))}else{const Q=await Ct("/api/db/mentors",te);Q!=null&&Q.success?(c(!1),E()):se.error("新增失败: "+(Q==null?void 0:Q.error))}}catch(I){console.error("Save error:",I),se.error("保存失败")}finally{y(!1)}},z=async I=>{if(confirm("确定删除该导师?"))try{const te=await li(`/api/db/mentors?id=${I}`);te!=null&&te.success?E():se.error("删除失败: "+(te==null?void 0:te.error))}catch(te){console.error("Delete error:",te),se.error("删除失败")}},V=I=>I!=null?`¥${I}`:"-";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(In,{className:"w-5 h-5 text-[#38bdac]"}),"导师管理"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师列表,支持每个导师独立配置单次/半年/年度价格"})]}),s.jsxs(X,{onClick:P,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(An,{className:"w-4 h-4 mr-2"}),"新增导师"]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Le,{className:"p-0",children:a?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"ID"}),s.jsx(je,{className:"text-gray-400",children:"姓名"}),s.jsx(je,{className:"text-gray-400",children:"简介"}),s.jsx(je,{className:"text-gray-400",children:"单次"}),s.jsx(je,{className:"text-gray-400",children:"半年"}),s.jsx(je,{className:"text-gray-400",children:"年度"}),s.jsx(je,{className:"text-gray-400",children:"排序"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(hs,{children:[n.map(I=>s.jsxs(ct,{className:"border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:I.id}),s.jsx(be,{children:s.jsxs("button",{type:"button",onClick:()=>e(`/users?search=${encodeURIComponent(I.name)}`),className:"text-[#38bdac] hover:text-[#2da396] hover:underline flex items-center gap-1",title:"在用户管理中查看",children:[I.name,s.jsx(fi,{className:"w-3 h-3"})]})}),s.jsx(be,{className:"text-gray-400 max-w-[200px] truncate",children:I.intro||"-"}),s.jsx(be,{className:"text-gray-400",children:V(I.priceSingle)}),s.jsx(be,{className:"text-gray-400",children:V(I.priceHalfYear)}),s.jsx(be,{className:"text-gray-400",children:V(I.priceYear)}),s.jsx(be,{className:"text-gray-400",children:I.sort}),s.jsxs(be,{className:"text-right",children:[s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>O(I),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(Jt,{className:"w-4 h-4"})}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>z(I.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(bs,{className:"w-4 h-4"})})]})]},I.id)),n.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无导师,点击「新增导师」添加"})})]})]})})}),s.jsx(Dt,{open:o,onOpenChange:c,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg max-h-[90vh] overflow-y-auto",children:[s.jsx(_t,{children:s.jsx(zt,{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(ee,{className:"text-gray-300",children:"姓名 *"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:卡若",value:f.name,onChange:I=>m(te=>({...te,name:I.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"排序"}),s.jsx(de,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:f.sort,onChange:I=>m(te=>({...te,sort:parseInt(I.target.value,10)||0}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"头像"}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(de,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:f.avatar,onChange:I=>m(te=>({...te,avatar:I.target.value})),placeholder:"点击上传或粘贴图片地址"}),s.jsx("input",{ref:j,type:"file",accept:"image/*",className:"hidden",onChange:S}),s.jsxs(X,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:N,onClick:()=>{var I;return(I=j.current)==null?void 0:I.click()},children:[s.jsx(Jh,{className:"w-4 h-4 mr-2"}),N?"上传中...":"上传"]})]}),f.avatar&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:fo(f.avatar.startsWith("http")?f.avatar:wc(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(ee,{className:"text-gray-300",children:"简介"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:结构判断型咨询 · Decision > Execution",value:f.intro,onChange:I=>m(te=>({...te,intro:I.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"技能标签(逗号分隔)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:项目结构判断、风险止损、人×项目匹配",value:f.tags,onChange:I=>m(te=>({...te,tags:I.target.value}))})]}),s.jsxs("div",{className:"border-t border-gray-700 pt-4",children:[s.jsx(ee,{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(ee,{className:"text-gray-500 text-xs",children:"单次咨询 ¥"}),s.jsx(de,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"980",value:f.priceSingle,onChange:I=>m(te=>({...te,priceSingle:I.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-500 text-xs",children:"半年咨询 ¥"}),s.jsx(de,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"19800",value:f.priceHalfYear,onChange:I=>m(te=>({...te,priceHalfYear:I.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-500 text-xs",children:"年度咨询 ¥"}),s.jsx(de,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"29800",value:f.priceYear,onChange:I=>m(te=>({...te,priceYear:I.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"引言"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:大多数人失败,不是因为不努力...",value:f.quote,onChange:I=>m(te=>({...te,quote:I.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"为什么找(文本)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:f.whyFind,onChange:I=>m(te=>({...te,whyFind:I.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"提供什么(文本)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:f.offering,onChange:I=>m(te=>({...te,offering:I.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"判断风格(逗号分隔)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:冷静、克制、偏风险视角",value:f.judgmentStyle,onChange:I=>m(te=>({...te,judgmentStyle:I.target.value}))})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"enabled",checked:f.enabled,onChange:I=>m(te=>({...te,enabled:I.target.checked})),className:"rounded border-gray-600 bg-[#0a1628]"}),s.jsx(ee,{htmlFor:"enabled",className:"text-gray-300 cursor-pointer",children:"上架(小程序可见)"})]})]}),s.jsxs(fn,{children:[s.jsxs(X,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(X,{onClick:q,disabled:g,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),g?"保存中...":"保存"]})]})]})})]})}function gV(){const[t,e]=b.useState([]),[n,r]=b.useState(!0),[a,i]=b.useState("");async function o(){r(!0);try{const h=a?`/api/db/mentor-consultations?status=${a}`:"/api/db/mentor-consultations",f=await Pe(h);f!=null&&f.success&&f.data&&e(f.data)}catch(h){console.error("Load consultations error:",h)}finally{r(!1)}}b.useEffect(()=>{o()},[a]);const c={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},u={single:"单次",half_year:"半年",year:"年度"};return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(rx,{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(X,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Le,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"ID"}),s.jsx(je,{className:"text-gray-400",children:"用户ID"}),s.jsx(je,{className:"text-gray-400",children:"导师ID"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"金额"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(hs,{children:[t.map(h=>s.jsxs(ct,{className:"border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:h.id}),s.jsx(be,{className:"text-gray-400",children:h.userId}),s.jsx(be,{className:"text-gray-400",children:h.mentorId}),s.jsx(be,{className:"text-gray-400",children:u[h.consultationType]||h.consultationType}),s.jsxs(be,{className:"text-white",children:["¥",h.amount]}),s.jsx(be,{className:"text-gray-400",children:c[h.status]||h.status}),s.jsx(be,{className:"text-gray-500 text-sm",children:h.createdAt})]},h.id)),t.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}const Ed={poolSource:["vip"],requirePhone:!0,requireNickname:!0,requireAvatar:!1,requireBusiness:!1},nj={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:Ed},xV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function yV(){const t=Sa(),[e,n]=b.useState(nj),[r,a]=b.useState(!0),[i,o]=b.useState(!1),[c,u]=b.useState(!1),[h,f]=b.useState(null),[m,g]=b.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),[y,N]=b.useState(null),[w,j]=b.useState(!1),S=async()=>{j(!0);try{const I=await Pe("/api/db/match-pool-counts");I!=null&&I.success&&I.data&&N(I.data)}catch(I){console.error("加载池子人数失败:",I)}finally{j(!1)}},E=async()=>{a(!0);try{const I=await Pe("/api/db/config/full?key=match_config"),te=(I==null?void 0:I.data)??(I==null?void 0:I.config);if(te){let Q=te.poolSettings??Ed;Q.poolSource&&!Array.isArray(Q.poolSource)&&(Q={...Q,poolSource:[Q.poolSource]}),n({...nj,...te,poolSettings:Q})}}catch(I){console.error("加载匹配配置失败:",I)}finally{a(!1)}};b.useEffect(()=>{E(),S()},[]);const T=async()=>{o(!0);try{const I=await Ct("/api/db/config",{key:"match_config",value:e,description:"匹配功能配置"});se.error((I==null?void 0:I.success)!==!1?"配置保存成功!":"保存失败: "+((I==null?void 0:I.error)||"未知错误"))}catch(I){console.error(I),se.error("保存失败")}finally{o(!1)}},P=I=>{f(I),g({...I}),u(!0)},O=()=>{f(null),g({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),u(!0)},q=()=>{if(!m.id||!m.label){se.error("请填写类型ID和名称");return}const I=[...e.matchTypes];if(h){const te=I.findIndex(Q=>Q.id===h.id);te!==-1&&(I[te]={...m})}else{if(I.some(te=>te.id===m.id)){se.error("类型ID已存在");return}I.push({...m})}n({...e,matchTypes:I}),u(!1)},z=I=>{confirm("确定要删除这个匹配类型吗?")&&n({...e,matchTypes:e.matchTypes.filter(te=>te.id!==I)})},V=I=>{n({...e,matchTypes:e.matchTypes.map(te=>te.id===I?{...te,enabled:!te.enabled}:te)})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsxs(X,{variant:"outline",onClick:E,disabled:r,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${r?"animate-spin":""}`})," 刷新"]}),s.jsxs(X,{onClick:T,disabled:i,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"})," ",i?"保存中...":"保存配置"]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(Ej,{className:"w-5 h-5 text-blue-400"})," 匹配池选择"]}),s.jsx(Kt,{className:"text-gray-400",children:"选择匹配的用户池和完善程度要求,只有满足条件的用户才可被匹配到"})]}),s.jsxs(Le,{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx(ee,{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(I=>{const te=e.poolSettings??Ed,F=(Array.isArray(te.poolSource)?te.poolSource:[te.poolSource]).includes(I.value),re=y==null?void 0:y[I.countKey],ae=()=>{const J=Array.isArray(te.poolSource)?[...te.poolSource]:[te.poolSource],$=F?J.filter(D=>D!==I.value):[...J,I.value];$.length===0&&$.push(I.value),n({...e,poolSettings:{...te,poolSource:$}})};return s.jsxs("button",{type:"button",onClick:ae,className:`p-4 rounded-lg border text-left transition-all ${F?"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 ${F?"border-[#38bdac] bg-[#38bdac] text-white":"border-gray-600"}`,children:F&&"✓"}),s.jsx("span",{className:"text-xl",children:I.icon}),s.jsx("span",{className:`text-sm font-medium ${F?"text-[#38bdac]":"text-gray-300"}`,children:I.label})]}),s.jsxs("span",{className:"text-lg font-bold text-white",children:[w?"...":re??"-",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:I.desc}),s.jsx("span",{role:"link",tabIndex:0,onClick:J=>{J.stopPropagation(),t(`/users?pool=${I.value}`)},onKeyDown:J=>{J.key==="Enter"&&(J.stopPropagation(),t(`/users?pool=${I.value}`))},className:"text-[#38bdac] text-xs mt-2 inline-block hover:underline cursor-pointer",children:"查看用户列表 →"})]},I.value)})})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-gray-700/50",children:[s.jsx(ee,{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(I=>{const Q=(e.poolSettings??Ed)[I.key];return s.jsxs("div",{className:"flex items-center gap-3 bg-[#0a1628] rounded-lg p-3",children:[s.jsx($t,{checked:Q,onCheckedChange:F=>n({...e,poolSettings:{...e.poolSettings??Ed,[I.key]:F}})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{children:I.icon}),s.jsx(ee,{className:"text-gray-300 text-sm",children:I.label})]})]},I.key)})})]})]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(pi,{className:"w-5 h-5 text-yellow-400"})," 基础设置"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),s.jsxs(Le,{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(ee,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(de,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.freeMatchLimit,onChange:I=>n({...e,freeMatchLimit:parseInt(I.target.value,10)||0})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(de,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:e.matchPrice,onChange:I=>n({...e,matchPrice:parseFloat(I.target.value)||1})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(de,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.settings.maxMatchesPerDay,onChange:I=>n({...e,settings:{...e.settings,maxMatchesPerDay:parseInt(I.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($t,{checked:e.settings.enableFreeMatches,onCheckedChange:I=>n({...e,settings:{...e.settings,enableFreeMatches:I}})}),s.jsx(ee,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($t,{checked:e.settings.enablePaidMatches,onCheckedChange:I=>n({...e,settings:{...e.settings,enablePaidMatches:I}})}),s.jsx(ee,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(In,{className:"w-5 h-5 text-[#38bdac]"})," 匹配类型管理"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(X,{onClick:O,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(An,{className:"w-4 h-4 mr-1"})," 添加类型"]})]}),s.jsx(Le,{children:s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"图标"}),s.jsx(je,{className:"text-gray-400",children:"类型ID"}),s.jsx(je,{className:"text-gray-400",children:"显示名称"}),s.jsx(je,{className:"text-gray-400",children:"匹配标签"}),s.jsx(je,{className:"text-gray-400",children:"价格"}),s.jsx(je,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(hs,{children:e.matchTypes.map(I=>s.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{children:s.jsx("span",{className:"text-2xl",children:I.icon})}),s.jsx(be,{className:"font-mono text-gray-300",children:I.id}),s.jsx(be,{className:"text-white font-medium",children:I.label}),s.jsx(be,{className:"text-gray-300",children:I.matchLabel}),s.jsx(be,{children:s.jsxs(Ve,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",I.price]})}),s.jsx(be,{children:I.matchFromDB?s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Ve,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(be,{children:s.jsx($t,{checked:I.enabled,onCheckedChange:()=>V(I.id)})}),s.jsx(be,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>P(I),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(Jt,{className:"w-4 h-4"})}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>z(I.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(bs,{className:"w-4 h-4"})})]})})]},I.id))})]})})]}),s.jsx(Dt,{open:c,onOpenChange:u,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[h?s.jsx(Jt,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(An,{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(ee,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:m.id,onChange:I=>g({...m,id:I.target.value}),disabled:!!h})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:xV.map(I=>s.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${m.icon===I?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>g({...m,icon:I}),children:I},I))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"显示名称"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.label,onChange:I=>g({...m,label:I.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"匹配标签"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.matchLabel,onChange:I=>g({...m,matchLabel:I.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(de,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:m.price,onChange:I=>g({...m,price:parseFloat(I.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($t,{checked:m.matchFromDB,onCheckedChange:I=>g({...m,matchFromDB:I})}),s.jsx(ee,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($t,{checked:m.showJoinAfterMatch,onCheckedChange:I=>g({...m,showJoinAfterMatch:I})}),s.jsx(ee,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($t,{checked:m.enabled,onCheckedChange:I=>g({...m,enabled:I})}),s.jsx(ee,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",onClick:()=>u(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(X,{onClick:q,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"})," 保存"]})]})]})})]})}const sj={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function bV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(""),[f,m]=b.useState(!0),[g,y]=b.useState(null),[N,w]=b.useState(null);async function j(){m(!0),y(null);try{const T=new URLSearchParams({page:String(a),pageSize:String(o)});u&&T.set("matchType",u);const P=await Pe(`/api/db/match-records?${T}`);P!=null&&P.success?(e(P.records||[]),r(P.total??0)):y("加载匹配记录失败")}catch{y("加载失败,请检查网络后重试")}finally{m(!1)}}b.useEffect(()=>{j()},[a,u]);const S=Math.ceil(n/o)||1,E=({userId:T,nickname:P,avatar:O})=>s.jsxs("div",{className:"flex items-center gap-3 cursor-pointer group",onClick:()=>w(T),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:[O?s.jsx("img",{src:fo(O),alt:"",className:"w-full h-full object-cover",onError:q=>{q.currentTarget.style.display="none"}}):null,s.jsx("span",{className:O?"hidden":"",children:(P||T||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white group-hover:text-[#38bdac] transition-colors",children:P||T}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[T==null?void 0:T.slice(0,16),(T==null?void 0:T.length)>16?"...":""]})]})]});return s.jsxs("div",{children:[g&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[s.jsx("span",{children:g}),s.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsxs("p",{className:"text-gray-400",children:["共 ",n," 条匹配记录 · 点击用户名查看详情"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("select",{value:u,onChange:T=>{h(T.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(sj).map(([T,P])=>s.jsx("option",{value:T,children:P},T))]}),s.jsxs("button",{type:"button",onClick:j,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(Fe,{className:`w-4 h-4 ${f?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:f?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Fe,{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(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"发起人"}),s.jsx(je,{className:"text-gray-400",children:"匹配到"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"联系方式"}),s.jsx(je,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(hs,{children:[t.map(T=>s.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{children:s.jsx(E,{userId:T.userId,nickname:T.userNickname,avatar:T.userAvatar})}),s.jsx(be,{children:T.matchedUserId?s.jsx(E,{userId:T.matchedUserId,nickname:T.matchedNickname,avatar:T.matchedUserAvatar}):s.jsx("span",{className:"text-gray-500",children:"—"})}),s.jsx(be,{children:s.jsx(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:sj[T.matchType]||T.matchType})}),s.jsxs(be,{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(be,{className:"text-gray-400",children:T.createdAt?new Date(T.createdAt).toLocaleString():"-"})]},T.id)),t.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(Ks,{page:a,totalPages:S,total:n,pageSize:o,onPageChange:i,onPageSizeChange:T=>{c(T),i(1)}})]})})}),s.jsx(I0,{open:!!N,onClose:()=>w(null),userId:N,onUserUpdated:j})]})}function vV(){const[t,e]=b.useState("records");return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>e("records"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="records"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"匹配记录"}),s.jsx("button",{type:"button",onClick:()=>e("pool"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="pool"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"匹配池设置"})]}),t==="records"&&s.jsx(bV,{}),t==="pool"&&s.jsx(yV,{})]})}const rj={investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function NV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(!0),[f,m]=b.useState("investor"),[g,y]=b.useState(null);async function N(){h(!0);try{const E=new URLSearchParams({page:String(a),pageSize:String(o),matchType:f}),T=await Pe(`/api/db/match-records?${E}`);T!=null&&T.success&&(e(T.records||[]),r(T.total??0))}catch(E){console.error(E)}finally{h(!1)}}b.useEffect(()=>{N()},[a,f]);const w=async E=>{if(!E.phone&&!E.wechatId){se.info("该记录无联系方式,无法推送到存客宝");return}y(E.id);try{const T=await Ct("/api/ckb/join",{type:E.matchType||"investor",phone:E.phone||"",wechat:E.wechatId||"",userId:E.userId,name:E.userNickname||""});se.error((T==null?void 0:T.message)||(T!=null&&T.success?"推送成功":"推送失败"))}catch(T){se.error("推送失败: "+(T instanceof Error?T.message:"网络错误"))}finally{y(null)}},j=Math.ceil(n/o)||1,S=E=>!!(E.phone||E.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:E=>{m(E.target.value),i(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:Object.entries(rj).map(([E,T])=>s.jsx("option",{value:E,children:T},E))}),s.jsxs(X,{onClick:N,disabled:u,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${u?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:u?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Fe,{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(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"发起人"}),s.jsx(je,{className:"text-gray-400",children:"匹配到"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"联系方式"}),s.jsx(je,{className:"text-gray-400",children:"时间"}),s.jsx(je,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsxs(hs,{children:[t.map(E=>{var T,P;return s.jsxs(ct,{className:`border-gray-700/50 ${S(E)?"hover:bg-[#0a1628]":"opacity-60"}`,children:[s.jsx(be,{className:"text-white",children:E.userNickname||((T=E.userId)==null?void 0:T.slice(0,12))}),s.jsx(be,{className:"text-white",children:E.matchedNickname||((P=E.matchedUserId)==null?void 0:P.slice(0,12))}),s.jsx(be,{children:s.jsx(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:rj[E.matchType]||E.matchType})}),s.jsxs(be,{className:"text-sm",children:[E.phone&&s.jsxs("div",{className:"text-green-400",children:["📱 ",E.phone]}),E.wechatId&&s.jsxs("div",{className:"text-blue-400",children:["💬 ",E.wechatId]}),!E.phone&&!E.wechatId&&s.jsx("span",{className:"text-gray-600",children:"无联系方式"})]}),s.jsx(be,{className:"text-gray-400 text-sm",children:E.createdAt?new Date(E.createdAt).toLocaleString():"-"}),s.jsx(be,{className:"text-right",children:S(E)?s.jsxs(X,{size:"sm",onClick:()=>w(E),disabled:g===E.id,className:"bg-[#38bdac] hover:bg-[#2da396] text-white text-xs h-7 px-3",children:[s.jsx(KM,{className:"w-3 h-3 mr-1"}),g===E.id?"推送中...":"推送CKB"]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"—"})})]},E.id)}),t.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无记录"})})]})]}),s.jsx(Ks,{page:a,totalPages:j,total:n,pageSize:o,onPageChange:i,onPageSizeChange:E=>{c(E),i(1)}})]})})})]})}const aj={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},wV={single:"单次",half_year:"半年",year:"年度"};function jV(){const[t,e]=b.useState([]),[n,r]=b.useState(!0),[a,i]=b.useState("");async function o(){r(!0);try{const c=a?`/api/db/mentor-consultations?status=${a}`:"/api/db/mentor-consultations",u=await Pe(c);u!=null&&u.success&&u.data&&e(u.data)}catch(c){console.error(c)}finally{r(!1)}}return b.useEffect(()=>{o()},[a]),s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsx("p",{className:"text-gray-400",children:"导师咨询预约记录"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:a,onChange:c=>i(c.target.value),className:"bg-[#0f2137] border border-gray-700 rounded-lg px-3 py-2 text-gray-300 text-sm",children:[s.jsx("option",{value:"",children:"全部状态"}),Object.entries(aj).map(([c,u])=>s.jsx("option",{value:c,children:u},c))]}),s.jsxs(X,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Le,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"ID"}),s.jsx(je,{className:"text-gray-400",children:"用户ID"}),s.jsx(je,{className:"text-gray-400",children:"导师ID"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"金额"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(hs,{children:[t.map(c=>s.jsxs(ct,{className:"border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:c.id}),s.jsx(be,{className:"text-gray-400",children:c.userId}),s.jsx(be,{className:"text-gray-400",children:c.mentorId}),s.jsx(be,{className:"text-gray-400",children:wV[c.consultationType]||c.consultationType}),s.jsxs(be,{className:"text-white",children:["¥",c.amount]}),s.jsx(be,{className:"text-gray-400",children:aj[c.status]||c.status}),s.jsx(be,{className:"text-gray-500 text-sm",children:c.createdAt?new Date(c.createdAt).toLocaleString():"-"})]},c.id)),t.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}function kV(){const[t,e]=b.useState("booking");return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>e("booking"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="booking"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"预约记录"}),s.jsx("button",{type:"button",onClick:()=>e("manage"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="manage"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"导师管理"})]}),t==="booking"&&s.jsx(jV,{}),t==="manage"&&s.jsx("div",{className:"-mx-8",children:s.jsx(g4,{embedded:!0})})]})}function SV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(!0);async function f(){h(!0);try{const g=new URLSearchParams({page:String(a),pageSize:String(o),matchType:"team"}),y=await Pe(`/api/db/match-records?${g}`);y!=null&&y.success&&(e(y.records||[]),r(y.total??0))}catch(g){console.error(g)}finally{h(!1)}}b.useEffect(()=>{f()},[a]);const m=Math.ceil(n/o)||1;return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-gray-400",children:["团队招募匹配记录,共 ",n," 条"]}),s.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"用户通过「团队招募」提交联系方式到存客宝"})]}),s.jsxs("button",{type:"button",onClick:f,disabled:u,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700/50 transition-colors disabled:opacity-50",children:[s.jsx(Fe,{className:`w-4 h-4 ${u?"animate-spin":""}`})," 刷新"]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:u?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Fe,{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(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"发起人"}),s.jsx(je,{className:"text-gray-400",children:"匹配到"}),s.jsx(je,{className:"text-gray-400",children:"联系方式"}),s.jsx(je,{className:"text-gray-400",children:"时间"})]})}),s.jsxs(hs,{children:[t.map(g=>s.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{className:"text-white",children:g.userNickname||g.userId}),s.jsx(be,{className:"text-white",children:g.matchedNickname||g.matchedUserId}),s.jsxs(be,{className:"text-gray-400 text-sm",children:[g.phone&&s.jsxs("div",{children:["📱 ",g.phone]}),g.wechatId&&s.jsxs("div",{children:["💬 ",g.wechatId]}),!g.phone&&!g.wechatId&&"-"]}),s.jsx(be,{className:"text-gray-400",children:g.createdAt?new Date(g.createdAt).toLocaleString():"-"})]},g.id)),t.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:4,className:"text-center py-12 text-gray-500",children:"暂无团队招募记录"})})]})]}),s.jsx(Ks,{page:a,totalPages:m,total:n,pageSize:o,onPageChange:i,onPageSizeChange:g=>{c(g),i(1)}})]})})})]})}const ij={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募",join:"加入",match:"匹配"},oj={partner:"⭐",investor:"👥",mentor:"❤️",team:"🎮",join:"📋",match:"🔗"};function CV({onSwitchTab:t,onOpenCKB:e}={}){const n=Sa(),[r,a]=b.useState(null),[i,o]=b.useState(null),[c,u]=b.useState(!0),h=b.useCallback(async()=>{var g,y;u(!0);try{const[N,w]=await Promise.allSettled([Pe("/api/db/match-records?stats=true"),Pe("/api/db/ckb-plan-stats")]);if(N.status==="fulfilled"&&((g=N.value)!=null&&g.success)&&N.value.data){let j=N.value.data;if(j.totalMatches>0&&(!j.uniqueUsers||j.uniqueUsers===0))try{const S=await Pe("/api/db/match-records?page=1&pageSize=200");if(S!=null&&S.success&&S.records){const E=new Set(S.records.map(T=>T.userId).filter(Boolean));j={...j,uniqueUsers:E.size}}}catch{}a(j)}w.status==="fulfilled"&&((y=w.value)!=null&&y.success)&&w.value.data&&o(w.value.data)}catch(N){console.error("加载统计失败:",N)}finally{u(!1)}},[]);b.useEffect(()=>{h()},[h]);const f=g=>c?"—":String(g??0),m=r!=null&&r.uniqueUsers?(r.totalMatches/r.uniqueUsers).toFixed(1):"0";return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-5 gap-3",children:[s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40 cursor-pointer hover:border-[#38bdac]/60 transition-all",onClick:()=>t==null?void 0:t("partner"),children:s.jsxs(Le,{className:"p-4",children:[s.jsx("p",{className:"text-gray-400 text-xs",children:"总匹配"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:f(r==null?void 0:r.totalMatches)}),s.jsxs("p",{className:"text-[#38bdac] text-[10px] mt-1 flex items-center gap-0.5",children:[s.jsx(fi,{className:"w-2.5 h-2.5"})," 查看记录"]})]})}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40",children:s.jsxs(Le,{className:"p-4",children:[s.jsx("p",{className:"text-gray-400 text-xs",children:"今日"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:f(r==null?void 0:r.todayMatches)}),s.jsxs("p",{className:"text-yellow-400/60 text-[10px] mt-1 flex items-center gap-0.5",children:[s.jsx(pi,{className:"w-2.5 h-2.5"})," 实时"]})]})}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40 cursor-pointer hover:border-blue-500/60 transition-all",onClick:()=>n("/users"),children:s.jsxs(Le,{className:"p-4",children:[s.jsx("p",{className:"text-gray-400 text-xs",children:"用户数"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:f(r==null?void 0:r.uniqueUsers)}),s.jsxs("p",{className:"text-blue-400/60 text-[10px] mt-1 flex items-center gap-0.5",children:[s.jsx(In,{className:"w-2.5 h-2.5"})," 查看用户"]})]})}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40",children:s.jsxs(Le,{className:"p-4",children:[s.jsx("p",{className:"text-gray-400 text-xs",children:"人均匹配"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:c?"—":m})]})}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40",children:s.jsxs(Le,{className:"p-4",children:[s.jsx("p",{className:"text-gray-400 text-xs",children:"付费匹配"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:f(r==null?void 0:r.paidMatchCount)})]})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40",children:s.jsxs(Le,{className:"p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"匹配类型分布"}),r!=null&&r.byType&&r.byType.length>0?s.jsx("div",{className:"space-y-2",children:r.byType.map(g=>{const y=r.totalMatches>0?g.count/r.totalMatches*100:0;return s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-lg shrink-0",children:oj[g.matchType]||"📊"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex justify-between text-xs mb-0.5",children:[s.jsx("span",{className:"text-gray-300",children:ij[g.matchType]||g.matchType}),s.jsxs("span",{className:"text-gray-500",children:[g.count," (",y.toFixed(0),"%)"]})]}),s.jsx("div",{className:"w-full h-1.5 bg-gray-700/50 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac] rounded-full",style:{width:`${Math.min(y,100)}%`}})})]})]},g.matchType)})}):s.jsx("p",{className:"text-gray-500 text-xs",children:"暂无数据"})]})}),s.jsx(Oe,{className:"bg-[#0f2137] border-orange-500/20",children:s.jsxs(Le,{className:"p-4",children:[s.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-1.5",children:[s.jsx(ya,{className:"w-4 h-4 text-orange-400"})," AI 获客"]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 cursor-pointer hover:border-orange-500/50 border border-transparent transition-colors",onClick:()=>e==null?void 0:e("submitted"),children:[s.jsx("p",{className:"text-gray-400 text-xs",children:"已提交线索"}),s.jsx("p",{className:"text-xl font-bold text-white",children:c?"—":(i==null?void 0:i.ckbTotal)??0})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 cursor-pointer hover:border-orange-500/50 border border-transparent transition-colors",onClick:()=>e==null?void 0:e("contact"),children:[s.jsx("p",{className:"text-gray-400 text-xs",children:"有联系方式"}),s.jsx("p",{className:"text-xl font-bold text-white",children:c?"—":(i==null?void 0:i.withContact)??0})]})]}),(i==null?void 0:i.byType)&&i.byType.length>0&&s.jsx("div",{className:"space-y-1.5",children:i.byType.map(g=>s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{children:oj[g.matchType]||"📋"}),s.jsx("span",{className:"text-gray-400",children:ij[g.matchType]||g.matchType}),s.jsx("span",{className:"ml-auto text-white font-medium",children:g.total})]},g.matchType))}),s.jsx("button",{type:"button",onClick:()=>e==null?void 0:e("test"),className:"mt-3 w-full text-xs text-orange-400 hover:text-orange-300 text-center py-1.5 bg-orange-500/10 rounded",children:"查看 AI 添加进度 →"})]})})]})]})}const TV=["partner","investor","mentor","team"],Zg=[{key:"join_partner",label:"找伙伴场景"},{key:"join_investor",label:"资源对接场景"},{key:"join_mentor",label:"导师顾问场景"},{key:"join_team",label:"团队招募场景"},{key:"match",label:"匹配上报"},{key:"lead",label:"链接卡若"}],lj=`# 场景获客接口摘要 +`).map(w=>w.trim()).filter(Boolean),N=[...o.liveQRCodes||[]];N[0]?N[0].urls=y:N.push({id:"live-1",name:"微信群活码",urls:y,clickCount:0}),await Ct("/api/db/config",{key:"live_qr_codes",value:N,description:"群活码配置"}),se.success("群活码配置已保存!"),await u()}catch(y){console.error(y),se.error("保存失败: "+(y instanceof Error?y.message:String(y)))}},m=async()=>{var y;try{await Ct("/api/db/config",{key:"payment_methods",value:{...o.paymentMethods||{},wechat:{...((y=o.paymentMethods)==null?void 0:y.wechat)||{},groupQrCode:n}},description:"支付方式配置"}),se.success("微信群链接已保存!用户支付成功后将自动跳转"),await u()}catch(N){console.error(N),se.error("保存失败: "+(N instanceof Error?N.message:String(N)))}},x=()=>{n?window.open(n,"_blank"):se.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(kj,{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(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(u1,{className:"w-5 h-5"}),"支付成功跳转链接(核心配置)"]}),s.jsx(Kt,{className:"text-gray-400",children:"用户支付完成后自动跳转到此链接,进入指定微信群"})]}),s.jsxs(Le,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ee,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(dg,{className:"w-4 h-4"}),"微信群链接 / 活码链接"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ce,{placeholder:"https://cli.im/xxxxx 或 https://weixin.qq.com/g/...",className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",value:n,onChange:y=>r(y.target.value)}),s.jsx(X,{variant:"outline",size:"icon",className:"border-gray-700 bg-transparent hover:bg-gray-700/50",onClick:()=>h(n,"group"),children:a==="group"?s.jsx(Zf,{className:"w-4 h-4 text-green-500"}):s.jsx(Cj,{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(fi,{className:"w-3 h-3"}),"支持格式:草料短链、微信群链接(https://weixin.qq.com/g/...)、企业微信链接等"]})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(X,{onClick:m,className:"flex-1 bg-[#07C160] hover:bg-[#06AD51] text-white",children:[s.jsx(Jh,{className:"w-4 h-4 mr-2"}),"保存配置"]}),s.jsxs(X,{onClick:x,variant:"outline",className:"border-[#07C160] text-[#07C160] hover:bg-[#07C160]/10 bg-transparent",children:[s.jsx(fi,{className:"w-4 h-4 mr-2"}),"测试跳转"]})]})]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(u1,{className:"w-5 h-5 text-[#38bdac]"}),"多群轮换(高级配置)"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置多个群链接,系统自动轮换分配,避免单群满员"})]}),s.jsxs(Le,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ee,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(dg,{className:"w-4 h-4"}),"多个群链接(每行一个)"]}),s.jsx(hl,{placeholder:"https://cli.im/group1\\nhttps://cli.im/group2",className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 min-h-[120px] font-mono text-sm",value:t,onChange:y=>e(y.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"每行填写一个群链接,系统将按顺序或随机分配"})]}),s.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[s.jsx("span",{className:"text-sm text-gray-400",children:"已配置群数量"}),s.jsxs("span",{className:"font-bold text-[#38bdac]",children:[t.split(` +`).filter(Boolean).length," 个"]})]}),s.jsxs(X,{onClick:f,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Jh,{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 ej={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}},hV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function fV(){const[t,e]=b.useState(ej),[n,r]=b.useState(!0),[a,i]=b.useState(!1),[o,c]=b.useState(!1),[u,h]=b.useState(null),[f,m]=b.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),x=async()=>{r(!0);try{const T=await Pe("/api/db/config/full?key=match_config"),P=(T==null?void 0:T.data)??(T==null?void 0:T.config);P&&e({...ej,...P})}catch(T){console.error("加载匹配配置失败:",T)}finally{r(!1)}};b.useEffect(()=>{x()},[]);const y=async()=>{i(!0);try{const T=await Ct("/api/db/config",{key:"match_config",value:t,description:"匹配功能配置"});T&&T.success!==!1?se.success("配置保存成功!"):se.error("保存失败: "+(T&&typeof T=="object"&&"error"in T?T.error:"未知错误"))}catch(T){console.error("保存配置失败:",T),se.error("保存失败")}finally{i(!1)}},N=T=>{h(T),m({id:T.id,label:T.label,matchLabel:T.matchLabel,icon:T.icon,matchFromDB:T.matchFromDB,showJoinAfterMatch:T.showJoinAfterMatch,price:T.price,enabled:T.enabled}),c(!0)},w=()=>{h(null),m({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),c(!0)},j=()=>{if(!f.id||!f.label){se.error("请填写类型ID和名称");return}const T=[...t.matchTypes];if(u){const P=T.findIndex(O=>O.id===u.id);P!==-1&&(T[P]={...f})}else{if(T.some(P=>P.id===f.id)){se.error("类型ID已存在");return}T.push({...f})}e({...t,matchTypes:T}),c(!1)},S=T=>{confirm("确定要删除这个匹配类型吗?")&&e({...t,matchTypes:t.matchTypes.filter(P=>P.id!==T)})},E=T=>{e({...t,matchTypes:t.matchTypes.map(P=>P.id===T?{...P,enabled:!P.enabled}:P)})};return s.jsxs("div",{className:"p-8 w-full space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(no,{className:"w-6 h-6 text-[#38bdac]"}),"匹配功能配置"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"管理找伙伴功能的匹配类型和价格"})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(X,{variant:"outline",onClick:x,disabled:n,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]}),s.jsxs(X,{onClick:y,disabled:a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存配置"]})]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(pi,{className:"w-5 h-5 text-yellow-400"}),"基础设置"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),s.jsxs(Le,{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(ee,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.freeMatchLimit,onChange:T=>e({...t,freeMatchLimit:parseInt(T.target.value,10)||0})}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户每天可免费匹配的次数"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(ce,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:t.matchPrice,onChange:T=>e({...t,matchPrice:parseFloat(T.target.value)||1})}),s.jsx("p",{className:"text-xs text-gray-500",children:"免费次数用完后的单次匹配价格"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(ce,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.settings.maxMatchesPerDay,onChange:T=>e({...t,settings:{...t.settings,maxMatchesPerDay:parseInt(T.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($t,{checked:t.settings.enableFreeMatches,onCheckedChange:T=>e({...t,settings:{...t.settings,enableFreeMatches:T}})}),s.jsx(ee,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($t,{checked:t.settings.enablePaidMatches,onCheckedChange:T=>e({...t,settings:{...t.settings,enablePaidMatches:T}})}),s.jsx(ee,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(In,{className:"w-5 h-5 text-[#38bdac]"}),"匹配类型管理"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(X,{onClick:w,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(An,{className:"w-4 h-4 mr-1"}),"添加类型"]})]}),s.jsx(Le,{children:s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"图标"}),s.jsx(je,{className:"text-gray-400",children:"类型ID"}),s.jsx(je,{className:"text-gray-400",children:"显示名称"}),s.jsx(je,{className:"text-gray-400",children:"匹配标签"}),s.jsx(je,{className:"text-gray-400",children:"价格"}),s.jsx(je,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(hs,{children:t.matchTypes.map(T=>s.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{children:s.jsx("span",{className:"text-2xl",children:T.icon})}),s.jsx(be,{className:"font-mono text-gray-300",children:T.id}),s.jsx(be,{className:"text-white font-medium",children:T.label}),s.jsx(be,{className:"text-gray-300",children:T.matchLabel}),s.jsx(be,{children:s.jsxs(Ve,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",T.price]})}),s.jsx(be,{children:T.matchFromDB?s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Ve,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(be,{children:s.jsx($t,{checked:T.enabled,onCheckedChange:()=>E(T.id)})}),s.jsx(be,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>N(T),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(Jt,{className:"w-4 h-4"})}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>S(T.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(bs,{className:"w-4 h-4"})})]})})]},T.id))})]})})]}),s.jsx(Dt,{open:o,onOpenChange:c,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[u?s.jsx(Jt,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(An,{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(ee,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:f.id,onChange:T=>m({...f,id:T.target.value}),disabled:!!u})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:hV.map(T=>s.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${f.icon===T?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>m({...f,icon:T}),children:T},T))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"显示名称"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业合伙",value:f.label,onChange:T=>m({...f,label:T.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"匹配标签"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业伙伴",value:f.matchLabel,onChange:T=>m({...f,matchLabel:T.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(ce,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:f.price,onChange:T=>m({...f,price:parseFloat(T.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($t,{checked:f.matchFromDB,onCheckedChange:T=>m({...f,matchFromDB:T})}),s.jsx(ee,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($t,{checked:f.showJoinAfterMatch,onCheckedChange:T=>m({...f,showJoinAfterMatch:T})}),s.jsx(ee,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($t,{checked:f.enabled,onCheckedChange:T=>m({...f,enabled:T})}),s.jsx(ee,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(X,{onClick:j,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),"保存"]})]})]})})]})}const tj={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function pV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(""),[f,m]=b.useState(!0),[x,y]=b.useState(null);async function N(){m(!0),y(null);try{const j=new URLSearchParams({page:String(a),pageSize:String(o)});u&&j.set("matchType",u);const S=await Pe(`/api/db/match-records?${j}`);S!=null&&S.success?(e(S.records||[]),r(S.total??0)):y("加载匹配记录失败")}catch(j){console.error("加载匹配记录失败",j),y("加载失败,请检查网络后重试")}finally{m(!1)}}b.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:()=>y(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"匹配记录"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["找伙伴匹配统计,共 ",n," 条记录"]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("select",{value:u,onChange:j=>{h(j.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(tj).map(([j,S])=>s.jsx("option",{value:j,children:S},j))]}),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(Fe,{className:`w-4 h-4 ${f?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:f?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Fe,{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(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"发起人"}),s.jsx(je,{className:"text-gray-400",children:"匹配到"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"联系方式"}),s.jsx(je,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(hs,{children:[t.map(j=>s.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 overflow-hidden",children:[j.userAvatar?s.jsx("img",{src:fo(j.userAvatar),alt:"",className:"w-full h-full object-cover",onError:S=>{S.currentTarget.style.display="none";const E=S.currentTarget.nextElementSibling;E&&E.classList.remove("hidden")}}):null,s.jsx("span",{className:j.userAvatar?"hidden":"",children:(j.userNickname||j.userId||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white",children:j.userNickname||j.userId}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[j.userId.slice(0,16),"..."]})]})]})}),s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 overflow-hidden",children:[j.matchedUserAvatar?s.jsx("img",{src:fo(j.matchedUserAvatar),alt:"",className:"w-full h-full object-cover",onError:S=>{S.currentTarget.style.display="none";const E=S.currentTarget.nextElementSibling;E&&E.classList.remove("hidden")}}):null,s.jsx("span",{className:j.matchedUserAvatar?"hidden":"",children:(j.matchedNickname||j.matchedUserId||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white",children:j.matchedNickname||j.matchedUserId}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[j.matchedUserId.slice(0,16),"..."]})]})]})}),s.jsx(be,{children:s.jsx(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:tj[j.matchType]||j.matchType})}),s.jsxs(be,{className:"text-gray-400 text-sm",children:[j.phone&&s.jsxs("div",{children:["📱 ",j.phone]}),j.wechatId&&s.jsxs("div",{children:["💬 ",j.wechatId]}),!j.phone&&!j.wechatId&&"-"]}),s.jsx(be,{className:"text-gray-400",children:j.createdAt?new Date(j.createdAt).toLocaleString():"-"})]},j.id)),t.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(qs,{page:a,totalPages:w,total:n,pageSize:o,onPageChange:i,onPageSizeChange:j=>{c(j),i(1)}})]})})})]})}function mV(){const[t,e]=b.useState([]),[n,r]=b.useState(!0);async function a(){r(!0);try{const i=await Pe("/api/db/vip-members?limit=100");if(i!=null&&i.success&&i.data){const o=[...i.data].map((c,u)=>({...c,vipSort:typeof c.vipSort=="number"?c.vipSort:u+1}));o.sort((c,u)=>(c.vipSort??999999)-(u.vipSort??999999)),e(o)}}catch(i){console.error("Load VIP members error:",i),se.error("加载 VIP 成员失败")}finally{r(!1)}}return b.useEffect(()=>{a()},[]),s.jsxs("div",{className:"p-8 w-full",children:[s.jsx("div",{className:"flex justify-between items-center mb-8",children:s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(pc,{className:"w-5 h-5 text-amber-400"}),"用户管理 / 超级个体列表"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"这里展示所有有效超级个体用户,仅用于查看其基本信息与排序值。"})]})}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Le,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400 w-20",children:"序号"}),s.jsx(je,{className:"text-gray-400",children:"成员"}),s.jsx(je,{className:"text-gray-400 w-40",children:"超级个体"}),s.jsx(je,{className:"text-gray-400 w-28",children:"排序值"})]})}),s.jsxs(hs,{children:[t.map((i,o)=>{var c;return s.jsxs(ct,{className:"border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:o+1}),s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[i.avatar?s.jsx("img",{src:fo(i.avatar),className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",children:((c=i.name)==null?void 0:c[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:i.name})})]})}),s.jsx(be,{className:"text-gray-300",children:i.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置超级个体)"})}),s.jsx(be,{className:"text-gray-300",children:i.vipSort??o+1})]},i.id)}),t.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:5,className:"text-center py-12 text-gray-500",children:"当前没有有效的超级个体用户。"})})]})]})})})]})}function x4(t){const e=Sa(),[n,r]=b.useState([]),[a,i]=b.useState(!0),[o,c]=b.useState(!1),[u,h]=b.useState(null),[f,m]=b.useState({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:0,enabled:!0}),[x,y]=b.useState(!1),[N,w]=b.useState(!1),j=b.useRef(null),S=async I=>{var Q;const te=(Q=I.target.files)==null?void 0:Q[0];if(te){w(!0);try{const F=new FormData;F.append("file",te),F.append("folder","mentors");const re=iu(),ie={};re&&(ie.Authorization=`Bearer ${re}`);const $=await(await fetch(wc("/api/upload"),{method:"POST",body:F,credentials:"include",headers:ie})).json();$!=null&&$.success&&($!=null&&$.url)?m(D=>({...D,avatar:$.url})):se.error("上传失败: "+(($==null?void 0:$.error)||"未知错误"))}catch(F){console.error(F),se.error("上传失败")}finally{w(!1),j.current&&(j.current.value="")}}};async function E(){i(!0);try{const I=await Pe("/api/db/mentors");I!=null&&I.success&&I.data&&r(I.data)}catch(I){console.error("Load mentors error:",I)}finally{i(!1)}}b.useEffect(()=>{E()},[]);const T=()=>{m({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:n.length>0?Math.max(...n.map(I=>I.sort))+1:0,enabled:!0})},P=()=>{h(null),T(),c(!0)},O=I=>{h(I),m({name:I.name,avatar:I.avatar||"",intro:I.intro||"",tags:I.tags||"",priceSingle:I.priceSingle!=null?String(I.priceSingle):"",priceHalfYear:I.priceHalfYear!=null?String(I.priceHalfYear):"",priceYear:I.priceYear!=null?String(I.priceYear):"",quote:I.quote||"",whyFind:I.whyFind||"",offering:I.offering||"",judgmentStyle:I.judgmentStyle||"",sort:I.sort,enabled:I.enabled??!0}),c(!0)},q=async()=>{if(!f.name.trim()){se.error("导师姓名不能为空");return}y(!0);try{const I=Q=>Q===""?void 0:parseFloat(Q),te={name:f.name.trim(),avatar:f.avatar.trim()||void 0,intro:f.intro.trim()||void 0,tags:f.tags.trim()||void 0,priceSingle:I(f.priceSingle),priceHalfYear:I(f.priceHalfYear),priceYear:I(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 Q=await Gt("/api/db/mentors",{id:u.id,...te});Q!=null&&Q.success?(c(!1),E()):se.error("更新失败: "+(Q==null?void 0:Q.error))}else{const Q=await Ct("/api/db/mentors",te);Q!=null&&Q.success?(c(!1),E()):se.error("新增失败: "+(Q==null?void 0:Q.error))}}catch(I){console.error("Save error:",I),se.error("保存失败")}finally{y(!1)}},z=async I=>{if(confirm("确定删除该导师?"))try{const te=await li(`/api/db/mentors?id=${I}`);te!=null&&te.success?E():se.error("删除失败: "+(te==null?void 0:te.error))}catch(te){console.error("Delete error:",te),se.error("删除失败")}},V=I=>I!=null?`¥${I}`:"-";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(In,{className:"w-5 h-5 text-[#38bdac]"}),"导师管理"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师列表,支持每个导师独立配置单次/半年/年度价格"})]}),s.jsxs(X,{onClick:P,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(An,{className:"w-4 h-4 mr-2"}),"新增导师"]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Le,{className:"p-0",children:a?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"ID"}),s.jsx(je,{className:"text-gray-400",children:"姓名"}),s.jsx(je,{className:"text-gray-400",children:"简介"}),s.jsx(je,{className:"text-gray-400",children:"单次"}),s.jsx(je,{className:"text-gray-400",children:"半年"}),s.jsx(je,{className:"text-gray-400",children:"年度"}),s.jsx(je,{className:"text-gray-400",children:"排序"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(hs,{children:[n.map(I=>s.jsxs(ct,{className:"border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:I.id}),s.jsx(be,{children:s.jsxs("button",{type:"button",onClick:()=>e(`/users?search=${encodeURIComponent(I.name)}`),className:"text-[#38bdac] hover:text-[#2da396] hover:underline flex items-center gap-1",title:"在用户管理中查看",children:[I.name,s.jsx(fi,{className:"w-3 h-3"})]})}),s.jsx(be,{className:"text-gray-400 max-w-[200px] truncate",children:I.intro||"-"}),s.jsx(be,{className:"text-gray-400",children:V(I.priceSingle)}),s.jsx(be,{className:"text-gray-400",children:V(I.priceHalfYear)}),s.jsx(be,{className:"text-gray-400",children:V(I.priceYear)}),s.jsx(be,{className:"text-gray-400",children:I.sort}),s.jsxs(be,{className:"text-right",children:[s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>O(I),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(Jt,{className:"w-4 h-4"})}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>z(I.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(bs,{className:"w-4 h-4"})})]})]},I.id)),n.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无导师,点击「新增导师」添加"})})]})]})})}),s.jsx(Dt,{open:o,onOpenChange:c,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg max-h-[90vh] overflow-y-auto",children:[s.jsx(_t,{children:s.jsx(zt,{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(ee,{className:"text-gray-300",children:"姓名 *"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:卡若",value:f.name,onChange:I=>m(te=>({...te,name:I.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"排序"}),s.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:f.sort,onChange:I=>m(te=>({...te,sort:parseInt(I.target.value,10)||0}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"头像"}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(ce,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:f.avatar,onChange:I=>m(te=>({...te,avatar:I.target.value})),placeholder:"点击上传或粘贴图片地址"}),s.jsx("input",{ref:j,type:"file",accept:"image/*",className:"hidden",onChange:S}),s.jsxs(X,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:N,onClick:()=>{var I;return(I=j.current)==null?void 0:I.click()},children:[s.jsx(Jh,{className:"w-4 h-4 mr-2"}),N?"上传中...":"上传"]})]}),f.avatar&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:fo(f.avatar.startsWith("http")?f.avatar:wc(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(ee,{className:"text-gray-300",children:"简介"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:结构判断型咨询 · Decision > Execution",value:f.intro,onChange:I=>m(te=>({...te,intro:I.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"技能标签(逗号分隔)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:项目结构判断、风险止损、人×项目匹配",value:f.tags,onChange:I=>m(te=>({...te,tags:I.target.value}))})]}),s.jsxs("div",{className:"border-t border-gray-700 pt-4",children:[s.jsx(ee,{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(ee,{className:"text-gray-500 text-xs",children:"单次咨询 ¥"}),s.jsx(ce,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"980",value:f.priceSingle,onChange:I=>m(te=>({...te,priceSingle:I.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-500 text-xs",children:"半年咨询 ¥"}),s.jsx(ce,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"19800",value:f.priceHalfYear,onChange:I=>m(te=>({...te,priceHalfYear:I.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-500 text-xs",children:"年度咨询 ¥"}),s.jsx(ce,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"29800",value:f.priceYear,onChange:I=>m(te=>({...te,priceYear:I.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"引言"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:大多数人失败,不是因为不努力...",value:f.quote,onChange:I=>m(te=>({...te,quote:I.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"为什么找(文本)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:f.whyFind,onChange:I=>m(te=>({...te,whyFind:I.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"提供什么(文本)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:f.offering,onChange:I=>m(te=>({...te,offering:I.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"判断风格(逗号分隔)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:冷静、克制、偏风险视角",value:f.judgmentStyle,onChange:I=>m(te=>({...te,judgmentStyle:I.target.value}))})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"enabled",checked:f.enabled,onChange:I=>m(te=>({...te,enabled:I.target.checked})),className:"rounded border-gray-600 bg-[#0a1628]"}),s.jsx(ee,{htmlFor:"enabled",className:"text-gray-300 cursor-pointer",children:"上架(小程序可见)"})]})]}),s.jsxs(fn,{children:[s.jsxs(X,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(Yn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(X,{onClick:q,disabled:x,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"}),x?"保存中...":"保存"]})]})]})})]})}function xV(){const[t,e]=b.useState([]),[n,r]=b.useState(!0),[a,i]=b.useState("");async function o(){r(!0);try{const h=a?`/api/db/mentor-consultations?status=${a}`:"/api/db/mentor-consultations",f=await Pe(h);f!=null&&f.success&&f.data&&e(f.data)}catch(h){console.error("Load consultations error:",h)}finally{r(!1)}}b.useEffect(()=>{o()},[a]);const c={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},u={single:"单次",half_year:"半年",year:"年度"};return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(rg,{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(X,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Le,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"ID"}),s.jsx(je,{className:"text-gray-400",children:"用户ID"}),s.jsx(je,{className:"text-gray-400",children:"导师ID"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"金额"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(hs,{children:[t.map(h=>s.jsxs(ct,{className:"border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:h.id}),s.jsx(be,{className:"text-gray-400",children:h.userId}),s.jsx(be,{className:"text-gray-400",children:h.mentorId}),s.jsx(be,{className:"text-gray-400",children:u[h.consultationType]||h.consultationType}),s.jsxs(be,{className:"text-white",children:["¥",h.amount]}),s.jsx(be,{className:"text-gray-400",children:c[h.status]||h.status}),s.jsx(be,{className:"text-gray-500 text-sm",children:h.createdAt})]},h.id)),t.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}const Ed={poolSource:["vip"],requirePhone:!0,requireNickname:!0,requireAvatar:!1,requireBusiness:!1},nj={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:Ed},gV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function yV(){const t=Sa(),[e,n]=b.useState(nj),[r,a]=b.useState(!0),[i,o]=b.useState(!1),[c,u]=b.useState(!1),[h,f]=b.useState(null),[m,x]=b.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),[y,N]=b.useState(null),[w,j]=b.useState(!1),S=async()=>{j(!0);try{const I=await Pe("/api/db/match-pool-counts");I!=null&&I.success&&I.data&&N(I.data)}catch(I){console.error("加载池子人数失败:",I)}finally{j(!1)}},E=async()=>{a(!0);try{const I=await Pe("/api/db/config/full?key=match_config"),te=(I==null?void 0:I.data)??(I==null?void 0:I.config);if(te){let Q=te.poolSettings??Ed;Q.poolSource&&!Array.isArray(Q.poolSource)&&(Q={...Q,poolSource:[Q.poolSource]}),n({...nj,...te,poolSettings:Q})}}catch(I){console.error("加载匹配配置失败:",I)}finally{a(!1)}};b.useEffect(()=>{E(),S()},[]);const T=async()=>{o(!0);try{const I=await Ct("/api/db/config",{key:"match_config",value:e,description:"匹配功能配置"});se.error((I==null?void 0:I.success)!==!1?"配置保存成功!":"保存失败: "+((I==null?void 0:I.error)||"未知错误"))}catch(I){console.error(I),se.error("保存失败")}finally{o(!1)}},P=I=>{f(I),x({...I}),u(!0)},O=()=>{f(null),x({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),u(!0)},q=()=>{if(!m.id||!m.label){se.error("请填写类型ID和名称");return}const I=[...e.matchTypes];if(h){const te=I.findIndex(Q=>Q.id===h.id);te!==-1&&(I[te]={...m})}else{if(I.some(te=>te.id===m.id)){se.error("类型ID已存在");return}I.push({...m})}n({...e,matchTypes:I}),u(!1)},z=I=>{confirm("确定要删除这个匹配类型吗?")&&n({...e,matchTypes:e.matchTypes.filter(te=>te.id!==I)})},V=I=>{n({...e,matchTypes:e.matchTypes.map(te=>te.id===I?{...te,enabled:!te.enabled}:te)})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsxs(X,{variant:"outline",onClick:E,disabled:r,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${r?"animate-spin":""}`})," 刷新"]}),s.jsxs(X,{onClick:T,disabled:i,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"})," ",i?"保存中...":"保存配置"]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(Ej,{className:"w-5 h-5 text-blue-400"})," 匹配池选择"]}),s.jsx(Kt,{className:"text-gray-400",children:"选择匹配的用户池和完善程度要求,只有满足条件的用户才可被匹配到"})]}),s.jsxs(Le,{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx(ee,{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(I=>{const te=e.poolSettings??Ed,F=(Array.isArray(te.poolSource)?te.poolSource:[te.poolSource]).includes(I.value),re=y==null?void 0:y[I.countKey],ie=()=>{const J=Array.isArray(te.poolSource)?[...te.poolSource]:[te.poolSource],$=F?J.filter(D=>D!==I.value):[...J,I.value];$.length===0&&$.push(I.value),n({...e,poolSettings:{...te,poolSource:$}})};return s.jsxs("button",{type:"button",onClick:ie,className:`p-4 rounded-lg border text-left transition-all ${F?"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 ${F?"border-[#38bdac] bg-[#38bdac] text-white":"border-gray-600"}`,children:F&&"✓"}),s.jsx("span",{className:"text-xl",children:I.icon}),s.jsx("span",{className:`text-sm font-medium ${F?"text-[#38bdac]":"text-gray-300"}`,children:I.label})]}),s.jsxs("span",{className:"text-lg font-bold text-white",children:[w?"...":re??"-",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:I.desc}),s.jsx("span",{role:"link",tabIndex:0,onClick:J=>{J.stopPropagation(),t(`/users?pool=${I.value}`)},onKeyDown:J=>{J.key==="Enter"&&(J.stopPropagation(),t(`/users?pool=${I.value}`))},className:"text-[#38bdac] text-xs mt-2 inline-block hover:underline cursor-pointer",children:"查看用户列表 →"})]},I.value)})})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-gray-700/50",children:[s.jsx(ee,{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(I=>{const Q=(e.poolSettings??Ed)[I.key];return s.jsxs("div",{className:"flex items-center gap-3 bg-[#0a1628] rounded-lg p-3",children:[s.jsx($t,{checked:Q,onCheckedChange:F=>n({...e,poolSettings:{...e.poolSettings??Ed,[I.key]:F}})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{children:I.icon}),s.jsx(ee,{className:"text-gray-300 text-sm",children:I.label})]})]},I.key)})})]})]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(rt,{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(pi,{className:"w-5 h-5 text-yellow-400"})," 基础设置"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),s.jsxs(Le,{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(ee,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.freeMatchLimit,onChange:I=>n({...e,freeMatchLimit:parseInt(I.target.value,10)||0})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(ce,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:e.matchPrice,onChange:I=>n({...e,matchPrice:parseFloat(I.target.value)||1})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(ce,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.settings.maxMatchesPerDay,onChange:I=>n({...e,settings:{...e.settings,maxMatchesPerDay:parseInt(I.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($t,{checked:e.settings.enableFreeMatches,onCheckedChange:I=>n({...e,settings:{...e.settings,enableFreeMatches:I}})}),s.jsx(ee,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($t,{checked:e.settings.enablePaidMatches,onCheckedChange:I=>n({...e,settings:{...e.settings,enablePaidMatches:I}})}),s.jsx(ee,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(rt,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(at,{className:"text-white flex items-center gap-2",children:[s.jsx(In,{className:"w-5 h-5 text-[#38bdac]"})," 匹配类型管理"]}),s.jsx(Kt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(X,{onClick:O,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(An,{className:"w-4 h-4 mr-1"})," 添加类型"]})]}),s.jsx(Le,{children:s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"图标"}),s.jsx(je,{className:"text-gray-400",children:"类型ID"}),s.jsx(je,{className:"text-gray-400",children:"显示名称"}),s.jsx(je,{className:"text-gray-400",children:"匹配标签"}),s.jsx(je,{className:"text-gray-400",children:"价格"}),s.jsx(je,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(hs,{children:e.matchTypes.map(I=>s.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{children:s.jsx("span",{className:"text-2xl",children:I.icon})}),s.jsx(be,{className:"font-mono text-gray-300",children:I.id}),s.jsx(be,{className:"text-white font-medium",children:I.label}),s.jsx(be,{className:"text-gray-300",children:I.matchLabel}),s.jsx(be,{children:s.jsxs(Ve,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",I.price]})}),s.jsx(be,{children:I.matchFromDB?s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Ve,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(be,{children:s.jsx($t,{checked:I.enabled,onCheckedChange:()=>V(I.id)})}),s.jsx(be,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>P(I),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(Jt,{className:"w-4 h-4"})}),s.jsx(X,{variant:"ghost",size:"sm",onClick:()=>z(I.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(bs,{className:"w-4 h-4"})})]})})]},I.id))})]})})]}),s.jsx(Dt,{open:c,onOpenChange:u,children:s.jsxs(Lt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(_t,{children:s.jsxs(zt,{className:"text-white flex items-center gap-2",children:[h?s.jsx(Jt,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(An,{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(ee,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:m.id,onChange:I=>x({...m,id:I.target.value}),disabled:!!h})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:gV.map(I=>s.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${m.icon===I?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>x({...m,icon:I}),children:I},I))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"显示名称"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.label,onChange:I=>x({...m,label:I.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"匹配标签"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.matchLabel,onChange:I=>x({...m,matchLabel:I.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ee,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(ce,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:m.price,onChange:I=>x({...m,price:parseFloat(I.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($t,{checked:m.matchFromDB,onCheckedChange:I=>x({...m,matchFromDB:I})}),s.jsx(ee,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($t,{checked:m.showJoinAfterMatch,onCheckedChange:I=>x({...m,showJoinAfterMatch:I})}),s.jsx(ee,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($t,{checked:m.enabled,onCheckedChange:I=>x({...m,enabled:I})}),s.jsx(ee,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(fn,{children:[s.jsx(X,{variant:"outline",onClick:()=>u(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(X,{onClick:q,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{className:"w-4 h-4 mr-2"})," 保存"]})]})]})})]})}const sj={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function bV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(""),[f,m]=b.useState(!0),[x,y]=b.useState(null),[N,w]=b.useState(null);async function j(){m(!0),y(null);try{const T=new URLSearchParams({page:String(a),pageSize:String(o)});u&&T.set("matchType",u);const P=await Pe(`/api/db/match-records?${T}`);P!=null&&P.success?(e(P.records||[]),r(P.total??0)):y("加载匹配记录失败")}catch{y("加载失败,请检查网络后重试")}finally{m(!1)}}b.useEffect(()=>{j()},[a,u]);const S=Math.ceil(n/o)||1,E=({userId:T,nickname:P,avatar:O})=>s.jsxs("div",{className:"flex items-center gap-3 cursor-pointer group",onClick:()=>w(T),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:[O?s.jsx("img",{src:fo(O),alt:"",className:"w-full h-full object-cover",onError:q=>{q.currentTarget.style.display="none"}}):null,s.jsx("span",{className:O?"hidden":"",children:(P||T||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white group-hover:text-[#38bdac] transition-colors",children:P||T}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[T==null?void 0:T.slice(0,16),(T==null?void 0:T.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:()=>y(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsxs("p",{className:"text-gray-400",children:["共 ",n," 条匹配记录 · 点击用户名查看详情"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("select",{value:u,onChange:T=>{h(T.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(sj).map(([T,P])=>s.jsx("option",{value:T,children:P},T))]}),s.jsxs("button",{type:"button",onClick:j,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(Fe,{className:`w-4 h-4 ${f?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:f?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Fe,{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(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"发起人"}),s.jsx(je,{className:"text-gray-400",children:"匹配到"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"联系方式"}),s.jsx(je,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(hs,{children:[t.map(T=>s.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{children:s.jsx(E,{userId:T.userId,nickname:T.userNickname,avatar:T.userAvatar})}),s.jsx(be,{children:T.matchedUserId?s.jsx(E,{userId:T.matchedUserId,nickname:T.matchedNickname,avatar:T.matchedUserAvatar}):s.jsx("span",{className:"text-gray-500",children:"—"})}),s.jsx(be,{children:s.jsx(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:sj[T.matchType]||T.matchType})}),s.jsxs(be,{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(be,{className:"text-gray-400",children:T.createdAt?new Date(T.createdAt).toLocaleString():"-"})]},T.id)),t.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(qs,{page:a,totalPages:S,total:n,pageSize:o,onPageChange:i,onPageSizeChange:T=>{c(T),i(1)}})]})})}),s.jsx(I0,{open:!!N,onClose:()=>w(null),userId:N,onUserUpdated:j})]})}function vV(){const[t,e]=b.useState("records");return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>e("records"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="records"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"匹配记录"}),s.jsx("button",{type:"button",onClick:()=>e("pool"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="pool"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"匹配池设置"})]}),t==="records"&&s.jsx(bV,{}),t==="pool"&&s.jsx(yV,{})]})}const rj={investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function NV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(!0),[f,m]=b.useState("investor"),[x,y]=b.useState(null);async function N(){h(!0);try{const E=new URLSearchParams({page:String(a),pageSize:String(o),matchType:f}),T=await Pe(`/api/db/match-records?${E}`);T!=null&&T.success&&(e(T.records||[]),r(T.total??0))}catch(E){console.error(E)}finally{h(!1)}}b.useEffect(()=>{N()},[a,f]);const w=async E=>{if(!E.phone&&!E.wechatId){se.info("该记录无联系方式,无法推送到存客宝");return}y(E.id);try{const T=await Ct("/api/ckb/join",{type:E.matchType||"investor",phone:E.phone||"",wechat:E.wechatId||"",userId:E.userId,name:E.userNickname||""});se.error((T==null?void 0:T.message)||(T!=null&&T.success?"推送成功":"推送失败"))}catch(T){se.error("推送失败: "+(T instanceof Error?T.message:"网络错误"))}finally{y(null)}},j=Math.ceil(n/o)||1,S=E=>!!(E.phone||E.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:E=>{m(E.target.value),i(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:Object.entries(rj).map(([E,T])=>s.jsx("option",{value:E,children:T},E))}),s.jsxs(X,{onClick:N,disabled:u,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${u?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:u?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Fe,{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(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"发起人"}),s.jsx(je,{className:"text-gray-400",children:"匹配到"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"联系方式"}),s.jsx(je,{className:"text-gray-400",children:"时间"}),s.jsx(je,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsxs(hs,{children:[t.map(E=>{var T,P;return s.jsxs(ct,{className:`border-gray-700/50 ${S(E)?"hover:bg-[#0a1628]":"opacity-60"}`,children:[s.jsx(be,{className:"text-white",children:E.userNickname||((T=E.userId)==null?void 0:T.slice(0,12))}),s.jsx(be,{className:"text-white",children:E.matchedNickname||((P=E.matchedUserId)==null?void 0:P.slice(0,12))}),s.jsx(be,{children:s.jsx(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:rj[E.matchType]||E.matchType})}),s.jsxs(be,{className:"text-sm",children:[E.phone&&s.jsxs("div",{className:"text-green-400",children:["📱 ",E.phone]}),E.wechatId&&s.jsxs("div",{className:"text-blue-400",children:["💬 ",E.wechatId]}),!E.phone&&!E.wechatId&&s.jsx("span",{className:"text-gray-600",children:"无联系方式"})]}),s.jsx(be,{className:"text-gray-400 text-sm",children:E.createdAt?new Date(E.createdAt).toLocaleString():"-"}),s.jsx(be,{className:"text-right",children:S(E)?s.jsxs(X,{size:"sm",onClick:()=>w(E),disabled:x===E.id,className:"bg-[#38bdac] hover:bg-[#2da396] text-white text-xs h-7 px-3",children:[s.jsx(KM,{className:"w-3 h-3 mr-1"}),x===E.id?"推送中...":"推送CKB"]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"—"})})]},E.id)}),t.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无记录"})})]})]}),s.jsx(qs,{page:a,totalPages:j,total:n,pageSize:o,onPageChange:i,onPageSizeChange:E=>{c(E),i(1)}})]})})})]})}const aj={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},wV={single:"单次",half_year:"半年",year:"年度"};function jV(){const[t,e]=b.useState([]),[n,r]=b.useState(!0),[a,i]=b.useState("");async function o(){r(!0);try{const c=a?`/api/db/mentor-consultations?status=${a}`:"/api/db/mentor-consultations",u=await Pe(c);u!=null&&u.success&&u.data&&e(u.data)}catch(c){console.error(c)}finally{r(!1)}}return b.useEffect(()=>{o()},[a]),s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsx("p",{className:"text-gray-400",children:"导师咨询预约记录"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:a,onChange:c=>i(c.target.value),className:"bg-[#0f2137] border border-gray-700 rounded-lg px-3 py-2 text-gray-300 text-sm",children:[s.jsx("option",{value:"",children:"全部状态"}),Object.entries(aj).map(([c,u])=>s.jsx("option",{value:c,children:u},c))]}),s.jsxs(X,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Le,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"ID"}),s.jsx(je,{className:"text-gray-400",children:"用户ID"}),s.jsx(je,{className:"text-gray-400",children:"导师ID"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"金额"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(hs,{children:[t.map(c=>s.jsxs(ct,{className:"border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:c.id}),s.jsx(be,{className:"text-gray-400",children:c.userId}),s.jsx(be,{className:"text-gray-400",children:c.mentorId}),s.jsx(be,{className:"text-gray-400",children:wV[c.consultationType]||c.consultationType}),s.jsxs(be,{className:"text-white",children:["¥",c.amount]}),s.jsx(be,{className:"text-gray-400",children:aj[c.status]||c.status}),s.jsx(be,{className:"text-gray-500 text-sm",children:c.createdAt?new Date(c.createdAt).toLocaleString():"-"})]},c.id)),t.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}function kV(){const[t,e]=b.useState("booking");return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>e("booking"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="booking"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"预约记录"}),s.jsx("button",{type:"button",onClick:()=>e("manage"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="manage"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"导师管理"})]}),t==="booking"&&s.jsx(jV,{}),t==="manage"&&s.jsx("div",{className:"-mx-8",children:s.jsx(x4,{embedded:!0})})]})}function SV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(!0);async function f(){h(!0);try{const x=new URLSearchParams({page:String(a),pageSize:String(o),matchType:"team"}),y=await Pe(`/api/db/match-records?${x}`);y!=null&&y.success&&(e(y.records||[]),r(y.total??0))}catch(x){console.error(x)}finally{h(!1)}}b.useEffect(()=>{f()},[a]);const m=Math.ceil(n/o)||1;return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-gray-400",children:["团队招募匹配记录,共 ",n," 条"]}),s.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"用户通过「团队招募」提交联系方式到存客宝"})]}),s.jsxs("button",{type:"button",onClick:f,disabled:u,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700/50 transition-colors disabled:opacity-50",children:[s.jsx(Fe,{className:`w-4 h-4 ${u?"animate-spin":""}`})," 刷新"]})]}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Le,{className:"p-0",children:u?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Fe,{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(ds,{children:[s.jsx(us,{children:s.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"发起人"}),s.jsx(je,{className:"text-gray-400",children:"匹配到"}),s.jsx(je,{className:"text-gray-400",children:"联系方式"}),s.jsx(je,{className:"text-gray-400",children:"时间"})]})}),s.jsxs(hs,{children:[t.map(x=>s.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{className:"text-white",children:x.userNickname||x.userId}),s.jsx(be,{className:"text-white",children:x.matchedNickname||x.matchedUserId}),s.jsxs(be,{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(be,{className:"text-gray-400",children:x.createdAt?new Date(x.createdAt).toLocaleString():"-"})]},x.id)),t.length===0&&s.jsx(ct,{children:s.jsx(be,{colSpan:4,className:"text-center py-12 text-gray-500",children:"暂无团队招募记录"})})]})]}),s.jsx(qs,{page:a,totalPages:m,total:n,pageSize:o,onPageChange:i,onPageSizeChange:x=>{c(x),i(1)}})]})})})]})}const ij={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募",join:"加入",match:"匹配"},oj={partner:"⭐",investor:"👥",mentor:"❤️",team:"🎮",join:"📋",match:"🔗"};function CV({onSwitchTab:t,onOpenCKB:e}={}){const n=Sa(),[r,a]=b.useState(null),[i,o]=b.useState(null),[c,u]=b.useState(!0),h=b.useCallback(async()=>{var x,y;u(!0);try{const[N,w]=await Promise.allSettled([Pe("/api/db/match-records?stats=true"),Pe("/api/db/ckb-plan-stats")]);if(N.status==="fulfilled"&&((x=N.value)!=null&&x.success)&&N.value.data){let j=N.value.data;if(j.totalMatches>0&&(!j.uniqueUsers||j.uniqueUsers===0))try{const S=await Pe("/api/db/match-records?page=1&pageSize=200");if(S!=null&&S.success&&S.records){const E=new Set(S.records.map(T=>T.userId).filter(Boolean));j={...j,uniqueUsers:E.size}}}catch{}a(j)}w.status==="fulfilled"&&((y=w.value)!=null&&y.success)&&w.value.data&&o(w.value.data)}catch(N){console.error("加载统计失败:",N)}finally{u(!1)}},[]);b.useEffect(()=>{h()},[h]);const f=x=>c?"—":String(x??0),m=r!=null&&r.uniqueUsers?(r.totalMatches/r.uniqueUsers).toFixed(1):"0";return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-5 gap-3",children:[s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40 cursor-pointer hover:border-[#38bdac]/60 transition-all",onClick:()=>t==null?void 0:t("partner"),children:s.jsxs(Le,{className:"p-4",children:[s.jsx("p",{className:"text-gray-400 text-xs",children:"总匹配"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:f(r==null?void 0:r.totalMatches)}),s.jsxs("p",{className:"text-[#38bdac] text-[10px] mt-1 flex items-center gap-0.5",children:[s.jsx(fi,{className:"w-2.5 h-2.5"})," 查看记录"]})]})}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40",children:s.jsxs(Le,{className:"p-4",children:[s.jsx("p",{className:"text-gray-400 text-xs",children:"今日"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:f(r==null?void 0:r.todayMatches)}),s.jsxs("p",{className:"text-yellow-400/60 text-[10px] mt-1 flex items-center gap-0.5",children:[s.jsx(pi,{className:"w-2.5 h-2.5"})," 实时"]})]})}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40 cursor-pointer hover:border-blue-500/60 transition-all",onClick:()=>n("/users"),children:s.jsxs(Le,{className:"p-4",children:[s.jsx("p",{className:"text-gray-400 text-xs",children:"用户数"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:f(r==null?void 0:r.uniqueUsers)}),s.jsxs("p",{className:"text-blue-400/60 text-[10px] mt-1 flex items-center gap-0.5",children:[s.jsx(In,{className:"w-2.5 h-2.5"})," 查看用户"]})]})}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40",children:s.jsxs(Le,{className:"p-4",children:[s.jsx("p",{className:"text-gray-400 text-xs",children:"人均匹配"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:c?"—":m})]})}),s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40",children:s.jsxs(Le,{className:"p-4",children:[s.jsx("p",{className:"text-gray-400 text-xs",children:"付费匹配"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:f(r==null?void 0:r.paidMatchCount)})]})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40",children:s.jsxs(Le,{className:"p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"匹配类型分布"}),r!=null&&r.byType&&r.byType.length>0?s.jsx("div",{className:"space-y-2",children:r.byType.map(x=>{const y=r.totalMatches>0?x.count/r.totalMatches*100:0;return s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-lg shrink-0",children:oj[x.matchType]||"📊"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex justify-between text-xs mb-0.5",children:[s.jsx("span",{className:"text-gray-300",children:ij[x.matchType]||x.matchType}),s.jsxs("span",{className:"text-gray-500",children:[x.count," (",y.toFixed(0),"%)"]})]}),s.jsx("div",{className:"w-full h-1.5 bg-gray-700/50 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac] rounded-full",style:{width:`${Math.min(y,100)}%`}})})]})]},x.matchType)})}):s.jsx("p",{className:"text-gray-500 text-xs",children:"暂无数据"})]})}),s.jsx(Oe,{className:"bg-[#0f2137] border-orange-500/20",children:s.jsxs(Le,{className:"p-4",children:[s.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-1.5",children:[s.jsx(ya,{className:"w-4 h-4 text-orange-400"})," AI 获客"]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 cursor-pointer hover:border-orange-500/50 border border-transparent transition-colors",onClick:()=>e==null?void 0:e("submitted"),children:[s.jsx("p",{className:"text-gray-400 text-xs",children:"已提交线索"}),s.jsx("p",{className:"text-xl font-bold text-white",children:c?"—":(i==null?void 0:i.ckbTotal)??0})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 cursor-pointer hover:border-orange-500/50 border border-transparent transition-colors",onClick:()=>e==null?void 0:e("contact"),children:[s.jsx("p",{className:"text-gray-400 text-xs",children:"有联系方式"}),s.jsx("p",{className:"text-xl font-bold text-white",children:c?"—":(i==null?void 0:i.withContact)??0})]})]}),(i==null?void 0:i.byType)&&i.byType.length>0&&s.jsx("div",{className:"space-y-1.5",children:i.byType.map(x=>s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{children:oj[x.matchType]||"📋"}),s.jsx("span",{className:"text-gray-400",children:ij[x.matchType]||x.matchType}),s.jsx("span",{className:"ml-auto text-white font-medium",children:x.total})]},x.matchType))}),s.jsx("button",{type:"button",onClick:()=>e==null?void 0:e("test"),className:"mt-3 w-full text-xs text-orange-400 hover:text-orange-300 text-center py-1.5 bg-orange-500/10 rounded",children:"查看 AI 添加进度 →"})]})})]})]})}const TV=["partner","investor","mentor","team"],Zx=[{key:"join_partner",label:"找伙伴场景"},{key:"join_investor",label:"资源对接场景"},{key:"join_mentor",label:"导师顾问场景"},{key:"join_team",label:"团队招募场景"},{key:"match",label:"匹配上报"},{key:"lead",label:"链接卡若"}],lj=`# 场景获客接口摘要 - 地址:POST /v1/api/scenarios - 必填:apiKey、sign、timestamp - 主标识:phone 或 wechatId 至少一项 - 可选:name、source、remark、tags、siteTags、portrait - 签名:排除 sign/apiKey/portrait,键名升序拼接值后双重 MD5 -- 成功:code=200,message=新增成功 或 已存在`;function EV({initialTab:t="overview"}){const[e,n]=b.useState(t),[r,a]=b.useState("13800000000"),[i,o]=b.useState(""),[c,u]=b.useState(""),[h,f]=b.useState(lj),[m,g]=b.useState(!1),[y,N]=b.useState(!1),[w,j]=b.useState([]),[S,E]=b.useState([]),[T,P]=b.useState({}),[O,q]=b.useState([{endpoint:"/api/ckb/join",label:"找伙伴",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"资源对接",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"导师顾问",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"团队招募",method:"POST",status:"idle"},{endpoint:"/api/ckb/match",label:"匹配上报",method:"POST",status:"idle"},{endpoint:"/api/miniprogram/ckb/lead",label:"链接卡若",method:"POST",status:"idle"},{endpoint:"/api/match/config",label:"匹配配置",method:"GET",status:"idle"}]),z=b.useMemo(()=>{const $={};return Zg.forEach(D=>{$[D.key]=T[D.key]||{apiUrl:"https://ckbapi.quwanzhi.com/v1/api/scenarios",apiKey:"fyngh-ecy9h-qkdae-epwd5-rz6kd",source:"",tags:"",siteTags:"创业实验APP",notes:""}}),$},[T]),V=$=>{const D=r.trim(),R=i.trim();return $<=3?{type:TV[$],phone:D||void 0,wechat:R||void 0,userId:"admin_test",name:"后台测试"}:$===4?{matchType:"partner",phone:D||void 0,wechat:R||void 0,userId:"admin_test",nickname:"后台测试",matchedUser:{id:"test",nickname:"测试",matchScore:88}}:$===5?{phone:D||void 0,wechatId:R||void 0,userId:"admin_test",name:"后台测试"}:{}};async function I(){N(!0);try{const[$,D,R]=await Promise.all([Pe("/api/db/config/full?key=ckb_config"),Pe("/api/db/ckb-leads?mode=submitted&page=1&pageSize=50"),Pe("/api/db/ckb-leads?mode=contact&page=1&pageSize=50")]),oe=$==null?void 0:$.data;oe!=null&&oe.routes&&P(oe.routes),oe!=null&&oe.docNotes&&u(oe.docNotes),oe!=null&&oe.docContent&&f(oe.docContent),D!=null&&D.success&&j(D.records||[]),R!=null&&R.success&&E(R.records||[])}finally{N(!1)}}b.useEffect(()=>{n(t)},[t]),b.useEffect(()=>{I()},[]);const te=b.useMemo(()=>{const $=_=>(_||"").replace(/\D/g,"")||"",D=_=>{const U=$(_.phone);if(U)return`phone:${U}`;const H=(_.userId||"").trim();if(H)return`user:${H}`;const K=(_.wechatId||"").trim();return K?`wechat:${K}`:`row:${_.id}`},R=[...S].sort((_,U)=>{const H=_.createdAt?new Date(_.createdAt).getTime():0;return(U.createdAt?new Date(U.createdAt).getTime():0)-H}),oe=new Set,G=[];for(const _ of R){const U=D(_);oe.has(U)||(oe.add(U),G.push(_))}return G},[S]);async function Q(){g(!0);try{const $=await Ct("/api/db/config",{key:"ckb_config",value:{routes:z,docNotes:c,docContent:h},description:"存客宝接口配置"});se.error(($==null?void 0:$.success)!==!1?"存客宝配置已保存":`保存失败: ${($==null?void 0:$.error)||"未知错误"}`)}catch($){se.error(`保存失败: ${$ instanceof Error?$.message:"网络错误"}`)}finally{g(!1)}}const F=($,D)=>{P(R=>({...R,[$]:{...z[$],...D}}))},re=async $=>{const D=O[$];if(D.method==="POST"&&!r.trim()&&!i.trim()){se.error("请填写测试手机号");return}const R=[...O];R[$]={...D,status:"testing",message:void 0,responseTime:void 0},q(R);const oe=performance.now();try{const G=D.method==="GET"?await Pe(D.endpoint):await Ct(D.endpoint,V($)),_=Math.round(performance.now()-oe),U=(G==null?void 0:G.message)||"",H=(G==null?void 0:G.success)===!0||U.includes("已存在")||U.includes("已加入")||U.includes("已提交"),K=[...O];K[$]={...D,status:H?"success":"error",message:U||(H?"正常":"异常"),responseTime:_},q(K),await I()}catch(G){const _=Math.round(performance.now()-oe),U=[...O];U[$]={...D,status:"error",message:G instanceof Error?G.message:"失败",responseTime:_},q(U)}},ae=async()=>{if(!r.trim()&&!i.trim()){se.error("请填写测试手机号");return}for(let $=0;$s.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:$.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(ll,{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:D}),R?s.jsx("p",{className:"text-gray-500 text-sm mt-2 max-w-md mx-auto leading-relaxed",children:R}):null]})})}):$.map(oe=>s.jsxs("tr",{className:"border-t border-gray-700/30",children:[s.jsx("td",{className:"px-4 py-3 text-white",children:oe.userNickname||oe.userId}),s.jsx("td",{className:"px-4 py-3 text-gray-300",children:oe.matchType}),s.jsx("td",{className:"px-4 py-3 text-green-400",children:oe.phone||"—"}),s.jsx("td",{className:"px-4 py-3 text-blue-400",children:oe.wechatId||"—"}),s.jsx("td",{className:"px-4 py-3 text-gray-400",children:oe.createdAt?new Date(oe.createdAt).toLocaleString():"—"})]},String(oe.id)))})]})});return s.jsx(Oe,{className:"bg-[#0f2137] border-orange-500/30 mb-6",children:s.jsxs(Le,{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h3",{className:"text-white font-semibold",children:"存客宝工作台"}),s.jsx(Ve,{className:"bg-orange-500/20 text-orange-400 border-0 text-xs",children:"CKB"}),s.jsxs("button",{type:"button",onClick:()=>n("doc"),className:"text-orange-400/60 text-xs hover:text-orange-400 flex items-center gap-1",children:[s.jsx(fi,{className:"w-3 h-3"})," API 文档"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(X,{onClick:()=>I(),variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-3.5 h-3.5 mr-1 ${y?"animate-spin":""}`})," 刷新"]}),s.jsxs(X,{onClick:Q,disabled:m,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{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(([$,D])=>s.jsx("button",{type:"button",onClick:()=>n($),className:`px-4 py-2 rounded-lg text-sm transition-colors ${e===$?"bg-orange-500 text-white":"bg-[#0a1628] text-gray-400 hover:text-white"}`,children:D},$))}),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:te.length}),S.length!==te.length&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-1",children:["原始 ",S.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:Zg.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"&&J(w,"暂无已提交线索","用户通过场景提交后会出现于此。"),e==="contact"&&s.jsxs("div",{className:"space-y-2",children:[S.length>te.length&&s.jsxs("p",{className:"text-xs text-gray-500",children:["已合并 ",S.length-te.length," 条重复(同手机号或同用户 ID 仅保留最近一条)"]}),J(te,"暂无有联系方式线索","存客宝留资同步后显示;完整列表与筛选请前往「用户管理 → 获客列表」。")]}),e==="config"&&s.jsx("div",{className:"space-y-4",children:Zg.map($=>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:$.label}),s.jsx(Ve,{className:"bg-orange-500/20 text-orange-300 border-0 text-xs",children:$.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(ee,{className:"text-gray-500 text-xs",children:"API 地址"}),s.jsx(de,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:z[$.key].apiUrl,onChange:D=>F($.key,{apiUrl:D.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-500 text-xs",children:"API Key"}),s.jsx(de,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:z[$.key].apiKey,onChange:D=>F($.key,{apiKey:D.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-500 text-xs",children:"Source"}),s.jsx(de,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:z[$.key].source,onChange:D=>F($.key,{source:D.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-500 text-xs",children:"Tags"}),s.jsx(de,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:z[$.key].tags,onChange:D=>F($.key,{tags:D.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-500 text-xs",children:"SiteTags"}),s.jsx(de,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:z[$.key].siteTags,onChange:D=>F($.key,{siteTags:D.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-500 text-xs",children:"说明备注"}),s.jsx(de,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:z[$.key].notes,onChange:D=>F($.key,{notes:D.target.value})})]})]})]},$.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(ll,{className:"w-4 h-4 text-gray-500 shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx(ee,{className:"text-gray-500 text-xs",children:"测试手机号"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:r,onChange:$=>a($.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(ee,{className:"text-gray-500 text-xs",children:"微信号(可选)"}),s.jsx(de,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:i,onChange:$=>o($.target.value)})]})]}),s.jsx("div",{className:"flex items-end",children:s.jsxs(X,{onClick:ae,className:"bg-orange-500 hover:bg-orange-600 text-white",children:[s.jsx(pi,{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:O.map(($,D)=>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:[$.status==="idle"&&s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-600 shrink-0"}),$.status==="testing"&&s.jsx(Fe,{className:"w-3 h-3 text-yellow-400 animate-spin shrink-0"}),$.status==="success"&&s.jsx(jj,{className:"w-3 h-3 text-green-400 shrink-0"}),$.status==="error"&&s.jsx(Sj,{className:"w-3 h-3 text-red-400 shrink-0"}),s.jsx("span",{className:"text-white text-xs truncate",children:$.label})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[$.responseTime!==void 0&&s.jsxs("span",{className:"text-gray-600 text-[10px]",children:[$.responseTime,"ms"]}),s.jsx("button",{type:"button",onClick:()=>re(D),disabled:$.status==="testing",className:"text-orange-400/60 hover:text-orange-400 text-[10px] disabled:opacity-50",children:"测试"})]})]},`${$.endpoint}-${D}`))})]}),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(fi,{className:"w-3 h-3"})," 打开外链"]})]}),s.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-400 leading-6",children:h||lj})]}),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:$=>u($.target.value),placeholder:"记录 Token、入口差异、回复率统计规则、对接约定等。"})]})]})]})})}const MV=[{id:"stats",label:"数据统计",icon:rc,desc:"匹配与获客概览"},{id:"partner",label:"找伙伴",icon:In,desc:"匹配池与记录"},{id:"resource",label:"资源对接",icon:V5,desc:"人脉资源"},{id:"mentor",label:"导师预约",icon:$5,desc:"预约与管理"},{id:"team",label:"团队招募",icon:hc,desc:"团队协作"}];function AV(){const[t,e]=b.useState("stats"),[n,r]=b.useState(!1),[a,i]=b.useState("overview");return s.jsxs("div",{className:"p-8 w-full 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(In,{className:"w-5 h-5 text-[#38bdac]"}),"找伙伴"]}),s.jsx("p",{className:"text-gray-500 text-sm mt-0.5",children:"匹配、获客、导师与团队管理"})]}),s.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:()=>r(o=>!o),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(ya,{className:"w-3.5 h-3.5 mr-1.5"}),"存客宝",s.jsx(Xo,{className:`w-3 h-3 ml-1 transition-transform ${n?"rotate-90":""}`})]})]}),n&&s.jsx(EV,{initialTab:a}),s.jsx("div",{className:"flex gap-1 mb-6 bg-[#0a1628] rounded-lg p-1 border border-gray-700/40",children:MV.map(o=>{const c=t===o.id;return s.jsxs("button",{type:"button",onClick:()=>e(o.id),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2 rounded-md text-sm transition-all ${c?"bg-[#38bdac] text-white shadow-md":"text-gray-400 hover:text-white hover:bg-gray-700/40"}`,children:[s.jsx(o.icon,{className:"w-3.5 h-3.5"}),o.label]},o.id)})}),t==="stats"&&s.jsx(CV,{onSwitchTab:o=>e(o),onOpenCKB:o=>{i(o||"overview"),r(!0)}}),t==="partner"&&s.jsx(vV,{}),t==="resource"&&s.jsx(NV,{}),t==="mentor"&&s.jsx(kV,{}),t==="team"&&s.jsx(SV,{})]})}function IV(){const t=vo();return s.jsx("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-8",children:s.jsxs("div",{className:"text-center max-w-md",children:[s.jsx("div",{className:"inline-flex items-center justify-center w-20 h-20 rounded-full bg-red-500/20 text-red-400 mb-6",children:s.jsx(wj,{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(X,{asChild:!0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:s.jsxs(bc,{to:"/",children:[s.jsx(Y5,{className:"w-4 h-4 mr-2"}),"返回首页"]})})]})})}function RV(){return s.jsxs(OE,{children:[s.jsx(nn,{path:"/login",element:s.jsx(AI,{})}),s.jsxs(nn,{path:"/",element:s.jsx(PA,{}),children:[s.jsx(nn,{index:!0,element:s.jsx(oh,{to:"/dashboard",replace:!0})}),s.jsx(nn,{path:"dashboard",element:s.jsx(HP,{})}),s.jsx(nn,{path:"orders",element:s.jsx(UP,{})}),s.jsx(nn,{path:"users",element:s.jsx(QP,{})}),s.jsx(nn,{path:"distribution",element:s.jsx(y8,{})}),s.jsx(nn,{path:"withdrawals",element:s.jsx(b8,{})}),s.jsx(nn,{path:"content",element:s.jsx(J9,{})}),s.jsx(nn,{path:"referral-settings",element:s.jsx(f2,{})}),s.jsx(nn,{path:"author-settings",element:s.jsx(oh,{to:"/settings?tab=author",replace:!0})}),s.jsx(nn,{path:"vip-roles",element:s.jsx(mV,{})}),s.jsx(nn,{path:"mentors",element:s.jsx(g4,{})}),s.jsx(nn,{path:"mentor-consultations",element:s.jsx(gV,{})}),s.jsx(nn,{path:"admin-users",element:s.jsx(oh,{to:"/settings?tab=admin",replace:!0})}),s.jsx(nn,{path:"settings",element:s.jsx(aV,{})}),s.jsx(nn,{path:"payment",element:s.jsx(iV,{})}),s.jsx(nn,{path:"site",element:s.jsx(dV,{})}),s.jsx(nn,{path:"qrcodes",element:s.jsx(uV,{})}),s.jsx(nn,{path:"find-partner",element:s.jsx(AV,{})}),s.jsx(nn,{path:"match",element:s.jsx(fV,{})}),s.jsx(nn,{path:"match-records",element:s.jsx(pV,{})}),s.jsx(nn,{path:"api-doc",element:s.jsx(oh,{to:"/api-docs",replace:!0})}),s.jsx(nn,{path:"api-docs",element:s.jsx(m4,{})})]}),s.jsx(nn,{path:"*",element:s.jsx(IV,{})})]})}$T.createRoot(document.getElementById("root")).render(s.jsx(b.StrictMode,{children:s.jsx(VE,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:s.jsx(RV,{})})})); +- 成功:code=200,message=新增成功 或 已存在`;function EV({initialTab:t="overview"}){const[e,n]=b.useState(t),[r,a]=b.useState("13800000000"),[i,o]=b.useState(""),[c,u]=b.useState(""),[h,f]=b.useState(lj),[m,x]=b.useState(!1),[y,N]=b.useState(!1),[w,j]=b.useState([]),[S,E]=b.useState([]),[T,P]=b.useState({}),[O,q]=b.useState([{endpoint:"/api/ckb/join",label:"找伙伴",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"资源对接",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"导师顾问",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"团队招募",method:"POST",status:"idle"},{endpoint:"/api/ckb/match",label:"匹配上报",method:"POST",status:"idle"},{endpoint:"/api/miniprogram/ckb/lead",label:"链接卡若",method:"POST",status:"idle"},{endpoint:"/api/match/config",label:"匹配配置",method:"GET",status:"idle"}]),z=b.useMemo(()=>{const $={};return Zx.forEach(D=>{$[D.key]=T[D.key]||{apiUrl:"https://ckbapi.quwanzhi.com/v1/api/scenarios",apiKey:"fyngh-ecy9h-qkdae-epwd5-rz6kd",source:"",tags:"",siteTags:"创业实验APP",notes:""}}),$},[T]),V=$=>{const D=r.trim(),R=i.trim();return $<=3?{type:TV[$],phone:D||void 0,wechat:R||void 0,userId:"admin_test",name:"后台测试"}:$===4?{matchType:"partner",phone:D||void 0,wechat:R||void 0,userId:"admin_test",nickname:"后台测试",matchedUser:{id:"test",nickname:"测试",matchScore:88}}:$===5?{phone:D||void 0,wechatId:R||void 0,userId:"admin_test",name:"后台测试"}:{}};async function I(){N(!0);try{const[$,D,R]=await Promise.all([Pe("/api/db/config/full?key=ckb_config"),Pe("/api/db/ckb-leads?mode=submitted&page=1&pageSize=50"),Pe("/api/db/ckb-leads?mode=contact&page=1&pageSize=50")]),oe=$==null?void 0:$.data;oe!=null&&oe.routes&&P(oe.routes),oe!=null&&oe.docNotes&&u(oe.docNotes),oe!=null&&oe.docContent&&f(oe.docContent),D!=null&&D.success&&j(D.records||[]),R!=null&&R.success&&E(R.records||[])}finally{N(!1)}}b.useEffect(()=>{n(t)},[t]),b.useEffect(()=>{I()},[]);const te=b.useMemo(()=>{const $=_=>(_||"").replace(/\D/g,"")||"",D=_=>{const U=$(_.phone);if(U)return`phone:${U}`;const H=(_.userId||"").trim();if(H)return`user:${H}`;const K=(_.wechatId||"").trim();return K?`wechat:${K}`:`row:${_.id}`},R=[...S].sort((_,U)=>{const H=_.createdAt?new Date(_.createdAt).getTime():0;return(U.createdAt?new Date(U.createdAt).getTime():0)-H}),oe=new Set,G=[];for(const _ of R){const U=D(_);oe.has(U)||(oe.add(U),G.push(_))}return G},[S]);async function Q(){x(!0);try{const $=await Ct("/api/db/config",{key:"ckb_config",value:{routes:z,docNotes:c,docContent:h},description:"存客宝接口配置"});se.error(($==null?void 0:$.success)!==!1?"存客宝配置已保存":`保存失败: ${($==null?void 0:$.error)||"未知错误"}`)}catch($){se.error(`保存失败: ${$ instanceof Error?$.message:"网络错误"}`)}finally{x(!1)}}const F=($,D)=>{P(R=>({...R,[$]:{...z[$],...D}}))},re=async $=>{const D=O[$];if(D.method==="POST"&&!r.trim()&&!i.trim()){se.error("请填写测试手机号");return}const R=[...O];R[$]={...D,status:"testing",message:void 0,responseTime:void 0},q(R);const oe=performance.now();try{const G=D.method==="GET"?await Pe(D.endpoint):await Ct(D.endpoint,V($)),_=Math.round(performance.now()-oe),U=(G==null?void 0:G.message)||"",H=(G==null?void 0:G.success)===!0||U.includes("已存在")||U.includes("已加入")||U.includes("已提交"),K=[...O];K[$]={...D,status:H?"success":"error",message:U||(H?"正常":"异常"),responseTime:_},q(K),await I()}catch(G){const _=Math.round(performance.now()-oe),U=[...O];U[$]={...D,status:"error",message:G instanceof Error?G.message:"失败",responseTime:_},q(U)}},ie=async()=>{if(!r.trim()&&!i.trim()){se.error("请填写测试手机号");return}for(let $=0;$s.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:$.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(ll,{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:D}),R?s.jsx("p",{className:"text-gray-500 text-sm mt-2 max-w-md mx-auto leading-relaxed",children:R}):null]})})}):$.map(oe=>s.jsxs("tr",{className:"border-t border-gray-700/30",children:[s.jsx("td",{className:"px-4 py-3 text-white",children:oe.userNickname||oe.userId}),s.jsx("td",{className:"px-4 py-3 text-gray-300",children:oe.matchType}),s.jsx("td",{className:"px-4 py-3 text-green-400",children:oe.phone||"—"}),s.jsx("td",{className:"px-4 py-3 text-blue-400",children:oe.wechatId||"—"}),s.jsx("td",{className:"px-4 py-3 text-gray-400",children:oe.createdAt?new Date(oe.createdAt).toLocaleString():"—"})]},String(oe.id)))})]})});return s.jsx(Oe,{className:"bg-[#0f2137] border-orange-500/30 mb-6",children:s.jsxs(Le,{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h3",{className:"text-white font-semibold",children:"存客宝工作台"}),s.jsx(Ve,{className:"bg-orange-500/20 text-orange-400 border-0 text-xs",children:"CKB"}),s.jsxs("button",{type:"button",onClick:()=>n("doc"),className:"text-orange-400/60 text-xs hover:text-orange-400 flex items-center gap-1",children:[s.jsx(fi,{className:"w-3 h-3"})," API 文档"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(X,{onClick:()=>I(),variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Fe,{className:`w-3.5 h-3.5 mr-1 ${y?"animate-spin":""}`})," 刷新"]}),s.jsxs(X,{onClick:Q,disabled:m,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(bn,{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(([$,D])=>s.jsx("button",{type:"button",onClick:()=>n($),className:`px-4 py-2 rounded-lg text-sm transition-colors ${e===$?"bg-orange-500 text-white":"bg-[#0a1628] text-gray-400 hover:text-white"}`,children:D},$))}),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:te.length}),S.length!==te.length&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-1",children:["原始 ",S.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:Zx.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"&&J(w,"暂无已提交线索","用户通过场景提交后会出现于此。"),e==="contact"&&s.jsxs("div",{className:"space-y-2",children:[S.length>te.length&&s.jsxs("p",{className:"text-xs text-gray-500",children:["已合并 ",S.length-te.length," 条重复(同手机号或同用户 ID 仅保留最近一条)"]}),J(te,"暂无有联系方式线索","存客宝留资同步后显示;完整列表与筛选请前往「用户管理 → 获客列表」。")]}),e==="config"&&s.jsx("div",{className:"space-y-4",children:Zx.map($=>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:$.label}),s.jsx(Ve,{className:"bg-orange-500/20 text-orange-300 border-0 text-xs",children:$.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(ee,{className:"text-gray-500 text-xs",children:"API 地址"}),s.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:z[$.key].apiUrl,onChange:D=>F($.key,{apiUrl:D.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-500 text-xs",children:"API Key"}),s.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:z[$.key].apiKey,onChange:D=>F($.key,{apiKey:D.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-500 text-xs",children:"Source"}),s.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:z[$.key].source,onChange:D=>F($.key,{source:D.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-500 text-xs",children:"Tags"}),s.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:z[$.key].tags,onChange:D=>F($.key,{tags:D.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-500 text-xs",children:"SiteTags"}),s.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:z[$.key].siteTags,onChange:D=>F($.key,{siteTags:D.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ee,{className:"text-gray-500 text-xs",children:"说明备注"}),s.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:z[$.key].notes,onChange:D=>F($.key,{notes:D.target.value})})]})]})]},$.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(ll,{className:"w-4 h-4 text-gray-500 shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx(ee,{className:"text-gray-500 text-xs",children:"测试手机号"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:r,onChange:$=>a($.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(ee,{className:"text-gray-500 text-xs",children:"微信号(可选)"}),s.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:i,onChange:$=>o($.target.value)})]})]}),s.jsx("div",{className:"flex items-end",children:s.jsxs(X,{onClick:ie,className:"bg-orange-500 hover:bg-orange-600 text-white",children:[s.jsx(pi,{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:O.map(($,D)=>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:[$.status==="idle"&&s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-600 shrink-0"}),$.status==="testing"&&s.jsx(Fe,{className:"w-3 h-3 text-yellow-400 animate-spin shrink-0"}),$.status==="success"&&s.jsx(jj,{className:"w-3 h-3 text-green-400 shrink-0"}),$.status==="error"&&s.jsx(Sj,{className:"w-3 h-3 text-red-400 shrink-0"}),s.jsx("span",{className:"text-white text-xs truncate",children:$.label})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[$.responseTime!==void 0&&s.jsxs("span",{className:"text-gray-600 text-[10px]",children:[$.responseTime,"ms"]}),s.jsx("button",{type:"button",onClick:()=>re(D),disabled:$.status==="testing",className:"text-orange-400/60 hover:text-orange-400 text-[10px] disabled:opacity-50",children:"测试"})]})]},`${$.endpoint}-${D}`))})]}),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(fi,{className:"w-3 h-3"})," 打开外链"]})]}),s.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-400 leading-6",children:h||lj})]}),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:$=>u($.target.value),placeholder:"记录 Token、入口差异、回复率统计规则、对接约定等。"})]})]})]})})}const MV=[{id:"stats",label:"数据统计",icon:rc,desc:"匹配与获客概览"},{id:"partner",label:"找伙伴",icon:In,desc:"匹配池与记录"},{id:"resource",label:"资源对接",icon:V5,desc:"人脉资源"},{id:"mentor",label:"导师预约",icon:$5,desc:"预约与管理"},{id:"team",label:"团队招募",icon:hc,desc:"团队协作"}];function AV(){const[t,e]=b.useState("stats"),[n,r]=b.useState(!1),[a,i]=b.useState("overview");return s.jsxs("div",{className:"p-8 w-full 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(In,{className:"w-5 h-5 text-[#38bdac]"}),"找伙伴"]}),s.jsx("p",{className:"text-gray-500 text-sm mt-0.5",children:"匹配、获客、导师与团队管理"})]}),s.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:()=>r(o=>!o),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(ya,{className:"w-3.5 h-3.5 mr-1.5"}),"存客宝",s.jsx(Xo,{className:`w-3 h-3 ml-1 transition-transform ${n?"rotate-90":""}`})]})]}),n&&s.jsx(EV,{initialTab:a}),s.jsx("div",{className:"flex gap-1 mb-6 bg-[#0a1628] rounded-lg p-1 border border-gray-700/40",children:MV.map(o=>{const c=t===o.id;return s.jsxs("button",{type:"button",onClick:()=>e(o.id),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2 rounded-md text-sm transition-all ${c?"bg-[#38bdac] text-white shadow-md":"text-gray-400 hover:text-white hover:bg-gray-700/40"}`,children:[s.jsx(o.icon,{className:"w-3.5 h-3.5"}),o.label]},o.id)})}),t==="stats"&&s.jsx(CV,{onSwitchTab:o=>e(o),onOpenCKB:o=>{i(o||"overview"),r(!0)}}),t==="partner"&&s.jsx(vV,{}),t==="resource"&&s.jsx(NV,{}),t==="mentor"&&s.jsx(kV,{}),t==="team"&&s.jsx(SV,{})]})}function IV(){const t=vo();return s.jsx("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-8",children:s.jsxs("div",{className:"text-center max-w-md",children:[s.jsx("div",{className:"inline-flex items-center justify-center w-20 h-20 rounded-full bg-red-500/20 text-red-400 mb-6",children:s.jsx(wj,{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(X,{asChild:!0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:s.jsxs(bc,{to:"/",children:[s.jsx(Y5,{className:"w-4 h-4 mr-2"}),"返回首页"]})})]})})}function RV(){return s.jsxs(OE,{children:[s.jsx(nn,{path:"/login",element:s.jsx(AI,{})}),s.jsxs(nn,{path:"/",element:s.jsx(PA,{}),children:[s.jsx(nn,{index:!0,element:s.jsx(oh,{to:"/dashboard",replace:!0})}),s.jsx(nn,{path:"dashboard",element:s.jsx(HP,{})}),s.jsx(nn,{path:"orders",element:s.jsx(UP,{})}),s.jsx(nn,{path:"users",element:s.jsx(QP,{})}),s.jsx(nn,{path:"distribution",element:s.jsx(y8,{})}),s.jsx(nn,{path:"withdrawals",element:s.jsx(b8,{})}),s.jsx(nn,{path:"content",element:s.jsx(J9,{})}),s.jsx(nn,{path:"referral-settings",element:s.jsx(f2,{})}),s.jsx(nn,{path:"author-settings",element:s.jsx(oh,{to:"/settings?tab=author",replace:!0})}),s.jsx(nn,{path:"vip-roles",element:s.jsx(mV,{})}),s.jsx(nn,{path:"mentors",element:s.jsx(x4,{})}),s.jsx(nn,{path:"mentor-consultations",element:s.jsx(xV,{})}),s.jsx(nn,{path:"admin-users",element:s.jsx(oh,{to:"/settings?tab=admin",replace:!0})}),s.jsx(nn,{path:"settings",element:s.jsx(aV,{})}),s.jsx(nn,{path:"payment",element:s.jsx(iV,{})}),s.jsx(nn,{path:"site",element:s.jsx(dV,{})}),s.jsx(nn,{path:"qrcodes",element:s.jsx(uV,{})}),s.jsx(nn,{path:"find-partner",element:s.jsx(AV,{})}),s.jsx(nn,{path:"match",element:s.jsx(fV,{})}),s.jsx(nn,{path:"match-records",element:s.jsx(pV,{})}),s.jsx(nn,{path:"api-doc",element:s.jsx(oh,{to:"/api-docs",replace:!0})}),s.jsx(nn,{path:"api-docs",element:s.jsx(m4,{})})]}),s.jsx(nn,{path:"*",element:s.jsx(IV,{})})]})}$T.createRoot(document.getElementById("root")).render(s.jsx(b.StrictMode,{children:s.jsx(VE,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:s.jsx(RV,{})})})); diff --git a/soul-admin/dist/assets/index-DXojA1Za.css b/soul-admin/dist/assets/index-qjssBjc3.css similarity index 92% rename from soul-admin/dist/assets/index-DXojA1Za.css rename to soul-admin/dist/assets/index-qjssBjc3.css index ab8f9dad..22f0085b 100644 --- a/soul-admin/dist/assets/index-DXojA1Za.css +++ b/soul-admin/dist/assets/index-qjssBjc3.css @@ -1 +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-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-orange-300:oklch(83.7% .128 66.29);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-600:oklch(64.6% .222 41.116);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-yellow-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-sky-200:oklch(90.1% .058 230.902);--color-sky-300:oklch(82.8% .111 230.318);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--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;--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-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-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-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-\[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-\[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-\[72px\]{width:72px}.w-\[100px\]{width:100px}.w-\[280px\]{width:280px}.w-fit{width:fit-content}.w-full{width:100%}.w-screen{width:100vw}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-7xl{max-width:var(--container-7xl)}.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-\[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-\[120px\]{min-width:120px}.min-w-\[200px\]{min-width:200px}.min-w-\[220px\]{min-width:220px}.min-w-\[1024px\]{min-width:1024px}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.caption-bottom{caption-side:bottom}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-1\/2{--tw-translate-x: 50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-y-0{--tw-translate-y:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-none{translate:none}.scale-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}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-pointer{cursor:pointer}.touch-pinch-zoom{--tw-pinch-zoom:pinch-zoom;touch-action:var(--tw-pan-x,)var(--tw-pan-y,)var(--tw-pinch-zoom,)}.touch-none{touch-action:none}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.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}.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-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-none{border-radius:0}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-s{border-start-start-radius:.25rem;border-end-start-radius:.25rem}.rounded-ss{border-start-start-radius:.25rem}.rounded-e{border-start-end-radius:.25rem;border-end-end-radius:.25rem}.rounded-se{border-start-end-radius:.25rem}.rounded-ee{border-end-end-radius:.25rem}.rounded-es{border-end-start-radius:.25rem}.rounded-t{border-top-left-radius:.25rem;border-top-right-radius:.25rem}.rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-tl{border-top-left-radius:.25rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.rounded-r-md{border-top-right-radius:var(--radius-md);border-bottom-right-radius:var(--radius-md)}.rounded-tr{border-top-right-radius:.25rem}.rounded-b{border-bottom-right-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-br{border-bottom-right-radius:.25rem}.rounded-bl{border-bottom-left-radius:.25rem}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-x{border-inline-style:var(--tw-border-style);border-inline-width:1px}.border-y{border-block-style:var(--tw-border-style);border-block-width:1px}.border-s{border-inline-start-style:var(--tw-border-style);border-inline-start-width:1px}.border-e{border-inline-end-style:var(--tw-border-style);border-inline-end-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-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-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-gray-500{border-color:var(--color-gray-500)}.border-gray-600{border-color:var(--color-gray-600)}.border-gray-700{border-color:var(--color-gray-700)}.border-gray-700\/30{border-color:#3641534d}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/30{border-color:color-mix(in oklab,var(--color-gray-700)30%,transparent)}}.border-gray-700\/40{border-color:#36415366}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/40{border-color:color-mix(in oklab,var(--color-gray-700)40%,transparent)}}.border-gray-700\/50{border-color:#36415380}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/50{border-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}.border-gray-700\/60{border-color:#36415399}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/60{border-color:color-mix(in oklab,var(--color-gray-700)60%,transparent)}}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500)30%,transparent)}}.border-green-500\/40{border-color:#00c75866}@supports (color:color-mix(in lab,red,red)){.border-green-500\/40{border-color:color-mix(in oklab,var(--color-green-500)40%,transparent)}}.border-inherit{border-color:inherit}.border-orange-500\/20{border-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/20{border-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.border-orange-500\/30{border-color:#fe6e004d}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/30{border-color:color-mix(in oklab,var(--color-orange-500)30%,transparent)}}.border-orange-500\/40{border-color:#fe6e0066}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/40{border-color:color-mix(in oklab,var(--color-orange-500)40%,transparent)}}.border-orange-500\/50{border-color:#fe6e0080}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/50{border-color:color-mix(in oklab,var(--color-orange-500)50%,transparent)}}.border-purple-500\/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\/50{border-color:#fb2c3680}@supports (color:color-mix(in lab,red,red)){.border-red-500\/50{border-color:color-mix(in oklab,var(--color-red-500)50%,transparent)}}.border-red-600\/50{border-color:#e4001480}@supports (color:color-mix(in lab,red,red)){.border-red-600\/50{border-color:color-mix(in oklab,var(--color-red-600)50%,transparent)}}.border-transparent{border-color:#0000}.border-white\/5{border-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.border-white\/5{border-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.border-white\/20{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.border-white\/20{border-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.border-yellow-500\/30{border-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/30{border-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.border-yellow-500\/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-\[\#0b1828\]{background-color:#0b1828}.bg-\[\#0f2137\]{background-color:#0f2137}.bg-\[\#0f2137\]\/90{background-color:#0f2137e6}.bg-\[\#00CED1\]{background-color:#00ced1}.bg-\[\#1C1C1E\]{background-color:#1c1c1e}.bg-\[\#07C160\]{background-color:#07c160}.bg-\[\#07C160\]\/5{background-color:#07c1600d}.bg-\[\#07C160\]\/10{background-color:#07c1601a}.bg-\[\#38bdac\]{background-color:#38bdac}.bg-\[\#38bdac\]\/5{background-color:#38bdac0d}.bg-\[\#38bdac\]\/10{background-color:#38bdac1a}.bg-\[\#38bdac\]\/15{background-color:#38bdac26}.bg-\[\#38bdac\]\/20{background-color:#38bdac33}.bg-\[\#38bdac\]\/30{background-color:#38bdac4d}.bg-\[\#38bdac\]\/60{background-color:#38bdac99}.bg-\[\#38bdac\]\/80{background-color:#38bdaccc}.bg-\[\#050c18\]{background-color:#050c18}.bg-\[\#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-black{background-color:var(--color-black)}.bg-black\/30{background-color:#0000004d}@supports (color:color-mix(in lab,red,red)){.bg-black\/30{background-color:color-mix(in oklab,var(--color-black)30%,transparent)}}.bg-black\/40{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.bg-black\/40{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black)60%,transparent)}}.bg-black\/90{background-color:#000000e6}@supports (color:color-mix(in lab,red,red)){.bg-black\/90{background-color:color-mix(in oklab,var(--color-black)90%,transparent)}}.bg-blue-500{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\/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-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\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.bg-red-600{background-color:var(--color-red-600)}.bg-red-900\/80{background-color:#82181acc}@supports (color:color-mix(in lab,red,red)){.bg-red-900\/80{background-color:color-mix(in oklab,var(--color-red-900)80%,transparent)}}.bg-transparent{background-color:#0000}.bg-white{background-color:var(--color-white)}.bg-white\/5{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.bg-white\/5{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.bg-white\/10{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.bg-white\/10{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.bg-white\/20{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.bg-white\/20{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.bg-yellow-500{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-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-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-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-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-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-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}.wrap-break-word{overflow-wrap:break-word}.break-all{word-break:break-all}.text-clip{text-overflow:clip}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[\#00CED1\]{color:#00ced1}.text-\[\#07C160\]{color:#07c160}.text-\[\#07C160\]\/60{color:#07c16099}.text-\[\#07C160\]\/70{color:#07c160b3}.text-\[\#07C160\]\/80{color:#07c160cc}.text-\[\#26A17B\]{color:#26a17b}.text-\[\#38bdac\]{color:#38bdac}.text-\[\#38bdac\]\/20{color:#38bdac33}.text-\[\#38bdac\]\/30{color:#38bdac4d}.text-\[\#38bdac\]\/40{color:#38bdac66}.text-\[\#38bdac\]\/90{color:#38bdace6}.text-\[\#169BD7\]{color:#169bd7}.text-\[\#1677FF\]{color:#1677ff}.text-\[\#FFD700\]{color:gold}.text-amber-200{color:var(--color-amber-200)}.text-amber-200\/80{color:#fee685cc}@supports (color:color-mix(in lab,red,red)){.text-amber-200\/80{color:color-mix(in oklab,var(--color-amber-200)80%,transparent)}}.text-amber-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-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-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\/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-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\/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-300{color:var(--color-red-300)}.text-red-400{color:var(--color-red-400)}.text-rose-400{color:var(--color-rose-400)}.text-sky-300{color:var(--color-sky-300)}.text-white{color:var(--color-white)}.text-white\/40{color:#fff6}@supports (color:color-mix(in lab,red,red)){.text-white\/40{color:color-mix(in oklab,var(--color-white)40%,transparent)}}.text-white\/60{color:#fff9}@supports (color:color-mix(in lab,red,red)){.text-white\/60{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.text-white\/70{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.text-white\/80{color:#fffc}@supports (color:color-mix(in lab,red,red)){.text-white\/80{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.text-yellow-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}.underline-offset-4{text-underline-offset:4px}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.subpixel-antialiased{-webkit-font-smoothing:auto;-moz-osx-font-smoothing:auto}.accent-\[\#38bdac\]{accent-color:#38bdac}.opacity-0{opacity:0}.opacity-50{opacity:.5}.opacity-55{opacity:.55}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-0{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(0px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.inset-ring{--tw-inset-ring-shadow:inset 0 0 0 1px var(--tw-inset-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[\#38bdac\]\/20{--tw-shadow-color:#38bdac33}@supports (color:color-mix(in lab,red,red)){.shadow-\[\#38bdac\]\/20{--tw-shadow-color:color-mix(in oklab,oklab(72.378% -.11483 -.0053193/.2) var(--tw-shadow-alpha),transparent)}}.shadow-\[\#38bdac\]\/30{--tw-shadow-color:#38bdac4d}@supports (color:color-mix(in lab,red,red)){.shadow-\[\#38bdac\]\/30{--tw-shadow-color:color-mix(in oklab,oklab(72.378% -.11483 -.0053193/.3) var(--tw-shadow-alpha),transparent)}}.ring-\[\#38bdac\]{--tw-ring-color:#38bdac}.ring-\[\#38bdac\]\/40{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.4)}.ring-\[\#38bdac\]\/50{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.5)}.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-none{-webkit-user-select:none;user-select:none}:where(.divide-x-reverse>:not(:last-child)){--tw-divide-x-reverse:1}.ring-inset{--tw-ring-inset:inset}.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)}.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\]\/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-\[\#1a3050\]:hover{background-color:#1a3050}.hover\:bg-\[\#2da396\]:hover{background-color:#2da396}.hover\:bg-\[\#06AD51\]:hover{background-color:#06ad51}.hover\:bg-\[\#07C160\]\/10:hover{background-color:#07c1601a}.hover\:bg-\[\#20B2AA\]:hover{background-color:#20b2aa}.hover\:bg-\[\#38bdac\]\/10:hover{background-color:#38bdac1a}.hover\:bg-\[\#38bdac\]\/20:hover{background-color:#38bdac33}.hover\:bg-\[\#162840\]:hover{background-color:#162840}.hover\:bg-\[\#162840\]\/30:hover{background-color:#1628404d}.hover\:bg-\[\#162840\]\/50:hover{background-color:#16284080}.hover\:bg-amber-500\/10:hover{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/10:hover{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.hover\:bg-amber-500\/20:hover{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/20:hover{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.hover\:bg-amber-600:hover{background-color:var(--color-amber-600)}.hover\:bg-blue-400\/10:hover{background-color:#54a2ff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-400\/10:hover{background-color:color-mix(in oklab,var(--color-blue-400)10%,transparent)}}.hover\:bg-blue-500\/20:hover{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-500\/20:hover{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.hover\:bg-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\/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-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-blue-300:hover{color:var(--color-blue-300)}.hover\:text-blue-400:hover{color:var(--color-blue-400)}.hover\:text-gray-300:hover{color:var(--color-gray-300)}.hover\:text-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-\[\#38bdac\]\/20:focus{background-color:#38bdac33}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-\[\#38bdac\]:focus{--tw-ring-color:#38bdac}.focus\:ring-amber-400:focus{--tw-ring-color:var(--color-amber-400)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\:ring-0:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(0px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-\[3px\]:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(3px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-\[\#38bdac\]:focus-visible{--tw-ring-color:#38bdac}.focus-visible\:ring-red-500:focus-visible{--tw-ring-color:var(--color-red-500)}.focus-visible\:ring-offset-0:focus-visible{--tw-ring-offset-width:0px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus-visible\:ring-offset-2:focus-visible{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus-visible\:ring-offset-\[\#0a1628\]:focus-visible{--tw-ring-offset-color:#0a1628}.focus-visible\:outline-none:focus-visible{--tw-outline-style:none;outline-style:none}.active\:cursor-grabbing:active{cursor:grabbing}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.has-\[\>svg\]\:px-2\.5:has(>svg){padding-inline:calc(var(--spacing)*2.5)}.has-\[\>svg\]\:px-3:has(>svg){padding-inline:calc(var(--spacing)*3)}.has-\[\>svg\]\:px-4:has(>svg){padding-inline:calc(var(--spacing)*4)}.data-\[disabled\]\:pointer-events-none[data-disabled]{pointer-events:none}.data-\[disabled\]\:opacity-50[data-disabled]{opacity:.5}.data-\[side\=bottom\]\:translate-y-1[data-side=bottom]{--tw-translate-y:calc(var(--spacing)*1);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=active\]\:bg-\[\#07C160\]\/20[data-state=active]{background-color:#07c16033}.data-\[state\=active\]\:bg-\[\#26A17B\]\/20[data-state=active]{background-color:#26a17b33}.data-\[state\=active\]\:bg-\[\#38bdac\]\/20[data-state=active]{background-color:#38bdac33}.data-\[state\=active\]\:bg-\[\#1677FF\]\/20[data-state=active]{background-color:#1677ff33}.data-\[state\=active\]\:bg-\[\#003087\]\/20[data-state=active]{background-color:#00308733}.data-\[state\=active\]\:bg-amber-500\/20[data-state=active]{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.data-\[state\=active\]\:bg-amber-500\/20[data-state=active]{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.data-\[state\=active\]\:bg-purple-500\/20[data-state=active]{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.data-\[state\=active\]\:bg-purple-500\/20[data-state=active]{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.data-\[state\=active\]\:font-medium[data-state=active]{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.data-\[state\=active\]\:text-\[\#07C160\][data-state=active]{color:#07c160}.data-\[state\=active\]\:text-\[\#26A17B\][data-state=active]{color:#26a17b}.data-\[state\=active\]\:text-\[\#38bdac\][data-state=active]{color:#38bdac}.data-\[state\=active\]\:text-\[\#169BD7\][data-state=active]{color:#169bd7}.data-\[state\=active\]\:text-\[\#1677FF\][data-state=active]{color:#1677ff}.data-\[state\=active\]\:text-amber-400[data-state=active]{color:var(--color-amber-400)}.data-\[state\=active\]\:text-purple-400[data-state=active]{color:var(--color-purple-400)}.data-\[state\=active\]\:shadow[data-state=active]{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.data-\[state\=checked\]\:translate-x-4[data-state=checked]{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=checked\]\:bg-\[\#38bdac\][data-state=checked]{background-color:#38bdac}.data-\[state\=unchecked\]\:translate-x-0[data-state=unchecked]{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=unchecked\]\:bg-gray-600[data-state=unchecked]{background-color:var(--color-gray-600)}@media(min-width:40rem){.sm\:col-span-2{grid-column:span 2/span 2}.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\: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))}}.\[\&_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)}} +.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-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-orange-300:oklch(83.7% .128 66.29);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-600:oklch(64.6% .222 41.116);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-yellow-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-sky-200:oklch(90.1% .058 230.902);--color-sky-300:oklch(82.8% .111 230.318);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--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;--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-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-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-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-\[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-\[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-\[72px\]{width:72px}.w-\[100px\]{width:100px}.w-\[280px\]{width:280px}.w-fit{width:fit-content}.w-full{width:100%}.w-screen{width:100vw}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-7xl{max-width:var(--container-7xl)}.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-\[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-\[120px\]{min-width:120px}.min-w-\[200px\]{min-width:200px}.min-w-\[220px\]{min-width:220px}.min-w-\[1024px\]{min-width:1024px}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.caption-bottom{caption-side:bottom}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-1\/2{--tw-translate-x: 50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-y-0{--tw-translate-y:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-none{translate:none}.scale-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}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-pointer{cursor:pointer}.touch-pinch-zoom{--tw-pinch-zoom:pinch-zoom;touch-action:var(--tw-pan-x,)var(--tw-pan-y,)var(--tw-pinch-zoom,)}.touch-none{touch-action:none}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.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}.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-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-none{border-radius:0}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-s{border-start-start-radius:.25rem;border-end-start-radius:.25rem}.rounded-ss{border-start-start-radius:.25rem}.rounded-e{border-start-end-radius:.25rem;border-end-end-radius:.25rem}.rounded-se{border-start-end-radius:.25rem}.rounded-ee{border-end-end-radius:.25rem}.rounded-es{border-end-start-radius:.25rem}.rounded-t{border-top-left-radius:.25rem;border-top-right-radius:.25rem}.rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-tl{border-top-left-radius:.25rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.rounded-r-md{border-top-right-radius:var(--radius-md);border-bottom-right-radius:var(--radius-md)}.rounded-tr{border-top-right-radius:.25rem}.rounded-b{border-bottom-right-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-br{border-bottom-right-radius:.25rem}.rounded-bl{border-bottom-left-radius:.25rem}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-x{border-inline-style:var(--tw-border-style);border-inline-width:1px}.border-y{border-block-style:var(--tw-border-style);border-block-width:1px}.border-s{border-inline-start-style:var(--tw-border-style);border-inline-start-width:1px}.border-e{border-inline-end-style:var(--tw-border-style);border-inline-end-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-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-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-gray-500{border-color:var(--color-gray-500)}.border-gray-600{border-color:var(--color-gray-600)}.border-gray-700{border-color:var(--color-gray-700)}.border-gray-700\/30{border-color:#3641534d}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/30{border-color:color-mix(in oklab,var(--color-gray-700)30%,transparent)}}.border-gray-700\/40{border-color:#36415366}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/40{border-color:color-mix(in oklab,var(--color-gray-700)40%,transparent)}}.border-gray-700\/50{border-color:#36415380}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/50{border-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}.border-gray-700\/60{border-color:#36415399}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/60{border-color:color-mix(in oklab,var(--color-gray-700)60%,transparent)}}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500)30%,transparent)}}.border-green-500\/40{border-color:#00c75866}@supports (color:color-mix(in lab,red,red)){.border-green-500\/40{border-color:color-mix(in oklab,var(--color-green-500)40%,transparent)}}.border-inherit{border-color:inherit}.border-orange-500\/20{border-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/20{border-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.border-orange-500\/30{border-color:#fe6e004d}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/30{border-color:color-mix(in oklab,var(--color-orange-500)30%,transparent)}}.border-orange-500\/40{border-color:#fe6e0066}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/40{border-color:color-mix(in oklab,var(--color-orange-500)40%,transparent)}}.border-orange-500\/50{border-color:#fe6e0080}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/50{border-color:color-mix(in oklab,var(--color-orange-500)50%,transparent)}}.border-purple-500\/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\/50{border-color:#fb2c3680}@supports (color:color-mix(in lab,red,red)){.border-red-500\/50{border-color:color-mix(in oklab,var(--color-red-500)50%,transparent)}}.border-red-600\/50{border-color:#e4001480}@supports (color:color-mix(in lab,red,red)){.border-red-600\/50{border-color:color-mix(in oklab,var(--color-red-600)50%,transparent)}}.border-transparent{border-color:#0000}.border-white\/5{border-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.border-white\/5{border-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.border-white\/20{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.border-white\/20{border-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.border-yellow-500\/30{border-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/30{border-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.border-yellow-500\/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-\[\#0b1828\]{background-color:#0b1828}.bg-\[\#0f2137\]{background-color:#0f2137}.bg-\[\#0f2137\]\/90{background-color:#0f2137e6}.bg-\[\#00CED1\]{background-color:#00ced1}.bg-\[\#1C1C1E\]{background-color:#1c1c1e}.bg-\[\#07C160\]{background-color:#07c160}.bg-\[\#07C160\]\/5{background-color:#07c1600d}.bg-\[\#07C160\]\/10{background-color:#07c1601a}.bg-\[\#38bdac\]{background-color:#38bdac}.bg-\[\#38bdac\]\/5{background-color:#38bdac0d}.bg-\[\#38bdac\]\/10{background-color:#38bdac1a}.bg-\[\#38bdac\]\/15{background-color:#38bdac26}.bg-\[\#38bdac\]\/20{background-color:#38bdac33}.bg-\[\#38bdac\]\/30{background-color:#38bdac4d}.bg-\[\#38bdac\]\/60{background-color:#38bdac99}.bg-\[\#38bdac\]\/80{background-color:#38bdaccc}.bg-\[\#050c18\]{background-color:#050c18}.bg-\[\#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-black{background-color:var(--color-black)}.bg-black\/30{background-color:#0000004d}@supports (color:color-mix(in lab,red,red)){.bg-black\/30{background-color:color-mix(in oklab,var(--color-black)30%,transparent)}}.bg-black\/40{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.bg-black\/40{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black)60%,transparent)}}.bg-black\/90{background-color:#000000e6}@supports (color:color-mix(in lab,red,red)){.bg-black\/90{background-color:color-mix(in oklab,var(--color-black)90%,transparent)}}.bg-blue-500{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\/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-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\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.bg-red-600{background-color:var(--color-red-600)}.bg-red-900\/80{background-color:#82181acc}@supports (color:color-mix(in lab,red,red)){.bg-red-900\/80{background-color:color-mix(in oklab,var(--color-red-900)80%,transparent)}}.bg-transparent{background-color:#0000}.bg-white{background-color:var(--color-white)}.bg-white\/5{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.bg-white\/5{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.bg-white\/10{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.bg-white\/10{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.bg-white\/20{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.bg-white\/20{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.bg-yellow-500{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-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-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-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-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-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}.wrap-break-word{overflow-wrap:break-word}.break-all{word-break:break-all}.text-clip{text-overflow:clip}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[\#00CED1\]{color:#00ced1}.text-\[\#07C160\]{color:#07c160}.text-\[\#07C160\]\/60{color:#07c16099}.text-\[\#07C160\]\/70{color:#07c160b3}.text-\[\#07C160\]\/80{color:#07c160cc}.text-\[\#26A17B\]{color:#26a17b}.text-\[\#38bdac\]{color:#38bdac}.text-\[\#38bdac\]\/20{color:#38bdac33}.text-\[\#38bdac\]\/30{color:#38bdac4d}.text-\[\#38bdac\]\/40{color:#38bdac66}.text-\[\#38bdac\]\/90{color:#38bdace6}.text-\[\#169BD7\]{color:#169bd7}.text-\[\#1677FF\]{color:#1677ff}.text-\[\#FFD700\]{color:gold}.text-amber-200{color:var(--color-amber-200)}.text-amber-200\/80{color:#fee685cc}@supports (color:color-mix(in lab,red,red)){.text-amber-200\/80{color:color-mix(in oklab,var(--color-amber-200)80%,transparent)}}.text-amber-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-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\/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\/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-300{color:var(--color-red-300)}.text-red-400{color:var(--color-red-400)}.text-rose-400{color:var(--color-rose-400)}.text-sky-300{color:var(--color-sky-300)}.text-white{color:var(--color-white)}.text-white\/40{color:#fff6}@supports (color:color-mix(in lab,red,red)){.text-white\/40{color:color-mix(in oklab,var(--color-white)40%,transparent)}}.text-white\/60{color:#fff9}@supports (color:color-mix(in lab,red,red)){.text-white\/60{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.text-white\/70{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.text-white\/80{color:#fffc}@supports (color:color-mix(in lab,red,red)){.text-white\/80{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.text-yellow-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}.underline-offset-4{text-underline-offset:4px}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.subpixel-antialiased{-webkit-font-smoothing:auto;-moz-osx-font-smoothing:auto}.accent-\[\#38bdac\]{accent-color:#38bdac}.opacity-0{opacity:0}.opacity-50{opacity:.5}.opacity-55{opacity:.55}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-0{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(0px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.inset-ring{--tw-inset-ring-shadow:inset 0 0 0 1px var(--tw-inset-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[\#38bdac\]\/20{--tw-shadow-color:#38bdac33}@supports (color:color-mix(in lab,red,red)){.shadow-\[\#38bdac\]\/20{--tw-shadow-color:color-mix(in oklab,oklab(72.378% -.11483 -.0053193/.2) var(--tw-shadow-alpha),transparent)}}.shadow-\[\#38bdac\]\/30{--tw-shadow-color:#38bdac4d}@supports (color:color-mix(in lab,red,red)){.shadow-\[\#38bdac\]\/30{--tw-shadow-color:color-mix(in oklab,oklab(72.378% -.11483 -.0053193/.3) var(--tw-shadow-alpha),transparent)}}.ring-\[\#38bdac\]{--tw-ring-color:#38bdac}.ring-\[\#38bdac\]\/40{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.4)}.ring-\[\#38bdac\]\/50{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.5)}.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-none{-webkit-user-select:none;user-select:none}:where(.divide-x-reverse>:not(:last-child)){--tw-divide-x-reverse:1}.ring-inset{--tw-ring-inset:inset}.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)}.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\]\/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-\[\#1a3050\]:hover{background-color:#1a3050}.hover\:bg-\[\#2da396\]:hover{background-color:#2da396}.hover\:bg-\[\#06AD51\]:hover{background-color:#06ad51}.hover\:bg-\[\#07C160\]\/10:hover{background-color:#07c1601a}.hover\:bg-\[\#20B2AA\]:hover{background-color:#20b2aa}.hover\:bg-\[\#38bdac\]\/10:hover{background-color:#38bdac1a}.hover\:bg-\[\#38bdac\]\/20:hover{background-color:#38bdac33}.hover\:bg-\[\#162840\]:hover{background-color:#162840}.hover\:bg-\[\#162840\]\/30:hover{background-color:#1628404d}.hover\:bg-\[\#162840\]\/50:hover{background-color:#16284080}.hover\:bg-amber-500\/10:hover{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/10:hover{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.hover\:bg-amber-500\/20:hover{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/20:hover{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.hover\:bg-amber-600:hover{background-color:var(--color-amber-600)}.hover\:bg-blue-400\/10:hover{background-color:#54a2ff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-400\/10:hover{background-color:color-mix(in oklab,var(--color-blue-400)10%,transparent)}}.hover\:bg-blue-500\/20:hover{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-500\/20:hover{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.hover\:bg-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\/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-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-blue-300:hover{color:var(--color-blue-300)}.hover\:text-blue-400:hover{color:var(--color-blue-400)}.hover\:text-gray-300:hover{color:var(--color-gray-300)}.hover\:text-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-\[\#38bdac\]\/20:focus{background-color:#38bdac33}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-\[\#38bdac\]:focus{--tw-ring-color:#38bdac}.focus\:ring-amber-400:focus{--tw-ring-color:var(--color-amber-400)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\:ring-0:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(0px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-\[3px\]:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(3px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-\[\#38bdac\]:focus-visible{--tw-ring-color:#38bdac}.focus-visible\:ring-red-500:focus-visible{--tw-ring-color:var(--color-red-500)}.focus-visible\:ring-offset-0:focus-visible{--tw-ring-offset-width:0px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus-visible\:ring-offset-2:focus-visible{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus-visible\:ring-offset-\[\#0a1628\]:focus-visible{--tw-ring-offset-color:#0a1628}.focus-visible\:outline-none:focus-visible{--tw-outline-style:none;outline-style:none}.active\:cursor-grabbing:active{cursor:grabbing}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.has-\[\>svg\]\:px-2\.5:has(>svg){padding-inline:calc(var(--spacing)*2.5)}.has-\[\>svg\]\:px-3:has(>svg){padding-inline:calc(var(--spacing)*3)}.has-\[\>svg\]\:px-4:has(>svg){padding-inline:calc(var(--spacing)*4)}.data-\[disabled\]\:pointer-events-none[data-disabled]{pointer-events:none}.data-\[disabled\]\:opacity-50[data-disabled]{opacity:.5}.data-\[side\=bottom\]\:translate-y-1[data-side=bottom]{--tw-translate-y:calc(var(--spacing)*1);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=active\]\:bg-\[\#07C160\]\/20[data-state=active]{background-color:#07c16033}.data-\[state\=active\]\:bg-\[\#26A17B\]\/20[data-state=active]{background-color:#26a17b33}.data-\[state\=active\]\:bg-\[\#38bdac\]\/20[data-state=active]{background-color:#38bdac33}.data-\[state\=active\]\:bg-\[\#1677FF\]\/20[data-state=active]{background-color:#1677ff33}.data-\[state\=active\]\:bg-\[\#003087\]\/20[data-state=active]{background-color:#00308733}.data-\[state\=active\]\:bg-amber-500\/20[data-state=active]{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.data-\[state\=active\]\:bg-amber-500\/20[data-state=active]{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.data-\[state\=active\]\:bg-purple-500\/20[data-state=active]{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.data-\[state\=active\]\:bg-purple-500\/20[data-state=active]{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.data-\[state\=active\]\:font-medium[data-state=active]{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.data-\[state\=active\]\:text-\[\#07C160\][data-state=active]{color:#07c160}.data-\[state\=active\]\:text-\[\#26A17B\][data-state=active]{color:#26a17b}.data-\[state\=active\]\:text-\[\#38bdac\][data-state=active]{color:#38bdac}.data-\[state\=active\]\:text-\[\#169BD7\][data-state=active]{color:#169bd7}.data-\[state\=active\]\:text-\[\#1677FF\][data-state=active]{color:#1677ff}.data-\[state\=active\]\:text-amber-400[data-state=active]{color:var(--color-amber-400)}.data-\[state\=active\]\:text-purple-400[data-state=active]{color:var(--color-purple-400)}.data-\[state\=active\]\:shadow[data-state=active]{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.data-\[state\=checked\]\:translate-x-4[data-state=checked]{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=checked\]\:bg-\[\#38bdac\][data-state=checked]{background-color:#38bdac}.data-\[state\=unchecked\]\:translate-x-0[data-state=unchecked]{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=unchecked\]\:bg-gray-600[data-state=unchecked]{background-color:var(--color-gray-600)}@media(min-width:40rem){.sm\:col-span-2{grid-column:span 2/span 2}.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\: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))}}.\[\&_svg\]\:pointer-events-none svg{pointer-events:none}.\[\&_svg\]\:shrink-0 svg{flex-shrink:0}.\[\&_svg\:not\(\[class\*\=\'size-\'\]\)\]\:size-4 svg:not([class*=size-]){width:calc(var(--spacing)*4);height:calc(var(--spacing)*4)}.\[\&_tr\]\:border-b tr{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.\[\&_tr\:last-child\]\:border-0 tr:last-child{border-style:var(--tw-border-style);border-width:0}.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-0:has([role=checkbox]){padding-right:calc(var(--spacing)*0)}.\[\&\>span\]\:line-clamp-1>span{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}}:root{--background:oklch(14.5% 0 0);--foreground:oklch(98.5% 0 0);--card:oklch(20% .02 240);--card-foreground:oklch(98.5% 0 0);--popover:oklch(20% .02 240);--popover-foreground:oklch(98.5% 0 0);--primary:oklch(65% .15 180);--primary-foreground:oklch(20% 0 0);--secondary:oklch(27% 0 0);--secondary-foreground:oklch(98.5% 0 0);--muted:oklch(27% 0 0);--muted-foreground:oklch(65% 0 0);--accent:oklch(27% 0 0);--accent-foreground:oklch(98.5% 0 0);--destructive:oklch(55% .2 25);--destructive-foreground:oklch(98.5% 0 0);--border:oklch(35% 0 0);--input:oklch(35% 0 0);--ring:oklch(65% .15 180);--radius:.625rem}body{font-family:var(--font-sans);color:var(--foreground);background:#0a1628}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-pan-x{syntax:"*";inherits:false}@property --tw-pan-y{syntax:"*";inherits:false}@property --tw-pinch-zoom{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-space-x-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-x-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}} diff --git a/soul-admin/dist/index.html b/soul-admin/dist/index.html index c2aa887c..7a939dad 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 5e8ccea1..7e2d0480 100644 --- a/soul-admin/src/components/RichEditor.tsx +++ b/soul-admin/src/components/RichEditor.tsx @@ -37,9 +37,11 @@ export interface LinkTagItem { label: string aliases?: string url: string - type: 'url' | 'miniprogram' | 'ckb' + type: 'url' | 'miniprogram' | 'ckb' | 'wxlink' appId?: string pagePath?: string + /** 管理端列表用:库内是否已存目标小程序 AppSecret(接口不下发明文) */ + hasAppSecret?: boolean } /** 插入附件 HTML 时转义,防 XSS */ diff --git a/soul-admin/src/pages/content/ContentPage.tsx b/soul-admin/src/pages/content/ContentPage.tsx index 05f350fe..7813933c 100644 --- a/soul-admin/src/pages/content/ContentPage.tsx +++ b/soul-admin/src/pages/content/ContentPage.tsx @@ -260,8 +260,9 @@ export function ContentPage() { label: '', aliases: '', url: '', - type: 'url' as 'url' | 'miniprogram' | 'ckb', + type: 'url' as 'url' | 'miniprogram' | 'ckb' | 'wxlink', appId: '', + appSecret: '', pagePath: '', }) const [linkTagSaving, setLinkTagSaving] = useState(false) @@ -537,7 +538,15 @@ export function ContentPage() { try { const data = await get<{ success?: boolean - linkTags?: { tagId: string; label: string; url: string; type: string; appId?: string; pagePath?: string }[] + linkTags?: { + tagId: string + label: string + url: string + type: string + appId?: string + pagePath?: string + hasAppSecret?: boolean + }[] }>('/api/db/link-tags') if (data?.success && data.linkTags) { setLinkTags( @@ -545,9 +554,10 @@ export function ContentPage() { id: t.tagId, label: t.label, url: t.url, - type: (t.type || 'url') as 'url' | 'miniprogram' | 'ckb', + type: (t.type || 'url') as 'url' | 'miniprogram' | 'ckb' | 'wxlink', appId: t.appId || '', pagePath: t.pagePath || '', + hasAppSecret: !!t.hasAppSecret, })), ) } @@ -608,7 +618,16 @@ export function ContentPage() { if (s) qs.set('search', s) const data = await get<{ success?: boolean - linkTags?: { tagId: string; label: string; aliases?: string; url: string; type: string; appId?: string; pagePath?: string }[] + linkTags?: { + tagId: string + label: string + aliases?: string + url: string + type: string + appId?: string + pagePath?: string + hasAppSecret?: boolean + }[] total?: number page?: number pageSize?: number @@ -622,9 +641,10 @@ export function ContentPage() { label: t.label, aliases: t.aliases || '', url: t.url, - type: (t.type || 'url') as 'url' | 'miniprogram' | 'ckb', + type: (t.type || 'url') as 'url' | 'miniprogram' | 'ckb' | 'wxlink', appId: t.appId || '', pagePath: t.pagePath || '', + hasAppSecret: !!t.hasAppSecret, })), ) setLinkTagTotal(typeof data.total === 'number' ? data.total : 0) @@ -2810,7 +2830,7 @@ export function ContentPage() { className="bg-amber-500 hover:bg-amber-600 text-white h-8" onClick={() => { setLinkTagEditing(null) - setLinkTagForm({ tagId: '', label: '', aliases: '', url: '', type: 'url', appId: '', pagePath: '' }) + setLinkTagForm({ tagId: '', label: '', aliases: '', url: '', type: 'url', appId: '', appSecret: '', pagePath: '' }) setMpSearchQuery('') setMpDropdownOpen(false) setLinkTagModalOpen(true) @@ -2862,6 +2882,7 @@ export function ContentPage() { url: t.url, type: t.type, appId: t.appId ?? '', + appSecret: '', pagePath: t.pagePath ?? '', }) setMpSearchQuery(t.appId ?? '') @@ -2882,12 +2903,12 @@ 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 === '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 === 'url' ? '网页' : t.type === 'ckb' ? '存客宝' : t.type === 'wxlink' ? '小程序链接' : '小程序'} @@ -2903,6 +2924,18 @@ export function ContentPage() { ) })()} {t.pagePath &&
{t.pagePath}
} +
+ AppSecret:{t.hasAppSecret ? '已保存(仅服务端)' : '未配置'} +
+ + ) : t.type === 'wxlink' ? ( +
+
+ {t.url || '—'} +
+
小程序内点击 → web-view 打开 → 自动唤起目标小程序
) : t.url ? ( {linkTagEditing ? '编辑链接标签' : '添加链接标签'} - 配置后可在富文本编辑器中通过 #标签 插入,并在小程序端点击跳转 + 配置后可在富文本编辑器中通过 #标签 插入,并在小程序端点击跳转。小程序类型需填 mpKey 或微信 AppID;AppSecret 仅存服务端(不下发小程序),供后续开放接口与台账使用。 @@ -3006,7 +3040,7 @@ export function ContentPage() { setLinkTagForm((p) => ({ ...p, tagId: e.target.value }))} @@ -3038,7 +3072,7 @@ export function ContentPage() { @@ -3057,9 +3092,18 @@ export function ContentPage() { ? 'URL地址' : linkTagForm.type === 'ckb' ? '存客宝计划URL' - : '小程序(选密钥)'} + : linkTagForm.type === 'wxlink' + ? '小程序链接' + : '小程序 mpKey / 微信 AppID'} - {linkTagForm.type === 'miniprogram' && linkedMps.length > 0 ? ( + {linkTagForm.type === 'wxlink' ? ( + setLinkTagForm((p) => ({ ...p, url: e.target.value }))} + /> + ) : linkTagForm.type === 'miniprogram' && linkedMps.length > 0 ? (
{ @@ -3123,16 +3167,38 @@ export function ContentPage() {
+ {linkTagForm.type === 'wxlink' && ( +

+ 操作:打开目标小程序 → 右上角「...」→「复制链接」→ 粘贴到上面。小程序内点击此标签会在 web-view 中打开,微信自动唤起目标小程序,无需修改小程序版本。 +

+ )} + {linkTagForm.type === 'miniprogram' && ( -
- - setLinkTagForm((p) => ({ ...p, pagePath: e.target.value }))} - /> -
+ <> +
+ + setLinkTagForm((p) => ({ ...p, pagePath: e.target.value }))} + /> +
+
+ + setLinkTagForm((p) => ({ ...p, appSecret: e.target.value }))} + /> +

+ 与 AppID 成对落库;接口响应与小程序配置中均不会返回此字段。 +

+
+ )} @@ -3149,13 +3215,18 @@ export function ContentPage() { url: linkTagForm.url.trim(), type: linkTagForm.type, appId: linkTagForm.appId.trim(), + appSecret: linkTagForm.appSecret.trim(), pagePath: linkTagForm.pagePath.trim(), } - // 新增:允许留空,后端自动生成;编辑:tagId 已锁定 + // 留空则后端自动生成;自定义时与库一致:1~50 字符,勿含 #、逗号、换行 if (payload.tagId) { - const ok = /^\d{12}$/.test(payload.tagId) || /^z[a-z0-9]{11}$/.test(payload.tagId) - if (!ok) { - toast.error('标签ID需为12位数字,或 z 开头的12位(z+11位小写字母数字)') + const id = payload.tagId + if ([...id].length > 50) { + toast.error('标签ID 最长 50 个字符') + return + } + if (/[#,\n\r\t]/.test(id)) { + toast.error('标签ID 不能含 #、逗号或换行') return } } @@ -3164,6 +3235,7 @@ export function ContentPage() { return } if (payload.type === 'miniprogram') payload.url = '' + if (payload.type === 'wxlink') { payload.appId = ''; payload.pagePath = '' } setLinkTagSaving(true) try { const res = await post<{ success?: boolean; error?: string }>('/api/db/link-tags', payload) diff --git a/soul-api/internal/handler/db.go b/soul-api/internal/handler/db.go index aa8169c3..1fce91f6 100644 --- a/soul-api/internal/handler/db.go +++ b/soul-api/internal/handler/db.go @@ -317,9 +317,18 @@ func buildMiniprogramConfig() gin.H { _ = db.Order("label ASC").Find(&linkTagRows).Error tags := make([]gin.H, 0, len(linkTagRows)) for _, t := range linkTagRows { - h := gin.H{"tagId": t.TagID, "label": t.Label, "url": t.URL, "type": t.Type, "pagePath": t.PagePath} + cType := t.Type + cURL := t.URL + // wxlink(小程序短链):下发给 C 端时转为 url 类型,现有 read.js web-view 可直接跳转,无需升级小程序 + if strings.EqualFold(cType, "wxlink") { + cType = "url" + if cURL == "" { + cURL = t.AppID + } + } + h := gin.H{"tagId": t.TagID, "label": t.Label, "url": cURL, "type": cType, "pagePath": t.PagePath} if t.Type == "miniprogram" { - h["mpKey"] = t.AppID // 可为「关联表 key」或「直接 wx AppID」;后者由 mergeDirectMiniProgramLinksFromLinkTags 补全 linkedMiniprograms + h["mpKey"] = t.AppID } else { h["appId"] = t.AppID } diff --git a/soul-api/internal/handler/db_link_tag.go b/soul-api/internal/handler/db_link_tag.go index 53c7d565..71b4576d 100644 --- a/soul-api/internal/handler/db_link_tag.go +++ b/soul-api/internal/handler/db_link_tag.go @@ -6,6 +6,7 @@ import ( "strconv" "strings" "time" + "unicode/utf8" "soul-api/internal/cache" "soul-api/internal/database" @@ -14,30 +15,64 @@ import ( "github.com/gin-gonic/gin" ) -func isDigits12(s string) bool { - if len(s) != 12 { +// isValidLinkTagID 自定义 tagId:与库字段 tag_id(50) 对齐,禁止破坏 #标签 解析的字符 +func isValidLinkTagID(s string) bool { + if s == "" { return false } - for _, ch := range s { - if ch < '0' || ch > '9' { + if utf8.RuneCountInString(s) > 50 { + return false + } + for _, r := range s { + if r == '#' || r == ',' || r == '\n' || r == '\r' || r == '\t' { return false } } return true } -func isZId12(s string) bool { - if len(s) != 12 || s[0] != 'z' { - return false +// linkTagAdminOut 管理端 API 出参:不含 appSecret 明文,仅 hasAppSecret +type linkTagAdminOut struct { + ID uint `json:"id"` + TagID string `json:"tagId"` + Label string `json:"label"` + Aliases string `json:"aliases"` + URL string `json:"url"` + Type string `json:"type"` + AppID string `json:"appId,omitempty"` + PagePath string `json:"pagePath,omitempty"` + HasAppSecret bool `json:"hasAppSecret"` + CreatedAt string `json:"createdAt,omitempty"` + UpdatedAt string `json:"updatedAt,omitempty"` +} + +func linkTagToAdminOut(t model.LinkTag) linkTagAdminOut { + o := linkTagAdminOut{ + ID: t.ID, + TagID: t.TagID, + Label: t.Label, + Aliases: t.Aliases, + URL: t.URL, + Type: t.Type, + AppID: t.AppID, + PagePath: t.PagePath, + HasAppSecret: strings.TrimSpace(t.AppSecret) != "", } - for i := 1; i < 12; i++ { - ch := s[i] - if (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') { - continue - } - return false + if !t.CreatedAt.IsZero() { + o.CreatedAt = t.CreatedAt.Format(time.RFC3339) } - return true + if !t.UpdatedAt.IsZero() { + o.UpdatedAt = t.UpdatedAt.Format(time.RFC3339) + } + return o +} + +func linkTagsToAdminOut(rows []model.LinkTag) []linkTagAdminOut { + out := make([]linkTagAdminOut, 0, len(rows)) + for _, t := range rows { + out = append(out, linkTagToAdminOut(t)) + } + return out } func genZId12() string { @@ -63,7 +98,7 @@ func DBLinkTagList(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"success": false, "error": err.Error()}) return } - c.JSON(http.StatusOK, gin.H{"success": true, "linkTags": rows}) + c.JSON(http.StatusOK, gin.H{"success": true, "linkTags": linkTagsToAdminOut(rows)}) return } @@ -99,7 +134,7 @@ func DBLinkTagList(c *gin.Context) { totalPages := (int(total) + pageSize - 1) / pageSize c.JSON(http.StatusOK, gin.H{ "success": true, - "linkTags": rows, + "linkTags": linkTagsToAdminOut(rows), "total": total, "page": page, "pageSize": pageSize, @@ -110,13 +145,14 @@ func DBLinkTagList(c *gin.Context) { // DBLinkTagSave POST /api/db/link-tags 管理端-新增或更新链接标签 func DBLinkTagSave(c *gin.Context) { var body struct { - TagID string `json:"tagId"` - Label string `json:"label"` - Aliases string `json:"aliases"` - URL string `json:"url"` - Type string `json:"type"` - AppID string `json:"appId"` - PagePath string `json:"pagePath"` + TagID string `json:"tagId"` + Label string `json:"label"` + Aliases string `json:"aliases"` + URL string `json:"url"` + Type string `json:"type"` + AppID string `json:"appId"` + AppSecret string `json:"appSecret"` + PagePath string `json:"pagePath"` } if err := c.ShouldBindJSON(&body); err != nil { c.JSON(http.StatusOK, gin.H{"success": false, "error": "请求体无效"}) @@ -128,6 +164,7 @@ func DBLinkTagSave(c *gin.Context) { body.URL = strings.TrimSpace(body.URL) body.Type = strings.TrimSpace(body.Type) body.AppID = strings.TrimSpace(body.AppID) + body.AppSecret = strings.TrimSpace(body.AppSecret) body.PagePath = strings.TrimSpace(body.PagePath) if body.Label == "" { @@ -141,24 +178,18 @@ func DBLinkTagSave(c *gin.Context) { if body.Type == "" { body.Type = "url" } - // tagId 规则:12位数字,或 12位且以 z 开头(z + 11位[a-z0-9]) - // 管理端新增:可不传 tagId,由后端生成;编辑:通常会携带现有 tagId + // 管理端新增:可不传 tagId,由后端生成 z 开头 12 位;也可自定义任意 1~50 字符(如 kr) if body.TagID == "" { body.TagID = genZId12() autoCreate = true } + if !isValidLinkTagID(body.TagID) { + c.JSON(http.StatusOK, gin.H{"success": false, "error": "tagId 长度 1~50 字符,且不能含 #、逗号或换行"}) + return + } db := database.DB() var existing model.LinkTag - // 若 tagId 不符合新规则:仅允许更新已有记录(兼容历史中文 tagId),禁止新建 - if !(isDigits12(body.TagID) || isZId12(body.TagID)) { - if err := db.Where("tag_id = ?", body.TagID).First(&existing).Error; err == nil { - // allow update existing legacy tagId - } else { - c.JSON(http.StatusOK, gin.H{"success": false, "error": "tagId 必须为12位数字,或12位且以 z 开头(z+11位小写字母数字)"}) - return - } - } // 小程序类型:只存 appId + pagePath,不存 weixin:// 到 url if body.Type == "miniprogram" { body.URL = "" @@ -166,7 +197,7 @@ func DBLinkTagSave(c *gin.Context) { // 按 label 查找:仅用于「自动创建」场景(tagId 为空时回落 label),若已存在则直接返回 if autoCreate { if db.Where("label = ?", body.Label).First(&existing).Error == nil { - c.JSON(http.StatusOK, gin.H{"success": true, "linkTag": existing}) + c.JSON(http.StatusOK, gin.H{"success": true, "linkTag": linkTagToAdminOut(existing)}) return } } @@ -176,21 +207,24 @@ func DBLinkTagSave(c *gin.Context) { existing.URL = body.URL existing.Type = body.Type existing.AppID = body.AppID + if body.AppSecret != "" { + existing.AppSecret = body.AppSecret + } existing.PagePath = body.PagePath db.Save(&existing) cache.InvalidateConfig() - c.JSON(http.StatusOK, gin.H{"success": true, "linkTag": existing}) + c.JSON(http.StatusOK, gin.H{"success": true, "linkTag": linkTagToAdminOut(existing)}) return } // body.URL 已在 miniprogram 类型时置空 - t := model.LinkTag{TagID: body.TagID, Label: body.Label, Aliases: body.Aliases, URL: body.URL, Type: body.Type, AppID: body.AppID, PagePath: body.PagePath} + t := model.LinkTag{TagID: body.TagID, Label: body.Label, Aliases: body.Aliases, URL: body.URL, Type: body.Type, AppID: body.AppID, AppSecret: body.AppSecret, PagePath: body.PagePath} if err := db.Create(&t).Error; err != nil { // 极低概率:生成的 tagId 冲突,重试一次 if strings.Contains(err.Error(), "Duplicate") || strings.Contains(err.Error(), "1062") { t.TagID = genZId12() if e2 := db.Create(&t).Error; e2 == nil { cache.InvalidateConfig() - c.JSON(http.StatusOK, gin.H{"success": true, "linkTag": t}) + c.JSON(http.StatusOK, gin.H{"success": true, "linkTag": linkTagToAdminOut(t)}) return } } @@ -198,7 +232,7 @@ func DBLinkTagSave(c *gin.Context) { return } cache.InvalidateConfig() - c.JSON(http.StatusOK, gin.H{"success": true, "linkTag": t}) + c.JSON(http.StatusOK, gin.H{"success": true, "linkTag": linkTagToAdminOut(t)}) } // DBLinkTagDelete DELETE /api/db/link-tags?tagId=xxx 管理端-删除链接标签 diff --git a/soul-api/internal/model/link_tag.go b/soul-api/internal/model/link_tag.go index 2eb45f01..a8860c0c 100644 --- a/soul-api/internal/model/link_tag.go +++ b/soul-api/internal/model/link_tag.go @@ -11,6 +11,8 @@ type LinkTag struct { URL string `gorm:"column:url;size:500" json:"url"` Type string `gorm:"column:type;size:20" json:"type"` AppID string `gorm:"column:app_id;size:100" json:"appId,omitempty"` + // AppSecret 目标小程序 AppSecret,仅存库;列表/保存响应用 hasAppSecret,永不 json 明文下发 + AppSecret string `gorm:"column:app_secret;size:256;default:''" json:"-"` PagePath string `gorm:"column:page_path;size:500" json:"pagePath,omitempty"` CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`