@whispering233/ai-editor-server 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
1
+ function QN(n,o){for(var r=0;r<o.length;r++){const l=o[r];if(typeof l!="string"&&!Array.isArray(l)){for(const c in l)if(c!=="default"&&!(c in n)){const d=Object.getOwnPropertyDescriptor(l,c);d&&Object.defineProperty(n,c,d.get?d:{enumerable:!0,get:()=>l[c]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))l(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const m of d.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&l(m)}).observe(document,{childList:!0,subtree:!0});function r(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function l(c){if(c.ep)return;c.ep=!0;const d=r(c);fetch(c.href,d)}})();function Kv(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Of={exports:{}},vl={};var Vb;function ZN(){if(Vb)return vl;Vb=1;var n=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function r(l,c,d){var m=null;if(d!==void 0&&(m=""+d),c.key!==void 0&&(m=""+c.key),"key"in c){d={};for(var g in c)g!=="key"&&(d[g]=c[g])}else d=c;return c=d.ref,{$$typeof:n,type:l,key:m,ref:c!==void 0?c:null,props:d}}return vl.Fragment=o,vl.jsx=r,vl.jsxs=r,vl}var Fb;function JN(){return Fb||(Fb=1,Of.exports=ZN()),Of.exports}var i=JN(),kf={exports:{}},it={};var Gb;function WN(){if(Gb)return it;Gb=1;var n=Symbol.for("react.transitional.element"),o=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),m=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),S=Symbol.iterator;function j(z){return z===null||typeof z!="object"?null:(z=S&&z[S]||z["@@iterator"],typeof z=="function"?z:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},M=Object.assign,O={};function N(z,X,I){this.props=z,this.context=X,this.refs=O,this.updater=I||E}N.prototype.isReactComponent={},N.prototype.setState=function(z,X){if(typeof z!="object"&&typeof z!="function"&&z!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,z,X,"setState")},N.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function T(){}T.prototype=N.prototype;function k(z,X,I){this.props=z,this.context=X,this.refs=O,this.updater=I||E}var C=k.prototype=new T;C.constructor=k,M(C,N.prototype),C.isPureReactComponent=!0;var U=Array.isArray;function A(){}var L={H:null,A:null,T:null,S:null},_=Object.prototype.hasOwnProperty;function K(z,X,I){var V=I.ref;return{$$typeof:n,type:z,key:X,ref:V!==void 0?V:null,props:I}}function W(z,X){return K(z.type,X,z.props)}function ue(z){return typeof z=="object"&&z!==null&&z.$$typeof===n}function ne(z){var X={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(I){return X[I]})}var $=/\/+/g;function oe(z,X){return typeof z=="object"&&z!==null&&z.key!=null?ne(""+z.key):X.toString(36)}function q(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(A,A):(z.status="pending",z.then(function(X){z.status==="pending"&&(z.status="fulfilled",z.value=X)},function(X){z.status==="pending"&&(z.status="rejected",z.reason=X)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function w(z,X,I,V,Q){var Y=typeof z;(Y==="undefined"||Y==="boolean")&&(z=null);var fe=!1;if(z===null)fe=!0;else switch(Y){case"bigint":case"string":case"number":fe=!0;break;case"object":switch(z.$$typeof){case n:case o:fe=!0;break;case v:return fe=z._init,w(fe(z._payload),X,I,V,Q)}}if(fe)return Q=Q(z),fe=V===""?"."+oe(z,0):V,U(Q)?(I="",fe!=null&&(I=fe.replace($,"$&/")+"/"),w(Q,X,I,"",function(_e){return _e})):Q!=null&&(ue(Q)&&(Q=W(Q,I+(Q.key==null||z&&z.key===Q.key?"":(""+Q.key).replace($,"$&/")+"/")+fe)),X.push(Q)),1;fe=0;var re=V===""?".":V+":";if(U(z))for(var de=0;de<z.length;de++)V=z[de],Y=re+oe(V,de),fe+=w(V,X,I,Y,Q);else if(de=j(z),typeof de=="function")for(z=de.call(z),de=0;!(V=z.next()).done;)V=V.value,Y=re+oe(V,de++),fe+=w(V,X,I,Y,Q);else if(Y==="object"){if(typeof z.then=="function")return w(q(z),X,I,V,Q);throw X=String(z),Error("Objects are not valid as a React child (found: "+(X==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":X)+"). If you meant to render a collection of children, use an array instead.")}return fe}function D(z,X,I){if(z==null)return z;var V=[],Q=0;return w(z,V,"","",function(Y){return X.call(I,Y,Q++)}),V}function H(z){if(z._status===-1){var X=z._result;X=X(),X.then(function(I){(z._status===0||z._status===-1)&&(z._status=1,z._result=I)},function(I){(z._status===0||z._status===-1)&&(z._status=2,z._result=I)}),z._status===-1&&(z._status=0,z._result=X)}if(z._status===1)return z._result.default;throw z._result}var B=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var X=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof z=="object"&&z!==null&&typeof z.message=="string"?String(z.message):String(z),error:z});if(!window.dispatchEvent(X))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},P={map:D,forEach:function(z,X,I){D(z,function(){X.apply(this,arguments)},I)},count:function(z){var X=0;return D(z,function(){X++}),X},toArray:function(z){return D(z,function(X){return X})||[]},only:function(z){if(!ue(z))throw Error("React.Children.only expected to receive a single React element child.");return z}};return it.Activity=x,it.Children=P,it.Component=N,it.Fragment=r,it.Profiler=c,it.PureComponent=k,it.StrictMode=l,it.Suspense=b,it.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=L,it.__COMPILER_RUNTIME={__proto__:null,c:function(z){return L.H.useMemoCache(z)}},it.cache=function(z){return function(){return z.apply(null,arguments)}},it.cacheSignal=function(){return null},it.cloneElement=function(z,X,I){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var V=M({},z.props),Q=z.key;if(X!=null)for(Y in X.key!==void 0&&(Q=""+X.key),X)!_.call(X,Y)||Y==="key"||Y==="__self"||Y==="__source"||Y==="ref"&&X.ref===void 0||(V[Y]=X[Y]);var Y=arguments.length-2;if(Y===1)V.children=I;else if(1<Y){for(var fe=Array(Y),re=0;re<Y;re++)fe[re]=arguments[re+2];V.children=fe}return K(z.type,Q,V)},it.createContext=function(z){return z={$$typeof:m,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null},z.Provider=z,z.Consumer={$$typeof:d,_context:z},z},it.createElement=function(z,X,I){var V,Q={},Y=null;if(X!=null)for(V in X.key!==void 0&&(Y=""+X.key),X)_.call(X,V)&&V!=="key"&&V!=="__self"&&V!=="__source"&&(Q[V]=X[V]);var fe=arguments.length-2;if(fe===1)Q.children=I;else if(1<fe){for(var re=Array(fe),de=0;de<fe;de++)re[de]=arguments[de+2];Q.children=re}if(z&&z.defaultProps)for(V in fe=z.defaultProps,fe)Q[V]===void 0&&(Q[V]=fe[V]);return K(z,Y,Q)},it.createRef=function(){return{current:null}},it.forwardRef=function(z){return{$$typeof:g,render:z}},it.isValidElement=ue,it.lazy=function(z){return{$$typeof:v,_payload:{_status:-1,_result:z},_init:H}},it.memo=function(z,X){return{$$typeof:p,type:z,compare:X===void 0?null:X}},it.startTransition=function(z){var X=L.T,I={};L.T=I;try{var V=z(),Q=L.S;Q!==null&&Q(I,V),typeof V=="object"&&V!==null&&typeof V.then=="function"&&V.then(A,B)}catch(Y){B(Y)}finally{X!==null&&I.types!==null&&(X.types=I.types),L.T=X}},it.unstable_useCacheRefresh=function(){return L.H.useCacheRefresh()},it.use=function(z){return L.H.use(z)},it.useActionState=function(z,X,I){return L.H.useActionState(z,X,I)},it.useCallback=function(z,X){return L.H.useCallback(z,X)},it.useContext=function(z){return L.H.useContext(z)},it.useDebugValue=function(){},it.useDeferredValue=function(z,X){return L.H.useDeferredValue(z,X)},it.useEffect=function(z,X){return L.H.useEffect(z,X)},it.useEffectEvent=function(z){return L.H.useEffectEvent(z)},it.useId=function(){return L.H.useId()},it.useImperativeHandle=function(z,X,I){return L.H.useImperativeHandle(z,X,I)},it.useInsertionEffect=function(z,X){return L.H.useInsertionEffect(z,X)},it.useLayoutEffect=function(z,X){return L.H.useLayoutEffect(z,X)},it.useMemo=function(z,X){return L.H.useMemo(z,X)},it.useOptimistic=function(z,X){return L.H.useOptimistic(z,X)},it.useReducer=function(z,X,I){return L.H.useReducer(z,X,I)},it.useRef=function(z){return L.H.useRef(z)},it.useState=function(z){return L.H.useState(z)},it.useSyncExternalStore=function(z,X,I){return L.H.useSyncExternalStore(z,X,I)},it.useTransition=function(){return L.H.useTransition()},it.version="19.2.8",it}var qb;function Xl(){return qb||(qb=1,kf.exports=WN()),kf.exports}var h=Xl();const Ae=Kv(h),ej=QN({__proto__:null,default:Ae},[h]);var _f={exports:{}},Sl={},Mf={exports:{}},Af={};var $b;function tj(){return $b||($b=1,(function(n){function o(w,D){var H=w.length;w.push(D);e:for(;0<H;){var B=H-1>>>1,P=w[B];if(0<c(P,D))w[B]=D,w[H]=P,H=B;else break e}}function r(w){return w.length===0?null:w[0]}function l(w){if(w.length===0)return null;var D=w[0],H=w.pop();if(H!==D){w[0]=H;e:for(var B=0,P=w.length,z=P>>>1;B<z;){var X=2*(B+1)-1,I=w[X],V=X+1,Q=w[V];if(0>c(I,H))V<P&&0>c(Q,I)?(w[B]=Q,w[V]=H,B=V):(w[B]=I,w[X]=H,B=X);else if(V<P&&0>c(Q,H))w[B]=Q,w[V]=H,B=V;else break e}}return D}function c(w,D){var H=w.sortIndex-D.sortIndex;return H!==0?H:w.id-D.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;n.unstable_now=function(){return d.now()}}else{var m=Date,g=m.now();n.unstable_now=function(){return m.now()-g}}var b=[],p=[],v=1,x=null,S=3,j=!1,E=!1,M=!1,O=!1,N=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function C(w){for(var D=r(p);D!==null;){if(D.callback===null)l(p);else if(D.startTime<=w)l(p),D.sortIndex=D.expirationTime,o(b,D);else break;D=r(p)}}function U(w){if(M=!1,C(w),!E)if(r(b)!==null)E=!0,A||(A=!0,ne());else{var D=r(p);D!==null&&q(U,D.startTime-w)}}var A=!1,L=-1,_=5,K=-1;function W(){return O?!0:!(n.unstable_now()-K<_)}function ue(){if(O=!1,A){var w=n.unstable_now();K=w;var D=!0;try{e:{E=!1,M&&(M=!1,T(L),L=-1),j=!0;var H=S;try{t:{for(C(w),x=r(b);x!==null&&!(x.expirationTime>w&&W());){var B=x.callback;if(typeof B=="function"){x.callback=null,S=x.priorityLevel;var P=B(x.expirationTime<=w);if(w=n.unstable_now(),typeof P=="function"){x.callback=P,C(w),D=!0;break t}x===r(b)&&l(b),C(w)}else l(b);x=r(b)}if(x!==null)D=!0;else{var z=r(p);z!==null&&q(U,z.startTime-w),D=!1}}break e}finally{x=null,S=H,j=!1}D=void 0}}finally{D?ne():A=!1}}}var ne;if(typeof k=="function")ne=function(){k(ue)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,oe=$.port2;$.port1.onmessage=ue,ne=function(){oe.postMessage(null)}}else ne=function(){N(ue,0)};function q(w,D){L=N(function(){w(n.unstable_now())},D)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(w){w.callback=null},n.unstable_forceFrameRate=function(w){0>w||125<w?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):_=0<w?Math.floor(1e3/w):5},n.unstable_getCurrentPriorityLevel=function(){return S},n.unstable_next=function(w){switch(S){case 1:case 2:case 3:var D=3;break;default:D=S}var H=S;S=D;try{return w()}finally{S=H}},n.unstable_requestPaint=function(){O=!0},n.unstable_runWithPriority=function(w,D){switch(w){case 1:case 2:case 3:case 4:case 5:break;default:w=3}var H=S;S=w;try{return D()}finally{S=H}},n.unstable_scheduleCallback=function(w,D,H){var B=n.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?B+H:B):H=B,w){case 1:var P=-1;break;case 2:P=250;break;case 5:P=1073741823;break;case 4:P=1e4;break;default:P=5e3}return P=H+P,w={id:v++,callback:D,priorityLevel:w,startTime:H,expirationTime:P,sortIndex:-1},H>B?(w.sortIndex=H,o(p,w),r(b)===null&&w===r(p)&&(M?(T(L),L=-1):M=!0,q(U,H-B))):(w.sortIndex=P,o(b,w),E||j||(E=!0,A||(A=!0,ne()))),w},n.unstable_shouldYield=W,n.unstable_wrapCallback=function(w){var D=S;return function(){var H=S;S=D;try{return w.apply(this,arguments)}finally{S=H}}}})(Af)),Af}var Xb;function nj(){return Xb||(Xb=1,Mf.exports=tj()),Mf.exports}var Df={exports:{}},vn={};var Kb;function sj(){if(Kb)return vn;Kb=1;var n=Xl();function o(b){var p="https://react.dev/errors/"+b;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var v=2;v<arguments.length;v++)p+="&args[]="+encodeURIComponent(arguments[v])}return"Minified React error #"+b+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var l={d:{f:r,r:function(){throw Error(o(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},c=Symbol.for("react.portal");function d(b,p,v){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:c,key:x==null?null:""+x,children:b,containerInfo:p,implementation:v}}var m=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function g(b,p){if(b==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return vn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=l,vn.createPortal=function(b,p){var v=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(o(299));return d(b,p,null,v)},vn.flushSync=function(b){var p=m.T,v=l.p;try{if(m.T=null,l.p=2,b)return b()}finally{m.T=p,l.p=v,l.d.f()}},vn.preconnect=function(b,p){typeof b=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,l.d.C(b,p))},vn.prefetchDNS=function(b){typeof b=="string"&&l.d.D(b)},vn.preinit=function(b,p){if(typeof b=="string"&&p&&typeof p.as=="string"){var v=p.as,x=g(v,p.crossOrigin),S=typeof p.integrity=="string"?p.integrity:void 0,j=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;v==="style"?l.d.S(b,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:x,integrity:S,fetchPriority:j}):v==="script"&&l.d.X(b,{crossOrigin:x,integrity:S,fetchPriority:j,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},vn.preinitModule=function(b,p){if(typeof b=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var v=g(p.as,p.crossOrigin);l.d.M(b,{crossOrigin:v,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&l.d.M(b)},vn.preload=function(b,p){if(typeof b=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var v=p.as,x=g(v,p.crossOrigin);l.d.L(b,v,{crossOrigin:x,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},vn.preloadModule=function(b,p){if(typeof b=="string")if(p){var v=g(p.as,p.crossOrigin);l.d.m(b,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:v,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else l.d.m(b)},vn.requestFormReset=function(b){l.d.r(b)},vn.unstable_batchedUpdates=function(b,p){return b(p)},vn.useFormState=function(b,p,v){return m.H.useFormState(b,p,v)},vn.useFormStatus=function(){return m.H.useHostTransitionStatus()},vn.version="19.2.8",vn}var Qb;function Qv(){if(Qb)return Df.exports;Qb=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(o){console.error(o)}}return n(),Df.exports=sj(),Df.exports}var Zb;function oj(){if(Zb)return Sl;Zb=1;var n=nj(),o=Xl(),r=Qv();function l(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function d(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function m(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function g(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function b(e){if(d(e)!==e)throw Error(l(188))}function p(e){var t=e.alternate;if(!t){if(t=d(e),t===null)throw Error(l(188));return t!==e?null:e}for(var s=e,a=t;;){var u=s.return;if(u===null)break;var f=u.alternate;if(f===null){if(a=u.return,a!==null){s=a;continue}break}if(u.child===f.child){for(f=u.child;f;){if(f===s)return b(u),e;if(f===a)return b(u),t;f=f.sibling}throw Error(l(188))}if(s.return!==a.return)s=u,a=f;else{for(var y=!1,R=u.child;R;){if(R===s){y=!0,s=u,a=f;break}if(R===a){y=!0,a=u,s=f;break}R=R.sibling}if(!y){for(R=f.child;R;){if(R===s){y=!0,s=f,a=u;break}if(R===a){y=!0,a=f,s=u;break}R=R.sibling}if(!y)throw Error(l(189))}}if(s.alternate!==a)throw Error(l(190))}if(s.tag!==3)throw Error(l(188));return s.stateNode.current===s?e:t}function v(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=v(e),t!==null)return t;e=e.sibling}return null}var x=Object.assign,S=Symbol.for("react.element"),j=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),k=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),U=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),W=Symbol.for("react.memo_cache_sentinel"),ue=Symbol.iterator;function ne(e){return e===null||typeof e!="object"?null:(e=ue&&e[ue]||e["@@iterator"],typeof e=="function"?e:null)}var $=Symbol.for("react.client.reference");function oe(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===$?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case M:return"Fragment";case N:return"Profiler";case O:return"StrictMode";case U:return"Suspense";case A:return"SuspenseList";case K:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case E:return"Portal";case k:return e.displayName||"Context";case T:return(e._context.displayName||"Context")+".Consumer";case C:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case L:return t=e.displayName||null,t!==null?t:oe(e.type)||"Memo";case _:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}var q=Array.isArray,w=o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H={pending:!1,data:null,method:null,action:null},B=[],P=-1;function z(e){return{current:e}}function X(e){0>P||(e.current=B[P],B[P]=null,P--)}function I(e,t){P++,B[P]=e.current,e.current=t}var V=z(null),Q=z(null),Y=z(null),fe=z(null);function re(e,t){switch(I(Y,t),I(Q,e),I(V,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?fb(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=fb(t),e=mb(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}X(V),I(V,e)}function de(){X(V),X(Q),X(Y)}function _e(e){e.memoizedState!==null&&I(fe,e);var t=V.current,s=mb(t,e.type);t!==s&&(I(Q,e),I(V,s))}function Ye(e){Q.current===e&&(X(V),X(Q)),fe.current===e&&(X(fe),gl._currentValue=H)}var Re,Le;function He(e){if(Re===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);Re=t&&t[1]||"",Le=-1<s.stack.indexOf(`
2
+ at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
3
+ `+Re+e+Le}var ge=!1;function pe(e,t){if(!e||ge)return"";ge=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var a={DetermineComponentFrameRoot:function(){try{if(t){var Te=function(){throw Error()};if(Object.defineProperty(Te.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Te,[])}catch(me){var ce=me}Reflect.construct(e,[],Te)}else{try{Te.call()}catch(me){ce=me}e.call(Te.prototype)}}else{try{throw Error()}catch(me){ce=me}(Te=e())&&typeof Te.catch=="function"&&Te.catch(function(){})}}catch(me){if(me&&ce&&typeof me.stack=="string")return[me.stack,ce.stack]}return[null,null]}};a.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(a.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(a.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var f=a.DetermineComponentFrameRoot(),y=f[0],R=f[1];if(y&&R){var G=y.split(`
4
+ `),le=R.split(`
5
+ `);for(u=a=0;a<G.length&&!G[a].includes("DetermineComponentFrameRoot");)a++;for(;u<le.length&&!le[u].includes("DetermineComponentFrameRoot");)u++;if(a===G.length||u===le.length)for(a=G.length-1,u=le.length-1;1<=a&&0<=u&&G[a]!==le[u];)u--;for(;1<=a&&0<=u;a--,u--)if(G[a]!==le[u]){if(a!==1||u!==1)do if(a--,u--,0>u||G[a]!==le[u]){var be=`
6
+ `+G[a].replace(" at new "," at ");return e.displayName&&be.includes("<anonymous>")&&(be=be.replace("<anonymous>",e.displayName)),be}while(1<=a&&0<=u);break}}}finally{ge=!1,Error.prepareStackTrace=s}return(s=e?e.displayName||e.name:"")?He(s):""}function ve(e,t){switch(e.tag){case 26:case 27:case 5:return He(e.type);case 16:return He("Lazy");case 13:return e.child!==t&&t!==null?He("Suspense Fallback"):He("Suspense");case 19:return He("SuspenseList");case 0:case 15:return pe(e.type,!1);case 11:return pe(e.type.render,!1);case 1:return pe(e.type,!0);case 31:return He("Activity");default:return""}}function Ue(e){try{var t="",s=null;do t+=ve(e,s),s=e,e=e.return;while(e);return t}catch(a){return`
7
+ Error generating stack: `+a.message+`
8
+ `+a.stack}}var ye=Object.prototype.hasOwnProperty,De=n.unstable_scheduleCallback,Pe=n.unstable_cancelCallback,Ie=n.unstable_shouldYield,we=n.unstable_requestPaint,ee=n.unstable_now,F=n.unstable_getCurrentPriorityLevel,ie=n.unstable_ImmediatePriority,Z=n.unstable_UserBlockingPriority,Ee=n.unstable_NormalPriority,Xe=n.unstable_LowPriority,Ne=n.unstable_IdlePriority,Me=n.log,Je=n.unstable_setDisableYieldValue,nt=null,jt=null;function kt(e){if(typeof Me=="function"&&Je(e),jt&&typeof jt.setStrictMode=="function")try{jt.setStrictMode(nt,e)}catch{}}var gt=Math.clz32?Math.clz32:et,ln=Math.log,Jt=Math.LN2;function et(e){return e>>>=0,e===0?32:31-(ln(e)/Jt|0)|0}var je=256,Ce=262144,qe=4194304;function te(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function xe(e,t,s){var a=e.pendingLanes;if(a===0)return 0;var u=0,f=e.suspendedLanes,y=e.pingedLanes;e=e.warmLanes;var R=a&134217727;return R!==0?(a=R&~f,a!==0?u=te(a):(y&=R,y!==0?u=te(y):s||(s=R&~e,s!==0&&(u=te(s))))):(R=a&~f,R!==0?u=te(R):y!==0?u=te(y):s||(s=a&~e,s!==0&&(u=te(s)))),u===0?0:t!==0&&t!==u&&(t&f)===0&&(f=u&-u,s=t&-t,f>=s||f===32&&(s&4194048)!==0)?t:u}function Oe(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function We(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function rt(){var e=qe;return qe<<=1,(qe&62914560)===0&&(qe=4194304),e}function ct(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function lt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ft(e,t,s,a,u,f){var y=e.pendingLanes;e.pendingLanes=s,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=s,e.entangledLanes&=s,e.errorRecoveryDisabledLanes&=s,e.shellSuspendCounter=0;var R=e.entanglements,G=e.expirationTimes,le=e.hiddenUpdates;for(s=y&~s;0<s;){var be=31-gt(s),Te=1<<be;R[be]=0,G[be]=-1;var ce=le[be];if(ce!==null)for(le[be]=null,be=0;be<ce.length;be++){var me=ce[be];me!==null&&(me.lane&=-536870913)}s&=~Te}a!==0&&$n(e,a,0),f!==0&&u===0&&e.tag!==0&&(e.suspendedLanes|=f&~(y&~t))}function $n(e,t,s){e.pendingLanes|=t,e.suspendedLanes&=~t;var a=31-gt(t);e.entangledLanes|=t,e.entanglements[a]=e.entanglements[a]|1073741824|s&261930}function Kt(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var a=31-gt(s),u=1<<a;u&t|e[a]&t&&(e[a]|=t),s&=~u}}function pn(e,t){var s=t&-t;return s=(s&42)!==0?1:mo(s),(s&(e.suspendedLanes|t))!==0?0:s}function mo(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;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:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Ln(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function zs(){var e=D.p;return e!==0?e:(e=window.event,e===void 0?32:Lb(e.type))}function ei(e,t){var s=D.p;try{return D.p=e,t()}finally{D.p=s}}var hs=Math.random().toString(36).slice(2),sn="__reactFiber$"+hs,wn="__reactProps$"+hs,Mr="__reactContainer$"+hs,yu="__reactEvents$"+hs,US="__reactListeners$"+hs,HS="__reactHandles$"+hs,Wp="__reactResources$"+hs,_a="__reactMarker$"+hs;function vu(e){delete e[sn],delete e[wn],delete e[yu],delete e[US],delete e[HS]}function Ar(e){var t=e[sn];if(t)return t;for(var s=e.parentNode;s;){if(t=s[Mr]||s[sn]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=vb(e);e!==null;){if(s=e[sn])return s;e=vb(e)}return t}e=s,s=e.parentNode}return null}function Dr(e){if(e=e[sn]||e[Mr]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Ma(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(l(33))}function zr(e){var t=e[Wp];return t||(t=e[Wp]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function cn(e){e[_a]=!0}var eh=new Set,th={};function $o(e,t){Lr(e,t),Lr(e+"Capture",t)}function Lr(e,t){for(th[e]=t,e=0;e<t.length;e++)eh.add(t[e])}var PS=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),nh={},sh={};function YS(e){return ye.call(sh,e)?!0:ye.call(nh,e)?!1:PS.test(e)?sh[e]=!0:(nh[e]=!0,!1)}function ti(e,t,s){if(YS(t))if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var a=t.toLowerCase().slice(0,5);if(a!=="data-"&&a!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+s)}}function ni(e,t,s){if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+s)}}function Ls(e,t,s,a){if(a===null)e.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(s);return}e.setAttributeNS(t,s,""+a)}}function Xn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function oh(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function VS(e,t,s){var a=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var u=a.get,f=a.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return u.call(this)},set:function(y){s=""+y,f.call(this,y)}}),Object.defineProperty(e,t,{enumerable:a.enumerable}),{getValue:function(){return s},setValue:function(y){s=""+y},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Su(e){if(!e._valueTracker){var t=oh(e)?"checked":"value";e._valueTracker=VS(e,t,""+e[t])}}function rh(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),a="";return e&&(a=oh(e)?e.checked?"true":"false":e.value),e=a,e!==s?(t.setValue(e),!0):!1}function si(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var FS=/[\n"\\]/g;function Kn(e){return e.replace(FS,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Eu(e,t,s,a,u,f,y,R){e.name="",y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"?e.type=y:e.removeAttribute("type"),t!=null?y==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Xn(t)):e.value!==""+Xn(t)&&(e.value=""+Xn(t)):y!=="submit"&&y!=="reset"||e.removeAttribute("value"),t!=null?Nu(e,y,Xn(t)):s!=null?Nu(e,y,Xn(s)):a!=null&&e.removeAttribute("value"),u==null&&f!=null&&(e.defaultChecked=!!f),u!=null&&(e.checked=u&&typeof u!="function"&&typeof u!="symbol"),R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?e.name=""+Xn(R):e.removeAttribute("name")}function ah(e,t,s,a,u,f,y,R){if(f!=null&&typeof f!="function"&&typeof f!="symbol"&&typeof f!="boolean"&&(e.type=f),t!=null||s!=null){if(!(f!=="submit"&&f!=="reset"||t!=null)){Su(e);return}s=s!=null?""+Xn(s):"",t=t!=null?""+Xn(t):s,R||t===e.value||(e.value=t),e.defaultValue=t}a=a??u,a=typeof a!="function"&&typeof a!="symbol"&&!!a,e.checked=R?e.checked:!!a,e.defaultChecked=!!a,y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(e.name=y),Su(e)}function Nu(e,t,s){t==="number"&&si(e.ownerDocument)===e||e.defaultValue===""+s||(e.defaultValue=""+s)}function Ir(e,t,s,a){if(e=e.options,t){t={};for(var u=0;u<s.length;u++)t["$"+s[u]]=!0;for(s=0;s<e.length;s++)u=t.hasOwnProperty("$"+e[s].value),e[s].selected!==u&&(e[s].selected=u),u&&a&&(e[s].defaultSelected=!0)}else{for(s=""+Xn(s),t=null,u=0;u<e.length;u++){if(e[u].value===s){e[u].selected=!0,a&&(e[u].defaultSelected=!0);return}t!==null||e[u].disabled||(t=e[u])}t!==null&&(t.selected=!0)}}function lh(e,t,s){if(t!=null&&(t=""+Xn(t),t!==e.value&&(e.value=t),s==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=s!=null?""+Xn(s):""}function ih(e,t,s,a){if(t==null){if(a!=null){if(s!=null)throw Error(l(92));if(q(a)){if(1<a.length)throw Error(l(93));a=a[0]}s=a}s==null&&(s=""),t=s}s=Xn(t),e.defaultValue=s,a=e.textContent,a===s&&a!==""&&a!==null&&(e.value=a),Su(e)}function Br(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var GS=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function ch(e,t,s){var a=t.indexOf("--")===0;s==null||typeof s=="boolean"||s===""?a?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":a?e.setProperty(t,s):typeof s!="number"||s===0||GS.has(t)?t==="float"?e.cssFloat=s:e[t]=(""+s).trim():e[t]=s+"px"}function uh(e,t,s){if(t!=null&&typeof t!="object")throw Error(l(62));if(e=e.style,s!=null){for(var a in s)!s.hasOwnProperty(a)||t!=null&&t.hasOwnProperty(a)||(a.indexOf("--")===0?e.setProperty(a,""):a==="float"?e.cssFloat="":e[a]="");for(var u in t)a=t[u],t.hasOwnProperty(u)&&s[u]!==a&&ch(e,u,a)}else for(var f in t)t.hasOwnProperty(f)&&ch(e,f,t[f])}function ju(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var qS=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),$S=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function oi(e){return $S.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Is(){}var Tu=null;function wu(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ur=null,Hr=null;function dh(e){var t=Dr(e);if(t&&(e=t.stateNode)){var s=e[wn]||null;e:switch(e=t.stateNode,t.type){case"input":if(Eu(e,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll('input[name="'+Kn(""+t)+'"][type="radio"]'),t=0;t<s.length;t++){var a=s[t];if(a!==e&&a.form===e.form){var u=a[wn]||null;if(!u)throw Error(l(90));Eu(a,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(t=0;t<s.length;t++)a=s[t],a.form===e.form&&rh(a)}break e;case"textarea":lh(e,s.value,s.defaultValue);break e;case"select":t=s.value,t!=null&&Ir(e,!!s.multiple,t,!1)}}}var Cu=!1;function fh(e,t,s){if(Cu)return e(t,s);Cu=!0;try{var a=e(t);return a}finally{if(Cu=!1,(Ur!==null||Hr!==null)&&(Gi(),Ur&&(t=Ur,e=Hr,Hr=Ur=null,dh(t),e)))for(t=0;t<e.length;t++)dh(e[t])}}function Aa(e,t){var s=e.stateNode;if(s===null)return null;var a=s[wn]||null;if(a===null)return null;s=a[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(a=!a.disabled)||(e=e.type,a=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!a;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(l(231,t,typeof s));return s}var Bs=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ru=!1;if(Bs)try{var Da={};Object.defineProperty(Da,"passive",{get:function(){Ru=!0}}),window.addEventListener("test",Da,Da),window.removeEventListener("test",Da,Da)}catch{Ru=!1}var po=null,Ou=null,ri=null;function mh(){if(ri)return ri;var e,t=Ou,s=t.length,a,u="value"in po?po.value:po.textContent,f=u.length;for(e=0;e<s&&t[e]===u[e];e++);var y=s-e;for(a=1;a<=y&&t[s-a]===u[f-a];a++);return ri=u.slice(e,1<a?1-a:void 0)}function ai(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function li(){return!0}function ph(){return!1}function Cn(e){function t(s,a,u,f,y){this._reactName=s,this._targetInst=u,this.type=a,this.nativeEvent=f,this.target=y,this.currentTarget=null;for(var R in e)e.hasOwnProperty(R)&&(s=e[R],this[R]=s?s(f):f[R]);return this.isDefaultPrevented=(f.defaultPrevented!=null?f.defaultPrevented:f.returnValue===!1)?li:ph,this.isPropagationStopped=ph,this}return x(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=li)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=li)},persist:function(){},isPersistent:li}),t}var Xo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ii=Cn(Xo),za=x({},Xo,{view:0,detail:0}),XS=Cn(za),ku,_u,La,ci=x({},za,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Au,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==La&&(La&&e.type==="mousemove"?(ku=e.screenX-La.screenX,_u=e.screenY-La.screenY):_u=ku=0,La=e),ku)},movementY:function(e){return"movementY"in e?e.movementY:_u}}),hh=Cn(ci),KS=x({},ci,{dataTransfer:0}),QS=Cn(KS),ZS=x({},za,{relatedTarget:0}),Mu=Cn(ZS),JS=x({},Xo,{animationName:0,elapsedTime:0,pseudoElement:0}),WS=Cn(JS),eE=x({},Xo,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),tE=Cn(eE),nE=x({},Xo,{data:0}),gh=Cn(nE),sE={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},oE={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},rE={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function aE(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=rE[e])?!!t[e]:!1}function Au(){return aE}var lE=x({},za,{key:function(e){if(e.key){var t=sE[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ai(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?oE[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Au,charCode:function(e){return e.type==="keypress"?ai(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ai(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),iE=Cn(lE),cE=x({},ci,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),xh=Cn(cE),uE=x({},za,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Au}),dE=Cn(uE),fE=x({},Xo,{propertyName:0,elapsedTime:0,pseudoElement:0}),mE=Cn(fE),pE=x({},ci,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),hE=Cn(pE),gE=x({},Xo,{newState:0,oldState:0}),xE=Cn(gE),bE=[9,13,27,32],Du=Bs&&"CompositionEvent"in window,Ia=null;Bs&&"documentMode"in document&&(Ia=document.documentMode);var yE=Bs&&"TextEvent"in window&&!Ia,bh=Bs&&(!Du||Ia&&8<Ia&&11>=Ia),yh=" ",vh=!1;function Sh(e,t){switch(e){case"keyup":return bE.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Eh(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Pr=!1;function vE(e,t){switch(e){case"compositionend":return Eh(t);case"keypress":return t.which!==32?null:(vh=!0,yh);case"textInput":return e=t.data,e===yh&&vh?null:e;default:return null}}function SE(e,t){if(Pr)return e==="compositionend"||!Du&&Sh(e,t)?(e=mh(),ri=Ou=po=null,Pr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return bh&&t.locale!=="ko"?null:t.data;default:return null}}var EE={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Nh(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!EE[e.type]:t==="textarea"}function jh(e,t,s,a){Ur?Hr?Hr.push(a):Hr=[a]:Ur=a,t=Ji(t,"onChange"),0<t.length&&(s=new ii("onChange","change",null,s,a),e.push({event:s,listeners:t}))}var Ba=null,Ua=null;function NE(e){ab(e,0)}function ui(e){var t=Ma(e);if(rh(t))return e}function Th(e,t){if(e==="change")return t}var wh=!1;if(Bs){var zu;if(Bs){var Lu="oninput"in document;if(!Lu){var Ch=document.createElement("div");Ch.setAttribute("oninput","return;"),Lu=typeof Ch.oninput=="function"}zu=Lu}else zu=!1;wh=zu&&(!document.documentMode||9<document.documentMode)}function Rh(){Ba&&(Ba.detachEvent("onpropertychange",Oh),Ua=Ba=null)}function Oh(e){if(e.propertyName==="value"&&ui(Ua)){var t=[];jh(t,Ua,e,wu(e)),fh(NE,t)}}function jE(e,t,s){e==="focusin"?(Rh(),Ba=t,Ua=s,Ba.attachEvent("onpropertychange",Oh)):e==="focusout"&&Rh()}function TE(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ui(Ua)}function wE(e,t){if(e==="click")return ui(t)}function CE(e,t){if(e==="input"||e==="change")return ui(t)}function RE(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var In=typeof Object.is=="function"?Object.is:RE;function Ha(e,t){if(In(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;for(a=0;a<s.length;a++){var u=s[a];if(!ye.call(t,u)||!In(e[u],t[u]))return!1}return!0}function kh(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function _h(e,t){var s=kh(e);e=0;for(var a;s;){if(s.nodeType===3){if(a=e+s.textContent.length,e<=t&&a>=t)return{node:s,offset:t-e};e=a}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=kh(s)}}function Mh(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Mh(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ah(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=si(e.document);t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=si(e.document)}return t}function Iu(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var OE=Bs&&"documentMode"in document&&11>=document.documentMode,Yr=null,Bu=null,Pa=null,Uu=!1;function Dh(e,t,s){var a=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;Uu||Yr==null||Yr!==si(a)||(a=Yr,"selectionStart"in a&&Iu(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),Pa&&Ha(Pa,a)||(Pa=a,a=Ji(Bu,"onSelect"),0<a.length&&(t=new ii("onSelect","select",null,t,s),e.push({event:t,listeners:a}),t.target=Yr)))}function Ko(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var Vr={animationend:Ko("Animation","AnimationEnd"),animationiteration:Ko("Animation","AnimationIteration"),animationstart:Ko("Animation","AnimationStart"),transitionrun:Ko("Transition","TransitionRun"),transitionstart:Ko("Transition","TransitionStart"),transitioncancel:Ko("Transition","TransitionCancel"),transitionend:Ko("Transition","TransitionEnd")},Hu={},zh={};Bs&&(zh=document.createElement("div").style,"AnimationEvent"in window||(delete Vr.animationend.animation,delete Vr.animationiteration.animation,delete Vr.animationstart.animation),"TransitionEvent"in window||delete Vr.transitionend.transition);function Qo(e){if(Hu[e])return Hu[e];if(!Vr[e])return e;var t=Vr[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in zh)return Hu[e]=t[s];return e}var Lh=Qo("animationend"),Ih=Qo("animationiteration"),Bh=Qo("animationstart"),kE=Qo("transitionrun"),_E=Qo("transitionstart"),ME=Qo("transitioncancel"),Uh=Qo("transitionend"),Hh=new Map,Pu="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Pu.push("scrollEnd");function cs(e,t){Hh.set(e,t),$o(t,[e])}var di=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Qn=[],Fr=0,Yu=0;function fi(){for(var e=Fr,t=Yu=Fr=0;t<e;){var s=Qn[t];Qn[t++]=null;var a=Qn[t];Qn[t++]=null;var u=Qn[t];Qn[t++]=null;var f=Qn[t];if(Qn[t++]=null,a!==null&&u!==null){var y=a.pending;y===null?u.next=u:(u.next=y.next,y.next=u),a.pending=u}f!==0&&Ph(s,u,f)}}function mi(e,t,s,a){Qn[Fr++]=e,Qn[Fr++]=t,Qn[Fr++]=s,Qn[Fr++]=a,Yu|=a,e.lanes|=a,e=e.alternate,e!==null&&(e.lanes|=a)}function Vu(e,t,s,a){return mi(e,t,s,a),pi(e)}function Zo(e,t){return mi(e,null,null,t),pi(e)}function Ph(e,t,s){e.lanes|=s;var a=e.alternate;a!==null&&(a.lanes|=s);for(var u=!1,f=e.return;f!==null;)f.childLanes|=s,a=f.alternate,a!==null&&(a.childLanes|=s),f.tag===22&&(e=f.stateNode,e===null||e._visibility&1||(u=!0)),e=f,f=f.return;return e.tag===3?(f=e.stateNode,u&&t!==null&&(u=31-gt(s),e=f.hiddenUpdates,a=e[u],a===null?e[u]=[t]:a.push(t),t.lane=s|536870912),f):null}function pi(e){if(50<cl)throw cl=0,Jd=null,Error(l(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Gr={};function AE(e,t,s,a){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=a,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Bn(e,t,s,a){return new AE(e,t,s,a)}function Fu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Us(e,t){var s=e.alternate;return s===null?(s=Bn(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&65011712,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s.refCleanup=e.refCleanup,s}function Yh(e,t){e.flags&=65011714;var s=e.alternate;return s===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=s.childLanes,e.lanes=s.lanes,e.child=s.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=s.memoizedProps,e.memoizedState=s.memoizedState,e.updateQueue=s.updateQueue,e.type=s.type,t=s.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function hi(e,t,s,a,u,f){var y=0;if(a=e,typeof e=="function")Fu(e)&&(y=1);else if(typeof e=="string")y=BN(e,s,V.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case K:return e=Bn(31,s,t,u),e.elementType=K,e.lanes=f,e;case M:return Jo(s.children,u,f,t);case O:y=8,u|=24;break;case N:return e=Bn(12,s,t,u|2),e.elementType=N,e.lanes=f,e;case U:return e=Bn(13,s,t,u),e.elementType=U,e.lanes=f,e;case A:return e=Bn(19,s,t,u),e.elementType=A,e.lanes=f,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case k:y=10;break e;case T:y=9;break e;case C:y=11;break e;case L:y=14;break e;case _:y=16,a=null;break e}y=29,s=Error(l(130,e===null?"null":typeof e,"")),a=null}return t=Bn(y,s,t,u),t.elementType=e,t.type=a,t.lanes=f,t}function Jo(e,t,s,a){return e=Bn(7,e,a,t),e.lanes=s,e}function Gu(e,t,s){return e=Bn(6,e,null,t),e.lanes=s,e}function Vh(e){var t=Bn(18,null,null,0);return t.stateNode=e,t}function qu(e,t,s){return t=Bn(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Fh=new WeakMap;function Zn(e,t){if(typeof e=="object"&&e!==null){var s=Fh.get(e);return s!==void 0?s:(t={value:e,source:t,stack:Ue(t)},Fh.set(e,t),t)}return{value:e,source:t,stack:Ue(t)}}var qr=[],$r=0,gi=null,Ya=0,Jn=[],Wn=0,ho=null,gs=1,xs="";function Hs(e,t){qr[$r++]=Ya,qr[$r++]=gi,gi=e,Ya=t}function Gh(e,t,s){Jn[Wn++]=gs,Jn[Wn++]=xs,Jn[Wn++]=ho,ho=e;var a=gs;e=xs;var u=32-gt(a)-1;a&=~(1<<u),s+=1;var f=32-gt(t)+u;if(30<f){var y=u-u%5;f=(a&(1<<y)-1).toString(32),a>>=y,u-=y,gs=1<<32-gt(t)+u|s<<u|a,xs=f+e}else gs=1<<f|s<<u|a,xs=e}function $u(e){e.return!==null&&(Hs(e,1),Gh(e,1,0))}function Xu(e){for(;e===gi;)gi=qr[--$r],qr[$r]=null,Ya=qr[--$r],qr[$r]=null;for(;e===ho;)ho=Jn[--Wn],Jn[Wn]=null,xs=Jn[--Wn],Jn[Wn]=null,gs=Jn[--Wn],Jn[Wn]=null}function qh(e,t){Jn[Wn++]=gs,Jn[Wn++]=xs,Jn[Wn++]=ho,gs=t.id,xs=t.overflow,ho=e}var hn=null,Yt=null,Tt=!1,go=null,es=!1,Ku=Error(l(519));function xo(e){var t=Error(l(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Va(Zn(t,e)),Ku}function $h(e){var t=e.stateNode,s=e.type,a=e.memoizedProps;switch(t[sn]=e,t[wn]=a,s){case"dialog":bt("cancel",t),bt("close",t);break;case"iframe":case"object":case"embed":bt("load",t);break;case"video":case"audio":for(s=0;s<dl.length;s++)bt(dl[s],t);break;case"source":bt("error",t);break;case"img":case"image":case"link":bt("error",t),bt("load",t);break;case"details":bt("toggle",t);break;case"input":bt("invalid",t),ah(t,a.value,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name,!0);break;case"select":bt("invalid",t);break;case"textarea":bt("invalid",t),ih(t,a.value,a.defaultValue,a.children)}s=a.children,typeof s!="string"&&typeof s!="number"&&typeof s!="bigint"||t.textContent===""+s||a.suppressHydrationWarning===!0||ub(t.textContent,s)?(a.popover!=null&&(bt("beforetoggle",t),bt("toggle",t)),a.onScroll!=null&&bt("scroll",t),a.onScrollEnd!=null&&bt("scrollend",t),a.onClick!=null&&(t.onclick=Is),t=!0):t=!1,t||xo(e,!0)}function Xh(e){for(hn=e.return;hn;)switch(hn.tag){case 5:case 31:case 13:es=!1;return;case 27:case 3:es=!0;return;default:hn=hn.return}}function Xr(e){if(e!==hn)return!1;if(!Tt)return Xh(e),Tt=!0,!1;var t=e.tag,s;if((s=t!==3&&t!==27)&&((s=t===5)&&(s=e.type,s=!(s!=="form"&&s!=="button")||pf(e.type,e.memoizedProps)),s=!s),s&&Yt&&xo(e),Xh(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));Yt=yb(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));Yt=yb(e)}else t===27?(t=Yt,_o(e.type)?(e=yf,yf=null,Yt=e):Yt=t):Yt=hn?ns(e.stateNode.nextSibling):null;return!0}function Wo(){Yt=hn=null,Tt=!1}function Qu(){var e=go;return e!==null&&(_n===null?_n=e:_n.push.apply(_n,e),go=null),e}function Va(e){go===null?go=[e]:go.push(e)}var Zu=z(null),er=null,Ps=null;function bo(e,t,s){I(Zu,t._currentValue),t._currentValue=s}function Ys(e){e._currentValue=Zu.current,X(Zu)}function Ju(e,t,s){for(;e!==null;){var a=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,a!==null&&(a.childLanes|=t)):a!==null&&(a.childLanes&t)!==t&&(a.childLanes|=t),e===s)break;e=e.return}}function Wu(e,t,s,a){var u=e.child;for(u!==null&&(u.return=e);u!==null;){var f=u.dependencies;if(f!==null){var y=u.child;f=f.firstContext;e:for(;f!==null;){var R=f;f=u;for(var G=0;G<t.length;G++)if(R.context===t[G]){f.lanes|=s,R=f.alternate,R!==null&&(R.lanes|=s),Ju(f.return,s,e),a||(y=null);break e}f=R.next}}else if(u.tag===18){if(y=u.return,y===null)throw Error(l(341));y.lanes|=s,f=y.alternate,f!==null&&(f.lanes|=s),Ju(y,s,e),y=null}else y=u.child;if(y!==null)y.return=u;else for(y=u;y!==null;){if(y===e){y=null;break}if(u=y.sibling,u!==null){u.return=y.return,y=u;break}y=y.return}u=y}}function Kr(e,t,s,a){e=null;for(var u=t,f=!1;u!==null;){if(!f){if((u.flags&524288)!==0)f=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var y=u.alternate;if(y===null)throw Error(l(387));if(y=y.memoizedProps,y!==null){var R=u.type;In(u.pendingProps.value,y.value)||(e!==null?e.push(R):e=[R])}}else if(u===fe.current){if(y=u.alternate,y===null)throw Error(l(387));y.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(e!==null?e.push(gl):e=[gl])}u=u.return}e!==null&&Wu(t,e,s,a),t.flags|=262144}function xi(e){for(e=e.firstContext;e!==null;){if(!In(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function tr(e){er=e,Ps=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function gn(e){return Kh(er,e)}function bi(e,t){return er===null&&tr(e),Kh(e,t)}function Kh(e,t){var s=t._currentValue;if(t={context:t,memoizedValue:s,next:null},Ps===null){if(e===null)throw Error(l(308));Ps=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Ps=Ps.next=t;return s}var DE=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(s,a){e.push(a)}};this.abort=function(){t.aborted=!0,e.forEach(function(s){return s()})}},zE=n.unstable_scheduleCallback,LE=n.unstable_NormalPriority,Wt={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ed(){return{controller:new DE,data:new Map,refCount:0}}function Fa(e){e.refCount--,e.refCount===0&&zE(LE,function(){e.controller.abort()})}var Ga=null,td=0,Qr=0,Zr=null;function IE(e,t){if(Ga===null){var s=Ga=[];td=0,Qr=of(),Zr={status:"pending",value:void 0,then:function(a){s.push(a)}}}return td++,t.then(Qh,Qh),t}function Qh(){if(--td===0&&Ga!==null){Zr!==null&&(Zr.status="fulfilled");var e=Ga;Ga=null,Qr=0,Zr=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function BE(e,t){var s=[],a={status:"pending",value:null,reason:null,then:function(u){s.push(u)}};return e.then(function(){a.status="fulfilled",a.value=t;for(var u=0;u<s.length;u++)(0,s[u])(t)},function(u){for(a.status="rejected",a.reason=u,u=0;u<s.length;u++)(0,s[u])(void 0)}),a}var Zh=w.S;w.S=function(e,t){Dx=ee(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&IE(e,t),Zh!==null&&Zh(e,t)};var nr=z(null);function nd(){var e=nr.current;return e!==null?e:Ut.pooledCache}function yi(e,t){t===null?I(nr,nr.current):I(nr,t.pool)}function Jh(){var e=nd();return e===null?null:{parent:Wt._currentValue,pool:e}}var Jr=Error(l(460)),sd=Error(l(474)),vi=Error(l(542)),Si={then:function(){}};function Wh(e){return e=e.status,e==="fulfilled"||e==="rejected"}function eg(e,t,s){switch(s=e[s],s===void 0?e.push(t):s!==t&&(t.then(Is,Is),t=s),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,ng(e),e;default:if(typeof t.status=="string")t.then(Is,Is);else{if(e=Ut,e!==null&&100<e.shellSuspendCounter)throw Error(l(482));e=t,e.status="pending",e.then(function(a){if(t.status==="pending"){var u=t;u.status="fulfilled",u.value=a}},function(a){if(t.status==="pending"){var u=t;u.status="rejected",u.reason=a}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,ng(e),e}throw or=t,Jr}}function sr(e){try{var t=e._init;return t(e._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?(or=s,Jr):s}}var or=null;function tg(){if(or===null)throw Error(l(459));var e=or;return or=null,e}function ng(e){if(e===Jr||e===vi)throw Error(l(483))}var Wr=null,qa=0;function Ei(e){var t=qa;return qa+=1,Wr===null&&(Wr=[]),eg(Wr,e,t)}function $a(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Ni(e,t){throw t.$$typeof===S?Error(l(525)):(e=Object.prototype.toString.call(t),Error(l(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function sg(e){function t(se,J){if(e){var ae=se.deletions;ae===null?(se.deletions=[J],se.flags|=16):ae.push(J)}}function s(se,J){if(!e)return null;for(;J!==null;)t(se,J),J=J.sibling;return null}function a(se){for(var J=new Map;se!==null;)se.key!==null?J.set(se.key,se):J.set(se.index,se),se=se.sibling;return J}function u(se,J){return se=Us(se,J),se.index=0,se.sibling=null,se}function f(se,J,ae){return se.index=ae,e?(ae=se.alternate,ae!==null?(ae=ae.index,ae<J?(se.flags|=67108866,J):ae):(se.flags|=67108866,J)):(se.flags|=1048576,J)}function y(se){return e&&se.alternate===null&&(se.flags|=67108866),se}function R(se,J,ae,Se){return J===null||J.tag!==6?(J=Gu(ae,se.mode,Se),J.return=se,J):(J=u(J,ae),J.return=se,J)}function G(se,J,ae,Se){var tt=ae.type;return tt===M?be(se,J,ae.props.children,Se,ae.key):J!==null&&(J.elementType===tt||typeof tt=="object"&&tt!==null&&tt.$$typeof===_&&sr(tt)===J.type)?(J=u(J,ae.props),$a(J,ae),J.return=se,J):(J=hi(ae.type,ae.key,ae.props,null,se.mode,Se),$a(J,ae),J.return=se,J)}function le(se,J,ae,Se){return J===null||J.tag!==4||J.stateNode.containerInfo!==ae.containerInfo||J.stateNode.implementation!==ae.implementation?(J=qu(ae,se.mode,Se),J.return=se,J):(J=u(J,ae.children||[]),J.return=se,J)}function be(se,J,ae,Se,tt){return J===null||J.tag!==7?(J=Jo(ae,se.mode,Se,tt),J.return=se,J):(J=u(J,ae),J.return=se,J)}function Te(se,J,ae){if(typeof J=="string"&&J!==""||typeof J=="number"||typeof J=="bigint")return J=Gu(""+J,se.mode,ae),J.return=se,J;if(typeof J=="object"&&J!==null){switch(J.$$typeof){case j:return ae=hi(J.type,J.key,J.props,null,se.mode,ae),$a(ae,J),ae.return=se,ae;case E:return J=qu(J,se.mode,ae),J.return=se,J;case _:return J=sr(J),Te(se,J,ae)}if(q(J)||ne(J))return J=Jo(J,se.mode,ae,null),J.return=se,J;if(typeof J.then=="function")return Te(se,Ei(J),ae);if(J.$$typeof===k)return Te(se,bi(se,J),ae);Ni(se,J)}return null}function ce(se,J,ae,Se){var tt=J!==null?J.key:null;if(typeof ae=="string"&&ae!==""||typeof ae=="number"||typeof ae=="bigint")return tt!==null?null:R(se,J,""+ae,Se);if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case j:return ae.key===tt?G(se,J,ae,Se):null;case E:return ae.key===tt?le(se,J,ae,Se):null;case _:return ae=sr(ae),ce(se,J,ae,Se)}if(q(ae)||ne(ae))return tt!==null?null:be(se,J,ae,Se,null);if(typeof ae.then=="function")return ce(se,J,Ei(ae),Se);if(ae.$$typeof===k)return ce(se,J,bi(se,ae),Se);Ni(se,ae)}return null}function me(se,J,ae,Se,tt){if(typeof Se=="string"&&Se!==""||typeof Se=="number"||typeof Se=="bigint")return se=se.get(ae)||null,R(J,se,""+Se,tt);if(typeof Se=="object"&&Se!==null){switch(Se.$$typeof){case j:return se=se.get(Se.key===null?ae:Se.key)||null,G(J,se,Se,tt);case E:return se=se.get(Se.key===null?ae:Se.key)||null,le(J,se,Se,tt);case _:return Se=sr(Se),me(se,J,ae,Se,tt)}if(q(Se)||ne(Se))return se=se.get(ae)||null,be(J,se,Se,tt,null);if(typeof Se.then=="function")return me(se,J,ae,Ei(Se),tt);if(Se.$$typeof===k)return me(se,J,ae,bi(J,Se),tt);Ni(J,Se)}return null}function $e(se,J,ae,Se){for(var tt=null,Rt=null,Ke=J,pt=J=0,St=null;Ke!==null&&pt<ae.length;pt++){Ke.index>pt?(St=Ke,Ke=null):St=Ke.sibling;var Ot=ce(se,Ke,ae[pt],Se);if(Ot===null){Ke===null&&(Ke=St);break}e&&Ke&&Ot.alternate===null&&t(se,Ke),J=f(Ot,J,pt),Rt===null?tt=Ot:Rt.sibling=Ot,Rt=Ot,Ke=St}if(pt===ae.length)return s(se,Ke),Tt&&Hs(se,pt),tt;if(Ke===null){for(;pt<ae.length;pt++)Ke=Te(se,ae[pt],Se),Ke!==null&&(J=f(Ke,J,pt),Rt===null?tt=Ke:Rt.sibling=Ke,Rt=Ke);return Tt&&Hs(se,pt),tt}for(Ke=a(Ke);pt<ae.length;pt++)St=me(Ke,se,pt,ae[pt],Se),St!==null&&(e&&St.alternate!==null&&Ke.delete(St.key===null?pt:St.key),J=f(St,J,pt),Rt===null?tt=St:Rt.sibling=St,Rt=St);return e&&Ke.forEach(function(Lo){return t(se,Lo)}),Tt&&Hs(se,pt),tt}function st(se,J,ae,Se){if(ae==null)throw Error(l(151));for(var tt=null,Rt=null,Ke=J,pt=J=0,St=null,Ot=ae.next();Ke!==null&&!Ot.done;pt++,Ot=ae.next()){Ke.index>pt?(St=Ke,Ke=null):St=Ke.sibling;var Lo=ce(se,Ke,Ot.value,Se);if(Lo===null){Ke===null&&(Ke=St);break}e&&Ke&&Lo.alternate===null&&t(se,Ke),J=f(Lo,J,pt),Rt===null?tt=Lo:Rt.sibling=Lo,Rt=Lo,Ke=St}if(Ot.done)return s(se,Ke),Tt&&Hs(se,pt),tt;if(Ke===null){for(;!Ot.done;pt++,Ot=ae.next())Ot=Te(se,Ot.value,Se),Ot!==null&&(J=f(Ot,J,pt),Rt===null?tt=Ot:Rt.sibling=Ot,Rt=Ot);return Tt&&Hs(se,pt),tt}for(Ke=a(Ke);!Ot.done;pt++,Ot=ae.next())Ot=me(Ke,se,pt,Ot.value,Se),Ot!==null&&(e&&Ot.alternate!==null&&Ke.delete(Ot.key===null?pt:Ot.key),J=f(Ot,J,pt),Rt===null?tt=Ot:Rt.sibling=Ot,Rt=Ot);return e&&Ke.forEach(function(KN){return t(se,KN)}),Tt&&Hs(se,pt),tt}function It(se,J,ae,Se){if(typeof ae=="object"&&ae!==null&&ae.type===M&&ae.key===null&&(ae=ae.props.children),typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case j:e:{for(var tt=ae.key;J!==null;){if(J.key===tt){if(tt=ae.type,tt===M){if(J.tag===7){s(se,J.sibling),Se=u(J,ae.props.children),Se.return=se,se=Se;break e}}else if(J.elementType===tt||typeof tt=="object"&&tt!==null&&tt.$$typeof===_&&sr(tt)===J.type){s(se,J.sibling),Se=u(J,ae.props),$a(Se,ae),Se.return=se,se=Se;break e}s(se,J);break}else t(se,J);J=J.sibling}ae.type===M?(Se=Jo(ae.props.children,se.mode,Se,ae.key),Se.return=se,se=Se):(Se=hi(ae.type,ae.key,ae.props,null,se.mode,Se),$a(Se,ae),Se.return=se,se=Se)}return y(se);case E:e:{for(tt=ae.key;J!==null;){if(J.key===tt)if(J.tag===4&&J.stateNode.containerInfo===ae.containerInfo&&J.stateNode.implementation===ae.implementation){s(se,J.sibling),Se=u(J,ae.children||[]),Se.return=se,se=Se;break e}else{s(se,J);break}else t(se,J);J=J.sibling}Se=qu(ae,se.mode,Se),Se.return=se,se=Se}return y(se);case _:return ae=sr(ae),It(se,J,ae,Se)}if(q(ae))return $e(se,J,ae,Se);if(ne(ae)){if(tt=ne(ae),typeof tt!="function")throw Error(l(150));return ae=tt.call(ae),st(se,J,ae,Se)}if(typeof ae.then=="function")return It(se,J,Ei(ae),Se);if(ae.$$typeof===k)return It(se,J,bi(se,ae),Se);Ni(se,ae)}return typeof ae=="string"&&ae!==""||typeof ae=="number"||typeof ae=="bigint"?(ae=""+ae,J!==null&&J.tag===6?(s(se,J.sibling),Se=u(J,ae),Se.return=se,se=Se):(s(se,J),Se=Gu(ae,se.mode,Se),Se.return=se,se=Se),y(se)):s(se,J)}return function(se,J,ae,Se){try{qa=0;var tt=It(se,J,ae,Se);return Wr=null,tt}catch(Ke){if(Ke===Jr||Ke===vi)throw Ke;var Rt=Bn(29,Ke,null,se.mode);return Rt.lanes=Se,Rt.return=se,Rt}}}var rr=sg(!0),og=sg(!1),yo=!1;function od(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function rd(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function vo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function So(e,t,s){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(_t&2)!==0){var u=a.pending;return u===null?t.next=t:(t.next=u.next,u.next=t),a.pending=t,t=pi(e),Ph(e,null,s),t}return mi(e,a,t,s),pi(e)}function Xa(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194048)!==0)){var a=t.lanes;a&=e.pendingLanes,s|=a,t.lanes=s,Kt(e,s)}}function ad(e,t){var s=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,s===a)){var u=null,f=null;if(s=s.firstBaseUpdate,s!==null){do{var y={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};f===null?u=f=y:f=f.next=y,s=s.next}while(s!==null);f===null?u=f=t:f=f.next=t}else u=f=t;s={baseState:a.baseState,firstBaseUpdate:u,lastBaseUpdate:f,shared:a.shared,callbacks:a.callbacks},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}var ld=!1;function Ka(){if(ld){var e=Zr;if(e!==null)throw e}}function Qa(e,t,s,a){ld=!1;var u=e.updateQueue;yo=!1;var f=u.firstBaseUpdate,y=u.lastBaseUpdate,R=u.shared.pending;if(R!==null){u.shared.pending=null;var G=R,le=G.next;G.next=null,y===null?f=le:y.next=le,y=G;var be=e.alternate;be!==null&&(be=be.updateQueue,R=be.lastBaseUpdate,R!==y&&(R===null?be.firstBaseUpdate=le:R.next=le,be.lastBaseUpdate=G))}if(f!==null){var Te=u.baseState;y=0,be=le=G=null,R=f;do{var ce=R.lane&-536870913,me=ce!==R.lane;if(me?(vt&ce)===ce:(a&ce)===ce){ce!==0&&ce===Qr&&(ld=!0),be!==null&&(be=be.next={lane:0,tag:R.tag,payload:R.payload,callback:null,next:null});e:{var $e=e,st=R;ce=t;var It=s;switch(st.tag){case 1:if($e=st.payload,typeof $e=="function"){Te=$e.call(It,Te,ce);break e}Te=$e;break e;case 3:$e.flags=$e.flags&-65537|128;case 0:if($e=st.payload,ce=typeof $e=="function"?$e.call(It,Te,ce):$e,ce==null)break e;Te=x({},Te,ce);break e;case 2:yo=!0}}ce=R.callback,ce!==null&&(e.flags|=64,me&&(e.flags|=8192),me=u.callbacks,me===null?u.callbacks=[ce]:me.push(ce))}else me={lane:ce,tag:R.tag,payload:R.payload,callback:R.callback,next:null},be===null?(le=be=me,G=Te):be=be.next=me,y|=ce;if(R=R.next,R===null){if(R=u.shared.pending,R===null)break;me=R,R=me.next,me.next=null,u.lastBaseUpdate=me,u.shared.pending=null}}while(!0);be===null&&(G=Te),u.baseState=G,u.firstBaseUpdate=le,u.lastBaseUpdate=be,f===null&&(u.shared.lanes=0),wo|=y,e.lanes=y,e.memoizedState=Te}}function rg(e,t){if(typeof e!="function")throw Error(l(191,e));e.call(t)}function ag(e,t){var s=e.callbacks;if(s!==null)for(e.callbacks=null,e=0;e<s.length;e++)rg(s[e],t)}var ea=z(null),ji=z(0);function lg(e,t){e=Zs,I(ji,e),I(ea,t),Zs=e|t.baseLanes}function id(){I(ji,Zs),I(ea,ea.current)}function cd(){Zs=ji.current,X(ea),X(ji)}var Un=z(null),ts=null;function Eo(e){var t=e.alternate;I(Qt,Qt.current&1),I(Un,e),ts===null&&(t===null||ea.current!==null||t.memoizedState!==null)&&(ts=e)}function ud(e){I(Qt,Qt.current),I(Un,e),ts===null&&(ts=e)}function ig(e){e.tag===22?(I(Qt,Qt.current),I(Un,e),ts===null&&(ts=e)):No()}function No(){I(Qt,Qt.current),I(Un,Un.current)}function Hn(e){X(Un),ts===e&&(ts=null),X(Qt)}var Qt=z(0);function Ti(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||xf(s)||bf(s)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Vs=0,dt=null,zt=null,en=null,wi=!1,ta=!1,ar=!1,Ci=0,Za=0,na=null,UE=0;function qt(){throw Error(l(321))}function dd(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!In(e[s],t[s]))return!1;return!0}function fd(e,t,s,a,u,f){return Vs=f,dt=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,w.H=e===null||e.memoizedState===null?Gg:Cd,ar=!1,f=s(a,u),ar=!1,ta&&(f=ug(t,s,a,u)),cg(e),f}function cg(e){w.H=el;var t=zt!==null&&zt.next!==null;if(Vs=0,en=zt=dt=null,wi=!1,Za=0,na=null,t)throw Error(l(300));e===null||tn||(e=e.dependencies,e!==null&&xi(e)&&(tn=!0))}function ug(e,t,s,a){dt=e;var u=0;do{if(ta&&(na=null),Za=0,ta=!1,25<=u)throw Error(l(301));if(u+=1,en=zt=null,e.updateQueue!=null){var f=e.updateQueue;f.lastEffect=null,f.events=null,f.stores=null,f.memoCache!=null&&(f.memoCache.index=0)}w.H=qg,f=t(s,a)}while(ta);return f}function HE(){var e=w.H,t=e.useState()[0];return t=typeof t.then=="function"?Ja(t):t,e=e.useState()[0],(zt!==null?zt.memoizedState:null)!==e&&(dt.flags|=1024),t}function md(){var e=Ci!==0;return Ci=0,e}function pd(e,t,s){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s}function hd(e){if(wi){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}wi=!1}Vs=0,en=zt=dt=null,ta=!1,Za=Ci=0,na=null}function Nn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return en===null?dt.memoizedState=en=e:en=en.next=e,en}function Zt(){if(zt===null){var e=dt.alternate;e=e!==null?e.memoizedState:null}else e=zt.next;var t=en===null?dt.memoizedState:en.next;if(t!==null)en=t,zt=e;else{if(e===null)throw dt.alternate===null?Error(l(467)):Error(l(310));zt=e,e={memoizedState:zt.memoizedState,baseState:zt.baseState,baseQueue:zt.baseQueue,queue:zt.queue,next:null},en===null?dt.memoizedState=en=e:en=en.next=e}return en}function Ri(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ja(e){var t=Za;return Za+=1,na===null&&(na=[]),e=eg(na,e,t),t=dt,(en===null?t.memoizedState:en.next)===null&&(t=t.alternate,w.H=t===null||t.memoizedState===null?Gg:Cd),e}function Oi(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Ja(e);if(e.$$typeof===k)return gn(e)}throw Error(l(438,String(e)))}function gd(e){var t=null,s=dt.updateQueue;if(s!==null&&(t=s.memoCache),t==null){var a=dt.alternate;a!==null&&(a=a.updateQueue,a!==null&&(a=a.memoCache,a!=null&&(t={data:a.data.map(function(u){return u.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),s===null&&(s=Ri(),dt.updateQueue=s),s.memoCache=t,s=t.data[t.index],s===void 0)for(s=t.data[t.index]=Array(e),a=0;a<e;a++)s[a]=W;return t.index++,s}function Fs(e,t){return typeof t=="function"?t(e):t}function ki(e){var t=Zt();return xd(t,zt,e)}function xd(e,t,s){var a=e.queue;if(a===null)throw Error(l(311));a.lastRenderedReducer=s;var u=e.baseQueue,f=a.pending;if(f!==null){if(u!==null){var y=u.next;u.next=f.next,f.next=y}t.baseQueue=u=f,a.pending=null}if(f=e.baseState,u===null)e.memoizedState=f;else{t=u.next;var R=y=null,G=null,le=t,be=!1;do{var Te=le.lane&-536870913;if(Te!==le.lane?(vt&Te)===Te:(Vs&Te)===Te){var ce=le.revertLane;if(ce===0)G!==null&&(G=G.next={lane:0,revertLane:0,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),Te===Qr&&(be=!0);else if((Vs&ce)===ce){le=le.next,ce===Qr&&(be=!0);continue}else Te={lane:0,revertLane:le.revertLane,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},G===null?(R=G=Te,y=f):G=G.next=Te,dt.lanes|=ce,wo|=ce;Te=le.action,ar&&s(f,Te),f=le.hasEagerState?le.eagerState:s(f,Te)}else ce={lane:Te,revertLane:le.revertLane,gesture:le.gesture,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},G===null?(R=G=ce,y=f):G=G.next=ce,dt.lanes|=Te,wo|=Te;le=le.next}while(le!==null&&le!==t);if(G===null?y=f:G.next=R,!In(f,e.memoizedState)&&(tn=!0,be&&(s=Zr,s!==null)))throw s;e.memoizedState=f,e.baseState=y,e.baseQueue=G,a.lastRenderedState=f}return u===null&&(a.lanes=0),[e.memoizedState,a.dispatch]}function bd(e){var t=Zt(),s=t.queue;if(s===null)throw Error(l(311));s.lastRenderedReducer=e;var a=s.dispatch,u=s.pending,f=t.memoizedState;if(u!==null){s.pending=null;var y=u=u.next;do f=e(f,y.action),y=y.next;while(y!==u);In(f,t.memoizedState)||(tn=!0),t.memoizedState=f,t.baseQueue===null&&(t.baseState=f),s.lastRenderedState=f}return[f,a]}function dg(e,t,s){var a=dt,u=Zt(),f=Tt;if(f){if(s===void 0)throw Error(l(407));s=s()}else s=t();var y=!In((zt||u).memoizedState,s);if(y&&(u.memoizedState=s,tn=!0),u=u.queue,Sd(pg.bind(null,a,u,e),[e]),u.getSnapshot!==t||y||en!==null&&en.memoizedState.tag&1){if(a.flags|=2048,sa(9,{destroy:void 0},mg.bind(null,a,u,s,t),null),Ut===null)throw Error(l(349));f||(Vs&127)!==0||fg(a,t,s)}return s}function fg(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=dt.updateQueue,t===null?(t=Ri(),dt.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function mg(e,t,s,a){t.value=s,t.getSnapshot=a,hg(t)&&gg(e)}function pg(e,t,s){return s(function(){hg(t)&&gg(e)})}function hg(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!In(e,s)}catch{return!0}}function gg(e){var t=Zo(e,2);t!==null&&Mn(t,e,2)}function yd(e){var t=Nn();if(typeof e=="function"){var s=e;if(e=s(),ar){kt(!0);try{s()}finally{kt(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fs,lastRenderedState:e},t}function xg(e,t,s,a){return e.baseState=s,xd(e,zt,typeof a=="function"?a:Fs)}function PE(e,t,s,a,u){if(Ai(e))throw Error(l(485));if(e=t.action,e!==null){var f={payload:u,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(y){f.listeners.push(y)}};w.T!==null?s(!0):f.isTransition=!1,a(f),s=t.pending,s===null?(f.next=t.pending=f,bg(t,f)):(f.next=s.next,t.pending=s.next=f)}}function bg(e,t){var s=t.action,a=t.payload,u=e.state;if(t.isTransition){var f=w.T,y={};w.T=y;try{var R=s(u,a),G=w.S;G!==null&&G(y,R),yg(e,t,R)}catch(le){vd(e,t,le)}finally{f!==null&&y.types!==null&&(f.types=y.types),w.T=f}}else try{f=s(u,a),yg(e,t,f)}catch(le){vd(e,t,le)}}function yg(e,t,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(a){vg(e,t,a)},function(a){return vd(e,t,a)}):vg(e,t,s)}function vg(e,t,s){t.status="fulfilled",t.value=s,Sg(t),e.state=s,t=e.pending,t!==null&&(s=t.next,s===t?e.pending=null:(s=s.next,t.next=s,bg(e,s)))}function vd(e,t,s){var a=e.pending;if(e.pending=null,a!==null){a=a.next;do t.status="rejected",t.reason=s,Sg(t),t=t.next;while(t!==a)}e.action=null}function Sg(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Eg(e,t){return t}function Ng(e,t){if(Tt){var s=Ut.formState;if(s!==null){e:{var a=dt;if(Tt){if(Yt){t:{for(var u=Yt,f=es;u.nodeType!==8;){if(!f){u=null;break t}if(u=ns(u.nextSibling),u===null){u=null;break t}}f=u.data,u=f==="F!"||f==="F"?u:null}if(u){Yt=ns(u.nextSibling),a=u.data==="F!";break e}}xo(a)}a=!1}a&&(t=s[0])}}return s=Nn(),s.memoizedState=s.baseState=t,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Eg,lastRenderedState:t},s.queue=a,s=Yg.bind(null,dt,a),a.dispatch=s,a=yd(!1),f=wd.bind(null,dt,!1,a.queue),a=Nn(),u={state:t,dispatch:null,action:e,pending:null},a.queue=u,s=PE.bind(null,dt,u,f,s),u.dispatch=s,a.memoizedState=e,[t,s,!1]}function jg(e){var t=Zt();return Tg(t,zt,e)}function Tg(e,t,s){if(t=xd(e,t,Eg)[0],e=ki(Fs)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var a=Ja(t)}catch(y){throw y===Jr?vi:y}else a=t;t=Zt();var u=t.queue,f=u.dispatch;return s!==t.memoizedState&&(dt.flags|=2048,sa(9,{destroy:void 0},YE.bind(null,u,s),null)),[a,f,e]}function YE(e,t){e.action=t}function wg(e){var t=Zt(),s=zt;if(s!==null)return Tg(t,s,e);Zt(),t=t.memoizedState,s=Zt();var a=s.queue.dispatch;return s.memoizedState=e,[t,a,!1]}function sa(e,t,s,a){return e={tag:e,create:s,deps:a,inst:t,next:null},t=dt.updateQueue,t===null&&(t=Ri(),dt.updateQueue=t),s=t.lastEffect,s===null?t.lastEffect=e.next=e:(a=s.next,s.next=e,e.next=a,t.lastEffect=e),e}function Cg(){return Zt().memoizedState}function _i(e,t,s,a){var u=Nn();dt.flags|=e,u.memoizedState=sa(1|t,{destroy:void 0},s,a===void 0?null:a)}function Mi(e,t,s,a){var u=Zt();a=a===void 0?null:a;var f=u.memoizedState.inst;zt!==null&&a!==null&&dd(a,zt.memoizedState.deps)?u.memoizedState=sa(t,f,s,a):(dt.flags|=e,u.memoizedState=sa(1|t,f,s,a))}function Rg(e,t){_i(8390656,8,e,t)}function Sd(e,t){Mi(2048,8,e,t)}function VE(e){dt.flags|=4;var t=dt.updateQueue;if(t===null)t=Ri(),dt.updateQueue=t,t.events=[e];else{var s=t.events;s===null?t.events=[e]:s.push(e)}}function Og(e){var t=Zt().memoizedState;return VE({ref:t,nextImpl:e}),function(){if((_t&2)!==0)throw Error(l(440));return t.impl.apply(void 0,arguments)}}function kg(e,t){return Mi(4,2,e,t)}function _g(e,t){return Mi(4,4,e,t)}function Mg(e,t){if(typeof t=="function"){e=e();var s=t(e);return function(){typeof s=="function"?s():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Ag(e,t,s){s=s!=null?s.concat([e]):null,Mi(4,4,Mg.bind(null,t,e),s)}function Ed(){}function Dg(e,t){var s=Zt();t=t===void 0?null:t;var a=s.memoizedState;return t!==null&&dd(t,a[1])?a[0]:(s.memoizedState=[e,t],e)}function zg(e,t){var s=Zt();t=t===void 0?null:t;var a=s.memoizedState;if(t!==null&&dd(t,a[1]))return a[0];if(a=e(),ar){kt(!0);try{e()}finally{kt(!1)}}return s.memoizedState=[a,t],a}function Nd(e,t,s){return s===void 0||(Vs&1073741824)!==0&&(vt&261930)===0?e.memoizedState=t:(e.memoizedState=s,e=Lx(),dt.lanes|=e,wo|=e,s)}function Lg(e,t,s,a){return In(s,t)?s:ea.current!==null?(e=Nd(e,s,a),In(e,t)||(tn=!0),e):(Vs&42)===0||(Vs&1073741824)!==0&&(vt&261930)===0?(tn=!0,e.memoizedState=s):(e=Lx(),dt.lanes|=e,wo|=e,t)}function Ig(e,t,s,a,u){var f=D.p;D.p=f!==0&&8>f?f:8;var y=w.T,R={};w.T=R,wd(e,!1,t,s);try{var G=u(),le=w.S;if(le!==null&&le(R,G),G!==null&&typeof G=="object"&&typeof G.then=="function"){var be=BE(G,a);Wa(e,t,be,Vn(e))}else Wa(e,t,a,Vn(e))}catch(Te){Wa(e,t,{then:function(){},status:"rejected",reason:Te},Vn())}finally{D.p=f,y!==null&&R.types!==null&&(y.types=R.types),w.T=y}}function FE(){}function jd(e,t,s,a){if(e.tag!==5)throw Error(l(476));var u=Bg(e).queue;Ig(e,u,t,H,s===null?FE:function(){return Ug(e),s(a)})}function Bg(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:H,baseState:H,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fs,lastRenderedState:H},next:null};var s={};return t.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fs,lastRenderedState:s},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ug(e){var t=Bg(e);t.next===null&&(t=e.alternate.memoizedState),Wa(e,t.next.queue,{},Vn())}function Td(){return gn(gl)}function Hg(){return Zt().memoizedState}function Pg(){return Zt().memoizedState}function GE(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var s=Vn();e=vo(s);var a=So(t,e,s);a!==null&&(Mn(a,t,s),Xa(a,t,s)),t={cache:ed()},e.payload=t;return}t=t.return}}function qE(e,t,s){var a=Vn();s={lane:a,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},Ai(e)?Vg(t,s):(s=Vu(e,t,s,a),s!==null&&(Mn(s,e,a),Fg(s,t,a)))}function Yg(e,t,s){var a=Vn();Wa(e,t,s,a)}function Wa(e,t,s,a){var u={lane:a,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(Ai(e))Vg(t,u);else{var f=e.alternate;if(e.lanes===0&&(f===null||f.lanes===0)&&(f=t.lastRenderedReducer,f!==null))try{var y=t.lastRenderedState,R=f(y,s);if(u.hasEagerState=!0,u.eagerState=R,In(R,y))return mi(e,t,u,0),Ut===null&&fi(),!1}catch{}if(s=Vu(e,t,u,a),s!==null)return Mn(s,e,a),Fg(s,t,a),!0}return!1}function wd(e,t,s,a){if(a={lane:2,revertLane:of(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Ai(e)){if(t)throw Error(l(479))}else t=Vu(e,s,a,2),t!==null&&Mn(t,e,2)}function Ai(e){var t=e.alternate;return e===dt||t!==null&&t===dt}function Vg(e,t){ta=wi=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function Fg(e,t,s){if((s&4194048)!==0){var a=t.lanes;a&=e.pendingLanes,s|=a,t.lanes=s,Kt(e,s)}}var el={readContext:gn,use:Oi,useCallback:qt,useContext:qt,useEffect:qt,useImperativeHandle:qt,useLayoutEffect:qt,useInsertionEffect:qt,useMemo:qt,useReducer:qt,useRef:qt,useState:qt,useDebugValue:qt,useDeferredValue:qt,useTransition:qt,useSyncExternalStore:qt,useId:qt,useHostTransitionStatus:qt,useFormState:qt,useActionState:qt,useOptimistic:qt,useMemoCache:qt,useCacheRefresh:qt};el.useEffectEvent=qt;var Gg={readContext:gn,use:Oi,useCallback:function(e,t){return Nn().memoizedState=[e,t===void 0?null:t],e},useContext:gn,useEffect:Rg,useImperativeHandle:function(e,t,s){s=s!=null?s.concat([e]):null,_i(4194308,4,Mg.bind(null,t,e),s)},useLayoutEffect:function(e,t){return _i(4194308,4,e,t)},useInsertionEffect:function(e,t){_i(4,2,e,t)},useMemo:function(e,t){var s=Nn();t=t===void 0?null:t;var a=e();if(ar){kt(!0);try{e()}finally{kt(!1)}}return s.memoizedState=[a,t],a},useReducer:function(e,t,s){var a=Nn();if(s!==void 0){var u=s(t);if(ar){kt(!0);try{s(t)}finally{kt(!1)}}}else u=t;return a.memoizedState=a.baseState=u,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:u},a.queue=e,e=e.dispatch=qE.bind(null,dt,e),[a.memoizedState,e]},useRef:function(e){var t=Nn();return e={current:e},t.memoizedState=e},useState:function(e){e=yd(e);var t=e.queue,s=Yg.bind(null,dt,t);return t.dispatch=s,[e.memoizedState,s]},useDebugValue:Ed,useDeferredValue:function(e,t){var s=Nn();return Nd(s,e,t)},useTransition:function(){var e=yd(!1);return e=Ig.bind(null,dt,e.queue,!0,!1),Nn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,s){var a=dt,u=Nn();if(Tt){if(s===void 0)throw Error(l(407));s=s()}else{if(s=t(),Ut===null)throw Error(l(349));(vt&127)!==0||fg(a,t,s)}u.memoizedState=s;var f={value:s,getSnapshot:t};return u.queue=f,Rg(pg.bind(null,a,f,e),[e]),a.flags|=2048,sa(9,{destroy:void 0},mg.bind(null,a,f,s,t),null),s},useId:function(){var e=Nn(),t=Ut.identifierPrefix;if(Tt){var s=xs,a=gs;s=(a&~(1<<32-gt(a)-1)).toString(32)+s,t="_"+t+"R_"+s,s=Ci++,0<s&&(t+="H"+s.toString(32)),t+="_"}else s=UE++,t="_"+t+"r_"+s.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Td,useFormState:Ng,useActionState:Ng,useOptimistic:function(e){var t=Nn();t.memoizedState=t.baseState=e;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=s,t=wd.bind(null,dt,!0,s),s.dispatch=t,[e,t]},useMemoCache:gd,useCacheRefresh:function(){return Nn().memoizedState=GE.bind(null,dt)},useEffectEvent:function(e){var t=Nn(),s={impl:e};return t.memoizedState=s,function(){if((_t&2)!==0)throw Error(l(440));return s.impl.apply(void 0,arguments)}}},Cd={readContext:gn,use:Oi,useCallback:Dg,useContext:gn,useEffect:Sd,useImperativeHandle:Ag,useInsertionEffect:kg,useLayoutEffect:_g,useMemo:zg,useReducer:ki,useRef:Cg,useState:function(){return ki(Fs)},useDebugValue:Ed,useDeferredValue:function(e,t){var s=Zt();return Lg(s,zt.memoizedState,e,t)},useTransition:function(){var e=ki(Fs)[0],t=Zt().memoizedState;return[typeof e=="boolean"?e:Ja(e),t]},useSyncExternalStore:dg,useId:Hg,useHostTransitionStatus:Td,useFormState:jg,useActionState:jg,useOptimistic:function(e,t){var s=Zt();return xg(s,zt,e,t)},useMemoCache:gd,useCacheRefresh:Pg};Cd.useEffectEvent=Og;var qg={readContext:gn,use:Oi,useCallback:Dg,useContext:gn,useEffect:Sd,useImperativeHandle:Ag,useInsertionEffect:kg,useLayoutEffect:_g,useMemo:zg,useReducer:bd,useRef:Cg,useState:function(){return bd(Fs)},useDebugValue:Ed,useDeferredValue:function(e,t){var s=Zt();return zt===null?Nd(s,e,t):Lg(s,zt.memoizedState,e,t)},useTransition:function(){var e=bd(Fs)[0],t=Zt().memoizedState;return[typeof e=="boolean"?e:Ja(e),t]},useSyncExternalStore:dg,useId:Hg,useHostTransitionStatus:Td,useFormState:wg,useActionState:wg,useOptimistic:function(e,t){var s=Zt();return zt!==null?xg(s,zt,e,t):(s.baseState=e,[e,s.queue.dispatch])},useMemoCache:gd,useCacheRefresh:Pg};qg.useEffectEvent=Og;function Rd(e,t,s,a){t=e.memoizedState,s=s(a,t),s=s==null?t:x({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var Od={enqueueSetState:function(e,t,s){e=e._reactInternals;var a=Vn(),u=vo(a);u.payload=t,s!=null&&(u.callback=s),t=So(e,u,a),t!==null&&(Mn(t,e,a),Xa(t,e,a))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var a=Vn(),u=vo(a);u.tag=1,u.payload=t,s!=null&&(u.callback=s),t=So(e,u,a),t!==null&&(Mn(t,e,a),Xa(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=Vn(),a=vo(s);a.tag=2,t!=null&&(a.callback=t),t=So(e,a,s),t!==null&&(Mn(t,e,s),Xa(t,e,s))}};function $g(e,t,s,a,u,f,y){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(a,f,y):t.prototype&&t.prototype.isPureReactComponent?!Ha(s,a)||!Ha(u,f):!0}function Xg(e,t,s,a){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,a),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,a),t.state!==e&&Od.enqueueReplaceState(t,t.state,null)}function lr(e,t){var s=t;if("ref"in t){s={};for(var a in t)a!=="ref"&&(s[a]=t[a])}if(e=e.defaultProps){s===t&&(s=x({},s));for(var u in e)s[u]===void 0&&(s[u]=e[u])}return s}function Kg(e){di(e)}function Qg(e){console.error(e)}function Zg(e){di(e)}function Di(e,t){try{var s=e.onUncaughtError;s(t.value,{componentStack:t.stack})}catch(a){setTimeout(function(){throw a})}}function Jg(e,t,s){try{var a=e.onCaughtError;a(s.value,{componentStack:s.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function kd(e,t,s){return s=vo(s),s.tag=3,s.payload={element:null},s.callback=function(){Di(e,t)},s}function Wg(e){return e=vo(e),e.tag=3,e}function ex(e,t,s,a){var u=s.type.getDerivedStateFromError;if(typeof u=="function"){var f=a.value;e.payload=function(){return u(f)},e.callback=function(){Jg(t,s,a)}}var y=s.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(e.callback=function(){Jg(t,s,a),typeof u!="function"&&(Co===null?Co=new Set([this]):Co.add(this));var R=a.stack;this.componentDidCatch(a.value,{componentStack:R!==null?R:""})})}function $E(e,t,s,a,u){if(s.flags|=32768,a!==null&&typeof a=="object"&&typeof a.then=="function"){if(t=s.alternate,t!==null&&Kr(t,s,u,!0),s=Un.current,s!==null){switch(s.tag){case 31:case 13:return ts===null?qi():s.alternate===null&&$t===0&&($t=3),s.flags&=-257,s.flags|=65536,s.lanes=u,a===Si?s.flags|=16384:(t=s.updateQueue,t===null?s.updateQueue=new Set([a]):t.add(a),tf(e,a,u)),!1;case 22:return s.flags|=65536,a===Si?s.flags|=16384:(t=s.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([a])},s.updateQueue=t):(s=t.retryQueue,s===null?t.retryQueue=new Set([a]):s.add(a)),tf(e,a,u)),!1}throw Error(l(435,s.tag))}return tf(e,a,u),qi(),!1}if(Tt)return t=Un.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=u,a!==Ku&&(e=Error(l(422),{cause:a}),Va(Zn(e,s)))):(a!==Ku&&(t=Error(l(423),{cause:a}),Va(Zn(t,s))),e=e.current.alternate,e.flags|=65536,u&=-u,e.lanes|=u,a=Zn(a,s),u=kd(e.stateNode,a,u),ad(e,u),$t!==4&&($t=2)),!1;var f=Error(l(520),{cause:a});if(f=Zn(f,s),il===null?il=[f]:il.push(f),$t!==4&&($t=2),t===null)return!0;a=Zn(a,s),s=t;do{switch(s.tag){case 3:return s.flags|=65536,e=u&-u,s.lanes|=e,e=kd(s.stateNode,a,e),ad(s,e),!1;case 1:if(t=s.type,f=s.stateNode,(s.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||f!==null&&typeof f.componentDidCatch=="function"&&(Co===null||!Co.has(f))))return s.flags|=65536,u&=-u,s.lanes|=u,u=Wg(u),ex(u,e,s,a),ad(s,u),!1}s=s.return}while(s!==null);return!1}var _d=Error(l(461)),tn=!1;function xn(e,t,s,a){t.child=e===null?og(t,null,s,a):rr(t,e.child,s,a)}function tx(e,t,s,a,u){s=s.render;var f=t.ref;if("ref"in a){var y={};for(var R in a)R!=="ref"&&(y[R]=a[R])}else y=a;return tr(t),a=fd(e,t,s,y,f,u),R=md(),e!==null&&!tn?(pd(e,t,u),Gs(e,t,u)):(Tt&&R&&$u(t),t.flags|=1,xn(e,t,a,u),t.child)}function nx(e,t,s,a,u){if(e===null){var f=s.type;return typeof f=="function"&&!Fu(f)&&f.defaultProps===void 0&&s.compare===null?(t.tag=15,t.type=f,sx(e,t,f,a,u)):(e=hi(s.type,null,a,t,t.mode,u),e.ref=t.ref,e.return=t,t.child=e)}if(f=e.child,!Ud(e,u)){var y=f.memoizedProps;if(s=s.compare,s=s!==null?s:Ha,s(y,a)&&e.ref===t.ref)return Gs(e,t,u)}return t.flags|=1,e=Us(f,a),e.ref=t.ref,e.return=t,t.child=e}function sx(e,t,s,a,u){if(e!==null){var f=e.memoizedProps;if(Ha(f,a)&&e.ref===t.ref)if(tn=!1,t.pendingProps=a=f,Ud(e,u))(e.flags&131072)!==0&&(tn=!0);else return t.lanes=e.lanes,Gs(e,t,u)}return Md(e,t,s,a,u)}function ox(e,t,s,a){var u=a.children,f=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.mode==="hidden"){if((t.flags&128)!==0){if(f=f!==null?f.baseLanes|s:s,e!==null){for(a=t.child=e.child,u=0;a!==null;)u=u|a.lanes|a.childLanes,a=a.sibling;a=u&~f}else a=0,t.child=null;return rx(e,t,f,s,a)}if((s&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&yi(t,f!==null?f.cachePool:null),f!==null?lg(t,f):id(),ig(t);else return a=t.lanes=536870912,rx(e,t,f!==null?f.baseLanes|s:s,s,a)}else f!==null?(yi(t,f.cachePool),lg(t,f),No(),t.memoizedState=null):(e!==null&&yi(t,null),id(),No());return xn(e,t,u,s),t.child}function tl(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function rx(e,t,s,a,u){var f=nd();return f=f===null?null:{parent:Wt._currentValue,pool:f},t.memoizedState={baseLanes:s,cachePool:f},e!==null&&yi(t,null),id(),ig(t),e!==null&&Kr(e,t,a,!0),t.childLanes=u,null}function zi(e,t){return t=Ii({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function ax(e,t,s){return rr(t,e.child,null,s),e=zi(t,t.pendingProps),e.flags|=2,Hn(t),t.memoizedState=null,e}function XE(e,t,s){var a=t.pendingProps,u=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Tt){if(a.mode==="hidden")return e=zi(t,a),t.lanes=536870912,tl(null,e);if(ud(t),(e=Yt)?(e=bb(e,es),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ho!==null?{id:gs,overflow:xs}:null,retryLane:536870912,hydrationErrors:null},s=Vh(e),s.return=t,t.child=s,hn=t,Yt=null)):e=null,e===null)throw xo(t);return t.lanes=536870912,null}return zi(t,a)}var f=e.memoizedState;if(f!==null){var y=f.dehydrated;if(ud(t),u)if(t.flags&256)t.flags&=-257,t=ax(e,t,s);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(l(558));else if(tn||Kr(e,t,s,!1),u=(s&e.childLanes)!==0,tn||u){if(a=Ut,a!==null&&(y=pn(a,s),y!==0&&y!==f.retryLane))throw f.retryLane=y,Zo(e,y),Mn(a,e,y),_d;qi(),t=ax(e,t,s)}else e=f.treeContext,Yt=ns(y.nextSibling),hn=t,Tt=!0,go=null,es=!1,e!==null&&qh(t,e),t=zi(t,a),t.flags|=4096;return t}return e=Us(e.child,{mode:a.mode,children:a.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Li(e,t){var s=t.ref;if(s===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof s!="function"&&typeof s!="object")throw Error(l(284));(e===null||e.ref!==s)&&(t.flags|=4194816)}}function Md(e,t,s,a,u){return tr(t),s=fd(e,t,s,a,void 0,u),a=md(),e!==null&&!tn?(pd(e,t,u),Gs(e,t,u)):(Tt&&a&&$u(t),t.flags|=1,xn(e,t,s,u),t.child)}function lx(e,t,s,a,u,f){return tr(t),t.updateQueue=null,s=ug(t,a,s,u),cg(e),a=md(),e!==null&&!tn?(pd(e,t,f),Gs(e,t,f)):(Tt&&a&&$u(t),t.flags|=1,xn(e,t,s,f),t.child)}function ix(e,t,s,a,u){if(tr(t),t.stateNode===null){var f=Gr,y=s.contextType;typeof y=="object"&&y!==null&&(f=gn(y)),f=new s(a,f),t.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,f.updater=Od,t.stateNode=f,f._reactInternals=t,f=t.stateNode,f.props=a,f.state=t.memoizedState,f.refs={},od(t),y=s.contextType,f.context=typeof y=="object"&&y!==null?gn(y):Gr,f.state=t.memoizedState,y=s.getDerivedStateFromProps,typeof y=="function"&&(Rd(t,s,y,a),f.state=t.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(y=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),y!==f.state&&Od.enqueueReplaceState(f,f.state,null),Qa(t,a,f,u),Ka(),f.state=t.memoizedState),typeof f.componentDidMount=="function"&&(t.flags|=4194308),a=!0}else if(e===null){f=t.stateNode;var R=t.memoizedProps,G=lr(s,R);f.props=G;var le=f.context,be=s.contextType;y=Gr,typeof be=="object"&&be!==null&&(y=gn(be));var Te=s.getDerivedStateFromProps;be=typeof Te=="function"||typeof f.getSnapshotBeforeUpdate=="function",R=t.pendingProps!==R,be||typeof f.UNSAFE_componentWillReceiveProps!="function"&&typeof f.componentWillReceiveProps!="function"||(R||le!==y)&&Xg(t,f,a,y),yo=!1;var ce=t.memoizedState;f.state=ce,Qa(t,a,f,u),Ka(),le=t.memoizedState,R||ce!==le||yo?(typeof Te=="function"&&(Rd(t,s,Te,a),le=t.memoizedState),(G=yo||$g(t,s,G,a,ce,le,y))?(be||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount()),typeof f.componentDidMount=="function"&&(t.flags|=4194308)):(typeof f.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=a,t.memoizedState=le),f.props=a,f.state=le,f.context=y,a=G):(typeof f.componentDidMount=="function"&&(t.flags|=4194308),a=!1)}else{f=t.stateNode,rd(e,t),y=t.memoizedProps,be=lr(s,y),f.props=be,Te=t.pendingProps,ce=f.context,le=s.contextType,G=Gr,typeof le=="object"&&le!==null&&(G=gn(le)),R=s.getDerivedStateFromProps,(le=typeof R=="function"||typeof f.getSnapshotBeforeUpdate=="function")||typeof f.UNSAFE_componentWillReceiveProps!="function"&&typeof f.componentWillReceiveProps!="function"||(y!==Te||ce!==G)&&Xg(t,f,a,G),yo=!1,ce=t.memoizedState,f.state=ce,Qa(t,a,f,u),Ka();var me=t.memoizedState;y!==Te||ce!==me||yo||e!==null&&e.dependencies!==null&&xi(e.dependencies)?(typeof R=="function"&&(Rd(t,s,R,a),me=t.memoizedState),(be=yo||$g(t,s,be,a,ce,me,G)||e!==null&&e.dependencies!==null&&xi(e.dependencies))?(le||typeof f.UNSAFE_componentWillUpdate!="function"&&typeof f.componentWillUpdate!="function"||(typeof f.componentWillUpdate=="function"&&f.componentWillUpdate(a,me,G),typeof f.UNSAFE_componentWillUpdate=="function"&&f.UNSAFE_componentWillUpdate(a,me,G)),typeof f.componentDidUpdate=="function"&&(t.flags|=4),typeof f.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof f.componentDidUpdate!="function"||y===e.memoizedProps&&ce===e.memoizedState||(t.flags|=4),typeof f.getSnapshotBeforeUpdate!="function"||y===e.memoizedProps&&ce===e.memoizedState||(t.flags|=1024),t.memoizedProps=a,t.memoizedState=me),f.props=a,f.state=me,f.context=G,a=be):(typeof f.componentDidUpdate!="function"||y===e.memoizedProps&&ce===e.memoizedState||(t.flags|=4),typeof f.getSnapshotBeforeUpdate!="function"||y===e.memoizedProps&&ce===e.memoizedState||(t.flags|=1024),a=!1)}return f=a,Li(e,t),a=(t.flags&128)!==0,f||a?(f=t.stateNode,s=a&&typeof s.getDerivedStateFromError!="function"?null:f.render(),t.flags|=1,e!==null&&a?(t.child=rr(t,e.child,null,u),t.child=rr(t,null,s,u)):xn(e,t,s,u),t.memoizedState=f.state,e=t.child):e=Gs(e,t,u),e}function cx(e,t,s,a){return Wo(),t.flags|=256,xn(e,t,s,a),t.child}var Ad={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Dd(e){return{baseLanes:e,cachePool:Jh()}}function zd(e,t,s){return e=e!==null?e.childLanes&~s:0,t&&(e|=Yn),e}function ux(e,t,s){var a=t.pendingProps,u=!1,f=(t.flags&128)!==0,y;if((y=f)||(y=e!==null&&e.memoizedState===null?!1:(Qt.current&2)!==0),y&&(u=!0,t.flags&=-129),y=(t.flags&32)!==0,t.flags&=-33,e===null){if(Tt){if(u?Eo(t):No(),(e=Yt)?(e=bb(e,es),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ho!==null?{id:gs,overflow:xs}:null,retryLane:536870912,hydrationErrors:null},s=Vh(e),s.return=t,t.child=s,hn=t,Yt=null)):e=null,e===null)throw xo(t);return bf(e)?t.lanes=32:t.lanes=536870912,null}var R=a.children;return a=a.fallback,u?(No(),u=t.mode,R=Ii({mode:"hidden",children:R},u),a=Jo(a,u,s,null),R.return=t,a.return=t,R.sibling=a,t.child=R,a=t.child,a.memoizedState=Dd(s),a.childLanes=zd(e,y,s),t.memoizedState=Ad,tl(null,a)):(Eo(t),Ld(t,R))}var G=e.memoizedState;if(G!==null&&(R=G.dehydrated,R!==null)){if(f)t.flags&256?(Eo(t),t.flags&=-257,t=Id(e,t,s)):t.memoizedState!==null?(No(),t.child=e.child,t.flags|=128,t=null):(No(),R=a.fallback,u=t.mode,a=Ii({mode:"visible",children:a.children},u),R=Jo(R,u,s,null),R.flags|=2,a.return=t,R.return=t,a.sibling=R,t.child=a,rr(t,e.child,null,s),a=t.child,a.memoizedState=Dd(s),a.childLanes=zd(e,y,s),t.memoizedState=Ad,t=tl(null,a));else if(Eo(t),bf(R)){if(y=R.nextSibling&&R.nextSibling.dataset,y)var le=y.dgst;y=le,a=Error(l(419)),a.stack="",a.digest=y,Va({value:a,source:null,stack:null}),t=Id(e,t,s)}else if(tn||Kr(e,t,s,!1),y=(s&e.childLanes)!==0,tn||y){if(y=Ut,y!==null&&(a=pn(y,s),a!==0&&a!==G.retryLane))throw G.retryLane=a,Zo(e,a),Mn(y,e,a),_d;xf(R)||qi(),t=Id(e,t,s)}else xf(R)?(t.flags|=192,t.child=e.child,t=null):(e=G.treeContext,Yt=ns(R.nextSibling),hn=t,Tt=!0,go=null,es=!1,e!==null&&qh(t,e),t=Ld(t,a.children),t.flags|=4096);return t}return u?(No(),R=a.fallback,u=t.mode,G=e.child,le=G.sibling,a=Us(G,{mode:"hidden",children:a.children}),a.subtreeFlags=G.subtreeFlags&65011712,le!==null?R=Us(le,R):(R=Jo(R,u,s,null),R.flags|=2),R.return=t,a.return=t,a.sibling=R,t.child=a,tl(null,a),a=t.child,R=e.child.memoizedState,R===null?R=Dd(s):(u=R.cachePool,u!==null?(G=Wt._currentValue,u=u.parent!==G?{parent:G,pool:G}:u):u=Jh(),R={baseLanes:R.baseLanes|s,cachePool:u}),a.memoizedState=R,a.childLanes=zd(e,y,s),t.memoizedState=Ad,tl(e.child,a)):(Eo(t),s=e.child,e=s.sibling,s=Us(s,{mode:"visible",children:a.children}),s.return=t,s.sibling=null,e!==null&&(y=t.deletions,y===null?(t.deletions=[e],t.flags|=16):y.push(e)),t.child=s,t.memoizedState=null,s)}function Ld(e,t){return t=Ii({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Ii(e,t){return e=Bn(22,e,null,t),e.lanes=0,e}function Id(e,t,s){return rr(t,e.child,null,s),e=Ld(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function dx(e,t,s){e.lanes|=t;var a=e.alternate;a!==null&&(a.lanes|=t),Ju(e.return,t,s)}function Bd(e,t,s,a,u,f){var y=e.memoizedState;y===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:a,tail:s,tailMode:u,treeForkCount:f}:(y.isBackwards=t,y.rendering=null,y.renderingStartTime=0,y.last=a,y.tail=s,y.tailMode=u,y.treeForkCount=f)}function fx(e,t,s){var a=t.pendingProps,u=a.revealOrder,f=a.tail;a=a.children;var y=Qt.current,R=(y&2)!==0;if(R?(y=y&1|2,t.flags|=128):y&=1,I(Qt,y),xn(e,t,a,s),a=Tt?Ya:0,!R&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&dx(e,s,t);else if(e.tag===19)dx(e,s,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(u){case"forwards":for(s=t.child,u=null;s!==null;)e=s.alternate,e!==null&&Ti(e)===null&&(u=s),s=s.sibling;s=u,s===null?(u=t.child,t.child=null):(u=s.sibling,s.sibling=null),Bd(t,!1,u,s,f,a);break;case"backwards":case"unstable_legacy-backwards":for(s=null,u=t.child,t.child=null;u!==null;){if(e=u.alternate,e!==null&&Ti(e)===null){t.child=u;break}e=u.sibling,u.sibling=s,s=u,u=e}Bd(t,!0,s,null,f,a);break;case"together":Bd(t,!1,null,null,void 0,a);break;default:t.memoizedState=null}return t.child}function Gs(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),wo|=t.lanes,(s&t.childLanes)===0)if(e!==null){if(Kr(e,t,s,!1),(s&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(l(153));if(t.child!==null){for(e=t.child,s=Us(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=Us(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function Ud(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&xi(e)))}function KE(e,t,s){switch(t.tag){case 3:re(t,t.stateNode.containerInfo),bo(t,Wt,e.memoizedState.cache),Wo();break;case 27:case 5:_e(t);break;case 4:re(t,t.stateNode.containerInfo);break;case 10:bo(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,ud(t),null;break;case 13:var a=t.memoizedState;if(a!==null)return a.dehydrated!==null?(Eo(t),t.flags|=128,null):(s&t.child.childLanes)!==0?ux(e,t,s):(Eo(t),e=Gs(e,t,s),e!==null?e.sibling:null);Eo(t);break;case 19:var u=(e.flags&128)!==0;if(a=(s&t.childLanes)!==0,a||(Kr(e,t,s,!1),a=(s&t.childLanes)!==0),u){if(a)return fx(e,t,s);t.flags|=128}if(u=t.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),I(Qt,Qt.current),a)break;return null;case 22:return t.lanes=0,ox(e,t,s,t.pendingProps);case 24:bo(t,Wt,e.memoizedState.cache)}return Gs(e,t,s)}function mx(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps)tn=!0;else{if(!Ud(e,s)&&(t.flags&128)===0)return tn=!1,KE(e,t,s);tn=(e.flags&131072)!==0}else tn=!1,Tt&&(t.flags&1048576)!==0&&Gh(t,Ya,t.index);switch(t.lanes=0,t.tag){case 16:e:{var a=t.pendingProps;if(e=sr(t.elementType),t.type=e,typeof e=="function")Fu(e)?(a=lr(e,a),t.tag=1,t=ix(null,t,e,a,s)):(t.tag=0,t=Md(null,t,e,a,s));else{if(e!=null){var u=e.$$typeof;if(u===C){t.tag=11,t=tx(null,t,e,a,s);break e}else if(u===L){t.tag=14,t=nx(null,t,e,a,s);break e}}throw t=oe(e)||e,Error(l(306,t,""))}}return t;case 0:return Md(e,t,t.type,t.pendingProps,s);case 1:return a=t.type,u=lr(a,t.pendingProps),ix(e,t,a,u,s);case 3:e:{if(re(t,t.stateNode.containerInfo),e===null)throw Error(l(387));a=t.pendingProps;var f=t.memoizedState;u=f.element,rd(e,t),Qa(t,a,null,s);var y=t.memoizedState;if(a=y.cache,bo(t,Wt,a),a!==f.cache&&Wu(t,[Wt],s,!0),Ka(),a=y.element,f.isDehydrated)if(f={element:a,isDehydrated:!1,cache:y.cache},t.updateQueue.baseState=f,t.memoizedState=f,t.flags&256){t=cx(e,t,a,s);break e}else if(a!==u){u=Zn(Error(l(424)),t),Va(u),t=cx(e,t,a,s);break e}else for(e=t.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,Yt=ns(e.firstChild),hn=t,Tt=!0,go=null,es=!0,s=og(t,null,a,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(Wo(),a===u){t=Gs(e,t,s);break e}xn(e,t,a,s)}t=t.child}return t;case 26:return Li(e,t),e===null?(s=jb(t.type,null,t.pendingProps,null))?t.memoizedState=s:Tt||(s=t.type,e=t.pendingProps,a=Wi(Y.current).createElement(s),a[sn]=t,a[wn]=e,bn(a,s,e),cn(a),t.stateNode=a):t.memoizedState=jb(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return _e(t),e===null&&Tt&&(a=t.stateNode=Sb(t.type,t.pendingProps,Y.current),hn=t,es=!0,u=Yt,_o(t.type)?(yf=u,Yt=ns(a.firstChild)):Yt=u),xn(e,t,t.pendingProps.children,s),Li(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Tt&&((u=a=Yt)&&(a=TN(a,t.type,t.pendingProps,es),a!==null?(t.stateNode=a,hn=t,Yt=ns(a.firstChild),es=!1,u=!0):u=!1),u||xo(t)),_e(t),u=t.type,f=t.pendingProps,y=e!==null?e.memoizedProps:null,a=f.children,pf(u,f)?a=null:y!==null&&pf(u,y)&&(t.flags|=32),t.memoizedState!==null&&(u=fd(e,t,HE,null,null,s),gl._currentValue=u),Li(e,t),xn(e,t,a,s),t.child;case 6:return e===null&&Tt&&((e=s=Yt)&&(s=wN(s,t.pendingProps,es),s!==null?(t.stateNode=s,hn=t,Yt=null,e=!0):e=!1),e||xo(t)),null;case 13:return ux(e,t,s);case 4:return re(t,t.stateNode.containerInfo),a=t.pendingProps,e===null?t.child=rr(t,null,a,s):xn(e,t,a,s),t.child;case 11:return tx(e,t,t.type,t.pendingProps,s);case 7:return xn(e,t,t.pendingProps,s),t.child;case 8:return xn(e,t,t.pendingProps.children,s),t.child;case 12:return xn(e,t,t.pendingProps.children,s),t.child;case 10:return a=t.pendingProps,bo(t,t.type,a.value),xn(e,t,a.children,s),t.child;case 9:return u=t.type._context,a=t.pendingProps.children,tr(t),u=gn(u),a=a(u),t.flags|=1,xn(e,t,a,s),t.child;case 14:return nx(e,t,t.type,t.pendingProps,s);case 15:return sx(e,t,t.type,t.pendingProps,s);case 19:return fx(e,t,s);case 31:return XE(e,t,s);case 22:return ox(e,t,s,t.pendingProps);case 24:return tr(t),a=gn(Wt),e===null?(u=nd(),u===null&&(u=Ut,f=ed(),u.pooledCache=f,f.refCount++,f!==null&&(u.pooledCacheLanes|=s),u=f),t.memoizedState={parent:a,cache:u},od(t),bo(t,Wt,u)):((e.lanes&s)!==0&&(rd(e,t),Qa(t,null,null,s),Ka()),u=e.memoizedState,f=t.memoizedState,u.parent!==a?(u={parent:a,cache:a},t.memoizedState=u,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=u),bo(t,Wt,a)):(a=f.cache,bo(t,Wt,a),a!==u.cache&&Wu(t,[Wt],s,!0))),xn(e,t,t.pendingProps.children,s),t.child;case 29:throw t.pendingProps}throw Error(l(156,t.tag))}function qs(e){e.flags|=4}function Hd(e,t,s,a,u){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(u&335544128)===u)if(e.stateNode.complete)e.flags|=8192;else if(Hx())e.flags|=8192;else throw or=Si,sd}else e.flags&=-16777217}function px(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Ob(t))if(Hx())e.flags|=8192;else throw or=Si,sd}function Bi(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?rt():536870912,e.lanes|=t,la|=t)}function nl(e,t){if(!Tt)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:a.sibling=null}}function Vt(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,a=0;if(t)for(var u=e.child;u!==null;)s|=u.lanes|u.childLanes,a|=u.subtreeFlags&65011712,a|=u.flags&65011712,u.return=e,u=u.sibling;else for(u=e.child;u!==null;)s|=u.lanes|u.childLanes,a|=u.subtreeFlags,a|=u.flags,u.return=e,u=u.sibling;return e.subtreeFlags|=a,e.childLanes=s,t}function QE(e,t,s){var a=t.pendingProps;switch(Xu(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Vt(t),null;case 1:return Vt(t),null;case 3:return s=t.stateNode,a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Ys(Wt),de(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(Xr(t)?qs(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Qu())),Vt(t),null;case 26:var u=t.type,f=t.memoizedState;return e===null?(qs(t),f!==null?(Vt(t),px(t,f)):(Vt(t),Hd(t,u,null,a,s))):f?f!==e.memoizedState?(qs(t),Vt(t),px(t,f)):(Vt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==a&&qs(t),Vt(t),Hd(t,u,e,a,s)),null;case 27:if(Ye(t),s=Y.current,u=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==a&&qs(t);else{if(!a){if(t.stateNode===null)throw Error(l(166));return Vt(t),null}e=V.current,Xr(t)?$h(t):(e=Sb(u,a,s),t.stateNode=e,qs(t))}return Vt(t),null;case 5:if(Ye(t),u=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==a&&qs(t);else{if(!a){if(t.stateNode===null)throw Error(l(166));return Vt(t),null}if(f=V.current,Xr(t))$h(t);else{var y=Wi(Y.current);switch(f){case 1:f=y.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:f=y.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":f=y.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":f=y.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":f=y.createElement("div"),f.innerHTML="<script><\/script>",f=f.removeChild(f.firstChild);break;case"select":f=typeof a.is=="string"?y.createElement("select",{is:a.is}):y.createElement("select"),a.multiple?f.multiple=!0:a.size&&(f.size=a.size);break;default:f=typeof a.is=="string"?y.createElement(u,{is:a.is}):y.createElement(u)}}f[sn]=t,f[wn]=a;e:for(y=t.child;y!==null;){if(y.tag===5||y.tag===6)f.appendChild(y.stateNode);else if(y.tag!==4&&y.tag!==27&&y.child!==null){y.child.return=y,y=y.child;continue}if(y===t)break e;for(;y.sibling===null;){if(y.return===null||y.return===t)break e;y=y.return}y.sibling.return=y.return,y=y.sibling}t.stateNode=f;e:switch(bn(f,u,a),u){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}a&&qs(t)}}return Vt(t),Hd(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,s),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==a&&qs(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(l(166));if(e=Y.current,Xr(t)){if(e=t.stateNode,s=t.memoizedProps,a=null,u=hn,u!==null)switch(u.tag){case 27:case 5:a=u.memoizedProps}e[sn]=t,e=!!(e.nodeValue===s||a!==null&&a.suppressHydrationWarning===!0||ub(e.nodeValue,s)),e||xo(t,!0)}else e=Wi(e).createTextNode(a),e[sn]=t,t.stateNode=e}return Vt(t),null;case 31:if(s=t.memoizedState,e===null||e.memoizedState!==null){if(a=Xr(t),s!==null){if(e===null){if(!a)throw Error(l(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(557));e[sn]=t}else Wo(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Vt(t),e=!1}else s=Qu(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=s),e=!0;if(!e)return t.flags&256?(Hn(t),t):(Hn(t),null);if((t.flags&128)!==0)throw Error(l(558))}return Vt(t),null;case 13:if(a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(u=Xr(t),a!==null&&a.dehydrated!==null){if(e===null){if(!u)throw Error(l(318));if(u=t.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(l(317));u[sn]=t}else Wo(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Vt(t),u=!1}else u=Qu(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=u),u=!0;if(!u)return t.flags&256?(Hn(t),t):(Hn(t),null)}return Hn(t),(t.flags&128)!==0?(t.lanes=s,t):(s=a!==null,e=e!==null&&e.memoizedState!==null,s&&(a=t.child,u=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(u=a.alternate.memoizedState.cachePool.pool),f=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(f=a.memoizedState.cachePool.pool),f!==u&&(a.flags|=2048)),s!==e&&s&&(t.child.flags|=8192),Bi(t,t.updateQueue),Vt(t),null);case 4:return de(),e===null&&cf(t.stateNode.containerInfo),Vt(t),null;case 10:return Ys(t.type),Vt(t),null;case 19:if(X(Qt),a=t.memoizedState,a===null)return Vt(t),null;if(u=(t.flags&128)!==0,f=a.rendering,f===null)if(u)nl(a,!1);else{if($t!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(f=Ti(e),f!==null){for(t.flags|=128,nl(a,!1),e=f.updateQueue,t.updateQueue=e,Bi(t,e),t.subtreeFlags=0,e=s,s=t.child;s!==null;)Yh(s,e),s=s.sibling;return I(Qt,Qt.current&1|2),Tt&&Hs(t,a.treeForkCount),t.child}e=e.sibling}a.tail!==null&&ee()>Vi&&(t.flags|=128,u=!0,nl(a,!1),t.lanes=4194304)}else{if(!u)if(e=Ti(f),e!==null){if(t.flags|=128,u=!0,e=e.updateQueue,t.updateQueue=e,Bi(t,e),nl(a,!0),a.tail===null&&a.tailMode==="hidden"&&!f.alternate&&!Tt)return Vt(t),null}else 2*ee()-a.renderingStartTime>Vi&&s!==536870912&&(t.flags|=128,u=!0,nl(a,!1),t.lanes=4194304);a.isBackwards?(f.sibling=t.child,t.child=f):(e=a.last,e!==null?e.sibling=f:t.child=f,a.last=f)}return a.tail!==null?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=ee(),e.sibling=null,s=Qt.current,I(Qt,u?s&1|2:s&1),Tt&&Hs(t,a.treeForkCount),e):(Vt(t),null);case 22:case 23:return Hn(t),cd(),a=t.memoizedState!==null,e!==null?e.memoizedState!==null!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?(s&536870912)!==0&&(t.flags&128)===0&&(Vt(t),t.subtreeFlags&6&&(t.flags|=8192)):Vt(t),s=t.updateQueue,s!==null&&Bi(t,s.retryQueue),s=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),a=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),a!==s&&(t.flags|=2048),e!==null&&X(nr),null;case 24:return s=null,e!==null&&(s=e.memoizedState.cache),t.memoizedState.cache!==s&&(t.flags|=2048),Ys(Wt),Vt(t),null;case 25:return null;case 30:return null}throw Error(l(156,t.tag))}function ZE(e,t){switch(Xu(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ys(Wt),de(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ye(t),null;case 31:if(t.memoizedState!==null){if(Hn(t),t.alternate===null)throw Error(l(340));Wo()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Hn(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(l(340));Wo()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return X(Qt),null;case 4:return de(),null;case 10:return Ys(t.type),null;case 22:case 23:return Hn(t),cd(),e!==null&&X(nr),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ys(Wt),null;case 25:return null;default:return null}}function hx(e,t){switch(Xu(t),t.tag){case 3:Ys(Wt),de();break;case 26:case 27:case 5:Ye(t);break;case 4:de();break;case 31:t.memoizedState!==null&&Hn(t);break;case 13:Hn(t);break;case 19:X(Qt);break;case 10:Ys(t.type);break;case 22:case 23:Hn(t),cd(),e!==null&&X(nr);break;case 24:Ys(Wt)}}function sl(e,t){try{var s=t.updateQueue,a=s!==null?s.lastEffect:null;if(a!==null){var u=a.next;s=u;do{if((s.tag&e)===e){a=void 0;var f=s.create,y=s.inst;a=f(),y.destroy=a}s=s.next}while(s!==u)}}catch(R){At(t,t.return,R)}}function jo(e,t,s){try{var a=t.updateQueue,u=a!==null?a.lastEffect:null;if(u!==null){var f=u.next;a=f;do{if((a.tag&e)===e){var y=a.inst,R=y.destroy;if(R!==void 0){y.destroy=void 0,u=t;var G=s,le=R;try{le()}catch(be){At(u,G,be)}}}a=a.next}while(a!==f)}}catch(be){At(t,t.return,be)}}function gx(e){var t=e.updateQueue;if(t!==null){var s=e.stateNode;try{ag(t,s)}catch(a){At(e,e.return,a)}}}function xx(e,t,s){s.props=lr(e.type,e.memoizedProps),s.state=e.memoizedState;try{s.componentWillUnmount()}catch(a){At(e,t,a)}}function ol(e,t){try{var s=e.ref;if(s!==null){switch(e.tag){case 26:case 27:case 5:var a=e.stateNode;break;case 30:a=e.stateNode;break;default:a=e.stateNode}typeof s=="function"?e.refCleanup=s(a):s.current=a}}catch(u){At(e,t,u)}}function bs(e,t){var s=e.ref,a=e.refCleanup;if(s!==null)if(typeof a=="function")try{a()}catch(u){At(e,t,u)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(u){At(e,t,u)}else s.current=null}function bx(e){var t=e.type,s=e.memoizedProps,a=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":s.autoFocus&&a.focus();break e;case"img":s.src?a.src=s.src:s.srcSet&&(a.srcset=s.srcSet)}}catch(u){At(e,e.return,u)}}function Pd(e,t,s){try{var a=e.stateNode;yN(a,e.type,s,t),a[wn]=t}catch(u){At(e,e.return,u)}}function yx(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&_o(e.type)||e.tag===4}function Yd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||yx(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&_o(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Vd(e,t,s){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(e,t):(t=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,t.appendChild(e),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=Is));else if(a!==4&&(a===27&&_o(e.type)&&(s=e.stateNode,t=null),e=e.child,e!==null))for(Vd(e,t,s),e=e.sibling;e!==null;)Vd(e,t,s),e=e.sibling}function Ui(e,t,s){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(a!==4&&(a===27&&_o(e.type)&&(s=e.stateNode),e=e.child,e!==null))for(Ui(e,t,s),e=e.sibling;e!==null;)Ui(e,t,s),e=e.sibling}function vx(e){var t=e.stateNode,s=e.memoizedProps;try{for(var a=e.type,u=t.attributes;u.length;)t.removeAttributeNode(u[0]);bn(t,a,s),t[sn]=e,t[wn]=s}catch(f){At(e,e.return,f)}}var $s=!1,nn=!1,Fd=!1,Sx=typeof WeakSet=="function"?WeakSet:Set,un=null;function JE(e,t){if(e=e.containerInfo,ff=ac,e=Ah(e),Iu(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var a=s.getSelection&&s.getSelection();if(a&&a.rangeCount!==0){s=a.anchorNode;var u=a.anchorOffset,f=a.focusNode;a=a.focusOffset;try{s.nodeType,f.nodeType}catch{s=null;break e}var y=0,R=-1,G=-1,le=0,be=0,Te=e,ce=null;t:for(;;){for(var me;Te!==s||u!==0&&Te.nodeType!==3||(R=y+u),Te!==f||a!==0&&Te.nodeType!==3||(G=y+a),Te.nodeType===3&&(y+=Te.nodeValue.length),(me=Te.firstChild)!==null;)ce=Te,Te=me;for(;;){if(Te===e)break t;if(ce===s&&++le===u&&(R=y),ce===f&&++be===a&&(G=y),(me=Te.nextSibling)!==null)break;Te=ce,ce=Te.parentNode}Te=me}s=R===-1||G===-1?null:{start:R,end:G}}else s=null}s=s||{start:0,end:0}}else s=null;for(mf={focusedElem:e,selectionRange:s},ac=!1,un=t;un!==null;)if(t=un,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,un=e;else for(;un!==null;){switch(t=un,f=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(s=0;s<e.length;s++)u=e[s],u.ref.impl=u.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&f!==null){e=void 0,s=t,u=f.memoizedProps,f=f.memoizedState,a=s.stateNode;try{var $e=lr(s.type,u);e=a.getSnapshotBeforeUpdate($e,f),a.__reactInternalSnapshotBeforeUpdate=e}catch(st){At(s,s.return,st)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,s=e.nodeType,s===9)gf(e);else if(s===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":gf(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(l(163))}if(e=t.sibling,e!==null){e.return=t.return,un=e;break}un=t.return}}function Ex(e,t,s){var a=s.flags;switch(s.tag){case 0:case 11:case 15:Ks(e,s),a&4&&sl(5,s);break;case 1:if(Ks(e,s),a&4)if(e=s.stateNode,t===null)try{e.componentDidMount()}catch(y){At(s,s.return,y)}else{var u=lr(s.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(u,t,e.__reactInternalSnapshotBeforeUpdate)}catch(y){At(s,s.return,y)}}a&64&&gx(s),a&512&&ol(s,s.return);break;case 3:if(Ks(e,s),a&64&&(e=s.updateQueue,e!==null)){if(t=null,s.child!==null)switch(s.child.tag){case 27:case 5:t=s.child.stateNode;break;case 1:t=s.child.stateNode}try{ag(e,t)}catch(y){At(s,s.return,y)}}break;case 27:t===null&&a&4&&vx(s);case 26:case 5:Ks(e,s),t===null&&a&4&&bx(s),a&512&&ol(s,s.return);break;case 12:Ks(e,s);break;case 31:Ks(e,s),a&4&&Tx(e,s);break;case 13:Ks(e,s),a&4&&wx(e,s),a&64&&(e=s.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(s=lN.bind(null,s),CN(e,s))));break;case 22:if(a=s.memoizedState!==null||$s,!a){t=t!==null&&t.memoizedState!==null||nn,u=$s;var f=nn;$s=a,(nn=t)&&!f?Qs(e,s,(s.subtreeFlags&8772)!==0):Ks(e,s),$s=u,nn=f}break;case 30:break;default:Ks(e,s)}}function Nx(e){var t=e.alternate;t!==null&&(e.alternate=null,Nx(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&vu(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Gt=null,Rn=!1;function Xs(e,t,s){for(s=s.child;s!==null;)jx(e,t,s),s=s.sibling}function jx(e,t,s){if(jt&&typeof jt.onCommitFiberUnmount=="function")try{jt.onCommitFiberUnmount(nt,s)}catch{}switch(s.tag){case 26:nn||bs(s,t),Xs(e,t,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:nn||bs(s,t);var a=Gt,u=Rn;_o(s.type)&&(Gt=s.stateNode,Rn=!1),Xs(e,t,s),ml(s.stateNode),Gt=a,Rn=u;break;case 5:nn||bs(s,t);case 6:if(a=Gt,u=Rn,Gt=null,Xs(e,t,s),Gt=a,Rn=u,Gt!==null)if(Rn)try{(Gt.nodeType===9?Gt.body:Gt.nodeName==="HTML"?Gt.ownerDocument.body:Gt).removeChild(s.stateNode)}catch(f){At(s,t,f)}else try{Gt.removeChild(s.stateNode)}catch(f){At(s,t,f)}break;case 18:Gt!==null&&(Rn?(e=Gt,gb(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,s.stateNode),ha(e)):gb(Gt,s.stateNode));break;case 4:a=Gt,u=Rn,Gt=s.stateNode.containerInfo,Rn=!0,Xs(e,t,s),Gt=a,Rn=u;break;case 0:case 11:case 14:case 15:jo(2,s,t),nn||jo(4,s,t),Xs(e,t,s);break;case 1:nn||(bs(s,t),a=s.stateNode,typeof a.componentWillUnmount=="function"&&xx(s,t,a)),Xs(e,t,s);break;case 21:Xs(e,t,s);break;case 22:nn=(a=nn)||s.memoizedState!==null,Xs(e,t,s),nn=a;break;default:Xs(e,t,s)}}function Tx(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{ha(e)}catch(s){At(t,t.return,s)}}}function wx(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{ha(e)}catch(s){At(t,t.return,s)}}function WE(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Sx),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Sx),t;default:throw Error(l(435,e.tag))}}function Hi(e,t){var s=WE(e);t.forEach(function(a){if(!s.has(a)){s.add(a);var u=iN.bind(null,e,a);a.then(u,u)}})}function On(e,t){var s=t.deletions;if(s!==null)for(var a=0;a<s.length;a++){var u=s[a],f=e,y=t,R=y;e:for(;R!==null;){switch(R.tag){case 27:if(_o(R.type)){Gt=R.stateNode,Rn=!1;break e}break;case 5:Gt=R.stateNode,Rn=!1;break e;case 3:case 4:Gt=R.stateNode.containerInfo,Rn=!0;break e}R=R.return}if(Gt===null)throw Error(l(160));jx(f,y,u),Gt=null,Rn=!1,f=u.alternate,f!==null&&(f.return=null),u.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Cx(t,e),t=t.sibling}var us=null;function Cx(e,t){var s=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:On(t,e),kn(e),a&4&&(jo(3,e,e.return),sl(3,e),jo(5,e,e.return));break;case 1:On(t,e),kn(e),a&512&&(nn||s===null||bs(s,s.return)),a&64&&$s&&(e=e.updateQueue,e!==null&&(a=e.callbacks,a!==null&&(s=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=s===null?a:s.concat(a))));break;case 26:var u=us;if(On(t,e),kn(e),a&512&&(nn||s===null||bs(s,s.return)),a&4){var f=s!==null?s.memoizedState:null;if(a=e.memoizedState,s===null)if(a===null)if(e.stateNode===null){e:{a=e.type,s=e.memoizedProps,u=u.ownerDocument||u;t:switch(a){case"title":f=u.getElementsByTagName("title")[0],(!f||f[_a]||f[sn]||f.namespaceURI==="http://www.w3.org/2000/svg"||f.hasAttribute("itemprop"))&&(f=u.createElement(a),u.head.insertBefore(f,u.querySelector("head > title"))),bn(f,a,s),f[sn]=e,cn(f),a=f;break e;case"link":var y=Cb("link","href",u).get(a+(s.href||""));if(y){for(var R=0;R<y.length;R++)if(f=y[R],f.getAttribute("href")===(s.href==null||s.href===""?null:s.href)&&f.getAttribute("rel")===(s.rel==null?null:s.rel)&&f.getAttribute("title")===(s.title==null?null:s.title)&&f.getAttribute("crossorigin")===(s.crossOrigin==null?null:s.crossOrigin)){y.splice(R,1);break t}}f=u.createElement(a),bn(f,a,s),u.head.appendChild(f);break;case"meta":if(y=Cb("meta","content",u).get(a+(s.content||""))){for(R=0;R<y.length;R++)if(f=y[R],f.getAttribute("content")===(s.content==null?null:""+s.content)&&f.getAttribute("name")===(s.name==null?null:s.name)&&f.getAttribute("property")===(s.property==null?null:s.property)&&f.getAttribute("http-equiv")===(s.httpEquiv==null?null:s.httpEquiv)&&f.getAttribute("charset")===(s.charSet==null?null:s.charSet)){y.splice(R,1);break t}}f=u.createElement(a),bn(f,a,s),u.head.appendChild(f);break;default:throw Error(l(468,a))}f[sn]=e,cn(f),a=f}e.stateNode=a}else Rb(u,e.type,e.stateNode);else e.stateNode=wb(u,a,e.memoizedProps);else f!==a?(f===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):f.count--,a===null?Rb(u,e.type,e.stateNode):wb(u,a,e.memoizedProps)):a===null&&e.stateNode!==null&&Pd(e,e.memoizedProps,s.memoizedProps)}break;case 27:On(t,e),kn(e),a&512&&(nn||s===null||bs(s,s.return)),s!==null&&a&4&&Pd(e,e.memoizedProps,s.memoizedProps);break;case 5:if(On(t,e),kn(e),a&512&&(nn||s===null||bs(s,s.return)),e.flags&32){u=e.stateNode;try{Br(u,"")}catch($e){At(e,e.return,$e)}}a&4&&e.stateNode!=null&&(u=e.memoizedProps,Pd(e,u,s!==null?s.memoizedProps:u)),a&1024&&(Fd=!0);break;case 6:if(On(t,e),kn(e),a&4){if(e.stateNode===null)throw Error(l(162));a=e.memoizedProps,s=e.stateNode;try{s.nodeValue=a}catch($e){At(e,e.return,$e)}}break;case 3:if(nc=null,u=us,us=ec(t.containerInfo),On(t,e),us=u,kn(e),a&4&&s!==null&&s.memoizedState.isDehydrated)try{ha(t.containerInfo)}catch($e){At(e,e.return,$e)}Fd&&(Fd=!1,Rx(e));break;case 4:a=us,us=ec(e.stateNode.containerInfo),On(t,e),kn(e),us=a;break;case 12:On(t,e),kn(e);break;case 31:On(t,e),kn(e),a&4&&(a=e.updateQueue,a!==null&&(e.updateQueue=null,Hi(e,a)));break;case 13:On(t,e),kn(e),e.child.flags&8192&&e.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(Yi=ee()),a&4&&(a=e.updateQueue,a!==null&&(e.updateQueue=null,Hi(e,a)));break;case 22:u=e.memoizedState!==null;var G=s!==null&&s.memoizedState!==null,le=$s,be=nn;if($s=le||u,nn=be||G,On(t,e),nn=be,$s=le,kn(e),a&8192)e:for(t=e.stateNode,t._visibility=u?t._visibility&-2:t._visibility|1,u&&(s===null||G||$s||nn||ir(e)),s=null,t=e;;){if(t.tag===5||t.tag===26){if(s===null){G=s=t;try{if(f=G.stateNode,u)y=f.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{R=G.stateNode;var Te=G.memoizedProps.style,ce=Te!=null&&Te.hasOwnProperty("display")?Te.display:null;R.style.display=ce==null||typeof ce=="boolean"?"":(""+ce).trim()}}catch($e){At(G,G.return,$e)}}}else if(t.tag===6){if(s===null){G=t;try{G.stateNode.nodeValue=u?"":G.memoizedProps}catch($e){At(G,G.return,$e)}}}else if(t.tag===18){if(s===null){G=t;try{var me=G.stateNode;u?xb(me,!0):xb(G.stateNode,!1)}catch($e){At(G,G.return,$e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;s===t&&(s=null),t=t.return}s===t&&(s=null),t.sibling.return=t.return,t=t.sibling}a&4&&(a=e.updateQueue,a!==null&&(s=a.retryQueue,s!==null&&(a.retryQueue=null,Hi(e,s))));break;case 19:On(t,e),kn(e),a&4&&(a=e.updateQueue,a!==null&&(e.updateQueue=null,Hi(e,a)));break;case 30:break;case 21:break;default:On(t,e),kn(e)}}function kn(e){var t=e.flags;if(t&2){try{for(var s,a=e.return;a!==null;){if(yx(a)){s=a;break}a=a.return}if(s==null)throw Error(l(160));switch(s.tag){case 27:var u=s.stateNode,f=Yd(e);Ui(e,f,u);break;case 5:var y=s.stateNode;s.flags&32&&(Br(y,""),s.flags&=-33);var R=Yd(e);Ui(e,R,y);break;case 3:case 4:var G=s.stateNode.containerInfo,le=Yd(e);Vd(e,le,G);break;default:throw Error(l(161))}}catch(be){At(e,e.return,be)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Rx(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Rx(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Ks(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Ex(e,t.alternate,t),t=t.sibling}function ir(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:jo(4,t,t.return),ir(t);break;case 1:bs(t,t.return);var s=t.stateNode;typeof s.componentWillUnmount=="function"&&xx(t,t.return,s),ir(t);break;case 27:ml(t.stateNode);case 26:case 5:bs(t,t.return),ir(t);break;case 22:t.memoizedState===null&&ir(t);break;case 30:ir(t);break;default:ir(t)}e=e.sibling}}function Qs(e,t,s){for(s=s&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var a=t.alternate,u=e,f=t,y=f.flags;switch(f.tag){case 0:case 11:case 15:Qs(u,f,s),sl(4,f);break;case 1:if(Qs(u,f,s),a=f,u=a.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(le){At(a,a.return,le)}if(a=f,u=a.updateQueue,u!==null){var R=a.stateNode;try{var G=u.shared.hiddenCallbacks;if(G!==null)for(u.shared.hiddenCallbacks=null,u=0;u<G.length;u++)rg(G[u],R)}catch(le){At(a,a.return,le)}}s&&y&64&&gx(f),ol(f,f.return);break;case 27:vx(f);case 26:case 5:Qs(u,f,s),s&&a===null&&y&4&&bx(f),ol(f,f.return);break;case 12:Qs(u,f,s);break;case 31:Qs(u,f,s),s&&y&4&&Tx(u,f);break;case 13:Qs(u,f,s),s&&y&4&&wx(u,f);break;case 22:f.memoizedState===null&&Qs(u,f,s),ol(f,f.return);break;case 30:break;default:Qs(u,f,s)}t=t.sibling}}function Gd(e,t){var s=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==s&&(e!=null&&e.refCount++,s!=null&&Fa(s))}function qd(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Fa(e))}function ds(e,t,s,a){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Ox(e,t,s,a),t=t.sibling}function Ox(e,t,s,a){var u=t.flags;switch(t.tag){case 0:case 11:case 15:ds(e,t,s,a),u&2048&&sl(9,t);break;case 1:ds(e,t,s,a);break;case 3:ds(e,t,s,a),u&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Fa(e)));break;case 12:if(u&2048){ds(e,t,s,a),e=t.stateNode;try{var f=t.memoizedProps,y=f.id,R=f.onPostCommit;typeof R=="function"&&R(y,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(G){At(t,t.return,G)}}else ds(e,t,s,a);break;case 31:ds(e,t,s,a);break;case 13:ds(e,t,s,a);break;case 23:break;case 22:f=t.stateNode,y=t.alternate,t.memoizedState!==null?f._visibility&2?ds(e,t,s,a):rl(e,t):f._visibility&2?ds(e,t,s,a):(f._visibility|=2,oa(e,t,s,a,(t.subtreeFlags&10256)!==0||!1)),u&2048&&Gd(y,t);break;case 24:ds(e,t,s,a),u&2048&&qd(t.alternate,t);break;default:ds(e,t,s,a)}}function oa(e,t,s,a,u){for(u=u&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var f=e,y=t,R=s,G=a,le=y.flags;switch(y.tag){case 0:case 11:case 15:oa(f,y,R,G,u),sl(8,y);break;case 23:break;case 22:var be=y.stateNode;y.memoizedState!==null?be._visibility&2?oa(f,y,R,G,u):rl(f,y):(be._visibility|=2,oa(f,y,R,G,u)),u&&le&2048&&Gd(y.alternate,y);break;case 24:oa(f,y,R,G,u),u&&le&2048&&qd(y.alternate,y);break;default:oa(f,y,R,G,u)}t=t.sibling}}function rl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var s=e,a=t,u=a.flags;switch(a.tag){case 22:rl(s,a),u&2048&&Gd(a.alternate,a);break;case 24:rl(s,a),u&2048&&qd(a.alternate,a);break;default:rl(s,a)}t=t.sibling}}var al=8192;function ra(e,t,s){if(e.subtreeFlags&al)for(e=e.child;e!==null;)kx(e,t,s),e=e.sibling}function kx(e,t,s){switch(e.tag){case 26:ra(e,t,s),e.flags&al&&e.memoizedState!==null&&UN(s,us,e.memoizedState,e.memoizedProps);break;case 5:ra(e,t,s);break;case 3:case 4:var a=us;us=ec(e.stateNode.containerInfo),ra(e,t,s),us=a;break;case 22:e.memoizedState===null&&(a=e.alternate,a!==null&&a.memoizedState!==null?(a=al,al=16777216,ra(e,t,s),al=a):ra(e,t,s));break;default:ra(e,t,s)}}function _x(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function ll(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var a=t[s];un=a,Ax(a,e)}_x(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Mx(e),e=e.sibling}function Mx(e){switch(e.tag){case 0:case 11:case 15:ll(e),e.flags&2048&&jo(9,e,e.return);break;case 3:ll(e);break;case 12:ll(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Pi(e)):ll(e);break;default:ll(e)}}function Pi(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var a=t[s];un=a,Ax(a,e)}_x(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:jo(8,t,t.return),Pi(t);break;case 22:s=t.stateNode,s._visibility&2&&(s._visibility&=-3,Pi(t));break;default:Pi(t)}e=e.sibling}}function Ax(e,t){for(;un!==null;){var s=un;switch(s.tag){case 0:case 11:case 15:jo(8,s,t);break;case 23:case 22:if(s.memoizedState!==null&&s.memoizedState.cachePool!==null){var a=s.memoizedState.cachePool.pool;a!=null&&a.refCount++}break;case 24:Fa(s.memoizedState.cache)}if(a=s.child,a!==null)a.return=s,un=a;else e:for(s=e;un!==null;){a=un;var u=a.sibling,f=a.return;if(Nx(a),a===s){un=null;break e}if(u!==null){u.return=f,un=u;break e}un=f}}}var eN={getCacheForType:function(e){var t=gn(Wt),s=t.data.get(e);return s===void 0&&(s=e(),t.data.set(e,s)),s},cacheSignal:function(){return gn(Wt).controller.signal}},tN=typeof WeakMap=="function"?WeakMap:Map,_t=0,Ut=null,xt=null,vt=0,Mt=0,Pn=null,To=!1,aa=!1,$d=!1,Zs=0,$t=0,wo=0,cr=0,Xd=0,Yn=0,la=0,il=null,_n=null,Kd=!1,Yi=0,Dx=0,Vi=1/0,Fi=null,Co=null,on=0,Ro=null,ia=null,Js=0,Qd=0,Zd=null,zx=null,cl=0,Jd=null;function Vn(){return(_t&2)!==0&&vt!==0?vt&-vt:w.T!==null?of():zs()}function Lx(){if(Yn===0)if((vt&536870912)===0||Tt){var e=Ce;Ce<<=1,(Ce&3932160)===0&&(Ce=262144),Yn=e}else Yn=536870912;return e=Un.current,e!==null&&(e.flags|=32),Yn}function Mn(e,t,s){(e===Ut&&(Mt===2||Mt===9)||e.cancelPendingCommit!==null)&&(ca(e,0),Oo(e,vt,Yn,!1)),lt(e,s),((_t&2)===0||e!==Ut)&&(e===Ut&&((_t&2)===0&&(cr|=s),$t===4&&Oo(e,vt,Yn,!1)),ys(e))}function Ix(e,t,s){if((_t&6)!==0)throw Error(l(327));var a=!s&&(t&127)===0&&(t&e.expiredLanes)===0||Oe(e,t),u=a?oN(e,t):ef(e,t,!0),f=a;do{if(u===0){aa&&!a&&Oo(e,t,0,!1);break}else{if(s=e.current.alternate,f&&!nN(s)){u=ef(e,t,!1),f=!1;continue}if(u===2){if(f=t,e.errorRecoveryDisabledLanes&f)var y=0;else y=e.pendingLanes&-536870913,y=y!==0?y:y&536870912?536870912:0;if(y!==0){t=y;e:{var R=e;u=il;var G=R.current.memoizedState.isDehydrated;if(G&&(ca(R,y).flags|=256),y=ef(R,y,!1),y!==2){if($d&&!G){R.errorRecoveryDisabledLanes|=f,cr|=f,u=4;break e}f=_n,_n=u,f!==null&&(_n===null?_n=f:_n.push.apply(_n,f))}u=y}if(f=!1,u!==2)continue}}if(u===1){ca(e,0),Oo(e,t,0,!0);break}e:{switch(a=e,f=u,f){case 0:case 1:throw Error(l(345));case 4:if((t&4194048)!==t)break;case 6:Oo(a,t,Yn,!To);break e;case 2:_n=null;break;case 3:case 5:break;default:throw Error(l(329))}if((t&62914560)===t&&(u=Yi+300-ee(),10<u)){if(Oo(a,t,Yn,!To),xe(a,0,!0)!==0)break e;Js=t,a.timeoutHandle=pb(Bx.bind(null,a,s,_n,Fi,Kd,t,Yn,cr,la,To,f,"Throttled",-0,0),u);break e}Bx(a,s,_n,Fi,Kd,t,Yn,cr,la,To,f,null,-0,0)}}break}while(!0);ys(e)}function Bx(e,t,s,a,u,f,y,R,G,le,be,Te,ce,me){if(e.timeoutHandle=-1,Te=t.subtreeFlags,Te&8192||(Te&16785408)===16785408){Te={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Is},kx(t,f,Te);var $e=(f&62914560)===f?Yi-ee():(f&4194048)===f?Dx-ee():0;if($e=HN(Te,$e),$e!==null){Js=f,e.cancelPendingCommit=$e(qx.bind(null,e,t,f,s,a,u,y,R,G,be,Te,null,ce,me)),Oo(e,f,y,!le);return}}qx(e,t,f,s,a,u,y,R,G)}function nN(e){for(var t=e;;){var s=t.tag;if((s===0||s===11||s===15)&&t.flags&16384&&(s=t.updateQueue,s!==null&&(s=s.stores,s!==null)))for(var a=0;a<s.length;a++){var u=s[a],f=u.getSnapshot;u=u.value;try{if(!In(f(),u))return!1}catch{return!1}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Oo(e,t,s,a){t&=~Xd,t&=~cr,e.suspendedLanes|=t,e.pingedLanes&=~t,a&&(e.warmLanes|=t),a=e.expirationTimes;for(var u=t;0<u;){var f=31-gt(u),y=1<<f;a[f]=-1,u&=~y}s!==0&&$n(e,s,t)}function Gi(){return(_t&6)===0?(ul(0),!1):!0}function Wd(){if(xt!==null){if(Mt===0)var e=xt.return;else e=xt,Ps=er=null,hd(e),Wr=null,qa=0,e=xt;for(;e!==null;)hx(e.alternate,e),e=e.return;xt=null}}function ca(e,t){var s=e.timeoutHandle;s!==-1&&(e.timeoutHandle=-1,EN(s)),s=e.cancelPendingCommit,s!==null&&(e.cancelPendingCommit=null,s()),Js=0,Wd(),Ut=e,xt=s=Us(e.current,null),vt=t,Mt=0,Pn=null,To=!1,aa=Oe(e,t),$d=!1,la=Yn=Xd=cr=wo=$t=0,_n=il=null,Kd=!1,(t&8)!==0&&(t|=t&32);var a=e.entangledLanes;if(a!==0)for(e=e.entanglements,a&=t;0<a;){var u=31-gt(a),f=1<<u;t|=e[u],a&=~f}return Zs=t,fi(),s}function Ux(e,t){dt=null,w.H=el,t===Jr||t===vi?(t=tg(),Mt=3):t===sd?(t=tg(),Mt=4):Mt=t===_d?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Pn=t,xt===null&&($t=1,Di(e,Zn(t,e.current)))}function Hx(){var e=Un.current;return e===null?!0:(vt&4194048)===vt?ts===null:(vt&62914560)===vt||(vt&536870912)!==0?e===ts:!1}function Px(){var e=w.H;return w.H=el,e===null?el:e}function Yx(){var e=w.A;return w.A=eN,e}function qi(){$t=4,To||(vt&4194048)!==vt&&Un.current!==null||(aa=!0),(wo&134217727)===0&&(cr&134217727)===0||Ut===null||Oo(Ut,vt,Yn,!1)}function ef(e,t,s){var a=_t;_t|=2;var u=Px(),f=Yx();(Ut!==e||vt!==t)&&(Fi=null,ca(e,t)),t=!1;var y=$t;e:do try{if(Mt!==0&&xt!==null){var R=xt,G=Pn;switch(Mt){case 8:Wd(),y=6;break e;case 3:case 2:case 9:case 6:Un.current===null&&(t=!0);var le=Mt;if(Mt=0,Pn=null,ua(e,R,G,le),s&&aa){y=0;break e}break;default:le=Mt,Mt=0,Pn=null,ua(e,R,G,le)}}sN(),y=$t;break}catch(be){Ux(e,be)}while(!0);return t&&e.shellSuspendCounter++,Ps=er=null,_t=a,w.H=u,w.A=f,xt===null&&(Ut=null,vt=0,fi()),y}function sN(){for(;xt!==null;)Vx(xt)}function oN(e,t){var s=_t;_t|=2;var a=Px(),u=Yx();Ut!==e||vt!==t?(Fi=null,Vi=ee()+500,ca(e,t)):aa=Oe(e,t);e:do try{if(Mt!==0&&xt!==null){t=xt;var f=Pn;t:switch(Mt){case 1:Mt=0,Pn=null,ua(e,t,f,1);break;case 2:case 9:if(Wh(f)){Mt=0,Pn=null,Fx(t);break}t=function(){Mt!==2&&Mt!==9||Ut!==e||(Mt=7),ys(e)},f.then(t,t);break e;case 3:Mt=7;break e;case 4:Mt=5;break e;case 7:Wh(f)?(Mt=0,Pn=null,Fx(t)):(Mt=0,Pn=null,ua(e,t,f,7));break;case 5:var y=null;switch(xt.tag){case 26:y=xt.memoizedState;case 5:case 27:var R=xt;if(y?Ob(y):R.stateNode.complete){Mt=0,Pn=null;var G=R.sibling;if(G!==null)xt=G;else{var le=R.return;le!==null?(xt=le,$i(le)):xt=null}break t}}Mt=0,Pn=null,ua(e,t,f,5);break;case 6:Mt=0,Pn=null,ua(e,t,f,6);break;case 8:Wd(),$t=6;break e;default:throw Error(l(462))}}rN();break}catch(be){Ux(e,be)}while(!0);return Ps=er=null,w.H=a,w.A=u,_t=s,xt!==null?0:(Ut=null,vt=0,fi(),$t)}function rN(){for(;xt!==null&&!Ie();)Vx(xt)}function Vx(e){var t=mx(e.alternate,e,Zs);e.memoizedProps=e.pendingProps,t===null?$i(e):xt=t}function Fx(e){var t=e,s=t.alternate;switch(t.tag){case 15:case 0:t=lx(s,t,t.pendingProps,t.type,void 0,vt);break;case 11:t=lx(s,t,t.pendingProps,t.type.render,t.ref,vt);break;case 5:hd(t);default:hx(s,t),t=xt=Yh(t,Zs),t=mx(s,t,Zs)}e.memoizedProps=e.pendingProps,t===null?$i(e):xt=t}function ua(e,t,s,a){Ps=er=null,hd(t),Wr=null,qa=0;var u=t.return;try{if($E(e,u,t,s,vt)){$t=1,Di(e,Zn(s,e.current)),xt=null;return}}catch(f){if(u!==null)throw xt=u,f;$t=1,Di(e,Zn(s,e.current)),xt=null;return}t.flags&32768?(Tt||a===1?e=!0:aa||(vt&536870912)!==0?e=!1:(To=e=!0,(a===2||a===9||a===3||a===6)&&(a=Un.current,a!==null&&a.tag===13&&(a.flags|=16384))),Gx(t,e)):$i(t)}function $i(e){var t=e;do{if((t.flags&32768)!==0){Gx(t,To);return}e=t.return;var s=QE(t.alternate,t,Zs);if(s!==null){xt=s;return}if(t=t.sibling,t!==null){xt=t;return}xt=t=e}while(t!==null);$t===0&&($t=5)}function Gx(e,t){do{var s=ZE(e.alternate,e);if(s!==null){s.flags&=32767,xt=s;return}if(s=e.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!t&&(e=e.sibling,e!==null)){xt=e;return}xt=e=s}while(e!==null);$t=6,xt=null}function qx(e,t,s,a,u,f,y,R,G){e.cancelPendingCommit=null;do Xi();while(on!==0);if((_t&6)!==0)throw Error(l(327));if(t!==null){if(t===e.current)throw Error(l(177));if(f=t.lanes|t.childLanes,f|=Yu,Ft(e,s,f,y,R,G),e===Ut&&(xt=Ut=null,vt=0),ia=t,Ro=e,Js=s,Qd=f,Zd=u,zx=a,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,cN(Ee,function(){return Zx(),null})):(e.callbackNode=null,e.callbackPriority=0),a=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||a){a=w.T,w.T=null,u=D.p,D.p=2,y=_t,_t|=4;try{JE(e,t,s)}finally{_t=y,D.p=u,w.T=a}}on=1,$x(),Xx(),Kx()}}function $x(){if(on===1){on=0;var e=Ro,t=ia,s=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||s){s=w.T,w.T=null;var a=D.p;D.p=2;var u=_t;_t|=4;try{Cx(t,e);var f=mf,y=Ah(e.containerInfo),R=f.focusedElem,G=f.selectionRange;if(y!==R&&R&&R.ownerDocument&&Mh(R.ownerDocument.documentElement,R)){if(G!==null&&Iu(R)){var le=G.start,be=G.end;if(be===void 0&&(be=le),"selectionStart"in R)R.selectionStart=le,R.selectionEnd=Math.min(be,R.value.length);else{var Te=R.ownerDocument||document,ce=Te&&Te.defaultView||window;if(ce.getSelection){var me=ce.getSelection(),$e=R.textContent.length,st=Math.min(G.start,$e),It=G.end===void 0?st:Math.min(G.end,$e);!me.extend&&st>It&&(y=It,It=st,st=y);var se=_h(R,st),J=_h(R,It);if(se&&J&&(me.rangeCount!==1||me.anchorNode!==se.node||me.anchorOffset!==se.offset||me.focusNode!==J.node||me.focusOffset!==J.offset)){var ae=Te.createRange();ae.setStart(se.node,se.offset),me.removeAllRanges(),st>It?(me.addRange(ae),me.extend(J.node,J.offset)):(ae.setEnd(J.node,J.offset),me.addRange(ae))}}}}for(Te=[],me=R;me=me.parentNode;)me.nodeType===1&&Te.push({element:me,left:me.scrollLeft,top:me.scrollTop});for(typeof R.focus=="function"&&R.focus(),R=0;R<Te.length;R++){var Se=Te[R];Se.element.scrollLeft=Se.left,Se.element.scrollTop=Se.top}}ac=!!ff,mf=ff=null}finally{_t=u,D.p=a,w.T=s}}e.current=t,on=2}}function Xx(){if(on===2){on=0;var e=Ro,t=ia,s=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||s){s=w.T,w.T=null;var a=D.p;D.p=2;var u=_t;_t|=4;try{Ex(e,t.alternate,t)}finally{_t=u,D.p=a,w.T=s}}on=3}}function Kx(){if(on===4||on===3){on=0,we();var e=Ro,t=ia,s=Js,a=zx;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?on=5:(on=0,ia=Ro=null,Qx(e,e.pendingLanes));var u=e.pendingLanes;if(u===0&&(Co=null),Ln(s),t=t.stateNode,jt&&typeof jt.onCommitFiberRoot=="function")try{jt.onCommitFiberRoot(nt,t,void 0,(t.current.flags&128)===128)}catch{}if(a!==null){t=w.T,u=D.p,D.p=2,w.T=null;try{for(var f=e.onRecoverableError,y=0;y<a.length;y++){var R=a[y];f(R.value,{componentStack:R.stack})}}finally{w.T=t,D.p=u}}(Js&3)!==0&&Xi(),ys(e),u=e.pendingLanes,(s&261930)!==0&&(u&42)!==0?e===Jd?cl++:(cl=0,Jd=e):cl=0,ul(0)}}function Qx(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Fa(t)))}function Xi(){return $x(),Xx(),Kx(),Zx()}function Zx(){if(on!==5)return!1;var e=Ro,t=Qd;Qd=0;var s=Ln(Js),a=w.T,u=D.p;try{D.p=32>s?32:s,w.T=null,s=Zd,Zd=null;var f=Ro,y=Js;if(on=0,ia=Ro=null,Js=0,(_t&6)!==0)throw Error(l(331));var R=_t;if(_t|=4,Mx(f.current),Ox(f,f.current,y,s),_t=R,ul(0,!1),jt&&typeof jt.onPostCommitFiberRoot=="function")try{jt.onPostCommitFiberRoot(nt,f)}catch{}return!0}finally{D.p=u,w.T=a,Qx(e,t)}}function Jx(e,t,s){t=Zn(s,t),t=kd(e.stateNode,t,2),e=So(e,t,2),e!==null&&(lt(e,2),ys(e))}function At(e,t,s){if(e.tag===3)Jx(e,e,s);else for(;t!==null;){if(t.tag===3){Jx(t,e,s);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(Co===null||!Co.has(a))){e=Zn(s,e),s=Wg(2),a=So(t,s,2),a!==null&&(ex(s,a,t,e),lt(a,2),ys(a));break}}t=t.return}}function tf(e,t,s){var a=e.pingCache;if(a===null){a=e.pingCache=new tN;var u=new Set;a.set(t,u)}else u=a.get(t),u===void 0&&(u=new Set,a.set(t,u));u.has(s)||($d=!0,u.add(s),e=aN.bind(null,e,t,s),t.then(e,e))}function aN(e,t,s){var a=e.pingCache;a!==null&&a.delete(t),e.pingedLanes|=e.suspendedLanes&s,e.warmLanes&=~s,Ut===e&&(vt&s)===s&&($t===4||$t===3&&(vt&62914560)===vt&&300>ee()-Yi?(_t&2)===0&&ca(e,0):Xd|=s,la===vt&&(la=0)),ys(e)}function Wx(e,t){t===0&&(t=rt()),e=Zo(e,t),e!==null&&(lt(e,t),ys(e))}function lN(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),Wx(e,s)}function iN(e,t){var s=0;switch(e.tag){case 31:case 13:var a=e.stateNode,u=e.memoizedState;u!==null&&(s=u.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(l(314))}a!==null&&a.delete(t),Wx(e,s)}function cN(e,t){return De(e,t)}var Ki=null,da=null,nf=!1,Qi=!1,sf=!1,ko=0;function ys(e){e!==da&&e.next===null&&(da===null?Ki=da=e:da=da.next=e),Qi=!0,nf||(nf=!0,dN())}function ul(e,t){if(!sf&&Qi){sf=!0;do for(var s=!1,a=Ki;a!==null;){if(e!==0){var u=a.pendingLanes;if(u===0)var f=0;else{var y=a.suspendedLanes,R=a.pingedLanes;f=(1<<31-gt(42|e)+1)-1,f&=u&~(y&~R),f=f&201326741?f&201326741|1:f?f|2:0}f!==0&&(s=!0,sb(a,f))}else f=vt,f=xe(a,a===Ut?f:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(f&3)===0||Oe(a,f)||(s=!0,sb(a,f));a=a.next}while(s);sf=!1}}function uN(){eb()}function eb(){Qi=nf=!1;var e=0;ko!==0&&SN()&&(e=ko);for(var t=ee(),s=null,a=Ki;a!==null;){var u=a.next,f=tb(a,t);f===0?(a.next=null,s===null?Ki=u:s.next=u,u===null&&(da=s)):(s=a,(e!==0||(f&3)!==0)&&(Qi=!0)),a=u}on!==0&&on!==5||ul(e),ko!==0&&(ko=0)}function tb(e,t){for(var s=e.suspendedLanes,a=e.pingedLanes,u=e.expirationTimes,f=e.pendingLanes&-62914561;0<f;){var y=31-gt(f),R=1<<y,G=u[y];G===-1?((R&s)===0||(R&a)!==0)&&(u[y]=We(R,t)):G<=t&&(e.expiredLanes|=R),f&=~R}if(t=Ut,s=vt,s=xe(e,e===t?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),a=e.callbackNode,s===0||e===t&&(Mt===2||Mt===9)||e.cancelPendingCommit!==null)return a!==null&&a!==null&&Pe(a),e.callbackNode=null,e.callbackPriority=0;if((s&3)===0||Oe(e,s)){if(t=s&-s,t===e.callbackPriority)return t;switch(a!==null&&Pe(a),Ln(s)){case 2:case 8:s=Z;break;case 32:s=Ee;break;case 268435456:s=Ne;break;default:s=Ee}return a=nb.bind(null,e),s=De(s,a),e.callbackPriority=t,e.callbackNode=s,t}return a!==null&&a!==null&&Pe(a),e.callbackPriority=2,e.callbackNode=null,2}function nb(e,t){if(on!==0&&on!==5)return e.callbackNode=null,e.callbackPriority=0,null;var s=e.callbackNode;if(Xi()&&e.callbackNode!==s)return null;var a=vt;return a=xe(e,e===Ut?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),a===0?null:(Ix(e,a,t),tb(e,ee()),e.callbackNode!=null&&e.callbackNode===s?nb.bind(null,e):null)}function sb(e,t){if(Xi())return null;Ix(e,t,!0)}function dN(){NN(function(){(_t&6)!==0?De(ie,uN):eb()})}function of(){if(ko===0){var e=Qr;e===0&&(e=je,je<<=1,(je&261888)===0&&(je=256)),ko=e}return ko}function ob(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:oi(""+e)}function rb(e,t){var s=t.ownerDocument.createElement("input");return s.name=t.name,s.value=t.value,e.id&&s.setAttribute("form",e.id),t.parentNode.insertBefore(s,t),e=new FormData(e),s.parentNode.removeChild(s),e}function fN(e,t,s,a,u){if(t==="submit"&&s&&s.stateNode===u){var f=ob((u[wn]||null).action),y=a.submitter;y&&(t=(t=y[wn]||null)?ob(t.formAction):y.getAttribute("formAction"),t!==null&&(f=t,y=null));var R=new ii("action","action",null,a,u);e.push({event:R,listeners:[{instance:null,listener:function(){if(a.defaultPrevented){if(ko!==0){var G=y?rb(u,y):new FormData(u);jd(s,{pending:!0,data:G,method:u.method,action:f},null,G)}}else typeof f=="function"&&(R.preventDefault(),G=y?rb(u,y):new FormData(u),jd(s,{pending:!0,data:G,method:u.method,action:f},f,G))},currentTarget:u}]})}}for(var rf=0;rf<Pu.length;rf++){var af=Pu[rf],mN=af.toLowerCase(),pN=af[0].toUpperCase()+af.slice(1);cs(mN,"on"+pN)}cs(Lh,"onAnimationEnd"),cs(Ih,"onAnimationIteration"),cs(Bh,"onAnimationStart"),cs("dblclick","onDoubleClick"),cs("focusin","onFocus"),cs("focusout","onBlur"),cs(kE,"onTransitionRun"),cs(_E,"onTransitionStart"),cs(ME,"onTransitionCancel"),cs(Uh,"onTransitionEnd"),Lr("onMouseEnter",["mouseout","mouseover"]),Lr("onMouseLeave",["mouseout","mouseover"]),Lr("onPointerEnter",["pointerout","pointerover"]),Lr("onPointerLeave",["pointerout","pointerover"]),$o("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),$o("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),$o("onBeforeInput",["compositionend","keypress","textInput","paste"]),$o("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),$o("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),$o("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var dl="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),hN=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(dl));function ab(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var a=e[s],u=a.event;a=a.listeners;e:{var f=void 0;if(t)for(var y=a.length-1;0<=y;y--){var R=a[y],G=R.instance,le=R.currentTarget;if(R=R.listener,G!==f&&u.isPropagationStopped())break e;f=R,u.currentTarget=le;try{f(u)}catch(be){di(be)}u.currentTarget=null,f=G}else for(y=0;y<a.length;y++){if(R=a[y],G=R.instance,le=R.currentTarget,R=R.listener,G!==f&&u.isPropagationStopped())break e;f=R,u.currentTarget=le;try{f(u)}catch(be){di(be)}u.currentTarget=null,f=G}}}}function bt(e,t){var s=t[yu];s===void 0&&(s=t[yu]=new Set);var a=e+"__bubble";s.has(a)||(lb(t,e,2,!1),s.add(a))}function lf(e,t,s){var a=0;t&&(a|=4),lb(s,e,a,t)}var Zi="_reactListening"+Math.random().toString(36).slice(2);function cf(e){if(!e[Zi]){e[Zi]=!0,eh.forEach(function(s){s!=="selectionchange"&&(hN.has(s)||lf(s,!1,e),lf(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Zi]||(t[Zi]=!0,lf("selectionchange",!1,t))}}function lb(e,t,s,a){switch(Lb(t)){case 2:var u=VN;break;case 8:u=FN;break;default:u=jf}s=u.bind(null,t,s,e),u=void 0,!Ru||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(u=!0),a?u!==void 0?e.addEventListener(t,s,{capture:!0,passive:u}):e.addEventListener(t,s,!0):u!==void 0?e.addEventListener(t,s,{passive:u}):e.addEventListener(t,s,!1)}function uf(e,t,s,a,u){var f=a;if((t&1)===0&&(t&2)===0&&a!==null)e:for(;;){if(a===null)return;var y=a.tag;if(y===3||y===4){var R=a.stateNode.containerInfo;if(R===u)break;if(y===4)for(y=a.return;y!==null;){var G=y.tag;if((G===3||G===4)&&y.stateNode.containerInfo===u)return;y=y.return}for(;R!==null;){if(y=Ar(R),y===null)return;if(G=y.tag,G===5||G===6||G===26||G===27){a=f=y;continue e}R=R.parentNode}}a=a.return}fh(function(){var le=f,be=wu(s),Te=[];e:{var ce=Hh.get(e);if(ce!==void 0){var me=ii,$e=e;switch(e){case"keypress":if(ai(s)===0)break e;case"keydown":case"keyup":me=iE;break;case"focusin":$e="focus",me=Mu;break;case"focusout":$e="blur",me=Mu;break;case"beforeblur":case"afterblur":me=Mu;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":me=hh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":me=QS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":me=dE;break;case Lh:case Ih:case Bh:me=WS;break;case Uh:me=mE;break;case"scroll":case"scrollend":me=XS;break;case"wheel":me=hE;break;case"copy":case"cut":case"paste":me=tE;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":me=xh;break;case"toggle":case"beforetoggle":me=xE}var st=(t&4)!==0,It=!st&&(e==="scroll"||e==="scrollend"),se=st?ce!==null?ce+"Capture":null:ce;st=[];for(var J=le,ae;J!==null;){var Se=J;if(ae=Se.stateNode,Se=Se.tag,Se!==5&&Se!==26&&Se!==27||ae===null||se===null||(Se=Aa(J,se),Se!=null&&st.push(fl(J,Se,ae))),It)break;J=J.return}0<st.length&&(ce=new me(ce,$e,null,s,be),Te.push({event:ce,listeners:st}))}}if((t&7)===0){e:{if(ce=e==="mouseover"||e==="pointerover",me=e==="mouseout"||e==="pointerout",ce&&s!==Tu&&($e=s.relatedTarget||s.fromElement)&&(Ar($e)||$e[Mr]))break e;if((me||ce)&&(ce=be.window===be?be:(ce=be.ownerDocument)?ce.defaultView||ce.parentWindow:window,me?($e=s.relatedTarget||s.toElement,me=le,$e=$e?Ar($e):null,$e!==null&&(It=d($e),st=$e.tag,$e!==It||st!==5&&st!==27&&st!==6)&&($e=null)):(me=null,$e=le),me!==$e)){if(st=hh,Se="onMouseLeave",se="onMouseEnter",J="mouse",(e==="pointerout"||e==="pointerover")&&(st=xh,Se="onPointerLeave",se="onPointerEnter",J="pointer"),It=me==null?ce:Ma(me),ae=$e==null?ce:Ma($e),ce=new st(Se,J+"leave",me,s,be),ce.target=It,ce.relatedTarget=ae,Se=null,Ar(be)===le&&(st=new st(se,J+"enter",$e,s,be),st.target=ae,st.relatedTarget=It,Se=st),It=Se,me&&$e)t:{for(st=gN,se=me,J=$e,ae=0,Se=se;Se;Se=st(Se))ae++;Se=0;for(var tt=J;tt;tt=st(tt))Se++;for(;0<ae-Se;)se=st(se),ae--;for(;0<Se-ae;)J=st(J),Se--;for(;ae--;){if(se===J||J!==null&&se===J.alternate){st=se;break t}se=st(se),J=st(J)}st=null}else st=null;me!==null&&ib(Te,ce,me,st,!1),$e!==null&&It!==null&&ib(Te,It,$e,st,!0)}}e:{if(ce=le?Ma(le):window,me=ce.nodeName&&ce.nodeName.toLowerCase(),me==="select"||me==="input"&&ce.type==="file")var Rt=Th;else if(Nh(ce))if(wh)Rt=CE;else{Rt=TE;var Ke=jE}else me=ce.nodeName,!me||me.toLowerCase()!=="input"||ce.type!=="checkbox"&&ce.type!=="radio"?le&&ju(le.elementType)&&(Rt=Th):Rt=wE;if(Rt&&(Rt=Rt(e,le))){jh(Te,Rt,s,be);break e}Ke&&Ke(e,ce,le),e==="focusout"&&le&&ce.type==="number"&&le.memoizedProps.value!=null&&Nu(ce,"number",ce.value)}switch(Ke=le?Ma(le):window,e){case"focusin":(Nh(Ke)||Ke.contentEditable==="true")&&(Yr=Ke,Bu=le,Pa=null);break;case"focusout":Pa=Bu=Yr=null;break;case"mousedown":Uu=!0;break;case"contextmenu":case"mouseup":case"dragend":Uu=!1,Dh(Te,s,be);break;case"selectionchange":if(OE)break;case"keydown":case"keyup":Dh(Te,s,be)}var pt;if(Du)e:{switch(e){case"compositionstart":var St="onCompositionStart";break e;case"compositionend":St="onCompositionEnd";break e;case"compositionupdate":St="onCompositionUpdate";break e}St=void 0}else Pr?Sh(e,s)&&(St="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(St="onCompositionStart");St&&(bh&&s.locale!=="ko"&&(Pr||St!=="onCompositionStart"?St==="onCompositionEnd"&&Pr&&(pt=mh()):(po=be,Ou="value"in po?po.value:po.textContent,Pr=!0)),Ke=Ji(le,St),0<Ke.length&&(St=new gh(St,e,null,s,be),Te.push({event:St,listeners:Ke}),pt?St.data=pt:(pt=Eh(s),pt!==null&&(St.data=pt)))),(pt=yE?vE(e,s):SE(e,s))&&(St=Ji(le,"onBeforeInput"),0<St.length&&(Ke=new gh("onBeforeInput","beforeinput",null,s,be),Te.push({event:Ke,listeners:St}),Ke.data=pt)),fN(Te,e,le,s,be)}ab(Te,t)})}function fl(e,t,s){return{instance:e,listener:t,currentTarget:s}}function Ji(e,t){for(var s=t+"Capture",a=[];e!==null;){var u=e,f=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||f===null||(u=Aa(e,s),u!=null&&a.unshift(fl(e,u,f)),u=Aa(e,t),u!=null&&a.push(fl(e,u,f))),e.tag===3)return a;e=e.return}return[]}function gN(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function ib(e,t,s,a,u){for(var f=t._reactName,y=[];s!==null&&s!==a;){var R=s,G=R.alternate,le=R.stateNode;if(R=R.tag,G!==null&&G===a)break;R!==5&&R!==26&&R!==27||le===null||(G=le,u?(le=Aa(s,f),le!=null&&y.unshift(fl(s,le,G))):u||(le=Aa(s,f),le!=null&&y.push(fl(s,le,G)))),s=s.return}y.length!==0&&e.push({event:t,listeners:y})}var xN=/\r\n?/g,bN=/\u0000|\uFFFD/g;function cb(e){return(typeof e=="string"?e:""+e).replace(xN,`
9
+ `).replace(bN,"")}function ub(e,t){return t=cb(t),cb(e)===t}function Lt(e,t,s,a,u,f){switch(s){case"children":typeof a=="string"?t==="body"||t==="textarea"&&a===""||Br(e,a):(typeof a=="number"||typeof a=="bigint")&&t!=="body"&&Br(e,""+a);break;case"className":ni(e,"class",a);break;case"tabIndex":ni(e,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":ni(e,s,a);break;case"style":uh(e,a,f);break;case"data":if(t!=="object"){ni(e,"data",a);break}case"src":case"href":if(a===""&&(t!=="a"||s!=="href")){e.removeAttribute(s);break}if(a==null||typeof a=="function"||typeof a=="symbol"||typeof a=="boolean"){e.removeAttribute(s);break}a=oi(""+a),e.setAttribute(s,a);break;case"action":case"formAction":if(typeof a=="function"){e.setAttribute(s,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof f=="function"&&(s==="formAction"?(t!=="input"&&Lt(e,t,"name",u.name,u,null),Lt(e,t,"formEncType",u.formEncType,u,null),Lt(e,t,"formMethod",u.formMethod,u,null),Lt(e,t,"formTarget",u.formTarget,u,null)):(Lt(e,t,"encType",u.encType,u,null),Lt(e,t,"method",u.method,u,null),Lt(e,t,"target",u.target,u,null)));if(a==null||typeof a=="symbol"||typeof a=="boolean"){e.removeAttribute(s);break}a=oi(""+a),e.setAttribute(s,a);break;case"onClick":a!=null&&(e.onclick=Is);break;case"onScroll":a!=null&&bt("scroll",e);break;case"onScrollEnd":a!=null&&bt("scrollend",e);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(l(61));if(s=a.__html,s!=null){if(u.children!=null)throw Error(l(60));e.innerHTML=s}}break;case"multiple":e.multiple=a&&typeof a!="function"&&typeof a!="symbol";break;case"muted":e.muted=a&&typeof a!="function"&&typeof a!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(a==null||typeof a=="function"||typeof a=="boolean"||typeof a=="symbol"){e.removeAttribute("xlink:href");break}s=oi(""+a),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":a!=null&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(s,""+a):e.removeAttribute(s);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":a&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(s,""):e.removeAttribute(s);break;case"capture":case"download":a===!0?e.setAttribute(s,""):a!==!1&&a!=null&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(s,a):e.removeAttribute(s);break;case"cols":case"rows":case"size":case"span":a!=null&&typeof a!="function"&&typeof a!="symbol"&&!isNaN(a)&&1<=a?e.setAttribute(s,a):e.removeAttribute(s);break;case"rowSpan":case"start":a==null||typeof a=="function"||typeof a=="symbol"||isNaN(a)?e.removeAttribute(s):e.setAttribute(s,a);break;case"popover":bt("beforetoggle",e),bt("toggle",e),ti(e,"popover",a);break;case"xlinkActuate":Ls(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":Ls(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":Ls(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":Ls(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":Ls(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":Ls(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":Ls(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":Ls(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":Ls(e,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":ti(e,"is",a);break;case"innerText":case"textContent":break;default:(!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(s=qS.get(s)||s,ti(e,s,a))}}function df(e,t,s,a,u,f){switch(s){case"style":uh(e,a,f);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(l(61));if(s=a.__html,s!=null){if(u.children!=null)throw Error(l(60));e.innerHTML=s}}break;case"children":typeof a=="string"?Br(e,a):(typeof a=="number"||typeof a=="bigint")&&Br(e,""+a);break;case"onScroll":a!=null&&bt("scroll",e);break;case"onScrollEnd":a!=null&&bt("scrollend",e);break;case"onClick":a!=null&&(e.onclick=Is);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!th.hasOwnProperty(s))e:{if(s[0]==="o"&&s[1]==="n"&&(u=s.endsWith("Capture"),t=s.slice(2,u?s.length-7:void 0),f=e[wn]||null,f=f!=null?f[s]:null,typeof f=="function"&&e.removeEventListener(t,f,u),typeof a=="function")){typeof f!="function"&&f!==null&&(s in e?e[s]=null:e.hasAttribute(s)&&e.removeAttribute(s)),e.addEventListener(t,a,u);break e}s in e?e[s]=a:a===!0?e.setAttribute(s,""):ti(e,s,a)}}}function bn(e,t,s){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":bt("error",e),bt("load",e);var a=!1,u=!1,f;for(f in s)if(s.hasOwnProperty(f)){var y=s[f];if(y!=null)switch(f){case"src":a=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:Lt(e,t,f,y,s,null)}}u&&Lt(e,t,"srcSet",s.srcSet,s,null),a&&Lt(e,t,"src",s.src,s,null);return;case"input":bt("invalid",e);var R=f=y=u=null,G=null,le=null;for(a in s)if(s.hasOwnProperty(a)){var be=s[a];if(be!=null)switch(a){case"name":u=be;break;case"type":y=be;break;case"checked":G=be;break;case"defaultChecked":le=be;break;case"value":f=be;break;case"defaultValue":R=be;break;case"children":case"dangerouslySetInnerHTML":if(be!=null)throw Error(l(137,t));break;default:Lt(e,t,a,be,s,null)}}ah(e,f,R,G,le,y,u,!1);return;case"select":bt("invalid",e),a=y=f=null;for(u in s)if(s.hasOwnProperty(u)&&(R=s[u],R!=null))switch(u){case"value":f=R;break;case"defaultValue":y=R;break;case"multiple":a=R;default:Lt(e,t,u,R,s,null)}t=f,s=y,e.multiple=!!a,t!=null?Ir(e,!!a,t,!1):s!=null&&Ir(e,!!a,s,!0);return;case"textarea":bt("invalid",e),f=u=a=null;for(y in s)if(s.hasOwnProperty(y)&&(R=s[y],R!=null))switch(y){case"value":a=R;break;case"defaultValue":u=R;break;case"children":f=R;break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(l(91));break;default:Lt(e,t,y,R,s,null)}ih(e,a,u,f);return;case"option":for(G in s)s.hasOwnProperty(G)&&(a=s[G],a!=null)&&(G==="selected"?e.selected=a&&typeof a!="function"&&typeof a!="symbol":Lt(e,t,G,a,s,null));return;case"dialog":bt("beforetoggle",e),bt("toggle",e),bt("cancel",e),bt("close",e);break;case"iframe":case"object":bt("load",e);break;case"video":case"audio":for(a=0;a<dl.length;a++)bt(dl[a],e);break;case"image":bt("error",e),bt("load",e);break;case"details":bt("toggle",e);break;case"embed":case"source":case"link":bt("error",e),bt("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(le in s)if(s.hasOwnProperty(le)&&(a=s[le],a!=null))switch(le){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:Lt(e,t,le,a,s,null)}return;default:if(ju(t)){for(be in s)s.hasOwnProperty(be)&&(a=s[be],a!==void 0&&df(e,t,be,a,s,void 0));return}}for(R in s)s.hasOwnProperty(R)&&(a=s[R],a!=null&&Lt(e,t,R,a,s,null))}function yN(e,t,s,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,f=null,y=null,R=null,G=null,le=null,be=null;for(me in s){var Te=s[me];if(s.hasOwnProperty(me)&&Te!=null)switch(me){case"checked":break;case"value":break;case"defaultValue":G=Te;default:a.hasOwnProperty(me)||Lt(e,t,me,null,a,Te)}}for(var ce in a){var me=a[ce];if(Te=s[ce],a.hasOwnProperty(ce)&&(me!=null||Te!=null))switch(ce){case"type":f=me;break;case"name":u=me;break;case"checked":le=me;break;case"defaultChecked":be=me;break;case"value":y=me;break;case"defaultValue":R=me;break;case"children":case"dangerouslySetInnerHTML":if(me!=null)throw Error(l(137,t));break;default:me!==Te&&Lt(e,t,ce,me,a,Te)}}Eu(e,y,R,G,le,be,f,u);return;case"select":me=y=R=ce=null;for(f in s)if(G=s[f],s.hasOwnProperty(f)&&G!=null)switch(f){case"value":break;case"multiple":me=G;default:a.hasOwnProperty(f)||Lt(e,t,f,null,a,G)}for(u in a)if(f=a[u],G=s[u],a.hasOwnProperty(u)&&(f!=null||G!=null))switch(u){case"value":ce=f;break;case"defaultValue":R=f;break;case"multiple":y=f;default:f!==G&&Lt(e,t,u,f,a,G)}t=R,s=y,a=me,ce!=null?Ir(e,!!s,ce,!1):!!a!=!!s&&(t!=null?Ir(e,!!s,t,!0):Ir(e,!!s,s?[]:"",!1));return;case"textarea":me=ce=null;for(R in s)if(u=s[R],s.hasOwnProperty(R)&&u!=null&&!a.hasOwnProperty(R))switch(R){case"value":break;case"children":break;default:Lt(e,t,R,null,a,u)}for(y in a)if(u=a[y],f=s[y],a.hasOwnProperty(y)&&(u!=null||f!=null))switch(y){case"value":ce=u;break;case"defaultValue":me=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(l(91));break;default:u!==f&&Lt(e,t,y,u,a,f)}lh(e,ce,me);return;case"option":for(var $e in s)ce=s[$e],s.hasOwnProperty($e)&&ce!=null&&!a.hasOwnProperty($e)&&($e==="selected"?e.selected=!1:Lt(e,t,$e,null,a,ce));for(G in a)ce=a[G],me=s[G],a.hasOwnProperty(G)&&ce!==me&&(ce!=null||me!=null)&&(G==="selected"?e.selected=ce&&typeof ce!="function"&&typeof ce!="symbol":Lt(e,t,G,ce,a,me));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var st in s)ce=s[st],s.hasOwnProperty(st)&&ce!=null&&!a.hasOwnProperty(st)&&Lt(e,t,st,null,a,ce);for(le in a)if(ce=a[le],me=s[le],a.hasOwnProperty(le)&&ce!==me&&(ce!=null||me!=null))switch(le){case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(l(137,t));break;default:Lt(e,t,le,ce,a,me)}return;default:if(ju(t)){for(var It in s)ce=s[It],s.hasOwnProperty(It)&&ce!==void 0&&!a.hasOwnProperty(It)&&df(e,t,It,void 0,a,ce);for(be in a)ce=a[be],me=s[be],!a.hasOwnProperty(be)||ce===me||ce===void 0&&me===void 0||df(e,t,be,ce,a,me);return}}for(var se in s)ce=s[se],s.hasOwnProperty(se)&&ce!=null&&!a.hasOwnProperty(se)&&Lt(e,t,se,null,a,ce);for(Te in a)ce=a[Te],me=s[Te],!a.hasOwnProperty(Te)||ce===me||ce==null&&me==null||Lt(e,t,Te,ce,a,me)}function db(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function vN(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,s=performance.getEntriesByType("resource"),a=0;a<s.length;a++){var u=s[a],f=u.transferSize,y=u.initiatorType,R=u.duration;if(f&&R&&db(y)){for(y=0,R=u.responseEnd,a+=1;a<s.length;a++){var G=s[a],le=G.startTime;if(le>R)break;var be=G.transferSize,Te=G.initiatorType;be&&db(Te)&&(G=G.responseEnd,y+=be*(G<R?1:(R-le)/(G-le)))}if(--a,t+=8*(f+y)/(u.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var ff=null,mf=null;function Wi(e){return e.nodeType===9?e:e.ownerDocument}function fb(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function mb(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function pf(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var hf=null;function SN(){var e=window.event;return e&&e.type==="popstate"?e===hf?!1:(hf=e,!0):(hf=null,!1)}var pb=typeof setTimeout=="function"?setTimeout:void 0,EN=typeof clearTimeout=="function"?clearTimeout:void 0,hb=typeof Promise=="function"?Promise:void 0,NN=typeof queueMicrotask=="function"?queueMicrotask:typeof hb<"u"?function(e){return hb.resolve(null).then(e).catch(jN)}:pb;function jN(e){setTimeout(function(){throw e})}function _o(e){return e==="head"}function gb(e,t){var s=t,a=0;do{var u=s.nextSibling;if(e.removeChild(s),u&&u.nodeType===8)if(s=u.data,s==="/$"||s==="/&"){if(a===0){e.removeChild(u),ha(t);return}a--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")a++;else if(s==="html")ml(e.ownerDocument.documentElement);else if(s==="head"){s=e.ownerDocument.head,ml(s);for(var f=s.firstChild;f;){var y=f.nextSibling,R=f.nodeName;f[_a]||R==="SCRIPT"||R==="STYLE"||R==="LINK"&&f.rel.toLowerCase()==="stylesheet"||s.removeChild(f),f=y}}else s==="body"&&ml(e.ownerDocument.body);s=u}while(s);ha(t)}function xb(e,t){var s=e;e=0;do{var a=s.nextSibling;if(s.nodeType===1?t?(s._stashedDisplay=s.style.display,s.style.display="none"):(s.style.display=s._stashedDisplay||"",s.getAttribute("style")===""&&s.removeAttribute("style")):s.nodeType===3&&(t?(s._stashedText=s.nodeValue,s.nodeValue=""):s.nodeValue=s._stashedText||""),a&&a.nodeType===8)if(s=a.data,s==="/$"){if(e===0)break;e--}else s!=="$"&&s!=="$?"&&s!=="$~"&&s!=="$!"||e++;s=a}while(s)}function gf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var s=t;switch(t=t.nextSibling,s.nodeName){case"HTML":case"HEAD":case"BODY":gf(s),vu(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}e.removeChild(s)}}function TN(e,t,s,a){for(;e.nodeType===1;){var u=s;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!a&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(a){if(!e[_a])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(f=e.getAttribute("rel"),f==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(f!==u.rel||e.getAttribute("href")!==(u.href==null||u.href===""?null:u.href)||e.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin)||e.getAttribute("title")!==(u.title==null?null:u.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(f=e.getAttribute("src"),(f!==(u.src==null?null:u.src)||e.getAttribute("type")!==(u.type==null?null:u.type)||e.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&f&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var f=u.name==null?null:""+u.name;if(u.type==="hidden"&&e.getAttribute("name")===f)return e}else return e;if(e=ns(e.nextSibling),e===null)break}return null}function wN(e,t,s){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!s||(e=ns(e.nextSibling),e===null))return null;return e}function bb(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=ns(e.nextSibling),e===null))return null;return e}function xf(e){return e.data==="$?"||e.data==="$~"}function bf(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function CN(e,t){var s=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||s.readyState!=="loading")t();else{var a=function(){t(),s.removeEventListener("DOMContentLoaded",a)};s.addEventListener("DOMContentLoaded",a),e._reactRetry=a}}function ns(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var yf=null;function yb(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"||s==="/&"){if(t===0)return ns(e.nextSibling);t--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||t++}e=e.nextSibling}return null}function vb(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"){if(t===0)return e;t--}else s!=="/$"&&s!=="/&"||t++}e=e.previousSibling}return null}function Sb(e,t,s){switch(t=Wi(s),e){case"html":if(e=t.documentElement,!e)throw Error(l(452));return e;case"head":if(e=t.head,!e)throw Error(l(453));return e;case"body":if(e=t.body,!e)throw Error(l(454));return e;default:throw Error(l(451))}}function ml(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);vu(e)}var ss=new Map,Eb=new Set;function ec(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Ws=D.d;D.d={f:RN,r:ON,D:kN,C:_N,L:MN,m:AN,X:zN,S:DN,M:LN};function RN(){var e=Ws.f(),t=Gi();return e||t}function ON(e){var t=Dr(e);t!==null&&t.tag===5&&t.type==="form"?Ug(t):Ws.r(e)}var fa=typeof document>"u"?null:document;function Nb(e,t,s){var a=fa;if(a&&typeof t=="string"&&t){var u=Kn(t);u='link[rel="'+e+'"][href="'+u+'"]',typeof s=="string"&&(u+='[crossorigin="'+s+'"]'),Eb.has(u)||(Eb.add(u),e={rel:e,crossOrigin:s,href:t},a.querySelector(u)===null&&(t=a.createElement("link"),bn(t,"link",e),cn(t),a.head.appendChild(t)))}}function kN(e){Ws.D(e),Nb("dns-prefetch",e,null)}function _N(e,t){Ws.C(e,t),Nb("preconnect",e,t)}function MN(e,t,s){Ws.L(e,t,s);var a=fa;if(a&&e&&t){var u='link[rel="preload"][as="'+Kn(t)+'"]';t==="image"&&s&&s.imageSrcSet?(u+='[imagesrcset="'+Kn(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(u+='[imagesizes="'+Kn(s.imageSizes)+'"]')):u+='[href="'+Kn(e)+'"]';var f=u;switch(t){case"style":f=ma(e);break;case"script":f=pa(e)}ss.has(f)||(e=x({rel:"preload",href:t==="image"&&s&&s.imageSrcSet?void 0:e,as:t},s),ss.set(f,e),a.querySelector(u)!==null||t==="style"&&a.querySelector(pl(f))||t==="script"&&a.querySelector(hl(f))||(t=a.createElement("link"),bn(t,"link",e),cn(t),a.head.appendChild(t)))}}function AN(e,t){Ws.m(e,t);var s=fa;if(s&&e){var a=t&&typeof t.as=="string"?t.as:"script",u='link[rel="modulepreload"][as="'+Kn(a)+'"][href="'+Kn(e)+'"]',f=u;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":f=pa(e)}if(!ss.has(f)&&(e=x({rel:"modulepreload",href:e},t),ss.set(f,e),s.querySelector(u)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(hl(f)))return}a=s.createElement("link"),bn(a,"link",e),cn(a),s.head.appendChild(a)}}}function DN(e,t,s){Ws.S(e,t,s);var a=fa;if(a&&e){var u=zr(a).hoistableStyles,f=ma(e);t=t||"default";var y=u.get(f);if(!y){var R={loading:0,preload:null};if(y=a.querySelector(pl(f)))R.loading=5;else{e=x({rel:"stylesheet",href:e,"data-precedence":t},s),(s=ss.get(f))&&vf(e,s);var G=y=a.createElement("link");cn(G),bn(G,"link",e),G._p=new Promise(function(le,be){G.onload=le,G.onerror=be}),G.addEventListener("load",function(){R.loading|=1}),G.addEventListener("error",function(){R.loading|=2}),R.loading|=4,tc(y,t,a)}y={type:"stylesheet",instance:y,count:1,state:R},u.set(f,y)}}}function zN(e,t){Ws.X(e,t);var s=fa;if(s&&e){var a=zr(s).hoistableScripts,u=pa(e),f=a.get(u);f||(f=s.querySelector(hl(u)),f||(e=x({src:e,async:!0},t),(t=ss.get(u))&&Sf(e,t),f=s.createElement("script"),cn(f),bn(f,"link",e),s.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},a.set(u,f))}}function LN(e,t){Ws.M(e,t);var s=fa;if(s&&e){var a=zr(s).hoistableScripts,u=pa(e),f=a.get(u);f||(f=s.querySelector(hl(u)),f||(e=x({src:e,async:!0,type:"module"},t),(t=ss.get(u))&&Sf(e,t),f=s.createElement("script"),cn(f),bn(f,"link",e),s.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},a.set(u,f))}}function jb(e,t,s,a){var u=(u=Y.current)?ec(u):null;if(!u)throw Error(l(446));switch(e){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(t=ma(s.href),s=zr(u).hoistableStyles,a=s.get(t),a||(a={type:"style",instance:null,count:0,state:null},s.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){e=ma(s.href);var f=zr(u).hoistableStyles,y=f.get(e);if(y||(u=u.ownerDocument||u,y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},f.set(e,y),(f=u.querySelector(pl(e)))&&!f._p&&(y.instance=f,y.state.loading=5),ss.has(e)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},ss.set(e,s),f||IN(u,e,s,y.state))),t&&a===null)throw Error(l(528,""));return y}if(t&&a!==null)throw Error(l(529,""));return null;case"script":return t=s.async,s=s.src,typeof s=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=pa(s),s=zr(u).hoistableScripts,a=s.get(t),a||(a={type:"script",instance:null,count:0,state:null},s.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,e))}}function ma(e){return'href="'+Kn(e)+'"'}function pl(e){return'link[rel="stylesheet"]['+e+"]"}function Tb(e){return x({},e,{"data-precedence":e.precedence,precedence:null})}function IN(e,t,s,a){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=e.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),bn(t,"link",s),cn(t),e.head.appendChild(t))}function pa(e){return'[src="'+Kn(e)+'"]'}function hl(e){return"script[async]"+e}function wb(e,t,s){if(t.count++,t.instance===null)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+Kn(s.href)+'"]');if(a)return t.instance=a,cn(a),a;var u=x({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return a=(e.ownerDocument||e).createElement("style"),cn(a),bn(a,"style",u),tc(a,s.precedence,e),t.instance=a;case"stylesheet":u=ma(s.href);var f=e.querySelector(pl(u));if(f)return t.state.loading|=4,t.instance=f,cn(f),f;a=Tb(s),(u=ss.get(u))&&vf(a,u),f=(e.ownerDocument||e).createElement("link"),cn(f);var y=f;return y._p=new Promise(function(R,G){y.onload=R,y.onerror=G}),bn(f,"link",a),t.state.loading|=4,tc(f,s.precedence,e),t.instance=f;case"script":return f=pa(s.src),(u=e.querySelector(hl(f)))?(t.instance=u,cn(u),u):(a=s,(u=ss.get(f))&&(a=x({},s),Sf(a,u)),e=e.ownerDocument||e,u=e.createElement("script"),cn(u),bn(u,"link",a),e.head.appendChild(u),t.instance=u);case"void":return null;default:throw Error(l(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,tc(a,s.precedence,e));return t.instance}function tc(e,t,s){for(var a=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=a.length?a[a.length-1]:null,f=u,y=0;y<a.length;y++){var R=a[y];if(R.dataset.precedence===t)f=R;else if(f!==u)break}f?f.parentNode.insertBefore(e,f.nextSibling):(t=s.nodeType===9?s.head:s,t.insertBefore(e,t.firstChild))}function vf(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Sf(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var nc=null;function Cb(e,t,s){if(nc===null){var a=new Map,u=nc=new Map;u.set(s,a)}else u=nc,a=u.get(s),a||(a=new Map,u.set(s,a));if(a.has(e))return a;for(a.set(e,null),s=s.getElementsByTagName(e),u=0;u<s.length;u++){var f=s[u];if(!(f[_a]||f[sn]||e==="link"&&f.getAttribute("rel")==="stylesheet")&&f.namespaceURI!=="http://www.w3.org/2000/svg"){var y=f.getAttribute(t)||"";y=e+y;var R=a.get(y);R?R.push(f):a.set(y,[f])}}return a}function Rb(e,t,s){e=e.ownerDocument||e,e.head.insertBefore(s,t==="title"?e.querySelector("head > title"):null)}function BN(e,t,s){if(s===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;return t.rel==="stylesheet"?(e=t.disabled,typeof t.precedence=="string"&&e==null):!0;case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function Ob(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function UN(e,t,s,a){if(s.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var u=ma(a.href),f=t.querySelector(pl(u));if(f){t=f._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=sc.bind(e),t.then(e,e)),s.state.loading|=4,s.instance=f,cn(f);return}f=t.ownerDocument||t,a=Tb(a),(u=ss.get(u))&&vf(a,u),f=f.createElement("link"),cn(f);var y=f;y._p=new Promise(function(R,G){y.onload=R,y.onerror=G}),bn(f,"link",a),s.instance=f}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(s,t),(t=s.state.preload)&&(s.state.loading&3)===0&&(e.count++,s=sc.bind(e),t.addEventListener("load",s),t.addEventListener("error",s))}}var Ef=0;function HN(e,t){return e.stylesheets&&e.count===0&&rc(e,e.stylesheets),0<e.count||0<e.imgCount?function(s){var a=setTimeout(function(){if(e.stylesheets&&rc(e,e.stylesheets),e.unsuspend){var f=e.unsuspend;e.unsuspend=null,f()}},6e4+t);0<e.imgBytes&&Ef===0&&(Ef=62500*vN());var u=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&rc(e,e.stylesheets),e.unsuspend)){var f=e.unsuspend;e.unsuspend=null,f()}},(e.imgBytes>Ef?50:800)+t);return e.unsuspend=s,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(u)}}:null}function sc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)rc(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var oc=null;function rc(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,oc=new Map,t.forEach(PN,e),oc=null,sc.call(e))}function PN(e,t){if(!(t.state.loading&4)){var s=oc.get(e);if(s)var a=s.get(null);else{s=new Map,oc.set(e,s);for(var u=e.querySelectorAll("link[data-precedence],style[data-precedence]"),f=0;f<u.length;f++){var y=u[f];(y.nodeName==="LINK"||y.getAttribute("media")!=="not all")&&(s.set(y.dataset.precedence,y),a=y)}a&&s.set(null,a)}u=t.instance,y=u.getAttribute("data-precedence"),f=s.get(y)||a,f===a&&s.set(null,u),s.set(y,u),this.count++,a=sc.bind(this),u.addEventListener("load",a),u.addEventListener("error",a),f?f.parentNode.insertBefore(u,f.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(u,e.firstChild)),t.state.loading|=4}}var gl={$$typeof:k,Provider:null,Consumer:null,_currentValue:H,_currentValue2:H,_threadCount:0};function YN(e,t,s,a,u,f,y,R,G){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ct(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ct(0),this.hiddenUpdates=ct(null),this.identifierPrefix=a,this.onUncaughtError=u,this.onCaughtError=f,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=G,this.incompleteTransitions=new Map}function kb(e,t,s,a,u,f,y,R,G,le,be,Te){return e=new YN(e,t,s,y,G,le,be,Te,R),t=1,f===!0&&(t|=24),f=Bn(3,null,null,t),e.current=f,f.stateNode=e,t=ed(),t.refCount++,e.pooledCache=t,t.refCount++,f.memoizedState={element:a,isDehydrated:s,cache:t},od(f),e}function _b(e){return e?(e=Gr,e):Gr}function Mb(e,t,s,a,u,f){u=_b(u),a.context===null?a.context=u:a.pendingContext=u,a=vo(t),a.payload={element:s},f=f===void 0?null:f,f!==null&&(a.callback=f),s=So(e,a,t),s!==null&&(Mn(s,e,t),Xa(s,e,t))}function Ab(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function Nf(e,t){Ab(e,t),(e=e.alternate)&&Ab(e,t)}function Db(e){if(e.tag===13||e.tag===31){var t=Zo(e,67108864);t!==null&&Mn(t,e,67108864),Nf(e,67108864)}}function zb(e){if(e.tag===13||e.tag===31){var t=Vn();t=mo(t);var s=Zo(e,t);s!==null&&Mn(s,e,t),Nf(e,t)}}var ac=!0;function VN(e,t,s,a){var u=w.T;w.T=null;var f=D.p;try{D.p=2,jf(e,t,s,a)}finally{D.p=f,w.T=u}}function FN(e,t,s,a){var u=w.T;w.T=null;var f=D.p;try{D.p=8,jf(e,t,s,a)}finally{D.p=f,w.T=u}}function jf(e,t,s,a){if(ac){var u=Tf(a);if(u===null)uf(e,t,a,lc,s),Ib(e,a);else if(qN(u,e,t,s,a))a.stopPropagation();else if(Ib(e,a),t&4&&-1<GN.indexOf(e)){for(;u!==null;){var f=Dr(u);if(f!==null)switch(f.tag){case 3:if(f=f.stateNode,f.current.memoizedState.isDehydrated){var y=te(f.pendingLanes);if(y!==0){var R=f;for(R.pendingLanes|=2,R.entangledLanes|=2;y;){var G=1<<31-gt(y);R.entanglements[1]|=G,y&=~G}ys(f),(_t&6)===0&&(Vi=ee()+500,ul(0))}}break;case 31:case 13:R=Zo(f,2),R!==null&&Mn(R,f,2),Gi(),Nf(f,2)}if(f=Tf(a),f===null&&uf(e,t,a,lc,s),f===u)break;u=f}u!==null&&a.stopPropagation()}else uf(e,t,a,null,s)}}function Tf(e){return e=wu(e),wf(e)}var lc=null;function wf(e){if(lc=null,e=Ar(e),e!==null){var t=d(e);if(t===null)e=null;else{var s=t.tag;if(s===13){if(e=m(t),e!==null)return e;e=null}else if(s===31){if(e=g(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return lc=e,null}function Lb(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(F()){case ie:return 2;case Z:return 8;case Ee:case Xe:return 32;case Ne:return 268435456;default:return 32}default:return 32}}var Cf=!1,Mo=null,Ao=null,Do=null,xl=new Map,bl=new Map,zo=[],GN="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Ib(e,t){switch(e){case"focusin":case"focusout":Mo=null;break;case"dragenter":case"dragleave":Ao=null;break;case"mouseover":case"mouseout":Do=null;break;case"pointerover":case"pointerout":xl.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":bl.delete(t.pointerId)}}function yl(e,t,s,a,u,f){return e===null||e.nativeEvent!==f?(e={blockedOn:t,domEventName:s,eventSystemFlags:a,nativeEvent:f,targetContainers:[u]},t!==null&&(t=Dr(t),t!==null&&Db(t)),e):(e.eventSystemFlags|=a,t=e.targetContainers,u!==null&&t.indexOf(u)===-1&&t.push(u),e)}function qN(e,t,s,a,u){switch(t){case"focusin":return Mo=yl(Mo,e,t,s,a,u),!0;case"dragenter":return Ao=yl(Ao,e,t,s,a,u),!0;case"mouseover":return Do=yl(Do,e,t,s,a,u),!0;case"pointerover":var f=u.pointerId;return xl.set(f,yl(xl.get(f)||null,e,t,s,a,u)),!0;case"gotpointercapture":return f=u.pointerId,bl.set(f,yl(bl.get(f)||null,e,t,s,a,u)),!0}return!1}function Bb(e){var t=Ar(e.target);if(t!==null){var s=d(t);if(s!==null){if(t=s.tag,t===13){if(t=m(s),t!==null){e.blockedOn=t,ei(e.priority,function(){zb(s)});return}}else if(t===31){if(t=g(s),t!==null){e.blockedOn=t,ei(e.priority,function(){zb(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ic(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=Tf(e.nativeEvent);if(s===null){s=e.nativeEvent;var a=new s.constructor(s.type,s);Tu=a,s.target.dispatchEvent(a),Tu=null}else return t=Dr(s),t!==null&&Db(t),e.blockedOn=s,!1;t.shift()}return!0}function Ub(e,t,s){ic(e)&&s.delete(t)}function $N(){Cf=!1,Mo!==null&&ic(Mo)&&(Mo=null),Ao!==null&&ic(Ao)&&(Ao=null),Do!==null&&ic(Do)&&(Do=null),xl.forEach(Ub),bl.forEach(Ub)}function cc(e,t){e.blockedOn===t&&(e.blockedOn=null,Cf||(Cf=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,$N)))}var uc=null;function Hb(e){uc!==e&&(uc=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){uc===e&&(uc=null);for(var t=0;t<e.length;t+=3){var s=e[t],a=e[t+1],u=e[t+2];if(typeof a!="function"){if(wf(a||s)===null)continue;break}var f=Dr(s);f!==null&&(e.splice(t,3),t-=3,jd(f,{pending:!0,data:u,method:s.method,action:a},a,u))}}))}function ha(e){function t(G){return cc(G,e)}Mo!==null&&cc(Mo,e),Ao!==null&&cc(Ao,e),Do!==null&&cc(Do,e),xl.forEach(t),bl.forEach(t);for(var s=0;s<zo.length;s++){var a=zo[s];a.blockedOn===e&&(a.blockedOn=null)}for(;0<zo.length&&(s=zo[0],s.blockedOn===null);)Bb(s),s.blockedOn===null&&zo.shift();if(s=(e.ownerDocument||e).$$reactFormReplay,s!=null)for(a=0;a<s.length;a+=3){var u=s[a],f=s[a+1],y=u[wn]||null;if(typeof f=="function")y||Hb(s);else if(y){var R=null;if(f&&f.hasAttribute("formAction")){if(u=f,y=f[wn]||null)R=y.formAction;else if(wf(u)!==null)continue}else R=y.action;typeof R=="function"?s[a+1]=R:(s.splice(a,3),a-=3),Hb(s)}}}function Pb(){function e(f){f.canIntercept&&f.info==="react-transition"&&f.intercept({handler:function(){return new Promise(function(y){return u=y})},focusReset:"manual",scroll:"manual"})}function t(){u!==null&&(u(),u=null),a||setTimeout(s,20)}function s(){if(!a&&!navigation.transition){var f=navigation.currentEntry;f&&f.url!=null&&navigation.navigate(f.url,{state:f.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var a=!1,u=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(s,100),function(){a=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),u!==null&&(u(),u=null)}}}function Rf(e){this._internalRoot=e}dc.prototype.render=Rf.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(l(409));var s=t.current,a=Vn();Mb(s,a,e,t,null,null)},dc.prototype.unmount=Rf.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Mb(e.current,2,null,e,null,null),Gi(),t[Mr]=null}};function dc(e){this._internalRoot=e}dc.prototype.unstable_scheduleHydration=function(e){if(e){var t=zs();e={blockedOn:null,target:e,priority:t};for(var s=0;s<zo.length&&t!==0&&t<zo[s].priority;s++);zo.splice(s,0,e),s===0&&Bb(e)}};var Yb=o.version;if(Yb!=="19.2.8")throw Error(l(527,Yb,"19.2.8"));D.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(l(188)):(e=Object.keys(e).join(","),Error(l(268,e)));return e=p(t),e=e!==null?v(e):null,e=e===null?null:e.stateNode,e};var XN={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:w,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var fc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!fc.isDisabled&&fc.supportsFiber)try{nt=fc.inject(XN),jt=fc}catch{}}return Sl.createRoot=function(e,t){if(!c(e))throw Error(l(299));var s=!1,a="",u=Kg,f=Qg,y=Zg;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(a=t.identifierPrefix),t.onUncaughtError!==void 0&&(u=t.onUncaughtError),t.onCaughtError!==void 0&&(f=t.onCaughtError),t.onRecoverableError!==void 0&&(y=t.onRecoverableError)),t=kb(e,1,!1,null,null,s,a,null,u,f,y,Pb),e[Mr]=t.current,cf(e),new Rf(t)},Sl.hydrateRoot=function(e,t,s){if(!c(e))throw Error(l(299));var a=!1,u="",f=Kg,y=Qg,R=Zg,G=null;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(u=s.identifierPrefix),s.onUncaughtError!==void 0&&(f=s.onUncaughtError),s.onCaughtError!==void 0&&(y=s.onCaughtError),s.onRecoverableError!==void 0&&(R=s.onRecoverableError),s.formState!==void 0&&(G=s.formState)),t=kb(e,1,!0,t,s??null,a,u,G,f,y,R,Pb),t.context=_b(null),s=t.current,a=Vn(),a=mo(a),u=vo(a),u.callback=null,So(s,u,a),s=a,t.current.lanes=s,lt(t,s),ys(t),e[Mr]=t.current,cf(e),new dc(t)},Sl.version="19.2.8",Sl}var Jb;function rj(){if(Jb)return _f.exports;Jb=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(o){console.error(o)}}return n(),_f.exports=oj(),_f.exports}var aj=rj();const Ca=["character","setting","location","hook","event","timepoint"],Um=["belongs_to","owns","masters","ally","rival","mentor","family","kills","appears_in","occurs_at","plot_edge","plants","advances","resolves","depends_on","involves","occurs_in"],lj="plot_edge",ij=["mystery","relationship","item","character_growth","world_building"],Zv=["inner","personal","extra_personal"],cj=[5,10,15,30,60],Wb=30;function is(n){const o=new Date(n);if(Number.isNaN(o.getTime()))return n;const r=l=>String(l).padStart(2,"0");return`${o.getFullYear()}-${r(o.getMonth()+1)}-${r(o.getDate())} ${r(o.getHours())}:${r(o.getMinutes())}`}function br(n){const o=new Date(n);if(Number.isNaN(o.getTime()))return n;const r=Math.floor((Date.now()-o.getTime())/6e4);if(r<1)return"刚刚";if(r<60)return`${r} 分钟前`;const l=Math.floor(r/60);if(l<24)return`${l} 小时前`;const c=Math.floor(l/24);return c<30?`${c} 天前`:is(n)}const uj=["outline","entities","canvas","hooks","timeline","trash","settings"];function ey(n){const o=n.replace(/^#/,"").replace(/^\/+/,""),r=o===""?[]:o.split("/").filter(c=>c!=="");return r.length>0&&!uj.includes(r[0])?{path:"/",segments:[],isFallback:!0}:{path:`/${r.join("/")}`,segments:r,isFallback:!1}}function dj(){const[n,o]=h.useState(()=>ey(window.location.hash));return h.useEffect(()=>{const r=()=>{const l=ey(window.location.hash);o(l),l.isFallback&&window.location.hash!=="#/"&&window.location.replace("#/")};return window.addEventListener("hashchange",r),r(),()=>window.removeEventListener("hashchange",r)},[]),n}function Tn(n){const o=n.startsWith("#")?n:`#${n.startsWith("/")?n:`/${n}`}`;window.location.hash!==o&&(window.location.hash=o)}const Jv=(...n)=>n.filter((o,r,l)=>!!o&&o.trim()!==""&&l.indexOf(o)===r).join(" ").trim();const fj=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const mj=n=>n.replace(/^([A-Z])|[\s-_]+(\w)/g,(o,r,l)=>l?l.toUpperCase():r.toLowerCase());const ty=n=>{const o=mj(n);return o.charAt(0).toUpperCase()+o.slice(1)};var zf={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const pj=n=>{for(const o in n)if(o.startsWith("aria-")||o==="role"||o==="title")return!0;return!1},hj=h.createContext({}),gj=()=>h.useContext(hj),xj=h.forwardRef(({color:n,size:o,strokeWidth:r,absoluteStrokeWidth:l,className:c="",children:d,iconNode:m,...g},b)=>{const{size:p=24,strokeWidth:v=2,absoluteStrokeWidth:x=!1,color:S="currentColor",className:j=""}=gj()??{},E=l??x?Number(r??v)*24/Number(o??p):r??v;return h.createElement("svg",{ref:b,...zf,width:o??p??zf.width,height:o??p??zf.height,stroke:n??S,strokeWidth:E,className:Jv("lucide",j,c),...!d&&!pj(g)&&{"aria-hidden":"true"},...g},[...m.map(([M,O])=>h.createElement(M,O)),...Array.isArray(d)?d:[d]])});const mt=(n,o)=>{const r=h.forwardRef(({className:l,...c},d)=>h.createElement(xj,{ref:d,iconNode:o,className:Jv(`lucide-${fj(ty(n))}`,`lucide-${n}`,l),...c}));return r.displayName=ty(n),r};const bj=[["path",{d:"M12 5v16",key:"1f6ucr"}],["path",{d:"M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z",key:"1fyvmf"}]],Lc=mt("book-open",bj);const yj=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v3",key:"otl347"}],["path",{d:"M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338",key:"7hb8p4"}],["path",{d:"M3 9h5.859",key:"numkqi"}],["path",{d:"M8 2v3",key:"1ioesn"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],vj=mt("calendar-clock",yj);const Sj=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ej=mt("check",Sj);const Nj=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],jj=mt("chevron-down",Nj);const Tj=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Hm=mt("chevron-right",Tj);const wj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Pm=mt("circle-alert",wj);const Cj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ym=mt("circle-check",Cj);const Rj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Oj=mt("circle",Rj);const kj=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],_j=mt("download",kj);const Mj=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Vm=mt("ellipsis",Mj);const Aj=[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]],Dj=mt("fast-forward",Aj);const zj=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Fm=mt("grip-vertical",zj);const Lj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Wv=mt("info",Lj);const Ij=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],Bj=mt("layout-grid",Ij);const Uj=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],Hj=mt("list-ordered",Uj);const Pj=[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]],Yj=mt("list-tree",Pj);const Vj=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Il=mt("loader-circle",Vj);const Fj=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Bl=mt("message-square",Fj);const Gj=[["path",{d:"M5 12h14",key:"1ays0h"}]],qj=mt("minus",Gj);const $j=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],Xj=mt("moon",$j);const Kj=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],Qj=mt("network",Kj);const Zj=[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Jj=mt("octagon-x",Zj);const Wj=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],eT=mt("panel-left-close",Wj);const tT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],nT=mt("panel-left-open",tT);const sT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],oT=mt("panel-right-close",sT);const rT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],aT=mt("panel-right-open",rT);const lT=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],iT=mt("pencil",lT);const cT=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],uT=mt("pin",cT);const dT=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Gm=mt("plus",dT);const fT=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],mT=mt("puzzle",fT);const pT=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],hT=mt("refresh-cw",pT);const gT=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],xT=mt("rotate-ccw",gT);const bT=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],yT=mt("send",bT);const vT=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],ST=mt("settings",vT);const ET=[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]],NT=mt("shapes",ET);const jT=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],e0=mt("sparkles",jT);const TT=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],wT=mt("sun",TT);const CT=[["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"}]],t0=mt("trash-2",CT);const RT=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],qm=mt("triangle-alert",RT);const OT=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],kT=mt("upload",OT);const _T=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],MT=mt("wrench",_T);const AT=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],As=mt("x",AT);function $m(n){const[o,r]=h.useState(()=>window.matchMedia(n).matches);return h.useEffect(()=>{const l=window.matchMedia(n),c=d=>r(d.matches);return r(l.matches),l.addEventListener("change",c),()=>l.removeEventListener("change",c)},[n]),o}const Ul=160,Xm=480,Hl=240,Km=720,DT=320,n0="ai-editor:panels",ny=1024,um=1440;function Pl(n,o,r){return Math.round(Math.min(Math.max(n,o),r))}function mc(n){const o=Number.isFinite(n)&&n>0?n:um;return{sidebarWidth:o<ny?Ul:Pl(o*.1,Ul,Xm),chatWidth:o<ny?Hl:Pl(o*.4,Hl,Km),collapsedSidebar:!1,collapsedChat:!1}}function zT(n,o){if(!n)return mc(o);let r;try{r=JSON.parse(n)}catch{return mc(o)}if(typeof r!="object"||r===null||Array.isArray(r))return mc(o);const l=r,c=l.sidebarWidth,d=l.chatWidth;return typeof c!="number"||!Number.isFinite(c)||typeof d!="number"||!Number.isFinite(d)?mc(o):{sidebarWidth:Pl(c,Ul,Xm),chatWidth:Pl(d,Hl,Km),collapsedSidebar:l.collapsedSidebar===!0,collapsedChat:l.collapsedChat===!0}}function sy(n){return JSON.stringify({sidebarWidth:n.sidebarWidth,chatWidth:n.chatWidth,collapsedSidebar:n.collapsedSidebar,collapsedChat:n.collapsedChat})}function LT(){if(typeof window>"u")return null;try{return window.localStorage.getItem(n0)}catch{return null}}function oy(n){try{window.localStorage.setItem(n0,n)}catch{}}function IT(){if(typeof window>"u")return um;const n=window.innerWidth;return Number.isFinite(n)&&n>0?n:um}function BT(){const[n,o]=h.useState(()=>zT(LT(),IT())),[r,l]=h.useState(null),c=$m("(min-width: 1024px)"),d=h.useRef(null);h.useEffect(()=>{!c&&d.current!==null&&(d.current=null,l(null))},[c]);function m(x){const S=x.lastX-x.startX,[j,E]=x.side==="sidebar"?[Ul,Xm]:[Hl,Km],M=x.side==="sidebar"?x.startWidth+S:x.startWidth-S;return Pl(M,j,E)}function g(x,S){const j=x==="sidebar"?n.sidebarWidth:n.chatWidth;d.current={side:x,startX:S,startWidth:j,lastX:S},l(x)}function b(x,S){const j=d.current;if(!j||j.side!==x)return;j.lastX=S;const E=m(j);o(M=>({...M,...x==="sidebar"?{sidebarWidth:E}:{chatWidth:E}}))}function p(){const x=d.current;if(!x)return;const S=m(x);d.current=null,l(null),o(j=>{const E={...j,...x.side==="sidebar"?{sidebarWidth:S}:{chatWidth:S}};return oy(sy(E)),E})}function v(x){o(S=>{const j=x==="sidebar"?{...S,collapsedSidebar:!S.collapsedSidebar}:{...S,collapsedChat:!S.collapsedChat};return oy(sy(j)),j})}return{layout:n,isDesktop:c,dragSide:r,toggleCollapse:v,startResize:g,moveResize:b,endResize:p}}function s0(n){var o,r,l="";if(typeof n=="string"||typeof n=="number")l+=n;else if(typeof n=="object")if(Array.isArray(n)){var c=n.length;for(o=0;o<c;o++)n[o]&&(r=s0(n[o]))&&(l&&(l+=" "),l+=r)}else for(r in n)n[r]&&(l&&(l+=" "),l+=r);return l}function o0(){for(var n,o,r=0,l="",c=arguments.length;r<c;r++)(n=arguments[r])&&(o=s0(n))&&(l&&(l+=" "),l+=o);return l}const UT=(n,o)=>{const r=new Array(n.length+o.length);for(let l=0;l<n.length;l++)r[l]=n[l];for(let l=0;l<o.length;l++)r[n.length+l]=o[l];return r},HT=(n,o)=>({classGroupId:n,validator:o}),r0=(n=new Map,o=null,r)=>({nextPart:n,validators:o,classGroupId:r}),Ic="-",ry=[],PT="arbitrary..",YT=n=>{const o=FT(n),{conflictingClassGroups:r,conflictingClassGroupModifiers:l}=n;return{getClassGroupId:m=>{if(m.startsWith("[")&&m.endsWith("]"))return VT(m);const g=m.split(Ic),b=g[0]===""&&g.length>1?1:0;return a0(g,b,o)},getConflictingClassGroupIds:(m,g)=>{if(g){const b=l[m],p=r[m];return b?p?UT(p,b):b:p||ry}return r[m]||ry}}},a0=(n,o,r)=>{if(n.length-o===0)return r.classGroupId;const c=n[o],d=r.nextPart.get(c);if(d){const p=a0(n,o+1,d);if(p)return p}const m=r.validators;if(m===null)return;const g=o===0?n.join(Ic):n.slice(o).join(Ic),b=m.length;for(let p=0;p<b;p++){const v=m[p];if(v.validator(g))return v.classGroupId}},VT=n=>n.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const o=n.slice(1,-1),r=o.indexOf(":"),l=o.slice(0,r);return l?PT+l:void 0})(),FT=n=>{const{theme:o,classGroups:r}=n;return GT(r,o)},GT=(n,o)=>{const r=r0();for(const l in n){const c=n[l];Qm(c,r,l,o)}return r},Qm=(n,o,r,l)=>{const c=n.length;for(let d=0;d<c;d++){const m=n[d];qT(m,o,r,l)}},qT=(n,o,r,l)=>{if(typeof n=="string"){$T(n,o,r);return}if(typeof n=="function"){XT(n,o,r,l);return}KT(n,o,r,l)},$T=(n,o,r)=>{const l=n===""?o:l0(o,n);l.classGroupId=r},XT=(n,o,r,l)=>{if(QT(n)){Qm(n(l),o,r,l);return}o.validators===null&&(o.validators=[]),o.validators.push(HT(r,n))},KT=(n,o,r,l)=>{const c=Object.entries(n),d=c.length;for(let m=0;m<d;m++){const[g,b]=c[m];Qm(b,l0(o,g),r,l)}},l0=(n,o)=>{let r=n;const l=o.split(Ic),c=l.length;for(let d=0;d<c;d++){const m=l[d];let g=r.nextPart.get(m);g||(g=r0(),r.nextPart.set(m,g)),r=g}return r},QT=n=>"isThemeGetter"in n&&n.isThemeGetter===!0,ZT=n=>{if(n<1)return{get:()=>{},set:()=>{}};let o=0,r=Object.create(null),l=Object.create(null);const c=(d,m)=>{r[d]=m,o++,o>n&&(o=0,l=r,r=Object.create(null))};return{get(d){let m=r[d];if(m!==void 0)return m;if((m=l[d])!==void 0)return c(d,m),m},set(d,m){d in r?r[d]=m:c(d,m)}}},dm="!",ay=":",JT=[],ly=(n,o,r,l,c)=>({modifiers:n,hasImportantModifier:o,baseClassName:r,maybePostfixModifierPosition:l,isExternal:c}),WT=n=>{const{prefix:o,experimentalParseClassName:r}=n;let l=c=>{const d=[];let m=0,g=0,b=0,p;const v=c.length;for(let M=0;M<v;M++){const O=c[M];if(m===0&&g===0){if(O===ay){d.push(c.slice(b,M)),b=M+1;continue}if(O==="/"){p=M;continue}}O==="["?m++:O==="]"?m--:O==="("?g++:O===")"&&g--}const x=d.length===0?c:c.slice(b);let S=x,j=!1;x.endsWith(dm)?(S=x.slice(0,-1),j=!0):x.startsWith(dm)&&(S=x.slice(1),j=!0);const E=p&&p>b?p-b:void 0;return ly(d,j,S,E)};if(o){const c=o+ay,d=l;l=m=>m.startsWith(c)?d(m.slice(c.length)):ly(JT,!1,m,void 0,!0)}if(r){const c=l;l=d=>r({className:d,parseClassName:c})}return l},ew=n=>{const o=new Map;return n.orderSensitiveModifiers.forEach((r,l)=>{o.set(r,1e6+l)}),r=>{const l=[];let c=[];for(let d=0;d<r.length;d++){const m=r[d],g=m[0]==="[",b=o.has(m);g||b?(c.length>0&&(c.sort(),l.push(...c),c=[]),l.push(m)):c.push(m)}return c.length>0&&(c.sort(),l.push(...c)),l}},tw=n=>({cache:ZT(n.cacheSize),parseClassName:WT(n),sortModifiers:ew(n),postfixLookupClassGroupIds:nw(n),...YT(n)}),nw=n=>{const o=Object.create(null),r=n.postfixLookupClassGroups;if(r)for(let l=0;l<r.length;l++)o[r[l]]=!0;return o},sw=/\s+/,ow=(n,o)=>{const{parseClassName:r,getClassGroupId:l,getConflictingClassGroupIds:c,sortModifiers:d,postfixLookupClassGroupIds:m}=o,g=[],b=n.trim().split(sw);let p="";for(let v=b.length-1;v>=0;v-=1){const x=b[v],{isExternal:S,modifiers:j,hasImportantModifier:E,baseClassName:M,maybePostfixModifierPosition:O}=r(x);if(S){p=x+(p.length>0?" "+p:p);continue}let N=!!O,T;if(N){const L=M.substring(0,O);T=l(L);const _=T&&m[T]?l(M):void 0;_&&_!==T&&(T=_,N=!1)}else T=l(M);if(!T){if(!N){p=x+(p.length>0?" "+p:p);continue}if(T=l(M),!T){p=x+(p.length>0?" "+p:p);continue}N=!1}const k=j.length===0?"":j.length===1?j[0]:d(j).join(":"),C=E?k+dm:k,U=C+T;if(g.indexOf(U)>-1)continue;g.push(U);const A=c(T,N);for(let L=0;L<A.length;++L){const _=A[L];g.push(C+_)}p=x+(p.length>0?" "+p:p)}return p},rw=(...n)=>{let o=0,r,l,c="";for(;o<n.length;)(r=n[o++])&&(l=i0(r))&&(c&&(c+=" "),c+=l);return c},i0=n=>{if(typeof n=="string")return n;let o,r="";for(let l=0;l<n.length;l++)n[l]&&(o=i0(n[l]))&&(r&&(r+=" "),r+=o);return r},aw=(n,...o)=>{let r,l,c,d;const m=b=>{const p=o.reduce((v,x)=>x(v),n());return r=tw(p),l=r.cache.get,c=r.cache.set,d=g,g(b)},g=b=>{const p=l(b);if(p)return p;const v=ow(b,r);return c(b,v),v};return d=m,(...b)=>d(rw(...b))},lw=[],rn=n=>{const o=r=>r[n]||lw;return o.isThemeGetter=!0,o},c0=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,u0=/^\((?:(\w[\w-]*):)?(.+)\)$/i,iw=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,cw=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,uw=/\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$/,dw=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,fw=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,mw=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Io=n=>iw.test(n),ht=n=>!!n&&!Number.isNaN(Number(n)),vs=n=>!!n&&Number.isInteger(Number(n)),Lf=n=>n.endsWith("%")&&ht(n.slice(0,-1)),eo=n=>cw.test(n),d0=()=>!0,pw=n=>uw.test(n)&&!dw.test(n),Zm=()=>!1,hw=n=>fw.test(n),gw=n=>mw.test(n),xw=n=>!Ve(n)&&!Fe(n),bw=n=>n.startsWith("@container")&&(n[10]==="/"&&n[11]!==void 0||n[11]==="s"&&n[16]!==void 0&&n.startsWith("-size/",10)||n[11]==="n"&&n[18]!==void 0&&n.startsWith("-normal/",10)),yw=n=>Fo(n,p0,Zm),Ve=n=>c0.test(n),ur=n=>Fo(n,h0,pw),iy=n=>Fo(n,Cw,ht),vw=n=>Fo(n,x0,d0),Sw=n=>Fo(n,g0,Zm),cy=n=>Fo(n,f0,Zm),Ew=n=>Fo(n,m0,gw),pc=n=>Fo(n,b0,hw),Fe=n=>u0.test(n),El=n=>wr(n,h0),Nw=n=>wr(n,g0),uy=n=>wr(n,f0),jw=n=>wr(n,p0),Tw=n=>wr(n,m0),hc=n=>wr(n,b0,!0),ww=n=>wr(n,x0,!0),Fo=(n,o,r)=>{const l=c0.exec(n);return l?l[1]?o(l[1]):r(l[2]):!1},wr=(n,o,r=!1)=>{const l=u0.exec(n);return l?l[1]?o(l[1]):r:!1},f0=n=>n==="position"||n==="percentage",m0=n=>n==="image"||n==="url",p0=n=>n==="length"||n==="size"||n==="bg-size",h0=n=>n==="length",Cw=n=>n==="number",g0=n=>n==="family-name",x0=n=>n==="number"||n==="weight",b0=n=>n==="shadow",Rw=()=>{const n=rn("color"),o=rn("font"),r=rn("text"),l=rn("font-weight"),c=rn("tracking"),d=rn("leading"),m=rn("breakpoint"),g=rn("container"),b=rn("spacing"),p=rn("radius"),v=rn("shadow"),x=rn("inset-shadow"),S=rn("text-shadow"),j=rn("drop-shadow"),E=rn("blur"),M=rn("perspective"),O=rn("aspect"),N=rn("ease"),T=rn("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],C=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],U=()=>[...C(),Fe,Ve],A=()=>["auto","hidden","clip","visible","scroll"],L=()=>["auto","contain","none"],_=()=>[Fe,Ve,b],K=()=>[Io,"full","auto",..._()],W=()=>[vs,"none","subgrid",Fe,Ve],ue=()=>["auto",{span:["full",vs,Fe,Ve]},vs,Fe,Ve],ne=()=>[vs,"auto",Fe,Ve],$=()=>["auto","min","max","fr",Fe,Ve],oe=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],q=()=>["start","end","center","stretch","center-safe","end-safe"],w=()=>["auto",..._()],D=()=>[Io,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",..._()],H=()=>[Io,"screen","full","dvw","lvw","svw","min","max","fit",..._()],B=()=>[Io,"screen","full","lh","dvh","lvh","svh","min","max","fit",..._()],P=()=>[n,Fe,Ve],z=()=>[...C(),uy,cy,{position:[Fe,Ve]}],X=()=>["no-repeat",{repeat:["","x","y","space","round"]}],I=()=>["auto","cover","contain",jw,yw,{size:[Fe,Ve]}],V=()=>[Lf,El,ur],Q=()=>["","none","full",p,Fe,Ve],Y=()=>["",ht,El,ur],fe=()=>["solid","dashed","dotted","double"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],de=()=>[ht,Lf,uy,cy],_e=()=>["","none",E,Fe,Ve],Ye=()=>["none",ht,Fe,Ve],Re=()=>["none",ht,Fe,Ve],Le=()=>[ht,Fe,Ve],He=()=>[Io,"full",..._()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[eo],breakpoint:[eo],color:[d0],container:[eo],"drop-shadow":[eo],ease:["in","out","in-out"],font:[xw],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[eo],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[eo],shadow:[eo],spacing:["px",ht],text:[eo],"text-shadow":[eo],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Io,Ve,Fe,O]}],container:["container"],"container-type":[{"@container":["","normal","size",Fe,Ve]}],"container-named":[bw],columns:[{columns:[ht,Ve,Fe,g]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"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:U()}],overflow:[{overflow:A()}],"overflow-x":[{"overflow-x":A()}],"overflow-y":[{"overflow-y":A()}],overscroll:[{overscroll:L()}],"overscroll-x":[{"overscroll-x":L()}],"overscroll-y":[{"overscroll-y":L()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:K()}],"inset-x":[{"inset-x":K()}],"inset-y":[{"inset-y":K()}],start:[{"inset-s":K(),start:K()}],end:[{"inset-e":K(),end:K()}],"inset-bs":[{"inset-bs":K()}],"inset-be":[{"inset-be":K()}],top:[{top:K()}],right:[{right:K()}],bottom:[{bottom:K()}],left:[{left:K()}],visibility:["visible","invisible","collapse"],z:[{z:[vs,"auto",Fe,Ve]}],basis:[{basis:[Io,"full","auto",g,..._()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ht,Io,"auto","initial","none",Ve]}],grow:[{grow:["",ht,Fe,Ve]}],shrink:[{shrink:["",ht,Fe,Ve]}],order:[{order:[vs,"first","last","none",Fe,Ve]}],"grid-cols":[{"grid-cols":W()}],"col-start-end":[{col:ue()}],"col-start":[{"col-start":ne()}],"col-end":[{"col-end":ne()}],"grid-rows":[{"grid-rows":W()}],"row-start-end":[{row:ue()}],"row-start":[{"row-start":ne()}],"row-end":[{"row-end":ne()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":$()}],"auto-rows":[{"auto-rows":$()}],gap:[{gap:_()}],"gap-x":[{"gap-x":_()}],"gap-y":[{"gap-y":_()}],"justify-content":[{justify:[...oe(),"normal"]}],"justify-items":[{"justify-items":[...q(),"normal"]}],"justify-self":[{"justify-self":["auto",...q()]}],"align-content":[{content:["normal",...oe()]}],"align-items":[{items:[...q(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...q(),{baseline:["","last"]}]}],"place-content":[{"place-content":oe()}],"place-items":[{"place-items":[...q(),"baseline"]}],"place-self":[{"place-self":["auto",...q()]}],p:[{p:_()}],px:[{px:_()}],py:[{py:_()}],ps:[{ps:_()}],pe:[{pe:_()}],pbs:[{pbs:_()}],pbe:[{pbe:_()}],pt:[{pt:_()}],pr:[{pr:_()}],pb:[{pb:_()}],pl:[{pl:_()}],m:[{m:w()}],mx:[{mx:w()}],my:[{my:w()}],ms:[{ms:w()}],me:[{me:w()}],mbs:[{mbs:w()}],mbe:[{mbe:w()}],mt:[{mt:w()}],mr:[{mr:w()}],mb:[{mb:w()}],ml:[{ml:w()}],"space-x":[{"space-x":_()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":_()}],"space-y-reverse":["space-y-reverse"],size:[{size:D()}],"inline-size":[{inline:["auto",...H()]}],"min-inline-size":[{"min-inline":["auto",...H()]}],"max-inline-size":[{"max-inline":["none",...H()]}],"block-size":[{block:["auto",...B()]}],"min-block-size":[{"min-block":["auto",...B()]}],"max-block-size":[{"max-block":["none",...B()]}],w:[{w:[g,"screen",...D()]}],"min-w":[{"min-w":[g,"screen","none",...D()]}],"max-w":[{"max-w":[g,"screen","none","prose",{screen:[m]},...D()]}],h:[{h:["screen","lh",...D()]}],"min-h":[{"min-h":["screen","lh","none",...D()]}],"max-h":[{"max-h":["screen","lh",...D()]}],"font-size":[{text:["base",r,El,ur]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[l,ww,vw]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Lf,Ve]}],"font-family":[{font:[Nw,Sw,o]}],"font-features":[{"font-features":[Ve]}],"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:[c,Fe,Ve]}],"line-clamp":[{"line-clamp":[ht,"none",Fe,iy]}],leading:[{leading:[d,..._()]}],"list-image":[{"list-image":["none",Fe,Ve]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Fe,Ve]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...fe(),"wavy"]}],"text-decoration-thickness":[{decoration:[ht,"from-font","auto",Fe,ur]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[ht,"auto",Fe,Ve]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"tab-size":[{tab:[vs,Fe,Ve]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Fe,Ve]}],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",Fe,Ve]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:z()}],"bg-repeat":[{bg:X()}],"bg-size":[{bg:I()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},vs,Fe,Ve],radial:["",Fe,Ve],conic:[vs,Fe,Ve]},Tw,Ew]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:V()}],"gradient-via-pos":[{via:V()}],"gradient-to-pos":[{to:V()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:Q()}],"rounded-s":[{"rounded-s":Q()}],"rounded-e":[{"rounded-e":Q()}],"rounded-t":[{"rounded-t":Q()}],"rounded-r":[{"rounded-r":Q()}],"rounded-b":[{"rounded-b":Q()}],"rounded-l":[{"rounded-l":Q()}],"rounded-ss":[{"rounded-ss":Q()}],"rounded-se":[{"rounded-se":Q()}],"rounded-ee":[{"rounded-ee":Q()}],"rounded-es":[{"rounded-es":Q()}],"rounded-tl":[{"rounded-tl":Q()}],"rounded-tr":[{"rounded-tr":Q()}],"rounded-br":[{"rounded-br":Q()}],"rounded-bl":[{"rounded-bl":Q()}],"border-w":[{border:Y()}],"border-w-x":[{"border-x":Y()}],"border-w-y":[{"border-y":Y()}],"border-w-s":[{"border-s":Y()}],"border-w-e":[{"border-e":Y()}],"border-w-bs":[{"border-bs":Y()}],"border-w-be":[{"border-be":Y()}],"border-w-t":[{"border-t":Y()}],"border-w-r":[{"border-r":Y()}],"border-w-b":[{"border-b":Y()}],"border-w-l":[{"border-l":Y()}],"divide-x":[{"divide-x":Y()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Y()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...fe(),"hidden","none"]}],"divide-style":[{divide:[...fe(),"hidden","none"]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-bs":[{"border-bs":P()}],"border-color-be":[{"border-be":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...fe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ht,Fe,Ve]}],"outline-w":[{outline:["",ht,El,ur]}],"outline-color":[{outline:P()}],shadow:[{shadow:["","none",v,hc,pc]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":["none",x,hc,pc]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:Y()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[ht,ur]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":Y()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":["none",S,hc,pc]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[ht,Fe,Ve]}],"mix-blend":[{"mix-blend":[...re(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":re()}],"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":[ht]}],"mask-image-linear-from-pos":[{"mask-linear-from":de()}],"mask-image-linear-to-pos":[{"mask-linear-to":de()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":de()}],"mask-image-t-to-pos":[{"mask-t-to":de()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":de()}],"mask-image-r-to-pos":[{"mask-r-to":de()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":de()}],"mask-image-b-to-pos":[{"mask-b-to":de()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":de()}],"mask-image-l-to-pos":[{"mask-l-to":de()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":de()}],"mask-image-x-to-pos":[{"mask-x-to":de()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":de()}],"mask-image-y-to-pos":[{"mask-y-to":de()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[Fe,Ve]}],"mask-image-radial-from-pos":[{"mask-radial-from":de()}],"mask-image-radial-to-pos":[{"mask-radial-to":de()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"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":C()}],"mask-image-conic-pos":[{"mask-conic":[ht]}],"mask-image-conic-from-pos":[{"mask-conic-from":de()}],"mask-image-conic-to-pos":[{"mask-conic-to":de()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:z()}],"mask-repeat":[{mask:X()}],"mask-size":[{mask:I()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Fe,Ve]}],filter:[{filter:["","none",Fe,Ve]}],blur:[{blur:_e()}],brightness:[{brightness:[ht,Fe,Ve]}],contrast:[{contrast:[ht,Fe,Ve]}],"drop-shadow":[{"drop-shadow":["","none",j,hc,pc]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:["",ht,Fe,Ve]}],"hue-rotate":[{"hue-rotate":[ht,Fe,Ve]}],invert:[{invert:["",ht,Fe,Ve]}],saturate:[{saturate:[ht,Fe,Ve]}],sepia:[{sepia:["",ht,Fe,Ve]}],"backdrop-filter":[{"backdrop-filter":["","none",Fe,Ve]}],"backdrop-blur":[{"backdrop-blur":_e()}],"backdrop-brightness":[{"backdrop-brightness":[ht,Fe,Ve]}],"backdrop-contrast":[{"backdrop-contrast":[ht,Fe,Ve]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ht,Fe,Ve]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ht,Fe,Ve]}],"backdrop-invert":[{"backdrop-invert":["",ht,Fe,Ve]}],"backdrop-opacity":[{"backdrop-opacity":[ht,Fe,Ve]}],"backdrop-saturate":[{"backdrop-saturate":[ht,Fe,Ve]}],"backdrop-sepia":[{"backdrop-sepia":["",ht,Fe,Ve]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":_()}],"border-spacing-x":[{"border-spacing-x":_()}],"border-spacing-y":[{"border-spacing-y":_()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Fe,Ve]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ht,"initial",Fe,Ve]}],ease:[{ease:["linear","initial",N,Fe,Ve]}],delay:[{delay:[ht,Fe,Ve]}],animate:[{animate:["none",T,Fe,Ve]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[M,Fe,Ve]}],"perspective-origin":[{"perspective-origin":U()}],rotate:[{rotate:Ye()}],"rotate-x":[{"rotate-x":Ye()}],"rotate-y":[{"rotate-y":Ye()}],"rotate-z":[{"rotate-z":Ye()}],scale:[{scale:Re()}],"scale-x":[{"scale-x":Re()}],"scale-y":[{"scale-y":Re()}],"scale-z":[{"scale-z":Re()}],"scale-3d":["scale-3d"],skew:[{skew:Le()}],"skew-x":[{"skew-x":Le()}],"skew-y":[{"skew-y":Le()}],transform:[{transform:[Fe,Ve,"","none","gpu","cpu"]}],"transform-origin":[{origin:U()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:He()}],"translate-x":[{"translate-x":He()}],"translate-y":[{"translate-y":He()}],"translate-z":[{"translate-z":He()}],"translate-none":["translate-none"],zoom:[{zoom:[vs,Fe,Ve]}],accent:[{accent:P()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:P()}],"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",Fe,Ve]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":P()}],"scrollbar-track-color":[{"scrollbar-track":P()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mbs":[{"scroll-mbs":_()}],"scroll-mbe":[{"scroll-mbe":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pbs":[{"scroll-pbs":_()}],"scroll-pbe":[{"scroll-pbe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"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",Fe,Ve]}],fill:[{fill:["none",...P()]}],"stroke-w":[{stroke:[ht,El,ur,iy]}],stroke:[{stroke:["none",...P()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","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","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","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-bs","border-w-be","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-bs","border-color-be","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-mbs","scroll-mbe","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-pbs","scroll-pbe","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"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Ow=aw(Rw);function Ze(...n){return Ow(o0(n))}const dy=n=>{let o;const r=new Set,l=(p,v)=>{const x=typeof p=="function"?p(o):p;if(!Object.is(x,o)){const S=o;o=v??(typeof x!="object"||x===null)?x:Object.assign({},o,x),r.forEach(j=>j(o,S))}},c=()=>o,g={setState:l,getState:c,getInitialState:()=>b,subscribe:p=>(r.add(p),()=>r.delete(p))},b=o=n(l,c,g);return g},kw=(n=>n?dy(n):dy),_w=n=>n;function Mw(n,o=_w){const r=Ae.useSyncExternalStore(n.subscribe,Ae.useCallback(()=>o(n.getState()),[n,o]),Ae.useCallback(()=>o(n.getInitialState()),[n,o]));return Ae.useDebugValue(r),r}const fy=n=>{const o=kw(n),r=l=>Mw(o,l);return Object.assign(r,o),r},Jm=(n=>n?fy(n):fy),Aw="/api/v1",ft="CLIENT_NETWORK_ERROR";class ze extends Error{code;constructor(o,r){super(r),this.name="ApiError",this.code=o}}function Dw(n){const o=new URLSearchParams;for(const[l,c]of Object.entries(n))c!=null&&o.set(l,String(c));const r=o.toString();return r?`?${r}`:""}function y0(n,o){const r=n.startsWith("/")?n:`/${n}`;return`${Aw}${r}${Dw(o??{})}`}function zw(n){return typeof n=="object"&&n!==null&&n.success===!0}function v0(n){if(typeof n!="object"||n===null)return!1;const o=n.error;return n.success===!1&&typeof o=="object"&&o!==null&&typeof o.code=="string"&&typeof o.message=="string"}async function ut(n,o={}){const{method:r="GET",body:l,query:c,headers:d,signal:m}=o;let g;try{g=await fetch(y0(n,c),{method:r,headers:l===void 0||l instanceof FormData?d:{"Content-Type":"application/json",...d},body:l===void 0?void 0:l instanceof FormData?l:JSON.stringify(l),signal:m})}catch(p){throw new ze(ft,p instanceof Error?p.message:"网络请求失败")}const b=await g.json().catch(()=>null);if(zw(b))return b.data;throw v0(b)?new ze(b.error.code,b.error.message):new ze(ft,`非预期响应(HTTP ${g.status})`)}function Lw(){return ut("/project/config")}function Iw(n){return ut("/project/config",{method:"PUT",body:n})}function Bw(){return ut("/outline")}function Uw(n){return ut("/outline",{method:"POST",body:n})}function S0(n,o){return ut(`/outline/${n}`,{method:"PUT",body:o})}function my(n,o){return ut(`/outline/${n}/move`,{method:"PUT",body:o})}function Hw(n){return ut(`/outline/${n}`,{method:"DELETE"})}function Pw(){return ut("/trash")}function Yw(n,o){return ut(`/trash/entity/${n}/${o}/restore`,{method:"POST"})}function Vw(n,o){return ut(`/trash/entity/${n}/${o}`,{method:"DELETE"})}function py(n){return ut(`/trash/outline/${n}/restore`,{method:"POST"})}function Fw(n){return ut(`/trash/outline/${n}`,{method:"DELETE"})}function ls(n,o={}){return ut(`/entity/${n}`,{query:o})}function pr(n,o){return ut(`/entity/${n}/${o}`)}function Bc(n,o){return ut(`/entity/${n}`,{method:"POST",body:o})}function yr(n,o,r){return ut(`/entity/${n}/${o}`,{method:"PUT",body:r})}function Qc(n,o){return ut(`/entity/${n}/${o}`,{method:"DELETE"})}function Gw(n,o){return ut(`/entity/event/${n}/move`,{method:"PUT",body:o})}function qw(n,o){return ut(`/entity/timepoint/${n}/move`,{method:"PUT",body:o})}function E0(n,o){return ut(`/entity/event/${n}/move_to`,{method:"POST",body:o})}function vr(n){return ut("/relation",{query:{source_type:n.source_type,source_id:n.source_id,target_type:n.target_type,target_id:n.target_id,relation_type:n.relation_type,depth:n.depth}})}function Sr(n){return ut("/relation",{method:"POST",body:n})}function Zc(n){return ut(`/relation/${n}`,{method:"DELETE"})}function $w(n,o){return ut(`/relation/${n}`,{method:"PUT",body:{metadata:o}})}function Xw(n){return ut(`/delta/node/${n}`)}function Kw(n){return ut("/delta/compute",{method:"POST",body:n})}function Wm(n){return ut("/delta",{method:"POST",body:n})}function Qw(){return ut("/project/list")}function Zw(n,o){return ut("/project/create",{method:"POST",body:{path:n,...o!==void 0?{config:o}:{}}})}function Jw(n){return ut("/project/open",{method:"POST",body:{path:n}})}function Ww(){return ut("/project/close",{method:"POST"})}function e2(n){if(n!==null){const o=/filename\*\s*=\s*UTF-8''([^;]+)/i.exec(n);if(o)try{return decodeURIComponent(o[1])}catch{}const r=/filename\s*=\s*"?([^";]+)"?/i.exec(n);if(r)return r[1]}return"project.zip"}async function t2(){let n;try{n=await fetch(y0("/project/export"))}catch(r){throw new ze(ft,r instanceof Error?r.message:"网络请求失败")}const o=n.headers.get("content-type")??"";if(n.ok&&(o.includes("zip")||o.includes("octet-stream")))return{blob:await n.blob(),filename:e2(n.headers.get("content-disposition"))};if(o.includes("application/json")){const r=await n.json().catch(()=>null);if(v0(r))throw new ze(r.error.code,r.error.message)}throw new ze(ft,`非预期响应(HTTP ${n.status})`)}async function n2(n,o){const r=new FormData;return r.append("file",n,"backup.zip"),r.append("name",o),ut("/project/import",{method:"POST",body:r})}function s2(){return ut("/project/backups")}function o2(n){return ut("/project/backup",{method:"POST",...n!==void 0?{body:{name:n}}:{}})}function r2(n){return ut("/project/backup/restore",{method:"POST",body:{fileName:n}})}function a2(n,o){const r=o?.trim()??"";return ut("/project/backup/rename",{method:"POST",body:{fileName:n,name:r}})}function l2(n){return ut("/project/rename",{method:"POST",body:{name:n}})}function i2(){return ut("/settings/llm")}function If(n){return ut("/settings/llm",{method:"PUT",body:n})}function c2(){return ut("/chat/sessions").then(n=>n.sessions)}function u2(n){return ut(`/chat/sessions/${n}/messages`)}function d2(n){return ut(`/proposal/${n}/confirm`,{method:"POST"})}function f2(n){return ut(`/proposal/${n}/reject`,{method:"POST"})}const fm=3e3;let m2=0;const ke=Jm((n,o)=>({error:null,showError:(r,l)=>n({error:{code:r,message:l}}),clearError:()=>n({error:null}),toast:null,showToast:(r,l="success")=>{const c=++m2;n({toast:{id:c,kind:l,text:r}}),setTimeout(()=>{n(d=>d.toast?.id===c?{toast:null}:{})},fm)},clearToast:()=>n({toast:null}),confirmState:null,confirm:r=>new Promise(l=>{n({confirmState:{...r,resolve:l}})}),resolveConfirm:r=>{const l=o().confirmState;l&&(l.resolve(r),n({confirmState:null}))},focusOutlineNodeId:null,setFocusOutlineNode:r=>n({focusOutlineNodeId:r}),clearFocusOutlineNode:()=>n({focusOutlineNodeId:null}),dataVersion:0,notifyDataChanged:()=>n(r=>({dataVersion:r.dataVersion+1}))})),Be=Jm((n,o)=>({config:null,configLoading:!1,loadError:null,outline:null,outlineLoading:!1,bookshelf:null,bookshelfLoading:!1,bookshelfError:null,loadConfig:async()=>{if(!o().configLoading){n({configLoading:!0});try{const r=await Lw();n({config:r,loadError:null})}catch(r){const l=r instanceof ze?r.code:"CLIENT_NETWORK_ERROR";n({config:null,loadError:l})}finally{n({configLoading:!1})}}},updateConfig:async r=>{await Iw(r),await o().loadConfig()},loadOutline:async()=>{if(!o().outlineLoading){n({outlineLoading:!0});try{const r=await Bw();n({outline:r})}catch{n({outline:null})}finally{n({outlineLoading:!1})}}},loadBookshelf:async()=>{if(!o().bookshelfLoading){n({bookshelfLoading:!0});try{const r=await Qw();n({bookshelf:r,bookshelfError:null})}catch(r){const l=r instanceof ze?r.code:"CLIENT_NETWORK_ERROR";n({bookshelf:null,bookshelfError:l})}finally{n({bookshelfLoading:!1})}}},openProjectAt:async r=>{const l=await Jw(r);n({config:l.config,loadError:null}),ke.getState().clearFocusOutlineNode(),l.rebuilt?ke.getState().showToast(`项目已按新版本重建${l.fromVersion!==void 0?`(v${l.fromVersion})`:""},备份已保留`):l.migrated&&ke.getState().showToast(`项目数据已自动升级${l.fromVersion!==void 0?`(v${l.fromVersion} → 当前版本)`:""},快照已保留`),await o().loadOutline()},createProjectAt:async(r,l)=>{await Zw(r,l),await o().openProjectAt(r)},closeProject:async()=>{await Ww(),n({config:null,loadError:null,outline:null}),ke.getState().clearFocusOutlineNode()}}));function N0(n,o){if(n.id===o)return n;if("children"in n&&n.children)for(const r of n.children){const l=N0(r,o);if(l)return l}return null}function j0(n,o){if(!n||!o)return null;for(const r of n.children){const l=N0(r,o);if(l)return l.title}return null}function T0(n,o){return`${n.replace(/\/+$/,"")}/books/${o.trim()}`}const p2="[DONE]",h2=6e4;function g2(n){const o=[];let r=n,l;for(;(l=r.indexOf(`
10
+
11
+ `))!==-1;)o.push(r.slice(0,l)),r=r.slice(l+2);return{frames:o,rest:r}}function hy(n){let o="message";const r=[];for(const l of n.split(`
12
+ `))if(!(l===""||l.startsWith(":"))){if(l.startsWith("event:"))o=l.slice(6).trim();else if(l.startsWith("data:")){let c=l.slice(5);c.startsWith(" ")&&(c=c.slice(1)),r.push(c)}}return r.length===0?null:{event:o,data:r.join(`
13
+ `)}}function gy(n){if(typeof n!="object"||n===null)return!1;const o=n.error;return typeof o=="object"&&o!==null&&typeof o.code=="string"&&typeof o.message=="string"}function x2(n,o){const{onEvent:r,timeoutMs:l=h2,onTimeout:c,onEnd:d,signal:m,body:g}=o,b=new AbortController,p=()=>b.abort();m&&(m.aborted?b.abort():m.addEventListener("abort",p));let v="",x=!1,S=!1,j=!1,E=!1,M=null;const O=()=>{M!==null&&(clearTimeout(M),M=null)},N=()=>{O(),M=setTimeout(()=>{x||(S=!0,x=!0,c?.(),b.abort())},l)},T=k=>{if(k.data===p2)return!1;let C=k.data;try{C=JSON.parse(k.data)}catch{}return r(k.event,C),k.event!=="error"};return N(),(async()=>{try{const k=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:g===void 0?void 0:JSON.stringify(g),signal:b.signal});if(!k.ok||!k.body){const A=await k.json().catch(()=>null),L=gy(A)?A.error.code:ft,_=gy(A)?A.error.message:`SSE 请求失败(HTTP ${k.status})`;x=!0,E=!0,r("error",{code:L,message:_});return}const C=k.body.getReader(),U=new TextDecoder;for(;!x;){const{done:A,value:L}=await C.read();if(A)break;v=(v+U.decode(L,{stream:!0})).replace(/\r\n/g,`
14
+ `);const{frames:_,rest:K}=g2(v);v=K;for(const W of _){const ue=hy(W);if(ue){if(!T(ue)){x=!0;break}N()}}}if(!x&&v.trim()!==""){const A=hy(v.trim());A&&!T(A)&&(x=!0)}}catch{!S&&!j&&(x=!0,E=!0,r("error",{code:ft,message:"网络请求失败"}))}finally{O(),m&&m.removeEventListener("abort",p),x=!0,!S&&!j&&!E&&d?.()}})(),()=>{x||(j=!0,x=!0,O(),b.abort())}}function b2(n,o){return o.includes("HTTP 404")?"聊天服务暂不可用":n==="CLIENT_NETWORK_ERROR"&&!o.includes("HTTP ")?"连接失败,请确认服务已启动":o}function y2(n,o){switch(n){case"INTERNAL_ERROR":return"提案执行失败,请让 AI 重新生成提案";case"CLIENT_NETWORK_ERROR":return"网络请求失败,请重试";default:return o}}let ga=0,xa=0,xy=0,dr=null,Ss=null,ba=null;const Nt=Jm((n,o)=>{const r=async(l,c,d)=>{const m=o().proposals.find(g=>g.proposalId===l);if(!(!m||m.status!=="pending"||m.processing===!0)){n(g=>({proposals:g.proposals.map(b=>b.proposalId===l?{...b,processing:!0}:b)}));try{await c(l),n(g=>({proposals:g.proposals.map(b=>b.proposalId===l?{...b,status:d,processing:!1}:b)})),d==="confirmed"&&ke.getState().notifyDataChanged()}catch(g){const b=g instanceof ze?g.code:"CLIENT_NETWORK_ERROR",p=g instanceof Error?g.message:"网络请求失败";switch(b){case"PROPOSAL_STALE":n(v=>({proposals:v.proposals.map(x=>x.proposalId===l?{...x,status:"stale",processing:!1}:x)}));return;case"PROPOSAL_NOT_FOUND":case"PROPOSAL_PROJECT_MISMATCH":n(v=>({proposals:v.proposals.filter(x=>x.proposalId!==l)}));return;default:ke.getState().showToast(y2(b,p),"error"),n(v=>({proposals:v.proposals.map(x=>x.proposalId===l?{...x,processing:!1}:x)}));return}}}};return{sessions:null,sessionsLoading:!1,sessionsError:null,currentSessionId:null,messages:[],messagesLoading:!1,loadSessions:async()=>{if(o().sessionsLoading)return;const l=++ga;n({sessionsLoading:!0});try{const c=await c2();if(l!==ga)return;n({sessions:c,sessionsError:null}),o().currentSessionId===null&&c.length>0&&o().setCurrentSession(c[0].id)}catch(c){if(l!==ga)return;const d=c instanceof ze?c.code:"CLIENT_NETWORK_ERROR";n({sessions:null,sessionsError:d})}finally{l===ga&&n({sessionsLoading:!1})}},setCurrentSession:l=>{l!==o().currentSessionId&&(xa++,dr?.(),dr=null,Ss=null,ba=null,n({currentSessionId:l,messages:[],messagesLoading:!1,streaming:!1,streamError:null,disconnected:!1,focusContext:null,proposals:[],streamTools:[]}),l!==null&&o().loadMessages(l))},newSession:()=>{ga++,o().setCurrentSession(null)},clearSessions:()=>{ga++,xa++,dr?.(),dr=null,Ss=null,ba=null,n({sessions:null,sessionsLoading:!1,sessionsError:null,currentSessionId:null,messages:[],messagesLoading:!1,streaming:!1,streamError:null,disconnected:!1,focusContext:null,proposals:[],streamTools:[]})},loadMessages:async l=>{const c=++xa;n({messagesLoading:!0});try{const d=await u2(l);if(c!==xa)return;const m=d.messages.map(g=>({...g,sessionId:d.sessionId}));n({messages:m})}catch{if(c!==xa)return;n({messages:[]})}finally{c===xa&&n({messagesLoading:!1})}},streaming:!1,streamError:null,setStreamError:l=>n({streamError:l}),focusContext:null,setFocusContext:l=>n({focusContext:l}),clearFocusContext:()=>n({focusContext:null}),disconnected:!1,setDisconnected:l=>n({disconnected:l}),proposals:[],streamTools:[],sendMessage:l=>{const{streaming:c,messagesLoading:d,currentSessionId:m,focusContext:g}=o(),b=l.trim();if(!b||c||d)return;dr?.(),dr=null;const p=new Date().toISOString(),v=m??"",x=`local-${++xy}`;Ss=x,ba=b,n(j=>({messages:[...j.messages,{id:`local-${++xy}`,sessionId:v,role:"user",content:b,createdAt:p},{id:x,sessionId:v,role:"assistant",content:"",createdAt:p}],streaming:!0,streamError:null,disconnected:!1,proposals:[],streamTools:[]}));const S={message:b};m&&(S.session_id=m),g&&(S.context=g),dr=x2("/api/v1/chat",{body:S,onEvent:(j,E)=>{switch(j){case"ping":break;case"text":{const M=E?.delta??"";Ss&&n(O=>({messages:O.messages.map(N=>N.id===Ss?{...N,content:(N.content??"")+M}:N)}));break}case"tool_call":{const{tool:M,args:O,id:N}=E;if(!N||!M)break;n(T=>({streamTools:[...T.streamTools,{id:N,tool:M,args:O,status:"running"}]}));break}case"tool_result":{const{id:M}=E;if(!M)break;n(O=>({streamTools:O.streamTools.map(N=>N.id===M?{...N,result:E.result,status:"ok"}:N)}));break}case"proposal":{const{proposal_id:M,type:O,preview:N}=E;if(!M||!O)break;n(T=>({proposals:[...T.proposals,{proposalId:M,type:O,preview:N,status:"pending"}]}));break}case"done":{if(Ss===null)break;const M=E?.session_id;n({streaming:!1,currentSessionId:M??o().currentSessionId}),M&&o().loadSessions();break}case"error":{const{code:M,message:O}=E;n({streaming:!1,streamError:b2(M??"",O??"")});break}}},onTimeout:()=>{Ss===x&&(Ss=null,n({streaming:!1,disconnected:!0,proposals:[],streamTools:[]}))},onEnd:()=>{Ss===x&&(Ss=null,n(j=>j.streaming?{streaming:!1}:{}))}})},resendLast:()=>{const{messages:l,streaming:c}=o();if(c||!ba)return;let d=l;d[d.length-1]?.role==="assistant"&&(d=d.slice(0,-1));const g=d[d.length-1];g?.role==="user"&&g.content===ba&&(d=d.slice(0,-1)),n({messages:d}),o().sendMessage(ba)},confirmProposal:l=>r(l,d2,"confirmed"),rejectProposal:l=>r(l,f2,"rejected")}});let by=Be.getState().config?.id??null;Be.subscribe(n=>{const o=n.config?.id??null;o!==by&&(by=o,Nt.getState().clearSessions(),o!==null&&Nt.getState().loadSessions())});function Jc(){return typeof window<"u"}function yn(n){return ep(n)?(n.nodeName||"").toLowerCase():"#document"}function Xt(n){var o;return(n==null||(o=n.ownerDocument)==null?void 0:o.defaultView)||window}function uo(n){var o;return(o=(ep(n)?n.ownerDocument:n.document)||window.document)==null?void 0:o.documentElement}function ep(n){return Jc()?n instanceof Node||n instanceof Xt(n).Node:!1}function Et(n){return Jc()?n instanceof Element||n instanceof Xt(n).Element:!1}function Ht(n){return Jc()?n instanceof HTMLElement||n instanceof Xt(n).HTMLElement:!1}function Ra(n){return!Jc()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Xt(n).ShadowRoot}function Cr(n){const{overflow:o,overflowX:r,overflowY:l,display:c}=Gn(n);return/auto|scroll|overlay|hidden|clip/.test(o+l+r)&&c!=="inline"&&c!=="contents"}function v2(n){return/^(table|td|th)$/.test(yn(n))}function Wc(n){try{if(n.matches(":popover-open"))return!0}catch{}try{return n.matches(":modal")}catch{return!1}}const S2=/transform|translate|scale|rotate|perspective|filter/,E2=/paint|layout|strict|content/,fr=n=>!!n&&n!=="none";let Bf;function tp(n){const o=Et(n)?Gn(n):n;return fr(o.transform)||fr(o.translate)||fr(o.scale)||fr(o.rotate)||fr(o.perspective)||!np()&&(fr(o.backdropFilter)||fr(o.filter))||S2.test(o.willChange||"")||E2.test(o.contain||"")}function N2(n){let o=lo(n);for(;Ht(o)&&!no(o);){if(tp(o))return o;if(Wc(o))return null;o=lo(o)}return null}function np(){return Bf==null&&(Bf=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Bf}function no(n){return/^(html|body|#document)$/.test(yn(n))}function Gn(n){return Xt(n).getComputedStyle(n)}function eu(n){return Et(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function lo(n){if(yn(n)==="html")return n;const o=n.assignedSlot||n.parentNode||Ra(n)&&n.host||uo(n);return Ra(o)?o.host:o}function w0(n){const o=lo(n);return no(o)?(n.ownerDocument||n).body:Ht(o)&&Cr(o)?o:w0(o)}function Yl(n,o,r){var l;o===void 0&&(o=[]),r===void 0&&(r=!0);const c=w0(n),d=c===((l=n.ownerDocument)==null?void 0:l.body),m=Xt(c);if(d){const g=mm(m);return o.concat(m,m.visualViewport||[],Cr(c)?c:[],g&&r?Yl(g):[])}else return o.concat(c,Yl(c,[],r))}function mm(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}const sp={...ej},yy={};function zn(n,o){const r=h.useRef(yy);return r.current===yy&&(r.current=n(o)),r}const Uf=sp.useInsertionEffect,j2=Uf&&Uf!==sp.useLayoutEffect?Uf:n=>n();function at(n){const o=zn(T2).current;return o.next=n,j2(o.effect),o.trampoline}function T2(){const n={next:void 0,callback:w2,trampoline:(...o)=>n.callback?.(...o),effect:()=>{n.callback=n.next}};return n}function w2(){}const C2=()=>{},Qe=typeof document<"u"?h.useLayoutEffect:C2;function pm(n,o){if(n&&!o)return n;if(!n&&o)return o;if(n||o)return{...n,...o}}const op={};function so(n,o,r,l,c){if(!r&&!l&&!c&&!n)return Uc(o);let d=Uc(n);return o&&(d=_l(d,o)),r&&(d=_l(d,r)),l&&(d=_l(d,l)),c&&(d=_l(d,c)),d}function R2(n){if(n.length===0)return op;if(n.length===1)return Uc(n[0]);let o=Uc(n[0]);for(let r=1;r<n.length;r+=1)o=_l(o,n[r]);return o}function Uc(n){return rp(n)?{...R0(n,op)}:O2(n)}function _l(n,o){return rp(o)?R0(o,n):k2(n,o)}function O2(n){const o={...n};for(const r in o){const l=o[r];C0(r,l)&&(o[r]=O0(l))}return o}function k2(n,o){if(!o)return n;for(const r in o){const l=o[r];switch(r){case"style":{n[r]=pm(n.style,l);break}case"className":{n[r]=k0(n.className,l);break}default:C0(r,l)?n[r]=_2(n[r],l):n[r]=l}}return n}function C0(n,o){const r=n.charCodeAt(0),l=n.charCodeAt(1),c=n.charCodeAt(2);return r===111&&l===110&&c>=65&&c<=90&&(typeof o=="function"||typeof o>"u")}function rp(n){return typeof n=="function"}function R0(n,o){return rp(n)?n(o):n??op}function _2(n,o){return o?n?(...r)=>{const l=r[0];if(_0(l)){const d=l;Hc(d);const m=o(...r);return d.baseUIHandlerPrevented||n?.(...r),m}const c=o(...r);return n?.(...r),c}:O0(o):n}function O0(n){return n&&((...o)=>{const r=o[0];return _0(r)&&Hc(r),n(...o)})}function Hc(n){return n.preventBaseUIHandler=()=>{n.baseUIHandlerPrevented=!0},n}function k0(n,o){return o?n?o+" "+n:o:n}function _0(n){return n!=null&&typeof n=="object"&&"nativeEvent"in n}function M2(n,o){return function(l,...c){const d=new URL(n);return d.searchParams.set("code",l.toString()),c.forEach(m=>d.searchParams.append("args[]",m)),`${o} error #${l}; visit ${d} for the full message.`}}const En=M2("https://base-ui.com/production-error","Base UI"),A2=h.createContext(void 0);function ap(n=!1){const o=h.useContext(A2);if(o===void 0&&!n)throw new Error(En(16));return o}function D2(n){const{focusableWhenDisabled:o,disabled:r,composite:l=!1,tabIndex:c=0,isNativeButton:d}=n,m=l&&o!==!1,g=l&&o===!1;return{props:h.useMemo(()=>{const p={onKeyDown(v){r&&o&&v.key!=="Tab"&&v.preventDefault()}};return l||(p.tabIndex=c,!d&&r&&(p.tabIndex=o?c:-1)),(d&&(o||m)||!d&&r)&&(p["aria-disabled"]=r),d&&(!o||g)&&(p.disabled=r),p},[l,r,o,m,g,d,c])}}function Kl(n={}){const{disabled:o=!1,focusableWhenDisabled:r,tabIndex:l=0,native:c=!0,composite:d}=n,m=h.useRef(null),g=ap(!0),b=d??g!==void 0,{props:p}=D2({focusableWhenDisabled:r,disabled:o,composite:b,tabIndex:l,isNativeButton:c}),v=h.useCallback(()=>{const j=m.current;Hf(j)&&b&&o&&p.disabled===void 0&&j.disabled&&(j.disabled=!1)},[o,p.disabled,b]);Qe(v,[v]);const x=h.useCallback((j={})=>{const{onClick:E,onMouseDown:M,onKeyUp:O,onKeyDown:N,onPointerDown:T,...k}=j;return so({onClick(C){if(o){C.preventDefault();return}E?.(C)},onMouseDown(C){o||M?.(C)},onKeyDown(C){if(o||(Hc(C),N?.(C),C.baseUIHandlerPrevented))return;const U=C.target===C.currentTarget,A=C.currentTarget,L=Hf(A),_=!c&&z2(A),K=U&&(c?L:!_),W=C.key==="Enter",ue=C.key===" ",ne=A.getAttribute("role"),$=ne?.startsWith("menuitem")||ne==="option"||ne==="gridcell";if(U&&b&&ue){if(C.defaultPrevented&&$)return;C.preventDefault(),_||c&&L?(A.click(),C.preventBaseUIHandler()):K&&(E?.(C),C.preventBaseUIHandler());return}K&&(!c&&(ue||W)&&C.preventDefault(),!c&&W&&E?.(C))},onKeyUp(C){if(!o){if(Hc(C),O?.(C),C.target===C.currentTarget&&c&&b&&Hf(C.currentTarget)&&C.key===" "){C.preventDefault();return}C.baseUIHandlerPrevented||C.target===C.currentTarget&&!c&&!b&&C.key===" "&&E?.(C)}},onPointerDown(C){if(o){C.preventDefault();return}T?.(C)}},c?{type:"button"}:{role:"button"},p,k)},[o,p,b,c]),S=at(j=>{m.current=j,v()});return{getButtonProps:x,buttonRef:S}}function Hf(n){return Ht(n)&&n.tagName==="BUTTON"}function z2(n){return!!(n?.tagName==="A"&&n?.href)}function Oa(n,o,r,l){const c=zn(M0).current;return I2(c,n,o,r,l)&&A0(c,[n,o,r,l]),c.callback}function L2(n){const o=zn(M0).current;return B2(o,n)&&A0(o,n),o.callback}function M0(){return{callback:null,cleanup:null,refs:[]}}function I2(n,o,r,l,c){return n.refs[0]!==o||n.refs[1]!==r||n.refs[2]!==l||n.refs[3]!==c}function B2(n,o){return n.refs.length!==o.length||n.refs.some((r,l)=>r!==o[l])}function A0(n,o){if(n.refs=o,o.every(r=>r==null)){n.callback=null;return}n.callback=r=>{if(n.cleanup&&(n.cleanup(),n.cleanup=null),r!=null){const l=Array(o.length).fill(null);for(let c=0;c<o.length;c+=1){const d=o[c];if(d!=null)switch(typeof d){case"function":{const m=d(r);typeof m=="function"&&(l[c]=m);break}case"object":{d.current=r;break}}}n.cleanup=()=>{for(let c=0;c<o.length;c+=1){const d=o[c];if(d!=null)switch(typeof d){case"function":{const m=l[c];typeof m=="function"?m():d(null);break}case"object":{d.current=null;break}}}}}}}const U2=parseInt(h.version,10);function lp(n){return U2>=n}function vy(n){if(!h.isValidElement(n))return null;const o=n,r=o.props;return(lp(19)?r?.ref:o.ref)??null}function dn(){}const Pc=Object.freeze([]),Pt=Object.freeze({});function H2(n,o){const r={};for(const l in n){const c=n[l];if(o?.hasOwnProperty(l)){const d=o[l](c);d!=null&&Object.assign(r,d);continue}c===!0?r[`data-${l.toLowerCase()}`]="":c&&(r[`data-${l.toLowerCase()}`]=c.toString())}return r}function P2(n,o){return typeof n=="function"?n(o):n}function Y2(n,o){return typeof n=="function"?n(o):n}function mn(n,o,r={}){const l=o.render,c=V2(o,r);if(r.enabled===!1)return null;const d=r.state??Pt;return q2(n,l,c,d)}function V2(n,o={}){const{className:r,style:l,render:c}=n,{state:d=Pt,ref:m,props:g,stateAttributesMapping:b,enabled:p=!0}=o,v=p?P2(r,d):void 0,x=p?Y2(l,d):void 0,S=p?H2(d,b):Pt,j=p&&g?F2(g):void 0,E=p?pm(S,j)??{}:Pt;return typeof document<"u"&&(p?Array.isArray(m)?E.ref=L2([E.ref,vy(c),...m]):E.ref=Oa(E.ref,vy(c),m):Oa(null,null)),p?(v!==void 0&&(E.className=k0(E.className,v)),x!==void 0&&(E.style=pm(E.style,x)),E):Pt}function F2(n){return Array.isArray(n)?R2(n):so(void 0,n)}const G2=Symbol.for("react.lazy");function q2(n,o,r,l){if(o){if(typeof o=="function")return o(r,l);const c=so(r,o.props);c.ref=r.ref;let d=o;return d?.$$typeof===G2&&(d=h.Children.toArray(o)[0]),h.cloneElement(d,c)}if(n&&typeof n=="string")return $2(n,r);throw new Error(En(8))}function $2(n,o){return n==="button"?h.createElement("button",{type:"button",...o,key:o.key}):n==="img"?h.createElement("img",{alt:"",...o,key:o.key}):h.createElement(n,o)}const X2=h.forwardRef(function(o,r){const{render:l,className:c,disabled:d=!1,focusableWhenDisabled:m=!1,nativeButton:g=!0,style:b,...p}=o,{getButtonProps:v,buttonRef:x}=Kl({disabled:d,focusableWhenDisabled:m,native:g});return mn("button",o,{state:{disabled:d},ref:[r,x],props:[p,v]})}),Sy=n=>typeof n=="boolean"?`${n}`:n===0?"0":n,Ey=o0,K2=(n,o)=>r=>{var l;if(o?.variants==null)return Ey(n,r?.class,r?.className);const{variants:c,defaultVariants:d}=o,m=Object.keys(c).map(p=>{const v=r?.[p],x=d?.[p];if(v===null)return null;const S=Sy(v)||Sy(x);return c[p][S]}),g=r&&Object.entries(r).reduce((p,v)=>{let[x,S]=v;return S===void 0||(p[x]=S),p},{}),b=o==null||(l=o.compoundVariants)===null||l===void 0?void 0:l.reduce((p,v)=>{let{class:x,className:S,...j}=v;return Object.entries(j).every(E=>{let[M,O]=E;return Array.isArray(O)?O.includes({...d,...g}[M]):{...d,...g}[M]===O})?[...p,x,S]:p},[]);return Ey(n,m,b,r?.class,r?.className)},hm=K2("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function he({className:n,variant:o="default",size:r="default",...l}){return i.jsx(X2,{"data-slot":"button",className:Ze(hm({variant:o,size:r,className:n})),...l})}const D0=h.createContext(void 0);function z0(n){const o=h.useContext(D0);if(o===void 0&&!n)throw new Error(En(33));return o}const L0=h.createContext(void 0);function Rr(n){const o=h.useContext(L0);if(o===void 0&&!n)throw new Error(En(36));return o}let Vl=(function(n){return n.startingStyle="data-starting-style",n.endingStyle="data-ending-style",n})({});const Q2={[Vl.startingStyle]:""},Z2={[Vl.endingStyle]:""},tu={transitionStatus(n){return n==="starting"?Q2:n==="ending"?Z2:null}};let hr=(function(n){return n.open="data-open",n.closed="data-closed",n[n.startingStyle=Vl.startingStyle]="startingStyle",n[n.endingStyle=Vl.endingStyle]="endingStyle",n.anchorHidden="data-anchor-hidden",n.side="data-side",n.align="data-align",n})({}),gm=(function(n){return n.popupOpen="data-popup-open",n.pressed="data-pressed",n})({});const J2={[gm.popupOpen]:""},W2={[gm.popupOpen]:"",[gm.pressed]:""},eC={[hr.open]:""},tC={[hr.closed]:""},nC={[hr.anchorHidden]:""},sC={open(n){return n?J2:null}},xm={open(n){return n?W2:null}},Ql={open(n){return n?eC:tC},anchorHidden(n){return n?nC:null}},oC=h.createContext(void 0);function nu(n=!0){const o=h.useContext(oC);if(o===void 0&&!n)throw new Error(En(25));return o}const I0="none",Er="trigger-press",fn="trigger-hover",Dl="trigger-focus",ip="outside-press",B0="item-press",U0="close-press",Nr="focus-out",su="escape-key",bm="list-navigation",rC="cancel-open",Ml="sibling-open",cp="imperative-action";function aC({controlled:n,default:o,name:r,state:l="value"}){const{current:c}=h.useRef(n!==void 0),[d,m]=h.useState(o),g=c?n:d,b=h.useCallback(p=>{c||m(p)},[]);return[g,b]}function lC(){return typeof navigator>"u"?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:iC,platform:cC,maxTouchPoints:uC}=lC(),ou=iC.toLowerCase(),Fl=cC.toLowerCase(),ru=/^i(os$|p)/.test(Fl)||Fl==="macintel"&&uC>1,Ny="android",ym=Fl===Ny||ou.includes(Ny),up=!ru&&Fl.startsWith("mac");Fl.startsWith("win");const dC=up||ru,Or=typeof CSS<"u"&&!!CSS.supports?.("-webkit-backdrop-filter:none");!Or&&ou.includes("firefox");!Or&&ou.includes("chrom");const fC=dC,dp=/jsdom|happydom/.test(ou);function mC(n){const{closeOnClick:o,highlighted:r,id:l,nodeId:c,store:d,typingRef:m,itemRef:g,itemMetadata:b}=n,{events:p}=d.useState("floatingTreeRoot"),v=d.useState("open"),x=nu(!0),S=x!==void 0;return h.useMemo(()=>({id:l,role:"menuitem",tabIndex:v&&r?0:-1,onKeyDown(j){j.key===" "&&m?.current&&j.preventDefault()},onMouseMove(j){c&&p.emit("itemhover",{nodeId:c,target:j.currentTarget})},onClick(j){o&&p.emit("close",{domEvent:j,reason:B0})},onMouseUp(j){if(x){const E=x.initialCursorPointRef.current;if(x.initialCursorPointRef.current=null,S&&E&&Math.abs(j.clientX-E.x)<=1&&Math.abs(j.clientY-E.y)<=1||S&&!up&&j.button===2)return}g.current&&d.context.allowMouseUpTriggerRef.current&&(!S||j.button===2)&&(!b||b.type==="regular-item")&&g.current.click()}}),[o,r,l,p,c,v,d,m,g,x,S,b])}const pC={type:"regular-item"};function hC(n){const{closeOnClick:o,disabled:r=!1,highlighted:l,id:c,store:d,typingRef:m=d.context.typingRef,nativeButton:g,itemMetadata:b,nodeId:p}=n,v=d.useState("disabled"),x=r||v,S=h.useRef(null),{getButtonProps:j,buttonRef:E}=Kl({disabled:x,focusableWhenDisabled:!0,native:g,composite:!0}),M=mC({closeOnClick:o,highlighted:l,id:c,nodeId:p,store:d,typingRef:m,itemRef:S,itemMetadata:b}),O=h.useCallback(T=>so(M,{onMouseEnter(){b.type==="submenu-trigger"&&b.setActive()}},T,j),[M,j,b]),N=Oa(S,E);return h.useMemo(()=>({getItemProps:O,itemRef:N}),[O,N])}const H0=h.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function gC(){return h.useContext(H0)}let xC=(function(n){return n[n.None=0]="None",n[n.GuessFromOrder=1]="GuessFromOrder",n})({});function P0(n={}){const{label:o,metadata:r,textRef:l,indexGuessBehavior:c,index:d}=n,{register:m,unregister:g,subscribeMapChange:b,elementsRef:p,labelsRef:v,nextIndexRef:x}=gC(),S=h.useRef(-1),[j,E]=h.useState(d??(c===xC.GuessFromOrder?()=>{if(S.current===-1){const N=x.current;x.current+=1,S.current=N}return S.current}:-1)),M=h.useRef(null),O=h.useCallback(N=>{if(M.current=N,j!==-1&&N!==null&&(p.current[j]=N,v)){const T=o!==void 0;v.current[j]=T?o:l?.current?.textContent??N.textContent}},[j,p,v,o,l]);return Qe(()=>{if(d!=null)return;const N=M.current;if(N)return m(N,r),()=>{g(N)}},[d,m,g,r]),Qe(()=>{if(d==null)return b(N=>{const T=M.current?N.get(M.current)?.index:null;T!=null&&E(T)})},[d,b,E]),{ref:O,index:j}}let jy=0;function bC(n,o="mui"){const[r,l]=h.useState(n),c=n||r;return h.useEffect(()=>{r==null&&(jy+=1,l(`${o}-${jy}`))},[r,o]),c}const Ty=sp.useId;function jr(n,o){if(Ty!==void 0){const r=Ty();return n??(o?`${o}-${r}`:r)}return bC(n,o)}function kr(n){return jr(n,"base-ui")}function Ct(n,o,r,l){let c=!1,d=!1;const m=Pt;return{reason:n,event:o??new Event("base-ui"),cancel(){c=!0},allowPropagation(){d=!0},get isCanceled(){return c},get isPropagationAllowed(){return d},trigger:r,...m}}const yC=[];function fp(n){h.useEffect(n,yC)}const gc=null;class vC{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=o=>{this.isScheduled=!1;const r=this.callbacks,l=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,l>0)for(let c=0;c<r.length;c+=1)r[c]?.(o)};request(o){const r=this.nextId;return this.nextId+=1,this.callbacks.push(o),this.callbacksCount+=1,!this.isScheduled&&(requestAnimationFrame(this.tick),this.isScheduled=!0),r}cancel(o){const r=o-this.startId;r<0||r>=this.callbacks.length||(this.callbacks[r]=null,this.callbacksCount-=1)}}const xc=new vC;class js{static create(){return new js}static request(o){return xc.request(o)}static cancel(o){return xc.cancel(o)}currentId=gc;request(o){this.cancel(),this.currentId=xc.request(()=>{this.currentId=gc,o()})}cancel=()=>{this.currentId!==gc&&(xc.cancel(this.currentId),this.currentId=gc)};disposeEffect=()=>this.cancel}function Gl(){const n=zn(js.create).current;return fp(n.disposeEffect),n}function SC(n,o=!1,r=!1){const[l,c]=h.useState(n&&o?"idle":void 0),[d,m]=h.useState(n);return n&&!d&&(m(!0),c("starting")),!n&&d&&l!=="ending"&&!r&&c("ending"),!n&&!d&&l==="ending"&&c(void 0),Qe(()=>{if(!n&&d&&l!=="ending"&&r){const g=js.request(()=>{c("ending")});return()=>{js.cancel(g)}}},[n,d,l,r]),Qe(()=>{if(!n||o)return;const g=js.request(()=>{c(void 0)});return()=>{js.cancel(g)}},[o,n]),Qe(()=>{if(!n||!o)return;n&&d&&l!=="idle"&&c("starting");const g=js.request(()=>{c("idle")});return()=>{js.cancel(g)}},[o,n,d,l]),{mounted:d,setMounted:m,transitionStatus:l}}var io=Qv();const EC=Kv(io);function to(n){return n==null?n:"current"in n?n.current:n}function mp(n,o=!1,r=!0){const l=Gl();return at((c,d=null)=>{l.cancel();const m=to(n);if(m==null)return;const g=m,b=()=>{io.flushSync(c)};if(typeof g.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){c();return}function p(){Promise.all(g.getAnimations().map(v=>v.finished)).then(()=>{d?.aborted||b()}).catch(()=>{if(r){d?.aborted||b();return}const v=g.getAnimations();!d?.aborted&&v.length>0&&v.some(x=>x.pending||x.playState!=="finished")&&p()})}if(o){const v=Vl.startingStyle;if(!g.hasAttribute(v)){l.request(p);return}const x=new MutationObserver(()=>{g.hasAttribute(v)||(x.disconnect(),p())});x.observe(g,{attributes:!0,attributeFilter:[v]}),d?.addEventListener("abort",()=>x.disconnect(),{once:!0});return}l.request(p)})}function au(n){const{enabled:o=!0,open:r,ref:l,onComplete:c}=n,d=at(c),m=mp(l,r,!1);h.useEffect(()=>{if(!o)return;const g=new AbortController;return m(d,g.signal),()=>{g.abort()}},[o,r,d,m])}const Y0=h.createContext(void 0);function NC(){const n=h.useContext(Y0);if(n===void 0)throw new Error(En(31));return n}const jC=h.forwardRef(function(o,r){const{render:l,className:c,style:d,...m}=o,[g,b]=h.useState(void 0),p=mn("div",o,{ref:r,props:{role:"group","aria-labelledby":g,...m}});return i.jsx(Y0.Provider,{value:b,children:p})}),TC=h.forwardRef(function(o,r){const{render:l,className:c,style:d,id:m,...g}=o,b=kr(m),p=NC();return Qe(()=>(p(b),()=>{p(void 0)}),[p,b]),mn("div",o,{ref:r,props:{id:b,role:"presentation",...g}})}),wC=h.forwardRef(function(o,r){const{render:l,className:c,id:d,label:m,nativeButton:g=!1,disabled:b=!1,closeOnClick:p=!0,style:v,...x}=o,S=P0({label:m}),j=z0(!0),E=kr(d),{store:M}=Rr(),O=M.useState("isActive",S.index),N=M.useState("itemProps"),{getItemProps:T,itemRef:k}=hC({closeOnClick:p,disabled:b,highlighted:O,id:E,store:M,nativeButton:g,nodeId:j?.context.nodeId,itemMetadata:pC});return mn("div",o,{state:{disabled:b,highlighted:O},props:[N,x,T],ref:[k,r,S.ref]})}),Nl=0;class ms{static create(){return new ms}currentId=Nl;start(o,r){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Nl,r()},o)}isStarted(){return this.currentId!==Nl}clear=()=>{this.currentId!==Nl&&(clearTimeout(this.currentId),this.currentId=Nl)};disposeEffect=()=>this.clear}function qn(){const n=zn(ms.create).current;return fp(n.disposeEffect),n}function Ns(n){n.preventDefault(),n.stopPropagation()}function CC(n){return"nativeEvent"in n}function V0(n){return n.pointerType===""&&n.isTrusted?!0:ym&&n.pointerType?n.type==="click"&&n.buttons===1:n.detail===0&&!n.pointerType}function F0(n){return dp?!1:!ym&&n.width===0&&n.height===0||ym&&n.width===1&&n.height===1&&n.pressure===0&&n.detail===0&&n.pointerType==="mouse"||n.width<1&&n.height<1&&n.pressure===0&&n.detail===0&&n.pointerType==="touch"}function ql(n,o){const r=["mouse","pen"];return o||r.push("",void 0),r.includes(n)}function RC(n){const o=n.type;return o==="click"||o==="mousedown"||o==="keydown"||o==="keyup"}const vm="data-base-ui-focusable",G0="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",lu="ArrowLeft",iu="ArrowRight",q0="ArrowUp",pp="ArrowDown";function jn(n){let o=n.activeElement;for(;o?.shadowRoot?.activeElement!=null;)o=o.shadowRoot.activeElement;return o}function ot(n,o){if(!n||!o)return!1;const r=o.getRootNode?.();if(n.contains(o))return!0;if(r&&Ra(r)){let l=o;for(;l;){if(n===l)return!0;l=l.parentNode||l.host}}return!1}function Dn(n){return"composedPath"in n?n.composedPath()[0]:n.target}function Yc(n,o){if(!Et(n))return!1;const r=n;if(o.hasElement(r))return!r.hasAttribute("data-trigger-disabled");for(const[,l]of o.entries())if(ot(l,r))return!l.hasAttribute("data-trigger-disabled");return!1}function Pf(n,o){if(o==null)return!1;if("composedPath"in n)return n.composedPath().includes(o);const r=n;return r.target!=null&&o.contains(r.target)}function OC(n){return n.matches("html,body")}function cu(n){return Ht(n)&&n.matches(G0)}function kC(n){return n?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${G0}`)!=null}function Sm(n){return n?n.getAttribute("role")==="combobox"&&cu(n):!1}function _C(n){if(!n||dp)return!0;try{return n.matches(":focus-visible")}catch{return!0}}function Em(n){return n?n.hasAttribute(vm)?n:n.querySelector(`[${vm}]`)||n:null}function MC(n,o){return o!=null&&!ql(o)?0:typeof n=="function"?n():n}function Nm(n,o,r){const l=MC(n,r);return typeof l=="number"?l:l?.[o]}function wy(n){return typeof n=="function"?n():n}function $0(n,o){return o||n==="click"||n==="mousedown"}function AC(n){return n?.includes("mouse")&&n!=="mousedown"}function yt(n,o,r,l){return n.addEventListener(o,r,l),()=>{n.removeEventListener(o,r,l)}}function Ms(...n){return()=>{for(let o=0;o<n.length;o+=1){const r=n[o];r&&r()}}}function an(n){const o=zn(DC,n).current;return o.next=n,Qe(o.effect),o}function DC(n){const o={current:n,next:n,effect:()=>{o.current=o.next}};return o}function wt(n){return n?.ownerDocument||document}const zC={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},LC={...zC,position:"fixed",top:0,left:0},Yo=h.forwardRef(function(o,r){const[l,c]=h.useState();Qe(()=>{fC&&Or&&c("button")},[]);const d={tabIndex:0,role:l};return i.jsx("span",{...o,ref:r,style:LC,"aria-hidden":l?void 0:!0,...d,"data-base-ui-focus-guard":""})}),IC=["top","right","bottom","left"],ka=Math.min,oo=Math.max,Vc=Math.round,bc=Math.floor,ro=n=>({x:n,y:n}),BC={left:"right",right:"left",bottom:"top",top:"bottom"};function X0(n,o,r){return oo(n,ka(o,r))}function co(n,o){return typeof n=="function"?n(o):n}function Fn(n){return n.split("-")[0]}function Go(n){return n.split("-")[1]}function hp(n){return n==="x"?"y":"x"}function gp(n){return n==="y"?"height":"width"}function as(n){const o=n[0];return o==="t"||o==="b"?"y":"x"}function xp(n){return hp(as(n))}function UC(n,o,r){r===void 0&&(r=!1);const l=Go(n),c=xp(n),d=gp(c);let m=c==="x"?l===(r?"end":"start")?"right":"left":l==="start"?"bottom":"top";return o.reference[d]>o.floating[d]&&(m=Fc(m)),[m,Fc(m)]}function HC(n){const o=Fc(n);return[jm(n),o,jm(o)]}function jm(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}const Cy=["left","right"],Ry=["right","left"],PC=["top","bottom"],YC=["bottom","top"];function VC(n,o,r){switch(n){case"top":case"bottom":return r?o?Ry:Cy:o?Cy:Ry;case"left":case"right":return o?PC:YC;default:return[]}}function FC(n,o,r,l){const c=Go(n);let d=VC(Fn(n),r==="start",l);return c&&(d=d.map(m=>m+"-"+c),o&&(d=d.concat(d.map(jm)))),d}function Fc(n){const o=Fn(n);return BC[o]+n.slice(o.length)}function GC(n){var o,r,l,c;return{top:(o=n.top)!=null?o:0,right:(r=n.right)!=null?r:0,bottom:(l=n.bottom)!=null?l:0,left:(c=n.left)!=null?c:0}}function K0(n){return typeof n!="number"?GC(n):{top:n,right:n,bottom:n,left:n}}function Gc(n){const{x:o,y:r,width:l,height:c}=n;return{width:l,height:c,top:r,left:o,right:o+l,bottom:r+c,x:o,y:r}}function Oy(n,o){return o<0||o>=n.length}function Yf(n,o){return ja(n.current,{disabledIndices:o})}function ky(n,o){return ja(n.current,{decrement:!0,startingIndex:n.current.length,disabledIndices:o})}function ja(n,{startingIndex:o=-1,decrement:r=!1,disabledIndices:l,amount:c=1}={}){let d=o;do d+=r?-c:c;while(d>=0&&d<=n.length-1&&Q0(n,d,l));return d}function Q0(n,o,r){if(typeof r=="function"?r(o):r?.includes(o)??!1)return!0;const c=n[o];return c?uu(c)?!r&&(c.hasAttribute("disabled")||c.getAttribute("aria-disabled")==="true"):!0:!1}function qC(n){return n.visibility==="hidden"||n.visibility==="collapse"}function uu(n,o=n?Gn(n):null){return!n||!n.isConnected||!o||qC(o)?!1:typeof n.checkVisibility=="function"?n.checkVisibility():o.display!=="none"&&o.display!=="contents"}const $C='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function XC(n){const o=n.assignedSlot;if(o)return o;if(n.parentElement)return n.parentElement;const r=n.getRootNode();return Ra(r)?r.host:null}function Tm(n){for(const o of Array.from(n.children))if(yn(o)==="summary")return o;return null}function KC(n,o){const r=Tm(o);return!!r&&(n===r||ot(r,n))}function Z0(n){const o=n?yn(n):"";return n!=null&&n.matches($C)&&(o!=="summary"||n.parentElement!=null&&yn(n.parentElement)==="details"&&Tm(n.parentElement)===n)&&(o!=="details"||Tm(n)==null)&&(o!=="input"||n.type!=="hidden")}function J0(n){if(!Z0(n)||!n.isConnected||n.matches(":disabled"))return!1;for(let o=n;o;o=XC(o)){const r=o!==n,l=yn(o)==="slot";if(o.hasAttribute("inert")||r&&yn(o)==="details"&&!o.open&&!KC(n,o)||o.hasAttribute("hidden")||!l&&!QC(o,r))return!1}return!0}function QC(n,o){const r=Gn(n);return o?r.display!=="none":uu(n,r)}function W0(n){const o=n.tabIndex;if(o<0){const r=yn(n);if(r==="details"||r==="audio"||r==="video"||Ht(n)&&n.isContentEditable)return 0}return o}function Vf(n){if(yn(n)!=="input")return null;const o=n;return o.type==="radio"&&o.name!==""?o:null}function ZC(n,o){const r=Vf(n);if(!r)return!0;const l=o.find(c=>{const d=Vf(c);return d?.name===r.name&&d.form===r.form&&d.checked});return l?l===r:o.find(c=>{const d=Vf(c);return d?.name===r.name&&d.form===r.form})===r}function e1(n){if(Ht(n)&&yn(n)==="slot"){const o=n.assignedElements({flatten:!0});if(o.length>0)return o}return Ht(n)&&n.shadowRoot?Array.from(n.shadowRoot.children):Array.from(n.children)}function t1(n,o){e1(n).forEach(r=>{Z0(r)&&o.push(r),t1(r,o)})}function n1(n,o,r){e1(n).forEach(l=>{Ht(l)&&l.matches(o)&&r.push(l),n1(l,o,r)})}function bp(n){return J0(n)&&W0(n)>=0}function s1(n){const o=[];return t1(n,o),o.filter(J0)}function Zl(n){const o=s1(n);return o.filter(r=>W0(r)>=0&&ZC(r,o))}function o1(n,o){const r=Zl(n),l=r.length;if(l===0)return;const c=jn(wt(n)),d=r.indexOf(c),m=d===-1?o===1?0:l-1:d+o;return r[m]}function yp(n){return o1(wt(n).body,1)||n}function r1(n){return o1(wt(n).body,-1)||n}function a1(n,o){if(!n)return null;const r=Zl(wt(n).body),l=r.length;if(l===0)return null;const c=r.indexOf(n);if(c===-1)return null;const d=(c+o+l)%l;return r[d]}function JC(n){return a1(n,1)}function WC(n){return a1(n,-1)}function Ta(n,o){const r=o||n.currentTarget,l=n.relatedTarget;return!l||!ot(r,l)}function eR(n){Zl(n).forEach(r=>{r.dataset.tabindex=r.getAttribute("tabindex")||"",r.setAttribute("tabindex","-1")})}function _y(n){const o=[];n1(n,"[data-tabindex]",o),o.forEach(r=>{const l=r.dataset.tabindex;delete r.dataset.tabindex,l?r.setAttribute("tabindex",l):r.removeAttribute("tabindex")})}function Vo(n,o,r=!0){return n.filter(c=>c.parentId===o).flatMap(c=>[...!r||c.context?.open?[c]:[],...Vo(n,c.id,r)])}function My(n,o){let r=[],l=n.find(c=>c.id===o)?.parentId;for(;l;){const c=n.find(d=>d.id===l);l=c?.parentId,c&&(r=r.concat(c))}return r}function $l(n){return`data-base-ui-${n}`}let yc=0;function kc(n,o={}){const{preventScroll:r=!1,sync:l=!1,shouldFocus:c}=o;cancelAnimationFrame(yc);function d(){c&&!c()||n?.focus({preventScroll:r})}if(l)return d(),dn;const m=requestAnimationFrame(d);return yc=m,()=>{yc===m&&(cancelAnimationFrame(m),yc=0)}}const Ff={inert:new WeakMap,"aria-hidden":new WeakMap},Ay="data-base-ui-inert",wm={inert:new WeakSet,"aria-hidden":new WeakSet};let jl=new WeakMap,Gf=0;function tR(n){return wm[n]}function l1(n){return n?Ra(n)?n.host:l1(n.parentNode):null}const Dy=(n,o)=>o.map(r=>{if(n.contains(r))return r;const l=l1(r);return n.contains(l)?l:null}).filter(r=>r!=null),zy=n=>{const o=new Set;return n.forEach(r=>{let l=r;for(;l&&!o.has(l);)o.add(l),l=l.parentNode}),o},Ly=(n,o,r)=>{const l=[],c=d=>{!d||r.has(d)||Array.from(d.children).forEach(m=>{yn(m)!=="script"&&(o.has(m)?c(m):l.push(m))})};return c(n),l};function nR(n,o,r,l,{mark:c=!0}){let d=null;l?d="inert":r&&(d="aria-hidden");let m=null,g=null;const b=Dy(o,n),p=c?Ly(o,zy(b),new Set(b)):[],v=[],x=[];if(d){const S=Ff[d],j=tR(d);g=j,m=S;const E=Dy(o,Array.from(o.querySelectorAll("[aria-live]"))),M=b.concat(E);Ly(o,zy(M),new Set(M)).forEach(N=>{const T=N.getAttribute(d),k=T!==null&&T!=="false",C=(S.get(N)||0)+1;S.set(N,C),v.push(N),C===1&&k&&j.add(N),k||N.setAttribute(d,d==="inert"?"":"true")})}return c&&p.forEach(S=>{const j=(jl.get(S)||0)+1;jl.set(S,j),x.push(S),j===1&&S.setAttribute(Ay,"")}),Gf+=1,()=>{m&&v.forEach(S=>{const E=(m.get(S)||0)-1;m.set(S,E),E||(!g?.has(S)&&d&&S.removeAttribute(d),g?.delete(S))}),c&&x.forEach(S=>{const j=(jl.get(S)||0)-1;jl.set(S,j),j||S.removeAttribute(Ay)}),Gf-=1,Gf||(Ff.inert=new WeakMap,Ff["aria-hidden"]=new WeakMap,wm.inert=new WeakSet,wm["aria-hidden"]=new WeakSet,jl=new WeakMap)}}function Iy(n,o={}){const{ariaHidden:r=!1,inert:l=!1,mark:c=!0}=o,d=wt(n[0]).body;return nR(n,d,r,l,{mark:c})}const sR=500,i1=500,oR={style:{transition:"none"}},c1="data-base-ui-click-trigger",rR={fallbackAxisSide:"none"},u1={fallbackAxisSide:"end"},aR={clipPath:"inset(50%)",position:"fixed",top:0,left:0},d1=h.createContext(null),f1=()=>h.useContext(d1),lR=$l("portal");function iR(n={}){const{ref:o,container:r,componentProps:l=Pt,elementProps:c}=n,d=jr(),g=f1()?.portalNode,[b,p]=h.useState(null),[v,x]=h.useState(null),S=at(O=>{O!==null&&x(O)}),j=h.useRef(null);Qe(()=>{if(r===null){j.current&&(j.current=null,x(null),p(null));return}if(d==null)return;const O=(r&&(ep(r)?r:r.current))??g??document.body;if(O==null){j.current&&(j.current=null,x(null),p(null));return}j.current!==O&&(j.current=O,x(null),p(O))},[r,g,d]);const E=mn("div",l,{ref:[o,S],props:[{id:d,[lR]:""},c]});return{portalNode:v,portalSubtree:b&&E?io.createPortal(E,b):null}}const vp=h.forwardRef(function(o,r){const{render:l,className:c,style:d,children:m,container:g,renderGuards:b,...p}=o,{portalNode:v,portalSubtree:x}=iR({container:g,ref:r,componentProps:o,elementProps:p}),S=h.useRef(null),j=h.useRef(null),E=h.useRef(null),M=h.useRef(null),[O,N]=h.useState(null),T=h.useRef(!1),k=O?.modal,C=O?.open,U=typeof b=="boolean"?b:!!O&&!O.modal&&O.open&&!!v;h.useEffect(()=>{if(!v||k)return;function L(_){v&&_.relatedTarget&&Ta(_)&&(_.type==="focusin"?T.current&&(_y(v),T.current=!1):(eR(v),T.current=!0))}return Ms(yt(v,"focusin",L,!0),yt(v,"focusout",L,!0))},[v,k]),Qe(()=>{!v||C!==!0||!T.current||(_y(v),T.current=!1)},[C,v]);const A=h.useMemo(()=>({beforeOutsideRef:S,afterOutsideRef:j,beforeInsideRef:E,afterInsideRef:M,portalNode:v,setFocusManagerState:N}),[v]);return i.jsxs(h.Fragment,{children:[x,i.jsxs(d1.Provider,{value:A,children:[U&&v&&i.jsx(Yo,{"data-type":"outside",ref:S,onFocus:L=>{if(Ta(L,v))E.current?.focus();else{const _=O?O.domReference:null;r1(_)?.focus()}}}),U&&v&&i.jsx("span",{"aria-owns":v.id,style:aR}),v&&io.createPortal(m,v),U&&v&&i.jsx(Yo,{"data-type":"outside",ref:j,onFocus:L=>{if(Ta(L,v))M.current?.focus();else{const _=O?O.domReference:null;yp(_)?.focus(),O?.closeOnFocusOut&&O?.onOpenChange(!1,Ct(Nr,L.nativeEvent))}}})]})]})});function m1(){const n=new Map;return{emit(o,r){n.get(o)?.forEach(l=>l(r))},on(o,r){n.has(o)||n.set(o,new Set),n.get(o).add(r)},off(o,r){n.get(o)?.delete(r)}}}class Sp{nodesRef={current:[]};events=m1();addNode(o){this.nodesRef.current.push(o)}removeNode(o){const r=this.nodesRef.current.findIndex(l=>l===o);r!==-1&&this.nodesRef.current.splice(r,1)}}const p1=h.createContext(null),h1=h.createContext(null),fo=()=>h.useContext(p1)?.id||null,qo=n=>{const o=h.useContext(h1);return n??o};function Ep(n){const o=jr(),r=qo(n),l=fo();return Qe(()=>{if(!o)return;const c={id:o,parentId:l};return r?.addNode(c),()=>{r?.removeNode(c)}},[r,o,l]),o}function g1(n){const{children:o,id:r}=n,l=fo();return i.jsx(p1.Provider,{value:h.useMemo(()=>({id:r,parentId:l}),[r,l]),children:o})}function x1(n){const{children:o,externalTree:r}=n,l=zn(()=>r??new Sp).current;return i.jsx(h1.Provider,{value:l,children:o})}function cR(n,o){const r=Xt(Dn(n));return n instanceof r.KeyboardEvent?"keyboard":n instanceof r.FocusEvent?o||"keyboard":"pointerType"in n?n.pointerType||"keyboard":"touches"in n?"touch":n instanceof r.MouseEvent?o||(n.detail===0?"keyboard":"mouse"):""}const By=20;let Uo=[];function Np(){Uo=Uo.filter(n=>n.deref()?.isConnected)}function Uy(n){Np(),n&&yn(n)!=="body"&&(Uo.push(new WeakRef(n)),Uo.length>By&&(Uo=Uo.slice(-By)))}function Hy(){return Np(),Uo[Uo.length-1]?.deref()}function uR(n){return n?bp(n)?n:Zl(n)[0]||n:null}function Py(n){if(n.hasAttribute("tabindex")&&!n.hasAttribute("data-tabindex")||!n.getAttribute("role")?.includes("dialog"))return;const r=s1(n).filter(c=>{const d=c.getAttribute("data-tabindex")||"";return bp(c)||c.hasAttribute("data-tabindex")&&!d.startsWith("-")}),l=n.getAttribute("tabindex");r.length===0?l!=="0"&&(n.setAttribute("tabindex","0"),n.setAttribute("data-tabindex","0")):(l!=="-1"||n.hasAttribute("data-tabindex")&&n.getAttribute("data-tabindex")!=="-1")&&(n.setAttribute("tabindex","-1"),n.setAttribute("data-tabindex","-1"))}function jp(n){const{context:o,children:r,disabled:l=!1,initialFocus:c=!0,returnFocus:d=!0,restoreFocus:m=!1,modal:g=!0,closeOnFocusOut:b=!0,openInteractionType:p="",nextFocusableElement:v,previousFocusableElement:x,beforeContentFocusGuardRef:S,externalTree:j,getInsideElements:E}=n,M="rootStore"in o?o.rootStore:o,O=M.useState("open"),N=M.useState("domReferenceElement"),T=M.useState("floatingElement"),{events:k,dataRef:C}=M.context,U=at(()=>C.current.floatingContext?.nodeId),A=c===!1,L=Sm(N)&&A,_=an(c),K=an(d),W=an(p),ue=an(O),ne=qo(j),$=f1(),oe=h.useRef(!1),q=h.useRef(!1),w=h.useRef(!1),D=h.useRef(null),H=h.useRef(""),B=h.useRef(""),P=h.useRef(null),z=h.useRef(null),X=Oa(P,S,$?.beforeInsideRef),I=Oa(z,$?.afterInsideRef),V=qn(),Q=qn(),Y=Gl(),fe=$!=null,re=Em(T),de=at((Re=re)=>Re?Zl(Re):[]),_e=at(()=>E?.().filter(Re=>Re!=null)??[]);h.useEffect(()=>{if(l||!g)return;function Re(He){He.key==="Tab"&&ot(re,jn(wt(re)))&&de().length===0&&!L&&Ns(He)}const Le=wt(re);return yt(Le,"keydown",Re)},[l,re,g,L,de]),h.useEffect(()=>{if(l||!O)return;const Re=wt(re);function Le(){w.current=!1}function He(pe){const ve=Dn(pe),Ue=_e(),ye=ot(T,ve)||ot(N,ve)||ot($?.portalNode,ve)||Ue.some(De=>De===ve||ot(De,ve));w.current=!ye,B.current=pe.pointerType||"keyboard",ve?.closest(`[${c1}]`)&&(q.current=!0,Q.start(0,()=>{q.current=!1}))}function ge(){B.current="keyboard"}return Ms(yt(Re,"pointerdown",He,!0),yt(Re,"pointerup",Le,!0),yt(Re,"pointercancel",Le,!0),yt(Re,"keydown",ge,!0),Le)},[l,T,N,re,O,$,Q,_e]),h.useEffect(()=>{if(l||!b)return;const Re=wt(re);function Le(){q.current=!0,Q.start(0,()=>{q.current=!1})}function He(Ue){const ye=Dn(Ue);bp(ye)&&(D.current=ye)}function ge(Ue){const ye=Ue.relatedTarget,De=Ue.currentTarget,Pe=Dn(Ue);g&&ye==null&&Pe!=null&&ot(T,Pe)&&Uy(Pe),queueMicrotask(()=>{const Ie=U(),we=M.context.triggerElements,ee=_e(),F=ye?.hasAttribute($l("focus-guard"))&&[P.current,z.current,$?.beforeInsideRef.current,$?.afterInsideRef.current,$?.beforeOutsideRef.current,$?.afterOutsideRef.current,to(x),to(v)].includes(ye),ie=!(ot(N,ye)||ot(T,ye)||ot(ye,T)||ot($?.portalNode,ye)||ee.some(Z=>Z===ye||ot(Z,ye))||ye!=null&&we.hasElement(ye)||we.hasMatchingElement(Z=>ot(Z,ye))||F||ne&&(Vo(ne.nodesRef.current,Ie).find(Z=>ot(Z.context?.elements.floating,ye)||ot(Z.context?.elements.domReference,ye))||My(ne.nodesRef.current,Ie).find(Z=>[Z.context?.elements.floating,Em(Z.context?.elements.floating)].includes(ye)||Z.context?.elements.domReference===ye)));if(De===N&&re&&Py(re),m&&De!==N&&!uu(Pe)&&jn(Re)===Re.body){if(Ht(re)&&(re.focus(),m==="popup")){Y.request(()=>{re.focus()});return}const Z=de(),Ee=D.current,Xe=(Ee&&Z.includes(Ee)?Ee:null)||Z[Z.length-1]||re;Ht(Xe)&&Xe.focus()}if(C.current.insideReactTree){C.current.insideReactTree=!1;return}(L||!g)&&ye&&ie&&!q.current&&(L||ye!==Hy())&&(oe.current=!0,M.setOpen(!1,Ct(Nr,Ue)))})}function pe(){w.current||(C.current.insideReactTree=!0,V.start(0,()=>{C.current.insideReactTree=!1}))}const ve=Ht(N)?N:null;if(!(!T&&!ve))return Ms(ve&&yt(ve,"focusout",ge),ve&&yt(ve,"pointerdown",Le),T&&yt(T,"focusin",He),T&&yt(T,"focusout",ge),T&&$&&yt(T,"focusout",pe,!0))},[l,N,T,re,g,ne,$,M,b,m,de,L,U,C,V,Q,Y,v,x,_e]),h.useEffect(()=>{if(l||!T||!O)return;const Re=Array.from($?.portalNode?.querySelectorAll(`[${$l("portal")}]`)||[]),He=(ne?My(ne.nodesRef.current,U()):[]).find(De=>Sm(De.context?.elements.domReference||null))?.context?.elements.domReference,pe=[...[T,...Re,P.current,z.current,$?.beforeOutsideRef.current,$?.afterOutsideRef.current,..._e()],He,to(x),to(v),L?N:null].filter(De=>De!=null),ve=Iy(pe,{ariaHidden:g||L,mark:!1}),Ue=[T,...Re].filter(De=>De!=null),ye=Iy(Ue);return()=>{ye(),ve()}},[O,l,N,T,g,$,L,ne,U,v,x,_e]),Qe(()=>{if(!O||l||!Ht(re))return;const Re=wt(re),Le=jn(Re);queueMicrotask(()=>{const He=_.current,ge=typeof He=="function"?He(W.current||""):He;if(ge===void 0||ge===!1||ot(re,Le))return;let ve=null;const Ue=()=>(ve==null&&(ve=de(re)),ve[0]||re);let ye;ge===!0||ge===null?ye=Ue():ye=to(ge),ye=ye||Ue();const De=ot(re,jn(Re));kc(ye,{preventScroll:ye===re,shouldFocus(){if(!ue.current)return!1;if(De)return!0;const Pe=jn(Re);return!(Pe!==ye&&ot(re,Pe))}})})},[l,O,re,de,_,W,ue]),Qe(()=>{if(l||!re)return;const Re=wt(re),Le=jn(Re),He=W.current==null;Uy(Le);function ge(ve){if(ve.open||(H.current=cR(ve.nativeEvent,B.current)),ve.reason===fn&&ve.nativeEvent.type==="mouseleave"&&(oe.current=!0),ve.reason===ip)if(ve.nested)oe.current=!1;else if(V0(ve.nativeEvent)||F0(ve.nativeEvent))oe.current=!1;else{let Ue=!1;wt(re).createElement("div").focus({get preventScroll(){return Ue=!0,!1}}),Ue?oe.current=!1:oe.current=!0}}k.on("openchange",ge);function pe(){const ve=K.current;let Ue=typeof ve=="function"?ve(H.current):ve;if(Ue===void 0||Ue===!1)return null;Ue===null&&(Ue=!0);const ye=N?.isConnected?N:null,De=Le?.isConnected&&yn(Le)!=="body"?Le:null;let Pe=He?De||ye:ye||De;return Pe||(Pe=Hy()||null),typeof Ue=="boolean"?Pe:to(Ue)||Pe||null}return()=>{k.off("openchange",ge);const ve=jn(Re),Ue=_e(),ye=ot(T,ve)||Ue.some(Ie=>Ie===ve||ot(Ie,ve))||ne&&Vo(ne.nodesRef.current,U(),!1).some(Ie=>ot(Ie.context?.elements.floating,ve)),De=K.current,Pe=pe();queueMicrotask(()=>{const Ie=uR(Pe),we=typeof De!="boolean";De&&!oe.current&&Ht(Ie)&&(!(!we&&Ie!==ve&&ve!==Re.body)||ye)&&Ie.focus({preventScroll:!0}),oe.current=!1})}},[l,T,re,K,W,k,ne,N,U,_e]),Qe(()=>{if(!Or||O||!T)return;const Re=jn(wt(T));!Ht(Re)||!cu(Re)||ot(T,Re)&&Re.blur()},[O,T]),Qe(()=>{if(!(l||!$))return $.setFocusManagerState({modal:g,closeOnFocusOut:b,open:O,onOpenChange:M.setOpen,domReference:N}),()=>{$.setFocusManagerState(null)}},[l,$,g,O,M,b,N]),Qe(()=>{if(!(l||!re))return Py(re),()=>{queueMicrotask(Np)}},[l,re]);const Ye=!l&&(g?!L:!0)&&(fe||g);return i.jsxs(h.Fragment,{children:[Ye&&i.jsx(Yo,{"data-type":"inside",ref:X,onFocus:Re=>{if(g){const Le=de();kc(Le[Le.length-1])}else $?.portalNode&&(oe.current=!1,Ta(Re,$.portalNode)?yp(N)?.focus():to(x??$.beforeOutsideRef)?.focus())}}),r,Ye&&i.jsx(Yo,{"data-type":"inside",ref:I,onFocus:Re=>{g?kc(de()[0]):$?.portalNode&&(b&&(oe.current=!0),Ta(Re,$.portalNode)?r1(N)?.focus():to(v??$.afterOutsideRef)?.focus())}})]})}function b1(n,o={}){const{enabled:r=!0,event:l="click",toggle:c=!0,ignoreMouse:d=!1,stickIfOpen:m=!0,touchOpenDelay:g=0,reason:b=Er}=o,p="rootStore"in n?n.rootStore:n,v=p.context.dataRef,x=h.useRef(void 0),S=Gl(),j=qn(),E=h.useMemo(()=>{function M(N,T,k,C){const U=Ct(b,T,k);N&&C==="touch"&&g>0?j.start(g,()=>{p.setOpen(!0,U)}):p.setOpen(N,U)}function O(N,T,k){const C=v.current.openEvent,U=p.select("domReferenceElement")!==T;return N&&U||!N||!c?!0:C&&m?!k(C.type):!1}return{onPointerDown(N){x.current=N.pointerType},onMouseDown(N){const T=x.current,k=N.nativeEvent,C=p.select("open");if(N.button!==0||l==="click"||ql(T,!0)&&d)return;const U=O(C,N.currentTarget,_=>_==="click"||_==="mousedown"),A=Dn(k);if(cu(A)){M(U,k,A,T);return}const L=N.currentTarget;S.request(()=>{M(U,k,L,T)})},onClick(N){if(l==="mousedown-only")return;const T=x.current;if(l==="mousedown"&&T){x.current=void 0;return}if(ql(T,!0)&&d)return;const k=p.select("open"),C=O(k,N.currentTarget,U=>U==="click"||U==="mousedown"||U==="keydown"||U==="keyup");M(C,N.nativeEvent,N.currentTarget,T)},onKeyDown(){x.current=void 0}}},[v,l,d,b,p,m,c,S,j,g]);return h.useMemo(()=>r?{reference:E}:Pt,[r,E])}function dR(){return!1}function fR(n){return{escapeKey:typeof n=="boolean"?n:n?.escapeKey??!1,outsidePress:typeof n=="boolean"?n:n?.outsidePress??!0}}function Tp(n,o={}){const{enabled:r=!0,escapeKey:l=!0,outsidePress:c=!0,outsidePressEvent:d="sloppy",referencePress:m=dR,bubbles:g,externalTree:b}=o,p="rootStore"in n?n.rootStore:n,v=p.useState("open"),x=p.useState("floatingElement"),{dataRef:S}=p.context,j=qo(b),E=at(typeof c=="function"?c:()=>!1),M=typeof c=="function"?E:c,O=M!==!1,N=at(()=>d),{escapeKey:T,outsidePress:k}=fR(g),C=h.useRef(!1),U=h.useRef(!1),A=h.useRef(!1),L=h.useRef(!1),_=h.useRef(""),K=h.useRef(null),W=qn(),ue=qn(),ne=at(()=>{ue.clear(),S.current.insideReactTree=!1}),$=at(X=>{const I=S.current.floatingContext?.nodeId;return(j?Vo(j.nodesRef.current,I):[]).some(Q=>Q.context?.open&&!Q.context.dataRef.current[X])}),oe=at(X=>Pf(X,p.select("floatingElement"))||Pf(X,p.select("domReferenceElement"))),q=at(X=>{m()&&p.setOpen(!1,Ct(Er,X.nativeEvent))}),w=at(X=>{if(!v||!r||!l||X.key!=="Escape"||L.current||!T&&$("__escapeKeyBubbles"))return;const I=CC(X)?X.nativeEvent:X,V=Ct(su,I);p.setOpen(!1,V),V.isCanceled||X.preventDefault(),!T&&!V.isPropagationAllowed&&X.stopPropagation()}),D=at(()=>{S.current.insideReactTree=!0,ue.start(0,ne)}),H=at(X=>{if(!v||!r||X.button!==0)return;const I=Dn(X.nativeEvent);ot(p.select("floatingElement"),I)&&(C.current||(C.current=!0,U.current=!1))}),B=at(X=>{!v||!r||(X.defaultPrevented||X.nativeEvent.defaultPrevented)&&C.current&&(U.current=!0)});h.useEffect(()=>{if(!v||!r)return;S.current.__escapeKeyBubbles=T,S.current.__outsidePressBubbles=k;const X=new ms,I=new ms;function V(){X.clear(),L.current=!0}function Q(){X.start(Or?5:0,()=>{L.current=!1})}function Y(){A.current=!0,I.start(0,()=>{A.current=!1})}function fe(){C.current=!1,U.current=!1}function re(){const ee=_.current,F=ee==="pen"||!ee?"mouse":ee,ie=N(),Z=typeof ie=="function"?ie():ie;return typeof Z=="string"?Z:Z[F]}function de(ee){const F=re();return F==="intentional"&&ee.type!=="click"||F==="sloppy"&&ee.type==="click"}function _e(ee){const F=S.current.floatingContext?.nodeId,ie=j&&Vo(j.nodesRef.current,F).some(Z=>Pf(ee,Z.context?.elements.floating));return oe(ee)||ie}function Ye(ee){if(de(ee)){ee.type!=="click"&&!oe(ee)&&(I.clear(),A.current=!1),ne();return}if(S.current.insideReactTree){ne();return}const F=Dn(ee),ie=`[${$l("inert")}]`,Z=Et(F)?F.getRootNode():null,Ee=Array.from((Ra(Z)?Z:wt(p.select("floatingElement"))).querySelectorAll(ie)),Xe=p.context.triggerElements;if(F&&(Xe.hasElement(F)||Xe.hasMatchingElement(Me=>ot(Me,F))))return;let Ne=Et(F)?F:null;for(;Ne&&!no(Ne);){const Me=lo(Ne);if(no(Me)||!Et(Me))break;Ne=Me}if(!(Ee.length&&Et(F)&&!OC(F)&&!ot(F,p.select("floatingElement"))&&Ee.every(Me=>!ot(Ne,Me)))){if(Ht(F)&&!("touches"in ee)){const Me=no(F),Je=Gn(F),nt=/auto|scroll/,jt=Me||nt.test(Je.overflowX),kt=Me||nt.test(Je.overflowY),gt=jt&&F.clientWidth>0&&F.scrollWidth>F.clientWidth,ln=kt&&F.clientHeight>0&&F.scrollHeight>F.clientHeight,Jt=Je.direction==="rtl",et=ln&&(Jt?ee.offsetX<=F.offsetWidth-F.clientWidth:ee.offsetX>F.clientWidth),je=gt&&ee.offsetY>F.clientHeight;if(et||je)return}if(!_e(ee)){if(re()==="intentional"&&A.current){I.clear(),A.current=!1;return}typeof M=="function"&&!M(ee)||$("__outsidePressBubbles")||(p.setOpen(!1,Ct(ip,ee)),ne())}}}function Re(ee){re()!=="sloppy"||ee.pointerType==="touch"||!p.select("open")||!r||oe(ee)||Ye(ee)}function Le(ee){if(re()!=="sloppy"||!p.select("open")||!r||oe(ee))return;const F=ee.touches[0];F&&(K.current={startTime:Date.now(),startX:F.clientX,startY:F.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},W.start(1e3,()=>{K.current&&(K.current.dismissOnTouchEnd=!1,K.current.dismissOnMouseDown=!1)}))}function He(ee,F){const ie=Dn(ee);if(!ie)return;const Z=yt(ie,ee.type,()=>{F(ee),Z()})}function ge(ee){_.current="touch",He(ee,Le)}function pe(ee){W.clear(),ee.type==="pointerdown"&&(_.current=ee.pointerType),!(ee.type==="mousedown"&&K.current&&!K.current.dismissOnMouseDown)&&He(ee,F=>{F.type==="pointerdown"?Re(F):Ye(F)})}function ve(ee){if(!C.current)return;const F=U.current;if(fe(),re()==="intentional"){if(ee.type==="pointercancel"){F&&Y();return}if(!_e(ee)){if(F){Y();return}typeof M=="function"&&!M(ee)||(I.clear(),A.current=!0,ne())}}}function Ue(ee){if(re()!=="sloppy"||!K.current||oe(ee))return;const F=ee.touches[0];if(!F)return;const ie=Math.abs(F.clientX-K.current.startX),Z=Math.abs(F.clientY-K.current.startY),Ee=Math.sqrt(ie*ie+Z*Z);Ee>5&&(K.current.dismissOnTouchEnd=!0),Ee>10&&(Ye(ee),W.clear(),K.current=null)}function ye(ee){He(ee,Ue)}function De(ee){re()!=="sloppy"||!K.current||oe(ee)||(K.current.dismissOnTouchEnd&&Ye(ee),W.clear(),K.current=null)}function Pe(ee){He(ee,De)}const Ie=wt(x),we=Ms(l&&Ms(yt(Ie,"keydown",w),yt(Ie,"compositionstart",V),yt(Ie,"compositionend",Q)),O&&Ms(yt(Ie,"click",pe,!0),yt(Ie,"pointerdown",pe,!0),yt(Ie,"pointerup",ve,!0),yt(Ie,"pointercancel",ve,!0),yt(Ie,"mousedown",pe,!0),yt(Ie,"mouseup",ve,!0),yt(Ie,"touchstart",ge,!0),yt(Ie,"touchmove",ye,!0),yt(Ie,"touchend",Pe,!0)));return()=>{we(),X.clear(),I.clear(),fe(),A.current=!1}},[S,x,l,O,M,v,r,T,k,w,ne,N,$,oe,j,p,W]),h.useEffect(ne,[M,ne]);const P=h.useMemo(()=>({onKeyDown:w,onPointerDown:q,onClick:q}),[w,q]),z=h.useMemo(()=>({onKeyDown:w,onPointerDown:B,onMouseDown:B,onClickCapture:D,onMouseDownCapture(X){D(),H(X)},onPointerDownCapture(X){D(),H(X)},onMouseUpCapture:D,onTouchEndCapture:D,onTouchMoveCapture:D}),[w,D,H,B]);return h.useMemo(()=>r?{reference:P,floating:z,trigger:P}:{},[r,P,z])}function Yy(n,o,r){let{reference:l,floating:c}=n;const d=as(o),m=xp(o),g=gp(m),b=Fn(o),p=d==="y",v=l.x+l.width/2-c.width/2,x=l.y+l.height/2-c.height/2,S=l[g]/2-c[g]/2;let j;switch(b){case"top":j={x:v,y:l.y-c.height};break;case"bottom":j={x:v,y:l.y+l.height};break;case"right":j={x:l.x+l.width,y:x};break;case"left":j={x:l.x-c.width,y:x};break;default:j={x:l.x,y:l.y}}const E=Go(o);return E&&(j[m]+=S*(E==="end"?1:-1)*(r&&p?-1:1)),j}async function mR(n,o){var r;o===void 0&&(o={});const{x:l,y:c,platform:d,rects:m,elements:g,strategy:b}=n,{boundary:p="clippingAncestors",rootBoundary:v="viewport",elementContext:x="floating",altBoundary:S=!1,padding:j=0}=co(o,n),E=K0(j),O=g[S?x==="floating"?"reference":"floating":x],N=Gc(await d.getClippingRect({element:(r=await(d.isElement==null?void 0:d.isElement(O)))==null||r?O:O.contextElement||await(d.getDocumentElement==null?void 0:d.getDocumentElement(g.floating)),boundary:p,rootBoundary:v,strategy:b})),T=x==="floating"?{x:l,y:c,width:m.floating.width,height:m.floating.height}:m.reference,k=await(d.getOffsetParent==null?void 0:d.getOffsetParent(g.floating)),C=await(d.isElement==null?void 0:d.isElement(k))&&await(d.getScale==null?void 0:d.getScale(k))||{x:1,y:1},U=Gc(d.convertOffsetParentRelativeRectToViewportRelativeRect?await d.convertOffsetParentRelativeRectToViewportRelativeRect({elements:g,rect:T,offsetParent:k,strategy:b}):T);return{top:(N.top-U.top+E.top)/C.y,bottom:(U.bottom-N.bottom+E.bottom)/C.y,left:(N.left-U.left+E.left)/C.x,right:(U.right-N.right+E.right)/C.x}}const pR=50,hR=async(n,o,r)=>{const{placement:l="bottom",strategy:c="absolute",middleware:d=[],platform:m}=r,g=m.detectOverflow?m:{...m,detectOverflow:mR},b=await(m.isRTL==null?void 0:m.isRTL(o));let p=await m.getElementRects({reference:n,floating:o,strategy:c}),{x:v,y:x}=Yy(p,l,b),S=l,j=0;const E={};for(let M=0;M<d.length;M++){const O=d[M];if(!O)continue;const{name:N,fn:T}=O,{x:k,y:C,data:U,reset:A}=await T({x:v,y:x,initialPlacement:l,placement:S,strategy:c,middlewareData:E,rects:p,platform:g,elements:{reference:n,floating:o}});v=k??v,x=C??x,E[N]={...E[N],...U},A&&j<pR&&(j++,typeof A=="object"&&(A.placement&&(S=A.placement),A.rects&&(p=A.rects===!0?await m.getElementRects({reference:n,floating:o,strategy:c}):A.rects),{x:v,y:x}=Yy(p,S,b)),M=-1)}return{x:v,y:x,placement:S,strategy:c,middlewareData:E}},gR=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(o){var r,l;const{placement:c,middlewareData:d,rects:m,initialPlacement:g,platform:b,elements:p}=o,{mainAxis:v=!0,crossAxis:x=!0,fallbackPlacements:S,fallbackStrategy:j="bestFit",fallbackAxisSideDirection:E="none",flipAlignment:M=!0,...O}=co(n,o);if((r=d.arrow)!=null&&r.alignmentOffset)return{};const N=Fn(c),T=as(g),k=Fn(g)===g,C=await(b.isRTL==null?void 0:b.isRTL(p.floating)),U=S||(k||!M?[Fc(g)]:HC(g)),A=E!=="none";!S&&A&&U.push(...FC(g,M,E,C));const L=[g,...U],_=await b.detectOverflow(o,O),K=[];let W=((l=d.flip)==null?void 0:l.overflows)||[];if(v&&K.push(_[N]),x){const oe=UC(c,m,C);K.push(_[oe[0]],_[oe[1]])}if(W=[...W,{placement:c,overflows:K}],!K.every(oe=>oe<=0)){var ue,ne;const oe=(((ue=d.flip)==null?void 0:ue.index)||0)+1,q=L[oe];if(q&&(!(x==="alignment"?T!==as(q):!1)||W.every(H=>as(H.placement)===T?H.overflows[0]>0:!0)))return{data:{index:oe,overflows:W},reset:{placement:q}};let w=(ne=W.filter(D=>D.overflows[0]<=0).sort((D,H)=>D.overflows[1]-H.overflows[1])[0])==null?void 0:ne.placement;if(!w)switch(j){case"bestFit":{var $;const D=($=W.filter(H=>{if(A){const B=as(H.placement);return B===T||B==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(B=>B>0).reduce((B,P)=>B+P,0)]).sort((H,B)=>H[1]-B[1])[0])==null?void 0:$[0];D&&(w=D);break}case"initialPlacement":w=g;break}if(c!==w)return{reset:{placement:w}}}return{}}}};function Vy(n,o){return{top:n.top-o.height,right:n.right-o.width,bottom:n.bottom-o.height,left:n.left-o.width}}function Fy(n){return IC.some(o=>n[o]>=0)}const xR=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(o){const{rects:r,platform:l}=o,{strategy:c="referenceHidden",...d}=co(n,o);switch(c){case"referenceHidden":{const m=await l.detectOverflow(o,{...d,elementContext:"reference"}),g=Vy(m,r.reference);return{data:{referenceHiddenOffsets:g,referenceHidden:Fy(g)}}}case"escaped":{const m=await l.detectOverflow(o,{...d,altBoundary:!0}),g=Vy(m,r.floating);return{data:{escapedOffsets:g,escaped:Fy(g)}}}default:return{}}}}},y1=new Set(["left","top"]);async function bR(n,o){const{placement:r,platform:l,elements:c}=n,d=await(l.isRTL==null?void 0:l.isRTL(c.floating)),m=Fn(r),g=Go(r),b=as(r)==="y",p=y1.has(m)?-1:1,v=d&&b?-1:1,x=co(o,n);let{mainAxis:S,crossAxis:j,alignmentAxis:E}=typeof x=="number"?{mainAxis:x,crossAxis:0,alignmentAxis:null}:{mainAxis:x.mainAxis||0,crossAxis:x.crossAxis||0,alignmentAxis:x.alignmentAxis};return g&&typeof E=="number"&&(j=g==="end"?E*-1:E),b?{x:j*v,y:S*p}:{x:S*p,y:j*v}}const yR=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(o){var r,l;const{x:c,y:d,placement:m,middlewareData:g}=o,b=await bR(o,n);return m===((r=g.offset)==null?void 0:r.placement)&&(l=g.arrow)!=null&&l.alignmentOffset?{}:{x:c+b.x,y:d+b.y,data:{...b,placement:m}}}}},vR=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(o){const{x:r,y:l,placement:c,platform:d}=o,{mainAxis:m=!0,crossAxis:g=!1,limiter:b={fn:T=>{let{x:k,y:C}=T;return{x:k,y:C}}},...p}=co(n,o),v={x:r,y:l},x=await d.detectOverflow(o,p),S=as(c),j=hp(S);let E=v[j],M=v[S];const O=(T,k)=>X0(k+x[T==="y"?"top":"left"],k,k-x[T==="y"?"bottom":"right"]);m&&(E=O(j,E)),g&&(M=O(S,M));const N=b.fn({...o,[j]:E,[S]:M});return{...N,data:{x:N.x-r,y:N.y-l,enabled:{[j]:m,[S]:g}}}}}},SR=function(n){return n===void 0&&(n={}),{options:n,fn(o){var r,l;const{x:c,y:d,placement:m,rects:g,middlewareData:b}=o,{offset:p=0,mainAxis:v=!0,crossAxis:x=!0}=co(n,o),S={x:c,y:d},j=as(m),E=hp(j);let M=S[E],O=S[j];const N=co(p,o),T=typeof N=="number"?{mainAxis:N,crossAxis:0}:{mainAxis:(r=N.mainAxis)!=null?r:0,crossAxis:(l=N.crossAxis)!=null?l:0};if(v){const U=E==="y"?"height":"width",A=g.reference[E]-g.floating[U]+T.mainAxis,L=g.reference[E]+g.reference[U]-T.mainAxis;M<A?M=A:M>L&&(M=L)}if(x){var k,C;const U=E==="y"?"width":"height",A=y1.has(Fn(m)),L=g.reference[j]-g.floating[U]+(A&&((k=b.offset)==null?void 0:k[j])||0)+(A?0:T.crossAxis),_=g.reference[j]+g.reference[U]+(A?0:((C=b.offset)==null?void 0:C[j])||0)-(A?T.crossAxis:0);O<L?O=L:O>_&&(O=_)}return{[E]:M,[j]:O}}}},ER=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(o){const{placement:r,rects:l,platform:c,elements:d}=o,{apply:m=()=>{},...g}=co(n,o),b=await c.detectOverflow(o,g),p=Fn(r),v=Go(r),x=as(r)==="y",{width:S,height:j}=l.floating;let E,M;p==="top"||p==="bottom"?(E=p,M=v===(await(c.isRTL==null?void 0:c.isRTL(d.floating))?"start":"end")?"left":"right"):(M=p,E=v==="end"?"top":"bottom");const O=j-b.top-b.bottom,N=S-b.left-b.right,T=ka(j-b[E],O),k=ka(S-b[M],N),C=o.middlewareData.shift,U=!C;let A=T,L=k;C!=null&&C.enabled.x&&(L=N),C!=null&&C.enabled.y&&(A=O),U&&!v&&(x?L=S-2*oo(b.left,b.right):A=j-2*oo(b.top,b.bottom)),await m({...o,availableWidth:L,availableHeight:A});const _=await c.getDimensions(d.floating);return S!==_.width||j!==_.height?{reset:{rects:!0}}:{}}}};function v1(n){const o=Gn(n);let r=parseFloat(o.width)||0,l=parseFloat(o.height)||0;const c=Ht(n),d=c?n.offsetWidth:r,m=c?n.offsetHeight:l,g=Vc(r)!==d||Vc(l)!==m;return g&&(r=d,l=m),{width:r,height:l,$:g}}function wp(n){return Et(n)?n:n.contextElement}function wa(n){const o=wp(n);if(!Ht(o))return ro(1);const r=o.getBoundingClientRect(),{width:l,height:c,$:d}=v1(o);let m=(d?Vc(r.width):r.width)/l,g=(d?Vc(r.height):r.height)/c;return(!m||!Number.isFinite(m))&&(m=1),(!g||!Number.isFinite(g))&&(g=1),{x:m,y:g}}const NR=ro(0);function S1(n){const o=Xt(n);return!np()||!o.visualViewport?NR:{x:o.visualViewport.offsetLeft,y:o.visualViewport.offsetTop}}function jR(n,o,r){return o===void 0&&(o=!1),!!r&&o&&r===Xt(n)}function Tr(n,o,r,l){o===void 0&&(o=!1),r===void 0&&(r=!1);const c=n.getBoundingClientRect(),d=wp(n);let m=ro(1);o&&(l?Et(l)&&(m=wa(l)):m=wa(n));const g=jR(d,r,l)?S1(d):ro(0);let b=(c.left+g.x)/m.x,p=(c.top+g.y)/m.y,v=c.width/m.x,x=c.height/m.y;if(d&&l){const S=Xt(d),j=Et(l)?Xt(l):l;let E=S,M=mm(E);for(;M&&j!==E;){const O=wa(M),N=M.getBoundingClientRect(),T=Gn(M),k=N.left+(M.clientLeft+parseFloat(T.paddingLeft))*O.x,C=N.top+(M.clientTop+parseFloat(T.paddingTop))*O.y;b*=O.x,p*=O.y,v*=O.x,x*=O.y,b+=k,p+=C,E=Xt(M),M=mm(E)}}return Gc({width:v,height:x,x:b,y:p})}function du(n,o){const r=eu(n).scrollLeft;return o?o.left+r:Tr(uo(n)).left+r}function E1(n,o){const r=n.getBoundingClientRect(),l=r.left+o.scrollLeft-du(n,r),c=r.top+o.scrollTop;return{x:l,y:c}}function TR(n){let{elements:o,rect:r,offsetParent:l,strategy:c}=n;const d=c==="fixed",m=uo(l),g=o?Wc(o.floating):!1;if(l===m||g&&d)return r;let b={scrollLeft:0,scrollTop:0},p=ro(1);const v=ro(0),x=Ht(l);if((x||!d)&&((yn(l)!=="body"||Cr(m))&&(b=eu(l)),x)){const j=Tr(l);p=wa(l),v.x=j.x+l.clientLeft,v.y=j.y+l.clientTop}const S=m&&!x&&!d?E1(m,b):ro(0);return{width:r.width*p.x,height:r.height*p.y,x:r.x*p.x-b.scrollLeft*p.x+v.x+S.x,y:r.y*p.y-b.scrollTop*p.y+v.y+S.y}}function wR(n){return n.getClientRects?Array.from(n.getClientRects()):[]}function CR(n){const o=eu(n),r=n.ownerDocument.body,l=oo(n.scrollWidth,n.clientWidth,r.scrollWidth,r.clientWidth),c=oo(n.scrollHeight,n.clientHeight,r.scrollHeight,r.clientHeight);let d=-o.scrollLeft+du(n);const m=-o.scrollTop;return Gn(r).direction==="rtl"&&(d+=oo(n.clientWidth,r.clientWidth)-l),{width:l,height:c,x:d,y:m}}const RR=25;function OR(n,o,r){r===void 0&&(r="viewport");const l=r==="layoutViewport",c=Xt(n),d=uo(n),m=c.visualViewport;let g=d.clientWidth,b=d.clientHeight,p=0,v=0;if(m){const S=!np()||o==="fixed";l?S||(p=-m.offsetLeft,v=-m.offsetTop):(g=m.width,b=m.height,S&&(p=m.offsetLeft,v=m.offsetTop))}if(du(d)<=0){const S=d.ownerDocument,j=S.body,E=getComputedStyle(j),M=S.compatMode==="CSS1Compat"&&parseFloat(E.marginLeft)+parseFloat(E.marginRight)||0,O=Math.abs(d.clientWidth-j.clientWidth-M),N=getComputedStyle(d).scrollbarGutter==="stable both-edges"?O/2:O;N<=RR&&(g-=N)}return{width:g,height:b,x:p,y:v}}function kR(n,o){const r=Tr(n,!0,o==="fixed"),l=r.top+n.clientTop,c=r.left+n.clientLeft,d=wa(n),m=n.clientWidth*d.x,g=n.clientHeight*d.y,b=c*d.x,p=l*d.y;return{width:m,height:g,x:b,y:p}}function Gy(n,o,r){let l;if(o==="viewport"||o==="layoutViewport")l=OR(n,r,o);else if(o==="document")l=CR(uo(n));else if(Et(o))l=kR(o,r);else{const c=S1(n);l={x:o.x-c.x,y:o.y-c.y,width:o.width,height:o.height}}return Gc(l)}function _R(n,o){const r=o.get(n);if(r)return r;let l=Yl(n,[],!1).filter(g=>Et(g)&&yn(g)!=="body"),c=null;const d=Gn(n).position==="fixed";let m=d?lo(n):n;for(;Et(m)&&!no(m);){const g=Gn(m),b=tp(m),p=c?c.position:d?"fixed":"";!b&&(p==="fixed"||p==="absolute"&&g.position==="static")?l=l.filter(x=>x!==m):c=g,m=lo(m)}return o.set(n,l),l}function MR(n){let{element:o,boundary:r,rootBoundary:l,strategy:c}=n;const m=[...r==="clippingAncestors"?Wc(o)?[]:_R(o,this._c):[].concat(r),l],g=Gy(o,m[0],c);let b=g.top,p=g.right,v=g.bottom,x=g.left;for(let S=1;S<m.length;S++){const j=Gy(o,m[S],c);b=oo(j.top,b),p=ka(j.right,p),v=ka(j.bottom,v),x=oo(j.left,x)}return{width:p-x,height:v-b,x,y:b}}function AR(n){const{width:o,height:r}=v1(n);return{width:o,height:r}}function DR(n,o,r){const l=Ht(o),c=uo(o),d=r==="fixed",m=Tr(n,!0,d,o);let g={scrollLeft:0,scrollTop:0};const b=ro(0);if((l||!d)&&((yn(o)!=="body"||Cr(c))&&(g=eu(o)),l)){const S=Tr(o,!0,d,o);b.x=S.x+o.clientLeft,b.y=S.y+o.clientTop}!l&&c&&(b.x=du(c));const p=c&&!l&&!d?E1(c,g):ro(0),v=m.left+g.scrollLeft-b.x-p.x,x=m.top+g.scrollTop-b.y-p.y;return{x:v,y:x,width:m.width,height:m.height}}function qf(n){return Gn(n).position==="static"}function qy(n,o){if(!Ht(n)||Gn(n).position==="fixed")return null;if(o)return o(n);let r=n.offsetParent;return uo(n)===r&&(r=r.ownerDocument.body),r}function N1(n,o){const r=Xt(n);if(Wc(n))return r;if(!Ht(n)){let c=lo(n);for(;c&&!no(c);){if(Et(c)&&!qf(c))return c;c=lo(c)}return r}let l=qy(n,o);for(;l&&v2(l)&&qf(l);)l=qy(l,o);return l&&no(l)&&qf(l)&&!tp(l)?r:l||N2(n)||r}const zR=async function(n){const o=this.getOffsetParent||N1,r=this.getDimensions,l=await r(n.floating);return{reference:DR(n.reference,await o(n.floating),n.strategy),floating:{x:0,y:0,width:l.width,height:l.height}}};function LR(n){return Gn(n).direction==="rtl"}const IR={convertOffsetParentRelativeRectToViewportRelativeRect:TR,getDocumentElement:uo,getClippingRect:MR,getOffsetParent:N1,getElementRects:zR,getClientRects:wR,getDimensions:AR,getScale:wa,isElement:Et,isRTL:LR};function j1(n,o){return n.x===o.x&&n.y===o.y&&n.width===o.width&&n.height===o.height}function BR(n,o,r){let l=null,c;const d=uo(n);function m(){var v;clearTimeout(c),(v=l)==null||v.disconnect(),l=null}function g(v,x){v===void 0&&(v=!1),x===void 0&&(x=1),m();const S=n.getBoundingClientRect(),{left:j,top:E,width:M,height:O}=S;if(v||o(),!M||!O)return;const N=bc(E),T=bc(d.clientWidth-(j+M)),k=bc(d.clientHeight-(E+O)),C=bc(j),A={rootMargin:-N+"px "+-T+"px "+-k+"px "+-C+"px",threshold:oo(0,ka(1,x))||1};let L=!0;function _(K){const W=K[0].intersectionRatio;if(!j1(S,n.getBoundingClientRect()))return g();if(W!==x){if(!L)return g();W?g(!1,W):c=setTimeout(()=>{g(!1,1e-7)},1e3)}L=!1}try{l=new IntersectionObserver(_,{...A,root:d.ownerDocument})}catch{l=new IntersectionObserver(_,A)}l.observe(n)}const b=Xt(n),p=()=>g(r);return b.addEventListener("resize",p),g(!0),()=>{b.removeEventListener("resize",p),m()}}function $y(n,o,r,l){l===void 0&&(l={});const{ancestorScroll:c=!0,ancestorResize:d=!0,elementResize:m=typeof ResizeObserver=="function",layoutShift:g=typeof IntersectionObserver=="function",animationFrame:b=!1}=l,p=wp(n),v=c||d?[...p?Yl(p):[],...o?Yl(o):[]]:[];v.forEach(N=>{c&&N.addEventListener("scroll",r),d&&N.addEventListener("resize",r)});const x=p&&g?BR(p,r,d):null;let S=-1,j=null;m&&(j=new ResizeObserver(N=>{let[T]=N;T&&T.target===p&&j&&o&&(j.unobserve(o),cancelAnimationFrame(S),S=requestAnimationFrame(()=>{var k;(k=j)==null||k.observe(o)})),r()}),p&&!b&&j.observe(p),o&&j.observe(o));let E,M=b?Tr(n):null;b&&O();function O(){const N=Tr(n);M&&!j1(M,N)&&r(),M=N,E=requestAnimationFrame(O)}return r(),()=>{var N;v.forEach(T=>{c&&T.removeEventListener("scroll",r),d&&T.removeEventListener("resize",r)}),x?.(),(N=j)==null||N.disconnect(),j=null,b&&cancelAnimationFrame(E)}}const UR=yR,HR=vR,PR=gR,YR=ER,VR=xR,FR=SR,GR=(n,o,r)=>{const l=new Map,c=r??{},d={...IR,...c.platform,_c:l};return hR(n,o,{...c,platform:d})};var qR=typeof document<"u",$R=function(){},_c=qR?h.useLayoutEffect:$R;function qc(n,o){if(n===o)return!0;if(typeof n!=typeof o)return!1;if(typeof n=="function"&&n.toString()===o.toString())return!0;let r,l,c;if(n&&o&&typeof n=="object"){if(Array.isArray(n)){if(r=n.length,r!==o.length)return!1;for(l=r;l--!==0;)if(!qc(n[l],o[l]))return!1;return!0}if(c=Object.keys(n),r=c.length,r!==Object.keys(o).length)return!1;for(l=r;l--!==0;)if(!{}.hasOwnProperty.call(o,c[l]))return!1;for(l=r;l--!==0;){const d=c[l];if(!(d==="_owner"&&n.$$typeof)&&!qc(n[d],o[d]))return!1}return!0}return n!==n&&o!==o}function T1(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function Xy(n,o){const r=T1(n);return Math.round(o*r)/r}function $f(n){const o=h.useRef(n);return _c(()=>{o.current=n}),o}function XR(n){n===void 0&&(n={});const{placement:o="bottom",strategy:r="absolute",middleware:l=[],platform:c,elements:{reference:d,floating:m}={},transform:g=!0,whileElementsMounted:b,open:p}=n,[v,x]=h.useState({x:0,y:0,strategy:r,placement:o,middlewareData:{},isPositioned:!1}),[S,j]=h.useState(l);qc(S,l)||j(l);const[E,M]=h.useState(null),[O,N]=h.useState(null),T=h.useCallback(H=>{H!==A.current&&(A.current=H,M(H))},[]),k=h.useCallback(H=>{H!==L.current&&(L.current=H,N(H))},[]),C=d||E,U=m||O,A=h.useRef(null),L=h.useRef(null),_=h.useRef(v),K=b!=null,W=$f(b),ue=$f(c),ne=$f(p),$=h.useCallback(()=>{if(!A.current||!L.current)return;const H={placement:o,strategy:r,middleware:S};ue.current&&(H.platform=ue.current),GR(A.current,L.current,H).then(B=>{const P={...B,isPositioned:ne.current!==!1};oe.current&&!qc(_.current,P)&&(_.current=P,io.flushSync(()=>{x(P)}))})},[S,o,r,ue,ne]);_c(()=>{p===!1&&_.current.isPositioned&&(_.current.isPositioned=!1,x(H=>({...H,isPositioned:!1})))},[p]);const oe=h.useRef(!1);_c(()=>(oe.current=!0,()=>{oe.current=!1}),[]),_c(()=>{if(C&&(A.current=C),U&&(L.current=U),C&&U){if(W.current)return W.current(C,U,$);$()}},[C,U,$,W,K]);const q=h.useMemo(()=>({reference:A,floating:L,setReference:T,setFloating:k}),[T,k]),w=h.useMemo(()=>({reference:C,floating:U}),[C,U]),D=h.useMemo(()=>{const H={position:r,left:0,top:0};if(!w.floating)return H;const B=Xy(w.floating,v.x),P=Xy(w.floating,v.y);return g?{...H,transform:"translate("+B+"px, "+P+"px)",...T1(w.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:B,top:P}},[r,g,w.floating,v.x,v.y]);return h.useMemo(()=>({...v,update:$,refs:q,elements:w,floatingStyles:D}),[v,$,q,w,D])}const KR=(n,o)=>{const r=UR(n);return{name:r.name,fn:r.fn,options:[n,o]}},QR=(n,o)=>{const r=HR(n);return{name:r.name,fn:r.fn,options:[n,o]}},ZR=(n,o)=>({fn:FR(n).fn,options:[n,o]}),JR=(n,o)=>{const r=PR(n);return{name:r.name,fn:r.fn,options:[n,o]}},WR=(n,o)=>{const r=YR(n);return{name:r.name,fn:r.fn,options:[n,o]}},eO=(n,o)=>{const r=VR(n);return{name:r.name,fn:r.fn,options:[n,o]}};function w1(n){const o=h.useRef(!0);o.current&&(o.current=!1,n())}const Ge=(n,o,r,l,c,d,...m)=>{if(m.length>0)throw new Error(En(1));let g;if(n)g=n;else throw new Error("Missing arguments");return g};var Xf={exports:{}},Kf={};var Ky;function tO(){if(Ky)return Kf;Ky=1;var n=Xl();function o(x,S){return x===S&&(x!==0||1/x===1/S)||x!==x&&S!==S}var r=typeof Object.is=="function"?Object.is:o,l=n.useState,c=n.useEffect,d=n.useLayoutEffect,m=n.useDebugValue;function g(x,S){var j=S(),E=l({inst:{value:j,getSnapshot:S}}),M=E[0].inst,O=E[1];return d(function(){M.value=j,M.getSnapshot=S,b(M)&&O({inst:M})},[x,j,S]),c(function(){return b(M)&&O({inst:M}),x(function(){b(M)&&O({inst:M})})},[x]),m(j),j}function b(x){var S=x.getSnapshot;x=x.value;try{var j=S();return!r(x,j)}catch{return!0}}function p(x,S){return S()}var v=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?p:g;return Kf.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:v,Kf}var Qy;function C1(){return Qy||(Qy=1,Xf.exports=tO()),Xf.exports}var R1=C1(),Qf={exports:{}},Zf={};var Zy;function nO(){if(Zy)return Zf;Zy=1;var n=Xl(),o=C1();function r(p,v){return p===v&&(p!==0||1/p===1/v)||p!==p&&v!==v}var l=typeof Object.is=="function"?Object.is:r,c=o.useSyncExternalStore,d=n.useRef,m=n.useEffect,g=n.useMemo,b=n.useDebugValue;return Zf.useSyncExternalStoreWithSelector=function(p,v,x,S,j){var E=d(null);if(E.current===null){var M={hasValue:!1,value:null};E.current=M}else M=E.current;E=g(function(){function N(A){if(!T){if(T=!0,k=A,A=S(A),j!==void 0&&M.hasValue){var L=M.value;if(j(L,A))return C=L}return C=A}if(L=C,l(k,A))return L;var _=S(A);return j!==void 0&&j(L,_)?(k=A,L):(k=A,C=_)}var T=!1,k,C,U=x===void 0?null:x;return[function(){return N(v())},U===null?void 0:function(){return N(U())}]},[v,x,S,j]);var O=c(p,E[0],E[1]);return m(function(){M.hasValue=!0,M.value=O},[O]),b(O),O},Zf}var Jy;function sO(){return Jy||(Jy=1,Qf.exports=nO()),Qf.exports}var oO=sO();const Cm=[];let Rm;function rO(){return Rm}function aO(n){Cm.push(n)}function O1(n){const o=(r,l)=>{const c=zn(iO).current;let d;try{Rm=c;for(const m of Cm)m.before(c);d=n(r,l);for(const m of Cm)m.after(c);c.didInitialize=!0}finally{Rm=void 0}return d};return o.displayName=n.displayName||n.name,o}function lO(n){return h.forwardRef(O1(n))}function iO(){return{didInitialize:!1}}const cO=lp(19),uO=cO?fO:mO;function k1(n,o,r,l,c){return uO(n,o,r,l,c)}function dO(n,o,r,l,c){const d=h.useCallback(()=>o(n.getSnapshot(),r,l,c),[n,o,r,l,c]);return R1.useSyncExternalStore(n.subscribe,d,d)}aO({before(n){n.syncIndex=0,n.didInitialize||(n.syncTick=1,n.syncHooks=[],n.didChangeStore=!0,n.getSnapshot=()=>{let o=!1;for(let r=0;r<n.syncHooks.length;r+=1){const l=n.syncHooks[r],c=l.selector(l.store.state,l.a1,l.a2,l.a3);Object.is(l.value,c)||(o=!0,l.value=c)}return o&&(n.syncTick+=1),n.syncTick})},after(n){n.syncHooks.length>0&&(n.didChangeStore&&(n.didChangeStore=!1,n.subscribe=o=>{const r=new Set;for(const c of n.syncHooks)r.add(c.store);const l=[];for(const c of r)l.push(c.subscribe(o));return()=>{for(const c of l)c()}}),R1.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot))}});function fO(n,o,r,l,c){const d=rO();if(!d)return dO(n,o,r,l,c);const m=d.syncIndex;d.syncIndex+=1;let g;return d.didInitialize?(g=d.syncHooks[m],(g.store!==n||g.selector!==o||!Object.is(g.a1,r)||!Object.is(g.a2,l)||!Object.is(g.a3,c))&&(g.store!==n&&(d.didChangeStore=!0),g.store=n,g.selector=o,g.a1=r,g.a2=l,g.a3=c,g.value=o(n.getSnapshot(),r,l,c))):(g={store:n,selector:o,a1:r,a2:l,a3:c,value:o(n.getSnapshot(),r,l,c)},d.syncHooks.push(g)),g.value}function mO(n,o,r,l,c){return oO.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getSnapshot,d=>o(d,r,l,c))}class pO{constructor(o){this.state=o,this.listeners=new Set,this.updateTick=0}subscribe=o=>(this.listeners.add(o),()=>{this.listeners.delete(o)});getSnapshot=()=>this.state;setState(o){if(this.state===o)return;this.state=o,this.updateTick+=1;const r=this.updateTick;for(const l of this.listeners){if(r!==this.updateTick)return;l(o)}}update(o){for(const r in o)if(!Object.is(this.state[r],o[r])){this.setState({...this.state,...o});return}}set(o,r){Object.is(this.state[o],r)||this.setState({...this.state,[o]:r})}notifyAll(){const o={...this.state};this.setState(o)}use(o,r,l,c){return k1(this,o,r,l,c)}}class fu extends pO{constructor(o,r={},l){super(o),this.context=r,this.selectors=l}useSyncedValue(o,r){h.useDebugValue(o);const l=this;Qe(()=>{l.state[o]!==r&&l.set(o,r)},[l,o,r])}useSyncedValueWithCleanup(o,r){const l=this;Qe(()=>(l.state[o]!==r&&l.set(o,r),()=>{l.set(o,void 0)}),[l,o,r])}useSyncedValues(o){const r=this,l=Object.values(o);Qe(()=>{r.update(o)},[r,...l])}useControlledProp(o,r){h.useDebugValue(o);const l=this,c=r!==void 0;Qe(()=>{c&&!Object.is(l.state[o],r)&&l.setState({...l.state,[o]:r})},[l,o,r,c])}select(o,r,l,c){const d=this.selectors[o];return d(this.state,r,l,c)}useState(o,r,l,c){return h.useDebugValue(o),k1(this,this.selectors[o],r,l,c)}useContextCallback(o,r){h.useDebugValue(o);const l=at(r??dn);this.context[o]=l}useStateSetter(o){const r=h.useRef(void 0);return r.current===void 0&&(r.current=l=>{this.set(o,l)}),r.current}observe(o,r){let l;typeof o=="function"?l=o:l=this.selectors[o];let c=l(this.state);return r(c,c,this),this.subscribe(d=>{const m=l(d);if(!Object.is(c,m)){const g=c;c=m,r(m,g,this)}})}}const hO={open:Ge(n=>n.open),transitionStatus:Ge(n=>n.transitionStatus),domReferenceElement:Ge(n=>n.domReferenceElement),referenceElement:Ge(n=>n.positionReference??n.referenceElement),floatingElement:Ge(n=>n.floatingElement),floatingId:Ge(n=>n.floatingId)};class mu extends fu{constructor(o){const{syncOnly:r,nested:l,onOpenChange:c,triggerElements:d,...m}=o;super({...m,positionReference:m.referenceElement,domReferenceElement:m.referenceElement},{onOpenChange:c,dataRef:{current:{}},events:m1(),nested:l,triggerElements:d},hO),this.syncOnly=r}syncOpenEvent=(o,r)=>{(!o||!this.state.open||r!=null&&RC(r))&&(this.context.dataRef.current.openEvent=o?r:void 0)};dispatchOpenChange=(o,r)=>{this.syncOpenEvent(o,r.event);const l={open:o,reason:r.reason,nativeEvent:r.event,nested:this.context.nested,triggerElement:r.trigger};this.context.events.emit("openchange",l)};setOpen=(o,r)=>{if(this.syncOnly){this.context.onOpenChange?.(o,r);return}this.dispatchOpenChange(o,r),this.context.onOpenChange?.(o,r)}}function _1(n){const{popupStore:o,treatPopupAsFloatingElement:r=!1,floatingRootContext:l,floatingId:c,nested:d,onOpenChange:m}=n,g=o.useState("open"),b=o.useState("activeTriggerElement"),p=o.useState(r?"popupElement":"positionerElement"),v=o.context.triggerElements,x=m,S=h.useRef(null);l===void 0&&S.current===null&&(S.current=new mu({open:g,transitionStatus:void 0,referenceElement:b,floatingElement:p,triggerElements:v,onOpenChange:x,floatingId:c,syncOnly:!0,nested:d}));const j=l??S.current;return o.useSyncedValue("floatingId",c),Qe(()=>{const E={open:g,floatingId:c,referenceElement:b,floatingElement:p};Et(b)&&(E.domReferenceElement=b),j.state.positionReference===j.state.referenceElement&&(E.positionReference=b),j.update(E)},[g,c,b,p,j]),j.context.onOpenChange=x,j.context.nested=d,j}const pu={tabIndex:-1,[vm]:""};function M1(n){return o=>o==="touch"?n.current:!0}function A1(n,o,r=!1){const l=jr(),c=fo()!=null,d=h.useRef(null);n===void 0&&d.current===null&&(d.current=o(l,c));const m=n??d.current;return _1({popupStore:m,treatPopupAsFloatingElement:r,floatingRootContext:m.state.floatingRootContext,floatingId:l,nested:c,onOpenChange:m.setOpen}),{store:m,internalStore:d.current}}function gO(n,o){const r=h.useRef(null),l=h.useRef(null);return h.useCallback(c=>{if(n===void 0)return;let d=!1;if(r.current!==null){const m=r.current,g=l.current,b=o.context.triggerElements.getById(m);g&&b===g&&(o.context.triggerElements.delete(m),d=!0),r.current=null,l.current=null}if(c!==null&&(r.current=n,l.current=c,o.context.triggerElements.add(n,c),d=!0),d){const m=o.context.triggerElements.size;o.select("open")&&o.state.triggerCount!==m&&o.set("triggerCount",m)}},[o,n])}function Cp(n,o,r,l=!1){o?n.preventUnmountingOnClose=!1:l&&(n.preventUnmountingOnClose=!0);const c=r?.id??null;(c||o)&&(n.activeTriggerId=c,n.activeTriggerElement=r??null)}function D1(n){let o=!1;return n.preventUnmountOnClose=()=>{o=!0},()=>o}function z1(n,o,r,l){w1(()=>{o===void 0&&n.state.open===!1&&r&&(n.state={...n.state,open:!0,activeTriggerId:l,preventUnmountingOnClose:!1})})}function L1(n,o,r,l){const c=r.useState("isMountedByTrigger",n),d=gO(n,r),m=at(g=>{if(d(g),!g)return;const b=r.select("open"),p=r.select("activeTriggerId");if(p===n){r.update({activeTriggerElement:g,...b?l:null});return}p==null&&b&&r.update({activeTriggerId:n,activeTriggerElement:g,...l})});return Qe(()=>{c&&r.update({activeTriggerElement:o.current,...l})},[c,r,o,...Object.values(l)]),{registerTrigger:m,isMountedByThisTrigger:c}}function Rp(n,o={}){const{closeOnActiveTriggerUnmount:r=!1}=o,l=n.useState("open"),c=n.useState("triggerCount");Qe(()=>{if(!l){n.state.triggerCount!==0&&n.set("triggerCount",0);return}const d=n.context.triggerElements.size,m={};n.state.triggerCount!==d&&(m.triggerCount=d);const g=n.select("activeTriggerId");let b=null;if(g){const p=n.context.triggerElements.getById(g);p?p!==n.state.activeTriggerElement&&(m.activeTriggerElement=p):b=g}if(!b&&!g&&d===1){const p=n.context.triggerElements.entries().next();if(!p.done){const[v,x]=p.value;m.activeTriggerId=v,m.activeTriggerElement=x}}(m.triggerCount!==void 0||m.activeTriggerId!==void 0||m.activeTriggerElement!==void 0)&&n.update(m),b&&r&&queueMicrotask(()=>{if(n.select("open")&&n.select("activeTriggerId")===b&&!n.context.triggerElements.getById(b)){const p=Ct(I0);n.setOpen(!1,p),p.isCanceled||n.update({activeTriggerId:null,activeTriggerElement:null})}})},[l,n,c,r])}function Op(n,o,r){const{mounted:l,setMounted:c,transitionStatus:d}=SC(n),m=o.useState("preventUnmountingOnClose"),g=n?!1:m;o.useSyncedValues({mounted:l,transitionStatus:d,preventUnmountingOnClose:g});const b=at(()=>{c(!1),o.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),r?.(),o.context.onOpenChangeComplete?.(!1)});return au({enabled:l&&!n&&!g,open:n,ref:o.context.popupRef,onComplete(){n||b()}}),{forceUnmount:b,transitionStatus:d}}function kp(n,o){n.useSyncedValues(o),Qe(()=>()=>{n.update({activeTriggerProps:Pt,inactiveTriggerProps:Pt,popupProps:Pt})},[n])}function I1(n,o){Qe(()=>{!o&&n.state.openMethod!==null&&n.set("openMethod",null)},[o,n]),Qe(()=>()=>{n.state.openMethod!==null&&n.set("openMethod",null)},[n])}class Jl{constructor(){this.elementsSet=new Set,this.idMap=new Map}add(o,r){const l=this.idMap.get(o);l!==r&&(l!==void 0&&this.elementsSet.delete(l),this.elementsSet.add(r),this.idMap.set(o,r))}delete(o){const r=this.idMap.get(o);r&&(this.elementsSet.delete(r),this.idMap.delete(o))}hasElement(o){return this.elementsSet.has(o)}hasMatchingElement(o){for(const r of this.elementsSet)if(o(r))return!0;return!1}getById(o){return this.idMap.get(o)}entries(){return this.idMap.entries()}elements(){return this.elementsSet.values()}get size(){return this.idMap.size}}function xO(){return new mu({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new Jl,floatingId:void 0,syncOnly:!1,nested:!1,onOpenChange:void 0})}function _p(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:xO(),floatingId:void 0,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:Pt,inactiveTriggerProps:Pt,popupProps:Pt}}function B1(n,o,r=!1){return new mu({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:n,floatingId:o,syncOnly:!0,nested:r,onOpenChange:void 0})}const zl=Ge(n=>n.triggerIdProp??n.activeTriggerId),Mp=Ge(n=>n.openProp??n.open),Wy=Ge(n=>(n.popupElement?.id??n.floatingId)||void 0);function U1(n,o){return o!==void 0&&Mp(n)&&zl(n)===o}function bO(n,o){return U1(n,o)?!0:o!==void 0&&Mp(n)&&zl(n)==null&&n.triggerCount===1}const Ap={open:Mp,mounted:Ge(n=>n.mounted),transitionStatus:Ge(n=>n.transitionStatus),floatingRootContext:Ge(n=>n.floatingRootContext),triggerCount:Ge(n=>n.triggerCount),preventUnmountingOnClose:Ge(n=>n.preventUnmountingOnClose),payload:Ge(n=>n.payload),activeTriggerId:zl,activeTriggerElement:Ge(n=>n.mounted?n.activeTriggerElement:null),popupId:Wy,isTriggerActive:Ge((n,o)=>o!==void 0&&zl(n)===o),isOpenedByTrigger:Ge((n,o)=>U1(n,o)),isMountedByTrigger:Ge((n,o)=>o!==void 0&&zl(n)===o&&n.mounted),triggerProps:Ge((n,o)=>o?n.activeTriggerProps:n.inactiveTriggerProps),triggerPopupId:Ge((n,o)=>bO(n,o)?Wy(n):void 0),popupProps:Ge(n=>n.popupProps),popupElement:Ge(n=>n.popupElement),positionerElement:Ge(n=>n.positionerElement)};function yO(n){const{open:o=!1,onOpenChange:r,elements:l={}}=n,c=jr(),d=fo()!=null,m=zn(()=>new mu({open:o,transitionStatus:void 0,onOpenChange:r,referenceElement:l.reference??null,floatingElement:l.floating??null,triggerElements:new Jl,floatingId:c,syncOnly:!1,nested:d})).current;return Qe(()=>{const g={open:o,floatingId:c};l.reference!==void 0&&(g.referenceElement=l.reference,g.domReferenceElement=Et(l.reference)?l.reference:null),l.floating!==void 0&&(g.floatingElement=l.floating),m.update(g)},[o,c,l.reference,l.floating,m]),m.context.onOpenChange=r,m.context.nested=d,m}function vO(n={}){const{nodeId:o,externalTree:r}=n,l=yO(n),c=n.rootContext||l,d=c.useState("referenceElement"),m=c.useState("floatingElement"),g=c.useState("domReferenceElement"),b=c.useState("open"),p=c.useState("floatingId"),[v,x]=h.useState(null),[S,j]=h.useState(void 0),[E,M]=h.useState(void 0),O=h.useRef(null),N=qo(r),T=h.useMemo(()=>({reference:d,floating:m,domReference:g}),[d,m,g]),k=XR({...n,elements:{...T,...v&&{reference:v}}}),C=Et(S)?S:null,U=E===void 0?c.state.floatingElement:E;c.useSyncedValue("referenceElement",S??null),c.useSyncedValue("domReferenceElement",S===void 0?g:C),c.useSyncedValue("floatingElement",U);const A=h.useCallback(ne=>{const $=Et(ne)?{getBoundingClientRect:()=>ne.getBoundingClientRect(),getClientRects:()=>ne.getClientRects(),contextElement:ne}:ne;x($),k.refs.setReference($)},[k.refs]),L=h.useCallback(ne=>{(Et(ne)||ne===null)&&(O.current=ne,j(ne)),(Et(k.refs.reference.current)||k.refs.reference.current===null||ne!==null&&!Et(ne))&&k.refs.setReference(ne)},[k.refs,j]),_=h.useCallback(ne=>{M(ne),k.refs.setFloating(ne)},[k.refs]),K=h.useMemo(()=>({...k.refs,setReference:L,setFloating:_,setPositionReference:A,domReference:O}),[k.refs,L,_,A]),W=h.useMemo(()=>({...k.elements,domReference:g}),[k.elements,g]),ue=h.useMemo(()=>({...k,dataRef:c.context.dataRef,open:b,onOpenChange:c.setOpen,events:c.context.events,floatingId:p,refs:K,elements:W,nodeId:o,rootStore:c}),[k,K,W,o,c,b,p]);return Qe(()=>{g&&(O.current=g)},[g]),Qe(()=>{c.context.dataRef.current.floatingContext=ue;const ne=N?.nodesRef.current.find($=>$.id===o);ne&&(ne.context=ue)}),h.useMemo(()=>({...k,context:ue,refs:K,elements:W,rootStore:c}),[k,K,W,ue,c])}const Jf=up&&Or;function SO(n,o={}){const{enabled:r=!0,delay:l}=o,c="rootStore"in n?n.rootStore:n,{events:d,dataRef:m}=c.context,g=h.useRef(!1),b=h.useRef(null),p=h.useRef(!0),v=qn();h.useEffect(()=>{const S=c.select("domReferenceElement");if(!r)return;const j=Xt(S);function E(){const N=c.select("domReferenceElement");!c.select("open")&&Ht(N)&&N===jn(wt(N))&&(g.current=!0)}function M(){p.current=!0}function O(){p.current=!1}return Ms(yt(j,"blur",E),Jf&&yt(j,"keydown",M,!0),Jf&&yt(j,"pointerdown",O,!0))},[c,r]),h.useEffect(()=>{if(!r)return;function S(j){if(j.reason===Er||j.reason===su){const E=c.select("domReferenceElement");Et(E)&&(b.current=E,g.current=!0)}}return d.on("openchange",S),()=>{d.off("openchange",S)}},[d,r,c]);const x=h.useMemo(()=>{function S(){g.current=!1,b.current=null}return{onMouseLeave(){S()},onFocus(j){const E=j.currentTarget;if(g.current){if(b.current===E)return;S()}const M=Dn(j.nativeEvent);if(Et(M)){if(Jf&&!j.relatedTarget){if(!p.current&&!cu(M))return}else if(!_C(M))return}const O=Yc(j.relatedTarget,c.context.triggerElements),{nativeEvent:N,currentTarget:T}=j,k=typeof l=="function"?l():l;if(c.select("open")&&O||k===0||k===void 0){c.setOpen(!0,Ct(Dl,N,T));return}v.start(k,()=>{g.current||c.setOpen(!0,Ct(Dl,N,T))})},onBlur(j){S();const E=j.relatedTarget,M=j.nativeEvent,O=Et(E)&&E.hasAttribute($l("focus-guard"))&&E.getAttribute("data-type")==="outside";v.start(0,()=>{const N=c.select("domReferenceElement"),T=jn(wt(N));!E&&T===N||ot(m.current.floatingContext?.refs.floating.current,T)||ot(N,T)||O||Yc(E??T,c.context.triggerElements)||c.setOpen(!1,Ct(Dl,M))})}}},[m,l,c,v]);return h.useMemo(()=>r?{reference:x,trigger:x}:{},[r,x])}class Dp{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new ms,this.restTimeout=new ms,this.handleCloseOptions=void 0}static create(){return new Dp}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose}const $c=new WeakMap;function Xc(n){if(!n.performedPointerEventsMutation)return;const o=n.pointerEventsScopeElement;o&&$c.get(o)===n&&(n.pointerEventsScopeElement?.style.removeProperty("pointer-events"),n.pointerEventsReferenceElement?.style.removeProperty("pointer-events"),n.pointerEventsFloatingElement?.style.removeProperty("pointer-events"),$c.delete(o)),n.performedPointerEventsMutation=!1,n.pointerEventsScopeElement=null,n.pointerEventsReferenceElement=null,n.pointerEventsFloatingElement=null}function H1(n,o){const{scopeElement:r,referenceElement:l,floatingElement:c}=o,d=$c.get(r);d&&d!==n&&Xc(d),Xc(n),n.performedPointerEventsMutation=!0,n.pointerEventsScopeElement=r,n.pointerEventsReferenceElement=l,n.pointerEventsFloatingElement=c,$c.set(r,n),r.style.pointerEvents="none",l.style.pointerEvents="auto",c.style.pointerEvents="auto"}function P1(n){const o=n.context.dataRef.current,r=zn(()=>o.hoverInteractionState??Dp.create()).current;return o.hoverInteractionState||(o.hoverInteractionState=r),fp(o.hoverInteractionState.disposeEffect),o.hoverInteractionState}function Y1(n,o={}){const{enabled:r=!0,closeDelay:l=0,nodeId:c}=o,d="rootStore"in n?n.rootStore:n,m=d.useState("open"),g=d.useState("floatingElement"),b=d.useState("domReferenceElement"),{dataRef:p}=d.context,v=qo(),x=fo(),S=P1(d),j=qn(),E=at(()=>$0(p.current.openEvent?.type,S.interactedInside)),M=at(()=>AC(p.current.openEvent?.type)),O=at(()=>{Xc(S)});Qe(()=>{m||(S.pointerType=void 0,S.restTimeoutPending=!1,S.interactedInside=!1,O())},[m,S,O]),h.useEffect(()=>O,[O]),Qe(()=>{if(r&&m&&S.handleCloseOptions?.blockPointerEvents&&M()&&Et(b)&&g){const N=b,T=g,k=wt(g),C=v?.nodesRef.current.find(_=>_.id===x)?.context?.elements.floating;C&&(C.style.pointerEvents="");const U=S.pointerEventsScopeElement!==T?S.pointerEventsScopeElement:null,A=C!==T?C:null,L=S.handleCloseOptions?.getScope?.()??U??A??N.closest("[data-rootownerid]")??k.body;return H1(S,{scopeElement:L,referenceElement:N,floatingElement:T}),()=>{O()}}},[r,m,b,g,S,M,v,x,O]),h.useEffect(()=>{if(!r)return;function N(){return!!(v&&x&&Vo(v.nodesRef.current,x).length>0)}function T(_){const K=Nm(l,"close",S.pointerType),W=()=>{d.setOpen(!1,Ct(fn,_)),v?.events.emit("floating.closed",_)};K?S.openChangeTimeout.start(K,W):(S.openChangeTimeout.clear(),W())}function k(_){const K=Dn(_);if(!kC(K)){S.interactedInside=!1;return}S.interactedInside=K?.closest("[aria-haspopup]")!=null}function C(){S.openChangeTimeout.clear(),j.clear(),v?.events.off("floating.closed",A),O()}function U(_){if(N()&&v){v.events.on("floating.closed",A);return}if(Yc(_.relatedTarget,d.context.triggerElements))return;const K=p.current.floatingContext?.nodeId??c,W=_.relatedTarget;if(!(v&&K&&Et(W)&&Vo(v.nodesRef.current,K,!1).some(ne=>ot(ne.context?.elements.floating,W)))){if(S.handler){S.handler(_);return}O(),M()&&!E()&&T(_)}}function A(_){!v||!x||N()||j.start(0,()=>{v.events.off("floating.closed",A),d.setOpen(!1,Ct(fn,_)),v.events.emit("floating.closed",_)})}const L=g;return Ms(L&&yt(L,"mouseenter",C),L&&yt(L,"mouseleave",U),L&&yt(L,"pointerdown",k,!0),()=>{v?.events.off("floating.closed",A)})},[r,g,d,p,l,c,M,E,O,S,v,x,j])}const EO={current:null};function V1(n,o={}){const{enabled:r=!0,delay:l=0,handleClose:c=null,mouseOnly:d=!1,restMs:m=0,move:g=!0,triggerElementRef:b=EO,externalTree:p,isActiveTrigger:v=!0,getHandleCloseContext:x,isClosing:S,shouldOpen:j}=o,E="rootStore"in n?n.rootStore:n,{dataRef:M,events:O}=E.context,N=qo(p),T=P1(E),k=h.useRef(!1),C=an(c),U=an(l),A=an(m),L=an(r),_=an(j),K=an(S),W=at(()=>$0(M.current.openEvent?.type,T.interactedInside)),ue=at(()=>_.current?.()!==!1),ne=at((q,w,D)=>{const H=E.context.triggerElements;if(H.hasElement(w))return!q||!ot(q,w);if(!Et(D))return!1;const B=D;return H.hasMatchingElement(P=>ot(P,B))&&(!q||!ot(q,B))}),$=at(()=>{if(!T.handler)return;wt(E.select("domReferenceElement")).removeEventListener("mousemove",T.handler),T.handler=void 0}),oe=at(()=>{Xc(T)});return v&&(T.handleCloseOptions=C.current?.__options),h.useEffect(()=>$,[$]),h.useEffect(()=>{if(!r)return;function q(w){w.open?k.current=!1:(k.current=w.reason===fn,$(),T.openChangeTimeout.clear(),T.restTimeout.clear(),T.blockMouseMove=!0,T.restTimeoutPending=!1)}return O.on("openchange",q),()=>{O.off("openchange",q)}},[r,O,T,$]),h.useEffect(()=>{if(!r)return;function q(B,P=!0){const z=Nm(U.current,"close",T.pointerType);z?T.openChangeTimeout.start(z,()=>{E.setOpen(!1,Ct(fn,B)),N?.events.emit("floating.closed",B)}):P&&(T.openChangeTimeout.clear(),E.setOpen(!1,Ct(fn,B)),N?.events.emit("floating.closed",B))}const w=b.current??(v?E.select("domReferenceElement"):null);if(!Et(w))return;function D(B){if(T.openChangeTimeout.clear(),T.blockMouseMove=!1,d&&!ql(T.pointerType))return;const P=wy(A.current),z=Nm(U.current,"open",T.pointerType),X=Dn(B),I=B.currentTarget??null,V=E.select("domReferenceElement");let Q=I;if(Et(X)&&!E.context.triggerElements.hasElement(X)){for(const He of E.context.triggerElements.elements())if(ot(He,X)){Q=He;break}}Et(I)&&Et(V)&&!E.context.triggerElements.hasElement(I)&&ot(I,V)&&(Q=V);const Y=Q==null?!1:ne(V,Q,X),fe=E.select("open"),re=K.current?.()??E.select("transitionStatus")==="ending",de=!fe&&re&&k.current,_e=!Y&&Et(Q)&&Et(V)&&ot(V,Q)&&de,Ye=P>0&&!z,Re=Y&&(fe||de)||_e,Le=!fe||Y;if(Re){ue()&&E.setOpen(!0,Ct(fn,B,Q));return}Ye||(z?T.openChangeTimeout.start(z,()=>{Le&&ue()&&E.setOpen(!0,Ct(fn,B,Q))}):Le&&ue()&&E.setOpen(!0,Ct(fn,B,Q)))}function H(B){if(W()){oe();return}$();const P=E.select("domReferenceElement"),z=wt(P);T.restTimeout.clear(),T.restTimeoutPending=!1;const X=M.current.floatingContext??x?.();if(Yc(B.relatedTarget,E.context.triggerElements))return;if(C.current&&X){E.select("open")||T.openChangeTimeout.clear();const V=b.current;T.handler=C.current({...X,tree:N,x:B.clientX,y:B.clientY,onClose(){oe(),$(),L.current&&!W()&&V===E.select("domReferenceElement")&&q(B,!0)}}),z.addEventListener("mousemove",T.handler),T.handler(B);return}(T.pointerType!=="touch"||!ot(E.select("floatingElement"),B.relatedTarget))&&q(B)}return g?Ms(yt(w,"mousemove",D,{once:!0}),yt(w,"mouseenter",D),yt(w,"mouseleave",H)):Ms(yt(w,"mouseenter",D),yt(w,"mouseleave",H))},[$,oe,M,U,E,r,C,T,v,ne,W,d,g,A,b,N,L,x,K,ue]),h.useMemo(()=>{if(!r)return;function q(w){T.pointerType=w.pointerType}return{onPointerDown:q,onPointerEnter:q,onMouseMove(w){const{nativeEvent:D}=w,H=w.currentTarget,B=E.select("domReferenceElement"),P=E.select("open"),z=ne(B,H,w.target);if(d&&!ql(T.pointerType))return;if(P&&z&&T.handleCloseOptions?.blockPointerEvents){const V=E.select("floatingElement");if(V){const Q=T.handleCloseOptions?.getScope?.()??H.ownerDocument.body;H1(T,{scopeElement:Q,referenceElement:H,floatingElement:V})}}const X=wy(A.current);if(P&&!z||X===0||!z&&T.restTimeoutPending&&w.movementX**2+w.movementY**2<2)return;T.restTimeout.clear();function I(){if(T.restTimeoutPending=!1,W())return;const V=E.select("open");!T.blockMouseMove&&(!V||z)&&ue()&&E.setOpen(!0,Ct(fn,D,H))}T.pointerType==="touch"?io.flushSync(()=>{I()}):z&&P?I():(T.restTimeoutPending=!0,T.restTimeout.start(X,I))}}},[r,T,W,ne,d,E,A,ue])}const NO="Escape";function hu(n,o,r){switch(n){case"vertical":return o;case"horizontal":return r;default:return o||r}}function vc(n,o){return hu(o,n===q0||n===pp,n===lu||n===iu)}function Wf(n,o,r){return hu(o,n===pp,r?n===lu:n===iu)||n==="Enter"||n===" "||n===""}function jO(n,o,r){return hu(o,r?n===lu:n===iu,n===pp)}function TO(n,o,r,l){const c=r?n===iu:n===lu,d=n===q0;return o==="both"||o==="horizontal"&&l?n===NO:hu(o,c,d)}function wO(n,o){const{listRef:r,activeIndex:l,onNavigate:c=()=>{},enabled:d=!0,selectedIndex:m=null,allowEscape:g=!1,loopFocus:b=!1,nested:p=!1,rtl:v=!1,virtual:x=!1,focusItemOnOpen:S="auto",focusItemOnHover:j=!0,openOnArrowKeyDown:E=!0,disabledIndices:M=void 0,orientation:O="vertical",parentOrientation:N,id:T,resetOnPointerLeave:k=!0,externalTree:C,grid:U}=o,A=U!=null,L="rootStore"in n?n.rootStore:n,_=L.useState("open"),K=L.useState("floatingElement"),W=L.useState("domReferenceElement"),ue=L.context.dataRef,ne=Em(K),$=Sm(W),oe=an(ne),q=fo(),w=qo(C),D=h.useRef(S),H=h.useRef(m??-1),B=h.useRef(null),P=h.useRef(!0),z=at(ee=>{c(H.current===-1?null:H.current,ee)}),X=h.useRef(!!K),I=h.useRef(_),V=h.useRef(!1),Q=h.useRef(!1),Y=h.useRef(null),fe=an(M),re=an(_),de=an(m),_e=an(k),Ye=Gl(),Re=Gl(),Le=at(()=>{function ee(Ee){x?w?.events.emit("virtualfocus",Ee):Y.current=kc(Ee,{sync:V.current,preventScroll:!0})}const F=r.current[H.current],ie=Q.current;F&&ee(F),(V.current?Ee=>Ee():Ee=>Ye.request(Ee))(()=>{const Ee=r.current[H.current]||F;if(!Ee)return;F||ee(Ee),ye&&(ie||!P.current)&&Ee.scrollIntoView?.({block:"nearest",inline:"nearest"})})});Qe(()=>{ue.current.orientation=O},[ue,O]),Qe(()=>{d&&(_&&K?(H.current=m??-1,D.current&&m!=null&&(Q.current=!0,z())):X.current&&(H.current=-1,z()))},[d,_,K,m,z]),Qe(()=>{if(d){if(!_){V.current=!1;return}if(K)if(l==null){if(V.current=!1,de.current!=null)return;if(X.current&&(H.current=-1,Le()),(!I.current||!X.current)&&D.current&&(B.current!=null||D.current===!0&&B.current==null)){let ee=0;const F=()=>{r.current[0]==null?(ee<2&&(ee?Z=>Re.request(Z):queueMicrotask)(F),ee+=1):(H.current=B.current==null||Wf(B.current,O,v)||p?Yf(r):ky(r),B.current=null,z())};F()}}else Oy(r.current,l)||(H.current=l,Le(),Q.current=!1)}},[d,_,K,l,de,p,r,O,v,z,Le,Re]),Qe(()=>{if(!d||K||!w||x||!X.current)return;const ee=w.nodesRef.current,F=ee.find(Ee=>Ee.id===q)?.context?.elements.floating,ie=jn(wt(W??F??null)),Z=ee.some(Ee=>Ee.context&&ot(Ee.context.elements.floating,ie));F&&!Z&&P.current&&F.focus({preventScroll:!0})},[d,K,W,w,q,x]),Qe(()=>{I.current=_,X.current=!!K}),Qe(()=>{_||(B.current=null,D.current=S)},[_,S]);const He=l!=null,ge=at(ee=>{if(!re.current)return;const F=r.current.indexOf(ee.currentTarget);F!==-1&&(H.current!==F||l!==F)&&(H.current=F,z(ee))}),pe=at(()=>N??w?.nodesRef.current.find(ee=>ee.id===q)?.context?.dataRef?.current.orientation),ve=at(()=>Yf(r,fe.current)),Ue=at(ee=>{if(P.current=!1,V.current=!0,ee.which===229||!re.current&&ee.currentTarget===oe.current)return;if(p&&TO(ee.key,O,v,A)){vc(ee.key,pe())||Ns(ee),L.setOpen(!1,Ct(bm,ee.nativeEvent)),Ht(W)&&(x?w?.events.emit("virtualfocus",W):W.focus());return}const F=H.current,ie=Yf(r,M),Z=ky(r,M);if($||(ee.key==="Home"&&(Ns(ee),H.current=ie,z(ee)),ee.key==="End"&&(Ns(ee),H.current=Z,z(ee))),U!=null){const Ee=U(ee,H.current,r,O,b,v,M,ie,Z);if(Ee!=null&&(H.current=Ee,z(ee)),O==="both")return}if(vc(ee.key,O)){if(Ns(ee),_&&!x&&jn(ee.currentTarget.ownerDocument)===ee.currentTarget){H.current=Wf(ee.key,O,v)?ie:Z,z(ee);return}Wf(ee.key,O,v)?b?F>=Z?g&&F!==r.current.length?H.current=-1:(V.current=!1,H.current=ie):H.current=ja(r.current,{startingIndex:F,disabledIndices:M}):H.current=Math.min(Z,ja(r.current,{startingIndex:F,disabledIndices:M})):b?F<=ie?g&&F!==-1?H.current=r.current.length:(V.current=!1,H.current=Z):H.current=ja(r.current,{startingIndex:F,decrement:!0,disabledIndices:M}):H.current=Math.max(ie,ja(r.current,{startingIndex:F,decrement:!0,disabledIndices:M})),Oy(r.current,H.current)&&(H.current=-1),z(ee)}}),ye=h.useMemo(()=>({onFocus(F){V.current=!0,ge(F)},onClick:({currentTarget:F})=>F.focus({preventScroll:!0}),onMouseMove(F){V.current=!0,Q.current=!1,j&&ge(F)},onPointerLeave(F){if(!re.current||!P.current||F.pointerType==="touch")return;V.current=!0;const ie=F.relatedTarget;if(!(!j||r.current.includes(ie))&&_e.current&&(Y.current?.(),Y.current=null,H.current=-1,z(F),!x)){const Z=oe.current,Ee=jn(wt(Z));Z&&ot(Z,Ee)&&Z.focus({preventScroll:!0})}}}),[ge,re,oe,j,r,z,_e,x]),De=h.useMemo(()=>x&&_&&He&&{"aria-activedescendant":`${T}-${l}`},[x,_,He,T,l]),Pe=h.useMemo(()=>({"aria-orientation":O==="both"?void 0:O,...$?{}:De,onKeyDown(ee){if(ee.key==="Tab"&&ee.shiftKey&&_&&!x){const F=Dn(ee.nativeEvent);if(F&&!ot(oe.current,F))return;Ns(ee),L.setOpen(!1,Ct(Nr,ee.nativeEvent)),Ht(W)&&W.focus();return}Ue(ee)},onPointerMove(){P.current=!0}}),[De,Ue,oe,O,$,L,_,x,W]),Ie=h.useMemo(()=>{function ee(Z){L.setOpen(!0,Ct(bm,Z.nativeEvent,Z.currentTarget))}function F(Z){S==="auto"&&V0(Z.nativeEvent)&&(D.current=!x)}function ie(Z){D.current=S,S==="auto"&&F0(Z.nativeEvent)&&(D.current=!0)}return{onKeyDown(Z){const Ee=L.select("open");P.current=!1;const Xe=Z.key.startsWith("Arrow"),Ne=jO(Z.key,pe(),v),Me=vc(Z.key,O),Je=(p?Ne:Me)||Z.key==="Enter"||Z.key.trim()==="";if(x&&Ee)return Ue(Z);if(!(!Ee&&!E&&Xe)){if(Je){const nt=vc(Z.key,pe());B.current=p&&nt?null:Z.key}if(p){Ne&&(Ns(Z),Ee?(H.current=ve(),z(Z)):ee(Z));return}Me&&(de.current!=null&&(H.current=de.current),Ns(Z),!Ee&&E?ee(Z):Ue(Z),Ee&&z(Z))}},onFocus(Z){L.select("open")&&!x&&(H.current=-1,z(Z))},onPointerDown:ie,onPointerEnter:ie,onMouseDown:F,onClick:F}},[Ue,S,ve,p,z,L,E,O,pe,v,de,x]),we=h.useMemo(()=>({...De,...Ie}),[De,Ie]);return h.useMemo(()=>d?{reference:we,floating:Pe,item:ye,trigger:Ie}:{},[d,we,Pe,Ie,ye])}function CO(n,o){const{listRef:r,elementsRef:l,activeIndex:c,onMatch:d,disabledIndices:m,onTyping:g,enabled:b=!0,resetMs:p=750,selectedIndex:v=null}=o,x="rootStore"in n?n.rootStore:n,S=x.useState("open"),j=qn(),E=h.useRef(""),M=h.useRef(v??c??-1),O=h.useRef(null),N=at(C=>{function U(oe){const q=l?.current[oe];return!q||uu(q)}function A(oe){return U(oe)?m==null||!Q0(Pc,oe,m):!1}function L(oe,q,w=0){if(oe.length===0)return-1;const D=(w%oe.length+oe.length)%oe.length,H=q.toLowerCase();for(let B=0;B<oe.length;B+=1){const P=(D+B)%oe.length;if(!(!oe[P]?.toLowerCase().startsWith(H)||!A(P)))return P}return-1}const _=r.current;if(E.current.length>0&&C.key===" "&&(Ns(C),g?.(!0)),E.current.length>0&&E.current[0]!==" "&&L(_,E.current)===-1&&C.key!==" "&&g?.(!1),_==null||C.key.length!==1||C.ctrlKey||C.metaKey||C.altKey)return;S&&C.key!==" "&&(Ns(C),g?.(!0));const K=E.current==="";K&&(M.current=v??c??-1),_.every((oe,q)=>oe&&A(q)?oe[0]?.toLowerCase()!==oe[1]?.toLowerCase():!0)&&E.current===C.key&&(E.current="",M.current=O.current),E.current+=C.key,j.start(p,()=>{E.current="",M.current=O.current,g?.(!1)});const ne=((K?v??c??-1:M.current)??0)+1,$=L(_,E.current,ne);$!==-1?(d?.($),O.current=$):C.key!==" "&&(E.current="",g?.(!1))}),T=at(C=>{const U=C.relatedTarget,A=x.select("domReferenceElement"),L=x.select("floatingElement");ot(A,U)||ot(L,U)||(j.clear(),E.current="",M.current=O.current,g?.(!1))});Qe(()=>{!S&&v!==null||(j.clear(),O.current=null,E.current!==""&&(E.current=""))},[S,v,j]),Qe(()=>{S&&E.current===""&&(M.current=v??c??-1)},[S,v,c]);const k=h.useMemo(()=>({onKeyDown:N,onBlur:T}),[N,T]);return h.useMemo(()=>b?{reference:k,floating:k}:{},[b,k])}const ev=.1,RO=ev*ev,Bt=.5;function Sc(n,o,r,l,c,d){return l>=o!=d>=o&&n<=(c-r)*(o-l)/(d-l)+r}function Ec(n,o,r,l,c,d,m,g,b,p){let v=!1;return Sc(n,o,r,l,c,d)&&(v=!v),Sc(n,o,c,d,m,g)&&(v=!v),Sc(n,o,m,g,b,p)&&(v=!v),Sc(n,o,b,p,r,l)&&(v=!v),v}function OO(n,o,r){return n>=r.x&&n<=r.x+r.width&&o>=r.y&&o<=r.y+r.height}function Nc(n,o,r,l,c,d){const m=Math.min(r,c),g=Math.max(r,c),b=Math.min(l,d),p=Math.max(l,d);return n>=m&&n<=g&&o>=b&&o<=p}function F1(n={}){const{blockPointerEvents:o=!1}=n,r=new ms,l=({x:c,y:d,placement:m,elements:g,onClose:b,nodeId:p,tree:v})=>{const x=m?.split("-")[0];let S=!1,j=null,E=null,M=typeof performance<"u"?performance.now():0;function O(T,k){const C=performance.now(),U=C-M;if(j===null||E===null||U===0)return j=T,E=k,M=C,!1;const A=T-j,L=k-E,_=A*A+L*L,K=U*U*RO;return j=T,E=k,M=C,_<K}function N(){r.clear(),b()}return function(k){r.clear();const C=g.domReference,U=g.floating;if(!C||!U||x==null||c==null||d==null)return;const{clientX:A,clientY:L}=k,_=Dn(k),K=k.type==="mouseleave",W=ot(U,_),ue=ot(C,_);if(W&&(S=!0,!K))return;if(ue&&(S=!1,!K)){S=!0;return}if(K&&Et(k.relatedTarget)&&ot(U,k.relatedTarget))return;function ne(){return!!(v&&Vo(v.nodesRef.current,p).length>0)}function $(){ne()||N()}if(ne())return;const oe=C.getBoundingClientRect(),q=U.getBoundingClientRect(),w=c>q.right-q.width/2,D=d>q.bottom-q.height/2,H=q.width>oe.width,B=q.height>oe.height,P=(H?oe:q).left,z=(H?oe:q).right,X=(B?oe:q).top,I=(B?oe:q).bottom;if(x==="top"&&d>=oe.bottom-1||x==="bottom"&&d<=oe.top+1||x==="left"&&c>=oe.right-1||x==="right"&&c<=oe.left+1){$();return}let V=!1;switch(x){case"top":V=Nc(A,L,P,oe.top+1,z,q.bottom-1);break;case"bottom":V=Nc(A,L,P,q.top+1,z,oe.bottom-1);break;case"left":V=Nc(A,L,q.right-1,I,oe.left+1,X);break;case"right":V=Nc(A,L,oe.right-1,I,q.left+1,X);break}if(V)return;if(S&&!OO(A,L,oe)){$();return}if(!K&&O(A,L)){$();return}let Q=!1;switch(x){case"top":{const Y=H?Bt/2:Bt*4,fe=H||w?c+Y:c-Y,re=H?c-Y:w?c+Y:c-Y,de=d+Bt+1,_e=w||H?q.bottom-Bt:q.top,Ye=w?H?q.bottom-Bt:q.top:q.bottom-Bt;Q=Ec(A,L,fe,de,re,de,q.left,_e,q.right,Ye);break}case"bottom":{const Y=H?Bt/2:Bt*4,fe=H||w?c+Y:c-Y,re=H?c-Y:w?c+Y:c-Y,de=d-Bt,_e=w||H?q.top+Bt:q.bottom,Ye=w?H?q.top+Bt:q.bottom:q.top+Bt;Q=Ec(A,L,fe,de,re,de,q.left,_e,q.right,Ye);break}case"left":{const Y=B?Bt/2:Bt*4,fe=B||D?d+Y:d-Y,re=B?d-Y:D?d+Y:d-Y,de=c+Bt+1,_e=D||B?q.right-Bt:q.left,Ye=D?B?q.right-Bt:q.left:q.right-Bt;Q=Ec(A,L,_e,q.top,Ye,q.bottom,de,fe,de,re);break}case"right":{const Y=B?Bt/2:Bt*4,fe=B||D?d+Y:d-Y,re=B?d-Y:D?d+Y:d-Y,de=c-Bt,_e=D||B?q.left+Bt:q.right,Ye=D?B?q.left+Bt:q.right:q.left+Bt;Q=Ec(A,L,de,fe,de,re,_e,q.top,Ye,q.bottom);break}}Q?S||r.start(40,$):$()}};return l.__options={...n,blockPointerEvents:o},l}const kO=h.createContext(void 0);function G1(n){return h.useContext(kO)}const _O="ArrowUp",MO="ArrowDown",AO="ArrowLeft",DO="ArrowRight",zO="Home",LO="End",IO=new Set([AO,DO]),BO=new Set([_O,MO]),UO=new Set([...IO,...BO]),zp=new Set([...UO,zO,LO]);function Lp(n){return n==="starting"?oR:Pt}const HO={...Ql,...tu},PO=h.forwardRef(function(o,r){const{render:l,className:c,style:d,finalFocus:m,...g}=o,{store:b}=Rr(),{side:p,align:v}=z0(),x=G1()!=null,S=b.useState("open"),j=b.useState("transitionStatus"),E=b.useState("popupProps"),M=b.useState("mounted"),O=b.useState("instantType"),N=b.useState("activeTriggerElement"),T=b.useState("parent"),k=b.useState("lastOpenChangeReason"),C=b.useState("rootId"),U=b.useState("floatingRootContext"),A=b.useState("floatingTreeRoot"),L=b.useState("closeDelay"),_=b.useState("activeTriggerElement"),K=b.useState("hoverEnabled"),W=b.useState("disabled"),ue=b.useState("openMethod"),ne=T.type==="context-menu";au({open:S,ref:b.context.popupRef,onComplete(){S&&b.context.onOpenChangeComplete?.(!0)}}),h.useEffect(()=>{function D(H){b.setOpen(!1,Ct(H.reason,H.domEvent))}return A.events.on("close",D),()=>{A.events.off("close",D)}},[A.events,b]),Y1(U,{enabled:K&&!W&&!ne&&T.type!=="menubar",closeDelay:L});const $=h.useCallback(D=>{b.set("popupElement",D)},[b]),oe={transitionStatus:j,side:p,align:v,open:S,nested:T.type==="menu",instant:O},q=mn("div",o,{state:oe,ref:[r,b.context.popupRef,$],stateAttributesMapping:HO,props:[E,{onKeyDown(D){x&&zp.has(D.key)&&D.stopPropagation()}},Lp(j),g,{"data-rootownerid":C}]});let w=T.type===void 0||ne;return(N||T.type==="menubar"&&k!==ip)&&(w=!0),i.jsx(jp,{context:U,openInteractionType:ue,modal:ne,disabled:!M,returnFocus:m===void 0?w:m,initialFocus:T.type!=="menu",restoreFocus:!0,externalTree:T.type!=="menubar"?A:void 0,previousFocusableElement:_,nextFocusableElement:T.type===void 0?b.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:T.type===void 0?b.context.beforeContentFocusGuardRef:void 0,children:q})}),q1=h.createContext(void 0);function YO(){const n=h.useContext(q1);if(n===void 0)throw new Error(En(32));return n}const VO=h.forwardRef(function(o,r){const{keepMounted:l=!1,...c}=o,{store:d}=Rr();return d.useState("mounted")||l?i.jsx(q1.Provider,{value:l,children:i.jsx(vp,{ref:r,...c})}):null});function Ip(n){return lp(19)?n:n?"true":void 0}const FO=h.createContext(void 0);function $1(){return h.useContext(FO)?.direction??"ltr"}const GO=n=>({name:"arrow",options:n,async fn(o){const{x:r,y:l,placement:c,rects:d,platform:m,elements:g,middlewareData:b}=o,{element:p,padding:v=0,offsetParent:x="real"}=co(n,o)||{};if(p==null)return{};const S=K0(v),j={x:r,y:l},E=xp(c),M=gp(E),O=await m.getDimensions(p),N=E==="y",T=N?"top":"left",k=N?"bottom":"right",C=N?"clientHeight":"clientWidth",U=d.reference[M]+d.reference[E]-j[E]-d.floating[M],A=j[E]-d.reference[E],L=x==="real"?await m.getOffsetParent?.(p):g.floating;let _=g.floating[C]||d.floating[M];(!_||!await m.isElement?.(L))&&(_=g.floating[C]||d.floating[M]);const K=U/2-A/2,W=_/2-O[M]/2-1,ue=Math.min(S[T],W),ne=Math.min(S[k],W),$=ue,oe=_-O[M]-ne,q=_/2-O[M]/2+K,w=X0($,q,oe),D=!b.arrow&&Go(c)!=null&&q!==w&&d.reference[M]/2-(q<$?ue:ne)-O[M]/2<0,H=D?q<$?q-$:q-oe:0;return{[E]:j[E]+H,data:{[E]:w,centerOffset:q-w-H,...D&&{alignmentOffset:H}},reset:D}}}),qO=(n,o)=>({...GO(n),options:[n,o]}),$O=eO().fn,XO={name:"hide",async fn(n){const{width:o,height:r,x:l,y:c}=n.rects.reference,d=o===0&&r===0&&l===0&&c===0;return{data:{referenceHidden:(await $O(n)).data?.referenceHidden||d}}}},Mc={sideX:"left",sideY:"top"},X1={name:"adaptiveOrigin",async fn(n){const{x:o,y:r,rects:{floating:l},elements:{floating:c},platform:d,strategy:m,placement:g}=n,b=Xt(c),p=b.getComputedStyle(c);if(!(p.transitionDuration!=="0s"&&p.transitionDuration!==""))return{x:o,y:r,data:Mc};const x=await d.getOffsetParent?.(c);let S={width:0,height:0};if(m==="fixed"&&b?.visualViewport)S={width:b.visualViewport.width,height:b.visualViewport.height};else if(x===b){const T=wt(c);S={width:T.documentElement.clientWidth,height:T.documentElement.clientHeight}}else await d.isElement?.(x)&&(S=await d.getDimensions(x));const j=Fn(g);let E=o,M=r;j==="left"&&(E=S.width-(o+l.width)),j==="top"&&(M=S.height-(r+l.height));const O=j==="left"?"right":Mc.sideX,N=j==="top"?"bottom":Mc.sideY;return{x:E,y:M,data:{sideX:O,sideY:N}}}};function K1(n,o,r){const l=n==="inline-start"||n==="inline-end";return{top:"top",right:l?r?"inline-start":"inline-end":"right",bottom:"bottom",left:l?r?"inline-end":"inline-start":"left"}[o]}function tv(n,o,r){const{rects:l,placement:c}=n;return{side:K1(o,Fn(c),r),align:Go(c)||"center",anchor:{width:l.reference.width,height:l.reference.height},positioner:{width:l.floating.width,height:l.floating.height}}}function Q1(n){const{anchor:o,positionMethod:r="absolute",side:l="bottom",sideOffset:c=0,align:d="center",alignOffset:m=0,collisionBoundary:g,collisionPadding:b=5,sticky:p=!1,arrowPadding:v=5,disableAnchorTracking:x=!1,inline:S,keepMounted:j=!1,floatingRootContext:E,mounted:M,collisionAvoidance:O,shiftCrossAxis:N=!1,nodeId:T,adaptiveOrigin:k,lazyFlip:C=!1,externalTree:U}=n,[A,L]=h.useState(null);!M&&A!==null&&L(null);const _=O.side||"flip",K=O.align||"flip",W=O.fallbackAxisSide||"end",ue=typeof o=="function"?o:void 0,ne=at(ue),$=ue?ne:o,oe=an(o),q=an(M),D=$1()==="rtl",H=A||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":D?"left":"right","inline-start":D?"right":"left"}[l],B=d==="center"?H:`${H}-${d}`;let P=b;const z=1,X=l==="bottom"?z:0,I=l==="top"?z:0,V=l==="right"?z:0,Q=l==="left"?z:0;typeof P=="number"?P={top:P+X,right:P+Q,bottom:P+I,left:P+V}:P&&(P={top:(P.top||0)+X,right:(P.right||0)+Q,bottom:(P.bottom||0)+I,left:(P.left||0)+V});const Y={boundary:g==="clipping-ancestors"?"clippingAncestors":g,padding:P},fe=h.useRef(null),re=an(c),de=an(m),_e=typeof c!="function"?c:0,Ye=typeof m!="function"?m:0,Re=[];S&&Re.push(S),Re.push(KR(et=>{const je=tv(et,l,D),Ce=typeof re.current=="function"?re.current(je):re.current,qe=typeof de.current=="function"?de.current(je):de.current;return{mainAxis:Ce,crossAxis:qe,alignmentAxis:qe}},[_e,Ye,D,l]));const Le=K==="none"&&_!=="shift",He=!Le&&(p||N||_==="shift"),ge=_==="none"?null:JR({...Y,padding:{top:P.top+z,right:P.right+z,bottom:P.bottom+z,left:P.left+z},mainAxis:!N&&_==="flip",crossAxis:K==="flip"?"alignment":!1,fallbackAxisSideDirection:W}),pe=Le?null:QR(et=>{const je=wt(et.elements.floating).documentElement;return{...Y,rootBoundary:N?{x:0,y:0,width:je.clientWidth,height:je.clientHeight}:void 0,mainAxis:K!=="none",crossAxis:He,limiter:p||N?void 0:ZR(Ce=>{if(!fe.current)return{};const{width:qe,height:te}=fe.current.getBoundingClientRect(),xe=as(Fn(Ce.placement)),Oe=xe==="y"?qe:te,We=xe==="y"?P.left+P.right:P.top+P.bottom;return{offset:Oe/2+We/2}})}},[Y,p,N,P,K]);_==="shift"||K==="shift"||d==="center"?Re.push(pe,ge):Re.push(ge,pe),Re.push(WR({...Y,apply({elements:{floating:et},availableWidth:je,availableHeight:Ce,rects:qe}){if(!q.current)return;const te=et.style;te.setProperty("--available-width",`${je}px`),te.setProperty("--available-height",`${Ce}px`);const xe=Xt(et).devicePixelRatio||1,{x:Oe,y:We,width:rt,height:ct}=qe.reference,lt=(Math.round((Oe+rt)*xe)-Math.round(Oe*xe))/xe,Ft=(Math.round((We+ct)*xe)-Math.round(We*xe))/xe;te.setProperty("--anchor-width",`${lt}px`),te.setProperty("--anchor-height",`${Ft}px`)}}),qO(et=>({element:fe.current||wt(et.elements.floating).createElement("div"),padding:v,offsetParent:"floating"}),[v]),{name:"transformOrigin",fn(et){const{elements:je,middlewareData:Ce,placement:qe,rects:te,y:xe}=et,Oe=Fn(qe),We=as(Oe),rt=fe.current,ct=Ce.arrow?.x||0,lt=Ce.arrow?.y||0,Ft=rt?.clientWidth||0,$n=rt?.clientHeight||0,Kt=ct+Ft/2,pn=lt+$n/2,mo=Math.abs(Ce.shift?.y||0),Ln=te.reference.height/2,zs=typeof c=="function"?c(tv(et,l,D)):c,ei=mo>zs,hs={top:`${Kt}px calc(100% + ${zs}px)`,bottom:`${Kt}px ${-zs}px`,left:`calc(100% + ${zs}px) ${pn}px`,right:`${-zs}px ${pn}px`}[Oe],sn=`${Kt}px ${te.reference.y+Ln-xe}px`;return je.floating.style.setProperty("--transform-origin",He&&We==="y"&&ei?sn:hs),{}}},XO,k),Qe(()=>{!M&&E&&E.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[M,E]);const ve=h.useMemo(()=>({elementResize:!x&&typeof ResizeObserver<"u",layoutShift:!x&&typeof IntersectionObserver<"u"}),[x]),{refs:Ue,elements:ye,x:De,y:Pe,middlewareData:Ie,update:we,placement:ee,context:F,isPositioned:ie,floatingStyles:Z}=vO({rootContext:E,open:j?M:void 0,placement:B,middleware:Re,strategy:r,whileElementsMounted:j?void 0:(...et)=>$y(...et,ve),nodeId:T,externalTree:U}),{sideX:Ee,sideY:Xe}=Ie.adaptiveOrigin||Mc,Ne=ie?r:"fixed",Me=h.useMemo(()=>{const et=k?{position:Ne,[Ee]:De,[Xe]:Pe}:{position:Ne,...Z};return ie||(et.opacity=0),et},[k,Ne,Ee,De,Xe,Pe,Z,ie]),Je=h.useRef(null);Qe(()=>{if(!M)return;const et=oe.current,je=typeof et=="function"?et():et,qe=(nv(je)?je.current:je)||null||null;qe!==Je.current&&(Ue.setPositionReference(qe),Je.current=qe)},[M,Ue,$,oe]),h.useEffect(()=>{if(!M)return;const et=oe.current;typeof et!="function"&&nv(et)&&et.current!==Je.current&&(Ue.setPositionReference(et.current),Je.current=et.current)},[M,Ue,$,oe]),h.useEffect(()=>{if(j&&M&&ye.reference&&ye.floating)return $y(ye.reference,ye.floating,we,ve)},[j,M,ye,we,ve]);const nt=Fn(ee),jt=K1(l,nt,D),kt=Go(ee)||"center",gt=!!Ie.hide?.referenceHidden;Qe(()=>{C&&M&&ie&&L(nt)},[C,M,ie,nt]);const ln=h.useMemo(()=>({position:"absolute",top:Ie.arrow?.y,left:Ie.arrow?.x}),[Ie.arrow]),Jt=Ie.arrow?.centerOffset!==0;return h.useMemo(()=>({positionerStyles:Me,arrowStyles:ln,arrowRef:fe,arrowUncentered:Jt,side:jt,align:kt,physicalSide:nt,anchorHidden:gt,refs:Ue,context:F,isPositioned:ie,update:we}),[Me,ln,fe,Jt,jt,kt,nt,gt,Ue,F,ie,we])}function nv(n){return n!=null&&"current"in n}function KO(n){const{children:o,elementsRef:r,labelsRef:l,onMapChange:c}=n,d=at(c),m=h.useRef(0),g=zn(ZO).current,b=zn(QO).current,[p,v]=h.useState(0),x=h.useRef(p),S=at((N,T)=>{b.set(N,T??null),x.current+=1,v(x.current)}),j=at(N=>{b.delete(N),x.current+=1,v(x.current)}),E=h.useMemo(()=>{const N=new Map;return Array.from(b.keys()).filter(k=>k.isConnected).sort(JO).forEach((k,C)=>{const U=b.get(k)??{};N.set(k,{...U,index:C})}),N},[b,p]);Qe(()=>{if(typeof MutationObserver!="function"||E.size===0)return;const N=new MutationObserver(T=>{const k=new Set,C=U=>k.has(U)?k.delete(U):k.add(U);T.forEach(U=>{U.removedNodes.forEach(C),U.addedNodes.forEach(C)}),k.size===0&&(x.current+=1,v(x.current))});return E.forEach((T,k)=>{k.parentElement&&N.observe(k.parentElement,{childList:!0})}),()=>{N.disconnect()}},[E]),Qe(()=>{x.current===p&&(r.current.length!==E.size&&(r.current.length=E.size),l&&l.current.length!==E.size&&(l.current.length=E.size),m.current=E.size),d(E)},[d,E,r,l,p]),Qe(()=>()=>{r.current=[]},[r]),Qe(()=>()=>{l&&(l.current=[])},[l]);const M=at(N=>(g.add(N),()=>{g.delete(N)}));Qe(()=>{g.forEach(N=>N(E))},[g,E]);const O=h.useMemo(()=>({register:S,unregister:j,subscribeMapChange:M,elementsRef:r,labelsRef:l,nextIndexRef:m}),[S,j,M,r,l,m]);return i.jsx(H0.Provider,{value:O,children:o})}function QO(){return new Map}function ZO(){return new Set}function JO(n,o){const r=n.compareDocumentPosition(o);return r&Node.DOCUMENT_POSITION_FOLLOWING||r&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:r&Node.DOCUMENT_POSITION_PRECEDING||r&Node.DOCUMENT_POSITION_CONTAINS?1:0}const Bp=h.forwardRef(function(o,r){const{cutout:l,...c}=o;let d;if(l){const m=l.getBoundingClientRect();d=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${m.left}px ${m.top}px,${m.left}px ${m.bottom}px,${m.right}px ${m.bottom}px,${m.right}px ${m.top}px,${m.left}px ${m.top}px)`}return i.jsx("div",{ref:r,role:"presentation","data-base-ui-inert":"",...c,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:d}})});function Z1(n,o,{styles:r,transitionStatus:l,props:c,refs:d,hidden:m,inert:g=!1}){const b={...r};return g&&(b.pointerEvents="none"),mn("div",n,{state:o,ref:d,props:[{role:"presentation",hidden:m,style:b},Lp(l),c],stateAttributesMapping:Ql})}let sv={},ov={},rv="";function WO(n){if(typeof document>"u")return!1;const o=wt(n);return Xt(o).innerWidth-o.documentElement.clientWidth>0}function ek(n){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const r=wt(n),l=r.documentElement,c=r.body,d=Cr(l)?l:c,m=d.style.overflowY,g=l.style.scrollbarGutter;l.style.scrollbarGutter="stable",d.style.overflowY="scroll";const b=d.offsetWidth;d.style.overflowY="hidden";const p=d.offsetWidth;return d.style.overflowY=m,l.style.scrollbarGutter=g,b===p}function tk(n){const o=wt(n),r=o.documentElement,l=o.body,c=Cr(r)?r:l,d={overflowY:c.style.overflowY,overflowX:c.style.overflowX};return Object.assign(c.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(c.style,d)}}function nk(n){const o=wt(n),r=o.documentElement,l=o.body,c=Xt(r);let d=0,m=0,g=!1;const b=js.create();if(Or&&(c.visualViewport?.scale??1)!==1)return()=>{};function p(){const j=c.getComputedStyle(r),E=c.getComputedStyle(l),N=(j.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";d=r.scrollTop,m=r.scrollLeft,sv={scrollbarGutter:r.style.scrollbarGutter,overflowY:r.style.overflowY,overflowX:r.style.overflowX},rv=r.style.scrollBehavior,ov={position:l.style.position,height:l.style.height,width:l.style.width,boxSizing:l.style.boxSizing,overflowY:l.style.overflowY,overflowX:l.style.overflowX,scrollBehavior:l.style.scrollBehavior};const T=r.scrollHeight>r.clientHeight,k=r.scrollWidth>r.clientWidth,C=j.overflowY==="scroll"||E.overflowY==="scroll",U=j.overflowX==="scroll"||E.overflowX==="scroll",A=Math.max(0,c.innerWidth-l.clientWidth),L=Math.max(0,c.innerHeight-l.clientHeight),_=parseFloat(E.marginTop)+parseFloat(E.marginBottom),K=parseFloat(E.marginLeft)+parseFloat(E.marginRight),W=Cr(r)?r:l;if(g=ek(n),g){r.style.scrollbarGutter=N,W.style.overflowY="hidden",W.style.overflowX="hidden";return}Object.assign(r.style,{scrollbarGutter:N,overflowY:"hidden",overflowX:"hidden"}),(T||C)&&(r.style.overflowY="scroll"),(k||U)&&(r.style.overflowX="scroll"),Object.assign(l.style,{position:"relative",height:_||L?`calc(100dvh - ${_+L}px)`:"100dvh",width:K||A?`calc(100vw - ${K+A}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),l.scrollTop=d,l.scrollLeft=m,r.setAttribute("data-base-ui-scroll-locked",""),r.style.scrollBehavior="unset"}function v(){Object.assign(r.style,sv),Object.assign(l.style,ov),g||(r.scrollTop=d,r.scrollLeft=m,r.removeAttribute("data-base-ui-scroll-locked"),r.style.scrollBehavior=rv)}function x(){v(),b.request(p)}p();const S=yt(c,"resize",x);return()=>{b.cancel(),v(),typeof c.removeEventListener=="function"&&S()}}class sk{lockCount=0;restore=null;timeoutLock=ms.create();timeoutUnlock=ms.create();acquire(o){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(o)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(o){if(this.lockCount===0||this.restore!==null)return;const l=wt(o).documentElement,c=Xt(l).getComputedStyle(l).overflowY;if(c==="hidden"||c==="clip"){this.restore=dn;return}const d=ru||!WO(o);this.restore=d?tk(o):nk(o)}}const ok=new sk;function J1(n=!0,o=null){Qe(()=>{if(n)return ok.acquire(o)},[n,o])}const rk=20;function W1(n,o,r,l){const[c,d]=h.useState(!1);Qe(()=>{if(!n||!o||r==null){d(!1);return}const m=wt(r).documentElement.clientWidth,g=r.offsetWidth;d(m>0&&g>0&&g>=m-rk)},[n,o,r]),J1(n&&(!o||c),l)}const ak=h.forwardRef(function(o,r){const{anchor:l,positionMethod:c="absolute",className:d,render:m,side:g,align:b,sideOffset:p=0,alignOffset:v=0,collisionBoundary:x="clipping-ancestors",collisionPadding:S=5,arrowPadding:j=5,sticky:E=!1,disableAnchorTracking:M=!1,collisionAvoidance:O=rR,style:N,...T}=o,{store:k}=Rr(),C=YO(),U=nu(!0),A=k.useState("parent"),L=k.useState("floatingRootContext"),_=k.useState("floatingTreeRoot"),K=k.useState("mounted"),W=k.useState("open"),ue=k.useState("modal"),ne=k.useState("openMethod"),$=k.useState("activeTriggerElement"),oe=k.useState("transitionStatus"),q=k.useState("positionerElement"),w=k.useState("instantType"),D=k.useState("hasViewport"),H=k.useState("lastOpenChangeReason"),B=k.useState("floatingNodeId"),P=k.useState("floatingParentNodeId"),z=L.useState("domReferenceElement"),X=h.useRef(null),I=mp(q,!1,!1);let V=l,Q=p,Y=v,fe=b,re=O;A.type==="context-menu"&&(V=l??A.context?.anchor,fe=fe??"start",!g&&fe!=="center"&&(Y=o.alignOffset??2,Q=o.sideOffset??-5));let de=g,_e=fe;A.type==="menu"?(de=de??"inline-end",_e=_e??"start",re=o.collisionAvoidance??u1):A.type==="menubar"&&(de=de??(A.context.orientation==="vertical"?"inline-end":"bottom"),_e=_e??"start");const Ye=A.type==="context-menu",Re=Q1({anchor:V,floatingRootContext:L,positionMethod:U?"fixed":c,mounted:K,side:de,sideOffset:Q,align:_e,alignOffset:Y,arrowPadding:Ye?0:j,collisionBoundary:x,collisionPadding:S,sticky:E,nodeId:B,keepMounted:C,disableAnchorTracking:M,collisionAvoidance:re,shiftCrossAxis:Ye&&!("side"in re&&re.side==="flip"),externalTree:_,adaptiveOrigin:D?X1:void 0});h.useEffect(()=>{function De(Pe){Pe.open&&(Pe.parentNodeId===B&&k.set("hoverEnabled",!1),Pe.nodeId!==B&&Pe.parentNodeId===k.select("floatingParentNodeId")&&k.setOpen(!1,Ct(Ml)))}return _.events.on("menuopenchange",De),()=>{_.events.off("menuopenchange",De)}},[k,_.events,B]),h.useEffect(()=>{if(k.select("floatingParentNodeId")==null)return;function De(Pe){if(Pe.open||Pe.nodeId!==k.select("floatingParentNodeId"))return;const Ie=Pe.reason??Ml;k.setOpen(!1,Ct(Ie))}return _.events.on("menuopenchange",De),()=>{_.events.off("menuopenchange",De)}},[_.events,k]);const Le=qn();h.useEffect(()=>{W||Le.clear()},[W,Le]),h.useEffect(()=>{function De(Pe){if(!(!W||Pe.nodeId!==k.select("floatingParentNodeId")))if(Pe.target&&$&&$!==Pe.target){const Ie=k.select("closeDelay");Ie>0?Le.isStarted()||Le.start(Ie,()=>{k.setOpen(!1,Ct(Ml))}):k.setOpen(!1,Ct(Ml))}else Le.clear()}return _.events.on("itemhover",De),()=>{_.events.off("itemhover",De)}},[_.events,W,$,k,Le]),h.useEffect(()=>{const De={open:W,nodeId:B,parentNodeId:P,reason:k.select("lastOpenChangeReason")};_.events.emit("menuopenchange",De)},[_.events,W,k,B,P]),Qe(()=>{const De=z,Pe=X.current;if(De&&(X.current=De),Pe&&De&&De!==Pe){k.set("instantType",void 0);const Ie=new AbortController;return I(()=>{k.set("instantType","trigger-change")},Ie.signal),()=>{Ie.abort()}}},[z,I,k]);const He={open:W,side:Re.side,align:Re.align,anchorHidden:Re.anchorHidden,nested:A.type==="menu",instant:w},ge=A.type==="menubar"&&A.context.modal;W1(W&&(ge||ue&&H!==fn),ne==="touch",q,$);const ve=Z1(o,He,{styles:Re.positionerStyles,transitionStatus:oe,props:T,refs:[r,k.useStateSetter("positionerElement")],hidden:!K,inert:!W}),Ue=K&&A.type!=="menu"&&(A.type!=="menubar"&&ue&&H!==fn||A.type==="menubar"&&A.context.modal);let ye=null;return A.type==="menubar"?ye=A.context.contentElement:A.type===void 0&&(ye=$),i.jsxs(D0.Provider,{value:Re,children:[Ue&&i.jsx(Bp,{ref:A.type==="context-menu"||A.type==="nested-context-menu"?A.context.internalBackdropRef:null,inert:Ip(!W),cutout:ye}),i.jsx(g1,{id:B,children:i.jsx(KO,{elementsRef:k.context.itemDomElements,labelsRef:k.context.itemLabels,children:ve})})]})}),lk=h.createContext(null);function eS(n){return h.useContext(lk)}function ik(n){const o=h.useRef(""),r=h.useCallback(c=>{c.defaultPrevented||(o.current=c.pointerType,n(c,c.pointerType))},[n]);return{onClick:h.useCallback(c=>{if(c.detail===0){n(c,"keyboard");return}"pointerType"in c?n(c,c.pointerType):n(c,o.current),o.current=""},[n]),onPointerDown:r}}function ck(n,o){const r=h.useRef(n),l=at(o);Qe(()=>{r.current!==n&&l(r.current)},[n,l]),Qe(()=>{r.current=n},[n])}function tS(n,o){const r=at((d,m)=>{(typeof n=="function"?n():n)||o(m||(ru?"touch":""))}),{onClick:l,onPointerDown:c}=ik(r);return h.useMemo(()=>({onClick:l,onPointerDown:c}),[l,c])}function uk(n){const[o,r]=h.useState(null),l=tS(n,r);return ck(n,c=>{c&&!n&&r(null)}),h.useMemo(()=>({openMethod:o,triggerProps:l}),[o,l])}const dk={...Ap,disabled:Ge(n=>n.parent.type==="menubar"&&n.parent.context.disabled||n.disabled),modal:Ge(n=>(n.parent.type===void 0||n.parent.type==="context-menu")&&(n.modal??!0)),openMethod:Ge(n=>n.openMethod),allowMouseEnter:Ge(n=>n.allowMouseEnter),highlightItemOnHover:Ge(n=>n.highlightItemOnHover),stickIfOpen:Ge(n=>n.stickIfOpen),parent:Ge(n=>n.parent),rootId:Ge(n=>n.parent.type==="menu"?n.parent.store.select("rootId"):n.parent.type!==void 0?n.parent.context.rootId:n.rootId),activeIndex:Ge(n=>n.activeIndex),isActive:Ge((n,o)=>n.activeIndex===o),hoverEnabled:Ge(n=>n.hoverEnabled),instantType:Ge(n=>n.instantType),lastOpenChangeReason:Ge(n=>n.openChangeReason),floatingTreeRoot:Ge(n=>n.parent.type==="menu"?n.parent.store.select("floatingTreeRoot"):n.floatingTreeRoot),floatingNodeId:Ge(n=>n.floatingNodeId),floatingParentNodeId:Ge(n=>n.floatingParentNodeId),itemProps:Ge(n=>n.itemProps),closeDelay:Ge(n=>n.closeDelay),hasViewport:Ge(n=>n.hasViewport),keyboardEventRelay:Ge(n=>{if(n.keyboardEventRelay)return n.keyboardEventRelay;if(n.parent.type==="menu")return n.parent.store.select("keyboardEventRelay")})};class Up extends fu{constructor(o){super({...fk(),...o},{positionerRef:h.createRef(),popupRef:h.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:h.createRef(),beforeContentFocusGuardRef:h.createRef(),onOpenChangeComplete:void 0,triggerElements:new Jl},dk),this.unsubscribeParentListener=this.observe("parent",r=>{if(this.unsubscribeParentListener?.(),r.type==="menu"){let l=r.store.select("rootId"),c=r.store.select("floatingTreeRoot"),d=r.store.select("keyboardEventRelay");this.unsubscribeParentListener=r.store.subscribe(()=>{const m=r.store.select("rootId"),g=r.store.select("floatingTreeRoot"),b=r.store.select("keyboardEventRelay");l===m&&c===g&&d===b||(l=m,c=g,d=b,this.notifyAll())}),this.context.allowMouseUpTriggerRef=r.store.context.allowMouseUpTriggerRef;return}r.type!==void 0&&(this.context.allowMouseUpTriggerRef=r.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(o,r){this.state.floatingRootContext.context.events.emit("setOpen",{open:o,eventDetails:r})}static useStore(o,r){const l=zn(()=>new Up(r)).current;return o??l}unsubscribeParentListener=null}function fk(){return{..._p(),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,stickIfOpen:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new Sp,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Pt,keyboardEventRelay:void 0,closeDelay:0,hasViewport:!1}}const mk=h.createContext(void 0);function pk(){return h.useContext(mk)}const hk=O1(function(o){const{children:r,open:l,onOpenChange:c,onOpenChangeComplete:d,defaultOpen:m=!1,disabled:g=!1,modal:b,loopFocus:p=!0,orientation:v="vertical",actionsRef:x,closeParentOnEsc:S=!1,handle:j,triggerId:E,defaultTriggerId:M=null,highlightItemOnHover:O=!0}=o,N=nu(!0),T=Rr(!0),k=eS(!0),C=pk(),U=h.useMemo(()=>C&&T?{type:"menu",store:T.store}:k?{type:"menubar",context:k}:N&&!T?{type:"context-menu",context:N}:{type:void 0},[N,T,k,C]),A=Up.useStore(j?.store,{open:m,openProp:l,activeTriggerId:M,triggerIdProp:E,parent:U});z1(A,l,m,M),A.useControlledProp("openProp",l),A.useControlledProp("triggerIdProp",E),A.useContextCallback("onOpenChangeComplete",d);const L=jr(),_=jr(),K=A.useState("floatingTreeRoot"),W=Ep(K),ue=fo(),ne=A.useState("open"),$=A.useState("activeTriggerElement"),oe=A.useState("positionerElement"),q=A.useState("hoverEnabled"),w=A.useState("disabled"),D=A.useState("lastOpenChangeReason"),H=A.useState("parent"),B=A.useState("activeIndex"),P=A.useState("payload"),z=A.useState("floatingParentNodeId"),X=h.useRef(null),I=h.useRef(H.type!=="context-menu"),V=qn(),Q=h.useRef(!0),Y=qn(),fe=z!=null,{openMethod:re,triggerProps:de}=uk(ne);A.useSyncedValues({disabled:g,highlightItemOnHover:O,modal:H.type===void 0?b:void 0,openMethod:re,rootId:L}),Rp(A);const{forceUnmount:_e}=Op(ne,A,()=>{A.update({allowMouseEnter:!1,stickIfOpen:!0})});Qe(()=>{N&&!T?A.update({parent:{type:"context-menu",context:N},floatingNodeId:W,floatingParentNodeId:ue}):T&&A.update({floatingNodeId:W,floatingParentNodeId:ue})},[N,T,W,ue,A]),h.useEffect(()=>{if(ne||(X.current=null),H.type==="context-menu"){if(!ne){V.clear(),I.current=!1;return}V.start(500,()=>{I.current=!0})}},[V,ne,H.type]),Qe(()=>{!ne&&!q&&A.set("hoverEnabled",!0)},[ne,q,A]);const Ye=at((Ee,Xe)=>{const Ne=Xe.reason;if(ne===Ee&&Xe.trigger===$&&D===Ne)return;const Me=D1(Xe);if(!Ee&&Xe.trigger==null&&(Xe.trigger=$??void 0),c?.(Ee,Xe),Xe.isCanceled)return;A.state.floatingRootContext.dispatchOpenChange(Ee,Xe);const Je=Xe.event;if(Ee===!1&&Je?.type==="click"&&Je.pointerType==="touch"&&!Q.current)return;Ee&&Ne===Dl?(Q.current=!1,Y.start(300,()=>{Q.current=!0})):(Q.current=!0,Y.clear());const nt=(Ne===Er||Ne===B0)&&Je.detail===0&&Je?.isTrusted,jt=!Ee&&(Ne===su||Ne==null),kt={open:Ee,openChangeReason:Ne};X.current=Xe.event??null,Cp(kt,Ee,Xe.trigger,Me()),A.update(kt),H.type==="menubar"&&(Ne===Dl||Ne===Nr||Ne===fn||Ne===bm||Ne===Ml)?A.set("instantType","group"):nt||jt?A.set("instantType",nt?"click":"dismiss"):A.set("instantType",void 0)}),Re=_1({popupStore:A,floatingId:_,nested:ue!=null,onOpenChange:Ye}),Le=Re.context.events;h.useEffect(()=>{const Ee=({open:Xe,eventDetails:Ne})=>Ye(Xe,Ne);return Le.on("setOpen",Ee),()=>{Le?.off("setOpen",Ee)}},[Le,Ye]);const He=h.useCallback(()=>{A.setOpen(!1,Ct(cp))},[A]);h.useImperativeHandle(x,()=>({unmount:_e,close:He}),[_e,He]);let ge;H.type==="context-menu"&&(ge=H.context),h.useImperativeHandle(ge?.positionerRef,()=>oe,[oe]),h.useImperativeHandle(ge?.actionsRef,()=>({setOpen:Ye}),[Ye]);const pe=Tp(Re,{enabled:!w,bubbles:{escapeKey:S&&H.type==="menu"},outsidePress(){return H.type!=="context-menu"||X.current?.type==="contextmenu"?!0:I.current},externalTree:fe?K:void 0}),ve=$1(),Ue=h.useCallback(Ee=>{A.select("activeIndex")!==Ee&&A.set("activeIndex",Ee)},[A]),ye=wO(Re,{enabled:!w,listRef:A.context.itemDomElements,activeIndex:B,nested:H.type!==void 0,loopFocus:p,orientation:v,parentOrientation:H.type==="menubar"?H.context.orientation:void 0,rtl:ve==="rtl",disabledIndices:Pc,onNavigate:Ue,openOnArrowKeyDown:H.type!=="context-menu",externalTree:fe?K:void 0,focusItemOnHover:O}),De=h.useCallback(Ee=>{A.context.typingRef.current=Ee},[A]),Pe=CO(Re,{enabled:!w,listRef:A.context.itemLabels,elementsRef:A.context.itemDomElements,activeIndex:B,resetMs:sR,onMatch:Ee=>{ne&&Ee!==B&&A.set("activeIndex",Ee)},onTyping:De}),Ie=h.useMemo(()=>{const Ee=so(Pe.reference,ye.reference,pe.reference,{onMouseMove(){A.set("allowMouseEnter",!0)}},de);return Ee["aria-haspopup"]="menu",Ee["aria-expanded"]=ne,Ee},[A,Pe.reference,ye.reference,pe.reference,de,ne]),we=h.useMemo(()=>{const Ee=so(ye.trigger,pe.trigger,de);return Ee["aria-haspopup"]="menu",Ee["aria-expanded"]=!1,Ee},[ye.trigger,pe.trigger,de]),ee=h.useMemo(()=>so(pu,{id:_,role:"menu","aria-labelledby":$?.id,onMouseMove(){A.set("allowMouseEnter",!0),H.type==="menu"&&A.set("hoverEnabled",!1)},onClick(){A.select("hoverEnabled")&&A.set("hoverEnabled",!1)},onKeyDown(Ee){const Xe=A.select("keyboardEventRelay");Xe&&!Ee.isPropagationStopped()&&Xe(Ee)}},Pe.floating,ye.floating,pe.floating),[$,_,H.type,A,Pe.floating,ye.floating,pe.floating]),F=ye.item??Pt;kp(A,{floatingRootContext:Re,activeTriggerProps:Ie,inactiveTriggerProps:we,popupProps:ee,itemProps:F});const ie=h.useMemo(()=>({store:A,parent:U}),[A,U]),Z=i.jsx(L0.Provider,{value:ie,children:typeof r=="function"?r({payload:P}):r});return H.type===void 0||H.type==="context-menu"?i.jsx(x1,{externalTree:K,children:Z}):Z});function gk(n){const o=n.getBoundingClientRect(),r=Xt(n);if(dp)return o;const l=r.getComputedStyle(n,"::before"),c=r.getComputedStyle(n,"::after");if(!(l.content!=="none"||c.content!=="none"))return o;const m=parseFloat(l.width)||0,g=parseFloat(l.height)||0,b=parseFloat(c.width)||0,p=parseFloat(c.height)||0,v=Math.max(o.width,m,b),x=Math.max(o.height,g,p),S=v-o.width,j=x-o.height;return{left:o.left-S/2,right:o.right+S/2,top:o.top-j/2,bottom:o.bottom+j/2}}function xk(n={}){const{highlightItemOnHover:o,highlightedIndex:r,onHighlightedIndexChange:l}=ap(),{ref:c,index:d}=P0(n),m=r===d,g=h.useRef(null),b=Oa(c,g);return{compositeProps:{tabIndex:m?0:-1,onFocus(){l(d)},onMouseMove(){const v=g.current;if(!o||!v)return;const x=v.hasAttribute("disabled")||v.ariaDisabled==="true";!m&&!x&&v.focus()}},compositeRef:b,index:d}}function bk(n){const{render:o,className:r,style:l,state:c=Pt,props:d=Pc,refs:m=Pc,metadata:g,stateAttributesMapping:b,tag:p="div",...v}=n,{compositeProps:x,compositeRef:S}=xk({metadata:g});return mn(p,n,{state:c,ref:[...m,S],props:[x,...d,v],stateAttributesMapping:b})}function nS(n){if(Ht(n)&&n.hasAttribute("data-rootownerid"))return n.getAttribute("data-rootownerid")??void 0;if(!no(n))return nS(lo(n))}function sS(n,o){const r=h.useRef(null);function l(d){io.flushSync(()=>{n.setOpen(!1,Ct(Nr,d.nativeEvent,d.currentTarget))}),WC(r.current)?.focus()}function c(d){const m=n.select("positionerElement");if(m&&Ta(d,m))n.context.beforeContentFocusGuardRef.current?.focus();else{io.flushSync(()=>{n.setOpen(!1,Ct(Nr,d.nativeEvent,d.currentTarget))});let g=JC(n.context.triggerFocusTargetRef.current||o.current);for(;g!==null&&ot(m,g);){const b=g;if(g=yp(g),g===b)break}g?.focus()}}return{preFocusGuardRef:r,handlePreFocusGuardFocus:l,handleFocusTargetFocus:c}}function yk(n){const{enabled:o=!0,mouseDownAction:r,open:l}=n,c=h.useRef(!1);return h.useMemo(()=>o?{onMouseDown:d=>{(r==="open"&&!l||r==="close"&&l)&&(c.current=!0,wt(d.currentTarget).addEventListener("click",()=>{c.current=!1},{once:!0}))},onClick:d=>{c.current&&(c.current=!1,d.preventBaseUIHandler())}}:Pt,[o,r,l])}const jc=2,vk=lO(function(o,r){const{render:l,className:c,style:d,disabled:m=!1,nativeButton:g=!0,id:b,openOnHover:p,delay:v=100,closeDelay:x=0,handle:S,payload:j,...E}=o,M=Rr(!0),O=S?.store??M?.store;if(!O)throw new Error(En(85));const N=kr(b),T=O.useState("isTriggerActive",N),k=O.useState("floatingRootContext"),C=O.useState("isOpenedByTrigger",N),U=O.useState("triggerPopupId",N),A=h.useRef(null),L=Ek(),_=ap(!0),K=qo(),W=h.useMemo(()=>K??new Sp,[K]),ue=Ep(W),ne=fo(),{registerTrigger:$,isMountedByThisTrigger:oe}=L1(N,A,O,{payload:j,closeDelay:x,parent:L,floatingTreeRoot:W,floatingNodeId:ue,floatingParentNodeId:ne,keyboardEventRelay:_?.relayKeyboardEvent}),q=L.type==="menubar",w=O.useState("disabled"),D=m||w||q&&L.context.disabled,{getButtonProps:H,buttonRef:B}=Kl({disabled:D,native:g});h.useEffect(()=>{!C&&L.type===void 0&&(O.context.allowMouseUpTriggerRef.current=!1)},[O,C,L.type]);const P=h.useRef(null),z=qn(),X=at(ye=>{if(!P.current)return;z.clear(),O.context.allowMouseUpTriggerRef.current=!1;const De=ye.target;if(ot(P.current,De)||ot(O.select("positionerElement"),De)||De===P.current||De!=null&&nS(De)===O.select("rootId"))return;const Pe=gk(P.current);ye.clientX>=Pe.left-jc&&ye.clientX<=Pe.right+jc&&ye.clientY>=Pe.top-jc&&ye.clientY<=Pe.bottom+jc||W.events.emit("close",{domEvent:ye,reason:rC})});h.useEffect(()=>{C&&O.select("lastOpenChangeReason")===fn&&wt(P.current).addEventListener("mouseup",X,{once:!0})},[C,X,O]);const I=q&&L.context.hasSubmenuOpen,Q=V1(k,{enabled:(p??I)&&!D&&L.type!=="context-menu"&&(!q||I&&!oe),handleClose:F1({blockPointerEvents:!q}),mouseOnly:!0,move:!1,restMs:L.type===void 0?v:void 0,delay:{close:x},triggerElementRef:A,externalTree:W,isActiveTrigger:T,isClosing:()=>O.select("transitionStatus")==="ending"}),Y=Sk(C,O.select("lastOpenChangeReason")),fe=b1(k,{enabled:!D&&L.type!=="context-menu",event:C&&q?"click":"mousedown",toggle:!0,ignoreMouse:!1,stickIfOpen:L.type===void 0?Y:!1}),re=SO(k,{enabled:!D&&I}),de=yk({open:C,enabled:q,mouseDownAction:"open"}),_e=h.useMemo(()=>so(re.reference,fe.reference),[re.reference,fe.reference]),Ye=O.useState("triggerProps",oe),{preFocusGuardRef:Re,handlePreFocusGuardFocus:Le,handleFocusTargetFocus:He}=sS(O,A),ge={disabled:D,open:C},pe=[P,r,B,$,A],ve=[_e,Q??Pt,Ye,{"aria-haspopup":"menu","aria-controls":U,id:N,onMouseDown:ye=>{if(O.select("open"))return;z.start(200,()=>{O.context.allowMouseUpTriggerRef.current=!0}),wt(ye.currentTarget).addEventListener("mouseup",X,{once:!0})}},q?{role:"menuitem"}:{},de,E,H],Ue=mn("button",o,{enabled:!q,stateAttributesMapping:xm,state:ge,ref:pe,props:ve});return q?i.jsx(bk,{tag:"button",render:l,className:c,style:d,state:ge,refs:pe,props:ve,stateAttributesMapping:xm}):C?i.jsxs(h.Fragment,{children:[i.jsx(Yo,{ref:Re,onFocus:Le},`${N}-pre-focus-guard`),i.jsx(h.Fragment,{children:Ue},N),i.jsx(Yo,{ref:O.context.triggerFocusTargetRef,onFocus:He},`${N}-post-focus-guard`)]}):i.jsx(h.Fragment,{children:Ue},N)});function Sk(n,o){const r=qn(),[l,c]=h.useState(!1);return Qe(()=>{n&&o==="trigger-hover"?(c(!0),r.start(i1,()=>{c(!1)})):n||(r.clear(),c(!1))},[n,o,r]),l}function Ek(){const n=nu(!0),o=Rr(!0),r=eS();return h.useMemo(()=>r?{type:"menubar",context:r}:n&&!o?{type:"context-menu",context:n}:{type:void 0},[n,o,r])}const Nk=h.forwardRef(function(o,r){const{className:l,render:c,orientation:d="horizontal",style:m,...g}=o;return mn("div",o,{state:{orientation:d},ref:r,props:[{role:"separator","aria-orientation":d},g]})});function gu({...n}){return i.jsx(hk,{"data-slot":"dropdown-menu",...n})}function xu({...n}){return i.jsx(vk,{"data-slot":"dropdown-menu-trigger",...n})}function bu({align:n="start",alignOffset:o=0,side:r="bottom",sideOffset:l=4,className:c,...d}){return i.jsx(VO,{children:i.jsx(ak,{className:"isolate z-50 outline-none",align:n,alignOffset:o,side:r,sideOffset:l,children:i.jsx(PO,{"data-slot":"dropdown-menu-content",className:Ze("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95",c),...d})})})}function jk({...n}){return i.jsx(jC,{"data-slot":"dropdown-menu-group",...n})}function Tk({className:n,inset:o,...r}){return i.jsx(TC,{"data-slot":"dropdown-menu-label","data-inset":o,className:Ze("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",n),...r})}function fs({className:n,inset:o,variant:r="default",...l}){return i.jsx(wC,{"data-slot":"dropdown-menu-item","data-inset":o,"data-variant":r,className:Ze("group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",n),...l})}function Hp({className:n,...o}){return i.jsx(Nk,{"data-slot":"dropdown-menu-separator",className:Ze("-mx-1 my-1 h-px bg-border",n),...o})}const wk={propose_create_entity:"新建实体",propose_update_entity:"更新实体",propose_add_relation:"新增关系",propose_outline_node:"新建大纲节点",propose_reorder_timepoints:"重排时间轴时间点"},Ck={character:"角色",setting:"设定",location:"地点",hook:"伏笔"};function Rk(n){const o=n.focus_entity_id??n.focus_node_id??"",r=n.focus_entity_type?Ck[n.focus_entity_type]??n.focus_entity_type:n.focus_node_id?"大纲节点":"";return r?`${r} ${o}`:o||"当前内容"}const Ok=n=>typeof n=="object"&&n!==null?n:{};function kk({disabled:n,onClose:o,onToggleCollapse:r}){const l=Nt(p=>p.sessions),c=Nt(p=>p.currentSessionId),d=Nt(p=>p.setCurrentSession),m=Nt(p=>p.newSession),g=l?.find(p=>p.id===c)??null,b=g?g.lastMessage||"(空会话)":"新会话";return i.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-1 border-b border-border px-2.5",children:[i.jsx(Bl,{className:"size-4 shrink-0 text-muted-foreground"}),i.jsxs(gu,{children:[i.jsx(xu,{render:i.jsxs(he,{variant:"ghost",size:"sm",disabled:n,className:"max-w-44 justify-start gap-1 px-1.5",children:[i.jsx("span",{className:"truncate text-sm font-medium",title:b,children:b}),i.jsx(jj,{className:"size-3.5 shrink-0 text-muted-foreground"})]})}),i.jsxs(bu,{align:"start",className:"w-64",children:[i.jsx(jk,{children:i.jsx(Tk,{children:"会话(本项目)"})}),i.jsx(Hp,{}),l&&l.length===0&&i.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"暂无历史会话"}),l?.map(p=>i.jsx(fs,{onClick:()=>d(p.id),className:Ze(p.id===c&&"bg-accent text-accent-foreground"),children:i.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[i.jsx("span",{className:"truncate text-sm",children:p.lastMessage||"(空会话)"}),i.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.messageCount," 条 · ",br(p.updatedAt)]})]})},p.id))]})]}),i.jsx(he,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground",disabled:n,onClick:m,"aria-label":"新会话",title:"新会话",children:i.jsx(Gm,{className:"size-4"})}),r&&i.jsx(he,{variant:"ghost",size:"icon-sm",className:"ml-auto shrink-0 text-muted-foreground",onClick:r,"aria-label":"收起聊天面板",title:"收起聊天面板",children:i.jsx(oT,{className:"size-4"})}),o&&i.jsx(he,{variant:"ghost",size:"icon-sm",className:"ml-auto shrink-0 text-muted-foreground",onClick:o,"aria-label":"关闭聊天面板",children:i.jsx(As,{className:"size-4"})})]})}function _k(){const n=Nt(l=>l.disconnected),o=Nt(l=>l.setDisconnected),r=Nt(l=>l.resendLast);return n?i.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:[i.jsx(qm,{className:"size-3.5 shrink-0"}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:"上次会话已取消"}),i.jsx(he,{size:"xs",variant:"outline",className:"shrink-0",onClick:r,children:"重新发送"}),i.jsx("button",{className:"shrink-0 rounded p-0.5 hover:bg-destructive/15",onClick:()=>o(!1),"aria-label":"关闭断连提示",children:i.jsx(As,{className:"size-3.5"})})]}):null}function Mk(){const n=Nt(r=>r.streamError),o=Nt(r=>r.setStreamError);return n?i.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:[i.jsx(Pm,{className:"size-3.5 shrink-0"}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:n}),i.jsx("button",{className:"shrink-0 rounded p-0.5 hover:bg-destructive/15",onClick:()=>o(null),"aria-label":"关闭错误提示",children:i.jsx(As,{className:"size-3.5"})})]}):null}function oS({toolName:n,args:o,result:r,status:l}){const[c,d]=h.useState(!1),m=l==="ok"||r!==void 0;return i.jsxs("div",{className:"rounded-md border border-border/70 bg-muted/40 px-2 py-1",children:[i.jsxs("button",{className:"flex w-full items-center gap-1.5 text-left text-xs text-muted-foreground",onClick:()=>d(g=>!g),"aria-expanded":c,children:[i.jsx(Hm,{className:Ze("size-3 shrink-0 transition-transform",c&&"rotate-90")}),i.jsx(MT,{className:"size-3 shrink-0"}),i.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["调用了 ",n]}),l==="error"&&i.jsx("span",{className:"shrink-0 text-destructive",children:"✗"}),m&&i.jsx("span",{className:"shrink-0 text-primary",children:"✓"})]}),c&&i.jsx("pre",{className:"mt-1 max-h-40 overflow-auto whitespace-pre-wrap text-xs text-muted-foreground",children:typeof o=="string"?o:JSON.stringify(o??{},null,2)})]})}function Ak({message:n,toolResults:o}){if(n.role==="user")return i.jsx("div",{className:"flex justify-end",children:i.jsx("div",{className:"max-w-[85%] rounded-lg bg-secondary px-3 py-2 text-sm text-secondary-foreground",children:n.content})});if(n.role==="tool")return null;const r=Array.isArray(n.toolCalls)?n.toolCalls:[];return i.jsxs("div",{className:"space-y-1.5",children:[r.map((l,c)=>{const d=Ok(l),m=d.id??`hist-${c}`,g=m?o.get(m):void 0;return i.jsx(oS,{toolName:d.tool??d.name??"工具",args:d.args,result:g?.content,status:g?"ok":void 0},m)}),n.content?i.jsx("p",{className:"whitespace-pre-wrap font-serif text-[17px] leading-[1.72] text-foreground",children:n.content}):null]})}function Dk({proposal:n}){const o=Nt(d=>d.confirmProposal),r=Nt(d=>d.rejectProposal),l=wk[n.type]??n.type,c=n.status!=="pending"||n.processing===!0;return i.jsxs("div",{className:"rounded-lg border border-primary/25 bg-primary/5 p-2.5",children:[i.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-medium text-foreground",children:[i.jsx(e0,{className:"size-3.5 shrink-0 text-primary"}),i.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["提案:",l]}),n.status==="confirmed"&&i.jsx("span",{className:"shrink-0 text-xs text-primary",children:"✓ 已确认"}),n.status==="rejected"&&i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:"已拒绝"}),n.status==="stale"&&i.jsx("span",{className:"shrink-0 text-xs text-destructive",children:"⚠ 数据已变化,此提案已失效"})]}),n.preview!==void 0&&i.jsx("pre",{className:"mt-1 max-h-32 overflow-auto whitespace-pre-wrap text-xs text-muted-foreground",children:typeof n.preview=="string"?n.preview:JSON.stringify(n.preview,null,2)}),i.jsxs("div",{className:"mt-2 flex gap-1.5",children:[i.jsx(he,{size:"xs",disabled:c,onClick:()=>{o(n.proposalId)},children:"确认"}),i.jsx(he,{size:"xs",variant:"outline",disabled:c,onClick:()=>{r(n.proposalId)},children:"拒绝"})]})]})}function zk(){const n=Nt(r=>r.focusContext),o=Nt(r=>r.clearFocusContext);return n?i.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 border-t border-border bg-accent/40 px-3 py-1.5 text-xs",children:[i.jsx(e0,{className:"size-3.5 shrink-0 text-primary"}),i.jsxs("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:["正在讨论:",Rk(n)]}),i.jsx("button",{className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted",onClick:o,"aria-label":"清除讨论上下文",children:i.jsx(As,{className:"size-3.5"})})]}):null}function Lk({disabled:n}){const[o,r]=h.useState(""),l=Nt(g=>g.streaming),c=Nt(g=>g.sendMessage),d=!n&&!l&&o.trim().length>0,m=()=>{d&&(c(o),r(""))};return i.jsx("div",{className:"shrink-0 border-t border-border p-3",children:i.jsxs("div",{className:"flex items-end gap-2",children:[i.jsx("textarea",{value:o,onChange:g=>r(g.target.value),onKeyDown:g=>{g.key==="Enter"&&!g.shiftKey&&!g.nativeEvent.isComposing&&(g.preventDefault(),m())},placeholder:l?"AI 思考中…":"输入消息…",rows:1,disabled:n||l,className:"max-h-32 min-h-9 flex-1 resize-none rounded-lg border border-input bg-transparent px-2.5 py-1.5 text-sm outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50"}),i.jsxs(he,{onClick:m,disabled:!d,className:"shrink-0",children:[l?i.jsx(Il,{className:"size-4 animate-spin"}):i.jsx(yT,{className:"size-4"}),l?"思考中":"发送"]})]})})}function Ik({disabled:n}){const o=Nt(p=>p.messages),r=Nt(p=>p.messagesLoading),l=Nt(p=>p.streamTools),c=Nt(p=>p.proposals),d=h.useRef(null),m=h.useMemo(()=>{const p=new Map;for(const v of o)v.role==="tool"&&v.toolCallId&&p.set(v.toolCallId,v);return p},[o]),g=o.length;if(h.useEffect(()=>{const p=d.current;p&&(p.scrollTop=p.scrollHeight)},[g,r,l.length,c.length]),n)return i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-2 p-4",children:[i.jsx(Bl,{className:"size-8 text-muted-foreground/40"}),i.jsx("p",{className:"text-sm text-muted-foreground/70",children:"打开项目后可用"})]});if(r)return i.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 p-4",children:[0,1].map(p=>i.jsx("div",{className:"animate-pulse rounded-lg bg-muted/60",style:{height:40,width:p%2?"70%":"90%"}},p))});const b=o.length===0&&l.length===0&&c.length===0;return i.jsx("div",{ref:d,className:"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:b?i.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1.5 p-4 text-center",children:[i.jsx(Bl,{className:"size-7 text-muted-foreground/40"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"试试问:这个设定有没有漏洞?"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"第 4 章剧情往哪走合理?"})]}):i.jsxs("div",{className:"flex flex-col gap-3",children:[o.map(p=>i.jsx(Ak,{message:p,toolResults:m},p.id)),l.map(p=>i.jsx(oS,{toolName:p.tool,args:p.args,result:p.result,status:p.status},p.id)),c.map(p=>i.jsx(Dk,{proposal:p},p.proposalId))]})})}function av({onClose:n,onToggleCollapse:o}){const l=!Be(c=>c.config);return i.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[i.jsx(kk,{disabled:l,onClose:n,onToggleCollapse:o}),!l&&i.jsxs(i.Fragment,{children:[i.jsx(_k,{}),i.jsx(Mk,{})]}),i.jsx(Ik,{disabled:l}),!l&&i.jsxs(i.Fragment,{children:[i.jsx(zk,{}),i.jsx(Lk,{disabled:l})]})]})}function Bk({open:n,onClose:o,width:r,onToggleCollapse:l}){return $m("(min-width: 1024px)")?i.jsx("aside",{className:"flex min-w-0 flex-[4_1_40%] flex-col border-l border-border bg-background",style:r!==void 0?{flex:`0 1 ${r}px`,minWidth:Hl}:void 0,children:i.jsx(av,{onToggleCollapse:l})}):n?i.jsxs("div",{className:"fixed inset-0 z-50",children:[i.jsx("div",{className:"absolute inset-0 bg-foreground/40 animate-in fade-in",onClick:o}),i.jsx("div",{className:"absolute inset-y-0 right-0 w-[85vw] max-w-md border-l border-border bg-background shadow-xl animate-in slide-in-from-right duration-300",children:i.jsx(av,{onClose:o})})]}):null}function Uk(n){if(typeof document>"u")return;let o=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",o.appendChild(r),r.styleSheet?r.styleSheet.cssText=n:r.appendChild(document.createTextNode(n))}const Hk=n=>{switch(n){case"success":return Vk;case"info":return Gk;case"warning":return Fk;case"error":return qk;default:return null}},Pk=Array(12).fill(0),Yk=({visible:n,className:o})=>Ae.createElement("div",{className:["sonner-loading-wrapper",o].filter(Boolean).join(" "),"data-visible":n},Ae.createElement("div",{className:"sonner-spinner"},Pk.map((r,l)=>Ae.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${l}`})))),Vk=Ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Ae.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),Fk=Ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Ae.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Gk=Ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Ae.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),qk=Ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Ae.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),$k=Ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},Ae.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Ae.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Xk=()=>{const[n,o]=Ae.useState(document.hidden);return Ae.useEffect(()=>{const r=()=>{o(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),n};let Om=1;class Kk{constructor(){this.subscribe=o=>(this.subscribers.push(o),()=>{const r=this.subscribers.indexOf(o);this.subscribers.splice(r,1)}),this.publish=o=>{this.subscribers.forEach(r=>r(o))},this.addToast=o=>{this.publish(o),this.toasts=[...this.toasts,o]},this.create=o=>{var r;const{message:l,...c}=o,d=typeof o?.id=="number"||((r=o.id)==null?void 0:r.length)>0?o.id:Om++,m=this.toasts.find(b=>b.id===d),g=o.dismissible===void 0?!0:o.dismissible;return this.dismissedToasts.has(d)&&this.dismissedToasts.delete(d),m?this.toasts=this.toasts.map(b=>b.id===d?(this.publish({...b,...o,id:d,title:l}),{...b,...o,id:d,dismissible:g,title:l}):b):this.addToast({title:l,...c,dismissible:g,id:d}),d},this.dismiss=o=>(o?(this.dismissedToasts.add(o),requestAnimationFrame(()=>this.subscribers.forEach(r=>r({id:o,dismiss:!0})))):this.toasts.forEach(r=>{this.subscribers.forEach(l=>l({id:r.id,dismiss:!0}))}),o),this.message=(o,r)=>this.create({...r,message:o}),this.error=(o,r)=>this.create({...r,message:o,type:"error"}),this.success=(o,r)=>this.create({...r,type:"success",message:o}),this.info=(o,r)=>this.create({...r,type:"info",message:o}),this.warning=(o,r)=>this.create({...r,type:"warning",message:o}),this.loading=(o,r)=>this.create({...r,type:"loading",message:o}),this.promise=(o,r)=>{if(!r)return;let l;r.loading!==void 0&&(l=this.create({...r,promise:o,type:"loading",message:r.loading,description:typeof r.description!="function"?r.description:void 0}));const c=Promise.resolve(o instanceof Function?o():o);let d=l!==void 0,m;const g=c.then(async p=>{if(m=["resolve",p],Ae.isValidElement(p))d=!1,this.create({id:l,type:"default",message:p});else if(Zk(p)&&!p.ok){d=!1;const x=typeof r.error=="function"?await r.error(`HTTP error! status: ${p.status}`):r.error,S=typeof r.description=="function"?await r.description(`HTTP error! status: ${p.status}`):r.description,E=typeof x=="object"&&!Ae.isValidElement(x)?x:{message:x};this.create({id:l,type:"error",description:S,...E})}else if(p instanceof Error){d=!1;const x=typeof r.error=="function"?await r.error(p):r.error,S=typeof r.description=="function"?await r.description(p):r.description,E=typeof x=="object"&&!Ae.isValidElement(x)?x:{message:x};this.create({id:l,type:"error",description:S,...E})}else if(r.success!==void 0){d=!1;const x=typeof r.success=="function"?await r.success(p):r.success,S=typeof r.description=="function"?await r.description(p):r.description,E=typeof x=="object"&&!Ae.isValidElement(x)?x:{message:x};this.create({id:l,type:"success",description:S,...E})}}).catch(async p=>{if(m=["reject",p],r.error!==void 0){d=!1;const v=typeof r.error=="function"?await r.error(p):r.error,x=typeof r.description=="function"?await r.description(p):r.description,j=typeof v=="object"&&!Ae.isValidElement(v)?v:{message:v};this.create({id:l,type:"error",description:x,...j})}}).finally(()=>{d&&(this.dismiss(l),l=void 0),r.finally==null||r.finally.call(r)}),b=()=>new Promise((p,v)=>g.then(()=>m[0]==="reject"?v(m[1]):p(m[1])).catch(v));return typeof l!="string"&&typeof l!="number"?{unwrap:b}:Object.assign(l,{unwrap:b})},this.custom=(o,r)=>{const l=r?.id||Om++;return this.create({jsx:o(l),id:l,...r}),l},this.getActiveToasts=()=>this.toasts.filter(o=>!this.dismissedToasts.has(o.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const An=new Kk,Qk=(n,o)=>{const r=o?.id||Om++;return An.addToast({title:n,...o,id:r}),r},Zk=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",Jk=Qk,Wk=()=>An.toasts,e_=()=>An.getActiveToasts(),lv=Object.assign(Jk,{success:An.success,info:An.info,warning:An.warning,error:An.error,custom:An.custom,message:An.message,promise:An.promise,dismiss:An.dismiss,loading:An.loading},{getHistory:Wk,getToasts:e_});Uk("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Tc(n){return n.label!==void 0}const t_=3,n_="24px",s_="16px",iv=4e3,o_=356,r_=14,a_=45,l_=200;function Es(...n){return n.filter(Boolean).join(" ")}function i_(n){const[o,r]=n.split("-"),l=[];return o&&l.push(o),r&&l.push(r),l}const c_=n=>{var o,r,l,c,d,m,g,b,p;const{invert:v,toast:x,unstyled:S,interacting:j,setHeights:E,visibleToasts:M,heights:O,index:N,toasts:T,expanded:k,removeToast:C,defaultRichColors:U,closeButton:A,style:L,cancelButtonStyle:_,actionButtonStyle:K,className:W="",descriptionClassName:ue="",duration:ne,position:$,gap:oe,expandByDefault:q,classNames:w,icons:D,closeButtonAriaLabel:H="Close toast"}=n,[B,P]=Ae.useState(null),[z,X]=Ae.useState(null),[I,V]=Ae.useState(!1),[Q,Y]=Ae.useState(!1),[fe,re]=Ae.useState(!1),[de,_e]=Ae.useState(!1),[Ye,Re]=Ae.useState(!1),[Le,He]=Ae.useState(0),[ge,pe]=Ae.useState(0),ve=Ae.useRef(x.duration||ne||iv),Ue=Ae.useRef(null),ye=Ae.useRef(null),De=N===0,Pe=N+1<=M,Ie=x.type,we=x.dismissible!==!1,ee=x.className||"",F=x.descriptionClassName||"",ie=Ae.useMemo(()=>O.findIndex(xe=>xe.toastId===x.id)||0,[O,x.id]),Z=Ae.useMemo(()=>{var xe;return(xe=x.closeButton)!=null?xe:A},[x.closeButton,A]),Ee=Ae.useMemo(()=>x.duration||ne||iv,[x.duration,ne]),Xe=Ae.useRef(0),Ne=Ae.useRef(0),Me=Ae.useRef(0),Je=Ae.useRef(null),[nt,jt]=$.split("-"),kt=Ae.useMemo(()=>O.reduce((xe,Oe,We)=>We>=ie?xe:xe+Oe.height,0),[O,ie]),gt=Xk(),ln=x.invert||v,Jt=Ie==="loading";Ne.current=Ae.useMemo(()=>ie*oe+kt,[ie,kt]),Ae.useEffect(()=>{ve.current=Ee},[Ee]),Ae.useEffect(()=>{V(!0)},[]),Ae.useEffect(()=>{const xe=ye.current;if(xe){const Oe=xe.getBoundingClientRect().height;return pe(Oe),E(We=>[{toastId:x.id,height:Oe,position:x.position},...We]),()=>E(We=>We.filter(rt=>rt.toastId!==x.id))}},[E,x.id]),Ae.useLayoutEffect(()=>{if(!I)return;const xe=ye.current,Oe=xe.style.height;xe.style.height="auto";const We=xe.getBoundingClientRect().height;xe.style.height=Oe,pe(We),E(rt=>rt.find(lt=>lt.toastId===x.id)?rt.map(lt=>lt.toastId===x.id?{...lt,height:We}:lt):[{toastId:x.id,height:We,position:x.position},...rt])},[I,x.title,x.description,E,x.id,x.jsx,x.action,x.cancel]);const et=Ae.useCallback(()=>{Y(!0),He(Ne.current),E(xe=>xe.filter(Oe=>Oe.toastId!==x.id)),setTimeout(()=>{C(x)},l_)},[x,C,E,Ne]);Ae.useEffect(()=>{if(x.promise&&Ie==="loading"||x.duration===1/0||x.type==="loading")return;let xe;return k||j||gt?(()=>{if(Me.current<Xe.current){const rt=new Date().getTime()-Xe.current;ve.current=ve.current-rt}Me.current=new Date().getTime()})():ve.current!==1/0&&(Xe.current=new Date().getTime(),xe=setTimeout(()=>{x.onAutoClose==null||x.onAutoClose.call(x,x),et()},ve.current)),()=>clearTimeout(xe)},[k,j,x,Ie,gt,et]),Ae.useEffect(()=>{x.delete&&(et(),x.onDismiss==null||x.onDismiss.call(x,x))},[et,x.delete]);function je(){var xe;if(D?.loading){var Oe;return Ae.createElement("div",{className:Es(w?.loader,x==null||(Oe=x.classNames)==null?void 0:Oe.loader,"sonner-loader"),"data-visible":Ie==="loading"},D.loading)}return Ae.createElement(Yk,{className:Es(w?.loader,x==null||(xe=x.classNames)==null?void 0:xe.loader),visible:Ie==="loading"})}const Ce=x.icon||D?.[Ie]||Hk(Ie);var qe,te;return Ae.createElement("li",{tabIndex:0,ref:ye,className:Es(W,ee,w?.toast,x==null||(o=x.classNames)==null?void 0:o.toast,w?.default,w?.[Ie],x==null||(r=x.classNames)==null?void 0:r[Ie]),"data-sonner-toast":"","data-rich-colors":(qe=x.richColors)!=null?qe:U,"data-styled":!(x.jsx||x.unstyled||S),"data-mounted":I,"data-promise":!!x.promise,"data-swiped":Ye,"data-removed":Q,"data-visible":Pe,"data-y-position":nt,"data-x-position":jt,"data-index":N,"data-front":De,"data-swiping":fe,"data-dismissible":we,"data-type":Ie,"data-invert":ln,"data-swipe-out":de,"data-swipe-direction":z,"data-expanded":!!(k||q&&I),"data-testid":x.testId,style:{"--index":N,"--toasts-before":N,"--z-index":T.length-N,"--offset":`${Q?Le:Ne.current}px`,"--initial-height":q?"auto":`${ge}px`,...L,...x.style},onDragEnd:()=>{re(!1),P(null),Je.current=null},onPointerDown:xe=>{xe.button!==2&&(Jt||!we||(Ue.current=new Date,He(Ne.current),xe.target.setPointerCapture(xe.pointerId),xe.target.tagName!=="BUTTON"&&(re(!0),Je.current={x:xe.clientX,y:xe.clientY})))},onPointerUp:()=>{var xe,Oe,We;if(de||!we)return;Je.current=null;const rt=Number(((xe=ye.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ct=Number(((Oe=ye.current)==null?void 0:Oe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),lt=new Date().getTime()-((We=Ue.current)==null?void 0:We.getTime()),Ft=B==="x"?rt:ct,$n=Math.abs(Ft)/lt;if(Math.abs(Ft)>=a_||$n>.11){He(Ne.current),x.onDismiss==null||x.onDismiss.call(x,x),X(B==="x"?rt>0?"right":"left":ct>0?"down":"up"),et(),_e(!0);return}else{var Kt,pn;(Kt=ye.current)==null||Kt.style.setProperty("--swipe-amount-x","0px"),(pn=ye.current)==null||pn.style.setProperty("--swipe-amount-y","0px")}Re(!1),re(!1),P(null)},onPointerMove:xe=>{var Oe,We,rt;if(!Je.current||!we||((Oe=window.getSelection())==null?void 0:Oe.toString().length)>0)return;const lt=xe.clientY-Je.current.y,Ft=xe.clientX-Je.current.x;var $n;const Kt=($n=n.swipeDirections)!=null?$n:i_($);!B&&(Math.abs(Ft)>1||Math.abs(lt)>1)&&P(Math.abs(Ft)>Math.abs(lt)?"x":"y");let pn={x:0,y:0};const mo=Ln=>1/(1.5+Math.abs(Ln)/20);if(B==="y"){if(Kt.includes("top")||Kt.includes("bottom"))if(Kt.includes("top")&&lt<0||Kt.includes("bottom")&&lt>0)pn.y=lt;else{const Ln=lt*mo(lt);pn.y=Math.abs(Ln)<Math.abs(lt)?Ln:lt}}else if(B==="x"&&(Kt.includes("left")||Kt.includes("right")))if(Kt.includes("left")&&Ft<0||Kt.includes("right")&&Ft>0)pn.x=Ft;else{const Ln=Ft*mo(Ft);pn.x=Math.abs(Ln)<Math.abs(Ft)?Ln:Ft}(Math.abs(pn.x)>0||Math.abs(pn.y)>0)&&Re(!0),(We=ye.current)==null||We.style.setProperty("--swipe-amount-x",`${pn.x}px`),(rt=ye.current)==null||rt.style.setProperty("--swipe-amount-y",`${pn.y}px`)}},Z&&!x.jsx&&Ie!=="loading"?Ae.createElement("button",{"aria-label":H,"data-disabled":Jt,"data-close-button":!0,onClick:Jt||!we?()=>{}:()=>{et(),x.onDismiss==null||x.onDismiss.call(x,x)},className:Es(w?.closeButton,x==null||(l=x.classNames)==null?void 0:l.closeButton)},(te=D?.close)!=null?te:$k):null,(Ie||x.icon||x.promise)&&x.icon!==null&&(D?.[Ie]!==null||x.icon)?Ae.createElement("div",{"data-icon":"",className:Es(w?.icon,x==null||(c=x.classNames)==null?void 0:c.icon)},x.promise||x.type==="loading"&&!x.icon?x.icon||je():null,x.type!=="loading"?Ce:null):null,Ae.createElement("div",{"data-content":"",className:Es(w?.content,x==null||(d=x.classNames)==null?void 0:d.content)},Ae.createElement("div",{"data-title":"",className:Es(w?.title,x==null||(m=x.classNames)==null?void 0:m.title)},x.jsx?x.jsx:typeof x.title=="function"?x.title():x.title),x.description?Ae.createElement("div",{"data-description":"",className:Es(ue,F,w?.description,x==null||(g=x.classNames)==null?void 0:g.description)},typeof x.description=="function"?x.description():x.description):null),Ae.isValidElement(x.cancel)?x.cancel:x.cancel&&Tc(x.cancel)?Ae.createElement("button",{"data-button":!0,"data-cancel":!0,style:x.cancelButtonStyle||_,onClick:xe=>{Tc(x.cancel)&&we&&(x.cancel.onClick==null||x.cancel.onClick.call(x.cancel,xe),et())},className:Es(w?.cancelButton,x==null||(b=x.classNames)==null?void 0:b.cancelButton)},x.cancel.label):null,Ae.isValidElement(x.action)?x.action:x.action&&Tc(x.action)?Ae.createElement("button",{"data-button":!0,"data-action":!0,style:x.actionButtonStyle||K,onClick:xe=>{Tc(x.action)&&(x.action.onClick==null||x.action.onClick.call(x.action,xe),!xe.defaultPrevented&&et())},className:Es(w?.actionButton,x==null||(p=x.classNames)==null?void 0:p.actionButton)},x.action.label):null)};function cv(){if(typeof window>"u"||typeof document>"u")return"ltr";const n=document.documentElement.getAttribute("dir");return n==="auto"||!n?window.getComputedStyle(document.documentElement).direction:n}function u_(n,o){const r={};return[n,o].forEach((l,c)=>{const d=c===1,m=d?"--mobile-offset":"--offset",g=d?s_:n_;function b(p){["top","right","bottom","left"].forEach(v=>{r[`${m}-${v}`]=typeof p=="number"?`${p}px`:p})}typeof l=="number"||typeof l=="string"?b(l):typeof l=="object"?["top","right","bottom","left"].forEach(p=>{l[p]===void 0?r[`${m}-${p}`]=g:r[`${m}-${p}`]=typeof l[p]=="number"?`${l[p]}px`:l[p]}):b(g)}),r}const d_=Ae.forwardRef(function(o,r){const{id:l,invert:c,position:d="bottom-right",hotkey:m=["altKey","KeyT"],expand:g,closeButton:b,className:p,offset:v,mobileOffset:x,theme:S="light",richColors:j,duration:E,style:M,visibleToasts:O=t_,toastOptions:N,dir:T=cv(),gap:k=r_,icons:C,containerAriaLabel:U="Notifications"}=o,[A,L]=Ae.useState([]),_=Ae.useMemo(()=>l?A.filter(I=>I.toasterId===l):A.filter(I=>!I.toasterId),[A,l]),K=Ae.useMemo(()=>Array.from(new Set([d].concat(_.filter(I=>I.position).map(I=>I.position)))),[_,d]),[W,ue]=Ae.useState([]),[ne,$]=Ae.useState(!1),[oe,q]=Ae.useState(!1),[w,D]=Ae.useState(S!=="system"?S:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),H=Ae.useRef(null),B=m.join("+").replace(/Key/g,"").replace(/Digit/g,""),P=Ae.useRef(null),z=Ae.useRef(!1),X=Ae.useCallback(I=>{L(V=>{var Q;return(Q=V.find(Y=>Y.id===I.id))!=null&&Q.delete||An.dismiss(I.id),V.filter(({id:Y})=>Y!==I.id)})},[]);return Ae.useEffect(()=>An.subscribe(I=>{if(I.dismiss){requestAnimationFrame(()=>{L(V=>V.map(Q=>Q.id===I.id?{...Q,delete:!0}:Q))});return}setTimeout(()=>{EC.flushSync(()=>{L(V=>{const Q=V.findIndex(Y=>Y.id===I.id);return Q!==-1?[...V.slice(0,Q),{...V[Q],...I},...V.slice(Q+1)]:[I,...V]})})})}),[A]),Ae.useEffect(()=>{if(S!=="system"){D(S);return}if(S==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?D("dark"):D("light")),typeof window>"u")return;const I=window.matchMedia("(prefers-color-scheme: dark)");try{I.addEventListener("change",({matches:V})=>{D(V?"dark":"light")})}catch{I.addListener(({matches:Q})=>{try{D(Q?"dark":"light")}catch(Y){console.error(Y)}})}},[S]),Ae.useEffect(()=>{A.length<=1&&$(!1)},[A]),Ae.useEffect(()=>{const I=V=>{var Q;if(m.every(re=>V[re]||V.code===re)){var fe;$(!0),(fe=H.current)==null||fe.focus()}V.code==="Escape"&&(document.activeElement===H.current||(Q=H.current)!=null&&Q.contains(document.activeElement))&&$(!1)};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[m]),Ae.useEffect(()=>{if(H.current)return()=>{P.current&&(P.current.focus({preventScroll:!0}),P.current=null,z.current=!1)}},[H.current]),Ae.createElement("section",{ref:r,"aria-label":`${U} ${B}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},K.map((I,V)=>{var Q;const[Y,fe]=I.split("-");return _.length?Ae.createElement("ol",{key:I,dir:T==="auto"?cv():T,tabIndex:-1,ref:H,className:p,"data-sonner-toaster":!0,"data-sonner-theme":w,"data-y-position":Y,"data-x-position":fe,style:{"--front-toast-height":`${((Q=W[0])==null?void 0:Q.height)||0}px`,"--width":`${o_}px`,"--gap":`${k}px`,...M,...u_(v,x)},onBlur:re=>{z.current&&!re.currentTarget.contains(re.relatedTarget)&&(z.current=!1,P.current&&(P.current.focus({preventScroll:!0}),P.current=null))},onFocus:re=>{re.target instanceof HTMLElement&&re.target.dataset.dismissible==="false"||z.current||(z.current=!0,P.current=re.relatedTarget)},onMouseEnter:()=>$(!0),onMouseMove:()=>$(!0),onMouseLeave:()=>{oe||$(!1)},onDragEnd:()=>$(!1),onPointerDown:re=>{re.target instanceof HTMLElement&&re.target.dataset.dismissible==="false"||q(!0)},onPointerUp:()=>q(!1)},_.filter(re=>!re.position&&V===0||re.position===I).map((re,de)=>{var _e,Ye;return Ae.createElement(c_,{key:re.id,icons:C,index:de,toast:re,defaultRichColors:j,duration:(_e=N?.duration)!=null?_e:E,className:N?.className,descriptionClassName:N?.descriptionClassName,invert:c,visibleToasts:O,closeButton:(Ye=N?.closeButton)!=null?Ye:b,interacting:oe,position:I,style:N?.style,unstyled:N?.unstyled,classNames:N?.classNames,cancelButtonStyle:N?.cancelButtonStyle,actionButtonStyle:N?.actionButtonStyle,closeButtonAriaLabel:N?.closeButtonAriaLabel,removeToast:X,toasts:_.filter(Re=>Re.position==re.position),heights:W.filter(Re=>Re.position==re.position),setHeights:ue,expandByDefault:g,gap:k,expanded:ne,swipeDirections:o.swipeDirections})})):null}))}),rS=h.createContext(!1),aS=h.createContext(void 0);function _r(n){const o=h.useContext(aS);if(n===!1&&o===void 0)throw new Error(En(27));return o}const f_={...Ql,...tu},m_=h.forwardRef(function(o,r){const{render:l,className:c,style:d,forceRender:m=!1,...g}=o,{store:b}=_r(),p=b.useState("open"),v=b.useState("nested"),x=b.useState("mounted"),S=b.useState("transitionStatus");return mn("div",o,{state:{open:p,transitionStatus:S},ref:[b.context.backdropRef,r],stateAttributesMapping:f_,props:[{role:"presentation",hidden:!x,style:{userSelect:"none",WebkitUserSelect:"none"}},g],enabled:m||!v})}),lS=h.forwardRef(function(o,r){const{render:l,className:c,style:d,disabled:m=!1,nativeButton:g=!0,...b}=o,{store:p}=_r(),v=p.useState("open"),{getButtonProps:x,buttonRef:S}=Kl({disabled:m,native:g}),j={disabled:m};function E(M){v&&p.setOpen(!1,Ct(U0,M.nativeEvent))}return mn("button",o,{state:j,ref:[r,S],props:[{onClick:E},b,x]})}),p_=h.forwardRef(function(o,r){const{render:l,className:c,style:d,id:m,...g}=o,{store:b}=_r(),p=kr(m);return b.useSyncedValueWithCleanup("descriptionElementId",p),mn("p",o,{ref:r,props:[{id:p},g]})});let h_=(function(n){return n.nestedDialogs="--nested-dialogs",n})({}),g_=(function(n){return n[n.open=hr.open]="open",n[n.closed=hr.closed]="closed",n[n.startingStyle=hr.startingStyle]="startingStyle",n[n.endingStyle=hr.endingStyle]="endingStyle",n.nested="data-nested",n.nestedDialogOpen="data-nested-dialog-open",n})({});const iS=h.createContext(void 0);function x_(){const n=h.useContext(iS);if(n===void 0)throw new Error(En(26));return n}const b_={...Ql,...tu,nestedDialogOpen(n){return n?{[g_.nestedDialogOpen]:""}:null}},y_=h.forwardRef(function(o,r){const{render:l,className:c,style:d,finalFocus:m,initialFocus:g,...b}=o,{store:p}=_r(),v=p.useState("descriptionElementId"),x=p.useState("disablePointerDismissal"),S=p.useState("floatingRootContext"),j=p.useState("popupProps"),E=p.useState("modal"),M=p.useState("mounted"),O=p.useState("nested"),N=p.useState("nestedOpenDialogCount"),T=p.useState("open"),k=p.useState("openMethod"),C=p.useState("titleElementId"),U=p.useState("transitionStatus"),A=p.useState("role"),L=S.useState("floatingId"),_=b.id??L;x_(),au({open:T,ref:p.context.popupRef,onComplete(){T&&p.context.onOpenChangeComplete?.(!0)}});const K=g===void 0?M1(p.context.popupRef):g,W=N>0,ue=p.useStateSetter("popupElement"),$=mn("div",o,{state:{open:T,nested:O,transitionStatus:U,nestedDialogOpen:W},props:[j,{id:_,"aria-labelledby":C??void 0,"aria-describedby":v??void 0,role:A,...pu,hidden:!M,onKeyDown(oe){zp.has(oe.key)&&oe.stopPropagation()},style:{[h_.nestedDialogs]:N}},b],ref:[r,p.context.popupRef,ue],stateAttributesMapping:b_});return i.jsx(jp,{context:S,openInteractionType:k,disabled:!M,closeOnFocusOut:!x,initialFocus:K,returnFocus:m,modal:E!==!1,restoreFocus:"popup",children:$})}),v_=h.forwardRef(function(o,r){const{keepMounted:l=!1,...c}=o,{store:d}=_r(),m=d.useState("mounted"),g=d.useState("modal"),b=d.useState("open");return m||l?i.jsx(iS.Provider,{value:l,children:i.jsxs(vp,{ref:r,...c,children:[m&&g===!0&&i.jsx(Bp,{ref:d.context.internalBackdropRef,inert:Ip(!b)}),o.children]})}):null});function S_(n){const{store:o,actionsRef:r}=n,l=o.useState("open");I1(o,l),Rp(o);const{forceUnmount:c}=Op(l,o),d=h.useCallback(()=>{o.setOpen(!1,Ct(cp))},[o]);h.useImperativeHandle(r,()=>({unmount:c,close:d}),[c,d])}function E_({store:n,parentContext:o,isDrawer:r}){const l=n.useState("open"),c=n.useState("disablePointerDismissal"),d=n.useState("modal"),m=n.useState("popupElement"),g=n.useState("floatingRootContext"),[b,p]=h.useState(0),[v,x]=h.useState(0),S=b===0,j=Tp(g,{outsidePressEvent(){return n.context.internalBackdropRef.current||n.context.backdropRef.current?"intentional":{mouse:d==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(N){if(!n.context.outsidePressEnabledRef.current||"button"in N&&N.button!==0||"touches"in N&&N.touches.length!==1)return!1;const T=Dn(N);return S&&!c?d&&(n.context.internalBackdropRef.current||n.context.backdropRef.current)?n.context.internalBackdropRef.current===T||n.context.backdropRef.current===T||ot(T,m)&&!T?.hasAttribute("data-base-ui-portal"):!0:!1},escapeKey:S});J1(l&&d===!0,m),n.useContextCallback("onNestedDialogOpen",(N,T)=>{p(N),x(T)}),n.useContextCallback("onNestedDialogClose",()=>{p(0),x(0)}),h.useEffect(()=>(o?.onNestedDialogOpen&&l&&o.onNestedDialogOpen(b+1,v+(r?1:0)),o?.onNestedDialogClose&&!l&&o.onNestedDialogClose(),()=>{o?.onNestedDialogClose&&l&&o.onNestedDialogClose()}),[r,l,b,v,o]);const E=j.reference??Pt,M=j.trigger??Pt,O=j.floating??Pt;return kp(n,{activeTriggerProps:E,inactiveTriggerProps:M,popupProps:O,nestedOpenDialogCount:b,nestedOpenDrawerCount:v}),null}const N_={...Ap,modal:Ge(n=>n.modal),nested:Ge(n=>n.nested),nestedOpenDialogCount:Ge(n=>n.nestedOpenDialogCount),nestedOpenDrawerCount:Ge(n=>n.nestedOpenDrawerCount),disablePointerDismissal:Ge(n=>n.disablePointerDismissal),openMethod:Ge(n=>n.openMethod),descriptionElementId:Ge(n=>n.descriptionElementId),titleElementId:Ge(n=>n.titleElementId),viewportElement:Ge(n=>n.viewportElement),role:Ge(n=>n.role)};class Pp extends fu{constructor(o,r,l=!1){const c=new Jl,d=j_(o);d.floatingRootContext=B1(c,r,l),super(d,{popupRef:h.createRef(),backdropRef:h.createRef(),internalBackdropRef:h.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:c,onOpenChange:void 0,onOpenChangeComplete:void 0},N_)}setOpen=(o,r)=>{if(r.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!o&&r.trigger==null&&this.state.activeTriggerId!=null&&(r.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(o,r),r.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(o,r);const l={open:o};Cp(l,o,r.trigger),this.update(l)};static useStore(o,r){return A1(o,(c,d)=>new Pp(r,c,d),!0).store}}function j_(n={}){return{..._p(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...n}}function T_(n,o="dialog"){const{children:r,open:l,defaultOpen:c=!1,onOpenChange:d,onOpenChangeComplete:m,disablePointerDismissal:g=!1,modal:b=!0,actionsRef:p,handle:v,triggerId:x,defaultTriggerId:S=null}=n,j=o==="drawer",E=o==="alert-dialog",M=E?!0:b,O=E||g,N=E?"alertdialog":"dialog",T=_r(!0),C={modal:M,disablePointerDismissal:O,nested:!!T,role:N},U=Pp.useStore(v?.store,{open:c,openProp:l,activeTriggerId:S,triggerIdProp:x,...C});w1(()=>{const ue=l===void 0&&U.state.open===!1&&c===!0?{open:!0,activeTriggerId:S}:null;E?U.update(ue?{...C,...ue}:C):ue&&U.update(ue)}),U.useControlledProp("openProp",l),U.useControlledProp("triggerIdProp",x),U.useSyncedValues(C),U.useContextCallback("onOpenChange",d),U.useContextCallback("onOpenChangeComplete",m);const A=U.useState("open"),L=U.useState("mounted"),_=U.useState("payload");S_({store:U,actionsRef:p});const K=A||L,W=h.useMemo(()=>({store:U}),[U]);return i.jsx(rS.Provider,{value:!1,children:i.jsxs(aS.Provider,{value:W,children:[K&&i.jsx(E_,{store:U,parentContext:T?.store.context,isDrawer:j}),typeof r=="function"?r({payload:_}):r]})})}function w_(n){const o=h.useContext(rS)?"drawer":"dialog";return T_(n,o)}const C_=h.forwardRef(function(o,r){const{render:l,className:c,style:d,id:m,...g}=o,{store:b}=_r(),p=kr(m);return b.useSyncedValueWithCleanup("titleElementId",p),mn("h2",o,{ref:r,props:[{id:p},g]})});function ws({...n}){return i.jsx(w_,{"data-slot":"dialog",...n})}function R_({...n}){return i.jsx(v_,{"data-slot":"dialog-portal",...n})}function O_({className:n,...o}){return i.jsx(m_,{"data-slot":"dialog-overlay",className:Ze("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",n),...o})}function Cs({className:n,children:o,showCloseButton:r=!0,...l}){return i.jsxs(R_,{children:[i.jsx(O_,{}),i.jsxs(y_,{"data-slot":"dialog-content",className:Ze("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",n),...l,children:[o,r&&i.jsxs(lS,{"data-slot":"dialog-close",render:i.jsx(he,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm"}),children:[i.jsx(As,{}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Rs({className:n,...o}){return i.jsx("div",{"data-slot":"dialog-header",className:Ze("flex flex-col gap-2",n),...o})}function Os({className:n,showCloseButton:o=!1,children:r,...l}){return i.jsxs("div",{"data-slot":"dialog-footer",className:Ze("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",n),...l,children:[r,o&&i.jsx(lS,{render:i.jsx(he,{variant:"outline"}),children:"Close"})]})}function ks({className:n,...o}){return i.jsx(C_,{"data-slot":"dialog-title",className:Ze("font-heading text-base leading-none font-medium",n),...o})}function k_({className:n,...o}){return i.jsx(p_,{"data-slot":"dialog-description",className:Ze("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",n),...o})}const os={volume:"卷",chapter:"章",scene:"场"},__={volume:"chapter",chapter:"scene",scene:null};function ps({title:n,description:o,confirmLabel:r,danger:l=!1,onConfirm:c,onClose:d}){const[m,g]=h.useState(null),[b,p]=h.useState(!1);async function v(){p(!0),g(null);try{await c(),d()}catch(x){g(x instanceof ze?x.message:"操作失败,请稍后重试")}finally{p(!1)}}return i.jsx(ws,{open:!0,onOpenChange:x=>!x&&d(),children:i.jsxs(Cs,{className:"sm:max-w-md",children:[i.jsx(Rs,{children:i.jsx(ks,{children:n})}),i.jsx("p",{className:"text-sm text-muted-foreground",children:o}),m&&i.jsx("p",{className:"mt-2 text-sm text-destructive",children:m}),i.jsxs(Os,{children:[i.jsx(he,{variant:"outline",type:"button",onClick:d,disabled:b,children:"取消"}),i.jsx(he,{variant:l?"destructive":"default",type:"button",onClick:()=>{v()},disabled:b,children:r})]})]})})}const uv="ai-editor:theme";function cS(){const[n,o]=h.useState("light");h.useEffect(()=>{const c=localStorage.getItem(uv)==="dark"?"dark":"light";o(c),document.documentElement.classList.toggle("dark",c==="dark")},[]);function r(){const l=n==="dark"?"light":"dark";localStorage.setItem(uv,l),document.documentElement.classList.toggle("dark",l==="dark"),o(l)}return{theme:n,toggleTheme:r}}const M_=({...n})=>{const{theme:o="light"}=cS();return i.jsx(d_,{theme:o,position:"top-right",className:"toaster group",icons:{success:i.jsx(Ym,{className:"size-4"}),info:i.jsx(Wv,{className:"size-4"}),warning:i.jsx(qm,{className:"size-4"}),error:i.jsx(Jj,{className:"size-4"}),loading:i.jsx(Il,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},toastOptions:{classNames:{toast:"cn-toast"}},...n})};function A_(n,o){return n!==null&&n.id!==o}function D_(){const n=ke(r=>r.confirmState),o=ke(r=>r.resolveConfirm);return n===null?null:i.jsx(ps,{title:n.title,description:n.description??"",confirmLabel:"确认",danger:n.danger,onConfirm:async()=>o(!0),onClose:()=>o(!1)})}function z_(){const n=ke(c=>c.toast),o=ke(c=>c.error),r=ke(c=>c.clearError),l=h.useRef(null);return h.useEffect(()=>{!n||!A_(n,l.current)||(l.current=n.id,n.kind==="error"?lv.error(n.text,{duration:fm}):lv.success(n.text,{duration:fm}))},[n]),i.jsxs(i.Fragment,{children:[i.jsx(M_,{}),i.jsx(D_,{}),o&&i.jsxs("div",{role:"alert",className:"fixed top-4 left-1/2 z-50 flex w-[min(92vw,32rem)] -translate-x-1/2 items-center gap-2 rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive shadow-lg",children:[i.jsx(Pm,{className:"size-4 shrink-0"}),i.jsx("p",{className:"min-w-0 flex-1",children:o.message}),i.jsx("button",{type:"button","aria-label":"关闭错误提示",onClick:r,className:"shrink-0 rounded p-0.5 hover:bg-destructive/15",children:i.jsx(As,{className:"size-4"})})]})]})}function L_({chatOpen:n,onToggleChat:o}){const r=Be(v=>v.config),l=Be(v=>v.configLoading),c=Be(v=>v.outline),d=ke(v=>v.setFocusOutlineNode),m=ke(v=>v.notifyDataChanged),g=$m("(min-width: 1024px)"),b=r?.currentPosition!=null?j0(c,r.currentPosition)??r.currentPosition:null,p=l?"加载中…":r?.name??"书架";return i.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-4",children:[i.jsxs("a",{href:"#/",className:"flex min-w-0 items-center gap-1.5 font-serif text-base font-medium text-foreground hover:text-primary",children:[i.jsx("span",{className:"text-primary",children:"◈"}),i.jsx("span",{className:"truncate",children:p})]}),i.jsxs("a",{href:"#/outline",onClick:()=>{r?.currentPosition!=null&&d(r.currentPosition)},title:r?.currentPosition!=null?"跳转大纲并定位该节点":void 0,className:"flex min-w-0 items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground",children:[i.jsx("span",{className:"shrink-0",children:"当前位置:"}),i.jsx("span",{className:"truncate text-foreground",children:b??"未设置"})]}),i.jsx(he,{variant:"ghost",size:"icon-sm",className:"ml-auto shrink-0 text-muted-foreground",onClick:m,"aria-label":"刷新数据",title:"刷新数据",children:i.jsx(hT,{className:"size-4"})}),i.jsxs("span",{className:"shrink-0 text-sm text-muted-foreground",children:["语言: ",r?.language??"—"]}),!g&&i.jsx(he,{variant:"ghost",size:"icon-sm",className:n?"bg-secondary text-foreground":"text-muted-foreground",onClick:o,"aria-label":n?"关闭聊天面板":"打开聊天面板",children:i.jsx(Bl,{className:"size-4"})})]})}const I_=[{label:"概览",href:"#/",segment:null,icon:Bj},{label:"大纲",href:"#/outline",segment:"outline",icon:Yj},{label:"画布",href:"#/canvas",segment:"canvas",icon:NT},{label:"实体关系",href:"#/entities/character",segment:"entities",icon:Qj},{label:"伏笔",href:"#/hooks",segment:"hooks",icon:mT},{label:"时间轴",href:"#/timeline",segment:"timeline",icon:vj},{label:"回收站",href:"#/trash",segment:"trash",icon:t0}];function B_({route:n}){const o=n.segments[0]??null,r=Be(d=>d.loadError==="NO_PROJECT_OPEN"),l=ke(d=>d.showToast),c=(d,m)=>{!r||m.segment===null||(d.preventDefault(),window.location.hash="#/",l("请先创建或打开项目"))};return i.jsx("nav",{"aria-label":"页面导航",className:"flex items-center gap-1 rounded-lg bg-secondary/30 p-1",children:I_.map(d=>{const m=d.icon,g=o===d.segment;return i.jsxs("a",{href:d.href,"aria-current":g?"page":void 0,onClick:b=>c(b,d),className:Ze("flex min-w-0 flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground",g&&"bg-card text-foreground shadow-sm"),children:[i.jsx(m,{className:"size-4 shrink-0"}),i.jsx("span",{className:"truncate",children:d.label})]},d.label)})})}function U_({route:n,chatOpen:o,onToggleChat:r,isDesktop:l,children:c}){const d=Be(m=>m.loadConfig);return h.useEffect(()=>{d()},[d]),i.jsxs("main",{className:"flex min-w-0 flex-[5_1_50%] flex-col",style:l?{flex:"1 1 0%",minWidth:DT}:void 0,children:[i.jsx(L_,{chatOpen:o,onToggleChat:r}),i.jsx("div",{className:"shrink-0 px-3 py-2",children:i.jsx(B_,{route:n})}),i.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-6",children:c})]})}function Ll(n){switch(n){case"INVALID_PROJECT_PATH":return"路径无效:请使用绝对路径,且目标目录须已含 project.json(不是项目目录)";case"PROJECT_ALREADY_EXISTS":return"该目录已是项目,请直接打开(书架列表或「打开其他路径」)";case"PROJECT_VERSION_NEWER":return"该项目由更高版本的 ai-editor 创建,请升级程序后再打开(避免降级导致数据丢失)";case"NO_PROJECT_OPEN":return"";case"CLIENT_NETWORK_ERROR":return"无法连接服务,请确认 ai-editor 服务已启动";default:return"操作失败,请稍后重试"}}function H_(n,o){switch(n){case"PROJECT_ALREADY_EXISTS":return"同名书籍已存在,请换一个书名";case"SCHEMA_VERSION_MISMATCH":return o;case"VALIDATION_ERROR":return o;case"NO_PROJECT_OPEN":return"";case"CLIENT_NETWORK_ERROR":return"无法连接服务,请确认 ai-editor 服务已启动";default:return"导入失败,请稍后重试"}}function P_(n,o){return n==="CLIENT_NETWORK_ERROR"?"无法连接服务,请确认 ai-editor 服务已启动":o}function Ac(n){const o=n.trim();return o===""?"请输入书名":/[\\/]|^\.+$|[\u0000-\u001f]/.test(o)?"书名不能包含 /、\\ 或为 . / ..":null}let dv=(function(n){return n.disabled="data-disabled",n.valid="data-valid",n.invalid="data-invalid",n.touched="data-touched",n.dirty="data-dirty",n.filled="data-filled",n.focused="data-focused",n})({});const Y_={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Al={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},V_={disabled:!1,...Al},F_={valid(n){return n===null?null:n?{[dv.valid]:""}:{[dv.invalid]:""}}},G_={invalid:void 0,name:void 0,validityData:{state:Y_,errors:[],error:"",value:"",initialValue:null},setValidityData:dn,disabled:void 0,touched:Al.touched,setTouched:dn,dirty:Al.dirty,setDirty:dn,filled:Al.filled,setFilled:dn,focused:Al.focused,setFocused:dn,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:V_,markedDirtyRef:{current:!1},registerFieldControl:dn,validation:{getValidationProps:(n,o=Pt)=>o,inputRef:{current:null},registerInput:dn,commit:async()=>{},change:dn}},q_=h.createContext(G_);function uS(n=!0){const o=h.useContext(q_);if(o.setValidityData===dn&&!n)throw new Error(En(28));return o}const $_=h.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:dn,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function X_(){return h.useContext($_)}const K_=h.createContext({controlId:void 0,registerControlId:dn,labelId:void 0,setLabelId:dn,messageIds:[],setMessageIds:dn,getDescriptionProps:n=>n});function dS(){return h.useContext(K_)}function Q_(n={}){const{id:o,implicit:r=!1,controlRef:l}=n,{controlId:c,registerControlId:d}=dS(),m=kr(o),g=r?c:void 0,b=zn(()=>Symbol("labelable-control")),p=h.useRef(!1),v=h.useRef(o!=null),x=at(()=>{!p.current||d===dn||(p.current=!1,d(b.current,void 0))});return Qe(()=>{if(d===dn)return;let S;if(r){const j=l?.current;Et(j)&&j.closest("label")!=null?S=o??null:S=g??m}else if(o!=null)v.current=!0,S=o;else if(v.current)S=m;else{x();return}if(S===void 0){x();return}p.current=!0,d(b.current,S)},[o,l,g,d,r,m,b,x]),h.useEffect(()=>x,[x]),c??m}function Z_(n,o,r,l,c=!0,d){const{registerFieldControl:m}=uS(),g=h.useRef(null);g.current||(g.current=Symbol()),Qe(()=>{const b=g.current;return!b||!c?void 0:(m(b,{controlRef:n,getValue:l,id:o,name:d,value:r}),()=>{m(b,void 0)})},[n,c,l,o,d,m,r])}const J_=h.forwardRef(function(o,r){const{render:l,className:c,id:d,name:m,value:g,disabled:b=!1,onValueChange:p,defaultValue:v,autoFocus:x=!1,style:S,...j}=o,{state:E,name:M,disabled:O,setTouched:N,setDirty:T,validityData:k,setFocused:C,setFilled:U,validationMode:A,validation:L}=uS(),{clearErrors:_}=X_(),K=O||b,W=M??m,ue={...E,disabled:K},{labelId:ne}=dS(),$=Q_({id:d});Qe(()=>{const P=g!=null;L.inputRef.current?.value||P&&g!==""?U(!0):P&&g===""&&U(!1)},[L.inputRef,U,g]);const oe=h.useRef(null);Qe(()=>{x&&oe.current===jn(wt(oe.current))&&C(!0)},[x,C]);const[q]=aC({controlled:g,default:v,name:"FieldControl",state:"value"}),w=g!==void 0,D=w?q:void 0,H=at(()=>L.inputRef.current?.value);return Z_(L.inputRef,$,D,H,!K,m),mn("input",o,{ref:[r,oe],state:ue,props:[{id:$,disabled:K,name:W,ref:L.inputRef,"aria-labelledby":ne,autoFocus:x,...w?{value:D}:{defaultValue:v},onChange(P){const z=P.currentTarget.value;p?.(z,Ct(I0,P.nativeEvent)),T(z!==k.initialValue),U(z!==""),P.nativeEvent.defaultPrevented||(_(W),L.change(z))},onFocus(){C(!0)},onBlur(P){N(!0),C(!1),A==="onBlur"&&L.commit(P.currentTarget.value)},onKeyDown(P){P.currentTarget.tagName==="INPUT"&&P.key==="Enter"&&(N(!0),L.commit(P.currentTarget.value))}},j,P=>L.getValidationProps(K,P)],stateAttributesMapping:F_})}),W_=h.forwardRef(function(o,r){return i.jsx(J_,{ref:r,...o})});function Dt({className:n,type:o,...r}){return i.jsx(W_,{type:o,"data-slot":"input",className:Ze("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",n),...r})}function e3(n){const o=new Date(n);if(Number.isNaN(o.getTime()))return n;const r=c=>String(c).padStart(2,"0");return o.getFullYear()===new Date().getFullYear()?`${r(o.getMonth()+1)}-${r(o.getDate())}`:`${String(o.getFullYear()).slice(-2)}-${r(o.getMonth()+1)}-${r(o.getDate())}`}function t3(){const n=Nt(m=>m.sessions),o=Nt(m=>m.sessionsLoading),r=Nt(m=>m.sessionsError),l=Nt(m=>m.loadSessions),c=Nt(m=>m.currentSessionId),d=Nt(m=>m.setCurrentSession);return h.useEffect(()=>{n===null&&!o&&r===null&&l()},[n,o,r,l]),n===null?r!==null?r==="NO_PROJECT_OPEN"?i.jsx("p",{className:"ml-3 border-l border-border py-1 pl-2 text-xs text-muted-foreground/60",children:"打开项目后查看会话"}):i.jsxs("div",{className:"ml-3 border-l border-border py-1 pl-2",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:"会话加载失败"}),i.jsx(he,{variant:"ghost",size:"xs",className:"mt-0.5",onClick:()=>{l()},children:"重试"})]}):i.jsx("p",{className:"ml-3 border-l border-border py-1 pl-2 text-xs text-muted-foreground/60",children:"会话加载中…"}):n.length===0?i.jsx("p",{className:"ml-3 border-l border-border py-1 pl-2 text-xs text-muted-foreground/60",children:"暂无会话"}):i.jsx("ul",{className:"ml-3 border-l border-border py-0.5 pl-1.5",children:n.map(m=>i.jsx("li",{children:i.jsxs("button",{type:"button",title:m.lastMessage||"空会话",onClick:()=>d(m.id),className:Ze("flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left text-xs transition-colors",c===m.id?"bg-accent font-medium text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[i.jsx(Bl,{className:"size-3 shrink-0 opacity-70"}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:m.lastMessage||"(空会话)"}),i.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground/60",children:br(m.updatedAt)})]})},m.id))})}function n3({width:n,onToggleCollapse:o}){const{theme:r,toggleTheme:l}=cS(),c=Be(we=>we.config),d=Be(we=>we.bookshelf),m=Be(we=>we.bookshelfLoading),g=Be(we=>we.bookshelfError),b=Be(we=>we.loadBookshelf),p=Be(we=>we.openProjectAt),v=Be(we=>we.createProjectAt),[x,S]=h.useState(null),[j,E]=h.useState(!1),[M,O]=h.useState(""),[N,T]=h.useState(null),[k,C]=h.useState(!1),[U,A]=h.useState(!1),[L,_]=h.useState(null),[K,W]=h.useState(""),[ue,ne]=h.useState(null),[$,oe]=h.useState(!1),[q,w]=h.useState(!1),[D,H]=h.useState(""),[B,P]=h.useState(!1),[z,X]=h.useState(null),[I,V]=h.useState(""),[Q,Y]=h.useState(null),[fe,re]=h.useState(!1),de=h.useRef(null);h.useEffect(()=>{!m&&d===null&&g===null&&b()},[m,d,g,b]);async function _e(we){try{await p(we),S(we)}catch(ee){ke.getState().showToast(Ll(ee instanceof ze?ee.code:null),"error")}}const Ye=c?.id??null,Re=h.useRef(Ye);h.useEffect(()=>{Re.current!==Ye&&(Re.current=Ye,S(null),X(null))},[Ye]);function Le(){O(""),T(null),E(!1)}async function He(we){we.preventDefault();const ee=M.trim(),F=Ac(ee);if(F!==null){T(F);return}if(!d){T("书架未加载,请稍后重试");return}C(!0),T(null);try{await v(T0(d.rootPath,ee),{name:ee,language:"zh"}),ke.getState().showToast(`已创建并打开《${ee}》`),await b();const ie=Be.getState().bookshelf?.books.find(Z=>Z.name===ee);ie&&S(ie.path),O(""),E(!1)}catch(ie){T(Ll(ie instanceof ze?ie.code:null))}finally{C(!1)}}async function ge(we){if(!B){P(!0);try{const{blob:ee,filename:F}=await t2(),ie=URL.createObjectURL(ee),Z=document.createElement("a");Z.href=ie,Z.download=F,document.body.appendChild(Z),Z.click(),Z.remove(),setTimeout(()=>URL.revokeObjectURL(ie),0),ke.getState().showToast(`已导出《${we}》备份`)}catch(ee){ke.getState().showToast(P_(ee instanceof ze?ee.code:null,ee instanceof ze?ee.message:"导出失败,请重试"),"error")}finally{P(!1)}}}function pe(we){const ee=we.target.files?.[0]??null;if(_(ee),ne(null),ee){const F=ee.name.replace(/\.zip$/i,""),ie=K.trim()===""?F:K;W(ie),ve(ie)}}function ve(we){const ee=we.trim(),F=ie=>d?.books.some(Z=>Z.name===ie)??!1;if(q){if(ee===`${D} (2)`||ee===D&&F(ee))return;if(F(ee)){H(ee),W(`${ee} (2)`);return}w(!1),H("");return}ee!==""&&F(ee)&&(H(ee),w(!0),W(`${ee} (2)`))}function Ue(we){const ee=we.target.value;W(ee),ve(ee)}async function ye(we,ee){const F=we.trim();if(!L){ne("请选择备份文件");return}const ie=Ac(F);if(ie!==null){ne(ie);return}oe(!0),ne(null);try{const Z=await n2(L,F);ke.getState().showToast(Z.mode==="restored"?`已恢复备份《${Z.name}》`:`已导入为新书《${Z.name}》`),await b(),A(!1),_(null),W(""),w(!1),H("")}catch(Z){const Ee=H_(Z instanceof ze?Z.code:null,Z instanceof ze?Z.message:"导入失败,请重试");ne(Ee),Ee!==""&&ke.getState().showToast(Ee,"error")}finally{oe(!1)}}function De(we){X(we.path),V(we.name),Y(null),window.setTimeout(()=>de.current?.focus(),150)}function Pe(){X(null),V(""),Y(null)}async function Ie(){if(z===null||fe)return;const we=I.trim();if(we===Be.getState().config?.name){Pe();return}const ee=Ac(we);if(ee!==null){Y(ee);return}re(!0),Y(null);try{await l2(we),ke.getState().showToast(`已重命名为《${we}》`),await Promise.all([b(),Be.getState().loadConfig()]),Pe()}catch(F){(F instanceof ze?F.code:null)==="PROJECT_ALREADY_EXISTS"?Y("书架已有同名书籍,请换一个名字"):F instanceof ze&&F.code!==ft?Y(F.message):Y("无法连接服务,请确认 ai-editor 服务已启动")}finally{re(!1)}}return i.jsxs("aside",{className:"flex min-w-0 flex-[1_1_10%] flex-col border-r border-border bg-sidebar",style:n!==void 0?{flex:`0 1 ${n}px`,minWidth:Ul}:void 0,children:[i.jsxs("div",{className:"flex h-12 shrink-0 items-center border-b border-border",children:[i.jsxs("a",{href:"#/",className:"flex h-full min-w-0 flex-1 items-center gap-1.5 px-3 font-serif text-base italic text-foreground hover:text-primary",children:[i.jsx("span",{className:"text-primary",children:"◈"}),i.jsx("span",{className:"truncate",children:"我的小说"})]}),o&&i.jsx("button",{type:"button",onClick:o,"aria-label":"收起左栏",title:"收起左栏",className:"mr-1.5 flex size-7 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:i.jsx(eT,{className:"size-4"})})]}),i.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2",children:[i.jsxs("div",{className:"mb-1 flex items-center justify-between px-1",children:[i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"书架"}),i.jsxs("div",{className:"flex items-center gap-0.5",children:[i.jsx(he,{variant:"ghost",size:"icon-xs",onClick:()=>A(!0),"aria-label":"导入备份",title:"导入备份(zip)",children:i.jsx(kT,{})}),j?i.jsx(he,{variant:"ghost",size:"icon-xs",onClick:Le,"aria-label":"取消新建项目",title:"取消新建",children:i.jsx(As,{})}):i.jsx(he,{variant:"ghost",size:"icon-xs",onClick:()=>E(!0),"aria-label":"新建项目",title:"新建项目",children:i.jsx(Gm,{})})]})]}),j&&i.jsxs("form",{onSubmit:He,className:"mb-1 flex flex-col gap-1 px-1","aria-label":"新建项目",children:[i.jsx(Dt,{value:M,onChange:we=>O(we.target.value),onKeyDown:we=>{we.key==="Escape"&&Le()},onBlur:Le,placeholder:"书名,回车创建",maxLength:60,disabled:k,autoFocus:!0,"aria-label":"书名"}),N&&i.jsx("p",{className:"text-xs text-destructive",children:N})]}),g!==null&&i.jsxs("div",{className:"flex flex-col items-start gap-1 px-1 py-2",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:g===ft?"无法连接服务":"书架加载失败"}),i.jsx(he,{variant:"ghost",size:"xs",onClick:()=>{b()},children:"重试"})]}),m&&d===null&&i.jsx("div",{className:"space-y-1 px-1 py-2",children:[0,1,2].map(we=>i.jsx("div",{className:"h-8 animate-pulse rounded-lg bg-muted"},we))}),g===null&&!m&&d&&d.books.length===0&&i.jsx("p",{className:"px-1 py-2 text-xs text-muted-foreground/70",children:"还没有书,先创建一本"}),g===null&&d&&d.books.length>0&&i.jsx("ul",{className:"space-y-0.5",children:d.books.map(we=>{const ee=x===we.path,F=c!==null&&we.name===c.name,ie=z===we.path;return i.jsxs("li",{children:[i.jsxs("div",{className:"flex items-center",children:[ie?i.jsxs("div",{className:"flex h-8 min-w-0 flex-1 items-center gap-1.5 rounded-lg bg-muted px-2",children:[i.jsx(Lc,{className:"size-3.5 shrink-0 text-primary"}),i.jsx(Dt,{ref:de,value:I,onChange:Z=>V(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"?(Z.preventDefault(),Ie()):Z.key==="Escape"&&Pe()},onBlur:()=>{Ie()},maxLength:60,disabled:fe,"aria-label":"重命名书名",className:"h-6 min-w-0 flex-1 rounded-md bg-transparent px-1.5 text-sm focus-visible:ring-2"})]}):i.jsxs("button",{type:"button",title:`打开《${we.name}》`,onClick:()=>{_e(we.path)},className:Ze("flex h-8 min-w-0 flex-1 items-center gap-1.5 rounded-lg px-2 text-left text-sm transition-colors",F?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[i.jsx(Lc,{className:Ze("size-3.5 shrink-0",F?"text-primary":"text-muted-foreground/60")}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:we.name}),i.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground/60",title:is(we.updatedAt),children:e3(we.updatedAt)})]}),F&&i.jsx("button",{type:"button",onClick:()=>{ge(we.name)},disabled:B,"aria-label":`导出《${we.name}》备份`,title:"导出备份(zip)",className:"flex h-8 w-6 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50",children:B?i.jsx(Il,{className:"size-3.5 animate-spin"}):i.jsx(_j,{className:"size-3.5"})}),i.jsx("button",{type:"button",onClick:()=>S(Z=>Z===we.path?null:we.path),"aria-expanded":ee,"aria-label":ee?`收起《${we.name}》会话`:`展开《${we.name}》会话`,className:"flex h-8 w-6 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:i.jsx(Hm,{className:Ze("size-4 transition-transform duration-200",ee&&"rotate-90")})}),F&&i.jsxs(gu,{children:[i.jsx(xu,{render:i.jsx("button",{type:"button","aria-label":`《${we.name}》更多操作`,title:"更多操作",className:"flex h-8 w-6 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:i.jsx(Vm,{className:"size-3.5"})})}),i.jsx(bu,{children:i.jsx(fs,{onClick:()=>De(we),children:"重命名"})})]})]}),ie&&Q&&i.jsx("p",{className:"px-2 pb-1 text-xs text-destructive",children:Q}),ee&&i.jsx(t3,{})]},we.path)})})]}),i.jsxs("div",{className:"flex shrink-0 flex-col gap-1 border-t border-border p-2",children:[i.jsxs("a",{href:"#/settings",className:"flex h-8 items-center gap-2 rounded-lg px-2 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[i.jsx(ST,{className:"size-4 shrink-0"}),i.jsx("span",{className:"truncate",children:"设置"})]}),i.jsxs(he,{variant:"ghost",size:"sm",className:"justify-start text-muted-foreground",onClick:l,"aria-label":"切换主题",children:[r==="dark"?i.jsx(wT,{className:"size-4 shrink-0"}):i.jsx(Xj,{className:"size-4 shrink-0"}),i.jsx("span",{className:"truncate",children:r==="dark"?"浅色模式":"深色模式"})]})]}),i.jsx(ws,{open:U,onOpenChange:we=>{A(we),we||(ne(null),_(null),W(""),w(!1),H(""))},children:i.jsxs(Cs,{className:"sm:max-w-sm",children:[i.jsxs(Rs,{children:[i.jsx(ks,{children:"导入书籍"}),i.jsx(k_,{children:"从备份 zip 导入;与书架已有书 id 匹配时覆盖恢复,否则导入为新书(同名可重命名或保持原样并存)"})]}),i.jsxs("form",{id:"import-book-form",onSubmit:we=>{we.preventDefault(),ye(K)},className:"flex flex-col gap-3",children:[i.jsx("input",{type:"file",accept:".zip,application/zip",onChange:pe,disabled:$,"aria-label":"选择备份文件",className:"block w-full cursor-pointer rounded-md border border-border bg-card px-3 py-1.5 text-sm text-foreground file:mr-2 file:cursor-pointer file:rounded file:border-0 file:bg-muted file:px-2 file:py-1 file:text-xs file:text-muted-foreground disabled:opacity-50"}),i.jsx(Dt,{value:K,onChange:Ue,placeholder:"书名(默认取文件名)",maxLength:60,disabled:$}),q&&i.jsxs("p",{className:"text-sm text-primary",children:["书架已有同名书籍《",D,"》——可重命名导入,或保持原样(服务端自动去重)"]}),ue&&i.jsx("p",{className:"text-sm text-destructive",children:ue})]}),i.jsxs(Os,{children:[i.jsx(he,{variant:"outline",type:"button",onClick:()=>A(!1),disabled:$,children:"取消"}),q?i.jsxs(i.Fragment,{children:[i.jsx(he,{variant:"outline",type:"button",onClick:()=>{ye(D)},disabled:$||L===null,children:$?"导入中…":"保持原样导入"}),i.jsx(he,{type:"button",onClick:()=>{ye(K)},disabled:$||L===null,children:$?"导入中…":"重命名导入"})]}):i.jsx(he,{type:"submit",form:"import-book-form",disabled:$||L===null,children:$?"导入中…":"导入"})]})]})})]})}function fv({side:n,active:o,onStart:r,onMove:l,onEnd:c}){return i.jsxs("div",{role:"separator","aria-orientation":"vertical","aria-label":n==="sidebar"?"调整左栏宽度":"调整右栏宽度",title:n==="sidebar"?"拖动调整左栏宽度":"拖动调整右栏宽度",onPointerDown:d=>{d.preventDefault(),d.currentTarget.setPointerCapture(d.pointerId),r(n,d.clientX)},onPointerMove:d=>l(n,d.clientX),onPointerUp:c,onPointerCancel:c,className:Ze("group relative z-10 h-full w-1.5 shrink-0 cursor-col-resize touch-none bg-transparent transition-colors hover:bg-border",o&&"bg-border"),children:[i.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border/60 transition-colors group-hover:bg-primary/70"}),i.jsx(Fm,{className:"absolute inset-y-0 left-1/2 size-4 -translate-x-1/2 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100"})]})}function mv({side:n,onExpand:o}){const r=n==="sidebar",l=r?nT:aT;return i.jsx("div",{className:Ze("flex h-full w-8 shrink-0 flex-col items-center bg-sidebar",r?"border-r border-border":"border-l border-border"),children:i.jsx("button",{type:"button",onClick:o,"aria-label":r?"展开左栏":"展开右栏",title:r?"展开左栏":"展开右栏",className:"mt-3 flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:i.jsx(l,{className:"size-4"})})})}function s3({route:n,children:o}){const[r,l]=h.useState(!1),{layout:c,isDesktop:d,dragSide:m,toggleCollapse:g,startResize:b,moveResize:p,endResize:v}=BT(),x=m!==null;return i.jsxs("div",{className:Ze("flex h-screen overflow-hidden",x&&"select-none"),children:[d&&c.collapsedSidebar?i.jsx(mv,{side:"sidebar",onExpand:()=>g("sidebar")}):i.jsx(n3,{width:d?c.sidebarWidth:void 0,onToggleCollapse:d?()=>g("sidebar"):void 0}),d&&!c.collapsedSidebar&&i.jsx(fv,{side:"sidebar",active:m==="sidebar",onStart:b,onMove:p,onEnd:v}),i.jsx(U_,{isDesktop:d,route:n,chatOpen:r,onToggleChat:()=>l(S=>!S),children:o}),d&&!c.collapsedChat&&i.jsx(fv,{side:"chat",active:m==="chat",onStart:b,onMove:p,onEnd:v}),d&&c.collapsedChat?i.jsx(mv,{side:"chat",onExpand:()=>g("chat")}):i.jsx(Bk,{open:r,onClose:()=>l(!1),width:d?c.chatWidth:void 0,onToggleCollapse:d?()=>g("chat"):void 0}),i.jsx(z_,{})]})}class o3 extends h.Component{state={error:null};static getDerivedStateFromError(o){return{error:o}}componentDidCatch(o,r){console.error("[ErrorBoundary] 渲染异常:",o,r.componentStack)}render(){const{error:o}=this.state;return o===null?this.props.children:i.jsx("div",{className:"flex h-full min-h-64 flex-col items-center justify-center gap-3 p-8",children:i.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-xl border border-destructive/30 bg-destructive/10 px-8 py-6 text-center",children:[i.jsx(Pm,{className:"size-8 text-destructive"}),i.jsx("p",{className:"font-serif text-base font-medium text-foreground",children:"界面出现异常"}),i.jsx("p",{className:"max-w-md text-sm text-muted-foreground",children:"数据不会丢失,请重新加载页面继续写作。"}),i.jsx("p",{className:"max-w-md break-all font-mono text-xs text-destructive/80",children:o.message||String(o)}),i.jsxs("div",{className:"mt-2 flex gap-2",children:[i.jsxs(he,{type:"button",onClick:()=>window.location.reload(),children:[i.jsx(xT,{className:"size-4"}),"重新加载"]}),i.jsx(he,{variant:"outline",type:"button",onClick:()=>{window.location.hash="#/",window.location.reload()},children:"回到首页"})]})]})})}}function Ds(n){const o=ke(l=>l.dataVersion),r=h.useRef(o);h.useEffect(()=>{o!==r.current&&(r.current=o,n())},[o])}const pv={character:"人物",setting:"设定",location:"地点",hook:"伏笔",event:"事件",timepoint:"时间点"},hv=["character","setting","location","hook"];function r3(n){const o={volumes:0,chapters:0,scenes:0,updatedAt:null},r=l=>{for(const c of l)c.type==="volume"?o.volumes+=1:c.type==="chapter"?o.chapters+=1:o.scenes+=1,(o.updatedAt===null||c.updatedAt>o.updatedAt)&&(o.updatedAt=c.updatedAt),c.type!=="scene"&&c.children&&r(c.children)};return r(n),o}function em(n){return n instanceof ze?n.code:null}function gv(){const n=Be(ge=>ge.config),o=Be(ge=>ge.configLoading),r=Be(ge=>ge.outline),l=Be(ge=>ge.outlineLoading),c=Be(ge=>ge.loadOutline),d=Be(ge=>ge.bookshelf),m=Be(ge=>ge.bookshelfLoading),g=Be(ge=>ge.bookshelfError),b=Be(ge=>ge.loadBookshelf),p=Be(ge=>ge.openProjectAt),v=Be(ge=>ge.createProjectAt),x=Nt(ge=>ge.sessions),S=Nt(ge=>ge.sessionsLoading),j=Nt(ge=>ge.sessionsError),E=Nt(ge=>ge.loadSessions),M=Nt(ge=>ge.setCurrentSession),O=Nt(ge=>ge.currentSessionId),N=ke(ge=>ge.setFocusOutlineNode),[T,k]=h.useState(""),[C,U]=h.useState(null),[A,L]=h.useState(null),[_,K]=h.useState(!1),[W,ue]=h.useState(!1),[ne,$]=h.useState(""),[oe,q]=h.useState(null),[w,D]=h.useState(!1),[H,B]=h.useState(null),[P,z]=h.useState(!1),[X,I]=h.useState(null),[V,Q]=h.useState(0),[Y,fe]=h.useState(!1),re=n===null&&!o,de=r?r3(r.children):null,_e=n?.currentPosition!=null?j0(r,n.currentPosition)??n.currentPosition:null;h.useEffect(()=>{re&&!m&&d===null&&g===null&&b()},[re,m,d,g,b]),h.useEffect(()=>{fe(!1)},[n?.id]),Ds(()=>{Q(ge=>ge+1),c(),E()}),h.useEffect(()=>{L(null)},[n?.id]),h.useEffect(()=>{n!==null&&r===null&&!l&&!Y&&(fe(!0),c())},[n,r,l,Y,c]),h.useEffect(()=>{if(n===null)return;let ge=!1;return B(null),z(!0),I(null),Promise.allSettled(hv.map(async pe=>({type:pe,total:(await ls(pe,{limit:1})).total}))).then(pe=>{if(ge)return;const ve={};let Ue=!1;for(const ye of pe)ye.status==="fulfilled"?ve[ye.value.type]=ye.value.total:Ue=!0;B(ve),I(Ue?"要素统计加载失败":null),z(!1)}),()=>{ge=!0}},[n,V]),h.useEffect(()=>{n!==null&&x===null&&!S&&j===null&&E()},[n,x,S,j,E]);async function Ye(ge){ge.preventDefault();const pe=T.trim(),ve=Ac(pe);if(ve!==null){U(ve);return}if(!d){U("书架未加载,请稍后重试");return}D(!0),U(null);try{await v(T0(d.rootPath,pe),{name:pe,language:"zh"}),await b(),ke.getState().showToast(`已创建并打开《${pe}》`),k("")}catch(Ue){U(Ll(em(Ue)))}finally{D(!1)}}async function Re(ge){if(ge.preventDefault(),!ne.trim()){q("请输入项目目录路径(绝对路径)");return}D(!0),q(null);try{await p(ne.trim())}catch(pe){q(Ll(em(pe)))}finally{D(!1)}}async function Le(ge){L(null);try{await p(ge)}catch(pe){L(Ll(em(pe)))}}function He(){n?.currentPosition!=null&&N(n.currentPosition)}if(o)return i.jsx("section",{children:i.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"加载中…"})});if(re){let ge=function(ye){return i.jsxs("form",{onSubmit:Ye,className:ye,children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Dt,{value:T,onChange:De=>k(De.target.value),placeholder:"书名",maxLength:60,disabled:w}),i.jsx(he,{type:"submit",disabled:w||d===null,children:"新建"})]}),C&&i.jsx("p",{className:"text-left text-sm text-destructive",children:C})]})};const pe=d===null&&m,ve=g!==null,Ue=d!==null&&d.books.length>0;return i.jsxs("section",{children:[g!==null&&i.jsxs("div",{className:"mx-auto mt-2 max-w-md rounded-md border border-border bg-card p-3",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:g===ft?"无法连接服务,请确认 ai-editor 服务已启动后重试。":"书架加载失败,请重试。"}),i.jsx(he,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>{b()},type:"button",children:"重试"})]}),i.jsx("div",{className:"mx-auto mt-10 max-w-md rounded-2xl border border-dashed border-border bg-card px-6 py-8 text-center",children:pe?i.jsxs("div",{className:"py-2",children:[i.jsx("div",{className:"mx-auto h-6 w-2/3 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"mx-auto mt-2 h-4 w-1/2 animate-pulse rounded bg-muted"}),i.jsxs("div",{className:"mt-5 space-y-2",children:[i.jsx("div",{className:"h-10 animate-pulse rounded-lg bg-muted"}),i.jsx("div",{className:"h-10 animate-pulse rounded-lg bg-muted"})]})]}):i.jsxs(i.Fragment,{children:[Ue?i.jsxs(i.Fragment,{children:[i.jsx("h1",{className:"font-serif text-lg text-foreground",children:"书架里有书,打开即可写作"}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"选择一本书打开,或新建一本"}),i.jsx("ul",{className:"mt-5 divide-y divide-border overflow-hidden rounded-lg border border-border text-left",children:d.books.map(ye=>i.jsx("li",{children:i.jsxs("button",{type:"button",title:`打开《${ye.name}》`,onClick:()=>{Le(ye.path)},className:"flex w-full items-center gap-3 px-3 py-2.5 text-left transition-colors hover:bg-muted",children:[i.jsx(Lc,{className:"size-4 shrink-0 text-muted-foreground/60"}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:ye.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:br(ye.updatedAt)})]})},ye.path))}),A!==null&&i.jsx("p",{className:"mt-3 text-left text-sm text-destructive",children:A}),i.jsxs("div",{className:"mt-4 border-t border-border pt-3",children:[i.jsx("button",{type:"button",className:"text-sm text-muted-foreground transition-colors hover:text-foreground",onClick:()=>K(ye=>!ye),children:_?"收起":"新建一本…"}),_&&ge("mt-2 flex flex-col gap-2 text-left")]})]}):ve?i.jsx("p",{className:"py-6 text-sm text-muted-foreground",children:"书架加载失败,重试后可查看书籍或新建"}):i.jsxs(i.Fragment,{children:[i.jsx("h1",{className:"font-serif text-lg text-foreground",children:"还没有书,先创建一本"}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"每本书一个独立目录(books/书名/),写作数据互不干扰"}),ge("mx-auto mt-5 flex flex-col gap-2"),i.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"创建于 创作根/books/书名/ 目录"})]}),i.jsxs("div",{className:"mt-4 border-t border-border pt-3",children:[i.jsx("button",{type:"button",className:"text-sm text-muted-foreground transition-colors hover:text-foreground",onClick:()=>ue(ye=>!ye),children:W?"收起":"打开其他路径…"}),W&&i.jsxs("form",{onSubmit:Re,className:"mt-2 flex flex-col gap-2 text-left",children:[i.jsx(Dt,{value:ne,onChange:ye=>$(ye.target.value),placeholder:"/absolute/path/to/project(须含 project.json)",disabled:w}),i.jsx("div",{children:i.jsx(he,{type:"submit",variant:"outline",disabled:w,children:"打开"})}),oe&&i.jsx("p",{className:"text-sm text-destructive",children:oe})]})]})]})})]})}return i.jsxs("section",{children:[i.jsx("div",{className:"mb-4",children:i.jsx("h1",{className:"font-serif text-xl font-medium text-foreground",children:"项目概览"})}),i.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[i.jsxs("section",{className:"rounded-xl border border-border bg-card p-4",children:[i.jsx("h2",{className:"font-serif text-base text-foreground",children:"项目信息"}),i.jsxs("dl",{className:"mt-3 space-y-2 text-sm",children:[i.jsxs("div",{className:"flex items-baseline gap-2",children:[i.jsx("dt",{className:"w-16 shrink-0 text-muted-foreground",children:"名称"}),i.jsx("dd",{className:"min-w-0 truncate font-medium text-foreground",children:n?.name})]}),i.jsxs("div",{className:"flex items-baseline gap-2",children:[i.jsx("dt",{className:"w-16 shrink-0 text-muted-foreground",children:"语言"}),i.jsx("dd",{className:"text-foreground",children:n?.language==="zh"?"中文":"English"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("dt",{className:"w-16 shrink-0 text-muted-foreground",children:"当前位置"}),i.jsx("dd",{className:"min-w-0 flex-1 truncate",children:n?.currentPosition!=null?i.jsx("a",{href:"#/outline",onClick:He,className:"text-primary hover:underline",children:_e??n.currentPosition}):i.jsx("span",{className:"text-muted-foreground",children:"未设置"})}),i.jsx("a",{href:"#/outline",onClick:He,className:hm({variant:"outline",size:"xs"}),children:"去大纲"})]})]}),i.jsxs("div",{className:"mt-3 border-t border-border pt-3",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:"项目提示词"}),i.jsx("p",{className:"mt-1 line-clamp-2 text-sm text-foreground/90",children:n?.prompt||"(未设置)"})]})]}),i.jsxs("section",{className:"rounded-xl border border-border bg-card p-4",children:[i.jsx("h2",{className:"font-serif text-base text-foreground",children:"创作要素"}),P&&H===null?i.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[0,1,2,3].map(ge=>i.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-muted"},ge))}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2",children:hv.map(ge=>i.jsxs("a",{href:`#/entities/${ge}`,className:"group rounded-lg border border-border bg-background p-3 transition-colors hover:border-primary/40 hover:bg-muted",title:`查看${pv[ge]}列表`,children:[i.jsx("p",{className:"font-serif text-2xl font-semibold text-foreground",children:H?.[ge]??"–"}),i.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground transition-colors group-hover:text-foreground",children:pv[ge]})]},ge))}),X!==null&&i.jsxs("div",{className:"mt-2 flex items-center gap-2 text-xs text-destructive",children:[X,i.jsx(he,{variant:"outline",size:"xs",type:"button",onClick:()=>Q(ge=>ge+1),children:"重试"})]})]})]}),i.jsxs("section",{className:"rounded-xl border border-border bg-card p-4 lg:col-span-2",children:[i.jsx("h2",{className:"font-serif text-base text-foreground",children:"大纲概览"}),r===null&&(l||!Y)?i.jsxs("div",{className:"mt-3 space-y-2",children:[i.jsx("div",{className:"h-5 w-2/5 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-4 w-1/3 animate-pulse rounded bg-muted"})]}):r===null?i.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm text-muted-foreground",children:["大纲加载失败",i.jsx(he,{variant:"outline",size:"xs",type:"button",onClick:()=>fe(!1),children:"重试"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"mt-3 text-sm text-foreground",children:["卷 ",de?.volumes??0," · 章 ",de?.chapters??0," · 场景"," ",de?.scenes??0]}),i.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["最近更新: ",de?.updatedAt?br(de.updatedAt):"—"]}),r.children.length===0&&i.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:"大纲还是空的"}),i.jsx(he,{variant:"ghost",size:"xs",type:"button",onClick:()=>M(null),children:"和 AI 聊聊设定"})]}),i.jsx("div",{className:"mt-3",children:i.jsx("a",{href:"#/outline",onClick:He,className:Ze(hm({variant:"outline",size:"sm"})),children:"去大纲编辑"})})]})]}),i.jsxs("section",{className:"rounded-xl border border-border bg-card p-4 lg:col-span-2",children:[i.jsx("h2",{className:"font-serif text-base text-foreground",children:"最近会话"}),x===null?j!==null?i.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm text-muted-foreground",children:["会话加载失败",i.jsx(he,{variant:"outline",size:"xs",type:"button",onClick:()=>{E()},children:"重试"})]}):i.jsx("div",{className:"mt-3 space-y-2",children:[0,1,2].map(ge=>i.jsx("div",{className:"h-8 animate-pulse rounded-md bg-muted"},ge))}):x.length===0?i.jsxs("div",{className:"mt-3",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"还没有会话,和 AI 聊聊设定吧"}),i.jsx(he,{variant:"outline",size:"sm",className:"mt-3",type:"button",onClick:()=>M(null),children:"开始新对话"})]}):i.jsxs(i.Fragment,{children:[i.jsx("ul",{className:"mt-3 divide-y divide-border rounded-lg border border-border",children:x.slice(0,5).map(ge=>i.jsx("li",{children:i.jsxs("button",{type:"button",title:ge.lastMessage||"空会话",onClick:()=>M(ge.id),className:Ze("flex w-full items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-muted",O===ge.id&&"bg-accent/40 hover:bg-accent/40"),children:[i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:ge.lastMessage||"(空会话)"}),i.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[ge.messageCount," 条消息"]}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:br(ge.updatedAt)})]})},ge.id))}),i.jsx("div",{className:"mt-3",children:i.jsx(he,{variant:"outline",size:"sm",type:"button",onClick:()=>M(null),children:"开始新对话"})})]})]})]})]})}const xv={plants:"埋设",advances:"推进",resolves:"回收"},a3={plants:uT,advances:Dj,resolves:Ym};function fS({mark:n}){const o=a3[n.relationType];return i.jsx("span",{className:"shrink-0 rounded px-0.5 text-muted-foreground hover:text-foreground",title:`${xv[n.relationType]}伏笔:${n.hookName}`,"aria-label":`${xv[n.relationType]}伏笔:${n.hookName}`,children:i.jsx(o,{className:"size-3"})})}const Yp=["plants","advances","resolves"],bv=["plants","advances","resolves"];function yv(n){const o=bv.indexOf(n);return o===-1?bv.length:o}function mS(n){const o=new Map;for(const r of n){if(!Yp.includes(r.relationType)||r.sourceType!=="outline_node"||r.targetType!=="hook")continue;const l={relationType:r.relationType,hookId:r.targetId,hookName:r.targetName??r.targetId},c=o.get(r.sourceId);c===void 0?o.set(r.sourceId,[l]):c.push(l)}for(const r of o.values())r.sort((l,c)=>yv(l.relationType)-yv(c.relationType)||(l.hookName<c.hookName?-1:l.hookName>c.hookName?1:0)||(l.hookId<c.hookId?-1:l.hookId>c.hookId?1:0));return o}const Sn="root",vv={id:Sn,label:"(根)",depth:0};function l3(n,o){if(o==="volume")return[vv];const r=o==="chapter"?[vv]:[],l=(c,d)=>{for(const m of c)o==="chapter"&&m.type==="volume"?r.push({id:m.id,label:m.title,depth:d}):o==="scene"&&m.type==="chapter"&&r.push({id:m.id,label:m.title,depth:d}),m.children&&l(m.children,d+1)};return l(n,1),r}function Ho(n,o){for(const r of n){if(r.id===o)return r;if(r.type!=="scene"&&r.children){const l=Ho(r.children,o);if(l)return l}}return null}function Vp(n,o,r=[]){for(const l of n){const c=[...r,l.id];if(l.id===o)return c;if(l.type!=="scene"&&l.children){const d=Vp(l.children,o,c);if(d)return d}}return null}function ao(n,o=0,r=[]){for(const l of n)r.push({id:l.id,label:l.title,depth:o}),l.type!=="scene"&&l.children&&ao(l.children,o+1,r);return r}function i3(n,o,r){const l=Ho(n,o);if(!l)return!1;const c=d=>d.id===r?!0:d.type!=="scene"&&d.children?d.children.some(m=>c(m)):!1;return c(l)}function wc(n,o,r){return o===n.id||i3(r,n.id,o)?!1:l3(r,n.type).some(l=>l.id===o)}function pS(n,o){const r=o.trim();return r!==""&&r!==n.trim()}function hS(n,o){return o.trim()!==(n??"").trim()}function c3(n){return n==="OUTLINE_NODE_NOT_FOUND"?"abandon":"restore"}function gS(n,o){if(o===Sn)return n;const r=l=>{for(const c of l){if(c.id===o)return c.children??[];if(c.children){const d=r(c.children);if(d)return d}}return null};return r(n)}function Sv(n,o,r){const l=r===void 0?n:n.filter(d=>d.id!==r);if(o.kind==="end")return l.length;const c=l.findIndex(d=>d.id===o.nodeId);return c===-1?l.length:o.kind==="before"?c:c+1}function Ev(n,o){return n===null||o===null?n===o:n.kind==="root-end"||o.kind==="root-end"?n.kind===o.kind:n.kind===o.kind&&n.nodeId===o.nodeId}function km(n,o){const r=(l,c)=>{for(const d of l){if(d.id===o)return c;if(d.children){const m=r(d.children,d.id);if(m!==null)return m}}return null};return r(n,Sn)}function u3(n,o){const r=km(n,o);if(r===null)return null;const c=(gS(n,r)??[]).findIndex(d=>d.id===o);return c===-1?null:{parentId:r,index:c}}function Nv(n,o,r,l){const c=u3(n,o);return c===null||c.parentId!==r?!1:l===c.index}function Cc(n){return n instanceof ze?n.code:null}function ya(n){switch(n){case"OUTLINE_NODE_NOT_FOUND":return"节点不存在(可能已被彻底删除),大纲已刷新";case"CLIENT_NETWORK_ERROR":return"无法连接服务,请确认 ai-editor 服务已启动";default:return"操作失败,请稍后重试"}}function Dc(n,o,r,l,c){return i.jsx("input",{autoFocus:!0,value:n,onChange:d=>o(d.target.value),onKeyDown:r,onBlur:l,maxLength:200,placeholder:c,className:"min-w-0 flex-1 rounded border border-border bg-card px-1.5 py-0.5 text-sm text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring"})}function jv({type:n,onTypeChange:o,value:r,onChange:l,onKeyDown:c,onCancel:d,className:m}){return i.jsxs("div",{className:Ze("flex items-center gap-2 rounded-md px-2 py-1",m),children:[i.jsx("div",{className:"flex shrink-0 gap-1",children:["volume","chapter"].map(g=>i.jsx("button",{type:"button",onClick:()=>o(g),className:Ze("rounded border px-2 py-0.5 text-xs transition-colors",n===g?"border-primary bg-primary text-primary-foreground":"border-border text-muted-foreground hover:bg-muted hover:text-foreground"),children:os[g]},g))}),Dc(r,l,c,d,`新${os[n]}标题,Enter 创建`)]})}function d3(){const n=Be(F=>F.outline),o=Be(F=>F.outlineLoading),r=Be(F=>F.config),l=Be(F=>F.configLoading),c=Be(F=>F.loadOutline),d=ke(F=>F.focusOutlineNodeId),m=ke(F=>F.clearFocusOutlineNode);Ds(()=>{c()});const[g,b]=h.useState(!1),[p,v]=h.useState(null),[x,S]=h.useState(new Set),[j,E]=h.useState(null),[M,O]=h.useState(!1),[N,T]=h.useState(null),[k,C]=h.useState(null),[U,A]=h.useState(null),[L,_]=h.useState(""),[K,W]=h.useState(null),[ue,ne]=h.useState(""),[$,oe]=h.useState(null),[q,w]=h.useState(null),[D,H]=h.useState(null),B=r===null&&!l;h.useEffect(()=>{n===null&&!o&&!g&&(b(!0),c())},[n,o,g,c]),h.useEffect(()=>{if(n===null){H(null);return}let F=!1;return Promise.all(Yp.map(ie=>vr({source_type:"outline_node",relation_type:ie,depth:1}).then(Z=>Z.relations).catch(()=>[]))).then(ie=>{F||H(mS(ie.flat()))}),()=>{F=!0}},[n]),h.useEffect(()=>{if(N===null)return;const F=setTimeout(()=>T(null),3e3);return()=>clearTimeout(F)},[N]),h.useEffect(()=>{if(d===null||n===null)return;const F=d,ie=Vp(n.children,F);if(ie===null){m();return}S(Ee=>{if(ie.every(Ne=>!Ee.has(Ne)))return Ee;const Xe=new Set(Ee);for(const Ne of ie)Xe.delete(Ne);return Xe});const Z=setTimeout(()=>{const Ee=document.querySelector(`[data-node-id="${F}"]`);Ee&&(Ee.scrollIntoView({block:"center"}),C(F)),m()},0);return()=>clearTimeout(Z)},[d,n,m]),h.useEffect(()=>{if(k===null)return;const F=setTimeout(()=>C(null),3e3);return()=>clearTimeout(F)},[k]);async function P(F,ie){F&&X(F),await c(),ie&&T(ie)}function z(F){S(ie=>{const Z=new Set(ie);return Z.has(F)?Z.delete(F):Z.add(F),Z})}function X(F){S(ie=>{if(!ie.has(F))return ie;const Z=new Set(ie);return Z.delete(F),Z})}function I(F,ie=[]){for(const Z of F)Z.type!=="scene"&&Z.children&&Z.children.length>0&&(ie.push(Z.id),I(Z.children,ie));return ie}function V(F,ie){de(),A({nodeId:F.id,field:ie}),_(ie==="title"?F.title:F.summary??"")}function Q(){A(null),_("")}async function Y(F,ie){if(!U||U.nodeId!==F.id||U.field!==ie||M)return;const Z=L;if(!(ie==="title"?pS(F.title,Z):hS(F.summary,Z))){Q();return}O(!0);try{await S0(F.id,ie==="title"?{title:Z.trim()}:{summary:Z.trim()}),Q(),ke.getState().showToast("已保存"),await P()}catch(Xe){const Ne=Cc(Xe);if(c3(Ne)==="abandon"){Q(),v(ya(Ne)),await P();return}v(ya(Ne))}finally{O(!1)}}function fe(F,ie){return Z=>{Z.key==="Enter"?(Z.preventDefault(),Y(F,ie)):Z.key==="Escape"&&Q()}}function re(F,ie){Q(),W({parentId:F,type:ie}),ne(""),F!==Sn&&X(F)}function de(){W(null),ne("")}async function _e(){if(!K)return;const F=ue.trim(),{parentId:ie,type:Z}=K;if(!F){de();return}de();try{const Ee=await Uw({type:Z,title:F,parent_id:ie});ke.getState().showToast(`已创建${os[Z]}《${F}》`),await P(ie,Ee.id)}catch(Ee){v(ya(Cc(Ee)))}}function Ye(F){F.key==="Enter"?(F.preventDefault(),_e()):F.key==="Escape"&&de()}function Re(F,ie){F.dataTransfer.setData("text/plain",ie.id),F.dataTransfer.effectAllowed="move",oe(ie.id),w(null)}function Le(){oe(null),w(null)}function He(F){const ie=F.currentTarget.getBoundingClientRect();return F.clientY<ie.top+ie.height/2?"before":"after"}function ge(F,ie){F.stopPropagation();const Z=$?Ho(n?.children??[],$):null;if(!Z)return;const Ee=km(n?.children??[],ie)??Sn;if(!wc(Z,Ee,n?.children??[]))return;F.preventDefault(),F.dataTransfer.dropEffect="move";const Xe={kind:He(F),nodeId:ie};w(Ne=>Ev(Ne,Xe)?Ne:Xe)}function pe(F,ie){F.currentTarget.contains(F.relatedTarget)||w(Z=>Z!==null&&Z.kind!=="root-end"&&Z.nodeId===ie?null:Z)}async function ve(F,ie){if(F.stopPropagation(),F.preventDefault(),!$)return;const Z=Ho(n?.children??[],$);if(!Z)return;const Ee=km(n?.children??[],ie)??Sn;if(!wc(Z,Ee,n?.children??[]))return;if(ie===Z.id){oe(null),w(null);return}const Xe=gS(n?.children??[],Ee)??[],Ne=Sv(Xe,{kind:He(F),nodeId:ie},Z.id);if(Nv(n?.children??[],Z.id,Ee,Ne)){oe(null),w(null);return}O(!0);try{await my(Z.id,{parent_id:Ee,order:Ne}),ke.getState().showToast(`已移动《${Z.title}》`),await P(Ee)}catch(Me){v(ya(Cc(Me)))}finally{O(!1),oe(null),w(null)}}function Ue(F){const ie=$?Ho(n?.children??[],$):null;!ie||!wc(ie,Sn,n?.children??[])||(F.preventDefault(),F.dataTransfer.dropEffect="move",w(Z=>Ev(Z,{kind:"root-end"})?Z:{kind:"root-end"}))}function ye(F){F.currentTarget.contains(F.relatedTarget)||w(ie=>ie?.kind==="root-end"?null:ie)}async function De(F){if(F.preventDefault(),!$)return;const ie=Ho(n?.children??[],$);if(!ie||!wc(ie,Sn,n?.children??[]))return;const Z=Sv(n?.children??[],{kind:"end"},ie.id);if(Nv(n?.children??[],ie.id,Sn,Z)){oe(null),w(null);return}O(!0);try{await my(ie.id,{parent_id:Sn,order:Z}),ke.getState().showToast(`已移动《${ie.title}》`),await P()}catch(Ee){v(ya(Cc(Ee)))}finally{O(!1),oe(null),w(null)}}async function Pe(){if(j)try{const F=await Hw(j.id),{children:ie,relations:Z,deltas:Ee}=F.cascaded,Xe=[];ie>0&&Xe.push(`${ie} 个子节点`),Z>0&&Xe.push(`${Z} 条关联`),Ee>0&&Xe.push(`${Ee} 条变化记录`),ke.getState().showToast(`已移入回收站${Xe.length>0?`(含 ${Xe.join("、")})`:""}`),E(null),await P()}catch(F){if(F instanceof ze&&F.code==="OUTLINE_NODE_NOT_FOUND"){v(ya("OUTLINE_NODE_NOT_FOUND")),E(null),await P();return}throw F}}function Ie(){return K?.parentId!==Sn?null:i.jsx(jv,{className:"mb-1",type:K.type,onTypeChange:F=>W({parentId:Sn,type:F}),value:ue,onChange:ne,onKeyDown:Ye,onCancel:de})}function we(F,ie){return F.map(Z=>{const Ee=Z.type!=="scene"&&(Z.children?.length??0)>0,Xe=x.has(Z.id),Ne=r?.currentPosition===Z.id,Me=__[Z.type],Je=U?.nodeId===Z.id&&U.field==="title",nt=U?.nodeId===Z.id&&U.field==="summary",jt=q?.kind==="before"&&q.nodeId===Z.id,kt=q?.kind==="after"&&q.nodeId===Z.id,gt=$===Z.id,ln=K?.parentId===Z.id,Jt=Z.id===k;return i.jsxs("div",{children:[i.jsxs("div",{"data-node-id":Z.id,draggable:!Je&&!nt&&!gt&&!M,onDragStart:et=>Re(et,Z),onDragEnd:Le,onDragOver:et=>ge(et,Z.id),onDragLeave:et=>pe(et,Z.id),onDrop:et=>{ve(et,Z.id)},className:Ze("relative cursor-grab rounded-md px-2 py-1 transition-colors hover:bg-muted/60 active:cursor-grabbing",Z.id===N&&"bg-accent/40",Jt&&"bg-accent ring-1 ring-inset ring-ring",gt&&"opacity-50"),style:{paddingLeft:ie*20+8},title:"拖动到目标行即可移动(上半=插前、下半=插后)",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[Ee?i.jsx("button",{type:"button",className:"w-4 shrink-0 text-muted-foreground hover:text-foreground",onClick:()=>z(Z.id),"aria-label":Xe?"展开":"折叠",children:Xe?"▸":"▾"}):i.jsx("span",{className:"w-4 shrink-0"}),i.jsx("span",{className:"flex h-5 w-7 shrink-0 items-center justify-center rounded bg-muted text-xs text-muted-foreground",children:os[Z.type]}),Je?Dc(L,_,fe(Z,"title"),()=>{Y(Z,"title")},"标题"):i.jsx("span",{className:Ze("min-w-0 cursor-text truncate text-sm hover:underline",Jt?"text-accent-foreground":"text-foreground"),title:"点击编辑标题",onClick:()=>V(Z,"title"),children:Z.title}),D!==null&&(D.get(Z.id)?.length??0)>0&&i.jsx("span",{className:"flex shrink-0 items-center gap-0.5",children:(D.get(Z.id)??[]).map(et=>i.jsx(fS,{mark:et},`${et.relationType}-${et.hookId}`))}),Me!==null&&i.jsx("button",{type:"button",className:"shrink-0 rounded px-1 text-muted-foreground hover:bg-muted hover:text-foreground",title:`就地新建${os[Me]}`,"aria-label":`新建${os[Me]}`,onClick:()=>re(Z.id,Me),children:"+"}),i.jsx("button",{type:"button",className:"shrink-0 rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground",title:"详情","aria-label":"详情",onClick:()=>Tn(`/outline/${Z.id}`),children:i.jsx(Lc,{className:"size-3.5"})}),i.jsx("button",{type:"button",className:"shrink-0 rounded p-1 text-muted-foreground hover:bg-muted hover:text-destructive",title:"移入回收站","aria-label":"移入回收站",onClick:()=>E(Z),children:i.jsx(t0,{className:"size-3.5"})}),Ne&&i.jsx("span",{className:"shrink-0 rounded bg-accent px-1.5 py-0.5 text-xs text-accent-foreground",children:"当前位置"}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:is(Z.updatedAt)})]}),nt||Z.summary?i.jsxs("div",{className:"mt-0.5 flex items-center gap-2",children:[i.jsx("span",{className:"w-4 shrink-0"}),i.jsx("span",{className:"w-7 shrink-0"}),nt?Dc(L,_,fe(Z,"summary"),()=>{Y(Z,"summary")},"摘要"):i.jsx("span",{className:"min-w-0 cursor-text truncate text-xs text-muted-foreground hover:underline",title:"点击编辑摘要",onClick:()=>V(Z,"summary"),children:Z.summary})]}):null,jt&&i.jsx("span",{className:"pointer-events-none absolute inset-x-0 -top-px h-0.5 rounded bg-accent"}),kt&&i.jsx("span",{className:"pointer-events-none absolute inset-x-0 -bottom-px h-0.5 rounded bg-accent"})]}),Ee&&!Xe&&i.jsx("div",{children:we(Z.children??[],ie+1)}),ln&&i.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-1",style:{paddingLeft:(ie+1)*20+8},children:[i.jsx("span",{className:"w-4 shrink-0"}),i.jsx("span",{className:"flex h-5 w-7 shrink-0 items-center justify-center rounded bg-muted text-xs text-muted-foreground",children:os[K.type]}),Dc(ue,ne,Ye,de,`新${os[K.type]}标题,Enter 创建`)]})]},Z.id)})}function ee(){n&&(x.size>0?S(new Set):S(new Set(I(n.children))))}return i.jsxs("section",{children:[i.jsxs("div",{className:"mb-4 flex items-center justify-between gap-4",children:[i.jsx("h1",{className:"text-xl font-semibold",children:"大纲"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(he,{variant:"outline",type:"button",onClick:ee,disabled:!n||n.children.length===0,children:x.size>0?"全部展开":"全部折叠"}),i.jsx(he,{type:"button",onClick:()=>re(Sn,"volume"),children:"+ 新建"})]})]}),p&&i.jsx("div",{className:"mb-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:p}),B?i.jsxs("div",{className:"rounded-md border border-dashed border-zinc-300 px-6 py-10 text-center",children:[i.jsx("p",{className:"text-sm text-zinc-600",children:"未打开项目,无法编辑大纲"}),i.jsx("a",{href:"#/",className:"mt-2 inline-block text-sm text-zinc-500 underline hover:text-zinc-700",children:"回到首页打开或创建书籍"})]}):o&&n===null?i.jsx("div",{className:"space-y-2 rounded-md border border-zinc-200 p-3",children:Array.from({length:6},(F,ie)=>i.jsx("div",{className:"h-5 animate-pulse rounded bg-zinc-100",style:{width:`${92-ie%3*24}%`,marginLeft:ie%3*20}},ie))}):n===null?i.jsxs("div",{className:"rounded-md border border-zinc-200 p-4 text-sm text-zinc-600",children:["大纲加载失败",i.jsx(he,{variant:"outline",className:"ml-3",type:"button",onClick:()=>b(!1),children:"重试"})]}):n.children.length===0?K?.parentId===Sn?i.jsxs("div",{className:"rounded-lg border border-dashed border-zinc-300 px-6 py-12 text-center",children:[i.jsx("p",{className:"text-sm text-zinc-600",children:"输入第一卷标题,Enter 创建"}),i.jsx("div",{className:"mx-auto mt-4 max-w-sm",children:i.jsx(jv,{type:K.type,onTypeChange:F=>W({parentId:Sn,type:F}),value:ue,onChange:ne,onKeyDown:Ye,onCancel:de})})]}):i.jsxs("div",{className:"rounded-lg border border-dashed border-zinc-300 px-6 py-12 text-center",children:[i.jsx("p",{className:"text-sm text-zinc-600",children:"大纲还是空的,先建第一卷"}),i.jsx("p",{className:"mt-1 text-xs text-zinc-400",children:"大纲是三层结构:卷 → 章 → 场景"}),i.jsx(he,{className:"mt-4",type:"button",onClick:()=>re(Sn,"volume"),children:"新建第一卷"})]}):i.jsxs("div",{className:Ze("rounded-md border border-border p-2",q?.kind==="root-end"&&"ring-1 ring-inset ring-accent"),onDragOver:Ue,onDragLeave:ye,onDrop:F=>{De(F)},children:[Ie(),we(n.children,0)]}),j&&i.jsx(ps,{title:"移入回收站",description:`将《${j.title}》移入回收站。子节点与关联的关系、变化记录将一并移入,可在回收站还原。`,confirmLabel:"移入回收站",danger:!0,onConfirm:Pe,onClose:()=>E(null)})]})}const Tl=20;function f3(n,o){return Math.max(1,Math.ceil(n/o))}const m3={character:{key1:"role",label1:"角色",key2:"status",label2:"状态"},setting:{key1:"category",label1:"类别"},location:{key1:"type",label1:"类型"},hook:{key1:"status",label1:"状态",key2:"payoff_timing",label2:"回收时机"},event:{key1:"description",label1:"描述"},timepoint:{key1:"",label1:""}},Fp={planted:"已埋设",progressing:"推进中",resolved:"已回收",abandoned:"已弃用"},Gp={immediate:"立即",near_term:"近期",mid_arc:"中段",slow_burn:"慢热",endgame:"终局"};function tm(n,o,r){return r==null||r===""?"—":n==="hook"&&o==="status"?Fp[String(r)]??String(r):n==="hook"&&o==="payoff_timing"?Gp[String(r)]??String(r):String(r)}const Tv={character:{key:"role",label:"角色定位",input:"text"},setting:{key:"category",label:"类别",input:"text"},location:{key:"type",label:"地点类型",input:"text"},hook:{key:"status",label:"状态",input:"select",options:["planted","progressing","resolved","abandoned"]},event:{key:"description",label:"描述",input:"text"},timepoint:{key:"",label:"",input:"text"}};function qp(n){switch(n){case"character":return[{key:"role",label:"角色定位",control:"text"},{key:"gender",label:"性别",control:"text"},{key:"age",label:"年龄",control:"number"},{key:"personality",label:"性格",control:"tags"},{key:"motivation",label:"动机",control:"textarea"},{key:"abilities",label:"能力",control:"tags"},{key:"status",label:"状态",control:"text"}];case"setting":return[{key:"category",label:"类别",control:"text"},{key:"parent_id",label:"上级设定",control:"text"},{key:"description",label:"描述",control:"textarea"},{key:"rules",label:"规则",control:"tags"}];case"location":return[{key:"type",label:"地点类型",control:"text"},{key:"parent_id",label:"上级地点",control:"text"},{key:"description",label:"描述",control:"textarea"}];case"hook":return[{key:"status",label:"状态",control:"select",options:["planted","progressing","resolved","abandoned"],optionsLabels:Fp},{key:"category",label:"类别",control:"text"},{key:"expected_payoff",label:"预期回收",control:"textarea"},{key:"payoff_timing",label:"回收时机",control:"select",options:["immediate","near_term","mid_arc","slow_burn","endgame"],optionsLabels:Gp},{key:"half_life",label:"半衰期(章数)",control:"number"},{key:"is_core",label:"主线伏笔",control:"toggle"},{key:"notes",label:"备注",control:"textarea"},{key:"expected_resolve_node_id",label:"预计回收节点",control:"outline-node"}];case"event":return[{key:"description",label:"描述",control:"textarea"},{key:"tags",label:"标签",control:"tags"}];case"timepoint":return[]}}const p3={belongs_to:"所属",owns:"拥有",masters:"掌握",ally:"盟友",rival:"对手",mentor:"师徒",family:"家族",kills:"击杀",appears_in:"出现于",occurs_at:"发生于",plot_edge:"剧情连线",plants:"埋设",advances:"推进",resolves:"回收",depends_on:"依赖",involves:"涉及"};function gr(n){return p3[n]??n}function $p(n,o){const r={};for(const l of new Set([...Object.keys(n),...Object.keys(o)])){const c=o[l];if(c===void 0)continue;const d=wv(n[l]),m=wv(c);JSON.stringify(d)!==JSON.stringify(m)&&(r[l]=c)}return Object.keys(r).length>0?r:null}function wv(n){return n==null||n===""||Array.isArray(n)&&n.length===0?null:n}const nm={character:"人物",setting:"设定",location:"地点",hook:"伏笔",event:"事件",timepoint:"时间点"},h3=Um.filter(n=>n!=="occurs_at"),va="w-full rounded-md border border-border bg-card px-3 py-1.5 text-sm text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring";function Xp({source:n,onCreated:o,onClose:r}){const l=Be(_=>_.outline),[c,d]=h.useState("character"),[m,g]=h.useState(null),[b,p]=h.useState(""),[v,x]=h.useState("character"),[S,j]=h.useState(null),[E,M]=h.useState(""),[O,N]=h.useState(Um[0]),[T,k]=h.useState(null),[C,U]=h.useState(!1);h.useEffect(()=>{n||(p(""),g(null),ls(c,{limit:100}).then(_=>g(_.items)).catch(()=>g([])))},[n,c]),h.useEffect(()=>{if(M(""),v==="outline_node"){j(null);return}j(null),ls(v,{limit:100}).then(_=>j(_.items)).catch(()=>j([]))},[v]);const A=ao(l?.children??[]);async function L(_){if(_.preventDefault(),!n&&!b){k("请选择源实体");return}if(!E){k("请选择关联对象");return}U(!0),k(null);try{const K={source_type:n?n.type:c,source_id:n?n.id:b,target_type:v,target_id:E,relation_type:O};await Sr(K),ke.getState().showToast("已建立关系"),await o(),r()}catch(K){K instanceof ze&&K.code==="RELATION_EXISTS"?k("这条关系已经存在"):k(K instanceof ze?K.message:"创建失败,请重试")}finally{U(!1)}}return i.jsx(ws,{open:!0,onOpenChange:_=>!_&&r(),children:i.jsxs(Cs,{className:"sm:max-w-2xl",children:[i.jsx(Rs,{children:i.jsx(ks,{children:"新增关联"})}),i.jsxs("form",{id:"create-relation-form",onSubmit:L,className:"flex flex-col gap-3",children:[i.jsxs("div",{className:"grid grid-cols-1 items-start gap-3 sm:grid-cols-[1fr_auto_1fr]",children:[i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("p",{className:"text-sm font-medium text-foreground",children:"源实体"}),n?i.jsxs("div",{title:n.name,className:"min-w-0 truncate rounded-md border border-border bg-muted/40 px-3 py-1.5 text-sm text-foreground",children:[n.type==="outline_node"?"本节点":"本实体",":",n.name]}):i.jsxs(i.Fragment,{children:[i.jsx("select",{value:c,onChange:_=>d(_.target.value),className:va,children:Ca.map(_=>i.jsx("option",{value:_,children:nm[_]},_))}),i.jsxs("select",{value:b,onChange:_=>p(_.target.value),className:va,children:[i.jsxs("option",{value:"",children:["选择",nm[c],"…"]}),(m??[]).map(_=>i.jsx("option",{value:_.id,children:_.name},_.id))]})]})]}),i.jsxs("div",{className:"flex flex-col gap-2 sm:w-44",children:[i.jsx("p",{className:"text-sm font-medium text-foreground",children:"关系类型"}),i.jsx("select",{value:O,onChange:_=>N(_.target.value),className:va,children:h3.map(_=>i.jsx("option",{value:_,children:gr(_)},_))}),i.jsx("span",{"aria-hidden":"true",className:"mt-auto select-none pb-1 text-center text-xl leading-none text-muted-foreground",children:"→"})]}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("p",{className:"text-sm font-medium text-foreground",children:"目标实体"}),i.jsxs("select",{value:v,onChange:_=>x(_.target.value),className:va,children:[i.jsx("option",{value:"character",children:"人物"}),i.jsx("option",{value:"setting",children:"设定"}),i.jsx("option",{value:"location",children:"地点"}),i.jsx("option",{value:"hook",children:"伏笔"}),i.jsx("option",{value:"outline_node",children:"大纲节点"})]}),v==="outline_node"?i.jsxs("select",{value:E,onChange:_=>M(_.target.value),className:va,children:[i.jsx("option",{value:"",children:"选择大纲节点…"}),A.map(_=>i.jsxs("option",{value:_.id,children:[" ".repeat(_.depth),_.label]},_.id))]}):i.jsxs("select",{value:E,onChange:_=>M(_.target.value),className:va,children:[i.jsxs("option",{value:"",children:["选择",nm[v],"…"]}),(S??[]).map(_=>i.jsx("option",{value:_.id,children:_.name},_.id))]})]})]}),T&&i.jsx("p",{className:"text-sm text-destructive",children:T})]}),i.jsxs(Os,{children:[i.jsx(he,{variant:"outline",type:"button",onClick:r,disabled:C,children:"取消"}),i.jsx(he,{type:"submit",form:"create-relation-form",disabled:C,children:"建立"})]})]})})}const xS={character:"人物",setting:"设定",location:"地点",hook:"伏笔",outline_node:"大纲节点"},Cv={endpointType:"",relationType:"",nameQuery:""};function g3(n,o){const r=o.nameQuery.trim().toLowerCase();return n.filter(l=>{if(o.endpointType!==""&&l.sourceType!==o.endpointType&&l.targetType!==o.endpointType||o.relationType!==""&&l.relationType!==o.relationType)return!1;if(r){const c=(l.sourceName??l.sourceId).toLowerCase(),d=(l.targetName??l.targetId).toLowerCase();if(!c.includes(r)&&!d.includes(r))return!1}return!0})}function Rv({type:n}){return i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:xS[n]??n})}function sm({type:n,id:o,name:r}){const l=r??o;if(!(Ca.includes(n)||n==="outline_node"))return i.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[i.jsx("span",{className:"min-w-0 truncate text-muted-foreground",title:l,children:l}),i.jsx(Rv,{type:n})]});const d=n==="outline_node"?`/outline/${o}`:`/entities/${n}/${o}`;return i.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[i.jsx("button",{type:"button",onClick:()=>Tn(d),title:`打开《${l}》`,className:"min-w-0 truncate font-medium text-foreground underline-offset-2 hover:text-primary hover:underline",children:l}),i.jsx(Rv,{type:n})]})}function Ov(n,o){const r=o==="source"?n.sourceName:n.targetName,l=o==="source"?n.sourceId:n.targetId;return r??l}function bS({reloadKey:n,onOpenCreate:o,scope:r}){const[l,c]=h.useState(null),[d,m]=h.useState(!1),[g,b]=h.useState(null),[p,v]=h.useState(0),[x,S]=h.useState(Cv),[j,E]=h.useState(null);h.useEffect(()=>{let N=!1;m(!0),b(null);const T=r!==void 0?{source_type:r.type,source_id:r.id,depth:1}:{depth:1};return vr(T).then(k=>{N||c(k.relations)}).catch(k=>{N||(c(null),b(k instanceof ze?k.code:ft))}).finally(()=>{N||m(!1)}),()=>{N=!0}},[n,p,r?.type,r?.id]);async function M(){if(j)try{await Zc(j.id),ke.getState().showToast("已删除关系"),E(null),v(N=>N+1)}catch(N){throw N}}const O=l===null?[]:g3(l,x);return i.jsxs("div",{children:[r===void 0&&i.jsxs("div",{className:"mb-2 mt-3 flex flex-wrap items-center gap-3",children:[i.jsxs("select",{value:x.endpointType,onChange:N=>S(T=>({...T,endpointType:N.target.value})),"aria-label":"端点类型过滤",className:"rounded-md border border-border bg-card px-2 py-1 text-sm text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[i.jsx("option",{value:"",children:"全部端点类型"}),Object.entries(xS).map(([N,T])=>i.jsx("option",{value:N,children:T},N))]}),i.jsxs("select",{value:x.relationType,onChange:N=>S(T=>({...T,relationType:N.target.value})),"aria-label":"关系类型过滤",className:"rounded-md border border-border bg-card px-2 py-1 text-sm text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[i.jsx("option",{value:"",children:"全部关系类型"}),Um.map(N=>i.jsx("option",{value:N,children:gr(N)},N))]}),i.jsx(Dt,{value:x.nameQuery,onChange:N=>S(T=>({...T,nameQuery:N.target.value})),placeholder:"搜索源/目标名称…",className:"w-52"})]}),g!==null&&i.jsxs("div",{className:"mb-3 rounded-md border border-border bg-muted px-3 py-2 text-sm text-muted-foreground",children:[g===ft?"无法连接服务,请确认 ai-editor 服务已启动。":"关系加载失败,请重试。",i.jsx(he,{variant:"outline",className:"ml-3",type:"button",onClick:()=>v(N=>N+1),children:"重试"})]}),d&&l===null&&g===null&&i.jsx("div",{className:"overflow-hidden rounded-md border border-border",children:Array.from({length:5},(N,T)=>i.jsxs("div",{className:"flex items-center gap-3 border-b border-border px-3 py-3 last:border-0",children:[i.jsx("div",{className:"h-4 w-1/4 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-4 w-1/6 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-4 w-1/4 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"ml-auto h-4 w-12 animate-pulse rounded bg-muted"})]},T))}),!d&&l!==null&&l.length===0&&i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-12 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"还没有关联,建立一条"}),i.jsx(he,{className:"mt-4",type:"button",onClick:o,children:"+ 建立关联"})]}),!d&&l!==null&&l.length>0&&O.length===0&&i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-12 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"没有匹配的关联"}),i.jsx(he,{variant:"outline",className:"mt-4",type:"button",onClick:()=>S(Cv),children:"清空过滤"})]}),!d&&l!==null&&O.length>0&&i.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[r===void 0&&i.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground",children:[i.jsx("span",{className:"w-1/4 shrink-0",children:"源"}),i.jsx("span",{className:"w-1/4 shrink-0",children:"关系"}),i.jsx("span",{className:"flex-1",children:"目标"}),i.jsx("span",{className:"w-14 shrink-0"})]}),i.jsx("ul",{className:"divide-y divide-border",children:O.map(N=>i.jsxs("li",{className:"flex items-center gap-2 px-3 py-2 text-sm",children:[r!==void 0?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"shrink-0 truncate rounded bg-muted px-1.5 py-0.5 text-center text-xs text-muted-foreground",children:[gr(N.relationType)," →"]}),i.jsx("span",{className:"min-w-0 flex-1",children:i.jsx(sm,{type:N.targetType,id:N.targetId,name:N.targetName})})]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"w-1/4 min-w-0 shrink-0",children:i.jsx(sm,{type:N.sourceType,id:N.sourceId,name:N.sourceName})}),i.jsxs("span",{className:"w-1/4 shrink-0 truncate rounded bg-muted px-1.5 py-0.5 text-center text-xs text-muted-foreground",children:[gr(N.relationType)," →"]}),i.jsx("span",{className:"min-w-0 flex-1",children:i.jsx(sm,{type:N.targetType,id:N.targetId,name:N.targetName})})]}),i.jsx(he,{variant:"outline",type:"button",className:"h-7 w-14 shrink-0 px-2 text-xs text-destructive hover:bg-destructive/10",onClick:()=>E(N),children:"删除"})]},N.id))})]}),j&&i.jsx(ps,{title:"删除关系",description:`删除关系「${Ov(j,"source")} ${gr(j.relationType)} ${Ov(j,"target")}」?物理删除不可恢复,可重新建立。`,confirmLabel:"删除",danger:!0,onConfirm:M,onClose:()=>E(null)})]})}const x3={set:"设为",update:"更新",add:"追加",remove:"移除"},b3={character:"人物",setting:"设定",location:"地点",hook:"伏笔",outline_node:"大纲节点"};function Kp(n){return b3[n]??n}function rs(n){return n==null?"空":typeof n=="object"?JSON.stringify(n):String(n)}function y3(n){switch(n.op){case"set":return`${n.field} = ${rs(n.to)}`;case"update":return`${n.field} ${rs(n.from)} → ${rs(n.to)}`;case"add":return`${n.field} +${rs(n.value??n.to)}`;case"remove":return`${n.field} -${rs(n.value??n.to)}`}}function v3(n,o){const r=[];for(const l of new Set([...Object.keys(n),...Object.keys(o)])){const c=n[l]??null,d=o[l]??null;JSON.stringify(c)!==JSON.stringify(d)&&r.push({field:l,from:n[l],to:o[l]})}return r}function yS({changes:n,skipped:o}){const r=o?new Set(o):null;return i.jsx("div",{className:"flex flex-wrap items-center gap-1",children:n.map((l,c)=>{const d=r?.has(c)??!1;return i.jsxs("span",{title:d?"该变更未应用(数据与变更记录不一致,见冲突标注)":void 0,className:Ze("inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs",d?"text-destructive":"text-muted-foreground"),children:[i.jsx("span",{className:Ze("shrink-0 font-medium",d?"text-destructive":"text-foreground/70"),children:x3[l.op]}),y3(l)]},c)})})}function S3({nodeId:n,reloadKey:o}){const[r,l]=h.useState(null),[c,d]=h.useState(!1),[m,g]=h.useState(null),[b,p]=h.useState(0);return h.useEffect(()=>{let v=!1;return d(!0),g(null),Xw(n).then(x=>{v||l([...x.deltas].sort((S,j)=>S.order-j.order))}).catch(x=>{v||g(x instanceof ze?x.code:ft)}).finally(()=>{v||d(!1)}),()=>{v=!0}},[n,b,o]),i.jsxs("div",{children:[c&&r===null&&m===null&&i.jsxs("div",{className:"space-y-2 py-1",children:[i.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-4 w-1/2 animate-pulse rounded bg-muted"})]}),m!==null&&i.jsxs("div",{className:"flex items-center gap-2 text-xs text-destructive",children:[i.jsx("span",{children:m==="OUTLINE_NODE_NOT_FOUND"?"节点不存在(可能已被删除),变更记录不可用":m===ft?"无法连接服务,请确认 ai-editor 服务已启动":"变更记录加载失败"}),m!=="OUTLINE_NODE_NOT_FOUND"&&i.jsx(he,{variant:"outline",size:"xs",type:"button",onClick:()=>p(v=>v+1),children:"重试"})]}),!c&&m===null&&r!==null&&r.length===0&&i.jsx("p",{className:"py-1 text-xs text-muted-foreground",children:"该节点没有变更记录"}),!c&&m===null&&r!==null&&r.length>0&&i.jsx("ul",{className:"divide-y divide-border/70",children:r.map(v=>i.jsxs("li",{className:"py-2 first:pt-0 last:pb-0",children:[i.jsxs("div",{className:"flex items-baseline gap-2",children:[i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",title:v.description,children:v.description}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:is(v.createdAt)})]}),i.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[i.jsxs("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[Kp(v.targetType),"《",v.targetName??v.targetId,"》"]}),i.jsx(yS,{changes:v.changes})]})]},v.id))})]})}const E3=Ca.filter(n=>n!=="event"&&n!=="timepoint").map(n=>({value:n,label:Kp(n)})),N3={character:["role","gender","age","personality","motivation","abilities","status","custom_fields"],setting:["category","parent_id","description","rules","custom_fields"],location:["type","parent_id","description","custom_fields"],hook:["status","category","expected_payoff","payoff_timing","half_life","is_core","notes","expected_resolve_node_id"]},j3={character:Rc("character"),setting:Rc("setting"),location:Rc("location"),hook:Rc("hook")};function Rc(n){return Object.fromEntries(qp(n).map(o=>[o.key,o.label]))}const T3={character:["personality","abilities"],setting:["rules"]},w3={character:["age"],hook:["half_life"]};function _m(n,o){return(T3[n]??[]).includes(o)}function C3(n,o){return(w3[n]??[]).includes(o)}function R3(n){return(N3[n]??[]).filter(r=>r!=="custom_fields").map(r=>({key:r,label:j3[n]?.[r]??r,array:_m(n,r)}))}function vS(n){if(n!==void 0){if(n===null)return null;if(typeof n=="string"||typeof n=="number")return n}}function kv(n){return n.array?{options:["add","remove"],default:"add"}:vS(n.currentValue)!==void 0?{options:["update","set"],default:"update"}:{options:["set"],default:"set"}}function O3(n){const o=n.rawValue.trim();if(o==="")return{error:"请填写值"};const r=Number(o),l=n.numeric&&!Number.isNaN(r)?r:o;switch(n.op){case"add":return{change:{field:n.field,op:"add",value:l}};case"remove":return{change:{field:n.field,op:"remove",value:l}};case"set":return{change:{field:n.field,op:"set",to:l}};case"update":{const c=vS(n.currentValue);return c===void 0?{error:"无法确定旧值(当前数据无此字段或类型不可表达),请改用「设为」"}:{change:{field:n.field,op:"update",from:c,to:l}}}}}const Sa="w-full rounded-md border border-border bg-card px-2 py-1 text-sm text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",k3={set:"设为",update:"更新",add:"追加",remove:"移除"};function _3({nodeId:n,onCreated:o,onClose:r}){const[l,c]=h.useState(""),[d,m]=h.useState(""),[g,b]=h.useState(""),[p,v]=h.useState("add"),[x,S]=h.useState(""),[j,E]=h.useState(""),[M,O]=h.useState(!1),[N,T]=h.useState(null),[k,C]=h.useState(null),[U,A]=h.useState(null),[L,_]=h.useState(0),[K,W]=h.useState(null),[ue,ne]=h.useState(null);h.useEffect(()=>{if(m(""),W(null),ne(null),l===""){C(null),A(null);return}let B=!1;return C(null),A(null),ls(l).then(P=>{B||C(P.items)}).catch(P=>{B||(C(null),A(P instanceof ze?P.code:ft))}),()=>{B=!0}},[l,L]),h.useEffect(()=>{if(l===""||d==="")return;let B=!1;return W(null),ne(null),pr(l,d).then(P=>{B||W(P.data)}).catch(P=>{B||(W(null),ne(P instanceof ze?P.code:ft))}),()=>{B=!0}},[l,d]),h.useEffect(()=>{b(""),S(""),T(null)},[l,d]);const $=R3(l),oe=K?.[g],q=kv({array:_m(l,g),currentValue:oe});function w(B){b(B),v(kv({array:_m(l,B),currentValue:K?.[B]}).default)}async function D(){if(M)return;if(l===""||d===""){T("请选择变更目标");return}if(g===""){T("请选择变更字段");return}const B=j.trim();if(B===""){T("请填写描述(本节点触发了什么变化)");return}const P=O3({field:g,op:p,rawValue:x,numeric:C3(l,g),currentValue:oe});if("error"in P){T(P.error);return}O(!0),T(null);try{await Wm({node_id:n,target_type:l,target_id:d,changes:[P.change],description:B}),ke.getState().showToast("已记录变更"),o()}catch(z){if(z instanceof ze&&z.code==="OUTLINE_NODE_NOT_FOUND"){ke.getState().showToast("节点不存在(可能已被删除),无法记录变更","error"),r();return}T(z instanceof ze?z.message:"提交失败,请重试")}finally{O(!1)}}const H=l;return i.jsxs("div",{className:"mb-3 space-y-3 rounded-md border border-border bg-muted/40 p-3",children:[i.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"目标类型"}),i.jsxs("select",{value:l,onChange:B=>c(B.target.value),className:Ze(Sa,l===""&&"text-muted-foreground"),"aria-label":"目标类型",children:[i.jsx("option",{value:"",children:"请选择目标类型"}),E3.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))]})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"目标"}),l===""?i.jsx("p",{className:"py-1 text-xs text-muted-foreground",children:"请先选择目标类型"}):U!==null?i.jsxs("div",{className:"flex items-center gap-2 text-xs text-destructive",children:[i.jsx("span",{children:U===ft?"无法连接服务,请确认 ai-editor 服务已启动":"实体列表加载失败"}),i.jsx(he,{variant:"outline",size:"xs",type:"button",onClick:()=>_(B=>B+1),children:"重试"})]}):k===null?i.jsx("p",{className:"py-1 text-xs text-muted-foreground",children:"加载中…"}):k.length===0?i.jsxs("p",{className:"py-1 text-xs text-muted-foreground",children:["暂无",_v(H)]}):i.jsxs("select",{value:d,onChange:B=>m(B.target.value),className:Ze(Sa,d===""&&"text-muted-foreground"),"aria-label":"目标实体",children:[i.jsxs("option",{value:"",children:["请选择",_v(H)]}),k.map(B=>i.jsx("option",{value:B.id,children:B.name},B.id))]})]})]}),i.jsxs("div",{className:"grid gap-3 sm:grid-cols-[1fr_auto_1fr]",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"字段"}),i.jsxs("select",{value:g,onChange:B=>w(B.target.value),className:Ze(Sa,g===""&&"text-muted-foreground"),"aria-label":"变更字段",children:[i.jsx("option",{value:"",children:"请选择字段"}),$.map(B=>i.jsx("option",{value:B.key,children:B.label},B.key))]})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"操作"}),i.jsx("select",{value:p,onChange:B=>v(B.target.value),className:Ze(Sa,"min-w-20"),"aria-label":"操作",children:q.options.map(B=>i.jsx("option",{value:B,children:k3[B]},B))})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:p==="set"||p==="update"?"新值":p==="add"?"追加值":"移除值"}),i.jsx("input",{value:x,onChange:B=>S(B.target.value),placeholder:p==="remove"?"按值匹配删除":"",className:Sa})]})]}),p==="update"&&i.jsx("p",{className:"text-xs text-muted-foreground",children:ue!==null?i.jsxs(i.Fragment,{children:["目标数据获取失败,无法自动取旧值(",ue==="ENTITY_NOT_FOUND"?"目标已不存在":"请稍后重试",")——可将操作改为「设为」"]}):i.jsxs(i.Fragment,{children:["旧值:",rs(oe),"(自动取自目标当前数据,无需手填)"]})}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"描述"}),i.jsx("textarea",{value:j,onChange:B=>E(B.target.value),rows:2,maxLength:500,placeholder:"本节点触发了什么变化,如:张三获得断剑认可",className:Ze(Sa,"resize-none")})]}),N!==null&&i.jsx("p",{className:"text-sm text-destructive",children:N}),i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[i.jsx(he,{variant:"ghost",size:"sm",type:"button",onClick:r,disabled:M,children:"取消"}),i.jsx(he,{size:"sm",type:"button",onClick:()=>{D()},disabled:M,children:M?"提交中…":"创建变更"})]})]})}function _v(n){return Kp(n)}function Qp({items:n,className:o}){return i.jsx("nav",{"aria-label":"面包屑",className:Ze("inline-flex items-center gap-1",o),children:n.map((r,l)=>{const c=l===n.length-1;return i.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.href?i.jsx("button",{type:"button",onClick:()=>Tn(r.href),className:"rounded-md px-2.5 py-1 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:r.label}):i.jsx("span",{"aria-current":"page",className:"max-w-40 truncate rounded-md bg-foreground px-2.5 py-1 text-sm font-medium text-background",children:r.label}),!c&&i.jsx("span",{className:"select-none text-sm text-muted-foreground/40",children:"›"})]},l)})})}const M3={inner:"内心冲突",personal:"人际冲突",extra_personal:"社会冲突"};function A3(n){switch(n){case"scene":return[{key:"goal",label:"场景目标",control:"textarea",maxLength:1e3},{key:"conflict_levels",label:"冲突层次",control:"checkbox-group",options:Zv,optionsLabels:M3},{key:"value_from",label:"开场价值",control:"text",maxLength:200},{key:"value_to",label:"收场价值",control:"text",maxLength:200}];case"chapter":return[{key:"reversal",label:"章末反转",control:"textarea",maxLength:1e3},{key:"climax_scene",label:"章高潮场景",control:"scene-select"}];case"volume":return[{key:"climax_scene",label:"幕高潮场景",control:"scene-select"},{key:"inciting_scene",label:"激励事件",control:"scene-select"}]}}function D3(n,o){return Zv.includes(o)?n.includes(o)?n.filter(r=>r!==o):[...n,o]:n}function z3(n){const o=[],r=(l,c)=>{for(const d of l)d.type==="scene"?o.push({id:d.id,label:d.title,depth:c}):d.children&&r(d.children,c+1)};return r(n,0),o}function L3(n){return typeof n=="string"&&n!==""?n:""}const Mm="w-full rounded-md border border-border bg-card px-3 py-1.5 text-sm text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring";function wl({title:n,children:o,className:r,action:l}){return i.jsxs("div",{className:Ze("rounded-xl border border-border bg-card p-4",r),children:[i.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[i.jsx("h2",{className:"font-serif text-base",children:n}),l]}),o]})}function I3({nodeId:n}){const o=Be(I=>I.outline),r=Be(I=>I.outlineLoading),l=Be(I=>I.config),c=Be(I=>I.configLoading),d=Be(I=>I.loadOutline),m=Be(I=>I.updateConfig),[g,b]=h.useState(!1),[p,v]=h.useState(""),[x,S]=h.useState(""),[j,E]=h.useState(null),[M,O]=h.useState(!1),[N,T]=h.useState(null),[k,C]=h.useState(!1),[U,A]=h.useState(!1),[L,_]=h.useState(0),[K,W]=h.useState(!1),[ue,ne]=h.useState(0);h.useEffect(()=>{o===null&&!r&&!g&&(b(!0),d())},[o,r,g,d]),Ds(()=>{d(),_(I=>I+1),ne(I=>I+1)});const $=o===null?null:Ho(o.children,n),oe=o!==null&&$===null,q=$?A3($.type):[],w=z3(o?.children??[]),D=l?.currentPosition===n;h.useEffect(()=>{$!==null&&(v($.title),S($.summary??""),E(JSON.parse(JSON.stringify($.data??{}))))},[$]);async function H(){if($===null||M)return;const I=p.trim();if(I===""){T("标题不能为空");return}const V={};pS($.title,p)&&(V.title=I),hS($.summary,x)&&(V.summary=x.trim());const Q=$p($.data??{},j??{});if(Q!==null&&(V.data=Q),Object.keys(V).length===0){ke.getState().showToast("没有变更");return}O(!0),T(null);try{await S0($.id,V),ke.getState().showToast("已保存"),await d()}catch(Y){if(Y instanceof ze&&Y.code==="OUTLINE_NODE_NOT_FOUND"){await d();return}T(Y instanceof ze?Y.message:"保存失败,请重试")}finally{O(!1)}}function B(I,V){E(Q=>Q&&{...Q,[I]:V})}async function P(){if(!($===null||k||D)){C(!0);try{await m({current_position:$.id}),ke.getState().showToast("已设为当前位置")}catch{ke.getState().showToast("设置失败:该节点可能已删除,无法设为当前位置","error")}finally{C(!1)}}}if(oe)return i.jsx("section",{children:i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-14 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"该节点不存在或已被删除"}),i.jsxs("div",{className:"mt-4 flex justify-center gap-2",children:[i.jsx("a",{href:"#/trash",className:"rounded-md border border-border px-4 py-1.5 text-sm text-muted-foreground hover:bg-muted",children:"去回收站"}),i.jsx(he,{variant:"outline",type:"button",onClick:()=>Tn("/outline"),children:"返回大纲"})]})]})});const z=l===null&&!c,X=[{label:"大纲",href:"/outline"}];if($!==null){const I=Vp(o?.children??[],n)??[];for(const V of I.slice(0,-1)){const Q=Ho(o?.children??[],V);Q&&X.push({label:Q.title,href:`/outline/${V}`})}X.push({label:$.title})}return i.jsxs("section",{children:[i.jsxs("div",{className:"mb-1 flex items-center gap-3",children:[i.jsx(Qp,{items:X}),i.jsx("h1",{className:"min-w-0 truncate text-xl font-semibold",children:$?.title??"…"}),i.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[i.jsx(he,{variant:"outline",type:"button",disabled:$===null||D||k,title:D?"当前节点已是创作进度位置":"标记为创作进度位置(InfoBar 展示 + 定位跳转基准)",onClick:()=>{P()},children:D?"当前位置":"设为当前位置"}),i.jsx(he,{type:"button",onClick:()=>{H()},disabled:$===null||M,children:M?"保存中…":"保存"})]})]}),$&&i.jsxs("div",{className:"mb-4 flex items-center gap-2 text-xs text-muted-foreground",children:[i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs",children:os[$.type]}),i.jsxs("span",{children:["更新于 ",is($.updatedAt)]}),D&&i.jsx("span",{className:"shrink-0 rounded bg-accent px-1.5 py-0.5 text-xs text-accent-foreground",children:"当前位置"})]}),z?i.jsxs("div",{className:"rounded-md border border-dashed border-border px-6 py-10 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"未打开项目,无法编辑大纲"}),i.jsx("a",{href:"#/",className:"mt-2 inline-block text-sm text-muted-foreground underline hover:text-foreground",children:"回到首页打开或创建书籍"})]}):r&&o===null?i.jsx("div",{className:"space-y-2 rounded-md border border-border p-3",children:Array.from({length:6},(I,V)=>i.jsx("div",{className:"h-5 animate-pulse rounded bg-muted",style:{width:`${92-V%3*24}%`,marginLeft:V%3*20}},V))}):o===null?i.jsxs("div",{className:"rounded-md border border-border p-4 text-sm text-muted-foreground",children:["大纲加载失败",i.jsx(he,{variant:"outline",className:"ml-3",type:"button",onClick:()=>b(!1),children:"重试"})]}):$===null||j===null?null:i.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[i.jsxs("div",{className:"flex min-w-0 flex-col gap-4",children:[i.jsx(wl,{title:"基础信息",children:i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"标题"}),i.jsx(Dt,{value:p,onChange:I=>v(I.target.value),maxLength:200,placeholder:`${os[$.type]}标题`,className:"h-8 text-sm"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"摘要"}),i.jsx("textarea",{value:x,onChange:I=>S(I.target.value),maxLength:200,rows:3,placeholder:"一句话概括本节点内容(可选)",className:Mm})]})]})}),i.jsxs(wl,{title:`结构化信息(${os[$.type]})`,children:[i.jsx("div",{className:"flex flex-col gap-3",children:q.map(I=>i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:I.label}),i.jsx(B3,{field:I,value:j?.[I.key],sceneOptions:w,onChange:V=>B(I.key,V)})]},I.key))}),N&&i.jsx("p",{className:"mt-3 text-sm text-destructive",children:N})]}),i.jsxs(wl,{title:"变更记录",action:i.jsx(he,{variant:"outline",size:"sm",type:"button",onClick:()=>W(I=>!I),children:K?"收起":"+ 新建变更"}),children:[K&&i.jsx(_3,{nodeId:n,onCreated:()=>{W(!1),ne(I=>I+1)},onClose:()=>W(!1)}),i.jsx(S3,{nodeId:n,reloadKey:ue})]}),i.jsx(wl,{title:"伏笔标记",className:"border-dashed",children:i.jsx("p",{className:"text-sm text-muted-foreground",children:"伏笔标记将在伏笔面板(S9)落地"})})]}),i.jsx("div",{className:"flex min-w-0 flex-col gap-4",children:i.jsxs(wl,{title:"相关实体",children:[i.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:"本节点作为源的关系(1 跳)"}),i.jsx(he,{variant:"outline",type:"button",className:"h-8 px-2 text-xs",onClick:()=>A(!0),children:"+ 新增关联"})]}),i.jsx(bS,{scope:{type:"outline_node",id:n},reloadKey:L,onOpenCreate:()=>A(!0)})]})})]}),U&&$!==null&&i.jsx(Xp,{source:{type:"outline_node",id:$.id,name:$.title},onCreated:()=>_(I=>I+1),onClose:()=>A(!1)})]})}function B3({field:n,value:o,sceneOptions:r,onChange:l}){switch(n.control){case"textarea":return i.jsx("textarea",{value:typeof o=="string"?o:"",onChange:c=>l(c.target.value),maxLength:n.maxLength,rows:3,className:Mm});case"checkbox-group":{const c=Array.isArray(o)?o:[];return i.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1.5",children:(n.options??[]).map(d=>i.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-sm text-foreground",children:[i.jsx("input",{type:"checkbox",checked:c.includes(d),onChange:()=>l(D3(c,d)),className:"size-4 accent-primary"}),n.optionsLabels?.[d]??d]},d))})}case"scene-select":{const c=L3(o),d=c!==""&&!r.some(m=>m.id===c);return i.jsxs("select",{value:c,onChange:m=>l(m.target.value),className:Ze(Mm,c===""&&"text-muted-foreground"),children:[i.jsx("option",{value:"",children:"(未设置)"}),d&&i.jsxs("option",{value:c,children:[c,"(已删除)"]}),r.map(m=>i.jsxs("option",{value:m.id,children:[" ".repeat(m.depth),m.label]},m.id))]})}default:return i.jsx(Dt,{value:typeof o=="string"?o:"",onChange:c=>l(c.target.value),maxLength:n.maxLength,className:"h-8 text-sm"})}}const xr={volume:248,chapter:208,scene:168},_s={volume:96,chapter:88,scene:76},Bo={padX:48,padY:48,colGap:304,rowGap:28,indentChapter:28,indentScene:56},SS=.5,ES=2,U3="ai-editor:canvas:";function Am(n){return Math.min(ES,Math.max(SS,n))}function H3(n){if(!n)return[];const o=[],r=(l,c,d)=>{for(const m of l)o.push({id:m.id,type:m.type,title:m.title,summary:m.summary,parentId:c,depth:d}),m.type!=="scene"&&m.children&&r(m.children,m.id,d+1)};return r(n.children,null,0),o}function Mv(n){const o={};let r=0;for(const l of n){if(l.depth!==0)continue;const c=Bo.padX+r*Bo.colGap;let d=Bo.padY;o[l.id]={x:c,y:d},d+=_s[l.type]+Bo.rowGap;for(const m of n)if(m.parentId===l.id){o[m.id]={x:c+Bo.indentChapter,y:d},d+=_s[m.type]+Bo.rowGap;for(const g of n)g.parentId===m.id&&(o[g.id]={x:c+Bo.indentScene,y:d},d+=_s.scene+Bo.rowGap)}r+=1}return o}function NS(n){return`${U3}${n}`}function P3(n){if(typeof n!="object"||n===null)return null;const o=n.nodes;if(typeof o!="object"||o===null||Array.isArray(o))return null;const r={};for(const[d,m]of Object.entries(o)){if(typeof m!="object"||m===null)return null;const g=m;if(typeof g.x!="number"||typeof g.y!="number"||!Number.isFinite(g.x)||!Number.isFinite(g.y))return null;r[d]={x:g.x,y:g.y}}const l=n.zoom,c=typeof l=="number"&&Number.isFinite(l)?Am(l):1;return{nodes:r,zoom:c}}function Y3(n){try{const o=localStorage.getItem(NS(n));return o===null?null:P3(JSON.parse(o))}catch{return null}}function om(n,o){try{localStorage.setItem(NS(n),JSON.stringify(o))}catch{}}function Av(n,o,r){const l={};for(const c of r)l[c.id]=n?.[c.id]??o[c.id];return l}function V3(n){const o=[];for(const r of n){if(r.relationType!==lj||r.sourceType!=="outline_node"||r.targetType!=="outline_node")continue;const l=r.metadata?.label,c=typeof l=="string"&&l.trim()!==""?l.trim():void 0;o.push({id:r.id,sourceId:r.sourceId,targetId:r.targetId,label:c})}return o.sort((r,l)=>r.id<l.id?-1:r.id>l.id?1:0),o}function F3(n){return n.filter(o=>o.type==="scene")}function G3(n,o){return n.filter(r=>o.has(r.sourceId)&&o.has(r.targetId))}function Dv(n,o){const r=Math.max(32,Math.abs(o.x-n.x)*.5),l=n.x+r,c=o.x-r;return`M ${n.x} ${n.y} C ${l} ${n.y}, ${c} ${o.y}, ${o.x} ${o.y}`}function q3(n,o){const r=Math.max(32,Math.abs(o.x-n.x)*.5),l={x:n.x+r,y:n.y},c={x:o.x-r,y:o.y};return{x:(n.x+3*l.x+3*c.x+o.x)/8,y:(n.y+3*l.y+3*c.y+o.y)/8}}function rm(n,o){return{x:n.x+xr[o]/2,y:n.y+_s[o]/2}}function zv(n,o,r,l){const c=o.x-n.x,d=o.y-n.y;if(c===0&&d===0)return n;const m=c===0?Number.POSITIVE_INFINITY:r/2/Math.abs(c),g=d===0?Number.POSITIVE_INFINITY:l/2/Math.abs(d),b=Math.min(m,g);return{x:n.x+b*c,y:n.y+b*d}}const Ts={highlight:"#a855f7",scene:"#f59e0b",chapter:"#3b82f6",volume:"#06b6d4",default:"#94a3b8"};function $3(n,o={}){if(o.onPath||o.selected)return Ts.highlight;switch(n){case"scene":return Ts.scene;case"chapter":return Ts.chapter;case"volume":return Ts.volume;default:return Ts.default}}function X3(n={}){return n.onPath||n.selected?2.5:1.5}function K3(n={}){return n.offPath?.2:1}const jS="canvas-edge-arrow";function Q3(){return`url(#${jS})`}const Kc={w:180,h:120},Oc=4,Z3=1,J3=.02;function W3(n,o,r,l){let c=Number.POSITIVE_INFINITY,d=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY,b=0;for(const C of n){const U=o[C.id];U&&(c=Math.min(c,U.x),d=Math.min(d,U.y),m=Math.max(m,U.x+xr[C.type]),g=Math.max(g,U.y+_s[C.type]),b+=1)}if(b===0)return{nodeRects:[],viewportRect:null};const p=m-c,v=g-d,x=Kc.w-2*Oc,S=Kc.h-2*Oc,j=Math.min(x/p,S/v),E=Math.min(Z3,Math.max(J3,j)),M=Oc+(x-p*E)/2,O=Oc+(S-v*E)/2,N=[];for(const C of n){const U=o[C.id];U&&N.push({id:C.id,x:M+(U.x-c)*E,y:O+(U.y-d)*E,w:xr[C.type]*E,h:_s[C.type]*E,type:C.type})}let T=null;const k=r>0?r:1;if(l!==null&&l.width>0&&l.height>0){const C={x:l.x/k,y:l.y/k,width:l.width/k,height:l.height/k};T={x:M+(C.x-c)*E,y:O+(C.y-d)*E,w:C.width*E,h:C.height*E}}return{nodeRects:N,viewportRect:T}}function eM(n,o){const r=new Set([n]),l=new Set,c=[n];for(;c.length>0;){const d=c.pop();for(const m of o)m.sourceId!==d||l.has(m.id)||(l.add(m.id),r.has(m.targetId)||(r.add(m.targetId),c.push(m.targetId)))}return{nodeIds:r,edgeIds:l}}function Lv(n){switch(n){case"RELATION_EXISTS":return"这条连线已经存在";case"VALIDATION_ERROR":return"连线参数有误";case"CLIENT_NETWORK_ERROR":return"无法连接服务,请确认 ai-editor 服务已启动";default:return null}}function tM(){const n=Be(te=>te.outline),o=Be(te=>te.outlineLoading),r=Be(te=>te.config),l=Be(te=>te.configLoading),c=Be(te=>te.loadOutline),[d,m]=h.useState({}),[g,b]=h.useState(1),[p,v]=h.useState(!1),[x,S]=h.useState(!0),[j,E]=h.useState(!1),[M,O]=h.useState(null),[N,T]=h.useState(null),[k,C]=h.useState(null),[U,A]=h.useState(null),[L,_]=h.useState(null),[K,W]=h.useState(null),[ue,ne]=h.useState(null),[$,oe]=h.useState(null),[q,w]=h.useState(null),[D,H]=h.useState(null),[B,P]=h.useState(!1),z=h.useRef(null),X=h.useRef(null),I=h.useRef(null),V=h.useRef(d);V.current=d;const Q=h.useRef(0),Y=r?.id??null,fe=r===null&&!l,re=h.useCallback(async()=>{if(Y===null)return;const xe=++Q.current;try{const Oe=await vr({source_type:"outline_node",relation_type:"plot_edge",depth:1});if(xe!==Q.current)return;O(V3(Oe.relations)),T(null)}catch(Oe){if(xe!==Q.current)return;T(Oe instanceof ze?Oe.code:ft)}},[Y]);Ds(()=>{c(),re()});const de=h.useMemo(()=>H3(n),[n]),_e=h.useMemo(()=>new Map(de.map(te=>[te.id,te])),[de]),[Ye,Re]=h.useState(null);h.useEffect(()=>{if(Y===null){Re(null),m({}),b(1);return}const te=Y3(Y);Re(Y),b(te?.zoom??1),m(te?.nodes??{})},[Y]);const Le=Ye===Y;h.useEffect(()=>{de.length===0||!Le||m(te=>Av(te,Mv(de),de))},[de,Le]),h.useEffect(()=>{if(!(Y===null||!Le))return I.current!==null&&window.clearTimeout(I.current),I.current=window.setTimeout(()=>{om(Y,{nodes:d,zoom:g})},300),()=>{I.current!==null&&(window.clearTimeout(I.current),I.current=null,V.current===d&&Y!==null&&Le&&om(Y,{nodes:d,zoom:g}))}},[d,Y,g,Le]),h.useEffect(()=>{Y===null||!Le||om(Y,{nodes:d,zoom:g})},[g,Y,Le]),h.useEffect(()=>{n===null&&!o&&!j&&(E(!0),c())},[n,o,j,c]),h.useEffect(()=>{if(Y===null){O(null),T(null);return}re()},[Y,re]),h.useEffect(()=>{if(n===null){C(null);return}let te=!1;return Promise.all(Yp.map(xe=>vr({source_type:"outline_node",relation_type:xe,depth:1}).then(Oe=>Oe.relations).catch(()=>[]))).then(xe=>{te||C(mS(xe.flat()))}),()=>{te=!0}},[n]);const He=h.useRef(null),ge=h.useRef(null),pe=h.useCallback(()=>{const te=z.current,xe=X.current;if(te===null||xe===null)return;const Oe=te.getBoundingClientRect(),We=xe.getBoundingClientRect(),rt={x:Math.round(Oe.left-We.left),y:Math.round(Oe.top-We.top),width:Math.round(Oe.width),height:Math.round(Oe.height)};W(ct=>ct!==null&&ct.x===rt.x&&ct.y===rt.y&&ct.width===rt.width&&ct.height===rt.height?ct:rt)},[]),ve=h.useCallback(te=>{if(z.current=te,He.current?.(),He.current=null,ge.current?.(),ge.current=null,te===null)return;const xe=We=>{We.preventDefault(),b(rt=>Am(Math.round((rt+(We.deltaY<0?.1:-.1))*10)/10))};te.addEventListener("wheel",xe,{passive:!1}),He.current=()=>te.removeEventListener("wheel",xe),pe();const Oe=new ResizeObserver(()=>pe());Oe.observe(te),ge.current=()=>Oe.disconnect()},[pe]);h.useEffect(()=>()=>{He.current?.(),He.current=null,ge.current?.(),ge.current=null},[]),h.useEffect(()=>{if($===null)return;const te=xe=>{xe.key==="Escape"&&oe(null)};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[$]);const Ue=p?F3(de):de,ye=h.useMemo(()=>new Set(Ue.map(te=>te.id)),[Ue]),De=h.useMemo(()=>G3(M??[],ye),[M,ye]);h.useEffect(()=>{L!==null&&!ye.has(L)&&_(null)},[L,ye]);const Pe=h.useMemo(()=>{const te=[];for(const xe of De){const Oe=d[xe.sourceId],We=d[xe.targetId],rt=_e.get(xe.sourceId),ct=_e.get(xe.targetId);if(!Oe||!We||!rt||!ct)continue;const lt=rm(Oe,rt.type),Ft=rm(We,ct.type),$n=zv(lt,Ft,xr[rt.type],_s[rt.type]),Kt=zv(Ft,lt,xr[ct.type],_s[ct.type]);te.push({edge:xe,d:Dv($n,Kt),mid:q3($n,Kt),targetType:ct.type})}return te},[De,d,_e]),Ie=h.useMemo(()=>L!==null&&$===null?eM(L,De):null,[L,$,De]),we=h.useMemo(()=>Pe.map(te=>{const xe=te.edge.id===U,Oe=Ie?.edgeIds.has(te.edge.id)??!1;return{...te,stroke:$3(te.targetType,{onPath:Oe,selected:xe}),strokeWidth:X3({onPath:Oe,selected:xe}),opacity:K3({offPath:Ie!==null&&!Oe}),dash:Oe||xe}}),[Pe,Ie,U]),ee=h.useMemo(()=>W3(Ue,d,g,K),[Ue,d,g,K]),F=h.useMemo(()=>{let te=0,xe=0;for(const Oe of de){const We=d[Oe.id];We&&(te=Math.max(te,We.x+xr[Oe.type]),xe=Math.max(xe,We.y+_s[Oe.type]))}return{w:te+96,h:xe+96}},[de,d]),ie=h.useMemo(()=>Pe.find(te=>te.edge.id===U)??null,[Pe,U]),Z=h.useMemo(()=>{if($===null||q===null)return null;const te=_e.get($),xe=d[$];return!te||!xe?null:Dv(rm(xe,te.type),q)},[$,q,d,_e]);function Ee(te,xe){const Oe=X.current?.getBoundingClientRect();return Oe?{x:(te-Oe.left)/g,y:(xe-Oe.top)/g}:{x:0,y:0}}function Xe(te,xe){if(te.target.closest("[data-canvas-handle]")||te.button!==0)return;te.preventDefault();const Oe=d[xe.id];Oe&&(te.currentTarget.setPointerCapture(te.pointerId),ne({nodeId:xe.id,startClientX:te.clientX,startClientY:te.clientY,origX:Oe.x,origY:Oe.y}))}function Ne(te,xe){if(ue===null||ue.nodeId!==xe)return;const Oe=(te.clientX-ue.startClientX)/g,We=(te.clientY-ue.startClientY)/g;m(rt=>rt[xe]?{...rt,[xe]:{x:ue.origX+Oe,y:ue.origY+We}}:rt)}function Me(){ne(null)}function Je(te,xe){te.stopPropagation(),te.preventDefault(),te.button===0&&(te.currentTarget.setPointerCapture(te.pointerId),A(null),oe(xe.id),w(Ee(te.clientX,te.clientY)))}function nt(te){$!==null&&w(Ee(te.clientX,te.clientY))}async function jt(te){if($===null)return;const xe=$,rt=document.elementFromPoint(te.clientX,te.clientY)?.closest("[data-canvas-node-id]")?.getAttribute("data-canvas-node-id")??null;if(oe(null),w(null),!(rt===null||rt===xe))try{await Sr({source_type:"outline_node",source_id:xe,target_type:"outline_node",target_id:rt,relation_type:"plot_edge"}),ke.getState().showToast("已建立连线"),await re()}catch(ct){const lt=ct instanceof ze?ct.code:null,Ft=Lv(lt);if(Ft!==null){ke.getState().showToast(Ft,"error"),await re();return}ke.getState().showToast(ct instanceof ze?ct.message:"创建失败,请重试","error")}}const kt=h.useRef(!1);function gt(te){kt.current=!1,H({edgeId:te.id,draft:te.label??""})}async function ln(te,xe){if(!B){P(!0),H(null);try{const Oe=xe.trim();await $w(te,Oe===""?{}:{label:Oe}),ke.getState().showToast("已保存标签"),await re()}catch(Oe){ke.getState().showToast(Oe instanceof ze?Oe.message:"保存失败,请重试","error")}finally{P(!1)}}}function Jt(te){te.key==="Enter"?(te.preventDefault(),kt.current=!0,D!==null&&ln(D.edgeId,D.draft)):te.key==="Escape"&&(te.preventDefault(),kt.current=!0,H(null))}function et(){kt.current||D!==null&&ln(D.edgeId,D.draft)}async function je(){if(ie===null)return;const te=ie.edge;if(await ke.getState().confirm({title:"删除连线",description:`删除连线「${te.label??"未命名"}」?物理删除不可恢复,可随时重建。`,danger:!0}))try{kt.current=!0,H(null),await Zc(te.id),ke.getState().showToast("已删除连线"),A(null),await re()}catch(Oe){const We=Oe instanceof ze?Oe.code:null,rt=Lv(We);ke.getState().showToast(rt??(Oe instanceof ze?Oe.message:"删除失败,请重试"),"error"),We==="RELATION_NOT_FOUND"&&(A(null),await re())}}function Ce(){m(te=>Av(te,Mv(de),de))}function qe(te){b(xe=>Am(Math.round((xe+te)*10)/10))}return i.jsxs("section",{className:"flex h-full min-h-0 flex-col gap-3",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[i.jsx("h1",{className:"mr-auto font-serif text-xl font-medium",children:"画布"}),i.jsx(he,{variant:"outline",type:"button",onClick:Ce,disabled:de.length===0,children:"重新布局"}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(he,{variant:"outline",size:"icon-sm",type:"button","aria-label":"缩小",disabled:g<=SS,onClick:()=>qe(-.1),children:i.jsx(qj,{})}),i.jsxs("span",{className:"w-12 text-center text-sm tabular-nums text-muted-foreground",children:[Math.round(g*100),"%"]}),i.jsx(he,{variant:"outline",size:"icon-sm",type:"button","aria-label":"放大",disabled:g>=ES,onClick:()=>qe(.1),children:i.jsx(Gm,{})})]}),i.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-secondary/30 p-1",role:"group","aria-label":"显示模式",children:[!1,!0].map(te=>i.jsx("button",{type:"button",onClick:()=>v(te),"aria-pressed":p===te,className:Ze("rounded-md px-2.5 py-1 text-xs transition-colors",p===te?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:te?"仅场景":"全部节点"},String(te)))}),i.jsxs(he,{variant:"ghost",size:"sm",type:"button",onClick:()=>S(te=>!te),"aria-expanded":x,children:[i.jsx(Wv,{}),"画布说明"]})]}),x&&i.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:["连线与坐标仅用于推演展示,不参与状态计算",i.jsx("button",{type:"button",className:"rounded p-0.5 hover:bg-muted hover:text-foreground","aria-label":"收起说明",onClick:()=>S(!1),children:i.jsx(As,{className:"size-3"})})]}),N!==null&&i.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[N===ft?"无法连接服务,请确认 ai-editor 服务已启动。":"连线加载失败,请重试。",i.jsx(he,{variant:"outline",className:"ml-3",type:"button",onClick:()=>{re()},children:"重试"})]}),fe?i.jsxs("div",{className:"rounded-md border border-dashed border-border px-6 py-10 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"未打开项目,无法查看画布"}),i.jsx("a",{href:"#/",className:"mt-2 inline-block text-sm text-muted-foreground underline hover:text-foreground",children:"回到首页打开或创建书籍"})]}):o&&n===null?i.jsx("div",{className:"flex-1 overflow-hidden rounded-md border border-border bg-muted/20 p-4",children:Array.from({length:3},(te,xe)=>i.jsxs("div",{className:"mb-4 flex gap-4",children:[i.jsx("div",{className:"h-24 w-60 animate-pulse rounded-lg bg-muted"}),i.jsx("div",{className:"mt-6 h-24 w-52 animate-pulse rounded-lg bg-muted"}),i.jsx("div",{className:"mt-12 h-20 w-44 animate-pulse rounded-lg bg-muted"})]},xe))}):n===null?i.jsxs("div",{className:"rounded-md border border-border p-4 text-sm text-muted-foreground",children:["大纲加载失败",i.jsx(he,{variant:"outline",className:"ml-3",type:"button",onClick:()=>E(!1),children:"重试"})]}):n.children.length===0?i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-12 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"大纲还是空的,先去搭大纲"}),i.jsx(he,{className:"mt-4",type:"button",onClick:()=>Tn("/outline"),children:"去大纲"})]}):Ue.length===0?i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-12 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"当前大纲还没有场景节点"}),i.jsx(he,{variant:"outline",className:"mt-4",type:"button",onClick:()=>v(!1),children:"显示全部节点"})]}):i.jsxs("div",{ref:ve,className:"relative min-h-0 flex-1 overflow-auto rounded-md border border-border bg-muted/20",onScroll:pe,onClick:te=>{te.target===te.currentTarget&&A(null)},children:[i.jsxs("div",{ref:X,className:"relative",style:{width:F.w,height:F.h,transform:`scale(${g})`,transformOrigin:"0 0"},onClick:te=>{te.target===te.currentTarget&&A(null)},children:[i.jsxs("svg",{className:"pointer-events-none absolute left-0 top-0",width:F.w,height:F.h,style:{overflow:"visible"},children:[i.jsx("defs",{children:i.jsx("marker",{id:jS,viewBox:"0 0 10 10",refX:10,refY:5,markerWidth:10,markerHeight:10,markerUnits:"userSpaceOnUse",orient:"auto",children:i.jsx("path",{d:"M 0 0 L 10 5 L 0 10 Z",fill:"context-stroke"})})}),we.map(({edge:te,d:xe,stroke:Oe,strokeWidth:We,opacity:rt,dash:ct})=>{const lt=te.id===U;return i.jsxs("g",{opacity:rt,children:[i.jsx("path",{d:xe,fill:"none",stroke:Oe,strokeWidth:We,strokeDasharray:ct?"6 4":void 0,vectorEffect:"non-scaling-stroke",markerEnd:Q3(),className:ct?"canvas-edge-flow":void 0}),i.jsx("path",{d:xe,fill:"none",stroke:"transparent",strokeWidth:14,vectorEffect:"non-scaling-stroke",className:"pointer-events-auto cursor-pointer",onClick:()=>A(lt?null:te.id)})]},te.id)}),Z!==null&&i.jsx("path",{d:Z,fill:"none",stroke:"var(--primary)",strokeWidth:2,strokeDasharray:"6 4",vectorEffect:"non-scaling-stroke"})]}),we.map(({edge:te,mid:xe,opacity:Oe})=>{const We=te.id===U;return We&&D!==null&&D.edgeId===te.id?i.jsx("div",{className:"absolute z-20 -translate-x-1/2 -translate-y-1/2",style:{left:xe.x,top:xe.y},children:i.jsx(Dt,{value:D.draft,onChange:ct=>H({edgeId:te.id,draft:ct.target.value}),onKeyDown:Jt,onBlur:et,onFocus:ct=>ct.currentTarget.select(),maxLength:50,placeholder:"+ 标签",autoFocus:!0,"aria-label":"编辑连线标签",className:"h-7 w-44 rounded-md px-1.5 py-0.5 text-xs"})},`label-${te.id}`):i.jsx("span",{className:Ze("pointer-events-none absolute max-w-44 -translate-x-1/2 -translate-y-1/2 truncate whitespace-nowrap rounded border bg-card px-1.5 py-0.5 text-[10px] text-muted-foreground",We&&"pointer-events-auto cursor-text"),style:{left:xe.x,top:xe.y,opacity:Oe,...We?{borderColor:Ts.highlight,color:Ts.highlight}:{}},title:We?te.label===void 0?"添加标签":"编辑标签":void 0,onClick:ct=>{ct.stopPropagation(),gt(te)},children:te.label??(We?"+ 标签":"未命名连线")},`label-${te.id}`)}),ie!==null&&i.jsxs("div",{className:"absolute z-10 flex -translate-x-1/2 items-center gap-1 rounded-lg border border-border bg-card p-1 shadow-sm",style:{left:ie.mid.x,top:ie.mid.y+26},children:[i.jsx("span",{className:"max-w-36 truncate px-1.5 text-xs text-muted-foreground",children:ie.edge.label??"未命名连线"}),i.jsx(he,{variant:"outline",size:"xs",type:"button",className:"text-destructive hover:bg-destructive/10",onClick:()=>{je()},children:"删除连线"}),i.jsx("button",{type:"button","aria-label":"取消选择",className:"rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>A(null),children:i.jsx(As,{className:"size-3.5"})})]}),Ue.map(te=>{const xe=d[te.id];if(!xe)return null;const Oe=k?.get(te.id)??[],We=$===te.id,rt=ue?.nodeId===te.id,ct=Ie?.nodeIds.has(te.id)??!1;return i.jsxs("div",{"data-canvas-node-id":te.id,className:Ze("group absolute cursor-grab touch-none select-none rounded-lg border bg-card p-2.5 transition-colors active:cursor-grabbing",We?"border-primary ring-2 ring-ring/40":"border-border",rt&&"opacity-80"),style:{left:xe.x,top:xe.y,width:xr[te.type],height:_s[te.type],...Ie!==null?{opacity:ct?1:.2,boxShadow:ct?`0 0 0 2px ${Ts.highlight}`:void 0}:{}},title:"拖动调整位置",onPointerDown:lt=>Xe(lt,te),onPointerMove:lt=>Ne(lt,te.id),onPointerUp:Me,onMouseEnter:()=>_(te.id),onMouseLeave:()=>_(lt=>lt===te.id?null:lt),children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:os[te.type]}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",title:te.title,children:te.title}),Oe.length>0&&i.jsx("span",{className:"flex shrink-0 items-center gap-0.5",children:Oe.map(lt=>i.jsx(fS,{mark:lt},`${lt.relationType}-${lt.hookId}`))})]}),te.summary&&i.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-4 text-muted-foreground",children:te.summary}),i.jsx("span",{"data-canvas-handle":!0,className:Ze("absolute top-1/2 -right-2 h-4 w-4 -translate-y-1/2 cursor-crosshair rounded-full border bg-card transition-colors",We?"border-primary bg-primary/10":"border-border hover:border-primary hover:bg-accent"),title:"拖出连线","aria-label":"拖出连线",onPointerDown:lt=>Je(lt,te),onPointerMove:nt,onPointerUp:jt})]},te.id)})]}),i.jsx("div",{className:"pointer-events-none absolute right-2 bottom-2 z-10 overflow-hidden rounded-md border border-border bg-card/90 shadow-sm",children:i.jsxs("svg",{width:Kc.w,height:Kc.h,children:[ee.nodeRects.map(te=>i.jsx("rect",{x:te.x,y:te.y,width:te.w,height:te.h,rx:2,fill:Ts[te.type],opacity:.85},te.id)),ee.viewportRect!==null&&i.jsx("rect",{x:ee.viewportRect.x,y:ee.viewportRect.y,width:ee.viewportRect.w,height:ee.viewportRect.h,fill:"none",stroke:Ts.highlight,strokeWidth:1})]})})]})]})}const Ea={character:"人物",setting:"设定",location:"地点",hook:"伏笔",event:"事件",timepoint:"时间点"},Iv=[{value:"updated_at:desc",label:"更新时间(新→旧)",sort:"updated_at",order:"desc"},{value:"updated_at:asc",label:"更新时间(旧→新)",sort:"updated_at",order:"asc"},{value:"name:asc",label:"名称(A→Z)",sort:"name",order:"asc"},{value:"name:desc",label:"名称(Z→A)",sort:"name",order:"desc"},{value:"created_at:desc",label:"创建时间(新→旧)",sort:"created_at",order:"desc"},{value:"created_at:asc",label:"创建时间(旧→新)",sort:"created_at",order:"asc"}];function Bv({type:n}){const o=n==="relations",r=Ca.includes(n)?n:"character",[l,c]=h.useState(null),[d,m]=h.useState(0),[g,b]=h.useState(!1),[p,v]=h.useState(null),[x,S]=h.useState(""),[j,E]=h.useState(""),[M,O]=h.useState(0),[N,T]=h.useState("updated_at"),[k,C]=h.useState("desc"),[U,A]=h.useState(0);Ds(()=>A(Y=>Y+1));const[L,_]=h.useState(!1),[K,W]=h.useState(""),[ue,ne]=h.useState(""),[$,oe]=h.useState(null),[q,w]=h.useState(!1),D=m3[r],H=Tv[r],B=f3(d,Tl),P=Math.floor(M/Tl)+1;h.useEffect(()=>{S(""),E(""),O(0),T("updated_at"),C("desc"),c(null),v(null),_(!1)},[n]),h.useEffect(()=>{const Y=setTimeout(()=>{E(x.trim()),O(0)},300);return()=>clearTimeout(Y)},[x]),h.useEffect(()=>{if(o)return;let Y=!1;return b(!0),v(null),ls(r,{q:j||void 0,offset:M,limit:Tl,sort:N,order:k}).then(fe=>{Y||(c(fe.items),m(fe.total))}).catch(fe=>{Y||(c(null),v(fe instanceof ze?fe.code:ft))}).finally(()=>{Y||b(!1)}),()=>{Y=!0}},[r,j,M,N,k,U,o]);function z(Y){const fe=Iv.find(re=>re.value===Y);fe&&(T(fe.sort),C(fe.order),O(0))}function X(){W(""),ne(""),oe(null),_(!0)}function I(){_(!1),oe(null)}async function V(Y){Y.preventDefault();const fe=K.trim();if(!fe){oe("请输入名称");return}w(!0),oe(null);try{const re=Tv[r],de={};re.key!==""&&ue.trim()&&(de[re.key]=ue.trim());const _e=await Bc(r,{name:fe,data:de});ke.getState().showToast(`已创建${Ea[r]}《${fe}》`),_(!1),Tn(`/entities/${r}/${_e.id}`)}catch(re){oe(re instanceof ze?re.message:"创建失败,请重试")}finally{w(!1)}}function Q(){S(""),E(""),O(0)}return i.jsxs("section",{children:[i.jsx("h1",{className:"mb-4 text-xl font-semibold",children:"实体"}),i.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b border-zinc-200 pb-3",children:[i.jsxs("div",{className:"flex gap-1",children:[Ca.map(Y=>i.jsx("button",{type:"button",onClick:()=>Tn(`/entities/${Y}`),className:Ze("rounded-md px-3 py-1.5 text-sm",!o&&r===Y?"bg-zinc-900 text-white":"text-zinc-500 hover:bg-zinc-100 hover:text-zinc-800"),children:Ea[Y]},Y)),i.jsx("button",{type:"button",onClick:()=>Tn("/entities/relations"),className:Ze("rounded-md px-3 py-1.5 text-sm",o?"bg-foreground font-medium text-background":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:"关联"})]}),i.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[!o&&i.jsx(Dt,{value:x,onChange:Y=>S(Y.target.value),placeholder:`搜索${Ea[r]}名称…`,className:"w-52"}),i.jsx(he,{type:"button",onClick:o?()=>_(!0):X,children:o?"+ 建立关联":"+ 新建"})]})]}),o?i.jsx(bS,{reloadKey:U,onOpenCreate:()=>_(!0)}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mb-2 mt-3 flex items-center gap-3",children:[i.jsxs("label",{className:"flex items-center gap-2 text-sm text-zinc-500",children:["排序:",i.jsx("select",{value:`${N}:${k}`,onChange:Y=>z(Y.target.value),className:"rounded-md border border-zinc-300 bg-white px-2 py-1 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400",children:Iv.map(Y=>i.jsx("option",{value:Y.value,children:Y.label},Y.value))})]}),i.jsxs("span",{className:"ml-auto text-sm text-zinc-400",children:["共 ",d," 个"]})]}),L&&i.jsxs("form",{id:"create-entity-row",onSubmit:V,className:"mb-3 flex flex-wrap items-center gap-2 rounded-md border border-border bg-card px-3 py-2",children:[i.jsx(Dt,{value:K,onChange:Y=>W(Y.target.value),onKeyDown:Y=>{Y.key==="Escape"&&I()},placeholder:`名称(如:${r==="character"?"张三":"示例名称"})`,maxLength:100,disabled:q,autoFocus:!0,"aria-label":"名称",className:"w-48"}),H.key!==""&&(H.input==="select"?i.jsxs("select",{value:ue,onChange:Y=>ne(Y.target.value),disabled:q,"aria-label":H.label,className:"rounded-md border border-input bg-background px-2 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",children:[i.jsxs("option",{value:"",children:[H.label,"(选填)"]}),H.options?.map(Y=>i.jsx("option",{value:Y,children:tm(r,H.key,Y)},Y))]}):i.jsx(Dt,{value:ue,onChange:Y=>ne(Y.target.value),placeholder:`${H.label}(选填)`,disabled:q,"aria-label":H.label,className:"w-40"})),i.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[i.jsx(he,{variant:"outline",type:"button",size:"sm",onClick:I,disabled:q,children:"取消"}),i.jsx(he,{type:"submit",size:"sm",disabled:q,children:q?"创建中…":"创建"})]}),$&&i.jsx("p",{className:"w-full text-sm text-destructive",children:$})]}),p!==null&&i.jsxs("div",{className:"mb-3 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700",children:[p===ft?"无法连接服务,请确认 ai-editor 服务已启动。":"列表加载失败,请重试。",i.jsx(he,{variant:"outline",className:"ml-3",type:"button",onClick:()=>A(Y=>Y+1),children:"重试"})]}),g&&l===null&&p===null&&i.jsx("div",{className:"overflow-hidden rounded-md border border-zinc-200",children:Array.from({length:6},(Y,fe)=>i.jsxs("div",{className:"flex items-center gap-3 border-b border-zinc-100 px-3 py-3 last:border-0",children:[i.jsx("div",{className:"h-4 w-1/4 animate-pulse rounded bg-zinc-100"}),i.jsx("div",{className:"h-4 w-1/6 animate-pulse rounded bg-zinc-100"}),D.key2&&i.jsx("div",{className:"h-4 w-1/6 animate-pulse rounded bg-zinc-100"}),i.jsx("div",{className:"ml-auto h-4 w-16 animate-pulse rounded bg-zinc-100"})]},fe))}),!g&&l!==null&&l.length===0&&i.jsx("div",{className:"rounded-lg border border-dashed border-zinc-300 px-6 py-12 text-center",children:j?i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"text-sm text-zinc-600",children:["没有匹配「",j,"」的",Ea[r]]}),i.jsx(he,{variant:"outline",className:"mt-4",type:"button",onClick:Q,children:"清空搜索"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"text-sm text-zinc-600",children:["还没有",Ea[r],",新建一个"]}),i.jsxs(he,{className:"mt-4",type:"button",onClick:X,children:["+ 新建",Ea[r]]})]})}),!g&&l!==null&&l.length>0&&i.jsx("div",{className:"overflow-hidden rounded-md border border-zinc-200",children:i.jsxs("table",{className:"w-full text-left text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-zinc-200 bg-zinc-50 text-xs text-zinc-400",children:[i.jsx("th",{className:"px-3 py-2 font-normal",children:"名称"}),i.jsx("th",{className:"px-3 py-2 font-normal",children:D.label1}),D.key2&&i.jsx("th",{className:"px-3 py-2 font-normal",children:D.label2}),i.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"更新时间"})]})}),i.jsx("tbody",{children:l.map(Y=>i.jsxs("tr",{className:"cursor-pointer border-b border-zinc-100 transition-colors last:border-0 hover:bg-zinc-50",onClick:()=>Tn(`/entities/${r}/${Y.id}`),title:`打开《${Y.name}》`,children:[i.jsx("td",{className:"max-w-64 truncate px-3 py-2 font-medium text-zinc-800",children:Y.name}),i.jsx("td",{className:"max-w-40 truncate px-3 py-2 text-zinc-600",children:tm(r,D.key1,Y.summary[D.key1])}),D.key2&&i.jsx("td",{className:"max-w-40 truncate px-3 py-2 text-zinc-600",children:tm(r,D.key2,Y.summary[D.key2])}),i.jsx("td",{className:"whitespace-nowrap px-3 py-2 text-right text-xs text-zinc-400",children:is(Y.updatedAt)})]},Y.id))})]})}),!g&&l!==null&&l.length>0&&i.jsxs("div",{className:"mt-4 flex items-center justify-center gap-3 text-sm",children:[i.jsx("button",{type:"button",disabled:P<=1||g,className:"rounded-md border border-zinc-300 px-3 py-1 text-zinc-600 hover:bg-zinc-100 disabled:opacity-40",onClick:()=>O((P-2)*Tl),children:"‹ 上一页"}),i.jsxs("span",{className:"text-zinc-500",children:["第 ",P," / ",B," 页"]}),i.jsx("button",{type:"button",disabled:P>=B||g,className:"rounded-md border border-zinc-300 px-3 py-1 text-zinc-600 hover:bg-zinc-100 disabled:opacity-40",onClick:()=>O(P*Tl),children:"下一页 ›"})]})]}),o&&L&&i.jsx(Xp,{source:null,onCreated:()=>A(Y=>Y+1),onClose:()=>_(!1)})]})}function nM({type:n,id:o,currentData:r,deltaCount:l}){const c=Be(T=>T.outline),d=Be(T=>T.config),m=Be(T=>T.loadOutline),[g,b]=h.useState(()=>{const T=Be.getState().config?.currentPosition??"",k=Be.getState().outline?.children??[];return T!==""&&ao(k).some(C=>C.id===T)?T:""}),[p,v]=h.useState(!1),[x,S]=h.useState(null),[j,E]=h.useState(null);h.useEffect(()=>{b(T=>{if(T!=="")return T;const k=d?.currentPosition??"";return k!==""&&ao(c?.children??[]).some(C=>C.id===k)?k:""})},[d?.currentPosition,c]);const M=ao(c?.children??[]),O=new Map(M.map(T=>[T.id,T.label]));async function N(){if(!(!g||p)){v(!0),E(null);try{const T=await Kw({target_type:n,target_id:o,at_node_id:g});S(T)}catch(T){S(null),T instanceof ze&&T.code==="OUTLINE_NODE_NOT_FOUND"?E("该节点已不存在,请重新选择计算节点"):E(T instanceof ze?T.message:"无法连接服务,请确认 ai-editor 服务已启动")}finally{v(!1)}}}return i.jsxs("div",{className:"mb-4 rounded-md border border-border p-4",children:[i.jsxs("h2",{className:"mb-2 text-sm font-semibold text-foreground",children:["变更记录 · 状态预览",i.jsxs("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:[l," 条"]})]}),l===0?i.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无变更记录——实体当前状态即初始状态"}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-xs text-muted-foreground",children:"计算节点(到达该节点时的累积状态)"}),c===null?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-xs text-muted-foreground",children:"大纲未加载"}),i.jsx(he,{variant:"outline",size:"xs",type:"button",onClick:()=>{m()},children:"加载大纲"})]}):i.jsxs("select",{value:g,onChange:T=>b(T.target.value),"aria-label":"计算节点",className:Ze("min-w-56 rounded-md border border-border bg-card px-2 py-1 text-sm text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",g===""&&"text-muted-foreground"),children:[i.jsx("option",{value:"",children:"请选择大纲节点"}),M.map(T=>i.jsxs("option",{value:T.id,children:[" ".repeat(T.depth),T.label]},T.id))]})]}),i.jsx(he,{variant:"outline",size:"sm",type:"button",disabled:!g||p,onClick:()=>{N()},children:p?"计算中…":"计算"})]}),d?.currentPosition==null&&i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"未设置当前位置,请手动选择计算节点"}),j!==null&&i.jsx("div",{className:"mt-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:j}),p&&i.jsxs("div",{className:"mt-3 space-y-2",children:[i.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-4 w-1/2 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-16 animate-pulse rounded bg-muted/60"})]}),!p&&x!==null&&i.jsx(sM,{result:x,currentData:r,nodeTitles:O})]})]})}function sM({result:n,currentData:o,nodeTitles:r}){const l=v3(o,n.state),c=r.get(n.atNodeId)??n.atNodeId;return i.jsxs("div",{className:"mt-3 space-y-3",children:[n.conflicts.length>0&&i.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2",children:[i.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-medium text-destructive",children:[i.jsx(qm,{className:"size-3.5 shrink-0"}),"发现 ",n.conflicts.length," 处状态冲突"]}),i.jsx("p",{className:"mt-0.5 text-xs text-destructive/90",children:"手动编辑的数据与变更记录不一致,以下变更未应用(可直接修改当前数据,或调整变更记录):"}),i.jsx("ul",{className:"mt-1 space-y-0.5",children:n.conflicts.map((d,m)=>i.jsxs("li",{className:"text-xs text-destructive",children:[d.field,":记录应为 ",rs(d.expected),",实际为 ",rs(d.actual)]},m))})]}),i.jsxs("div",{children:[i.jsxs("h3",{className:"mb-1.5 text-xs font-medium text-muted-foreground",children:["状态差异(相对当前数据 · 到达《",c,"》",l.length>0?`,${l.length} 处`:"",")"]}),l.length===0?i.jsx("p",{className:"text-xs text-muted-foreground",children:"计算状态与当前数据一致"}):i.jsx("ul",{className:"space-y-1",children:l.map(d=>i.jsxs("li",{className:"flex items-baseline gap-2 text-xs",children:[i.jsx("span",{className:"shrink-0 font-medium text-foreground",children:d.field}),i.jsxs("span",{className:"text-muted-foreground",children:[d.from===void 0?"(无)":rs(d.from)," →"," ",d.to===void 0?"(已移除)":rs(d.to)]})]},d.field))})]}),i.jsxs("div",{children:[i.jsxs("h3",{className:"mb-1.5 text-xs font-medium text-muted-foreground",children:["应用的变更记录(",n.appliedDeltas.length,")"]}),n.appliedDeltas.length===0?i.jsx("p",{className:"text-xs text-muted-foreground",children:"到达该节点前没有变更被应用"}):i.jsx("ul",{className:"divide-y divide-border/70 rounded-md border border-border",children:n.appliedDeltas.map((d,m)=>i.jsxs("li",{className:"px-3 py-2",children:[i.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",title:d.description,children:d.description}),i.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:["《",r.get(d.nodeId)??d.nodeId,"》"]})]}),d.skipped!==void 0&&d.skipped.length>0&&i.jsx("ul",{className:"mt-1 space-y-0.5",children:d.skipped.map(g=>i.jsxs("li",{className:"text-xs text-destructive",children:[g.field,":记录应为 ",rs(g.expected),",实际 ",rs(g.actual),"(已跳过)"]},g.index))}),i.jsx("div",{className:"mt-1.5",children:i.jsx(yS,{changes:d.changes,skipped:d.skipped?.map(g=>g.index)})})]},m))})]})]})}const oM={character:"人物",setting:"设定",location:"地点",hook:"伏笔",event:"事件",timepoint:"时间点"};function Cl(n,o){const r=n[o];return r==null?"":String(r)}function rM({values:n,onChange:o,placeholder:r}){return i.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.map((l,c)=>i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Dt,{value:l,onChange:d=>{const m=[...n];m[c]=d.target.value,o(m)},placeholder:r,className:"h-8 flex-1 text-sm"}),i.jsx(he,{variant:"outline",type:"button",className:"h-8 px-2 text-xs",onClick:()=>o(n.filter((d,m)=>m!==c)),children:"删除"})]},c)),i.jsx(he,{variant:"outline",type:"button",className:"h-8 self-start px-2 text-xs",onClick:()=>o([...n,""]),children:"+ 添加"})]})}function aM({value:n,onChange:o}){const[r,l]=h.useState(()=>Object.entries(n??{}).map(([d,m])=>({key:d,value:String(m??"")})));h.useEffect(()=>{l(Object.entries(n??{}).map(([d,m])=>({key:d,value:String(m??"")})))},[n]);function c(d){l(d);const m={};for(const g of d)g.key.trim()&&(m[g.key.trim()]=g.value);o(m)}return i.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.map((d,m)=>i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Dt,{value:d.key,onChange:g=>c(r.map((b,p)=>p===m?{...b,key:g.target.value}:b)),placeholder:"键",className:"h-8 w-28 text-sm"}),i.jsx(Dt,{value:d.value,onChange:g=>c(r.map((b,p)=>p===m?{...b,value:g.target.value}:b)),placeholder:"值",className:"h-8 flex-1 text-sm"}),i.jsx(he,{variant:"outline",type:"button",className:"h-8 px-2 text-xs",onClick:()=>c(r.filter((g,b)=>b!==m)),children:"删除"})]},m)),i.jsx(he,{variant:"outline",type:"button",className:"h-8 self-start px-2 text-xs",onClick:()=>c([...r,{key:"",value:""}]),children:"+ 添加字段"})]})}function lM({type:n,id:o}){const r=n,[l,c]=h.useState(null),[d,m]=h.useState(!1),[g,b]=h.useState(!1),[p,v]=h.useState(null),[x,S]=h.useState(null),[j,E]=h.useState(!1),[M,O]=h.useState(null),[N,T]=h.useState(!1),[k,C]=h.useState(null),[U,A]=h.useState(!1),[L,_]=h.useState(!1),K=qp(r);async function W(){m(!0),v(null),b(!1);try{const w=await pr(r,o);c(w),S(JSON.parse(JSON.stringify(w.data)))}catch(w){c(null),S(null),w instanceof ze&&w.code==="ENTITY_NOT_FOUND"?b(!0):v(w instanceof ze?w.code:ft)}finally{m(!1)}}h.useEffect(()=>{W()},[r,o]),Ds(()=>{W()});async function ue(){if(!l||!x||j)return;const w=$p(l.data,x);if(!w){ke.getState().showToast("没有变更");return}E(!0),O(null);try{await yr(r,o,{data:w}),ke.getState().showToast("已保存"),await W()}catch(D){if(D instanceof ze&&D.code==="ENTITY_NOT_FOUND"){b(!0);return}O(D instanceof ze?D.message:"保存失败,请重试")}finally{E(!1)}}function ne(w,D){S(H=>H&&{...H,[w]:D})}async function $(){if(l)try{const w=await Qc(r,o),D=[];w.cascaded.relations>0&&D.push(`${w.cascaded.relations} 条关联`),w.cascaded.deltas>0&&D.push(`${w.cascaded.deltas} 条变更记录`),ke.getState().showToast(`已移入回收站,可随时还原${D.length>0?`(含 ${D.join("、")})`:""}`),A(!1),Tn(`/entities/${r}`)}catch(w){throw w}}async function oe(){if(k)try{await Zc(k.id),ke.getState().showToast("已删除关系"),C(null),await W()}catch(w){throw w}}function q(w,D){return(D==="source"?w.sourceId:w.targetId)===o?l?.name??"本实体":(D==="source"?w.sourceName:w.targetName)??(D==="source"?w.sourceId:w.targetId)}return g?i.jsx("section",{children:i.jsxs("div",{className:"rounded-lg border border-dashed border-zinc-300 px-6 py-14 text-center",children:[i.jsx("p",{className:"text-sm text-zinc-600",children:"该实体不存在或已被删除"}),i.jsxs("div",{className:"mt-4 flex justify-center gap-2",children:[i.jsx("a",{href:"#/trash",className:"rounded-md border border-zinc-300 px-4 py-1.5 text-sm text-zinc-600 hover:bg-zinc-100",children:"去回收站"}),i.jsx(he,{variant:"outline",type:"button",onClick:()=>Tn(`/entities/${r}`),children:"返回列表"})]})]})}):i.jsxs("section",{children:[i.jsxs("div",{className:"mb-1 flex items-center gap-3",children:[i.jsx(Qp,{items:[{label:"实体",href:"/entities/character"},{label:oM[r],href:`/entities/${r}`},{label:l?.name??"…"}]}),i.jsx("h1",{className:"min-w-0 truncate text-xl font-semibold",children:l?.name??"…"}),i.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[i.jsx(he,{variant:"outline",type:"button",onClick:()=>{ue()},disabled:!l||j,children:j?"保存中…":"保存"}),i.jsx(he,{variant:"outline",type:"button",disabled:!l,className:"text-red-600 hover:bg-red-50",onClick:()=>A(!0),children:"移入回收站"})]})]}),l&&i.jsxs("p",{className:"mb-4 text-xs text-muted-foreground",children:["创建于 ",is(l.createdAt)," · 更新于 ",is(l.updatedAt)," ·"," ",i.jsxs("button",{type:"button",onClick:()=>_(w=>!w),title:"展开状态预览:计算该实体在任意大纲节点处的累积状态",className:"text-muted-foreground underline-offset-2 hover:text-primary hover:underline",children:["变更记录 ",l.deltaCount," 条"]})]}),l&&L&&i.jsx(nM,{type:r,id:o,currentData:l.data,deltaCount:l.deltaCount}),d&&!l&&i.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[i.jsx("div",{className:"space-y-3 rounded-md border border-zinc-200 p-4",children:Array.from({length:5},(w,D)=>i.jsx("div",{className:"h-9 animate-pulse rounded bg-zinc-100"},D))}),i.jsx("div",{className:"space-y-3 rounded-md border border-zinc-200 p-4",children:Array.from({length:3},(w,D)=>i.jsx("div",{className:"h-9 animate-pulse rounded bg-zinc-100"},D))})]}),!d&&!l&&p!==null&&i.jsxs("div",{className:"rounded-md border border-zinc-200 p-4 text-sm text-zinc-600",children:[p===ft?"无法连接服务,请确认 ai-editor 服务已启动。":"详情加载失败,请重试。",i.jsx(he,{variant:"outline",className:"ml-3",type:"button",onClick:()=>{W()},children:"重试"})]}),l&&x&&i.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[i.jsxs("div",{className:"rounded-md border border-zinc-200 p-4",children:[i.jsx("h2",{className:"mb-3 text-sm font-semibold text-zinc-700",children:"基础信息"}),i.jsxs("div",{className:"flex flex-col gap-3",children:[K.map(w=>i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-zinc-700",children:w.label}),i.jsx(iM,{field:w,value:x[w.key],onChange:D=>ne(w.key,D)})]},w.key)),"custom_fields"in l.data&&i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-zinc-700",children:"自定义字段"}),i.jsx(aM,{value:x.custom_fields,onChange:w=>ne("custom_fields",w)})]})]}),M&&i.jsx("p",{className:"mt-3 text-sm text-red-600",children:M})]}),i.jsxs("div",{className:"rounded-md border border-zinc-200 p-4",children:[i.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[i.jsx("h2",{className:"text-sm font-semibold text-zinc-700",children:"关联(1 跳)"}),i.jsx(he,{variant:"outline",type:"button",className:"h-8 px-2 text-xs",onClick:()=>T(!0),children:"+ 新增关联"})]}),l.relations.length===0?i.jsx("p",{className:"py-6 text-center text-sm text-zinc-400",children:"暂无关联,新增一个"}):i.jsx("ul",{className:"divide-y divide-zinc-100",children:l.relations.map(w=>{const D=w.sourceId===o,H=q(w,"source"),B=q(w,"target");return i.jsxs("li",{className:"flex items-center gap-2 py-2 text-sm",children:[i.jsx("span",{className:"min-w-0 max-w-28 truncate text-zinc-700",children:H}),i.jsxs("span",{className:"shrink-0 rounded bg-zinc-100 px-1.5 py-0.5 text-xs text-zinc-500",children:[gr(w.relationType)," ",D?"→":"←"]}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-zinc-700",children:B}),i.jsx(he,{variant:"outline",type:"button",className:"h-7 shrink-0 px-2 text-xs text-red-600 hover:bg-red-50",onClick:()=>C(w),children:"删除"})]},w.id)})})]})]}),N&&i.jsx(Xp,{source:{type:r,id:o,name:l?.name??""},onCreated:W,onClose:()=>T(!1)}),k&&i.jsx(ps,{title:"删除关系",description:`删除关系「${q(k,"source")} ${gr(k.relationType)} ${q(k,"target")}」?物理删除不可恢复,可重新建立。`,confirmLabel:"删除",danger:!0,onConfirm:oe,onClose:()=>C(null)}),U&&i.jsx(ps,{title:"移入回收站",description:`将《${l?.name??""}》移入回收站。关联关系与变更记录将一并移入,可在回收站还原。`,confirmLabel:"移入回收站",danger:!0,onConfirm:$,onClose:()=>A(!1)})]})}function iM({field:n,value:o,onChange:r}){switch(n.control){case"textarea":return i.jsx("textarea",{value:Cl({[n.key]:o},n.key),onChange:l=>r(l.target.value),rows:3,className:"w-full rounded-md border border-zinc-300 px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400"});case"number":return i.jsx(Dt,{type:"number",value:Cl({[n.key]:o},n.key),onChange:l=>r(l.target.value===""?void 0:Number(l.target.value)),className:"h-8 text-sm"});case"tags":return i.jsx(rM,{values:Array.isArray(o)?o:[],onChange:r,placeholder:"输入后回车添加下一项"});case"select":return i.jsx("select",{value:Cl({[n.key]:o},n.key),onChange:l=>r(l.target.value),className:"w-full rounded-md border border-zinc-300 bg-white px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400",children:n.options?.map(l=>i.jsx("option",{value:l,children:n.optionsLabels?.[l]??l},l))});case"toggle":return i.jsx("input",{type:"checkbox",checked:o===!0,onChange:l=>r(l.target.checked),className:"h-4 w-4 accent-zinc-900"});case"outline-node":return i.jsx(cM,{value:Cl({[n.key]:o},n.key),onChange:r});default:return i.jsx(Dt,{value:Cl({[n.key]:o},n.key),onChange:l=>r(l.target.value),className:"h-8 text-sm"})}}function cM({value:n,onChange:o}){const r=Be(c=>c.outline),l=ao(r?.children??[]);return i.jsxs("select",{value:n,onChange:c=>o(c.target.value===""?null:c.target.value),className:Ze("w-full rounded-md border border-zinc-300 bg-white px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400",n===""&&"text-zinc-400"),children:[i.jsx("option",{value:"",children:"未设置"}),l.map(c=>i.jsxs("option",{value:c.id,children:[" ".repeat(c.depth),c.label]},c.id))]})}function uM(n){return n==="resolved"?"resolved":n==="abandoned"?"abandoned":"active"}function dM(n){const o={active:[],resolved:[],abandoned:[]};for(const r of n)o[uM(r.summary.status)].push(r);return o}function Po(n,o){return n.filter(r=>r.relationType===o)}function TS(n,o){return Po(n,"depends_on").filter(r=>r.sourceId===o).map(r=>r.targetName??r.targetId)}function fM(n,o){return Po(n,"depends_on").filter(r=>r.targetId===o).map(r=>r.sourceName??r.sourceId)}function Uv(n,o){return fM(n,o).length}function mM(n,o){return Po(n,"involves").map(r=>r.sourceId===o?r.targetName??r.targetId:r.sourceName??r.sourceId)}const pM=3;function hM(n){const o=n.maxDepth??pM,r=[],l=new Set([n.startHookId]),c=[{hookId:n.startHookId,depth:0}];for(;c.length>0;){const{hookId:d,depth:m}=c.shift();if(r.push({hookId:d,name:n.names.get(d)??d,depth:m}),!(m>=o))for(const g of n.depsOf.get(d)??[])g.relationType!=="depends_on"||g.sourceId!==d||l.has(g.targetId)||(l.add(g.targetId),c.push({hookId:g.targetId,depth:m+1}))}return r}function wS(n,o){if(!n)return!1;const r=[...n.children];for(;r.length>0;){const l=r.pop();if(l.id===o)return l.deleted!==!0;l.type!=="scene"&&l.children&&r.push(...l.children)}return!1}function gM(n){if(!n)return null;let o=null;const r=l=>{if(l.deleted!==!0&&(o=l.id,l.type!=="scene"&&l.children))for(const c of l.children)r(c)};for(const l of n.children)r(l);return o}function xM(n,o){const r=n?.currentPosition;return r!=null&&r!==""&&wS(o,r)?r:gM(o)}const CS={advance:"progressing",resolve:"resolved",abandon:"abandoned"},bM={advance:"advances",resolve:"resolves"};function Hv(n){const o=n.status;return typeof o=="string"&&o!==""?o:"planted"}function RS(n,o){return{field:"status",op:"update",from:n,to:o}}function yM(n,o,r){return{source_type:"outline_node",source_id:r,target_type:"hook",target_id:o,relation_type:bM[n]}}function vM(n,o){return{source_type:"outline_node",source_id:o,target_type:"hook",target_id:n,relation_type:"plants"}}function OS(n){return{status:n}}async function SM(n){const o=CS[n.kind];await Wm({node_id:n.nodeId,target_type:"hook",target_id:n.hookId,changes:[RS(n.fromStatus,o)],description:n.description});try{await Sr(yM(n.kind,n.hookId,n.nodeId))}catch(r){if(!(r instanceof ze&&r.code==="RELATION_EXISTS"))throw r}await yr("hook",n.hookId,{data:OS(o)})}async function EM(n){await Wm({node_id:n.nodeId,target_type:"hook",target_id:n.hookId,changes:[RS(n.fromStatus,"abandoned")],description:n.description}),await yr("hook",n.hookId,{data:OS("abandoned")})}const am={advance:"推进",resolve:"回收",abandon:"废弃"};function NM(n){return n==="resolved"||n==="abandoned"}function Rl(n,o){const r=n[o];return r==null?"":String(r)}function jM(){const[n,o]=h.useState(null),[r,l]=h.useState(!1),[c,d]=h.useState(null),[m,g]=h.useState(0);Ds(()=>g(Ne=>Ne+1));const[b,p]=h.useState([]),[v,x]=h.useState(!1),[S,j]=h.useState(null),[E,M]=h.useState(!1),[O,N]=h.useState(null),[T,k]=h.useState(null),[C,U]=h.useState("advance"),[A,L]=h.useState(""),[_,K]=h.useState(""),[W,ue]=h.useState(null),[ne,$]=h.useState(!1),[oe,q]=h.useState(null),[w,D]=h.useState(null),[H,B]=h.useState(null),[P,z]=h.useState(!1),[X,I]=h.useState(null),[V,Q]=h.useState(!1),[Y,fe]=h.useState(""),[re,de]=h.useState({}),[_e,Ye]=h.useState(""),[Re,Le]=h.useState(null),[He,ge]=h.useState(!1),[pe,ve]=h.useState({}),Ue=Be(Ne=>Ne.config),ye=Be(Ne=>Ne.outline),De=ao(ye?.children??[]),Pe=n===null?null:dM(n);h.useEffect(()=>{let Ne=!1;return l(!0),d(null),x(!1),ve({}),ls("hook",{}).then(Me=>{Ne||o(Me.items)}).catch(Me=>{Ne||(o(null),d(Me instanceof ze?Me.code:ft))}),vr({source_type:"hook",relation_type:"depends_on",depth:1}).then(Me=>{Ne||p(Me.relations)}).catch(()=>{Ne||x(!0)}).finally(()=>{Ne||l(!1)}),()=>{Ne=!0}},[m]),h.useEffect(()=>{Be.getState().outline===null&&Be.getState().config!==null&&Be.getState().loadOutline()},[]);async function Ie(Ne){j(null),M(!0),N(null);try{j(await pr("hook",Ne.id))}catch(Me){N(Me instanceof ze?Me.message:"详情加载失败,请重试")}finally{M(!1)}}async function we(Ne,Me){k(null),ue(null),K("");try{const Je=await pr("hook",Me.id),nt=Be.getState().config?.currentPosition,jt=nt!=null&&nt!==""&&wS(ye,nt)?nt:"";L(jt),U(Ne),k(Je)}catch{ke.getState().showToast("无法读取伏笔状态,请重试","error")}}async function ee(){const Ne=T;if(!Ne||ne)return;const Me=C;$(!0),ue(null);try{if(Me==="abandon"){const Je=xM(Ue,ye);if(Je===null){ue("大纲为空,无法记录废弃变更");return}await EM({hookId:Ne.id,fromStatus:Hv(Ne.data),nodeId:Je,description:_.trim()})}else{if(A===""){ue("请选择大纲节点");return}await SM({kind:Me,hookId:Ne.id,fromStatus:Hv(Ne.data),nodeId:A,description:_.trim()})}ke.getState().showToast(`已${am[Me]}`),k(null),g(Je=>Je+1)}catch(Je){ue(Je instanceof ze?Je.message:"操作失败,请重试")}finally{$(!1)}}async function F(Ne){q(null),B(null);try{const Me=await pr("hook",Ne.id);q(Me),D(JSON.parse(JSON.stringify(Me.data)))}catch{ke.getState().showToast("无法读取伏笔数据,请重试","error")}}async function ie(){if(!oe||!w||P)return;const Ne=$p(oe.data,w);if(!Ne){ke.getState().showToast("没有变更"),q(null);return}z(!0),B(null);try{await yr("hook",oe.id,{data:Ne}),ke.getState().showToast("已保存"),q(null),g(Me=>Me+1)}catch(Me){B(Me instanceof ze?Me.message:"保存失败,请重试")}finally{z(!1)}}async function Z(Ne){Ne.preventDefault();const Me=Y.trim();if(!Me){Le("请输入名称");return}ge(!0),Le(null);try{const Je=await Bc("hook",{name:Me,data:re});if(_e!=="")try{await Sr(vM(Je.id,_e))}catch(nt){ke.getState().showToast(`已创建伏笔《${Me}》,但埋点关联失败:${nt instanceof ze?nt.message:"未知错误"}`,"error"),Q(!1),g(jt=>jt+1);return}ke.getState().showToast(`已创建伏笔《${Me}》`),Q(!1),fe(""),de({}),Ye(""),g(nt=>nt+1)}catch(Je){Le(Je instanceof ze?Je.message:"创建失败,请重试")}finally{ge(!1)}}async function Ee(){const Ne=X;if(Ne)try{const Me=await Qc("hook",Ne.id),Je=[];Me.cascaded.relations>0&&Je.push(`${Me.cascaded.relations} 条关联`),Me.cascaded.deltas>0&&Je.push(`${Me.cascaded.deltas} 条变更记录`),ke.getState().showToast(`已移入回收站,可随时还原${Je.length>0?`(含 ${Je.join("、")})`:""}`),I(null),g(nt=>nt+1)}catch(Me){throw Me}}async function Xe(Ne){if(pe[Ne.id]){ve(Me=>{const Je={...Me};return delete Je[Ne.id],Je});return}ve(Me=>({...Me,[Ne.id]:{status:"loading",nodes:[]}}));try{const Me=new Map,Je=new Map,nt=[{id:Ne.id,depth:0}],jt=new Set;for(;nt.length>0;){const{id:gt,depth:ln}=nt.shift();if(jt.has(gt))continue;jt.add(gt);const Jt=await pr("hook",gt);Je.set(gt,Jt.name);const et=Po(Jt.relations,"depends_on").filter(je=>je.sourceId===gt);if(Me.set(gt,et),!(ln>=2))for(const je of et)Je.has(je.targetId)||Je.set(je.targetId,je.targetName??je.targetId),nt.push({id:je.targetId,depth:ln+1})}const kt=hM({startHookId:Ne.id,depsOf:Me,names:Je});ve(gt=>({...gt,[Ne.id]:{status:"ready",nodes:kt}}))}catch{ve(Me=>({...Me,[Ne.id]:{status:"error",nodes:[]}}))}}return i.jsxs("section",{children:[i.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[i.jsx("h1",{className:"text-xl font-semibold",children:"伏笔池"}),i.jsx(he,{type:"button",className:"ml-auto",onClick:()=>Q(!0),children:"+ 新建伏笔"})]}),c!==null&&i.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[c===ft?"无法连接服务,请确认 ai-editor 服务已启动。":"伏笔池加载失败,请重试。",i.jsx(he,{variant:"outline",className:"ml-auto h-7 px-2 text-xs",type:"button",onClick:()=>g(Ne=>Ne+1),children:"重试"})]}),r&&Pe===null&&c===null&&i.jsx("div",{className:"space-y-4",children:Array.from({length:3},(Ne,Me)=>i.jsxs("div",{className:"rounded-md border border-border",children:[i.jsx("div",{className:"h-4 w-20 animate-pulse rounded bg-muted px-3 py-1.5"}),Array.from({length:Me===0?3:1},(Je,nt)=>i.jsxs("div",{className:"flex items-center gap-3 border-t border-border/70 px-3 py-2.5",children:[i.jsx("div",{className:"h-4 w-1/3 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-3 w-16 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"ml-auto h-6 w-6 animate-pulse rounded bg-muted"})]},nt))]},Me))}),!r&&Pe!==null&&n?.length===0&&i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-12 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"还没有伏笔。好伏笔要趁早埋下——先新建一个,或在聊天里让 AI 帮你规划。"}),i.jsx(he,{className:"mt-4",type:"button",onClick:()=>Q(!0),children:"+ 新建伏笔"})]}),Pe!==null&&n&&n.length>0&&i.jsxs("div",{className:"space-y-4",children:[i.jsx(lm,{title:"活跃",icon:i.jsx("span",{className:"size-2 shrink-0 rounded-full bg-primary"}),hooks:Pe.active,depEdges:b,depEdgesFailed:v,chains:pe,onToggleChain:Xe,onDetail:Ie,onLifecycle:we,onEdit:F,onDelete:I}),i.jsx(lm,{title:"已回收",icon:i.jsx(Ym,{className:"size-3.5 shrink-0 text-primary"}),hooks:Pe.resolved,depEdges:b,depEdgesFailed:v,chains:pe,onToggleChain:Xe,onDetail:Ie,onLifecycle:we,onEdit:F,onDelete:I}),i.jsx(lm,{title:"已废弃",icon:i.jsx(Oj,{className:"size-3.5 shrink-0 text-muted-foreground"}),hooks:Pe.abandoned,depEdges:b,depEdgesFailed:v,chains:pe,onToggleChain:Xe,onDetail:Ie,onLifecycle:we,onEdit:F,onDelete:I})]}),i.jsx(ws,{open:V,onOpenChange:Ne=>!Ne&&Q(!1),children:i.jsxs(Cs,{className:"sm:max-w-md",children:[i.jsx(Rs,{children:i.jsx(ks,{children:"新建伏笔"})}),i.jsxs("form",{id:"create-hook-form",onSubmit:Z,className:"flex flex-col gap-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"名称(必填)"}),i.jsx(Dt,{value:Y,onChange:Ne=>fe(Ne.target.value),placeholder:"如:身世之谜",maxLength:100})]}),i.jsx(Pv,{fields:wM,data:re,onChange:de,nodeOptions:De}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"埋点节点(选填,可空)"}),i.jsx(Dm,{value:_e,onChange:Ye,nodeOptions:De})]}),Re&&i.jsx("p",{className:"text-sm text-destructive",children:Re})]}),i.jsxs(Os,{children:[i.jsx(he,{variant:"outline",type:"button",onClick:()=>Q(!1),disabled:He,children:"取消"}),i.jsx(he,{type:"submit",form:"create-hook-form",disabled:He,children:"创建"})]})]})}),i.jsx(ws,{open:S!==null||E,onOpenChange:Ne=>!Ne&&j(null),children:i.jsxs(Cs,{className:"sm:max-w-lg",children:[i.jsx(Rs,{children:i.jsx(ks,{children:"伏笔详情"})}),E&&i.jsx("p",{className:"py-4 text-sm text-muted-foreground",children:"加载中…"}),O&&i.jsx("p",{className:"py-4 text-sm text-destructive",children:O}),S&&i.jsx(TM,{detail:S}),i.jsx(Os,{children:i.jsx(he,{variant:"outline",type:"button",onClick:()=>j(null),children:"关闭"})})]})}),T&&i.jsx(ws,{open:!0,onOpenChange:Ne=>!Ne&&!ne&&k(null),children:i.jsxs(Cs,{className:"sm:max-w-md",children:[i.jsx(Rs,{children:i.jsxs(ks,{children:[am[C],"伏笔《",T.name,"》"]})}),i.jsxs("div",{className:"flex flex-col gap-3",children:[C!=="abandon"&&i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"大纲节点(默认当前位置)"}),i.jsx(Dm,{value:A,onChange:L,nodeOptions:De,placeholder:"请选择节点"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"描述"}),i.jsx("textarea",{value:_,onChange:Ne=>K(Ne.target.value),rows:2,placeholder:C==="abandon"?"说明废弃原因":"说明伏笔如何被推进/回收",className:"w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50"})]}),i.jsxs("div",{className:"rounded-md border border-primary/25 bg-primary/5 px-3 py-2 text-sm",children:[i.jsx("p",{className:"font-medium text-foreground",children:"将写入:"}),i.jsxs("p",{className:"mt-1 text-muted-foreground",children:["status → ",CS[C],C==="advance"&&" + advances 关系",C==="resolve"&&" + resolves 关系"," + 同步 status"]}),C==="resolve"&&v&&i.jsx("p",{className:"mt-2 text-sm text-destructive",children:"依赖关系加载失败,无法确认依赖者"}),C==="resolve"&&!v&&Uv(b,T.id)>0&&i.jsxs("p",{className:"mt-2 text-sm text-destructive",children:["有 ",Uv(b,T.id)," 个伏笔依赖此伏笔"]})]}),W&&i.jsx("p",{className:"text-sm text-destructive",children:W})]}),i.jsxs(Os,{children:[i.jsx(he,{variant:"outline",type:"button",onClick:()=>k(null),disabled:ne,children:"取消"}),i.jsx(he,{type:"button",onClick:()=>{ee()},disabled:ne,children:ne?"提交中…":`确认${am[C]}`})]})]})}),oe&&w&&i.jsx(ws,{open:!0,onOpenChange:Ne=>!Ne&&!P&&q(null),children:i.jsxs(Cs,{className:"sm:max-w-md",children:[i.jsx(Rs,{children:i.jsxs(ks,{children:["编辑伏笔《",oe.name,"》"]})}),i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsx(Pv,{fields:qp("hook"),data:w,onChange:Ne=>D(Me=>Me&&{...Me,...Ne}),nodeOptions:De}),H&&i.jsx("p",{className:"text-sm text-destructive",children:H})]}),i.jsxs(Os,{children:[i.jsx(he,{variant:"outline",type:"button",onClick:()=>q(null),disabled:P,children:"取消"}),i.jsx(he,{type:"button",onClick:()=>{ie()},disabled:P,children:P?"保存中…":"保存"})]})]})}),X&&i.jsx(ps,{title:"移入回收站",description:`将《${X.name}》移入回收站。关联关系与变更记录将一并移入,可在回收站还原。`,confirmLabel:"移入回收站",danger:!0,onConfirm:Ee,onClose:()=>I(null)})]})}function lm({title:n,icon:o,hooks:r,depEdges:l,depEdgesFailed:c,chains:d,onToggleChain:m,onDetail:g,onLifecycle:b,onEdit:p,onDelete:v}){return i.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[i.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-muted/30 px-3 py-1.5 text-sm font-medium text-foreground",children:[o,i.jsx("span",{children:n}),i.jsxs("span",{className:"text-muted-foreground",children:["(",r.length,")"]})]}),r.length===0?i.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground/70",children:"(空)"}):i.jsx("ul",{className:"divide-y divide-border/70",children:r.map(x=>{const S=NM(x.summary.status),j=c?[]:TS(l,x.id),E=d[x.id],M=typeof x.summary.category=="string"?x.summary.category:"";return i.jsxs("li",{className:"px-3 py-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",title:x.name,children:x.name}),M&&i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:M}),i.jsx("span",{className:"ml-auto shrink-0",children:i.jsxs(gu,{children:[i.jsx(xu,{render:i.jsx(he,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground","aria-label":`${x.name} 操作`,children:i.jsx(Vm,{})})}),i.jsxs(bu,{align:"end",children:[i.jsx(fs,{onClick:()=>g(x),children:"详情"}),i.jsx(fs,{disabled:S,onClick:()=>b("advance",x),children:"推进"}),i.jsx(fs,{disabled:S,onClick:()=>b("resolve",x),children:"回收"}),i.jsx(fs,{disabled:S,onClick:()=>b("abandon",x),children:"废弃"}),i.jsx(fs,{onClick:()=>p(x),children:"编辑"}),i.jsx(Hp,{}),i.jsx(fs,{variant:"destructive",onClick:()=>v(x),children:"移入回收站"})]})]})})]}),j.length>0&&i.jsxs("button",{type:"button",onClick:()=>m(x),className:"mt-0.5 flex items-center gap-1 text-xs text-muted-foreground underline-offset-2 hover:text-primary hover:underline",children:["依赖: ",j.join("、")]}),E?.status==="loading"&&i.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"依赖链展开中…"}),E?.status==="error"&&i.jsx("p",{className:"mt-0.5 text-xs text-destructive",children:"依赖链加载失败"}),E?.status==="ready"&&E.nodes.length>1&&i.jsx("ul",{className:"mt-1 space-y-0.5 border-l border-border pl-2",children:E.nodes.slice(1).map(O=>i.jsxs("li",{className:"text-xs text-muted-foreground",children:[" ".repeat(O.depth-1),O.name]},`${O.depth}-${O.hookId}`))})]},x.id)})})]})}function TM({detail:n}){const o=n.id,r=typeof n.data.status=="string"?n.data.status:"",l=typeof n.data.category=="string"?n.data.category:"",c=Po(n.relations,"plants"),d=Po(n.relations,"advances"),m=Po(n.relations,"resolves"),g=TS(n.relations,o),b=Po(n.relations,"depends_on").filter(x=>x.targetId===o).map(x=>x.sourceName??x.sourceId),p=mM(n.relations,o),v=typeof n.data.expected_resolve_node_id=="string"?n.data.expected_resolve_node_id:"";return i.jsxs("div",{className:"flex flex-col gap-3 text-sm",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium text-foreground",children:n.name}),l&&i.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:l}),r&&i.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:Fp[r]??r})]}),i.jsxs("p",{className:"text-xs text-muted-foreground",children:["创建于 ",is(n.createdAt)," · 更新于 ",is(n.updatedAt)]}),i.jsx(mr,{title:"埋点节点(plants)",items:c.map(x=>x.sourceName??x.sourceId)}),i.jsx(mr,{title:"推进节点(advances)",items:d.map(x=>x.sourceName??x.sourceId)}),i.jsx(mr,{title:"回收节点(resolves)",items:m.map(x=>x.sourceName??x.sourceId)}),i.jsx(mr,{title:"预计回收节点",items:v?[v]:[]}),i.jsx(mr,{title:"依赖(depends_on)",items:g}),i.jsx(mr,{title:"被依赖(其他伏笔依赖本伏笔)",items:b}),i.jsx(mr,{title:"涉及(involves)",items:p})]})}function mr({title:n,items:o}){return i.jsxs("div",{children:[i.jsx("p",{className:"mb-0.5 text-xs font-medium text-muted-foreground",children:n}),o.length===0?i.jsx("p",{className:"text-xs text-muted-foreground/70",children:"无"}):i.jsx("ul",{className:"flex flex-wrap gap-1",children:o.map((r,l)=>i.jsx("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:r},`${r}-${l}`))})]})}const wM=[{key:"category",label:"类别",control:"text"},{key:"expected_payoff",label:"预期回收",control:"textarea"},{key:"payoff_timing",label:"回收时机",control:"select",options:["immediate","near_term","mid_arc","slow_burn","endgame"],optionsLabels:Gp},{key:"half_life",label:"半衰期(章数)",control:"number"},{key:"is_core",label:"主线伏笔",control:"toggle"},{key:"notes",label:"备注",control:"textarea"},{key:"expected_resolve_node_id",label:"预计回收节点",control:"outline-node"}];function Pv({fields:n,data:o,onChange:r,nodeOptions:l}){return i.jsx(i.Fragment,{children:n.map(c=>i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:c.label}),i.jsx(CM,{field:c,value:o[c.key],nodeOptions:l,onValue:d=>r({...o,[c.key]:d})})]},c.key))})}function CM({field:n,value:o,nodeOptions:r,onValue:l}){switch(n.control){case"textarea":return i.jsx("textarea",{value:Rl({[n.key]:o},n.key),onChange:c=>l(c.target.value),rows:2,className:"w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50"});case"number":return i.jsx(Dt,{type:"number",value:Rl({[n.key]:o},n.key),onChange:c=>l(c.target.value===""?void 0:Number(c.target.value)),className:"h-8 text-sm"});case"select":return i.jsxs("select",{value:Rl({[n.key]:o},n.key),onChange:c=>l(c.target.value),className:"w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",children:[i.jsx("option",{value:"",children:"未设置"}),n.options?.map(c=>i.jsx("option",{value:c,children:n.optionsLabels?.[c]??c},c))]});case"toggle":return i.jsx("input",{type:"checkbox",checked:o===!0,onChange:c=>l(c.target.checked),className:"h-4 w-4 accent-primary"});case"outline-node":return i.jsx(Dm,{value:Rl({[n.key]:o},n.key),onChange:l,nodeOptions:r});default:return i.jsx(Dt,{value:Rl({[n.key]:o},n.key),onChange:c=>l(c.target.value),placeholder:n.key==="category"?`如:${ij.join(" / ")}`:void 0,className:"h-8 text-sm"})}}function Dm({value:n,onChange:o,nodeOptions:r,placeholder:l="未设置"}){return i.jsxs("select",{value:n,onChange:c=>o(c.target.value),className:Ze("w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",n===""&&"text-muted-foreground"),children:[i.jsx("option",{value:"",children:l}),r.map(c=>i.jsxs("option",{value:c.id,children:[" ".repeat(c.depth),c.label]},c.id))]})}function zm(n,o,r){const l=r===void 0?n:n.filter(d=>d!==r);if(o.kind==="end")return l.length;const c=l.indexOf(o.id);return c===-1?l.length:o.kind==="before"?c:c+1}function Yv(n,o,r){const l=n.map(g=>({timepoint:g,events:[]})),c=new Map(l.map(g=>[g.timepoint.id,g])),d=new Map;for(const g of r)g.relationType!=="occurs_at"||g.sourceType!=="timepoint"||d.has(g.targetId)||d.set(g.targetId,g.sourceId);const m=[];for(const g of o){const b=d.get(g.id),p=b===void 0?void 0:c.get(b);p===void 0?m.push(g):p.events.push(g)}return{groups:l,ungrouped:m}}function RM(n,o,r,l,c){const d=[...n.flatMap(b=>b.events.map(p=>p.id)),...o.map(b=>b.id)];let m;if(r===-1)m=l==="before"?o[0]:o[o.length-1];else{const b=n[r];if(b!==void 0){if(l==="before"){if(m=b.events[0],m===void 0)for(let p=r+1;p<n.length;p++){const v=n[p].events[0];if(v!==void 0){m=v;break}}}else if(m=b.events[b.events.length-1],m===void 0)for(let p=r-1;p>=0;p--){const v=n[p].events[n[p].events.length-1];if(v!==void 0){m=v;break}}}}if(m!==void 0)return zm(d,{kind:l,id:m.id},c);const g=d.find(b=>b!==c);return g===void 0?0:zm(d,{kind:"before",id:g},c)}function Zp(n){const o=n.summary.tags;return Array.isArray(o)?o.filter(r=>typeof r=="string"):[]}function OM(n){const o=n.summary.description;return typeof o=="string"?o:""}function Lm(n,o,r=5){const l=n.split(/[,,、\n]/),c=l[l.length-1].trim();if(c==="")return[];const d=new Set(l.slice(0,-1).map(p=>p.trim()).filter(p=>p!=="")),m=c.toLowerCase(),g=[],b=new Set;for(const p of o){if(g.length>=r)break;d.has(p)||b.has(p)||p.toLowerCase().includes(m)&&(b.add(p),g.push(p))}return g}function Im(n,o){const r=n.split(/[,,、\n]/);return r[r.length-1]=o,r.join(",")+","}function zc(n){const o=new Set,r=[];for(const l of n)for(const c of Zp(l))c!==""&&!o.has(c)&&(o.add(c),r.push(c));return r}function kM(n,o){return o===null||o===""?n:n.filter(r=>Zp(r).includes(o))}function kS(n){const o=[],r=new Set;for(const l of n.split(/[,,、\n]/)){const c=l.trim();c!==""&&!r.has(c)&&(r.add(c),o.push(c))}return o}function _S(n){return Array.isArray(n)?n.filter(o=>typeof o=="string").join(","):""}function _M(n){const o=n.data;return{name:n.name,description:typeof o.description=="string"?o.description:"",tagsInput:_S(o.tags)}}function MS(n,o){const r={};o.name.trim()!==n.name&&(r.name=o.name.trim());const l={};(o.description.trim()!==""||n.data.description!==void 0)&&(l.description=o.description.trim());const c=kS(o.tagsInput);(c.length>0||n.data.tags!==void 0)&&(l.tags=c);const d={};for(const m of["description","tags"])JSON.stringify(l[m])!==JSON.stringify(n.data[m])&&(d[m]=l[m]);return Object.keys(d).length>0&&(r.data=d),r.name===void 0&&r.data===void 0?null:r}const AS="occurs_in",DS="occurs_at";function MM(n,o){return n.filter(r=>r.relationType===AS&&r.sourceId===o)}function AM(n,o){return{source_type:"event",source_id:n,target_type:"outline_node",target_id:o,relation_type:AS}}function im(n,o){const r=n.find(l=>l.relationType===DS&&l.sourceType==="timepoint"&&l.targetId===o);return r===void 0?null:r.sourceId}function DM(n,o){return{source_type:"timepoint",source_id:n,target_type:"event",target_id:o,relation_type:DS}}function zM({ev:n,occursCount:o,hasOccursData:r,dragging:l,busy:c,showInsertBefore:d,showInsertAfter:m,eventDrag:g,onDetail:b,onEdit:p,onDelete:v}){const x=Zp(n),S=OM(n),j=o(n.id),[E,M]=h.useState(!1),O=h.useRef(null),[N,T]=h.useState(!1);return h.useLayoutEffect(()=>{const k=O.current;if(k===null)return;const C=()=>{E||T(k.scrollHeight>k.clientHeight+1)};return C(),window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)},[S,E]),i.jsxs("div",{draggable:!c,onDragStart:k=>g.onDragStart(k,n),onDragEnd:g.onDragEnd,onDragOver:k=>g.onDragOver(k,n),onDrop:k=>g.onDrop(k,n),className:Ze("relative flex items-start",l&&"opacity-50"),children:[d&&i.jsx("div",{className:"absolute inset-x-0 -top-px h-0.5 bg-primary"}),m&&i.jsx("div",{className:"absolute inset-x-0 -bottom-px h-0.5 bg-primary"}),i.jsx("div",{className:"w-[22px] shrink-0",children:i.jsx("span",{"aria-hidden":"true",className:"mx-auto mt-[16px] block size-2 rounded-full bg-primary/60"})}),i.jsxs("div",{className:"min-w-0 flex-1 rounded-md border border-border bg-card px-3 py-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"shrink-0 cursor-grab text-muted-foreground/60 active:cursor-grabbing",title:"拖拽调整事件顺序/挂载","aria-hidden":"true",children:i.jsx(Fm,{className:"size-4"})}),i.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",title:n.name,children:n.name}),x.map(k=>i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:k},k)),r&&i.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[j," 节点"]}),i.jsx("span",{className:"ml-auto shrink-0",children:i.jsxs(gu,{children:[i.jsx(xu,{render:i.jsx(he,{variant:"ghost",size:"icon-sm",draggable:!1,className:"text-muted-foreground","aria-label":`${n.name} 操作`,children:i.jsx(Vm,{})})}),i.jsxs(bu,{align:"end",children:[i.jsx(fs,{onClick:()=>b(n),children:"详情"}),i.jsx(fs,{onClick:()=>p(n),children:"编辑"}),i.jsx(Hp,{}),i.jsx(fs,{variant:"destructive",onClick:()=>v(n),children:"移入回收站"})]})]})})]}),S.trim()!==""&&i.jsxs("div",{className:"mt-1.5",children:[i.jsx("p",{ref:O,className:Ze("text-sm leading-relaxed text-muted-foreground",!E&&"line-clamp-2"),children:S}),(E||N)&&i.jsx("button",{type:"button",draggable:!1,onClick:()=>M(k=>!k),className:"mt-1 text-xs text-primary hover:underline","aria-expanded":E,children:E?"收起":"展开"})]})]})]})}function LM({timepoint:n,groupId:o,events:r,collapsed:l,dragSource:c,busy:d,occursCount:m,hasOccursData:g,showInsertBefore:b,showInsertAfter:p,onToggleCollapse:v,onRename:x,onAddEventAt:S,onDragStart:j,onDragEnd:E,onDragOver:M,onDrop:O,eventDrag:N,eventInsertLines:T,onDetail:k,onEdit:C,onDelete:U}){const[A,L]=h.useState(!1),[_,K]=h.useState(""),W=n===null,ue=W?"未挂载":n.name,ne=c!==null&&c.kind==="timepoint"&&c.id===o;function $(){n!==null&&(K(n.name),L(!0))}async function oe(){if(n===null)return;const q=_.trim();L(!1),!(q===""||q===n.name)&&await x(n.id,q)}return i.jsxs("div",{className:"relative flex flex-col gap-2",children:[b&&i.jsx("div",{className:"absolute inset-x-0 -top-px h-0.5 bg-primary"}),p&&i.jsx("div",{className:"absolute inset-x-0 -bottom-px h-0.5 bg-primary"}),i.jsxs("div",{draggable:!W&&!d&&!A,onDragStart:j,onDragEnd:E,onDragOver:M,onDrop:O,className:Ze("flex items-start",!W&&ne&&"opacity-50"),children:[i.jsx("div",{className:"w-[22px] shrink-0",children:i.jsx("span",{"aria-hidden":"true",className:Ze("relative z-10 mx-auto mt-[6px] block size-4 rounded-full border-2 bg-background",W?"border-dashed border-border":"border-primary")})}),i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 py-1",children:[!W&&i.jsx("span",{className:"shrink-0 cursor-grab text-muted-foreground/60 active:cursor-grabbing",title:"拖拽调整时间点顺序(组内事件不动)","aria-hidden":"true",children:i.jsx(Fm,{className:"size-4"})}),A?i.jsx("input",{autoFocus:!0,value:_,onChange:q=>K(q.target.value),onKeyDown:q=>{q.key==="Enter"?oe():q.key==="Escape"&&L(!1)},onBlur:()=>L(!1),maxLength:100,"aria-label":"时间点名称",className:"w-40 rounded-md border border-border bg-background px-2 py-0.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50"}):i.jsx("span",{className:Ze("min-w-0 truncate text-sm font-medium",W?"italic text-muted-foreground":"text-foreground"),title:ue,children:ue}),i.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[r.length," 个事件"]}),!W&&!A&&i.jsx(he,{type:"button",variant:"ghost",size:"sm",draggable:!1,className:"h-6 px-1.5 text-xs text-muted-foreground",onClick:$,children:"重命名"}),i.jsx("span",{className:"ml-auto shrink-0",children:i.jsx(he,{type:"button",variant:"ghost",size:"icon-sm",draggable:!1,className:"text-muted-foreground","aria-expanded":!l,"aria-label":`${l?"展开":"折叠"}「${ue}」组`,onClick:v,children:i.jsx(Hm,{className:Ze("size-4 transition-transform duration-200",!l&&"rotate-90")})})})]})]}),!l&&i.jsxs("div",{className:"flex flex-col gap-2",children:[r.map(q=>{const w=T(q.id);return i.jsx(zM,{ev:q,occursCount:m,hasOccursData:g,dragging:c!==null&&c.kind==="event"&&c.id===q.id,busy:d,showInsertBefore:w.before,showInsertAfter:w.after,eventDrag:N,onDetail:k,onEdit:C,onDelete:U},q.id)}),!W&&i.jsx("button",{type:"button",draggable:!1,onClick:()=>S(o),className:"ml-[22px] w-fit rounded-md px-3 py-1 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"+ 在此时间点新建事件"})]})]})}function IM({timepoints:n,events:o,allEvents:r,occursAtEdges:l,occursCount:c,hasOccursData:d,onMoveTimepoint:m,onMoveEvent:g,onMoveEventTo:b,onRenameTimepoint:p,onAddEventAt:v,onDetail:x,onEdit:S,onDelete:j}){const E=h.useMemo(()=>Yv(n,o,l),[n,o,l]),M=h.useMemo(()=>Yv(n,r,l),[n,r,l]),O=h.useMemo(()=>[...E.groups.map(I=>({timepoint:I.timepoint,groupId:I.timepoint.id,events:I.events})),...E.ungrouped.length>0?[{timepoint:null,groupId:"",events:E.ungrouped}]:[]],[E]),N=h.useMemo(()=>{const I=new Map;for(const V of E.groups)for(const Q of V.events)I.set(Q.id,V.timepoint.id);for(const V of E.ungrouped)I.set(V.id,"");return I},[E]),T=h.useMemo(()=>n.map(I=>I.id),[n]),[k,C]=h.useState(new Set),[U,A]=h.useState(null),[L,_]=h.useState(null),[K,W]=h.useState(!1);function ue(I){const V=I.currentTarget.getBoundingClientRect();return I.clientY<V.top+V.height/2?"before":"after"}function ne(I){return I===""?-1:M.groups.findIndex(V=>V.timepoint.id===I)}function $(I,V,Q){I.preventDefault(),I.dataTransfer.dropEffect="move";const Y=ue(I);_(fe=>fe!==null&&fe.kind==="event"&&fe.at===Q.at&&fe.side===Y&&fe.groupId===V&&fe.anchorId===Q.anchorId?fe:{kind:"event",at:Q.at,side:Y,groupId:V,anchorId:Q.anchorId})}function oe(I,V){V.timepoint!==null&&(I.dataTransfer.setData("text/plain",V.timepoint.id),I.dataTransfer.effectAllowed="move",A({kind:"timepoint",id:V.timepoint.id}),_(null))}function q(I,V){I.dataTransfer.setData("text/plain",V.id),I.dataTransfer.effectAllowed="move",A({kind:"event",id:V.id}),_(null)}function w(){A(null),_(null)}function D(I,V){const Q=U;if(Q===null||Q.kind==="timepoint"&&V.timepoint===null)return;I.preventDefault(),I.dataTransfer.dropEffect="move";const Y=ue(I);if(Q.kind==="timepoint"){_(re=>re!==null&&re.kind==="timepoint"&&re.side===Y&&re.groupId===V.groupId?re:{kind:"timepoint",side:Y,groupId:V.groupId});return}const fe=V.events.length===0?null:Y==="before"?V.events[0].id:V.events[V.events.length-1].id;$(I,V.groupId,{at:"group",anchorId:fe})}function H(I,V,Q){const Y=U;if(Y!==null&&!(Y.kind==="timepoint"&&Q.timepoint===null)){if(I.preventDefault(),I.dataTransfer.dropEffect="move",Y.kind==="timepoint"){const fe=ue(I);_(re=>re!==null&&re.kind==="timepoint"&&re.side===fe&&re.groupId===Q.groupId?re:{kind:"timepoint",side:fe,groupId:Q.groupId});return}$(I,Q.groupId,{at:"row",anchorId:V.id})}}async function B(I,V,Q){const Y=U;if(Y===null||Y.kind!=="event"||K)return;if(I.preventDefault(),Q===Y.id){w();return}const fe=ue(I),re=RM(M.groups,M.ungrouped,ne(V.groupId),fe,Y.id),de=N.get(Y.id)??"";W(!0);try{V.groupId===de?await g(Y.id,re):await b(Y.id,V.groupId===""?null:V.groupId,re)}finally{W(!1),w()}}function P(I,V){const Q=U;if(Q===null||K)return;if(I.preventDefault(),Q.kind==="timepoint"){if(V.timepoint===null)return;if(V.groupId===Q.id){w();return}const re=ue(I),de=zm(T,{kind:re,id:V.groupId},Q.id);W(!0),m(Q.id,de).finally(()=>{W(!1),w()});return}const Y=ue(I),fe=V.events.length===0?null:Y==="before"?V.events[0].id:V.events[V.events.length-1].id;B(I,V,fe)}function z(I,V,Q){const Y=U;if(Y!==null&&Y.kind==="timepoint"){P(I,Q);return}B(I,Q,V.id)}function X(I){C(V=>{const Q=new Set(V);return Q.has(I)?Q.delete(I):Q.add(I),Q})}return i.jsxs("div",{className:"relative flex flex-col gap-2",children:[i.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0 left-[11px] top-0 w-0.5 bg-border"}),O.map(I=>{const V=L!==null&&(L.kind==="timepoint"&&L.groupId===I.groupId||L.kind==="event"&&L.at==="group"&&L.groupId===I.groupId),Q=V&&L!==null&&L.side==="before",Y=V&&L!==null&&L.side==="after",fe=L!==null&&L.kind==="event"&&L.at==="row"&&L.side==="before",re=L!==null&&L.kind==="event"&&L.at==="row"&&L.side==="after",de={onDragStart:q,onDragEnd:w,onDragOver:(_e,Ye)=>H(_e,Ye,I),onDrop:(_e,Ye)=>z(_e,Ye,I)};return i.jsx(LM,{timepoint:I.timepoint,groupId:I.groupId,events:I.events,collapsed:k.has(I.groupId),dragSource:U,busy:K,occursCount:c,hasOccursData:d,showInsertBefore:Q,showInsertAfter:Y,onToggleCollapse:()=>X(I.groupId),onRename:p,onAddEventAt:v,onDragStart:_e=>oe(_e,I),onDragEnd:w,onDragOver:_e=>D(_e,I),onDrop:_e=>P(_e,I),eventDrag:de,eventInsertLines:_e=>({before:fe&&L!==null&&L.kind==="event"&&L.anchorId===_e,after:re&&L!==null&&L.kind==="event"&&L.anchorId===_e}),onDetail:x,onEdit:S,onDelete:j},I.groupId===""?"__ungrouped__":I.groupId)})]})}function Bm({suggestions:n,visible:o,onPick:r}){return!o||n.length===0?null:i.jsx("div",{className:"mt-1 overflow-hidden rounded-md border border-border bg-card",children:n.map(l=>i.jsx("button",{type:"button",onMouseDown:c=>c.preventDefault(),onClick:()=>r(l),className:"block w-full cursor-pointer px-2.5 py-1 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l},l))})}const Na={name:"",description:"",tagsInput:""};function BM(){const[n,o]=h.useState(null),[r,l]=h.useState(null),[c,d]=h.useState(!1),[m,g]=h.useState(null),[b,p]=h.useState(0);Ds(()=>p(je=>je+1));const[v,x]=h.useState([]),[S,j]=h.useState(!1),[E,M]=h.useState([]),[O,N]=h.useState(!1),[T,k]=h.useState(null),[C,U]=h.useState([]),[A,L]=h.useState(!1),[_,K]=h.useState(Na),[W,ue]=h.useState(null),[ne,$]=h.useState(""),[oe,q]=h.useState(null),[w,D]=h.useState(!1),[H,B]=h.useState(!1),[P,z]=h.useState(""),[X,I]=h.useState(null),[V,Q]=h.useState(!1),[Y,fe]=h.useState(null),[re,de]=h.useState(null),[_e,Ye]=h.useState(null),[Re,Le]=h.useState(!1),[He,ge]=h.useState(null),pe=Be(je=>je.config),ve=Be(je=>je.outline),Ue=ao(ve?.children??[]),ye=Nt(je=>je.sendMessage);h.useEffect(()=>{let je=!1;return d(!0),g(null),j(!1),N(!1),Promise.allSettled([ls("timepoint",{}).then(Ce=>{je||o(Ce.items)}).catch(Ce=>{je||(o(null),g(Ce instanceof ze?Ce.code:ft))}),ls("event",{}).then(Ce=>{je||(l(Ce.items),U(zc(Ce.items)),Ce.items.length>=Ce.limit&&ls("event",{limit:200}).then(qe=>{je||U(zc(qe.items))}).catch(()=>{}))}).catch(Ce=>{je||(l(null),g(Ce instanceof ze?Ce.code:ft))}),vr({source_type:"timepoint",relation_type:"occurs_at",depth:1}).then(Ce=>{je||x(Ce.relations)}).catch(()=>{je||j(!0)}),vr({source_type:"event",relation_type:"occurs_in",depth:1}).then(Ce=>{je||M(Ce.relations)}).catch(()=>{je||N(!0)})]).finally(()=>{je||d(!1)}),()=>{je=!0}},[b]),h.useEffect(()=>{Be.getState().outline===null&&Be.getState().config!==null&&Be.getState().loadOutline()},[]);async function De(je){je.preventDefault();const Ce=P.trim();if(!Ce){I("请输入名称");return}Q(!0),I(null);try{await Bc("timepoint",{name:Ce}),ke.getState().showToast(`已创建时间点《${Ce}》`),B(!1),z(""),p(qe=>qe+1)}catch(qe){I(qe instanceof ze?qe.message:"创建失败,请重试")}finally{Q(!1)}}async function Pe(je){je.preventDefault();const Ce=_.name.trim();if(!Ce){q("请输入名称");return}D(!0),q(null);try{const qe={};_.description.trim()!==""&&(qe.description=_.description.trim());const te=kS(_.tagsInput);te.length>0&&(qe.tags=te);const xe=await Bc("event",{name:Ce,data:qe});if(W!==null)try{await Sr(DM(W,xe.id))}catch(Oe){ke.getState().showToast(`已创建事件《${Ce}》,但挂载到时间点失败:${Oe instanceof ze?Oe.message:"未知错误"}`,"error"),L(!1),K(Na),ue(null),$(""),p(We=>We+1);return}if(ne!=="")try{await Sr({source_type:"event",source_id:xe.id,target_type:"outline_node",target_id:ne,relation_type:"occurs_in"})}catch(Oe){ke.getState().showToast(`已创建事件《${Ce}》,但节点关联失败:${Oe instanceof ze?Oe.message:"未知错误"}`,"error"),L(!1),K(Na),ue(null),$(""),p(We=>We+1);return}ke.getState().showToast(`已创建事件《${Ce}》`),L(!1),K(Na),ue(null),$(""),p(Oe=>Oe+1)}catch(qe){q(qe instanceof ze?qe.message:"创建失败,请重试")}finally{D(!1)}}function Ie(je){const Ce=je.summary;fe(je),Ye(null),de({name:je.name,description:typeof Ce.description=="string"?Ce.description:"",tagsInput:_S(Ce.tags)})}async function we(){const je=Y,Ce=re;if(!(!je||!Ce||Re)){Le(!0),Ye(null);try{const qe=MS({name:je.name,data:je.summary},Ce);if(qe===null){ke.getState().showToast("没有变更"),fe(null);return}await yr("event",je.id,qe),ke.getState().showToast("已保存"),fe(null),p(te=>te+1)}catch(qe){Ye(qe instanceof ze?qe.message:"保存失败,请重试")}finally{Le(!1)}}}async function ee(){const je=He;if(je)try{const Ce=await Qc("event",je.id),qe=[];Ce.cascaded.relations>0&&qe.push(`${Ce.cascaded.relations} 条关联`),Ce.cascaded.deltas>0&&qe.push(`${Ce.cascaded.deltas} 条变更记录`),ke.getState().showToast(`已移入回收站,可随时还原${qe.length>0?`(含 ${qe.join("、")})`:""}`),ge(null),p(te=>te+1)}catch(Ce){throw Ce}}async function F(je,Ce){try{await qw(je,{order:Ce}),ke.getState().showToast("已调整时间点顺序")}catch(qe){ke.getState().showToast(qe instanceof ze?`排序失败:${qe.message}`:"排序失败,请重试","error")}finally{p(qe=>qe+1)}}async function ie(je,Ce){try{await Gw(je,{order:Ce}),ke.getState().showToast("已调整事件顺序")}catch(qe){ke.getState().showToast(qe instanceof ze?`排序失败:${qe.message}`:"排序失败,请重试","error")}finally{p(qe=>qe+1)}}async function Z(je,Ce,qe){try{await E0(je,{timepoint_id:Ce,order:qe}),ke.getState().showToast(Ce===null?"已移至未挂载区":"已调整事件挂载与顺序")}catch(te){ke.getState().showToast(te instanceof ze?`操作失败:${te.message}`:"操作失败,请重试","error")}finally{p(te=>te+1)}}async function Ee(je,Ce){try{await yr("timepoint",je,{name:Ce}),ke.getState().showToast("已重命名"),p(qe=>qe+1)}catch(qe){ke.getState().showToast(qe instanceof ze?`重命名失败:${qe.message}`:"重命名失败,请重试","error")}}function Xe(je){K(Na),$(""),q(null),ue(je),L(!0)}function Ne(){K(Na),$(""),q(null),ue(null),L(!0)}function Me(){pe!==null&&ye("请按时间标签的语义先后顺序对时间轴时间点排序,并使用 propose_reorder_timepoints 工具生成排序提案。")}const Je=r===null?[]:zc(r),nt=r===null?null:kM(r,T),jt=je=>O?0:E.filter(Ce=>Ce.sourceId===je).length,kt=!O,gt=Lm(_.tagsInput,C),ln=re===null?[]:Lm(re.tagsInput,C);function Jt(je){K(Ce=>({...Ce,tagsInput:Im(Ce.tagsInput,je)}))}function et(je){de(Ce=>Ce&&{...Ce,tagsInput:Im(Ce.tagsInput,je)})}return i.jsxs("section",{className:"flex h-full min-h-0 flex-col",children:[i.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[i.jsx("h1",{className:"text-xl font-semibold",children:"时间轴"}),i.jsx("span",{className:Ze("ml-auto",!pe&&"cursor-not-allowed"),title:pe?void 0:"请先打开项目",children:i.jsxs(he,{type:"button",variant:"outline",size:"sm",disabled:!pe,onClick:Me,"aria-label":"AI 排序",children:[i.jsx(Hj,{className:"size-3.5"}),"AI 排序"]})}),i.jsx(he,{type:"button",variant:"outline",onClick:Ne,children:"+ 新建事件"}),i.jsx(he,{type:"button",onClick:()=>B(!0),children:"+ 新建时间点"})]}),r!==null&&r.length>0&&i.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-1.5",children:[i.jsx("button",{type:"button",onClick:()=>k(null),className:Ze("rounded-full px-2.5 py-0.5 text-xs transition-colors",T===null?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"),children:"全部"}),Je.map(je=>i.jsx("button",{type:"button",onClick:()=>k(Ce=>Ce===je?null:je),className:Ze("rounded-full px-2.5 py-0.5 text-xs transition-colors",T===je?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"),children:je},je))]}),i.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[m!==null&&i.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[m===ft?"无法连接服务,请确认 ai-editor 服务已启动。":"时间轴加载失败,请重试。",i.jsx(he,{variant:"outline",className:"ml-auto h-7 px-2 text-xs",type:"button",onClick:()=>p(je=>je+1),children:"重试"})]}),c&&(n===null||r===null)&&m===null&&i.jsx("div",{className:"space-y-2",children:Array.from({length:4},(je,Ce)=>i.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border px-3 py-2.5",children:[i.jsx("div",{className:"h-4 w-4 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-4 w-1/3 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-3 w-20 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"ml-auto h-6 w-6 animate-pulse rounded bg-muted"})]},Ce))}),!c&&n!==null&&r!==null&&n.length===0&&r.length===0&&i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-12 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"还没有时间点。先定义一个时间标签点(如「第二天黄昏」),再在其中挂载事件。"}),i.jsx(he,{className:"mt-4",type:"button",onClick:()=>B(!0),children:"+ 新建时间点"})]}),n!==null&&r!==null&&nt!==null&&!(T!==null&&nt.length===0)&&i.jsx(IM,{timepoints:n,events:nt,allEvents:r,occursAtEdges:S?[]:v,occursCount:jt,hasOccursData:kt,onMoveTimepoint:F,onMoveEvent:ie,onMoveEventTo:Z,onRenameTimepoint:Ee,onAddEventAt:Xe,onDetail:je=>Tn(`/timeline/${je.id}`),onEdit:Ie,onDelete:ge}),!c&&r!==null&&r.length>0&&nt!==null&&nt.length===0&&i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-8 text-center text-sm text-muted-foreground",children:["没有匹配「",T,"」的事件"]})]}),i.jsx(ws,{open:H,onOpenChange:je=>!je&&B(!1),children:i.jsxs(Cs,{className:"sm:max-w-md",children:[i.jsx(Rs,{children:i.jsx(ks,{children:"新建时间点"})}),i.jsxs("form",{id:"create-timepoint-form",onSubmit:De,className:"flex flex-col gap-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"名称(必填,时间标签文本)"}),i.jsx(Dt,{value:P,onChange:je=>z(je.target.value),placeholder:"如:第二天黄昏",maxLength:100,autoFocus:!0})]}),X&&i.jsx("p",{className:"text-sm text-destructive",children:X})]}),i.jsxs(Os,{children:[i.jsx(he,{variant:"outline",type:"button",onClick:()=>B(!1),disabled:V,children:"取消"}),i.jsx(he,{type:"submit",form:"create-timepoint-form",disabled:V,children:"创建"})]})]})}),i.jsx(ws,{open:A,onOpenChange:je=>!je&&L(!1),children:i.jsxs(Cs,{className:"sm:max-w-md",children:[i.jsx(Rs,{children:i.jsx(ks,{children:W!==null?"在此时间点新建事件(自动挂载)":"新建事件(不挂载,入未挂载区)"})}),i.jsxs("form",{id:"create-event-form",onSubmit:Pe,className:"flex flex-col gap-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"名称(必填)"}),i.jsx(Dt,{value:_.name,onChange:je=>K(Ce=>({...Ce,name:je.target.value})),placeholder:"如:主角踏入宗门",maxLength:100})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"描述"}),i.jsx("textarea",{value:_.description,onChange:je=>K(Ce=>({...Ce,description:je.target.value})),rows:2,placeholder:"事件发生了什么",className:"w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"标签"}),i.jsx(Dt,{value:_.tagsInput,onChange:je=>K(Ce=>({...Ce,tagsInput:je.target.value})),placeholder:"如:主线,战争(逗号/回车分隔)"}),i.jsx(Bm,{suggestions:gt,visible:_.tagsInput.trim()!=="",onPick:Jt})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"关联大纲节点(选填,可空)"}),i.jsx(UM,{value:ne,onChange:$,nodeOptions:Ue})]}),oe&&i.jsx("p",{className:"text-sm text-destructive",children:oe})]}),i.jsxs(Os,{children:[i.jsx(he,{variant:"outline",type:"button",onClick:()=>L(!1),disabled:w,children:"取消"}),i.jsx(he,{type:"submit",form:"create-event-form",disabled:w,children:"创建"})]})]})}),Y&&re&&i.jsx(ws,{open:!0,onOpenChange:je=>!je&&!Re&&fe(null),children:i.jsxs(Cs,{className:"sm:max-w-md",children:[i.jsx(Rs,{children:i.jsxs(ks,{children:["编辑事件《",Y.name,"》"]})}),i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"名称(必填)"}),i.jsx(Dt,{value:re.name,onChange:je=>de(Ce=>Ce&&{...Ce,name:je.target.value}),maxLength:100})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"描述"}),i.jsx("textarea",{value:re.description,onChange:je=>de(Ce=>Ce&&{...Ce,description:je.target.value}),rows:2,className:"w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"标签"}),i.jsx(Dt,{value:re.tagsInput,onChange:je=>de(Ce=>Ce&&{...Ce,tagsInput:je.target.value}),placeholder:"如:主线,战争(逗号/回车分隔)"}),i.jsx(Bm,{suggestions:ln,visible:re.tagsInput.trim()!=="",onPick:et})]}),_e&&i.jsx("p",{className:"text-sm text-destructive",children:_e})]}),i.jsxs(Os,{children:[i.jsx(he,{variant:"outline",type:"button",onClick:()=>fe(null),disabled:Re,children:"取消"}),i.jsx(he,{type:"button",onClick:()=>{we()},disabled:Re,children:Re?"保存中…":"保存"})]})]})}),He&&i.jsx(ps,{title:"移入回收站",description:`将《${He.name}》移入回收站。关联关系与变更记录将一并移入,可在回收站还原。`,confirmLabel:"移入回收站",danger:!0,onConfirm:ee,onClose:()=>ge(null)})]})}function UM({value:n,onChange:o,nodeOptions:r,placeholder:l="未设置"}){return i.jsxs("select",{value:n,onChange:c=>o(c.target.value),className:Ze("w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",n===""&&"text-muted-foreground"),children:[i.jsx("option",{value:"",children:l}),r.map(c=>i.jsxs("option",{value:c.id,children:[" ".repeat(c.depth),c.label]},c.id))]})}const zS=h.createContext(void 0);function Wl(n){const o=h.useContext(zS);if(o===void 0&&!n)throw new Error(En(47));return o}function HM(){return{..._p(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}const PM={...Ap,disabled:Ge(n=>n.disabled),instantType:Ge(n=>n.instantType),openMethod:Ge(n=>n.openMethod),openChangeReason:Ge(n=>n.openChangeReason),modal:Ge(n=>n.modal),focusManagerModal:Ge(n=>n.focusManagerModal),stickIfOpen:Ge(n=>n.stickIfOpen),titleElementId:Ge(n=>n.titleElementId),descriptionElementId:Ge(n=>n.descriptionElementId),openOnHover:Ge(n=>n.openOnHover),closeDelay:Ge(n=>n.closeDelay),hasViewport:Ge(n=>n.hasViewport)};class Jp extends fu{constructor(o,r,l=!1){const c={...HM(),...o},d=new Jl;c.open&&o?.mounted===void 0&&(c.mounted=!0),c.floatingRootContext=B1(d,r,l),super(c,{popupRef:h.createRef(),backdropRef:h.createRef(),internalBackdropRef:h.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:h.createRef(),beforeContentFocusGuardRef:h.createRef(),stickIfOpenTimeout:new ms,triggerElements:d},PM)}setOpen=(o,r)=>{const l=r.reason===fn,c=r.reason===Er&&r.event.detail===0,d=!o&&(r.reason===su||r.reason==null),m=D1(r),g=this.select("activeTriggerId");if(!o&&r.reason===U0&&r.trigger==null&&g!=null&&(r.trigger=this.context.triggerElements.getById(g)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(o,r),r.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(o,r);const b=()=>{const p={open:o,openChangeReason:r.reason};Cp(p,o,r.trigger,m()),this.update(p)};l?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(i1,()=>{this.set("stickIfOpen",!1)}),io.flushSync(b)):b(),c||d?this.set("instantType",c?"click":"dismiss"):r.reason===Nr?this.set("instantType","focus"):this.set("instantType",void 0)};static useStore(o,r){const{store:l,internalStore:c}=A1(o,(d,m)=>new Jp(r,d,m));return h.useEffect(()=>c?.disposeEffect(),[c]),l}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()}function Vv({props:n}){const{children:o,open:r,defaultOpen:l=!1,onOpenChange:c,onOpenChangeComplete:d,modal:m=!1,handle:g,triggerId:b,defaultTriggerId:p=null}=n,v=Jp.useStore(g?.store,{modal:m,open:l,openProp:r,activeTriggerId:p,triggerIdProp:b});z1(v,r,l,p),v.useControlledProp("openProp",r),v.useControlledProp("triggerIdProp",b);const x=v.useState("open"),S=v.useState("mounted"),j=v.useState("payload"),E=fo()!=null;v.useContextCallback("onOpenChange",c),v.useContextCallback("onOpenChangeComplete",d),I1(v,x),Rp(v);const{forceUnmount:M}=Op(x,v,()=>{v.update({stickIfOpen:!0,openChangeReason:null})});v.useSyncedValues({modal:m,nested:E}),h.useEffect(()=>{x||v.context.stickIfOpenTimeout.clear()},[v,x]);const O=h.useCallback(()=>{v.setOpen(!1,Ct(cp))},[v]);h.useImperativeHandle(n.actionsRef,()=>({unmount:M,close:O}),[M,O]);const N=x||S,T=h.useMemo(()=>({store:v}),[v]);return i.jsxs(zS.Provider,{value:T,children:[N&&i.jsx(VM,{store:v,modal:m}),typeof o=="function"?o({payload:j}):o]})}function YM(n){return Wl(!0)?i.jsx(Vv,{props:n}):i.jsx(x1,{children:i.jsx(Vv,{props:n})})}function VM({store:n,modal:o}){const r=n.useState("floatingRootContext"),l=Tp(r,{outsidePressEvent:{mouse:o==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),c=l.reference??Pt,d=l.trigger??Pt,m=h.useMemo(()=>so(pu,l.floating),[l.floating]);return kp(n,{activeTriggerProps:c,inactiveTriggerProps:d,popupProps:m}),null}const FM=300,GM=h.forwardRef(function(o,r){const{render:l,className:c,style:d,disabled:m=!1,nativeButton:g=!0,handle:b,payload:p,openOnHover:v=!1,delay:x=FM,closeDelay:S=0,id:j,...E}=o,M=Wl(!0),O=b?.store??M?.store;if(!O)throw new Error(En(74));const N=kr(j),T=O.useState("isTriggerActive",N),k=O.useState("floatingRootContext"),C=O.useState("isOpenedByTrigger",N),U=O.useState("triggerPopupId",N),A=h.useRef(null),{registerTrigger:L,isMountedByThisTrigger:_}=L1(N,A,O,{payload:p,disabled:m,openOnHover:v,closeDelay:S}),K=O.useState("openChangeReason"),W=O.useState("stickIfOpen"),ue=O.useState("openMethod"),ne=O.useState("focusManagerModal"),$=V1(k,{enabled:!m&&k!=null&&v&&(ue!=="touch"||K!==Er),mouseOnly:!0,move:!1,handleClose:F1(),restMs:x,delay:{close:S},triggerElementRef:A,isActiveTrigger:T,isClosing:()=>O.select("transitionStatus")==="ending"}),oe=b1(k,{enabled:k!=null,stickIfOpen:W}),q=tS(()=>O.select("open"),Q=>{O.set("openMethod",Q)}),w=O.useState("triggerProps",_),{getButtonProps:D,buttonRef:H}=Kl({disabled:m,native:g}),B={open(Q){return Q&&K===Er?xm.open(Q):sC.open(Q)}},{preFocusGuardRef:P,handlePreFocusGuardFocus:z,handleFocusTargetFocus:X}=sS(O,A),V=mn("button",o,{state:{disabled:m,open:C},ref:[H,r,L,A],props:[oe.reference,$,w,q,{[c1]:"",id:N,"aria-haspopup":"dialog","aria-expanded":C,"aria-controls":U},E,D],stateAttributesMapping:B});return _&&!ne?i.jsxs(h.Fragment,{children:[i.jsx(Yo,{ref:P,onFocus:z}),i.jsx(h.Fragment,{children:V},N),i.jsx(Yo,{ref:O.context.triggerFocusTargetRef,onFocus:X})]}):i.jsx(h.Fragment,{children:V},N)}),LS=h.createContext(void 0);function qM(){const n=h.useContext(LS);if(n===void 0)throw new Error(En(45));return n}const $M=h.forwardRef(function(o,r){const{keepMounted:l=!1,...c}=o,{store:d}=Wl();return d.useState("mounted")||l?i.jsx(LS.Provider,{value:l,children:i.jsx(vp,{ref:r,...c})}):null}),IS=h.createContext(void 0);function XM(){const n=h.useContext(IS);if(!n)throw new Error(En(46));return n}const KM=h.forwardRef(function(o,r){const{render:l,className:c,style:d,anchor:m,positionMethod:g="absolute",side:b="bottom",align:p="center",sideOffset:v=0,alignOffset:x=0,collisionBoundary:S="clipping-ancestors",collisionPadding:j=5,arrowPadding:E=5,sticky:M=!1,disableAnchorTracking:O=!1,collisionAvoidance:N=u1,...T}=o,{store:k}=Wl(),C=qM(),U=Ep(),A=k.useState("floatingRootContext"),L=k.useState("mounted"),_=k.useState("open"),K=k.useState("openChangeReason"),W=k.useState("activeTriggerElement"),ue=k.useState("modal"),ne=k.useState("openMethod"),$=k.useState("positionerElement"),oe=k.useState("instantType"),q=k.useState("transitionStatus"),w=k.useState("hasViewport"),D=h.useRef(null),H=mp($,!1,!1),B=Q1({anchor:m,floatingRootContext:A,positionMethod:g,mounted:L,side:b,sideOffset:v,align:p,alignOffset:x,arrowPadding:E,collisionBoundary:S,collisionPadding:j,sticky:M,disableAnchorTracking:O,keepMounted:C,nodeId:U,collisionAvoidance:N,adaptiveOrigin:w?X1:void 0}),P=A.useState("domReferenceElement");Qe(()=>{const V=P,Q=D.current;if(V&&(D.current=V),Q&&V&&V!==Q){k.set("instantType",void 0);const Y=new AbortController;return H(()=>{k.set("instantType","trigger-change")},Y.signal),()=>{Y.abort()}}},[P,H,k]),W1(_&&ue===!0&&K!==fn,ne==="touch",$,W);const z=h.useCallback(V=>{k.set("positionerElement",V)},[k]),X={open:_,side:B.side,align:B.align,anchorHidden:B.anchorHidden,instant:oe},I=Z1(o,X,{styles:B.positionerStyles,transitionStatus:q,props:T,refs:[r,z],hidden:!L,inert:!_});return i.jsxs(IS.Provider,{value:B,children:[L&&ue===!0&&K!==fn&&i.jsx(Bp,{ref:k.context.internalBackdropRef,inert:Ip(!_),cutout:W}),i.jsx(g1,{id:U,children:I})]})}),QM=h.createContext(void 0);function ZM(){const[n,o]=h.useState(0),r=at(()=>(o(c=>c+1),()=>{o(c=>Math.max(0,c-1))}));return{context:h.useMemo(()=>({register:r}),[r]),hasClosePart:n>0}}function JM(n){const{value:o,children:r}=n;return i.jsx(QM.Provider,{value:o,children:r})}const WM={...Ql,...tu},eA=h.forwardRef(function(o,r){const{render:l,className:c,style:d,initialFocus:m,finalFocus:g,...b}=o,{store:p}=Wl(),v=XM(),x=G1()!=null,{context:S,hasClosePart:j}=ZM(),E=p.useState("open"),M=p.useState("openMethod"),O=p.useState("instantType"),N=p.useState("transitionStatus"),T=p.useState("popupProps"),k=p.useState("titleElementId"),C=p.useState("descriptionElementId"),U=p.useState("modal"),A=p.useState("mounted"),L=p.useState("openChangeReason"),_=p.useState("activeTriggerElement"),K=p.useState("floatingRootContext"),W=K.useState("floatingId"),ue=p.useState("disabled"),ne=p.useState("openOnHover"),$=p.useState("closeDelay"),oe=b.id??W;au({open:E,ref:p.context.popupRef,onComplete(){E&&p.context.onOpenChangeComplete?.(!0)}}),Y1(K,{enabled:ne&&!ue,closeDelay:$});const q=m===void 0?M1(p.context.popupRef):m,w=U!==!1&&j;p.useSyncedValue("focusManagerModal",w);const D=h.useCallback(P=>{p.set("popupElement",P)},[p]),H={open:E,side:v.side,align:v.align,instant:O,transitionStatus:N},B=mn("div",o,{state:H,ref:[r,p.context.popupRef,D],props:[T,{id:oe,role:"dialog",...pu,"aria-labelledby":k,"aria-describedby":C,onKeyDown(P){x&&zp.has(P.key)&&P.stopPropagation()}},Lp(N),b],stateAttributesMapping:WM});return i.jsx(jp,{context:K,openInteractionType:M,modal:w,disabled:!A||L===fn,initialFocus:q,returnFocus:g,restoreFocus:"popup",previousFocusableElement:Ht(_)?_:void 0,nextFocusableElement:p.context.triggerFocusTargetRef,beforeContentFocusGuardRef:p.context.beforeContentFocusGuardRef,children:i.jsx(JM,{value:S,children:B})})});function tA({...n}){return i.jsx(YM,{"data-slot":"popover",...n})}function nA({...n}){return i.jsx(GM,{"data-slot":"popover-trigger",...n})}function sA({align:n="start",alignOffset:o=0,side:r="bottom",sideOffset:l=8,className:c,...d}){return i.jsx($M,{children:i.jsx(KM,{className:"isolate z-50 outline-none",align:n,alignOffset:o,side:r,sideOffset:l,children:i.jsx(eA,{"data-slot":"popover-content",className:Ze("z-50 min-w-64 origin-(--transform-origin) rounded-lg bg-popover p-3 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",c),...d})})})}function oA({id:n}){const[o,r]=h.useState(null),[l,c]=h.useState(!1),[d,m]=h.useState(!1),[g,b]=h.useState(null),[p,v]=h.useState(null),[x,S]=h.useState(!1),[j,E]=h.useState(null),[M,O]=h.useState(!1),[N,T]=h.useState(""),[k,C]=h.useState(null),[U,A]=h.useState(!1),[L,_]=h.useState(null),[K,W]=h.useState(!1),[ue,ne]=h.useState([]),[$,oe]=h.useState(null),[q,w]=h.useState(null),[D,H]=h.useState(!1),[B,P]=h.useState(!1),[z,X]=h.useState(null);async function I(){try{const pe=await ls("event",{limit:200});ne(zc(pe.items))}catch{}}async function V(){H(!1);try{const[pe,ve]=await Promise.all([ls("timepoint",{}),ls("event",{limit:200})]);oe(pe.items),w(ve.items)}catch{oe(null),w(null),H(!0)}}h.useEffect(()=>{I(),V()},[]);const Q=Be(pe=>pe.outline),Y=ao(Q?.children??[]);async function fe(){c(!0),b(null),m(!1);try{const pe=await pr("event",n);r(pe),v(_M(pe))}catch(pe){r(null),v(null),pe instanceof ze&&pe.code==="ENTITY_NOT_FOUND"?m(!0):b(pe instanceof ze?pe.code:ft)}finally{c(!1)}}h.useEffect(()=>{fe()},[n]),Ds(()=>{fe(),I(),V()}),h.useEffect(()=>{Be.getState().outline===null&&Be.getState().config!==null&&Be.getState().loadOutline()},[]);async function re(){if(!o||!p||x)return;const pe=MS({name:o.name,data:o.data},p);if(pe===null){ke.getState().showToast("没有变更");return}S(!0),E(null);try{await yr("event",n,pe),ke.getState().showToast("已保存"),await fe()}catch(ve){if(ve instanceof ze&&ve.code==="ENTITY_NOT_FOUND"){m(!0);return}E(ve instanceof ze?ve.message:"保存失败,请重试")}finally{S(!1)}}async function de(pe){if(!o||B||!$||!q)return;const ve=im(o.relations,n);if(pe===(ve??""))return;const Ue=q.findIndex(De=>De.id===n),ye=Ue===-1?q.length:Ue;P(!0),X(null);try{await E0(n,{timepoint_id:pe===""?null:pe,order:ye}),ke.getState().showToast(pe===""?"已移出挂载":"已更新挂载时间点"),await fe()}catch(De){if(De instanceof ze&&De.code==="ENTITY_NOT_FOUND"){m(!0);return}X(De instanceof ze?De.message:"挂载保存失败,请重试")}finally{P(!1)}}async function _e(){if(!(N===""||U)){A(!0),C(null);try{await Sr(AM(n,N)),ke.getState().showToast("已关联大纲节点"),O(!1),await fe()}catch(pe){if(pe instanceof ze&&pe.code==="RELATION_EXISTS"){C("这条关系已经存在");return}C(pe instanceof ze?pe.message:"关联失败,请重试")}finally{A(!1)}}}async function Ye(){if(L)try{await Zc(L.id),ke.getState().showToast("已取消关联"),_(null),await fe()}catch(pe){throw pe}}async function Re(){if(o)try{const pe=await Qc("event",n),ve=[];pe.cascaded.relations>0&&ve.push(`${pe.cascaded.relations} 条关联`),pe.cascaded.deltas>0&&ve.push(`${pe.cascaded.deltas} 条变更记录`),ke.getState().showToast(`已移入回收站,可随时还原${ve.length>0?`(含 ${ve.join("、")})`:""}`),W(!1),Tn("/timeline")}catch(pe){throw pe}}if(d)return i.jsx("section",{children:i.jsxs("div",{className:"rounded-lg border border-dashed border-border px-6 py-14 text-center",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"该事件不存在或已被删除"}),i.jsxs("div",{className:"mt-4 flex justify-center gap-2",children:[i.jsx("a",{href:"#/trash",className:"rounded-md border border-border px-4 py-1.5 text-sm text-muted-foreground hover:bg-muted",children:"去回收站"}),i.jsx(he,{variant:"outline",type:"button",onClick:()=>Tn("/timeline"),children:"返回列表"})]})]})});const Le=o===null?[]:MM(o.relations,n),He=p===null?[]:Lm(p.tagsInput,ue);function ge(pe){v(ve=>ve&&{...ve,tagsInput:Im(ve.tagsInput,pe)})}return i.jsxs("section",{children:[i.jsxs("div",{className:"mb-1 flex items-center gap-3",children:[i.jsx(Qp,{items:[{label:"时间轴",href:"/timeline"},{label:o?.name??"…"}]}),i.jsx("h1",{className:"min-w-0 truncate text-xl font-semibold",children:o?.name??"…"}),i.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[i.jsx(he,{variant:"outline",type:"button",onClick:()=>{re()},disabled:!o||x,children:x?"保存中…":"保存"}),i.jsx(he,{variant:"outline",type:"button",disabled:!o,className:"text-destructive hover:bg-destructive/10",onClick:()=>W(!0),children:"移入回收站"})]})]}),o&&i.jsxs("p",{className:"mb-4 text-xs text-muted-foreground",children:["创建于 ",is(o.createdAt)," · 更新于 ",is(o.updatedAt)]}),l&&!o&&i.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[i.jsx("div",{className:"space-y-3 rounded-md border border-border p-4",children:Array.from({length:5},(pe,ve)=>i.jsx("div",{className:"h-9 animate-pulse rounded bg-muted"},ve))}),i.jsx("div",{className:"space-y-3 rounded-md border border-border p-4",children:Array.from({length:3},(pe,ve)=>i.jsx("div",{className:"h-9 animate-pulse rounded bg-muted"},ve))})]}),!l&&!o&&g!==null&&i.jsxs("div",{className:"rounded-md border border-border p-4 text-sm text-muted-foreground",children:[g===ft?"无法连接服务,请确认 ai-editor 服务已启动。":"详情加载失败,请重试。",i.jsx(he,{variant:"outline",className:"ml-3",type:"button",onClick:()=>{fe()},children:"重试"})]}),o&&p&&i.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[i.jsxs("div",{className:"rounded-md border border-border p-4",children:[i.jsx("h2",{className:"mb-3 text-sm font-semibold text-foreground",children:"基础信息"}),i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"名称(必填)"}),i.jsx(Dt,{value:p.name,onChange:pe=>v(ve=>ve&&{...ve,name:pe.target.value}),maxLength:100})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"描述"}),i.jsx("textarea",{value:p.description,onChange:pe=>v(ve=>ve&&{...ve,description:pe.target.value}),rows:3,placeholder:"事件发生了什么",className:"w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"挂载时间点"}),$===null?D?i.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:["挂载数据加载失败",i.jsx(he,{variant:"outline",size:"sm",type:"button",className:"h-6 px-2 text-xs",onClick:()=>{V()},children:"重试"})]}):i.jsx("div",{className:"h-9 animate-pulse rounded bg-muted"}):i.jsxs("select",{value:im(o.relations,n)??"",onChange:pe=>{de(pe.target.value)},disabled:B,className:Ze("w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",im(o.relations,n)===null&&"text-muted-foreground"),children:[i.jsx("option",{value:"",children:"未挂载"}),$.map(pe=>i.jsx("option",{value:pe.id,children:pe.name},pe.id))]}),B&&i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"保存中…"}),z&&i.jsx("p",{className:"mt-1 text-sm text-destructive",children:z})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"标签"}),i.jsx(Dt,{value:p.tagsInput,onChange:pe=>v(ve=>ve&&{...ve,tagsInput:pe.target.value}),placeholder:"如:主线,战争(逗号/回车分隔)"}),i.jsx(Bm,{suggestions:He,visible:p.tagsInput.trim()!=="",onPick:ge})]}),j&&i.jsx("p",{className:"text-sm text-destructive",children:j})]})]}),i.jsxs("div",{className:"rounded-md border border-border p-4",children:[i.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[i.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"关联节点(occurs_in)"}),i.jsxs(tA,{open:M,onOpenChange:pe=>{pe?(T(""),C(null),O(!0)):U||O(!1)},children:[i.jsx(nA,{render:i.jsx(he,{variant:"outline",type:"button",className:"h-8 px-2 text-xs",children:"+ 关联场景/章节"})}),i.jsxs(sA,{className:"flex flex-col gap-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"大纲节点"}),i.jsx(rA,{value:N,onChange:T,nodeOptions:Y,placeholder:"请选择节点"})]}),k&&i.jsx("p",{className:"text-sm text-destructive",children:k}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(he,{variant:"outline",type:"button",size:"sm",onClick:()=>O(!1),disabled:U,children:"取消"}),i.jsx(he,{type:"button",size:"sm",onClick:()=>{_e()},disabled:U||N==="",children:U?"关联中…":"关联"})]})]})]})]}),Le.length===0?i.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"暂无关联节点,新增一个"}):i.jsx("ul",{className:"divide-y divide-border/70",children:Le.map(pe=>i.jsxs("li",{className:"flex items-center gap-2 py-2 text-sm",children:[i.jsx("button",{type:"button",onClick:()=>Tn(`/outline/${pe.targetId}`),title:"跳转大纲定位",className:"min-w-0 flex-1 truncate text-left text-foreground underline-offset-2 hover:text-primary hover:underline",children:pe.targetName??pe.targetId}),i.jsx(he,{variant:"outline",type:"button",className:"h-7 shrink-0 px-2 text-xs text-destructive hover:bg-destructive/10",onClick:()=>_(pe),children:"取消关联"})]},pe.id))})]})]}),L&&i.jsx(ps,{title:"取消关联",description:`取消《${L.targetName??L.targetId}》与事件的关联?物理删除不可恢复,可重新建立。`,confirmLabel:"取消关联",danger:!0,onConfirm:Ye,onClose:()=>_(null)}),K&&i.jsx(ps,{title:"移入回收站",description:`将《${o?.name??""}》移入回收站。关联关系与变更记录将一并移入,可在回收站还原。`,confirmLabel:"移入回收站",danger:!0,onConfirm:Re,onClose:()=>W(!1)})]})}function rA({value:n,onChange:o,nodeOptions:r,placeholder:l="未设置"}){return i.jsxs("select",{value:n,onChange:c=>o(c.target.value),className:Ze("w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",n===""&&"text-muted-foreground"),children:[i.jsx("option",{value:"",children:l}),r.map(c=>i.jsxs("option",{value:c.id,children:[" ".repeat(c.depth),c.label]},c.id))]})}function aA(n,o){const r=[];return n>0&&r.push(`${n} 条关系`),o>0&&r.push(`${o} 条变更记录`),r.length>0?`已还原,连带恢复 ${r.join("、")}`:"已还原"}function lA(n){return n>0?`已还原(含 ${n} 个子节点)`:"已还原"}function iA(n){return/软删祖先\s+([^\s,,]+)/.exec(n)?.[1]??null}const Fv={character:"人物",setting:"设定",location:"地点",hook:"伏笔",event:"事件",timepoint:"时间点"},cA={volume:"卷",chapter:"章",scene:"场"};function Gv({label:n}){return i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:n})}function uA(){const[n,o]=h.useState(null),[r,l]=h.useState(!1),[c,d]=h.useState(null),[m,g]=h.useState(0);Ds(()=>g(C=>C+1));const[b,p]=h.useState(null),[v,x]=h.useState(null);h.useEffect(()=>{let C=!1;return l(!0),d(null),Pw().then(U=>{C||o(U)}).catch(U=>{C||d(U instanceof ze?U.code:ft)}).finally(()=>{C||l(!1)}),()=>{C=!0}},[m]);async function S(){g(C=>C+1)}function j(C){return C instanceof ze&&(C.code==="ENTITY_NOT_FOUND"||C.code==="OUTLINE_NODE_NOT_FOUND")}function E(C){ke.getState().showError(C instanceof ze?C.code:ft,C instanceof ze?C.message:"操作失败,请重试")}async function M(C){try{const U=await Yw(C.type,C.id);ke.getState().showToast(aA(U.restoredRelations,U.restoredDeltas)),await S()}catch(U){if(j(U)){ke.getState().showToast("该对象已不存在","error"),await S();return}E(U)}}async function O(C){x(null);try{const U=await py(C.id);ke.getState().showToast(lA(U.restoredChildren)),await S(),Be.getState().loadOutline()}catch(U){if(U instanceof ze&&U.code==="OUTLINE_ANCESTOR_DELETED"){const A=iA(U.message);if(A===null){ke.getState().showError("OUTLINE_ANCESTOR_DELETED","上级节点也在回收站,请先还原上级");return}x({node:C,ancestorId:A,ancestorName:n?.nodes.find(L=>L.id===A)?.title??A});return}if(j(U)){ke.getState().showToast("该对象已不存在","error"),await S();return}E(U)}}async function N(){const C=v;if(C)try{await py(C.ancestorId),Be.getState().loadOutline(),await O(C.node)}catch(U){if(j(U)){ke.getState().showToast("该对象已不存在","error"),x(null),await S();return}E(U)}}async function T(){if(b)try{b.kind==="entity"?await Vw(b.item.type,b.item.id):(await Fw(b.item.id),Be.getState().loadOutline()),ke.getState().showToast("已彻底删除"),await S()}catch(C){if(j(C)){ke.getState().showToast("该对象已不存在","error"),await S();return}throw C}}const k=n!==null&&n.entities.length===0&&n.nodes.length===0;return i.jsxs("section",{children:[i.jsxs("div",{className:"mb-1 flex items-center gap-3",children:[i.jsx("h1",{className:"text-xl font-semibold",children:"回收站"}),i.jsx(he,{variant:"outline",type:"button",className:"ml-auto",onClick:()=>{S()},disabled:r,children:"刷新"})]}),i.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:"软删对象会保留一段时间,可在此还原,或彻底删除(不可恢复)。"}),c!==null&&i.jsxs("div",{className:"mb-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[c===ft?"无法连接服务,请确认 ai-editor 服务已启动。":"回收站加载失败,请重试。",i.jsx(he,{variant:"outline",className:"ml-3",type:"button",onClick:()=>{S()},children:"重试"})]}),r&&n===null&&c===null&&i.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:[0,1].map(C=>i.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[i.jsx("div",{className:"h-9 animate-pulse bg-muted/60"}),Array.from({length:3},(U,A)=>i.jsxs("div",{className:"flex items-center gap-2 border-b border-border/70 px-3 py-2.5 last:border-0",children:[i.jsx("div",{className:"h-4 w-10 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-4 flex-1 animate-pulse rounded bg-muted"}),i.jsx("div",{className:"h-4 w-16 animate-pulse rounded bg-muted"})]},A))]},C))}),!r&&k&&i.jsx("div",{className:"rounded-lg border border-dashed border-border px-6 py-12 text-center text-sm text-muted-foreground",children:"回收站是空的"}),n!==null&&!k&&i.jsxs("div",{className:"grid items-start gap-4 md:grid-cols-2",children:[i.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[i.jsxs("div",{className:"border-b border-border bg-muted/40 px-3 py-2 text-sm font-medium text-foreground",children:["实体 (",n.entities.length,")"]}),n.entities.length===0?i.jsx("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"暂无实体"}):i.jsx("ul",{className:"divide-y divide-border/70",children:n.entities.map(C=>i.jsxs("li",{className:"flex items-center gap-2 px-3 py-2",children:[i.jsx(Gv,{label:Fv[C.type]}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",title:C.name,children:C.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:br(C.deletedAt)}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[i.jsx(he,{variant:"outline",size:"xs",type:"button",onClick:()=>{M(C)},children:"还原"}),i.jsx(he,{variant:"outline",size:"xs",type:"button",className:"text-destructive hover:bg-destructive/10",onClick:()=>p({kind:"entity",item:C}),children:"彻底删除"})]})]},C.id))})]}),i.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[i.jsxs("div",{className:"border-b border-border bg-muted/40 px-3 py-2 text-sm font-medium text-foreground",children:["大纲节点 (",n.nodes.length,")"]}),n.nodes.length===0?i.jsx("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"暂无节点"}):i.jsx("ul",{className:"divide-y divide-border/70",children:n.nodes.map(C=>i.jsxs("li",{className:"px-3 py-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Gv,{label:cA[C.type]}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",title:C.title,children:C.title}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:br(C.deletedAt)}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[i.jsx(he,{variant:"outline",size:"xs",type:"button",onClick:()=>{O(C)},children:"还原"}),i.jsx(he,{variant:"outline",size:"xs",type:"button",className:"text-destructive hover:bg-destructive/10",onClick:()=>p({kind:"node",item:C}),children:"彻底删除"})]})]}),v?.node.id===C.id&&i.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm",children:[i.jsxs("span",{className:"text-destructive",children:["上级节点《",v.ancestorName,"》也在回收站,请先还原上级"]}),i.jsxs(he,{variant:"outline",size:"xs",type:"button",className:"border-destructive/40 text-destructive hover:bg-destructive/10",onClick:()=>{N()},children:["还原上级《",v.ancestorName,"》"]})]})]},C.id))})]})]}),b&&i.jsx(ps,{title:"彻底删除",description:b.kind==="entity"?`将彻底删除《${b.item.name}》(${Fv[b.item.type]})及其关联关系、变更记录,不可恢复。`:`将彻底删除《${b.item.title}》及整棵子树、关联关系、变更记录,不可恢复。`,confirmLabel:"确认彻底删除",danger:!0,onConfirm:T,onClose:()=>p(null)})]})}function cm(n,o=new Date){const r=new Date(n);if(Number.isNaN(r.getTime()))return n;const l=m=>String(m).padStart(2,"0"),c=`${l(r.getHours())}:${l(r.getMinutes())}:${l(r.getSeconds())}`;return r.getFullYear()===o.getFullYear()?`${l(r.getMonth()+1)}-${l(r.getDate())} ${c}`:`${String(r.getFullYear()).slice(-2)}-${l(r.getMonth()+1)}-${l(r.getDate())} ${c}`}function qv(n){return!Number.isFinite(n)||n<0?"0 B":n<1024?`${n} B`:n<1024*1024?`${Math.round(n/1024)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}const $v=[{value:null,label:"关闭"},...cj.map(n=>({value:n,label:`每 ${n} 分钟`}))],Xv={auto:"自动",manual:"手动"};let Ol=0;function dA(){const n=ke(D=>D.showToast),o=ke(D=>D.showError),r=ke(D=>D.notifyDataChanged),l=Be(D=>D.config),c=Be(D=>D.configLoading),d=Be(D=>D.updateConfig),m=Be(D=>D.loadConfig),g=Be(D=>D.loadOutline),[b,p]=h.useState(!1),[v,x]=h.useState(null),[S,j]=h.useState(!1),[E,M]=h.useState(null),[O,N]=h.useState(!1),[T,k]=h.useState(null),[C,U]=h.useState(""),[A,L]=h.useState(null),_=h.useRef(A);_.current=A;async function K(){if(Be.getState().config===null)return;const D=++Ol;j(!0),M(null);try{const H=await s2();if(D!==Ol)return;x(H.backups)}catch(H){if(D!==Ol)return;const B=H instanceof ze?H.code:ft;M(B)}finally{D===Ol&&j(!1)}}const W=l?.id??null,ue=h.useRef(null);h.useEffect(()=>{if(W===null){Ol++,x(null),M(null),k(null),L(null),ue.current=null;return}ue.current!==W&&(ue.current=W,K())},[W]);async function ne(D){if(l===null)return;const H=D==="null"?null:Number(D);if(H!==l.backupFrequencyMinutes){p(!0);try{await d({backup_frequency_minutes:H}),n(H===null?"已关闭自动备份":`自动备份频率已设为每 ${H} 分钟`)}catch(B){B instanceof ze&&B.code===ft?o("CLIENT_NETWORK_ERROR","无法连接服务,频率未保存"):n("频率保存失败,请重试","error")}finally{p(!1)}}}async function $(){if(!(l===null||O)){N(!0);try{const D=C.trim();await o2(D.length>0?D:void 0),U(""),n(D.length>0?`已备份「${D}」`:"已备份"),await K()}catch(D){n(D instanceof ze&&D.code!==ft?D.message:"无法连接服务,备份失败","error")}finally{N(!1)}}}async function oe(){if(T===null)return;const D=await r2(T.fileName);n(`已恢复备份,覆盖前状态已自动快照(${D.snapshot.fileName})`),await Promise.all([m(),g()]),r(),Nt.getState().clearSessions(),Nt.getState().loadSessions(),K()}async function q(){if(A===null||A.saving)return;const D=v?.find(B=>B.fileName===A.fileName)?.name??"",H=A.value.trim();if(H===D){L(null);return}L({...A,saving:!0,error:null});try{await a2(A.fileName,A.value),L(null),n(H.length>0?`已重命名「${H}」`:"已清除备份名称"),await K()}catch(B){const P=B instanceof ze&&B.code!==ft?B.message:"无法连接服务,重命名失败";if(_.current===null){n(P,"error");return}L(z=>z===null?z:{...z,saving:!1,error:P})}}const w=l===null?"":$v.some(D=>String(D.value)===String(l.backupFrequencyMinutes))?String(l.backupFrequencyMinutes):"null";return i.jsxs("div",{children:[i.jsx("h2",{className:"mb-1 text-sm font-semibold text-foreground",children:"自动备份"}),i.jsx("p",{className:"mb-2 text-xs text-muted-foreground",children:"跟随书籍:备份与频率均为本项目独立;服务运行期间按频率自动备份,有变更才生成新备份;每项目保留最近 20 份"}),i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsx("select",{value:w,onChange:D=>{ne(D.target.value)},disabled:l===null||b,"aria-label":"自动备份频率",className:"rounded-lg border border-input bg-transparent px-2.5 py-1.5 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",children:$v.map(D=>i.jsx("option",{value:String(D.value),children:D.label},String(D.value)))}),i.jsx("input",{value:C,onChange:D=>U(D.target.value),maxLength:Wb,placeholder:"备份名称(可选)","aria-label":"备份名称(可选)",disabled:l===null,className:"w-36 rounded-lg border border-input bg-transparent px-2.5 py-1.5 text-sm outline-none placeholder:text-muted-foreground/60 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50"}),i.jsxs(he,{onClick:()=>{$()},disabled:l===null||O,type:"button",children:[O?i.jsx(Il,{className:"size-4 animate-spin"}):null,"立即备份"]})]}),l===null&&!c&&i.jsx("p",{className:"mt-1 text-xs text-muted-foreground/70",children:"打开项目后可用"}),l!==null&&i.jsxs("div",{className:"mt-3",children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"历史备份"}),i.jsx("div",{className:"overflow-hidden rounded-lg border border-border",children:S&&v===null?i.jsxs("div",{className:"space-y-1 p-2",children:[i.jsx("div",{className:"h-7 animate-pulse rounded-md bg-muted"}),i.jsx("div",{className:"h-7 animate-pulse rounded-md bg-muted"})]}):E!==null?i.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:E===ft?"无法连接服务":"备份列表加载失败"}),i.jsx(he,{variant:"ghost",size:"xs",onClick:()=>{K()},children:"重试"})]}):v!==null&&v.length===0?i.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground/70",children:"暂无备份,自动备份将在数据变更后按频率生成"}):v!==null?i.jsx("ul",{className:"divide-y divide-border",children:v.map(D=>{const H=A!==null&&A.fileName===D.fileName;return i.jsxs("li",{className:"px-2 py-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"min-w-0 flex-1 text-sm",title:D.fileName,children:[i.jsx("span",{className:"text-muted-foreground",children:cm(D.createdAt)}),i.jsx("span",{className:D.kind==="manual"?"ml-1.5 rounded border border-primary/40 px-1 text-[10px] leading-4 text-primary":"ml-1.5 rounded border border-border px-1 text-[10px] leading-4 text-muted-foreground",children:Xv[D.kind]}),!H&&D.name!==void 0?i.jsx("span",{className:"ml-1.5 font-medium text-foreground",children:D.name}):null]}),H?null:i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:qv(D.size)}),H?i.jsxs(i.Fragment,{children:[i.jsx("input",{value:A.value,onChange:B=>L(P=>P===null?P:{...P,value:B.target.value,error:null}),onKeyDown:B=>{B.key==="Enter"?q():B.key==="Escape"&&L(null)},onBlur:()=>{_.current?.saving||L(null)},maxLength:Wb,disabled:A.saving,autoFocus:!0,"aria-label":"备份新名称",className:"w-36 shrink-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-sm outline-none placeholder:text-muted-foreground/60 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50"}),i.jsx(he,{size:"icon-xs",variant:"ghost",onClick:()=>{q()},disabled:A.saving,onMouseDown:B=>B.preventDefault(),"aria-label":"确认重命名",title:"确认(Enter)",children:A.saving?i.jsx(Il,{className:"size-3 animate-spin"}):i.jsx(Ej,{className:"size-3"})}),i.jsx(he,{size:"icon-xs",variant:"ghost",onClick:()=>L(null),disabled:A.saving,onMouseDown:B=>B.preventDefault(),"aria-label":"取消重命名",title:"取消(Esc)",children:i.jsx(As,{className:"size-3"})})]}):i.jsxs(i.Fragment,{children:[i.jsx(he,{size:"icon-xs",variant:"ghost",onClick:()=>L({fileName:D.fileName,value:D.name??"",saving:!1,error:null}),"aria-label":`重命名备份 ${cm(D.createdAt)}`,title:"重命名",children:i.jsx(iT,{className:"size-3"})}),i.jsx(he,{variant:"outline",size:"xs",onClick:()=>k(D),children:"加载"})]})]}),H&&A.error!==null?i.jsx("p",{className:"mt-1 text-xs text-destructive",children:A.error}):null]},D.fileName)})}):null})]}),T!==null&&i.jsx(ps,{title:"加载备份",description:`${cm(T.createdAt)} · ${Xv[T.kind]}${T.name!==void 0?` · ${T.name}`:""} · ${qv(T.size)}。将覆盖当前项目数据;覆盖前会自动备份当前状态(可回退)`,confirmLabel:"确认加载",danger:!0,onConfirm:oe,onClose:()=>k(null)})]})}function kl(n){return n instanceof ze?n.code:ft}function fA(){const n=ke(B=>B.showToast),o=ke(B=>B.showError),r=ke(B=>B.notifyDataChanged),l=Be(B=>B.config),c=Be(B=>B.configLoading),d=Be(B=>B.updateConfig),[m,g]=h.useState(!0),[b,p]=h.useState(""),[v,x]=h.useState(!1),[S,j]=h.useState(void 0),[E,M]=h.useState(""),[O,N]=h.useState(!1),[T,k]=h.useState(null),[C,U]=h.useState(null),[A,L]=h.useState(""),[_,K]=h.useState(null),[W,ue]=h.useState(!1),[ne,$]=h.useState(null);async function oe(){try{const B=await i2();p(B.model),x(B.apiKeySet),j(B.apiKeyMasked)}catch(B){o(kl(B),"读取 LLM 配置失败")}finally{g(!1)}}h.useEffect(()=>{oe()},[]),h.useEffect(()=>{const B=Be.getState();B.config===null&&!B.configLoading&&B.loadConfig()},[]),h.useEffect(()=>{if(l===null){K(null);return}l.id!==_&&(L(l.prompt),K(l.id))},[l,_]);async function q(){$(null),ue(!0);try{const B=A.trim();await d({prompt:B}),L(B),n("提示词已保存,仅影响新请求"),r()}catch(B){kl(B)===ft?o("CLIENT_NETWORK_ERROR","无法连接服务,提示词未保存"):$("保存失败,请重试")}finally{ue(!1)}}async function w(){if(!b.trim()){k("模型名不能为空");return}k(null),N(!0);try{await If({model:b.trim()}),n("已保存,仅影响新请求"),p(b.trim())}catch(B){kl(B)===ft?o("CLIENT_NETWORK_ERROR","无法连接服务,模型配置未保存"):k("保存失败,请重试")}finally{N(!1)}}async function D(){if(!E.trim()){U("请输入新 key");return}U(null),N(!0);try{await If({api_key:E.trim()}),M(""),n("Key 已保存,仅影响新请求"),await oe()}catch(B){kl(B)===ft?o("CLIENT_NETWORK_ERROR","无法连接服务,Key 未保存"):U("保存失败,请重试")}finally{N(!1)}}async function H(){U(null),N(!0);try{await If({api_key:""}),M(""),n("Key 已清除"),await oe()}catch(B){kl(B)===ft?o("CLIENT_NETWORK_ERROR","无法连接服务,Key 未清除"):U("清除失败,请重试")}finally{N(!1)}}return i.jsxs("section",{className:"max-w-lg",children:[i.jsx("h1",{className:"mb-4 text-xl font-semibold",children:"设置"}),m?i.jsx("p",{className:"text-sm text-zinc-500",children:"加载中…"}):i.jsxs("div",{className:"flex flex-col gap-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"mb-1 text-sm font-semibold text-zinc-700",children:"AI 模型"}),i.jsx("p",{className:"mb-2 text-xs text-zinc-500",children:"默认 deepseek-v4-flash(可在服务端设置页或环境变量覆盖)"}),i.jsxs("div",{className:"flex max-w-sm gap-2",children:[i.jsx(Dt,{value:b,onChange:B=>p(B.target.value),placeholder:"deepseek-v4-flash"}),i.jsx(he,{onClick:()=>{w()},disabled:O,type:"button",children:"保存设置"})]}),T&&i.jsx("p",{className:"mt-1 text-sm text-red-600",children:T})]}),i.jsxs("div",{children:[i.jsx("h2",{className:"mb-1 text-sm font-semibold text-zinc-700",children:"API Key"}),i.jsxs("p",{className:"mb-2 text-xs text-zinc-500",children:["状态:",v?`已配置(${S??""})`:"未配置"]}),i.jsxs("div",{className:"flex max-w-sm gap-2",children:[i.jsx(Dt,{value:E,onChange:B=>M(B.target.value),placeholder:"输入新 key(覆盖旧 key)"}),i.jsx(he,{onClick:()=>{D()},disabled:O,type:"button",children:"保存 Key"}),i.jsx(he,{variant:"outline",onClick:()=>{H()},disabled:O,type:"button",children:"清除 Key"})]}),C&&i.jsx("p",{className:"mt-1 text-sm text-red-600",children:C})]}),i.jsxs("div",{className:"rounded-md border border-zinc-200 bg-zinc-50 p-3 text-xs leading-relaxed text-zinc-600",children:[i.jsx("p",{children:"· key 保存在用户目录配置文件(~/.ai-editor/config.json),不写入项目文件(决策 17)"}),i.jsx("p",{children:"· 环境变量 DEEPSEEK_API_KEY 优先于此处配置;保存的 key 仅影响新请求"})]}),i.jsxs("div",{children:[i.jsx("h2",{className:"mb-1 text-sm font-semibold text-foreground",children:"项目提示词"}),i.jsx("p",{className:"mb-2 text-xs text-muted-foreground",children:"注入 AI 上下文「## 项目设定」段(每轮有效);承载项目级规则/行业要求;空 = 整段跳过"}),i.jsx("p",{className:"mb-2 text-xs text-muted-foreground/70",children:"建议用 ### 及以下层级的小标题组织内容(如「### 写作规则」);避免使用 ## 顶层标题(与系统分段标题冲突)"}),i.jsx("textarea",{value:A,onChange:B=>L(B.target.value),rows:6,disabled:l===null||l.id!==_,placeholder:"输入项目级规则/行业要求…",className:"w-full resize-y rounded-lg border border-input bg-transparent px-2.5 py-1.5 text-sm outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50"}),i.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[i.jsx(he,{onClick:()=>{q()},disabled:W||l===null||l.id!==_,type:"button",children:"保存提示词"}),l===null&&!c&&i.jsx("p",{className:"text-xs text-muted-foreground/70",children:"打开项目后可用"})]}),ne&&i.jsx("p",{className:"mt-1 text-sm text-destructive",children:ne})]}),i.jsx(dA,{})]})]})}function mA(n){const[o,r,l]=n.segments;switch(o){case void 0:return i.jsx(gv,{});case"outline":return r!==void 0?i.jsx(I3,{nodeId:r},r):i.jsx(d3,{});case"canvas":return i.jsx(tM,{});case"entities":{if(r==="relations")return i.jsx(Bv,{type:"relations"});const c=r!==void 0&&Ca.includes(r)?r:"character";return l!==void 0?i.jsx(lM,{type:c,id:l},`${c}:${l}`):i.jsx(Bv,{type:c})}case"hooks":return i.jsx(jM,{});case"timeline":return r!==void 0?i.jsx(oA,{id:r},r):i.jsx(BM,{});case"trash":return i.jsx(uA,{});case"settings":return i.jsx(fA,{});default:return i.jsx(gv,{})}}function pA(){const n=dj();return i.jsx(s3,{route:n,children:mA(n)})}const BS=document.getElementById("root");if(!BS)throw new Error("#root 元素缺失(index.html)");aj.createRoot(BS).render(i.jsx(h.StrictMode,{children:i.jsx(o3,{children:i.jsx(pA,{})})}));