mt?(us=ct,ct=null):us=ct.sibling;var xo=Te(pe,ct,Ht.value,Oe);if(xo===null){ct===null&&(ct=us);break}l&&ct&&xo.alternate===null&&d(pe,ct),ie=S(xo,ie,mt),lt===null?nt=xo:lt.sibling=xo,lt=xo,ct=us}if(Ht.done)return p(pe,ct),Nn&&vl(pe,mt),nt;if(ct===null){for(;!Ht.done;mt++,Ht=ge.next())Ht=Ie(pe,Ht.value,Oe),Ht!==null&&(ie=S(Ht,ie,mt),lt===null?nt=Ht:lt.sibling=Ht,lt=Ht);return Nn&&vl(pe,mt),nt}for(ct=y(pe,ct);!Ht.done;mt++,Ht=ge.next())Ht=qe(ct,pe,mt,Ht.value,Oe),Ht!==null&&(l&&Ht.alternate!==null&&ct.delete(Ht.key===null?mt:Ht.key),ie=S(Ht,ie,mt),lt===null?nt=Ht:lt.sibling=Ht,lt=Ht);return l&&ct.forEach(function(q5){return d(pe,q5)}),Nn&&vl(pe,mt),nt}function zn(pe,ie,ge,Oe){if(typeof ge=="object"&&ge!==null&&ge.type===P&&ge.key===null&&(ge=ge.props.children),typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case R:e:{for(var nt=ge.key,lt=ie;lt!==null;){if(lt.key===nt){if(nt=ge.type,nt===P){if(lt.tag===7){p(pe,lt.sibling),ie=j(lt,ge.props.children),ie.return=pe,pe=ie;break e}}else if(lt.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===I&&Wb(nt)===lt.type){p(pe,lt.sibling),ie=j(lt,ge.props),ie.ref=Bd(pe,lt,ge),ie.return=pe,pe=ie;break e}p(pe,lt);break}else d(pe,lt);lt=lt.sibling}ge.type===P?(ie=Tl(ge.props.children,pe.mode,Oe,ge.key),ie.return=pe,pe=ie):(Oe=$h(ge.type,ge.key,ge.props,null,pe.mode,Oe),Oe.ref=Bd(pe,ie,ge),Oe.return=pe,pe=Oe)}return A(pe);case U:e:{for(lt=ge.key;ie!==null;){if(ie.key===lt)if(ie.tag===4&&ie.stateNode.containerInfo===ge.containerInfo&&ie.stateNode.implementation===ge.implementation){p(pe,ie.sibling),ie=j(ie,ge.children||[]),ie.return=pe,pe=ie;break e}else{p(pe,ie);break}else d(pe,ie);ie=ie.sibling}ie=Cx(ge,pe.mode,Oe),ie.return=pe,pe=ie}return A(pe);case I:return lt=ge._init,zn(pe,ie,lt(ge._payload),Oe)}if(pn(ge))return Xe(pe,ie,ge,Oe);if(xe(ge))return tt(pe,ie,ge,Oe);ph(pe,ge)}return typeof ge=="string"&&ge!==""||typeof ge=="number"?(ge=""+ge,ie!==null&&ie.tag===6?(p(pe,ie.sibling),ie=j(ie,ge),ie.return=pe,pe=ie):(p(pe,ie),ie=Sx(ge,pe.mode,Oe),ie.return=pe,pe=ie),A(pe)):p(pe,ie)}return zn}var Ec=Kb(!0),qb=Kb(!1),mh=ro(null),xh=null,Tc=null,Om=null;function Dm(){Om=Tc=xh=null}function _m(l){var d=mh.current;gn(mh),l._currentValue=d}function $m(l,d,p){for(;l!==null;){var y=l.alternate;if((l.childLanes&d)!==d?(l.childLanes|=d,y!==null&&(y.childLanes|=d)):y!==null&&(y.childLanes&d)!==d&&(y.childLanes|=d),l===p)break;l=l.return}}function Mc(l,d){xh=l,Om=Tc=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(ir=!0),l.firstContext=null)}function Fr(l){var d=l._currentValue;if(Om!==l)if(l={context:l,memoizedValue:d,next:null},Tc===null){if(xh===null)throw Error(n(308));Tc=l,xh.dependencies={lanes:0,firstContext:l}}else Tc=Tc.next=l;return d}var Nl=null;function zm(l){Nl===null?Nl=[l]:Nl.push(l)}function Gb(l,d,p,y){var j=d.interleaved;return j===null?(p.next=p,zm(d)):(p.next=j.next,j.next=p),d.interleaved=p,gi(l,y)}function gi(l,d){l.lanes|=d;var p=l.alternate;for(p!==null&&(p.lanes|=d),p=l,l=l.return;l!==null;)l.childLanes|=d,p=l.alternate,p!==null&&(p.childLanes|=d),p=l,l=l.return;return p.tag===3?p.stateNode:null}var oo=!1;function Fm(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Jb(l,d){l=l.updateQueue,d.updateQueue===l&&(d.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,effects:l.effects})}function yi(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function lo(l,d,p){var y=l.updateQueue;if(y===null)return null;if(y=y.shared,(Bt&2)!==0){var j=y.pending;return j===null?d.next=d:(d.next=j.next,j.next=d),y.pending=d,gi(l,p)}return j=y.interleaved,j===null?(d.next=d,zm(y)):(d.next=j.next,j.next=d),y.interleaved=d,gi(l,p)}function gh(l,d,p){if(d=d.updateQueue,d!==null&&(d=d.shared,(p&4194240)!==0)){var y=d.lanes;y&=l.pendingLanes,p|=y,d.lanes=p,Ta(l,p)}}function Qb(l,d){var p=l.updateQueue,y=l.alternate;if(y!==null&&(y=y.updateQueue,p===y)){var j=null,S=null;if(p=p.firstBaseUpdate,p!==null){do{var A={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};S===null?j=S=A:S=S.next=A,p=p.next}while(p!==null);S===null?j=S=d:S=S.next=d}else j=S=d;p={baseState:y.baseState,firstBaseUpdate:j,lastBaseUpdate:S,shared:y.shared,effects:y.effects},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=d:l.next=d,p.lastBaseUpdate=d}function yh(l,d,p,y){var j=l.updateQueue;oo=!1;var S=j.firstBaseUpdate,A=j.lastBaseUpdate,K=j.shared.pending;if(K!==null){j.shared.pending=null;var se=K,ye=se.next;se.next=null,A===null?S=ye:A.next=ye,A=se;var Pe=l.alternate;Pe!==null&&(Pe=Pe.updateQueue,K=Pe.lastBaseUpdate,K!==A&&(K===null?Pe.firstBaseUpdate=ye:K.next=ye,Pe.lastBaseUpdate=se))}if(S!==null){var Ie=j.baseState;A=0,Pe=ye=se=null,K=S;do{var Te=K.lane,qe=K.eventTime;if((y&Te)===Te){Pe!==null&&(Pe=Pe.next={eventTime:qe,lane:0,tag:K.tag,payload:K.payload,callback:K.callback,next:null});e:{var Xe=l,tt=K;switch(Te=d,qe=p,tt.tag){case 1:if(Xe=tt.payload,typeof Xe=="function"){Ie=Xe.call(qe,Ie,Te);break e}Ie=Xe;break e;case 3:Xe.flags=Xe.flags&-65537|128;case 0:if(Xe=tt.payload,Te=typeof Xe=="function"?Xe.call(qe,Ie,Te):Xe,Te==null)break e;Ie=X({},Ie,Te);break e;case 2:oo=!0}}K.callback!==null&&K.lane!==0&&(l.flags|=64,Te=j.effects,Te===null?j.effects=[K]:Te.push(K))}else qe={eventTime:qe,lane:Te,tag:K.tag,payload:K.payload,callback:K.callback,next:null},Pe===null?(ye=Pe=qe,se=Ie):Pe=Pe.next=qe,A|=Te;if(K=K.next,K===null){if(K=j.shared.pending,K===null)break;Te=K,K=Te.next,Te.next=null,j.lastBaseUpdate=Te,j.shared.pending=null}}while(!0);if(Pe===null&&(se=Ie),j.baseState=se,j.firstBaseUpdate=ye,j.lastBaseUpdate=Pe,d=j.shared.interleaved,d!==null){j=d;do A|=j.lane,j=j.next;while(j!==d)}else S===null&&(j.shared.lanes=0);kl|=A,l.lanes=A,l.memoizedState=Ie}}function Yb(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;dp?p:4,l(!0);var y=Wm.transition;Wm.transition={};try{l(!1),d()}finally{Nt=p,Wm.transition=y}}function xv(){return Br().memoizedState}function g5(l,d,p){var y=fo(l);if(p={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null},gv(l))yv(d,p);else if(p=Gb(l,d,p,y),p!==null){var j=Ks();fa(p,l,y,j),bv(p,d,y)}}function y5(l,d,p){var y=fo(l),j={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null};if(gv(l))yv(d,j);else{var S=l.alternate;if(l.lanes===0&&(S===null||S.lanes===0)&&(S=d.lastRenderedReducer,S!==null))try{var A=d.lastRenderedState,K=S(A,p);if(j.hasEagerState=!0,j.eagerState=K,la(K,A)){var se=d.interleaved;se===null?(j.next=j,zm(d)):(j.next=se.next,se.next=j),d.interleaved=j;return}}catch{}finally{}p=Gb(l,d,j,y),p!==null&&(j=Ks(),fa(p,l,y,j),bv(p,d,y))}}function gv(l){var d=l.alternate;return l===En||d!==null&&d===En}function yv(l,d){Wd=Nh=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function bv(l,d,p){if((p&4194240)!==0){var y=d.lanes;y&=l.pendingLanes,p|=y,d.lanes=p,Ta(l,p)}}var kh={readContext:Fr,useCallback:Ls,useContext:Ls,useEffect:Ls,useImperativeHandle:Ls,useInsertionEffect:Ls,useLayoutEffect:Ls,useMemo:Ls,useReducer:Ls,useRef:Ls,useState:Ls,useDebugValue:Ls,useDeferredValue:Ls,useTransition:Ls,useMutableSource:Ls,useSyncExternalStore:Ls,useId:Ls,unstable_isNewReconciler:!1},b5={readContext:Fr,useCallback:function(l,d){return _a().memoizedState=[l,d===void 0?null:d],l},useContext:Fr,useEffect:lv,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,wh(4194308,4,uv.bind(null,d,l),p)},useLayoutEffect:function(l,d){return wh(4194308,4,l,d)},useInsertionEffect:function(l,d){return wh(4,2,l,d)},useMemo:function(l,d){var p=_a();return d=d===void 0?null:d,l=l(),p.memoizedState=[l,d],l},useReducer:function(l,d,p){var y=_a();return d=p!==void 0?p(d):d,y.memoizedState=y.baseState=d,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:d},y.queue=l,l=l.dispatch=g5.bind(null,En,l),[y.memoizedState,l]},useRef:function(l){var d=_a();return l={current:l},d.memoizedState=l},useState:iv,useDebugValue:Xm,useDeferredValue:function(l){return _a().memoizedState=l},useTransition:function(){var l=iv(!1),d=l[0];return l=x5.bind(null,l[1]),_a().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var y=En,j=_a();if(Nn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),ds===null)throw Error(n(349));(jl&30)!==0||tv(y,d,p)}j.memoizedState=p;var S={value:p,getSnapshot:d};return j.queue=S,lv(sv.bind(null,y,S,l),[l]),y.flags|=2048,Gd(9,nv.bind(null,y,S,p,d),void 0,null),p},useId:function(){var l=_a(),d=ds.identifierPrefix;if(Nn){var p=xi,y=mi;p=(y&~(1<<32-bs(y)-1)).toString(32)+p,d=":"+d+"R"+p,p=Kd++,0<\/script>",l=l.removeChild(l.firstChild)):typeof y.is=="string"?l=A.createElement(p,{is:y.is}):(l=A.createElement(p),p==="select"&&(A=l,y.multiple?A.multiple=!0:y.size&&(A.size=y.size))):l=A.createElementNS(l,p),l[Oa]=d,l[zd]=y,zv(l,d,!1,!1),d.stateNode=l;e:{switch(A=vt(p,y),p){case"dialog":xn("cancel",l),xn("close",l),j=y;break;case"iframe":case"object":case"embed":xn("load",l),j=y;break;case"video":case"audio":for(j=0;j
Lc&&(d.flags|=128,y=!0,Jd(S,!1),d.lanes=4194304)}else{if(!y)if(l=bh(A),l!==null){if(d.flags|=128,y=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),Jd(S,!0),S.tail===null&&S.tailMode==="hidden"&&!A.alternate&&!Nn)return Os(d),null}else 2*mn()-S.renderingStartTime>Lc&&p!==1073741824&&(d.flags|=128,y=!0,Jd(S,!1),d.lanes=4194304);S.isBackwards?(A.sibling=d.child,d.child=A):(p=S.last,p!==null?p.sibling=A:d.child=A,S.last=A)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=mn(),d.sibling=null,p=Cn.current,dn(Cn,y?p&1|2:p&1),d):(Os(d),null);case 22:case 23:return wx(),y=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==y&&(d.flags|=8192),y&&(d.mode&1)!==0?(kr&1073741824)!==0&&(Os(d),d.subtreeFlags&6&&(d.flags|=8192)):Os(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function E5(l,d){switch(Pm(d),d.tag){case 1:return ar(d.type)&&lh(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return Ac(),gn(rr),gn(Rs),Um(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return Vm(d),null;case 13:if(gn(Cn),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));Cc()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return gn(Cn),null;case 4:return Ac(),null;case 10:return _m(d.type._context),null;case 22:case 23:return wx(),null;case 24:return null;default:return null}}var Th=!1,Ds=!1,T5=typeof WeakSet=="function"?WeakSet:Set,Ye=null;function Ic(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(y){An(l,d,y)}else p.current=null}function dx(l,d,p){try{p()}catch(y){An(l,d,y)}}var Vv=!1;function M5(l,d){if(wm=Lr,l=vb(),pm(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var y=p.getSelection&&p.getSelection();if(y&&y.rangeCount!==0){p=y.anchorNode;var j=y.anchorOffset,S=y.focusNode;y=y.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var A=0,K=-1,se=-1,ye=0,Pe=0,Ie=l,Te=null;t:for(;;){for(var qe;Ie!==p||j!==0&&Ie.nodeType!==3||(K=A+j),Ie!==S||y!==0&&Ie.nodeType!==3||(se=A+y),Ie.nodeType===3&&(A+=Ie.nodeValue.length),(qe=Ie.firstChild)!==null;)Te=Ie,Ie=qe;for(;;){if(Ie===l)break t;if(Te===p&&++ye===j&&(K=A),Te===S&&++Pe===y&&(se=A),(qe=Ie.nextSibling)!==null)break;Ie=Te,Te=Ie.parentNode}Ie=qe}p=K===-1||se===-1?null:{start:K,end:se}}else p=null}p=p||{start:0,end:0}}else p=null;for(jm={focusedElem:l,selectionRange:p},Lr=!1,Ye=d;Ye!==null;)if(d=Ye,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,Ye=l;else for(;Ye!==null;){d=Ye;try{var Xe=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(Xe!==null){var tt=Xe.memoizedProps,zn=Xe.memoizedState,pe=d.stateNode,ie=pe.getSnapshotBeforeUpdate(d.elementType===d.type?tt:da(d.type,tt),zn);pe.__reactInternalSnapshotBeforeUpdate=ie}break;case 3:var ge=d.stateNode.containerInfo;ge.nodeType===1?ge.textContent="":ge.nodeType===9&&ge.documentElement&&ge.removeChild(ge.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Oe){An(d,d.return,Oe)}if(l=d.sibling,l!==null){l.return=d.return,Ye=l;break}Ye=d.return}return Xe=Vv,Vv=!1,Xe}function Qd(l,d,p){var y=d.updateQueue;if(y=y!==null?y.lastEffect:null,y!==null){var j=y=y.next;do{if((j.tag&l)===l){var S=j.destroy;j.destroy=void 0,S!==void 0&&dx(d,p,S)}j=j.next}while(j!==y)}}function Mh(l,d){if(d=d.updateQueue,d=d!==null?d.lastEffect:null,d!==null){var p=d=d.next;do{if((p.tag&l)===l){var y=p.create;p.destroy=y()}p=p.next}while(p!==d)}}function ux(l){var d=l.ref;if(d!==null){var p=l.stateNode;switch(l.tag){case 5:l=p;break;default:l=p}typeof d=="function"?d(l):d.current=l}}function Hv(l){var d=l.alternate;d!==null&&(l.alternate=null,Hv(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[Oa],delete d[zd],delete d[Em],delete d[u5],delete d[h5])),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function Uv(l){return l.tag===5||l.tag===3||l.tag===4}function Wv(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||Uv(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function hx(l,d,p){var y=l.tag;if(y===5||y===6)l=l.stateNode,d?p.nodeType===8?p.parentNode.insertBefore(l,d):p.insertBefore(l,d):(p.nodeType===8?(d=p.parentNode,d.insertBefore(l,p)):(d=p,d.appendChild(l)),p=p._reactRootContainer,p!=null||d.onclick!==null||(d.onclick=ih));else if(y!==4&&(l=l.child,l!==null))for(hx(l,d,p),l=l.sibling;l!==null;)hx(l,d,p),l=l.sibling}function fx(l,d,p){var y=l.tag;if(y===5||y===6)l=l.stateNode,d?p.insertBefore(l,d):p.appendChild(l);else if(y!==4&&(l=l.child,l!==null))for(fx(l,d,p),l=l.sibling;l!==null;)fx(l,d,p),l=l.sibling}var ws=null,ua=!1;function co(l,d,p){for(p=p.child;p!==null;)Kv(l,d,p),p=p.sibling}function Kv(l,d,p){if(Zs&&typeof Zs.onCommitFiberUnmount=="function")try{Zs.onCommitFiberUnmount(Xs,p)}catch{}switch(p.tag){case 5:Ds||Ic(p,d);case 6:var y=ws,j=ua;ws=null,co(l,d,p),ws=y,ua=j,ws!==null&&(ua?(l=ws,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):ws.removeChild(p.stateNode));break;case 18:ws!==null&&(ua?(l=ws,p=p.stateNode,l.nodeType===8?Cm(l.parentNode,p):l.nodeType===1&&Cm(l,p),Ia(l)):Cm(ws,p.stateNode));break;case 4:y=ws,j=ua,ws=p.stateNode.containerInfo,ua=!0,co(l,d,p),ws=y,ua=j;break;case 0:case 11:case 14:case 15:if(!Ds&&(y=p.updateQueue,y!==null&&(y=y.lastEffect,y!==null))){j=y=y.next;do{var S=j,A=S.destroy;S=S.tag,A!==void 0&&((S&2)!==0||(S&4)!==0)&&dx(p,d,A),j=j.next}while(j!==y)}co(l,d,p);break;case 1:if(!Ds&&(Ic(p,d),y=p.stateNode,typeof y.componentWillUnmount=="function"))try{y.props=p.memoizedProps,y.state=p.memoizedState,y.componentWillUnmount()}catch(K){An(p,d,K)}co(l,d,p);break;case 21:co(l,d,p);break;case 22:p.mode&1?(Ds=(y=Ds)||p.memoizedState!==null,co(l,d,p),Ds=y):co(l,d,p);break;default:co(l,d,p)}}function qv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new T5),d.forEach(function(y){var j=$5.bind(null,l,y);p.has(y)||(p.add(y),y.then(j,j))})}}function ha(l,d){var p=d.deletions;if(p!==null)for(var y=0;yj&&(j=A),y&=~S}if(y=j,y=mn()-y,y=(120>y?120:480>y?480:1080>y?1080:1920>y?1920:3e3>y?3e3:4320>y?4320:1960*P5(y/1960))-y,10l?16:l,ho===null)var y=!1;else{if(l=ho,ho=null,Lh=0,(Bt&6)!==0)throw Error(n(331));var j=Bt;for(Bt|=4,Ye=l.current;Ye!==null;){var S=Ye,A=S.child;if((Ye.flags&16)!==0){var K=S.deletions;if(K!==null){for(var se=0;semn()-xx?Cl(l,0):mx|=p),lr(l,d)}function i1(l,d){d===0&&((l.mode&1)===0?d=1:(d=tr,tr<<=1,(tr&130023424)===0&&(tr=4194304)));var p=Ks();l=gi(l,d),l!==null&&(Ea(l,d,p),lr(l,p))}function _5(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),i1(l,p)}function $5(l,d){var p=0;switch(l.tag){case 13:var y=l.stateNode,j=l.memoizedState;j!==null&&(p=j.retryLane);break;case 19:y=l.stateNode;break;default:throw Error(n(314))}y!==null&&y.delete(d),i1(l,p)}var o1;o1=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||rr.current)ir=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return ir=!1,S5(l,d,p);ir=(l.flags&131072)!==0}else ir=!1,Nn&&(d.flags&1048576)!==0&&Fb(d,hh,d.index);switch(d.lanes=0,d.tag){case 2:var y=d.type;Eh(l,d),l=d.pendingProps;var j=jc(d,Rs.current);Mc(d,p),j=qm(null,d,y,l,j,p);var S=Gm();return d.flags|=1,typeof j=="object"&&j!==null&&typeof j.render=="function"&&j.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,ar(y)?(S=!0,ch(d)):S=!1,d.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,Fm(d),j.updater=Sh,d.stateNode=j,j._reactInternals=d,ex(d,y,l,p),d=rx(null,d,y,!0,S,p)):(d.tag=0,Nn&&S&&Am(d),Ws(null,d,j,p),d=d.child),d;case 16:y=d.elementType;e:{switch(Eh(l,d),l=d.pendingProps,j=y._init,y=j(y._payload),d.type=y,j=d.tag=F5(y),l=da(y,l),j){case 0:d=sx(null,d,y,l,p);break e;case 1:d=Rv(null,d,y,l,p);break e;case 11:d=Tv(null,d,y,l,p);break e;case 14:d=Mv(null,d,y,da(y.type,l),p);break e}throw Error(n(306,y,""))}return d;case 0:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:da(y,j),sx(l,d,y,j,p);case 1:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:da(y,j),Rv(l,d,y,j,p);case 3:e:{if(Lv(d),l===null)throw Error(n(387));y=d.pendingProps,S=d.memoizedState,j=S.element,Jb(l,d),yh(d,y,null,p);var A=d.memoizedState;if(y=A.element,S.isDehydrated)if(S={element:y,isDehydrated:!1,cache:A.cache,pendingSuspenseBoundaries:A.pendingSuspenseBoundaries,transitions:A.transitions},d.updateQueue.baseState=S,d.memoizedState=S,d.flags&256){j=Pc(Error(n(423)),d),d=Ov(l,d,y,p,j);break e}else if(y!==j){j=Pc(Error(n(424)),d),d=Ov(l,d,y,p,j);break e}else for(jr=so(d.stateNode.containerInfo.firstChild),wr=d,Nn=!0,ca=null,p=qb(d,null,y,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Cc(),y===j){d=bi(l,d,p);break e}Ws(l,d,y,p)}d=d.child}return d;case 5:return Xb(d),l===null&&Rm(d),y=d.type,j=d.pendingProps,S=l!==null?l.memoizedProps:null,A=j.children,km(y,j)?A=null:S!==null&&km(y,S)&&(d.flags|=32),Iv(l,d),Ws(l,d,A,p),d.child;case 6:return l===null&&Rm(d),null;case 13:return Dv(l,d,p);case 4:return Bm(d,d.stateNode.containerInfo),y=d.pendingProps,l===null?d.child=Ec(d,null,y,p):Ws(l,d,y,p),d.child;case 11:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:da(y,j),Tv(l,d,y,j,p);case 7:return Ws(l,d,d.pendingProps,p),d.child;case 8:return Ws(l,d,d.pendingProps.children,p),d.child;case 12:return Ws(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(y=d.type._context,j=d.pendingProps,S=d.memoizedProps,A=j.value,dn(mh,y._currentValue),y._currentValue=A,S!==null)if(la(S.value,A)){if(S.children===j.children&&!rr.current){d=bi(l,d,p);break e}}else for(S=d.child,S!==null&&(S.return=d);S!==null;){var K=S.dependencies;if(K!==null){A=S.child;for(var se=K.firstContext;se!==null;){if(se.context===y){if(S.tag===1){se=yi(-1,p&-p),se.tag=2;var ye=S.updateQueue;if(ye!==null){ye=ye.shared;var Pe=ye.pending;Pe===null?se.next=se:(se.next=Pe.next,Pe.next=se),ye.pending=se}}S.lanes|=p,se=S.alternate,se!==null&&(se.lanes|=p),$m(S.return,p,d),K.lanes|=p;break}se=se.next}}else if(S.tag===10)A=S.type===d.type?null:S.child;else if(S.tag===18){if(A=S.return,A===null)throw Error(n(341));A.lanes|=p,K=A.alternate,K!==null&&(K.lanes|=p),$m(A,p,d),A=S.sibling}else A=S.child;if(A!==null)A.return=S;else for(A=S;A!==null;){if(A===d){A=null;break}if(S=A.sibling,S!==null){S.return=A.return,A=S;break}A=A.return}S=A}Ws(l,d,j.children,p),d=d.child}return d;case 9:return j=d.type,y=d.pendingProps.children,Mc(d,p),j=Fr(j),y=y(j),d.flags|=1,Ws(l,d,y,p),d.child;case 14:return y=d.type,j=da(y,d.pendingProps),j=da(y.type,j),Mv(l,d,y,j,p);case 15:return Av(l,d,d.type,d.pendingProps,p);case 17:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:da(y,j),Eh(l,d),d.tag=1,ar(y)?(l=!0,ch(d)):l=!1,Mc(d,p),Nv(d,y,j),ex(d,y,j,p),rx(null,d,y,!0,l,p);case 19:return $v(l,d,p);case 22:return Pv(l,d,p)}throw Error(n(156,d.tag))};function l1(l,d){return Tt(l,d)}function z5(l,d,p,y){this.tag=l,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=d,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Hr(l,d,p,y){return new z5(l,d,p,y)}function kx(l){return l=l.prototype,!(!l||!l.isReactComponent)}function F5(l){if(typeof l=="function")return kx(l)?1:0;if(l!=null){if(l=l.$$typeof,l===D)return 11;if(l===me)return 14}return 2}function mo(l,d){var p=l.alternate;return p===null?(p=Hr(l.tag,d,l.key,l.mode),p.elementType=l.elementType,p.type=l.type,p.stateNode=l.stateNode,p.alternate=l,l.alternate=p):(p.pendingProps=d,p.type=l.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=l.flags&14680064,p.childLanes=l.childLanes,p.lanes=l.lanes,p.child=l.child,p.memoizedProps=l.memoizedProps,p.memoizedState=l.memoizedState,p.updateQueue=l.updateQueue,d=l.dependencies,p.dependencies=d===null?null:{lanes:d.lanes,firstContext:d.firstContext},p.sibling=l.sibling,p.index=l.index,p.ref=l.ref,p}function $h(l,d,p,y,j,S){var A=2;if(y=l,typeof l=="function")kx(l)&&(A=1);else if(typeof l=="string")A=5;else e:switch(l){case P:return Tl(p.children,j,S,d);case z:A=8,j|=8;break;case O:return l=Hr(12,p,d,j|2),l.elementType=O,l.lanes=S,l;case ne:return l=Hr(13,p,d,j),l.elementType=ne,l.lanes=S,l;case le:return l=Hr(19,p,d,j),l.elementType=le,l.lanes=S,l;case Y:return zh(p,j,S,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case Q:A=10;break e;case re:A=9;break e;case D:A=11;break e;case me:A=14;break e;case I:A=16,y=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=Hr(A,p,d,j),d.elementType=l,d.type=y,d.lanes=S,d}function Tl(l,d,p,y){return l=Hr(7,l,y,d),l.lanes=p,l}function zh(l,d,p,y){return l=Hr(22,l,y,d),l.elementType=Y,l.lanes=p,l.stateNode={isHidden:!1},l}function Sx(l,d,p){return l=Hr(6,l,null,d),l.lanes=p,l}function Cx(l,d,p){return d=Hr(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function B5(l,d,p,y,j){this.tag=d,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Qi(0),this.expirationTimes=Qi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qi(0),this.identifierPrefix=y,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function Ex(l,d,p,y,j,S,A,K,se){return l=new B5(l,d,p,K,se),d===1?(d=1,S===!0&&(d|=8)):d=0,S=Hr(3,null,null,d),l.current=S,S.stateNode=l,S.memoizedState={element:y,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Fm(S),l}function V5(l,d,p){var y=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Rx.exports=eE(),Rx.exports}var w1;function tE(){if(w1)return Kh;w1=1;var t=Fj();return Kh.createRoot=t.createRoot,Kh.hydrateRoot=t.hydrateRoot,Kh}var nE=tE(),hd=Fj();const Bj=zj(hd);/**
+`+S.stack}return{value:l,source:d,stack:j,digest:null}}function tx(l,d,p){return{value:l,source:null,stack:p??null,digest:d??null}}function nx(l,d){try{console.error(d.value)}catch(p){setTimeout(function(){throw p})}}var w5=typeof WeakMap=="function"?WeakMap:Map;function jv(l,d,p){p=yi(-1,p),p.tag=3,p.payload={element:null};var y=d.value;return p.callback=function(){Ih||(Ih=!0,gx=y),nx(l,d)},p}function kv(l,d,p){p=yi(-1,p),p.tag=3;var y=l.type.getDerivedStateFromError;if(typeof y=="function"){var j=d.value;p.payload=function(){return y(j)},p.callback=function(){nx(l,d)}}var S=l.stateNode;return S!==null&&typeof S.componentDidCatch=="function"&&(p.callback=function(){nx(l,d),typeof y!="function"&&(uo===null?uo=new Set([this]):uo.add(this));var A=d.stack;this.componentDidCatch(d.value,{componentStack:A!==null?A:""})}),p}function Sv(l,d,p){var y=l.pingCache;if(y===null){y=l.pingCache=new w5;var j=new Set;y.set(d,j)}else j=y.get(d),j===void 0&&(j=new Set,y.set(d,j));j.has(p)||(j.add(p),l=D5.bind(null,l,d,p),d.then(l,l))}function Cv(l){do{var d;if((d=l.tag===13)&&(d=l.memoizedState,d=d!==null?d.dehydrated!==null:!0),d)return l;l=l.return}while(l!==null);return null}function Ev(l,d,p,y,j){return(l.mode&1)===0?(l===d?l.flags|=65536:(l.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(d=yi(-1,1),d.tag=2,lo(p,d,1))),p.lanes|=1),l):(l.flags|=65536,l.lanes=j,l)}var j5=L.ReactCurrentOwner,ir=!1;function Ws(l,d,p,y){d.child=l===null?qb(d,null,p,y):Ec(d,l.child,p,y)}function Tv(l,d,p,y,j){p=p.render;var S=d.ref;return Mc(d,j),y=qm(l,d,p,y,S,j),p=Gm(),l!==null&&!ir?(d.updateQueue=l.updateQueue,d.flags&=-2053,l.lanes&=~j,bi(l,d,j)):(Nn&&p&&Am(d),d.flags|=1,Ws(l,d,y,j),d.child)}function Mv(l,d,p,y,j){if(l===null){var S=p.type;return typeof S=="function"&&!kx(S)&&S.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(d.tag=15,d.type=S,Av(l,d,S,y,j)):(l=$h(p.type,null,y,d,d.mode,j),l.ref=d.ref,l.return=d,d.child=l)}if(S=l.child,(l.lanes&j)===0){var A=S.memoizedProps;if(p=p.compare,p=p!==null?p:Ld,p(A,y)&&l.ref===d.ref)return bi(l,d,j)}return d.flags|=1,l=mo(S,y),l.ref=d.ref,l.return=d,d.child=l}function Av(l,d,p,y,j){if(l!==null){var S=l.memoizedProps;if(Ld(S,y)&&l.ref===d.ref)if(ir=!1,d.pendingProps=y=S,(l.lanes&j)!==0)(l.flags&131072)!==0&&(ir=!0);else return d.lanes=l.lanes,bi(l,d,j)}return sx(l,d,p,y,j)}function Pv(l,d,p){var y=d.pendingProps,j=y.children,S=l!==null?l.memoizedState:null;if(y.mode==="hidden")if((d.mode&1)===0)d.memoizedState={baseLanes:0,cachePool:null,transitions:null},dn(Rc,kr),kr|=p;else{if((p&1073741824)===0)return l=S!==null?S.baseLanes|p:p,d.lanes=d.childLanes=1073741824,d.memoizedState={baseLanes:l,cachePool:null,transitions:null},d.updateQueue=null,dn(Rc,kr),kr|=l,null;d.memoizedState={baseLanes:0,cachePool:null,transitions:null},y=S!==null?S.baseLanes:p,dn(Rc,kr),kr|=y}else S!==null?(y=S.baseLanes|p,d.memoizedState=null):y=p,dn(Rc,kr),kr|=y;return Ws(l,d,j,p),d.child}function Iv(l,d){var p=d.ref;(l===null&&p!==null||l!==null&&l.ref!==p)&&(d.flags|=512,d.flags|=2097152)}function sx(l,d,p,y,j){var S=ar(p)?yl:Rs.current;return S=jc(d,S),Mc(d,j),p=qm(l,d,p,y,S,j),y=Gm(),l!==null&&!ir?(d.updateQueue=l.updateQueue,d.flags&=-2053,l.lanes&=~j,bi(l,d,j)):(Nn&&y&&Am(d),d.flags|=1,Ws(l,d,p,j),d.child)}function Rv(l,d,p,y,j){if(ar(p)){var S=!0;ch(d)}else S=!1;if(Mc(d,j),d.stateNode===null)Eh(l,d),Nv(d,p,y),ex(d,p,y,j),y=!0;else if(l===null){var A=d.stateNode,K=d.memoizedProps;A.props=K;var se=A.context,ye=p.contextType;typeof ye=="object"&&ye!==null?ye=Fr(ye):(ye=ar(p)?yl:Rs.current,ye=jc(d,ye));var Pe=p.getDerivedStateFromProps,Ie=typeof Pe=="function"||typeof A.getSnapshotBeforeUpdate=="function";Ie||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(K!==y||se!==ye)&&wv(d,A,y,ye),oo=!1;var Te=d.memoizedState;A.state=Te,yh(d,y,A,j),se=d.memoizedState,K!==y||Te!==se||rr.current||oo?(typeof Pe=="function"&&(Zm(d,p,Pe,y),se=d.memoizedState),(K=oo||vv(d,p,K,y,Te,se,ye))?(Ie||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount()),typeof A.componentDidMount=="function"&&(d.flags|=4194308)):(typeof A.componentDidMount=="function"&&(d.flags|=4194308),d.memoizedProps=y,d.memoizedState=se),A.props=y,A.state=se,A.context=ye,y=K):(typeof A.componentDidMount=="function"&&(d.flags|=4194308),y=!1)}else{A=d.stateNode,Jb(l,d),K=d.memoizedProps,ye=d.type===d.elementType?K:da(d.type,K),A.props=ye,Ie=d.pendingProps,Te=A.context,se=p.contextType,typeof se=="object"&&se!==null?se=Fr(se):(se=ar(p)?yl:Rs.current,se=jc(d,se));var qe=p.getDerivedStateFromProps;(Pe=typeof qe=="function"||typeof A.getSnapshotBeforeUpdate=="function")||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(K!==Ie||Te!==se)&&wv(d,A,y,se),oo=!1,Te=d.memoizedState,A.state=Te,yh(d,y,A,j);var Xe=d.memoizedState;K!==Ie||Te!==Xe||rr.current||oo?(typeof qe=="function"&&(Zm(d,p,qe,y),Xe=d.memoizedState),(ye=oo||vv(d,p,ye,y,Te,Xe,se)||!1)?(Pe||typeof A.UNSAFE_componentWillUpdate!="function"&&typeof A.componentWillUpdate!="function"||(typeof A.componentWillUpdate=="function"&&A.componentWillUpdate(y,Xe,se),typeof A.UNSAFE_componentWillUpdate=="function"&&A.UNSAFE_componentWillUpdate(y,Xe,se)),typeof A.componentDidUpdate=="function"&&(d.flags|=4),typeof A.getSnapshotBeforeUpdate=="function"&&(d.flags|=1024)):(typeof A.componentDidUpdate!="function"||K===l.memoizedProps&&Te===l.memoizedState||(d.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||K===l.memoizedProps&&Te===l.memoizedState||(d.flags|=1024),d.memoizedProps=y,d.memoizedState=Xe),A.props=y,A.state=Xe,A.context=se,y=ye):(typeof A.componentDidUpdate!="function"||K===l.memoizedProps&&Te===l.memoizedState||(d.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||K===l.memoizedProps&&Te===l.memoizedState||(d.flags|=1024),y=!1)}return rx(l,d,p,y,S,j)}function rx(l,d,p,y,j,S){Iv(l,d);var A=(d.flags&128)!==0;if(!y&&!A)return j&&$b(d,p,!1),bi(l,d,S);y=d.stateNode,j5.current=d;var K=A&&typeof p.getDerivedStateFromError!="function"?null:y.render();return d.flags|=1,l!==null&&A?(d.child=Ec(d,l.child,null,S),d.child=Ec(d,null,K,S)):Ws(l,d,K,S),d.memoizedState=y.state,j&&$b(d,p,!0),d.child}function Lv(l){var d=l.stateNode;d.pendingContext?Db(l,d.pendingContext,d.pendingContext!==d.context):d.context&&Db(l,d.context,!1),Bm(l,d.containerInfo)}function Ov(l,d,p,y,j){return Cc(),Lm(j),d.flags|=256,Ws(l,d,p,y),d.child}var ax={dehydrated:null,treeContext:null,retryLane:0};function ix(l){return{baseLanes:l,cachePool:null,transitions:null}}function Dv(l,d,p){var y=d.pendingProps,j=Cn.current,S=!1,A=(d.flags&128)!==0,K;if((K=A)||(K=l!==null&&l.memoizedState===null?!1:(j&2)!==0),K?(S=!0,d.flags&=-129):(l===null||l.memoizedState!==null)&&(j|=1),dn(Cn,j&1),l===null)return Rm(d),l=d.memoizedState,l!==null&&(l=l.dehydrated,l!==null)?((d.mode&1)===0?d.lanes=1:l.data==="$!"?d.lanes=8:d.lanes=1073741824,null):(A=y.children,l=y.fallback,S?(y=d.mode,S=d.child,A={mode:"hidden",children:A},(y&1)===0&&S!==null?(S.childLanes=0,S.pendingProps=A):S=zh(A,y,0,null),l=Tl(l,y,p,null),S.return=d,l.return=d,S.sibling=l,d.child=S,d.child.memoizedState=ix(p),d.memoizedState=ax,l):ox(d,A));if(j=l.memoizedState,j!==null&&(K=j.dehydrated,K!==null))return k5(l,d,A,y,K,j,p);if(S){S=y.fallback,A=d.mode,j=l.child,K=j.sibling;var se={mode:"hidden",children:y.children};return(A&1)===0&&d.child!==j?(y=d.child,y.childLanes=0,y.pendingProps=se,d.deletions=null):(y=mo(j,se),y.subtreeFlags=j.subtreeFlags&14680064),K!==null?S=mo(K,S):(S=Tl(S,A,p,null),S.flags|=2),S.return=d,y.return=d,y.sibling=S,d.child=y,y=S,S=d.child,A=l.child.memoizedState,A=A===null?ix(p):{baseLanes:A.baseLanes|p,cachePool:null,transitions:A.transitions},S.memoizedState=A,S.childLanes=l.childLanes&~p,d.memoizedState=ax,y}return S=l.child,l=S.sibling,y=mo(S,{mode:"visible",children:y.children}),(d.mode&1)===0&&(y.lanes=p),y.return=d,y.sibling=null,l!==null&&(p=d.deletions,p===null?(d.deletions=[l],d.flags|=16):p.push(l)),d.child=y,d.memoizedState=null,y}function ox(l,d){return d=zh({mode:"visible",children:d},l.mode,0,null),d.return=l,l.child=d}function Ch(l,d,p,y){return y!==null&&Lm(y),Ec(d,l.child,null,p),l=ox(d,d.pendingProps.children),l.flags|=2,d.memoizedState=null,l}function k5(l,d,p,y,j,S,A){if(p)return d.flags&256?(d.flags&=-257,y=tx(Error(n(422))),Ch(l,d,A,y)):d.memoizedState!==null?(d.child=l.child,d.flags|=128,null):(S=y.fallback,j=d.mode,y=zh({mode:"visible",children:y.children},j,0,null),S=Tl(S,j,A,null),S.flags|=2,y.return=d,S.return=d,y.sibling=S,d.child=y,(d.mode&1)!==0&&Ec(d,l.child,null,A),d.child.memoizedState=ix(A),d.memoizedState=ax,S);if((d.mode&1)===0)return Ch(l,d,A,null);if(j.data==="$!"){if(y=j.nextSibling&&j.nextSibling.dataset,y)var K=y.dgst;return y=K,S=Error(n(419)),y=tx(S,y,void 0),Ch(l,d,A,y)}if(K=(A&l.childLanes)!==0,ir||K){if(y=ds,y!==null){switch(A&-A){case 4:j=2;break;case 16:j=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:j=32;break;case 536870912:j=268435456;break;default:j=0}j=(j&(y.suspendedLanes|A))!==0?0:j,j!==0&&j!==S.retryLane&&(S.retryLane=j,gi(l,j),fa(y,l,j,-1))}return jx(),y=tx(Error(n(421))),Ch(l,d,A,y)}return j.data==="$?"?(d.flags|=128,d.child=l.child,d=_5.bind(null,l),j._reactRetry=d,null):(l=S.treeContext,jr=so(j.nextSibling),wr=d,Nn=!0,ca=null,l!==null&&($r[zr++]=mi,$r[zr++]=xi,$r[zr++]=bl,mi=l.id,xi=l.overflow,bl=d),d=ox(d,y.children),d.flags|=4096,d)}function _v(l,d,p){l.lanes|=d;var y=l.alternate;y!==null&&(y.lanes|=d),$m(l.return,d,p)}function lx(l,d,p,y,j){var S=l.memoizedState;S===null?l.memoizedState={isBackwards:d,rendering:null,renderingStartTime:0,last:y,tail:p,tailMode:j}:(S.isBackwards=d,S.rendering=null,S.renderingStartTime=0,S.last=y,S.tail=p,S.tailMode=j)}function $v(l,d,p){var y=d.pendingProps,j=y.revealOrder,S=y.tail;if(Ws(l,d,y.children,p),y=Cn.current,(y&2)!==0)y=y&1|2,d.flags|=128;else{if(l!==null&&(l.flags&128)!==0)e:for(l=d.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&_v(l,p,d);else if(l.tag===19)_v(l,p,d);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===d)break e;for(;l.sibling===null;){if(l.return===null||l.return===d)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}y&=1}if(dn(Cn,y),(d.mode&1)===0)d.memoizedState=null;else switch(j){case"forwards":for(p=d.child,j=null;p!==null;)l=p.alternate,l!==null&&bh(l)===null&&(j=p),p=p.sibling;p=j,p===null?(j=d.child,d.child=null):(j=p.sibling,p.sibling=null),lx(d,!1,j,p,S);break;case"backwards":for(p=null,j=d.child,d.child=null;j!==null;){if(l=j.alternate,l!==null&&bh(l)===null){d.child=j;break}l=j.sibling,j.sibling=p,p=j,j=l}lx(d,!0,p,null,S);break;case"together":lx(d,!1,null,null,void 0);break;default:d.memoizedState=null}return d.child}function Eh(l,d){(d.mode&1)===0&&l!==null&&(l.alternate=null,d.alternate=null,d.flags|=2)}function bi(l,d,p){if(l!==null&&(d.dependencies=l.dependencies),kl|=d.lanes,(p&d.childLanes)===0)return null;if(l!==null&&d.child!==l.child)throw Error(n(153));if(d.child!==null){for(l=d.child,p=mo(l,l.pendingProps),d.child=p,p.return=d;l.sibling!==null;)l=l.sibling,p=p.sibling=mo(l,l.pendingProps),p.return=d;p.sibling=null}return d.child}function S5(l,d,p){switch(d.tag){case 3:Lv(d),Cc();break;case 5:Xb(d);break;case 1:ar(d.type)&&ch(d);break;case 4:Bm(d,d.stateNode.containerInfo);break;case 10:var y=d.type._context,j=d.memoizedProps.value;dn(mh,y._currentValue),y._currentValue=j;break;case 13:if(y=d.memoizedState,y!==null)return y.dehydrated!==null?(dn(Cn,Cn.current&1),d.flags|=128,null):(p&d.child.childLanes)!==0?Dv(l,d,p):(dn(Cn,Cn.current&1),l=bi(l,d,p),l!==null?l.sibling:null);dn(Cn,Cn.current&1);break;case 19:if(y=(p&d.childLanes)!==0,(l.flags&128)!==0){if(y)return $v(l,d,p);d.flags|=128}if(j=d.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),dn(Cn,Cn.current),y)break;return null;case 22:case 23:return d.lanes=0,Pv(l,d,p)}return bi(l,d,p)}var zv,cx,Fv,Bv;zv=function(l,d){for(var p=d.child;p!==null;){if(p.tag===5||p.tag===6)l.appendChild(p.stateNode);else if(p.tag!==4&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===d)break;for(;p.sibling===null;){if(p.return===null||p.return===d)return;p=p.return}p.sibling.return=p.return,p=p.sibling}},cx=function(){},Fv=function(l,d,p,y){var j=l.memoizedProps;if(j!==y){l=d.stateNode,wl(Da.current);var S=null;switch(p){case"input":j=wt(l,j),y=wt(l,y),S=[];break;case"select":j=X({},j,{value:void 0}),y=X({},y,{value:void 0}),S=[];break;case"textarea":j=bn(l,j),y=bn(l,y),S=[];break;default:typeof j.onClick!="function"&&typeof y.onClick=="function"&&(l.onclick=ih)}Qe(p,y);var A;p=null;for(ye in j)if(!y.hasOwnProperty(ye)&&j.hasOwnProperty(ye)&&j[ye]!=null)if(ye==="style"){var K=j[ye];for(A in K)K.hasOwnProperty(A)&&(p||(p={}),p[A]="")}else ye!=="dangerouslySetInnerHTML"&&ye!=="children"&&ye!=="suppressContentEditableWarning"&&ye!=="suppressHydrationWarning"&&ye!=="autoFocus"&&(a.hasOwnProperty(ye)?S||(S=[]):(S=S||[]).push(ye,null));for(ye in y){var se=y[ye];if(K=j!=null?j[ye]:void 0,y.hasOwnProperty(ye)&&se!==K&&(se!=null||K!=null))if(ye==="style")if(K){for(A in K)!K.hasOwnProperty(A)||se&&se.hasOwnProperty(A)||(p||(p={}),p[A]="");for(A in se)se.hasOwnProperty(A)&&K[A]!==se[A]&&(p||(p={}),p[A]=se[A])}else p||(S||(S=[]),S.push(ye,p)),p=se;else ye==="dangerouslySetInnerHTML"?(se=se?se.__html:void 0,K=K?K.__html:void 0,se!=null&&K!==se&&(S=S||[]).push(ye,se)):ye==="children"?typeof se!="string"&&typeof se!="number"||(S=S||[]).push(ye,""+se):ye!=="suppressContentEditableWarning"&&ye!=="suppressHydrationWarning"&&(a.hasOwnProperty(ye)?(se!=null&&ye==="onScroll"&&xn("scroll",l),S||K===se||(S=[])):(S=S||[]).push(ye,se))}p&&(S=S||[]).push("style",p);var ye=S;(d.updateQueue=ye)&&(d.flags|=4)}},Bv=function(l,d,p,y){p!==y&&(d.flags|=4)};function Jd(l,d){if(!Nn)switch(l.tailMode){case"hidden":d=l.tail;for(var p=null;d!==null;)d.alternate!==null&&(p=d),d=d.sibling;p===null?l.tail=null:p.sibling=null;break;case"collapsed":p=l.tail;for(var y=null;p!==null;)p.alternate!==null&&(y=p),p=p.sibling;y===null?d||l.tail===null?l.tail=null:l.tail.sibling=null:y.sibling=null}}function Os(l){var d=l.alternate!==null&&l.alternate.child===l.child,p=0,y=0;if(d)for(var j=l.child;j!==null;)p|=j.lanes|j.childLanes,y|=j.subtreeFlags&14680064,y|=j.flags&14680064,j.return=l,j=j.sibling;else for(j=l.child;j!==null;)p|=j.lanes|j.childLanes,y|=j.subtreeFlags,y|=j.flags,j.return=l,j=j.sibling;return l.subtreeFlags|=y,l.childLanes=p,d}function C5(l,d,p){var y=d.pendingProps;switch(Pm(d),d.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Os(d),null;case 1:return ar(d.type)&&lh(),Os(d),null;case 3:return y=d.stateNode,Ac(),gn(rr),gn(Rs),Um(),y.pendingContext&&(y.context=y.pendingContext,y.pendingContext=null),(l===null||l.child===null)&&(fh(d)?d.flags|=4:l===null||l.memoizedState.isDehydrated&&(d.flags&256)===0||(d.flags|=1024,ca!==null&&(vx(ca),ca=null))),cx(l,d),Os(d),null;case 5:Vm(d);var j=wl(Ud.current);if(p=d.type,l!==null&&d.stateNode!=null)Fv(l,d,p,y,j),l.ref!==d.ref&&(d.flags|=512,d.flags|=2097152);else{if(!y){if(d.stateNode===null)throw Error(n(166));return Os(d),null}if(l=wl(Da.current),fh(d)){y=d.stateNode,p=d.type;var S=d.memoizedProps;switch(y[Oa]=d,y[zd]=S,l=(d.mode&1)!==0,p){case"dialog":xn("cancel",y),xn("close",y);break;case"iframe":case"object":case"embed":xn("load",y);break;case"video":case"audio":for(j=0;j<\/script>",l=l.removeChild(l.firstChild)):typeof y.is=="string"?l=A.createElement(p,{is:y.is}):(l=A.createElement(p),p==="select"&&(A=l,y.multiple?A.multiple=!0:y.size&&(A.size=y.size))):l=A.createElementNS(l,p),l[Oa]=d,l[zd]=y,zv(l,d,!1,!1),d.stateNode=l;e:{switch(A=vt(p,y),p){case"dialog":xn("cancel",l),xn("close",l),j=y;break;case"iframe":case"object":case"embed":xn("load",l),j=y;break;case"video":case"audio":for(j=0;jLc&&(d.flags|=128,y=!0,Jd(S,!1),d.lanes=4194304)}else{if(!y)if(l=bh(A),l!==null){if(d.flags|=128,y=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),Jd(S,!0),S.tail===null&&S.tailMode==="hidden"&&!A.alternate&&!Nn)return Os(d),null}else 2*mn()-S.renderingStartTime>Lc&&p!==1073741824&&(d.flags|=128,y=!0,Jd(S,!1),d.lanes=4194304);S.isBackwards?(A.sibling=d.child,d.child=A):(p=S.last,p!==null?p.sibling=A:d.child=A,S.last=A)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=mn(),d.sibling=null,p=Cn.current,dn(Cn,y?p&1|2:p&1),d):(Os(d),null);case 22:case 23:return wx(),y=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==y&&(d.flags|=8192),y&&(d.mode&1)!==0?(kr&1073741824)!==0&&(Os(d),d.subtreeFlags&6&&(d.flags|=8192)):Os(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function E5(l,d){switch(Pm(d),d.tag){case 1:return ar(d.type)&&lh(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return Ac(),gn(rr),gn(Rs),Um(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return Vm(d),null;case 13:if(gn(Cn),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));Cc()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return gn(Cn),null;case 4:return Ac(),null;case 10:return _m(d.type._context),null;case 22:case 23:return wx(),null;case 24:return null;default:return null}}var Th=!1,Ds=!1,T5=typeof WeakSet=="function"?WeakSet:Set,Ye=null;function Ic(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(y){An(l,d,y)}else p.current=null}function dx(l,d,p){try{p()}catch(y){An(l,d,y)}}var Vv=!1;function M5(l,d){if(wm=Lr,l=vb(),pm(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var y=p.getSelection&&p.getSelection();if(y&&y.rangeCount!==0){p=y.anchorNode;var j=y.anchorOffset,S=y.focusNode;y=y.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var A=0,K=-1,se=-1,ye=0,Pe=0,Ie=l,Te=null;t:for(;;){for(var qe;Ie!==p||j!==0&&Ie.nodeType!==3||(K=A+j),Ie!==S||y!==0&&Ie.nodeType!==3||(se=A+y),Ie.nodeType===3&&(A+=Ie.nodeValue.length),(qe=Ie.firstChild)!==null;)Te=Ie,Ie=qe;for(;;){if(Ie===l)break t;if(Te===p&&++ye===j&&(K=A),Te===S&&++Pe===y&&(se=A),(qe=Ie.nextSibling)!==null)break;Ie=Te,Te=Ie.parentNode}Ie=qe}p=K===-1||se===-1?null:{start:K,end:se}}else p=null}p=p||{start:0,end:0}}else p=null;for(jm={focusedElem:l,selectionRange:p},Lr=!1,Ye=d;Ye!==null;)if(d=Ye,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,Ye=l;else for(;Ye!==null;){d=Ye;try{var Xe=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(Xe!==null){var tt=Xe.memoizedProps,zn=Xe.memoizedState,pe=d.stateNode,ie=pe.getSnapshotBeforeUpdate(d.elementType===d.type?tt:da(d.type,tt),zn);pe.__reactInternalSnapshotBeforeUpdate=ie}break;case 3:var ge=d.stateNode.containerInfo;ge.nodeType===1?ge.textContent="":ge.nodeType===9&&ge.documentElement&&ge.removeChild(ge.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Oe){An(d,d.return,Oe)}if(l=d.sibling,l!==null){l.return=d.return,Ye=l;break}Ye=d.return}return Xe=Vv,Vv=!1,Xe}function Qd(l,d,p){var y=d.updateQueue;if(y=y!==null?y.lastEffect:null,y!==null){var j=y=y.next;do{if((j.tag&l)===l){var S=j.destroy;j.destroy=void 0,S!==void 0&&dx(d,p,S)}j=j.next}while(j!==y)}}function Mh(l,d){if(d=d.updateQueue,d=d!==null?d.lastEffect:null,d!==null){var p=d=d.next;do{if((p.tag&l)===l){var y=p.create;p.destroy=y()}p=p.next}while(p!==d)}}function ux(l){var d=l.ref;if(d!==null){var p=l.stateNode;switch(l.tag){case 5:l=p;break;default:l=p}typeof d=="function"?d(l):d.current=l}}function Hv(l){var d=l.alternate;d!==null&&(l.alternate=null,Hv(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[Oa],delete d[zd],delete d[Em],delete d[u5],delete d[h5])),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function Uv(l){return l.tag===5||l.tag===3||l.tag===4}function Wv(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||Uv(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function hx(l,d,p){var y=l.tag;if(y===5||y===6)l=l.stateNode,d?p.nodeType===8?p.parentNode.insertBefore(l,d):p.insertBefore(l,d):(p.nodeType===8?(d=p.parentNode,d.insertBefore(l,p)):(d=p,d.appendChild(l)),p=p._reactRootContainer,p!=null||d.onclick!==null||(d.onclick=ih));else if(y!==4&&(l=l.child,l!==null))for(hx(l,d,p),l=l.sibling;l!==null;)hx(l,d,p),l=l.sibling}function fx(l,d,p){var y=l.tag;if(y===5||y===6)l=l.stateNode,d?p.insertBefore(l,d):p.appendChild(l);else if(y!==4&&(l=l.child,l!==null))for(fx(l,d,p),l=l.sibling;l!==null;)fx(l,d,p),l=l.sibling}var ws=null,ua=!1;function co(l,d,p){for(p=p.child;p!==null;)Kv(l,d,p),p=p.sibling}function Kv(l,d,p){if(Zs&&typeof Zs.onCommitFiberUnmount=="function")try{Zs.onCommitFiberUnmount(Xs,p)}catch{}switch(p.tag){case 5:Ds||Ic(p,d);case 6:var y=ws,j=ua;ws=null,co(l,d,p),ws=y,ua=j,ws!==null&&(ua?(l=ws,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):ws.removeChild(p.stateNode));break;case 18:ws!==null&&(ua?(l=ws,p=p.stateNode,l.nodeType===8?Cm(l.parentNode,p):l.nodeType===1&&Cm(l,p),Ia(l)):Cm(ws,p.stateNode));break;case 4:y=ws,j=ua,ws=p.stateNode.containerInfo,ua=!0,co(l,d,p),ws=y,ua=j;break;case 0:case 11:case 14:case 15:if(!Ds&&(y=p.updateQueue,y!==null&&(y=y.lastEffect,y!==null))){j=y=y.next;do{var S=j,A=S.destroy;S=S.tag,A!==void 0&&((S&2)!==0||(S&4)!==0)&&dx(p,d,A),j=j.next}while(j!==y)}co(l,d,p);break;case 1:if(!Ds&&(Ic(p,d),y=p.stateNode,typeof y.componentWillUnmount=="function"))try{y.props=p.memoizedProps,y.state=p.memoizedState,y.componentWillUnmount()}catch(K){An(p,d,K)}co(l,d,p);break;case 21:co(l,d,p);break;case 22:p.mode&1?(Ds=(y=Ds)||p.memoizedState!==null,co(l,d,p),Ds=y):co(l,d,p);break;default:co(l,d,p)}}function qv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new T5),d.forEach(function(y){var j=$5.bind(null,l,y);p.has(y)||(p.add(y),y.then(j,j))})}}function ha(l,d){var p=d.deletions;if(p!==null)for(var y=0;yj&&(j=A),y&=~S}if(y=j,y=mn()-y,y=(120>y?120:480>y?480:1080>y?1080:1920>y?1920:3e3>y?3e3:4320>y?4320:1960*P5(y/1960))-y,10l?16:l,ho===null)var y=!1;else{if(l=ho,ho=null,Lh=0,(Bt&6)!==0)throw Error(n(331));var j=Bt;for(Bt|=4,Ye=l.current;Ye!==null;){var S=Ye,A=S.child;if((Ye.flags&16)!==0){var K=S.deletions;if(K!==null){for(var se=0;semn()-xx?Cl(l,0):mx|=p),lr(l,d)}function i1(l,d){d===0&&((l.mode&1)===0?d=1:(d=tr,tr<<=1,(tr&130023424)===0&&(tr=4194304)));var p=Ks();l=gi(l,d),l!==null&&(Ea(l,d,p),lr(l,p))}function _5(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),i1(l,p)}function $5(l,d){var p=0;switch(l.tag){case 13:var y=l.stateNode,j=l.memoizedState;j!==null&&(p=j.retryLane);break;case 19:y=l.stateNode;break;default:throw Error(n(314))}y!==null&&y.delete(d),i1(l,p)}var o1;o1=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||rr.current)ir=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return ir=!1,S5(l,d,p);ir=(l.flags&131072)!==0}else ir=!1,Nn&&(d.flags&1048576)!==0&&Fb(d,hh,d.index);switch(d.lanes=0,d.tag){case 2:var y=d.type;Eh(l,d),l=d.pendingProps;var j=jc(d,Rs.current);Mc(d,p),j=qm(null,d,y,l,j,p);var S=Gm();return d.flags|=1,typeof j=="object"&&j!==null&&typeof j.render=="function"&&j.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,ar(y)?(S=!0,ch(d)):S=!1,d.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,Fm(d),j.updater=Sh,d.stateNode=j,j._reactInternals=d,ex(d,y,l,p),d=rx(null,d,y,!0,S,p)):(d.tag=0,Nn&&S&&Am(d),Ws(null,d,j,p),d=d.child),d;case 16:y=d.elementType;e:{switch(Eh(l,d),l=d.pendingProps,j=y._init,y=j(y._payload),d.type=y,j=d.tag=F5(y),l=da(y,l),j){case 0:d=sx(null,d,y,l,p);break e;case 1:d=Rv(null,d,y,l,p);break e;case 11:d=Tv(null,d,y,l,p);break e;case 14:d=Mv(null,d,y,da(y.type,l),p);break e}throw Error(n(306,y,""))}return d;case 0:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:da(y,j),sx(l,d,y,j,p);case 1:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:da(y,j),Rv(l,d,y,j,p);case 3:e:{if(Lv(d),l===null)throw Error(n(387));y=d.pendingProps,S=d.memoizedState,j=S.element,Jb(l,d),yh(d,y,null,p);var A=d.memoizedState;if(y=A.element,S.isDehydrated)if(S={element:y,isDehydrated:!1,cache:A.cache,pendingSuspenseBoundaries:A.pendingSuspenseBoundaries,transitions:A.transitions},d.updateQueue.baseState=S,d.memoizedState=S,d.flags&256){j=Pc(Error(n(423)),d),d=Ov(l,d,y,p,j);break e}else if(y!==j){j=Pc(Error(n(424)),d),d=Ov(l,d,y,p,j);break e}else for(jr=so(d.stateNode.containerInfo.firstChild),wr=d,Nn=!0,ca=null,p=qb(d,null,y,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Cc(),y===j){d=bi(l,d,p);break e}Ws(l,d,y,p)}d=d.child}return d;case 5:return Xb(d),l===null&&Rm(d),y=d.type,j=d.pendingProps,S=l!==null?l.memoizedProps:null,A=j.children,km(y,j)?A=null:S!==null&&km(y,S)&&(d.flags|=32),Iv(l,d),Ws(l,d,A,p),d.child;case 6:return l===null&&Rm(d),null;case 13:return Dv(l,d,p);case 4:return Bm(d,d.stateNode.containerInfo),y=d.pendingProps,l===null?d.child=Ec(d,null,y,p):Ws(l,d,y,p),d.child;case 11:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:da(y,j),Tv(l,d,y,j,p);case 7:return Ws(l,d,d.pendingProps,p),d.child;case 8:return Ws(l,d,d.pendingProps.children,p),d.child;case 12:return Ws(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(y=d.type._context,j=d.pendingProps,S=d.memoizedProps,A=j.value,dn(mh,y._currentValue),y._currentValue=A,S!==null)if(la(S.value,A)){if(S.children===j.children&&!rr.current){d=bi(l,d,p);break e}}else for(S=d.child,S!==null&&(S.return=d);S!==null;){var K=S.dependencies;if(K!==null){A=S.child;for(var se=K.firstContext;se!==null;){if(se.context===y){if(S.tag===1){se=yi(-1,p&-p),se.tag=2;var ye=S.updateQueue;if(ye!==null){ye=ye.shared;var Pe=ye.pending;Pe===null?se.next=se:(se.next=Pe.next,Pe.next=se),ye.pending=se}}S.lanes|=p,se=S.alternate,se!==null&&(se.lanes|=p),$m(S.return,p,d),K.lanes|=p;break}se=se.next}}else if(S.tag===10)A=S.type===d.type?null:S.child;else if(S.tag===18){if(A=S.return,A===null)throw Error(n(341));A.lanes|=p,K=A.alternate,K!==null&&(K.lanes|=p),$m(A,p,d),A=S.sibling}else A=S.child;if(A!==null)A.return=S;else for(A=S;A!==null;){if(A===d){A=null;break}if(S=A.sibling,S!==null){S.return=A.return,A=S;break}A=A.return}S=A}Ws(l,d,j.children,p),d=d.child}return d;case 9:return j=d.type,y=d.pendingProps.children,Mc(d,p),j=Fr(j),y=y(j),d.flags|=1,Ws(l,d,y,p),d.child;case 14:return y=d.type,j=da(y,d.pendingProps),j=da(y.type,j),Mv(l,d,y,j,p);case 15:return Av(l,d,d.type,d.pendingProps,p);case 17:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:da(y,j),Eh(l,d),d.tag=1,ar(y)?(l=!0,ch(d)):l=!1,Mc(d,p),Nv(d,y,j),ex(d,y,j,p),rx(null,d,y,!0,l,p);case 19:return $v(l,d,p);case 22:return Pv(l,d,p)}throw Error(n(156,d.tag))};function l1(l,d){return jt(l,d)}function z5(l,d,p,y){this.tag=l,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=d,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Hr(l,d,p,y){return new z5(l,d,p,y)}function kx(l){return l=l.prototype,!(!l||!l.isReactComponent)}function F5(l){if(typeof l=="function")return kx(l)?1:0;if(l!=null){if(l=l.$$typeof,l===D)return 11;if(l===me)return 14}return 2}function mo(l,d){var p=l.alternate;return p===null?(p=Hr(l.tag,d,l.key,l.mode),p.elementType=l.elementType,p.type=l.type,p.stateNode=l.stateNode,p.alternate=l,l.alternate=p):(p.pendingProps=d,p.type=l.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=l.flags&14680064,p.childLanes=l.childLanes,p.lanes=l.lanes,p.child=l.child,p.memoizedProps=l.memoizedProps,p.memoizedState=l.memoizedState,p.updateQueue=l.updateQueue,d=l.dependencies,p.dependencies=d===null?null:{lanes:d.lanes,firstContext:d.firstContext},p.sibling=l.sibling,p.index=l.index,p.ref=l.ref,p}function $h(l,d,p,y,j,S){var A=2;if(y=l,typeof l=="function")kx(l)&&(A=1);else if(typeof l=="string")A=5;else e:switch(l){case P:return Tl(p.children,j,S,d);case F:A=8,j|=8;break;case O:return l=Hr(12,p,d,j|2),l.elementType=O,l.lanes=S,l;case ne:return l=Hr(13,p,d,j),l.elementType=ne,l.lanes=S,l;case le:return l=Hr(19,p,d,j),l.elementType=le,l.lanes=S,l;case Y:return zh(p,j,S,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case Q:A=10;break e;case re:A=9;break e;case D:A=11;break e;case me:A=14;break e;case I:A=16,y=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=Hr(A,p,d,j),d.elementType=l,d.type=y,d.lanes=S,d}function Tl(l,d,p,y){return l=Hr(7,l,y,d),l.lanes=p,l}function zh(l,d,p,y){return l=Hr(22,l,y,d),l.elementType=Y,l.lanes=p,l.stateNode={isHidden:!1},l}function Sx(l,d,p){return l=Hr(6,l,null,d),l.lanes=p,l}function Cx(l,d,p){return d=Hr(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function B5(l,d,p,y,j){this.tag=d,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Qi(0),this.expirationTimes=Qi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qi(0),this.identifierPrefix=y,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function Ex(l,d,p,y,j,S,A,K,se){return l=new B5(l,d,p,K,se),d===1?(d=1,S===!0&&(d|=8)):d=0,S=Hr(3,null,null,d),l.current=S,S.stateNode=l,S.memoizedState={element:y,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Fm(S),l}function V5(l,d,p){var y=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Rx.exports=eE(),Rx.exports}var w1;function tE(){if(w1)return Kh;w1=1;var t=Fj();return Kh.createRoot=t.createRoot,Kh.hydrateRoot=t.hydrateRoot,Kh}var nE=tE(),hd=Fj();const Bj=zj(hd);/**
* @remix-run/router v1.23.2
*
* Copyright (c) Remix Software Inc.
@@ -544,7 +544,7 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const LA=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],ts=Ee("trash-2",LA);/**
+ */const LA=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],ns=Ee("trash-2",LA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -584,7 +584,7 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const HA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Kn=Ee("users",HA);/**
+ */const HA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],qn=Ee("users",HA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
@@ -604,12 +604,12 @@ Error generating stack: `+S.message+`
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const JA=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ns=Ee("x",JA);/**
+ */const JA=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ss=Ee("x",JA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
- */const QA=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Ho=Ee("zap",QA),ey="admin_token";function Ku(){try{return localStorage.getItem(ey)}catch{return null}}function YA(t){try{localStorage.setItem(ey,t)}catch{}}function zx(){try{localStorage.removeItem(ey)}catch{}}const XA="https://soulapi.quwanzhi.com",ZA=15e3,F1=6e4,eP=()=>{const t="https://soulapi.quwanzhi.com";{const e=t.trim();if(e.length>0)return e.replace(/\/$/,"")}return XA};function Vl(t){const e=eP(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function $p(t,e={}){const{data:n,...r}=e,a=Vl(t),i=new Headers(r.headers),o=Ku();o&&i.set("Authorization",`Bearer ${o}`),n!=null&&!i.has("Content-Type")&&i.set("Content-Type","application/json");const c=n!=null?JSON.stringify(n):r.body,u=r.timeout??ZA,h=new AbortController,f=setTimeout(()=>h.abort(),u),m=await fetch(a,{...r,headers:i,body:c,credentials:"include",signal:h.signal}).finally(()=>clearTimeout(f)),x=m.headers.get("Content-Type")||"";let b;if(x.includes("application/json"))try{b=await m.json()}catch{throw new Error(`API 响应解析失败 (${m.status})`)}else{const w=await m.text();throw new Error(`API 返回非 JSON 响应 (${m.status}): ${w.slice(0,100)}`)}const N=w=>{const v=w,k=((v==null?void 0:v.message)||(v==null?void 0:v.error)||"").toString();(k.includes("可提现金额不足")||k.includes("可提现不足")||k.includes("余额不足"))&&window.dispatchEvent(new CustomEvent("recharge-alert",{detail:k}))};if(!m.ok){N(b);const w=new Error((b==null?void 0:b.error)||`HTTP ${m.status}`);throw w.status=m.status,w.data=b,w}return N(b),b}function Le(t,e){return $p(t,{...e,method:"GET"})}function bt(t,e,n){return $p(t,{...n,method:"POST",data:e})}function tn(t,e,n){return $p(t,{...n,method:"PUT",data:e})}function Pi(t,e){return $p(t,{...e,method:"DELETE"})}function tP(){const[t,e]=g.useState(!1),[n,r]=g.useState("");return g.useEffect(()=>{const a=i=>{const o=i.detail;r(o||"可提现/余额不足,请及时充值商户号"),e(!0)};return window.addEventListener("recharge-alert",a),()=>window.removeEventListener("recharge-alert",a)},[]),t?s.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-3 bg-red-900/80 border-b border-red-600/50 text-red-100",role:"alert",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(Xj,{className:"w-5 h-5 shrink-0 text-red-400"}),s.jsxs("span",{className:"text-sm font-medium",children:[n,s.jsx("span",{className:"ml-2 text-red-300",children:"请及时充值商户号或核对账户后重试。"})]})]}),s.jsx("button",{type:"button",onClick:()=>e(!1),className:"shrink-0 p-1 rounded hover:bg-red-800/50 transition-colors","aria-label":"关闭告警",children:s.jsx(ns,{className:"w-4 h-4"})})]}):null}const nP=[{icon:EM,label:"数据概览",href:"/dashboard"},{icon:ur,label:"内容管理",href:"/content"},{icon:Kn,label:"用户管理",href:"/users"},{icon:aM,label:"找伙伴",href:"/find-partner"},{icon:sd,label:"推广中心",href:"/distribution"}];function sP(){const t=Xo(),e=g.useRef(t.pathname);e.current=t.pathname;const n=Ya(),[r,a]=g.useState(!1),[i,o]=g.useState(!1);g.useEffect(()=>{a(!0)},[]),g.useEffect(()=>{if(!r)return;let u=!1;if(!Ku()){n("/login",{replace:!0});return}return Le("/api/admin").then(h=>{u||(h&&h.success!==!1?o(!0):(zx(),n("/login",{replace:!0,state:{from:e.current}})))}).catch(()=>{u||(zx(),n("/login",{replace:!0,state:{from:e.current}}))}),()=>{u=!0}},[r,n]);const c=async()=>{zx();try{await bt("/api/admin/logout",{})}catch{}n("/login",{replace:!0})};return!r||!i?s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsx("div",{className:"w-64 bg-[#0f2137] border-r border-gray-700/50"}),s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("div",{className:"text-[#38bdac]",children:"加载中..."})})]}):s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsxs("div",{className:"w-64 bg-[#0f2137] flex flex-col border-r border-gray-700/50 shadow-xl",children:[s.jsxs("div",{className:"p-6 border-b border-gray-700/50",children:[s.jsx("h1",{className:"text-xl font-bold text-[#38bdac]",children:"管理后台"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Soul创业派对"})]}),s.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[nP.map(u=>{const h=t.pathname===u.href;return s.jsxs(_i,{to:u.href,className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${h?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[s.jsx(u.icon,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:u.label})]},u.href)}),s.jsxs("div",{className:"pt-4 mt-4 border-t border-gray-700/50 space-y-1",children:[s.jsxs(_i,{to:"/settings",className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${t.pathname==="/settings"?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[s.jsx(Po,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:"系统设置"})]}),s.jsxs(_i,{to:"/open-platform",className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${t.pathname==="/open-platform"?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[s.jsx(QT,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:"API开放平台"})]})]})]}),s.jsx("div",{className:"p-4 border-t border-gray-700/50 space-y-1",children:s.jsxs("button",{type:"button",onClick:c,className:"w-full flex items-center gap-3 px-4 py-3 text-gray-400 hover:text-white rounded-lg hover:bg-gray-700/50 transition-colors",children:[s.jsx($M,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm",children:"退出登录"})]})})]}),s.jsxs("div",{className:"flex-1 overflow-auto bg-[#0a1628] min-w-0 flex flex-col",children:[s.jsx(tP,{}),s.jsx("div",{className:"w-full min-w-0 min-h-full flex-1",children:s.jsx(JE,{})})]})]})}function B1(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function ty(...t){return e=>{let n=!1;const r=t.map(a=>{const i=B1(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a{let{children:i,...o}=r;ck(i)&&typeof _f=="function"&&(i=_f(i._payload));const c=g.Children.toArray(i),u=c.find(lP);if(u){const h=u.props.children,f=c.map(m=>m===u?g.Children.count(h)>1?g.Children.only(null):g.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:a,children:g.isValidElement(h)?g.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}var uk=dk("Slot");function iP(t){const e=g.forwardRef((n,r)=>{let{children:a,...i}=n;if(ck(a)&&typeof _f=="function"&&(a=_f(a._payload)),g.isValidElement(a)){const o=dP(a),c=cP(i,a.props);return a.type!==g.Fragment&&(c.ref=r?ty(r,o):o),g.cloneElement(a,c)}return g.Children.count(a)>1?g.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var oP=Symbol("radix.slottable");function lP(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===oP}function cP(t,e){const n={...e};for(const r in e){const a=t[r],i=e[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function dP(t){var r,a;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function hk(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(e=0;etypeof t=="boolean"?`${t}`:t===0?"0":t,H1=fk,pk=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return H1(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:a,defaultVariants:i}=e,o=Object.keys(a).map(h=>{const f=n==null?void 0:n[h],m=i==null?void 0:i[h];if(f===null)return null;const x=V1(f)||V1(m);return a[h][x]}),c=n&&Object.entries(n).reduce((h,f)=>{let[m,x]=f;return x===void 0||(h[m]=x),h},{}),u=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((h,f)=>{let{class:m,className:x,...b}=f;return Object.entries(b).every(N=>{let[w,v]=N;return Array.isArray(v)?v.includes({...i,...c}[w]):{...i,...c}[w]===v})?[...h,m,x]:h},[]);return H1(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},uP=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r({classGroupId:t,validator:e}),mk=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),$f="-",U1=[],fP="arbitrary..",pP=t=>{const e=xP(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return mP(o);const c=o.split($f),u=c[0]===""&&c.length>1?1:0;return xk(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=r[o],h=n[o];return u?h?uP(h,u):u:h||U1}return n[o]||U1}}},xk=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const a=t[e],i=n.nextPart.get(a);if(i){const h=xk(t,e+1,i);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join($f):t.slice(e).join($f),u=o.length;for(let h=0;ht.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),r=e.slice(0,n);return r?fP+r:void 0})(),xP=t=>{const{theme:e,classGroups:n}=t;return gP(n,e)},gP=(t,e)=>{const n=mk();for(const r in t){const a=t[r];ny(a,n,r,e)}return n},ny=(t,e,n,r)=>{const a=t.length;for(let i=0;i{if(typeof t=="string"){bP(t,e,n);return}if(typeof t=="function"){vP(t,e,n,r);return}NP(t,e,n,r)},bP=(t,e,n)=>{const r=t===""?e:gk(e,t);r.classGroupId=n},vP=(t,e,n,r)=>{if(wP(t)){ny(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(hP(n,t))},NP=(t,e,n,r)=>{const a=Object.entries(t),i=a.length;for(let o=0;o{let n=t;const r=e.split($f),a=r.length;for(let i=0;i"isThemeGetter"in t&&t.isThemeGetter===!0,jP=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),r=Object.create(null);const a=(i,o)=>{n[i]=o,e++,e>t&&(e=0,r=n,n=Object.create(null))};return{get(i){let o=n[i];if(o!==void 0)return o;if((o=r[i])!==void 0)return a(i,o),o},set(i,o){i in n?n[i]=o:a(i,o)}}},Gg="!",W1=":",kP=[],K1=(t,e,n,r,a)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:a}),SP=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=a=>{const i=[];let o=0,c=0,u=0,h;const f=a.length;for(let w=0;wu?h-u:void 0;return K1(i,b,x,N)};if(e){const a=e+W1,i=r;r=o=>o.startsWith(a)?i(o.slice(a.length)):K1(kP,!1,o,void 0,!0)}if(n){const a=r;r=i=>n({className:i,parseClassName:a})}return r},CP=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,r)=>{e.set(n,1e6+r)}),n=>{const r=[];let a=[];for(let i=0;i0&&(a.sort(),r.push(...a),a=[]),r.push(o)):a.push(o)}return a.length>0&&(a.sort(),r.push(...a)),r}},EP=t=>({cache:jP(t.cacheSize),parseClassName:SP(t),sortModifiers:CP(t),...pP(t)}),TP=/\s+/,MP=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:i}=e,o=[],c=t.trim().split(TP);let u="";for(let h=c.length-1;h>=0;h-=1){const f=c[h],{isExternal:m,modifiers:x,hasImportantModifier:b,baseClassName:N,maybePostfixModifierPosition:w}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let v=!!w,k=r(v?N.substring(0,w):N);if(!k){if(!v){u=f+(u.length>0?" "+u:u);continue}if(k=r(N),!k){u=f+(u.length>0?" "+u:u);continue}v=!1}const T=x.length===0?"":x.length===1?x[0]:i(x).join(":"),C=b?T+Gg:T,L=C+k;if(o.indexOf(L)>-1)continue;o.push(L);const R=a(k,v);for(let U=0;U0?" "+u:u)}return u},AP=(...t)=>{let e=0,n,r,a="";for(;e{if(typeof t=="string")return t;let e,n="";for(let r=0;r{let n,r,a,i;const o=u=>{const h=e.reduce((f,m)=>m(f),t());return n=EP(h),r=n.cache.get,a=n.cache.set,i=c,c(u)},c=u=>{const h=r(u);if(h)return h;const f=MP(u,n);return a(u,f),f};return i=o,(...u)=>i(AP(...u))},IP=[],es=t=>{const e=n=>n[t]||IP;return e.isThemeGetter=!0,e},bk=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,vk=/^\((?:(\w[\w-]*):)?(.+)\)$/i,RP=/^\d+\/\d+$/,LP=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,OP=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,DP=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,_P=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,$P=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Dc=t=>RP.test(t),Ct=t=>!!t&&!Number.isNaN(Number(t)),go=t=>!!t&&Number.isInteger(Number(t)),Fx=t=>t.endsWith("%")&&Ct(t.slice(0,-1)),wi=t=>LP.test(t),zP=()=>!0,FP=t=>OP.test(t)&&!DP.test(t),Nk=()=>!1,BP=t=>_P.test(t),VP=t=>$P.test(t),HP=t=>!Ze(t)&&!et(t),UP=t=>md(t,kk,Nk),Ze=t=>bk.test(t),Ml=t=>md(t,Sk,FP),Bx=t=>md(t,JP,Ct),q1=t=>md(t,wk,Nk),WP=t=>md(t,jk,VP),Yh=t=>md(t,Ck,BP),et=t=>vk.test(t),su=t=>xd(t,Sk),KP=t=>xd(t,QP),G1=t=>xd(t,wk),qP=t=>xd(t,kk),GP=t=>xd(t,jk),Xh=t=>xd(t,Ck,!0),md=(t,e,n)=>{const r=bk.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},xd=(t,e,n=!1)=>{const r=vk.exec(t);return r?r[1]?e(r[1]):n:!1},wk=t=>t==="position"||t==="percentage",jk=t=>t==="image"||t==="url",kk=t=>t==="length"||t==="size"||t==="bg-size",Sk=t=>t==="length",JP=t=>t==="number",QP=t=>t==="family-name",Ck=t=>t==="shadow",YP=()=>{const t=es("color"),e=es("font"),n=es("text"),r=es("font-weight"),a=es("tracking"),i=es("leading"),o=es("breakpoint"),c=es("container"),u=es("spacing"),h=es("radius"),f=es("shadow"),m=es("inset-shadow"),x=es("text-shadow"),b=es("drop-shadow"),N=es("blur"),w=es("perspective"),v=es("aspect"),k=es("ease"),T=es("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],L=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],R=()=>[...L(),et,Ze],U=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto","contain","none"],z=()=>[et,Ze,u],O=()=>[Dc,"full","auto",...z()],Q=()=>[go,"none","subgrid",et,Ze],re=()=>["auto",{span:["full",go,et,Ze]},go,et,Ze],D=()=>[go,"auto",et,Ze],ne=()=>["auto","min","max","fr",et,Ze],le=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],me=()=>["start","end","center","stretch","center-safe","end-safe"],I=()=>["auto",...z()],Y=()=>[Dc,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...z()],F=()=>[t,et,Ze],xe=()=>[...L(),G1,q1,{position:[et,Ze]}],X=()=>["no-repeat",{repeat:["","x","y","space","round"]}],V=()=>["auto","cover","contain",qP,UP,{size:[et,Ze]}],W=()=>[Fx,su,Ml],fe=()=>["","none","full",h,et,Ze],he=()=>["",Ct,su,Ml],de=()=>["solid","dashed","dotted","double"],_=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],J=()=>[Ct,Fx,G1,q1],$=()=>["","none",N,et,Ze],Z=()=>["none",Ct,et,Ze],ae=()=>["none",Ct,et,Ze],we=()=>[Ct,et,Ze],Fe=()=>[Dc,"full",...z()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[wi],breakpoint:[wi],color:[zP],container:[wi],"drop-shadow":[wi],ease:["in","out","in-out"],font:[HP],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[wi],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[wi],shadow:[wi],spacing:["px",Ct],text:[wi],"text-shadow":[wi],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Dc,Ze,et,v]}],container:["container"],columns:[{columns:[Ct,Ze,et,c]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:R()}],overflow:[{overflow:U()}],"overflow-x":[{"overflow-x":U()}],"overflow-y":[{"overflow-y":U()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:O()}],"inset-x":[{"inset-x":O()}],"inset-y":[{"inset-y":O()}],start:[{start:O()}],end:[{end:O()}],top:[{top:O()}],right:[{right:O()}],bottom:[{bottom:O()}],left:[{left:O()}],visibility:["visible","invisible","collapse"],z:[{z:[go,"auto",et,Ze]}],basis:[{basis:[Dc,"full","auto",c,...z()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ct,Dc,"auto","initial","none",Ze]}],grow:[{grow:["",Ct,et,Ze]}],shrink:[{shrink:["",Ct,et,Ze]}],order:[{order:[go,"first","last","none",et,Ze]}],"grid-cols":[{"grid-cols":Q()}],"col-start-end":[{col:re()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":Q()}],"row-start-end":[{row:re()}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ne()}],"auto-rows":[{"auto-rows":ne()}],gap:[{gap:z()}],"gap-x":[{"gap-x":z()}],"gap-y":[{"gap-y":z()}],"justify-content":[{justify:[...le(),"normal"]}],"justify-items":[{"justify-items":[...me(),"normal"]}],"justify-self":[{"justify-self":["auto",...me()]}],"align-content":[{content:["normal",...le()]}],"align-items":[{items:[...me(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...me(),{baseline:["","last"]}]}],"place-content":[{"place-content":le()}],"place-items":[{"place-items":[...me(),"baseline"]}],"place-self":[{"place-self":["auto",...me()]}],p:[{p:z()}],px:[{px:z()}],py:[{py:z()}],ps:[{ps:z()}],pe:[{pe:z()}],pt:[{pt:z()}],pr:[{pr:z()}],pb:[{pb:z()}],pl:[{pl:z()}],m:[{m:I()}],mx:[{mx:I()}],my:[{my:I()}],ms:[{ms:I()}],me:[{me:I()}],mt:[{mt:I()}],mr:[{mr:I()}],mb:[{mb:I()}],ml:[{ml:I()}],"space-x":[{"space-x":z()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":z()}],"space-y-reverse":["space-y-reverse"],size:[{size:Y()}],w:[{w:[c,"screen",...Y()]}],"min-w":[{"min-w":[c,"screen","none",...Y()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...Y()]}],h:[{h:["screen","lh",...Y()]}],"min-h":[{"min-h":["screen","lh","none",...Y()]}],"max-h":[{"max-h":["screen","lh",...Y()]}],"font-size":[{text:["base",n,su,Ml]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,et,Bx]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Fx,Ze]}],"font-family":[{font:[KP,Ze,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,et,Ze]}],"line-clamp":[{"line-clamp":[Ct,"none",et,Bx]}],leading:[{leading:[i,...z()]}],"list-image":[{"list-image":["none",et,Ze]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",et,Ze]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:F()}],"text-color":[{text:F()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...de(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ct,"from-font","auto",et,Ml]}],"text-decoration-color":[{decoration:F()}],"underline-offset":[{"underline-offset":[Ct,"auto",et,Ze]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:z()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",et,Ze]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",et,Ze]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:xe()}],"bg-repeat":[{bg:X()}],"bg-size":[{bg:V()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},go,et,Ze],radial:["",et,Ze],conic:[go,et,Ze]},GP,WP]}],"bg-color":[{bg:F()}],"gradient-from-pos":[{from:W()}],"gradient-via-pos":[{via:W()}],"gradient-to-pos":[{to:W()}],"gradient-from":[{from:F()}],"gradient-via":[{via:F()}],"gradient-to":[{to:F()}],rounded:[{rounded:fe()}],"rounded-s":[{"rounded-s":fe()}],"rounded-e":[{"rounded-e":fe()}],"rounded-t":[{"rounded-t":fe()}],"rounded-r":[{"rounded-r":fe()}],"rounded-b":[{"rounded-b":fe()}],"rounded-l":[{"rounded-l":fe()}],"rounded-ss":[{"rounded-ss":fe()}],"rounded-se":[{"rounded-se":fe()}],"rounded-ee":[{"rounded-ee":fe()}],"rounded-es":[{"rounded-es":fe()}],"rounded-tl":[{"rounded-tl":fe()}],"rounded-tr":[{"rounded-tr":fe()}],"rounded-br":[{"rounded-br":fe()}],"rounded-bl":[{"rounded-bl":fe()}],"border-w":[{border:he()}],"border-w-x":[{"border-x":he()}],"border-w-y":[{"border-y":he()}],"border-w-s":[{"border-s":he()}],"border-w-e":[{"border-e":he()}],"border-w-t":[{"border-t":he()}],"border-w-r":[{"border-r":he()}],"border-w-b":[{"border-b":he()}],"border-w-l":[{"border-l":he()}],"divide-x":[{"divide-x":he()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":he()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...de(),"hidden","none"]}],"divide-style":[{divide:[...de(),"hidden","none"]}],"border-color":[{border:F()}],"border-color-x":[{"border-x":F()}],"border-color-y":[{"border-y":F()}],"border-color-s":[{"border-s":F()}],"border-color-e":[{"border-e":F()}],"border-color-t":[{"border-t":F()}],"border-color-r":[{"border-r":F()}],"border-color-b":[{"border-b":F()}],"border-color-l":[{"border-l":F()}],"divide-color":[{divide:F()}],"outline-style":[{outline:[...de(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ct,et,Ze]}],"outline-w":[{outline:["",Ct,su,Ml]}],"outline-color":[{outline:F()}],shadow:[{shadow:["","none",f,Xh,Yh]}],"shadow-color":[{shadow:F()}],"inset-shadow":[{"inset-shadow":["none",m,Xh,Yh]}],"inset-shadow-color":[{"inset-shadow":F()}],"ring-w":[{ring:he()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:F()}],"ring-offset-w":[{"ring-offset":[Ct,Ml]}],"ring-offset-color":[{"ring-offset":F()}],"inset-ring-w":[{"inset-ring":he()}],"inset-ring-color":[{"inset-ring":F()}],"text-shadow":[{"text-shadow":["none",x,Xh,Yh]}],"text-shadow-color":[{"text-shadow":F()}],opacity:[{opacity:[Ct,et,Ze]}],"mix-blend":[{"mix-blend":[..._(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":_()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ct]}],"mask-image-linear-from-pos":[{"mask-linear-from":J()}],"mask-image-linear-to-pos":[{"mask-linear-to":J()}],"mask-image-linear-from-color":[{"mask-linear-from":F()}],"mask-image-linear-to-color":[{"mask-linear-to":F()}],"mask-image-t-from-pos":[{"mask-t-from":J()}],"mask-image-t-to-pos":[{"mask-t-to":J()}],"mask-image-t-from-color":[{"mask-t-from":F()}],"mask-image-t-to-color":[{"mask-t-to":F()}],"mask-image-r-from-pos":[{"mask-r-from":J()}],"mask-image-r-to-pos":[{"mask-r-to":J()}],"mask-image-r-from-color":[{"mask-r-from":F()}],"mask-image-r-to-color":[{"mask-r-to":F()}],"mask-image-b-from-pos":[{"mask-b-from":J()}],"mask-image-b-to-pos":[{"mask-b-to":J()}],"mask-image-b-from-color":[{"mask-b-from":F()}],"mask-image-b-to-color":[{"mask-b-to":F()}],"mask-image-l-from-pos":[{"mask-l-from":J()}],"mask-image-l-to-pos":[{"mask-l-to":J()}],"mask-image-l-from-color":[{"mask-l-from":F()}],"mask-image-l-to-color":[{"mask-l-to":F()}],"mask-image-x-from-pos":[{"mask-x-from":J()}],"mask-image-x-to-pos":[{"mask-x-to":J()}],"mask-image-x-from-color":[{"mask-x-from":F()}],"mask-image-x-to-color":[{"mask-x-to":F()}],"mask-image-y-from-pos":[{"mask-y-from":J()}],"mask-image-y-to-pos":[{"mask-y-to":J()}],"mask-image-y-from-color":[{"mask-y-from":F()}],"mask-image-y-to-color":[{"mask-y-to":F()}],"mask-image-radial":[{"mask-radial":[et,Ze]}],"mask-image-radial-from-pos":[{"mask-radial-from":J()}],"mask-image-radial-to-pos":[{"mask-radial-to":J()}],"mask-image-radial-from-color":[{"mask-radial-from":F()}],"mask-image-radial-to-color":[{"mask-radial-to":F()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":L()}],"mask-image-conic-pos":[{"mask-conic":[Ct]}],"mask-image-conic-from-pos":[{"mask-conic-from":J()}],"mask-image-conic-to-pos":[{"mask-conic-to":J()}],"mask-image-conic-from-color":[{"mask-conic-from":F()}],"mask-image-conic-to-color":[{"mask-conic-to":F()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:xe()}],"mask-repeat":[{mask:X()}],"mask-size":[{mask:V()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",et,Ze]}],filter:[{filter:["","none",et,Ze]}],blur:[{blur:$()}],brightness:[{brightness:[Ct,et,Ze]}],contrast:[{contrast:[Ct,et,Ze]}],"drop-shadow":[{"drop-shadow":["","none",b,Xh,Yh]}],"drop-shadow-color":[{"drop-shadow":F()}],grayscale:[{grayscale:["",Ct,et,Ze]}],"hue-rotate":[{"hue-rotate":[Ct,et,Ze]}],invert:[{invert:["",Ct,et,Ze]}],saturate:[{saturate:[Ct,et,Ze]}],sepia:[{sepia:["",Ct,et,Ze]}],"backdrop-filter":[{"backdrop-filter":["","none",et,Ze]}],"backdrop-blur":[{"backdrop-blur":$()}],"backdrop-brightness":[{"backdrop-brightness":[Ct,et,Ze]}],"backdrop-contrast":[{"backdrop-contrast":[Ct,et,Ze]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ct,et,Ze]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ct,et,Ze]}],"backdrop-invert":[{"backdrop-invert":["",Ct,et,Ze]}],"backdrop-opacity":[{"backdrop-opacity":[Ct,et,Ze]}],"backdrop-saturate":[{"backdrop-saturate":[Ct,et,Ze]}],"backdrop-sepia":[{"backdrop-sepia":["",Ct,et,Ze]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":z()}],"border-spacing-x":[{"border-spacing-x":z()}],"border-spacing-y":[{"border-spacing-y":z()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",et,Ze]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ct,"initial",et,Ze]}],ease:[{ease:["linear","initial",k,et,Ze]}],delay:[{delay:[Ct,et,Ze]}],animate:[{animate:["none",T,et,Ze]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,et,Ze]}],"perspective-origin":[{"perspective-origin":R()}],rotate:[{rotate:Z()}],"rotate-x":[{"rotate-x":Z()}],"rotate-y":[{"rotate-y":Z()}],"rotate-z":[{"rotate-z":Z()}],scale:[{scale:ae()}],"scale-x":[{"scale-x":ae()}],"scale-y":[{"scale-y":ae()}],"scale-z":[{"scale-z":ae()}],"scale-3d":["scale-3d"],skew:[{skew:we()}],"skew-x":[{"skew-x":we()}],"skew-y":[{"skew-y":we()}],transform:[{transform:[et,Ze,"","none","gpu","cpu"]}],"transform-origin":[{origin:R()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Fe()}],"translate-x":[{"translate-x":Fe()}],"translate-y":[{"translate-y":Fe()}],"translate-z":[{"translate-z":Fe()}],"translate-none":["translate-none"],accent:[{accent:F()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:F()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",et,Ze]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":z()}],"scroll-mx":[{"scroll-mx":z()}],"scroll-my":[{"scroll-my":z()}],"scroll-ms":[{"scroll-ms":z()}],"scroll-me":[{"scroll-me":z()}],"scroll-mt":[{"scroll-mt":z()}],"scroll-mr":[{"scroll-mr":z()}],"scroll-mb":[{"scroll-mb":z()}],"scroll-ml":[{"scroll-ml":z()}],"scroll-p":[{"scroll-p":z()}],"scroll-px":[{"scroll-px":z()}],"scroll-py":[{"scroll-py":z()}],"scroll-ps":[{"scroll-ps":z()}],"scroll-pe":[{"scroll-pe":z()}],"scroll-pt":[{"scroll-pt":z()}],"scroll-pr":[{"scroll-pr":z()}],"scroll-pb":[{"scroll-pb":z()}],"scroll-pl":[{"scroll-pl":z()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",et,Ze]}],fill:[{fill:["none",...F()]}],"stroke-w":[{stroke:[Ct,su,Ml,Bx]}],stroke:[{stroke:["none",...F()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},XP=PP(YP);function zt(...t){return XP(fk(t))}function ya(t){if(!t)return"";let e=t.trim();return e?(e=e.replace(/^(https?)\/\//,"$1://"),e):""}const ZP=pk("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function G({className:t,variant:e,size:n,asChild:r=!1,...a}){const i=r?uk:"button";return s.jsx(i,{"data-slot":"button",className:zt(ZP({variant:e,size:n,className:t})),...a})}function oe({className:t,type:e,...n}){return s.jsx("input",{type:e,"data-slot":"input",className:zt("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs outline-none placeholder:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 md:text-sm focus-visible:ring-2 focus-visible:ring-ring",t),...n})}function eI(){const t=Ya(),[e,n]=g.useState(""),[r,a]=g.useState(""),[i,o]=g.useState(""),[c,u]=g.useState(!1);g.useEffect(()=>{Ku()&&t("/dashboard",{replace:!0})},[t]);const h=async()=>{o(""),u(!0);try{const f=await bt("/api/admin",{username:e.trim(),password:r});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){YA(f.token),t("/dashboard",{replace:!0});return}o(f.error||"用户名或密码错误")}catch(f){const m=f;o(m.status===401?"用户名或密码错误":(m==null?void 0:m.message)||"网络错误,请重试")}finally{u(!1)}};return s.jsxs("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-4",children:[s.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[s.jsx("div",{className:"absolute top-1/4 left-1/4 w-96 h-96 bg-[#38bdac]/5 rounded-full blur-3xl"}),s.jsx("div",{className:"absolute bottom-1/4 right-1/4 w-96 h-96 bg-blue-500/5 rounded-full blur-3xl"})]}),s.jsxs("div",{className:"w-full max-w-md relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("div",{className:"w-16 h-16 bg-[#38bdac]/20 rounded-2xl flex items-center justify-center mx-auto mb-4 border border-[#38bdac]/30",children:s.jsx(Gc,{className:"w-8 h-8 text-[#38bdac]"})}),s.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"管理后台"}),s.jsx("p",{className:"text-gray-400",children:"一场SOUL的创业实验场"})]}),s.jsxs("div",{className:"bg-[#0f2137] rounded-2xl p-8 shadow-xl border border-gray-700/50 backdrop-blur-xl",children:[s.jsx("h2",{className:"text-xl font-semibold text-white mb-6 text-center",children:"管理员登录"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"用户名"}),s.jsxs("div",{className:"relative",children:[s.jsx(Ai,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(oe,{type:"text",value:e,onChange:f=>{n(f.target.value),i&&o("")},placeholder:"请输入用户名",className:"pl-10 bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 focus:border-[#38bdac]"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"密码"}),s.jsxs("div",{className:"relative",children:[s.jsx(DM,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(oe,{type:"password",value:r,onChange:f=>{a(f.target.value),i&&o("")},placeholder:"请输入密码",className:"pl-10 bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 focus:border-[#38bdac]",onKeyDown:f=>f.key==="Enter"&&h()})]})]}),i&&s.jsx("div",{className:"bg-red-500/10 text-red-400 text-sm p-3 rounded-lg border border-red-500/20",children:i}),s.jsx(G,{onClick:h,disabled:c,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white py-5 disabled:opacity-50",children:c?"登录中...":"登录"})]})]}),s.jsx("p",{className:"text-center text-gray-500 text-xs mt-6",children:"Soul创业实验场 · 后台管理系统"})]})]})}const De=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:zt("rounded-xl border bg-card text-card-foreground shadow",t),...e}));De.displayName="Card";const dt=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:zt("flex flex-col space-y-1.5 p-6",t),...e}));dt.displayName="CardHeader";const ut=g.forwardRef(({className:t,...e},n)=>s.jsx("h3",{ref:n,className:zt("font-semibold leading-none tracking-tight",t),...e}));ut.displayName="CardTitle";const Qt=g.forwardRef(({className:t,...e},n)=>s.jsx("p",{ref:n,className:zt("text-sm text-muted-foreground",t),...e}));Qt.displayName="CardDescription";const _e=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:zt("p-6 pt-0",t),...e}));_e.displayName="CardContent";const tI=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:zt("flex items-center p-6 pt-0",t),...e}));tI.displayName="CardFooter";const nI={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function Vx(t,e="info",n=3e3){const r=`toast-${Date.now()}`,a=nI[e],i=document.createElement("div");i.id=r,i.setAttribute("role","alert"),Object.assign(i.style,{position:"fixed",top:"24px",right:"24px",zIndex:"9999",display:"flex",alignItems:"center",gap:"10px",padding:"12px 18px",borderRadius:"10px",background:a.bg,border:`1.5px solid ${a.border}`,boxShadow:"0 4px 20px rgba(0,0,0,.12)",fontSize:"14px",color:"#1a1a1a",fontWeight:"500",maxWidth:"380px",lineHeight:"1.5",opacity:"0",transform:"translateY(-8px)",transition:"opacity .22s ease, transform .22s ease",pointerEvents:"none"});const o=document.createElement("span");Object.assign(o.style,{width:"20px",height:"20px",borderRadius:"50%",background:a.border,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"700",flexShrink:"0"}),o.textContent=a.icon;const c=document.createElement("span");c.textContent=t,i.appendChild(o),i.appendChild(c),document.body.appendChild(i),requestAnimationFrame(()=>{i.style.opacity="1",i.style.transform="translateY(0)"});const u=setTimeout(()=>h(r),n);function h(f){clearTimeout(u);const m=document.getElementById(f);m&&(m.style.opacity="0",m.style.transform="translateY(-8px)",setTimeout(()=>{var x;return(x=m.parentNode)==null?void 0:x.removeChild(m)},250))}}const q={success:(t,e)=>Vx(t,"success",e),error:(t,e)=>Vx(t,"error",e),info:(t,e)=>Vx(t,"info",e)};function jt(t,e,{checkForDefaultPrevented:n=!0}={}){return function(a){if(t==null||t(a),n===!1||!a.defaultPrevented)return e==null?void 0:e(a)}}function sI(t,e){const n=g.createContext(e),r=i=>{const{children:o,...c}=i,u=g.useMemo(()=>c,Object.values(c));return s.jsx(n.Provider,{value:u,children:o})};r.displayName=t+"Provider";function a(i){const o=g.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[r,a]}function Zo(t,e=[]){let n=[];function r(i,o){const c=g.createContext(o),u=n.length;n=[...n,o];const h=m=>{var k;const{scope:x,children:b,...N}=m,w=((k=x==null?void 0:x[t])==null?void 0:k[u])||c,v=g.useMemo(()=>N,Object.values(N));return s.jsx(w.Provider,{value:v,children:b})};h.displayName=i+"Provider";function f(m,x){var w;const b=((w=x==null?void 0:x[t])==null?void 0:w[u])||c,N=g.useContext(b);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${i}\``)}return[h,f]}const a=()=>{const i=n.map(o=>g.createContext(o));return function(c){const u=(c==null?void 0:c[t])||i;return g.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return a.scopeName=t,[r,rI(a,...e)]}function rI(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((c,{useScope:u,scopeName:h})=>{const m=u(i)[`__scope${h}`];return{...c,...m}},{});return g.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var $s=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},aI=Op[" useId ".trim().toString()]||(()=>{}),iI=0;function _o(t){const[e,n]=g.useState(aI());return $s(()=>{n(r=>r??String(iI++))},[t]),e?`radix-${e}`:""}var oI=Op[" useInsertionEffect ".trim().toString()]||$s;function Hl({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[a,i,o]=lI({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:a;{const f=g.useRef(t!==void 0);g.useEffect(()=>{const m=f.current;m!==c&&console.warn(`${r} is changing from ${m?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=c},[c,r])}const h=g.useCallback(f=>{var m;if(c){const x=cI(f)?f(t):f;x!==t&&((m=o.current)==null||m.call(o,x))}else i(f)},[c,t,i,o]);return[u,h]}function lI({defaultProp:t,onChange:e}){const[n,r]=g.useState(t),a=g.useRef(n),i=g.useRef(e);return oI(()=>{i.current=e},[e]),g.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,r,i]}function cI(t){return typeof t=="function"}function Pu(t){const e=dI(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,c=g.Children.toArray(i),u=c.find(hI);if(u){const h=u.props.children,f=c.map(m=>m===u?g.Children.count(h)>1?g.Children.only(null):g.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:a,children:g.isValidElement(h)?g.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function dI(t){const e=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=pI(a),c=fI(i,a.props);return a.type!==g.Fragment&&(c.ref=r?ty(r,o):o),g.cloneElement(a,c)}return g.Children.count(a)>1?g.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var uI=Symbol("radix.slottable");function hI(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===uI}function fI(t,e){const n={...e};for(const r in e){const a=t[r],i=e[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function pI(t){var r,a;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var mI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Et=mI.reduce((t,e)=>{const n=Pu(`Primitive.${e}`),r=g.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function xI(t,e){t&&hd.flushSync(()=>t.dispatchEvent(e))}function Uo(t){const e=g.useRef(t);return g.useEffect(()=>{e.current=t}),g.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function gI(t,e=globalThis==null?void 0:globalThis.document){const n=Uo(t);g.useEffect(()=>{const r=a=>{a.key==="Escape"&&n(a)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var yI="DismissableLayer",Jg="dismissableLayer.update",bI="dismissableLayer.pointerDownOutside",vI="dismissableLayer.focusOutside",J1,Ek=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),sy=g.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:c,...u}=t,h=g.useContext(Ek),[f,m]=g.useState(null),x=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,b]=g.useState({}),N=Xt(e,P=>m(P)),w=Array.from(h.layers),[v]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),k=w.indexOf(v),T=f?w.indexOf(f):-1,C=h.layersWithOutsidePointerEventsDisabled.size>0,L=T>=k,R=jI(P=>{const z=P.target,O=[...h.branches].some(Q=>Q.contains(z));!L||O||(a==null||a(P),o==null||o(P),P.defaultPrevented||c==null||c())},x),U=kI(P=>{const z=P.target;[...h.branches].some(Q=>Q.contains(z))||(i==null||i(P),o==null||o(P),P.defaultPrevented||c==null||c())},x);return gI(P=>{T===h.layers.size-1&&(r==null||r(P),!P.defaultPrevented&&c&&(P.preventDefault(),c()))},x),g.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(J1=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),Q1(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=J1)}},[f,x,n,h]),g.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),Q1())},[f,h]),g.useEffect(()=>{const P=()=>b({});return document.addEventListener(Jg,P),()=>document.removeEventListener(Jg,P)},[]),s.jsx(Et.div,{...u,ref:N,style:{pointerEvents:C?L?"auto":"none":void 0,...t.style},onFocusCapture:jt(t.onFocusCapture,U.onFocusCapture),onBlurCapture:jt(t.onBlurCapture,U.onBlurCapture),onPointerDownCapture:jt(t.onPointerDownCapture,R.onPointerDownCapture)})});sy.displayName=yI;var NI="DismissableLayerBranch",wI=g.forwardRef((t,e)=>{const n=g.useContext(Ek),r=g.useRef(null),a=Xt(e,r);return g.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(Et.div,{...t,ref:a})});wI.displayName=NI;function jI(t,e=globalThis==null?void 0:globalThis.document){const n=Uo(t),r=g.useRef(!1),a=g.useRef(()=>{});return g.useEffect(()=>{const i=c=>{if(c.target&&!r.current){let u=function(){Tk(bI,n,h,{discrete:!0})};const h={originalEvent:c};c.pointerType==="touch"?(e.removeEventListener("click",a.current),a.current=u,e.addEventListener("click",a.current,{once:!0})):u()}else e.removeEventListener("click",a.current);r.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",i),e.removeEventListener("click",a.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function kI(t,e=globalThis==null?void 0:globalThis.document){const n=Uo(t),r=g.useRef(!1);return g.useEffect(()=>{const a=i=>{i.target&&!r.current&&Tk(vI,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",a),()=>e.removeEventListener("focusin",a)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Q1(){const t=new CustomEvent(Jg);document.dispatchEvent(t)}function Tk(t,e,n,{discrete:r}){const a=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&a.addEventListener(t,e,{once:!0}),r?xI(a,i):a.dispatchEvent(i)}var Hx="focusScope.autoFocusOnMount",Ux="focusScope.autoFocusOnUnmount",Y1={bubbles:!1,cancelable:!0},SI="FocusScope",ry=g.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[c,u]=g.useState(null),h=Uo(a),f=Uo(i),m=g.useRef(null),x=Xt(e,w=>u(w)),b=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let w=function(C){if(b.paused||!c)return;const L=C.target;c.contains(L)?m.current=L:vo(m.current,{select:!0})},v=function(C){if(b.paused||!c)return;const L=C.relatedTarget;L!==null&&(c.contains(L)||vo(m.current,{select:!0}))},k=function(C){if(document.activeElement===document.body)for(const R of C)R.removedNodes.length>0&&vo(c)};document.addEventListener("focusin",w),document.addEventListener("focusout",v);const T=new MutationObserver(k);return c&&T.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",v),T.disconnect()}}},[r,c,b.paused]),g.useEffect(()=>{if(c){Z1.add(b);const w=document.activeElement;if(!c.contains(w)){const k=new CustomEvent(Hx,Y1);c.addEventListener(Hx,h),c.dispatchEvent(k),k.defaultPrevented||(CI(PI(Mk(c)),{select:!0}),document.activeElement===w&&vo(c))}return()=>{c.removeEventListener(Hx,h),setTimeout(()=>{const k=new CustomEvent(Ux,Y1);c.addEventListener(Ux,f),c.dispatchEvent(k),k.defaultPrevented||vo(w??document.body,{select:!0}),c.removeEventListener(Ux,f),Z1.remove(b)},0)}}},[c,h,f,b]);const N=g.useCallback(w=>{if(!n&&!r||b.paused)return;const v=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,k=document.activeElement;if(v&&k){const T=w.currentTarget,[C,L]=EI(T);C&&L?!w.shiftKey&&k===L?(w.preventDefault(),n&&vo(C,{select:!0})):w.shiftKey&&k===C&&(w.preventDefault(),n&&vo(L,{select:!0})):k===T&&w.preventDefault()}},[n,r,b.paused]);return s.jsx(Et.div,{tabIndex:-1,...o,ref:x,onKeyDown:N})});ry.displayName=SI;function CI(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(vo(r,{select:e}),document.activeElement!==n)return}function EI(t){const e=Mk(t),n=X1(e,t),r=X1(e.reverse(),t);return[n,r]}function Mk(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const a=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||a?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function X1(t,e){for(const n of t)if(!TI(n,{upTo:e}))return n}function TI(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function MI(t){return t instanceof HTMLInputElement&&"select"in t}function vo(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&MI(t)&&e&&t.select()}}var Z1=AI();function AI(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=eN(t,e),t.unshift(e)},remove(e){var n;t=eN(t,e),(n=t[0])==null||n.resume()}}}function eN(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function PI(t){return t.filter(e=>e.tagName!=="A")}var II="Portal",ay=g.forwardRef((t,e)=>{var c;const{container:n,...r}=t,[a,i]=g.useState(!1);$s(()=>i(!0),[]);const o=n||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Bj.createPortal(s.jsx(Et.div,{...r,ref:e}),o):null});ay.displayName=II;function RI(t,e){return g.useReducer((n,r)=>e[n][r]??n,t)}var qu=t=>{const{present:e,children:n}=t,r=LI(e),a=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),i=Xt(r.ref,OI(a));return typeof n=="function"||r.isPresent?g.cloneElement(a,{ref:i}):null};qu.displayName="Presence";function LI(t){const[e,n]=g.useState(),r=g.useRef(null),a=g.useRef(t),i=g.useRef("none"),o=t?"mounted":"unmounted",[c,u]=RI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const h=Zh(r.current);i.current=c==="mounted"?h:"none"},[c]),$s(()=>{const h=r.current,f=a.current;if(f!==t){const x=i.current,b=Zh(h);t?u("MOUNT"):b==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&x!==b?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,u]),$s(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=b=>{const w=Zh(r.current).includes(CSS.escape(b.animationName));if(b.target===e&&w&&(u("ANIMATION_END"),!a.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},x=b=>{b.target===e&&(i.current=Zh(r.current))};return e.addEventListener("animationstart",x),e.addEventListener("animationcancel",m),e.addEventListener("animationend",m),()=>{f.clearTimeout(h),e.removeEventListener("animationstart",x),e.removeEventListener("animationcancel",m),e.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[e,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:g.useCallback(h=>{r.current=h?getComputedStyle(h):null,n(h)},[])}}function Zh(t){return(t==null?void 0:t.animationName)||"none"}function OI(t){var r,a;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Wx=0;function Ak(){g.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??tN()),document.body.insertAdjacentElement("beforeend",t[1]??tN()),Wx++,()=>{Wx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Wx--}},[])}function tN(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Va=function(){return Va=Object.assign||function(e){for(var n,r=1,a=arguments.length;r"u")return XI;var e=ZI(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},tR=Lk(),Zc="data-scroll-locked",nR=function(t,e,n,r){var a=t.left,i=t.top,o=t.right,c=t.gap;return n===void 0&&(n="margin"),`
+ */const QA=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Ho=Ee("zap",QA),ey="admin_token";function Ku(){try{return localStorage.getItem(ey)}catch{return null}}function YA(t){try{localStorage.setItem(ey,t)}catch{}}function zx(){try{localStorage.removeItem(ey)}catch{}}const XA="https://soulapi.quwanzhi.com",ZA=15e3,F1=6e4,eP=()=>{const t="https://soulapi.quwanzhi.com";{const e=t.trim();if(e.length>0)return e.replace(/\/$/,"")}return XA};function Vl(t){const e=eP(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function $p(t,e={}){const{data:n,...r}=e,a=Vl(t),i=new Headers(r.headers),o=Ku();o&&i.set("Authorization",`Bearer ${o}`),n!=null&&!i.has("Content-Type")&&i.set("Content-Type","application/json");const c=n!=null?JSON.stringify(n):r.body,u=r.timeout??ZA,h=new AbortController,f=setTimeout(()=>h.abort(),u),m=await fetch(a,{...r,headers:i,body:c,credentials:"include",signal:h.signal}).finally(()=>clearTimeout(f)),x=m.headers.get("Content-Type")||"";let b;if(x.includes("application/json"))try{b=await m.json()}catch{throw new Error(`API 响应解析失败 (${m.status})`)}else{const w=await m.text();throw new Error(`API 返回非 JSON 响应 (${m.status}): ${w.slice(0,100)}`)}const N=w=>{const v=w,k=((v==null?void 0:v.message)||(v==null?void 0:v.error)||"").toString();(k.includes("可提现金额不足")||k.includes("可提现不足")||k.includes("余额不足"))&&window.dispatchEvent(new CustomEvent("recharge-alert",{detail:k}))};if(!m.ok){N(b);const w=new Error((b==null?void 0:b.error)||`HTTP ${m.status}`);throw w.status=m.status,w.data=b,w}return N(b),b}function Le(t,e){return $p(t,{...e,method:"GET"})}function bt(t,e,n){return $p(t,{...n,method:"POST",data:e})}function tn(t,e,n){return $p(t,{...n,method:"PUT",data:e})}function Pi(t,e){return $p(t,{...e,method:"DELETE"})}function tP(){const[t,e]=g.useState(!1),[n,r]=g.useState("");return g.useEffect(()=>{const a=i=>{const o=i.detail;r(o||"可提现/余额不足,请及时充值商户号"),e(!0)};return window.addEventListener("recharge-alert",a),()=>window.removeEventListener("recharge-alert",a)},[]),t?s.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-3 bg-red-900/80 border-b border-red-600/50 text-red-100",role:"alert",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(Xj,{className:"w-5 h-5 shrink-0 text-red-400"}),s.jsxs("span",{className:"text-sm font-medium",children:[n,s.jsx("span",{className:"ml-2 text-red-300",children:"请及时充值商户号或核对账户后重试。"})]})]}),s.jsx("button",{type:"button",onClick:()=>e(!1),className:"shrink-0 p-1 rounded hover:bg-red-800/50 transition-colors","aria-label":"关闭告警",children:s.jsx(ss,{className:"w-4 h-4"})})]}):null}const nP=[{icon:EM,label:"数据概览",href:"/dashboard"},{icon:ur,label:"内容管理",href:"/content"},{icon:qn,label:"用户管理",href:"/users"},{icon:aM,label:"找伙伴",href:"/find-partner"},{icon:sd,label:"推广中心",href:"/distribution"}];function sP(){const t=Xo(),e=g.useRef(t.pathname);e.current=t.pathname;const n=Ya(),[r,a]=g.useState(!1),[i,o]=g.useState(!1);g.useEffect(()=>{a(!0)},[]),g.useEffect(()=>{if(!r)return;let u=!1;if(!Ku()){n("/login",{replace:!0});return}return Le("/api/admin").then(h=>{u||(h&&h.success!==!1?o(!0):(zx(),n("/login",{replace:!0,state:{from:e.current}})))}).catch(()=>{u||(zx(),n("/login",{replace:!0,state:{from:e.current}}))}),()=>{u=!0}},[r,n]);const c=async()=>{zx();try{await bt("/api/admin/logout",{})}catch{}n("/login",{replace:!0})};return!r||!i?s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsx("div",{className:"w-64 bg-[#0f2137] border-r border-gray-700/50"}),s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("div",{className:"text-[#38bdac]",children:"加载中..."})})]}):s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsxs("div",{className:"w-64 bg-[#0f2137] flex flex-col border-r border-gray-700/50 shadow-xl",children:[s.jsxs("div",{className:"p-6 border-b border-gray-700/50",children:[s.jsx("h1",{className:"text-xl font-bold text-[#38bdac]",children:"管理后台"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Soul创业派对"})]}),s.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[nP.map(u=>{const h=t.pathname===u.href;return s.jsxs(_i,{to:u.href,className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${h?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[s.jsx(u.icon,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:u.label})]},u.href)}),s.jsxs("div",{className:"pt-4 mt-4 border-t border-gray-700/50 space-y-1",children:[s.jsxs(_i,{to:"/settings",className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${t.pathname==="/settings"?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[s.jsx(Po,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:"系统设置"})]}),s.jsxs(_i,{to:"/open-platform",className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${t.pathname==="/open-platform"?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[s.jsx(QT,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:"API开放平台"})]})]})]}),s.jsx("div",{className:"p-4 border-t border-gray-700/50 space-y-1",children:s.jsxs("button",{type:"button",onClick:c,className:"w-full flex items-center gap-3 px-4 py-3 text-gray-400 hover:text-white rounded-lg hover:bg-gray-700/50 transition-colors",children:[s.jsx($M,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm",children:"退出登录"})]})})]}),s.jsxs("div",{className:"flex-1 overflow-auto bg-[#0a1628] min-w-0 flex flex-col",children:[s.jsx(tP,{}),s.jsx("div",{className:"w-full min-w-0 min-h-full flex-1",children:s.jsx(JE,{})})]})]})}function B1(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function ty(...t){return e=>{let n=!1;const r=t.map(a=>{const i=B1(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a{let{children:i,...o}=r;ck(i)&&typeof _f=="function"&&(i=_f(i._payload));const c=g.Children.toArray(i),u=c.find(lP);if(u){const h=u.props.children,f=c.map(m=>m===u?g.Children.count(h)>1?g.Children.only(null):g.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:a,children:g.isValidElement(h)?g.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}var uk=dk("Slot");function iP(t){const e=g.forwardRef((n,r)=>{let{children:a,...i}=n;if(ck(a)&&typeof _f=="function"&&(a=_f(a._payload)),g.isValidElement(a)){const o=dP(a),c=cP(i,a.props);return a.type!==g.Fragment&&(c.ref=r?ty(r,o):o),g.cloneElement(a,c)}return g.Children.count(a)>1?g.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var oP=Symbol("radix.slottable");function lP(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===oP}function cP(t,e){const n={...e};for(const r in e){const a=t[r],i=e[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function dP(t){var r,a;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function hk(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(e=0;etypeof t=="boolean"?`${t}`:t===0?"0":t,H1=fk,pk=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return H1(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:a,defaultVariants:i}=e,o=Object.keys(a).map(h=>{const f=n==null?void 0:n[h],m=i==null?void 0:i[h];if(f===null)return null;const x=V1(f)||V1(m);return a[h][x]}),c=n&&Object.entries(n).reduce((h,f)=>{let[m,x]=f;return x===void 0||(h[m]=x),h},{}),u=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((h,f)=>{let{class:m,className:x,...b}=f;return Object.entries(b).every(N=>{let[w,v]=N;return Array.isArray(v)?v.includes({...i,...c}[w]):{...i,...c}[w]===v})?[...h,m,x]:h},[]);return H1(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},uP=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r({classGroupId:t,validator:e}),mk=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),$f="-",U1=[],fP="arbitrary..",pP=t=>{const e=xP(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return mP(o);const c=o.split($f),u=c[0]===""&&c.length>1?1:0;return xk(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=r[o],h=n[o];return u?h?uP(h,u):u:h||U1}return n[o]||U1}}},xk=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const a=t[e],i=n.nextPart.get(a);if(i){const h=xk(t,e+1,i);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join($f):t.slice(e).join($f),u=o.length;for(let h=0;ht.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),r=e.slice(0,n);return r?fP+r:void 0})(),xP=t=>{const{theme:e,classGroups:n}=t;return gP(n,e)},gP=(t,e)=>{const n=mk();for(const r in t){const a=t[r];ny(a,n,r,e)}return n},ny=(t,e,n,r)=>{const a=t.length;for(let i=0;i{if(typeof t=="string"){bP(t,e,n);return}if(typeof t=="function"){vP(t,e,n,r);return}NP(t,e,n,r)},bP=(t,e,n)=>{const r=t===""?e:gk(e,t);r.classGroupId=n},vP=(t,e,n,r)=>{if(wP(t)){ny(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(hP(n,t))},NP=(t,e,n,r)=>{const a=Object.entries(t),i=a.length;for(let o=0;o{let n=t;const r=e.split($f),a=r.length;for(let i=0;i"isThemeGetter"in t&&t.isThemeGetter===!0,jP=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),r=Object.create(null);const a=(i,o)=>{n[i]=o,e++,e>t&&(e=0,r=n,n=Object.create(null))};return{get(i){let o=n[i];if(o!==void 0)return o;if((o=r[i])!==void 0)return a(i,o),o},set(i,o){i in n?n[i]=o:a(i,o)}}},Gg="!",W1=":",kP=[],K1=(t,e,n,r,a)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:a}),SP=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=a=>{const i=[];let o=0,c=0,u=0,h;const f=a.length;for(let w=0;wu?h-u:void 0;return K1(i,b,x,N)};if(e){const a=e+W1,i=r;r=o=>o.startsWith(a)?i(o.slice(a.length)):K1(kP,!1,o,void 0,!0)}if(n){const a=r;r=i=>n({className:i,parseClassName:a})}return r},CP=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,r)=>{e.set(n,1e6+r)}),n=>{const r=[];let a=[];for(let i=0;i0&&(a.sort(),r.push(...a),a=[]),r.push(o)):a.push(o)}return a.length>0&&(a.sort(),r.push(...a)),r}},EP=t=>({cache:jP(t.cacheSize),parseClassName:SP(t),sortModifiers:CP(t),...pP(t)}),TP=/\s+/,MP=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:i}=e,o=[],c=t.trim().split(TP);let u="";for(let h=c.length-1;h>=0;h-=1){const f=c[h],{isExternal:m,modifiers:x,hasImportantModifier:b,baseClassName:N,maybePostfixModifierPosition:w}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let v=!!w,k=r(v?N.substring(0,w):N);if(!k){if(!v){u=f+(u.length>0?" "+u:u);continue}if(k=r(N),!k){u=f+(u.length>0?" "+u:u);continue}v=!1}const T=x.length===0?"":x.length===1?x[0]:i(x).join(":"),C=b?T+Gg:T,L=C+k;if(o.indexOf(L)>-1)continue;o.push(L);const R=a(k,v);for(let U=0;U0?" "+u:u)}return u},AP=(...t)=>{let e=0,n,r,a="";for(;e{if(typeof t=="string")return t;let e,n="";for(let r=0;r{let n,r,a,i;const o=u=>{const h=e.reduce((f,m)=>m(f),t());return n=EP(h),r=n.cache.get,a=n.cache.set,i=c,c(u)},c=u=>{const h=r(u);if(h)return h;const f=MP(u,n);return a(u,f),f};return i=o,(...u)=>i(AP(...u))},IP=[],es=t=>{const e=n=>n[t]||IP;return e.isThemeGetter=!0,e},bk=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,vk=/^\((?:(\w[\w-]*):)?(.+)\)$/i,RP=/^\d+\/\d+$/,LP=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,OP=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,DP=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,_P=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,$P=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Dc=t=>RP.test(t),Et=t=>!!t&&!Number.isNaN(Number(t)),go=t=>!!t&&Number.isInteger(Number(t)),Fx=t=>t.endsWith("%")&&Et(t.slice(0,-1)),wi=t=>LP.test(t),zP=()=>!0,FP=t=>OP.test(t)&&!DP.test(t),Nk=()=>!1,BP=t=>_P.test(t),VP=t=>$P.test(t),HP=t=>!Ze(t)&&!et(t),UP=t=>md(t,kk,Nk),Ze=t=>bk.test(t),Ml=t=>md(t,Sk,FP),Bx=t=>md(t,JP,Et),q1=t=>md(t,wk,Nk),WP=t=>md(t,jk,VP),Yh=t=>md(t,Ck,BP),et=t=>vk.test(t),su=t=>xd(t,Sk),KP=t=>xd(t,QP),G1=t=>xd(t,wk),qP=t=>xd(t,kk),GP=t=>xd(t,jk),Xh=t=>xd(t,Ck,!0),md=(t,e,n)=>{const r=bk.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},xd=(t,e,n=!1)=>{const r=vk.exec(t);return r?r[1]?e(r[1]):n:!1},wk=t=>t==="position"||t==="percentage",jk=t=>t==="image"||t==="url",kk=t=>t==="length"||t==="size"||t==="bg-size",Sk=t=>t==="length",JP=t=>t==="number",QP=t=>t==="family-name",Ck=t=>t==="shadow",YP=()=>{const t=es("color"),e=es("font"),n=es("text"),r=es("font-weight"),a=es("tracking"),i=es("leading"),o=es("breakpoint"),c=es("container"),u=es("spacing"),h=es("radius"),f=es("shadow"),m=es("inset-shadow"),x=es("text-shadow"),b=es("drop-shadow"),N=es("blur"),w=es("perspective"),v=es("aspect"),k=es("ease"),T=es("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],L=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],R=()=>[...L(),et,Ze],U=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto","contain","none"],F=()=>[et,Ze,u],O=()=>[Dc,"full","auto",...F()],Q=()=>[go,"none","subgrid",et,Ze],re=()=>["auto",{span:["full",go,et,Ze]},go,et,Ze],D=()=>[go,"auto",et,Ze],ne=()=>["auto","min","max","fr",et,Ze],le=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],me=()=>["start","end","center","stretch","center-safe","end-safe"],I=()=>["auto",...F()],Y=()=>[Dc,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...F()],B=()=>[t,et,Ze],xe=()=>[...L(),G1,q1,{position:[et,Ze]}],X=()=>["no-repeat",{repeat:["","x","y","space","round"]}],V=()=>["auto","cover","contain",qP,UP,{size:[et,Ze]}],W=()=>[Fx,su,Ml],fe=()=>["","none","full",h,et,Ze],he=()=>["",Et,su,Ml],de=()=>["solid","dashed","dotted","double"],_=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],J=()=>[Et,Fx,G1,q1],$=()=>["","none",N,et,Ze],Z=()=>["none",Et,et,Ze],ae=()=>["none",Et,et,Ze],we=()=>[Et,et,Ze],Fe=()=>[Dc,"full",...F()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[wi],breakpoint:[wi],color:[zP],container:[wi],"drop-shadow":[wi],ease:["in","out","in-out"],font:[HP],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[wi],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[wi],shadow:[wi],spacing:["px",Et],text:[wi],"text-shadow":[wi],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Dc,Ze,et,v]}],container:["container"],columns:[{columns:[Et,Ze,et,c]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:R()}],overflow:[{overflow:U()}],"overflow-x":[{"overflow-x":U()}],"overflow-y":[{"overflow-y":U()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:O()}],"inset-x":[{"inset-x":O()}],"inset-y":[{"inset-y":O()}],start:[{start:O()}],end:[{end:O()}],top:[{top:O()}],right:[{right:O()}],bottom:[{bottom:O()}],left:[{left:O()}],visibility:["visible","invisible","collapse"],z:[{z:[go,"auto",et,Ze]}],basis:[{basis:[Dc,"full","auto",c,...F()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Et,Dc,"auto","initial","none",Ze]}],grow:[{grow:["",Et,et,Ze]}],shrink:[{shrink:["",Et,et,Ze]}],order:[{order:[go,"first","last","none",et,Ze]}],"grid-cols":[{"grid-cols":Q()}],"col-start-end":[{col:re()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":Q()}],"row-start-end":[{row:re()}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ne()}],"auto-rows":[{"auto-rows":ne()}],gap:[{gap:F()}],"gap-x":[{"gap-x":F()}],"gap-y":[{"gap-y":F()}],"justify-content":[{justify:[...le(),"normal"]}],"justify-items":[{"justify-items":[...me(),"normal"]}],"justify-self":[{"justify-self":["auto",...me()]}],"align-content":[{content:["normal",...le()]}],"align-items":[{items:[...me(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...me(),{baseline:["","last"]}]}],"place-content":[{"place-content":le()}],"place-items":[{"place-items":[...me(),"baseline"]}],"place-self":[{"place-self":["auto",...me()]}],p:[{p:F()}],px:[{px:F()}],py:[{py:F()}],ps:[{ps:F()}],pe:[{pe:F()}],pt:[{pt:F()}],pr:[{pr:F()}],pb:[{pb:F()}],pl:[{pl:F()}],m:[{m:I()}],mx:[{mx:I()}],my:[{my:I()}],ms:[{ms:I()}],me:[{me:I()}],mt:[{mt:I()}],mr:[{mr:I()}],mb:[{mb:I()}],ml:[{ml:I()}],"space-x":[{"space-x":F()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":F()}],"space-y-reverse":["space-y-reverse"],size:[{size:Y()}],w:[{w:[c,"screen",...Y()]}],"min-w":[{"min-w":[c,"screen","none",...Y()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...Y()]}],h:[{h:["screen","lh",...Y()]}],"min-h":[{"min-h":["screen","lh","none",...Y()]}],"max-h":[{"max-h":["screen","lh",...Y()]}],"font-size":[{text:["base",n,su,Ml]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,et,Bx]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Fx,Ze]}],"font-family":[{font:[KP,Ze,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,et,Ze]}],"line-clamp":[{"line-clamp":[Et,"none",et,Bx]}],leading:[{leading:[i,...F()]}],"list-image":[{"list-image":["none",et,Ze]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",et,Ze]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:B()}],"text-color":[{text:B()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...de(),"wavy"]}],"text-decoration-thickness":[{decoration:[Et,"from-font","auto",et,Ml]}],"text-decoration-color":[{decoration:B()}],"underline-offset":[{"underline-offset":[Et,"auto",et,Ze]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:F()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",et,Ze]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",et,Ze]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:xe()}],"bg-repeat":[{bg:X()}],"bg-size":[{bg:V()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},go,et,Ze],radial:["",et,Ze],conic:[go,et,Ze]},GP,WP]}],"bg-color":[{bg:B()}],"gradient-from-pos":[{from:W()}],"gradient-via-pos":[{via:W()}],"gradient-to-pos":[{to:W()}],"gradient-from":[{from:B()}],"gradient-via":[{via:B()}],"gradient-to":[{to:B()}],rounded:[{rounded:fe()}],"rounded-s":[{"rounded-s":fe()}],"rounded-e":[{"rounded-e":fe()}],"rounded-t":[{"rounded-t":fe()}],"rounded-r":[{"rounded-r":fe()}],"rounded-b":[{"rounded-b":fe()}],"rounded-l":[{"rounded-l":fe()}],"rounded-ss":[{"rounded-ss":fe()}],"rounded-se":[{"rounded-se":fe()}],"rounded-ee":[{"rounded-ee":fe()}],"rounded-es":[{"rounded-es":fe()}],"rounded-tl":[{"rounded-tl":fe()}],"rounded-tr":[{"rounded-tr":fe()}],"rounded-br":[{"rounded-br":fe()}],"rounded-bl":[{"rounded-bl":fe()}],"border-w":[{border:he()}],"border-w-x":[{"border-x":he()}],"border-w-y":[{"border-y":he()}],"border-w-s":[{"border-s":he()}],"border-w-e":[{"border-e":he()}],"border-w-t":[{"border-t":he()}],"border-w-r":[{"border-r":he()}],"border-w-b":[{"border-b":he()}],"border-w-l":[{"border-l":he()}],"divide-x":[{"divide-x":he()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":he()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...de(),"hidden","none"]}],"divide-style":[{divide:[...de(),"hidden","none"]}],"border-color":[{border:B()}],"border-color-x":[{"border-x":B()}],"border-color-y":[{"border-y":B()}],"border-color-s":[{"border-s":B()}],"border-color-e":[{"border-e":B()}],"border-color-t":[{"border-t":B()}],"border-color-r":[{"border-r":B()}],"border-color-b":[{"border-b":B()}],"border-color-l":[{"border-l":B()}],"divide-color":[{divide:B()}],"outline-style":[{outline:[...de(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Et,et,Ze]}],"outline-w":[{outline:["",Et,su,Ml]}],"outline-color":[{outline:B()}],shadow:[{shadow:["","none",f,Xh,Yh]}],"shadow-color":[{shadow:B()}],"inset-shadow":[{"inset-shadow":["none",m,Xh,Yh]}],"inset-shadow-color":[{"inset-shadow":B()}],"ring-w":[{ring:he()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:B()}],"ring-offset-w":[{"ring-offset":[Et,Ml]}],"ring-offset-color":[{"ring-offset":B()}],"inset-ring-w":[{"inset-ring":he()}],"inset-ring-color":[{"inset-ring":B()}],"text-shadow":[{"text-shadow":["none",x,Xh,Yh]}],"text-shadow-color":[{"text-shadow":B()}],opacity:[{opacity:[Et,et,Ze]}],"mix-blend":[{"mix-blend":[..._(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":_()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Et]}],"mask-image-linear-from-pos":[{"mask-linear-from":J()}],"mask-image-linear-to-pos":[{"mask-linear-to":J()}],"mask-image-linear-from-color":[{"mask-linear-from":B()}],"mask-image-linear-to-color":[{"mask-linear-to":B()}],"mask-image-t-from-pos":[{"mask-t-from":J()}],"mask-image-t-to-pos":[{"mask-t-to":J()}],"mask-image-t-from-color":[{"mask-t-from":B()}],"mask-image-t-to-color":[{"mask-t-to":B()}],"mask-image-r-from-pos":[{"mask-r-from":J()}],"mask-image-r-to-pos":[{"mask-r-to":J()}],"mask-image-r-from-color":[{"mask-r-from":B()}],"mask-image-r-to-color":[{"mask-r-to":B()}],"mask-image-b-from-pos":[{"mask-b-from":J()}],"mask-image-b-to-pos":[{"mask-b-to":J()}],"mask-image-b-from-color":[{"mask-b-from":B()}],"mask-image-b-to-color":[{"mask-b-to":B()}],"mask-image-l-from-pos":[{"mask-l-from":J()}],"mask-image-l-to-pos":[{"mask-l-to":J()}],"mask-image-l-from-color":[{"mask-l-from":B()}],"mask-image-l-to-color":[{"mask-l-to":B()}],"mask-image-x-from-pos":[{"mask-x-from":J()}],"mask-image-x-to-pos":[{"mask-x-to":J()}],"mask-image-x-from-color":[{"mask-x-from":B()}],"mask-image-x-to-color":[{"mask-x-to":B()}],"mask-image-y-from-pos":[{"mask-y-from":J()}],"mask-image-y-to-pos":[{"mask-y-to":J()}],"mask-image-y-from-color":[{"mask-y-from":B()}],"mask-image-y-to-color":[{"mask-y-to":B()}],"mask-image-radial":[{"mask-radial":[et,Ze]}],"mask-image-radial-from-pos":[{"mask-radial-from":J()}],"mask-image-radial-to-pos":[{"mask-radial-to":J()}],"mask-image-radial-from-color":[{"mask-radial-from":B()}],"mask-image-radial-to-color":[{"mask-radial-to":B()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":L()}],"mask-image-conic-pos":[{"mask-conic":[Et]}],"mask-image-conic-from-pos":[{"mask-conic-from":J()}],"mask-image-conic-to-pos":[{"mask-conic-to":J()}],"mask-image-conic-from-color":[{"mask-conic-from":B()}],"mask-image-conic-to-color":[{"mask-conic-to":B()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:xe()}],"mask-repeat":[{mask:X()}],"mask-size":[{mask:V()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",et,Ze]}],filter:[{filter:["","none",et,Ze]}],blur:[{blur:$()}],brightness:[{brightness:[Et,et,Ze]}],contrast:[{contrast:[Et,et,Ze]}],"drop-shadow":[{"drop-shadow":["","none",b,Xh,Yh]}],"drop-shadow-color":[{"drop-shadow":B()}],grayscale:[{grayscale:["",Et,et,Ze]}],"hue-rotate":[{"hue-rotate":[Et,et,Ze]}],invert:[{invert:["",Et,et,Ze]}],saturate:[{saturate:[Et,et,Ze]}],sepia:[{sepia:["",Et,et,Ze]}],"backdrop-filter":[{"backdrop-filter":["","none",et,Ze]}],"backdrop-blur":[{"backdrop-blur":$()}],"backdrop-brightness":[{"backdrop-brightness":[Et,et,Ze]}],"backdrop-contrast":[{"backdrop-contrast":[Et,et,Ze]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Et,et,Ze]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Et,et,Ze]}],"backdrop-invert":[{"backdrop-invert":["",Et,et,Ze]}],"backdrop-opacity":[{"backdrop-opacity":[Et,et,Ze]}],"backdrop-saturate":[{"backdrop-saturate":[Et,et,Ze]}],"backdrop-sepia":[{"backdrop-sepia":["",Et,et,Ze]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":F()}],"border-spacing-x":[{"border-spacing-x":F()}],"border-spacing-y":[{"border-spacing-y":F()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",et,Ze]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Et,"initial",et,Ze]}],ease:[{ease:["linear","initial",k,et,Ze]}],delay:[{delay:[Et,et,Ze]}],animate:[{animate:["none",T,et,Ze]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,et,Ze]}],"perspective-origin":[{"perspective-origin":R()}],rotate:[{rotate:Z()}],"rotate-x":[{"rotate-x":Z()}],"rotate-y":[{"rotate-y":Z()}],"rotate-z":[{"rotate-z":Z()}],scale:[{scale:ae()}],"scale-x":[{"scale-x":ae()}],"scale-y":[{"scale-y":ae()}],"scale-z":[{"scale-z":ae()}],"scale-3d":["scale-3d"],skew:[{skew:we()}],"skew-x":[{"skew-x":we()}],"skew-y":[{"skew-y":we()}],transform:[{transform:[et,Ze,"","none","gpu","cpu"]}],"transform-origin":[{origin:R()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Fe()}],"translate-x":[{"translate-x":Fe()}],"translate-y":[{"translate-y":Fe()}],"translate-z":[{"translate-z":Fe()}],"translate-none":["translate-none"],accent:[{accent:B()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:B()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",et,Ze]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":F()}],"scroll-mx":[{"scroll-mx":F()}],"scroll-my":[{"scroll-my":F()}],"scroll-ms":[{"scroll-ms":F()}],"scroll-me":[{"scroll-me":F()}],"scroll-mt":[{"scroll-mt":F()}],"scroll-mr":[{"scroll-mr":F()}],"scroll-mb":[{"scroll-mb":F()}],"scroll-ml":[{"scroll-ml":F()}],"scroll-p":[{"scroll-p":F()}],"scroll-px":[{"scroll-px":F()}],"scroll-py":[{"scroll-py":F()}],"scroll-ps":[{"scroll-ps":F()}],"scroll-pe":[{"scroll-pe":F()}],"scroll-pt":[{"scroll-pt":F()}],"scroll-pr":[{"scroll-pr":F()}],"scroll-pb":[{"scroll-pb":F()}],"scroll-pl":[{"scroll-pl":F()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",et,Ze]}],fill:[{fill:["none",...B()]}],"stroke-w":[{stroke:[Et,su,Ml,Bx]}],stroke:[{stroke:["none",...B()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},XP=PP(YP);function zt(...t){return XP(fk(t))}function ya(t){if(!t)return"";let e=t.trim();return e?(e=e.replace(/^(https?)\/\//,"$1://"),e):""}const ZP=pk("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function G({className:t,variant:e,size:n,asChild:r=!1,...a}){const i=r?uk:"button";return s.jsx(i,{"data-slot":"button",className:zt(ZP({variant:e,size:n,className:t})),...a})}function oe({className:t,type:e,...n}){return s.jsx("input",{type:e,"data-slot":"input",className:zt("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs outline-none placeholder:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 md:text-sm focus-visible:ring-2 focus-visible:ring-ring",t),...n})}function eI(){const t=Ya(),[e,n]=g.useState(""),[r,a]=g.useState(""),[i,o]=g.useState(""),[c,u]=g.useState(!1);g.useEffect(()=>{Ku()&&t("/dashboard",{replace:!0})},[t]);const h=async()=>{o(""),u(!0);try{const f=await bt("/api/admin",{username:e.trim(),password:r});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){YA(f.token),t("/dashboard",{replace:!0});return}o(f.error||"用户名或密码错误")}catch(f){const m=f;o(m.status===401?"用户名或密码错误":(m==null?void 0:m.message)||"网络错误,请重试")}finally{u(!1)}};return s.jsxs("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-4",children:[s.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[s.jsx("div",{className:"absolute top-1/4 left-1/4 w-96 h-96 bg-[#38bdac]/5 rounded-full blur-3xl"}),s.jsx("div",{className:"absolute bottom-1/4 right-1/4 w-96 h-96 bg-blue-500/5 rounded-full blur-3xl"})]}),s.jsxs("div",{className:"w-full max-w-md relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("div",{className:"w-16 h-16 bg-[#38bdac]/20 rounded-2xl flex items-center justify-center mx-auto mb-4 border border-[#38bdac]/30",children:s.jsx(Gc,{className:"w-8 h-8 text-[#38bdac]"})}),s.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"管理后台"}),s.jsx("p",{className:"text-gray-400",children:"一场SOUL的创业实验场"})]}),s.jsxs("div",{className:"bg-[#0f2137] rounded-2xl p-8 shadow-xl border border-gray-700/50 backdrop-blur-xl",children:[s.jsx("h2",{className:"text-xl font-semibold text-white mb-6 text-center",children:"管理员登录"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"用户名"}),s.jsxs("div",{className:"relative",children:[s.jsx(Ai,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(oe,{type:"text",value:e,onChange:f=>{n(f.target.value),i&&o("")},placeholder:"请输入用户名",className:"pl-10 bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 focus:border-[#38bdac]"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"密码"}),s.jsxs("div",{className:"relative",children:[s.jsx(DM,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(oe,{type:"password",value:r,onChange:f=>{a(f.target.value),i&&o("")},placeholder:"请输入密码",className:"pl-10 bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 focus:border-[#38bdac]",onKeyDown:f=>f.key==="Enter"&&h()})]})]}),i&&s.jsx("div",{className:"bg-red-500/10 text-red-400 text-sm p-3 rounded-lg border border-red-500/20",children:i}),s.jsx(G,{onClick:h,disabled:c,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white py-5 disabled:opacity-50",children:c?"登录中...":"登录"})]})]}),s.jsx("p",{className:"text-center text-gray-500 text-xs mt-6",children:"Soul创业实验场 · 后台管理系统"})]})]})}const De=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:zt("rounded-xl border bg-card text-card-foreground shadow",t),...e}));De.displayName="Card";const dt=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:zt("flex flex-col space-y-1.5 p-6",t),...e}));dt.displayName="CardHeader";const ut=g.forwardRef(({className:t,...e},n)=>s.jsx("h3",{ref:n,className:zt("font-semibold leading-none tracking-tight",t),...e}));ut.displayName="CardTitle";const Qt=g.forwardRef(({className:t,...e},n)=>s.jsx("p",{ref:n,className:zt("text-sm text-muted-foreground",t),...e}));Qt.displayName="CardDescription";const _e=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:zt("p-6 pt-0",t),...e}));_e.displayName="CardContent";const tI=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:zt("flex items-center p-6 pt-0",t),...e}));tI.displayName="CardFooter";const nI={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function Vx(t,e="info",n=3e3){const r=`toast-${Date.now()}`,a=nI[e],i=document.createElement("div");i.id=r,i.setAttribute("role","alert"),Object.assign(i.style,{position:"fixed",top:"24px",right:"24px",zIndex:"9999",display:"flex",alignItems:"center",gap:"10px",padding:"12px 18px",borderRadius:"10px",background:a.bg,border:`1.5px solid ${a.border}`,boxShadow:"0 4px 20px rgba(0,0,0,.12)",fontSize:"14px",color:"#1a1a1a",fontWeight:"500",maxWidth:"380px",lineHeight:"1.5",opacity:"0",transform:"translateY(-8px)",transition:"opacity .22s ease, transform .22s ease",pointerEvents:"none"});const o=document.createElement("span");Object.assign(o.style,{width:"20px",height:"20px",borderRadius:"50%",background:a.border,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"700",flexShrink:"0"}),o.textContent=a.icon;const c=document.createElement("span");c.textContent=t,i.appendChild(o),i.appendChild(c),document.body.appendChild(i),requestAnimationFrame(()=>{i.style.opacity="1",i.style.transform="translateY(0)"});const u=setTimeout(()=>h(r),n);function h(f){clearTimeout(u);const m=document.getElementById(f);m&&(m.style.opacity="0",m.style.transform="translateY(-8px)",setTimeout(()=>{var x;return(x=m.parentNode)==null?void 0:x.removeChild(m)},250))}}const q={success:(t,e)=>Vx(t,"success",e),error:(t,e)=>Vx(t,"error",e),info:(t,e)=>Vx(t,"info",e)};function kt(t,e,{checkForDefaultPrevented:n=!0}={}){return function(a){if(t==null||t(a),n===!1||!a.defaultPrevented)return e==null?void 0:e(a)}}function sI(t,e){const n=g.createContext(e),r=i=>{const{children:o,...c}=i,u=g.useMemo(()=>c,Object.values(c));return s.jsx(n.Provider,{value:u,children:o})};r.displayName=t+"Provider";function a(i){const o=g.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[r,a]}function Zo(t,e=[]){let n=[];function r(i,o){const c=g.createContext(o),u=n.length;n=[...n,o];const h=m=>{var k;const{scope:x,children:b,...N}=m,w=((k=x==null?void 0:x[t])==null?void 0:k[u])||c,v=g.useMemo(()=>N,Object.values(N));return s.jsx(w.Provider,{value:v,children:b})};h.displayName=i+"Provider";function f(m,x){var w;const b=((w=x==null?void 0:x[t])==null?void 0:w[u])||c,N=g.useContext(b);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${i}\``)}return[h,f]}const a=()=>{const i=n.map(o=>g.createContext(o));return function(c){const u=(c==null?void 0:c[t])||i;return g.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return a.scopeName=t,[r,rI(a,...e)]}function rI(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((c,{useScope:u,scopeName:h})=>{const m=u(i)[`__scope${h}`];return{...c,...m}},{});return g.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var $s=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},aI=Op[" useId ".trim().toString()]||(()=>{}),iI=0;function _o(t){const[e,n]=g.useState(aI());return $s(()=>{n(r=>r??String(iI++))},[t]),e?`radix-${e}`:""}var oI=Op[" useInsertionEffect ".trim().toString()]||$s;function Hl({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[a,i,o]=lI({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:a;{const f=g.useRef(t!==void 0);g.useEffect(()=>{const m=f.current;m!==c&&console.warn(`${r} is changing from ${m?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=c},[c,r])}const h=g.useCallback(f=>{var m;if(c){const x=cI(f)?f(t):f;x!==t&&((m=o.current)==null||m.call(o,x))}else i(f)},[c,t,i,o]);return[u,h]}function lI({defaultProp:t,onChange:e}){const[n,r]=g.useState(t),a=g.useRef(n),i=g.useRef(e);return oI(()=>{i.current=e},[e]),g.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,r,i]}function cI(t){return typeof t=="function"}function Pu(t){const e=dI(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,c=g.Children.toArray(i),u=c.find(hI);if(u){const h=u.props.children,f=c.map(m=>m===u?g.Children.count(h)>1?g.Children.only(null):g.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:a,children:g.isValidElement(h)?g.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function dI(t){const e=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=pI(a),c=fI(i,a.props);return a.type!==g.Fragment&&(c.ref=r?ty(r,o):o),g.cloneElement(a,c)}return g.Children.count(a)>1?g.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var uI=Symbol("radix.slottable");function hI(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===uI}function fI(t,e){const n={...e};for(const r in e){const a=t[r],i=e[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function pI(t){var r,a;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var mI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Tt=mI.reduce((t,e)=>{const n=Pu(`Primitive.${e}`),r=g.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function xI(t,e){t&&hd.flushSync(()=>t.dispatchEvent(e))}function Uo(t){const e=g.useRef(t);return g.useEffect(()=>{e.current=t}),g.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function gI(t,e=globalThis==null?void 0:globalThis.document){const n=Uo(t);g.useEffect(()=>{const r=a=>{a.key==="Escape"&&n(a)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var yI="DismissableLayer",Jg="dismissableLayer.update",bI="dismissableLayer.pointerDownOutside",vI="dismissableLayer.focusOutside",J1,Ek=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),sy=g.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:c,...u}=t,h=g.useContext(Ek),[f,m]=g.useState(null),x=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,b]=g.useState({}),N=Xt(e,P=>m(P)),w=Array.from(h.layers),[v]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),k=w.indexOf(v),T=f?w.indexOf(f):-1,C=h.layersWithOutsidePointerEventsDisabled.size>0,L=T>=k,R=jI(P=>{const F=P.target,O=[...h.branches].some(Q=>Q.contains(F));!L||O||(a==null||a(P),o==null||o(P),P.defaultPrevented||c==null||c())},x),U=kI(P=>{const F=P.target;[...h.branches].some(Q=>Q.contains(F))||(i==null||i(P),o==null||o(P),P.defaultPrevented||c==null||c())},x);return gI(P=>{T===h.layers.size-1&&(r==null||r(P),!P.defaultPrevented&&c&&(P.preventDefault(),c()))},x),g.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(J1=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),Q1(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=J1)}},[f,x,n,h]),g.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),Q1())},[f,h]),g.useEffect(()=>{const P=()=>b({});return document.addEventListener(Jg,P),()=>document.removeEventListener(Jg,P)},[]),s.jsx(Tt.div,{...u,ref:N,style:{pointerEvents:C?L?"auto":"none":void 0,...t.style},onFocusCapture:kt(t.onFocusCapture,U.onFocusCapture),onBlurCapture:kt(t.onBlurCapture,U.onBlurCapture),onPointerDownCapture:kt(t.onPointerDownCapture,R.onPointerDownCapture)})});sy.displayName=yI;var NI="DismissableLayerBranch",wI=g.forwardRef((t,e)=>{const n=g.useContext(Ek),r=g.useRef(null),a=Xt(e,r);return g.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(Tt.div,{...t,ref:a})});wI.displayName=NI;function jI(t,e=globalThis==null?void 0:globalThis.document){const n=Uo(t),r=g.useRef(!1),a=g.useRef(()=>{});return g.useEffect(()=>{const i=c=>{if(c.target&&!r.current){let u=function(){Tk(bI,n,h,{discrete:!0})};const h={originalEvent:c};c.pointerType==="touch"?(e.removeEventListener("click",a.current),a.current=u,e.addEventListener("click",a.current,{once:!0})):u()}else e.removeEventListener("click",a.current);r.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",i),e.removeEventListener("click",a.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function kI(t,e=globalThis==null?void 0:globalThis.document){const n=Uo(t),r=g.useRef(!1);return g.useEffect(()=>{const a=i=>{i.target&&!r.current&&Tk(vI,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",a),()=>e.removeEventListener("focusin",a)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Q1(){const t=new CustomEvent(Jg);document.dispatchEvent(t)}function Tk(t,e,n,{discrete:r}){const a=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&a.addEventListener(t,e,{once:!0}),r?xI(a,i):a.dispatchEvent(i)}var Hx="focusScope.autoFocusOnMount",Ux="focusScope.autoFocusOnUnmount",Y1={bubbles:!1,cancelable:!0},SI="FocusScope",ry=g.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[c,u]=g.useState(null),h=Uo(a),f=Uo(i),m=g.useRef(null),x=Xt(e,w=>u(w)),b=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let w=function(C){if(b.paused||!c)return;const L=C.target;c.contains(L)?m.current=L:vo(m.current,{select:!0})},v=function(C){if(b.paused||!c)return;const L=C.relatedTarget;L!==null&&(c.contains(L)||vo(m.current,{select:!0}))},k=function(C){if(document.activeElement===document.body)for(const R of C)R.removedNodes.length>0&&vo(c)};document.addEventListener("focusin",w),document.addEventListener("focusout",v);const T=new MutationObserver(k);return c&&T.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",v),T.disconnect()}}},[r,c,b.paused]),g.useEffect(()=>{if(c){Z1.add(b);const w=document.activeElement;if(!c.contains(w)){const k=new CustomEvent(Hx,Y1);c.addEventListener(Hx,h),c.dispatchEvent(k),k.defaultPrevented||(CI(PI(Mk(c)),{select:!0}),document.activeElement===w&&vo(c))}return()=>{c.removeEventListener(Hx,h),setTimeout(()=>{const k=new CustomEvent(Ux,Y1);c.addEventListener(Ux,f),c.dispatchEvent(k),k.defaultPrevented||vo(w??document.body,{select:!0}),c.removeEventListener(Ux,f),Z1.remove(b)},0)}}},[c,h,f,b]);const N=g.useCallback(w=>{if(!n&&!r||b.paused)return;const v=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,k=document.activeElement;if(v&&k){const T=w.currentTarget,[C,L]=EI(T);C&&L?!w.shiftKey&&k===L?(w.preventDefault(),n&&vo(C,{select:!0})):w.shiftKey&&k===C&&(w.preventDefault(),n&&vo(L,{select:!0})):k===T&&w.preventDefault()}},[n,r,b.paused]);return s.jsx(Tt.div,{tabIndex:-1,...o,ref:x,onKeyDown:N})});ry.displayName=SI;function CI(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(vo(r,{select:e}),document.activeElement!==n)return}function EI(t){const e=Mk(t),n=X1(e,t),r=X1(e.reverse(),t);return[n,r]}function Mk(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const a=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||a?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function X1(t,e){for(const n of t)if(!TI(n,{upTo:e}))return n}function TI(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function MI(t){return t instanceof HTMLInputElement&&"select"in t}function vo(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&MI(t)&&e&&t.select()}}var Z1=AI();function AI(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=eN(t,e),t.unshift(e)},remove(e){var n;t=eN(t,e),(n=t[0])==null||n.resume()}}}function eN(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function PI(t){return t.filter(e=>e.tagName!=="A")}var II="Portal",ay=g.forwardRef((t,e)=>{var c;const{container:n,...r}=t,[a,i]=g.useState(!1);$s(()=>i(!0),[]);const o=n||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Bj.createPortal(s.jsx(Tt.div,{...r,ref:e}),o):null});ay.displayName=II;function RI(t,e){return g.useReducer((n,r)=>e[n][r]??n,t)}var qu=t=>{const{present:e,children:n}=t,r=LI(e),a=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),i=Xt(r.ref,OI(a));return typeof n=="function"||r.isPresent?g.cloneElement(a,{ref:i}):null};qu.displayName="Presence";function LI(t){const[e,n]=g.useState(),r=g.useRef(null),a=g.useRef(t),i=g.useRef("none"),o=t?"mounted":"unmounted",[c,u]=RI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const h=Zh(r.current);i.current=c==="mounted"?h:"none"},[c]),$s(()=>{const h=r.current,f=a.current;if(f!==t){const x=i.current,b=Zh(h);t?u("MOUNT"):b==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&x!==b?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,u]),$s(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=b=>{const w=Zh(r.current).includes(CSS.escape(b.animationName));if(b.target===e&&w&&(u("ANIMATION_END"),!a.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},x=b=>{b.target===e&&(i.current=Zh(r.current))};return e.addEventListener("animationstart",x),e.addEventListener("animationcancel",m),e.addEventListener("animationend",m),()=>{f.clearTimeout(h),e.removeEventListener("animationstart",x),e.removeEventListener("animationcancel",m),e.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[e,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:g.useCallback(h=>{r.current=h?getComputedStyle(h):null,n(h)},[])}}function Zh(t){return(t==null?void 0:t.animationName)||"none"}function OI(t){var r,a;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Wx=0;function Ak(){g.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??tN()),document.body.insertAdjacentElement("beforeend",t[1]??tN()),Wx++,()=>{Wx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Wx--}},[])}function tN(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Va=function(){return Va=Object.assign||function(e){for(var n,r=1,a=arguments.length;r"u")return XI;var e=ZI(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},tR=Lk(),Zc="data-scroll-locked",nR=function(t,e,n,r){var a=t.left,i=t.top,o=t.right,c=t.gap;return n===void 0&&(n="margin"),`
.`.concat(_I,` {
overflow: hidden `).concat(r,`;
padding-right: `).concat(c,"px ").concat(r,`;
@@ -649,12 +649,12 @@ Error generating stack: `+S.message+`
`)},sN=function(){var t=parseInt(document.body.getAttribute(Zc)||"0",10);return isFinite(t)?t:0},sR=function(){g.useEffect(function(){return document.body.setAttribute(Zc,(sN()+1).toString()),function(){var t=sN()-1;t<=0?document.body.removeAttribute(Zc):document.body.setAttribute(Zc,t.toString())}},[])},rR=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,a=r===void 0?"margin":r;sR();var i=g.useMemo(function(){return eR(a)},[a]);return g.createElement(tR,{styles:nR(i,!e,a,n?"":"!important")})},Qg=!1;if(typeof window<"u")try{var ef=Object.defineProperty({},"passive",{get:function(){return Qg=!0,!0}});window.addEventListener("test",ef,ef),window.removeEventListener("test",ef,ef)}catch{Qg=!1}var _c=Qg?{passive:!1}:!1,aR=function(t){return t.tagName==="TEXTAREA"},Ok=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!aR(t)&&n[e]==="visible")},iR=function(t){return Ok(t,"overflowY")},oR=function(t){return Ok(t,"overflowX")},rN=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=Dk(t,r);if(a){var i=_k(t,r),o=i[1],c=i[2];if(o>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},lR=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},cR=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},Dk=function(t,e){return t==="v"?iR(e):oR(e)},_k=function(t,e){return t==="v"?lR(e):cR(e)},dR=function(t,e){return t==="h"&&e==="rtl"?-1:1},uR=function(t,e,n,r,a){var i=dR(t,window.getComputedStyle(e).direction),o=i*r,c=n.target,u=e.contains(c),h=!1,f=o>0,m=0,x=0;do{if(!c)break;var b=_k(t,c),N=b[0],w=b[1],v=b[2],k=w-v-i*N;(N||k)&&Dk(t,c)&&(m+=k,x+=N);var T=c.parentNode;c=T&&T.nodeType===Node.DOCUMENT_FRAGMENT_NODE?T.host:T}while(!u&&c!==document.body||u&&(e.contains(c)||e===c));return(f&&Math.abs(m)<1||!f&&Math.abs(x)<1)&&(h=!0),h},tf=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},aN=function(t){return[t.deltaX,t.deltaY]},iN=function(t){return t&&"current"in t?t.current:t},hR=function(t,e){return t[0]===e[0]&&t[1]===e[1]},fR=function(t){return`
.block-interactivity-`.concat(t,` {pointer-events: none;}
.allow-interactivity-`).concat(t,` {pointer-events: all;}
-`)},pR=0,$c=[];function mR(t){var e=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),a=g.useState(pR++)[0],i=g.useState(Lk)[0],o=g.useRef(t);g.useEffect(function(){o.current=t},[t]),g.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var w=DI([t.lockRef.current],(t.shards||[]).map(iN),!0).filter(Boolean);return w.forEach(function(v){return v.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),w.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var c=g.useCallback(function(w,v){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!o.current.allowPinchZoom;var k=tf(w),T=n.current,C="deltaX"in w?w.deltaX:T[0]-k[0],L="deltaY"in w?w.deltaY:T[1]-k[1],R,U=w.target,P=Math.abs(C)>Math.abs(L)?"h":"v";if("touches"in w&&P==="h"&&U.type==="range")return!1;var z=window.getSelection(),O=z&&z.anchorNode,Q=O?O===U||O.contains(U):!1;if(Q)return!1;var re=rN(P,U);if(!re)return!0;if(re?R=P:(R=P==="v"?"h":"v",re=rN(P,U)),!re)return!1;if(!r.current&&"changedTouches"in w&&(C||L)&&(r.current=R),!R)return!0;var D=r.current||R;return uR(D,v,w,D==="h"?C:L)},[]),u=g.useCallback(function(w){var v=w;if(!(!$c.length||$c[$c.length-1]!==i)){var k="deltaY"in v?aN(v):tf(v),T=e.current.filter(function(R){return R.name===v.type&&(R.target===v.target||v.target===R.shadowParent)&&hR(R.delta,k)})[0];if(T&&T.should){v.cancelable&&v.preventDefault();return}if(!T){var C=(o.current.shards||[]).map(iN).filter(Boolean).filter(function(R){return R.contains(v.target)}),L=C.length>0?c(v,C[0]):!o.current.noIsolation;L&&v.cancelable&&v.preventDefault()}}},[]),h=g.useCallback(function(w,v,k,T){var C={name:w,delta:v,target:k,should:T,shadowParent:xR(k)};e.current.push(C),setTimeout(function(){e.current=e.current.filter(function(L){return L!==C})},1)},[]),f=g.useCallback(function(w){n.current=tf(w),r.current=void 0},[]),m=g.useCallback(function(w){h(w.type,aN(w),w.target,c(w,t.lockRef.current))},[]),x=g.useCallback(function(w){h(w.type,tf(w),w.target,c(w,t.lockRef.current))},[]);g.useEffect(function(){return $c.push(i),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:x}),document.addEventListener("wheel",u,_c),document.addEventListener("touchmove",u,_c),document.addEventListener("touchstart",f,_c),function(){$c=$c.filter(function(w){return w!==i}),document.removeEventListener("wheel",u,_c),document.removeEventListener("touchmove",u,_c),document.removeEventListener("touchstart",f,_c)}},[]);var b=t.removeScrollBar,N=t.inert;return g.createElement(g.Fragment,null,N?g.createElement(i,{styles:fR(a)}):null,b?g.createElement(rR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function xR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const gR=WI(Rk,mR);var iy=g.forwardRef(function(t,e){return g.createElement(zp,Va({},t,{ref:e,sideCar:gR}))});iy.classNames=zp.classNames;var yR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},zc=new WeakMap,nf=new WeakMap,sf={},Jx=0,$k=function(t){return t&&(t.host||$k(t.parentNode))},bR=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=$k(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},vR=function(t,e,n,r){var a=bR(e,Array.isArray(t)?t:[t]);sf[n]||(sf[n]=new WeakMap);var i=sf[n],o=[],c=new Set,u=new Set(a),h=function(m){!m||c.has(m)||(c.add(m),h(m.parentNode))};a.forEach(h);var f=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(x){if(c.has(x))f(x);else try{var b=x.getAttribute(r),N=b!==null&&b!=="false",w=(zc.get(x)||0)+1,v=(i.get(x)||0)+1;zc.set(x,w),i.set(x,v),o.push(x),w===1&&N&&nf.set(x,!0),v===1&&x.setAttribute(n,"true"),N||x.setAttribute(r,"true")}catch(k){console.error("aria-hidden: cannot operate on ",x,k)}})};return f(e),c.clear(),Jx++,function(){o.forEach(function(m){var x=zc.get(m)-1,b=i.get(m)-1;zc.set(m,x),i.set(m,b),x||(nf.has(m)||m.removeAttribute(r),nf.delete(m)),b||m.removeAttribute(n)}),Jx--,Jx||(zc=new WeakMap,zc=new WeakMap,nf=new WeakMap,sf={})}},zk=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),a=yR(t);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),vR(r,a,n,"aria-hidden")):function(){return null}},Fp="Dialog",[Fk]=Zo(Fp),[NR,Na]=Fk(Fp),Bk=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,c=g.useRef(null),u=g.useRef(null),[h,f]=Hl({prop:r,defaultProp:a??!1,onChange:i,caller:Fp});return s.jsx(NR,{scope:e,triggerRef:c,contentRef:u,contentId:_o(),titleId:_o(),descriptionId:_o(),open:h,onOpenChange:f,onOpenToggle:g.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};Bk.displayName=Fp;var Vk="DialogTrigger",wR=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(Vk,n),i=Xt(e,a.triggerRef);return s.jsx(Et.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":cy(a.open),...r,ref:i,onClick:jt(t.onClick,a.onOpenToggle)})});wR.displayName=Vk;var oy="DialogPortal",[jR,Hk]=Fk(oy,{forceMount:void 0}),Uk=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:a}=t,i=Na(oy,e);return s.jsx(jR,{scope:e,forceMount:n,children:g.Children.map(r,o=>s.jsx(qu,{present:n||i.open,children:s.jsx(ay,{asChild:!0,container:a,children:o})}))})};Uk.displayName=oy;var zf="DialogOverlay",Wk=g.forwardRef((t,e)=>{const n=Hk(zf,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=Na(zf,t.__scopeDialog);return i.modal?s.jsx(qu,{present:r||i.open,children:s.jsx(SR,{...a,ref:e})}):null});Wk.displayName=zf;var kR=Pu("DialogOverlay.RemoveScroll"),SR=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(zf,n);return s.jsx(iy,{as:kR,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(Et.div,{"data-state":cy(a.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Ul="DialogContent",Kk=g.forwardRef((t,e)=>{const n=Hk(Ul,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=Na(Ul,t.__scopeDialog);return s.jsx(qu,{present:r||i.open,children:i.modal?s.jsx(CR,{...a,ref:e}):s.jsx(ER,{...a,ref:e})})});Kk.displayName=Ul;var CR=g.forwardRef((t,e)=>{const n=Na(Ul,t.__scopeDialog),r=g.useRef(null),a=Xt(e,n.contentRef,r);return g.useEffect(()=>{const i=r.current;if(i)return zk(i)},[]),s.jsx(qk,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:jt(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:jt(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&i.preventDefault()}),onFocusOutside:jt(t.onFocusOutside,i=>i.preventDefault())})}),ER=g.forwardRef((t,e)=>{const n=Na(Ul,t.__scopeDialog),r=g.useRef(!1),a=g.useRef(!1);return s.jsx(qk,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,c;(o=t.onCloseAutoFocus)==null||o.call(t,i),i.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),i.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:i=>{var u,h;(u=t.onInteractOutside)==null||u.call(t,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((h=n.triggerRef.current)==null?void 0:h.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),qk=g.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,c=Na(Ul,n),u=g.useRef(null),h=Xt(e,u);return Ak(),s.jsxs(s.Fragment,{children:[s.jsx(ry,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:s.jsx(sy,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":cy(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(TR,{titleId:c.titleId}),s.jsx(AR,{contentRef:u,descriptionId:c.descriptionId})]})]})}),ly="DialogTitle",Gk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(ly,n);return s.jsx(Et.h2,{id:a.titleId,...r,ref:e})});Gk.displayName=ly;var Jk="DialogDescription",Qk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(Jk,n);return s.jsx(Et.p,{id:a.descriptionId,...r,ref:e})});Qk.displayName=Jk;var Yk="DialogClose",Xk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(Yk,n);return s.jsx(Et.button,{type:"button",...r,ref:e,onClick:jt(t.onClick,()=>a.onOpenChange(!1))})});Xk.displayName=Yk;function cy(t){return t?"open":"closed"}var Zk="DialogTitleWarning",[EH,e2]=sI(Zk,{contentName:Ul,titleName:ly,docsSlug:"dialog"}),TR=({titleId:t})=>{const e=e2(Zk),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
+`)},pR=0,$c=[];function mR(t){var e=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),a=g.useState(pR++)[0],i=g.useState(Lk)[0],o=g.useRef(t);g.useEffect(function(){o.current=t},[t]),g.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var w=DI([t.lockRef.current],(t.shards||[]).map(iN),!0).filter(Boolean);return w.forEach(function(v){return v.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),w.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var c=g.useCallback(function(w,v){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!o.current.allowPinchZoom;var k=tf(w),T=n.current,C="deltaX"in w?w.deltaX:T[0]-k[0],L="deltaY"in w?w.deltaY:T[1]-k[1],R,U=w.target,P=Math.abs(C)>Math.abs(L)?"h":"v";if("touches"in w&&P==="h"&&U.type==="range")return!1;var F=window.getSelection(),O=F&&F.anchorNode,Q=O?O===U||O.contains(U):!1;if(Q)return!1;var re=rN(P,U);if(!re)return!0;if(re?R=P:(R=P==="v"?"h":"v",re=rN(P,U)),!re)return!1;if(!r.current&&"changedTouches"in w&&(C||L)&&(r.current=R),!R)return!0;var D=r.current||R;return uR(D,v,w,D==="h"?C:L)},[]),u=g.useCallback(function(w){var v=w;if(!(!$c.length||$c[$c.length-1]!==i)){var k="deltaY"in v?aN(v):tf(v),T=e.current.filter(function(R){return R.name===v.type&&(R.target===v.target||v.target===R.shadowParent)&&hR(R.delta,k)})[0];if(T&&T.should){v.cancelable&&v.preventDefault();return}if(!T){var C=(o.current.shards||[]).map(iN).filter(Boolean).filter(function(R){return R.contains(v.target)}),L=C.length>0?c(v,C[0]):!o.current.noIsolation;L&&v.cancelable&&v.preventDefault()}}},[]),h=g.useCallback(function(w,v,k,T){var C={name:w,delta:v,target:k,should:T,shadowParent:xR(k)};e.current.push(C),setTimeout(function(){e.current=e.current.filter(function(L){return L!==C})},1)},[]),f=g.useCallback(function(w){n.current=tf(w),r.current=void 0},[]),m=g.useCallback(function(w){h(w.type,aN(w),w.target,c(w,t.lockRef.current))},[]),x=g.useCallback(function(w){h(w.type,tf(w),w.target,c(w,t.lockRef.current))},[]);g.useEffect(function(){return $c.push(i),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:x}),document.addEventListener("wheel",u,_c),document.addEventListener("touchmove",u,_c),document.addEventListener("touchstart",f,_c),function(){$c=$c.filter(function(w){return w!==i}),document.removeEventListener("wheel",u,_c),document.removeEventListener("touchmove",u,_c),document.removeEventListener("touchstart",f,_c)}},[]);var b=t.removeScrollBar,N=t.inert;return g.createElement(g.Fragment,null,N?g.createElement(i,{styles:fR(a)}):null,b?g.createElement(rR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function xR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const gR=WI(Rk,mR);var iy=g.forwardRef(function(t,e){return g.createElement(zp,Va({},t,{ref:e,sideCar:gR}))});iy.classNames=zp.classNames;var yR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},zc=new WeakMap,nf=new WeakMap,sf={},Jx=0,$k=function(t){return t&&(t.host||$k(t.parentNode))},bR=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=$k(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},vR=function(t,e,n,r){var a=bR(e,Array.isArray(t)?t:[t]);sf[n]||(sf[n]=new WeakMap);var i=sf[n],o=[],c=new Set,u=new Set(a),h=function(m){!m||c.has(m)||(c.add(m),h(m.parentNode))};a.forEach(h);var f=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(x){if(c.has(x))f(x);else try{var b=x.getAttribute(r),N=b!==null&&b!=="false",w=(zc.get(x)||0)+1,v=(i.get(x)||0)+1;zc.set(x,w),i.set(x,v),o.push(x),w===1&&N&&nf.set(x,!0),v===1&&x.setAttribute(n,"true"),N||x.setAttribute(r,"true")}catch(k){console.error("aria-hidden: cannot operate on ",x,k)}})};return f(e),c.clear(),Jx++,function(){o.forEach(function(m){var x=zc.get(m)-1,b=i.get(m)-1;zc.set(m,x),i.set(m,b),x||(nf.has(m)||m.removeAttribute(r),nf.delete(m)),b||m.removeAttribute(n)}),Jx--,Jx||(zc=new WeakMap,zc=new WeakMap,nf=new WeakMap,sf={})}},zk=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),a=yR(t);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),vR(r,a,n,"aria-hidden")):function(){return null}},Fp="Dialog",[Fk]=Zo(Fp),[NR,Na]=Fk(Fp),Bk=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,c=g.useRef(null),u=g.useRef(null),[h,f]=Hl({prop:r,defaultProp:a??!1,onChange:i,caller:Fp});return s.jsx(NR,{scope:e,triggerRef:c,contentRef:u,contentId:_o(),titleId:_o(),descriptionId:_o(),open:h,onOpenChange:f,onOpenToggle:g.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};Bk.displayName=Fp;var Vk="DialogTrigger",wR=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(Vk,n),i=Xt(e,a.triggerRef);return s.jsx(Tt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":cy(a.open),...r,ref:i,onClick:kt(t.onClick,a.onOpenToggle)})});wR.displayName=Vk;var oy="DialogPortal",[jR,Hk]=Fk(oy,{forceMount:void 0}),Uk=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:a}=t,i=Na(oy,e);return s.jsx(jR,{scope:e,forceMount:n,children:g.Children.map(r,o=>s.jsx(qu,{present:n||i.open,children:s.jsx(ay,{asChild:!0,container:a,children:o})}))})};Uk.displayName=oy;var zf="DialogOverlay",Wk=g.forwardRef((t,e)=>{const n=Hk(zf,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=Na(zf,t.__scopeDialog);return i.modal?s.jsx(qu,{present:r||i.open,children:s.jsx(SR,{...a,ref:e})}):null});Wk.displayName=zf;var kR=Pu("DialogOverlay.RemoveScroll"),SR=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(zf,n);return s.jsx(iy,{as:kR,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(Tt.div,{"data-state":cy(a.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Ul="DialogContent",Kk=g.forwardRef((t,e)=>{const n=Hk(Ul,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=Na(Ul,t.__scopeDialog);return s.jsx(qu,{present:r||i.open,children:i.modal?s.jsx(CR,{...a,ref:e}):s.jsx(ER,{...a,ref:e})})});Kk.displayName=Ul;var CR=g.forwardRef((t,e)=>{const n=Na(Ul,t.__scopeDialog),r=g.useRef(null),a=Xt(e,n.contentRef,r);return g.useEffect(()=>{const i=r.current;if(i)return zk(i)},[]),s.jsx(qk,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:kt(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:kt(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&i.preventDefault()}),onFocusOutside:kt(t.onFocusOutside,i=>i.preventDefault())})}),ER=g.forwardRef((t,e)=>{const n=Na(Ul,t.__scopeDialog),r=g.useRef(!1),a=g.useRef(!1);return s.jsx(qk,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,c;(o=t.onCloseAutoFocus)==null||o.call(t,i),i.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),i.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:i=>{var u,h;(u=t.onInteractOutside)==null||u.call(t,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((h=n.triggerRef.current)==null?void 0:h.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),qk=g.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,c=Na(Ul,n),u=g.useRef(null),h=Xt(e,u);return Ak(),s.jsxs(s.Fragment,{children:[s.jsx(ry,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:s.jsx(sy,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":cy(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(TR,{titleId:c.titleId}),s.jsx(AR,{contentRef:u,descriptionId:c.descriptionId})]})]})}),ly="DialogTitle",Gk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(ly,n);return s.jsx(Tt.h2,{id:a.titleId,...r,ref:e})});Gk.displayName=ly;var Jk="DialogDescription",Qk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(Jk,n);return s.jsx(Tt.p,{id:a.descriptionId,...r,ref:e})});Qk.displayName=Jk;var Yk="DialogClose",Xk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(Yk,n);return s.jsx(Tt.button,{type:"button",...r,ref:e,onClick:kt(t.onClick,()=>a.onOpenChange(!1))})});Xk.displayName=Yk;function cy(t){return t?"open":"closed"}var Zk="DialogTitleWarning",[EH,e2]=sI(Zk,{contentName:Ul,titleName:ly,docsSlug:"dialog"}),TR=({titleId:t})=>{const e=e2(Zk),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
-For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return g.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},MR="DialogDescriptionWarning",AR=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${e2(MR).contentName}}.`;return g.useEffect(()=>{var i;const a=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");e&&a&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},PR=Bk,IR=Uk,RR=Wk,LR=Kk,OR=Gk,DR=Qk,_R=Xk;function Lt(t){return s.jsx(PR,{"data-slot":"dialog",...t})}function $R(t){return s.jsx(IR,{...t})}const t2=g.forwardRef(({className:t,...e},n)=>s.jsx(RR,{ref:n,className:zt("fixed inset-0 z-50 bg-black/50",t),...e}));t2.displayName="DialogOverlay";const It=g.forwardRef(({className:t,children:e,showCloseButton:n=!0,...r},a)=>s.jsxs($R,{children:[s.jsx(t2,{}),s.jsxs(LR,{ref:a,"aria-describedby":void 0,className:zt("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border bg-background p-6 shadow-lg",t),...r,children:[e,n&&s.jsxs(_R,{className:"absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[s.jsx(ns,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));It.displayName="DialogContent";function Ot({className:t,...e}){return s.jsx("div",{className:zt("flex flex-col gap-2 text-center sm:text-left",t),...e})}function nn({className:t,...e}){return s.jsx("div",{className:zt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Dt(t){return s.jsx(OR,{className:"text-lg font-semibold leading-none",...t})}function Wo(t){return s.jsx(DR,{className:"text-sm text-muted-foreground",...t})}const zR=pk("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 transition-colors",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Be({className:t,variant:e,asChild:n=!1,...r}){const a=n?uk:"span";return s.jsx(a,{className:zt(zR({variant:e}),t),...r})}var FR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],BR=FR.reduce((t,e)=>{const n=dk(`Primitive.${e}`),r=g.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),VR="Label",n2=g.forwardRef((t,e)=>s.jsx(BR.label,{...t,ref:e,onMouseDown:n=>{var a;n.target.closest("button, input, select, textarea")||((a=t.onMouseDown)==null||a.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));n2.displayName=VR;var s2=n2;const te=g.forwardRef(({className:t,...e},n)=>s.jsx(s2,{ref:n,className:zt("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));te.displayName=s2.displayName;function dy(t){const e=t+"CollectionProvider",[n,r]=Zo(e),[a,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:v,children:k}=w,T=qs.useRef(null),C=qs.useRef(new Map).current;return s.jsx(a,{scope:v,itemMap:C,collectionRef:T,children:k})};o.displayName=e;const c=t+"CollectionSlot",u=Pu(c),h=qs.forwardRef((w,v)=>{const{scope:k,children:T}=w,C=i(c,k),L=Xt(v,C.collectionRef);return s.jsx(u,{ref:L,children:T})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",x=Pu(f),b=qs.forwardRef((w,v)=>{const{scope:k,children:T,...C}=w,L=qs.useRef(null),R=Xt(v,L),U=i(f,k);return qs.useEffect(()=>(U.itemMap.set(L,{ref:L,...C}),()=>void U.itemMap.delete(L))),s.jsx(x,{[m]:"",ref:R,children:T})});b.displayName=f;function N(w){const v=i(t+"CollectionConsumer",w);return qs.useCallback(()=>{const T=v.collectionRef.current;if(!T)return[];const C=Array.from(T.querySelectorAll(`[${m}]`));return Array.from(v.itemMap.values()).sort((U,P)=>C.indexOf(U.ref.current)-C.indexOf(P.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:h,ItemSlot:b},N,r]}var HR=g.createContext(void 0);function Bp(t){const e=g.useContext(HR);return t||e||"ltr"}var Qx="rovingFocusGroup.onEntryFocus",UR={bubbles:!1,cancelable:!0},Gu="RovingFocusGroup",[Yg,r2,WR]=dy(Gu),[KR,a2]=Zo(Gu,[WR]),[qR,GR]=KR(Gu),i2=g.forwardRef((t,e)=>s.jsx(Yg.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(Yg.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(JR,{...t,ref:e})})}));i2.displayName=Gu;var JR=g.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...m}=t,x=g.useRef(null),b=Xt(e,x),N=Bp(i),[w,v]=Hl({prop:o,defaultProp:c??null,onChange:u,caller:Gu}),[k,T]=g.useState(!1),C=Uo(h),L=r2(n),R=g.useRef(!1),[U,P]=g.useState(0);return g.useEffect(()=>{const z=x.current;if(z)return z.addEventListener(Qx,C),()=>z.removeEventListener(Qx,C)},[C]),s.jsx(qR,{scope:n,orientation:r,dir:N,loop:a,currentTabStopId:w,onItemFocus:g.useCallback(z=>v(z),[v]),onItemShiftTab:g.useCallback(()=>T(!0),[]),onFocusableItemAdd:g.useCallback(()=>P(z=>z+1),[]),onFocusableItemRemove:g.useCallback(()=>P(z=>z-1),[]),children:s.jsx(Et.div,{tabIndex:k||U===0?-1:0,"data-orientation":r,...m,ref:b,style:{outline:"none",...t.style},onMouseDown:jt(t.onMouseDown,()=>{R.current=!0}),onFocus:jt(t.onFocus,z=>{const O=!R.current;if(z.target===z.currentTarget&&O&&!k){const Q=new CustomEvent(Qx,UR);if(z.currentTarget.dispatchEvent(Q),!Q.defaultPrevented){const re=L().filter(I=>I.focusable),D=re.find(I=>I.active),ne=re.find(I=>I.id===w),me=[D,ne,...re].filter(Boolean).map(I=>I.ref.current);c2(me,f)}}R.current=!1}),onBlur:jt(t.onBlur,()=>T(!1))})})}),o2="RovingFocusGroupItem",l2=g.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...c}=t,u=_o(),h=i||u,f=GR(o2,n),m=f.currentTabStopId===h,x=r2(n),{onFocusableItemAdd:b,onFocusableItemRemove:N,currentTabStopId:w}=f;return g.useEffect(()=>{if(r)return b(),()=>N()},[r,b,N]),s.jsx(Yg.ItemSlot,{scope:n,id:h,focusable:r,active:a,children:s.jsx(Et.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:jt(t.onMouseDown,v=>{r?f.onItemFocus(h):v.preventDefault()}),onFocus:jt(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:jt(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const k=XR(v,f.orientation,f.dir);if(k!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let C=x().filter(L=>L.focusable).map(L=>L.ref.current);if(k==="last")C.reverse();else if(k==="prev"||k==="next"){k==="prev"&&C.reverse();const L=C.indexOf(v.currentTarget);C=f.loop?ZR(C,L+1):C.slice(L+1)}setTimeout(()=>c2(C))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:w!=null}):o})})});l2.displayName=o2;var QR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function YR(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function XR(t,e,n){const r=YR(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return QR[r]}function c2(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function ZR(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var e8=i2,t8=l2,Vp="Tabs",[n8]=Zo(Vp,[a2]),d2=a2(),[s8,uy]=n8(Vp),u2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=Bp(c),[m,x]=Hl({prop:r,onChange:a,defaultProp:i??"",caller:Vp});return s.jsx(s8,{scope:n,baseId:_o(),value:m,onValueChange:x,orientation:o,dir:f,activationMode:u,children:s.jsx(Et.div,{dir:f,"data-orientation":o,...h,ref:e})})});u2.displayName=Vp;var h2="TabsList",f2=g.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...a}=t,i=uy(h2,n),o=d2(n);return s.jsx(e8,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(Et.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:e})})});f2.displayName=h2;var p2="TabsTrigger",m2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...i}=t,o=uy(p2,n),c=d2(n),u=y2(o.baseId,r),h=b2(o.baseId,r),f=r===o.value;return s.jsx(t8,{asChild:!0,...c,focusable:!a,active:f,children:s.jsx(Et.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":h,"data-state":f?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:u,...i,ref:e,onMouseDown:jt(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(r):m.preventDefault()}),onKeyDown:jt(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(r)}),onFocus:jt(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!a&&m&&o.onValueChange(r)})})})});m2.displayName=p2;var x2="TabsContent",g2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=t,c=uy(x2,n),u=y2(c.baseId,r),h=b2(c.baseId,r),f=r===c.value,m=g.useRef(f);return g.useEffect(()=>{const x=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(x)},[]),s.jsx(qu,{present:a||f,children:({present:x})=>s.jsx(Et.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!x,id:h,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:m.current?"0s":void 0},children:x&&i})})});g2.displayName=x2;function y2(t,e){return`${t}-trigger-${e}`}function b2(t,e){return`${t}-content-${e}`}var r8=u2,v2=f2,N2=m2,w2=g2;const Wl=r8,Ko=g.forwardRef(({className:t,...e},n)=>s.jsx(v2,{ref:n,className:zt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));Ko.displayName=v2.displayName;const Ut=g.forwardRef(({className:t,...e},n)=>s.jsx(N2,{ref:n,className:zt("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...e}));Ut.displayName=N2.displayName;const Wt=g.forwardRef(({className:t,...e},n)=>s.jsx(w2,{ref:n,className:zt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));Wt.displayName=w2.displayName;function hy(t){const e=g.useRef({value:t,previous:t});return g.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function fy(t){const[e,n]=g.useState(void 0);return $s(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const i=a[0];let o,c;if("borderBoxSize"in i){const u=i.borderBoxSize,h=Array.isArray(u)?u[0]:u;o=h.inlineSize,c=h.blockSize}else o=t.offsetWidth,c=t.offsetHeight;n({width:o,height:c})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var Hp="Switch",[a8]=Zo(Hp),[i8,o8]=a8(Hp),j2=g.forwardRef((t,e)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:i,required:o,disabled:c,value:u="on",onCheckedChange:h,form:f,...m}=t,[x,b]=g.useState(null),N=Xt(e,C=>b(C)),w=g.useRef(!1),v=x?f||!!x.closest("form"):!0,[k,T]=Hl({prop:a,defaultProp:i??!1,onChange:h,caller:Hp});return s.jsxs(i8,{scope:n,checked:k,disabled:c,children:[s.jsx(Et.button,{type:"button",role:"switch","aria-checked":k,"aria-required":o,"data-state":E2(k),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:N,onClick:jt(t.onClick,C=>{T(L=>!L),v&&(w.current=C.isPropagationStopped(),w.current||C.stopPropagation())})}),v&&s.jsx(C2,{control:x,bubbles:!w.current,name:r,value:u,checked:k,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});j2.displayName=Hp;var k2="SwitchThumb",S2=g.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,a=o8(k2,n);return s.jsx(Et.span,{"data-state":E2(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:e})});S2.displayName=k2;var l8="SwitchBubbleInput",C2=g.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...a},i)=>{const o=g.useRef(null),c=Xt(o,i),u=hy(n),h=fy(e);return g.useEffect(()=>{const f=o.current;if(!f)return;const m=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(m,"checked").set;if(u!==n&&b){const N=new Event("click",{bubbles:r});b.call(f,n),f.dispatchEvent(N)}},[u,n,r]),s.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:c,style:{...a.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});C2.displayName=l8;function E2(t){return t?"checked":"unchecked"}var T2=j2,c8=S2;const Kt=g.forwardRef(({className:t,...e},n)=>s.jsx(T2,{className:zt("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#38bdac] focus-visible:ring-offset-2 focus-visible:ring-offset-[#0a1628] disabled:cursor-not-allowed disabled:opacity-50 data-[state=unchecked]:bg-gray-600 data-[state=checked]:bg-[#38bdac]",t),...e,ref:n,children:s.jsx(c8,{className:zt("pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Kt.displayName=T2.displayName;const d8={view_chapter:"浏览章节",purchase:"购买",match:"派对匹配",login:"登录",register:"注册",share:"分享",bind_phone:"绑定手机",bind_wechat:"绑定微信",fill_profile:"完善资料",fill_avatar:"设置头像",visit_page:"访问页面",first_pay:"首次付款",vip_activate:"开通会员",click_super:"点击超级个体",lead_submit:"提交留资",withdraw:"申请提现",referral_bind:"绑定推荐人",card_click:"点击名片",btn_click:"按钮点击",tab_click:"切换标签",nav_click:"导航点击",page_view:"页面浏览",search:"搜索"};function u8(t){return d8[t]||t||"行为"}function h8(t,e){const n=new Set,r=a=>(t[a]??0)>0;return(r("purchase")||r("first_pay")||r("vip_activate"))&&n.add("已付费"),(r("lead_submit")||r("click_super"))&&n.add("高意向"),r("view_chapter")&&n.add("想学习"),r("match")&&n.add("找合伙人"),r("withdraw")&&n.add("有提现行为"),r("referral_bind")&&n.add("推广参与"),(r("fill_profile")||r("fill_avatar")||r("bind_phone"))&&n.add("资料完善中"),e!=null&&e.hasFullBook&&n.add("全书读者"),e!=null&&e.isVip&&n.add("VIP会员"),e!=null&&e.mbti&&/^[EI][NS][FT][JP]$/i.test(e.mbti)&&n.add(String(e.mbti).toUpperCase()),Array.from(n)}function py({open:t,onClose:e,userId:n,onUserUpdated:r}){var Qr,Vs,Qs,pr,Ys,ka;const[a,i]=g.useState(null),[o,c]=g.useState([]),[u,h]=g.useState({}),[f,m]=g.useState([]),[x,b]=g.useState(null),[N,w]=g.useState(null),[v,k]=g.useState(!1),[T,C]=g.useState(!1),[L,R]=g.useState(!1),[U,P]=g.useState("info"),[z,O]=g.useState(""),[Q,re]=g.useState(""),[D,ne]=g.useState(""),[le,me]=g.useState([]),[I,Y]=g.useState(""),[F,xe]=g.useState(""),[X,V]=g.useState(""),[W,fe]=g.useState(!1),[he,de]=g.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[_,J]=g.useState([]),[$,Z]=g.useState(!1),[ae,we]=g.useState(""),[Fe,Ue]=g.useState(""),[wt,jn]=g.useState(!1),[pt,At]=g.useState(!1),[fn,Vn]=g.useState(null),[pn,qt]=g.useState(null),[bn,Mn]=g.useState(""),[Hn,rs]=g.useState(""),[_t,vn]=g.useState(""),[Ne,Me]=g.useState(!1),[We,rt]=g.useState(null),[$t,kt]=g.useState(!1),[$e,H]=g.useState({}),[Qe,vt]=g.useState([]);g.useEffect(()=>{t&&n&&(kt(!1),P("info"),Vn(null),qt(null),rt(null),xe(""),V(""),yt(),Le("/api/db/vip-roles").then(ce=>{ce!=null&&ce.success&&ce.data&&J(ce.data)}).catch(()=>{}))},[t,n]),g.useEffect(()=>{t&&Le("/api/admin/mbti-avatars").then(ce=>{ce!=null&&ce.avatars&&typeof ce.avatars=="object"?H(ce.avatars):H({})}).catch(()=>H({}))},[t]);const Ft=(ce,ve)=>{const Rt=(ce||"").trim();if(Rt)return ya(Rt);const Zt=(ve||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(Zt)?($e[Zt]||"").trim():""};async function yt(){if(n){k(!0);try{const ce=await Le(`/api/db/users?id=${encodeURIComponent(n)}`);if(ce!=null&&ce.success&&ce.user){const ve=ce.user;i(ve),O(ve.phone||""),re(ve.wechatId||""),ne(ve.nickname||""),Mn(ve.phone||""),rs(ve.wechatId||""),vn(ve.openId||"");try{me(typeof ve.tags=="string"?JSON.parse(ve.tags||"[]"):[])}catch{me([])}de({isVip:!!(ve.isVip??!1),vipExpireDate:ve.vipExpireDate?String(ve.vipExpireDate).slice(0,10):"",vipRole:String(ve.vipRole??""),vipName:String(ve.vipName??""),vipProject:String(ve.vipProject??""),vipContact:String(ve.vipContact??""),vipBio:String(ve.vipBio??"")})}try{const ve=await Le(`/api/admin/user/track?userId=${encodeURIComponent(n)}&limit=100`);if(ve!=null&&ve.success){h(ve.stats&&typeof ve.stats=="object"?ve.stats:{});const Rt=ve.tracks||[];c(Rt.map(Zt=>({...Zt,actionLabel:Zt.actionLabel||Zt.action,timeAgo:Zt.timeAgo||""})))}else h({}),c([])}catch{h({}),c([])}try{const ve=await Le(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);ve!=null&&ve.success?(m(ve.referrals||[]),b(ve.inboundSource||null)):(m([]),b(null))}catch{m([]),b(null)}try{const ve=await Le(`/api/admin/users/${encodeURIComponent(n)}/balance`);ve!=null&&ve.success&&ve.data?w(ve.data):w(null)}catch{w(null)}try{const ve=await Le(`/api/orders?userId=${encodeURIComponent(n)}&status=paid&pageSize=50`);ve!=null&&ve.success&&ve.orders?vt(ve.orders):vt([])}catch{vt([])}}catch(ce){console.error("Load user detail error:",ce)}finally{k(!1)}}}async function ht(){if(!(a!=null&&a.phone)){q.info("用户未绑定手机号,无法同步");return}C(!0);try{const ce=await bt("/api/ckb/sync",{action:"full_sync",phone:a.phone,userId:a.id});ce!=null&&ce.success?(q.success("同步成功"),yt()):q.error("同步失败: "+(ce==null?void 0:ce.error))}catch(ce){console.error("Sync CKB error:",ce),q.error("同步失败")}finally{C(!1)}}async function Pt(){if(a){if(he.isVip&&!he.vipExpireDate.trim()){q.error("开启 VIP 请填写有效到期日");return}R(!0);try{const ce={id:a.id,phone:z.trim()||void 0,wechatId:Q.trim(),nickname:D||void 0,tags:JSON.stringify(le),isVip:he.isVip,vipExpireDate:he.isVip?he.vipExpireDate:void 0,vipRole:he.vipRole||void 0,vipName:he.vipName||void 0,vipProject:he.vipProject||void 0,vipContact:he.vipContact||void 0,vipBio:he.vipBio||void 0},ve=await tn("/api/db/users",ce);ve!=null&&ve.success?(q.success("保存成功"),yt(),r==null||r()):q.error("保存失败: "+(ve==null?void 0:ve.error))}catch(ce){console.error("Save user error:",ce),q.error("保存失败")}finally{R(!1)}}}const Gt=()=>{I&&!le.includes(I)&&(me([...le,I]),Y(""))},kn=ce=>me(le.filter(ve=>ve!==ce));async function Ts(){if(a){if(!F){q.error("请输入新密码");return}if(F!==X){q.error("两次密码不一致");return}if(F.length<6){q.error("密码至少 6 位");return}fe(!0);try{const ce=await tn("/api/db/users",{id:a.id,password:F});ce!=null&&ce.success?(q.success("修改成功"),xe(""),V("")):q.error("修改失败: "+((ce==null?void 0:ce.error)||""))}catch{q.error("修改失败")}finally{fe(!1)}}}async function Ms(){if(!a)return;const ce=parseFloat(ae);if(Number.isNaN(ce)||ce===0){q.error("请输入有效金额(正数增加、负数扣减)");return}jn(!0);try{const ve=await bt(`/api/admin/users/${a.id}/balance/adjust`,{amount:ce,remark:Fe||void 0});ve!=null&&ve.success?(q.success("余额已调整"),Z(!1),we(""),Ue(""),yt(),r==null||r()):q.error("调整失败: "+((ve==null?void 0:ve.error)||""))}catch{q.error("调整失败")}finally{jn(!1)}}async function Ki(){if(!bn&&!_t&&!Hn){qt("请至少输入手机号、微信号或 OpenID 中的一项");return}At(!0),qt(null),Vn(null);try{const ce=new URLSearchParams;bn&&ce.set("phone",bn),_t&&ce.set("openId",_t),Hn&&ce.set("wechatId",Hn);const ve=await Le(`/api/admin/shensheshou/query?${ce}`);ve!=null&&ve.success&&ve.data?(Vn(ve.data),a&&await ja(ve.data)):qt((ve==null?void 0:ve.error)||"未查询到数据,该用户可能未在神射手收录")}catch(ce){console.error("SSS query error:",ce),qt("请求失败,请检查神射手接口配置")}finally{At(!1)}}async function ja(ce){if(a)try{await bt("/api/admin/shensheshou/enrich",{userId:a.id,phone:bn||a.phone||"",openId:_t||a.openId||"",wechatId:Hn||a.wechatId||""}),yt()}catch(ve){console.error("SSS enrich error:",ve)}}async function ei(){if(a){Me(!0),rt(null);try{const ce=Array.from(new Set(o.filter(as=>as.action==="view_chapter"||as.action==="purchase"||as.action==="first_pay").map(as=>(as.chapterTitle||as.target||"").trim()).filter(Boolean))).slice(0,12),ve={viewChapter:u.view_chapter||0,purchase:u.purchase||0,firstPay:u.first_pay||0},Rt=ce.length>0?`意向章节:${ce.join("、")}`:"",Zt={users:[{phone:a.phone||"",name:a.nickname||"",openId:a.openId||"",tags:le,purchaseIntent:ve,purchaseIntentChapters:ce,remark:Rt}]},sn=await bt("/api/admin/shensheshou/ingest",Zt);sn!=null&&sn.success&&sn.data?rt(sn.data):rt({error:(sn==null?void 0:sn.error)||"推送失败"})}catch(ce){console.error("SSS ingest error:",ce),rt({error:"请求失败"})}finally{Me(!1)}}}const ti=ce=>{const Rt={view_chapter:ur,purchase:mu,match:Kn,login:Ai,register:Ai,share:Ua,bind_phone:_1,bind_wechat:HM,fill_profile:xu,fill_avatar:Ai,visit_page:ma,first_pay:mu,vip_activate:Xc,click_super:Kn,lead_submit:_1,withdraw:Au,referral_bind:Ua,card_click:Ai,btn_click:Ho,tab_click:ma,nav_click:ma,page_view:ma,search:ma}[ce]||Vg;return s.jsx(Rt,{className:"w-4 h-4"})};function Ar(ce){const ve=String(ce||"").trim();return ve.length>22&&/^[a-zA-Z0-9_-]+$/.test(ve)}const Pr=g.useMemo(()=>h8(u,a),[u,a]);function Ir(){const ce=[...le];for(const ve of Pr)ce.includes(ve)||ce.push(ve);me(ce),q.success("已将旅程推断标签合并到已选")}return t?s.jsxs(s.Fragment,{children:[s.jsx(Lt,{open:t,onOpenChange:()=>e(),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[92vh] overflow-hidden flex flex-col p-4 sm:p-5",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Ai,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(a==null?void 0:a.phone)&&s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(a==null?void 0:a.isVip)&&s.jsx(Be,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),v?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):a?s.jsxs("div",{className:"flex flex-col min-h-0 flex-1 overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-2.5 p-2.5 bg-[#0a1628] rounded-lg mb-2 shrink-0",children:[s.jsxs("div",{className:"flex gap-2.5 min-w-0 flex-1",children:[s.jsx("div",{className:"w-11 h-11 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-lg text-[#38bdac] shrink-0",children:Ft(a.avatar,a.mbti)&&!$t?s.jsx("img",{src:Ft(a.avatar,a.mbti),className:"w-full h-full rounded-full object-cover",alt:"",onError:()=>kt(!0)}):((Qr=a.nickname)==null?void 0:Qr.charAt(0))||"?"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("h3",{className:"text-base font-bold text-white leading-tight",children:a.nickname}),a.isAdmin&&s.jsx(Be,{className:"bg-purple-500/20 text-purple-400 border-0 text-[10px] py-0",children:"管理员"}),a.hasFullBook&&s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"全书已购"}),a.vipRole&&s.jsx(Be,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0",children:a.vipRole})]}),a.referralCode&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-0.5",children:["推荐码 ",s.jsx("code",{className:"text-[#38bdac]",children:a.referralCode})]}),s.jsxs("div",{className:"mt-1 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-1.5 text-[11px]",children:[s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"昵称"}),s.jsx("p",{className:"text-white truncate",children:D||a.nickname||"—"})]}),s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"手机号"}),s.jsx("p",{className:"text-white truncate",children:z||"—"})]}),s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"微信标识"}),s.jsx("p",{className:"text-white truncate",children:Q||"—"})]}),s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"画像"}),s.jsx("p",{className:"text-[#38bdac] truncate",children:[a.region,a.industry,a.position,a.mbti?`MBTI ${a.mbti}`:""].filter(Boolean).join(" · ")||"未完善"})]})]})]})]}),s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-2 gap-1.5 shrink-0 sm:w-[220px]",children:[s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsx("p",{className:"text-[9px] text-gray-500 uppercase tracking-wide",children:"累计佣金"}),s.jsxs("p",{className:"text-sm font-bold text-[#38bdac] leading-tight",children:["¥",(a.earnings??0).toFixed(2)]}),s.jsx("p",{className:"text-[9px] text-gray-600",children:"推广/分佣入账"})]}),s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsx("p",{className:"text-[9px] text-gray-500",children:"待提现"}),s.jsxs("p",{className:"text-sm font-bold text-yellow-400 leading-tight",children:["¥",(a.pendingEarnings??0).toFixed(2)]}),s.jsx("p",{className:"text-[9px] text-gray-600",children:"未打款部分"})]}),s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsxs("div",{className:"flex items-center justify-between gap-1",children:[s.jsx("p",{className:"text-[9px] text-gray-500",children:"账户余额"}),s.jsx(G,{type:"button",size:"sm",variant:"ghost",className:"h-5 px-1 text-[9px] text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>{we(""),Ue(""),Z(!0)},children:"调整"})]}),s.jsxs("p",{className:"text-sm font-bold text-white leading-tight",children:["¥",((N==null?void 0:N.balance)??0).toFixed(2)]}),s.jsx("p",{className:"text-[9px] text-gray-600",children:"可消费/抵扣"})]}),s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsx("p",{className:"text-[9px] text-gray-500",children:"推荐人数"}),s.jsx("p",{className:"text-sm font-bold text-white leading-tight",children:a.referralCount??0}),s.jsx("p",{className:"text-[9px] text-gray-600",children:a.createdAt?`注册 ${new Date(a.createdAt).toLocaleDateString()}`:"—"})]})]})]}),s.jsxs(Wl,{value:U,onValueChange:P,className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[s.jsxs(Ko,{className:"bg-[#0a1628] border border-gray-700/50 p-0.5 mb-2 flex-wrap h-auto gap-0.5 shrink-0",children:[s.jsx(Ut,{value:"info",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"用户信息"}),s.jsxs(Ut,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:[s.jsx(ma,{className:"w-3 h-3 mr-0.5"}),"旅程与轨迹"]}),s.jsx(Ut,{value:"relations",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"关系链路"}),s.jsx(Ut,{value:"tags",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"标签体系"})]}),s.jsxs(Wt,{value:"info",className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-0.5",children:[s.jsxs("details",{className:"rounded-lg bg-[#0a1628] border border-gray-700/40 p-2 text-[11px] group",children:[s.jsxs("summary",{className:"cursor-pointer text-gray-400 select-none list-none flex items-center gap-1",children:[s.jsx("span",{className:"group-open:text-[#38bdac]",children:"技术标识"}),s.jsx("span",{className:"text-gray-600",children:"(用户ID / OpenID,默认折叠)"})]}),s.jsxs("div",{className:"mt-2 space-y-1.5 text-gray-300 font-mono text-[10px] break-all border-t border-gray-700/30 pt-2",children:[s.jsxs("p",{children:[s.jsx("span",{className:"text-gray-500 not-italic font-sans",children:"用户ID"})," ",a.id]}),s.jsxs("p",{children:[s.jsx("span",{className:"text-gray-500 not-italic font-sans",children:"OpenID"})," ",a.openId||"—"]}),s.jsx("p",{className:"text-gray-500 not-italic font-sans leading-snug",children:"OpenID 为微信用户标识;下方「微信标识」为微信号/wxid,供存客宝归属,与 OpenID 不同。"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-[11px]",children:"昵称"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"昵称",value:D,onChange:ce=>ne(ce.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-[11px]",children:"手机号(可改,点底部保存生效)"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"11 位手机号",value:z,onChange:ce=>O(ce.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-[11px]",children:"微信标识(微信号/wxid,非 OpenID)"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"如 wxid_xxx 或自定义微信号",value:Q,onChange:ce=>re(ce.target.value)})]})]}),(a.region||a.industry||a.position||a.mbti)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5 text-[11px]",children:[a.region&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:[s.jsx(ik,{className:"w-3 h-3 inline mr-0.5"}),a.region]}),a.industry&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:["行业 ",a.industry]}),a.position&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:["职位 ",a.position]}),a.mbti&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#38bdac]/15 text-[#38bdac]",children:["MBTI ",a.mbti]})]}),s.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-amber-500/25",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(Xc,{className:"w-3.5 h-3.5 text-amber-400 shrink-0"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"超级个体"}),a.isVip&&s.jsx(Be,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0 shrink-0",children:a.vipRole||"VIP"})]}),s.jsx(Kt,{className:"scale-90",checked:he.isVip,onCheckedChange:ce=>de(ve=>({...ve,isVip:ce}))})]}),he.isVip&&s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-1.5 mt-2",children:[s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"到期日"}),s.jsx(oe,{type:"date",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",value:he.vipExpireDate,onChange:ce=>de(ve=>({...ve,vipExpireDate:ce.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"角色"}),s.jsxs("select",{className:"w-full bg-[#162840] border border-gray-700 text-white rounded px-1.5 h-7 text-xs",value:he.vipRole,onChange:ce=>de(ve=>({...ve,vipRole:ce.target.value})),children:[s.jsx("option",{value:"",children:"请选择"}),_.map(ce=>s.jsx("option",{value:ce.name,children:ce.name},ce.id))]})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"展示名"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"展示名",value:he.vipName,onChange:ce=>de(ve=>({...ve,vipName:ce.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"项目"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"项目",value:he.vipProject,onChange:ce=>de(ve=>({...ve,vipProject:ce.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"联系方式"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"微信/手机",value:he.vipContact,onChange:ce=>de(ve=>({...ve,vipContact:ce.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5 sm:col-span-2",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"简介"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"简短介绍",value:he.vipBio,onChange:ce=>de(ve=>({...ve,vipBio:ce.target.value}))})]})]})]}),s.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-[#38bdac]/20",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx(Ho,{className:"w-3.5 h-3.5 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"外部资料 · 神射手 / 存客宝(与上方基础信息联动)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-1.5 mb-1.5",children:[s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:手机",value:bn,onChange:ce=>Mn(ce.target.value)}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:微信号",value:Hn,onChange:ce=>rs(ce.target.value)}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:OpenID",value:_t,onChange:ce=>vn(ce.target.value)})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsxs(G,{size:"sm",className:"h-7 text-[11px] px-2 bg-[#38bdac] hover:bg-[#2da396]",onClick:Ki,disabled:pt,children:[pt?s.jsx(Ve,{className:"w-3 h-3 animate-spin"}):s.jsx(hr,{className:"w-3 h-3 mr-0.5"}),"查询回填"]}),s.jsx(G,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2 border-purple-500/40 text-purple-300",onClick:ei,disabled:Ne||!a.phone,children:Ne?"推送…":"推神射手"}),s.jsx(G,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2",onClick:ht,disabled:T||!a.phone,children:T?"同步…":"存客宝同步"})]}),a.ckbSyncedAt&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-1",children:["最近存客宝同步:",new Date(a.ckbSyncedAt).toLocaleString()]}),pn&&s.jsx("p",{className:"mt-1 text-red-400 text-[11px]",children:pn}),fn&&s.jsxs("div",{className:"mt-1.5 grid grid-cols-2 gap-1.5",children:[s.jsxs("div",{className:"p-1.5 bg-[#162840] rounded text-[11px]",children:[s.jsx("span",{className:"text-gray-500",children:"RFM"})," ",s.jsx("span",{className:"text-[#38bdac] font-semibold",children:fn.rfm_score??"—"})]}),s.jsxs("div",{className:"p-1.5 bg-[#162840] rounded text-[11px]",children:[s.jsx("span",{className:"text-gray-500",children:"等级"})," ",s.jsx("span",{className:"text-white font-semibold",children:fn.user_level??"—"})]})]}),We&&s.jsx("p",{className:"mt-1 text-[11px]",children:We.error?s.jsx("span",{className:"text-red-400",children:String(We.error)}):s.jsx("span",{className:"text-green-400",children:"推送成功"})})]}),s.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx(Au,{className:"w-3.5 h-3.5 text-yellow-400"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"修改密码"})]}),s.jsxs("div",{className:"flex flex-col sm:flex-row gap-1.5 sm:items-center",children:[s.jsx(oe,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"新密码 ≥6 位",value:F,onChange:ce=>xe(ce.target.value)}),s.jsx(oe,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"确认密码",value:X,onChange:ce=>V(ce.target.value)}),s.jsx(G,{size:"sm",className:"h-7 text-[11px] shrink-0 bg-yellow-500/20 text-yellow-300 border border-yellow-500/35 hover:bg-yellow-500/30",onClick:Ts,disabled:W||!F||!X,children:W?"保存中":"确认修改"})]})]})]}),s.jsxs(Wt,{value:"journey",className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-0.5",children:[Qe.length>0&&s.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx(mu,{className:"w-3.5 h-3.5 text-amber-400"}),s.jsxs("span",{className:"text-white text-xs font-medium",children:["购买清单(",Qe.length," 笔)"]})]}),s.jsx("div",{className:"space-y-1 max-h-[120px] overflow-y-auto",children:Qe.map((ce,ve)=>s.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-[#162840] rounded text-[11px]",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"text-amber-300",children:ce.productType==="fullbook"||ce.productType==="vip"?"全书/VIP":`章节 ${ce.productId||""}`}),s.jsxs("span",{className:"text-gray-500 ml-2",children:["¥",Number(ce.amount||0).toFixed(2)]})]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:ce.createdAt?new Date(ce.createdAt).toLocaleString("zh-CN"):""})]},ce.orderSn||ve))})]}),s.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg flex flex-col gap-1.5 text-[11px]",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-gray-400",children:[s.jsx(ma,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),s.jsxs("span",{children:["全站埋点共 ",o.length," 条;用于 RFM 与「标签体系」旅程推断"]})]}),Object.keys(u).length>0&&s.jsx("div",{className:"flex flex-wrap gap-1 pt-1 border-t border-gray-700/40",children:Object.entries(u).sort((ce,ve)=>ve[1]-ce[1]).map(([ce,ve])=>s.jsxs(Be,{variant:"outline",className:"text-[10px] border-gray-600 text-gray-300 bg-[#162840] py-0 h-5",children:[u8(ce)," ×",ve]},ce))})]}),s.jsx("div",{className:"space-y-1.5",children:o.length>0?o.map((ce,ve)=>s.jsxs("div",{className:"flex items-start gap-2 p-2 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[s.jsx("div",{className:"w-7 h-7 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[#38bdac]",children:ti(ce.action)}),ve0?((x==null?void 0:x.visits)||[]).map((ce,ve)=>s.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-[#162840] rounded text-xs",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("p",{className:"text-white truncate",children:["第 ",ce.seq||ve+1," 次 · ",ce.referrerNickname||"微信用户",ce.referrerId?`(${ce.referrerId})`:""]}),ce.page?s.jsx("p",{className:"text-gray-500 text-[10px] truncate",children:ce.page}):null]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:ce.visitedAt?new Date(ce.visitedAt).toLocaleString():""})]},`${ce.referrerId||"unknown"}_${ve}`)):s.jsx("p",{className:"text-gray-500 text-sm text-center py-2",children:"暂无来源点击记录"})})]}),s.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ua,{className:"w-3.5 h-3.5 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"推荐的用户"})]}),s.jsxs(Be,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 text-[10px]",children:["共 ",f.length," 人"]})]}),s.jsx("div",{className:"space-y-1 max-h-[min(280px,40vh)] overflow-y-auto",children:f.length>0?f.map((ce,ve)=>{var Zt;const Rt=ce;return s.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-[#162840] rounded text-xs",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx("div",{className:"w-6 h-6 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[10px] text-[#38bdac] shrink-0",children:((Zt=Rt.nickname)==null?void 0:Zt.charAt(0))||"?"}),s.jsx("span",{className:"text-white truncate",children:Rt.nickname})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[Rt.status==="vip"&&s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"已购"}),s.jsx("span",{className:"text-gray-500 text-[10px]",children:Rt.createdAt?new Date(Rt.createdAt).toLocaleDateString():""})]})]},Rt.id||ve)}):s.jsx("p",{className:"text-gray-500 text-sm text-center py-3",children:"暂无推荐用户"})})]})]}),s.jsxs(Wt,{value:"tags",className:"flex-1 min-h-0 overflow-y-auto space-y-3 pr-0.5",children:[s.jsxs("div",{className:"p-2.5 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2 flex-wrap",children:[s.jsx(xu,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"用户标签"}),s.jsx("span",{className:"text-gray-500 text-[11px]",children:"《一场 Soul 的创业实验》维度"})]}),s.jsxs("div",{className:"mb-2 p-2 bg-[#38bdac]/5 border border-[#38bdac]/20 rounded-lg flex items-start gap-2 text-[11px] text-gray-400",children:[s.jsx(Zj,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0 mt-0.5"}),"预设可点选;下方「旅程推断」由轨迹+资料自动算出,可一键并入已选后点弹窗底部保存。"]}),s.jsxs("div",{className:"mb-3 p-2 rounded-lg bg-[#162840]/80 border border-cyan-500/20",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-1.5",children:[s.jsx("span",{className:"text-cyan-300/90 text-xs font-medium",children:"旅程推断标签"}),s.jsx(G,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-cyan-500/40 text-cyan-200 hover:bg-cyan-500/10",disabled:Pr.length===0,onClick:Ir,children:"合并到已选"})]}),Pr.length>0?s.jsx("div",{className:"flex flex-wrap gap-1",children:Pr.map(ce=>s.jsxs(Be,{variant:"outline",className:`text-[10px] py-0 h-5 border-cyan-500/30 ${le.includes(ce)?"bg-cyan-500/15 text-cyan-200":"text-gray-300"}`,children:[le.includes(ce)?"✓ ":"",ce]},ce))}):s.jsx("p",{className:"text-[11px] text-gray-500",children:"暂无推断(无轨迹或行为未命中规则)"})]}),s.jsx("div",{className:"mb-3 space-y-2",children:[{category:"身份类型",tags:["创业者","打工人","自由职业","学生","投资人","合伙人"]},{category:"行业背景",tags:["电商","内容","传统行业","科技/AI","金融","教育","餐饮"]},{category:"痛点标签",tags:["找资源","找方向","找合伙人","想赚钱","想学习","找情感出口"]},{category:"付费意愿",tags:["高意向","已付费","观望中","薅羊毛"]},{category:"MBTI",tags:["ENTJ","INTJ","ENFP","INFP","ENTP","INTP","ESTJ","ISFJ"]}].map(ce=>s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-[11px] mb-1",children:ce.category}),s.jsx("div",{className:"flex flex-wrap gap-1",children:ce.tags.map(ve=>s.jsxs("button",{type:"button",onClick:()=>{le.includes(ve)?kn(ve):me([...le,ve])},className:`px-1.5 py-0.5 rounded text-[11px] border transition-all ${le.includes(ve)?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-transparent border-gray-700 text-gray-500 hover:border-gray-500 hover:text-gray-300"}`,children:[le.includes(ve)?"✓ ":"",ve]},ve))})]},ce.category))}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-2",children:[s.jsx("p",{className:"text-gray-500 text-[11px] mb-1.5",children:"已选标签(需保存修改写入库)"}),s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2 min-h-[28px]",children:[le.map((ce,ve)=>s.jsxs(Be,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1 text-[11px] py-0",children:[ce,s.jsx("button",{type:"button",onClick:()=>kn(ce),className:"ml-1 hover:text-red-400",children:s.jsx(ns,{className:"w-3 h-3"})})]},ve)),le.length===0&&s.jsx("span",{className:"text-gray-600 text-xs",children:"暂未选择"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white flex-1 h-8 text-xs",placeholder:"自定义标签,回车添加",value:I,onChange:ce=>Y(ce.target.value),onKeyDown:ce=>ce.key==="Enter"&&Gt()}),s.jsx(G,{onClick:Gt,className:"bg-[#38bdac] hover:bg-[#2da396] h-8 text-xs px-3",children:"添加"})]})]})]}),(()=>{const ce=a.tags||a.ckbTags||"";let ve=[];try{const Zt=typeof ce=="string"?JSON.parse(ce||"[]"):[];ve=Array.isArray(Zt)?Zt:typeof ce=="string"?ce.split(","):[]}catch{ve=typeof ce=="string"?ce.split(","):[]}const Rt=ve.map(Zt=>String(Zt).trim()).filter(Boolean);return Rt.length===0?null:s.jsxs("div",{className:"p-2.5 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx(xu,{className:"w-3.5 h-3.5 text-purple-400"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"存客宝标签"})]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:Rt.map((Zt,sn)=>s.jsx(Be,{className:"bg-purple-500/20 text-purple-400 border-0 text-[11px] py-0",children:Zt},sn))})]})})()]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3 shrink-0",children:[s.jsxs(G,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ns,{className:"w-4 h-4 mr-2"}),"关闭"]}),s.jsxs(G,{onClick:Pt,disabled:L,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),L?"保存中...":"保存修改"]})]})]}):s.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}),s.jsx(Lt,{open:$,onOpenChange:Z,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsx(Dt,{children:"调整余额"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"调整金额(元)"}),s.jsx(oe,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"正数增加,负数扣减,如 10 或 -5",value:ae,onChange:ce=>we(ce.target.value)})]}),s.jsxs("div",{children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"备注(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"如:活动补偿",value:Fe,onChange:ce=>Ue(ce.target.value)})]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(G,{variant:"outline",onClick:()=>Z(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(G,{onClick:Ms,disabled:wt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:wt?"提交中...":"确认调整"})]})]})})]}):null}function f8(){const t=Ya(),[e,n]=g.useState(!0),[r,a]=g.useState(!0),[i,o]=g.useState(!0),[c,u]=g.useState([]),[h,f]=g.useState([]),[m,x]=g.useState(0),[b,N]=g.useState(0),[w,v]=g.useState(0),[k,T]=g.useState(0),[C,L]=g.useState(null),[R,U]=g.useState(null),[P,z]=g.useState(!1),[O,Q]=g.useState(0),[re,D]=g.useState(!1),[ne,le]=g.useState(null),[me,I]=g.useState("overview"),[Y,F]=g.useState([]),[xe,X]=g.useState(!1),[V,W]=g.useState("today"),[fe,he]=g.useState(null),[de,_]=g.useState(!1),[J,$]=g.useState(!0),[Z,ae]=g.useState(null),[we,Fe]=g.useState(null),[Ue,wt]=g.useState([]),jn=Ne=>{const Me=Ne;if((Me==null?void 0:Me.status)===401)L("登录已过期,请重新登录");else{if((Me==null?void 0:Me.name)==="AbortError")return;L("加载失败,请检查网络或联系管理员")}};async function pt(Ne){var $t,kt;const Me=Ne?{signal:Ne}:void 0;n(!0),L(null);try{const $e=await Le("/api/admin/dashboard/stats",Me);$e!=null&&$e.success&&(x($e.totalUsers??0),N($e.paidOrderCount??0),v($e.totalRevenue??0),T($e.conversionRate??0))}catch($e){if(($e==null?void 0:$e.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",$e);try{const H=await Le("/api/admin/dashboard/overview",Me);H!=null&&H.success&&(x(H.totalUsers??0),N(H.paidOrderCount??0),v(H.totalRevenue??0),T(H.conversionRate??0))}catch(H){jn(H)}}}finally{n(!1)}try{const $e=await Le("/api/admin/balance/summary",Me);$e!=null&&$e.success&&$e.data&&Q($e.data.totalGifted??0)}catch{}try{const $e=await Le("/api/db/ckb-plan-stats",Me);$e!=null&&$e.success&&$e.data?le({ckbTotal:$e.data.ckbTotal??0,withContact:$e.data.withContact??0}):le(null)}catch{le(null)}$(!0);try{const[$e,H]=await Promise.allSettled([Le("/api/db/match-records?stats=true",Me),Le("/api/admin/distribution/overview",Me)]);$e.status==="fulfilled"&&(($t=$e.value)!=null&&$t.success)&&$e.value.data?ae({totalMatches:$e.value.data.totalMatches??0,todayMatches:$e.value.data.todayMatches??0,uniqueUsers:$e.value.data.uniqueUsers??0,paidMatchCount:$e.value.data.paidMatchCount??0}):ae(null),H.status==="fulfilled"&&((kt=H.value)!=null&&kt.success)&&H.value.overview?Fe({todayClicks:H.value.overview.todayClicks??0,todayBindings:H.value.overview.todayBindings??0,todayConversions:H.value.overview.todayConversions??0,monthClicks:H.value.overview.monthClicks??0,monthBindings:H.value.overview.monthBindings??0,monthConversions:H.value.overview.monthConversions??0,totalClicks:H.value.overview.totalClicks??0,totalBindings:H.value.overview.totalBindings??0,totalConversions:H.value.overview.totalConversions??0,conversionRate:H.value.overview.conversionRate}):Fe(null)}catch{ae(null),Fe(null)}finally{$(!1)}try{const $e=await Le("/api/db/vip-members?limit=500",Me);$e!=null&&$e.success&&Array.isArray($e.data)?wt($e.data):wt([])}catch{wt([])}a(!0),o(!0);const We=async()=>{try{const $e=await Le("/api/admin/dashboard/recent-orders?limit=10",Me);if($e!=null&&$e.success&&$e.recentOrders)f($e.recentOrders);else throw new Error("no data")}catch($e){if(($e==null?void 0:$e.name)!=="AbortError")try{const H=await Le("/api/admin/orders?page=1&pageSize=20&status=paid",Me),vt=((H==null?void 0:H.orders)??[]).filter(Ft=>["paid","completed","success"].includes(Ft.status||""));f(vt.slice(0,5))}catch{f([])}}finally{a(!1)}},rt=async()=>{try{const $e=await Le("/api/admin/dashboard/new-users",Me);if($e!=null&&$e.success&&$e.newUsers)u($e.newUsers);else throw new Error("no data")}catch($e){if(($e==null?void 0:$e.name)!=="AbortError")try{const H=await Le("/api/db/users?page=1&pageSize=10",Me);u((H==null?void 0:H.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([We(),rt()])}async function At(Ne){const Me=Ne||V;_(!0);try{const We=await Le(`/api/admin/track/stats?period=${Me}`);We!=null&&We.success&&he({total:We.total??0,byModule:We.byModule??{}})}catch{he(null)}finally{_(!1)}}const fn={home:"首页",chapters:"目录",read:"阅读页",my:"我的",vip:"超级个体",wallet:"钱包",match:"找伙伴",referral:"推广中心",search:"搜索",settings:"设置",about:"关于",member_detail:"成员详情",other:"其他"},Vn={btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",page_view:"页面浏览",share:"分享",purchase:"购买",register:"注册",rule_trigger:"规则触发",view_chapter:"浏览章节",link_click:"链接点击"},pn=Ne=>Ne?Ne.replace(/^part-/,"").replace(/^soulvip_/,"").replace(/^super_?/,"").replace(/^user_/,"").replace(/[_-]+/g," ").trim():"",qt=Ne=>{if(!Ne)return"";const Me=Ne.trim().toLowerCase();if(!Me)return"";const We=Ue.find($t=>{const kt=String($t.id||"").toLowerCase();return kt===Me||kt.includes(Me)||Me.includes(kt)});if(We)return We.name||We.nickname||"";const rt=Ue.find($t=>{const kt=String($t.token||"").toLowerCase();return kt&&(kt===Me||kt.includes(Me)||Me.includes(kt))});return rt&&(rt.name||rt.nickname)||""},bn=Ne=>{if(!Ne)return"未命名点击";const Me=Ne.trim(),We=Me.toLowerCase();if(/^链接头像[_-]/.test(Me)){const $t=pn(Me.replace(/^链接头像[_-]/,""));return $t?`头像:${$t}`:"头像点击"}if(/^member[_-]?detail$/i.test(We)||We.includes("member detail"))return"成员详情";if(/^giftpay$/i.test(We)||We.includes("gift pay"))return"代付入口";if(/^part[-_]/i.test(We))return`章节:${pn(Me)}`;if(We.includes("soulvip")||We.includes("super")){const $t=Me.replace(/^超级个体[::]?/i,"").replace(/^super[_-]?/i,"").replace(/^soulvip[_-]?/i,"").replace(/^user[_-]?/i,"").trim(),kt=qt($t)||qt(pn($t));return kt?`超级个体:${kt}`:`超级个体:${pn($t)}`}if(We.includes("qgdtw")||We.includes("token")||We.includes("0000"))return`对象:${pn(Me)}`;const rt={开始匹配:"开始匹配",mentor:"导师顾问",team:"团队招募",investor:"资源对接",充值:"充值",退款:"退款",wallet:"钱包",设置:"设置",VIP:"VIP会员",推广:"推广中心",目录:"目录",搜索:"搜索",匹配:"找伙伴",settings:"设置",expired:"已过期",active:"活跃",converted:"已转化",fill_profile:"完善资料",register:"注册",purchase:"购买",链接卡若:"链接卡若",更多分享:"更多分享",分享朋友圈文案:"分享朋友圈",选择金额10:"选择金额10元",member_detail:"成员详情",giftPay:"代付入口"};return rt[Me]?rt[Me]:/^[a-z0-9_-]+$/i.test(Me)&&pn(Me)||Me},Mn=Ne=>{const Me=fn[Ne.module]||fn[Ne.page]||Ne.module||Ne.page||"其他",We=Vn[Ne.action]||Ne.action||"点击",rt=bn(Ne.target);return`${Me} · ${We} · ${rt}`};async function Hn(){X(!0);try{const Ne=await Le("/api/admin/super-individual/stats");Ne!=null&&Ne.success&&Array.isArray(Ne.data)&&F(Ne.data)}catch{}finally{X(!1)}}g.useEffect(()=>{const Ne=new AbortController;return pt(Ne.signal),At(),Hn(),()=>{Ne.abort()}},[]);const rs=m,_t=Ne=>{const Me=Ne.productType||"",We=Ne.description||"";if(Me==="balance_recharge")return{title:`余额充值 ¥${typeof Ne.amount=="number"?Ne.amount.toFixed(2):parseFloat(String(Ne.amount||"0")).toFixed(2)}`,subtitle:"余额充值"};if(Me==="gift_pay")return{title:`代付 ¥${typeof Ne.amount=="number"?Ne.amount.toFixed(2):parseFloat(String(Ne.amount||"0")).toFixed(2)}`,subtitle:"好友代付"};if(Me==="gift_pay_batch"){const rt=typeof Ne.amount=="number"?Ne.amount.toFixed(2):parseFloat(String(Ne.amount||"0")).toFixed(2);return{title:We||`代付分享 ¥${rt}`,subtitle:"代付分享"}}if(Me==="section"&&We.includes("代付领取"))return{title:We.replace("代付领取 - ",""),subtitle:"代付领取"};if(We){if(Me==="section"&&We.includes("章节")){if(We.includes("-")){const rt=We.split("-");if(rt.length>=3)return{title:`第${rt[1]}章 第${rt[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:We,subtitle:"章节购买"}}return Me==="fullbook"||We.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:Me==="vip"||We.includes("VIP")?{title:"超级个体开通费用",subtitle:"超级个体"}:Me==="match"||We.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:We,subtitle:Me==="section"?"单章":Me==="fullbook"?"全书":"其他"}}return Me==="section"?{title:`章节 ${Ne.productId||""}`,subtitle:"单章购买"}:Me==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:Me==="vip"?{title:"超级个体开通费用",subtitle:"超级个体"}:Me==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:Me||"其他"}},vn=[{title:"总用户数",value:e?null:rs,sub:null,icon:Kn,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:e?null:`¥${(w??0).toFixed(2)}`,sub:O>0?`含代付 ¥${O.toFixed(2)}`:null,icon:Of,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:b,sub:null,icon:mu,color:"text-purple-400",bg:"bg-purple-500/20",link:"/orders"},{title:"转化率",value:e?null:`${typeof k=="number"?k.toFixed(1):0}%`,sub:null,icon:ur,color:"text-orange-400",bg:"bg-orange-500/20",link:"/distribution"},{title:"存客宝获客",value:ne?ne.ckbTotal??0:null,sub:(ne==null?void 0:ne.withContact)!=null?`含联系方式 ${ne.withContact} 人`:null,icon:Qc,color:"text-cyan-400",bg:"bg-cyan-500/20",link:"/users?tab=leads"},{title:"伙伴&推广协同",value:J?null:((Z==null?void 0:Z.totalMatches)??0)+((we==null?void 0:we.totalClicks)??0),sub:J?null:`找伙伴 ${(Z==null?void 0:Z.totalMatches)??0} / 推广 ${(we==null?void 0:we.totalClicks)??0}`,icon:nu,color:"text-emerald-400",bg:"bg-emerald-500/20",link:"/find-partner"}];return s.jsxs("div",{className:"p-8 w-full",children:[s.jsx("h1",{className:"text-2xl font-bold mb-8 text-white",children:"数据概览"}),C&&s.jsxs("div",{className:"mb-6 px-4 py-3 rounded-lg bg-amber-500/20 border border-amber-500/50 text-amber-200 text-sm flex items-center justify-between",children:[s.jsx("span",{children:C}),s.jsx("button",{type:"button",onClick:()=>pt(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),s.jsx("div",{className:"grid gap-6 mb-8 grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 xl:grid-cols-6",children:vn.map((Ne,Me)=>s.jsxs(De,{className:"min-w-0 bg-[#0f2137] border-gray-700/50 shadow-xl cursor-pointer hover:border-[#38bdac]/50 transition-colors group",onClick:()=>Ne.link&&t(Ne.link),children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsx(ut,{className:"text-sm font-medium text-gray-400",children:Ne.title}),s.jsx("div",{className:`p-2 rounded-lg ${Ne.bg}`,children:s.jsx(Ne.icon,{className:`w-4 h-4 ${Ne.color}`})})]}),s.jsx(_e,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-white min-h-8 flex items-center",children:Ne.value!=null?Ne.value:s.jsxs("span",{className:"inline-flex items-center gap-2 text-gray-500",children:[s.jsx(Ve,{className:"w-4 h-4 animate-spin"}),"加载中"]})}),Ne.sub&&s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:Ne.sub})]}),s.jsx(Li,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},Me))}),s.jsxs("div",{className:"flex gap-2 mb-6 mt-2",children:[s.jsx("button",{type:"button",onClick:()=>I("overview"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${me==="overview"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"数据概览"}),s.jsx("button",{type:"button",onClick:()=>I("tags"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${me==="tags"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"用户标签点击统计"}),s.jsx("button",{type:"button",onClick:()=>I("super"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${me==="super"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"超级个体统计"})]}),me==="overview"&&s.jsxs("div",{className:"space-y-8",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsx(ut,{className:"text-white",children:"找伙伴 × 推广中心(共统计)"}),s.jsxs("button",{type:"button",onClick:()=>pt(),disabled:J,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新共统计",children:[s.jsx(Ve,{className:`w-3.5 h-3.5 ${J?"animate-spin":""}`}),"刷新"]})]}),s.jsxs(_e,{children:[J&&!Z&&!we?s.jsxs("div",{className:"flex items-center justify-center py-10 text-gray-500",children:[s.jsx(Ve,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-6 gap-4",children:[s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"找伙伴总匹配"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(Z==null?void 0:Z.totalMatches)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"找伙伴今日"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(Z==null?void 0:Z.todayMatches)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"找伙伴用户数"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(Z==null?void 0:Z.uniqueUsers)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"推广总点击"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(we==null?void 0:we.totalClicks)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"推广总绑定"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(we==null?void 0:we.totalBindings)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"推广总转化"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(we==null?void 0:we.totalConversions)??0})]})]}),(we==null?void 0:we.conversionRate)&&s.jsxs("p",{className:"text-xs text-gray-500 mt-3",children:["推广转化率:",we.conversionRate]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsx(ut,{className:"text-white",children:"最近订单"}),s.jsxs("button",{type:"button",onClick:()=>pt(),disabled:r||i,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新",children:[r||i?s.jsx(Ve,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(Ve,{className:"w-3.5 h-3.5"}),"刷新"]})]}),s.jsx(_e,{children:s.jsx("div",{className:"space-y-3",children:r&&h.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Ve,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[h.slice(0,re?10:4).map(Ne=>{var kt;const Me=Ne.referrerId?c.find($e=>$e.id===Ne.referrerId):void 0,We=Ne.referralCode||(Me==null?void 0:Me.referralCode)||(Me==null?void 0:Me.nickname)||(Ne.referrerId?String(Ne.referrerId).slice(0,8):""),rt=_t(Ne),$t=Ne.userNickname||((kt=c.find($e=>$e.id===Ne.userId))==null?void 0:kt.nickname)||"匿名用户";return s.jsxs("div",{className:"flex items-start justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30 hover:border-[#38bdac]/30 transition-colors",children:[s.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[Ne.userAvatar?s.jsx("img",{src:Ne.userAvatar,alt:$t,className:"w-9 h-9 rounded-full object-cover shrink-0 mt-0.5",onError:$e=>{$e.currentTarget.style.display="none";const H=$e.currentTarget.nextElementSibling;H&&H.classList.remove("hidden")}}):null,s.jsx("div",{className:`w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] shrink-0 mt-0.5 ${Ne.userAvatar?"hidden":""}`,children:$t.charAt(0)}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("button",{type:"button",onClick:()=>{Ne.userId&&(U(Ne.userId),z(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:$t}),s.jsx("span",{className:"text-gray-600",children:"·"}),s.jsx("span",{className:"text-sm font-medium text-white truncate",title:rt.title,children:rt.title})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[rt.subtitle&&rt.subtitle!=="章节购买"&&s.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:rt.subtitle}),s.jsx("span",{children:new Date(Ne.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),We&&s.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",We]})]})]}),s.jsxs("div",{className:"text-right ml-4 shrink-0",children:[s.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(Ne.amount).toFixed(2)]}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:Ne.paymentMethod||"微信"})]})]},Ne.id)}),h.length>4&&!re&&s.jsx("button",{type:"button",onClick:()=>D(!0),className:"w-full py-2 text-sm text-[#38bdac] hover:text-[#2da396] border border-dashed border-gray-600 rounded-lg hover:border-[#38bdac]/50 transition-colors",children:"展开更多"}),h.length===0&&!r&&s.jsxs("div",{className:"text-center py-12",children:[s.jsx(mu,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(dt,{children:s.jsx(ut,{className:"text-white",children:"新注册用户"})}),s.jsx(_e,{children:s.jsx("div",{className:"space-y-3",children:i&&c.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Ve,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[c.slice(0,5).map(Ne=>{var Me;return s.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:((Me=Ne.nickname)==null?void 0:Me.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("button",{type:"button",onClick:()=>{U(Ne.id),z(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:Ne.nickname||"匿名用户"}),s.jsx("p",{className:"text-xs text-gray-500",children:Ne.phone||"未绑定手机"})]})]}),s.jsx("p",{className:"text-xs text-gray-400",children:Ne.createdAt?new Date(Ne.createdAt).toLocaleDateString():"-"})]},Ne.id)}),c.length===0&&!i&&s.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})})]})]})]}),me==="tags"&&s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(nu,{className:"w-5 h-5 text-[#38bdac]"}),"分类标签点击统计"]}),s.jsx("div",{className:"flex items-center gap-2",children:["today","week","month","all"].map(Ne=>s.jsx("button",{type:"button",onClick:()=>{W(Ne),At(Ne)},className:`px-3 py-1 text-xs rounded-full transition-colors ${V===Ne?"bg-[#38bdac] text-white":"bg-gray-700/50 text-gray-400 hover:bg-gray-700"}`,children:{today:"今日",week:"本周",month:"本月",all:"全部"}[Ne]},Ne))})]}),s.jsx(_e,{children:de&&!fe?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(Ve,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):fe&&Object.keys(fe.byModule).length>0?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("p",{className:"text-sm text-gray-400",children:["总点击 ",s.jsx("span",{className:"text-white font-bold text-lg",children:fe.total})," 次"]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Object.entries(fe.byModule).sort((Ne,Me)=>Me[1].reduce((We,rt)=>We+rt.count,0)-Ne[1].reduce((We,rt)=>We+rt.count,0)).slice(0,5).map(([Ne,Me])=>{const We=Me.reduce((rt,$t)=>rt+$t.count,0);return s.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("span",{className:"text-sm font-medium text-[#38bdac]",children:fn[Ne]||Ne}),s.jsxs("span",{className:"text-xs text-gray-500",children:[We," 次"]})]}),s.jsx("div",{className:"space-y-2",children:Me.sort((rt,$t)=>$t.count-rt.count).slice(0,8).map((rt,$t)=>{const kt=Mn(rt);return s.jsxs("div",{className:"flex items-center justify-between text-xs",children:[s.jsx("span",{className:"text-gray-300 truncate mr-2",title:kt,children:kt}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx("div",{className:"w-16 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac] rounded-full",style:{width:`${We>0?rt.count/We*100:0}%`}})}),s.jsx("span",{className:"text-gray-400 w-8 text-right",children:rt.count})]})]},$t)})})]},Ne)})})]}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(nu,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无点击数据"}),s.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"小程序端接入埋点后,数据将在此实时展示"})]})})]}),me==="super"&&s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(nu,{className:"w-5 h-5 text-amber-400"}),"超级个体点击统计"]}),s.jsxs(G,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300 h-8",onClick:Hn,disabled:xe,children:[s.jsx(Ve,{className:`w-3.5 h-3.5 mr-1 ${xe?"animate-spin":""}`}),"刷新"]})]}),s.jsx(_e,{children:xe&&Y.length===0?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(Ve,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):Y.length>0?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-xs text-gray-400 border-b border-gray-700/50",children:[s.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"排名"}),s.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"超级个体"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"总点击"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"独立访客"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"人均点击"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",title:"该用户绑定 @人物 后,指向其 person 的留资独立人数",children:"获客(去重)"}),s.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"手机号"})]})}),s.jsx("tbody",{children:Y.map((Ne,Me)=>s.jsxs("tr",{className:"border-b border-gray-700/30 hover:bg-[#0a1628]/80",children:[s.jsx("td",{className:"py-2 px-3 text-gray-500 text-xs",children:Me+1}),s.jsx("td",{className:"py-2 px-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[Ne.avatar?s.jsx("img",{src:Ne.avatar,alt:"",className:"w-7 h-7 rounded-full object-cover"}):s.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-700 flex items-center justify-center text-xs text-gray-400",children:"?"}),s.jsx("button",{type:"button",className:"text-amber-400 hover:text-amber-300 hover:underline text-left text-sm truncate max-w-[160px]",onClick:()=>t(`/users?search=${encodeURIComponent(Ne.nickname||Ne.userId)}`),title:"点击跳转用户管理",children:Ne.nickname||Ne.userId})]})}),s.jsx("td",{className:"py-2 px-3 text-center text-white font-bold",children:Ne.clicks}),s.jsx("td",{className:"py-2 px-3 text-center text-[#38bdac]",children:Ne.uniqueClicks}),s.jsx("td",{className:"py-2 px-3 text-center text-gray-400",children:Ne.uniqueClicks>0?(Ne.clicks/Ne.uniqueClicks).toFixed(1):"-"}),s.jsx("td",{className:"py-2 px-3 text-center text-green-400 text-xs font-medium",children:typeof Ne.leadCount=="number"?Ne.leadCount:0}),s.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs",children:Ne.phone||"-"})]},Ne.userId))})]})}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(nu,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无超级个体点击数据"}),s.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"小程序首页的超级个体被用户点击后,数据将展示在此"})]})})]}),s.jsx(py,{open:P,onClose:()=>{z(!1),U(null)},userId:R,onUserUpdated:()=>pt()})]})}const fs=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx("table",{ref:n,className:zt("w-full caption-bottom text-sm",t),...e})}));fs.displayName="Table";const ps=g.forwardRef(({className:t,...e},n)=>s.jsx("thead",{ref:n,className:zt("[&_tr]:border-b",t),...e}));ps.displayName="TableHeader";const ms=g.forwardRef(({className:t,...e},n)=>s.jsx("tbody",{ref:n,className:zt("[&_tr:last-child]:border-0",t),...e}));ms.displayName="TableBody";const xt=g.forwardRef(({className:t,...e},n)=>s.jsx("tr",{ref:n,className:zt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));xt.displayName="TableRow";const Se=g.forwardRef(({className:t,...e},n)=>s.jsx("th",{ref:n,className:zt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));Se.displayName="TableHead";const je=g.forwardRef(({className:t,...e},n)=>s.jsx("td",{ref:n,className:zt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));je.displayName="TableCell";function qa(t,e){const[n,r]=g.useState(t);return g.useEffect(()=>{const a=setTimeout(()=>r(t),e);return()=>clearTimeout(a)},[t,e]),n}function xs({page:t,totalPages:e,total:n,pageSize:r,onPageChange:a,onPageSizeChange:i,pageSizeOptions:o=[10,20,50,100]}){return e<=1&&!i?null:s.jsxs("div",{className:"flex items-center justify-between gap-4 py-4 px-5 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[s.jsxs("span",{children:["共 ",n," 条"]}),i&&s.jsx("select",{value:r,onChange:c=>i(Number(c.target.value)),className:"bg-[#0f2137] border border-gray-600 rounded px-2 py-1 text-gray-300 text-sm",children:o.map(c=>s.jsxs("option",{value:c,children:[c," 条/页"]},c))})]}),e>1&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>a(1),disabled:t<=1,className:"px-2 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"首页"}),s.jsx("button",{type:"button",onClick:()=>a(t-1),disabled:t<=1,className:"px-3 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"上一页"}),s.jsxs("span",{className:"px-3 py-1 text-gray-400 text-sm",children:[t," / ",e]}),s.jsx("button",{type:"button",onClick:()=>a(t+1),disabled:t>=e,className:"px-3 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"下一页"}),s.jsx("button",{type:"button",onClick:()=>a(e),disabled:t>=e,className:"px-2 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"末页"})]})]})}function p8(){const[t,e]=g.useState([]),[n,r]=g.useState([]),[a,i]=g.useState(0),[o,c]=g.useState(0),[u,h]=g.useState(0),[f,m]=g.useState(1),[x,b]=g.useState(10),[N,w]=g.useState(""),v=qa(N,300),[k,T]=g.useState("all"),[C,L]=g.useState(!0),[R,U]=g.useState(null),[P,z]=g.useState(null),[O,Q]=g.useState(""),[re,D]=g.useState(!1);async function ne(){L(!0),U(null);try{const X=k==="all"?"":k==="completed"?"completed":k,V=new URLSearchParams({page:String(f),pageSize:String(x),...X&&{status:X},...v&&{search:v}}),[W,fe]=await Promise.all([Le(`/api/admin/orders?${V}`),Le("/api/db/users?page=1&pageSize=500")]);W!=null&&W.success&&(e(W.orders||[]),i(W.total??0),c(W.totalRevenue??0),h(W.todayRevenue??0)),fe!=null&&fe.success&&fe.users&&r(fe.users)}catch(X){console.error("加载订单失败",X),U("加载订单失败,请检查网络后重试")}finally{L(!1)}}g.useEffect(()=>{m(1)},[v,k]),g.useEffect(()=>{ne()},[f,x,v,k]);const le=X=>{var V;return X.userNickname||((V=n.find(W=>W.id===X.userId))==null?void 0:V.nickname)||"匿名用户"},me=X=>{var V;return((V=n.find(W=>W.id===X))==null?void 0:V.phone)||"-"},I=X=>{const V=X.productType||X.type||"",W=X.description||"";if(V==="balance_recharge")return{name:`余额充值 ¥${Number(X.amount||0).toFixed(2)}`,type:"余额充值"};if(W){if(V==="section"&&(W.includes("章节")||W.includes("代付领取"))){if(W.includes("代付领取"))return{name:W.replace("代付领取 - ",""),type:"代付领取"};if(W.includes("-")){const fe=W.split("-");if(fe.length>=3)return{name:`第${fe[1]}章 第${fe[2]}节`,type:"《一场Soul的创业实验》"}}return{name:W,type:"章节购买"}}return V==="fullbook"||W.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:V==="vip"||W.includes("VIP")?{name:"超级个体开通费用",type:"超级个体"}:V==="match"||W.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:W,type:"其他"}}return V==="section"?{name:`章节 ${X.productId||X.sectionId||""}`,type:"单章"}:V==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:V==="vip"?{name:"超级个体开通费用",type:"超级个体"}:V==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:V||"其他"}},Y=Math.ceil(a/x)||1;async function F(){var X;if(!(!(P!=null&&P.orderSn)&&!(P!=null&&P.id))){D(!0),U(null);try{const V=await tn("/api/admin/orders/refund",{orderSn:P.orderSn||P.id,reason:O||void 0});V!=null&&V.success?(z(null),Q(""),ne()):U((V==null?void 0:V.error)||"退款失败")}catch(V){const W=V;U(((X=W==null?void 0:W.data)==null?void 0:X.error)||"退款失败,请检查网络后重试")}finally{D(!1)}}}function xe(){if(t.length===0){q.info("暂无数据可导出");return}const X=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],V=t.map(_=>{const J=I(_);return[_.orderSn||_.id||"",le(_),me(_.userId),J.name,Number(_.amount||0).toFixed(2),_.paymentMethod==="wechat"?"微信支付":_.paymentMethod==="balance"?"余额支付":_.paymentMethod==="alipay"?"支付宝":_.paymentMethod||"微信支付",_.status==="refunded"?"已退款":_.status==="paid"||_.status==="completed"?"已完成":_.status==="pending"||_.status==="created"?"待支付":"已失败",_.status==="refunded"&&_.refundReason?_.refundReason:"-",_.referrerEarnings?Number(_.referrerEarnings).toFixed(2):"-",_.createdAt?new Date(_.createdAt).toLocaleString("zh-CN"):""].join(",")}),W="\uFEFF"+[X.join(","),...V].join(`
-`),fe=new Blob([W],{type:"text/csv;charset=utf-8"}),he=URL.createObjectURL(fe),de=document.createElement("a");de.href=he,de.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,de.click(),URL.revokeObjectURL(he)}return s.jsxs("div",{className:"p-8 w-full",children:[R&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[s.jsx("span",{children:R}),s.jsx("button",{type:"button",onClick:()=>U(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"订单管理"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",t.length," 笔订单"]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs(G,{variant:"outline",onClick:ne,disabled:C,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${C?"animate-spin":""}`}),"刷新"]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"text-gray-400",children:"总收入:"}),s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",o.toFixed(2)]}),s.jsx("span",{className:"text-gray-600",children:"|"}),s.jsx("span",{className:"text-gray-400",children:"今日:"}),s.jsxs("span",{className:"text-[#FFD700] font-bold",children:["¥",u.toFixed(2)]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsxs("div",{className:"relative flex-1 max-w-md",children:[s.jsx(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:N,onChange:X=>w(X.target.value)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(sk,{className:"w-4 h-4 text-gray-400"}),s.jsxs("select",{value:k,onChange:X=>T(X.target.value),className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"pending",children:"待支付"}),s.jsx("option",{value:"created",children:"已创建"}),s.jsx("option",{value:"failed",children:"已失败"}),s.jsx("option",{value:"refunded",children:"已退款"})]})]}),s.jsxs(G,{variant:"outline",onClick:xe,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(GT,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(_e,{className:"p-0",children:C?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"订单号"}),s.jsx(Se,{className:"text-gray-400",children:"用户"}),s.jsx(Se,{className:"text-gray-400",children:"商品"}),s.jsx(Se,{className:"text-gray-400",children:"金额"}),s.jsx(Se,{className:"text-gray-400",children:"支付方式"}),s.jsx(Se,{className:"text-gray-400",children:"状态"}),s.jsx(Se,{className:"text-gray-400",children:"退款原因"}),s.jsx(Se,{className:"text-gray-400",children:"分销佣金"}),s.jsx(Se,{className:"text-gray-400",children:"下单时间"}),s.jsx(Se,{className:"text-gray-400",children:"操作"})]})}),s.jsxs(ms,{children:[t.map(X=>{const V=I(X);return s.jsxs(xt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsxs(je,{className:"font-mono text-xs text-gray-400",children:[(X.orderSn||X.id||"").slice(0,12),"..."]}),s.jsx(je,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[le(X),X.paymentMethod==="gift_pay"&&s.jsx(Be,{className:"bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 border-0 text-xs",children:"代付领取"}),X.payerUserId&&X.paymentMethod!=="gift_pay"&&s.jsx(Be,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"代付"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:me(X.userId)}),X.payerUserId&&X.payerNickname&&s.jsxs("p",{className:"text-amber-400/80 text-xs mt-0.5",children:[X.paymentMethod==="gift_pay"?"赠送人:":"代付人:",X.payerNickname]})]})}),s.jsx(je,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[V.name,(X.productType||X.type)==="vip"&&s.jsx(Be,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"超级个体"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:V.type})]})}),s.jsxs(je,{className:"text-[#38bdac] font-bold",children:["¥",Number(X.amount||0).toFixed(2)]}),s.jsx(je,{className:"text-gray-300",children:X.paymentMethod==="wechat"?"微信支付":X.paymentMethod==="balance"?"余额支付":X.paymentMethod==="alipay"?"支付宝":X.paymentMethod||"微信支付"}),s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[X.status==="refunded"?s.jsx(Be,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):X.status==="paid"||X.status==="completed"?s.jsx(Be,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):X.status==="pending"||X.status==="created"?s.jsx(Be,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):s.jsx(Be,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"}),(X.status==="paid"||X.status==="completed")&&(X.webhookPushStatus==="sent"?s.jsx(Be,{className:"bg-emerald-500/20 text-emerald-300 hover:bg-emerald-500/20 border-0",children:"已推送"}):s.jsx(Be,{className:"bg-orange-500/20 text-orange-300 hover:bg-orange-500/20 border-0",children:"待补推"}))]})}),s.jsx(je,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:X.refundReason,children:X.status==="refunded"&&X.refundReason?X.refundReason:"-"}),s.jsx(je,{className:"text-[#FFD700]",children:X.referrerEarnings?`¥${Number(X.referrerEarnings).toFixed(2)}`:"-"}),s.jsx(je,{className:"text-gray-400 text-sm",children:new Date(X.createdAt).toLocaleString("zh-CN")}),s.jsx(je,{children:(X.status==="paid"||X.status==="completed")&&X.paymentMethod!=="balance"&&s.jsxs(G,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{z(X),Q("")},children:[s.jsx(lk,{className:"w-3 h-3 mr-1"}),"退款"]})})]},X.id)}),t.length===0&&s.jsx(xt,{children:s.jsx(je,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),s.jsx(xs,{page:f,totalPages:Y,total:a,pageSize:x,onPageChange:m,onPageSizeChange:X=>{b(X),m(1)}})]})})}),s.jsx(Lt,{open:!!P,onOpenChange:X=>!X&&z(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:"订单退款"})}),P&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",P.orderSn||P.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(P.amount||0).toFixed(2)]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:O,onChange:X=>Q(X.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>z(null),disabled:re,children:"取消"}),s.jsx(G,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:F,disabled:re,children:re?"退款中...":"确认退款"})]})]})})]})}const el=g.forwardRef(({className:t,...e},n)=>s.jsx("textarea",{className:zt("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:n,...e}));el.displayName="Textarea";const oN=["INTJ","INTP","ENTJ","ENTP","INFJ","INFP","ENFJ","ENFP","ISTJ","ISFJ","ESTJ","ESFJ","ISTP","ISFP","ESTP","ESFP"],M2={INTJ:{title:"战略家",group:"NT",mood:"sharp"},INTP:{title:"逻辑学家",group:"NT",mood:"calm"},ENTJ:{title:"指挥官",group:"NT",mood:"sharp"},ENTP:{title:"辩论家",group:"NT",mood:"playful"},INFJ:{title:"提倡者",group:"NF",mood:"warm"},INFP:{title:"调停者",group:"NF",mood:"warm"},ENFJ:{title:"主人公",group:"NF",mood:"warm"},ENFP:{title:"竞选者",group:"NF",mood:"playful"},ISTJ:{title:"物流师",group:"SJ",mood:"calm"},ISFJ:{title:"守卫者",group:"SJ",mood:"warm"},ESTJ:{title:"总经理",group:"SJ",mood:"sharp"},ESFJ:{title:"执政官",group:"SJ",mood:"warm"},ISTP:{title:"鉴赏家",group:"SP",mood:"sharp"},ISFP:{title:"探险家",group:"SP",mood:"playful"},ESTP:{title:"企业家",group:"SP",mood:"playful"},ESFP:{title:"表演者",group:"SP",mood:"playful"}};function m8(t){switch(t){case"NT":return{bg:"#0d1424",body:"#c89a2c",accent:"#ffd66b",hair:"#6d540f",line:"#111827"};case"NF":return{bg:"#0a1721",body:"#2e9f7c",accent:"#84e9c9",hair:"#2d6a4f",line:"#11212a"};case"SJ":return{bg:"#101828",body:"#4f8cb8",accent:"#9bd4ff",hair:"#2e4a66",line:"#111f2d"};case"SP":return{bg:"#161225",body:"#8b6bc0",accent:"#ccb3ff",hair:"#574183",line:"#211832"};default:return{bg:"#0e1422",body:"#38bdac",accent:"#7ee7db",hair:"#1f6f66",line:"#10202d"}}}function x8(t){switch(t){case"sharp":return{eye:"M222 222 L242 220 M270 220 L290 222",brow:"M218 210 L244 202 M268 202 L294 210",mouth:"M234 256 Q256 246 278 256",tilt:-5};case"warm":return{eye:"M222 224 Q232 230 242 224 M270 224 Q280 230 290 224",brow:"M220 210 Q232 206 244 210 M268 210 Q280 206 292 210",mouth:"M232 254 Q256 272 280 254",tilt:2};case"playful":return{eye:"M222 224 Q232 236 242 224 M270 224 Q280 236 290 224",brow:"M220 210 Q234 200 246 208 M266 208 Q278 200 292 210",mouth:"M232 256 Q256 266 280 250",tilt:8};default:return{eye:"M222 224 Q232 220 242 224 M270 224 Q280 220 290 224",brow:"M220 210 Q232 208 244 210 M268 210 Q280 208 292 210",mouth:"M236 256 Q256 260 276 256",tilt:0}}}function g8(t){switch(t){case"sharp":return"M168 370 L206 300 L256 332 L306 300 L344 370 L306 392 L256 374 L206 392 Z";case"warm":return"M166 368 Q188 318 226 314 L256 340 L286 314 Q324 318 346 368 L314 392 Q286 404 256 396 Q226 404 198 392 Z";case"playful":return"M164 370 L198 304 L252 332 L318 300 L350 374 L316 394 L258 378 L196 396 Z";default:return"M166 370 L202 306 L256 336 L310 306 L346 370 L310 392 L256 380 L202 392 Z"}}function lN(t){const e=M2[t],n=m8(e.group),r=x8(e.mood),a=g8(e.mood),i=`
+For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return g.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},MR="DialogDescriptionWarning",AR=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${e2(MR).contentName}}.`;return g.useEffect(()=>{var i;const a=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");e&&a&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},PR=Bk,IR=Uk,RR=Wk,LR=Kk,OR=Gk,DR=Qk,_R=Xk;function Lt(t){return s.jsx(PR,{"data-slot":"dialog",...t})}function $R(t){return s.jsx(IR,{...t})}const t2=g.forwardRef(({className:t,...e},n)=>s.jsx(RR,{ref:n,className:zt("fixed inset-0 z-50 bg-black/50",t),...e}));t2.displayName="DialogOverlay";const It=g.forwardRef(({className:t,children:e,showCloseButton:n=!0,...r},a)=>s.jsxs($R,{children:[s.jsx(t2,{}),s.jsxs(LR,{ref:a,"aria-describedby":void 0,className:zt("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border bg-background p-6 shadow-lg",t),...r,children:[e,n&&s.jsxs(_R,{className:"absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[s.jsx(ss,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));It.displayName="DialogContent";function Ot({className:t,...e}){return s.jsx("div",{className:zt("flex flex-col gap-2 text-center sm:text-left",t),...e})}function nn({className:t,...e}){return s.jsx("div",{className:zt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Dt(t){return s.jsx(OR,{className:"text-lg font-semibold leading-none",...t})}function Wo(t){return s.jsx(DR,{className:"text-sm text-muted-foreground",...t})}const zR=pk("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 transition-colors",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Be({className:t,variant:e,asChild:n=!1,...r}){const a=n?uk:"span";return s.jsx(a,{className:zt(zR({variant:e}),t),...r})}var FR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],BR=FR.reduce((t,e)=>{const n=dk(`Primitive.${e}`),r=g.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),VR="Label",n2=g.forwardRef((t,e)=>s.jsx(BR.label,{...t,ref:e,onMouseDown:n=>{var a;n.target.closest("button, input, select, textarea")||((a=t.onMouseDown)==null||a.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));n2.displayName=VR;var s2=n2;const te=g.forwardRef(({className:t,...e},n)=>s.jsx(s2,{ref:n,className:zt("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));te.displayName=s2.displayName;function dy(t){const e=t+"CollectionProvider",[n,r]=Zo(e),[a,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:v,children:k}=w,T=qs.useRef(null),C=qs.useRef(new Map).current;return s.jsx(a,{scope:v,itemMap:C,collectionRef:T,children:k})};o.displayName=e;const c=t+"CollectionSlot",u=Pu(c),h=qs.forwardRef((w,v)=>{const{scope:k,children:T}=w,C=i(c,k),L=Xt(v,C.collectionRef);return s.jsx(u,{ref:L,children:T})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",x=Pu(f),b=qs.forwardRef((w,v)=>{const{scope:k,children:T,...C}=w,L=qs.useRef(null),R=Xt(v,L),U=i(f,k);return qs.useEffect(()=>(U.itemMap.set(L,{ref:L,...C}),()=>void U.itemMap.delete(L))),s.jsx(x,{[m]:"",ref:R,children:T})});b.displayName=f;function N(w){const v=i(t+"CollectionConsumer",w);return qs.useCallback(()=>{const T=v.collectionRef.current;if(!T)return[];const C=Array.from(T.querySelectorAll(`[${m}]`));return Array.from(v.itemMap.values()).sort((U,P)=>C.indexOf(U.ref.current)-C.indexOf(P.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:h,ItemSlot:b},N,r]}var HR=g.createContext(void 0);function Bp(t){const e=g.useContext(HR);return t||e||"ltr"}var Qx="rovingFocusGroup.onEntryFocus",UR={bubbles:!1,cancelable:!0},Gu="RovingFocusGroup",[Yg,r2,WR]=dy(Gu),[KR,a2]=Zo(Gu,[WR]),[qR,GR]=KR(Gu),i2=g.forwardRef((t,e)=>s.jsx(Yg.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(Yg.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(JR,{...t,ref:e})})}));i2.displayName=Gu;var JR=g.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...m}=t,x=g.useRef(null),b=Xt(e,x),N=Bp(i),[w,v]=Hl({prop:o,defaultProp:c??null,onChange:u,caller:Gu}),[k,T]=g.useState(!1),C=Uo(h),L=r2(n),R=g.useRef(!1),[U,P]=g.useState(0);return g.useEffect(()=>{const F=x.current;if(F)return F.addEventListener(Qx,C),()=>F.removeEventListener(Qx,C)},[C]),s.jsx(qR,{scope:n,orientation:r,dir:N,loop:a,currentTabStopId:w,onItemFocus:g.useCallback(F=>v(F),[v]),onItemShiftTab:g.useCallback(()=>T(!0),[]),onFocusableItemAdd:g.useCallback(()=>P(F=>F+1),[]),onFocusableItemRemove:g.useCallback(()=>P(F=>F-1),[]),children:s.jsx(Tt.div,{tabIndex:k||U===0?-1:0,"data-orientation":r,...m,ref:b,style:{outline:"none",...t.style},onMouseDown:kt(t.onMouseDown,()=>{R.current=!0}),onFocus:kt(t.onFocus,F=>{const O=!R.current;if(F.target===F.currentTarget&&O&&!k){const Q=new CustomEvent(Qx,UR);if(F.currentTarget.dispatchEvent(Q),!Q.defaultPrevented){const re=L().filter(I=>I.focusable),D=re.find(I=>I.active),ne=re.find(I=>I.id===w),me=[D,ne,...re].filter(Boolean).map(I=>I.ref.current);c2(me,f)}}R.current=!1}),onBlur:kt(t.onBlur,()=>T(!1))})})}),o2="RovingFocusGroupItem",l2=g.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...c}=t,u=_o(),h=i||u,f=GR(o2,n),m=f.currentTabStopId===h,x=r2(n),{onFocusableItemAdd:b,onFocusableItemRemove:N,currentTabStopId:w}=f;return g.useEffect(()=>{if(r)return b(),()=>N()},[r,b,N]),s.jsx(Yg.ItemSlot,{scope:n,id:h,focusable:r,active:a,children:s.jsx(Tt.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:kt(t.onMouseDown,v=>{r?f.onItemFocus(h):v.preventDefault()}),onFocus:kt(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:kt(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const k=XR(v,f.orientation,f.dir);if(k!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let C=x().filter(L=>L.focusable).map(L=>L.ref.current);if(k==="last")C.reverse();else if(k==="prev"||k==="next"){k==="prev"&&C.reverse();const L=C.indexOf(v.currentTarget);C=f.loop?ZR(C,L+1):C.slice(L+1)}setTimeout(()=>c2(C))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:w!=null}):o})})});l2.displayName=o2;var QR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function YR(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function XR(t,e,n){const r=YR(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return QR[r]}function c2(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function ZR(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var e8=i2,t8=l2,Vp="Tabs",[n8]=Zo(Vp,[a2]),d2=a2(),[s8,uy]=n8(Vp),u2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=Bp(c),[m,x]=Hl({prop:r,onChange:a,defaultProp:i??"",caller:Vp});return s.jsx(s8,{scope:n,baseId:_o(),value:m,onValueChange:x,orientation:o,dir:f,activationMode:u,children:s.jsx(Tt.div,{dir:f,"data-orientation":o,...h,ref:e})})});u2.displayName=Vp;var h2="TabsList",f2=g.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...a}=t,i=uy(h2,n),o=d2(n);return s.jsx(e8,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(Tt.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:e})})});f2.displayName=h2;var p2="TabsTrigger",m2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...i}=t,o=uy(p2,n),c=d2(n),u=y2(o.baseId,r),h=b2(o.baseId,r),f=r===o.value;return s.jsx(t8,{asChild:!0,...c,focusable:!a,active:f,children:s.jsx(Tt.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":h,"data-state":f?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:u,...i,ref:e,onMouseDown:kt(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(r):m.preventDefault()}),onKeyDown:kt(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(r)}),onFocus:kt(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!a&&m&&o.onValueChange(r)})})})});m2.displayName=p2;var x2="TabsContent",g2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=t,c=uy(x2,n),u=y2(c.baseId,r),h=b2(c.baseId,r),f=r===c.value,m=g.useRef(f);return g.useEffect(()=>{const x=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(x)},[]),s.jsx(qu,{present:a||f,children:({present:x})=>s.jsx(Tt.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!x,id:h,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:m.current?"0s":void 0},children:x&&i})})});g2.displayName=x2;function y2(t,e){return`${t}-trigger-${e}`}function b2(t,e){return`${t}-content-${e}`}var r8=u2,v2=f2,N2=m2,w2=g2;const Wl=r8,Ko=g.forwardRef(({className:t,...e},n)=>s.jsx(v2,{ref:n,className:zt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));Ko.displayName=v2.displayName;const Ut=g.forwardRef(({className:t,...e},n)=>s.jsx(N2,{ref:n,className:zt("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...e}));Ut.displayName=N2.displayName;const Wt=g.forwardRef(({className:t,...e},n)=>s.jsx(w2,{ref:n,className:zt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));Wt.displayName=w2.displayName;function hy(t){const e=g.useRef({value:t,previous:t});return g.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function fy(t){const[e,n]=g.useState(void 0);return $s(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const i=a[0];let o,c;if("borderBoxSize"in i){const u=i.borderBoxSize,h=Array.isArray(u)?u[0]:u;o=h.inlineSize,c=h.blockSize}else o=t.offsetWidth,c=t.offsetHeight;n({width:o,height:c})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var Hp="Switch",[a8]=Zo(Hp),[i8,o8]=a8(Hp),j2=g.forwardRef((t,e)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:i,required:o,disabled:c,value:u="on",onCheckedChange:h,form:f,...m}=t,[x,b]=g.useState(null),N=Xt(e,C=>b(C)),w=g.useRef(!1),v=x?f||!!x.closest("form"):!0,[k,T]=Hl({prop:a,defaultProp:i??!1,onChange:h,caller:Hp});return s.jsxs(i8,{scope:n,checked:k,disabled:c,children:[s.jsx(Tt.button,{type:"button",role:"switch","aria-checked":k,"aria-required":o,"data-state":E2(k),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:N,onClick:kt(t.onClick,C=>{T(L=>!L),v&&(w.current=C.isPropagationStopped(),w.current||C.stopPropagation())})}),v&&s.jsx(C2,{control:x,bubbles:!w.current,name:r,value:u,checked:k,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});j2.displayName=Hp;var k2="SwitchThumb",S2=g.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,a=o8(k2,n);return s.jsx(Tt.span,{"data-state":E2(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:e})});S2.displayName=k2;var l8="SwitchBubbleInput",C2=g.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...a},i)=>{const o=g.useRef(null),c=Xt(o,i),u=hy(n),h=fy(e);return g.useEffect(()=>{const f=o.current;if(!f)return;const m=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(m,"checked").set;if(u!==n&&b){const N=new Event("click",{bubbles:r});b.call(f,n),f.dispatchEvent(N)}},[u,n,r]),s.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:c,style:{...a.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});C2.displayName=l8;function E2(t){return t?"checked":"unchecked"}var T2=j2,c8=S2;const Kt=g.forwardRef(({className:t,...e},n)=>s.jsx(T2,{className:zt("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#38bdac] focus-visible:ring-offset-2 focus-visible:ring-offset-[#0a1628] disabled:cursor-not-allowed disabled:opacity-50 data-[state=unchecked]:bg-gray-600 data-[state=checked]:bg-[#38bdac]",t),...e,ref:n,children:s.jsx(c8,{className:zt("pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Kt.displayName=T2.displayName;const d8={view_chapter:"浏览章节",purchase:"购买",match:"派对匹配",login:"登录",register:"注册",share:"分享",bind_phone:"绑定手机",bind_wechat:"绑定微信",fill_profile:"完善资料",fill_avatar:"设置头像",visit_page:"访问页面",first_pay:"首次付款",vip_activate:"开通会员",click_super:"点击超级个体",lead_submit:"提交留资",withdraw:"申请提现",referral_bind:"绑定推荐人",card_click:"点击名片",btn_click:"按钮点击",tab_click:"切换标签",nav_click:"导航点击",page_view:"页面浏览",search:"搜索"};function u8(t){return d8[t]||t||"行为"}function h8(t,e){const n=new Set,r=a=>(t[a]??0)>0;return(r("purchase")||r("first_pay")||r("vip_activate"))&&n.add("已付费"),(r("lead_submit")||r("click_super"))&&n.add("高意向"),r("view_chapter")&&n.add("想学习"),r("match")&&n.add("找合伙人"),r("withdraw")&&n.add("有提现行为"),r("referral_bind")&&n.add("推广参与"),(r("fill_profile")||r("fill_avatar")||r("bind_phone"))&&n.add("资料完善中"),e!=null&&e.hasFullBook&&n.add("全书读者"),e!=null&&e.isVip&&n.add("VIP会员"),e!=null&&e.mbti&&/^[EI][NS][FT][JP]$/i.test(e.mbti)&&n.add(String(e.mbti).toUpperCase()),Array.from(n)}function py({open:t,onClose:e,userId:n,onUserUpdated:r}){var Qr,Vs,Qs,pr,Ys,ka;const[a,i]=g.useState(null),[o,c]=g.useState([]),[u,h]=g.useState({}),[f,m]=g.useState([]),[x,b]=g.useState(null),[N,w]=g.useState(null),[v,k]=g.useState(!1),[T,C]=g.useState(!1),[L,R]=g.useState(!1),[U,P]=g.useState("info"),[F,O]=g.useState(""),[Q,re]=g.useState(""),[D,ne]=g.useState(""),[le,me]=g.useState([]),[I,Y]=g.useState(""),[B,xe]=g.useState(""),[X,V]=g.useState(""),[W,fe]=g.useState(!1),[he,de]=g.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[_,J]=g.useState([]),[$,Z]=g.useState(!1),[ae,we]=g.useState(""),[Fe,Ue]=g.useState(""),[wt,jn]=g.useState(!1),[pt,At]=g.useState(!1),[fn,Vn]=g.useState(null),[pn,qt]=g.useState(null),[bn,Mn]=g.useState(""),[Hn,as]=g.useState(""),[_t,vn]=g.useState(""),[Ne,Me]=g.useState(!1),[We,rt]=g.useState(null),[$t,St]=g.useState(!1),[$e,H]=g.useState({}),[Qe,vt]=g.useState([]);g.useEffect(()=>{t&&n&&(St(!1),P("info"),Vn(null),qt(null),rt(null),xe(""),V(""),yt(),Le("/api/db/vip-roles").then(ce=>{ce!=null&&ce.success&&ce.data&&J(ce.data)}).catch(()=>{}))},[t,n]),g.useEffect(()=>{t&&Le("/api/admin/mbti-avatars").then(ce=>{ce!=null&&ce.avatars&&typeof ce.avatars=="object"?H(ce.avatars):H({})}).catch(()=>H({}))},[t]);const Ft=(ce,ve)=>{const Rt=(ce||"").trim();if(Rt)return ya(Rt);const Zt=(ve||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(Zt)?($e[Zt]||"").trim():""};async function yt(){if(n){k(!0);try{const ce=await Le(`/api/db/users?id=${encodeURIComponent(n)}`);if(ce!=null&&ce.success&&ce.user){const ve=ce.user;i(ve),O(ve.phone||""),re(ve.wechatId||""),ne(ve.nickname||""),Mn(ve.phone||""),as(ve.wechatId||""),vn(ve.openId||"");try{me(typeof ve.tags=="string"?JSON.parse(ve.tags||"[]"):[])}catch{me([])}de({isVip:!!(ve.isVip??!1),vipExpireDate:ve.vipExpireDate?String(ve.vipExpireDate).slice(0,10):"",vipRole:String(ve.vipRole??""),vipName:String(ve.vipName??""),vipProject:String(ve.vipProject??""),vipContact:String(ve.vipContact??""),vipBio:String(ve.vipBio??"")})}try{const ve=await Le(`/api/admin/user/track?userId=${encodeURIComponent(n)}&limit=100`);if(ve!=null&&ve.success){h(ve.stats&&typeof ve.stats=="object"?ve.stats:{});const Rt=ve.tracks||[];c(Rt.map(Zt=>({...Zt,actionLabel:Zt.actionLabel||Zt.action,timeAgo:Zt.timeAgo||""})))}else h({}),c([])}catch{h({}),c([])}try{const ve=await Le(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);ve!=null&&ve.success?(m(ve.referrals||[]),b(ve.inboundSource||null)):(m([]),b(null))}catch{m([]),b(null)}try{const ve=await Le(`/api/admin/users/${encodeURIComponent(n)}/balance`);ve!=null&&ve.success&&ve.data?w(ve.data):w(null)}catch{w(null)}try{const ve=await Le(`/api/orders?userId=${encodeURIComponent(n)}&status=paid&pageSize=50`);ve!=null&&ve.success&&ve.orders?vt(ve.orders):vt([])}catch{vt([])}}catch(ce){console.error("Load user detail error:",ce)}finally{k(!1)}}}async function ht(){if(!(a!=null&&a.phone)){q.info("用户未绑定手机号,无法同步");return}C(!0);try{const ce=await bt("/api/ckb/sync",{action:"full_sync",phone:a.phone,userId:a.id});ce!=null&&ce.success?(q.success("同步成功"),yt()):q.error("同步失败: "+(ce==null?void 0:ce.error))}catch(ce){console.error("Sync CKB error:",ce),q.error("同步失败")}finally{C(!1)}}async function Pt(){if(a){if(he.isVip&&!he.vipExpireDate.trim()){q.error("开启 VIP 请填写有效到期日");return}R(!0);try{const ce={id:a.id,phone:F.trim()||void 0,wechatId:Q.trim(),nickname:D||void 0,tags:JSON.stringify(le),isVip:he.isVip,vipExpireDate:he.isVip?he.vipExpireDate:void 0,vipRole:he.vipRole||void 0,vipName:he.vipName||void 0,vipProject:he.vipProject||void 0,vipContact:he.vipContact||void 0,vipBio:he.vipBio||void 0},ve=await tn("/api/db/users",ce);ve!=null&&ve.success?(q.success("保存成功"),yt(),r==null||r()):q.error("保存失败: "+(ve==null?void 0:ve.error))}catch(ce){console.error("Save user error:",ce),q.error("保存失败")}finally{R(!1)}}}const Gt=()=>{I&&!le.includes(I)&&(me([...le,I]),Y(""))},kn=ce=>me(le.filter(ve=>ve!==ce));async function Ts(){if(a){if(!B){q.error("请输入新密码");return}if(B!==X){q.error("两次密码不一致");return}if(B.length<6){q.error("密码至少 6 位");return}fe(!0);try{const ce=await tn("/api/db/users",{id:a.id,password:B});ce!=null&&ce.success?(q.success("修改成功"),xe(""),V("")):q.error("修改失败: "+((ce==null?void 0:ce.error)||""))}catch{q.error("修改失败")}finally{fe(!1)}}}async function Ms(){if(!a)return;const ce=parseFloat(ae);if(Number.isNaN(ce)||ce===0){q.error("请输入有效金额(正数增加、负数扣减)");return}jn(!0);try{const ve=await bt(`/api/admin/users/${a.id}/balance/adjust`,{amount:ce,remark:Fe||void 0});ve!=null&&ve.success?(q.success("余额已调整"),Z(!1),we(""),Ue(""),yt(),r==null||r()):q.error("调整失败: "+((ve==null?void 0:ve.error)||""))}catch{q.error("调整失败")}finally{jn(!1)}}async function Ki(){if(!bn&&!_t&&!Hn){qt("请至少输入手机号、微信号或 OpenID 中的一项");return}At(!0),qt(null),Vn(null);try{const ce=new URLSearchParams;bn&&ce.set("phone",bn),_t&&ce.set("openId",_t),Hn&&ce.set("wechatId",Hn);const ve=await Le(`/api/admin/shensheshou/query?${ce}`);ve!=null&&ve.success&&ve.data?(Vn(ve.data),a&&await ja(ve.data)):qt((ve==null?void 0:ve.error)||"未查询到数据,该用户可能未在神射手收录")}catch(ce){console.error("SSS query error:",ce),qt("请求失败,请检查神射手接口配置")}finally{At(!1)}}async function ja(ce){if(a)try{await bt("/api/admin/shensheshou/enrich",{userId:a.id,phone:bn||a.phone||"",openId:_t||a.openId||"",wechatId:Hn||a.wechatId||""}),yt()}catch(ve){console.error("SSS enrich error:",ve)}}async function ei(){if(a){Me(!0),rt(null);try{const ce=Array.from(new Set(o.filter(is=>is.action==="view_chapter"||is.action==="purchase"||is.action==="first_pay").map(is=>(is.chapterTitle||is.target||"").trim()).filter(Boolean))).slice(0,12),ve={viewChapter:u.view_chapter||0,purchase:u.purchase||0,firstPay:u.first_pay||0},Rt=ce.length>0?`意向章节:${ce.join("、")}`:"",Zt={users:[{phone:a.phone||"",name:a.nickname||"",openId:a.openId||"",tags:le,purchaseIntent:ve,purchaseIntentChapters:ce,remark:Rt}]},sn=await bt("/api/admin/shensheshou/ingest",Zt);sn!=null&&sn.success&&sn.data?rt(sn.data):rt({error:(sn==null?void 0:sn.error)||"推送失败"})}catch(ce){console.error("SSS ingest error:",ce),rt({error:"请求失败"})}finally{Me(!1)}}}const ti=ce=>{const Rt={view_chapter:ur,purchase:mu,match:qn,login:Ai,register:Ai,share:Ua,bind_phone:_1,bind_wechat:HM,fill_profile:xu,fill_avatar:Ai,visit_page:ma,first_pay:mu,vip_activate:Xc,click_super:qn,lead_submit:_1,withdraw:Au,referral_bind:Ua,card_click:Ai,btn_click:Ho,tab_click:ma,nav_click:ma,page_view:ma,search:ma}[ce]||Vg;return s.jsx(Rt,{className:"w-4 h-4"})};function Ar(ce){const ve=String(ce||"").trim();return ve.length>22&&/^[a-zA-Z0-9_-]+$/.test(ve)}const Pr=g.useMemo(()=>h8(u,a),[u,a]);function Ir(){const ce=[...le];for(const ve of Pr)ce.includes(ve)||ce.push(ve);me(ce),q.success("已将旅程推断标签合并到已选")}return t?s.jsxs(s.Fragment,{children:[s.jsx(Lt,{open:t,onOpenChange:()=>e(),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[92vh] overflow-hidden flex flex-col p-4 sm:p-5",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Ai,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(a==null?void 0:a.phone)&&s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(a==null?void 0:a.isVip)&&s.jsx(Be,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),v?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):a?s.jsxs("div",{className:"flex flex-col min-h-0 flex-1 overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-2.5 p-2.5 bg-[#0a1628] rounded-lg mb-2 shrink-0",children:[s.jsxs("div",{className:"flex gap-2.5 min-w-0 flex-1",children:[s.jsx("div",{className:"w-11 h-11 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-lg text-[#38bdac] shrink-0",children:Ft(a.avatar,a.mbti)&&!$t?s.jsx("img",{src:Ft(a.avatar,a.mbti),className:"w-full h-full rounded-full object-cover",alt:"",onError:()=>St(!0)}):((Qr=a.nickname)==null?void 0:Qr.charAt(0))||"?"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("h3",{className:"text-base font-bold text-white leading-tight",children:a.nickname}),a.isAdmin&&s.jsx(Be,{className:"bg-purple-500/20 text-purple-400 border-0 text-[10px] py-0",children:"管理员"}),a.hasFullBook&&s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"全书已购"}),a.vipRole&&s.jsx(Be,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0",children:a.vipRole})]}),a.referralCode&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-0.5",children:["推荐码 ",s.jsx("code",{className:"text-[#38bdac]",children:a.referralCode})]}),s.jsxs("div",{className:"mt-1 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-1.5 text-[11px]",children:[s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"昵称"}),s.jsx("p",{className:"text-white truncate",children:D||a.nickname||"—"})]}),s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"手机号"}),s.jsx("p",{className:"text-white truncate",children:F||"—"})]}),s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"微信标识"}),s.jsx("p",{className:"text-white truncate",children:Q||"—"})]}),s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"画像"}),s.jsx("p",{className:"text-[#38bdac] truncate",children:[a.region,a.industry,a.position,a.mbti?`MBTI ${a.mbti}`:""].filter(Boolean).join(" · ")||"未完善"})]})]})]})]}),s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-2 gap-1.5 shrink-0 sm:w-[220px]",children:[s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsx("p",{className:"text-[9px] text-gray-500 uppercase tracking-wide",children:"累计佣金"}),s.jsxs("p",{className:"text-sm font-bold text-[#38bdac] leading-tight",children:["¥",(a.earnings??0).toFixed(2)]}),s.jsx("p",{className:"text-[9px] text-gray-600",children:"推广/分佣入账"})]}),s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsx("p",{className:"text-[9px] text-gray-500",children:"待提现"}),s.jsxs("p",{className:"text-sm font-bold text-yellow-400 leading-tight",children:["¥",(a.pendingEarnings??0).toFixed(2)]}),s.jsx("p",{className:"text-[9px] text-gray-600",children:"未打款部分"})]}),s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsxs("div",{className:"flex items-center justify-between gap-1",children:[s.jsx("p",{className:"text-[9px] text-gray-500",children:"账户余额"}),s.jsx(G,{type:"button",size:"sm",variant:"ghost",className:"h-5 px-1 text-[9px] text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>{we(""),Ue(""),Z(!0)},children:"调整"})]}),s.jsxs("p",{className:"text-sm font-bold text-white leading-tight",children:["¥",((N==null?void 0:N.balance)??0).toFixed(2)]}),s.jsx("p",{className:"text-[9px] text-gray-600",children:"可消费/抵扣"})]}),s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsx("p",{className:"text-[9px] text-gray-500",children:"推荐人数"}),s.jsx("p",{className:"text-sm font-bold text-white leading-tight",children:a.referralCount??0}),s.jsx("p",{className:"text-[9px] text-gray-600",children:a.createdAt?`注册 ${new Date(a.createdAt).toLocaleDateString()}`:"—"})]})]})]}),s.jsxs(Wl,{value:U,onValueChange:P,className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[s.jsxs(Ko,{className:"bg-[#0a1628] border border-gray-700/50 p-0.5 mb-2 flex-wrap h-auto gap-0.5 shrink-0",children:[s.jsx(Ut,{value:"info",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"用户信息"}),s.jsxs(Ut,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:[s.jsx(ma,{className:"w-3 h-3 mr-0.5"}),"旅程与轨迹"]}),s.jsx(Ut,{value:"relations",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"关系链路"}),s.jsx(Ut,{value:"tags",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"标签体系"})]}),s.jsxs(Wt,{value:"info",className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-0.5",children:[s.jsxs("details",{className:"rounded-lg bg-[#0a1628] border border-gray-700/40 p-2 text-[11px] group",children:[s.jsxs("summary",{className:"cursor-pointer text-gray-400 select-none list-none flex items-center gap-1",children:[s.jsx("span",{className:"group-open:text-[#38bdac]",children:"技术标识"}),s.jsx("span",{className:"text-gray-600",children:"(用户ID / OpenID,默认折叠)"})]}),s.jsxs("div",{className:"mt-2 space-y-1.5 text-gray-300 font-mono text-[10px] break-all border-t border-gray-700/30 pt-2",children:[s.jsxs("p",{children:[s.jsx("span",{className:"text-gray-500 not-italic font-sans",children:"用户ID"})," ",a.id]}),s.jsxs("p",{children:[s.jsx("span",{className:"text-gray-500 not-italic font-sans",children:"OpenID"})," ",a.openId||"—"]}),s.jsx("p",{className:"text-gray-500 not-italic font-sans leading-snug",children:"OpenID 为微信用户标识;下方「微信标识」为微信号/wxid,供存客宝归属,与 OpenID 不同。"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-[11px]",children:"昵称"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"昵称",value:D,onChange:ce=>ne(ce.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-[11px]",children:"手机号(可改,点底部保存生效)"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"11 位手机号",value:F,onChange:ce=>O(ce.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-[11px]",children:"微信标识(微信号/wxid,非 OpenID)"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"如 wxid_xxx 或自定义微信号",value:Q,onChange:ce=>re(ce.target.value)})]})]}),(a.region||a.industry||a.position||a.mbti)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5 text-[11px]",children:[a.region&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:[s.jsx(ik,{className:"w-3 h-3 inline mr-0.5"}),a.region]}),a.industry&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:["行业 ",a.industry]}),a.position&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:["职位 ",a.position]}),a.mbti&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#38bdac]/15 text-[#38bdac]",children:["MBTI ",a.mbti]})]}),s.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-amber-500/25",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(Xc,{className:"w-3.5 h-3.5 text-amber-400 shrink-0"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"超级个体"}),a.isVip&&s.jsx(Be,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0 shrink-0",children:a.vipRole||"VIP"})]}),s.jsx(Kt,{className:"scale-90",checked:he.isVip,onCheckedChange:ce=>de(ve=>({...ve,isVip:ce}))})]}),he.isVip&&s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-1.5 mt-2",children:[s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"到期日"}),s.jsx(oe,{type:"date",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",value:he.vipExpireDate,onChange:ce=>de(ve=>({...ve,vipExpireDate:ce.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"角色"}),s.jsxs("select",{className:"w-full bg-[#162840] border border-gray-700 text-white rounded px-1.5 h-7 text-xs",value:he.vipRole,onChange:ce=>de(ve=>({...ve,vipRole:ce.target.value})),children:[s.jsx("option",{value:"",children:"请选择"}),_.map(ce=>s.jsx("option",{value:ce.name,children:ce.name},ce.id))]})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"展示名"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"展示名",value:he.vipName,onChange:ce=>de(ve=>({...ve,vipName:ce.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"项目"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"项目",value:he.vipProject,onChange:ce=>de(ve=>({...ve,vipProject:ce.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"联系方式"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"微信/手机",value:he.vipContact,onChange:ce=>de(ve=>({...ve,vipContact:ce.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5 sm:col-span-2",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"简介"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"简短介绍",value:he.vipBio,onChange:ce=>de(ve=>({...ve,vipBio:ce.target.value}))})]})]})]}),s.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-[#38bdac]/20",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx(Ho,{className:"w-3.5 h-3.5 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"外部资料 · 神射手 / 存客宝(与上方基础信息联动)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-1.5 mb-1.5",children:[s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:手机",value:bn,onChange:ce=>Mn(ce.target.value)}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:微信号",value:Hn,onChange:ce=>as(ce.target.value)}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:OpenID",value:_t,onChange:ce=>vn(ce.target.value)})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsxs(G,{size:"sm",className:"h-7 text-[11px] px-2 bg-[#38bdac] hover:bg-[#2da396]",onClick:Ki,disabled:pt,children:[pt?s.jsx(Ve,{className:"w-3 h-3 animate-spin"}):s.jsx(hr,{className:"w-3 h-3 mr-0.5"}),"查询回填"]}),s.jsx(G,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2 border-purple-500/40 text-purple-300",onClick:ei,disabled:Ne||!a.phone,children:Ne?"推送…":"推神射手"}),s.jsx(G,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2",onClick:ht,disabled:T||!a.phone,children:T?"同步…":"存客宝同步"})]}),a.ckbSyncedAt&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-1",children:["最近存客宝同步:",new Date(a.ckbSyncedAt).toLocaleString()]}),pn&&s.jsx("p",{className:"mt-1 text-red-400 text-[11px]",children:pn}),fn&&s.jsxs("div",{className:"mt-1.5 grid grid-cols-2 gap-1.5",children:[s.jsxs("div",{className:"p-1.5 bg-[#162840] rounded text-[11px]",children:[s.jsx("span",{className:"text-gray-500",children:"RFM"})," ",s.jsx("span",{className:"text-[#38bdac] font-semibold",children:fn.rfm_score??"—"})]}),s.jsxs("div",{className:"p-1.5 bg-[#162840] rounded text-[11px]",children:[s.jsx("span",{className:"text-gray-500",children:"等级"})," ",s.jsx("span",{className:"text-white font-semibold",children:fn.user_level??"—"})]})]}),We&&s.jsx("p",{className:"mt-1 text-[11px]",children:We.error?s.jsx("span",{className:"text-red-400",children:String(We.error)}):s.jsx("span",{className:"text-green-400",children:"推送成功"})})]}),s.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx(Au,{className:"w-3.5 h-3.5 text-yellow-400"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"修改密码"})]}),s.jsxs("div",{className:"flex flex-col sm:flex-row gap-1.5 sm:items-center",children:[s.jsx(oe,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"新密码 ≥6 位",value:B,onChange:ce=>xe(ce.target.value)}),s.jsx(oe,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"确认密码",value:X,onChange:ce=>V(ce.target.value)}),s.jsx(G,{size:"sm",className:"h-7 text-[11px] shrink-0 bg-yellow-500/20 text-yellow-300 border border-yellow-500/35 hover:bg-yellow-500/30",onClick:Ts,disabled:W||!B||!X,children:W?"保存中":"确认修改"})]})]})]}),s.jsxs(Wt,{value:"journey",className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-0.5",children:[Qe.length>0&&s.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx(mu,{className:"w-3.5 h-3.5 text-amber-400"}),s.jsxs("span",{className:"text-white text-xs font-medium",children:["购买清单(",Qe.length," 笔)"]})]}),s.jsx("div",{className:"space-y-1 max-h-[120px] overflow-y-auto",children:Qe.map((ce,ve)=>s.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-[#162840] rounded text-[11px]",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"text-amber-300",children:ce.productType==="fullbook"||ce.productType==="vip"?"全书/VIP":`章节 ${ce.productId||""}`}),s.jsxs("span",{className:"text-gray-500 ml-2",children:["¥",Number(ce.amount||0).toFixed(2)]})]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:ce.createdAt?new Date(ce.createdAt).toLocaleString("zh-CN"):""})]},ce.orderSn||ve))})]}),s.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg flex flex-col gap-1.5 text-[11px]",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-gray-400",children:[s.jsx(ma,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),s.jsxs("span",{children:["全站埋点共 ",o.length," 条;用于 RFM 与「标签体系」旅程推断"]})]}),Object.keys(u).length>0&&s.jsx("div",{className:"flex flex-wrap gap-1 pt-1 border-t border-gray-700/40",children:Object.entries(u).sort((ce,ve)=>ve[1]-ce[1]).map(([ce,ve])=>s.jsxs(Be,{variant:"outline",className:"text-[10px] border-gray-600 text-gray-300 bg-[#162840] py-0 h-5",children:[u8(ce)," ×",ve]},ce))})]}),s.jsx("div",{className:"space-y-1.5",children:o.length>0?o.map((ce,ve)=>s.jsxs("div",{className:"flex items-start gap-2 p-2 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[s.jsx("div",{className:"w-7 h-7 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[#38bdac]",children:ti(ce.action)}),ve0?((x==null?void 0:x.visits)||[]).map((ce,ve)=>s.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-[#162840] rounded text-xs",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("p",{className:"text-white truncate",children:["第 ",ce.seq||ve+1," 次 · ",ce.referrerNickname||"微信用户",ce.referrerId?`(${ce.referrerId})`:""]}),ce.page?s.jsx("p",{className:"text-gray-500 text-[10px] truncate",children:ce.page}):null]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:ce.visitedAt?new Date(ce.visitedAt).toLocaleString():""})]},`${ce.referrerId||"unknown"}_${ve}`)):s.jsx("p",{className:"text-gray-500 text-sm text-center py-2",children:"暂无来源点击记录"})})]}),s.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ua,{className:"w-3.5 h-3.5 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"推荐的用户"})]}),s.jsxs(Be,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 text-[10px]",children:["共 ",f.length," 人"]})]}),s.jsx("div",{className:"space-y-1 max-h-[min(280px,40vh)] overflow-y-auto",children:f.length>0?f.map((ce,ve)=>{var Zt;const Rt=ce;return s.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-[#162840] rounded text-xs",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx("div",{className:"w-6 h-6 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[10px] text-[#38bdac] shrink-0",children:((Zt=Rt.nickname)==null?void 0:Zt.charAt(0))||"?"}),s.jsx("span",{className:"text-white truncate",children:Rt.nickname})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[Rt.status==="vip"&&s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"已购"}),s.jsx("span",{className:"text-gray-500 text-[10px]",children:Rt.createdAt?new Date(Rt.createdAt).toLocaleDateString():""})]})]},Rt.id||ve)}):s.jsx("p",{className:"text-gray-500 text-sm text-center py-3",children:"暂无推荐用户"})})]})]}),s.jsxs(Wt,{value:"tags",className:"flex-1 min-h-0 overflow-y-auto space-y-3 pr-0.5",children:[s.jsxs("div",{className:"p-2.5 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2 flex-wrap",children:[s.jsx(xu,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"用户标签"}),s.jsx("span",{className:"text-gray-500 text-[11px]",children:"《一场 Soul 的创业实验》维度"})]}),s.jsxs("div",{className:"mb-2 p-2 bg-[#38bdac]/5 border border-[#38bdac]/20 rounded-lg flex items-start gap-2 text-[11px] text-gray-400",children:[s.jsx(Zj,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0 mt-0.5"}),"预设可点选;下方「旅程推断」由轨迹+资料自动算出,可一键并入已选后点弹窗底部保存。"]}),s.jsxs("div",{className:"mb-3 p-2 rounded-lg bg-[#162840]/80 border border-cyan-500/20",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-1.5",children:[s.jsx("span",{className:"text-cyan-300/90 text-xs font-medium",children:"旅程推断标签"}),s.jsx(G,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-cyan-500/40 text-cyan-200 hover:bg-cyan-500/10",disabled:Pr.length===0,onClick:Ir,children:"合并到已选"})]}),Pr.length>0?s.jsx("div",{className:"flex flex-wrap gap-1",children:Pr.map(ce=>s.jsxs(Be,{variant:"outline",className:`text-[10px] py-0 h-5 border-cyan-500/30 ${le.includes(ce)?"bg-cyan-500/15 text-cyan-200":"text-gray-300"}`,children:[le.includes(ce)?"✓ ":"",ce]},ce))}):s.jsx("p",{className:"text-[11px] text-gray-500",children:"暂无推断(无轨迹或行为未命中规则)"})]}),s.jsx("div",{className:"mb-3 space-y-2",children:[{category:"身份类型",tags:["创业者","打工人","自由职业","学生","投资人","合伙人"]},{category:"行业背景",tags:["电商","内容","传统行业","科技/AI","金融","教育","餐饮"]},{category:"痛点标签",tags:["找资源","找方向","找合伙人","想赚钱","想学习","找情感出口"]},{category:"付费意愿",tags:["高意向","已付费","观望中","薅羊毛"]},{category:"MBTI",tags:["ENTJ","INTJ","ENFP","INFP","ENTP","INTP","ESTJ","ISFJ"]}].map(ce=>s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-[11px] mb-1",children:ce.category}),s.jsx("div",{className:"flex flex-wrap gap-1",children:ce.tags.map(ve=>s.jsxs("button",{type:"button",onClick:()=>{le.includes(ve)?kn(ve):me([...le,ve])},className:`px-1.5 py-0.5 rounded text-[11px] border transition-all ${le.includes(ve)?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-transparent border-gray-700 text-gray-500 hover:border-gray-500 hover:text-gray-300"}`,children:[le.includes(ve)?"✓ ":"",ve]},ve))})]},ce.category))}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-2",children:[s.jsx("p",{className:"text-gray-500 text-[11px] mb-1.5",children:"已选标签(需保存修改写入库)"}),s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2 min-h-[28px]",children:[le.map((ce,ve)=>s.jsxs(Be,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1 text-[11px] py-0",children:[ce,s.jsx("button",{type:"button",onClick:()=>kn(ce),className:"ml-1 hover:text-red-400",children:s.jsx(ss,{className:"w-3 h-3"})})]},ve)),le.length===0&&s.jsx("span",{className:"text-gray-600 text-xs",children:"暂未选择"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white flex-1 h-8 text-xs",placeholder:"自定义标签,回车添加",value:I,onChange:ce=>Y(ce.target.value),onKeyDown:ce=>ce.key==="Enter"&&Gt()}),s.jsx(G,{onClick:Gt,className:"bg-[#38bdac] hover:bg-[#2da396] h-8 text-xs px-3",children:"添加"})]})]})]}),(()=>{const ce=a.tags||a.ckbTags||"";let ve=[];try{const Zt=typeof ce=="string"?JSON.parse(ce||"[]"):[];ve=Array.isArray(Zt)?Zt:typeof ce=="string"?ce.split(","):[]}catch{ve=typeof ce=="string"?ce.split(","):[]}const Rt=ve.map(Zt=>String(Zt).trim()).filter(Boolean);return Rt.length===0?null:s.jsxs("div",{className:"p-2.5 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx(xu,{className:"w-3.5 h-3.5 text-purple-400"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"存客宝标签"})]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:Rt.map((Zt,sn)=>s.jsx(Be,{className:"bg-purple-500/20 text-purple-400 border-0 text-[11px] py-0",children:Zt},sn))})]})})()]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3 shrink-0",children:[s.jsxs(G,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ss,{className:"w-4 h-4 mr-2"}),"关闭"]}),s.jsxs(G,{onClick:Pt,disabled:L,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),L?"保存中...":"保存修改"]})]})]}):s.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}),s.jsx(Lt,{open:$,onOpenChange:Z,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsx(Dt,{children:"调整余额"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"调整金额(元)"}),s.jsx(oe,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"正数增加,负数扣减,如 10 或 -5",value:ae,onChange:ce=>we(ce.target.value)})]}),s.jsxs("div",{children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"备注(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"如:活动补偿",value:Fe,onChange:ce=>Ue(ce.target.value)})]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(G,{variant:"outline",onClick:()=>Z(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(G,{onClick:Ms,disabled:wt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:wt?"提交中...":"确认调整"})]})]})})]}):null}function f8(){const t=Ya(),[e,n]=g.useState(!0),[r,a]=g.useState(!0),[i,o]=g.useState(!0),[c,u]=g.useState([]),[h,f]=g.useState([]),[m,x]=g.useState(0),[b,N]=g.useState(0),[w,v]=g.useState(0),[k,T]=g.useState(0),[C,L]=g.useState(null),[R,U]=g.useState(null),[P,F]=g.useState(!1),[O,Q]=g.useState(0),[re,D]=g.useState(!1),[ne,le]=g.useState(null),[me,I]=g.useState("overview"),[Y,B]=g.useState([]),[xe,X]=g.useState(!1),[V,W]=g.useState("today"),[fe,he]=g.useState(null),[de,_]=g.useState(!1),[J,$]=g.useState(!0),[Z,ae]=g.useState(null),[we,Fe]=g.useState(null),[Ue,wt]=g.useState([]),jn=Ne=>{const Me=Ne;if((Me==null?void 0:Me.status)===401)L("登录已过期,请重新登录");else{if((Me==null?void 0:Me.name)==="AbortError")return;L("加载失败,请检查网络或联系管理员")}};async function pt(Ne){var $t,St;const Me=Ne?{signal:Ne}:void 0;n(!0),L(null);try{const $e=await Le("/api/admin/dashboard/stats",Me);$e!=null&&$e.success&&(x($e.totalUsers??0),N($e.paidOrderCount??0),v($e.totalRevenue??0),T($e.conversionRate??0))}catch($e){if(($e==null?void 0:$e.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",$e);try{const H=await Le("/api/admin/dashboard/overview",Me);H!=null&&H.success&&(x(H.totalUsers??0),N(H.paidOrderCount??0),v(H.totalRevenue??0),T(H.conversionRate??0))}catch(H){jn(H)}}}finally{n(!1)}try{const $e=await Le("/api/admin/balance/summary",Me);$e!=null&&$e.success&&$e.data&&Q($e.data.totalGifted??0)}catch{}try{const $e=await Le("/api/db/ckb-plan-stats",Me);$e!=null&&$e.success&&$e.data?le({ckbTotal:$e.data.ckbTotal??0,withContact:$e.data.withContact??0}):le(null)}catch{le(null)}$(!0);try{const[$e,H]=await Promise.allSettled([Le("/api/db/match-records?stats=true",Me),Le("/api/admin/distribution/overview",Me)]);$e.status==="fulfilled"&&(($t=$e.value)!=null&&$t.success)&&$e.value.data?ae({totalMatches:$e.value.data.totalMatches??0,todayMatches:$e.value.data.todayMatches??0,uniqueUsers:$e.value.data.uniqueUsers??0,paidMatchCount:$e.value.data.paidMatchCount??0}):ae(null),H.status==="fulfilled"&&((St=H.value)!=null&&St.success)&&H.value.overview?Fe({todayClicks:H.value.overview.todayClicks??0,todayBindings:H.value.overview.todayBindings??0,todayConversions:H.value.overview.todayConversions??0,monthClicks:H.value.overview.monthClicks??0,monthBindings:H.value.overview.monthBindings??0,monthConversions:H.value.overview.monthConversions??0,totalClicks:H.value.overview.totalClicks??0,totalBindings:H.value.overview.totalBindings??0,totalConversions:H.value.overview.totalConversions??0,conversionRate:H.value.overview.conversionRate}):Fe(null)}catch{ae(null),Fe(null)}finally{$(!1)}try{const $e=await Le("/api/db/vip-members?limit=500",Me);$e!=null&&$e.success&&Array.isArray($e.data)?wt($e.data):wt([])}catch{wt([])}a(!0),o(!0);const We=async()=>{try{const $e=await Le("/api/admin/dashboard/recent-orders?limit=10",Me);if($e!=null&&$e.success&&$e.recentOrders)f($e.recentOrders);else throw new Error("no data")}catch($e){if(($e==null?void 0:$e.name)!=="AbortError")try{const H=await Le("/api/admin/orders?page=1&pageSize=20&status=paid",Me),vt=((H==null?void 0:H.orders)??[]).filter(Ft=>["paid","completed","success"].includes(Ft.status||""));f(vt.slice(0,5))}catch{f([])}}finally{a(!1)}},rt=async()=>{try{const $e=await Le("/api/admin/dashboard/new-users",Me);if($e!=null&&$e.success&&$e.newUsers)u($e.newUsers);else throw new Error("no data")}catch($e){if(($e==null?void 0:$e.name)!=="AbortError")try{const H=await Le("/api/db/users?page=1&pageSize=10",Me);u((H==null?void 0:H.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([We(),rt()])}async function At(Ne){const Me=Ne||V;_(!0);try{const We=await Le(`/api/admin/track/stats?period=${Me}`);We!=null&&We.success&&he({total:We.total??0,byModule:We.byModule??{}})}catch{he(null)}finally{_(!1)}}const fn={home:"首页",chapters:"目录",read:"阅读页",my:"我的",vip:"超级个体",wallet:"钱包",match:"找伙伴",referral:"推广中心",search:"搜索",settings:"设置",about:"关于",member_detail:"成员详情",other:"其他"},Vn={btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",page_view:"页面浏览",share:"分享",purchase:"购买",register:"注册",rule_trigger:"规则触发",view_chapter:"浏览章节",link_click:"链接点击"},pn=Ne=>Ne?Ne.replace(/^part-/,"").replace(/^soulvip_/,"").replace(/^super_?/,"").replace(/^user_/,"").replace(/[_-]+/g," ").trim():"",qt=Ne=>{if(!Ne)return"";const Me=Ne.trim().toLowerCase();if(!Me)return"";const We=Ue.find($t=>{const St=String($t.id||"").toLowerCase();return St===Me||St.includes(Me)||Me.includes(St)});if(We)return We.name||We.nickname||"";const rt=Ue.find($t=>{const St=String($t.token||"").toLowerCase();return St&&(St===Me||St.includes(Me)||Me.includes(St))});return rt&&(rt.name||rt.nickname)||""},bn=Ne=>{if(!Ne)return"未命名点击";const Me=Ne.trim(),We=Me.toLowerCase();if(/^链接头像[_-]/.test(Me)){const $t=pn(Me.replace(/^链接头像[_-]/,""));return $t?`头像:${$t}`:"头像点击"}if(/^member[_-]?detail$/i.test(We)||We.includes("member detail"))return"成员详情";if(/^giftpay$/i.test(We)||We.includes("gift pay"))return"代付入口";if(/^part[-_]/i.test(We))return`章节:${pn(Me)}`;if(We.includes("soulvip")||We.includes("super")){const $t=Me.replace(/^超级个体[::]?/i,"").replace(/^super[_-]?/i,"").replace(/^soulvip[_-]?/i,"").replace(/^user[_-]?/i,"").trim(),St=qt($t)||qt(pn($t));return St?`超级个体:${St}`:`超级个体:${pn($t)}`}if(We.includes("qgdtw")||We.includes("token")||We.includes("0000"))return`对象:${pn(Me)}`;const rt={开始匹配:"开始匹配",mentor:"导师顾问",team:"团队招募",investor:"资源对接",充值:"充值",退款:"退款",wallet:"钱包",设置:"设置",VIP:"VIP会员",推广:"推广中心",目录:"目录",搜索:"搜索",匹配:"找伙伴",settings:"设置",expired:"已过期",active:"活跃",converted:"已转化",fill_profile:"完善资料",register:"注册",purchase:"购买",链接卡若:"链接卡若",更多分享:"更多分享",分享朋友圈文案:"分享朋友圈",选择金额10:"选择金额10元",member_detail:"成员详情",giftPay:"代付入口"};return rt[Me]?rt[Me]:/^[a-z0-9_-]+$/i.test(Me)&&pn(Me)||Me},Mn=Ne=>{const Me=fn[Ne.module]||fn[Ne.page]||Ne.module||Ne.page||"其他",We=Vn[Ne.action]||Ne.action||"点击",rt=bn(Ne.target);return`${Me} · ${We} · ${rt}`};async function Hn(){X(!0);try{const Ne=await Le("/api/admin/super-individual/stats");Ne!=null&&Ne.success&&Array.isArray(Ne.data)&&B(Ne.data)}catch{}finally{X(!1)}}g.useEffect(()=>{const Ne=new AbortController;return pt(Ne.signal),At(),Hn(),()=>{Ne.abort()}},[]);const as=m,_t=Ne=>{const Me=Ne.productType||"",We=Ne.description||"";if(Me==="balance_recharge")return{title:`余额充值 ¥${typeof Ne.amount=="number"?Ne.amount.toFixed(2):parseFloat(String(Ne.amount||"0")).toFixed(2)}`,subtitle:"余额充值"};if(Me==="gift_pay")return{title:`代付 ¥${typeof Ne.amount=="number"?Ne.amount.toFixed(2):parseFloat(String(Ne.amount||"0")).toFixed(2)}`,subtitle:"好友代付"};if(Me==="gift_pay_batch"){const rt=typeof Ne.amount=="number"?Ne.amount.toFixed(2):parseFloat(String(Ne.amount||"0")).toFixed(2);return{title:We||`代付分享 ¥${rt}`,subtitle:"代付分享"}}if(Me==="section"&&We.includes("代付领取"))return{title:We.replace("代付领取 - ",""),subtitle:"代付领取"};if(We){if(Me==="section"&&We.includes("章节")){if(We.includes("-")){const rt=We.split("-");if(rt.length>=3)return{title:`第${rt[1]}章 第${rt[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:We,subtitle:"章节购买"}}return Me==="fullbook"||We.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:Me==="vip"||We.includes("VIP")?{title:"超级个体开通费用",subtitle:"超级个体"}:Me==="match"||We.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:We,subtitle:Me==="section"?"单章":Me==="fullbook"?"全书":"其他"}}return Me==="section"?{title:`章节 ${Ne.productId||""}`,subtitle:"单章购买"}:Me==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:Me==="vip"?{title:"超级个体开通费用",subtitle:"超级个体"}:Me==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:Me||"其他"}},vn=[{title:"总用户数",value:e?null:as,sub:null,icon:qn,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:e?null:`¥${(w??0).toFixed(2)}`,sub:O>0?`含代付 ¥${O.toFixed(2)}`:null,icon:Of,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:b,sub:null,icon:mu,color:"text-purple-400",bg:"bg-purple-500/20",link:"/orders"},{title:"转化率",value:e?null:`${typeof k=="number"?k.toFixed(1):0}%`,sub:null,icon:ur,color:"text-orange-400",bg:"bg-orange-500/20",link:"/distribution"},{title:"存客宝获客",value:ne?ne.ckbTotal??0:null,sub:(ne==null?void 0:ne.withContact)!=null?`含联系方式 ${ne.withContact} 人`:null,icon:Qc,color:"text-cyan-400",bg:"bg-cyan-500/20",link:"/users?tab=leads"},{title:"伙伴&推广协同",value:J?null:((Z==null?void 0:Z.totalMatches)??0)+((we==null?void 0:we.totalClicks)??0),sub:J?null:`找伙伴 ${(Z==null?void 0:Z.totalMatches)??0} / 推广 ${(we==null?void 0:we.totalClicks)??0}`,icon:nu,color:"text-emerald-400",bg:"bg-emerald-500/20",link:"/find-partner"}];return s.jsxs("div",{className:"p-8 w-full",children:[s.jsx("h1",{className:"text-2xl font-bold mb-8 text-white",children:"数据概览"}),C&&s.jsxs("div",{className:"mb-6 px-4 py-3 rounded-lg bg-amber-500/20 border border-amber-500/50 text-amber-200 text-sm flex items-center justify-between",children:[s.jsx("span",{children:C}),s.jsx("button",{type:"button",onClick:()=>pt(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),s.jsx("div",{className:"grid gap-6 mb-8 grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 xl:grid-cols-6",children:vn.map((Ne,Me)=>s.jsxs(De,{className:"min-w-0 bg-[#0f2137] border-gray-700/50 shadow-xl cursor-pointer hover:border-[#38bdac]/50 transition-colors group",onClick:()=>Ne.link&&t(Ne.link),children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsx(ut,{className:"text-sm font-medium text-gray-400",children:Ne.title}),s.jsx("div",{className:`p-2 rounded-lg ${Ne.bg}`,children:s.jsx(Ne.icon,{className:`w-4 h-4 ${Ne.color}`})})]}),s.jsx(_e,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-white min-h-8 flex items-center",children:Ne.value!=null?Ne.value:s.jsxs("span",{className:"inline-flex items-center gap-2 text-gray-500",children:[s.jsx(Ve,{className:"w-4 h-4 animate-spin"}),"加载中"]})}),Ne.sub&&s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:Ne.sub})]}),s.jsx(Li,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},Me))}),s.jsxs("div",{className:"flex gap-2 mb-6 mt-2",children:[s.jsx("button",{type:"button",onClick:()=>I("overview"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${me==="overview"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"数据概览"}),s.jsx("button",{type:"button",onClick:()=>I("tags"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${me==="tags"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"用户标签点击统计"}),s.jsx("button",{type:"button",onClick:()=>I("super"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${me==="super"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"超级个体统计"})]}),me==="overview"&&s.jsxs("div",{className:"space-y-8",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsx(ut,{className:"text-white",children:"找伙伴 × 推广中心(共统计)"}),s.jsxs("button",{type:"button",onClick:()=>pt(),disabled:J,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新共统计",children:[s.jsx(Ve,{className:`w-3.5 h-3.5 ${J?"animate-spin":""}`}),"刷新"]})]}),s.jsxs(_e,{children:[J&&!Z&&!we?s.jsxs("div",{className:"flex items-center justify-center py-10 text-gray-500",children:[s.jsx(Ve,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-6 gap-4",children:[s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"找伙伴总匹配"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(Z==null?void 0:Z.totalMatches)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"找伙伴今日"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(Z==null?void 0:Z.todayMatches)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"找伙伴用户数"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(Z==null?void 0:Z.uniqueUsers)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"推广总点击"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(we==null?void 0:we.totalClicks)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"推广总绑定"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(we==null?void 0:we.totalBindings)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"推广总转化"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(we==null?void 0:we.totalConversions)??0})]})]}),(we==null?void 0:we.conversionRate)&&s.jsxs("p",{className:"text-xs text-gray-500 mt-3",children:["推广转化率:",we.conversionRate]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsx(ut,{className:"text-white",children:"最近订单"}),s.jsxs("button",{type:"button",onClick:()=>pt(),disabled:r||i,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新",children:[r||i?s.jsx(Ve,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(Ve,{className:"w-3.5 h-3.5"}),"刷新"]})]}),s.jsx(_e,{children:s.jsx("div",{className:"space-y-3",children:r&&h.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Ve,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[h.slice(0,re?10:4).map(Ne=>{var St;const Me=Ne.referrerId?c.find($e=>$e.id===Ne.referrerId):void 0,We=Ne.referralCode||(Me==null?void 0:Me.referralCode)||(Me==null?void 0:Me.nickname)||(Ne.referrerId?String(Ne.referrerId).slice(0,8):""),rt=_t(Ne),$t=Ne.userNickname||((St=c.find($e=>$e.id===Ne.userId))==null?void 0:St.nickname)||"匿名用户";return s.jsxs("div",{className:"flex items-start justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30 hover:border-[#38bdac]/30 transition-colors",children:[s.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[Ne.userAvatar?s.jsx("img",{src:Ne.userAvatar,alt:$t,className:"w-9 h-9 rounded-full object-cover shrink-0 mt-0.5",onError:$e=>{$e.currentTarget.style.display="none";const H=$e.currentTarget.nextElementSibling;H&&H.classList.remove("hidden")}}):null,s.jsx("div",{className:`w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] shrink-0 mt-0.5 ${Ne.userAvatar?"hidden":""}`,children:$t.charAt(0)}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("button",{type:"button",onClick:()=>{Ne.userId&&(U(Ne.userId),F(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:$t}),s.jsx("span",{className:"text-gray-600",children:"·"}),s.jsx("span",{className:"text-sm font-medium text-white truncate",title:rt.title,children:rt.title})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[rt.subtitle&&rt.subtitle!=="章节购买"&&s.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:rt.subtitle}),s.jsx("span",{children:new Date(Ne.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),We&&s.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",We]})]})]}),s.jsxs("div",{className:"text-right ml-4 shrink-0",children:[s.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(Ne.amount).toFixed(2)]}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:Ne.paymentMethod||"微信"})]})]},Ne.id)}),h.length>4&&!re&&s.jsx("button",{type:"button",onClick:()=>D(!0),className:"w-full py-2 text-sm text-[#38bdac] hover:text-[#2da396] border border-dashed border-gray-600 rounded-lg hover:border-[#38bdac]/50 transition-colors",children:"展开更多"}),h.length===0&&!r&&s.jsxs("div",{className:"text-center py-12",children:[s.jsx(mu,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(dt,{children:s.jsx(ut,{className:"text-white",children:"新注册用户"})}),s.jsx(_e,{children:s.jsx("div",{className:"space-y-3",children:i&&c.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Ve,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[c.slice(0,5).map(Ne=>{var Me;return s.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:((Me=Ne.nickname)==null?void 0:Me.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("button",{type:"button",onClick:()=>{U(Ne.id),F(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:Ne.nickname||"匿名用户"}),s.jsx("p",{className:"text-xs text-gray-500",children:Ne.phone||"未绑定手机"})]})]}),s.jsx("p",{className:"text-xs text-gray-400",children:Ne.createdAt?new Date(Ne.createdAt).toLocaleDateString():"-"})]},Ne.id)}),c.length===0&&!i&&s.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})})]})]})]}),me==="tags"&&s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(nu,{className:"w-5 h-5 text-[#38bdac]"}),"分类标签点击统计"]}),s.jsx("div",{className:"flex items-center gap-2",children:["today","week","month","all"].map(Ne=>s.jsx("button",{type:"button",onClick:()=>{W(Ne),At(Ne)},className:`px-3 py-1 text-xs rounded-full transition-colors ${V===Ne?"bg-[#38bdac] text-white":"bg-gray-700/50 text-gray-400 hover:bg-gray-700"}`,children:{today:"今日",week:"本周",month:"本月",all:"全部"}[Ne]},Ne))})]}),s.jsx(_e,{children:de&&!fe?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(Ve,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):fe&&Object.keys(fe.byModule).length>0?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("p",{className:"text-sm text-gray-400",children:["总点击 ",s.jsx("span",{className:"text-white font-bold text-lg",children:fe.total})," 次"]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Object.entries(fe.byModule).sort((Ne,Me)=>Me[1].reduce((We,rt)=>We+rt.count,0)-Ne[1].reduce((We,rt)=>We+rt.count,0)).slice(0,5).map(([Ne,Me])=>{const We=Me.reduce((rt,$t)=>rt+$t.count,0);return s.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("span",{className:"text-sm font-medium text-[#38bdac]",children:fn[Ne]||Ne}),s.jsxs("span",{className:"text-xs text-gray-500",children:[We," 次"]})]}),s.jsx("div",{className:"space-y-2",children:Me.sort((rt,$t)=>$t.count-rt.count).slice(0,8).map((rt,$t)=>{const St=Mn(rt);return s.jsxs("div",{className:"flex items-center justify-between text-xs",children:[s.jsx("span",{className:"text-gray-300 truncate mr-2",title:St,children:St}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx("div",{className:"w-16 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac] rounded-full",style:{width:`${We>0?rt.count/We*100:0}%`}})}),s.jsx("span",{className:"text-gray-400 w-8 text-right",children:rt.count})]})]},$t)})})]},Ne)})})]}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(nu,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无点击数据"}),s.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"小程序端接入埋点后,数据将在此实时展示"})]})})]}),me==="super"&&s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(nu,{className:"w-5 h-5 text-amber-400"}),"超级个体点击统计"]}),s.jsxs(G,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300 h-8",onClick:Hn,disabled:xe,children:[s.jsx(Ve,{className:`w-3.5 h-3.5 mr-1 ${xe?"animate-spin":""}`}),"刷新"]})]}),s.jsx(_e,{children:xe&&Y.length===0?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(Ve,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):Y.length>0?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-xs text-gray-400 border-b border-gray-700/50",children:[s.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"排名"}),s.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"超级个体"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"总点击"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"独立访客"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"人均点击"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",title:"该用户绑定 @人物 后,指向其 person 的留资独立人数",children:"获客(去重)"}),s.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"手机号"})]})}),s.jsx("tbody",{children:Y.map((Ne,Me)=>s.jsxs("tr",{className:"border-b border-gray-700/30 hover:bg-[#0a1628]/80",children:[s.jsx("td",{className:"py-2 px-3 text-gray-500 text-xs",children:Me+1}),s.jsx("td",{className:"py-2 px-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[Ne.avatar?s.jsx("img",{src:Ne.avatar,alt:"",className:"w-7 h-7 rounded-full object-cover"}):s.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-700 flex items-center justify-center text-xs text-gray-400",children:"?"}),s.jsx("button",{type:"button",className:"text-amber-400 hover:text-amber-300 hover:underline text-left text-sm truncate max-w-[160px]",onClick:()=>t(`/users?search=${encodeURIComponent(Ne.nickname||Ne.userId)}`),title:"点击跳转用户管理",children:Ne.nickname||Ne.userId})]})}),s.jsx("td",{className:"py-2 px-3 text-center text-white font-bold",children:Ne.clicks}),s.jsx("td",{className:"py-2 px-3 text-center text-[#38bdac]",children:Ne.uniqueClicks}),s.jsx("td",{className:"py-2 px-3 text-center text-gray-400",children:Ne.uniqueClicks>0?(Ne.clicks/Ne.uniqueClicks).toFixed(1):"-"}),s.jsx("td",{className:"py-2 px-3 text-center text-green-400 text-xs font-medium",children:typeof Ne.leadCount=="number"?Ne.leadCount:0}),s.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs",children:Ne.phone||"-"})]},Ne.userId))})]})}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(nu,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无超级个体点击数据"}),s.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"小程序首页的超级个体被用户点击后,数据将展示在此"})]})})]}),s.jsx(py,{open:P,onClose:()=>{F(!1),U(null)},userId:R,onUserUpdated:()=>pt()})]})}const fs=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx("table",{ref:n,className:zt("w-full caption-bottom text-sm",t),...e})}));fs.displayName="Table";const ps=g.forwardRef(({className:t,...e},n)=>s.jsx("thead",{ref:n,className:zt("[&_tr]:border-b",t),...e}));ps.displayName="TableHeader";const ms=g.forwardRef(({className:t,...e},n)=>s.jsx("tbody",{ref:n,className:zt("[&_tr:last-child]:border-0",t),...e}));ms.displayName="TableBody";const xt=g.forwardRef(({className:t,...e},n)=>s.jsx("tr",{ref:n,className:zt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));xt.displayName="TableRow";const Se=g.forwardRef(({className:t,...e},n)=>s.jsx("th",{ref:n,className:zt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));Se.displayName="TableHead";const je=g.forwardRef(({className:t,...e},n)=>s.jsx("td",{ref:n,className:zt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));je.displayName="TableCell";function qa(t,e){const[n,r]=g.useState(t);return g.useEffect(()=>{const a=setTimeout(()=>r(t),e);return()=>clearTimeout(a)},[t,e]),n}function xs({page:t,totalPages:e,total:n,pageSize:r,onPageChange:a,onPageSizeChange:i,pageSizeOptions:o=[10,20,50,100]}){return e<=1&&!i?null:s.jsxs("div",{className:"flex items-center justify-between gap-4 py-4 px-5 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[s.jsxs("span",{children:["共 ",n," 条"]}),i&&s.jsx("select",{value:r,onChange:c=>i(Number(c.target.value)),className:"bg-[#0f2137] border border-gray-600 rounded px-2 py-1 text-gray-300 text-sm",children:o.map(c=>s.jsxs("option",{value:c,children:[c," 条/页"]},c))})]}),e>1&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>a(1),disabled:t<=1,className:"px-2 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"首页"}),s.jsx("button",{type:"button",onClick:()=>a(t-1),disabled:t<=1,className:"px-3 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"上一页"}),s.jsxs("span",{className:"px-3 py-1 text-gray-400 text-sm",children:[t," / ",e]}),s.jsx("button",{type:"button",onClick:()=>a(t+1),disabled:t>=e,className:"px-3 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"下一页"}),s.jsx("button",{type:"button",onClick:()=>a(e),disabled:t>=e,className:"px-2 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"末页"})]})]})}function p8(){const[t,e]=g.useState([]),[n,r]=g.useState([]),[a,i]=g.useState(0),[o,c]=g.useState(0),[u,h]=g.useState(0),[f,m]=g.useState(1),[x,b]=g.useState(10),[N,w]=g.useState(""),v=qa(N,300),[k,T]=g.useState("all"),[C,L]=g.useState(!0),[R,U]=g.useState(null),[P,F]=g.useState(null),[O,Q]=g.useState(""),[re,D]=g.useState(!1);async function ne(){L(!0),U(null);try{const X=k==="all"?"":k==="completed"?"completed":k,V=new URLSearchParams({page:String(f),pageSize:String(x),...X&&{status:X},...v&&{search:v}}),[W,fe]=await Promise.all([Le(`/api/admin/orders?${V}`),Le("/api/db/users?page=1&pageSize=500")]);W!=null&&W.success&&(e(W.orders||[]),i(W.total??0),c(W.totalRevenue??0),h(W.todayRevenue??0)),fe!=null&&fe.success&&fe.users&&r(fe.users)}catch(X){console.error("加载订单失败",X),U("加载订单失败,请检查网络后重试")}finally{L(!1)}}g.useEffect(()=>{m(1)},[v,k]),g.useEffect(()=>{ne()},[f,x,v,k]);const le=X=>{var V;return X.userNickname||((V=n.find(W=>W.id===X.userId))==null?void 0:V.nickname)||"匿名用户"},me=X=>{var V;return((V=n.find(W=>W.id===X))==null?void 0:V.phone)||"-"},I=X=>{const V=X.productType||X.type||"",W=X.description||"";if(V==="balance_recharge")return{name:`余额充值 ¥${Number(X.amount||0).toFixed(2)}`,type:"余额充值"};if(W){if(V==="section"&&(W.includes("章节")||W.includes("代付领取"))){if(W.includes("代付领取"))return{name:W.replace("代付领取 - ",""),type:"代付领取"};if(W.includes("-")){const fe=W.split("-");if(fe.length>=3)return{name:`第${fe[1]}章 第${fe[2]}节`,type:"《一场Soul的创业实验》"}}return{name:W,type:"章节购买"}}return V==="fullbook"||W.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:V==="vip"||W.includes("VIP")?{name:"超级个体开通费用",type:"超级个体"}:V==="match"||W.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:W,type:"其他"}}return V==="section"?{name:`章节 ${X.productId||X.sectionId||""}`,type:"单章"}:V==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:V==="vip"?{name:"超级个体开通费用",type:"超级个体"}:V==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:V||"其他"}},Y=Math.ceil(a/x)||1;async function B(){var X;if(!(!(P!=null&&P.orderSn)&&!(P!=null&&P.id))){D(!0),U(null);try{const V=await tn("/api/admin/orders/refund",{orderSn:P.orderSn||P.id,reason:O||void 0});V!=null&&V.success?(F(null),Q(""),ne()):U((V==null?void 0:V.error)||"退款失败")}catch(V){const W=V;U(((X=W==null?void 0:W.data)==null?void 0:X.error)||"退款失败,请检查网络后重试")}finally{D(!1)}}}function xe(){if(t.length===0){q.info("暂无数据可导出");return}const X=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],V=t.map(_=>{const J=I(_);return[_.orderSn||_.id||"",le(_),me(_.userId),J.name,Number(_.amount||0).toFixed(2),_.paymentMethod==="wechat"?"微信支付":_.paymentMethod==="balance"?"余额支付":_.paymentMethod==="alipay"?"支付宝":_.paymentMethod||"微信支付",_.status==="refunded"?"已退款":_.status==="paid"||_.status==="completed"?"已完成":_.status==="pending"||_.status==="created"?"待支付":"已失败",_.status==="refunded"&&_.refundReason?_.refundReason:"-",_.referrerEarnings?Number(_.referrerEarnings).toFixed(2):"-",_.createdAt?new Date(_.createdAt).toLocaleString("zh-CN"):""].join(",")}),W="\uFEFF"+[X.join(","),...V].join(`
+`),fe=new Blob([W],{type:"text/csv;charset=utf-8"}),he=URL.createObjectURL(fe),de=document.createElement("a");de.href=he,de.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,de.click(),URL.revokeObjectURL(he)}return s.jsxs("div",{className:"p-8 w-full",children:[R&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[s.jsx("span",{children:R}),s.jsx("button",{type:"button",onClick:()=>U(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"订单管理"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",t.length," 笔订单"]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs(G,{variant:"outline",onClick:ne,disabled:C,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${C?"animate-spin":""}`}),"刷新"]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"text-gray-400",children:"总收入:"}),s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",o.toFixed(2)]}),s.jsx("span",{className:"text-gray-600",children:"|"}),s.jsx("span",{className:"text-gray-400",children:"今日:"}),s.jsxs("span",{className:"text-[#FFD700] font-bold",children:["¥",u.toFixed(2)]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsxs("div",{className:"relative flex-1 max-w-md",children:[s.jsx(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:N,onChange:X=>w(X.target.value)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(sk,{className:"w-4 h-4 text-gray-400"}),s.jsxs("select",{value:k,onChange:X=>T(X.target.value),className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"pending",children:"待支付"}),s.jsx("option",{value:"created",children:"已创建"}),s.jsx("option",{value:"failed",children:"已失败"}),s.jsx("option",{value:"refunded",children:"已退款"})]})]}),s.jsxs(G,{variant:"outline",onClick:xe,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(GT,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(_e,{className:"p-0",children:C?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"订单号"}),s.jsx(Se,{className:"text-gray-400",children:"用户"}),s.jsx(Se,{className:"text-gray-400",children:"商品"}),s.jsx(Se,{className:"text-gray-400",children:"金额"}),s.jsx(Se,{className:"text-gray-400",children:"支付方式"}),s.jsx(Se,{className:"text-gray-400",children:"状态"}),s.jsx(Se,{className:"text-gray-400",children:"退款原因"}),s.jsx(Se,{className:"text-gray-400",children:"分销佣金"}),s.jsx(Se,{className:"text-gray-400",children:"下单时间"}),s.jsx(Se,{className:"text-gray-400",children:"操作"})]})}),s.jsxs(ms,{children:[t.map(X=>{const V=I(X);return s.jsxs(xt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsxs(je,{className:"font-mono text-xs text-gray-400",children:[(X.orderSn||X.id||"").slice(0,12),"..."]}),s.jsx(je,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[le(X),X.paymentMethod==="gift_pay"&&s.jsx(Be,{className:"bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 border-0 text-xs",children:"代付领取"}),X.payerUserId&&X.paymentMethod!=="gift_pay"&&s.jsx(Be,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"代付"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:me(X.userId)}),X.payerUserId&&X.payerNickname&&s.jsxs("p",{className:"text-amber-400/80 text-xs mt-0.5",children:[X.paymentMethod==="gift_pay"?"赠送人:":"代付人:",X.payerNickname]})]})}),s.jsx(je,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[V.name,(X.productType||X.type)==="vip"&&s.jsx(Be,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"超级个体"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:V.type})]})}),s.jsxs(je,{className:"text-[#38bdac] font-bold",children:["¥",Number(X.amount||0).toFixed(2)]}),s.jsx(je,{className:"text-gray-300",children:X.paymentMethod==="wechat"?"微信支付":X.paymentMethod==="balance"?"余额支付":X.paymentMethod==="alipay"?"支付宝":X.paymentMethod||"微信支付"}),s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[X.status==="refunded"?s.jsx(Be,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):X.status==="paid"||X.status==="completed"?s.jsx(Be,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):X.status==="pending"||X.status==="created"?s.jsx(Be,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):s.jsx(Be,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"}),(X.status==="paid"||X.status==="completed")&&(X.webhookPushStatus==="sent"?s.jsx(Be,{className:"bg-emerald-500/20 text-emerald-300 hover:bg-emerald-500/20 border-0",children:"已推送"}):s.jsx(Be,{className:"bg-orange-500/20 text-orange-300 hover:bg-orange-500/20 border-0",children:"待补推"}))]})}),s.jsx(je,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:X.refundReason,children:X.status==="refunded"&&X.refundReason?X.refundReason:"-"}),s.jsx(je,{className:"text-[#FFD700]",children:X.referrerEarnings?`¥${Number(X.referrerEarnings).toFixed(2)}`:"-"}),s.jsx(je,{className:"text-gray-400 text-sm",children:new Date(X.createdAt).toLocaleString("zh-CN")}),s.jsx(je,{children:(X.status==="paid"||X.status==="completed")&&X.paymentMethod!=="balance"&&s.jsxs(G,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{F(X),Q("")},children:[s.jsx(lk,{className:"w-3 h-3 mr-1"}),"退款"]})})]},X.id)}),t.length===0&&s.jsx(xt,{children:s.jsx(je,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),s.jsx(xs,{page:f,totalPages:Y,total:a,pageSize:x,onPageChange:m,onPageSizeChange:X=>{b(X),m(1)}})]})})}),s.jsx(Lt,{open:!!P,onOpenChange:X=>!X&&F(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:"订单退款"})}),P&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",P.orderSn||P.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(P.amount||0).toFixed(2)]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:O,onChange:X=>Q(X.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>F(null),disabled:re,children:"取消"}),s.jsx(G,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:B,disabled:re,children:re?"退款中...":"确认退款"})]})]})})]})}const el=g.forwardRef(({className:t,...e},n)=>s.jsx("textarea",{className:zt("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:n,...e}));el.displayName="Textarea";const oN=["INTJ","INTP","ENTJ","ENTP","INFJ","INFP","ENFJ","ENFP","ISTJ","ISFJ","ESTJ","ESFJ","ISTP","ISFP","ESTP","ESFP"],M2={INTJ:{title:"战略家",group:"NT",mood:"sharp"},INTP:{title:"逻辑学家",group:"NT",mood:"calm"},ENTJ:{title:"指挥官",group:"NT",mood:"sharp"},ENTP:{title:"辩论家",group:"NT",mood:"playful"},INFJ:{title:"提倡者",group:"NF",mood:"warm"},INFP:{title:"调停者",group:"NF",mood:"warm"},ENFJ:{title:"主人公",group:"NF",mood:"warm"},ENFP:{title:"竞选者",group:"NF",mood:"playful"},ISTJ:{title:"物流师",group:"SJ",mood:"calm"},ISFJ:{title:"守卫者",group:"SJ",mood:"warm"},ESTJ:{title:"总经理",group:"SJ",mood:"sharp"},ESFJ:{title:"执政官",group:"SJ",mood:"warm"},ISTP:{title:"鉴赏家",group:"SP",mood:"sharp"},ISFP:{title:"探险家",group:"SP",mood:"playful"},ESTP:{title:"企业家",group:"SP",mood:"playful"},ESFP:{title:"表演者",group:"SP",mood:"playful"}};function m8(t){switch(t){case"NT":return{bg:"#0d1424",body:"#c89a2c",accent:"#ffd66b",hair:"#6d540f",line:"#111827"};case"NF":return{bg:"#0a1721",body:"#2e9f7c",accent:"#84e9c9",hair:"#2d6a4f",line:"#11212a"};case"SJ":return{bg:"#101828",body:"#4f8cb8",accent:"#9bd4ff",hair:"#2e4a66",line:"#111f2d"};case"SP":return{bg:"#161225",body:"#8b6bc0",accent:"#ccb3ff",hair:"#574183",line:"#211832"};default:return{bg:"#0e1422",body:"#38bdac",accent:"#7ee7db",hair:"#1f6f66",line:"#10202d"}}}function x8(t){switch(t){case"sharp":return{eye:"M222 222 L242 220 M270 220 L290 222",brow:"M218 210 L244 202 M268 202 L294 210",mouth:"M234 256 Q256 246 278 256",tilt:-5};case"warm":return{eye:"M222 224 Q232 230 242 224 M270 224 Q280 230 290 224",brow:"M220 210 Q232 206 244 210 M268 210 Q280 206 292 210",mouth:"M232 254 Q256 272 280 254",tilt:2};case"playful":return{eye:"M222 224 Q232 236 242 224 M270 224 Q280 236 290 224",brow:"M220 210 Q234 200 246 208 M266 208 Q278 200 292 210",mouth:"M232 256 Q256 266 280 250",tilt:8};default:return{eye:"M222 224 Q232 220 242 224 M270 224 Q280 220 290 224",brow:"M220 210 Q232 208 244 210 M268 210 Q280 208 292 210",mouth:"M236 256 Q256 260 276 256",tilt:0}}}function g8(t){switch(t){case"sharp":return"M168 370 L206 300 L256 332 L306 300 L344 370 L306 392 L256 374 L206 392 Z";case"warm":return"M166 368 Q188 318 226 314 L256 340 L286 314 Q324 318 346 368 L314 392 Q286 404 256 396 Q226 404 198 392 Z";case"playful":return"M164 370 L198 304 L252 332 L318 300 L350 374 L316 394 L258 378 L196 396 Z";default:return"M166 370 L202 306 L256 336 L310 306 L346 370 L310 392 L256 380 L202 392 Z"}}function lN(t){const e=M2[t],n=m8(e.group),r=x8(e.mood),a=g8(e.mood),i=`
`;return`data:image/svg+xml;utf8,${encodeURIComponent(i)}`}function y8(){const[t,e]=g.useState({}),[n,r]=g.useState(!0),[a,i]=g.useState(!1),[o,c]=g.useState(!1),u=g.useCallback(async()=>{r(!0);try{const x=await Le("/api/admin/mbti-avatars");x!=null&&x.avatars?e(x.avatars):e({})}catch{q.error("加载 MBTI 头像配置失败")}finally{r(!1)}},[]);g.useEffect(()=>{u()},[u]);const h=async()=>{i(!0);try{const x=await bt("/api/admin/mbti-avatars",{avatars:t});if(!x||x.success===!1){q.error((x==null?void 0:x.error)||"保存失败");return}q.success("已保存,后台与小程序默认头像同步生效"),u()}catch{q.error("保存失败")}finally{i(!1)}},f=x=>{const b=lN(x);e(N=>({...N,[x]:b})),q.success(`${x} 已生成`)},m=()=>{c(!0);try{const x={...t};oN.forEach(b=>{x[b]=lN(b)}),e(x),q.success("16 型头像已生成(仅人物)")}finally{c(!1)}};return n?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-400",children:[s.jsx(Ve,{className:"w-5 h-5 mr-2 animate-spin text-[#38bdac]"}),"加载配置…"]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs(De,{className:"bg-[#0f2137] border-[#38bdac]/25 shadow-xl",children:[s.jsxs(dt,{className:"pb-2",children:[s.jsxs(ut,{className:"text-white flex items-center gap-2 text-lg",children:[s.jsx(SA,{className:"w-5 h-5 text-[#38bdac]"}),"MBTI 头像库"]}),s.jsx(Qt,{className:"text-gray-400 text-sm leading-relaxed",children:"采用人物化风格,按 MBTI 性格自动生成。头像内不显示中英文,仅显示人物形象,颜色与站点主题融合。"})]}),s.jsxs(_e,{className:"flex flex-wrap gap-2",children:[s.jsxs(G,{type:"button",size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396]",onClick:m,disabled:o,children:[s.jsx(GA,{className:"w-3.5 h-3.5 mr-1"}),o?"生成中…":"一键生成16头像"]}),s.jsxs(G,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-300",onClick:u,children:[s.jsx(Ve,{className:"w-3.5 h-3.5 mr-1"}),"重新加载"]}),s.jsxs(G,{type:"button",size:"sm",className:"bg-emerald-600 hover:bg-emerald-500",onClick:h,disabled:a,children:[s.jsx(Tn,{className:"w-3.5 h-3.5 mr-1"}),a?"保存中…":"保存映射"]})]})]}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:oN.map(x=>{const b=t[x]??"",N=M2[x];return s.jsxs("div",{className:"rounded-xl border border-gray-700/60 bg-[#0a1628] p-3 flex flex-col gap-2 hover:border-[#38bdac]/35 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Be,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 font-mono text-xs",children:x}),s.jsx("span",{className:"text-xs text-gray-400 truncate",title:N.title,children:N.title})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-16 h-16 rounded-full shrink-0 overflow-hidden flex items-center justify-center bg-[#081322] ring-2 ring-[#38bdac]/40 ring-offset-2 ring-offset-[#0a1628]",children:b?s.jsx("img",{src:b,alt:x,className:"w-full h-full object-cover scale-110"}):s.jsx("span",{className:"text-gray-600 text-[10px]",children:"未配"})}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"https://... 或 data:image/...",value:b,onChange:w=>e(v=>({...v,[x]:w.target.value}))})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(G,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-[#38bdac]/40 text-[#38bdac]",onClick:()=>f(x),children:"生成这张"}),s.jsx(G,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-[11px] text-gray-400",onClick:()=>e(w=>({...w,[x]:""})),children:"清空"})]})]},x)})})]})}const cN=[{value:"after_login",label:"注册/登录成功",group:"用户状态"},{value:"bind_phone",label:"绑定手机号",group:"用户状态"},{value:"update_avatar",label:"完善头像(非默认图,与昵称分开配置)",group:"用户状态"},{value:"update_nickname",label:"修改昵称(非默认微信昵称,与头像分开)",group:"用户状态"},{value:"fill_profile",label:"完善资料(MBTI/行业/职位,不含头像昵称)",group:"用户状态"},{value:"view_chapter",label:"浏览章节",group:"阅读行为"},{value:"browse_5_chapters",label:"累计浏览5个章节",group:"阅读行为"},{value:"purchase_section",label:"购买单章",group:"付费行为"},{value:"purchase_fullbook",label:"购买全书/VIP",group:"付费行为"},{value:"after_pay",label:"任意付款成功",group:"付费行为"},{value:"after_match",label:"完成派对匹配",group:"社交行为"},{value:"click_super_individual",label:"点击超级个体头像",group:"社交行为"},{value:"lead_submit",label:"提交留资/链接",group:"社交行为"},{value:"referral_bind",label:"被推荐人绑定",group:"分销行为"},{value:"share_action",label:"分享给好友/朋友圈",group:"分销行为"},{value:"withdraw_request",label:"申请提现",group:"分销行为"},{value:"add_wechat",label:"添加微信联系方式",group:"用户状态"}],dN=[{value:"popup",label:"弹窗提示",desc:"在小程序内弹窗引导用户完成下一步"},{value:"navigate",label:"跳转页面",desc:"引导用户跳转到指定页面"},{value:"webhook",label:"推送飞书群",desc:"触发后推送消息到飞书群Webhook"},{value:"tag",label:"自动打标签",desc:"触发后自动给用户打上指定标签"}];function A2(t){if(Array.isArray(t))return t.filter(e=>typeof e=="string");if(typeof t=="string")try{const e=JSON.parse(t);if(Array.isArray(e))return e.filter(n=>typeof n=="string")}catch{try{const e=typeof atob=="function"?atob(t):"",n=JSON.parse(e);if(Array.isArray(n))return n.filter(r=>typeof r=="string")}catch{}}return[]}function b8(t){return{...t,triggerConditions:A2(t.triggerConditions)}}const v8=[{level:"S",range:"≥85",label:"高价值"},{level:"A",range:"70–84",label:"优质"},{level:"B",range:"50–69",label:"中等"},{level:"C",range:"30–49",label:"潜力"},{level:"D",range:"<30",label:"待激活"}],Fc=[{id:"register",label:"注册/登录",icon:"👤",color:"bg-blue-500/20 border-blue-500/40 text-blue-400",desc:"微信授权登录或手机号注册"},{id:"browse",label:"浏览章节",icon:"📖",color:"bg-purple-500/20 border-purple-500/40 text-purple-400",desc:"点击免费/付费章节预览"},{id:"bind_phone",label:"绑定手机",icon:"📱",color:"bg-cyan-500/20 border-cyan-500/40 text-cyan-400",desc:"触发付费章节后绑定手机"},{id:"first_pay",label:"首次付款",icon:"💳",color:"bg-green-500/20 border-green-500/40 text-green-400",desc:"购买单章或全书"},{id:"fill_profile",label:"完善资料",icon:"✍️",color:"bg-yellow-500/20 border-yellow-500/40 text-yellow-400",desc:"填写头像、MBTI、行业等"},{id:"match",label:"派对房匹配",icon:"🤝",color:"bg-orange-500/20 border-orange-500/40 text-orange-400",desc:"参与 Soul 派对房"},{id:"vip",label:"升级 VIP",icon:"👑",color:"bg-amber-500/20 border-amber-500/40 text-amber-400",desc:"付款 ¥1980 购买全书"},{id:"distribution",label:"开启分销",icon:"🔗",color:"bg-[#38bdac]/20 border-[#38bdac]/40 text-[#38bdac]",desc:"生成推广码并推荐好友"}];function uN(t){return confirm(`确定删除该${t}?此操作不可恢复。`)?window.prompt(`请输入「删除」以确认删除${t}`)==="删除":!1}function N8({userId:t,userAvatar:e,nickname:n,name:r,onOpenDetail:a}){const[i,o]=g.useState(!1),c=n||r||"-",u=(c==="-"?"?":c).charAt(0),h=!!(e!=null&&e.trim())&&!i;return s.jsxs("div",{className:"flex items-center gap-2 min-w-0 max-w-[220px]",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/15 flex items-center justify-center text-xs font-medium text-[#38bdac] flex-shrink-0 overflow-hidden border border-gray-600/50","aria-hidden":!0,children:h?s.jsx("img",{src:ya(e),alt:"",className:"w-full h-full object-cover",onError:()=>o(!0)}):s.jsx("span",{children:u})}),s.jsx("button",{type:"button",className:`text-left truncate min-w-0 ${t?"hover:text-[#38bdac] cursor-pointer":"cursor-default text-gray-300"}`,disabled:!t,title:t?"查看用户详情":void 0,onClick:()=>{t&&a(t)},children:c})]})}function w8(t){const e=(t||"").trim();if(!e)return"";try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function j8(){var eo,eh,Ed,Td,Md,Ad,Pd;const[t,e]=X0(),n=t.get("pool"),r=t.get("tab")||"users",a=["users","journey","rules","vip-roles","leads"].includes(r)?r:"users",i=(t.get("leadAction")||"").trim(),[o,c]=g.useState([]),[u,h]=g.useState(0),[f,m]=g.useState(1),[x,b]=g.useState(10),[N,w]=g.useState(""),v=qa(N,300),k=n==="vip"?"vip":n==="complete"?"complete":"all",[T,C]=g.useState(k),[L,R]=g.useState(!0),[U,P]=g.useState(!1),[z,O]=g.useState(null),[Q,re]=g.useState(!1),[D,ne]=g.useState(!1),[le,me]=g.useState("desc");g.useEffect(()=>{n==="vip"?C("vip"):n==="complete"?C("complete"):n==="all"&&C("all")},[n]);const[I,Y]=g.useState(!1),[F,xe]=g.useState(null),[X,V]=g.useState(!1),[W,fe]=g.useState(!1),[he,de]=g.useState({referrals:[],stats:{}}),[_,J]=g.useState(!1),[$,Z]=g.useState(null),[ae,we]=g.useState(!1),[Fe,Ue]=g.useState(null),[wt,jn]=g.useState(!1),[pt,At]=g.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[fn,Vn]=g.useState([]),[pn,qt]=g.useState(!1),[bn,Mn]=g.useState(!1),[Hn,rs]=g.useState(null),[_t,vn]=g.useState({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),[Ne,Me]=g.useState([]),[We,rt]=g.useState(!1),[$t,kt]=g.useState(null),[$e,H]=g.useState(null),[Qe,vt]=g.useState({}),[Ft,yt]=g.useState(!1),[ht,Pt]=g.useState(null),[Gt,kn]=g.useState([]),[Ts,Ms]=g.useState(!1),[Ki,ja]=g.useState(null),[ei,ti]=g.useState(""),[Ar,Pr]=g.useState([]),[Ir,Qr]=g.useState(!1),[Vs,Qs]=g.useState({}),[pr,Ys]=g.useState([]),[ka,ce]=g.useState(0),[ve,Rt]=g.useState(1),[Zt]=g.useState(10),[sn,as]=g.useState(!1),[Rr,Yr]=g.useState(null),[Tt,Jn]=g.useState(""),Xr=qa(Tt,300),[Sa,mn]=g.useState(""),[Zr,ni]=g.useState(""),[mr,As]=g.useState(""),[Ca,qi]=g.useState(!1),[Xs,Zs]=g.useState({}),[Gi,bs]=g.useState(null),[il,Ji]=g.useState(null),[vs,er]=g.useState([]),[tr,xr]=g.useState(!1),si=g.useRef(null),[ea,ac]=g.useState(!1),[ol,ri]=g.useState(!1),[Qi,Ea]=g.useState("存客宝返回 data"),[ll,Ta]=g.useState(""),Nt=g.useCallback(async(M,ee)=>{as(!0),Yr(null);try{const be=new URLSearchParams({mode:"contact",page:String(ve),pageSize:String(Zt)}),Ae=M??Xr;Ae&&be.set("search",Ae);const Ge=ee??Sa;Ge&&be.set("source",Ge),Zr&&be.set("action",Zr),mr&&be.set("pushStatus",mr);const Je=await Le(`/api/db/ckb-leads?${be}`);if(Je!=null&&Je.success)Ys(Je.records||[]),ce(Je.total??0),Je.stats&&Zs(Je.stats);else{const Vt=(Je==null?void 0:Je.error)||"加载获客列表失败";Yr(Vt),q.error(Vt),Ys([]),ce(0)}}catch(be){const Ae=be instanceof Error?be.message:"网络错误";Yr(Ae),q.error("加载获客列表失败: "+Ae),Ys([]),ce(0)}finally{as(!1)}},[ve,Zt,Xr,Sa,Zr,mr]);g.useEffect(()=>{er([])},[Xr,Sa,Zr,mr]),g.useEffect(()=>{a==="leads"&&ni(i)},[a,i]);function Yi(M,ee){return{...M,...ee.pushStatus!==void 0?{pushStatus:ee.pushStatus}:{},...typeof ee.retryCount=="number"?{retryCount:ee.retryCount}:{},...typeof ee.ckbCode=="number"?{ckbCode:ee.ckbCode}:{},...ee.ckbMessage!==void 0?{ckbMessage:ee.ckbMessage}:{},...ee.ckbData!==void 0?{ckbData:ee.ckbData}:{},...ee.ckbError!==void 0?{ckbError:ee.ckbError}:{},...ee.lastPushAt!==void 0?{lastPushAt:ee.lastPushAt??void 0}:{},...ee.nextRetryAt!==void 0?{nextRetryAt:ee.nextRetryAt??void 0}:{}}}async function cl(M){if(M){bs(M);try{const ee=await bt("/api/db/ckb-leads/retry",{id:M});ee!=null&&ee.success?(q.success(ee.pushed?"重推成功":"已发起重推,请刷新查看状态"),ee.record&&Ys(be=>be.map(Ae=>Ae.id===M?Yi(Ae,ee.record):Ae))):q.error((ee==null?void 0:ee.error)||"重推失败")}catch(ee){q.error(ee instanceof Error?ee.message:"重推请求失败")}finally{bs(null)}}}async function ai(M){if(M&&confirm("确定删除该条获客记录?删除后不可恢复。")){Ji(M);try{const ee=await bt("/api/db/ckb-leads/delete",{id:M});ee!=null&&ee.success?q.success("已删除"):q.error((ee==null?void 0:ee.error)||"删除失败")}catch(ee){q.error(ee instanceof Error?ee.message:"删除请求失败")}finally{Ji(null),Nt()}}}async function ii(){const M=at.filter(Ae=>Ae.pushStatus==="failed");if(M.length===0){q.info("当前页无失败记录");return}ac(!0);let ee=0;for(const Ae of M)try{const Ge=await bt("/api/db/ckb-leads/retry",{id:Ae.id});if(Ge!=null&&Ge.success&&Ge.pushed&&ee++,Ge!=null&&Ge.success&&Ge.record){const Je=Ge.record;Ys(Vt=>Vt.map(He=>He.id===Ae.id?Yi(He,Je):He))}}catch{}ac(!1);const be=M.length;q.success(`批量重推完成:成功 ${ee} / ${be}`)}function ic(){const M=at.filter(He=>He.pushStatus==="failed");if(M.length===0){q.info("当前筛选下无失败记录可导出");return}const ee=He=>`"${String(He??"").replace(/"/g,'""')}"`,Ae=[["ID","昵称","手机号","微信号","对应@人","计划Key","来源","推送状态","重试次数","失败原因","下次重试时间","创建时间"].join(",")];for(const He of M)Ae.push([ee(He.id),ee(He.userNickname||He.name||""),ee(He.phone||""),ee(He.wechatId||""),ee(He.personName||""),ee(He.planApiKey||""),ee(He.source||""),ee(He.pushStatus||""),ee(typeof He.retryCount=="number"?He.retryCount:""),ee(He.ckbError||""),ee(He.nextRetryAt?new Date(He.nextRetryAt).toLocaleString():""),ee(He.createdAt?new Date(He.createdAt).toLocaleString():"")].join(","));const Ge=new Blob(["\uFEFF"+Ae.join(`
-`)],{type:"text/csv;charset=utf-8;"}),Je=URL.createObjectURL(Ge),Vt=document.createElement("a");Vt.href=Je,Vt.download=`获客失败清单-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.csv`,document.body.appendChild(Vt),Vt.click(),document.body.removeChild(Vt),URL.revokeObjectURL(Je),q.success(`已导出失败清单(${M.length} 条)`)}const Qn=g.useCallback(async()=>{try{const M=await Le("/api/admin/mbti-avatars"),ee=M!=null&&M.avatars&&typeof M.avatars=="object"?M.avatars:{};Qs(ee)}catch{Qs({})}},[]);g.useEffect(()=>{t.get("tab")==="leads"&&Nt()},[t.get("tab"),ve,Nt]),g.useEffect(()=>{if(a!=="leads")return;const M=window.setInterval(()=>{Nt()},3e4);return()=>window.clearInterval(M)},[a,Nt]),g.useEffect(()=>{Qn()},[Qn]);const Ma=g.useCallback((M,ee)=>{const be=(M||"").trim();if(be)return be;const Ae=(ee||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(Ae)?(Vs[Ae]||"").trim():""},[Vs]),ta=g.useCallback(M=>{const ee=!!M.hasFullBook,be=Number(M.purchasedSectionCount||0);return ee?{tone:"vip",main:"已购全书",sub:be>0?`另购单章 ${be} 章`:"购买项:VIP / 全书"}:be>0?{tone:"paid",main:`已购 ${be} 章`,sub:"购买项:章节"}:{tone:"free",main:"未购买",sub:""}},[]),[Hs,Us]=g.useState(null),cn=g.useCallback(async()=>{try{const M=await Le("/api/admin/users/online-stats");M!=null&&M.success&&typeof M.onlineCount=="number"?Us(M.onlineCount):Us(0)}catch{Us(null)}},[]);g.useEffect(()=>{cn();const M=setInterval(cn,1e4);return()=>clearInterval(M)},[cn]);async function nr(M=!1){var ee;R(!0),M&&P(!0),O(null);try{if(Q){const be=new URLSearchParams({search:v,limit:String(x*5)}),Ae=await Le(`/api/db/users/rfm?${be}`);if(Ae!=null&&Ae.success){let Ge=Ae.users||[];le==="asc"&&(Ge=[...Ge].reverse());const Je=(f-1)*x;c(Ge.slice(Je,Je+x)),h(((ee=Ae.users)==null?void 0:ee.length)??0),Ge.length===0&&(re(!1),O("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else re(!1),O((Ae==null?void 0:Ae.error)||"RFM 加载失败,已切回普通模式")}else{const be=new URLSearchParams({page:String(f),pageSize:String(x),search:v,...T==="vip"&&{vip:"true"},...T==="complete"&&{pool:"complete"}}),Ae=await Le(`/api/db/users?${be}`);Ae!=null&&Ae.success?(c(Ae.users||[]),h(Ae.total??0)):O((Ae==null?void 0:Ae.error)||"加载失败")}}catch(be){console.error("Load users error:",be),O("网络错误")}finally{R(!1),M&&P(!1)}}g.useEffect(()=>{m(1)},[v,T,Q]),g.useEffect(()=>{nr()},[f,x,v,T,Q,le]);const gr=Math.ceil(u/x)||1,yr=()=>{Q?le==="desc"?me("asc"):(re(!1),me("desc")):(re(!0),me("desc"))},oc=M=>({S:"bg-amber-500/20 text-amber-400",A:"bg-green-500/20 text-green-400",B:"bg-blue-500/20 text-blue-400",C:"bg-gray-500/20 text-gray-400",D:"bg-red-500/20 text-red-400"})[M||""]||"bg-gray-500/20 text-gray-400";async function lc(M){var ee;if(!uN("用户")){q.info("已取消删除");return}try{const be=await Pi(`/api/db/users?id=${encodeURIComponent(M)}`);be!=null&&be.success?(q.success("已删除"),nr()):q.error("删除失败: "+((be==null?void 0:be.error)||"未知错误"))}catch(be){const Ae=be,Ge=((ee=Ae==null?void 0:Ae.data)==null?void 0:ee.error)||(Ae==null?void 0:Ae.message)||"网络错误";q.error("删除失败: "+Ge)}}const Aa=M=>{xe(M),At({phone:M.phone||"",nickname:M.nickname||"",password:"",isAdmin:!!(M.isAdmin??!1),hasFullBook:!!(M.hasFullBook??!1)}),Y(!0)},wd=()=>{xe(null),At({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),Y(!0)};async function dl(){if(!pt.phone||!pt.nickname){q.error("请填写手机号和昵称");return}V(!0);try{if(F){const M=await tn("/api/db/users",{id:F.id,phone:pt.phone||void 0,nickname:pt.nickname,isAdmin:pt.isAdmin,hasFullBook:pt.hasFullBook,...pt.password&&{password:pt.password}});if(!(M!=null&&M.success)){q.error("更新失败: "+((M==null?void 0:M.error)||""));return}}else{const M=await bt("/api/db/users",{phone:pt.phone,nickname:pt.nickname,password:pt.password,isAdmin:pt.isAdmin});if(!(M!=null&&M.success)){q.error("创建失败: "+((M==null?void 0:M.error)||""));return}}Y(!1),nr()}catch{q.error("保存失败")}finally{V(!1)}}async function Ns(M){Z(M),fe(!0),J(!0);try{const ee=await Le(`/api/db/users/referrals?userId=${encodeURIComponent(M.id)}`);ee!=null&&ee.success?de({referrals:ee.referrals||[],stats:ee.stats||{}}):de({referrals:[],stats:{}})}catch{de({referrals:[],stats:{}})}finally{J(!1)}}const na=g.useCallback(async()=>{qt(!0);try{const M=await Le("/api/db/user-rules");M!=null&&M.success&&Vn((M.rules||[]).map(ee=>b8(ee)))}catch{}finally{qt(!1)}},[]);async function sa(){if(!_t.title){q.error("请填写规则标题");return}V(!0);try{if(Hn){const M=await tn("/api/db/user-rules",{id:Hn.id,..._t});if(!(M!=null&&M.success)){q.error("更新失败: "+((M==null?void 0:M.error)||""));return}}else{const M=await bt("/api/db/user-rules",_t);if(!(M!=null&&M.success)){q.error("创建失败: "+((M==null?void 0:M.error)||""));return}}Mn(!1),na()}catch{q.error("保存失败")}finally{V(!1)}}async function Pa(M){if(!uN("规则")){q.info("已取消删除");return}try{const ee=await Pi(`/api/db/user-rules?id=${M}`);ee!=null&&ee.success&&na()}catch{}}async function Ia(M){try{await tn("/api/db/user-rules",{id:M.id,enabled:!M.enabled}),na()}catch{}}const _n=g.useCallback(async()=>{rt(!0);try{const M=await Le("/api/db/vip-members?limit=500");if(M!=null&&M.success&&M.data){const ee=[...M.data].map((be,Ae)=>({...be,vipSort:typeof be.vipSort=="number"?be.vipSort:Ae+1}));ee.sort((be,Ae)=>(be.vipSort??999999)-(Ae.vipSort??999999)),Me(ee)}else M&&M.error&&q.error(M.error)}catch{q.error("加载超级个体列表失败")}finally{rt(!1)}},[]),[Lr,ra]=g.useState(!1),[oi,br]=g.useState(null),[Ps,Ra]=g.useState(""),[vr,Nr]=g.useState(!1),[Xi,Or]=g.useState(!1),[aa,ia]=g.useState(null),[li,ci]=g.useState(""),[is,Dr]=g.useState(!1),di=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],ui=M=>{br(M),Ra(M.vipRole||""),ra(!0)},jd=M=>{ia(M),ci((M.webhookUrl||"").trim()),Or(!0)},ul=async M=>{const ee=M.trim();if(oi){if(!ee){q.error("请选择或输入标签");return}Nr(!0);try{const be=await tn("/api/db/users",{id:oi.id,vipRole:ee});if(!(be!=null&&be.success)){q.error((be==null?void 0:be.error)||"更新超级个体标签失败");return}q.success("已更新超级个体标签"),ra(!1),br(null),await _n()}catch{q.error("更新超级个体标签失败")}finally{Nr(!1)}}},hl=async()=>{if(!aa)return;const M=li.trim();if(M&&!/^https?:\/\//i.test(M)){q.error("Webhook 地址需以 http/https 开头");return}Dr(!0);try{const ee=await tn("/api/db/vip-members/webhook",{userId:aa.id,webhookUrl:M});if(!(ee!=null&&ee.success)){q.error((ee==null?void 0:ee.error)||"保存飞书群 Webhook 失败");return}q.success(M?"已保存该超级个体的飞书群 Webhook":"已清空该超级个体的飞书群 Webhook"),Or(!1),ia(null),await _n()}catch{q.error("保存飞书群 Webhook 失败")}finally{Dr(!1)}},[hi,oa]=g.useState(!1),[La,fl]=g.useState(null),[cc,dc]=g.useState(""),[Zi,uc]=g.useState(!1),kd=M=>{fl(M),dc(M.vipSort!=null?String(M.vipSort):""),oa(!0)},hc=async()=>{if(!La)return;const M=Number(cc);if(!Number.isFinite(M)){q.error("请输入有效的数字序号");return}uc(!0);try{const ee=await tn("/api/db/users",{id:La.id,vipSort:M});if(!(ee!=null&&ee.success)){q.error((ee==null?void 0:ee.error)||"更新排序序号失败");return}q.success("已更新排序序号"),oa(!1),fl(null),await _n()}catch{q.error("更新排序序号失败")}finally{uc(!1)}},pl=(M,ee)=>{M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/plain",ee),kt(ee)},fc=(M,ee)=>{M.preventDefault(),$e!==ee&&H(ee)},ml=()=>{kt(null),H(null)},pc=async(M,ee)=>{M.preventDefault();const be=M.dataTransfer.getData("text/plain")||$t;if(kt(null),H(null),!be||be===ee)return;const Ae=Ne.find(He=>He.id===be),Ge=Ne.find(He=>He.id===ee);if(!Ae||!Ge)return;const Je=Ae.vipSort??Ne.findIndex(He=>He.id===be)+1,Vt=Ge.vipSort??Ne.findIndex(He=>He.id===ee)+1;Me(He=>{const en=[...He],Is=en.findIndex(xc=>xc.id===be),_r=en.findIndex(xc=>xc.id===ee);if(Is===-1||_r===-1)return He;const to=[...en],[Id,Rd]=[to[Is],to[_r]];return to[Is]={...Rd,vipSort:Je},to[_r]={...Id,vipSort:Vt},to});try{const[He,en]=await Promise.all([tn("/api/db/users",{id:be,vipSort:Vt}),tn("/api/db/users",{id:ee,vipSort:Je})]);if(!(He!=null&&He.success)||!(en!=null&&en.success)){q.error((He==null?void 0:He.error)||(en==null?void 0:en.error)||"更新排序失败"),await _n();return}q.success("已更新排序"),await _n()}catch{q.error("更新排序失败"),await _n()}},xl=g.useCallback(async()=>{yt(!0);try{const M=await Le("/api/db/users/journey-stats");M!=null&&M.success&&M.stats&&vt(M.stats)}catch{}finally{yt(!1)}},[]),E=g.useCallback(async M=>{Pt(M),Ms(!0);try{const ee=await Le(`/api/db/users/journey-users?stage=${M}&limit=50`);ee!=null&&ee.success&&ee.users&&kn(ee.users)}catch{}finally{Ms(!1)}},[]),B=g.useCallback(async(M,ee)=>{ja(M),ti(ee),Qr(!0);try{const be=await Le(`/api/db/users/tracks?userId=${M}&limit=50`);be!=null&&be.success&&be.tracks&&Pr(be.tracks)}catch{}finally{Qr(!1)}},[]),[ue,ke]=g.useState(!1),Ke=async()=>{ke(!0);try{const M=await bt("/api/admin/shensheshou/batch-enrich",{limit:20});M!=null&&M.success?(q.success(`批量补全完成:${M.enriched} 人已补全,${M.skipped} 人跳过`),nr()):q.error((M==null?void 0:M.error)||"批量补全失败")}catch{q.error("批量补全请求失败")}finally{ke(!1)}},gt=M=>{const ee=[M.phone,M.nickname,M.avatar,M.wechatId,M.mbti,M.industry,M.region,M.position],be=ee.filter(Ae=>Ae!=null&&Ae!=="").length;return Math.round(be/ee.length*100)},{leadsRows:at,leadsRawCount:$n,leadsDeduped:Yn}=g.useMemo(()=>{const M=He=>(He||"").replace(/\D/g,"")||"",ee=He=>{const en=M(He.phone);if(en)return`phone:${en}`;const Is=(He.userId||"").trim();if(Is)return`user:${Is}`;const _r=(He.wechatId||"").trim();return _r?`wechat:${_r}`:`row:${He.id}`},be=Xr.trim().toLowerCase();let Ae=pr;be&&(Ae=pr.filter(He=>[He.userNickname,He.name,He.phone,He.wechatId,He.personName,He.source,He.planApiKey].filter(Boolean).join(" ").toLowerCase().includes(be)));const Ge=[...Ae].sort((He,en)=>{const Is=He.createdAt?new Date(He.createdAt).getTime():0;return(en.createdAt?new Date(en.createdAt).getTime():0)-Is});if(!Ca)return{leadsRows:Ge,leadsRawCount:Ae.length,leadsDeduped:0};const Je=new Set,Vt=[];for(const He of Ge){const en=ee(He);Je.has(en)||(Je.add(en),Vt.push(He))}return{leadsRows:Vt,leadsRawCount:Ae.length,leadsDeduped:Ae.length-Vt.length}},[pr,Xr,Ca]);g.useEffect(()=>{const M=at.map(Ae=>Ae.id),ee=M.filter(Ae=>vs.includes(Ae)).length,be=si.current;be&&(be.indeterminate=ee>0&&eebe.id),ee=M.length>0&&M.every(be=>vs.includes(be));er(ee?be=>be.filter(Ae=>!M.includes(Ae)):be=>[...new Set([...be,...M])])}function sr(M){er(ee=>ee.includes(M)?ee.filter(be=>be!==M):[...ee,M])}async function Un(){if(vs.length===0){q.info("请先勾选要删除的记录");return}const M=vs.length;if(!confirm(`确定批量删除选中的 ${M} 条获客记录?删除后不可恢复。`))return;const ee=500;xr(!0);try{let be=0;for(let Ae=0;Ae{const ee=M||"";return ee==="success"?s.jsx(Be,{className:"bg-emerald-500/20 text-emerald-300 border-0 text-xs",children:"已推送(存客宝已接收)"}):ee==="pending_verify"?s.jsx(Be,{className:"bg-sky-500/20 text-sky-300 border-0 text-xs",children:"待通过 / 处理中"}):ee==="expired"?s.jsx(Be,{className:"bg-gray-500/20 text-gray-300 border-0 text-xs",children:"已过期"}):ee==="failed"?s.jsx(Be,{className:"bg-red-500/20 text-red-300 border-0 text-xs",children:"失败"}):ee==="pending"?s.jsx(Be,{className:"bg-amber-500/20 text-amber-300 border-0 text-xs",children:"待推送"}):ee?s.jsx(Be,{className:"bg-violet-500/20 text-violet-300 border-0 text-xs",title:ee,children:ee}):s.jsx(Be,{className:"bg-amber-500/20 text-amber-300 border-0 text-xs",children:"待推送"})},Sd=g.useMemo(()=>{const M=new Map;for(const ee of at){if(ee.pushStatus!=="failed")continue;const be=(ee.ckbError||"未知错误").trim()||"未知错误";M.set(be,(M.get(be)||0)+1)}return Array.from(M.entries()).map(([ee,be])=>({reason:ee,count:be})).sort((ee,be)=>be.count-ee.count)},[at]);async function Cd(){const M=at.filter(Je=>Je.pushStatus==="failed");if(M.length===0){q.info("当前页无失败记录");return}const ee=Sd.slice(0,8).map(Je=>`- ${Je.reason}:${Je.count} 条`).join(`
+`;return`data:image/svg+xml;utf8,${encodeURIComponent(i)}`}function y8(){const[t,e]=g.useState({}),[n,r]=g.useState(!0),[a,i]=g.useState(!1),[o,c]=g.useState(!1),u=g.useCallback(async()=>{r(!0);try{const x=await Le("/api/admin/mbti-avatars");x!=null&&x.avatars?e(x.avatars):e({})}catch{q.error("加载 MBTI 头像配置失败")}finally{r(!1)}},[]);g.useEffect(()=>{u()},[u]);const h=async()=>{i(!0);try{const x=await bt("/api/admin/mbti-avatars",{avatars:t});if(!x||x.success===!1){q.error((x==null?void 0:x.error)||"保存失败");return}q.success("已保存,后台与小程序默认头像同步生效"),u()}catch{q.error("保存失败")}finally{i(!1)}},f=x=>{const b=lN(x);e(N=>({...N,[x]:b})),q.success(`${x} 已生成`)},m=()=>{c(!0);try{const x={...t};oN.forEach(b=>{x[b]=lN(b)}),e(x),q.success("16 型头像已生成(仅人物)")}finally{c(!1)}};return n?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-400",children:[s.jsx(Ve,{className:"w-5 h-5 mr-2 animate-spin text-[#38bdac]"}),"加载配置…"]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs(De,{className:"bg-[#0f2137] border-[#38bdac]/25 shadow-xl",children:[s.jsxs(dt,{className:"pb-2",children:[s.jsxs(ut,{className:"text-white flex items-center gap-2 text-lg",children:[s.jsx(SA,{className:"w-5 h-5 text-[#38bdac]"}),"MBTI 头像库"]}),s.jsx(Qt,{className:"text-gray-400 text-sm leading-relaxed",children:"采用人物化风格,按 MBTI 性格自动生成。头像内不显示中英文,仅显示人物形象,颜色与站点主题融合。"})]}),s.jsxs(_e,{className:"flex flex-wrap gap-2",children:[s.jsxs(G,{type:"button",size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396]",onClick:m,disabled:o,children:[s.jsx(GA,{className:"w-3.5 h-3.5 mr-1"}),o?"生成中…":"一键生成16头像"]}),s.jsxs(G,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-300",onClick:u,children:[s.jsx(Ve,{className:"w-3.5 h-3.5 mr-1"}),"重新加载"]}),s.jsxs(G,{type:"button",size:"sm",className:"bg-emerald-600 hover:bg-emerald-500",onClick:h,disabled:a,children:[s.jsx(Tn,{className:"w-3.5 h-3.5 mr-1"}),a?"保存中…":"保存映射"]})]})]}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:oN.map(x=>{const b=t[x]??"",N=M2[x];return s.jsxs("div",{className:"rounded-xl border border-gray-700/60 bg-[#0a1628] p-3 flex flex-col gap-2 hover:border-[#38bdac]/35 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Be,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 font-mono text-xs",children:x}),s.jsx("span",{className:"text-xs text-gray-400 truncate",title:N.title,children:N.title})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-16 h-16 rounded-full shrink-0 overflow-hidden flex items-center justify-center bg-[#081322] ring-2 ring-[#38bdac]/40 ring-offset-2 ring-offset-[#0a1628]",children:b?s.jsx("img",{src:b,alt:x,className:"w-full h-full object-cover scale-110"}):s.jsx("span",{className:"text-gray-600 text-[10px]",children:"未配"})}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"https://... 或 data:image/...",value:b,onChange:w=>e(v=>({...v,[x]:w.target.value}))})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(G,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-[#38bdac]/40 text-[#38bdac]",onClick:()=>f(x),children:"生成这张"}),s.jsx(G,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-[11px] text-gray-400",onClick:()=>e(w=>({...w,[x]:""})),children:"清空"})]})]},x)})})]})}const cN=[{value:"after_login",label:"注册/登录成功",group:"用户状态"},{value:"bind_phone",label:"绑定手机号",group:"用户状态"},{value:"update_avatar",label:"完善头像(非默认图,与昵称分开配置)",group:"用户状态"},{value:"update_nickname",label:"修改昵称(非默认微信昵称,与头像分开)",group:"用户状态"},{value:"fill_profile",label:"完善资料(MBTI/行业/职位,不含头像昵称)",group:"用户状态"},{value:"view_chapter",label:"浏览章节",group:"阅读行为"},{value:"browse_5_chapters",label:"累计浏览5个章节",group:"阅读行为"},{value:"purchase_section",label:"购买单章",group:"付费行为"},{value:"purchase_fullbook",label:"购买全书/VIP",group:"付费行为"},{value:"after_pay",label:"任意付款成功",group:"付费行为"},{value:"after_match",label:"完成派对匹配",group:"社交行为"},{value:"click_super_individual",label:"点击超级个体头像",group:"社交行为"},{value:"lead_submit",label:"提交留资/链接",group:"社交行为"},{value:"referral_bind",label:"被推荐人绑定",group:"分销行为"},{value:"share_action",label:"分享给好友/朋友圈",group:"分销行为"},{value:"withdraw_request",label:"申请提现",group:"分销行为"},{value:"add_wechat",label:"添加微信联系方式",group:"用户状态"}],dN=[{value:"popup",label:"弹窗提示",desc:"在小程序内弹窗引导用户完成下一步"},{value:"navigate",label:"跳转页面",desc:"引导用户跳转到指定页面"},{value:"webhook",label:"推送飞书群",desc:"触发后推送消息到飞书群Webhook"},{value:"tag",label:"自动打标签",desc:"触发后自动给用户打上指定标签"}];function A2(t){if(Array.isArray(t))return t.filter(e=>typeof e=="string");if(typeof t=="string")try{const e=JSON.parse(t);if(Array.isArray(e))return e.filter(n=>typeof n=="string")}catch{try{const e=typeof atob=="function"?atob(t):"",n=JSON.parse(e);if(Array.isArray(n))return n.filter(r=>typeof r=="string")}catch{}}return[]}function b8(t){return{...t,triggerConditions:A2(t.triggerConditions)}}const v8=[{level:"S",range:"≥85",label:"高价值"},{level:"A",range:"70–84",label:"优质"},{level:"B",range:"50–69",label:"中等"},{level:"C",range:"30–49",label:"潜力"},{level:"D",range:"<30",label:"待激活"}],Fc=[{id:"register",label:"注册/登录",icon:"👤",color:"bg-blue-500/20 border-blue-500/40 text-blue-400",desc:"微信授权登录或手机号注册"},{id:"browse",label:"浏览章节",icon:"📖",color:"bg-purple-500/20 border-purple-500/40 text-purple-400",desc:"点击免费/付费章节预览"},{id:"bind_phone",label:"绑定手机",icon:"📱",color:"bg-cyan-500/20 border-cyan-500/40 text-cyan-400",desc:"触发付费章节后绑定手机"},{id:"first_pay",label:"首次付款",icon:"💳",color:"bg-green-500/20 border-green-500/40 text-green-400",desc:"购买单章或全书"},{id:"fill_profile",label:"完善资料",icon:"✍️",color:"bg-yellow-500/20 border-yellow-500/40 text-yellow-400",desc:"填写头像、MBTI、行业等"},{id:"match",label:"派对房匹配",icon:"🤝",color:"bg-orange-500/20 border-orange-500/40 text-orange-400",desc:"参与 Soul 派对房"},{id:"vip",label:"升级 VIP",icon:"👑",color:"bg-amber-500/20 border-amber-500/40 text-amber-400",desc:"付款 ¥1980 购买全书"},{id:"distribution",label:"开启分销",icon:"🔗",color:"bg-[#38bdac]/20 border-[#38bdac]/40 text-[#38bdac]",desc:"生成推广码并推荐好友"}];function uN(t){return confirm(`确定删除该${t}?此操作不可恢复。`)?window.prompt(`请输入「删除」以确认删除${t}`)==="删除":!1}function N8({userId:t,userAvatar:e,nickname:n,name:r,onOpenDetail:a}){const[i,o]=g.useState(!1),c=n||r||"-",u=(c==="-"?"?":c).charAt(0),h=!!(e!=null&&e.trim())&&!i;return s.jsxs("div",{className:"flex items-center gap-2 min-w-0 max-w-[220px]",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/15 flex items-center justify-center text-xs font-medium text-[#38bdac] flex-shrink-0 overflow-hidden border border-gray-600/50","aria-hidden":!0,children:h?s.jsx("img",{src:ya(e),alt:"",className:"w-full h-full object-cover",onError:()=>o(!0)}):s.jsx("span",{children:u})}),s.jsx("button",{type:"button",className:`text-left truncate min-w-0 ${t?"hover:text-[#38bdac] cursor-pointer":"cursor-default text-gray-300"}`,disabled:!t,title:t?"查看用户详情":void 0,onClick:()=>{t&&a(t)},children:c})]})}function w8(t){const e=(t||"").trim();if(!e)return"";try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function j8(){var eo,eh,Ed,Td,Md,Ad,Pd;const[t,e]=X0(),n=t.get("pool"),r=t.get("tab")||"users",a=["users","journey","rules","vip-roles","leads"].includes(r)?r:"users",i=(t.get("leadAction")||"").trim(),[o,c]=g.useState([]),[u,h]=g.useState(0),[f,m]=g.useState(1),[x,b]=g.useState(10),[N,w]=g.useState(""),v=qa(N,300),k=n==="vip"?"vip":n==="complete"?"complete":"all",[T,C]=g.useState(k),[L,R]=g.useState(!0),[U,P]=g.useState(!1),[F,O]=g.useState(null),[Q,re]=g.useState(!1),[D,ne]=g.useState(!1),[le,me]=g.useState("desc");g.useEffect(()=>{n==="vip"?C("vip"):n==="complete"?C("complete"):n==="all"&&C("all")},[n]);const[I,Y]=g.useState(!1),[B,xe]=g.useState(null),[X,V]=g.useState(!1),[W,fe]=g.useState(!1),[he,de]=g.useState({referrals:[],stats:{}}),[_,J]=g.useState(!1),[$,Z]=g.useState(null),[ae,we]=g.useState(!1),[Fe,Ue]=g.useState(null),[wt,jn]=g.useState(!1),[pt,At]=g.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[fn,Vn]=g.useState([]),[pn,qt]=g.useState(!1),[bn,Mn]=g.useState(!1),[Hn,as]=g.useState(null),[_t,vn]=g.useState({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),[Ne,Me]=g.useState([]),[We,rt]=g.useState(!1),[$t,St]=g.useState(null),[$e,H]=g.useState(null),[Qe,vt]=g.useState({}),[Ft,yt]=g.useState(!1),[ht,Pt]=g.useState(null),[Gt,kn]=g.useState([]),[Ts,Ms]=g.useState(!1),[Ki,ja]=g.useState(null),[ei,ti]=g.useState(""),[Ar,Pr]=g.useState([]),[Ir,Qr]=g.useState(!1),[Vs,Qs]=g.useState({}),[pr,Ys]=g.useState([]),[ka,ce]=g.useState(0),[ve,Rt]=g.useState(1),[Zt]=g.useState(10),[sn,is]=g.useState(!1),[Rr,Yr]=g.useState(null),[jt,Un]=g.useState(""),Xr=qa(jt,300),[Sa,mn]=g.useState(""),[Zr,ni]=g.useState(""),[mr,As]=g.useState(""),[Ca,qi]=g.useState(!1),[Xs,Zs]=g.useState({}),[Gi,bs]=g.useState(null),[il,Ji]=g.useState(null),[vs,er]=g.useState([]),[tr,xr]=g.useState(!1),si=g.useRef(null),[ea,ac]=g.useState(!1),[ol,ri]=g.useState(!1),[Qi,Ea]=g.useState("存客宝返回 data"),[ll,Ta]=g.useState(""),Nt=g.useCallback(async(M,ee)=>{is(!0),Yr(null);try{const be=new URLSearchParams({mode:"contact",page:String(ve),pageSize:String(Zt)}),Ae=M??Xr;Ae&&be.set("search",Ae);const Ge=ee??Sa;Ge&&be.set("source",Ge),Zr&&be.set("action",Zr),mr&&be.set("pushStatus",mr);const Je=await Le(`/api/db/ckb-leads?${be}`);if(Je!=null&&Je.success)Ys(Je.records||[]),ce(Je.total??0),Je.stats&&Zs(Je.stats);else{const Vt=(Je==null?void 0:Je.error)||"加载获客列表失败";Yr(Vt),q.error(Vt),Ys([]),ce(0)}}catch(be){const Ae=be instanceof Error?be.message:"网络错误";Yr(Ae),q.error("加载获客列表失败: "+Ae),Ys([]),ce(0)}finally{is(!1)}},[ve,Zt,Xr,Sa,Zr,mr]);g.useEffect(()=>{er([])},[Xr,Sa,Zr,mr]),g.useEffect(()=>{a==="leads"&&ni(i)},[a,i]);function Yi(M,ee){return{...M,...ee.pushStatus!==void 0?{pushStatus:ee.pushStatus}:{},...typeof ee.retryCount=="number"?{retryCount:ee.retryCount}:{},...typeof ee.ckbCode=="number"?{ckbCode:ee.ckbCode}:{},...ee.ckbMessage!==void 0?{ckbMessage:ee.ckbMessage}:{},...ee.ckbData!==void 0?{ckbData:ee.ckbData}:{},...ee.ckbError!==void 0?{ckbError:ee.ckbError}:{},...ee.lastPushAt!==void 0?{lastPushAt:ee.lastPushAt??void 0}:{},...ee.nextRetryAt!==void 0?{nextRetryAt:ee.nextRetryAt??void 0}:{}}}async function cl(M){if(M){bs(M);try{const ee=await bt("/api/db/ckb-leads/retry",{id:M});ee!=null&&ee.success?(q.success(ee.pushed?"重推成功":"已发起重推,请刷新查看状态"),ee.record&&Ys(be=>be.map(Ae=>Ae.id===M?Yi(Ae,ee.record):Ae))):q.error((ee==null?void 0:ee.error)||"重推失败")}catch(ee){q.error(ee instanceof Error?ee.message:"重推请求失败")}finally{bs(null)}}}async function ai(M){if(M&&confirm("确定删除该条获客记录?删除后不可恢复。")){Ji(M);try{const ee=await bt("/api/db/ckb-leads/delete",{id:M});ee!=null&&ee.success?q.success("已删除"):q.error((ee==null?void 0:ee.error)||"删除失败")}catch(ee){q.error(ee instanceof Error?ee.message:"删除请求失败")}finally{Ji(null),Nt()}}}async function ii(){const M=at.filter(Ae=>Ae.pushStatus==="failed");if(M.length===0){q.info("当前页无失败记录");return}ac(!0);let ee=0;for(const Ae of M)try{const Ge=await bt("/api/db/ckb-leads/retry",{id:Ae.id});if(Ge!=null&&Ge.success&&Ge.pushed&&ee++,Ge!=null&&Ge.success&&Ge.record){const Je=Ge.record;Ys(Vt=>Vt.map(He=>He.id===Ae.id?Yi(He,Je):He))}}catch{}ac(!1);const be=M.length;q.success(`批量重推完成:成功 ${ee} / ${be}`)}function ic(){const M=at.filter(He=>He.pushStatus==="failed");if(M.length===0){q.info("当前筛选下无失败记录可导出");return}const ee=He=>`"${String(He??"").replace(/"/g,'""')}"`,Ae=[["ID","昵称","手机号","微信号","对应@人","计划Key","来源","推送状态","重试次数","失败原因","下次重试时间","创建时间"].join(",")];for(const He of M)Ae.push([ee(He.id),ee(He.userNickname||He.name||""),ee(He.phone||""),ee(He.wechatId||""),ee(He.personName||""),ee(He.planApiKey||""),ee(He.source||""),ee(He.pushStatus||""),ee(typeof He.retryCount=="number"?He.retryCount:""),ee(He.ckbError||""),ee(He.nextRetryAt?new Date(He.nextRetryAt).toLocaleString():""),ee(He.createdAt?new Date(He.createdAt).toLocaleString():"")].join(","));const Ge=new Blob(["\uFEFF"+Ae.join(`
+`)],{type:"text/csv;charset=utf-8;"}),Je=URL.createObjectURL(Ge),Vt=document.createElement("a");Vt.href=Je,Vt.download=`获客失败清单-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.csv`,document.body.appendChild(Vt),Vt.click(),document.body.removeChild(Vt),URL.revokeObjectURL(Je),q.success(`已导出失败清单(${M.length} 条)`)}const Qn=g.useCallback(async()=>{try{const M=await Le("/api/admin/mbti-avatars"),ee=M!=null&&M.avatars&&typeof M.avatars=="object"?M.avatars:{};Qs(ee)}catch{Qs({})}},[]);g.useEffect(()=>{t.get("tab")==="leads"&&Nt()},[t.get("tab"),ve,Nt]),g.useEffect(()=>{if(a!=="leads")return;const M=window.setInterval(()=>{Nt()},3e4);return()=>window.clearInterval(M)},[a,Nt]),g.useEffect(()=>{Qn()},[Qn]);const Ma=g.useCallback((M,ee)=>{const be=(M||"").trim();if(be)return be;const Ae=(ee||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(Ae)?(Vs[Ae]||"").trim():""},[Vs]),ta=g.useCallback(M=>{const ee=!!M.hasFullBook,be=Number(M.purchasedSectionCount||0);return ee?{tone:"vip",main:"已购全书",sub:be>0?`另购单章 ${be} 章`:"购买项:VIP / 全书"}:be>0?{tone:"paid",main:`已购 ${be} 章`,sub:"购买项:章节"}:{tone:"free",main:"未购买",sub:""}},[]),[Hs,Us]=g.useState(null),cn=g.useCallback(async()=>{try{const M=await Le("/api/admin/users/online-stats");M!=null&&M.success&&typeof M.onlineCount=="number"?Us(M.onlineCount):Us(0)}catch{Us(null)}},[]);g.useEffect(()=>{cn();const M=setInterval(cn,1e4);return()=>clearInterval(M)},[cn]);async function nr(M=!1){var ee;R(!0),M&&P(!0),O(null);try{if(Q){const be=new URLSearchParams({search:v,limit:String(x*5)}),Ae=await Le(`/api/db/users/rfm?${be}`);if(Ae!=null&&Ae.success){let Ge=Ae.users||[];le==="asc"&&(Ge=[...Ge].reverse());const Je=(f-1)*x;c(Ge.slice(Je,Je+x)),h(((ee=Ae.users)==null?void 0:ee.length)??0),Ge.length===0&&(re(!1),O("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else re(!1),O((Ae==null?void 0:Ae.error)||"RFM 加载失败,已切回普通模式")}else{const be=new URLSearchParams({page:String(f),pageSize:String(x),search:v,...T==="vip"&&{vip:"true"},...T==="complete"&&{pool:"complete"}}),Ae=await Le(`/api/db/users?${be}`);Ae!=null&&Ae.success?(c(Ae.users||[]),h(Ae.total??0)):O((Ae==null?void 0:Ae.error)||"加载失败")}}catch(be){console.error("Load users error:",be),O("网络错误")}finally{R(!1),M&&P(!1)}}g.useEffect(()=>{m(1)},[v,T,Q]),g.useEffect(()=>{nr()},[f,x,v,T,Q,le]);const gr=Math.ceil(u/x)||1,yr=()=>{Q?le==="desc"?me("asc"):(re(!1),me("desc")):(re(!0),me("desc"))},oc=M=>({S:"bg-amber-500/20 text-amber-400",A:"bg-green-500/20 text-green-400",B:"bg-blue-500/20 text-blue-400",C:"bg-gray-500/20 text-gray-400",D:"bg-red-500/20 text-red-400"})[M||""]||"bg-gray-500/20 text-gray-400";async function lc(M){var ee;if(!uN("用户")){q.info("已取消删除");return}try{const be=await Pi(`/api/db/users?id=${encodeURIComponent(M)}`);be!=null&&be.success?(q.success("已删除"),nr()):q.error("删除失败: "+((be==null?void 0:be.error)||"未知错误"))}catch(be){const Ae=be,Ge=((ee=Ae==null?void 0:Ae.data)==null?void 0:ee.error)||(Ae==null?void 0:Ae.message)||"网络错误";q.error("删除失败: "+Ge)}}const Aa=M=>{xe(M),At({phone:M.phone||"",nickname:M.nickname||"",password:"",isAdmin:!!(M.isAdmin??!1),hasFullBook:!!(M.hasFullBook??!1)}),Y(!0)},wd=()=>{xe(null),At({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),Y(!0)};async function dl(){if(!pt.phone||!pt.nickname){q.error("请填写手机号和昵称");return}V(!0);try{if(B){const M=await tn("/api/db/users",{id:B.id,phone:pt.phone||void 0,nickname:pt.nickname,isAdmin:pt.isAdmin,hasFullBook:pt.hasFullBook,...pt.password&&{password:pt.password}});if(!(M!=null&&M.success)){q.error("更新失败: "+((M==null?void 0:M.error)||""));return}}else{const M=await bt("/api/db/users",{phone:pt.phone,nickname:pt.nickname,password:pt.password,isAdmin:pt.isAdmin});if(!(M!=null&&M.success)){q.error("创建失败: "+((M==null?void 0:M.error)||""));return}}Y(!1),nr()}catch{q.error("保存失败")}finally{V(!1)}}async function Ns(M){Z(M),fe(!0),J(!0);try{const ee=await Le(`/api/db/users/referrals?userId=${encodeURIComponent(M.id)}`);ee!=null&&ee.success?de({referrals:ee.referrals||[],stats:ee.stats||{}}):de({referrals:[],stats:{}})}catch{de({referrals:[],stats:{}})}finally{J(!1)}}const na=g.useCallback(async()=>{qt(!0);try{const M=await Le("/api/db/user-rules");M!=null&&M.success&&Vn((M.rules||[]).map(ee=>b8(ee)))}catch{}finally{qt(!1)}},[]);async function sa(){if(!_t.title){q.error("请填写规则标题");return}V(!0);try{if(Hn){const M=await tn("/api/db/user-rules",{id:Hn.id,..._t});if(!(M!=null&&M.success)){q.error("更新失败: "+((M==null?void 0:M.error)||""));return}}else{const M=await bt("/api/db/user-rules",_t);if(!(M!=null&&M.success)){q.error("创建失败: "+((M==null?void 0:M.error)||""));return}}Mn(!1),na()}catch{q.error("保存失败")}finally{V(!1)}}async function Pa(M){if(!uN("规则")){q.info("已取消删除");return}try{const ee=await Pi(`/api/db/user-rules?id=${M}`);ee!=null&&ee.success&&na()}catch{}}async function Ia(M){try{await tn("/api/db/user-rules",{id:M.id,enabled:!M.enabled}),na()}catch{}}const _n=g.useCallback(async()=>{rt(!0);try{const M=await Le("/api/db/vip-members?limit=500");if(M!=null&&M.success&&M.data){const ee=[...M.data].map((be,Ae)=>({...be,vipSort:typeof be.vipSort=="number"?be.vipSort:Ae+1}));ee.sort((be,Ae)=>(be.vipSort??999999)-(Ae.vipSort??999999)),Me(ee)}else M&&M.error&&q.error(M.error)}catch{q.error("加载超级个体列表失败")}finally{rt(!1)}},[]),[Lr,ra]=g.useState(!1),[oi,br]=g.useState(null),[Ps,Ra]=g.useState(""),[vr,Nr]=g.useState(!1),[Xi,Or]=g.useState(!1),[aa,ia]=g.useState(null),[li,ci]=g.useState(""),[ls,Dr]=g.useState(!1),di=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],ui=M=>{br(M),Ra(M.vipRole||""),ra(!0)},jd=M=>{ia(M),ci((M.webhookUrl||"").trim()),Or(!0)},ul=async M=>{const ee=M.trim();if(oi){if(!ee){q.error("请选择或输入标签");return}Nr(!0);try{const be=await tn("/api/db/users",{id:oi.id,vipRole:ee});if(!(be!=null&&be.success)){q.error((be==null?void 0:be.error)||"更新超级个体标签失败");return}q.success("已更新超级个体标签"),ra(!1),br(null),await _n()}catch{q.error("更新超级个体标签失败")}finally{Nr(!1)}}},hl=async()=>{if(!aa)return;const M=li.trim();if(M&&!/^https?:\/\//i.test(M)){q.error("Webhook 地址需以 http/https 开头");return}Dr(!0);try{const ee=await tn("/api/db/vip-members/webhook",{userId:aa.id,webhookUrl:M});if(!(ee!=null&&ee.success)){q.error((ee==null?void 0:ee.error)||"保存飞书群 Webhook 失败");return}q.success(M?"已保存该超级个体的飞书群 Webhook":"已清空该超级个体的飞书群 Webhook"),Or(!1),ia(null),await _n()}catch{q.error("保存飞书群 Webhook 失败")}finally{Dr(!1)}},[hi,oa]=g.useState(!1),[La,fl]=g.useState(null),[cc,dc]=g.useState(""),[Zi,uc]=g.useState(!1),kd=M=>{fl(M),dc(M.vipSort!=null?String(M.vipSort):""),oa(!0)},hc=async()=>{if(!La)return;const M=Number(cc);if(!Number.isFinite(M)){q.error("请输入有效的数字序号");return}uc(!0);try{const ee=await tn("/api/db/users",{id:La.id,vipSort:M});if(!(ee!=null&&ee.success)){q.error((ee==null?void 0:ee.error)||"更新排序序号失败");return}q.success("已更新排序序号"),oa(!1),fl(null),await _n()}catch{q.error("更新排序序号失败")}finally{uc(!1)}},pl=(M,ee)=>{M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/plain",ee),St(ee)},fc=(M,ee)=>{M.preventDefault(),$e!==ee&&H(ee)},ml=()=>{St(null),H(null)},pc=async(M,ee)=>{M.preventDefault();const be=M.dataTransfer.getData("text/plain")||$t;if(St(null),H(null),!be||be===ee)return;const Ae=Ne.find(He=>He.id===be),Ge=Ne.find(He=>He.id===ee);if(!Ae||!Ge)return;const Je=Ae.vipSort??Ne.findIndex(He=>He.id===be)+1,Vt=Ge.vipSort??Ne.findIndex(He=>He.id===ee)+1;Me(He=>{const en=[...He],Is=en.findIndex(xc=>xc.id===be),_r=en.findIndex(xc=>xc.id===ee);if(Is===-1||_r===-1)return He;const to=[...en],[Id,Rd]=[to[Is],to[_r]];return to[Is]={...Rd,vipSort:Je},to[_r]={...Id,vipSort:Vt},to});try{const[He,en]=await Promise.all([tn("/api/db/users",{id:be,vipSort:Vt}),tn("/api/db/users",{id:ee,vipSort:Je})]);if(!(He!=null&&He.success)||!(en!=null&&en.success)){q.error((He==null?void 0:He.error)||(en==null?void 0:en.error)||"更新排序失败"),await _n();return}q.success("已更新排序"),await _n()}catch{q.error("更新排序失败"),await _n()}},xl=g.useCallback(async()=>{yt(!0);try{const M=await Le("/api/db/users/journey-stats");M!=null&&M.success&&M.stats&&vt(M.stats)}catch{}finally{yt(!1)}},[]),E=g.useCallback(async M=>{Pt(M),Ms(!0);try{const ee=await Le(`/api/db/users/journey-users?stage=${M}&limit=50`);ee!=null&&ee.success&&ee.users&&kn(ee.users)}catch{}finally{Ms(!1)}},[]),z=g.useCallback(async(M,ee)=>{ja(M),ti(ee),Qr(!0);try{const be=await Le(`/api/db/users/tracks?userId=${M}&limit=50`);be!=null&&be.success&&be.tracks&&Pr(be.tracks)}catch{}finally{Qr(!1)}},[]),[ue,ke]=g.useState(!1),Ke=async()=>{ke(!0);try{const M=await bt("/api/admin/shensheshou/batch-enrich",{limit:20});M!=null&&M.success?(q.success(`批量补全完成:${M.enriched} 人已补全,${M.skipped} 人跳过`),nr()):q.error((M==null?void 0:M.error)||"批量补全失败")}catch{q.error("批量补全请求失败")}finally{ke(!1)}},gt=M=>{const ee=[M.phone,M.nickname,M.avatar,M.wechatId,M.mbti,M.industry,M.region,M.position],be=ee.filter(Ae=>Ae!=null&&Ae!=="").length;return Math.round(be/ee.length*100)},{leadsRows:at,leadsRawCount:$n,leadsDeduped:Yn}=g.useMemo(()=>{const M=He=>(He||"").replace(/\D/g,"")||"",ee=He=>{const en=M(He.phone);if(en)return`phone:${en}`;const Is=(He.userId||"").trim();if(Is)return`user:${Is}`;const _r=(He.wechatId||"").trim();return _r?`wechat:${_r}`:`row:${He.id}`},be=Xr.trim().toLowerCase();let Ae=pr;be&&(Ae=pr.filter(He=>[He.userNickname,He.name,He.phone,He.wechatId,He.personName,He.source,He.planApiKey].filter(Boolean).join(" ").toLowerCase().includes(be)));const Ge=[...Ae].sort((He,en)=>{const Is=He.createdAt?new Date(He.createdAt).getTime():0;return(en.createdAt?new Date(en.createdAt).getTime():0)-Is});if(!Ca)return{leadsRows:Ge,leadsRawCount:Ae.length,leadsDeduped:0};const Je=new Set,Vt=[];for(const He of Ge){const en=ee(He);Je.has(en)||(Je.add(en),Vt.push(He))}return{leadsRows:Vt,leadsRawCount:Ae.length,leadsDeduped:Ae.length-Vt.length}},[pr,Xr,Ca]);g.useEffect(()=>{const M=at.map(Ae=>Ae.id),ee=M.filter(Ae=>vs.includes(Ae)).length,be=si.current;be&&(be.indeterminate=ee>0&&eebe.id),ee=M.length>0&&M.every(be=>vs.includes(be));er(ee?be=>be.filter(Ae=>!M.includes(Ae)):be=>[...new Set([...be,...M])])}function sr(M){er(ee=>ee.includes(M)?ee.filter(be=>be!==M):[...ee,M])}async function Wn(){if(vs.length===0){q.info("请先勾选要删除的记录");return}const M=vs.length;if(!confirm(`确定批量删除选中的 ${M} 条获客记录?删除后不可恢复。`))return;const ee=500;xr(!0);try{let be=0;for(let Ae=0;Ae{const ee=M||"";return ee==="success"?s.jsx(Be,{className:"bg-emerald-500/20 text-emerald-300 border-0 text-xs",children:"已推送(存客宝已接收)"}):ee==="pending_verify"?s.jsx(Be,{className:"bg-sky-500/20 text-sky-300 border-0 text-xs",children:"待通过 / 处理中"}):ee==="expired"?s.jsx(Be,{className:"bg-gray-500/20 text-gray-300 border-0 text-xs",children:"已过期"}):ee==="failed"?s.jsx(Be,{className:"bg-red-500/20 text-red-300 border-0 text-xs",children:"失败"}):ee==="pending"?s.jsx(Be,{className:"bg-amber-500/20 text-amber-300 border-0 text-xs",children:"待推送"}):ee?s.jsx(Be,{className:"bg-violet-500/20 text-violet-300 border-0 text-xs",title:ee,children:ee}):s.jsx(Be,{className:"bg-amber-500/20 text-amber-300 border-0 text-xs",children:"待推送"})},Sd=g.useMemo(()=>{const M=new Map;for(const ee of at){if(ee.pushStatus!=="failed")continue;const be=(ee.ckbError||"未知错误").trim()||"未知错误";M.set(be,(M.get(be)||0)+1)}return Array.from(M.entries()).map(([ee,be])=>({reason:ee,count:be})).sort((ee,be)=>be.count-ee.count)},[at]);async function Cd(){const M=at.filter(Je=>Je.pushStatus==="failed");if(M.length===0){q.info("当前页无失败记录");return}const ee=Sd.slice(0,8).map(Je=>`- ${Je.reason}:${Je.count} 条`).join(`
`),be=M.slice(0,30).map(Je=>Je.id).join(", "),Ae=M.slice(0,20).map(Je=>`#${Je.id} | ${Je.userNickname||Je.name||"-"} | 手机:${Je.phone||"-"} | 来源:${Je.source||"-"} | 重试:${Je.retryCount??0} | 错误:${Je.ckbError||"-"}`).join(`
`),Ge=["【获客失败排障信息】",`时间:${new Date().toLocaleString()}`,`当前页失败总数:${M.length}`,"主要失败原因:",ee||"- 无",`最近失败记录ID(最多30条):${be||"无"}`,"","失败记录明细(最多20条):",Ae||"无"].join(`
-`);try{await navigator.clipboard.writeText(Ge),q.success("已复制排障信息")}catch{q.error("复制失败,请检查浏览器剪贴板权限")}}return s.jsxs("div",{className:"p-8 w-full",children:[z&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[s.jsx("span",{children:z}),s.jsx("button",{type:"button",onClick:()=>O(null),children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-start gap-6 mb-6 flex-wrap",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"用户管理"}),s.jsxs("p",{className:"text-gray-400 mt-1 text-sm",children:["共 ",u," 位注册用户",Hs!==null&&s.jsxs("span",{className:"text-[#38bdac] ml-1",children:["· 在线 ",Hs," 人"]}),Q&&" · RFM 排序中"]})]}),s.jsx(De,{className:"shrink-0 w-full max-w-md border-[#38bdac]/35 bg-[#0f2137]/90",children:s.jsxs(_e,{className:"p-3 sm:p-4 space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>ne(M=>!M),className:"flex items-center gap-2 min-w-0 flex-1 text-left rounded-lg px-1 py-0.5 hover:bg-white/5 transition-colors","aria-expanded":D,children:[s.jsx(Of,{className:"w-5 h-5 text-[#38bdac] shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-semibold text-white",children:"算法配置"}),s.jsx("div",{className:"text-xs text-gray-500 truncate",children:D?"RFM · Are you good(用户价值分层)":"RFM · 点击展开说明"})]}),D?s.jsx(Bg,{className:"w-4 h-4 text-gray-400 shrink-0"}):s.jsx(Bi,{className:"w-4 h-4 text-gray-400 shrink-0"})]}),s.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:yr,className:"border-[#38bdac]/50 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent shrink-0",children:Q?le==="desc"?"RFM 降序":"RFM 升序":"按 RFM 排序"})]}),D&&s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"text-xs text-gray-400 leading-relaxed",children:["综合分 0–100(六维度):最近消费 R(25%)+ 订单频次 F(20%)+ 累计金额 M(20%)+ 推荐人数(15%)+ 行为轨迹(10%)+ 资料完善(10%)。各维度在全量用户中归一化,与后端"," ",s.jsx("code",{className:"text-gray-500",children:"/api/db/users/rfm"})," 一致。"]}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:v8.map(({level:M,range:ee,label:be})=>s.jsxs(Be,{variant:"outline",className:`text-[10px] border-0 ${oc(M)}`,children:[M," ",ee," · ",be]},M))})]})]})})]}),s.jsxs(Wl,{value:a,onValueChange:M=>{const ee=new URLSearchParams(t);M==="users"?ee.delete("tab"):ee.set("tab",M),e(ee)},className:"w-full",children:[s.jsxs(Ko,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[s.jsxs(Ut,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[s.jsx(Kn,{className:"w-4 h-4"})," 用户列表"]}),s.jsxs(Ut,{value:"leads",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:()=>Nt(),children:[s.jsx(Qc,{className:"w-4 h-4"})," 获客列表"]}),s.jsxs(Ut,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:xl,children:[s.jsx(ma,{className:"w-4 h-4"})," 用户旅程总览"]}),s.jsxs(Ut,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:na,children:[s.jsx(Po,{className:"w-4 h-4"})," 规则配置"]}),s.jsxs(Ut,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:_n,children:[s.jsx(Xc,{className:"w-4 h-4"})," 超级个体列表"]})]}),s.jsxs(Wt,{value:"users",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[s.jsxs(G,{variant:"outline",onClick:Ke,disabled:ue,className:"border-purple-500/50 text-purple-400 hover:bg-purple-500/10 bg-transparent",title:"批量调用神射手补全有手机号用户的资料",children:[ue?s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}):s.jsx(Ho,{className:"w-4 h-4 mr-2"}),"批量补全"]}),s.jsxs(G,{variant:"outline",onClick:()=>nr(!0),disabled:U,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${U?"animate-spin":""}`})," 刷新"]}),s.jsxs("select",{value:T,onChange:M=>{const ee=M.target.value;C(ee),m(1),n&&(t.delete("pool"),e(t))},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",disabled:Q,children:[s.jsx("option",{value:"all",children:"全部用户"}),s.jsx("option",{value:"vip",children:"VIP会员(超级个体)"}),s.jsx("option",{value:"complete",children:"完善资料用户"})]}),s.jsxs("div",{className:"relative",children:[s.jsx(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:N,onChange:M=>w(M.target.value)})]}),s.jsxs(G,{onClick:wd,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Qc,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(_e,{className:"p-0",children:L?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"用户信息"}),s.jsx(Se,{className:"text-gray-400",children:"绑定信息"}),s.jsx(Se,{className:"text-gray-400",children:"购买状态"}),s.jsx(Se,{className:"text-gray-400",children:"分销收益"}),s.jsxs(Se,{className:"text-gray-400 cursor-pointer select-none",onClick:yr,children:[s.jsxs("div",{className:"flex items-center gap-1 group",children:[s.jsx(Of,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:"RFM分值"}),Q?le==="desc"?s.jsx(Bi,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(Bg,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(_x,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),Q&&s.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),s.jsx(Se,{className:"text-gray-400",children:"资料完善"}),s.jsx(Se,{className:"text-gray-400",children:"注册时间"}),s.jsx(Se,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(ms,{children:[o.map(M=>{var ee,be,Ae;return s.jsxs(xt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[(()=>{var Vt;const Ge=Ma(M.avatar,M.mbti),Je=((Vt=M.nickname)==null?void 0:Vt.charAt(0))||"?";return s.jsx("button",{type:"button",title:"点击管理 MBTI 默认头像库",onClick:()=>jn(!0),className:"w-10 h-10 shrink-0 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] overflow-hidden ring-1 ring-transparent hover:ring-[#38bdac]/60 transition",children:Ge?s.jsx("img",{src:Ge,className:"w-full h-full rounded-full object-cover",alt:"",onError:He=>{var _r;const en=He.target;if(en.style.display="none",en.nextElementSibling)return;const Is=document.createElement("span");Is.textContent=Je,(_r=en.parentElement)==null||_r.appendChild(Is)}}):Je})})(),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",onClick:()=>{Ue(M.id),we(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left truncate max-w-[120px]",children:M.nickname}),M.isAdmin&&s.jsx(Be,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),M.openId&&!((ee=M.id)!=null&&ee.startsWith("user_"))&&s.jsx(Be,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),s.jsxs("p",{className:"text-xs text-gray-500 font-mono truncate max-w-[140px]",title:M.id,children:[(be=M.id)==null?void 0:be.slice(0,16),(((Ae=M.id)==null?void 0:Ae.length)??0)>16?"…":""]})]})]})}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[M.phone&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"📱"}),s.jsx("span",{className:"text-gray-300",children:M.phone})]}),M.wechatId&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"💬"}),s.jsx("span",{className:"text-gray-300",children:M.wechatId})]}),!M.phone&&!M.wechatId&&s.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),s.jsx(je,{children:(()=>{const Ge=ta(M);return Ge.tone==="vip"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(Be,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:Ge.main}),Ge.sub&&s.jsx("p",{className:"text-[11px] text-amber-300/80",children:Ge.sub})]}):Ge.tone==="paid"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(Be,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:Ge.main}),Ge.sub&&s.jsx("p",{className:"text-[11px] text-blue-300/80",children:Ge.sub})]}):s.jsx(Be,{variant:"outline",className:"text-gray-500 border-gray-600",children:Ge.main})})()}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(M.earnings||0)).toFixed(2)]}),parseFloat(String(M.pendingEarnings||0))>0&&s.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(M.pendingEarnings||0)).toFixed(2)]}),s.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>Ns(M),role:"button",tabIndex:0,onKeyDown:Ge=>Ge.key==="Enter"&&Ns(M),children:[s.jsx(Kn,{className:"w-3 h-3"})," 绑定",M.referralCount||0,"人"]})]})}),s.jsx(je,{children:M.rfmScore!=null&&M.rfmScore!==void 0?s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-white font-bold text-base",children:M.rfmScore}),s.jsx(Be,{className:`border-0 text-xs ${oc(M.rfmLevel)}`,children:M.rfmLevel})]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"无订单"})}),s.jsx(je,{children:(()=>{const Ge=gt(M),Je=Ge>=75?"text-green-400":Ge>=50?"text-yellow-400":"text-gray-500";return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-12 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full ${Ge>=75?"bg-green-500":Ge>=50?"bg-yellow-500":"bg-gray-500"}`,style:{width:`${Ge}%`}})}),s.jsxs("span",{className:`text-xs ${Je}`,children:[Ge,"%"]})]})})()}),s.jsx(je,{className:"text-gray-400",children:M.createdAt?new Date(M.createdAt).toLocaleDateString():"-"}),s.jsx(je,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>{Ue(M.id),we(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:s.jsx(Lf,{className:"w-4 h-4"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Aa(M),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:s.jsx(an,{className:"w-4 h-4"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>lc(M.id),title:"删除",children:s.jsx(ts,{className:"w-4 h-4"})})]})})]},M.id)}),o.length===0&&s.jsx(xt,{children:s.jsx(je,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),s.jsx(xs,{page:f,totalPages:gr,total:u,pageSize:x,onPageChange:m,onPageSizeChange:M=>{b(M),m(1)}})]})})})]}),s.jsxs(Wt,{value:"leads",children:[Rr&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[s.jsx("span",{children:Rr}),s.jsx("button",{type:"button",className:"shrink-0 ml-2",onClick:()=>Yr(null),"aria-label":"关闭",children:"×"})]}),!sn&&s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-4",children:[s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs",children:"线索总条数(含留资/加入/匹配)"}),s.jsx("p",{className:"text-xl font-bold text-white",children:ka})]}),s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs",children:"去重用户数(按 userId)"}),s.jsx("p",{className:"text-xl font-bold text-[#38bdac]",title:"后端 COUNT(DISTINCT user_id)",children:Xs.uniqueUsers??0})]}),(Xs.sourceStats&&Xs.sourceStats.length>0?Xs.sourceStats.slice(0,2):[]).map(M=>s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsxs("p",{className:"text-gray-500 text-xs",children:["来源:",M.source]}),s.jsx("p",{className:"text-xl font-bold text-purple-400",children:M.cnt})]},M.source))]}),!sn&&Sd.length>0&&s.jsx(De,{className:"bg-[#3a1010]/35 border-red-900/60 shadow-lg mb-4",children:s.jsxs(_e,{className:"p-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-red-200 font-medium",children:"失败原因聚合"}),s.jsx("p",{className:"text-red-300/70 text-xs",children:"基于当前页筛选结果,按失败原因聚合统计"})]}),s.jsx(G,{type:"button",variant:"outline",onClick:Cd,className:"border-red-600/70 text-red-200 hover:bg-red-500/10 bg-transparent",children:"一键复制排障信息"})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Sd.slice(0,8).map(M=>s.jsxs(Be,{className:"bg-red-500/15 text-red-200 border border-red-600/40",children:[M.reason," · ",M.count]},M.reason))})]})}),s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 flex-1 min-w-[200px]",children:[s.jsxs("div",{className:"relative flex-1 max-w-xs",children:[s.jsx(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{placeholder:"搜索昵称/手机/微信/@人/来源/类型…",value:Tt,onChange:M=>Jn(M.target.value),className:"pl-9 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"})]}),Xs.sourceStats&&Xs.sourceStats.length>0&&s.jsxs("select",{value:Sa,onChange:M=>{mn(M.target.value),Rt(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部来源"}),Xs.sourceStats.map(M=>s.jsxs("option",{value:M.source,children:[M.source,"(",M.cnt,")"]},M.source))]}),s.jsxs("select",{value:Zr,onChange:M=>{const ee=M.target.value;ni(ee),Rt(1),e(be=>{const Ae=new URLSearchParams(be);return Ae.set("tab","leads"),ee?Ae.set("leadAction",ee):Ae.delete("leadAction"),Ae})},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",title:"按业务类型筛选",children:[s.jsx("option",{value:"",children:"全部类型"}),s.jsx("option",{value:"lead",children:"留资线索(文章@ / 首页链接)"}),s.jsx("option",{value:"join",children:"加入报名(导师 / 资源对接 / 团队)"}),s.jsx("option",{value:"match",children:"匹配上报(找伙伴匹配)"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-xs text-gray-400 select-none bg-[#0f2137] border border-gray-700 rounded-lg px-3 py-2",children:[s.jsx("input",{type:"checkbox",checked:Ca,onChange:M=>qi(M.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer"}),"去重展示"]}),s.jsxs("select",{value:mr,onChange:M=>{As(M.target.value),Rt(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待推送"}),s.jsx("option",{value:"success",children:"已推送(存客宝已接收)"}),s.jsx("option",{value:"pending_verify",children:"待通过 / 处理中"}),s.jsx("option",{value:"expired",children:"已过期"}),s.jsx("option",{value:"failed",children:"推送失败"})]}),s.jsx(G,{type:"button",variant:"outline",onClick:()=>{As("failed"),Rt(1)},className:"border-red-600/60 text-red-300 hover:bg-red-500/10 bg-transparent text-xs h-9",children:"只看失败"}),s.jsxs("span",{className:"text-xs text-gray-500 whitespace-nowrap max-w-[min(100%,20rem)]",title:"同一页内:相同手机号或相同用户 ID(含微信侧标识)只保留最近一条",children:["本页 ",$n," 条",Yn>0?` · 已合并 ${Yn} 条重复`:""]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(G,{variant:"outline",onClick:ic,disabled:sn,className:"border-cyan-600/60 text-cyan-300 hover:bg-cyan-500/10 bg-transparent",children:"导出失败清单"}),s.jsxs(G,{variant:"outline",onClick:ii,disabled:ea||tr||sn,className:"border-amber-600/60 text-amber-300 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${ea?"animate-spin":""}`}),"重推本页失败项"]}),s.jsxs(G,{variant:"outline",onClick:()=>void Un(),disabled:tr||vs.length===0||sn,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(ts,{className:`w-4 h-4 mr-2 ${tr?"animate-pulse":""}`}),tr?"删除中…":`批量删除(${vs.length})`]}),s.jsxs(G,{variant:"outline",onClick:()=>Nt(),disabled:sn,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${sn?"animate-spin":""}`})," 刷新"]})]})]}),!sn&&at.length>0&&s.jsxs("p",{className:"text-xs text-gray-500 mb-2",children:["已选 ",s.jsx("span",{className:"text-[#38bdac]",children:vs.length})," 条 · 可翻页继续勾选 · 改搜索/筛选会清空选择",vs.length>0&&s.jsx("button",{type:"button",className:"ml-2 text-gray-400 hover:text-gray-200 underline",onClick:()=>er([]),children:"清空"})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(_e,{className:"p-0",children:sn?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400 w-10 text-center",children:s.jsx("input",{ref:si,type:"checkbox",checked:at.length>0&&at.every(M=>vs.includes(M.id)),onChange:Sn,className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer",title:"全选本页(展示行)"})}),s.jsx(Se,{className:"text-gray-400",children:"昵称"}),s.jsx(Se,{className:"text-gray-400",children:"手机号"}),s.jsx(Se,{className:"text-gray-400",children:"微信号"}),s.jsx(Se,{className:"text-gray-400",children:"对应 @人"}),s.jsx(Se,{className:"text-gray-400",children:"获客计划(Key)"}),s.jsx(Se,{className:"text-gray-400",children:"推送状态"}),s.jsx(Se,{className:"text-gray-400",children:"时间"}),s.jsx(Se,{className:"text-gray-400",children:"重试"})]})}),s.jsxs(ms,{children:[at.map(M=>s.jsxs(xt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{className:"text-center align-middle w-10",children:s.jsx("input",{type:"checkbox",checked:vs.includes(M.id),onChange:()=>sr(M.id),disabled:tr,className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer"})}),s.jsx(je,{className:"text-gray-300 align-middle",children:s.jsx(N8,{userId:M.userId,userAvatar:M.userAvatar,nickname:M.userNickname,name:M.name,onOpenDetail:ee=>{Ue(ee),we(!0)}})}),s.jsx(je,{className:"text-gray-300",children:M.phone||"-"}),s.jsx(je,{className:"text-gray-300",children:M.wechatId||"-"}),s.jsx(je,{className:"text-[#38bdac]",children:M.personName||"-"}),s.jsx(je,{className:"text-gray-400 text-xs",children:(()=>{const ee=(M.planApiKey||"").trim();if(!ee)return"-";const be=ee.length<=10?ee:`${ee.slice(0,6)}…${ee.slice(-4)}`;return s.jsx("button",{type:"button",className:"font-mono text-gray-400 hover:text-gray-200 underline decoration-dotted",title:ee,onClick:async()=>{try{await navigator.clipboard.writeText(ee),q.success("已复制计划Key")}catch{q.error("复制失败,请手动复制")}},children:be})})()}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[mc(M.pushStatus),(typeof M.ckbCode=="number"||(M.ckbMessage||"").trim())&&s.jsx("p",{className:"text-[11px] text-gray-500 max-w-[260px] truncate",title:[typeof M.ckbCode=="number"?`code=${M.ckbCode}`:"",(M.ckbMessage||"").trim()?`message=${String(M.ckbMessage).trim()}`:"",(M.ckbData||"").trim()?`data=${String(M.ckbData).trim()}`:""].filter(Boolean).join(" | "),children:[typeof M.ckbCode=="number"?`code=${M.ckbCode}`:"",(M.ckbMessage||"").trim()?String(M.ckbMessage).trim():""].filter(Boolean).join(" · ")}),!!(M.ckbData||"").trim()&&s.jsx("button",{type:"button",className:"text-[11px] text-sky-300/90 hover:text-sky-200 underline decoration-dotted",onClick:()=>{const ee=String(M.ckbData||"").trim();Ea(`存客宝返回 data(#${M.id})`),Ta(w8(ee)),ri(!0)},children:"查看 data"}),!!M.ckbError&&s.jsx("p",{className:"text-[11px] text-red-300 max-w-[220px] truncate",title:M.ckbError,children:M.ckbError})]})}),s.jsx(je,{className:"text-gray-400 whitespace-nowrap",children:M.createdAt?new Date(M.createdAt).toLocaleString():"-"}),s.jsx(je,{className:"text-gray-400 text-xs align-top py-3 min-w-[148px]",children:s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("p",{className:"text-gray-400 leading-snug",children:typeof M.retryCount=="number"?`第 ${M.retryCount} 次`:"-"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(G,{size:"sm",variant:"outline",disabled:tr||Gi===M.id||il===M.id,onClick:()=>cl(M.id),className:"h-8 px-2.5 text-[11px] border-gray-600 text-gray-200 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-3 h-3 mr-1 ${Gi===M.id?"animate-spin":""}`}),"重推"]}),s.jsxs(G,{size:"sm",variant:"outline",disabled:tr||il===M.id||Gi===M.id,onClick:()=>ai(M.id),className:"h-8 px-2.5 text-[11px] border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent shrink-0",children:[s.jsx(ts,{className:`w-3 h-3 mr-1 ${il===M.id?"animate-pulse":""}`}),"删除"]})]})]})})]},M.id)),at.length===0&&s.jsx(xt,{children:s.jsx(je,{colSpan:9,className:"p-0 align-top",children:s.jsxs("div",{className:"py-16 px-6 text-center border-t border-gray-700/40 bg-[#0a1628]/30",children:[s.jsx(Qc,{className:"w-14 h-14 text-[#38bdac]/20 mx-auto mb-4","aria-hidden":!0}),s.jsx("p",{className:"text-gray-200 font-medium mb-1",children:"暂无获客线索"}),s.jsx("p",{className:"text-gray-500 text-sm mb-6 max-w-md mx-auto leading-relaxed",children:Xr.trim()||Sa?"当前搜索或来源筛选下没有匹配记录,可清空条件后重试。":"存客宝场景产生的手机号 / 微信留资会出现在此列表。请确认获客计划已开启,并有用户完成留资。"}),s.jsxs(G,{type:"button",variant:"outline",onClick:()=>Nt(),disabled:sn,className:"border-[#38bdac]/40 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${sn?"animate-spin":""}`}),"重新加载"]})]})})})]})]}),s.jsx(xs,{page:ve,totalPages:Math.ceil(ka/Zt)||1,total:ka,pageSize:Zt,onPageChange:Rt,onPageSizeChange:()=>{}})]})})})]}),s.jsxs(Wt,{value:"journey",children:[s.jsxs("div",{className:"flex items-center justify-between mb-5",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"用户从注册到 VIP 的完整行动路径,点击各阶段查看用户动态"}),s.jsxs(G,{variant:"outline",onClick:xl,disabled:Ft,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${Ft?"animate-spin":""}`})," 刷新数据"]})]}),s.jsxs("div",{className:"relative mb-8",children:[s.jsx("div",{className:"absolute top-16 left-0 right-0 h-0.5 bg-gradient-to-r from-blue-500/20 via-[#38bdac]/30 to-amber-500/20 mx-20"}),s.jsx("div",{className:"grid grid-cols-4 gap-4 lg:grid-cols-8",children:Fc.map((M,ee)=>s.jsxs("div",{className:"relative flex flex-col items-center",children:[s.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${M.color} text-center cursor-pointer hover:opacity-80 transition-opacity ${ht===M.id?"ring-2 ring-[#38bdac]":""}`,onClick:()=>E(M.id),title:`点击查看「${M.label}」阶段的用户`,children:[s.jsx("div",{className:"text-2xl mb-1",children:M.icon}),s.jsx("div",{className:`text-xs font-medium ${M.color.split(" ").find(be=>be.startsWith("text-"))}`,children:M.label}),Qe[M.id]!==void 0&&s.jsxs("div",{className:"mt-1.5 text-xs text-gray-400",children:[s.jsx("span",{className:"font-bold text-white",children:Qe[M.id]})," 人"]}),s.jsx("div",{className:"absolute -top-2.5 -left-2.5 w-5 h-5 rounded-full bg-[#0a1628] border border-gray-700 flex items-center justify-center text-[10px] text-gray-500",children:ee+1})]}),ees.jsxs("div",{className:"flex items-start gap-3 p-2 bg-[#0a1628] rounded",children:[s.jsx("span",{className:"text-[#38bdac] font-mono text-xs shrink-0 mt-0.5",children:M.step}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-300",children:M.action}),s.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",M.next]})]})]},M.step))})]}),s.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(ur,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"行为锚点统计"}),s.jsx("span",{className:"text-gray-500 text-xs ml-auto",children:"实时更新"})]}),Ft?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(Qe).length>0?s.jsx("div",{className:"space-y-2",children:(()=>{const M=Fc.reduce((ee,be)=>ee+(Qe[be.id]||0),0);return Fc.map(ee=>{const be=Qe[ee.id]||0,Ae=M>0?Math.round(be/M*100):0,Ge=be>0?Math.max(Ae,6):0;return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-gray-500 text-xs w-[5.5rem] shrink-0 leading-tight",children:[ee.icon," ",ee.label]}),s.jsx("div",{className:"flex-1 h-2.5 bg-[#0a1628] rounded-full overflow-hidden border border-gray-700/40",children:s.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-[#38bdac]/50 to-[#38bdac] transition-all",style:{width:`${Ge}%`}})}),s.jsx("span",{className:"text-gray-400 text-xs w-14 text-right tabular-nums",children:be}),s.jsx("span",{className:"text-gray-600 text-[10px] w-8 text-right tabular-nums",children:M>0?`${Ae}%`:"—"})]},ee.id)})})()}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]}),ht&&s.jsxs("div",{className:"mt-6 bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Kn,{className:"w-4 h-4 text-[#38bdac]"}),s.jsxs("span",{className:"text-white font-medium",children:[(eo=Fc.find(M=>M.id===ht))==null?void 0:eo.icon," ",(eh=Fc.find(M=>M.id===ht))==null?void 0:eh.label," 阶段用户"]}),s.jsxs(Be,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:[Gt.length," 人"]})]}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Pt(null),className:"text-gray-400 hover:text-white",children:s.jsx(ns,{className:"w-4 h-4"})})]}),Ts?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Gt.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"该阶段暂无用户"}):s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"昵称"}),s.jsx(Se,{className:"text-gray-400",children:"手机号"}),s.jsx(Se,{className:"text-gray-400",children:"注册时间"}),s.jsx(Se,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsx(ms,{children:Gt.map(M=>s.jsxs(xt,{className:"border-gray-700/50 hover:bg-[#0a1628]",children:[s.jsx(je,{className:"text-white",children:M.nickname||"微信用户"}),s.jsx(je,{className:"text-gray-300",children:M.phone||"-"}),s.jsx(je,{className:"text-gray-400 text-xs",children:M.createdAt?new Date(M.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx(je,{className:"text-right",children:s.jsxs(G,{variant:"ghost",size:"sm",className:"text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>B(M.id,M.nickname||"微信用户"),children:[s.jsx(Lf,{className:"w-4 h-4 mr-1"})," 行为轨迹"]})})]},M.id))})]})]}),s.jsx(Lt,{open:!!Ki,onOpenChange:M=>{M||ja(null)},children:s.jsxs(It,{className:"sm:max-w-[600px] bg-[#0f2137] border-gray-700 text-white max-h-[80vh] overflow-y-auto",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(ma,{className:"w-5 h-5 text-[#38bdac]"}),ei," 的行为轨迹"]})}),Ir?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Ar.length===0?s.jsx("p",{className:"text-gray-500 text-center py-8",children:"该用户暂无行为记录"}):s.jsxs("div",{className:"relative pl-6 space-y-0",children:[s.jsx("div",{className:"absolute left-[11px] top-2 bottom-2 w-0.5 bg-gray-700"}),Ar.map((M,ee)=>s.jsxs("div",{className:"relative flex items-start gap-3 py-2",children:[s.jsx("div",{className:"absolute left-[-13px] top-3 w-2.5 h-2.5 rounded-full bg-[#38bdac] border-2 border-[#0f2137] z-10"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-white text-sm font-medium",children:M.actionLabel}),M.module&&s.jsx(Be,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[10px]",children:M.module})]}),(M.chapterTitle||M.target)&&s.jsx("p",{className:"text-gray-400 text-xs mt-0.5 truncate",children:M.chapterTitle||M.target}),s.jsxs("p",{className:"text-gray-600 text-[10px] mt-0.5",children:[M.timeAgo," · ",M.createdAt?new Date(M.createdAt).toLocaleString("zh-CN"):""]})]})]},M.id||ee))]})]})})]}),s.jsxs(Wt,{value:"rules",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"用户旅程触达规则:各行为节点的触发条件与展示文案(偏利他说明,少用命令式)"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(G,{variant:"outline",onClick:na,disabled:pn,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${pn?"animate-spin":""}`})," 刷新"]}),s.jsxs(G,{onClick:()=>{rs(null),vn({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),Mn(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Rn,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),pn?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):fn.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(ur,{className:"w-12 h-12 text-[#38bdac]/30 mx-auto mb-4"}),s.jsx("p",{className:"text-gray-400 mb-4",children:"暂无规则(重启服务将自动写入10条默认规则)"}),s.jsxs(G,{onClick:na,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Ve,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):s.jsx("div",{className:"space-y-2",children:fn.map(M=>{var be;const ee=A2(M.triggerConditions);return s.jsxs("div",{className:`p-3 rounded-lg border transition-all ${M.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[s.jsxs("span",{className:"text-gray-600 text-xs font-mono w-5 shrink-0 text-right",children:["#",M.sort]}),s.jsx(an,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),s.jsx("span",{className:"text-white font-medium text-sm truncate",children:M.title}),M.trigger&&s.jsx(Be,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-[10px] shrink-0",children:M.trigger}),ee.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-0.5 ml-1",children:[ee.slice(0,3).map(Ae=>{const Ge=cN.find(Je=>Je.value===Ae);return s.jsx(Be,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[9px]",children:(Ge==null?void 0:Ge.label)||Ae},Ae)}),ee.length>3&&s.jsxs("span",{className:"text-gray-500 text-[9px]",children:["+",ee.length-3]})]}),M.actionType&&M.actionType!=="popup"&&s.jsx(Be,{className:"bg-amber-500/10 text-amber-400 border border-amber-500/30 text-[9px] shrink-0",children:((be=dN.find(Ae=>Ae.value===M.actionType))==null?void 0:be.label)||M.actionType})]}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-3 shrink-0",children:[s.jsx(Kt,{checked:M.enabled,onCheckedChange:()=>Ia(M)}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>{rs(M),vn({title:M.title,description:M.description,trigger:M.trigger,triggerConditions:ee,actionType:M.actionType||"popup",sort:M.sort,enabled:M.enabled}),Mn(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10 h-7 w-7 p-0",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Pa(M.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 h-7 w-7 p-0",children:s.jsx(ts,{className:"w-3.5 h-3.5"})})]})]}),M.description&&s.jsxs("details",{className:"ml-[52px] mt-1",children:[s.jsxs("summary",{className:"text-gray-500 text-xs cursor-pointer hover:text-gray-400 select-none",children:["查看完整描述",s.jsxs("span",{className:"text-gray-600 ml-1",children:["(",M.description.length," 字,默认折叠)"]})]}),s.jsx("p",{className:"text-gray-400 text-sm mt-1 pl-1 border-l-2 border-gray-700 whitespace-pre-wrap",children:M.description})]})]},M.id)})})]}),s.jsxs(Wt,{value:"vip-roles",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"展示当前所有有效的超级个体(VIP 用户),用于检查会员信息与排序值。"}),s.jsx("p",{className:"text-xs text-[#38bdac]",children:"提示:按住任意一行即可拖拽排序,释放后将同步更新小程序展示顺序。"})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs(G,{variant:"outline",onClick:_n,disabled:We,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${We?"animate-spin":""}`})," ","刷新"]})})]}),We?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):Ne.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(Xc,{className:"w-12 h-12 text-amber-400/30 mx-auto mb-4"}),s.jsx("p",{className:"text-gray-400 mb-4",children:"当前没有有效的超级个体用户。"})]}):s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(_e,{className:"p-0",children:s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400 w-12",children:"序号"}),s.jsx(Se,{className:"text-gray-400",children:"成员"}),s.jsx(Se,{className:"text-gray-400 min-w-40",children:"超级个体标签"}),s.jsx(Se,{className:"text-gray-400 w-16 text-center",children:"头像点击"}),s.jsx(Se,{className:"text-gray-400 w-16 text-center",children:"获客数"}),s.jsx(Se,{className:"text-gray-400 w-20",children:"排序值"}),s.jsx(Se,{className:"text-gray-400 w-36",children:"飞书群"}),s.jsx(Se,{className:"text-gray-400 w-36 text-right",children:"操作"})]})}),s.jsx(ms,{children:Ne.map((M,ee)=>{var Ge;const be=$t===M.id,Ae=$e===M.id;return s.jsxs(xt,{draggable:!0,onDragStart:Je=>pl(Je,M.id),onDragOver:Je=>fc(Je,M.id),onDrop:Je=>pc(Je,M.id),onDragEnd:ml,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${be?"opacity-60":""} ${Ae?"bg-[#38bdac]/10":""}`,children:[s.jsx(je,{className:"text-gray-300",children:ee+1}),s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[Ma(M.avatar,M.mbti)?s.jsx("img",{src:Ma(M.avatar,M.mbti),className:"w-8 h-8 rounded-full object-cover border border-amber-400/60",alt:"",onError:Je=>{var He,en;Je.target.style.display="none";const Vt=document.createElement("div");Vt.className="w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",Vt.textContent=((He=M.name)==null?void 0:He[0])||"创",(en=Je.target.parentElement)==null||en.appendChild(Vt)}}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",children:((Ge=M.name)==null?void 0:Ge[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:M.name})})]})}),s.jsx(je,{className:"text-gray-300 whitespace-nowrap",children:M.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置)"})}),s.jsx(je,{className:"text-center text-blue-400 text-xs font-mono",children:M.clickCount!=null?String(M.clickCount):"-"}),s.jsx(je,{className:"text-center text-green-400 text-xs font-mono",children:M.leadCount!=null?String(M.leadCount):"-"}),s.jsx(je,{className:"text-gray-300",children:M.vipSort??ee+1}),s.jsx(je,{className:"text-xs",children:M.webhookUrl?s.jsx("span",{className:"text-[#38bdac] truncate block max-w-[180px]",title:M.webhookUrl,children:"已配置"}):s.jsx("span",{className:"text-gray-500",children:"未配置"})}),s.jsx(je,{className:"text-right text-xs text-gray-300",children:s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>ui(M),title:"设置超级个体标签",children:s.jsx(xu,{className:"w-3.5 h-3.5"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-[#38bdac] hover:text-[#5fe0cd]",onClick:()=>jd(M),title:"编辑飞书群Webhook",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>kd(M),title:"设置排序序号",children:s.jsx(_x,{className:"w-3.5 h-3.5"})})]})})]},M.id)})})]})})})]})]}),s.jsx(Lt,{open:wt,onOpenChange:jn,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-6xl",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:"MBTI 默认头像库"})}),s.jsx(y8,{})]})}),s.jsx(Lt,{open:hi,onOpenChange:M=>{oa(M),M||fl(null)},children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(_x,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",La==null?void 0:La.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:cc,onChange:M=>dc(M.target.value)})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>oa(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ns,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:hc,disabled:Zi,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),Zi?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:Lr,onOpenChange:M=>{ra(M),M||br(null)},children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Xc,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",oi==null?void 0:oi.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:di.map(M=>s.jsx(G,{variant:Ps===M?"default":"outline",size:"sm",className:Ps===M?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>Ra(M),children:M},M))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"或手动输入"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:Ps,onChange:M=>Ra(M.target.value)})]})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>ra(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ns,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:()=>ul(Ps),disabled:vr,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),vr?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:Xi,onOpenChange:M=>{Or(M),M||ia(null)},children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-xl",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}),"设置飞书群 Webhook — ",aa==null?void 0:aa.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"VOX Webhook 地址(留空即清空)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",value:li,onChange:M=>ci(M.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"当用户点击该超级个体头像并提交链接时,线索将优先推送到这里配置的飞书群。"})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>Or(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ns,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:hl,disabled:is,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),is?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:I,onOpenChange:Y,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[F?s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Qc,{className:"w-5 h-5 text-[#38bdac]"}),F?"编辑用户":"添加用户"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"手机号"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:pt.phone,onChange:M=>At({...pt,phone:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"昵称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:pt.nickname,onChange:M=>At({...pt,nickname:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:F?"新密码 (留空则不修改)":"密码"}),s.jsx(oe,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:F?"留空则不修改":"请输入密码",value:pt.password,onChange:M=>At({...pt,password:M.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(te,{className:"text-gray-300",children:"管理员权限"}),s.jsx(Kt,{checked:pt.isAdmin,onCheckedChange:M=>At({...pt,isAdmin:M})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(te,{className:"text-gray-300",children:"已购全书"}),s.jsx(Kt,{checked:pt.hasFullBook,onCheckedChange:M=>At({...pt,hasFullBook:M})})]})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>Y(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ns,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:dl,disabled:X,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),X?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:bn,onOpenChange:Mn,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[90vh] overflow-y-auto",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}),Hn?"编辑规则":"添加规则"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"规则标题 *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:_t.title,onChange:M=>vn({..._t,title:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"规则描述"}),s.jsx(el,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[60px] resize-none",placeholder:"弹窗内容/推送文案...",value:_t.description,onChange:M=>vn({..._t,description:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"触发条件(可多选)"}),s.jsx("div",{className:"space-y-2",children:["用户状态","阅读行为","付费行为","社交行为","分销行为"].map(M=>{const ee=cN.filter(be=>be.group===M);return ee.length===0?null:s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-gray-500 mb-1",children:M}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:ee.map(be=>{const Ae=(_t.triggerConditions||[]).includes(be.value);return s.jsx("button",{type:"button",className:`px-2.5 py-1 rounded-md text-xs border transition-colors ${Ae?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-[#0a1628] border-gray-700 text-gray-400 hover:border-gray-500"}`,onClick:()=>{const Ge=_t.triggerConditions||[],Je=Ae?Ge.filter(Vt=>Vt!==be.value):[...Ge,be.value];vn({..._t,triggerConditions:Je})},children:be.label},be.value)})})]},M)})}),(_t.triggerConditions||[]).length>0&&s.jsxs("p",{className:"text-[10px] text-[#38bdac]",children:["已选 ",(_t.triggerConditions||[]).length," 个触发条件(满足任一即触发)"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"兼容触发标识(旧版)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white text-xs h-8",placeholder:"与小程序一致:注册、完成付款、update_avatar、update_nickname 等",value:_t.trigger,onChange:M=>vn({..._t,trigger:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"推送动作"}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:dN.map(M=>s.jsxs("button",{type:"button",className:`p-2 rounded-lg border text-left transition-colors ${_t.actionType===M.value?"bg-[#38bdac]/15 border-[#38bdac]/50":"bg-[#0a1628] border-gray-700 hover:border-gray-500"}`,onClick:()=>vn({..._t,actionType:M.value}),children:[s.jsx("span",{className:`text-xs font-medium ${_t.actionType===M.value?"text-[#38bdac]":"text-gray-300"}`,children:M.label}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5",children:M.desc})]},M.value))})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{children:s.jsx(te,{className:"text-gray-300",children:"启用状态"})}),s.jsx(Kt,{checked:_t.enabled,onCheckedChange:M=>vn({..._t,enabled:M})})]})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>Mn(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ns,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:sa,disabled:X,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),X?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:W,onOpenChange:fe,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Kn,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",$==null?void 0:$.nickname]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsx("div",{className:"text-2xl font-bold text-[#38bdac]",children:((Ed=he.stats)==null?void 0:Ed.total)||0}),s.jsx("div",{className:"text-xs text-gray-400",children:"绑定总数"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsx("div",{className:"text-2xl font-bold text-green-400",children:((Td=he.stats)==null?void 0:Td.purchased)||0}),s.jsx("div",{className:"text-xs text-gray-400",children:"已付费"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsxs("div",{className:"text-2xl font-bold text-yellow-400",children:["¥",(((Md=he.stats)==null?void 0:Md.earnings)||0).toFixed(2)]}),s.jsx("div",{className:"text-xs text-gray-400",children:"累计收益"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsxs("div",{className:"text-2xl font-bold text-orange-400",children:["¥",(((Ad=he.stats)==null?void 0:Ad.pendingEarnings)||0).toFixed(2)]}),s.jsx("div",{className:"text-xs text-gray-400",children:"待提现"})]})]}),_?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((Pd=he.referrals)==null?void 0:Pd.length)??0)>0?s.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(he.referrals??[]).map((M,ee)=>{var Ae;const be=M;return s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:((Ae=be.nickname)==null?void 0:Ae.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white text-sm",children:be.nickname}),s.jsx("div",{className:"text-xs text-gray-500",children:be.phone||(be.hasOpenId?"微信用户":"未绑定")})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[be.status==="vip"&&s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),be.status==="paid"&&s.jsxs(Be,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",be.purchasedSections,"章"]}),be.status==="free"&&s.jsx(Be,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),s.jsx("span",{className:"text-xs text-gray-500",children:be.createdAt?new Date(be.createdAt).toLocaleDateString():""})]})]},be.id||ee)})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),s.jsx(nn,{children:s.jsx(G,{variant:"outline",onClick:()=>fe(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),s.jsx(py,{open:ae,onClose:()=>we(!1),userId:Fe,onUserUpdated:nr}),s.jsx(Lt,{open:ol,onOpenChange:ri,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700/60 text-white max-w-2xl",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:Qi})}),s.jsx("div",{className:"mt-2",children:s.jsx("pre",{className:"text-xs text-gray-200 bg-[#0a1628] border border-gray-700/60 rounded-lg p-3 max-h-[520px] overflow-auto whitespace-pre-wrap break-words",children:ll||"—"})}),s.jsxs(nn,{children:[s.jsx(G,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 hover:bg-gray-700/50 bg-transparent",onClick:async()=>{try{await navigator.clipboard.writeText(ll||""),q.success("已复制 data")}catch{q.error("复制失败,请手动复制")}},disabled:!ll,children:"复制 data"}),s.jsx(G,{type:"button",className:"bg-[#38bdac] hover:bg-[#2aa896] text-white",onClick:()=>ri(!1),children:"关闭"})]})]})})]})}function Ff(t,[e,n]){return Math.min(n,Math.max(e,t))}var P2=["PageUp","PageDown"],I2=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],R2={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},gd="Slider",[Xg,k8,S8]=dy(gd),[L2]=Zo(gd,[S8]),[C8,Up]=L2(gd),O2=g.forwardRef((t,e)=>{const{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:u=0,defaultValue:h=[r],value:f,onValueChange:m=()=>{},onValueCommit:x=()=>{},inverted:b=!1,form:N,...w}=t,v=g.useRef(new Set),k=g.useRef(0),C=o==="horizontal"?E8:T8,[L=[],R]=Hl({prop:f,defaultProp:h,onChange:re=>{var ne;(ne=[...v.current][k.current])==null||ne.focus(),m(re)}}),U=g.useRef(L);function P(re){const D=R8(L,re);Q(re,D)}function z(re){Q(re,k.current)}function O(){const re=U.current[k.current];L[k.current]!==re&&x(L)}function Q(re,D,{commit:ne}={commit:!1}){const le=_8(i),me=$8(Math.round((re-r)/i)*i+r,le),I=Ff(me,[r,a]);R((Y=[])=>{const F=P8(Y,I,D);if(D8(F,u*i)){k.current=F.indexOf(I);const xe=String(F)!==String(Y);return xe&&ne&&x(F),xe?F:Y}else return Y})}return s.jsx(C8,{scope:t.__scopeSlider,name:n,disabled:c,min:r,max:a,valueIndexToChangeRef:k,thumbs:v.current,values:L,orientation:o,form:N,children:s.jsx(Xg.Provider,{scope:t.__scopeSlider,children:s.jsx(Xg.Slot,{scope:t.__scopeSlider,children:s.jsx(C,{"aria-disabled":c,"data-disabled":c?"":void 0,...w,ref:e,onPointerDown:jt(w.onPointerDown,()=>{c||(U.current=L)}),min:r,max:a,inverted:b,onSlideStart:c?void 0:P,onSlideMove:c?void 0:z,onSlideEnd:c?void 0:O,onHomeKeyDown:()=>!c&&Q(r,0,{commit:!0}),onEndKeyDown:()=>!c&&Q(a,L.length-1,{commit:!0}),onStepKeyDown:({event:re,direction:D})=>{if(!c){const me=P2.includes(re.key)||re.shiftKey&&I2.includes(re.key)?10:1,I=k.current,Y=L[I],F=i*me*D;Q(Y+F,I,{commit:!0})}}})})})})});O2.displayName=gd;var[D2,_2]=L2(gd,{startEdge:"left",endEdge:"right",size:"width",direction:1}),E8=g.forwardRef((t,e)=>{const{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,x]=g.useState(null),b=Xt(e,C=>x(C)),N=g.useRef(void 0),w=Bp(a),v=w==="ltr",k=v&&!i||!v&&i;function T(C){const L=N.current||m.getBoundingClientRect(),R=[0,L.width],P=my(R,k?[n,r]:[r,n]);return N.current=L,P(C-L.left)}return s.jsx(D2,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:s.jsx($2,{dir:w,"data-orientation":"horizontal",...f,ref:b,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:C=>{const L=T(C.clientX);o==null||o(L)},onSlideMove:C=>{const L=T(C.clientX);c==null||c(L)},onSlideEnd:()=>{N.current=void 0,u==null||u()},onStepKeyDown:C=>{const R=R2[k?"from-left":"from-right"].includes(C.key);h==null||h({event:C,direction:R?-1:1})}})})}),T8=g.forwardRef((t,e)=>{const{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=g.useRef(null),m=Xt(e,f),x=g.useRef(void 0),b=!a;function N(w){const v=x.current||f.current.getBoundingClientRect(),k=[0,v.height],C=my(k,b?[r,n]:[n,r]);return x.current=v,C(w-v.top)}return s.jsx(D2,{scope:t.__scopeSlider,startEdge:b?"bottom":"top",endEdge:b?"top":"bottom",size:"height",direction:b?1:-1,children:s.jsx($2,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const v=N(w.clientY);i==null||i(v)},onSlideMove:w=>{const v=N(w.clientY);o==null||o(v)},onSlideEnd:()=>{x.current=void 0,c==null||c()},onStepKeyDown:w=>{const k=R2[b?"from-bottom":"from-top"].includes(w.key);u==null||u({event:w,direction:k?-1:1})}})})}),$2=g.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=Up(gd,n);return s.jsx(Et.span,{...h,ref:e,onKeyDown:jt(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):P2.concat(I2).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:jt(t.onPointerDown,m=>{const x=m.target;x.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(x)?x.focus():r(m)}),onPointerMove:jt(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&a(m)}),onPointerUp:jt(t.onPointerUp,m=>{const x=m.target;x.hasPointerCapture(m.pointerId)&&(x.releasePointerCapture(m.pointerId),i(m))})})}),z2="SliderTrack",F2=g.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=Up(z2,n);return s.jsx(Et.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:e})});F2.displayName=z2;var Zg="SliderRange",B2=g.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=Up(Zg,n),i=_2(Zg,n),o=g.useRef(null),c=Xt(e,o),u=a.values.length,h=a.values.map(x=>U2(x,a.min,a.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return s.jsx(Et.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:c,style:{...t.style,[i.startEdge]:f+"%",[i.endEdge]:m+"%"}})});B2.displayName=Zg;var e0="SliderThumb",V2=g.forwardRef((t,e)=>{const n=k8(t.__scopeSlider),[r,a]=g.useState(null),i=Xt(e,c=>a(c)),o=g.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(M8,{...t,ref:i,index:o})}),M8=g.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:a,...i}=t,o=Up(e0,n),c=_2(e0,n),[u,h]=g.useState(null),f=Xt(e,T=>h(T)),m=u?o.form||!!u.closest("form"):!0,x=fy(u),b=o.values[r],N=b===void 0?0:U2(b,o.min,o.max),w=I8(r,o.values.length),v=x==null?void 0:x[c.size],k=v?L8(v,N,c.direction):0;return g.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),s.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${N}% + ${k}px)`},children:[s.jsx(Xg.ItemSlot,{scope:t.__scopeSlider,children:s.jsx(Et.span,{role:"slider","aria-label":t["aria-label"]||w,"aria-valuemin":o.min,"aria-valuenow":b,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:f,style:b===void 0?{display:"none"}:t.style,onFocus:jt(t.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),m&&s.jsx(H2,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:b},r)]})});V2.displayName=e0;var A8="RadioBubbleInput",H2=g.forwardRef(({__scopeSlider:t,value:e,...n},r)=>{const a=g.useRef(null),i=Xt(a,r),o=hy(e);return g.useEffect(()=>{const c=a.current;if(!c)return;const u=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==e&&f){const m=new Event("input",{bubbles:!0});f.call(c,e),c.dispatchEvent(m)}},[o,e]),s.jsx(Et.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});H2.displayName=A8;function P8(t=[],e,n){const r=[...t];return r[n]=e,r.sort((a,i)=>a-i)}function U2(t,e,n){const i=100/(n-e)*(t-e);return Ff(i,[0,100])}function I8(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function R8(t,e){if(t.length===1)return 0;const n=t.map(a=>Math.abs(a-e)),r=Math.min(...n);return n.indexOf(r)}function L8(t,e,n){const r=t/2,i=my([0,50],[0,r]);return(r-i(e)*n)*n}function O8(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function D8(t,e){if(e>0){const n=O8(t);return Math.min(...n)>=e}return!0}function my(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(t[1]-t[0]);return e[0]+r*(n-t[0])}}function _8(t){return(String(t).split(".")[1]||"").length}function $8(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var z8=O2,F8=F2,B8=B2,V8=V2;function H8({className:t,defaultValue:e,value:n,min:r=0,max:a=100,...i}){const o=g.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[r,a],[n,e,r,a]);return s.jsxs(z8,{defaultValue:e,value:n,min:r,max:a,className:zt("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...i,children:[s.jsx(F8,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:s.jsx(B8,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>s.jsx(V8,{className:"block size-4 shrink-0 rounded-full border-2 border-[#38bdac] bg-white shadow-sm focus-visible:ring-2 focus-visible:ring-[#38bdac] focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"},u))]})}const U8={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,withdrawFee:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function W2(t){const e=!!(t!=null&&t.embedded),[n,r]=g.useState(U8),[a,i]=g.useState(!0),[o,c]=g.useState(!1);g.useEffect(()=>{Le("/api/admin/referral-settings").then(f=>{const m=f==null?void 0:f.data;m&&typeof m=="object"&&r({distributorShare:m.distributorShare??90,minWithdrawAmount:m.minWithdrawAmount??10,bindingDays:m.bindingDays??30,userDiscount:m.userDiscount??5,withdrawFee:m.withdrawFee??5,enableAutoWithdraw:m.enableAutoWithdraw??!1,vipOrderShareVip:m.vipOrderShareVip??20,vipOrderShareNonVip:m.vipOrderShareNonVip??10})}).catch(console.error).finally(()=>i(!1))},[]);const u=async()=>{c(!0);try{const f={distributorShare:Number(n.distributorShare)||0,minWithdrawAmount:Number(n.minWithdrawAmount)||0,bindingDays:Number(n.bindingDays)||0,userDiscount:Number(n.userDiscount)||0,withdrawFee:Number(n.withdrawFee)??5,enableAutoWithdraw:!!n.enableAutoWithdraw,vipOrderShareVip:Number(n.vipOrderShareVip)||20,vipOrderShareNonVip:Number(n.vipOrderShareNonVip)||10},m=await bt("/api/admin/referral-settings",f);if(!m||m.success===!1){q.error("保存失败: "+(m&&typeof m=="object"&&"error"in m?m.error:""));return}q.success(`✅ 分销配置已保存成功!
+`);try{await navigator.clipboard.writeText(Ge),q.success("已复制排障信息")}catch{q.error("复制失败,请检查浏览器剪贴板权限")}}return s.jsxs("div",{className:"p-8 w-full",children:[F&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[s.jsx("span",{children:F}),s.jsx("button",{type:"button",onClick:()=>O(null),children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-start gap-6 mb-6 flex-wrap",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"用户管理"}),s.jsxs("p",{className:"text-gray-400 mt-1 text-sm",children:["共 ",u," 位注册用户",Hs!==null&&s.jsxs("span",{className:"text-[#38bdac] ml-1",children:["· 在线 ",Hs," 人"]}),Q&&" · RFM 排序中"]})]}),s.jsx(De,{className:"shrink-0 w-full max-w-md border-[#38bdac]/35 bg-[#0f2137]/90",children:s.jsxs(_e,{className:"p-3 sm:p-4 space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>ne(M=>!M),className:"flex items-center gap-2 min-w-0 flex-1 text-left rounded-lg px-1 py-0.5 hover:bg-white/5 transition-colors","aria-expanded":D,children:[s.jsx(Of,{className:"w-5 h-5 text-[#38bdac] shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-semibold text-white",children:"算法配置"}),s.jsx("div",{className:"text-xs text-gray-500 truncate",children:D?"RFM · Are you good(用户价值分层)":"RFM · 点击展开说明"})]}),D?s.jsx(Bg,{className:"w-4 h-4 text-gray-400 shrink-0"}):s.jsx(Bi,{className:"w-4 h-4 text-gray-400 shrink-0"})]}),s.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:yr,className:"border-[#38bdac]/50 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent shrink-0",children:Q?le==="desc"?"RFM 降序":"RFM 升序":"按 RFM 排序"})]}),D&&s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"text-xs text-gray-400 leading-relaxed",children:["综合分 0–100(六维度):最近消费 R(25%)+ 订单频次 F(20%)+ 累计金额 M(20%)+ 推荐人数(15%)+ 行为轨迹(10%)+ 资料完善(10%)。各维度在全量用户中归一化,与后端"," ",s.jsx("code",{className:"text-gray-500",children:"/api/db/users/rfm"})," 一致。"]}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:v8.map(({level:M,range:ee,label:be})=>s.jsxs(Be,{variant:"outline",className:`text-[10px] border-0 ${oc(M)}`,children:[M," ",ee," · ",be]},M))})]})]})})]}),s.jsxs(Wl,{value:a,onValueChange:M=>{const ee=new URLSearchParams(t);M==="users"?ee.delete("tab"):ee.set("tab",M),e(ee)},className:"w-full",children:[s.jsxs(Ko,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[s.jsxs(Ut,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[s.jsx(qn,{className:"w-4 h-4"})," 用户列表"]}),s.jsxs(Ut,{value:"leads",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:()=>Nt(),children:[s.jsx(Qc,{className:"w-4 h-4"})," 获客列表"]}),s.jsxs(Ut,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:xl,children:[s.jsx(ma,{className:"w-4 h-4"})," 用户旅程总览"]}),s.jsxs(Ut,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:na,children:[s.jsx(Po,{className:"w-4 h-4"})," 规则配置"]}),s.jsxs(Ut,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:_n,children:[s.jsx(Xc,{className:"w-4 h-4"})," 超级个体列表"]})]}),s.jsxs(Wt,{value:"users",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[s.jsxs(G,{variant:"outline",onClick:Ke,disabled:ue,className:"border-purple-500/50 text-purple-400 hover:bg-purple-500/10 bg-transparent",title:"批量调用神射手补全有手机号用户的资料",children:[ue?s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}):s.jsx(Ho,{className:"w-4 h-4 mr-2"}),"批量补全"]}),s.jsxs(G,{variant:"outline",onClick:()=>nr(!0),disabled:U,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${U?"animate-spin":""}`})," 刷新"]}),s.jsxs("select",{value:T,onChange:M=>{const ee=M.target.value;C(ee),m(1),n&&(t.delete("pool"),e(t))},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",disabled:Q,children:[s.jsx("option",{value:"all",children:"全部用户"}),s.jsx("option",{value:"vip",children:"VIP会员(超级个体)"}),s.jsx("option",{value:"complete",children:"完善资料用户"})]}),s.jsxs("div",{className:"relative",children:[s.jsx(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:N,onChange:M=>w(M.target.value)})]}),s.jsxs(G,{onClick:wd,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Qc,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(_e,{className:"p-0",children:L?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"用户信息"}),s.jsx(Se,{className:"text-gray-400",children:"绑定信息"}),s.jsx(Se,{className:"text-gray-400",children:"购买状态"}),s.jsx(Se,{className:"text-gray-400",children:"分销收益"}),s.jsxs(Se,{className:"text-gray-400 cursor-pointer select-none",onClick:yr,children:[s.jsxs("div",{className:"flex items-center gap-1 group",children:[s.jsx(Of,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:"RFM分值"}),Q?le==="desc"?s.jsx(Bi,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(Bg,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(_x,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),Q&&s.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),s.jsx(Se,{className:"text-gray-400",children:"资料完善"}),s.jsx(Se,{className:"text-gray-400",children:"注册时间"}),s.jsx(Se,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(ms,{children:[o.map(M=>{var ee,be,Ae;return s.jsxs(xt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[(()=>{var Vt;const Ge=Ma(M.avatar,M.mbti),Je=((Vt=M.nickname)==null?void 0:Vt.charAt(0))||"?";return s.jsx("button",{type:"button",title:"点击管理 MBTI 默认头像库",onClick:()=>jn(!0),className:"w-10 h-10 shrink-0 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] overflow-hidden ring-1 ring-transparent hover:ring-[#38bdac]/60 transition",children:Ge?s.jsx("img",{src:Ge,className:"w-full h-full rounded-full object-cover",alt:"",onError:He=>{var _r;const en=He.target;if(en.style.display="none",en.nextElementSibling)return;const Is=document.createElement("span");Is.textContent=Je,(_r=en.parentElement)==null||_r.appendChild(Is)}}):Je})})(),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",onClick:()=>{Ue(M.id),we(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left truncate max-w-[120px]",children:M.nickname}),M.isAdmin&&s.jsx(Be,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),M.openId&&!((ee=M.id)!=null&&ee.startsWith("user_"))&&s.jsx(Be,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),s.jsxs("p",{className:"text-xs text-gray-500 font-mono truncate max-w-[140px]",title:M.id,children:[(be=M.id)==null?void 0:be.slice(0,16),(((Ae=M.id)==null?void 0:Ae.length)??0)>16?"…":""]})]})]})}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[M.phone&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"📱"}),s.jsx("span",{className:"text-gray-300",children:M.phone})]}),M.wechatId&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"💬"}),s.jsx("span",{className:"text-gray-300",children:M.wechatId})]}),!M.phone&&!M.wechatId&&s.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),s.jsx(je,{children:(()=>{const Ge=ta(M);return Ge.tone==="vip"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(Be,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:Ge.main}),Ge.sub&&s.jsx("p",{className:"text-[11px] text-amber-300/80",children:Ge.sub})]}):Ge.tone==="paid"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(Be,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:Ge.main}),Ge.sub&&s.jsx("p",{className:"text-[11px] text-blue-300/80",children:Ge.sub})]}):s.jsx(Be,{variant:"outline",className:"text-gray-500 border-gray-600",children:Ge.main})})()}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(M.earnings||0)).toFixed(2)]}),parseFloat(String(M.pendingEarnings||0))>0&&s.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(M.pendingEarnings||0)).toFixed(2)]}),s.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>Ns(M),role:"button",tabIndex:0,onKeyDown:Ge=>Ge.key==="Enter"&&Ns(M),children:[s.jsx(qn,{className:"w-3 h-3"})," 绑定",M.referralCount||0,"人"]})]})}),s.jsx(je,{children:M.rfmScore!=null&&M.rfmScore!==void 0?s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-white font-bold text-base",children:M.rfmScore}),s.jsx(Be,{className:`border-0 text-xs ${oc(M.rfmLevel)}`,children:M.rfmLevel})]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"无订单"})}),s.jsx(je,{children:(()=>{const Ge=gt(M),Je=Ge>=75?"text-green-400":Ge>=50?"text-yellow-400":"text-gray-500";return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-12 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full ${Ge>=75?"bg-green-500":Ge>=50?"bg-yellow-500":"bg-gray-500"}`,style:{width:`${Ge}%`}})}),s.jsxs("span",{className:`text-xs ${Je}`,children:[Ge,"%"]})]})})()}),s.jsx(je,{className:"text-gray-400",children:M.createdAt?new Date(M.createdAt).toLocaleDateString():"-"}),s.jsx(je,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>{Ue(M.id),we(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:s.jsx(Lf,{className:"w-4 h-4"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Aa(M),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:s.jsx(an,{className:"w-4 h-4"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>lc(M.id),title:"删除",children:s.jsx(ns,{className:"w-4 h-4"})})]})})]},M.id)}),o.length===0&&s.jsx(xt,{children:s.jsx(je,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),s.jsx(xs,{page:f,totalPages:gr,total:u,pageSize:x,onPageChange:m,onPageSizeChange:M=>{b(M),m(1)}})]})})})]}),s.jsxs(Wt,{value:"leads",children:[Rr&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[s.jsx("span",{children:Rr}),s.jsx("button",{type:"button",className:"shrink-0 ml-2",onClick:()=>Yr(null),"aria-label":"关闭",children:"×"})]}),!sn&&s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-4",children:[s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs",children:"线索总条数(含留资/加入/匹配)"}),s.jsx("p",{className:"text-xl font-bold text-white",children:ka})]}),s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs",children:"去重用户数(按 userId)"}),s.jsx("p",{className:"text-xl font-bold text-[#38bdac]",title:"后端 COUNT(DISTINCT user_id)",children:Xs.uniqueUsers??0})]}),(Xs.sourceStats&&Xs.sourceStats.length>0?Xs.sourceStats.slice(0,2):[]).map(M=>s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsxs("p",{className:"text-gray-500 text-xs",children:["来源:",M.source]}),s.jsx("p",{className:"text-xl font-bold text-purple-400",children:M.cnt})]},M.source))]}),!sn&&Sd.length>0&&s.jsx(De,{className:"bg-[#3a1010]/35 border-red-900/60 shadow-lg mb-4",children:s.jsxs(_e,{className:"p-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-red-200 font-medium",children:"失败原因聚合"}),s.jsx("p",{className:"text-red-300/70 text-xs",children:"基于当前页筛选结果,按失败原因聚合统计"})]}),s.jsx(G,{type:"button",variant:"outline",onClick:Cd,className:"border-red-600/70 text-red-200 hover:bg-red-500/10 bg-transparent",children:"一键复制排障信息"})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Sd.slice(0,8).map(M=>s.jsxs(Be,{className:"bg-red-500/15 text-red-200 border border-red-600/40",children:[M.reason," · ",M.count]},M.reason))})]})}),s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 flex-1 min-w-[200px]",children:[s.jsxs("div",{className:"relative flex-1 max-w-xs",children:[s.jsx(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{placeholder:"搜索昵称/手机/微信/@人/来源/类型…",value:jt,onChange:M=>Un(M.target.value),className:"pl-9 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"})]}),Xs.sourceStats&&Xs.sourceStats.length>0&&s.jsxs("select",{value:Sa,onChange:M=>{mn(M.target.value),Rt(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部来源"}),Xs.sourceStats.map(M=>s.jsxs("option",{value:M.source,children:[M.source,"(",M.cnt,")"]},M.source))]}),s.jsxs("select",{value:Zr,onChange:M=>{const ee=M.target.value;ni(ee),Rt(1),e(be=>{const Ae=new URLSearchParams(be);return Ae.set("tab","leads"),ee?Ae.set("leadAction",ee):Ae.delete("leadAction"),Ae})},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",title:"按业务类型筛选",children:[s.jsx("option",{value:"",children:"全部类型"}),s.jsx("option",{value:"lead",children:"留资线索(文章@ / 首页链接)"}),s.jsx("option",{value:"join",children:"加入报名(导师 / 资源对接 / 团队)"}),s.jsx("option",{value:"match",children:"匹配上报(找伙伴匹配)"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-xs text-gray-400 select-none bg-[#0f2137] border border-gray-700 rounded-lg px-3 py-2",children:[s.jsx("input",{type:"checkbox",checked:Ca,onChange:M=>qi(M.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer"}),"去重展示"]}),s.jsxs("select",{value:mr,onChange:M=>{As(M.target.value),Rt(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待推送"}),s.jsx("option",{value:"success",children:"已推送(存客宝已接收)"}),s.jsx("option",{value:"pending_verify",children:"待通过 / 处理中"}),s.jsx("option",{value:"expired",children:"已过期"}),s.jsx("option",{value:"failed",children:"推送失败"})]}),s.jsx(G,{type:"button",variant:"outline",onClick:()=>{As("failed"),Rt(1)},className:"border-red-600/60 text-red-300 hover:bg-red-500/10 bg-transparent text-xs h-9",children:"只看失败"}),s.jsxs("span",{className:"text-xs text-gray-500 whitespace-nowrap max-w-[min(100%,20rem)]",title:"同一页内:相同手机号或相同用户 ID(含微信侧标识)只保留最近一条",children:["本页 ",$n," 条",Yn>0?` · 已合并 ${Yn} 条重复`:""]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(G,{variant:"outline",onClick:ic,disabled:sn,className:"border-cyan-600/60 text-cyan-300 hover:bg-cyan-500/10 bg-transparent",children:"导出失败清单"}),s.jsxs(G,{variant:"outline",onClick:ii,disabled:ea||tr||sn,className:"border-amber-600/60 text-amber-300 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${ea?"animate-spin":""}`}),"重推本页失败项"]}),s.jsxs(G,{variant:"outline",onClick:()=>void Wn(),disabled:tr||vs.length===0||sn,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(ns,{className:`w-4 h-4 mr-2 ${tr?"animate-pulse":""}`}),tr?"删除中…":`批量删除(${vs.length})`]}),s.jsxs(G,{variant:"outline",onClick:()=>Nt(),disabled:sn,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${sn?"animate-spin":""}`})," 刷新"]})]})]}),!sn&&at.length>0&&s.jsxs("p",{className:"text-xs text-gray-500 mb-2",children:["已选 ",s.jsx("span",{className:"text-[#38bdac]",children:vs.length})," 条 · 可翻页继续勾选 · 改搜索/筛选会清空选择",vs.length>0&&s.jsx("button",{type:"button",className:"ml-2 text-gray-400 hover:text-gray-200 underline",onClick:()=>er([]),children:"清空"})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(_e,{className:"p-0",children:sn?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400 w-10 text-center",children:s.jsx("input",{ref:si,type:"checkbox",checked:at.length>0&&at.every(M=>vs.includes(M.id)),onChange:Sn,className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer",title:"全选本页(展示行)"})}),s.jsx(Se,{className:"text-gray-400",children:"昵称"}),s.jsx(Se,{className:"text-gray-400",children:"手机号"}),s.jsx(Se,{className:"text-gray-400",children:"微信号"}),s.jsx(Se,{className:"text-gray-400",children:"对应 @人"}),s.jsx(Se,{className:"text-gray-400",children:"获客计划(Key)"}),s.jsx(Se,{className:"text-gray-400",children:"推送状态"}),s.jsx(Se,{className:"text-gray-400",children:"时间"}),s.jsx(Se,{className:"text-gray-400",children:"重试"})]})}),s.jsxs(ms,{children:[at.map(M=>s.jsxs(xt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{className:"text-center align-middle w-10",children:s.jsx("input",{type:"checkbox",checked:vs.includes(M.id),onChange:()=>sr(M.id),disabled:tr,className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer"})}),s.jsx(je,{className:"text-gray-300 align-middle",children:s.jsx(N8,{userId:M.userId,userAvatar:M.userAvatar,nickname:M.userNickname,name:M.name,onOpenDetail:ee=>{Ue(ee),we(!0)}})}),s.jsx(je,{className:"text-gray-300",children:M.phone||"-"}),s.jsx(je,{className:"text-gray-300",children:M.wechatId||"-"}),s.jsx(je,{className:"text-[#38bdac]",children:M.personName||"-"}),s.jsx(je,{className:"text-gray-400 text-xs",children:(()=>{const ee=(M.planApiKey||"").trim();if(!ee)return"-";const be=ee.length<=10?ee:`${ee.slice(0,6)}…${ee.slice(-4)}`;return s.jsx("button",{type:"button",className:"font-mono text-gray-400 hover:text-gray-200 underline decoration-dotted",title:ee,onClick:async()=>{try{await navigator.clipboard.writeText(ee),q.success("已复制计划Key")}catch{q.error("复制失败,请手动复制")}},children:be})})()}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[mc(M.pushStatus),(typeof M.ckbCode=="number"||(M.ckbMessage||"").trim())&&s.jsx("p",{className:"text-[11px] text-gray-500 max-w-[260px] truncate",title:[typeof M.ckbCode=="number"?`code=${M.ckbCode}`:"",(M.ckbMessage||"").trim()?`message=${String(M.ckbMessage).trim()}`:"",(M.ckbData||"").trim()?`data=${String(M.ckbData).trim()}`:""].filter(Boolean).join(" | "),children:[typeof M.ckbCode=="number"?`code=${M.ckbCode}`:"",(M.ckbMessage||"").trim()?String(M.ckbMessage).trim():""].filter(Boolean).join(" · ")}),!!(M.ckbData||"").trim()&&s.jsx("button",{type:"button",className:"text-[11px] text-sky-300/90 hover:text-sky-200 underline decoration-dotted",onClick:()=>{const ee=String(M.ckbData||"").trim();Ea(`存客宝返回 data(#${M.id})`),Ta(w8(ee)),ri(!0)},children:"查看 data"}),!!M.ckbError&&s.jsx("p",{className:"text-[11px] text-red-300 max-w-[220px] truncate",title:M.ckbError,children:M.ckbError})]})}),s.jsx(je,{className:"text-gray-400 whitespace-nowrap",children:M.createdAt?new Date(M.createdAt).toLocaleString():"-"}),s.jsx(je,{className:"text-gray-400 text-xs align-top py-3 min-w-[148px]",children:s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("p",{className:"text-gray-400 leading-snug",children:typeof M.retryCount=="number"?`第 ${M.retryCount} 次`:"-"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(G,{size:"sm",variant:"outline",disabled:tr||Gi===M.id||il===M.id,onClick:()=>cl(M.id),className:"h-8 px-2.5 text-[11px] border-gray-600 text-gray-200 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-3 h-3 mr-1 ${Gi===M.id?"animate-spin":""}`}),"重推"]}),s.jsxs(G,{size:"sm",variant:"outline",disabled:tr||il===M.id||Gi===M.id,onClick:()=>ai(M.id),className:"h-8 px-2.5 text-[11px] border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent shrink-0",children:[s.jsx(ns,{className:`w-3 h-3 mr-1 ${il===M.id?"animate-pulse":""}`}),"删除"]})]})]})})]},M.id)),at.length===0&&s.jsx(xt,{children:s.jsx(je,{colSpan:9,className:"p-0 align-top",children:s.jsxs("div",{className:"py-16 px-6 text-center border-t border-gray-700/40 bg-[#0a1628]/30",children:[s.jsx(Qc,{className:"w-14 h-14 text-[#38bdac]/20 mx-auto mb-4","aria-hidden":!0}),s.jsx("p",{className:"text-gray-200 font-medium mb-1",children:"暂无获客线索"}),s.jsx("p",{className:"text-gray-500 text-sm mb-6 max-w-md mx-auto leading-relaxed",children:Xr.trim()||Sa?"当前搜索或来源筛选下没有匹配记录,可清空条件后重试。":"存客宝场景产生的手机号 / 微信留资会出现在此列表。请确认获客计划已开启,并有用户完成留资。"}),s.jsxs(G,{type:"button",variant:"outline",onClick:()=>Nt(),disabled:sn,className:"border-[#38bdac]/40 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${sn?"animate-spin":""}`}),"重新加载"]})]})})})]})]}),s.jsx(xs,{page:ve,totalPages:Math.ceil(ka/Zt)||1,total:ka,pageSize:Zt,onPageChange:Rt,onPageSizeChange:()=>{}})]})})})]}),s.jsxs(Wt,{value:"journey",children:[s.jsxs("div",{className:"flex items-center justify-between mb-5",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"用户从注册到 VIP 的完整行动路径,点击各阶段查看用户动态"}),s.jsxs(G,{variant:"outline",onClick:xl,disabled:Ft,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${Ft?"animate-spin":""}`})," 刷新数据"]})]}),s.jsxs("div",{className:"relative mb-8",children:[s.jsx("div",{className:"absolute top-16 left-0 right-0 h-0.5 bg-gradient-to-r from-blue-500/20 via-[#38bdac]/30 to-amber-500/20 mx-20"}),s.jsx("div",{className:"grid grid-cols-4 gap-4 lg:grid-cols-8",children:Fc.map((M,ee)=>s.jsxs("div",{className:"relative flex flex-col items-center",children:[s.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${M.color} text-center cursor-pointer hover:opacity-80 transition-opacity ${ht===M.id?"ring-2 ring-[#38bdac]":""}`,onClick:()=>E(M.id),title:`点击查看「${M.label}」阶段的用户`,children:[s.jsx("div",{className:"text-2xl mb-1",children:M.icon}),s.jsx("div",{className:`text-xs font-medium ${M.color.split(" ").find(be=>be.startsWith("text-"))}`,children:M.label}),Qe[M.id]!==void 0&&s.jsxs("div",{className:"mt-1.5 text-xs text-gray-400",children:[s.jsx("span",{className:"font-bold text-white",children:Qe[M.id]})," 人"]}),s.jsx("div",{className:"absolute -top-2.5 -left-2.5 w-5 h-5 rounded-full bg-[#0a1628] border border-gray-700 flex items-center justify-center text-[10px] text-gray-500",children:ee+1})]}),ees.jsxs("div",{className:"flex items-start gap-3 p-2 bg-[#0a1628] rounded",children:[s.jsx("span",{className:"text-[#38bdac] font-mono text-xs shrink-0 mt-0.5",children:M.step}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-300",children:M.action}),s.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",M.next]})]})]},M.step))})]}),s.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(ur,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"行为锚点统计"}),s.jsx("span",{className:"text-gray-500 text-xs ml-auto",children:"实时更新"})]}),Ft?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(Qe).length>0?s.jsx("div",{className:"space-y-2",children:(()=>{const M=Fc.reduce((ee,be)=>ee+(Qe[be.id]||0),0);return Fc.map(ee=>{const be=Qe[ee.id]||0,Ae=M>0?Math.round(be/M*100):0,Ge=be>0?Math.max(Ae,6):0;return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-gray-500 text-xs w-[5.5rem] shrink-0 leading-tight",children:[ee.icon," ",ee.label]}),s.jsx("div",{className:"flex-1 h-2.5 bg-[#0a1628] rounded-full overflow-hidden border border-gray-700/40",children:s.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-[#38bdac]/50 to-[#38bdac] transition-all",style:{width:`${Ge}%`}})}),s.jsx("span",{className:"text-gray-400 text-xs w-14 text-right tabular-nums",children:be}),s.jsx("span",{className:"text-gray-600 text-[10px] w-8 text-right tabular-nums",children:M>0?`${Ae}%`:"—"})]},ee.id)})})()}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]}),ht&&s.jsxs("div",{className:"mt-6 bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qn,{className:"w-4 h-4 text-[#38bdac]"}),s.jsxs("span",{className:"text-white font-medium",children:[(eo=Fc.find(M=>M.id===ht))==null?void 0:eo.icon," ",(eh=Fc.find(M=>M.id===ht))==null?void 0:eh.label," 阶段用户"]}),s.jsxs(Be,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:[Gt.length," 人"]})]}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Pt(null),className:"text-gray-400 hover:text-white",children:s.jsx(ss,{className:"w-4 h-4"})})]}),Ts?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Gt.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"该阶段暂无用户"}):s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"昵称"}),s.jsx(Se,{className:"text-gray-400",children:"手机号"}),s.jsx(Se,{className:"text-gray-400",children:"注册时间"}),s.jsx(Se,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsx(ms,{children:Gt.map(M=>s.jsxs(xt,{className:"border-gray-700/50 hover:bg-[#0a1628]",children:[s.jsx(je,{className:"text-white",children:M.nickname||"微信用户"}),s.jsx(je,{className:"text-gray-300",children:M.phone||"-"}),s.jsx(je,{className:"text-gray-400 text-xs",children:M.createdAt?new Date(M.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx(je,{className:"text-right",children:s.jsxs(G,{variant:"ghost",size:"sm",className:"text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>z(M.id,M.nickname||"微信用户"),children:[s.jsx(Lf,{className:"w-4 h-4 mr-1"})," 行为轨迹"]})})]},M.id))})]})]}),s.jsx(Lt,{open:!!Ki,onOpenChange:M=>{M||ja(null)},children:s.jsxs(It,{className:"sm:max-w-[600px] bg-[#0f2137] border-gray-700 text-white max-h-[80vh] overflow-y-auto",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(ma,{className:"w-5 h-5 text-[#38bdac]"}),ei," 的行为轨迹"]})}),Ir?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Ar.length===0?s.jsx("p",{className:"text-gray-500 text-center py-8",children:"该用户暂无行为记录"}):s.jsxs("div",{className:"relative pl-6 space-y-0",children:[s.jsx("div",{className:"absolute left-[11px] top-2 bottom-2 w-0.5 bg-gray-700"}),Ar.map((M,ee)=>s.jsxs("div",{className:"relative flex items-start gap-3 py-2",children:[s.jsx("div",{className:"absolute left-[-13px] top-3 w-2.5 h-2.5 rounded-full bg-[#38bdac] border-2 border-[#0f2137] z-10"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-white text-sm font-medium",children:M.actionLabel}),M.module&&s.jsx(Be,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[10px]",children:M.module})]}),(M.chapterTitle||M.target)&&s.jsx("p",{className:"text-gray-400 text-xs mt-0.5 truncate",children:M.chapterTitle||M.target}),s.jsxs("p",{className:"text-gray-600 text-[10px] mt-0.5",children:[M.timeAgo," · ",M.createdAt?new Date(M.createdAt).toLocaleString("zh-CN"):""]})]})]},M.id||ee))]})]})})]}),s.jsxs(Wt,{value:"rules",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"用户旅程触达规则:各行为节点的触发条件与展示文案(偏利他说明,少用命令式)"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(G,{variant:"outline",onClick:na,disabled:pn,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${pn?"animate-spin":""}`})," 刷新"]}),s.jsxs(G,{onClick:()=>{as(null),vn({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),Mn(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Rn,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),pn?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):fn.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(ur,{className:"w-12 h-12 text-[#38bdac]/30 mx-auto mb-4"}),s.jsx("p",{className:"text-gray-400 mb-4",children:"暂无规则(重启服务将自动写入10条默认规则)"}),s.jsxs(G,{onClick:na,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Ve,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):s.jsx("div",{className:"space-y-2",children:fn.map(M=>{var be;const ee=A2(M.triggerConditions);return s.jsxs("div",{className:`p-3 rounded-lg border transition-all ${M.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[s.jsxs("span",{className:"text-gray-600 text-xs font-mono w-5 shrink-0 text-right",children:["#",M.sort]}),s.jsx(an,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),s.jsx("span",{className:"text-white font-medium text-sm truncate",children:M.title}),M.trigger&&s.jsx(Be,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-[10px] shrink-0",children:M.trigger}),ee.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-0.5 ml-1",children:[ee.slice(0,3).map(Ae=>{const Ge=cN.find(Je=>Je.value===Ae);return s.jsx(Be,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[9px]",children:(Ge==null?void 0:Ge.label)||Ae},Ae)}),ee.length>3&&s.jsxs("span",{className:"text-gray-500 text-[9px]",children:["+",ee.length-3]})]}),M.actionType&&M.actionType!=="popup"&&s.jsx(Be,{className:"bg-amber-500/10 text-amber-400 border border-amber-500/30 text-[9px] shrink-0",children:((be=dN.find(Ae=>Ae.value===M.actionType))==null?void 0:be.label)||M.actionType})]}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-3 shrink-0",children:[s.jsx(Kt,{checked:M.enabled,onCheckedChange:()=>Ia(M)}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>{as(M),vn({title:M.title,description:M.description,trigger:M.trigger,triggerConditions:ee,actionType:M.actionType||"popup",sort:M.sort,enabled:M.enabled}),Mn(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10 h-7 w-7 p-0",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Pa(M.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 h-7 w-7 p-0",children:s.jsx(ns,{className:"w-3.5 h-3.5"})})]})]}),M.description&&s.jsxs("details",{className:"ml-[52px] mt-1",children:[s.jsxs("summary",{className:"text-gray-500 text-xs cursor-pointer hover:text-gray-400 select-none",children:["查看完整描述",s.jsxs("span",{className:"text-gray-600 ml-1",children:["(",M.description.length," 字,默认折叠)"]})]}),s.jsx("p",{className:"text-gray-400 text-sm mt-1 pl-1 border-l-2 border-gray-700 whitespace-pre-wrap",children:M.description})]})]},M.id)})})]}),s.jsxs(Wt,{value:"vip-roles",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"展示当前所有有效的超级个体(VIP 用户),用于检查会员信息与排序值。"}),s.jsx("p",{className:"text-xs text-[#38bdac]",children:"提示:按住任意一行即可拖拽排序,释放后将同步更新小程序展示顺序。"})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs(G,{variant:"outline",onClick:_n,disabled:We,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${We?"animate-spin":""}`})," ","刷新"]})})]}),We?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):Ne.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(Xc,{className:"w-12 h-12 text-amber-400/30 mx-auto mb-4"}),s.jsx("p",{className:"text-gray-400 mb-4",children:"当前没有有效的超级个体用户。"})]}):s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(_e,{className:"p-0",children:s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400 w-12",children:"序号"}),s.jsx(Se,{className:"text-gray-400",children:"成员"}),s.jsx(Se,{className:"text-gray-400 min-w-40",children:"超级个体标签"}),s.jsx(Se,{className:"text-gray-400 w-16 text-center",children:"头像点击"}),s.jsx(Se,{className:"text-gray-400 w-16 text-center",children:"获客数"}),s.jsx(Se,{className:"text-gray-400 w-20",children:"排序值"}),s.jsx(Se,{className:"text-gray-400 w-36",children:"飞书群"}),s.jsx(Se,{className:"text-gray-400 w-36 text-right",children:"操作"})]})}),s.jsx(ms,{children:Ne.map((M,ee)=>{var Ge;const be=$t===M.id,Ae=$e===M.id;return s.jsxs(xt,{draggable:!0,onDragStart:Je=>pl(Je,M.id),onDragOver:Je=>fc(Je,M.id),onDrop:Je=>pc(Je,M.id),onDragEnd:ml,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${be?"opacity-60":""} ${Ae?"bg-[#38bdac]/10":""}`,children:[s.jsx(je,{className:"text-gray-300",children:ee+1}),s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[Ma(M.avatar,M.mbti)?s.jsx("img",{src:Ma(M.avatar,M.mbti),className:"w-8 h-8 rounded-full object-cover border border-amber-400/60",alt:"",onError:Je=>{var He,en;Je.target.style.display="none";const Vt=document.createElement("div");Vt.className="w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",Vt.textContent=((He=M.name)==null?void 0:He[0])||"创",(en=Je.target.parentElement)==null||en.appendChild(Vt)}}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",children:((Ge=M.name)==null?void 0:Ge[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:M.name})})]})}),s.jsx(je,{className:"text-gray-300 whitespace-nowrap",children:M.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置)"})}),s.jsx(je,{className:"text-center text-blue-400 text-xs font-mono",children:M.clickCount!=null?String(M.clickCount):"-"}),s.jsx(je,{className:"text-center text-green-400 text-xs font-mono",children:M.leadCount!=null?String(M.leadCount):"-"}),s.jsx(je,{className:"text-gray-300",children:M.vipSort??ee+1}),s.jsx(je,{className:"text-xs",children:M.webhookUrl?s.jsx("span",{className:"text-[#38bdac] truncate block max-w-[180px]",title:M.webhookUrl,children:"已配置"}):s.jsx("span",{className:"text-gray-500",children:"未配置"})}),s.jsx(je,{className:"text-right text-xs text-gray-300",children:s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>ui(M),title:"设置超级个体标签",children:s.jsx(xu,{className:"w-3.5 h-3.5"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-[#38bdac] hover:text-[#5fe0cd]",onClick:()=>jd(M),title:"编辑飞书群Webhook",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>kd(M),title:"设置排序序号",children:s.jsx(_x,{className:"w-3.5 h-3.5"})})]})})]},M.id)})})]})})})]})]}),s.jsx(Lt,{open:wt,onOpenChange:jn,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-6xl",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:"MBTI 默认头像库"})}),s.jsx(y8,{})]})}),s.jsx(Lt,{open:hi,onOpenChange:M=>{oa(M),M||fl(null)},children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(_x,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",La==null?void 0:La.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:cc,onChange:M=>dc(M.target.value)})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>oa(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ss,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:hc,disabled:Zi,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),Zi?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:Lr,onOpenChange:M=>{ra(M),M||br(null)},children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Xc,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",oi==null?void 0:oi.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:di.map(M=>s.jsx(G,{variant:Ps===M?"default":"outline",size:"sm",className:Ps===M?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>Ra(M),children:M},M))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"或手动输入"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:Ps,onChange:M=>Ra(M.target.value)})]})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>ra(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ss,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:()=>ul(Ps),disabled:vr,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),vr?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:Xi,onOpenChange:M=>{Or(M),M||ia(null)},children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-xl",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}),"设置飞书群 Webhook — ",aa==null?void 0:aa.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"VOX Webhook 地址(留空即清空)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",value:li,onChange:M=>ci(M.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"当用户点击该超级个体头像并提交链接时,线索将优先推送到这里配置的飞书群。"})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>Or(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ss,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:hl,disabled:ls,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),ls?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:I,onOpenChange:Y,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[B?s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Qc,{className:"w-5 h-5 text-[#38bdac]"}),B?"编辑用户":"添加用户"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"手机号"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:pt.phone,onChange:M=>At({...pt,phone:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"昵称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:pt.nickname,onChange:M=>At({...pt,nickname:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:B?"新密码 (留空则不修改)":"密码"}),s.jsx(oe,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:B?"留空则不修改":"请输入密码",value:pt.password,onChange:M=>At({...pt,password:M.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(te,{className:"text-gray-300",children:"管理员权限"}),s.jsx(Kt,{checked:pt.isAdmin,onCheckedChange:M=>At({...pt,isAdmin:M})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(te,{className:"text-gray-300",children:"已购全书"}),s.jsx(Kt,{checked:pt.hasFullBook,onCheckedChange:M=>At({...pt,hasFullBook:M})})]})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>Y(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ss,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:dl,disabled:X,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),X?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:bn,onOpenChange:Mn,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[90vh] overflow-y-auto",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}),Hn?"编辑规则":"添加规则"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"规则标题 *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:_t.title,onChange:M=>vn({..._t,title:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"规则描述"}),s.jsx(el,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[60px] resize-none",placeholder:"弹窗内容/推送文案...",value:_t.description,onChange:M=>vn({..._t,description:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"触发条件(可多选)"}),s.jsx("div",{className:"space-y-2",children:["用户状态","阅读行为","付费行为","社交行为","分销行为"].map(M=>{const ee=cN.filter(be=>be.group===M);return ee.length===0?null:s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-gray-500 mb-1",children:M}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:ee.map(be=>{const Ae=(_t.triggerConditions||[]).includes(be.value);return s.jsx("button",{type:"button",className:`px-2.5 py-1 rounded-md text-xs border transition-colors ${Ae?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-[#0a1628] border-gray-700 text-gray-400 hover:border-gray-500"}`,onClick:()=>{const Ge=_t.triggerConditions||[],Je=Ae?Ge.filter(Vt=>Vt!==be.value):[...Ge,be.value];vn({..._t,triggerConditions:Je})},children:be.label},be.value)})})]},M)})}),(_t.triggerConditions||[]).length>0&&s.jsxs("p",{className:"text-[10px] text-[#38bdac]",children:["已选 ",(_t.triggerConditions||[]).length," 个触发条件(满足任一即触发)"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"兼容触发标识(旧版)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white text-xs h-8",placeholder:"与小程序一致:注册、完成付款、update_avatar、update_nickname 等",value:_t.trigger,onChange:M=>vn({..._t,trigger:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"推送动作"}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:dN.map(M=>s.jsxs("button",{type:"button",className:`p-2 rounded-lg border text-left transition-colors ${_t.actionType===M.value?"bg-[#38bdac]/15 border-[#38bdac]/50":"bg-[#0a1628] border-gray-700 hover:border-gray-500"}`,onClick:()=>vn({..._t,actionType:M.value}),children:[s.jsx("span",{className:`text-xs font-medium ${_t.actionType===M.value?"text-[#38bdac]":"text-gray-300"}`,children:M.label}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5",children:M.desc})]},M.value))})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{children:s.jsx(te,{className:"text-gray-300",children:"启用状态"})}),s.jsx(Kt,{checked:_t.enabled,onCheckedChange:M=>vn({..._t,enabled:M})})]})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>Mn(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ss,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:sa,disabled:X,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),X?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:W,onOpenChange:fe,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(qn,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",$==null?void 0:$.nickname]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsx("div",{className:"text-2xl font-bold text-[#38bdac]",children:((Ed=he.stats)==null?void 0:Ed.total)||0}),s.jsx("div",{className:"text-xs text-gray-400",children:"绑定总数"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsx("div",{className:"text-2xl font-bold text-green-400",children:((Td=he.stats)==null?void 0:Td.purchased)||0}),s.jsx("div",{className:"text-xs text-gray-400",children:"已付费"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsxs("div",{className:"text-2xl font-bold text-yellow-400",children:["¥",(((Md=he.stats)==null?void 0:Md.earnings)||0).toFixed(2)]}),s.jsx("div",{className:"text-xs text-gray-400",children:"累计收益"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsxs("div",{className:"text-2xl font-bold text-orange-400",children:["¥",(((Ad=he.stats)==null?void 0:Ad.pendingEarnings)||0).toFixed(2)]}),s.jsx("div",{className:"text-xs text-gray-400",children:"待提现"})]})]}),_?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((Pd=he.referrals)==null?void 0:Pd.length)??0)>0?s.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(he.referrals??[]).map((M,ee)=>{var Ae;const be=M;return s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:((Ae=be.nickname)==null?void 0:Ae.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white text-sm",children:be.nickname}),s.jsx("div",{className:"text-xs text-gray-500",children:be.phone||(be.hasOpenId?"微信用户":"未绑定")})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[be.status==="vip"&&s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),be.status==="paid"&&s.jsxs(Be,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",be.purchasedSections,"章"]}),be.status==="free"&&s.jsx(Be,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),s.jsx("span",{className:"text-xs text-gray-500",children:be.createdAt?new Date(be.createdAt).toLocaleDateString():""})]})]},be.id||ee)})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),s.jsx(nn,{children:s.jsx(G,{variant:"outline",onClick:()=>fe(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),s.jsx(py,{open:ae,onClose:()=>we(!1),userId:Fe,onUserUpdated:nr}),s.jsx(Lt,{open:ol,onOpenChange:ri,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700/60 text-white max-w-2xl",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:Qi})}),s.jsx("div",{className:"mt-2",children:s.jsx("pre",{className:"text-xs text-gray-200 bg-[#0a1628] border border-gray-700/60 rounded-lg p-3 max-h-[520px] overflow-auto whitespace-pre-wrap break-words",children:ll||"—"})}),s.jsxs(nn,{children:[s.jsx(G,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 hover:bg-gray-700/50 bg-transparent",onClick:async()=>{try{await navigator.clipboard.writeText(ll||""),q.success("已复制 data")}catch{q.error("复制失败,请手动复制")}},disabled:!ll,children:"复制 data"}),s.jsx(G,{type:"button",className:"bg-[#38bdac] hover:bg-[#2aa896] text-white",onClick:()=>ri(!1),children:"关闭"})]})]})})]})}function Ff(t,[e,n]){return Math.min(n,Math.max(e,t))}var P2=["PageUp","PageDown"],I2=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],R2={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},gd="Slider",[Xg,k8,S8]=dy(gd),[L2]=Zo(gd,[S8]),[C8,Up]=L2(gd),O2=g.forwardRef((t,e)=>{const{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:u=0,defaultValue:h=[r],value:f,onValueChange:m=()=>{},onValueCommit:x=()=>{},inverted:b=!1,form:N,...w}=t,v=g.useRef(new Set),k=g.useRef(0),C=o==="horizontal"?E8:T8,[L=[],R]=Hl({prop:f,defaultProp:h,onChange:re=>{var ne;(ne=[...v.current][k.current])==null||ne.focus(),m(re)}}),U=g.useRef(L);function P(re){const D=R8(L,re);Q(re,D)}function F(re){Q(re,k.current)}function O(){const re=U.current[k.current];L[k.current]!==re&&x(L)}function Q(re,D,{commit:ne}={commit:!1}){const le=_8(i),me=$8(Math.round((re-r)/i)*i+r,le),I=Ff(me,[r,a]);R((Y=[])=>{const B=P8(Y,I,D);if(D8(B,u*i)){k.current=B.indexOf(I);const xe=String(B)!==String(Y);return xe&&ne&&x(B),xe?B:Y}else return Y})}return s.jsx(C8,{scope:t.__scopeSlider,name:n,disabled:c,min:r,max:a,valueIndexToChangeRef:k,thumbs:v.current,values:L,orientation:o,form:N,children:s.jsx(Xg.Provider,{scope:t.__scopeSlider,children:s.jsx(Xg.Slot,{scope:t.__scopeSlider,children:s.jsx(C,{"aria-disabled":c,"data-disabled":c?"":void 0,...w,ref:e,onPointerDown:kt(w.onPointerDown,()=>{c||(U.current=L)}),min:r,max:a,inverted:b,onSlideStart:c?void 0:P,onSlideMove:c?void 0:F,onSlideEnd:c?void 0:O,onHomeKeyDown:()=>!c&&Q(r,0,{commit:!0}),onEndKeyDown:()=>!c&&Q(a,L.length-1,{commit:!0}),onStepKeyDown:({event:re,direction:D})=>{if(!c){const me=P2.includes(re.key)||re.shiftKey&&I2.includes(re.key)?10:1,I=k.current,Y=L[I],B=i*me*D;Q(Y+B,I,{commit:!0})}}})})})})});O2.displayName=gd;var[D2,_2]=L2(gd,{startEdge:"left",endEdge:"right",size:"width",direction:1}),E8=g.forwardRef((t,e)=>{const{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,x]=g.useState(null),b=Xt(e,C=>x(C)),N=g.useRef(void 0),w=Bp(a),v=w==="ltr",k=v&&!i||!v&&i;function T(C){const L=N.current||m.getBoundingClientRect(),R=[0,L.width],P=my(R,k?[n,r]:[r,n]);return N.current=L,P(C-L.left)}return s.jsx(D2,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:s.jsx($2,{dir:w,"data-orientation":"horizontal",...f,ref:b,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:C=>{const L=T(C.clientX);o==null||o(L)},onSlideMove:C=>{const L=T(C.clientX);c==null||c(L)},onSlideEnd:()=>{N.current=void 0,u==null||u()},onStepKeyDown:C=>{const R=R2[k?"from-left":"from-right"].includes(C.key);h==null||h({event:C,direction:R?-1:1})}})})}),T8=g.forwardRef((t,e)=>{const{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=g.useRef(null),m=Xt(e,f),x=g.useRef(void 0),b=!a;function N(w){const v=x.current||f.current.getBoundingClientRect(),k=[0,v.height],C=my(k,b?[r,n]:[n,r]);return x.current=v,C(w-v.top)}return s.jsx(D2,{scope:t.__scopeSlider,startEdge:b?"bottom":"top",endEdge:b?"top":"bottom",size:"height",direction:b?1:-1,children:s.jsx($2,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const v=N(w.clientY);i==null||i(v)},onSlideMove:w=>{const v=N(w.clientY);o==null||o(v)},onSlideEnd:()=>{x.current=void 0,c==null||c()},onStepKeyDown:w=>{const k=R2[b?"from-bottom":"from-top"].includes(w.key);u==null||u({event:w,direction:k?-1:1})}})})}),$2=g.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=Up(gd,n);return s.jsx(Tt.span,{...h,ref:e,onKeyDown:kt(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):P2.concat(I2).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:kt(t.onPointerDown,m=>{const x=m.target;x.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(x)?x.focus():r(m)}),onPointerMove:kt(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&a(m)}),onPointerUp:kt(t.onPointerUp,m=>{const x=m.target;x.hasPointerCapture(m.pointerId)&&(x.releasePointerCapture(m.pointerId),i(m))})})}),z2="SliderTrack",F2=g.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=Up(z2,n);return s.jsx(Tt.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:e})});F2.displayName=z2;var Zg="SliderRange",B2=g.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=Up(Zg,n),i=_2(Zg,n),o=g.useRef(null),c=Xt(e,o),u=a.values.length,h=a.values.map(x=>U2(x,a.min,a.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return s.jsx(Tt.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:c,style:{...t.style,[i.startEdge]:f+"%",[i.endEdge]:m+"%"}})});B2.displayName=Zg;var e0="SliderThumb",V2=g.forwardRef((t,e)=>{const n=k8(t.__scopeSlider),[r,a]=g.useState(null),i=Xt(e,c=>a(c)),o=g.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(M8,{...t,ref:i,index:o})}),M8=g.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:a,...i}=t,o=Up(e0,n),c=_2(e0,n),[u,h]=g.useState(null),f=Xt(e,T=>h(T)),m=u?o.form||!!u.closest("form"):!0,x=fy(u),b=o.values[r],N=b===void 0?0:U2(b,o.min,o.max),w=I8(r,o.values.length),v=x==null?void 0:x[c.size],k=v?L8(v,N,c.direction):0;return g.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),s.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${N}% + ${k}px)`},children:[s.jsx(Xg.ItemSlot,{scope:t.__scopeSlider,children:s.jsx(Tt.span,{role:"slider","aria-label":t["aria-label"]||w,"aria-valuemin":o.min,"aria-valuenow":b,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:f,style:b===void 0?{display:"none"}:t.style,onFocus:kt(t.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),m&&s.jsx(H2,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:b},r)]})});V2.displayName=e0;var A8="RadioBubbleInput",H2=g.forwardRef(({__scopeSlider:t,value:e,...n},r)=>{const a=g.useRef(null),i=Xt(a,r),o=hy(e);return g.useEffect(()=>{const c=a.current;if(!c)return;const u=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==e&&f){const m=new Event("input",{bubbles:!0});f.call(c,e),c.dispatchEvent(m)}},[o,e]),s.jsx(Tt.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});H2.displayName=A8;function P8(t=[],e,n){const r=[...t];return r[n]=e,r.sort((a,i)=>a-i)}function U2(t,e,n){const i=100/(n-e)*(t-e);return Ff(i,[0,100])}function I8(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function R8(t,e){if(t.length===1)return 0;const n=t.map(a=>Math.abs(a-e)),r=Math.min(...n);return n.indexOf(r)}function L8(t,e,n){const r=t/2,i=my([0,50],[0,r]);return(r-i(e)*n)*n}function O8(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function D8(t,e){if(e>0){const n=O8(t);return Math.min(...n)>=e}return!0}function my(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(t[1]-t[0]);return e[0]+r*(n-t[0])}}function _8(t){return(String(t).split(".")[1]||"").length}function $8(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var z8=O2,F8=F2,B8=B2,V8=V2;function H8({className:t,defaultValue:e,value:n,min:r=0,max:a=100,...i}){const o=g.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[r,a],[n,e,r,a]);return s.jsxs(z8,{defaultValue:e,value:n,min:r,max:a,className:zt("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...i,children:[s.jsx(F8,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:s.jsx(B8,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>s.jsx(V8,{className:"block size-4 shrink-0 rounded-full border-2 border-[#38bdac] bg-white shadow-sm focus-visible:ring-2 focus-visible:ring-[#38bdac] focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"},u))]})}const U8={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,withdrawFee:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function W2(t){const e=!!(t!=null&&t.embedded),[n,r]=g.useState(U8),[a,i]=g.useState(!0),[o,c]=g.useState(!1);g.useEffect(()=>{Le("/api/admin/referral-settings").then(f=>{const m=f==null?void 0:f.data;m&&typeof m=="object"&&r({distributorShare:m.distributorShare??90,minWithdrawAmount:m.minWithdrawAmount??10,bindingDays:m.bindingDays??30,userDiscount:m.userDiscount??5,withdrawFee:m.withdrawFee??5,enableAutoWithdraw:m.enableAutoWithdraw??!1,vipOrderShareVip:m.vipOrderShareVip??20,vipOrderShareNonVip:m.vipOrderShareNonVip??10})}).catch(console.error).finally(()=>i(!1))},[]);const u=async()=>{c(!0);try{const f={distributorShare:Number(n.distributorShare)||0,minWithdrawAmount:Number(n.minWithdrawAmount)||0,bindingDays:Number(n.bindingDays)||0,userDiscount:Number(n.userDiscount)||0,withdrawFee:Number(n.withdrawFee)??5,enableAutoWithdraw:!!n.enableAutoWithdraw,vipOrderShareVip:Number(n.vipOrderShareVip)||20,vipOrderShareNonVip:Number(n.vipOrderShareNonVip)||10},m=await bt("/api/admin/referral-settings",f);if(!m||m.success===!1){q.error("保存失败: "+(m&&typeof m=="object"&&"error"in m?m.error:""));return}q.success(`✅ 分销配置已保存成功!
• 小程序与网站的推广规则会一起生效
• 绑定关系会使用新的天数配置
• 佣金比例会立即应用到新订单
-如有缓存,请刷新前台/小程序页面。`)}catch(f){console.error(f),q.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{c(!1)}},h=f=>m=>{const x=parseFloat(m.target.value||"0");r(b=>({...b,[f]:isNaN(x)?0:x}))};return a?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:e?"p-4 w-full":"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(sd,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置(与系统设置中的「推广功能」开关配合:开关在"," ",s.jsx(_i,{to:"/settings",className:"text-[#38bdac] underline hover:text-[#5ee0d1]",children:"系统设置 → 功能开关"}),")。"]})]}),s.jsxs(G,{onClick:u,disabled:o||a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),o?"保存中...":"保存配置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"flex items-center gap-2 text-white",children:[s.jsx(tA,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),s.jsx(Qt,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),s.jsx(_e,{className:"space-y-6",children:s.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Jh,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.userDiscount,onChange:h("userDiscount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"例如 5 表示好友立减 5%(在价格配置基础上生效)。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Kn,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(H8,{className:"flex-1",min:10,max:100,step:1,value:[n.distributorShare],onValueChange:([f])=>r(m=>({...m,distributorShare:f}))}),s.jsx(oe,{type:"number",min:0,max:100,className:"w-20 bg-[#0a1628] border-gray-700 text-white text-center",value:n.distributorShare,onChange:h("distributorShare")})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["内容订单佣金 = 订单金额 ×"," ",s.jsxs("span",{className:"text-[#38bdac] font-mono",children:[n.distributorShare,"%"]}),";会员订单见下方。"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Jh,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.vipOrderShareVip,onChange:h("vipOrderShareVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者已是会员时,会员订单佣金比例,默认 20%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Jh,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.vipOrderShareNonVip,onChange:h("vipOrderShareNonVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者非会员时,会员订单佣金比例,默认 10%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Kn,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),s.jsx(oe,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:n.bindingDays,onChange:h("bindingDays")}),s.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"flex items-center gap-2 text-white",children:[s.jsx(sd,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),s.jsx(Qt,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),s.jsx(_e,{className:"space-y-6",children:s.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"最低提现金额(元)"}),s.jsx(oe,{type:"number",min:0,step:1,className:"bg-[#0a1628] border-gray-700 text-white",value:n.minWithdrawAmount,onChange:h("minWithdrawAmount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"小程序「满 X 元可提现」展示的门槛,同时用于后端接口校验。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"提现手续费(%)"}),s.jsx(oe,{type:"number",min:0,max:100,step:.5,className:"bg-[#0a1628] border-gray-700 text-white",value:n.withdrawFee,onChange:h("withdrawFee")}),s.jsx("p",{className:"text-xs text-gray-500",children:"批准提现时按此比例扣除后打款,如 5 表示申请 100 元实际到账 95 元。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",s.jsx(Be,{variant:"outline",className:"border-[#38bdac]/40 text-[#38bdac] text-[10px]",children:"预留"})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[s.jsx(Kt,{checked:n.enableAutoWithdraw,onCheckedChange:f=>r(m=>({...m,enableAutoWithdraw:f}))}),s.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(dt,{children:s.jsxs(ut,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[s.jsx(Jh,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),s.jsxs(_e,{className:"space-y-2 text-xs text-gray-400 leading-relaxed",children:[s.jsxs("p",{children:["1. 以上配置会写入"," ",s.jsx("code",{className:"font-mono text-[11px] text-[#38bdac]",children:"system_config.referral_config"}),",小程序「推广中心」、Web 推广页以及支付回调都会读取同一份配置。"]}),s.jsx("p",{children:"2. 修改后新订单立即生效;旧订单的历史佣金不会自动重算,只影响之后产生的订单。"}),s.jsx("p",{children:"3. 如遇前端展示与实际结算不一致,优先以此处配置为准,再排查缓存和小程序版本。"})]})]})]})]})}function W8(){const[t]=X0(),e=Ya(),[n,r]=g.useState("overview"),[a,i]=g.useState("orders"),[o,c]=g.useState([]),[u,h]=g.useState(null),[f,m]=g.useState([]),[x,b]=g.useState([]),[N,w]=g.useState([]),[v,k]=g.useState(!0),[T,C]=g.useState(null),[L,R]=g.useState(""),[U,P]=g.useState("all"),[z,O]=g.useState(1),[Q,re]=g.useState(10),[D,ne]=g.useState(0),[le,me]=g.useState(new Set),[I,Y]=g.useState(null),[F,xe]=g.useState(""),[X,V]=g.useState(!1),[W,fe]=g.useState(null),[he,de]=g.useState(""),[_,J]=g.useState(!1),[$,Z]=g.useState(!1),[ae,we]=g.useState(!1),[Fe,Ue]=g.useState([]),[wt,jn]=g.useState(1),[pt,At]=g.useState(0),[fn,Vn]=g.useState("");g.useEffect(()=>{t.get("tab")==="leads"&&e("/users?tab=leads",{replace:!0})},[t,e]),g.useEffect(()=>{pn()},[]),g.useEffect(()=>{const H=t.get("tab");(H==="overview"||H==="orders"||H==="bindings"||H==="withdrawals"||H==="settings")&&r(H)},[t]),g.useEffect(()=>{O(1)},[n,U]),g.useEffect(()=>{qt(n)},[n]),g.useEffect(()=>{if(n==="orders"&&a==="giftpay"){qt("giftPay",!0);return}["orders","bindings","withdrawals"].includes(n)&&qt(n,!0)},[z,Q,U,L,n,a,wt,fn]),g.useEffect(()=>{n==="withdrawals"&&_t()},[n]);async function pn(){C(null);try{const H=await Le("/api/admin/distribution/overview");H!=null&&H.success&&H.overview&&h(H.overview)}catch(H){console.error("[Admin] 概览接口异常:",H),C("加载概览失败")}try{const H=await Le("/api/db/users");w((H==null?void 0:H.users)||[])}catch(H){console.error("[Admin] 用户数据加载失败:",H)}}async function qt(H,Qe=!1){var vt;if(!(!Qe&&le.has(H))){k(!0);try{const Ft=N;switch(H){case"overview":break;case"orders":{try{const yt=new URLSearchParams({page:String(z),pageSize:String(Q),...U!=="all"&&{status:U},...L&&{search:L}}),ht=await Le(`/api/admin/orders?${yt}`);if(ht!=null&&ht.success&&ht.orders){const Pt=ht.orders.map(Gt=>{const kn=Ft.find(Ms=>Ms.id===Gt.userId),Ts=Gt.referrerId?Ft.find(Ms=>Ms.id===Gt.referrerId):null;return{...Gt,amount:parseFloat(String(Gt.amount))||0,userNickname:(kn==null?void 0:kn.nickname)||Gt.userNickname||"未知用户",userPhone:(kn==null?void 0:kn.phone)||Gt.userPhone||"-",referrerNickname:(Ts==null?void 0:Ts.nickname)||null,referrerCode:(Ts==null?void 0:Ts.referralCode)??null,type:Gt.productType||Gt.type}});c(Pt),ne(ht.total??Pt.length)}else c([]),ne(0)}catch(yt){console.error(yt),C("加载订单失败"),c([])}break}case"bindings":{try{const yt=new URLSearchParams({page:String(z),pageSize:String(Q),...U!=="all"&&{status:U}}),ht=await Le(`/api/db/distribution?${yt}`);m((ht==null?void 0:ht.bindings)||[]),ne((ht==null?void 0:ht.total)??((vt=ht==null?void 0:ht.bindings)==null?void 0:vt.length)??0)}catch(yt){console.error(yt),C("加载绑定数据失败"),m([])}break}case"withdrawals":{try{const yt=U==="completed"?"success":U==="rejected"?"failed":U,ht=new URLSearchParams({...yt&&yt!=="all"&&{status:yt},page:String(z),pageSize:String(Q)}),Pt=await Le(`/api/admin/withdrawals?${ht}`);if(Pt!=null&&Pt.success&&Pt.withdrawals){const Gt=Pt.withdrawals.map(kn=>({...kn,account:kn.account??"未绑定微信号",status:kn.status==="success"?"completed":kn.status==="failed"?"rejected":kn.status}));b(Gt),ne((Pt==null?void 0:Pt.total)??Gt.length)}else Pt!=null&&Pt.success||C(`获取提现记录失败: ${(Pt==null?void 0:Pt.error)||"未知错误"}`),b([])}catch(yt){console.error(yt),C("加载提现数据失败"),b([])}break}case"giftPay":{try{const yt=new URLSearchParams({page:String(wt),pageSize:"20",...fn&&{status:fn}}),ht=await Le(`/api/admin/gift-pay-requests?${yt}`);ht!=null&&ht.success&&ht.data?(Ue(ht.data),At(ht.total??ht.data.length)):(Ue([]),At(0))}catch(yt){console.error(yt),C("加载代付请求失败"),Ue([])}break}}me(yt=>new Set(yt).add(H))}catch(Ft){console.error(Ft)}finally{k(!1)}}}async function bn(){C(null),me(H=>{const Qe=new Set(H);return Qe.delete(n),n==="orders"&&a==="giftpay"&&Qe.delete("giftPay"),Qe}),n==="overview"&&pn(),n==="orders"&&a==="giftpay"?await qt("giftPay",!0):await qt(n,!0)}async function Mn(H){if(confirm("确认审核通过并打款?"))try{const Qe=await tn("/api/admin/withdrawals",{id:H,action:"approve"});if(!(Qe!=null&&Qe.success)){const vt=(Qe==null?void 0:Qe.message)||(Qe==null?void 0:Qe.error)||"操作失败";q.error(vt);return}await bn()}catch(Qe){console.error(Qe),q.error("操作失败")}}function Hn(H){fe(H),de("")}async function rs(){const H=W;if(!H)return;const Qe=he.trim();if(!Qe){q.error("请填写拒绝原因");return}J(!0);try{const vt=await tn("/api/admin/withdrawals",{id:H,action:"reject",errorMessage:Qe});if(!(vt!=null&&vt.success)){q.error((vt==null?void 0:vt.error)||"操作失败");return}q.success("已拒绝该提现申请"),fe(null),de(""),await bn()}catch(vt){console.error(vt),q.error("操作失败")}finally{J(!1)}}async function _t(){try{const H=await Le("/api/admin/withdrawals/auto-approve");H!=null&&H.success&&typeof H.enableAutoApprove=="boolean"&&Z(H.enableAutoApprove)}catch{}}async function vn(H){we(!0);try{const Qe=await tn("/api/admin/withdrawals/auto-approve",{enableAutoApprove:H});Qe!=null&&Qe.success?(Z(H),q.success(H?"已开启自动审批,新提现将自动打款":"已关闭自动审批")):q.error("更新失败: "+((Qe==null?void 0:Qe.error)??""))}catch{q.error("更新失败")}finally{we(!1)}}function Ne(){W&&q.info("已取消操作"),fe(null),de("")}async function Me(){var H;if(!(!(I!=null&&I.orderSn)&&!(I!=null&&I.id))){V(!0),C(null);try{const Qe=await tn("/api/admin/orders/refund",{orderSn:I.orderSn||I.id,reason:F||void 0});Qe!=null&&Qe.success?(Y(null),xe(""),await qt("orders",!0)):C((Qe==null?void 0:Qe.error)||"退款失败")}catch(Qe){const vt=Qe;C(((H=vt==null?void 0:vt.data)==null?void 0:H.error)||"退款失败,请检查网络后重试")}finally{V(!1)}}}function We(H){const Qe={active:"bg-green-500/20 text-green-400",converted:"bg-blue-500/20 text-blue-400",expired:"bg-gray-500/20 text-gray-400",cancelled:"bg-red-500/20 text-red-400",pending:"bg-orange-500/20 text-orange-400",pending_confirm:"bg-orange-500/20 text-orange-400",processing:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",rejected:"bg-red-500/20 text-red-400"},vt={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return s.jsx(Be,{className:`${Qe[H]||"bg-gray-500/20 text-gray-400"} border-0`,children:vt[H]||H})}const rt=Math.ceil(D/Q)||1,$t=o,kt=f.filter(H=>{var vt,Ft,yt,ht;if(!L)return!0;const Qe=L.toLowerCase();return((vt=H.refereeNickname)==null?void 0:vt.toLowerCase().includes(Qe))||((Ft=H.refereePhone)==null?void 0:Ft.includes(Qe))||((yt=H.referrerName)==null?void 0:yt.toLowerCase().includes(Qe))||((ht=H.referrerCode)==null?void 0:ht.toLowerCase().includes(Qe))}),$e=x.filter(H=>{var vt;if(!L)return!0;const Qe=L.toLowerCase();return((vt=H.userName)==null?void 0:vt.toLowerCase().includes(Qe))||H.account&&H.account.toLowerCase().includes(Qe)});return s.jsxs("div",{className:"p-8 w-full",children:[T&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[s.jsx("span",{children:T}),s.jsx("button",{type:"button",onClick:()=>C(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-semibold text-white",children:"推广中心"}),s.jsx("p",{className:"text-gray-500 text-sm mt-0.5",children:"分销绑定、提现审核、推广设置"})]}),s.jsxs(G,{onClick:bn,disabled:v,variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[s.jsx(Ve,{className:`w-3.5 h-3.5 mr-1.5 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx("div",{className:"flex gap-1 mb-6 bg-[#0a1628] rounded-lg p-1 border border-gray-700/40",children:[{key:"overview",label:"数据概览",icon:Of},{key:"orders",label:"订单与代付",icon:Rf},{key:"bindings",label:"绑定管理",icon:Ua},{key:"withdrawals",label:"提现审核",icon:sd},{key:"settings",label:"推广设置",icon:Po}].map(H=>s.jsxs("button",{type:"button",onClick:()=>{r(H.key),P("all"),R(""),H.key!=="orders"&&i("orders")},className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2 rounded-md text-sm transition-all ${n===H.key?"bg-[#38bdac] text-white shadow-md":"text-gray-400 hover:text-white hover:bg-gray-700/40"}`,children:[s.jsx(H.icon,{className:"w-3.5 h-3.5"}),H.label]},H.key))}),v?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Ve,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[n==="overview"&&u&&s.jsxs("div",{className:"space-y-6",children:[s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("span",{className:"text-sm font-medium text-gray-300 flex items-center gap-2",children:[s.jsx(Ho,{className:"w-4 h-4 text-amber-400"}),"推广转化漏斗"]}),s.jsx(G,{type:"button",size:"sm",variant:"ghost",onClick:()=>void bn(),disabled:v,className:"text-gray-400 h-7",children:s.jsx(Ve,{className:`w-3.5 h-3.5 ${v?"animate-spin":""}`})})]}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-gray-500 text-xs border-b border-gray-700/50",children:[s.jsx("th",{className:"pb-2 text-left font-normal",children:"指标"}),s.jsx("th",{className:"pb-2 text-right font-normal",children:"今日"}),s.jsx("th",{className:"pb-2 text-right font-normal",children:"本月"}),s.jsx("th",{className:"pb-2 text-right font-normal",children:"累计"})]})}),s.jsxs("tbody",{className:"text-white",children:[s.jsxs("tr",{className:"border-b border-gray-700/30",children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(Lf,{className:"w-4 h-4 text-blue-400"}),"点击数"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:u.todayClicks}),s.jsx("td",{className:"py-2.5 text-right",children:u.monthClicks}),s.jsx("td",{className:"py-2.5 text-right",children:u.totalClicks})]}),s.jsxs("tr",{className:"border-b border-gray-700/30",children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(Ua,{className:"w-4 h-4 text-green-400"}),"绑定关系"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:u.todayBindings}),s.jsx("td",{className:"py-2.5 text-right",children:u.monthBindings}),s.jsx("td",{className:"py-2.5 text-right",children:u.totalBindings})]}),s.jsxs("tr",{className:"border-b border-gray-700/30",children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx($x,{className:"w-4 h-4 text-purple-400"}),"付款转化"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:u.todayConversions}),s.jsx("td",{className:"py-2.5 text-right",children:u.monthConversions}),s.jsx("td",{className:"py-2.5 text-right",children:u.totalConversions})]}),s.jsxs("tr",{children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(Rf,{className:"w-4 h-4 text-[#38bdac]"}),"佣金收入"]}),s.jsxs("td",{className:"py-2.5 text-right font-bold text-[#38bdac]",children:["¥",(u.todayEarnings??0).toFixed(0)]}),s.jsxs("td",{className:"py-2.5 text-right text-[#38bdac]",children:["¥",(u.monthEarnings??0).toFixed(0)]}),s.jsxs("td",{className:"py-2.5 text-right text-[#38bdac]",children:["¥",(u.totalEarnings??0).toFixed(0)]})]})]})]})}),u.conversionRate&&s.jsxs("p",{className:"text-xs text-gray-500 mt-3 text-right",children:["综合转化率 ",u.conversionRate]})]})}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(De,{className:"bg-orange-500/10 border-orange-500/30",children:s.jsx(_e,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Vg,{className:"w-5 h-5 text-orange-400 shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-orange-300 font-medium text-sm",children:"即将过期绑定"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[u.expiringBindings," ",s.jsx("span",{className:"text-sm font-normal text-orange-300/60",children:"个 · 7天内"})]})]})]})})}),s.jsx(De,{className:"bg-blue-500/10 border-blue-500/30",children:s.jsx(_e,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(sd,{className:"w-5 h-5 text-blue-400 shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-blue-300 font-medium text-sm",children:"待审核提现"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[u.pendingWithdrawals," ",s.jsxs("span",{className:"text-sm font-normal text-blue-300/60",children:["笔 · ¥",(u.pendingWithdrawAmount??0).toFixed(0)]})]})]}),s.jsx(G,{onClick:()=>r("withdrawals"),variant:"outline",size:"sm",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20 shrink-0",children:"去审核"})]})})})]}),s.jsx(De,{className:"bg-emerald-500/10 border-emerald-500/30",children:s.jsxs(_e,{className:"p-4 flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-emerald-300 font-medium text-sm",children:"获客线索(存客宝)"}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"留资列表、推送状态与重试已统一至「用户管理 → 获客列表」,避免与推广中心重复维护。"})]}),s.jsx(_i,{to:"/users?tab=leads",className:"shrink-0",children:s.jsx(G,{type:"button",variant:"outline",size:"sm",className:"border-emerald-500/50 text-emerald-400 hover:bg-emerald-500/15 bg-transparent",children:"打开获客列表"})})]})}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(_e,{className:"p-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-white/5",children:[s.jsx(Kn,{className:"w-5 h-5 text-gray-400 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-lg font-bold text-white",children:u.totalDistributors}),s.jsx("p",{className:"text-[10px] text-gray-500",children:"推广用户"})]})]}),s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-white/5",children:[s.jsx($x,{className:"w-5 h-5 text-green-400 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-lg font-bold text-green-400",children:u.activeDistributors}),s.jsx("p",{className:"text-[10px] text-gray-500",children:"有收益用户"})]})]})]})})})]}),n==="orders"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2 mb-2",children:[s.jsx("button",{type:"button",className:`px-3 py-1.5 rounded-md text-xs font-medium transition-all ${a==="orders"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,onClick:()=>i("orders"),children:"普通订单"}),s.jsxs("button",{type:"button",className:`px-3 py-1.5 rounded-md text-xs font-medium transition-all ${a==="giftpay"?"bg-amber-500/20 text-amber-400 border border-amber-500/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,onClick:()=>{i("giftpay"),qt("giftPay",!0)},children:[s.jsx(Hg,{className:"w-3 h-3 inline mr-1"}),"代付请求"]})]}),a==="orders"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[s.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[s.jsx(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:L,onChange:H=>R(H.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:U,onChange:H=>P(H.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"pending",children:"待支付"}),s.jsx("option",{value:"failed",children:"已失败"}),s.jsx("option",{value:"refunded",children:"已退款"})]}),s.jsxs(G,{type:"button",variant:"outline",onClick:()=>void bn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-0",children:[o.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无订单数据"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"订单号"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"商品"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"支付方式"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"退款原因"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"推荐人/邀请码"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"分销佣金"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"下单时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:$t.map(H=>{var Qe,vt;return s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsxs("td",{className:"p-4 font-mono text-xs text-gray-400",children:[(Qe=H.id)==null?void 0:Qe.slice(0,12),"..."]}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:H.userNickname}),s.jsx("p",{className:"text-gray-500 text-xs",children:H.userPhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:(()=>{const Ft=H.productType||H.type,yt=H.description||"",ht=String(H.productId||H.sectionId||""),Pt=Ft==="vip"||yt.includes("VIP")||yt.toLowerCase().includes("vip")||ht.toLowerCase().includes("vip");return Ft==="balance_recharge"?`余额充值 ¥${typeof H.amount=="number"?H.amount.toFixed(2):parseFloat(String(H.amount||"0")).toFixed(2)}`:Pt?"超级个体开通费用":Ft==="fullbook"?`${H.bookName||"《底层逻辑》"} - 全本`:Ft==="match"?"匹配次数购买":`${H.bookName||"《底层逻辑》"} - ${H.sectionTitle||H.chapterTitle||`章节${H.productId||H.sectionId||""}`}`})()}),s.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const Ft=H.productType||H.type,yt=H.description||"",ht=String(H.productId||H.sectionId||""),Pt=Ft==="vip"||yt.includes("VIP")||yt.toLowerCase().includes("vip")||ht.toLowerCase().includes("vip");return Ft==="balance_recharge"?"余额充值":Pt?"超级个体":Ft==="fullbook"?"全书解锁":Ft==="match"?"功能权益":H.chapterTitle||"单章购买"})()})]})}),s.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof H.amount=="number"?H.amount.toFixed(2):parseFloat(String(H.amount||"0")).toFixed(2)]}),s.jsx("td",{className:"p-4 text-gray-300",children:H.paymentMethod==="wechat"?"微信支付":H.paymentMethod==="balance"?"余额支付":H.paymentMethod==="alipay"?"支付宝":H.paymentMethod||"微信支付"}),s.jsx("td",{className:"p-4",children:H.status==="refunded"?s.jsx(Be,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):H.status==="completed"||H.status==="paid"?s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):H.status==="pending"||H.status==="created"?s.jsx(Be,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):s.jsx(Be,{className:"bg-red-500/20 text-red-400 border-0",children:"已失败"})}),s.jsx("td",{className:"p-4 text-gray-400 text-sm max-w-[120px]",title:H.refundReason,children:H.status==="refunded"&&H.refundReason?H.refundReason:"-"}),s.jsx("td",{className:"p-4 text-gray-300 text-sm",children:H.referrerId||H.referralCode?s.jsxs("span",{title:H.referralCode||H.referrerCode||H.referrerId||"",children:[H.referrerNickname||H.referralCode||H.referrerCode||((vt=H.referrerId)==null?void 0:vt.slice(0,8)),(H.referralCode||H.referrerCode)&&` (${H.referralCode||H.referrerCode})`]}):"-"}),s.jsx("td",{className:"p-4 text-[#FFD700]",children:H.referrerEarnings?`¥${(typeof H.referrerEarnings=="number"?H.referrerEarnings:parseFloat(String(H.referrerEarnings))).toFixed(2)}`:"-"}),s.jsx("td",{className:"p-4 text-gray-400 text-sm",children:H.createdAt?new Date(H.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:(H.status==="paid"||H.status==="completed")&&s.jsxs(G,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{Y(H),xe("")},children:[s.jsx(lk,{className:"w-3 h-3 mr-1"}),"退款"]})})]},H.id)})})]})}),n==="orders"&&s.jsx(xs,{page:z,totalPages:rt,total:D,pageSize:Q,onPageChange:O,onPageSizeChange:H=>{re(H),O(1)}})]})})]}),a==="giftpay"&&s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(dt,{children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[s.jsx(ut,{className:"text-white text-base",children:"代付请求列表"}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsxs("select",{className:"bg-[#0a1628] border border-gray-700 text-white rounded px-3 py-1.5 text-sm",value:fn,onChange:H=>{Vn(H.target.value),jn(1)},children:[s.jsx("option",{value:"",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待支付(旧)"}),s.jsx("option",{value:"pending_pay",children:"待发起人支付"}),s.jsx("option",{value:"paid",children:"已支付"}),s.jsx("option",{value:"refunded",children:"已退款"}),s.jsx("option",{value:"cancelled",children:"已取消"}),s.jsx("option",{value:"expired",children:"已过期"})]}),s.jsxs(G,{size:"sm",variant:"outline",onClick:()=>void qt("giftPay",!0),disabled:v,className:"border-gray-600 text-gray-300",children:[s.jsx(Ve,{className:`w-3.5 h-3.5 mr-1 ${v?"animate-spin":""}`}),"刷新"]})]})]})}),s.jsxs(_e,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-700/50",children:[s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"请求号"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"发起人"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"商品/金额"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"份数/已领"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"付款人"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"状态"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"创建时间"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:Fe.map(H=>s.jsxs("tr",{className:"hover:bg-[#0a1628]",children:[s.jsx("td",{className:"p-3 font-mono text-xs text-gray-400",children:H.requestSn}),s.jsx("td",{className:"p-3 text-white text-sm",children:H.initiatorNick||H.initiatorUserId}),s.jsxs("td",{className:"p-3",children:[s.jsxs("p",{className:"text-white",children:[H.productType," · ¥",H.amount.toFixed(2)]}),H.description&&s.jsx("p",{className:"text-gray-500 text-xs",children:H.description})]}),s.jsx("td",{className:"p-3 text-gray-400",children:(H.quantity??1)>1?`${H.quantity}份 / 已领${H.redeemedCount??0}`:"-"}),s.jsx("td",{className:"p-3 text-gray-400",children:H.payerNick||(H.payerUserId?H.payerUserId:"-")}),s.jsx("td",{className:"p-3",children:s.jsx(Be,{className:H.status==="paid"?"bg-green-500/20 text-green-400 border-0":H.status==="pending"||H.status==="pending_pay"?"bg-amber-500/20 text-amber-400 border-0":H.status==="refunded"?"bg-red-500/20 text-red-400 border-0":"bg-gray-500/20 text-gray-400 border-0",children:H.status==="paid"?"已支付":H.status==="pending"||H.status==="pending_pay"?"待支付":H.status==="refunded"?"已退款":H.status==="cancelled"?"已取消":"已过期"})}),s.jsx("td",{className:"p-3 text-gray-400 text-xs",children:H.createdAt?new Date(H.createdAt).toLocaleString("zh-CN"):"-"})]},H.id))})]})}),Fe.length===0&&!v&&s.jsx("p",{className:"text-center py-8 text-gray-500",children:"暂无代付请求"}),pt>20&&s.jsx("div",{className:"mt-4 flex justify-center",children:s.jsx(xs,{page:wt,totalPages:Math.ceil(pt/20),total:pt,pageSize:20,onPageChange:jn,onPageSizeChange:()=>{}})})]})]})]}),n==="bindings"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[s.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[s.jsx(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:L,onChange:H=>R(H.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:U,onChange:H=>P(H.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"active",children:"有效"}),s.jsx("option",{value:"converted",children:"已转化"}),s.jsx("option",{value:"expired",children:"已过期"})]}),s.jsxs(G,{type:"button",variant:"outline",onClick:()=>void bn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-0",children:[kt.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无绑定数据"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"访客"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"分销商"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"绑定时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"到期时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"佣金"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:kt.map(H=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:H.refereeNickname||"匿名用户"}),s.jsx("p",{className:"text-gray-500 text-xs",children:H.refereePhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:H.referrerName||"-"}),s.jsx("p",{className:"text-gray-500 text-xs font-mono",children:H.referrerCode})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:H.boundAt?new Date(H.boundAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:H.expiresAt?new Date(H.expiresAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:We(H.status)}),s.jsx("td",{className:"p-4",children:H.commission?s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",H.commission.toFixed(2)]}):s.jsx("span",{className:"text-gray-500",children:"-"})})]},H.id))})]})}),n==="bindings"&&s.jsx(xs,{page:z,totalPages:rt,total:D,pageSize:Q,onPageChange:O,onPageSizeChange:H=>{re(H),O(1)}})]})})]}),n==="withdrawals"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[s.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[s.jsx(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:L,onChange:H=>R(H.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:U,onChange:H=>P(H.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待审核"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"rejected",children:"已拒绝"})]}),s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[#0f2137] border border-gray-700/50 shrink-0",children:[s.jsx(Ho,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-sm text-gray-300",children:"自动审批"}),s.jsx(Kt,{checked:$,onCheckedChange:vn,disabled:ae,className:"data-[state=checked]:bg-[#38bdac]"})]}),s.jsxs(G,{type:"button",variant:"outline",onClick:()=>void bn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-0",children:[$e.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无提现记录"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"申请人"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"收款方式"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"收款账号"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"备注"}),s.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:$e.map(H=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[H.userAvatar?s.jsx("img",{src:H.userAvatar,alt:"",className:"w-8 h-8 rounded-full object-cover"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-600 flex items-center justify-center text-white text-sm font-medium",children:(H.userName||H.name||"?").slice(0,1)}),s.jsx("p",{className:"text-white font-medium",children:H.userName||H.name})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",H.amount.toFixed(2)]})}),s.jsx("td",{className:"p-4",children:s.jsx(Be,{className:H.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:H.method==="wechat"?"微信":"支付宝"})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-mono text-xs",children:H.account}),s.jsx("p",{className:"text-gray-500 text-xs",children:H.name})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:H.createdAt?new Date(H.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:We(H.status)}),s.jsx("td",{className:"p-4 max-w-[160px]",children:s.jsx("span",{className:`text-xs ${H.status==="rejected"||H.status==="failed"?"text-red-400":"text-gray-400"}`,title:H.remark,children:H.remark||"-"})}),s.jsx("td",{className:"p-4 text-right",children:H.status==="pending"&&s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsxs(G,{size:"sm",onClick:()=>Mn(H.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx($x,{className:"w-4 h-4 mr-1"}),"通过"]}),s.jsxs(G,{size:"sm",variant:"outline",onClick:()=>Hn(H.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[s.jsx(tk,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},H.id))})]})}),n==="withdrawals"&&s.jsx(xs,{page:z,totalPages:rt,total:D,pageSize:Q,onPageChange:O,onPageSizeChange:H=>{re(H),O(1)}})]})})]})]}),s.jsx(Lt,{open:!!I,onOpenChange:H=>!H&&Y(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:"订单退款"})}),I&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",I.orderSn||I.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof I.amount=="number"?I.amount.toFixed(2):parseFloat(String(I.amount||"0")).toFixed(2)]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:F,onChange:H=>xe(H.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>Y(null),disabled:X,children:"取消"}),s.jsx(G,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:Me,disabled:X,children:X?"退款中...":"确认退款"})]})]})}),s.jsx(Lt,{open:!!W,onOpenChange:H=>!H&&Ne(),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:"拒绝提现"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:he,onChange:H=>de(H.target.value)})})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:Ne,disabled:_,children:"取消"}),s.jsx(G,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:rs,disabled:_||!he.trim(),children:_?"提交中...":"确认拒绝"})]})]})}),n==="settings"&&s.jsx("div",{className:"-mx-8 -mt-6",children:s.jsx(W2,{embedded:!0})})]})}function K8(){const[t,e]=g.useState([]),[n,r]=g.useState({total:0,pendingCount:0,pendingAmount:0,successCount:0,successAmount:0,failedCount:0}),[a,i]=g.useState(!0),[o,c]=g.useState(null),[u,h]=g.useState("all"),[f,m]=g.useState(1),[x,b]=g.useState(10),[N,w]=g.useState(0),[v,k]=g.useState(null),[T,C]=g.useState(null),[L,R]=g.useState(""),[U,P]=g.useState(!1);async function z(){var I,Y,F,xe,X,V,W;i(!0),c(null);try{const fe=new URLSearchParams({status:u,page:String(f),pageSize:String(x)}),he=await Le(`/api/admin/withdrawals?${fe}`);if(he!=null&&he.success){const de=he.withdrawals||[];e(de),w(he.total??((I=he.stats)==null?void 0:I.total)??de.length),r({total:((Y=he.stats)==null?void 0:Y.total)??he.total??de.length,pendingCount:((F=he.stats)==null?void 0:F.pendingCount)??0,pendingAmount:((xe=he.stats)==null?void 0:xe.pendingAmount)??0,successCount:((X=he.stats)==null?void 0:X.successCount)??0,successAmount:((V=he.stats)==null?void 0:V.successAmount)??0,failedCount:((W=he.stats)==null?void 0:W.failedCount)??0})}else c("加载提现记录失败")}catch(fe){console.error("Load withdrawals error:",fe),c("加载失败,请检查网络后重试")}finally{i(!1)}}g.useEffect(()=>{m(1)},[u]),g.useEffect(()=>{z()},[u,f,x]);const O=Math.ceil(N/x)||1;async function Q(I){const Y=t.find(F=>F.id===I);if(Y!=null&&Y.userCommissionInfo&&Y.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${Y.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。
+如有缓存,请刷新前台/小程序页面。`)}catch(f){console.error(f),q.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{c(!1)}},h=f=>m=>{const x=parseFloat(m.target.value||"0");r(b=>({...b,[f]:isNaN(x)?0:x}))};return a?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:e?"p-4 w-full":"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(sd,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置(与系统设置中的「推广功能」开关配合:开关在"," ",s.jsx(_i,{to:"/settings",className:"text-[#38bdac] underline hover:text-[#5ee0d1]",children:"系统设置 → 功能开关"}),")。"]})]}),s.jsxs(G,{onClick:u,disabled:o||a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),o?"保存中...":"保存配置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"flex items-center gap-2 text-white",children:[s.jsx(tA,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),s.jsx(Qt,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),s.jsx(_e,{className:"space-y-6",children:s.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Jh,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.userDiscount,onChange:h("userDiscount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"例如 5 表示好友立减 5%(在价格配置基础上生效)。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(qn,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(H8,{className:"flex-1",min:10,max:100,step:1,value:[n.distributorShare],onValueChange:([f])=>r(m=>({...m,distributorShare:f}))}),s.jsx(oe,{type:"number",min:0,max:100,className:"w-20 bg-[#0a1628] border-gray-700 text-white text-center",value:n.distributorShare,onChange:h("distributorShare")})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["内容订单佣金 = 订单金额 ×"," ",s.jsxs("span",{className:"text-[#38bdac] font-mono",children:[n.distributorShare,"%"]}),";会员订单见下方。"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Jh,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.vipOrderShareVip,onChange:h("vipOrderShareVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者已是会员时,会员订单佣金比例,默认 20%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Jh,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.vipOrderShareNonVip,onChange:h("vipOrderShareNonVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者非会员时,会员订单佣金比例,默认 10%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(qn,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),s.jsx(oe,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:n.bindingDays,onChange:h("bindingDays")}),s.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"flex items-center gap-2 text-white",children:[s.jsx(sd,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),s.jsx(Qt,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),s.jsx(_e,{className:"space-y-6",children:s.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"最低提现金额(元)"}),s.jsx(oe,{type:"number",min:0,step:1,className:"bg-[#0a1628] border-gray-700 text-white",value:n.minWithdrawAmount,onChange:h("minWithdrawAmount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"小程序「满 X 元可提现」展示的门槛,同时用于后端接口校验。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"提现手续费(%)"}),s.jsx(oe,{type:"number",min:0,max:100,step:.5,className:"bg-[#0a1628] border-gray-700 text-white",value:n.withdrawFee,onChange:h("withdrawFee")}),s.jsx("p",{className:"text-xs text-gray-500",children:"批准提现时按此比例扣除后打款,如 5 表示申请 100 元实际到账 95 元。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",s.jsx(Be,{variant:"outline",className:"border-[#38bdac]/40 text-[#38bdac] text-[10px]",children:"预留"})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[s.jsx(Kt,{checked:n.enableAutoWithdraw,onCheckedChange:f=>r(m=>({...m,enableAutoWithdraw:f}))}),s.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(dt,{children:s.jsxs(ut,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[s.jsx(Jh,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),s.jsxs(_e,{className:"space-y-2 text-xs text-gray-400 leading-relaxed",children:[s.jsxs("p",{children:["1. 以上配置会写入"," ",s.jsx("code",{className:"font-mono text-[11px] text-[#38bdac]",children:"system_config.referral_config"}),",小程序「推广中心」、Web 推广页以及支付回调都会读取同一份配置。"]}),s.jsx("p",{children:"2. 修改后新订单立即生效;旧订单的历史佣金不会自动重算,只影响之后产生的订单。"}),s.jsx("p",{children:"3. 如遇前端展示与实际结算不一致,优先以此处配置为准,再排查缓存和小程序版本。"})]})]})]})]})}function W8(){const[t]=X0(),e=Ya(),[n,r]=g.useState("overview"),[a,i]=g.useState("orders"),[o,c]=g.useState([]),[u,h]=g.useState(null),[f,m]=g.useState([]),[x,b]=g.useState([]),[N,w]=g.useState([]),[v,k]=g.useState(!0),[T,C]=g.useState(null),[L,R]=g.useState(""),[U,P]=g.useState("all"),[F,O]=g.useState(1),[Q,re]=g.useState(10),[D,ne]=g.useState(0),[le,me]=g.useState(new Set),[I,Y]=g.useState(null),[B,xe]=g.useState(""),[X,V]=g.useState(!1),[W,fe]=g.useState(null),[he,de]=g.useState(""),[_,J]=g.useState(!1),[$,Z]=g.useState(!1),[ae,we]=g.useState(!1),[Fe,Ue]=g.useState([]),[wt,jn]=g.useState(1),[pt,At]=g.useState(0),[fn,Vn]=g.useState("");g.useEffect(()=>{t.get("tab")==="leads"&&e("/users?tab=leads",{replace:!0})},[t,e]),g.useEffect(()=>{pn()},[]),g.useEffect(()=>{const H=t.get("tab");(H==="overview"||H==="orders"||H==="bindings"||H==="withdrawals"||H==="settings")&&r(H)},[t]),g.useEffect(()=>{O(1)},[n,U]),g.useEffect(()=>{qt(n)},[n]),g.useEffect(()=>{if(n==="orders"&&a==="giftpay"){qt("giftPay",!0);return}["orders","bindings","withdrawals"].includes(n)&&qt(n,!0)},[F,Q,U,L,n,a,wt,fn]),g.useEffect(()=>{n==="withdrawals"&&_t()},[n]);async function pn(){C(null);try{const H=await Le("/api/admin/distribution/overview");H!=null&&H.success&&H.overview&&h(H.overview)}catch(H){console.error("[Admin] 概览接口异常:",H),C("加载概览失败")}try{const H=await Le("/api/db/users");w((H==null?void 0:H.users)||[])}catch(H){console.error("[Admin] 用户数据加载失败:",H)}}async function qt(H,Qe=!1){var vt;if(!(!Qe&&le.has(H))){k(!0);try{const Ft=N;switch(H){case"overview":break;case"orders":{try{const yt=new URLSearchParams({page:String(F),pageSize:String(Q),...U!=="all"&&{status:U},...L&&{search:L}}),ht=await Le(`/api/admin/orders?${yt}`);if(ht!=null&&ht.success&&ht.orders){const Pt=ht.orders.map(Gt=>{const kn=Ft.find(Ms=>Ms.id===Gt.userId),Ts=Gt.referrerId?Ft.find(Ms=>Ms.id===Gt.referrerId):null;return{...Gt,amount:parseFloat(String(Gt.amount))||0,userNickname:(kn==null?void 0:kn.nickname)||Gt.userNickname||"未知用户",userPhone:(kn==null?void 0:kn.phone)||Gt.userPhone||"-",referrerNickname:(Ts==null?void 0:Ts.nickname)||null,referrerCode:(Ts==null?void 0:Ts.referralCode)??null,type:Gt.productType||Gt.type}});c(Pt),ne(ht.total??Pt.length)}else c([]),ne(0)}catch(yt){console.error(yt),C("加载订单失败"),c([])}break}case"bindings":{try{const yt=new URLSearchParams({page:String(F),pageSize:String(Q),...U!=="all"&&{status:U}}),ht=await Le(`/api/db/distribution?${yt}`);m((ht==null?void 0:ht.bindings)||[]),ne((ht==null?void 0:ht.total)??((vt=ht==null?void 0:ht.bindings)==null?void 0:vt.length)??0)}catch(yt){console.error(yt),C("加载绑定数据失败"),m([])}break}case"withdrawals":{try{const yt=U==="completed"?"success":U==="rejected"?"failed":U,ht=new URLSearchParams({...yt&&yt!=="all"&&{status:yt},page:String(F),pageSize:String(Q)}),Pt=await Le(`/api/admin/withdrawals?${ht}`);if(Pt!=null&&Pt.success&&Pt.withdrawals){const Gt=Pt.withdrawals.map(kn=>({...kn,account:kn.account??"未绑定微信号",status:kn.status==="success"?"completed":kn.status==="failed"?"rejected":kn.status}));b(Gt),ne((Pt==null?void 0:Pt.total)??Gt.length)}else Pt!=null&&Pt.success||C(`获取提现记录失败: ${(Pt==null?void 0:Pt.error)||"未知错误"}`),b([])}catch(yt){console.error(yt),C("加载提现数据失败"),b([])}break}case"giftPay":{try{const yt=new URLSearchParams({page:String(wt),pageSize:"20",...fn&&{status:fn}}),ht=await Le(`/api/admin/gift-pay-requests?${yt}`);ht!=null&&ht.success&&ht.data?(Ue(ht.data),At(ht.total??ht.data.length)):(Ue([]),At(0))}catch(yt){console.error(yt),C("加载代付请求失败"),Ue([])}break}}me(yt=>new Set(yt).add(H))}catch(Ft){console.error(Ft)}finally{k(!1)}}}async function bn(){C(null),me(H=>{const Qe=new Set(H);return Qe.delete(n),n==="orders"&&a==="giftpay"&&Qe.delete("giftPay"),Qe}),n==="overview"&&pn(),n==="orders"&&a==="giftpay"?await qt("giftPay",!0):await qt(n,!0)}async function Mn(H){if(confirm("确认审核通过并打款?"))try{const Qe=await tn("/api/admin/withdrawals",{id:H,action:"approve"});if(!(Qe!=null&&Qe.success)){const vt=(Qe==null?void 0:Qe.message)||(Qe==null?void 0:Qe.error)||"操作失败";q.error(vt);return}await bn()}catch(Qe){console.error(Qe),q.error("操作失败")}}function Hn(H){fe(H),de("")}async function as(){const H=W;if(!H)return;const Qe=he.trim();if(!Qe){q.error("请填写拒绝原因");return}J(!0);try{const vt=await tn("/api/admin/withdrawals",{id:H,action:"reject",errorMessage:Qe});if(!(vt!=null&&vt.success)){q.error((vt==null?void 0:vt.error)||"操作失败");return}q.success("已拒绝该提现申请"),fe(null),de(""),await bn()}catch(vt){console.error(vt),q.error("操作失败")}finally{J(!1)}}async function _t(){try{const H=await Le("/api/admin/withdrawals/auto-approve");H!=null&&H.success&&typeof H.enableAutoApprove=="boolean"&&Z(H.enableAutoApprove)}catch{}}async function vn(H){we(!0);try{const Qe=await tn("/api/admin/withdrawals/auto-approve",{enableAutoApprove:H});Qe!=null&&Qe.success?(Z(H),q.success(H?"已开启自动审批,新提现将自动打款":"已关闭自动审批")):q.error("更新失败: "+((Qe==null?void 0:Qe.error)??""))}catch{q.error("更新失败")}finally{we(!1)}}function Ne(){W&&q.info("已取消操作"),fe(null),de("")}async function Me(){var H;if(!(!(I!=null&&I.orderSn)&&!(I!=null&&I.id))){V(!0),C(null);try{const Qe=await tn("/api/admin/orders/refund",{orderSn:I.orderSn||I.id,reason:B||void 0});Qe!=null&&Qe.success?(Y(null),xe(""),await qt("orders",!0)):C((Qe==null?void 0:Qe.error)||"退款失败")}catch(Qe){const vt=Qe;C(((H=vt==null?void 0:vt.data)==null?void 0:H.error)||"退款失败,请检查网络后重试")}finally{V(!1)}}}function We(H){const Qe={active:"bg-green-500/20 text-green-400",converted:"bg-blue-500/20 text-blue-400",expired:"bg-gray-500/20 text-gray-400",cancelled:"bg-red-500/20 text-red-400",pending:"bg-orange-500/20 text-orange-400",pending_confirm:"bg-orange-500/20 text-orange-400",processing:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",rejected:"bg-red-500/20 text-red-400"},vt={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return s.jsx(Be,{className:`${Qe[H]||"bg-gray-500/20 text-gray-400"} border-0`,children:vt[H]||H})}const rt=Math.ceil(D/Q)||1,$t=o,St=f.filter(H=>{var vt,Ft,yt,ht;if(!L)return!0;const Qe=L.toLowerCase();return((vt=H.refereeNickname)==null?void 0:vt.toLowerCase().includes(Qe))||((Ft=H.refereePhone)==null?void 0:Ft.includes(Qe))||((yt=H.referrerName)==null?void 0:yt.toLowerCase().includes(Qe))||((ht=H.referrerCode)==null?void 0:ht.toLowerCase().includes(Qe))}),$e=x.filter(H=>{var vt;if(!L)return!0;const Qe=L.toLowerCase();return((vt=H.userName)==null?void 0:vt.toLowerCase().includes(Qe))||H.account&&H.account.toLowerCase().includes(Qe)});return s.jsxs("div",{className:"p-8 w-full",children:[T&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[s.jsx("span",{children:T}),s.jsx("button",{type:"button",onClick:()=>C(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-semibold text-white",children:"推广中心"}),s.jsx("p",{className:"text-gray-500 text-sm mt-0.5",children:"分销绑定、提现审核、推广设置"})]}),s.jsxs(G,{onClick:bn,disabled:v,variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[s.jsx(Ve,{className:`w-3.5 h-3.5 mr-1.5 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx("div",{className:"flex gap-1 mb-6 bg-[#0a1628] rounded-lg p-1 border border-gray-700/40",children:[{key:"overview",label:"数据概览",icon:Of},{key:"orders",label:"订单与代付",icon:Rf},{key:"bindings",label:"绑定管理",icon:Ua},{key:"withdrawals",label:"提现审核",icon:sd},{key:"settings",label:"推广设置",icon:Po}].map(H=>s.jsxs("button",{type:"button",onClick:()=>{r(H.key),P("all"),R(""),H.key!=="orders"&&i("orders")},className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2 rounded-md text-sm transition-all ${n===H.key?"bg-[#38bdac] text-white shadow-md":"text-gray-400 hover:text-white hover:bg-gray-700/40"}`,children:[s.jsx(H.icon,{className:"w-3.5 h-3.5"}),H.label]},H.key))}),v?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Ve,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[n==="overview"&&u&&s.jsxs("div",{className:"space-y-6",children:[s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("span",{className:"text-sm font-medium text-gray-300 flex items-center gap-2",children:[s.jsx(Ho,{className:"w-4 h-4 text-amber-400"}),"推广转化漏斗"]}),s.jsx(G,{type:"button",size:"sm",variant:"ghost",onClick:()=>void bn(),disabled:v,className:"text-gray-400 h-7",children:s.jsx(Ve,{className:`w-3.5 h-3.5 ${v?"animate-spin":""}`})})]}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-gray-500 text-xs border-b border-gray-700/50",children:[s.jsx("th",{className:"pb-2 text-left font-normal",children:"指标"}),s.jsx("th",{className:"pb-2 text-right font-normal",children:"今日"}),s.jsx("th",{className:"pb-2 text-right font-normal",children:"本月"}),s.jsx("th",{className:"pb-2 text-right font-normal",children:"累计"})]})}),s.jsxs("tbody",{className:"text-white",children:[s.jsxs("tr",{className:"border-b border-gray-700/30",children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(Lf,{className:"w-4 h-4 text-blue-400"}),"点击数"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:u.todayClicks}),s.jsx("td",{className:"py-2.5 text-right",children:u.monthClicks}),s.jsx("td",{className:"py-2.5 text-right",children:u.totalClicks})]}),s.jsxs("tr",{className:"border-b border-gray-700/30",children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(Ua,{className:"w-4 h-4 text-green-400"}),"绑定关系"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:u.todayBindings}),s.jsx("td",{className:"py-2.5 text-right",children:u.monthBindings}),s.jsx("td",{className:"py-2.5 text-right",children:u.totalBindings})]}),s.jsxs("tr",{className:"border-b border-gray-700/30",children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx($x,{className:"w-4 h-4 text-purple-400"}),"付款转化"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:u.todayConversions}),s.jsx("td",{className:"py-2.5 text-right",children:u.monthConversions}),s.jsx("td",{className:"py-2.5 text-right",children:u.totalConversions})]}),s.jsxs("tr",{children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(Rf,{className:"w-4 h-4 text-[#38bdac]"}),"佣金收入"]}),s.jsxs("td",{className:"py-2.5 text-right font-bold text-[#38bdac]",children:["¥",(u.todayEarnings??0).toFixed(0)]}),s.jsxs("td",{className:"py-2.5 text-right text-[#38bdac]",children:["¥",(u.monthEarnings??0).toFixed(0)]}),s.jsxs("td",{className:"py-2.5 text-right text-[#38bdac]",children:["¥",(u.totalEarnings??0).toFixed(0)]})]})]})]})}),u.conversionRate&&s.jsxs("p",{className:"text-xs text-gray-500 mt-3 text-right",children:["综合转化率 ",u.conversionRate]})]})}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(De,{className:"bg-orange-500/10 border-orange-500/30",children:s.jsx(_e,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Vg,{className:"w-5 h-5 text-orange-400 shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-orange-300 font-medium text-sm",children:"即将过期绑定"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[u.expiringBindings," ",s.jsx("span",{className:"text-sm font-normal text-orange-300/60",children:"个 · 7天内"})]})]})]})})}),s.jsx(De,{className:"bg-blue-500/10 border-blue-500/30",children:s.jsx(_e,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(sd,{className:"w-5 h-5 text-blue-400 shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-blue-300 font-medium text-sm",children:"待审核提现"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[u.pendingWithdrawals," ",s.jsxs("span",{className:"text-sm font-normal text-blue-300/60",children:["笔 · ¥",(u.pendingWithdrawAmount??0).toFixed(0)]})]})]}),s.jsx(G,{onClick:()=>r("withdrawals"),variant:"outline",size:"sm",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20 shrink-0",children:"去审核"})]})})})]}),s.jsx(De,{className:"bg-emerald-500/10 border-emerald-500/30",children:s.jsxs(_e,{className:"p-4 flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-emerald-300 font-medium text-sm",children:"获客线索(存客宝)"}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"留资列表、推送状态与重试已统一至「用户管理 → 获客列表」,避免与推广中心重复维护。"})]}),s.jsx(_i,{to:"/users?tab=leads",className:"shrink-0",children:s.jsx(G,{type:"button",variant:"outline",size:"sm",className:"border-emerald-500/50 text-emerald-400 hover:bg-emerald-500/15 bg-transparent",children:"打开获客列表"})})]})}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(_e,{className:"p-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-white/5",children:[s.jsx(qn,{className:"w-5 h-5 text-gray-400 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-lg font-bold text-white",children:u.totalDistributors}),s.jsx("p",{className:"text-[10px] text-gray-500",children:"推广用户"})]})]}),s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-white/5",children:[s.jsx($x,{className:"w-5 h-5 text-green-400 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-lg font-bold text-green-400",children:u.activeDistributors}),s.jsx("p",{className:"text-[10px] text-gray-500",children:"有收益用户"})]})]})]})})})]}),n==="orders"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2 mb-2",children:[s.jsx("button",{type:"button",className:`px-3 py-1.5 rounded-md text-xs font-medium transition-all ${a==="orders"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,onClick:()=>i("orders"),children:"普通订单"}),s.jsxs("button",{type:"button",className:`px-3 py-1.5 rounded-md text-xs font-medium transition-all ${a==="giftpay"?"bg-amber-500/20 text-amber-400 border border-amber-500/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,onClick:()=>{i("giftpay"),qt("giftPay",!0)},children:[s.jsx(Hg,{className:"w-3 h-3 inline mr-1"}),"代付请求"]})]}),a==="orders"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[s.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[s.jsx(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:L,onChange:H=>R(H.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:U,onChange:H=>P(H.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"pending",children:"待支付"}),s.jsx("option",{value:"failed",children:"已失败"}),s.jsx("option",{value:"refunded",children:"已退款"})]}),s.jsxs(G,{type:"button",variant:"outline",onClick:()=>void bn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-0",children:[o.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无订单数据"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"订单号"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"商品"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"支付方式"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"退款原因"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"推荐人/邀请码"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"分销佣金"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"下单时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:$t.map(H=>{var Qe,vt;return s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsxs("td",{className:"p-4 font-mono text-xs text-gray-400",children:[(Qe=H.id)==null?void 0:Qe.slice(0,12),"..."]}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:H.userNickname}),s.jsx("p",{className:"text-gray-500 text-xs",children:H.userPhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:(()=>{const Ft=H.productType||H.type,yt=H.description||"",ht=String(H.productId||H.sectionId||""),Pt=Ft==="vip"||yt.includes("VIP")||yt.toLowerCase().includes("vip")||ht.toLowerCase().includes("vip");return Ft==="balance_recharge"?`余额充值 ¥${typeof H.amount=="number"?H.amount.toFixed(2):parseFloat(String(H.amount||"0")).toFixed(2)}`:Pt?"超级个体开通费用":Ft==="fullbook"?`${H.bookName||"《底层逻辑》"} - 全本`:Ft==="match"?"匹配次数购买":`${H.bookName||"《底层逻辑》"} - ${H.sectionTitle||H.chapterTitle||`章节${H.productId||H.sectionId||""}`}`})()}),s.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const Ft=H.productType||H.type,yt=H.description||"",ht=String(H.productId||H.sectionId||""),Pt=Ft==="vip"||yt.includes("VIP")||yt.toLowerCase().includes("vip")||ht.toLowerCase().includes("vip");return Ft==="balance_recharge"?"余额充值":Pt?"超级个体":Ft==="fullbook"?"全书解锁":Ft==="match"?"功能权益":H.chapterTitle||"单章购买"})()})]})}),s.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof H.amount=="number"?H.amount.toFixed(2):parseFloat(String(H.amount||"0")).toFixed(2)]}),s.jsx("td",{className:"p-4 text-gray-300",children:H.paymentMethod==="wechat"?"微信支付":H.paymentMethod==="balance"?"余额支付":H.paymentMethod==="alipay"?"支付宝":H.paymentMethod||"微信支付"}),s.jsx("td",{className:"p-4",children:H.status==="refunded"?s.jsx(Be,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):H.status==="completed"||H.status==="paid"?s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):H.status==="pending"||H.status==="created"?s.jsx(Be,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):s.jsx(Be,{className:"bg-red-500/20 text-red-400 border-0",children:"已失败"})}),s.jsx("td",{className:"p-4 text-gray-400 text-sm max-w-[120px]",title:H.refundReason,children:H.status==="refunded"&&H.refundReason?H.refundReason:"-"}),s.jsx("td",{className:"p-4 text-gray-300 text-sm",children:H.referrerId||H.referralCode?s.jsxs("span",{title:H.referralCode||H.referrerCode||H.referrerId||"",children:[H.referrerNickname||H.referralCode||H.referrerCode||((vt=H.referrerId)==null?void 0:vt.slice(0,8)),(H.referralCode||H.referrerCode)&&` (${H.referralCode||H.referrerCode})`]}):"-"}),s.jsx("td",{className:"p-4 text-[#FFD700]",children:H.referrerEarnings?`¥${(typeof H.referrerEarnings=="number"?H.referrerEarnings:parseFloat(String(H.referrerEarnings))).toFixed(2)}`:"-"}),s.jsx("td",{className:"p-4 text-gray-400 text-sm",children:H.createdAt?new Date(H.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:(H.status==="paid"||H.status==="completed")&&s.jsxs(G,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{Y(H),xe("")},children:[s.jsx(lk,{className:"w-3 h-3 mr-1"}),"退款"]})})]},H.id)})})]})}),n==="orders"&&s.jsx(xs,{page:F,totalPages:rt,total:D,pageSize:Q,onPageChange:O,onPageSizeChange:H=>{re(H),O(1)}})]})})]}),a==="giftpay"&&s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(dt,{children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[s.jsx(ut,{className:"text-white text-base",children:"代付请求列表"}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsxs("select",{className:"bg-[#0a1628] border border-gray-700 text-white rounded px-3 py-1.5 text-sm",value:fn,onChange:H=>{Vn(H.target.value),jn(1)},children:[s.jsx("option",{value:"",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待支付(旧)"}),s.jsx("option",{value:"pending_pay",children:"待发起人支付"}),s.jsx("option",{value:"paid",children:"已支付"}),s.jsx("option",{value:"refunded",children:"已退款"}),s.jsx("option",{value:"cancelled",children:"已取消"}),s.jsx("option",{value:"expired",children:"已过期"})]}),s.jsxs(G,{size:"sm",variant:"outline",onClick:()=>void qt("giftPay",!0),disabled:v,className:"border-gray-600 text-gray-300",children:[s.jsx(Ve,{className:`w-3.5 h-3.5 mr-1 ${v?"animate-spin":""}`}),"刷新"]})]})]})}),s.jsxs(_e,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-700/50",children:[s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"请求号"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"发起人"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"商品/金额"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"份数/已领"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"付款人"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"状态"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"创建时间"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:Fe.map(H=>s.jsxs("tr",{className:"hover:bg-[#0a1628]",children:[s.jsx("td",{className:"p-3 font-mono text-xs text-gray-400",children:H.requestSn}),s.jsx("td",{className:"p-3 text-white text-sm",children:H.initiatorNick||H.initiatorUserId}),s.jsxs("td",{className:"p-3",children:[s.jsxs("p",{className:"text-white",children:[H.productType," · ¥",H.amount.toFixed(2)]}),H.description&&s.jsx("p",{className:"text-gray-500 text-xs",children:H.description})]}),s.jsx("td",{className:"p-3 text-gray-400",children:(H.quantity??1)>1?`${H.quantity}份 / 已领${H.redeemedCount??0}`:"-"}),s.jsx("td",{className:"p-3 text-gray-400",children:H.payerNick||(H.payerUserId?H.payerUserId:"-")}),s.jsx("td",{className:"p-3",children:s.jsx(Be,{className:H.status==="paid"?"bg-green-500/20 text-green-400 border-0":H.status==="pending"||H.status==="pending_pay"?"bg-amber-500/20 text-amber-400 border-0":H.status==="refunded"?"bg-red-500/20 text-red-400 border-0":"bg-gray-500/20 text-gray-400 border-0",children:H.status==="paid"?"已支付":H.status==="pending"||H.status==="pending_pay"?"待支付":H.status==="refunded"?"已退款":H.status==="cancelled"?"已取消":"已过期"})}),s.jsx("td",{className:"p-3 text-gray-400 text-xs",children:H.createdAt?new Date(H.createdAt).toLocaleString("zh-CN"):"-"})]},H.id))})]})}),Fe.length===0&&!v&&s.jsx("p",{className:"text-center py-8 text-gray-500",children:"暂无代付请求"}),pt>20&&s.jsx("div",{className:"mt-4 flex justify-center",children:s.jsx(xs,{page:wt,totalPages:Math.ceil(pt/20),total:pt,pageSize:20,onPageChange:jn,onPageSizeChange:()=>{}})})]})]})]}),n==="bindings"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[s.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[s.jsx(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:L,onChange:H=>R(H.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:U,onChange:H=>P(H.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"active",children:"有效"}),s.jsx("option",{value:"converted",children:"已转化"}),s.jsx("option",{value:"expired",children:"已过期"})]}),s.jsxs(G,{type:"button",variant:"outline",onClick:()=>void bn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-0",children:[St.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无绑定数据"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"访客"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"分销商"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"绑定时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"到期时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"佣金"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:St.map(H=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:H.refereeNickname||"匿名用户"}),s.jsx("p",{className:"text-gray-500 text-xs",children:H.refereePhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:H.referrerName||"-"}),s.jsx("p",{className:"text-gray-500 text-xs font-mono",children:H.referrerCode})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:H.boundAt?new Date(H.boundAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:H.expiresAt?new Date(H.expiresAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:We(H.status)}),s.jsx("td",{className:"p-4",children:H.commission?s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",H.commission.toFixed(2)]}):s.jsx("span",{className:"text-gray-500",children:"-"})})]},H.id))})]})}),n==="bindings"&&s.jsx(xs,{page:F,totalPages:rt,total:D,pageSize:Q,onPageChange:O,onPageSizeChange:H=>{re(H),O(1)}})]})})]}),n==="withdrawals"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[s.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[s.jsx(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:L,onChange:H=>R(H.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:U,onChange:H=>P(H.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待审核"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"rejected",children:"已拒绝"})]}),s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[#0f2137] border border-gray-700/50 shrink-0",children:[s.jsx(Ho,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-sm text-gray-300",children:"自动审批"}),s.jsx(Kt,{checked:$,onCheckedChange:vn,disabled:ae,className:"data-[state=checked]:bg-[#38bdac]"})]}),s.jsxs(G,{type:"button",variant:"outline",onClick:()=>void bn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-0",children:[$e.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无提现记录"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"申请人"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"收款方式"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"收款账号"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"备注"}),s.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:$e.map(H=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[H.userAvatar?s.jsx("img",{src:H.userAvatar,alt:"",className:"w-8 h-8 rounded-full object-cover"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-600 flex items-center justify-center text-white text-sm font-medium",children:(H.userName||H.name||"?").slice(0,1)}),s.jsx("p",{className:"text-white font-medium",children:H.userName||H.name})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",H.amount.toFixed(2)]})}),s.jsx("td",{className:"p-4",children:s.jsx(Be,{className:H.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:H.method==="wechat"?"微信":"支付宝"})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-mono text-xs",children:H.account}),s.jsx("p",{className:"text-gray-500 text-xs",children:H.name})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:H.createdAt?new Date(H.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:We(H.status)}),s.jsx("td",{className:"p-4 max-w-[160px]",children:s.jsx("span",{className:`text-xs ${H.status==="rejected"||H.status==="failed"?"text-red-400":"text-gray-400"}`,title:H.remark,children:H.remark||"-"})}),s.jsx("td",{className:"p-4 text-right",children:H.status==="pending"&&s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsxs(G,{size:"sm",onClick:()=>Mn(H.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx($x,{className:"w-4 h-4 mr-1"}),"通过"]}),s.jsxs(G,{size:"sm",variant:"outline",onClick:()=>Hn(H.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[s.jsx(tk,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},H.id))})]})}),n==="withdrawals"&&s.jsx(xs,{page:F,totalPages:rt,total:D,pageSize:Q,onPageChange:O,onPageSizeChange:H=>{re(H),O(1)}})]})})]})]}),s.jsx(Lt,{open:!!I,onOpenChange:H=>!H&&Y(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:"订单退款"})}),I&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",I.orderSn||I.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof I.amount=="number"?I.amount.toFixed(2):parseFloat(String(I.amount||"0")).toFixed(2)]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:B,onChange:H=>xe(H.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>Y(null),disabled:X,children:"取消"}),s.jsx(G,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:Me,disabled:X,children:X?"退款中...":"确认退款"})]})]})}),s.jsx(Lt,{open:!!W,onOpenChange:H=>!H&&Ne(),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:"拒绝提现"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:he,onChange:H=>de(H.target.value)})})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:Ne,disabled:_,children:"取消"}),s.jsx(G,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:as,disabled:_||!he.trim(),children:_?"提交中...":"确认拒绝"})]})]})}),n==="settings"&&s.jsx("div",{className:"-mx-8 -mt-6",children:s.jsx(W2,{embedded:!0})})]})}function K8(){const[t,e]=g.useState([]),[n,r]=g.useState({total:0,pendingCount:0,pendingAmount:0,successCount:0,successAmount:0,failedCount:0}),[a,i]=g.useState(!0),[o,c]=g.useState(null),[u,h]=g.useState("all"),[f,m]=g.useState(1),[x,b]=g.useState(10),[N,w]=g.useState(0),[v,k]=g.useState(null),[T,C]=g.useState(null),[L,R]=g.useState(""),[U,P]=g.useState(!1);async function F(){var I,Y,B,xe,X,V,W;i(!0),c(null);try{const fe=new URLSearchParams({status:u,page:String(f),pageSize:String(x)}),he=await Le(`/api/admin/withdrawals?${fe}`);if(he!=null&&he.success){const de=he.withdrawals||[];e(de),w(he.total??((I=he.stats)==null?void 0:I.total)??de.length),r({total:((Y=he.stats)==null?void 0:Y.total)??he.total??de.length,pendingCount:((B=he.stats)==null?void 0:B.pendingCount)??0,pendingAmount:((xe=he.stats)==null?void 0:xe.pendingAmount)??0,successCount:((X=he.stats)==null?void 0:X.successCount)??0,successAmount:((V=he.stats)==null?void 0:V.successAmount)??0,failedCount:((W=he.stats)==null?void 0:W.failedCount)??0})}else c("加载提现记录失败")}catch(fe){console.error("Load withdrawals error:",fe),c("加载失败,请检查网络后重试")}finally{i(!1)}}g.useEffect(()=>{m(1)},[u]),g.useEffect(()=>{F()},[u,f,x]);const O=Math.ceil(N/x)||1;async function Q(I){const Y=t.find(B=>B.id===I);if(Y!=null&&Y.userCommissionInfo&&Y.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${Y.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。
-确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;k(I);try{const F=await tn("/api/admin/withdrawals",{id:I,action:"approve"});F!=null&&F.success?z():q.error("操作失败: "+((F==null?void 0:F.error)??""))}catch{q.error("操作失败")}finally{k(null)}}async function re(I){if(confirm("确认撤回该笔打款?仅在用户未确认收款前可撤回。")){k(I);try{const Y=await bt("/api/admin/withdrawals/cancel",{id:I});Y!=null&&Y.success?(q.success("已撤回打款"),z()):q.error("撤回失败: "+((Y==null?void 0:Y.error)??"未知错误"))}catch{q.error("撤回失败")}finally{k(null)}}}function D(I){C(I),R("")}async function ne(){const I=T;if(!I)return;const Y=L.trim();if(!Y){q.error("请填写拒绝原因");return}P(!0);try{const F=await tn("/api/admin/withdrawals",{id:I,action:"reject",errorMessage:Y});F!=null&&F.success?(q.success("已拒绝该提现申请"),C(null),R(""),z()):q.error("操作失败: "+((F==null?void 0:F.error)??""))}catch{q.error("操作失败")}finally{P(!1)}}function le(){T&&q.info("已取消操作"),C(null),R("")}function me(I){switch(I){case"pending":return s.jsx(Be,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return s.jsx(Be,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return s.jsx(Be,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return s.jsx(Be,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return s.jsx(Be,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return s.jsx(Be,{className:"bg-gray-500/20 text-gray-400 border-0",children:I})}}return s.jsxs("div",{className:"p-8 w-full",children:[o&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[s.jsx("span",{children:o}),s.jsx("button",{type:"button",onClick:()=>c(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-start mb-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"分账提现管理"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"管理用户分销收益的提现申请"})]}),s.jsxs(G,{variant:"outline",onClick:z,disabled:a,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"刷新"]})]}),s.jsx(De,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:s.jsx(_e,{className:"p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Rf,{className:"w-5 h-5 text-[#38bdac] mt-0.5"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white font-medium mb-2",children:"自动分账规则"}),s.jsxs("div",{className:"text-sm text-gray-400 space-y-1",children:[s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"分销比例"}),":推广者获得订单金额的"," ",s.jsx("span",{className:"text-white font-medium",children:"90%"})]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"结算方式"}),":用户付款后,分销收益自动计入推广者账户"]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"提现方式"}),":用户在小程序端点击提现,系统自动转账到微信零钱"]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"审批流程"}),":待处理的提现需管理员手动确认打款后批准(自动审批开关在推广中心-提现审核)"]})]})]})]})})}),s.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-[#38bdac]",children:n.total}),s.jsx("div",{className:"text-sm text-gray-400",children:"总申请"})]})}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-orange-400",children:n.pendingCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"待处理"}),s.jsxs("div",{className:"text-xs text-orange-400 mt-1",children:["¥",n.pendingAmount.toFixed(2)]})]})}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-green-400",children:n.successCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"已完成"}),s.jsxs("div",{className:"text-xs text-green-400 mt-1",children:["¥",n.successAmount.toFixed(2)]})]})}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-red-400",children:n.failedCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"已拒绝"})]})})]}),s.jsx("div",{className:"flex gap-2 mb-4",children:["all","pending","processing","pending_confirm","success","failed"].map(I=>s.jsx(G,{variant:u===I?"default":"outline",size:"sm",onClick:()=>h(I),className:u===I?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:I==="all"?"全部":I==="pending"?"待处理":I==="processing"?"处理中":I==="pending_confirm"?"待确认收款":I==="success"?"已完成":"已拒绝"},I))}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(_e,{className:"p-0",children:a?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):t.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx(sd,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无提现记录"})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"提现金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户佣金信息"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"备注"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"处理时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"确认收款"}),s.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:t.map(I=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4 text-gray-400",children:new Date(I.createdAt??"").toLocaleString()}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[I.userAvatar?s.jsx("img",{src:ya(I.userAvatar),alt:I.userName??"",className:"w-8 h-8 rounded-full object-cover"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:(I.userName??"?").charAt(0)}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:I.userName??"未知"}),s.jsx("p",{className:"text-xs text-gray-500",children:I.userPhone??I.referralCode??(I.userId??"").slice(0,10)})]})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(I.amount).toFixed(2)]})}),s.jsx("td",{className:"p-4",children:I.userCommissionInfo?s.jsxs("div",{className:"text-xs space-y-1",children:[s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"累计佣金:"}),s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",I.userCommissionInfo.totalCommission.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"已提现:"}),s.jsxs("span",{className:"text-gray-400",children:["¥",I.userCommissionInfo.withdrawnEarnings.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"待审核:"}),s.jsxs("span",{className:"text-orange-400",children:["¥",I.userCommissionInfo.pendingWithdrawals.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4 pt-1 border-t border-gray-700/30",children:[s.jsx("span",{className:"text-gray-500",children:"审核后余额:"}),s.jsxs("span",{className:I.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",I.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):s.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),s.jsx("td",{className:"p-4",children:me(I.status)}),s.jsx("td",{className:"p-4 max-w-[180px]",children:s.jsx("span",{className:`text-xs ${I.status==="rejected"||I.status==="failed"?"text-red-400":"text-gray-400"}`,title:I.remark,children:I.remark||"-"})}),s.jsx("td",{className:"p-4 text-gray-400",children:I.processedAt?new Date(I.processedAt).toLocaleString():"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:I.userConfirmedAt?s.jsxs("span",{className:"text-green-400",title:I.userConfirmedAt,children:["已确认 ",new Date(I.userConfirmedAt).toLocaleString()]}):"-"}),s.jsxs("td",{className:"p-4 text-right",children:[(I.status==="pending"||I.status==="pending_confirm")&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(G,{size:"sm",onClick:()=>Q(I.id),disabled:v===I.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[s.jsx(_p,{className:"w-4 h-4 mr-1"}),"批准"]}),s.jsxs(G,{size:"sm",variant:"outline",onClick:()=>D(I.id),disabled:v===I.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(ns,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(I.status==="processing"||I.status==="pending_confirm")&&s.jsx("div",{className:"mt-2 flex items-center justify-end gap-2",children:s.jsx(G,{size:"sm",variant:"outline",onClick:()=>re(I.id),disabled:v===I.id,className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:"撤回打款"})}),(I.status==="success"||I.status==="completed")&&I.transactionId&&s.jsx("span",{className:"text-xs text-gray-500 font-mono",children:I.transactionId})]})]},I.id))})]})}),s.jsx(xs,{page:f,totalPages:O,total:N,pageSize:x,onPageChange:m,onPageSizeChange:I=>{b(I),m(1)}})]})})}),s.jsx(Lt,{open:!!T,onOpenChange:I=>!I&&le(),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:"拒绝提现"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:L,onChange:I=>R(I.target.value)})})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:le,disabled:U,children:"取消"}),s.jsx(G,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:ne,disabled:U||!L.trim(),children:U?"提交中...":"确认拒绝"})]})]})})]})}var Yx={exports:{}},Xx={};/**
+确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;k(I);try{const B=await tn("/api/admin/withdrawals",{id:I,action:"approve"});B!=null&&B.success?F():q.error("操作失败: "+((B==null?void 0:B.error)??""))}catch{q.error("操作失败")}finally{k(null)}}async function re(I){if(confirm("确认撤回该笔打款?仅在用户未确认收款前可撤回。")){k(I);try{const Y=await bt("/api/admin/withdrawals/cancel",{id:I});Y!=null&&Y.success?(q.success("已撤回打款"),F()):q.error("撤回失败: "+((Y==null?void 0:Y.error)??"未知错误"))}catch{q.error("撤回失败")}finally{k(null)}}}function D(I){C(I),R("")}async function ne(){const I=T;if(!I)return;const Y=L.trim();if(!Y){q.error("请填写拒绝原因");return}P(!0);try{const B=await tn("/api/admin/withdrawals",{id:I,action:"reject",errorMessage:Y});B!=null&&B.success?(q.success("已拒绝该提现申请"),C(null),R(""),F()):q.error("操作失败: "+((B==null?void 0:B.error)??""))}catch{q.error("操作失败")}finally{P(!1)}}function le(){T&&q.info("已取消操作"),C(null),R("")}function me(I){switch(I){case"pending":return s.jsx(Be,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return s.jsx(Be,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return s.jsx(Be,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return s.jsx(Be,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return s.jsx(Be,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return s.jsx(Be,{className:"bg-gray-500/20 text-gray-400 border-0",children:I})}}return s.jsxs("div",{className:"p-8 w-full",children:[o&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[s.jsx("span",{children:o}),s.jsx("button",{type:"button",onClick:()=>c(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-start mb-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"分账提现管理"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"管理用户分销收益的提现申请"})]}),s.jsxs(G,{variant:"outline",onClick:F,disabled:a,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"刷新"]})]}),s.jsx(De,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:s.jsx(_e,{className:"p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Rf,{className:"w-5 h-5 text-[#38bdac] mt-0.5"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white font-medium mb-2",children:"自动分账规则"}),s.jsxs("div",{className:"text-sm text-gray-400 space-y-1",children:[s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"分销比例"}),":推广者获得订单金额的"," ",s.jsx("span",{className:"text-white font-medium",children:"90%"})]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"结算方式"}),":用户付款后,分销收益自动计入推广者账户"]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"提现方式"}),":用户在小程序端点击提现,系统自动转账到微信零钱"]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"审批流程"}),":待处理的提现需管理员手动确认打款后批准(自动审批开关在推广中心-提现审核)"]})]})]})]})})}),s.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-[#38bdac]",children:n.total}),s.jsx("div",{className:"text-sm text-gray-400",children:"总申请"})]})}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-orange-400",children:n.pendingCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"待处理"}),s.jsxs("div",{className:"text-xs text-orange-400 mt-1",children:["¥",n.pendingAmount.toFixed(2)]})]})}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-green-400",children:n.successCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"已完成"}),s.jsxs("div",{className:"text-xs text-green-400 mt-1",children:["¥",n.successAmount.toFixed(2)]})]})}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-red-400",children:n.failedCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"已拒绝"})]})})]}),s.jsx("div",{className:"flex gap-2 mb-4",children:["all","pending","processing","pending_confirm","success","failed"].map(I=>s.jsx(G,{variant:u===I?"default":"outline",size:"sm",onClick:()=>h(I),className:u===I?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:I==="all"?"全部":I==="pending"?"待处理":I==="processing"?"处理中":I==="pending_confirm"?"待确认收款":I==="success"?"已完成":"已拒绝"},I))}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(_e,{className:"p-0",children:a?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):t.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx(sd,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无提现记录"})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"提现金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户佣金信息"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"备注"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"处理时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"确认收款"}),s.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:t.map(I=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4 text-gray-400",children:new Date(I.createdAt??"").toLocaleString()}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[I.userAvatar?s.jsx("img",{src:ya(I.userAvatar),alt:I.userName??"",className:"w-8 h-8 rounded-full object-cover"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:(I.userName??"?").charAt(0)}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:I.userName??"未知"}),s.jsx("p",{className:"text-xs text-gray-500",children:I.userPhone??I.referralCode??(I.userId??"").slice(0,10)})]})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(I.amount).toFixed(2)]})}),s.jsx("td",{className:"p-4",children:I.userCommissionInfo?s.jsxs("div",{className:"text-xs space-y-1",children:[s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"累计佣金:"}),s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",I.userCommissionInfo.totalCommission.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"已提现:"}),s.jsxs("span",{className:"text-gray-400",children:["¥",I.userCommissionInfo.withdrawnEarnings.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"待审核:"}),s.jsxs("span",{className:"text-orange-400",children:["¥",I.userCommissionInfo.pendingWithdrawals.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4 pt-1 border-t border-gray-700/30",children:[s.jsx("span",{className:"text-gray-500",children:"审核后余额:"}),s.jsxs("span",{className:I.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",I.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):s.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),s.jsx("td",{className:"p-4",children:me(I.status)}),s.jsx("td",{className:"p-4 max-w-[180px]",children:s.jsx("span",{className:`text-xs ${I.status==="rejected"||I.status==="failed"?"text-red-400":"text-gray-400"}`,title:I.remark,children:I.remark||"-"})}),s.jsx("td",{className:"p-4 text-gray-400",children:I.processedAt?new Date(I.processedAt).toLocaleString():"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:I.userConfirmedAt?s.jsxs("span",{className:"text-green-400",title:I.userConfirmedAt,children:["已确认 ",new Date(I.userConfirmedAt).toLocaleString()]}):"-"}),s.jsxs("td",{className:"p-4 text-right",children:[(I.status==="pending"||I.status==="pending_confirm")&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(G,{size:"sm",onClick:()=>Q(I.id),disabled:v===I.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[s.jsx(_p,{className:"w-4 h-4 mr-1"}),"批准"]}),s.jsxs(G,{size:"sm",variant:"outline",onClick:()=>D(I.id),disabled:v===I.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(ss,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(I.status==="processing"||I.status==="pending_confirm")&&s.jsx("div",{className:"mt-2 flex items-center justify-end gap-2",children:s.jsx(G,{size:"sm",variant:"outline",onClick:()=>re(I.id),disabled:v===I.id,className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:"撤回打款"})}),(I.status==="success"||I.status==="completed")&&I.transactionId&&s.jsx("span",{className:"text-xs text-gray-500 font-mono",children:I.transactionId})]})]},I.id))})]})}),s.jsx(xs,{page:f,totalPages:O,total:N,pageSize:x,onPageChange:m,onPageSizeChange:I=>{b(I),m(1)}})]})})}),s.jsx(Lt,{open:!!T,onOpenChange:I=>!I&&le(),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:"拒绝提现"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:L,onChange:I=>R(I.target.value)})})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:le,disabled:U,children:"取消"}),s.jsx(G,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:ne,disabled:U||!L.trim(),children:U?"提交中...":"确认拒绝"})]})]})})]})}var Yx={exports:{}},Xx={};/**
* @license React
* use-sync-external-store-shim.production.js
*
@@ -703,16 +703,16 @@ For more information, see https://radix-ui.com/primitives/docs/components/${e.do
*/var hN;function q8(){if(hN)return Xx;hN=1;var t=Wu();function e(m,x){return m===x&&(m!==0||1/m===1/x)||m!==m&&x!==x}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,a=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function c(m,x){var b=x(),N=r({inst:{value:b,getSnapshot:x}}),w=N[0].inst,v=N[1];return i(function(){w.value=b,w.getSnapshot=x,u(w)&&v({inst:w})},[m,b,x]),a(function(){return u(w)&&v({inst:w}),m(function(){u(w)&&v({inst:w})})},[m]),o(b),b}function u(m){var x=m.getSnapshot;m=m.value;try{var b=x();return!n(m,b)}catch{return!0}}function h(m,x){return x()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return Xx.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,Xx}var fN;function K2(){return fN||(fN=1,Yx.exports=q8()),Yx.exports}var q2=K2();function ks(t){this.content=t}ks.prototype={constructor:ks,find:function(t){for(var e=0;e>1}};ks.from=function(t){if(t instanceof ks)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ks(e)};function G2(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let a=t.child(r),i=e.child(r);if(a==i){n+=a.nodeSize;continue}if(!a.sameMarkup(i))return n;if(a.isText&&a.text!=i.text){for(let o=0;a.text[o]==i.text[o];o++)n++;return n}if(a.content.size||i.content.size){let o=G2(a.content,i.content,n+1);if(o!=null)return o}n+=a.nodeSize}}function J2(t,e,n,r){for(let a=t.childCount,i=e.childCount;;){if(a==0||i==0)return a==i?null:{a:n,b:r};let o=t.child(--a),c=e.child(--i),u=o.nodeSize;if(o==c){n-=u,r-=u;continue}if(!o.sameMarkup(c))return{a:n,b:r};if(o.isText&&o.text!=c.text){let h=0,f=Math.min(o.text.length,c.text.length);for(;he&&r(u,a+c,i||null,o)!==!1&&u.content.size){let f=c+1;u.nodesBetween(Math.max(0,e-f),Math.min(u.content.size,n-f),r,a+f)}c=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,a){let i="",o=!0;return this.nodesBetween(e,n,(c,u)=>{let h=c.isText?c.text.slice(Math.max(e,u)-u,n-u):c.isLeaf?a?typeof a=="function"?a(c):a:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&h||c.isTextblock)&&r&&(o?o=!1:i+=r),i+=h},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,a=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(a[a.length-1]=n.withText(n.text+r.text),i=1);ie)for(let i=0,o=0;oe&&((on)&&(c.isText?c=c.cut(Math.max(0,e-o),Math.min(c.text.length,n-o)):c=c.cut(Math.max(0,e-o-1),Math.min(c.content.size,n-o-1))),r.push(c),a+=c.nodeSize),o=u}return new Ce(r,a)}cutByIndex(e,n){return e==n?Ce.empty:e==0&&n==this.content.length?this:new Ce(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let a=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return a[e]=n,new Ce(a,i)}addToStart(e){return new Ce([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Ce(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let a=this.child(n),i=r+a.nodeSize;if(i>=e)return i==e?rf(n+1,i):rf(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return Ce.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Ce(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Ce.empty;let n,r=0;for(let a=0;athis.type.rank&&(n||(n=e.slice(0,a)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-a.type.rank),n}};ln.none=[];class Vf extends Error{}class ze{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Y2(this.content,e+this.openStart,n);return r&&new ze(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ze(Q2(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ze.empty;let r=n.openStart||0,a=n.openEnd||0;if(typeof r!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ze(Ce.fromJSON(e,n.content),r,a)}static maxOpen(e,n=!0){let r=0,a=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)a++;return new ze(e,r,a)}}ze.empty=new ze(Ce.empty,0,0);function Q2(t,e,n){let{index:r,offset:a}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:c}=t.findIndex(n);if(a==e||i.isText){if(c!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Q2(i.content,e-a-1,n-a-1)))}function Y2(t,e,n,r){let{index:a,offset:i}=t.findIndex(e),o=t.maybeChild(a);if(i==e||o.isText)return r&&!r.canReplace(a,a,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=Y2(o.content,e-i-1,n,o);return c&&t.replaceChild(a,o.copy(c))}function G8(t,e,n){if(n.openStart>t.depth)throw new Vf("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Vf("Inconsistent open depths");return X2(t,e,n,0)}function X2(t,e,n,r){let a=t.index(r),i=t.node(r);if(a==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function gu(t,e,n,r){let a=(e||t).node(n),i=0,o=e?e.index(n):a.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Dl(t.nodeAfter,r),i++));for(let c=i;ca&&n0(t,e,a+1),o=r.depth>a&&n0(n,r,a+1),c=[];return gu(null,t,a,c),i&&o&&e.index(a)==n.index(a)?(Z2(i,o),Dl(_l(i,eS(t,e,n,r,a+1)),c)):(i&&Dl(_l(i,Hf(t,e,a+1)),c),gu(e,n,a,c),o&&Dl(_l(o,Hf(n,r,a+1)),c)),gu(r,null,a,c),new Ce(c)}function Hf(t,e,n){let r=[];if(gu(null,t,n,r),t.depth>n){let a=n0(t,e,n+1);Dl(_l(a,Hf(t,e,n+1)),r)}return gu(e,null,n,r),new Ce(r)}function J8(t,e){let n=e.depth-t.openStart,a=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)a=e.node(i).copy(Ce.from(a));return{start:a.resolveNoCache(t.openStart+n),end:a.resolveNoCache(a.content.size-t.openEnd-n)}}class Iu{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],a=e.child(n);return r?e.child(n).cut(r):a}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],a=n==0?0:this.path[n*3-1]+1;for(let i=0;i0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Uf(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],a=0,i=n;for(let o=e;;){let{index:c,offset:u}=o.content.findIndex(i),h=i-u;if(r.push(o,c,a+u),!h||(o=o.child(c),o.isText))break;i=h-1,a+=u+1}return new Iu(n,r,i)}static resolveCached(e,n){let r=pN.get(e);if(r)for(let i=0;ie&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(a=!0),!a)),a}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),tS(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=Ce.empty,a=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,a,i),c=o&&o.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let u=a;un.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let a=Ce.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,a,r);return i.type.checkAttrs(i.attrs),i}};$i.prototype.text=void 0;class Wf extends $i{constructor(e,n,r,a){if(super(e,n,null,a),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):tS(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Wf(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Wf(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function tS(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Kl{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Z8(e,n);if(r.next==null)return Kl.empty;let a=nS(r);r.next&&r.err("Unexpected trailing text");let i=i6(a6(a));return o6(i,r),i}matchType(e){for(let n=0;nh.createAndFill()));for(let h=0;h=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let a=0;a{let i=a+(r.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(r.next[o].next);return i}).join(`
`)}}Kl.empty=new Kl(!0);class Z8{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function nS(t){let e=[];do e.push(e6(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function e6(t){let e=[];do e.push(t6(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function t6(t){let e=r6(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=n6(t,e);else break;return e}function mN(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function n6(t,e){let n=mN(t),r=n;return t.eat(",")&&(t.next!="}"?r=mN(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function s6(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let a=[];for(let i in n){let o=n[i];o.isInGroup(e)&&a.push(o)}return a.length==0&&t.err("No node type or group '"+e+"' found"),a}function r6(t){if(t.eat("(")){let e=nS(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=s6(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function a6(t){let e=[[]];return a(i(t,0),n()),e;function n(){return e.push([])-1}function r(o,c,u){let h={term:u,to:c};return e[o].push(h),h}function a(o,c){o.forEach(u=>u.to=c)}function i(o,c){if(o.type=="choice")return o.exprs.reduce((u,h)=>u.concat(i(h,c)),[]);if(o.type=="seq")for(let u=0;;u++){let h=i(o.exprs[u],c);if(u==o.exprs.length-1)return h;a(h,c=n())}else if(o.type=="star"){let u=n();return r(c,u),a(i(o.expr,u),u),[r(u)]}else if(o.type=="plus"){let u=n();return a(i(o.expr,c),u),a(i(o.expr,u),u),[r(u)]}else{if(o.type=="opt")return[r(c)].concat(i(o.expr,c));if(o.type=="range"){let u=c;for(let h=0;h{t[o].forEach(({term:c,to:u})=>{if(!c)return;let h;for(let f=0;f{h||a.push([c,h=[]]),h.indexOf(f)==-1&&h.push(f)})})});let i=e[r.join(",")]=new Kl(r.indexOf(t.length-1)>-1);for(let o=0;o-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:aS(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new $i(this,this.computeAttrs(e),Ce.from(n),ln.setFrom(r))}createChecked(e=null,n,r){return n=Ce.from(n),this.checkContent(n),new $i(this,this.computeAttrs(e),n,ln.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=Ce.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let a=this.contentMatch.matchFragment(n),i=a&&a.fillBefore(Ce.empty,!0);return i?new $i(this,e,n.append(i),ln.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[i]=new lS(i,n,o));let a=n.spec.topNode||"doc";if(!r[a])throw new RangeError("Schema is missing its top node type ('"+a+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function l6(t,e,n){let r=n.split("|");return a=>{let i=a===null?"null":typeof a;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class c6{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?l6(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Wp{constructor(e,n,r,a){this.name=e,this.rank=n,this.schema=r,this.spec=a,this.attrs=oS(e,a.attrs),this.excluded=null;let i=rS(this.attrs);this.instance=i?new ln(this,i):null}create(e=null){return!e&&this.instance?this.instance:new ln(this,aS(this.attrs,e))}static compile(e,n){let r=Object.create(null),a=0;return e.forEach((i,o)=>r[i]=new Wp(i,a++,n,o)),r}removeFromSet(e){for(var n=0;n-1}}class cS{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let a in e)n[a]=e[a];n.nodes=ks.from(e.nodes),n.marks=ks.from(e.marks||{}),this.nodes=gN.compile(this.spec.nodes,this),this.marks=Wp.compile(this.spec.marks,this);let r=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw new RangeError(a+" can not be both a node and a mark");let i=this.nodes[a],o=i.spec.content||"",c=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=Kl.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=c=="_"?null:c?yN(this,c.split(" ")):c==""||!i.inlineContent?[]:null}for(let a in this.marks){let i=this.marks[a],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:yN(this,o.split(" "))}this.nodeFromJSON=a=>$i.fromJSON(this,a),this.markFromJSON=a=>ln.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,a){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof gN){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,a)}text(e,n){let r=this.nodes.text;return new Wf(r,r.defaultAttrs,e,ln.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function yN(t,e){let n=[];for(let r=0;r-1)&&n.push(o=u)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function d6(t){return t.tag!=null}function u6(t){return t.style!=null}class $o{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(a=>{if(d6(a))this.tags.push(a);else if(u6(a)){let i=/[^=]*/.exec(a.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(a=>{if(!/^(ul|ol)\b/.test(a.tag)||!a.node)return!1;let i=e.nodes[a.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new vN(this,n,!1);return r.addAll(e,ln.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new vN(this,n,!0);return r.addAll(e,ln.none,n.from,n.to),ze.maxOpen(r.finish())}matchTag(e,n,r){for(let a=r?this.tags.indexOf(r)+1:0;ae.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=n))){if(o.getAttrs){let u=o.getAttrs(n);if(u===!1)continue;o.attrs=u||void 0}return o}}}static schemaRules(e){let n=[];function r(a){let i=a.priority==null?50:a.priority,o=0;for(;o{r(o=NN(o)),o.mark||o.ignore||o.clearMark||(o.mark=a)})}for(let a in e.nodes){let i=e.nodes[a].spec.parseDOM;i&&i.forEach(o=>{r(o=NN(o)),o.node||o.ignore||o.mark||(o.node=a)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new $o(e,$o.schemaRules(e)))}}const dS={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},h6={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},uS={ol:!0,ul:!0},Ru=1,r0=2,yu=4;function bN(t,e,n){return e!=null?(e?Ru:0)|(e==="full"?r0:0):t&&t.whitespace=="pre"?Ru|r0:n&~yu}class af{constructor(e,n,r,a,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=a,this.options=o,this.content=[],this.activeMarks=ln.none,this.match=i||(o&yu?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Ce.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,a;return(a=r.findWrapping(e.type))?(this.match=r,a):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ru)){let r=this.content[this.content.length-1],a;if(r&&r.isText&&(a=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-a[0].length))}}let n=Ce.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Ce.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!dS.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class vN{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let a=n.topNode,i,o=bN(null,n.preserveWhitespace,0)|(r?yu:0);a?i=new af(a.type,a.attrs,ln.none,!0,n.topMatch||a.type.contentMatch,o):r?i=new af(null,null,ln.none,!0,null,o):i=new af(e.schema.topNodeType,null,ln.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,a=this.top,i=a.options&r0?"full":this.localPreserveWS||(a.options&Ru)>0,{schema:o}=this.parser;if(i==="full"||a.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let c=r.split(/\r?\n|\r/);for(let u=0;u!u.clearMark(h)):n=n.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)c=u;else break}}return n}addElementByRule(e,n,r,a){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let u=this.enter(o,n.attrs||null,r,n.preserveWhitespace);u&&(i=!0,r=u)}else{let u=this.parser.schema.marks[n.mark];r=r.concat(u.create(n.attrs))}let c=this.top;if(o&&o.isLeaf)this.findInside(e);else if(a)this.addElement(e,r,a);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,r,!1));else{let u=e;typeof n.contentElement=="string"?u=e.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(e):n.contentElement&&(u=n.contentElement),this.findAround(e,u,!0),this.addAll(u,r),this.findAround(e,u,!1)}i&&this.sync(c)&&this.open--}addAll(e,n,r,a){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,c=a==null?null:e.childNodes[a];o!=c;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let a,i;for(let o=this.open,c=0;o>=0;o--){let u=this.nodes[o],h=u.findWrapping(e);if(h&&(!a||a.length>h.length+c)&&(a=h,i=u,!h.length))break;if(u.solid){if(r)break;c+=2}}if(!a)return null;this.sync(i);for(let o=0;o(o.type?o.type.allowsMarkType(h.type):wN(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new af(e,n,u,a,null,c)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Ru)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let a=r.length-1;a>=0;a--)e+=r[a].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,a=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(a?0:1),o=(c,u)=>{for(;c>=0;c--){let h=n[c];if(h==""){if(c==n.length-1||c==0)continue;for(;u>=i;u--)if(o(c-1,u))return!0;return!1}else{let f=u>0||u==0&&a?this.nodes[u].type:r&&u>=i?r.node(u-i).type:null;if(!f||f.name!=h&&!f.isInGroup(h))return!1;u--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function f6(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&uS.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function p6(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function NN(t){let e={};for(let n in t)e[n]=t[n];return e}function wN(t,e){let n=e.schema.nodes;for(let r in n){let a=n[r];if(!a.allowsMarkType(t))continue;let i=[],o=c=>{i.push(c);for(let u=0;u{if(i.length||o.marks.length){let c=0,u=0;for(;c=0;a--){let i=this.serializeMark(e.marks[a],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let a=this.marks[e.type.name];return a&&kf(eg(r),a(e,n),null,e.attrs)}static renderSpec(e,n,r=null,a){return kf(e,n,r,a)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new nc(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=jN(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return jN(e.marks)}}function jN(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function eg(t){return t.document||window.document}const kN=new WeakMap;function m6(t){let e=kN.get(t);return e===void 0&&kN.set(t,e=x6(t)),e}function x6(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let a=0;a-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=a.indexOf(" ");o>0&&(n=a.slice(0,o),a=a.slice(o+1));let c,u=n?t.createElementNS(n,a):t.createElement(a),h=e[1],f=1;if(h&&typeof h=="object"&&h.nodeType==null&&!Array.isArray(h)){f=2;for(let m in h)if(h[m]!=null){let x=m.indexOf(" ");x>0?u.setAttributeNS(m.slice(0,x),m.slice(x+1),h[m]):m=="style"&&u.style?u.style.cssText=h[m]:u.setAttribute(m,h[m])}}for(let m=f;mf)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:b,contentDOM:N}=kf(t,x,n,r);if(u.appendChild(b),N){if(c)throw new RangeError("Multiple content holes");c=N}}}return{dom:u,contentDOM:c}}const hS=65535,fS=Math.pow(2,16);function g6(t,e){return t+e*fS}function SN(t){return t&hS}function y6(t){return(t-(t&hS))/fS}const pS=1,mS=2,Sf=4,xS=8;class a0{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&xS)>0}get deletedBefore(){return(this.delInfo&(pS|Sf))>0}get deletedAfter(){return(this.delInfo&(mS|Sf))>0}get deletedAcross(){return(this.delInfo&Sf)>0}}class Cr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Cr.empty)return Cr.empty}recover(e){let n=0,r=SN(e);if(!this.inverted)for(let a=0;ae)break;let h=this.ranges[c+i],f=this.ranges[c+o],m=u+h;if(e<=m){let x=h?e==u?-1:e==m?1:n:n,b=u+a+(x<0?0:f);if(r)return b;let N=e==(n<0?u:m)?null:g6(c/3,e-u),w=e==u?mS:e==m?pS:Sf;return(n<0?e!=u:e!=m)&&(w|=xS),new a0(b,w,N)}a+=f-h}return r?e+a:new a0(e+a,0,null)}touches(e,n){let r=0,a=SN(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let c=0;ce)break;let h=this.ranges[c+i],f=u+h;if(e<=f&&c==a*3)return!0;r+=this.ranges[c+o]-h}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let a=0,i=0;a=0;n--){let a=e.getMirror(n);this.appendMap(e._maps[n].invert(),a!=null&&a>n?r-a-1:void 0)}}invert(){let e=new Lu;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ri&&u!o.isAtom||!c.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),a),n.openStart,n.openEnd);return qn.fromReplace(e,this.from,this.to,i)}invert(){return new ga(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Io(n.pos,r.pos,this.mark)}merge(e){return e instanceof Io&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Io(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Io(n.from,n.to,e.markFromJSON(n.mark))}}Bs.jsonID("addMark",Io);class ga extends Bs{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new ze(xy(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),e),n.openStart,n.openEnd);return qn.fromReplace(e,this.from,this.to,r)}invert(){return new Io(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ga(n.pos,r.pos,this.mark)}merge(e){return e instanceof ga&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ga(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ga(n.from,n.to,e.markFromJSON(n.mark))}}Bs.jsonID("removeMark",ga);class Ro extends Bs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return qn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return qn.fromReplace(e,this.pos,this.pos+1,new ze(Ce.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let a=0;ar.pos?null:new gs(n.pos,r.pos,a,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new gs(n.from,n.to,n.gapFrom,n.gapTo,ze.fromJSON(e,n.slice),n.insert,!!n.structure)}}Bs.jsonID("replaceAround",gs);function i0(t,e,n){let r=t.resolve(e),a=n-e,i=r.depth;for(;a>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,a--;if(a>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;a>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,a--}}return!1}function b6(t,e,n,r){let a=[],i=[],o,c;t.doc.nodesBetween(e,n,(u,h,f)=>{if(!u.isInline)return;let m=u.marks;if(!r.isInSet(m)&&f.type.allowsMarkType(r.type)){let x=Math.max(h,e),b=Math.min(h+u.nodeSize,n),N=r.addToSet(m);for(let w=0;wt.step(u)),i.forEach(u=>t.step(u))}function v6(t,e,n,r){let a=[],i=0;t.doc.nodesBetween(e,n,(o,c)=>{if(!o.isInline)return;i++;let u=null;if(r instanceof Wp){let h=o.marks,f;for(;f=r.isInSet(h);)(u||(u=[])).push(f),h=f.removeFromSet(h)}else r?r.isInSet(o.marks)&&(u=[r]):u=o.marks;if(u&&u.length){let h=Math.min(c+o.nodeSize,n);for(let f=0;ft.step(new ga(o.from,o.to,o.style)))}function gy(t,e,n,r=n.contentMatch,a=!0){let i=t.doc.nodeAt(e),o=[],c=e+1;for(let u=0;u=0;u--)t.step(o[u])}function N6(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function yd(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,a=0,i=0;;--r){let o=t.$from.node(r),c=t.$from.index(r)+a,u=t.$to.indexAfter(r)-i;if(rn;N--)w||r.index(N)>0?(w=!0,f=Ce.from(r.node(N).copy(f)),m++):u--;let x=Ce.empty,b=0;for(let N=i,w=!1;N>n;N--)w||a.after(N+1)=0;o--){if(r.size){let c=n[o].type.contentMatch.matchFragment(r);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Ce.from(n[o].type.create(n[o].attrs,r))}let a=e.start,i=e.end;t.step(new gs(a,i,a,i,new ze(r,0,0),n.length,!0))}function C6(t,e,n,r,a){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,c)=>{let u=typeof a=="function"?a(o):a;if(o.isTextblock&&!o.hasMarkup(r,u)&&E6(t.doc,t.mapping.slice(i).map(c),r)){let h=null;if(r.schema.linebreakReplacement){let b=r.whitespace=="pre",N=!!r.contentMatch.matchType(r.schema.linebreakReplacement);b&&!N?h=!1:!b&&N&&(h=!0)}h===!1&&yS(t,o,c,i),gy(t,t.mapping.slice(i).map(c,1),r,void 0,h===null);let f=t.mapping.slice(i),m=f.map(c,1),x=f.map(c+o.nodeSize,1);return t.step(new gs(m,x,m+1,x-1,new ze(Ce.from(r.create(u,null,o.marks)),0,0),1,!0)),h===!0&&gS(t,o,c,i),!1}})}function gS(t,e,n,r){e.forEach((a,i)=>{if(a.isText){let o,c=/\r?\n|\r/g;for(;o=c.exec(a.text);){let u=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function yS(t,e,n,r){e.forEach((a,i)=>{if(a.type==a.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
-`))}})}function E6(t,e,n){let r=t.resolve(e),a=r.index();return r.parent.canReplaceWith(a,a+1,n)}function T6(t,e,n,r,a){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,a||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new gs(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new ze(Ce.from(o),0,0),1,!0))}function zi(t,e,n=1,r){let a=t.resolve(e),i=a.depth-n,o=r&&r[r.length-1]||a.parent;if(i<0||a.parent.type.spec.isolating||!a.parent.canReplace(a.index(),a.parent.childCount)||!o.type.validContent(a.parent.content.cutByIndex(a.index(),a.parent.childCount)))return!1;for(let h=a.depth-1,f=n-2;h>i;h--,f--){let m=a.node(h),x=a.index(h);if(m.type.spec.isolating)return!1;let b=m.content.cutByIndex(x,m.childCount),N=r&&r[f+1];N&&(b=b.replaceChild(0,N.type.create(N.attrs)));let w=r&&r[f]||m;if(!m.canReplace(x+1,m.childCount)||!w.type.validContent(b))return!1}let c=a.indexAfter(i),u=r&&r[0];return a.node(i).canReplaceWith(c,c,u?u.type:a.node(i+1).type)}function M6(t,e,n=1,r){let a=t.doc.resolve(e),i=Ce.empty,o=Ce.empty;for(let c=a.depth,u=a.depth-n,h=n-1;c>u;c--,h--){i=Ce.from(a.node(c).copy(i));let f=r&&r[h];o=Ce.from(f?f.type.create(f.attrs,o):a.node(c).copy(o))}t.step(new hs(e,e,new ze(i.append(o),n,n),!0))}function tl(t,e){let n=t.resolve(e),r=n.index();return bS(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function A6(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let a=0;a0?(i=r.node(a+1),c++,o=r.node(a).maybeChild(c)):(i=r.node(a).maybeChild(c-1),o=r.node(a+1)),i&&!i.isTextblock&&bS(i,o)&&r.node(a).canReplace(c,c+1))return e;if(a==0)break;e=n<0?r.before(a):r.after(a)}}function P6(t,e,n){let r=null,{linebreakReplacement:a}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(a&&o.inlineContent){let f=o.whitespace=="pre",m=!!o.contentMatch.matchType(a);f&&!m?r=!1:!f&&m&&(r=!0)}let c=t.steps.length;if(r===!1){let f=t.doc.resolve(e+n);yS(t,f.node(),f.before(),c)}o.inlineContent&&gy(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let u=t.mapping.slice(c),h=u.map(e-n);if(t.step(new hs(h,u.map(e+n,-1),ze.empty,!0)),r===!0){let f=t.doc.resolve(h);gS(t,f.node(),f.before(),t.steps.length)}return t}function I6(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let a=r.depth-1;a>=0;a--){let i=r.index(a);if(r.node(a).canReplaceWith(i,i,n))return r.before(a+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let a=r.depth-1;a>=0;a--){let i=r.indexAfter(a);if(r.node(a).canReplaceWith(i,i,n))return r.after(a+1);if(i=0;o--){let c=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,u=r.index(o)+(c>0?1:0),h=r.node(o),f=!1;if(i==1)f=h.canReplace(u,u,a);else{let m=h.contentMatchAt(u).findWrapping(a.firstChild.type);f=m&&h.canReplaceWith(u,u,m[0])}if(f)return c==0?r.pos:c<0?r.before(o+1):r.after(o+1)}return null}function qp(t,e,n=e,r=ze.empty){if(e==n&&!r.size)return null;let a=t.resolve(e),i=t.resolve(n);return NS(a,i,r)?new hs(e,n,r):new R6(a,i,r).fit()}function NS(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class R6{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Ce.empty;for(let a=0;a<=e.depth;a++){let i=e.node(a);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(a))})}for(let a=e.depth;a>0;a--)this.placed=Ce.from(e.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let h=this.findFittable();h?this.placeNodes(h):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,a=this.close(e<0?this.$to:r.doc.resolve(e));if(!a)return null;let i=this.placed,o=r.depth,c=a.depth;for(;o&&c&&i.childCount==1;)i=i.firstChild.content,o--,c--;let u=new ze(i,o,c);return e>-1?new gs(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new hs(r.pos,a.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,a=this.unplaced.openEnd;r1&&(a=0),i.type.spec.isolating&&a<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let a,i=null;r?(i=ng(this.unplaced.content,r-1).firstChild,a=i.content):a=this.unplaced.content;let o=a.firstChild;for(let c=this.depth;c>=0;c--){let{type:u,match:h}=this.frontier[c],f,m=null;if(n==1&&(o?h.matchType(o.type)||(m=h.fillBefore(Ce.from(o),!1)):i&&u.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:c,parent:i,inject:m};if(n==2&&o&&(f=h.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:c,parent:i,wrap:f};if(i&&h.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,a=ng(e,n);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new ze(e,n+1,Math.max(r,a.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,a=ng(e,n);if(a.childCount<=1&&n>0){let i=e.size-n<=n+a.size;this.unplaced=new ze(lu(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new ze(lu(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:a,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let w=0;w1||u==0||w.content.size)&&(m=v,f.push(wS(w.mark(x.allowedMarks(w.marks)),h==1?u:0,h==c.childCount?b:-1)))}let N=h==c.childCount;N||(b=-1),this.placed=cu(this.placed,n,Ce.from(f)),this.frontier[n].match=m,N&&b<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,v=c;w1&&a==this.$to.end(--r);)++a;return a}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:a}=this.frontier[n],i=n=0;c--){let{match:u,type:h}=this.frontier[c],f=sg(e,c,h,u,!0);if(!f||f.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=cu(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let a=e.node(r),i=a.type.contentMatch.fillBefore(a.content,!0,e.index(r));this.openFrontierNode(a.type,a.attrs,i)}return e}openFrontierNode(e,n=null,r){let a=this.frontier[this.depth];a.match=a.match.matchType(e),this.placed=cu(this.placed,this.depth,Ce.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Ce.empty,!0);n.childCount&&(this.placed=cu(this.placed,this.frontier.length,n))}}function lu(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(lu(t.firstChild.content,e-1,n)))}function cu(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(cu(t.lastChild.content,e-1,n)))}function ng(t,e){for(let n=0;n1&&(r=r.replaceChild(0,wS(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(Ce.empty,!0)))),t.copy(r)}function sg(t,e,n,r,a){let i=t.node(e),o=a?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let c=r.fillBefore(i.content,!0,o);return c&&!L6(n,i.content,o)?c:null}function L6(t,e,n){for(let r=n;r0;x--,b--){let N=a.node(x).type.spec;if(N.defining||N.definingAsContext||N.isolating)break;o.indexOf(x)>-1?c=x:a.before(x)==b&&o.splice(1,0,-x)}let u=o.indexOf(c),h=[],f=r.openStart;for(let x=r.content,b=0;;b++){let N=x.firstChild;if(h.push(N),b==r.openStart)break;x=N.content}for(let x=f-1;x>=0;x--){let b=h[x],N=O6(b.type);if(N&&!b.sameMarkup(a.node(Math.abs(c)-1)))f=x;else if(N||!b.type.isTextblock)break}for(let x=r.openStart;x>=0;x--){let b=(x+f+1)%(r.openStart+1),N=h[b];if(N)for(let w=0;w=0&&(t.replace(e,n,r),!(t.steps.length>m));x--){let b=o[x];b<0||(e=a.before(b),n=i.after(b))}}function jS(t,e,n,r,a){if(er){let i=a.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(Ce.empty,!0))}return t}function _6(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let a=I6(t.doc,e,r.type);a!=null&&(e=n=a)}t.replaceRange(e,n,new ze(Ce.from(r),0,0))}function $6(t,e,n){let r=t.doc.resolve(e),a=t.doc.resolve(n),i=kS(r,a);for(let o=0;o0&&(u||r.node(c-1).canReplace(r.index(c-1),a.indexAfter(c-1))))return t.delete(r.before(c),a.after(c))}for(let o=1;o<=r.depth&&o<=a.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&a.end(o)-n!=a.depth-o&&r.start(o-1)==a.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),a.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function kS(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let a=r;a>=0;a--){let i=t.start(a);if(ie.pos+(e.depth-a)||t.node(a).type.spec.isolating||e.node(a).type.spec.isolating)break;(i==e.start(a)||a==t.depth&&a==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&a&&e.start(a-1)==i-1)&&n.push(a)}return n}class ed extends Bs{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return qn.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let a=n.type.create(r,null,n.marks);return qn.fromReplace(e,this.pos,this.pos+1,new ze(Ce.from(a),0,n.isLeaf?0:1))}getMap(){return Cr.empty}invert(e){return new ed(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ed(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ed(n.pos,n.attr,n.value)}}Bs.jsonID("attr",ed);class Ou extends Bs{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let a in e.attrs)n[a]=e.attrs[a];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return qn.ok(r)}getMap(){return Cr.empty}invert(e){return new Ou(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ou(n.attr,n.value)}}Bs.jsonID("docAttr",Ou);let rd=class extends Error{};rd=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};rd.prototype=Object.create(Error.prototype);rd.prototype.constructor=rd;rd.prototype.name="TransformError";class by{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Lu}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new rd(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r{e=Math.min(e,c),n=Math.max(n,u)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=ze.empty){let a=qp(this.doc,e,n,r);return a&&this.step(a),this}replaceWith(e,n,r){return this.replace(e,n,new ze(Ce.from(r),0,0))}delete(e,n){return this.replace(e,n,ze.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return D6(this,e,n,r),this}replaceRangeWith(e,n,r){return _6(this,e,n,r),this}deleteRange(e,n){return $6(this,e,n),this}lift(e,n){return w6(this,e,n),this}join(e,n=1){return P6(this,e,n),this}wrap(e,n){return S6(this,e,n),this}setBlockType(e,n=e,r,a=null){return C6(this,e,n,r,a),this}setNodeMarkup(e,n,r=null,a){return T6(this,e,n,r,a),this}setNodeAttribute(e,n,r){return this.step(new ed(e,n,r)),this}setDocAttribute(e,n){return this.step(new Ou(e,n)),this}addNodeMark(e,n){return this.step(new Ro(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof ln)n.isInSet(r.marks)&&this.step(new ql(e,n));else{let a=r.marks,i,o=[];for(;i=n.isInSet(a);)o.push(new ql(e,i)),a=i.removeFromSet(a);for(let c=o.length-1;c>=0;c--)this.step(o[c])}return this}split(e,n=1,r){return M6(this,e,n,r),this}addMark(e,n,r){return b6(this,e,n,r),this}removeMark(e,n,r){return v6(this,e,n,r),this}clearIncompatible(e,n,r){return gy(this,e,n,r),this}}const rg=Object.create(null);class ft{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new SS(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;i--){let o=n<0?Uc(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Uc(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Tr(e.node(0))}static atStart(e){return Uc(e,e,0,0,1)||new Tr(e)}static atEnd(e){return Uc(e,e,e.content.size,e.childCount,-1)||new Tr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=rg[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in rg)throw new RangeError("Duplicate use of selection JSON ID "+e);return rg[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ot.between(this.$anchor,this.$head).getBookmark()}}ft.prototype.visible=!0;class SS{constructor(e,n){this.$from=e,this.$to=n}}let EN=!1;function TN(t){!EN&&!t.parent.inlineContent&&(EN=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ot extends ft{constructor(e,n=e){TN(e),TN(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return ft.near(r);let a=e.resolve(n.map(this.anchor));return new ot(a.parent.inlineContent?a:r,r)}replace(e,n=ze.empty){if(super.replace(e,n),n==ze.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ot&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Gp(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ot(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let a=e.resolve(n);return new this(a,r==n?a:e.resolve(r))}static between(e,n,r){let a=e.pos-n.pos;if((!r||a)&&(r=a>=0?1:-1),!n.parent.inlineContent){let i=ft.findFrom(n,r,!0)||ft.findFrom(n,-r,!0);if(i)n=i.$head;else return ft.near(n,r)}return e.parent.inlineContent||(a==0?e=n:(e=(ft.findFrom(e,-r,!0)||ft.findFrom(e,r,!0)).$anchor,e.pos0?0:1);a>0?o=0;o+=a){let c=e.child(o);if(c.isAtom){if(!i&&it.isSelectable(c))return it.create(t,n-(a<0?c.nodeSize:0))}else{let u=Uc(t,c,n+a,a<0?c.childCount:0,a,i);if(u)return u}n+=c.nodeSize*a}return null}function MN(t,e,n){let r=t.steps.length-1;if(r{o==null&&(o=f)}),t.setSelection(ft.near(t.doc.resolve(o),n))}const AN=1,of=2,PN=4;class F6 extends by{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=of,this}ensureMarks(e){return ln.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&of)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~of,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ln.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let a=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(a.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,a.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(ft.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=PN,this}get scrolledIntoView(){return(this.updated&PN)>0}}function IN(t,e){return!e||!t?t:t.bind(e)}class du{constructor(e,n,r){this.name=e,this.init=IN(n.init,r),this.apply=IN(n.apply,r)}}const B6=[new du("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new du("selection",{init(t,e){return t.selection||ft.atStart(e.doc)},apply(t){return t.selection}}),new du("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new du("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class ag{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=B6.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new du(r.key,r.spec.state,r))})}}class Yc{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let a=e[r],i=a.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(a,this[a.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let a=new ag(e.schema,e.plugins),i=new Yc(a);return a.fields.forEach(o=>{if(o.name=="doc")i.doc=$i.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=ft.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let c in r){let u=r[c],h=u.spec.state;if(u.key==o.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(n,c)){i[o.name]=h.fromJSON.call(u,e,n[c],i);return}}i[o.name]=o.init(e,i)}}),i}}function CS(t,e,n){for(let r in t){let a=t[r];a instanceof Function?a=a.bind(e):r=="handleDOMEvents"&&(a=CS(a,e,{})),n[r]=a}return n}class hn{constructor(e){this.spec=e,this.props={},e.props&&CS(e.props,this,this.props),this.key=e.key?e.key.key:ES("plugin")}getState(e){return e[this.key]}}const ig=Object.create(null);function ES(t){return t in ig?t+"$"+ ++ig[t]:(ig[t]=0,t+"$")}class wn{constructor(e="key"){this.key=ES(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ny=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function TS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const MS=(t,e,n)=>{let r=TS(t,n);if(!r)return!1;let a=wy(r);if(!a){let o=r.blockRange(),c=o&&yd(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let i=a.nodeBefore;if($S(t,a,e,-1))return!0;if(r.parent.content.size==0&&(ad(i,"end")||it.isSelectable(i)))for(let o=r.depth;;o--){let c=qp(t.doc,r.before(o),r.after(o),ze.empty);if(c&&c.slice.size1)break}return i.isAtom&&a.depth==r.depth-1?(e&&e(t.tr.delete(a.pos-i.nodeSize,a.pos).scrollIntoView()),!0):!1},V6=(t,e,n)=>{let r=TS(t,n);if(!r)return!1;let a=wy(r);return a?AS(t,a,e):!1},H6=(t,e,n)=>{let r=IS(t,n);if(!r)return!1;let a=jy(r);return a?AS(t,a,e):!1};function AS(t,e,n){let r=e.nodeBefore,a=r,i=e.pos-1;for(;!a.isTextblock;i--){if(a.type.spec.isolating)return!1;let f=a.lastChild;if(!f)return!1;a=f}let o=e.nodeAfter,c=o,u=e.pos+1;for(;!c.isTextblock;u++){if(c.type.spec.isolating)return!1;let f=c.firstChild;if(!f)return!1;c=f}let h=qp(t.doc,i,u,ze.empty);if(!h||h.from!=i||h instanceof hs&&h.slice.size>=u-i)return!1;if(n){let f=t.tr.step(h);f.setSelection(ot.create(f.doc,i)),n(f.scrollIntoView())}return!0}function ad(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const PS=(t,e,n)=>{let{$head:r,empty:a}=t.selection,i=r;if(!a)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=wy(r)}let o=i&&i.nodeBefore;return!o||!it.isSelectable(o)?!1:(e&&e(t.tr.setSelection(it.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function wy(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function IS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=IS(t,n);if(!r)return!1;let a=jy(r);if(!a)return!1;let i=a.nodeAfter;if($S(t,a,e,1))return!0;if(r.parent.content.size==0&&(ad(i,"start")||it.isSelectable(i))){let o=qp(t.doc,r.before(),r.after(),ze.empty);if(o&&o.slice.size{let{$head:r,empty:a}=t.selection,i=r;if(!a)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof it,a;if(r){if(n.node.isTextblock||!tl(t.doc,n.from))return!1;a=n.from}else if(a=Kp(t.doc,n.from,-1),a==null)return!1;if(e){let i=t.tr.join(a);r&&i.setSelection(it.create(i.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},W6=(t,e)=>{let n=t.selection,r;if(n instanceof it){if(n.node.isTextblock||!tl(t.doc,n.to))return!1;r=n.to}else if(r=Kp(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},K6=(t,e)=>{let{$from:n,$to:r}=t.selection,a=n.blockRange(r),i=a&&yd(a);return i==null?!1:(e&&e(t.tr.lift(a,i).scrollIntoView()),!0)},OS=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
+`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let a=0;a!u.clearMark(h)):n=n.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)c=u;else break}}return n}addElementByRule(e,n,r,a){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let u=this.enter(o,n.attrs||null,r,n.preserveWhitespace);u&&(i=!0,r=u)}else{let u=this.parser.schema.marks[n.mark];r=r.concat(u.create(n.attrs))}let c=this.top;if(o&&o.isLeaf)this.findInside(e);else if(a)this.addElement(e,r,a);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,r,!1));else{let u=e;typeof n.contentElement=="string"?u=e.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(e):n.contentElement&&(u=n.contentElement),this.findAround(e,u,!0),this.addAll(u,r),this.findAround(e,u,!1)}i&&this.sync(c)&&this.open--}addAll(e,n,r,a){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,c=a==null?null:e.childNodes[a];o!=c;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let a,i;for(let o=this.open,c=0;o>=0;o--){let u=this.nodes[o],h=u.findWrapping(e);if(h&&(!a||a.length>h.length+c)&&(a=h,i=u,!h.length))break;if(u.solid){if(r)break;c+=2}}if(!a)return null;this.sync(i);for(let o=0;o(o.type?o.type.allowsMarkType(h.type):wN(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new af(e,n,u,a,null,c)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Ru)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let a=r.length-1;a>=0;a--)e+=r[a].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,a=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(a?0:1),o=(c,u)=>{for(;c>=0;c--){let h=n[c];if(h==""){if(c==n.length-1||c==0)continue;for(;u>=i;u--)if(o(c-1,u))return!0;return!1}else{let f=u>0||u==0&&a?this.nodes[u].type:r&&u>=i?r.node(u-i).type:null;if(!f||f.name!=h&&!f.isInGroup(h))return!1;u--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function f6(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&uS.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function p6(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function NN(t){let e={};for(let n in t)e[n]=t[n];return e}function wN(t,e){let n=e.schema.nodes;for(let r in n){let a=n[r];if(!a.allowsMarkType(t))continue;let i=[],o=c=>{i.push(c);for(let u=0;u{if(i.length||o.marks.length){let c=0,u=0;for(;c=0;a--){let i=this.serializeMark(e.marks[a],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let a=this.marks[e.type.name];return a&&kf(eg(r),a(e,n),null,e.attrs)}static renderSpec(e,n,r=null,a){return kf(e,n,r,a)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new nc(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=jN(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return jN(e.marks)}}function jN(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function eg(t){return t.document||window.document}const kN=new WeakMap;function m6(t){let e=kN.get(t);return e===void 0&&kN.set(t,e=x6(t)),e}function x6(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let a=0;a-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=a.indexOf(" ");o>0&&(n=a.slice(0,o),a=a.slice(o+1));let c,u=n?t.createElementNS(n,a):t.createElement(a),h=e[1],f=1;if(h&&typeof h=="object"&&h.nodeType==null&&!Array.isArray(h)){f=2;for(let m in h)if(h[m]!=null){let x=m.indexOf(" ");x>0?u.setAttributeNS(m.slice(0,x),m.slice(x+1),h[m]):m=="style"&&u.style?u.style.cssText=h[m]:u.setAttribute(m,h[m])}}for(let m=f;mf)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:b,contentDOM:N}=kf(t,x,n,r);if(u.appendChild(b),N){if(c)throw new RangeError("Multiple content holes");c=N}}}return{dom:u,contentDOM:c}}const hS=65535,fS=Math.pow(2,16);function g6(t,e){return t+e*fS}function SN(t){return t&hS}function y6(t){return(t-(t&hS))/fS}const pS=1,mS=2,Sf=4,xS=8;class a0{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&xS)>0}get deletedBefore(){return(this.delInfo&(pS|Sf))>0}get deletedAfter(){return(this.delInfo&(mS|Sf))>0}get deletedAcross(){return(this.delInfo&Sf)>0}}class Cr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Cr.empty)return Cr.empty}recover(e){let n=0,r=SN(e);if(!this.inverted)for(let a=0;ae)break;let h=this.ranges[c+i],f=this.ranges[c+o],m=u+h;if(e<=m){let x=h?e==u?-1:e==m?1:n:n,b=u+a+(x<0?0:f);if(r)return b;let N=e==(n<0?u:m)?null:g6(c/3,e-u),w=e==u?mS:e==m?pS:Sf;return(n<0?e!=u:e!=m)&&(w|=xS),new a0(b,w,N)}a+=f-h}return r?e+a:new a0(e+a,0,null)}touches(e,n){let r=0,a=SN(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let c=0;ce)break;let h=this.ranges[c+i],f=u+h;if(e<=f&&c==a*3)return!0;r+=this.ranges[c+o]-h}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let a=0,i=0;a=0;n--){let a=e.getMirror(n);this.appendMap(e._maps[n].invert(),a!=null&&a>n?r-a-1:void 0)}}invert(){let e=new Lu;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ri&&u!o.isAtom||!c.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),a),n.openStart,n.openEnd);return Gn.fromReplace(e,this.from,this.to,i)}invert(){return new ga(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Io(n.pos,r.pos,this.mark)}merge(e){return e instanceof Io&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Io(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Io(n.from,n.to,e.markFromJSON(n.mark))}}Bs.jsonID("addMark",Io);class ga extends Bs{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new ze(xy(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),e),n.openStart,n.openEnd);return Gn.fromReplace(e,this.from,this.to,r)}invert(){return new Io(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ga(n.pos,r.pos,this.mark)}merge(e){return e instanceof ga&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ga(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ga(n.from,n.to,e.markFromJSON(n.mark))}}Bs.jsonID("removeMark",ga);class Ro extends Bs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Gn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Gn.fromReplace(e,this.pos,this.pos+1,new ze(Ce.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let a=0;ar.pos?null:new gs(n.pos,r.pos,a,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new gs(n.from,n.to,n.gapFrom,n.gapTo,ze.fromJSON(e,n.slice),n.insert,!!n.structure)}}Bs.jsonID("replaceAround",gs);function i0(t,e,n){let r=t.resolve(e),a=n-e,i=r.depth;for(;a>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,a--;if(a>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;a>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,a--}}return!1}function b6(t,e,n,r){let a=[],i=[],o,c;t.doc.nodesBetween(e,n,(u,h,f)=>{if(!u.isInline)return;let m=u.marks;if(!r.isInSet(m)&&f.type.allowsMarkType(r.type)){let x=Math.max(h,e),b=Math.min(h+u.nodeSize,n),N=r.addToSet(m);for(let w=0;wt.step(u)),i.forEach(u=>t.step(u))}function v6(t,e,n,r){let a=[],i=0;t.doc.nodesBetween(e,n,(o,c)=>{if(!o.isInline)return;i++;let u=null;if(r instanceof Wp){let h=o.marks,f;for(;f=r.isInSet(h);)(u||(u=[])).push(f),h=f.removeFromSet(h)}else r?r.isInSet(o.marks)&&(u=[r]):u=o.marks;if(u&&u.length){let h=Math.min(c+o.nodeSize,n);for(let f=0;ft.step(new ga(o.from,o.to,o.style)))}function gy(t,e,n,r=n.contentMatch,a=!0){let i=t.doc.nodeAt(e),o=[],c=e+1;for(let u=0;u=0;u--)t.step(o[u])}function N6(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function yd(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,a=0,i=0;;--r){let o=t.$from.node(r),c=t.$from.index(r)+a,u=t.$to.indexAfter(r)-i;if(rn;N--)w||r.index(N)>0?(w=!0,f=Ce.from(r.node(N).copy(f)),m++):u--;let x=Ce.empty,b=0;for(let N=i,w=!1;N>n;N--)w||a.after(N+1)=0;o--){if(r.size){let c=n[o].type.contentMatch.matchFragment(r);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Ce.from(n[o].type.create(n[o].attrs,r))}let a=e.start,i=e.end;t.step(new gs(a,i,a,i,new ze(r,0,0),n.length,!0))}function C6(t,e,n,r,a){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,c)=>{let u=typeof a=="function"?a(o):a;if(o.isTextblock&&!o.hasMarkup(r,u)&&E6(t.doc,t.mapping.slice(i).map(c),r)){let h=null;if(r.schema.linebreakReplacement){let b=r.whitespace=="pre",N=!!r.contentMatch.matchType(r.schema.linebreakReplacement);b&&!N?h=!1:!b&&N&&(h=!0)}h===!1&&yS(t,o,c,i),gy(t,t.mapping.slice(i).map(c,1),r,void 0,h===null);let f=t.mapping.slice(i),m=f.map(c,1),x=f.map(c+o.nodeSize,1);return t.step(new gs(m,x,m+1,x-1,new ze(Ce.from(r.create(u,null,o.marks)),0,0),1,!0)),h===!0&&gS(t,o,c,i),!1}})}function gS(t,e,n,r){e.forEach((a,i)=>{if(a.isText){let o,c=/\r?\n|\r/g;for(;o=c.exec(a.text);){let u=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function yS(t,e,n,r){e.forEach((a,i)=>{if(a.type==a.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
+`))}})}function E6(t,e,n){let r=t.resolve(e),a=r.index();return r.parent.canReplaceWith(a,a+1,n)}function T6(t,e,n,r,a){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,a||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new gs(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new ze(Ce.from(o),0,0),1,!0))}function zi(t,e,n=1,r){let a=t.resolve(e),i=a.depth-n,o=r&&r[r.length-1]||a.parent;if(i<0||a.parent.type.spec.isolating||!a.parent.canReplace(a.index(),a.parent.childCount)||!o.type.validContent(a.parent.content.cutByIndex(a.index(),a.parent.childCount)))return!1;for(let h=a.depth-1,f=n-2;h>i;h--,f--){let m=a.node(h),x=a.index(h);if(m.type.spec.isolating)return!1;let b=m.content.cutByIndex(x,m.childCount),N=r&&r[f+1];N&&(b=b.replaceChild(0,N.type.create(N.attrs)));let w=r&&r[f]||m;if(!m.canReplace(x+1,m.childCount)||!w.type.validContent(b))return!1}let c=a.indexAfter(i),u=r&&r[0];return a.node(i).canReplaceWith(c,c,u?u.type:a.node(i+1).type)}function M6(t,e,n=1,r){let a=t.doc.resolve(e),i=Ce.empty,o=Ce.empty;for(let c=a.depth,u=a.depth-n,h=n-1;c>u;c--,h--){i=Ce.from(a.node(c).copy(i));let f=r&&r[h];o=Ce.from(f?f.type.create(f.attrs,o):a.node(c).copy(o))}t.step(new hs(e,e,new ze(i.append(o),n,n),!0))}function tl(t,e){let n=t.resolve(e),r=n.index();return bS(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function A6(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let a=0;a0?(i=r.node(a+1),c++,o=r.node(a).maybeChild(c)):(i=r.node(a).maybeChild(c-1),o=r.node(a+1)),i&&!i.isTextblock&&bS(i,o)&&r.node(a).canReplace(c,c+1))return e;if(a==0)break;e=n<0?r.before(a):r.after(a)}}function P6(t,e,n){let r=null,{linebreakReplacement:a}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(a&&o.inlineContent){let f=o.whitespace=="pre",m=!!o.contentMatch.matchType(a);f&&!m?r=!1:!f&&m&&(r=!0)}let c=t.steps.length;if(r===!1){let f=t.doc.resolve(e+n);yS(t,f.node(),f.before(),c)}o.inlineContent&&gy(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let u=t.mapping.slice(c),h=u.map(e-n);if(t.step(new hs(h,u.map(e+n,-1),ze.empty,!0)),r===!0){let f=t.doc.resolve(h);gS(t,f.node(),f.before(),t.steps.length)}return t}function I6(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let a=r.depth-1;a>=0;a--){let i=r.index(a);if(r.node(a).canReplaceWith(i,i,n))return r.before(a+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let a=r.depth-1;a>=0;a--){let i=r.indexAfter(a);if(r.node(a).canReplaceWith(i,i,n))return r.after(a+1);if(i=0;o--){let c=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,u=r.index(o)+(c>0?1:0),h=r.node(o),f=!1;if(i==1)f=h.canReplace(u,u,a);else{let m=h.contentMatchAt(u).findWrapping(a.firstChild.type);f=m&&h.canReplaceWith(u,u,m[0])}if(f)return c==0?r.pos:c<0?r.before(o+1):r.after(o+1)}return null}function qp(t,e,n=e,r=ze.empty){if(e==n&&!r.size)return null;let a=t.resolve(e),i=t.resolve(n);return NS(a,i,r)?new hs(e,n,r):new R6(a,i,r).fit()}function NS(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class R6{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Ce.empty;for(let a=0;a<=e.depth;a++){let i=e.node(a);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(a))})}for(let a=e.depth;a>0;a--)this.placed=Ce.from(e.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let h=this.findFittable();h?this.placeNodes(h):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,a=this.close(e<0?this.$to:r.doc.resolve(e));if(!a)return null;let i=this.placed,o=r.depth,c=a.depth;for(;o&&c&&i.childCount==1;)i=i.firstChild.content,o--,c--;let u=new ze(i,o,c);return e>-1?new gs(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new hs(r.pos,a.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,a=this.unplaced.openEnd;r1&&(a=0),i.type.spec.isolating&&a<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let a,i=null;r?(i=ng(this.unplaced.content,r-1).firstChild,a=i.content):a=this.unplaced.content;let o=a.firstChild;for(let c=this.depth;c>=0;c--){let{type:u,match:h}=this.frontier[c],f,m=null;if(n==1&&(o?h.matchType(o.type)||(m=h.fillBefore(Ce.from(o),!1)):i&&u.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:c,parent:i,inject:m};if(n==2&&o&&(f=h.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:c,parent:i,wrap:f};if(i&&h.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,a=ng(e,n);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new ze(e,n+1,Math.max(r,a.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,a=ng(e,n);if(a.childCount<=1&&n>0){let i=e.size-n<=n+a.size;this.unplaced=new ze(lu(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new ze(lu(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:a,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let w=0;w1||u==0||w.content.size)&&(m=v,f.push(wS(w.mark(x.allowedMarks(w.marks)),h==1?u:0,h==c.childCount?b:-1)))}let N=h==c.childCount;N||(b=-1),this.placed=cu(this.placed,n,Ce.from(f)),this.frontier[n].match=m,N&&b<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,v=c;w1&&a==this.$to.end(--r);)++a;return a}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:a}=this.frontier[n],i=n=0;c--){let{match:u,type:h}=this.frontier[c],f=sg(e,c,h,u,!0);if(!f||f.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=cu(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let a=e.node(r),i=a.type.contentMatch.fillBefore(a.content,!0,e.index(r));this.openFrontierNode(a.type,a.attrs,i)}return e}openFrontierNode(e,n=null,r){let a=this.frontier[this.depth];a.match=a.match.matchType(e),this.placed=cu(this.placed,this.depth,Ce.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Ce.empty,!0);n.childCount&&(this.placed=cu(this.placed,this.frontier.length,n))}}function lu(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(lu(t.firstChild.content,e-1,n)))}function cu(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(cu(t.lastChild.content,e-1,n)))}function ng(t,e){for(let n=0;n1&&(r=r.replaceChild(0,wS(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(Ce.empty,!0)))),t.copy(r)}function sg(t,e,n,r,a){let i=t.node(e),o=a?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let c=r.fillBefore(i.content,!0,o);return c&&!L6(n,i.content,o)?c:null}function L6(t,e,n){for(let r=n;r0;x--,b--){let N=a.node(x).type.spec;if(N.defining||N.definingAsContext||N.isolating)break;o.indexOf(x)>-1?c=x:a.before(x)==b&&o.splice(1,0,-x)}let u=o.indexOf(c),h=[],f=r.openStart;for(let x=r.content,b=0;;b++){let N=x.firstChild;if(h.push(N),b==r.openStart)break;x=N.content}for(let x=f-1;x>=0;x--){let b=h[x],N=O6(b.type);if(N&&!b.sameMarkup(a.node(Math.abs(c)-1)))f=x;else if(N||!b.type.isTextblock)break}for(let x=r.openStart;x>=0;x--){let b=(x+f+1)%(r.openStart+1),N=h[b];if(N)for(let w=0;w=0&&(t.replace(e,n,r),!(t.steps.length>m));x--){let b=o[x];b<0||(e=a.before(b),n=i.after(b))}}function jS(t,e,n,r,a){if(er){let i=a.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(Ce.empty,!0))}return t}function _6(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let a=I6(t.doc,e,r.type);a!=null&&(e=n=a)}t.replaceRange(e,n,new ze(Ce.from(r),0,0))}function $6(t,e,n){let r=t.doc.resolve(e),a=t.doc.resolve(n),i=kS(r,a);for(let o=0;o0&&(u||r.node(c-1).canReplace(r.index(c-1),a.indexAfter(c-1))))return t.delete(r.before(c),a.after(c))}for(let o=1;o<=r.depth&&o<=a.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&a.end(o)-n!=a.depth-o&&r.start(o-1)==a.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),a.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function kS(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let a=r;a>=0;a--){let i=t.start(a);if(ie.pos+(e.depth-a)||t.node(a).type.spec.isolating||e.node(a).type.spec.isolating)break;(i==e.start(a)||a==t.depth&&a==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&a&&e.start(a-1)==i-1)&&n.push(a)}return n}class ed extends Bs{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Gn.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let a=n.type.create(r,null,n.marks);return Gn.fromReplace(e,this.pos,this.pos+1,new ze(Ce.from(a),0,n.isLeaf?0:1))}getMap(){return Cr.empty}invert(e){return new ed(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ed(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ed(n.pos,n.attr,n.value)}}Bs.jsonID("attr",ed);class Ou extends Bs{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let a in e.attrs)n[a]=e.attrs[a];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Gn.ok(r)}getMap(){return Cr.empty}invert(e){return new Ou(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ou(n.attr,n.value)}}Bs.jsonID("docAttr",Ou);let rd=class extends Error{};rd=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};rd.prototype=Object.create(Error.prototype);rd.prototype.constructor=rd;rd.prototype.name="TransformError";class by{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Lu}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new rd(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r{e=Math.min(e,c),n=Math.max(n,u)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=ze.empty){let a=qp(this.doc,e,n,r);return a&&this.step(a),this}replaceWith(e,n,r){return this.replace(e,n,new ze(Ce.from(r),0,0))}delete(e,n){return this.replace(e,n,ze.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return D6(this,e,n,r),this}replaceRangeWith(e,n,r){return _6(this,e,n,r),this}deleteRange(e,n){return $6(this,e,n),this}lift(e,n){return w6(this,e,n),this}join(e,n=1){return P6(this,e,n),this}wrap(e,n){return S6(this,e,n),this}setBlockType(e,n=e,r,a=null){return C6(this,e,n,r,a),this}setNodeMarkup(e,n,r=null,a){return T6(this,e,n,r,a),this}setNodeAttribute(e,n,r){return this.step(new ed(e,n,r)),this}setDocAttribute(e,n){return this.step(new Ou(e,n)),this}addNodeMark(e,n){return this.step(new Ro(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof ln)n.isInSet(r.marks)&&this.step(new ql(e,n));else{let a=r.marks,i,o=[];for(;i=n.isInSet(a);)o.push(new ql(e,i)),a=i.removeFromSet(a);for(let c=o.length-1;c>=0;c--)this.step(o[c])}return this}split(e,n=1,r){return M6(this,e,n,r),this}addMark(e,n,r){return b6(this,e,n,r),this}removeMark(e,n,r){return v6(this,e,n,r),this}clearIncompatible(e,n,r){return gy(this,e,n,r),this}}const rg=Object.create(null);class ft{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new SS(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;i--){let o=n<0?Uc(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Uc(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Tr(e.node(0))}static atStart(e){return Uc(e,e,0,0,1)||new Tr(e)}static atEnd(e){return Uc(e,e,e.content.size,e.childCount,-1)||new Tr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=rg[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in rg)throw new RangeError("Duplicate use of selection JSON ID "+e);return rg[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ot.between(this.$anchor,this.$head).getBookmark()}}ft.prototype.visible=!0;class SS{constructor(e,n){this.$from=e,this.$to=n}}let EN=!1;function TN(t){!EN&&!t.parent.inlineContent&&(EN=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ot extends ft{constructor(e,n=e){TN(e),TN(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return ft.near(r);let a=e.resolve(n.map(this.anchor));return new ot(a.parent.inlineContent?a:r,r)}replace(e,n=ze.empty){if(super.replace(e,n),n==ze.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ot&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Gp(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ot(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let a=e.resolve(n);return new this(a,r==n?a:e.resolve(r))}static between(e,n,r){let a=e.pos-n.pos;if((!r||a)&&(r=a>=0?1:-1),!n.parent.inlineContent){let i=ft.findFrom(n,r,!0)||ft.findFrom(n,-r,!0);if(i)n=i.$head;else return ft.near(n,r)}return e.parent.inlineContent||(a==0?e=n:(e=(ft.findFrom(e,-r,!0)||ft.findFrom(e,r,!0)).$anchor,e.pos0?0:1);a>0?o=0;o+=a){let c=e.child(o);if(c.isAtom){if(!i&&it.isSelectable(c))return it.create(t,n-(a<0?c.nodeSize:0))}else{let u=Uc(t,c,n+a,a<0?c.childCount:0,a,i);if(u)return u}n+=c.nodeSize*a}return null}function MN(t,e,n){let r=t.steps.length-1;if(r{o==null&&(o=f)}),t.setSelection(ft.near(t.doc.resolve(o),n))}const AN=1,of=2,PN=4;class F6 extends by{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=of,this}ensureMarks(e){return ln.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&of)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~of,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ln.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let a=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(a.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,a.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(ft.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=PN,this}get scrolledIntoView(){return(this.updated&PN)>0}}function IN(t,e){return!e||!t?t:t.bind(e)}class du{constructor(e,n,r){this.name=e,this.init=IN(n.init,r),this.apply=IN(n.apply,r)}}const B6=[new du("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new du("selection",{init(t,e){return t.selection||ft.atStart(e.doc)},apply(t){return t.selection}}),new du("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new du("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class ag{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=B6.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new du(r.key,r.spec.state,r))})}}class Yc{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let a=e[r],i=a.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(a,this[a.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let a=new ag(e.schema,e.plugins),i=new Yc(a);return a.fields.forEach(o=>{if(o.name=="doc")i.doc=$i.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=ft.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let c in r){let u=r[c],h=u.spec.state;if(u.key==o.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(n,c)){i[o.name]=h.fromJSON.call(u,e,n[c],i);return}}i[o.name]=o.init(e,i)}}),i}}function CS(t,e,n){for(let r in t){let a=t[r];a instanceof Function?a=a.bind(e):r=="handleDOMEvents"&&(a=CS(a,e,{})),n[r]=a}return n}class hn{constructor(e){this.spec=e,this.props={},e.props&&CS(e.props,this,this.props),this.key=e.key?e.key.key:ES("plugin")}getState(e){return e[this.key]}}const ig=Object.create(null);function ES(t){return t in ig?t+"$"+ ++ig[t]:(ig[t]=0,t+"$")}class wn{constructor(e="key"){this.key=ES(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ny=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function TS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const MS=(t,e,n)=>{let r=TS(t,n);if(!r)return!1;let a=wy(r);if(!a){let o=r.blockRange(),c=o&&yd(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let i=a.nodeBefore;if($S(t,a,e,-1))return!0;if(r.parent.content.size==0&&(ad(i,"end")||it.isSelectable(i)))for(let o=r.depth;;o--){let c=qp(t.doc,r.before(o),r.after(o),ze.empty);if(c&&c.slice.size1)break}return i.isAtom&&a.depth==r.depth-1?(e&&e(t.tr.delete(a.pos-i.nodeSize,a.pos).scrollIntoView()),!0):!1},V6=(t,e,n)=>{let r=TS(t,n);if(!r)return!1;let a=wy(r);return a?AS(t,a,e):!1},H6=(t,e,n)=>{let r=IS(t,n);if(!r)return!1;let a=jy(r);return a?AS(t,a,e):!1};function AS(t,e,n){let r=e.nodeBefore,a=r,i=e.pos-1;for(;!a.isTextblock;i--){if(a.type.spec.isolating)return!1;let f=a.lastChild;if(!f)return!1;a=f}let o=e.nodeAfter,c=o,u=e.pos+1;for(;!c.isTextblock;u++){if(c.type.spec.isolating)return!1;let f=c.firstChild;if(!f)return!1;c=f}let h=qp(t.doc,i,u,ze.empty);if(!h||h.from!=i||h instanceof hs&&h.slice.size>=u-i)return!1;if(n){let f=t.tr.step(h);f.setSelection(ot.create(f.doc,i)),n(f.scrollIntoView())}return!0}function ad(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const PS=(t,e,n)=>{let{$head:r,empty:a}=t.selection,i=r;if(!a)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=wy(r)}let o=i&&i.nodeBefore;return!o||!it.isSelectable(o)?!1:(e&&e(t.tr.setSelection(it.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function wy(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function IS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=IS(t,n);if(!r)return!1;let a=jy(r);if(!a)return!1;let i=a.nodeAfter;if($S(t,a,e,1))return!0;if(r.parent.content.size==0&&(ad(i,"start")||it.isSelectable(i))){let o=qp(t.doc,r.before(),r.after(),ze.empty);if(o&&o.slice.size{let{$head:r,empty:a}=t.selection,i=r;if(!a)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof it,a;if(r){if(n.node.isTextblock||!tl(t.doc,n.from))return!1;a=n.from}else if(a=Kp(t.doc,n.from,-1),a==null)return!1;if(e){let i=t.tr.join(a);r&&i.setSelection(it.create(i.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},W6=(t,e)=>{let n=t.selection,r;if(n instanceof it){if(n.node.isTextblock||!tl(t.doc,n.to))return!1;r=n.to}else if(r=Kp(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},K6=(t,e)=>{let{$from:n,$to:r}=t.selection,a=n.blockRange(r),i=a&&yd(a);return i==null?!1:(e&&e(t.tr.lift(a,i).scrollIntoView()),!0)},OS=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
`).scrollIntoView()),!0)};function ky(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let a=n.node(-1),i=n.indexAfter(-1),o=ky(a.contentMatchAt(i));if(!o||!a.canReplaceWith(i,i,o))return!1;if(e){let c=n.after(),u=t.tr.replaceWith(c,c,o.createAndFill());u.setSelection(ft.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},DS=(t,e)=>{let n=t.selection,{$from:r,$to:a}=n;if(n instanceof Tr||r.parent.inlineContent||a.parent.inlineContent)return!1;let i=ky(a.parent.contentMatchAt(a.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&a.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(zi(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),a=r&&yd(r);return a==null?!1:(e&&e(t.tr.lift(r,a).scrollIntoView()),!0)};function G6(t){return(e,n)=>{let{$from:r,$to:a}=e.selection;if(e.selection instanceof it&&e.selection.node.isBlock)return!r.parentOffset||!zi(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,c,u=!1,h=!1;for(let b=r.depth;;b--)if(r.node(b).isBlock){u=r.end(b)==r.pos+(r.depth-b),h=r.start(b)==r.pos-(r.depth-b),c=ky(r.node(b-1).contentMatchAt(r.indexAfter(b-1))),i.unshift(u&&c?{type:c}:null),o=b;break}else{if(b==1)return!1;i.unshift(null)}let f=e.tr;(e.selection instanceof ot||e.selection instanceof Tr)&&f.deleteSelection();let m=f.mapping.map(r.pos),x=zi(f.doc,m,i.length,i);if(x||(i[0]=c?{type:c}:null,x=zi(f.doc,m,i.length,i)),!x)return!1;if(f.split(m,i.length,i),!u&&h&&r.node(o).type!=c){let b=f.mapping.map(r.before(o)),N=f.doc.resolve(b);c&&r.node(o-1).canReplaceWith(N.index(),N.index()+1,c)&&f.setNodeMarkup(f.mapping.map(r.before(o)),c)}return n&&n(f.scrollIntoView()),!0}}const J6=G6(),Q6=(t,e)=>{let{$from:n,to:r}=t.selection,a,i=n.sharedDepth(r);return i==0?!1:(a=n.before(i),e&&e(t.tr.setSelection(it.create(t.doc,a))),!0)};function Y6(t,e,n){let r=e.nodeBefore,a=e.nodeAfter,i=e.index();return!r||!a||!r.type.compatibleContent(a.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(a.isTextblock||tl(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function $S(t,e,n,r){let a=e.nodeBefore,i=e.nodeAfter,o,c,u=a.type.spec.isolating||i.type.spec.isolating;if(!u&&Y6(t,e,n))return!0;let h=!u&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(o=(c=a.contentMatchAt(a.childCount)).findWrapping(i.type))&&c.matchType(o[0]||i.type).validEnd){if(n){let b=e.pos+i.nodeSize,N=Ce.empty;for(let k=o.length-1;k>=0;k--)N=Ce.from(o[k].create(null,N));N=Ce.from(a.copy(N));let w=t.tr.step(new gs(e.pos-1,b,e.pos,b,new ze(N,1,0),o.length,!0)),v=w.doc.resolve(b+2*o.length);v.nodeAfter&&v.nodeAfter.type==a.type&&tl(w.doc,v.pos)&&w.join(v.pos),n(w.scrollIntoView())}return!0}let f=i.type.spec.isolating||r>0&&u?null:ft.findFrom(e,1),m=f&&f.$from.blockRange(f.$to),x=m&&yd(m);if(x!=null&&x>=e.depth)return n&&n(t.tr.lift(m,x).scrollIntoView()),!0;if(h&&ad(i,"start",!0)&&ad(a,"end")){let b=a,N=[];for(;N.push(b),!b.isTextblock;)b=b.lastChild;let w=i,v=1;for(;!w.isTextblock;w=w.firstChild)v++;if(b.canReplace(b.childCount,b.childCount,w.content)){if(n){let k=Ce.empty;for(let C=N.length-1;C>=0;C--)k=Ce.from(N[C].copy(k));let T=t.tr.step(new gs(e.pos-N.length,e.pos+i.nodeSize,e.pos+v,e.pos+i.nodeSize-v,new ze(k,N.length,0),0,!0));n(T.scrollIntoView())}return!0}}return!1}function zS(t){return function(e,n){let r=e.selection,a=t<0?r.$from:r.$to,i=a.depth;for(;a.node(i).isInline;){if(!i)return!1;i--}return a.node(i).isTextblock?(n&&n(e.tr.setSelection(ot.create(e.doc,t<0?a.start(i):a.end(i)))),!0):!1}}const X6=zS(-1),Z6=zS(1);function eL(t,e=null){return function(n,r){let{$from:a,$to:i}=n.selection,o=a.blockRange(i),c=o&&yy(o,t,e);return c?(r&&r(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function RN(t,e=null){return function(n,r){let a=!1;for(let i=0;i{if(a)return!1;if(!(!u.isTextblock||u.hasMarkup(t,e)))if(u.type==t)a=!0;else{let f=n.doc.resolve(h),m=f.index();a=f.parent.canReplaceWith(m,m+1,t)}})}if(!a)return!1;if(r){let i=n.tr;for(let o=0;o=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let u=o.resolve(e.start-2);i=new Uf(u,u,e.depth),e.endIndex=0;f--)i=Ce.from(n[f].type.create(n[f].attrs,i));t.step(new gs(e.start-(r?2:0),e.end,e.start,e.end,new ze(i,0,0),n.length,!0));let o=0;for(let f=0;fo.childCount>0&&o.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?aL(e,n,t,i):iL(e,n,i):!0:!1}}function aL(t,e,n,r){let a=t.tr,i=r.end,o=r.$to.end(r.depth);iw;N--)b-=a.child(N).nodeSize,r.delete(b-1,b+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let c=n.startIndex==0,u=n.endIndex==a.childCount,h=i.node(-1),f=i.index(-1);if(!h.canReplace(f+(c?0:1),f+1,o.content.append(u?Ce.empty:Ce.from(a))))return!1;let m=i.pos,x=m+o.nodeSize;return r.step(new gs(m-(c?1:0),x+(u?1:0),m+1,x-1,new ze((c?Ce.empty:Ce.from(a.copy(Ce.empty))).append(u?Ce.empty:Ce.from(a.copy(Ce.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function oL(t){return function(e,n){let{$from:r,$to:a}=e.selection,i=r.blockRange(a,h=>h.childCount>0&&h.firstChild.type==t);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let c=i.parent,u=c.child(o-1);if(u.type!=t)return!1;if(n){let h=u.lastChild&&u.lastChild.type==c.type,f=Ce.from(h?t.create():null),m=new ze(Ce.from(t.create(null,Ce.from(c.type.create(null,f)))),h?3:1,0),x=i.start,b=i.end;n(e.tr.step(new gs(x-(h?3:1),b,x,b,m,1,!0)).scrollIntoView())}return!0}}const Ss=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},id=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let o0=null;const Ti=function(t,e,n){let r=o0||(o0=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},lL=function(){o0=null},Gl=function(t,e,n,r){return n&&(LN(t,e,n,r,-1)||LN(t,e,n,r,1))},cL=/^(img|br|input|textarea|hr)$/i;function LN(t,e,n,r,a){for(var i;;){if(t==n&&e==r)return!0;if(e==(a<0?0:qr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Ju(t)||cL.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ss(t)+(a<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(a<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=a;else return!1;else t=o,e=a<0?qr(t):0}else return!1}}function qr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function dL(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=qr(t)}else if(t.parentNode&&!Ju(t))e=Ss(t),t=t.parentNode;else return null}}function uL(t,e){for(;;){if(t.nodeType==3&&e2),Kr=od||(Ga?/Mac/.test(Ga.platform):!1),VS=Ga?/Win/.test(Ga.platform):!1,Oi=/Android \d/.test(nl),Qu=!!ON&&"webkitFontSmoothing"in ON.documentElement.style,mL=Qu?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function xL(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function ji(t,e){return typeof t=="number"?t:t[e]}function gL(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function DN(t,e,n){let r=t.someProp("scrollThreshold")||0,a=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=id(o);continue}let c=o,u=c==i.body,h=u?xL(i):gL(c),f=0,m=0;if(e.toph.bottom-ji(r,"bottom")&&(m=e.bottom-e.top>h.bottom-h.top?e.top+ji(a,"top")-h.top:e.bottom-h.bottom+ji(a,"bottom")),e.lefth.right-ji(r,"right")&&(f=e.right-h.right+ji(a,"right")),f||m)if(u)i.defaultView.scrollBy(f,m);else{let b=c.scrollLeft,N=c.scrollTop;m&&(c.scrollTop+=m),f&&(c.scrollLeft+=f);let w=c.scrollLeft-b,v=c.scrollTop-N;e={left:e.left-w,top:e.top-v,right:e.right-w,bottom:e.bottom-v}}let x=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(x))break;o=x=="absolute"?o.offsetParent:id(o)}}function yL(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,a;for(let i=(e.left+e.right)/2,o=n+1;o=n-20){r=c,a=u.top;break}}return{refDOM:r,refTop:a,stack:HS(t.dom)}}function HS(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=id(r));return e}function bL({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;US(n,r==0?0:r-e)}function US(t,e){for(let n=0;n=c){o=Math.max(N.bottom,o),c=Math.min(N.top,c);let w=N.left>e.left?N.left-e.left:N.right=(N.left+N.right)/2?1:0));continue}}else N.top>e.top&&!u&&N.left<=e.left&&N.right>=e.left&&(u=f,h={left:Math.max(N.left,Math.min(N.right,e.left)),top:N.top});!n&&(e.left>=N.right&&e.top>=N.top||e.left>=N.left&&e.top>=N.bottom)&&(i=m+1)}}return!n&&u&&(n=u,a=h,r=0),n&&n.nodeType==3?NL(n,a):!n||r&&n.nodeType==1?{node:t,offset:i}:WS(n,a)}function NL(t,e){let n=t.nodeValue.length,r=document.createRange(),a;for(let i=0;i=(o.left+o.right)/2?1:0)};break}}return r.detach(),a||{node:t,offset:0}}function Cy(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function wL(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,a,i)}function kL(t,e,n,r){let a=-1;for(let i=e,o=!1;i!=t.dom;){let c=t.docView.nearestDesc(i,!0),u;if(!c)return null;if(c.dom.nodeType==1&&(c.node.isBlock&&c.parent||!c.contentDOM)&&((u=c.dom.getBoundingClientRect()).width||u.height)&&(c.node.isBlock&&c.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(c.dom.nodeName)&&(!o&&u.left>r.left||u.top>r.top?a=c.posBefore:(!o&&u.right-1?a:t.docView.posFromDOM(e,n,-1)}function KS(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&a++}let h;Qu&&a&&r.nodeType==1&&(h=r.childNodes[a-1]).nodeType==1&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=e.top&&a--,r==t.dom&&a==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?c=t.state.doc.content.size:(a==0||r.nodeType!=1||r.childNodes[a-1].nodeName!="BR")&&(c=kL(t,r,a,e))}c==null&&(c=jL(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function _N(t){return t.top=0&&a==r.nodeValue.length?(u--,f=1):n<0?u--:h++,ru(No(Ti(r,u,h),f),f<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&a&&(n<0||a==qr(r))){let u=r.childNodes[a-1];if(u.nodeType==1)return og(u.getBoundingClientRect(),!1)}if(i==null&&a=0)}if(i==null&&a&&(n<0||a==qr(r))){let u=r.childNodes[a-1],h=u.nodeType==3?Ti(u,qr(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(h)return ru(No(h,1),!1)}if(i==null&&a=0)}function ru(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function og(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function GS(t,e,n){let r=t.state,a=t.root.activeElement;r!=e&&t.updateState(e),a!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),a!=t.dom&&a&&a.focus()}}function EL(t,e,n){let r=e.selection,a=n=="up"?r.$from:r.$to;return GS(t,e,()=>{let{node:i}=t.docView.domFromPos(a.pos,n=="up"?-1:1);for(;;){let c=t.docView.nearestDesc(i,!0);if(!c)break;if(c.node.isBlock){i=c.contentDOM||c.dom;break}i=c.dom.parentNode}let o=qS(t,a.pos,1);for(let c=i.firstChild;c;c=c.nextSibling){let u;if(c.nodeType==1)u=c.getClientRects();else if(c.nodeType==3)u=Ti(c,0,c.nodeValue.length).getClientRects();else continue;for(let h=0;hf.top+1&&(n=="up"?o.top-f.top>(f.bottom-o.top)*2:f.bottom-o.bottom>(o.bottom-f.top)*2))return!1}}return!0})}const TL=/[\u0590-\u08ac]/;function ML(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let a=r.parentOffset,i=!a,o=a==r.parent.content.size,c=t.domSelection();return c?!TL.test(r.parent.textContent)||!c.modify?n=="left"||n=="backward"?i:o:GS(t,e,()=>{let{focusNode:u,focusOffset:h,anchorNode:f,anchorOffset:m}=t.domSelectionRange(),x=c.caretBidiLevel;c.modify("move",n,"character");let b=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:N,focusOffset:w}=t.domSelectionRange(),v=N&&!b.contains(N.nodeType==1?N:N.parentNode)||u==N&&h==w;try{c.collapse(f,m),u&&(u!=f||h!=m)&&c.extend&&c.extend(u,h)}catch{}return x!=null&&(c.caretBidiLevel=x),v}):r.pos==r.start()||r.pos==r.end()}let $N=null,zN=null,FN=!1;function AL(t,e,n){return $N==e&&zN==n?FN:($N=e,zN=n,FN=n=="up"||n=="down"?EL(t,e,n):ML(t,e,n))}const Jr=0,BN=1,Il=2,Ja=3;class Yu{constructor(e,n,r,a){this.parent=e,this.children=n,this.dom=r,this.contentDOM=a,this.dirty=Jr,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nSs(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){a=!1;break}if(i.previousSibling)break}if(a==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){a=!0;break}if(i.nextSibling)break}}return a??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,a=e;a;a=a.parentNode){let i=this.getDesc(a),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let a=e;a;a=a.parentNode){let i=this.getDesc(a);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||o instanceof QS){a=e-i;break}i=c}if(a)return this.children[r].domFromPos(a-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof JS&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?Ss(i.dom)+1:0}}else{let i,o=!0;for(;i=r=f&&n<=h-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,n,f);e=o;for(let m=c;m>0;m--){let x=this.children[m-1];if(x.size&&x.dom.parentNode==this.contentDOM&&!x.emptyChildAt(1)){a=Ss(x.dom)+1;break}e-=x.size}a==-1&&(a=0)}if(a>-1&&(h>n||c==this.children.length-1)){n=h;for(let f=c+1;fN&&on){let N=c;c=u,u=N}let b=document.createRange();b.setEnd(u.node,u.offset),b.setStart(c.node,c.offset),h.removeAllRanges(),h.addRange(b)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,a=0;a=r:er){let c=r+i.border,u=o-i.border;if(e>=c&&n<=u){this.dirty=e==r||n==o?Il:BN,e==c&&n==u&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ja:i.markDirty(e-c,n-c);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Il:Ja}r=o}this.dirty=Il}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Il:BN;n.dirty{if(!i)return a;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let c=document.createElement("span");c.appendChild(o),o=c}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==Jr&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class PL extends Yu{constructor(e,n,r,a){super(e,[],n,null),this.textDOM=r,this.text=a}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Jl extends Yu{constructor(e,n,r,a,i){super(e,[],r,a),this.mark=n,this.spec=i}static create(e,n,r,a){let i=a.nodeViews[n.type.name],o=i&&i(n,a,r);return(!o||!o.dom)&&(o=nc.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Jl(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ja||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ja&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Jr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=h0(i,0,e,r));for(let c=0;c{if(!u)return o;if(u.parent)return u.parent.posBeforeChild(u)},r,a),f=h&&h.dom,m=h&&h.contentDOM;if(n.isText){if(!f)f=document.createTextNode(n.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:m}=nc.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!m&&!n.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),n.type.spec.draggable&&(f.draggable=!0));let x=f;return f=ZS(f,r,n),h?u=new IL(e,n,r,a,f,m||null,x,h,i,o+1):n.isText?new Qp(e,n,r,a,f,x,i):new Fo(e,n,r,a,f,m||null,x,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Ce.empty)}return e}matchesNode(e,n,r){return this.dirty==Jr&&e.eq(this.node)&&Kf(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,a=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,c=i&&i.pos<0,u=new LL(this,o&&o.node,e);_L(this.node,this.innerDeco,(h,f,m)=>{h.spec.marks?u.syncToMarks(h.spec.marks,r,e,f):h.type.side>=0&&!m&&u.syncToMarks(f==this.node.childCount?ln.none:this.node.child(f).marks,r,e,f),u.placeWidget(h,e,a)},(h,f,m,x)=>{u.syncToMarks(h.marks,r,e,x);let b;u.findNodeMatch(h,f,m,x)||c&&e.state.selection.from>a&&e.state.selection.to-1&&u.updateNodeAt(h,f,m,b,e)||u.updateNextNode(h,f,m,e,x,a)||u.addNode(h,f,m,e,a),a+=h.nodeSize}),u.syncToMarks([],r,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==Il)&&(o&&this.protectLocalComposition(e,o),YS(this.contentDOM,this.children,e),od&&$L(this.dom))}localCompositionInfo(e,n){let{from:r,to:a}=e.state.selection;if(!(e.state.selection instanceof ot)||rn+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,c=zL(this.node.content,o,r-n,a-n);return c<0?null:{node:i,pos:c,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:a}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new PL(this,i,n,a);e.input.compositionNodes.push(o),this.children=h0(this.children,r,r+a.length,e,o)}update(e,n,r,a){return this.dirty==Ja||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,a),!0)}updateInner(e,n,r,a){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(a,this.posAtStart),this.dirty=Jr}updateOuterDeco(e){if(Kf(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=XS(this.dom,this.nodeDOM,u0(this.outerDeco,this.node,n),u0(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function VN(t,e,n,r,a){ZS(r,e,t);let i=new Fo(void 0,t,e,n,r,r,r,a,0);return i.contentDOM&&i.updateChildren(a,0),i}class Qp extends Fo{constructor(e,n,r,a,i,o,c){super(e,n,r,a,i,null,o,c,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,a){return this.dirty==Ja||this.dirty!=Jr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Jr||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,a.trackWrites==this.nodeDOM&&(a.trackWrites=null)),this.node=e,this.dirty=Jr,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let a=this.node.cut(e,n),i=document.createTextNode(a.text);return new Qp(this.parent,a,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Ja)}get domAtom(){return!1}isText(e){return this.node.text==e}}class QS extends Yu{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Jr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class IL extends Fo{constructor(e,n,r,a,i,o,c,u,h,f){super(e,n,r,a,i,o,c,h,f),this.spec=u}update(e,n,r,a){if(this.dirty==Ja)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,a),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,a)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,a){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,a)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function YS(t,e,n){let r=t.firstChild,a=!1;for(let i=0;i>1,c=Math.min(o,e.length);for(;i-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let f=Jl.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,a){let i=-1,o;if(a>=this.preMatch.index&&(o=this.preMatch.matches[a-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))i=this.top.children.indexOf(o,this.index);else for(let c=this.index,u=Math.min(this.top.children.length,c+5);c0;){let c;for(;;)if(r){let h=n.children[r-1];if(h instanceof Jl)n=h,r=h.children.length;else{c=h,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let u=c.node;if(u){if(u!=t.child(a-1))break;--a,i.set(c,a),o.push(c)}}return{index:a,matched:i,matches:o.reverse()}}function DL(t,e){return t.type.side-e.type.side}function _L(t,e,n,r){let a=e.locals(t),i=0;if(a.length==0){for(let h=0;hi;)c.push(a[o++]);let N=i+x.nodeSize;if(x.isText){let v=N;o!v.inline):c.slice();r(x,w,e.forChild(i,x),b),i=N}}function $L(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function zL(t,e,n,r){for(let a=0,i=0;a=n){if(i>=r&&u.slice(r-e.length-c,r-c)==e)return r-e.length;let h=c=0&&h+e.length+c>=n)return c+h;if(n==r&&u.length>=r+e.length-c&&u.slice(r-c,r-c+e.length)==e)return r}}return-1}function h0(t,e,n,r,a){let i=[];for(let o=0,c=0;o=n||f<=e?i.push(u):(hn&&i.push(u.slice(n-h,u.size,r)))}return i}function Ey(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let a=t.docView.nearestDesc(n.focusNode),i=a&&a.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let c=r.resolve(o),u,h;if(Jp(n)){for(u=o;a&&!a.node;)a=a.parent;let m=a.node;if(a&&m.isAtom&&it.isSelectable(m)&&a.parent&&!(m.isInline&&hL(n.focusNode,n.focusOffset,a.dom))){let x=a.posBefore;h=new it(o==x?c:r.resolve(x))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=o,x=o;for(let b=0;b{(n.anchorNode!=r||n.anchorOffset!=a)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!eC(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function BL(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ss(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&fr&&zo<=11&&(n.disabled=!0,n.disabled=!1)}function tC(t,e){if(e instanceof it){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(qN(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else qN(t)}function qN(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ty(t,e,n,r){return t.someProp("createSelectionBetween",a=>a(t,e,n))||ot.between(e,n,r)}function GN(t){return t.editable&&!t.hasFocus()?!1:nC(t)}function nC(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function VL(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Gl(e.node,e.offset,n.anchorNode,n.anchorOffset)}function f0(t,e){let{$anchor:n,$head:r}=t.selection,a=e>0?n.max(r):n.min(r),i=a.parent.inlineContent?a.depth?t.doc.resolve(e>0?a.after():a.before()):null:a;return i&&ft.findFrom(i,e)}function wo(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function JN(t,e,n){let r=t.state.selection;if(r instanceof ot)if(n.indexOf("s")>-1){let{$head:a}=r,i=a.textOffset?null:e<0?a.nodeBefore:a.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(a.pos+i.nodeSize*(e<0?-1:1));return wo(t,new ot(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let a=f0(t.state,e);return a&&a instanceof it?wo(t,a):!1}else if(!(Kr&&n.indexOf("m")>-1)){let a=r.$head,i=a.textOffset?null:e<0?a.nodeBefore:a.nodeAfter,o;if(!i||i.isText)return!1;let c=e<0?a.pos-i.nodeSize:a.pos;return i.isAtom||(o=t.docView.descAt(c))&&!o.contentDOM?it.isSelectable(i)?wo(t,new it(e<0?t.state.doc.resolve(a.pos-i.nodeSize):a)):Qu?wo(t,new ot(t.state.doc.resolve(e<0?c:c+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof it&&r.node.isInline)return wo(t,new ot(e>0?r.$to:r.$from));{let a=f0(t.state,e);return a?wo(t,a):!1}}}function qf(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function vu(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Vc(t,e){return e<0?HL(t):UL(t)}function HL(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let a,i,o=!1;for(Gr&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(vu(c,-1))a=n,i=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(sC(n))break;{let c=n.previousSibling;for(;c&&vu(c,-1);)a=n.parentNode,i=Ss(c),c=c.previousSibling;if(c)n=c,r=qf(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?p0(t,n,r):a&&p0(t,a,i)}function UL(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let a=qf(n),i,o;for(;;)if(r{t.state==a&&Fi(t)},50)}function QN(t,e){let n=t.state.doc.resolve(e);if(!(Es||VS)&&n.parent.inlineContent){let a=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>a.top&&o1)return i.lefta.top&&o1)return i.left>a.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function YN(t,e,n){let r=t.state.selection;if(r instanceof ot&&!r.empty||n.indexOf("s")>-1||Kr&&n.indexOf("m")>-1)return!1;let{$from:a,$to:i}=r;if(!a.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=f0(t.state,e);if(o&&o instanceof it)return wo(t,o)}if(!a.parent.inlineContent){let o=e<0?a:i,c=r instanceof Tr?ft.near(o,e):ft.findFrom(o,e);return c?wo(t,c):!1}return!1}function XN(t,e){if(!(t.state.selection instanceof ot))return!0;let{$head:n,$anchor:r,empty:a}=t.state.selection;if(!n.sameParent(r))return!0;if(!a)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function ZN(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function qL(t){if(!zs||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;ZN(t,r,"true"),setTimeout(()=>ZN(t,r,"false"),20)}return!1}function GL(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function JL(t,e){let n=e.keyCode,r=GL(e);if(n==8||Kr&&n==72&&r=="c")return XN(t,-1)||Vc(t,-1);if(n==46&&!e.shiftKey||Kr&&n==68&&r=="c")return XN(t,1)||Vc(t,1);if(n==13||n==27)return!0;if(n==37||Kr&&n==66&&r=="c"){let a=n==37?QN(t,t.state.selection.from)=="ltr"?-1:1:-1;return JN(t,a,r)||Vc(t,a)}else if(n==39||Kr&&n==70&&r=="c"){let a=n==39?QN(t,t.state.selection.from)=="ltr"?1:-1:1;return JN(t,a,r)||Vc(t,a)}else{if(n==38||Kr&&n==80&&r=="c")return YN(t,-1,r)||Vc(t,-1);if(n==40||Kr&&n==78&&r=="c")return qL(t)||YN(t,1,r)||Vc(t,1);if(r==(Kr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function My(t,e){t.someProp("transformCopied",b=>{e=b(e,t)});let n=[],{content:r,openStart:a,openEnd:i}=e;for(;a>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){a--,i--;let b=r.firstChild;n.push(b.type.name,b.attrs!=b.type.defaultAttrs?b.attrs:null),r=b.content}let o=t.someProp("clipboardSerializer")||nc.fromSchema(t.state.schema),c=cC(),u=c.createElement("div");u.appendChild(o.serializeFragment(r,{document:c}));let h=u.firstChild,f,m=0;for(;h&&h.nodeType==1&&(f=lC[h.nodeName.toLowerCase()]);){for(let b=f.length-1;b>=0;b--){let N=c.createElement(f[b]);for(;u.firstChild;)N.appendChild(u.firstChild);u.appendChild(N),m++}h=u.firstChild}h&&h.nodeType==1&&h.setAttribute("data-pm-slice",`${a} ${i}${m?` -${m}`:""} ${JSON.stringify(n)}`);let x=t.someProp("clipboardTextSerializer",b=>b(e,t))||e.content.textBetween(0,e.content.size,`
`);return{dom:u,text:x,slice:e}}function rC(t,e,n,r,a){let i=a.parent.type.spec.code,o,c;if(!n&&!e)return null;let u=!!e&&(r||i||!n);if(u){if(t.someProp("transformPastedText",x=>{e=x(e,i||r,t)}),i)return c=new ze(Ce.from(t.state.schema.text(e.replace(/\r\n?/g,`
-`))),0,0),t.someProp("transformPasted",x=>{c=x(c,t,!0)}),c;let m=t.someProp("clipboardTextParser",x=>x(e,a,r,t));if(m)c=m;else{let x=a.marks(),{schema:b}=t.state,N=nc.fromSchema(b);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let v=o.appendChild(document.createElement("p"));w&&v.appendChild(N.serializeNode(b.text(w,x)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=ZL(n),Qu&&eO(o);let h=o&&o.querySelector("[data-pm-slice]"),f=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let m=+f[3];m>0;m--){let x=o.firstChild;for(;x&&x.nodeType!=1;)x=x.nextSibling;if(!x)break;o=x}if(c||(c=(t.someProp("clipboardParser")||t.someProp("domParser")||$o.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||f),context:a,ruleFromNode(x){return x.nodeName=="BR"&&!x.nextSibling&&x.parentNode&&!QL.test(x.parentNode.nodeName)?{ignore:!0}:null}})),f)c=tO(ew(c,+f[1],+f[2]),f[4]);else if(c=ze.maxOpen(YL(c.content,a),!0),c.openStart||c.openEnd){let m=0,x=0;for(let b=c.content.firstChild;m{c=m(c,t,u)}),c}const QL=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function YL(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let a=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(c=>{if(!o)return;let u=a.findWrapping(c.type),h;if(!u)return o=null;if(h=o.length&&i.length&&iC(u,i,c,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=oC(o[o.length-1],i.length));let f=aC(c,u);o.push(f),a=a.matchType(f.type),i=u}}),o)return Ce.from(o)}return t}function aC(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Ce.from(t));return t}function iC(t,e,n,r,a){if(a1&&(i=0),a=n&&(c=e<0?o.contentMatchAt(0).fillBefore(c,i<=a).append(c):c.append(o.contentMatchAt(o.childCount).fillBefore(Ce.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(c))}function ew(t,e,n){return en})),cg.createHTML(t)):t}function ZL(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=cC().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),a;if((a=r&&lC[r[1].toLowerCase()])&&(t=a.map(i=>"<"+i+">").join("")+t+a.map(i=>""+i+">").reverse().join("")),n.innerHTML=XL(t),a)for(let i=0;i=0;c-=2){let u=n.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;a=Ce.from(u.create(r[c+1],a)),i++,o++}return new ze(a,i,o)}const Gs={},Js={},nO={touchstart:!0,touchmove:!0};class sO{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function rO(t){for(let e in Gs){let n=Gs[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{iO(t,r)&&!Ay(t,r)&&(t.editable||!(r.type in Js))&&n(t,r)},nO[e]?{passive:!0}:void 0)}zs&&t.dom.addEventListener("input",()=>null),x0(t)}function Lo(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function aO(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function x0(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Ay(t,r))})}function Ay(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function iO(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function oO(t,e){!Ay(t,e)&&Gs[e.type]&&(t.editable||!(e.type in Js))&&Gs[e.type](t,e)}Js.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!uC(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Oi&&Es&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),od&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",a=>a(t,Pl(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||JL(t,n)?n.preventDefault():Lo(t,"key")};Js.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Js.keypress=(t,e)=>{let n=e;if(uC(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Kr&&n.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof ot)||!r.$from.sameParent(r.$to)){let a=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(a).scrollIntoView();!/[\r\n]/.test(a)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,a,i))&&t.dispatch(i()),n.preventDefault()}};function Yp(t){return{left:t.clientX,top:t.clientY}}function lO(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Py(t,e,n,r,a){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,c=>o>i.depth?c(t,n,i.nodeAfter,i.before(o),a,!0):c(t,n,i.node(o),i.before(o),a,!1)))return!0;return!1}function td(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function cO(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&it.isSelectable(r)?(td(t,new it(n)),!0):!1}function dO(t,e){if(e==-1)return!1;let n=t.state.selection,r,a;n instanceof it&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let c=o>i.depth?i.nodeAfter:i.node(o);if(it.isSelectable(c)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?a=i.before(n.$from.depth):a=i.before(o);break}}return a!=null?(td(t,it.create(t.state.doc,a)),!0):!1}function uO(t,e,n,r,a){return Py(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(a?dO(t,n):cO(t,n))}function hO(t,e,n,r){return Py(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",a=>a(t,e,r))}function fO(t,e,n,r){return Py(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",a=>a(t,e,r))||pO(t,n,r)}function pO(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(td(t,ot.create(r,0,r.content.size)),!0):!1;let a=r.resolve(e);for(let i=a.depth+1;i>0;i--){let o=i>a.depth?a.nodeAfter:a.node(i),c=a.before(i);if(o.inlineContent)td(t,ot.create(r,c+1,c+1+o.content.size));else if(it.isSelectable(o))td(t,it.create(r,c));else continue;return!0}}function Iy(t){return Gf(t)}const dC=Kr?"metaKey":"ctrlKey";Gs.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Iy(t),a=Date.now(),i="singleClick";a-t.input.lastClick.time<500&&lO(n,t.input.lastClick)&&!n[dC]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:a,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(Yp(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new mO(t,o,n,!!r)):(i=="doubleClick"?hO:fO)(t,o.pos,o.inside,n)?n.preventDefault():Lo(t,"pointer"))};class mO{constructor(e,n,r,a){this.view=e,this.pos=n,this.event=r,this.flushed=a,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[dC],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let f=e.state.doc.resolve(n.pos);i=f.parent,o=f.depth?f.before():0}const c=a?null:r.target,u=c?e.docView.nearestDesc(c,!0):null;this.target=u&&u.nodeDOM.nodeType==1?u.nodeDOM:null;let{selection:h}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||h instanceof it&&h.from<=o&&h.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Gr&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Lo(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Fi(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Yp(e))),this.updateAllowDefault(e),this.allowDefault||!n?Lo(this.view,"pointer"):uO(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||zs&&this.mightDrag&&!this.mightDrag.node.isAtom||Es&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(td(this.view,ft.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Lo(this.view,"pointer")}move(e){this.updateAllowDefault(e),Lo(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Gs.touchstart=t=>{t.input.lastTouch=Date.now(),Iy(t),Lo(t,"pointer")};Gs.touchmove=t=>{t.input.lastTouch=Date.now(),Lo(t,"pointer")};Gs.contextmenu=t=>Iy(t);function uC(t,e){return t.composing?!0:zs&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const xO=Oi?5e3:-1;Js.compositionstart=Js.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof ot&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Es&&VS&&gO(t)))t.markCursor=t.state.storedMarks||n.marks(),Gf(t,!0),t.markCursor=null;else if(Gf(t,!e.selection.empty),Gr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let a=r.focusNode,i=r.focusOffset;a&&a.nodeType==1&&i!=0;){let o=i<0?a.lastChild:a.childNodes[i-1];if(!o)break;if(o.nodeType==3){let c=t.domSelection();c&&c.collapse(o,o.nodeValue.length);break}else a=o,i=-1}}t.input.composing=!0}hC(t,xO)};function gO(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Js.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,hC(t,20))};function hC(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Gf(t),e))}function fC(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=bO());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function yO(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=dL(e.focusNode,e.focusOffset),r=uL(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let a=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!a||!a.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function bO(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Gf(t,e=!1){if(!(Oi&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),fC(t),e||t.docView&&t.docView.dirty){let n=Ey(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function vO(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),a=document.createRange();a.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(a),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Du=fr&&zo<15||od&&mL<604;Gs.copy=Js.cut=(t,e)=>{let n=e,r=t.state.selection,a=n.type=="cut";if(r.empty)return;let i=Du?null:n.clipboardData,o=r.content(),{dom:c,text:u}=My(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",c.innerHTML),i.setData("text/plain",u)):vO(t,c),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function NO(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function wO(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let a=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?_u(t,r.value,null,a,e):_u(t,r.textContent,r.innerHTML,a,e)},50)}function _u(t,e,n,r,a){let i=rC(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,a,i||ze.empty)))return!0;if(!i)return!1;let o=NO(i),c=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function pC(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Js.paste=(t,e)=>{let n=e;if(t.composing&&!Oi)return;let r=Du?null:n.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&_u(t,pC(r),r.getData("text/html"),a,n)?n.preventDefault():wO(t,n)};class mC{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const jO=Kr?"altKey":"ctrlKey";function xC(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[jO]}Gs.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let a=t.state.selection,i=a.empty?null:t.posAtCoords(Yp(n)),o;if(!(i&&i.pos>=a.from&&i.pos<=(a instanceof it?a.to-1:a.to))){if(r&&r.mightDrag)o=it.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let m=t.docView.nearestDesc(n.target,!0);m&&m.node.type.spec.draggable&&m!=t.docView&&(o=it.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:u,text:h,slice:f}=My(t,c);(!n.dataTransfer.files.length||!Es||BS>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Du?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Du||n.dataTransfer.setData("text/plain",h),t.dragging=new mC(f,xC(t,n),o)};Gs.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Js.dragover=Js.dragenter=(t,e)=>e.preventDefault();Js.drop=(t,e)=>{try{kO(t,e,t.dragging)}finally{t.dragging=null}};function kO(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Yp(e));if(!r)return;let a=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",b=>{i=b(i,t,!1)}):i=rC(t,pC(e.dataTransfer),Du?null:e.dataTransfer.getData("text/html"),!1,a);let o=!!(n&&xC(t,e));if(t.someProp("handleDrop",b=>b(t,e,i||ze.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let c=i?vS(t.state.doc,a.pos,i):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(o){let{node:b}=n;b?b.replace(u):u.deleteSelection()}let h=u.mapping.map(c),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,m=u.doc;if(f?u.replaceRangeWith(h,h,i.content.firstChild):u.replaceRange(h,h,i),u.doc.eq(m))return;let x=u.doc.resolve(h);if(f&&it.isSelectable(i.content.firstChild)&&x.nodeAfter&&x.nodeAfter.sameMarkup(i.content.firstChild))u.setSelection(new it(x));else{let b=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((N,w,v,k)=>b=k),u.setSelection(Ty(t,x,u.doc.resolve(b)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}Gs.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Fi(t)},20))};Gs.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Gs.beforeinput=(t,e)=>{if(Es&&Oi&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,Pl(8,"Backspace")))))return;let{$cursor:a}=t.state.selection;a&&a.pos>0&&t.dispatch(t.state.tr.delete(a.pos-1,a.pos).scrollIntoView())},50)}};for(let t in Js)Gs[t]=Js[t];function $u(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Jf{constructor(e,n){this.toDOM=e,this.spec=n||$l,this.side=this.spec.side||0}map(e,n,r,a){let{pos:i,deleted:o}=e.mapResult(n.from+a,this.side<0?-1:1);return o?null:new ss(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Jf&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&$u(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Bo{constructor(e,n){this.attrs=e,this.spec=n||$l}map(e,n,r,a){let i=e.map(n.from+a,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+a,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new ss(i,o,this)}valid(e,n){return n.from=e&&(!i||i(c.spec))&&r.push(c.copy(c.from+a,c.to+a))}for(let o=0;o