Files
soul-yongping/soul-admin/dist/assets/index-CW7Mmh6Q.js
卡若 fa3da12b16 feat: 小程序阅读记录与资料链路、管理端用户规则、API/VIP/推荐与运营脚本
- miniprogram: reading-records、imageUrl/mpNavigate、多页资料与 VIP 展示调整
- soul-admin: Users/Settings/UserDetailModal、dist 构建产物更新
- soul-api: user/vip/referral/ckb/db、MBTI 头像管理、user_rule_completion、迁移 SQL
- .cursor: karuo-party 与飞书文档;.gitignore 忽略 .tmp_skill_bundle

Made-with: Cursor
2026-03-23 18:38:23 +08:00

966 lines
1.2 MiB
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function jE(t,e){for(var n=0;n<e.length;n++){const s=e[n];if(typeof s!="string"&&!Array.isArray(s)){for(const a in s)if(a!=="default"&&!(a in t)){const i=Object.getOwnPropertyDescriptor(s,a);i&&Object.defineProperty(t,a,i.get?i:{enumerable:!0,get:()=>s[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"]'))s(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"&&s(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 s(a){if(a.ep)return;a.ep=!0;const i=n(a);fetch(a.href,i)}})();function Zw(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Jm={exports:{}},dd={},Ym={exports:{}},jt={};/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var _v;function kE(){if(_v)return jt;_v=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),o=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.iterator;function g(L){return L===null||typeof L!="object"?null:(L=m&&L[m]||L["@@iterator"],typeof L=="function"?L:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,w={};function N(L,F,re){this.props=L,this.context=F,this.refs=w,this.updater=re||y}N.prototype.isReactComponent={},N.prototype.setState=function(L,F){if(typeof L!="object"&&typeof L!="function"&&L!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,L,F,"setState")},N.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function k(){}k.prototype=N.prototype;function E(L,F,re){this.props=L,this.context=F,this.refs=w,this.updater=re||y}var C=E.prototype=new k;C.constructor=E,v(C,N.prototype),C.isPureReactComponent=!0;var P=Array.isArray,O=Object.prototype.hasOwnProperty,U={current:null},_={key:!0,ref:!0,__self:!0,__source:!0};function V(L,F,re){var ge,Te={},se=null,le=null;if(F!=null)for(ge in F.ref!==void 0&&(le=F.ref),F.key!==void 0&&(se=""+F.key),F)O.call(F,ge)&&!_.hasOwnProperty(ge)&&(Te[ge]=F[ge]);var ae=arguments.length-2;if(ae===1)Te.children=re;else if(1<ae){for(var Q=Array(ae),Z=0;Z<ae;Z++)Q[Z]=arguments[Z+2];Te.children=Q}if(L&&L.defaultProps)for(ge in ae=L.defaultProps,ae)Te[ge]===void 0&&(Te[ge]=ae[ge]);return{$$typeof:t,type:L,key:se,ref:le,props:Te,_owner:U.current}}function A(L,F){return{$$typeof:t,type:L.type,key:F,ref:L.ref,props:L.props,_owner:L._owner}}function X(L){return typeof L=="object"&&L!==null&&L.$$typeof===t}function G(L){var F={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(re){return F[re]})}var z=/\/+/g;function ne(L,F){return typeof L=="object"&&L!==null&&L.key!=null?G(""+L.key):F.toString(36)}function ue(L,F,re,ge,Te){var se=typeof L;(se==="undefined"||se==="boolean")&&(L=null);var le=!1;if(L===null)le=!0;else switch(se){case"string":case"number":le=!0;break;case"object":switch(L.$$typeof){case t:case e:le=!0}}if(le)return le=L,Te=Te(le),L=ge===""?"."+ne(le,0):ge,P(Te)?(re="",L!=null&&(re=L.replace(z,"$&/")+"/"),ue(Te,F,re,"",function(Z){return Z})):Te!=null&&(X(Te)&&(Te=A(Te,re+(!Te.key||le&&le.key===Te.key?"":(""+Te.key).replace(z,"$&/")+"/")+L)),F.push(Te)),1;if(le=0,ge=ge===""?".":ge+":",P(L))for(var ae=0;ae<L.length;ae++){se=L[ae];var Q=ge+ne(se,ae);le+=ue(se,F,re,Q,Te)}else if(Q=g(L),typeof Q=="function")for(L=Q.call(L),ae=0;!(se=L.next()).done;)se=se.value,Q=ge+ne(se,ae++),le+=ue(se,F,re,Q,Te);else if(se==="object")throw F=String(L),Error("Objects are not valid as a React child (found: "+(F==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":F)+"). If you meant to render a collection of children, use an array instead.");return le}function K(L,F,re){if(L==null)return L;var ge=[],Te=0;return ue(L,ge,"","",function(se){return F.call(re,se,Te++)}),ge}function $(L){if(L._status===-1){var F=L._result;F=F(),F.then(function(re){(L._status===0||L._status===-1)&&(L._status=1,L._result=re)},function(re){(L._status===0||L._status===-1)&&(L._status=2,L._result=re)}),L._status===-1&&(L._status=0,L._result=F)}if(L._status===1)return L._result.default;throw L._result}var D={current:null},I={transition:null},ie={ReactCurrentDispatcher:D,ReactCurrentBatchConfig:I,ReactCurrentOwner:U};function q(){throw Error("act(...) is not supported in production builds of React.")}return jt.Children={map:K,forEach:function(L,F,re){K(L,function(){F.apply(this,arguments)},re)},count:function(L){var F=0;return K(L,function(){F++}),F},toArray:function(L){return K(L,function(F){return F})||[]},only:function(L){if(!X(L))throw Error("React.Children.only expected to receive a single React element child.");return L}},jt.Component=N,jt.Fragment=n,jt.Profiler=a,jt.PureComponent=E,jt.StrictMode=s,jt.Suspense=u,jt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ie,jt.act=q,jt.cloneElement=function(L,F,re){if(L==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+L+".");var ge=v({},L.props),Te=L.key,se=L.ref,le=L._owner;if(F!=null){if(F.ref!==void 0&&(se=F.ref,le=U.current),F.key!==void 0&&(Te=""+F.key),L.type&&L.type.defaultProps)var ae=L.type.defaultProps;for(Q in F)O.call(F,Q)&&!_.hasOwnProperty(Q)&&(ge[Q]=F[Q]===void 0&&ae!==void 0?ae[Q]:F[Q])}var Q=arguments.length-2;if(Q===1)ge.children=re;else if(1<Q){ae=Array(Q);for(var Z=0;Z<Q;Z++)ae[Z]=arguments[Z+2];ge.children=ae}return{$$typeof:t,type:L.type,key:Te,ref:se,props:ge,_owner:le}},jt.createContext=function(L){return L={$$typeof:o,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},L.Provider={$$typeof:i,_context:L},L.Consumer=L},jt.createElement=V,jt.createFactory=function(L){var F=V.bind(null,L);return F.type=L,F},jt.createRef=function(){return{current:null}},jt.forwardRef=function(L){return{$$typeof:c,render:L}},jt.isValidElement=X,jt.lazy=function(L){return{$$typeof:f,_payload:{_status:-1,_result:L},_init:$}},jt.memo=function(L,F){return{$$typeof:h,type:L,compare:F===void 0?null:F}},jt.startTransition=function(L){var F=I.transition;I.transition={};try{L()}finally{I.transition=F}},jt.unstable_act=q,jt.useCallback=function(L,F){return D.current.useCallback(L,F)},jt.useContext=function(L){return D.current.useContext(L)},jt.useDebugValue=function(){},jt.useDeferredValue=function(L){return D.current.useDeferredValue(L)},jt.useEffect=function(L,F){return D.current.useEffect(L,F)},jt.useId=function(){return D.current.useId()},jt.useImperativeHandle=function(L,F,re){return D.current.useImperativeHandle(L,F,re)},jt.useInsertionEffect=function(L,F){return D.current.useInsertionEffect(L,F)},jt.useLayoutEffect=function(L,F){return D.current.useLayoutEffect(L,F)},jt.useMemo=function(L,F){return D.current.useMemo(L,F)},jt.useReducer=function(L,F,re){return D.current.useReducer(L,F,re)},jt.useRef=function(L){return D.current.useRef(L)},jt.useState=function(L){return D.current.useState(L)},jt.useSyncExternalStore=function(L,F,re){return D.current.useSyncExternalStore(L,F,re)},jt.useTransition=function(){return D.current.useTransition()},jt.version="18.3.1",jt}var zv;function eu(){return zv||(zv=1,Ym.exports=kE()),Ym.exports}/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var $v;function SE(){if($v)return dd;$v=1;var t=eu(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(c,u,h){var f,m={},g=null,y=null;h!==void 0&&(g=""+h),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(y=u.ref);for(f in u)s.call(u,f)&&!i.hasOwnProperty(f)&&(m[f]=u[f]);if(c&&c.defaultProps)for(f in u=c.defaultProps,u)m[f]===void 0&&(m[f]=u[f]);return{$$typeof:e,type:c,key:g,ref:y,props:m,_owner:a.current}}return dd.Fragment=n,dd.jsx=o,dd.jsxs=o,dd}var Fv;function CE(){return Fv||(Fv=1,Jm.exports=SE()),Jm.exports}var r=CE(),b=eu();const Ls=Zw(b),Jf=jE({__proto__:null,default:Ls},[b]);var rh={},Qm={exports:{}},Ks={},Xm={exports:{}},Zm={};/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Bv;function EE(){return Bv||(Bv=1,(function(t){function e(I,ie){var q=I.length;I.push(ie);e:for(;0<q;){var L=q-1>>>1,F=I[L];if(0<a(F,ie))I[L]=ie,I[q]=F,q=L;else break e}}function n(I){return I.length===0?null:I[0]}function s(I){if(I.length===0)return null;var ie=I[0],q=I.pop();if(q!==ie){I[0]=q;e:for(var L=0,F=I.length,re=F>>>1;L<re;){var ge=2*(L+1)-1,Te=I[ge],se=ge+1,le=I[se];if(0>a(Te,q))se<F&&0>a(le,Te)?(I[L]=le,I[se]=q,L=se):(I[L]=Te,I[ge]=q,L=ge);else if(se<F&&0>a(le,q))I[L]=le,I[se]=q,L=se;else break e}}return ie}function a(I,ie){var q=I.sortIndex-ie.sortIndex;return q!==0?q:I.id-ie.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,c=o.now();t.unstable_now=function(){return o.now()-c}}var u=[],h=[],f=1,m=null,g=3,y=!1,v=!1,w=!1,N=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,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 C(I){for(var ie=n(h);ie!==null;){if(ie.callback===null)s(h);else if(ie.startTime<=I)s(h),ie.sortIndex=ie.expirationTime,e(u,ie);else break;ie=n(h)}}function P(I){if(w=!1,C(I),!v)if(n(u)!==null)v=!0,$(O);else{var ie=n(h);ie!==null&&D(P,ie.startTime-I)}}function O(I,ie){v=!1,w&&(w=!1,k(V),V=-1),y=!0;var q=g;try{for(C(ie),m=n(u);m!==null&&(!(m.expirationTime>ie)||I&&!G());){var L=m.callback;if(typeof L=="function"){m.callback=null,g=m.priorityLevel;var F=L(m.expirationTime<=ie);ie=t.unstable_now(),typeof F=="function"?m.callback=F:m===n(u)&&s(u),C(ie)}else s(u);m=n(u)}if(m!==null)var re=!0;else{var ge=n(h);ge!==null&&D(P,ge.startTime-ie),re=!1}return re}finally{m=null,g=q,y=!1}}var U=!1,_=null,V=-1,A=5,X=-1;function G(){return!(t.unstable_now()-X<A)}function z(){if(_!==null){var I=t.unstable_now();X=I;var ie=!0;try{ie=_(!0,I)}finally{ie?ne():(U=!1,_=null)}}else U=!1}var ne;if(typeof E=="function")ne=function(){E(z)};else if(typeof MessageChannel<"u"){var ue=new MessageChannel,K=ue.port2;ue.port1.onmessage=z,ne=function(){K.postMessage(null)}}else ne=function(){N(z,0)};function $(I){_=I,U||(U=!0,ne())}function D(I,ie){V=N(function(){I(t.unstable_now())},ie)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(I){I.callback=null},t.unstable_continueExecution=function(){v||y||(v=!0,$(O))},t.unstable_forceFrameRate=function(I){0>I||125<I?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<I?Math.floor(1e3/I):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_getFirstCallbackNode=function(){return n(u)},t.unstable_next=function(I){switch(g){case 1:case 2:case 3:var ie=3;break;default:ie=g}var q=g;g=ie;try{return I()}finally{g=q}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(I,ie){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var q=g;g=I;try{return ie()}finally{g=q}},t.unstable_scheduleCallback=function(I,ie,q){var L=t.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?L+q:L):q=L,I){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=q+F,I={id:f++,callback:ie,priorityLevel:I,startTime:q,expirationTime:F,sortIndex:-1},q>L?(I.sortIndex=q,e(h,I),n(u)===null&&I===n(h)&&(w?(k(V),V=-1):w=!0,D(P,q-L))):(I.sortIndex=F,e(u,I),v||y||(v=!0,$(O))),I},t.unstable_shouldYield=G,t.unstable_wrapCallback=function(I){var ie=g;return function(){var q=g;g=ie;try{return I.apply(this,arguments)}finally{g=q}}}})(Zm)),Zm}var Vv;function TE(){return Vv||(Vv=1,Xm.exports=EE()),Xm.exports}/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Hv;function ME(){if(Hv)return Ks;Hv=1;var t=eu(),e=TE();function n(l){for(var d="https://reactjs.org/docs/error-decoder.html?invariant="+l,p=1;p<arguments.length;p++)d+="&args[]="+encodeURIComponent(arguments[p]);return"Minified React error #"+l+"; visit "+d+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,a={};function i(l,d){o(l,d),o(l+"Capture",d)}function o(l,d){for(a[l]=d,l=0;l<d.length;l++)s.add(d[l])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},m={};function g(l){return u.call(m,l)?!0:u.call(f,l)?!1:h.test(l)?m[l]=!0:(f[l]=!0,!1)}function y(l,d,p,x){if(p!==null&&p.type===0)return!1;switch(typeof d){case"function":case"symbol":return!0;case"boolean":return x?!1:p!==null?!p.acceptsBooleans:(l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-");default:return!1}}function v(l,d,p,x){if(d===null||typeof d>"u"||y(l,d,p,x))return!0;if(x)return!1;if(p!==null)switch(p.type){case 3:return!d;case 4:return d===!1;case 5:return isNaN(d);case 6:return isNaN(d)||1>d}return!1}function w(l,d,p,x,j,S,M){this.acceptsBooleans=d===2||d===3||d===4,this.attributeName=x,this.attributeNamespace=j,this.mustUseProperty=p,this.propertyName=l,this.type=d,this.sanitizeURL=S,this.removeEmptyString=M}var N={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){N[l]=new w(l,0,!1,l,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var d=l[0];N[d]=new w(d,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){N[l]=new w(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){N[l]=new w(l,2,!1,l,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(l){N[l]=new w(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){N[l]=new w(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){N[l]=new w(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){N[l]=new w(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){N[l]=new w(l,5,!1,l.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function 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(k,E);N[d]=new w(d,1,!1,l,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(l){var d=l.replace(k,E);N[d]=new w(d,1,!1,l,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(l){var d=l.replace(k,E);N[d]=new w(d,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){N[l]=new w(l,1,!1,l.toLowerCase(),null,!1,!1)}),N.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){N[l]=new w(l,1,!1,l.toLowerCase(),null,!0,!0)});function C(l,d,p,x){var j=N.hasOwnProperty(d)?N[d]:null;(j!==null?j.type!==0:x||!(2<d.length)||d[0]!=="o"&&d[0]!=="O"||d[1]!=="n"&&d[1]!=="N")&&(v(d,p,j,x)&&(p=null),x||j===null?g(d)&&(p===null?l.removeAttribute(d):l.setAttribute(d,""+p)):j.mustUseProperty?l[j.propertyName]=p===null?j.type===3?!1:"":p:(d=j.attributeName,x=j.attributeNamespace,p===null?l.removeAttribute(d):(j=j.type,p=j===3||j===4&&p===!0?"":""+p,x?l.setAttributeNS(x,d,p):l.setAttribute(d,p))))}var P=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,O=Symbol.for("react.element"),U=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),X=Symbol.for("react.provider"),G=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),ne=Symbol.for("react.suspense"),ue=Symbol.for("react.suspense_list"),K=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),D=Symbol.for("react.offscreen"),I=Symbol.iterator;function ie(l){return l===null||typeof l!="object"?null:(l=I&&l[I]||l["@@iterator"],typeof l=="function"?l:null)}var q=Object.assign,L;function F(l){if(L===void 0)try{throw Error()}catch(p){var d=p.stack.trim().match(/\n( *(at )?)/);L=d&&d[1]||""}return`
`+L+l}var re=!1;function ge(l,d){if(!l||re)return"";re=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(d)if(d=function(){throw Error()},Object.defineProperty(d.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(d,[])}catch(me){var x=me}Reflect.construct(l,[],d)}else{try{d.call()}catch(me){x=me}l.call(d.prototype)}else{try{throw Error()}catch(me){x=me}l()}}catch(me){if(me&&x&&typeof me.stack=="string"){for(var j=me.stack.split(`
`),S=x.stack.split(`
`),M=j.length-1,H=S.length-1;1<=M&&0<=H&&j[M]!==S[H];)H--;for(;1<=M&&0<=H;M--,H--)if(j[M]!==S[H]){if(M!==1||H!==1)do if(M--,H--,0>H||j[M]!==S[H]){var J=`
`+j[M].replace(" at new "," at ");return l.displayName&&J.includes("<anonymous>")&&(J=J.replace("<anonymous>",l.displayName)),J}while(1<=M&&0<=H);break}}}finally{re=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?F(l):""}function Te(l){switch(l.tag){case 5:return F(l.type);case 16:return F("Lazy");case 13:return F("Suspense");case 19:return F("SuspenseList");case 0:case 2:case 15:return l=ge(l.type,!1),l;case 11:return l=ge(l.type.render,!1),l;case 1:return l=ge(l.type,!0),l;default:return""}}function se(l){if(l==null)return null;if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case _:return"Fragment";case U:return"Portal";case A:return"Profiler";case V:return"StrictMode";case ne:return"Suspense";case ue:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case G:return(l.displayName||"Context")+".Consumer";case X:return(l._context.displayName||"Context")+".Provider";case z:var d=l.render;return l=l.displayName,l||(l=d.displayName||d.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case K:return d=l.displayName||null,d!==null?d:se(l.type)||"Memo";case $:d=l._payload,l=l._init;try{return se(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 se(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 ae(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function Q(l){var d=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function Z(l){var d=Q(l)?"checked":"value",p=Object.getOwnPropertyDescriptor(l.constructor.prototype,d),x=""+l[d];if(!l.hasOwnProperty(d)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var j=p.get,S=p.set;return Object.defineProperty(l,d,{configurable:!0,get:function(){return j.call(this)},set:function(M){x=""+M,S.call(this,M)}}),Object.defineProperty(l,d,{enumerable:p.enumerable}),{getValue:function(){return x},setValue:function(M){x=""+M},stopTracking:function(){l._valueTracker=null,delete l[d]}}}}function xe(l){l._valueTracker||(l._valueTracker=Z(l))}function Ne(l){if(!l)return!1;var d=l._valueTracker;if(!d)return!0;var p=d.getValue(),x="";return l&&(x=Q(l)?l.checked?"true":"false":l.value),l=x,l!==p?(d.setValue(l),!0):!1}function ct(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 ye(l,d){var p=d.checked;return q({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??l._wrapperState.initialChecked})}function $e(l,d){var p=d.defaultValue==null?"":d.defaultValue,x=d.checked!=null?d.checked:d.defaultChecked;p=ae(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 Ze(l,d){d=d.checked,d!=null&&C(l,"checked",d,!1)}function tt(l,d){Ze(l,d);var p=ae(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")?st(l,d.type,p):d.hasOwnProperty("defaultValue")&&st(l,d.type,ae(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(l.defaultChecked=!!d.defaultChecked)}function _e(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 st(l,d,p){(d!=="number"||ct(l.ownerDocument)!==l)&&(p==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+p&&(l.defaultValue=""+p))}var kt=Array.isArray;function Pt(l,d,p,x){if(l=l.options,d){d={};for(var j=0;j<p.length;j++)d["$"+p[j]]=!0;for(p=0;p<l.length;p++)j=d.hasOwnProperty("$"+l[p].value),l[p].selected!==j&&(l[p].selected=j),j&&x&&(l[p].defaultSelected=!0)}else{for(p=""+ae(p),d=null,j=0;j<l.length;j++){if(l[j].value===p){l[j].selected=!0,x&&(l[j].defaultSelected=!0);return}d!==null||l[j].disabled||(d=l[j])}d!==null&&(d.selected=!0)}}function Ot(l,d){if(d.dangerouslySetInnerHTML!=null)throw Error(n(91));return q({},d,{value:void 0,defaultValue:void 0,children:""+l._wrapperState.initialValue})}function Mn(l,d){var p=d.value;if(p==null){if(p=d.children,d=d.defaultValue,p!=null){if(d!=null)throw Error(n(92));if(kt(p)){if(1<p.length)throw Error(n(93));p=p[0]}d=p}d==null&&(d=""),p=d}l._wrapperState={initialValue:ae(p)}}function Dn(l,d){var p=ae(d.value),x=ae(d.defaultValue);p!=null&&(p=""+p,p!==l.value&&(l.value=p),d.defaultValue==null&&l.defaultValue!==p&&(l.defaultValue=p)),x!=null&&(l.defaultValue=""+x)}function gs(l){var d=l.textContent;d===l._wrapperState.initialValue&&d!==""&&d!==null&&(l.value=d)}function zs(l){switch(l){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function ts(l,d){return l==null||l==="http://www.w3.org/1999/xhtml"?zs(d):l==="http://www.w3.org/2000/svg"&&d==="foreignObject"?"http://www.w3.org/1999/xhtml":l}var xs,Gt=(function(l){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(d,p,x,j){MSApp.execUnsafeLocalFunction(function(){return l(d,p,x,j)})}:l})(function(l,d){if(l.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in l)l.innerHTML=d;else{for(xs=xs||document.createElement("div"),xs.innerHTML="<svg>"+d.valueOf().toString()+"</svg>",d=xs.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;d.firstChild;)l.appendChild(d.firstChild)}});function ln(l,d){if(d){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=d;return}}l.textContent=d}var As={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},Is=["Webkit","ms","Moz","O"];Object.keys(As).forEach(function(l){Is.forEach(function(d){d=d+l.charAt(0).toUpperCase()+l.substring(1),As[d]=As[l]})});function ns(l,d,p){return d==null||typeof d=="boolean"||d===""?"":p||typeof d!="number"||d===0||As.hasOwnProperty(l)&&As[l]?(""+d).trim():d+"px"}function W(l,d){l=l.style;for(var p in d)if(d.hasOwnProperty(p)){var x=p.indexOf("--")===0,j=ns(p,d[p],x);p==="float"&&(p="cssFloat"),x?l.setProperty(p,j):l[p]=j}}var Qe=q({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 mt(l,d){if(d){if(Qe[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 Bt(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 gt=null;function ht(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var At=null,It=null,sn=null;function Wn(l){if(l=Jc(l)){if(typeof At!="function")throw Error(n(280));var d=l.stateNode;d&&(d=bu(d),At(l.stateNode,l.type,d))}}function pe(l){It?sn?sn.push(l):sn=[l]:It=l}function be(){if(It){var l=It,d=sn;if(sn=It=null,Wn(l),d)for(l=0;l<d.length;l++)Wn(d[l])}}function vn(l,d){return l(d)}function hn(){}var Mr=!1;function Pa(l,d,p){if(Mr)return l(d,p);Mr=!0;try{return vn(l,d,p)}finally{Mr=!1,(It!==null||sn!==null)&&(hn(),be())}}function Ar(l,d){var p=l.stateNode;if(p===null)return null;var x=bu(p);if(x===null)return null;p=x[d];e:switch(d){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(x=!x.disabled)||(l=l.type,x=!(l==="button"||l==="input"||l==="select"||l==="textarea")),l=!x;break e;default:l=!1}if(l)return null;if(p&&typeof p!="function")throw Error(n(231,d,typeof p));return p}var Oa=!1;if(c)try{var Ir={};Object.defineProperty(Ir,"passive",{get:function(){Oa=!0}}),window.addEventListener("test",Ir,Ir),window.removeEventListener("test",Ir,Ir)}catch{Oa=!1}function No(l,d,p,x,j,S,M,H,J){var me=Array.prototype.slice.call(arguments,3);try{d.apply(p,me)}catch(Ce){this.onError(Ce)}}var pr=!1,Rr=null,Pr=!1,mr=null,Or={onError:function(l){pr=!0,Rr=l}};function mi(l,d,p,x,j,S,M,H,J){pr=!1,Rr=null,No.apply(Or,arguments)}function ea(l,d,p,x,j,S,M,H,J){if(mi.apply(this,arguments),pr){if(pr){var me=Rr;pr=!1,Rr=null}else throw Error(n(198));Pr||(Pr=!0,mr=me)}}function St(l){var d=l,p=l;if(l.alternate)for(;d.return;)d=d.return;else{l=d;do d=l,(d.flags&4098)!==0&&(p=d.return),l=d.return;while(l)}return d.tag===3?p:null}function ss(l){if(l.tag===13){var d=l.memoizedState;if(d===null&&(l=l.alternate,l!==null&&(d=l.memoizedState)),d!==null)return d.dehydrated}return null}function Lr(l){if(St(l)!==l)throw Error(n(188))}function La(l){var d=l.alternate;if(!d){if(d=St(l),d===null)throw Error(n(188));return d!==l?null:l}for(var p=l,x=d;;){var j=p.return;if(j===null)break;var S=j.alternate;if(S===null){if(x=j.return,x!==null){p=x;continue}break}if(j.child===S.child){for(S=j.child;S;){if(S===p)return Lr(j),l;if(S===x)return Lr(j),d;S=S.sibling}throw Error(n(188))}if(p.return!==x.return)p=j,x=S;else{for(var M=!1,H=j.child;H;){if(H===p){M=!0,p=j,x=S;break}if(H===x){M=!0,x=j,p=S;break}H=H.sibling}if(!M){for(H=S.child;H;){if(H===p){M=!0,p=S,x=j;break}if(H===x){M=!0,x=S,p=j;break}H=H.sibling}if(!M)throw Error(n(189))}}if(p.alternate!==x)throw Error(n(190))}if(p.tag!==3)throw Error(n(188));return p.stateNode.current===p?l:d}function jl(l){return l=La(l),l!==null?$s(l):null}function $s(l){if(l.tag===5||l.tag===6)return l;for(l=l.child;l!==null;){var d=$s(l);if(d!==null)return d;l=l.sibling}return null}var wo=e.unstable_scheduleCallback,Qs=e.unstable_cancelCallback,Xs=e.unstable_shouldYield,ta=e.unstable_requestPaint,Vt=e.unstable_now,na=e.unstable_getCurrentPriorityLevel,jo=e.unstable_ImmediatePriority,gi=e.unstable_UserBlockingPriority,sa=e.unstable_NormalPriority,Dc=e.unstable_LowPriority,xi=e.unstable_IdlePriority,yi=null,Rs=null;function kl(l){if(Rs&&typeof Rs.onCommitFiberRoot=="function")try{Rs.onCommitFiberRoot(yi,l,void 0,(l.current.flags&128)===128)}catch{}}var fn=Math.clz32?Math.clz32:zc,_c=Math.log,ra=Math.LN2;function zc(l){return l>>>=0,l===0?32:31-(_c(l)/ra|0)|0}var Fs=64,Da=4194304;function Zs(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 er(l,d){var p=l.pendingLanes;if(p===0)return 0;var x=0,j=l.suspendedLanes,S=l.pingedLanes,M=p&268435455;if(M!==0){var H=M&~j;H!==0?x=Zs(H):(S&=M,S!==0&&(x=Zs(S)))}else M=p&~j,M!==0?x=Zs(M):S!==0&&(x=Zs(S));if(x===0)return 0;if(d!==0&&d!==x&&(d&j)===0&&(j=x&-x,S=d&-d,j>=S||j===16&&(S&4194240)!==0))return d;if((x&4)!==0&&(x|=p&16),d=l.entangledLanes,d!==0)for(l=l.entanglements,d&=x;0<d;)p=31-fn(d),j=1<<p,x|=l[p],d&=~j;return x}function ko(l,d){switch(l){case 1:case 2:case 4:return d+250;case 8:case 16:case 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 d+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dr(l,d){for(var p=l.suspendedLanes,x=l.pingedLanes,j=l.expirationTimes,S=l.pendingLanes;0<S;){var M=31-fn(S),H=1<<M,J=j[M];J===-1?((H&p)===0||(H&x)!==0)&&(j[M]=ko(H,d)):J<=d&&(l.expiredLanes|=H),S&=~H}}function aa(l){return l=l.pendingLanes&-1073741825,l!==0?l:l&1073741824?1073741824:0}function bi(){var l=Fs;return Fs<<=1,(Fs&4194240)===0&&(Fs=64),l}function vi(l){for(var d=[],p=0;31>p;p++)d.push(l);return d}function An(l,d,p){l.pendingLanes|=d,d!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,d=31-fn(d),l[d]=p}function Sl(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<p;){var j=31-fn(p),S=1<<j;d[j]=0,x[j]=-1,l[j]=-1,p&=~S}}function ia(l,d){var p=l.entangledLanes|=d;for(l=l.entanglements;p;){var x=31-fn(p),j=1<<x;j&d|l[x]&d&&(l[x]|=d),p&=~j}}var Ct=0;function oa(l){return l&=-l,1<l?4<l?(l&268435455)!==0?16:536870912:4:1}var Nn,tr,So,Co,Eo,_a=!1,Ni=[],nr=null,Kn=null,qn=null,la=new Map,ca=new Map,rs=[],za="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function $a(l,d){switch(l){case"focusin":case"focusout":nr=null;break;case"dragenter":case"dragleave":Kn=null;break;case"mouseover":case"mouseout":qn=null;break;case"pointerover":case"pointerout":la.delete(d.pointerId);break;case"gotpointercapture":case"lostpointercapture":ca.delete(d.pointerId)}}function da(l,d,p,x,j,S){return l===null||l.nativeEvent!==S?(l={blockedOn:d,domEventName:p,eventSystemFlags:x,nativeEvent:S,targetContainers:[j]},d!==null&&(d=Jc(d),d!==null&&tr(d)),l):(l.eventSystemFlags|=x,d=l.targetContainers,j!==null&&d.indexOf(j)===-1&&d.push(j),l)}function ua(l,d,p,x,j){switch(d){case"focusin":return nr=da(nr,l,d,p,x,j),!0;case"dragenter":return Kn=da(Kn,l,d,p,x,j),!0;case"mouseover":return qn=da(qn,l,d,p,x,j),!0;case"pointerover":var S=j.pointerId;return la.set(S,da(la.get(S)||null,l,d,p,x,j)),!0;case"gotpointercapture":return S=j.pointerId,ca.set(S,da(ca.get(S)||null,l,d,p,x,j)),!0}return!1}function _r(l){var d=Io(l.target);if(d!==null){var p=St(d);if(p!==null){if(d=p.tag,d===13){if(d=ss(p),d!==null){l.blockedOn=d,Eo(l.priority,function(){So(p)});return}}else if(d===3&&p.stateNode.current.memoizedState.isDehydrated){l.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}l.blockedOn=null}function Fa(l){if(l.blockedOn!==null)return!1;for(var d=l.targetContainers;0<d.length;){var p=R(l.domEventName,l.eventSystemFlags,d[0],l.nativeEvent);if(p===null){p=l.nativeEvent;var x=new p.constructor(p.type,p);gt=x,p.target.dispatchEvent(x),gt=null}else return d=Jc(p),d!==null&&tr(d),l.blockedOn=p,!1;d.shift()}return!0}function sr(l,d,p){Fa(l)&&p.delete(d)}function $c(){_a=!1,nr!==null&&Fa(nr)&&(nr=null),Kn!==null&&Fa(Kn)&&(Kn=null),qn!==null&&Fa(qn)&&(qn=null),la.forEach(sr),ca.forEach(sr)}function zr(l,d){l.blockedOn===d&&(l.blockedOn=null,_a||(_a=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,$c)))}function $r(l){function d(j){return zr(j,l)}if(0<Ni.length){zr(Ni[0],l);for(var p=1;p<Ni.length;p++){var x=Ni[p];x.blockedOn===l&&(x.blockedOn=null)}}for(nr!==null&&zr(nr,l),Kn!==null&&zr(Kn,l),qn!==null&&zr(qn,l),la.forEach(d),ca.forEach(d),p=0;p<rs.length;p++)x=rs[p],x.blockedOn===l&&(x.blockedOn=null);for(;0<rs.length&&(p=rs[0],p.blockedOn===null);)_r(p),p.blockedOn===null&&rs.shift()}var gr=P.ReactCurrentBatchConfig,ha=!0;function Cl(l,d,p,x){var j=Ct,S=gr.transition;gr.transition=null;try{Ct=1,fa(l,d,p,x)}finally{Ct=j,gr.transition=S}}function To(l,d,p,x){var j=Ct,S=gr.transition;gr.transition=null;try{Ct=4,fa(l,d,p,x)}finally{Ct=j,gr.transition=S}}function fa(l,d,p,x){if(ha){var j=R(l,d,p,x);if(j===null)$p(l,d,x,Ba,p),$a(l,x);else if(ua(j,l,d,p,x))x.stopPropagation();else if($a(l,x),d&4&&-1<za.indexOf(l)){for(;j!==null;){var S=Jc(j);if(S!==null&&Nn(S),S=R(l,d,p,x),S===null&&$p(l,d,x,Ba,p),S===j)break;j=S}j!==null&&x.stopPropagation()}else $p(l,d,x,null,p)}}var Ba=null;function R(l,d,p,x){if(Ba=null,l=ht(x),l=Io(l),l!==null)if(d=St(l),d===null)l=null;else if(p=d.tag,p===13){if(l=ss(d),l!==null)return l;l=null}else if(p===3){if(d.stateNode.current.memoizedState.isDehydrated)return d.tag===3?d.stateNode.containerInfo:null;l=null}else d!==l&&(l=null);return Ba=l,null}function Pe(l){switch(l){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(na()){case jo:return 1;case gi:return 4;case sa:case Dc:return 16;case xi:return 536870912;default:return 16}default:return 16}}var Re=null,qe=null,Nt=null;function wt(){if(Nt)return Nt;var l,d=qe,p=d.length,x,j="value"in Re?Re.value:Re.textContent,S=j.length;for(l=0;l<p&&d[l]===j[l];l++);var M=p-l;for(x=1;x<=M&&d[p-x]===j[S-x];x++);return Nt=j.slice(l,1<x?1-x:void 0)}function pn(l){var d=l.keyCode;return"charCode"in l?(l=l.charCode,l===0&&d===13&&(l=13)):l=d,l===10&&(l=13),32<=l||l===13?l:0}function dt(){return!0}function qt(){return!1}function cn(l){function d(p,x,j,S,M){this._reactName=p,this._targetInst=j,this.type=x,this.nativeEvent=S,this.target=M,this.currentTarget=null;for(var H in l)l.hasOwnProperty(H)&&(p=l[H],this[H]=p?p(S):S[H]);return this.isDefaultPrevented=(S.defaultPrevented!=null?S.defaultPrevented:S.returnValue===!1)?dt:qt,this.isPropagationStopped=qt,this}return q(d.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=dt)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=dt)},persist:function(){},isPersistent:dt}),d}var ys={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Fr=cn(ys),pa=q({},ys,{view:0,detail:0}),Mo=cn(pa),ma,El,wi,Ao=q({},pa,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Tp,button:0,buttons:0,relatedTarget:function(l){return l.relatedTarget===void 0?l.fromElement===l.srcElement?l.toElement:l.fromElement:l.relatedTarget},movementX:function(l){return"movementX"in l?l.movementX:(l!==wi&&(wi&&l.type==="mousemove"?(ma=l.screenX-wi.screenX,El=l.screenY-wi.screenY):El=ma=0,wi=l),ma)},movementY:function(l){return"movementY"in l?l.movementY:El}}),T=cn(Ao),B=q({},Ao,{dataTransfer:0}),he=cn(B),ke=q({},pa,{relatedTarget:0}),Je=cn(ke),ft=q({},ys,{animationName:0,elapsedTime:0,pseudoElement:0}),Lt=cn(ft),bs=q({},ys,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),ga=cn(bs),In=q({},ys,{data:0}),rr=cn(In),Gn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},uu={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},o4={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function l4(l){var d=this.nativeEvent;return d.getModifierState?d.getModifierState(l):(l=o4[l])?!!d[l]:!1}function Tp(){return l4}var c4=q({},pa,{key:function(l){if(l.key){var d=Gn[l.key]||l.key;if(d!=="Unidentified")return d}return l.type==="keypress"?(l=pn(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?uu[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Tp,charCode:function(l){return l.type==="keypress"?pn(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?pn(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),d4=cn(c4),u4=q({},Ao,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ty=cn(u4),h4=q({},pa,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Tp}),f4=cn(h4),p4=q({},ys,{propertyName:0,elapsedTime:0,pseudoElement:0}),m4=cn(p4),g4=q({},Ao,{deltaX:function(l){return"deltaX"in l?l.deltaX:"wheelDeltaX"in l?-l.wheelDeltaX:0},deltaY:function(l){return"deltaY"in l?l.deltaY:"wheelDeltaY"in l?-l.wheelDeltaY:"wheelDelta"in l?-l.wheelDelta:0},deltaZ:0,deltaMode:0}),x4=cn(g4),y4=[9,13,27,32],Mp=c&&"CompositionEvent"in window,Fc=null;c&&"documentMode"in document&&(Fc=document.documentMode);var b4=c&&"TextEvent"in window&&!Fc,My=c&&(!Mp||Fc&&8<Fc&&11>=Fc),Ay=" ",Iy=!1;function Ry(l,d){switch(l){case"keyup":return y4.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Py(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Tl=!1;function v4(l,d){switch(l){case"compositionend":return Py(d);case"keypress":return d.which!==32?null:(Iy=!0,Ay);case"textInput":return l=d.data,l===Ay&&Iy?null:l;default:return null}}function N4(l,d){if(Tl)return l==="compositionend"||!Mp&&Ry(l,d)?(l=wt(),Nt=qe=Re=null,Tl=!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.char.length)return d.char;if(d.which)return String.fromCharCode(d.which)}return null;case"compositionend":return My&&d.locale!=="ko"?null:d.data;default:return null}}var w4={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Oy(l){var d=l&&l.nodeName&&l.nodeName.toLowerCase();return d==="input"?!!w4[l.type]:d==="textarea"}function Ly(l,d,p,x){pe(x),d=gu(d,"onChange"),0<d.length&&(p=new Fr("onChange","change",null,p,x),l.push({event:p,listeners:d}))}var Bc=null,Vc=null;function j4(l){Zy(l,0)}function hu(l){var d=Pl(l);if(Ne(d))return l}function k4(l,d){if(l==="change")return d}var Dy=!1;if(c){var Ap;if(c){var Ip="oninput"in document;if(!Ip){var _y=document.createElement("div");_y.setAttribute("oninput","return;"),Ip=typeof _y.oninput=="function"}Ap=Ip}else Ap=!1;Dy=Ap&&(!document.documentMode||9<document.documentMode)}function zy(){Bc&&(Bc.detachEvent("onpropertychange",$y),Vc=Bc=null)}function $y(l){if(l.propertyName==="value"&&hu(Vc)){var d=[];Ly(d,Vc,l,ht(l)),Pa(j4,d)}}function S4(l,d,p){l==="focusin"?(zy(),Bc=d,Vc=p,Bc.attachEvent("onpropertychange",$y)):l==="focusout"&&zy()}function C4(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return hu(Vc)}function E4(l,d){if(l==="click")return hu(d)}function T4(l,d){if(l==="input"||l==="change")return hu(d)}function M4(l,d){return l===d&&(l!==0||1/l===1/d)||l!==l&&d!==d}var Br=typeof Object.is=="function"?Object.is:M4;function Hc(l,d){if(Br(l,d))return!0;if(typeof l!="object"||l===null||typeof d!="object"||d===null)return!1;var p=Object.keys(l),x=Object.keys(d);if(p.length!==x.length)return!1;for(x=0;x<p.length;x++){var j=p[x];if(!u.call(d,j)||!Br(l[j],d[j]))return!1}return!0}function Fy(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function By(l,d){var p=Fy(l);l=0;for(var x;p;){if(p.nodeType===3){if(x=l+p.textContent.length,l<=d&&x>=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=Fy(p)}}function Vy(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?Vy(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function Hy(){for(var l=window,d=ct();d instanceof l.HTMLIFrameElement;){try{var p=typeof d.contentWindow.location.href=="string"}catch{p=!1}if(p)l=d.contentWindow;else break;d=ct(l.document)}return d}function Rp(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 A4(l){var d=Hy(),p=l.focusedElem,x=l.selectionRange;if(d!==p&&p&&p.ownerDocument&&Vy(p.ownerDocument.documentElement,p)){if(x!==null&&Rp(p)){if(d=x.start,l=x.end,l===void 0&&(l=d),"selectionStart"in p)p.selectionStart=d,p.selectionEnd=Math.min(l,p.value.length);else if(l=(d=p.ownerDocument||document)&&d.defaultView||window,l.getSelection){l=l.getSelection();var j=p.textContent.length,S=Math.min(x.start,j);x=x.end===void 0?S:Math.min(x.end,j),!l.extend&&S>x&&(j=x,x=S,S=j),j=By(p,S);var M=By(p,x);j&&M&&(l.rangeCount!==1||l.anchorNode!==j.node||l.anchorOffset!==j.offset||l.focusNode!==M.node||l.focusOffset!==M.offset)&&(d=d.createRange(),d.setStart(j.node,j.offset),l.removeAllRanges(),S>x?(l.addRange(d),l.extend(M.node,M.offset)):(d.setEnd(M.node,M.offset),l.addRange(d)))}}for(d=[],l=p;l=l.parentNode;)l.nodeType===1&&d.push({element:l,left:l.scrollLeft,top:l.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p<d.length;p++)l=d[p],l.element.scrollLeft=l.left,l.element.scrollTop=l.top}}var I4=c&&"documentMode"in document&&11>=document.documentMode,Ml=null,Pp=null,Uc=null,Op=!1;function Uy(l,d,p){var x=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;Op||Ml==null||Ml!==ct(x)||(x=Ml,"selectionStart"in x&&Rp(x)?x={start:x.selectionStart,end:x.selectionEnd}:(x=(x.ownerDocument&&x.ownerDocument.defaultView||window).getSelection(),x={anchorNode:x.anchorNode,anchorOffset:x.anchorOffset,focusNode:x.focusNode,focusOffset:x.focusOffset}),Uc&&Hc(Uc,x)||(Uc=x,x=gu(Pp,"onSelect"),0<x.length&&(d=new Fr("onSelect","select",null,d,p),l.push({event:d,listeners:x}),d.target=Ml)))}function fu(l,d){var p={};return p[l.toLowerCase()]=d.toLowerCase(),p["Webkit"+l]="webkit"+d,p["Moz"+l]="moz"+d,p}var Al={animationend:fu("Animation","AnimationEnd"),animationiteration:fu("Animation","AnimationIteration"),animationstart:fu("Animation","AnimationStart"),transitionend:fu("Transition","TransitionEnd")},Lp={},Wy={};c&&(Wy=document.createElement("div").style,"AnimationEvent"in window||(delete Al.animationend.animation,delete Al.animationiteration.animation,delete Al.animationstart.animation),"TransitionEvent"in window||delete Al.transitionend.transition);function pu(l){if(Lp[l])return Lp[l];if(!Al[l])return l;var d=Al[l],p;for(p in d)if(d.hasOwnProperty(p)&&p in Wy)return Lp[l]=d[p];return l}var Ky=pu("animationend"),qy=pu("animationiteration"),Gy=pu("animationstart"),Jy=pu("transitionend"),Yy=new Map,Qy="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function ji(l,d){Yy.set(l,d),i(d,[l])}for(var Dp=0;Dp<Qy.length;Dp++){var _p=Qy[Dp],R4=_p.toLowerCase(),P4=_p[0].toUpperCase()+_p.slice(1);ji(R4,"on"+P4)}ji(Ky,"onAnimationEnd"),ji(qy,"onAnimationIteration"),ji(Gy,"onAnimationStart"),ji("dblclick","onDoubleClick"),ji("focusin","onFocus"),ji("focusout","onBlur"),ji(Jy,"onTransitionEnd"),o("onMouseEnter",["mouseout","mouseover"]),o("onMouseLeave",["mouseout","mouseover"]),o("onPointerEnter",["pointerout","pointerover"]),o("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Wc="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),O4=new Set("cancel close invalid load scroll toggle".split(" ").concat(Wc));function Xy(l,d,p){var x=l.type||"unknown-event";l.currentTarget=p,ea(x,d,void 0,l),l.currentTarget=null}function Zy(l,d){d=(d&4)!==0;for(var p=0;p<l.length;p++){var x=l[p],j=x.event;x=x.listeners;e:{var S=void 0;if(d)for(var M=x.length-1;0<=M;M--){var H=x[M],J=H.instance,me=H.currentTarget;if(H=H.listener,J!==S&&j.isPropagationStopped())break e;Xy(j,H,me),S=J}else for(M=0;M<x.length;M++){if(H=x[M],J=H.instance,me=H.currentTarget,H=H.listener,J!==S&&j.isPropagationStopped())break e;Xy(j,H,me),S=J}}}if(Pr)throw l=mr,Pr=!1,mr=null,l}function rn(l,d){var p=d[Wp];p===void 0&&(p=d[Wp]=new Set);var x=l+"__bubble";p.has(x)||(eb(d,l,2,!1),p.add(x))}function zp(l,d,p){var x=0;d&&(x|=4),eb(p,l,x,d)}var mu="_reactListening"+Math.random().toString(36).slice(2);function Kc(l){if(!l[mu]){l[mu]=!0,s.forEach(function(p){p!=="selectionchange"&&(O4.has(p)||zp(p,!1,l),zp(p,!0,l))});var d=l.nodeType===9?l:l.ownerDocument;d===null||d[mu]||(d[mu]=!0,zp("selectionchange",!1,d))}}function eb(l,d,p,x){switch(Pe(d)){case 1:var j=Cl;break;case 4:j=To;break;default:j=fa}p=j.bind(null,d,p,l),j=void 0,!Oa||d!=="touchstart"&&d!=="touchmove"&&d!=="wheel"||(j=!0),x?j!==void 0?l.addEventListener(d,p,{capture:!0,passive:j}):l.addEventListener(d,p,!0):j!==void 0?l.addEventListener(d,p,{passive:j}):l.addEventListener(d,p,!1)}function $p(l,d,p,x,j){var S=x;if((d&1)===0&&(d&2)===0&&x!==null)e:for(;;){if(x===null)return;var M=x.tag;if(M===3||M===4){var H=x.stateNode.containerInfo;if(H===j||H.nodeType===8&&H.parentNode===j)break;if(M===4)for(M=x.return;M!==null;){var J=M.tag;if((J===3||J===4)&&(J=M.stateNode.containerInfo,J===j||J.nodeType===8&&J.parentNode===j))return;M=M.return}for(;H!==null;){if(M=Io(H),M===null)return;if(J=M.tag,J===5||J===6){x=S=M;continue e}H=H.parentNode}}x=x.return}Pa(function(){var me=S,Ce=ht(p),Me=[];e:{var Se=Yy.get(l);if(Se!==void 0){var Fe=Fr,He=l;switch(l){case"keypress":if(pn(p)===0)break e;case"keydown":case"keyup":Fe=d4;break;case"focusin":He="focus",Fe=Je;break;case"focusout":He="blur",Fe=Je;break;case"beforeblur":case"afterblur":Fe=Je;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Fe=T;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Fe=he;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Fe=f4;break;case Ky:case qy:case Gy:Fe=Lt;break;case Jy:Fe=m4;break;case"scroll":Fe=Mo;break;case"wheel":Fe=x4;break;case"copy":case"cut":case"paste":Fe=ga;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Fe=Ty}var Ke=(d&4)!==0,Rn=!Ke&&l==="scroll",de=Ke?Se!==null?Se+"Capture":null:Se;Ke=[];for(var te=me,fe;te!==null;){fe=te;var Ie=fe.stateNode;if(fe.tag===5&&Ie!==null&&(fe=Ie,de!==null&&(Ie=Ar(te,de),Ie!=null&&Ke.push(qc(te,Ie,fe)))),Rn)break;te=te.return}0<Ke.length&&(Se=new Fe(Se,He,null,p,Ce),Me.push({event:Se,listeners:Ke}))}}if((d&7)===0){e:{if(Se=l==="mouseover"||l==="pointerover",Fe=l==="mouseout"||l==="pointerout",Se&&p!==gt&&(He=p.relatedTarget||p.fromElement)&&(Io(He)||He[Va]))break e;if((Fe||Se)&&(Se=Ce.window===Ce?Ce:(Se=Ce.ownerDocument)?Se.defaultView||Se.parentWindow:window,Fe?(He=p.relatedTarget||p.toElement,Fe=me,He=He?Io(He):null,He!==null&&(Rn=St(He),He!==Rn||He.tag!==5&&He.tag!==6)&&(He=null)):(Fe=null,He=me),Fe!==He)){if(Ke=T,Ie="onMouseLeave",de="onMouseEnter",te="mouse",(l==="pointerout"||l==="pointerover")&&(Ke=Ty,Ie="onPointerLeave",de="onPointerEnter",te="pointer"),Rn=Fe==null?Se:Pl(Fe),fe=He==null?Se:Pl(He),Se=new Ke(Ie,te+"leave",Fe,p,Ce),Se.target=Rn,Se.relatedTarget=fe,Ie=null,Io(Ce)===me&&(Ke=new Ke(de,te+"enter",He,p,Ce),Ke.target=fe,Ke.relatedTarget=Rn,Ie=Ke),Rn=Ie,Fe&&He)t:{for(Ke=Fe,de=He,te=0,fe=Ke;fe;fe=Il(fe))te++;for(fe=0,Ie=de;Ie;Ie=Il(Ie))fe++;for(;0<te-fe;)Ke=Il(Ke),te--;for(;0<fe-te;)de=Il(de),fe--;for(;te--;){if(Ke===de||de!==null&&Ke===de.alternate)break t;Ke=Il(Ke),de=Il(de)}Ke=null}else Ke=null;Fe!==null&&tb(Me,Se,Fe,Ke,!1),He!==null&&Rn!==null&&tb(Me,Rn,He,Ke,!0)}}e:{if(Se=me?Pl(me):window,Fe=Se.nodeName&&Se.nodeName.toLowerCase(),Fe==="select"||Fe==="input"&&Se.type==="file")var Ye=k4;else if(Oy(Se))if(Dy)Ye=T4;else{Ye=C4;var rt=S4}else(Fe=Se.nodeName)&&Fe.toLowerCase()==="input"&&(Se.type==="checkbox"||Se.type==="radio")&&(Ye=E4);if(Ye&&(Ye=Ye(l,me))){Ly(Me,Ye,p,Ce);break e}rt&&rt(l,Se,me),l==="focusout"&&(rt=Se._wrapperState)&&rt.controlled&&Se.type==="number"&&st(Se,"number",Se.value)}switch(rt=me?Pl(me):window,l){case"focusin":(Oy(rt)||rt.contentEditable==="true")&&(Ml=rt,Pp=me,Uc=null);break;case"focusout":Uc=Pp=Ml=null;break;case"mousedown":Op=!0;break;case"contextmenu":case"mouseup":case"dragend":Op=!1,Uy(Me,p,Ce);break;case"selectionchange":if(I4)break;case"keydown":case"keyup":Uy(Me,p,Ce)}var at;if(Mp)e:{switch(l){case"compositionstart":var ut="onCompositionStart";break e;case"compositionend":ut="onCompositionEnd";break e;case"compositionupdate":ut="onCompositionUpdate";break e}ut=void 0}else Tl?Ry(l,p)&&(ut="onCompositionEnd"):l==="keydown"&&p.keyCode===229&&(ut="onCompositionStart");ut&&(My&&p.locale!=="ko"&&(Tl||ut!=="onCompositionStart"?ut==="onCompositionEnd"&&Tl&&(at=wt()):(Re=Ce,qe="value"in Re?Re.value:Re.textContent,Tl=!0)),rt=gu(me,ut),0<rt.length&&(ut=new rr(ut,l,null,p,Ce),Me.push({event:ut,listeners:rt}),at?ut.data=at:(at=Py(p),at!==null&&(ut.data=at)))),(at=b4?v4(l,p):N4(l,p))&&(me=gu(me,"onBeforeInput"),0<me.length&&(Ce=new rr("onBeforeInput","beforeinput",null,p,Ce),Me.push({event:Ce,listeners:me}),Ce.data=at))}Zy(Me,d)})}function qc(l,d,p){return{instance:l,listener:d,currentTarget:p}}function gu(l,d){for(var p=d+"Capture",x=[];l!==null;){var j=l,S=j.stateNode;j.tag===5&&S!==null&&(j=S,S=Ar(l,p),S!=null&&x.unshift(qc(l,S,j)),S=Ar(l,d),S!=null&&x.push(qc(l,S,j))),l=l.return}return x}function Il(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5);return l||null}function tb(l,d,p,x,j){for(var S=d._reactName,M=[];p!==null&&p!==x;){var H=p,J=H.alternate,me=H.stateNode;if(J!==null&&J===x)break;H.tag===5&&me!==null&&(H=me,j?(J=Ar(p,S),J!=null&&M.unshift(qc(p,J,H))):j||(J=Ar(p,S),J!=null&&M.push(qc(p,J,H)))),p=p.return}M.length!==0&&l.push({event:d,listeners:M})}var L4=/\r\n?/g,D4=/\u0000|\uFFFD/g;function nb(l){return(typeof l=="string"?l:""+l).replace(L4,`
`).replace(D4,"")}function xu(l,d,p){if(d=nb(d),nb(l)!==d&&p)throw Error(n(425))}function yu(){}var Fp=null,Bp=null;function Vp(l,d){return l==="textarea"||l==="noscript"||typeof d.children=="string"||typeof d.children=="number"||typeof d.dangerouslySetInnerHTML=="object"&&d.dangerouslySetInnerHTML!==null&&d.dangerouslySetInnerHTML.__html!=null}var Hp=typeof setTimeout=="function"?setTimeout:void 0,_4=typeof clearTimeout=="function"?clearTimeout:void 0,sb=typeof Promise=="function"?Promise:void 0,z4=typeof queueMicrotask=="function"?queueMicrotask:typeof sb<"u"?function(l){return sb.resolve(null).then(l).catch($4)}:Hp;function $4(l){setTimeout(function(){throw l})}function Up(l,d){var p=d,x=0;do{var j=p.nextSibling;if(l.removeChild(p),j&&j.nodeType===8)if(p=j.data,p==="/$"){if(x===0){l.removeChild(j),$r(d);return}x--}else p!=="$"&&p!=="$?"&&p!=="$!"||x++;p=j}while(p);$r(d)}function ki(l){for(;l!=null;l=l.nextSibling){var d=l.nodeType;if(d===1||d===3)break;if(d===8){if(d=l.data,d==="$"||d==="$!"||d==="$?")break;if(d==="/$")return null}}return l}function rb(l){l=l.previousSibling;for(var d=0;l;){if(l.nodeType===8){var p=l.data;if(p==="$"||p==="$!"||p==="$?"){if(d===0)return l;d--}else p==="/$"&&d++}l=l.previousSibling}return null}var Rl=Math.random().toString(36).slice(2),xa="__reactFiber$"+Rl,Gc="__reactProps$"+Rl,Va="__reactContainer$"+Rl,Wp="__reactEvents$"+Rl,F4="__reactListeners$"+Rl,B4="__reactHandles$"+Rl;function Io(l){var d=l[xa];if(d)return d;for(var p=l.parentNode;p;){if(d=p[Va]||p[xa]){if(p=d.alternate,d.child!==null||p!==null&&p.child!==null)for(l=rb(l);l!==null;){if(p=l[xa])return p;l=rb(l)}return d}l=p,p=l.parentNode}return null}function Jc(l){return l=l[xa]||l[Va],!l||l.tag!==5&&l.tag!==6&&l.tag!==13&&l.tag!==3?null:l}function Pl(l){if(l.tag===5||l.tag===6)return l.stateNode;throw Error(n(33))}function bu(l){return l[Gc]||null}var Kp=[],Ol=-1;function Si(l){return{current:l}}function an(l){0>Ol||(l.current=Kp[Ol],Kp[Ol]=null,Ol--)}function Xt(l,d){Ol++,Kp[Ol]=l.current,l.current=d}var Ci={},vs=Si(Ci),Bs=Si(!1),Ro=Ci;function Ll(l,d){var p=l.type.contextTypes;if(!p)return Ci;var x=l.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===d)return x.__reactInternalMemoizedMaskedChildContext;var j={},S;for(S in p)j[S]=d[S];return x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=d,l.__reactInternalMemoizedMaskedChildContext=j),j}function Vs(l){return l=l.childContextTypes,l!=null}function vu(){an(Bs),an(vs)}function ab(l,d,p){if(vs.current!==Ci)throw Error(n(168));Xt(vs,d),Xt(Bs,p)}function ib(l,d,p){var x=l.stateNode;if(d=d.childContextTypes,typeof x.getChildContext!="function")return p;x=x.getChildContext();for(var j in x)if(!(j in d))throw Error(n(108,le(l)||"Unknown",j));return q({},p,x)}function Nu(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||Ci,Ro=vs.current,Xt(vs,l),Xt(Bs,Bs.current),!0}function ob(l,d,p){var x=l.stateNode;if(!x)throw Error(n(169));p?(l=ib(l,d,Ro),x.__reactInternalMemoizedMergedChildContext=l,an(Bs),an(vs),Xt(vs,l)):an(Bs),Xt(Bs,p)}var Ha=null,wu=!1,qp=!1;function lb(l){Ha===null?Ha=[l]:Ha.push(l)}function V4(l){wu=!0,lb(l)}function Ei(){if(!qp&&Ha!==null){qp=!0;var l=0,d=Ct;try{var p=Ha;for(Ct=1;l<p.length;l++){var x=p[l];do x=x(!0);while(x!==null)}Ha=null,wu=!1}catch(j){throw Ha!==null&&(Ha=Ha.slice(l+1)),wo(jo,Ei),j}finally{Ct=d,qp=!1}}return null}var Dl=[],_l=0,ju=null,ku=0,xr=[],yr=0,Po=null,Ua=1,Wa="";function Oo(l,d){Dl[_l++]=ku,Dl[_l++]=ju,ju=l,ku=d}function cb(l,d,p){xr[yr++]=Ua,xr[yr++]=Wa,xr[yr++]=Po,Po=l;var x=Ua;l=Wa;var j=32-fn(x)-1;x&=~(1<<j),p+=1;var S=32-fn(d)+j;if(30<S){var M=j-j%5;S=(x&(1<<M)-1).toString(32),x>>=M,j-=M,Ua=1<<32-fn(d)+j|p<<j|x,Wa=S+l}else Ua=1<<S|p<<j|x,Wa=l}function Gp(l){l.return!==null&&(Oo(l,1),cb(l,1,0))}function Jp(l){for(;l===ju;)ju=Dl[--_l],Dl[_l]=null,ku=Dl[--_l],Dl[_l]=null;for(;l===Po;)Po=xr[--yr],xr[yr]=null,Wa=xr[--yr],xr[yr]=null,Ua=xr[--yr],xr[yr]=null}var ar=null,ir=null,dn=!1,Vr=null;function db(l,d){var p=wr(5,null,null,0);p.elementType="DELETED",p.stateNode=d,p.return=l,d=l.deletions,d===null?(l.deletions=[p],l.flags|=16):d.push(p)}function ub(l,d){switch(l.tag){case 5:var p=l.type;return d=d.nodeType!==1||p.toLowerCase()!==d.nodeName.toLowerCase()?null:d,d!==null?(l.stateNode=d,ar=l,ir=ki(d.firstChild),!0):!1;case 6:return d=l.pendingProps===""||d.nodeType!==3?null:d,d!==null?(l.stateNode=d,ar=l,ir=null,!0):!1;case 13:return d=d.nodeType!==8?null:d,d!==null?(p=Po!==null?{id:Ua,overflow:Wa}:null,l.memoizedState={dehydrated:d,treeContext:p,retryLane:1073741824},p=wr(18,null,null,0),p.stateNode=d,p.return=l,l.child=p,ar=l,ir=null,!0):!1;default:return!1}}function Yp(l){return(l.mode&1)!==0&&(l.flags&128)===0}function Qp(l){if(dn){var d=ir;if(d){var p=d;if(!ub(l,d)){if(Yp(l))throw Error(n(418));d=ki(p.nextSibling);var x=ar;d&&ub(l,d)?db(x,p):(l.flags=l.flags&-4097|2,dn=!1,ar=l)}}else{if(Yp(l))throw Error(n(418));l.flags=l.flags&-4097|2,dn=!1,ar=l}}}function hb(l){for(l=l.return;l!==null&&l.tag!==5&&l.tag!==3&&l.tag!==13;)l=l.return;ar=l}function Su(l){if(l!==ar)return!1;if(!dn)return hb(l),dn=!0,!1;var d;if((d=l.tag!==3)&&!(d=l.tag!==5)&&(d=l.type,d=d!=="head"&&d!=="body"&&!Vp(l.type,l.memoizedProps)),d&&(d=ir)){if(Yp(l))throw fb(),Error(n(418));for(;d;)db(l,d),d=ki(d.nextSibling)}if(hb(l),l.tag===13){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(n(317));e:{for(l=l.nextSibling,d=0;l;){if(l.nodeType===8){var p=l.data;if(p==="/$"){if(d===0){ir=ki(l.nextSibling);break e}d--}else p!=="$"&&p!=="$!"&&p!=="$?"||d++}l=l.nextSibling}ir=null}}else ir=ar?ki(l.stateNode.nextSibling):null;return!0}function fb(){for(var l=ir;l;)l=ki(l.nextSibling)}function zl(){ir=ar=null,dn=!1}function Xp(l){Vr===null?Vr=[l]:Vr.push(l)}var H4=P.ReactCurrentBatchConfig;function Yc(l,d,p){if(l=p.ref,l!==null&&typeof l!="function"&&typeof l!="object"){if(p._owner){if(p=p._owner,p){if(p.tag!==1)throw Error(n(309));var x=p.stateNode}if(!x)throw Error(n(147,l));var j=x,S=""+l;return d!==null&&d.ref!==null&&typeof d.ref=="function"&&d.ref._stringRef===S?d.ref:(d=function(M){var H=j.refs;M===null?delete H[S]:H[S]=M},d._stringRef=S,d)}if(typeof l!="string")throw Error(n(284));if(!p._owner)throw Error(n(290,l))}return l}function Cu(l,d){throw l=Object.prototype.toString.call(d),Error(n(31,l==="[object Object]"?"object with keys {"+Object.keys(d).join(", ")+"}":l))}function pb(l){var d=l._init;return d(l._payload)}function mb(l){function d(de,te){if(l){var fe=de.deletions;fe===null?(de.deletions=[te],de.flags|=16):fe.push(te)}}function p(de,te){if(!l)return null;for(;te!==null;)d(de,te),te=te.sibling;return null}function x(de,te){for(de=new Map;te!==null;)te.key!==null?de.set(te.key,te):de.set(te.index,te),te=te.sibling;return de}function j(de,te){return de=Li(de,te),de.index=0,de.sibling=null,de}function S(de,te,fe){return de.index=fe,l?(fe=de.alternate,fe!==null?(fe=fe.index,fe<te?(de.flags|=2,te):fe):(de.flags|=2,te)):(de.flags|=1048576,te)}function M(de){return l&&de.alternate===null&&(de.flags|=2),de}function H(de,te,fe,Ie){return te===null||te.tag!==6?(te=Hm(fe,de.mode,Ie),te.return=de,te):(te=j(te,fe),te.return=de,te)}function J(de,te,fe,Ie){var Ye=fe.type;return Ye===_?Ce(de,te,fe.props.children,Ie,fe.key):te!==null&&(te.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===$&&pb(Ye)===te.type)?(Ie=j(te,fe.props),Ie.ref=Yc(de,te,fe),Ie.return=de,Ie):(Ie=Yu(fe.type,fe.key,fe.props,null,de.mode,Ie),Ie.ref=Yc(de,te,fe),Ie.return=de,Ie)}function me(de,te,fe,Ie){return te===null||te.tag!==4||te.stateNode.containerInfo!==fe.containerInfo||te.stateNode.implementation!==fe.implementation?(te=Um(fe,de.mode,Ie),te.return=de,te):(te=j(te,fe.children||[]),te.return=de,te)}function Ce(de,te,fe,Ie,Ye){return te===null||te.tag!==7?(te=Vo(fe,de.mode,Ie,Ye),te.return=de,te):(te=j(te,fe),te.return=de,te)}function Me(de,te,fe){if(typeof te=="string"&&te!==""||typeof te=="number")return te=Hm(""+te,de.mode,fe),te.return=de,te;if(typeof te=="object"&&te!==null){switch(te.$$typeof){case O:return fe=Yu(te.type,te.key,te.props,null,de.mode,fe),fe.ref=Yc(de,null,te),fe.return=de,fe;case U:return te=Um(te,de.mode,fe),te.return=de,te;case $:var Ie=te._init;return Me(de,Ie(te._payload),fe)}if(kt(te)||ie(te))return te=Vo(te,de.mode,fe,null),te.return=de,te;Cu(de,te)}return null}function Se(de,te,fe,Ie){var Ye=te!==null?te.key:null;if(typeof fe=="string"&&fe!==""||typeof fe=="number")return Ye!==null?null:H(de,te,""+fe,Ie);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case O:return fe.key===Ye?J(de,te,fe,Ie):null;case U:return fe.key===Ye?me(de,te,fe,Ie):null;case $:return Ye=fe._init,Se(de,te,Ye(fe._payload),Ie)}if(kt(fe)||ie(fe))return Ye!==null?null:Ce(de,te,fe,Ie,null);Cu(de,fe)}return null}function Fe(de,te,fe,Ie,Ye){if(typeof Ie=="string"&&Ie!==""||typeof Ie=="number")return de=de.get(fe)||null,H(te,de,""+Ie,Ye);if(typeof Ie=="object"&&Ie!==null){switch(Ie.$$typeof){case O:return de=de.get(Ie.key===null?fe:Ie.key)||null,J(te,de,Ie,Ye);case U:return de=de.get(Ie.key===null?fe:Ie.key)||null,me(te,de,Ie,Ye);case $:var rt=Ie._init;return Fe(de,te,fe,rt(Ie._payload),Ye)}if(kt(Ie)||ie(Ie))return de=de.get(fe)||null,Ce(te,de,Ie,Ye,null);Cu(te,Ie)}return null}function He(de,te,fe,Ie){for(var Ye=null,rt=null,at=te,ut=te=0,Qn=null;at!==null&&ut<fe.length;ut++){at.index>ut?(Qn=at,at=null):Qn=at.sibling;var Mt=Se(de,at,fe[ut],Ie);if(Mt===null){at===null&&(at=Qn);break}l&&at&&Mt.alternate===null&&d(de,at),te=S(Mt,te,ut),rt===null?Ye=Mt:rt.sibling=Mt,rt=Mt,at=Qn}if(ut===fe.length)return p(de,at),dn&&Oo(de,ut),Ye;if(at===null){for(;ut<fe.length;ut++)at=Me(de,fe[ut],Ie),at!==null&&(te=S(at,te,ut),rt===null?Ye=at:rt.sibling=at,rt=at);return dn&&Oo(de,ut),Ye}for(at=x(de,at);ut<fe.length;ut++)Qn=Fe(at,de,ut,fe[ut],Ie),Qn!==null&&(l&&Qn.alternate!==null&&at.delete(Qn.key===null?ut:Qn.key),te=S(Qn,te,ut),rt===null?Ye=Qn:rt.sibling=Qn,rt=Qn);return l&&at.forEach(function(Di){return d(de,Di)}),dn&&Oo(de,ut),Ye}function Ke(de,te,fe,Ie){var Ye=ie(fe);if(typeof Ye!="function")throw Error(n(150));if(fe=Ye.call(fe),fe==null)throw Error(n(151));for(var rt=Ye=null,at=te,ut=te=0,Qn=null,Mt=fe.next();at!==null&&!Mt.done;ut++,Mt=fe.next()){at.index>ut?(Qn=at,at=null):Qn=at.sibling;var Di=Se(de,at,Mt.value,Ie);if(Di===null){at===null&&(at=Qn);break}l&&at&&Di.alternate===null&&d(de,at),te=S(Di,te,ut),rt===null?Ye=Di:rt.sibling=Di,rt=Di,at=Qn}if(Mt.done)return p(de,at),dn&&Oo(de,ut),Ye;if(at===null){for(;!Mt.done;ut++,Mt=fe.next())Mt=Me(de,Mt.value,Ie),Mt!==null&&(te=S(Mt,te,ut),rt===null?Ye=Mt:rt.sibling=Mt,rt=Mt);return dn&&Oo(de,ut),Ye}for(at=x(de,at);!Mt.done;ut++,Mt=fe.next())Mt=Fe(at,de,ut,Mt.value,Ie),Mt!==null&&(l&&Mt.alternate!==null&&at.delete(Mt.key===null?ut:Mt.key),te=S(Mt,te,ut),rt===null?Ye=Mt:rt.sibling=Mt,rt=Mt);return l&&at.forEach(function(wE){return d(de,wE)}),dn&&Oo(de,ut),Ye}function Rn(de,te,fe,Ie){if(typeof fe=="object"&&fe!==null&&fe.type===_&&fe.key===null&&(fe=fe.props.children),typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case O:e:{for(var Ye=fe.key,rt=te;rt!==null;){if(rt.key===Ye){if(Ye=fe.type,Ye===_){if(rt.tag===7){p(de,rt.sibling),te=j(rt,fe.props.children),te.return=de,de=te;break e}}else if(rt.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===$&&pb(Ye)===rt.type){p(de,rt.sibling),te=j(rt,fe.props),te.ref=Yc(de,rt,fe),te.return=de,de=te;break e}p(de,rt);break}else d(de,rt);rt=rt.sibling}fe.type===_?(te=Vo(fe.props.children,de.mode,Ie,fe.key),te.return=de,de=te):(Ie=Yu(fe.type,fe.key,fe.props,null,de.mode,Ie),Ie.ref=Yc(de,te,fe),Ie.return=de,de=Ie)}return M(de);case U:e:{for(rt=fe.key;te!==null;){if(te.key===rt)if(te.tag===4&&te.stateNode.containerInfo===fe.containerInfo&&te.stateNode.implementation===fe.implementation){p(de,te.sibling),te=j(te,fe.children||[]),te.return=de,de=te;break e}else{p(de,te);break}else d(de,te);te=te.sibling}te=Um(fe,de.mode,Ie),te.return=de,de=te}return M(de);case $:return rt=fe._init,Rn(de,te,rt(fe._payload),Ie)}if(kt(fe))return He(de,te,fe,Ie);if(ie(fe))return Ke(de,te,fe,Ie);Cu(de,fe)}return typeof fe=="string"&&fe!==""||typeof fe=="number"?(fe=""+fe,te!==null&&te.tag===6?(p(de,te.sibling),te=j(te,fe),te.return=de,de=te):(p(de,te),te=Hm(fe,de.mode,Ie),te.return=de,de=te),M(de)):p(de,te)}return Rn}var $l=mb(!0),gb=mb(!1),Eu=Si(null),Tu=null,Fl=null,Zp=null;function em(){Zp=Fl=Tu=null}function tm(l){var d=Eu.current;an(Eu),l._currentValue=d}function nm(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 Bl(l,d){Tu=l,Zp=Fl=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(Hs=!0),l.firstContext=null)}function br(l){var d=l._currentValue;if(Zp!==l)if(l={context:l,memoizedValue:d,next:null},Fl===null){if(Tu===null)throw Error(n(308));Fl=l,Tu.dependencies={lanes:0,firstContext:l}}else Fl=Fl.next=l;return d}var Lo=null;function sm(l){Lo===null?Lo=[l]:Lo.push(l)}function xb(l,d,p,x){var j=d.interleaved;return j===null?(p.next=p,sm(d)):(p.next=j.next,j.next=p),d.interleaved=p,Ka(l,x)}function Ka(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 Ti=!1;function rm(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function yb(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 qa(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function Mi(l,d,p){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,(Tt&2)!==0){var j=x.pending;return j===null?d.next=d:(d.next=j.next,j.next=d),x.pending=d,Ka(l,p)}return j=x.interleaved,j===null?(d.next=d,sm(x)):(d.next=j.next,j.next=d),x.interleaved=d,Ka(l,p)}function Mu(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,ia(l,p)}}function bb(l,d){var p=l.updateQueue,x=l.alternate;if(x!==null&&(x=x.updateQueue,p===x)){var j=null,S=null;if(p=p.firstBaseUpdate,p!==null){do{var M={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};S===null?j=S=M:S=S.next=M,p=p.next}while(p!==null);S===null?j=S=d:S=S.next=d}else j=S=d;p={baseState:x.baseState,firstBaseUpdate:j,lastBaseUpdate:S,shared:x.shared,effects:x.effects},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=d:l.next=d,p.lastBaseUpdate=d}function Au(l,d,p,x){var j=l.updateQueue;Ti=!1;var S=j.firstBaseUpdate,M=j.lastBaseUpdate,H=j.shared.pending;if(H!==null){j.shared.pending=null;var J=H,me=J.next;J.next=null,M===null?S=me:M.next=me,M=J;var Ce=l.alternate;Ce!==null&&(Ce=Ce.updateQueue,H=Ce.lastBaseUpdate,H!==M&&(H===null?Ce.firstBaseUpdate=me:H.next=me,Ce.lastBaseUpdate=J))}if(S!==null){var Me=j.baseState;M=0,Ce=me=J=null,H=S;do{var Se=H.lane,Fe=H.eventTime;if((x&Se)===Se){Ce!==null&&(Ce=Ce.next={eventTime:Fe,lane:0,tag:H.tag,payload:H.payload,callback:H.callback,next:null});e:{var He=l,Ke=H;switch(Se=d,Fe=p,Ke.tag){case 1:if(He=Ke.payload,typeof He=="function"){Me=He.call(Fe,Me,Se);break e}Me=He;break e;case 3:He.flags=He.flags&-65537|128;case 0:if(He=Ke.payload,Se=typeof He=="function"?He.call(Fe,Me,Se):He,Se==null)break e;Me=q({},Me,Se);break e;case 2:Ti=!0}}H.callback!==null&&H.lane!==0&&(l.flags|=64,Se=j.effects,Se===null?j.effects=[H]:Se.push(H))}else Fe={eventTime:Fe,lane:Se,tag:H.tag,payload:H.payload,callback:H.callback,next:null},Ce===null?(me=Ce=Fe,J=Me):Ce=Ce.next=Fe,M|=Se;if(H=H.next,H===null){if(H=j.shared.pending,H===null)break;Se=H,H=Se.next,Se.next=null,j.lastBaseUpdate=Se,j.shared.pending=null}}while(!0);if(Ce===null&&(J=Me),j.baseState=J,j.firstBaseUpdate=me,j.lastBaseUpdate=Ce,d=j.shared.interleaved,d!==null){j=d;do M|=j.lane,j=j.next;while(j!==d)}else S===null&&(j.shared.lanes=0);zo|=M,l.lanes=M,l.memoizedState=Me}}function vb(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;d<l.length;d++){var x=l[d],j=x.callback;if(j!==null){if(x.callback=null,x=p,typeof j!="function")throw Error(n(191,j));j.call(x)}}}var Qc={},ya=Si(Qc),Xc=Si(Qc),Zc=Si(Qc);function Do(l){if(l===Qc)throw Error(n(174));return l}function am(l,d){switch(Xt(Zc,d),Xt(Xc,l),Xt(ya,Qc),l=d.nodeType,l){case 9:case 11:d=(d=d.documentElement)?d.namespaceURI:ts(null,"");break;default:l=l===8?d.parentNode:d,d=l.namespaceURI||null,l=l.tagName,d=ts(d,l)}an(ya),Xt(ya,d)}function Vl(){an(ya),an(Xc),an(Zc)}function Nb(l){Do(Zc.current);var d=Do(ya.current),p=ts(d,l.type);d!==p&&(Xt(Xc,l),Xt(ya,p))}function im(l){Xc.current===l&&(an(ya),an(Xc))}var mn=Si(0);function Iu(l){for(var d=l;d!==null;){if(d.tag===13){var p=d.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||p.data==="$?"||p.data==="$!"))return d}else if(d.tag===19&&d.memoizedProps.revealOrder!==void 0){if((d.flags&128)!==0)return d}else if(d.child!==null){d.child.return=d,d=d.child;continue}if(d===l)break;for(;d.sibling===null;){if(d.return===null||d.return===l)return null;d=d.return}d.sibling.return=d.return,d=d.sibling}return null}var om=[];function lm(){for(var l=0;l<om.length;l++)om[l]._workInProgressVersionPrimary=null;om.length=0}var Ru=P.ReactCurrentDispatcher,cm=P.ReactCurrentBatchConfig,_o=0,gn=null,Bn=null,Jn=null,Pu=!1,ed=!1,td=0,U4=0;function Ns(){throw Error(n(321))}function dm(l,d){if(d===null)return!1;for(var p=0;p<d.length&&p<l.length;p++)if(!Br(l[p],d[p]))return!1;return!0}function um(l,d,p,x,j,S){if(_o=S,gn=d,d.memoizedState=null,d.updateQueue=null,d.lanes=0,Ru.current=l===null||l.memoizedState===null?G4:J4,l=p(x,j),ed){S=0;do{if(ed=!1,td=0,25<=S)throw Error(n(301));S+=1,Jn=Bn=null,d.updateQueue=null,Ru.current=Y4,l=p(x,j)}while(ed)}if(Ru.current=Du,d=Bn!==null&&Bn.next!==null,_o=0,Jn=Bn=gn=null,Pu=!1,d)throw Error(n(300));return l}function hm(){var l=td!==0;return td=0,l}function ba(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Jn===null?gn.memoizedState=Jn=l:Jn=Jn.next=l,Jn}function vr(){if(Bn===null){var l=gn.alternate;l=l!==null?l.memoizedState:null}else l=Bn.next;var d=Jn===null?gn.memoizedState:Jn.next;if(d!==null)Jn=d,Bn=l;else{if(l===null)throw Error(n(310));Bn=l,l={memoizedState:Bn.memoizedState,baseState:Bn.baseState,baseQueue:Bn.baseQueue,queue:Bn.queue,next:null},Jn===null?gn.memoizedState=Jn=l:Jn=Jn.next=l}return Jn}function nd(l,d){return typeof d=="function"?d(l):d}function fm(l){var d=vr(),p=d.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=l;var x=Bn,j=x.baseQueue,S=p.pending;if(S!==null){if(j!==null){var M=j.next;j.next=S.next,S.next=M}x.baseQueue=j=S,p.pending=null}if(j!==null){S=j.next,x=x.baseState;var H=M=null,J=null,me=S;do{var Ce=me.lane;if((_o&Ce)===Ce)J!==null&&(J=J.next={lane:0,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null}),x=me.hasEagerState?me.eagerState:l(x,me.action);else{var Me={lane:Ce,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null};J===null?(H=J=Me,M=x):J=J.next=Me,gn.lanes|=Ce,zo|=Ce}me=me.next}while(me!==null&&me!==S);J===null?M=x:J.next=H,Br(x,d.memoizedState)||(Hs=!0),d.memoizedState=x,d.baseState=M,d.baseQueue=J,p.lastRenderedState=x}if(l=p.interleaved,l!==null){j=l;do S=j.lane,gn.lanes|=S,zo|=S,j=j.next;while(j!==l)}else j===null&&(p.lanes=0);return[d.memoizedState,p.dispatch]}function pm(l){var d=vr(),p=d.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=l;var x=p.dispatch,j=p.pending,S=d.memoizedState;if(j!==null){p.pending=null;var M=j=j.next;do S=l(S,M.action),M=M.next;while(M!==j);Br(S,d.memoizedState)||(Hs=!0),d.memoizedState=S,d.baseQueue===null&&(d.baseState=S),p.lastRenderedState=S}return[S,x]}function wb(){}function jb(l,d){var p=gn,x=vr(),j=d(),S=!Br(x.memoizedState,j);if(S&&(x.memoizedState=j,Hs=!0),x=x.queue,mm(Cb.bind(null,p,x,l),[l]),x.getSnapshot!==d||S||Jn!==null&&Jn.memoizedState.tag&1){if(p.flags|=2048,sd(9,Sb.bind(null,p,x,j,d),void 0,null),Yn===null)throw Error(n(349));(_o&30)!==0||kb(p,d,j)}return j}function kb(l,d,p){l.flags|=16384,l={getSnapshot:d,value:p},d=gn.updateQueue,d===null?(d={lastEffect:null,stores:null},gn.updateQueue=d,d.stores=[l]):(p=d.stores,p===null?d.stores=[l]:p.push(l))}function Sb(l,d,p,x){d.value=p,d.getSnapshot=x,Eb(d)&&Tb(l)}function Cb(l,d,p){return p(function(){Eb(d)&&Tb(l)})}function Eb(l){var d=l.getSnapshot;l=l.value;try{var p=d();return!Br(l,p)}catch{return!0}}function Tb(l){var d=Ka(l,1);d!==null&&Kr(d,l,1,-1)}function Mb(l){var d=ba();return typeof l=="function"&&(l=l()),d.memoizedState=d.baseState=l,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:nd,lastRenderedState:l},d.queue=l,l=l.dispatch=q4.bind(null,gn,l),[d.memoizedState,l]}function sd(l,d,p,x){return l={tag:l,create:d,destroy:p,deps:x,next:null},d=gn.updateQueue,d===null?(d={lastEffect:null,stores:null},gn.updateQueue=d,d.lastEffect=l.next=l):(p=d.lastEffect,p===null?d.lastEffect=l.next=l:(x=p.next,p.next=l,l.next=x,d.lastEffect=l)),l}function Ab(){return vr().memoizedState}function Ou(l,d,p,x){var j=ba();gn.flags|=l,j.memoizedState=sd(1|d,p,void 0,x===void 0?null:x)}function Lu(l,d,p,x){var j=vr();x=x===void 0?null:x;var S=void 0;if(Bn!==null){var M=Bn.memoizedState;if(S=M.destroy,x!==null&&dm(x,M.deps)){j.memoizedState=sd(d,p,S,x);return}}gn.flags|=l,j.memoizedState=sd(1|d,p,S,x)}function Ib(l,d){return Ou(8390656,8,l,d)}function mm(l,d){return Lu(2048,8,l,d)}function Rb(l,d){return Lu(4,2,l,d)}function Pb(l,d){return Lu(4,4,l,d)}function Ob(l,d){if(typeof d=="function")return l=l(),d(l),function(){d(null)};if(d!=null)return l=l(),d.current=l,function(){d.current=null}}function Lb(l,d,p){return p=p!=null?p.concat([l]):null,Lu(4,4,Ob.bind(null,d,l),p)}function gm(){}function Db(l,d){var p=vr();d=d===void 0?null:d;var x=p.memoizedState;return x!==null&&d!==null&&dm(d,x[1])?x[0]:(p.memoizedState=[l,d],l)}function _b(l,d){var p=vr();d=d===void 0?null:d;var x=p.memoizedState;return x!==null&&d!==null&&dm(d,x[1])?x[0]:(l=l(),p.memoizedState=[l,d],l)}function zb(l,d,p){return(_o&21)===0?(l.baseState&&(l.baseState=!1,Hs=!0),l.memoizedState=p):(Br(p,d)||(p=bi(),gn.lanes|=p,zo|=p,l.baseState=!0),d)}function W4(l,d){var p=Ct;Ct=p!==0&&4>p?p:4,l(!0);var x=cm.transition;cm.transition={};try{l(!1),d()}finally{Ct=p,cm.transition=x}}function $b(){return vr().memoizedState}function K4(l,d,p){var x=Pi(l);if(p={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null},Fb(l))Bb(d,p);else if(p=xb(l,d,p,x),p!==null){var j=Os();Kr(p,l,x,j),Vb(p,d,x)}}function q4(l,d,p){var x=Pi(l),j={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null};if(Fb(l))Bb(d,j);else{var S=l.alternate;if(l.lanes===0&&(S===null||S.lanes===0)&&(S=d.lastRenderedReducer,S!==null))try{var M=d.lastRenderedState,H=S(M,p);if(j.hasEagerState=!0,j.eagerState=H,Br(H,M)){var J=d.interleaved;J===null?(j.next=j,sm(d)):(j.next=J.next,J.next=j),d.interleaved=j;return}}catch{}finally{}p=xb(l,d,j,x),p!==null&&(j=Os(),Kr(p,l,x,j),Vb(p,d,x))}}function Fb(l){var d=l.alternate;return l===gn||d!==null&&d===gn}function Bb(l,d){ed=Pu=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function Vb(l,d,p){if((p&4194240)!==0){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,ia(l,p)}}var Du={readContext:br,useCallback:Ns,useContext:Ns,useEffect:Ns,useImperativeHandle:Ns,useInsertionEffect:Ns,useLayoutEffect:Ns,useMemo:Ns,useReducer:Ns,useRef:Ns,useState:Ns,useDebugValue:Ns,useDeferredValue:Ns,useTransition:Ns,useMutableSource:Ns,useSyncExternalStore:Ns,useId:Ns,unstable_isNewReconciler:!1},G4={readContext:br,useCallback:function(l,d){return ba().memoizedState=[l,d===void 0?null:d],l},useContext:br,useEffect:Ib,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,Ou(4194308,4,Ob.bind(null,d,l),p)},useLayoutEffect:function(l,d){return Ou(4194308,4,l,d)},useInsertionEffect:function(l,d){return Ou(4,2,l,d)},useMemo:function(l,d){var p=ba();return d=d===void 0?null:d,l=l(),p.memoizedState=[l,d],l},useReducer:function(l,d,p){var x=ba();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=K4.bind(null,gn,l),[x.memoizedState,l]},useRef:function(l){var d=ba();return l={current:l},d.memoizedState=l},useState:Mb,useDebugValue:gm,useDeferredValue:function(l){return ba().memoizedState=l},useTransition:function(){var l=Mb(!1),d=l[0];return l=W4.bind(null,l[1]),ba().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var x=gn,j=ba();if(dn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),Yn===null)throw Error(n(349));(_o&30)!==0||kb(x,d,p)}j.memoizedState=p;var S={value:p,getSnapshot:d};return j.queue=S,Ib(Cb.bind(null,x,S,l),[l]),x.flags|=2048,sd(9,Sb.bind(null,x,S,p,d),void 0,null),p},useId:function(){var l=ba(),d=Yn.identifierPrefix;if(dn){var p=Wa,x=Ua;p=(x&~(1<<32-fn(x)-1)).toString(32)+p,d=":"+d+"R"+p,p=td++,0<p&&(d+="H"+p.toString(32)),d+=":"}else p=U4++,d=":"+d+"r"+p.toString(32)+":";return l.memoizedState=d},unstable_isNewReconciler:!1},J4={readContext:br,useCallback:Db,useContext:br,useEffect:mm,useImperativeHandle:Lb,useInsertionEffect:Rb,useLayoutEffect:Pb,useMemo:_b,useReducer:fm,useRef:Ab,useState:function(){return fm(nd)},useDebugValue:gm,useDeferredValue:function(l){var d=vr();return zb(d,Bn.memoizedState,l)},useTransition:function(){var l=fm(nd)[0],d=vr().memoizedState;return[l,d]},useMutableSource:wb,useSyncExternalStore:jb,useId:$b,unstable_isNewReconciler:!1},Y4={readContext:br,useCallback:Db,useContext:br,useEffect:mm,useImperativeHandle:Lb,useInsertionEffect:Rb,useLayoutEffect:Pb,useMemo:_b,useReducer:pm,useRef:Ab,useState:function(){return pm(nd)},useDebugValue:gm,useDeferredValue:function(l){var d=vr();return Bn===null?d.memoizedState=l:zb(d,Bn.memoizedState,l)},useTransition:function(){var l=pm(nd)[0],d=vr().memoizedState;return[l,d]},useMutableSource:wb,useSyncExternalStore:jb,useId:$b,unstable_isNewReconciler:!1};function Hr(l,d){if(l&&l.defaultProps){d=q({},d),l=l.defaultProps;for(var p in l)d[p]===void 0&&(d[p]=l[p]);return d}return d}function xm(l,d,p,x){d=l.memoizedState,p=p(x,d),p=p==null?d:q({},d,p),l.memoizedState=p,l.lanes===0&&(l.updateQueue.baseState=p)}var _u={isMounted:function(l){return(l=l._reactInternals)?St(l)===l:!1},enqueueSetState:function(l,d,p){l=l._reactInternals;var x=Os(),j=Pi(l),S=qa(x,j);S.payload=d,p!=null&&(S.callback=p),d=Mi(l,S,j),d!==null&&(Kr(d,l,j,x),Mu(d,l,j))},enqueueReplaceState:function(l,d,p){l=l._reactInternals;var x=Os(),j=Pi(l),S=qa(x,j);S.tag=1,S.payload=d,p!=null&&(S.callback=p),d=Mi(l,S,j),d!==null&&(Kr(d,l,j,x),Mu(d,l,j))},enqueueForceUpdate:function(l,d){l=l._reactInternals;var p=Os(),x=Pi(l),j=qa(p,x);j.tag=2,d!=null&&(j.callback=d),d=Mi(l,j,x),d!==null&&(Kr(d,l,x,p),Mu(d,l,x))}};function Hb(l,d,p,x,j,S,M){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(x,S,M):d.prototype&&d.prototype.isPureReactComponent?!Hc(p,x)||!Hc(j,S):!0}function Ub(l,d,p){var x=!1,j=Ci,S=d.contextType;return typeof S=="object"&&S!==null?S=br(S):(j=Vs(d)?Ro:vs.current,x=d.contextTypes,S=(x=x!=null)?Ll(l,j):Ci),d=new d(p,S),l.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=_u,l.stateNode=d,d._reactInternals=l,x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=j,l.__reactInternalMemoizedMaskedChildContext=S),d}function Wb(l,d,p,x){l=d.state,typeof d.componentWillReceiveProps=="function"&&d.componentWillReceiveProps(p,x),typeof d.UNSAFE_componentWillReceiveProps=="function"&&d.UNSAFE_componentWillReceiveProps(p,x),d.state!==l&&_u.enqueueReplaceState(d,d.state,null)}function ym(l,d,p,x){var j=l.stateNode;j.props=p,j.state=l.memoizedState,j.refs={},rm(l);var S=d.contextType;typeof S=="object"&&S!==null?j.context=br(S):(S=Vs(d)?Ro:vs.current,j.context=Ll(l,S)),j.state=l.memoizedState,S=d.getDerivedStateFromProps,typeof S=="function"&&(xm(l,d,S,p),j.state=l.memoizedState),typeof d.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(d=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),d!==j.state&&_u.enqueueReplaceState(j,j.state,null),Au(l,p,j,x),j.state=l.memoizedState),typeof j.componentDidMount=="function"&&(l.flags|=4194308)}function Hl(l,d){try{var p="",x=d;do p+=Te(x),x=x.return;while(x);var j=p}catch(S){j=`
Error generating stack: `+S.message+`
`+S.stack}return{value:l,source:d,stack:j,digest:null}}function bm(l,d,p){return{value:l,source:null,stack:p??null,digest:d??null}}function vm(l,d){try{console.error(d.value)}catch(p){setTimeout(function(){throw p})}}var Q4=typeof WeakMap=="function"?WeakMap:Map;function Kb(l,d,p){p=qa(-1,p),p.tag=3,p.payload={element:null};var x=d.value;return p.callback=function(){Uu||(Uu=!0,Lm=x),vm(l,d)},p}function qb(l,d,p){p=qa(-1,p),p.tag=3;var x=l.type.getDerivedStateFromError;if(typeof x=="function"){var j=d.value;p.payload=function(){return x(j)},p.callback=function(){vm(l,d)}}var S=l.stateNode;return S!==null&&typeof S.componentDidCatch=="function"&&(p.callback=function(){vm(l,d),typeof x!="function"&&(Ii===null?Ii=new Set([this]):Ii.add(this));var M=d.stack;this.componentDidCatch(d.value,{componentStack:M!==null?M:""})}),p}function Gb(l,d,p){var x=l.pingCache;if(x===null){x=l.pingCache=new Q4;var j=new Set;x.set(d,j)}else j=x.get(d),j===void 0&&(j=new Set,x.set(d,j));j.has(p)||(j.add(p),l=uE.bind(null,l,d,p),d.then(l,l))}function Jb(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 Yb(l,d,p,x,j){return(l.mode&1)===0?(l===d?l.flags|=65536:(l.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(d=qa(-1,1),d.tag=2,Mi(p,d,1))),p.lanes|=1),l):(l.flags|=65536,l.lanes=j,l)}var X4=P.ReactCurrentOwner,Hs=!1;function Ps(l,d,p,x){d.child=l===null?gb(d,null,p,x):$l(d,l.child,p,x)}function Qb(l,d,p,x,j){p=p.render;var S=d.ref;return Bl(d,j),x=um(l,d,p,x,S,j),p=hm(),l!==null&&!Hs?(d.updateQueue=l.updateQueue,d.flags&=-2053,l.lanes&=~j,Ga(l,d,j)):(dn&&p&&Gp(d),d.flags|=1,Ps(l,d,x,j),d.child)}function Xb(l,d,p,x,j){if(l===null){var S=p.type;return typeof S=="function"&&!Vm(S)&&S.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(d.tag=15,d.type=S,Zb(l,d,S,x,j)):(l=Yu(p.type,null,x,d,d.mode,j),l.ref=d.ref,l.return=d,d.child=l)}if(S=l.child,(l.lanes&j)===0){var M=S.memoizedProps;if(p=p.compare,p=p!==null?p:Hc,p(M,x)&&l.ref===d.ref)return Ga(l,d,j)}return d.flags|=1,l=Li(S,x),l.ref=d.ref,l.return=d,d.child=l}function Zb(l,d,p,x,j){if(l!==null){var S=l.memoizedProps;if(Hc(S,x)&&l.ref===d.ref)if(Hs=!1,d.pendingProps=x=S,(l.lanes&j)!==0)(l.flags&131072)!==0&&(Hs=!0);else return d.lanes=l.lanes,Ga(l,d,j)}return Nm(l,d,p,x,j)}function ev(l,d,p){var x=d.pendingProps,j=x.children,S=l!==null?l.memoizedState:null;if(x.mode==="hidden")if((d.mode&1)===0)d.memoizedState={baseLanes:0,cachePool:null,transitions:null},Xt(Wl,or),or|=p;else{if((p&1073741824)===0)return l=S!==null?S.baseLanes|p:p,d.lanes=d.childLanes=1073741824,d.memoizedState={baseLanes:l,cachePool:null,transitions:null},d.updateQueue=null,Xt(Wl,or),or|=l,null;d.memoizedState={baseLanes:0,cachePool:null,transitions:null},x=S!==null?S.baseLanes:p,Xt(Wl,or),or|=x}else S!==null?(x=S.baseLanes|p,d.memoizedState=null):x=p,Xt(Wl,or),or|=x;return Ps(l,d,j,p),d.child}function tv(l,d){var p=d.ref;(l===null&&p!==null||l!==null&&l.ref!==p)&&(d.flags|=512,d.flags|=2097152)}function Nm(l,d,p,x,j){var S=Vs(p)?Ro:vs.current;return S=Ll(d,S),Bl(d,j),p=um(l,d,p,x,S,j),x=hm(),l!==null&&!Hs?(d.updateQueue=l.updateQueue,d.flags&=-2053,l.lanes&=~j,Ga(l,d,j)):(dn&&x&&Gp(d),d.flags|=1,Ps(l,d,p,j),d.child)}function nv(l,d,p,x,j){if(Vs(p)){var S=!0;Nu(d)}else S=!1;if(Bl(d,j),d.stateNode===null)$u(l,d),Ub(d,p,x),ym(d,p,x,j),x=!0;else if(l===null){var M=d.stateNode,H=d.memoizedProps;M.props=H;var J=M.context,me=p.contextType;typeof me=="object"&&me!==null?me=br(me):(me=Vs(p)?Ro:vs.current,me=Ll(d,me));var Ce=p.getDerivedStateFromProps,Me=typeof Ce=="function"||typeof M.getSnapshotBeforeUpdate=="function";Me||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(H!==x||J!==me)&&Wb(d,M,x,me),Ti=!1;var Se=d.memoizedState;M.state=Se,Au(d,x,M,j),J=d.memoizedState,H!==x||Se!==J||Bs.current||Ti?(typeof Ce=="function"&&(xm(d,p,Ce,x),J=d.memoizedState),(H=Ti||Hb(d,p,H,x,Se,J,me))?(Me||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=x,d.memoizedState=J),M.props=x,M.state=J,M.context=me,x=H):(typeof M.componentDidMount=="function"&&(d.flags|=4194308),x=!1)}else{M=d.stateNode,yb(l,d),H=d.memoizedProps,me=d.type===d.elementType?H:Hr(d.type,H),M.props=me,Me=d.pendingProps,Se=M.context,J=p.contextType,typeof J=="object"&&J!==null?J=br(J):(J=Vs(p)?Ro:vs.current,J=Ll(d,J));var Fe=p.getDerivedStateFromProps;(Ce=typeof Fe=="function"||typeof M.getSnapshotBeforeUpdate=="function")||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(H!==Me||Se!==J)&&Wb(d,M,x,J),Ti=!1,Se=d.memoizedState,M.state=Se,Au(d,x,M,j);var He=d.memoizedState;H!==Me||Se!==He||Bs.current||Ti?(typeof Fe=="function"&&(xm(d,p,Fe,x),He=d.memoizedState),(me=Ti||Hb(d,p,me,x,Se,He,J)||!1)?(Ce||typeof M.UNSAFE_componentWillUpdate!="function"&&typeof M.componentWillUpdate!="function"||(typeof M.componentWillUpdate=="function"&&M.componentWillUpdate(x,He,J),typeof M.UNSAFE_componentWillUpdate=="function"&&M.UNSAFE_componentWillUpdate(x,He,J)),typeof M.componentDidUpdate=="function"&&(d.flags|=4),typeof M.getSnapshotBeforeUpdate=="function"&&(d.flags|=1024)):(typeof M.componentDidUpdate!="function"||H===l.memoizedProps&&Se===l.memoizedState||(d.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||H===l.memoizedProps&&Se===l.memoizedState||(d.flags|=1024),d.memoizedProps=x,d.memoizedState=He),M.props=x,M.state=He,M.context=J,x=me):(typeof M.componentDidUpdate!="function"||H===l.memoizedProps&&Se===l.memoizedState||(d.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||H===l.memoizedProps&&Se===l.memoizedState||(d.flags|=1024),x=!1)}return wm(l,d,p,x,S,j)}function wm(l,d,p,x,j,S){tv(l,d);var M=(d.flags&128)!==0;if(!x&&!M)return j&&ob(d,p,!1),Ga(l,d,S);x=d.stateNode,X4.current=d;var H=M&&typeof p.getDerivedStateFromError!="function"?null:x.render();return d.flags|=1,l!==null&&M?(d.child=$l(d,l.child,null,S),d.child=$l(d,null,H,S)):Ps(l,d,H,S),d.memoizedState=x.state,j&&ob(d,p,!0),d.child}function sv(l){var d=l.stateNode;d.pendingContext?ab(l,d.pendingContext,d.pendingContext!==d.context):d.context&&ab(l,d.context,!1),am(l,d.containerInfo)}function rv(l,d,p,x,j){return zl(),Xp(j),d.flags|=256,Ps(l,d,p,x),d.child}var jm={dehydrated:null,treeContext:null,retryLane:0};function km(l){return{baseLanes:l,cachePool:null,transitions:null}}function av(l,d,p){var x=d.pendingProps,j=mn.current,S=!1,M=(d.flags&128)!==0,H;if((H=M)||(H=l!==null&&l.memoizedState===null?!1:(j&2)!==0),H?(S=!0,d.flags&=-129):(l===null||l.memoizedState!==null)&&(j|=1),Xt(mn,j&1),l===null)return Qp(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=x.children,l=x.fallback,S?(x=d.mode,S=d.child,M={mode:"hidden",children:M},(x&1)===0&&S!==null?(S.childLanes=0,S.pendingProps=M):S=Qu(M,x,0,null),l=Vo(l,x,p,null),S.return=d,l.return=d,S.sibling=l,d.child=S,d.child.memoizedState=km(p),d.memoizedState=jm,l):Sm(d,M));if(j=l.memoizedState,j!==null&&(H=j.dehydrated,H!==null))return Z4(l,d,M,x,H,j,p);if(S){S=x.fallback,M=d.mode,j=l.child,H=j.sibling;var J={mode:"hidden",children:x.children};return(M&1)===0&&d.child!==j?(x=d.child,x.childLanes=0,x.pendingProps=J,d.deletions=null):(x=Li(j,J),x.subtreeFlags=j.subtreeFlags&14680064),H!==null?S=Li(H,S):(S=Vo(S,M,p,null),S.flags|=2),S.return=d,x.return=d,x.sibling=S,d.child=x,x=S,S=d.child,M=l.child.memoizedState,M=M===null?km(p):{baseLanes:M.baseLanes|p,cachePool:null,transitions:M.transitions},S.memoizedState=M,S.childLanes=l.childLanes&~p,d.memoizedState=jm,x}return S=l.child,l=S.sibling,x=Li(S,{mode:"visible",children:x.children}),(d.mode&1)===0&&(x.lanes=p),x.return=d,x.sibling=null,l!==null&&(p=d.deletions,p===null?(d.deletions=[l],d.flags|=16):p.push(l)),d.child=x,d.memoizedState=null,x}function Sm(l,d){return d=Qu({mode:"visible",children:d},l.mode,0,null),d.return=l,l.child=d}function zu(l,d,p,x){return x!==null&&Xp(x),$l(d,l.child,null,p),l=Sm(d,d.pendingProps.children),l.flags|=2,d.memoizedState=null,l}function Z4(l,d,p,x,j,S,M){if(p)return d.flags&256?(d.flags&=-257,x=bm(Error(n(422))),zu(l,d,M,x)):d.memoizedState!==null?(d.child=l.child,d.flags|=128,null):(S=x.fallback,j=d.mode,x=Qu({mode:"visible",children:x.children},j,0,null),S=Vo(S,j,M,null),S.flags|=2,x.return=d,S.return=d,x.sibling=S,d.child=x,(d.mode&1)!==0&&$l(d,l.child,null,M),d.child.memoizedState=km(M),d.memoizedState=jm,S);if((d.mode&1)===0)return zu(l,d,M,null);if(j.data==="$!"){if(x=j.nextSibling&&j.nextSibling.dataset,x)var H=x.dgst;return x=H,S=Error(n(419)),x=bm(S,x,void 0),zu(l,d,M,x)}if(H=(M&l.childLanes)!==0,Hs||H){if(x=Yn,x!==null){switch(M&-M){case 4:j=2;break;case 16:j=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:j=32;break;case 536870912:j=268435456;break;default:j=0}j=(j&(x.suspendedLanes|M))!==0?0:j,j!==0&&j!==S.retryLane&&(S.retryLane=j,Ka(l,j),Kr(x,l,j,-1))}return Bm(),x=bm(Error(n(421))),zu(l,d,M,x)}return j.data==="$?"?(d.flags|=128,d.child=l.child,d=hE.bind(null,l),j._reactRetry=d,null):(l=S.treeContext,ir=ki(j.nextSibling),ar=d,dn=!0,Vr=null,l!==null&&(xr[yr++]=Ua,xr[yr++]=Wa,xr[yr++]=Po,Ua=l.id,Wa=l.overflow,Po=d),d=Sm(d,x.children),d.flags|=4096,d)}function iv(l,d,p){l.lanes|=d;var x=l.alternate;x!==null&&(x.lanes|=d),nm(l.return,d,p)}function Cm(l,d,p,x,j){var S=l.memoizedState;S===null?l.memoizedState={isBackwards:d,rendering:null,renderingStartTime:0,last:x,tail:p,tailMode:j}:(S.isBackwards=d,S.rendering=null,S.renderingStartTime=0,S.last=x,S.tail=p,S.tailMode=j)}function ov(l,d,p){var x=d.pendingProps,j=x.revealOrder,S=x.tail;if(Ps(l,d,x.children,p),x=mn.current,(x&2)!==0)x=x&1|2,d.flags|=128;else{if(l!==null&&(l.flags&128)!==0)e:for(l=d.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&iv(l,p,d);else if(l.tag===19)iv(l,p,d);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===d)break e;for(;l.sibling===null;){if(l.return===null||l.return===d)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}x&=1}if(Xt(mn,x),(d.mode&1)===0)d.memoizedState=null;else switch(j){case"forwards":for(p=d.child,j=null;p!==null;)l=p.alternate,l!==null&&Iu(l)===null&&(j=p),p=p.sibling;p=j,p===null?(j=d.child,d.child=null):(j=p.sibling,p.sibling=null),Cm(d,!1,j,p,S);break;case"backwards":for(p=null,j=d.child,d.child=null;j!==null;){if(l=j.alternate,l!==null&&Iu(l)===null){d.child=j;break}l=j.sibling,j.sibling=p,p=j,j=l}Cm(d,!0,p,null,S);break;case"together":Cm(d,!1,null,null,void 0);break;default:d.memoizedState=null}return d.child}function $u(l,d){(d.mode&1)===0&&l!==null&&(l.alternate=null,d.alternate=null,d.flags|=2)}function Ga(l,d,p){if(l!==null&&(d.dependencies=l.dependencies),zo|=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=Li(l,l.pendingProps),d.child=p,p.return=d;l.sibling!==null;)l=l.sibling,p=p.sibling=Li(l,l.pendingProps),p.return=d;p.sibling=null}return d.child}function eE(l,d,p){switch(d.tag){case 3:sv(d),zl();break;case 5:Nb(d);break;case 1:Vs(d.type)&&Nu(d);break;case 4:am(d,d.stateNode.containerInfo);break;case 10:var x=d.type._context,j=d.memoizedProps.value;Xt(Eu,x._currentValue),x._currentValue=j;break;case 13:if(x=d.memoizedState,x!==null)return x.dehydrated!==null?(Xt(mn,mn.current&1),d.flags|=128,null):(p&d.child.childLanes)!==0?av(l,d,p):(Xt(mn,mn.current&1),l=Ga(l,d,p),l!==null?l.sibling:null);Xt(mn,mn.current&1);break;case 19:if(x=(p&d.childLanes)!==0,(l.flags&128)!==0){if(x)return ov(l,d,p);d.flags|=128}if(j=d.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),Xt(mn,mn.current),x)break;return null;case 22:case 23:return d.lanes=0,ev(l,d,p)}return Ga(l,d,p)}var lv,Em,cv,dv;lv=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}},Em=function(){},cv=function(l,d,p,x){var j=l.memoizedProps;if(j!==x){l=d.stateNode,Do(ya.current);var S=null;switch(p){case"input":j=ye(l,j),x=ye(l,x),S=[];break;case"select":j=q({},j,{value:void 0}),x=q({},x,{value:void 0}),S=[];break;case"textarea":j=Ot(l,j),x=Ot(l,x),S=[];break;default:typeof j.onClick!="function"&&typeof x.onClick=="function"&&(l.onclick=yu)}mt(p,x);var M;p=null;for(me in j)if(!x.hasOwnProperty(me)&&j.hasOwnProperty(me)&&j[me]!=null)if(me==="style"){var H=j[me];for(M in H)H.hasOwnProperty(M)&&(p||(p={}),p[M]="")}else me!=="dangerouslySetInnerHTML"&&me!=="children"&&me!=="suppressContentEditableWarning"&&me!=="suppressHydrationWarning"&&me!=="autoFocus"&&(a.hasOwnProperty(me)?S||(S=[]):(S=S||[]).push(me,null));for(me in x){var J=x[me];if(H=j!=null?j[me]:void 0,x.hasOwnProperty(me)&&J!==H&&(J!=null||H!=null))if(me==="style")if(H){for(M in H)!H.hasOwnProperty(M)||J&&J.hasOwnProperty(M)||(p||(p={}),p[M]="");for(M in J)J.hasOwnProperty(M)&&H[M]!==J[M]&&(p||(p={}),p[M]=J[M])}else p||(S||(S=[]),S.push(me,p)),p=J;else me==="dangerouslySetInnerHTML"?(J=J?J.__html:void 0,H=H?H.__html:void 0,J!=null&&H!==J&&(S=S||[]).push(me,J)):me==="children"?typeof J!="string"&&typeof J!="number"||(S=S||[]).push(me,""+J):me!=="suppressContentEditableWarning"&&me!=="suppressHydrationWarning"&&(a.hasOwnProperty(me)?(J!=null&&me==="onScroll"&&rn("scroll",l),S||H===J||(S=[])):(S=S||[]).push(me,J))}p&&(S=S||[]).push("style",p);var me=S;(d.updateQueue=me)&&(d.flags|=4)}},dv=function(l,d,p,x){p!==x&&(d.flags|=4)};function rd(l,d){if(!dn)switch(l.tailMode){case"hidden":d=l.tail;for(var p=null;d!==null;)d.alternate!==null&&(p=d),d=d.sibling;p===null?l.tail=null:p.sibling=null;break;case"collapsed":p=l.tail;for(var x=null;p!==null;)p.alternate!==null&&(x=p),p=p.sibling;x===null?d||l.tail===null?l.tail=null:l.tail.sibling=null:x.sibling=null}}function ws(l){var d=l.alternate!==null&&l.alternate.child===l.child,p=0,x=0;if(d)for(var j=l.child;j!==null;)p|=j.lanes|j.childLanes,x|=j.subtreeFlags&14680064,x|=j.flags&14680064,j.return=l,j=j.sibling;else for(j=l.child;j!==null;)p|=j.lanes|j.childLanes,x|=j.subtreeFlags,x|=j.flags,j.return=l,j=j.sibling;return l.subtreeFlags|=x,l.childLanes=p,d}function tE(l,d,p){var x=d.pendingProps;switch(Jp(d),d.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ws(d),null;case 1:return Vs(d.type)&&vu(),ws(d),null;case 3:return x=d.stateNode,Vl(),an(Bs),an(vs),lm(),x.pendingContext&&(x.context=x.pendingContext,x.pendingContext=null),(l===null||l.child===null)&&(Su(d)?d.flags|=4:l===null||l.memoizedState.isDehydrated&&(d.flags&256)===0||(d.flags|=1024,Vr!==null&&(zm(Vr),Vr=null))),Em(l,d),ws(d),null;case 5:im(d);var j=Do(Zc.current);if(p=d.type,l!==null&&d.stateNode!=null)cv(l,d,p,x,j),l.ref!==d.ref&&(d.flags|=512,d.flags|=2097152);else{if(!x){if(d.stateNode===null)throw Error(n(166));return ws(d),null}if(l=Do(ya.current),Su(d)){x=d.stateNode,p=d.type;var S=d.memoizedProps;switch(x[xa]=d,x[Gc]=S,l=(d.mode&1)!==0,p){case"dialog":rn("cancel",x),rn("close",x);break;case"iframe":case"object":case"embed":rn("load",x);break;case"video":case"audio":for(j=0;j<Wc.length;j++)rn(Wc[j],x);break;case"source":rn("error",x);break;case"img":case"image":case"link":rn("error",x),rn("load",x);break;case"details":rn("toggle",x);break;case"input":$e(x,S),rn("invalid",x);break;case"select":x._wrapperState={wasMultiple:!!S.multiple},rn("invalid",x);break;case"textarea":Mn(x,S),rn("invalid",x)}mt(p,S),j=null;for(var M in S)if(S.hasOwnProperty(M)){var H=S[M];M==="children"?typeof H=="string"?x.textContent!==H&&(S.suppressHydrationWarning!==!0&&xu(x.textContent,H,l),j=["children",H]):typeof H=="number"&&x.textContent!==""+H&&(S.suppressHydrationWarning!==!0&&xu(x.textContent,H,l),j=["children",""+H]):a.hasOwnProperty(M)&&H!=null&&M==="onScroll"&&rn("scroll",x)}switch(p){case"input":xe(x),_e(x,S,!0);break;case"textarea":xe(x),gs(x);break;case"select":case"option":break;default:typeof S.onClick=="function"&&(x.onclick=yu)}x=j,d.updateQueue=x,x!==null&&(d.flags|=4)}else{M=j.nodeType===9?j:j.ownerDocument,l==="http://www.w3.org/1999/xhtml"&&(l=zs(p)),l==="http://www.w3.org/1999/xhtml"?p==="script"?(l=M.createElement("div"),l.innerHTML="<script><\/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[xa]=d,l[Gc]=x,lv(l,d,!1,!1),d.stateNode=l;e:{switch(M=Bt(p,x),p){case"dialog":rn("cancel",l),rn("close",l),j=x;break;case"iframe":case"object":case"embed":rn("load",l),j=x;break;case"video":case"audio":for(j=0;j<Wc.length;j++)rn(Wc[j],l);j=x;break;case"source":rn("error",l),j=x;break;case"img":case"image":case"link":rn("error",l),rn("load",l),j=x;break;case"details":rn("toggle",l),j=x;break;case"input":$e(l,x),j=ye(l,x),rn("invalid",l);break;case"option":j=x;break;case"select":l._wrapperState={wasMultiple:!!x.multiple},j=q({},x,{value:void 0}),rn("invalid",l);break;case"textarea":Mn(l,x),j=Ot(l,x),rn("invalid",l);break;default:j=x}mt(p,j),H=j;for(S in H)if(H.hasOwnProperty(S)){var J=H[S];S==="style"?W(l,J):S==="dangerouslySetInnerHTML"?(J=J?J.__html:void 0,J!=null&&Gt(l,J)):S==="children"?typeof J=="string"?(p!=="textarea"||J!=="")&&ln(l,J):typeof J=="number"&&ln(l,""+J):S!=="suppressContentEditableWarning"&&S!=="suppressHydrationWarning"&&S!=="autoFocus"&&(a.hasOwnProperty(S)?J!=null&&S==="onScroll"&&rn("scroll",l):J!=null&&C(l,S,J,M))}switch(p){case"input":xe(l),_e(l,x,!1);break;case"textarea":xe(l),gs(l);break;case"option":x.value!=null&&l.setAttribute("value",""+ae(x.value));break;case"select":l.multiple=!!x.multiple,S=x.value,S!=null?Pt(l,!!x.multiple,S,!1):x.defaultValue!=null&&Pt(l,!!x.multiple,x.defaultValue,!0);break;default:typeof j.onClick=="function"&&(l.onclick=yu)}switch(p){case"button":case"input":case"select":case"textarea":x=!!x.autoFocus;break e;case"img":x=!0;break e;default:x=!1}}x&&(d.flags|=4)}d.ref!==null&&(d.flags|=512,d.flags|=2097152)}return ws(d),null;case 6:if(l&&d.stateNode!=null)dv(l,d,l.memoizedProps,x);else{if(typeof x!="string"&&d.stateNode===null)throw Error(n(166));if(p=Do(Zc.current),Do(ya.current),Su(d)){if(x=d.stateNode,p=d.memoizedProps,x[xa]=d,(S=x.nodeValue!==p)&&(l=ar,l!==null))switch(l.tag){case 3:xu(x.nodeValue,p,(l.mode&1)!==0);break;case 5:l.memoizedProps.suppressHydrationWarning!==!0&&xu(x.nodeValue,p,(l.mode&1)!==0)}S&&(d.flags|=4)}else x=(p.nodeType===9?p:p.ownerDocument).createTextNode(x),x[xa]=d,d.stateNode=x}return ws(d),null;case 13:if(an(mn),x=d.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(dn&&ir!==null&&(d.mode&1)!==0&&(d.flags&128)===0)fb(),zl(),d.flags|=98560,S=!1;else if(S=Su(d),x!==null&&x.dehydrated!==null){if(l===null){if(!S)throw Error(n(318));if(S=d.memoizedState,S=S!==null?S.dehydrated:null,!S)throw Error(n(317));S[xa]=d}else zl(),(d.flags&128)===0&&(d.memoizedState=null),d.flags|=4;ws(d),S=!1}else Vr!==null&&(zm(Vr),Vr=null),S=!0;if(!S)return d.flags&65536?d:null}return(d.flags&128)!==0?(d.lanes=p,d):(x=x!==null,x!==(l!==null&&l.memoizedState!==null)&&x&&(d.child.flags|=8192,(d.mode&1)!==0&&(l===null||(mn.current&1)!==0?Vn===0&&(Vn=3):Bm())),d.updateQueue!==null&&(d.flags|=4),ws(d),null);case 4:return Vl(),Em(l,d),l===null&&Kc(d.stateNode.containerInfo),ws(d),null;case 10:return tm(d.type._context),ws(d),null;case 17:return Vs(d.type)&&vu(),ws(d),null;case 19:if(an(mn),S=d.memoizedState,S===null)return ws(d),null;if(x=(d.flags&128)!==0,M=S.rendering,M===null)if(x)rd(S,!1);else{if(Vn!==0||l!==null&&(l.flags&128)!==0)for(l=d.child;l!==null;){if(M=Iu(l),M!==null){for(d.flags|=128,rd(S,!1),x=M.updateQueue,x!==null&&(d.updateQueue=x,d.flags|=4),d.subtreeFlags=0,x=p,p=d.child;p!==null;)S=p,l=x,S.flags&=14680066,M=S.alternate,M===null?(S.childLanes=0,S.lanes=l,S.child=null,S.subtreeFlags=0,S.memoizedProps=null,S.memoizedState=null,S.updateQueue=null,S.dependencies=null,S.stateNode=null):(S.childLanes=M.childLanes,S.lanes=M.lanes,S.child=M.child,S.subtreeFlags=0,S.deletions=null,S.memoizedProps=M.memoizedProps,S.memoizedState=M.memoizedState,S.updateQueue=M.updateQueue,S.type=M.type,l=M.dependencies,S.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),p=p.sibling;return Xt(mn,mn.current&1|2),d.child}l=l.sibling}S.tail!==null&&Vt()>Kl&&(d.flags|=128,x=!0,rd(S,!1),d.lanes=4194304)}else{if(!x)if(l=Iu(M),l!==null){if(d.flags|=128,x=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),rd(S,!0),S.tail===null&&S.tailMode==="hidden"&&!M.alternate&&!dn)return ws(d),null}else 2*Vt()-S.renderingStartTime>Kl&&p!==1073741824&&(d.flags|=128,x=!0,rd(S,!1),d.lanes=4194304);S.isBackwards?(M.sibling=d.child,d.child=M):(p=S.last,p!==null?p.sibling=M:d.child=M,S.last=M)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=Vt(),d.sibling=null,p=mn.current,Xt(mn,x?p&1|2:p&1),d):(ws(d),null);case 22:case 23:return Fm(),x=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==x&&(d.flags|=8192),x&&(d.mode&1)!==0?(or&1073741824)!==0&&(ws(d),d.subtreeFlags&6&&(d.flags|=8192)):ws(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function nE(l,d){switch(Jp(d),d.tag){case 1:return Vs(d.type)&&vu(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return Vl(),an(Bs),an(vs),lm(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return im(d),null;case 13:if(an(mn),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));zl()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return an(mn),null;case 4:return Vl(),null;case 10:return tm(d.type._context),null;case 22:case 23:return Fm(),null;case 24:return null;default:return null}}var Fu=!1,js=!1,sE=typeof WeakSet=="function"?WeakSet:Set,Ve=null;function Ul(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(x){wn(l,d,x)}else p.current=null}function Tm(l,d,p){try{p()}catch(x){wn(l,d,x)}}var uv=!1;function rE(l,d){if(Fp=ha,l=Hy(),Rp(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var x=p.getSelection&&p.getSelection();if(x&&x.rangeCount!==0){p=x.anchorNode;var j=x.anchorOffset,S=x.focusNode;x=x.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var M=0,H=-1,J=-1,me=0,Ce=0,Me=l,Se=null;t:for(;;){for(var Fe;Me!==p||j!==0&&Me.nodeType!==3||(H=M+j),Me!==S||x!==0&&Me.nodeType!==3||(J=M+x),Me.nodeType===3&&(M+=Me.nodeValue.length),(Fe=Me.firstChild)!==null;)Se=Me,Me=Fe;for(;;){if(Me===l)break t;if(Se===p&&++me===j&&(H=M),Se===S&&++Ce===x&&(J=M),(Fe=Me.nextSibling)!==null)break;Me=Se,Se=Me.parentNode}Me=Fe}p=H===-1||J===-1?null:{start:H,end:J}}else p=null}p=p||{start:0,end:0}}else p=null;for(Bp={focusedElem:l,selectionRange:p},ha=!1,Ve=d;Ve!==null;)if(d=Ve,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,Ve=l;else for(;Ve!==null;){d=Ve;try{var He=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(He!==null){var Ke=He.memoizedProps,Rn=He.memoizedState,de=d.stateNode,te=de.getSnapshotBeforeUpdate(d.elementType===d.type?Ke:Hr(d.type,Ke),Rn);de.__reactInternalSnapshotBeforeUpdate=te}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(Ie){wn(d,d.return,Ie)}if(l=d.sibling,l!==null){l.return=d.return,Ve=l;break}Ve=d.return}return He=uv,uv=!1,He}function ad(l,d,p){var x=d.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var j=x=x.next;do{if((j.tag&l)===l){var S=j.destroy;j.destroy=void 0,S!==void 0&&Tm(d,p,S)}j=j.next}while(j!==x)}}function Bu(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 Mm(l){var d=l.ref;if(d!==null){var p=l.stateNode;switch(l.tag){case 5:l=p;break;default:l=p}typeof d=="function"?d(l):d.current=l}}function hv(l){var d=l.alternate;d!==null&&(l.alternate=null,hv(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[xa],delete d[Gc],delete d[Wp],delete d[F4],delete d[B4])),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 fv(l){return l.tag===5||l.tag===3||l.tag===4}function pv(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||fv(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 Am(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=yu));else if(x!==4&&(l=l.child,l!==null))for(Am(l,d,p),l=l.sibling;l!==null;)Am(l,d,p),l=l.sibling}function Im(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(Im(l,d,p),l=l.sibling;l!==null;)Im(l,d,p),l=l.sibling}var as=null,Ur=!1;function Ai(l,d,p){for(p=p.child;p!==null;)mv(l,d,p),p=p.sibling}function mv(l,d,p){if(Rs&&typeof Rs.onCommitFiberUnmount=="function")try{Rs.onCommitFiberUnmount(yi,p)}catch{}switch(p.tag){case 5:js||Ul(p,d);case 6:var x=as,j=Ur;as=null,Ai(l,d,p),as=x,Ur=j,as!==null&&(Ur?(l=as,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):as.removeChild(p.stateNode));break;case 18:as!==null&&(Ur?(l=as,p=p.stateNode,l.nodeType===8?Up(l.parentNode,p):l.nodeType===1&&Up(l,p),$r(l)):Up(as,p.stateNode));break;case 4:x=as,j=Ur,as=p.stateNode.containerInfo,Ur=!0,Ai(l,d,p),as=x,Ur=j;break;case 0:case 11:case 14:case 15:if(!js&&(x=p.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){j=x=x.next;do{var S=j,M=S.destroy;S=S.tag,M!==void 0&&((S&2)!==0||(S&4)!==0)&&Tm(p,d,M),j=j.next}while(j!==x)}Ai(l,d,p);break;case 1:if(!js&&(Ul(p,d),x=p.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=p.memoizedProps,x.state=p.memoizedState,x.componentWillUnmount()}catch(H){wn(p,d,H)}Ai(l,d,p);break;case 21:Ai(l,d,p);break;case 22:p.mode&1?(js=(x=js)||p.memoizedState!==null,Ai(l,d,p),js=x):Ai(l,d,p);break;default:Ai(l,d,p)}}function gv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new sE),d.forEach(function(x){var j=fE.bind(null,l,x);p.has(x)||(p.add(x),x.then(j,j))})}}function Wr(l,d){var p=d.deletions;if(p!==null)for(var x=0;x<p.length;x++){var j=p[x];try{var S=l,M=d,H=M;e:for(;H!==null;){switch(H.tag){case 5:as=H.stateNode,Ur=!1;break e;case 3:as=H.stateNode.containerInfo,Ur=!0;break e;case 4:as=H.stateNode.containerInfo,Ur=!0;break e}H=H.return}if(as===null)throw Error(n(160));mv(S,M,j),as=null,Ur=!1;var J=j.alternate;J!==null&&(J.return=null),j.return=null}catch(me){wn(j,d,me)}}if(d.subtreeFlags&12854)for(d=d.child;d!==null;)xv(d,l),d=d.sibling}function xv(l,d){var p=l.alternate,x=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:if(Wr(d,l),va(l),x&4){try{ad(3,l,l.return),Bu(3,l)}catch(Ke){wn(l,l.return,Ke)}try{ad(5,l,l.return)}catch(Ke){wn(l,l.return,Ke)}}break;case 1:Wr(d,l),va(l),x&512&&p!==null&&Ul(p,p.return);break;case 5:if(Wr(d,l),va(l),x&512&&p!==null&&Ul(p,p.return),l.flags&32){var j=l.stateNode;try{ln(j,"")}catch(Ke){wn(l,l.return,Ke)}}if(x&4&&(j=l.stateNode,j!=null)){var S=l.memoizedProps,M=p!==null?p.memoizedProps:S,H=l.type,J=l.updateQueue;if(l.updateQueue=null,J!==null)try{H==="input"&&S.type==="radio"&&S.name!=null&&Ze(j,S),Bt(H,M);var me=Bt(H,S);for(M=0;M<J.length;M+=2){var Ce=J[M],Me=J[M+1];Ce==="style"?W(j,Me):Ce==="dangerouslySetInnerHTML"?Gt(j,Me):Ce==="children"?ln(j,Me):C(j,Ce,Me,me)}switch(H){case"input":tt(j,S);break;case"textarea":Dn(j,S);break;case"select":var Se=j._wrapperState.wasMultiple;j._wrapperState.wasMultiple=!!S.multiple;var Fe=S.value;Fe!=null?Pt(j,!!S.multiple,Fe,!1):Se!==!!S.multiple&&(S.defaultValue!=null?Pt(j,!!S.multiple,S.defaultValue,!0):Pt(j,!!S.multiple,S.multiple?[]:"",!1))}j[Gc]=S}catch(Ke){wn(l,l.return,Ke)}}break;case 6:if(Wr(d,l),va(l),x&4){if(l.stateNode===null)throw Error(n(162));j=l.stateNode,S=l.memoizedProps;try{j.nodeValue=S}catch(Ke){wn(l,l.return,Ke)}}break;case 3:if(Wr(d,l),va(l),x&4&&p!==null&&p.memoizedState.isDehydrated)try{$r(d.containerInfo)}catch(Ke){wn(l,l.return,Ke)}break;case 4:Wr(d,l),va(l);break;case 13:Wr(d,l),va(l),j=l.child,j.flags&8192&&(S=j.memoizedState!==null,j.stateNode.isHidden=S,!S||j.alternate!==null&&j.alternate.memoizedState!==null||(Om=Vt())),x&4&&gv(l);break;case 22:if(Ce=p!==null&&p.memoizedState!==null,l.mode&1?(js=(me=js)||Ce,Wr(d,l),js=me):Wr(d,l),va(l),x&8192){if(me=l.memoizedState!==null,(l.stateNode.isHidden=me)&&!Ce&&(l.mode&1)!==0)for(Ve=l,Ce=l.child;Ce!==null;){for(Me=Ve=Ce;Ve!==null;){switch(Se=Ve,Fe=Se.child,Se.tag){case 0:case 11:case 14:case 15:ad(4,Se,Se.return);break;case 1:Ul(Se,Se.return);var He=Se.stateNode;if(typeof He.componentWillUnmount=="function"){x=Se,p=Se.return;try{d=x,He.props=d.memoizedProps,He.state=d.memoizedState,He.componentWillUnmount()}catch(Ke){wn(x,p,Ke)}}break;case 5:Ul(Se,Se.return);break;case 22:if(Se.memoizedState!==null){vv(Me);continue}}Fe!==null?(Fe.return=Se,Ve=Fe):vv(Me)}Ce=Ce.sibling}e:for(Ce=null,Me=l;;){if(Me.tag===5){if(Ce===null){Ce=Me;try{j=Me.stateNode,me?(S=j.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none"):(H=Me.stateNode,J=Me.memoizedProps.style,M=J!=null&&J.hasOwnProperty("display")?J.display:null,H.style.display=ns("display",M))}catch(Ke){wn(l,l.return,Ke)}}}else if(Me.tag===6){if(Ce===null)try{Me.stateNode.nodeValue=me?"":Me.memoizedProps}catch(Ke){wn(l,l.return,Ke)}}else if((Me.tag!==22&&Me.tag!==23||Me.memoizedState===null||Me===l)&&Me.child!==null){Me.child.return=Me,Me=Me.child;continue}if(Me===l)break e;for(;Me.sibling===null;){if(Me.return===null||Me.return===l)break e;Ce===Me&&(Ce=null),Me=Me.return}Ce===Me&&(Ce=null),Me.sibling.return=Me.return,Me=Me.sibling}}break;case 19:Wr(d,l),va(l),x&4&&gv(l);break;case 21:break;default:Wr(d,l),va(l)}}function va(l){var d=l.flags;if(d&2){try{e:{for(var p=l.return;p!==null;){if(fv(p)){var x=p;break e}p=p.return}throw Error(n(160))}switch(x.tag){case 5:var j=x.stateNode;x.flags&32&&(ln(j,""),x.flags&=-33);var S=pv(l);Im(l,S,j);break;case 3:case 4:var M=x.stateNode.containerInfo,H=pv(l);Am(l,H,M);break;default:throw Error(n(161))}}catch(J){wn(l,l.return,J)}l.flags&=-3}d&4096&&(l.flags&=-4097)}function aE(l,d,p){Ve=l,yv(l)}function yv(l,d,p){for(var x=(l.mode&1)!==0;Ve!==null;){var j=Ve,S=j.child;if(j.tag===22&&x){var M=j.memoizedState!==null||Fu;if(!M){var H=j.alternate,J=H!==null&&H.memoizedState!==null||js;H=Fu;var me=js;if(Fu=M,(js=J)&&!me)for(Ve=j;Ve!==null;)M=Ve,J=M.child,M.tag===22&&M.memoizedState!==null?Nv(j):J!==null?(J.return=M,Ve=J):Nv(j);for(;S!==null;)Ve=S,yv(S),S=S.sibling;Ve=j,Fu=H,js=me}bv(l)}else(j.subtreeFlags&8772)!==0&&S!==null?(S.return=j,Ve=S):bv(l)}}function bv(l){for(;Ve!==null;){var d=Ve;if((d.flags&8772)!==0){var p=d.alternate;try{if((d.flags&8772)!==0)switch(d.tag){case 0:case 11:case 15:js||Bu(5,d);break;case 1:var x=d.stateNode;if(d.flags&4&&!js)if(p===null)x.componentDidMount();else{var j=d.elementType===d.type?p.memoizedProps:Hr(d.type,p.memoizedProps);x.componentDidUpdate(j,p.memoizedState,x.__reactInternalSnapshotBeforeUpdate)}var S=d.updateQueue;S!==null&&vb(d,S,x);break;case 3:var M=d.updateQueue;if(M!==null){if(p=null,d.child!==null)switch(d.child.tag){case 5:p=d.child.stateNode;break;case 1:p=d.child.stateNode}vb(d,M,p)}break;case 5:var H=d.stateNode;if(p===null&&d.flags&4){p=H;var J=d.memoizedProps;switch(d.type){case"button":case"input":case"select":case"textarea":J.autoFocus&&p.focus();break;case"img":J.src&&(p.src=J.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(d.memoizedState===null){var me=d.alternate;if(me!==null){var Ce=me.memoizedState;if(Ce!==null){var Me=Ce.dehydrated;Me!==null&&$r(Me)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}js||d.flags&512&&Mm(d)}catch(Se){wn(d,d.return,Se)}}if(d===l){Ve=null;break}if(p=d.sibling,p!==null){p.return=d.return,Ve=p;break}Ve=d.return}}function vv(l){for(;Ve!==null;){var d=Ve;if(d===l){Ve=null;break}var p=d.sibling;if(p!==null){p.return=d.return,Ve=p;break}Ve=d.return}}function Nv(l){for(;Ve!==null;){var d=Ve;try{switch(d.tag){case 0:case 11:case 15:var p=d.return;try{Bu(4,d)}catch(J){wn(d,p,J)}break;case 1:var x=d.stateNode;if(typeof x.componentDidMount=="function"){var j=d.return;try{x.componentDidMount()}catch(J){wn(d,j,J)}}var S=d.return;try{Mm(d)}catch(J){wn(d,S,J)}break;case 5:var M=d.return;try{Mm(d)}catch(J){wn(d,M,J)}}}catch(J){wn(d,d.return,J)}if(d===l){Ve=null;break}var H=d.sibling;if(H!==null){H.return=d.return,Ve=H;break}Ve=d.return}}var iE=Math.ceil,Vu=P.ReactCurrentDispatcher,Rm=P.ReactCurrentOwner,Nr=P.ReactCurrentBatchConfig,Tt=0,Yn=null,_n=null,is=0,or=0,Wl=Si(0),Vn=0,id=null,zo=0,Hu=0,Pm=0,od=null,Us=null,Om=0,Kl=1/0,Ja=null,Uu=!1,Lm=null,Ii=null,Wu=!1,Ri=null,Ku=0,ld=0,Dm=null,qu=-1,Gu=0;function Os(){return(Tt&6)!==0?Vt():qu!==-1?qu:qu=Vt()}function Pi(l){return(l.mode&1)===0?1:(Tt&2)!==0&&is!==0?is&-is:H4.transition!==null?(Gu===0&&(Gu=bi()),Gu):(l=Ct,l!==0||(l=window.event,l=l===void 0?16:Pe(l.type)),l)}function Kr(l,d,p,x){if(50<ld)throw ld=0,Dm=null,Error(n(185));An(l,p,x),((Tt&2)===0||l!==Yn)&&(l===Yn&&((Tt&2)===0&&(Hu|=p),Vn===4&&Oi(l,is)),Ws(l,x),p===1&&Tt===0&&(d.mode&1)===0&&(Kl=Vt()+500,wu&&Ei()))}function Ws(l,d){var p=l.callbackNode;Dr(l,d);var x=er(l,l===Yn?is:0);if(x===0)p!==null&&Qs(p),l.callbackNode=null,l.callbackPriority=0;else if(d=x&-x,l.callbackPriority!==d){if(p!=null&&Qs(p),d===1)l.tag===0?V4(jv.bind(null,l)):lb(jv.bind(null,l)),z4(function(){(Tt&6)===0&&Ei()}),p=null;else{switch(oa(x)){case 1:p=jo;break;case 4:p=gi;break;case 16:p=sa;break;case 536870912:p=xi;break;default:p=sa}p=Iv(p,wv.bind(null,l))}l.callbackPriority=d,l.callbackNode=p}}function wv(l,d){if(qu=-1,Gu=0,(Tt&6)!==0)throw Error(n(327));var p=l.callbackNode;if(ql()&&l.callbackNode!==p)return null;var x=er(l,l===Yn?is:0);if(x===0)return null;if((x&30)!==0||(x&l.expiredLanes)!==0||d)d=Ju(l,x);else{d=x;var j=Tt;Tt|=2;var S=Sv();(Yn!==l||is!==d)&&(Ja=null,Kl=Vt()+500,Fo(l,d));do try{cE();break}catch(H){kv(l,H)}while(!0);em(),Vu.current=S,Tt=j,_n!==null?d=0:(Yn=null,is=0,d=Vn)}if(d!==0){if(d===2&&(j=aa(l),j!==0&&(x=j,d=_m(l,j))),d===1)throw p=id,Fo(l,0),Oi(l,x),Ws(l,Vt()),p;if(d===6)Oi(l,x);else{if(j=l.current.alternate,(x&30)===0&&!oE(j)&&(d=Ju(l,x),d===2&&(S=aa(l),S!==0&&(x=S,d=_m(l,S))),d===1))throw p=id,Fo(l,0),Oi(l,x),Ws(l,Vt()),p;switch(l.finishedWork=j,l.finishedLanes=x,d){case 0:case 1:throw Error(n(345));case 2:Bo(l,Us,Ja);break;case 3:if(Oi(l,x),(x&130023424)===x&&(d=Om+500-Vt(),10<d)){if(er(l,0)!==0)break;if(j=l.suspendedLanes,(j&x)!==x){Os(),l.pingedLanes|=l.suspendedLanes&j;break}l.timeoutHandle=Hp(Bo.bind(null,l,Us,Ja),d);break}Bo(l,Us,Ja);break;case 4:if(Oi(l,x),(x&4194240)===x)break;for(d=l.eventTimes,j=-1;0<x;){var M=31-fn(x);S=1<<M,M=d[M],M>j&&(j=M),x&=~S}if(x=j,x=Vt()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*iE(x/1960))-x,10<x){l.timeoutHandle=Hp(Bo.bind(null,l,Us,Ja),x);break}Bo(l,Us,Ja);break;case 5:Bo(l,Us,Ja);break;default:throw Error(n(329))}}}return Ws(l,Vt()),l.callbackNode===p?wv.bind(null,l):null}function _m(l,d){var p=od;return l.current.memoizedState.isDehydrated&&(Fo(l,d).flags|=256),l=Ju(l,d),l!==2&&(d=Us,Us=p,d!==null&&zm(d)),l}function zm(l){Us===null?Us=l:Us.push.apply(Us,l)}function oE(l){for(var d=l;;){if(d.flags&16384){var p=d.updateQueue;if(p!==null&&(p=p.stores,p!==null))for(var x=0;x<p.length;x++){var j=p[x],S=j.getSnapshot;j=j.value;try{if(!Br(S(),j))return!1}catch{return!1}}}if(p=d.child,d.subtreeFlags&16384&&p!==null)p.return=d,d=p;else{if(d===l)break;for(;d.sibling===null;){if(d.return===null||d.return===l)return!0;d=d.return}d.sibling.return=d.return,d=d.sibling}}return!0}function Oi(l,d){for(d&=~Pm,d&=~Hu,l.suspendedLanes|=d,l.pingedLanes&=~d,l=l.expirationTimes;0<d;){var p=31-fn(d),x=1<<p;l[p]=-1,d&=~x}}function jv(l){if((Tt&6)!==0)throw Error(n(327));ql();var d=er(l,0);if((d&1)===0)return Ws(l,Vt()),null;var p=Ju(l,d);if(l.tag!==0&&p===2){var x=aa(l);x!==0&&(d=x,p=_m(l,x))}if(p===1)throw p=id,Fo(l,0),Oi(l,d),Ws(l,Vt()),p;if(p===6)throw Error(n(345));return l.finishedWork=l.current.alternate,l.finishedLanes=d,Bo(l,Us,Ja),Ws(l,Vt()),null}function $m(l,d){var p=Tt;Tt|=1;try{return l(d)}finally{Tt=p,Tt===0&&(Kl=Vt()+500,wu&&Ei())}}function $o(l){Ri!==null&&Ri.tag===0&&(Tt&6)===0&&ql();var d=Tt;Tt|=1;var p=Nr.transition,x=Ct;try{if(Nr.transition=null,Ct=1,l)return l()}finally{Ct=x,Nr.transition=p,Tt=d,(Tt&6)===0&&Ei()}}function Fm(){or=Wl.current,an(Wl)}function Fo(l,d){l.finishedWork=null,l.finishedLanes=0;var p=l.timeoutHandle;if(p!==-1&&(l.timeoutHandle=-1,_4(p)),_n!==null)for(p=_n.return;p!==null;){var x=p;switch(Jp(x),x.tag){case 1:x=x.type.childContextTypes,x!=null&&vu();break;case 3:Vl(),an(Bs),an(vs),lm();break;case 5:im(x);break;case 4:Vl();break;case 13:an(mn);break;case 19:an(mn);break;case 10:tm(x.type._context);break;case 22:case 23:Fm()}p=p.return}if(Yn=l,_n=l=Li(l.current,null),is=or=d,Vn=0,id=null,Pm=Hu=zo=0,Us=od=null,Lo!==null){for(d=0;d<Lo.length;d++)if(p=Lo[d],x=p.interleaved,x!==null){p.interleaved=null;var j=x.next,S=p.pending;if(S!==null){var M=S.next;S.next=j,x.next=M}p.pending=x}Lo=null}return l}function kv(l,d){do{var p=_n;try{if(em(),Ru.current=Du,Pu){for(var x=gn.memoizedState;x!==null;){var j=x.queue;j!==null&&(j.pending=null),x=x.next}Pu=!1}if(_o=0,Jn=Bn=gn=null,ed=!1,td=0,Rm.current=null,p===null||p.return===null){Vn=1,id=d,_n=null;break}e:{var S=l,M=p.return,H=p,J=d;if(d=is,H.flags|=32768,J!==null&&typeof J=="object"&&typeof J.then=="function"){var me=J,Ce=H,Me=Ce.tag;if((Ce.mode&1)===0&&(Me===0||Me===11||Me===15)){var Se=Ce.alternate;Se?(Ce.updateQueue=Se.updateQueue,Ce.memoizedState=Se.memoizedState,Ce.lanes=Se.lanes):(Ce.updateQueue=null,Ce.memoizedState=null)}var Fe=Jb(M);if(Fe!==null){Fe.flags&=-257,Yb(Fe,M,H,S,d),Fe.mode&1&&Gb(S,me,d),d=Fe,J=me;var He=d.updateQueue;if(He===null){var Ke=new Set;Ke.add(J),d.updateQueue=Ke}else He.add(J);break e}else{if((d&1)===0){Gb(S,me,d),Bm();break e}J=Error(n(426))}}else if(dn&&H.mode&1){var Rn=Jb(M);if(Rn!==null){(Rn.flags&65536)===0&&(Rn.flags|=256),Yb(Rn,M,H,S,d),Xp(Hl(J,H));break e}}S=J=Hl(J,H),Vn!==4&&(Vn=2),od===null?od=[S]:od.push(S),S=M;do{switch(S.tag){case 3:S.flags|=65536,d&=-d,S.lanes|=d;var de=Kb(S,J,d);bb(S,de);break e;case 1:H=J;var te=S.type,fe=S.stateNode;if((S.flags&128)===0&&(typeof te.getDerivedStateFromError=="function"||fe!==null&&typeof fe.componentDidCatch=="function"&&(Ii===null||!Ii.has(fe)))){S.flags|=65536,d&=-d,S.lanes|=d;var Ie=qb(S,H,d);bb(S,Ie);break e}}S=S.return}while(S!==null)}Ev(p)}catch(Ye){d=Ye,_n===p&&p!==null&&(_n=p=p.return);continue}break}while(!0)}function Sv(){var l=Vu.current;return Vu.current=Du,l===null?Du:l}function Bm(){(Vn===0||Vn===3||Vn===2)&&(Vn=4),Yn===null||(zo&268435455)===0&&(Hu&268435455)===0||Oi(Yn,is)}function Ju(l,d){var p=Tt;Tt|=2;var x=Sv();(Yn!==l||is!==d)&&(Ja=null,Fo(l,d));do try{lE();break}catch(j){kv(l,j)}while(!0);if(em(),Tt=p,Vu.current=x,_n!==null)throw Error(n(261));return Yn=null,is=0,Vn}function lE(){for(;_n!==null;)Cv(_n)}function cE(){for(;_n!==null&&!Xs();)Cv(_n)}function Cv(l){var d=Av(l.alternate,l,or);l.memoizedProps=l.pendingProps,d===null?Ev(l):_n=d,Rm.current=null}function Ev(l){var d=l;do{var p=d.alternate;if(l=d.return,(d.flags&32768)===0){if(p=tE(p,d,or),p!==null){_n=p;return}}else{if(p=nE(p,d),p!==null){p.flags&=32767,_n=p;return}if(l!==null)l.flags|=32768,l.subtreeFlags=0,l.deletions=null;else{Vn=6,_n=null;return}}if(d=d.sibling,d!==null){_n=d;return}_n=d=l}while(d!==null);Vn===0&&(Vn=5)}function Bo(l,d,p){var x=Ct,j=Nr.transition;try{Nr.transition=null,Ct=1,dE(l,d,p,x)}finally{Nr.transition=j,Ct=x}return null}function dE(l,d,p,x){do ql();while(Ri!==null);if((Tt&6)!==0)throw Error(n(327));p=l.finishedWork;var j=l.finishedLanes;if(p===null)return null;if(l.finishedWork=null,l.finishedLanes=0,p===l.current)throw Error(n(177));l.callbackNode=null,l.callbackPriority=0;var S=p.lanes|p.childLanes;if(Sl(l,S),l===Yn&&(_n=Yn=null,is=0),(p.subtreeFlags&2064)===0&&(p.flags&2064)===0||Wu||(Wu=!0,Iv(sa,function(){return ql(),null})),S=(p.flags&15990)!==0,(p.subtreeFlags&15990)!==0||S){S=Nr.transition,Nr.transition=null;var M=Ct;Ct=1;var H=Tt;Tt|=4,Rm.current=null,rE(l,p),xv(p,l),A4(Bp),ha=!!Fp,Bp=Fp=null,l.current=p,aE(p),ta(),Tt=H,Ct=M,Nr.transition=S}else l.current=p;if(Wu&&(Wu=!1,Ri=l,Ku=j),S=l.pendingLanes,S===0&&(Ii=null),kl(p.stateNode),Ws(l,Vt()),d!==null)for(x=l.onRecoverableError,p=0;p<d.length;p++)j=d[p],x(j.value,{componentStack:j.stack,digest:j.digest});if(Uu)throw Uu=!1,l=Lm,Lm=null,l;return(Ku&1)!==0&&l.tag!==0&&ql(),S=l.pendingLanes,(S&1)!==0?l===Dm?ld++:(ld=0,Dm=l):ld=0,Ei(),null}function ql(){if(Ri!==null){var l=oa(Ku),d=Nr.transition,p=Ct;try{if(Nr.transition=null,Ct=16>l?16:l,Ri===null)var x=!1;else{if(l=Ri,Ri=null,Ku=0,(Tt&6)!==0)throw Error(n(331));var j=Tt;for(Tt|=4,Ve=l.current;Ve!==null;){var S=Ve,M=S.child;if((Ve.flags&16)!==0){var H=S.deletions;if(H!==null){for(var J=0;J<H.length;J++){var me=H[J];for(Ve=me;Ve!==null;){var Ce=Ve;switch(Ce.tag){case 0:case 11:case 15:ad(8,Ce,S)}var Me=Ce.child;if(Me!==null)Me.return=Ce,Ve=Me;else for(;Ve!==null;){Ce=Ve;var Se=Ce.sibling,Fe=Ce.return;if(hv(Ce),Ce===me){Ve=null;break}if(Se!==null){Se.return=Fe,Ve=Se;break}Ve=Fe}}}var He=S.alternate;if(He!==null){var Ke=He.child;if(Ke!==null){He.child=null;do{var Rn=Ke.sibling;Ke.sibling=null,Ke=Rn}while(Ke!==null)}}Ve=S}}if((S.subtreeFlags&2064)!==0&&M!==null)M.return=S,Ve=M;else e:for(;Ve!==null;){if(S=Ve,(S.flags&2048)!==0)switch(S.tag){case 0:case 11:case 15:ad(9,S,S.return)}var de=S.sibling;if(de!==null){de.return=S.return,Ve=de;break e}Ve=S.return}}var te=l.current;for(Ve=te;Ve!==null;){M=Ve;var fe=M.child;if((M.subtreeFlags&2064)!==0&&fe!==null)fe.return=M,Ve=fe;else e:for(M=te;Ve!==null;){if(H=Ve,(H.flags&2048)!==0)try{switch(H.tag){case 0:case 11:case 15:Bu(9,H)}}catch(Ye){wn(H,H.return,Ye)}if(H===M){Ve=null;break e}var Ie=H.sibling;if(Ie!==null){Ie.return=H.return,Ve=Ie;break e}Ve=H.return}}if(Tt=j,Ei(),Rs&&typeof Rs.onPostCommitFiberRoot=="function")try{Rs.onPostCommitFiberRoot(yi,l)}catch{}x=!0}return x}finally{Ct=p,Nr.transition=d}}return!1}function Tv(l,d,p){d=Hl(p,d),d=Kb(l,d,1),l=Mi(l,d,1),d=Os(),l!==null&&(An(l,1,d),Ws(l,d))}function wn(l,d,p){if(l.tag===3)Tv(l,l,p);else for(;d!==null;){if(d.tag===3){Tv(d,l,p);break}else if(d.tag===1){var x=d.stateNode;if(typeof d.type.getDerivedStateFromError=="function"||typeof x.componentDidCatch=="function"&&(Ii===null||!Ii.has(x))){l=Hl(p,l),l=qb(d,l,1),d=Mi(d,l,1),l=Os(),d!==null&&(An(d,1,l),Ws(d,l));break}}d=d.return}}function uE(l,d,p){var x=l.pingCache;x!==null&&x.delete(d),d=Os(),l.pingedLanes|=l.suspendedLanes&p,Yn===l&&(is&p)===p&&(Vn===4||Vn===3&&(is&130023424)===is&&500>Vt()-Om?Fo(l,0):Pm|=p),Ws(l,d)}function Mv(l,d){d===0&&((l.mode&1)===0?d=1:(d=Da,Da<<=1,(Da&130023424)===0&&(Da=4194304)));var p=Os();l=Ka(l,d),l!==null&&(An(l,d,p),Ws(l,p))}function hE(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),Mv(l,p)}function fE(l,d){var p=0;switch(l.tag){case 13:var x=l.stateNode,j=l.memoizedState;j!==null&&(p=j.retryLane);break;case 19:x=l.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(d),Mv(l,p)}var Av;Av=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||Bs.current)Hs=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return Hs=!1,eE(l,d,p);Hs=(l.flags&131072)!==0}else Hs=!1,dn&&(d.flags&1048576)!==0&&cb(d,ku,d.index);switch(d.lanes=0,d.tag){case 2:var x=d.type;$u(l,d),l=d.pendingProps;var j=Ll(d,vs.current);Bl(d,p),j=um(null,d,x,l,j,p);var S=hm();return d.flags|=1,typeof j=="object"&&j!==null&&typeof j.render=="function"&&j.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,Vs(x)?(S=!0,Nu(d)):S=!1,d.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,rm(d),j.updater=_u,d.stateNode=j,j._reactInternals=d,ym(d,x,l,p),d=wm(null,d,x,!0,S,p)):(d.tag=0,dn&&S&&Gp(d),Ps(null,d,j,p),d=d.child),d;case 16:x=d.elementType;e:{switch($u(l,d),l=d.pendingProps,j=x._init,x=j(x._payload),d.type=x,j=d.tag=mE(x),l=Hr(x,l),j){case 0:d=Nm(null,d,x,l,p);break e;case 1:d=nv(null,d,x,l,p);break e;case 11:d=Qb(null,d,x,l,p);break e;case 14:d=Xb(null,d,x,Hr(x.type,l),p);break e}throw Error(n(306,x,""))}return d;case 0:return x=d.type,j=d.pendingProps,j=d.elementType===x?j:Hr(x,j),Nm(l,d,x,j,p);case 1:return x=d.type,j=d.pendingProps,j=d.elementType===x?j:Hr(x,j),nv(l,d,x,j,p);case 3:e:{if(sv(d),l===null)throw Error(n(387));x=d.pendingProps,S=d.memoizedState,j=S.element,yb(l,d),Au(d,x,null,p);var M=d.memoizedState;if(x=M.element,S.isDehydrated)if(S={element:x,isDehydrated:!1,cache:M.cache,pendingSuspenseBoundaries:M.pendingSuspenseBoundaries,transitions:M.transitions},d.updateQueue.baseState=S,d.memoizedState=S,d.flags&256){j=Hl(Error(n(423)),d),d=rv(l,d,x,p,j);break e}else if(x!==j){j=Hl(Error(n(424)),d),d=rv(l,d,x,p,j);break e}else for(ir=ki(d.stateNode.containerInfo.firstChild),ar=d,dn=!0,Vr=null,p=gb(d,null,x,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(zl(),x===j){d=Ga(l,d,p);break e}Ps(l,d,x,p)}d=d.child}return d;case 5:return Nb(d),l===null&&Qp(d),x=d.type,j=d.pendingProps,S=l!==null?l.memoizedProps:null,M=j.children,Vp(x,j)?M=null:S!==null&&Vp(x,S)&&(d.flags|=32),tv(l,d),Ps(l,d,M,p),d.child;case 6:return l===null&&Qp(d),null;case 13:return av(l,d,p);case 4:return am(d,d.stateNode.containerInfo),x=d.pendingProps,l===null?d.child=$l(d,null,x,p):Ps(l,d,x,p),d.child;case 11:return x=d.type,j=d.pendingProps,j=d.elementType===x?j:Hr(x,j),Qb(l,d,x,j,p);case 7:return Ps(l,d,d.pendingProps,p),d.child;case 8:return Ps(l,d,d.pendingProps.children,p),d.child;case 12:return Ps(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(x=d.type._context,j=d.pendingProps,S=d.memoizedProps,M=j.value,Xt(Eu,x._currentValue),x._currentValue=M,S!==null)if(Br(S.value,M)){if(S.children===j.children&&!Bs.current){d=Ga(l,d,p);break e}}else for(S=d.child,S!==null&&(S.return=d);S!==null;){var H=S.dependencies;if(H!==null){M=S.child;for(var J=H.firstContext;J!==null;){if(J.context===x){if(S.tag===1){J=qa(-1,p&-p),J.tag=2;var me=S.updateQueue;if(me!==null){me=me.shared;var Ce=me.pending;Ce===null?J.next=J:(J.next=Ce.next,Ce.next=J),me.pending=J}}S.lanes|=p,J=S.alternate,J!==null&&(J.lanes|=p),nm(S.return,p,d),H.lanes|=p;break}J=J.next}}else if(S.tag===10)M=S.type===d.type?null:S.child;else if(S.tag===18){if(M=S.return,M===null)throw Error(n(341));M.lanes|=p,H=M.alternate,H!==null&&(H.lanes|=p),nm(M,p,d),M=S.sibling}else M=S.child;if(M!==null)M.return=S;else for(M=S;M!==null;){if(M===d){M=null;break}if(S=M.sibling,S!==null){S.return=M.return,M=S;break}M=M.return}S=M}Ps(l,d,j.children,p),d=d.child}return d;case 9:return j=d.type,x=d.pendingProps.children,Bl(d,p),j=br(j),x=x(j),d.flags|=1,Ps(l,d,x,p),d.child;case 14:return x=d.type,j=Hr(x,d.pendingProps),j=Hr(x.type,j),Xb(l,d,x,j,p);case 15:return Zb(l,d,d.type,d.pendingProps,p);case 17:return x=d.type,j=d.pendingProps,j=d.elementType===x?j:Hr(x,j),$u(l,d),d.tag=1,Vs(x)?(l=!0,Nu(d)):l=!1,Bl(d,p),Ub(d,x,j),ym(d,x,j,p),wm(null,d,x,!0,l,p);case 19:return ov(l,d,p);case 22:return ev(l,d,p)}throw Error(n(156,d.tag))};function Iv(l,d){return wo(l,d)}function pE(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 wr(l,d,p,x){return new pE(l,d,p,x)}function Vm(l){return l=l.prototype,!(!l||!l.isReactComponent)}function mE(l){if(typeof l=="function")return Vm(l)?1:0;if(l!=null){if(l=l.$$typeof,l===z)return 11;if(l===K)return 14}return 2}function Li(l,d){var p=l.alternate;return p===null?(p=wr(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 Yu(l,d,p,x,j,S){var M=2;if(x=l,typeof l=="function")Vm(l)&&(M=1);else if(typeof l=="string")M=5;else e:switch(l){case _:return Vo(p.children,j,S,d);case V:M=8,j|=8;break;case A:return l=wr(12,p,d,j|2),l.elementType=A,l.lanes=S,l;case ne:return l=wr(13,p,d,j),l.elementType=ne,l.lanes=S,l;case ue:return l=wr(19,p,d,j),l.elementType=ue,l.lanes=S,l;case D:return Qu(p,j,S,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case X:M=10;break e;case G:M=9;break e;case z:M=11;break e;case K:M=14;break e;case $:M=16,x=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=wr(M,p,d,j),d.elementType=l,d.type=x,d.lanes=S,d}function Vo(l,d,p,x){return l=wr(7,l,x,d),l.lanes=p,l}function Qu(l,d,p,x){return l=wr(22,l,x,d),l.elementType=D,l.lanes=p,l.stateNode={isHidden:!1},l}function Hm(l,d,p){return l=wr(6,l,null,d),l.lanes=p,l}function Um(l,d,p){return d=wr(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function gE(l,d,p,x,j){this.tag=d,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=vi(0),this.expirationTimes=vi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=vi(0),this.identifierPrefix=x,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function Wm(l,d,p,x,j,S,M,H,J){return l=new gE(l,d,p,H,J),d===1?(d=1,S===!0&&(d|=8)):d=0,S=wr(3,null,null,d),l.current=S,S.stateNode=l,S.memoizedState={element:x,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},rm(S),l}function xE(l,d,p){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:U,key:x==null?null:""+x,children:l,containerInfo:d,implementation:p}}function Rv(l){if(!l)return Ci;l=l._reactInternals;e:{if(St(l)!==l||l.tag!==1)throw Error(n(170));var d=l;do{switch(d.tag){case 3:d=d.stateNode.context;break e;case 1:if(Vs(d.type)){d=d.stateNode.__reactInternalMemoizedMergedChildContext;break e}}d=d.return}while(d!==null);throw Error(n(171))}if(l.tag===1){var p=l.type;if(Vs(p))return ib(l,p,d)}return d}function Pv(l,d,p,x,j,S,M,H,J){return l=Wm(p,x,!0,l,j,S,M,H,J),l.context=Rv(null),p=l.current,x=Os(),j=Pi(p),S=qa(x,j),S.callback=d??null,Mi(p,S,j),l.current.lanes=j,An(l,j,x),Ws(l,x),l}function Xu(l,d,p,x){var j=d.current,S=Os(),M=Pi(j);return p=Rv(p),d.context===null?d.context=p:d.pendingContext=p,d=qa(S,M),d.payload={element:l},x=x===void 0?null:x,x!==null&&(d.callback=x),l=Mi(j,d,M),l!==null&&(Kr(l,j,M,S),Mu(l,j,M)),M}function Zu(l){if(l=l.current,!l.child)return null;switch(l.child.tag){case 5:return l.child.stateNode;default:return l.child.stateNode}}function Ov(l,d){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var p=l.retryLane;l.retryLane=p!==0&&p<d?p:d}}function Km(l,d){Ov(l,d),(l=l.alternate)&&Ov(l,d)}function yE(){return null}var Lv=typeof reportError=="function"?reportError:function(l){console.error(l)};function qm(l){this._internalRoot=l}eh.prototype.render=qm.prototype.render=function(l){var d=this._internalRoot;if(d===null)throw Error(n(409));Xu(l,d,null,null)},eh.prototype.unmount=qm.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var d=l.containerInfo;$o(function(){Xu(null,l,null,null)}),d[Va]=null}};function eh(l){this._internalRoot=l}eh.prototype.unstable_scheduleHydration=function(l){if(l){var d=Co();l={blockedOn:null,target:l,priority:d};for(var p=0;p<rs.length&&d!==0&&d<rs[p].priority;p++);rs.splice(p,0,l),p===0&&_r(l)}};function Gm(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function th(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11&&(l.nodeType!==8||l.nodeValue!==" react-mount-point-unstable "))}function Dv(){}function bE(l,d,p,x,j){if(j){if(typeof x=="function"){var S=x;x=function(){var me=Zu(M);S.call(me)}}var M=Pv(d,x,l,0,null,!1,!1,"",Dv);return l._reactRootContainer=M,l[Va]=M.current,Kc(l.nodeType===8?l.parentNode:l),$o(),M}for(;j=l.lastChild;)l.removeChild(j);if(typeof x=="function"){var H=x;x=function(){var me=Zu(J);H.call(me)}}var J=Wm(l,0,!1,null,null,!1,!1,"",Dv);return l._reactRootContainer=J,l[Va]=J.current,Kc(l.nodeType===8?l.parentNode:l),$o(function(){Xu(d,J,p,x)}),J}function nh(l,d,p,x,j){var S=p._reactRootContainer;if(S){var M=S;if(typeof j=="function"){var H=j;j=function(){var J=Zu(M);H.call(J)}}Xu(d,M,l,j)}else M=bE(p,d,l,j,x);return Zu(M)}Nn=function(l){switch(l.tag){case 3:var d=l.stateNode;if(d.current.memoizedState.isDehydrated){var p=Zs(d.pendingLanes);p!==0&&(ia(d,p|1),Ws(d,Vt()),(Tt&6)===0&&(Kl=Vt()+500,Ei()))}break;case 13:$o(function(){var x=Ka(l,1);if(x!==null){var j=Os();Kr(x,l,1,j)}}),Km(l,1)}},tr=function(l){if(l.tag===13){var d=Ka(l,134217728);if(d!==null){var p=Os();Kr(d,l,134217728,p)}Km(l,134217728)}},So=function(l){if(l.tag===13){var d=Pi(l),p=Ka(l,d);if(p!==null){var x=Os();Kr(p,l,d,x)}Km(l,d)}},Co=function(){return Ct},Eo=function(l,d){var p=Ct;try{return Ct=l,d()}finally{Ct=p}},At=function(l,d,p){switch(d){case"input":if(tt(l,p),d=p.name,p.type==="radio"&&d!=null){for(p=l;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll("input[name="+JSON.stringify(""+d)+'][type="radio"]'),d=0;d<p.length;d++){var x=p[d];if(x!==l&&x.form===l.form){var j=bu(x);if(!j)throw Error(n(90));Ne(x),tt(x,j)}}}break;case"textarea":Dn(l,p);break;case"select":d=p.value,d!=null&&Pt(l,!!p.multiple,d,!1)}},vn=$m,hn=$o;var vE={usingClientEntryPoint:!1,Events:[Jc,Pl,bu,pe,be,$m]},cd={findFiberByHostInstance:Io,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},NE={bundleType:cd.bundleType,version:cd.version,rendererPackageName:cd.rendererPackageName,rendererConfig:cd.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:P.ReactCurrentDispatcher,findHostInstanceByFiber:function(l){return l=jl(l),l===null?null:l.stateNode},findFiberByHostInstance:cd.findFiberByHostInstance||yE,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var sh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!sh.isDisabled&&sh.supportsFiber)try{yi=sh.inject(NE),Rs=sh}catch{}}return Ks.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=vE,Ks.createPortal=function(l,d){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Gm(d))throw Error(n(200));return xE(l,d,null,p)},Ks.createRoot=function(l,d){if(!Gm(l))throw Error(n(299));var p=!1,x="",j=Lv;return d!=null&&(d.unstable_strictMode===!0&&(p=!0),d.identifierPrefix!==void 0&&(x=d.identifierPrefix),d.onRecoverableError!==void 0&&(j=d.onRecoverableError)),d=Wm(l,1,!1,null,null,p,!1,x,j),l[Va]=d.current,Kc(l.nodeType===8?l.parentNode:l),new qm(d)},Ks.findDOMNode=function(l){if(l==null)return null;if(l.nodeType===1)return l;var d=l._reactInternals;if(d===void 0)throw typeof l.render=="function"?Error(n(188)):(l=Object.keys(l).join(","),Error(n(268,l)));return l=jl(d),l=l===null?null:l.stateNode,l},Ks.flushSync=function(l){return $o(l)},Ks.hydrate=function(l,d,p){if(!th(d))throw Error(n(200));return nh(null,l,d,!0,p)},Ks.hydrateRoot=function(l,d,p){if(!Gm(l))throw Error(n(405));var x=p!=null&&p.hydratedSources||null,j=!1,S="",M=Lv;if(p!=null&&(p.unstable_strictMode===!0&&(j=!0),p.identifierPrefix!==void 0&&(S=p.identifierPrefix),p.onRecoverableError!==void 0&&(M=p.onRecoverableError)),d=Pv(d,null,l,1,p??null,j,!1,S,M),l[Va]=d.current,Kc(l),x)for(l=0;l<x.length;l++)p=x[l],j=p._getVersion,j=j(p._source),d.mutableSourceEagerHydrationData==null?d.mutableSourceEagerHydrationData=[p,j]:d.mutableSourceEagerHydrationData.push(p,j);return new eh(d)},Ks.render=function(l,d,p){if(!th(d))throw Error(n(200));return nh(null,l,d,!1,p)},Ks.unmountComponentAtNode=function(l){if(!th(l))throw Error(n(40));return l._reactRootContainer?($o(function(){nh(null,null,l,!1,function(){l._reactRootContainer=null,l[Va]=null})}),!0):!1},Ks.unstable_batchedUpdates=$m,Ks.unstable_renderSubtreeIntoContainer=function(l,d,p,x){if(!th(p))throw Error(n(200));if(l==null||l._reactInternals===void 0)throw Error(n(38));return nh(l,d,p,!1,x)},Ks.version="18.3.1-next-f1338f8080-20240426",Ks}var Uv;function ej(){if(Uv)return Qm.exports;Uv=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Qm.exports=ME(),Qm.exports}var Wv;function AE(){if(Wv)return rh;Wv=1;var t=ej();return rh.createRoot=t.createRoot,rh.hydrateRoot=t.hydrateRoot,rh}var IE=AE(),tu=ej();const tj=Zw(tu);/**
* @remix-run/router v1.23.2
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function _d(){return _d=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},_d.apply(this,arguments)}var Gi;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(Gi||(Gi={}));const Kv="popstate";function RE(t){t===void 0&&(t={});function e(s,a){let{pathname:i,search:o,hash:c}=s.location;return Qg("",{pathname:i,search:o,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function n(s,a){return typeof a=="string"?a:Hh(a)}return OE(e,n,null,t)}function On(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function l0(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function PE(){return Math.random().toString(36).substr(2,8)}function qv(t,e){return{usr:t.state,key:t.key,idx:e}}function Qg(t,e,n,s){return n===void 0&&(n=null),_d({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?Cc(e):e,{state:n,key:e&&e.key||s||PE()})}function Hh(t){let{pathname:e="/",search:n="",hash:s=""}=t;return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),s&&s!=="#"&&(e+=s.charAt(0)==="#"?s:"#"+s),e}function Cc(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));let s=t.indexOf("?");s>=0&&(e.search=t.substr(s),t=t.substr(0,s)),t&&(e.pathname=t)}return e}function OE(t,e,n,s){s===void 0&&(s={});let{window:a=document.defaultView,v5Compat:i=!1}=s,o=a.history,c=Gi.Pop,u=null,h=f();h==null&&(h=0,o.replaceState(_d({},o.state,{idx:h}),""));function f(){return(o.state||{idx:null}).idx}function m(){c=Gi.Pop;let N=f(),k=N==null?null:N-h;h=N,u&&u({action:c,location:w.location,delta:k})}function g(N,k){c=Gi.Push;let E=Qg(w.location,N,k);h=f()+1;let C=qv(E,h),P=w.createHref(E);try{o.pushState(C,"",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(N,k){c=Gi.Replace;let E=Qg(w.location,N,k);h=f();let C=qv(E,h),P=w.createHref(E);o.replaceState(C,"",P),i&&u&&u({action:c,location:w.location,delta:0})}function v(N){let k=a.location.origin!=="null"?a.location.origin:a.location.href,E=typeof N=="string"?N:Hh(N);return E=E.replace(/ $/,"%20"),On(k,"No window.location.(origin|href) available to create URL for href: "+E),new URL(E,k)}let w={get action(){return c},get location(){return t(a,o)},listen(N){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(Kv,m),u=N,()=>{a.removeEventListener(Kv,m),u=null}},createHref(N){return e(a,N)},createURL:v,encodeLocation(N){let k=v(N);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:g,replace:y,go(N){return o.go(N)}};return w}var Gv;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(Gv||(Gv={}));function LE(t,e,n){return n===void 0&&(n="/"),DE(t,e,n)}function DE(t,e,n,s){let a=typeof e=="string"?Cc(e):e,i=c0(a.pathname||"/",n);if(i==null)return null;let o=nj(t);_E(o);let c=null;for(let u=0;c==null&&u<o.length;++u){let h=JE(i);c=KE(o[u],h)}return c}function nj(t,e,n,s){e===void 0&&(e=[]),n===void 0&&(n=[]),s===void 0&&(s="");let a=(i,o,c)=>{let u={relativePath:c===void 0?i.path||"":c,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};u.relativePath.startsWith("/")&&(On(u.relativePath.startsWith(s),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+s+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(s.length));let h=Xi([s,u.relativePath]),f=n.concat(u);i.children&&i.children.length>0&&(On(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),nj(i.children,e,f,h)),!(i.path==null&&!i.index)&&e.push({path:h,score:UE(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 sj(i.path))a(i,o,u)}),e}function sj(t){let e=t.split("/");if(e.length===0)return[];let[n,...s]=e,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(s.length===0)return a?[i,""]:[i];let o=sj(s.join("/")),c=[];return c.push(...o.map(u=>u===""?i:[i,u].join("/"))),a&&c.push(...o),c.map(u=>t.startsWith("/")&&u===""?"/":u)}function _E(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:WE(e.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}const zE=/^:[\w-]+$/,$E=3,FE=2,BE=1,VE=10,HE=-2,Jv=t=>t==="*";function UE(t,e){let n=t.split("/"),s=n.length;return n.some(Jv)&&(s+=HE),e&&(s+=FE),n.filter(a=>!Jv(a)).reduce((a,i)=>a+(zE.test(i)?$E:i===""?BE:VE),s)}function WE(t,e){return t.length===e.length&&t.slice(0,-1).every((s,a)=>s===e[a])?t[t.length-1]-e[e.length-1]:0}function KE(t,e,n){let{routesMeta:s}=t,a={},i="/",o=[];for(let c=0;c<s.length;++c){let u=s[c],h=c===s.length-1,f=i==="/"?e:e.slice(i.length)||"/",m=qE({path:u.relativePath,caseSensitive:u.caseSensitive,end:h},f),g=u.route;if(!m)return null;Object.assign(a,m.params),o.push({params:a,pathname:Xi([i,m.pathname]),pathnameBase:eT(Xi([i,m.pathnameBase])),route:g}),m.pathnameBase!=="/"&&(i=Xi([i,m.pathnameBase]))}return o}function qE(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,s]=GE(t.path,t.caseSensitive,t.end),a=e.match(n);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),c=a.slice(1);return{params:s.reduce((h,f,m)=>{let{paramName:g,isOptional:y}=f;if(g==="*"){let w=c[m]||"";o=i.slice(0,i.length-w.length).replace(/(.)\/+$/,"$1")}const v=c[m];return y&&!v?h[g]=void 0:h[g]=(v||"").replace(/%2F/g,"/"),h},{}),pathname:i,pathnameBase:o,pattern:t}}function GE(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),l0(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let s=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,c,u)=>(s.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(s.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,e?void 0:"i"),s]}function JE(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return l0(!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 c0(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,s=t.charAt(n);return s&&s!=="/"?null:t.slice(n)||"/"}const YE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,QE=t=>YE.test(t);function XE(t,e){e===void 0&&(e="/");let{pathname:n,search:s="",hash:a=""}=typeof t=="string"?Cc(t):t,i;if(n)if(QE(n))i=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),l0(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?i=Yv(n.substring(1),"/"):i=Yv(n,e)}else i=e;return{pathname:i,search:tT(s),hash:nT(a)}}function Yv(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 eg(t,e,n,s){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(s)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function ZE(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function d0(t,e){let n=ZE(t);return e?n.map((s,a)=>a===n.length-1?s.pathname:s.pathnameBase):n.map(s=>s.pathnameBase)}function u0(t,e,n,s){s===void 0&&(s=!1);let a;typeof t=="string"?a=Cc(t):(a=_d({},t),On(!a.pathname||!a.pathname.includes("?"),eg("?","pathname","search",a)),On(!a.pathname||!a.pathname.includes("#"),eg("#","pathname","hash",a)),On(!a.search||!a.search.includes("#"),eg("#","search","hash",a)));let i=t===""||a.pathname==="",o=i?"/":a.pathname,c;if(o==null)c=n;else{let m=e.length-1;if(!s&&o.startsWith("..")){let g=o.split("/");for(;g[0]==="..";)g.shift(),m-=1;a.pathname=g.join("/")}c=m>=0?e[m]:"/"}let u=XE(a,c),h=o&&o!=="/"&&o.endsWith("/"),f=(i||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||f)&&(u.pathname+="/"),u}const Xi=t=>t.join("/").replace(/\/\/+/g,"/"),eT=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),tT=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,nT=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function sT(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const rj=["post","put","patch","delete"];new Set(rj);const rT=["get",...rj];new Set(rT);/**
* React Router v6.30.3
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function zd(){return zd=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},zd.apply(this,arguments)}const h0=b.createContext(null),aT=b.createContext(null),fo=b.createContext(null),Yf=b.createContext(null),fi=b.createContext({outlet:null,matches:[],isDataRoute:!1}),aj=b.createContext(null);function iT(t,e){let{relative:n}=e===void 0?{}:e;Ec()||On(!1);let{basename:s,navigator:a}=b.useContext(fo),{hash:i,pathname:o,search:c}=oj(t,{relative:n}),u=o;return s!=="/"&&(u=o==="/"?s:Xi([s,o])),a.createHref({pathname:u,search:c,hash:i})}function Ec(){return b.useContext(Yf)!=null}function po(){return Ec()||On(!1),b.useContext(Yf).location}function ij(t){b.useContext(fo).static||b.useLayoutEffect(t)}function Aa(){let{isDataRoute:t}=b.useContext(fi);return t?NT():oT()}function oT(){Ec()||On(!1);let t=b.useContext(h0),{basename:e,future:n,navigator:s}=b.useContext(fo),{matches:a}=b.useContext(fi),{pathname:i}=po(),o=JSON.stringify(d0(a,n.v7_relativeSplatPath)),c=b.useRef(!1);return ij(()=>{c.current=!0}),b.useCallback(function(h,f){if(f===void 0&&(f={}),!c.current)return;if(typeof h=="number"){s.go(h);return}let m=u0(h,JSON.parse(o),i,f.relative==="path");t==null&&e!=="/"&&(m.pathname=m.pathname==="/"?e:Xi([e,m.pathname])),(f.replace?s.replace:s.push)(m,f.state,f)},[e,s,o,i,t])}const lT=b.createContext(null);function cT(t){let e=b.useContext(fi).outlet;return e&&b.createElement(lT.Provider,{value:t},e)}function oj(t,e){let{relative:n}=e===void 0?{}:e,{future:s}=b.useContext(fo),{matches:a}=b.useContext(fi),{pathname:i}=po(),o=JSON.stringify(d0(a,s.v7_relativeSplatPath));return b.useMemo(()=>u0(t,JSON.parse(o),i,n==="path"),[t,o,i,n])}function dT(t,e){return uT(t,e)}function uT(t,e,n,s){Ec()||On(!1);let{navigator:a}=b.useContext(fo),{matches:i}=b.useContext(fi),o=i[i.length-1],c=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let h=po(),f;if(e){var m;let N=typeof e=="string"?Cc(e):e;u==="/"||(m=N.pathname)!=null&&m.startsWith(u)||On(!1),f=N}else f=h;let g=f.pathname||"/",y=g;if(u!=="/"){let N=u.replace(/^\//,"").split("/");y="/"+g.replace(/^\//,"").split("/").slice(N.length).join("/")}let v=LE(t,{pathname:y}),w=gT(v&&v.map(N=>Object.assign({},N,{params:Object.assign({},c,N.params),pathname:Xi([u,a.encodeLocation?a.encodeLocation(N.pathname).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?u:Xi([u,a.encodeLocation?a.encodeLocation(N.pathnameBase).pathname:N.pathnameBase])})),i,n,s);return e&&w?b.createElement(Yf.Provider,{value:{location:zd({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:Gi.Pop}},w):w}function hT(){let t=vT(),e=sT(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 fT=b.createElement(hT,null);class pT 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(fi.Provider,{value:this.props.routeContext},b.createElement(aj.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function mT(t){let{routeContext:e,match:n,children:s}=t,a=b.useContext(h0);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),b.createElement(fi.Provider,{value:e},s)}function gT(t,e,n,s){var a;if(e===void 0&&(e=[]),n===void 0&&(n=null),s===void 0&&(s=null),t==null){var i;if(!n)return null;if(n.errors)t=n.matches;else if((i=s)!=null&&i.v7_partialHydration&&e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let o=t,c=(a=n)==null?void 0:a.errors;if(c!=null){let f=o.findIndex(m=>m.route.id&&(c==null?void 0:c[m.route.id])!==void 0);f>=0||On(!1),o=o.slice(0,Math.min(o.length,f+1))}let u=!1,h=-1;if(n&&s&&s.v7_partialHydration)for(let f=0;f<o.length;f++){let m=o[f];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(h=f),m.route.id){let{loaderData:g,errors:y}=n,v=m.route.loader&&g[m.route.id]===void 0&&(!y||y[m.route.id]===void 0);if(m.route.lazy||v){u=!0,h>=0?o=o.slice(0,h+1):o=[o[0]];break}}}return o.reduceRight((f,m,g)=>{let y,v=!1,w=null,N=null;n&&(y=c&&m.route.id?c[m.route.id]:void 0,w=m.route.errorElement||fT,u&&(h<0&&g===0?(wT("route-fallback"),v=!0,N=null):h===g&&(v=!0,N=m.route.hydrateFallbackElement||null)));let k=e.concat(o.slice(0,g+1)),E=()=>{let C;return y?C=w:v?C=N:m.route.Component?C=b.createElement(m.route.Component,null):m.route.element?C=m.route.element:C=f,b.createElement(mT,{match:m,routeContext:{outlet:f,matches:k,isDataRoute:n!=null},children:C})};return n&&(m.route.ErrorBoundary||m.route.errorElement||g===0)?b.createElement(pT,{location:n.location,revalidation:n.revalidation,component:w,error:y,children:E(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):E()},null)}var lj=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(lj||{}),cj=(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})(cj||{});function xT(t){let e=b.useContext(h0);return e||On(!1),e}function yT(t){let e=b.useContext(aT);return e||On(!1),e}function bT(t){let e=b.useContext(fi);return e||On(!1),e}function dj(t){let e=bT(),n=e.matches[e.matches.length-1];return n.route.id||On(!1),n.route.id}function vT(){var t;let e=b.useContext(aj),n=yT(),s=dj();return e!==void 0?e:(t=n.errors)==null?void 0:t[s]}function NT(){let{router:t}=xT(lj.UseNavigateStable),e=dj(cj.UseNavigateStable),n=b.useRef(!1);return ij(()=>{n.current=!0}),b.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,zd({fromRouteId:e},i)))},[t,e])}const Qv={};function wT(t,e,n){Qv[t]||(Qv[t]=!0)}function jT(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function ah(t){let{to:e,replace:n,state:s,relative:a}=t;Ec()||On(!1);let{future:i,static:o}=b.useContext(fo),{matches:c}=b.useContext(fi),{pathname:u}=po(),h=Aa(),f=u0(e,d0(c,i.v7_relativeSplatPath),u,a==="path"),m=JSON.stringify(f);return b.useEffect(()=>h(JSON.parse(m),{replace:n,state:s,relative:a}),[h,m,a,n,s]),null}function kT(t){return cT(t.context)}function Zt(t){On(!1)}function ST(t){let{basename:e="/",children:n=null,location:s,navigationType:a=Gi.Pop,navigator:i,static:o=!1,future:c}=t;Ec()&&On(!1);let u=e.replace(/^\/*/,"/"),h=b.useMemo(()=>({basename:u,navigator:i,static:o,future:zd({v7_relativeSplatPath:!1},c)}),[u,c,i,o]);typeof s=="string"&&(s=Cc(s));let{pathname:f="/",search:m="",hash:g="",state:y=null,key:v="default"}=s,w=b.useMemo(()=>{let N=c0(f,u);return N==null?null:{location:{pathname:N,search:m,hash:g,state:y,key:v},navigationType:a}},[u,f,m,g,y,v,a]);return w==null?null:b.createElement(fo.Provider,{value:h},b.createElement(Yf.Provider,{children:n,value:w}))}function CT(t){let{children:e,location:n}=t;return dT(Xg(e),n)}new Promise(()=>{});function Xg(t,e){e===void 0&&(e=[]);let n=[];return b.Children.forEach(t,(s,a)=>{if(!b.isValidElement(s))return;let i=[...e,a];if(s.type===b.Fragment){n.push.apply(n,Xg(s.props.children,i));return}s.type!==Zt&&On(!1),!s.props.index||!s.props.children||On(!1);let o={id:s.props.id||i.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,loader:s.props.loader,action:s.props.action,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(o.children=Xg(s.props.children,i)),n.push(o)}),n}/**
* React Router DOM v6.30.3
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function Zg(){return Zg=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Zg.apply(this,arguments)}function ET(t,e){if(t==null)return{};var n={},s=Object.keys(t),a,i;for(i=0;i<s.length;i++)a=s[i],!(e.indexOf(a)>=0)&&(n[a]=t[a]);return n}function TT(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function MT(t,e){return t.button===0&&(!e||e==="_self")&&!TT(t)}function ex(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 s=t[n];return e.concat(Array.isArray(s)?s.map(a=>[n,a]):[[n,s]])},[]))}function AT(t,e){let n=ex(t);return e&&e.forEach((s,a)=>{n.has(a)||e.getAll(a).forEach(i=>{n.append(a,i)})}),n}const IT=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],RT="6";try{window.__reactRouterVersion=RT}catch{}const PT="startTransition",Xv=Jf[PT];function OT(t){let{basename:e,children:n,future:s,window:a}=t,i=b.useRef();i.current==null&&(i.current=RE({window:a,v5Compat:!0}));let o=i.current,[c,u]=b.useState({action:o.action,location:o.location}),{v7_startTransition:h}=s||{},f=b.useCallback(m=>{h&&Xv?Xv(()=>u(m)):u(m)},[u,h]);return b.useLayoutEffect(()=>o.listen(f),[o,f]),b.useEffect(()=>jT(s),[s]),b.createElement(ST,{basename:e,children:n,location:c.location,navigationType:c.action,navigator:o,future:s})}const LT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",DT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,$d=b.forwardRef(function(e,n){let{onClick:s,relative:a,reloadDocument:i,replace:o,state:c,target:u,to:h,preventScrollReset:f,viewTransition:m}=e,g=ET(e,IT),{basename:y}=b.useContext(fo),v,w=!1;if(typeof h=="string"&&DT.test(h)&&(v=h,LT))try{let C=new URL(window.location.href),P=h.startsWith("//")?new URL(C.protocol+h):new URL(h),O=c0(P.pathname,y);P.origin===C.origin&&O!=null?h=O+P.search+P.hash:w=!0}catch{}let N=iT(h,{relative:a}),k=_T(h,{replace:o,state:c,target:u,preventScrollReset:f,relative:a,viewTransition:m});function E(C){s&&s(C),C.defaultPrevented||k(C)}return b.createElement("a",Zg({},g,{href:v||N,onClick:w||i?s:E,ref:n,target:u}))});var Zv;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(Zv||(Zv={}));var e1;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(e1||(e1={}));function _T(t,e){let{target:n,replace:s,state:a,preventScrollReset:i,relative:o,viewTransition:c}=e===void 0?{}:e,u=Aa(),h=po(),f=oj(t,{relative:o});return b.useCallback(m=>{if(MT(m,n)){m.preventDefault();let g=s!==void 0?s:Hh(h)===Hh(f);u(t,{replace:g,state:a,preventScrollReset:i,relative:o,viewTransition:c})}},[h,u,f,s,a,n,t,i,o,c])}function f0(t){let e=b.useRef(ex(t)),n=b.useRef(!1),s=po(),a=b.useMemo(()=>AT(s.search,n.current?null:e.current),[s.search]),i=Aa(),o=b.useCallback((c,u)=>{const h=ex(typeof c=="function"?c(a):c);n.current=!0,i("?"+h,u)},[i,a]);return[a,o]}/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const zT=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),$T=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,s)=>s?s.toUpperCase():n.toLowerCase()),t1=t=>{const e=$T(t);return e.charAt(0).toUpperCase()+e.slice(1)},uj=(...t)=>t.filter((e,n,s)=>!!e&&e.trim()!==""&&s.indexOf(e)===n).join(" ").trim(),FT=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/var BT={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const VT=b.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:a="",children:i,iconNode:o,...c},u)=>b.createElement("svg",{ref:u,...BT,width:e,height:e,stroke:t,strokeWidth:s?Number(n)*24/Number(e):n,className:uj("lucide",a),...!i&&!FT(c)&&{"aria-hidden":"true"},...c},[...o.map(([h,f])=>b.createElement(h,f)),...Array.isArray(i)?i:[i]]));/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ee=(t,e)=>{const n=b.forwardRef(({className:s,...a},i)=>b.createElement(VT,{ref:i,iconNode:e,className:uj(`lucide-${zT(t1(t))}`,`lucide-${t}`,s),...a}));return n.displayName=t1(t),n};/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const HT=[["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"}]],tg=Ee("arrow-up-down",HT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const UT=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],WT=Ee("at-sign",UT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const KT=[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]],n1=Ee("bitcoin",KT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const qT=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],GT=Ee("bold",qT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const JT=[["path",{d:"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"}]],Js=Ee("book-open",JT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const YT=[["path",{d:"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"}]],tx=Ee("calendar",YT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const QT=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],gd=Ee("chart-column",QT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const XT=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Qf=Ee("check",XT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ZT=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],pc=Ee("chevron-down",ZT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const e5=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],t5=Ee("chevron-left",e5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const n5=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Go=Ee("chevron-right",n5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const s5=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],nx=Ee("chevron-up",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=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],hj=Ee("circle-alert",r5);/**
* @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 a5=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],ng=Ee("circle-check-big",a5);/**
* @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 i5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],fj=Ee("circle-check",i5);/**
* @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 o5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],pj=Ee("circle-question-mark",o5);/**
* @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 l5=[["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"}]],ih=Ee("circle-user",l5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const c5=[["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"}]],mj=Ee("circle-x",c5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const d5=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],sx=Ee("clock",d5);/**
* @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 u5=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],h5=Ee("cloud",u5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const f5=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],p5=Ee("code",f5);/**
* @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 m5=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],gj=Ee("copy",m5);/**
* @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 g5=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],s1=Ee("credit-card",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 x5=[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]],kd=Ee("crown",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 y5=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],Uh=Ee("dollar-sign",y5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const b5=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],v5=Ee("download",b5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const N5=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],di=Ee("external-link",N5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const w5=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],j5=Ee("eye-off",w5);/**
* @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 k5=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Wh=Ee("eye",k5);/**
* @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 S5=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],xj=Ee("file-text",S5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const C5=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],yj=Ee("funnel",C5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const E5=[["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"}]],rx=Ee("gift",E5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const T5=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],M5=Ee("git-merge",T5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const A5=[["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"}]],ax=Ee("globe",A5);/**
* @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 I5=[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]],R5=Ee("graduation-cap",I5);/**
* @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 P5=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Ya=Ee("grip-vertical",P5);/**
* @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 O5=[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]],L5=Ee("handshake",O5);/**
* @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 D5=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],r1=Ee("hash",D5);/**
* @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 _5=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],z5=Ee("heading-1",_5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $5=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],F5=Ee("heading-2",$5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const B5=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],V5=Ee("heading-3",B5);/**
* @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 H5=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],U5=Ee("house",H5);/**
* @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 W5=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],bj=Ee("image",W5);/**
* @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 K5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],oh=Ee("info",K5);/**
* @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 q5=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],G5=Ee("italic",q5);/**
* @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 J5=[["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"}]],vj=Ee("key",J5);/**
* @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=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Q5=Ee("layout-dashboard",Y5);/**
* @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=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],ro=Ee("link-2",X5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Z5=[["path",{d:"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"}]],ix=Ee("link",Z5);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const eM=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],tM=Ee("list-ordered",eM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const nM=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],sM=Ee("list",nM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const rM=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],aM=Ee("lock",rM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const iM=[["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"}]],oM=Ee("log-out",iM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const lM=[["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"}]],Nj=Ee("map-pin",lM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const cM=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],dM=Ee("menu",cM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const uM=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],hM=Ee("message-circle",uM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const fM=[["path",{d:"M5 12h14",key:"1ays0h"}]],pM=Ee("minus",fM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const mM=[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]],Jo=Ee("navigation",mM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const gM=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],xM=Ee("palette",gM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const yM=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],bM=Ee("paperclip",yM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const vM=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],en=Ee("pen-line",vM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const NM=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],a1=Ee("pencil",NM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const wM=[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]],jM=Ee("percent",wM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const kM=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],SM=Ee("phone",kM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const CM=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],EM=Ee("pin",CM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const TM=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Pn=Ee("plus",TM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const MM=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],i1=Ee("qr-code",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 AM=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],IM=Ee("quote",AM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const RM=[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]],PM=Ee("redo",RM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const OM=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Be=Ee("refresh-cw",OM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const LM=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],En=Ee("save",LM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const DM=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Sa=Ee("search",DM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _M=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],zM=Ee("send",_M);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $M=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],el=Ee("settings",$M);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const FM=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],lh=Ee("settings-2",FM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const BM=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],VM=Ee("share-2",BM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const HM=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ic=Ee("shield-check",HM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const UM=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],ox=Ee("shopping-bag",UM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const WM=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],mc=Ee("smartphone",WM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const KM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],o1=Ee("smile",KM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const qM=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],oc=Ee("star",qM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const GM=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],JM=Ee("strikethrough",GM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const YM=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],QM=Ee("table",YM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const XM=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],Sd=Ee("tag",XM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ZM=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],ks=Ee("trash-2",ZM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const eA=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Kh=Ee("trending-up",eA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const tA=[["path",{d:"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"}]],lx=Ee("trophy",tA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const nA=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],wj=Ee("undo-2",nA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const sA=[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]],rA=Ee("undo",sA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const aA=[["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"}]],qh=Ee("upload",aA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const iA=[["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"}]],lc=Ee("user-plus",iA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const oA=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],tl=Ee("user",oA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const lA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],zn=Ee("users",lA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const cA=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],dA=Ee("video",cA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const uA=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]],gc=Ee("wallet",uA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const hA=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],us=Ee("x",hA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const fA=[["path",{d:"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"}]],ao=Ee("zap",fA),p0="admin_token";function nu(){try{return localStorage.getItem(p0)}catch{return null}}function pA(t){try{localStorage.setItem(p0,t)}catch{}}function sg(){try{localStorage.removeItem(p0)}catch{}}const mA="https://soulapi.quwanzhi.com",gA=15e3,l1=6e4,xA=()=>{const t="https://soulapi.quwanzhi.com";{const e=t.trim();if(e.length>0)return e.replace(/\/$/,"")}return mA};function xc(t){const e=xA(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function Xf(t,e={}){const{data:n,...s}=e,a=xc(t),i=new Headers(s.headers),o=nu();o&&i.set("Authorization",`Bearer ${o}`),n!=null&&!i.has("Content-Type")&&i.set("Content-Type","application/json");const c=n!=null?JSON.stringify(n):s.body,u=s.timeout??gA,h=new AbortController,f=setTimeout(()=>h.abort(),u),m=await fetch(a,{...s,headers:i,body:c,credentials:"include",signal:h.signal}).finally(()=>clearTimeout(f)),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 v=w=>{const N=w,k=((N==null?void 0:N.message)||(N==null?void 0:N.error)||"").toString();(k.includes("可提现金额不足")||k.includes("可提现不足")||k.includes("余额不足"))&&window.dispatchEvent(new CustomEvent("recharge-alert",{detail:k}))};if(!m.ok){v(y);const w=new Error((y==null?void 0:y.error)||`HTTP ${m.status}`);throw w.status=m.status,w.data=y,w}return v(y),y}function De(t,e){return Xf(t,{...e,method:"GET"})}function Et(t,e,n){return Xf(t,{...n,method:"POST",data:e})}function Jt(t,e,n){return Xf(t,{...n,method:"PUT",data:e})}function ai(t,e){return Xf(t,{...e,method:"DELETE"})}function yA(){const[t,e]=b.useState(!1),[n,s]=b.useState("");return b.useEffect(()=>{const a=i=>{const o=i.detail;s(o||"可提现/余额不足,请及时充值商户号"),e(!0)};return window.addEventListener("recharge-alert",a),()=>window.removeEventListener("recharge-alert",a)},[]),t?r.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-3 bg-red-900/80 border-b border-red-600/50 text-red-100",role:"alert",children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsx(hj,{className:"w-5 h-5 shrink-0 text-red-400"}),r.jsxs("span",{className:"text-sm font-medium",children:[n,r.jsx("span",{className:"ml-2 text-red-300",children:"请及时充值商户号或核对账户后重试。"})]})]}),r.jsx("button",{type:"button",onClick:()=>e(!1),className:"shrink-0 p-1 rounded hover:bg-red-800/50 transition-colors","aria-label":"关闭告警",children:r.jsx(us,{className:"w-4 h-4"})})]}):null}const bA=[{icon:Q5,label:"数据概览",href:"/dashboard"},{icon:Js,label:"内容管理",href:"/content"},{icon:zn,label:"用户管理",href:"/users"},{icon:M5,label:"找伙伴",href:"/find-partner"},{icon:gc,label:"推广中心",href:"/distribution"}];function vA(){const t=po(),e=Aa(),[n,s]=b.useState(!1),[a,i]=b.useState(!1);b.useEffect(()=>{s(!0)},[]),b.useEffect(()=>{if(!n)return;i(!1);let c=!1;if(!nu()){e("/login",{replace:!0});return}return De("/api/admin").then(u=>{c||(u&&u.success!==!1?i(!0):(sg(),e("/login",{replace:!0,state:{from:t.pathname}})))}).catch(()=>{c||(sg(),e("/login",{replace:!0,state:{from:t.pathname}}))}),()=>{c=!0}},[t.pathname,n,e]);const o=async()=>{sg();try{await Et("/api/admin/logout",{})}catch{}e("/login",{replace:!0})};return!n||!a?r.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[r.jsx("div",{className:"w-64 bg-[#0f2137] border-r border-gray-700/50"}),r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx("div",{className:"text-[#38bdac]",children:"加载中..."})})]}):r.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[r.jsxs("div",{className:"w-64 bg-[#0f2137] flex flex-col border-r border-gray-700/50 shadow-xl",children:[r.jsxs("div",{className:"p-6 border-b border-gray-700/50",children:[r.jsx("h1",{className:"text-xl font-bold text-[#38bdac]",children:"管理后台"}),r.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Soul创业派对"})]}),r.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[bA.map(c=>{const u=t.pathname===c.href;return r.jsxs($d,{to:c.href,className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${u?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[r.jsx(c.icon,{className:"w-5 h-5 shrink-0"}),r.jsx("span",{className:"text-sm",children:c.label})]},c.href)}),r.jsx("div",{className:"pt-4 mt-4 border-t border-gray-700/50",children:r.jsxs($d,{to:"/settings",className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${t.pathname==="/settings"?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[r.jsx(el,{className:"w-5 h-5 shrink-0"}),r.jsx("span",{className:"text-sm",children:"系统设置"})]})})]}),r.jsx("div",{className:"p-4 border-t border-gray-700/50 space-y-1",children:r.jsxs("button",{type:"button",onClick:o,className:"w-full flex items-center gap-3 px-4 py-3 text-gray-400 hover:text-white rounded-lg hover:bg-gray-700/50 transition-colors",children:[r.jsx(oM,{className:"w-5 h-5"}),r.jsx("span",{className:"text-sm",children:"退出登录"})]})})]}),r.jsxs("div",{className:"flex-1 overflow-auto bg-[#0a1628] min-w-0 flex flex-col",children:[r.jsx(yA,{}),r.jsx("div",{className:"w-full min-w-[1024px] min-h-full flex-1",children:r.jsx(kT,{})})]})]})}function c1(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function m0(...t){return e=>{let n=!1;const s=t.map(a=>{const i=c1(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a<s.length;a++){const i=s[a];typeof i=="function"?i():c1(t[a],null)}}}}function $t(...t){return b.useCallback(m0(...t),t)}var NA=Symbol.for("react.lazy"),Gh=Jf[" use ".trim().toString()];function wA(t){return typeof t=="object"&&t!==null&&"then"in t}function jj(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===NA&&"_payload"in t&&wA(t._payload)}function kj(t){const e=jA(t),n=b.forwardRef((s,a)=>{let{children:i,...o}=s;jj(i)&&typeof Gh=="function"&&(i=Gh(i._payload));const c=b.Children.toArray(i),u=c.find(SA);if(u){const h=u.props.children,f=c.map(m=>m===u?b.Children.count(h)>1?b.Children.only(null):b.isValidElement(h)?h.props.children:null:m);return r.jsx(e,{...o,ref:a,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return r.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}var Sj=kj("Slot");function jA(t){const e=b.forwardRef((n,s)=>{let{children:a,...i}=n;if(jj(a)&&typeof Gh=="function"&&(a=Gh(a._payload)),b.isValidElement(a)){const o=EA(a),c=CA(i,a.props);return a.type!==b.Fragment&&(c.ref=s?m0(s,o):o),b.cloneElement(a,c)}return b.Children.count(a)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var kA=Symbol("radix.slottable");function SA(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===kA}function CA(t,e){const n={...e};for(const s in e){const a=t[s],i=e[s];/^on[A-Z]/.test(s)?a&&i?n[s]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[s]=a):s==="style"?n[s]={...a,...i}:s==="className"&&(n[s]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function EA(t){var s,a;let e=(s=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function Cj(t){var e,n,s="";if(typeof t=="string"||typeof t=="number")s+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(e=0;e<a;e++)t[e]&&(n=Cj(t[e]))&&(s&&(s+=" "),s+=n)}else for(n in t)t[n]&&(s&&(s+=" "),s+=n);return s}function Ej(){for(var t,e,n=0,s="",a=arguments.length;n<a;n++)(t=arguments[n])&&(e=Cj(t))&&(s&&(s+=" "),s+=e);return s}const d1=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,u1=Ej,Tj=(t,e)=>n=>{var s;if((e==null?void 0:e.variants)==null)return u1(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=d1(f)||d1(m);return a[h][g]}),c=n&&Object.entries(n).reduce((h,f)=>{let[m,g]=f;return g===void 0||(h[m]=g),h},{}),u=e==null||(s=e.compoundVariants)===null||s===void 0?void 0:s.reduce((h,f)=>{let{class:m,className:g,...y}=f;return Object.entries(y).every(v=>{let[w,N]=v;return Array.isArray(N)?N.includes({...i,...c}[w]):{...i,...c}[w]===N})?[...h,m,g]:h},[]);return u1(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},TA=(t,e)=>{const n=new Array(t.length+e.length);for(let s=0;s<t.length;s++)n[s]=t[s];for(let s=0;s<e.length;s++)n[t.length+s]=e[s];return n},MA=(t,e)=>({classGroupId:t,validator:e}),Mj=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),Jh="-",h1=[],AA="arbitrary..",IA=t=>{const e=PA(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return RA(o);const c=o.split(Jh),u=c[0]===""&&c.length>1?1:0;return Aj(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=s[o],h=n[o];return u?h?TA(h,u):u:h||h1}return n[o]||h1}}},Aj=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const a=t[e],i=n.nextPart.get(a);if(i){const h=Aj(t,e+1,i);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(Jh):t.slice(e).join(Jh),u=o.length;for(let h=0;h<u;h++){const f=o[h];if(f.validator(c))return f.classGroupId}},RA=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),s=e.slice(0,n);return s?AA+s:void 0})(),PA=t=>{const{theme:e,classGroups:n}=t;return OA(n,e)},OA=(t,e)=>{const n=Mj();for(const s in t){const a=t[s];g0(a,n,s,e)}return n},g0=(t,e,n,s)=>{const a=t.length;for(let i=0;i<a;i++){const o=t[i];LA(o,e,n,s)}},LA=(t,e,n,s)=>{if(typeof t=="string"){DA(t,e,n);return}if(typeof t=="function"){_A(t,e,n,s);return}zA(t,e,n,s)},DA=(t,e,n)=>{const s=t===""?e:Ij(e,t);s.classGroupId=n},_A=(t,e,n,s)=>{if($A(t)){g0(t(s),e,n,s);return}e.validators===null&&(e.validators=[]),e.validators.push(MA(n,t))},zA=(t,e,n,s)=>{const a=Object.entries(t),i=a.length;for(let o=0;o<i;o++){const[c,u]=a[o];g0(u,Ij(e,c),n,s)}},Ij=(t,e)=>{let n=t;const s=e.split(Jh),a=s.length;for(let i=0;i<a;i++){const o=s[i];let c=n.nextPart.get(o);c||(c=Mj(),n.nextPart.set(o,c)),n=c}return n},$A=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,FA=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),s=Object.create(null);const a=(i,o)=>{n[i]=o,e++,e>t&&(e=0,s=n,n=Object.create(null))};return{get(i){let o=n[i];if(o!==void 0)return o;if((o=s[i])!==void 0)return a(i,o),o},set(i,o){i in n?n[i]=o:a(i,o)}}},cx="!",f1=":",BA=[],p1=(t,e,n,s,a)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:s,isExternal:a}),VA=t=>{const{prefix:e,experimentalParseClassName:n}=t;let s=a=>{const i=[];let o=0,c=0,u=0,h;const f=a.length;for(let w=0;w<f;w++){const N=a[w];if(o===0&&c===0){if(N===f1){i.push(a.slice(u,w)),u=w+1;continue}if(N==="/"){h=w;continue}}N==="["?o++:N==="]"?o--:N==="("?c++:N===")"&&c--}const m=i.length===0?a:a.slice(u);let g=m,y=!1;m.endsWith(cx)?(g=m.slice(0,-1),y=!0):m.startsWith(cx)&&(g=m.slice(1),y=!0);const v=h&&h>u?h-u:void 0;return p1(i,y,g,v)};if(e){const a=e+f1,i=s;s=o=>o.startsWith(a)?i(o.slice(a.length)):p1(BA,!1,o,void 0,!0)}if(n){const a=s;s=i=>n({className:i,parseClassName:a})}return s},HA=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,s)=>{e.set(n,1e6+s)}),n=>{const s=[];let a=[];for(let i=0;i<n.length;i++){const o=n[i],c=o[0]==="[",u=e.has(o);c||u?(a.length>0&&(a.sort(),s.push(...a),a=[]),s.push(o)):a.push(o)}return a.length>0&&(a.sort(),s.push(...a)),s}},UA=t=>({cache:FA(t.cacheSize),parseClassName:VA(t),sortModifiers:HA(t),...IA(t)}),WA=/\s+/,KA=(t,e)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:a,sortModifiers:i}=e,o=[],c=t.trim().split(WA);let u="";for(let h=c.length-1;h>=0;h-=1){const f=c[h],{isExternal:m,modifiers:g,hasImportantModifier:y,baseClassName:v,maybePostfixModifierPosition:w}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let N=!!w,k=s(N?v.substring(0,w):v);if(!k){if(!N){u=f+(u.length>0?" "+u:u);continue}if(k=s(v),!k){u=f+(u.length>0?" "+u:u);continue}N=!1}const E=g.length===0?"":g.length===1?g[0]:i(g).join(":"),C=y?E+cx:E,P=C+k;if(o.indexOf(P)>-1)continue;o.push(P);const O=a(k,N);for(let U=0;U<O.length;++U){const _=O[U];o.push(C+_)}u=f+(u.length>0?" "+u:u)}return u},qA=(...t)=>{let e=0,n,s,a="";for(;e<t.length;)(n=t[e++])&&(s=Rj(n))&&(a&&(a+=" "),a+=s);return a},Rj=t=>{if(typeof t=="string")return t;let e,n="";for(let s=0;s<t.length;s++)t[s]&&(e=Rj(t[s]))&&(n&&(n+=" "),n+=e);return n},GA=(t,...e)=>{let n,s,a,i;const o=u=>{const h=e.reduce((f,m)=>m(f),t());return n=UA(h),s=n.cache.get,a=n.cache.set,i=c,c(u)},c=u=>{const h=s(u);if(h)return h;const f=KA(u,n);return a(u,f),f};return i=o,(...u)=>i(qA(...u))},JA=[],Hn=t=>{const e=n=>n[t]||JA;return e.isThemeGetter=!0,e},Pj=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Oj=/^\((?:(\w[\w-]*):)?(.+)\)$/i,YA=/^\d+\/\d+$/,QA=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,XA=/\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$/,ZA=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,eI=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,tI=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Gl=t=>YA.test(t),bt=t=>!!t&&!Number.isNaN(Number(t)),_i=t=>!!t&&Number.isInteger(Number(t)),rg=t=>t.endsWith("%")&&bt(t.slice(0,-1)),Qa=t=>QA.test(t),nI=()=>!0,sI=t=>XA.test(t)&&!ZA.test(t),Lj=()=>!1,rI=t=>eI.test(t),aI=t=>tI.test(t),iI=t=>!Ue(t)&&!We(t),oI=t=>Tc(t,zj,Lj),Ue=t=>Pj.test(t),Ho=t=>Tc(t,$j,sI),ag=t=>Tc(t,hI,bt),m1=t=>Tc(t,Dj,Lj),lI=t=>Tc(t,_j,aI),ch=t=>Tc(t,Fj,rI),We=t=>Oj.test(t),ud=t=>Mc(t,$j),cI=t=>Mc(t,fI),g1=t=>Mc(t,Dj),dI=t=>Mc(t,zj),uI=t=>Mc(t,_j),dh=t=>Mc(t,Fj,!0),Tc=(t,e,n)=>{const s=Pj.exec(t);return s?s[1]?e(s[1]):n(s[2]):!1},Mc=(t,e,n=!1)=>{const s=Oj.exec(t);return s?s[1]?e(s[1]):n:!1},Dj=t=>t==="position"||t==="percentage",_j=t=>t==="image"||t==="url",zj=t=>t==="length"||t==="size"||t==="bg-size",$j=t=>t==="length",hI=t=>t==="number",fI=t=>t==="family-name",Fj=t=>t==="shadow",pI=()=>{const t=Hn("color"),e=Hn("font"),n=Hn("text"),s=Hn("font-weight"),a=Hn("tracking"),i=Hn("leading"),o=Hn("breakpoint"),c=Hn("container"),u=Hn("spacing"),h=Hn("radius"),f=Hn("shadow"),m=Hn("inset-shadow"),g=Hn("text-shadow"),y=Hn("drop-shadow"),v=Hn("blur"),w=Hn("perspective"),N=Hn("aspect"),k=Hn("ease"),E=Hn("animate"),C=()=>["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(),We,Ue],U=()=>["auto","hidden","clip","visible","scroll"],_=()=>["auto","contain","none"],V=()=>[We,Ue,u],A=()=>[Gl,"full","auto",...V()],X=()=>[_i,"none","subgrid",We,Ue],G=()=>["auto",{span:["full",_i,We,Ue]},_i,We,Ue],z=()=>[_i,"auto",We,Ue],ne=()=>["auto","min","max","fr",We,Ue],ue=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],K=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...V()],D=()=>[Gl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...V()],I=()=>[t,We,Ue],ie=()=>[...P(),g1,m1,{position:[We,Ue]}],q=()=>["no-repeat",{repeat:["","x","y","space","round"]}],L=()=>["auto","cover","contain",dI,oI,{size:[We,Ue]}],F=()=>[rg,ud,Ho],re=()=>["","none","full",h,We,Ue],ge=()=>["",bt,ud,Ho],Te=()=>["solid","dashed","dotted","double"],se=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],le=()=>[bt,rg,g1,m1],ae=()=>["","none",v,We,Ue],Q=()=>["none",bt,We,Ue],Z=()=>["none",bt,We,Ue],xe=()=>[bt,We,Ue],Ne=()=>[Gl,"full",...V()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Qa],breakpoint:[Qa],color:[nI],container:[Qa],"drop-shadow":[Qa],ease:["in","out","in-out"],font:[iI],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Qa],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Qa],shadow:[Qa],spacing:["px",bt],text:[Qa],"text-shadow":[Qa],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Gl,Ue,We,N]}],container:["container"],columns:[{columns:[bt,Ue,We,c]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:O()}],overflow:[{overflow:U()}],"overflow-x":[{"overflow-x":U()}],"overflow-y":[{"overflow-y":U()}],overscroll:[{overscroll:_()}],"overscroll-x":[{"overscroll-x":_()}],"overscroll-y":[{"overscroll-y":_()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{start:A()}],end:[{end:A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[_i,"auto",We,Ue]}],basis:[{basis:[Gl,"full","auto",c,...V()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[bt,Gl,"auto","initial","none",Ue]}],grow:[{grow:["",bt,We,Ue]}],shrink:[{shrink:["",bt,We,Ue]}],order:[{order:[_i,"first","last","none",We,Ue]}],"grid-cols":[{"grid-cols":X()}],"col-start-end":[{col:G()}],"col-start":[{"col-start":z()}],"col-end":[{"col-end":z()}],"grid-rows":[{"grid-rows":X()}],"row-start-end":[{row:G()}],"row-start":[{"row-start":z()}],"row-end":[{"row-end":z()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ne()}],"auto-rows":[{"auto-rows":ne()}],gap:[{gap:V()}],"gap-x":[{"gap-x":V()}],"gap-y":[{"gap-y":V()}],"justify-content":[{justify:[...ue(),"normal"]}],"justify-items":[{"justify-items":[...K(),"normal"]}],"justify-self":[{"justify-self":["auto",...K()]}],"align-content":[{content:["normal",...ue()]}],"align-items":[{items:[...K(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...K(),{baseline:["","last"]}]}],"place-content":[{"place-content":ue()}],"place-items":[{"place-items":[...K(),"baseline"]}],"place-self":[{"place-self":["auto",...K()]}],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,ud,Ho]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,We,ag]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",rg,Ue]}],"font-family":[{font:[cI,Ue,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,We,Ue]}],"line-clamp":[{"line-clamp":[bt,"none",We,ag]}],leading:[{leading:[i,...V()]}],"list-image":[{"list-image":["none",We,Ue]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",We,Ue]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Te(),"wavy"]}],"text-decoration-thickness":[{decoration:[bt,"from-font","auto",We,Ho]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[bt,"auto",We,Ue]}],"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",We,Ue]}],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",We,Ue]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ie()}],"bg-repeat":[{bg:q()}],"bg-size":[{bg:L()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},_i,We,Ue],radial:["",We,Ue],conic:[_i,We,Ue]},uI,lI]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:F()}],"gradient-via-pos":[{via:F()}],"gradient-to-pos":[{to:F()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:re()}],"rounded-s":[{"rounded-s":re()}],"rounded-e":[{"rounded-e":re()}],"rounded-t":[{"rounded-t":re()}],"rounded-r":[{"rounded-r":re()}],"rounded-b":[{"rounded-b":re()}],"rounded-l":[{"rounded-l":re()}],"rounded-ss":[{"rounded-ss":re()}],"rounded-se":[{"rounded-se":re()}],"rounded-ee":[{"rounded-ee":re()}],"rounded-es":[{"rounded-es":re()}],"rounded-tl":[{"rounded-tl":re()}],"rounded-tr":[{"rounded-tr":re()}],"rounded-br":[{"rounded-br":re()}],"rounded-bl":[{"rounded-bl":re()}],"border-w":[{border:ge()}],"border-w-x":[{"border-x":ge()}],"border-w-y":[{"border-y":ge()}],"border-w-s":[{"border-s":ge()}],"border-w-e":[{"border-e":ge()}],"border-w-t":[{"border-t":ge()}],"border-w-r":[{"border-r":ge()}],"border-w-b":[{"border-b":ge()}],"border-w-l":[{"border-l":ge()}],"divide-x":[{"divide-x":ge()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ge()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Te(),"hidden","none"]}],"divide-style":[{divide:[...Te(),"hidden","none"]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...Te(),"none","hidden"]}],"outline-offset":[{"outline-offset":[bt,We,Ue]}],"outline-w":[{outline:["",bt,ud,Ho]}],"outline-color":[{outline:I()}],shadow:[{shadow:["","none",f,dh,ch]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":["none",m,dh,ch]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:ge()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[bt,Ho]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":ge()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":["none",g,dh,ch]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[bt,We,Ue]}],"mix-blend":[{"mix-blend":[...se(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":se()}],"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":[bt]}],"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":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"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":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"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":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"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":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"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":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"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":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"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":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[We,Ue]}],"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":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"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":[bt]}],"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":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ie()}],"mask-repeat":[{mask:q()}],"mask-size":[{mask:L()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",We,Ue]}],filter:[{filter:["","none",We,Ue]}],blur:[{blur:ae()}],brightness:[{brightness:[bt,We,Ue]}],contrast:[{contrast:[bt,We,Ue]}],"drop-shadow":[{"drop-shadow":["","none",y,dh,ch]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:["",bt,We,Ue]}],"hue-rotate":[{"hue-rotate":[bt,We,Ue]}],invert:[{invert:["",bt,We,Ue]}],saturate:[{saturate:[bt,We,Ue]}],sepia:[{sepia:["",bt,We,Ue]}],"backdrop-filter":[{"backdrop-filter":["","none",We,Ue]}],"backdrop-blur":[{"backdrop-blur":ae()}],"backdrop-brightness":[{"backdrop-brightness":[bt,We,Ue]}],"backdrop-contrast":[{"backdrop-contrast":[bt,We,Ue]}],"backdrop-grayscale":[{"backdrop-grayscale":["",bt,We,Ue]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[bt,We,Ue]}],"backdrop-invert":[{"backdrop-invert":["",bt,We,Ue]}],"backdrop-opacity":[{"backdrop-opacity":[bt,We,Ue]}],"backdrop-saturate":[{"backdrop-saturate":[bt,We,Ue]}],"backdrop-sepia":[{"backdrop-sepia":["",bt,We,Ue]}],"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",We,Ue]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[bt,"initial",We,Ue]}],ease:[{ease:["linear","initial",k,We,Ue]}],delay:[{delay:[bt,We,Ue]}],animate:[{animate:["none",E,We,Ue]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,We,Ue]}],"perspective-origin":[{"perspective-origin":O()}],rotate:[{rotate:Q()}],"rotate-x":[{"rotate-x":Q()}],"rotate-y":[{"rotate-y":Q()}],"rotate-z":[{"rotate-z":Q()}],scale:[{scale:Z()}],"scale-x":[{"scale-x":Z()}],"scale-y":[{"scale-y":Z()}],"scale-z":[{"scale-z":Z()}],"scale-3d":["scale-3d"],skew:[{skew:xe()}],"skew-x":[{"skew-x":xe()}],"skew-y":[{"skew-y":xe()}],transform:[{transform:[We,Ue,"","none","gpu","cpu"]}],"transform-origin":[{origin:O()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ne()}],"translate-x":[{"translate-x":Ne()}],"translate-y":[{"translate-y":Ne()}],"translate-z":[{"translate-z":Ne()}],"translate-none":["translate-none"],accent:[{accent:I()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:I()}],"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",We,Ue]}],"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",We,Ue]}],fill:[{fill:["none",...I()]}],"stroke-w":[{stroke:[bt,ud,Ho,ag]}],stroke:[{stroke:["none",...I()]}],"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"]}},mI=GA(pI);function Ft(...t){return mI(Ej(t))}function io(t){if(!t)return"";let e=t.trim();return e?(e=e.replace(/^(https?)\/\//,"$1://"),e):""}const gI=Tj("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 Y({className:t,variant:e,size:n,asChild:s=!1,...a}){const i=s?Sj:"button";return r.jsx(i,{"data-slot":"button",className:Ft(gI({variant:e,size:n,className:t})),...a})}function ce({className:t,type:e,...n}){return r.jsx("input",{type:e,"data-slot":"input",className:Ft("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 xI(){const t=Aa(),[e,n]=b.useState(""),[s,a]=b.useState(""),[i,o]=b.useState(""),[c,u]=b.useState(!1);b.useEffect(()=>{nu()&&t("/dashboard",{replace:!0})},[t]);const h=async()=>{o(""),u(!0);try{const f=await Et("/api/admin",{username:e.trim(),password:s});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){pA(f.token),t("/dashboard",{replace:!0});return}o(f.error||"用户名或密码错误")}catch(f){const m=f;o(m.status===401?"用户名或密码错误":(m==null?void 0:m.message)||"网络错误,请重试")}finally{u(!1)}};return r.jsxs("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-4",children:[r.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[r.jsx("div",{className:"absolute top-1/4 left-1/4 w-96 h-96 bg-[#38bdac]/5 rounded-full blur-3xl"}),r.jsx("div",{className:"absolute bottom-1/4 right-1/4 w-96 h-96 bg-blue-500/5 rounded-full blur-3xl"})]}),r.jsxs("div",{className:"w-full max-w-md relative z-10",children:[r.jsxs("div",{className:"text-center mb-8",children:[r.jsx("div",{className:"w-16 h-16 bg-[#38bdac]/20 rounded-2xl flex items-center justify-center mx-auto mb-4 border border-[#38bdac]/30",children:r.jsx(ic,{className:"w-8 h-8 text-[#38bdac]"})}),r.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"管理后台"}),r.jsx("p",{className:"text-gray-400",children:"一场SOUL的创业实验场"})]}),r.jsxs("div",{className:"bg-[#0f2137] rounded-2xl p-8 shadow-xl border border-gray-700/50 backdrop-blur-xl",children:[r.jsx("h2",{className:"text-xl font-semibold text-white mb-6 text-center",children:"管理员登录"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"用户名"}),r.jsxs("div",{className:"relative",children:[r.jsx(tl,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),r.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]"})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"密码"}),r.jsxs("div",{className:"relative",children:[r.jsx(aM,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),r.jsx(ce,{type:"password",value:s,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&&r.jsx("div",{className:"bg-red-500/10 text-red-400 text-sm p-3 rounded-lg border border-red-500/20",children:i}),r.jsx(Y,{onClick:h,disabled:c,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white py-5 disabled:opacity-50",children:c?"登录中...":"登录"})]})]}),r.jsx("p",{className:"text-center text-gray-500 text-xs mt-6",children:"Soul创业实验场 · 后台管理系统"})]})]})}const Oe=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:Ft("rounded-xl border bg-card text-card-foreground shadow",t),...e}));Oe.displayName="Card";const it=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:Ft("flex flex-col space-y-1.5 p-6",t),...e}));it.displayName="CardHeader";const ot=b.forwardRef(({className:t,...e},n)=>r.jsx("h3",{ref:n,className:Ft("font-semibold leading-none tracking-tight",t),...e}));ot.displayName="CardTitle";const Kt=b.forwardRef(({className:t,...e},n)=>r.jsx("p",{ref:n,className:Ft("text-sm text-muted-foreground",t),...e}));Kt.displayName="CardDescription";const Le=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:Ft("p-6 pt-0",t),...e}));Le.displayName="CardContent";const yI=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:Ft("flex items-center p-6 pt-0",t),...e}));yI.displayName="CardFooter";const bI={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:""}};function ig(t,e="info",n=3e3){const s=`toast-${Date.now()}`,a=bI[e],i=document.createElement("div");i.id=s,i.setAttribute("role","alert"),Object.assign(i.style,{position:"fixed",top:"24px",right:"24px",zIndex:"9999",display:"flex",alignItems:"center",gap:"10px",padding:"12px 18px",borderRadius:"10px",background:a.bg,border:`1.5px solid ${a.border}`,boxShadow:"0 4px 20px rgba(0,0,0,.12)",fontSize:"14px",color:"#1a1a1a",fontWeight:"500",maxWidth:"380px",lineHeight:"1.5",opacity:"0",transform:"translateY(-8px)",transition:"opacity .22s ease, transform .22s ease",pointerEvents:"none"});const o=document.createElement("span");Object.assign(o.style,{width:"20px",height:"20px",borderRadius:"50%",background:a.border,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"700",flexShrink:"0"}),o.textContent=a.icon;const c=document.createElement("span");c.textContent=t,i.appendChild(o),i.appendChild(c),document.body.appendChild(i),requestAnimationFrame(()=>{i.style.opacity="1",i.style.transform="translateY(0)"});const u=setTimeout(()=>h(s),n);function h(f){clearTimeout(u);const m=document.getElementById(f);m&&(m.style.opacity="0",m.style.transform="translateY(-8px)",setTimeout(()=>{var g;return(g=m.parentNode)==null?void 0:g.removeChild(m)},250))}}const oe={success:(t,e)=>ig(t,"success",e),error:(t,e)=>ig(t,"error",e),info:(t,e)=>ig(t,"info",e)};function xt(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 vI(t,e){const n=b.createContext(e),s=i=>{const{children:o,...c}=i,u=b.useMemo(()=>c,Object.values(c));return r.jsx(n.Provider,{value:u,children:o})};s.displayName=t+"Provider";function a(i){const o=b.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[s,a]}function mo(t,e=[]){let n=[];function s(i,o){const c=b.createContext(o),u=n.length;n=[...n,o];const h=m=>{var k;const{scope:g,children:y,...v}=m,w=((k=g==null?void 0:g[t])==null?void 0:k[u])||c,N=b.useMemo(()=>v,Object.values(v));return r.jsx(w.Provider,{value:N,children:y})};h.displayName=i+"Provider";function f(m,g){var w;const y=((w=g==null?void 0:g[t])==null?void 0:w[u])||c,v=b.useContext(y);if(v)return v;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${i}\``)}return[h,f]}const a=()=>{const i=n.map(o=>b.createContext(o));return function(c){const u=(c==null?void 0:c[t])||i;return b.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return a.scopeName=t,[s,NI(a,...e)]}function NI(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const s=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=s.reduce((c,{useScope:u,scopeName:h})=>{const m=u(i)[`__scope${h}`];return{...c,...m}},{});return b.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var Cs=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},wI=Jf[" useId ".trim().toString()]||(()=>{}),jI=0;function Zi(t){const[e,n]=b.useState(wI());return Cs(()=>{n(s=>s??String(jI++))},[t]),e?`radix-${e}`:""}var kI=Jf[" useInsertionEffect ".trim().toString()]||Cs;function ol({prop:t,defaultProp:e,onChange:n=()=>{},caller:s}){const[a,i,o]=SI({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:a;{const f=b.useRef(t!==void 0);b.useEffect(()=>{const m=f.current;m!==c&&console.warn(`${s} is changing from ${m?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=c},[c,s])}const h=b.useCallback(f=>{var m;if(c){const g=CI(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 SI({defaultProp:t,onChange:e}){const[n,s]=b.useState(t),a=b.useRef(n),i=b.useRef(e);return kI(()=>{i.current=e},[e]),b.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,s,i]}function CI(t){return typeof t=="function"}function Fd(t){const e=EI(t),n=b.forwardRef((s,a)=>{const{children:i,...o}=s,c=b.Children.toArray(i),u=c.find(MI);if(u){const h=u.props.children,f=c.map(m=>m===u?b.Children.count(h)>1?b.Children.only(null):b.isValidElement(h)?h.props.children:null:m);return r.jsx(e,{...o,ref:a,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return r.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function EI(t){const e=b.forwardRef((n,s)=>{const{children:a,...i}=n;if(b.isValidElement(a)){const o=II(a),c=AI(i,a.props);return a.type!==b.Fragment&&(c.ref=s?m0(s,o):o),b.cloneElement(a,c)}return b.Children.count(a)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var TI=Symbol("radix.slottable");function MI(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===TI}function AI(t,e){const n={...e};for(const s in e){const a=t[s],i=e[s];/^on[A-Z]/.test(s)?a&&i?n[s]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[s]=a):s==="style"?n[s]={...a,...i}:s==="className"&&(n[s]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function II(t){var s,a;let e=(s=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var RI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],vt=RI.reduce((t,e)=>{const n=Fd(`Primitive.${e}`),s=b.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...c,ref:i})});return s.displayName=`Primitive.${e}`,{...t,[e]:s}},{});function PI(t,e){t&&tu.flushSync(()=>t.dispatchEvent(e))}function oo(t){const e=b.useRef(t);return b.useEffect(()=>{e.current=t}),b.useMemo(()=>(...n)=>{var s;return(s=e.current)==null?void 0:s.call(e,...n)},[])}function OI(t,e=globalThis==null?void 0:globalThis.document){const n=oo(t);b.useEffect(()=>{const s=a=>{a.key==="Escape"&&n(a)};return e.addEventListener("keydown",s,{capture:!0}),()=>e.removeEventListener("keydown",s,{capture:!0})},[n,e])}var LI="DismissableLayer",dx="dismissableLayer.update",DI="dismissableLayer.pointerDownOutside",_I="dismissableLayer.focusOutside",x1,Bj=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),x0=b.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:c,...u}=t,h=b.useContext(Bj),[f,m]=b.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=b.useState({}),v=$t(e,_=>m(_)),w=Array.from(h.layers),[N]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),k=w.indexOf(N),E=f?w.indexOf(f):-1,C=h.layersWithOutsidePointerEventsDisabled.size>0,P=E>=k,O=FI(_=>{const V=_.target,A=[...h.branches].some(X=>X.contains(V));!P||A||(a==null||a(_),o==null||o(_),_.defaultPrevented||c==null||c())},g),U=BI(_=>{const V=_.target;[...h.branches].some(X=>X.contains(V))||(i==null||i(_),o==null||o(_),_.defaultPrevented||c==null||c())},g);return OI(_=>{E===h.layers.size-1&&(s==null||s(_),!_.defaultPrevented&&c&&(_.preventDefault(),c()))},g),b.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(x1=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),y1(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=x1)}},[f,g,n,h]),b.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),y1())},[f,h]),b.useEffect(()=>{const _=()=>y({});return document.addEventListener(dx,_),()=>document.removeEventListener(dx,_)},[]),r.jsx(vt.div,{...u,ref:v,style:{pointerEvents:C?P?"auto":"none":void 0,...t.style},onFocusCapture:xt(t.onFocusCapture,U.onFocusCapture),onBlurCapture:xt(t.onBlurCapture,U.onBlurCapture),onPointerDownCapture:xt(t.onPointerDownCapture,O.onPointerDownCapture)})});x0.displayName=LI;var zI="DismissableLayerBranch",$I=b.forwardRef((t,e)=>{const n=b.useContext(Bj),s=b.useRef(null),a=$t(e,s);return b.useEffect(()=>{const i=s.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),r.jsx(vt.div,{...t,ref:a})});$I.displayName=zI;function FI(t,e=globalThis==null?void 0:globalThis.document){const n=oo(t),s=b.useRef(!1),a=b.useRef(()=>{});return b.useEffect(()=>{const i=c=>{if(c.target&&!s.current){let u=function(){Vj(DI,n,h,{discrete:!0})};const h={originalEvent:c};c.pointerType==="touch"?(e.removeEventListener("click",a.current),a.current=u,e.addEventListener("click",a.current,{once:!0})):u()}else e.removeEventListener("click",a.current);s.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",i),e.removeEventListener("click",a.current)}},[e,n]),{onPointerDownCapture:()=>s.current=!0}}function BI(t,e=globalThis==null?void 0:globalThis.document){const n=oo(t),s=b.useRef(!1);return b.useEffect(()=>{const a=i=>{i.target&&!s.current&&Vj(_I,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",a),()=>e.removeEventListener("focusin",a)},[e,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function y1(){const t=new CustomEvent(dx);document.dispatchEvent(t)}function Vj(t,e,n,{discrete:s}){const a=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&a.addEventListener(t,e,{once:!0}),s?PI(a,i):a.dispatchEvent(i)}var og="focusScope.autoFocusOnMount",lg="focusScope.autoFocusOnUnmount",b1={bubbles:!1,cancelable:!0},VI="FocusScope",y0=b.forwardRef((t,e)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[c,u]=b.useState(null),h=oo(a),f=oo(i),m=b.useRef(null),g=$t(e,w=>u(w)),y=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(s){let w=function(C){if(y.paused||!c)return;const P=C.target;c.contains(P)?m.current=P:Fi(m.current,{select:!0})},N=function(C){if(y.paused||!c)return;const P=C.relatedTarget;P!==null&&(c.contains(P)||Fi(m.current,{select:!0}))},k=function(C){if(document.activeElement===document.body)for(const O of C)O.removedNodes.length>0&&Fi(c)};document.addEventListener("focusin",w),document.addEventListener("focusout",N);const E=new MutationObserver(k);return c&&E.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",N),E.disconnect()}}},[s,c,y.paused]),b.useEffect(()=>{if(c){N1.add(y);const w=document.activeElement;if(!c.contains(w)){const k=new CustomEvent(og,b1);c.addEventListener(og,h),c.dispatchEvent(k),k.defaultPrevented||(HI(GI(Hj(c)),{select:!0}),document.activeElement===w&&Fi(c))}return()=>{c.removeEventListener(og,h),setTimeout(()=>{const k=new CustomEvent(lg,b1);c.addEventListener(lg,f),c.dispatchEvent(k),k.defaultPrevented||Fi(w??document.body,{select:!0}),c.removeEventListener(lg,f),N1.remove(y)},0)}}},[c,h,f,y]);const v=b.useCallback(w=>{if(!n&&!s||y.paused)return;const N=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,k=document.activeElement;if(N&&k){const E=w.currentTarget,[C,P]=UI(E);C&&P?!w.shiftKey&&k===P?(w.preventDefault(),n&&Fi(C,{select:!0})):w.shiftKey&&k===C&&(w.preventDefault(),n&&Fi(P,{select:!0})):k===E&&w.preventDefault()}},[n,s,y.paused]);return r.jsx(vt.div,{tabIndex:-1,...o,ref:g,onKeyDown:v})});y0.displayName=VI;function HI(t,{select:e=!1}={}){const n=document.activeElement;for(const s of t)if(Fi(s,{select:e}),document.activeElement!==n)return}function UI(t){const e=Hj(t),n=v1(e,t),s=v1(e.reverse(),t);return[n,s]}function Hj(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const a=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||a?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function v1(t,e){for(const n of t)if(!WI(n,{upTo:e}))return n}function WI(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 KI(t){return t instanceof HTMLInputElement&&"select"in t}function Fi(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&KI(t)&&e&&t.select()}}var N1=qI();function qI(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=w1(t,e),t.unshift(e)},remove(e){var n;t=w1(t,e),(n=t[0])==null||n.resume()}}}function w1(t,e){const n=[...t],s=n.indexOf(e);return s!==-1&&n.splice(s,1),n}function GI(t){return t.filter(e=>e.tagName!=="A")}var JI="Portal",b0=b.forwardRef((t,e)=>{var c;const{container:n,...s}=t,[a,i]=b.useState(!1);Cs(()=>i(!0),[]);const o=n||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?tj.createPortal(r.jsx(vt.div,{...s,ref:e}),o):null});b0.displayName=JI;function YI(t,e){return b.useReducer((n,s)=>e[n][s]??n,t)}var su=t=>{const{present:e,children:n}=t,s=QI(e),a=typeof n=="function"?n({present:s.isPresent}):b.Children.only(n),i=$t(s.ref,XI(a));return typeof n=="function"||s.isPresent?b.cloneElement(a,{ref:i}):null};su.displayName="Presence";function QI(t){const[e,n]=b.useState(),s=b.useRef(null),a=b.useRef(t),i=b.useRef("none"),o=t?"mounted":"unmounted",[c,u]=YI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const h=uh(s.current);i.current=c==="mounted"?h:"none"},[c]),Cs(()=>{const h=s.current,f=a.current;if(f!==t){const g=i.current,y=uh(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]),Cs(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=y=>{const w=uh(s.current).includes(CSS.escape(y.animationName));if(y.target===e&&w&&(u("ANIMATION_END"),!a.current)){const N=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=N)})}},g=y=>{y.target===e&&(i.current=uh(s.current))};return e.addEventListener("animationstart",g),e.addEventListener("animationcancel",m),e.addEventListener("animationend",m),()=>{f.clearTimeout(h),e.removeEventListener("animationstart",g),e.removeEventListener("animationcancel",m),e.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[e,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:b.useCallback(h=>{s.current=h?getComputedStyle(h):null,n(h)},[])}}function uh(t){return(t==null?void 0:t.animationName)||"none"}function XI(t){var s,a;let e=(s=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var cg=0;function Uj(){b.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??j1()),document.body.insertAdjacentElement("beforeend",t[1]??j1()),cg++,()=>{cg===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),cg--}},[])}function j1(){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 ja=function(){return ja=Object.assign||function(e){for(var n,s=1,a=arguments.length;s<a;s++){n=arguments[s];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},ja.apply(this,arguments)};function Wj(t,e){var n={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(n[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,s=Object.getOwnPropertySymbols(t);a<s.length;a++)e.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(t,s[a])&&(n[s[a]]=t[s[a]]);return n}function ZI(t,e,n){if(n||arguments.length===2)for(var s=0,a=e.length,i;s<a;s++)(i||!(s in e))&&(i||(i=Array.prototype.slice.call(e,0,s)),i[s]=e[s]);return t.concat(i||Array.prototype.slice.call(e))}var Ph="right-scroll-bar-position",Oh="width-before-scroll-bar",eR="with-scroll-bars-hidden",tR="--removed-body-scroll-bar-size";function dg(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function nR(t,e){var n=b.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(s){var a=n.value;a!==s&&(n.value=s,n.callback(s,a))}}}})[0];return n.callback=e,n.facade}var sR=typeof window<"u"?b.useLayoutEffect:b.useEffect,k1=new WeakMap;function rR(t,e){var n=nR(null,function(s){return t.forEach(function(a){return dg(a,s)})});return sR(function(){var s=k1.get(n);if(s){var a=new Set(s),i=new Set(t),o=n.current;a.forEach(function(c){i.has(c)||dg(c,null)}),i.forEach(function(c){a.has(c)||dg(c,o)})}k1.set(n,t)},[t]),n}function aR(t){return t}function iR(t,e){e===void 0&&(e=aR);var n=[],s=!1,a={read:function(){if(s)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(i){var o=e(i,s);return n.push(o),function(){n=n.filter(function(c){return c!==o})}},assignSyncMedium:function(i){for(s=!0;n.length;){var o=n;n=[],o.forEach(i)}n={push:function(c){return i(c)},filter:function(){return n}}},assignMedium:function(i){s=!0;var o=[];if(n.length){var c=n;n=[],c.forEach(i),o=n}var u=function(){var f=o;o=[],f.forEach(i)},h=function(){return Promise.resolve().then(u)};h(),n={push:function(f){o.push(f),h()},filter:function(f){return o=o.filter(f),n}}}};return a}function oR(t){t===void 0&&(t={});var e=iR(null);return e.options=ja({async:!0,ssr:!1},t),e}var Kj=function(t){var e=t.sideCar,n=Wj(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=e.read();if(!s)throw new Error("Sidecar medium not found");return b.createElement(s,ja({},n))};Kj.isSideCarExport=!0;function lR(t,e){return t.useMedium(e),Kj}var qj=oR(),ug=function(){},Zf=b.forwardRef(function(t,e){var n=b.useRef(null),s=b.useState({onScrollCapture:ug,onWheelCapture:ug,onTouchMoveCapture:ug}),a=s[0],i=s[1],o=t.forwardProps,c=t.children,u=t.className,h=t.removeScrollBar,f=t.enabled,m=t.shards,g=t.sideCar,y=t.noRelative,v=t.noIsolation,w=t.inert,N=t.allowPinchZoom,k=t.as,E=k===void 0?"div":k,C=t.gapMode,P=Wj(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),O=g,U=rR([n,e]),_=ja(ja({},P),a);return b.createElement(b.Fragment,null,f&&b.createElement(O,{sideCar:qj,removeScrollBar:h,shards:m,noRelative:y,noIsolation:v,inert:w,setCallbacks:i,allowPinchZoom:!!N,lockRef:n,gapMode:C}),o?b.cloneElement(b.Children.only(c),ja(ja({},_),{ref:U})):b.createElement(E,ja({},_,{className:u,ref:U}),c))});Zf.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Zf.classNames={fullWidth:Oh,zeroRight:Ph};var cR=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function dR(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=cR();return e&&t.setAttribute("nonce",e),t}function uR(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function hR(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var fR=function(){var t=0,e=null;return{add:function(n){t==0&&(e=dR())&&(uR(e,n),hR(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},pR=function(){var t=fR();return function(e,n){b.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},Gj=function(){var t=pR(),e=function(n){var s=n.styles,a=n.dynamic;return t(s,a),null};return e},mR={left:0,top:0,right:0,gap:0},hg=function(t){return parseInt(t||"",10)||0},gR=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],s=e[t==="padding"?"paddingTop":"marginTop"],a=e[t==="padding"?"paddingRight":"marginRight"];return[hg(n),hg(s),hg(a)]},xR=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return mR;var e=gR(t),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,s-n+e[2]-e[0])}},yR=Gj(),dc="data-scroll-locked",bR=function(t,e,n,s){var a=t.left,i=t.top,o=t.right,c=t.gap;return n===void 0&&(n="margin"),`
.`.concat(eR,` {
overflow: hidden `).concat(s,`;
padding-right: `).concat(c,"px ").concat(s,`;
}
body[`).concat(dc,`] {
overflow: hidden `).concat(s,`;
overscroll-behavior: contain;
`).concat([e&&"position: relative ".concat(s,";"),n==="margin"&&`
padding-left: `.concat(a,`px;
padding-top: `).concat(i,`px;
padding-right: `).concat(o,`px;
margin-left:0;
margin-top:0;
margin-right: `).concat(c,"px ").concat(s,`;
`),n==="padding"&&"padding-right: ".concat(c,"px ").concat(s,";")].filter(Boolean).join(""),`
}
.`).concat(Ph,` {
right: `).concat(c,"px ").concat(s,`;
}
.`).concat(Oh,` {
margin-right: `).concat(c,"px ").concat(s,`;
}
.`).concat(Ph," .").concat(Ph,` {
right: 0 `).concat(s,`;
}
.`).concat(Oh," .").concat(Oh,` {
margin-right: 0 `).concat(s,`;
}
body[`).concat(dc,`] {
`).concat(tR,": ").concat(c,`px;
}
`)},S1=function(){var t=parseInt(document.body.getAttribute(dc)||"0",10);return isFinite(t)?t:0},vR=function(){b.useEffect(function(){return document.body.setAttribute(dc,(S1()+1).toString()),function(){var t=S1()-1;t<=0?document.body.removeAttribute(dc):document.body.setAttribute(dc,t.toString())}},[])},NR=function(t){var e=t.noRelative,n=t.noImportant,s=t.gapMode,a=s===void 0?"margin":s;vR();var i=b.useMemo(function(){return xR(a)},[a]);return b.createElement(yR,{styles:bR(i,!e,a,n?"":"!important")})},ux=!1;if(typeof window<"u")try{var hh=Object.defineProperty({},"passive",{get:function(){return ux=!0,!0}});window.addEventListener("test",hh,hh),window.removeEventListener("test",hh,hh)}catch{ux=!1}var Jl=ux?{passive:!1}:!1,wR=function(t){return t.tagName==="TEXTAREA"},Jj=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!wR(t)&&n[e]==="visible")},jR=function(t){return Jj(t,"overflowY")},kR=function(t){return Jj(t,"overflowX")},C1=function(t,e){var n=e.ownerDocument,s=e;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var a=Yj(t,s);if(a){var i=Qj(t,s),o=i[1],c=i[2];if(o>c)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},SR=function(t){var e=t.scrollTop,n=t.scrollHeight,s=t.clientHeight;return[e,n,s]},CR=function(t){var e=t.scrollLeft,n=t.scrollWidth,s=t.clientWidth;return[e,n,s]},Yj=function(t,e){return t==="v"?jR(e):kR(e)},Qj=function(t,e){return t==="v"?SR(e):CR(e)},ER=function(t,e){return t==="h"&&e==="rtl"?-1:1},TR=function(t,e,n,s,a){var i=ER(t,window.getComputedStyle(e).direction),o=i*s,c=n.target,u=e.contains(c),h=!1,f=o>0,m=0,g=0;do{if(!c)break;var y=Qj(t,c),v=y[0],w=y[1],N=y[2],k=w-N-i*v;(v||k)&&Yj(t,c)&&(m+=k,g+=v);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},fh=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},E1=function(t){return[t.deltaX,t.deltaY]},T1=function(t){return t&&"current"in t?t.current:t},MR=function(t,e){return t[0]===e[0]&&t[1]===e[1]},AR=function(t){return`
.block-interactivity-`.concat(t,` {pointer-events: none;}
.allow-interactivity-`).concat(t,` {pointer-events: all;}
`)},IR=0,Yl=[];function RR(t){var e=b.useRef([]),n=b.useRef([0,0]),s=b.useRef(),a=b.useState(IR++)[0],i=b.useState(Gj)[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=ZI([t.lockRef.current],(t.shards||[]).map(T1),!0).filter(Boolean);return w.forEach(function(N){return N.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),w.forEach(function(N){return N.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var c=b.useCallback(function(w,N){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!o.current.allowPinchZoom;var k=fh(w),E=n.current,C="deltaX"in w?w.deltaX:E[0]-k[0],P="deltaY"in w?w.deltaY:E[1]-k[1],O,U=w.target,_=Math.abs(C)>Math.abs(P)?"h":"v";if("touches"in w&&_==="h"&&U.type==="range")return!1;var V=window.getSelection(),A=V&&V.anchorNode,X=A?A===U||A.contains(U):!1;if(X)return!1;var G=C1(_,U);if(!G)return!0;if(G?O=_:(O=_==="v"?"h":"v",G=C1(_,U)),!G)return!1;if(!s.current&&"changedTouches"in w&&(C||P)&&(s.current=O),!O)return!0;var z=s.current||O;return TR(z,N,w,z==="h"?C:P)},[]),u=b.useCallback(function(w){var N=w;if(!(!Yl.length||Yl[Yl.length-1]!==i)){var k="deltaY"in N?E1(N):fh(N),E=e.current.filter(function(O){return O.name===N.type&&(O.target===N.target||N.target===O.shadowParent)&&MR(O.delta,k)})[0];if(E&&E.should){N.cancelable&&N.preventDefault();return}if(!E){var C=(o.current.shards||[]).map(T1).filter(Boolean).filter(function(O){return O.contains(N.target)}),P=C.length>0?c(N,C[0]):!o.current.noIsolation;P&&N.cancelable&&N.preventDefault()}}},[]),h=b.useCallback(function(w,N,k,E){var C={name:w,delta:N,target:k,should:E,shadowParent:PR(k)};e.current.push(C),setTimeout(function(){e.current=e.current.filter(function(P){return P!==C})},1)},[]),f=b.useCallback(function(w){n.current=fh(w),s.current=void 0},[]),m=b.useCallback(function(w){h(w.type,E1(w),w.target,c(w,t.lockRef.current))},[]),g=b.useCallback(function(w){h(w.type,fh(w),w.target,c(w,t.lockRef.current))},[]);b.useEffect(function(){return Yl.push(i),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:g}),document.addEventListener("wheel",u,Jl),document.addEventListener("touchmove",u,Jl),document.addEventListener("touchstart",f,Jl),function(){Yl=Yl.filter(function(w){return w!==i}),document.removeEventListener("wheel",u,Jl),document.removeEventListener("touchmove",u,Jl),document.removeEventListener("touchstart",f,Jl)}},[]);var y=t.removeScrollBar,v=t.inert;return b.createElement(b.Fragment,null,v?b.createElement(i,{styles:AR(a)}):null,y?b.createElement(NR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function PR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const OR=lR(qj,RR);var v0=b.forwardRef(function(t,e){return b.createElement(Zf,ja({},t,{ref:e,sideCar:OR}))});v0.classNames=Zf.classNames;var LR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Ql=new WeakMap,ph=new WeakMap,mh={},fg=0,Xj=function(t){return t&&(t.host||Xj(t.parentNode))},DR=function(t,e){return e.map(function(n){if(t.contains(n))return n;var s=Xj(n);return s&&t.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},_R=function(t,e,n,s){var a=DR(e,Array.isArray(t)?t:[t]);mh[n]||(mh[n]=new WeakMap);var i=mh[n],o=[],c=new Set,u=new Set(a),h=function(m){!m||c.has(m)||(c.add(m),h(m.parentNode))};a.forEach(h);var f=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(g){if(c.has(g))f(g);else try{var y=g.getAttribute(s),v=y!==null&&y!=="false",w=(Ql.get(g)||0)+1,N=(i.get(g)||0)+1;Ql.set(g,w),i.set(g,N),o.push(g),w===1&&v&&ph.set(g,!0),N===1&&g.setAttribute(n,"true"),v||g.setAttribute(s,"true")}catch(k){console.error("aria-hidden: cannot operate on ",g,k)}})};return f(e),c.clear(),fg++,function(){o.forEach(function(m){var g=Ql.get(m)-1,y=i.get(m)-1;Ql.set(m,g),i.set(m,y),g||(ph.has(m)||m.removeAttribute(s),ph.delete(m)),y||m.removeAttribute(n)}),fg--,fg||(Ql=new WeakMap,Ql=new WeakMap,ph=new WeakMap,mh={})}},Zj=function(t,e,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(t)?t:[t]),a=LR(t);return a?(s.push.apply(s,Array.from(a.querySelectorAll("[aria-live], script"))),_R(s,a,n,"aria-hidden")):function(){return null}},ep="Dialog",[ek]=mo(ep),[zR,Xr]=ek(ep),tk=t=>{const{__scopeDialog:e,children:n,open:s,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,c=b.useRef(null),u=b.useRef(null),[h,f]=ol({prop:s,defaultProp:a??!1,onChange:i,caller:ep});return r.jsx(zR,{scope:e,triggerRef:c,contentRef:u,contentId:Zi(),titleId:Zi(),descriptionId:Zi(),open:h,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};tk.displayName=ep;var nk="DialogTrigger",$R=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Xr(nk,n),i=$t(e,a.triggerRef);return r.jsx(vt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":j0(a.open),...s,ref:i,onClick:xt(t.onClick,a.onOpenToggle)})});$R.displayName=nk;var N0="DialogPortal",[FR,sk]=ek(N0,{forceMount:void 0}),rk=t=>{const{__scopeDialog:e,forceMount:n,children:s,container:a}=t,i=Xr(N0,e);return r.jsx(FR,{scope:e,forceMount:n,children:b.Children.map(s,o=>r.jsx(su,{present:n||i.open,children:r.jsx(b0,{asChild:!0,container:a,children:o})}))})};rk.displayName=N0;var Yh="DialogOverlay",ak=b.forwardRef((t,e)=>{const n=sk(Yh,t.__scopeDialog),{forceMount:s=n.forceMount,...a}=t,i=Xr(Yh,t.__scopeDialog);return i.modal?r.jsx(su,{present:s||i.open,children:r.jsx(VR,{...a,ref:e})}):null});ak.displayName=Yh;var BR=Fd("DialogOverlay.RemoveScroll"),VR=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Xr(Yh,n);return r.jsx(v0,{as:BR,allowPinchZoom:!0,shards:[a.contentRef],children:r.jsx(vt.div,{"data-state":j0(a.open),...s,ref:e,style:{pointerEvents:"auto",...s.style}})})}),ll="DialogContent",ik=b.forwardRef((t,e)=>{const n=sk(ll,t.__scopeDialog),{forceMount:s=n.forceMount,...a}=t,i=Xr(ll,t.__scopeDialog);return r.jsx(su,{present:s||i.open,children:i.modal?r.jsx(HR,{...a,ref:e}):r.jsx(UR,{...a,ref:e})})});ik.displayName=ll;var HR=b.forwardRef((t,e)=>{const n=Xr(ll,t.__scopeDialog),s=b.useRef(null),a=$t(e,n.contentRef,s);return b.useEffect(()=>{const i=s.current;if(i)return Zj(i)},[]),r.jsx(ok,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xt(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:xt(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&i.preventDefault()}),onFocusOutside:xt(t.onFocusOutside,i=>i.preventDefault())})}),UR=b.forwardRef((t,e)=>{const n=Xr(ll,t.__scopeDialog),s=b.useRef(!1),a=b.useRef(!1);return r.jsx(ok,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,c;(o=t.onCloseAutoFocus)==null||o.call(t,i),i.defaultPrevented||(s.current||(c=n.triggerRef.current)==null||c.focus(),i.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:i=>{var u,h;(u=t.onInteractOutside)==null||u.call(t,i),i.defaultPrevented||(s.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((h=n.triggerRef.current)==null?void 0:h.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),ok=b.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,c=Xr(ll,n),u=b.useRef(null),h=$t(e,u);return Uj(),r.jsxs(r.Fragment,{children:[r.jsx(y0,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:i,children:r.jsx(x0,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":j0(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(WR,{titleId:c.titleId}),r.jsx(qR,{contentRef:u,descriptionId:c.descriptionId})]})]})}),w0="DialogTitle",lk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Xr(w0,n);return r.jsx(vt.h2,{id:a.titleId,...s,ref:e})});lk.displayName=w0;var ck="DialogDescription",dk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Xr(ck,n);return r.jsx(vt.p,{id:a.descriptionId,...s,ref:e})});dk.displayName=ck;var uk="DialogClose",hk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Xr(uk,n);return r.jsx(vt.button,{type:"button",...s,ref:e,onClick:xt(t.onClick,()=>a.onOpenChange(!1))})});hk.displayName=uk;function j0(t){return t?"open":"closed"}var fk="DialogTitleWarning",[m9,pk]=vI(fk,{contentName:ll,titleName:w0,docsSlug:"dialog"}),WR=({titleId:t})=>{const e=pk(fk),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},KR="DialogDescriptionWarning",qR=({contentRef:t,descriptionId:e})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${pk(KR).contentName}}.`;return b.useEffect(()=>{var i;const a=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");e&&a&&(document.getElementById(e)||console.warn(s))},[s,t,e]),null},GR=tk,JR=rk,YR=ak,QR=ik,XR=lk,ZR=dk,eP=hk;function Ht(t){return r.jsx(GR,{"data-slot":"dialog",...t})}function tP(t){return r.jsx(JR,{...t})}const mk=b.forwardRef(({className:t,...e},n)=>r.jsx(YR,{ref:n,className:Ft("fixed inset-0 z-50 bg-black/50",t),...e}));mk.displayName="DialogOverlay";const _t=b.forwardRef(({className:t,children:e,showCloseButton:n=!0,...s},a)=>r.jsxs(tP,{children:[r.jsx(mk,{}),r.jsxs(QR,{ref:a,"aria-describedby":void 0,className:Ft("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border bg-background p-6 shadow-lg",t),...s,children:[e,n&&r.jsxs(eP,{className:"absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[r.jsx(us,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));_t.displayName="DialogContent";function Ut({className:t,...e}){return r.jsx("div",{className:Ft("flex flex-col gap-2 text-center sm:text-left",t),...e})}function xn({className:t,...e}){return r.jsx("div",{className:Ft("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Wt(t){return r.jsx(XR,{className:"text-lg font-semibold leading-none",...t})}function Qh(t){return r.jsx(ZR,{className:"text-sm text-muted-foreground",...t})}const nP=Tj("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 Ge({className:t,variant:e,asChild:n=!1,...s}){const a=n?Sj:"span";return r.jsx(a,{className:Ft(nP({variant:e}),t),...s})}var sP=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],rP=sP.reduce((t,e)=>{const n=kj(`Primitive.${e}`),s=b.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...c,ref:i})});return s.displayName=`Primitive.${e}`,{...t,[e]:s}},{}),aP="Label",gk=b.forwardRef((t,e)=>r.jsx(rP.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())}}));gk.displayName=aP;var xk=gk;const ee=b.forwardRef(({className:t,...e},n)=>r.jsx(xk,{ref:n,className:Ft("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));ee.displayName=xk.displayName;function k0(t){const e=t+"CollectionProvider",[n,s]=mo(e),[a,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:N,children:k}=w,E=Ls.useRef(null),C=Ls.useRef(new Map).current;return r.jsx(a,{scope:N,itemMap:C,collectionRef:E,children:k})};o.displayName=e;const c=t+"CollectionSlot",u=Fd(c),h=Ls.forwardRef((w,N)=>{const{scope:k,children:E}=w,C=i(c,k),P=$t(N,C.collectionRef);return r.jsx(u,{ref:P,children:E})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",g=Fd(f),y=Ls.forwardRef((w,N)=>{const{scope:k,children:E,...C}=w,P=Ls.useRef(null),O=$t(N,P),U=i(f,k);return Ls.useEffect(()=>(U.itemMap.set(P,{ref:P,...C}),()=>void U.itemMap.delete(P))),r.jsx(g,{[m]:"",ref:O,children:E})});y.displayName=f;function v(w){const N=i(t+"CollectionConsumer",w);return Ls.useCallback(()=>{const E=N.collectionRef.current;if(!E)return[];const C=Array.from(E.querySelectorAll(`[${m}]`));return Array.from(N.itemMap.values()).sort((U,_)=>C.indexOf(U.ref.current)-C.indexOf(_.ref.current))},[N.collectionRef,N.itemMap])}return[{Provider:o,Slot:h,ItemSlot:y},v,s]}var iP=b.createContext(void 0);function tp(t){const e=b.useContext(iP);return t||e||"ltr"}var pg="rovingFocusGroup.onEntryFocus",oP={bubbles:!1,cancelable:!0},ru="RovingFocusGroup",[hx,yk,lP]=k0(ru),[cP,bk]=mo(ru,[lP]),[dP,uP]=cP(ru),vk=b.forwardRef((t,e)=>r.jsx(hx.Provider,{scope:t.__scopeRovingFocusGroup,children:r.jsx(hx.Slot,{scope:t.__scopeRovingFocusGroup,children:r.jsx(hP,{...t,ref:e})})}));vk.displayName=ru;var hP=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...m}=t,g=b.useRef(null),y=$t(e,g),v=tp(i),[w,N]=ol({prop:o,defaultProp:c??null,onChange:u,caller:ru}),[k,E]=b.useState(!1),C=oo(h),P=yk(n),O=b.useRef(!1),[U,_]=b.useState(0);return b.useEffect(()=>{const V=g.current;if(V)return V.addEventListener(pg,C),()=>V.removeEventListener(pg,C)},[C]),r.jsx(dP,{scope:n,orientation:s,dir:v,loop:a,currentTabStopId:w,onItemFocus:b.useCallback(V=>N(V),[N]),onItemShiftTab:b.useCallback(()=>E(!0),[]),onFocusableItemAdd:b.useCallback(()=>_(V=>V+1),[]),onFocusableItemRemove:b.useCallback(()=>_(V=>V-1),[]),children:r.jsx(vt.div,{tabIndex:k||U===0?-1:0,"data-orientation":s,...m,ref:y,style:{outline:"none",...t.style},onMouseDown:xt(t.onMouseDown,()=>{O.current=!0}),onFocus:xt(t.onFocus,V=>{const A=!O.current;if(V.target===V.currentTarget&&A&&!k){const X=new CustomEvent(pg,oP);if(V.currentTarget.dispatchEvent(X),!X.defaultPrevented){const G=P().filter($=>$.focusable),z=G.find($=>$.active),ne=G.find($=>$.id===w),K=[z,ne,...G].filter(Boolean).map($=>$.ref.current);jk(K,f)}}O.current=!1}),onBlur:xt(t.onBlur,()=>E(!1))})})}),Nk="RovingFocusGroupItem",wk=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:a=!1,tabStopId:i,children:o,...c}=t,u=Zi(),h=i||u,f=uP(Nk,n),m=f.currentTabStopId===h,g=yk(n),{onFocusableItemAdd:y,onFocusableItemRemove:v,currentTabStopId:w}=f;return b.useEffect(()=>{if(s)return y(),()=>v()},[s,y,v]),r.jsx(hx.ItemSlot,{scope:n,id:h,focusable:s,active:a,children:r.jsx(vt.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:xt(t.onMouseDown,N=>{s?f.onItemFocus(h):N.preventDefault()}),onFocus:xt(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:xt(t.onKeyDown,N=>{if(N.key==="Tab"&&N.shiftKey){f.onItemShiftTab();return}if(N.target!==N.currentTarget)return;const k=mP(N,f.orientation,f.dir);if(k!==void 0){if(N.metaKey||N.ctrlKey||N.altKey||N.shiftKey)return;N.preventDefault();let C=g().filter(P=>P.focusable).map(P=>P.ref.current);if(k==="last")C.reverse();else if(k==="prev"||k==="next"){k==="prev"&&C.reverse();const P=C.indexOf(N.currentTarget);C=f.loop?gP(C,P+1):C.slice(P+1)}setTimeout(()=>jk(C))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:w!=null}):o})})});wk.displayName=Nk;var fP={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function pP(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function mP(t,e,n){const s=pP(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return fP[s]}function jk(t,e=!1){const n=document.activeElement;for(const s of t)if(s===n||(s.focus({preventScroll:e}),document.activeElement!==n))return}function gP(t,e){return t.map((n,s)=>t[(e+s)%t.length])}var xP=vk,yP=wk,np="Tabs",[bP]=mo(np,[bk]),kk=bk(),[vP,S0]=bP(np),Sk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=tp(c),[m,g]=ol({prop:s,onChange:a,defaultProp:i??"",caller:np});return r.jsx(vP,{scope:n,baseId:Zi(),value:m,onValueChange:g,orientation:o,dir:f,activationMode:u,children:r.jsx(vt.div,{dir:f,"data-orientation":o,...h,ref:e})})});Sk.displayName=np;var Ck="TabsList",Ek=b.forwardRef((t,e)=>{const{__scopeTabs:n,loop:s=!0,...a}=t,i=S0(Ck,n),o=kk(n);return r.jsx(xP,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:s,children:r.jsx(vt.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:e})})});Ek.displayName=Ck;var Tk="TabsTrigger",Mk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,disabled:a=!1,...i}=t,o=S0(Tk,n),c=kk(n),u=Rk(o.baseId,s),h=Pk(o.baseId,s),f=s===o.value;return r.jsx(yP,{asChild:!0,...c,focusable:!a,active:f,children:r.jsx(vt.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:xt(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(s):m.preventDefault()}),onKeyDown:xt(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(s)}),onFocus:xt(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!a&&m&&o.onValueChange(s)})})})});Mk.displayName=Tk;var Ak="TabsContent",Ik=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,forceMount:a,children:i,...o}=t,c=S0(Ak,n),u=Rk(c.baseId,s),h=Pk(c.baseId,s),f=s===c.value,m=b.useRef(f);return b.useEffect(()=>{const g=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(g)},[]),r.jsx(su,{present:a||f,children:({present:g})=>r.jsx(vt.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})})});Ik.displayName=Ak;function Rk(t,e){return`${t}-trigger-${e}`}function Pk(t,e){return`${t}-content-${e}`}var NP=Sk,Ok=Ek,Lk=Mk,Dk=Ik;const au=NP,Ac=b.forwardRef(({className:t,...e},n)=>r.jsx(Ok,{ref:n,className:Ft("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));Ac.displayName=Ok.displayName;const yn=b.forwardRef(({className:t,...e},n)=>r.jsx(Lk,{ref:n,className:Ft("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}));yn.displayName=Lk.displayName;const bn=b.forwardRef(({className:t,...e},n)=>r.jsx(Dk,{ref:n,className:Ft("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));bn.displayName=Dk.displayName;function C0(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 E0(t){const[e,n]=b.useState(void 0);return Cs(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const s=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const i=a[0];let o,c;if("borderBoxSize"in i){const u=i.borderBoxSize,h=Array.isArray(u)?u[0]:u;o=h.inlineSize,c=h.blockSize}else o=t.offsetWidth,c=t.offsetHeight;n({width:o,height:c})});return s.observe(t,{box:"border-box"}),()=>s.unobserve(t)}else n(void 0)},[t]),e}var sp="Switch",[wP]=mo(sp),[jP,kP]=wP(sp),_k=b.forwardRef((t,e)=>{const{__scopeSwitch:n,name:s,checked:a,defaultChecked:i,required:o,disabled:c,value:u="on",onCheckedChange:h,form:f,...m}=t,[g,y]=b.useState(null),v=$t(e,C=>y(C)),w=b.useRef(!1),N=g?f||!!g.closest("form"):!0,[k,E]=ol({prop:a,defaultProp:i??!1,onChange:h,caller:sp});return r.jsxs(jP,{scope:n,checked:k,disabled:c,children:[r.jsx(vt.button,{type:"button",role:"switch","aria-checked":k,"aria-required":o,"data-state":Bk(k),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:v,onClick:xt(t.onClick,C=>{E(P=>!P),N&&(w.current=C.isPropagationStopped(),w.current||C.stopPropagation())})}),N&&r.jsx(Fk,{control:g,bubbles:!w.current,name:s,value:u,checked:k,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});_k.displayName=sp;var zk="SwitchThumb",$k=b.forwardRef((t,e)=>{const{__scopeSwitch:n,...s}=t,a=kP(zk,n);return r.jsx(vt.span,{"data-state":Bk(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:e})});$k.displayName=zk;var SP="SwitchBubbleInput",Fk=b.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:s=!0,...a},i)=>{const o=b.useRef(null),c=$t(o,i),u=C0(n),h=E0(e);return b.useEffect(()=>{const f=o.current;if(!f)return;const m=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(m,"checked").set;if(u!==n&&y){const v=new Event("click",{bubbles:s});y.call(f,n),f.dispatchEvent(v)}},[u,n,s]),r.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:c,style:{...a.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Fk.displayName=SP;function Bk(t){return t?"checked":"unchecked"}var Vk=_k,CP=$k;const Rt=b.forwardRef(({className:t,...e},n)=>r.jsx(Vk,{className:Ft("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#38bdac] focus-visible:ring-offset-2 focus-visible:ring-offset-[#0a1628] disabled:cursor-not-allowed disabled:opacity-50 data-[state=unchecked]:bg-gray-600 data-[state=checked]:bg-[#38bdac]",t),...e,ref:n,children:r.jsx(CP,{className:Ft("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")})}));Rt.displayName=Vk.displayName;const EP={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 TP(t){return EP[t]||t||"行为"}function MP(t,e){const n=new Set,s=a=>(t[a]??0)>0;return(s("purchase")||s("first_pay")||s("vip_activate"))&&n.add("已付费"),(s("lead_submit")||s("click_super"))&&n.add("高意向"),s("view_chapter")&&n.add("想学习"),s("match")&&n.add("找合伙人"),s("withdraw")&&n.add("有提现行为"),s("referral_bind")&&n.add("推广参与"),(s("fill_profile")||s("fill_avatar")||s("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 T0({open:t,onClose:e,userId:n,onUserUpdated:s}){var Wn;const[a,i]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState({}),[f,m]=b.useState([]),[g,y]=b.useState(null),[v,w]=b.useState(!1),[N,k]=b.useState(!1),[E,C]=b.useState(!1),[P,O]=b.useState("info"),[U,_]=b.useState(""),[V,A]=b.useState(""),[X,G]=b.useState(""),[z,ne]=b.useState([]),[ue,K]=b.useState(""),[$,D]=b.useState(""),[I,ie]=b.useState(""),[q,L]=b.useState(!1),[F,re]=b.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[ge,Te]=b.useState([]),[se,le]=b.useState(!1),[ae,Q]=b.useState(""),[Z,xe]=b.useState(""),[Ne,ct]=b.useState(!1),[ye,$e]=b.useState(!1),[Ze,tt]=b.useState(null),[_e,st]=b.useState(null),[kt,Pt]=b.useState(""),[Ot,Mn]=b.useState(""),[Dn,gs]=b.useState(""),[zs,ts]=b.useState(!1),[xs,Gt]=b.useState(null);b.useEffect(()=>{t&&n&&(O("info"),tt(null),st(null),Gt(null),D(""),ie(""),ln(),De("/api/db/vip-roles").then(pe=>{pe!=null&&pe.success&&pe.data&&Te(pe.data)}).catch(()=>{}))},[t,n]);async function ln(){if(n){w(!0);try{const pe=await De(`/api/db/users?id=${encodeURIComponent(n)}`);if(pe!=null&&pe.success&&pe.user){const be=pe.user;i(be),_(be.phone||""),A(be.wechatId||""),G(be.nickname||""),Pt(be.phone||""),Mn(be.wechatId||""),gs(be.openId||"");try{ne(typeof be.tags=="string"?JSON.parse(be.tags||"[]"):[])}catch{ne([])}re({isVip:!!(be.isVip??!1),vipExpireDate:be.vipExpireDate?String(be.vipExpireDate).slice(0,10):"",vipRole:String(be.vipRole??""),vipName:String(be.vipName??""),vipProject:String(be.vipProject??""),vipContact:String(be.vipContact??""),vipBio:String(be.vipBio??"")})}try{const be=await De(`/api/admin/user/track?userId=${encodeURIComponent(n)}&limit=100`);if(be!=null&&be.success){h(be.stats&&typeof be.stats=="object"?be.stats:{});const vn=be.tracks||[];c(vn.map(hn=>({...hn,actionLabel:hn.actionLabel||hn.action,timeAgo:hn.timeAgo||""})))}else h({}),c([])}catch{h({}),c([])}try{const be=await De(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);be!=null&&be.success&&be.referrals&&m(be.referrals)}catch{m([])}try{const be=await De(`/api/admin/users/${encodeURIComponent(n)}/balance`);be!=null&&be.success&&be.data?y(be.data):y(null)}catch{y(null)}}catch(pe){console.error("Load user detail error:",pe)}finally{w(!1)}}}async function As(){if(!(a!=null&&a.phone)){oe.info("用户未绑定手机号,无法同步");return}k(!0);try{const pe=await Et("/api/ckb/sync",{action:"full_sync",phone:a.phone,userId:a.id});pe!=null&&pe.success?(oe.success("同步成功"),ln()):oe.error("同步失败: "+(pe==null?void 0:pe.error))}catch(pe){console.error("Sync CKB error:",pe),oe.error("同步失败")}finally{k(!1)}}async function Is(){if(a){if(F.isVip&&!F.vipExpireDate.trim()){oe.error("开启 VIP 请填写有效到期日");return}C(!0);try{const pe={id:a.id,phone:U.trim()||void 0,wechatId:V.trim(),nickname:X||void 0,tags:JSON.stringify(z),isVip:F.isVip,vipExpireDate:F.isVip?F.vipExpireDate:void 0,vipRole:F.vipRole||void 0,vipName:F.vipName||void 0,vipProject:F.vipProject||void 0,vipContact:F.vipContact||void 0,vipBio:F.vipBio||void 0},be=await Jt("/api/db/users",pe);be!=null&&be.success?(oe.success("保存成功"),ln(),s==null||s()):oe.error("保存失败: "+(be==null?void 0:be.error))}catch(pe){console.error("Save user error:",pe),oe.error("保存失败")}finally{C(!1)}}}const ns=()=>{ue&&!z.includes(ue)&&(ne([...z,ue]),K(""))},W=pe=>ne(z.filter(be=>be!==pe));async function Qe(){if(a){if(!$){oe.error("请输入新密码");return}if($!==I){oe.error("两次密码不一致");return}if($.length<6){oe.error("密码至少 6 位");return}L(!0);try{const pe=await Jt("/api/db/users",{id:a.id,password:$});pe!=null&&pe.success?(oe.success("修改成功"),D(""),ie("")):oe.error("修改失败: "+((pe==null?void 0:pe.error)||""))}catch{oe.error("修改失败")}finally{L(!1)}}}async function mt(){if(!a)return;const pe=parseFloat(ae);if(Number.isNaN(pe)||pe===0){oe.error("请输入有效金额(正数增加、负数扣减)");return}ct(!0);try{const be=await Et(`/api/admin/users/${a.id}/balance/adjust`,{amount:pe,remark:Z||void 0});be!=null&&be.success?(oe.success("余额已调整"),le(!1),Q(""),xe(""),ln(),s==null||s()):oe.error("调整失败: "+((be==null?void 0:be.error)||""))}catch{oe.error("调整失败")}finally{ct(!1)}}async function Bt(){if(!kt&&!Dn&&!Ot){st("请至少输入手机号、微信号或 OpenID 中的一项");return}$e(!0),st(null),tt(null);try{const pe=new URLSearchParams;kt&&pe.set("phone",kt),Dn&&pe.set("openId",Dn),Ot&&pe.set("wechatId",Ot);const be=await De(`/api/admin/shensheshou/query?${pe}`);be!=null&&be.success&&be.data?(tt(be.data),a&&await gt(be.data)):st((be==null?void 0:be.error)||"未查询到数据,该用户可能未在神射手收录")}catch(pe){console.error("SSS query error:",pe),st("请求失败,请检查神射手接口配置")}finally{$e(!1)}}async function gt(pe){if(a)try{await Et("/api/admin/shensheshou/enrich",{userId:a.id,phone:kt||a.phone||"",openId:Dn||a.openId||"",wechatId:Ot||a.wechatId||""}),ln()}catch(be){console.error("SSS enrich error:",be)}}async function ht(){if(a){ts(!0),Gt(null);try{const pe={users:[{phone:a.phone||"",name:a.nickname||"",openId:a.openId||"",tags:z}]},be=await Et("/api/admin/shensheshou/ingest",pe);be!=null&&be.success&&be.data?Gt(be.data):Gt({error:(be==null?void 0:be.error)||"推送失败"})}catch(pe){console.error("SSS ingest error:",pe),Gt({error:"请求失败"})}finally{ts(!1)}}}const At=pe=>{const vn={view_chapter:Js,purchase:ox,match:zn,login:tl,register:tl,share:ro,bind_phone:SM,bind_wechat:hM,fill_profile:Sd,visit_page:Jo}[pe]||sx;return r.jsx(vn,{className:"w-4 h-4"})},It=b.useMemo(()=>MP(u,a),[u,a]);function sn(){const pe=[...z];for(const be of It)pe.includes(be)||pe.push(be);ne(pe),oe.success("已将旅程推断标签合并到已选")}return t?r.jsxs(r.Fragment,{children:[r.jsx(Ht,{open:t,onOpenChange:()=>e(),children:r.jsxs(_t,{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:[r.jsx(Ut,{children:r.jsxs(Wt,{className:"text-white flex items-center gap-2",children:[r.jsx(tl,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(a==null?void 0:a.phone)&&r.jsx(Ge,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(a==null?void 0:a.isVip)&&r.jsx(Ge,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),v?r.jsxs("div",{className:"flex items-center justify-center py-20",children:[r.jsx(Be,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):a?r.jsxs("div",{className:"flex flex-col min-h-0 flex-1 overflow-hidden",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row gap-2.5 p-2.5 bg-[#0a1628] rounded-lg mb-2 shrink-0",children:[r.jsxs("div",{className:"flex gap-2.5 min-w-0 flex-1",children:[r.jsx("div",{className:"w-11 h-11 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-lg text-[#38bdac] shrink-0",children:a.avatar?r.jsx("img",{src:io(a.avatar),className:"w-full h-full rounded-full object-cover",alt:""}):((Wn=a.nickname)==null?void 0:Wn.charAt(0))||"?"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[r.jsx("h3",{className:"text-base font-bold text-white leading-tight",children:a.nickname}),a.isAdmin&&r.jsx(Ge,{className:"bg-purple-500/20 text-purple-400 border-0 text-[10px] py-0",children:"管理员"}),a.hasFullBook&&r.jsx(Ge,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"全书已购"}),a.vipRole&&r.jsx(Ge,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0",children:a.vipRole})]}),r.jsxs("p",{className:"text-[10px] text-gray-500 font-mono truncate mt-0.5",children:[a.id,a.referralCode&&r.jsxs(r.Fragment,{children:[" · ",r.jsx("code",{className:"text-[#38bdac]",children:a.referralCode})]})]}),r.jsxs("p",{className:"text-[10px] text-gray-500 leading-snug mt-1",children:[r.jsx("span",{className:"text-gray-400",children:"OpenID"})," 为微信开放平台用户唯一标识;",r.jsx("span",{className:"text-[#38bdac]/90",children:" 微信标识"})," 填微信号 / wxid存客宝归属用与 OpenID 不是同一字段。"]}),r.jsxs("div",{className:"grid grid-cols-1 xs:grid-cols-3 gap-x-2 gap-y-1 mt-1.5 text-[10px]",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("span",{className:"text-gray-500",children:"OpenID"}),r.jsx("p",{className:"text-gray-300 font-mono break-all line-clamp-2",children:a.openId||"—"})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("span",{className:"text-gray-500",children:"库内手机"}),r.jsx("p",{className:"text-gray-300",children:a.phone||"—"})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("span",{className:"text-gray-500",children:"库内微信标识"}),r.jsx("p",{className:"text-gray-300 font-mono break-all",children:a.wechatId||"—"})]})]})]})]}),r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-2 gap-1.5 shrink-0 sm:w-[220px]",children:[r.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[r.jsx("p",{className:"text-[9px] text-gray-500 uppercase tracking-wide",children:"累计佣金"}),r.jsxs("p",{className:"text-sm font-bold text-[#38bdac] leading-tight",children:["¥",(a.earnings??0).toFixed(2)]}),r.jsx("p",{className:"text-[9px] text-gray-600",children:"推广/分佣入账"})]}),r.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[r.jsx("p",{className:"text-[9px] text-gray-500",children:"待提现"}),r.jsxs("p",{className:"text-sm font-bold text-yellow-400 leading-tight",children:["¥",(a.pendingEarnings??0).toFixed(2)]}),r.jsx("p",{className:"text-[9px] text-gray-600",children:"未打款部分"})]}),r.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[r.jsxs("div",{className:"flex items-center justify-between gap-1",children:[r.jsx("p",{className:"text-[9px] text-gray-500",children:"账户余额"}),r.jsx(Y,{type:"button",size:"sm",variant:"ghost",className:"h-5 px-1 text-[9px] text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>{Q(""),xe(""),le(!0)},children:"调整"})]}),r.jsxs("p",{className:"text-sm font-bold text-white leading-tight",children:["¥",((g==null?void 0:g.balance)??0).toFixed(2)]}),r.jsx("p",{className:"text-[9px] text-gray-600",children:"可消费/抵扣"})]}),r.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[r.jsx("p",{className:"text-[9px] text-gray-500",children:"推荐人数"}),r.jsx("p",{className:"text-sm font-bold text-white leading-tight",children:a.referralCount??0}),r.jsx("p",{className:"text-[9px] text-gray-600",children:a.createdAt?`注册 ${new Date(a.createdAt).toLocaleDateString()}`:"—"})]})]})]}),r.jsxs(au,{value:P,onValueChange:O,className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[r.jsxs(Ac,{className:"bg-[#0a1628] border border-gray-700/50 p-0.5 mb-2 flex-wrap h-auto gap-0.5 shrink-0",children:[r.jsx(yn,{value:"info",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"用户信息"}),r.jsxs(yn,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:[r.jsx(Jo,{className:"w-3 h-3 mr-0.5"}),"旅程与轨迹"]}),r.jsx(yn,{value:"relations",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"关系链路"}),r.jsx(yn,{value:"tags",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"标签体系"})]}),r.jsxs(bn,{value:"info",className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-0.5",children:[r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-400 text-[11px]",children:"昵称"}),r.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"昵称",value:X,onChange:pe=>G(pe.target.value)})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-400 text-[11px]",children:"手机号(可改,点底部保存生效)"}),r.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"11 位手机号",value:U,onChange:pe=>_(pe.target.value)})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-400 text-[11px]",children:"微信标识(微信号/wxid非 OpenID"}),r.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"如 wxid_xxx 或自定义微信号",value:V,onChange:pe=>A(pe.target.value)})]})]}),(a.region||a.industry||a.position||a.mbti)&&r.jsxs("div",{className:"flex flex-wrap gap-1.5 text-[11px]",children:[a.region&&r.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:[r.jsx(Nj,{className:"w-3 h-3 inline mr-0.5"}),a.region]}),a.industry&&r.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:["行业 ",a.industry]}),a.position&&r.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:["职位 ",a.position]}),a.mbti&&r.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#38bdac]/15 text-[#38bdac]",children:["MBTI ",a.mbti]})]}),r.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-amber-500/25",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[r.jsx(kd,{className:"w-3.5 h-3.5 text-amber-400 shrink-0"}),r.jsx("span",{className:"text-white text-xs font-medium",children:"超级个体"}),a.isVip&&r.jsx(Ge,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0 shrink-0",children:a.vipRole||"VIP"})]}),r.jsx(Rt,{className:"scale-90",checked:F.isVip,onCheckedChange:pe=>re(be=>({...be,isVip:pe}))})]}),F.isVip&&r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-1.5 mt-2",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(ee,{className:"text-gray-500 text-[10px]",children:"到期日"}),r.jsx(ce,{type:"date",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",value:F.vipExpireDate,onChange:pe=>re(be=>({...be,vipExpireDate:pe.target.value}))})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(ee,{className:"text-gray-500 text-[10px]",children:"角色"}),r.jsxs("select",{className:"w-full bg-[#162840] border border-gray-700 text-white rounded px-1.5 h-7 text-xs",value:F.vipRole,onChange:pe=>re(be=>({...be,vipRole:pe.target.value})),children:[r.jsx("option",{value:"",children:"请选择"}),ge.map(pe=>r.jsx("option",{value:pe.name,children:pe.name},pe.id))]})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(ee,{className:"text-gray-500 text-[10px]",children:"展示名"}),r.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"展示名",value:F.vipName,onChange:pe=>re(be=>({...be,vipName:pe.target.value}))})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(ee,{className:"text-gray-500 text-[10px]",children:"项目"}),r.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"项目",value:F.vipProject,onChange:pe=>re(be=>({...be,vipProject:pe.target.value}))})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(ee,{className:"text-gray-500 text-[10px]",children:"联系方式"}),r.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"微信/手机",value:F.vipContact,onChange:pe=>re(be=>({...be,vipContact:pe.target.value}))})]}),r.jsxs("div",{className:"space-y-0.5 sm:col-span-2",children:[r.jsx(ee,{className:"text-gray-500 text-[10px]",children:"简介"}),r.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"简短介绍",value:F.vipBio,onChange:pe=>re(be=>({...be,vipBio:pe.target.value}))})]})]})]}),r.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-[#38bdac]/20",children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[r.jsx(ao,{className:"w-3.5 h-3.5 text-[#38bdac]"}),r.jsx("span",{className:"text-white text-xs font-medium",children:"资料完善 · 神射手 / 存客宝"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-1.5 mb-1.5",children:[r.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:手机",value:kt,onChange:pe=>Pt(pe.target.value)}),r.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:微信号",value:Ot,onChange:pe=>Mn(pe.target.value)}),r.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查OpenID",value:Dn,onChange:pe=>gs(pe.target.value)})]}),r.jsxs("div",{className:"flex flex-wrap gap-1",children:[r.jsxs(Y,{size:"sm",className:"h-7 text-[11px] px-2 bg-[#38bdac] hover:bg-[#2da396]",onClick:Bt,disabled:ye,children:[ye?r.jsx(Be,{className:"w-3 h-3 animate-spin"}):r.jsx(Sa,{className:"w-3 h-3 mr-0.5"}),"查询回填"]}),r.jsx(Y,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2 border-purple-500/40 text-purple-300",onClick:ht,disabled:zs||!a.phone,children:zs?"推送…":"推神射手"}),r.jsx(Y,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2",onClick:As,disabled:N||!a.phone,children:N?"同步…":"存客宝同步"})]}),a.ckbSyncedAt&&r.jsxs("p",{className:"text-[10px] text-gray-500 mt-1",children:["最近存客宝同步:",new Date(a.ckbSyncedAt).toLocaleString()]}),_e&&r.jsx("p",{className:"mt-1 text-red-400 text-[11px]",children:_e}),Ze&&r.jsxs("div",{className:"mt-1.5 grid grid-cols-2 gap-1.5",children:[r.jsxs("div",{className:"p-1.5 bg-[#162840] rounded text-[11px]",children:[r.jsx("span",{className:"text-gray-500",children:"RFM"})," ",r.jsx("span",{className:"text-[#38bdac] font-semibold",children:Ze.rfm_score??"—"})]}),r.jsxs("div",{className:"p-1.5 bg-[#162840] rounded text-[11px]",children:[r.jsx("span",{className:"text-gray-500",children:"等级"})," ",r.jsx("span",{className:"text-white font-semibold",children:Ze.user_level??"—"})]})]}),xs&&r.jsx("p",{className:"mt-1 text-[11px]",children:xs.error?r.jsx("span",{className:"text-red-400",children:String(xs.error)}):r.jsx("span",{className:"text-green-400",children:"推送成功"})})]}),r.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[r.jsx(vj,{className:"w-3.5 h-3.5 text-yellow-400"}),r.jsx("span",{className:"text-white text-xs font-medium",children:"修改密码"})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-1.5 sm:items-center",children:[r.jsx(ce,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"新密码 ≥6 位",value:$,onChange:pe=>D(pe.target.value)}),r.jsx(ce,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"确认密码",value:I,onChange:pe=>ie(pe.target.value)}),r.jsx(Y,{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:Qe,disabled:q||!$||!I,children:q?"保存中":"确认修改"})]})]})]}),r.jsxs(bn,{value:"journey",className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-0.5",children:[r.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg flex flex-col gap-1.5 text-[11px]",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-gray-400",children:[r.jsx(Jo,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),r.jsxs("span",{children:["全站埋点共 ",o.length," 条;用于 RFM 与「标签体系」旅程推断"]})]}),Object.keys(u).length>0&&r.jsx("div",{className:"flex flex-wrap gap-1 pt-1 border-t border-gray-700/40",children:Object.entries(u).sort((pe,be)=>be[1]-pe[1]).map(([pe,be])=>r.jsxs(Ge,{variant:"outline",className:"text-[10px] border-gray-600 text-gray-300 bg-[#162840] py-0 h-5",children:[TP(pe)," ×",be]},pe))})]}),r.jsx("div",{className:"space-y-1.5",children:o.length>0?o.map((pe,be)=>r.jsxs("div",{className:"flex items-start gap-2 p-2 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[r.jsx("div",{className:"w-7 h-7 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[#38bdac]",children:At(pe.action)}),be<o.length-1&&r.jsx("div",{className:"w-0.5 h-3 bg-gray-700/50 mt-0.5"})]}),r.jsxs("div",{className:"flex-1 pb-0.5 min-w-0 text-xs",children:[r.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[r.jsx("span",{className:"text-white font-medium",children:pe.actionLabel||pe.action}),pe.chapterTitle&&r.jsxs("span",{className:"text-gray-500",children:["· ",pe.chapterTitle]})]}),pe.target&&pe.target!==pe.chapterTitle&&r.jsxs("p",{className:"text-gray-600 text-[10px] font-mono mt-0.5 break-all",children:["target: ",pe.target]}),r.jsxs("p",{className:"text-gray-500 text-[10px] mt-0.5",children:[r.jsx(sx,{className:"w-3 h-3 inline mr-0.5"}),pe.timeAgo?`${pe.timeAgo} · `:"",pe.createdAt?new Date(pe.createdAt).toLocaleString():""]})]})]},pe.id)):r.jsxs("div",{className:"text-center py-8 text-gray-500 text-sm",children:[r.jsx(Jo,{className:"w-8 h-8 text-[#38bdac]/40 mx-auto mb-2"}),"暂无旅程记录"]})})]}),r.jsx(bn,{value:"relations",className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-0.5",children:r.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(ro,{className:"w-3.5 h-3.5 text-[#38bdac]"}),r.jsx("span",{className:"text-white text-sm font-medium",children:"推荐的用户"})]}),r.jsxs(Ge,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 text-[10px]",children:["共 ",f.length," 人"]})]}),r.jsx("div",{className:"space-y-1 max-h-[min(280px,40vh)] overflow-y-auto",children:f.length>0?f.map((pe,be)=>{var hn;const vn=pe;return r.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-[#162840] rounded text-xs",children:[r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[r.jsx("div",{className:"w-6 h-6 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[10px] text-[#38bdac] shrink-0",children:((hn=vn.nickname)==null?void 0:hn.charAt(0))||"?"}),r.jsx("span",{className:"text-white truncate",children:vn.nickname})]}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[vn.status==="vip"&&r.jsx(Ge,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"已购"}),r.jsx("span",{className:"text-gray-500 text-[10px]",children:vn.createdAt?new Date(vn.createdAt).toLocaleDateString():""})]})]},vn.id||be)}):r.jsx("p",{className:"text-gray-500 text-sm text-center py-3",children:"暂无推荐用户"})})]})}),r.jsxs(bn,{value:"tags",className:"flex-1 min-h-0 overflow-y-auto space-y-3 pr-0.5",children:[r.jsxs("div",{className:"p-2.5 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2 flex-wrap",children:[r.jsx(Sd,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx("span",{className:"text-white text-sm font-medium",children:"用户标签"}),r.jsx("span",{className:"text-gray-500 text-[11px]",children:"《一场 Soul 的创业实验》维度"})]}),r.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:[r.jsx(fj,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0 mt-0.5"}),"预设可点选;下方「旅程推断」由轨迹+资料自动算出,可一键并入已选后点弹窗底部保存。"]}),r.jsxs("div",{className:"mb-3 p-2 rounded-lg bg-[#162840]/80 border border-cyan-500/20",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-1.5",children:[r.jsx("span",{className:"text-cyan-300/90 text-xs font-medium",children:"旅程推断标签"}),r.jsx(Y,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-cyan-500/40 text-cyan-200 hover:bg-cyan-500/10",disabled:It.length===0,onClick:sn,children:"合并到已选"})]}),It.length>0?r.jsx("div",{className:"flex flex-wrap gap-1",children:It.map(pe=>r.jsxs(Ge,{variant:"outline",className:`text-[10px] py-0 h-5 border-cyan-500/30 ${z.includes(pe)?"bg-cyan-500/15 text-cyan-200":"text-gray-300"}`,children:[z.includes(pe)?"✓ ":"",pe]},pe))}):r.jsx("p",{className:"text-[11px] text-gray-500",children:"暂无推断(无轨迹或行为未命中规则)"})]}),r.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(pe=>r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-[11px] mb-1",children:pe.category}),r.jsx("div",{className:"flex flex-wrap gap-1",children:pe.tags.map(be=>r.jsxs("button",{type:"button",onClick:()=>{z.includes(be)?W(be):ne([...z,be])},className:`px-1.5 py-0.5 rounded text-[11px] border transition-all ${z.includes(be)?"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:[z.includes(be)?"✓ ":"",be]},be))})]},pe.category))}),r.jsxs("div",{className:"border-t border-gray-700/50 pt-2",children:[r.jsx("p",{className:"text-gray-500 text-[11px] mb-1.5",children:"已选标签(需保存修改写入库)"}),r.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2 min-h-[28px]",children:[z.map((pe,be)=>r.jsxs(Ge,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1 text-[11px] py-0",children:[pe,r.jsx("button",{type:"button",onClick:()=>W(pe),className:"ml-1 hover:text-red-400",children:r.jsx(us,{className:"w-3 h-3"})})]},be)),z.length===0&&r.jsx("span",{className:"text-gray-600 text-xs",children:"暂未选择"})]}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white flex-1 h-8 text-xs",placeholder:"自定义标签,回车添加",value:ue,onChange:pe=>K(pe.target.value),onKeyDown:pe=>pe.key==="Enter"&&ns()}),r.jsx(Y,{onClick:ns,className:"bg-[#38bdac] hover:bg-[#2da396] h-8 text-xs px-3",children:"添加"})]})]})]}),(()=>{const pe=a.tags||a.ckbTags||"";let be=[];try{const hn=typeof pe=="string"?JSON.parse(pe||"[]"):[];be=Array.isArray(hn)?hn:typeof pe=="string"?pe.split(","):[]}catch{be=typeof pe=="string"?pe.split(","):[]}const vn=be.map(hn=>String(hn).trim()).filter(Boolean);return vn.length===0?null:r.jsxs("div",{className:"p-2.5 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[r.jsx(Sd,{className:"w-3.5 h-3.5 text-purple-400"}),r.jsx("span",{className:"text-white text-sm font-medium",children:"存客宝标签"})]}),r.jsx("div",{className:"flex flex-wrap gap-1",children:vn.map((hn,Mr)=>r.jsx(Ge,{className:"bg-purple-500/20 text-purple-400 border-0 text-[11px] py-0",children:hn},Mr))})]})})()]})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3 shrink-0",children:[r.jsxs(Y,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(us,{className:"w-4 h-4 mr-2"}),"关闭"]}),r.jsxs(Y,{onClick:Is,disabled:E,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),E?"保存中...":"保存修改"]})]})]}):r.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}),r.jsx(Ht,{open:se,onOpenChange:le,children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[r.jsx(Ut,{children:r.jsx(Wt,{children:"调整余额"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx(ee,{className:"text-gray-300 text-sm",children:"调整金额(元)"}),r.jsx(ce,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"正数增加,负数扣减,如 10 或 -5",value:ae,onChange:pe=>Q(pe.target.value)})]}),r.jsxs("div",{children:[r.jsx(ee,{className:"text-gray-300 text-sm",children:"备注(可选)"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"如:活动补偿",value:Z,onChange:pe=>xe(pe.target.value)})]})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(Y,{variant:"outline",onClick:()=>le(!1),className:"border-gray-600 text-gray-300",children:"取消"}),r.jsx(Y,{onClick:mt,disabled:Ne,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:Ne?"提交中...":"确认调整"})]})]})})]}):null}function AP(){const t=Aa(),[e,n]=b.useState(!0),[s,a]=b.useState(!0),[i,o]=b.useState(!0),[c,u]=b.useState([]),[h,f]=b.useState([]),[m,g]=b.useState(0),[y,v]=b.useState(0),[w,N]=b.useState(0),[k,E]=b.useState(0),[C,P]=b.useState(null),[O,U]=b.useState(null),[_,V]=b.useState(!1),[A,X]=b.useState(0),[G,z]=b.useState(!1),[ne,ue]=b.useState(null),[K,$]=b.useState("overview"),[D,I]=b.useState([]),[ie,q]=b.useState(!1),[L,F]=b.useState("week"),[re,ge]=b.useState(null),[Te,se]=b.useState(!1),le=ye=>{const $e=ye;if(($e==null?void 0:$e.status)===401)P("登录已过期,请重新登录");else{if(($e==null?void 0:$e.name)==="AbortError")return;P("加载失败,请检查网络或联系管理员")}};async function ae(ye){const $e=ye?{signal:ye}:void 0;n(!0),P(null);try{const _e=await De("/api/admin/dashboard/stats",$e);_e!=null&&_e.success&&(g(_e.totalUsers??0),v(_e.paidOrderCount??0),N(_e.totalRevenue??0),E(_e.conversionRate??0))}catch(_e){if((_e==null?void 0:_e.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",_e);try{const st=await De("/api/admin/dashboard/overview",$e);st!=null&&st.success&&(g(st.totalUsers??0),v(st.paidOrderCount??0),N(st.totalRevenue??0),E(st.conversionRate??0))}catch(st){le(st)}}}finally{n(!1)}try{const _e=await De("/api/admin/balance/summary",$e);_e!=null&&_e.success&&_e.data&&X(_e.data.totalGifted??0)}catch{}try{const _e=await De("/api/db/ckb-plan-stats",$e);_e!=null&&_e.success&&_e.data?ue({ckbTotal:_e.data.ckbTotal??0,withContact:_e.data.withContact??0}):ue(null)}catch{ue(null)}a(!0),o(!0);const Ze=async()=>{try{const _e=await De("/api/admin/dashboard/recent-orders?limit=10",$e);if(_e!=null&&_e.success&&_e.recentOrders)f(_e.recentOrders);else throw new Error("no data")}catch(_e){if((_e==null?void 0:_e.name)!=="AbortError")try{const st=await De("/api/admin/orders?page=1&pageSize=20&status=paid",$e),Pt=((st==null?void 0:st.orders)??[]).filter(Ot=>["paid","completed","success"].includes(Ot.status||""));f(Pt.slice(0,5))}catch{f([])}}finally{a(!1)}},tt=async()=>{try{const _e=await De("/api/admin/dashboard/new-users",$e);if(_e!=null&&_e.success&&_e.newUsers)u(_e.newUsers);else throw new Error("no data")}catch(_e){if((_e==null?void 0:_e.name)!=="AbortError")try{const st=await De("/api/db/users?page=1&pageSize=10",$e);u((st==null?void 0:st.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([Ze(),tt()])}async function Q(ye){const $e=ye||L;se(!0);try{const Ze=await De(`/api/admin/track/stats?period=${$e}`);Ze!=null&&Ze.success&&ge({total:Ze.total??0,byModule:Ze.byModule??{}})}catch{ge(null)}finally{se(!1)}}async function Z(){q(!0);try{const ye=await De("/api/admin/super-individual/stats");ye!=null&&ye.success&&Array.isArray(ye.data)&&I(ye.data)}catch{}finally{q(!1)}}b.useEffect(()=>{const ye=new AbortController;return ae(ye.signal),Q(),Z(),()=>{ye.abort()}},[]);const xe=m,Ne=ye=>{const $e=ye.productType||"",Ze=ye.description||"";if($e==="balance_recharge")return{title:`余额充值 ¥${typeof ye.amount=="number"?ye.amount.toFixed(2):parseFloat(String(ye.amount||"0")).toFixed(2)}`,subtitle:"余额充值"};if($e==="gift_pay")return{title:`代付 ¥${typeof ye.amount=="number"?ye.amount.toFixed(2):parseFloat(String(ye.amount||"0")).toFixed(2)}`,subtitle:"好友代付"};if($e==="gift_pay_batch"){const tt=typeof ye.amount=="number"?ye.amount.toFixed(2):parseFloat(String(ye.amount||"0")).toFixed(2);return{title:Ze||`代付分享 ¥${tt}`,subtitle:"代付分享"}}if($e==="section"&&Ze.includes("代付领取"))return{title:Ze.replace("代付领取 - ",""),subtitle:"代付领取"};if(Ze){if($e==="section"&&Ze.includes("章节")){if(Ze.includes("-")){const tt=Ze.split("-");if(tt.length>=3)return{title:`第${tt[1]}章 第${tt[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:Ze,subtitle:"章节购买"}}return $e==="fullbook"||Ze.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:$e==="vip"||Ze.includes("VIP")?{title:"超级个体开通费用",subtitle:"超级个体"}:$e==="match"||Ze.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:Ze,subtitle:$e==="section"?"单章":$e==="fullbook"?"全书":"其他"}}return $e==="section"?{title:`章节 ${ye.productId||""}`,subtitle:"单章购买"}:$e==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:$e==="vip"?{title:"超级个体开通费用",subtitle:"超级个体"}:$e==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:$e||"其他"}},ct=[{title:"总用户数",value:e?null:xe,sub:null,icon:zn,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:e?null:`¥${(w??0).toFixed(2)}`,sub:A>0?`含代付 ¥${A.toFixed(2)}`:null,icon:Kh,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:y,sub:null,icon:ox,color:"text-purple-400",bg:"bg-purple-500/20",link:"/orders"},{title:"转化率",value:e?null:`${typeof k=="number"?k.toFixed(1):0}%`,sub:null,icon:Js,color:"text-orange-400",bg:"bg-orange-500/20",link:"/distribution"},{title:"存客宝获客",value:ne?ne.ckbTotal??0:null,sub:(ne==null?void 0:ne.withContact)!=null?`含联系方式 ${ne.withContact} 人`:null,icon:lc,color:"text-cyan-400",bg:"bg-cyan-500/20",link:"/users?tab=leads"}];return r.jsxs("div",{className:"p-8 w-full",children:[r.jsx("h1",{className:"text-2xl font-bold mb-8 text-white",children:"数据概览"}),C&&r.jsxs("div",{className:"mb-6 px-4 py-3 rounded-lg bg-amber-500/20 border border-amber-500/50 text-amber-200 text-sm flex items-center justify-between",children:[r.jsx("span",{children:C}),r.jsx("button",{type:"button",onClick:()=>ae(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8",children:ct.map((ye,$e)=>r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl cursor-pointer hover:border-[#38bdac]/50 transition-colors group",onClick:()=>ye.link&&t(ye.link),children:[r.jsxs(it,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsx(ot,{className:"text-sm font-medium text-gray-400",children:ye.title}),r.jsx("div",{className:`p-2 rounded-lg ${ye.bg}`,children:r.jsx(ye.icon,{className:`w-4 h-4 ${ye.color}`})})]}),r.jsx(Le,{children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-2xl font-bold text-white min-h-8 flex items-center",children:ye.value!=null?ye.value:r.jsxs("span",{className:"inline-flex items-center gap-2 text-gray-500",children:[r.jsx(Be,{className:"w-4 h-4 animate-spin"}),"加载中"]})}),ye.sub&&r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:ye.sub})]}),r.jsx(Go,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},$e))}),r.jsxs("div",{className:"flex gap-2 mb-6 mt-2",children:[r.jsx("button",{type:"button",onClick:()=>$("overview"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${K==="overview"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"数据概览"}),r.jsx("button",{type:"button",onClick:()=>$("tags"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${K==="tags"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"用户标签点击统计"}),r.jsx("button",{type:"button",onClick:()=>$("super"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${K==="super"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"超级个体统计"})]}),K==="overview"&&r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{className:"flex flex-row items-center justify-between",children:[r.jsx(ot,{className:"text-white",children:"最近订单"}),r.jsxs("button",{type:"button",onClick:()=>ae(),disabled:s||i,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新",children:[s||i?r.jsx(Be,{className:"w-3.5 h-3.5 animate-spin"}):r.jsx(Be,{className:"w-3.5 h-3.5"}),"刷新"]})]}),r.jsx(Le,{children:r.jsx("div",{className:"space-y-3",children:s&&h.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[r.jsx(Be,{className:"w-8 h-8 animate-spin mb-2"}),r.jsx("span",{className:"text-sm",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[h.slice(0,G?10:4).map(ye=>{var st;const $e=ye.referrerId?c.find(kt=>kt.id===ye.referrerId):void 0,Ze=ye.referralCode||($e==null?void 0:$e.referralCode)||($e==null?void 0:$e.nickname)||(ye.referrerId?String(ye.referrerId).slice(0,8):""),tt=Ne(ye),_e=ye.userNickname||((st=c.find(kt=>kt.id===ye.userId))==null?void 0:st.nickname)||"匿名用户";return r.jsxs("div",{className:"flex items-start justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30 hover:border-[#38bdac]/30 transition-colors",children:[r.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[ye.userAvatar?r.jsx("img",{src:ye.userAvatar,alt:_e,className:"w-9 h-9 rounded-full object-cover flex-shrink-0 mt-0.5",onError:kt=>{kt.currentTarget.style.display="none";const Pt=kt.currentTarget.nextElementSibling;Pt&&Pt.classList.remove("hidden")}}):null,r.jsx("div",{className:`w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 mt-0.5 ${ye.userAvatar?"hidden":""}`,children:_e.charAt(0)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("button",{type:"button",onClick:()=>{ye.userId&&(U(ye.userId),V(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:_e}),r.jsx("span",{className:"text-gray-600",children:"·"}),r.jsx("span",{className:"text-sm font-medium text-white truncate",title:tt.title,children:tt.title})]}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[tt.subtitle&&tt.subtitle!=="章节购买"&&r.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:tt.subtitle}),r.jsx("span",{children:new Date(ye.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),Ze&&r.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",Ze]})]})]}),r.jsxs("div",{className:"text-right ml-4 flex-shrink-0",children:[r.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(ye.amount).toFixed(2)]}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:ye.paymentMethod||"微信"})]})]},ye.id)}),h.length>4&&!G&&r.jsx("button",{type:"button",onClick:()=>z(!0),className:"w-full py-2 text-sm text-[#38bdac] hover:text-[#2da396] border border-dashed border-gray-600 rounded-lg hover:border-[#38bdac]/50 transition-colors",children:"展开更多"}),h.length===0&&!s&&r.jsxs("div",{className:"text-center py-12",children:[r.jsx(ox,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),r.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsx(it,{children:r.jsx(ot,{className:"text-white",children:"新注册用户"})}),r.jsx(Le,{children:r.jsx("div",{className:"space-y-3",children:i&&c.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[r.jsx(Be,{className:"w-8 h-8 animate-spin mb-2"}),r.jsx("span",{className:"text-sm",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[c.slice(0,5).map(ye=>{var $e;return r.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:(($e=ye.nickname)==null?void 0:$e.charAt(0))||"?"}),r.jsxs("div",{children:[r.jsx("button",{type:"button",onClick:()=>{U(ye.id),V(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:ye.nickname||"匿名用户"}),r.jsx("p",{className:"text-xs text-gray-500",children:ye.phone||"未绑定手机"})]})]}),r.jsx("p",{className:"text-xs text-gray-400",children:ye.createdAt?new Date(ye.createdAt).toLocaleDateString():"-"})]},ye.id)}),c.length===0&&!i&&r.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})})]})]}),K==="tags"&&r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{className:"flex flex-row items-center justify-between",children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(gd,{className:"w-5 h-5 text-[#38bdac]"}),"分类标签点击统计"]}),r.jsx("div",{className:"flex items-center gap-2",children:["today","week","month","all"].map(ye=>r.jsx("button",{type:"button",onClick:()=>{F(ye),Q(ye)},className:`px-3 py-1 text-xs rounded-full transition-colors ${L===ye?"bg-[#38bdac] text-white":"bg-gray-700/50 text-gray-400 hover:bg-gray-700"}`,children:{today:"今日",week:"本周",month:"本月",all:"全部"}[ye]},ye))})]}),r.jsx(Le,{children:Te&&!re?r.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[r.jsx(Be,{className:"w-6 h-6 animate-spin mr-2"}),r.jsx("span",{children:"加载中..."})]}):re&&Object.keys(re.byModule).length>0?r.jsxs("div",{className:"space-y-6",children:[r.jsxs("p",{className:"text-sm text-gray-400",children:["总点击 ",r.jsx("span",{className:"text-white font-bold text-lg",children:re.total})," 次"]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Object.entries(re.byModule).sort((ye,$e)=>$e[1].reduce((Ze,tt)=>Ze+tt.count,0)-ye[1].reduce((Ze,tt)=>Ze+tt.count,0)).slice(0,5).map(([ye,$e])=>{const Ze=$e.reduce((_e,st)=>_e+st.count,0),tt={home:"首页",chapters:"目录",read:"阅读",my:"我的",vip:"VIP",wallet:"钱包",match:"找伙伴",referral:"推广",search:"搜索",settings:"设置",about:"关于",other:"其他"};return r.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("span",{className:"text-sm font-medium text-[#38bdac]",children:tt[ye]||ye}),r.jsxs("span",{className:"text-xs text-gray-500",children:[Ze," 次"]})]}),r.jsx("div",{className:"space-y-2",children:$e.sort((_e,st)=>st.count-_e.count).slice(0,8).map((_e,st)=>{const kt={开始匹配:"开始匹配",mentor:"导师顾问",team:"团队招募",investor:"资源对接",充值:"充值",退款:"退款",wallet:"钱包",设置:"设置",VIP:"VIP会员",推广:"推广中心",目录:"目录",搜索:"搜索",匹配:"找伙伴",settings:"设置",expired:"已过期",active:"活跃",converted:"已转化",fill_profile:"完善资料",register:"注册",purchase:"购买",btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",rule_trigger:"规则触发",view_chapter:"浏览章节",链接卡若:"链接卡若",更多分享:"更多分享",分享朋友圈文案:"分享朋友圈",选择金额10:"选择金额10元"},Pt={btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",purchase:"购买",register:"注册",rule_trigger:"规则触发",view_chapter:"浏览章节"},Ot=kt[_e.target]||_e.target||Pt[_e.action]||_e.action;return r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-gray-300 truncate mr-2",title:`${_e.action}: ${_e.target}`,children:Ot}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsx("div",{className:"w-16 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-[#38bdac] rounded-full",style:{width:`${Ze>0?_e.count/Ze*100:0}%`}})}),r.jsx("span",{className:"text-gray-400 w-8 text-right",children:_e.count})]})]},st)})})]},ye)})})]}):r.jsxs("div",{className:"text-center py-12",children:[r.jsx(gd,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),r.jsx("p",{className:"text-gray-500",children:"暂无点击数据"}),r.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"小程序端接入埋点后,数据将在此实时展示"})]})})]}),K==="super"&&r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{className:"flex flex-row items-center justify-between",children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(gd,{className:"w-5 h-5 text-amber-400"}),"超级个体点击统计"]}),r.jsxs(Y,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300 h-8",onClick:Z,disabled:ie,children:[r.jsx(Be,{className:`w-3.5 h-3.5 mr-1 ${ie?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Le,{children:ie&&D.length===0?r.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[r.jsx(Be,{className:"w-6 h-6 animate-spin mr-2"}),r.jsx("span",{children:"加载中..."})]}):D.length>0?r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"text-xs text-gray-400 border-b border-gray-700/50",children:[r.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"排名"}),r.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"超级个体"}),r.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"总点击"}),r.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"独立访客"}),r.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"人均点击"}),r.jsx("th",{className:"text-center py-2 px-3 font-normal",title:"该用户绑定 @人物 后,指向其 person 的留资独立人数",children:"获客(去重)"}),r.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"手机号"})]})}),r.jsx("tbody",{children:D.map((ye,$e)=>r.jsxs("tr",{className:"border-b border-gray-700/30 hover:bg-[#0a1628]/80",children:[r.jsx("td",{className:"py-2 px-3 text-gray-500 text-xs",children:$e+1}),r.jsx("td",{className:"py-2 px-3",children:r.jsxs("div",{className:"flex items-center gap-2",children:[ye.avatar?r.jsx("img",{src:ye.avatar,alt:"",className:"w-7 h-7 rounded-full object-cover"}):r.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-700 flex items-center justify-center text-xs text-gray-400",children:"?"}),r.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(ye.nickname||ye.userId)}`),title:"点击跳转用户管理",children:ye.nickname||ye.userId})]})}),r.jsx("td",{className:"py-2 px-3 text-center text-white font-bold",children:ye.clicks}),r.jsx("td",{className:"py-2 px-3 text-center text-[#38bdac]",children:ye.uniqueClicks}),r.jsx("td",{className:"py-2 px-3 text-center text-gray-400",children:ye.uniqueClicks>0?(ye.clicks/ye.uniqueClicks).toFixed(1):"-"}),r.jsx("td",{className:"py-2 px-3 text-center text-green-400 text-xs font-medium",children:typeof ye.leadCount=="number"?ye.leadCount:0}),r.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs",children:ye.phone||"-"})]},ye.userId))})]})}):r.jsxs("div",{className:"text-center py-12",children:[r.jsx(gd,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),r.jsx("p",{className:"text-gray-500",children:"暂无超级个体点击数据"}),r.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"小程序首页的超级个体被用户点击后,数据将展示在此"})]})})]}),r.jsx(T0,{open:_,onClose:()=>{V(!1),U(null)},userId:O,onUserUpdated:()=>ae()})]})}const hs=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{className:"relative w-full overflow-auto",children:r.jsx("table",{ref:n,className:Ft("w-full caption-bottom text-sm",t),...e})}));hs.displayName="Table";const fs=b.forwardRef(({className:t,...e},n)=>r.jsx("thead",{ref:n,className:Ft("[&_tr]:border-b",t),...e}));fs.displayName="TableHeader";const ps=b.forwardRef(({className:t,...e},n)=>r.jsx("tbody",{ref:n,className:Ft("[&_tr:last-child]:border-0",t),...e}));ps.displayName="TableBody";const pt=b.forwardRef(({className:t,...e},n)=>r.jsx("tr",{ref:n,className:Ft("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));pt.displayName="TableRow";const je=b.forwardRef(({className:t,...e},n)=>r.jsx("th",{ref:n,className:Ft("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));je.displayName="TableHead";const ve=b.forwardRef(({className:t,...e},n)=>r.jsx("td",{ref:n,className:Ft("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));ve.displayName="TableCell";function Xh(t,e){const[n,s]=b.useState(t);return b.useEffect(()=>{const a=setTimeout(()=>s(t),e);return()=>clearTimeout(a)},[t,e]),n}function Gs({page:t,totalPages:e,total:n,pageSize:s,onPageChange:a,onPageSizeChange:i,pageSizeOptions:o=[10,20,50,100]}){return e<=1&&!i?null:r.jsxs("div",{className:"flex items-center justify-between gap-4 py-4 px-5 border-t border-gray-700/50",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[r.jsxs("span",{children:["共 ",n," 条"]}),i&&r.jsx("select",{value:s,onChange:c=>i(Number(c.target.value)),className:"bg-[#0f2137] border border-gray-600 rounded px-2 py-1 text-gray-300 text-sm",children:o.map(c=>r.jsxs("option",{value:c,children:[c," 条/页"]},c))})]}),e>1&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{type:"button",onClick:()=>a(1),disabled:t<=1,className:"px-2 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"首页"}),r.jsx("button",{type:"button",onClick:()=>a(t-1),disabled:t<=1,className:"px-3 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"上一页"}),r.jsxs("span",{className:"px-3 py-1 text-gray-400 text-sm",children:[t," / ",e]}),r.jsx("button",{type:"button",onClick:()=>a(t+1),disabled:t>=e,className:"px-3 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"下一页"}),r.jsx("button",{type:"button",onClick:()=>a(e),disabled:t>=e,className:"px-2 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"末页"})]})]})}function IP(){const[t,e]=b.useState([]),[n,s]=b.useState([]),[a,i]=b.useState(0),[o,c]=b.useState(0),[u,h]=b.useState(0),[f,m]=b.useState(1),[g,y]=b.useState(10),[v,w]=b.useState(""),N=Xh(v,300),[k,E]=b.useState("all"),[C,P]=b.useState(!0),[O,U]=b.useState(null),[_,V]=b.useState(null),[A,X]=b.useState(""),[G,z]=b.useState(!1);async function ne(){P(!0),U(null);try{const q=k==="all"?"":k==="completed"?"completed":k,L=new URLSearchParams({page:String(f),pageSize:String(g),...q&&{status:q},...N&&{search:N}}),[F,re]=await Promise.all([De(`/api/admin/orders?${L}`),De("/api/db/users?page=1&pageSize=500")]);F!=null&&F.success&&(e(F.orders||[]),i(F.total??0),c(F.totalRevenue??0),h(F.todayRevenue??0)),re!=null&&re.success&&re.users&&s(re.users)}catch(q){console.error("加载订单失败",q),U("加载订单失败,请检查网络后重试")}finally{P(!1)}}b.useEffect(()=>{m(1)},[N,k]),b.useEffect(()=>{ne()},[f,g,N,k]);const ue=q=>{var L;return q.userNickname||((L=n.find(F=>F.id===q.userId))==null?void 0:L.nickname)||"匿名用户"},K=q=>{var L;return((L=n.find(F=>F.id===q))==null?void 0:L.phone)||"-"},$=q=>{const L=q.productType||q.type||"",F=q.description||"";if(L==="balance_recharge")return{name:`余额充值 ¥${Number(q.amount||0).toFixed(2)}`,type:"余额充值"};if(F){if(L==="section"&&(F.includes("章节")||F.includes("代付领取"))){if(F.includes("代付领取"))return{name:F.replace("代付领取 - ",""),type:"代付领取"};if(F.includes("-")){const re=F.split("-");if(re.length>=3)return{name:`第${re[1]}章 第${re[2]}节`,type:"《一场Soul的创业实验》"}}return{name:F,type:"章节购买"}}return L==="fullbook"||F.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:L==="vip"||F.includes("VIP")?{name:"超级个体开通费用",type:"超级个体"}:L==="match"||F.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:F,type:"其他"}}return L==="section"?{name:`章节 ${q.productId||q.sectionId||""}`,type:"单章"}:L==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:L==="vip"?{name:"超级个体开通费用",type:"超级个体"}:L==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:L||"其他"}},D=Math.ceil(a/g)||1;async function I(){var q;if(!(!(_!=null&&_.orderSn)&&!(_!=null&&_.id))){z(!0),U(null);try{const L=await Jt("/api/admin/orders/refund",{orderSn:_.orderSn||_.id,reason:A||void 0});L!=null&&L.success?(V(null),X(""),ne()):U((L==null?void 0:L.error)||"退款失败")}catch(L){const F=L;U(((q=F==null?void 0:F.data)==null?void 0:q.error)||"退款失败,请检查网络后重试")}finally{z(!1)}}}function ie(){if(t.length===0){oe.info("暂无数据可导出");return}const q=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],L=t.map(se=>{const le=$(se);return[se.orderSn||se.id||"",ue(se),K(se.userId),le.name,Number(se.amount||0).toFixed(2),se.paymentMethod==="wechat"?"微信支付":se.paymentMethod==="balance"?"余额支付":se.paymentMethod==="alipay"?"支付宝":se.paymentMethod||"微信支付",se.status==="refunded"?"已退款":se.status==="paid"||se.status==="completed"?"已完成":se.status==="pending"||se.status==="created"?"待支付":"已失败",se.status==="refunded"&&se.refundReason?se.refundReason:"-",se.referrerEarnings?Number(se.referrerEarnings).toFixed(2):"-",se.createdAt?new Date(se.createdAt).toLocaleString("zh-CN"):""].join(",")}),F="\uFEFF"+[q.join(","),...L].join(`
`),re=new Blob([F],{type:"text/csv;charset=utf-8"}),ge=URL.createObjectURL(re),Te=document.createElement("a");Te.href=ge,Te.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,Te.click(),URL.revokeObjectURL(ge)}return r.jsxs("div",{className:"p-8 w-full",children:[O&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:O}),r.jsx("button",{type:"button",onClick:()=>U(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"订单管理"}),r.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",t.length," 笔订单"]})]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs(Y,{variant:"outline",onClick:ne,disabled:C,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${C?"animate-spin":""}`}),"刷新"]}),r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"text-gray-400",children:"总收入:"}),r.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",o.toFixed(2)]}),r.jsx("span",{className:"text-gray-600",children:"|"}),r.jsx("span",{className:"text-gray-400",children:"今日:"}),r.jsxs("span",{className:"text-[#FFD700] font-bold",children:["¥",u.toFixed(2)]})]})]})]}),r.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[r.jsxs("div",{className:"relative flex-1 max-w-md",children:[r.jsx(Sa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),r.jsx(ce,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:v,onChange:q=>w(q.target.value)})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(yj,{className:"w-4 h-4 text-gray-400"}),r.jsxs("select",{value:k,onChange:q=>E(q.target.value),className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"completed",children:"已完成"}),r.jsx("option",{value:"pending",children:"待支付"}),r.jsx("option",{value:"created",children:"已创建"}),r.jsx("option",{value:"failed",children:"已失败"}),r.jsx("option",{value:"refunded",children:"已退款"})]})]}),r.jsxs(Y,{variant:"outline",onClick:ie,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(v5,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Le,{className:"p-0",children:C?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Be,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs("div",{children:[r.jsxs(hs,{children:[r.jsx(fs,{children:r.jsxs(pt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(je,{className:"text-gray-400",children:"订单号"}),r.jsx(je,{className:"text-gray-400",children:"用户"}),r.jsx(je,{className:"text-gray-400",children:"商品"}),r.jsx(je,{className:"text-gray-400",children:"金额"}),r.jsx(je,{className:"text-gray-400",children:"支付方式"}),r.jsx(je,{className:"text-gray-400",children:"状态"}),r.jsx(je,{className:"text-gray-400",children:"退款原因"}),r.jsx(je,{className:"text-gray-400",children:"分销佣金"}),r.jsx(je,{className:"text-gray-400",children:"下单时间"}),r.jsx(je,{className:"text-gray-400",children:"操作"})]})}),r.jsxs(ps,{children:[t.map(q=>{const L=$(q);return r.jsxs(pt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsxs(ve,{className:"font-mono text-xs text-gray-400",children:[(q.orderSn||q.id||"").slice(0,12),"..."]}),r.jsx(ve,{children:r.jsxs("div",{children:[r.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[ue(q),q.paymentMethod==="gift_pay"&&r.jsx(Ge,{className:"bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 border-0 text-xs",children:"代付领取"}),q.payerUserId&&q.paymentMethod!=="gift_pay"&&r.jsx(Ge,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"代付"})]}),r.jsx("p",{className:"text-gray-500 text-xs",children:K(q.userId)}),q.payerUserId&&q.payerNickname&&r.jsxs("p",{className:"text-amber-400/80 text-xs mt-0.5",children:[q.paymentMethod==="gift_pay"?"赠送人:":"代付人:",q.payerNickname]})]})}),r.jsx(ve,{children:r.jsxs("div",{children:[r.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[L.name,(q.productType||q.type)==="vip"&&r.jsx(Ge,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"超级个体"})]}),r.jsx("p",{className:"text-gray-500 text-xs",children:L.type})]})}),r.jsxs(ve,{className:"text-[#38bdac] font-bold",children:["¥",Number(q.amount||0).toFixed(2)]}),r.jsx(ve,{className:"text-gray-300",children:q.paymentMethod==="wechat"?"微信支付":q.paymentMethod==="balance"?"余额支付":q.paymentMethod==="alipay"?"支付宝":q.paymentMethod||"微信支付"}),r.jsx(ve,{children:q.status==="refunded"?r.jsx(Ge,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):q.status==="paid"||q.status==="completed"?r.jsx(Ge,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):q.status==="pending"||q.status==="created"?r.jsx(Ge,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):r.jsx(Ge,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"})}),r.jsx(ve,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:q.refundReason,children:q.status==="refunded"&&q.refundReason?q.refundReason:"-"}),r.jsx(ve,{className:"text-[#FFD700]",children:q.referrerEarnings?`¥${Number(q.referrerEarnings).toFixed(2)}`:"-"}),r.jsx(ve,{className:"text-gray-400 text-sm",children:new Date(q.createdAt).toLocaleString("zh-CN")}),r.jsx(ve,{children:(q.status==="paid"||q.status==="completed")&&q.paymentMethod!=="balance"&&r.jsxs(Y,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{V(q),X("")},children:[r.jsx(wj,{className:"w-3 h-3 mr-1"}),"退款"]})})]},q.id)}),t.length===0&&r.jsx(pt,{children:r.jsx(ve,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),r.jsx(Gs,{page:f,totalPages:D,total:a,pageSize:g,onPageChange:m,onPageSizeChange:q=>{y(q),m(1)}})]})})}),r.jsx(Ht,{open:!!_,onOpenChange:q=>!q&&V(null),children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Ut,{children:r.jsx(Wt,{className:"text-white",children:"订单退款"})}),_&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",_.orderSn||_.id]}),r.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(_.amount||0).toFixed(2)]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),r.jsx("div",{className:"form-input",children:r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:A,onChange:q=>X(q.target.value)})})]}),r.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),r.jsxs(xn,{children:[r.jsx(Y,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>V(null),disabled:G,children:"取消"}),r.jsx(Y,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:I,disabled:G,children:G?"退款中...":"确认退款"})]})]})})]})}const cl=b.forwardRef(({className:t,...e},n)=>r.jsx("textarea",{className:Ft("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}));cl.displayName="Textarea";const RP=[{level:"S",range:"≥85",label:"高价值"},{level:"A",range:"7084",label:"优质"},{level:"B",range:"5069",label:"中等"},{level:"C",range:"3049",label:"潜力"},{level:"D",range:"<30",label:"待激活"}],Xl=[{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 PP(){var $r,gr,ha,Cl,To,fa,Ba;const[t,e]=f0(),n=t.get("pool"),s=t.get("tab")||"users",[a,i]=b.useState([]),[o,c]=b.useState(0),[u,h]=b.useState(1),[f,m]=b.useState(10),[g,y]=b.useState(""),v=Xh(g,300),w=n==="vip"?"vip":n==="complete"?"complete":"all",[N,k]=b.useState(w),[E,C]=b.useState(!0),[P,O]=b.useState(!1),[U,_]=b.useState(null),[V,A]=b.useState(!1),[X,G]=b.useState(!1),[z,ne]=b.useState("desc");b.useEffect(()=>{n==="vip"?k("vip"):n==="complete"?k("complete"):n==="all"&&k("all")},[n]);const[ue,K]=b.useState(!1),[$,D]=b.useState(null),[I,ie]=b.useState(!1),[q,L]=b.useState(!1),[F,re]=b.useState({referrals:[],stats:{}}),[ge,Te]=b.useState(!1),[se,le]=b.useState(null),[ae,Q]=b.useState(!1),[Z,xe]=b.useState(null),[Ne,ct]=b.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[ye,$e]=b.useState([]),[Ze,tt]=b.useState(!1),[_e,st]=b.useState(!1),[kt,Pt]=b.useState(null),[Ot,Mn]=b.useState({title:"",description:"",trigger:"",sort:0,enabled:!0}),[Dn,gs]=b.useState([]),[zs,ts]=b.useState(!1),[xs,Gt]=b.useState(null),[ln,As]=b.useState(null),[Is,ns]=b.useState({}),[W,Qe]=b.useState(!1),[mt,Bt]=b.useState(null),[gt,ht]=b.useState([]),[At,It]=b.useState(!1),[sn,Wn]=b.useState(null),[pe,be]=b.useState(""),[vn,hn]=b.useState([]),[Mr,Pa]=b.useState(!1),[Ar,Oa]=b.useState([]),[Ir,No]=b.useState(0),[pr,Rr]=b.useState(1),[Pr]=b.useState(20),[mr,Or]=b.useState(!1),[mi,ea]=b.useState(null),[St,ss]=b.useState(""),Lr=Xh(St,300),[La,jl]=b.useState(""),[$s,wo]=b.useState({}),Qs=b.useCallback(async(R,Pe)=>{Or(!0),ea(null);try{const Re=new URLSearchParams({mode:"contact",page:String(pr),pageSize:String(Pr)}),qe=R??Lr;qe&&Re.set("search",qe);const Nt=Pe??La;Nt&&Re.set("source",Nt);const wt=await De(`/api/db/ckb-leads?${Re}`);if(wt!=null&&wt.success)Oa(wt.records||[]),No(wt.total??0),wt.stats&&wo(wt.stats);else{const pn=(wt==null?void 0:wt.error)||"加载获客列表失败";ea(pn),oe.error(pn),Oa([]),No(0)}}catch(Re){const qe=Re instanceof Error?Re.message:"网络错误";ea(qe),oe.error("加载获客列表失败: "+qe),Oa([]),No(0)}finally{Or(!1)}},[pr,Pr,Lr,La]);b.useEffect(()=>{t.get("tab")==="leads"&&Qs()},[t.get("tab"),pr,Qs]);const[Xs,ta]=b.useState(null),Vt=b.useCallback(async()=>{try{const R=await De("/api/admin/users/online-stats");R!=null&&R.success&&typeof R.onlineCount=="number"?ta(R.onlineCount):ta(0)}catch{ta(null)}},[]);b.useEffect(()=>{Vt();const R=setInterval(Vt,1e4);return()=>clearInterval(R)},[Vt]);async function na(R=!1){var Pe;C(!0),R&&O(!0),_(null);try{if(V){const Re=new URLSearchParams({search:v,limit:String(f*5)}),qe=await De(`/api/db/users/rfm?${Re}`);if(qe!=null&&qe.success){let Nt=qe.users||[];z==="asc"&&(Nt=[...Nt].reverse());const wt=(u-1)*f;i(Nt.slice(wt,wt+f)),c(((Pe=qe.users)==null?void 0:Pe.length)??0),Nt.length===0&&(A(!1),_("暂无订单数据RFM 排序需要用户有购买记录后才能生效"))}else A(!1),_((qe==null?void 0:qe.error)||"RFM 加载失败,已切回普通模式")}else{const Re=new URLSearchParams({page:String(u),pageSize:String(f),search:v,...N==="vip"&&{vip:"true"},...N==="complete"&&{pool:"complete"}}),qe=await De(`/api/db/users?${Re}`);qe!=null&&qe.success?(i(qe.users||[]),c(qe.total??0)):_((qe==null?void 0:qe.error)||"加载失败")}}catch(Re){console.error("Load users error:",Re),_("网络错误")}finally{C(!1),R&&O(!1)}}b.useEffect(()=>{h(1)},[v,N,V]),b.useEffect(()=>{na()},[u,f,v,N,V,z]);const jo=Math.ceil(o/f)||1,gi=()=>{V?z==="desc"?ne("asc"):(A(!1),ne("desc")):(A(!0),ne("desc"))},sa=R=>({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"})[R||""]||"bg-gray-500/20 text-gray-400";async function Dc(R){var Pe;if(confirm("确定要删除这个用户吗?"))try{const Re=await ai(`/api/db/users?id=${encodeURIComponent(R)}`);Re!=null&&Re.success?(oe.success("已删除"),na()):oe.error("删除失败: "+((Re==null?void 0:Re.error)||"未知错误"))}catch(Re){const qe=Re,Nt=((Pe=qe==null?void 0:qe.data)==null?void 0:Pe.error)||(qe==null?void 0:qe.message)||"网络错误";oe.error("删除失败: "+Nt)}}const xi=R=>{D(R),ct({phone:R.phone||"",nickname:R.nickname||"",password:"",isAdmin:!!(R.isAdmin??!1),hasFullBook:!!(R.hasFullBook??!1)}),K(!0)},yi=()=>{D(null),ct({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),K(!0)};async function Rs(){if(!Ne.phone||!Ne.nickname){oe.error("请填写手机号和昵称");return}ie(!0);try{if($){const R=await Jt("/api/db/users",{id:$.id,phone:Ne.phone||void 0,nickname:Ne.nickname,isAdmin:Ne.isAdmin,hasFullBook:Ne.hasFullBook,...Ne.password&&{password:Ne.password}});if(!(R!=null&&R.success)){oe.error("更新失败: "+((R==null?void 0:R.error)||""));return}}else{const R=await Et("/api/db/users",{phone:Ne.phone,nickname:Ne.nickname,password:Ne.password,isAdmin:Ne.isAdmin});if(!(R!=null&&R.success)){oe.error("创建失败: "+((R==null?void 0:R.error)||""));return}}K(!1),na()}catch{oe.error("保存失败")}finally{ie(!1)}}async function kl(R){le(R),L(!0),Te(!0);try{const Pe=await De(`/api/db/users/referrals?userId=${encodeURIComponent(R.id)}`);Pe!=null&&Pe.success?re({referrals:Pe.referrals||[],stats:Pe.stats||{}}):re({referrals:[],stats:{}})}catch{re({referrals:[],stats:{}})}finally{Te(!1)}}const fn=b.useCallback(async()=>{tt(!0);try{const R=await De("/api/db/user-rules");R!=null&&R.success&&$e(R.rules||[])}catch{}finally{tt(!1)}},[]);async function _c(){if(!Ot.title){oe.error("请填写规则标题");return}ie(!0);try{if(kt){const R=await Jt("/api/db/user-rules",{id:kt.id,...Ot});if(!(R!=null&&R.success)){oe.error("更新失败: "+((R==null?void 0:R.error)||""));return}}else{const R=await Et("/api/db/user-rules",Ot);if(!(R!=null&&R.success)){oe.error("创建失败: "+((R==null?void 0:R.error)||""));return}}st(!1),fn()}catch{oe.error("保存失败")}finally{ie(!1)}}async function ra(R){if(confirm("确定删除?"))try{const Pe=await ai(`/api/db/user-rules?id=${R}`);Pe!=null&&Pe.success&&fn()}catch{}}async function zc(R){try{await Jt("/api/db/user-rules",{id:R.id,enabled:!R.enabled}),fn()}catch{}}const Fs=b.useCallback(async()=>{ts(!0);try{const R=await De("/api/db/vip-members?limit=500");if(R!=null&&R.success&&R.data){const Pe=[...R.data].map((Re,qe)=>({...Re,vipSort:typeof Re.vipSort=="number"?Re.vipSort:qe+1}));Pe.sort((Re,qe)=>(Re.vipSort??999999)-(qe.vipSort??999999)),gs(Pe)}else R&&R.error&&oe.error(R.error)}catch{oe.error("加载超级个体列表失败")}finally{ts(!1)}},[]),[Da,Zs]=b.useState(!1),[er,ko]=b.useState(null),[Dr,aa]=b.useState(""),[bi,vi]=b.useState(!1),An=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],Sl=R=>{ko(R),aa(R.vipRole||""),Zs(!0)},ia=async R=>{const Pe=R.trim();if(er){if(!Pe){oe.error("请选择或输入标签");return}vi(!0);try{const Re=await Jt("/api/db/users",{id:er.id,vipRole:Pe});if(!(Re!=null&&Re.success)){oe.error((Re==null?void 0:Re.error)||"更新超级个体标签失败");return}oe.success("已更新超级个体标签"),Zs(!1),ko(null),await Fs()}catch{oe.error("更新超级个体标签失败")}finally{vi(!1)}}},[Ct,oa]=b.useState(!1),[Nn,tr]=b.useState(null),[So,Co]=b.useState(""),[Eo,_a]=b.useState(!1),Ni=R=>{tr(R),Co(R.vipSort!=null?String(R.vipSort):""),oa(!0)},nr=async()=>{if(!Nn)return;const R=Number(So);if(!Number.isFinite(R)){oe.error("请输入有效的数字序号");return}_a(!0);try{const Pe=await Jt("/api/db/users",{id:Nn.id,vipSort:R});if(!(Pe!=null&&Pe.success)){oe.error((Pe==null?void 0:Pe.error)||"更新排序序号失败");return}oe.success("已更新排序序号"),oa(!1),tr(null),await Fs()}catch{oe.error("更新排序序号失败")}finally{_a(!1)}},Kn=(R,Pe)=>{R.dataTransfer.effectAllowed="move",R.dataTransfer.setData("text/plain",Pe),Gt(Pe)},qn=(R,Pe)=>{R.preventDefault(),ln!==Pe&&As(Pe)},la=()=>{Gt(null),As(null)},ca=async(R,Pe)=>{R.preventDefault();const Re=R.dataTransfer.getData("text/plain")||xs;if(Gt(null),As(null),!Re||Re===Pe)return;const qe=Dn.find(dt=>dt.id===Re),Nt=Dn.find(dt=>dt.id===Pe);if(!qe||!Nt)return;const wt=qe.vipSort??Dn.findIndex(dt=>dt.id===Re)+1,pn=Nt.vipSort??Dn.findIndex(dt=>dt.id===Pe)+1;gs(dt=>{const qt=[...dt],cn=qt.findIndex(ma=>ma.id===Re),ys=qt.findIndex(ma=>ma.id===Pe);if(cn===-1||ys===-1)return dt;const Fr=[...qt],[pa,Mo]=[Fr[cn],Fr[ys]];return Fr[cn]={...Mo,vipSort:wt},Fr[ys]={...pa,vipSort:pn},Fr});try{const[dt,qt]=await Promise.all([Jt("/api/db/users",{id:Re,vipSort:pn}),Jt("/api/db/users",{id:Pe,vipSort:wt})]);if(!(dt!=null&&dt.success)||!(qt!=null&&qt.success)){oe.error((dt==null?void 0:dt.error)||(qt==null?void 0:qt.error)||"更新排序失败"),await Fs();return}oe.success("已更新排序"),await Fs()}catch{oe.error("更新排序失败"),await Fs()}},rs=b.useCallback(async()=>{Qe(!0);try{const R=await De("/api/db/users/journey-stats");R!=null&&R.success&&R.stats&&ns(R.stats)}catch{}finally{Qe(!1)}},[]),za=b.useCallback(async R=>{Bt(R),It(!0);try{const Pe=await De(`/api/db/users/journey-users?stage=${R}&limit=50`);Pe!=null&&Pe.success&&Pe.users&&ht(Pe.users)}catch{}finally{It(!1)}},[]),$a=b.useCallback(async(R,Pe)=>{Wn(R),be(Pe),Pa(!0);try{const Re=await De(`/api/db/users/tracks?userId=${R}&limit=50`);Re!=null&&Re.success&&Re.tracks&&hn(Re.tracks)}catch{}finally{Pa(!1)}},[]),[da,ua]=b.useState(!1),_r=async()=>{ua(!0);try{const R=await Et("/api/admin/shensheshou/batch-enrich",{limit:20});R!=null&&R.success?(oe.success(`批量补全完成:${R.enriched} 人已补全,${R.skipped} 人跳过`),na()):oe.error((R==null?void 0:R.error)||"批量补全失败")}catch{oe.error("批量补全请求失败")}finally{ua(!1)}},Fa=R=>{const Pe=[R.phone,R.nickname,R.avatar,R.wechatId,R.mbti,R.industry,R.region,R.position],Re=Pe.filter(qe=>qe!=null&&qe!=="").length;return Math.round(Re/Pe.length*100)},{leadsRows:sr,leadsRawCount:$c,leadsDeduped:zr}=b.useMemo(()=>{const R=dt=>(dt||"").replace(/\D/g,"")||"",Pe=dt=>{const qt=R(dt.phone);if(qt)return`phone:${qt}`;const cn=(dt.userId||"").trim();if(cn)return`user:${cn}`;const ys=(dt.wechatId||"").trim();return ys?`wechat:${ys}`:`row:${dt.id}`},Re=Lr.trim().toLowerCase();let qe=Ar;Re&&(qe=Ar.filter(dt=>[dt.userNickname,dt.name,dt.phone,dt.wechatId,dt.personName,dt.source,String(dt.ckbPlanId??"")].filter(Boolean).join(" ").toLowerCase().includes(Re)));const Nt=[...qe].sort((dt,qt)=>{const cn=dt.createdAt?new Date(dt.createdAt).getTime():0;return(qt.createdAt?new Date(qt.createdAt).getTime():0)-cn}),wt=new Set,pn=[];for(const dt of Nt){const qt=Pe(dt);wt.has(qt)||(wt.add(qt),pn.push(dt))}return{leadsRows:pn,leadsRawCount:qe.length,leadsDeduped:qe.length-pn.length}},[Ar,Lr]);return r.jsxs("div",{className:"p-8 w-full",children:[U&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:U}),r.jsx("button",{type:"button",onClick:()=>_(null),children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-start gap-6 mb-6 flex-wrap",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"用户管理"}),r.jsxs("p",{className:"text-gray-400 mt-1 text-sm",children:["共 ",o," 位注册用户",Xs!==null&&r.jsxs("span",{className:"text-[#38bdac] ml-1",children:["· 在线 ",Xs," 人"]}),V&&" · RFM 排序中"]})]}),r.jsx(Oe,{className:"shrink-0 w-full max-w-md border-[#38bdac]/35 bg-[#0f2137]/90",children:r.jsxs(Le,{className:"p-3 sm:p-4 space-y-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>G(R=>!R),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":X,children:[r.jsx(Kh,{className:"w-5 h-5 text-[#38bdac] shrink-0"}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-semibold text-white",children:"算法配置"}),r.jsx("div",{className:"text-xs text-gray-500 truncate",children:X?"RFM · Are you good用户价值分层":"RFM · 点击展开说明"})]}),X?r.jsx(nx,{className:"w-4 h-4 text-gray-400 shrink-0"}):r.jsx(pc,{className:"w-4 h-4 text-gray-400 shrink-0"})]}),r.jsx(Y,{type:"button",variant:"outline",size:"sm",onClick:gi,className:"border-[#38bdac]/50 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent shrink-0",children:V?z==="desc"?"RFM 降序":"RFM 升序":"按 RFM 排序"})]}),X&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"text-xs text-gray-400 leading-relaxed",children:["综合分 0100六维度最近消费 R25%+ 订单频次 F20%+ 累计金额 M20%+ 推荐人数15%+ 行为轨迹10%+ 资料完善10%)。各维度在全量用户中归一化,与后端"," ",r.jsx("code",{className:"text-gray-500",children:"/api/db/users/rfm"})," 一致。"]}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:RP.map(({level:R,range:Pe,label:Re})=>r.jsxs(Ge,{variant:"outline",className:`text-[10px] border-0 ${sa(R)}`,children:[R," ",Pe," · ",Re]},R))})]})]})})]}),r.jsxs(au,{value:s,onValueChange:R=>{const Pe=new URLSearchParams(t);R==="users"?Pe.delete("tab"):Pe.set("tab",R),e(Pe)},className:"w-full",children:[r.jsxs(Ac,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[r.jsxs(yn,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[r.jsx(zn,{className:"w-4 h-4"})," 用户列表"]}),r.jsxs(yn,{value:"leads",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:()=>Qs(),children:[r.jsx(lc,{className:"w-4 h-4"})," 获客列表"]}),r.jsxs(yn,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:rs,children:[r.jsx(Jo,{className:"w-4 h-4"})," 用户旅程总览"]}),r.jsxs(yn,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:fn,children:[r.jsx(el,{className:"w-4 h-4"})," 规则配置"]}),r.jsxs(yn,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Fs,children:[r.jsx(kd,{className:"w-4 h-4"})," 超级个体列表"]})]}),r.jsxs(bn,{value:"users",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[r.jsxs(Y,{variant:"outline",onClick:_r,disabled:da,className:"border-purple-500/50 text-purple-400 hover:bg-purple-500/10 bg-transparent",title:"批量调用神射手补全有手机号用户的资料",children:[da?r.jsx(Be,{className:"w-4 h-4 mr-2 animate-spin"}):r.jsx(ao,{className:"w-4 h-4 mr-2"}),"批量补全"]}),r.jsxs(Y,{variant:"outline",onClick:()=>na(!0),disabled:P,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${P?"animate-spin":""}`})," 刷新"]}),r.jsxs("select",{value:N,onChange:R=>{const Pe=R.target.value;k(Pe),h(1),n&&(t.delete("pool"),e(t))},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",disabled:V,children:[r.jsx("option",{value:"all",children:"全部用户"}),r.jsx("option",{value:"vip",children:"VIP会员超级个体"}),r.jsx("option",{value:"complete",children:"完善资料用户"})]}),r.jsxs("div",{className:"relative",children:[r.jsx(Sa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),r.jsx(ce,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:g,onChange:R=>y(R.target.value)})]}),r.jsxs(Y,{onClick:yi,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(lc,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Le,{className:"p-0",children:E?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Be,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs("div",{children:[r.jsxs(hs,{children:[r.jsx(fs,{children:r.jsxs(pt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(je,{className:"text-gray-400",children:"用户信息"}),r.jsx(je,{className:"text-gray-400",children:"绑定信息"}),r.jsx(je,{className:"text-gray-400",children:"购买状态"}),r.jsx(je,{className:"text-gray-400",children:"分销收益"}),r.jsxs(je,{className:"text-gray-400 cursor-pointer select-none",onClick:gi,children:[r.jsxs("div",{className:"flex items-center gap-1 group",children:[r.jsx(Kh,{className:"w-3.5 h-3.5"}),r.jsx("span",{children:"RFM分值"}),V?z==="desc"?r.jsx(pc,{className:"w-3.5 h-3.5 text-[#38bdac]"}):r.jsx(nx,{className:"w-3.5 h-3.5 text-[#38bdac]"}):r.jsx(tg,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),V&&r.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),r.jsx(je,{className:"text-gray-400",children:"资料完善"}),r.jsx(je,{className:"text-gray-400",children:"注册时间"}),r.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsxs(ps,{children:[a.map(R=>{var Pe,Re,qe;return r.jsxs(pt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] overflow-hidden",children:R.avatar?r.jsx("img",{src:R.avatar,className:"w-full h-full rounded-full object-cover",alt:"",onError:Nt=>{var pn;Nt.target.style.display="none";const wt=Nt.target.parentElement;wt&&(wt.textContent=((pn=R.nickname)==null?void 0:pn.charAt(0))||"?")}}):((Pe=R.nickname)==null?void 0:Pe.charAt(0))||"?"}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("button",{type:"button",onClick:()=>{xe(R.id),Q(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:R.nickname}),R.isAdmin&&r.jsx(Ge,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),R.openId&&!((Re=R.id)!=null&&Re.startsWith("user_"))&&r.jsx(Ge,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),r.jsx("p",{className:"text-xs text-gray-500 font-mono",children:R.openId?R.openId.slice(0,12)+"...":(qe=R.id)==null?void 0:qe.slice(0,12)})]})]})}),r.jsx(ve,{children:r.jsxs("div",{className:"space-y-1",children:[R.phone&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"📱"}),r.jsx("span",{className:"text-gray-300",children:R.phone})]}),R.wechatId&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"💬"}),r.jsx("span",{className:"text-gray-300",children:R.wechatId})]}),R.openId&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"🔗"}),r.jsxs("span",{className:"text-gray-500 truncate max-w-[100px]",title:R.openId,children:[R.openId.slice(0,12),"..."]})]}),!R.phone&&!R.wechatId&&!R.openId&&r.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),r.jsx(ve,{children:R.hasFullBook?r.jsx(Ge,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:"VIP"}):r.jsx(Ge,{variant:"outline",className:"text-gray-500 border-gray-600",children:"未购买"})}),r.jsx(ve,{children:r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(R.earnings||0)).toFixed(2)]}),parseFloat(String(R.pendingEarnings||0))>0&&r.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(R.pendingEarnings||0)).toFixed(2)]}),r.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>kl(R),role:"button",tabIndex:0,onKeyDown:Nt=>Nt.key==="Enter"&&kl(R),children:[r.jsx(zn,{className:"w-3 h-3"})," 绑定",R.referralCount||0,"人"]})]})}),r.jsx(ve,{children:R.rfmScore!==void 0?r.jsx("div",{className:"flex flex-col gap-1",children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-white font-bold text-base",children:R.rfmScore}),r.jsx(Ge,{className:`border-0 text-xs ${sa(R.rfmLevel)}`,children:R.rfmLevel})]})}):r.jsxs("span",{className:"text-gray-600 text-sm",children:["— ",r.jsx("span",{className:"text-xs text-gray-700",children:"点列头排序"})]})}),r.jsx(ve,{children:(()=>{const Nt=Fa(R),wt=Nt>=75?"text-green-400":Nt>=50?"text-yellow-400":"text-gray-500";return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-12 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full ${Nt>=75?"bg-green-500":Nt>=50?"bg-yellow-500":"bg-gray-500"}`,style:{width:`${Nt}%`}})}),r.jsxs("span",{className:`text-xs ${wt}`,children:[Nt,"%"]})]})})()}),r.jsx(ve,{className:"text-gray-400",children:R.createdAt?new Date(R.createdAt).toLocaleDateString():"-"}),r.jsx(ve,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>{xe(R.id),Q(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:r.jsx(Wh,{className:"w-4 h-4"})}),r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>xi(R),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:r.jsx(en,{className:"w-4 h-4"})}),r.jsx(Y,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>Dc(R.id),title:"删除",children:r.jsx(ks,{className:"w-4 h-4"})})]})})]},R.id)}),a.length===0&&r.jsx(pt,{children:r.jsx(ve,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),r.jsx(Gs,{page:u,totalPages:jo,total:o,pageSize:f,onPageChange:h,onPageSizeChange:R=>{m(R),h(1)}})]})})})]}),r.jsxs(bn,{value:"leads",children:[mi&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:mi}),r.jsx("button",{type:"button",className:"shrink-0 ml-2",onClick:()=>ea(null),"aria-label":"关闭",children:"×"})]}),!mr&&r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-4",children:[r.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs",children:"总留资条数"}),r.jsx("p",{className:"text-xl font-bold text-white",children:Ir})]}),r.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs",children:"去重用户数(按 userId"}),r.jsx("p",{className:"text-xl font-bold text-[#38bdac]",title:"后端 COUNT(DISTINCT user_id)",children:$s.uniqueUsers??0})]}),($s.sourceStats&&$s.sourceStats.length>0?$s.sourceStats.slice(0,2):[]).map(R=>r.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[r.jsxs("p",{className:"text-gray-500 text-xs",children:["来源:",R.source]}),r.jsx("p",{className:"text-xl font-bold text-purple-400",children:R.cnt})]},R.source))]}),r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-4",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2 flex-1 min-w-[200px]",children:[r.jsxs("div",{className:"relative flex-1 max-w-xs",children:[r.jsx(Sa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),r.jsx(ce,{placeholder:"搜索昵称/手机/微信/@人/来源…",value:St,onChange:R=>ss(R.target.value),className:"pl-9 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"})]}),$s.sourceStats&&$s.sourceStats.length>0&&r.jsxs("select",{value:La,onChange:R=>{jl(R.target.value),Rr(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[r.jsx("option",{value:"",children:"全部来源"}),$s.sourceStats.map(R=>r.jsxs("option",{value:R.source,children:[R.source,"",R.cnt,""]},R.source))]}),r.jsxs("span",{className:"text-xs text-gray-500 whitespace-nowrap max-w-[min(100%,20rem)]",title:"同一页内:相同手机号或相同用户 ID含微信侧标识只保留最近一条",children:["本页 ",$c," 条",zr>0?` · 已合并 ${zr} 条重复`:""]})]}),r.jsxs(Y,{variant:"outline",onClick:()=>Qs(),disabled:mr,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${mr?"animate-spin":""}`})," 刷新"]})]}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Le,{className:"p-0",children:mr?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Be,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs("div",{children:[r.jsxs(hs,{children:[r.jsx(fs,{children:r.jsxs(pt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(je,{className:"text-gray-400",children:"昵称"}),r.jsx(je,{className:"text-gray-400",children:"手机号"}),r.jsx(je,{className:"text-gray-400",children:"微信号"}),r.jsx(je,{className:"text-gray-400",children:"对应 @人"}),r.jsx(je,{className:"text-gray-400",children:"获客计划"}),r.jsx(je,{className:"text-gray-400",children:"来源"}),r.jsx(je,{className:"text-gray-400",children:"时间"})]})}),r.jsxs(ps,{children:[sr.map(R=>r.jsxs(pt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:R.userNickname||R.name||"-"}),r.jsx(ve,{className:"text-gray-300",children:R.phone||"-"}),r.jsx(ve,{className:"text-gray-300",children:R.wechatId||"-"}),r.jsx(ve,{className:"text-[#38bdac]",children:R.personName||"-"}),r.jsx(ve,{className:"text-gray-400",children:R.ckbPlanId?`#${R.ckbPlanId}`:"-"}),r.jsx(ve,{children:r.jsx(Ge,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:R.source||"未知"})}),r.jsx(ve,{className:"text-gray-400",children:R.createdAt?new Date(R.createdAt).toLocaleString():"-"})]},R.id)),sr.length===0&&r.jsx(pt,{children:r.jsx(ve,{colSpan:7,className:"p-0 align-top",children:r.jsxs("div",{className:"py-16 px-6 text-center border-t border-gray-700/40 bg-[#0a1628]/30",children:[r.jsx(lc,{className:"w-14 h-14 text-[#38bdac]/20 mx-auto mb-4","aria-hidden":!0}),r.jsx("p",{className:"text-gray-200 font-medium mb-1",children:"暂无获客线索"}),r.jsx("p",{className:"text-gray-500 text-sm mb-6 max-w-md mx-auto leading-relaxed",children:Lr.trim()||La?"当前搜索或来源筛选下没有匹配记录,可清空条件后重试。":"存客宝场景产生的手机号 / 微信留资会出现在此列表。请确认获客计划已开启,并有用户完成留资。"}),r.jsxs(Y,{type:"button",variant:"outline",onClick:()=>Qs(),disabled:mr,className:"border-[#38bdac]/40 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${mr?"animate-spin":""}`}),"重新加载"]})]})})})]})]}),r.jsx(Gs,{page:pr,totalPages:Math.ceil(Ir/Pr)||1,total:Ir,pageSize:Pr,onPageChange:Rr,onPageSizeChange:()=>{}})]})})})]}),r.jsxs(bn,{value:"journey",children:[r.jsxs("div",{className:"flex items-center justify-between mb-5",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"用户从注册到 VIP 的完整行动路径,点击各阶段查看用户动态"}),r.jsxs(Y,{variant:"outline",onClick:rs,disabled:W,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${W?"animate-spin":""}`})," 刷新数据"]})]}),r.jsxs("div",{className:"relative mb-8",children:[r.jsx("div",{className:"absolute top-16 left-0 right-0 h-0.5 bg-gradient-to-r from-blue-500/20 via-[#38bdac]/30 to-amber-500/20 mx-20"}),r.jsx("div",{className:"grid grid-cols-4 gap-4 lg:grid-cols-8",children:Xl.map((R,Pe)=>r.jsxs("div",{className:"relative flex flex-col items-center",children:[r.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${R.color} text-center cursor-pointer hover:opacity-80 transition-opacity ${mt===R.id?"ring-2 ring-[#38bdac]":""}`,onClick:()=>za(R.id),title:`点击查看「${R.label}」阶段的用户`,children:[r.jsx("div",{className:"text-2xl mb-1",children:R.icon}),r.jsx("div",{className:`text-xs font-medium ${R.color.split(" ").find(Re=>Re.startsWith("text-"))}`,children:R.label}),Is[R.id]!==void 0&&r.jsxs("div",{className:"mt-1.5 text-xs text-gray-400",children:[r.jsx("span",{className:"font-bold text-white",children:Is[R.id]})," 人"]}),r.jsx("div",{className:"absolute -top-2.5 -left-2.5 w-5 h-5 rounded-full bg-[#0a1628] border border-gray-700 flex items-center justify-center text-[10px] text-gray-500",children:Pe+1})]}),Pe<Xl.length-1&&r.jsx("div",{className:"hidden lg:block absolute right-0 top-1/2 -translate-y-1/2 translate-x-1/2 z-10",children:r.jsx("svg",{width:"20",height:"12",viewBox:"0 0 20 12",fill:"none",children:r.jsx("path",{d:"M0 6H16M16 6L11 1M16 6L11 11",stroke:"#374151",strokeWidth:"1.5",strokeLinecap:"round"})})}),r.jsx("p",{className:"text-[10px] text-gray-600 text-center mt-2 leading-tight",children:R.desc})]},R.id))})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Jo,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx("span",{className:"text-white font-medium",children:"旅程关键节点"})]}),r.jsx("div",{className:"space-y-2 text-sm",children:[{step:"① 注册",action:"微信 OAuth 或手机号注册",next:"提示设置头像与昵称"},{step:"② 浏览",action:"点击章节/阅读免费内容",next:"触发绑定手机"},{step:"③ 首付",action:"购买单章或全书",next:"推送分销功能"},{step:"④ VIP",action:"¥1980 购买全书",next:"进入 VIP 私域群"},{step:"⑤ 分销",action:"推广好友购买",next:"提现分销收益"}].map(R=>r.jsxs("div",{className:"flex items-start gap-3 p-2 bg-[#0a1628] rounded",children:[r.jsx("span",{className:"text-[#38bdac] font-mono text-xs shrink-0 mt-0.5",children:R.step}),r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-300",children:R.action}),r.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",R.next]})]})]},R.step))})]}),r.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Js,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"行为锚点统计"}),r.jsx("span",{className:"text-gray-500 text-xs ml-auto",children:"实时更新"})]}),W?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Be,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(Is).length>0?r.jsx("div",{className:"space-y-2",children:Xl.map(R=>{const Pe=Is[R.id]||0,Re=Math.max(...Xl.map(Nt=>Is[Nt.id]||0),1),qe=Math.round(Pe/Re*100);return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"text-gray-500 text-xs w-20 shrink-0",children:[R.icon," ",R.label]}),r.jsx("div",{className:"flex-1 h-2 bg-[#0a1628] rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-[#38bdac]/60 rounded-full transition-all",style:{width:`${qe}%`}})}),r.jsx("span",{className:"text-gray-400 text-xs w-10 text-right",children:Pe})]},R.id)})}):r.jsx("div",{className:"text-center py-8",children:r.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]}),mt&&r.jsxs("div",{className:"mt-6 bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(zn,{className:"w-4 h-4 text-[#38bdac]"}),r.jsxs("span",{className:"text-white font-medium",children:[($r=Xl.find(R=>R.id===mt))==null?void 0:$r.icon," ",(gr=Xl.find(R=>R.id===mt))==null?void 0:gr.label," 阶段用户"]}),r.jsxs(Ge,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:[gt.length," 人"]})]}),r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>Bt(null),className:"text-gray-400 hover:text-white",children:r.jsx(us,{className:"w-4 h-4"})})]}),At?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Be,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):gt.length===0?r.jsx("p",{className:"text-gray-500 text-center py-6",children:"该阶段暂无用户"}):r.jsxs(hs,{children:[r.jsx(fs,{children:r.jsxs(pt,{className:"border-gray-700",children:[r.jsx(je,{className:"text-gray-400",children:"昵称"}),r.jsx(je,{className:"text-gray-400",children:"手机号"}),r.jsx(je,{className:"text-gray-400",children:"注册时间"}),r.jsx(je,{className:"text-gray-400 text-right",children:"操作"})]})}),r.jsx(ps,{children:gt.map(R=>r.jsxs(pt,{className:"border-gray-700/50 hover:bg-[#0a1628]",children:[r.jsx(ve,{className:"text-white",children:R.nickname||"微信用户"}),r.jsx(ve,{className:"text-gray-300",children:R.phone||"-"}),r.jsx(ve,{className:"text-gray-400 text-xs",children:R.createdAt?new Date(R.createdAt).toLocaleString("zh-CN"):"-"}),r.jsx(ve,{className:"text-right",children:r.jsxs(Y,{variant:"ghost",size:"sm",className:"text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>$a(R.id,R.nickname||"微信用户"),children:[r.jsx(Wh,{className:"w-4 h-4 mr-1"})," 行为轨迹"]})})]},R.id))})]})]}),r.jsx(Ht,{open:!!sn,onOpenChange:R=>{R||Wn(null)},children:r.jsxs(_t,{className:"sm:max-w-[600px] bg-[#0f2137] border-gray-700 text-white max-h-[80vh] overflow-y-auto",children:[r.jsx(Ut,{children:r.jsxs(Wt,{className:"text-white flex items-center gap-2",children:[r.jsx(Jo,{className:"w-5 h-5 text-[#38bdac]"}),pe," 的行为轨迹"]})}),Mr?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx(Be,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):vn.length===0?r.jsx("p",{className:"text-gray-500 text-center py-8",children:"该用户暂无行为记录"}):r.jsxs("div",{className:"relative pl-6 space-y-0",children:[r.jsx("div",{className:"absolute left-[11px] top-2 bottom-2 w-0.5 bg-gray-700"}),vn.map((R,Pe)=>r.jsxs("div",{className:"relative flex items-start gap-3 py-2",children:[r.jsx("div",{className:"absolute left-[-13px] top-3 w-2.5 h-2.5 rounded-full bg-[#38bdac] border-2 border-[#0f2137] z-10"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:"text-white text-sm font-medium",children:R.actionLabel}),R.module&&r.jsx(Ge,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[10px]",children:R.module})]}),(R.chapterTitle||R.target)&&r.jsx("p",{className:"text-gray-400 text-xs mt-0.5 truncate",children:R.chapterTitle||R.target}),r.jsxs("p",{className:"text-gray-600 text-[10px] mt-0.5",children:[R.timeAgo," · ",R.createdAt?new Date(R.createdAt).toLocaleString("zh-CN"):""]})]})]},R.id||Pe))]})]})})]}),r.jsxs(bn,{value:"rules",children:[r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"用户旅程触达规则:各行为节点的触发条件与展示文案(偏利他说明,少用命令式)"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(Y,{variant:"outline",onClick:fn,disabled:Ze,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${Ze?"animate-spin":""}`})," 刷新"]}),r.jsxs(Y,{onClick:()=>{Pt(null),Mn({title:"",description:"",trigger:"",sort:0,enabled:!0}),st(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Pn,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),Ze?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx(Be,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):ye.length===0?r.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[r.jsx(Js,{className:"w-12 h-12 text-[#38bdac]/30 mx-auto mb-4"}),r.jsx("p",{className:"text-gray-400 mb-4",children:"暂无规则重启服务将自动写入10条默认规则"}),r.jsxs(Y,{onClick:fn,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Be,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):r.jsx("div",{className:"space-y-2",children:ye.map(R=>r.jsxs("div",{className:`p-3 rounded-lg border transition-all ${R.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[r.jsxs("span",{className:"text-gray-600 text-xs font-mono w-5 shrink-0 text-right",children:["#",R.sort]}),r.jsx(en,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),r.jsx("span",{className:"text-white font-medium text-sm truncate",children:R.title}),R.trigger&&r.jsx(Ge,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-[10px] shrink-0",children:R.trigger})]}),r.jsxs("div",{className:"flex items-center gap-1.5 ml-3 shrink-0",children:[r.jsx(Rt,{checked:R.enabled,onCheckedChange:()=>zc(R)}),r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>{Pt(R),Mn({title:R.title,description:R.description,trigger:R.trigger,sort:R.sort,enabled:R.enabled}),st(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10 h-7 w-7 p-0",children:r.jsx(en,{className:"w-3.5 h-3.5"})}),r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>ra(R.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 h-7 w-7 p-0",children:r.jsx(ks,{className:"w-3.5 h-3.5"})})]})]}),R.description&&r.jsxs("details",{className:"ml-[52px] mt-1",children:[r.jsx("summary",{className:"text-gray-500 text-xs cursor-pointer hover:text-gray-400 select-none",children:"查看描述"}),r.jsx("p",{className:"text-gray-400 text-sm mt-1 pl-1 border-l-2 border-gray-700",children:R.description})]})]},R.id))})]}),r.jsxs(bn,{value:"vip-roles",children:[r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"展示当前所有有效的超级个体VIP 用户),用于检查会员信息与排序值。"}),r.jsx("p",{className:"text-xs text-[#38bdac]",children:"提示:按住任意一行即可拖拽排序,释放后将同步更新小程序展示顺序。"})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs(Y,{variant:"outline",onClick:Fs,disabled:zs,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${zs?"animate-spin":""}`})," ","刷新"]})})]}),zs?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Be,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):Dn.length===0?r.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[r.jsx(kd,{className:"w-12 h-12 text-amber-400/30 mx-auto mb-4"}),r.jsx("p",{className:"text-gray-400 mb-4",children:"当前没有有效的超级个体用户。"})]}):r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Le,{className:"p-0",children:r.jsxs(hs,{children:[r.jsx(fs,{children:r.jsxs(pt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(je,{className:"text-gray-400 w-12",children:"序号"}),r.jsx(je,{className:"text-gray-400",children:"成员"}),r.jsx(je,{className:"text-gray-400 min-w-40",children:"超级个体标签"}),r.jsx(je,{className:"text-gray-400 w-16 text-center",children:"点击数"}),r.jsx(je,{className:"text-gray-400 w-16 text-center",children:"获客数"}),r.jsx(je,{className:"text-gray-400 w-20",children:"排序值"}),r.jsx(je,{className:"text-gray-400 w-36 text-right",children:"操作"})]})}),r.jsx(ps,{children:Dn.map((R,Pe)=>{var Nt;const Re=xs===R.id,qe=ln===R.id;return r.jsxs(pt,{draggable:!0,onDragStart:wt=>Kn(wt,R.id),onDragOver:wt=>qn(wt,R.id),onDrop:wt=>ca(wt,R.id),onDragEnd:la,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${Re?"opacity-60":""} ${qe?"bg-[#38bdac]/10":""}`,children:[r.jsx(ve,{className:"text-gray-300",children:Pe+1}),r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[R.avatar?r.jsx("img",{src:R.avatar,className:"w-8 h-8 rounded-full object-cover border border-amber-400/60",alt:"",onError:wt=>{var dt,qt;wt.target.style.display="none";const pn=document.createElement("div");pn.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",pn.textContent=((dt=R.name)==null?void 0:dt[0])||"创",(qt=wt.target.parentElement)==null||qt.appendChild(pn)}}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",children:((Nt=R.name)==null?void 0:Nt[0])||"创"}),r.jsx("div",{className:"min-w-0",children:r.jsx("div",{className:"text-white text-sm truncate",children:R.name})})]})}),r.jsx(ve,{className:"text-gray-300 whitespace-nowrap",children:R.vipRole||r.jsx("span",{className:"text-gray-500",children:"(未设置)"})}),r.jsx(ve,{className:"text-center text-blue-400 text-xs font-mono",children:R.clickCount!=null?String(R.clickCount):"-"}),r.jsx(ve,{className:"text-center text-green-400 text-xs font-mono",children:R.leadCount!=null?String(R.leadCount):"-"}),r.jsx(ve,{className:"text-gray-300",children:R.vipSort??Pe+1}),r.jsx(ve,{className:"text-right text-xs text-gray-300",children:r.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[r.jsx(Y,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>Sl(R),title:"设置超级个体标签",children:r.jsx(Sd,{className:"w-3.5 h-3.5"})}),r.jsx(Y,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-[#38bdac] hover:text-[#5fe0cd]",onClick:()=>{xe(R.id),Q(!0)},title:"编辑资料",children:r.jsx(en,{className:"w-3.5 h-3.5"})}),r.jsx(Y,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>Ni(R),title:"设置排序序号",children:r.jsx(tg,{className:"w-3.5 h-3.5"})})]})})]},R.id)})})]})})})]})]}),r.jsx(Ht,{open:Ct,onOpenChange:R=>{oa(R),R||tr(null)},children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[r.jsx(Ut,{children:r.jsxs(Wt,{className:"text-white flex items-center gap-2",children:[r.jsx(tg,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",Nn==null?void 0:Nn.name]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsx(ee,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),r.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如1",value:So,onChange:R=>Co(R.target.value)})]}),r.jsxs(xn,{children:[r.jsxs(Y,{variant:"outline",onClick:()=>oa(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(us,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(Y,{onClick:nr,disabled:Eo,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),Eo?"保存中...":"保存"]})]})]})}),r.jsx(Ht,{open:Da,onOpenChange:R=>{Zs(R),R||ko(null)},children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Ut,{children:r.jsxs(Wt,{className:"text-white flex items-center gap-2",children:[r.jsx(kd,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",er==null?void 0:er.name]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsx(ee,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:An.map(R=>r.jsx(Y,{variant:Dr===R?"default":"outline",size:"sm",className:Dr===R?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>aa(R),children:R},R))}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"或手动输入"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:Dr,onChange:R=>aa(R.target.value)})]})]}),r.jsxs(xn,{children:[r.jsxs(Y,{variant:"outline",onClick:()=>Zs(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(us,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(Y,{onClick:()=>ia(Dr),disabled:bi,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),bi?"保存中...":"保存"]})]})]})}),r.jsx(Ht,{open:ue,onOpenChange:K,children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[r.jsx(Ut,{children:r.jsxs(Wt,{className:"text-white flex items-center gap-2",children:[$?r.jsx(en,{className:"w-5 h-5 text-[#38bdac]"}):r.jsx(lc,{className:"w-5 h-5 text-[#38bdac]"}),$?"编辑用户":"添加用户"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"手机号"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:Ne.phone,onChange:R=>ct({...Ne,phone:R.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"昵称"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:Ne.nickname,onChange:R=>ct({...Ne,nickname:R.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:$?"新密码 (留空则不修改)":"密码"}),r.jsx(ce,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:$?"留空则不修改":"请输入密码",value:Ne.password,onChange:R=>ct({...Ne,password:R.target.value})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(ee,{className:"text-gray-300",children:"管理员权限"}),r.jsx(Rt,{checked:Ne.isAdmin,onCheckedChange:R=>ct({...Ne,isAdmin:R})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(ee,{className:"text-gray-300",children:"已购全书"}),r.jsx(Rt,{checked:Ne.hasFullBook,onCheckedChange:R=>ct({...Ne,hasFullBook:R})})]})]}),r.jsxs(xn,{children:[r.jsxs(Y,{variant:"outline",onClick:()=>K(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(us,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(Y,{onClick:Rs,disabled:I,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),I?"保存中...":"保存"]})]})]})}),r.jsx(Ht,{open:_e,onOpenChange:st,children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[r.jsx(Ut,{children:r.jsxs(Wt,{className:"text-white flex items-center gap-2",children:[r.jsx(en,{className:"w-5 h-5 text-[#38bdac]"}),kt?"编辑规则":"添加规则"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"规则标题 *"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例匹配后填写头像、付款1980需填写信息",value:Ot.title,onChange:R=>Mn({...Ot,title:R.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"规则描述"}),r.jsx(cl,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[80px] resize-none",placeholder:"详细说明规则内容...",value:Ot.description,onChange:R=>Mn({...Ot,description:R.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"触发条件"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:完成匹配、付款后、注册时",value:Ot.trigger,onChange:R=>Mn({...Ot,trigger:R.target.value})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{children:r.jsx(ee,{className:"text-gray-300",children:"启用状态"})}),r.jsx(Rt,{checked:Ot.enabled,onCheckedChange:R=>Mn({...Ot,enabled:R})})]})]}),r.jsxs(xn,{children:[r.jsxs(Y,{variant:"outline",onClick:()=>st(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(us,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(Y,{onClick:_c,disabled:I,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),I?"保存中...":"保存"]})]})]})}),r.jsx(Ht,{open:q,onOpenChange:L,children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[r.jsx(Ut,{children:r.jsxs(Wt,{className:"text-white flex items-center gap-2",children:[r.jsx(zn,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",se==null?void 0:se.nickname]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold text-[#38bdac]",children:((ha=F.stats)==null?void 0:ha.total)||0}),r.jsx("div",{className:"text-xs text-gray-400",children:"绑定总数"})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold text-green-400",children:((Cl=F.stats)==null?void 0:Cl.purchased)||0}),r.jsx("div",{className:"text-xs text-gray-400",children:"已付费"})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsxs("div",{className:"text-2xl font-bold text-yellow-400",children:["¥",(((To=F.stats)==null?void 0:To.earnings)||0).toFixed(2)]}),r.jsx("div",{className:"text-xs text-gray-400",children:"累计收益"})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsxs("div",{className:"text-2xl font-bold text-orange-400",children:["¥",(((fa=F.stats)==null?void 0:fa.pendingEarnings)||0).toFixed(2)]}),r.jsx("div",{className:"text-xs text-gray-400",children:"待提现"})]})]}),ge?r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(Be,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((Ba=F.referrals)==null?void 0:Ba.length)??0)>0?r.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(F.referrals??[]).map((R,Pe)=>{var qe;const Re=R;return r.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:((qe=Re.nickname)==null?void 0:qe.charAt(0))||"?"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white text-sm",children:Re.nickname}),r.jsx("div",{className:"text-xs text-gray-500",children:Re.phone||(Re.hasOpenId?"微信用户":"未绑定")})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[Re.status==="vip"&&r.jsx(Ge,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),Re.status==="paid"&&r.jsxs(Ge,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",Re.purchasedSections,"章"]}),Re.status==="free"&&r.jsx(Ge,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),r.jsx("span",{className:"text-xs text-gray-500",children:Re.createdAt?new Date(Re.createdAt).toLocaleDateString():""})]})]},Re.id||Pe)})}):r.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),r.jsx(xn,{children:r.jsx(Y,{variant:"outline",onClick:()=>L(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),r.jsx(T0,{open:ae,onClose:()=>Q(!1),userId:Z,onUserUpdated:na})]})}function Zh(t,[e,n]){return Math.min(n,Math.max(e,t))}var Hk=["PageUp","PageDown"],Uk=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Wk={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Ic="Slider",[fx,OP,LP]=k0(Ic),[Kk]=mo(Ic,[LP]),[DP,rp]=Kk(Ic),qk=b.forwardRef((t,e)=>{const{name:n,min:s=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:u=0,defaultValue:h=[s],value:f,onValueChange:m=()=>{},onValueCommit:g=()=>{},inverted:y=!1,form:v,...w}=t,N=b.useRef(new Set),k=b.useRef(0),C=o==="horizontal"?_P:zP,[P=[],O]=ol({prop:f,defaultProp:h,onChange:G=>{var ne;(ne=[...N.current][k.current])==null||ne.focus(),m(G)}}),U=b.useRef(P);function _(G){const z=HP(P,G);X(G,z)}function V(G){X(G,k.current)}function A(){const G=U.current[k.current];P[k.current]!==G&&g(P)}function X(G,z,{commit:ne}={commit:!1}){const ue=qP(i),K=GP(Math.round((G-s)/i)*i+s,ue),$=Zh(K,[s,a]);O((D=[])=>{const I=BP(D,$,z);if(KP(I,u*i)){k.current=I.indexOf($);const ie=String(I)!==String(D);return ie&&ne&&g(I),ie?I:D}else return D})}return r.jsx(DP,{scope:t.__scopeSlider,name:n,disabled:c,min:s,max:a,valueIndexToChangeRef:k,thumbs:N.current,values:P,orientation:o,form:v,children:r.jsx(fx.Provider,{scope:t.__scopeSlider,children:r.jsx(fx.Slot,{scope:t.__scopeSlider,children:r.jsx(C,{"aria-disabled":c,"data-disabled":c?"":void 0,...w,ref:e,onPointerDown:xt(w.onPointerDown,()=>{c||(U.current=P)}),min:s,max:a,inverted:y,onSlideStart:c?void 0:_,onSlideMove:c?void 0:V,onSlideEnd:c?void 0:A,onHomeKeyDown:()=>!c&&X(s,0,{commit:!0}),onEndKeyDown:()=>!c&&X(a,P.length-1,{commit:!0}),onStepKeyDown:({event:G,direction:z})=>{if(!c){const K=Hk.includes(G.key)||G.shiftKey&&Uk.includes(G.key)?10:1,$=k.current,D=P[$],I=i*K*z;X(D+I,$,{commit:!0})}}})})})})});qk.displayName=Ic;var[Gk,Jk]=Kk(Ic,{startEdge:"left",endEdge:"right",size:"width",direction:1}),_P=b.forwardRef((t,e)=>{const{min:n,max:s,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,g]=b.useState(null),y=$t(e,C=>g(C)),v=b.useRef(void 0),w=tp(a),N=w==="ltr",k=N&&!i||!N&&i;function E(C){const P=v.current||m.getBoundingClientRect(),O=[0,P.width],_=M0(O,k?[n,s]:[s,n]);return v.current=P,_(C-P.left)}return r.jsx(Gk,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:r.jsx(Yk,{dir:w,"data-orientation":"horizontal",...f,ref:y,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:C=>{const P=E(C.clientX);o==null||o(P)},onSlideMove:C=>{const P=E(C.clientX);c==null||c(P)},onSlideEnd:()=>{v.current=void 0,u==null||u()},onStepKeyDown:C=>{const O=Wk[k?"from-left":"from-right"].includes(C.key);h==null||h({event:C,direction:O?-1:1})}})})}),zP=b.forwardRef((t,e)=>{const{min:n,max:s,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=b.useRef(null),m=$t(e,f),g=b.useRef(void 0),y=!a;function v(w){const N=g.current||f.current.getBoundingClientRect(),k=[0,N.height],C=M0(k,y?[s,n]:[n,s]);return g.current=N,C(w-N.top)}return r.jsx(Gk,{scope:t.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:r.jsx(Yk,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const N=v(w.clientY);i==null||i(N)},onSlideMove:w=>{const N=v(w.clientY);o==null||o(N)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:w=>{const k=Wk[y?"from-bottom":"from-top"].includes(w.key);u==null||u({event:w,direction:k?-1:1})}})})}),Yk=b.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:s,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=rp(Ic,n);return r.jsx(vt.span,{...h,ref:e,onKeyDown:xt(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):Hk.concat(Uk).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:xt(t.onPointerDown,m=>{const g=m.target;g.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(g)?g.focus():s(m)}),onPointerMove:xt(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&a(m)}),onPointerUp:xt(t.onPointerUp,m=>{const g=m.target;g.hasPointerCapture(m.pointerId)&&(g.releasePointerCapture(m.pointerId),i(m))})})}),Qk="SliderTrack",Xk=b.forwardRef((t,e)=>{const{__scopeSlider:n,...s}=t,a=rp(Qk,n);return r.jsx(vt.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...s,ref:e})});Xk.displayName=Qk;var px="SliderRange",Zk=b.forwardRef((t,e)=>{const{__scopeSlider:n,...s}=t,a=rp(px,n),i=Jk(px,n),o=b.useRef(null),c=$t(e,o),u=a.values.length,h=a.values.map(g=>nS(g,a.min,a.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return r.jsx(vt.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...s,ref:c,style:{...t.style,[i.startEdge]:f+"%",[i.endEdge]:m+"%"}})});Zk.displayName=px;var mx="SliderThumb",eS=b.forwardRef((t,e)=>{const n=OP(t.__scopeSlider),[s,a]=b.useState(null),i=$t(e,c=>a(c)),o=b.useMemo(()=>s?n().findIndex(c=>c.ref.current===s):-1,[n,s]);return r.jsx($P,{...t,ref:i,index:o})}),$P=b.forwardRef((t,e)=>{const{__scopeSlider:n,index:s,name:a,...i}=t,o=rp(mx,n),c=Jk(mx,n),[u,h]=b.useState(null),f=$t(e,E=>h(E)),m=u?o.form||!!u.closest("form"):!0,g=E0(u),y=o.values[s],v=y===void 0?0:nS(y,o.min,o.max),w=VP(s,o.values.length),N=g==null?void 0:g[c.size],k=N?UP(N,v,c.direction):0;return b.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),r.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${v}% + ${k}px)`},children:[r.jsx(fx.ItemSlot,{scope:t.__scopeSlider,children:r.jsx(vt.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:xt(t.onFocus,()=>{o.valueIndexToChangeRef.current=s})})}),m&&r.jsx(tS,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:y},s)]})});eS.displayName=mx;var FP="RadioBubbleInput",tS=b.forwardRef(({__scopeSlider:t,value:e,...n},s)=>{const a=b.useRef(null),i=$t(a,s),o=C0(e);return b.useEffect(()=>{const c=a.current;if(!c)return;const u=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==e&&f){const m=new Event("input",{bubbles:!0});f.call(c,e),c.dispatchEvent(m)}},[o,e]),r.jsx(vt.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});tS.displayName=FP;function BP(t=[],e,n){const s=[...t];return s[n]=e,s.sort((a,i)=>a-i)}function nS(t,e,n){const i=100/(n-e)*(t-e);return Zh(i,[0,100])}function VP(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function HP(t,e){if(t.length===1)return 0;const n=t.map(a=>Math.abs(a-e)),s=Math.min(...n);return n.indexOf(s)}function UP(t,e,n){const s=t/2,i=M0([0,50],[0,s]);return(s-i(e)*n)*n}function WP(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function KP(t,e){if(e>0){const n=WP(t);return Math.min(...n)>=e}return!0}function M0(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const s=(e[1]-e[0])/(t[1]-t[0]);return e[0]+s*(n-t[0])}}function qP(t){return(String(t).split(".")[1]||"").length}function GP(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var JP=qk,YP=Xk,QP=Zk,XP=eS;function ZP({className:t,defaultValue:e,value:n,min:s=0,max:a=100,...i}){const o=b.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[s,a],[n,e,s,a]);return r.jsxs(JP,{defaultValue:e,value:n,min:s,max:a,className:Ft("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...i,children:[r.jsx(YP,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:r.jsx(QP,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>r.jsx(XP,{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 eO={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,withdrawFee:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function sS(t){const e=!!(t!=null&&t.embedded),[n,s]=b.useState(eO),[a,i]=b.useState(!0),[o,c]=b.useState(!1);b.useEffect(()=>{De("/api/admin/referral-settings").then(f=>{const m=f==null?void 0:f.data;m&&typeof m=="object"&&s({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 Et("/api/admin/referral-settings",f);if(!m||m.success===!1){oe.error("保存失败: "+(m&&typeof m=="object"&&"error"in m?m.error:""));return}oe.success(`✅ 分销配置已保存成功!
• 小程序与网站的推广规则会一起生效
• 绑定关系会使用新的天数配置
• 佣金比例会立即应用到新订单
如有缓存,请刷新前台/小程序页面。`)}catch(f){console.error(f),oe.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{c(!1)}},h=f=>m=>{const g=parseFloat(m.target.value||"0");s(y=>({...y,[f]:isNaN(g)?0:g}))};return a?r.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):r.jsxs("div",{className:e?"p-4 w-full":"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(gc,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),r.jsxs("p",{className:"text-gray-400 mt-1",children:["统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置(与系统设置中的「推广功能」开关配合:开关在"," ",r.jsx($d,{to:"/settings",className:"text-[#38bdac] underline hover:text-[#5ee0d1]",children:"系统设置 → 功能开关"}),")。"]})]}),r.jsxs(Y,{onClick:u,disabled:o||a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),o?"保存中...":"保存配置"]})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"flex items-center gap-2 text-white",children:[r.jsx(jM,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),r.jsx(Kt,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),r.jsx(Le,{className:"space-y-6",children:r.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(ee,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(oh,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%"]}),r.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.userDiscount,onChange:h("userDiscount")}),r.jsx("p",{className:"text-xs text-gray-500",children:"例如 5 表示好友立减 5%(在价格配置基础上生效)。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(ee,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(zn,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%"]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(ZP,{className:"flex-1",min:10,max:100,step:1,value:[n.distributorShare],onValueChange:([f])=>s(m=>({...m,distributorShare:f}))}),r.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")})]}),r.jsxs("p",{className:"text-xs text-gray-500",children:["内容订单佣金 = 订单金额 ×"," ",r.jsxs("span",{className:"text-[#38bdac] font-mono",children:[n.distributorShare,"%"]}),";会员订单见下方。"]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(ee,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(oh,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %"]}),r.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.vipOrderShareVip,onChange:h("vipOrderShareVip")}),r.jsx("p",{className:"text-xs text-gray-500",children:"推广者已是会员时,会员订单佣金比例,默认 20%。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(ee,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(oh,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %"]}),r.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.vipOrderShareNonVip,onChange:h("vipOrderShareNonVip")}),r.jsx("p",{className:"text-xs text-gray-500",children:"推广者非会员时,会员订单佣金比例,默认 10%。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(ee,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(zn,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),r.jsx(ce,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:n.bindingDays,onChange:h("bindingDays")}),r.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"flex items-center gap-2 text-white",children:[r.jsx(gc,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),r.jsx(Kt,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),r.jsx(Le,{className:"space-y-6",children:r.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"最低提现金额(元)"}),r.jsx(ce,{type:"number",min:0,step:1,className:"bg-[#0a1628] border-gray-700 text-white",value:n.minWithdrawAmount,onChange:h("minWithdrawAmount")}),r.jsx("p",{className:"text-xs text-gray-500",children:"小程序「满 X 元可提现」展示的门槛,同时用于后端接口校验。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"提现手续费(%"}),r.jsx(ce,{type:"number",min:0,max:100,step:.5,className:"bg-[#0a1628] border-gray-700 text-white",value:n.withdrawFee,onChange:h("withdrawFee")}),r.jsx("p",{className:"text-xs text-gray-500",children:"批准提现时按此比例扣除后打款,如 5 表示申请 100 元实际到账 95 元。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(ee,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",r.jsx(Ge,{variant:"outline",className:"border-[#38bdac]/40 text-[#38bdac] text-[10px]",children:"预留"})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[r.jsx(Rt,{checked:n.enableAutoWithdraw,onCheckedChange:f=>s(m=>({...m,enableAutoWithdraw:f}))}),r.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(it,{children:r.jsxs(ot,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[r.jsx(oh,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),r.jsxs(Le,{className:"space-y-2 text-xs text-gray-400 leading-relaxed",children:[r.jsxs("p",{children:["1. 以上配置会写入"," ",r.jsx("code",{className:"font-mono text-[11px] text-[#38bdac]",children:"system_config.referral_config"}),"小程序「推广中心」、Web 推广页以及支付回调都会读取同一份配置。"]}),r.jsx("p",{children:"2. 修改后新订单立即生效;旧订单的历史佣金不会自动重算,只影响之后产生的订单。"}),r.jsx("p",{children:"3. 如遇前端展示与实际结算不一致,优先以此处配置为准,再排查缓存和小程序版本。"})]})]})]})]})}function tO(){const[t]=f0(),[e,n]=b.useState("overview"),[s,a]=b.useState("orders"),[i,o]=b.useState([]),[c,u]=b.useState(null),[h,f]=b.useState([]),[m,g]=b.useState([]),[y,v]=b.useState([]),[w,N]=b.useState(!0),[k,E]=b.useState(null),[C,P]=b.useState(""),[O,U]=b.useState("all"),[_,V]=b.useState(1),[A,X]=b.useState(10),[G,z]=b.useState(0),[ne,ue]=b.useState(new Set),[K,$]=b.useState(null),[D,I]=b.useState(""),[ie,q]=b.useState(!1),[L,F]=b.useState(null),[re,ge]=b.useState(""),[Te,se]=b.useState(!1),[le,ae]=b.useState(!1),[Q,Z]=b.useState(!1),[xe,Ne]=b.useState([]),[ct,ye]=b.useState(1),[$e,Ze]=b.useState(0),[tt,_e]=b.useState("");b.useEffect(()=>{st()},[]),b.useEffect(()=>{const W=t.get("tab");(W==="overview"||W==="orders"||W==="bindings"||W==="withdrawals"||W==="settings")&&n(W)},[t]),b.useEffect(()=>{V(1)},[e,O]),b.useEffect(()=>{kt(e)},[e]),b.useEffect(()=>{if(e==="orders"&&s==="giftpay"){kt("giftPay",!0);return}["orders","bindings","withdrawals"].includes(e)&&kt(e,!0)},[_,A,O,C,e,s,ct,tt]),b.useEffect(()=>{e==="withdrawals"&&gs()},[e]);async function st(){E(null);try{const W=await De("/api/admin/distribution/overview");W!=null&&W.success&&W.overview&&u(W.overview)}catch(W){console.error("[Admin] 概览接口异常:",W),E("加载概览失败")}try{const W=await De("/api/db/users");v((W==null?void 0:W.users)||[])}catch(W){console.error("[Admin] 用户数据加载失败:",W)}}async function kt(W,Qe=!1){var mt;if(!(!Qe&&ne.has(W))){N(!0);try{const Bt=y;switch(W){case"overview":break;case"orders":{try{const gt=new URLSearchParams({page:String(_),pageSize:String(A),...O!=="all"&&{status:O},...C&&{search:C}}),ht=await De(`/api/admin/orders?${gt}`);if(ht!=null&&ht.success&&ht.orders){const At=ht.orders.map(It=>{const sn=Bt.find(pe=>pe.id===It.userId),Wn=It.referrerId?Bt.find(pe=>pe.id===It.referrerId):null;return{...It,amount:parseFloat(String(It.amount))||0,userNickname:(sn==null?void 0:sn.nickname)||It.userNickname||"未知用户",userPhone:(sn==null?void 0:sn.phone)||It.userPhone||"-",referrerNickname:(Wn==null?void 0:Wn.nickname)||null,referrerCode:(Wn==null?void 0:Wn.referralCode)??null,type:It.productType||It.type}});o(At),z(ht.total??At.length)}else o([]),z(0)}catch(gt){console.error(gt),E("加载订单失败"),o([])}break}case"bindings":{try{const gt=new URLSearchParams({page:String(_),pageSize:String(A),...O!=="all"&&{status:O}}),ht=await De(`/api/db/distribution?${gt}`);f((ht==null?void 0:ht.bindings)||[]),z((ht==null?void 0:ht.total)??((mt=ht==null?void 0:ht.bindings)==null?void 0:mt.length)??0)}catch(gt){console.error(gt),E("加载绑定数据失败"),f([])}break}case"withdrawals":{try{const gt=O==="completed"?"success":O==="rejected"?"failed":O,ht=new URLSearchParams({...gt&&gt!=="all"&&{status:gt},page:String(_),pageSize:String(A)}),At=await De(`/api/admin/withdrawals?${ht}`);if(At!=null&&At.success&&At.withdrawals){const It=At.withdrawals.map(sn=>({...sn,account:sn.account??"未绑定微信号",status:sn.status==="success"?"completed":sn.status==="failed"?"rejected":sn.status}));g(It),z((At==null?void 0:At.total)??It.length)}else At!=null&&At.success||E(`获取提现记录失败: ${(At==null?void 0:At.error)||"未知错误"}`),g([])}catch(gt){console.error(gt),E("加载提现数据失败"),g([])}break}case"giftPay":{try{const gt=new URLSearchParams({page:String(ct),pageSize:"20",...tt&&{status:tt}}),ht=await De(`/api/admin/gift-pay-requests?${gt}`);ht!=null&&ht.success&&ht.data?(Ne(ht.data),Ze(ht.total??ht.data.length)):(Ne([]),Ze(0))}catch(gt){console.error(gt),E("加载代付请求失败"),Ne([])}break}}ue(gt=>new Set(gt).add(W))}catch(Bt){console.error(Bt)}finally{N(!1)}}}async function Pt(){E(null),ue(W=>{const Qe=new Set(W);return Qe.delete(e),e==="orders"&&s==="giftpay"&&Qe.delete("giftPay"),Qe}),e==="overview"&&st(),e==="orders"&&s==="giftpay"?await kt("giftPay",!0):await kt(e,!0)}async function Ot(W){if(confirm("确认审核通过并打款?"))try{const Qe=await Jt("/api/admin/withdrawals",{id:W,action:"approve"});if(!(Qe!=null&&Qe.success)){const mt=(Qe==null?void 0:Qe.message)||(Qe==null?void 0:Qe.error)||"操作失败";oe.error(mt);return}await Pt()}catch(Qe){console.error(Qe),oe.error("操作失败")}}function Mn(W){F(W),ge("")}async function Dn(){const W=L;if(!W)return;const Qe=re.trim();if(!Qe){oe.error("请填写拒绝原因");return}se(!0);try{const mt=await Jt("/api/admin/withdrawals",{id:W,action:"reject",errorMessage:Qe});if(!(mt!=null&&mt.success)){oe.error((mt==null?void 0:mt.error)||"操作失败");return}oe.success("已拒绝该提现申请"),F(null),ge(""),await Pt()}catch(mt){console.error(mt),oe.error("操作失败")}finally{se(!1)}}async function gs(){try{const W=await De("/api/admin/withdrawals/auto-approve");W!=null&&W.success&&typeof W.enableAutoApprove=="boolean"&&ae(W.enableAutoApprove)}catch{}}async function zs(W){Z(!0);try{const Qe=await Jt("/api/admin/withdrawals/auto-approve",{enableAutoApprove:W});Qe!=null&&Qe.success?(ae(W),oe.success(W?"已开启自动审批,新提现将自动打款":"已关闭自动审批")):oe.error("更新失败: "+((Qe==null?void 0:Qe.error)??""))}catch{oe.error("更新失败")}finally{Z(!1)}}function ts(){L&&oe.info("已取消操作"),F(null),ge("")}async function xs(){var W;if(!(!(K!=null&&K.orderSn)&&!(K!=null&&K.id))){q(!0),E(null);try{const Qe=await Jt("/api/admin/orders/refund",{orderSn:K.orderSn||K.id,reason:D||void 0});Qe!=null&&Qe.success?($(null),I(""),await kt("orders",!0)):E((Qe==null?void 0:Qe.error)||"退款失败")}catch(Qe){const mt=Qe;E(((W=mt==null?void 0:mt.data)==null?void 0:W.error)||"退款失败,请检查网络后重试")}finally{q(!1)}}}function Gt(W){const Qe={active:"bg-green-500/20 text-green-400",converted:"bg-blue-500/20 text-blue-400",expired:"bg-gray-500/20 text-gray-400",cancelled:"bg-red-500/20 text-red-400",pending:"bg-orange-500/20 text-orange-400",pending_confirm:"bg-orange-500/20 text-orange-400",processing:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",rejected:"bg-red-500/20 text-red-400"},mt={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return r.jsx(Ge,{className:`${Qe[W]||"bg-gray-500/20 text-gray-400"} border-0`,children:mt[W]||W})}const ln=Math.ceil(G/A)||1,As=i,Is=h.filter(W=>{var mt,Bt,gt,ht;if(!C)return!0;const Qe=C.toLowerCase();return((mt=W.refereeNickname)==null?void 0:mt.toLowerCase().includes(Qe))||((Bt=W.refereePhone)==null?void 0:Bt.includes(Qe))||((gt=W.referrerName)==null?void 0:gt.toLowerCase().includes(Qe))||((ht=W.referrerCode)==null?void 0:ht.toLowerCase().includes(Qe))}),ns=m.filter(W=>{var mt;if(!C)return!0;const Qe=C.toLowerCase();return((mt=W.userName)==null?void 0:mt.toLowerCase().includes(Qe))||W.account&&W.account.toLowerCase().includes(Qe)});return r.jsxs("div",{className:"p-8 w-full",children:[k&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:k}),r.jsx("button",{type:"button",onClick:()=>E(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-xl font-semibold text-white",children:"推广中心"}),r.jsx("p",{className:"text-gray-500 text-sm mt-0.5",children:"分销绑定、提现审核、推广设置"})]}),r.jsxs(Y,{onClick:Pt,disabled:w,variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[r.jsx(Be,{className:`w-3.5 h-3.5 mr-1.5 ${w?"animate-spin":""}`}),"刷新"]})]}),r.jsx("div",{className:"flex gap-1 mb-6 bg-[#0a1628] rounded-lg p-1 border border-gray-700/40",children:[{key:"overview",label:"数据概览",icon:Kh},{key:"orders",label:"订单与代付",icon:Uh},{key:"bindings",label:"绑定管理",icon:ro},{key:"withdrawals",label:"提现审核",icon:gc},{key:"settings",label:"推广设置",icon:el}].map(W=>r.jsxs("button",{type:"button",onClick:()=>{n(W.key),U("all"),P(""),W.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===W.key?"bg-[#38bdac] text-white shadow-md":"text-gray-400 hover:text-white hover:bg-gray-700/40"}`,children:[r.jsx(W.icon,{className:"w-3.5 h-3.5"}),W.label]},W.key))}),w?r.jsxs("div",{className:"flex items-center justify-center py-20",children:[r.jsx(Be,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[e==="overview"&&c&&r.jsxs("div",{className:"space-y-6",children:[r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Le,{className:"p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("span",{className:"text-sm font-medium text-gray-300 flex items-center gap-2",children:[r.jsx(ao,{className:"w-4 h-4 text-amber-400"}),"推广转化漏斗"]}),r.jsx(Y,{type:"button",size:"sm",variant:"ghost",onClick:()=>void Pt(),disabled:w,className:"text-gray-400 h-7",children:r.jsx(Be,{className:`w-3.5 h-3.5 ${w?"animate-spin":""}`})})]}),r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"text-gray-500 text-xs border-b border-gray-700/50",children:[r.jsx("th",{className:"pb-2 text-left font-normal",children:"指标"}),r.jsx("th",{className:"pb-2 text-right font-normal",children:"今日"}),r.jsx("th",{className:"pb-2 text-right font-normal",children:"本月"}),r.jsx("th",{className:"pb-2 text-right font-normal",children:"累计"})]})}),r.jsxs("tbody",{className:"text-white",children:[r.jsxs("tr",{className:"border-b border-gray-700/30",children:[r.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[r.jsx(Wh,{className:"w-4 h-4 text-blue-400"}),"点击数"]}),r.jsx("td",{className:"py-2.5 text-right font-bold",children:c.todayClicks}),r.jsx("td",{className:"py-2.5 text-right",children:c.monthClicks}),r.jsx("td",{className:"py-2.5 text-right",children:c.totalClicks})]}),r.jsxs("tr",{className:"border-b border-gray-700/30",children:[r.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[r.jsx(ro,{className:"w-4 h-4 text-green-400"}),"绑定关系"]}),r.jsx("td",{className:"py-2.5 text-right font-bold",children:c.todayBindings}),r.jsx("td",{className:"py-2.5 text-right",children:c.monthBindings}),r.jsx("td",{className:"py-2.5 text-right",children:c.totalBindings})]}),r.jsxs("tr",{className:"border-b border-gray-700/30",children:[r.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[r.jsx(ng,{className:"w-4 h-4 text-purple-400"}),"付款转化"]}),r.jsx("td",{className:"py-2.5 text-right font-bold",children:c.todayConversions}),r.jsx("td",{className:"py-2.5 text-right",children:c.monthConversions}),r.jsx("td",{className:"py-2.5 text-right",children:c.totalConversions})]}),r.jsxs("tr",{children:[r.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[r.jsx(Uh,{className:"w-4 h-4 text-[#38bdac]"}),"佣金收入"]}),r.jsxs("td",{className:"py-2.5 text-right font-bold text-[#38bdac]",children:["¥",(c.todayEarnings??0).toFixed(0)]}),r.jsxs("td",{className:"py-2.5 text-right text-[#38bdac]",children:["¥",(c.monthEarnings??0).toFixed(0)]}),r.jsxs("td",{className:"py-2.5 text-right text-[#38bdac]",children:["¥",(c.totalEarnings??0).toFixed(0)]})]})]})]})}),c.conversionRate&&r.jsxs("p",{className:"text-xs text-gray-500 mt-3 text-right",children:["综合转化率 ",c.conversionRate]})]})}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsx(Oe,{className:"bg-orange-500/10 border-orange-500/30",children:r.jsx(Le,{className:"p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(sx,{className:"w-5 h-5 text-orange-400 shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-orange-300 font-medium text-sm",children:"即将过期绑定"}),r.jsxs("p",{className:"text-xl font-bold text-white",children:[c.expiringBindings," ",r.jsx("span",{className:"text-sm font-normal text-orange-300/60",children:"个 · 7天内"})]})]})]})})}),r.jsx(Oe,{className:"bg-blue-500/10 border-blue-500/30",children:r.jsx(Le,{className:"p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(gc,{className:"w-5 h-5 text-blue-400 shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-blue-300 font-medium text-sm",children:"待审核提现"}),r.jsxs("p",{className:"text-xl font-bold text-white",children:[c.pendingWithdrawals," ",r.jsxs("span",{className:"text-sm font-normal text-blue-300/60",children:["笔 · ¥",(c.pendingWithdrawAmount??0).toFixed(0)]})]})]}),r.jsx(Y,{onClick:()=>n("withdrawals"),variant:"outline",size:"sm",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20 shrink-0",children:"去审核"})]})})})]}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Le,{className:"p-4",children:r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-white/5",children:[r.jsx(zn,{className:"w-5 h-5 text-gray-400 shrink-0"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-lg font-bold text-white",children:c.totalDistributors}),r.jsx("p",{className:"text-[10px] text-gray-500",children:"推广用户"})]})]}),r.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-white/5",children:[r.jsx(ng,{className:"w-5 h-5 text-green-400 shrink-0"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-lg font-bold text-green-400",children:c.activeDistributors}),r.jsx("p",{className:"text-[10px] text-gray-500",children:"有收益用户"})]})]})]})})})]}),e==="orders"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex gap-2 mb-2",children:[r.jsx("button",{type:"button",className:`px-3 py-1.5 rounded-md text-xs font-medium transition-all ${s==="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:"普通订单"}),r.jsxs("button",{type:"button",className:`px-3 py-1.5 rounded-md text-xs font-medium transition-all ${s==="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"),kt("giftPay",!0)},children:[r.jsx(rx,{className:"w-3 h-3 inline mr-1"}),"代付请求"]})]}),s==="orders"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[r.jsx(Sa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),r.jsx(ce,{value:C,onChange:W=>P(W.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),r.jsxs("select",{value:O,onChange:W=>U(W.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"completed",children:"已完成"}),r.jsx("option",{value:"pending",children:"待支付"}),r.jsx("option",{value:"failed",children:"已失败"}),r.jsx("option",{value:"refunded",children:"已退款"})]}),r.jsxs(Y,{type:"button",variant:"outline",onClick:()=>void Pt(),disabled:w,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${w?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Le,{className:"p-0",children:[i.length===0?r.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无订单数据"}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"订单号"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"商品"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"支付方式"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"退款原因"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"推荐人/邀请码"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"分销佣金"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"下单时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"操作"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:As.map(W=>{var Qe,mt;return r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsxs("td",{className:"p-4 font-mono text-xs text-gray-400",children:[(Qe=W.id)==null?void 0:Qe.slice(0,12),"..."]}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white text-sm",children:W.userNickname}),r.jsx("p",{className:"text-gray-500 text-xs",children:W.userPhone})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white text-sm",children:(()=>{const Bt=W.productType||W.type,gt=W.description||"",ht=String(W.productId||W.sectionId||""),At=Bt==="vip"||gt.includes("VIP")||gt.toLowerCase().includes("vip")||ht.toLowerCase().includes("vip");return Bt==="balance_recharge"?`余额充值 ¥${typeof W.amount=="number"?W.amount.toFixed(2):parseFloat(String(W.amount||"0")).toFixed(2)}`:At?"超级个体开通费用":Bt==="fullbook"?`${W.bookName||"《底层逻辑》"} - 全本`:Bt==="match"?"匹配次数购买":`${W.bookName||"《底层逻辑》"} - ${W.sectionTitle||W.chapterTitle||`章节${W.productId||W.sectionId||""}`}`})()}),r.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const Bt=W.productType||W.type,gt=W.description||"",ht=String(W.productId||W.sectionId||""),At=Bt==="vip"||gt.includes("VIP")||gt.toLowerCase().includes("vip")||ht.toLowerCase().includes("vip");return Bt==="balance_recharge"?"余额充值":At?"超级个体":Bt==="fullbook"?"全书解锁":Bt==="match"?"功能权益":W.chapterTitle||"单章购买"})()})]})}),r.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof W.amount=="number"?W.amount.toFixed(2):parseFloat(String(W.amount||"0")).toFixed(2)]}),r.jsx("td",{className:"p-4 text-gray-300",children:W.paymentMethod==="wechat"?"微信支付":W.paymentMethod==="balance"?"余额支付":W.paymentMethod==="alipay"?"支付宝":W.paymentMethod||"微信支付"}),r.jsx("td",{className:"p-4",children:W.status==="refunded"?r.jsx(Ge,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):W.status==="completed"||W.status==="paid"?r.jsx(Ge,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):W.status==="pending"||W.status==="created"?r.jsx(Ge,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):r.jsx(Ge,{className:"bg-red-500/20 text-red-400 border-0",children:"已失败"})}),r.jsx("td",{className:"p-4 text-gray-400 text-sm max-w-[120px]",title:W.refundReason,children:W.status==="refunded"&&W.refundReason?W.refundReason:"-"}),r.jsx("td",{className:"p-4 text-gray-300 text-sm",children:W.referrerId||W.referralCode?r.jsxs("span",{title:W.referralCode||W.referrerCode||W.referrerId||"",children:[W.referrerNickname||W.referralCode||W.referrerCode||((mt=W.referrerId)==null?void 0:mt.slice(0,8)),(W.referralCode||W.referrerCode)&&` (${W.referralCode||W.referrerCode})`]}):"-"}),r.jsx("td",{className:"p-4 text-[#FFD700]",children:W.referrerEarnings?`¥${(typeof W.referrerEarnings=="number"?W.referrerEarnings:parseFloat(String(W.referrerEarnings))).toFixed(2)}`:"-"}),r.jsx("td",{className:"p-4 text-gray-400 text-sm",children:W.createdAt?new Date(W.createdAt).toLocaleString("zh-CN"):"-"}),r.jsx("td",{className:"p-4",children:(W.status==="paid"||W.status==="completed")&&r.jsxs(Y,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{$(W),I("")},children:[r.jsx(wj,{className:"w-3 h-3 mr-1"}),"退款"]})})]},W.id)})})]})}),e==="orders"&&r.jsx(Gs,{page:_,totalPages:ln,total:G,pageSize:A,onPageChange:V,onPageSizeChange:W=>{X(W),V(1)}})]})})]}),s==="giftpay"&&r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(it,{children:r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[r.jsx(ot,{className:"text-white text-base",children:"代付请求列表"}),r.jsxs("div",{className:"flex gap-2 items-center",children:[r.jsxs("select",{className:"bg-[#0a1628] border border-gray-700 text-white rounded px-3 py-1.5 text-sm",value:tt,onChange:W=>{_e(W.target.value),ye(1)},children:[r.jsx("option",{value:"",children:"全部状态"}),r.jsx("option",{value:"pending",children:"待支付(旧)"}),r.jsx("option",{value:"pending_pay",children:"待发起人支付"}),r.jsx("option",{value:"paid",children:"已支付"}),r.jsx("option",{value:"refunded",children:"已退款"}),r.jsx("option",{value:"cancelled",children:"已取消"}),r.jsx("option",{value:"expired",children:"已过期"})]}),r.jsxs(Y,{size:"sm",variant:"outline",onClick:()=>void kt("giftPay",!0),disabled:w,className:"border-gray-600 text-gray-300",children:[r.jsx(Be,{className:`w-3.5 h-3.5 mr-1 ${w?"animate-spin":""}`}),"刷新"]})]})]})}),r.jsxs(Le,{children:[r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-gray-700/50",children:[r.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"请求号"}),r.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"发起人"}),r.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"商品/金额"}),r.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"份数/已领"}),r.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"付款人"}),r.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"状态"}),r.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"创建时间"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:xe.map(W=>r.jsxs("tr",{className:"hover:bg-[#0a1628]",children:[r.jsx("td",{className:"p-3 font-mono text-xs text-gray-400",children:W.requestSn}),r.jsx("td",{className:"p-3 text-white text-sm",children:W.initiatorNick||W.initiatorUserId}),r.jsxs("td",{className:"p-3",children:[r.jsxs("p",{className:"text-white",children:[W.productType," · ¥",W.amount.toFixed(2)]}),W.description&&r.jsx("p",{className:"text-gray-500 text-xs",children:W.description})]}),r.jsx("td",{className:"p-3 text-gray-400",children:(W.quantity??1)>1?`${W.quantity}份 / 已领${W.redeemedCount??0}`:"-"}),r.jsx("td",{className:"p-3 text-gray-400",children:W.payerNick||(W.payerUserId?W.payerUserId:"-")}),r.jsx("td",{className:"p-3",children:r.jsx(Ge,{className:W.status==="paid"?"bg-green-500/20 text-green-400 border-0":W.status==="pending"||W.status==="pending_pay"?"bg-amber-500/20 text-amber-400 border-0":W.status==="refunded"?"bg-red-500/20 text-red-400 border-0":"bg-gray-500/20 text-gray-400 border-0",children:W.status==="paid"?"已支付":W.status==="pending"||W.status==="pending_pay"?"待支付":W.status==="refunded"?"已退款":W.status==="cancelled"?"已取消":"已过期"})}),r.jsx("td",{className:"p-3 text-gray-400 text-xs",children:W.createdAt?new Date(W.createdAt).toLocaleString("zh-CN"):"-"})]},W.id))})]})}),xe.length===0&&!w&&r.jsx("p",{className:"text-center py-8 text-gray-500",children:"暂无代付请求"}),$e>20&&r.jsx("div",{className:"mt-4 flex justify-center",children:r.jsx(Gs,{page:ct,totalPages:Math.ceil($e/20),total:$e,pageSize:20,onPageChange:ye,onPageSizeChange:()=>{}})})]})]})]}),e==="bindings"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[r.jsx(Sa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),r.jsx(ce,{value:C,onChange:W=>P(W.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),r.jsxs("select",{value:O,onChange:W=>U(W.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"active",children:"有效"}),r.jsx("option",{value:"converted",children:"已转化"}),r.jsx("option",{value:"expired",children:"已过期"})]}),r.jsxs(Y,{type:"button",variant:"outline",onClick:()=>void Pt(),disabled:w,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${w?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Le,{className:"p-0",children:[Is.length===0?r.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无绑定数据"}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"访客"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"分销商"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"绑定时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"到期时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"佣金"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:Is.map(W=>r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white font-medium",children:W.refereeNickname||"匿名用户"}),r.jsx("p",{className:"text-gray-500 text-xs",children:W.refereePhone})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white",children:W.referrerName||"-"}),r.jsx("p",{className:"text-gray-500 text-xs font-mono",children:W.referrerCode})]})}),r.jsx("td",{className:"p-4 text-gray-400",children:W.boundAt?new Date(W.boundAt).toLocaleDateString("zh-CN"):"-"}),r.jsx("td",{className:"p-4 text-gray-400",children:W.expiresAt?new Date(W.expiresAt).toLocaleDateString("zh-CN"):"-"}),r.jsx("td",{className:"p-4",children:Gt(W.status)}),r.jsx("td",{className:"p-4",children:W.commission?r.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",W.commission.toFixed(2)]}):r.jsx("span",{className:"text-gray-500",children:"-"})})]},W.id))})]})}),e==="bindings"&&r.jsx(Gs,{page:_,totalPages:ln,total:G,pageSize:A,onPageChange:V,onPageSizeChange:W=>{X(W),V(1)}})]})})]}),e==="withdrawals"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[r.jsx(Sa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),r.jsx(ce,{value:C,onChange:W=>P(W.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),r.jsxs("select",{value:O,onChange:W=>U(W.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"pending",children:"待审核"}),r.jsx("option",{value:"completed",children:"已完成"}),r.jsx("option",{value:"rejected",children:"已拒绝"})]}),r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[#0f2137] border border-gray-700/50 shrink-0",children:[r.jsx(ao,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx("span",{className:"text-sm text-gray-300",children:"自动审批"}),r.jsx(Rt,{checked:le,onCheckedChange:zs,disabled:Q,className:"data-[state=checked]:bg-[#38bdac]"})]}),r.jsxs(Y,{type:"button",variant:"outline",onClick:()=>void Pt(),disabled:w,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${w?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Le,{className:"p-0",children:[ns.length===0?r.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无提现记录"}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"申请人"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"收款方式"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"收款账号"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"备注"}),r.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:ns.map(W=>r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsx("td",{className:"p-4",children:r.jsxs("div",{className:"flex items-center gap-2",children:[W.userAvatar?r.jsx("img",{src:W.userAvatar,alt:"",className:"w-8 h-8 rounded-full object-cover"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-600 flex items-center justify-center text-white text-sm font-medium",children:(W.userName||W.name||"?").slice(0,1)}),r.jsx("p",{className:"text-white font-medium",children:W.userName||W.name})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",W.amount.toFixed(2)]})}),r.jsx("td",{className:"p-4",children:r.jsx(Ge,{className:W.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:W.method==="wechat"?"微信":"支付宝"})}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white font-mono text-xs",children:W.account}),r.jsx("p",{className:"text-gray-500 text-xs",children:W.name})]})}),r.jsx("td",{className:"p-4 text-gray-400",children:W.createdAt?new Date(W.createdAt).toLocaleString("zh-CN"):"-"}),r.jsx("td",{className:"p-4",children:Gt(W.status)}),r.jsx("td",{className:"p-4 max-w-[160px]",children:r.jsx("span",{className:`text-xs ${W.status==="rejected"||W.status==="failed"?"text-red-400":"text-gray-400"}`,title:W.remark,children:W.remark||"-"})}),r.jsx("td",{className:"p-4 text-right",children:W.status==="pending"&&r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsxs(Y,{size:"sm",onClick:()=>Ot(W.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(ng,{className:"w-4 h-4 mr-1"}),"通过"]}),r.jsxs(Y,{size:"sm",variant:"outline",onClick:()=>Mn(W.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[r.jsx(mj,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},W.id))})]})}),e==="withdrawals"&&r.jsx(Gs,{page:_,totalPages:ln,total:G,pageSize:A,onPageChange:V,onPageSizeChange:W=>{X(W),V(1)}})]})})]})]}),r.jsx(Ht,{open:!!K,onOpenChange:W=>!W&&$(null),children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Ut,{children:r.jsx(Wt,{className:"text-white",children:"订单退款"})}),K&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",K.orderSn||K.id]}),r.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof K.amount=="number"?K.amount.toFixed(2):parseFloat(String(K.amount||"0")).toFixed(2)]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),r.jsx("div",{className:"form-input",children:r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:D,onChange:W=>I(W.target.value)})})]}),r.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),r.jsxs(xn,{children:[r.jsx(Y,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>$(null),disabled:ie,children:"取消"}),r.jsx(Y,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:xs,disabled:ie,children:ie?"退款中...":"确认退款"})]})]})}),r.jsx(Ht,{open:!!L,onOpenChange:W=>!W&&ts(),children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Ut,{children:r.jsx(Wt,{className:"text-white",children:"拒绝提现"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),r.jsx("div",{className:"form-input",children:r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:re,onChange:W=>ge(W.target.value)})})]})]}),r.jsxs(xn,{children:[r.jsx(Y,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:ts,disabled:Te,children:"取消"}),r.jsx(Y,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:Dn,disabled:Te||!re.trim(),children:Te?"提交中...":"确认拒绝"})]})]})}),e==="settings"&&r.jsx("div",{className:"-mx-8 -mt-6",children:r.jsx(sS,{embedded:!0})})]})}function nO(){const[t,e]=b.useState([]),[n,s]=b.useState({total:0,pendingCount:0,pendingAmount:0,successCount:0,successAmount:0,failedCount:0}),[a,i]=b.useState(!0),[o,c]=b.useState(null),[u,h]=b.useState("all"),[f,m]=b.useState(1),[g,y]=b.useState(10),[v,w]=b.useState(0),[N,k]=b.useState(null),[E,C]=b.useState(null),[P,O]=b.useState(""),[U,_]=b.useState(!1);async function V(){var K,$,D,I,ie,q,L;i(!0),c(null);try{const F=new URLSearchParams({status:u,page:String(f),pageSize:String(g)}),re=await De(`/api/admin/withdrawals?${F}`);if(re!=null&&re.success){const ge=re.withdrawals||[];e(ge),w(re.total??((K=re.stats)==null?void 0:K.total)??ge.length),s({total:(($=re.stats)==null?void 0:$.total)??re.total??ge.length,pendingCount:((D=re.stats)==null?void 0:D.pendingCount)??0,pendingAmount:((I=re.stats)==null?void 0:I.pendingAmount)??0,successCount:((ie=re.stats)==null?void 0:ie.successCount)??0,successAmount:((q=re.stats)==null?void 0:q.successAmount)??0,failedCount:((L=re.stats)==null?void 0:L.failedCount)??0})}else c("加载提现记录失败")}catch(F){console.error("Load withdrawals error:",F),c("加载失败,请检查网络后重试")}finally{i(!1)}}b.useEffect(()=>{m(1)},[u]),b.useEffect(()=>{V()},[u,f,g]);const A=Math.ceil(v/g)||1;async function X(K){const $=t.find(D=>D.id===K);if($!=null&&$.userCommissionInfo&&$.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${$.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。
确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;k(K);try{const D=await Jt("/api/admin/withdrawals",{id:K,action:"approve"});D!=null&&D.success?V():oe.error("操作失败: "+((D==null?void 0:D.error)??""))}catch{oe.error("操作失败")}finally{k(null)}}function G(K){C(K),O("")}async function z(){const K=E;if(!K)return;const $=P.trim();if(!$){oe.error("请填写拒绝原因");return}_(!0);try{const D=await Jt("/api/admin/withdrawals",{id:K,action:"reject",errorMessage:$});D!=null&&D.success?(oe.success("已拒绝该提现申请"),C(null),O(""),V()):oe.error("操作失败: "+((D==null?void 0:D.error)??""))}catch{oe.error("操作失败")}finally{_(!1)}}function ne(){E&&oe.info("已取消操作"),C(null),O("")}function ue(K){switch(K){case"pending":return r.jsx(Ge,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return r.jsx(Ge,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return r.jsx(Ge,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return r.jsx(Ge,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return r.jsx(Ge,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return r.jsx(Ge,{className:"bg-gray-500/20 text-gray-400 border-0",children:K})}}return r.jsxs("div",{className:"p-8 w-full",children:[o&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:o}),r.jsx("button",{type:"button",onClick:()=>c(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-start mb-8",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-white",children:"分账提现管理"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"管理用户分销收益的提现申请"})]}),r.jsxs(Y,{variant:"outline",onClick:V,disabled:a,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Oe,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:r.jsx(Le,{className:"p-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(Uh,{className:"w-5 h-5 text-[#38bdac] mt-0.5"}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-white font-medium mb-2",children:"自动分账规则"}),r.jsxs("div",{className:"text-sm text-gray-400 space-y-1",children:[r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"分销比例"}),":推广者获得订单金额的"," ",r.jsx("span",{className:"text-white font-medium",children:"90%"})]}),r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"结算方式"}),":用户付款后,分销收益自动计入推广者账户"]}),r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"提现方式"}),":用户在小程序端点击提现,系统自动转账到微信零钱"]}),r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"审批流程"}),":待处理的提现需管理员手动确认打款后批准(自动审批开关在推广中心-提现审核)"]})]})]})]})})}),r.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Le,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-[#38bdac]",children:n.total}),r.jsx("div",{className:"text-sm text-gray-400",children:"总申请"})]})}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Le,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-orange-400",children:n.pendingCount}),r.jsx("div",{className:"text-sm text-gray-400",children:"待处理"}),r.jsxs("div",{className:"text-xs text-orange-400 mt-1",children:["¥",n.pendingAmount.toFixed(2)]})]})}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Le,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-green-400",children:n.successCount}),r.jsx("div",{className:"text-sm text-gray-400",children:"已完成"}),r.jsxs("div",{className:"text-xs text-green-400 mt-1",children:["¥",n.successAmount.toFixed(2)]})]})}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Le,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-red-400",children:n.failedCount}),r.jsx("div",{className:"text-sm text-gray-400",children:"已拒绝"})]})})]}),r.jsx("div",{className:"flex gap-2 mb-4",children:["all","pending","success","failed"].map(K=>r.jsx(Y,{variant:u===K?"default":"outline",size:"sm",onClick:()=>h(K),className:u===K?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:K==="all"?"全部":K==="pending"?"待处理":K==="success"?"已完成":"已拒绝"},K))}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Le,{className:"p-0",children:a?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Be,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):t.length===0?r.jsxs("div",{className:"text-center py-12",children:[r.jsx(gc,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),r.jsx("p",{className:"text-gray-500",children:"暂无提现记录"})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"提现金额"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"用户佣金信息"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"备注"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"处理时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"确认收款"}),r.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:t.map(K=>r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsx("td",{className:"p-4 text-gray-400",children:new Date(K.createdAt??"").toLocaleString()}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{className:"flex items-center gap-2",children:[K.userAvatar?r.jsx("img",{src:io(K.userAvatar),alt:K.userName??"",className:"w-8 h-8 rounded-full object-cover"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:(K.userName??"?").charAt(0)}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-white",children:K.userName??"未知"}),r.jsx("p",{className:"text-xs text-gray-500",children:K.userPhone??K.referralCode??(K.userId??"").slice(0,10)})]})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(K.amount).toFixed(2)]})}),r.jsx("td",{className:"p-4",children:K.userCommissionInfo?r.jsxs("div",{className:"text-xs space-y-1",children:[r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{className:"text-gray-500",children:"累计佣金:"}),r.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",K.userCommissionInfo.totalCommission.toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{className:"text-gray-500",children:"已提现:"}),r.jsxs("span",{className:"text-gray-400",children:["¥",K.userCommissionInfo.withdrawnEarnings.toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{className:"text-gray-500",children:"待审核:"}),r.jsxs("span",{className:"text-orange-400",children:["¥",K.userCommissionInfo.pendingWithdrawals.toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between gap-4 pt-1 border-t border-gray-700/30",children:[r.jsx("span",{className:"text-gray-500",children:"审核后余额:"}),r.jsxs("span",{className:K.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",K.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):r.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),r.jsx("td",{className:"p-4",children:ue(K.status)}),r.jsx("td",{className:"p-4 max-w-[180px]",children:r.jsx("span",{className:`text-xs ${K.status==="rejected"||K.status==="failed"?"text-red-400":"text-gray-400"}`,title:K.remark,children:K.remark||"-"})}),r.jsx("td",{className:"p-4 text-gray-400",children:K.processedAt?new Date(K.processedAt).toLocaleString():"-"}),r.jsx("td",{className:"p-4 text-gray-400",children:K.userConfirmedAt?r.jsxs("span",{className:"text-green-400",title:K.userConfirmedAt,children:["已确认 ",new Date(K.userConfirmedAt).toLocaleString()]}):"-"}),r.jsxs("td",{className:"p-4 text-right",children:[(K.status==="pending"||K.status==="pending_confirm")&&r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[r.jsxs(Y,{size:"sm",onClick:()=>X(K.id),disabled:N===K.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[r.jsx(Qf,{className:"w-4 h-4 mr-1"}),"批准"]}),r.jsxs(Y,{size:"sm",variant:"outline",onClick:()=>G(K.id),disabled:N===K.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[r.jsx(us,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(K.status==="success"||K.status==="completed")&&K.transactionId&&r.jsx("span",{className:"text-xs text-gray-500 font-mono",children:K.transactionId})]})]},K.id))})]})}),r.jsx(Gs,{page:f,totalPages:A,total:v,pageSize:g,onPageChange:m,onPageSizeChange:K=>{y(K),m(1)}})]})})}),r.jsx(Ht,{open:!!E,onOpenChange:K=>!K&&ne(),children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Ut,{children:r.jsx(Wt,{className:"text-white",children:"拒绝提现"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),r.jsx("div",{className:"form-input",children:r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:P,onChange:K=>O(K.target.value)})})]})]}),r.jsxs(xn,{children:[r.jsx(Y,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:ne,disabled:U,children:"取消"}),r.jsx(Y,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:z,disabled:U||!P.trim(),children:U?"提交中...":"确认拒绝"})]})]})})]})}var mg={exports:{}},gg={};/**
* @license React
* use-sync-external-store-shim.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var M1;function sO(){if(M1)return gg;M1=1;var t=eu();function e(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:e,s=t.useState,a=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function c(m,g){var y=g(),v=s({inst:{value:y,getSnapshot:g}}),w=v[0].inst,N=v[1];return i(function(){w.value=y,w.getSnapshot=g,u(w)&&N({inst:w})},[m,y,g]),a(function(){return u(w)&&N({inst:w}),m(function(){u(w)&&N({inst:w})})},[m]),o(y),y}function u(m){var g=m.getSnapshot;m=m.value;try{var y=g();return!n(m,y)}catch{return!0}}function h(m,g){return g()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return gg.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,gg}var A1;function rS(){return A1||(A1=1,mg.exports=sO()),mg.exports}var aS=rS();function ls(t){this.content=t}ls.prototype={constructor:ls,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var s=n&&n!=t?this.remove(n):this,a=s.find(t),i=s.content.slice();return a==-1?i.push(n||t,e):(i[a+1]=e,n&&(i[a]=n)),new ls(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new ls(n)},addToStart:function(t,e){return new ls([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new ls(n)},addBefore:function(t,e,n){var s=this.remove(e),a=s.content.slice(),i=s.find(t);return a.splice(i==-1?a.length:i,0,e,n),new ls(a)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=ls.from(t),t.size?new ls(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=ls.from(t),t.size?new ls(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ls.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};ls.from=function(t){if(t instanceof ls)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ls(e)};function iS(t,e,n){for(let s=0;;s++){if(s==t.childCount||s==e.childCount)return t.childCount==e.childCount?null:n;let a=t.child(s),i=e.child(s);if(a==i){n+=a.nodeSize;continue}if(!a.sameMarkup(i))return n;if(a.isText&&a.text!=i.text){for(let o=0;a.text[o]==i.text[o];o++)n++;return n}if(a.content.size||i.content.size){let o=iS(a.content,i.content,n+1);if(o!=null)return o}n+=a.nodeSize}}function oS(t,e,n,s){for(let a=t.childCount,i=e.childCount;;){if(a==0||i==0)return a==i?null:{a:n,b:s};let o=t.child(--a),c=e.child(--i),u=o.nodeSize;if(o==c){n-=u,s-=u;continue}if(!o.sameMarkup(c))return{a:n,b:s};if(o.isText&&o.text!=c.text){let h=0,f=Math.min(o.text.length,c.text.length);for(;h<f&&o.text[o.text.length-h-1]==c.text[c.text.length-h-1];)h++,n--,s--;return{a:n,b:s}}if(o.content.size||c.content.size){let h=oS(o.content,c.content,n-1,s-1);if(h)return h}n-=u,s-=u}}class we{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let s=0;s<e.length;s++)this.size+=e[s].nodeSize}nodesBetween(e,n,s,a=0,i){for(let o=0,c=0;c<n;o++){let u=this.content[o],h=c+u.nodeSize;if(h>e&&s(u,a+c,i||null,o)!==!1&&u.content.size){let f=c+1;u.nodesBetween(Math.max(0,e-f),Math.min(u.content.size,n-f),s,a+f)}c=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,s,a){let i="",o=!0;return this.nodesBetween(e,n,(c,u)=>{let h=c.isText?c.text.slice(Math.max(e,u)-u,n-u):c.isLeaf?a?typeof a=="function"?a(c):a:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&h||c.isTextblock)&&s&&(o?o=!1:i+=s),i+=h},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,s=e.firstChild,a=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(s)&&(a[a.length-1]=n.withText(n.text+s.text),i=1);i<e.content.length;i++)a.push(e.content[i]);return new we(a,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let s=[],a=0;if(n>e)for(let i=0,o=0;o<n;i++){let c=this.content[i],u=o+c.nodeSize;u>e&&((o<e||u>n)&&(c.isText?c=c.cut(Math.max(0,e-o),Math.min(c.text.length,n-o)):c=c.cut(Math.max(0,e-o-1),Math.min(c.content.size,n-o-1))),s.push(c),a+=c.nodeSize),o=u}return new we(s,a)}cutByIndex(e,n){return e==n?we.empty:e==0&&n==this.content.length?this:new we(this.content.slice(e,n))}replaceChild(e,n){let s=this.content[e];if(s==n)return this;let a=this.content.slice(),i=this.size+n.nodeSize-s.nodeSize;return a[e]=n,new we(a,i)}addToStart(e){return new we([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new we(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,s=0;n<this.content.length;n++){let a=this.content[n];e(a,s,n),s+=a.nodeSize}}findDiffStart(e,n=0){return iS(this,e,n)}findDiffEnd(e,n=this.size,s=e.size){return oS(this,e,n,s)}findIndex(e){if(e==0)return gh(0,e);if(e==this.size)return gh(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,s=0;;n++){let a=this.child(n),i=s+a.nodeSize;if(i>=e)return i==e?gh(n+1,i):gh(n,s);s=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return we.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new we(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return we.empty;let n,s=0;for(let a=0;a<e.length;a++){let i=e[a];s+=i.nodeSize,a&&i.isText&&e[a-1].sameMarkup(i)?(n||(n=e.slice(0,a)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new we(n||e,s)}static from(e){if(!e)return we.empty;if(e instanceof we)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new we([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}we.empty=new we([],0);const xg={index:0,offset:0};function gh(t,e){return xg.index=t,xg.offset=e,xg}function ef(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let s=0;s<t.length;s++)if(!ef(t[s],e[s]))return!1}else{for(let s in t)if(!(s in e)||!ef(t[s],e[s]))return!1;for(let s in e)if(!(s in t))return!1}return!0}let Qt=class gx{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,s=!1;for(let a=0;a<e.length;a++){let i=e[a];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,a));else{if(i.type.excludes(this.type))return e;!s&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,a)),n.push(this),s=!0),n&&n.push(i)}}return n||(n=e.slice()),s||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ef(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let s=e.marks[n.type];if(!s)throw new RangeError(`There is no mark type ${n.type} in this schema`);let a=s.create(n.attrs);return s.checkAttrs(a.attrs),a}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let s=0;s<e.length;s++)if(!e[s].eq(n[s]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return gx.none;if(e instanceof gx)return[e];let n=e.slice();return n.sort((s,a)=>s.type.rank-a.type.rank),n}};Qt.none=[];class tf extends Error{}class ze{constructor(e,n,s){this.content=e,this.openStart=n,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let s=cS(this.content,e+this.openStart,n);return s&&new ze(s,this.openStart,this.openEnd)}removeBetween(e,n){return new ze(lS(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ze.empty;let s=n.openStart||0,a=n.openEnd||0;if(typeof s!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ze(we.fromJSON(e,n.content),s,a)}static maxOpen(e,n=!0){let s=0,a=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)s++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)a++;return new ze(e,s,a)}}ze.empty=new ze(we.empty,0,0);function lS(t,e,n){let{index:s,offset:a}=t.findIndex(e),i=t.maybeChild(s),{index:o,offset:c}=t.findIndex(n);if(a==e||i.isText){if(c!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(s!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(s,i.copy(lS(i.content,e-a-1,n-a-1)))}function cS(t,e,n,s){let{index:a,offset:i}=t.findIndex(e),o=t.maybeChild(a);if(i==e||o.isText)return s&&!s.canReplace(a,a,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=cS(o.content,e-i-1,n,o);return c&&t.replaceChild(a,o.copy(c))}function rO(t,e,n){if(n.openStart>t.depth)throw new tf("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new tf("Inconsistent open depths");return dS(t,e,n,0)}function dS(t,e,n,s){let a=t.index(s),i=t.node(s);if(a==e.index(s)&&s<t.depth-n.openStart){let o=dS(t,e,n,s+1);return i.copy(i.content.replaceChild(a,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==s&&e.depth==s){let o=t.parent,c=o.content;return sl(o,c.cut(0,t.parentOffset).append(n.content).append(c.cut(e.parentOffset)))}else{let{start:o,end:c}=aO(n,t);return sl(i,hS(t,o,c,e,s))}else return sl(i,nf(t,e,s))}function uS(t,e){if(!e.type.compatibleContent(t.type))throw new tf("Cannot join "+e.type.name+" onto "+t.type.name)}function xx(t,e,n){let s=t.node(n);return uS(s,e.node(n)),s}function nl(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Cd(t,e,n,s){let a=(e||t).node(n),i=0,o=e?e.index(n):a.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(nl(t.nodeAfter,s),i++));for(let c=i;c<o;c++)nl(a.child(c),s);e&&e.depth==n&&e.textOffset&&nl(e.nodeBefore,s)}function sl(t,e){return t.type.checkContent(e),t.copy(e)}function hS(t,e,n,s,a){let i=t.depth>a&&xx(t,e,a+1),o=s.depth>a&&xx(n,s,a+1),c=[];return Cd(null,t,a,c),i&&o&&e.index(a)==n.index(a)?(uS(i,o),nl(sl(i,hS(t,e,n,s,a+1)),c)):(i&&nl(sl(i,nf(t,e,a+1)),c),Cd(e,n,a,c),o&&nl(sl(o,nf(n,s,a+1)),c)),Cd(s,null,a,c),new we(c)}function nf(t,e,n){let s=[];if(Cd(null,t,n,s),t.depth>n){let a=xx(t,e,n+1);nl(sl(a,nf(t,e,n+1)),s)}return Cd(e,null,n,s),new we(s)}function aO(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(we.from(a));return{start:a.resolveNoCache(t.openStart+n),end:a.resolveNoCache(a.content.size-t.openEnd-n)}}class Bd{constructor(e,n,s){this.pos=e,this.path=n,this.parentOffset=s,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let s=this.pos-this.path[this.path.length-1],a=e.child(n);return s?e.child(n).cut(s):a}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let s=this.path[n*3],a=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)a+=s.child(i).nodeSize;return a}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Qt.none;if(this.textOffset)return e.child(n).marks;let s=e.maybeChild(n-1),a=e.maybeChild(n);if(!s){let c=s;s=a,a=c}let i=s.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!a||!i[o].isInSet(a.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let s=n.marks,a=e.parent.maybeChild(e.index());for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!a||!s[i].isInSet(a.marks))&&(s=s[i--].removeFromSet(s));return s}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let s=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);s>=0;s--)if(e.pos<=this.end(s)&&(!n||n(this.node(s))))return new sf(this,e,s);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let s=[],a=0,i=n;for(let o=e;;){let{index:c,offset:u}=o.content.findIndex(i),h=i-u;if(s.push(o,c,a+u),!h||(o=o.child(c),o.isText))break;i=h-1,a+=u+1}return new Bd(n,s,i)}static resolveCached(e,n){let s=I1.get(e);if(s)for(let i=0;i<s.elts.length;i++){let o=s.elts[i];if(o.pos==n)return o}else I1.set(e,s=new iO);let a=s.elts[s.i]=Bd.resolve(e,n);return s.i=(s.i+1)%oO,a}}class iO{constructor(){this.elts=[],this.i=0}}const oO=12,I1=new WeakMap;class sf{constructor(e,n,s){this.$from=e,this.$to=n,this.depth=s}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const lO=Object.create(null);let oi=class yx{constructor(e,n,s,a=Qt.none){this.type=e,this.attrs=n,this.marks=a,this.content=s||we.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,s,a=0){this.content.nodesBetween(e,n,s,a,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,s,a){return this.content.textBetween(e,n,s,a)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,s){return this.type==e&&ef(this.attrs,n||e.defaultAttrs||lO)&&Qt.sameSet(this.marks,s||Qt.none)}copy(e=null){return e==this.content?this:new yx(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new yx(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,s=!1){if(e==n)return ze.empty;let a=this.resolve(e),i=this.resolve(n),o=s?0:a.sharedDepth(n),c=a.start(o),h=a.node(o).content.cut(a.pos-c,i.pos-c);return new ze(h,a.depth-o,i.depth-o)}replace(e,n,s){return rO(this.resolve(e),this.resolve(n),s)}nodeAt(e){for(let n=this;;){let{index:s,offset:a}=n.content.findIndex(e);if(n=n.maybeChild(s),!n)return null;if(a==e||n.isText)return n;e-=a+1}}childAfter(e){let{index:n,offset:s}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:s}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:s}=this.content.findIndex(e);if(s<e)return{node:this.content.child(n),index:n,offset:s};let a=this.content.child(n-1);return{node:a,index:n-1,offset:s-a.nodeSize}}resolve(e){return Bd.resolveCached(this,e)}resolveNoCache(e){return Bd.resolve(this,e)}rangeHasMark(e,n,s){let a=!1;return n>e&&this.nodesBetween(e,n,i=>(s.isInSet(i.marks)&&(a=!0),!a)),a}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),fS(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,s=we.empty,a=0,i=s.childCount){let o=this.contentMatchAt(e).matchFragment(s,a,i),c=o&&o.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let u=a;u<i;u++)if(!this.type.allowsMarks(s.child(u).marks))return!1;return!0}canReplaceWith(e,n,s,a){if(a&&!this.type.allowsMarks(a))return!1;let i=this.contentMatchAt(e).matchType(s),o=i&&i.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Qt.none;for(let n=0;n<this.marks.length;n++){let s=this.marks[n];s.type.checkAttrs(s.attrs),e=s.addToSet(e)}if(!Qt.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let s;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,s)}let a=we.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,a,s);return i.type.checkAttrs(i.attrs),i}};oi.prototype.text=void 0;class rf extends oi{constructor(e,n,s,a){if(super(e,n,null,a),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):fS(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 rf(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new rf(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 fS(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class dl{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let s=new cO(e,n);if(s.next==null)return dl.empty;let a=pS(s);s.next&&s.err("Unexpected trailing text");let i=gO(mO(a));return xO(i,s),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,s=e.childCount){let a=this;for(let i=n;a&&i<s;i++)a=a.matchType(e.child(i).type);return a}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let s=0;s<e.next.length;s++)if(this.next[n].type==e.next[s].type)return!0;return!1}fillBefore(e,n=!1,s=0){let a=[this];function i(o,c){let u=o.matchFragment(e,s);if(u&&(!n||u.validEnd))return we.from(c.map(h=>h.createAndFill()));for(let h=0;h<o.next.length;h++){let{type:f,next:m}=o.next[h];if(!(f.isText||f.hasRequiredAttrs())&&a.indexOf(m)==-1){a.push(m);let g=i(m,c.concat(f));if(g)return g}}return null}return i(this,[])}findWrapping(e){for(let s=0;s<this.wrapCache.length;s+=2)if(this.wrapCache[s]==e)return this.wrapCache[s+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),s=[{match:this,type:null,via:null}];for(;s.length;){let a=s.shift(),i=a.match;if(i.matchType(e)){let o=[];for(let c=a;c.type;c=c.via)o.push(c.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:c,next:u}=i.next[o];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in n)&&(!a.type||u.validEnd)&&(s.push({match:c.contentMatch,type:c,via:a}),n[c.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(s){e.push(s);for(let a=0;a<s.next.length;a++)e.indexOf(s.next[a].next)==-1&&n(s.next[a].next)}return n(this),e.map((s,a)=>{let i=a+(s.validEnd?"*":" ")+" ";for(let o=0;o<s.next.length;o++)i+=(o?", ":"")+s.next[o].type.name+"->"+e.indexOf(s.next[o].next);return i}).join(`
`)}}dl.empty=new dl(!0);class cO{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 pS(t){let e=[];do e.push(dO(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function dO(t){let e=[];do e.push(uO(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function uO(t){let e=pO(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=hO(t,e);else break;return e}function R1(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function hO(t,e){let n=R1(t),s=n;return t.eat(",")&&(t.next!="}"?s=R1(t):s=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:s,expr:e}}function fO(t,e){let n=t.nodeTypes,s=n[e];if(s)return[s];let a=[];for(let i in n){let o=n[i];o.isInGroup(e)&&a.push(o)}return a.length==0&&t.err("No node type or group '"+e+"' found"),a}function pO(t){if(t.eat("(")){let e=pS(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=fO(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 mO(t){let e=[[]];return a(i(t,0),n()),e;function n(){return e.push([])-1}function s(o,c,u){let h={term:u,to:c};return e[o].push(h),h}function a(o,c){o.forEach(u=>u.to=c)}function i(o,c){if(o.type=="choice")return o.exprs.reduce((u,h)=>u.concat(i(h,c)),[]);if(o.type=="seq")for(let u=0;;u++){let h=i(o.exprs[u],c);if(u==o.exprs.length-1)return h;a(h,c=n())}else if(o.type=="star"){let u=n();return s(c,u),a(i(o.expr,u),u),[s(u)]}else if(o.type=="plus"){let u=n();return a(i(o.expr,c),u),a(i(o.expr,u),u),[s(u)]}else{if(o.type=="opt")return[s(c)].concat(i(o.expr,c));if(o.type=="range"){let u=c;for(let h=0;h<o.min;h++){let f=n();a(i(o.expr,u),f),u=f}if(o.max==-1)a(i(o.expr,u),u);else for(let h=o.min;h<o.max;h++){let f=n();s(u,f),a(i(o.expr,u),f),u=f}return[s(u)]}else{if(o.type=="name")return[s(c,void 0,o.value)];throw new Error("Unknown expr type")}}}}function mS(t,e){return e-t}function P1(t,e){let n=[];return s(e),n.sort(mS);function s(a){let i=t[a];if(i.length==1&&!i[0].term)return s(i[0].to);n.push(a);for(let o=0;o<i.length;o++){let{term:c,to:u}=i[o];!c&&n.indexOf(u)==-1&&s(u)}}}function gO(t){let e=Object.create(null);return n(P1(t,0));function n(s){let a=[];s.forEach(o=>{t[o].forEach(({term:c,to:u})=>{if(!c)return;let h;for(let f=0;f<a.length;f++)a[f][0]==c&&(h=a[f][1]);P1(t,u).forEach(f=>{h||a.push([c,h=[]]),h.indexOf(f)==-1&&h.push(f)})})});let i=e[s.join(",")]=new dl(s.indexOf(t.length-1)>-1);for(let o=0;o<a.length;o++){let c=a[o][1].sort(mS);i.next.push({type:a[o][0],next:e[c.join(",")]||n(c)})}return i}}function xO(t,e){for(let n=0,s=[t];n<s.length;n++){let a=s[n],i=!a.validEnd,o=[];for(let c=0;c<a.next.length;c++){let{type:u,next:h}=a.next[c];o.push(u.name),i&&!(u.isText||u.hasRequiredAttrs())&&(i=!1),s.indexOf(h)==-1&&s.push(h)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function gS(t){let e=Object.create(null);for(let n in t){let s=t[n];if(!s.hasDefault)return null;e[n]=s.default}return e}function xS(t,e){let n=Object.create(null);for(let s in t){let a=e&&e[s];if(a===void 0){let i=t[s];if(i.hasDefault)a=i.default;else throw new RangeError("No value supplied for attribute "+s)}n[s]=a}return n}function yS(t,e,n,s){for(let a in e)if(!(a in t))throw new RangeError(`Unsupported attribute ${a} for ${n} of type ${a}`);for(let a in t){let i=t[a];i.validate&&i.validate(e[a])}}function bS(t,e){let n=Object.create(null);if(e)for(let s in e)n[s]=new bO(t,s,e[s]);return n}let O1=class vS{constructor(e,n,s){this.name=e,this.schema=n,this.spec=s,this.markSet=null,this.groups=s.group?s.group.split(" "):[],this.attrs=bS(e,s.attrs),this.defaultAttrs=gS(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(s.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==dl.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-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:xS(this.attrs,e)}create(e=null,n,s){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new oi(this,this.computeAttrs(e),we.from(n),Qt.setFrom(s))}createChecked(e=null,n,s){return n=we.from(n),this.checkContent(n),new oi(this,this.computeAttrs(e),n,Qt.setFrom(s))}createAndFill(e=null,n,s){if(e=this.computeAttrs(e),n=we.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(we.empty,!0);return i?new oi(this,e,n.append(i),Qt.setFrom(s)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let s=0;s<e.childCount;s++)if(!this.allowsMarks(e.child(s).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){yS(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let s=0;s<e.length;s++)this.allowsMarkType(e[s].type)?n&&n.push(e[s]):n||(n=e.slice(0,s));return n?n.length?n:Qt.none:e}static compile(e,n){let s=Object.create(null);e.forEach((i,o)=>s[i]=new vS(i,n,o));let a=n.spec.topNode||"doc";if(!s[a])throw new RangeError("Schema is missing its top node type ('"+a+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let i in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function yO(t,e,n){let s=n.split("|");return a=>{let i=a===null?"null":typeof a;if(s.indexOf(i)<0)throw new RangeError(`Expected value of type ${s} for attribute ${e} on type ${t}, got ${i}`)}}class bO{constructor(e,n,s){this.hasDefault=Object.prototype.hasOwnProperty.call(s,"default"),this.default=s.default,this.validate=typeof s.validate=="string"?yO(e,n,s.validate):s.validate}get isRequired(){return!this.hasDefault}}class ap{constructor(e,n,s,a){this.name=e,this.rank=n,this.schema=s,this.spec=a,this.attrs=bS(e,a.attrs),this.excluded=null;let i=gS(this.attrs);this.instance=i?new Qt(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Qt(this,xS(this.attrs,e))}static compile(e,n){let s=Object.create(null),a=0;return e.forEach((i,o)=>s[i]=new ap(i,a++,n,o)),s}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){yS(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class NS{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=ls.from(e.nodes),n.marks=ls.from(e.marks||{}),this.nodes=O1.compile(this.spec.nodes,this),this.marks=ap.compile(this.spec.marks,this);let s=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw new RangeError(a+" can not be both a node and a mark");let i=this.nodes[a],o=i.spec.content||"",c=i.spec.marks;if(i.contentMatch=s[o]||(s[o]=dl.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?L1(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==""?[]:L1(this,o.split(" "))}this.nodeFromJSON=a=>oi.fromJSON(this,a),this.markFromJSON=a=>Qt.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,s,a){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof O1){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,s,a)}text(e,n){let s=this.nodes.text;return new rf(s,s.defaultAttrs,e,Qt.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 L1(t,e){let n=[];for(let s=0;s<e.length;s++){let a=e[s],i=t.marks[a],o=i;if(i)n.push(i);else for(let c in t.marks){let u=t.marks[c];(a=="_"||u.spec.group&&u.spec.group.split(" ").indexOf(a)>-1)&&n.push(o=u)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[s]+"'")}return n}function vO(t){return t.tag!=null}function NO(t){return t.style!=null}class eo{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let s=this.matchedStyles=[];n.forEach(a=>{if(vO(a))this.tags.push(a);else if(NO(a)){let i=/[^=]*/.exec(a.style)[0];s.indexOf(i)<0&&s.push(i),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(a=>{if(!/^(ul|ol)\b/.test(a.tag)||!a.node)return!1;let i=e.nodes[a.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let s=new _1(this,n,!1);return s.addAll(e,Qt.none,n.from,n.to),s.finish()}parseSlice(e,n={}){let s=new _1(this,n,!0);return s.addAll(e,Qt.none,n.from,n.to),ze.maxOpen(s.finish())}matchTag(e,n,s){for(let a=s?this.tags.indexOf(s)+1:0;a<this.tags.length;a++){let i=this.tags[a];if(kO(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,s,a){for(let i=a?this.styles.indexOf(a)+1:0;i<this.styles.length;i++){let o=this.styles[i],c=o.style;if(!(c.indexOf(e)!=0||o.context&&!s.matchesContext(o.context)||c.length>e.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=n))){if(o.getAttrs){let u=o.getAttrs(n);if(u===!1)continue;o.attrs=u||void 0}return o}}}static schemaRules(e){let n=[];function s(a){let i=a.priority==null?50:a.priority,o=0;for(;o<n.length;o++){let c=n[o];if((c.priority==null?50:c.priority)<i)break}n.splice(o,0,a)}for(let a in e.marks){let i=e.marks[a].spec.parseDOM;i&&i.forEach(o=>{s(o=z1(o)),o.mark||o.ignore||o.clearMark||(o.mark=a)})}for(let a in e.nodes){let i=e.nodes[a].spec.parseDOM;i&&i.forEach(o=>{s(o=z1(o)),o.node||o.ignore||o.mark||(o.node=a)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new eo(e,eo.schemaRules(e)))}}const wS={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},wO={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},jS={ol:!0,ul:!0},Vd=1,bx=2,Ed=4;function D1(t,e,n){return e!=null?(e?Vd:0)|(e==="full"?bx:0):t&&t.whitespace=="pre"?Vd|bx:n&~Ed}class xh{constructor(e,n,s,a,i,o){this.type=e,this.attrs=n,this.marks=s,this.solid=a,this.options=o,this.content=[],this.activeMarks=Qt.none,this.match=i||(o&Ed?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(we.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let s=this.type.contentMatch,a;return(a=s.findWrapping(e.type))?(this.match=s,a):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Vd)){let s=this.content[this.content.length-1],a;if(s&&s.isText&&(a=/[ \t\r\n\u000c]+$/.exec(s.text))){let i=s;s.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-a[0].length))}}let n=we.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(we.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&&!wS.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class _1{constructor(e,n,s){this.parser=e,this.options=n,this.isOpen=s,this.open=0,this.localPreserveWS=!1;let a=n.topNode,i,o=D1(null,n.preserveWhitespace,0)|(s?Ed:0);a?i=new xh(a.type,a.attrs,Qt.none,!0,n.topMatch||a.type.contentMatch,o):s?i=new xh(null,null,Qt.none,!0,null,o):i=new xh(e.schema.topNodeType,null,Qt.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let s=e.nodeValue,a=this.top,i=a.options&bx?"full":this.localPreserveWS||(a.options&Vd)>0,{schema:o}=this.parser;if(i==="full"||a.inlineContext(e)||/[^ \t\r\n\u000c]/.test(s)){if(i)if(i==="full")s=s.replace(/\r\n?/g,`
`);else if(o.linebreakReplacement&&/[\r\n]/.test(s)&&this.top.findWrapping(o.linebreakReplacement.create())){let c=s.split(/\r?\n|\r/);for(let u=0;u<c.length;u++)u&&this.insertNode(o.linebreakReplacement.create(),n,!0),c[u]&&this.insertNode(o.text(c[u]),n,!/\S/.test(c[u]));s=""}else s=s.replace(/\r?\n|\r/g," ");else if(s=s.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(s)&&this.open==this.nodes.length-1){let c=a.content[a.content.length-1],u=e.previousSibling;(!c||u&&u.nodeName=="BR"||c.isText&&/[ \t\r\n\u000c]$/.test(c.text))&&(s=s.slice(1))}s&&this.insertNode(o.text(s),n,!/\S/.test(s)),this.findInText(e)}else this.findInside(e)}addElement(e,n,s){let a=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),c;jS.hasOwnProperty(o)&&this.parser.normalizeLists&&jO(e);let u=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(c=this.parser.matchTag(e,this,s));e:if(u?u.ignore:wO.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!u||u.skip||u.closeParent){u&&u.closeParent?this.open=Math.max(0,this.open-1):u&&u.skip.nodeType&&(e=u.skip);let h,f=this.needsBlock;if(wS.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),h=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let m=u&&u.skip?n:this.readStyles(e,n);m&&this.addAll(e,m),h&&this.sync(i),this.needsBlock=f}else{let h=this.readStyles(e,n);h&&this.addElementByRule(e,u,h,u.consuming===!1?c:void 0)}this.localPreserveWS=a}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let s=e.style;if(s&&s.length)for(let a=0;a<this.parser.matchedStyles.length;a++){let i=this.parser.matchedStyles[a],o=s.getPropertyValue(i);if(o)for(let c=void 0;;){let u=this.parser.matchStyle(i,o,this,c);if(!u)break;if(u.ignore)return null;if(u.clearMark?n=n.filter(h=>!u.clearMark(h)):n=n.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)c=u;else break}}return n}addElementByRule(e,n,s,a){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),s,e.nodeName=="BR")||this.leafFallback(e,s);else{let u=this.enter(o,n.attrs||null,s,n.preserveWhitespace);u&&(i=!0,s=u)}else{let u=this.parser.schema.marks[n.mark];s=s.concat(u.create(n.attrs))}let c=this.top;if(o&&o.isLeaf)this.findInside(e);else if(a)this.addElement(e,s,a);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,s,!1));else{let u=e;typeof n.contentElement=="string"?u=e.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(e):n.contentElement&&(u=n.contentElement),this.findAround(e,u,!0),this.addAll(u,s),this.findAround(e,u,!1)}i&&this.sync(c)&&this.open--}addAll(e,n,s,a){let i=s||0;for(let o=s?e.childNodes[s]:e.firstChild,c=a==null?null:e.childNodes[a];o!=c;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,s){let a,i;for(let o=this.open,c=0;o>=0;o--){let u=this.nodes[o],h=u.findWrapping(e);if(h&&(!a||a.length>h.length+c)&&(a=h,i=u,!h.length))break;if(u.solid){if(s)break;c+=2}}if(!a)return null;this.sync(i);for(let o=0;o<a.length;o++)n=this.enterInner(a[o],null,n,!1);return n}insertNode(e,n,s){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let a=this.findPlace(e,n,s);if(a){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=Qt.none;for(let c of a.concat(e.marks))(i.type?i.type.allowsMarkType(c.type):$1(c.type,e.type))&&(o=c.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,s,a){let i=this.findPlace(e.create(n),s,!1);return i&&(i=this.enterInner(e,n,s,!0,a)),i}enterInner(e,n,s,a=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let c=D1(e,i,o.options);o.options&Ed&&o.content.length==0&&(c|=Ed);let u=Qt.none;return s=s.filter(h=>(o.type?o.type.allowsMarkType(h.type):$1(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new xh(e,n,u,a,null,c)),this.open++,s}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Vd)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let s=this.nodes[n].content;for(let a=s.length-1;a>=0;a--)e+=s[a].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let s=0;s<this.find.length;s++)this.find[s].node==e&&this.find[s].offset==n&&(this.find[s].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,s){if(e!=n&&this.find)for(let a=0;a<this.find.length;a++)this.find[a].pos==null&&e.nodeType==1&&e.contains(this.find[a].node)&&n.compareDocumentPosition(this.find[a].node)&(s?2:4)&&(this.find[a].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),s=this.options.context,a=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),i=-(s?s.depth+1:0)+(a?0:1),o=(c,u)=>{for(;c>=0;c--){let h=n[c];if(h==""){if(c==n.length-1||c==0)continue;for(;u>=i;u--)if(o(c-1,u))return!0;return!1}else{let f=u>0||u==0&&a?this.nodes[u].type:s&&u>=i?s.node(u-i).type:null;if(!f||f.name!=h&&!f.isInGroup(h))return!1;u--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let n in this.parser.schema.nodes){let s=this.parser.schema.nodes[n];if(s.isTextblock&&s.defaultAttrs)return s}}}function jO(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let s=e.nodeType==1?e.nodeName.toLowerCase():null;s&&jS.hasOwnProperty(s)&&n?(n.appendChild(e),e=n):s=="li"?n=e:s&&(n=null)}}function kO(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function z1(t){let e={};for(let n in t)e[n]=t[n];return e}function $1(t,e){let n=e.schema.nodes;for(let s in n){let a=n[s];if(!a.allowsMarkType(t))continue;let i=[],o=c=>{i.push(c);for(let u=0;u<c.edgeCount;u++){let{type:h,next:f}=c.edge(u);if(h==e||i.indexOf(f)<0&&o(f))return!0}};if(o(a.contentMatch))return!0}}class vl{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},s){s||(s=yg(n).createDocumentFragment());let a=s,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let c=0,u=0;for(;c<i.length&&u<o.marks.length;){let h=o.marks[u];if(!this.marks[h.type.name]){u++;continue}if(!h.eq(i[c][0])||h.type.spec.spanning===!1)break;c++,u++}for(;c<i.length;)a=i.pop()[1];for(;u<o.marks.length;){let h=o.marks[u++],f=this.serializeMark(h,o.isInline,n);f&&(i.push([h,a]),a.appendChild(f.dom),a=f.contentDOM||f.dom)}}a.appendChild(this.serializeNodeInner(o,n))}),s}serializeNodeInner(e,n){let{dom:s,contentDOM:a}=Lh(yg(n),this.nodes[e.type.name](e),null,e.attrs);if(a){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,a)}return s}serializeNode(e,n={}){let s=this.serializeNodeInner(e,n);for(let a=e.marks.length-1;a>=0;a--){let i=this.serializeMark(e.marks[a],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(s),s=i.dom)}return s}serializeMark(e,n,s={}){let a=this.marks[e.type.name];return a&&Lh(yg(s),a(e,n),null,e.attrs)}static renderSpec(e,n,s=null,a){return Lh(e,n,s,a)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new vl(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=F1(e.nodes);return n.text||(n.text=s=>s.text),n}static marksFromSchema(e){return F1(e.marks)}}function F1(t){let e={};for(let n in t){let s=t[n].spec.toDOM;s&&(e[n]=s)}return e}function yg(t){return t.document||window.document}const B1=new WeakMap;function SO(t){let e=B1.get(t);return e===void 0&&B1.set(t,e=CO(t)),e}function CO(t){let e=null;function n(s){if(s&&typeof s=="object")if(Array.isArray(s))if(typeof s[0]=="string")e||(e=[]),e.push(s);else for(let a=0;a<s.length;a++)n(s[a]);else for(let a in s)n(s[a])}return n(t),e}function Lh(t,e,n,s){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let a=e[0],i;if(typeof a!="string")throw new RangeError("Invalid array passed to renderSpec");if(s&&(i=SO(s))&&i.indexOf(e)>-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;m<e.length;m++){let g=e[m];if(g===0){if(m<e.length-1||m>f)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:y,contentDOM:v}=Lh(t,g,n,s);if(u.appendChild(y),v){if(c)throw new RangeError("Multiple content holes");c=v}}}return{dom:u,contentDOM:c}}const kS=65535,SS=Math.pow(2,16);function EO(t,e){return t+e*SS}function V1(t){return t&kS}function TO(t){return(t-(t&kS))/SS}const CS=1,ES=2,Dh=4,TS=8;class vx{constructor(e,n,s){this.pos=e,this.delInfo=n,this.recover=s}get deleted(){return(this.delInfo&TS)>0}get deletedBefore(){return(this.delInfo&(CS|Dh))>0}get deletedAfter(){return(this.delInfo&(ES|Dh))>0}get deletedAcross(){return(this.delInfo&Dh)>0}}class dr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&dr.empty)return dr.empty}recover(e){let n=0,s=V1(e);if(!this.inverted)for(let a=0;a<s;a++)n+=this.ranges[a*3+2]-this.ranges[a*3+1];return this.ranges[s*3]+n+TO(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,s){let a=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?a:0);if(u>e)break;let h=this.ranges[c+i],f=this.ranges[c+o],m=u+h;if(e<=m){let g=h?e==u?-1:e==m?1:n:n,y=u+a+(g<0?0:f);if(s)return y;let v=e==(n<0?u:m)?null:EO(c/3,e-u),w=e==u?ES:e==m?CS:Dh;return(n<0?e!=u:e!=m)&&(w|=TS),new vx(y,w,v)}a+=f-h}return s?e+a:new vx(e+a,0,null)}touches(e,n){let s=0,a=V1(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?s:0);if(u>e)break;let h=this.ranges[c+i],f=u+h;if(e<=f&&c==a*3)return!0;s+=this.ranges[c+o]-h}return!1}forEach(e){let n=this.inverted?2:1,s=this.inverted?1:2;for(let a=0,i=0;a<this.ranges.length;a+=3){let o=this.ranges[a],c=o-(this.inverted?i:0),u=o+(this.inverted?0:i),h=this.ranges[a+n],f=this.ranges[a+s];e(c,c+h,u,u+f),i+=f-h}}invert(){return new dr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?dr.empty:new dr(e<0?[0,-e,0]:[0,0,e])}}dr.empty=new dr([]);class Hd{constructor(e,n,s=0,a=e?e.length:0){this.mirror=n,this.from=s,this.to=a,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Hd(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,s=this._maps.length;n<e._maps.length;n++){let a=e.getMirror(n);this.appendMap(e._maps[n],a!=null&&a<n?s+a:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,s=this._maps.length+e._maps.length;n>=0;n--){let a=e.getMirror(n);this.appendMap(e._maps[n].invert(),a!=null&&a>n?s-a-1:void 0)}}invert(){let e=new Hd;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let s=this.from;s<this.to;s++)e=this._maps[s].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,s){let a=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],c=o.mapResult(e,n);if(c.recover!=null){let u=this.getMirror(i);if(u!=null&&u>i&&u<this.to){i=u,e=this._maps[u].recover(c.recover);continue}}a|=c.delInfo,e=c.pos}return s?e:new vx(e,a,null)}}const bg=Object.create(null);class Ms{getMap(){return dr.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let s=bg[n.stepType];if(!s)throw new RangeError(`No step type ${n.stepType} defined`);return s.fromJSON(e,n)}static jsonID(e,n){if(e in bg)throw new RangeError("Duplicate use of step JSON ID "+e);return bg[e]=n,n.prototype.jsonID=e,n}}class $n{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new $n(e,null)}static fail(e){return new $n(null,e)}static fromReplace(e,n,s,a){try{return $n.ok(e.replace(n,s,a))}catch(i){if(i instanceof tf)return $n.fail(i.message);throw i}}}function A0(t,e,n){let s=[];for(let a=0;a<t.childCount;a++){let i=t.child(a);i.content.size&&(i=i.copy(A0(i.content,e,i))),i.isInline&&(i=e(i,n,a)),s.push(i)}return we.fromArray(s)}class Ji extends Ms{constructor(e,n,s){super(),this.from=e,this.to=n,this.mark=s}apply(e){let n=e.slice(this.from,this.to),s=e.resolve(this.from),a=s.node(s.sharedDepth(this.to)),i=new ze(A0(n.content,(o,c)=>!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),s=e.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new Ji(n.pos,s.pos,this.mark)}merge(e){return e instanceof Ji&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ji(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 Ji(n.from,n.to,e.markFromJSON(n.mark))}}Ms.jsonID("addMark",Ji);class Jr extends Ms{constructor(e,n,s){super(),this.from=e,this.to=n,this.mark=s}apply(e){let n=e.slice(this.from,this.to),s=new ze(A0(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),e),n.openStart,n.openEnd);return $n.fromReplace(e,this.from,this.to,s)}invert(){return new Ji(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new Jr(n.pos,s.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))}}Ms.jsonID("removeMark",Jr);class Yi extends Ms{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 s=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return $n.fromReplace(e,this.pos,this.pos+1,new ze(we.from(s),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let s=this.mark.addToSet(n.marks);if(s.length==n.marks.length){for(let a=0;a<n.marks.length;a++)if(!n.marks[a].isInSet(s))return new Yi(this.pos,n.marks[a]);return new Yi(this.pos,this.mark)}}return new ul(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Yi(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Yi(n.pos,e.markFromJSON(n.mark))}}Ms.jsonID("addNodeMark",Yi);class ul extends Ms{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 s=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return $n.fromReplace(e,this.pos,this.pos+1,new ze(we.from(s),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Yi(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ul(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new ul(n.pos,e.markFromJSON(n.mark))}}Ms.jsonID("removeNodeMark",ul);class Xn extends Ms{constructor(e,n,s,a=!1){super(),this.from=e,this.to=n,this.slice=s,this.structure=a}apply(e){return this.structure&&Nx(e,this.from,this.to)?$n.fail("Structure replace would overwrite content"):$n.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new dr([this.from,this.to-this.from,this.slice.size])}invert(e){return new Xn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return n.deletedAcross&&s.deletedAcross?null:new Xn(n.pos,Math.max(n.pos,s.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Xn)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?ze.empty:new ze(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Xn(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?ze.empty:new ze(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Xn(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};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")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Xn(n.from,n.to,ze.fromJSON(e,n.slice),!!n.structure)}}Ms.jsonID("replace",Xn);class Zn extends Ms{constructor(e,n,s,a,i,o,c=!1){super(),this.from=e,this.to=n,this.gapFrom=s,this.gapTo=a,this.slice=i,this.insert=o,this.structure=c}apply(e){if(this.structure&&(Nx(e,this.from,this.gapFrom)||Nx(e,this.gapTo,this.to)))return $n.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return $n.fail("Gap is not a flat range");let s=this.slice.insertAt(this.insert,n.content);return s?$n.fromReplace(e,this.from,this.to,s):$n.fail("Content does not fit in gap")}getMap(){return new dr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Zn(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1),a=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?s.pos:e.map(this.gapTo,1);return n.deletedAcross&&s.deletedAcross||a<n.pos||i>s.pos?null:new Zn(n.pos,s.pos,a,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Zn(n.from,n.to,n.gapFrom,n.gapTo,ze.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ms.jsonID("replaceAround",Zn);function Nx(t,e,n){let s=t.resolve(e),a=n-e,i=s.depth;for(;a>0&&i>0&&s.indexAfter(i)==s.node(i).childCount;)i--,a--;if(a>0){let o=s.node(i).maybeChild(s.indexAfter(i));for(;a>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,a--}}return!1}function MO(t,e,n,s){let a=[],i=[],o,c;t.doc.nodesBetween(e,n,(u,h,f)=>{if(!u.isInline)return;let m=u.marks;if(!s.isInSet(m)&&f.type.allowsMarkType(s.type)){let g=Math.max(h,e),y=Math.min(h+u.nodeSize,n),v=s.addToSet(m);for(let w=0;w<m.length;w++)m[w].isInSet(v)||(o&&o.to==g&&o.mark.eq(m[w])?o.to=y:a.push(o=new Jr(g,y,m[w])));c&&c.to==g?c.to=y:i.push(c=new Ji(g,y,s))}}),a.forEach(u=>t.step(u)),i.forEach(u=>t.step(u))}function AO(t,e,n,s){let a=[],i=0;t.doc.nodesBetween(e,n,(o,c)=>{if(!o.isInline)return;i++;let u=null;if(s instanceof ap){let h=o.marks,f;for(;f=s.isInSet(h);)(u||(u=[])).push(f),h=f.removeFromSet(h)}else s?s.isInSet(o.marks)&&(u=[s]):u=o.marks;if(u&&u.length){let h=Math.min(c+o.nodeSize,n);for(let f=0;f<u.length;f++){let m=u[f],g;for(let y=0;y<a.length;y++){let v=a[y];v.step==i-1&&m.eq(a[y].style)&&(g=v)}g?(g.to=h,g.step=i):a.push({style:m,from:Math.max(c,e),to:h,step:i})}}}),a.forEach(o=>t.step(new Jr(o.from,o.to,o.style)))}function I0(t,e,n,s=n.contentMatch,a=!0){let i=t.doc.nodeAt(e),o=[],c=e+1;for(let u=0;u<i.childCount;u++){let h=i.child(u),f=c+h.nodeSize,m=s.matchType(h.type);if(!m)o.push(new Xn(c,f,ze.empty));else{s=m;for(let g=0;g<h.marks.length;g++)n.allowsMarkType(h.marks[g].type)||t.step(new Jr(c,f,h.marks[g]));if(a&&h.isText&&n.whitespace!="pre"){let g,y=/\r?\n|\r/g,v;for(;g=y.exec(h.text);)v||(v=new ze(we.from(n.schema.text(" ",n.allowedMarks(h.marks))),0,0)),o.push(new Xn(c+g.index,c+g.index+g[0].length,v))}}c=f}if(!s.validEnd){let u=s.fillBefore(we.empty,!0);t.replace(c,c,new ze(u,0,0))}for(let u=o.length-1;u>=0;u--)t.step(o[u])}function IO(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Rc(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let s=t.depth,a=0,i=0;;--s){let o=t.$from.node(s),c=t.$from.index(s)+a,u=t.$to.indexAfter(s)-i;if(s<t.depth&&o.canReplace(c,u,n))return s;if(s==0||o.type.spec.isolating||!IO(o,c,u))break;c&&(a=1),u<o.childCount&&(i=1)}return null}function RO(t,e,n){let{$from:s,$to:a,depth:i}=e,o=s.before(i+1),c=a.after(i+1),u=o,h=c,f=we.empty,m=0;for(let v=i,w=!1;v>n;v--)w||s.index(v)>0?(w=!0,f=we.from(s.node(v).copy(f)),m++):u--;let g=we.empty,y=0;for(let v=i,w=!1;v>n;v--)w||a.after(v+1)<a.end(v)?(w=!0,g=we.from(a.node(v).copy(g)),y++):h++;t.step(new Zn(u,h,o,c,new ze(f.append(g),m,y),f.size-m,!0))}function R0(t,e,n=null,s=t){let a=PO(t,e),i=a&&OO(s,e);return i?a.map(H1).concat({type:e,attrs:n}).concat(i.map(H1)):null}function H1(t){return{type:t,attrs:null}}function PO(t,e){let{parent:n,startIndex:s,endIndex:a}=t,i=n.contentMatchAt(s).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return n.canReplaceWith(s,a,o)?i:null}function OO(t,e){let{parent:n,startIndex:s,endIndex:a}=t,i=n.child(s),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let u=(o.length?o[o.length-1]:e).contentMatch;for(let h=s;u&&h<a;h++)u=u.matchType(n.child(h).type);return!u||!u.validEnd?null:o}function LO(t,e,n){let s=we.empty;for(let o=n.length-1;o>=0;o--){if(s.size){let c=n[o].type.contentMatch.matchFragment(s);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}s=we.from(n[o].type.create(n[o].attrs,s))}let a=e.start,i=e.end;t.step(new Zn(a,i,a,i,new ze(s,0,0),n.length,!0))}function DO(t,e,n,s,a){if(!s.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,c)=>{let u=typeof a=="function"?a(o):a;if(o.isTextblock&&!o.hasMarkup(s,u)&&_O(t.doc,t.mapping.slice(i).map(c),s)){let h=null;if(s.schema.linebreakReplacement){let y=s.whitespace=="pre",v=!!s.contentMatch.matchType(s.schema.linebreakReplacement);y&&!v?h=!1:!y&&v&&(h=!0)}h===!1&&AS(t,o,c,i),I0(t,t.mapping.slice(i).map(c,1),s,void 0,h===null);let f=t.mapping.slice(i),m=f.map(c,1),g=f.map(c+o.nodeSize,1);return t.step(new Zn(m,g,m+1,g-1,new ze(we.from(s.create(u,null,o.marks)),0,0),1,!0)),h===!0&&MS(t,o,c,i),!1}})}function MS(t,e,n,s){e.forEach((a,i)=>{if(a.isText){let o,c=/\r?\n|\r/g;for(;o=c.exec(a.text);){let u=t.mapping.slice(s).map(n+1+i+o.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function AS(t,e,n,s){e.forEach((a,i)=>{if(a.type==a.type.schema.linebreakReplacement){let o=t.mapping.slice(s).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
`))}})}function _O(t,e,n){let s=t.resolve(e),a=s.index();return s.parent.canReplaceWith(a,a+1,n)}function zO(t,e,n,s,a){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(s,null,a||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Zn(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new ze(we.from(o),0,0),1,!0))}function li(t,e,n=1,s){let a=t.resolve(e),i=a.depth-n,o=s&&s[s.length-1]||a.parent;if(i<0||a.parent.type.spec.isolating||!a.parent.canReplace(a.index(),a.parent.childCount)||!o.type.validContent(a.parent.content.cutByIndex(a.index(),a.parent.childCount)))return!1;for(let h=a.depth-1,f=n-2;h>i;h--,f--){let m=a.node(h),g=a.index(h);if(m.type.spec.isolating)return!1;let y=m.content.cutByIndex(g,m.childCount),v=s&&s[f+1];v&&(y=y.replaceChild(0,v.type.create(v.attrs)));let w=s&&s[f]||m;if(!m.canReplace(g+1,m.childCount)||!w.type.validContent(y))return!1}let c=a.indexAfter(i),u=s&&s[0];return a.node(i).canReplaceWith(c,c,u?u.type:a.node(i+1).type)}function $O(t,e,n=1,s){let a=t.doc.resolve(e),i=we.empty,o=we.empty;for(let c=a.depth,u=a.depth-n,h=n-1;c>u;c--,h--){i=we.from(a.node(c).copy(i));let f=s&&s[h];o=we.from(f?f.type.create(f.attrs,o):a.node(c).copy(o))}t.step(new Xn(e,e,new ze(i.append(o),n,n),!0))}function go(t,e){let n=t.resolve(e),s=n.index();return IS(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(s,s+1)}function FO(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:s}=t.type.schema;for(let a=0;a<e.childCount;a++){let i=e.child(a),o=i.type==s?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function IS(t,e){return!!(t&&e&&!t.isLeaf&&FO(t,e))}function ip(t,e,n=-1){let s=t.resolve(e);for(let a=s.depth;;a--){let i,o,c=s.index(a);if(a==s.depth?(i=s.nodeBefore,o=s.nodeAfter):n>0?(i=s.node(a+1),c++,o=s.node(a).maybeChild(c)):(i=s.node(a).maybeChild(c-1),o=s.node(a+1)),i&&!i.isTextblock&&IS(i,o)&&s.node(a).canReplace(c,c+1))return e;if(a==0)break;e=n<0?s.before(a):s.after(a)}}function BO(t,e,n){let s=null,{linebreakReplacement:a}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(a&&o.inlineContent){let f=o.whitespace=="pre",m=!!o.contentMatch.matchType(a);f&&!m?s=!1:!f&&m&&(s=!0)}let c=t.steps.length;if(s===!1){let f=t.doc.resolve(e+n);AS(t,f.node(),f.before(),c)}o.inlineContent&&I0(t,e+n-1,o,i.node().contentMatchAt(i.index()),s==null);let u=t.mapping.slice(c),h=u.map(e-n);if(t.step(new Xn(h,u.map(e+n,-1),ze.empty,!0)),s===!0){let f=t.doc.resolve(h);MS(t,f.node(),f.before(),t.steps.length)}return t}function VO(t,e,n){let s=t.resolve(e);if(s.parent.canReplaceWith(s.index(),s.index(),n))return e;if(s.parentOffset==0)for(let a=s.depth-1;a>=0;a--){let i=s.index(a);if(s.node(a).canReplaceWith(i,i,n))return s.before(a+1);if(i>0)return null}if(s.parentOffset==s.parent.content.size)for(let a=s.depth-1;a>=0;a--){let i=s.indexAfter(a);if(s.node(a).canReplaceWith(i,i,n))return s.after(a+1);if(i<s.node(a).childCount)return null}return null}function RS(t,e,n){let s=t.resolve(e);if(!n.content.size)return e;let a=n.content;for(let i=0;i<n.openStart;i++)a=a.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=s.depth;o>=0;o--){let c=o==s.depth?0:s.pos<=(s.start(o+1)+s.end(o+1))/2?-1:1,u=s.index(o)+(c>0?1:0),h=s.node(o),f=!1;if(i==1)f=h.canReplace(u,u,a);else{let m=h.contentMatchAt(u).findWrapping(a.firstChild.type);f=m&&h.canReplaceWith(u,u,m[0])}if(f)return c==0?s.pos:c<0?s.before(o+1):s.after(o+1)}return null}function op(t,e,n=e,s=ze.empty){if(e==n&&!s.size)return null;let a=t.resolve(e),i=t.resolve(n);return PS(a,i,s)?new Xn(e,n,s):new HO(a,i,s).fit()}function PS(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class HO{constructor(e,n,s){this.$from=e,this.$to=n,this.unplaced=s,this.frontier=[],this.placed=we.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=we.from(e.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let h=this.findFittable();h?this.placeNodes(h):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,s=this.$from,a=this.close(e<0?this.$to:s.doc.resolve(e));if(!a)return null;let i=this.placed,o=s.depth,c=a.depth;for(;o&&c&&i.childCount==1;)i=i.firstChild.content,o--,c--;let u=new ze(i,o,c);return e>-1?new Zn(s.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||s.pos!=this.$to.pos?new Xn(s.pos,a.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,s=0,a=this.unplaced.openEnd;s<e;s++){let i=n.firstChild;if(n.childCount>1&&(a=0),i.type.spec.isolating&&a<=s){e=s;break}n=i.content}for(let n=1;n<=2;n++)for(let s=n==1?e:this.unplaced.openStart;s>=0;s--){let a,i=null;s?(i=vg(this.unplaced.content,s-1).firstChild,a=i.content):a=this.unplaced.content;let o=a.firstChild;for(let c=this.depth;c>=0;c--){let{type:u,match:h}=this.frontier[c],f,m=null;if(n==1&&(o?h.matchType(o.type)||(m=h.fillBefore(we.from(o),!1)):i&&u.compatibleContent(i.type)))return{sliceDepth:s,frontierDepth:c,parent:i,inject:m};if(n==2&&o&&(f=h.findWrapping(o.type)))return{sliceDepth:s,frontierDepth:c,parent:i,wrap:f};if(i&&h.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:s}=this.unplaced,a=vg(e,n);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new ze(e,n+1,Math.max(s,a.size+n>=e.size-s?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:s}=this.unplaced,a=vg(e,n);if(a.childCount<=1&&n>0){let i=e.size-n<=n+a.size;this.unplaced=new ze(xd(e,n-1,1),n-1,i?n-1:s)}else this.unplaced=new ze(xd(e,n,1),n,s)}placeNodes({sliceDepth:e,frontierDepth:n,parent:s,inject:a,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let w=0;w<i.length;w++)this.openFrontierNode(i[w]);let o=this.unplaced,c=s?s.content:o.content,u=o.openStart-e,h=0,f=[],{match:m,type:g}=this.frontier[n];if(a){for(let w=0;w<a.childCount;w++)f.push(a.child(w));m=m.matchFragment(a)}let y=c.size+e-(o.content.size-o.openEnd);for(;h<c.childCount;){let w=c.child(h),N=m.matchType(w.type);if(!N)break;h++,(h>1||u==0||w.content.size)&&(m=N,f.push(OS(w.mark(g.allowedMarks(w.marks)),h==1?u:0,h==c.childCount?y:-1)))}let v=h==c.childCount;v||(y=-1),this.placed=yd(this.placed,n,we.from(f)),this.frontier[n].match=m,v&&y<0&&s&&s.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,N=c;w<y;w++){let k=N.lastChild;this.frontier.push({type:k.type,match:k.contentMatchAt(k.childCount)}),N=k.content}this.unplaced=v?e==0?ze.empty:new ze(xd(o.content,e-1,1),e-1,y<0?o.openEnd:e-1):new ze(xd(o.content,e,h),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Ng(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:s}=this.$to,a=this.$to.after(s);for(;s>1&&a==this.$to.end(--s);)++a;return a}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:s,type:a}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=Ng(e,n,a,s,i);if(o){for(let c=n-1;c>=0;c--){let{match:u,type:h}=this.frontier[c],f=Ng(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=yd(this.placed,n.depth,n.fit)),e=n.move;for(let s=n.depth+1;s<=e.depth;s++){let a=e.node(s),i=a.type.contentMatch.fillBefore(a.content,!0,e.index(s));this.openFrontierNode(a.type,a.attrs,i)}return e}openFrontierNode(e,n=null,s){let a=this.frontier[this.depth];a.match=a.match.matchType(e),this.placed=yd(this.placed,this.depth,we.from(e.create(n,s))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(we.empty,!0);n.childCount&&(this.placed=yd(this.placed,this.frontier.length,n))}}function xd(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(xd(t.firstChild.content,e-1,n)))}function yd(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(yd(t.lastChild.content,e-1,n)))}function vg(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function OS(t,e,n){if(e<=0)return t;let s=t.content;return e>1&&(s=s.replaceChild(0,OS(s.firstChild,e-1,s.childCount==1?n-1:0))),e>0&&(s=t.type.contentMatch.fillBefore(s).append(s),n<=0&&(s=s.append(t.type.contentMatch.matchFragment(s).fillBefore(we.empty,!0)))),t.copy(s)}function Ng(t,e,n,s,a){let i=t.node(e),o=a?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let c=s.fillBefore(i.content,!0,o);return c&&!UO(n,i.content,o)?c:null}function UO(t,e,n){for(let s=n;s<e.childCount;s++)if(!t.allowsMarks(e.child(s).marks))return!0;return!1}function WO(t){return t.spec.defining||t.spec.definingForContent}function KO(t,e,n,s){if(!s.size)return t.deleteRange(e,n);let a=t.doc.resolve(e),i=t.doc.resolve(n);if(PS(a,i,s))return t.step(new Xn(e,n,s));let o=DS(a,i);o[o.length-1]==0&&o.pop();let c=-(a.depth+1);o.unshift(c);for(let g=a.depth,y=a.pos-1;g>0;g--,y--){let v=a.node(g).type.spec;if(v.defining||v.definingAsContext||v.isolating)break;o.indexOf(g)>-1?c=g:a.before(g)==y&&o.splice(1,0,-g)}let u=o.indexOf(c),h=[],f=s.openStart;for(let g=s.content,y=0;;y++){let v=g.firstChild;if(h.push(v),y==s.openStart)break;g=v.content}for(let g=f-1;g>=0;g--){let y=h[g],v=WO(y.type);if(v&&!y.sameMarkup(a.node(Math.abs(c)-1)))f=g;else if(v||!y.type.isTextblock)break}for(let g=s.openStart;g>=0;g--){let y=(g+f+1)%(s.openStart+1),v=h[y];if(v)for(let w=0;w<o.length;w++){let N=o[(w+u)%o.length],k=!0;N<0&&(k=!1,N=-N);let E=a.node(N-1),C=a.index(N-1);if(E.canReplaceWith(C,C,v.type,v.marks))return t.replace(a.before(N),k?i.after(N):n,new ze(LS(s.content,0,s.openStart,y),y,s.openEnd))}}let m=t.steps.length;for(let g=o.length-1;g>=0&&(t.replace(e,n,s),!(t.steps.length>m));g--){let y=o[g];y<0||(e=a.before(y),n=i.after(y))}}function LS(t,e,n,s,a){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(LS(i.content,e+1,n,s,i)))}if(e>s){let i=a.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(we.empty,!0))}return t}function qO(t,e,n,s){if(!s.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let a=VO(t.doc,e,s.type);a!=null&&(e=n=a)}t.replaceRange(e,n,new ze(we.from(s),0,0))}function GO(t,e,n){let s=t.doc.resolve(e),a=t.doc.resolve(n),i=DS(s,a);for(let o=0;o<i.length;o++){let c=i[o],u=o==i.length-1;if(u&&c==0||s.node(c).type.contentMatch.validEnd)return t.delete(s.start(c),a.end(c));if(c>0&&(u||s.node(c-1).canReplace(s.index(c-1),a.indexAfter(c-1))))return t.delete(s.before(c),a.after(c))}for(let o=1;o<=s.depth&&o<=a.depth;o++)if(e-s.start(o)==s.depth-o&&n>s.end(o)&&a.end(o)-n!=a.depth-o&&s.start(o-1)==a.start(o-1)&&s.node(o-1).canReplace(s.index(o-1),a.index(o-1)))return t.delete(s.before(o),n);t.delete(e,n)}function DS(t,e){let n=[],s=Math.min(t.depth,e.depth);for(let a=s;a>=0;a--){let i=t.start(a);if(i<t.pos-(t.depth-a)||e.end(a)>e.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 uc extends Ms{constructor(e,n,s){super(),this.pos=e,this.attr=n,this.value=s}apply(e){let n=e.nodeAt(this.pos);if(!n)return $n.fail("No node at attribute step's position");let s=Object.create(null);for(let i in n.attrs)s[i]=n.attrs[i];s[this.attr]=this.value;let a=n.type.create(s,null,n.marks);return $n.fromReplace(e,this.pos,this.pos+1,new ze(we.from(a),0,n.isLeaf?0:1))}getMap(){return dr.empty}invert(e){return new uc(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 uc(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 uc(n.pos,n.attr,n.value)}}Ms.jsonID("attr",uc);class Ud extends Ms{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let a in e.attrs)n[a]=e.attrs[a];n[this.attr]=this.value;let s=e.type.create(n,e.content,e.marks);return $n.ok(s)}getMap(){return dr.empty}invert(e){return new Ud(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ud(n.attr,n.value)}}Ms.jsonID("docAttr",Ud);let yc=class extends Error{};yc=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};yc.prototype=Object.create(Error.prototype);yc.prototype.constructor=yc;yc.prototype.name="TransformError";class P0{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Hd}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new yc(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let s=0;s<this.mapping.maps.length;s++){let a=this.mapping.maps[s];s&&(e=a.map(e,1),n=a.map(n,-1)),a.forEach((i,o,c,u)=>{e=Math.min(e,c),n=Math.max(n,u)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,s=ze.empty){let a=op(this.doc,e,n,s);return a&&this.step(a),this}replaceWith(e,n,s){return this.replace(e,n,new ze(we.from(s),0,0))}delete(e,n){return this.replace(e,n,ze.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,s){return KO(this,e,n,s),this}replaceRangeWith(e,n,s){return qO(this,e,n,s),this}deleteRange(e,n){return GO(this,e,n),this}lift(e,n){return RO(this,e,n),this}join(e,n=1){return BO(this,e,n),this}wrap(e,n){return LO(this,e,n),this}setBlockType(e,n=e,s,a=null){return DO(this,e,n,s,a),this}setNodeMarkup(e,n,s=null,a){return zO(this,e,n,s,a),this}setNodeAttribute(e,n,s){return this.step(new uc(e,n,s)),this}setDocAttribute(e,n){return this.step(new Ud(e,n)),this}addNodeMark(e,n){return this.step(new Yi(e,n)),this}removeNodeMark(e,n){let s=this.doc.nodeAt(e);if(!s)throw new RangeError("No node at position "+e);if(n instanceof Qt)n.isInSet(s.marks)&&this.step(new ul(e,n));else{let a=s.marks,i,o=[];for(;i=n.isInSet(a);)o.push(new ul(e,i)),a=i.removeFromSet(a);for(let c=o.length-1;c>=0;c--)this.step(o[c])}return this}split(e,n=1,s){return $O(this,e,n,s),this}addMark(e,n,s){return MO(this,e,n,s),this}removeMark(e,n,s){return AO(this,e,n,s),this}clearIncompatible(e,n,s){return I0(this,e,n,s),this}}const wg=Object.create(null);class lt{constructor(e,n,s){this.$anchor=e,this.$head=n,this.ranges=s||[new _S(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<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=ze.empty){let s=n.content.lastChild,a=null;for(let c=0;c<n.openEnd;c++)a=s,s=s.lastChild;let i=e.steps.length,o=this.ranges;for(let c=0;c<o.length;c++){let{$from:u,$to:h}=o[c],f=e.mapping.slice(i);e.replaceRange(f.map(u.pos),f.map(h.pos),c?ze.empty:n),c==0&&K1(e,i,(s?s.isInline:a&&a.isTextblock)?-1:1)}}replaceWith(e,n){let s=e.steps.length,a=this.ranges;for(let i=0;i<a.length;i++){let{$from:o,$to:c}=a[i],u=e.mapping.slice(s),h=u.map(o.pos),f=u.map(c.pos);i?e.deleteRange(h,f):(e.replaceRangeWith(h,f,n),K1(e,s,n.isInline?-1:1))}}static findFrom(e,n,s=!1){let a=e.parent.inlineContent?new nt(e):tc(e.node(0),e.parent,e.pos,e.index(),n,s);if(a)return a;for(let i=e.depth-1;i>=0;i--){let o=n<0?tc(e.node(0),e.node(i),e.before(i+1),e.index(i),n,s):tc(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,s);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new hr(e.node(0))}static atStart(e){return tc(e,e,0,0,1)||new hr(e)}static atEnd(e){return tc(e,e,e.content.size,e.childCount,-1)||new hr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let s=wg[n.type];if(!s)throw new RangeError(`No selection type ${n.type} defined`);return s.fromJSON(e,n)}static jsonID(e,n){if(e in wg)throw new RangeError("Duplicate use of selection JSON ID "+e);return wg[e]=n,n.prototype.jsonID=e,n}getBookmark(){return nt.between(this.$anchor,this.$head).getBookmark()}}lt.prototype.visible=!0;class _S{constructor(e,n){this.$from=e,this.$to=n}}let U1=!1;function W1(t){!U1&&!t.parent.inlineContent&&(U1=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class nt extends lt{constructor(e,n=e){W1(e),W1(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let s=e.resolve(n.map(this.head));if(!s.parent.inlineContent)return lt.near(s);let a=e.resolve(n.map(this.anchor));return new nt(a.parent.inlineContent?a:s,s)}replace(e,n=ze.empty){if(super.replace(e,n),n==ze.empty){let s=this.$from.marksAcross(this.$to);s&&e.ensureMarks(s)}}eq(e){return e instanceof nt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new lp(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 nt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,s=n){let a=e.resolve(n);return new this(a,s==n?a:e.resolve(s))}static between(e,n,s){let a=e.pos-n.pos;if((!s||a)&&(s=a>=0?1:-1),!n.parent.inlineContent){let i=lt.findFrom(n,s,!0)||lt.findFrom(n,-s,!0);if(i)n=i.$head;else return lt.near(n,s)}return e.parent.inlineContent||(a==0?e=n:(e=(lt.findFrom(e,-s,!0)||lt.findFrom(e,s,!0)).$anchor,e.pos<n.pos!=a<0&&(e=n))),new nt(e,n)}}lt.jsonID("text",nt);class lp{constructor(e,n){this.anchor=e,this.head=n}map(e){return new lp(e.map(this.anchor),e.map(this.head))}resolve(e){return nt.between(e.resolve(this.anchor),e.resolve(this.head))}}class et extends lt{constructor(e){let n=e.nodeAfter,s=e.node(0).resolve(e.pos+n.nodeSize);super(e,s),this.node=n}map(e,n){let{deleted:s,pos:a}=n.mapResult(this.anchor),i=e.resolve(a);return s?lt.near(i):new et(i)}content(){return new ze(we.from(this.node),0,0)}eq(e){return e instanceof et&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new O0(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new et(e.resolve(n.anchor))}static create(e,n){return new et(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}et.prototype.visible=!1;lt.jsonID("node",et);class O0{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:s}=e.mapResult(this.anchor);return n?new lp(s,s):new O0(s)}resolve(e){let n=e.resolve(this.anchor),s=n.nodeAfter;return s&&et.isSelectable(s)?new et(n):lt.near(n)}}class hr extends lt{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=ze.empty){if(n==ze.empty){e.delete(0,e.doc.content.size);let s=lt.atStart(e.doc);s.eq(e.selection)||e.setSelection(s)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new hr(e)}map(e){return new hr(e)}eq(e){return e instanceof hr}getBookmark(){return JO}}lt.jsonID("all",hr);const JO={map(){return this},resolve(t){return new hr(t)}};function tc(t,e,n,s,a,i=!1){if(e.inlineContent)return nt.create(t,n);for(let o=s-(a>0?0:1);a>0?o<e.childCount:o>=0;o+=a){let c=e.child(o);if(c.isAtom){if(!i&&et.isSelectable(c))return et.create(t,n-(a<0?c.nodeSize:0))}else{let u=tc(t,c,n+a,a<0?c.childCount:0,a,i);if(u)return u}n+=c.nodeSize*a}return null}function K1(t,e,n){let s=t.steps.length-1;if(s<e)return;let a=t.steps[s];if(!(a instanceof Xn||a instanceof Zn))return;let i=t.mapping.maps[s],o;i.forEach((c,u,h,f)=>{o==null&&(o=f)}),t.setSelection(lt.near(t.doc.resolve(o),n))}const q1=1,yh=2,G1=4;class YO extends P0{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.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|q1)&~yh,this.storedMarks=null,this}get selectionSet(){return(this.updated&q1)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=yh,this}ensureMarks(e){return Qt.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&yh)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~yh,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let s=this.selection;return n&&(e=e.mark(this.storedMarks||(s.empty?s.$from.marks():s.$from.marksAcross(s.$to)||Qt.none))),s.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,s){let a=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(a.text(e),!0):this.deleteSelection();{if(s==null&&(s=n),!e)return this.deleteRange(n,s);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=s==n?o.marks():o.marksAcross(this.doc.resolve(s))}return this.replaceRangeWith(n,s,a.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(lt.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|=G1,this}get scrolledIntoView(){return(this.updated&G1)>0}}function J1(t,e){return!e||!t?t:t.bind(e)}class bd{constructor(e,n,s){this.name=e,this.init=J1(n.init,s),this.apply=J1(n.apply,s)}}const QO=[new bd("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new bd("selection",{init(t,e){return t.selection||lt.atStart(e.doc)},apply(t){return t.selection}}),new bd("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,s){return s.selection.$cursor?t.storedMarks:null}}),new bd("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class jg{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=QO.slice(),n&&n.forEach(s=>{if(this.pluginsByKey[s.key])throw new RangeError("Adding different instances of a keyed plugin ("+s.key+")");this.plugins.push(s),this.pluginsByKey[s.key]=s,s.spec.state&&this.fields.push(new bd(s.key,s.spec.state,s))})}}class cc{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let s=0;s<this.config.plugins.length;s++)if(s!=n){let a=this.config.plugins[s];if(a.spec.filterTransaction&&!a.spec.filterTransaction.call(a,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],s=this.applyInner(e),a=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let c=this.config.plugins[o];if(c.spec.appendTransaction){let u=a?a[o].n:0,h=a?a[o].state:this,f=u<n.length&&c.spec.appendTransaction.call(c,u?n.slice(u):n,h,s);if(f&&s.filterTransaction(f,o)){if(f.setMeta("appendedTransaction",e),!a){a=[];for(let m=0;m<this.config.plugins.length;m++)a.push(m<o?{state:s,n:n.length}:{state:this,n:0})}n.push(f),s=s.applyInner(f),i=!0}a&&(a[o]={state:s,n:n.length})}}if(!i)return{state:s,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new cc(this.config),s=this.config.fields;for(let a=0;a<s.length;a++){let i=s[a];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new YO(this)}static create(e){let n=new jg(e.doc?e.doc.type.schema:e.schema,e.plugins),s=new cc(n);for(let a=0;a<n.fields.length;a++)s[n.fields[a].name]=n.fields[a].init(e,s);return s}reconfigure(e){let n=new jg(this.schema,e.plugins),s=n.fields,a=new cc(n);for(let i=0;i<s.length;i++){let o=s[i].name;a[o]=this.hasOwnProperty(o)?this[o]:s[i].init(e,a)}return a}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(s=>s.toJSON())),e&&typeof e=="object")for(let s in e){if(s=="doc"||s=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let a=e[s],i=a.spec.state;i&&i.toJSON&&(n[s]=i.toJSON.call(a,this[a.key]))}return n}static fromJSON(e,n,s){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let a=new jg(e.schema,e.plugins),i=new cc(a);return a.fields.forEach(o=>{if(o.name=="doc")i.doc=oi.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=lt.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(s)for(let c in s){let u=s[c],h=u.spec.state;if(u.key==o.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(n,c)){i[o.name]=h.fromJSON.call(u,e,n[c],i);return}}i[o.name]=o.init(e,i)}}),i}}function zS(t,e,n){for(let s in t){let a=t[s];a instanceof Function?a=a.bind(e):s=="handleDOMEvents"&&(a=zS(a,e,{})),n[s]=a}return n}class nn{constructor(e){this.spec=e,this.props={},e.props&&zS(e.props,this,this.props),this.key=e.key?e.key.key:$S("plugin")}getState(e){return e[this.key]}}const kg=Object.create(null);function $S(t){return t in kg?t+"$"+ ++kg[t]:(kg[t]=0,t+"$")}class un{constructor(e="key"){this.key=$S(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const L0=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function FS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const BS=(t,e,n)=>{let s=FS(t,n);if(!s)return!1;let a=D0(s);if(!a){let o=s.blockRange(),c=o&&Rc(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let i=a.nodeBefore;if(YS(t,a,e,-1))return!0;if(s.parent.content.size==0&&(bc(i,"end")||et.isSelectable(i)))for(let o=s.depth;;o--){let c=op(t.doc,s.before(o),s.after(o),ze.empty);if(c&&c.slice.size<c.to-c.from){if(e){let u=t.tr.step(c);u.setSelection(bc(i,"end")?lt.findFrom(u.doc.resolve(u.mapping.map(a.pos,-1)),-1):et.create(u.doc,a.pos-i.nodeSize)),e(u.scrollIntoView())}return!0}if(o==1||s.node(o-1).childCount>1)break}return i.isAtom&&a.depth==s.depth-1?(e&&e(t.tr.delete(a.pos-i.nodeSize,a.pos).scrollIntoView()),!0):!1},XO=(t,e,n)=>{let s=FS(t,n);if(!s)return!1;let a=D0(s);return a?VS(t,a,e):!1},ZO=(t,e,n)=>{let s=US(t,n);if(!s)return!1;let a=_0(s);return a?VS(t,a,e):!1};function VS(t,e,n){let s=e.nodeBefore,a=s,i=e.pos-1;for(;!a.isTextblock;i--){if(a.type.spec.isolating)return!1;let f=a.lastChild;if(!f)return!1;a=f}let o=e.nodeAfter,c=o,u=e.pos+1;for(;!c.isTextblock;u++){if(c.type.spec.isolating)return!1;let f=c.firstChild;if(!f)return!1;c=f}let h=op(t.doc,i,u,ze.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(nt.create(f.doc,i)),n(f.scrollIntoView())}return!0}function bc(t,e,n=!1){for(let s=t;s;s=e=="start"?s.firstChild:s.lastChild){if(s.isTextblock)return!0;if(n&&s.childCount!=1)return!1}return!1}const HS=(t,e,n)=>{let{$head:s,empty:a}=t.selection,i=s;if(!a)return!1;if(s.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):s.parentOffset>0)return!1;i=D0(s)}let o=i&&i.nodeBefore;return!o||!et.isSelectable(o)?!1:(e&&e(t.tr.setSelection(et.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function D0(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 US(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const WS=(t,e,n)=>{let s=US(t,n);if(!s)return!1;let a=_0(s);if(!a)return!1;let i=a.nodeAfter;if(YS(t,a,e,1))return!0;if(s.parent.content.size==0&&(bc(i,"start")||et.isSelectable(i))){let o=op(t.doc,s.before(),s.after(),ze.empty);if(o&&o.slice.size<o.to-o.from){if(e){let c=t.tr.step(o);c.setSelection(bc(i,"start")?lt.findFrom(c.doc.resolve(c.mapping.map(a.pos)),1):et.create(c.doc,c.mapping.map(a.pos))),e(c.scrollIntoView())}return!0}}return i.isAtom&&a.depth==s.depth-1?(e&&e(t.tr.delete(a.pos,a.pos+i.nodeSize).scrollIntoView()),!0):!1},KS=(t,e,n)=>{let{$head:s,empty:a}=t.selection,i=s;if(!a)return!1;if(s.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):s.parentOffset<s.parent.content.size)return!1;i=_0(s)}let o=i&&i.nodeAfter;return!o||!et.isSelectable(o)?!1:(e&&e(t.tr.setSelection(et.create(t.doc,i.pos)).scrollIntoView()),!0)};function _0(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const e8=(t,e)=>{let n=t.selection,s=n instanceof et,a;if(s){if(n.node.isTextblock||!go(t.doc,n.from))return!1;a=n.from}else if(a=ip(t.doc,n.from,-1),a==null)return!1;if(e){let i=t.tr.join(a);s&&i.setSelection(et.create(i.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},t8=(t,e)=>{let n=t.selection,s;if(n instanceof et){if(n.node.isTextblock||!go(t.doc,n.to))return!1;s=n.to}else if(s=ip(t.doc,n.to,1),s==null)return!1;return e&&e(t.tr.join(s).scrollIntoView()),!0},n8=(t,e)=>{let{$from:n,$to:s}=t.selection,a=n.blockRange(s),i=a&&Rc(a);return i==null?!1:(e&&e(t.tr.lift(a,i).scrollIntoView()),!0)},qS=(t,e)=>{let{$head:n,$anchor:s}=t.selection;return!n.parent.type.spec.code||!n.sameParent(s)?!1:(e&&e(t.tr.insertText(`
`).scrollIntoView()),!0)};function z0(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const s8=(t,e)=>{let{$head:n,$anchor:s}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(s))return!1;let a=n.node(-1),i=n.indexAfter(-1),o=z0(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(lt.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},GS=(t,e)=>{let n=t.selection,{$from:s,$to:a}=n;if(n instanceof hr||s.parent.inlineContent||a.parent.inlineContent)return!1;let i=z0(a.parent.contentMatchAt(a.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!s.parentOffset&&a.index()<a.parent.childCount?s:a).pos,c=t.tr.insert(o,i.createAndFill());c.setSelection(nt.create(c.doc,o+1)),e(c.scrollIntoView())}return!0},JS=(t,e)=>{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(li(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let s=n.blockRange(),a=s&&Rc(s);return a==null?!1:(e&&e(t.tr.lift(s,a).scrollIntoView()),!0)};function r8(t){return(e,n)=>{let{$from:s,$to:a}=e.selection;if(e.selection instanceof et&&e.selection.node.isBlock)return!s.parentOffset||!li(e.doc,s.pos)?!1:(n&&n(e.tr.split(s.pos).scrollIntoView()),!0);if(!s.depth)return!1;let i=[],o,c,u=!1,h=!1;for(let y=s.depth;;y--)if(s.node(y).isBlock){u=s.end(y)==s.pos+(s.depth-y),h=s.start(y)==s.pos-(s.depth-y),c=z0(s.node(y-1).contentMatchAt(s.indexAfter(y-1))),i.unshift(u&&c?{type:c}:null),o=y;break}else{if(y==1)return!1;i.unshift(null)}let f=e.tr;(e.selection instanceof nt||e.selection instanceof hr)&&f.deleteSelection();let m=f.mapping.map(s.pos),g=li(f.doc,m,i.length,i);if(g||(i[0]=c?{type:c}:null,g=li(f.doc,m,i.length,i)),!g)return!1;if(f.split(m,i.length,i),!u&&h&&s.node(o).type!=c){let y=f.mapping.map(s.before(o)),v=f.doc.resolve(y);c&&s.node(o-1).canReplaceWith(v.index(),v.index()+1,c)&&f.setNodeMarkup(f.mapping.map(s.before(o)),c)}return n&&n(f.scrollIntoView()),!0}}const a8=r8(),i8=(t,e)=>{let{$from:n,to:s}=t.selection,a,i=n.sharedDepth(s);return i==0?!1:(a=n.before(i),e&&e(t.tr.setSelection(et.create(t.doc,a))),!0)};function o8(t,e,n){let s=e.nodeBefore,a=e.nodeAfter,i=e.index();return!s||!a||!s.type.compatibleContent(a.type)?!1:!s.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-s.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(a.isTextblock||go(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function YS(t,e,n,s){let a=e.nodeBefore,i=e.nodeAfter,o,c,u=a.type.spec.isolating||i.type.spec.isolating;if(!u&&o8(t,e,n))return!0;let h=!u&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(o=(c=a.contentMatchAt(a.childCount)).findWrapping(i.type))&&c.matchType(o[0]||i.type).validEnd){if(n){let y=e.pos+i.nodeSize,v=we.empty;for(let k=o.length-1;k>=0;k--)v=we.from(o[k].create(null,v));v=we.from(a.copy(v));let w=t.tr.step(new Zn(e.pos-1,y,e.pos,y,new ze(v,1,0),o.length,!0)),N=w.doc.resolve(y+2*o.length);N.nodeAfter&&N.nodeAfter.type==a.type&&go(w.doc,N.pos)&&w.join(N.pos),n(w.scrollIntoView())}return!0}let f=i.type.spec.isolating||s>0&&u?null:lt.findFrom(e,1),m=f&&f.$from.blockRange(f.$to),g=m&&Rc(m);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(m,g).scrollIntoView()),!0;if(h&&bc(i,"start",!0)&&bc(a,"end")){let y=a,v=[];for(;v.push(y),!y.isTextblock;)y=y.lastChild;let w=i,N=1;for(;!w.isTextblock;w=w.firstChild)N++;if(y.canReplace(y.childCount,y.childCount,w.content)){if(n){let k=we.empty;for(let C=v.length-1;C>=0;C--)k=we.from(v[C].copy(k));let E=t.tr.step(new Zn(e.pos-v.length,e.pos+i.nodeSize,e.pos+N,e.pos+i.nodeSize-N,new ze(k,v.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function QS(t){return function(e,n){let s=e.selection,a=t<0?s.$from:s.$to,i=a.depth;for(;a.node(i).isInline;){if(!i)return!1;i--}return a.node(i).isTextblock?(n&&n(e.tr.setSelection(nt.create(e.doc,t<0?a.start(i):a.end(i)))),!0):!1}}const l8=QS(-1),c8=QS(1);function d8(t,e=null){return function(n,s){let{$from:a,$to:i}=n.selection,o=a.blockRange(i),c=o&&R0(o,t,e);return c?(s&&s(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function Y1(t,e=null){return function(n,s){let a=!1;for(let i=0;i<n.selection.ranges.length&&!a;i++){let{$from:{pos:o},$to:{pos:c}}=n.selection.ranges[i];n.doc.nodesBetween(o,c,(u,h)=>{if(a)return!1;if(!(!u.isTextblock||u.hasMarkup(t,e)))if(u.type==t)a=!0;else{let f=n.doc.resolve(h),m=f.index();a=f.parent.canReplaceWith(m,m+1,t)}})}if(!a)return!1;if(s){let i=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:c},$to:{pos:u}}=n.selection.ranges[o];i.setBlockType(c,u,t,e)}s(i.scrollIntoView())}return!0}}function $0(...t){return function(e,n,s){for(let a=0;a<t.length;a++)if(t[a](e,n,s))return!0;return!1}}$0(L0,BS,HS);$0(L0,WS,KS);$0(qS,GS,JS,a8);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function u8(t,e=null){return function(n,s){let{$from:a,$to:i}=n.selection,o=a.blockRange(i);if(!o)return!1;let c=s?n.tr:null;return h8(c,o,t,e)?(s&&s(c.scrollIntoView()),!0):!1}}function h8(t,e,n,s=null){let a=!1,i=e,o=e.$from.doc;if(e.depth>=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 sf(u,u,e.depth),e.endIndex<e.parent.childCount&&(e=new sf(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),a=!0}let c=R0(i,n,s,e);return c?(t&&f8(t,e,c,a,n),!0):!1}function f8(t,e,n,s,a){let i=we.empty;for(let f=n.length-1;f>=0;f--)i=we.from(n[f].type.create(n[f].attrs,i));t.step(new Zn(e.start-(s?2:0),e.end,e.start,e.end,new ze(i,0,0),n.length,!0));let o=0;for(let f=0;f<n.length;f++)n[f].type==a&&(o=f+1);let c=n.length-o,u=e.start+n.length-(s?2:0),h=e.parent;for(let f=e.startIndex,m=e.endIndex,g=!0;f<m;f++,g=!1)!g&&li(t.doc,u,c)&&(t.split(u,c),u+=2*c),u+=h.child(f).nodeSize;return t}function p8(t){return function(e,n){let{$from:s,$to:a}=e.selection,i=s.blockRange(a,o=>o.childCount>0&&o.firstChild.type==t);return i?n?s.node(i.depth-1).type==t?m8(e,n,t,i):g8(e,n,i):!0:!1}}function m8(t,e,n,s){let a=t.tr,i=s.end,o=s.$to.end(s.depth);i<o&&(a.step(new Zn(i-1,o,i,o,new ze(we.from(n.create(null,s.parent.copy())),1,0),1,!0)),s=new sf(a.doc.resolve(s.$from.pos),a.doc.resolve(o),s.depth));const c=Rc(s);if(c==null)return!1;a.lift(s,c);let u=a.doc.resolve(a.mapping.map(i,-1)-1);return go(a.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type&&a.join(u.pos),e(a.scrollIntoView()),!0}function g8(t,e,n){let s=t.tr,a=n.parent;for(let y=n.end,v=n.endIndex-1,w=n.startIndex;v>w;v--)y-=a.child(v).nodeSize,s.delete(y-1,y+1);let i=s.doc.resolve(n.start),o=i.nodeAfter;if(s.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let c=n.startIndex==0,u=n.endIndex==a.childCount,h=i.node(-1),f=i.index(-1);if(!h.canReplace(f+(c?0:1),f+1,o.content.append(u?we.empty:we.from(a))))return!1;let m=i.pos,g=m+o.nodeSize;return s.step(new Zn(m-(c?1:0),g+(u?1:0),m+1,g-1,new ze((c?we.empty:we.from(a.copy(we.empty))).append(u?we.empty:we.from(a.copy(we.empty))),c?0:1,u?0:1),c?0:1)),e(s.scrollIntoView()),!0}function x8(t){return function(e,n){let{$from:s,$to:a}=e.selection,i=s.blockRange(a,h=>h.childCount>0&&h.firstChild.type==t);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let c=i.parent,u=c.child(o-1);if(u.type!=t)return!1;if(n){let h=u.lastChild&&u.lastChild.type==c.type,f=we.from(h?t.create():null),m=new ze(we.from(t.create(null,we.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 cs=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},vc=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let wx=null;const si=function(t,e,n){let s=wx||(wx=document.createRange());return s.setEnd(t,n??t.nodeValue.length),s.setStart(t,e||0),s},y8=function(){wx=null},hl=function(t,e,n,s){return n&&(Q1(t,e,n,s,-1)||Q1(t,e,n,s,1))},b8=/^(img|br|input|textarea|hr)$/i;function Q1(t,e,n,s,a){for(var i;;){if(t==n&&e==s)return!0;if(e==(a<0?0:Cr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||iu(t)||b8.test(t.nodeName)||t.contentEditable=="false")return!1;e=cs(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?Cr(t):0}else return!1}}function Cr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function v8(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=Cr(t)}else if(t.parentNode&&!iu(t))e=cs(t),t=t.parentNode;else return null}}function N8(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!iu(t))e=cs(t)+1,t=t.parentNode;else return null}}function w8(t,e,n){for(let s=e==0,a=e==Cr(t);s||a;){if(t==n)return!0;let i=cs(t);if(t=t.parentNode,!t)return!1;s=s&&i==0,a=a&&i==Cr(t)}}function iu(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const cp=function(t){return t.focusNode&&hl(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Wo(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function j8(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function k8(t,e,n){if(t.caretPositionFromPoint)try{let s=t.caretPositionFromPoint(e,n);if(s)return{node:s.offsetNode,offset:Math.min(Cr(s.offsetNode),s.offset)}}catch{}if(t.caretRangeFromPoint){let s=t.caretRangeFromPoint(e,n);if(s)return{node:s.startContainer,offset:Math.min(Cr(s.startContainer),s.startOffset)}}}const Ea=typeof navigator<"u"?navigator:null,X1=typeof document<"u"?document:null,xo=Ea&&Ea.userAgent||"",jx=/Edge\/(\d+)/.exec(xo),XS=/MSIE \d/.exec(xo),kx=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(xo),Ys=!!(XS||kx||jx),to=XS?document.documentMode:kx?+kx[1]:jx?+jx[1]:0,Er=!Ys&&/gecko\/(\d+)/i.test(xo);Er&&+(/Firefox\/(\d+)/.exec(xo)||[0,0])[1];const Sx=!Ys&&/Chrome\/(\d+)/.exec(xo),ms=!!Sx,ZS=Sx?+Sx[1]:0,Es=!Ys&&!!Ea&&/Apple Computer/.test(Ea.vendor),Nc=Es&&(/Mobile\/\w+/.test(xo)||!!Ea&&Ea.maxTouchPoints>2),Sr=Nc||(Ea?/Mac/.test(Ea.platform):!1),e2=Ea?/Win/.test(Ea.platform):!1,ii=/Android \d/.test(xo),ou=!!X1&&"webkitFontSmoothing"in X1.documentElement.style,S8=ou?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function C8(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 Xa(t,e){return typeof t=="number"?t:t[e]}function E8(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,s=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*s}}function Z1(t,e,n){let s=t.someProp("scrollThreshold")||0,a=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=vc(o);continue}let c=o,u=c==i.body,h=u?C8(i):E8(c),f=0,m=0;if(e.top<h.top+Xa(s,"top")?m=-(h.top-e.top+Xa(a,"top")):e.bottom>h.bottom-Xa(s,"bottom")&&(m=e.bottom-e.top>h.bottom-h.top?e.top+Xa(a,"top")-h.top:e.bottom-h.bottom+Xa(a,"bottom")),e.left<h.left+Xa(s,"left")?f=-(h.left-e.left+Xa(a,"left")):e.right>h.right-Xa(s,"right")&&(f=e.right-h.right+Xa(a,"right")),f||m)if(u)i.defaultView.scrollBy(f,m);else{let y=c.scrollLeft,v=c.scrollTop;m&&(c.scrollTop+=m),f&&(c.scrollLeft+=f);let w=c.scrollLeft-y,N=c.scrollTop-v;e={left:e.left-w,top:e.top-N,right:e.right-w,bottom:e.bottom-N}}let g=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(g))break;o=g=="absolute"?o.offsetParent:vc(o)}}function T8(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),s,a;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let c=t.root.elementFromPoint(i,o);if(!c||c==t.dom||!t.dom.contains(c))continue;let u=c.getBoundingClientRect();if(u.top>=n-20){s=c,a=u.top;break}}return{refDOM:s,refTop:a,stack:t2(t.dom)}}function t2(t){let e=[],n=t.ownerDocument;for(let s=t;s&&(e.push({dom:s,top:s.scrollTop,left:s.scrollLeft}),t!=n);s=vc(s));return e}function M8({refDOM:t,refTop:e,stack:n}){let s=t?t.getBoundingClientRect().top:0;n2(n,s==0?0:s-e)}function n2(t,e){for(let n=0;n<t.length;n++){let{dom:s,top:a,left:i}=t[n];s.scrollTop!=a+e&&(s.scrollTop=a+e),s.scrollLeft!=i&&(s.scrollLeft=i)}}let Zl=null;function A8(t){if(t.setActive)return t.setActive();if(Zl)return t.focus(Zl);let e=t2(t);t.focus(Zl==null?{get preventScroll(){return Zl={preventScroll:!0},!0}}:void 0),Zl||(Zl=!1,n2(e,0))}function s2(t,e){let n,s=2e8,a,i=0,o=e.top,c=e.top,u,h;for(let f=t.firstChild,m=0;f;f=f.nextSibling,m++){let g;if(f.nodeType==1)g=f.getClientRects();else if(f.nodeType==3)g=si(f).getClientRects();else continue;for(let y=0;y<g.length;y++){let v=g[y];if(v.top<=o&&v.bottom>=c){o=Math.max(v.bottom,o),c=Math.min(v.top,c);let w=v.left>e.left?v.left-e.left:v.right<e.left?e.left-v.right:0;if(w<s){n=f,s=w,a=w&&n.nodeType==3?{left:v.right<e.left?v.right:v.left,top:e.top}:e,f.nodeType==1&&w&&(i=m+(e.left>=(v.left+v.right)/2?1:0));continue}}else v.top>e.top&&!u&&v.left<=e.left&&v.right>=e.left&&(u=f,h={left:Math.max(v.left,Math.min(v.right,e.left)),top:v.top});!n&&(e.left>=v.right&&e.top>=v.top||e.left>=v.left&&e.top>=v.bottom)&&(i=m+1)}}return!n&&u&&(n=u,a=h,s=0),n&&n.nodeType==3?I8(n,a):!n||s&&n.nodeType==1?{node:t,offset:i}:s2(n,a)}function I8(t,e){let n=t.nodeValue.length,s=document.createRange(),a;for(let i=0;i<n;i++){s.setEnd(t,i+1),s.setStart(t,i);let o=Bi(s,1);if(o.top!=o.bottom&&F0(e,o)){a={node:t,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return s.detach(),a||{node:t,offset:0}}function F0(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function R8(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function P8(t,e,n){let{node:s,offset:a}=s2(e,n),i=-1;if(s.nodeType==1&&!s.firstChild){let o=s.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(s,a,i)}function O8(t,e,n,s){let a=-1;for(let i=e,o=!1;i!=t.dom;){let c=t.docView.nearestDesc(i,!0),u;if(!c)return null;if(c.dom.nodeType==1&&(c.node.isBlock&&c.parent||!c.contentDOM)&&((u=c.dom.getBoundingClientRect()).width||u.height)&&(c.node.isBlock&&c.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(c.dom.nodeName)&&(!o&&u.left>s.left||u.top>s.top?a=c.posBefore:(!o&&u.right<s.left||u.bottom<s.top)&&(a=c.posAfter),o=!0),!c.contentDOM&&a<0&&!c.node.isText))return(c.node.isBlock?s.top<(u.top+u.bottom)/2:s.left<(u.left+u.right)/2)?c.posBefore:c.posAfter;i=c.dom.parentNode}return a>-1?a:t.docView.posFromDOM(e,n,-1)}function r2(t,e,n){let s=t.childNodes.length;if(s&&n.top<n.bottom)for(let a=Math.max(0,Math.min(s-1,Math.floor(s*(e.top-n.top)/(n.bottom-n.top))-2)),i=a;;){let o=t.childNodes[i];if(o.nodeType==1){let c=o.getClientRects();for(let u=0;u<c.length;u++){let h=c[u];if(F0(e,h))return r2(o,e,h)}}if((i=(i+1)%s)==a)break}return t}function L8(t,e){let n=t.dom.ownerDocument,s,a=0,i=k8(n,e.left,e.top);i&&({node:s,offset:a}=i);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),c;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let h=t.dom.getBoundingClientRect();if(!F0(e,h)||(o=r2(t.dom,e,h),!o))return null}if(Es)for(let h=o;s&&h;h=vc(h))h.draggable&&(s=void 0);if(o=R8(o,e),s){if(Er&&s.nodeType==1&&(a=Math.min(a,s.childNodes.length),a<s.childNodes.length)){let f=s.childNodes[a],m;f.nodeName=="IMG"&&(m=f.getBoundingClientRect()).right<=e.left&&m.bottom>e.top&&a++}let h;ou&&a&&s.nodeType==1&&(h=s.childNodes[a-1]).nodeType==1&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=e.top&&a--,s==t.dom&&a==s.childNodes.length-1&&s.lastChild.nodeType==1&&e.top>s.lastChild.getBoundingClientRect().bottom?c=t.state.doc.content.size:(a==0||s.nodeType!=1||s.childNodes[a-1].nodeName!="BR")&&(c=O8(t,s,a,e))}c==null&&(c=P8(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function eN(t){return t.top<t.bottom||t.left<t.right}function Bi(t,e){let n=t.getClientRects();if(n.length){let s=n[e<0?0:n.length-1];if(eN(s))return s}return Array.prototype.find.call(n,eN)||t.getBoundingClientRect()}const D8=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function a2(t,e,n){let{node:s,offset:a,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=ou||Er;if(s.nodeType==3)if(o&&(D8.test(s.nodeValue)||(n<0?!a:a==s.nodeValue.length))){let u=Bi(si(s,a,a),n);if(Er&&a&&/\s/.test(s.nodeValue[a-1])&&a<s.nodeValue.length){let h=Bi(si(s,a-1,a-1),-1);if(h.top==u.top){let f=Bi(si(s,a,a+1),-1);if(f.top!=u.top)return hd(f,f.left<h.left)}}return u}else{let u=a,h=a,f=n<0?1:-1;return n<0&&!a?(h++,f=-1):n>=0&&a==s.nodeValue.length?(u--,f=1):n<0?u--:h++,hd(Bi(si(s,u,h),f),f<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&a&&(n<0||a==Cr(s))){let u=s.childNodes[a-1];if(u.nodeType==1)return Sg(u.getBoundingClientRect(),!1)}if(i==null&&a<Cr(s)){let u=s.childNodes[a];if(u.nodeType==1)return Sg(u.getBoundingClientRect(),!0)}return Sg(s.getBoundingClientRect(),n>=0)}if(i==null&&a&&(n<0||a==Cr(s))){let u=s.childNodes[a-1],h=u.nodeType==3?si(u,Cr(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(h)return hd(Bi(h,1),!1)}if(i==null&&a<Cr(s)){let u=s.childNodes[a];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let h=u?u.nodeType==3?si(u,0,o?0:1):u.nodeType==1?u:null:null;if(h)return hd(Bi(h,-1),!0)}return hd(Bi(s.nodeType==3?si(s):s,-n),n>=0)}function hd(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 Sg(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 i2(t,e,n){let s=t.state,a=t.root.activeElement;s!=e&&t.updateState(e),a!=t.dom&&t.focus();try{return n()}finally{s!=e&&t.updateState(s),a!=t.dom&&a&&a.focus()}}function _8(t,e,n){let s=e.selection,a=n=="up"?s.$from:s.$to;return i2(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=a2(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=si(c,0,c.nodeValue.length).getClientRects();else continue;for(let h=0;h<u.length;h++){let f=u[h];if(f.bottom>f.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 z8=/[\u0590-\u08ac]/;function $8(t,e,n){let{$head:s}=e.selection;if(!s.parent.isTextblock)return!1;let a=s.parentOffset,i=!a,o=a==s.parent.content.size,c=t.domSelection();return c?!z8.test(s.parent.textContent)||!c.modify?n=="left"||n=="backward"?i:o:i2(t,e,()=>{let{focusNode:u,focusOffset:h,anchorNode:f,anchorOffset:m}=t.domSelectionRange(),g=c.caretBidiLevel;c.modify("move",n,"character");let y=s.depth?t.docView.domAfterPos(s.before()):t.dom,{focusNode:v,focusOffset:w}=t.domSelectionRange(),N=v&&!y.contains(v.nodeType==1?v:v.parentNode)||u==v&&h==w;try{c.collapse(f,m),u&&(u!=f||h!=m)&&c.extend&&c.extend(u,h)}catch{}return g!=null&&(c.caretBidiLevel=g),N}):s.pos==s.start()||s.pos==s.end()}let tN=null,nN=null,sN=!1;function F8(t,e,n){return tN==e&&nN==n?sN:(tN=e,nN=n,sN=n=="up"||n=="down"?_8(t,e,n):$8(t,e,n))}const Tr=0,rN=1,Yo=2,Ta=3;class lu{constructor(e,n,s,a){this.parent=e,this.children=n,this.dom=s,this.contentDOM=a,this.dirty=Tr,s.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,s){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,s=this.posAtStart;;n++){let a=this.children[n];if(a==e)return s;s+=a.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,s){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(s<0){let i,o;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let a;if(e==this.dom&&this.contentDOM)a=n>cs(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){a=!1;break}if(i.previousSibling)break}if(a==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){a=!0;break}if(i.nextSibling)break}}return a??s>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let s=!0,a=e;a;a=a.parentNode){let i=this.getDesc(a),o;if(i&&(!n||i.node))if(s&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))s=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let s=n;s;s=s.parent)if(s==this)return n}posFromDOM(e,n,s){for(let a=e;a;a=a.parentNode){let i=this.getDesc(a);if(i)return i.localPosFromDOM(e,n,s)}return-1}descAt(e){for(let n=0,s=0;n<this.children.length;n++){let a=this.children[n],i=s+a.size;if(s==e&&i!=s){for(;!a.border&&a.children.length;)for(let o=0;o<a.children.length;o++){let c=a.children[o];if(c.size){a=c;break}}return a}if(e<i)return a.descAt(e-s-a.border);s=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let s=0,a=0;for(let i=0;s<this.children.length;s++){let o=this.children[s],c=i+o.size;if(c>e||o instanceof l2){a=e-i;break}i=c}if(a)return this.children[s].domFromPos(a-this.children[s].border,n);for(let i;s&&!(i=this.children[s-1]).size&&i instanceof o2&&i.side>=0;s--);if(n<=0){let i,o=!0;for(;i=s?this.children[s-1]:null,!(!i||i.dom.parentNode==this.contentDOM);s--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?cs(i.dom)+1:0}}else{let i,o=!0;for(;i=s<this.children.length?this.children[s]:null,!(!i||i.dom.parentNode==this.contentDOM);s++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?cs(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,s=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let a=-1,i=-1;for(let o=s,c=0;;c++){let u=this.children[c],h=o+u.size;if(a==-1&&e<=h){let f=o+u.border;if(e>=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=cs(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;f<this.children.length;f++){let m=this.children[f];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(-1)){i=cs(m.dom);break}n+=m.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=h}return{node:this.contentDOM,from:e,to:n,fromOffset:a,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:s}=this.domFromPos(e,0);if(n.nodeType!=1||s==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[s]}setSelection(e,n,s,a=!1){let i=Math.min(e,n),o=Math.max(e,n);for(let y=0,v=0;y<this.children.length;y++){let w=this.children[y],N=v+w.size;if(i>v&&o<N)return w.setSelection(e-v-w.border,n-v-w.border,s,a);v=N}let c=this.domFromPos(e,e?-1:1),u=n==e?c:this.domFromPos(n,n?-1:1),h=s.root.getSelection(),f=s.domSelectionRange(),m=!1;if((Er||Es)&&e==n){let{node:y,offset:v}=c;if(y.nodeType==3){if(m=!!(v&&y.nodeValue[v-1]==`
`),m&&v==y.nodeValue.length)for(let w=y,N;w;w=w.parentNode){if(N=w.nextSibling){N.nodeName=="BR"&&(c=u={node:N.parentNode,offset:cs(N)+1});break}let k=w.pmViewDesc;if(k&&k.node&&k.node.isBlock)break}}else{let w=y.childNodes[v-1];m=w&&(w.nodeName=="BR"||w.contentEditable=="false")}}if(Er&&f.focusNode&&f.focusNode!=u.node&&f.focusNode.nodeType==1){let y=f.focusNode.childNodes[f.focusOffset];y&&y.contentEditable=="false"&&(a=!0)}if(!(a||m&&Es)&&hl(c.node,c.offset,f.anchorNode,f.anchorOffset)&&hl(u.node,u.offset,f.focusNode,f.focusOffset))return;let g=!1;if((h.extend||e==n)&&!(m&&Er)){h.collapse(c.node,c.offset);try{e!=n&&h.extend(u.node,u.offset),g=!0}catch{}}if(!g){if(e>n){let v=c;c=u,u=v}let y=document.createRange();y.setEnd(u.node,u.offset),y.setStart(c.node,c.offset),h.removeAllRanges(),h.addRange(y)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let s=0,a=0;a<this.children.length;a++){let i=this.children[a],o=s+i.size;if(s==o?e<=o&&n>=s:e<o&&n>s){let c=s+i.border,u=o-i.border;if(e>=c&&n<=u){this.dirty=e==s||n==o?Yo:rN,e==c&&n==u&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ta:i.markDirty(e-c,n-c);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Yo:Ta}s=o}this.dirty=Yo}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let s=e==1?Yo:rN;n.dirty<s&&(n.dirty=s)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class o2 extends lu{constructor(e,n,s,a){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(s,()=>{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 B8 extends lu{constructor(e,n,s,a){super(e,[],n,null),this.textDOM=s,this.text=a}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class fl extends lu{constructor(e,n,s,a,i){super(e,[],s,a),this.mark=n,this.spec=i}static create(e,n,s,a){let i=a.nodeViews[n.type.name],o=i&&i(n,a,s);return(!o||!o.dom)&&(o=vl.renderSpec(document,n.type.spec.toDOM(n,s),null,n.attrs)),new fl(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ta||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ta&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Tr){let s=this.parent;for(;!s.node;)s=s.parent;s.dirty<this.dirty&&(s.dirty=this.dirty),this.dirty=Tr}}slice(e,n,s){let a=fl.create(this.parent,this.mark,!0,s),i=this.children,o=this.size;n<o&&(i=Ex(i,n,o,s)),e>0&&(i=Ex(i,0,e,s));for(let c=0;c<i.length;c++)i[c].parent=a;return a.children=i,a}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class no extends lu{constructor(e,n,s,a,i,o,c,u,h){super(e,[],i,o),this.node=n,this.outerDeco=s,this.innerDeco=a,this.nodeDOM=c}static create(e,n,s,a,i,o){let c=i.nodeViews[n.type.name],u,h=c&&c(n,i,()=>{if(!u)return o;if(u.parent)return u.parent.posBeforeChild(u)},s,a),f=h&&h.dom,m=h&&h.contentDOM;if(n.isText){if(!f)f=document.createTextNode(n.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:m}=vl.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=u2(f,s,n),h?u=new V8(e,n,s,a,f,m||null,g,h,i,o+1):n.isText?new dp(e,n,s,a,f,g,i):new no(e,n,s,a,f,m||null,g,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let s=this.children[n];if(this.dom.contains(s.dom.parentNode)){e.contentElement=s.dom.parentNode;break}}e.contentElement||(e.getContent=()=>we.empty)}return e}matchesNode(e,n,s){return this.dirty==Tr&&e.eq(this.node)&&af(n,this.outerDeco)&&s.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let s=this.node.inlineContent,a=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,c=i&&i.pos<0,u=new U8(this,o&&o.node,e);q8(this.node,this.innerDeco,(h,f,m)=>{h.spec.marks?u.syncToMarks(h.spec.marks,s,e,f):h.type.side>=0&&!m&&u.syncToMarks(f==this.node.childCount?Qt.none:this.node.child(f).marks,s,e,f),u.placeWidget(h,e,a)},(h,f,m,g)=>{u.syncToMarks(h.marks,s,e,g);let y;u.findNodeMatch(h,f,m,g)||c&&e.state.selection.from>a&&e.state.selection.to<a+h.nodeSize&&(y=u.findIndexWithChild(i.node))>-1&&u.updateNodeAt(h,f,m,y,e)||u.updateNextNode(h,f,m,e,g,a)||u.addNode(h,f,m,e,a),a+=h.nodeSize}),u.syncToMarks([],s,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==Yo)&&(o&&this.protectLocalComposition(e,o),c2(this.contentDOM,this.children,e),Nc&&G8(this.dom))}localCompositionInfo(e,n){let{from:s,to:a}=e.state.selection;if(!(e.state.selection instanceof nt)||s<n||a>n+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=J8(this.node.content,o,s-n,a-n);return c<0?null:{node:i,pos:c,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:s,text:a}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new B8(this,i,n,a);e.input.compositionNodes.push(o),this.children=Ex(this.children,s,s+a.length,e,o)}update(e,n,s,a){return this.dirty==Ta||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,s,a),!0)}updateInner(e,n,s,a){this.updateOuterDeco(n),this.node=e,this.innerDeco=s,this.contentDOM&&this.updateChildren(a,this.posAtStart),this.dirty=Tr}updateOuterDeco(e){if(af(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,s=this.dom;this.dom=d2(this.dom,this.nodeDOM,Cx(this.outerDeco,this.node,n),Cx(e,this.node,n)),this.dom!=s&&(s.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function aN(t,e,n,s,a){u2(s,e,t);let i=new no(void 0,t,e,n,s,s,s,a,0);return i.contentDOM&&i.updateChildren(a,0),i}class dp extends no{constructor(e,n,s,a,i,o,c){super(e,n,s,a,i,null,o,c,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,s,a){return this.dirty==Ta||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,s){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,s)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,s){let a=this.node.cut(e,n),i=document.createTextNode(a.text);return new dp(this.parent,a,this.outerDeco,this.innerDeco,i,i,s)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Ta)}get domAtom(){return!1}isText(e){return this.node.text==e}}class l2 extends lu{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 V8 extends no{constructor(e,n,s,a,i,o,c,u,h,f){super(e,n,s,a,i,o,c,h,f),this.spec=u}update(e,n,s,a){if(this.dirty==Ta)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,s);return i&&this.updateInner(e,n,s,a),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,s,a)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,s,a){this.spec.setSelection?this.spec.setSelection(e,n,s.root):super.setSelection(e,n,s,a)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function c2(t,e,n){let s=t.firstChild,a=!1;for(let i=0;i<e.length;i++){let o=e[i],c=o.dom;if(c.parentNode==t){for(;c!=s;)s=iN(s),a=!0;s=s.nextSibling}else a=!0,t.insertBefore(c,s);if(o instanceof fl){let u=s?s.previousSibling:t.lastChild;c2(o.contentDOM,o.children,n),s=u?u.nextSibling:t.firstChild}}for(;s;)s=iN(s),a=!0;a&&n.trackWrites==t&&(n.trackWrites=null)}const Td=function(t){t&&(this.nodeName=t)};Td.prototype=Object.create(null);const Qo=[new Td];function Cx(t,e,n){if(t.length==0)return Qo;let s=n?Qo[0]:new Td,a=[s];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&a.push(s=new Td(o.nodeName));for(let c in o){let u=o[c];u!=null&&(n&&a.length==1&&a.push(s=new Td(e.isInline?"span":"div")),c=="class"?s.class=(s.class?s.class+" ":"")+u:c=="style"?s.style=(s.style?s.style+";":"")+u:c!="nodeName"&&(s[c]=u))}}}return a}function d2(t,e,n,s){if(n==Qo&&s==Qo)return e;let a=e;for(let i=0;i<s.length;i++){let o=s[i],c=n[i];if(i){let u;c&&c.nodeName==o.nodeName&&a!=t&&(u=a.parentNode)&&u.nodeName.toLowerCase()==o.nodeName||(u=document.createElement(o.nodeName),u.pmIsDeco=!0,u.appendChild(a),c=Qo[0]),a=u}H8(a,c||Qo[0],o)}return a}function H8(t,e,n){for(let s in e)s!="class"&&s!="style"&&s!="nodeName"&&!(s in n)&&t.removeAttribute(s);for(let s in n)s!="class"&&s!="style"&&s!="nodeName"&&n[s]!=e[s]&&t.setAttribute(s,n[s]);if(e.class!=n.class){let s=e.class?e.class.split(" ").filter(Boolean):[],a=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<s.length;i++)a.indexOf(s[i])==-1&&t.classList.remove(s[i]);for(let i=0;i<a.length;i++)s.indexOf(a[i])==-1&&t.classList.add(a[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let s=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,a;for(;a=s.exec(e.style);)t.style.removeProperty(a[1])}n.style&&(t.style.cssText+=n.style)}}function u2(t,e,n){return d2(t,t,Qo,Cx(e,n,t.nodeType!=1))}function af(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function iN(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class U8{constructor(e,n,s){this.lock=n,this.view=s,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=W8(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let s=e;s<n;s++)this.top.children[s].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,s,a){let i=0,o=this.stack.length>>1,c=Math.min(o,e.length);for(;i<c&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=Tr,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let u=-1,h=this.top.children.length;a<this.preMatch.index&&(h=Math.min(this.index+3,h));for(let f=this.index;f<h;f++){let m=this.top.children[f];if(m.matchesMark(e[o])&&!this.isLocked(m.dom)){u=f;break}}if(u>-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let f=fl.create(this.top,e[o],n,s);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,s,a){let i=-1,o;if(a>=this.preMatch.index&&(o=this.preMatch.matches[a-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,s))i=this.top.children.indexOf(o,this.index);else for(let c=this.index,u=Math.min(this.top.children.length,c+5);c<u;c++){let h=this.top.children[c];if(h.matchesNode(e,n,s)&&!this.preMatch.matched.has(h)){i=c;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,s,a,i){let o=this.top.children[a];return o.dirty==Ta&&o.dom==o.contentDOM&&(o.dirty=Yo),o.update(e,n,s,i)?(this.destroyBetween(this.index,a),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let s=e.pmViewDesc;if(s){for(let a=this.index;a<this.top.children.length;a++)if(this.top.children[a]==s)return a}return-1}e=n}}updateNextNode(e,n,s,a,i,o){for(let c=this.index;c<this.top.children.length;c++){let u=this.top.children[c];if(u instanceof no){let h=this.preMatch.matched.get(u);if(h!=null&&h!=i)return!1;let f=u.dom,m,g=this.isLocked(f)&&!(e.isText&&u.node&&u.node.isText&&u.nodeDOM.nodeValue==e.text&&u.dirty!=Ta&&af(n,u.outerDeco));if(!g&&u.update(e,n,s,a))return this.destroyBetween(this.index,c),u.dom!=f&&(this.changed=!0),this.index++,!0;if(!g&&(m=this.recreateWrapper(u,e,n,s,a,o)))return this.destroyBetween(this.index,c),this.top.children[this.index]=m,m.contentDOM&&(m.dirty=Yo,m.updateChildren(a,o+1),m.dirty=Tr),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,s,a,i,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!af(s,e.outerDeco)||!a.eq(e.innerDeco))return null;let c=no.create(this.top,n,s,a,i,o);if(c.contentDOM){c.children=e.children,e.children=[];for(let u of c.children)u.parent=c}return e.destroy(),c}addNode(e,n,s,a,i){let o=no.create(this.top,e,n,s,a,i);o.contentDOM&&o.updateChildren(a,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,s){let a=this.index<this.top.children.length?this.top.children[this.index]:null;if(a&&a.matchesWidget(e)&&(e==a.widget||!a.widget.type.toDOM.parentNode))this.index++;else{let i=new o2(this.top,e,n,s);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof fl;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof dp)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Es||ms)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let s=document.createElement(e);e=="IMG"&&(s.className="ProseMirror-separator",s.alt=""),e=="BR"&&(s.className="ProseMirror-trailingBreak");let a=new l2(this.top,[],s,null);n!=this.top?n.children.push(a):n.children.splice(this.index++,0,a),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function W8(t,e){let n=e,s=n.children.length,a=t.childCount,i=new Map,o=[];e:for(;a>0;){let c;for(;;)if(s){let h=n.children[s-1];if(h instanceof fl)n=h,s=h.children.length;else{c=h,s--;break}}else{if(n==e)break e;s=n.parent.children.indexOf(n),n=n.parent}let u=c.node;if(u){if(u!=t.child(a-1))break;--a,i.set(c,a),o.push(c)}}return{index:a,matched:i,matches:o.reverse()}}function K8(t,e){return t.type.side-e.type.side}function q8(t,e,n,s){let a=e.locals(t),i=0;if(a.length==0){for(let h=0;h<t.childCount;h++){let f=t.child(h);s(f,a,e.forChild(i,f),h),i+=f.nodeSize}return}let o=0,c=[],u=null;for(let h=0;;){let f,m;for(;o<a.length&&a[o].to==i;){let N=a[o++];N.widget&&(f?(m||(m=[f])).push(N):f=N)}if(f)if(m){m.sort(K8);for(let N=0;N<m.length;N++)n(m[N],h,!!u)}else n(f,h,!!u);let g,y;if(u)y=-1,g=u,u=null;else if(h<t.childCount)y=h,g=t.child(h++);else break;for(let N=0;N<c.length;N++)c[N].to<=i&&c.splice(N--,1);for(;o<a.length&&a[o].from<=i&&a[o].to>i;)c.push(a[o++]);let v=i+g.nodeSize;if(g.isText){let N=v;o<a.length&&a[o].from<N&&(N=a[o].from);for(let k=0;k<c.length;k++)c[k].to<N&&(N=c[k].to);N<v&&(u=g.cut(N-i),g=g.cut(0,N-i),v=N,y=-1)}else for(;o<a.length&&a[o].to<v;)o++;let w=g.isInline&&!g.isLeaf?c.filter(N=>!N.inline):c.slice();s(g,w,e.forChild(i,g),y),i=v}}function G8(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 J8(t,e,n,s){for(let a=0,i=0;a<t.childCount&&i<=s;){let o=t.child(a++),c=i;if(i+=o.nodeSize,!o.isText)continue;let u=o.text;for(;a<t.childCount;){let h=t.child(a++);if(i+=h.nodeSize,!h.isText)break;u+=h.text}if(i>=n){if(i>=s&&u.slice(s-e.length-c,s-c)==e)return s-e.length;let h=c<s?u.lastIndexOf(e,s-c-1):-1;if(h>=0&&h+e.length+c>=n)return c+h;if(n==s&&u.length>=s+e.length-c&&u.slice(s-c,s-c+e.length)==e)return s}}return-1}function Ex(t,e,n,s,a){let i=[];for(let o=0,c=0;o<t.length;o++){let u=t[o],h=c,f=c+=u.size;h>=n||f<=e?i.push(u):(h<e&&i.push(u.slice(0,e-h,s)),a&&(i.push(a),a=void 0),f>n&&i.push(u.slice(n-h,u.size,s)))}return i}function B0(t,e=null){let n=t.domSelectionRange(),s=t.state.doc;if(!n.focusNode)return null;let a=t.docView.nearestDesc(n.focusNode),i=a&&a.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let c=s.resolve(o),u,h;if(cp(n)){for(u=o;a&&!a.node;)a=a.parent;let m=a.node;if(a&&m.isAtom&&et.isSelectable(m)&&a.parent&&!(m.isInline&&w8(n.focusNode,n.focusOffset,a.dom))){let g=a.posBefore;h=new et(o==g?c:s.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=o,g=o;for(let y=0;y<n.rangeCount;y++){let v=n.getRangeAt(y);m=Math.min(m,t.docView.posFromDOM(v.startContainer,v.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(m<0)return null;[u,o]=g==t.state.selection.anchor?[g,m]:[m,g],c=s.resolve(o)}else u=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(u<0)return null}let f=s.resolve(u);if(!h){let m=e=="pointer"||t.state.selection.head<c.pos&&!i?1:-1;h=V0(t,f,c,m)}return h}function h2(t){return t.editable?t.hasFocus():p2(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function ci(t,e=!1){let n=t.state.selection;if(f2(t,n),!!h2(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ms){let s=t.domSelectionRange(),a=t.domObserver.currentSelection;if(s.anchorNode&&a.anchorNode&&hl(s.anchorNode,s.anchorOffset,a.anchorNode,a.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Q8(t);else{let{anchor:s,head:a}=n,i,o;oN&&!(n instanceof nt)&&(n.$from.parent.inlineContent||(i=lN(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=lN(t,n.to))),t.docView.setSelection(s,a,t,e),oN&&(i&&cN(i),o&&cN(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Y8(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const oN=Es||ms&&ZS<63;function lN(t,e){let{node:n,offset:s}=t.docView.domFromPos(e,0),a=s<n.childNodes.length?n.childNodes[s]:null,i=s?n.childNodes[s-1]:null;if(Es&&a&&a.contentEditable=="false")return Cg(a);if((!a||a.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(a)return Cg(a);if(i)return Cg(i)}}function Cg(t){return t.contentEditable="true",Es&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function cN(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Y8(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),s=n.anchorNode,a=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=s||n.anchorOffset!=a)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!h2(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Q8(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,s=n.nodeName=="IMG";s?e.collapse(n.parentNode,cs(n)+1):e.collapse(n,0),!s&&!t.state.selection.visible&&Ys&&to<=11&&(n.disabled=!0,n.disabled=!1)}function f2(t,e){if(e instanceof et){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(dN(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else dN(t)}function dN(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function V0(t,e,n,s){return t.someProp("createSelectionBetween",a=>a(t,e,n))||nt.between(e,n,s)}function uN(t){return t.editable&&!t.hasFocus()?!1:p2(t)}function p2(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 X8(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return hl(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Tx(t,e){let{$anchor:n,$head:s}=t.selection,a=e>0?n.max(s):n.min(s),i=a.parent.inlineContent?a.depth?t.doc.resolve(e>0?a.after():a.before()):null:a;return i&&lt.findFrom(i,e)}function Vi(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function hN(t,e,n){let s=t.state.selection;if(s instanceof nt)if(n.indexOf("s")>-1){let{$head:a}=s,i=a.textOffset?null:e<0?a.nodeBefore:a.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(a.pos+i.nodeSize*(e<0?-1:1));return Vi(t,new nt(s.$anchor,o))}else if(s.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let a=Tx(t.state,e);return a&&a instanceof et?Vi(t,a):!1}else if(!(Sr&&n.indexOf("m")>-1)){let a=s.$head,i=a.textOffset?null:e<0?a.nodeBefore:a.nodeAfter,o;if(!i||i.isText)return!1;let c=e<0?a.pos-i.nodeSize:a.pos;return i.isAtom||(o=t.docView.descAt(c))&&!o.contentDOM?et.isSelectable(i)?Vi(t,new et(e<0?t.state.doc.resolve(a.pos-i.nodeSize):a)):ou?Vi(t,new nt(t.state.doc.resolve(e<0?c:c+i.nodeSize))):!1:!1}}else return!1;else{if(s instanceof et&&s.node.isInline)return Vi(t,new nt(e>0?s.$to:s.$from));{let a=Tx(t.state,e);return a?Vi(t,a):!1}}}function of(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Md(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function ec(t,e){return e<0?Z8(t):eL(t)}function Z8(t){let e=t.domSelectionRange(),n=e.focusNode,s=e.focusOffset;if(!n)return;let a,i,o=!1;for(Er&&n.nodeType==1&&s<of(n)&&Md(n.childNodes[s],-1)&&(o=!0);;)if(s>0){if(n.nodeType!=1)break;{let c=n.childNodes[s-1];if(Md(c,-1))a=n,i=--s;else if(c.nodeType==3)n=c,s=n.nodeValue.length;else break}}else{if(m2(n))break;{let c=n.previousSibling;for(;c&&Md(c,-1);)a=n.parentNode,i=cs(c),c=c.previousSibling;if(c)n=c,s=of(n);else{if(n=n.parentNode,n==t.dom)break;s=0}}}o?Mx(t,n,s):a&&Mx(t,a,i)}function eL(t){let e=t.domSelectionRange(),n=e.focusNode,s=e.focusOffset;if(!n)return;let a=of(n),i,o;for(;;)if(s<a){if(n.nodeType!=1)break;let c=n.childNodes[s];if(Md(c,1))i=n,o=++s;else break}else{if(m2(n))break;{let c=n.nextSibling;for(;c&&Md(c,1);)i=c.parentNode,o=cs(c)+1,c=c.nextSibling;if(c)n=c,s=0,a=of(n);else{if(n=n.parentNode,n==t.dom)break;s=a=0}}}i&&Mx(t,i,o)}function m2(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function tL(t,e){for(;t&&e==t.childNodes.length&&!iu(t);)e=cs(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function nL(t,e){for(;t&&!e&&!iu(t);)e=cs(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Mx(t,e,n){if(e.nodeType!=3){let i,o;(o=tL(e,n))?(e=o,n=0):(i=nL(e,n))&&(e=i,n=i.nodeValue.length)}let s=t.domSelection();if(!s)return;if(cp(s)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),s.removeAllRanges(),s.addRange(i)}else s.extend&&s.extend(e,n);t.domObserver.setCurSelection();let{state:a}=t;setTimeout(()=>{t.state==a&&ci(t)},50)}function fN(t,e){let n=t.state.doc.resolve(e);if(!(ms||e2)&&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&&o<a.bottom&&Math.abs(i.left-a.left)>1)return i.left<a.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>a.top&&o<a.bottom&&Math.abs(i.left-a.left)>1)return i.left>a.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function pN(t,e,n){let s=t.state.selection;if(s instanceof nt&&!s.empty||n.indexOf("s")>-1||Sr&&n.indexOf("m")>-1)return!1;let{$from:a,$to:i}=s;if(!a.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Tx(t.state,e);if(o&&o instanceof et)return Vi(t,o)}if(!a.parent.inlineContent){let o=e<0?a:i,c=s instanceof hr?lt.near(o,e):lt.findFrom(o,e);return c?Vi(t,c):!1}return!1}function mN(t,e){if(!(t.state.selection instanceof nt))return!0;let{$head:n,$anchor:s,empty:a}=t.state.selection;if(!n.sameParent(s))return!0;if(!a)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function gN(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function sL(t){if(!Es||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let s=e.firstChild;gN(t,s,"true"),setTimeout(()=>gN(t,s,"false"),20)}return!1}function rL(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function aL(t,e){let n=e.keyCode,s=rL(e);if(n==8||Sr&&n==72&&s=="c")return mN(t,-1)||ec(t,-1);if(n==46&&!e.shiftKey||Sr&&n==68&&s=="c")return mN(t,1)||ec(t,1);if(n==13||n==27)return!0;if(n==37||Sr&&n==66&&s=="c"){let a=n==37?fN(t,t.state.selection.from)=="ltr"?-1:1:-1;return hN(t,a,s)||ec(t,a)}else if(n==39||Sr&&n==70&&s=="c"){let a=n==39?fN(t,t.state.selection.from)=="ltr"?1:-1:1;return hN(t,a,s)||ec(t,a)}else{if(n==38||Sr&&n==80&&s=="c")return pN(t,-1,s)||ec(t,-1);if(n==40||Sr&&n==78&&s=="c")return sL(t)||pN(t,1,s)||ec(t,1);if(s==(Sr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function H0(t,e){t.someProp("transformCopied",y=>{e=y(e,t)});let n=[],{content:s,openStart:a,openEnd:i}=e;for(;a>1&&i>1&&s.childCount==1&&s.firstChild.childCount==1;){a--,i--;let y=s.firstChild;n.push(y.type.name,y.attrs!=y.type.defaultAttrs?y.attrs:null),s=y.content}let o=t.someProp("clipboardSerializer")||vl.fromSchema(t.state.schema),c=N2(),u=c.createElement("div");u.appendChild(o.serializeFragment(s,{document:c}));let h=u.firstChild,f,m=0;for(;h&&h.nodeType==1&&(f=v2[h.nodeName.toLowerCase()]);){for(let y=f.length-1;y>=0;y--){let v=c.createElement(f[y]);for(;u.firstChild;)v.appendChild(u.firstChild);u.appendChild(v),m++}h=u.firstChild}h&&h.nodeType==1&&h.setAttribute("data-pm-slice",`${a} ${i}${m?` -${m}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",y=>y(e,t))||e.content.textBetween(0,e.content.size,`
`);return{dom:u,text:g,slice:e}}function g2(t,e,n,s,a){let i=a.parent.type.spec.code,o,c;if(!n&&!e)return null;let u=!!e&&(s||i||!n);if(u){if(t.someProp("transformPastedText",g=>{e=g(e,i||s,t)}),i)return c=new ze(we.from(t.state.schema.text(e.replace(/\r\n?/g,`
`))),0,0),t.someProp("transformPasted",g=>{c=g(c,t,!0)}),c;let m=t.someProp("clipboardTextParser",g=>g(e,a,s,t));if(m)c=m;else{let g=a.marks(),{schema:y}=t.state,v=vl.fromSchema(y);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let N=o.appendChild(document.createElement("p"));w&&N.appendChild(v.serializeNode(y.text(w,g)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=cL(n),ou&&dL(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")||eo.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||f),context:a,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!iL.test(g.parentNode.nodeName)?{ignore:!0}:null}})),f)c=uL(xN(c,+f[1],+f[2]),f[4]);else if(c=ze.maxOpen(oL(c.content,a),!0),c.openStart||c.openEnd){let m=0,g=0;for(let y=c.content.firstChild;m<c.openStart&&!y.type.spec.isolating;m++,y=y.firstChild);for(let y=c.content.lastChild;g<c.openEnd&&!y.type.spec.isolating;g++,y=y.lastChild);c=xN(c,m,g)}return t.someProp("transformPasted",m=>{c=m(c,t,u)}),c}const iL=/^(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 oL(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&&y2(u,i,c,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=b2(o[o.length-1],i.length));let f=x2(c,u);o.push(f),a=a.matchType(f.type),i=u}}),o)return we.from(o)}return t}function x2(t,e,n=0){for(let s=e.length-1;s>=n;s--)t=e[s].create(null,we.from(t));return t}function y2(t,e,n,s,a){if(a<t.length&&a<e.length&&t[a]==e[a]){let i=y2(t,e,n,s.lastChild,a+1);if(i)return s.copy(s.content.replaceChild(s.childCount-1,i));if(s.contentMatchAt(s.childCount).matchType(a==t.length-1?n.type:t[a+1]))return s.copy(s.content.append(we.from(x2(n,t,a+1))))}}function b2(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,b2(t.lastChild,e-1)),s=t.contentMatchAt(t.childCount).fillBefore(we.empty,!0);return t.copy(n.append(s))}function Ax(t,e,n,s,a,i){let o=e<0?t.firstChild:t.lastChild,c=o.content;return t.childCount>1&&(i=0),a<s-1&&(c=Ax(c,e,n,s,a+1,i)),a>=n&&(c=e<0?o.contentMatchAt(0).fillBefore(c,i<=a).append(c):c.append(o.contentMatchAt(o.childCount).fillBefore(we.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(c))}function xN(t,e,n){return e<t.openStart&&(t=new ze(Ax(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new ze(Ax(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const v2={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let yN=null;function N2(){return yN||(yN=document.implementation.createHTMLDocument("title"))}let Eg=null;function lL(t){let e=window.trustedTypes;return e?(Eg||(Eg=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Eg.createHTML(t)):t}function cL(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=N2().createElement("div"),s=/<([a-z][^>\s]+)/i.exec(t),a;if((a=s&&v2[s[1].toLowerCase()])&&(t=a.map(i=>"<"+i+">").join("")+t+a.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=lL(t),a)for(let i=0;i<a.length;i++)n=n.querySelector(a[i])||n;return n}function dL(t){let e=t.querySelectorAll(ms?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let s=e[n];s.childNodes.length==1&&s.textContent==" "&&s.parentNode&&s.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),s)}}function uL(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,s;try{s=JSON.parse(e)}catch{return t}let{content:a,openStart:i,openEnd:o}=t;for(let c=s.length-2;c>=0;c-=2){let u=n.nodes[s[c]];if(!u||u.hasRequiredAttrs())break;a=we.from(u.create(s[c+1],a)),i++,o++}return new ze(a,i,o)}const Ds={},_s={},hL={touchstart:!0,touchmove:!0};class fL{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 pL(t){for(let e in Ds){let n=Ds[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=s=>{gL(t,s)&&!U0(t,s)&&(t.editable||!(s.type in _s))&&n(t,s)},hL[e]?{passive:!0}:void 0)}Es&&t.dom.addEventListener("input",()=>null),Ix(t)}function Qi(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function mL(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 Ix(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=s=>U0(t,s))})}function U0(t,e){return t.someProp("handleDOMEvents",n=>{let s=n[e.type];return s?s(t,e)||e.defaultPrevented:!1})}function gL(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 xL(t,e){!U0(t,e)&&Ds[e.type]&&(t.editable||!(e.type in _s))&&Ds[e.type](t,e)}_s.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!j2(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(ii&&ms&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Nc&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let s=Date.now();t.input.lastIOSEnter=s,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==s&&(t.someProp("handleKeyDown",a=>a(t,Wo(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",s=>s(t,n))||aL(t,n)?n.preventDefault():Qi(t,"key")};_s.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};_s.keypress=(t,e)=>{let n=e;if(j2(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Sr&&n.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,n))){n.preventDefault();return}let s=t.state.selection;if(!(s instanceof nt)||!s.$from.sameParent(s.$to)){let a=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(a).scrollIntoView();!/[\r\n]/.test(a)&&!t.someProp("handleTextInput",o=>o(t,s.$from.pos,s.$to.pos,a,i))&&t.dispatch(i()),n.preventDefault()}};function up(t){return{left:t.clientX,top:t.clientY}}function yL(t,e){let n=e.x-t.clientX,s=e.y-t.clientY;return n*n+s*s<100}function W0(t,e,n,s,a){if(s==-1)return!1;let i=t.state.doc.resolve(s);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,c=>o>i.depth?c(t,n,i.nodeAfter,i.before(o),a,!0):c(t,n,i.node(o),i.before(o),a,!1)))return!0;return!1}function hc(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let s=t.state.tr.setSelection(e);s.setMeta("pointer",!0),t.dispatch(s)}function bL(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),s=n.nodeAfter;return s&&s.isAtom&&et.isSelectable(s)?(hc(t,new et(n)),!0):!1}function vL(t,e){if(e==-1)return!1;let n=t.state.selection,s,a;n instanceof et&&(s=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let c=o>i.depth?i.nodeAfter:i.node(o);if(et.isSelectable(c)){s&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?a=i.before(n.$from.depth):a=i.before(o);break}}return a!=null?(hc(t,et.create(t.state.doc,a)),!0):!1}function NL(t,e,n,s,a){return W0(t,"handleClickOn",e,n,s)||t.someProp("handleClick",i=>i(t,e,s))||(a?vL(t,n):bL(t,n))}function wL(t,e,n,s){return W0(t,"handleDoubleClickOn",e,n,s)||t.someProp("handleDoubleClick",a=>a(t,e,s))}function jL(t,e,n,s){return W0(t,"handleTripleClickOn",e,n,s)||t.someProp("handleTripleClick",a=>a(t,e,s))||kL(t,n,s)}function kL(t,e,n){if(n.button!=0)return!1;let s=t.state.doc;if(e==-1)return s.inlineContent?(hc(t,nt.create(s,0,s.content.size)),!0):!1;let a=s.resolve(e);for(let i=a.depth+1;i>0;i--){let o=i>a.depth?a.nodeAfter:a.node(i),c=a.before(i);if(o.inlineContent)hc(t,nt.create(s,c+1,c+1+o.content.size));else if(et.isSelectable(o))hc(t,et.create(s,c));else continue;return!0}}function K0(t){return lf(t)}const w2=Sr?"metaKey":"ctrlKey";Ds.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let s=K0(t),a=Date.now(),i="singleClick";a-t.input.lastClick.time<500&&yL(n,t.input.lastClick)&&!n[w2]&&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(up(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new SL(t,o,n,!!s)):(i=="doubleClick"?wL:jL)(t,o.pos,o.inside,n)?n.preventDefault():Qi(t,"pointer"))};class SL{constructor(e,n,s,a){this.view=e,this.pos=n,this.event=s,this.flushed=a,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!s[w2],this.allowDefault=s.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let f=e.state.doc.resolve(n.pos);i=f.parent,o=f.depth?f.before():0}const c=a?null:s.target,u=c?e.docView.nearestDesc(c,!0):null;this.target=u&&u.nodeDOM.nodeType==1?u.nodeDOM:null;let{selection:h}=e.state;(s.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||h instanceof et&&h.from<=o&&h.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Er&&!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)),Qi(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(()=>ci(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(up(e))),this.updateAllowDefault(e),this.allowDefault||!n?Qi(this.view,"pointer"):NL(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Es&&this.mightDrag&&!this.mightDrag.node.isAtom||ms&&!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)?(hc(this.view,lt.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Qi(this.view,"pointer")}move(e){this.updateAllowDefault(e),Qi(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)}}Ds.touchstart=t=>{t.input.lastTouch=Date.now(),K0(t),Qi(t,"pointer")};Ds.touchmove=t=>{t.input.lastTouch=Date.now(),Qi(t,"pointer")};Ds.contextmenu=t=>K0(t);function j2(t,e){return t.composing?!0:Es&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const CL=ii?5e3:-1;_s.compositionstart=_s.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof nt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(s=>s.type.spec.inclusive===!1)||ms&&e2&&EL(t)))t.markCursor=t.state.storedMarks||n.marks(),lf(t,!0),t.markCursor=null;else if(lf(t,!e.selection.empty),Er&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let s=t.domSelectionRange();for(let a=s.focusNode,i=s.focusOffset;a&&a.nodeType==1&&i!=0;){let o=i<0?a.lastChild:a.childNodes[i-1];if(!o)break;if(o.nodeType==3){let c=t.domSelection();c&&c.collapse(o,o.nodeValue.length);break}else a=o,i=-1}}t.input.composing=!0}k2(t,CL)};function EL(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let s=e.childNodes[n];return s.nodeType==1&&s.contentEditable=="false"}_s.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++,k2(t,20))};function k2(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>lf(t),e))}function S2(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=ML());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function TL(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=v8(e.focusNode,e.focusOffset),s=N8(e.focusNode,e.focusOffset);if(n&&s&&n!=s){let a=s.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||s==i)return i;if(!a||!a.isText(s.nodeValue))return s;if(t.input.compositionNode==s){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return s}}return n||s}function ML(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function lf(t,e=!1){if(!(ii&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),S2(t),e||t.docView&&t.docView.dirty){let n=B0(t),s=t.state.selection;return n&&!n.eq(s)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!s.$from.node(s.$from.sharedDepth(s.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function AL(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let s=getSelection(),a=document.createRange();a.selectNodeContents(e),t.dom.blur(),s.removeAllRanges(),s.addRange(a),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Wd=Ys&&to<15||Nc&&S8<604;Ds.copy=_s.cut=(t,e)=>{let n=e,s=t.state.selection,a=n.type=="cut";if(s.empty)return;let i=Wd?null:n.clipboardData,o=s.content(),{dom:c,text:u}=H0(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",c.innerHTML),i.setData("text/plain",u)):AL(t,c),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function IL(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function RL(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,s=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(s.contentEditable="true"),s.style.cssText="position: fixed; left: -10000px; top: 10px",s.focus();let a=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),s.parentNode&&s.parentNode.removeChild(s),n?Kd(t,s.value,null,a,e):Kd(t,s.textContent,s.innerHTML,a,e)},50)}function Kd(t,e,n,s,a){let i=g2(t,e,n,s,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,a,i||ze.empty)))return!0;if(!i)return!1;let o=IL(i),c=o?t.state.tr.replaceSelectionWith(o,s):t.state.tr.replaceSelection(i);return t.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function C2(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," "):""}_s.paste=(t,e)=>{let n=e;if(t.composing&&!ii)return;let s=Wd?null:n.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;s&&Kd(t,C2(s),s.getData("text/html"),a,n)?n.preventDefault():RL(t,n)};class E2{constructor(e,n,s){this.slice=e,this.move=n,this.node=s}}const PL=Sr?"altKey":"ctrlKey";function T2(t,e){let n=t.someProp("dragCopies",s=>!s(e));return n??!e[PL]}Ds.dragstart=(t,e)=>{let n=e,s=t.input.mouseDown;if(s&&s.done(),!n.dataTransfer)return;let a=t.state.selection,i=a.empty?null:t.posAtCoords(up(n)),o;if(!(i&&i.pos>=a.from&&i.pos<=(a instanceof et?a.to-1:a.to))){if(s&&s.mightDrag)o=et.create(t.state.doc,s.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let m=t.docView.nearestDesc(n.target,!0);m&&m.node.type.spec.draggable&&m!=t.docView&&(o=et.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:u,text:h,slice:f}=H0(t,c);(!n.dataTransfer.files.length||!ms||ZS>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Wd?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Wd||n.dataTransfer.setData("text/plain",h),t.dragging=new E2(f,T2(t,n),o)};Ds.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};_s.dragover=_s.dragenter=(t,e)=>e.preventDefault();_s.drop=(t,e)=>{try{OL(t,e,t.dragging)}finally{t.dragging=null}};function OL(t,e,n){if(!e.dataTransfer)return;let s=t.posAtCoords(up(e));if(!s)return;let a=t.state.doc.resolve(s.pos),i=n&&n.slice;i?t.someProp("transformPasted",y=>{i=y(i,t,!1)}):i=g2(t,C2(e.dataTransfer),Wd?null:e.dataTransfer.getData("text/html"),!1,a);let o=!!(n&&T2(t,e));if(t.someProp("handleDrop",y=>y(t,e,i||ze.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let c=i?RS(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&&et.isSelectable(i.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(i.content.firstChild))u.setSelection(new et(g));else{let y=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((v,w,N,k)=>y=k),u.setSelection(V0(t,g,u.doc.resolve(y)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}Ds.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())&&ci(t)},20))};Ds.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)};Ds.beforeinput=(t,e)=>{if(ms&&ii&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:s}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=s||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,Wo(8,"Backspace")))))return;let{$cursor:a}=t.state.selection;a&&a.pos>0&&t.dispatch(t.state.tr.delete(a.pos-1,a.pos).scrollIntoView())},50)}};for(let t in _s)Ds[t]=_s[t];function qd(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 cf{constructor(e,n){this.toDOM=e,this.spec=n||rl,this.side=this.spec.side||0}map(e,n,s,a){let{pos:i,deleted:o}=e.mapResult(n.from+a,this.side<0?-1:1);return o?null:new Un(i-s,i-s,this)}valid(){return!0}eq(e){return this==e||e instanceof cf&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&qd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class so{constructor(e,n){this.attrs=e,this.spec=n||rl}map(e,n,s,a){let i=e.map(n.from+a,this.spec.inclusiveStart?-1:1)-s,o=e.map(n.to+a,this.spec.inclusiveEnd?1:-1)-s;return i>=o?null:new Un(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof so&&qd(this.attrs,e.attrs)&&qd(this.spec,e.spec)}static is(e){return e.type instanceof so}destroy(){}}class q0{constructor(e,n){this.attrs=e,this.spec=n||rl}map(e,n,s,a){let i=e.mapResult(n.from+a,1);if(i.deleted)return null;let o=e.mapResult(n.to+a,-1);return o.deleted||o.pos<=i.pos?null:new Un(i.pos-s,o.pos-s,this)}valid(e,n){let{index:s,offset:a}=e.content.findIndex(n.from),i;return a==n.from&&!(i=e.child(s)).isText&&a+i.nodeSize==n.to}eq(e){return this==e||e instanceof q0&&qd(this.attrs,e.attrs)&&qd(this.spec,e.spec)}destroy(){}}class Un{constructor(e,n,s){this.from=e,this.to=n,this.type=s}copy(e,n){return new Un(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,s){return this.type.map(e,this,n,s)}static widget(e,n,s){return new Un(e,e,new cf(n,s))}static inline(e,n,s,a){return new Un(e,n,new so(s,a))}static node(e,n,s,a){return new Un(e,n,new q0(s,a))}get spec(){return this.type.spec}get inline(){return this.type instanceof so}get widget(){return this.type instanceof cf}}const nc=[],rl={};class Yt{constructor(e,n){this.local=e.length?e:nc,this.children=n.length?n:nc}static create(e,n){return n.length?df(n,e,0,rl):Ss}find(e,n,s){let a=[];return this.findInner(e??0,n??1e9,a,0,s),a}findInner(e,n,s,a,i){for(let o=0;o<this.local.length;o++){let c=this.local[o];c.from<=n&&c.to>=e&&(!i||i(c.spec))&&s.push(c.copy(c.from+a,c.to+a))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let c=this.children[o]+1;this.children[o+2].findInner(e-c,n-c,s,a+c,i)}}map(e,n,s){return this==Ss||e.maps.length==0?this:this.mapInner(e,n,0,0,s||rl)}mapInner(e,n,s,a,i){let o;for(let c=0;c<this.local.length;c++){let u=this.local[c].map(e,s,a);u&&u.type.valid(n,u)?(o||(o=[])).push(u):i.onRemove&&i.onRemove(this.local[c].spec)}return this.children.length?LL(this.children,o||[],e,n,s,a,i):o?new Yt(o.sort(al),nc):Ss}add(e,n){return n.length?this==Ss?Yt.create(e,n):this.addInner(e,n,0):this}addInner(e,n,s){let a,i=0;e.forEach((c,u)=>{let h=u+s,f;if(f=A2(n,c,h)){for(a||(a=this.children.slice());i<a.length&&a[i]<u;)i+=3;a[i]==u?a[i+2]=a[i+2].addInner(c,f,h+1):a.splice(i,0,u,u+c.nodeSize,df(f,c,h+1,rl)),i+=3}});let o=M2(i?I2(n):n,-s);for(let c=0;c<o.length;c++)o[c].type.valid(e,o[c])||o.splice(c--,1);return new Yt(o.length?this.local.concat(o).sort(al):this.local,a||this.children)}remove(e){return e.length==0||this==Ss?this:this.removeInner(e,0)}removeInner(e,n){let s=this.children,a=this.local;for(let i=0;i<s.length;i+=3){let o,c=s[i]+n,u=s[i+1]+n;for(let f=0,m;f<e.length;f++)(m=e[f])&&m.from>c&&m.to<u&&(e[f]=null,(o||(o=[])).push(m));if(!o)continue;s==this.children&&(s=this.children.slice());let h=s[i+2].removeInner(o,c+1);h!=Ss?s[i+2]=h:(s.splice(i,3),i-=3)}if(a.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let c=0;c<a.length;c++)a[c].eq(o,n)&&(a==this.local&&(a=this.local.slice()),a.splice(c--,1))}return s==this.children&&a==this.local?this:a.length||s.length?new Yt(a,s):Ss}forChild(e,n){if(this==Ss)return this;if(n.isLeaf)return Yt.empty;let s,a;for(let c=0;c<this.children.length;c+=3)if(this.children[c]>=e){this.children[c]==e&&(s=this.children[c+2]);break}let i=e+1,o=i+n.content.size;for(let c=0;c<this.local.length;c++){let u=this.local[c];if(u.from<o&&u.to>i&&u.type instanceof so){let h=Math.max(i,u.from)-i,f=Math.min(o,u.to)-i;h<f&&(a||(a=[])).push(u.copy(h,f))}}if(a){let c=new Yt(a.sort(al),nc);return s?new Wi([c,s]):c}return s||Ss}eq(e){if(this==e)return!0;if(!(e instanceof Yt)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return G0(this.localsInner(e))}localsInner(e){if(this==Ss)return nc;if(e.inlineContent||!this.local.some(so.is))return this.local;let n=[];for(let s=0;s<this.local.length;s++)this.local[s].type instanceof so||n.push(this.local[s]);return n}forEachSet(e){e(this)}}Yt.empty=new Yt([],[]);Yt.removeOverlap=G0;const Ss=Yt.empty;class Wi{constructor(e){this.members=e}map(e,n){const s=this.members.map(a=>a.map(e,n,rl));return Wi.from(s)}forChild(e,n){if(n.isLeaf)return Yt.empty;let s=[];for(let a=0;a<this.members.length;a++){let i=this.members[a].forChild(e,n);i!=Ss&&(i instanceof Wi?s=s.concat(i.members):s.push(i))}return Wi.from(s)}eq(e){if(!(e instanceof Wi)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,s=!0;for(let a=0;a<this.members.length;a++){let i=this.members[a].localsInner(e);if(i.length)if(!n)n=i;else{s&&(n=n.slice(),s=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?G0(s?n:n.sort(al)):nc}static from(e){switch(e.length){case 0:return Ss;case 1:return e[0];default:return new Wi(e.every(n=>n instanceof Yt)?e:e.reduce((n,s)=>n.concat(s instanceof Yt?s:s.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function LL(t,e,n,s,a,i,o){let c=t.slice();for(let h=0,f=i;h<n.maps.length;h++){let m=0;n.maps[h].forEach((g,y,v,w)=>{let N=w-v-(y-g);for(let k=0;k<c.length;k+=3){let E=c[k+1];if(E<0||g>E+f-m)continue;let C=c[k]+f-m;y>=C?c[k+1]=g<=C?-2:-1:g>=f&&N&&(c[k]+=N,c[k+1]+=N)}m+=N}),f=n.maps[h].map(f,-1)}let u=!1;for(let h=0;h<c.length;h+=3)if(c[h+1]<0){if(c[h+1]==-2){u=!0,c[h+1]=-1;continue}let f=n.map(t[h]+i),m=f-a;if(m<0||m>=s.content.size){u=!0;continue}let g=n.map(t[h+1]+i,-1),y=g-a,{index:v,offset:w}=s.content.findIndex(m),N=s.maybeChild(v);if(N&&w==m&&w+N.nodeSize==y){let k=c[h+2].mapInner(n,N,f+1,t[h]+i+1,o);k!=Ss?(c[h]=m,c[h+1]=y,c[h+2]=k):(c[h+1]=-2,u=!0)}else u=!0}if(u){let h=DL(c,t,e,n,a,i,o),f=df(h,s,0,o);e=f.local;for(let m=0;m<c.length;m+=3)c[m+1]<0&&(c.splice(m,3),m-=3);for(let m=0,g=0;m<f.children.length;m+=3){let y=f.children[m];for(;g<c.length&&c[g]<y;)g+=3;c.splice(g,0,f.children[m],f.children[m+1],f.children[m+2])}}return new Yt(e.sort(al),c)}function M2(t,e){if(!e||!t.length)return t;let n=[];for(let s=0;s<t.length;s++){let a=t[s];n.push(new Un(a.from+e,a.to+e,a.type))}return n}function DL(t,e,n,s,a,i,o){function c(u,h){for(let f=0;f<u.local.length;f++){let m=u.local[f].map(s,a,h);m?n.push(m):o.onRemove&&o.onRemove(u.local[f].spec)}for(let f=0;f<u.children.length;f+=3)c(u.children[f+2],u.children[f]+h+1)}for(let u=0;u<t.length;u+=3)t[u+1]==-1&&c(t[u+2],e[u]+i+1);return n}function A2(t,e,n){if(e.isLeaf)return null;let s=n+e.nodeSize,a=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<s&&((a||(a=[])).push(o),t[i]=null);return a}function I2(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function df(t,e,n,s){let a=[],i=!1;e.forEach((c,u)=>{let h=A2(t,c,u+n);if(h){i=!0;let f=df(h,c,n+u+1,s);f!=Ss&&a.push(u,u+c.nodeSize,f)}});let o=M2(i?I2(t):t,-n).sort(al);for(let c=0;c<o.length;c++)o[c].type.valid(e,o[c])||(s.onRemove&&s.onRemove(o[c].spec),o.splice(c--,1));return o.length||a.length?new Yt(o,a):Ss}function al(t,e){return t.from-e.from||t.to-e.to}function G0(t){let e=t;for(let n=0;n<e.length-1;n++){let s=e[n];if(s.from!=s.to)for(let a=n+1;a<e.length;a++){let i=e[a];if(i.from==s.from){i.to!=s.to&&(e==t&&(e=t.slice()),e[a]=i.copy(i.from,s.to),bN(e,a+1,i.copy(s.to,i.to)));continue}else{i.from<s.to&&(e==t&&(e=t.slice()),e[n]=s.copy(s.from,i.from),bN(e,a,s.copy(i.from,s.to)));break}}}return e}function bN(t,e,n){for(;e<t.length&&al(n,t[e])>0;)e++;t.splice(e,0,n)}function Tg(t){let e=[];return t.someProp("decorations",n=>{let s=n(t.state);s&&s!=Ss&&e.push(s)}),t.cursorWrapper&&e.push(Yt.create(t.state.doc,[t.cursorWrapper.deco])),Wi.from(e)}const _L={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},zL=Ys&&to<=11;class $L{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 FL{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new $L,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(s=>{for(let a=0;a<s.length;a++)this.queue.push(s[a]);Ys&&to<=11&&s.some(a=>a.type=="childList"&&a.removedNodes.length||a.type=="characterData"&&a.oldValue.length>a.target.nodeValue.length)?this.flushSoon():Es&&e.composing&&s.some(a=>a.type=="childList"&&a.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),zL&&(this.onCharData=s=>{this.queue.push({target:s.target,type:"characterData",oldValue:s.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,_L)),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;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.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(uN(this.view)){if(this.suppressingSelectionUpdates)return ci(this.view);if(Ys&&to<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&hl(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,s;for(let i=e.focusNode;i;i=vc(i))n.add(i);for(let i=e.anchorNode;i;i=vc(i))if(n.has(i)){s=i;break}let a=s&&this.view.docView.nearestDesc(s);if(a&&a.ignoreMutation({type:"selection",target:s.nodeType==3?s.parentNode:s}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let s=e.domSelectionRange(),a=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(s)&&uN(e)&&!this.ignoreSelectionChange(s),i=-1,o=-1,c=!1,u=[];if(e.editable)for(let f=0;f<n.length;f++){let m=this.registerMutation(n[f],u);m&&(i=i<0?m.from:Math.min(m.from,i),o=o<0?m.to:Math.max(m.to,o),m.typeOver&&(c=!0))}if(u.some(f=>f.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(Er&&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||HL(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)<Date.now()-300&&cp(s)&&(h=B0(e))&&h.eq(lt.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ci(e),this.currentSelection.set(s),e.scrollToSelection()):(i>-1||a)&&(i>-1&&(e.docView.markDirty(i,o),BL(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,UL(e,u)),this.handleDOMChange(i,o,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(s)||ci(e),this.currentSelection.set(s))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let s=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(s==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!s||s.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;f<e.addedNodes.length;f++){let m=e.addedNodes[f];n.push(m),m.nodeType==3&&(this.lastChangedTextNode=m)}if(s.contentDOM&&s.contentDOM!=s.dom&&!s.contentDOM.contains(e.target))return{from:s.posBefore,to:s.posAfter};let a=e.previousSibling,i=e.nextSibling;if(Ys&&to<=11&&e.addedNodes.length)for(let f=0;f<e.addedNodes.length;f++){let{previousSibling:m,nextSibling:g}=e.addedNodes[f];(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(a=m),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(i=g)}let o=a&&a.parentNode==e.target?cs(a)+1:0,c=s.localPosFromDOM(e.target,o,-1),u=i&&i.parentNode==e.target?cs(i):e.target.childNodes.length,h=s.localPosFromDOM(e.target,u,1);return{from:c,to:h}}else return e.type=="attributes"?{from:s.posAtStart-s.border,to:s.posAtEnd+s.border}:(this.lastChangedTextNode=e.target,{from:s.posAtStart,to:s.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let vN=new WeakMap,NN=!1;function BL(t){if(!vN.has(t)&&(vN.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Er,NN)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),NN=!0}}function wN(t,e){let n=e.startContainer,s=e.startOffset,a=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return hl(o.node,o.offset,a,i)&&([n,s,a,i]=[a,i,n,s]),{anchorNode:n,anchorOffset:s,focusNode:a,focusOffset:i}}function VL(t,e){if(e.getComposedRanges){let a=e.getComposedRanges(t.root)[0];if(a)return wN(t,a)}let n;function s(a){a.preventDefault(),a.stopImmediatePropagation(),n=a.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",s,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",s,!0),n?wN(t,n):null}function HL(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let s=t.docView.nearestDesc(n,!0);if(s&&s.node.isBlock)return n}return null}function UL(t,e){var n;let{focusNode:s,focusOffset:a}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=i.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let c=o;for(;;){let u=c.firstChild;if(!u||u.nodeType!=1||u.contentEditable=="false"||/^(BR|IMG)$/.test(u.nodeName))break;c=u}c.insertBefore(i,c.firstChild),s==i&&t.domSelection().collapse(i,a)}else i.parentNode.removeChild(i)}}function WL(t,e,n){let{node:s,fromOffset:a,toOffset:i,from:o,to:c}=t.docView.parseRange(e,n),u=t.domSelectionRange(),h,f=u.anchorNode;if(f&&t.dom.contains(f.nodeType==1?f:f.parentNode)&&(h=[{node:f,offset:u.anchorOffset}],cp(u)||h.push({node:u.focusNode,offset:u.focusOffset})),ms&&t.input.lastKeyCode===8)for(let N=i;N>a;N--){let k=s.childNodes[N-1],E=k.pmViewDesc;if(k.nodeName=="BR"&&!E){i=N;break}if(!E||E.size)break}let m=t.state.doc,g=t.someProp("domParser")||eo.fromSchema(t.state.schema),y=m.resolve(o),v=null,w=g.parse(s,{topNode:y.parent,topMatch:y.parent.contentMatchAt(y.index()),topOpen:!0,from:a,to:i,preserveWhitespace:y.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:KL,context:y});if(h&&h[0].pos!=null){let N=h[0].pos,k=h[1]&&h[1].pos;k==null&&(k=N),v={anchor:N+o,head:k+o}}return{doc:w,sel:v,from:o,to:c}}function KL(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Es&&/^(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||Es&&/^(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 qL=/^(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 GL(t,e,n,s,a){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let _=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,V=B0(t,_);if(V&&!t.state.selection.eq(V)){if(ms&&ii&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",X=>X(t,Wo(13,"Enter"))))return;let A=t.state.tr.setSelection(V);_=="pointer"?A.setMeta("pointer",!0):_=="key"&&A.scrollIntoView(),i&&A.setMeta("composition",i),t.dispatch(A)}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=WL(t,e,n),f=t.state.doc,m=f.slice(h.from,h.to),g,y;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(g=t.state.selection.to,y="end"):(g=t.state.selection.from,y="start"),t.input.lastKeyCode=null;let v=QL(m.content,h.doc.content,h.from,g,y);if(v&&t.input.domChangeCount++,(Nc&&t.input.lastIOSEnter>Date.now()-225||ii)&&a.some(_=>_.nodeType==1&&!qL.test(_.nodeName))&&(!v||v.endA>=v.endB)&&t.someProp("handleKeyDown",_=>_(t,Wo(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!v)if(s&&u instanceof nt&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))v={start:u.from,endA:u.to,endB:u.to};else{if(h.sel){let _=jN(t,t.state.doc,h.sel);if(_&&!_.eq(t.state.selection)){let V=t.state.tr.setSelection(_);i&&V.setMeta("composition",i),t.dispatch(V)}}return}t.state.selection.from<t.state.selection.to&&v.start==v.endB&&t.state.selection instanceof nt&&(v.start>t.state.selection.from&&v.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?v.start=t.state.selection.from:v.endA<t.state.selection.to&&v.endA>=t.state.selection.to-2&&t.state.selection.to<=h.to&&(v.endB+=t.state.selection.to-v.endA,v.endA=t.state.selection.to)),Ys&&to<=11&&v.endB==v.start+1&&v.endA==v.start&&v.start>h.from&&h.doc.textBetween(v.start-h.from-1,v.start-h.from+1)=="  "&&(v.start--,v.endA--,v.endB--);let w=h.doc.resolveNoCache(v.start-h.from),N=h.doc.resolveNoCache(v.endB-h.from),k=f.resolve(v.start),E=w.sameParent(N)&&w.parent.inlineContent&&k.end()>=v.endA;if((Nc&&t.input.lastIOSEnter>Date.now()-225&&(!E||a.some(_=>_.nodeName=="DIV"||_.nodeName=="P"))||!E&&w.pos<h.doc.content.size&&(!w.sameParent(N)||!w.parent.inlineContent)&&w.pos<N.pos&&!/\S/.test(h.doc.textBetween(w.pos,N.pos,"","")))&&t.someProp("handleKeyDown",_=>_(t,Wo(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>v.start&&YL(f,v.start,v.endA,w,N)&&t.someProp("handleKeyDown",_=>_(t,Wo(8,"Backspace")))){ii&&ms&&t.domObserver.suppressSelectionUpdates();return}ms&&v.endB==v.start&&(t.input.lastChromeDelete=Date.now()),ii&&!E&&w.start()!=N.start()&&N.parentOffset==0&&w.depth==N.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==v.endA&&(v.endB-=2,N=h.doc.resolveNoCache(v.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function(_){return _(t,Wo(13,"Enter"))})},20));let C=v.start,P=v.endA,O=_=>{let V=_||t.state.tr.replace(C,P,h.doc.slice(v.start-h.from,v.endB-h.from));if(h.sel){let A=jN(t,V.doc,h.sel);A&&!(ms&&t.composing&&A.empty&&(v.start!=v.endB||t.input.lastChromeDelete<Date.now()-100)&&(A.head==C||A.head==V.mapping.map(P)-1)||Ys&&A.empty&&A.head==C)&&V.setSelection(A)}return i&&V.setMeta("composition",i),V.scrollIntoView()},U;if(E)if(w.pos==N.pos){Ys&&to<=11&&w.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>ci(t),20));let _=O(t.state.tr.delete(C,P)),V=f.resolve(v.start).marksAcross(f.resolve(v.endA));V&&_.ensureMarks(V),t.dispatch(_)}else if(v.endA==v.endB&&(U=JL(w.parent.content.cut(w.parentOffset,N.parentOffset),k.parent.content.cut(k.parentOffset,v.endA-k.start())))){let _=O(t.state.tr);U.type=="add"?_.addMark(C,P,U.mark):_.removeMark(C,P,U.mark),t.dispatch(_)}else if(w.parent.child(w.index()).isText&&w.index()==N.index()-(N.textOffset?0:1)){let _=w.parent.textBetween(w.parentOffset,N.parentOffset),V=()=>O(t.state.tr.insertText(_,C,P));t.someProp("handleTextInput",A=>A(t,C,P,_,V))||t.dispatch(V())}else t.dispatch(O());else t.dispatch(O())}function jN(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:V0(t,e.resolve(n.anchor),e.resolve(n.head))}function JL(t,e){let n=t.firstChild.marks,s=e.firstChild.marks,a=n,i=s,o,c,u;for(let f=0;f<s.length;f++)a=s[f].removeFromSet(a);for(let f=0;f<n.length;f++)i=n[f].removeFromSet(i);if(a.length==1&&i.length==0)c=a[0],o="add",u=f=>f.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;f<e.childCount;f++)h.push(u(e.child(f)));if(we.from(h).eq(t))return{mark:c,type:o}}function YL(t,e,n,s,a){if(n-e<=a.pos-s.pos||Mg(s,!0,!1)<a.pos)return!1;let i=t.resolve(e);if(!s.parent.isTextblock){let c=i.nodeAfter;return c!=null&&n==e+c.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(Mg(i,!0,!0));return!o.parent.isTextblock||o.pos>n||Mg(o,!0,!1)<n?!1:s.parent.content.cut(s.parentOffset).eq(o.parent.content)}function Mg(t,e,n){let s=t.depth,a=e?t.end():t.pos;for(;s>0&&(e||t.indexAfter(s)==t.node(s).childCount);)s--,a++,e=!1;if(n){let i=t.node(s).maybeChild(t.indexAfter(s));for(;i&&!i.isLeaf;)i=i.firstChild,a++}return a}function QL(t,e,n,s,a){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:o,b:c}=t.findDiffEnd(e,n+t.size,n+e.size);if(a=="end"){let u=Math.max(0,i-Math.min(o,c));s-=o+u-i}if(o<i&&t.size<e.size){let u=s<=i&&s>=o?i-s:0;i-=u,i&&i<e.size&&kN(e.textBetween(i-1,i+1))&&(i+=u?1:-1),c=i+(c-o),o=i}else if(c<i){let u=s<=i&&s>=c?i-s:0;i-=u,i&&i<t.size&&kN(t.textBetween(i-1,i+1))&&(i+=u?1:-1),o=i+(o-c),c=i}return{start:i,endA:o,endB:c}}function kN(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class R2{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 fL,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(MN),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=EN(this),CN(this),this.nodeViews=TN(this),this.docView=aN(this.state.doc,SN(this),Tg(this),this.dom,this),this.domObserver=new FL(this,(s,a,i,o)=>GL(this,s,a,i,o)),this.domObserver.start(),pL(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&&Ix(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(MN),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let s in this._props)n[s]=this._props[s];n.state=this.state;for(let s in e)n[s]=e[s];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var s;let a=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(S2(this),o=!0),this.state=e;let c=a.plugins!=e.plugins||this._props.plugins!=n.plugins;if(c||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let y=TN(this);ZL(y,this.nodeViews)&&(this.nodeViews=y,i=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&Ix(this),this.editable=EN(this),CN(this);let u=Tg(this),h=SN(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&&T8(this);if(o){this.domObserver.stop();let y=m&&(Ys||ms)&&!this.composing&&!a.selection.empty&&!e.selection.empty&&XL(a.selection,e.selection);if(m){let v=ms?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=TL(this)),(i||!this.docView.update(e.doc,h,u,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=aN(e.doc,h,u,this.dom,this)),v&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(y=!0)}y||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&X8(this))?ci(this,y):(f2(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(a),!((s=this.dragging)===null||s===void 0)&&s.node&&!a.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,a),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():g&&M8(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 et){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Z1(this,n.getBoundingClientRect(),e)}else Z1(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;n<this.directPlugins.length;n++){let s=this.directPlugins[n];s.spec.view&&this.pluginViews.push(s.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let s=this.state.plugins[n];s.spec.view&&this.pluginViews.push(s.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let s=this.pluginViews[n];s.update&&s.update(this,e)}}updateDraggedNode(e,n){let s=e.node,a=-1;if(this.state.doc.nodeAt(s.from)==s.node)a=s.from;else{let i=s.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==s.node&&(a=i)}this.dragging=new E2(e.slice,e.move,a<0?void 0:et.create(this.state.doc,a))}someProp(e,n){let s=this._props&&this._props[e],a;if(s!=null&&(a=n?n(s):s))return a;for(let o=0;o<this.directPlugins.length;o++){let c=this.directPlugins[o].props[e];if(c!=null&&(a=n?n(c):c))return a}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let c=i[o].props[e];if(c!=null&&(a=n?n(c):c))return a}}hasFocus(){if(Ys){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&A8(this.dom),ci(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return L8(this,e)}coordsAtPos(e,n=1){return a2(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,s=-1){let a=this.docView.posFromDOM(e,n,s);if(a==null)throw new RangeError("DOM position not inside the editor");return a}endOfTextblock(e,n){return F8(this,n||this.state,e)}pasteHTML(e,n){return Kd(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Kd(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return H0(this,e)}destroy(){this.docView&&(mL(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Tg(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,y8())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return xL(this,e)}domSelectionRange(){let e=this.domSelection();return e?Es&&this.root.nodeType===11&&j8(this.dom.ownerDocument)==this.dom&&VL(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}R2.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function SN(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let s in n)s=="class"?e.class+=" "+n[s]:s=="style"?e.style=(e.style?e.style+";":"")+n[s]:!e[s]&&s!="contenteditable"&&s!="nodeName"&&(e[s]=String(n[s]))}),e.translate||(e.translate="no"),[Un.node(0,t.state.doc.content.size,e)]}function CN(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:Un.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function EN(t){return!t.someProp("editable",e=>e(t.state)===!1)}function XL(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 TN(t){let e=Object.create(null);function n(s){for(let a in s)Object.prototype.hasOwnProperty.call(e,a)||(e[a]=s[a])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function ZL(t,e){let n=0,s=0;for(let a in t){if(t[a]!=e[a])return!0;n++}for(let a in e)s++;return n!=s}function MN(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 lo={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:"'"},uf={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},eD=typeof navigator<"u"&&/Mac/.test(navigator.platform),tD=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ds=0;ds<10;ds++)lo[48+ds]=lo[96+ds]=String(ds);for(var ds=1;ds<=24;ds++)lo[ds+111]="F"+ds;for(var ds=65;ds<=90;ds++)lo[ds]=String.fromCharCode(ds+32),uf[ds]=String.fromCharCode(ds);for(var Ag in lo)uf.hasOwnProperty(Ag)||(uf[Ag]=lo[Ag]);function nD(t){var e=eD&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||tD&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?uf:lo)[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 sD=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),rD=typeof navigator<"u"&&/Win/.test(navigator.platform);function aD(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let s,a,i,o;for(let c=0;c<e.length-1;c++){let u=e[c];if(/^(cmd|meta|m)$/i.test(u))o=!0;else if(/^a(lt)?$/i.test(u))s=!0;else if(/^(c|ctrl|control)$/i.test(u))a=!0;else if(/^s(hift)?$/i.test(u))i=!0;else if(/^mod$/i.test(u))sD?o=!0:a=!0;else throw new Error("Unrecognized modifier name: "+u)}return s&&(n="Alt-"+n),a&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function iD(t){let e=Object.create(null);for(let n in t)e[aD(n)]=t[n];return e}function Ig(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function oD(t){return new nn({props:{handleKeyDown:J0(t)}})}function J0(t){let e=iD(t);return function(n,s){let a=nD(s),i,o=e[Ig(a,s)];if(o&&o(n.state,n.dispatch,n))return!0;if(a.length==1&&a!=" "){if(s.shiftKey){let c=e[Ig(a,s,!1)];if(c&&c(n.state,n.dispatch,n))return!0}if((s.altKey||s.metaKey||s.ctrlKey)&&!(rD&&s.ctrlKey&&s.altKey)&&(i=lo[s.keyCode])&&i!=a){let c=e[Ig(i,s)];if(c&&c(n.state,n.dispatch,n))return!0}}return!1}}var lD=Object.defineProperty,Y0=(t,e)=>{for(var n in e)lD(t,n,{get:e[n],enumerable:!0})};function hp(t){const{state:e,transaction:n}=t;let{selection:s}=n,{doc:a}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return s},get doc(){return a},get tr(){return s=n.selection,a=n.doc,i=n.storedMarks,n}}}var fp=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:s}=e,{tr:a}=n,i=this.buildProps(a);return Object.fromEntries(Object.entries(t).map(([o,c])=>[o,(...h)=>{const f=c(...h)(i);return!a.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(a),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:s,state:a}=this,{view:i}=s,o=[],c=!!t,u=t||a.tr,h=()=>(!c&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(u),o.every(m=>m===!0)),f={...Object.fromEntries(Object.entries(n).map(([m,g])=>[m,(...v)=>{const w=this.buildProps(u,e),N=g(...v)(w);return o.push(N),f}])),run:h};return f}createCan(t){const{rawCommands:e,state:n}=this,s=!1,a=t||n.tr,i=this.buildProps(a,s);return{...Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...h)=>u(...h)({...i,dispatch:void 0})])),chain:()=>this.createChain(a,s)}}buildProps(t,e=!0){const{rawCommands:n,editor:s,state:a}=this,{view:i}=s,o={tr:t,editor:s,view:i,state:hp({state:a,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([c,u])=>[c,(...h)=>u(...h)(o)]))}};return o}},P2={};Y0(P2,{blur:()=>cD,clearContent:()=>dD,clearNodes:()=>uD,command:()=>hD,createParagraphNear:()=>fD,cut:()=>pD,deleteCurrentNode:()=>mD,deleteNode:()=>gD,deleteRange:()=>xD,deleteSelection:()=>yD,enter:()=>bD,exitCode:()=>vD,extendMarkRange:()=>ND,first:()=>wD,focus:()=>kD,forEach:()=>SD,insertContent:()=>CD,insertContentAt:()=>MD,joinBackward:()=>RD,joinDown:()=>ID,joinForward:()=>PD,joinItemBackward:()=>OD,joinItemForward:()=>LD,joinTextblockBackward:()=>DD,joinTextblockForward:()=>_D,joinUp:()=>AD,keyboardShortcut:()=>$D,lift:()=>FD,liftEmptyBlock:()=>BD,liftListItem:()=>VD,newlineInCode:()=>HD,resetAttributes:()=>UD,scrollIntoView:()=>WD,selectAll:()=>KD,selectNodeBackward:()=>qD,selectNodeForward:()=>GD,selectParentNode:()=>JD,selectTextblockEnd:()=>YD,selectTextblockStart:()=>QD,setContent:()=>XD,setMark:()=>y6,setMeta:()=>b6,setNode:()=>v6,setNodeSelection:()=>N6,setTextDirection:()=>w6,setTextSelection:()=>j6,sinkListItem:()=>k6,splitBlock:()=>S6,splitListItem:()=>C6,toggleList:()=>E6,toggleMark:()=>T6,toggleNode:()=>M6,toggleWrap:()=>A6,undoInputRule:()=>I6,unsetAllMarks:()=>R6,unsetMark:()=>P6,unsetTextDirection:()=>O6,updateAttributes:()=>L6,wrapIn:()=>D6,wrapInList:()=>_6});var cD=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),dD=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),uD=()=>({state:t,tr:e,dispatch:n})=>{const{selection:s}=e,{ranges:a}=s;return n&&a.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(c,u)=>{if(c.type.isText)return;const{doc:h,mapping:f}=e,m=h.resolve(f.map(u)),g=h.resolve(f.map(u+c.nodeSize)),y=m.blockRange(g);if(!y)return;const v=Rc(y);if(c.type.isTextblock){const{defaultType:w}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(y.start,w)}(v||v===0)&&e.lift(y,v)})}),!0},hD=t=>e=>t(e),fD=()=>({state:t,dispatch:e})=>GS(t,e),pD=(t,e)=>({editor:n,tr:s})=>{const{state:a}=n,i=a.doc.slice(t.from,t.to);s.deleteRange(t.from,t.to);const o=s.mapping.map(e);return s.insert(o,i.content),s.setSelection(new nt(s.doc.resolve(Math.max(o-1,0)))),!0},mD=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,s=n.$anchor.node();if(s.content.size>0)return!1;const a=t.selection.$anchor;for(let i=a.depth;i>0;i-=1)if(a.node(i).type===s.type){if(e){const c=a.before(i),u=a.after(i);t.delete(c,u).scrollIntoView()}return!0}return!1};function Fn(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 gD=t=>({tr:e,state:n,dispatch:s})=>{const a=Fn(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===a){if(s){const u=i.before(o),h=i.after(o);e.delete(u,h).scrollIntoView()}return!0}return!1},xD=t=>({tr:e,dispatch:n})=>{const{from:s,to:a}=t;return n&&e.delete(s,a),!0},yD=()=>({state:t,dispatch:e})=>L0(t,e),bD=()=>({commands:t})=>t.keyboardShortcut("Enter"),vD=()=>({state:t,dispatch:e})=>s8(t,e);function Q0(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function hf(t,e,n={strict:!0}){const s=Object.keys(e);return s.length?s.every(a=>n.strict?e[a]===t[a]:Q0(e[a])?e[a].test(t[a]):e[a]===t[a]):!0}function O2(t,e,n={}){return t.find(s=>s.type===e&&hf(Object.fromEntries(Object.keys(n).map(a=>[a,s.attrs[a]])),n))}function AN(t,e,n={}){return!!O2(t,e,n)}function X0(t,e,n){var s;if(!t||!e)return;let a=t.parent.childAfter(t.parentOffset);if((!a.node||!a.node.marks.some(f=>f.type===e))&&(a=t.parent.childBefore(t.parentOffset)),!a.node||!a.node.marks.some(f=>f.type===e)||(n=n||((s=a.node.marks[0])==null?void 0:s.attrs),!O2([...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&&AN([...t.parent.child(o-1).marks],e,n);)o-=1,c-=t.parent.child(o).nodeSize;for(;u<t.parent.childCount&&AN([...t.parent.child(u).marks],e,n);)h+=t.parent.child(u).nodeSize,u+=1;return{from:c,to:h}}function pi(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var ND=(t,e={})=>({tr:n,state:s,dispatch:a})=>{const i=pi(t,s.schema),{doc:o,selection:c}=n,{$from:u,from:h,to:f}=c;if(a){const m=X0(u,i,e);if(m&&m.from<=h&&m.to>=f){const g=nt.create(o,m.from,m.to);n.setSelection(g)}}return!0},wD=t=>e=>{const n=typeof t=="function"?t(e):t;for(let s=0;s<n.length;s+=1)if(n[s](e))return!0;return!1};function L2(t){return t instanceof nt}function Xo(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function D2(t,e=null){if(!e)return null;const n=lt.atStart(t),s=lt.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return s;const a=n.from,i=s.to;return e==="all"?nt.create(t,Xo(0,a,i),Xo(t.content.size,a,i)):nt.create(t,Xo(e,a,i),Xo(e,a,i))}function IN(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function ff(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function jD(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var kD=(t=null,e={})=>({editor:n,view:s,tr:a,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(ff()||IN())&&s.dom.focus(),jD()&&!ff()&&!IN()&&s.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(s.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(s.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!L2(n.state.selection))return o(),!0;const c=D2(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},SD=(t,e)=>n=>t.every((s,a)=>e(s,{...n,index:a})),CD=(t,e)=>({tr:n,commands:s})=>s.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),_2=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const s=e[n];s.nodeType===3&&s.nodeValue&&/^(\n\s\s|\n)$/.test(s.nodeValue)?t.removeChild(s):s.nodeType===1&&_2(s)}return t};function bh(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return _2(n)}function Gd(t,e,n){if(t instanceof oi||t instanceof we)return t;n={slice:!0,parseOptions:{},...n};const s=typeof t=="object"&&t!==null,a=typeof t=="string";if(s)try{if(Array.isArray(t)&&t.length>0)return we.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),Gd("",e,n)}if(a){if(n.errorOnInvalidContent){let o=!1,c="";const u=new NS({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:h=>(o=!0,c=typeof h=="string"?h:h.outerHTML,null)}]}})});if(n.slice?eo.fromSchema(u).parseSlice(bh(t),n.parseOptions):eo.fromSchema(u).parse(bh(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const i=eo.fromSchema(e);return n.slice?i.parseSlice(bh(t),n.parseOptions).content:i.parse(bh(t),n.parseOptions)}return Gd("",e,n)}function ED(t,e,n){const s=t.steps.length-1;if(s<e)return;const a=t.steps[s];if(!(a instanceof Xn||a instanceof Zn))return;const i=t.mapping.maps[s];let o=0;i.forEach((c,u,h,f)=>{o===0&&(o=f)}),t.setSelection(lt.near(t.doc.resolve(o),n))}var TD=t=>!("type"in t),MD=(t,e,n)=>({tr:s,dispatch:a,editor:i})=>{var o;if(a){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let c;const u=N=>{i.emit("contentError",{editor:i,error:N,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},h={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Gd(e,i.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(N){u(N)}try{c=Gd(e,i.schema,{parseOptions:h,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(N){return u(N),!1}let{from:f,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,y=!0;if((TD(c)?c:[c]).forEach(N=>{N.check(),g=g?N.isText&&N.marks.length===0:!1,y=y?N.isBlock:!1}),f===m&&y){const{parent:N}=s.doc.resolve(f);N.isTextblock&&!N.type.spec.code&&!N.childCount&&(f-=1,m+=1)}let w;if(g){if(Array.isArray(e))w=e.map(N=>N.text||"").join("");else if(e instanceof we){let N="";e.forEach(k=>{k.text&&(N+=k.text)}),w=N}else typeof e=="object"&&e&&e.text?w=e.text:w=e;s.insertText(w,f,m)}else{w=c;const N=s.doc.resolve(f),k=N.node(),E=N.parentOffset===0,C=k.isText||k.isTextblock,P=k.content.size>0;E&&C&&P&&(f=Math.max(0,f-1)),s.replaceWith(f,m,w)}n.updateSelection&&ED(s,s.steps.length-1,-1),n.applyInputRules&&s.setMeta("applyInputRules",{from:f,text:w}),n.applyPasteRules&&s.setMeta("applyPasteRules",{from:f,text:w})}return!0},AD=()=>({state:t,dispatch:e})=>e8(t,e),ID=()=>({state:t,dispatch:e})=>t8(t,e),RD=()=>({state:t,dispatch:e})=>BS(t,e),PD=()=>({state:t,dispatch:e})=>WS(t,e),OD=()=>({state:t,dispatch:e,tr:n})=>{try{const s=ip(t.doc,t.selection.$from.pos,-1);return s==null?!1:(n.join(s,2),e&&e(n),!0)}catch{return!1}},LD=()=>({state:t,dispatch:e,tr:n})=>{try{const s=ip(t.doc,t.selection.$from.pos,1);return s==null?!1:(n.join(s,2),e&&e(n),!0)}catch{return!1}},DD=()=>({state:t,dispatch:e})=>XO(t,e),_D=()=>({state:t,dispatch:e})=>ZO(t,e);function z2(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function zD(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let s,a,i,o;for(let c=0;c<e.length-1;c+=1){const u=e[c];if(/^(cmd|meta|m)$/i.test(u))o=!0;else if(/^a(lt)?$/i.test(u))s=!0;else if(/^(c|ctrl|control)$/i.test(u))a=!0;else if(/^s(hift)?$/i.test(u))i=!0;else if(/^mod$/i.test(u))ff()||z2()?o=!0:a=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return s&&(n=`Alt-${n}`),a&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var $D=t=>({editor:e,view:n,tr:s,dispatch:a})=>{const i=zD(t).split(/-(?!$)/),o=i.find(h=>!["Alt","Ctrl","Meta","Shift"].includes(h)),c=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction(()=>{n.someProp("handleKeyDown",h=>h(n,c))});return u==null||u.steps.forEach(h=>{const f=h.map(s.mapping);f&&a&&s.maybeStep(f)}),!0};function co(t,e,n={}){const{from:s,to:a,empty:i}=t.selection,o=e?Fn(e,t.schema):null,c=[];t.doc.nodesBetween(s,a,(m,g)=>{if(m.isText)return;const y=Math.max(s,g),v=Math.min(a,g+m.nodeSize);c.push({node:m,from:y,to:v})});const u=a-s,h=c.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>hf(m.node.attrs,n,{strict:!1}));return i?!!h.length:h.reduce((m,g)=>m+g.to-g.from,0)>=u}var FD=(t,e={})=>({state:n,dispatch:s})=>{const a=Fn(t,n.schema);return co(n,a,e)?n8(n,s):!1},BD=()=>({state:t,dispatch:e})=>JS(t,e),VD=t=>({state:e,dispatch:n})=>{const s=Fn(t,e.schema);return p8(s)(e,n)},HD=()=>({state:t,dispatch:e})=>qS(t,e);function pp(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function RN(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((s,a)=>(n.includes(a)||(s[a]=t[a]),s),{})}var UD=(t,e)=>({tr:n,state:s,dispatch:a})=>{let i=null,o=null;const c=pp(typeof t=="string"?t:t.name,s.schema);if(!c)return!1;c==="node"&&(i=Fn(t,s.schema)),c==="mark"&&(o=pi(t,s.schema));let u=!1;return n.selection.ranges.forEach(h=>{s.doc.nodesBetween(h.$from.pos,h.$to.pos,(f,m)=>{i&&i===f.type&&(u=!0,a&&n.setNodeMarkup(m,void 0,RN(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(RN(g.attrs,e))))})})}),u},WD=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),KD=()=>({tr:t,dispatch:e})=>{if(e){const n=new hr(t.doc);t.setSelection(n)}return!0},qD=()=>({state:t,dispatch:e})=>HS(t,e),GD=()=>({state:t,dispatch:e})=>KS(t,e),JD=()=>({state:t,dispatch:e})=>i8(t,e),YD=()=>({state:t,dispatch:e})=>c8(t,e),QD=()=>({state:t,dispatch:e})=>l8(t,e);function Rx(t,e,n={},s={}){return Gd(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:s.errorOnInvalidContent})}var XD=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:s={}}={})=>({editor:a,tr:i,dispatch:o,commands:c})=>{const{doc:u}=i;if(s.preserveWhitespace!=="full"){const h=Rx(t,a.schema,s,{errorOnInvalidContent:e??a.options.enableContentCheck});return o&&i.replaceWith(0,u.content.size,h).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),c.insertContentAt({from:0,to:u.content.size},t,{parseOptions:s,errorOnInvalidContent:e??a.options.enableContentCheck})};function $2(t,e){const n=pi(e,t.schema),{from:s,to:a,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(s,a,u=>{o.push(...u.marks)});const c=o.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function F2(t,e){const n=new P0(t);return e.forEach(s=>{s.steps.forEach(a=>{n.step(a)})}),n}function ZD(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function e6(t,e,n){const s=[];return t.nodesBetween(e.from,e.to,(a,i)=>{n(a)&&s.push({node:a,pos:i})}),s}function B2(t,e){for(let n=t.depth;n>0;n-=1){const s=t.node(n);if(e(s))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:s}}}function mp(t){return e=>B2(e.$from,t)}function Xe(t,e,n){return t.config[e]===void 0&&t.parent?Xe(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Xe(t.parent,e,n):null}):t.config[e]}function Z0(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},s=Xe(e,"addExtensions",n);return s?[e,...Z0(s())]:e}).flat(10)}function ey(t,e){const n=vl.fromSchema(e).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(n),a.innerHTML}function V2(t){return typeof t=="function"}function Dt(t,e=void 0,...n){return V2(t)?e?t.bind(e)(...n):t(...n):t}function t6(t={}){return Object.keys(t).length===0&&t.constructor===Object}function wc(t){const e=t.filter(a=>a.type==="extension"),n=t.filter(a=>a.type==="node"),s=t.filter(a=>a.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:s}}function H2(t){const e=[],{nodeExtensions:n,markExtensions:s}=wc(t),a=[...n,...s],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(h=>h.name!=="text").map(h=>h.name),c=s.map(h=>h.name),u=[...o,...c];return t.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage,extensions:a},m=Xe(h,"addGlobalAttributes",f);if(!m)return;m().forEach(y=>{let v;Array.isArray(y.types)?v=y.types:y.types==="*"?v=u:y.types==="nodes"?v=o:y.types==="marks"?v=c:v=[],v.forEach(w=>{Object.entries(y.attributes).forEach(([N,k])=>{e.push({type:w,name:N,attribute:{...i,...k}})})})})}),a.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage},m=Xe(h,"addAttributes",f);if(!m)return;const g=m();Object.entries(g).forEach(([y,v])=>{const w={...i,...v};typeof(w==null?void 0:w.default)=="function"&&(w.default=w.default()),w!=null&&w.isRequired&&(w==null?void 0:w.default)===void 0&&delete w.default,e.push({type:h.name,name:y,attribute:w})})}),e}function n6(t){const e=[];let n="",s=!1,a=!1,i=0;const o=t.length;for(let c=0;c<o;c+=1){const u=t[c];if(u==="'"&&!a){s=!s,n+=u;continue}if(u==='"'&&!s){a=!a,n+=u;continue}if(!s&&!a){if(u==="("){i+=1,n+=u;continue}if(u===")"&&i>0){i-=1,n+=u;continue}if(u===";"&&i===0){e.push(n),n="";continue}}n+=u}return n&&e.push(n),e}function PN(t){const e=[],n=n6(t||""),s=n.length;for(let a=0;a<s;a+=1){const i=n[a],o=i.indexOf(":");if(o===-1)continue;const c=i.slice(0,o).trim(),u=i.slice(o+1).trim();c&&u&&e.push([c,u])}return e}function zt(...t){return t.filter(e=>!!e).reduce((e,n)=>{const s={...e};return Object.entries(n).forEach(([a,i])=>{if(!s[a]){s[a]=i;return}if(a==="class"){const c=i?String(i).split(" "):[],u=s[a]?s[a].split(" "):[],h=c.filter(f=>!u.includes(f));s[a]=[...u,...h].join(" ")}else if(a==="style"){const c=new Map([...PN(s[a]),...PN(i)]);s[a]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else s[a]=i}),s},{})}function Jd(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,s)=>zt(n,s),{})}function s6(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function ON(t,e){return"style"in t?t:{...t,getAttrs:n=>{const s=t.getAttrs?t.getAttrs(n):t.attrs;if(s===!1)return!1;const a=e.reduce((i,o)=>{const c=o.attribute.parseHTML?o.attribute.parseHTML(n):s6(n.getAttribute(o.name));return c==null?i:{...i,[o.name]:c}},{});return{...s,...a}}}}function LN(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&t6(n)?!1:n!=null))}function DN(t){var e,n;const s={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(s.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(s.validate=t.attribute.validate),[t.name,s]}function r6(t,e){var n;const s=H2(t),{nodeExtensions:a,markExtensions:i}=wc(t),o=(n=a.find(h=>Xe(h,"topNode")))==null?void 0:n.name,c=Object.fromEntries(a.map(h=>{const f=s.filter(k=>k.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},g=t.reduce((k,E)=>{const C=Xe(E,"extendNodeSchema",m);return{...k,...C?C(h):{}}},{}),y=LN({...g,content:Dt(Xe(h,"content",m)),marks:Dt(Xe(h,"marks",m)),group:Dt(Xe(h,"group",m)),inline:Dt(Xe(h,"inline",m)),atom:Dt(Xe(h,"atom",m)),selectable:Dt(Xe(h,"selectable",m)),draggable:Dt(Xe(h,"draggable",m)),code:Dt(Xe(h,"code",m)),whitespace:Dt(Xe(h,"whitespace",m)),linebreakReplacement:Dt(Xe(h,"linebreakReplacement",m)),defining:Dt(Xe(h,"defining",m)),isolating:Dt(Xe(h,"isolating",m)),attrs:Object.fromEntries(f.map(DN))}),v=Dt(Xe(h,"parseHTML",m));v&&(y.parseDOM=v.map(k=>ON(k,f)));const w=Xe(h,"renderHTML",m);w&&(y.toDOM=k=>w({node:k,HTMLAttributes:Jd(k,f)}));const N=Xe(h,"renderText",m);return N&&(y.toText=N),[h.name,y]})),u=Object.fromEntries(i.map(h=>{const f=s.filter(N=>N.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},g=t.reduce((N,k)=>{const E=Xe(k,"extendMarkSchema",m);return{...N,...E?E(h):{}}},{}),y=LN({...g,inclusive:Dt(Xe(h,"inclusive",m)),excludes:Dt(Xe(h,"excludes",m)),group:Dt(Xe(h,"group",m)),spanning:Dt(Xe(h,"spanning",m)),code:Dt(Xe(h,"code",m)),attrs:Object.fromEntries(f.map(DN))}),v=Dt(Xe(h,"parseHTML",m));v&&(y.parseDOM=v.map(N=>ON(N,f)));const w=Xe(h,"renderHTML",m);return w&&(y.toDOM=N=>w({mark:N,HTMLAttributes:Jd(N,f)})),[h.name,y]}));return new NS({topNode:o,nodes:c,marks:u})}function a6(t){const e=t.filter((n,s)=>t.indexOf(n)!==s);return Array.from(new Set(e))}function Ad(t){return t.sort((n,s)=>{const a=Xe(n,"priority")||100,i=Xe(s,"priority")||100;return a>i?-1:a<i?1:0})}function U2(t){const e=Ad(Z0(t)),n=a6(e.map(s=>s.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),e}function W2(t,e,n){const{from:s,to:a}=e,{blockSeparator:i=`
`,textSerializers:o={}}=n||{};let c="";return t.nodesBetween(s,a,(u,h,f,m)=>{var g;u.isBlock&&h>s&&(c+=i);const y=o==null?void 0:o[u.type.name];if(y)return f&&(c+=y({node:u,pos:h,parent:f,index:m,range:e})),!1;u.isText&&(c+=(g=u==null?void 0:u.text)==null?void 0:g.slice(Math.max(s,h)-h,a-h))}),c}function i6(t,e){const n={from:0,to:t.content.size};return W2(t,n,e)}function K2(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function o6(t,e){const n=Fn(e,t.schema),{from:s,to:a}=t.selection,i=[];t.doc.nodesBetween(s,a,c=>{i.push(c)});const o=i.reverse().find(c=>c.type.name===n.name);return o?{...o.attrs}:{}}function q2(t,e){const n=pp(typeof e=="string"?e:e.name,t.schema);return n==="node"?o6(t,e):n==="mark"?$2(t,e):{}}function l6(t,e=JSON.stringify){const n={};return t.filter(s=>{const a=e(s);return Object.prototype.hasOwnProperty.call(n,a)?!1:n[a]=!0})}function c6(t){const e=l6(t);return e.length===1?e:e.filter((n,s)=>!e.filter((i,o)=>o!==s).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function G2(t){const{mapping:e,steps:n}=t,s=[];return e.maps.forEach((a,i)=>{const o=[];if(a.ranges.length)a.forEach((c,u)=>{o.push({from:c,to:u})});else{const{from:c,to:u}=n[i];if(c===void 0||u===void 0)return;o.push({from:c,to:u})}o.forEach(({from:c,to:u})=>{const h=e.slice(i).map(c,-1),f=e.slice(i).map(u),m=e.invert().map(h,-1),g=e.invert().map(f);s.push({oldRange:{from:m,to:g},newRange:{from:h,to:f}})})}),c6(s)}function ty(t,e,n){const s=[];return t===e?n.resolve(t).marks().forEach(a=>{const i=n.resolve(t),o=X0(i,a.type);o&&s.push({mark:a,...o})}):n.nodesBetween(t,e,(a,i)=>{!a||(a==null?void 0:a.nodeSize)===void 0||s.push(...a.marks.map(o=>({from:i,to:i+a.nodeSize,mark:o})))}),s}var d6=(t,e,n,s=20)=>{const a=t.doc.resolve(n);let i=s,o=null;for(;i>0&&o===null;){const c=a.node(i);(c==null?void 0:c.type.name)===e?o=c:i-=1}return[o,i]};function fd(t,e){return e.nodes[t]||e.marks[t]||null}function _h(t,e,n){return Object.fromEntries(Object.entries(n).filter(([s])=>{const a=t.find(i=>i.type===e&&i.name===s);return a?a.attribute.keepOnSplit:!1}))}var u6=(t,e=500)=>{let n="";const s=t.parentOffset;return t.parent.nodesBetween(Math.max(0,s-e),s,(a,i,o,c)=>{var u,h;const f=((h=(u=a.type.spec).toText)==null?void 0:h.call(u,{node:a,pos:i,parent:o,index:c}))||a.textContent||"%leaf%";n+=a.isAtom&&!a.isText?f:f.slice(0,Math.max(0,s-i))}),n};function Px(t,e,n={}){const{empty:s,ranges:a}=t.selection,i=e?pi(e,t.schema):null;if(s)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>hf(m.attrs,n,{strict:!1}));let o=0;const c=[];if(a.forEach(({$from:m,$to:g})=>{const y=m.pos,v=g.pos;t.doc.nodesBetween(y,v,(w,N)=>{if(i&&w.inlineContent&&!w.type.allowsMarkType(i))return!1;if(!w.isText&&!w.marks.length)return;const k=Math.max(y,N),E=Math.min(v,N+w.nodeSize),C=E-k;o+=C,c.push(...w.marks.map(P=>({mark:P,from:k,to:E})))})}),o===0)return!1;const u=c.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>hf(m.mark.attrs,n,{strict:!1})).reduce((m,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 h6(t,e,n={}){if(!e)return co(t,null,n)||Px(t,null,n);const s=pp(e,t.schema);return s==="node"?co(t,e,n):s==="mark"?Px(t,e,n):!1}var f6=(t,e)=>{const{$from:n,$to:s,$anchor:a}=t.selection;if(e){const i=mp(c=>c.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return a.pos+1===o.end()}return!(s.parentOffset<s.parent.nodeSize-2||n.pos!==s.pos)},p6=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function _N(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function zN(t,e){const{nodeExtensions:n}=wc(e),s=n.find(o=>o.name===t);if(!s)return!1;const a={name:s.name,options:s.options,storage:s.storage},i=Dt(Xe(s,"group",a));return typeof i!="string"?!1:i.split(" ").includes("list")}function gp(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var s;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((s=t.text)!=null?s:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let a=!0;return t.content.forEach(i=>{a!==!1&&(gp(i,{ignoreWhitespace:n,checkChildren:e})||(a=!1))}),a}return!1}function J2(t){return t instanceof et}var Y2=class Q2{constructor(e){this.position=e}static fromJSON(e){return new Q2(e.position)}toJSON(){return{position:this.position}}};function m6(t,e){const n=e.mapping.mapResult(t.position);return{position:new Y2(n.pos),mapResult:n}}function g6(t){return new Y2(t)}function x6(t,e,n){var s;const{selection:a}=e;let i=null;if(L2(a)&&(i=a.$cursor),i){const c=(s=t.storedMarks)!=null?s:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(c)||!c.some(h=>h.type.excludes(n)))}const{ranges:o}=a;return o.some(({$from:c,$to:u})=>{let h=c.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(c.pos,u.pos,(f,m,g)=>{if(h)return!1;if(f.isInline){const y=!g||g.type.allowsMarkType(n),v=!!n.isInSet(f.marks)||!f.marks.some(w=>w.type.excludes(n));h=y&&v}return!h}),h})}var y6=(t,e={})=>({tr:n,state:s,dispatch:a})=>{const{selection:i}=n,{empty:o,ranges:c}=i,u=pi(t,s.schema);if(a)if(o){const h=$2(s,u);n.addStoredMark(u.create({...h,...e}))}else c.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;s.doc.nodesBetween(f,m,(g,y)=>{const v=Math.max(y,f),w=Math.min(y+g.nodeSize,m);g.marks.find(k=>k.type===u)?g.marks.forEach(k=>{u===k.type&&n.addMark(v,w,u.create({...k.attrs,...e}))}):n.addMark(v,w,u.create(e))})});return x6(s,n,u)},b6=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),v6=(t,e={})=>({state:n,dispatch:s,chain:a})=>{const i=Fn(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})=>Y1(i,{...o,...e})(n)?!0:c.clearNodes()).command(({state:c})=>Y1(i,{...o,...e})(c,s)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},N6=t=>({tr:e,dispatch:n})=>{if(n){const{doc:s}=e,a=Xo(t,0,s.content.size),i=et.create(s,a);e.setSelection(i)}return!0},w6=(t,e)=>({tr:n,state:s,dispatch:a})=>{const{selection:i}=s;let o,c;return typeof e=="number"?(o=e,c=e):e&&"from"in e&&"to"in e?(o=e.from,c=e.to):(o=i.from,c=i.to),a&&n.doc.nodesBetween(o,c,(u,h)=>{u.isText||n.setNodeMarkup(h,void 0,{...u.attrs,dir:t})}),!0},j6=t=>({tr:e,dispatch:n})=>{if(n){const{doc:s}=e,{from:a,to:i}=typeof t=="number"?{from:t,to:t}:t,o=nt.atStart(s).from,c=nt.atEnd(s).to,u=Xo(a,o,c),h=Xo(i,o,c),f=nt.create(s,u,h);e.setSelection(f)}return!0},k6=t=>({state:e,dispatch:n})=>{const s=Fn(t,e.schema);return x8(s)(e,n)};function $N(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const s=n.filter(a=>e==null?void 0:e.includes(a.type.name));t.tr.ensureMarks(s)}}var S6=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:s,editor:a})=>{const{selection:i,doc:o}=e,{$from:c,$to:u}=i,h=a.extensionManager.attributes,f=_h(h,c.node().type.name,c.node().attrs);if(i instanceof et&&i.node.isBlock)return!c.parentOffset||!li(o,c.pos)?!1:(s&&(t&&$N(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:ZD(c.node(-1).contentMatchAt(c.indexAfter(-1)));let y=m&&g?[{type:g,attrs:f}]:void 0,v=li(e.doc,e.mapping.map(c.pos),1,y);if(!y&&!v&&li(e.doc,e.mapping.map(c.pos),1,g?[{type:g}]:void 0)&&(v=!0,y=g?[{type:g,attrs:f}]:void 0),s){if(v&&(i instanceof nt&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,y),g&&!m&&!c.parentOffset&&c.parent.type!==g)){const w=e.mapping.map(c.before()),N=e.doc.resolve(w);c.node(-1).canReplaceWith(N.index(),N.index()+1,g)&&e.setNodeMarkup(e.mapping.map(c.before()),g)}t&&$N(n,a.extensionManager.splittableMarks),e.scrollIntoView()}return v},C6=(t,e={})=>({tr:n,state:s,dispatch:a,editor:i})=>{var o;const c=Fn(t,s.schema),{$from:u,$to:h}=s.selection,f=s.selection.node;if(f&&f.isBlock||u.depth<2||!u.sameParent(h))return!1;const m=u.node(-1);if(m.type!==c)return!1;const g=i.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==c||u.index(-2)!==u.node(-2).childCount-1)return!1;if(a){let k=we.empty;const E=u.index(-1)?1:u.index(-2)?2:3;for(let V=u.depth-E;V>=u.depth-3;V-=1)k=we.from(u.node(V).copy(k));const C=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3,P={..._h(g,u.node().type.name,u.node().attrs),...e},O=((o=c.contentMatch.defaultType)==null?void 0:o.createAndFill(P))||void 0;k=k.append(we.from(c.createAndFill(null,O)||void 0));const U=u.before(u.depth-(E-1));n.replace(U,u.after(-C),new ze(k,4-E,0));let _=-1;n.doc.nodesBetween(U,n.doc.content.size,(V,A)=>{if(_>-1)return!1;V.isTextblock&&V.content.size===0&&(_=A+1)}),_>-1&&n.setSelection(nt.near(n.doc.resolve(_))),n.scrollIntoView()}return!0}const y=h.pos===u.end()?m.contentMatchAt(0).defaultType:null,v={..._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 N=y?[{type:c,attrs:v},{type:y,attrs:w}]:[{type:c,attrs:v}];if(!li(n.doc,u.pos,2))return!1;if(a){const{selection:k,storedMarks:E}=s,{splittableMarks:C}=i.extensionManager,P=E||k.$to.parentOffset&&k.$from.marks();if(n.split(u.pos,2,N).scrollIntoView(),!P||!a)return!0;const O=P.filter(U=>C.includes(U.type.name));n.ensureMarks(O)}return!0},Rg=(t,e)=>{const n=mp(o=>o.type===e)(t.selection);if(!n)return!0;const s=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(s===void 0)return!0;const a=t.doc.nodeAt(s);return n.node.type===(a==null?void 0:a.type)&&go(t.doc,n.pos)&&t.join(n.pos),!0},Pg=(t,e)=>{const n=mp(o=>o.type===e)(t.selection);if(!n)return!0;const s=t.doc.resolve(n.start).after(n.depth);if(s===void 0)return!0;const a=t.doc.nodeAt(s);return n.node.type===(a==null?void 0:a.type)&&go(t.doc,s)&&t.join(s),!0},E6=(t,e,n,s={})=>({editor:a,tr:i,state:o,dispatch:c,chain:u,commands:h,can:f})=>{const{extensions:m,splittableMarks:g}=a.extensionManager,y=Fn(t,o.schema),v=Fn(e,o.schema),{selection:w,storedMarks:N}=o,{$from:k,$to:E}=w,C=k.blockRange(E),P=N||w.$to.parentOffset&&w.$from.marks();if(!C)return!1;const O=mp(U=>zN(U.type.name,m))(w);if(C.depth>=1&&O&&C.depth-O.depth<=1){if(O.node.type===y)return h.liftListItem(v);if(zN(O.node.type.name,m)&&y.validContent(O.node.content)&&c)return u().command(()=>(i.setNodeMarkup(O.pos,y),!0)).command(()=>Rg(i,y)).command(()=>Pg(i,y)).run()}return!n||!P||!c?u().command(()=>f().wrapInList(y,s)?!0:h.clearNodes()).wrapInList(y,s).command(()=>Rg(i,y)).command(()=>Pg(i,y)).run():u().command(()=>{const U=f().wrapInList(y,s),_=P.filter(V=>g.includes(V.type.name));return i.ensureMarks(_),U?!0:h.clearNodes()}).wrapInList(y,s).command(()=>Rg(i,y)).command(()=>Pg(i,y)).run()},T6=(t,e={},n={})=>({state:s,commands:a})=>{const{extendEmptyMarkRange:i=!1}=n,o=pi(t,s.schema);return Px(s,o,e)?a.unsetMark(o,{extendEmptyMarkRange:i}):a.setMark(o,e)},M6=(t,e,n={})=>({state:s,commands:a})=>{const i=Fn(t,s.schema),o=Fn(e,s.schema),c=co(s,i,n);let u;return s.selection.$anchor.sameParent(s.selection.$head)&&(u=s.selection.$anchor.parent.attrs),c?a.setNode(o,u):a.setNode(i,{...u,...n})},A6=(t,e={})=>({state:n,commands:s})=>{const a=Fn(t,n.schema);return co(n,a,e)?s.lift(a):s.wrapIn(a,e)},I6=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let s=0;s<n.length;s+=1){const a=n[s];let i;if(a.spec.isInputRules&&(i=a.getState(t))){if(e){const o=t.tr,c=i.transform;for(let u=c.steps.length-1;u>=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},R6=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:s,ranges:a}=n;return s||e&&a.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},P6=(t,e={})=>({tr:n,state:s,dispatch:a})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:c}=n,u=pi(t,s.schema),{$from:h,empty:f,ranges:m}=c;if(!a)return!0;if(f&&o){let{from:g,to:y}=c;const v=(i=h.marks().find(N=>N.type===u))==null?void 0:i.attrs,w=X0(h,u,v);w&&(g=w.from,y=w.to),n.removeMark(g,y,u)}else m.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,u)});return n.removeStoredMark(u),!0},O6=t=>({tr:e,state:n,dispatch:s})=>{const{selection:a}=n;let i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=a.from,o=a.to),s&&e.doc.nodesBetween(i,o,(c,u)=>{if(c.isText)return;const h={...c.attrs};delete h.dir,e.setNodeMarkup(u,void 0,h)}),!0},L6=(t,e={})=>({tr:n,state:s,dispatch:a})=>{let i=null,o=null;const c=pp(typeof t=="string"?t:t.name,s.schema);if(!c)return!1;c==="node"&&(i=Fn(t,s.schema)),c==="mark"&&(o=pi(t,s.schema));let u=!1;return n.selection.ranges.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;let g,y,v,w;n.selection.empty?s.doc.nodesBetween(f,m,(N,k)=>{i&&i===N.type&&(u=!0,v=Math.max(k,f),w=Math.min(k+N.nodeSize,m),g=k,y=N)}):s.doc.nodesBetween(f,m,(N,k)=>{k<f&&i&&i===N.type&&(u=!0,v=Math.max(k,f),w=Math.min(k+N.nodeSize,m),g=k,y=N),k>=f&&k<=m&&(i&&i===N.type&&(u=!0,a&&n.setNodeMarkup(k,void 0,{...N.attrs,...e})),o&&N.marks.length&&N.marks.forEach(E=>{if(o===E.type&&(u=!0,a)){const C=Math.max(k,f),P=Math.min(k+N.nodeSize,m);n.addMark(C,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(N=>{o===N.type&&a&&n.addMark(v,w,o.create({...N.attrs,...e}))}))}),u},D6=(t,e={})=>({state:n,dispatch:s})=>{const a=Fn(t,n.schema);return d8(a,e)(n,s)},_6=(t,e={})=>({state:n,dispatch:s})=>{const a=Fn(t,n.schema);return u8(a,e)(n,s)},z6=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(s=>s.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(s=>s!==e):delete this.callbacks[t]),this}once(t,e){const n=(...s)=>{this.off(t,n),e.apply(this,s)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},xp=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},$6=(t,e)=>{if(Q0(e))return e.exec(t);const n=e(t);if(!n)return null;const s=[n.text];return s.index=n.index,s.input=t,s.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),s.push(n.replaceWith)),s};function vh(t){var e;const{editor:n,from:s,to:a,text:i,rules:o,plugin:c}=t,{view:u}=n;if(u.composing)return!1;const h=u.state.doc.resolve(s);if(h.parent.type.spec.code||(e=h.nodeBefore||h.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let f=!1;const m=u6(h)+i;return o.forEach(g=>{if(f)return;const y=$6(m,g.find);if(!y)return;const v=u.state.tr,w=hp({state:u.state,transaction:v}),N={from:s-(y[0].length-i.length),to:a},{commands:k,chain:E,can:C}=new fp({editor:n,state:w});g.handler({state:w,range:N,match:y,commands:k,chain:E,can:C})===null||!v.steps.length||(g.undoable&&v.setMeta(c,{transform:v,from:s,to:a,text:i}),u.dispatch(v),f=!0)}),f}function F6(t){const{editor:e,rules:n}=t,s=new nn({state:{init(){return null},apply(a,i,o){const c=a.getMeta(s);if(c)return c;const u=a.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:f}=u;typeof f=="string"?f=f:f=ey(we.from(f),o.schema);const{from:m}=u,g=m+f.length;vh({editor:e,from:m,to:g,text:f,rules:n,plugin:s})}),a.selectionSet||a.docChanged?null:i}},props:{handleTextInput(a,i,o,c){return vh({editor:e,from:i,to:o,text:c,rules:n,plugin:s})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:i}=a.state.selection;i&&vh({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:s})}),!1)},handleKeyDown(a,i){if(i.key!=="Enter")return!1;const{$cursor:o}=a.state.selection;return o?vh({editor:e,from:o.pos,to:o.pos,text:`
`,rules:n,plugin:s}):!1}},isInputRules:!0});return s}function B6(t){return Object.prototype.toString.call(t).slice(8,-1)}function Nh(t){return B6(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function X2(t,e){const n={...t};return Nh(t)&&Nh(e)&&Object.keys(e).forEach(s=>{Nh(e[s])&&Nh(t[s])?n[s]=X2(t[s],e[s]):n[s]=e[s]}),n}var ny=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{...Dt(Xe(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Dt(Xe(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>X2(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}},Nl=class Z2 extends ny{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Z2(n)}static handleExit({editor:e,mark:n}){const{tr:s}=e.state,a=e.state.selection.$from;if(a.pos===a.end()){const o=a.marks();if(!!!o.find(h=>(h==null?void 0:h.type.name)===n.name))return!1;const u=o.find(h=>(h==null?void 0:h.type.name)===n.name);return u&&s.removeStoredMark(u),s.insertText(" ",a.pos),e.view.dispatch(s),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function V6(t){return typeof t=="number"}var H6=class{constructor(t){this.find=t.find,this.handler=t.handler}},U6=(t,e,n)=>{if(Q0(e))return[...t.matchAll(e)];const s=e(t,n);return s?s.map(a=>{const i=[a.text];return i.index=a.index,i.input=t,i.data=a.data,a.replaceWith&&(a.text.includes(a.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(a.replaceWith)),i}):[]};function W6(t){const{editor:e,state:n,from:s,to:a,rule:i,pasteEvent:o,dropEvent:c}=t,{commands:u,chain:h,can:f}=new fp({editor:e,state:n}),m=[];return n.doc.nodesBetween(s,a,(y,v)=>{var w,N,k,E,C;if((N=(w=y.type)==null?void 0:w.spec)!=null&&N.code||!(y.isText||y.isTextblock||y.isInline))return;const P=(C=(E=(k=y.content)==null?void 0:k.size)!=null?E:y.nodeSize)!=null?C:0,O=Math.max(s,v),U=Math.min(a,v+P);if(O>=U)return;const _=y.isText?y.text||"":y.textBetween(O-v,U-v,void 0,"");U6(_,i.find,o).forEach(A=>{if(A.index===void 0)return;const X=O+A.index+1,G=X+A[0].length,z={from:n.tr.mapping.map(X),to:n.tr.mapping.map(G)},ne=i.handler({state:n,range:z,match:A,commands:u,chain:h,can:f,pasteEvent:o,dropEvent:c});m.push(ne)})}),m.every(y=>y!==null)}var wh=null,K6=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function q6(t){const{editor:e,rules:n}=t;let s=null,a=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,c;try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}const u=({state:f,from:m,to:g,rule:y,pasteEvt:v})=>{const w=f.tr,N=hp({state:f,transaction:w});if(!(!W6({editor:e,state:N,from:Math.max(m-1,0),to:g.b-1,rule:y,pasteEvent:v,dropEvent:c})||!w.steps.length)){try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return n.map(f=>new nn({view(m){const g=v=>{var w;s=(w=m.dom.parentElement)!=null&&w.contains(v.target)?m.dom.parentElement:null,s&&(wh=e)},y=()=>{wh&&(wh=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",y),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",y)}}},props:{handleDOMEvents:{drop:(m,g)=>{if(i=s===m.dom.parentElement,c=g,!i){const y=wh;y!=null&&y.isEditable&&setTimeout(()=>{const v=y.state.selection;v&&y.commands.deleteRange({from:v.from,to:v.to})},10)}return!1},paste:(m,g)=>{var y;const v=(y=g.clipboardData)==null?void 0:y.getData("text/html");return o=g,a=!!(v!=null&&v.includes("data-pm-slice")),!1}}},appendTransaction:(m,g,y)=>{const v=m[0],w=v.getMeta("uiEvent")==="paste"&&!a,N=v.getMeta("uiEvent")==="drop"&&!i,k=v.getMeta("applyPasteRules"),E=!!k;if(!w&&!N&&!E)return;if(E){let{text:O}=k;typeof O=="string"?O=O:O=ey(we.from(O),y.schema);const{from:U}=k,_=U+O.length,V=K6(O);return u({rule:f,state:y,from:U,to:{b:_},pasteEvt:V})}const C=g.doc.content.findDiffStart(y.doc.content),P=g.doc.content.findDiffEnd(y.doc.content);if(!(!V6(C)||!P||C===P.b))return u({rule:f,state:y,from:C,to:P,pasteEvt:o})}}))}var yp=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=U2(t),this.schema=r6(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:fd(e.name,this.schema)},s=Xe(e,"addCommands",n);return s?{...t,...s()}:t},{})}get plugins(){const{editor:t}=this;return Ad([...this.extensions].reverse()).flatMap(s=>{const a={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:t,type:fd(s.name,this.schema)},i=[],o=Xe(s,"addKeyboardShortcuts",a);let c={};if(s.type==="mark"&&Xe(s,"exitable",a)&&(c.ArrowRight=()=>Nl.handleExit({editor:t,mark:s})),o){const g=Object.fromEntries(Object.entries(o()).map(([y,v])=>[y,()=>v({editor:t})]));c={...c,...g}}const u=oD(c);i.push(u);const h=Xe(s,"addInputRules",a);if(_N(s,t.options.enableInputRules)&&h){const g=h();if(g&&g.length){const y=F6({editor:t,rules:g}),v=Array.isArray(y)?y:[y];i.push(...v)}}const f=Xe(s,"addPasteRules",a);if(_N(s,t.options.enablePasteRules)&&f){const g=f();if(g&&g.length){const y=q6({editor:t,rules:g});i.push(...y)}}const m=Xe(s,"addProseMirrorPlugins",a);if(m){const g=m();i.push(...g)}return i})}get attributes(){return H2(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=wc(this.extensions);return Object.fromEntries(e.filter(n=>!!Xe(n,"addNodeView")).map(n=>{const s=this.attributes.filter(u=>u.type===n.name),a={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Fn(n.name,this.schema)},i=Xe(n,"addNodeView",a);if(!i)return[];const o=i();if(!o)return[];const c=(u,h,f,m,g)=>{const y=Jd(u,s);return o({node:u,view:h,getPos:f,decorations:m,innerDecorations:g,editor:t,extension:n,HTMLAttributes:y})};return[n.name,c]}))}dispatchTransaction(t){const{editor:e}=this;return Ad([...this.extensions].reverse()).reduceRight((s,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:fd(a.name,this.schema)},o=Xe(a,"dispatchTransaction",i);return o?c=>{o.call(i,{transaction:c,next:s})}:s},t)}transformPastedHTML(t){const{editor:e}=this;return Ad([...this.extensions]).reduce((s,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:fd(a.name,this.schema)},o=Xe(a,"transformPastedHTML",i);return o?(c,u)=>{const h=s(c,u);return o.call(i,h)}:s},t||(s=>s))}get markViews(){const{editor:t}=this,{markExtensions:e}=wc(this.extensions);return Object.fromEntries(e.filter(n=>!!Xe(n,"addMarkView")).map(n=>{const s=this.attributes.filter(c=>c.type===n.name),a={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:pi(n.name,this.schema)},i=Xe(n,"addMarkView",a);if(!i)return[];const o=(c,u,h)=>{const f=Jd(c,s);return i()({mark:c,view:u,inline:h,editor:t,extension:n,HTMLAttributes:f,updateAttributes:m=>{l_(c,t,m)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const s={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:fd(e.name,this.schema)};e.type==="mark"&&((n=Dt(Xe(e,"keepOnSplit",s)))==null||n)&&this.splittableMarks.push(e.name);const a=Xe(e,"onBeforeCreate",s),i=Xe(e,"onCreate",s),o=Xe(e,"onUpdate",s),c=Xe(e,"onSelectionUpdate",s),u=Xe(e,"onTransaction",s),h=Xe(e,"onFocus",s),f=Xe(e,"onBlur",s),m=Xe(e,"onDestroy",s);a&&this.editor.on("beforeCreate",a),i&&this.editor.on("create",i),o&&this.editor.on("update",o),c&&this.editor.on("selectionUpdate",c),u&&this.editor.on("transaction",u),h&&this.editor.on("focus",h),f&&this.editor.on("blur",f),m&&this.editor.on("destroy",m)})}};yp.resolve=U2;yp.sort=Ad;yp.flatten=Z0;var G6={};Y0(G6,{ClipboardTextSerializer:()=>tC,Commands:()=>nC,Delete:()=>sC,Drop:()=>rC,Editable:()=>aC,FocusEvents:()=>oC,Keymap:()=>lC,Paste:()=>cC,Tabindex:()=>dC,TextDirection:()=>uC,focusEventsPluginKey:()=>iC});var Tn=class eC extends ny{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new eC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},tC=Tn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new nn({key:new un("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:s,selection:a}=e,{ranges:i}=a,o=Math.min(...i.map(f=>f.$from.pos)),c=Math.max(...i.map(f=>f.$to.pos)),u=K2(n);return W2(s,{from:o,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),nC=Tn.create({name:"commands",addCommands(){return{...P2}}}),sC=Tn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,s,a;const i=()=>{var o,c,u,h;if((h=(u=(c=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:c.filterTransaction)==null?void 0:u.call(c,t))!=null?h:t.getMeta("y-sync$"))return;const f=F2(t.before,[t,...e]);G2(f).forEach(y=>{f.mapping.mapResult(y.oldRange.from).deletedAfter&&f.mapping.mapResult(y.oldRange.to).deletedBefore&&f.before.nodesBetween(y.oldRange.from,y.oldRange.to,(v,w)=>{const N=w+v.nodeSize-2,k=y.oldRange.from<=w&&N<=y.oldRange.to;this.editor.emit("delete",{type:"node",node:v,from:w,to:N,newFrom:f.mapping.map(w),newTo:f.mapping.map(N),deletedRange:y.oldRange,newRange:y.newRange,partial:!k,editor:this.editor,transaction:t,combinedTransform:f})})});const g=f.mapping;f.steps.forEach((y,v)=>{var w,N;if(y instanceof Jr){const k=g.slice(v).map(y.from,-1),E=g.slice(v).map(y.to),C=g.invert().map(k,-1),P=g.invert().map(E),O=(w=f.doc.nodeAt(k-1))==null?void 0:w.marks.some(_=>_.eq(y.mark)),U=(N=f.doc.nodeAt(E))==null?void 0:N.marks.some(_=>_.eq(y.mark));this.editor.emit("delete",{type:"mark",mark:y.mark,from:y.from,to:y.to,deletedRange:{from:C,to:P},newRange:{from:k,to:E},partial:!!(U||O),editor:this.editor,transaction:t,combinedTransform:f})}})};(a=(s=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:s.async)==null||a?setTimeout(i,0):i()}}),rC=Tn.create({name:"drop",addProseMirrorPlugins(){return[new nn({key:new un("tiptapDrop"),props:{handleDrop:(t,e,n,s)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:s})}}})]}}),aC=Tn.create({name:"editable",addProseMirrorPlugins(){return[new nn({key:new un("editable"),props:{editable:()=>this.editor.options.editable}})]}}),iC=new un("focusEvents"),oC=Tn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new nn({key:iC,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const s=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(s),!1},blur:(e,n)=>{t.isFocused=!1;const s=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(s),!1}}}})]}}),lC=Tn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:c})=>{const{selection:u,doc:h}=c,{empty:f,$anchor:m}=u,{pos:g,parent:y}=m,v=m.parent.isTextblock&&g>0?c.doc.resolve(g-1):m,w=v.parent.type.spec.isolating,N=m.pos-m.parentOffset,k=w&&v.parent.childCount===1?N===m.pos:lt.atStart(h).from===g;return!f||!y.type.isTextblock||y.textContent.length||!k||k&&m.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),s={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},a={...s},i={...s,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ff()||z2()?i:a},addProseMirrorPlugins(){return[new nn({key:new un("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(w=>w.getMeta("composition")))return;const s=t.some(w=>w.docChanged)&&!e.doc.eq(n.doc),a=t.some(w=>w.getMeta("preventClearDocument"));if(!s||a)return;const{empty:i,from:o,to:c}=e.selection,u=lt.atStart(e.doc).from,h=lt.atEnd(e.doc).to;if(i||!(o===u&&c===h)||!gp(n.doc))return;const g=n.tr,y=hp({state:n,transaction:g}),{commands:v}=new fp({editor:this.editor,state:y});if(v.clearNodes(),!!g.steps.length)return g}})]}}),cC=Tn.create({name:"paste",addProseMirrorPlugins(){return[new nn({key:new un("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),dC=Tn.create({name:"tabindex",addProseMirrorPlugins(){return[new nn({key:new un("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),uC=Tn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=wc(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 nn({key:new un("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),J6=class vd{constructor(e,n,s=!1,a=null){this.currentNode=null,this.actualDepth=null,this.isBlock=s,this.resolvedPos=e,this.editor=n,this.currentNode=a}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,s=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You cant set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,s=this.to-1}this.editor.commands.insertContentAt({from:n,to:s},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new vd(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 vd(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 vd(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,s)=>{const a=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.isInline,c=this.pos+s+(i?0:1);if(c<0||c>this.resolvedPos.doc.nodeSize-2)return;const u=this.resolvedPos.doc.resolve(c);if(!a&&!o&&u.depth<=this.depth)return;const h=new vd(u,this.editor,a,a||o?n:null);a&&(h.actualDepth=this.depth+1),e.push(h)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let s=null,a=this.parent;for(;a&&!s;){if(a.node.type.name===e)if(Object.keys(n).length>0){const i=a.node.attrs,o=Object.keys(n);for(let c=0;c<o.length;c+=1){const u=o[c];if(i[u]!==n[u])break}}else s=a;a=a.parent}return s}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},s=!1){let a=[];if(!this.children||this.children.length===0)return a;const i=Object.keys(n);return this.children.forEach(o=>{s&&a.length>0||(o.node.type.name===e&&i.every(u=>n[u]===o.node.attrs[u])&&a.push(o),!(s&&a.length>0)&&(a=a.concat(o.querySelectorAll(e,n,s))))}),a}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},Y6=`.ProseMirror {
position: relative;
}
.ProseMirror {
word-wrap: break-word;
white-space: pre-wrap;
white-space: break-spaces;
-webkit-font-variant-ligatures: none;
font-variant-ligatures: none;
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
}
.ProseMirror [contenteditable="false"] {
white-space: normal;
}
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
white-space: pre-wrap;
}
.ProseMirror pre {
white-space: pre-wrap;
}
img.ProseMirror-separator {
display: inline !important;
border: none !important;
margin: 0 !important;
width: 0 !important;
height: 0 !important;
}
.ProseMirror-gapcursor {
display: none;
pointer-events: none;
position: absolute;
margin: 0;
}
.ProseMirror-gapcursor:after {
content: "";
display: block;
position: absolute;
top: -2px;
width: 20px;
border-top: 1px solid black;
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}
@keyframes ProseMirror-cursor-blink {
to {
visibility: hidden;
}
}
.ProseMirror-hideselection *::selection {
background: transparent;
}
.ProseMirror-hideselection *::-moz-selection {
background: transparent;
}
.ProseMirror-hideselection * {
caret-color: transparent;
}
.ProseMirror-focused .ProseMirror-gapcursor {
display: block;
}`;function Q6(t,e,n){const s=document.querySelector("style[data-tiptap-style]");if(s!==null)return s;const a=document.createElement("style");return e&&a.setAttribute("nonce",e),a.setAttribute("data-tiptap-style",""),a.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(a),a}var X6=class extends z6{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:s})=>{throw s},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:m6,createMappablePosition:g6},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:s,slice:a,moved:i})=>this.options.onDrop(s,a,i)),this.on("paste",({event:s,slice:a})=>this.options.onPaste(s,a)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=D2(e,this.options.autofocus);this.editorState=cc.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=Q6(Y6,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=V2(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],s=this.state.reconfigure({plugins:n});return this.view.updateState(s),s}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(a=>{const i=typeof a=="string"?`${a}$`:a.key;n=n.filter(o=>!o.key.startsWith(i))}),e.length===n.length)return;const s=this.state.reconfigure({plugins:n});return this.view.updateState(s),s}createExtensionManager(){var t,e;const s=[...this.options.enableCoreExtensions?[aC,tC.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),nC,oC,lC,dC,rC,cC,sC,uC.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 yp(s,this)}createCommandManager(){this.commandManager=new fp({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Rx(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=Rx(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,s=e.dispatchTransaction||this.dispatchTransaction.bind(this),a=n?this.extensionManager.dispatchTransaction(s):s,i=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(i);this.editorView=new R2(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:a,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const c=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(c),this.prependClass(),this.injectCSS();const u=this.view.dom;u.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(h=>{var f;return(f=this.capturedTransaction)==null?void 0:f.step(h)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),s=!this.state.selection.eq(e.selection),a=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!a)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),s&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(h=>h.getMeta("focus")||h.getMeta("blur")),c=o==null?void 0:o.getMeta("focus"),u=o==null?void 0:o.getMeta("blur");c&&this.emit("focus",{editor:this,event:c.event,transaction:o}),u&&this.emit("blur",{editor:this,event:u.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(h=>h.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return q2(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,s=typeof t=="string"?e:t;return h6(this.state,n,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return ey(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
`,textSerializers:n={}}=t||{};return i6(this.state.doc,{blockSeparator:e,textSerializers:{...K2(this.schema),...n}})}get isEmpty(){return gp(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 J6(e,this)}get $doc(){return this.$pos(0)}};function jc(t){return new xp({find:t.find,handler:({state:e,range:n,match:s})=>{const a=Dt(t.getAttributes,void 0,s);if(a===!1||a===null)return null;const{tr:i}=e,o=s[s.length-1],c=s[0];if(o){const u=c.search(/\S/),h=n.from+c.indexOf(o),f=h+o.length;if(ty(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;f<n.to&&i.delete(f,n.to),h>n.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 hC(t){return new xp({find:t.find,handler:({state:e,range:n,match:s})=>{const a=Dt(t.getAttributes,void 0,s)||{},{tr:i}=e,o=n.from;let c=n.to;const u=t.type.create(a);if(s[1]){const h=s[0].lastIndexOf(s[1]);let f=o+h;f>c?f=c:c=f+s[1].length;const m=s[0][s[0].length-1];i.insertText(m,o+s[0].length-1),i.replaceWith(f,c,u)}else if(s[0]){const h=t.type.isInline?o:o-1;i.insert(h,t.type.create(a)).delete(i.mapping.map(o),i.mapping.map(c))}i.scrollIntoView()},undoable:t.undoable})}function Ox(t){return new xp({find:t.find,handler:({state:e,range:n,match:s})=>{const a=e.doc.resolve(n.from),i=Dt(t.getAttributes,void 0,s)||{};if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function kc(t){return new xp({find:t.find,handler:({state:e,range:n,match:s,chain:a})=>{const i=Dt(t.getAttributes,void 0,s)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),h=u&&R0(u,t.type,i);if(!h)return null;if(o.wrap(u,h),t.keepMarks&&t.editor){const{selection:m,storedMarks:g}=e,{splittableMarks:y}=t.editor.extensionManager,v=g||m.$to.parentOffset&&m.$from.marks();if(v){const w=v.filter(N=>y.includes(N.type.name));o.ensureMarks(w)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(m,i).run()}const f=o.doc.resolve(n.from-1).nodeBefore;f&&f.type===t.type&&go(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(s,f))&&o.join(n.from-1)},undoable:t.undoable})}var Z6=t=>"touches"in t,e_=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=c=>{if(!this.isResizing||!this.activeHandle)return;const u=c.clientX-this.startX,h=c.clientY-this.startY;this.handleResize(u,h)},this.handleTouchMove=c=>{if(!this.isResizing||!this.activeHandle)return;const u=c.touches[0];if(!u)return;const h=u.clientX-this.startX,f=u.clientY-this.startY;this.handleResize(h,f)},this.handleMouseUp=()=>{if(!this.isResizing)return;const c=this.element.offsetWidth,u=this.element.offsetHeight;this.onCommit(c,u),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,s,a,i,o;this.node=t.node,this.editor=t.editor,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(s=t==null?void 0:t.options)!=null&&s.directions&&(this.directions=t.options.directions),(a=t.options)!=null&&a.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(i=t.options)!=null&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(o=t.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),s=e.includes("bottom"),a=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),s&&(t.style.bottom="0"),a&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,Z6(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:s,height:a}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(s,a,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let s=this.startWidth,a=this.startHeight;const i=t.includes("right"),o=t.includes("left"),c=t.includes("bottom"),u=t.includes("top");return i?s=this.startWidth+e:o&&(s=this.startWidth-e),c?a=this.startHeight+n:u&&(a=this.startHeight-n),(t==="right"||t==="left")&&(s=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(a=this.startHeight+(c?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(s,a,t):{width:s,height:a}}applyConstraints(t,e,n){var s,a,i,o;if(!n){let h=Math.max(this.minSize.width,t),f=Math.max(this.minSize.height,e);return(s=this.maxSize)!=null&&s.width&&(h=Math.min(this.maxSize.width,h)),(a=this.maxSize)!=null&&a.height&&(f=Math.min(this.maxSize.height,f)),{width:h,height:f}}let c=t,u=e;return c<this.minSize.width&&(c=this.minSize.width,u=c/this.aspectRatio),u<this.minSize.height&&(u=this.minSize.height,c=u*this.aspectRatio),(i=this.maxSize)!=null&&i.width&&c>this.maxSize.width&&(c=this.maxSize.width,u=c/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&u>this.maxSize.height&&(u=this.maxSize.height,c=u*this.aspectRatio),{width:c,height:u}}applyAspectRatio(t,e,n){const s=n==="left"||n==="right",a=n==="top"||n==="bottom";return s?{width:t,height:t/this.aspectRatio}:a?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function t_(t,e){const{selection:n}=t,{$from:s}=n;if(n instanceof et){const i=s.index();return s.parent.canReplaceWith(i,i+1,e)}let a=s.depth;for(;a>=0;){const i=s.index(a);if(s.node(a).contentMatchAt(i).matchType(e))return!0;a-=1}return!1}function n_(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var s_={};Y0(s_,{createAtomBlockMarkdownSpec:()=>r_,createBlockMarkdownSpec:()=>a_,createInlineMarkdownSpec:()=>fC,parseAttributes:()=>sy,parseIndentedBlocks:()=>Lx,renderNestedMarkdownContent:()=>ay,serializeAttributes:()=>ry});function sy(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],s=t.replace(/["']([^"']*)["']/g,h=>(n.push(h),`__QUOTED_${n.length-1}__`)),a=s.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(a){const h=a.map(f=>f.trim().slice(1));e.class=h.join(" ")}const i=s.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(s.matchAll(o)).forEach(([,h,f])=>{var m;const g=parseInt(((m=f.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),y=n[g];y&&(e[h]=y.slice(1,-1))});const u=s.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return u&&u.split(/\s+/).filter(Boolean).forEach(f=>{f.match(/^[a-zA-Z][\w-]*$/)&&(e[f]=!0)}),e}function ry(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(s=>e.push(`.${s}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,s])=>{n==="class"||n==="id"||(s===!0?e.push(n):s!==!1&&s!=null&&e.push(`${n}="${String(s)}"`))}),e.join(" ")}function r_(t){const{nodeName:e,name:n,parseAttributes:s=sy,serializeAttributes:a=ry,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:c}=t,u=n||e,h=f=>{if(!c)return f;const m={};return c.forEach(g=>{g in f&&(m[g]=f[g])}),m};return{parseMarkdown:(f,m)=>{const g={...i,...f.attributes};return m.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(f){var m;const g=new RegExp(`^:::${u}(?:\\s|$)`,"m"),y=(m=f.match(g))==null?void 0:m.index;return y!==void 0?y:-1},tokenize(f,m,g){const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),v=f.match(y);if(!v)return;const w=v[1]||"",N=s(w);if(!o.find(E=>!(E in N)))return{type:e,raw:v[0],attributes:N}}},renderMarkdown:f=>{const m=h(f.attrs||{}),g=a(m),y=g?` {${g}}`:"";return`:::${u}${y} :::`}}}function a_(t){const{nodeName:e,name:n,getContent:s,parseAttributes:a=sy,serializeAttributes:i=ry,defaultAttributes:o={},content:c="block",allowedAttributes:u}=t,h=n||e,f=m=>{if(!u)return m;const g={};return u.forEach(y=>{y in m&&(g[y]=m[y])}),g};return{parseMarkdown:(m,g)=>{let y;if(s){const w=s(m);y=typeof w=="string"?[{type:"text",text:w}]:w}else c==="block"?y=g.parseChildren(m.tokens||[]):y=g.parseInline(m.tokens||[]);const v={...o,...m.attributes};return g.createNode(e,v,y)},markdownTokenizer:{name:e,level:"block",start(m){var g;const y=new RegExp(`^:::${h}`,"m"),v=(g=m.match(y))==null?void 0:g.index;return v!==void 0?v:-1},tokenize(m,g,y){var v;const w=new RegExp(`^:::${h}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),N=m.match(w);if(!N)return;const[k,E=""]=N,C=a(E);let P=1;const O=k.length;let U="";const _=/^:::([\w-]*)(\s.*)?/gm,V=m.slice(O);for(_.lastIndex=0;;){const A=_.exec(V);if(A===null)break;const X=A.index,G=A[1];if(!((v=A[2])!=null&&v.endsWith(":::"))){if(G)P+=1;else if(P-=1,P===0){const z=V.slice(0,X);U=z.trim();const ne=m.slice(0,O+X+A[0].length);let ue=[];if(U)if(c==="block")for(ue=y.blockTokens(z),ue.forEach(K=>{K.text&&(!K.tokens||K.tokens.length===0)&&(K.tokens=y.inlineTokens(K.text))});ue.length>0;){const K=ue[ue.length-1];if(K.type==="paragraph"&&(!K.text||K.text.trim()===""))ue.pop();else break}else ue=y.inlineTokens(U);return{type:e,raw:ne,attributes:C,content:U,tokens:ue}}}}}},renderMarkdown:(m,g)=>{const y=f(m.attrs||{}),v=i(y),w=v?` {${v}}`:"",N=g.renderChildren(m.content||[],`
`);return`:::${h}${w}
${N}
:::`}}}function i_(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let s=n.exec(t);for(;s!==null;){const[,a,i,o]=s;e[a]=i||o,s=n.exec(t)}return e}function o_(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function fC(t){const{nodeName:e,name:n,getContent:s,parseAttributes:a=i_,serializeAttributes:i=o_,defaultAttributes:o={},selfClosing:c=!1,allowedAttributes:u}=t,h=n||e,f=g=>{if(!u)return g;const y={};return u.forEach(v=>{const w=typeof v=="string"?v:v.name,N=typeof v=="string"?void 0:v.skipIfDefault;if(w in g){const k=g[w];if(N!==void 0&&k===N)return;y[w]=k}}),y},m=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,y)=>{const v={...o,...g.attributes};if(c)return y.createNode(e,v);const w=s?s(g):g.content||"";return w?y.createNode(e,v,[y.createTextNode(w)]):y.createNode(e,v,[])},markdownTokenizer:{name:e,level:"inline",start(g){const y=c?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),v=g.match(y),w=v==null?void 0:v.index;return w!==void 0?w:-1},tokenize(g,y,v){const w=c?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),N=g.match(w);if(!N)return;let k="",E="";if(c){const[,P]=N;E=P}else{const[,P,O]=N;E=P,k=O||""}const C=a(E.trim());return{type:e,raw:N[0],content:k.trim(),attributes:C}}},renderMarkdown:g=>{let y="";s?y=s(g):g.content&&g.content.length>0&&(y=g.content.filter(k=>k.type==="text").map(k=>k.text).join(""));const v=f(g.attrs||{}),w=i(v),N=w?` ${w}`:"";return c?`[${h}${N}]`:`[${h}${N}]${y}[/${h}]`}}}function Lx(t,e,n){var s,a,i,o;const c=t.split(`
`),u=[];let h="",f=0;const m=e.baseIndentSize||2;for(;f<c.length;){const g=c[f],y=g.match(e.itemPattern);if(!y){if(u.length>0)break;if(g.trim()===""){f+=1,h=`${h}${g}
`;continue}else return}const v=e.extractItemData(y),{indentLevel:w,mainContent:N}=v;h=`${h}${g}
`;const k=[N];for(f+=1;f<c.length;){const O=c[f];if(O.trim()===""){const _=c.slice(f+1).findIndex(X=>X.trim()!=="");if(_===-1)break;if((((a=(s=c[f+1+_].match(/^(\s*)/))==null?void 0:s[1])==null?void 0:a.length)||0)>w){k.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)k.push(O),h=`${h}${O}
`,f+=1;else break}let E;const C=k.slice(1);if(C.length>0){const O=C.map(U=>U.slice(w+m)).join(`
`);O.trim()&&(e.customNestedParser?E=e.customNestedParser(O):E=n.blockTokens(O))}const P=e.createToken(v,E);u.push(P)}if(u.length!==0)return{items:u,raw:h}}function ay(t,e,n,s){if(!t||!Array.isArray(t.content))return"";const a=typeof n=="function"?n(s):n,[i,...o]=t.content,c=e.renderChildren([i]),u=[`${a}${c}`];return o&&o.length>0&&o.forEach(h=>{const f=e.renderChildren([h]);if(f){const m=f.split(`
`).map(g=>g?e.indent(g):"").join(`
`);u.push(m)}}),u.join(`
`)}function l_(t,e,n={}){const{state:s}=e,{doc:a,tr:i}=s,o=t;a.descendants((c,u)=>{const h=i.mapping.map(u),f=i.mapping.map(u)+c.nodeSize;let m=null;if(c.marks.forEach(y=>{if(y!==o)return!1;m=y}),!m)return;let g=!1;if(Object.keys(n).forEach(y=>{n[y]!==m.attrs[y]&&(g=!0)}),g){const y=t.type.create({...t.attrs,...n});i.removeMark(h,f,t.type),i.addMark(h,f,y)}}),i.docChanged&&e.view.dispatch(i)}var Ln=class pC extends ny{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new pC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function pl(t){return new H6({find:t.find,handler:({state:e,range:n,match:s,pasteEvent:a})=>{const i=Dt(t.getAttributes,void 0,s,a);if(i===!1||i===null)return null;const{tr:o}=e,c=s[s.length-1],u=s[0];let h=n.to;if(c){const f=u.search(/\S/),m=n.from+u.indexOf(c),g=m+c.length;if(ty(n.from,n.to,e.doc).filter(v=>v.mark.type.excluded.find(N=>N===t.type&&N!==v.mark.type)).filter(v=>v.to>m).length)return null;g<n.to&&o.delete(g,n.to),m>n.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:d_}=Object,{hasOwnProperty:u_}=Object.prototype;function Og(t,e){return function(s,a,i){return t(s,a,i)&&e(s,a,i)}}function jh(t){return function(n,s,a){if(!n||!s||typeof n!="object"||typeof s!="object")return t(n,s,a);const{cache:i}=a,o=i.get(n),c=i.get(s);if(o&&c)return o===s&&c===n;i.set(n,s),i.set(s,n);const u=t(n,s,a);return i.delete(n),i.delete(s),u}}function h_(t){return t!=null?t[Symbol.toStringTag]:void 0}function FN(t){return c_(t).concat(d_(t))}const f_=Object.hasOwn||((t,e)=>u_.call(t,e));function wl(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const p_="__v",m_="__o",g_="_owner",{getOwnPropertyDescriptor:BN,keys:VN}=Object;function x_(t,e){return t.byteLength===e.byteLength&&pf(new Uint8Array(t),new Uint8Array(e))}function y_(t,e,n){let s=t.length;if(e.length!==s)return!1;for(;s-- >0;)if(!n.equals(t[s],e[s],s,s,t,e,n))return!1;return!0}function b_(t,e){return t.byteLength===e.byteLength&&pf(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function v_(t,e){return wl(t.getTime(),e.getTime())}function N_(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function w_(t,e){return t===e}function HN(t,e,n){const s=t.size;if(s!==e.size)return!1;if(!s)return!0;const a=new Array(s),i=t.entries();let o,c,u=0;for(;(o=i.next())&&!o.done;){const h=e.entries();let f=!1,m=0;for(;(c=h.next())&&!c.done;){if(a[m]){m++;continue}const g=o.value,y=c.value;if(n.equals(g[0],y[0],u,m,t,e,n)&&n.equals(g[1],y[1],g[0],y[0],t,e,n)){f=a[m]=!0;break}m++}if(!f)return!1;u++}return!0}const j_=wl;function k_(t,e,n){const s=VN(t);let a=s.length;if(VN(e).length!==a)return!1;for(;a-- >0;)if(!mC(t,e,n,s[a]))return!1;return!0}function pd(t,e,n){const s=FN(t);let a=s.length;if(FN(e).length!==a)return!1;let i,o,c;for(;a-- >0;)if(i=s[a],!mC(t,e,n,i)||(o=BN(t,i),c=BN(e,i),(o||c)&&(!o||!c||o.configurable!==c.configurable||o.enumerable!==c.enumerable||o.writable!==c.writable)))return!1;return!0}function S_(t,e){return wl(t.valueOf(),e.valueOf())}function C_(t,e){return t.source===e.source&&t.flags===e.flags}function UN(t,e,n){const s=t.size;if(s!==e.size)return!1;if(!s)return!0;const a=new Array(s),i=t.values();let o,c;for(;(o=i.next())&&!o.done;){const u=e.values();let h=!1,f=0;for(;(c=u.next())&&!c.done;){if(!a[f]&&n.equals(o.value,c.value,o.value,c.value,t,e,n)){h=a[f]=!0;break}f++}if(!h)return!1}return!0}function pf(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 E_(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 mC(t,e,n,s){return(s===g_||s===m_||s===p_)&&(t.$$typeof||e.$$typeof)?!0:f_(e,s)&&n.equals(t[s],e[s],s,s,t,e,n)}const T_="[object ArrayBuffer]",M_="[object Arguments]",A_="[object Boolean]",I_="[object DataView]",R_="[object Date]",P_="[object Error]",O_="[object Map]",L_="[object Number]",D_="[object Object]",__="[object RegExp]",z_="[object Set]",$_="[object String]",F_={"[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},B_="[object URL]",V_=Object.prototype.toString;function H_({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:s,areErrorsEqual:a,areFunctionsEqual:i,areMapsEqual:o,areNumbersEqual:c,areObjectsEqual:u,arePrimitiveWrappersEqual:h,areRegExpsEqual:f,areSetsEqual:m,areTypedArraysEqual:g,areUrlsEqual:y,unknownTagComparators:v}){return function(N,k,E){if(N===k)return!0;if(N==null||k==null)return!1;const C=typeof N;if(C!==typeof k)return!1;if(C!=="object")return C==="number"?c(N,k,E):C==="function"?i(N,k,E):!1;const P=N.constructor;if(P!==k.constructor)return!1;if(P===Object)return u(N,k,E);if(Array.isArray(N))return e(N,k,E);if(P===Date)return s(N,k,E);if(P===RegExp)return f(N,k,E);if(P===Map)return o(N,k,E);if(P===Set)return m(N,k,E);const O=V_.call(N);if(O===R_)return s(N,k,E);if(O===__)return f(N,k,E);if(O===O_)return o(N,k,E);if(O===z_)return m(N,k,E);if(O===D_)return typeof N.then!="function"&&typeof k.then!="function"&&u(N,k,E);if(O===B_)return y(N,k,E);if(O===P_)return a(N,k,E);if(O===M_)return u(N,k,E);if(F_[O])return g(N,k,E);if(O===T_)return t(N,k,E);if(O===I_)return n(N,k,E);if(O===A_||O===L_||O===$_)return h(N,k,E);if(v){let U=v[O];if(!U){const _=h_(N);_&&(U=v[_])}if(U)return U(N,k,E)}return!1}}function U_({circular:t,createCustomConfig:e,strict:n}){let s={areArrayBuffersEqual:x_,areArraysEqual:n?pd:y_,areDataViewsEqual:b_,areDatesEqual:v_,areErrorsEqual:N_,areFunctionsEqual:w_,areMapsEqual:n?Og(HN,pd):HN,areNumbersEqual:j_,areObjectsEqual:n?pd:k_,arePrimitiveWrappersEqual:S_,areRegExpsEqual:C_,areSetsEqual:n?Og(UN,pd):UN,areTypedArraysEqual:n?Og(pf,pd):pf,areUrlsEqual:E_,unknownTagComparators:void 0};if(e&&(s=Object.assign({},s,e(s))),t){const a=jh(s.areArraysEqual),i=jh(s.areMapsEqual),o=jh(s.areObjectsEqual),c=jh(s.areSetsEqual);s=Object.assign({},s,{areArraysEqual:a,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:c})}return s}function W_(t){return function(e,n,s,a,i,o,c){return t(e,n,c)}}function K_({circular:t,comparator:e,createState:n,equals:s,strict:a}){if(n)return function(c,u){const{cache:h=t?new WeakMap:void 0,meta:f}=n();return e(c,u,{cache:h,equals:s,meta:f,strict:a})};if(t)return function(c,u){return e(c,u,{cache:new WeakMap,equals:s,meta:void 0,strict:a})};const i={cache:void 0,equals:s,meta:void 0,strict:a};return function(c,u){return e(c,u,i)}}const q_=yo();yo({strict:!0});yo({circular:!0});yo({circular:!0,strict:!0});yo({createInternalComparator:()=>wl});yo({strict:!0,createInternalComparator:()=>wl});yo({circular:!0,createInternalComparator:()=>wl});yo({circular:!0,createInternalComparator:()=>wl,strict:!0});function yo(t={}){const{circular:e=!1,createInternalComparator:n,createState:s,strict:a=!1}=t,i=U_(t),o=H_(i),c=n?n(o):W_(o);return K_({circular:e,comparator:o,createState:s,equals:c,strict:a})}var Lg={exports:{}},Dg={};/**
* @license React
* use-sync-external-store-shim/with-selector.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var WN;function G_(){if(WN)return Dg;WN=1;var t=eu(),e=rS();function n(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var s=typeof Object.is=="function"?Object.is:n,a=e.useSyncExternalStore,i=t.useRef,o=t.useEffect,c=t.useMemo,u=t.useDebugValue;return Dg.useSyncExternalStoreWithSelector=function(h,f,m,g,y){var v=i(null);if(v.current===null){var w={hasValue:!1,value:null};v.current=w}else w=v.current;v=c(function(){function k(U){if(!E){if(E=!0,C=U,U=g(U),y!==void 0&&w.hasValue){var _=w.value;if(y(_,U))return P=_}return P=U}if(_=P,s(C,U))return _;var V=g(U);return y!==void 0&&y(_,V)?(C=U,_):(C=U,P=V)}var E=!1,C,P,O=m===void 0?null:m;return[function(){return k(f())},O===null?void 0:function(){return k(O())}]},[f,m,g,y]);var N=a(h,v[0],v[1]);return o(function(){w.hasValue=!0,w.value=N},[N]),u(N),N},Dg}var KN;function J_(){return KN||(KN=1,Lg.exports=G_()),Lg.exports}var Y_=J_(),Q_=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},X_=({contentComponent:t})=>{const e=aS.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return r.jsx(r.Fragment,{children:Object.values(e)})};function Z_(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,s){e={...e,[n]:tj.createPortal(s.reactElement,s.element,n)},t.forEach(a=>a())},removeRenderer(n){const s={...e};delete s[n],e=s,t.forEach(a=>a())}}}var e7=class extends Ls.Component{constructor(t){var e;super(t),this.editorContentRef=Ls.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=Z_(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(s=>s.hasContentComponentInitialized?s:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:Q_(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&r.jsx(X_,{contentComponent:t.contentComponent})]})}},t7=b.forwardRef((t,e)=>{const n=Ls.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Ls.createElement(e7,{key:n,innerRef:e,...t})}),gC=Ls.memo(t7),n7=typeof window<"u"?b.useLayoutEffect:b.useEffect,s7=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(s=>s())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function r7(t){var e;const[n]=b.useState(()=>new s7(t.editor)),s=Y_.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:q_);return n7(()=>n.watch(t.editor),[t.editor,n]),b.useDebugValue(s),s}var a7=!1,Dx=typeof window>"u",i7=Dx||!!(typeof window<"u"&&window.next),o7=class xC{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?Dx||i7?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...s)=>{var a,i;return(i=(a=this.options.current).onBeforeCreate)==null?void 0:i.call(a,...s)},onBlur:(...s)=>{var a,i;return(i=(a=this.options.current).onBlur)==null?void 0:i.call(a,...s)},onCreate:(...s)=>{var a,i;return(i=(a=this.options.current).onCreate)==null?void 0:i.call(a,...s)},onDestroy:(...s)=>{var a,i;return(i=(a=this.options.current).onDestroy)==null?void 0:i.call(a,...s)},onFocus:(...s)=>{var a,i;return(i=(a=this.options.current).onFocus)==null?void 0:i.call(a,...s)},onSelectionUpdate:(...s)=>{var a,i;return(i=(a=this.options.current).onSelectionUpdate)==null?void 0:i.call(a,...s)},onTransaction:(...s)=>{var a,i;return(i=(a=this.options.current).onTransaction)==null?void 0:i.call(a,...s)},onUpdate:(...s)=>{var a,i;return(i=(a=this.options.current).onUpdate)==null?void 0:i.call(a,...s)},onContentError:(...s)=>{var a,i;return(i=(a=this.options.current).onContentError)==null?void 0:i.call(a,...s)},onDrop:(...s)=>{var a,i;return(i=(a=this.options.current).onDrop)==null?void 0:i.call(a,...s)},onPaste:(...s)=>{var a,i;return(i=(a=this.options.current).onPaste)==null?void 0:i.call(a,...s)},onDelete:(...s)=>{var a,i;return(i=(a=this.options.current).onDelete)==null?void 0:i.call(a,...s)}};return new X6(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(s=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(s)?!0:s==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((a,i)=>{var o;return a===((o=n.extensions)==null?void 0:o[i])}):e[s]===n[s])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?xC.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((s,a)=>s===e[a]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function l7(t={},e=[]){const n=b.useRef(t);n.current=t;const[s]=b.useState(()=>new o7(n)),a=aS.useSyncExternalStore(s.subscribe,s.getEditor,s.getServerSnapshot);return b.useDebugValue(a),b.useEffect(s.onRender(e)),r7({editor:a,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),a}var yC=b.createContext({editor:null});yC.Consumer;var c7=b.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),d7=()=>b.useContext(c7);Ls.forwardRef((t,e)=>{const{onDragStart:n}=d7(),s=t.as||"div";return r.jsx(s,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Ls.createContext({markViewContentRef:()=>{}});var iy=b.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});iy.displayName="TiptapContext";var u7=()=>b.useContext(iy);function bC({editor:t,instance:e,children:n}){const s=t??e;if(!s)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const a=b.useMemo(()=>({editor:s}),[s]),i=b.useMemo(()=>({editor:s}),[s]);return r.jsx(yC.Provider,{value:i,children:r.jsx(iy.Provider,{value:a,children:n})})}bC.displayName="Tiptap";function vC({...t}){const{editor:e}=u7();return r.jsx(gC,{editor:e,...t})}vC.displayName="Tiptap.Content";Object.assign(bC,{Content:vC});var mf=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...s}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,s,n]},h7=/^\s*>\s$/,f7=Ln.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return mf("blockquote",{...zt(this.options.HTMLAttributes,t),children:mf("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",s=[];return t.content.forEach(a=>{const c=e.renderChildren([a]).split(`
`).map(u=>u.trim()===""?n:`${n} ${u}`);s.push(c.join(`
`))}),s.join(`
${n}
`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[kc({find:h7,type:this.type})]}}),p7=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,m7=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,g7=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,x7=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,y7=Nl.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 mf("strong",{...zt(this.options.HTMLAttributes,t),children:mf("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[jc({find:p7,type:this.type}),jc({find:g7,type:this.type})]},addPasteRules(){return[pl({find:m7,type:this.type}),pl({find:x7,type:this.type})]}}),b7=/(^|[^`])`([^`]+)`(?!`)$/,v7=/(^|[^`])`([^`]+)`(?!`)/g,N7=Nl.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",zt(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[jc({find:b7,type:this.type})]},addPasteRules(){return[pl({find:v7,type:this.type})]}}),_g=4,w7=/^```([a-z]+)?[\s\n]$/,j7=/^~~~([a-z]+)?[\s\n]$/,k7=Ln.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:_g,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",zt(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,s;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&((s=t.raw)==null?void 0:s.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let s="";const a=((n=t.attrs)==null?void 0:n.language)||"";return t.content?s=[`\`\`\`${a}`,e.renderChildren(t.content),"```"].join(`
`):s=`\`\`\`${a}
\`\`\``,s},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:_g,{state:s}=t,{selection:a}=s,{$from:i,empty:o}=a;if(i.parent.type!==this.type)return!1;const c=" ".repeat(n);return o?t.commands.insertContent(c):t.commands.command(({tr:u})=>{const{from:h,to:f}=a,y=s.doc.textBetween(h,f,`
`,`
`).split(`
`).map(v=>c+v).join(`
`);return u.replaceWith(h,f,s.schema.text(y)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:_g,{state:s}=t,{selection:a}=s,{$from:i,empty:o}=a;return i.parent.type!==this.type?!1:o?t.commands.command(({tr:c})=>{var u;const{pos:h}=i,f=i.start(),m=i.end(),y=s.doc.textBetween(f,m,`
`,`
`).split(`
`);let v=0,w=0;const N=h-f;for(let U=0;U<y.length;U+=1){if(w+y[U].length>=N){v=U;break}w+=y[U].length+1}const E=((u=y[v].match(/^ */))==null?void 0:u[0])||"",C=Math.min(E.length,n);if(C===0)return!0;let P=f;for(let U=0;U<v;U+=1)P+=y[U].length+1;return c.delete(P,P+C),h-P<=C&&c.setSelection(nt.create(c.doc,P)),!0}):t.commands.command(({tr:c})=>{const{from:u,to:h}=a,g=s.doc.textBetween(u,h,`
`,`
`).split(`
`).map(y=>{var v;const w=((v=y.match(/^ */))==null?void 0:v[0])||"",N=Math.min(w.length,n);return y.slice(N)}).join(`
`);return c.replaceWith(u,h,s.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:s,empty:a}=n;if(!a||s.parent.type!==this.type)return!1;const i=s.parentOffset===s.parent.nodeSize-2,o=s.parent.textContent.endsWith(`
`);return!i||!o?!1:t.chain().command(({tr:c})=>(c.delete(s.pos-2,s.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:s}=e,{$from:a,empty:i}=n;if(!i||a.parent.type!==this.type||!(a.parentOffset===a.parent.nodeSize-2))return!1;const c=a.after();return c===void 0?!1:s.nodeAt(c)?t.commands.command(({tr:h})=>(h.setSelection(lt.near(s.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[Ox({find:w7,type:this.type,getAttributes:t=>({language:t[1]})}),Ox({find:j7,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new nn({key:new un("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),s=e.clipboardData.getData("vscode-editor-data"),a=s?JSON.parse(s):void 0,i=a==null?void 0:a.mode;if(!n||!i)return!1;const{tr:o,schema:c}=t.state,u=c.text(n.replace(/\r\n?/g,`
`));return o.replaceSelectionWith(this.type.create({language:i},u)),o.selection.$from.parent.type!==this.type&&o.setSelection(nt.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),S7=Ln.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):""}),C7=Ln.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",zt(this.options.HTMLAttributes,t)]},renderText(){return`
`},renderMarkdown:()=>`
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:s})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:a,storedMarks:i}=n;if(a.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:c}=s.extensionManager,u=i||a.$to.parentOffset&&a.$from.marks();return e().insertContent({type:this.name}).command(({tr:h,dispatch:f})=>{if(f&&u&&o){const m=u.filter(g=>c.includes(g.type.name));h.ensureMarks(m)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),E7=Ln.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]}`,zt(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const s=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,a="#".repeat(s);return t.content?`${a} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Ox({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),T7=Ln.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",zt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!t_(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:s}=n,a=t();return J2(n)?a.insertContentAt(s.pos,{type:this.name}):a.insertContent({type:this.name}),a.command(({state:i,tr:o,dispatch:c})=>{if(c){const{$to:u}=o.selection,h=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?o.setSelection(nt.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(et.create(o.doc,u.pos)):o.setSelection(nt.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(nt.create(o.doc,h+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[hC({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),M7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,A7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,I7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,R7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,P7=Nl.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",zt(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[jc({find:M7,type:this.type}),jc({find:I7,type:this.type})]},addPasteRules(){return[pl({find:A7,type:this.type}),pl({find:R7,type:this.type})]}});const O7="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",L7="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт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همراهاکستان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",_x="numeric",zx="ascii",$x="alpha",Id="asciinumeric",Nd="alphanumeric",Fx="domain",NC="emoji",D7="scheme",_7="slashscheme",zg="whitespace";function z7(t,e){return t in e||(e[t]=[]),e[t]}function Zo(t,e,n){e[_x]&&(e[Id]=!0,e[Nd]=!0),e[zx]&&(e[Id]=!0,e[$x]=!0),e[Id]&&(e[Nd]=!0),e[$x]&&(e[Nd]=!0),e[Nd]&&(e[Fx]=!0),e[NC]&&(e[Fx]=!0);for(const s in e){const a=z7(s,n);a.indexOf(t)<0&&a.push(t)}}function $7(t,e){const n={};for(const s in e)e[s].indexOf(t)>=0&&(n[s]=!0);return n}function qs(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}qs.groups={};qs.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let s=0;s<e.jr.length;s++){const a=e.jr[s][0],i=e.jr[s][1];if(i&&a.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,s){for(let a=0;a<t.length;a++)this.tt(t[a],e,n,s)},tr(t,e,n,s){s=s||qs.groups;let a;return e&&e.j?a=e:(a=new qs(e),n&&s&&Zo(e,n,s)),this.jr.push([t,a]),a},ts(t,e,n,s){let a=this;const i=t.length;if(!i)return a;for(let o=0;o<i-1;o++)a=a.tt(t[o]);return a.tt(t[i-1],e,n,s)},tt(t,e,n,s){s=s||qs.groups;const a=this;if(e&&e.j)return a.j[t]=e,e;const i=e;let o,c=a.go(t);if(c?(o=new qs,Object.assign(o.j,c.j),o.jr.push.apply(o.jr,c.jr),o.jd=c.jd,o.t=c.t):o=new qs,i){if(s)if(o.t&&typeof o.t=="string"){const u=Object.assign($7(o.t,s),n);Zo(i,u,s)}else n&&Zo(i,n,s);o.t=i}return a.j[t]=o,o}};const yt=(t,e,n,s,a)=>t.ta(e,n,s,a),jn=(t,e,n,s,a)=>t.tr(e,n,s,a),qN=(t,e,n,s,a)=>t.ts(e,n,s,a),Ae=(t,e,n,s,a)=>t.tt(e,n,s,a),ti="WORD",Bx="UWORD",wC="ASCIINUMERICAL",jC="ALPHANUMERICAL",Yd="LOCALHOST",Vx="TLD",Hx="UTLD",zh="SCHEME",sc="SLASH_SCHEME",oy="NUM",Ux="WS",ly="NL",Rd="OPENBRACE",Pd="CLOSEBRACE",gf="OPENBRACKET",xf="CLOSEBRACKET",yf="OPENPAREN",bf="CLOSEPAREN",vf="OPENANGLEBRACKET",Nf="CLOSEANGLEBRACKET",wf="FULLWIDTHLEFTPAREN",jf="FULLWIDTHRIGHTPAREN",kf="LEFTCORNERBRACKET",Sf="RIGHTCORNERBRACKET",Cf="LEFTWHITECORNERBRACKET",Ef="RIGHTWHITECORNERBRACKET",Tf="FULLWIDTHLESSTHAN",Mf="FULLWIDTHGREATERTHAN",Af="AMPERSAND",If="APOSTROPHE",Rf="ASTERISK",Hi="AT",Pf="BACKSLASH",Of="BACKTICK",Lf="CARET",Ki="COLON",cy="COMMA",Df="DOLLAR",Na="DOT",_f="EQUALS",dy="EXCLAMATION",kr="HYPHEN",Od="PERCENT",zf="PIPE",$f="PLUS",Ff="POUND",Ld="QUERY",uy="QUOTE",kC="FULLWIDTHMIDDLEDOT",hy="SEMI",wa="SLASH",Dd="TILDE",Bf="UNDERSCORE",SC="EMOJI",Vf="SYM";var CC=Object.freeze({__proto__:null,ALPHANUMERICAL:jC,AMPERSAND:Af,APOSTROPHE:If,ASCIINUMERICAL:wC,ASTERISK:Rf,AT:Hi,BACKSLASH:Pf,BACKTICK:Of,CARET:Lf,CLOSEANGLEBRACKET:Nf,CLOSEBRACE:Pd,CLOSEBRACKET:xf,CLOSEPAREN:bf,COLON:Ki,COMMA:cy,DOLLAR:Df,DOT:Na,EMOJI:SC,EQUALS:_f,EXCLAMATION:dy,FULLWIDTHGREATERTHAN:Mf,FULLWIDTHLEFTPAREN:wf,FULLWIDTHLESSTHAN:Tf,FULLWIDTHMIDDLEDOT:kC,FULLWIDTHRIGHTPAREN:jf,HYPHEN:kr,LEFTCORNERBRACKET:kf,LEFTWHITECORNERBRACKET:Cf,LOCALHOST:Yd,NL:ly,NUM:oy,OPENANGLEBRACKET:vf,OPENBRACE:Rd,OPENBRACKET:gf,OPENPAREN:yf,PERCENT:Od,PIPE:zf,PLUS:$f,POUND:Ff,QUERY:Ld,QUOTE:uy,RIGHTCORNERBRACKET:Sf,RIGHTWHITECORNERBRACKET:Ef,SCHEME:zh,SEMI:hy,SLASH:wa,SLASH_SCHEME:sc,SYM:Vf,TILDE:Dd,TLD:Vx,UNDERSCORE:Bf,UTLD:Hx,UWORD:Bx,WORD:ti,WS:Ux});const Za=/[a-z]/,md=new RegExp("\\p{L}","u"),$g=new RegExp("\\p{Emoji}","u"),ei=/\d/,Fg=/\s/,GN="\r",Bg=`
`,F7="",B7="",Vg="";let kh=null,Sh=null;function V7(t=[]){const e={};qs.groups=e;const n=new qs;kh==null&&(kh=JN(O7)),Sh==null&&(Sh=JN(L7)),Ae(n,"'",If),Ae(n,"{",Rd),Ae(n,"}",Pd),Ae(n,"[",gf),Ae(n,"]",xf),Ae(n,"(",yf),Ae(n,")",bf),Ae(n,"<",vf),Ae(n,">",Nf),Ae(n,"",wf),Ae(n,"",jf),Ae(n,"「",kf),Ae(n,"」",Sf),Ae(n,"『",Cf),Ae(n,"』",Ef),Ae(n,"",Tf),Ae(n,"",Mf),Ae(n,"&",Af),Ae(n,"*",Rf),Ae(n,"@",Hi),Ae(n,"`",Of),Ae(n,"^",Lf),Ae(n,":",Ki),Ae(n,",",cy),Ae(n,"$",Df),Ae(n,".",Na),Ae(n,"=",_f),Ae(n,"!",dy),Ae(n,"-",kr),Ae(n,"%",Od),Ae(n,"|",zf),Ae(n,"+",$f),Ae(n,"#",Ff),Ae(n,"?",Ld),Ae(n,'"',uy),Ae(n,"/",wa),Ae(n,";",hy),Ae(n,"~",Dd),Ae(n,"_",Bf),Ae(n,"\\",Pf),Ae(n,"・",kC);const s=jn(n,ei,oy,{[_x]:!0});jn(s,ei,s);const a=jn(s,Za,wC,{[Id]:!0}),i=jn(s,md,jC,{[Nd]:!0}),o=jn(n,Za,ti,{[zx]:!0});jn(o,ei,a),jn(o,Za,o),jn(a,ei,a),jn(a,Za,a);const c=jn(n,md,Bx,{[$x]:!0});jn(c,Za),jn(c,ei,i),jn(c,md,c),jn(i,ei,i),jn(i,Za),jn(i,md,i);const u=Ae(n,Bg,ly,{[zg]:!0}),h=Ae(n,GN,Ux,{[zg]:!0}),f=jn(n,Fg,Ux,{[zg]:!0});Ae(n,Vg,f),Ae(h,Bg,u),Ae(h,Vg,f),jn(h,Fg,f),Ae(f,GN),Ae(f,Bg),jn(f,Fg,f),Ae(f,Vg,f);const m=jn(n,$g,SC,{[NC]:!0});Ae(m,"#"),jn(m,$g,m),Ae(m,F7,m);const g=Ae(m,B7);Ae(g,"#"),jn(g,$g,m);const y=[[Za,o],[ei,a]],v=[[Za,null],[md,c],[ei,i]];for(let w=0;w<kh.length;w++)zi(n,kh[w],Vx,ti,y);for(let w=0;w<Sh.length;w++)zi(n,Sh[w],Hx,Bx,v);Zo(Vx,{tld:!0,ascii:!0},e),Zo(Hx,{utld:!0,alpha:!0},e),zi(n,"file",zh,ti,y),zi(n,"mailto",zh,ti,y),zi(n,"http",sc,ti,y),zi(n,"https",sc,ti,y),zi(n,"ftp",sc,ti,y),zi(n,"ftps",sc,ti,y),Zo(zh,{scheme:!0,ascii:!0},e),Zo(sc,{slashscheme:!0,ascii:!0},e),t=t.sort((w,N)=>w[0]>N[0]?1:-1);for(let w=0;w<t.length;w++){const N=t[w][0],E=t[w][1]?{[D7]:!0}:{[_7]:!0};N.indexOf("-")>=0?E[Fx]=!0:Za.test(N)?ei.test(N)?E[Id]=!0:E[zx]=!0:E[_x]=!0,qN(n,N,N,E)}return qN(n,"localhost",Yd,{ascii:!0}),n.jd=new qs(Vf),{start:n,tokens:Object.assign({groups:e},CC)}}function EC(t,e){const n=H7(e.replace(/[A-Z]/g,c=>c.toLowerCase())),s=n.length,a=[];let i=0,o=0;for(;o<s;){let c=t,u=null,h=0,f=null,m=-1,g=-1;for(;o<s&&(u=c.go(n[o]));)c=u,c.accepts()?(m=0,g=0,f=c):m>=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 H7(t){const e=[],n=t.length;let s=0;for(;s<n;){let a=t.charCodeAt(s),i,o=a<55296||a>56319||s+1===n||(i=t.charCodeAt(s+1))<56320||i>57343?t[s]:t.slice(s,s+2);e.push(o),s+=o.length}return e}function zi(t,e,n,s,a){let i;const o=e.length;for(let c=0;c<o-1;c++){const u=e[c];t.j[u]?i=t.j[u]:(i=new qs(s),i.jr=a.slice(),t.j[u]=i),t=i}return i=new qs(n),i.jr=a.slice(),t.j[e[o-1]]=i,i}function JN(t){const e=[],n=[];let s=0,a="0123456789";for(;s<t.length;){let i=0;for(;a.indexOf(t[s+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let o=parseInt(t.substring(s,s+i),10);o>0;o--)n.pop();s+=i}else n.push(t[s]),s++}return e}const Qd={defaultProtocol:"http",events:null,format:YN,formatHref:YN,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function fy(t,e=null){let n=Object.assign({},Qd);t&&(n=Object.assign(n,t instanceof fy?t.o:t));const s=n.ignoreTags,a=[];for(let i=0;i<s.length;i++)a.push(s[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=a}fy.prototype={o:Qd,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const s=e!=null;let a=this.o[t];return a&&(typeof a=="object"?(a=n.t in a?a[n.t]:Qd[t],typeof a=="function"&&s&&(a=a(e,n))):typeof a=="function"&&s&&(a=a(e,n.t,n)),a)},getObj(t,e,n){let s=this.o[t];return typeof s=="function"&&e!=null&&(s=s(e,n.t,n)),s},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function YN(t){return t}function TC(t,e){this.t="token",this.v=t,this.tk=e}TC.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),s=t.get("format",e,this);return n&&s.length>n?s.substring(0,n)+"…":s},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Qd.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),s=t.get("formatHref",n,this),a=t.get("tagName",n,e),i=this.toFormattedString(t),o={},c=t.get("className",n,e),u=t.get("target",n,e),h=t.get("rel",n,e),f=t.getObj("attributes",n,e),m=t.getObj("events",n,e);return o.href=s,c&&(o.class=c),u&&(o.target=u),h&&(o.rel=h),f&&Object.assign(o,f),{tagName:a,attributes:o,content:i,eventListeners:m}}};function bp(t,e){class n extends TC{constructor(a,i){super(a,i),this.t=t}}for(const s in e)n.prototype[s]=e[s];return n.t=t,n}const QN=bp("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),XN=bp("text"),U7=bp("nl"),Ch=bp("url",{isLink:!0,toHref(t=Qd.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Yd&&t[1].t===Ki}}),jr=t=>new qs(t);function W7({groups:t}){const e=t.domain.concat([Af,Rf,Hi,Pf,Of,Lf,Df,_f,kr,oy,Od,zf,$f,Ff,wa,Vf,Dd,Bf]),n=[If,Ki,cy,Na,dy,Od,Ld,uy,hy,vf,Nf,Rd,Pd,xf,gf,yf,bf,wf,jf,kf,Sf,Cf,Ef,Tf,Mf],s=[Af,If,Rf,Pf,Of,Lf,Df,_f,kr,Rd,Pd,Od,zf,$f,Ff,Ld,wa,Vf,Dd,Bf],a=jr(),i=Ae(a,Dd);yt(i,s,i),yt(i,t.domain,i);const o=jr(),c=jr(),u=jr();yt(a,t.domain,o),yt(a,t.scheme,c),yt(a,t.slashscheme,u),yt(o,s,i),yt(o,t.domain,o);const h=Ae(o,Hi);Ae(i,Hi,h),Ae(c,Hi,h),Ae(u,Hi,h);const f=Ae(i,Na);yt(f,s,i),yt(f,t.domain,i);const m=jr();yt(h,t.domain,m),yt(m,t.domain,m);const g=Ae(m,Na);yt(g,t.domain,m);const y=jr(QN);yt(g,t.tld,y),yt(g,t.utld,y),Ae(h,Yd,y);const v=Ae(m,kr);Ae(v,kr,v),yt(v,t.domain,m),yt(y,t.domain,m),Ae(y,Na,g),Ae(y,kr,v);const w=Ae(y,Ki);yt(w,t.numeric,QN);const N=Ae(o,kr),k=Ae(o,Na);Ae(N,kr,N),yt(N,t.domain,o),yt(k,s,i),yt(k,t.domain,o);const E=jr(Ch);yt(k,t.tld,E),yt(k,t.utld,E),yt(E,t.domain,o),yt(E,s,i),Ae(E,Na,k),Ae(E,kr,N),Ae(E,Hi,h);const C=Ae(E,Ki),P=jr(Ch);yt(C,t.numeric,P);const O=jr(Ch),U=jr();yt(O,e,O),yt(O,n,U),yt(U,e,O),yt(U,n,U),Ae(E,wa,O),Ae(P,wa,O);const _=Ae(c,Ki),V=Ae(u,Ki),A=Ae(V,wa),X=Ae(A,wa);yt(c,t.domain,o),Ae(c,Na,k),Ae(c,kr,N),yt(u,t.domain,o),Ae(u,Na,k),Ae(u,kr,N),yt(_,t.domain,O),Ae(_,wa,O),Ae(_,Ld,O),yt(X,t.domain,O),yt(X,e,O),Ae(X,wa,O);const G=[[Rd,Pd],[gf,xf],[yf,bf],[vf,Nf],[wf,jf],[kf,Sf],[Cf,Ef],[Tf,Mf]];for(let z=0;z<G.length;z++){const[ne,ue]=G[z],K=Ae(O,ne);Ae(U,ne,K),Ae(K,ue,O);const $=jr(Ch);yt(K,e,$);const D=jr();yt(K,n),yt($,e,$),yt($,n,D),yt(D,e,$),yt(D,n,D),Ae($,ue,O),Ae(D,ue,O)}return Ae(a,Yd,E),Ae(a,ly,U7),{start:a,tokens:CC}}function K7(t,e,n){let s=n.length,a=0,i=[],o=[];for(;a<s;){let c=t,u=null,h=null,f=0,m=null,g=-1;for(;a<s&&!(u=c.go(n[a].t));)o.push(n[a++]);for(;a<s&&(h=u||c.go(n[a].t));)u=null,c=h,c.accepts()?(g=0,m=c):g>=0&&g++,a++,f++;if(g<0)a-=f,a<s&&(o.push(n[a]),a++);else{o.length>0&&(i.push(Hg(XN,e,o)),o=[]),a-=g,f-=g;const y=m.t,v=n.slice(a-f,a);i.push(Hg(y,e,v))}}return o.length>0&&i.push(Hg(XN,e,o)),i}function Hg(t,e,n){const s=n[0].s,a=n[n.length-1].e,i=e.slice(s,a);return new t(i,n)}const q7=typeof console<"u"&&console&&console.warn||(()=>{}),G7="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",on={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function J7(){return qs.groups={},on.scanner=null,on.parser=null,on.tokenQueue=[],on.pluginQueue=[],on.customSchemes=[],on.initialized=!1,on}function ZN(t,e=!1){if(on.initialized&&q7(`linkifyjs: already initialized - will not register custom scheme "${t}" ${G7}`),!/^[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`);on.customSchemes.push([t,e])}function Y7(){on.scanner=V7(on.customSchemes);for(let t=0;t<on.tokenQueue.length;t++)on.tokenQueue[t][1]({scanner:on.scanner});on.parser=W7(on.scanner.tokens);for(let t=0;t<on.pluginQueue.length;t++)on.pluginQueue[t][1]({scanner:on.scanner,parser:on.parser});return on.initialized=!0,on}function py(t){return on.initialized||Y7(),K7(on.parser.start,t,EC(on.scanner.start,t))}py.scan=EC;function MC(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const s=new fy(n),a=py(t),i=[];for(let o=0;o<a.length;o++){const c=a[o];c.isLink&&(!e||c.t===e)&&s.check(c)&&i.push(c.toFormattedObject(s))}return i}var my="[\0-   -\u2029 ]",Q7=new RegExp(my),X7=new RegExp(`${my}$`),Z7=new RegExp(my,"g");function ez(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function tz(t){return new nn({key:new un("autolink"),appendTransaction:(e,n,s)=>{const a=e.some(h=>h.docChanged)&&!n.doc.eq(s.doc),i=e.some(h=>h.getMeta("preventAutolink"));if(!a||i)return;const{tr:o}=s,c=F2(n.doc,[...e]);if(G2(c).forEach(({newRange:h})=>{const f=e6(s.doc,h,y=>y.isTextblock);let m,g;if(f.length>1)m=f[0],g=s.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(f.length){const y=s.doc.textBetween(h.from,h.to," "," ");if(!X7.test(y))return;m=f[0],g=s.doc.textBetween(m.pos,h.to,void 0," ")}if(m&&g){const y=g.split(Q7).filter(Boolean);if(y.length<=0)return!1;const v=y[y.length-1],w=m.pos+g.lastIndexOf(v);if(!v)return!1;const N=py(v).map(k=>k.toObject(t.defaultProtocol));if(!ez(N))return!1;N.filter(k=>k.isLink).map(k=>({...k,from:w+k.start+1,to:w+k.end+1})).filter(k=>s.schema.marks.code?!s.doc.rangeHasMark(k.from,k.to,s.schema.marks.code):!0).filter(k=>t.validate(k.value)).filter(k=>t.shouldAutoLink(k.value)).forEach(k=>{ty(k.from,k.to,s.doc).some(E=>E.mark.type===t.type)||o.addMark(k.from,k.to,t.type.create({href:k.href}))})}}),!!o.steps.length)return o}})}function nz(t){return new nn({key:new un("handleClickLink"),props:{handleClick:(e,n,s)=>{var a,i;if(s.button!==0||!e.editable)return!1;let o=null;if(s.target instanceof HTMLAnchorElement)o=s.target;else{const u=s.target;if(!u)return!1;const h=t.editor.view.dom;o=u.closest("a"),o&&!h.contains(o)&&(o=null)}if(!o)return!1;let c=!1;if(t.enableClickSelection&&(c=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const u=q2(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 sz(t){return new nn({key:new un("handlePasteLink"),props:{handlePaste:(e,n,s)=>{const{shouldAutoLink:a}=t,{state:i}=e,{selection:o}=i,{empty:c}=o;if(c)return!1;let u="";s.content.forEach(f=>{u+=f.textContent});const h=MC(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 Uo(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(s=>{const a=typeof s=="string"?s:s.scheme;a&&n.push(a)}),!t||t.replace(Z7,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var rz=Nl.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"){ZN(t);return}ZN(t.scheme,t.optionalSlashes)})},onDestroy(){J7()},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)=>!!Uo(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=>!!Uo(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=>!!Uo(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",zt(this.options.HTMLAttributes,t),0]:["a",zt(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,s,a,i;const o=(s=(n=t.attrs)==null?void 0:n.href)!=null?s:"",c=(i=(a=t.attrs)==null?void 0:a.title)!=null?i:"",u=e.renderChildren(t);return c?`[${u}](${o} "${c}")`:`[${u}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:s=>!!Uo(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:s=>!!Uo(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[pl({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:s}=this.options,a=MC(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!Uo(o,n),protocols:n,defaultProtocol:s}));a.length&&a.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(tz({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:s=>this.options.isAllowedUri(s,{defaultValidate:a=>!!Uo(a,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(nz({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(sz({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),az=Object.defineProperty,iz=(t,e)=>{for(var n in e)az(t,n,{get:e[n],enumerable:!0})},oz="listItem",ew="textStyle",tw=/^\s*([-+*])\s$/,AC=Ln.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",zt(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(oz,this.editor.getAttributes(ew)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=kc({find:tw,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=kc({find:tw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ew),editor:this.editor})),[t]}}),IC=Ln.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",zt(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)=>ay(t,e,s=>{var a,i;return s.parentType==="bulletList"?"- ":s.parentType==="orderedList"?`${(((i=(a=s.meta)==null?void 0:a.parentAttrs)==null?void 0:i.start)||1)+s.index}. `:"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),lz={};iz(lz,{findListItemPos:()=>cu,getNextListDepth:()=>gy,handleBackspace:()=>Wx,handleDelete:()=>Kx,hasListBefore:()=>RC,hasListItemAfter:()=>cz,hasListItemBefore:()=>PC,listItemHasSubList:()=>OC,nextListIsDeeper:()=>LC,nextListIsHigher:()=>DC});var cu=(t,e)=>{const{$from:n}=e.selection,s=Fn(t,e.schema);let a=null,i=n.depth,o=n.pos,c=null;for(;i>0&&c===null;)a=n.node(i),a.type===s?c=i:(i-=1,o-=1);return c===null?null:{$pos:e.doc.resolve(o),depth:c}},gy=(t,e)=>{const n=cu(t,e);if(!n)return!1;const[,s]=d6(e,t,n.$pos.pos+4);return s},RC=(t,e,n)=>{const{$anchor:s}=t.selection,a=Math.max(0,s.pos-2),i=t.doc.resolve(a).node();return!(!i||!n.includes(i.type.name))},PC=(t,e)=>{var n;const{$anchor:s}=e.selection,a=e.doc.resolve(s.pos-2);return!(a.index()===0||((n=a.nodeBefore)==null?void 0:n.type.name)!==t)},OC=(t,e,n)=>{if(!n)return!1;const s=Fn(t,e.schema);let a=!1;return n.descendants(i=>{i.type===s&&(a=!0)}),a},Wx=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!co(t.state,e)&&RC(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(!co(t.state,e)||!p6(t.state))return!1;const s=cu(e,t.state);if(!s)return!1;const i=t.state.doc.resolve(s.$pos.pos-2).node(s.depth),o=OC(e,t.state,i);return PC(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},LC=(t,e)=>{const n=gy(t,e),s=cu(t,e);return!s||!n?!1:n>s.depth},DC=(t,e)=>{const n=gy(t,e),s=cu(t,e);return!s||!n?!1:n<s.depth},Kx=(t,e)=>{if(!co(t.state,e)||!f6(t.state,e))return!1;const{selection:n}=t.state,{$from:s,$to:a}=n;return!n.empty&&s.sameParent(a)?!1:LC(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():DC(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},cz=(t,e)=>{var n;const{$anchor:s}=e.selection,a=e.doc.resolve(s.pos-s.parentOffset-2);return!(a.index()===a.parent.childCount-1||((n=a.nodeAfter)==null?void 0:n.type.name)!==t)},_C=Tn.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&&Kx(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&&Kx(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:s})=>{t.state.schema.nodes[n]!==void 0&&Wx(t,n,s)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:s})=>{t.state.schema.nodes[n]!==void 0&&Wx(t,n,s)&&(e=!0)}),e}}}}),nw=/^(\s*)(\d+)\.\s+(.*)$/,dz=/^\s/;function uz(t){const e=[];let n=0,s=0;for(;n<t.length;){const a=t[n],i=a.match(nw);if(!i)break;const[,o,c,u]=i,h=o.length;let f=u,m=n+1;const g=[a];for(;m<t.length;){const y=t[m];if(y.match(nw))break;if(y.trim()==="")g.push(y),f+=`
`,m+=1;else if(y.match(dz))g.push(y),f+=`
${y.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content:f.trim(),raw:g.join(`
`)}),s=m,n=m}return[e,s]}function zC(t,e,n){var s;const a=[];let i=0;for(;i<t.length;){const o=t[i];if(o.indent===e){const c=o.content.split(`
`),u=((s=c[0])==null?void 0:s.trim())||"",h=[];u&&h.push({type:"paragraph",raw:u,tokens:n.inlineTokens(u)});const f=c.slice(1).join(`
`).trim();if(f){const y=n.blockTokens(f);h.push(...y)}let m=i+1;const g=[];for(;m<t.length&&t[m].indent>e;)g.push(t[m]),m+=1;if(g.length>0){const y=Math.min(...g.map(w=>w.indent)),v=zC(g,y,n);h.push({type:"list",ordered:!0,start:g[0].number,items:v,raw:g.map(w=>w.raw).join(`
`)})}a.push({type:"list_item",raw:o.raw,tokens:h}),i=m}else i+=1}return a}function hz(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const s=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(a=>{if(a.type==="paragraph"||a.type==="list"||a.type==="blockquote"||a.type==="code")s.push(...e.parseChildren([a]));else if(a.type==="text"&&a.tokens){const i=e.parseChildren([a]);s.push({type:"paragraph",content:i})}else{const i=e.parseChildren([a]);i.length>0&&s.push(...i)}}),{type:"listItem",content:s}})}var fz="listItem",sw="textStyle",rw=/^(\d+)\.\s$/,$C=Ln.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",zt(this.options.HTMLAttributes,n),0]:["ol",zt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,s=t.items?hz(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:s}:{type:"orderedList",content:s}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e==null?void 0:e.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var s;const a=t.split(`
`),[i,o]=uz(a);if(i.length===0)return;const c=zC(i,0,n);return c.length===0?void 0:{type:"list",ordered:!0,start:((s=i[0])==null?void 0:s.number)||1,items:c,raw:a.slice(0,o).join(`
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(fz,this.editor.getAttributes(sw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=kc({find:rw,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=kc({find:rw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(sw)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),pz=/^\s*(\[([( |x])?\])\s$/,mz=Ln.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",zt(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const s=e.parseChildren(t.nestedTokens);n.push(...s)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const a=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return ay(t,e,a)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:s})=>{const a=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),c=document.createElement("input"),u=document.createElement("div"),h=m=>{var g,y;c.ariaLabel=((y=(g=this.options.a11y)==null?void 0:g.checkboxLabel)==null?void 0:y.call(g,m,c.checked))||`Task item checkbox for ${m.textContent||"empty task item"}`};h(t),i.contentEditable="false",c.type="checkbox",c.addEventListener("mousedown",m=>m.preventDefault()),c.addEventListener("change",m=>{if(!s.isEditable&&!this.options.onReadOnlyChecked){c.checked=!c.checked;return}const{checked:g}=m.target;s.isEditable&&typeof n=="function"&&s.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:y})=>{const v=n();if(typeof v!="number")return!1;const w=y.doc.nodeAt(v);return y.setNodeMarkup(v,void 0,{...w==null?void 0:w.attrs,checked:g}),!0}).run(),!s.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,g)||(c.checked=!c.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([m,g])=>{a.setAttribute(m,g)}),a.dataset.checked=t.attrs.checked,c.checked=t.attrs.checked,i.append(c,o),a.append(i,u),Object.entries(e).forEach(([m,g])=>{a.setAttribute(m,g)});let f=new Set(Object.keys(e));return{dom:a,contentDOM:u,update:m=>{if(m.type!==this.type)return!1;a.dataset.checked=m.attrs.checked,c.checked=m.attrs.checked,h(m);const g=s.extensionManager.attributes,y=Jd(m,g),v=new Set(Object.keys(y)),w=this.options.HTMLAttributes;return f.forEach(N=>{v.has(N)||(N in w?a.setAttribute(N,w[N]):a.removeAttribute(N))}),Object.entries(y).forEach(([N,k])=>{k==null?N in w?a.setAttribute(N,w[N]):a.removeAttribute(N):a.setAttribute(N,k)}),f=v,!0}}}},addInputRules(){return[kc({find:pz,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),gz=Ln.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",zt(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const s=i=>{const o=Lx(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:c=>({indentLevel:c[1].length,mainContent:c[4],checked:c[3].toLowerCase()==="x"}),createToken:(c,u)=>({type:"taskItem",raw:"",mainContent:c.mainContent,indentLevel:c.indentLevel,checked:c.checked,text:c.mainContent,tokens:n.inlineTokens(c.mainContent),nestedTokens:u}),customNestedParser:s},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(i)},a=Lx(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:s},n);if(a)return{type:"taskList",raw:a.raw,items:a.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Tn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(AC.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(IC.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(_C.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push($C.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(mz.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(gz.configure(this.options.taskList)),t}});var aw="&nbsp;",xz=" ",yz=Ln.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",zt(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const s=e.parseInline(n);return s.length===1&&s[0].type==="text"&&(s[0].text===aw||s[0].text===xz)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,s)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?aw:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),bz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,vz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Nz=Nl.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",zt(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[jc({find:bz,type:this.type})]},addPasteRules(){return[pl({find:vz,type:this.type})]}}),wz=Ln.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),jz=Nl.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",zt(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 kz(t={}){return new nn({view(e){return new Sz(e,t)}})}class Sz{constructor(e,n){var s;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(s=n.width)!==null&&s!==void 0?s:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(a=>{let i=o=>{this[a](o)};return e.dom.addEventListener(a,i),{name:a,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,s,a=this.editorView.dom,i=a.getBoundingClientRect(),o=i.width/a.offsetWidth,c=i.height/a.offsetHeight;if(n){let m=e.nodeBefore,g=e.nodeAfter;if(m||g){let y=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(y){let v=y.getBoundingClientRect(),w=m?v.bottom:v.top;m&&g&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let N=this.width/2*c;s={left:v.left,right:v.right,top:w-N,bottom:w+N}}}}if(!s){let m=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*o;s={left:m.left-g,right:m.left+g,top:m.top,bottom:m.bottom}}let u=this.editorView.dom.offsetParent;this.element||(this.element=u.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let h,f;if(!u||u==document.body&&getComputedStyle(u).position=="static")h=-pageXOffset,f=-pageYOffset;else{let m=u.getBoundingClientRect(),g=m.width/u.offsetWidth,y=m.height/u.offsetHeight;h=m.left-u.scrollLeft*g,f=m.top-u.scrollTop*y}this.element.style.left=(s.left-h)/o+"px",this.element.style.top=(s.top-f)/c+"px",this.element.style.width=(s.right-s.left)/o+"px",this.element.style.height=(s.bottom-s.top)/c+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),s=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),a=s&&s.type.spec.disableDropCursor,i=typeof a=="function"?a(this.editorView,n,e):a;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=RS(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 Sn extends lt{constructor(e){super(e,e)}map(e,n){let s=e.resolve(n.map(this.head));return Sn.valid(s)?new Sn(s):lt.near(s)}content(){return ze.empty}eq(e){return e instanceof Sn&&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 Sn(e.resolve(n.pos))}getBookmark(){return new xy(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Cz(e)||!Ez(e))return!1;let s=n.type.spec.allowGapCursor;if(s!=null)return s;let a=n.contentMatchAt(e.index()).defaultType;return a&&a.isTextblock}static findGapCursorFrom(e,n,s=!1){e:for(;;){if(!s&&Sn.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)<c.childCount:e.index(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(Sn.valid(u))return u}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!et.isSelectable(i)){e=e.doc.resolve(a+i.nodeSize*n),s=!1;continue e}break}i=o,a+=n;let c=e.doc.resolve(a);if(Sn.valid(c))return c}return null}}}Sn.prototype.visible=!1;Sn.findFrom=Sn.findGapCursorFrom;lt.jsonID("gapcursor",Sn);class xy{constructor(e){this.pos=e}map(e){return new xy(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Sn.valid(n)?new Sn(n):lt.near(n)}}function FC(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Cz(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),s=t.node(e);if(n==0){if(s.type.spec.isolating)return!0;continue}for(let a=s.child(n-1);;a=a.lastChild){if(a.childCount==0&&!a.inlineContent||FC(a.type))return!0;if(a.inlineContent)return!1}}return!0}function Ez(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),s=t.node(e);if(n==s.childCount){if(s.type.spec.isolating)return!0;continue}for(let a=s.child(n);;a=a.firstChild){if(a.childCount==0&&!a.inlineContent||FC(a.type))return!0;if(a.inlineContent)return!1}}return!0}function Tz(){return new nn({props:{decorations:Rz,createSelectionBetween(t,e,n){return e.pos==n.pos&&Sn.valid(n)?new Sn(n):null},handleClick:Az,handleKeyDown:Mz,handleDOMEvents:{beforeinput:Iz}}})}const Mz=J0({ArrowLeft:Eh("horiz",-1),ArrowRight:Eh("horiz",1),ArrowUp:Eh("vert",-1),ArrowDown:Eh("vert",1)});function Eh(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(s,a,i){let o=s.selection,c=e>0?o.$to:o.$from,u=o.empty;if(o instanceof nt){if(!i.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=s.doc.resolve(e>0?c.after():c.before())}let h=Sn.findGapCursorFrom(c,e,u);return h?(a&&a(s.tr.setSelection(new Sn(h))),!0):!1}}function Az(t,e,n){if(!t||!t.editable)return!1;let s=t.state.doc.resolve(e);if(!Sn.valid(s))return!1;let a=t.posAtCoords({left:n.clientX,top:n.clientY});return a&&a.inside>-1&&et.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Sn(s))),!0)}function Iz(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Sn))return!1;let{$from:n}=t.state.selection,s=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!s)return!1;let a=we.empty;for(let o=s.length-1;o>=0;o--)a=we.from(s[o].createAndFill(null,a));let i=t.state.tr.replace(n.pos,n.pos,new ze(a,0,0));return i.setSelection(nt.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function Rz(t){if(!(t.selection instanceof Sn))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Yt.create(t.doc,[Un.widget(t.selection.head,e,{key:"gapcursor"})])}var Hf=200,es=function(){};es.prototype.append=function(e){return e.length?(e=es.from(e),!this.length&&e||e.length<Hf&&this.leafAppend(e)||this.length<Hf&&e.leafPrepend(this)||this.appendInner(e)):this};es.prototype.prepend=function(e){return e.length?es.from(e).append(this):this};es.prototype.appendInner=function(e){return new Pz(this,e)};es.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=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,s){n===void 0&&(n=0),s===void 0&&(s=this.length),n<=s?this.forEachInner(e,n,s,0):this.forEachInvertedInner(e,n,s,0)};es.prototype.map=function(e,n,s){n===void 0&&(n=0),s===void 0&&(s=this.length);var a=[];return this.forEach(function(i,o){return a.push(e(i,o))},n,s),a};es.from=function(e){return e instanceof es?e:e&&e.length?new BC(e):es.empty};var BC=(function(t){function e(s){t.call(this),this.values=s}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(a,i){return a==0&&i==this.length?this:new e(this.values.slice(a,i))},e.prototype.getInner=function(a){return this.values[a]},e.prototype.forEachInner=function(a,i,o,c){for(var u=i;u<o;u++)if(a(this.values[u],c+u)===!1)return!1},e.prototype.forEachInvertedInner=function(a,i,o,c){for(var u=i-1;u>=o;u--)if(a(this.values[u],c+u)===!1)return!1},e.prototype.leafAppend=function(a){if(this.length+a.length<=Hf)return new e(this.values.concat(a.flatten()))},e.prototype.leafPrepend=function(a){if(this.length+a.length<=Hf)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 BC([]);var Pz=(function(t){function e(n,s){t.call(this),this.left=n,this.right=s,this.length=n.length+s.length,this.depth=Math.max(n.depth,s.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(s){return s<this.left.length?this.left.get(s):this.right.get(s-this.left.length)},e.prototype.forEachInner=function(s,a,i,o){var c=this.left.length;if(a<c&&this.left.forEachInner(s,a,Math.min(i,c),o)===!1||i>c&&this.right.forEachInner(s,Math.max(a-c,0),Math.min(this.length,i)-c,o+c)===!1)return!1},e.prototype.forEachInvertedInner=function(s,a,i,o){var c=this.left.length;if(a>c&&this.right.forEachInvertedInner(s,a-c,Math.max(i,c)-c,o+c)===!1||i<c&&this.left.forEachInvertedInner(s,Math.min(a,c),i,o)===!1)return!1},e.prototype.sliceInner=function(s,a){if(s==0&&a==this.length)return this;var i=this.left.length;return a<=i?this.left.slice(s,a):s>=i?this.right.slice(s-i,a-i):this.left.slice(s,i).append(this.right.slice(0,a-i))},e.prototype.leafAppend=function(s){var a=this.right.leafAppend(s);if(a)return new e(this.left,a)},e.prototype.leafPrepend=function(s){var a=this.left.leafPrepend(s);if(a)return new e(a,this.right)},e.prototype.appendInner=function(s){return this.left.depth>=Math.max(this.right.depth,s.depth)+1?new e(this.left,new e(this.right,s)):new e(this,s)},e})(es);const Oz=500;class Gr{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let s=this.items.length;for(;;s--)if(this.items.get(s-1).selection){--s;break}let a,i;n&&(a=this.remapping(s,this.items.length),i=a.maps.length);let o=e.tr,c,u,h=[],f=[];return this.items.forEach((m,g)=>{if(!m.step){a||(a=this.remapping(s,g+1),i=a.maps.length),i--,f.push(m);return}if(a){f.push(new $i(m.map));let y=m.step.map(a.slice(i)),v;y&&o.maybeStep(y).doc&&(v=o.mapping.maps[o.mapping.maps.length-1],h.push(new $i(v,void 0,void 0,h.length+f.length))),i--,v&&a.appendMap(v,i)}else o.maybeStep(m.step);if(m.selection)return c=a?m.selection.map(a.slice(i)):m.selection,u=new Gr(this.items.slice(0,s).append(f.reverse().concat(h)),this.eventCount-1),!1},this.items.length,0),{remaining:u,transform:o,selection:c}}addTransform(e,n,s,a){let i=[],o=this.eventCount,c=this.items,u=!a&&c.length?c.get(c.length-1):null;for(let f=0;f<e.steps.length;f++){let m=e.steps[f].invert(e.docs[f]),g=new $i(e.mapping.maps[f],m,n),y;(y=u&&u.merge(g))&&(g=y,f?i.pop():c=c.slice(0,c.length-1)),i.push(g),n&&(o++,n=void 0),a||(u=g)}let h=o-s.depth;return h>Dz&&(c=Lz(c,h),o-=h),new Gr(c.append(i),o)}remapping(e,n){let s=new Hd;return this.items.forEach((a,i)=>{let o=a.mirrorOffset!=null&&i-a.mirrorOffset>=e?s.maps.length-a.mirrorOffset:void 0;s.appendMap(a.map,o)},e,n),s}addMaps(e){return this.eventCount==0?this:new Gr(this.items.append(e.map(n=>new $i(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let s=[],a=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,c=this.eventCount;this.items.forEach(g=>{g.selection&&c--},a);let u=n;this.items.forEach(g=>{let y=i.getMirror(--u);if(y==null)return;o=Math.min(o,y);let v=i.maps[y];if(g.step){let w=e.steps[y].invert(e.docs[y]),N=g.selection&&g.selection.map(i.slice(u+1,y));N&&c++,s.push(new $i(v,w,N))}else s.push(new $i(v))},a);let h=[];for(let g=n;g<o;g++)h.push(new $i(i.maps[g]));let f=this.items.slice(0,a).append(h).append(s),m=new Gr(f,c);return m.emptyItemCount()>Oz&&(m=m.compress(this.items.length-s.length)),m}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),s=n.maps.length,a=[],i=0;return this.items.forEach((o,c)=>{if(c>=e)a.push(o),o.selection&&i++;else if(o.step){let u=o.step.map(n.slice(s)),h=u&&u.getMap();if(s--,h&&n.appendMap(h,s),u){let f=o.selection&&o.selection.map(n.slice(s));f&&i++;let m=new $i(h.invert(),u,f),g,y=a.length-1;(g=a.length&&a[y].merge(m))?a[y]=g:a.push(m)}}else o.map&&s--},this.items.length,0),new Gr(es.from(a.reverse()),i)}}Gr.empty=new Gr(es.empty,0);function Lz(t,e){let n;return t.forEach((s,a)=>{if(s.selection&&e--==0)return n=a,!1}),t.slice(n)}let $i=class VC{constructor(e,n,s,a){this.map=e,this.step=n,this.selection=s,this.mirrorOffset=a}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new VC(n.getMap().invert(),n,this.selection)}}};class Ui{constructor(e,n,s,a,i){this.done=e,this.undone=n,this.prevRanges=s,this.prevTime=a,this.prevComposition=i}}const Dz=20;function _z(t,e,n,s){let a=n.getMeta(il),i;if(a)return a.historyState;n.getMeta(Fz)&&(t=new Ui(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(il))return o.getMeta(il).redo?new Ui(t.done.addTransform(n,void 0,s,$h(e)),t.undone,iw(n.mapping.maps),t.prevTime,t.prevComposition):new Ui(t.done,t.undone.addTransform(n,void 0,s,$h(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let c=n.getMeta("composition"),u=t.prevTime==0||!o&&t.prevComposition!=c&&(t.prevTime<(n.time||0)-s.newGroupDelay||!zz(n,t.prevRanges)),h=o?Ug(t.prevRanges,n.mapping):iw(n.mapping.maps);return new Ui(t.done.addTransform(n,u?e.selection.getBookmark():void 0,s,$h(e)),Gr.empty,h,n.time,c??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ui(t.done.rebased(n,i),t.undone.rebased(n,i),Ug(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ui(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Ug(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function zz(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((s,a)=>{for(let i=0;i<e.length;i+=2)s<=e[i+1]&&a>=e[i]&&(n=!0)}),n}function iw(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((s,a,i,o)=>e.push(i,o));return e}function Ug(t,e){if(!t)return null;let n=[];for(let s=0;s<t.length;s+=2){let a=e.map(t[s],1),i=e.map(t[s+1],-1);a<=i&&n.push(a,i)}return n}function $z(t,e,n){let s=$h(e),a=il.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,s);if(!i)return null;let o=i.selection.resolve(i.transform.doc),c=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),a,s),u=new Ui(n?c:i.remaining,n?i.remaining:c,null,0,-1);return i.transform.setSelection(o).setMeta(il,{redo:n,historyState:u})}let Wg=!1,ow=null;function $h(t){let e=t.plugins;if(ow!=e){Wg=!1,ow=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Wg=!0;break}}return Wg}const il=new un("history"),Fz=new un("closeHistory");function Bz(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new nn({key:il,state:{init(){return new Ui(Gr.empty,Gr.empty,null,0,-1)},apply(e,n,s){return _z(n,s,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let s=n.inputType,a=s=="historyUndo"?UC:s=="historyRedo"?WC:null;return!a||!e.editable?!1:(n.preventDefault(),a(e.state,e.dispatch))}}}})}function HC(t,e){return(n,s)=>{let a=il.getState(n);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(s){let i=$z(a,n,t);i&&s(e?i.scrollIntoView():i)}return!0}}const UC=HC(!1,!0),WC=HC(!0,!0);Tn.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const s=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(s)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new nn({key:new un("characterCount"),appendTransaction:(e,n,s)=>{if(t)return;const a=this.options.limit;if(a==null||a===0){t=!0;return}const i=this.storage.characters({node:s.doc});if(i>a){const o=i-a,c=0,u=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${a} characters. Content was automatically trimmed.`);const h=s.tr.deleteRange(c,u);return t=!0,h}t=!0},filterTransaction:(e,n)=>{const s=this.options.limit;if(!e.docChanged||s===0||s===null||s===void 0)return!0;const a=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=s||a>s&&i>s&&i<=a)return!0;if(a>s&&i>s&&i>a||!e.getMeta("paste"))return!1;const c=e.selection.$head.pos,u=i-s,h=c-u,f=c;return e.deleteRange(h,f),!(this.storage.characters({node:e.doc})>s)}})]}});var Vz=Tn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[kz(this.options)]}});Tn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new nn({key:new un("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:s}=this.editor,{anchor:a}=e,i=[];if(!n||!s)return Yt.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(Un.node(h,h+u.nodeSize,{class:this.options.className}))}),Yt.create(t,i)}}})]}});var Hz=Tn.create({name:"gapCursor",addProseMirrorPlugins(){return[Tz()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Dt(Xe(t,"allowGapCursor",n)))!=null?e:null}}}),lw="placeholder";function Uz(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var Wz=Tn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:lw,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${Uz(this.options.dataAttribute)}`:`data-${lw}`;return[new nn({key:new un("placeholder"),props:{decorations:({doc:e,selection:n})=>{const s=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:a}=n,i=[];if(!s)return null;const o=this.editor.isEmpty;return e.descendants((c,u)=>{const h=a>=u&&a<=u+c.nodeSize,f=!c.isLeaf&&gp(c);if((h||!this.options.showOnlyCurrent)&&f){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const g=Un.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}),Yt.create(e,i)}}})]}});Tn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new nn({key:new un("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||J2(n.selection)||t.view.dragging?null:Yt.create(n.doc,[Un.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function cw({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var Kz=Tn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new un(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",s=Object.entries(this.editor.schema.nodes).map(([,a])=>a).filter(a=>(this.options.notAfter||[]).concat(n).includes(a.name));return[new nn({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!cw({node:o,types:s})},apply:(a,i)=>{if(!a.docChanged||a.getMeta("__uniqueIDTransaction"))return i;const o=a.doc.lastChild;return!cw({node:o,types:s})}}})]}}),qz=Tn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>UC(t,e),redo:()=>({state:t,dispatch:e})=>WC(t,e)}},addProseMirrorPlugins(){return[Bz(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()}}}),Gz=Tn.create({name:"starterKit",addExtensions(){var t,e,n,s;const a=[];return this.options.bold!==!1&&a.push(y7.configure(this.options.bold)),this.options.blockquote!==!1&&a.push(f7.configure(this.options.blockquote)),this.options.bulletList!==!1&&a.push(AC.configure(this.options.bulletList)),this.options.code!==!1&&a.push(N7.configure(this.options.code)),this.options.codeBlock!==!1&&a.push(k7.configure(this.options.codeBlock)),this.options.document!==!1&&a.push(S7.configure(this.options.document)),this.options.dropcursor!==!1&&a.push(Vz.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&a.push(Hz.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&a.push(C7.configure(this.options.hardBreak)),this.options.heading!==!1&&a.push(E7.configure(this.options.heading)),this.options.undoRedo!==!1&&a.push(qz.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&a.push(T7.configure(this.options.horizontalRule)),this.options.italic!==!1&&a.push(P7.configure(this.options.italic)),this.options.listItem!==!1&&a.push(IC.configure(this.options.listItem)),this.options.listKeymap!==!1&&a.push(_C.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&a.push(rz.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&a.push($C.configure(this.options.orderedList)),this.options.paragraph!==!1&&a.push(yz.configure(this.options.paragraph)),this.options.strike!==!1&&a.push(Nz.configure(this.options.strike)),this.options.text!==!1&&a.push(wz.configure(this.options.text)),this.options.underline!==!1&&a.push(jz.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&a.push(Kz.configure((s=this.options)==null?void 0:s.trailingNode)),a}}),Jz=Gz,Yz=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Qz=Ln.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",zt(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,s,a,i,o;const c=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",u=(a=(s=t.attrs)==null?void 0:s.alt)!=null?a:"",h=(o=(i=t.attrs)==null?void 0:i.title)!=null?o:"";return h?`![${u}](${c} "${h}")`:`![${u}](${c})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:s}=this.options.resize;return({node:a,getPos:i,HTMLAttributes:o,editor:c})=>{const u=document.createElement("img");Object.entries(o).forEach(([m,g])=>{if(g!=null)switch(m){case"width":case"height":break;default:u.setAttribute(m,g);break}}),u.src=o.src;const h=new e_({element:u,editor:c,node:a,getPos:i,onResize:(m,g)=>{u.style.width=`${m}px`,u.style.height=`${g}px`},onCommit:(m,g)=>{const y=i();y!==void 0&&this.editor.chain().setNodeSelection(y).updateAttributes(this.name,{width:m,height:g}).run()},onUpdate:(m,g,y)=>m.type===a.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:s===!0}}),f=h.dom;return f.style.visibility="hidden",f.style.pointerEvents="none",u.onload=()=>{f.style.visibility="",f.style.pointerEvents=""},h}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[hC({find:Yz,type:this.type,getAttributes:t=>{const[,,e,n,s]=t;return{src:n,alt:e,title:s}}})]}}),Xz=Qz;function Zz(t){var e;const{char:n,allowSpaces:s,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:c}=t,u=s&&!a,h=n_(n),f=new RegExp(`\\s${h}$`),m=o?"^":"",g=a?"":h,y=u?new RegExp(`${m}${h}.*?(?=\\s${g}|$)`,"gm"):new RegExp(`${m}(?:^)?${h}[^\\s${g}]*`,"gm"),v=((e=c.nodeBefore)==null?void 0:e.isText)&&c.nodeBefore.text;if(!v)return null;const w=c.pos-v.length,N=Array.from(v.matchAll(y)).pop();if(!N||N.input===void 0||N.index===void 0)return null;const k=N.input.slice(Math.max(0,N.index-1),N.index),E=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(k);if(i!==null&&!E)return null;const C=w+N.index;let P=C+N[0].length;return u&&f.test(v.slice(P-1,P+1))&&(N[0]+=" ",P+=1),C<c.pos&&P>=c.pos?{range:{from:C,to:P},query:N[0].slice(n.length),text:N[0]}:null}var e$=new un("suggestion");function t$({pluginKey:t=e$,editor:e,char:n="@",allowSpaces:s=!1,allowToIncludeChar:a=!1,allowedPrefixes:i=[" "],startOfLine:o=!1,decorationTag:c="span",decorationClass:u="suggestion",decorationContent:h="",decorationEmptyClass:f="is-empty",command:m=()=>null,items:g=()=>[],render:y=()=>({}),allow:v=()=>!0,findSuggestionMatch:w=Zz,shouldShow:N}){let k;const E=y==null?void 0:y(),C=()=>{const _=e.state.selection.$anchor.pos,V=e.view.coordsAtPos(_),{top:A,right:X,bottom:G,left:z}=V;try{return new DOMRect(z,A,X-z,G-A)}catch{return null}},P=(_,V)=>V?()=>{const A=t.getState(e.state),X=A==null?void 0:A.decorationId,G=_.dom.querySelector(`[data-decoration-id="${X}"]`);return(G==null?void 0:G.getBoundingClientRect())||null}:C;function O(_,V){var A;try{const G=t.getState(_.state),z=G!=null&&G.decorationId?_.dom.querySelector(`[data-decoration-id="${G.decorationId}"]`):null,ne={editor:e,range:(G==null?void 0:G.range)||{from:0,to:0},query:(G==null?void 0:G.query)||null,text:(G==null?void 0:G.text)||null,items:[],command:ue=>m({editor:e,range:(G==null?void 0:G.range)||{from:0,to:0},props:ue}),decorationNode:z,clientRect:P(_,z)};(A=E==null?void 0:E.onExit)==null||A.call(E,ne)}catch{}const X=_.state.tr.setMeta(V,{exit:!0});_.dispatch(X)}const U=new nn({key:t,view(){return{update:async(_,V)=>{var A,X,G,z,ne,ue,K;const $=(A=this.key)==null?void 0:A.getState(V),D=(X=this.key)==null?void 0:X.getState(_.state),I=$.active&&D.active&&$.range.from!==D.range.from,ie=!$.active&&D.active,q=$.active&&!D.active,L=!ie&&!q&&$.query!==D.query,F=ie||I&&L,re=L||I,ge=q||I&&L;if(!F&&!re&&!ge)return;const Te=ge&&!F?$:D,se=_.dom.querySelector(`[data-decoration-id="${Te.decorationId}"]`);k={editor:e,range:Te.range,query:Te.query,text:Te.text,items:[],command:le=>m({editor:e,range:Te.range,props:le}),decorationNode:se,clientRect:P(_,se)},F&&((G=E==null?void 0:E.onBeforeStart)==null||G.call(E,k)),re&&((z=E==null?void 0:E.onBeforeUpdate)==null||z.call(E,k)),(re||F)&&(k.items=await g({editor:e,query:Te.query})),ge&&((ne=E==null?void 0:E.onExit)==null||ne.call(E,k)),re&&((ue=E==null?void 0:E.onUpdate)==null||ue.call(E,k)),F&&((K=E==null?void 0:E.onStart)==null||K.call(E,k))},destroy:()=>{var _;k&&((_=E==null?void 0:E.onExit)==null||_.call(E,k))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(_,V,A,X){const{isEditable:G}=e,{composing:z}=e.view,{selection:ne}=_,{empty:ue,from:K}=ne,$={...V},D=_.getMeta(t);if(D&&D.exit)return $.active=!1,$.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null,$;if($.composing=z,G&&(ue||e.view.composing)){(K<V.range.from||K>V.range.to)&&!z&&!V.composing&&($.active=!1);const I=w({char:n,allowSpaces:s,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:ne.$from}),ie=`id_${Math.floor(Math.random()*4294967295)}`;I&&v({editor:e,state:X,range:I.range,isActive:V.active})&&(!N||N({editor:e,range:I.range,query:I.query,text:I.text,transaction:_}))?($.active=!0,$.decorationId=V.decorationId?V.decorationId:ie,$.range=I.range,$.query=I.query,$.text=I.text):$.active=!1}else $.active=!1;return $.active||($.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null),$}},props:{handleKeyDown(_,V){var A,X,G,z;const{active:ne,range:ue}=U.getState(_.state);if(!ne)return!1;if(V.key==="Escape"||V.key==="Esc"){const $=U.getState(_.state),D=(A=k==null?void 0:k.decorationNode)!=null?A:null,I=D??($!=null&&$.decorationId?_.dom.querySelector(`[data-decoration-id="${$.decorationId}"]`):null);if(((X=E==null?void 0:E.onKeyDown)==null?void 0:X.call(E,{view:_,event:V,range:$.range}))||!1)return!0;const q={editor:e,range:$.range,query:$.query,text:$.text,items:[],command:L=>m({editor:e,range:$.range,props:L}),decorationNode:I,clientRect:I?()=>I.getBoundingClientRect()||null:null};return(G=E==null?void 0:E.onExit)==null||G.call(E,q),O(_,t),!0}return((z=E==null?void 0:E.onKeyDown)==null?void 0:z.call(E,{view:_,event:V,range:ue}))||!1},decorations(_){const{active:V,range:A,decorationId:X,query:G}=U.getState(_);if(!V)return null;const z=!(G!=null&&G.length),ne=[u];return z&&ne.push(f),Yt.create(_.doc,[Un.inline(A.from,A.to,{nodeName:c,class:ne.join(" "),"data-decoration-id":X,"data-decoration-content":h})])}}});return U}function n$({editor:t,overrideSuggestionOptions:e,extensionName:n,char:s="@"}){const a=new un;return{editor:t,char:s,pluginKey:a,command:({editor:i,range:o,props:c})=>{var u,h,f;const m=i.view.state.selection.$to.nodeAfter;((u=m==null?void 0:m.text)==null?void 0:u.startsWith(" "))&&(o.to+=1),i.chain().focus().insertContentAt(o,[{type:n,attrs:{...c,mentionSuggestionChar:s}},{type:"text",text:" "}]).run(),(f=(h=i.view.dom.ownerDocument.defaultView)==null?void 0:h.getSelection())==null||f.collapseToEnd()},allow:({state:i,range:o})=>{const c=i.doc.resolve(o.from),u=i.schema.nodes[n];return!!c.parent.type.contentMatch.matchType(u)},...e}}function KC(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>n$({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function dw(t,e){const n=KC(t),s=n.find(a=>a.char===e);return s||(n.length?n[0]:null)}var s$=Ln.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:t,suggestion:e}){var n,s;return`${(n=e==null?void 0:e.char)!=null?n:"@"}${(s=t.attrs.label)!=null?s:t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e,suggestion:n}){var s,a;return["span",zt(this.HTMLAttributes,t.HTMLAttributes),`${(s=n==null?void 0:n.char)!=null?s:"@"}${(a=e.attrs.label)!=null?a:e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-label":t.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:t=>t.getAttribute("data-mention-suggestion-char"),renderHTML:t=>({"data-mention-suggestion-char":t.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){const n=dw(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",zt({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const s={...this.options};s.HTMLAttributes=zt({"data-type":this.name},this.options.HTMLAttributes,e);const a=this.options.renderHTML({options:s,node:t,suggestion:n});return typeof a=="string"?["span",zt({"data-type":this.name},this.options.HTMLAttributes,e),a]:a},...fC({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:t=>{const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let s=n.exec(t);for(;s!==null;){const[,a,i,o]=s,c=i??o;e[a==="char"?"mentionSuggestionChar":a]=c,s=n.exec(t)}return e},serializeAttributes:t=>Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e==="mentionSuggestionChar"?"char":e}="${n}"`).join(" ")}),renderText({node:t}){const e={options:this.options,node:t,suggestion:dw(this,t.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(e)):this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1;const{selection:s}=e,{empty:a,anchor:i}=s;if(!a)return!1;let o=new oi,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 KC(this).map(t$)}}),r$=s$,a$=Wz;let qx,Gx;if(typeof WeakMap<"u"){let t=new WeakMap;qx=e=>t.get(e),Gx=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;qx=s=>{for(let a=0;a<t.length;a+=2)if(t[a]==s)return t[a+1]},Gx=(s,a)=>(n==10&&(n=0),t[n++]=s,t[n++]=a)}var Cn=class{constructor(t,e,n,s){this.width=t,this.height=e,this.map=n,this.problems=s}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const s=e%this.width,a=e/this.width|0;let i=s+1,o=a+1;for(let c=1;i<this.width&&this.map[e+c]==n;c++)i++;for(let c=1;o<this.height&&this.map[e+this.width*c]==n;c++)o++;return{left:s,top:a,right:i,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:s,right:a,top:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?s==0:a==this.width)?null:this.map[i*this.width+(n<0?s-1:a)]:(n<0?i==0:o==this.height)?null:this.map[s+this.width*(n<0?i-1:o)]}rectBetween(t,e){const{left:n,right:s,top:a,bottom:i}=this.findCell(t),{left:o,right:c,top:u,bottom:h}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(a,u),right:Math.max(s,c),bottom:Math.max(i,h)}}cellsInRect(t){const e=[],n={};for(let s=t.top;s<t.bottom;s++)for(let a=t.left;a<t.right;a++){const i=s*this.width+a,o=this.map[i];n[o]||(n[o]=!0,!(a==t.left&&a&&this.map[i-1]==o||s==t.top&&s&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let s=0,a=0;;s++){const i=a+n.child(s).nodeSize;if(s==t){let o=e+t*this.width;const c=(t+1)*this.width;for(;o<c&&this.map[o]<a;)o++;return o==c?i-1:this.map[o]}a=i}}static get(t){return qx(t)||Gx(t,i$(t))}};function i$(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=o$(t),n=t.childCount,s=[];let a=0,i=null;const o=[];for(let h=0,f=e*n;h<f;h++)s[h]=0;for(let h=0,f=0;h<n;h++){const m=t.child(h);f++;for(let v=0;;v++){for(;a<s.length&&s[a]!=0;)a++;if(v==m.childCount)break;const w=m.child(v),{colspan:N,rowspan:k,colwidth:E}=w.attrs;for(let C=0;C<k;C++){if(C+h>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:f,n:k-C});break}const P=a+C*e;for(let O=0;O<N;O++){s[P+O]==0?s[P+O]=f:(i||(i=[])).push({type:"collision",row:h,pos:f,n:N-O});const U=E&&E[O];if(U){const _=(P+O)%e*2,V=o[_];V==null||V!=U&&o[_+1]==1?(o[_]=U,o[_+1]=1):V==U&&o[_+1]++}}}a+=N,f+=w.nodeSize}const g=(h+1)*e;let y=0;for(;a<g;)s[a++]==0&&y++;y&&(i||(i=[])).push({type:"missing",row:h,n:y}),f++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const c=new Cn(e,n,s,i);let u=!1;for(let h=0;!u&&h<o.length;h+=2)o[h]!=null&&o[h+1]<n&&(u=!0);return u&&l$(c,o,t),c}function o$(t){let e=-1,n=!1;for(let s=0;s<t.childCount;s++){const a=t.child(s);let i=0;if(n)for(let o=0;o<s;o++){const c=t.child(o);for(let u=0;u<c.childCount;u++){const h=c.child(u);o+h.attrs.rowspan>s&&(i+=h.attrs.colspan)}}for(let o=0;o<a.childCount;o++){const c=a.child(o);i+=c.attrs.colspan,c.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function l$(t,e,n){t.problems||(t.problems=[]);const s={};for(let a=0;a<t.map.length;a++){const i=t.map[a];if(s[i])continue;s[i]=!0;const o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let c=null;const u=o.attrs;for(let h=0;h<u.colspan;h++){const f=e[(a+h)%t.width*2];f!=null&&(!u.colwidth||u.colwidth[h]!=f)&&((c||(c=c$(u)))[h]=f)}c&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:c})}}function c$(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Ts(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const s=t.nodes[n],a=s.spec.tableRole;a&&(e[a]=s)}}return e}const qi=new un("selectingCells");function ml(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function d$(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 vp(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=ml(e.$head)||u$(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function u$(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const s=e.type.spec.tableRole;if(s=="cell"||s=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const s=e.type.spec.tableRole;if(s=="cell"||s=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Jx(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function h$(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function yy(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function qC(t,e,n){const s=t.node(-1),a=Cn.get(s),i=t.start(-1),o=a.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function gl(t,e,n=1){const s={...t,colspan:t.colspan-n};return s.colwidth&&(s.colwidth=s.colwidth.slice(),s.colwidth.splice(e,n),s.colwidth.some(a=>a>0)||(s.colwidth=null)),s}function GC(t,e,n=1){const s={...t,colspan:t.colspan+n};if(s.colwidth){s.colwidth=s.colwidth.slice();for(let a=0;a<n;a++)s.colwidth.splice(e,0,0)}return s}function f$(t,e,n){const s=Ts(e.type.schema).header_cell;for(let a=0;a<t.height;a++)if(e.nodeAt(t.map[n+a*t.width]).type!=s)return!1;return!0}var tn=class ni extends lt{constructor(e,n=e){const s=e.node(-1),a=Cn.get(s),i=e.start(-1),o=a.rectBetween(e.pos-i,n.pos-i),c=e.node(0),u=a.cellsInRect(o).filter(f=>f!=n.pos-i);u.unshift(n.pos-i);const h=u.map(f=>{const m=s.nodeAt(f);if(!m)throw new RangeError(`No cell with offset ${f} found`);const g=i+f+1;return new _S(c.resolve(g),c.resolve(g+m.content.size))});super(h[0].$from,h[0].$to,h),this.$anchorCell=e,this.$headCell=n}map(e,n){const s=e.resolve(n.map(this.$anchorCell.pos)),a=e.resolve(n.map(this.$headCell.pos));if(Jx(s)&&Jx(a)&&yy(s,a)){const i=this.$anchorCell.node(-1)!=s.node(-1);return i&&this.isRowSelection()?ni.rowSelection(s,a):i&&this.isColSelection()?ni.colSelection(s,a):new ni(s,a)}return nt.between(s,a)}content(){const e=this.$anchorCell.node(-1),n=Cn.get(e),s=this.$anchorCell.start(-1),a=n.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s),i={},o=[];for(let u=a.top;u<a.bottom;u++){const h=[];for(let f=u*n.width+a.left,m=a.left;m<a.right;m++,f++){const g=n.map[f];if(i[g])continue;i[g]=!0;const y=n.findCell(g);let v=e.nodeAt(g);if(!v)throw new RangeError(`No cell with offset ${g} found`);const w=a.left-y.left,N=y.right-a.right;if(w>0||N>0){let k=v.attrs;if(w>0&&(k=gl(k,0,w)),N>0&&(k=gl(k,k.colspan-N,N)),y.left<a.left){if(v=v.type.createAndFill(k),!v)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(k)}`)}else v=v.type.create(k,v.content)}if(y.top<a.top||y.bottom>a.bottom){const k={...v.attrs,rowspan:Math.min(y.bottom,a.bottom)-Math.max(y.top,a.top)};y.top<a.top?v=v.type.createAndFill(k):v=v.type.create(k,v.content)}h.push(v)}o.push(e.child(u).copy(we.from(h)))}const c=this.isColSelection()&&this.isRowSelection()?e:o;return new ze(we.from(c),1,1)}replace(e,n=ze.empty){const s=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){const{$from:c,$to:u}=a[o],h=e.mapping.slice(s);e.replace(h.map(c.pos),h.map(u.pos),o?ze.empty:n)}const i=lt.findFrom(e.doc.resolve(e.mapping.slice(s).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new ze(we.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),s=Cn.get(n),a=this.$anchorCell.start(-1),i=s.cellsInRect(s.rectBetween(this.$anchorCell.pos-a,this.$headCell.pos-a));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),a+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const s=e+this.$anchorCell.nodeAfter.attrs.rowspan,a=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(s,a)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const s=e.node(-1),a=Cn.get(s),i=e.start(-1),o=a.findCell(e.pos-i),c=a.findCell(n.pos-i),u=e.node(0);return o.top<=c.top?(o.top>0&&(e=u.resolve(i+a.map[o.left])),c.bottom<a.height&&(n=u.resolve(i+a.map[a.width*(a.height-1)+c.right-1]))):(c.top>0&&(n=u.resolve(i+a.map[c.left])),o.bottom<a.height&&(e=u.resolve(i+a.map[a.width*(a.height-1)+o.right-1]))),new ni(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Cn.get(e),s=this.$anchorCell.start(-1),a=n.colCount(this.$anchorCell.pos-s),i=n.colCount(this.$headCell.pos-s);if(Math.min(a,i)>0)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 ni&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const s=e.node(-1),a=Cn.get(s),i=e.start(-1),o=a.findCell(e.pos-i),c=a.findCell(n.pos-i),u=e.node(0);return o.left<=c.left?(o.left>0&&(e=u.resolve(i+a.map[o.top*a.width])),c.right<a.width&&(n=u.resolve(i+a.map[a.width*(c.top+1)-1]))):(c.left>0&&(n=u.resolve(i+a.map[c.top*a.width])),o.right<a.width&&(e=u.resolve(i+a.map[a.width*(o.top+1)-1]))),new ni(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new ni(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,s=n){return new ni(e.resolve(n),e.resolve(s))}getBookmark(){return new p$(this.$anchorCell.pos,this.$headCell.pos)}};tn.prototype.visible=!1;lt.jsonID("cell",tn);var p$=class JC{constructor(e,n){this.anchor=e,this.head=n}map(e){return new JC(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),s=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&s.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&s.index()<s.parent.childCount&&yy(n,s)?new tn(n,s):lt.near(s,1)}};function m$(t){if(!(t.selection instanceof tn))return null;const e=[];return t.selection.forEachCell((n,s)=>{e.push(Un.node(s,s+n.nodeSize,{class:"selectedCell"}))}),Yt.create(t.doc,e)}function g$({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,s=e.pos,a=t.depth;for(;a>=0&&!(t.after(a+1)<t.end(a));a--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,s--);return n==s&&/row|table/.test(t.node(a).type.spec.tableRole)}function x$({$from:t,$to:e}){let n,s;for(let a=t.depth;a>0;a--){const i=t.node(a);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let a=e.depth;a>0;a--){const i=e.node(a);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){s=i;break}}return n!==s&&e.parentOffset===0}function y$(t,e,n){const s=(e||t).selection,a=(e||t).doc;let i,o;if(s instanceof et&&(o=s.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=tn.create(a,s.from);else if(o=="row"){const c=a.resolve(s.from+1);i=tn.rowSelection(c,c)}else if(!n){const c=Cn.get(s.node),u=s.from+1,h=u+c.map[c.width*c.height-1];i=tn.create(a,u+1,h)}}else s instanceof nt&&g$(s)?i=nt.create(a,s.from):s instanceof nt&&x$(s)&&(i=nt.create(a,s.$from.start(),s.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const b$=new un("fix-tables");function YC(t,e,n,s){const a=t.childCount,i=e.childCount;e:for(let o=0,c=0;o<i;o++){const u=e.child(o);for(let h=c,f=Math.min(a,o+3);h<f;h++)if(t.child(h)==u){c=h+1,n+=u.nodeSize;continue e}s(u,n),c<a&&t.child(c).sameMarkup(u)?YC(t.child(c),u,n+1,s):u.nodesBetween(0,u.content.size,s,n+1),n+=u.nodeSize}}function QC(t,e){let n;const s=(a,i)=>{a.type.spec.tableRole=="table"&&(n=v$(t,a,i,n))};return e?e.doc!=t.doc&&YC(e.doc,t.doc,0,s):t.doc.descendants(s),n}function v$(t,e,n,s){const a=Cn.get(e);if(!a.problems)return s;s||(s=t.tr);const i=[];for(let u=0;u<a.height;u++)i.push(0);for(let u=0;u<a.problems.length;u++){const h=a.problems[u];if(h.type=="collision"){const f=e.nodeAt(h.pos);if(!f)continue;const m=f.attrs;for(let g=0;g<m.rowspan;g++)i[h.row+g]+=h.n;s.setNodeMarkup(s.mapping.map(n+1+h.pos),null,gl(m,m.colspan-h.n,h.n))}else if(h.type=="missing")i[h.row]+=h.n;else if(h.type=="overlong_rowspan"){const f=e.nodeAt(h.pos);if(!f)continue;s.setNodeMarkup(s.mapping.map(n+1+h.pos),null,{...f.attrs,rowspan:f.attrs.rowspan-h.n})}else if(h.type=="colwidth mismatch"){const f=e.nodeAt(h.pos);if(!f)continue;s.setNodeMarkup(s.mapping.map(n+1+h.pos),null,{...f.attrs,colwidth:h.colwidth})}else if(h.type=="zero_sized"){const f=s.mapping.map(n);s.delete(f,f+e.nodeSize)}}let o,c;for(let u=0;u<i.length;u++)i[u]&&(o==null&&(o=u),c=u);for(let u=0,h=n+1;u<a.height;u++){const f=e.child(u),m=h+f.nodeSize,g=i[u];if(g>0){let y="cell";f.firstChild&&(y=f.firstChild.type.spec.tableRole);const v=[];for(let N=0;N<g;N++){const k=Ts(t.schema)[y].createAndFill();k&&v.push(k)}const w=(u==0||o==u-1)&&c==u?h+1:m-1;s.insert(s.mapping.map(w),v)}h=m}return s.setMeta(b$,{fixTables:!0})}function Ia(t){const e=t.selection,n=vp(t),s=n.node(-1),a=n.start(-1),i=Cn.get(s);return{...e instanceof tn?i.rectBetween(e.$anchorCell.pos-a,e.$headCell.pos-a):i.findCell(n.pos-a),tableStart:a,map:i,table:s}}function XC(t,{map:e,tableStart:n,table:s},a){let i=a>0?-1:0;f$(e,s,a+i)&&(i=a==0||a==e.width?null:0);for(let o=0;o<e.height;o++){const c=o*e.width+a;if(a>0&&a<e.width&&e.map[c-1]==e.map[c]){const u=e.map[c],h=s.nodeAt(u);t.setNodeMarkup(t.mapping.map(n+u),null,GC(h.attrs,a-e.colCount(u))),o+=h.attrs.rowspan-1}else{const u=i==null?Ts(s.type.schema).cell:s.nodeAt(e.map[c+i]).type,h=e.positionAt(o,a,s);t.insert(t.mapping.map(n+h),u.createAndFill())}}return t}function N$(t,e){if(!Zr(t))return!1;if(e){const n=Ia(t);e(XC(t.tr,n,n.left))}return!0}function w$(t,e){if(!Zr(t))return!1;if(e){const n=Ia(t);e(XC(t.tr,n,n.right))}return!0}function j$(t,{map:e,table:n,tableStart:s},a){const i=t.mapping.maps.length;for(let o=0;o<e.height;){const c=o*e.width+a,u=e.map[c],h=n.nodeAt(u),f=h.attrs;if(a>0&&e.map[c-1]==u||a<e.width-1&&e.map[c+1]==u)t.setNodeMarkup(t.mapping.slice(i).map(s+u),null,gl(f,a-e.colCount(u)));else{const m=t.mapping.slice(i).map(s+u);t.delete(m,m+h.nodeSize)}o+=f.rowspan}}function k$(t,e){if(!Zr(t))return!1;if(e){const n=Ia(t),s=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let a=n.right-1;j$(s,n,a),a!=n.left;a--){const i=n.tableStart?s.doc.nodeAt(n.tableStart-1):s.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=Cn.get(i)}e(s)}return!0}function S$(t,e,n){var s;const a=Ts(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((s=e.nodeAt(t.map[i+n*t.width]))===null||s===void 0?void 0:s.type)!=a)return!1;return!0}function ZC(t,{map:e,tableStart:n,table:s},a){let i=n;for(let h=0;h<a;h++)i+=s.child(h).nodeSize;const o=[];let c=a>0?-1:0;S$(e,s,a+c)&&(c=a==0||a==e.height?null:0);for(let h=0,f=e.width*a;h<e.width;h++,f++)if(a>0&&a<e.height&&e.map[f]==e.map[f-e.width]){const m=e.map[f],g=s.nodeAt(m).attrs;t.setNodeMarkup(n+m,null,{...g,rowspan:g.rowspan+1}),h+=g.colspan-1}else{var u;const m=c==null?Ts(s.type.schema).cell:(u=s.nodeAt(e.map[f+c*e.width]))===null||u===void 0?void 0:u.type,g=m==null?void 0:m.createAndFill();g&&o.push(g)}return t.insert(i,Ts(s.type.schema).row.create(null,o)),t}function C$(t,e){if(!Zr(t))return!1;if(e){const n=Ia(t);e(ZC(t.tr,n,n.top))}return!0}function E$(t,e){if(!Zr(t))return!1;if(e){const n=Ia(t);e(ZC(t.tr,n,n.bottom))}return!0}function T$(t,{map:e,table:n,tableStart:s},a){let i=0;for(let h=0;h<a;h++)i+=n.child(h).nodeSize;const o=i+n.child(a).nodeSize,c=t.mapping.maps.length;t.delete(i+s,o+s);const u=new Set;for(let h=0,f=a*e.width;h<e.width;h++,f++){const m=e.map[f];if(!u.has(m)){if(u.add(m),a>0&&m==e.map[f-e.width]){const g=n.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(c).map(m+s),null,{...g,rowspan:g.rowspan-1}),h+=g.colspan-1}else if(a<e.height&&m==e.map[f+e.width]){const g=n.nodeAt(m),y=g.attrs,v=g.type.create({...y,rowspan:g.attrs.rowspan-1},g.content),w=e.positionAt(a+1,h,n);t.insert(t.mapping.slice(c).map(s+w),v),h+=y.colspan-1}}}}function M$(t,e){if(!Zr(t))return!1;if(e){const n=Ia(t),s=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let a=n.bottom-1;T$(s,n,a),a!=n.top;a--){const i=n.tableStart?s.doc.nodeAt(n.tableStart-1):s.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=Cn.get(n.table)}e(s)}return!0}function uw(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function A$({width:t,height:e,map:n},s){let a=s.top*t+s.left,i=a,o=(s.bottom-1)*t+s.left,c=a+(s.right-s.left-1);for(let u=s.top;u<s.bottom;u++){if(s.left>0&&n[i]==n[i-1]||s.right<t&&n[c]==n[c+1])return!0;i+=t,c+=t}for(let u=s.left;u<s.right;u++){if(s.top>0&&n[a]==n[a-t]||s.bottom<e&&n[o]==n[o+t])return!0;a++,o++}return!1}function hw(t,e){const n=t.selection;if(!(n instanceof tn)||n.$anchorCell.pos==n.$headCell.pos)return!1;const s=Ia(t),{map:a}=s;if(A$(a,s))return!1;if(e){const i=t.tr,o={};let c=we.empty,u,h;for(let f=s.top;f<s.bottom;f++)for(let m=s.left;m<s.right;m++){const g=a.map[f*a.width+m],y=s.table.nodeAt(g);if(!(o[g]||!y))if(o[g]=!0,u==null)u=g,h=y;else{uw(y)||(c=c.append(y.content));const v=i.mapping.map(g+s.tableStart);i.delete(v,v+y.nodeSize)}}if(u==null||h==null)return!0;if(i.setNodeMarkup(u+s.tableStart,null,{...GC(h.attrs,h.attrs.colspan,s.right-s.left-h.attrs.colspan),rowspan:s.bottom-s.top}),c.size>0){const f=u+1+h.content.size,m=uw(h)?u+1:f;i.replaceWith(m+s.tableStart,f+s.tableStart,c)}i.setSelection(new tn(i.doc.resolve(u+s.tableStart))),e(i)}return!0}function fw(t,e){const n=Ts(t.schema);return I$(({node:s})=>n[s.type.spec.tableRole])(t,e)}function I$(t){return(e,n)=>{const s=e.selection;let a,i;if(s instanceof tn){if(s.$anchorCell.pos!=s.$headCell.pos)return!1;a=s.$anchorCell.nodeAfter,i=s.$anchorCell.pos}else{var o;if(a=d$(s.$from),!a)return!1;i=(o=ml(s.$from))===null||o===void 0?void 0:o.pos}if(a==null||i==null||a.attrs.colspan==1&&a.attrs.rowspan==1)return!1;if(n){let c=a.attrs;const u=[],h=c.colwidth;c.rowspan>1&&(c={...c,rowspan:1}),c.colspan>1&&(c={...c,colspan:1});const f=Ia(e),m=e.tr;for(let y=0;y<f.right-f.left;y++)u.push(h?{...c,colwidth:h&&h[y]?[h[y]]:null}:c);let g;for(let y=f.top;y<f.bottom;y++){let v=f.map.positionAt(y,f.left,f.table);y==f.top&&(v+=a.nodeSize);for(let w=f.left,N=0;w<f.right;w++,N++)w==f.left&&y==f.top||m.insert(g=m.mapping.map(v+f.tableStart,1),t({node:a,row:y,col:w}).createAndFill(u[N]))}m.setNodeMarkup(i,t({node:a,row:f.top,col:f.left}),u[0]),s instanceof tn&&m.setSelection(new tn(m.doc.resolve(s.$anchorCell.pos),g?m.doc.resolve(g):void 0)),n(m)}return!0}}function R$(t,e){return function(n,s){if(!Zr(n))return!1;const a=vp(n);if(a.nodeAfter.attrs[t]===e)return!1;if(s){const i=n.tr;n.selection instanceof tn?n.selection.forEachCell((o,c)=>{o.attrs[t]!==e&&i.setNodeMarkup(c,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(a.pos,null,{...a.nodeAfter.attrs,[t]:e}),s(i)}return!0}}function P$(t){return function(e,n){if(!Zr(e))return!1;if(n){const s=Ts(e.schema),a=Ia(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<o.length;u++)c[u].type==s.header_cell&&i.setNodeMarkup(a.tableStart+o[u],s.cell,c[u].attrs);if(i.steps.length===0)for(let u=0;u<o.length;u++)i.setNodeMarkup(a.tableStart+o[u],s.header_cell,c[u].attrs);n(i)}return!0}}function pw(t,e,n){const s=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let a=0;a<s.length;a++){const i=e.table.nodeAt(s[a]);if(i&&i.type!==n.header_cell)return!1}return!0}function Xd(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?P$(t):function(n,s){if(!Zr(n))return!1;if(s){const a=Ts(n.schema),i=Ia(n),o=n.tr,c=pw("row",i,a),u=pw("column",i,a),h=(t==="column"?c:t==="row"&&u)?1:0,f=t=="column"?{left:0,top:h,right:1,bottom:i.map.height}:t=="row"?{left:h,top:0,right:i.map.width,bottom:1}:i,m=t=="column"?u?a.cell:a.header_cell:t=="row"?c?a.cell:a.header_cell:a.cell;i.map.cellsInRect(f).forEach(g=>{const y=g+i.tableStart,v=o.doc.nodeAt(y);v&&o.setNodeMarkup(y,m,v.attrs)}),s(o)}return!0}}Xd("row",{useDeprecatedLogic:!0});Xd("column",{useDeprecatedLogic:!0});const O$=Xd("cell",{useDeprecatedLogic:!0});function L$(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let s=t.index(-1)-1,a=t.before();s>=0;s--){const i=t.node(-1).child(s),o=i.lastChild;if(o)return a-1-o.nodeSize;a-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let s=t.indexAfter(-1),a=t.after();s<n.childCount;s++){const i=n.child(s);if(i.childCount)return a+1;a+=i.nodeSize}}return null}function mw(t){return function(e,n){if(!Zr(e))return!1;const s=L$(vp(e),t);if(s==null)return!1;if(n){const a=e.doc.resolve(s);n(e.tr.setSelection(nt.between(a,h$(a))).scrollIntoView())}return!0}}function D$(t,e){const n=t.selection.$anchor;for(let s=n.depth;s>0;s--)if(n.node(s).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(s),n.after(s)).scrollIntoView()),!0;return!1}function Th(t,e){const n=t.selection;if(!(n instanceof tn))return!1;if(e){const s=t.tr,a=Ts(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(a)||s.replace(s.mapping.map(o+1),s.mapping.map(o+i.nodeSize-1),new ze(a,0,0))}),s.docChanged&&e(s)}return!0}function _$(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:s}=t;for(;e.childCount==1&&(n>0&&s>0||e.child(0).type.spec.tableRole=="table");)n--,s--,e=e.child(0).content;const a=e.child(0),i=a.type.spec.tableRole,o=a.type.schema,c=[];if(i=="row")for(let u=0;u<e.childCount;u++){let h=e.child(u).content;const f=u?0:Math.max(0,n-1),m=u<e.childCount-1?0:Math.max(0,s-1);(f||m)&&(h=Yx(Ts(o).row,new ze(h,f,m)).content),c.push(h)}else if(i=="cell"||i=="header_cell")c.push(n||s?Yx(Ts(o).row,new ze(e,n,s)).content:e);else return null;return z$(o,c)}function z$(t,e){const n=[];for(let a=0;a<e.length;a++){const i=e[a];for(let o=i.childCount-1;o>=0;o--){const{rowspan:c,colspan:u}=i.child(o).attrs;for(let h=a;h<a+c;h++)n[h]=(n[h]||0)+u}}let s=0;for(let a=0;a<n.length;a++)s=Math.max(s,n[a]);for(let a=0;a<n.length;a++)if(a>=e.length&&e.push(we.empty),n[a]<s){const i=Ts(t).cell.createAndFill(),o=[];for(let c=n[a];c<s;c++)o.push(i);e[a]=e[a].append(we.from(o))}return{height:e.length,width:s,rows:e}}function Yx(t,e){const n=t.createAndFill();return new P0(n).replace(0,n.content.size,e).doc}function $$({width:t,height:e,rows:n},s,a){if(t!=s){const i=[],o=[];for(let c=0;c<n.length;c++){const u=n[c],h=[];for(let f=i[c]||0,m=0;f<s;m++){let g=u.child(m%u.childCount);f+g.attrs.colspan>s&&(g=g.type.createChecked(gl(g.attrs,g.attrs.colspan,f+g.attrs.colspan-s),g.content)),h.push(g),f+=g.attrs.colspan;for(let y=1;y<g.attrs.rowspan;y++)i[c+y]=(i[c+y]||0)+g.attrs.colspan}o.push(we.from(h))}n=o,t=s}if(e!=a){const i=[];for(let o=0,c=0;o<a;o++,c++){const u=[],h=n[c%e];for(let f=0;f<h.childCount;f++){let m=h.child(f);o+m.attrs.rowspan>a&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,a-m.attrs.rowspan)},m.content)),u.push(m)}i.push(we.from(u))}n=i,e=a}return{width:t,height:e,rows:n}}function F$(t,e,n,s,a,i,o){const c=t.doc.type.schema,u=Ts(c);let h,f;if(a>e.width)for(let m=0,g=0;m<e.height;m++){const y=n.child(m);g+=y.nodeSize;const v=[];let w;y.lastChild==null||y.lastChild.type==u.cell?w=h||(h=u.cell.createAndFill()):w=f||(f=u.header_cell.createAndFill());for(let N=e.width;N<a;N++)v.push(w);t.insert(t.mapping.slice(o).map(g-1+s),v)}if(i>e.height){const m=[];for(let v=0,w=(e.height-1)*e.width;v<Math.max(e.width,a);v++){const N=v>=e.width?!1:n.nodeAt(e.map[w+v]).type==u.header_cell;m.push(N?f||(f=u.header_cell.createAndFill()):h||(h=u.cell.createAndFill()))}const g=u.row.create(null,we.from(m)),y=[];for(let v=e.height;v<i;v++)y.push(g);t.insert(t.mapping.slice(o).map(s+n.nodeSize-2),y)}return!!(h||f)}function gw(t,e,n,s,a,i,o,c){if(o==0||o==e.height)return!1;let u=!1;for(let h=a;h<i;h++){const f=o*e.width+h,m=e.map[f];if(e.map[f-e.width]==m){u=!0;const g=n.nodeAt(m),{top:y,left:v}=e.findCell(m);t.setNodeMarkup(t.mapping.slice(c).map(m+s),null,{...g.attrs,rowspan:o-y}),t.insert(t.mapping.slice(c).map(e.positionAt(o,v,n)),g.type.createAndFill({...g.attrs,rowspan:y+g.attrs.rowspan-o})),h+=g.attrs.colspan-1}}return u}function xw(t,e,n,s,a,i,o,c){if(o==0||o==e.width)return!1;let u=!1;for(let h=a;h<i;h++){const f=h*e.width+o,m=e.map[f];if(e.map[f-1]==m){u=!0;const g=n.nodeAt(m),y=e.colCount(m),v=t.mapping.slice(c).map(m+s);t.setNodeMarkup(v,null,gl(g.attrs,o-y,g.attrs.colspan-(o-y))),t.insert(v+g.nodeSize,g.type.createAndFill(gl(g.attrs,0,o-y))),h+=g.attrs.rowspan-1}}return u}function yw(t,e,n,s,a){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let o=Cn.get(i);const{top:c,left:u}=s,h=u+a.width,f=c+a.height,m=t.tr;let g=0;function y(){if(i=n?m.doc.nodeAt(n-1):m.doc,!i)throw new Error("No table found");o=Cn.get(i),g=m.mapping.maps.length}F$(m,o,i,n,h,f,g)&&y(),gw(m,o,i,n,u,h,c,g)&&y(),gw(m,o,i,n,u,h,f,g)&&y(),xw(m,o,i,n,c,f,u,g)&&y(),xw(m,o,i,n,c,f,h,g)&&y();for(let v=c;v<f;v++){const w=o.positionAt(v,u,i),N=o.positionAt(v,h,i);m.replace(m.mapping.slice(g).map(w+n),m.mapping.slice(g).map(N+n),new ze(a.rows[v-c],0,0))}y(),m.setSelection(new tn(m.doc.resolve(n+o.positionAt(c,u,i)),m.doc.resolve(n+o.positionAt(f-1,h-1,i)))),e(m)}const B$=J0({ArrowLeft:Mh("horiz",-1),ArrowRight:Mh("horiz",1),ArrowUp:Mh("vert",-1),ArrowDown:Mh("vert",1),"Shift-ArrowLeft":Ah("horiz",-1),"Shift-ArrowRight":Ah("horiz",1),"Shift-ArrowUp":Ah("vert",-1),"Shift-ArrowDown":Ah("vert",1),Backspace:Th,"Mod-Backspace":Th,Delete:Th,"Mod-Delete":Th});function Fh(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Mh(t,e){return(n,s,a)=>{if(!a)return!1;const i=n.selection;if(i instanceof tn)return Fh(n,s,lt.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=e3(a,t,e);if(o==null)return!1;if(t=="horiz")return Fh(n,s,lt.near(n.doc.resolve(i.head+e),e));{const c=n.doc.resolve(o),u=qC(c,t,e);let h;return u?h=lt.near(u,1):e<0?h=lt.near(n.doc.resolve(c.before(-1)),-1):h=lt.near(n.doc.resolve(c.after(-1)),1),Fh(n,s,h)}}}function Ah(t,e){return(n,s,a)=>{if(!a)return!1;const i=n.selection;let o;if(i instanceof tn)o=i;else{const u=e3(a,t,e);if(u==null)return!1;o=new tn(n.doc.resolve(u))}const c=qC(o.$headCell,t,e);return c?Fh(n,s,new tn(o.$anchorCell,c)):!1}}function V$(t,e){const n=t.state.doc,s=ml(n.resolve(e));return s?(t.dispatch(t.state.tr.setSelection(new tn(s))),!0):!1}function H$(t,e,n){if(!Zr(t.state))return!1;let s=_$(n);const a=t.state.selection;if(a instanceof tn){s||(s={width:1,height:1,rows:[we.from(Yx(Ts(t.state.schema).cell,n))]});const i=a.$anchorCell.node(-1),o=a.$anchorCell.start(-1),c=Cn.get(i).rectBetween(a.$anchorCell.pos-o,a.$headCell.pos-o);return s=$$(s,c.right-c.left,c.bottom-c.top),yw(t.state,t.dispatch,o,c,s),!0}else if(s){const i=vp(t.state),o=i.start(-1);return yw(t.state,t.dispatch,o,Cn.get(i.node(-1)).findCell(i.pos-o),s),!0}else return!1}function U$(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const s=bw(t,e.target);let a;if(e.shiftKey&&t.state.selection instanceof tn)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&s&&(a=ml(t.state.selection.$anchor))!=null&&((n=Kg(t,e))===null||n===void 0?void 0:n.pos)!=a.pos)i(a,e),e.preventDefault();else if(!s)return;function i(u,h){let f=Kg(t,h);const m=qi.getState(t.state)==null;if(!f||!yy(u,f))if(m)f=u;else return;const g=new tn(u,f);if(m||!t.state.selection.eq(g)){const y=t.state.tr.setSelection(g);m&&y.setMeta(qi,u.pos),t.dispatch(y)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",c),qi.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(qi,-1))}function c(u){const h=u,f=qi.getState(t.state);let m;if(f!=null)m=t.state.doc.resolve(f);else if(bw(t,h.target)!=s&&(m=Kg(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 e3(t,e,n){if(!(t.state.selection instanceof nt))return null;const{$head:s}=t.state.selection;for(let a=s.depth-1;a>=0;a--){const i=s.node(a);if((n<0?s.index(a):s.indexAfter(a))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=s.before(a),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?o:null}}return null}function bw(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Kg(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:s,pos:a}=n;return s>=0&&ml(t.state.doc.resolve(s))||ml(t.state.doc.resolve(a))}var W$=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")),Qx(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,Qx(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Qx(t,e,n,s,a,i){let o=0,c=!0,u=e.firstChild;const h=t.firstChild;if(h){for(let m=0,g=0;m<h.childCount;m++){const{colspan:y,colwidth:v}=h.child(m).attrs;for(let w=0;w<y;w++,g++){const N=a==g?i:v&&v[w],k=N?N+"px":"";if(o+=N||s,N||(c=!1),u)u.style.width!=k&&(u.style.width=k),u=u.nextSibling;else{const E=document.createElement("col");E.style.width=k,e.appendChild(E)}}}for(;u;){var f;const m=u.nextSibling;(f=u.parentNode)===null||f===void 0||f.removeChild(u),u=m}c?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}const ur=new un("tableColumnResizing");function K$({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:s=W$,lastColumnResizable:a=!0}={}){const i=new nn({key:ur,state:{init(o,c){var u;const h=(u=i.spec)===null||u===void 0||(u=u.props)===null||u===void 0?void 0:u.nodeViews,f=Ts(c.schema).table.name;return s&&h&&(h[f]=(m,g)=>new s(m,n,g)),new q$(-1,!1)},apply(o,c){return c.apply(o)}},props:{attributes:o=>{const c=ur.getState(o);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,c)=>{G$(o,c,t,a)},mouseleave:o=>{J$(o)},mousedown:(o,c)=>{Y$(o,c,e,n)}},decorations:o=>{const c=ur.getState(o);if(c&&c.activeHandle>-1)return tF(o,c.activeHandle)},nodeViews:{}}});return i}var q$=class Bh{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,s=e.getMeta(ur);if(s&&s.setHandle!=null)return new Bh(s.setHandle,!1);if(s&&s.setDragging!==void 0)return new Bh(n.activeHandle,s.setDragging);if(n.activeHandle>-1&&e.docChanged){let a=e.mapping.map(n.activeHandle,-1);return Jx(e.doc.resolve(a))||(a=-1),new Bh(a,n.dragging)}return n}};function G$(t,e,n,s){if(!t.editable)return;const a=ur.getState(t.state);if(a&&!a.dragging){const i=X$(e.target);let o=-1;if(i){const{left:c,right:u}=i.getBoundingClientRect();e.clientX-c<=n?o=vw(t,e,"left",n):u-e.clientX<=n&&(o=vw(t,e,"right",n))}if(o!=a.activeHandle){if(!s&&o!==-1){const c=t.state.doc.resolve(o),u=c.node(-1),h=Cn.get(u),f=c.start(-1);if(h.colCount(c.pos-f)+c.nodeAfter.attrs.colspan-1==h.width-1)return}t3(t,o)}}}function J$(t){if(!t.editable)return;const e=ur.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&t3(t,-1)}function Y$(t,e,n,s){var a;if(!t.editable)return!1;const i=(a=t.dom.ownerDocument.defaultView)!==null&&a!==void 0?a:window,o=ur.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const c=t.state.doc.nodeAt(o.activeHandle),u=Q$(t,o.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(ur,{setDragging:{startX:e.clientX,startWidth:u}}));function h(m){i.removeEventListener("mouseup",h),i.removeEventListener("mousemove",f);const g=ur.getState(t.state);g!=null&&g.dragging&&(Z$(t,g.activeHandle,Nw(g.dragging,m,n)),t.dispatch(t.state.tr.setMeta(ur,{setDragging:null})))}function f(m){if(!m.which)return h(m);const g=ur.getState(t.state);if(g&&g.dragging){const y=Nw(g.dragging,m,n);ww(t,g.activeHandle,y,s)}}return ww(t,o.activeHandle,u,s),i.addEventListener("mouseup",h),i.addEventListener("mousemove",f),e.preventDefault(),!0}function Q$(t,e,{colspan:n,colwidth:s}){const a=s&&s[s.length-1];if(a)return a;const i=t.domAtPos(e);let o=i.node.childNodes[i.offset].offsetWidth,c=n;if(s)for(let u=0;u<n;u++)s[u]&&(o-=s[u],c--);return o/c}function X$(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function vw(t,e,n,s){const a=n=="right"?-s:s,i=t.posAtCoords({left:e.clientX+a,top:e.clientY});if(!i)return-1;const{pos:o}=i,c=ml(t.state.doc.resolve(o));if(!c)return-1;if(n=="right")return c.pos;const u=Cn.get(c.node(-1)),h=c.start(-1),f=u.map.indexOf(c.pos-h);return f%u.width==0?-1:h+u.map[f-1]}function Nw(t,e,n){const s=e.clientX-t.startX;return Math.max(n,t.startWidth+s)}function t3(t,e){t.dispatch(t.state.tr.setMeta(ur,{setHandle:e}))}function Z$(t,e,n){const s=t.state.doc.resolve(e),a=s.node(-1),i=Cn.get(a),o=s.start(-1),c=i.colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1,u=t.state.tr;for(let h=0;h<i.height;h++){const f=h*i.width+c;if(h&&i.map[f]==i.map[f-i.width])continue;const m=i.map[f],g=a.nodeAt(m).attrs,y=g.colspan==1?0:c-i.colCount(m);if(g.colwidth&&g.colwidth[y]==n)continue;const v=g.colwidth?g.colwidth.slice():eF(g.colspan);v[y]=n,u.setNodeMarkup(o+m,null,{...g,colwidth:v})}u.docChanged&&t.dispatch(u)}function ww(t,e,n,s){const a=t.state.doc.resolve(e),i=a.node(-1),o=a.start(-1),c=Cn.get(i).colCount(a.pos-o)+a.nodeAfter.attrs.colspan-1;let u=t.domAtPos(a.start(-1)).node;for(;u&&u.nodeName!="TABLE";)u=u.parentNode;u&&Qx(i,u.firstChild,u,s,c,n)}function eF(t){return Array(t).fill(0)}function tF(t,e){const n=[],s=t.doc.resolve(e),a=s.node(-1);if(!a)return Yt.empty;const i=Cn.get(a),o=s.start(-1),c=i.colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;for(let h=0;h<i.height;h++){const f=c+h*i.width;if((c==i.width-1||i.map[f]!=i.map[f+1])&&(h==0||i.map[f]!=i.map[f-i.width])){var u;const m=i.map[f],g=o+m+a.nodeAt(m).nodeSize-1,y=document.createElement("div");y.className="column-resize-handle",!((u=ur.getState(t))===null||u===void 0)&&u.dragging&&n.push(Un.node(o+m,o+m+a.nodeAt(m).nodeSize,{class:"column-resize-dragging"})),n.push(Un.widget(g,y))}}return Yt.create(t.doc,n)}function nF({allowTableNodeSelection:t=!1}={}){return new nn({key:qi,state:{init(){return null},apply(e,n){const s=e.getMeta(qi);if(s!=null)return s==-1?null:s;if(n==null||!e.docChanged)return n;const{deleted:a,pos:i}=e.mapping.mapResult(n);return a?null:i}},props:{decorations:m$,handleDOMEvents:{mousedown:U$},createSelectionBetween(e){return qi.getState(e.state)!=null?e.state.selection:null},handleTripleClick:V$,handleKeyDown:B$,handlePaste:H$},appendTransaction(e,n,s){return y$(s,QC(s,n),t)}})}var n3=Ln.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const s=t.getAttribute("colwidth"),a=s?s.split(",").map(i=>parseInt(i,10)):null;if(!a){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&i&&i[o]){const c=i[o].getAttribute("width");return c?[parseInt(c,10)]:null}}return a}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",zt(this.options.HTMLAttributes,t),0]}}),s3=Ln.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(s=>parseInt(s,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",zt(this.options.HTMLAttributes,t),0]}}),r3=Ln.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",zt(this.options.HTMLAttributes,t),0]}});function Xx(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function jw(t,e,n,s,a,i){var o;let c=0,u=!0,h=e.firstChild;const f=t.firstChild;if(f!==null)for(let g=0,y=0;g<f.childCount;g+=1){const{colspan:v,colwidth:w}=f.child(g).attrs;for(let N=0;N<v;N+=1,y+=1){const k=a===y?i:w&&w[N],E=k?`${k}px`:"";if(c+=k||s,k||(u=!1),h){if(h.style.width!==E){const[C,P]=Xx(s,k);h.style.setProperty(C,P)}h=h.nextSibling}else{const C=document.createElement("col"),[P,O]=Xx(s,k);C.style.setProperty(P,O),e.appendChild(C)}}}for(;h;){const g=h.nextSibling;(o=h.parentNode)==null||o.removeChild(h),h=g}const m=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);u&&!m?(n.style.width=`${c}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${c}px`)}var sF=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),jw(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,jw(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),s=this.contentDOM.contains(e);return!!(n&&!s&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function rF(t,e,n,s){let a=0,i=!0;const o=[],c=t.firstChild;if(!c)return{};for(let m=0,g=0;m<c.childCount;m+=1){const{colspan:y,colwidth:v}=c.child(m).attrs;for(let w=0;w<y;w+=1,g+=1){const N=n===g?s:v&&v[w];a+=N||e,N||(i=!1);const[k,E]=Xx(e,N);o.push(["col",{style:`${k}: ${E}`}])}}const u=i?`${a}px`:"",h=i?"":`${a}px`;return{colgroup:["colgroup",{},...o],tableWidth:u,tableMinWidth:h}}function kw(t,e){return t.createAndFill()}function aF(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const s=t.nodes[n];s.spec.tableRole&&(e[s.spec.tableRole]=s)}),t.cached.tableNodeTypes=e,e}function iF(t,e,n,s,a){const i=aF(t),o=[],c=[];for(let h=0;h<n;h+=1){const f=kw(i.cell);if(f&&c.push(f),s){const m=kw(i.header_cell);m&&o.push(m)}}const u=[];for(let h=0;h<e;h+=1)u.push(i.row.createChecked(null,s&&h===0?o:c));return i.table.createChecked(null,u)}function oF(t){return t instanceof tn}var Ih=({editor:t})=>{const{selection:e}=t.state;if(!oF(e))return!1;let n=0;const s=B2(e.ranges[0].$from,i=>i.type.name==="table");return s==null||s.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},lF="";function cF(t){return(t||"").replace(/\s+/g," ").trim()}function dF(t,e,n={}){var s;const a=(s=n.cellLineSeparator)!=null?s:lF;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(v=>{const w=[];v.content&&v.content.forEach(N=>{let k="";N.content&&Array.isArray(N.content)&&N.content.length>1?k=N.content.map(O=>e.renderChildren(O)).join(a):k=N.content?e.renderChildren(N.content):"";const E=cF(k),C=N.type==="tableHeader";w.push({text:E,isHeader:C})}),i.push(w)});const o=i.reduce((v,w)=>Math.max(v,w.length),0);if(o===0)return"";const c=new Array(o).fill(0);i.forEach(v=>{var w;for(let N=0;N<o;N+=1){const E=(((w=v[N])==null?void 0:w.text)||"").length;E>c[N]&&(c[N]=E),c[N]<3&&(c[N]=3)}});const u=(v,w)=>v+" ".repeat(Math.max(0,w-v.length)),h=i[0],f=h.some(v=>v.isHeader);let m=`
`;const g=new Array(o).fill(0).map((v,w)=>f&&h[w]&&h[w].text||"");return m+=`| ${g.map((v,w)=>u(v,c[w])).join(" | ")} |
`,m+=`| ${c.map(v=>"-".repeat(Math.max(3,v))).join(" | ")} |
`,(f?i.slice(1):i).forEach(v=>{m+=`| ${new Array(o).fill(0).map((w,N)=>u(v[N]&&v[N].text||"",c[N])).join(" | ")} |
`}),m}var uF=dF,a3=Ln.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:sF,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:s,tableMinWidth:a}=rF(t,this.options.cellMinWidth),i=e.style;function o(){return i||(s?`width: ${s}`:`min-width: ${a}`)}const c=["table",zt(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},c]:c},parseMarkdown:(t,e)=>{const n=[];if(t.header){const s=[];t.header.forEach(a=>{s.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(a.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}return t.rows&&t.rows.forEach(s=>{const a=[];s.forEach(i=>{a.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},a))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>uF(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:s,dispatch:a,editor:i})=>{const o=iF(i.schema,t,e,n);if(a){const c=s.selection.from+1;s.replaceSelectionWith(o).scrollIntoView().setSelection(nt.near(s.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>N$(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>w$(t,e),deleteColumn:()=>({state:t,dispatch:e})=>k$(t,e),addRowBefore:()=>({state:t,dispatch:e})=>C$(t,e),addRowAfter:()=>({state:t,dispatch:e})=>E$(t,e),deleteRow:()=>({state:t,dispatch:e})=>M$(t,e),deleteTable:()=>({state:t,dispatch:e})=>D$(t,e),mergeCells:()=>({state:t,dispatch:e})=>hw(t,e),splitCell:()=>({state:t,dispatch:e})=>fw(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Xd("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Xd("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>O$(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>hw(t,e)?!0:fw(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:s})=>R$(t,e)(n,s),goToNextCell:()=>({state:t,dispatch:e})=>mw(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>mw(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&QC(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const s=tn.create(e.doc,t.anchorCell,t.headCell);e.setSelection(s)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Ih,"Mod-Backspace":Ih,Delete:Ih,"Mod-Delete":Ih}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[K$({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],nF({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:Dt(Xe(t,"tableRole",e))}}});Tn.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(a3.configure(this.options.table)),this.options.tableCell!==!1&&t.push(n3.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(s3.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(r3.configure(this.options.tableRow)),t}});function hF(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function fF(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function pF(t){if(!t)return"";let e=t;return e=e.replace(/<h1[^>]*>(.*?)<\/h1>/gi,`# $1
`),e=e.replace(/<h2[^>]*>(.*?)<\/h2>/gi,`## $1
`),e=e.replace(/<h3[^>]*>(.*?)<\/h3>/gi,`### $1
`),e=e.replace(/<strong[^>]*>(.*?)<\/strong>/gi,"**$1**"),e=e.replace(/<b[^>]*>(.*?)<\/b>/gi,"**$1**"),e=e.replace(/<em[^>]*>(.*?)<\/em>/gi,"*$1*"),e=e.replace(/<i[^>]*>(.*?)<\/i>/gi,"*$1*"),e=e.replace(/<s[^>]*>(.*?)<\/s>/gi,"~~$1~~"),e=e.replace(/<del[^>]*>(.*?)<\/del>/gi,"~~$1~~"),e=e.replace(/<code[^>]*>(.*?)<\/code>/gi,"`$1`"),e=e.replace(/<blockquote[^>]*>(.*?)<\/blockquote>/gi,`> $1
`),e=e.replace(/<img[^>]*src="([^"]*)"[^>]*alt="([^"]*)"[^>]*>/gi,"![$2]($1)"),e=e.replace(/<img[^>]*src="([^"]*)"[^>]*>/gi,"![]($1)"),e=e.replace(/<a[^>]*href="([^"]*)"[^>]*>(.*?)<\/a>/gi,"[$2]($1)"),e=e.replace(/<li[^>]*>(.*?)<\/li>/gi,`- $1
`),e=e.replace(/<\/?[uo]l[^>]*>/gi,`
`),e=e.replace(/<br\s*\/?>/gi,`
`),e=e.replace(/<p[^>]*>(.*?)<\/p>/gi,`$1
`),e=e.replace(/<hr\s*\/?>/gi,`---
`),e=e.replace(/<span[^>]*data-type="mention"[^>]*data-id="([^"]*)"[^>]*>@([^<]*)<\/span>/gi,"@$2"),e=e.replace(/<span[^>]*data-type="linkTag"[^>]*data-url="([^"]*)"[^>]*>#([^<]*)<\/span>/gi,"#[$2]($1)"),e=e.replace(/<[^>]+>/g,""),e=e.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),e=e.replace(/\n{3,}/g,`
`),e.trim()}function Sw(t){if(!t)return"";if(t.startsWith("<")&&t.includes("</"))return t;let e=t;e=e.replace(/^### (.+)$/gm,"<h3>$1</h3>"),e=e.replace(/^## (.+)$/gm,"<h2>$1</h2>"),e=e.replace(/^# (.+)$/gm,"<h1>$1</h1>"),e=e.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),e=e.replace(/\*(.+?)\*/g,"<em>$1</em>"),e=e.replace(/~~(.+?)~~/g,"<s>$1</s>"),e=e.replace(/`([^`]+)`/g,"<code>$1</code>"),e=e.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" />'),e=e.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>'),e=e.replace(/^> (.+)$/gm,"<blockquote><p>$1</p></blockquote>"),e=e.replace(/^---$/gm,"<hr />"),e=e.replace(/^- (.+)$/gm,"<li>$1</li>");const n=e.split(`
`),s=[];for(const a of n){const i=a.trim();i&&(/^<(?:h[1-6]|blockquote|hr|li|ul|ol|table|img)/.test(i)?s.push(i):s.push(`<p>${i}</p>`))}return s.join("")}const mF=Ln.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 端全宽播放)"]]}}),gF=Ln.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",zt(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 Cw(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}const xF=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,s=[],a=null;const i=()=>{e&&(e.innerHTML=s.map((o,c)=>`<div class="mention-item ${c===n?"is-selected":""}" data-index="${c}">
<span class="mention-name">@${Cw(o.name)}</span>
<span class="mention-id">${Cw(o.label||o.id)}</span>
</div>`).join(""),e.querySelectorAll(".mention-item").forEach(o=>{o.addEventListener("click",()=>{const c=parseInt(o.getAttribute("data-index")||"0");a&&s[c]&&a({id:s[c].id,label:s[c].name})})}))};return{onStart:o=>{if(e=document.createElement("div"),e.className="mention-popup",document.body.appendChild(e),s=o.items,a=o.command,n=0,i(),o.clientRect){const c=o.clientRect();c&&(e.style.top=`${c.bottom+4}px`,e.style.left=`${c.left}px`)}},onUpdate:o=>{if(s=o.items,a=o.command,n=0,i(),o.clientRect&&e){const c=o.clientRect();c&&(e.style.top=`${c.bottom+4}px`,e.style.left=`${c.left}px`)}},onKeyDown:o=>o.event.key==="ArrowUp"?(n=Math.max(0,n-1),i(),!0):o.event.key==="ArrowDown"?(n=Math.min(s.length-1,n+1),i(),!0):o.event.key==="Enter"?(a&&s[n]&&a({id:s[n].id,label:s[n].name}),!0):o.event.key==="Escape"?(e==null||e.remove(),e=null,!0):!1,onExit:()=>{e==null||e.remove(),e=null}}}});function yF(t){var s;const e=[],n=(s=t.clipboardData)==null?void 0:s.items;if(!n)return e;for(let a=0;a<n.length;a++)if(n[a].type.indexOf("image")!==-1){const i=n[a].getAsFile();i&&e.push(i)}return e}const bF=/src=["'](data:image\/([^;"']+);base64,([A-Za-z0-9+/=]+))["']/gi;function vF(t,e){const n={png:".png",jpeg:".jpg",jpg:".jpg",gif:".gif",webp:".webp"}[e.toLowerCase()]||".png",s=atob(t),a=new Uint8Array(s.length);for(let i=0;i<s.length;i++)a[i]=s.charCodeAt(i);return new File([new Blob([a],{type:`image/${e}`})],`image${n}`,{type:`image/${e}`})}async function NF(t,e){const n=[...t.matchAll(bF)];if(n.length===0)return t;const s=new Map;let a=t;for(const i of n){const o=i[1],c=i[2],u=i[3];let h=s.get(o);if(!h)try{const f=vF(u,c);h=await e(f),s.set(o,h)}catch(f){console.error("base64 图片上传失败",f);continue}a=a.split(`src="${o}"`).join(`src="${h}"`).split(`src='${o}'`).join(`src="${h}"`)}return a}const Zx=b.forwardRef(({content:t,onChange:e,onImageUpload:n,onMediaUpload:s,persons:a=[],linkTags:i=[],placeholder:o="开始编辑内容...",className:c},u)=>{const h=b.useRef(null),f=b.useRef(null),m=b.useRef(null),g=b.useRef(null),[y,v]=b.useState(""),[w,N]=b.useState(!1),k=b.useRef(Sw(t)),E=b.useCallback((G,z)=>{var $;const ne=g.current;if(!ne||!n)return!1;const ue=yF(z);if(ue.length>0)return z.preventDefault(),(async()=>{for(const D of ue)try{const I=await n(D);I&&ne.chain().focus().setImage({src:I}).run()}catch(I){console.error("粘贴图片上传失败",I)}})(),!0;const K=($=z.clipboardData)==null?void 0:$.getData("text/html");if(K&&/data:image\/[^;"']+;base64,/i.test(K)){z.preventDefault();const{from:D,to:I}=ne.state.selection;return(async()=>{try{const ie=await NF(K,n);ne.chain().focus().insertContentAt({from:D,to:I},ie).run()}catch(ie){console.error("粘贴 HTML 内 base64 转换失败",ie)}})(),!0}return!1},[n]),C=l7({extensions:[Jz.configure({link:{openOnClick:!1,HTMLAttributes:{class:"rich-link"}}}),Xz.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"rich-editor-img-thumb"}}),mF,r$.configure({HTMLAttributes:{class:"mention-tag"},suggestion:xF(a)}),gF,a$.configure({placeholder:o}),a3.configure({resizable:!0}),r3,n3,s3],content:k.current,onUpdate:({editor:G})=>{e(G.getHTML())},editorProps:{attributes:{class:"rich-editor-content"},handlePaste:E}});b.useEffect(()=>{g.current=C??null},[C]),b.useImperativeHandle(u,()=>({getHTML:()=>(C==null?void 0:C.getHTML())||"",getMarkdown:()=>pF((C==null?void 0:C.getHTML())||"")})),b.useEffect(()=>{if(C&&t!==C.getHTML()){const G=Sw(t);G!==C.getHTML()&&C.commands.setContent(G)}},[t]);const P=b.useCallback(async G=>{if(s)return s(G);if(n)return n(G);throw new Error("未配置上传")},[n,s]),O=b.useCallback(async G=>{var ne;const z=(ne=G.target.files)==null?void 0:ne[0];if(!(!z||!C)){if(n){const ue=await n(z);ue&&C.chain().focus().setImage({src:ue}).run()}else{const ue=new FileReader;ue.onload=()=>{typeof ue.result=="string"&&C.chain().focus().setImage({src:ue.result}).run()},ue.readAsDataURL(z)}G.target.value=""}},[C,n]),U=b.useCallback(async G=>{var ne;const z=(ne=G.target.files)==null?void 0:ne[0];if(!(!z||!C)){try{const ue=await P(z);ue&&C.chain().focus().insertContent({type:"videoEmbed",attrs:{src:ue}}).run()}catch(ue){console.error(ue)}G.target.value=""}},[C,P]),_=b.useCallback(async G=>{var ne;const z=(ne=G.target.files)==null?void 0:ne[0];if(!(!z||!C)){try{const ue=await P(z);if(!ue)return;const K=z.name||"附件";C.chain().focus().insertContent(`<p class="rich-attachment-line"><span class="rich-attachment-badge">附件</span> <a class="rich-attachment-link" href="${fF(ue)}" target="_blank" rel="noopener noreferrer">${hF(K)}</a></p>`).run()}catch(ue){console.error(ue)}G.target.value=""}},[C,P]),V=b.useCallback(()=>{C&&C.chain().focus().insertContent("@").run()},[C]),A=b.useCallback(G=>{C&&C.chain().focus().insertContent([{type:"linkTag",attrs:{label:G.label,url:G.url||"",tagType:G.type||"url",tagId:G.id||"",pagePath:G.pagePath||"",appId:G.appId||"",mpKey:G.type==="miniprogram"&&G.appId||""}},{type:"text",text:" "}]).run()},[C]),X=b.useCallback(()=>{!C||!y||(C.chain().focus().setLink({href:y}).run(),v(""),N(!1))},[C,y]);return C?r.jsxs("div",{className:`rich-editor-wrapper ${c||""}`,children:[r.jsxs("div",{className:"rich-editor-toolbar",children:[r.jsxs("div",{className:"toolbar-group",children:[r.jsx("button",{onClick:()=>C.chain().focus().toggleBold().run(),className:C.isActive("bold")?"is-active":"",type:"button",children:r.jsx(GT,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>C.chain().focus().toggleItalic().run(),className:C.isActive("italic")?"is-active":"",type:"button",children:r.jsx(G5,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>C.chain().focus().toggleStrike().run(),className:C.isActive("strike")?"is-active":"",type:"button",children:r.jsx(JM,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>C.chain().focus().toggleCode().run(),className:C.isActive("code")?"is-active":"",type:"button",children:r.jsx(p5,{className:"w-4 h-4"})})]}),r.jsx("div",{className:"toolbar-divider"}),r.jsxs("div",{className:"toolbar-group",children:[r.jsx("button",{onClick:()=>C.chain().focus().toggleHeading({level:1}).run(),className:C.isActive("heading",{level:1})?"is-active":"",type:"button",children:r.jsx(z5,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>C.chain().focus().toggleHeading({level:2}).run(),className:C.isActive("heading",{level:2})?"is-active":"",type:"button",children:r.jsx(F5,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>C.chain().focus().toggleHeading({level:3}).run(),className:C.isActive("heading",{level:3})?"is-active":"",type:"button",children:r.jsx(V5,{className:"w-4 h-4"})})]}),r.jsx("div",{className:"toolbar-divider"}),r.jsxs("div",{className:"toolbar-group",children:[r.jsx("button",{onClick:()=>C.chain().focus().toggleBulletList().run(),className:C.isActive("bulletList")?"is-active":"",type:"button",children:r.jsx(sM,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>C.chain().focus().toggleOrderedList().run(),className:C.isActive("orderedList")?"is-active":"",type:"button",children:r.jsx(tM,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>C.chain().focus().toggleBlockquote().run(),className:C.isActive("blockquote")?"is-active":"",type:"button",children:r.jsx(IM,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>C.chain().focus().setHorizontalRule().run(),type:"button",children:r.jsx(pM,{className:"w-4 h-4"})})]}),r.jsx("div",{className:"toolbar-divider"}),r.jsxs("div",{className:"toolbar-group",children:[r.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:O,className:"hidden"}),r.jsx("input",{ref:f,type:"file",accept:"video/*",onChange:U,className:"hidden"}),r.jsx("input",{ref:m,type:"file",onChange:_,className:"hidden"}),r.jsx("button",{onClick:()=>{var G;return(G=h.current)==null?void 0:G.click()},type:"button",title:"上传图片",children:r.jsx(bj,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>{var G;return(G=f.current)==null?void 0:G.click()},type:"button",title:"上传视频",disabled:!s&&!n,children:r.jsx(dA,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>{var G;return(G=m.current)==null?void 0:G.click()},type:"button",title:"上传附件(生成下载链接)",disabled:!s&&!n,children:r.jsx(bM,{className:"w-4 h-4"})}),r.jsx("button",{onClick:V,type:"button",title:"插入 @ 并选择人物",className:a.length?"mention-trigger-btn":"",disabled:a.length===0,children:r.jsx(WT,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>N(!w),className:C.isActive("link")?"is-active":"",type:"button",title:"链接",children:r.jsx(ix,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>C.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),type:"button",title:"表格",children:r.jsx(QM,{className:"w-4 h-4"})})]}),r.jsx("div",{className:"toolbar-divider"}),r.jsxs("div",{className:"toolbar-group",children:[r.jsx("button",{onClick:()=>C.chain().focus().undo().run(),disabled:!C.can().undo(),type:"button",children:r.jsx(rA,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>C.chain().focus().redo().run(),disabled:!C.can().redo(),type:"button",children:r.jsx(PM,{className:"w-4 h-4"})})]}),i.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"toolbar-divider"}),r.jsx("div",{className:"toolbar-group",children:r.jsxs("select",{className:"link-tag-select",onChange:G=>{const z=i.find(ne=>ne.id===G.target.value);z&&A(z),G.target.value=""},defaultValue:"",children:[r.jsx("option",{value:"",disabled:!0,children:"# 插入链接标签"}),i.map(G=>r.jsx("option",{value:G.id,children:G.label},G.id))]})})]})]}),w&&r.jsxs("div",{className:"link-input-bar",children:[r.jsx("input",{type:"url",placeholder:"输入链接地址...",value:y,onChange:G=>v(G.target.value),onKeyDown:G=>G.key==="Enter"&&X(),className:"link-input"}),r.jsx("button",{onClick:X,className:"link-confirm",type:"button",children:"确定"}),r.jsx("button",{onClick:()=>{C.chain().focus().unsetLink().run(),N(!1)},className:"link-remove",type:"button",children:"移除"})]}),r.jsx(gC,{editor:C})]}):null});Zx.displayName="RichEditor";const wF=["top","right","bottom","left"],uo=Math.min,cr=Math.max,Uf=Math.round,Rh=Math.floor,Ca=t=>({x:t,y:t}),jF={left:"right",right:"left",bottom:"top",top:"bottom"},kF={start:"end",end:"start"};function e0(t,e,n){return cr(t,uo(e,n))}function ui(t,e){return typeof t=="function"?t(e):t}function hi(t){return t.split("-")[0]}function Pc(t){return t.split("-")[1]}function by(t){return t==="x"?"y":"x"}function vy(t){return t==="y"?"height":"width"}const SF=new Set(["top","bottom"]);function ka(t){return SF.has(hi(t))?"y":"x"}function Ny(t){return by(ka(t))}function CF(t,e,n){n===void 0&&(n=!1);const s=Pc(t),a=Ny(t),i=vy(a);let o=a==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=Wf(o)),[o,Wf(o)]}function EF(t){const e=Wf(t);return[t0(t),e,t0(e)]}function t0(t){return t.replace(/start|end/g,e=>kF[e])}const Ew=["left","right"],Tw=["right","left"],TF=["top","bottom"],MF=["bottom","top"];function AF(t,e,n){switch(t){case"top":case"bottom":return n?e?Tw:Ew:e?Ew:Tw;case"left":case"right":return e?TF:MF;default:return[]}}function IF(t,e,n,s){const a=Pc(t);let i=AF(hi(t),n==="start",s);return a&&(i=i.map(o=>o+"-"+a),e&&(i=i.concat(i.map(t0)))),i}function Wf(t){return t.replace(/left|right|bottom|top/g,e=>jF[e])}function RF(t){return{top:0,right:0,bottom:0,left:0,...t}}function i3(t){return typeof t!="number"?RF(t):{top:t,right:t,bottom:t,left:t}}function Kf(t){const{x:e,y:n,width:s,height:a}=t;return{width:s,height:a,top:n,left:e,right:e+s,bottom:n+a,x:e,y:n}}function Mw(t,e,n){let{reference:s,floating:a}=t;const i=ka(e),o=Ny(e),c=vy(o),u=hi(e),h=i==="y",f=s.x+s.width/2-a.width/2,m=s.y+s.height/2-a.height/2,g=s[c]/2-a[c]/2;let y;switch(u){case"top":y={x:f,y:s.y-a.height};break;case"bottom":y={x:f,y:s.y+s.height};break;case"right":y={x:s.x+s.width,y:m};break;case"left":y={x:s.x-a.width,y:m};break;default:y={x:s.x,y:s.y}}switch(Pc(e)){case"start":y[o]-=g*(n&&h?-1:1);break;case"end":y[o]+=g*(n&&h?-1:1);break}return y}async function PF(t,e){var n;e===void 0&&(e={});const{x:s,y:a,platform:i,rects:o,elements:c,strategy:u}=t,{boundary:h="clippingAncestors",rootBoundary:f="viewport",elementContext:m="floating",altBoundary:g=!1,padding:y=0}=ui(e,t),v=i3(y),N=c[g?m==="floating"?"reference":"floating":m],k=Kf(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(N)))==null||n?N:N.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:h,rootBoundary:f,strategy:u})),E=m==="floating"?{x:s,y:a,width:o.floating.width,height:o.floating.height}:o.reference,C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),P=await(i.isElement==null?void 0:i.isElement(C))?await(i.getScale==null?void 0:i.getScale(C))||{x:1,y:1}:{x:1,y:1},O=Kf(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:E,offsetParent:C,strategy:u}):E);return{top:(k.top-O.top+v.top)/P.y,bottom:(O.bottom-k.bottom+v.bottom)/P.y,left:(k.left-O.left+v.left)/P.x,right:(O.right-k.right+v.right)/P.x}}const OF=async(t,e,n)=>{const{placement:s="bottom",strategy:a="absolute",middleware:i=[],platform:o}=n,c=i.filter(Boolean),u=await(o.isRTL==null?void 0:o.isRTL(e));let h=await o.getElementRects({reference:t,floating:e,strategy:a}),{x:f,y:m}=Mw(h,s,u),g=s,y={},v=0;for(let N=0;N<c.length;N++){var w;const{name:k,fn:E}=c[N],{x:C,y:P,data:O,reset:U}=await E({x:f,y:m,initialPlacement:s,placement:g,strategy:a,middlewareData:y,rects:h,platform:{...o,detectOverflow:(w=o.detectOverflow)!=null?w:PF},elements:{reference:t,floating:e}});f=C??f,m=P??m,y={...y,[k]:{...y[k],...O}},U&&v<=50&&(v++,typeof U=="object"&&(U.placement&&(g=U.placement),U.rects&&(h=U.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:a}):U.rects),{x:f,y:m}=Mw(h,g,u)),N=-1)}return{x:f,y:m,placement:g,strategy:a,middlewareData:y}},LF=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:s,placement:a,rects:i,platform:o,elements:c,middlewareData:u}=e,{element:h,padding:f=0}=ui(t,e)||{};if(h==null)return{};const m=i3(f),g={x:n,y:s},y=Ny(a),v=vy(y),w=await o.getDimensions(h),N=y==="y",k=N?"top":"left",E=N?"bottom":"right",C=N?"clientHeight":"clientWidth",P=i.reference[v]+i.reference[y]-g[y]-i.floating[v],O=g[y]-i.reference[y],U=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let _=U?U[C]:0;(!_||!await(o.isElement==null?void 0:o.isElement(U)))&&(_=c.floating[C]||i.floating[v]);const V=P/2-O/2,A=_/2-w[v]/2-1,X=uo(m[k],A),G=uo(m[E],A),z=X,ne=_-w[v]-G,ue=_/2-w[v]/2+V,K=e0(z,ue,ne),$=!u.arrow&&Pc(a)!=null&&ue!==K&&i.reference[v]/2-(ue<z?X:G)-w[v]/2<0,D=$?ue<z?ue-z:ue-ne:0;return{[y]:g[y]+D,data:{[y]:K,centerOffset:ue-K-D,...$&&{alignmentOffset:D}},reset:$}}}),DF=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,s;const{placement:a,middlewareData:i,rects:o,initialPlacement:c,platform:u,elements:h}=e,{mainAxis:f=!0,crossAxis:m=!0,fallbackPlacements:g,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:w=!0,...N}=ui(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const k=hi(a),E=ka(c),C=hi(c)===c,P=await(u.isRTL==null?void 0:u.isRTL(h.floating)),O=g||(C||!w?[Wf(c)]:EF(c)),U=v!=="none";!g&&U&&O.push(...IF(c,w,v,P));const _=[c,...O],V=await u.detectOverflow(e,N),A=[];let X=((s=i.flip)==null?void 0:s.overflows)||[];if(f&&A.push(V[k]),m){const ue=CF(a,o,P);A.push(V[ue[0]],V[ue[1]])}if(X=[...X,{placement:a,overflows:A}],!A.every(ue=>ue<=0)){var G,z;const ue=(((G=i.flip)==null?void 0:G.index)||0)+1,K=_[ue];if(K&&(!(m==="alignment"?E!==ka(K):!1)||X.every(I=>ka(I.placement)===E?I.overflows[0]>0:!0)))return{data:{index:ue,overflows:X},reset:{placement:K}};let $=(z=X.filter(D=>D.overflows[0]<=0).sort((D,I)=>D.overflows[1]-I.overflows[1])[0])==null?void 0:z.placement;if(!$)switch(y){case"bestFit":{var ne;const D=(ne=X.filter(I=>{if(U){const ie=ka(I.placement);return ie===E||ie==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(ie=>ie>0).reduce((ie,q)=>ie+q,0)]).sort((I,ie)=>I[1]-ie[1])[0])==null?void 0:ne[0];D&&($=D);break}case"initialPlacement":$=c;break}if(a!==$)return{reset:{placement:$}}}return{}}}};function Aw(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Iw(t){return wF.some(e=>t[e]>=0)}const _F=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:s}=e,{strategy:a="referenceHidden",...i}=ui(t,e);switch(a){case"referenceHidden":{const o=await s.detectOverflow(e,{...i,elementContext:"reference"}),c=Aw(o,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:Iw(c)}}}case"escaped":{const o=await s.detectOverflow(e,{...i,altBoundary:!0}),c=Aw(o,n.floating);return{data:{escapedOffsets:c,escaped:Iw(c)}}}default:return{}}}}},o3=new Set(["left","top"]);async function zF(t,e){const{placement:n,platform:s,elements:a}=t,i=await(s.isRTL==null?void 0:s.isRTL(a.floating)),o=hi(n),c=Pc(n),u=ka(n)==="y",h=o3.has(o)?-1:1,f=i&&u?-1:1,m=ui(e,t);let{mainAxis:g,crossAxis:y,alignmentAxis:v}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof v=="number"&&(y=c==="end"?v*-1:v),u?{x:y*f,y:g*h}:{x:g*h,y:y*f}}const $F=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,s;const{x:a,y:i,placement:o,middlewareData:c}=e,u=await zF(e,t);return o===((n=c.offset)==null?void 0:n.placement)&&(s=c.arrow)!=null&&s.alignmentOffset?{}:{x:a+u.x,y:i+u.y,data:{...u,placement:o}}}}},FF=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:s,placement:a,platform:i}=e,{mainAxis:o=!0,crossAxis:c=!1,limiter:u={fn:k=>{let{x:E,y:C}=k;return{x:E,y:C}}},...h}=ui(t,e),f={x:n,y:s},m=await i.detectOverflow(e,h),g=ka(hi(a)),y=by(g);let v=f[y],w=f[g];if(o){const k=y==="y"?"top":"left",E=y==="y"?"bottom":"right",C=v+m[k],P=v-m[E];v=e0(C,v,P)}if(c){const k=g==="y"?"top":"left",E=g==="y"?"bottom":"right",C=w+m[k],P=w-m[E];w=e0(C,w,P)}const N=u.fn({...e,[y]:v,[g]:w});return{...N,data:{x:N.x-n,y:N.y-s,enabled:{[y]:o,[g]:c}}}}}},BF=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:s,placement:a,rects:i,middlewareData:o}=e,{offset:c=0,mainAxis:u=!0,crossAxis:h=!0}=ui(t,e),f={x:n,y:s},m=ka(a),g=by(m);let y=f[g],v=f[m];const w=ui(c,e),N=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(u){const C=g==="y"?"height":"width",P=i.reference[g]-i.floating[C]+N.mainAxis,O=i.reference[g]+i.reference[C]-N.mainAxis;y<P?y=P:y>O&&(y=O)}if(h){var k,E;const C=g==="y"?"width":"height",P=o3.has(hi(a)),O=i.reference[m]-i.floating[C]+(P&&((k=o.offset)==null?void 0:k[m])||0)+(P?0:N.crossAxis),U=i.reference[m]+i.reference[C]+(P?0:((E=o.offset)==null?void 0:E[m])||0)-(P?N.crossAxis:0);v<O?v=O:v>U&&(v=U)}return{[g]:y,[m]:v}}}},VF=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,s;const{placement:a,rects:i,platform:o,elements:c}=e,{apply:u=()=>{},...h}=ui(t,e),f=await o.detectOverflow(e,h),m=hi(a),g=Pc(a),y=ka(a)==="y",{width:v,height:w}=i.floating;let N,k;m==="top"||m==="bottom"?(N=m,k=g===(await(o.isRTL==null?void 0:o.isRTL(c.floating))?"start":"end")?"left":"right"):(k=m,N=g==="end"?"top":"bottom");const E=w-f.top-f.bottom,C=v-f.left-f.right,P=uo(w-f[N],E),O=uo(v-f[k],C),U=!e.middlewareData.shift;let _=P,V=O;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(V=C),(s=e.middlewareData.shift)!=null&&s.enabled.y&&(_=E),U&&!g){const X=cr(f.left,0),G=cr(f.right,0),z=cr(f.top,0),ne=cr(f.bottom,0);y?V=v-2*(X!==0||G!==0?X+G:cr(f.left,f.right)):_=w-2*(z!==0||ne!==0?z+ne:cr(f.top,f.bottom))}await u({...e,availableWidth:V,availableHeight:_});const A=await o.getDimensions(c.floating);return v!==A.width||w!==A.height?{reset:{rects:!0}}:{}}}};function Np(){return typeof window<"u"}function Oc(t){return l3(t)?(t.nodeName||"").toLowerCase():"#document"}function fr(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Ra(t){var e;return(e=(l3(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function l3(t){return Np()?t instanceof Node||t instanceof fr(t).Node:!1}function Yr(t){return Np()?t instanceof Element||t instanceof fr(t).Element:!1}function Ma(t){return Np()?t instanceof HTMLElement||t instanceof fr(t).HTMLElement:!1}function Rw(t){return!Np()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof fr(t).ShadowRoot}const HF=new Set(["inline","contents"]);function du(t){const{overflow:e,overflowX:n,overflowY:s,display:a}=Qr(t);return/auto|scroll|overlay|hidden|clip/.test(e+s+n)&&!HF.has(a)}const UF=new Set(["table","td","th"]);function WF(t){return UF.has(Oc(t))}const KF=[":popover-open",":modal"];function wp(t){return KF.some(e=>{try{return t.matches(e)}catch{return!1}})}const qF=["transform","translate","scale","rotate","perspective"],GF=["transform","translate","scale","rotate","perspective","filter"],JF=["paint","layout","strict","content"];function wy(t){const e=jy(),n=Yr(t)?Qr(t):t;return qF.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||GF.some(s=>(n.willChange||"").includes(s))||JF.some(s=>(n.contain||"").includes(s))}function YF(t){let e=ho(t);for(;Ma(e)&&!Sc(e);){if(wy(e))return e;if(wp(e))return null;e=ho(e)}return null}function jy(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const QF=new Set(["html","body","#document"]);function Sc(t){return QF.has(Oc(t))}function Qr(t){return fr(t).getComputedStyle(t)}function jp(t){return Yr(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function ho(t){if(Oc(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Rw(t)&&t.host||Ra(t);return Rw(e)?e.host:e}function c3(t){const e=ho(t);return Sc(e)?t.ownerDocument?t.ownerDocument.body:t.body:Ma(e)&&du(e)?e:c3(e)}function Zd(t,e,n){var s;e===void 0&&(e=[]),n===void 0&&(n=!0);const a=c3(t),i=a===((s=t.ownerDocument)==null?void 0:s.body),o=fr(a);if(i){const c=n0(o);return e.concat(o,o.visualViewport||[],du(a)?a:[],c&&n?Zd(c):[])}return e.concat(a,Zd(a,[],n))}function n0(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function d3(t){const e=Qr(t);let n=parseFloat(e.width)||0,s=parseFloat(e.height)||0;const a=Ma(t),i=a?t.offsetWidth:n,o=a?t.offsetHeight:s,c=Uf(n)!==i||Uf(s)!==o;return c&&(n=i,s=o),{width:n,height:s,$:c}}function ky(t){return Yr(t)?t:t.contextElement}function fc(t){const e=ky(t);if(!Ma(e))return Ca(1);const n=e.getBoundingClientRect(),{width:s,height:a,$:i}=d3(e);let o=(i?Uf(n.width):n.width)/s,c=(i?Uf(n.height):n.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!c||!Number.isFinite(c))&&(c=1),{x:o,y:c}}const XF=Ca(0);function u3(t){const e=fr(t);return!jy()||!e.visualViewport?XF:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function ZF(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==fr(t)?!1:e}function xl(t,e,n,s){e===void 0&&(e=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),i=ky(t);let o=Ca(1);e&&(s?Yr(s)&&(o=fc(s)):o=fc(t));const c=ZF(i,n,s)?u3(i):Ca(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=fr(i),y=s&&Yr(s)?fr(s):s;let v=g,w=n0(v);for(;w&&s&&y!==v;){const N=fc(w),k=w.getBoundingClientRect(),E=Qr(w),C=k.left+(w.clientLeft+parseFloat(E.paddingLeft))*N.x,P=k.top+(w.clientTop+parseFloat(E.paddingTop))*N.y;u*=N.x,h*=N.y,f*=N.x,m*=N.y,u+=C,h+=P,v=fr(w),w=n0(v)}}return Kf({width:f,height:m,x:u,y:h})}function kp(t,e){const n=jp(t).scrollLeft;return e?e.left+n:xl(Ra(t)).left+n}function h3(t,e){const n=t.getBoundingClientRect(),s=n.left+e.scrollLeft-kp(t,n),a=n.top+e.scrollTop;return{x:s,y:a}}function eB(t){let{elements:e,rect:n,offsetParent:s,strategy:a}=t;const i=a==="fixed",o=Ra(s),c=e?wp(e.floating):!1;if(s===o||c&&i)return n;let u={scrollLeft:0,scrollTop:0},h=Ca(1);const f=Ca(0),m=Ma(s);if((m||!m&&!i)&&((Oc(s)!=="body"||du(o))&&(u=jp(s)),Ma(s))){const y=xl(s);h=fc(s),f.x=y.x+s.clientLeft,f.y=y.y+s.clientTop}const g=o&&!m&&!i?h3(o,u):Ca(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 tB(t){return Array.from(t.getClientRects())}function nB(t){const e=Ra(t),n=jp(t),s=t.ownerDocument.body,a=cr(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),i=cr(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let o=-n.scrollLeft+kp(t);const c=-n.scrollTop;return Qr(s).direction==="rtl"&&(o+=cr(e.clientWidth,s.clientWidth)-a),{width:a,height:i,x:o,y:c}}const Pw=25;function sB(t,e){const n=fr(t),s=Ra(t),a=n.visualViewport;let i=s.clientWidth,o=s.clientHeight,c=0,u=0;if(a){i=a.width,o=a.height;const f=jy();(!f||f&&e==="fixed")&&(c=a.offsetLeft,u=a.offsetTop)}const h=kp(s);if(h<=0){const f=s.ownerDocument,m=f.body,g=getComputedStyle(m),y=f.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,v=Math.abs(s.clientWidth-m.clientWidth-y);v<=Pw&&(i-=v)}else h<=Pw&&(i+=h);return{width:i,height:o,x:c,y:u}}const rB=new Set(["absolute","fixed"]);function aB(t,e){const n=xl(t,!0,e==="fixed"),s=n.top+t.clientTop,a=n.left+t.clientLeft,i=Ma(t)?fc(t):Ca(1),o=t.clientWidth*i.x,c=t.clientHeight*i.y,u=a*i.x,h=s*i.y;return{width:o,height:c,x:u,y:h}}function Ow(t,e,n){let s;if(e==="viewport")s=sB(t,n);else if(e==="document")s=nB(Ra(t));else if(Yr(e))s=aB(e,n);else{const a=u3(t);s={x:e.x-a.x,y:e.y-a.y,width:e.width,height:e.height}}return Kf(s)}function f3(t,e){const n=ho(t);return n===e||!Yr(n)||Sc(n)?!1:Qr(n).position==="fixed"||f3(n,e)}function iB(t,e){const n=e.get(t);if(n)return n;let s=Zd(t,[],!1).filter(c=>Yr(c)&&Oc(c)!=="body"),a=null;const i=Qr(t).position==="fixed";let o=i?ho(t):t;for(;Yr(o)&&!Sc(o);){const c=Qr(o),u=wy(o);!u&&c.position==="fixed"&&(a=null),(i?!u&&!a:!u&&c.position==="static"&&!!a&&rB.has(a.position)||du(o)&&!u&&f3(t,o))?s=s.filter(f=>f!==o):a=c,o=ho(o)}return e.set(t,s),s}function oB(t){let{element:e,boundary:n,rootBoundary:s,strategy:a}=t;const o=[...n==="clippingAncestors"?wp(e)?[]:iB(e,this._c):[].concat(n),s],c=o[0],u=o.reduce((h,f)=>{const m=Ow(e,f,a);return h.top=cr(m.top,h.top),h.right=uo(m.right,h.right),h.bottom=uo(m.bottom,h.bottom),h.left=cr(m.left,h.left),h},Ow(e,c,a));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function lB(t){const{width:e,height:n}=d3(t);return{width:e,height:n}}function cB(t,e,n){const s=Ma(e),a=Ra(e),i=n==="fixed",o=xl(t,!0,i,e);let c={scrollLeft:0,scrollTop:0};const u=Ca(0);function h(){u.x=kp(a)}if(s||!s&&!i)if((Oc(e)!=="body"||du(a))&&(c=jp(e)),s){const y=xl(e,!0,i,e);u.x=y.x+e.clientLeft,u.y=y.y+e.clientTop}else a&&h();i&&!s&&a&&h();const f=a&&!s&&!i?h3(a,c):Ca(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 Qr(t).position==="static"}function Lw(t,e){if(!Ma(t)||Qr(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Ra(t)===n&&(n=n.ownerDocument.body),n}function p3(t,e){const n=fr(t);if(wp(t))return n;if(!Ma(t)){let a=ho(t);for(;a&&!Sc(a);){if(Yr(a)&&!qg(a))return a;a=ho(a)}return n}let s=Lw(t,e);for(;s&&WF(s)&&qg(s);)s=Lw(s,e);return s&&Sc(s)&&qg(s)&&!wy(s)?n:s||YF(t)||n}const dB=async function(t){const e=this.getOffsetParent||p3,n=this.getDimensions,s=await n(t.floating);return{reference:cB(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function uB(t){return Qr(t).direction==="rtl"}const hB={convertOffsetParentRelativeRectToViewportRelativeRect:eB,getDocumentElement:Ra,getClippingRect:oB,getOffsetParent:p3,getElementRects:dB,getClientRects:tB,getDimensions:lB,getScale:fc,isElement:Yr,isRTL:uB};function m3(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function fB(t,e){let n=null,s;const a=Ra(t);function i(){var c;clearTimeout(s),(c=n)==null||c.disconnect(),n=null}function o(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),i();const h=t.getBoundingClientRect(),{left:f,top:m,width:g,height:y}=h;if(c||e(),!g||!y)return;const v=Rh(m),w=Rh(a.clientWidth-(f+g)),N=Rh(a.clientHeight-(m+y)),k=Rh(f),C={rootMargin:-v+"px "+-w+"px "+-N+"px "+-k+"px",threshold:cr(0,uo(1,u))||1};let P=!0;function O(U){const _=U[0].intersectionRatio;if(_!==u){if(!P)return o();_?o(!1,_):s=setTimeout(()=>{o(!1,1e-7)},1e3)}_===1&&!m3(h,t.getBoundingClientRect())&&o(),P=!1}try{n=new IntersectionObserver(O,{...C,root:a.ownerDocument})}catch{n=new IntersectionObserver(O,C)}n.observe(t)}return o(!0),i}function pB(t,e,n,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=s,h=ky(t),f=a||i?[...h?Zd(h):[],...Zd(e)]:[];f.forEach(k=>{a&&k.addEventListener("scroll",n,{passive:!0}),i&&k.addEventListener("resize",n)});const m=h&&c?fB(h,n):null;let g=-1,y=null;o&&(y=new ResizeObserver(k=>{let[E]=k;E&&E.target===h&&y&&(y.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var C;(C=y)==null||C.observe(e)})),n()}),h&&!u&&y.observe(h),y.observe(e));let v,w=u?xl(t):null;u&&N();function N(){const k=xl(t);w&&!m3(w,k)&&n(),w=k,v=requestAnimationFrame(N)}return n(),()=>{var k;f.forEach(E=>{a&&E.removeEventListener("scroll",n),i&&E.removeEventListener("resize",n)}),m==null||m(),(k=y)==null||k.disconnect(),y=null,u&&cancelAnimationFrame(v)}}const mB=$F,gB=FF,xB=DF,yB=VF,bB=_F,Dw=LF,vB=BF,NB=(t,e,n)=>{const s=new Map,a={platform:hB,...n},i={...a.platform,_c:s};return OF(t,e,{...a,platform:i})};var wB=typeof document<"u",jB=function(){},Vh=wB?b.useLayoutEffect:jB;function qf(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,s,a;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(s=n;s--!==0;)if(!qf(t[s],e[s]))return!1;return!0}if(a=Object.keys(t),n=a.length,n!==Object.keys(e).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(e,a[s]))return!1;for(s=n;s--!==0;){const i=a[s];if(!(i==="_owner"&&t.$$typeof)&&!qf(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function g3(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function _w(t,e){const n=g3(t);return Math.round(e*n)/n}function Gg(t){const e=b.useRef(t);return Vh(()=>{e.current=t}),e}function kB(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:s=[],platform:a,elements:{reference:i,floating:o}={},transform:c=!0,whileElementsMounted:u,open:h}=t,[f,m]=b.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[g,y]=b.useState(s);qf(g,s)||y(s);const[v,w]=b.useState(null),[N,k]=b.useState(null),E=b.useCallback(I=>{I!==U.current&&(U.current=I,w(I))},[]),C=b.useCallback(I=>{I!==_.current&&(_.current=I,k(I))},[]),P=i||v,O=o||N,U=b.useRef(null),_=b.useRef(null),V=b.useRef(f),A=u!=null,X=Gg(u),G=Gg(a),z=Gg(h),ne=b.useCallback(()=>{if(!U.current||!_.current)return;const I={placement:e,strategy:n,middleware:g};G.current&&(I.platform=G.current),NB(U.current,_.current,I).then(ie=>{const q={...ie,isPositioned:z.current!==!1};ue.current&&!qf(V.current,q)&&(V.current=q,tu.flushSync(()=>{m(q)}))})},[g,e,n,G,z]);Vh(()=>{h===!1&&V.current.isPositioned&&(V.current.isPositioned=!1,m(I=>({...I,isPositioned:!1})))},[h]);const ue=b.useRef(!1);Vh(()=>(ue.current=!0,()=>{ue.current=!1}),[]),Vh(()=>{if(P&&(U.current=P),O&&(_.current=O),P&&O){if(X.current)return X.current(P,O,ne);ne()}},[P,O,ne,X,A]);const K=b.useMemo(()=>({reference:U,floating:_,setReference:E,setFloating:C}),[E,C]),$=b.useMemo(()=>({reference:P,floating:O}),[P,O]),D=b.useMemo(()=>{const I={position:n,left:0,top:0};if(!$.floating)return I;const ie=_w($.floating,f.x),q=_w($.floating,f.y);return c?{...I,transform:"translate("+ie+"px, "+q+"px)",...g3($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:ie,top:q}},[n,c,$.floating,f.x,f.y]);return b.useMemo(()=>({...f,update:ne,refs:K,elements:$,floatingStyles:D}),[f,ne,K,$,D])}const SB=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:s,padding:a}=typeof t=="function"?t(n):t;return s&&e(s)?s.current!=null?Dw({element:s.current,padding:a}).fn(n):{}:s?Dw({element:s,padding:a}).fn(n):{}}}},CB=(t,e)=>({...mB(t),options:[t,e]}),EB=(t,e)=>({...gB(t),options:[t,e]}),TB=(t,e)=>({...vB(t),options:[t,e]}),MB=(t,e)=>({...xB(t),options:[t,e]}),AB=(t,e)=>({...yB(t),options:[t,e]}),IB=(t,e)=>({...bB(t),options:[t,e]}),RB=(t,e)=>({...SB(t),options:[t,e]});var PB="Arrow",x3=b.forwardRef((t,e)=>{const{children:n,width:s=10,height:a=5,...i}=t;return r.jsx(vt.svg,{...i,ref:e,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});x3.displayName=PB;var OB=x3,Sy="Popper",[y3,b3]=mo(Sy),[LB,v3]=y3(Sy),N3=t=>{const{__scopePopper:e,children:n}=t,[s,a]=b.useState(null);return r.jsx(LB,{scope:e,anchor:s,onAnchorChange:a,children:n})};N3.displayName=Sy;var w3="PopperAnchor",j3=b.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:s,...a}=t,i=v3(w3,n),o=b.useRef(null),c=$t(e,o),u=b.useRef(null);return b.useEffect(()=>{const h=u.current;u.current=(s==null?void 0:s.current)||o.current,h!==u.current&&i.onAnchorChange(u.current)}),s?null:r.jsx(vt.div,{...a,ref:c})});j3.displayName=w3;var Cy="PopperContent",[DB,_B]=y3(Cy),k3=b.forwardRef((t,e)=>{var le,ae,Q,Z,xe,Ne;const{__scopePopper:n,side:s="bottom",sideOffset:a=0,align:i="center",alignOffset:o=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:h=[],collisionPadding:f=0,sticky:m="partial",hideWhenDetached:g=!1,updatePositionStrategy:y="optimized",onPlaced:v,...w}=t,N=v3(Cy,n),[k,E]=b.useState(null),C=$t(e,ct=>E(ct)),[P,O]=b.useState(null),U=E0(P),_=(U==null?void 0:U.width)??0,V=(U==null?void 0:U.height)??0,A=s+(i!=="center"?"-"+i:""),X=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},G=Array.isArray(h)?h:[h],z=G.length>0,ne={padding:X,boundary:G.filter($B),altBoundary:z},{refs:ue,floatingStyles:K,placement:$,isPositioned:D,middlewareData:I}=kB({strategy:"fixed",placement:A,whileElementsMounted:(...ct)=>pB(...ct,{animationFrame:y==="always"}),elements:{reference:N.anchor},middleware:[CB({mainAxis:a+V,alignmentAxis:o}),u&&EB({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?TB():void 0,...ne}),u&&MB({...ne}),AB({...ne,apply:({elements:ct,rects:ye,availableWidth:$e,availableHeight:Ze})=>{const{width:tt,height:_e}=ye.reference,st=ct.floating.style;st.setProperty("--radix-popper-available-width",`${$e}px`),st.setProperty("--radix-popper-available-height",`${Ze}px`),st.setProperty("--radix-popper-anchor-width",`${tt}px`),st.setProperty("--radix-popper-anchor-height",`${_e}px`)}}),P&&RB({element:P,padding:c}),FB({arrowWidth:_,arrowHeight:V}),g&&IB({strategy:"referenceHidden",...ne})]}),[ie,q]=E3($),L=oo(v);Cs(()=>{D&&(L==null||L())},[D,L]);const F=(le=I.arrow)==null?void 0:le.x,re=(ae=I.arrow)==null?void 0:ae.y,ge=((Q=I.arrow)==null?void 0:Q.centerOffset)!==0,[Te,se]=b.useState();return Cs(()=>{k&&se(window.getComputedStyle(k).zIndex)},[k]),r.jsx("div",{ref:ue.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:D?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Te,"--radix-popper-transform-origin":[(Z=I.transformOrigin)==null?void 0:Z.x,(xe=I.transformOrigin)==null?void 0:xe.y].join(" "),...((Ne=I.hide)==null?void 0:Ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:r.jsx(DB,{scope:n,placedSide:ie,onArrowChange:O,arrowX:F,arrowY:re,shouldHideArrow:ge,children:r.jsx(vt.div,{"data-side":ie,"data-align":q,...w,ref:C,style:{...w.style,animation:D?void 0:"none"}})})})});k3.displayName=Cy;var S3="PopperArrow",zB={top:"bottom",right:"left",bottom:"top",left:"right"},C3=b.forwardRef(function(e,n){const{__scopePopper:s,...a}=e,i=_B(S3,s),o=zB[i.placedSide];return r.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:r.jsx(OB,{...a,ref:n,style:{...a.style,display:"block"}})})});C3.displayName=S3;function $B(t){return t!==null}var FB=t=>({name:"transformOrigin",options:t,fn(e){var N,k,E;const{placement:n,rects:s,middlewareData:a}=e,o=((N=a.arrow)==null?void 0:N.centerOffset)!==0,c=o?0:t.arrowWidth,u=o?0:t.arrowHeight,[h,f]=E3(n),m={start:"0%",center:"50%",end:"100%"}[f],g=(((k=a.arrow)==null?void 0:k.x)??0)+c/2,y=(((E=a.arrow)==null?void 0:E.y)??0)+u/2;let v="",w="";return h==="bottom"?(v=o?m:`${g}px`,w=`${-u}px`):h==="top"?(v=o?m:`${g}px`,w=`${s.floating.height+u}px`):h==="right"?(v=`${-u}px`,w=o?m:`${y}px`):h==="left"&&(v=`${s.floating.width+u}px`,w=o?m:`${y}px`),{data:{x:v,y:w}}}});function E3(t){const[e,n="center"]=t.split("-");return[e,n]}var BB=N3,VB=j3,HB=k3,UB=C3,T3=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"}),WB="VisuallyHidden",KB=b.forwardRef((t,e)=>r.jsx(vt.span,{...t,ref:e,style:{...T3,...t.style}}));KB.displayName=WB;var qB=[" ","Enter","ArrowUp","ArrowDown"],GB=[" ","Enter"],yl="Select",[Sp,Cp,JB]=k0(yl),[Lc]=mo(yl,[JB,b3]),Ep=b3(),[YB,bo]=Lc(yl),[QB,XB]=Lc(yl),M3=t=>{const{__scopeSelect:e,children:n,open:s,defaultOpen:a,onOpenChange:i,value:o,defaultValue:c,onValueChange:u,dir:h,name:f,autoComplete:m,disabled:g,required:y,form:v}=t,w=Ep(e),[N,k]=b.useState(null),[E,C]=b.useState(null),[P,O]=b.useState(!1),U=tp(h),[_,V]=ol({prop:s,defaultProp:a??!1,onChange:i,caller:yl}),[A,X]=ol({prop:o,defaultProp:c,onChange:u,caller:yl}),G=b.useRef(null),z=N?v||!!N.closest("form"):!0,[ne,ue]=b.useState(new Set),K=Array.from(ne).map($=>$.props.value).join(";");return r.jsx(BB,{...w,children:r.jsxs(YB,{required:y,scope:e,trigger:N,onTriggerChange:k,valueNode:E,onValueNodeChange:C,valueNodeHasChildren:P,onValueNodeHasChildrenChange:O,contentId:Zi(),value:A,onValueChange:X,open:_,onOpenChange:V,dir:U,triggerPointerDownPosRef:G,disabled:g,children:[r.jsx(Sp.Provider,{scope:e,children:r.jsx(QB,{scope:t.__scopeSelect,onNativeOptionAdd:b.useCallback($=>{ue(D=>new Set(D).add($))},[]),onNativeOptionRemove:b.useCallback($=>{ue(D=>{const I=new Set(D);return I.delete($),I})},[]),children:n})}),z?r.jsxs(Q3,{"aria-hidden":!0,required:y,tabIndex:-1,name:f,autoComplete:m,value:A,onChange:$=>X($.target.value),disabled:g,form:v,children:[A===void 0?r.jsx("option",{value:""}):null,Array.from(ne)]},K):null]})})};M3.displayName=yl;var A3="SelectTrigger",I3=b.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:s=!1,...a}=t,i=Ep(n),o=bo(A3,n),c=o.disabled||s,u=$t(e,o.onTriggerChange),h=Cp(n),f=b.useRef("touch"),[m,g,y]=Z3(w=>{const N=h().filter(C=>!C.disabled),k=N.find(C=>C.value===o.value),E=e4(N,w,k);E!==void 0&&o.onValueChange(E.value)}),v=w=>{c||(o.onOpenChange(!0),y()),w&&(o.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return r.jsx(VB,{asChild:!0,...i,children:r.jsx(vt.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":X3(o.value)?"":void 0,...a,ref:u,onClick:xt(a.onClick,w=>{w.currentTarget.focus(),f.current!=="mouse"&&v(w)}),onPointerDown:xt(a.onPointerDown,w=>{f.current=w.pointerType;const N=w.target;N.hasPointerCapture(w.pointerId)&&N.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(v(w),w.preventDefault())}),onKeyDown:xt(a.onKeyDown,w=>{const N=m.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&g(w.key),!(N&&w.key===" ")&&qB.includes(w.key)&&(v(),w.preventDefault())})})})});I3.displayName=A3;var R3="SelectValue",P3=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:s,style:a,children:i,placeholder:o="",...c}=t,u=bo(R3,n),{onValueNodeHasChildrenChange:h}=u,f=i!==void 0,m=$t(e,u.onValueNodeChange);return Cs(()=>{h(f)},[h,f]),r.jsx(vt.span,{...c,ref:m,style:{pointerEvents:"none"},children:X3(u.value)?r.jsx(r.Fragment,{children:o}):i})});P3.displayName=R3;var ZB="SelectIcon",O3=b.forwardRef((t,e)=>{const{__scopeSelect:n,children:s,...a}=t;return r.jsx(vt.span,{"aria-hidden":!0,...a,ref:e,children:s||"▼"})});O3.displayName=ZB;var eV="SelectPortal",L3=t=>r.jsx(b0,{asChild:!0,...t});L3.displayName=eV;var bl="SelectContent",D3=b.forwardRef((t,e)=>{const n=bo(bl,t.__scopeSelect),[s,a]=b.useState();if(Cs(()=>{a(new DocumentFragment)},[]),!n.open){const i=s;return i?tu.createPortal(r.jsx(_3,{scope:t.__scopeSelect,children:r.jsx(Sp.Slot,{scope:t.__scopeSelect,children:r.jsx("div",{children:t.children})})}),i):null}return r.jsx(z3,{...t,ref:e})});D3.displayName=bl;var qr=10,[_3,vo]=Lc(bl),tV="SelectContentImpl",nV=Fd("SelectContent.RemoveScroll"),z3=b.forwardRef((t,e)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:o,side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:v,hideWhenDetached:w,avoidCollisions:N,...k}=t,E=bo(bl,n),[C,P]=b.useState(null),[O,U]=b.useState(null),_=$t(e,le=>P(le)),[V,A]=b.useState(null),[X,G]=b.useState(null),z=Cp(n),[ne,ue]=b.useState(!1),K=b.useRef(!1);b.useEffect(()=>{if(C)return Zj(C)},[C]),Uj();const $=b.useCallback(le=>{const[ae,...Q]=z().map(Ne=>Ne.ref.current),[Z]=Q.slice(-1),xe=document.activeElement;for(const Ne of le)if(Ne===xe||(Ne==null||Ne.scrollIntoView({block:"nearest"}),Ne===ae&&O&&(O.scrollTop=0),Ne===Z&&O&&(O.scrollTop=O.scrollHeight),Ne==null||Ne.focus(),document.activeElement!==xe))return},[z,O]),D=b.useCallback(()=>$([V,C]),[$,V,C]);b.useEffect(()=>{ne&&D()},[ne,D]);const{onOpenChange:I,triggerPointerDownPosRef:ie}=E;b.useEffect(()=>{if(C){let le={x:0,y:0};const ae=Z=>{var xe,Ne;le={x:Math.abs(Math.round(Z.pageX)-(((xe=ie.current)==null?void 0:xe.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((Ne=ie.current)==null?void 0:Ne.y)??0))}},Q=Z=>{le.x<=10&&le.y<=10?Z.preventDefault():C.contains(Z.target)||I(!1),document.removeEventListener("pointermove",ae),ie.current=null};return ie.current!==null&&(document.addEventListener("pointermove",ae),document.addEventListener("pointerup",Q,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ae),document.removeEventListener("pointerup",Q,{capture:!0})}}},[C,I,ie]),b.useEffect(()=>{const le=()=>I(!1);return window.addEventListener("blur",le),window.addEventListener("resize",le),()=>{window.removeEventListener("blur",le),window.removeEventListener("resize",le)}},[I]);const[q,L]=Z3(le=>{const ae=z().filter(xe=>!xe.disabled),Q=ae.find(xe=>xe.ref.current===document.activeElement),Z=e4(ae,le,Q);Z&&setTimeout(()=>Z.ref.current.focus())}),F=b.useCallback((le,ae,Q)=>{const Z=!K.current&&!Q;(E.value!==void 0&&E.value===ae||Z)&&(A(le),Z&&(K.current=!0))},[E.value]),re=b.useCallback(()=>C==null?void 0:C.focus(),[C]),ge=b.useCallback((le,ae,Q)=>{const Z=!K.current&&!Q;(E.value!==void 0&&E.value===ae||Z)&&G(le)},[E.value]),Te=s==="popper"?s0:$3,se=Te===s0?{side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:v,hideWhenDetached:w,avoidCollisions:N}:{};return r.jsx(_3,{scope:n,content:C,viewport:O,onViewportChange:U,itemRefCallback:F,selectedItem:V,onItemLeave:re,itemTextRefCallback:ge,focusSelectedItem:D,selectedItemText:X,position:s,isPositioned:ne,searchRef:q,children:r.jsx(v0,{as:nV,allowPinchZoom:!0,children:r.jsx(y0,{asChild:!0,trapped:E.open,onMountAutoFocus:le=>{le.preventDefault()},onUnmountAutoFocus:xt(a,le=>{var ae;(ae=E.trigger)==null||ae.focus({preventScroll:!0}),le.preventDefault()}),children:r.jsx(x0,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:le=>le.preventDefault(),onDismiss:()=>E.onOpenChange(!1),children:r.jsx(Te,{role:"listbox",id:E.contentId,"data-state":E.open?"open":"closed",dir:E.dir,onContextMenu:le=>le.preventDefault(),...k,...se,onPlaced:()=>ue(!0),ref:_,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:xt(k.onKeyDown,le=>{const ae=le.ctrlKey||le.altKey||le.metaKey;if(le.key==="Tab"&&le.preventDefault(),!ae&&le.key.length===1&&L(le.key),["ArrowUp","ArrowDown","Home","End"].includes(le.key)){let Z=z().filter(xe=>!xe.disabled).map(xe=>xe.ref.current);if(["ArrowUp","End"].includes(le.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(le.key)){const xe=le.target,Ne=Z.indexOf(xe);Z=Z.slice(Ne+1)}setTimeout(()=>$(Z)),le.preventDefault()}})})})})})})});z3.displayName=tV;var sV="SelectItemAlignedPosition",$3=b.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:s,...a}=t,i=bo(bl,n),o=vo(bl,n),[c,u]=b.useState(null),[h,f]=b.useState(null),m=$t(e,_=>f(_)),g=Cp(n),y=b.useRef(!1),v=b.useRef(!0),{viewport:w,selectedItem:N,selectedItemText:k,focusSelectedItem:E}=o,C=b.useCallback(()=>{if(i.trigger&&i.valueNode&&c&&h&&w&&N&&k){const _=i.trigger.getBoundingClientRect(),V=h.getBoundingClientRect(),A=i.valueNode.getBoundingClientRect(),X=k.getBoundingClientRect();if(i.dir!=="rtl"){const xe=X.left-V.left,Ne=A.left-xe,ct=_.left-Ne,ye=_.width+ct,$e=Math.max(ye,V.width),Ze=window.innerWidth-qr,tt=Zh(Ne,[qr,Math.max(qr,Ze-$e)]);c.style.minWidth=ye+"px",c.style.left=tt+"px"}else{const xe=V.right-X.right,Ne=window.innerWidth-A.right-xe,ct=window.innerWidth-_.right-Ne,ye=_.width+ct,$e=Math.max(ye,V.width),Ze=window.innerWidth-qr,tt=Zh(Ne,[qr,Math.max(qr,Ze-$e)]);c.style.minWidth=ye+"px",c.style.right=tt+"px"}const G=g(),z=window.innerHeight-qr*2,ne=w.scrollHeight,ue=window.getComputedStyle(h),K=parseInt(ue.borderTopWidth,10),$=parseInt(ue.paddingTop,10),D=parseInt(ue.borderBottomWidth,10),I=parseInt(ue.paddingBottom,10),ie=K+$+ne+I+D,q=Math.min(N.offsetHeight*5,ie),L=window.getComputedStyle(w),F=parseInt(L.paddingTop,10),re=parseInt(L.paddingBottom,10),ge=_.top+_.height/2-qr,Te=z-ge,se=N.offsetHeight/2,le=N.offsetTop+se,ae=K+$+le,Q=ie-ae;if(ae<=ge){const xe=G.length>0&&N===G[G.length-1].ref.current;c.style.bottom="0px";const Ne=h.clientHeight-w.offsetTop-w.offsetHeight,ct=Math.max(Te,se+(xe?re:0)+Ne+D),ye=ae+ct;c.style.height=ye+"px"}else{const xe=G.length>0&&N===G[0].ref.current;c.style.top="0px";const ct=Math.max(ge,K+w.offsetTop+(xe?F:0)+se)+Q;c.style.height=ct+"px",w.scrollTop=ae-ge+w.offsetTop}c.style.margin=`${qr}px 0`,c.style.minHeight=q+"px",c.style.maxHeight=z+"px",s==null||s(),requestAnimationFrame(()=>y.current=!0)}},[g,i.trigger,i.valueNode,c,h,w,N,k,i.dir,s]);Cs(()=>C(),[C]);const[P,O]=b.useState();Cs(()=>{h&&O(window.getComputedStyle(h).zIndex)},[h]);const U=b.useCallback(_=>{_&&v.current===!0&&(C(),E==null||E(),v.current=!1)},[C,E]);return r.jsx(aV,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:y,onScrollButtonChange:U,children:r.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:P},children:r.jsx(vt.div,{...a,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});$3.displayName=sV;var rV="SelectPopperPosition",s0=b.forwardRef((t,e)=>{const{__scopeSelect:n,align:s="start",collisionPadding:a=qr,...i}=t,o=Ep(n);return r.jsx(HB,{...o,...i,ref:e,align:s,collisionPadding:a,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});s0.displayName=rV;var[aV,Ey]=Lc(bl,{}),r0="SelectViewport",F3=b.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:s,...a}=t,i=vo(r0,n),o=Ey(r0,n),c=$t(e,i.onViewportChange),u=b.useRef(0);return r.jsxs(r.Fragment,{children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),r.jsx(Sp.Slot,{scope:n,children:r.jsx(vt.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:xt(a.onScroll,h=>{const f=h.currentTarget,{contentWrapper:m,shouldExpandOnScrollRef:g}=o;if(g!=null&&g.current&&m){const y=Math.abs(u.current-f.scrollTop);if(y>0){const v=window.innerHeight-qr*2,w=parseFloat(m.style.minHeight),N=parseFloat(m.style.height),k=Math.max(w,N);if(k<v){const E=k+y,C=Math.min(v,E),P=E-C;m.style.height=C+"px",m.style.bottom==="0px"&&(f.scrollTop=P>0?P:0,m.style.justifyContent="flex-end")}}}u.current=f.scrollTop})})})]})});F3.displayName=r0;var B3="SelectGroup",[iV,oV]=Lc(B3),lV=b.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t,a=Zi();return r.jsx(iV,{scope:n,id:a,children:r.jsx(vt.div,{role:"group","aria-labelledby":a,...s,ref:e})})});lV.displayName=B3;var V3="SelectLabel",cV=b.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t,a=oV(V3,n);return r.jsx(vt.div,{id:a.id,...s,ref:e})});cV.displayName=V3;var Gf="SelectItem",[dV,H3]=Lc(Gf),U3=b.forwardRef((t,e)=>{const{__scopeSelect:n,value:s,disabled:a=!1,textValue:i,...o}=t,c=bo(Gf,n),u=vo(Gf,n),h=c.value===s,[f,m]=b.useState(i??""),[g,y]=b.useState(!1),v=$t(e,E=>{var C;return(C=u.itemRefCallback)==null?void 0:C.call(u,E,s,a)}),w=Zi(),N=b.useRef("touch"),k=()=>{a||(c.onValueChange(s),c.onOpenChange(!1))};if(s==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return r.jsx(dV,{scope:n,value:s,disabled:a,textId:w,isSelected:h,onItemTextChange:b.useCallback(E=>{m(C=>C||((E==null?void 0:E.textContent)??"").trim())},[]),children:r.jsx(Sp.ItemSlot,{scope:n,value:s,disabled:a,textValue:f,children:r.jsx(vt.div,{role:"option","aria-labelledby":w,"data-highlighted":g?"":void 0,"aria-selected":h&&g,"data-state":h?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:v,onFocus:xt(o.onFocus,()=>y(!0)),onBlur:xt(o.onBlur,()=>y(!1)),onClick:xt(o.onClick,()=>{N.current!=="mouse"&&k()}),onPointerUp:xt(o.onPointerUp,()=>{N.current==="mouse"&&k()}),onPointerDown:xt(o.onPointerDown,E=>{N.current=E.pointerType}),onPointerMove:xt(o.onPointerMove,E=>{var C;N.current=E.pointerType,a?(C=u.onItemLeave)==null||C.call(u):N.current==="mouse"&&E.currentTarget.focus({preventScroll:!0})}),onPointerLeave:xt(o.onPointerLeave,E=>{var C;E.currentTarget===document.activeElement&&((C=u.onItemLeave)==null||C.call(u))}),onKeyDown:xt(o.onKeyDown,E=>{var P;((P=u.searchRef)==null?void 0:P.current)!==""&&E.key===" "||(GB.includes(E.key)&&k(),E.key===" "&&E.preventDefault())})})})})});U3.displayName=Gf;var wd="SelectItemText",W3=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:s,style:a,...i}=t,o=bo(wd,n),c=vo(wd,n),u=H3(wd,n),h=XB(wd,n),[f,m]=b.useState(null),g=$t(e,k=>m(k),u.onItemTextChange,k=>{var E;return(E=c.itemTextRefCallback)==null?void 0:E.call(c,k,u.value,u.disabled)}),y=f==null?void 0:f.textContent,v=b.useMemo(()=>r.jsx("option",{value:u.value,disabled:u.disabled,children:y},u.value),[u.disabled,u.value,y]),{onNativeOptionAdd:w,onNativeOptionRemove:N}=h;return Cs(()=>(w(v),()=>N(v)),[w,N,v]),r.jsxs(r.Fragment,{children:[r.jsx(vt.span,{id:u.textId,...i,ref:g}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?tu.createPortal(i.children,o.valueNode):null]})});W3.displayName=wd;var K3="SelectItemIndicator",q3=b.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t;return H3(K3,n).isSelected?r.jsx(vt.span,{"aria-hidden":!0,...s,ref:e}):null});q3.displayName=K3;var a0="SelectScrollUpButton",G3=b.forwardRef((t,e)=>{const n=vo(a0,t.__scopeSelect),s=Ey(a0,t.__scopeSelect),[a,i]=b.useState(!1),o=$t(e,s.onScrollButtonChange);return Cs(()=>{if(n.viewport&&n.isPositioned){let c=function(){const h=u.scrollTop>0;i(h)};const u=n.viewport;return c(),u.addEventListener("scroll",c),()=>u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?r.jsx(Y3,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop-u.offsetHeight)}}):null});G3.displayName=a0;var i0="SelectScrollDownButton",J3=b.forwardRef((t,e)=>{const n=vo(i0,t.__scopeSelect),s=Ey(i0,t.__scopeSelect),[a,i]=b.useState(!1),o=$t(e,s.onScrollButtonChange);return Cs(()=>{if(n.viewport&&n.isPositioned){let c=function(){const h=u.scrollHeight-u.clientHeight,f=Math.ceil(u.scrollTop)<h;i(f)};const u=n.viewport;return c(),u.addEventListener("scroll",c),()=>u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?r.jsx(Y3,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop+u.offsetHeight)}}):null});J3.displayName=i0;var Y3=b.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:s,...a}=t,i=vo("SelectScrollButton",n),o=b.useRef(null),c=Cp(n),u=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>u(),[u]),Cs(()=>{var f;const h=c().find(m=>m.ref.current===document.activeElement);(f=h==null?void 0:h.ref.current)==null||f.scrollIntoView({block:"nearest"})},[c]),r.jsx(vt.div,{"aria-hidden":!0,...a,ref:e,style:{flexShrink:0,...a.style},onPointerDown:xt(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(s,50))}),onPointerMove:xt(a.onPointerMove,()=>{var h;(h=i.onItemLeave)==null||h.call(i),o.current===null&&(o.current=window.setInterval(s,50))}),onPointerLeave:xt(a.onPointerLeave,()=>{u()})})}),uV="SelectSeparator",hV=b.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t;return r.jsx(vt.div,{"aria-hidden":!0,...s,ref:e})});hV.displayName=uV;var o0="SelectArrow",fV=b.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t,a=Ep(n),i=bo(o0,n),o=vo(o0,n);return i.open&&o.position==="popper"?r.jsx(UB,{...a,...s,ref:e}):null});fV.displayName=o0;var pV="SelectBubbleInput",Q3=b.forwardRef(({__scopeSelect:t,value:e,...n},s)=>{const a=b.useRef(null),i=$t(s,a),o=C0(e);return b.useEffect(()=>{const c=a.current;if(!c)return;const u=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==e&&f){const m=new Event("change",{bubbles:!0});f.call(c,e),c.dispatchEvent(m)}},[o,e]),r.jsx(vt.select,{...n,style:{...T3,...n.style},ref:i,defaultValue:e})});Q3.displayName=pV;function X3(t){return t===""||t===void 0}function Z3(t){const e=oo(t),n=b.useRef(""),s=b.useRef(0),a=b.useCallback(o=>{const c=n.current+o;e(c),(function u(h){n.current=h,window.clearTimeout(s.current),h!==""&&(s.current=window.setTimeout(()=>u(""),1e3))})(c)},[e]),i=b.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,a,i]}function e4(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=mV(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 mV(t,e){return t.map((n,s)=>t[(e+s)%t.length])}var gV=M3,t4=I3,xV=P3,yV=O3,bV=L3,n4=D3,vV=F3,s4=U3,NV=W3,wV=q3,jV=G3,kV=J3;const rc=gV,ac=xV,Ko=b.forwardRef(({className:t,children:e,...n},s)=>r.jsxs(t4,{ref:s,className:Ft("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...n,children:[e,r.jsx(yV,{asChild:!0,children:r.jsx(pc,{className:"h-4 w-4 opacity-50"})})]}));Ko.displayName=t4.displayName;const qo=b.forwardRef(({className:t,children:e,position:n="popper",...s},a)=>r.jsx(bV,{children:r.jsxs(n4,{ref:a,className:Ft("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,...s,children:[r.jsx(jV,{className:"flex cursor-default items-center justify-center py-1",children:r.jsx(nx,{className:"h-4 w-4"})}),r.jsx(vV,{className:"p-1",children:e}),r.jsx(kV,{className:"flex cursor-default items-center justify-center py-1",children:r.jsx(pc,{className:"h-4 w-4"})})]})}));qo.displayName=n4.displayName;const lr=b.forwardRef(({className:t,children:e,...n},s)=>r.jsxs(s4,{ref:s,className:Ft("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(wV,{children:r.jsx(Qf,{className:"h-4 w-4"})})}),r.jsx(NV,{children:e})]}));lr.displayName=s4.displayName;const zw=["📖","📕","📗","📘","📙","📓","📔","📒","📚","📖"];function SV(t){return t.title==="序言"||t.title.includes("序言")}function $w(t){const e=[];for(const n of t.chapters)for(const s of n.sections)e.push(s.id);return e.length===0?"暂无章节":e.length===1?e[0]:`${e[0]}~${e[e.length-1]}`}function Jg(t){return t.startsWith("part:")?{type:"part",id:t.slice(5)}:t.startsWith("chapter:")?{type:"chapter",id:t.slice(8)}:t.startsWith("section:")?{type:"section",id:t.slice(8)}:null}function CV({parts:t,expandedParts:e,onTogglePart:n,onReorder:s,onReadSection:a,onDeleteSection:i,onAddSectionInPart:o,onAddChapterInPart:c,onDeleteChapter:u,onEditPart:h,onDeletePart:f,onEditChapter:m,selectedSectionIds:g=[],onToggleSectionSelect:y,onShowSectionOrders:v,pinnedSectionIds:w=[]}){const[N,k]=b.useState(null),[E,C]=b.useState(null),P=(z,ne)=>(N==null?void 0:N.type)===z&&(N==null?void 0:N.id)===ne,O=(z,ne)=>(E==null?void 0:E.type)===z&&(E==null?void 0:E.id)===ne,U=b.useCallback(()=>{const z=[];for(const ne of t)for(const ue of ne.chapters)for(const K of ue.sections)z.push({id:K.id,partId:ne.id,partTitle:ne.title,chapterId:ue.id,chapterTitle:ue.title});return z},[t]),_=b.useCallback(async(z,ne,ue,K)=>{var q;z.preventDefault(),z.stopPropagation();const $=z.dataTransfer.getData("text/plain"),D=Jg($);if(!D||D.type===ne&&D.id===ue)return;const I=U(),ie=new Map(I.map(L=>[L.id,L]));if(D.type==="part"&&ne==="part"){const L=t.map(se=>se.id),F=L.indexOf(D.id),re=L.indexOf(ue);if(F===-1||re===-1)return;const ge=[...L];ge.splice(F,1),ge.splice(F<re?re-1:re,0,D.id);const Te=[];for(const se of ge){const le=t.find(ae=>ae.id===se);if(le)for(const ae of le.chapters)for(const Q of ae.sections){const Z=ie.get(Q.id);Z&&Te.push(Z)}}await s(Te);return}if(D.type==="chapter"&&(ne==="chapter"||ne==="section"||ne==="part")){const L=t.find(Z=>Z.chapters.some(xe=>xe.id===D.id)),F=L==null?void 0:L.chapters.find(Z=>Z.id===D.id);if(!L||!F)return;let re,ge,Te=null;if(ne==="section"){const Z=ie.get(ue);if(!Z)return;re=Z.partId,ge=Z.partTitle,Te=ue}else if(ne==="chapter"){const Z=t.find(ct=>ct.chapters.some(ye=>ye.id===ue)),xe=Z==null?void 0:Z.chapters.find(ct=>ct.id===ue);if(!Z||!xe)return;re=Z.id,ge=Z.title;const Ne=I.filter(ct=>ct.chapterId===ue).pop();Te=(Ne==null?void 0:Ne.id)??null}else{const Z=t.find(xe=>xe.id===ue);if(!Z)return;if(re=Z.id,ge=Z.title,Z.chapters[0]){const xe=I.filter(Ne=>Ne.partId===Z.id&&Ne.chapterId===Z.chapters[0].id);Te=((q=xe[xe.length-1])==null?void 0:q.id)??null}}const se=F.sections.map(Z=>Z.id),le=I.filter(Z=>!se.includes(Z.id));let ae=le.length;if(Te){const Z=le.findIndex(xe=>xe.id===Te);Z>=0&&(ae=Z+1)}const Q=se.map(Z=>({...ie.get(Z),partId:re,partTitle:ge,chapterId:F.id,chapterTitle:F.title}));await s([...le.slice(0,ae),...Q,...le.slice(ae)]);return}if(D.type==="section"&&(ne==="section"||ne==="chapter"||ne==="part")){if(!K)return;const{partId:L,partTitle:F,chapterId:re,chapterTitle:ge}=K;let Te;if(ne==="section")Te=I.findIndex(xe=>xe.id===ue);else if(ne==="chapter"){const xe=I.filter(Ne=>Ne.chapterId===ue).pop();Te=xe?I.findIndex(Ne=>Ne.id===xe.id)+1:I.length}else{const xe=t.find(Ne=>Ne.id===ue);if(xe!=null&&xe.chapters[0]){const Ne=I.filter(ye=>ye.partId===xe.id&&ye.chapterId===xe.chapters[0].id),ct=Ne[Ne.length-1];Te=ct?I.findIndex(ye=>ye.id===ct.id)+1:I.length}else Te=I.length}const se=I.findIndex(xe=>xe.id===D.id);if(se===-1)return;const le=I.filter(xe=>xe.id!==D.id),ae=se<Te?Te-1:Te,Z={...I[se],partId:L,partTitle:F,chapterId:re,chapterTitle:ge};le.splice(ae,0,Z),await s(le)}},[t,U,s]),V=(z,ne,ue)=>({onDragEnter:K=>{K.preventDefault(),K.stopPropagation(),K.dataTransfer.dropEffect="move",C({type:z,id:ne})},onDragOver:K=>{K.preventDefault(),K.stopPropagation(),K.dataTransfer.dropEffect="move",C({type:z,id:ne})},onDragLeave:()=>C(null),onDrop:K=>{C(null);const $=Jg(K.dataTransfer.getData("text/plain"));$&&(z==="section"&&$.type==="section"&&$.id===ne||(z==="part"?$.type==="part"?_(K,"part",ne):ue&&_(K,"part",ne,ue):z==="chapter"&&ue?($.type==="section"||$.type==="chapter")&&_(K,"chapter",ne,ue):z==="section"&&ue&&_(K,"section",ne,ue)))}}),A=z=>zw[z%zw.length],X=z=>t.slice(0,z).filter(ne=>!SV(ne)).length,G=z=>r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-gray-500 font-mono text-xs tabular-nums shrink-0 mr-1.5 max-w-[72px] truncate",title:`章节ID: ${z.id}`,children:z.id}),r.jsx("span",{className:"truncate",children:z.title})]});return r.jsx("div",{className:"space-y-3",children:t.map((z,ne)=>{var F,re,ge,Te;const ue=z.title==="序言"||z.title.includes("序言"),K=z.title==="尾声"||z.title.includes("尾声"),$=z.title==="附录"||z.title.includes("附录"),D=O("part",z.id),I=e.includes(z.id),ie=z.chapters.length,q=z.chapters.reduce((se,le)=>se+le.sections.length,0);if(ue&&z.chapters.length===1&&z.chapters[0].sections.length===1){const se=z.chapters[0].sections[0],le=O("section",se.id),ae={partId:z.id,partTitle:z.title,chapterId:z.chapters[0].id,chapterTitle:z.chapters[0].title};return r.jsxs("div",{draggable:!0,onDragStart:Q=>{Q.stopPropagation(),Q.dataTransfer.setData("text/plain","section:"+se.id),Q.dataTransfer.effectAllowed="move",k({type:"section",id:se.id})},onDragEnd:()=>{k(null),C(null)},className:`rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-4 flex items-center justify-between hover:border-[#38bdac]/30 transition-colors cursor-grab active:cursor-grabbing select-none min-h-[40px] ${le?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${P("section",se.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...V("section",se.id,ae),children:[r.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[r.jsx(Ya,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:Q=>Q.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(se.id),onChange:()=>y(se.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-600/50 flex items-center justify-center shrink-0",children:r.jsx(Js,{className:"w-4 h-4 text-gray-400"})}),r.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[z.chapters[0].title," | ",se.title]}),w.includes(se.id)&&r.jsx("span",{title:"已置顶",children:r.jsx(oc,{className:"w-3.5 h-3.5 text-amber-400 fill-amber-400 shrink-0"})})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:Q=>Q.stopPropagation(),onClick:Q=>Q.stopPropagation(),children:[se.price===0||se.isFree?r.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):r.jsxs("span",{className:"text-xs text-gray-500",children:["¥",se.price]}),r.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",se.clickCount??0," · 付款 ",se.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(se.hotScore??0).toFixed(1)," · 第",se.hotRank&&se.hotRank>0?se.hotRank:"-","名"]}),v&&r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>v(se),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(se),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:r.jsx(en,{className:"w-3.5 h-3.5"})}),r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(se),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:r.jsx(ks,{className:"w-3.5 h-3.5"})})]})]})]},z.id)}if(z.title==="2026每日派对干货"||z.title.includes("2026每日派对干货")){const se=O("part",z.id);return r.jsxs("div",{className:`rounded-xl border overflow-hidden transition-all duration-200 ${se?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50 bg-[#1C1C1E]"}`,...V("part",z.id,{partId:z.id,partTitle:z.title,chapterId:((F=z.chapters[0])==null?void 0:F.id)??"",chapterTitle:((re=z.chapters[0])==null?void 0:re.title)??""}),children:[r.jsxs("div",{draggable:!0,onDragStart:le=>{le.stopPropagation(),le.dataTransfer.setData("text/plain","part:"+z.id),le.dataTransfer.effectAllowed="move",k({type:"part",id:z.id})},onDragEnd:()=>{k(null),C(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${P("part",z.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/50"}`,children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsx(Ya,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),r.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#38bdac]/80 flex items-center justify-center text-white font-bold shrink-0",children:"派"}),r.jsxs("div",{children:[r.jsx("h3",{className:"font-bold text-white text-base",children:z.title}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:$w(z)})]})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:le=>le.stopPropagation(),onClick:le=>le.stopPropagation(),children:[o&&r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:r.jsx(Pn,{className:"w-3.5 h-3.5"})}),h&&r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:r.jsx(en,{className:"w-3.5 h-3.5"})}),f&&r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(z),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:r.jsx(ks,{className:"w-3.5 h-3.5"})}),r.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[ie," 章 · ",q," 节"]}),r.jsx("button",{type:"button",draggable:!1,className:"p-1 rounded-md hover:bg-white/10 text-gray-500",title:I?"收起":"展开",onMouseDown:le=>le.stopPropagation(),onClick:le=>{le.stopPropagation(),n(z.id)},children:I?r.jsx(pc,{className:"w-5 h-5"}):r.jsx(Go,{className:"w-5 h-5"})})]})]}),I&&z.chapters.length>0&&r.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:z.chapters.map(le=>r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 w-full",children:[r.jsx("p",{className:"text-xs text-gray-500 pb-1 flex-1",children:le.title}),r.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:ae=>ae.stopPropagation(),children:[m&&r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>m(z,le),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:r.jsx(en,{className:"w-3.5 h-3.5"})}),c&&r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>c(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:r.jsx(Pn,{className:"w-3.5 h-3.5"})}),u&&r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>u(z,le),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:r.jsx(ks,{className:"w-3.5 h-3.5"})})]})]}),r.jsx("div",{className:"space-y-1 pl-2",children:le.sections.map(ae=>{const Q=O("section",ae.id);return r.jsxs("div",{draggable:!0,onDragStart:Z=>{Z.stopPropagation(),Z.dataTransfer.setData("text/plain","section:"+ae.id),Z.dataTransfer.effectAllowed="move",k({type:"section",id:ae.id})},onDragEnd:()=>{k(null),C(null)},onClick:()=>a(ae),className:`flex items-center justify-between py-2 px-3 rounded-lg min-h-[40px] cursor-pointer select-none transition-all duration-200 ${Q?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${P("section",ae.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...V("section",ae.id,{partId:z.id,partTitle:z.title,chapterId:le.id,chapterTitle:le.title}),children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[r.jsx(Ya,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:Z=>Z.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(ae.id),onChange:()=>y(ae.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsx("span",{className:"text-sm text-gray-200 truncate flex items-center min-w-0",children:G(ae)}),w.includes(ae.id)&&r.jsx("span",{title:"已置顶",children:r.jsx(oc,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",onClick:Z=>Z.stopPropagation(),children:[r.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",ae.clickCount??0," · 付款 ",ae.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(ae.hotScore??0).toFixed(1)," · 第",ae.hotRank&&ae.hotRank>0?ae.hotRank:"-","名"]}),v&&r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>v(ae),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(ae),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:r.jsx(en,{className:"w-3.5 h-3.5"})}),r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(ae),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:r.jsx(ks,{className:"w-3.5 h-3.5"})})]})]},ae.id)})})]},le.id))})]},z.id)}if($)return r.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"附录"}),r.jsx("div",{className:"space-y-3",children:z.chapters.map((se,le)=>se.sections.length>0?se.sections.map(ae=>{const Q=O("section",ae.id);return r.jsxs("div",{draggable:!0,onDragStart:Z=>{Z.stopPropagation(),Z.dataTransfer.setData("text/plain","section:"+ae.id),Z.dataTransfer.effectAllowed="move",k({type:"section",id:ae.id})},onDragEnd:()=>{k(null),C(null)},className:`flex justify-between items-center py-2 select-none rounded px-2 -mx-2 group cursor-grab active:cursor-grabbing min-h-[40px] transition-all duration-200 ${Q?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${P("section",ae.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...V("section",ae.id,{partId:z.id,partTitle:z.title,chapterId:se.id,chapterTitle:se.title}),children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[r.jsx(Ya,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:Z=>Z.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(ae.id),onChange:()=>y(ae.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsxs("span",{className:"text-sm text-gray-300 truncate",children:["附录",le+1," | ",se.title," | ",ae.title]}),w.includes(ae.id)&&r.jsx("span",{title:"已置顶",children:r.jsx(oc,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",ae.clickCount??0," · 付款 ",ae.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(ae.hotScore??0).toFixed(1)," · 第",ae.hotRank&&ae.hotRank>0?ae.hotRank:"-","名"]}),v&&r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>v(ae),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),r.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>a(ae),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:r.jsx(en,{className:"w-3.5 h-3.5"})}),r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>i(ae),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:r.jsx(ks,{className:"w-3.5 h-3.5"})})]})]}),r.jsx(Go,{className:"w-4 h-4 text-gray-500 shrink-0"})]},ae.id)}):r.jsxs("div",{className:"flex justify-between items-center py-2 select-none hover:bg-[#162840]/50 rounded px-2 -mx-2",children:[r.jsxs("span",{className:"text-sm text-gray-500",children:["附录",le+1," | ",se.title,"(空)"]}),r.jsx(Go,{className:"w-4 h-4 text-gray-500 shrink-0"})]},se.id))})]},z.id);if(K&&z.chapters.length===1&&z.chapters[0].sections.length===1){const se=z.chapters[0].sections[0],le=O("section",se.id),ae={partId:z.id,partTitle:z.title,chapterId:z.chapters[0].id,chapterTitle:z.chapters[0].title};return r.jsxs("div",{draggable:!0,onDragStart:Q=>{Q.stopPropagation(),Q.dataTransfer.setData("text/plain","section:"+se.id),Q.dataTransfer.effectAllowed="move",k({type:"section",id:se.id})},onDragEnd:()=>{k(null),C(null)},className:`rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-4 flex items-center justify-between hover:border-[#38bdac]/30 transition-colors cursor-grab active:cursor-grabbing select-none min-h-[40px] ${le?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${P("section",se.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...V("section",se.id,ae),children:[r.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[r.jsx(Ya,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:Q=>Q.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(se.id),onChange:()=>y(se.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-600/50 flex items-center justify-center shrink-0",children:r.jsx(Js,{className:"w-4 h-4 text-gray-400"})}),r.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[z.chapters[0].title," | ",se.title]})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:Q=>Q.stopPropagation(),onClick:Q=>Q.stopPropagation(),children:[se.price===0||se.isFree?r.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):r.jsxs("span",{className:"text-xs text-gray-500",children:["¥",se.price]}),r.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",se.clickCount??0," · 付款 ",se.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(se.hotScore??0).toFixed(1)," · 第",se.hotRank&&se.hotRank>0?se.hotRank:"-","名"]}),v&&r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>v(se),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(se),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:r.jsx(en,{className:"w-3.5 h-3.5"})}),r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(se),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:r.jsx(ks,{className:"w-3.5 h-3.5"})})]})]})]},z.id)}return K?r.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"尾声"}),r.jsx("div",{className:"space-y-3",children:z.chapters.map(se=>se.sections.map(le=>{const ae=O("section",le.id);return r.jsxs("div",{draggable:!0,onDragStart:Q=>{Q.stopPropagation(),Q.dataTransfer.setData("text/plain","section:"+le.id),Q.dataTransfer.effectAllowed="move",k({type:"section",id:le.id})},onDragEnd:()=>{k(null),C(null)},className:`flex justify-between items-center py-2 select-none rounded px-2 -mx-2 cursor-grab active:cursor-grabbing min-h-[40px] transition-all duration-200 ${ae?"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:z.id,partTitle:z.title,chapterId:se.id,chapterTitle:se.title}),children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[r.jsx(Ya,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:Q=>Q.stopPropagation(),children:r.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]"})}),r.jsxs("span",{className:"text-sm text-gray-300",children:[se.title," | ",le.title]})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",le.clickCount??0," · 付款 ",le.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(le.hotScore??0).toFixed(1)," · 第",le.hotRank&&le.hotRank>0?le.hotRank:"-","名"]}),v&&r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>v(le),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(le),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:r.jsx(en,{className:"w-3.5 h-3.5"})}),r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(le),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:r.jsx(ks,{className:"w-3.5 h-3.5"})})]})]})]},le.id)}))})]},z.id):r.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",z.id,{partId:z.id,partTitle:z.title,chapterId:((ge=z.chapters[0])==null?void 0:ge.id)??"",chapterTitle:((Te=z.chapters[0])==null?void 0:Te.title)??""}),children:[r.jsxs("div",{draggable:!0,onDragStart:se=>{se.stopPropagation(),se.dataTransfer.setData("text/plain","part:"+z.id),se.dataTransfer.effectAllowed="move",k({type:"part",id:z.id})},onDragEnd:()=>{k(null),C(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${P("part",z.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] rounded-xl shadow-xl shadow-[#38bdac]/20":"hover:bg-[#162840]/50"}`,children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsx(Ya,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),r.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#38bdac] flex items-center justify-center text-lg shadow-lg shadow-[#38bdac]/30 shrink-0",children:A(X(ne))}),r.jsxs("div",{children:[r.jsx("h3",{className:"font-bold text-white text-base",children:z.title}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:$w(z)})]})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:se=>se.stopPropagation(),onClick:se=>se.stopPropagation(),children:[o&&r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:r.jsx(Pn,{className:"w-3.5 h-3.5"})}),h&&r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:r.jsx(en,{className:"w-3.5 h-3.5"})}),f&&r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(z),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:r.jsx(ks,{className:"w-3.5 h-3.5"})}),r.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[ie," 章 · ",q," 节"]}),r.jsx("button",{type:"button",draggable:!1,className:"p-1 rounded-md hover:bg-white/10 text-gray-500",title:I?"收起":"展开",onMouseDown:se=>se.stopPropagation(),onClick:se=>{se.stopPropagation(),n(z.id)},children:I?r.jsx(pc,{className:"w-5 h-5"}):r.jsx(Go,{className:"w-5 h-5"})})]})]}),I&&r.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:z.chapters.map(se=>{const le=O("chapter",se.id);return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 w-full",children:[r.jsxs("div",{draggable:!0,onDragStart:ae=>{ae.stopPropagation(),ae.dataTransfer.setData("text/plain","chapter:"+se.id),ae.dataTransfer.effectAllowed="move",k({type:"chapter",id:se.id})},onDragEnd:()=>{k(null),C(null)},onDragEnter:ae=>{ae.preventDefault(),ae.stopPropagation(),ae.dataTransfer.dropEffect="move",C({type:"chapter",id:se.id})},onDragOver:ae=>{ae.preventDefault(),ae.stopPropagation(),ae.dataTransfer.dropEffect="move",C({type:"chapter",id:se.id})},onDragLeave:()=>C(null),onDrop:ae=>{C(null);const Q=Jg(ae.dataTransfer.getData("text/plain"));if(!Q)return;const Z={partId:z.id,partTitle:z.title,chapterId:se.id,chapterTitle:se.title};(Q.type==="section"||Q.type==="chapter")&&_(ae,"chapter",se.id,Z)},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",se.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/30"}`,children:[r.jsx(Ya,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),r.jsx("p",{className:"text-xs text-gray-500 pb-1 flex-1",children:se.title})]}),r.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:ae=>ae.stopPropagation(),children:[m&&r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>m(z,se),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:r.jsx(en,{className:"w-3.5 h-3.5"})}),c&&r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>c(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:r.jsx(Pn,{className:"w-3.5 h-3.5"})}),u&&r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>u(z,se),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:r.jsx(ks,{className:"w-3.5 h-3.5"})})]})]}),r.jsx("div",{className:"space-y-1 pl-2",children:se.sections.map(ae=>{const Q=O("section",ae.id);return r.jsxs("div",{draggable:!0,onDragStart:Z=>{Z.stopPropagation(),Z.dataTransfer.setData("text/plain","section:"+ae.id),Z.dataTransfer.effectAllowed="move",k({type:"section",id:ae.id})},onDragEnd:()=>{k(null),C(null)},className:`flex items-center justify-between py-2 px-3 rounded-lg group cursor-grab active:cursor-grabbing select-none min-h-[40px] transition-all duration-200 ${Q?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${P("section",ae.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] shadow-lg":"hover:bg-[#162840]/50"}`,...V("section",ae.id,{partId:z.id,partTitle:z.title,chapterId:se.id,chapterTitle:se.title}),children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:Z=>Z.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(ae.id),onChange:()=>y(ae.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsx(Ya,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),r.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${ae.price===0||ae.isFree?"border-2 border-[#38bdac] bg-transparent":"bg-gray-500"}`}),r.jsx("span",{className:"text-sm text-gray-200 truncate flex items-center min-w-0",children:G(ae)}),w.includes(ae.id)&&r.jsx("span",{title:"已置顶",children:r.jsx(oc,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:Z=>Z.stopPropagation(),onClick:Z=>Z.stopPropagation(),children:[ae.isNew&&r.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"NEW"}),ae.price===0||ae.isFree?r.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):r.jsxs("span",{className:"text-xs text-gray-500",children:["¥",ae.price]}),r.jsxs("span",{className:"text-[10px] text-gray-500",title:"点击次数 · 付款笔数",children:["点击 ",ae.clickCount??0," · 付款 ",ae.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(ae.hotScore??0).toFixed(1)," · 第",ae.hotRank&&ae.hotRank>0?ae.hotRank:"-","名"]}),v&&r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>v(ae),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5 shrink-0",children:"付款记录"}),r.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(ae),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:r.jsx(en,{className:"w-3.5 h-3.5"})}),r.jsx(Y,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(ae),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:r.jsx(ks,{className:"w-3.5 h-3.5"})})]})]})]},ae.id)})})]},se.id)})})]},z.id)})})}function EV(t){var a;const e=new URLSearchParams;e.set("page",String(t.page)),e.set("limit",String(t.limit)),(a=t==null?void 0:t.keyword)!=null&&a.trim()&&e.set("keyword",t.keyword.trim());const n=e.toString(),s=n?`/api/admin/ckb/devices?${n}`:"/api/admin/ckb/devices";return De(s)}function TV(t){return De(`/api/db/person?personId=${encodeURIComponent(t)}`)}function MV(t){var s;const e=new URLSearchParams;e.set("page",String(t.page)),e.set("limit",String(t.limit)),(s=t==null?void 0:t.keyword)!=null&&s.trim()&&e.set("keyword",t.keyword.trim());const n=e.toString();return De(n?`/api/admin/ckb/plans?${n}`:"/api/admin/ckb/plans")}const r4=11,Fw={personId:"",name:"",boundUserId:"",aliases:"",label:"",sceneId:r4,ckbApiKey:"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:"phone",remarkFormat:"",addFriendInterval:1,startTime:"06:00",endTime:"22:00",deviceGroups:""};function AV({open:t,onOpenChange:e,editingPerson:n,onSubmit:s}){var $;const a=!!n,[i,o]=b.useState(Fw),[c,u]=b.useState(!1),[h,f]=b.useState(!1),[m,g]=b.useState([]),[y,v]=b.useState(!1),[w,N]=b.useState(""),[k,E]=b.useState([]),[C,P]=b.useState(!1),[O,U]=b.useState(""),[_,V]=b.useState(!1),[A,X]=b.useState({});b.useEffect(()=>{t&&(N(""),o(n?{personId:n.personId??n.name??"",name:n.name??"",boundUserId:n.userId??"",aliases:n.aliases??"",label:n.label??"",sceneId:r4,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??""}:{...Fw}),X({}),m.length===0&&G(""),k.length===0&&z(""))},[t,n]);const G=async D=>{v(!0);try{const I=await EV({page:1,limit:50,keyword:D});I!=null&&I.success&&Array.isArray(I.devices)?g(I.devices):I!=null&&I.error&&oe.error(I.error)}catch(I){oe.error(I instanceof Error?I.message:"加载设备列表失败")}finally{v(!1)}},z=async D=>{P(!0);try{const I=await MV({page:1,limit:100,keyword:D});I!=null&&I.success&&Array.isArray(I.plans)?E(I.plans):I!=null&&I.error&&oe.error(I.error)}catch{oe.error("加载计划列表失败")}finally{P(!1)}},ne=D=>{const I=Array.isArray(D.deviceGroups)?D.deviceGroups.map(String).join(","):"";o(ie=>({...ie,ckbApiKey:D.apiKey||"",greeting:D.greeting||ie.greeting,tips:D.tips||ie.tips,remarkType:D.remarkType||ie.remarkType,remarkFormat:D.remarkFormat||ie.remarkFormat,addFriendInterval:D.addInterval||ie.addFriendInterval,startTime:D.startTime||ie.startTime,endTime:D.endTime||ie.endTime,deviceGroups:I||ie.deviceGroups})),V(!1),oe.success(`已选择计划「${D.name}」,参数已覆盖`)},ue=O.trim()?k.filter(D=>(D.name||"").includes(O.trim())||String(D.id).includes(O.trim())):k,K=async()=>{var q;const D={};(!i.name||!String(i.name).trim())&&(D.name="请填写名称");const I=i.addFriendInterval;if((typeof I!="number"||I<1)&&(D.addFriendInterval="添加间隔至少为 1 分钟"),(((q=i.deviceGroups)==null?void 0:q.split(",").map(L=>L.trim()).filter(Boolean))??[]).length===0&&(D.deviceGroups="请至少选择 1 台设备"),X(D),Object.keys(D).length>0){oe.error(D.name||D.addFriendInterval||D.deviceGroups||"请完善必填项");return}u(!0);try{await s(i),e(!1)}catch(L){oe.error(L instanceof Error?L.message:"保存失败")}finally{u(!1)}};return r.jsx(Ht,{open:t,onOpenChange:e,children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-y-auto",children:[r.jsxs(Ut,{children:[r.jsx(Wt,{className:"text-[#38bdac]",children:a?"编辑人物":"添加人物 — 存客宝 API 获客"}),r.jsx(Qh,{className:"text-gray-400 text-sm",children:a?"修改后同步到存客宝计划":"添加时自动生成 token并同步创建存客宝场景获客计划"})]}),r.jsxs("div",{className:"space-y-6 py-2",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-3",children:"基础信息"}),r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs(ee,{className:"text-gray-400 text-xs",children:["名称 ",r.jsx("span",{className:"text-red-400",children:"*"})]}),r.jsx(ce,{className:`bg-[#0a1628] text-white ${A.name?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,placeholder:"如 卡若",value:i.name,onChange:D=>{o(I=>({...I,name:D.target.value})),A.name&&X(I=>({...I,name:void 0}))}}),A.name&&r.jsx("p",{className:"text-xs text-red-400",children:A.name})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"人物ID可选"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"自动生成",value:i.personId,onChange:D=>o(I=>({...I,personId:D.target.value})),disabled:a})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"标签(身份/角色)"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 超级个体",value:i.label,onChange:D=>o(I=>({...I,label:D.target.value}))})]}),r.jsxs("div",{className:"space-y-1.5 col-span-3",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"绑定会员用户 ID可选与「用户管理」中用户 id 一致)"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-xs",placeholder:"留空则不绑定;填写后获客统计可与超级个体对齐",value:i.boundUserId,onChange:D=>o(I=>({...I,boundUserId:D.target.value.trim()}))}),r.jsx("p",{className:"text-[11px] text-gray-500",children:"保存前请在用户管理中核对 id同一会员只能绑定一个 @人物。"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"别名(逗号分隔,@ 可匹配)"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 卡卡, 若若",value:i.aliases,onChange:D=>o(I=>({...I,aliases:D.target.value}))})]})]})]}),r.jsxs("div",{className:"border-t border-gray-700/50 pt-5",children:[r.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-4",children:"存客宝 API 获客配置"}),r.jsxs("div",{className:"grid grid-cols-2 gap-x-8 gap-y-4",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5 relative",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"选择存客宝获客计划"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("div",{className:"flex-1 flex items-center bg-[#0a1628] border border-gray-700 rounded-md px-3 py-2 cursor-pointer hover:border-[#38bdac]/60 text-sm",onClick:()=>V(!_),children:i.ckbApiKey?r.jsx("span",{className:"text-white truncate",children:(($=k.find(D=>D.apiKey===i.ckbApiKey))==null?void 0:$.name)||`获客计划 (${i.ckbApiKey.slice(0,8)}…)`}):r.jsx("span",{className:"text-gray-500",children:"点击选择已有计划 / 新建时自动创建"})}),r.jsx(Y,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-200 shrink-0",onClick:()=>{z(O),V(!0)},disabled:C,children:C?"加载...":"刷新"})]}),_&&r.jsxs("div",{className:"absolute z-50 top-full left-0 right-0 mt-1 bg-[#0b1828] border border-gray-700 rounded-lg shadow-xl max-h-64 flex flex-col",children:[r.jsx("div",{className:"p-2 border-b border-gray-700/60",children:r.jsx(ce,{className:"bg-[#050c18] border-gray-700 text-white h-8 text-xs",placeholder:"搜索计划名称...",value:O,onChange:D=>U(D.target.value),onKeyDown:D=>{D.key==="Enter"&&z(O)},autoFocus:!0})}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:ue.length===0?r.jsx("div",{className:"text-center py-4 text-gray-500 text-xs",children:C?"加载中...":"暂无计划"}):ue.map(D=>r.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:()=>ne(D),children:[r.jsxs("div",{className:"truncate",children:[r.jsx("span",{className:"font-medium",children:D.name}),r.jsxs("span",{className:"text-xs text-gray-500 ml-2",children:["ID:",String(D.id)]})]}),D.enabled?r.jsx("span",{className:"text-[10px] text-green-400 bg-green-400/10 px-1.5 rounded shrink-0 ml-2",children:"启用"}):r.jsx("span",{className:"text-[10px] text-gray-500 bg-gray-500/10 px-1.5 rounded shrink-0 ml-2",children:"停用"})]},String(D.id)))}),r.jsx("div",{className:"p-2 border-t border-gray-700/60 flex justify-end",children:r.jsx(Y,{type:"button",size:"sm",variant:"ghost",className:"text-gray-400 h-7 text-xs",onClick:()=>V(!1),children:"关闭"})})]}),r.jsx("p",{className:"text-xs text-gray-500",children:"选择计划后自动覆盖下方参数。新建人物时若不选择则自动创建新计划。"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs(ee,{className:"text-gray-400 text-xs",children:["选择设备 ",r.jsx("span",{className:"text-red-400",children:"*"})]}),r.jsxs("div",{className:`flex gap-2 rounded-md border ${A.deviceGroups?"border-red-500":"border-gray-700"}`,children:[r.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)}),r.jsx(Y,{type:"button",variant:"outline",className:"border-0 border-l border-inherit rounded-r-md text-gray-200",onClick:()=>f(!0),children:"选择"})]}),A.deviceGroups?r.jsx("p",{className:"text-xs text-red-400",children:A.deviceGroups}):r.jsx("p",{className:"text-xs text-gray-500",children:"从存客宝设备列表中选择,至少选择 1 台设备参与获客计划。"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"好友备注"}),r.jsxs(rc,{value:i.remarkType,onValueChange:D=>o(I=>({...I,remarkType:D})),children:[r.jsx(Ko,{className:"bg-[#0a1628] border-gray-700 text-white",children:r.jsx(ac,{placeholder:"选择备注类型"})}),r.jsxs(qo,{children:[r.jsx(lr,{value:"phone",children:"手机号"}),r.jsx(lr,{value:"nickname",children:"昵称"}),r.jsx(lr,{value:"source",children:"来源"})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"备注格式(手机号+标签标签不超过6字"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 {手机号}-{来源标签}总长不超过10字",value:i.remarkFormat,onChange:D=>o(I=>({...I,remarkFormat:D.target.value}))}),r.jsx("p",{className:"text-xs text-gray-500",children:"格式:手机号+来源标签标签≤6字总长≤10字"})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"打招呼语"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"你好,请通过",value:i.greeting,onChange:D=>o(I=>({...I,greeting:D.target.value}))})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"添加间隔(分钟)"}),r.jsx(ce,{type:"number",min:1,className:`bg-[#0a1628] text-white ${A.addFriendInterval?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,value:i.addFriendInterval,onChange:D=>{o(I=>({...I,addFriendInterval:Number(D.target.value)||1})),A.addFriendInterval&&X(I=>({...I,addFriendInterval:void 0}))}}),A.addFriendInterval&&r.jsx("p",{className:"text-xs text-red-400",children:A.addFriendInterval})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"允许加人时间段"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ce,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:i.startTime,onChange:D=>o(I=>({...I,startTime:D.target.value}))}),r.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"至"}),r.jsx(ce,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:i.endTime,onChange:D=>o(I=>({...I,endTime:D.target.value}))})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"获客成功提示"}),r.jsx(cl,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[72px] resize-none",placeholder:"请注意消息,稍后加你微信",value:i.tips,onChange:D=>o(I=>({...I,tips:D.target.value}))})]})]})]})]})]}),r.jsxs(xn,{className:"gap-3 pt-2",children:[r.jsx(Y,{variant:"outline",onClick:()=>e(!1),className:"border-gray-600 text-gray-300",children:"取消"}),r.jsx(Y,{onClick:K,disabled:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:c?"保存中...":a?"保存":"添加"})]}),h&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:r.jsxs("div",{className:"w-full max-w-3xl max-h-[80vh] bg-[#0b1828] border border-gray-700 rounded-xl shadow-xl flex flex-col",children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-gray-700/60",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-medium text-white",children:"选择设备"}),r.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:"勾选需要参与本计划的设备,可多选"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Y,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>{const D=m.map(q=>String(q.id??"")),I=i.deviceGroups?i.deviceGroups.split(",").map(q=>q.trim()).filter(Boolean):[],ie=D.length>0&&D.every(q=>I.includes(q));o(q=>({...q,deviceGroups:ie?"":D.join(",")})),!ie&&D.length>0&&X(q=>({...q,deviceGroups:void 0}))},children:(()=>{const D=m.map(ie=>String(ie.id??"")),I=i.deviceGroups?i.deviceGroups.split(",").map(ie=>ie.trim()).filter(Boolean):[];return D.length>0&&D.every(ie=>I.includes(ie))?"取消全选":"全选"})()}),r.jsx(ce,{className:"bg-[#050c18] border-gray-700 text-white h-8 w-52",placeholder:"搜索备注/微信号/IMEI",value:w,onChange:D=>N(D.target.value),onKeyDown:D=>{D.key==="Enter"&&G(w)}}),r.jsx(Y,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>G(w),disabled:y,children:"刷新"}),r.jsx(Y,{type:"button",size:"icon",variant:"outline",className:"border-gray-600 text-gray-300 h-8 w-8",onClick:()=>f(!1),children:"✕"})]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:y?r.jsx("div",{className:"flex h-full items-center justify-center text-gray-400 text-sm",children:"正在加载设备列表…"}):m.length===0?r.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 text-sm",children:"暂无设备数据,请检查存客宝账号与开放 API 配置"}):r.jsx("div",{className:"p-4 space-y-2",children:m.map(D=>{const I=String(D.id??""),ie=i.deviceGroups?i.deviceGroups.split(",").map(F=>F.trim()).filter(Boolean):[],q=ie.includes(I),L=()=>{let F;q?F=ie.filter(re=>re!==I):F=[...ie,I],o(re=>({...re,deviceGroups:F.join(",")})),F.length>0&&X(re=>({...re,deviceGroups:void 0}))};return r.jsxs("label",{className:"flex items-center gap-3 rounded-lg border border-gray-700/60 bg-[#050c18] px-3 py-2 cursor-pointer hover:border-[#38bdac]/70",children:[r.jsx("input",{type:"checkbox",className:"h-4 w-4 accent-[#38bdac]",checked:q,onChange:L}),r.jsxs("div",{className:"flex flex-col min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-white truncate max-w-xs",children:D.memo||D.wechatId||`设备 ${I}`}),D.status==="online"&&r.jsx("span",{className:"rounded-full bg-emerald-500/20 text-emerald-400 text-[11px] px-2 py-0.5",children:"在线"}),D.status==="offline"&&r.jsx("span",{className:"rounded-full bg-gray-600/20 text-gray-400 text-[11px] px-2 py-0.5",children:"离线"})]}),r.jsxs("div",{className:"text-[11px] text-gray-400 mt-0.5",children:[r.jsxs("span",{className:"mr-3",children:["ID: ",I]}),D.wechatId&&r.jsxs("span",{className:"mr-3",children:["微信号: ",D.wechatId]}),typeof D.totalFriend=="number"&&r.jsxs("span",{children:["好友数: ",D.totalFriend]})]})]})]},I)})})}),r.jsxs("div",{className:"flex justify-between items-center px-5 py-3 border-t border-gray-700/60",children:[r.jsxs("span",{className:"text-xs text-gray-400",children:["已选择"," ",i.deviceGroups?i.deviceGroups.split(",").filter(Boolean).length:0," ","台设备"]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Y,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 h-8 px-4",onClick:()=>f(!1),children:"取消"}),r.jsx(Y,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da396] text-white h-8 px-4",onClick:()=>f(!1),children:"确定"})]})]})]})})]})})}function IV(t,e){const n=new Map;for(const i of t){const o=i.partId||"part-1",c=i.partTitle||"未分类",u=i.chapterId||"chapter-1",h=i.chapterTitle||"未分类";n.has(o)||n.set(o,{id:o,title:c,chapters:new Map});const f=n.get(o);f.chapters.has(u)||f.chapters.set(u,{id:u,title:h,sections:[]}),f.chapters.get(u).sections.push({id:i.id,mid:i.mid,title:i.title,price:i.price??1,filePath:i.filePath,isFree:i.isFree,isNew:i.isNew,clickCount:i.clickCount??0,payCount:i.payCount??0,hotScore:i.hotScore??0,hotRank:e.get(i.id)??0})}const s=Array.from(n.values()).map(i=>({...i,chapters:Array.from(i.chapters.values())})),a=new Map;for(let i=0;i<t.length;i++){const o=t[i].partId||"part-1";a.has(o)||a.set(o,i)}return s.sort((i,o)=>{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 RV(){var El,wi,Ao;const t=Aa(),[e,n]=b.useState([]),[s,a]=b.useState(!0),[i,o]=b.useState([]),[c,u]=b.useState(null),[h,f]=b.useState(!1),[m,g]=b.useState(!1),[y,v]=b.useState(!1),[w,N]=b.useState(""),[k,E]=b.useState([]),[C,P]=b.useState(!1),[O,U]=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}),[_,V]=b.useState(null),[A,X]=b.useState(!1),[G,z]=b.useState(!1),[ne,ue]=b.useState(null),[K,$]=b.useState(!1),[D,I]=b.useState([]),[ie,q]=b.useState(!1),[L,F]=b.useState(""),[re,ge]=b.useState(""),[Te,se]=b.useState(!1),[le,ae]=b.useState(""),[Q,Z]=b.useState(!1),[xe,Ne]=b.useState(null),[ct,ye]=b.useState(!1),[$e,Ze]=b.useState(!1),[tt,_e]=b.useState({readWeight:.5,recencyWeight:.3,payWeight:.2}),[st,kt]=b.useState(!1),[Pt,Ot]=b.useState(!1),[Mn,Dn]=b.useState(1),[gs,zs]=b.useState([]),[ts,xs]=b.useState(!1),[Gt,ln]=b.useState([]),[As,Is]=b.useState(!1),[ns,W]=b.useState(20),[Qe,mt]=b.useState(!1),[Bt,gt]=b.useState(!1),[ht,At]=b.useState([]),[It,sn]=b.useState([]),[Wn,pe]=b.useState([]),[be,vn]=b.useState(!1),[hn,Mr]=b.useState(1),[Pa,Ar]=b.useState(20),[Oa,Ir]=b.useState(0),[No,pr]=b.useState(1),[Rr,Pr]=b.useState(""),[mr,Or]=b.useState(!1),[mi,ea]=b.useState(null),[St,ss]=b.useState({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",pagePath:""}),[Lr,La]=b.useState(!1),[jl,$s]=b.useState(!1),[wo,Qs]=b.useState(null),[Xs,ta]=b.useState(null),[Vt,na]=b.useState({}),[jo,gi]=b.useState(!1),[sa,Dc]=b.useState(""),[xi,yi]=b.useState(""),[Rs,kl]=b.useState([]),[fn,_c]=b.useState(0),[ra,zc]=b.useState(1),[Fs,Da]=b.useState(!1),[Zs,er]=b.useState(""),ko=b.useRef(null),Dr=b.useCallback(async(T,B)=>{var ft;const he=new FormData;he.append("file",T),he.append("folder",B);const Je=await(await fetch(xc("/api/upload"),{method:"POST",body:he,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((ft=Je==null?void 0:Je.data)==null?void 0:ft.url)||(Je==null?void 0:Je.url)||""},[]),aa=b.useCallback(T=>Dr(T,"book-images"),[Dr]),bi=b.useCallback(T=>{const B=T.type.startsWith("video/")?"book-videos":"book-attachments";return Dr(T,B)},[Dr]),vi=b.useMemo(()=>{const T=new Map;return gs.forEach((B,he)=>{T.set(B.id,he+1)}),T},[gs]),An=IV(e,vi),Sl=e.length,ia=10,Ct=Math.max(1,Math.ceil(gs.length/ia)),oa=gs.slice((Mn-1)*ia,Mn*ia),Nn=async()=>{a(!0);try{const T=await De("/api/db/book?action=list",{cache:"no-store"});n(Array.isArray(T==null?void 0:T.sections)?T.sections:[])}catch(T){console.error(T),n([])}finally{a(!1)}},tr=async()=>{xs(!0);try{const T=await De("/api/db/book?action=ranking",{cache:"no-store"}),B=Array.isArray(T==null?void 0:T.sections)?T.sections:[];zs(B);const he=B.filter(ke=>ke.isPinned).map(ke=>ke.id);ln(he)}catch(T){console.error(T),zs([])}finally{xs(!1)}};b.useEffect(()=>{Nn(),tr()},[]);const So=T=>{o(B=>B.includes(T)?B.filter(he=>he!==T):[...B,T])},Co=b.useCallback(T=>{const B=e,he=T.flatMap(ke=>{const Je=B.find(ft=>ft.id===ke.id);return Je?[{...Je,partId:ke.partId,partTitle:ke.partTitle,chapterId:ke.chapterId,chapterTitle:ke.chapterTitle}]:[]});return n(he),Jt("/api/db/book",{action:"reorder",items:T}).then(ke=>{ke&&ke.success===!1&&(n(B),oe.error("排序失败: "+(ke&&typeof ke=="object"&&"error"in ke?ke.error:"未知错误")))}).catch(ke=>{n(B),console.error("排序失败:",ke),oe.error("排序失败: "+(ke instanceof Error?ke.message:"网络或服务异常"))}),Promise.resolve()},[e]),Eo=async T=>{if(confirm(`确定要删除章节「${T.title}」吗?此操作不可恢复。`))try{const B=await ai(`/api/db/book?id=${encodeURIComponent(T.id)}`);B&&B.success!==!1?(oe.success("已删除"),Nn(),tr()):oe.error("删除失败: "+(B&&typeof B=="object"&&"error"in B?B.error:"未知错误"))}catch(B){console.error(B),oe.error("删除失败")}},_a=b.useCallback(async()=>{kt(!0);try{const T=await De("/api/db/config/full?key=article_ranking_weights",{cache:"no-store"}),B=T&&T.data;B&&typeof B.readWeight=="number"&&typeof B.recencyWeight=="number"&&typeof B.payWeight=="number"&&_e({readWeight:Math.max(0,Math.min(1,B.readWeight)),recencyWeight:Math.max(0,Math.min(1,B.recencyWeight)),payWeight:Math.max(0,Math.min(1,B.payWeight))})}catch{}finally{kt(!1)}},[]);b.useEffect(()=>{$e&&_a()},[$e,_a]);const Ni=async()=>{const{readWeight:T,recencyWeight:B,payWeight:he}=tt,ke=T+B+he;if(Math.abs(ke-1)>.001){oe.error("三个权重之和必须等于 1");return}Ot(!0);try{const Je=await Et("/api/db/config",{key:"article_ranking_weights",value:{readWeight:T,recencyWeight:B,payWeight:he},description:"文章排名算法权重"});Je&&Je.success!==!1?(oe.success("排名权重已保存"),Ze(!1),Nn(),tr()):oe.error("保存失败: "+(Je&&typeof Je=="object"&&"error"in Je?Je.error:""))}catch(Je){console.error(Je),oe.error("保存失败")}finally{Ot(!1)}},nr=b.useCallback(async()=>{Is(!0);try{const T=await De("/api/db/config/full?key=pinned_section_ids",{cache:"no-store"}),B=T&&T.data;Array.isArray(B)&&ln(B)}catch{}finally{Is(!1)}},[]),Kn=b.useCallback(async()=>{try{const T=await De("/api/db/persons");T!=null&&T.success&&T.persons&&At(T.persons.map(B=>{const he=B.deviceGroups,ke=Array.isArray(he)?he.join(","):he??"";return{id:B.token??B.personId??"",personId:B.personId,name:B.name,personSource:B.personSource??"",userId:B.userId,aliases:B.aliases??"",label:B.label??"",ckbApiKey:B.ckbApiKey??"",ckbPlanId:B.ckbPlanId,remarkType:B.remarkType,remarkFormat:B.remarkFormat,addFriendInterval:B.addFriendInterval,startTime:B.startTime,endTime:B.endTime,deviceGroups:ke}}))}catch{}},[]),qn=b.useCallback(async()=>{try{const T=await De("/api/db/link-tags");T!=null&&T.success&&T.linkTags&&sn(T.linkTags.map(B=>({id:B.tagId,label:B.label,url:B.url,type:B.type||"url",appId:B.appId||"",pagePath:B.pagePath||""})))}catch{}},[]),la=b.useCallback(async()=>{try{const T=await De("/api/db/config/full?key=ckb_lead_webhook_url",{cache:"no-store"});T!=null&&T.success&&typeof T.data=="string"&&er(T.data)}catch{}},[]),ca=b.useCallback(async()=>{try{const T=await De("/api/db/ckb-person-leads");if(T!=null&&T.success&&T.byPerson){const B={};for(const he of T.byPerson)B[he.token]=he.total;na(B)}}catch{}},[]),rs=b.useCallback(async(T,B,he=1)=>{Dc(T),yi(B),gi(!0),zc(he),Da(!0);try{const ke=await De(`/api/db/ckb-person-leads?token=${encodeURIComponent(T)}&page=${he}&pageSize=20`);ke!=null&&ke.success?(kl(ke.records||[]),_c(ke.total||0)):oe.error((ke==null?void 0:ke.error)||"加载获客详情失败")}catch(ke){oe.error(ke instanceof Error?ke.message:"加载获客详情失败")}finally{Da(!1)}},[]),za=b.useCallback(async()=>{vn(!0);try{const T=new URLSearchParams({page:String(hn),pageSize:String(Pa)}),B=Rr.trim();B&&T.set("search",B);const he=await De(`/api/db/link-tags?${T.toString()}`);if(he!=null&&he.success){const ke=Array.isArray(he.linkTags)?he.linkTags:[];pe(ke.map(Je=>({id:Je.tagId,label:Je.label,aliases:Je.aliases||"",url:Je.url,type:Je.type||"url",appId:Je.appId||"",pagePath:Je.pagePath||""}))),Ir(typeof he.total=="number"?he.total:0),pr(typeof he.totalPages=="number"&&he.totalPages>0?he.totalPages:1)}}catch(T){console.error(T),oe.error("加载链接标签失败")}finally{vn(!1)}},[hn,Pa,Rr]),[$a,da]=b.useState([]),[ua,_r]=b.useState(""),[Fa,sr]=b.useState(!1),$c=b.useRef(null),zr=b.useCallback(async()=>{try{const T=await De("/api/admin/linked-miniprograms");T!=null&&T.success&&Array.isArray(T.data)&&da(T.data.map(B=>({...B,key:B.key})))}catch{}},[]),$r=$a.filter(T=>!ua.trim()||T.name.toLowerCase().includes(ua.toLowerCase())||T.key&&T.key.toLowerCase().includes(ua.toLowerCase())||T.appId.toLowerCase().includes(ua.toLowerCase())),gr=async T=>{const B=Gt.includes(T)?Gt.filter(he=>he!==T):[...Gt,T];ln(B);try{await Et("/api/db/config",{key:"pinned_section_ids",value:B,description:"强制置顶章节ID列表精选推荐/首页最新更新)"}),tr()}catch{ln(Gt)}},ha=b.useCallback(async()=>{mt(!0);try{const T=await De("/api/db/config/full?key=unpaid_preview_percent",{cache:"no-store"}),B=T&&T.data;typeof B=="number"&&B>0&&B<=100&&W(B)}catch{}finally{mt(!1)}},[]),Cl=async()=>{if(ns<1||ns>100){oe.error("预览比例需在 1~100 之间");return}gt(!0);try{const T=await Et("/api/db/config",{key:"unpaid_preview_percent",value:ns,description:"小程序未付费内容默认预览比例(%)"});T&&T.success!==!1?oe.success("预览比例已保存"):oe.error("保存失败: "+(T.error||""))}catch{oe.error("保存失败")}finally{gt(!1)}};b.useEffect(()=>{nr(),ha(),Kn(),qn(),ca(),zr(),la()},[nr,ha,Kn,qn,ca,zr,la]),b.useEffect(()=>{za()},[za]);const To=async T=>{Ne({section:T,orders:[]}),ye(!0);try{const B=await De(`/api/db/book?action=section-orders&id=${encodeURIComponent(T.id)}`),he=B!=null&&B.success&&Array.isArray(B.orders)?B.orders:[];Ne(ke=>ke?{...ke,orders:he}:null)}catch(B){console.error(B),Ne(he=>he?{...he,orders:[]}:null)}finally{ye(!1)}},fa=async T=>{g(!0);try{const B=T.mid!=null&&T.mid>0?`/api/db/book?action=read&mid=${T.mid}`:`/api/db/book?action=read&id=${encodeURIComponent(T.id)}`,he=await De(B);if(he!=null&&he.success&&he.section){const ke=he.section,Je=ke.editionPremium===!0;u({id:T.id,originalId:T.id,title:he.section.title??T.title,price:he.section.price??T.price,content:he.section.content??"",filePath:T.filePath,isFree:T.isFree||T.price===0,isNew:ke.isNew??T.isNew,isPinned:Gt.includes(T.id),hotScore:T.hotScore??0,editionStandard:Je?!1:ke.editionStandard??!0,editionPremium:Je})}else u({id:T.id,originalId:T.id,title:T.title,price:T.price,content:"",filePath:T.filePath,isFree:T.isFree,isNew:T.isNew,isPinned:Gt.includes(T.id),hotScore:T.hotScore??0,editionStandard:!0,editionPremium:!1}),he&&!he.success&&oe.error("无法读取文件内容: "+(he.error||"未知错误"))}catch(B){console.error(B),u({id:T.id,title:T.title,price:T.price,content:"",filePath:T.filePath,isFree:T.isFree})}finally{g(!1)}},Ba=async()=>{var T;if(c){v(!0);try{let B=c.content||"";const he=[new RegExp(`^#+\\s*${c.id.replace(".","\\.")}\\s+.*$`,"gm"),new RegExp(`^#+\\s*${c.id.replace(".","\\.")}[:].*$`,"gm"),new RegExp(`^#\\s+.*${(T=c.title)==null?void 0:T.slice(0,10).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}.*$`,"gm")];for(const bs of he)B=B.replace(bs,"");B=B.replace(/^\s*\n+/,"").trim();const ke=c.originalId||c.id,Je=c.id!==ke,ft=await Jt("/api/db/book",{id:ke,...Je?{newId:c.id}:{},title:c.title,price:c.isFree?0:c.price,content:B,isFree:c.isFree||c.price===0,isNew:c.isNew,hotScore:c.hotScore,previewPercent:c.previewPercent??null,editionStandard:c.editionPremium?!1:c.editionStandard??!0,editionPremium:c.editionPremium??!1,saveToFile:!0},{timeout:l1}),Lt=Je?c.id:ke;c.isPinned!==Gt.includes(Lt)&&await gr(Lt),ft&&ft.success!==!1?(oe.success(`已保存:${c.title}`),u(null),Nn(),Kn(),qn()):oe.error("保存失败: "+(ft&&typeof ft=="object"&&"error"in ft?ft.error:"未知错误"))}catch(B){console.error(B);const he=B instanceof Error&&B.name==="AbortError"?"保存超时,请检查网络或稍后重试":"保存失败";oe.error(he)}finally{v(!1)}}},R=async()=>{if(!O.id||!O.title){oe.error("请填写章节ID和标题");return}v(!0);try{const T=An.find(ke=>ke.id===O.partId),B=T==null?void 0:T.chapters.find(ke=>ke.id===O.chapterId),he=await Jt("/api/db/book",{id:O.id,title:O.title,price:O.isFree?0:O.price,content:O.content||"",partId:O.partId,partTitle:(T==null?void 0:T.title)??"",chapterId:O.chapterId,chapterTitle:(B==null?void 0:B.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:l1});if(he&&he.success!==!1){if(O.isPinned){const ke=[...Gt,O.id];ln(ke);try{await Et("/api/db/config",{key:"pinned_section_ids",value:ke,description:"强制置顶章节ID列表精选推荐/首页最新更新)"})}catch{}}oe.success(`章节创建成功:${O.title}`),f(!1),U({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),Nn(),Kn(),qn()}else oe.error("创建失败: "+(he&&typeof he=="object"&&"error"in he?he.error:"未知错误"))}catch(T){console.error(T),oe.error("创建失败")}finally{v(!1)}},Pe=T=>{U(B=>{var he;return{...B,partId:T.id,chapterId:((he=T.chapters[0])==null?void 0:he.id)??"chapter-1"}}),f(!0)},Re=T=>{V({id:T.id,title:T.title})},qe=async()=>{var T;if((T=_==null?void 0:_.title)!=null&&T.trim()){X(!0);try{const B=e.map(ke=>({id:ke.id,partId:ke.partId||"part-1",partTitle:ke.partId===_.id?_.title.trim():ke.partTitle||"",chapterId:ke.chapterId||"chapter-1",chapterTitle:ke.chapterTitle||""})),he=await Jt("/api/db/book",{action:"reorder",items:B});if(he&&he.success!==!1){const ke=_.title.trim();n(Je=>Je.map(ft=>ft.partId===_.id?{...ft,partTitle:ke}:ft)),V(null),Nn()}else oe.error("更新篇名失败: "+(he&&typeof he=="object"&&"error"in he?he.error:"未知错误"))}catch(B){console.error(B),oe.error("更新篇名失败")}finally{X(!1)}}},Nt=T=>{const B=T.chapters.length+1,he=`chapter-${T.id}-${B}-${Date.now()}`;U({id:`${B}.1`,title:"新章节",price:1,partId:T.id,chapterId:he,content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),f(!0)},wt=(T,B)=>{const he=B.sections;let ke=1,Je=!1,ft=!1;if(he.length>0){const Lt=typeof he[0].price=="number"?he[0].price:Number(he[0].price)||1,bs=!!(he[0].isFree||Lt===0);ft=he.some(ga=>{const In=typeof ga.price=="number"?ga.price:Number(ga.price)||1,rr=!!(ga.isFree||In===0);return In!==Lt||rr!==bs}),ke=bs?0:Lt,Je=bs}ue({part:T,chapter:B,title:B.title,price:ke,isFree:Je,priceMixed:ft,initialTitle:B.title,initialPrice:ke,initialIsFree:Je})},pn=async()=>{var Je;if(!((Je=ne==null?void 0:ne.title)!=null&&Je.trim()))return;const T=ne,B=T.title.trim(),he=B!==T.initialTitle,ke=T.isFree!==T.initialIsFree||!T.isFree&&Number(T.price)!==Number(T.initialPrice);if(!he&&!ke){oe.info("未修改任何内容"),ue(null);return}if(T.priceMixed&&ke){const ft=T.chapter.sections.length,Lt=T.isFree?"全部设为免费":`全部设为 ¥${T.price}`;if(!confirm(`本章 ${ft} 节当前定价不一致,保存后将${Lt},确定?`))return}$(!0);try{if(he){const ft=e.map(In=>({id:In.id,partId:In.partId||T.part.id,partTitle:In.partId===T.part.id?T.part.title:In.partTitle||"",chapterId:In.chapterId||T.chapter.id,chapterTitle:In.partId===T.part.id&&In.chapterId===T.chapter.id?B:In.chapterTitle||""})),Lt=await Jt("/api/db/book",{action:"reorder",items:ft});if(Lt&&Lt.success===!1){oe.error("保存章节名失败: "+(Lt&&typeof Lt=="object"&&"error"in Lt?Lt.error:"未知错误"));return}const bs=T.part.id,ga=T.chapter.id;n(In=>In.map(rr=>rr.partId===bs&&rr.chapterId===ga?{...rr,chapterTitle:B}:rr))}if(ke){const ft=await Jt("/api/db/book",{action:"update-chapter-pricing",partId:T.part.id,chapterId:T.chapter.id,price:T.isFree?0:Number(T.price)||0,isFree:T.isFree});if(ft&&ft.success===!1){oe.error("保存定价失败: "+(ft&&typeof ft=="object"&&"error"in ft?ft.error:"未知错误")),he&&Nn();return}}ue(null),Nn(),oe.success("已保存")}catch(ft){console.error(ft),oe.error("保存失败")}finally{$(!1)}},dt=async(T,B)=>{const he=B.sections.map(ke=>ke.id);if(he.length===0){oe.info("该章下无小节,无需删除");return}if(confirm(`确定要删除「第${T.chapters.indexOf(B)+1}章 | ${B.title}」吗?将删除共 ${he.length} 节,此操作不可恢复。`))try{for(const ke of he)await ai(`/api/db/book?id=${encodeURIComponent(ke)}`);Nn()}catch(ke){console.error(ke),oe.error("删除失败")}},qt=async()=>{if(!le.trim()){oe.error("请输入篇名");return}Z(!0);try{const T=`part-new-${Date.now()}`,B="chapter-1",he=`part-placeholder-${Date.now()}`,ke=await Jt("/api/db/book",{id:he,title:"占位节(可编辑)",price:0,content:"",partId:T,partTitle:le.trim(),chapterId:B,chapterTitle:"第1章 | 待编辑",saveToFile:!1});ke&&ke.success!==!1?(oe.success(`篇「${le}」创建成功`),z(!1),ae(""),Nn()):oe.error("创建失败: "+(ke&&typeof ke=="object"&&"error"in ke?ke.error:"未知错误"))}catch(T){console.error(T),oe.error("创建失败")}finally{Z(!1)}},cn=async()=>{if(D.length===0){oe.error("请先勾选要移动的章节");return}const T=An.find(he=>he.id===L),B=T==null?void 0:T.chapters.find(he=>he.id===re);if(!T||!B||!L||!re){oe.error("请选择目标篇和章");return}se(!0);try{const he=()=>{const Lt=new Set(D),bs=e.map(Gn=>({id:Gn.id,partId:Gn.partId||"",partTitle:Gn.partTitle||"",chapterId:Gn.chapterId||"",chapterTitle:Gn.chapterTitle||""})),ga=bs.filter(Gn=>Lt.has(Gn.id)).map(Gn=>({...Gn,partId:L,partTitle:T.title||L,chapterId:re,chapterTitle:B.title||re})),In=bs.filter(Gn=>!Lt.has(Gn.id));let rr=In.length;for(let Gn=In.length-1;Gn>=0;Gn-=1){const uu=In[Gn];if(uu.partId===L&&uu.chapterId===re){rr=Gn+1;break}}return[...In.slice(0,rr),...ga,...In.slice(rr)]},ke=async()=>{const Lt=he(),bs=await Jt("/api/db/book",{action:"reorder",items:Lt});return bs&&bs.success!==!1?(oe.success(`已移动 ${D.length} 节到「${T.title}」-「${B.title}」`),q(!1),I([]),await Nn(),!0):!1},Je={action:"move-sections",sectionIds:D,targetPartId:L,targetChapterId:re,targetPartTitle:T.title||L,targetChapterTitle:B.title||re},ft=await Jt("/api/db/book",Je);if(ft&&ft.success!==!1)oe.success(`已移动 ${ft.count??D.length} 节到「${T.title}」-「${B.title}」`),q(!1),I([]),await Nn();else{const Lt=ft&&typeof ft=="object"&&"error"in ft?ft.error||"":"未知错误";if((Lt.includes("缺少 id")||Lt.includes("无效的 action"))&&await ke())return;oe.error("移动失败: "+Lt)}}catch(he){console.error(he),oe.error("移动失败: "+(he instanceof Error?he.message:"网络或服务异常"))}finally{se(!1)}},ys=T=>{I(B=>B.includes(T)?B.filter(he=>he!==T):[...B,T])},Fr=async T=>{const B=e.filter(he=>he.partId===T.id).map(he=>he.id);if(B.length===0){oe.info("该篇下暂无小节可删除");return}if(confirm(`确定要删除「${T.title}」整篇吗?将删除共 ${B.length} 节内容,此操作不可恢复。`))try{for(const he of B)await ai(`/api/db/book?id=${encodeURIComponent(he)}`);Nn()}catch(he){console.error(he),oe.error("删除失败")}},pa=async()=>{var T;if(w.trim()){P(!0);try{const B=await De(`/api/search?q=${encodeURIComponent(w)}`);B!=null&&B.success&&((T=B.data)!=null&&T.results)?E(B.data.results):(E([]),B&&!B.success&&oe.error("搜索失败: "+B.error))}catch(B){console.error(B),E([]),oe.error("搜索失败")}finally{P(!1)}}},Mo=An.find(T=>T.id===O.partId),ma=(Mo==null?void 0:Mo.chapters)??[];return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"内容管理"}),r.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",An.length," 篇 · ",Sl," 节内容"]})]}),r.jsx("div",{className:"flex gap-2",children:r.jsxs(Y,{onClick:()=>Ze(!0),variant:"outline",className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:[r.jsx(lh,{className:"w-4 h-4 mr-2"}),"排名算法"]})})]}),r.jsx(Ht,{open:h,onOpenChange:f,children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white inset-0 translate-x-0 translate-y-0 w-screen h-screen max-w-none max-h-none rounded-none flex flex-col p-0 gap-0",showCloseButton:!0,children:[r.jsx(Ut,{className:"shrink-0 px-6 pt-6 pb-2",children:r.jsxs(Wt,{className:"text-white flex items-center gap-2",children:[r.jsx(Pn,{className:"w-5 h-5 text-[#38bdac]"}),"新建章节"]})}),r.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"章节ID *"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 9.15",value:O.id,onChange:T=>U({...O,id:T.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"价格 (元)"}),r.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:O.isFree?0:O.price,onChange:T=>U({...O,price:Number(T.target.value),isFree:Number(T.target.value)===0}),disabled:O.isFree})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"免费"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:O.isFree,onChange:T=>U({...O,isFree:T.target.checked,price:T.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"最新新增"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:O.isNew,onChange:T=>U({...O,isNew:T.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"小程序直推"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:O.isPinned,onChange:T=>U({...O,isPinned:T.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"文章类型"}),r.jsxs("div",{className:"flex items-center gap-4 h-10",children:[r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"radio",name:"new-edition-type",checked:O.editionPremium!==!0,onChange:()=>U({...O,editionStandard:!0,editionPremium:!1}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"普通版"})]}),r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"radio",name:"new-edition-type",checked:O.editionPremium===!0,onChange:()=>U({...O,editionStandard:!1,editionPremium:!0}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"增值版"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"热度分"}),r.jsx(ce,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:O.hotScore??0,onChange:T=>U({...O,hotScore:Math.max(0,parseFloat(T.target.value)||0)})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"章节标题 *"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入章节标题",value:O.title,onChange:T=>U({...O,title:T.target.value})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"所属篇"}),r.jsxs(rc,{value:O.partId,onValueChange:T=>{var he;const B=An.find(ke=>ke.id===T);U({...O,partId:T,chapterId:((he=B==null?void 0:B.chapters[0])==null?void 0:he.id)??"chapter-1"})},children:[r.jsx(Ko,{className:"bg-[#0a1628] border-gray-700 text-white",children:r.jsx(ac,{})}),r.jsxs(qo,{className:"bg-[#0f2137] border-gray-700",children:[An.map(T=>r.jsx(lr,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id)),An.length===0&&r.jsx(lr,{value:"part-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认篇"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"所属章"}),r.jsxs(rc,{value:O.chapterId,onValueChange:T=>U({...O,chapterId:T}),children:[r.jsx(Ko,{className:"bg-[#0a1628] border-gray-700 text-white",children:r.jsx(ac,{})}),r.jsxs(qo,{className:"bg-[#0f2137] border-gray-700",children:[ma.map(T=>r.jsx(lr,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id)),ma.length===0&&r.jsx(lr,{value:"chapter-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认章"})]})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),r.jsx(Zx,{content:O.content||"",onChange:T=>U({...O,content:T}),onImageUpload:aa,onMediaUpload:bi,persons:ht,linkTags:It,placeholder:"开始编辑内容... 输入 @ 可链接AI人物工具栏可插入 #链接标签"})]})]}),r.jsxs(xn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[r.jsx(Y,{variant:"outline",onClick:()=>f(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsx(Y,{onClick:R,disabled:y||!O.id||!O.title,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:y?r.jsxs(r.Fragment,{children:[r.jsx(Be,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Pn,{className:"w-4 h-4 mr-2"}),"创建章节"]})})]})]})}),r.jsx(Ht,{open:!!_,onOpenChange:T=>!T&&V(null),children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[r.jsx(Ut,{children:r.jsxs(Wt,{className:"text-white flex items-center gap-2",children:[r.jsx(en,{className:"w-5 h-5 text-[#38bdac]"}),"编辑篇名"]})}),_&&r.jsx("div",{className:"space-y-4 py-4",children:r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"篇名"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:_.title,onChange:T=>V({..._,title:T.target.value}),placeholder:"输入篇名"})]})}),r.jsxs(xn,{children:[r.jsx(Y,{variant:"outline",onClick:()=>V(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsx(Y,{onClick:qe,disabled:A||!((El=_==null?void 0:_.title)!=null&&El.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:A?r.jsxs(r.Fragment,{children:[r.jsx(Be,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),r.jsx(Ht,{open:!!ne,onOpenChange:T=>!T&&ue(null),children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[r.jsxs(Ut,{children:[r.jsxs(Wt,{className:"text-white flex items-center gap-2",children:[r.jsx(en,{className:"w-5 h-5 text-[#38bdac]"}),"章节设置"]}),r.jsx("p",{className:"text-gray-400 text-sm font-normal pt-1",children:"修改本章显示名称,或为本章下全部节设置统一金额(仍可在单节编辑里单独改某一节)。"})]}),ne&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"章节名称第8章底层结构"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:ne.title,onChange:T=>ue({...ne,title:T.target.value}),placeholder:"输入章节名称"})]}),r.jsxs("div",{className:"space-y-2 border-t border-gray-700/60 pt-4",children:[r.jsxs(ee,{className:"text-gray-300",children:["本章统一定价(应用于本章全部 ",ne.chapter.sections.length," 节)"]}),ne.priceMixed&&r.jsx("p",{className:"text-amber-400/90 text-xs",children:"当前各节定价不一致,保存后将按下方设置全部统一。"}),r.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[r.jsxs("div",{className:"space-y-1 flex-1 min-w-[120px]",children:[r.jsx("span",{className:"text-gray-500 text-xs",children:"价格 (元)"}),r.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:ne.isFree?0:ne.price,onChange:T=>ue({...ne,price:Number(T.target.value),isFree:Number(T.target.value)===0}),disabled:ne.isFree,min:0,step:.01})]}),r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer pb-2",children:[r.jsx("input",{type:"checkbox",checked:ne.isFree||ne.price===0,onChange:T=>ue({...ne,isFree:T.target.checked,price:T.target.checked?0:ne.initialPrice>0?ne.initialPrice:1}),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac]"}),r.jsx("span",{className:"text-gray-400 text-sm",children:"本章全部免费"})]})]})]})]}),r.jsxs(xn,{children:[r.jsx(Y,{variant:"outline",onClick:()=>ue(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsx(Y,{onClick:pn,disabled:K||!((wi=ne==null?void 0:ne.title)!=null&&wi.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:K?r.jsxs(r.Fragment,{children:[r.jsx(Be,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),r.jsx(Ht,{open:ie,onOpenChange:T=>{var B;if(q(T),T&&An.length>0){const he=An[0];F(he.id),ge(((B=he.chapters[0])==null?void 0:B.id)??"")}},children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[r.jsx(Ut,{children:r.jsx(Wt,{className:"text-white",children:"批量移动至指定目录"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("p",{className:"text-gray-400 text-sm",children:["已选 ",r.jsx("span",{className:"text-[#38bdac] font-medium",children:D.length})," 节,请选择目标篇与章。"]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"目标篇"}),r.jsxs(rc,{value:L,onValueChange:T=>{var he;F(T);const B=An.find(ke=>ke.id===T);ge(((he=B==null?void 0:B.chapters[0])==null?void 0:he.id)??"")},children:[r.jsx(Ko,{className:"bg-[#0a1628] border-gray-700 text-white",children:r.jsx(ac,{placeholder:"选择篇"})}),r.jsx(qo,{className:"bg-[#0f2137] border-gray-700",children:An.map(T=>r.jsx(lr,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"目标章"}),r.jsxs(rc,{value:re,onValueChange:ge,children:[r.jsx(Ko,{className:"bg-[#0a1628] border-gray-700 text-white",children:r.jsx(ac,{placeholder:"选择章"})}),r.jsx(qo,{className:"bg-[#0f2137] border-gray-700",children:(((Ao=An.find(T=>T.id===L))==null?void 0:Ao.chapters)??[]).map(T=>r.jsx(lr,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id))})]})]})]}),r.jsxs(xn,{children:[r.jsx(Y,{variant:"outline",onClick:()=>q(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsx(Y,{onClick:cn,disabled:Te||D.length===0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:Te?r.jsxs(r.Fragment,{children:[r.jsx(Be,{className:"w-4 h-4 mr-2 animate-spin"}),"移动中..."]}):"确认移动"})]})]})}),r.jsx(Ht,{open:!!xe,onOpenChange:T=>!T&&Ne(null),children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",showCloseButton:!0,children:[r.jsx(Ut,{children:r.jsxs(Wt,{className:"text-white",children:["付款记录 — ",(xe==null?void 0:xe.section.title)??""]})}),r.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:ct?r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(Be,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):xe&&xe.orders.length===0?r.jsx("p",{className:"text-gray-500 text-center py-6",children:"暂无付款记录"}):xe?r.jsxs("table",{className:"w-full text-sm border-collapse",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[r.jsx("th",{className:"py-2 pr-2",children:"订单号"}),r.jsx("th",{className:"py-2 pr-2",children:"用户ID"}),r.jsx("th",{className:"py-2 pr-2",children:"金额"}),r.jsx("th",{className:"py-2 pr-2",children:"状态"}),r.jsx("th",{className:"py-2 pr-2",children:"支付时间"})]})}),r.jsx("tbody",{children:xe.orders.map(T=>r.jsxs("tr",{className:"border-b border-gray-700/50",children:[r.jsx("td",{className:"py-2 pr-2",children:r.jsx("button",{className:"text-blue-400 hover:text-blue-300 hover:underline text-left truncate max-w-[180px] block",title:`查看订单 ${T.orderSn}`,onClick:()=>window.open(`/orders?search=${T.orderSn??T.id??""}`,"_blank"),children:T.orderSn?T.orderSn.length>16?T.orderSn.slice(0,8)+"..."+T.orderSn.slice(-6):T.orderSn:"-"})}),r.jsx("td",{className:"py-2 pr-2",children:r.jsx("button",{className:"text-[#38bdac] hover:text-[#2da396] hover:underline text-left truncate max-w-[140px] block",title:`查看用户 ${T.userId??T.openId??""}`,onClick:()=>window.open(`/users?search=${T.userId??T.openId??""}`,"_blank"),children:(()=>{const B=T.userId??T.openId??"-";return B.length>12?B.slice(0,6)+"..."+B.slice(-4):B})()})}),r.jsxs("td",{className:"py-2 pr-2 text-gray-300",children:["¥",T.amount??0]}),r.jsx("td",{className:"py-2 pr-2 text-gray-300",children:T.status??"-"}),r.jsx("td",{className:"py-2 pr-2 text-gray-500",children:T.payTime??T.createdAt??"-"})]},T.id??T.orderSn??""))})]}):null})]})}),r.jsx(Ht,{open:$e,onOpenChange:Ze,children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[r.jsx(Ut,{children:r.jsxs(Wt,{className:"text-white flex items-center gap-2",children:[r.jsx(lh,{className:"w-5 h-5 text-amber-400"}),"文章排名算法"]})}),r.jsxs("div",{className:"space-y-4 py-2",children:[r.jsx("p",{className:"text-sm text-gray-400",children:"热度积分 = 阅读权重×阅读排名分 + 新度权重×新度排名分 + 付款权重×付款排名分(三权重之和须为 1"}),st?r.jsx("p",{className:"text-gray-500",children:"加载中..."}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"阅读权重"}),r.jsx(ce,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:tt.readWeight,onChange:T=>_e(B=>({...B,readWeight:Math.max(0,Math.min(1,parseFloat(T.target.value)||0))}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"新度权重"}),r.jsx(ce,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:tt.recencyWeight,onChange:T=>_e(B=>({...B,recencyWeight:Math.max(0,Math.min(1,parseFloat(T.target.value)||0))}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"付款权重"}),r.jsx(ce,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:tt.payWeight,onChange:T=>_e(B=>({...B,payWeight:Math.max(0,Math.min(1,parseFloat(T.target.value)||0))}))})]})]}),r.jsxs("p",{className:"text-xs text-gray-500",children:["当前之和: ",(tt.readWeight+tt.recencyWeight+tt.payWeight).toFixed(1)]}),r.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs text-gray-400",children:[r.jsx("li",{children:"阅读量前 20 名第1名=20分、第2名=19分...第20名=1分"}),r.jsx("li",{children:"最近更新前 30 篇第1名=30分、第2名=29分...第30名=1分"}),r.jsx("li",{children:"付款数前 20 名第1名=20分、第2名=19分...第20名=1分"}),r.jsx("li",{children:"热度分可在编辑章节中手动覆盖"})]}),r.jsx(Y,{onClick:Ni,disabled:Pt||Math.abs(tt.readWeight+tt.recencyWeight+tt.payWeight-1)>.001,className:"w-full bg-amber-500 hover:bg-amber-600 text-white",children:Pt?"保存中...":"保存权重"})]})]})]})}),r.jsx(Ht,{open:G,onOpenChange:z,children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[r.jsx(Ut,{children:r.jsxs(Wt,{className:"text-white flex items-center gap-2",children:[r.jsx(Pn,{className:"w-5 h-5 text-amber-400"}),"新建篇"]})}),r.jsx("div",{className:"space-y-4 py-4",children:r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"篇名(如:第六篇|真实的社会)"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:le,onChange:T=>ae(T.target.value),placeholder:"输入篇名"})]})}),r.jsxs(xn,{children:[r.jsx(Y,{variant:"outline",onClick:()=>{z(!1),ae("")},className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsx(Y,{onClick:qt,disabled:Q||!le.trim(),className:"bg-amber-500 hover:bg-amber-600 text-white",children:Q?r.jsxs(r.Fragment,{children:[r.jsx(Be,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Pn,{className:"w-4 h-4 mr-2"}),"创建篇"]})})]})]})}),r.jsx(Ht,{open:!!c,onOpenChange:()=>u(null),children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white inset-0 translate-x-0 translate-y-0 w-screen h-screen max-w-none max-h-none rounded-none flex flex-col p-0 gap-0",showCloseButton:!0,children:[r.jsx(Ut,{className:"shrink-0 px-6 pt-6 pb-2",children:r.jsxs(Wt,{className:"text-white flex items-center gap-2",children:[r.jsx(en,{className:"w-5 h-5 text-[#38bdac]"}),"编辑章节"]})}),c&&r.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"章节ID"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:c.id,onChange:T=>u({...c,id:T.target.value}),placeholder:"如: 9.15"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"价格 (元)"}),r.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:c.isFree?0:c.price,onChange:T=>u({...c,price:Number(T.target.value),isFree:Number(T.target.value)===0}),disabled:c.isFree})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"免费"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:c.isFree||c.price===0,onChange:T=>u({...c,isFree:T.target.checked,price:T.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"预览%"}),r.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",placeholder:`全局 ${ns}%`,value:c.previewPercent??"",onChange:T=>{const B=T.target.value===""?void 0:Math.min(100,Math.max(0,Number(T.target.value)));u({...c,previewPercent:B})}})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"最新新增"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:c.isNew??!1,onChange:T=>u({...c,isNew:T.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"小程序直推"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:c.isPinned??!1,onChange:T=>u({...c,isPinned:T.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"文章类型"}),r.jsxs("div",{className:"flex items-center gap-4 h-10",children:[r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"radio",name:"edition-type",checked: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]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"普通版"})]}),r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"radio",name:"edition-type",checked: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]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"增值版"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"热度分"}),r.jsx(ce,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:c.hotScore??0,onChange:T=>u({...c,hotScore:Math.max(0,parseFloat(T.target.value)||0)})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"章节标题"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:c.title,onChange:T=>u({...c,title:T.target.value})})]}),c.filePath&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"文件路径"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-gray-400 text-sm",value:c.filePath,disabled:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),m?r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700 rounded-md min-h-[400px] flex items-center justify-center",children:[r.jsx(Be,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsx(Zx,{ref:ko,content:c.content||"",onChange:T=>u({...c,content:T}),onImageUpload:aa,onMediaUpload:bi,persons:ht,linkTags:It,placeholder:"开始编辑内容... 输入 @ 可链接AI人物工具栏可插入 #链接标签"})]})]}),r.jsxs(xn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[c&&r.jsxs(Y,{variant:"outline",onClick:()=>To({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:[r.jsx(Js,{className:"w-4 h-4 mr-2"}),"付款记录"]}),r.jsxs(Y,{variant:"outline",onClick:()=>u(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(us,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsx(Y,{onClick:Ba,disabled:y,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:y?r.jsxs(r.Fragment,{children:[r.jsx(Be,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),"保存修改"]})})]})]})}),r.jsxs(au,{defaultValue:"chapters",className:"space-y-6",children:[r.jsxs(Ac,{className:"bg-[#0f2137] border border-gray-700/50 p-1",children:[r.jsxs(yn,{value:"chapters",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[r.jsx(Js,{className:"w-4 h-4 mr-2"}),"章节管理"]}),r.jsxs(yn,{value:"ranking",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[r.jsx(lx,{className:"w-4 h-4 mr-2"}),"内容排行榜"]}),r.jsxs(yn,{value:"search",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[r.jsx(Sa,{className:"w-4 h-4 mr-2"}),"内容搜索"]}),r.jsxs(yn,{value:"link-person",className:"data-[state=active]:bg-purple-500/20 data-[state=active]:text-purple-400 text-gray-400",children:[r.jsx(ro,{className:"w-4 h-4 mr-2"}),"链接人与事"]}),r.jsxs(yn,{value:"link-tag",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[r.jsx(r1,{className:"w-4 h-4 mr-2"}),"链接标签"]})]}),r.jsxs(bn,{value:"chapters",className:"space-y-4",children:[r.jsxs("div",{className:"rounded-2xl border border-gray-700/50 bg-[#1C1C1E] p-4 flex items-center justify-between shadow-sm",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#38bdac] flex items-center justify-center text-white shadow-lg shadow-[#38bdac]/20 shrink-0",children:r.jsx(Js,{className:"w-6 h-6"})}),r.jsxs("div",{children:[r.jsx("h2",{className:"font-bold text-base text-white leading-tight mb-1",children:"一场SOUL的创业实验场"}),r.jsx("p",{className:"text-xs text-gray-500",children:"来自Soul派对房的真实商业故事"})]})]}),r.jsxs("div",{className:"text-center shrink-0",children:[r.jsx("span",{className:"block text-2xl font-bold text-[#38bdac]",children:Sl}),r.jsx("span",{className:"text-xs text-gray-500",children:"章节"})]})]}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(Y,{onClick:()=>f(!0),className:"flex-1 min-w-[120px] bg-[#38bdac]/10 hover:bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/30",children:[r.jsx(Pn,{className:"w-4 h-4 mr-2"}),"新建章节"]}),r.jsxs(Y,{onClick:()=>z(!0),className:"flex-1 min-w-[120px] bg-amber-500/10 hover:bg-amber-500/20 text-amber-400 border border-amber-500/30",children:[r.jsx(Pn,{className:"w-4 h-4 mr-2"}),"新建篇"]}),r.jsxs(Y,{variant:"outline",onClick:()=>q(!0),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:["批量移动(已选 ",D.length," 节)"]})]}),s?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Be,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsx(CV,{parts:An,expandedParts:i,onTogglePart:So,onReorder:Co,onReadSection:fa,onDeleteSection:Eo,onAddSectionInPart:Pe,onAddChapterInPart:Nt,onDeleteChapter:dt,onEditPart:Re,onDeletePart:Fr,onEditChapter:wt,selectedSectionIds:D,onToggleSectionSelect:ys,onShowSectionOrders:To,pinnedSectionIds:Gt})]}),r.jsx(bn,{value:"search",className:"space-y-4",children:r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsx(it,{children:r.jsx(ot,{className:"text-white",children:"内容搜索"})}),r.jsxs(Le,{className:"space-y-4",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",placeholder:"搜索标题或内容...",value:w,onChange:T=>N(T.target.value),onKeyDown:T=>T.key==="Enter"&&pa()}),r.jsx(Y,{onClick:pa,disabled:C||!w.trim(),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:C?r.jsx(Be,{className:"w-4 h-4 animate-spin"}):r.jsx(Sa,{className:"w-4 h-4"})})]}),k.length>0&&r.jsxs("div",{className:"space-y-2 mt-4",children:[r.jsxs("p",{className:"text-gray-400 text-sm",children:["找到 ",k.length," 个结果"]}),k.map(T=>r.jsxs("div",{className:"p-3 rounded-lg bg-[#162840] hover:bg-[#1a3050] cursor-pointer transition-colors",onClick:()=>fa({id:T.id,mid:T.mid,title:T.title,price:T.price??1,filePath:""}),children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[#38bdac] font-mono text-xs",children:T.id}),r.jsx("span",{className:"text-white",children:T.title}),Gt.includes(T.id)&&r.jsx(oc,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})]}),r.jsx(Ge,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:T.matchType==="title"?"标题匹配":"内容匹配"})]}),T.snippet&&r.jsx("p",{className:"text-gray-500 text-xs mt-2 line-clamp-2",children:T.snippet}),(T.partTitle||T.chapterTitle)&&r.jsxs("p",{className:"text-gray-600 text-xs mt-1",children:[T.partTitle," · ",T.chapterTitle]})]},T.id))]})]})]})}),r.jsxs(bn,{value:"ranking",className:"space-y-4",children:[r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsx(it,{className:"pb-3",children:r.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[r.jsx(lh,{className:"w-4 h-4 text-[#38bdac]"}),"内容显示规则"]})}),r.jsx(Le,{children:r.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ee,{className:"text-gray-400 text-sm whitespace-nowrap",children:"未付费预览比例"}),r.jsx(ce,{type:"number",min:"1",max:"100",className:"bg-[#0a1628] border-gray-700 text-white w-20",value:ns,onChange:T=>W(Math.max(1,Math.min(100,Number(T.target.value)||20))),disabled:Qe}),r.jsx("span",{className:"text-gray-500 text-sm",children:"%"})]}),r.jsx(Y,{size:"sm",onClick:Cl,disabled:Bt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:Bt?"保存中...":"保存"}),r.jsxs("span",{className:"text-xs text-gray-500",children:["小程序未付费用户默认显示文章前 ",ns,"% 内容"]})]})})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsx(it,{className:"pb-3",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[r.jsx(lx,{className:"w-4 h-4 text-amber-400"}),"内容排行榜",r.jsxs("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["按热度排行 · 共 ",gs.length," 节"]})]}),r.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>tr(),disabled:ts,className:"text-gray-400 hover:text-white h-7 w-7 p-0",title:"刷新排行榜",children:r.jsx(Be,{className:`w-4 h-4 ${ts?"animate-spin":""}`})}),r.jsx(Y,{variant:"ghost",size:"sm",disabled:Mn<=1||ts,onClick:()=>Dn(T=>Math.max(1,T-1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:r.jsx(t5,{className:"w-4 h-4"})}),r.jsxs("span",{className:"text-gray-400 min-w-[60px] text-center",children:[Mn," / ",Ct]}),r.jsx(Y,{variant:"ghost",size:"sm",disabled:Mn>=Ct||ts,onClick:()=>Dn(T=>Math.min(Ct,T+1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:r.jsx(Go,{className:"w-4 h-4"})})]})]})}),r.jsx(Le,{children:r.jsxs("div",{className:"space-y-0",children:[r.jsxs("div",{className:"grid grid-cols-[40px_40px_1fr_80px_80px_80px_60px] gap-2 px-3 py-2 text-xs text-gray-500 border-b border-gray-700/50",children:[r.jsx("span",{children:"排名"}),r.jsx("span",{children:"置顶"}),r.jsx("span",{children:"标题"}),r.jsx("span",{className:"text-right",children:"点击量"}),r.jsx("span",{className:"text-right",children:"付款数"}),r.jsx("span",{className:"text-right",children:"热度"}),r.jsx("span",{className:"text-right",children:"编辑"})]}),oa.map((T,B)=>{const he=(Mn-1)*ia+B+1,ke=T.isPinned??Gt.includes(T.id);return r.jsxs("div",{className:`grid grid-cols-[40px_40px_1fr_80px_80px_80px_60px] gap-2 px-3 py-2.5 items-center border-b border-gray-700/30 hover:bg-[#162840] transition-colors ${ke?"bg-amber-500/5":""}`,children:[r.jsx("span",{className:`text-sm font-bold ${he<=3?"text-amber-400":"text-gray-500"}`,children:he<=3?["🥇","🥈","🥉"][he-1]:`#${he}`}),r.jsx(Y,{variant:"ghost",size:"sm",className:`h-6 w-6 p-0 ${ke?"text-amber-400":"text-gray-600 hover:text-amber-400"}`,onClick:()=>gr(T.id),disabled:As,title:ke?"取消置顶":"强制置顶(精选推荐/首页最新更新)",children:ke?r.jsx(oc,{className:"w-3.5 h-3.5 fill-current"}):r.jsx(EM,{className:"w-3.5 h-3.5"})}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("span",{className:"text-white text-sm truncate block",children:T.title}),r.jsxs("span",{className:"text-gray-600 text-xs",children:[T.partTitle," · ",T.chapterTitle]})]}),r.jsx("span",{className:"text-right text-sm text-blue-400 font-mono",children:T.clickCount??0}),r.jsx("span",{className:"text-right text-sm text-green-400 font-mono",children:T.payCount??0}),r.jsx("span",{className:"text-right text-sm text-amber-400 font-mono",children:(T.hotScore??0).toFixed(1)}),r.jsx("div",{className:"text-right",children:r.jsx(Y,{variant:"ghost",size:"sm",className:"text-gray-500 hover:text-[#38bdac] h-6 px-1",onClick:()=>fa({id:T.id,mid:T.mid,title:T.title,price:T.price,filePath:""}),title:"编辑文章",children:r.jsx(en,{className:"w-3 h-3"})})})]},T.id)}),oa.length===0&&r.jsx("div",{className:"py-8 text-center text-gray-500",children:"暂无数据"})]})})]})]}),r.jsxs(bn,{value:"link-person",className:"space-y-4",children:[r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{className:"pb-3",children:[r.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[r.jsx("span",{className:"text-[#38bdac] text-lg font-bold",children:"@"}),"AI列表 — 链接人与事(编辑器内输入 @ 可链接)"]}),r.jsxs("div",{className:"text-xs text-gray-500 mt-1 space-y-1",children:[r.jsxs("p",{children:["文章 @ 存 ",r.jsx("span",{className:"text-gray-400",children:"token"}),";小程序点 @ 用 token 换存客宝密钥后加好友/拉群。"]}),r.jsxs("p",{children:[r.jsx("span",{className:"text-purple-300",children:"超级个体"}),":开通且昵称合法会自动进本列表可 @;共用「超级个体拉群」统一获客计划(话术由技术侧在系统里配置,本页不填 plan/apiKey避免误操作。"]}),r.jsx("p",{children:"点「添加」新建的人物每人单独一条存客宝计划SOUL链接人与事-名称)。"})]})]}),r.jsxs(Le,{className:"space-y-3",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsx("p",{className:"text-xs text-gray-500",children:"本页只管理可 @ 的人物列表"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Y,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50",onClick:()=>{Kn()},title:"刷新",children:r.jsx(Be,{className:"w-4 h-4"})}),r.jsxs(Y,{size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:()=>{Qs(null),$s(!0)},children:[r.jsx(Pn,{className:"w-4 h-4 mr-2"}),"添加"]})]})]}),r.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:ht.length>0?r.jsxs("table",{className:"w-full text-sm border-collapse",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"text-xs text-gray-500 border-b border-gray-700/50",children:[r.jsx("th",{className:"text-left py-1.5 px-3 w-[280px] font-normal",children:"token"}),r.jsx("th",{className:"text-left py-1.5 px-3 w-24 font-normal",children:"@的人"}),r.jsx("th",{className:"text-left py-1.5 px-3 w-[72px] font-normal text-xs",children:"来源"}),r.jsx("th",{className:"text-left py-1.5 px-3 w-[100px] font-normal text-xs",children:"会员"}),r.jsx("th",{className:"py-1.5 px-3 w-16 font-normal text-center",children:"获客数"}),r.jsx("th",{className:"text-left py-1.5 px-3 font-normal",children:"获客计划"}),r.jsx("th",{className:"text-left py-1.5 px-3 w-16 font-normal",children:"状态"}),r.jsx("th",{className:"text-left py-1.5 px-2 w-24 font-normal",children:"操作"})]})}),r.jsx("tbody",{children:ht.map(T=>r.jsxs("tr",{className:"border-b border-gray-700/30 hover:bg-[#0a1628]/80",children:[r.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs font-mono",title:"32位token",children:T.id}),r.jsx("td",{className:"py-2 px-3 truncate max-w-[96px]",children:r.jsx("button",{type:"button",className:"text-amber-400 hover:text-amber-300 hover:underline text-left",onClick:()=>{Vt[T.id]&&rs(T.id,T.name)},title:Vt[T.id]?"点击查看获客详情":T.name,children:T.name})}),r.jsx("td",{className:"py-2 px-3",children:T.personSource==="vip_sync"?r.jsx("span",{className:"text-[10px] text-purple-300 bg-purple-500/15 px-1.5 py-0.5 rounded whitespace-nowrap",children:"超级个体"}):r.jsx("span",{className:"text-[10px] text-gray-500 bg-gray-500/10 px-1.5 py-0.5 rounded whitespace-nowrap",children:"手工"})}),r.jsx("td",{className:"py-2 px-3 text-xs",children:T.userId?r.jsxs("div",{className:"flex flex-col gap-0.5 items-start max-w-[100px]",children:[T.personSource==="vip_sync"&&r.jsx("span",{className:"text-[10px] text-purple-300/90 leading-tight",children:"已绑定超级个体"}),r.jsx("button",{type:"button",className:"text-[#38bdac] hover:underline truncate max-w-[96px] block text-left",title:`用户ID: ${T.userId}`,onClick:()=>t(`/users?search=${encodeURIComponent(T.userId||"")}`),children:T.name})]}):r.jsx("span",{className:"text-gray-600",children:"—"})}),(()=>{const B=Vt[T.id]||0;return r.jsx("td",{className:`py-2 px-3 shrink-0 w-16 text-center text-xs font-bold cursor-pointer ${B>0?"text-green-400 hover:text-green-300 hover:underline":"text-gray-600"}`,title:B>0?"点击查看获客详情":"暂无获客",onClick:()=>{B>0&&rs(T.id,T.name)},children:B})})(),r.jsx("td",{className:"py-2 px-3 text-white truncate max-w-[220px]",title:`planId: ${T.ckbPlanId??"-"}`,children:r.jsx("div",{className:"flex items-center gap-1.5",children:r.jsx("span",{className:"truncate",children:T.ckbPlanId?T.personSource==="vip_sync"?"超级个体拉群(统一计划)":`SOUL链接人与事-${T.name}`:"—"})})}),r.jsx("td",{className:"py-2 px-3 text-center",children:T.ckbPlanId?r.jsx("span",{className:"text-[10px] text-green-400 bg-green-400/10 px-1.5 py-0.5 rounded",children:"启用"}):r.jsx("span",{className:"text-[10px] text-gray-500 bg-gray-500/10 px-1.5 py-0.5 rounded",children:"未配置"})}),r.jsx("td",{className:"py-2 px-2",children:r.jsxs("div",{className:"flex items-center gap-0",children:[r.jsx(Y,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-[#38bdac] h-6 px-2",title:"编辑",onClick:async()=>{try{const B=await TV(T.personId||"");if(B!=null&&B.success&&B.person){const he=B.person;Qs({id:he.token??he.personId,personId:he.personId,name:he.name,personSource:he.personSource??"",userId:he.userId??"",label:he.label??"",ckbApiKey:he.ckbApiKey??"",remarkType:he.remarkType,remarkFormat:he.remarkFormat,addFriendInterval:he.addFriendInterval,startTime:he.startTime,endTime:he.endTime,deviceGroups:he.deviceGroups})}else Qs(T),B!=null&&B.error&&oe.error(B.error)}catch(B){console.error(B),Qs(T),oe.error(B instanceof Error?B.message:"加载人物详情失败")}$s(!0)},children:r.jsx(a1,{className:"w-3 h-3"})}),r.jsx(Y,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-green-400 h-6 px-2",title:"查看新客户",onClick:()=>rs(T.id,T.name),children:r.jsx(zn,{className:"w-3 h-3"})}),r.jsx(Y,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",title:T.personSource==="vip_sync"?"删除本地 @人物(不删统一获客计划)":"删除(同时删除存客宝对应获客计划)",onClick:()=>ta(T),children:r.jsx(us,{className:"w-3 h-3"})})]})})]},T.id))})]}):r.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无AI人物添加后可在编辑器中 @链接"})})]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{className:"pb-3",children:[r.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[r.jsx(VM,{className:"w-4 h-4 text-[#38bdac]"}),"存客宝绑定"]}),r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"配置存客宝 API 后,文章中 @人物 或 #标签 点击可自动进入存客宝流量池"})]}),r.jsxs(Le,{className:"space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"存客宝 API 地址"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"https://ckbapi.quwanzhi.com",defaultValue:"https://ckbapi.quwanzhi.com",readOnly:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"绑定计划"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"创业实验-内容引流",defaultValue:"创业实验-内容引流",readOnly:!0})]})]}),r.jsxs("p",{className:"text-xs text-gray-500",children:["具体存客宝场景配置与接口测试请前往"," ",r.jsx("button",{className:"text-[#38bdac] hover:underline",onClick:()=>window.open("/match","_blank"),children:"找伙伴 → 存客宝工作台"})]})]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{className:"pb-3",children:[r.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[r.jsx(lh,{className:"w-4 h-4 text-blue-400"}),"获客 Webhook 通知"]}),r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"配置后新获客线索将自动推送到群聊(支持企业微信/飞书 Webhook"})]}),r.jsxs(Le,{className:"space-y-3",children:[r.jsxs("div",{className:"flex gap-3 items-end",children:[r.jsxs("div",{className:"flex-1 space-y-1",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"Webhook URL"}),r.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:Zs,onChange:T=>er(T.target.value)})]}),r.jsxs(Y,{size:"sm",className:"bg-blue-500 hover:bg-blue-600 text-white h-8",onClick:async()=>{const T=Zs.trim();try{const B=await Et("/api/db/config",{key:"ckb_lead_webhook_url",value:T,description:"获客线索 Webhook 通知 URL企微/飞书)"});B!=null&&B.success?oe.success(T?"Webhook 已保存":"Webhook 已清除"):oe.error((B==null?void 0:B.error)??"保存失败")}catch{oe.error("保存失败")}},children:[r.jsx(En,{className:"w-3.5 h-3.5 mr-1"}),"保存"]})]}),r.jsx("p",{className:"text-xs text-gray-500",children:"配置企业微信或飞书群机器人 Webhook URL获客成功后自动推送通知"})]})]})]}),r.jsxs(bn,{value:"link-tag",className:"space-y-4",children:[r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{className:"pb-3",children:[r.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[r.jsx(r1,{className:"w-4 h-4 text-amber-400"}),"链接标签 — 链接事与物(编辑器内 #标签 可跳转链接/小程序/存客宝)"]}),r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"小程序端点击 #标签 可直接跳转对应链接,进入流量池"})]}),r.jsxs(Le,{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-end justify-between gap-3 flex-wrap",children:[r.jsxs("div",{className:"flex items-end gap-2 flex-wrap",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-400 text-xs",children:"搜索"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-48",placeholder:"按标签ID/显示文字搜索",value:Rr,onChange:T=>{Pr(T.target.value),Mr(1)}})]}),r.jsx(Y,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50 h-8",onClick:()=>{qn(),za()},title:"刷新",children:r.jsx(Be,{className:"w-4 h-4"})})]}),r.jsxs(Y,{size:"sm",className:"bg-amber-500 hover:bg-amber-600 text-white h-8",onClick:()=>{ea(null),ss({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",pagePath:""}),_r(""),sr(!1),Or(!0)},children:[r.jsx(Pn,{className:"w-4 h-4 mr-2"}),"添加标签"]})]}),r.jsxs("div",{className:"rounded-md border border-gray-700/50 overflow-hidden",children:[r.jsx("div",{className:"max-h-[420px] overflow-y-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{className:"bg-[#0a1628] border-b border-gray-700/50",children:r.jsxs("tr",{children:[r.jsx("th",{className:"text-left px-3 py-2 text-gray-400 w-32",children:"标签"}),r.jsx("th",{className:"text-left px-3 py-2 text-gray-400 w-28",children:"别名"}),r.jsx("th",{className:"text-left px-3 py-2 text-gray-400 w-20",children:"类型"}),r.jsx("th",{className:"text-left px-3 py-2 text-gray-400",children:"目标 / AppID"}),r.jsx("th",{className:"text-right px-3 py-2 text-gray-400 w-28",children:"操作"})]})}),r.jsx("tbody",{children:be?r.jsx("tr",{children:r.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:"加载中..."})}):Wn.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:"暂无链接标签,添加后可在编辑器中使用 #标签 跳转"})}):Wn.map(T=>r.jsxs("tr",{className:"border-b border-gray-700/30 hover:bg-white/5",children:[r.jsx("td",{className:"px-3 py-2",children:r.jsxs("button",{type:"button",className:"text-amber-400 font-semibold hover:text-amber-300 hover:underline text-left",onClick:()=>{ea(T),ss({tagId:T.id,label:T.label,aliases:T.aliases??"",url:T.url,type:T.type,appId:T.appId??"",pagePath:T.pagePath??""}),_r(T.appId??""),sr(!1),Or(!0)},title:"点击编辑标签",children:["#",T.label]})}),r.jsx("td",{className:"px-3 py-2 text-gray-500 text-xs truncate max-w-[120px]",title:T.aliases||"",children:T.aliases||"—"}),r.jsx("td",{className:"px-3 py-2",children:r.jsx(Ge,{variant:"secondary",className:`text-[10px] ${T.type==="ckb"?"bg-green-500/20 text-green-300 border-green-500/30":T.type==="miniprogram"?"bg-[#38bdac]/20 text-[#38bdac] border-[#38bdac]/30":"bg-gray-700 text-gray-300"}`,children:T.type==="url"?"网页":T.type==="ckb"?"存客宝":"小程序"})}),r.jsx("td",{className:"px-3 py-2 text-gray-300",children:T.type==="miniprogram"?r.jsxs("div",{className:"space-y-0.5",children:[(()=>{const B=$a.find(he=>he.key===T.appId);return r.jsxs(r.Fragment,{children:[B&&r.jsx("div",{className:"text-xs text-white",children:B.name}),r.jsxs("div",{className:"text-xs font-mono text-[#38bdac]",children:["AppID: ",(B==null?void 0:B.appId)||T.appId||"—"]})]})})(),T.pagePath&&r.jsx("div",{className:"text-xs text-gray-500 font-mono",children:T.pagePath})]}):T.url?r.jsxs("a",{href:T.url,target:"_blank",rel:"noreferrer",className:"text-blue-400 text-xs truncate max-w-[420px] hover:underline inline-flex items-center gap-1",children:[T.url," ",r.jsx(di,{className:"w-3 h-3 shrink-0"})]}):r.jsx("span",{className:"text-gray-500 text-xs",children:"—"})}),r.jsx("td",{className:"px-3 py-2",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(Y,{variant:"ghost",size:"sm",className:"text-gray-300 hover:text-white h-7 px-2",onClick:()=>{ea(T),ss({tagId:T.id,label:T.label,aliases:T.aliases??"",url:T.url,type:T.type,appId:T.appId??"",pagePath:T.pagePath??""}),_r(T.appId??""),sr(!1),Or(!0)},title:"编辑",children:r.jsx(a1,{className:"w-3 h-3"})}),r.jsx(Y,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-7 px-2",onClick:async()=>{if(confirm(`确定要删除「#${T.label}」吗?`))try{const B=await ai(`/api/db/link-tags?tagId=${encodeURIComponent(T.id)}`);B!=null&&B.success?(oe.success("已删除"),qn(),za()):oe.error((B==null?void 0:B.error)??"删除失败")}catch(B){console.error(B),oe.error("删除失败")}},title:"删除",children:r.jsx(us,{className:"w-3 h-3"})})]})})]},T.id))})]})}),r.jsx(Gs,{page:hn,pageSize:Pa,total:Oa,totalPages:No,onPageChange:T=>Mr(T),onPageSizeChange:T=>{Ar(T),Mr(1)}})]})]})]}),r.jsx(Ht,{open:mr,onOpenChange:Or,children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg p-4 gap-3",children:[r.jsxs(Ut,{className:"gap-1",children:[r.jsx(Wt,{className:"text-base",children:mi?"编辑链接标签":"添加链接标签"}),r.jsx(Qh,{className:"text-gray-400 text-xs",children:"配置后可在富文本编辑器中通过 #标签 插入,并在小程序端点击跳转"})]}),r.jsxs("div",{className:"space-y-3 py-2",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-300 text-sm",children:"标签ID"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"留空自动生成;或填 12位数字 / z开头12位",value:St.tagId,disabled:!!mi,onChange:T=>ss(B=>({...B,tagId:T.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-300 text-sm",children:"显示文字"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"如 神仙团队",value:St.label,onChange:T=>ss(B=>({...B,label:T.target.value}))})]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-300 text-sm",children:"别名(多个用逗号分隔,同指向一个目标)"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"如 团队招募, 团队合伙人",value:St.aliases,onChange:T=>ss(B=>({...B,aliases:T.target.value}))})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 items-end",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-300 text-sm",children:"类型"}),r.jsxs(rc,{value:St.type,onValueChange:T=>ss(B=>({...B,type:T})),children:[r.jsx(Ko,{className:"bg-[#0a1628] border-gray-700 text-white h-8",children:r.jsx(ac,{})}),r.jsxs(qo,{className:"bg-[#0f2137] border-gray-700 text-white",children:[r.jsx(lr,{value:"url",children:"网页链接"}),r.jsx(lr,{value:"miniprogram",children:"小程序"}),r.jsx(lr,{value:"ckb",children:"存客宝"})]})]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-300 text-sm",children:St.type==="url"?"URL地址":St.type==="ckb"?"存客宝计划URL":"小程序(选密钥)"}),St.type==="miniprogram"&&$a.length>0?r.jsxs("div",{ref:$c,className:"relative",children:[r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"搜索名称或密钥",value:Fa?ua:St.appId,onChange:T=>{const B=T.target.value;_r(B),sr(!0),$a.some(he=>he.key===B)||ss(he=>({...he,appId:B}))},onFocus:()=>{_r(St.appId),sr(!0)},onBlur:()=>setTimeout(()=>sr(!1),150)}),Fa&&r.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 max-h-48 overflow-y-auto rounded-md border border-gray-700 bg-[#0a1628] shadow-lg z-50",children:$r.length===0?r.jsx("div",{className:"px-3 py-2 text-gray-500 text-xs",children:"无匹配,可手动输入密钥"}):$r.map(T=>r.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm text-white hover:bg-[#38bdac]/20 flex flex-col gap-0.5",onMouseDown:B=>{B.preventDefault(),ss(he=>({...he,appId:T.key,pagePath:T.path||""})),_r(""),sr(!1)},children:[r.jsx("span",{children:T.name}),r.jsx("span",{className:"text-xs text-gray-400 font-mono",children:T.key})]},T.key))})]}):r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:St.type==="url"?"https://...":St.type==="ckb"?"https://ckbapi.quwanzhi.com/...":"关联小程序的32位密钥",value:St.type==="url"||St.type==="ckb"?St.url:St.appId,onChange:T=>{St.type==="url"||St.type==="ckb"?ss(B=>({...B,url:T.target.value})):ss(B=>({...B,appId:T.target.value}))}})]})]}),St.type==="miniprogram"&&r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-300 text-sm",children:"页面路径(可选)"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"pages/index/index",value:St.pagePath,onChange:T=>ss(B=>({...B,pagePath:T.target.value}))})]})]}),r.jsxs(xn,{className:"gap-2 pt-1",children:[r.jsx(Y,{variant:"outline",onClick:()=>Or(!1),className:"border-gray-600",children:"取消"}),r.jsx(Y,{onClick:async()=>{const T={tagId:St.tagId.trim(),label:St.label.trim(),aliases:St.aliases.trim(),url:St.url.trim(),type:St.type,appId:St.appId.trim(),pagePath:St.pagePath.trim()};if(T.tagId&&!(/^\d{12}$/.test(T.tagId)||/^z[a-z0-9]{11}$/.test(T.tagId))){oe.error("标签ID需为12位数字或 z 开头的12位z+11位小写字母数字");return}if(!T.label){oe.error("显示文字必填");return}T.type==="miniprogram"&&(T.url=""),La(!0);try{const B=await Et("/api/db/link-tags",T);B!=null&&B.success?(oe.success(mi?"已更新":"已添加"),Or(!1),qn(),za()):oe.error((B==null?void 0:B.error)??"保存失败")}catch(B){console.error(B),oe.error("保存失败")}finally{La(!1)}},disabled:Lr,className:"bg-amber-500 hover:bg-amber-600 text-white",children:Lr?"保存中...":"保存"})]})]})})]})]}),r.jsx(AV,{open:jl,onOpenChange:$s,editingPerson:wo,onSubmit:async T=>{var ke;const B={personId:T.personId||T.name.toLowerCase().replace(/\s+/g,"_")+"_"+Date.now().toString(36),name:T.name,userId:T.boundUserId,aliases:T.aliases||void 0,label:T.label,ckbApiKey:T.ckbApiKey||void 0,greeting:T.greeting||void 0,tips:T.tips||void 0,remarkType:T.remarkType||void 0,remarkFormat:T.remarkFormat||void 0,addFriendInterval:T.addFriendInterval,startTime:T.startTime||void 0,endTime:T.endTime||void 0,deviceGroups:(ke=T.deviceGroups)!=null&&ke.trim()?T.deviceGroups.split(",").map(Je=>parseInt(Je.trim(),10)).filter(Je=>!Number.isNaN(Je)):void 0},he=await Et("/api/db/persons",B);if(he&&he.success===!1){const Je=he;Je.ckbResponse&&console.log("存客宝返回",Je.ckbResponse);const ft=Je.error||"操作失败";throw new Error(ft)}if(Kn(),oe.success(wo?"已保存":"已添加"),he!=null&&he.ckbCreateResult&&Object.keys(he.ckbCreateResult).length>0){const Je=he.ckbCreateResult;console.log("存客宝创建结果",Je);const ft=Je.planId??Je.id,Lt=ft!=null?[`planId: ${ft}`]:[];Je.apiKey!=null&&Lt.push("apiKey: ***"),oe.info(Lt.length?`存客宝创建结果:${Lt.join("")}`:"存客宝创建结果见控制台")}}}),r.jsx(Ht,{open:!!Xs,onOpenChange:T=>{T||ta(null)},children:r.jsxs(_t,{showCloseButton:!0,className:"bg-[#0f2137] border-gray-700 text-white max-w-md p-4 gap-3",children:[r.jsxs(Ut,{className:"gap-1",children:[r.jsx(Wt,{className:"text-white text-base",children:"确认删除"}),r.jsx(Qh,{className:"text-gray-400 text-sm leading-relaxed wrap-break-word",children:Xs&&r.jsxs(r.Fragment,{children:[Xs.personSource==="vip_sync"?r.jsxs(r.Fragment,{children:[r.jsxs("p",{children:["确定删除超级个体「",Xs.name,"」对应的 @人物?"]}),r.jsxs("p",{className:"mt-1.5 text-amber-200/90",children:["仅删除本系统的 Person 与独立 token",r.jsx("strong",{children:"不会"}),"删除存客宝里的「超级个体统一获客计划」(其他超级个体仍在使用该计划)。"]})]}):r.jsx(r.Fragment,{children:r.jsxs("p",{children:["确定删除「SOUL链接人与事-",Xs.name,"」?将同时删除存客宝对应获客计划。"]})}),r.jsxs("p",{className:"mt-1.5",children:["二次确认:删除后无法恢复,文章中的 @",Xs.name," 将无法正常跳转。"]})]})})]}),r.jsxs(xn,{className:"gap-2 sm:gap-2 pt-1",children:[r.jsx(Y,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300",onClick:()=>ta(null),children:"取消"}),r.jsx(Y,{variant:"destructive",size:"sm",className:"bg-red-600 hover:bg-red-700",onClick:async()=>{Xs&&(await ai(`/api/db/persons?personId=${Xs.personId}`),ta(null),Kn(),oe.success("已删除"))},children:"确定删除"})]})]})}),r.jsx(Ht,{open:jo,onOpenChange:gi,children:r.jsxs(_t,{className:"max-w-2xl bg-[#0f2137] border-gray-700",children:[r.jsx(Ut,{children:r.jsxs(Wt,{className:"text-white flex items-center gap-2",children:[r.jsx(zn,{className:"w-5 h-5 text-green-400"}),xi," — 获客详情(共 ",fn," 条)"]})}),r.jsx("div",{className:"max-h-[450px] overflow-y-auto space-y-2",children:Fs?r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(Be,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):Rs.length===0?r.jsx("div",{className:"text-gray-500 text-sm py-8 text-center",children:"暂无获客记录"}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-[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:[r.jsx("span",{children:"#"}),r.jsx("span",{children:"昵称/姓名"}),r.jsx("span",{children:"手机"}),r.jsx("span",{children:"微信"}),r.jsx("span",{children:"来源"}),r.jsx("span",{children:"状态"}),r.jsx("span",{children:"时间"})]}),Rs.map((T,B)=>r.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:[r.jsx("span",{className:"text-gray-500 text-xs",children:(ra-1)*20+B+1}),r.jsx("span",{className:"text-white truncate",children:T.nickname||T.name||T.userId||"-"}),r.jsx("span",{className:"text-gray-300 text-xs",children:T.phone||"-"}),r.jsx("span",{className:"text-gray-300 text-xs truncate",children:T.wechatId||"-"}),r.jsx("span",{className:"text-xs",children:T.source==="article_mention"?r.jsx("span",{className:"text-purple-400",children:"文章@"}):T.source==="index_lead"?r.jsx("span",{className:"text-blue-400",children:"首页"}):r.jsx("span",{className:"text-gray-500",children:T.source||"-"})}),r.jsx("span",{className:"text-[10px]",children:r.jsx("span",{className:"text-green-400 bg-green-400/10 px-1 py-0.5 rounded",children:"已添加"})}),r.jsx("span",{className:"text-gray-500 text-xs",children:T.createdAt?new Date(T.createdAt).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-"})]},T.id))]})}),fn>20&&r.jsxs("div",{className:"flex items-center justify-center gap-2 pt-2",children:[r.jsx(Y,{size:"sm",variant:"outline",disabled:ra<=1,onClick:()=>rs(sa,xi,ra-1),className:"border-gray-600 text-gray-300 bg-transparent h-7 px-3",children:"上一页"}),r.jsxs("span",{className:"text-gray-400 text-xs",children:[ra," / ",Math.ceil(fn/20)]}),r.jsx(Y,{size:"sm",variant:"outline",disabled:ra>=Math.ceil(fn/20),onClick:()=>rs(sa,xi,ra+1),className:"border-gray-600 text-gray-300 bg-transparent h-7 px-3",children:"下一页"})]})]})})]})}const ri={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 Bw(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):ri.stats}function Vw(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?e:String(e??"")).filter(Boolean):ri.highlights}function PV(){const[t,e]=b.useState(ri),[n,s]=b.useState(!0),[a,i]=b.useState(!1),[o,c]=b.useState(!1),u=b.useRef(null);b.useEffect(()=>{De("/api/admin/author-settings").then(k=>{const E=k==null?void 0:k.data;E&&typeof E=="object"&&e({name:String(E.name??ri.name),avatar:String(E.avatar??ri.avatar),avatarImg:String(E.avatarImg??""),title:String(E.title??ri.title),bio:String(E.bio??ri.bio),stats:Bw(E.stats).length?Bw(E.stats):ri.stats,highlights:Vw(E.highlights).length?Vw(E.highlights):ri.highlights})}).catch(console.error).finally(()=>s(!1))},[]);const h=async()=>{i(!0);try{const k={name:t.name,avatar:t.avatar||"K",avatarImg:t.avatarImg,title:t.title,bio:t.bio,stats:t.stats.filter(P=>P.label||P.value),highlights:t.highlights.filter(Boolean)},E=await Et("/api/admin/author-settings",k);if(!E||E.success===!1){oe.error("保存失败: "+(E&&typeof E=="object"&&"error"in E?E.error:""));return}i(!1);const C=document.createElement("div");C.className="fixed top-4 right-4 z-50 px-4 py-2 rounded-lg bg-[#38bdac] text-white text-sm shadow-lg",C.textContent="作者设置已保存",document.body.appendChild(C),setTimeout(()=>C.remove(),2e3)}catch(k){console.error(k),oe.error("保存失败: "+(k instanceof Error?k.message:String(k)))}finally{i(!1)}},f=async k=>{var C;const E=(C=k.target.files)==null?void 0:C[0];if(E){c(!0);try{const P=new FormData;P.append("file",E),P.append("folder","avatars");const O=nu(),U={};O&&(U.Authorization=`Bearer ${O}`);const V=await(await fetch(xc("/api/upload"),{method:"POST",body:P,credentials:"include",headers:U})).json();V!=null&&V.success&&(V!=null&&V.url)?e(A=>({...A,avatarImg:V.url})):oe.error("上传失败: "+((V==null?void 0:V.error)||"未知错误"))}catch(P){console.error(P),oe.error("上传失败")}finally{c(!1),u.current&&(u.current.value="")}}},m=()=>e(k=>({...k,stats:[...k.stats,{label:"",value:""}]})),g=k=>e(E=>({...E,stats:E.stats.filter((C,P)=>P!==k)})),y=(k,E,C)=>e(P=>({...P,stats:P.stats.map((O,U)=>U===k?{...O,[E]:C}:O)})),v=()=>e(k=>({...k,highlights:[...k.highlights,""]})),w=k=>e(E=>({...E,highlights:E.highlights.filter((C,P)=>P!==k)})),N=(k,E)=>e(C=>({...C,highlights:C.highlights.map((P,O)=>O===k?E:P)}));return n?r.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(tl,{className:"w-5 h-5 text-[#38bdac]"}),"作者详情"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"配置小程序「关于作者」页展示的作者信息,包括头像、简介、统计数据与亮点标签。"})]}),r.jsxs(Y,{onClick:h,disabled:a||n,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存"]})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"flex items-center gap-2 text-white",children:[r.jsx(tl,{className:"w-4 h-4 text-[#38bdac]"}),"基本信息"]}),r.jsx(Kt,{className:"text-gray-400",children:"作者姓名、头像、头衔与个人简介,将展示在「关于作者」页顶部。"})]}),r.jsxs(Le,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"姓名"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.name,onChange:k=>e(E=>({...E,name:k.target.value})),placeholder:"卡若"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"首字母占位(无头像时显示)"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white w-20",value:t.avatar,onChange:k=>e(E=>({...E,avatar:k.target.value.slice(0,1)||"K"})),placeholder:"K"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(ee,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(bj,{className:"w-3 h-3 text-[#38bdac]"}),"头像图片"]}),r.jsxs("div",{className:"flex gap-3 items-center",children:[r.jsx(ce,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:t.avatarImg,onChange:k=>e(E=>({...E,avatarImg:k.target.value})),placeholder:"上传或粘贴 URL如 /uploads/avatars/xxx.png"}),r.jsx("input",{ref:u,type:"file",accept:"image/*",className:"hidden",onChange:f}),r.jsxs(Y,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:o,onClick:()=>{var k;return(k=u.current)==null?void 0:k.click()},children:[r.jsx(qh,{className:"w-4 h-4 mr-2"}),o?"上传中...":"上传"]})]}),t.avatarImg&&r.jsx("div",{className:"mt-2",children:r.jsx("img",{src:io(t.avatarImg.startsWith("http")?t.avatarImg:xc(t.avatarImg)),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"头衔"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.title,onChange:k=>e(E=>({...E,title:k.target.value})),placeholder:"Soul派对房主理人 · 私域运营专家"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"个人简介"}),r.jsx(cl,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[120px]",value:t.bio,onChange:k=>e(E=>({...E,bio:k.target.value})),placeholder:"每天早上6点到9点..."})]})]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{children:[r.jsx(ot,{className:"text-white",children:"统计数据"}),r.jsx(Kt,{className:"text-gray-400",children:"展示在作者卡片中的数字指标,如「商业案例 62」「连续直播 365天」。第一个「商业案例」的值可由书籍统计自动更新。"})]}),r.jsxs(Le,{className:"space-y-3",children:[t.stats.map((k,E)=>r.jsxs("div",{className:"flex gap-3 items-center",children:[r.jsx(ce,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.label,onChange:C=>y(E,"label",C.target.value),placeholder:"标签"}),r.jsx(ce,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.value,onChange:C=>y(E,"value",C.target.value),placeholder:"数值"}),r.jsx(Y,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>g(E),children:r.jsx(us,{className:"w-4 h-4"})})]},E)),r.jsxs(Y,{variant:"outline",size:"sm",onClick:m,className:"border-gray-600 text-gray-400",children:[r.jsx(Pn,{className:"w-4 h-4 mr-2"}),"添加统计项"]})]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{children:[r.jsx(ot,{className:"text-white",children:"亮点标签"}),r.jsx(Kt,{className:"text-gray-400",children:"作者优势或成就的简短描述,以标签形式展示。"})]}),r.jsxs(Le,{className:"space-y-3",children:[t.highlights.map((k,E)=>r.jsxs("div",{className:"flex gap-3 items-center",children:[r.jsx(ce,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k,onChange:C=>N(E,C.target.value),placeholder:"5年私域运营经验"}),r.jsx(Y,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>w(E),children:r.jsx(us,{className:"w-4 h-4"})})]},E)),r.jsxs(Y,{variant:"outline",size:"sm",onClick:v,className:"border-gray-600 text-gray-400",children:[r.jsx(Pn,{className:"w-4 h-4 mr-2"}),"添加亮点"]})]})]})]})]})}function OV(){const[t,e]=b.useState([]),[n,s]=b.useState(0),[a,i]=b.useState(1),[o]=b.useState(10),[c,u]=b.useState(0),[h,f]=b.useState(""),m=Xh(h,300),[g,y]=b.useState(!0),[v,w]=b.useState(null),[N,k]=b.useState(!1),[E,C]=b.useState(null),[P,O]=b.useState(""),[U,_]=b.useState(""),[V,A]=b.useState(""),[X,G]=b.useState("admin"),[z,ne]=b.useState("active"),[ue,K]=b.useState(!1);async function $(){var F;y(!0),w(null);try{const re=new URLSearchParams({page:String(a),pageSize:String(o)});m.trim()&&re.set("search",m.trim());const ge=await De(`/api/admin/admin-users?${re}`);ge!=null&&ge.success?(e(ge.records||[]),s(ge.total??0),u(ge.totalPages??0)):w(ge.error||"加载失败")}catch(re){const ge=re;w(ge.status===403?"无权限访问":((F=ge==null?void 0:ge.data)==null?void 0:F.error)||"加载失败"),e([])}finally{y(!1)}}b.useEffect(()=>{$()},[a,o,m]);const D=()=>{C(null),O(""),_(""),A(""),G("admin"),ne("active"),k(!0)},I=F=>{C(F),O(F.username),_(""),A(F.name||""),G(F.role==="super_admin"?"super_admin":"admin"),ne(F.status==="disabled"?"disabled":"active"),k(!0)},ie=async()=>{var F;if(!P.trim()){w("用户名不能为空");return}if(!E&&!U){w("新建时密码必填,至少 6 位");return}if(U&&U.length<6){w("密码至少 6 位");return}w(null),K(!0);try{if(E){const re=await Jt("/api/admin/admin-users",{id:E.id,password:U||void 0,name:V.trim(),role:X,status:z});re!=null&&re.success?(k(!1),$()):w((re==null?void 0:re.error)||"保存失败")}else{const re=await Et("/api/admin/admin-users",{username:P.trim(),password:U,name:V.trim(),role:X});re!=null&&re.success?(k(!1),$()):w((re==null?void 0:re.error)||"保存失败")}}catch(re){const ge=re;w(((F=ge==null?void 0:ge.data)==null?void 0:F.error)||"保存失败")}finally{K(!1)}},q=async F=>{var re;if(confirm("确定删除该管理员?"))try{const ge=await ai(`/api/admin/admin-users?id=${F}`);ge!=null&&ge.success?$():w((ge==null?void 0:ge.error)||"删除失败")}catch(ge){const Te=ge;w(((re=Te==null?void 0:Te.data)==null?void 0:re.error)||"删除失败")}},L=F=>{if(!F)return"-";try{const re=new Date(F);return isNaN(re.getTime())?F:re.toLocaleString("zh-CN")}catch{return F}};return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-6",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(ic,{className:"w-5 h-5 text-[#38bdac]"}),"管理员用户"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"后台登录账号管理,仅超级管理员可操作"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ce,{placeholder:"搜索用户名/昵称",value:h,onChange:F=>f(F.target.value),className:"w-48 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"}),r.jsx(Y,{variant:"outline",size:"sm",onClick:$,disabled:g,className:"border-gray-600 text-gray-300",children:r.jsx(Be,{className:`w-4 h-4 ${g?"animate-spin":""}`})}),r.jsxs(Y,{onClick:D,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Pn,{className:"w-4 h-4 mr-2"}),"新增管理员"]})]})]}),v&&r.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-red-400 text-sm flex justify-between items-center",children:[r.jsx("span",{children:v}),r.jsx("button",{type:"button",onClick:()=>w(null),className:"text-red-400 hover:text-red-300",children:"×"})]}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Le,{className:"p-0",children:g?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(r.Fragment,{children:[r.jsxs(hs,{children:[r.jsx(fs,{children:r.jsxs(pt,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(je,{className:"text-gray-400",children:"ID"}),r.jsx(je,{className:"text-gray-400",children:"用户名"}),r.jsx(je,{className:"text-gray-400",children:"昵称"}),r.jsx(je,{className:"text-gray-400",children:"角色"}),r.jsx(je,{className:"text-gray-400",children:"状态"}),r.jsx(je,{className:"text-gray-400",children:"创建时间"}),r.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsxs(ps,{children:[t.map(F=>r.jsxs(pt,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:F.id}),r.jsx(ve,{className:"text-white font-medium",children:F.username}),r.jsx(ve,{className:"text-gray-400",children:F.name||"-"}),r.jsx(ve,{children:r.jsx(Ge,{variant:"outline",className:F.role==="super_admin"?"border-amber-500/50 text-amber-400":"border-gray-600 text-gray-400",children:F.role==="super_admin"?"超级管理员":"管理员"})}),r.jsx(ve,{children:r.jsx(Ge,{variant:"outline",className:F.status==="active"?"border-[#38bdac]/50 text-[#38bdac]":"border-gray-500 text-gray-500",children:F.status==="active"?"正常":"已禁用"})}),r.jsx(ve,{className:"text-gray-500 text-sm",children:L(F.createdAt)}),r.jsxs(ve,{className:"text-right",children:[r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>I(F),className:"text-gray-400 hover:text-[#38bdac]",children:r.jsx(en,{className:"w-4 h-4"})}),r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>q(F.id),className:"text-gray-400 hover:text-red-400",children:r.jsx(ks,{className:"w-4 h-4"})})]})]},F.id)),t.length===0&&!g&&r.jsx(pt,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:v==="无权限访问"?"仅超级管理员可查看":"暂无管理员"})})]})]}),c>1&&r.jsx("div",{className:"p-4 border-t border-gray-700/50",children:r.jsx(Gs,{page:a,pageSize:o,total:n,totalPages:c,onPageChange:i})})]})})}),r.jsx(Ht,{open:N,onOpenChange:k,children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[r.jsx(Ut,{children:r.jsx(Wt,{className:"text-white",children:E?"编辑管理员":"新增管理员"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"用户名"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"登录用户名",value:P,onChange:F=>O(F.target.value),disabled:!!E}),E&&r.jsx("p",{className:"text-xs text-gray-500",children:"用户名不可修改"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:E?"新密码(留空不改)":"密码"}),r.jsx(ce,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:E?"留空表示不修改":"至少 6 位",value:U,onChange:F=>_(F.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"昵称"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"显示名称",value:V,onChange:F=>A(F.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"角色"}),r.jsxs("select",{value:X,onChange:F=>G(F.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[r.jsx("option",{value:"admin",children:"管理员"}),r.jsx("option",{value:"super_admin",children:"超级管理员"})]})]}),E&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"状态"}),r.jsxs("select",{value:z,onChange:F=>ne(F.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[r.jsx("option",{value:"active",children:"正常"}),r.jsx("option",{value:"disabled",children:"禁用"})]})]})]}),r.jsxs(xn,{children:[r.jsxs(Y,{variant:"outline",onClick:()=>k(!1),className:"border-gray-600 text-gray-300",children:[r.jsx(us,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(Y,{onClick:ie,disabled:ue,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),ue?"保存中...":"保存"]})]})]})})]})}function kn({method:t,url:e,desc:n,headers:s,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 r.jsxs("div",{className:"rounded-lg bg-[#0a1628]/60 border border-gray-700/50 p-4 space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:`font-mono font-semibold ${c}`,children:t}),r.jsx("code",{className:"text-sm text-[#38bdac] break-all",children:e})]}),n&&r.jsx("p",{className:"text-gray-400 text-sm",children:n}),s&&s.length>0&&r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"Headers"}),r.jsx("pre",{className:"text-xs text-gray-300 font-mono overflow-x-auto p-2 rounded bg-black/30",children:s.join(`
`)})]}),i&&r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:a??"Request Body (JSON)"}),r.jsx("pre",{className:"text-xs text-green-400/90 font-mono overflow-x-auto p-2 rounded bg-black/30 whitespace-pre-wrap",children:i})]}),o&&r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"Response Example"}),r.jsx("pre",{className:"text-xs text-amber-200/80 font-mono overflow-x-auto p-2 rounded bg-black/30 whitespace-pre-wrap",children:o})]})]})}function a4(){const t=["Authorization: Bearer {token}","Content-Type: application/json"];return r.jsxs("div",{className:"p-8 w-full bg-[#0a1628] text-white",children:[r.jsxs("div",{className:"mb-8",children:[r.jsx("h1",{className:"text-2xl font-bold text-white",children:"API 接口文档"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"内容管理相关接口 · RESTful · 基础路径 /api · 管理端需 Bearer Token"})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(it,{className:"pb-3",children:r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(vj,{className:"w-5 h-5 text-[#38bdac]"}),"1. Authentication"]})}),r.jsx(Le,{className:"space-y-4",children:r.jsx(kn,{method:"POST",url:"/api/admin",desc:"登录,返回 JWT token",headers:["Content-Type: application/json"],body:`{
"username": "admin",
"password": "your_password"
}`,response:`{
"success": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_at": "2026-03-16T12:00:00Z"
}`})})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(it,{className:"pb-3",children:r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(Js,{className:"w-5 h-5 text-[#38bdac]"}),"2. 章节管理 (Chapters)"]})}),r.jsxs(Le,{className:"space-y-4",children:[r.jsx(kn,{method:"GET",url:"/api/db/book?action=chapters",desc:"获取章节树",headers:t,response:`{
"success": true,
"data": [
{ "id": "part-1", "title": "第一篇", "children": [...] },
{ "id": "section-1", "title": "第1节", "price": 1.0, "isFree": false }
]
}`}),r.jsx(kn,{method:"GET",url:"/api/db/book?action=section&id={id}",desc:"获取单篇内容",headers:t,response:`{
"success": true,
"data": {
"id": "section-1",
"title": "标题",
"content": "正文...",
"price": 1.0,
"isFree": false,
"partId": "part-1",
"chapterId": "ch-1"
}
}`}),r.jsx(kn,{method:"POST",url:"/api/db/book",desc:"新建章节 (action=create-section)",headers:t,body:`{
"action": "create-section",
"title": "新章节标题",
"content": "正文内容",
"price": 0,
"isFree": true,
"partId": "part-1",
"chapterId": "ch-1",
"partTitle": "第一篇",
"chapterTitle": "第1章"
}`,response:`{
"success": true,
"data": { "id": "section-new-id", "title": "新章节标题", ... }
}`}),r.jsx(kn,{method:"POST",url:"/api/db/book",desc:"更新章节内容 (action=update-section)",headers:t,body:`{
"action": "update-section",
"id": "section-1",
"title": "更新后的标题",
"content": "更新后的正文",
"price": 1.0,
"isFree": false
}`,response:`{
"success": true,
"data": { "id": "section-1", "title": "更新后的标题", ... }
}`}),r.jsx(kn,{method:"POST",url:"/api/db/book",desc:"删除章节 (action=delete-section)",headers:t,body:`{
"action": "delete-section",
"id": "section-1"
}`,response:`{
"success": true,
"message": "已删除"
}`}),r.jsxs("div",{className:"rounded-lg border border-[#38bdac]/30 bg-[#0a1628]/40 p-4 space-y-2",children:[r.jsx("p",{className:"text-[#38bdac] text-sm font-medium",children:"富文本流程说明(编辑器 ⇄ 接口)"}),r.jsxs("ol",{className:"text-gray-400 text-xs space-y-2 list-decimal list-inside leading-relaxed",children:[r.jsxs("li",{children:["先 ",r.jsx("code",{className:"text-[#38bdac]",children:"POST /api/upload"})," 上传素材,得到"," ",r.jsx("code",{className:"text-amber-200/90",children:"url"}),"(可为相对路径 ",r.jsx("code",{className:"text-amber-200/90",children:"/uploads/..."})," 或 OSS 完整 URL。"]}),r.jsxs("li",{children:["将返回的 ",r.jsx("code",{className:"text-amber-200/90",children:"url"})," 填入正文 HTML图片用"," ",r.jsx("code",{className:"text-green-400/90",children:'<img src="...">'}),";视频用"," ",r.jsx("code",{className:"text-green-400/90",children:'<div class="rich-video-wrap"><video src="..." controls></video></div>'}),";附件用带链接的段落或"," ",r.jsx("code",{className:"text-green-400/90",children:'<a href="...">文件名</a>'}),"。"]}),r.jsxs("li",{children:["最后把完整 HTML 字符串写入"," ",r.jsx("code",{className:"text-[#38bdac]",children:"create-section"})," /"," ",r.jsx("code",{className:"text-[#38bdac]",children:"update-section"})," 的 ",r.jsx("code",{className:"text-amber-200/90",children:"content"})," 字段。"]})]}),r.jsxs("p",{className:"text-gray-500 text-xs",children:["管理后台编辑器内图片/视频仅作小预览CSS 类 ",r.jsx("code",{className:"text-gray-400",children:".rich-editor-content"}),"),不影响已保存 HTMLC 端按小程序/Web 自己的样式渲染全尺寸。"]})]}),r.jsx(kn,{method:"POST",url:"/api/upload",desc:"上传章节富文本素材:图片 / 视频 / 附件multipart与后台「内容管理」编辑器一致。按 form 字段 folder 区分类型与大小上限。",headers:["Authorization: Bearer {token}(建议携带,与后台一致)","Content-Type: multipart/form-data由浏览器自动带 boundary不要手写为 application/json"],bodyTitle:"Request (multipart/form-data)",body:`字段:
file — 二进制文件(必填)
folder — 存储子目录(必填约定):
• book-images 图片≤5MBimage/*
• book-videos 视频≤100MBvideo/*(如 mp4、mov、webm
• book-attachments 附件≤30MBpdf/zip/Office/txt 等
成功时 data.url 与根字段 url 均为可访问地址。`,response:`{
"success": true,
"url": "/uploads/book-images/1730000000000_abc123.jpg",
"data": {
"url": "/uploads/book-images/1730000000000_abc123.jpg",
"fileName": "1730000000000_abc123.jpg",
"size": 102400,
"type": "image/jpeg"
}
}`}),r.jsx(kn,{method:"DELETE",url:"/api/upload?path={encodeURIComponent(文件URL)}",desc:"按 URL 删除已上传文件(本地或 OSS需与上传返回的 url 一致)",headers:["Authorization: Bearer {token}(建议携带)"],response:`{
"success": true,
"message": "删除成功"
}`})]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(it,{className:"pb-3",children:r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(tl,{className:"w-5 h-5 text-[#38bdac]"}),"3. 人物管理 (@Mentions)"]})}),r.jsxs(Le,{className:"space-y-4",children:[r.jsx(kn,{method:"GET",url:"/api/db/persons",desc:"人物列表",headers:t,response:`{
"success": true,
"data": [
{ "personId": "p1", "label": "张三", "aliases": ["老张"], ... }
]
}`}),r.jsx(kn,{method:"GET",url:"/api/db/person?personId={id}",desc:"人物详情",headers:t,response:`{
"success": true,
"data": {
"personId": "p1",
"label": "张三",
"aliases": ["老张"],
"description": "..."
}
}`}),r.jsx(kn,{method:"POST",url:"/api/db/persons",desc:"新增/更新人物(含 aliases 字段)",headers:t,body:`{
"personId": "p1",
"label": "张三",
"aliases": ["老张", "张三丰"],
"description": "可选描述"
}`,response:`{
"success": true,
"data": { "personId": "p1", "label": "张三", ... }
}`}),r.jsx(kn,{method:"DELETE",url:"/api/db/persons?personId={id}",desc:"删除人物",headers:t,response:`{
"success": true,
"message": "已删除"
}`})]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(it,{className:"pb-3",children:r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(Sd,{className:"w-5 h-5 text-[#38bdac]"}),"4. 链接标签 (#LinkTags)"]})}),r.jsxs(Le,{className:"space-y-4",children:[r.jsx(kn,{method:"GET",url:"/api/db/link-tags",desc:"标签列表",headers:t,response:`{
"success": true,
"data": [
{ "tagId": "t1", "label": "官网", "aliases": [], "type": "url", "url": "https://..." }
]
}`}),r.jsx(kn,{method:"POST",url:"/api/db/link-tags",desc:"新增/更新标签(含 aliases, type: url/miniprogram/ckb",headers:t,body:`{
"tagId": "t1",
"label": "官网",
"aliases": ["官方网站"],
"type": "url",
"url": "https://example.com"
}
// type 可选: url | miniprogram | ckb`,response:`{
"success": true,
"data": { "tagId": "t1", "label": "官网", "type": "url", ... }
}`}),r.jsx(kn,{method:"DELETE",url:"/api/db/link-tags?tagId={id}",desc:"删除标签",headers:t,response:`{
"success": true,
"message": "已删除"
}`})]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(it,{className:"pb-3",children:r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(Sa,{className:"w-5 h-5 text-[#38bdac]"}),"5. 内容搜索"]})}),r.jsx(Le,{className:"space-y-4",children:r.jsx(kn,{method:"GET",url:"/api/search?q={keyword}",desc:"搜索(标题优先 3 条 + 内容匹配)",headers:t,response:`{
"success": true,
"data": {
"titleMatches": [{ "id": "s1", "title": "...", "snippet": "..." }],
"contentMatches": [{ "id": "s2", "title": "...", "snippet": "..." }]
}
}`})})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(it,{className:"pb-3",children:r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(lx,{className:"w-5 h-5 text-[#38bdac]"}),"6. 内容排行"]})}),r.jsx(Le,{className:"space-y-4",children:r.jsx(kn,{method:"GET",url:"/api/db/book?action=ranking",desc:"排行榜数据",headers:t,response:`{
"success": true,
"data": [
{ "id": "s1", "title": "...", "clickCount": 100, "payCount": 50, "hotScore": 120, "hotRank": 1 }
]
}`})})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(it,{className:"pb-3",children:r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(mc,{className:"w-5 h-5 text-[#38bdac]"}),"7. 小程序接口"]})}),r.jsxs(Le,{className:"space-y-4",children:[r.jsx(kn,{method:"GET",url:"/api/miniprogram/config/read-extras",desc:"阅读页懒加载linkTags、linkedMiniprograms、mentionPersons@ 自动解析name/label/aliases + token与 persons 表一致inPool 表示已绑定会员即超级个体侧流量池人物)",headers:["Content-Type: application/json"],response:`{
"linkTags": [],
"linkedMiniprograms": [],
"mentionPersons": [
{ "personId": "xxx", "token": "32位...", "name": "陈周", "aliases": "", "label": "", "inPool": true }
]
}`}),r.jsx(kn,{method:"GET",url:"/api/miniprogram/book/all-chapters",desc:"全部章节(小程序用)",headers:["Content-Type: application/json"],response:`{
"success": true,
"data": [ { "id": "s1", "title": "...", "price": 1.0, "isFree": false }, ... ]
}`}),r.jsx(kn,{method:"GET",url:"/api/miniprogram/balance?userId={id}",desc:"查余额",headers:["Content-Type: application/json"],response:`{
"success": true,
"data": { "balance": 100.50, "userId": "xxx" }
}`}),r.jsx(kn,{method:"POST",url:"/api/miniprogram/balance/gift",desc:"代付",headers:["Content-Type: application/json"],body:`{
"userId": "xxx",
"amount": 10.00,
"remark": "可选备注"
}`,response:`{
"success": true,
"data": { "balance": 110.50 }
}`}),r.jsx(kn,{method:"POST",url:"/api/miniprogram/balance/gift/redeem",desc:"领取代付",headers:["Content-Type: application/json"],body:`{
"code": "GIFT_XXXX"
}`,response:`{
"success": true,
"data": { "amount": 10.00, "balance": 120.50 }
}`})]})]}),r.jsx("p",{className:"text-gray-500 text-xs mt-6",children:"管理端主要使用 /api/admin/*、/api/db/*;富文本素材上传另用公共接口 /api/upload与后台编辑器一致。小程序使用 /api/miniprogram/*。完整实现见 soul-api 源码。"})]})}const LV={appId:"wxb8bbb2b10dec74aa",withdrawSubscribeTmplId:"u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE",mchId:"1318592501",minWithdraw:10},DV={name:"卡若",startDate:"2025年10月15日",bio:"连续创业者,私域运营专家,每天早上6-9点在Soul派对房分享真实商业故事",liveTime:"06:00-09:00",platform:"Soul派对房",description:"连续创业者,私域运营专家"},_V={sectionPrice:1,baseBookPrice:9.9,distributorShare:90,authorInfo:{...DV},ckbLeadApiKey:""},zV={matchEnabled:!0,referralEnabled:!0,searchEnabled:!0,aboutEnabled:!0},$V={tabBar:{home:"首页",chapters:"目录",match:"找伙伴",my:"我的"},chaptersPage:{bookTitle:"一场SOUL的创业实验场",bookSubtitle:"来自Soul派对房的真实商业故事"},homePage:{logoTitle:"卡若创业派对",logoSubtitle:"来自派对房的真实故事",linkKaruoText:"点击链接卡若",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"}},FV=["system","author","admin","api-docs"];function BV(){const[t,e]=f0(),n=t.get("tab")??"system",s=FV.includes(n)?n:"system",[a,i]=b.useState(_V),[o,c]=b.useState(zV),[u,h]=b.useState(LV),[f,m]=b.useState("{}"),[g,y]=b.useState({}),[v,w]=b.useState(!1),[N,k]=b.useState(!0),[E,C]=b.useState(!1),[P,O]=b.useState(""),[U,_]=b.useState(""),[V,A]=b.useState(!1),[X,G]=b.useState(!1),z=["INTJ","INTP","ENTJ","ENTP","INFJ","INFP","ENFJ","ENFP","ISTJ","ISFJ","ESTJ","ESFJ","ISTP","ISFP","ESTP","ESFP"],[ne,ue]=b.useState({}),[K,$]=b.useState(!1),[D,I]=b.useState(!1),ie=async()=>{$(!0);try{const Q=await De("/api/admin/mbti-avatars");Q!=null&&Q.avatars&&ue(Q.avatars)}catch{}finally{$(!1)}},q=async()=>{I(!0);try{const Q=await Et("/api/admin/mbti-avatars",{avatars:ne});if(!Q||Q.success===!1){L("保存失败",(Q==null?void 0:Q.error)??"未知错误",!0);return}L("已保存","MBTI 头像映射已保存,无头像的超级个体将自动使用对应性格头像。")}catch(Q){L("保存失败",Q instanceof Error?Q.message:String(Q),!0)}finally{I(!1)}},L=(Q,Z,xe=!1)=>{O(Q),_(Z),A(xe),C(!0)};b.useEffect(()=>{(async()=>{try{const Z=await De("/api/admin/settings");if(!Z||Z.success===!1)return;if(Z.featureConfig&&Object.keys(Z.featureConfig).length&&c(xe=>({...xe,...Z.featureConfig})),Z.mpConfig&&typeof Z.mpConfig=="object"){const xe={...Z.mpConfig};h(ct=>({...ct,...xe}));const Ne=xe.mpUi;m(JSON.stringify(Ne!=null&&typeof Ne=="object"&&!Array.isArray(Ne)?Ne:{},null,2))}if(Z.ossConfig&&typeof Z.ossConfig=="object"&&y(xe=>({...xe,...Z.ossConfig})),Z.siteSettings&&typeof Z.siteSettings=="object"){const xe=Z.siteSettings;i(Ne=>({...Ne,...typeof xe.sectionPrice=="number"&&{sectionPrice:xe.sectionPrice},...typeof xe.baseBookPrice=="number"&&{baseBookPrice:xe.baseBookPrice},...typeof xe.distributorShare=="number"&&{distributorShare:xe.distributorShare},...xe.authorInfo&&typeof xe.authorInfo=="object"&&{authorInfo:{...Ne.authorInfo,...xe.authorInfo}},...typeof xe.ckbLeadApiKey=="string"&&{ckbLeadApiKey:xe.ckbLeadApiKey}}))}}catch(Z){console.error("Load settings error:",Z)}finally{k(!1)}})(),ie()},[]);const F=async(Q,Z)=>{G(!0);try{const xe=await Et("/api/admin/settings",{featureConfig:Q});if(!xe||xe.success===!1){Z(),L("保存失败",(xe==null?void 0:xe.error)??"未知错误",!0);return}L("已保存","功能开关已更新,相关入口将随之显示或隐藏。")}catch(xe){console.error("Save feature config error:",xe),Z(),L("保存失败",xe instanceof Error?xe.message:String(xe),!0)}finally{G(!1)}},re=(Q,Z)=>{const xe=o,Ne={...xe,[Q]:Z};c(Ne),F(Ne,()=>c(xe))},[ge,Te]=b.useState(!1),se=async Q=>{const Z=u,xe={...Z,auditMode:Q};h(xe),Te(!0);try{const Ne=await Et("/api/admin/settings",{mpConfig:xe});if(!Ne||Ne.success===!1){h(Z),L("保存失败",(Ne==null?void 0:Ne.error)??"未知错误",!0);return}L("已保存",Q?"审核模式已开启,小程序将隐藏所有支付入口。":"审核模式已关闭,支付功能已恢复。")}catch(Ne){h(Z),L("保存失败",Ne instanceof Error?Ne.message:String(Ne),!0)}finally{Te(!1)}},le=async()=>{w(!0);try{let Q={};try{const xe=f.trim();if(xe){const Ne=JSON.parse(xe);if(Ne&&typeof Ne=="object"&&!Array.isArray(Ne))Q=Ne;else{L("保存失败","小程序文案 mpUi 须为 JSON 对象(非数组)",!0),w(!1);return}}}catch{L("保存失败","小程序文案 mpUi 不是合法 JSON",!0),w(!1);return}const Z=await Et("/api/admin/settings",{featureConfig:o,siteSettings:{sectionPrice:a.sectionPrice,baseBookPrice:a.baseBookPrice,distributorShare:a.distributorShare,authorInfo:a.authorInfo,ckbLeadApiKey:a.ckbLeadApiKey||void 0},mpConfig:{...u,appId:u.appId||"",withdrawSubscribeTmplId:u.withdrawSubscribeTmplId||"",mchId:u.mchId||"",minWithdraw:typeof u.minWithdraw=="number"?u.minWithdraw:10,auditMode:u.auditMode??!1,mpUi:Q},ossConfig:Object.keys(g).length?{endpoint:g.endpoint??"",bucket:g.bucket??"",region:g.region??"",accessKeyId:g.accessKeyId??"",accessKeySecret:g.accessKeySecret??""}:void 0});if(!Z||Z.success===!1){L("保存失败",(Z==null?void 0:Z.error)??"未知错误",!0);return}L("已保存","设置已保存成功。")}catch(Q){console.error("Save settings error:",Q),L("保存失败",Q instanceof Error?Q.message:String(Q),!0)}finally{w(!1)}},ae=Q=>{e(Q==="system"?{}:{tab:Q})};return N?r.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-6",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"系统设置"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"配置全站基础参数与开关"})]}),s==="system"&&r.jsxs(Y,{onClick:le,disabled:v,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),v?"保存中...":"保存设置"]})]}),r.jsxs(au,{value:s,onValueChange:ae,className:"w-full",children:[r.jsxs(Ac,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1",children:[r.jsxs(yn,{value:"system",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[r.jsx(el,{className:"w-4 h-4 mr-2"}),"系统设置"]}),r.jsxs(yn,{value:"author",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[r.jsx(ih,{className:"w-4 h-4 mr-2"}),"作者详情"]}),r.jsxs(yn,{value:"admin",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[r.jsx(ic,{className:"w-4 h-4 mr-2"}),"管理员"]}),r.jsxs(yn,{value:"api-docs",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",onClick:Q=>{Q.preventDefault(),window.open("/api-docs","_blank")},children:[r.jsx(xj,{className:"w-4 h-4 mr-2"}),"API 文档 ↗"]})]}),r.jsx(bn,{value:"system",className:"mt-0",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(ih,{className:"w-5 h-5 text-[#38bdac]"}),"关于作者"]}),r.jsx(Kt,{className:"text-gray-400",children:'配置作者信息,将在"关于作者"页面显示'})]}),r.jsxs(Le,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(ee,{htmlFor:"author-name",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(ih,{className:"w-3 h-3"}),"主理人名称"]}),r.jsx(ce,{id:"author-name",className:"bg-[#0a1628] border-gray-700 text-white",value:a.authorInfo.name??"",onChange:Q=>i(Z=>({...Z,authorInfo:{...Z.authorInfo,name:Q.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(ee,{htmlFor:"start-date",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(tx,{className:"w-3 h-3"}),"开播日期"]}),r.jsx(ce,{id:"start-date",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 2025年10月15日",value:a.authorInfo.startDate??"",onChange:Q=>i(Z=>({...Z,authorInfo:{...Z.authorInfo,startDate:Q.target.value}}))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(ee,{htmlFor:"live-time",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(tx,{className:"w-3 h-3"}),"直播时间"]}),r.jsx(ce,{id:"live-time",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 06:00-09:00",value:a.authorInfo.liveTime??"",onChange:Q=>i(Z=>({...Z,authorInfo:{...Z.authorInfo,liveTime:Q.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(ee,{htmlFor:"platform",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(Nj,{className:"w-3 h-3"}),"直播平台"]}),r.jsx(ce,{id:"platform",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: Soul派对房",value:a.authorInfo.platform??"",onChange:Q=>i(Z=>({...Z,authorInfo:{...Z.authorInfo,platform:Q.target.value}}))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(ee,{htmlFor:"description",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(Js,{className:"w-3 h-3"}),"简介描述"]}),r.jsx(ce,{id:"description",className:"bg-[#0a1628] border-gray-700 text-white",value:a.authorInfo.description??"",onChange:Q=>i(Z=>({...Z,authorInfo:{...Z.authorInfo,description:Q.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{htmlFor:"bio",className:"text-gray-300",children:"详细介绍"}),r.jsx(cl,{id:"bio",className:"bg-[#0a1628] border-gray-700 text-white min-h-[100px]",placeholder:"输入作者详细介绍...",value:a.authorInfo.bio??"",onChange:Q=>i(Z=>({...Z,authorInfo:{...Z.authorInfo,bio:Q.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(ee,{htmlFor:"ckb-lead-api-key",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(ro,{className:"w-3 h-3"}),"链接卡若存客宝密钥"]}),r.jsx(ce,{id:"ckb-lead-api-key",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 xxxxx-xxxxx-xxxxx-xxxxx留空则用 .env 默认)",value:a.ckbLeadApiKey??"",onChange:Q=>i(Z=>({...Z,ckbLeadApiKey:Q.target.value}))}),r.jsx("p",{className:"text-xs text-gray-500",children:"小程序首页「链接卡若」留资接口使用的存客宝 API Key优先于 .env 配置"})]}),r.jsxs("div",{className:"mt-4 p-4 rounded-xl bg-[#0a1628] border border-[#38bdac]/30",children:[r.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"预览效果"}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-12 h-12 rounded-full bg-gradient-to-br from-[#00CED1] to-[#20B2AA] flex items-center justify-center text-xl font-bold text-white",children:(a.authorInfo.name??"K").charAt(0)}),r.jsxs("div",{children:[r.jsx("p",{className:"text-white font-semibold",children:a.authorInfo.name}),r.jsx("p",{className:"text-gray-400 text-xs",children:a.authorInfo.description}),r.jsxs("p",{className:"text-[#38bdac] text-xs mt-1",children:["每日 ",a.authorInfo.liveTime," · ",a.authorInfo.platform]})]})]})]})]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(Uh,{className:"w-5 h-5 text-[#38bdac]"}),"价格设置"]}),r.jsx(Kt,{className:"text-gray-400",children:"配置书籍和章节的定价"})]}),r.jsx(Le,{className:"space-y-4",children:r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"单节价格 (元)"}),r.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:a.sectionPrice,onChange:Q=>i(Z=>({...Z,sectionPrice:Number.parseFloat(Q.target.value)||1}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"整本价格 (元)"}),r.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:a.baseBookPrice,onChange:Q=>i(Z=>({...Z,baseBookPrice:Number.parseFloat(Q.target.value)||9.9}))})]})]})})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(mc,{className:"w-5 h-5 text-[#38bdac]"}),"小程序配置"]}),r.jsx(Kt,{className:"text-gray-400",children:"订阅消息模板、支付商户号等,小程序从 /api/miniprogram/config 读取API 地址由 app.js baseUrl 控制)"})]}),r.jsxs(Le,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"小程序 AppID"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"wxb8bbb2b10dec74aa",value:u.appId??"",onChange:Q=>h(Z=>({...Z,appId:Q.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"提现订阅模板 ID"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"用户申请提现时需授权",value:u.withdrawSubscribeTmplId??"",onChange:Q=>h(Z=>({...Z,withdrawSubscribeTmplId:Q.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"微信支付商户号"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"1318592501",value:u.mchId??"",onChange:Q=>h(Z=>({...Z,mchId:Q.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"最低提现金额 (元)"}),r.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:u.minWithdraw??10,onChange:Q=>h(Z=>({...Z,minWithdraw:Number.parseFloat(Q.target.value)||10}))})]})]}),r.jsxs("div",{className:"space-y-2 pt-2 border-t border-gray-700/50",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[r.jsx(ee,{className:"text-gray-300",children:"小程序界面文案 mpUiJSON"}),r.jsx(Y,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-200",onClick:()=>m(JSON.stringify($V,null,2)),children:"填入默认模板"})]}),r.jsx("p",{className:"text-xs text-gray-500",children:"覆盖 Tab 文案、首页/目录标题、我的页名片与阅读记录路径等;仅填需要改的字段也可(与后端默认值深合并)。保存后小程序约 5 分钟内通过 config 缓存刷新。"}),r.jsx(cl,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm min-h-[280px]",spellCheck:!1,value:f,onChange:Q=>m(Q.target.value)})]})]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(h5,{className:"w-5 h-5 text-[#38bdac]"}),"OSS 配置(阿里云对象存储)"]}),r.jsx(Kt,{className:"text-gray-400",children:"endpoint、bucket、accessKey 等,用于图片/文件上传"})]}),r.jsx(Le,{className:"space-y-4",children:r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"Endpoint"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou.aliyuncs.com",value:g.endpoint??"",onChange:Q=>y(Z=>({...Z,endpoint:Q.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"Bucket"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"bucket 名称",value:g.bucket??"",onChange:Q=>y(Z=>({...Z,bucket:Q.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"Region"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou",value:g.region??"",onChange:Q=>y(Z=>({...Z,region:Q.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"AccessKey ID"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey ID",value:g.accessKeyId??"",onChange:Q=>y(Z=>({...Z,accessKeyId:Q.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"AccessKey Secret"}),r.jsx(ce,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey Secret",value:g.accessKeySecret??"",onChange:Q=>y(Z=>({...Z,accessKeySecret:Q.target.value}))})]})]})})]}),r.jsxs(Oe,{className:`bg-[#0f2137] shadow-xl ${u.auditMode?"border-amber-500/50 border-2":"border-gray-700/50"}`,children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(ic,{className:"w-5 h-5 text-amber-400"}),"小程序审核模式"]}),r.jsx(Kt,{className:"text-gray-400",children:"提交微信审核前开启,审核通过后关闭即可恢复支付功能"})]}),r.jsx(Le,{children:r.jsxs("div",{className:`flex items-center justify-between p-4 rounded-lg border ${u.auditMode?"bg-amber-500/10 border-amber-500/30":"bg-[#0a1628] border-gray-700/50"}`,children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ic,{className:`w-4 h-4 ${u.auditMode?"text-amber-400":"text-gray-400"}`}),r.jsx(ee,{htmlFor:"audit-mode",className:"text-white font-medium cursor-pointer",children:u.auditMode?"审核模式(已开启)":"审核模式(已关闭)"})]}),r.jsx("p",{className:"text-xs text-gray-400 ml-6",children:u.auditMode?"当前已隐藏所有支付、VIP、充值、收益等入口审核员看不到任何付费内容":"关闭状态小程序正常显示所有功能含支付、VIP 等)"})]}),r.jsx(Rt,{id:"audit-mode",checked:u.auditMode??!1,disabled:ge,onCheckedChange:se})]})})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(el,{className:"w-5 h-5 text-[#38bdac]"}),"功能开关"]}),r.jsx(Kt,{className:"text-gray-400",children:"控制各个功能模块的显示/隐藏"})]}),r.jsxs(Le,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(zn,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx(ee,{htmlFor:"match-enabled",className:"text-white font-medium cursor-pointer",children:"找伙伴功能"})]}),r.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制小程序和Web端的找伙伴功能显示"})]}),r.jsx(Rt,{id:"match-enabled",checked:o.matchEnabled,disabled:X,onCheckedChange:Q=>re("matchEnabled",Q)})]}),r.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(rx,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx(ee,{htmlFor:"referral-enabled",className:"text-white font-medium cursor-pointer",children:"推广功能"})]}),r.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制推广中心的显示(我的页面入口)"}),r.jsxs("p",{className:"text-xs text-amber-400/80 ml-6 mt-1",children:["佣金比例、绑定期、提现规则等与",r.jsx($d,{to:"/distribution?tab=settings",className:"underline mx-1 text-[#38bdac]",children:"推广中心 → 推广设置"}),"为同一套接口,在此仅控制是否展示入口。"]})]}),r.jsx(Rt,{id:"referral-enabled",checked:o.referralEnabled,disabled:X,onCheckedChange:Q=>re("referralEnabled",Q)})]}),r.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Js,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx(ee,{htmlFor:"search-enabled",className:"text-white font-medium cursor-pointer",children:"搜索功能"})]}),r.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制首页、目录页搜索栏的显示"})]}),r.jsx(Rt,{id:"search-enabled",checked:o.searchEnabled,disabled:X,onCheckedChange:Q=>re("searchEnabled",Q)})]}),r.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(el,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx(ee,{htmlFor:"about-enabled",className:"text-white font-medium cursor-pointer",children:"关于页面"})]}),r.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制关于页面的访问"})]}),r.jsx(Rt,{id:"about-enabled",checked:o.aboutEnabled,disabled:X,onCheckedChange:Q=>re("aboutEnabled",Q)})]})]}),r.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:r.jsx("p",{className:"text-xs text-blue-300",children:"💡 关闭功能后,相关入口会自动隐藏。建议在功能开发完成后再开启。"})})]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(o1,{className:"w-5 h-5 text-[#38bdac]"}),"MBTI 头像组"]}),r.jsx(Kt,{className:"text-gray-400",children:"为 16 种 MBTI 性格类型配置默认头像 URL。无头像的超级个体将自动使用对应性格的头像。"})]}),r.jsx(Le,{className:"space-y-4",children:K?r.jsx("p",{className:"text-gray-500 text-sm",children:"加载中..."}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"grid grid-cols-2 gap-3",children:z.map(Q=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-[#38bdac] font-mono w-10 flex-shrink-0",children:Q}),ne[Q]&&r.jsx("img",{src:ne[Q],alt:Q,className:"w-8 h-8 rounded-full flex-shrink-0 object-cover border border-gray-600"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white text-xs h-8 flex-1",placeholder:"头像 URL",value:ne[Q]??"",onChange:Z=>ue(xe=>({...xe,[Q]:Z.target.value}))})]},Q))}),r.jsxs(Y,{onClick:q,disabled:D,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",size:"sm",children:[r.jsx(En,{className:"w-3 h-3 mr-1"}),D?"保存中...":"保存头像映射"]})]})})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(Wh,{className:"w-5 h-5 text-[#38bdac]"}),"小程序模块显隐说明"]}),r.jsx(Kt,{className:"text-gray-400",children:"以下模块受上方开关和审核模式共同控制"})]}),r.jsx(Le,{children:r.jsx("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[{mod:"找伙伴",ctrl:"找伙伴功能开关",icon:r.jsx(zn,{className:"w-3 h-3"})},{mod:"推广中心 / 推荐好友",ctrl:"推广功能开关",icon:r.jsx(rx,{className:"w-3 h-3"})},{mod:"搜索",ctrl:"搜索功能开关",icon:r.jsx(Js,{className:"w-3 h-3"})},{mod:"关于页面",ctrl:"关于页面开关",icon:r.jsx(ih,{className:"w-3 h-3"})},{mod:"支付 / VIP / 充值 / 收益",ctrl:"审核模式",icon:r.jsx(ic,{className:"w-3 h-3"})},{mod:"超级个体名片",ctrl:"审核模式",icon:r.jsx(o1,{className:"w-3 h-3"})},{mod:"首页获客入口",ctrl:"已移除",icon:r.jsx(j5,{className:"w-3 h-3"})}].map(Q=>r.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#0a1628] border border-gray-700/30",children:[Q.icon,r.jsxs("div",{children:[r.jsx("span",{className:"text-white",children:Q.mod}),r.jsxs("span",{className:"text-gray-500 ml-1",children:["← ",Q.ctrl]})]})]},Q.mod))})})]})]})}),r.jsx(bn,{value:"author",className:"mt-0",children:r.jsx(PV,{})}),r.jsx(bn,{value:"admin",className:"mt-0",children:r.jsx(OV,{})}),r.jsx(bn,{value:"api-docs",className:"mt-0",children:r.jsx(a4,{})})]}),r.jsx(Ht,{open:E,onOpenChange:C,children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[r.jsxs(Ut,{children:[r.jsx(Wt,{className:V?"text-red-400":"text-[#38bdac]",children:P}),r.jsx(Qh,{className:"text-gray-400 whitespace-pre-wrap pt-2",children:U})]}),r.jsx(xn,{className:"mt-4",children:r.jsx(Y,{onClick:()=>C(!1),className:V?"bg-gray-600 hover:bg-gray-500":"bg-[#38bdac] hover:bg-[#2da396]",children:"确定"})})]})})]})}const Hw={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 VV(){const[t,e]=b.useState(!1),[n,s]=b.useState(Hw),[a,i]=b.useState(""),o=async()=>{e(!0);try{const k=await De("/api/config");k!=null&&k.paymentMethods&&s({...Hw,...k.paymentMethods})}catch(k){console.error(k)}finally{e(!1)}};b.useEffect(()=>{o()},[]);const c=async()=>{e(!0);try{await Et("/api/db/config",{key:"payment_methods",value:n,description:"支付方式配置"}),oe.success("配置已保存!")}catch(k){console.error("保存失败:",k),oe.error("保存失败: "+(k instanceof Error?k.message:String(k)))}finally{e(!1)}},u=(k,E)=>{navigator.clipboard.writeText(k),i(E),setTimeout(()=>i(""),2e3)},h=(k,E)=>{s(C=>({...C,wechat:{...C.wechat,[k]:E}}))},f=(k,E)=>{s(C=>({...C,alipay:{...C.alipay,[k]:E}}))},m=(k,E)=>{s(C=>({...C,usdt:{...C.usdt,[k]:E}}))},g=(k,E)=>{s(C=>({...C,paypal:{...C.paypal,[k]:E}}))},y=n.wechat,v=n.alipay,w=n.usdt,N=n.paypal;return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold mb-2 text-white",children:"支付配置"}),r.jsx("p",{className:"text-gray-400",children:"配置微信、支付宝、USDT、PayPal等支付参数"})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs(Y,{variant:"outline",onClick:o,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"同步配置"]}),r.jsxs(Y,{onClick:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),"保存配置"]})]})]}),r.jsx("div",{className:"mb-6 bg-[#07C160]/10 border border-[#07C160]/30 rounded-xl p-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(pj,{className:"w-5 h-5 text-[#07C160] flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"text-sm",children:[r.jsx("p",{className:"font-medium mb-2 text-[#07C160]",children:"如何获取微信群跳转链接?"}),r.jsxs("ol",{className:"text-[#07C160]/80 space-y-1 list-decimal list-inside",children:[r.jsx("li",{children:"打开微信,进入目标微信群"}),r.jsx("li",{children:'点击右上角"..." → "群二维码"'}),r.jsx("li",{children:'点击右上角"..." → "发送到电脑"'}),r.jsx("li",{children:"在电脑上保存二维码图片上传到图床获取URL"}),r.jsx("li",{children:"或使用草料二维码等工具解析二维码获取链接"})]}),r.jsx("p",{className:"text-[#07C160]/60 mt-2",children:"提示微信群二维码7天后失效建议使用活码工具"})]})]})}),r.jsxs(au,{defaultValue:"wechat",className:"space-y-6",children:[r.jsxs(Ac,{className:"bg-[#0f2137] border border-gray-700/50 p-1 grid grid-cols-4 w-full",children:[r.jsxs(yn,{value:"wechat",className:"data-[state=active]:bg-[#07C160]/20 data-[state=active]:text-[#07C160] text-gray-400",children:[r.jsx(mc,{className:"w-4 h-4 mr-2"}),"微信"]}),r.jsxs(yn,{value:"alipay",className:"data-[state=active]:bg-[#1677FF]/20 data-[state=active]:text-[#1677FF] text-gray-400",children:[r.jsx(s1,{className:"w-4 h-4 mr-2"}),"支付宝"]}),r.jsxs(yn,{value:"usdt",className:"data-[state=active]:bg-[#26A17B]/20 data-[state=active]:text-[#26A17B] text-gray-400",children:[r.jsx(n1,{className:"w-4 h-4 mr-2"}),"USDT"]}),r.jsxs(yn,{value:"paypal",className:"data-[state=active]:bg-[#003087]/20 data-[state=active]:text-[#169BD7] text-gray-400",children:[r.jsx(ax,{className:"w-4 h-4 mr-2"}),"PayPal"]})]}),r.jsx(bn,{value:"wechat",className:"space-y-4",children:r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs(ot,{className:"text-[#07C160] flex items-center gap-2",children:[r.jsx(mc,{className:"w-5 h-5"}),"微信支付配置"]}),r.jsx(Kt,{className:"text-gray-400",children:"配置微信支付参数和跳转链接"})]}),r.jsx(Rt,{checked:!!y.enabled,onCheckedChange:k=>h("enabled",k)})]}),r.jsxs(Le,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"网站AppID"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.websiteAppId??""),onChange:k=>h("websiteAppId",k.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"商户号"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.merchantId??""),onChange:k=>h("merchantId",k.target.value)})]})]}),r.jsxs("div",{className:"border-t border-gray-700/50 pt-4 space-y-4",children:[r.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[r.jsx(di,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置(核心功能)"]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"微信收款码/支付链接"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://收款码图片URL 或 weixin://支付链接",value:String(y.qrCode??""),onChange:k=>h("qrCode",k.target.value)}),r.jsx("p",{className:"text-xs text-gray-500",children:"用户点击微信支付后显示的二维码图片URL"})]}),r.jsxs("div",{className:"space-y-2 bg-[#07C160]/5 p-4 rounded-xl border border-[#07C160]/20",children:[r.jsx(ee,{className:"text-[#07C160] font-medium",children:"微信群跳转链接(支付成功后跳转)"}),r.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:k=>h("groupQrCode",k.target.value)}),r.jsx("p",{className:"text-xs text-[#07C160]/70",children:"用户支付成功后将自动跳转到此链接,进入指定微信群"})]})]})]})]})}),r.jsx(bn,{value:"alipay",className:"space-y-4",children:r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs(ot,{className:"text-[#1677FF] flex items-center gap-2",children:[r.jsx(s1,{className:"w-5 h-5"}),"支付宝配置"]}),r.jsx(Kt,{className:"text-gray-400",children:"已加载真实支付宝参数"})]}),r.jsx(Rt,{checked:!!v.enabled,onCheckedChange:k=>f("enabled",k)})]}),r.jsxs(Le,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"合作者身份 (PID)"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(v.partnerId??""),onChange:k=>f("partnerId",k.target.value)}),r.jsx(Y,{size:"icon",variant:"outline",className:"border-gray-700 bg-transparent",onClick:()=>u(String(v.partnerId??""),"pid"),children:a==="pid"?r.jsx(Qf,{className:"w-4 h-4 text-green-500"}):r.jsx(gj,{className:"w-4 h-4 text-gray-400"})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"安全校验码 (Key)"}),r.jsx(ce,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(v.securityKey??""),onChange:k=>f("securityKey",k.target.value)})]})]}),r.jsxs("div",{className:"border-t border-gray-700/50 pt-4 space-y-4",children:[r.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[r.jsx(di,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置"]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"支付宝收款码/跳转链接"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://qr.alipay.com/... 或收款码图片URL",value:String(v.qrCode??""),onChange:k=>f("qrCode",k.target.value)}),r.jsx("p",{className:"text-xs text-gray-500",children:"用户点击支付宝支付后显示的二维码"})]})]})]})]})}),r.jsx(bn,{value:"usdt",className:"space-y-4",children:r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs(ot,{className:"text-[#26A17B] flex items-center gap-2",children:[r.jsx(n1,{className:"w-5 h-5"}),"USDT配置"]}),r.jsx(Kt,{className:"text-gray-400",children:"配置加密货币收款地址"})]}),r.jsx(Rt,{checked:!!w.enabled,onCheckedChange:k=>m("enabled",k)})]}),r.jsxs(Le,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"网络类型"}),r.jsxs("select",{className:"w-full bg-[#0a1628] border border-gray-700 text-white rounded-md p-2",value:String(w.network??"TRC20"),onChange:k=>m("network",k.target.value),children:[r.jsx("option",{value:"TRC20",children:"TRC20 (波场)"}),r.jsx("option",{value:"ERC20",children:"ERC20 (以太坊)"}),r.jsx("option",{value:"BEP20",children:"BEP20 (币安链)"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"收款地址"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",placeholder:"T... (TRC20地址)",value:String(w.address??""),onChange:k=>m("address",k.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),r.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(w.exchangeRate)??7.2,onChange:k=>m("exchangeRate",Number.parseFloat(k.target.value)||7.2)})]})]})]})}),r.jsx(bn,{value:"paypal",className:"space-y-4",children:r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs(ot,{className:"text-[#169BD7] flex items-center gap-2",children:[r.jsx(ax,{className:"w-5 h-5"}),"PayPal配置"]}),r.jsx(Kt,{className:"text-gray-400",children:"配置PayPal收款账户"})]}),r.jsx(Rt,{checked:!!N.enabled,onCheckedChange:k=>g("enabled",k)})]}),r.jsxs(Le,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"PayPal邮箱"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"your@email.com",value:String(N.email??""),onChange:k=>g("email",k.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),r.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(N.exchangeRate)??7.2,onChange:k=>g("exchangeRate",Number(k.target.value)||7.2)})]})]})]})})]})]})}const HV={siteName:"卡若日记",siteTitle:"一场SOUL的创业实验场",siteDescription:"来自Soul派对房的真实商业故事",logo:"/logo.png",favicon:"/favicon.ico",primaryColor:"#00CED1"},UV={home:{enabled:!0,label:"首页"},chapters:{enabled:!0,label:"目录"},match:{enabled:!0,label:"匹配"},my:{enabled:!0,label:"我的"}},WV={homeTitle:"一场SOUL的创业实验场",homeSubtitle:"来自Soul派对房的真实商业故事",chaptersTitle:"我要看",matchTitle:"语音匹配",myTitle:"我的",aboutTitle:"关于作者"};function KV(){const[t,e]=b.useState({siteConfig:{...HV},menuConfig:{...UV},pageConfig:{...WV}}),[n,s]=b.useState(!1),[a,i]=b.useState(!1);b.useEffect(()=>{De("/api/config").then(f=>{f!=null&&f.siteConfig&&e(m=>({...m,siteConfig:{...m.siteConfig,...f.siteConfig}})),f!=null&&f.menuConfig&&e(m=>({...m,menuConfig:{...m.menuConfig,...f.menuConfig}})),f!=null&&f.pageConfig&&e(m=>({...m,pageConfig:{...m.pageConfig,...f.pageConfig}}))}).catch(console.error)},[]);const o=async()=>{i(!0);try{await Et("/api/db/config",{key:"site_config",value:t.siteConfig,description:"网站基础配置"}),await Et("/api/db/config",{key:"menu_config",value:t.menuConfig,description:"底部菜单配置"}),await Et("/api/db/config",{key:"page_config",value:t.pageConfig,description:"页面标题配置"}),s(!0),setTimeout(()=>s(!1),2e3),oe.success("配置已保存")}catch(f){console.error(f),oe.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{i(!1)}},c=t.siteConfig,u=t.menuConfig,h=t.pageConfig;return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"网站配置"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"配置网站名称、图标、菜单和页面标题"})]}),r.jsxs(Y,{onClick:o,disabled:a,className:`${n?"bg-green-500":"bg-[#00CED1]"} hover:bg-[#20B2AA] text-white transition-colors`,children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),a?"保存中...":n?"已保存":"保存设置"]})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(ax,{className:"w-5 h-5 text-[#00CED1]"}),"网站基础信息"]}),r.jsx(Kt,{className:"text-gray-400",children:"配置网站名称、标题和描述"})]}),r.jsxs(Le,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{htmlFor:"site-name",className:"text-gray-300",children:"网站名称"}),r.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}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{htmlFor:"site-title",className:"text-gray-300",children:"网站标题"}),r.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}}))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{htmlFor:"site-desc",className:"text-gray-300",children:"网站描述"}),r.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}}))})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{htmlFor:"logo",className:"text-gray-300",children:"Logo地址"}),r.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}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{htmlFor:"favicon",className:"text-gray-300",children:"Favicon地址"}),r.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}}))})]})]})]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(xM,{className:"w-5 h-5 text-[#00CED1]"}),"主题颜色"]}),r.jsx(Kt,{className:"text-gray-400",children:"配置网站主题色"})]}),r.jsx(Le,{children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("div",{className:"space-y-2 flex-1",children:[r.jsx(ee,{htmlFor:"primary-color",className:"text-gray-300",children:"主色调"}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.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}}))}),r.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}}))})]})]}),r.jsx("div",{className:"w-24 h-24 rounded-xl flex items-center justify-center text-white font-bold",style:{backgroundColor:c.primaryColor??"#00CED1"},children:"预览"})]})})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(dM,{className:"w-5 h-5 text-[#00CED1]"}),"底部菜单配置"]}),r.jsx(Kt,{className:"text-gray-400",children:"控制底部导航栏菜单的显示和名称"})]}),r.jsx(Le,{className:"space-y-4",children:Object.entries(u).map(([f,m])=>r.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[r.jsx(Rt,{checked:(m==null?void 0:m.enabled)??!0,onCheckedChange:g=>e(y=>({...y,menuConfig:{...y.menuConfig,[f]:{...m,enabled:g}}}))}),r.jsx("span",{className:"text-gray-300 w-16 capitalize",children:f}),r.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white max-w-[200px]",value:(m==null?void 0:m.label)??"",onChange:g=>e(y=>({...y,menuConfig:{...y.menuConfig,[f]:{...m,label:g.target.value}}}))})]}),r.jsx("span",{className:`text-sm ${m!=null&&m.enabled?"text-green-400":"text-gray-500"}`,children:m!=null&&m.enabled?"显示":"隐藏"})]},f))})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(xj,{className:"w-5 h-5 text-[#00CED1]"}),"页面标题配置"]}),r.jsx(Kt,{className:"text-gray-400",children:"配置各个页面的标题和副标题"})]}),r.jsxs(Le,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"首页标题"}),r.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}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"首页副标题"}),r.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}}))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"目录页标题"}),r.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}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"匹配页标题"}),r.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}}))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"我的页标题"}),r.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}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"关于作者标题"}),r.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 qV(){const[t,e]=b.useState(""),[n,s]=b.useState(""),[a,i]=b.useState(""),[o,c]=b.useState({}),u=async()=>{var y,v,w,N;try{const k=await De("/api/config"),E=(v=(y=k==null?void 0:k.liveQRCodes)==null?void 0:y[0])==null?void 0:v.urls;Array.isArray(E)&&e(E.join(`
`));const C=(N=(w=k==null?void 0:k.paymentMethods)==null?void 0:w.wechat)==null?void 0:N.groupQrCode;C&&s(C),c({paymentMethods:k==null?void 0:k.paymentMethods,liveQRCodes:k==null?void 0:k.liveQRCodes})}catch(k){console.error(k)}};b.useEffect(()=>{u()},[]);const h=(y,v)=>{navigator.clipboard.writeText(y),i(v),setTimeout(()=>i(""),2e3)},f=async()=>{try{const y=t.split(`
`).map(w=>w.trim()).filter(Boolean),v=[...o.liveQRCodes||[]];v[0]?v[0].urls=y:v.push({id:"live-1",name:"微信群活码",urls:y,clickCount:0}),await Et("/api/db/config",{key:"live_qr_codes",value:v,description:"群活码配置"}),oe.success("群活码配置已保存!"),await u()}catch(y){console.error(y),oe.error("保存失败: "+(y instanceof Error?y.message:String(y)))}},m=async()=>{var y;try{await Et("/api/db/config",{key:"payment_methods",value:{...o.paymentMethods||{},wechat:{...((y=o.paymentMethods)==null?void 0:y.wechat)||{},groupQrCode:n}},description:"支付方式配置"}),oe.success("微信群链接已保存!用户支付成功后将自动跳转"),await u()}catch(v){console.error(v),oe.error("保存失败: "+(v instanceof Error?v.message:String(v)))}},g=()=>{n?window.open(n,"_blank"):oe.error("请先配置微信群链接")};return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"mb-8",children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"微信群活码管理"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"配置微信群跳转链接,用户支付后自动跳转加群"})]}),r.jsx("div",{className:"mb-6 bg-[#07C160]/10 border border-[#07C160]/30 rounded-xl p-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(pj,{className:"w-5 h-5 text-[#07C160] flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"text-sm",children:[r.jsx("p",{className:"font-medium mb-2 text-[#07C160]",children:"微信群活码配置指南"}),r.jsxs("div",{className:"text-[#07C160]/80 space-y-2",children:[r.jsx("p",{className:"font-medium",children:"方法一:使用草料活码(推荐)"}),r.jsxs("ol",{className:"list-decimal list-inside space-y-1 pl-2",children:[r.jsx("li",{children:"访问草料二维码创建活码"}),r.jsx("li",{children:"上传微信群二维码图片,生成永久链接"}),r.jsx("li",{children:"复制生成的短链接填入下方配置"}),r.jsx("li",{children:"群满后可直接在草料后台更换新群码,链接不变"})]}),r.jsx("p",{className:"font-medium mt-3",children:"方法二:直接使用微信群链接"}),r.jsxs("ol",{className:"list-decimal list-inside space-y-1 pl-2",children:[r.jsx("li",{children:'微信打开目标群 → 右上角"..." → 群二维码'}),r.jsx("li",{children:"长按二维码 → 识别二维码 → 复制链接"})]}),r.jsx("p",{className:"text-[#07C160]/60 mt-2",children:"注意微信原生群二维码7天后失效建议使用草料活码"})]})]})]})}),r.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-[#07C160] flex items-center gap-2",children:[r.jsx(i1,{className:"w-5 h-5"}),"支付成功跳转链接(核心配置)"]}),r.jsx(Kt,{className:"text-gray-400",children:"用户支付完成后自动跳转到此链接,进入指定微信群"})]}),r.jsxs(Le,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(ee,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(ix,{className:"w-4 h-4"}),"微信群链接 / 活码链接"]}),r.jsxs("div",{className:"flex gap-2",children:[r.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=>s(y.target.value)}),r.jsx(Y,{variant:"outline",size:"icon",className:"border-gray-700 bg-transparent hover:bg-gray-700/50",onClick:()=>h(n,"group"),children:a==="group"?r.jsx(Qf,{className:"w-4 h-4 text-green-500"}):r.jsx(gj,{className:"w-4 h-4 text-gray-400"})})]}),r.jsxs("p",{className:"text-xs text-gray-500 flex items-center gap-1",children:[r.jsx(di,{className:"w-3 h-3"}),"支持格式:草料短链、微信群链接(https://weixin.qq.com/g/...)、企业微信链接等"]})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs(Y,{onClick:m,className:"flex-1 bg-[#07C160] hover:bg-[#06AD51] text-white",children:[r.jsx(qh,{className:"w-4 h-4 mr-2"}),"保存配置"]}),r.jsxs(Y,{onClick:g,variant:"outline",className:"border-[#07C160] text-[#07C160] hover:bg-[#07C160]/10 bg-transparent",children:[r.jsx(di,{className:"w-4 h-4 mr-2"}),"测试跳转"]})]})]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(i1,{className:"w-5 h-5 text-[#38bdac]"}),"多群轮换(高级配置)"]}),r.jsx(Kt,{className:"text-gray-400",children:"配置多个群链接,系统自动轮换分配,避免单群满员"})]}),r.jsxs(Le,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(ee,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(ix,{className:"w-4 h-4"}),"多个群链接(每行一个)"]}),r.jsx(cl,{placeholder:"https://cli.im/group1\\nhttps://cli.im/group2",className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 min-h-[120px] font-mono text-sm",value:t,onChange:y=>e(y.target.value)}),r.jsx("p",{className:"text-xs text-gray-500",children:"每行填写一个群链接,系统将按顺序或随机分配"})]}),r.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[r.jsx("span",{className:"text-sm text-gray-400",children:"已配置群数量"}),r.jsxs("span",{className:"font-bold text-[#38bdac]",children:[t.split(`
`).filter(Boolean).length," 个"]})]}),r.jsxs(Y,{onClick:f,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(qh,{className:"w-4 h-4 mr-2"}),"保存多群配置"]})]})]})]}),r.jsxs("div",{className:"mt-6 bg-[#0f2137] rounded-xl p-4 border border-gray-700/50",children:[r.jsx("h4",{className:"text-white font-medium mb-3",children:"常见问题"}),r.jsxs("div",{className:"space-y-3 text-sm",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-[#38bdac]",children:"Q: 为什么推荐使用草料活码?"}),r.jsx("p",{className:"text-gray-400",children:"A: 草料活码是永久链接群满后可直接在后台更换新群码无需修改网站配置。微信原生群码7天失效。"})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[#38bdac]",children:"Q: 支付后没有跳转怎么办?"}),r.jsx("p",{className:"text-gray-400",children:"A: 1) 检查链接是否正确填写 2) 部分浏览器可能拦截弹窗,用户需手动允许 3) 建议使用https开头的链接"})]})]})]})]})}const Uw={matchTypes:[{id:"partner",label:"创业合伙",matchLabel:"创业伙伴",icon:"⭐",matchFromDB:!0,showJoinAfterMatch:!1,price:1,enabled:!0},{id:"investor",label:"资源对接",matchLabel:"资源对接",icon:"👥",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0},{id:"mentor",label:"导师顾问",matchLabel:"导师顾问",icon:"❤️",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0},{id:"team",label:"团队招募",matchLabel:"加入项目",icon:"🎮",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}],freeMatchLimit:3,matchPrice:1,settings:{enableFreeMatches:!0,enablePaidMatches:!0,maxMatchesPerDay:10}},GV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function JV(){const[t,e]=b.useState(Uw),[n,s]=b.useState(!0),[a,i]=b.useState(!1),[o,c]=b.useState(!1),[u,h]=b.useState(null),[f,m]=b.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),g=async()=>{s(!0);try{const C=await De("/api/db/config/full?key=match_config"),P=(C==null?void 0:C.data)??(C==null?void 0:C.config);P&&e({...Uw,...P})}catch(C){console.error("加载匹配配置失败:",C)}finally{s(!1)}};b.useEffect(()=>{g()},[]);const y=async()=>{i(!0);try{const C=await Et("/api/db/config",{key:"match_config",value:t,description:"匹配功能配置"});C&&C.success!==!1?oe.success("配置保存成功!"):oe.error("保存失败: "+(C&&typeof C=="object"&&"error"in C?C.error:"未知错误"))}catch(C){console.error("保存配置失败:",C),oe.error("保存失败")}finally{i(!1)}},v=C=>{h(C),m({id:C.id,label:C.label,matchLabel:C.matchLabel,icon:C.icon,matchFromDB:C.matchFromDB,showJoinAfterMatch:C.showJoinAfterMatch,price:C.price,enabled:C.enabled}),c(!0)},w=()=>{h(null),m({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),c(!0)},N=()=>{if(!f.id||!f.label){oe.error("请填写类型ID和名称");return}const C=[...t.matchTypes];if(u){const P=C.findIndex(O=>O.id===u.id);P!==-1&&(C[P]={...f})}else{if(C.some(P=>P.id===f.id)){oe.error("类型ID已存在");return}C.push({...f})}e({...t,matchTypes:C}),c(!1)},k=C=>{confirm("确定要删除这个匹配类型吗?")&&e({...t,matchTypes:t.matchTypes.filter(P=>P.id!==C)})},E=C=>{e({...t,matchTypes:t.matchTypes.map(P=>P.id===C?{...P,enabled:!P.enabled}:P)})};return r.jsxs("div",{className:"p-8 w-full space-y-6",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(el,{className:"w-6 h-6 text-[#38bdac]"}),"匹配功能配置"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"管理找伙伴功能的匹配类型和价格"})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs(Y,{variant:"outline",onClick:g,disabled:n,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]}),r.jsxs(Y,{onClick:y,disabled:a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存配置"]})]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(ao,{className:"w-5 h-5 text-yellow-400"}),"基础设置"]}),r.jsx(Kt,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),r.jsxs(Le,{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"每日免费匹配次数"}),r.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.freeMatchLimit,onChange:C=>e({...t,freeMatchLimit:parseInt(C.target.value,10)||0})}),r.jsx("p",{className:"text-xs text-gray-500",children:"用户每天可免费匹配的次数"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"付费匹配价格(元)"}),r.jsx(ce,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:t.matchPrice,onChange:C=>e({...t,matchPrice:parseFloat(C.target.value)||1})}),r.jsx("p",{className:"text-xs text-gray-500",children:"免费次数用完后的单次匹配价格"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"每日最大匹配次数"}),r.jsx(ce,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.settings.maxMatchesPerDay,onChange:C=>e({...t,settings:{...t.settings,maxMatchesPerDay:parseInt(C.target.value,10)||10}})}),r.jsx("p",{className:"text-xs text-gray-500",children:"包含免费和付费的总次数"})]})]}),r.jsxs("div",{className:"flex gap-8 pt-4 border-t border-gray-700/50",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Rt,{checked:t.settings.enableFreeMatches,onCheckedChange:C=>e({...t,settings:{...t.settings,enableFreeMatches:C}})}),r.jsx(ee,{className:"text-gray-300",children:"启用免费匹配"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Rt,{checked:t.settings.enablePaidMatches,onCheckedChange:C=>e({...t,settings:{...t.settings,enablePaidMatches:C}})}),r.jsx(ee,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsxs(it,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(zn,{className:"w-5 h-5 text-[#38bdac]"}),"匹配类型管理"]}),r.jsx(Kt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),r.jsxs(Y,{onClick:w,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Pn,{className:"w-4 h-4 mr-1"}),"添加类型"]})]}),r.jsx(Le,{children:r.jsxs(hs,{children:[r.jsx(fs,{children:r.jsxs(pt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(je,{className:"text-gray-400",children:"图标"}),r.jsx(je,{className:"text-gray-400",children:"类型ID"}),r.jsx(je,{className:"text-gray-400",children:"显示名称"}),r.jsx(je,{className:"text-gray-400",children:"匹配标签"}),r.jsx(je,{className:"text-gray-400",children:"价格"}),r.jsx(je,{className:"text-gray-400",children:"数据库匹配"}),r.jsx(je,{className:"text-gray-400",children:"状态"}),r.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsx(ps,{children:t.matchTypes.map(C=>r.jsxs(pt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsx("span",{className:"text-2xl",children:C.icon})}),r.jsx(ve,{className:"font-mono text-gray-300",children:C.id}),r.jsx(ve,{className:"text-white font-medium",children:C.label}),r.jsx(ve,{className:"text-gray-300",children:C.matchLabel}),r.jsx(ve,{children:r.jsxs(Ge,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",C.price]})}),r.jsx(ve,{children:C.matchFromDB?r.jsx(Ge,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):r.jsx(Ge,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),r.jsx(ve,{children:r.jsx(Rt,{checked:C.enabled,onCheckedChange:()=>E(C.id)})}),r.jsx(ve,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>v(C),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:r.jsx(en,{className:"w-4 h-4"})}),r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>k(C.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:r.jsx(ks,{className:"w-4 h-4"})})]})})]},C.id))})]})})]}),r.jsx(Ht,{open:o,onOpenChange:c,children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[r.jsx(Ut,{children:r.jsxs(Wt,{className:"text-white flex items-center gap-2",children:[u?r.jsx(en,{className:"w-5 h-5 text-[#38bdac]"}):r.jsx(Pn,{className:"w-5 h-5 text-[#38bdac]"}),u?"编辑匹配类型":"添加匹配类型"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"类型ID英文"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:f.id,onChange:C=>m({...f,id:C.target.value}),disabled:!!u})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"图标"}),r.jsx("div",{className:"flex gap-1 flex-wrap",children:GV.map(C=>r.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${f.icon===C?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>m({...f,icon:C}),children:C},C))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"显示名称"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业合伙",value:f.label,onChange:C=>m({...f,label:C.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"匹配标签"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业伙伴",value:f.matchLabel,onChange:C=>m({...f,matchLabel:C.target.value})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"单次匹配价格(元)"}),r.jsx(ce,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:f.price,onChange:C=>m({...f,price:parseFloat(C.target.value)||1})})]}),r.jsxs("div",{className:"flex gap-6 pt-2",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Rt,{checked:f.matchFromDB,onCheckedChange:C=>m({...f,matchFromDB:C})}),r.jsx(ee,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Rt,{checked:f.showJoinAfterMatch,onCheckedChange:C=>m({...f,showJoinAfterMatch:C})}),r.jsx(ee,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Rt,{checked:f.enabled,onCheckedChange:C=>m({...f,enabled:C})}),r.jsx(ee,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),r.jsxs(xn,{children:[r.jsx(Y,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsxs(Y,{onClick:N,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),"保存"]})]})]})})]})}const Ww={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function YV(){const[t,e]=b.useState([]),[n,s]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(""),[f,m]=b.useState(!0),[g,y]=b.useState(null);async function v(){m(!0),y(null);try{const N=new URLSearchParams({page:String(a),pageSize:String(o)});u&&N.set("matchType",u);const k=await De(`/api/db/match-records?${N}`);k!=null&&k.success?(e(k.records||[]),s(k.total??0)):y("加载匹配记录失败")}catch(N){console.error("加载匹配记录失败",N),y("加载失败,请检查网络后重试")}finally{m(!1)}}b.useEffect(()=>{v()},[a,u]);const w=Math.ceil(n/o)||1;return r.jsxs("div",{className:"p-8 w-full",children:[g&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:g}),r.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"匹配记录"}),r.jsxs("p",{className:"text-gray-400 mt-1",children:["找伙伴匹配统计,共 ",n," 条记录"]})]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("select",{value:u,onChange:N=>{h(N.target.value),i(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[r.jsx("option",{value:"",children:"全部类型"}),Object.entries(Ww).map(([N,k])=>r.jsx("option",{value:N,children:k},N))]}),r.jsxs("button",{type:"button",onClick:v,disabled:f,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700/50 transition-colors disabled:opacity-50",children:[r.jsx(Be,{className:`w-4 h-4 ${f?"animate-spin":""}`}),"刷新"]})]})]}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Le,{className:"p-0",children:f?r.jsxs("div",{className:"flex justify-center py-12",children:[r.jsx(Be,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[r.jsxs(hs,{children:[r.jsx(fs,{children:r.jsxs(pt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(je,{className:"text-gray-400",children:"发起人"}),r.jsx(je,{className:"text-gray-400",children:"匹配到"}),r.jsx(je,{className:"text-gray-400",children:"类型"}),r.jsx(je,{className:"text-gray-400",children:"联系方式"}),r.jsx(je,{className:"text-gray-400",children:"匹配时间"})]})}),r.jsxs(ps,{children:[t.map(N=>r.jsxs(pt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 overflow-hidden",children:[N.userAvatar?r.jsx("img",{src:io(N.userAvatar),alt:"",className:"w-full h-full object-cover",onError:k=>{k.currentTarget.style.display="none";const E=k.currentTarget.nextElementSibling;E&&E.classList.remove("hidden")}}):null,r.jsx("span",{className:N.userAvatar?"hidden":"",children:(N.userNickname||N.userId||"?").charAt(0)})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white",children:N.userNickname||N.userId}),r.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[N.userId.slice(0,16),"..."]})]})]})}),r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 overflow-hidden",children:[N.matchedUserAvatar?r.jsx("img",{src:io(N.matchedUserAvatar),alt:"",className:"w-full h-full object-cover",onError:k=>{k.currentTarget.style.display="none";const E=k.currentTarget.nextElementSibling;E&&E.classList.remove("hidden")}}):null,r.jsx("span",{className:N.matchedUserAvatar?"hidden":"",children:(N.matchedNickname||N.matchedUserId||"?").charAt(0)})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white",children:N.matchedNickname||N.matchedUserId}),r.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[N.matchedUserId.slice(0,16),"..."]})]})]})}),r.jsx(ve,{children:r.jsx(Ge,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Ww[N.matchType]||N.matchType})}),r.jsxs(ve,{className:"text-gray-400 text-sm",children:[N.phone&&r.jsxs("div",{children:["📱 ",N.phone]}),N.wechatId&&r.jsxs("div",{children:["💬 ",N.wechatId]}),!N.phone&&!N.wechatId&&"-"]}),r.jsx(ve,{className:"text-gray-400",children:N.createdAt?new Date(N.createdAt).toLocaleString():"-"})]},N.id)),t.length===0&&r.jsx(pt,{children:r.jsx(ve,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),r.jsx(Gs,{page:a,totalPages:w,total:n,pageSize:o,onPageChange:i,onPageSizeChange:N=>{c(N),i(1)}})]})})})]})}function QV(){const[t,e]=b.useState([]),[n,s]=b.useState(!0);async function a(){s(!0);try{const i=await De("/api/db/vip-members?limit=100");if(i!=null&&i.success&&i.data){const o=[...i.data].map((c,u)=>({...c,vipSort:typeof c.vipSort=="number"?c.vipSort:u+1}));o.sort((c,u)=>(c.vipSort??999999)-(u.vipSort??999999)),e(o)}}catch(i){console.error("Load VIP members error:",i),oe.error("加载 VIP 成员失败")}finally{s(!1)}}return b.useEffect(()=>{a()},[]),r.jsxs("div",{className:"p-8 w-full",children:[r.jsx("div",{className:"flex justify-between items-center mb-8",children:r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(kd,{className:"w-5 h-5 text-amber-400"}),"用户管理 / 超级个体列表"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"这里展示所有有效超级个体用户,仅用于查看其基本信息与排序值。"})]})}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Le,{className:"p-0",children:n?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(hs,{children:[r.jsx(fs,{children:r.jsxs(pt,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(je,{className:"text-gray-400 w-20",children:"序号"}),r.jsx(je,{className:"text-gray-400",children:"成员"}),r.jsx(je,{className:"text-gray-400 w-40",children:"超级个体"}),r.jsx(je,{className:"text-gray-400 w-28",children:"排序值"})]})}),r.jsxs(ps,{children:[t.map((i,o)=>{var c;return r.jsxs(pt,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:o+1}),r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[i.avatar?r.jsx("img",{src:io(i.avatar),className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",children:((c=i.name)==null?void 0:c[0])||"创"}),r.jsx("div",{className:"min-w-0",children:r.jsx("div",{className:"text-white text-sm truncate",children:i.name})})]})}),r.jsx(ve,{className:"text-gray-300",children:i.vipRole||r.jsx("span",{className:"text-gray-500",children:"(未设置超级个体)"})}),r.jsx(ve,{className:"text-gray-300",children:i.vipSort??o+1})]},i.id)}),t.length===0&&r.jsx(pt,{children:r.jsx(ve,{colSpan:5,className:"text-center py-12 text-gray-500",children:"当前没有有效的超级个体用户。"})})]})]})})})]})}function i4(t){const e=Aa(),[n,s]=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),[v,w]=b.useState(!1),N=b.useRef(null),k=async A=>{var G;const X=(G=A.target.files)==null?void 0:G[0];if(X){w(!0);try{const z=new FormData;z.append("file",X),z.append("folder","mentors");const ne=nu(),ue={};ne&&(ue.Authorization=`Bearer ${ne}`);const $=await(await fetch(xc("/api/upload"),{method:"POST",body:z,credentials:"include",headers:ue})).json();$!=null&&$.success&&($!=null&&$.url)?m(D=>({...D,avatar:$.url})):oe.error("上传失败: "+(($==null?void 0:$.error)||"未知错误"))}catch(z){console.error(z),oe.error("上传失败")}finally{w(!1),N.current&&(N.current.value="")}}};async function E(){i(!0);try{const A=await De("/api/db/mentors");A!=null&&A.success&&A.data&&s(A.data)}catch(A){console.error("Load mentors error:",A)}finally{i(!1)}}b.useEffect(()=>{E()},[]);const C=()=>{m({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:n.length>0?Math.max(...n.map(A=>A.sort))+1:0,enabled:!0})},P=()=>{h(null),C(),c(!0)},O=A=>{h(A),m({name:A.name,avatar:A.avatar||"",intro:A.intro||"",tags:A.tags||"",priceSingle:A.priceSingle!=null?String(A.priceSingle):"",priceHalfYear:A.priceHalfYear!=null?String(A.priceHalfYear):"",priceYear:A.priceYear!=null?String(A.priceYear):"",quote:A.quote||"",whyFind:A.whyFind||"",offering:A.offering||"",judgmentStyle:A.judgmentStyle||"",sort:A.sort,enabled:A.enabled??!0}),c(!0)},U=async()=>{if(!f.name.trim()){oe.error("导师姓名不能为空");return}y(!0);try{const A=G=>G===""?void 0:parseFloat(G),X={name:f.name.trim(),avatar:f.avatar.trim()||void 0,intro:f.intro.trim()||void 0,tags:f.tags.trim()||void 0,priceSingle:A(f.priceSingle),priceHalfYear:A(f.priceHalfYear),priceYear:A(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 G=await Jt("/api/db/mentors",{id:u.id,...X});G!=null&&G.success?(c(!1),E()):oe.error("更新失败: "+(G==null?void 0:G.error))}else{const G=await Et("/api/db/mentors",X);G!=null&&G.success?(c(!1),E()):oe.error("新增失败: "+(G==null?void 0:G.error))}}catch(A){console.error("Save error:",A),oe.error("保存失败")}finally{y(!1)}},_=async A=>{if(confirm("确定删除该导师?"))try{const X=await ai(`/api/db/mentors?id=${A}`);X!=null&&X.success?E():oe.error("删除失败: "+(X==null?void 0:X.error))}catch(X){console.error("Delete error:",X),oe.error("删除失败")}},V=A=>A!=null?`¥${A}`:"-";return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(zn,{className:"w-5 h-5 text-[#38bdac]"}),"导师管理"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师列表,支持每个导师独立配置单次/半年/年度价格"})]}),r.jsxs(Y,{onClick:P,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Pn,{className:"w-4 h-4 mr-2"}),"新增导师"]})]}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Le,{className:"p-0",children:a?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(hs,{children:[r.jsx(fs,{children:r.jsxs(pt,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(je,{className:"text-gray-400",children:"ID"}),r.jsx(je,{className:"text-gray-400",children:"姓名"}),r.jsx(je,{className:"text-gray-400",children:"简介"}),r.jsx(je,{className:"text-gray-400",children:"单次"}),r.jsx(je,{className:"text-gray-400",children:"半年"}),r.jsx(je,{className:"text-gray-400",children:"年度"}),r.jsx(je,{className:"text-gray-400",children:"排序"}),r.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsxs(ps,{children:[n.map(A=>r.jsxs(pt,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:A.id}),r.jsx(ve,{children:r.jsxs("button",{type:"button",onClick:()=>e(`/users?search=${encodeURIComponent(A.name)}`),className:"text-[#38bdac] hover:text-[#2da396] hover:underline flex items-center gap-1",title:"在用户管理中查看",children:[A.name,r.jsx(di,{className:"w-3 h-3"})]})}),r.jsx(ve,{className:"text-gray-400 max-w-[200px] truncate",children:A.intro||"-"}),r.jsx(ve,{className:"text-gray-400",children:V(A.priceSingle)}),r.jsx(ve,{className:"text-gray-400",children:V(A.priceHalfYear)}),r.jsx(ve,{className:"text-gray-400",children:V(A.priceYear)}),r.jsx(ve,{className:"text-gray-400",children:A.sort}),r.jsxs(ve,{className:"text-right",children:[r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>O(A),className:"text-gray-400 hover:text-[#38bdac]",children:r.jsx(en,{className:"w-4 h-4"})}),r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>_(A.id),className:"text-gray-400 hover:text-red-400",children:r.jsx(ks,{className:"w-4 h-4"})})]})]},A.id)),n.length===0&&r.jsx(pt,{children:r.jsx(ve,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无导师,点击「新增导师」添加"})})]})]})})}),r.jsx(Ht,{open:o,onOpenChange:c,children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg max-h-[90vh] overflow-y-auto",children:[r.jsx(Ut,{children:r.jsx(Wt,{className:"text-white",children:u?"编辑导师":"新增导师"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"姓名 *"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:卡若",value:f.name,onChange:A=>m(X=>({...X,name:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"排序"}),r.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:f.sort,onChange:A=>m(X=>({...X,sort:parseInt(A.target.value,10)||0}))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"头像"}),r.jsxs("div",{className:"flex gap-3 items-center",children:[r.jsx(ce,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:f.avatar,onChange:A=>m(X=>({...X,avatar:A.target.value})),placeholder:"点击上传或粘贴图片地址"}),r.jsx("input",{ref:N,type:"file",accept:"image/*",className:"hidden",onChange:k}),r.jsxs(Y,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:v,onClick:()=>{var A;return(A=N.current)==null?void 0:A.click()},children:[r.jsx(qh,{className:"w-4 h-4 mr-2"}),v?"上传中...":"上传"]})]}),f.avatar&&r.jsx("div",{className:"mt-2",children:r.jsx("img",{src:io(f.avatar.startsWith("http")?f.avatar:xc(f.avatar)),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"简介"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:结构判断型咨询 · Decision > Execution",value:f.intro,onChange:A=>m(X=>({...X,intro:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"技能标签(逗号分隔)"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:项目结构判断、风险止损、人×项目匹配",value:f.tags,onChange:A=>m(X=>({...X,tags:A.target.value}))})]}),r.jsxs("div",{className:"border-t border-gray-700 pt-4",children:[r.jsx(ee,{className:"text-gray-300 block mb-2",children:"价格配置(每个导师独立)"}),r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-500 text-xs",children:"单次咨询 ¥"}),r.jsx(ce,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"980",value:f.priceSingle,onChange:A=>m(X=>({...X,priceSingle:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-500 text-xs",children:"半年咨询 ¥"}),r.jsx(ce,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"19800",value:f.priceHalfYear,onChange:A=>m(X=>({...X,priceHalfYear:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-500 text-xs",children:"年度咨询 ¥"}),r.jsx(ce,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"29800",value:f.priceYear,onChange:A=>m(X=>({...X,priceYear:A.target.value}))})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"引言"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:大多数人失败,不是因为不努力...",value:f.quote,onChange:A=>m(X=>({...X,quote:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"为什么找(文本)"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:f.whyFind,onChange:A=>m(X=>({...X,whyFind:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"提供什么(文本)"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:f.offering,onChange:A=>m(X=>({...X,offering:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"判断风格(逗号分隔)"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:冷静、克制、偏风险视角",value:f.judgmentStyle,onChange:A=>m(X=>({...X,judgmentStyle:A.target.value}))})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"checkbox",id:"enabled",checked:f.enabled,onChange:A=>m(X=>({...X,enabled:A.target.checked})),className:"rounded border-gray-600 bg-[#0a1628]"}),r.jsx(ee,{htmlFor:"enabled",className:"text-gray-300 cursor-pointer",children:"上架(小程序可见)"})]})]}),r.jsxs(xn,{children:[r.jsxs(Y,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300",children:[r.jsx(us,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(Y,{onClick:U,disabled:g,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(En,{className:"w-4 h-4 mr-2"}),g?"保存中...":"保存"]})]})]})})]})}function XV(){const[t,e]=b.useState([]),[n,s]=b.useState(!0),[a,i]=b.useState("");async function o(){s(!0);try{const h=a?`/api/db/mentor-consultations?status=${a}`:"/api/db/mentor-consultations",f=await De(h);f!=null&&f.success&&f.data&&e(f.data)}catch(h){console.error("Load consultations error:",h)}finally{s(!1)}}b.useEffect(()=>{o()},[a]);const c={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},u={single:"单次",half_year:"半年",year:"年度"};return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(tx,{className:"w-5 h-5 text-[#38bdac]"}),"导师预约列表"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师咨询预约记录"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("select",{value:a,onChange:h=>i(h.target.value),className:"bg-[#0f2137] border border-gray-700 rounded-lg px-3 py-2 text-gray-300 text-sm",children:[r.jsx("option",{value:"",children:"全部状态"}),Object.entries(c).map(([h,f])=>r.jsx("option",{value:h,children:f},h))]}),r.jsxs(Y,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]})]})]}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Le,{className:"p-0",children:n?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(hs,{children:[r.jsx(fs,{children:r.jsxs(pt,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(je,{className:"text-gray-400",children:"ID"}),r.jsx(je,{className:"text-gray-400",children:"用户ID"}),r.jsx(je,{className:"text-gray-400",children:"导师ID"}),r.jsx(je,{className:"text-gray-400",children:"类型"}),r.jsx(je,{className:"text-gray-400",children:"金额"}),r.jsx(je,{className:"text-gray-400",children:"状态"}),r.jsx(je,{className:"text-gray-400",children:"创建时间"})]})}),r.jsxs(ps,{children:[t.map(h=>r.jsxs(pt,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:h.id}),r.jsx(ve,{className:"text-gray-400",children:h.userId}),r.jsx(ve,{className:"text-gray-400",children:h.mentorId}),r.jsx(ve,{className:"text-gray-400",children:u[h.consultationType]||h.consultationType}),r.jsxs(ve,{className:"text-white",children:["¥",h.amount]}),r.jsx(ve,{className:"text-gray-400",children:c[h.status]||h.status}),r.jsx(ve,{className:"text-gray-500 text-sm",children:h.createdAt})]},h.id)),t.length===0&&r.jsx(pt,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}const jd={poolSource:["vip"],requirePhone:!0,requireNickname:!0,requireAvatar:!1,requireBusiness:!1},Kw={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:jd},ZV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function e9(){const t=Aa(),[e,n]=b.useState(Kw),[s,a]=b.useState(!0),[i,o]=b.useState(!1),[c,u]=b.useState(!1),[h,f]=b.useState(null),[m,g]=b.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),[y,v]=b.useState(null),[w,N]=b.useState(!1),k=async()=>{N(!0);try{const A=await De("/api/db/match-pool-counts");A!=null&&A.success&&A.data&&v(A.data)}catch(A){console.error("加载池子人数失败:",A)}finally{N(!1)}},E=async()=>{a(!0);try{const A=await De("/api/db/config/full?key=match_config"),X=(A==null?void 0:A.data)??(A==null?void 0:A.config);if(X){let G=X.poolSettings??jd;G.poolSource&&!Array.isArray(G.poolSource)&&(G={...G,poolSource:[G.poolSource]}),n({...Kw,...X,poolSettings:G})}}catch(A){console.error("加载匹配配置失败:",A)}finally{a(!1)}};b.useEffect(()=>{E(),k()},[]);const C=async()=>{o(!0);try{const A=await Et("/api/db/config",{key:"match_config",value:e,description:"匹配功能配置"});oe.error((A==null?void 0:A.success)!==!1?"配置保存成功!":"保存失败: "+((A==null?void 0:A.error)||"未知错误"))}catch(A){console.error(A),oe.error("保存失败")}finally{o(!1)}},P=A=>{f(A),g({...A}),u(!0)},O=()=>{f(null),g({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),u(!0)},U=()=>{if(!m.id||!m.label){oe.error("请填写类型ID和名称");return}const A=[...e.matchTypes];if(h){const X=A.findIndex(G=>G.id===h.id);X!==-1&&(A[X]={...m})}else{if(A.some(X=>X.id===m.id)){oe.error("类型ID已存在");return}A.push({...m})}n({...e,matchTypes:A}),u(!1)},_=A=>{confirm("确定要删除这个匹配类型吗?")&&n({...e,matchTypes:e.matchTypes.filter(X=>X.id!==A)})},V=A=>{n({...e,matchTypes:e.matchTypes.map(X=>X.id===A?{...X,enabled:!X.enabled}:X)})};return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex justify-end gap-3",children:[r.jsxs(Y,{variant:"outline",onClick:E,disabled:s,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${s?"animate-spin":""}`})," 刷新"]}),r.jsxs(Y,{onClick:C,disabled:i,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(En,{className:"w-4 h-4 mr-2"})," ",i?"保存中...":"保存配置"]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(yj,{className:"w-5 h-5 text-blue-400"})," 匹配池选择"]}),r.jsx(Kt,{className:"text-gray-400",children:"选择匹配的用户池和完善程度要求,只有满足条件的用户才可被匹配到"})]}),r.jsxs(Le,{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-3",children:[r.jsx(ee,{className:"text-gray-300",children:"匹配来源池"}),r.jsx("p",{className:"text-gray-500 text-xs",children:"可同时勾选多个池子(取并集匹配)"}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[{value:"vip",label:"超级个体VIP会员",desc:"付费 ¥1980 的VIP会员",icon:"👑",countKey:"vip"},{value:"complete",label:"完善资料用户",desc:"符合下方完善度要求的用户",icon:"✅",countKey:"complete"},{value:"all",label:"全部用户",desc:"所有已注册用户",icon:"👥",countKey:"all"}].map(A=>{const X=e.poolSettings??jd,z=(Array.isArray(X.poolSource)?X.poolSource:[X.poolSource]).includes(A.value),ne=y==null?void 0:y[A.countKey],ue=()=>{const K=Array.isArray(X.poolSource)?[...X.poolSource]:[X.poolSource],$=z?K.filter(D=>D!==A.value):[...K,A.value];$.length===0&&$.push(A.value),n({...e,poolSettings:{...X,poolSource:$}})};return r.jsxs("button",{type:"button",onClick:ue,className:`p-4 rounded-lg border text-left transition-all ${z?"border-[#38bdac] bg-[#38bdac]/10":"border-gray-700 bg-[#0a1628] hover:border-gray-600"}`,children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center text-xs ${z?"border-[#38bdac] bg-[#38bdac] text-white":"border-gray-600"}`,children:z&&"✓"}),r.jsx("span",{className:"text-xl",children:A.icon}),r.jsx("span",{className:`text-sm font-medium ${z?"text-[#38bdac]":"text-gray-300"}`,children:A.label})]}),r.jsxs("span",{className:"text-lg font-bold text-white",children:[w?"...":ne??"-",r.jsx("span",{className:"text-xs text-gray-500 font-normal ml-1",children:"人"})]})]}),r.jsx("p",{className:"text-gray-500 text-xs mt-2",children:A.desc}),r.jsx("span",{role:"link",tabIndex:0,onClick:K=>{K.stopPropagation(),t(`/users?pool=${A.value}`)},onKeyDown:K=>{K.key==="Enter"&&(K.stopPropagation(),t(`/users?pool=${A.value}`))},className:"text-[#38bdac] text-xs mt-2 inline-block hover:underline cursor-pointer",children:"查看用户列表 →"})]},A.value)})})]}),r.jsxs("div",{className:"space-y-3 pt-4 border-t border-gray-700/50",children:[r.jsx(ee,{className:"text-gray-300",children:"用户资料完善要求(被匹配用户必须满足以下条件)"}),r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{key:"requirePhone",label:"有手机号",icon:"📱"},{key:"requireNickname",label:"有昵称",icon:"👤"},{key:"requireAvatar",label:"有头像",icon:"🖼️"},{key:"requireBusiness",label:"有业务需求",icon:"💼"}].map(A=>{const G=(e.poolSettings??jd)[A.key];return r.jsxs("div",{className:"flex items-center gap-3 bg-[#0a1628] rounded-lg p-3",children:[r.jsx(Rt,{checked:G,onCheckedChange:z=>n({...e,poolSettings:{...e.poolSettings??jd,[A.key]:z}})}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{children:A.icon}),r.jsx(ee,{className:"text-gray-300 text-sm",children:A.label})]})]},A.key)})})]})]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsxs(it,{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(ao,{className:"w-5 h-5 text-yellow-400"})," 基础设置"]}),r.jsx(Kt,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),r.jsxs(Le,{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"每日免费匹配次数"}),r.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.freeMatchLimit,onChange:A=>n({...e,freeMatchLimit:parseInt(A.target.value,10)||0})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"付费匹配价格(元)"}),r.jsx(ce,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:e.matchPrice,onChange:A=>n({...e,matchPrice:parseFloat(A.target.value)||1})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"每日最大匹配次数"}),r.jsx(ce,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.settings.maxMatchesPerDay,onChange:A=>n({...e,settings:{...e.settings,maxMatchesPerDay:parseInt(A.target.value,10)||10}})})]})]}),r.jsxs("div",{className:"flex gap-8 pt-4 border-t border-gray-700/50",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Rt,{checked:e.settings.enableFreeMatches,onCheckedChange:A=>n({...e,settings:{...e.settings,enableFreeMatches:A}})}),r.jsx(ee,{className:"text-gray-300",children:"启用免费匹配"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Rt,{checked:e.settings.enablePaidMatches,onCheckedChange:A=>n({...e,settings:{...e.settings,enablePaidMatches:A}})}),r.jsx(ee,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),r.jsxs(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsxs(it,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs(ot,{className:"text-white flex items-center gap-2",children:[r.jsx(zn,{className:"w-5 h-5 text-[#38bdac]"})," 匹配类型管理"]}),r.jsx(Kt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),r.jsxs(Y,{onClick:O,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Pn,{className:"w-4 h-4 mr-1"})," 添加类型"]})]}),r.jsx(Le,{children:r.jsxs(hs,{children:[r.jsx(fs,{children:r.jsxs(pt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(je,{className:"text-gray-400",children:"图标"}),r.jsx(je,{className:"text-gray-400",children:"类型ID"}),r.jsx(je,{className:"text-gray-400",children:"显示名称"}),r.jsx(je,{className:"text-gray-400",children:"匹配标签"}),r.jsx(je,{className:"text-gray-400",children:"价格"}),r.jsx(je,{className:"text-gray-400",children:"数据库匹配"}),r.jsx(je,{className:"text-gray-400",children:"状态"}),r.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsx(ps,{children:e.matchTypes.map(A=>r.jsxs(pt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsx("span",{className:"text-2xl",children:A.icon})}),r.jsx(ve,{className:"font-mono text-gray-300",children:A.id}),r.jsx(ve,{className:"text-white font-medium",children:A.label}),r.jsx(ve,{className:"text-gray-300",children:A.matchLabel}),r.jsx(ve,{children:r.jsxs(Ge,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",A.price]})}),r.jsx(ve,{children:A.matchFromDB?r.jsx(Ge,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):r.jsx(Ge,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),r.jsx(ve,{children:r.jsx(Rt,{checked:A.enabled,onCheckedChange:()=>V(A.id)})}),r.jsx(ve,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>P(A),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:r.jsx(en,{className:"w-4 h-4"})}),r.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>_(A.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:r.jsx(ks,{className:"w-4 h-4"})})]})})]},A.id))})]})})]}),r.jsx(Ht,{open:c,onOpenChange:u,children:r.jsxs(_t,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[r.jsx(Ut,{children:r.jsxs(Wt,{className:"text-white flex items-center gap-2",children:[h?r.jsx(en,{className:"w-5 h-5 text-[#38bdac]"}):r.jsx(Pn,{className:"w-5 h-5 text-[#38bdac]"}),h?"编辑匹配类型":"添加匹配类型"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"类型ID英文"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:m.id,onChange:A=>g({...m,id:A.target.value}),disabled:!!h})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"图标"}),r.jsx("div",{className:"flex gap-1 flex-wrap",children:ZV.map(A=>r.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${m.icon===A?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>g({...m,icon:A}),children:A},A))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"显示名称"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.label,onChange:A=>g({...m,label:A.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"匹配标签"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.matchLabel,onChange:A=>g({...m,matchLabel:A.target.value})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(ee,{className:"text-gray-300",children:"单次匹配价格(元)"}),r.jsx(ce,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:m.price,onChange:A=>g({...m,price:parseFloat(A.target.value)||1})})]}),r.jsxs("div",{className:"flex gap-6 pt-2",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Rt,{checked:m.matchFromDB,onCheckedChange:A=>g({...m,matchFromDB:A})}),r.jsx(ee,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Rt,{checked:m.showJoinAfterMatch,onCheckedChange:A=>g({...m,showJoinAfterMatch:A})}),r.jsx(ee,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Rt,{checked:m.enabled,onCheckedChange:A=>g({...m,enabled:A})}),r.jsx(ee,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),r.jsxs(xn,{children:[r.jsx(Y,{variant:"outline",onClick:()=>u(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsxs(Y,{onClick:U,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(En,{className:"w-4 h-4 mr-2"})," 保存"]})]})]})})]})}const qw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function t9(){const[t,e]=b.useState([]),[n,s]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(""),[f,m]=b.useState(!0),[g,y]=b.useState(null),[v,w]=b.useState(null);async function N(){m(!0),y(null);try{const C=new URLSearchParams({page:String(a),pageSize:String(o)});u&&C.set("matchType",u);const P=await De(`/api/db/match-records?${C}`);P!=null&&P.success?(e(P.records||[]),s(P.total??0)):y("加载匹配记录失败")}catch{y("加载失败,请检查网络后重试")}finally{m(!1)}}b.useEffect(()=>{N()},[a,u]);const k=Math.ceil(n/o)||1,E=({userId:C,nickname:P,avatar:O})=>r.jsxs("div",{className:"flex items-center gap-3 cursor-pointer group",onClick:()=>w(C),children:[r.jsxs("div",{className:"w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 overflow-hidden",children:[O?r.jsx("img",{src:io(O),alt:"",className:"w-full h-full object-cover",onError:U=>{U.currentTarget.style.display="none"}}):null,r.jsx("span",{className:O?"hidden":"",children:(P||C||"?").charAt(0)})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white group-hover:text-[#38bdac] transition-colors",children:P||C}),r.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[C==null?void 0:C.slice(0,16),(C==null?void 0:C.length)>16?"...":""]})]})]});return r.jsxs("div",{children:[g&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:g}),r.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-center mb-4",children:[r.jsxs("p",{className:"text-gray-400",children:["共 ",n," 条匹配记录 · 点击用户名查看详情"]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("select",{value:u,onChange:C=>{h(C.target.value),i(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[r.jsx("option",{value:"",children:"全部类型"}),Object.entries(qw).map(([C,P])=>r.jsx("option",{value:C,children:P},C))]}),r.jsxs("button",{type:"button",onClick:N,disabled:f,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700/50 transition-colors disabled:opacity-50",children:[r.jsx(Be,{className:`w-4 h-4 ${f?"animate-spin":""}`})," 刷新"]})]})]}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Le,{className:"p-0",children:f?r.jsxs("div",{className:"flex justify-center py-12",children:[r.jsx(Be,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[r.jsxs(hs,{children:[r.jsx(fs,{children:r.jsxs(pt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(je,{className:"text-gray-400",children:"发起人"}),r.jsx(je,{className:"text-gray-400",children:"匹配到"}),r.jsx(je,{className:"text-gray-400",children:"类型"}),r.jsx(je,{className:"text-gray-400",children:"联系方式"}),r.jsx(je,{className:"text-gray-400",children:"匹配时间"})]})}),r.jsxs(ps,{children:[t.map(C=>r.jsxs(pt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsx(E,{userId:C.userId,nickname:C.userNickname,avatar:C.userAvatar})}),r.jsx(ve,{children:C.matchedUserId?r.jsx(E,{userId:C.matchedUserId,nickname:C.matchedNickname,avatar:C.matchedUserAvatar}):r.jsx("span",{className:"text-gray-500",children:"—"})}),r.jsx(ve,{children:r.jsx(Ge,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:qw[C.matchType]||C.matchType})}),r.jsxs(ve,{className:"text-sm",children:[C.phone&&r.jsxs("div",{className:"text-green-400",children:["📱 ",C.phone]}),C.wechatId&&r.jsxs("div",{className:"text-blue-400",children:["💬 ",C.wechatId]}),!C.phone&&!C.wechatId&&r.jsx("span",{className:"text-gray-600",children:"-"})]}),r.jsx(ve,{className:"text-gray-400",children:C.createdAt?new Date(C.createdAt).toLocaleString():"-"})]},C.id)),t.length===0&&r.jsx(pt,{children:r.jsx(ve,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),r.jsx(Gs,{page:a,totalPages:k,total:n,pageSize:o,onPageChange:i,onPageSizeChange:C=>{c(C),i(1)}})]})})}),r.jsx(T0,{open:!!v,onClose:()=>w(null),userId:v,onUserUpdated:N})]})}function n9(){const[t,e]=b.useState("records");return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{type:"button",onClick:()=>e("records"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="records"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"匹配记录"}),r.jsx("button",{type:"button",onClick:()=>e("pool"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="pool"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"匹配池设置"})]}),t==="records"&&r.jsx(t9,{}),t==="pool"&&r.jsx(e9,{})]})}const Gw={investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function s9(){const[t,e]=b.useState([]),[n,s]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(!0),[f,m]=b.useState("investor"),[g,y]=b.useState(null);async function v(){h(!0);try{const E=new URLSearchParams({page:String(a),pageSize:String(o),matchType:f}),C=await De(`/api/db/match-records?${E}`);C!=null&&C.success&&(e(C.records||[]),s(C.total??0))}catch(E){console.error(E)}finally{h(!1)}}b.useEffect(()=>{v()},[a,f]);const w=async E=>{if(!E.phone&&!E.wechatId){oe.info("该记录无联系方式,无法推送到存客宝");return}y(E.id);try{const C=await Et("/api/ckb/join",{type:E.matchType||"investor",phone:E.phone||"",wechat:E.wechatId||"",userId:E.userId,name:E.userNickname||""});oe.error((C==null?void 0:C.message)||(C!=null&&C.success?"推送成功":"推送失败"))}catch(C){oe.error("推送失败: "+(C instanceof Error?C.message:"网络错误"))}finally{y(null)}},N=Math.ceil(n/o)||1,k=E=>!!(E.phone||E.wechatId);return r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between items-center mb-4",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400",children:"点击获客:有人填写手机号/微信号的直接显示,可一键推送到存客宝"}),r.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["共 ",n," 条记录 — 有联系方式的可触发存客宝添加好友"]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("select",{value:f,onChange: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(Gw).map(([E,C])=>r.jsx("option",{value:E,children:C},E))}),r.jsxs(Y,{onClick:v,disabled:u,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${u?"animate-spin":""}`})," 刷新"]})]})]}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Le,{className:"p-0",children:u?r.jsxs("div",{className:"flex justify-center py-12",children:[r.jsx(Be,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[r.jsxs(hs,{children:[r.jsx(fs,{children:r.jsxs(pt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(je,{className:"text-gray-400",children:"发起人"}),r.jsx(je,{className:"text-gray-400",children:"匹配到"}),r.jsx(je,{className:"text-gray-400",children:"类型"}),r.jsx(je,{className:"text-gray-400",children:"联系方式"}),r.jsx(je,{className:"text-gray-400",children:"时间"}),r.jsx(je,{className:"text-gray-400 text-right",children:"操作"})]})}),r.jsxs(ps,{children:[t.map(E=>{var C,P;return r.jsxs(pt,{className:`border-gray-700/50 ${k(E)?"hover:bg-[#0a1628]":"opacity-60"}`,children:[r.jsx(ve,{className:"text-white",children:E.userNickname||((C=E.userId)==null?void 0:C.slice(0,12))}),r.jsx(ve,{className:"text-white",children:E.matchedNickname||((P=E.matchedUserId)==null?void 0:P.slice(0,12))}),r.jsx(ve,{children:r.jsx(Ge,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Gw[E.matchType]||E.matchType})}),r.jsxs(ve,{className:"text-sm",children:[E.phone&&r.jsxs("div",{className:"text-green-400",children:["📱 ",E.phone]}),E.wechatId&&r.jsxs("div",{className:"text-blue-400",children:["💬 ",E.wechatId]}),!E.phone&&!E.wechatId&&r.jsx("span",{className:"text-gray-600",children:"无联系方式"})]}),r.jsx(ve,{className:"text-gray-400 text-sm",children:E.createdAt?new Date(E.createdAt).toLocaleString():"-"}),r.jsx(ve,{className:"text-right",children:k(E)?r.jsxs(Y,{size:"sm",onClick:()=>w(E),disabled:g===E.id,className:"bg-[#38bdac] hover:bg-[#2da396] text-white text-xs h-7 px-3",children:[r.jsx(zM,{className:"w-3 h-3 mr-1"}),g===E.id?"推送中...":"推送CKB"]}):r.jsx("span",{className:"text-gray-600 text-xs",children:"—"})})]},E.id)}),t.length===0&&r.jsx(pt,{children:r.jsx(ve,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无记录"})})]})]}),r.jsx(Gs,{page:a,totalPages:N,total:n,pageSize:o,onPageChange:i,onPageSizeChange:E=>{c(E),i(1)}})]})})})]})}const Jw={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},r9={single:"单次",half_year:"半年",year:"年度"};function a9(){const[t,e]=b.useState([]),[n,s]=b.useState(!0),[a,i]=b.useState("");async function o(){s(!0);try{const c=a?`/api/db/mentor-consultations?status=${a}`:"/api/db/mentor-consultations",u=await De(c);u!=null&&u.success&&u.data&&e(u.data)}catch(c){console.error(c)}finally{s(!1)}}return b.useEffect(()=>{o()},[a]),r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between items-center mb-4",children:[r.jsx("p",{className:"text-gray-400",children:"导师咨询预约记录"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("select",{value:a,onChange:c=>i(c.target.value),className:"bg-[#0f2137] border border-gray-700 rounded-lg px-3 py-2 text-gray-300 text-sm",children:[r.jsx("option",{value:"",children:"全部状态"}),Object.entries(Jw).map(([c,u])=>r.jsx("option",{value:c,children:u},c))]}),r.jsxs(Y,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Be,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`})," 刷新"]})]})]}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Le,{className:"p-0",children:n?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(hs,{children:[r.jsx(fs,{children:r.jsxs(pt,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(je,{className:"text-gray-400",children:"ID"}),r.jsx(je,{className:"text-gray-400",children:"用户ID"}),r.jsx(je,{className:"text-gray-400",children:"导师ID"}),r.jsx(je,{className:"text-gray-400",children:"类型"}),r.jsx(je,{className:"text-gray-400",children:"金额"}),r.jsx(je,{className:"text-gray-400",children:"状态"}),r.jsx(je,{className:"text-gray-400",children:"创建时间"})]})}),r.jsxs(ps,{children:[t.map(c=>r.jsxs(pt,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:c.id}),r.jsx(ve,{className:"text-gray-400",children:c.userId}),r.jsx(ve,{className:"text-gray-400",children:c.mentorId}),r.jsx(ve,{className:"text-gray-400",children:r9[c.consultationType]||c.consultationType}),r.jsxs(ve,{className:"text-white",children:["¥",c.amount]}),r.jsx(ve,{className:"text-gray-400",children:Jw[c.status]||c.status}),r.jsx(ve,{className:"text-gray-500 text-sm",children:c.createdAt?new Date(c.createdAt).toLocaleString():"-"})]},c.id)),t.length===0&&r.jsx(pt,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}function i9(){const[t,e]=b.useState("booking");return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{type:"button",onClick:()=>e("booking"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="booking"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"预约记录"}),r.jsx("button",{type:"button",onClick:()=>e("manage"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="manage"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"导师管理"})]}),t==="booking"&&r.jsx(a9,{}),t==="manage"&&r.jsx("div",{className:"-mx-8",children:r.jsx(i4,{embedded:!0})})]})}function o9(){const[t,e]=b.useState([]),[n,s]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(!0);async function f(){h(!0);try{const g=new URLSearchParams({page:String(a),pageSize:String(o),matchType:"team"}),y=await De(`/api/db/match-records?${g}`);y!=null&&y.success&&(e(y.records||[]),s(y.total??0))}catch(g){console.error(g)}finally{h(!1)}}b.useEffect(()=>{f()},[a]);const m=Math.ceil(n/o)||1;return r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between items-center mb-4",children:[r.jsxs("div",{children:[r.jsxs("p",{className:"text-gray-400",children:["团队招募匹配记录,共 ",n," 条"]}),r.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"用户通过「团队招募」提交联系方式到存客宝"})]}),r.jsxs("button",{type:"button",onClick:f,disabled:u,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700/50 transition-colors disabled:opacity-50",children:[r.jsx(Be,{className:`w-4 h-4 ${u?"animate-spin":""}`})," 刷新"]})]}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Le,{className:"p-0",children:u?r.jsxs("div",{className:"flex justify-center py-12",children:[r.jsx(Be,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[r.jsxs(hs,{children:[r.jsx(fs,{children:r.jsxs(pt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(je,{className:"text-gray-400",children:"发起人"}),r.jsx(je,{className:"text-gray-400",children:"匹配到"}),r.jsx(je,{className:"text-gray-400",children:"联系方式"}),r.jsx(je,{className:"text-gray-400",children:"时间"})]})}),r.jsxs(ps,{children:[t.map(g=>r.jsxs(pt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{className:"text-white",children:g.userNickname||g.userId}),r.jsx(ve,{className:"text-white",children:g.matchedNickname||g.matchedUserId}),r.jsxs(ve,{className:"text-gray-400 text-sm",children:[g.phone&&r.jsxs("div",{children:["📱 ",g.phone]}),g.wechatId&&r.jsxs("div",{children:["💬 ",g.wechatId]}),!g.phone&&!g.wechatId&&"-"]}),r.jsx(ve,{className:"text-gray-400",children:g.createdAt?new Date(g.createdAt).toLocaleString():"-"})]},g.id)),t.length===0&&r.jsx(pt,{children:r.jsx(ve,{colSpan:4,className:"text-center py-12 text-gray-500",children:"暂无团队招募记录"})})]})]}),r.jsx(Gs,{page:a,totalPages:m,total:n,pageSize:o,onPageChange:i,onPageSizeChange:g=>{c(g),i(1)}})]})})})]})}const Yw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募",join:"加入",match:"匹配"},Qw={partner:"⭐",investor:"👥",mentor:"❤️",team:"🎮",join:"📋",match:"🔗"};function l9({onSwitchTab:t,onOpenCKB:e}={}){const n=Aa(),[s,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[v,w]=await Promise.allSettled([De("/api/db/match-records?stats=true"),De("/api/db/ckb-plan-stats")]);if(v.status==="fulfilled"&&((g=v.value)!=null&&g.success)&&v.value.data){let N=v.value.data;if(N.totalMatches>0&&(!N.uniqueUsers||N.uniqueUsers===0))try{const k=await De("/api/db/match-records?page=1&pageSize=200");if(k!=null&&k.success&&k.records){const E=new Set(k.records.map(C=>C.userId).filter(Boolean));N={...N,uniqueUsers:E.size}}}catch{}a(N)}w.status==="fulfilled"&&((y=w.value)!=null&&y.success)&&w.value.data&&o(w.value.data)}catch(v){console.error("加载统计失败:",v)}finally{u(!1)}},[]);b.useEffect(()=>{h()},[h]);const f=g=>c?"—":String(g??0),m=s!=null&&s.uniqueUsers?(s.totalMatches/s.uniqueUsers).toFixed(1):"0";return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-5 gap-3",children:[r.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:r.jsxs(Le,{className:"p-4",children:[r.jsx("p",{className:"text-gray-400 text-xs",children:"总匹配"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:f(s==null?void 0:s.totalMatches)}),r.jsxs("p",{className:"text-[#38bdac] text-[10px] mt-1 flex items-center gap-0.5",children:[r.jsx(di,{className:"w-2.5 h-2.5"})," 查看记录"]})]})}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40",children:r.jsxs(Le,{className:"p-4",children:[r.jsx("p",{className:"text-gray-400 text-xs",children:"今日"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:f(s==null?void 0:s.todayMatches)}),r.jsxs("p",{className:"text-yellow-400/60 text-[10px] mt-1 flex items-center gap-0.5",children:[r.jsx(ao,{className:"w-2.5 h-2.5"})," 实时"]})]})}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40 cursor-pointer hover:border-blue-500/60 transition-all",onClick:()=>n("/users"),children:r.jsxs(Le,{className:"p-4",children:[r.jsx("p",{className:"text-gray-400 text-xs",children:"用户数"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:f(s==null?void 0:s.uniqueUsers)}),r.jsxs("p",{className:"text-blue-400/60 text-[10px] mt-1 flex items-center gap-0.5",children:[r.jsx(zn,{className:"w-2.5 h-2.5"})," 查看用户"]})]})}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40",children:r.jsxs(Le,{className:"p-4",children:[r.jsx("p",{className:"text-gray-400 text-xs",children:"人均匹配"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:c?"—":m})]})}),r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40",children:r.jsxs(Le,{className:"p-4",children:[r.jsx("p",{className:"text-gray-400 text-xs",children:"付费匹配"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:f(s==null?void 0:s.paidMatchCount)})]})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsx(Oe,{className:"bg-[#0f2137] border-gray-700/40",children:r.jsxs(Le,{className:"p-4",children:[r.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"匹配类型分布"}),s!=null&&s.byType&&s.byType.length>0?r.jsx("div",{className:"space-y-2",children:s.byType.map(g=>{const y=s.totalMatches>0?g.count/s.totalMatches*100:0;return r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:"text-lg shrink-0",children:Qw[g.matchType]||"📊"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex justify-between text-xs mb-0.5",children:[r.jsx("span",{className:"text-gray-300",children:Yw[g.matchType]||g.matchType}),r.jsxs("span",{className:"text-gray-500",children:[g.count," (",y.toFixed(0),"%)"]})]}),r.jsx("div",{className:"w-full h-1.5 bg-gray-700/50 rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-[#38bdac] rounded-full",style:{width:`${Math.min(y,100)}%`}})})]})]},g.matchType)})}):r.jsx("p",{className:"text-gray-500 text-xs",children:"暂无数据"})]})}),r.jsx(Oe,{className:"bg-[#0f2137] border-orange-500/20",children:r.jsxs(Le,{className:"p-4",children:[r.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-1.5",children:[r.jsx(ro,{className:"w-4 h-4 text-orange-400"})," AI 获客"]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[r.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:[r.jsx("p",{className:"text-gray-400 text-xs",children:"已提交线索"}),r.jsx("p",{className:"text-xl font-bold text-white",children:c?"—":(i==null?void 0:i.ckbTotal)??0})]}),r.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:[r.jsx("p",{className:"text-gray-400 text-xs",children:"有联系方式"}),r.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&&r.jsx("div",{className:"space-y-1.5",children:i.byType.map(g=>r.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[r.jsx("span",{children:Qw[g.matchType]||"📋"}),r.jsx("span",{className:"text-gray-400",children:Yw[g.matchType]||g.matchType}),r.jsx("span",{className:"ml-auto text-white font-medium",children:g.total})]},g.matchType))}),r.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 c9=["partner","investor","mentor","team"],Yg=[{key:"join_partner",label:"找伙伴场景"},{key:"join_investor",label:"资源对接场景"},{key:"join_mentor",label:"导师顾问场景"},{key:"join_team",label:"团队招募场景"},{key:"match",label:"匹配上报"},{key:"lead",label:"链接卡若"}],Xw=`# 场景获客接口摘要
- 地址POST /v1/api/scenarios
- 必填apiKey、sign、timestamp
- 主标识phone 或 wechatId 至少一项
- 可选name、source、remark、tags、siteTags、portrait
- 签名:排除 sign/apiKey/portrait键名升序拼接值后双重 MD5
- 成功code=200message=新增成功 或 已存在`;function d9({initialTab:t="overview"}){const[e,n]=b.useState(t),[s,a]=b.useState("13800000000"),[i,o]=b.useState(""),[c,u]=b.useState(""),[h,f]=b.useState(Xw),[m,g]=b.useState(!1),[y,v]=b.useState(!1),[w,N]=b.useState([]),[k,E]=b.useState([]),[C,P]=b.useState({}),[O,U]=b.useState([{endpoint:"/api/ckb/join",label:"找伙伴",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"资源对接",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"导师顾问",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"团队招募",method:"POST",status:"idle"},{endpoint:"/api/ckb/match",label:"匹配上报",method:"POST",status:"idle"},{endpoint:"/api/miniprogram/ckb/lead",label:"链接卡若",method:"POST",status:"idle"},{endpoint:"/api/match/config",label:"匹配配置",method:"GET",status:"idle"}]),_=b.useMemo(()=>{const $={};return Yg.forEach(D=>{$[D.key]=C[D.key]||{apiUrl:"https://ckbapi.quwanzhi.com/v1/api/scenarios",apiKey:"fyngh-ecy9h-qkdae-epwd5-rz6kd",source:"",tags:"",siteTags:"创业实验APP",notes:""}}),$},[C]),V=$=>{const D=s.trim(),I=i.trim();return $<=3?{type:c9[$],phone:D||void 0,wechat:I||void 0,userId:"admin_test",name:"后台测试"}:$===4?{matchType:"partner",phone:D||void 0,wechat:I||void 0,userId:"admin_test",nickname:"后台测试",matchedUser:{id:"test",nickname:"测试",matchScore:88}}:$===5?{phone:D||void 0,wechatId:I||void 0,userId:"admin_test",name:"后台测试"}:{}};async function A(){v(!0);try{const[$,D,I]=await Promise.all([De("/api/db/config/full?key=ckb_config"),De("/api/db/ckb-leads?mode=submitted&page=1&pageSize=50"),De("/api/db/ckb-leads?mode=contact&page=1&pageSize=50")]),ie=$==null?void 0:$.data;ie!=null&&ie.routes&&P(ie.routes),ie!=null&&ie.docNotes&&u(ie.docNotes),ie!=null&&ie.docContent&&f(ie.docContent),D!=null&&D.success&&N(D.records||[]),I!=null&&I.success&&E(I.records||[])}finally{v(!1)}}b.useEffect(()=>{n(t)},[t]),b.useEffect(()=>{A()},[]);const X=b.useMemo(()=>{const $=L=>(L||"").replace(/\D/g,"")||"",D=L=>{const F=$(L.phone);if(F)return`phone:${F}`;const re=(L.userId||"").trim();if(re)return`user:${re}`;const ge=(L.wechatId||"").trim();return ge?`wechat:${ge}`:`row:${L.id}`},I=[...k].sort((L,F)=>{const re=L.createdAt?new Date(L.createdAt).getTime():0;return(F.createdAt?new Date(F.createdAt).getTime():0)-re}),ie=new Set,q=[];for(const L of I){const F=D(L);ie.has(F)||(ie.add(F),q.push(L))}return q},[k]);async function G(){g(!0);try{const $=await Et("/api/db/config",{key:"ckb_config",value:{routes:_,docNotes:c,docContent:h},description:"存客宝接口配置"});oe.error(($==null?void 0:$.success)!==!1?"存客宝配置已保存":`保存失败: ${($==null?void 0:$.error)||"未知错误"}`)}catch($){oe.error(`保存失败: ${$ instanceof Error?$.message:"网络错误"}`)}finally{g(!1)}}const z=($,D)=>{P(I=>({...I,[$]:{..._[$],...D}}))},ne=async $=>{const D=O[$];if(D.method==="POST"&&!s.trim()&&!i.trim()){oe.error("请填写测试手机号");return}const I=[...O];I[$]={...D,status:"testing",message:void 0,responseTime:void 0},U(I);const ie=performance.now();try{const q=D.method==="GET"?await De(D.endpoint):await Et(D.endpoint,V($)),L=Math.round(performance.now()-ie),F=(q==null?void 0:q.message)||"",re=(q==null?void 0:q.success)===!0||F.includes("已存在")||F.includes("已加入")||F.includes("已提交"),ge=[...O];ge[$]={...D,status:re?"success":"error",message:F||(re?"正常":"异常"),responseTime:L},U(ge),await A()}catch(q){const L=Math.round(performance.now()-ie),F=[...O];F[$]={...D,status:"error",message:q instanceof Error?q.message:"失败",responseTime:L},U(F)}},ue=async()=>{if(!s.trim()&&!i.trim()){oe.error("请填写测试手机号");return}for(let $=0;$<O.length;$++)await ne($)},K=($,D,I)=>r.jsx("div",{className:"overflow-auto rounded-lg border border-gray-700/30",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{className:"bg-[#0a1628] text-gray-400",children:r.jsxs("tr",{children:[r.jsx("th",{className:"text-left px-4 py-3",children:"发起人"}),r.jsx("th",{className:"text-left px-4 py-3",children:"类型"}),r.jsx("th",{className:"text-left px-4 py-3",children:"手机号"}),r.jsx("th",{className:"text-left px-4 py-3",children:"微信号"}),r.jsx("th",{className:"text-left px-4 py-3",children:"时间"})]})}),r.jsx("tbody",{children:$.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:5,className:"p-0 align-top",children:r.jsxs("div",{className:"py-14 px-6 text-center bg-[#0a1628]/40 border-t border-gray-700/30",children:[r.jsx(mc,{className:"w-12 h-12 text-orange-400/25 mx-auto mb-3","aria-hidden":!0}),r.jsx("p",{className:"text-gray-300 font-medium",children:D}),I?r.jsx("p",{className:"text-gray-500 text-sm mt-2 max-w-md mx-auto leading-relaxed",children:I}):null]})})}):$.map(ie=>r.jsxs("tr",{className:"border-t border-gray-700/30",children:[r.jsx("td",{className:"px-4 py-3 text-white",children:ie.userNickname||ie.userId}),r.jsx("td",{className:"px-4 py-3 text-gray-300",children:ie.matchType}),r.jsx("td",{className:"px-4 py-3 text-green-400",children:ie.phone||"—"}),r.jsx("td",{className:"px-4 py-3 text-blue-400",children:ie.wechatId||"—"}),r.jsx("td",{className:"px-4 py-3 text-gray-400",children:ie.createdAt?new Date(ie.createdAt).toLocaleString():"—"})]},String(ie.id)))})]})});return r.jsx(Oe,{className:"bg-[#0f2137] border-orange-500/30 mb-6",children:r.jsxs(Le,{className:"p-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("h3",{className:"text-white font-semibold",children:"存客宝工作台"}),r.jsx(Ge,{className:"bg-orange-500/20 text-orange-400 border-0 text-xs",children:"CKB"}),r.jsxs("button",{type:"button",onClick:()=>n("doc"),className:"text-orange-400/60 text-xs hover:text-orange-400 flex items-center gap-1",children:[r.jsx(di,{className:"w-3 h-3"})," API 文档"]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(Y,{onClick:()=>A(),variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Be,{className:`w-3.5 h-3.5 mr-1 ${y?"animate-spin":""}`})," 刷新"]}),r.jsxs(Y,{onClick:G,disabled:m,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(En,{className:"w-3.5 h-3.5 mr-1"})," ",m?"保存中...":"保存配置"]})]})]}),r.jsx("div",{className:"flex flex-wrap gap-2 mb-5",children:[["overview","概览"],["submitted","已提交线索"],["contact","有联系方式"],["config","场景配置"],["test","接口测试"],["doc","API 文档"]].map(([$,D])=>r.jsx("button",{type:"button",onClick:()=>n($),className:`px-4 py-2 rounded-lg text-sm transition-colors ${e===$?"bg-orange-500 text-white":"bg-[#0a1628] text-gray-400 hover:text-white"}`,children:D},$))}),e==="overview"&&r.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[r.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"已提交线索"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:w.length})]}),r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[r.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"有联系方式(已去重)"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:X.length}),k.length!==X.length&&r.jsxs("p",{className:"text-[10px] text-gray-500 mt-1",children:["原始 ",k.length," 条"]})]}),r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[r.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"场景配置数"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:Yg.length})]}),r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[r.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"文档备注"}),r.jsx("p",{className:"text-sm text-gray-300 line-clamp-3",children:c||"未填写"})]})]}),e==="submitted"&&K(w,"暂无已提交线索","用户通过场景提交后会出现于此。"),e==="contact"&&r.jsxs("div",{className:"space-y-2",children:[k.length>X.length&&r.jsxs("p",{className:"text-xs text-gray-500",children:["已合并 ",k.length-X.length," 条重复(同手机号或同用户 ID 仅保留最近一条)"]}),K(X,"暂无有联系方式线索","存客宝留资同步后显示;完整列表与筛选请前往「用户管理 → 获客列表」。")]}),e==="config"&&r.jsx("div",{className:"space-y-4",children:Yg.map($=>r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h4",{className:"text-white font-medium",children:$.label}),r.jsx(Ge,{className:"bg-orange-500/20 text-orange-300 border-0 text-xs",children:$.key})]}),r.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-500 text-xs",children:"API 地址"}),r.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:_[$.key].apiUrl,onChange:D=>z($.key,{apiUrl:D.target.value})})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-500 text-xs",children:"API Key"}),r.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:_[$.key].apiKey,onChange:D=>z($.key,{apiKey:D.target.value})})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-500 text-xs",children:"Source"}),r.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:_[$.key].source,onChange:D=>z($.key,{source:D.target.value})})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-500 text-xs",children:"Tags"}),r.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:_[$.key].tags,onChange:D=>z($.key,{tags:D.target.value})})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-500 text-xs",children:"SiteTags"}),r.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:_[$.key].siteTags,onChange:D=>z($.key,{siteTags:D.target.value})})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(ee,{className:"text-gray-500 text-xs",children:"说明备注"}),r.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:_[$.key].notes,onChange:D=>z($.key,{notes:D.target.value})})]})]})]},$.key))}),e==="test"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex gap-3 mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[r.jsx(mc,{className:"w-4 h-4 text-gray-500 shrink-0"}),r.jsxs("div",{className:"flex-1",children:[r.jsx(ee,{className:"text-gray-500 text-xs",children:"测试手机号"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:s,onChange:$=>a($.target.value)})]})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[r.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"💬"}),r.jsxs("div",{className:"flex-1",children:[r.jsx(ee,{className:"text-gray-500 text-xs",children:"微信号(可选)"}),r.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:i,onChange:$=>o($.target.value)})]})]}),r.jsx("div",{className:"flex items-end",children:r.jsxs(Y,{onClick:ue,className:"bg-orange-500 hover:bg-orange-600 text-white",children:[r.jsx(ao,{className:"w-3.5 h-3.5 mr-1"})," 全部测试"]})})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-2",children:O.map(($,D)=>r.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg px-3 py-2 border border-gray-700/30",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[$.status==="idle"&&r.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-600 shrink-0"}),$.status==="testing"&&r.jsx(Be,{className:"w-3 h-3 text-yellow-400 animate-spin shrink-0"}),$.status==="success"&&r.jsx(fj,{className:"w-3 h-3 text-green-400 shrink-0"}),$.status==="error"&&r.jsx(mj,{className:"w-3 h-3 text-red-400 shrink-0"}),r.jsx("span",{className:"text-white text-xs truncate",children:$.label})]}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[$.responseTime!==void 0&&r.jsxs("span",{className:"text-gray-600 text-[10px]",children:[$.responseTime,"ms"]}),r.jsx("button",{type:"button",onClick:()=>ne(D),disabled:$.status==="testing",className:"text-orange-400/60 hover:text-orange-400 text-[10px] disabled:opacity-50",children:"测试"})]})]},`${$.endpoint}-${D}`))})]}),e==="doc"&&r.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h4",{className:"text-white text-sm font-medium",children:"场景获客 API 摘要"}),r.jsxs("a",{href:"https://ckbapi.quwanzhi.com/v1/api/scenarios",target:"_blank",rel:"noreferrer",className:"text-orange-400/70 hover:text-orange-400 text-xs flex items-center gap-1",children:[r.jsx(di,{className:"w-3 h-3"})," 打开外链"]})]}),r.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-400 leading-6",children:h||Xw})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[r.jsx("h4",{className:"text-white text-sm font-medium mb-3",children:"说明备注(可编辑)"}),r.jsx("textarea",{className:"w-full min-h-[260px] bg-[#0f2137] border border-gray-700 rounded-md text-sm text-gray-300 p-3 outline-none focus:border-orange-500/50 resize-y",value:c,onChange:$=>u($.target.value),placeholder:"记录 Token、入口差异、回复率统计规则、对接约定等。"})]})]})]})})}const u9=[{id:"stats",label:"数据统计",icon:gd,desc:"匹配与获客概览"},{id:"partner",label:"找伙伴",icon:zn,desc:"匹配池与记录"},{id:"resource",label:"资源对接",icon:L5,desc:"人脉资源"},{id:"mentor",label:"导师预约",icon:R5,desc:"预约与管理"},{id:"team",label:"团队招募",icon:lc,desc:"团队协作"}];function h9(){const[t,e]=b.useState("stats"),[n,s]=b.useState(!1),[a,i]=b.useState("overview");return r.jsxs("div",{className:"p-8 w-full max-w-7xl mx-auto",children:[r.jsxs("div",{className:"mb-8 flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-xl font-semibold text-white flex items-center gap-2",children:[r.jsx(zn,{className:"w-5 h-5 text-[#38bdac]"}),"找伙伴"]}),r.jsx("p",{className:"text-gray-500 text-sm mt-0.5",children:"匹配、获客、导师与团队管理"})]}),r.jsxs(Y,{type:"button",variant:"outline",size:"sm",onClick:()=>s(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:[r.jsx(ro,{className:"w-3.5 h-3.5 mr-1.5"}),"存客宝",r.jsx(Go,{className:`w-3 h-3 ml-1 transition-transform ${n?"rotate-90":""}`})]})]}),n&&r.jsx(d9,{initialTab:a}),r.jsx("div",{className:"flex gap-1 mb-6 bg-[#0a1628] rounded-lg p-1 border border-gray-700/40",children:u9.map(o=>{const c=t===o.id;return r.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:[r.jsx(o.icon,{className:"w-3.5 h-3.5"}),o.label]},o.id)})}),t==="stats"&&r.jsx(l9,{onSwitchTab:o=>e(o),onOpenCKB:o=>{i(o||"overview"),s(!0)}}),t==="partner"&&r.jsx(n9,{}),t==="resource"&&r.jsx(s9,{}),t==="mentor"&&r.jsx(i9,{}),t==="team"&&r.jsx(o9,{})]})}function f9(){const t=po();return r.jsx("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-8",children:r.jsxs("div",{className:"text-center max-w-md",children:[r.jsx("div",{className:"inline-flex items-center justify-center w-20 h-20 rounded-full bg-red-500/20 text-red-400 mb-6",children:r.jsx(hj,{className:"w-10 h-10"})}),r.jsx("h1",{className:"text-4xl font-bold text-white mb-2",children:"404"}),r.jsx("p",{className:"text-gray-400 mb-1",children:"页面不存在"}),r.jsx("p",{className:"text-sm text-gray-500 font-mono mb-8 break-all",children:t.pathname}),r.jsx(Y,{asChild:!0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:r.jsxs($d,{to:"/",children:[r.jsx(U5,{className:"w-4 h-4 mr-2"}),"返回首页"]})})]})})}function p9(){return r.jsxs(CT,{children:[r.jsx(Zt,{path:"/login",element:r.jsx(xI,{})}),r.jsxs(Zt,{path:"/",element:r.jsx(vA,{}),children:[r.jsx(Zt,{index:!0,element:r.jsx(ah,{to:"/dashboard",replace:!0})}),r.jsx(Zt,{path:"dashboard",element:r.jsx(AP,{})}),r.jsx(Zt,{path:"orders",element:r.jsx(IP,{})}),r.jsx(Zt,{path:"users",element:r.jsx(PP,{})}),r.jsx(Zt,{path:"distribution",element:r.jsx(tO,{})}),r.jsx(Zt,{path:"withdrawals",element:r.jsx(nO,{})}),r.jsx(Zt,{path:"content",element:r.jsx(RV,{})}),r.jsx(Zt,{path:"referral-settings",element:r.jsx(sS,{})}),r.jsx(Zt,{path:"author-settings",element:r.jsx(ah,{to:"/settings?tab=author",replace:!0})}),r.jsx(Zt,{path:"vip-roles",element:r.jsx(QV,{})}),r.jsx(Zt,{path:"mentors",element:r.jsx(i4,{})}),r.jsx(Zt,{path:"mentor-consultations",element:r.jsx(XV,{})}),r.jsx(Zt,{path:"admin-users",element:r.jsx(ah,{to:"/settings?tab=admin",replace:!0})}),r.jsx(Zt,{path:"settings",element:r.jsx(BV,{})}),r.jsx(Zt,{path:"payment",element:r.jsx(VV,{})}),r.jsx(Zt,{path:"site",element:r.jsx(KV,{})}),r.jsx(Zt,{path:"qrcodes",element:r.jsx(qV,{})}),r.jsx(Zt,{path:"find-partner",element:r.jsx(h9,{})}),r.jsx(Zt,{path:"match",element:r.jsx(JV,{})}),r.jsx(Zt,{path:"match-records",element:r.jsx(YV,{})}),r.jsx(Zt,{path:"api-doc",element:r.jsx(ah,{to:"/api-docs",replace:!0})}),r.jsx(Zt,{path:"api-docs",element:r.jsx(a4,{})})]}),r.jsx(Zt,{path:"*",element:r.jsx(f9,{})})]})}IE.createRoot(document.getElementById("root")).render(r.jsx(b.StrictMode,{children:r.jsx(OT,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:r.jsx(p9,{})})}));