@whispering233/ai-editor-server 0.0.5 → 0.0.7

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 TN(n,r){for(var o=0;o<r.length;o++){const l=r[o];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 r=document.createElement("link").relList;if(r&&r.supports&&r.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 o(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=o(c);fetch(c.href,d)}})();function jv(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ef={exports:{}},yl={};var jb;function wN(){if(jb)return yl;jb=1;var n=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function o(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 yl.Fragment=r,yl.jsx=o,yl.jsxs=o,yl}var Tb;function CN(){return Tb||(Tb=1,Ef.exports=wN()),Ef.exports}var i=CN(),Nf={exports:{}},ot={};var wb;function RN(){if(wb)return ot;wb=1;var n=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),o=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"),h=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),S=Symbol.iterator;function j(D){return D===null||typeof D!="object"?null:(D=S&&D[S]||D["@@iterator"],typeof D=="function"?D:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,O={};function E(D,q,V){this.props=D,this.context=q,this.refs=O,this.updater=V||N}E.prototype.isReactComponent={},E.prototype.setState=function(D,q){if(typeof D!="object"&&typeof D!="function"&&D!=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,D,q,"setState")},E.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function T(){}T.prototype=E.prototype;function _(D,q,V){this.props=D,this.context=q,this.refs=O,this.updater=V||N}var w=_.prototype=new T;w.constructor=_,k(w,E.prototype),w.isPureReactComponent=!0;var I=Array.isArray;function A(){}var U={H:null,A:null,T:null,S:null},M=Object.prototype.hasOwnProperty;function K(D,q,V){var Q=V.ref;return{$$typeof:n,type:D,key:q,ref:Q!==void 0?Q:null,props:V}}function oe(D,q){return K(D.type,q,D.props)}function Z(D){return typeof D=="object"&&D!==null&&D.$$typeof===n}function ee(D){var q={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(V){return q[V]})}var G=/\/+/g;function te(D,q){return typeof D=="object"&&D!==null&&D.key!=null?ee(""+D.key):q.toString(36)}function X(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(A,A):(D.status="pending",D.then(function(q){D.status==="pending"&&(D.status="fulfilled",D.value=q)},function(q){D.status==="pending"&&(D.status="rejected",D.reason=q)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function C(D,q,V,Q,ne){var F=typeof D;(F==="undefined"||F==="boolean")&&(D=null);var Te=!1;if(D===null)Te=!0;else switch(F){case"bigint":case"string":case"number":Te=!0;break;case"object":switch(D.$$typeof){case n:case r:Te=!0;break;case v:return Te=D._init,C(Te(D._payload),q,V,Q,ne)}}if(Te)return ne=ne(D),Te=Q===""?"."+te(D,0):Q,I(ne)?(V="",Te!=null&&(V=Te.replace(G,"$&/")+"/"),C(ne,q,V,"",function(Le){return Le})):ne!=null&&(Z(ne)&&(ne=oe(ne,V+(ne.key==null||D&&D.key===ne.key?"":(""+ne.key).replace(G,"$&/")+"/")+Te)),q.push(ne)),1;Te=0;var me=Q===""?".":Q+":";if(I(D))for(var he=0;he<D.length;he++)Q=D[he],F=me+te(Q,he),Te+=C(Q,q,V,F,ne);else if(he=j(D),typeof he=="function")for(D=he.call(D),he=0;!(Q=D.next()).done;)Q=Q.value,F=me+te(Q,he++),Te+=C(Q,q,V,F,ne);else if(F==="object"){if(typeof D.then=="function")return C(X(D),q,V,Q,ne);throw q=String(D),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return Te}function B(D,q,V){if(D==null)return D;var Q=[],ne=0;return C(D,Q,"","",function(F){return q.call(V,F,ne++)}),Q}function H(D){if(D._status===-1){var q=D._result;q=q(),q.then(function(V){(D._status===0||D._status===-1)&&(D._status=1,D._result=V)},function(V){(D._status===0||D._status===-1)&&(D._status=2,D._result=V)}),D._status===-1&&(D._status=0,D._result=q)}if(D._status===1)return D._result.default;throw D._result}var z=typeof reportError=="function"?reportError:function(D){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof D=="object"&&D!==null&&typeof D.message=="string"?String(D.message):String(D),error:D});if(!window.dispatchEvent(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",D);return}console.error(D)},L={map:B,forEach:function(D,q,V){B(D,function(){q.apply(this,arguments)},V)},count:function(D){var q=0;return B(D,function(){q++}),q},toArray:function(D){return B(D,function(q){return q})||[]},only:function(D){if(!Z(D))throw Error("React.Children.only expected to receive a single React element child.");return D}};return ot.Activity=x,ot.Children=L,ot.Component=E,ot.Fragment=o,ot.Profiler=c,ot.PureComponent=_,ot.StrictMode=l,ot.Suspense=b,ot.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=U,ot.__COMPILER_RUNTIME={__proto__:null,c:function(D){return U.H.useMemoCache(D)}},ot.cache=function(D){return function(){return D.apply(null,arguments)}},ot.cacheSignal=function(){return null},ot.cloneElement=function(D,q,V){if(D==null)throw Error("The argument must be a React element, but you passed "+D+".");var Q=k({},D.props),ne=D.key;if(q!=null)for(F in q.key!==void 0&&(ne=""+q.key),q)!M.call(q,F)||F==="key"||F==="__self"||F==="__source"||F==="ref"&&q.ref===void 0||(Q[F]=q[F]);var F=arguments.length-2;if(F===1)Q.children=V;else if(1<F){for(var Te=Array(F),me=0;me<F;me++)Te[me]=arguments[me+2];Q.children=Te}return K(D.type,ne,Q)},ot.createContext=function(D){return D={$$typeof:m,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null},D.Provider=D,D.Consumer={$$typeof:d,_context:D},D},ot.createElement=function(D,q,V){var Q,ne={},F=null;if(q!=null)for(Q in q.key!==void 0&&(F=""+q.key),q)M.call(q,Q)&&Q!=="key"&&Q!=="__self"&&Q!=="__source"&&(ne[Q]=q[Q]);var Te=arguments.length-2;if(Te===1)ne.children=V;else if(1<Te){for(var me=Array(Te),he=0;he<Te;he++)me[he]=arguments[he+2];ne.children=me}if(D&&D.defaultProps)for(Q in Te=D.defaultProps,Te)ne[Q]===void 0&&(ne[Q]=Te[Q]);return K(D,F,ne)},ot.createRef=function(){return{current:null}},ot.forwardRef=function(D){return{$$typeof:g,render:D}},ot.isValidElement=Z,ot.lazy=function(D){return{$$typeof:v,_payload:{_status:-1,_result:D},_init:H}},ot.memo=function(D,q){return{$$typeof:h,type:D,compare:q===void 0?null:q}},ot.startTransition=function(D){var q=U.T,V={};U.T=V;try{var Q=D(),ne=U.S;ne!==null&&ne(V,Q),typeof Q=="object"&&Q!==null&&typeof Q.then=="function"&&Q.then(A,z)}catch(F){z(F)}finally{q!==null&&V.types!==null&&(q.types=V.types),U.T=q}},ot.unstable_useCacheRefresh=function(){return U.H.useCacheRefresh()},ot.use=function(D){return U.H.use(D)},ot.useActionState=function(D,q,V){return U.H.useActionState(D,q,V)},ot.useCallback=function(D,q){return U.H.useCallback(D,q)},ot.useContext=function(D){return U.H.useContext(D)},ot.useDebugValue=function(){},ot.useDeferredValue=function(D,q){return U.H.useDeferredValue(D,q)},ot.useEffect=function(D,q){return U.H.useEffect(D,q)},ot.useEffectEvent=function(D){return U.H.useEffectEvent(D)},ot.useId=function(){return U.H.useId()},ot.useImperativeHandle=function(D,q,V){return U.H.useImperativeHandle(D,q,V)},ot.useInsertionEffect=function(D,q){return U.H.useInsertionEffect(D,q)},ot.useLayoutEffect=function(D,q){return U.H.useLayoutEffect(D,q)},ot.useMemo=function(D,q){return U.H.useMemo(D,q)},ot.useOptimistic=function(D,q){return U.H.useOptimistic(D,q)},ot.useReducer=function(D,q,V){return U.H.useReducer(D,q,V)},ot.useRef=function(D){return U.H.useRef(D)},ot.useState=function(D){return U.H.useState(D)},ot.useSyncExternalStore=function(D,q,V){return U.H.useSyncExternalStore(D,q,V)},ot.useTransition=function(){return U.H.useTransition()},ot.version="19.2.8",ot}var Cb;function Vl(){return Cb||(Cb=1,Nf.exports=RN()),Nf.exports}var p=Vl();const _e=jv(p),ON=TN({__proto__:null,default:_e},[p]);var jf={exports:{}},vl={},Tf={exports:{}},wf={};var Rb;function kN(){return Rb||(Rb=1,(function(n){function r(C,B){var H=C.length;C.push(B);e:for(;0<H;){var z=H-1>>>1,L=C[z];if(0<c(L,B))C[z]=B,C[H]=L,H=z;else break e}}function o(C){return C.length===0?null:C[0]}function l(C){if(C.length===0)return null;var B=C[0],H=C.pop();if(H!==B){C[0]=H;e:for(var z=0,L=C.length,D=L>>>1;z<D;){var q=2*(z+1)-1,V=C[q],Q=q+1,ne=C[Q];if(0>c(V,H))Q<L&&0>c(ne,V)?(C[z]=ne,C[Q]=H,z=Q):(C[z]=V,C[q]=H,z=q);else if(Q<L&&0>c(ne,H))C[z]=ne,C[Q]=H,z=Q;else break e}}return B}function c(C,B){var H=C.sortIndex-B.sortIndex;return H!==0?H:C.id-B.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=[],h=[],v=1,x=null,S=3,j=!1,N=!1,k=!1,O=!1,E=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;function w(C){for(var B=o(h);B!==null;){if(B.callback===null)l(h);else if(B.startTime<=C)l(h),B.sortIndex=B.expirationTime,r(b,B);else break;B=o(h)}}function I(C){if(k=!1,w(C),!N)if(o(b)!==null)N=!0,A||(A=!0,ee());else{var B=o(h);B!==null&&X(I,B.startTime-C)}}var A=!1,U=-1,M=5,K=-1;function oe(){return O?!0:!(n.unstable_now()-K<M)}function Z(){if(O=!1,A){var C=n.unstable_now();K=C;var B=!0;try{e:{N=!1,k&&(k=!1,T(U),U=-1),j=!0;var H=S;try{t:{for(w(C),x=o(b);x!==null&&!(x.expirationTime>C&&oe());){var z=x.callback;if(typeof z=="function"){x.callback=null,S=x.priorityLevel;var L=z(x.expirationTime<=C);if(C=n.unstable_now(),typeof L=="function"){x.callback=L,w(C),B=!0;break t}x===o(b)&&l(b),w(C)}else l(b);x=o(b)}if(x!==null)B=!0;else{var D=o(h);D!==null&&X(I,D.startTime-C),B=!1}}break e}finally{x=null,S=H,j=!1}B=void 0}}finally{B?ee():A=!1}}}var ee;if(typeof _=="function")ee=function(){_(Z)};else if(typeof MessageChannel<"u"){var G=new MessageChannel,te=G.port2;G.port1.onmessage=Z,ee=function(){te.postMessage(null)}}else ee=function(){E(Z,0)};function X(C,B){U=E(function(){C(n.unstable_now())},B)}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(C){C.callback=null},n.unstable_forceFrameRate=function(C){0>C||125<C?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):M=0<C?Math.floor(1e3/C):5},n.unstable_getCurrentPriorityLevel=function(){return S},n.unstable_next=function(C){switch(S){case 1:case 2:case 3:var B=3;break;default:B=S}var H=S;S=B;try{return C()}finally{S=H}},n.unstable_requestPaint=function(){O=!0},n.unstable_runWithPriority=function(C,B){switch(C){case 1:case 2:case 3:case 4:case 5:break;default:C=3}var H=S;S=C;try{return B()}finally{S=H}},n.unstable_scheduleCallback=function(C,B,H){var z=n.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?z+H:z):H=z,C){case 1:var L=-1;break;case 2:L=250;break;case 5:L=1073741823;break;case 4:L=1e4;break;default:L=5e3}return L=H+L,C={id:v++,callback:B,priorityLevel:C,startTime:H,expirationTime:L,sortIndex:-1},H>z?(C.sortIndex=H,r(h,C),o(b)===null&&C===o(h)&&(k?(T(U),U=-1):k=!0,X(I,H-z))):(C.sortIndex=L,r(b,C),N||j||(N=!0,A||(A=!0,ee()))),C},n.unstable_shouldYield=oe,n.unstable_wrapCallback=function(C){var B=S;return function(){var H=S;S=B;try{return C.apply(this,arguments)}finally{S=H}}}})(wf)),wf}var Ob;function _N(){return Ob||(Ob=1,Tf.exports=kN()),Tf.exports}var Cf={exports:{}},vn={};var kb;function MN(){if(kb)return vn;kb=1;var n=Vl();function r(b){var h="https://react.dev/errors/"+b;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var v=2;v<arguments.length;v++)h+="&args[]="+encodeURIComponent(arguments[v])}return"Minified React error #"+b+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(){}var l={d:{f:o,r:function(){throw Error(r(522))},D:o,C:o,L:o,m:o,X:o,S:o,M:o},p:0,findDOMNode:null},c=Symbol.for("react.portal");function d(b,h,v){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:c,key:x==null?null:""+x,children:b,containerInfo:h,implementation:v}}var m=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function g(b,h){if(b==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return vn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=l,vn.createPortal=function(b,h){var v=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(r(299));return d(b,h,null,v)},vn.flushSync=function(b){var h=m.T,v=l.p;try{if(m.T=null,l.p=2,b)return b()}finally{m.T=h,l.p=v,l.d.f()}},vn.preconnect=function(b,h){typeof b=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,l.d.C(b,h))},vn.prefetchDNS=function(b){typeof b=="string"&&l.d.D(b)},vn.preinit=function(b,h){if(typeof b=="string"&&h&&typeof h.as=="string"){var v=h.as,x=g(v,h.crossOrigin),S=typeof h.integrity=="string"?h.integrity:void 0,j=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;v==="style"?l.d.S(b,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:x,integrity:S,fetchPriority:j}):v==="script"&&l.d.X(b,{crossOrigin:x,integrity:S,fetchPriority:j,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},vn.preinitModule=function(b,h){if(typeof b=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var v=g(h.as,h.crossOrigin);l.d.M(b,{crossOrigin:v,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&l.d.M(b)},vn.preload=function(b,h){if(typeof b=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var v=h.as,x=g(v,h.crossOrigin);l.d.L(b,v,{crossOrigin:x,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},vn.preloadModule=function(b,h){if(typeof b=="string")if(h){var v=g(h.as,h.crossOrigin);l.d.m(b,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:v,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else l.d.m(b)},vn.requestFormReset=function(b){l.d.r(b)},vn.unstable_batchedUpdates=function(b,h){return b(h)},vn.useFormState=function(b,h,v){return m.H.useFormState(b,h,v)},vn.useFormStatus=function(){return m.H.useHostTransitionStatus()},vn.version="19.2.8",vn}var _b;function Tv(){if(_b)return Cf.exports;_b=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(r){console.error(r)}}return n(),Cf.exports=MN(),Cf.exports}var Mb;function AN(){if(Mb)return vl;Mb=1;var n=_N(),r=Vl(),o=Tv();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 h(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"),N=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),_=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),oe=Symbol.for("react.memo_cache_sentinel"),Z=Symbol.iterator;function ee(e){return e===null||typeof e!="object"?null:(e=Z&&e[Z]||e["@@iterator"],typeof e=="function"?e:null)}var G=Symbol.for("react.client.reference");function te(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===G?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case k:return"Fragment";case E:return"Profiler";case O:return"StrictMode";case I:return"Suspense";case A:return"SuspenseList";case K:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case N:return"Portal";case _:return e.displayName||"Context";case T:return(e._context.displayName||"Context")+".Consumer";case w:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case U:return t=e.displayName||null,t!==null?t:te(e.type)||"Memo";case M:t=e._payload,e=e._init;try{return te(e(t))}catch{}}return null}var X=Array.isArray,C=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B=o.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H={pending:!1,data:null,method:null,action:null},z=[],L=-1;function D(e){return{current:e}}function q(e){0>L||(e.current=z[L],z[L]=null,L--)}function V(e,t){L++,z[L]=e.current,e.current=t}var Q=D(null),ne=D(null),F=D(null),Te=D(null);function me(e,t){switch(V(F,t),V(ne,e),V(Q,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Xx(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Xx(t),e=$x(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}q(Q),V(Q,e)}function he(){q(Q),q(ne),q(F)}function Le(e){e.memoizedState!==null&&V(Te,e);var t=Q.current,s=$x(t,e.type);t!==s&&(V(ne,e),V(Q,s))}function Ve(e){ne.current===e&&(q(Q),q(ne)),Te.current===e&&(q(Te),hl._currentValue=H)}var Re,ze;function De(e){if(Re===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);Re=t&&t[1]||"",ze=-1<s.stack.indexOf(`
2
+ at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
3
+ `+Re+e+ze}var ye=!1;function Be(e,t){if(!e||ye)return"";ye=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var a={DetermineComponentFrameRoot:function(){try{if(t){var Ne=function(){throw Error()};if(Object.defineProperty(Ne.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ne,[])}catch(pe){var ce=pe}Reflect.construct(e,[],Ne)}else{try{Ne.call()}catch(pe){ce=pe}e.call(Ne.prototype)}}else{try{throw Error()}catch(pe){ce=pe}(Ne=e())&&typeof Ne.catch=="function"&&Ne.catch(function(){})}}catch(pe){if(pe&&ce&&typeof pe.stack=="string")return[pe.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 P=y.split(`
4
+ `),ie=R.split(`
5
+ `);for(u=a=0;a<P.length&&!P[a].includes("DetermineComponentFrameRoot");)a++;for(;u<ie.length&&!ie[u].includes("DetermineComponentFrameRoot");)u++;if(a===P.length||u===ie.length)for(a=P.length-1,u=ie.length-1;1<=a&&0<=u&&P[a]!==ie[u];)u--;for(;1<=a&&0<=u;a--,u--)if(P[a]!==ie[u]){if(a!==1||u!==1)do if(a--,u--,0>u||P[a]!==ie[u]){var xe=`
6
+ `+P[a].replace(" at new "," at ");return e.displayName&&xe.includes("<anonymous>")&&(xe=xe.replace("<anonymous>",e.displayName)),xe}while(1<=a&&0<=u);break}}}finally{ye=!1,Error.prepareStackTrace=s}return(s=e?e.displayName||e.name:"")?De(s):""}function ae(e,t){switch(e.tag){case 26:case 27:case 5:return De(e.type);case 16:return De("Lazy");case 13:return e.child!==t&&t!==null?De("Suspense Fallback"):De("Suspense");case 19:return De("SuspenseList");case 0:case 15:return Be(e.type,!1);case 11:return Be(e.type.render,!1);case 1:return Be(e.type,!0);case 31:return De("Activity");default:return""}}function de(e){try{var t="",s=null;do t+=ae(e,s),s=e,e=e.return;while(e);return t}catch(a){return`
7
+ Error generating stack: `+a.message+`
8
+ `+a.stack}}var ue=Object.prototype.hasOwnProperty,Ce=n.unstable_scheduleCallback,fe=n.unstable_cancelCallback,be=n.unstable_shouldYield,qe=n.unstable_requestPaint,se=n.unstable_now,Y=n.unstable_getCurrentPriorityLevel,ge=n.unstable_ImmediatePriority,J=n.unstable_UserBlockingPriority,we=n.unstable_NormalPriority,Xe=n.unstable_LowPriority,je=n.unstable_IdlePriority,Me=n.log,$e=n.unstable_setDisableYieldValue,rt=null,Nt=null;function kt(e){if(typeof Me=="function"&&$e(e),Nt&&typeof Nt.setStrictMode=="function")try{Nt.setStrictMode(rt,e)}catch{}}var bt=Math.clz32?Math.clz32:Ke,yn=Math.log,an=Math.LN2;function Ke(e){return e>>>=0,e===0?32:31-(yn(e)/an|0)|0}var Tt=256,tn=262144,qt=4194304;function re(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 ve(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=re(a):(y&=R,y!==0?u=re(y):s||(s=R&~e,s!==0&&(u=re(s))))):(R=a&~f,R!==0?u=re(R):y!==0?u=re(y):s||(s=a&~e,s!==0&&(u=re(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 Qe(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 tt(){var e=qt;return qt<<=1,(qt&62914560)===0&&(qt=4194304),e}function at(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function st(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Pt(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,P=e.expirationTimes,ie=e.hiddenUpdates;for(s=y&~s;0<s;){var xe=31-bt(s),Ne=1<<xe;R[xe]=0,P[xe]=-1;var ce=ie[xe];if(ce!==null)for(ie[xe]=null,xe=0;xe<ce.length;xe++){var pe=ce[xe];pe!==null&&(pe.lane&=-536870913)}s&=~Ne}a!==0&&Xn(e,a,0),f!==0&&u===0&&e.tag!==0&&(e.suspendedLanes|=f&~(y&~t))}function Xn(e,t,s){e.pendingLanes|=t,e.suspendedLanes&=~t;var a=31-bt(t);e.entangledLanes|=t,e.entanglements[a]=e.entanglements[a]|1073741824|s&261930}function $t(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var a=31-bt(s),u=1<<a;u&t|e[a]&t&&(e[a]|=t),s&=~u}}function mn(e,t){var s=t&-t;return s=(s&42)!==0?1:dr(s),(s&(e.suspendedLanes|t))!==0?0:s}function dr(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 Rs(){var e=B.p;return e!==0?e:(e=window.event,e===void 0?32:xb(e.type))}function Kl(e,t){var s=B.p;try{return B.p=e,t()}finally{B.p=s}}var ps=Math.random().toString(36).slice(2),nn="__reactFiber$"+ps,wn="__reactProps$"+ps,Oo="__reactContainer$"+ps,fu="__reactEvents$"+ps,pS="__reactListeners$"+ps,hS="__reactHandles$"+ps,Dp="__reactResources$"+ps,ka="__reactMarker$"+ps;function mu(e){delete e[nn],delete e[wn],delete e[fu],delete e[pS],delete e[hS]}function ko(e){var t=e[nn];if(t)return t;for(var s=e.parentNode;s;){if(t=s[Oo]||s[nn]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=tb(e);e!==null;){if(s=e[nn])return s;e=tb(e)}return t}e=s,s=e.parentNode}return null}function _o(e){if(e=e[nn]||e[Oo]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function _a(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(l(33))}function Mo(e){var t=e[Dp];return t||(t=e[Dp]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function ln(e){e[ka]=!0}var zp=new Set,Lp={};function Fr(e,t){Ao(e,t),Ao(e+"Capture",t)}function Ao(e,t){for(Lp[e]=t,e=0;e<t.length;e++)zp.add(t[e])}var gS=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]*$"),Ip={},Bp={};function xS(e){return ue.call(Bp,e)?!0:ue.call(Ip,e)?!1:gS.test(e)?Bp[e]=!0:(Ip[e]=!0,!1)}function Ql(e,t,s){if(xS(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 Zl(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 Os(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 $n(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Up(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function bS(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 pu(e){if(!e._valueTracker){var t=Up(e)?"checked":"value";e._valueTracker=bS(e,t,""+e[t])}}function Hp(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),a="";return e&&(a=Up(e)?e.checked?"true":"false":e.value),e=a,e!==s?(t.setValue(e),!0):!1}function Jl(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 yS=/[\n"\\]/g;function Kn(e){return e.replace(yS,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function hu(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=""+$n(t)):e.value!==""+$n(t)&&(e.value=""+$n(t)):y!=="submit"&&y!=="reset"||e.removeAttribute("value"),t!=null?gu(e,y,$n(t)):s!=null?gu(e,y,$n(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=""+$n(R):e.removeAttribute("name")}function Yp(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)){pu(e);return}s=s!=null?""+$n(s):"",t=t!=null?""+$n(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),pu(e)}function gu(e,t,s){t==="number"&&Jl(e.ownerDocument)===e||e.defaultValue===""+s||(e.defaultValue=""+s)}function Do(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=""+$n(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 Pp(e,t,s){if(t!=null&&(t=""+$n(t),t!==e.value&&(e.value=t),s==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=s!=null?""+$n(s):""}function Vp(e,t,s,a){if(t==null){if(a!=null){if(s!=null)throw Error(l(92));if(X(a)){if(1<a.length)throw Error(l(93));a=a[0]}s=a}s==null&&(s=""),t=s}s=$n(t),e.defaultValue=s,a=e.textContent,a===s&&a!==""&&a!==null&&(e.value=a),pu(e)}function zo(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var vS=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 qp(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||vS.has(t)?t==="float"?e.cssFloat=s:e[t]=(""+s).trim():e[t]=s+"px"}function Fp(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&&qp(e,u,a)}else for(var f in t)t.hasOwnProperty(f)&&qp(e,f,t[f])}function xu(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 SS=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"]]),ES=/^[\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 Wl(e){return ES.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function ks(){}var bu=null;function yu(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Lo=null,Io=null;function Gp(e){var t=_o(e);if(t&&(e=t.stateNode)){var s=e[wn]||null;e:switch(e=t.stateNode,t.type){case"input":if(hu(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));hu(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&&Hp(a)}break e;case"textarea":Pp(e,s.value,s.defaultValue);break e;case"select":t=s.value,t!=null&&Do(e,!!s.multiple,t,!1)}}}var vu=!1;function Xp(e,t,s){if(vu)return e(t,s);vu=!0;try{var a=e(t);return a}finally{if(vu=!1,(Lo!==null||Io!==null)&&(Hi(),Lo&&(t=Lo,e=Io,Io=Lo=null,Gp(t),e)))for(t=0;t<e.length;t++)Gp(e[t])}}function Ma(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 _s=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Su=!1;if(_s)try{var Aa={};Object.defineProperty(Aa,"passive",{get:function(){Su=!0}}),window.addEventListener("test",Aa,Aa),window.removeEventListener("test",Aa,Aa)}catch{Su=!1}var fr=null,Eu=null,ei=null;function $p(){if(ei)return ei;var e,t=Eu,s=t.length,a,u="value"in fr?fr.value:fr.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 ei=u.slice(e,1<a?1-a:void 0)}function ti(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 ni(){return!0}function Kp(){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)?ni:Kp,this.isPropagationStopped=Kp,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=ni)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=ni)},persist:function(){},isPersistent:ni}),t}var Gr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},si=Cn(Gr),Da=x({},Gr,{view:0,detail:0}),NS=Cn(Da),Nu,ju,za,ri=x({},Da,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:wu,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!==za&&(za&&e.type==="mousemove"?(Nu=e.screenX-za.screenX,ju=e.screenY-za.screenY):ju=Nu=0,za=e),Nu)},movementY:function(e){return"movementY"in e?e.movementY:ju}}),Qp=Cn(ri),jS=x({},ri,{dataTransfer:0}),TS=Cn(jS),wS=x({},Da,{relatedTarget:0}),Tu=Cn(wS),CS=x({},Gr,{animationName:0,elapsedTime:0,pseudoElement:0}),RS=Cn(CS),OS=x({},Gr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),kS=Cn(OS),_S=x({},Gr,{data:0}),Zp=Cn(_S),MS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},AS={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"},DS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function zS(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=DS[e])?!!t[e]:!1}function wu(){return zS}var LS=x({},Da,{key:function(e){if(e.key){var t=MS[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ti(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?AS[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:wu,charCode:function(e){return e.type==="keypress"?ti(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ti(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),IS=Cn(LS),BS=x({},ri,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Jp=Cn(BS),US=x({},Da,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:wu}),HS=Cn(US),YS=x({},Gr,{propertyName:0,elapsedTime:0,pseudoElement:0}),PS=Cn(YS),VS=x({},ri,{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}),qS=Cn(VS),FS=x({},Gr,{newState:0,oldState:0}),GS=Cn(FS),XS=[9,13,27,32],Cu=_s&&"CompositionEvent"in window,La=null;_s&&"documentMode"in document&&(La=document.documentMode);var $S=_s&&"TextEvent"in window&&!La,Wp=_s&&(!Cu||La&&8<La&&11>=La),eh=" ",th=!1;function nh(e,t){switch(e){case"keyup":return XS.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function sh(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Bo=!1;function KS(e,t){switch(e){case"compositionend":return sh(t);case"keypress":return t.which!==32?null:(th=!0,eh);case"textInput":return e=t.data,e===eh&&th?null:e;default:return null}}function QS(e,t){if(Bo)return e==="compositionend"||!Cu&&nh(e,t)?(e=$p(),ei=Eu=fr=null,Bo=!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 Wp&&t.locale!=="ko"?null:t.data;default:return null}}var ZS={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 rh(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!ZS[e.type]:t==="textarea"}function oh(e,t,s,a){Lo?Io?Io.push(a):Io=[a]:Lo=a,t=Xi(t,"onChange"),0<t.length&&(s=new si("onChange","change",null,s,a),e.push({event:s,listeners:t}))}var Ia=null,Ba=null;function JS(e){Yx(e,0)}function oi(e){var t=_a(e);if(Hp(t))return e}function ah(e,t){if(e==="change")return t}var lh=!1;if(_s){var Ru;if(_s){var Ou="oninput"in document;if(!Ou){var ih=document.createElement("div");ih.setAttribute("oninput","return;"),Ou=typeof ih.oninput=="function"}Ru=Ou}else Ru=!1;lh=Ru&&(!document.documentMode||9<document.documentMode)}function ch(){Ia&&(Ia.detachEvent("onpropertychange",uh),Ba=Ia=null)}function uh(e){if(e.propertyName==="value"&&oi(Ba)){var t=[];oh(t,Ba,e,yu(e)),Xp(JS,t)}}function WS(e,t,s){e==="focusin"?(ch(),Ia=t,Ba=s,Ia.attachEvent("onpropertychange",uh)):e==="focusout"&&ch()}function eE(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return oi(Ba)}function tE(e,t){if(e==="click")return oi(t)}function nE(e,t){if(e==="input"||e==="change")return oi(t)}function sE(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var In=typeof Object.is=="function"?Object.is:sE;function Ua(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(!ue.call(t,u)||!In(e[u],t[u]))return!1}return!0}function dh(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function fh(e,t){var s=dh(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=dh(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 ph(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Jl(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=Jl(e.document)}return t}function ku(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 rE=_s&&"documentMode"in document&&11>=document.documentMode,Uo=null,_u=null,Ha=null,Mu=!1;function hh(e,t,s){var a=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;Mu||Uo==null||Uo!==Jl(a)||(a=Uo,"selectionStart"in a&&ku(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}),Ha&&Ua(Ha,a)||(Ha=a,a=Xi(_u,"onSelect"),0<a.length&&(t=new si("onSelect","select",null,t,s),e.push({event:t,listeners:a}),t.target=Uo)))}function Xr(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var Ho={animationend:Xr("Animation","AnimationEnd"),animationiteration:Xr("Animation","AnimationIteration"),animationstart:Xr("Animation","AnimationStart"),transitionrun:Xr("Transition","TransitionRun"),transitionstart:Xr("Transition","TransitionStart"),transitioncancel:Xr("Transition","TransitionCancel"),transitionend:Xr("Transition","TransitionEnd")},Au={},gh={};_s&&(gh=document.createElement("div").style,"AnimationEvent"in window||(delete Ho.animationend.animation,delete Ho.animationiteration.animation,delete Ho.animationstart.animation),"TransitionEvent"in window||delete Ho.transitionend.transition);function $r(e){if(Au[e])return Au[e];if(!Ho[e])return e;var t=Ho[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in gh)return Au[e]=t[s];return e}var xh=$r("animationend"),bh=$r("animationiteration"),yh=$r("animationstart"),oE=$r("transitionrun"),aE=$r("transitionstart"),lE=$r("transitioncancel"),vh=$r("transitionend"),Sh=new Map,Du="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(" ");Du.push("scrollEnd");function is(e,t){Sh.set(e,t),Fr(t,[e])}var ai=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=[],Yo=0,zu=0;function li(){for(var e=Yo,t=zu=Yo=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&&Eh(s,u,f)}}function ii(e,t,s,a){Qn[Yo++]=e,Qn[Yo++]=t,Qn[Yo++]=s,Qn[Yo++]=a,zu|=a,e.lanes|=a,e=e.alternate,e!==null&&(e.lanes|=a)}function Lu(e,t,s,a){return ii(e,t,s,a),ci(e)}function Kr(e,t){return ii(e,null,null,t),ci(e)}function Eh(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-bt(s),e=f.hiddenUpdates,a=e[u],a===null?e[u]=[t]:a.push(t),t.lane=s|536870912),f):null}function ci(e){if(50<il)throw il=0,Fd=null,Error(l(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Po={};function iE(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 iE(e,t,s,a)}function Iu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Ms(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 Nh(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 ui(e,t,s,a,u,f){var y=0;if(a=e,typeof e=="function")Iu(e)&&(y=1);else if(typeof e=="string")y=mN(e,s,Q.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 k:return Qr(s.children,u,f,t);case O:y=8,u|=24;break;case E:return e=Bn(12,s,t,u|2),e.elementType=E,e.lanes=f,e;case I:return e=Bn(13,s,t,u),e.elementType=I,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 _:y=10;break e;case T:y=9;break e;case w:y=11;break e;case U:y=14;break e;case M: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 Qr(e,t,s,a){return e=Bn(7,e,a,t),e.lanes=s,e}function Bu(e,t,s){return e=Bn(6,e,null,t),e.lanes=s,e}function jh(e){var t=Bn(18,null,null,0);return t.stateNode=e,t}function Uu(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 Th=new WeakMap;function Zn(e,t){if(typeof e=="object"&&e!==null){var s=Th.get(e);return s!==void 0?s:(t={value:e,source:t,stack:de(t)},Th.set(e,t),t)}return{value:e,source:t,stack:de(t)}}var Vo=[],qo=0,di=null,Ya=0,Jn=[],Wn=0,mr=null,hs=1,gs="";function As(e,t){Vo[qo++]=Ya,Vo[qo++]=di,di=e,Ya=t}function wh(e,t,s){Jn[Wn++]=hs,Jn[Wn++]=gs,Jn[Wn++]=mr,mr=e;var a=hs;e=gs;var u=32-bt(a)-1;a&=~(1<<u),s+=1;var f=32-bt(t)+u;if(30<f){var y=u-u%5;f=(a&(1<<y)-1).toString(32),a>>=y,u-=y,hs=1<<32-bt(t)+u|s<<u|a,gs=f+e}else hs=1<<f|s<<u|a,gs=e}function Hu(e){e.return!==null&&(As(e,1),wh(e,1,0))}function Yu(e){for(;e===di;)di=Vo[--qo],Vo[qo]=null,Ya=Vo[--qo],Vo[qo]=null;for(;e===mr;)mr=Jn[--Wn],Jn[Wn]=null,gs=Jn[--Wn],Jn[Wn]=null,hs=Jn[--Wn],Jn[Wn]=null}function Ch(e,t){Jn[Wn++]=hs,Jn[Wn++]=gs,Jn[Wn++]=mr,hs=t.id,gs=t.overflow,mr=e}var pn=null,Ht=null,yt=!1,pr=null,es=!1,Pu=Error(l(519));function hr(e){var t=Error(l(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Pa(Zn(t,e)),Pu}function Rh(e){var t=e.stateNode,s=e.type,a=e.memoizedProps;switch(t[nn]=e,t[wn]=a,s){case"dialog":mt("cancel",t),mt("close",t);break;case"iframe":case"object":case"embed":mt("load",t);break;case"video":case"audio":for(s=0;s<ul.length;s++)mt(ul[s],t);break;case"source":mt("error",t);break;case"img":case"image":case"link":mt("error",t),mt("load",t);break;case"details":mt("toggle",t);break;case"input":mt("invalid",t),Yp(t,a.value,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name,!0);break;case"select":mt("invalid",t);break;case"textarea":mt("invalid",t),Vp(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||Fx(t.textContent,s)?(a.popover!=null&&(mt("beforetoggle",t),mt("toggle",t)),a.onScroll!=null&&mt("scroll",t),a.onScrollEnd!=null&&mt("scrollend",t),a.onClick!=null&&(t.onclick=ks),t=!0):t=!1,t||hr(e,!0)}function Oh(e){for(pn=e.return;pn;)switch(pn.tag){case 5:case 31:case 13:es=!1;return;case 27:case 3:es=!0;return;default:pn=pn.return}}function Fo(e){if(e!==pn)return!1;if(!yt)return Oh(e),yt=!0,!1;var t=e.tag,s;if((s=t!==3&&t!==27)&&((s=t===5)&&(s=e.type,s=!(s!=="form"&&s!=="button")||af(e.type,e.memoizedProps)),s=!s),s&&Ht&&hr(e),Oh(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));Ht=eb(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));Ht=eb(e)}else t===27?(t=Ht,Or(e.type)?(e=ff,ff=null,Ht=e):Ht=t):Ht=pn?ns(e.stateNode.nextSibling):null;return!0}function Zr(){Ht=pn=null,yt=!1}function Vu(){var e=pr;return e!==null&&(_n===null?_n=e:_n.push.apply(_n,e),pr=null),e}function Pa(e){pr===null?pr=[e]:pr.push(e)}var qu=D(null),Jr=null,Ds=null;function gr(e,t,s){V(qu,t._currentValue),t._currentValue=s}function zs(e){e._currentValue=qu.current,q(qu)}function Fu(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 Gu(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 P=0;P<t.length;P++)if(R.context===t[P]){f.lanes|=s,R=f.alternate,R!==null&&(R.lanes|=s),Fu(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),Fu(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 Go(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===Te.current){if(y=u.alternate,y===null)throw Error(l(387));y.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(e!==null?e.push(hl):e=[hl])}u=u.return}e!==null&&Gu(t,e,s,a),t.flags|=262144}function fi(e){for(e=e.firstContext;e!==null;){if(!In(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Wr(e){Jr=e,Ds=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function hn(e){return kh(Jr,e)}function mi(e,t){return Jr===null&&Wr(e),kh(e,t)}function kh(e,t){var s=t._currentValue;if(t={context:t,memoizedValue:s,next:null},Ds===null){if(e===null)throw Error(l(308));Ds=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Ds=Ds.next=t;return s}var cE=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()})}},uE=n.unstable_scheduleCallback,dE=n.unstable_NormalPriority,Zt={$$typeof:_,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Xu(){return{controller:new cE,data:new Map,refCount:0}}function Va(e){e.refCount--,e.refCount===0&&uE(dE,function(){e.controller.abort()})}var qa=null,$u=0,Xo=0,$o=null;function fE(e,t){if(qa===null){var s=qa=[];$u=0,Xo=Zd(),$o={status:"pending",value:void 0,then:function(a){s.push(a)}}}return $u++,t.then(_h,_h),t}function _h(){if(--$u===0&&qa!==null){$o!==null&&($o.status="fulfilled");var e=qa;qa=null,Xo=0,$o=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function mE(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 Mh=C.S;C.S=function(e,t){hx=se(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&fE(e,t),Mh!==null&&Mh(e,t)};var eo=D(null);function Ku(){var e=eo.current;return e!==null?e:It.pooledCache}function pi(e,t){t===null?V(eo,eo.current):V(eo,t.pool)}function Ah(){var e=Ku();return e===null?null:{parent:Zt._currentValue,pool:e}}var Ko=Error(l(460)),Qu=Error(l(474)),hi=Error(l(542)),gi={then:function(){}};function Dh(e){return e=e.status,e==="fulfilled"||e==="rejected"}function zh(e,t,s){switch(s=e[s],s===void 0?e.push(t):s!==t&&(t.then(ks,ks),t=s),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Ih(e),e;default:if(typeof t.status=="string")t.then(ks,ks);else{if(e=It,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,Ih(e),e}throw no=t,Ko}}function to(e){try{var t=e._init;return t(e._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?(no=s,Ko):s}}var no=null;function Lh(){if(no===null)throw Error(l(459));var e=no;return no=null,e}function Ih(e){if(e===Ko||e===hi)throw Error(l(483))}var Qo=null,Fa=0;function xi(e){var t=Fa;return Fa+=1,Qo===null&&(Qo=[]),zh(Qo,e,t)}function Ga(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function bi(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 Bh(e){function t(W,$){if(e){var le=W.deletions;le===null?(W.deletions=[$],W.flags|=16):le.push($)}}function s(W,$){if(!e)return null;for(;$!==null;)t(W,$),$=$.sibling;return null}function a(W){for(var $=new Map;W!==null;)W.key!==null?$.set(W.key,W):$.set(W.index,W),W=W.sibling;return $}function u(W,$){return W=Ms(W,$),W.index=0,W.sibling=null,W}function f(W,$,le){return W.index=le,e?(le=W.alternate,le!==null?(le=le.index,le<$?(W.flags|=67108866,$):le):(W.flags|=67108866,$)):(W.flags|=1048576,$)}function y(W){return e&&W.alternate===null&&(W.flags|=67108866),W}function R(W,$,le,Ee){return $===null||$.tag!==6?($=Bu(le,W.mode,Ee),$.return=W,$):($=u($,le),$.return=W,$)}function P(W,$,le,Ee){var Ze=le.type;return Ze===k?xe(W,$,le.props.children,Ee,le.key):$!==null&&($.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===M&&to(Ze)===$.type)?($=u($,le.props),Ga($,le),$.return=W,$):($=ui(le.type,le.key,le.props,null,W.mode,Ee),Ga($,le),$.return=W,$)}function ie(W,$,le,Ee){return $===null||$.tag!==4||$.stateNode.containerInfo!==le.containerInfo||$.stateNode.implementation!==le.implementation?($=Uu(le,W.mode,Ee),$.return=W,$):($=u($,le.children||[]),$.return=W,$)}function xe(W,$,le,Ee,Ze){return $===null||$.tag!==7?($=Qr(le,W.mode,Ee,Ze),$.return=W,$):($=u($,le),$.return=W,$)}function Ne(W,$,le){if(typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint")return $=Bu(""+$,W.mode,le),$.return=W,$;if(typeof $=="object"&&$!==null){switch($.$$typeof){case j:return le=ui($.type,$.key,$.props,null,W.mode,le),Ga(le,$),le.return=W,le;case N:return $=Uu($,W.mode,le),$.return=W,$;case M:return $=to($),Ne(W,$,le)}if(X($)||ee($))return $=Qr($,W.mode,le,null),$.return=W,$;if(typeof $.then=="function")return Ne(W,xi($),le);if($.$$typeof===_)return Ne(W,mi(W,$),le);bi(W,$)}return null}function ce(W,$,le,Ee){var Ze=$!==null?$.key:null;if(typeof le=="string"&&le!==""||typeof le=="number"||typeof le=="bigint")return Ze!==null?null:R(W,$,""+le,Ee);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case j:return le.key===Ze?P(W,$,le,Ee):null;case N:return le.key===Ze?ie(W,$,le,Ee):null;case M:return le=to(le),ce(W,$,le,Ee)}if(X(le)||ee(le))return Ze!==null?null:xe(W,$,le,Ee,null);if(typeof le.then=="function")return ce(W,$,xi(le),Ee);if(le.$$typeof===_)return ce(W,$,mi(W,le),Ee);bi(W,le)}return null}function pe(W,$,le,Ee,Ze){if(typeof Ee=="string"&&Ee!==""||typeof Ee=="number"||typeof Ee=="bigint")return W=W.get(le)||null,R($,W,""+Ee,Ze);if(typeof Ee=="object"&&Ee!==null){switch(Ee.$$typeof){case j:return W=W.get(Ee.key===null?le:Ee.key)||null,P($,W,Ee,Ze);case N:return W=W.get(Ee.key===null?le:Ee.key)||null,ie($,W,Ee,Ze);case M:return Ee=to(Ee),pe(W,$,le,Ee,Ze)}if(X(Ee)||ee(Ee))return W=W.get(le)||null,xe($,W,Ee,Ze,null);if(typeof Ee.then=="function")return pe(W,$,le,xi(Ee),Ze);if(Ee.$$typeof===_)return pe(W,$,le,mi($,Ee),Ze);bi($,Ee)}return null}function Pe(W,$,le,Ee){for(var Ze=null,wt=null,Fe=$,it=$=0,gt=null;Fe!==null&&it<le.length;it++){Fe.index>it?(gt=Fe,Fe=null):gt=Fe.sibling;var Ct=ce(W,Fe,le[it],Ee);if(Ct===null){Fe===null&&(Fe=gt);break}e&&Fe&&Ct.alternate===null&&t(W,Fe),$=f(Ct,$,it),wt===null?Ze=Ct:wt.sibling=Ct,wt=Ct,Fe=gt}if(it===le.length)return s(W,Fe),yt&&As(W,it),Ze;if(Fe===null){for(;it<le.length;it++)Fe=Ne(W,le[it],Ee),Fe!==null&&($=f(Fe,$,it),wt===null?Ze=Fe:wt.sibling=Fe,wt=Fe);return yt&&As(W,it),Ze}for(Fe=a(Fe);it<le.length;it++)gt=pe(Fe,W,it,le[it],Ee),gt!==null&&(e&&gt.alternate!==null&&Fe.delete(gt.key===null?it:gt.key),$=f(gt,$,it),wt===null?Ze=gt:wt.sibling=gt,wt=gt);return e&&Fe.forEach(function(Dr){return t(W,Dr)}),yt&&As(W,it),Ze}function Je(W,$,le,Ee){if(le==null)throw Error(l(151));for(var Ze=null,wt=null,Fe=$,it=$=0,gt=null,Ct=le.next();Fe!==null&&!Ct.done;it++,Ct=le.next()){Fe.index>it?(gt=Fe,Fe=null):gt=Fe.sibling;var Dr=ce(W,Fe,Ct.value,Ee);if(Dr===null){Fe===null&&(Fe=gt);break}e&&Fe&&Dr.alternate===null&&t(W,Fe),$=f(Dr,$,it),wt===null?Ze=Dr:wt.sibling=Dr,wt=Dr,Fe=gt}if(Ct.done)return s(W,Fe),yt&&As(W,it),Ze;if(Fe===null){for(;!Ct.done;it++,Ct=le.next())Ct=Ne(W,Ct.value,Ee),Ct!==null&&($=f(Ct,$,it),wt===null?Ze=Ct:wt.sibling=Ct,wt=Ct);return yt&&As(W,it),Ze}for(Fe=a(Fe);!Ct.done;it++,Ct=le.next())Ct=pe(Fe,W,it,Ct.value,Ee),Ct!==null&&(e&&Ct.alternate!==null&&Fe.delete(Ct.key===null?it:Ct.key),$=f(Ct,$,it),wt===null?Ze=Ct:wt.sibling=Ct,wt=Ct);return e&&Fe.forEach(function(jN){return t(W,jN)}),yt&&As(W,it),Ze}function zt(W,$,le,Ee){if(typeof le=="object"&&le!==null&&le.type===k&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case j:e:{for(var Ze=le.key;$!==null;){if($.key===Ze){if(Ze=le.type,Ze===k){if($.tag===7){s(W,$.sibling),Ee=u($,le.props.children),Ee.return=W,W=Ee;break e}}else if($.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===M&&to(Ze)===$.type){s(W,$.sibling),Ee=u($,le.props),Ga(Ee,le),Ee.return=W,W=Ee;break e}s(W,$);break}else t(W,$);$=$.sibling}le.type===k?(Ee=Qr(le.props.children,W.mode,Ee,le.key),Ee.return=W,W=Ee):(Ee=ui(le.type,le.key,le.props,null,W.mode,Ee),Ga(Ee,le),Ee.return=W,W=Ee)}return y(W);case N:e:{for(Ze=le.key;$!==null;){if($.key===Ze)if($.tag===4&&$.stateNode.containerInfo===le.containerInfo&&$.stateNode.implementation===le.implementation){s(W,$.sibling),Ee=u($,le.children||[]),Ee.return=W,W=Ee;break e}else{s(W,$);break}else t(W,$);$=$.sibling}Ee=Uu(le,W.mode,Ee),Ee.return=W,W=Ee}return y(W);case M:return le=to(le),zt(W,$,le,Ee)}if(X(le))return Pe(W,$,le,Ee);if(ee(le)){if(Ze=ee(le),typeof Ze!="function")throw Error(l(150));return le=Ze.call(le),Je(W,$,le,Ee)}if(typeof le.then=="function")return zt(W,$,xi(le),Ee);if(le.$$typeof===_)return zt(W,$,mi(W,le),Ee);bi(W,le)}return typeof le=="string"&&le!==""||typeof le=="number"||typeof le=="bigint"?(le=""+le,$!==null&&$.tag===6?(s(W,$.sibling),Ee=u($,le),Ee.return=W,W=Ee):(s(W,$),Ee=Bu(le,W.mode,Ee),Ee.return=W,W=Ee),y(W)):s(W,$)}return function(W,$,le,Ee){try{Fa=0;var Ze=zt(W,$,le,Ee);return Qo=null,Ze}catch(Fe){if(Fe===Ko||Fe===hi)throw Fe;var wt=Bn(29,Fe,null,W.mode);return wt.lanes=Ee,wt.return=W,wt}}}var so=Bh(!0),Uh=Bh(!1),xr=!1;function Zu(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ju(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 br(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function yr(e,t,s){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(Rt&2)!==0){var u=a.pending;return u===null?t.next=t:(t.next=u.next,u.next=t),a.pending=t,t=ci(e),Eh(e,null,s),t}return ii(e,a,t,s),ci(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,$t(e,s)}}function Wu(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 ed=!1;function $a(){if(ed){var e=$o;if(e!==null)throw e}}function Ka(e,t,s,a){ed=!1;var u=e.updateQueue;xr=!1;var f=u.firstBaseUpdate,y=u.lastBaseUpdate,R=u.shared.pending;if(R!==null){u.shared.pending=null;var P=R,ie=P.next;P.next=null,y===null?f=ie:y.next=ie,y=P;var xe=e.alternate;xe!==null&&(xe=xe.updateQueue,R=xe.lastBaseUpdate,R!==y&&(R===null?xe.firstBaseUpdate=ie:R.next=ie,xe.lastBaseUpdate=P))}if(f!==null){var Ne=u.baseState;y=0,xe=ie=P=null,R=f;do{var ce=R.lane&-536870913,pe=ce!==R.lane;if(pe?(ht&ce)===ce:(a&ce)===ce){ce!==0&&ce===Xo&&(ed=!0),xe!==null&&(xe=xe.next={lane:0,tag:R.tag,payload:R.payload,callback:null,next:null});e:{var Pe=e,Je=R;ce=t;var zt=s;switch(Je.tag){case 1:if(Pe=Je.payload,typeof Pe=="function"){Ne=Pe.call(zt,Ne,ce);break e}Ne=Pe;break e;case 3:Pe.flags=Pe.flags&-65537|128;case 0:if(Pe=Je.payload,ce=typeof Pe=="function"?Pe.call(zt,Ne,ce):Pe,ce==null)break e;Ne=x({},Ne,ce);break e;case 2:xr=!0}}ce=R.callback,ce!==null&&(e.flags|=64,pe&&(e.flags|=8192),pe=u.callbacks,pe===null?u.callbacks=[ce]:pe.push(ce))}else pe={lane:ce,tag:R.tag,payload:R.payload,callback:R.callback,next:null},xe===null?(ie=xe=pe,P=Ne):xe=xe.next=pe,y|=ce;if(R=R.next,R===null){if(R=u.shared.pending,R===null)break;pe=R,R=pe.next,pe.next=null,u.lastBaseUpdate=pe,u.shared.pending=null}}while(!0);xe===null&&(P=Ne),u.baseState=P,u.firstBaseUpdate=ie,u.lastBaseUpdate=xe,f===null&&(u.shared.lanes=0),jr|=y,e.lanes=y,e.memoizedState=Ne}}function Hh(e,t){if(typeof e!="function")throw Error(l(191,e));e.call(t)}function Yh(e,t){var s=e.callbacks;if(s!==null)for(e.callbacks=null,e=0;e<s.length;e++)Hh(s[e],t)}var Zo=D(null),yi=D(0);function Ph(e,t){e=qs,V(yi,e),V(Zo,t),qs=e|t.baseLanes}function td(){V(yi,qs),V(Zo,Zo.current)}function nd(){qs=yi.current,q(Zo),q(yi)}var Un=D(null),ts=null;function vr(e){var t=e.alternate;V(Kt,Kt.current&1),V(Un,e),ts===null&&(t===null||Zo.current!==null||t.memoizedState!==null)&&(ts=e)}function sd(e){V(Kt,Kt.current),V(Un,e),ts===null&&(ts=e)}function Vh(e){e.tag===22?(V(Kt,Kt.current),V(Un,e),ts===null&&(ts=e)):Sr()}function Sr(){V(Kt,Kt.current),V(Un,Un.current)}function Hn(e){q(Un),ts===e&&(ts=null),q(Kt)}var Kt=D(0);function vi(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||uf(s)||df(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 Ls=0,lt=null,At=null,Jt=null,Si=!1,Jo=!1,ro=!1,Ei=0,Qa=0,Wo=null,pE=0;function Ft(){throw Error(l(321))}function rd(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 od(e,t,s,a,u,f){return Ls=f,lt=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,C.H=e===null||e.memoizedState===null?wg:vd,ro=!1,f=s(a,u),ro=!1,Jo&&(f=Fh(t,s,a,u)),qh(e),f}function qh(e){C.H=Wa;var t=At!==null&&At.next!==null;if(Ls=0,Jt=At=lt=null,Si=!1,Qa=0,Wo=null,t)throw Error(l(300));e===null||Wt||(e=e.dependencies,e!==null&&fi(e)&&(Wt=!0))}function Fh(e,t,s,a){lt=e;var u=0;do{if(Jo&&(Wo=null),Qa=0,Jo=!1,25<=u)throw Error(l(301));if(u+=1,Jt=At=null,e.updateQueue!=null){var f=e.updateQueue;f.lastEffect=null,f.events=null,f.stores=null,f.memoCache!=null&&(f.memoCache.index=0)}C.H=Cg,f=t(s,a)}while(Jo);return f}function hE(){var e=C.H,t=e.useState()[0];return t=typeof t.then=="function"?Za(t):t,e=e.useState()[0],(At!==null?At.memoizedState:null)!==e&&(lt.flags|=1024),t}function ad(){var e=Ei!==0;return Ei=0,e}function ld(e,t,s){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s}function id(e){if(Si){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Si=!1}Ls=0,Jt=At=lt=null,Jo=!1,Qa=Ei=0,Wo=null}function Nn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Jt===null?lt.memoizedState=Jt=e:Jt=Jt.next=e,Jt}function Qt(){if(At===null){var e=lt.alternate;e=e!==null?e.memoizedState:null}else e=At.next;var t=Jt===null?lt.memoizedState:Jt.next;if(t!==null)Jt=t,At=e;else{if(e===null)throw lt.alternate===null?Error(l(467)):Error(l(310));At=e,e={memoizedState:At.memoizedState,baseState:At.baseState,baseQueue:At.baseQueue,queue:At.queue,next:null},Jt===null?lt.memoizedState=Jt=e:Jt=Jt.next=e}return Jt}function Ni(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Za(e){var t=Qa;return Qa+=1,Wo===null&&(Wo=[]),e=zh(Wo,e,t),t=lt,(Jt===null?t.memoizedState:Jt.next)===null&&(t=t.alternate,C.H=t===null||t.memoizedState===null?wg:vd),e}function ji(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Za(e);if(e.$$typeof===_)return hn(e)}throw Error(l(438,String(e)))}function cd(e){var t=null,s=lt.updateQueue;if(s!==null&&(t=s.memoCache),t==null){var a=lt.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=Ni(),lt.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]=oe;return t.index++,s}function Is(e,t){return typeof t=="function"?t(e):t}function Ti(e){var t=Qt();return ud(t,At,e)}function ud(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,P=null,ie=t,xe=!1;do{var Ne=ie.lane&-536870913;if(Ne!==ie.lane?(ht&Ne)===Ne:(Ls&Ne)===Ne){var ce=ie.revertLane;if(ce===0)P!==null&&(P=P.next={lane:0,revertLane:0,gesture:null,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null}),Ne===Xo&&(xe=!0);else if((Ls&ce)===ce){ie=ie.next,ce===Xo&&(xe=!0);continue}else Ne={lane:0,revertLane:ie.revertLane,gesture:null,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null},P===null?(R=P=Ne,y=f):P=P.next=Ne,lt.lanes|=ce,jr|=ce;Ne=ie.action,ro&&s(f,Ne),f=ie.hasEagerState?ie.eagerState:s(f,Ne)}else ce={lane:Ne,revertLane:ie.revertLane,gesture:ie.gesture,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null},P===null?(R=P=ce,y=f):P=P.next=ce,lt.lanes|=Ne,jr|=Ne;ie=ie.next}while(ie!==null&&ie!==t);if(P===null?y=f:P.next=R,!In(f,e.memoizedState)&&(Wt=!0,xe&&(s=$o,s!==null)))throw s;e.memoizedState=f,e.baseState=y,e.baseQueue=P,a.lastRenderedState=f}return u===null&&(a.lanes=0),[e.memoizedState,a.dispatch]}function dd(e){var t=Qt(),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)||(Wt=!0),t.memoizedState=f,t.baseQueue===null&&(t.baseState=f),s.lastRenderedState=f}return[f,a]}function Gh(e,t,s){var a=lt,u=Qt(),f=yt;if(f){if(s===void 0)throw Error(l(407));s=s()}else s=t();var y=!In((At||u).memoizedState,s);if(y&&(u.memoizedState=s,Wt=!0),u=u.queue,pd(Kh.bind(null,a,u,e),[e]),u.getSnapshot!==t||y||Jt!==null&&Jt.memoizedState.tag&1){if(a.flags|=2048,ea(9,{destroy:void 0},$h.bind(null,a,u,s,t),null),It===null)throw Error(l(349));f||(Ls&127)!==0||Xh(a,t,s)}return s}function Xh(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=lt.updateQueue,t===null?(t=Ni(),lt.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function $h(e,t,s,a){t.value=s,t.getSnapshot=a,Qh(t)&&Zh(e)}function Kh(e,t,s){return s(function(){Qh(t)&&Zh(e)})}function Qh(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!In(e,s)}catch{return!0}}function Zh(e){var t=Kr(e,2);t!==null&&Mn(t,e,2)}function fd(e){var t=Nn();if(typeof e=="function"){var s=e;if(e=s(),ro){kt(!0);try{s()}finally{kt(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Is,lastRenderedState:e},t}function Jh(e,t,s,a){return e.baseState=s,ud(e,At,typeof a=="function"?a:Is)}function gE(e,t,s,a,u){if(Ri(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)}};C.T!==null?s(!0):f.isTransition=!1,a(f),s=t.pending,s===null?(f.next=t.pending=f,Wh(t,f)):(f.next=s.next,t.pending=s.next=f)}}function Wh(e,t){var s=t.action,a=t.payload,u=e.state;if(t.isTransition){var f=C.T,y={};C.T=y;try{var R=s(u,a),P=C.S;P!==null&&P(y,R),eg(e,t,R)}catch(ie){md(e,t,ie)}finally{f!==null&&y.types!==null&&(f.types=y.types),C.T=f}}else try{f=s(u,a),eg(e,t,f)}catch(ie){md(e,t,ie)}}function eg(e,t,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(a){tg(e,t,a)},function(a){return md(e,t,a)}):tg(e,t,s)}function tg(e,t,s){t.status="fulfilled",t.value=s,ng(t),e.state=s,t=e.pending,t!==null&&(s=t.next,s===t?e.pending=null:(s=s.next,t.next=s,Wh(e,s)))}function md(e,t,s){var a=e.pending;if(e.pending=null,a!==null){a=a.next;do t.status="rejected",t.reason=s,ng(t),t=t.next;while(t!==a)}e.action=null}function ng(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function sg(e,t){return t}function rg(e,t){if(yt){var s=It.formState;if(s!==null){e:{var a=lt;if(yt){if(Ht){t:{for(var u=Ht,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){Ht=ns(u.nextSibling),a=u.data==="F!";break e}}hr(a)}a=!1}a&&(t=s[0])}}return s=Nn(),s.memoizedState=s.baseState=t,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:sg,lastRenderedState:t},s.queue=a,s=Ng.bind(null,lt,a),a.dispatch=s,a=fd(!1),f=yd.bind(null,lt,!1,a.queue),a=Nn(),u={state:t,dispatch:null,action:e,pending:null},a.queue=u,s=gE.bind(null,lt,u,f,s),u.dispatch=s,a.memoizedState=e,[t,s,!1]}function og(e){var t=Qt();return ag(t,At,e)}function ag(e,t,s){if(t=ud(e,t,sg)[0],e=Ti(Is)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var a=Za(t)}catch(y){throw y===Ko?hi:y}else a=t;t=Qt();var u=t.queue,f=u.dispatch;return s!==t.memoizedState&&(lt.flags|=2048,ea(9,{destroy:void 0},xE.bind(null,u,s),null)),[a,f,e]}function xE(e,t){e.action=t}function lg(e){var t=Qt(),s=At;if(s!==null)return ag(t,s,e);Qt(),t=t.memoizedState,s=Qt();var a=s.queue.dispatch;return s.memoizedState=e,[t,a,!1]}function ea(e,t,s,a){return e={tag:e,create:s,deps:a,inst:t,next:null},t=lt.updateQueue,t===null&&(t=Ni(),lt.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 ig(){return Qt().memoizedState}function wi(e,t,s,a){var u=Nn();lt.flags|=e,u.memoizedState=ea(1|t,{destroy:void 0},s,a===void 0?null:a)}function Ci(e,t,s,a){var u=Qt();a=a===void 0?null:a;var f=u.memoizedState.inst;At!==null&&a!==null&&rd(a,At.memoizedState.deps)?u.memoizedState=ea(t,f,s,a):(lt.flags|=e,u.memoizedState=ea(1|t,f,s,a))}function cg(e,t){wi(8390656,8,e,t)}function pd(e,t){Ci(2048,8,e,t)}function bE(e){lt.flags|=4;var t=lt.updateQueue;if(t===null)t=Ni(),lt.updateQueue=t,t.events=[e];else{var s=t.events;s===null?t.events=[e]:s.push(e)}}function ug(e){var t=Qt().memoizedState;return bE({ref:t,nextImpl:e}),function(){if((Rt&2)!==0)throw Error(l(440));return t.impl.apply(void 0,arguments)}}function dg(e,t){return Ci(4,2,e,t)}function fg(e,t){return Ci(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 pg(e,t,s){s=s!=null?s.concat([e]):null,Ci(4,4,mg.bind(null,t,e),s)}function hd(){}function hg(e,t){var s=Qt();t=t===void 0?null:t;var a=s.memoizedState;return t!==null&&rd(t,a[1])?a[0]:(s.memoizedState=[e,t],e)}function gg(e,t){var s=Qt();t=t===void 0?null:t;var a=s.memoizedState;if(t!==null&&rd(t,a[1]))return a[0];if(a=e(),ro){kt(!0);try{e()}finally{kt(!1)}}return s.memoizedState=[a,t],a}function gd(e,t,s){return s===void 0||(Ls&1073741824)!==0&&(ht&261930)===0?e.memoizedState=t:(e.memoizedState=s,e=xx(),lt.lanes|=e,jr|=e,s)}function xg(e,t,s,a){return In(s,t)?s:Zo.current!==null?(e=gd(e,s,a),In(e,t)||(Wt=!0),e):(Ls&42)===0||(Ls&1073741824)!==0&&(ht&261930)===0?(Wt=!0,e.memoizedState=s):(e=xx(),lt.lanes|=e,jr|=e,t)}function bg(e,t,s,a,u){var f=B.p;B.p=f!==0&&8>f?f:8;var y=C.T,R={};C.T=R,yd(e,!1,t,s);try{var P=u(),ie=C.S;if(ie!==null&&ie(R,P),P!==null&&typeof P=="object"&&typeof P.then=="function"){var xe=mE(P,a);Ja(e,t,xe,Vn(e))}else Ja(e,t,a,Vn(e))}catch(Ne){Ja(e,t,{then:function(){},status:"rejected",reason:Ne},Vn())}finally{B.p=f,y!==null&&R.types!==null&&(y.types=R.types),C.T=y}}function yE(){}function xd(e,t,s,a){if(e.tag!==5)throw Error(l(476));var u=yg(e).queue;bg(e,u,t,H,s===null?yE:function(){return vg(e),s(a)})}function yg(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:Is,lastRenderedState:H},next:null};var s={};return t.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Is,lastRenderedState:s},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function vg(e){var t=yg(e);t.next===null&&(t=e.alternate.memoizedState),Ja(e,t.next.queue,{},Vn())}function bd(){return hn(hl)}function Sg(){return Qt().memoizedState}function Eg(){return Qt().memoizedState}function vE(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var s=Vn();e=br(s);var a=yr(t,e,s);a!==null&&(Mn(a,t,s),Xa(a,t,s)),t={cache:Xu()},e.payload=t;return}t=t.return}}function SE(e,t,s){var a=Vn();s={lane:a,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},Ri(e)?jg(t,s):(s=Lu(e,t,s,a),s!==null&&(Mn(s,e,a),Tg(s,t,a)))}function Ng(e,t,s){var a=Vn();Ja(e,t,s,a)}function Ja(e,t,s,a){var u={lane:a,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(Ri(e))jg(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 ii(e,t,u,0),It===null&&li(),!1}catch{}if(s=Lu(e,t,u,a),s!==null)return Mn(s,e,a),Tg(s,t,a),!0}return!1}function yd(e,t,s,a){if(a={lane:2,revertLane:Zd(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Ri(e)){if(t)throw Error(l(479))}else t=Lu(e,s,a,2),t!==null&&Mn(t,e,2)}function Ri(e){var t=e.alternate;return e===lt||t!==null&&t===lt}function jg(e,t){Jo=Si=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function Tg(e,t,s){if((s&4194048)!==0){var a=t.lanes;a&=e.pendingLanes,s|=a,t.lanes=s,$t(e,s)}}var Wa={readContext:hn,use:ji,useCallback:Ft,useContext:Ft,useEffect:Ft,useImperativeHandle:Ft,useLayoutEffect:Ft,useInsertionEffect:Ft,useMemo:Ft,useReducer:Ft,useRef:Ft,useState:Ft,useDebugValue:Ft,useDeferredValue:Ft,useTransition:Ft,useSyncExternalStore:Ft,useId:Ft,useHostTransitionStatus:Ft,useFormState:Ft,useActionState:Ft,useOptimistic:Ft,useMemoCache:Ft,useCacheRefresh:Ft};Wa.useEffectEvent=Ft;var wg={readContext:hn,use:ji,useCallback:function(e,t){return Nn().memoizedState=[e,t===void 0?null:t],e},useContext:hn,useEffect:cg,useImperativeHandle:function(e,t,s){s=s!=null?s.concat([e]):null,wi(4194308,4,mg.bind(null,t,e),s)},useLayoutEffect:function(e,t){return wi(4194308,4,e,t)},useInsertionEffect:function(e,t){wi(4,2,e,t)},useMemo:function(e,t){var s=Nn();t=t===void 0?null:t;var a=e();if(ro){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(ro){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=SE.bind(null,lt,e),[a.memoizedState,e]},useRef:function(e){var t=Nn();return e={current:e},t.memoizedState=e},useState:function(e){e=fd(e);var t=e.queue,s=Ng.bind(null,lt,t);return t.dispatch=s,[e.memoizedState,s]},useDebugValue:hd,useDeferredValue:function(e,t){var s=Nn();return gd(s,e,t)},useTransition:function(){var e=fd(!1);return e=bg.bind(null,lt,e.queue,!0,!1),Nn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,s){var a=lt,u=Nn();if(yt){if(s===void 0)throw Error(l(407));s=s()}else{if(s=t(),It===null)throw Error(l(349));(ht&127)!==0||Xh(a,t,s)}u.memoizedState=s;var f={value:s,getSnapshot:t};return u.queue=f,cg(Kh.bind(null,a,f,e),[e]),a.flags|=2048,ea(9,{destroy:void 0},$h.bind(null,a,f,s,t),null),s},useId:function(){var e=Nn(),t=It.identifierPrefix;if(yt){var s=gs,a=hs;s=(a&~(1<<32-bt(a)-1)).toString(32)+s,t="_"+t+"R_"+s,s=Ei++,0<s&&(t+="H"+s.toString(32)),t+="_"}else s=pE++,t="_"+t+"r_"+s.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:bd,useFormState:rg,useActionState:rg,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=yd.bind(null,lt,!0,s),s.dispatch=t,[e,t]},useMemoCache:cd,useCacheRefresh:function(){return Nn().memoizedState=vE.bind(null,lt)},useEffectEvent:function(e){var t=Nn(),s={impl:e};return t.memoizedState=s,function(){if((Rt&2)!==0)throw Error(l(440));return s.impl.apply(void 0,arguments)}}},vd={readContext:hn,use:ji,useCallback:hg,useContext:hn,useEffect:pd,useImperativeHandle:pg,useInsertionEffect:dg,useLayoutEffect:fg,useMemo:gg,useReducer:Ti,useRef:ig,useState:function(){return Ti(Is)},useDebugValue:hd,useDeferredValue:function(e,t){var s=Qt();return xg(s,At.memoizedState,e,t)},useTransition:function(){var e=Ti(Is)[0],t=Qt().memoizedState;return[typeof e=="boolean"?e:Za(e),t]},useSyncExternalStore:Gh,useId:Sg,useHostTransitionStatus:bd,useFormState:og,useActionState:og,useOptimistic:function(e,t){var s=Qt();return Jh(s,At,e,t)},useMemoCache:cd,useCacheRefresh:Eg};vd.useEffectEvent=ug;var Cg={readContext:hn,use:ji,useCallback:hg,useContext:hn,useEffect:pd,useImperativeHandle:pg,useInsertionEffect:dg,useLayoutEffect:fg,useMemo:gg,useReducer:dd,useRef:ig,useState:function(){return dd(Is)},useDebugValue:hd,useDeferredValue:function(e,t){var s=Qt();return At===null?gd(s,e,t):xg(s,At.memoizedState,e,t)},useTransition:function(){var e=dd(Is)[0],t=Qt().memoizedState;return[typeof e=="boolean"?e:Za(e),t]},useSyncExternalStore:Gh,useId:Sg,useHostTransitionStatus:bd,useFormState:lg,useActionState:lg,useOptimistic:function(e,t){var s=Qt();return At!==null?Jh(s,At,e,t):(s.baseState=e,[e,s.queue.dispatch])},useMemoCache:cd,useCacheRefresh:Eg};Cg.useEffectEvent=ug;function Sd(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 Ed={enqueueSetState:function(e,t,s){e=e._reactInternals;var a=Vn(),u=br(a);u.payload=t,s!=null&&(u.callback=s),t=yr(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=br(a);u.tag=1,u.payload=t,s!=null&&(u.callback=s),t=yr(e,u,a),t!==null&&(Mn(t,e,a),Xa(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=Vn(),a=br(s);a.tag=2,t!=null&&(a.callback=t),t=yr(e,a,s),t!==null&&(Mn(t,e,s),Xa(t,e,s))}};function Rg(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?!Ua(s,a)||!Ua(u,f):!0}function Og(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&&Ed.enqueueReplaceState(t,t.state,null)}function oo(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){ai(e)}function _g(e){console.error(e)}function Mg(e){ai(e)}function Oi(e,t){try{var s=e.onUncaughtError;s(t.value,{componentStack:t.stack})}catch(a){setTimeout(function(){throw a})}}function Ag(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 Nd(e,t,s){return s=br(s),s.tag=3,s.payload={element:null},s.callback=function(){Oi(e,t)},s}function Dg(e){return e=br(e),e.tag=3,e}function zg(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(){Ag(t,s,a)}}var y=s.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(e.callback=function(){Ag(t,s,a),typeof u!="function"&&(Tr===null?Tr=new Set([this]):Tr.add(this));var R=a.stack;this.componentDidCatch(a.value,{componentStack:R!==null?R:""})})}function EE(e,t,s,a,u){if(s.flags|=32768,a!==null&&typeof a=="object"&&typeof a.then=="function"){if(t=s.alternate,t!==null&&Go(t,s,u,!0),s=Un.current,s!==null){switch(s.tag){case 31:case 13:return ts===null?Yi():s.alternate===null&&Gt===0&&(Gt=3),s.flags&=-257,s.flags|=65536,s.lanes=u,a===gi?s.flags|=16384:(t=s.updateQueue,t===null?s.updateQueue=new Set([a]):t.add(a),$d(e,a,u)),!1;case 22:return s.flags|=65536,a===gi?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)),$d(e,a,u)),!1}throw Error(l(435,s.tag))}return $d(e,a,u),Yi(),!1}if(yt)return t=Un.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=u,a!==Pu&&(e=Error(l(422),{cause:a}),Pa(Zn(e,s)))):(a!==Pu&&(t=Error(l(423),{cause:a}),Pa(Zn(t,s))),e=e.current.alternate,e.flags|=65536,u&=-u,e.lanes|=u,a=Zn(a,s),u=Nd(e.stateNode,a,u),Wu(e,u),Gt!==4&&(Gt=2)),!1;var f=Error(l(520),{cause:a});if(f=Zn(f,s),ll===null?ll=[f]:ll.push(f),Gt!==4&&(Gt=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=Nd(s.stateNode,a,e),Wu(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"&&(Tr===null||!Tr.has(f))))return s.flags|=65536,u&=-u,s.lanes|=u,u=Dg(u),zg(u,e,s,a),Wu(s,u),!1}s=s.return}while(s!==null);return!1}var jd=Error(l(461)),Wt=!1;function gn(e,t,s,a){t.child=e===null?Uh(t,null,s,a):so(t,e.child,s,a)}function Lg(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 Wr(t),a=od(e,t,s,y,f,u),R=ad(),e!==null&&!Wt?(ld(e,t,u),Bs(e,t,u)):(yt&&R&&Hu(t),t.flags|=1,gn(e,t,a,u),t.child)}function Ig(e,t,s,a,u){if(e===null){var f=s.type;return typeof f=="function"&&!Iu(f)&&f.defaultProps===void 0&&s.compare===null?(t.tag=15,t.type=f,Bg(e,t,f,a,u)):(e=ui(s.type,null,a,t,t.mode,u),e.ref=t.ref,e.return=t,t.child=e)}if(f=e.child,!Md(e,u)){var y=f.memoizedProps;if(s=s.compare,s=s!==null?s:Ua,s(y,a)&&e.ref===t.ref)return Bs(e,t,u)}return t.flags|=1,e=Ms(f,a),e.ref=t.ref,e.return=t,t.child=e}function Bg(e,t,s,a,u){if(e!==null){var f=e.memoizedProps;if(Ua(f,a)&&e.ref===t.ref)if(Wt=!1,t.pendingProps=a=f,Md(e,u))(e.flags&131072)!==0&&(Wt=!0);else return t.lanes=e.lanes,Bs(e,t,u)}return Td(e,t,s,a,u)}function Ug(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 Hg(e,t,f,s,a)}if((s&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&pi(t,f!==null?f.cachePool:null),f!==null?Ph(t,f):td(),Vh(t);else return a=t.lanes=536870912,Hg(e,t,f!==null?f.baseLanes|s:s,s,a)}else f!==null?(pi(t,f.cachePool),Ph(t,f),Sr(),t.memoizedState=null):(e!==null&&pi(t,null),td(),Sr());return gn(e,t,u,s),t.child}function el(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Hg(e,t,s,a,u){var f=Ku();return f=f===null?null:{parent:Zt._currentValue,pool:f},t.memoizedState={baseLanes:s,cachePool:f},e!==null&&pi(t,null),td(),Vh(t),e!==null&&Go(e,t,a,!0),t.childLanes=u,null}function ki(e,t){return t=Mi({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Yg(e,t,s){return so(t,e.child,null,s),e=ki(t,t.pendingProps),e.flags|=2,Hn(t),t.memoizedState=null,e}function NE(e,t,s){var a=t.pendingProps,u=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(yt){if(a.mode==="hidden")return e=ki(t,a),t.lanes=536870912,el(null,e);if(sd(t),(e=Ht)?(e=Wx(e,es),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:mr!==null?{id:hs,overflow:gs}:null,retryLane:536870912,hydrationErrors:null},s=jh(e),s.return=t,t.child=s,pn=t,Ht=null)):e=null,e===null)throw hr(t);return t.lanes=536870912,null}return ki(t,a)}var f=e.memoizedState;if(f!==null){var y=f.dehydrated;if(sd(t),u)if(t.flags&256)t.flags&=-257,t=Yg(e,t,s);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(l(558));else if(Wt||Go(e,t,s,!1),u=(s&e.childLanes)!==0,Wt||u){if(a=It,a!==null&&(y=mn(a,s),y!==0&&y!==f.retryLane))throw f.retryLane=y,Kr(e,y),Mn(a,e,y),jd;Yi(),t=Yg(e,t,s)}else e=f.treeContext,Ht=ns(y.nextSibling),pn=t,yt=!0,pr=null,es=!1,e!==null&&Ch(t,e),t=ki(t,a),t.flags|=4096;return t}return e=Ms(e.child,{mode:a.mode,children:a.children}),e.ref=t.ref,t.child=e,e.return=t,e}function _i(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 Td(e,t,s,a,u){return Wr(t),s=od(e,t,s,a,void 0,u),a=ad(),e!==null&&!Wt?(ld(e,t,u),Bs(e,t,u)):(yt&&a&&Hu(t),t.flags|=1,gn(e,t,s,u),t.child)}function Pg(e,t,s,a,u,f){return Wr(t),t.updateQueue=null,s=Fh(t,a,s,u),qh(e),a=ad(),e!==null&&!Wt?(ld(e,t,f),Bs(e,t,f)):(yt&&a&&Hu(t),t.flags|=1,gn(e,t,s,f),t.child)}function Vg(e,t,s,a,u){if(Wr(t),t.stateNode===null){var f=Po,y=s.contextType;typeof y=="object"&&y!==null&&(f=hn(y)),f=new s(a,f),t.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,f.updater=Ed,t.stateNode=f,f._reactInternals=t,f=t.stateNode,f.props=a,f.state=t.memoizedState,f.refs={},Zu(t),y=s.contextType,f.context=typeof y=="object"&&y!==null?hn(y):Po,f.state=t.memoizedState,y=s.getDerivedStateFromProps,typeof y=="function"&&(Sd(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&&Ed.enqueueReplaceState(f,f.state,null),Ka(t,a,f,u),$a(),f.state=t.memoizedState),typeof f.componentDidMount=="function"&&(t.flags|=4194308),a=!0}else if(e===null){f=t.stateNode;var R=t.memoizedProps,P=oo(s,R);f.props=P;var ie=f.context,xe=s.contextType;y=Po,typeof xe=="object"&&xe!==null&&(y=hn(xe));var Ne=s.getDerivedStateFromProps;xe=typeof Ne=="function"||typeof f.getSnapshotBeforeUpdate=="function",R=t.pendingProps!==R,xe||typeof f.UNSAFE_componentWillReceiveProps!="function"&&typeof f.componentWillReceiveProps!="function"||(R||ie!==y)&&Og(t,f,a,y),xr=!1;var ce=t.memoizedState;f.state=ce,Ka(t,a,f,u),$a(),ie=t.memoizedState,R||ce!==ie||xr?(typeof Ne=="function"&&(Sd(t,s,Ne,a),ie=t.memoizedState),(P=xr||Rg(t,s,P,a,ce,ie,y))?(xe||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=ie),f.props=a,f.state=ie,f.context=y,a=P):(typeof f.componentDidMount=="function"&&(t.flags|=4194308),a=!1)}else{f=t.stateNode,Ju(e,t),y=t.memoizedProps,xe=oo(s,y),f.props=xe,Ne=t.pendingProps,ce=f.context,ie=s.contextType,P=Po,typeof ie=="object"&&ie!==null&&(P=hn(ie)),R=s.getDerivedStateFromProps,(ie=typeof R=="function"||typeof f.getSnapshotBeforeUpdate=="function")||typeof f.UNSAFE_componentWillReceiveProps!="function"&&typeof f.componentWillReceiveProps!="function"||(y!==Ne||ce!==P)&&Og(t,f,a,P),xr=!1,ce=t.memoizedState,f.state=ce,Ka(t,a,f,u),$a();var pe=t.memoizedState;y!==Ne||ce!==pe||xr||e!==null&&e.dependencies!==null&&fi(e.dependencies)?(typeof R=="function"&&(Sd(t,s,R,a),pe=t.memoizedState),(xe=xr||Rg(t,s,xe,a,ce,pe,P)||e!==null&&e.dependencies!==null&&fi(e.dependencies))?(ie||typeof f.UNSAFE_componentWillUpdate!="function"&&typeof f.componentWillUpdate!="function"||(typeof f.componentWillUpdate=="function"&&f.componentWillUpdate(a,pe,P),typeof f.UNSAFE_componentWillUpdate=="function"&&f.UNSAFE_componentWillUpdate(a,pe,P)),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=pe),f.props=a,f.state=pe,f.context=P,a=xe):(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,_i(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=so(t,e.child,null,u),t.child=so(t,null,s,u)):gn(e,t,s,u),t.memoizedState=f.state,e=t.child):e=Bs(e,t,u),e}function qg(e,t,s,a){return Zr(),t.flags|=256,gn(e,t,s,a),t.child}var wd={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Cd(e){return{baseLanes:e,cachePool:Ah()}}function Rd(e,t,s){return e=e!==null?e.childLanes&~s:0,t&&(e|=Pn),e}function Fg(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:(Kt.current&2)!==0),y&&(u=!0,t.flags&=-129),y=(t.flags&32)!==0,t.flags&=-33,e===null){if(yt){if(u?vr(t):Sr(),(e=Ht)?(e=Wx(e,es),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:mr!==null?{id:hs,overflow:gs}:null,retryLane:536870912,hydrationErrors:null},s=jh(e),s.return=t,t.child=s,pn=t,Ht=null)):e=null,e===null)throw hr(t);return df(e)?t.lanes=32:t.lanes=536870912,null}var R=a.children;return a=a.fallback,u?(Sr(),u=t.mode,R=Mi({mode:"hidden",children:R},u),a=Qr(a,u,s,null),R.return=t,a.return=t,R.sibling=a,t.child=R,a=t.child,a.memoizedState=Cd(s),a.childLanes=Rd(e,y,s),t.memoizedState=wd,el(null,a)):(vr(t),Od(t,R))}var P=e.memoizedState;if(P!==null&&(R=P.dehydrated,R!==null)){if(f)t.flags&256?(vr(t),t.flags&=-257,t=kd(e,t,s)):t.memoizedState!==null?(Sr(),t.child=e.child,t.flags|=128,t=null):(Sr(),R=a.fallback,u=t.mode,a=Mi({mode:"visible",children:a.children},u),R=Qr(R,u,s,null),R.flags|=2,a.return=t,R.return=t,a.sibling=R,t.child=a,so(t,e.child,null,s),a=t.child,a.memoizedState=Cd(s),a.childLanes=Rd(e,y,s),t.memoizedState=wd,t=el(null,a));else if(vr(t),df(R)){if(y=R.nextSibling&&R.nextSibling.dataset,y)var ie=y.dgst;y=ie,a=Error(l(419)),a.stack="",a.digest=y,Pa({value:a,source:null,stack:null}),t=kd(e,t,s)}else if(Wt||Go(e,t,s,!1),y=(s&e.childLanes)!==0,Wt||y){if(y=It,y!==null&&(a=mn(y,s),a!==0&&a!==P.retryLane))throw P.retryLane=a,Kr(e,a),Mn(y,e,a),jd;uf(R)||Yi(),t=kd(e,t,s)}else uf(R)?(t.flags|=192,t.child=e.child,t=null):(e=P.treeContext,Ht=ns(R.nextSibling),pn=t,yt=!0,pr=null,es=!1,e!==null&&Ch(t,e),t=Od(t,a.children),t.flags|=4096);return t}return u?(Sr(),R=a.fallback,u=t.mode,P=e.child,ie=P.sibling,a=Ms(P,{mode:"hidden",children:a.children}),a.subtreeFlags=P.subtreeFlags&65011712,ie!==null?R=Ms(ie,R):(R=Qr(R,u,s,null),R.flags|=2),R.return=t,a.return=t,a.sibling=R,t.child=a,el(null,a),a=t.child,R=e.child.memoizedState,R===null?R=Cd(s):(u=R.cachePool,u!==null?(P=Zt._currentValue,u=u.parent!==P?{parent:P,pool:P}:u):u=Ah(),R={baseLanes:R.baseLanes|s,cachePool:u}),a.memoizedState=R,a.childLanes=Rd(e,y,s),t.memoizedState=wd,el(e.child,a)):(vr(t),s=e.child,e=s.sibling,s=Ms(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 Od(e,t){return t=Mi({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Mi(e,t){return e=Bn(22,e,null,t),e.lanes=0,e}function kd(e,t,s){return so(t,e.child,null,s),e=Od(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Gg(e,t,s){e.lanes|=t;var a=e.alternate;a!==null&&(a.lanes|=t),Fu(e.return,t,s)}function _d(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 Xg(e,t,s){var a=t.pendingProps,u=a.revealOrder,f=a.tail;a=a.children;var y=Kt.current,R=(y&2)!==0;if(R?(y=y&1|2,t.flags|=128):y&=1,V(Kt,y),gn(e,t,a,s),a=yt?Ya:0,!R&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Gg(e,s,t);else if(e.tag===19)Gg(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&&vi(e)===null&&(u=s),s=s.sibling;s=u,s===null?(u=t.child,t.child=null):(u=s.sibling,s.sibling=null),_d(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&&vi(e)===null){t.child=u;break}e=u.sibling,u.sibling=s,s=u,u=e}_d(t,!0,s,null,f,a);break;case"together":_d(t,!1,null,null,void 0,a);break;default:t.memoizedState=null}return t.child}function Bs(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),jr|=t.lanes,(s&t.childLanes)===0)if(e!==null){if(Go(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=Ms(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=Ms(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function Md(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&fi(e)))}function jE(e,t,s){switch(t.tag){case 3:me(t,t.stateNode.containerInfo),gr(t,Zt,e.memoizedState.cache),Zr();break;case 27:case 5:Le(t);break;case 4:me(t,t.stateNode.containerInfo);break;case 10:gr(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,sd(t),null;break;case 13:var a=t.memoizedState;if(a!==null)return a.dehydrated!==null?(vr(t),t.flags|=128,null):(s&t.child.childLanes)!==0?Fg(e,t,s):(vr(t),e=Bs(e,t,s),e!==null?e.sibling:null);vr(t);break;case 19:var u=(e.flags&128)!==0;if(a=(s&t.childLanes)!==0,a||(Go(e,t,s,!1),a=(s&t.childLanes)!==0),u){if(a)return Xg(e,t,s);t.flags|=128}if(u=t.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),V(Kt,Kt.current),a)break;return null;case 22:return t.lanes=0,Ug(e,t,s,t.pendingProps);case 24:gr(t,Zt,e.memoizedState.cache)}return Bs(e,t,s)}function $g(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps)Wt=!0;else{if(!Md(e,s)&&(t.flags&128)===0)return Wt=!1,jE(e,t,s);Wt=(e.flags&131072)!==0}else Wt=!1,yt&&(t.flags&1048576)!==0&&wh(t,Ya,t.index);switch(t.lanes=0,t.tag){case 16:e:{var a=t.pendingProps;if(e=to(t.elementType),t.type=e,typeof e=="function")Iu(e)?(a=oo(e,a),t.tag=1,t=Vg(null,t,e,a,s)):(t.tag=0,t=Td(null,t,e,a,s));else{if(e!=null){var u=e.$$typeof;if(u===w){t.tag=11,t=Lg(null,t,e,a,s);break e}else if(u===U){t.tag=14,t=Ig(null,t,e,a,s);break e}}throw t=te(e)||e,Error(l(306,t,""))}}return t;case 0:return Td(e,t,t.type,t.pendingProps,s);case 1:return a=t.type,u=oo(a,t.pendingProps),Vg(e,t,a,u,s);case 3:e:{if(me(t,t.stateNode.containerInfo),e===null)throw Error(l(387));a=t.pendingProps;var f=t.memoizedState;u=f.element,Ju(e,t),Ka(t,a,null,s);var y=t.memoizedState;if(a=y.cache,gr(t,Zt,a),a!==f.cache&&Gu(t,[Zt],s,!0),$a(),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=qg(e,t,a,s);break e}else if(a!==u){u=Zn(Error(l(424)),t),Pa(u),t=qg(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,Ht=ns(e.firstChild),pn=t,yt=!0,pr=null,es=!0,s=Uh(t,null,a,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(Zr(),a===u){t=Bs(e,t,s);break e}gn(e,t,a,s)}t=t.child}return t;case 26:return _i(e,t),e===null?(s=ob(t.type,null,t.pendingProps,null))?t.memoizedState=s:yt||(s=t.type,e=t.pendingProps,a=$i(F.current).createElement(s),a[nn]=t,a[wn]=e,xn(a,s,e),ln(a),t.stateNode=a):t.memoizedState=ob(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Le(t),e===null&&yt&&(a=t.stateNode=nb(t.type,t.pendingProps,F.current),pn=t,es=!0,u=Ht,Or(t.type)?(ff=u,Ht=ns(a.firstChild)):Ht=u),gn(e,t,t.pendingProps.children,s),_i(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&yt&&((u=a=Ht)&&(a=eN(a,t.type,t.pendingProps,es),a!==null?(t.stateNode=a,pn=t,Ht=ns(a.firstChild),es=!1,u=!0):u=!1),u||hr(t)),Le(t),u=t.type,f=t.pendingProps,y=e!==null?e.memoizedProps:null,a=f.children,af(u,f)?a=null:y!==null&&af(u,y)&&(t.flags|=32),t.memoizedState!==null&&(u=od(e,t,hE,null,null,s),hl._currentValue=u),_i(e,t),gn(e,t,a,s),t.child;case 6:return e===null&&yt&&((e=s=Ht)&&(s=tN(s,t.pendingProps,es),s!==null?(t.stateNode=s,pn=t,Ht=null,e=!0):e=!1),e||hr(t)),null;case 13:return Fg(e,t,s);case 4:return me(t,t.stateNode.containerInfo),a=t.pendingProps,e===null?t.child=so(t,null,a,s):gn(e,t,a,s),t.child;case 11:return Lg(e,t,t.type,t.pendingProps,s);case 7:return gn(e,t,t.pendingProps,s),t.child;case 8:return gn(e,t,t.pendingProps.children,s),t.child;case 12:return gn(e,t,t.pendingProps.children,s),t.child;case 10:return a=t.pendingProps,gr(t,t.type,a.value),gn(e,t,a.children,s),t.child;case 9:return u=t.type._context,a=t.pendingProps.children,Wr(t),u=hn(u),a=a(u),t.flags|=1,gn(e,t,a,s),t.child;case 14:return Ig(e,t,t.type,t.pendingProps,s);case 15:return Bg(e,t,t.type,t.pendingProps,s);case 19:return Xg(e,t,s);case 31:return NE(e,t,s);case 22:return Ug(e,t,s,t.pendingProps);case 24:return Wr(t),a=hn(Zt),e===null?(u=Ku(),u===null&&(u=It,f=Xu(),u.pooledCache=f,f.refCount++,f!==null&&(u.pooledCacheLanes|=s),u=f),t.memoizedState={parent:a,cache:u},Zu(t),gr(t,Zt,u)):((e.lanes&s)!==0&&(Ju(e,t),Ka(t,null,null,s),$a()),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),gr(t,Zt,a)):(a=f.cache,gr(t,Zt,a),a!==u.cache&&Gu(t,[Zt],s,!0))),gn(e,t,t.pendingProps.children,s),t.child;case 29:throw t.pendingProps}throw Error(l(156,t.tag))}function Us(e){e.flags|=4}function Ad(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(Sx())e.flags|=8192;else throw no=gi,Qu}else e.flags&=-16777217}function Kg(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!ub(t))if(Sx())e.flags|=8192;else throw no=gi,Qu}function Ai(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?tt():536870912,e.lanes|=t,ra|=t)}function tl(e,t){if(!yt)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 Yt(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 TE(e,t,s){var a=t.pendingProps;switch(Yu(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Yt(t),null;case 1:return Yt(t),null;case 3:return s=t.stateNode,a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),zs(Zt),he(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(Fo(t)?Us(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Vu())),Yt(t),null;case 26:var u=t.type,f=t.memoizedState;return e===null?(Us(t),f!==null?(Yt(t),Kg(t,f)):(Yt(t),Ad(t,u,null,a,s))):f?f!==e.memoizedState?(Us(t),Yt(t),Kg(t,f)):(Yt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==a&&Us(t),Yt(t),Ad(t,u,e,a,s)),null;case 27:if(Ve(t),s=F.current,u=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==a&&Us(t);else{if(!a){if(t.stateNode===null)throw Error(l(166));return Yt(t),null}e=Q.current,Fo(t)?Rh(t):(e=nb(u,a,s),t.stateNode=e,Us(t))}return Yt(t),null;case 5:if(Ve(t),u=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==a&&Us(t);else{if(!a){if(t.stateNode===null)throw Error(l(166));return Yt(t),null}if(f=Q.current,Fo(t))Rh(t);else{var y=$i(F.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[nn]=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(xn(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&&Us(t)}}return Yt(t),Ad(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,s),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==a&&Us(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(l(166));if(e=F.current,Fo(t)){if(e=t.stateNode,s=t.memoizedProps,a=null,u=pn,u!==null)switch(u.tag){case 27:case 5:a=u.memoizedProps}e[nn]=t,e=!!(e.nodeValue===s||a!==null&&a.suppressHydrationWarning===!0||Fx(e.nodeValue,s)),e||hr(t,!0)}else e=$i(e).createTextNode(a),e[nn]=t,t.stateNode=e}return Yt(t),null;case 31:if(s=t.memoizedState,e===null||e.memoizedState!==null){if(a=Fo(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[nn]=t}else Zr(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Yt(t),e=!1}else s=Vu(),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 Yt(t),null;case 13:if(a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(u=Fo(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[nn]=t}else Zr(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Yt(t),u=!1}else u=Vu(),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),Ai(t,t.updateQueue),Yt(t),null);case 4:return he(),e===null&&tf(t.stateNode.containerInfo),Yt(t),null;case 10:return zs(t.type),Yt(t),null;case 19:if(q(Kt),a=t.memoizedState,a===null)return Yt(t),null;if(u=(t.flags&128)!==0,f=a.rendering,f===null)if(u)tl(a,!1);else{if(Gt!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(f=vi(e),f!==null){for(t.flags|=128,tl(a,!1),e=f.updateQueue,t.updateQueue=e,Ai(t,e),t.subtreeFlags=0,e=s,s=t.child;s!==null;)Nh(s,e),s=s.sibling;return V(Kt,Kt.current&1|2),yt&&As(t,a.treeForkCount),t.child}e=e.sibling}a.tail!==null&&se()>Bi&&(t.flags|=128,u=!0,tl(a,!1),t.lanes=4194304)}else{if(!u)if(e=vi(f),e!==null){if(t.flags|=128,u=!0,e=e.updateQueue,t.updateQueue=e,Ai(t,e),tl(a,!0),a.tail===null&&a.tailMode==="hidden"&&!f.alternate&&!yt)return Yt(t),null}else 2*se()-a.renderingStartTime>Bi&&s!==536870912&&(t.flags|=128,u=!0,tl(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=se(),e.sibling=null,s=Kt.current,V(Kt,u?s&1|2:s&1),yt&&As(t,a.treeForkCount),e):(Yt(t),null);case 22:case 23:return Hn(t),nd(),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&&(Yt(t),t.subtreeFlags&6&&(t.flags|=8192)):Yt(t),s=t.updateQueue,s!==null&&Ai(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&&q(eo),null;case 24:return s=null,e!==null&&(s=e.memoizedState.cache),t.memoizedState.cache!==s&&(t.flags|=2048),zs(Zt),Yt(t),null;case 25:return null;case 30:return null}throw Error(l(156,t.tag))}function wE(e,t){switch(Yu(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return zs(Zt),he(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ve(t),null;case 31:if(t.memoizedState!==null){if(Hn(t),t.alternate===null)throw Error(l(340));Zr()}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));Zr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return q(Kt),null;case 4:return he(),null;case 10:return zs(t.type),null;case 22:case 23:return Hn(t),nd(),e!==null&&q(eo),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return zs(Zt),null;case 25:return null;default:return null}}function Qg(e,t){switch(Yu(t),t.tag){case 3:zs(Zt),he();break;case 26:case 27:case 5:Ve(t);break;case 4:he();break;case 31:t.memoizedState!==null&&Hn(t);break;case 13:Hn(t);break;case 19:q(Kt);break;case 10:zs(t.type);break;case 22:case 23:Hn(t),nd(),e!==null&&q(eo);break;case 24:zs(Zt)}}function nl(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){Mt(t,t.return,R)}}function Er(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 P=s,ie=R;try{ie()}catch(xe){Mt(u,P,xe)}}}a=a.next}while(a!==f)}}catch(xe){Mt(t,t.return,xe)}}function Zg(e){var t=e.updateQueue;if(t!==null){var s=e.stateNode;try{Yh(t,s)}catch(a){Mt(e,e.return,a)}}}function Jg(e,t,s){s.props=oo(e.type,e.memoizedProps),s.state=e.memoizedState;try{s.componentWillUnmount()}catch(a){Mt(e,t,a)}}function sl(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){Mt(e,t,u)}}function xs(e,t){var s=e.ref,a=e.refCleanup;if(s!==null)if(typeof a=="function")try{a()}catch(u){Mt(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){Mt(e,t,u)}else s.current=null}function Wg(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){Mt(e,e.return,u)}}function Dd(e,t,s){try{var a=e.stateNode;$E(a,e.type,s,t),a[wn]=t}catch(u){Mt(e,e.return,u)}}function ex(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Or(e.type)||e.tag===4}function zd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ex(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&&Or(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 Ld(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=ks));else if(a!==4&&(a===27&&Or(e.type)&&(s=e.stateNode,t=null),e=e.child,e!==null))for(Ld(e,t,s),e=e.sibling;e!==null;)Ld(e,t,s),e=e.sibling}function Di(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&&Or(e.type)&&(s=e.stateNode),e=e.child,e!==null))for(Di(e,t,s),e=e.sibling;e!==null;)Di(e,t,s),e=e.sibling}function tx(e){var t=e.stateNode,s=e.memoizedProps;try{for(var a=e.type,u=t.attributes;u.length;)t.removeAttributeNode(u[0]);xn(t,a,s),t[nn]=e,t[wn]=s}catch(f){Mt(e,e.return,f)}}var Hs=!1,en=!1,Id=!1,nx=typeof WeakSet=="function"?WeakSet:Set,cn=null;function CE(e,t){if(e=e.containerInfo,rf=tc,e=ph(e),ku(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,P=-1,ie=0,xe=0,Ne=e,ce=null;t:for(;;){for(var pe;Ne!==s||u!==0&&Ne.nodeType!==3||(R=y+u),Ne!==f||a!==0&&Ne.nodeType!==3||(P=y+a),Ne.nodeType===3&&(y+=Ne.nodeValue.length),(pe=Ne.firstChild)!==null;)ce=Ne,Ne=pe;for(;;){if(Ne===e)break t;if(ce===s&&++ie===u&&(R=y),ce===f&&++xe===a&&(P=y),(pe=Ne.nextSibling)!==null)break;Ne=ce,ce=Ne.parentNode}Ne=pe}s=R===-1||P===-1?null:{start:R,end:P}}else s=null}s=s||{start:0,end:0}}else s=null;for(of={focusedElem:e,selectionRange:s},tc=!1,cn=t;cn!==null;)if(t=cn,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,cn=e;else for(;cn!==null;){switch(t=cn,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 Pe=oo(s.type,u);e=a.getSnapshotBeforeUpdate(Pe,f),a.__reactInternalSnapshotBeforeUpdate=e}catch(Je){Mt(s,s.return,Je)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,s=e.nodeType,s===9)cf(e);else if(s===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":cf(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,cn=e;break}cn=t.return}}function sx(e,t,s){var a=s.flags;switch(s.tag){case 0:case 11:case 15:Ps(e,s),a&4&&nl(5,s);break;case 1:if(Ps(e,s),a&4)if(e=s.stateNode,t===null)try{e.componentDidMount()}catch(y){Mt(s,s.return,y)}else{var u=oo(s.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(u,t,e.__reactInternalSnapshotBeforeUpdate)}catch(y){Mt(s,s.return,y)}}a&64&&Zg(s),a&512&&sl(s,s.return);break;case 3:if(Ps(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{Yh(e,t)}catch(y){Mt(s,s.return,y)}}break;case 27:t===null&&a&4&&tx(s);case 26:case 5:Ps(e,s),t===null&&a&4&&Wg(s),a&512&&sl(s,s.return);break;case 12:Ps(e,s);break;case 31:Ps(e,s),a&4&&ax(e,s);break;case 13:Ps(e,s),a&4&&lx(e,s),a&64&&(e=s.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(s=LE.bind(null,s),nN(e,s))));break;case 22:if(a=s.memoizedState!==null||Hs,!a){t=t!==null&&t.memoizedState!==null||en,u=Hs;var f=en;Hs=a,(en=t)&&!f?Vs(e,s,(s.subtreeFlags&8772)!==0):Ps(e,s),Hs=u,en=f}break;case 30:break;default:Ps(e,s)}}function rx(e){var t=e.alternate;t!==null&&(e.alternate=null,rx(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&mu(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 Vt=null,Rn=!1;function Ys(e,t,s){for(s=s.child;s!==null;)ox(e,t,s),s=s.sibling}function ox(e,t,s){if(Nt&&typeof Nt.onCommitFiberUnmount=="function")try{Nt.onCommitFiberUnmount(rt,s)}catch{}switch(s.tag){case 26:en||xs(s,t),Ys(e,t,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:en||xs(s,t);var a=Vt,u=Rn;Or(s.type)&&(Vt=s.stateNode,Rn=!1),Ys(e,t,s),fl(s.stateNode),Vt=a,Rn=u;break;case 5:en||xs(s,t);case 6:if(a=Vt,u=Rn,Vt=null,Ys(e,t,s),Vt=a,Rn=u,Vt!==null)if(Rn)try{(Vt.nodeType===9?Vt.body:Vt.nodeName==="HTML"?Vt.ownerDocument.body:Vt).removeChild(s.stateNode)}catch(f){Mt(s,t,f)}else try{Vt.removeChild(s.stateNode)}catch(f){Mt(s,t,f)}break;case 18:Vt!==null&&(Rn?(e=Vt,Zx(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,s.stateNode),fa(e)):Zx(Vt,s.stateNode));break;case 4:a=Vt,u=Rn,Vt=s.stateNode.containerInfo,Rn=!0,Ys(e,t,s),Vt=a,Rn=u;break;case 0:case 11:case 14:case 15:Er(2,s,t),en||Er(4,s,t),Ys(e,t,s);break;case 1:en||(xs(s,t),a=s.stateNode,typeof a.componentWillUnmount=="function"&&Jg(s,t,a)),Ys(e,t,s);break;case 21:Ys(e,t,s);break;case 22:en=(a=en)||s.memoizedState!==null,Ys(e,t,s),en=a;break;default:Ys(e,t,s)}}function ax(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{fa(e)}catch(s){Mt(t,t.return,s)}}}function lx(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{fa(e)}catch(s){Mt(t,t.return,s)}}function RE(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new nx),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new nx),t;default:throw Error(l(435,e.tag))}}function zi(e,t){var s=RE(e);t.forEach(function(a){if(!s.has(a)){s.add(a);var u=IE.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(Or(R.type)){Vt=R.stateNode,Rn=!1;break e}break;case 5:Vt=R.stateNode,Rn=!1;break e;case 3:case 4:Vt=R.stateNode.containerInfo,Rn=!0;break e}R=R.return}if(Vt===null)throw Error(l(160));ox(f,y,u),Vt=null,Rn=!1,f=u.alternate,f!==null&&(f.return=null),u.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)ix(t,e),t=t.sibling}var cs=null;function ix(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&&(Er(3,e,e.return),nl(3,e),Er(5,e,e.return));break;case 1:On(t,e),kn(e),a&512&&(en||s===null||xs(s,s.return)),a&64&&Hs&&(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=cs;if(On(t,e),kn(e),a&512&&(en||s===null||xs(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[ka]||f[nn]||f.namespaceURI==="http://www.w3.org/2000/svg"||f.hasAttribute("itemprop"))&&(f=u.createElement(a),u.head.insertBefore(f,u.querySelector("head > title"))),xn(f,a,s),f[nn]=e,ln(f),a=f;break e;case"link":var y=ib("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),xn(f,a,s),u.head.appendChild(f);break;case"meta":if(y=ib("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),xn(f,a,s),u.head.appendChild(f);break;default:throw Error(l(468,a))}f[nn]=e,ln(f),a=f}e.stateNode=a}else cb(u,e.type,e.stateNode);else e.stateNode=lb(u,a,e.memoizedProps);else f!==a?(f===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):f.count--,a===null?cb(u,e.type,e.stateNode):lb(u,a,e.memoizedProps)):a===null&&e.stateNode!==null&&Dd(e,e.memoizedProps,s.memoizedProps)}break;case 27:On(t,e),kn(e),a&512&&(en||s===null||xs(s,s.return)),s!==null&&a&4&&Dd(e,e.memoizedProps,s.memoizedProps);break;case 5:if(On(t,e),kn(e),a&512&&(en||s===null||xs(s,s.return)),e.flags&32){u=e.stateNode;try{zo(u,"")}catch(Pe){Mt(e,e.return,Pe)}}a&4&&e.stateNode!=null&&(u=e.memoizedProps,Dd(e,u,s!==null?s.memoizedProps:u)),a&1024&&(Id=!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(Pe){Mt(e,e.return,Pe)}}break;case 3:if(Zi=null,u=cs,cs=Ki(t.containerInfo),On(t,e),cs=u,kn(e),a&4&&s!==null&&s.memoizedState.isDehydrated)try{fa(t.containerInfo)}catch(Pe){Mt(e,e.return,Pe)}Id&&(Id=!1,cx(e));break;case 4:a=cs,cs=Ki(e.stateNode.containerInfo),On(t,e),kn(e),cs=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,zi(e,a)));break;case 13:On(t,e),kn(e),e.child.flags&8192&&e.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(Ii=se()),a&4&&(a=e.updateQueue,a!==null&&(e.updateQueue=null,zi(e,a)));break;case 22:u=e.memoizedState!==null;var P=s!==null&&s.memoizedState!==null,ie=Hs,xe=en;if(Hs=ie||u,en=xe||P,On(t,e),en=xe,Hs=ie,kn(e),a&8192)e:for(t=e.stateNode,t._visibility=u?t._visibility&-2:t._visibility|1,u&&(s===null||P||Hs||en||ao(e)),s=null,t=e;;){if(t.tag===5||t.tag===26){if(s===null){P=s=t;try{if(f=P.stateNode,u)y=f.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{R=P.stateNode;var Ne=P.memoizedProps.style,ce=Ne!=null&&Ne.hasOwnProperty("display")?Ne.display:null;R.style.display=ce==null||typeof ce=="boolean"?"":(""+ce).trim()}}catch(Pe){Mt(P,P.return,Pe)}}}else if(t.tag===6){if(s===null){P=t;try{P.stateNode.nodeValue=u?"":P.memoizedProps}catch(Pe){Mt(P,P.return,Pe)}}}else if(t.tag===18){if(s===null){P=t;try{var pe=P.stateNode;u?Jx(pe,!0):Jx(P.stateNode,!1)}catch(Pe){Mt(P,P.return,Pe)}}}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,zi(e,s))));break;case 19:On(t,e),kn(e),a&4&&(a=e.updateQueue,a!==null&&(e.updateQueue=null,zi(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(ex(a)){s=a;break}a=a.return}if(s==null)throw Error(l(160));switch(s.tag){case 27:var u=s.stateNode,f=zd(e);Di(e,f,u);break;case 5:var y=s.stateNode;s.flags&32&&(zo(y,""),s.flags&=-33);var R=zd(e);Di(e,R,y);break;case 3:case 4:var P=s.stateNode.containerInfo,ie=zd(e);Ld(e,ie,P);break;default:throw Error(l(161))}}catch(xe){Mt(e,e.return,xe)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function cx(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;cx(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Ps(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)sx(e,t.alternate,t),t=t.sibling}function ao(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Er(4,t,t.return),ao(t);break;case 1:xs(t,t.return);var s=t.stateNode;typeof s.componentWillUnmount=="function"&&Jg(t,t.return,s),ao(t);break;case 27:fl(t.stateNode);case 26:case 5:xs(t,t.return),ao(t);break;case 22:t.memoizedState===null&&ao(t);break;case 30:ao(t);break;default:ao(t)}e=e.sibling}}function Vs(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:Vs(u,f,s),nl(4,f);break;case 1:if(Vs(u,f,s),a=f,u=a.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(ie){Mt(a,a.return,ie)}if(a=f,u=a.updateQueue,u!==null){var R=a.stateNode;try{var P=u.shared.hiddenCallbacks;if(P!==null)for(u.shared.hiddenCallbacks=null,u=0;u<P.length;u++)Hh(P[u],R)}catch(ie){Mt(a,a.return,ie)}}s&&y&64&&Zg(f),sl(f,f.return);break;case 27:tx(f);case 26:case 5:Vs(u,f,s),s&&a===null&&y&4&&Wg(f),sl(f,f.return);break;case 12:Vs(u,f,s);break;case 31:Vs(u,f,s),s&&y&4&&ax(u,f);break;case 13:Vs(u,f,s),s&&y&4&&lx(u,f);break;case 22:f.memoizedState===null&&Vs(u,f,s),sl(f,f.return);break;case 30:break;default:Vs(u,f,s)}t=t.sibling}}function Bd(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&&Va(s))}function Ud(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Va(e))}function us(e,t,s,a){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)ux(e,t,s,a),t=t.sibling}function ux(e,t,s,a){var u=t.flags;switch(t.tag){case 0:case 11:case 15:us(e,t,s,a),u&2048&&nl(9,t);break;case 1:us(e,t,s,a);break;case 3:us(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&&Va(e)));break;case 12:if(u&2048){us(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(P){Mt(t,t.return,P)}}else us(e,t,s,a);break;case 31:us(e,t,s,a);break;case 13:us(e,t,s,a);break;case 23:break;case 22:f=t.stateNode,y=t.alternate,t.memoizedState!==null?f._visibility&2?us(e,t,s,a):rl(e,t):f._visibility&2?us(e,t,s,a):(f._visibility|=2,ta(e,t,s,a,(t.subtreeFlags&10256)!==0||!1)),u&2048&&Bd(y,t);break;case 24:us(e,t,s,a),u&2048&&Ud(t.alternate,t);break;default:us(e,t,s,a)}}function ta(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,P=a,ie=y.flags;switch(y.tag){case 0:case 11:case 15:ta(f,y,R,P,u),nl(8,y);break;case 23:break;case 22:var xe=y.stateNode;y.memoizedState!==null?xe._visibility&2?ta(f,y,R,P,u):rl(f,y):(xe._visibility|=2,ta(f,y,R,P,u)),u&&ie&2048&&Bd(y.alternate,y);break;case 24:ta(f,y,R,P,u),u&&ie&2048&&Ud(y.alternate,y);break;default:ta(f,y,R,P,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&&Bd(a.alternate,a);break;case 24:rl(s,a),u&2048&&Ud(a.alternate,a);break;default:rl(s,a)}t=t.sibling}}var ol=8192;function na(e,t,s){if(e.subtreeFlags&ol)for(e=e.child;e!==null;)dx(e,t,s),e=e.sibling}function dx(e,t,s){switch(e.tag){case 26:na(e,t,s),e.flags&ol&&e.memoizedState!==null&&pN(s,cs,e.memoizedState,e.memoizedProps);break;case 5:na(e,t,s);break;case 3:case 4:var a=cs;cs=Ki(e.stateNode.containerInfo),na(e,t,s),cs=a;break;case 22:e.memoizedState===null&&(a=e.alternate,a!==null&&a.memoizedState!==null?(a=ol,ol=16777216,na(e,t,s),ol=a):na(e,t,s));break;default:na(e,t,s)}}function fx(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 al(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];cn=a,px(a,e)}fx(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:al(e),e.flags&2048&&Er(9,e,e.return);break;case 3:al(e);break;case 12:al(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Li(e)):al(e);break;default:al(e)}}function Li(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];cn=a,px(a,e)}fx(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Er(8,t,t.return),Li(t);break;case 22:s=t.stateNode,s._visibility&2&&(s._visibility&=-3,Li(t));break;default:Li(t)}e=e.sibling}}function px(e,t){for(;cn!==null;){var s=cn;switch(s.tag){case 0:case 11:case 15:Er(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:Va(s.memoizedState.cache)}if(a=s.child,a!==null)a.return=s,cn=a;else e:for(s=e;cn!==null;){a=cn;var u=a.sibling,f=a.return;if(rx(a),a===s){cn=null;break e}if(u!==null){u.return=f,cn=u;break e}cn=f}}}var OE={getCacheForType:function(e){var t=hn(Zt),s=t.data.get(e);return s===void 0&&(s=e(),t.data.set(e,s)),s},cacheSignal:function(){return hn(Zt).controller.signal}},kE=typeof WeakMap=="function"?WeakMap:Map,Rt=0,It=null,ft=null,ht=0,_t=0,Yn=null,Nr=!1,sa=!1,Hd=!1,qs=0,Gt=0,jr=0,lo=0,Yd=0,Pn=0,ra=0,ll=null,_n=null,Pd=!1,Ii=0,hx=0,Bi=1/0,Ui=null,Tr=null,sn=0,wr=null,oa=null,Fs=0,Vd=0,qd=null,gx=null,il=0,Fd=null;function Vn(){return(Rt&2)!==0&&ht!==0?ht&-ht:C.T!==null?Zd():Rs()}function xx(){if(Pn===0)if((ht&536870912)===0||yt){var e=tn;tn<<=1,(tn&3932160)===0&&(tn=262144),Pn=e}else Pn=536870912;return e=Un.current,e!==null&&(e.flags|=32),Pn}function Mn(e,t,s){(e===It&&(_t===2||_t===9)||e.cancelPendingCommit!==null)&&(aa(e,0),Cr(e,ht,Pn,!1)),st(e,s),((Rt&2)===0||e!==It)&&(e===It&&((Rt&2)===0&&(lo|=s),Gt===4&&Cr(e,ht,Pn,!1)),bs(e))}function bx(e,t,s){if((Rt&6)!==0)throw Error(l(327));var a=!s&&(t&127)===0&&(t&e.expiredLanes)===0||Oe(e,t),u=a?AE(e,t):Xd(e,t,!0),f=a;do{if(u===0){sa&&!a&&Cr(e,t,0,!1);break}else{if(s=e.current.alternate,f&&!_E(s)){u=Xd(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=ll;var P=R.current.memoizedState.isDehydrated;if(P&&(aa(R,y).flags|=256),y=Xd(R,y,!1),y!==2){if(Hd&&!P){R.errorRecoveryDisabledLanes|=f,lo|=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){aa(e,0),Cr(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:Cr(a,t,Pn,!Nr);break e;case 2:_n=null;break;case 3:case 5:break;default:throw Error(l(329))}if((t&62914560)===t&&(u=Ii+300-se(),10<u)){if(Cr(a,t,Pn,!Nr),ve(a,0,!0)!==0)break e;Fs=t,a.timeoutHandle=Kx(yx.bind(null,a,s,_n,Ui,Pd,t,Pn,lo,ra,Nr,f,"Throttled",-0,0),u);break e}yx(a,s,_n,Ui,Pd,t,Pn,lo,ra,Nr,f,null,-0,0)}}break}while(!0);bs(e)}function yx(e,t,s,a,u,f,y,R,P,ie,xe,Ne,ce,pe){if(e.timeoutHandle=-1,Ne=t.subtreeFlags,Ne&8192||(Ne&16785408)===16785408){Ne={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:ks},dx(t,f,Ne);var Pe=(f&62914560)===f?Ii-se():(f&4194048)===f?hx-se():0;if(Pe=hN(Ne,Pe),Pe!==null){Fs=f,e.cancelPendingCommit=Pe(Cx.bind(null,e,t,f,s,a,u,y,R,P,xe,Ne,null,ce,pe)),Cr(e,f,y,!ie);return}}Cx(e,t,f,s,a,u,y,R,P)}function _E(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 Cr(e,t,s,a){t&=~Yd,t&=~lo,e.suspendedLanes|=t,e.pingedLanes&=~t,a&&(e.warmLanes|=t),a=e.expirationTimes;for(var u=t;0<u;){var f=31-bt(u),y=1<<f;a[f]=-1,u&=~y}s!==0&&Xn(e,s,t)}function Hi(){return(Rt&6)===0?(cl(0),!1):!0}function Gd(){if(ft!==null){if(_t===0)var e=ft.return;else e=ft,Ds=Jr=null,id(e),Qo=null,Fa=0,e=ft;for(;e!==null;)Qg(e.alternate,e),e=e.return;ft=null}}function aa(e,t){var s=e.timeoutHandle;s!==-1&&(e.timeoutHandle=-1,ZE(s)),s=e.cancelPendingCommit,s!==null&&(e.cancelPendingCommit=null,s()),Fs=0,Gd(),It=e,ft=s=Ms(e.current,null),ht=t,_t=0,Yn=null,Nr=!1,sa=Oe(e,t),Hd=!1,ra=Pn=Yd=lo=jr=Gt=0,_n=ll=null,Pd=!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-bt(a),f=1<<u;t|=e[u],a&=~f}return qs=t,li(),s}function vx(e,t){lt=null,C.H=Wa,t===Ko||t===hi?(t=Lh(),_t=3):t===Qu?(t=Lh(),_t=4):_t=t===jd?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Yn=t,ft===null&&(Gt=1,Oi(e,Zn(t,e.current)))}function Sx(){var e=Un.current;return e===null?!0:(ht&4194048)===ht?ts===null:(ht&62914560)===ht||(ht&536870912)!==0?e===ts:!1}function Ex(){var e=C.H;return C.H=Wa,e===null?Wa:e}function Nx(){var e=C.A;return C.A=OE,e}function Yi(){Gt=4,Nr||(ht&4194048)!==ht&&Un.current!==null||(sa=!0),(jr&134217727)===0&&(lo&134217727)===0||It===null||Cr(It,ht,Pn,!1)}function Xd(e,t,s){var a=Rt;Rt|=2;var u=Ex(),f=Nx();(It!==e||ht!==t)&&(Ui=null,aa(e,t)),t=!1;var y=Gt;e:do try{if(_t!==0&&ft!==null){var R=ft,P=Yn;switch(_t){case 8:Gd(),y=6;break e;case 3:case 2:case 9:case 6:Un.current===null&&(t=!0);var ie=_t;if(_t=0,Yn=null,la(e,R,P,ie),s&&sa){y=0;break e}break;default:ie=_t,_t=0,Yn=null,la(e,R,P,ie)}}ME(),y=Gt;break}catch(xe){vx(e,xe)}while(!0);return t&&e.shellSuspendCounter++,Ds=Jr=null,Rt=a,C.H=u,C.A=f,ft===null&&(It=null,ht=0,li()),y}function ME(){for(;ft!==null;)jx(ft)}function AE(e,t){var s=Rt;Rt|=2;var a=Ex(),u=Nx();It!==e||ht!==t?(Ui=null,Bi=se()+500,aa(e,t)):sa=Oe(e,t);e:do try{if(_t!==0&&ft!==null){t=ft;var f=Yn;t:switch(_t){case 1:_t=0,Yn=null,la(e,t,f,1);break;case 2:case 9:if(Dh(f)){_t=0,Yn=null,Tx(t);break}t=function(){_t!==2&&_t!==9||It!==e||(_t=7),bs(e)},f.then(t,t);break e;case 3:_t=7;break e;case 4:_t=5;break e;case 7:Dh(f)?(_t=0,Yn=null,Tx(t)):(_t=0,Yn=null,la(e,t,f,7));break;case 5:var y=null;switch(ft.tag){case 26:y=ft.memoizedState;case 5:case 27:var R=ft;if(y?ub(y):R.stateNode.complete){_t=0,Yn=null;var P=R.sibling;if(P!==null)ft=P;else{var ie=R.return;ie!==null?(ft=ie,Pi(ie)):ft=null}break t}}_t=0,Yn=null,la(e,t,f,5);break;case 6:_t=0,Yn=null,la(e,t,f,6);break;case 8:Gd(),Gt=6;break e;default:throw Error(l(462))}}DE();break}catch(xe){vx(e,xe)}while(!0);return Ds=Jr=null,C.H=a,C.A=u,Rt=s,ft!==null?0:(It=null,ht=0,li(),Gt)}function DE(){for(;ft!==null&&!be();)jx(ft)}function jx(e){var t=$g(e.alternate,e,qs);e.memoizedProps=e.pendingProps,t===null?Pi(e):ft=t}function Tx(e){var t=e,s=t.alternate;switch(t.tag){case 15:case 0:t=Pg(s,t,t.pendingProps,t.type,void 0,ht);break;case 11:t=Pg(s,t,t.pendingProps,t.type.render,t.ref,ht);break;case 5:id(t);default:Qg(s,t),t=ft=Nh(t,qs),t=$g(s,t,qs)}e.memoizedProps=e.pendingProps,t===null?Pi(e):ft=t}function la(e,t,s,a){Ds=Jr=null,id(t),Qo=null,Fa=0;var u=t.return;try{if(EE(e,u,t,s,ht)){Gt=1,Oi(e,Zn(s,e.current)),ft=null;return}}catch(f){if(u!==null)throw ft=u,f;Gt=1,Oi(e,Zn(s,e.current)),ft=null;return}t.flags&32768?(yt||a===1?e=!0:sa||(ht&536870912)!==0?e=!1:(Nr=e=!0,(a===2||a===9||a===3||a===6)&&(a=Un.current,a!==null&&a.tag===13&&(a.flags|=16384))),wx(t,e)):Pi(t)}function Pi(e){var t=e;do{if((t.flags&32768)!==0){wx(t,Nr);return}e=t.return;var s=TE(t.alternate,t,qs);if(s!==null){ft=s;return}if(t=t.sibling,t!==null){ft=t;return}ft=t=e}while(t!==null);Gt===0&&(Gt=5)}function wx(e,t){do{var s=wE(e.alternate,e);if(s!==null){s.flags&=32767,ft=s;return}if(s=e.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!t&&(e=e.sibling,e!==null)){ft=e;return}ft=e=s}while(e!==null);Gt=6,ft=null}function Cx(e,t,s,a,u,f,y,R,P){e.cancelPendingCommit=null;do Vi();while(sn!==0);if((Rt&6)!==0)throw Error(l(327));if(t!==null){if(t===e.current)throw Error(l(177));if(f=t.lanes|t.childLanes,f|=zu,Pt(e,s,f,y,R,P),e===It&&(ft=It=null,ht=0),oa=t,wr=e,Fs=s,Vd=f,qd=u,gx=a,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,BE(we,function(){return Mx(),null})):(e.callbackNode=null,e.callbackPriority=0),a=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||a){a=C.T,C.T=null,u=B.p,B.p=2,y=Rt,Rt|=4;try{CE(e,t,s)}finally{Rt=y,B.p=u,C.T=a}}sn=1,Rx(),Ox(),kx()}}function Rx(){if(sn===1){sn=0;var e=wr,t=oa,s=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||s){s=C.T,C.T=null;var a=B.p;B.p=2;var u=Rt;Rt|=4;try{ix(t,e);var f=of,y=ph(e.containerInfo),R=f.focusedElem,P=f.selectionRange;if(y!==R&&R&&R.ownerDocument&&mh(R.ownerDocument.documentElement,R)){if(P!==null&&ku(R)){var ie=P.start,xe=P.end;if(xe===void 0&&(xe=ie),"selectionStart"in R)R.selectionStart=ie,R.selectionEnd=Math.min(xe,R.value.length);else{var Ne=R.ownerDocument||document,ce=Ne&&Ne.defaultView||window;if(ce.getSelection){var pe=ce.getSelection(),Pe=R.textContent.length,Je=Math.min(P.start,Pe),zt=P.end===void 0?Je:Math.min(P.end,Pe);!pe.extend&&Je>zt&&(y=zt,zt=Je,Je=y);var W=fh(R,Je),$=fh(R,zt);if(W&&$&&(pe.rangeCount!==1||pe.anchorNode!==W.node||pe.anchorOffset!==W.offset||pe.focusNode!==$.node||pe.focusOffset!==$.offset)){var le=Ne.createRange();le.setStart(W.node,W.offset),pe.removeAllRanges(),Je>zt?(pe.addRange(le),pe.extend($.node,$.offset)):(le.setEnd($.node,$.offset),pe.addRange(le))}}}}for(Ne=[],pe=R;pe=pe.parentNode;)pe.nodeType===1&&Ne.push({element:pe,left:pe.scrollLeft,top:pe.scrollTop});for(typeof R.focus=="function"&&R.focus(),R=0;R<Ne.length;R++){var Ee=Ne[R];Ee.element.scrollLeft=Ee.left,Ee.element.scrollTop=Ee.top}}tc=!!rf,of=rf=null}finally{Rt=u,B.p=a,C.T=s}}e.current=t,sn=2}}function Ox(){if(sn===2){sn=0;var e=wr,t=oa,s=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||s){s=C.T,C.T=null;var a=B.p;B.p=2;var u=Rt;Rt|=4;try{sx(e,t.alternate,t)}finally{Rt=u,B.p=a,C.T=s}}sn=3}}function kx(){if(sn===4||sn===3){sn=0,qe();var e=wr,t=oa,s=Fs,a=gx;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?sn=5:(sn=0,oa=wr=null,_x(e,e.pendingLanes));var u=e.pendingLanes;if(u===0&&(Tr=null),Ln(s),t=t.stateNode,Nt&&typeof Nt.onCommitFiberRoot=="function")try{Nt.onCommitFiberRoot(rt,t,void 0,(t.current.flags&128)===128)}catch{}if(a!==null){t=C.T,u=B.p,B.p=2,C.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{C.T=t,B.p=u}}(Fs&3)!==0&&Vi(),bs(e),u=e.pendingLanes,(s&261930)!==0&&(u&42)!==0?e===Fd?il++:(il=0,Fd=e):il=0,cl(0)}}function _x(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Va(t)))}function Vi(){return Rx(),Ox(),kx(),Mx()}function Mx(){if(sn!==5)return!1;var e=wr,t=Vd;Vd=0;var s=Ln(Fs),a=C.T,u=B.p;try{B.p=32>s?32:s,C.T=null,s=qd,qd=null;var f=wr,y=Fs;if(sn=0,oa=wr=null,Fs=0,(Rt&6)!==0)throw Error(l(331));var R=Rt;if(Rt|=4,mx(f.current),ux(f,f.current,y,s),Rt=R,cl(0,!1),Nt&&typeof Nt.onPostCommitFiberRoot=="function")try{Nt.onPostCommitFiberRoot(rt,f)}catch{}return!0}finally{B.p=u,C.T=a,_x(e,t)}}function Ax(e,t,s){t=Zn(s,t),t=Nd(e.stateNode,t,2),e=yr(e,t,2),e!==null&&(st(e,2),bs(e))}function Mt(e,t,s){if(e.tag===3)Ax(e,e,s);else for(;t!==null;){if(t.tag===3){Ax(t,e,s);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(Tr===null||!Tr.has(a))){e=Zn(s,e),s=Dg(2),a=yr(t,s,2),a!==null&&(zg(s,a,t,e),st(a,2),bs(a));break}}t=t.return}}function $d(e,t,s){var a=e.pingCache;if(a===null){a=e.pingCache=new kE;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)||(Hd=!0,u.add(s),e=zE.bind(null,e,t,s),t.then(e,e))}function zE(e,t,s){var a=e.pingCache;a!==null&&a.delete(t),e.pingedLanes|=e.suspendedLanes&s,e.warmLanes&=~s,It===e&&(ht&s)===s&&(Gt===4||Gt===3&&(ht&62914560)===ht&&300>se()-Ii?(Rt&2)===0&&aa(e,0):Yd|=s,ra===ht&&(ra=0)),bs(e)}function Dx(e,t){t===0&&(t=tt()),e=Kr(e,t),e!==null&&(st(e,t),bs(e))}function LE(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),Dx(e,s)}function IE(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),Dx(e,s)}function BE(e,t){return Ce(e,t)}var qi=null,ia=null,Kd=!1,Fi=!1,Qd=!1,Rr=0;function bs(e){e!==ia&&e.next===null&&(ia===null?qi=ia=e:ia=ia.next=e),Fi=!0,Kd||(Kd=!0,HE())}function cl(e,t){if(!Qd&&Fi){Qd=!0;do for(var s=!1,a=qi;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-bt(42|e)+1)-1,f&=u&~(y&~R),f=f&201326741?f&201326741|1:f?f|2:0}f!==0&&(s=!0,Bx(a,f))}else f=ht,f=ve(a,a===It?f:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(f&3)===0||Oe(a,f)||(s=!0,Bx(a,f));a=a.next}while(s);Qd=!1}}function UE(){zx()}function zx(){Fi=Kd=!1;var e=0;Rr!==0&&QE()&&(e=Rr);for(var t=se(),s=null,a=qi;a!==null;){var u=a.next,f=Lx(a,t);f===0?(a.next=null,s===null?qi=u:s.next=u,u===null&&(ia=s)):(s=a,(e!==0||(f&3)!==0)&&(Fi=!0)),a=u}sn!==0&&sn!==5||cl(e),Rr!==0&&(Rr=0)}function Lx(e,t){for(var s=e.suspendedLanes,a=e.pingedLanes,u=e.expirationTimes,f=e.pendingLanes&-62914561;0<f;){var y=31-bt(f),R=1<<y,P=u[y];P===-1?((R&s)===0||(R&a)!==0)&&(u[y]=Qe(R,t)):P<=t&&(e.expiredLanes|=R),f&=~R}if(t=It,s=ht,s=ve(e,e===t?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),a=e.callbackNode,s===0||e===t&&(_t===2||_t===9)||e.cancelPendingCommit!==null)return a!==null&&a!==null&&fe(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&&fe(a),Ln(s)){case 2:case 8:s=J;break;case 32:s=we;break;case 268435456:s=je;break;default:s=we}return a=Ix.bind(null,e),s=Ce(s,a),e.callbackPriority=t,e.callbackNode=s,t}return a!==null&&a!==null&&fe(a),e.callbackPriority=2,e.callbackNode=null,2}function Ix(e,t){if(sn!==0&&sn!==5)return e.callbackNode=null,e.callbackPriority=0,null;var s=e.callbackNode;if(Vi()&&e.callbackNode!==s)return null;var a=ht;return a=ve(e,e===It?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),a===0?null:(bx(e,a,t),Lx(e,se()),e.callbackNode!=null&&e.callbackNode===s?Ix.bind(null,e):null)}function Bx(e,t){if(Vi())return null;bx(e,t,!0)}function HE(){JE(function(){(Rt&6)!==0?Ce(ge,UE):zx()})}function Zd(){if(Rr===0){var e=Xo;e===0&&(e=Tt,Tt<<=1,(Tt&261888)===0&&(Tt=256)),Rr=e}return Rr}function Ux(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Wl(""+e)}function Hx(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 YE(e,t,s,a,u){if(t==="submit"&&s&&s.stateNode===u){var f=Ux((u[wn]||null).action),y=a.submitter;y&&(t=(t=y[wn]||null)?Ux(t.formAction):y.getAttribute("formAction"),t!==null&&(f=t,y=null));var R=new si("action","action",null,a,u);e.push({event:R,listeners:[{instance:null,listener:function(){if(a.defaultPrevented){if(Rr!==0){var P=y?Hx(u,y):new FormData(u);xd(s,{pending:!0,data:P,method:u.method,action:f},null,P)}}else typeof f=="function"&&(R.preventDefault(),P=y?Hx(u,y):new FormData(u),xd(s,{pending:!0,data:P,method:u.method,action:f},f,P))},currentTarget:u}]})}}for(var Jd=0;Jd<Du.length;Jd++){var Wd=Du[Jd],PE=Wd.toLowerCase(),VE=Wd[0].toUpperCase()+Wd.slice(1);is(PE,"on"+VE)}is(xh,"onAnimationEnd"),is(bh,"onAnimationIteration"),is(yh,"onAnimationStart"),is("dblclick","onDoubleClick"),is("focusin","onFocus"),is("focusout","onBlur"),is(oE,"onTransitionRun"),is(aE,"onTransitionStart"),is(lE,"onTransitionCancel"),is(vh,"onTransitionEnd"),Ao("onMouseEnter",["mouseout","mouseover"]),Ao("onMouseLeave",["mouseout","mouseover"]),Ao("onPointerEnter",["pointerout","pointerover"]),Ao("onPointerLeave",["pointerout","pointerover"]),Fr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Fr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Fr("onBeforeInput",["compositionend","keypress","textInput","paste"]),Fr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Fr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Fr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ul="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(" "),qE=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ul));function Yx(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],P=R.instance,ie=R.currentTarget;if(R=R.listener,P!==f&&u.isPropagationStopped())break e;f=R,u.currentTarget=ie;try{f(u)}catch(xe){ai(xe)}u.currentTarget=null,f=P}else for(y=0;y<a.length;y++){if(R=a[y],P=R.instance,ie=R.currentTarget,R=R.listener,P!==f&&u.isPropagationStopped())break e;f=R,u.currentTarget=ie;try{f(u)}catch(xe){ai(xe)}u.currentTarget=null,f=P}}}}function mt(e,t){var s=t[fu];s===void 0&&(s=t[fu]=new Set);var a=e+"__bubble";s.has(a)||(Px(t,e,2,!1),s.add(a))}function ef(e,t,s){var a=0;t&&(a|=4),Px(s,e,a,t)}var Gi="_reactListening"+Math.random().toString(36).slice(2);function tf(e){if(!e[Gi]){e[Gi]=!0,zp.forEach(function(s){s!=="selectionchange"&&(qE.has(s)||ef(s,!1,e),ef(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Gi]||(t[Gi]=!0,ef("selectionchange",!1,t))}}function Px(e,t,s,a){switch(xb(t)){case 2:var u=bN;break;case 8:u=yN;break;default:u=xf}s=u.bind(null,t,s,e),u=void 0,!Su||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 nf(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 P=y.tag;if((P===3||P===4)&&y.stateNode.containerInfo===u)return;y=y.return}for(;R!==null;){if(y=ko(R),y===null)return;if(P=y.tag,P===5||P===6||P===26||P===27){a=f=y;continue e}R=R.parentNode}}a=a.return}Xp(function(){var ie=f,xe=yu(s),Ne=[];e:{var ce=Sh.get(e);if(ce!==void 0){var pe=si,Pe=e;switch(e){case"keypress":if(ti(s)===0)break e;case"keydown":case"keyup":pe=IS;break;case"focusin":Pe="focus",pe=Tu;break;case"focusout":Pe="blur",pe=Tu;break;case"beforeblur":case"afterblur":pe=Tu;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":pe=Qp;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":pe=TS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":pe=HS;break;case xh:case bh:case yh:pe=RS;break;case vh:pe=PS;break;case"scroll":case"scrollend":pe=NS;break;case"wheel":pe=qS;break;case"copy":case"cut":case"paste":pe=kS;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":pe=Jp;break;case"toggle":case"beforetoggle":pe=GS}var Je=(t&4)!==0,zt=!Je&&(e==="scroll"||e==="scrollend"),W=Je?ce!==null?ce+"Capture":null:ce;Je=[];for(var $=ie,le;$!==null;){var Ee=$;if(le=Ee.stateNode,Ee=Ee.tag,Ee!==5&&Ee!==26&&Ee!==27||le===null||W===null||(Ee=Ma($,W),Ee!=null&&Je.push(dl($,Ee,le))),zt)break;$=$.return}0<Je.length&&(ce=new pe(ce,Pe,null,s,xe),Ne.push({event:ce,listeners:Je}))}}if((t&7)===0){e:{if(ce=e==="mouseover"||e==="pointerover",pe=e==="mouseout"||e==="pointerout",ce&&s!==bu&&(Pe=s.relatedTarget||s.fromElement)&&(ko(Pe)||Pe[Oo]))break e;if((pe||ce)&&(ce=xe.window===xe?xe:(ce=xe.ownerDocument)?ce.defaultView||ce.parentWindow:window,pe?(Pe=s.relatedTarget||s.toElement,pe=ie,Pe=Pe?ko(Pe):null,Pe!==null&&(zt=d(Pe),Je=Pe.tag,Pe!==zt||Je!==5&&Je!==27&&Je!==6)&&(Pe=null)):(pe=null,Pe=ie),pe!==Pe)){if(Je=Qp,Ee="onMouseLeave",W="onMouseEnter",$="mouse",(e==="pointerout"||e==="pointerover")&&(Je=Jp,Ee="onPointerLeave",W="onPointerEnter",$="pointer"),zt=pe==null?ce:_a(pe),le=Pe==null?ce:_a(Pe),ce=new Je(Ee,$+"leave",pe,s,xe),ce.target=zt,ce.relatedTarget=le,Ee=null,ko(xe)===ie&&(Je=new Je(W,$+"enter",Pe,s,xe),Je.target=le,Je.relatedTarget=zt,Ee=Je),zt=Ee,pe&&Pe)t:{for(Je=FE,W=pe,$=Pe,le=0,Ee=W;Ee;Ee=Je(Ee))le++;Ee=0;for(var Ze=$;Ze;Ze=Je(Ze))Ee++;for(;0<le-Ee;)W=Je(W),le--;for(;0<Ee-le;)$=Je($),Ee--;for(;le--;){if(W===$||$!==null&&W===$.alternate){Je=W;break t}W=Je(W),$=Je($)}Je=null}else Je=null;pe!==null&&Vx(Ne,ce,pe,Je,!1),Pe!==null&&zt!==null&&Vx(Ne,zt,Pe,Je,!0)}}e:{if(ce=ie?_a(ie):window,pe=ce.nodeName&&ce.nodeName.toLowerCase(),pe==="select"||pe==="input"&&ce.type==="file")var wt=ah;else if(rh(ce))if(lh)wt=nE;else{wt=eE;var Fe=WS}else pe=ce.nodeName,!pe||pe.toLowerCase()!=="input"||ce.type!=="checkbox"&&ce.type!=="radio"?ie&&xu(ie.elementType)&&(wt=ah):wt=tE;if(wt&&(wt=wt(e,ie))){oh(Ne,wt,s,xe);break e}Fe&&Fe(e,ce,ie),e==="focusout"&&ie&&ce.type==="number"&&ie.memoizedProps.value!=null&&gu(ce,"number",ce.value)}switch(Fe=ie?_a(ie):window,e){case"focusin":(rh(Fe)||Fe.contentEditable==="true")&&(Uo=Fe,_u=ie,Ha=null);break;case"focusout":Ha=_u=Uo=null;break;case"mousedown":Mu=!0;break;case"contextmenu":case"mouseup":case"dragend":Mu=!1,hh(Ne,s,xe);break;case"selectionchange":if(rE)break;case"keydown":case"keyup":hh(Ne,s,xe)}var it;if(Cu)e:{switch(e){case"compositionstart":var gt="onCompositionStart";break e;case"compositionend":gt="onCompositionEnd";break e;case"compositionupdate":gt="onCompositionUpdate";break e}gt=void 0}else Bo?nh(e,s)&&(gt="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(gt="onCompositionStart");gt&&(Wp&&s.locale!=="ko"&&(Bo||gt!=="onCompositionStart"?gt==="onCompositionEnd"&&Bo&&(it=$p()):(fr=xe,Eu="value"in fr?fr.value:fr.textContent,Bo=!0)),Fe=Xi(ie,gt),0<Fe.length&&(gt=new Zp(gt,e,null,s,xe),Ne.push({event:gt,listeners:Fe}),it?gt.data=it:(it=sh(s),it!==null&&(gt.data=it)))),(it=$S?KS(e,s):QS(e,s))&&(gt=Xi(ie,"onBeforeInput"),0<gt.length&&(Fe=new Zp("onBeforeInput","beforeinput",null,s,xe),Ne.push({event:Fe,listeners:gt}),Fe.data=it)),YE(Ne,e,ie,s,xe)}Yx(Ne,t)})}function dl(e,t,s){return{instance:e,listener:t,currentTarget:s}}function Xi(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=Ma(e,s),u!=null&&a.unshift(dl(e,u,f)),u=Ma(e,t),u!=null&&a.push(dl(e,u,f))),e.tag===3)return a;e=e.return}return[]}function FE(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Vx(e,t,s,a,u){for(var f=t._reactName,y=[];s!==null&&s!==a;){var R=s,P=R.alternate,ie=R.stateNode;if(R=R.tag,P!==null&&P===a)break;R!==5&&R!==26&&R!==27||ie===null||(P=ie,u?(ie=Ma(s,f),ie!=null&&y.unshift(dl(s,ie,P))):u||(ie=Ma(s,f),ie!=null&&y.push(dl(s,ie,P)))),s=s.return}y.length!==0&&e.push({event:t,listeners:y})}var GE=/\r\n?/g,XE=/\u0000|\uFFFD/g;function qx(e){return(typeof e=="string"?e:""+e).replace(GE,`
9
+ `).replace(XE,"")}function Fx(e,t){return t=qx(t),qx(e)===t}function Dt(e,t,s,a,u,f){switch(s){case"children":typeof a=="string"?t==="body"||t==="textarea"&&a===""||zo(e,a):(typeof a=="number"||typeof a=="bigint")&&t!=="body"&&zo(e,""+a);break;case"className":Zl(e,"class",a);break;case"tabIndex":Zl(e,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":Zl(e,s,a);break;case"style":Fp(e,a,f);break;case"data":if(t!=="object"){Zl(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=Wl(""+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"&&Dt(e,t,"name",u.name,u,null),Dt(e,t,"formEncType",u.formEncType,u,null),Dt(e,t,"formMethod",u.formMethod,u,null),Dt(e,t,"formTarget",u.formTarget,u,null)):(Dt(e,t,"encType",u.encType,u,null),Dt(e,t,"method",u.method,u,null),Dt(e,t,"target",u.target,u,null)));if(a==null||typeof a=="symbol"||typeof a=="boolean"){e.removeAttribute(s);break}a=Wl(""+a),e.setAttribute(s,a);break;case"onClick":a!=null&&(e.onclick=ks);break;case"onScroll":a!=null&&mt("scroll",e);break;case"onScrollEnd":a!=null&&mt("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=Wl(""+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":mt("beforetoggle",e),mt("toggle",e),Ql(e,"popover",a);break;case"xlinkActuate":Os(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":Os(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":Os(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":Os(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":Os(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":Os(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":Os(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":Os(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":Os(e,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":Ql(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=SS.get(s)||s,Ql(e,s,a))}}function sf(e,t,s,a,u,f){switch(s){case"style":Fp(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"?zo(e,a):(typeof a=="number"||typeof a=="bigint")&&zo(e,""+a);break;case"onScroll":a!=null&&mt("scroll",e);break;case"onScrollEnd":a!=null&&mt("scrollend",e);break;case"onClick":a!=null&&(e.onclick=ks);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Lp.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,""):Ql(e,s,a)}}}function xn(e,t,s){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":mt("error",e),mt("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:Dt(e,t,f,y,s,null)}}u&&Dt(e,t,"srcSet",s.srcSet,s,null),a&&Dt(e,t,"src",s.src,s,null);return;case"input":mt("invalid",e);var R=f=y=u=null,P=null,ie=null;for(a in s)if(s.hasOwnProperty(a)){var xe=s[a];if(xe!=null)switch(a){case"name":u=xe;break;case"type":y=xe;break;case"checked":P=xe;break;case"defaultChecked":ie=xe;break;case"value":f=xe;break;case"defaultValue":R=xe;break;case"children":case"dangerouslySetInnerHTML":if(xe!=null)throw Error(l(137,t));break;default:Dt(e,t,a,xe,s,null)}}Yp(e,f,R,P,ie,y,u,!1);return;case"select":mt("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:Dt(e,t,u,R,s,null)}t=f,s=y,e.multiple=!!a,t!=null?Do(e,!!a,t,!1):s!=null&&Do(e,!!a,s,!0);return;case"textarea":mt("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:Dt(e,t,y,R,s,null)}Vp(e,a,u,f);return;case"option":for(P in s)s.hasOwnProperty(P)&&(a=s[P],a!=null)&&(P==="selected"?e.selected=a&&typeof a!="function"&&typeof a!="symbol":Dt(e,t,P,a,s,null));return;case"dialog":mt("beforetoggle",e),mt("toggle",e),mt("cancel",e),mt("close",e);break;case"iframe":case"object":mt("load",e);break;case"video":case"audio":for(a=0;a<ul.length;a++)mt(ul[a],e);break;case"image":mt("error",e),mt("load",e);break;case"details":mt("toggle",e);break;case"embed":case"source":case"link":mt("error",e),mt("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(ie in s)if(s.hasOwnProperty(ie)&&(a=s[ie],a!=null))switch(ie){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:Dt(e,t,ie,a,s,null)}return;default:if(xu(t)){for(xe in s)s.hasOwnProperty(xe)&&(a=s[xe],a!==void 0&&sf(e,t,xe,a,s,void 0));return}}for(R in s)s.hasOwnProperty(R)&&(a=s[R],a!=null&&Dt(e,t,R,a,s,null))}function $E(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,P=null,ie=null,xe=null;for(pe in s){var Ne=s[pe];if(s.hasOwnProperty(pe)&&Ne!=null)switch(pe){case"checked":break;case"value":break;case"defaultValue":P=Ne;default:a.hasOwnProperty(pe)||Dt(e,t,pe,null,a,Ne)}}for(var ce in a){var pe=a[ce];if(Ne=s[ce],a.hasOwnProperty(ce)&&(pe!=null||Ne!=null))switch(ce){case"type":f=pe;break;case"name":u=pe;break;case"checked":ie=pe;break;case"defaultChecked":xe=pe;break;case"value":y=pe;break;case"defaultValue":R=pe;break;case"children":case"dangerouslySetInnerHTML":if(pe!=null)throw Error(l(137,t));break;default:pe!==Ne&&Dt(e,t,ce,pe,a,Ne)}}hu(e,y,R,P,ie,xe,f,u);return;case"select":pe=y=R=ce=null;for(f in s)if(P=s[f],s.hasOwnProperty(f)&&P!=null)switch(f){case"value":break;case"multiple":pe=P;default:a.hasOwnProperty(f)||Dt(e,t,f,null,a,P)}for(u in a)if(f=a[u],P=s[u],a.hasOwnProperty(u)&&(f!=null||P!=null))switch(u){case"value":ce=f;break;case"defaultValue":R=f;break;case"multiple":y=f;default:f!==P&&Dt(e,t,u,f,a,P)}t=R,s=y,a=pe,ce!=null?Do(e,!!s,ce,!1):!!a!=!!s&&(t!=null?Do(e,!!s,t,!0):Do(e,!!s,s?[]:"",!1));return;case"textarea":pe=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:Dt(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":pe=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(l(91));break;default:u!==f&&Dt(e,t,y,u,a,f)}Pp(e,ce,pe);return;case"option":for(var Pe in s)ce=s[Pe],s.hasOwnProperty(Pe)&&ce!=null&&!a.hasOwnProperty(Pe)&&(Pe==="selected"?e.selected=!1:Dt(e,t,Pe,null,a,ce));for(P in a)ce=a[P],pe=s[P],a.hasOwnProperty(P)&&ce!==pe&&(ce!=null||pe!=null)&&(P==="selected"?e.selected=ce&&typeof ce!="function"&&typeof ce!="symbol":Dt(e,t,P,ce,a,pe));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 Je in s)ce=s[Je],s.hasOwnProperty(Je)&&ce!=null&&!a.hasOwnProperty(Je)&&Dt(e,t,Je,null,a,ce);for(ie in a)if(ce=a[ie],pe=s[ie],a.hasOwnProperty(ie)&&ce!==pe&&(ce!=null||pe!=null))switch(ie){case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(l(137,t));break;default:Dt(e,t,ie,ce,a,pe)}return;default:if(xu(t)){for(var zt in s)ce=s[zt],s.hasOwnProperty(zt)&&ce!==void 0&&!a.hasOwnProperty(zt)&&sf(e,t,zt,void 0,a,ce);for(xe in a)ce=a[xe],pe=s[xe],!a.hasOwnProperty(xe)||ce===pe||ce===void 0&&pe===void 0||sf(e,t,xe,ce,a,pe);return}}for(var W in s)ce=s[W],s.hasOwnProperty(W)&&ce!=null&&!a.hasOwnProperty(W)&&Dt(e,t,W,null,a,ce);for(Ne in a)ce=a[Ne],pe=s[Ne],!a.hasOwnProperty(Ne)||ce===pe||ce==null&&pe==null||Dt(e,t,Ne,ce,a,pe)}function Gx(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function KE(){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&&Gx(y)){for(y=0,R=u.responseEnd,a+=1;a<s.length;a++){var P=s[a],ie=P.startTime;if(ie>R)break;var xe=P.transferSize,Ne=P.initiatorType;xe&&Gx(Ne)&&(P=P.responseEnd,y+=xe*(P<R?1:(R-ie)/(P-ie)))}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 rf=null,of=null;function $i(e){return e.nodeType===9?e:e.ownerDocument}function Xx(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 $x(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 af(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 lf=null;function QE(){var e=window.event;return e&&e.type==="popstate"?e===lf?!1:(lf=e,!0):(lf=null,!1)}var Kx=typeof setTimeout=="function"?setTimeout:void 0,ZE=typeof clearTimeout=="function"?clearTimeout:void 0,Qx=typeof Promise=="function"?Promise:void 0,JE=typeof queueMicrotask=="function"?queueMicrotask:typeof Qx<"u"?function(e){return Qx.resolve(null).then(e).catch(WE)}:Kx;function WE(e){setTimeout(function(){throw e})}function Or(e){return e==="head"}function Zx(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),fa(t);return}a--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")a++;else if(s==="html")fl(e.ownerDocument.documentElement);else if(s==="head"){s=e.ownerDocument.head,fl(s);for(var f=s.firstChild;f;){var y=f.nextSibling,R=f.nodeName;f[ka]||R==="SCRIPT"||R==="STYLE"||R==="LINK"&&f.rel.toLowerCase()==="stylesheet"||s.removeChild(f),f=y}}else s==="body"&&fl(e.ownerDocument.body);s=u}while(s);fa(t)}function Jx(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 cf(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":cf(s),mu(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}e.removeChild(s)}}function eN(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[ka])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 tN(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 Wx(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 uf(e){return e.data==="$?"||e.data==="$~"}function df(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function nN(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 ff=null;function eb(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 tb(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 nb(e,t,s){switch(t=$i(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 fl(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);mu(e)}var ss=new Map,sb=new Set;function Ki(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Gs=B.d;B.d={f:sN,r:rN,D:oN,C:aN,L:lN,m:iN,X:uN,S:cN,M:dN};function sN(){var e=Gs.f(),t=Hi();return e||t}function rN(e){var t=_o(e);t!==null&&t.tag===5&&t.type==="form"?vg(t):Gs.r(e)}var ca=typeof document>"u"?null:document;function rb(e,t,s){var a=ca;if(a&&typeof t=="string"&&t){var u=Kn(t);u='link[rel="'+e+'"][href="'+u+'"]',typeof s=="string"&&(u+='[crossorigin="'+s+'"]'),sb.has(u)||(sb.add(u),e={rel:e,crossOrigin:s,href:t},a.querySelector(u)===null&&(t=a.createElement("link"),xn(t,"link",e),ln(t),a.head.appendChild(t)))}}function oN(e){Gs.D(e),rb("dns-prefetch",e,null)}function aN(e,t){Gs.C(e,t),rb("preconnect",e,t)}function lN(e,t,s){Gs.L(e,t,s);var a=ca;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=ua(e);break;case"script":f=da(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(ml(f))||t==="script"&&a.querySelector(pl(f))||(t=a.createElement("link"),xn(t,"link",e),ln(t),a.head.appendChild(t)))}}function iN(e,t){Gs.m(e,t);var s=ca;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=da(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(pl(f)))return}a=s.createElement("link"),xn(a,"link",e),ln(a),s.head.appendChild(a)}}}function cN(e,t,s){Gs.S(e,t,s);var a=ca;if(a&&e){var u=Mo(a).hoistableStyles,f=ua(e);t=t||"default";var y=u.get(f);if(!y){var R={loading:0,preload:null};if(y=a.querySelector(ml(f)))R.loading=5;else{e=x({rel:"stylesheet",href:e,"data-precedence":t},s),(s=ss.get(f))&&mf(e,s);var P=y=a.createElement("link");ln(P),xn(P,"link",e),P._p=new Promise(function(ie,xe){P.onload=ie,P.onerror=xe}),P.addEventListener("load",function(){R.loading|=1}),P.addEventListener("error",function(){R.loading|=2}),R.loading|=4,Qi(y,t,a)}y={type:"stylesheet",instance:y,count:1,state:R},u.set(f,y)}}}function uN(e,t){Gs.X(e,t);var s=ca;if(s&&e){var a=Mo(s).hoistableScripts,u=da(e),f=a.get(u);f||(f=s.querySelector(pl(u)),f||(e=x({src:e,async:!0},t),(t=ss.get(u))&&pf(e,t),f=s.createElement("script"),ln(f),xn(f,"link",e),s.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},a.set(u,f))}}function dN(e,t){Gs.M(e,t);var s=ca;if(s&&e){var a=Mo(s).hoistableScripts,u=da(e),f=a.get(u);f||(f=s.querySelector(pl(u)),f||(e=x({src:e,async:!0,type:"module"},t),(t=ss.get(u))&&pf(e,t),f=s.createElement("script"),ln(f),xn(f,"link",e),s.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},a.set(u,f))}}function ob(e,t,s,a){var u=(u=F.current)?Ki(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=ua(s.href),s=Mo(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=ua(s.href);var f=Mo(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(ml(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||fN(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=da(s),s=Mo(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 ua(e){return'href="'+Kn(e)+'"'}function ml(e){return'link[rel="stylesheet"]['+e+"]"}function ab(e){return x({},e,{"data-precedence":e.precedence,precedence:null})}function fN(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}),xn(t,"link",s),ln(t),e.head.appendChild(t))}function da(e){return'[src="'+Kn(e)+'"]'}function pl(e){return"script[async]"+e}function lb(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,ln(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"),ln(a),xn(a,"style",u),Qi(a,s.precedence,e),t.instance=a;case"stylesheet":u=ua(s.href);var f=e.querySelector(ml(u));if(f)return t.state.loading|=4,t.instance=f,ln(f),f;a=ab(s),(u=ss.get(u))&&mf(a,u),f=(e.ownerDocument||e).createElement("link"),ln(f);var y=f;return y._p=new Promise(function(R,P){y.onload=R,y.onerror=P}),xn(f,"link",a),t.state.loading|=4,Qi(f,s.precedence,e),t.instance=f;case"script":return f=da(s.src),(u=e.querySelector(pl(f)))?(t.instance=u,ln(u),u):(a=s,(u=ss.get(f))&&(a=x({},s),pf(a,u)),e=e.ownerDocument||e,u=e.createElement("script"),ln(u),xn(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,Qi(a,s.precedence,e));return t.instance}function Qi(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 mf(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function pf(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Zi=null;function ib(e,t,s){if(Zi===null){var a=new Map,u=Zi=new Map;u.set(s,a)}else u=Zi,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[ka]||f[nn]||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 cb(e,t,s){e=e.ownerDocument||e,e.head.insertBefore(s,t==="title"?e.querySelector("head > title"):null)}function mN(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 ub(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function pN(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=ua(a.href),f=t.querySelector(ml(u));if(f){t=f._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Ji.bind(e),t.then(e,e)),s.state.loading|=4,s.instance=f,ln(f);return}f=t.ownerDocument||t,a=ab(a),(u=ss.get(u))&&mf(a,u),f=f.createElement("link"),ln(f);var y=f;y._p=new Promise(function(R,P){y.onload=R,y.onerror=P}),xn(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=Ji.bind(e),t.addEventListener("load",s),t.addEventListener("error",s))}}var hf=0;function hN(e,t){return e.stylesheets&&e.count===0&&ec(e,e.stylesheets),0<e.count||0<e.imgCount?function(s){var a=setTimeout(function(){if(e.stylesheets&&ec(e,e.stylesheets),e.unsuspend){var f=e.unsuspend;e.unsuspend=null,f()}},6e4+t);0<e.imgBytes&&hf===0&&(hf=62500*KE());var u=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&ec(e,e.stylesheets),e.unsuspend)){var f=e.unsuspend;e.unsuspend=null,f()}},(e.imgBytes>hf?50:800)+t);return e.unsuspend=s,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(u)}}:null}function Ji(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ec(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Wi=null;function ec(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Wi=new Map,t.forEach(gN,e),Wi=null,Ji.call(e))}function gN(e,t){if(!(t.state.loading&4)){var s=Wi.get(e);if(s)var a=s.get(null);else{s=new Map,Wi.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=Ji.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 hl={$$typeof:_,Provider:null,Consumer:null,_currentValue:H,_currentValue2:H,_threadCount:0};function xN(e,t,s,a,u,f,y,R,P){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=at(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=at(0),this.hiddenUpdates=at(null),this.identifierPrefix=a,this.onUncaughtError=u,this.onCaughtError=f,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=P,this.incompleteTransitions=new Map}function db(e,t,s,a,u,f,y,R,P,ie,xe,Ne){return e=new xN(e,t,s,y,P,ie,xe,Ne,R),t=1,f===!0&&(t|=24),f=Bn(3,null,null,t),e.current=f,f.stateNode=e,t=Xu(),t.refCount++,e.pooledCache=t,t.refCount++,f.memoizedState={element:a,isDehydrated:s,cache:t},Zu(f),e}function fb(e){return e?(e=Po,e):Po}function mb(e,t,s,a,u,f){u=fb(u),a.context===null?a.context=u:a.pendingContext=u,a=br(t),a.payload={element:s},f=f===void 0?null:f,f!==null&&(a.callback=f),s=yr(e,a,t),s!==null&&(Mn(s,e,t),Xa(s,e,t))}function pb(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function gf(e,t){pb(e,t),(e=e.alternate)&&pb(e,t)}function hb(e){if(e.tag===13||e.tag===31){var t=Kr(e,67108864);t!==null&&Mn(t,e,67108864),gf(e,67108864)}}function gb(e){if(e.tag===13||e.tag===31){var t=Vn();t=dr(t);var s=Kr(e,t);s!==null&&Mn(s,e,t),gf(e,t)}}var tc=!0;function bN(e,t,s,a){var u=C.T;C.T=null;var f=B.p;try{B.p=2,xf(e,t,s,a)}finally{B.p=f,C.T=u}}function yN(e,t,s,a){var u=C.T;C.T=null;var f=B.p;try{B.p=8,xf(e,t,s,a)}finally{B.p=f,C.T=u}}function xf(e,t,s,a){if(tc){var u=bf(a);if(u===null)nf(e,t,a,nc,s),bb(e,a);else if(SN(u,e,t,s,a))a.stopPropagation();else if(bb(e,a),t&4&&-1<vN.indexOf(e)){for(;u!==null;){var f=_o(u);if(f!==null)switch(f.tag){case 3:if(f=f.stateNode,f.current.memoizedState.isDehydrated){var y=re(f.pendingLanes);if(y!==0){var R=f;for(R.pendingLanes|=2,R.entangledLanes|=2;y;){var P=1<<31-bt(y);R.entanglements[1]|=P,y&=~P}bs(f),(Rt&6)===0&&(Bi=se()+500,cl(0))}}break;case 31:case 13:R=Kr(f,2),R!==null&&Mn(R,f,2),Hi(),gf(f,2)}if(f=bf(a),f===null&&nf(e,t,a,nc,s),f===u)break;u=f}u!==null&&a.stopPropagation()}else nf(e,t,a,null,s)}}function bf(e){return e=yu(e),yf(e)}var nc=null;function yf(e){if(nc=null,e=ko(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 nc=e,null}function xb(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(Y()){case ge:return 2;case J:return 8;case we:case Xe:return 32;case je:return 268435456;default:return 32}default:return 32}}var vf=!1,kr=null,_r=null,Mr=null,gl=new Map,xl=new Map,Ar=[],vN="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 bb(e,t){switch(e){case"focusin":case"focusout":kr=null;break;case"dragenter":case"dragleave":_r=null;break;case"mouseover":case"mouseout":Mr=null;break;case"pointerover":case"pointerout":gl.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":xl.delete(t.pointerId)}}function bl(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=_o(t),t!==null&&hb(t)),e):(e.eventSystemFlags|=a,t=e.targetContainers,u!==null&&t.indexOf(u)===-1&&t.push(u),e)}function SN(e,t,s,a,u){switch(t){case"focusin":return kr=bl(kr,e,t,s,a,u),!0;case"dragenter":return _r=bl(_r,e,t,s,a,u),!0;case"mouseover":return Mr=bl(Mr,e,t,s,a,u),!0;case"pointerover":var f=u.pointerId;return gl.set(f,bl(gl.get(f)||null,e,t,s,a,u)),!0;case"gotpointercapture":return f=u.pointerId,xl.set(f,bl(xl.get(f)||null,e,t,s,a,u)),!0}return!1}function yb(e){var t=ko(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,Kl(e.priority,function(){gb(s)});return}}else if(t===31){if(t=g(s),t!==null){e.blockedOn=t,Kl(e.priority,function(){gb(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 sc(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=bf(e.nativeEvent);if(s===null){s=e.nativeEvent;var a=new s.constructor(s.type,s);bu=a,s.target.dispatchEvent(a),bu=null}else return t=_o(s),t!==null&&hb(t),e.blockedOn=s,!1;t.shift()}return!0}function vb(e,t,s){sc(e)&&s.delete(t)}function EN(){vf=!1,kr!==null&&sc(kr)&&(kr=null),_r!==null&&sc(_r)&&(_r=null),Mr!==null&&sc(Mr)&&(Mr=null),gl.forEach(vb),xl.forEach(vb)}function rc(e,t){e.blockedOn===t&&(e.blockedOn=null,vf||(vf=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,EN)))}var oc=null;function Sb(e){oc!==e&&(oc=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){oc===e&&(oc=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(yf(a||s)===null)continue;break}var f=_o(s);f!==null&&(e.splice(t,3),t-=3,xd(f,{pending:!0,data:u,method:s.method,action:a},a,u))}}))}function fa(e){function t(P){return rc(P,e)}kr!==null&&rc(kr,e),_r!==null&&rc(_r,e),Mr!==null&&rc(Mr,e),gl.forEach(t),xl.forEach(t);for(var s=0;s<Ar.length;s++){var a=Ar[s];a.blockedOn===e&&(a.blockedOn=null)}for(;0<Ar.length&&(s=Ar[0],s.blockedOn===null);)yb(s),s.blockedOn===null&&Ar.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||Sb(s);else if(y){var R=null;if(f&&f.hasAttribute("formAction")){if(u=f,y=f[wn]||null)R=y.formAction;else if(yf(u)!==null)continue}else R=y.action;typeof R=="function"?s[a+1]=R:(s.splice(a,3),a-=3),Sb(s)}}}function Eb(){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 Sf(e){this._internalRoot=e}ac.prototype.render=Sf.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)},ac.prototype.unmount=Sf.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),Hi(),t[Oo]=null}};function ac(e){this._internalRoot=e}ac.prototype.unstable_scheduleHydration=function(e){if(e){var t=Rs();e={blockedOn:null,target:e,priority:t};for(var s=0;s<Ar.length&&t!==0&&t<Ar[s].priority;s++);Ar.splice(s,0,e),s===0&&yb(e)}};var Nb=r.version;if(Nb!=="19.2.8")throw Error(l(527,Nb,"19.2.8"));B.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=h(t),e=e!==null?v(e):null,e=e===null?null:e.stateNode,e};var NN={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:C,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var lc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!lc.isDisabled&&lc.supportsFiber)try{rt=lc.inject(NN),Nt=lc}catch{}}return vl.createRoot=function(e,t){if(!c(e))throw Error(l(299));var s=!1,a="",u=kg,f=_g,y=Mg;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=db(e,1,!1,null,null,s,a,null,u,f,y,Eb),e[Oo]=t.current,tf(e),new Sf(t)},vl.hydrateRoot=function(e,t,s){if(!c(e))throw Error(l(299));var a=!1,u="",f=kg,y=_g,R=Mg,P=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&&(P=s.formState)),t=db(e,1,!0,t,s??null,a,u,P,f,y,R,Eb),t.context=fb(null),s=t.current,a=Vn(),a=dr(a),u=br(a),u.callback=null,yr(s,u,a),s=a,t.current.lanes=s,st(t,s),bs(t),e[Oo]=t.current,tf(e),new ac(t)},vl.version="19.2.8",vl}var Ab;function DN(){if(Ab)return jf.exports;Ab=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(r){console.error(r)}}return n(),jf.exports=AN(),jf.exports}var zN=DN();const Na=["character","setting","location","hook","event"],tm=["belongs_to","owns","masters","ally","rival","mentor","family","kills","appears_in","occurs_at","plot_edge","plants","advances","resolves","depends_on","involves","occurs_in"],LN="plot_edge",IN=["mystery","relationship","item","character_growth","world_building"],wv=["inner","personal","extra_personal"],BN=[5,10,15,30,60];function ls(n){const r=new Date(n);if(Number.isNaN(r.getTime()))return n;const o=l=>String(l).padStart(2,"0");return`${r.getFullYear()}-${o(r.getMonth()+1)}-${o(r.getDate())} ${o(r.getHours())}:${o(r.getMinutes())}`}function xo(n){const r=new Date(n);if(Number.isNaN(r.getTime()))return n;const o=Math.floor((Date.now()-r.getTime())/6e4);if(o<1)return"刚刚";if(o<60)return`${o} 分钟前`;const l=Math.floor(o/60);if(l<24)return`${l} 小时前`;const c=Math.floor(l/24);return c<30?`${c} 天前`:ls(n)}const UN=["outline","entities","canvas","hooks","timeline","trash","settings"];function Db(n){const r=n.replace(/^#/,"").replace(/^\/+/,""),o=r===""?[]:r.split("/").filter(c=>c!=="");return o.length>0&&!UN.includes(o[0])?{path:"/",segments:[],isFallback:!0}:{path:`/${o.join("/")}`,segments:o,isFallback:!1}}function HN(){const[n,r]=p.useState(()=>Db(window.location.hash));return p.useEffect(()=>{const o=()=>{const l=Db(window.location.hash);r(l),l.isFallback&&window.location.hash!=="#/"&&window.location.replace("#/")};return window.addEventListener("hashchange",o),o(),()=>window.removeEventListener("hashchange",o)},[]),n}function Tn(n){const r=n.startsWith("#")?n:`#${n.startsWith("/")?n:`/${n}`}`;window.location.hash!==r&&(window.location.hash=r)}const Cv=(...n)=>n.filter((r,o,l)=>!!r&&r.trim()!==""&&l.indexOf(r)===o).join(" ").trim();const YN=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const PN=n=>n.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,o,l)=>l?l.toUpperCase():o.toLowerCase());const zb=n=>{const r=PN(n);return r.charAt(0).toUpperCase()+r.slice(1)};var Rf={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 VN=n=>{for(const r in n)if(r.startsWith("aria-")||r==="role"||r==="title")return!0;return!1},qN=p.createContext({}),FN=()=>p.useContext(qN),GN=p.forwardRef(({color:n,size:r,strokeWidth:o,absoluteStrokeWidth:l,className:c="",children:d,iconNode:m,...g},b)=>{const{size:h=24,strokeWidth:v=2,absoluteStrokeWidth:x=!1,color:S="currentColor",className:j=""}=FN()??{},N=l??x?Number(o??v)*24/Number(r??h):o??v;return p.createElement("svg",{ref:b,...Rf,width:r??h??Rf.width,height:r??h??Rf.height,stroke:n??S,strokeWidth:N,className:Cv("lucide",j,c),...!d&&!VN(g)&&{"aria-hidden":"true"},...g},[...m.map(([k,O])=>p.createElement(k,O)),...Array.isArray(d)?d:[d]])});const Et=(n,r)=>{const o=p.forwardRef(({className:l,...c},d)=>p.createElement(GN,{ref:d,iconNode:r,className:Cv(`lucide-${YN(zb(n))}`,`lucide-${n}`,l),...c}));return o.displayName=zb(n),o};const XN=[["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"}]],Oc=Et("book-open",XN);const $N=[["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"}]],KN=Et("calendar-clock",$N);const QN=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],ZN=Et("chevron-down",QN);const JN=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Rv=Et("chevron-right",JN);const WN=[["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"}]],wm=Et("circle-alert",WN);const ej=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Cm=Et("circle-check",ej);const tj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],nj=Et("circle",tj);const sj=[["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"}]],rj=Et("download",sj);const oj=[["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"}]],Rm=Et("ellipsis",oj);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"}]],lj=Et("fast-forward",aj);const ij=[["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"}]],cj=Et("grip-vertical",ij);const uj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ov=Et("info",uj);const dj=[["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"}]],fj=Et("layout-grid",dj);const mj=[["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"}]],pj=Et("list-tree",mj);const hj=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Pc=Et("loader-circle",hj);const gj=[["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"}]],Ll=Et("message-square",gj);const xj=[["path",{d:"M5 12h14",key:"1ays0h"}]],bj=Et("minus",xj);const yj=[["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"}]],vj=Et("moon",yj);const Sj=[["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"}]],Ej=Et("network",Sj);const Nj=[["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=Et("octagon-x",Nj);const Tj=[["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"}]],wj=Et("pin",Tj);const Cj=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Om=Et("plus",Cj);const Rj=[["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"}]],Oj=Et("puzzle",Rj);const kj=[["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"}]],_j=Et("refresh-cw",kj);const Mj=[["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"}]],Aj=Et("rotate-ccw",Mj);const Dj=[["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"}]],zj=Et("send",Dj);const Lj=[["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"}]],Ij=Et("settings",Lj);const Bj=[["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"}]],Uj=Et("shapes",Bj);const Hj=[["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"}]],kv=Et("sparkles",Hj);const Yj=[["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"}]],Pj=Et("sun",Yj);const Vj=[["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"}]],_v=Et("trash-2",Vj);const qj=[["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"}]],km=Et("triangle-alert",qj);const Fj=[["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"}]],Gj=Et("upload",Fj);const Xj=[["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"}]],$j=Et("wrench",Xj);const Kj=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],or=Et("x",Kj);function Mv(n){const[r,o]=p.useState(()=>window.matchMedia(n).matches);return p.useEffect(()=>{const l=window.matchMedia(n),c=d=>o(d.matches);return o(l.matches),l.addEventListener("change",c),()=>l.removeEventListener("change",c)},[n]),r}const Lb=n=>{let r;const o=new Set,l=(h,v)=>{const x=typeof h=="function"?h(r):h;if(!Object.is(x,r)){const S=r;r=v??(typeof x!="object"||x===null)?x:Object.assign({},r,x),o.forEach(j=>j(r,S))}},c=()=>r,g={setState:l,getState:c,getInitialState:()=>b,subscribe:h=>(o.add(h),()=>o.delete(h))},b=r=n(l,c,g);return g},Qj=(n=>n?Lb(n):Lb),Zj=n=>n;function Jj(n,r=Zj){const o=_e.useSyncExternalStore(n.subscribe,_e.useCallback(()=>r(n.getState()),[n,r]),_e.useCallback(()=>r(n.getInitialState()),[n,r]));return _e.useDebugValue(o),o}const Ib=n=>{const r=Qj(n),o=l=>Jj(r,l);return Object.assign(o,r),o},_m=(n=>n?Ib(n):Ib),Wj="/api/v1",ct="CLIENT_NETWORK_ERROR";class Ie extends Error{code;constructor(r,o){super(o),this.name="ApiError",this.code=r}}function eT(n){const r=new URLSearchParams;for(const[l,c]of Object.entries(n))c!=null&&r.set(l,String(c));const o=r.toString();return o?`?${o}`:""}function Av(n,r){const o=n.startsWith("/")?n:`/${n}`;return`${Wj}${o}${eT(r??{})}`}function tT(n){return typeof n=="object"&&n!==null&&n.success===!0}function Dv(n){if(typeof n!="object"||n===null)return!1;const r=n.error;return n.success===!1&&typeof r=="object"&&r!==null&&typeof r.code=="string"&&typeof r.message=="string"}async function ut(n,r={}){const{method:o="GET",body:l,query:c,headers:d,signal:m}=r;let g;try{g=await fetch(Av(n,c),{method:o,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(h){throw new Ie(ct,h instanceof Error?h.message:"网络请求失败")}const b=await g.json().catch(()=>null);if(tT(b))return b.data;throw Dv(b)?new Ie(b.error.code,b.error.message):new Ie(ct,`非预期响应(HTTP ${g.status})`)}function nT(){return ut("/project/config")}function sT(n){return ut("/project/config",{method:"PUT",body:n})}function rT(){return ut("/outline")}function oT(n){return ut("/outline",{method:"POST",body:n})}function zv(n,r){return ut(`/outline/${n}`,{method:"PUT",body:r})}function Bb(n,r){return ut(`/outline/${n}/move`,{method:"PUT",body:r})}function aT(n){return ut(`/outline/${n}`,{method:"DELETE"})}function lT(){return ut("/trash")}function iT(n,r){return ut(`/trash/entity/${n}/${r}/restore`,{method:"POST"})}function cT(n,r){return ut(`/trash/entity/${n}/${r}`,{method:"DELETE"})}function Ub(n){return ut(`/trash/outline/${n}/restore`,{method:"POST"})}function uT(n){return ut(`/trash/outline/${n}`,{method:"DELETE"})}function bo(n,r={}){return ut(`/entity/${n}`,{query:r})}function mo(n,r){return ut(`/entity/${n}/${r}`)}function Mm(n,r){return ut(`/entity/${n}`,{method:"POST",body:r})}function Ra(n,r,o){return ut(`/entity/${n}/${r}`,{method:"PUT",body:o})}function Vc(n,r){return ut(`/entity/${n}/${r}`,{method:"DELETE"})}function dT(n,r){return ut(`/entity/event/${n}/move`,{method:"PUT",body:r})}function ja(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 Oa(n){return ut("/relation",{method:"POST",body:n})}function qc(n){return ut(`/relation/${n}`,{method:"DELETE"})}function fT(n,r){return ut(`/relation/${n}`,{method:"PUT",body:{metadata:r}})}function mT(n){return ut(`/delta/node/${n}`)}function pT(n){return ut("/delta/compute",{method:"POST",body:n})}function Am(n){return ut("/delta",{method:"POST",body:n})}function hT(){return ut("/project/list")}function gT(n,r){return ut("/project/create",{method:"POST",body:{path:n,...r!==void 0?{config:r}:{}}})}function xT(n){return ut("/project/open",{method:"POST",body:{path:n}})}function bT(){return ut("/project/close",{method:"POST"})}function yT(n){if(n!==null){const r=/filename\*\s*=\s*UTF-8''([^;]+)/i.exec(n);if(r)try{return decodeURIComponent(r[1])}catch{}const o=/filename\s*=\s*"?([^";]+)"?/i.exec(n);if(o)return o[1]}return"project.zip"}async function vT(){let n;try{n=await fetch(Av("/project/export"))}catch(o){throw new Ie(ct,o instanceof Error?o.message:"网络请求失败")}const r=n.headers.get("content-type")??"";if(n.ok&&(r.includes("zip")||r.includes("octet-stream")))return{blob:await n.blob(),filename:yT(n.headers.get("content-disposition"))};if(r.includes("application/json")){const o=await n.json().catch(()=>null);if(Dv(o))throw new Ie(o.error.code,o.error.message)}throw new Ie(ct,`非预期响应(HTTP ${n.status})`)}async function ST(n,r){const o=new FormData;return o.append("file",n,"backup.zip"),o.append("name",r),ut("/project/import",{method:"POST",body:o})}function ET(){return ut("/project/backups")}function NT(){return ut("/project/backup",{method:"POST"})}function jT(n){return ut("/project/backup/restore",{method:"POST",body:{fileName:n}})}function TT(n){return ut("/project/rename",{method:"POST",body:{name:n}})}function wT(){return ut("/settings/llm")}function Of(n){return ut("/settings/llm",{method:"PUT",body:n})}function CT(){return ut("/chat/sessions").then(n=>n.sessions)}function RT(n){return ut(`/chat/sessions/${n}/messages`)}function OT(n){return ut(`/proposal/${n}/confirm`,{method:"POST"})}function kT(n){return ut(`/proposal/${n}/reject`,{method:"POST"})}const nm=3e3;let _T=0;const ke=_m((n,r)=>({error:null,showError:(o,l)=>n({error:{code:o,message:l}}),clearError:()=>n({error:null}),toast:null,showToast:(o,l="success")=>{const c=++_T;n({toast:{id:c,kind:l,text:o}}),setTimeout(()=>{n(d=>d.toast?.id===c?{toast:null}:{})},nm)},clearToast:()=>n({toast:null}),confirmState:null,confirm:o=>new Promise(l=>{n({confirmState:{...o,resolve:l}})}),resolveConfirm:o=>{const l=r().confirmState;l&&(l.resolve(o),n({confirmState:null}))},focusOutlineNodeId:null,setFocusOutlineNode:o=>n({focusOutlineNodeId:o}),clearFocusOutlineNode:()=>n({focusOutlineNodeId:null}),dataVersion:0,notifyDataChanged:()=>n(o=>({dataVersion:o.dataVersion+1}))})),Ae=_m((n,r)=>({config:null,configLoading:!1,loadError:null,outline:null,outlineLoading:!1,bookshelf:null,bookshelfLoading:!1,bookshelfError:null,loadConfig:async()=>{if(!r().configLoading){n({configLoading:!0});try{const o=await nT();n({config:o,loadError:null})}catch(o){const l=o instanceof Ie?o.code:"CLIENT_NETWORK_ERROR";n({config:null,loadError:l})}finally{n({configLoading:!1})}}},updateConfig:async o=>{await sT(o),await r().loadConfig()},loadOutline:async()=>{if(!r().outlineLoading){n({outlineLoading:!0});try{const o=await rT();n({outline:o})}catch{n({outline:null})}finally{n({outlineLoading:!1})}}},loadBookshelf:async()=>{if(!r().bookshelfLoading){n({bookshelfLoading:!0});try{const o=await hT();n({bookshelf:o,bookshelfError:null})}catch(o){const l=o instanceof Ie?o.code:"CLIENT_NETWORK_ERROR";n({bookshelf:null,bookshelfError:l})}finally{n({bookshelfLoading:!1})}}},openProjectAt:async o=>{const l=await xT(o);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 r().loadOutline()},createProjectAt:async(o,l)=>{await gT(o,l),await r().openProjectAt(o)},closeProject:async()=>{await bT(),n({config:null,loadError:null,outline:null}),ke.getState().clearFocusOutlineNode()}}));function Lv(n,r){if(n.id===r)return n;if("children"in n&&n.children)for(const o of n.children){const l=Lv(o,r);if(l)return l}return null}function Iv(n,r){if(!n||!r)return null;for(const o of n.children){const l=Lv(o,r);if(l)return l.title}return null}function Bv(n,r){return`${n.replace(/\/+$/,"")}/books/${r.trim()}`}const MT="[DONE]",AT=6e4;function DT(n){const r=[];let o=n,l;for(;(l=o.indexOf(`
10
+
11
+ `))!==-1;)r.push(o.slice(0,l)),o=o.slice(l+2);return{frames:r,rest:o}}function Hb(n){let r="message";const o=[];for(const l of n.split(`
12
+ `))if(!(l===""||l.startsWith(":"))){if(l.startsWith("event:"))r=l.slice(6).trim();else if(l.startsWith("data:")){let c=l.slice(5);c.startsWith(" ")&&(c=c.slice(1)),o.push(c)}}return o.length===0?null:{event:r,data:o.join(`
13
+ `)}}function Yb(n){if(typeof n!="object"||n===null)return!1;const r=n.error;return typeof r=="object"&&r!==null&&typeof r.code=="string"&&typeof r.message=="string"}function zT(n,r){const{onEvent:o,timeoutMs:l=AT,onTimeout:c,onEnd:d,signal:m,body:g}=r,b=new AbortController,h=()=>b.abort();m&&(m.aborted?b.abort():m.addEventListener("abort",h));let v="",x=!1,S=!1,j=!1,N=!1,k=null;const O=()=>{k!==null&&(clearTimeout(k),k=null)},E=()=>{O(),k=setTimeout(()=>{x||(S=!0,x=!0,c?.(),b.abort())},l)},T=_=>{if(_.data===MT)return!1;let w=_.data;try{w=JSON.parse(_.data)}catch{}return o(_.event,w),_.event!=="error"};return E(),(async()=>{try{const _=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(!_.ok||!_.body){const A=await _.json().catch(()=>null),U=Yb(A)?A.error.code:ct,M=Yb(A)?A.error.message:`SSE 请求失败(HTTP ${_.status})`;x=!0,N=!0,o("error",{code:U,message:M});return}const w=_.body.getReader(),I=new TextDecoder;for(;!x;){const{done:A,value:U}=await w.read();if(A)break;v=(v+I.decode(U,{stream:!0})).replace(/\r\n/g,`
14
+ `);const{frames:M,rest:K}=DT(v);v=K;for(const oe of M){const Z=Hb(oe);if(Z){if(!T(Z)){x=!0;break}E()}}}if(!x&&v.trim()!==""){const A=Hb(v.trim());A&&!T(A)&&(x=!0)}}catch{!S&&!j&&(x=!0,N=!0,o("error",{code:ct,message:"网络请求失败"}))}finally{O(),m&&m.removeEventListener("abort",h),x=!0,!S&&!j&&!N&&d?.()}})(),()=>{x||(j=!0,x=!0,O(),b.abort())}}function LT(n,r){return r.includes("HTTP 404")?"聊天服务暂不可用":n==="CLIENT_NETWORK_ERROR"&&!r.includes("HTTP ")?"连接失败,请确认服务已启动":r}function IT(n,r){switch(n){case"INTERNAL_ERROR":return"提案执行失败,请让 AI 重新生成提案";case"CLIENT_NETWORK_ERROR":return"网络请求失败,请重试";default:return r}}let ma=0,pa=0,Pb=0,io=null,ys=null,ha=null;const St=_m((n,r)=>{const o=async(l,c,d)=>{const m=r().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 Ie?g.code:"CLIENT_NETWORK_ERROR",h=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(IT(b,h),"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(r().sessionsLoading)return;const l=++ma;n({sessionsLoading:!0});try{const c=await CT();if(l!==ma)return;n({sessions:c,sessionsError:null}),r().currentSessionId===null&&c.length>0&&r().setCurrentSession(c[0].id)}catch(c){if(l!==ma)return;const d=c instanceof Ie?c.code:"CLIENT_NETWORK_ERROR";n({sessions:null,sessionsError:d})}finally{l===ma&&n({sessionsLoading:!1})}},setCurrentSession:l=>{l!==r().currentSessionId&&(pa++,io?.(),io=null,ys=null,ha=null,n({currentSessionId:l,messages:[],messagesLoading:!1,streaming:!1,streamError:null,disconnected:!1,focusContext:null,proposals:[],streamTools:[]}),l!==null&&r().loadMessages(l))},newSession:()=>{ma++,r().setCurrentSession(null)},clearSessions:()=>{ma++,pa++,io?.(),io=null,ys=null,ha=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=++pa;n({messagesLoading:!0});try{const d=await RT(l);if(c!==pa)return;const m=d.messages.map(g=>({...g,sessionId:d.sessionId}));n({messages:m})}catch{if(c!==pa)return;n({messages:[]})}finally{c===pa&&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}=r(),b=l.trim();if(!b||c||d)return;io?.(),io=null;const h=new Date().toISOString(),v=m??"",x=`local-${++Pb}`;ys=x,ha=b,n(j=>({messages:[...j.messages,{id:`local-${++Pb}`,sessionId:v,role:"user",content:b,createdAt:h},{id:x,sessionId:v,role:"assistant",content:"",createdAt:h}],streaming:!0,streamError:null,disconnected:!1,proposals:[],streamTools:[]}));const S={message:b};m&&(S.session_id=m),g&&(S.context=g),io=zT("/api/v1/chat",{body:S,onEvent:(j,N)=>{switch(j){case"ping":break;case"text":{const k=N?.delta??"";ys&&n(O=>({messages:O.messages.map(E=>E.id===ys?{...E,content:(E.content??"")+k}:E)}));break}case"tool_call":{const{tool:k,args:O,id:E}=N;if(!E||!k)break;n(T=>({streamTools:[...T.streamTools,{id:E,tool:k,args:O,status:"running"}]}));break}case"tool_result":{const{id:k}=N;if(!k)break;n(O=>({streamTools:O.streamTools.map(E=>E.id===k?{...E,result:N.result,status:"ok"}:E)}));break}case"proposal":{const{proposal_id:k,type:O,preview:E}=N;if(!k||!O)break;n(T=>({proposals:[...T.proposals,{proposalId:k,type:O,preview:E,status:"pending"}]}));break}case"done":{if(ys===null)break;const k=N?.session_id;n({streaming:!1,currentSessionId:k??r().currentSessionId}),k&&r().loadSessions();break}case"error":{const{code:k,message:O}=N;n({streaming:!1,streamError:LT(k??"",O??"")});break}}},onTimeout:()=>{ys===x&&(ys=null,n({streaming:!1,disconnected:!0,proposals:[],streamTools:[]}))},onEnd:()=>{ys===x&&(ys=null,n(j=>j.streaming?{streaming:!1}:{}))}})},resendLast:()=>{const{messages:l,streaming:c}=r();if(c||!ha)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===ha&&(d=d.slice(0,-1)),n({messages:d}),r().sendMessage(ha)},confirmProposal:l=>o(l,OT,"confirmed"),rejectProposal:l=>o(l,kT,"rejected")}});let Vb=Ae.getState().config?.id??null;Ae.subscribe(n=>{const r=n.config?.id??null;r!==Vb&&(Vb=r,St.getState().clearSessions(),r!==null&&St.getState().loadSessions())});function Uv(n){var r,o,l="";if(typeof n=="string"||typeof n=="number")l+=n;else if(typeof n=="object")if(Array.isArray(n)){var c=n.length;for(r=0;r<c;r++)n[r]&&(o=Uv(n[r]))&&(l&&(l+=" "),l+=o)}else for(o in n)n[o]&&(l&&(l+=" "),l+=o);return l}function Hv(){for(var n,r,o=0,l="",c=arguments.length;o<c;o++)(n=arguments[o])&&(r=Uv(n))&&(l&&(l+=" "),l+=r);return l}const BT=(n,r)=>{const o=new Array(n.length+r.length);for(let l=0;l<n.length;l++)o[l]=n[l];for(let l=0;l<r.length;l++)o[n.length+l]=r[l];return o},UT=(n,r)=>({classGroupId:n,validator:r}),Yv=(n=new Map,r=null,o)=>({nextPart:n,validators:r,classGroupId:o}),kc="-",qb=[],HT="arbitrary..",YT=n=>{const r=VT(n),{conflictingClassGroups:o,conflictingClassGroupModifiers:l}=n;return{getClassGroupId:m=>{if(m.startsWith("[")&&m.endsWith("]"))return PT(m);const g=m.split(kc),b=g[0]===""&&g.length>1?1:0;return Pv(g,b,r)},getConflictingClassGroupIds:(m,g)=>{if(g){const b=l[m],h=o[m];return b?h?BT(h,b):b:h||qb}return o[m]||qb}}},Pv=(n,r,o)=>{if(n.length-r===0)return o.classGroupId;const c=n[r],d=o.nextPart.get(c);if(d){const h=Pv(n,r+1,d);if(h)return h}const m=o.validators;if(m===null)return;const g=r===0?n.join(kc):n.slice(r).join(kc),b=m.length;for(let h=0;h<b;h++){const v=m[h];if(v.validator(g))return v.classGroupId}},PT=n=>n.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=n.slice(1,-1),o=r.indexOf(":"),l=r.slice(0,o);return l?HT+l:void 0})(),VT=n=>{const{theme:r,classGroups:o}=n;return qT(o,r)},qT=(n,r)=>{const o=Yv();for(const l in n){const c=n[l];Dm(c,o,l,r)}return o},Dm=(n,r,o,l)=>{const c=n.length;for(let d=0;d<c;d++){const m=n[d];FT(m,r,o,l)}},FT=(n,r,o,l)=>{if(typeof n=="string"){GT(n,r,o);return}if(typeof n=="function"){XT(n,r,o,l);return}$T(n,r,o,l)},GT=(n,r,o)=>{const l=n===""?r:Vv(r,n);l.classGroupId=o},XT=(n,r,o,l)=>{if(KT(n)){Dm(n(l),r,o,l);return}r.validators===null&&(r.validators=[]),r.validators.push(UT(o,n))},$T=(n,r,o,l)=>{const c=Object.entries(n),d=c.length;for(let m=0;m<d;m++){const[g,b]=c[m];Dm(b,Vv(r,g),o,l)}},Vv=(n,r)=>{let o=n;const l=r.split(kc),c=l.length;for(let d=0;d<c;d++){const m=l[d];let g=o.nextPart.get(m);g||(g=Yv(),o.nextPart.set(m,g)),o=g}return o},KT=n=>"isThemeGetter"in n&&n.isThemeGetter===!0,QT=n=>{if(n<1)return{get:()=>{},set:()=>{}};let r=0,o=Object.create(null),l=Object.create(null);const c=(d,m)=>{o[d]=m,r++,r>n&&(r=0,l=o,o=Object.create(null))};return{get(d){let m=o[d];if(m!==void 0)return m;if((m=l[d])!==void 0)return c(d,m),m},set(d,m){d in o?o[d]=m:c(d,m)}}},sm="!",Fb=":",ZT=[],Gb=(n,r,o,l,c)=>({modifiers:n,hasImportantModifier:r,baseClassName:o,maybePostfixModifierPosition:l,isExternal:c}),JT=n=>{const{prefix:r,experimentalParseClassName:o}=n;let l=c=>{const d=[];let m=0,g=0,b=0,h;const v=c.length;for(let k=0;k<v;k++){const O=c[k];if(m===0&&g===0){if(O===Fb){d.push(c.slice(b,k)),b=k+1;continue}if(O==="/"){h=k;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(sm)?(S=x.slice(0,-1),j=!0):x.startsWith(sm)&&(S=x.slice(1),j=!0);const N=h&&h>b?h-b:void 0;return Gb(d,j,S,N)};if(r){const c=r+Fb,d=l;l=m=>m.startsWith(c)?d(m.slice(c.length)):Gb(ZT,!1,m,void 0,!0)}if(o){const c=l;l=d=>o({className:d,parseClassName:c})}return l},WT=n=>{const r=new Map;return n.orderSensitiveModifiers.forEach((o,l)=>{r.set(o,1e6+l)}),o=>{const l=[];let c=[];for(let d=0;d<o.length;d++){const m=o[d],g=m[0]==="[",b=r.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}},e2=n=>({cache:QT(n.cacheSize),parseClassName:JT(n),sortModifiers:WT(n),postfixLookupClassGroupIds:t2(n),...YT(n)}),t2=n=>{const r=Object.create(null),o=n.postfixLookupClassGroups;if(o)for(let l=0;l<o.length;l++)r[o[l]]=!0;return r},n2=/\s+/,s2=(n,r)=>{const{parseClassName:o,getClassGroupId:l,getConflictingClassGroupIds:c,sortModifiers:d,postfixLookupClassGroupIds:m}=r,g=[],b=n.trim().split(n2);let h="";for(let v=b.length-1;v>=0;v-=1){const x=b[v],{isExternal:S,modifiers:j,hasImportantModifier:N,baseClassName:k,maybePostfixModifierPosition:O}=o(x);if(S){h=x+(h.length>0?" "+h:h);continue}let E=!!O,T;if(E){const U=k.substring(0,O);T=l(U);const M=T&&m[T]?l(k):void 0;M&&M!==T&&(T=M,E=!1)}else T=l(k);if(!T){if(!E){h=x+(h.length>0?" "+h:h);continue}if(T=l(k),!T){h=x+(h.length>0?" "+h:h);continue}E=!1}const _=j.length===0?"":j.length===1?j[0]:d(j).join(":"),w=N?_+sm:_,I=w+T;if(g.indexOf(I)>-1)continue;g.push(I);const A=c(T,E);for(let U=0;U<A.length;++U){const M=A[U];g.push(w+M)}h=x+(h.length>0?" "+h:h)}return h},r2=(...n)=>{let r=0,o,l,c="";for(;r<n.length;)(o=n[r++])&&(l=qv(o))&&(c&&(c+=" "),c+=l);return c},qv=n=>{if(typeof n=="string")return n;let r,o="";for(let l=0;l<n.length;l++)n[l]&&(r=qv(n[l]))&&(o&&(o+=" "),o+=r);return o},o2=(n,...r)=>{let o,l,c,d;const m=b=>{const h=r.reduce((v,x)=>x(v),n());return o=e2(h),l=o.cache.get,c=o.cache.set,d=g,g(b)},g=b=>{const h=l(b);if(h)return h;const v=s2(b,o);return c(b,v),v};return d=m,(...b)=>d(r2(...b))},a2=[],rn=n=>{const r=o=>o[n]||a2;return r.isThemeGetter=!0,r},Fv=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Gv=/^\((?:(\w[\w-]*):)?(.+)\)$/i,l2=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,i2=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,c2=/\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$/,u2=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,d2=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,f2=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,zr=n=>l2.test(n),dt=n=>!!n&&!Number.isNaN(Number(n)),vs=n=>!!n&&Number.isInteger(Number(n)),kf=n=>n.endsWith("%")&&dt(n.slice(0,-1)),Xs=n=>i2.test(n),Xv=()=>!0,m2=n=>c2.test(n)&&!u2.test(n),zm=()=>!1,p2=n=>d2.test(n),h2=n=>f2.test(n),g2=n=>!Ue(n)&&!He(n),x2=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)),b2=n=>Pr(n,Qv,zm),Ue=n=>Fv.test(n),co=n=>Pr(n,Zv,m2),Xb=n=>Pr(n,w2,dt),y2=n=>Pr(n,Wv,Xv),v2=n=>Pr(n,Jv,zm),$b=n=>Pr(n,$v,zm),S2=n=>Pr(n,Kv,h2),ic=n=>Pr(n,e0,p2),He=n=>Gv.test(n),Sl=n=>No(n,Zv),E2=n=>No(n,Jv),Kb=n=>No(n,$v),N2=n=>No(n,Qv),j2=n=>No(n,Kv),cc=n=>No(n,e0,!0),T2=n=>No(n,Wv,!0),Pr=(n,r,o)=>{const l=Fv.exec(n);return l?l[1]?r(l[1]):o(l[2]):!1},No=(n,r,o=!1)=>{const l=Gv.exec(n);return l?l[1]?r(l[1]):o:!1},$v=n=>n==="position"||n==="percentage",Kv=n=>n==="image"||n==="url",Qv=n=>n==="length"||n==="size"||n==="bg-size",Zv=n=>n==="length",w2=n=>n==="number",Jv=n=>n==="family-name",Wv=n=>n==="number"||n==="weight",e0=n=>n==="shadow",C2=()=>{const n=rn("color"),r=rn("font"),o=rn("text"),l=rn("font-weight"),c=rn("tracking"),d=rn("leading"),m=rn("breakpoint"),g=rn("container"),b=rn("spacing"),h=rn("radius"),v=rn("shadow"),x=rn("inset-shadow"),S=rn("text-shadow"),j=rn("drop-shadow"),N=rn("blur"),k=rn("perspective"),O=rn("aspect"),E=rn("ease"),T=rn("animate"),_=()=>["auto","avoid","all","avoid-page","page","left","right","column"],w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],I=()=>[...w(),He,Ue],A=()=>["auto","hidden","clip","visible","scroll"],U=()=>["auto","contain","none"],M=()=>[He,Ue,b],K=()=>[zr,"full","auto",...M()],oe=()=>[vs,"none","subgrid",He,Ue],Z=()=>["auto",{span:["full",vs,He,Ue]},vs,He,Ue],ee=()=>[vs,"auto",He,Ue],G=()=>["auto","min","max","fr",He,Ue],te=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],X=()=>["start","end","center","stretch","center-safe","end-safe"],C=()=>["auto",...M()],B=()=>[zr,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...M()],H=()=>[zr,"screen","full","dvw","lvw","svw","min","max","fit",...M()],z=()=>[zr,"screen","full","lh","dvh","lvh","svh","min","max","fit",...M()],L=()=>[n,He,Ue],D=()=>[...w(),Kb,$b,{position:[He,Ue]}],q=()=>["no-repeat",{repeat:["","x","y","space","round"]}],V=()=>["auto","cover","contain",N2,b2,{size:[He,Ue]}],Q=()=>[kf,Sl,co],ne=()=>["","none","full",h,He,Ue],F=()=>["",dt,Sl,co],Te=()=>["solid","dashed","dotted","double"],me=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],he=()=>[dt,kf,Kb,$b],Le=()=>["","none",N,He,Ue],Ve=()=>["none",dt,He,Ue],Re=()=>["none",dt,He,Ue],ze=()=>[dt,He,Ue],De=()=>[zr,"full",...M()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Xs],breakpoint:[Xs],color:[Xv],container:[Xs],"drop-shadow":[Xs],ease:["in","out","in-out"],font:[g2],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Xs],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Xs],shadow:[Xs],spacing:["px",dt],text:[Xs],"text-shadow":[Xs],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",zr,Ue,He,O]}],container:["container"],"container-type":[{"@container":["","normal","size",He,Ue]}],"container-named":[x2],columns:[{columns:[dt,Ue,He,g]}],"break-after":[{"break-after":_()}],"break-before":[{"break-before":_()}],"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:I()}],overflow:[{overflow:A()}],"overflow-x":[{"overflow-x":A()}],"overflow-y":[{"overflow-y":A()}],overscroll:[{overscroll:U()}],"overscroll-x":[{"overscroll-x":U()}],"overscroll-y":[{"overscroll-y":U()}],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",He,Ue]}],basis:[{basis:[zr,"full","auto",g,...M()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[dt,zr,"auto","initial","none",Ue]}],grow:[{grow:["",dt,He,Ue]}],shrink:[{shrink:["",dt,He,Ue]}],order:[{order:[vs,"first","last","none",He,Ue]}],"grid-cols":[{"grid-cols":oe()}],"col-start-end":[{col:Z()}],"col-start":[{"col-start":ee()}],"col-end":[{"col-end":ee()}],"grid-rows":[{"grid-rows":oe()}],"row-start-end":[{row:Z()}],"row-start":[{"row-start":ee()}],"row-end":[{"row-end":ee()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":G()}],"auto-rows":[{"auto-rows":G()}],gap:[{gap:M()}],"gap-x":[{"gap-x":M()}],"gap-y":[{"gap-y":M()}],"justify-content":[{justify:[...te(),"normal"]}],"justify-items":[{"justify-items":[...X(),"normal"]}],"justify-self":[{"justify-self":["auto",...X()]}],"align-content":[{content:["normal",...te()]}],"align-items":[{items:[...X(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...X(),{baseline:["","last"]}]}],"place-content":[{"place-content":te()}],"place-items":[{"place-items":[...X(),"baseline"]}],"place-self":[{"place-self":["auto",...X()]}],p:[{p:M()}],px:[{px:M()}],py:[{py:M()}],ps:[{ps:M()}],pe:[{pe:M()}],pbs:[{pbs:M()}],pbe:[{pbe:M()}],pt:[{pt:M()}],pr:[{pr:M()}],pb:[{pb:M()}],pl:[{pl:M()}],m:[{m:C()}],mx:[{mx:C()}],my:[{my:C()}],ms:[{ms:C()}],me:[{me:C()}],mbs:[{mbs:C()}],mbe:[{mbe:C()}],mt:[{mt:C()}],mr:[{mr:C()}],mb:[{mb:C()}],ml:[{ml:C()}],"space-x":[{"space-x":M()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":M()}],"space-y-reverse":["space-y-reverse"],size:[{size:B()}],"inline-size":[{inline:["auto",...H()]}],"min-inline-size":[{"min-inline":["auto",...H()]}],"max-inline-size":[{"max-inline":["none",...H()]}],"block-size":[{block:["auto",...z()]}],"min-block-size":[{"min-block":["auto",...z()]}],"max-block-size":[{"max-block":["none",...z()]}],w:[{w:[g,"screen",...B()]}],"min-w":[{"min-w":[g,"screen","none",...B()]}],"max-w":[{"max-w":[g,"screen","none","prose",{screen:[m]},...B()]}],h:[{h:["screen","lh",...B()]}],"min-h":[{"min-h":["screen","lh","none",...B()]}],"max-h":[{"max-h":["screen","lh",...B()]}],"font-size":[{text:["base",o,Sl,co]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[l,T2,y2]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",kf,Ue]}],"font-family":[{font:[E2,v2,r]}],"font-features":[{"font-features":[Ue]}],"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,He,Ue]}],"line-clamp":[{"line-clamp":[dt,"none",He,Xb]}],leading:[{leading:[d,...M()]}],"list-image":[{"list-image":["none",He,Ue]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",He,Ue]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:L()}],"text-color":[{text:L()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Te(),"wavy"]}],"text-decoration-thickness":[{decoration:[dt,"from-font","auto",He,co]}],"text-decoration-color":[{decoration:L()}],"underline-offset":[{"underline-offset":[dt,"auto",He,Ue]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:M()}],"tab-size":[{tab:[vs,He,Ue]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",He,Ue]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",He,Ue]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:D()}],"bg-repeat":[{bg:q()}],"bg-size":[{bg:V()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},vs,He,Ue],radial:["",He,Ue],conic:[vs,He,Ue]},j2,S2]}],"bg-color":[{bg:L()}],"gradient-from-pos":[{from:Q()}],"gradient-via-pos":[{via:Q()}],"gradient-to-pos":[{to:Q()}],"gradient-from":[{from:L()}],"gradient-via":[{via:L()}],"gradient-to":[{to:L()}],rounded:[{rounded:ne()}],"rounded-s":[{"rounded-s":ne()}],"rounded-e":[{"rounded-e":ne()}],"rounded-t":[{"rounded-t":ne()}],"rounded-r":[{"rounded-r":ne()}],"rounded-b":[{"rounded-b":ne()}],"rounded-l":[{"rounded-l":ne()}],"rounded-ss":[{"rounded-ss":ne()}],"rounded-se":[{"rounded-se":ne()}],"rounded-ee":[{"rounded-ee":ne()}],"rounded-es":[{"rounded-es":ne()}],"rounded-tl":[{"rounded-tl":ne()}],"rounded-tr":[{"rounded-tr":ne()}],"rounded-br":[{"rounded-br":ne()}],"rounded-bl":[{"rounded-bl":ne()}],"border-w":[{border:F()}],"border-w-x":[{"border-x":F()}],"border-w-y":[{"border-y":F()}],"border-w-s":[{"border-s":F()}],"border-w-e":[{"border-e":F()}],"border-w-bs":[{"border-bs":F()}],"border-w-be":[{"border-be":F()}],"border-w-t":[{"border-t":F()}],"border-w-r":[{"border-r":F()}],"border-w-b":[{"border-b":F()}],"border-w-l":[{"border-l":F()}],"divide-x":[{"divide-x":F()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":F()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Te(),"hidden","none"]}],"divide-style":[{divide:[...Te(),"hidden","none"]}],"border-color":[{border:L()}],"border-color-x":[{"border-x":L()}],"border-color-y":[{"border-y":L()}],"border-color-s":[{"border-s":L()}],"border-color-e":[{"border-e":L()}],"border-color-bs":[{"border-bs":L()}],"border-color-be":[{"border-be":L()}],"border-color-t":[{"border-t":L()}],"border-color-r":[{"border-r":L()}],"border-color-b":[{"border-b":L()}],"border-color-l":[{"border-l":L()}],"divide-color":[{divide:L()}],"outline-style":[{outline:[...Te(),"none","hidden"]}],"outline-offset":[{"outline-offset":[dt,He,Ue]}],"outline-w":[{outline:["",dt,Sl,co]}],"outline-color":[{outline:L()}],shadow:[{shadow:["","none",v,cc,ic]}],"shadow-color":[{shadow:L()}],"inset-shadow":[{"inset-shadow":["none",x,cc,ic]}],"inset-shadow-color":[{"inset-shadow":L()}],"ring-w":[{ring:F()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:L()}],"ring-offset-w":[{"ring-offset":[dt,co]}],"ring-offset-color":[{"ring-offset":L()}],"inset-ring-w":[{"inset-ring":F()}],"inset-ring-color":[{"inset-ring":L()}],"text-shadow":[{"text-shadow":["none",S,cc,ic]}],"text-shadow-color":[{"text-shadow":L()}],opacity:[{opacity:[dt,He,Ue]}],"mix-blend":[{"mix-blend":[...me(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":me()}],"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":[dt]}],"mask-image-linear-from-pos":[{"mask-linear-from":he()}],"mask-image-linear-to-pos":[{"mask-linear-to":he()}],"mask-image-linear-from-color":[{"mask-linear-from":L()}],"mask-image-linear-to-color":[{"mask-linear-to":L()}],"mask-image-t-from-pos":[{"mask-t-from":he()}],"mask-image-t-to-pos":[{"mask-t-to":he()}],"mask-image-t-from-color":[{"mask-t-from":L()}],"mask-image-t-to-color":[{"mask-t-to":L()}],"mask-image-r-from-pos":[{"mask-r-from":he()}],"mask-image-r-to-pos":[{"mask-r-to":he()}],"mask-image-r-from-color":[{"mask-r-from":L()}],"mask-image-r-to-color":[{"mask-r-to":L()}],"mask-image-b-from-pos":[{"mask-b-from":he()}],"mask-image-b-to-pos":[{"mask-b-to":he()}],"mask-image-b-from-color":[{"mask-b-from":L()}],"mask-image-b-to-color":[{"mask-b-to":L()}],"mask-image-l-from-pos":[{"mask-l-from":he()}],"mask-image-l-to-pos":[{"mask-l-to":he()}],"mask-image-l-from-color":[{"mask-l-from":L()}],"mask-image-l-to-color":[{"mask-l-to":L()}],"mask-image-x-from-pos":[{"mask-x-from":he()}],"mask-image-x-to-pos":[{"mask-x-to":he()}],"mask-image-x-from-color":[{"mask-x-from":L()}],"mask-image-x-to-color":[{"mask-x-to":L()}],"mask-image-y-from-pos":[{"mask-y-from":he()}],"mask-image-y-to-pos":[{"mask-y-to":he()}],"mask-image-y-from-color":[{"mask-y-from":L()}],"mask-image-y-to-color":[{"mask-y-to":L()}],"mask-image-radial":[{"mask-radial":[He,Ue]}],"mask-image-radial-from-pos":[{"mask-radial-from":he()}],"mask-image-radial-to-pos":[{"mask-radial-to":he()}],"mask-image-radial-from-color":[{"mask-radial-from":L()}],"mask-image-radial-to-color":[{"mask-radial-to":L()}],"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":w()}],"mask-image-conic-pos":[{"mask-conic":[dt]}],"mask-image-conic-from-pos":[{"mask-conic-from":he()}],"mask-image-conic-to-pos":[{"mask-conic-to":he()}],"mask-image-conic-from-color":[{"mask-conic-from":L()}],"mask-image-conic-to-color":[{"mask-conic-to":L()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:D()}],"mask-repeat":[{mask:q()}],"mask-size":[{mask:V()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",He,Ue]}],filter:[{filter:["","none",He,Ue]}],blur:[{blur:Le()}],brightness:[{brightness:[dt,He,Ue]}],contrast:[{contrast:[dt,He,Ue]}],"drop-shadow":[{"drop-shadow":["","none",j,cc,ic]}],"drop-shadow-color":[{"drop-shadow":L()}],grayscale:[{grayscale:["",dt,He,Ue]}],"hue-rotate":[{"hue-rotate":[dt,He,Ue]}],invert:[{invert:["",dt,He,Ue]}],saturate:[{saturate:[dt,He,Ue]}],sepia:[{sepia:["",dt,He,Ue]}],"backdrop-filter":[{"backdrop-filter":["","none",He,Ue]}],"backdrop-blur":[{"backdrop-blur":Le()}],"backdrop-brightness":[{"backdrop-brightness":[dt,He,Ue]}],"backdrop-contrast":[{"backdrop-contrast":[dt,He,Ue]}],"backdrop-grayscale":[{"backdrop-grayscale":["",dt,He,Ue]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[dt,He,Ue]}],"backdrop-invert":[{"backdrop-invert":["",dt,He,Ue]}],"backdrop-opacity":[{"backdrop-opacity":[dt,He,Ue]}],"backdrop-saturate":[{"backdrop-saturate":[dt,He,Ue]}],"backdrop-sepia":[{"backdrop-sepia":["",dt,He,Ue]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":M()}],"border-spacing-x":[{"border-spacing-x":M()}],"border-spacing-y":[{"border-spacing-y":M()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",He,Ue]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[dt,"initial",He,Ue]}],ease:[{ease:["linear","initial",E,He,Ue]}],delay:[{delay:[dt,He,Ue]}],animate:[{animate:["none",T,He,Ue]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[k,He,Ue]}],"perspective-origin":[{"perspective-origin":I()}],rotate:[{rotate:Ve()}],"rotate-x":[{"rotate-x":Ve()}],"rotate-y":[{"rotate-y":Ve()}],"rotate-z":[{"rotate-z":Ve()}],scale:[{scale:Re()}],"scale-x":[{"scale-x":Re()}],"scale-y":[{"scale-y":Re()}],"scale-z":[{"scale-z":Re()}],"scale-3d":["scale-3d"],skew:[{skew:ze()}],"skew-x":[{"skew-x":ze()}],"skew-y":[{"skew-y":ze()}],transform:[{transform:[He,Ue,"","none","gpu","cpu"]}],"transform-origin":[{origin:I()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:De()}],"translate-x":[{"translate-x":De()}],"translate-y":[{"translate-y":De()}],"translate-z":[{"translate-z":De()}],"translate-none":["translate-none"],zoom:[{zoom:[vs,He,Ue]}],accent:[{accent:L()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:L()}],"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",He,Ue]}],"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":L()}],"scrollbar-track-color":[{"scrollbar-track":L()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":M()}],"scroll-mx":[{"scroll-mx":M()}],"scroll-my":[{"scroll-my":M()}],"scroll-ms":[{"scroll-ms":M()}],"scroll-me":[{"scroll-me":M()}],"scroll-mbs":[{"scroll-mbs":M()}],"scroll-mbe":[{"scroll-mbe":M()}],"scroll-mt":[{"scroll-mt":M()}],"scroll-mr":[{"scroll-mr":M()}],"scroll-mb":[{"scroll-mb":M()}],"scroll-ml":[{"scroll-ml":M()}],"scroll-p":[{"scroll-p":M()}],"scroll-px":[{"scroll-px":M()}],"scroll-py":[{"scroll-py":M()}],"scroll-ps":[{"scroll-ps":M()}],"scroll-pe":[{"scroll-pe":M()}],"scroll-pbs":[{"scroll-pbs":M()}],"scroll-pbe":[{"scroll-pbe":M()}],"scroll-pt":[{"scroll-pt":M()}],"scroll-pr":[{"scroll-pr":M()}],"scroll-pb":[{"scroll-pb":M()}],"scroll-pl":[{"scroll-pl":M()}],"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",He,Ue]}],fill:[{fill:["none",...L()]}],"stroke-w":[{stroke:[dt,Sl,co,Xb]}],stroke:[{stroke:["none",...L()]}],"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"]}},R2=o2(C2);function et(...n){return R2(Hv(n))}function Fc(){return typeof window<"u"}function bn(n){return Lm(n)?(n.nodeName||"").toLowerCase():"#document"}function Xt(n){var r;return(n==null||(r=n.ownerDocument)==null?void 0:r.defaultView)||window}function cr(n){var r;return(r=(Lm(n)?n.ownerDocument:n.document)||window.document)==null?void 0:r.documentElement}function Lm(n){return Fc()?n instanceof Node||n instanceof Xt(n).Node:!1}function xt(n){return Fc()?n instanceof Element||n instanceof Xt(n).Element:!1}function Bt(n){return Fc()?n instanceof HTMLElement||n instanceof Xt(n).HTMLElement:!1}function Ta(n){return!Fc()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Xt(n).ShadowRoot}function jo(n){const{overflow:r,overflowX:o,overflowY:l,display:c}=Fn(n);return/auto|scroll|overlay|hidden|clip/.test(r+l+o)&&c!=="inline"&&c!=="contents"}function O2(n){return/^(table|td|th)$/.test(bn(n))}function Gc(n){try{if(n.matches(":popover-open"))return!0}catch{}try{return n.matches(":modal")}catch{return!1}}const k2=/transform|translate|scale|rotate|perspective|filter/,_2=/paint|layout|strict|content/,uo=n=>!!n&&n!=="none";let _f;function Im(n){const r=xt(n)?Fn(n):n;return uo(r.transform)||uo(r.translate)||uo(r.scale)||uo(r.rotate)||uo(r.perspective)||!Bm()&&(uo(r.backdropFilter)||uo(r.filter))||k2.test(r.willChange||"")||_2.test(r.contain||"")}function M2(n){let r=ar(n);for(;Bt(r)&&!er(r);){if(Im(r))return r;if(Gc(r))return null;r=ar(r)}return null}function Bm(){return _f==null&&(_f=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),_f}function er(n){return/^(html|body|#document)$/.test(bn(n))}function Fn(n){return Xt(n).getComputedStyle(n)}function Xc(n){return xt(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function ar(n){if(bn(n)==="html")return n;const r=n.assignedSlot||n.parentNode||Ta(n)&&n.host||cr(n);return Ta(r)?r.host:r}function t0(n){const r=ar(n);return er(r)?(n.ownerDocument||n).body:Bt(r)&&jo(r)?r:t0(r)}function Il(n,r,o){var l;r===void 0&&(r=[]),o===void 0&&(o=!0);const c=t0(n),d=c===((l=n.ownerDocument)==null?void 0:l.body),m=Xt(c);if(d){const g=rm(m);return r.concat(m,m.visualViewport||[],jo(c)?c:[],g&&o?Il(g):[])}else return r.concat(c,Il(c,[],o))}function rm(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}const Um={...ON},Qb={};function zn(n,r){const o=p.useRef(Qb);return o.current===Qb&&(o.current=n(r)),o}const Mf=Um.useInsertionEffect,A2=Mf&&Mf!==Um.useLayoutEffect?Mf:n=>n();function nt(n){const r=zn(D2).current;return r.next=n,A2(r.effect),r.trampoline}function D2(){const n={next:void 0,callback:z2,trampoline:(...r)=>n.callback?.(...r),effect:()=>{n.callback=n.next}};return n}function z2(){}const L2=()=>{},Ge=typeof document<"u"?p.useLayoutEffect:L2;function om(n,r){if(n&&!r)return n;if(!n&&r)return r;if(n||r)return{...n,...r}}const Hm={};function tr(n,r,o,l,c){if(!o&&!l&&!c&&!n)return _c(r);let d=_c(n);return r&&(d=kl(d,r)),o&&(d=kl(d,o)),l&&(d=kl(d,l)),c&&(d=kl(d,c)),d}function I2(n){if(n.length===0)return Hm;if(n.length===1)return _c(n[0]);let r=_c(n[0]);for(let o=1;o<n.length;o+=1)r=kl(r,n[o]);return r}function _c(n){return Ym(n)?{...s0(n,Hm)}:B2(n)}function kl(n,r){return Ym(r)?s0(r,n):U2(n,r)}function B2(n){const r={...n};for(const o in r){const l=r[o];n0(o,l)&&(r[o]=r0(l))}return r}function U2(n,r){if(!r)return n;for(const o in r){const l=r[o];switch(o){case"style":{n[o]=om(n.style,l);break}case"className":{n[o]=o0(n.className,l);break}default:n0(o,l)?n[o]=H2(n[o],l):n[o]=l}}return n}function n0(n,r){const o=n.charCodeAt(0),l=n.charCodeAt(1),c=n.charCodeAt(2);return o===111&&l===110&&c>=65&&c<=90&&(typeof r=="function"||typeof r>"u")}function Ym(n){return typeof n=="function"}function s0(n,r){return Ym(n)?n(r):n??Hm}function H2(n,r){return r?n?(...o)=>{const l=o[0];if(a0(l)){const d=l;Mc(d);const m=r(...o);return d.baseUIHandlerPrevented||n?.(...o),m}const c=r(...o);return n?.(...o),c}:r0(r):n}function r0(n){return n&&((...r)=>{const o=r[0];return a0(o)&&Mc(o),n(...r)})}function Mc(n){return n.preventBaseUIHandler=()=>{n.baseUIHandlerPrevented=!0},n}function o0(n,r){return r?n?r+" "+n:r:n}function a0(n){return n!=null&&typeof n=="object"&&"nativeEvent"in n}function Y2(n,r){return function(l,...c){const d=new URL(n);return d.searchParams.set("code",l.toString()),c.forEach(m=>d.searchParams.append("args[]",m)),`${r} error #${l}; visit ${d} for the full message.`}}const En=Y2("https://base-ui.com/production-error","Base UI"),P2=p.createContext(void 0);function Pm(n=!1){const r=p.useContext(P2);if(r===void 0&&!n)throw new Error(En(16));return r}function V2(n){const{focusableWhenDisabled:r,disabled:o,composite:l=!1,tabIndex:c=0,isNativeButton:d}=n,m=l&&r!==!1,g=l&&r===!1;return{props:p.useMemo(()=>{const h={onKeyDown(v){o&&r&&v.key!=="Tab"&&v.preventDefault()}};return l||(h.tabIndex=c,!d&&o&&(h.tabIndex=r?c:-1)),(d&&(r||m)||!d&&o)&&(h["aria-disabled"]=o),d&&(!r||g)&&(h.disabled=o),h},[l,o,r,m,g,d,c])}}function ql(n={}){const{disabled:r=!1,focusableWhenDisabled:o,tabIndex:l=0,native:c=!0,composite:d}=n,m=p.useRef(null),g=Pm(!0),b=d??g!==void 0,{props:h}=V2({focusableWhenDisabled:o,disabled:r,composite:b,tabIndex:l,isNativeButton:c}),v=p.useCallback(()=>{const j=m.current;Af(j)&&b&&r&&h.disabled===void 0&&j.disabled&&(j.disabled=!1)},[r,h.disabled,b]);Ge(v,[v]);const x=p.useCallback((j={})=>{const{onClick:N,onMouseDown:k,onKeyUp:O,onKeyDown:E,onPointerDown:T,..._}=j;return tr({onClick(w){if(r){w.preventDefault();return}N?.(w)},onMouseDown(w){r||k?.(w)},onKeyDown(w){if(r||(Mc(w),E?.(w),w.baseUIHandlerPrevented))return;const I=w.target===w.currentTarget,A=w.currentTarget,U=Af(A),M=!c&&q2(A),K=I&&(c?U:!M),oe=w.key==="Enter",Z=w.key===" ",ee=A.getAttribute("role"),G=ee?.startsWith("menuitem")||ee==="option"||ee==="gridcell";if(I&&b&&Z){if(w.defaultPrevented&&G)return;w.preventDefault(),M||c&&U?(A.click(),w.preventBaseUIHandler()):K&&(N?.(w),w.preventBaseUIHandler());return}K&&(!c&&(Z||oe)&&w.preventDefault(),!c&&oe&&N?.(w))},onKeyUp(w){if(!r){if(Mc(w),O?.(w),w.target===w.currentTarget&&c&&b&&Af(w.currentTarget)&&w.key===" "){w.preventDefault();return}w.baseUIHandlerPrevented||w.target===w.currentTarget&&!c&&!b&&w.key===" "&&N?.(w)}},onPointerDown(w){if(r){w.preventDefault();return}T?.(w)}},c?{type:"button"}:{role:"button"},h,_)},[r,h,b,c]),S=nt(j=>{m.current=j,v()});return{getButtonProps:x,buttonRef:S}}function Af(n){return Bt(n)&&n.tagName==="BUTTON"}function q2(n){return!!(n?.tagName==="A"&&n?.href)}function wa(n,r,o,l){const c=zn(l0).current;return G2(c,n,r,o,l)&&i0(c,[n,r,o,l]),c.callback}function F2(n){const r=zn(l0).current;return X2(r,n)&&i0(r,n),r.callback}function l0(){return{callback:null,cleanup:null,refs:[]}}function G2(n,r,o,l,c){return n.refs[0]!==r||n.refs[1]!==o||n.refs[2]!==l||n.refs[3]!==c}function X2(n,r){return n.refs.length!==r.length||n.refs.some((o,l)=>o!==r[l])}function i0(n,r){if(n.refs=r,r.every(o=>o==null)){n.callback=null;return}n.callback=o=>{if(n.cleanup&&(n.cleanup(),n.cleanup=null),o!=null){const l=Array(r.length).fill(null);for(let c=0;c<r.length;c+=1){const d=r[c];if(d!=null)switch(typeof d){case"function":{const m=d(o);typeof m=="function"&&(l[c]=m);break}case"object":{d.current=o;break}}}n.cleanup=()=>{for(let c=0;c<r.length;c+=1){const d=r[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 $2=parseInt(p.version,10);function Vm(n){return $2>=n}function Zb(n){if(!p.isValidElement(n))return null;const r=n,o=r.props;return(Vm(19)?o?.ref:r.ref)??null}function un(){}const Ac=Object.freeze([]),Ut=Object.freeze({});function K2(n,r){const o={};for(const l in n){const c=n[l];if(r?.hasOwnProperty(l)){const d=r[l](c);d!=null&&Object.assign(o,d);continue}c===!0?o[`data-${l.toLowerCase()}`]="":c&&(o[`data-${l.toLowerCase()}`]=c.toString())}return o}function Q2(n,r){return typeof n=="function"?n(r):n}function Z2(n,r){return typeof n=="function"?n(r):n}function fn(n,r,o={}){const l=r.render,c=J2(r,o);if(o.enabled===!1)return null;const d=o.state??Ut;return tw(n,l,c,d)}function J2(n,r={}){const{className:o,style:l,render:c}=n,{state:d=Ut,ref:m,props:g,stateAttributesMapping:b,enabled:h=!0}=r,v=h?Q2(o,d):void 0,x=h?Z2(l,d):void 0,S=h?K2(d,b):Ut,j=h&&g?W2(g):void 0,N=h?om(S,j)??{}:Ut;return typeof document<"u"&&(h?Array.isArray(m)?N.ref=F2([N.ref,Zb(c),...m]):N.ref=wa(N.ref,Zb(c),m):wa(null,null)),h?(v!==void 0&&(N.className=o0(N.className,v)),x!==void 0&&(N.style=om(N.style,x)),N):Ut}function W2(n){return Array.isArray(n)?I2(n):tr(void 0,n)}const ew=Symbol.for("react.lazy");function tw(n,r,o,l){if(r){if(typeof r=="function")return r(o,l);const c=tr(o,r.props);c.ref=o.ref;let d=r;return d?.$$typeof===ew&&(d=p.Children.toArray(r)[0]),p.cloneElement(d,c)}if(n&&typeof n=="string")return nw(n,o);throw new Error(En(8))}function nw(n,r){return n==="button"?p.createElement("button",{type:"button",...r,key:r.key}):n==="img"?p.createElement("img",{alt:"",...r,key:r.key}):p.createElement(n,r)}const sw=p.forwardRef(function(r,o){const{render:l,className:c,disabled:d=!1,focusableWhenDisabled:m=!1,nativeButton:g=!0,style:b,...h}=r,{getButtonProps:v,buttonRef:x}=ql({disabled:d,focusableWhenDisabled:m,native:g});return fn("button",r,{state:{disabled:d},ref:[o,x],props:[h,v]})}),Jb=n=>typeof n=="boolean"?`${n}`:n===0?"0":n,Wb=Hv,rw=(n,r)=>o=>{var l;if(r?.variants==null)return Wb(n,o?.class,o?.className);const{variants:c,defaultVariants:d}=r,m=Object.keys(c).map(h=>{const v=o?.[h],x=d?.[h];if(v===null)return null;const S=Jb(v)||Jb(x);return c[h][S]}),g=o&&Object.entries(o).reduce((h,v)=>{let[x,S]=v;return S===void 0||(h[x]=S),h},{}),b=r==null||(l=r.compoundVariants)===null||l===void 0?void 0:l.reduce((h,v)=>{let{class:x,className:S,...j}=v;return Object.entries(j).every(N=>{let[k,O]=N;return Array.isArray(O)?O.includes({...d,...g}[k]):{...d,...g}[k]===O})?[...h,x,S]:h},[]);return Wb(n,m,b,o?.class,o?.className)},am=rw("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 Se({className:n,variant:r="default",size:o="default",...l}){return i.jsx(sw,{"data-slot":"button",className:et(am({variant:r,size:o,className:n})),...l})}const c0=p.createContext(void 0);function u0(n){const r=p.useContext(c0);if(r===void 0&&!n)throw new Error(En(33));return r}const d0=p.createContext(void 0);function To(n){const r=p.useContext(d0);if(r===void 0&&!n)throw new Error(En(36));return r}let Bl=(function(n){return n.startingStyle="data-starting-style",n.endingStyle="data-ending-style",n})({});const ow={[Bl.startingStyle]:""},aw={[Bl.endingStyle]:""},$c={transitionStatus(n){return n==="starting"?ow:n==="ending"?aw:null}};let po=(function(n){return n.open="data-open",n.closed="data-closed",n[n.startingStyle=Bl.startingStyle]="startingStyle",n[n.endingStyle=Bl.endingStyle]="endingStyle",n.anchorHidden="data-anchor-hidden",n.side="data-side",n.align="data-align",n})({}),lm=(function(n){return n.popupOpen="data-popup-open",n.pressed="data-pressed",n})({});const lw={[lm.popupOpen]:""},iw={[lm.popupOpen]:"",[lm.pressed]:""},cw={[po.open]:""},uw={[po.closed]:""},dw={[po.anchorHidden]:""},fw={open(n){return n?lw:null}},im={open(n){return n?iw:null}},Fl={open(n){return n?cw:uw},anchorHidden(n){return n?dw:null}},mw=p.createContext(void 0);function Kc(n=!0){const r=p.useContext(mw);if(r===void 0&&!n)throw new Error(En(25));return r}const f0="none",yo="trigger-press",dn="trigger-hover",Al="trigger-focus",qm="outside-press",m0="item-press",p0="close-press",vo="focus-out",Qc="escape-key",cm="list-navigation",pw="cancel-open",_l="sibling-open",Fm="imperative-action";function hw({controlled:n,default:r,name:o,state:l="value"}){const{current:c}=p.useRef(n!==void 0),[d,m]=p.useState(r),g=c?n:d,b=p.useCallback(h=>{c||m(h)},[]);return[g,b]}function gw(){return typeof navigator>"u"?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:xw,platform:bw,maxTouchPoints:yw}=gw(),Zc=xw.toLowerCase(),Ul=bw.toLowerCase(),Jc=/^i(os$|p)/.test(Ul)||Ul==="macintel"&&yw>1,ey="android",um=Ul===ey||Zc.includes(ey),Gm=!Jc&&Ul.startsWith("mac");Ul.startsWith("win");const vw=Gm||Jc,wo=typeof CSS<"u"&&!!CSS.supports?.("-webkit-backdrop-filter:none");!wo&&Zc.includes("firefox");!wo&&Zc.includes("chrom");const Sw=vw,Xm=/jsdom|happydom/.test(Zc);function Ew(n){const{closeOnClick:r,highlighted:o,id:l,nodeId:c,store:d,typingRef:m,itemRef:g,itemMetadata:b}=n,{events:h}=d.useState("floatingTreeRoot"),v=d.useState("open"),x=Kc(!0),S=x!==void 0;return p.useMemo(()=>({id:l,role:"menuitem",tabIndex:v&&o?0:-1,onKeyDown(j){j.key===" "&&m?.current&&j.preventDefault()},onMouseMove(j){c&&h.emit("itemhover",{nodeId:c,target:j.currentTarget})},onClick(j){r&&h.emit("close",{domEvent:j,reason:m0})},onMouseUp(j){if(x){const N=x.initialCursorPointRef.current;if(x.initialCursorPointRef.current=null,S&&N&&Math.abs(j.clientX-N.x)<=1&&Math.abs(j.clientY-N.y)<=1||S&&!Gm&&j.button===2)return}g.current&&d.context.allowMouseUpTriggerRef.current&&(!S||j.button===2)&&(!b||b.type==="regular-item")&&g.current.click()}}),[r,o,l,h,c,v,d,m,g,x,S,b])}const Nw={type:"regular-item"};function jw(n){const{closeOnClick:r,disabled:o=!1,highlighted:l,id:c,store:d,typingRef:m=d.context.typingRef,nativeButton:g,itemMetadata:b,nodeId:h}=n,v=d.useState("disabled"),x=o||v,S=p.useRef(null),{getButtonProps:j,buttonRef:N}=ql({disabled:x,focusableWhenDisabled:!0,native:g,composite:!0}),k=Ew({closeOnClick:r,highlighted:l,id:c,nodeId:h,store:d,typingRef:m,itemRef:S,itemMetadata:b}),O=p.useCallback(T=>tr(k,{onMouseEnter(){b.type==="submenu-trigger"&&b.setActive()}},T,j),[k,j,b]),E=wa(S,N);return p.useMemo(()=>({getItemProps:O,itemRef:E}),[O,E])}const h0=p.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function Tw(){return p.useContext(h0)}let ww=(function(n){return n[n.None=0]="None",n[n.GuessFromOrder=1]="GuessFromOrder",n})({});function g0(n={}){const{label:r,metadata:o,textRef:l,indexGuessBehavior:c,index:d}=n,{register:m,unregister:g,subscribeMapChange:b,elementsRef:h,labelsRef:v,nextIndexRef:x}=Tw(),S=p.useRef(-1),[j,N]=p.useState(d??(c===ww.GuessFromOrder?()=>{if(S.current===-1){const E=x.current;x.current+=1,S.current=E}return S.current}:-1)),k=p.useRef(null),O=p.useCallback(E=>{if(k.current=E,j!==-1&&E!==null&&(h.current[j]=E,v)){const T=r!==void 0;v.current[j]=T?r:l?.current?.textContent??E.textContent}},[j,h,v,r,l]);return Ge(()=>{if(d!=null)return;const E=k.current;if(E)return m(E,o),()=>{g(E)}},[d,m,g,o]),Ge(()=>{if(d==null)return b(E=>{const T=k.current?E.get(k.current)?.index:null;T!=null&&N(T)})},[d,b,N]),{ref:O,index:j}}let ty=0;function Cw(n,r="mui"){const[o,l]=p.useState(n),c=n||o;return p.useEffect(()=>{o==null&&(ty+=1,l(`${r}-${ty}`))},[o,r]),c}const ny=Um.useId;function So(n,r){if(ny!==void 0){const o=ny();return n??(r?`${r}-${o}`:o)}return Cw(n,r)}function Co(n){return So(n,"base-ui")}function jt(n,r,o,l){let c=!1,d=!1;const m=Ut;return{reason:n,event:r??new Event("base-ui"),cancel(){c=!0},allowPropagation(){d=!0},get isCanceled(){return c},get isPropagationAllowed(){return d},trigger:o,...m}}const Rw=[];function $m(n){p.useEffect(n,Rw)}const uc=null;class Ow{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=r=>{this.isScheduled=!1;const o=this.callbacks,l=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,l>0)for(let c=0;c<o.length;c+=1)o[c]?.(r)};request(r){const o=this.nextId;return this.nextId+=1,this.callbacks.push(r),this.callbacksCount+=1,!this.isScheduled&&(requestAnimationFrame(this.tick),this.isScheduled=!0),o}cancel(r){const o=r-this.startId;o<0||o>=this.callbacks.length||(this.callbacks[o]=null,this.callbacksCount-=1)}}const dc=new Ow;class Ns{static create(){return new Ns}static request(r){return dc.request(r)}static cancel(r){return dc.cancel(r)}currentId=uc;request(r){this.cancel(),this.currentId=dc.request(()=>{this.currentId=uc,r()})}cancel=()=>{this.currentId!==uc&&(dc.cancel(this.currentId),this.currentId=uc)};disposeEffect=()=>this.cancel}function Hl(){const n=zn(Ns.create).current;return $m(n.disposeEffect),n}function kw(n,r=!1,o=!1){const[l,c]=p.useState(n&&r?"idle":void 0),[d,m]=p.useState(n);return n&&!d&&(m(!0),c("starting")),!n&&d&&l!=="ending"&&!o&&c("ending"),!n&&!d&&l==="ending"&&c(void 0),Ge(()=>{if(!n&&d&&l!=="ending"&&o){const g=Ns.request(()=>{c("ending")});return()=>{Ns.cancel(g)}}},[n,d,l,o]),Ge(()=>{if(!n||r)return;const g=Ns.request(()=>{c(void 0)});return()=>{Ns.cancel(g)}},[r,n]),Ge(()=>{if(!n||!r)return;n&&d&&l!=="idle"&&c("starting");const g=Ns.request(()=>{c("idle")});return()=>{Ns.cancel(g)}},[r,n,d,l]),{mounted:d,setMounted:m,transitionStatus:l}}var lr=Tv();const _w=jv(lr);function $s(n){return n==null?n:"current"in n?n.current:n}function Km(n,r=!1,o=!0){const l=Hl();return nt((c,d=null)=>{l.cancel();const m=$s(n);if(m==null)return;const g=m,b=()=>{lr.flushSync(c)};if(typeof g.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){c();return}function h(){Promise.all(g.getAnimations().map(v=>v.finished)).then(()=>{d?.aborted||b()}).catch(()=>{if(o){d?.aborted||b();return}const v=g.getAnimations();!d?.aborted&&v.length>0&&v.some(x=>x.pending||x.playState!=="finished")&&h()})}if(r){const v=Bl.startingStyle;if(!g.hasAttribute(v)){l.request(h);return}const x=new MutationObserver(()=>{g.hasAttribute(v)||(x.disconnect(),h())});x.observe(g,{attributes:!0,attributeFilter:[v]}),d?.addEventListener("abort",()=>x.disconnect(),{once:!0});return}l.request(h)})}function Wc(n){const{enabled:r=!0,open:o,ref:l,onComplete:c}=n,d=nt(c),m=Km(l,o,!1);p.useEffect(()=>{if(!r)return;const g=new AbortController;return m(d,g.signal),()=>{g.abort()}},[r,o,d,m])}const x0=p.createContext(void 0);function Mw(){const n=p.useContext(x0);if(n===void 0)throw new Error(En(31));return n}const Aw=p.forwardRef(function(r,o){const{render:l,className:c,style:d,...m}=r,[g,b]=p.useState(void 0),h=fn("div",r,{ref:o,props:{role:"group","aria-labelledby":g,...m}});return i.jsx(x0.Provider,{value:b,children:h})}),Dw=p.forwardRef(function(r,o){const{render:l,className:c,style:d,id:m,...g}=r,b=Co(m),h=Mw();return Ge(()=>(h(b),()=>{h(void 0)}),[h,b]),fn("div",r,{ref:o,props:{id:b,role:"presentation",...g}})}),zw=p.forwardRef(function(r,o){const{render:l,className:c,id:d,label:m,nativeButton:g=!1,disabled:b=!1,closeOnClick:h=!0,style:v,...x}=r,S=g0({label:m}),j=u0(!0),N=Co(d),{store:k}=To(),O=k.useState("isActive",S.index),E=k.useState("itemProps"),{getItemProps:T,itemRef:_}=jw({closeOnClick:h,disabled:b,highlighted:O,id:N,store:k,nativeButton:g,nodeId:j?.context.nodeId,itemMetadata:Nw});return fn("div",r,{state:{disabled:b,highlighted:O},props:[E,x,T],ref:[_,o,S.ref]})}),El=0;class fs{static create(){return new fs}currentId=El;start(r,o){this.clear(),this.currentId=setTimeout(()=>{this.currentId=El,o()},r)}isStarted(){return this.currentId!==El}clear=()=>{this.currentId!==El&&(clearTimeout(this.currentId),this.currentId=El)};disposeEffect=()=>this.clear}function Gn(){const n=zn(fs.create).current;return $m(n.disposeEffect),n}function Es(n){n.preventDefault(),n.stopPropagation()}function Lw(n){return"nativeEvent"in n}function b0(n){return n.pointerType===""&&n.isTrusted?!0:um&&n.pointerType?n.type==="click"&&n.buttons===1:n.detail===0&&!n.pointerType}function y0(n){return Xm?!1:!um&&n.width===0&&n.height===0||um&&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 Yl(n,r){const o=["mouse","pen"];return r||o.push("",void 0),o.includes(n)}function Iw(n){const r=n.type;return r==="click"||r==="mousedown"||r==="keydown"||r==="keyup"}const dm="data-base-ui-focusable",v0="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",eu="ArrowLeft",tu="ArrowRight",S0="ArrowUp",Qm="ArrowDown";function jn(n){let r=n.activeElement;for(;r?.shadowRoot?.activeElement!=null;)r=r.shadowRoot.activeElement;return r}function We(n,r){if(!n||!r)return!1;const o=r.getRootNode?.();if(n.contains(r))return!0;if(o&&Ta(o)){let l=r;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 Dc(n,r){if(!xt(n))return!1;const o=n;if(r.hasElement(o))return!o.hasAttribute("data-trigger-disabled");for(const[,l]of r.entries())if(We(l,o))return!l.hasAttribute("data-trigger-disabled");return!1}function Df(n,r){if(r==null)return!1;if("composedPath"in n)return n.composedPath().includes(r);const o=n;return o.target!=null&&r.contains(o.target)}function Bw(n){return n.matches("html,body")}function nu(n){return Bt(n)&&n.matches(v0)}function Uw(n){return n?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${v0}`)!=null}function fm(n){return n?n.getAttribute("role")==="combobox"&&nu(n):!1}function Hw(n){if(!n||Xm)return!0;try{return n.matches(":focus-visible")}catch{return!0}}function mm(n){return n?n.hasAttribute(dm)?n:n.querySelector(`[${dm}]`)||n:null}function Yw(n,r){return r!=null&&!Yl(r)?0:typeof n=="function"?n():n}function pm(n,r,o){const l=Yw(n,o);return typeof l=="number"?l:l?.[r]}function sy(n){return typeof n=="function"?n():n}function E0(n,r){return r||n==="click"||n==="mousedown"}function Pw(n){return n?.includes("mouse")&&n!=="mousedown"}function pt(n,r,o,l){return n.addEventListener(r,o,l),()=>{n.removeEventListener(r,o,l)}}function ws(...n){return()=>{for(let r=0;r<n.length;r+=1){const o=n[r];o&&o()}}}function on(n){const r=zn(Vw,n).current;return r.next=n,Ge(r.effect),r}function Vw(n){const r={current:n,next:n,effect:()=>{r.current=r.next}};return r}function vt(n){return n?.ownerDocument||document}const qw={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},Fw={...qw,position:"fixed",top:0,left:0},Hr=p.forwardRef(function(r,o){const[l,c]=p.useState();Ge(()=>{Sw&&wo&&c("button")},[]);const d={tabIndex:0,role:l};return i.jsx("span",{...r,ref:o,style:Fw,"aria-hidden":l?void 0:!0,...d,"data-base-ui-focus-guard":""})}),Gw=["top","right","bottom","left"],Ca=Math.min,nr=Math.max,zc=Math.round,fc=Math.floor,sr=n=>({x:n,y:n}),Xw={left:"right",right:"left",bottom:"top",top:"bottom"};function N0(n,r,o){return nr(n,Ca(r,o))}function ir(n,r){return typeof n=="function"?n(r):n}function qn(n){return n.split("-")[0]}function Vr(n){return n.split("-")[1]}function Zm(n){return n==="x"?"y":"x"}function Jm(n){return n==="y"?"height":"width"}function as(n){const r=n[0];return r==="t"||r==="b"?"y":"x"}function Wm(n){return Zm(as(n))}function $w(n,r,o){o===void 0&&(o=!1);const l=Vr(n),c=Wm(n),d=Jm(c);let m=c==="x"?l===(o?"end":"start")?"right":"left":l==="start"?"bottom":"top";return r.reference[d]>r.floating[d]&&(m=Lc(m)),[m,Lc(m)]}function Kw(n){const r=Lc(n);return[hm(n),r,hm(r)]}function hm(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}const ry=["left","right"],oy=["right","left"],Qw=["top","bottom"],Zw=["bottom","top"];function Jw(n,r,o){switch(n){case"top":case"bottom":return o?r?oy:ry:r?ry:oy;case"left":case"right":return r?Qw:Zw;default:return[]}}function Ww(n,r,o,l){const c=Vr(n);let d=Jw(qn(n),o==="start",l);return c&&(d=d.map(m=>m+"-"+c),r&&(d=d.concat(d.map(hm)))),d}function Lc(n){const r=qn(n);return Xw[r]+n.slice(r.length)}function eC(n){var r,o,l,c;return{top:(r=n.top)!=null?r:0,right:(o=n.right)!=null?o:0,bottom:(l=n.bottom)!=null?l:0,left:(c=n.left)!=null?c:0}}function j0(n){return typeof n!="number"?eC(n):{top:n,right:n,bottom:n,left:n}}function Ic(n){const{x:r,y:o,width:l,height:c}=n;return{width:l,height:c,top:o,left:r,right:r+l,bottom:o+c,x:r,y:o}}function ay(n,r){return r<0||r>=n.length}function zf(n,r){return va(n.current,{disabledIndices:r})}function ly(n,r){return va(n.current,{decrement:!0,startingIndex:n.current.length,disabledIndices:r})}function va(n,{startingIndex:r=-1,decrement:o=!1,disabledIndices:l,amount:c=1}={}){let d=r;do d+=o?-c:c;while(d>=0&&d<=n.length-1&&T0(n,d,l));return d}function T0(n,r,o){if(typeof o=="function"?o(r):o?.includes(r)??!1)return!0;const c=n[r];return c?su(c)?!o&&(c.hasAttribute("disabled")||c.getAttribute("aria-disabled")==="true"):!0:!1}function tC(n){return n.visibility==="hidden"||n.visibility==="collapse"}function su(n,r=n?Fn(n):null){return!n||!n.isConnected||!r||tC(r)?!1:typeof n.checkVisibility=="function"?n.checkVisibility():r.display!=="none"&&r.display!=="contents"}const nC='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function sC(n){const r=n.assignedSlot;if(r)return r;if(n.parentElement)return n.parentElement;const o=n.getRootNode();return Ta(o)?o.host:null}function gm(n){for(const r of Array.from(n.children))if(bn(r)==="summary")return r;return null}function rC(n,r){const o=gm(r);return!!o&&(n===o||We(o,n))}function w0(n){const r=n?bn(n):"";return n!=null&&n.matches(nC)&&(r!=="summary"||n.parentElement!=null&&bn(n.parentElement)==="details"&&gm(n.parentElement)===n)&&(r!=="details"||gm(n)==null)&&(r!=="input"||n.type!=="hidden")}function C0(n){if(!w0(n)||!n.isConnected||n.matches(":disabled"))return!1;for(let r=n;r;r=sC(r)){const o=r!==n,l=bn(r)==="slot";if(r.hasAttribute("inert")||o&&bn(r)==="details"&&!r.open&&!rC(n,r)||r.hasAttribute("hidden")||!l&&!oC(r,o))return!1}return!0}function oC(n,r){const o=Fn(n);return r?o.display!=="none":su(n,o)}function R0(n){const r=n.tabIndex;if(r<0){const o=bn(n);if(o==="details"||o==="audio"||o==="video"||Bt(n)&&n.isContentEditable)return 0}return r}function Lf(n){if(bn(n)!=="input")return null;const r=n;return r.type==="radio"&&r.name!==""?r:null}function aC(n,r){const o=Lf(n);if(!o)return!0;const l=r.find(c=>{const d=Lf(c);return d?.name===o.name&&d.form===o.form&&d.checked});return l?l===o:r.find(c=>{const d=Lf(c);return d?.name===o.name&&d.form===o.form})===o}function O0(n){if(Bt(n)&&bn(n)==="slot"){const r=n.assignedElements({flatten:!0});if(r.length>0)return r}return Bt(n)&&n.shadowRoot?Array.from(n.shadowRoot.children):Array.from(n.children)}function k0(n,r){O0(n).forEach(o=>{w0(o)&&r.push(o),k0(o,r)})}function _0(n,r,o){O0(n).forEach(l=>{Bt(l)&&l.matches(r)&&o.push(l),_0(l,r,o)})}function ep(n){return C0(n)&&R0(n)>=0}function M0(n){const r=[];return k0(n,r),r.filter(C0)}function Gl(n){const r=M0(n);return r.filter(o=>R0(o)>=0&&aC(o,r))}function A0(n,r){const o=Gl(n),l=o.length;if(l===0)return;const c=jn(vt(n)),d=o.indexOf(c),m=d===-1?r===1?0:l-1:d+r;return o[m]}function tp(n){return A0(vt(n).body,1)||n}function D0(n){return A0(vt(n).body,-1)||n}function z0(n,r){if(!n)return null;const o=Gl(vt(n).body),l=o.length;if(l===0)return null;const c=o.indexOf(n);if(c===-1)return null;const d=(c+r+l)%l;return o[d]}function lC(n){return z0(n,1)}function iC(n){return z0(n,-1)}function Sa(n,r){const o=r||n.currentTarget,l=n.relatedTarget;return!l||!We(o,l)}function cC(n){Gl(n).forEach(o=>{o.dataset.tabindex=o.getAttribute("tabindex")||"",o.setAttribute("tabindex","-1")})}function iy(n){const r=[];_0(n,"[data-tabindex]",r),r.forEach(o=>{const l=o.dataset.tabindex;delete o.dataset.tabindex,l?o.setAttribute("tabindex",l):o.removeAttribute("tabindex")})}function Yr(n,r,o=!0){return n.filter(c=>c.parentId===r).flatMap(c=>[...!o||c.context?.open?[c]:[],...Yr(n,c.id,o)])}function cy(n,r){let o=[],l=n.find(c=>c.id===r)?.parentId;for(;l;){const c=n.find(d=>d.id===l);l=c?.parentId,c&&(o=o.concat(c))}return o}function Pl(n){return`data-base-ui-${n}`}let mc=0;function jc(n,r={}){const{preventScroll:o=!1,sync:l=!1,shouldFocus:c}=r;cancelAnimationFrame(mc);function d(){c&&!c()||n?.focus({preventScroll:o})}if(l)return d(),un;const m=requestAnimationFrame(d);return mc=m,()=>{mc===m&&(cancelAnimationFrame(m),mc=0)}}const If={inert:new WeakMap,"aria-hidden":new WeakMap},uy="data-base-ui-inert",xm={inert:new WeakSet,"aria-hidden":new WeakSet};let Nl=new WeakMap,Bf=0;function uC(n){return xm[n]}function L0(n){return n?Ta(n)?n.host:L0(n.parentNode):null}const dy=(n,r)=>r.map(o=>{if(n.contains(o))return o;const l=L0(o);return n.contains(l)?l:null}).filter(o=>o!=null),fy=n=>{const r=new Set;return n.forEach(o=>{let l=o;for(;l&&!r.has(l);)r.add(l),l=l.parentNode}),r},my=(n,r,o)=>{const l=[],c=d=>{!d||o.has(d)||Array.from(d.children).forEach(m=>{bn(m)!=="script"&&(r.has(m)?c(m):l.push(m))})};return c(n),l};function dC(n,r,o,l,{mark:c=!0}){let d=null;l?d="inert":o&&(d="aria-hidden");let m=null,g=null;const b=dy(r,n),h=c?my(r,fy(b),new Set(b)):[],v=[],x=[];if(d){const S=If[d],j=uC(d);g=j,m=S;const N=dy(r,Array.from(r.querySelectorAll("[aria-live]"))),k=b.concat(N);my(r,fy(k),new Set(k)).forEach(E=>{const T=E.getAttribute(d),_=T!==null&&T!=="false",w=(S.get(E)||0)+1;S.set(E,w),v.push(E),w===1&&_&&j.add(E),_||E.setAttribute(d,d==="inert"?"":"true")})}return c&&h.forEach(S=>{const j=(Nl.get(S)||0)+1;Nl.set(S,j),x.push(S),j===1&&S.setAttribute(uy,"")}),Bf+=1,()=>{m&&v.forEach(S=>{const N=(m.get(S)||0)-1;m.set(S,N),N||(!g?.has(S)&&d&&S.removeAttribute(d),g?.delete(S))}),c&&x.forEach(S=>{const j=(Nl.get(S)||0)-1;Nl.set(S,j),j||S.removeAttribute(uy)}),Bf-=1,Bf||(If.inert=new WeakMap,If["aria-hidden"]=new WeakMap,xm.inert=new WeakSet,xm["aria-hidden"]=new WeakSet,Nl=new WeakMap)}}function py(n,r={}){const{ariaHidden:o=!1,inert:l=!1,mark:c=!0}=r,d=vt(n[0]).body;return dC(n,d,o,l,{mark:c})}const fC=500,I0=500,mC={style:{transition:"none"}},B0="data-base-ui-click-trigger",pC={fallbackAxisSide:"none"},U0={fallbackAxisSide:"end"},hC={clipPath:"inset(50%)",position:"fixed",top:0,left:0},H0=p.createContext(null),Y0=()=>p.useContext(H0),gC=Pl("portal");function xC(n={}){const{ref:r,container:o,componentProps:l=Ut,elementProps:c}=n,d=So(),g=Y0()?.portalNode,[b,h]=p.useState(null),[v,x]=p.useState(null),S=nt(O=>{O!==null&&x(O)}),j=p.useRef(null);Ge(()=>{if(o===null){j.current&&(j.current=null,x(null),h(null));return}if(d==null)return;const O=(o&&(Lm(o)?o:o.current))??g??document.body;if(O==null){j.current&&(j.current=null,x(null),h(null));return}j.current!==O&&(j.current=O,x(null),h(O))},[o,g,d]);const N=fn("div",l,{ref:[r,S],props:[{id:d,[gC]:""},c]});return{portalNode:v,portalSubtree:b&&N?lr.createPortal(N,b):null}}const np=p.forwardRef(function(r,o){const{render:l,className:c,style:d,children:m,container:g,renderGuards:b,...h}=r,{portalNode:v,portalSubtree:x}=xC({container:g,ref:o,componentProps:r,elementProps:h}),S=p.useRef(null),j=p.useRef(null),N=p.useRef(null),k=p.useRef(null),[O,E]=p.useState(null),T=p.useRef(!1),_=O?.modal,w=O?.open,I=typeof b=="boolean"?b:!!O&&!O.modal&&O.open&&!!v;p.useEffect(()=>{if(!v||_)return;function U(M){v&&M.relatedTarget&&Sa(M)&&(M.type==="focusin"?T.current&&(iy(v),T.current=!1):(cC(v),T.current=!0))}return ws(pt(v,"focusin",U,!0),pt(v,"focusout",U,!0))},[v,_]),Ge(()=>{!v||w!==!0||!T.current||(iy(v),T.current=!1)},[w,v]);const A=p.useMemo(()=>({beforeOutsideRef:S,afterOutsideRef:j,beforeInsideRef:N,afterInsideRef:k,portalNode:v,setFocusManagerState:E}),[v]);return i.jsxs(p.Fragment,{children:[x,i.jsxs(H0.Provider,{value:A,children:[I&&v&&i.jsx(Hr,{"data-type":"outside",ref:S,onFocus:U=>{if(Sa(U,v))N.current?.focus();else{const M=O?O.domReference:null;D0(M)?.focus()}}}),I&&v&&i.jsx("span",{"aria-owns":v.id,style:hC}),v&&lr.createPortal(m,v),I&&v&&i.jsx(Hr,{"data-type":"outside",ref:j,onFocus:U=>{if(Sa(U,v))k.current?.focus();else{const M=O?O.domReference:null;tp(M)?.focus(),O?.closeOnFocusOut&&O?.onOpenChange(!1,jt(vo,U.nativeEvent))}}})]})]})});function P0(){const n=new Map;return{emit(r,o){n.get(r)?.forEach(l=>l(o))},on(r,o){n.has(r)||n.set(r,new Set),n.get(r).add(o)},off(r,o){n.get(r)?.delete(o)}}}class sp{nodesRef={current:[]};events=P0();addNode(r){this.nodesRef.current.push(r)}removeNode(r){const o=this.nodesRef.current.findIndex(l=>l===r);o!==-1&&this.nodesRef.current.splice(o,1)}}const V0=p.createContext(null),q0=p.createContext(null),ur=()=>p.useContext(V0)?.id||null,qr=n=>{const r=p.useContext(q0);return n??r};function rp(n){const r=So(),o=qr(n),l=ur();return Ge(()=>{if(!r)return;const c={id:r,parentId:l};return o?.addNode(c),()=>{o?.removeNode(c)}},[o,r,l]),r}function F0(n){const{children:r,id:o}=n,l=ur();return i.jsx(V0.Provider,{value:p.useMemo(()=>({id:o,parentId:l}),[o,l]),children:r})}function G0(n){const{children:r,externalTree:o}=n,l=zn(()=>o??new sp).current;return i.jsx(q0.Provider,{value:l,children:r})}function bC(n,r){const o=Xt(Dn(n));return n instanceof o.KeyboardEvent?"keyboard":n instanceof o.FocusEvent?r||"keyboard":"pointerType"in n?n.pointerType||"keyboard":"touches"in n?"touch":n instanceof o.MouseEvent?r||(n.detail===0?"keyboard":"mouse"):""}const hy=20;let Ir=[];function op(){Ir=Ir.filter(n=>n.deref()?.isConnected)}function gy(n){op(),n&&bn(n)!=="body"&&(Ir.push(new WeakRef(n)),Ir.length>hy&&(Ir=Ir.slice(-hy)))}function xy(){return op(),Ir[Ir.length-1]?.deref()}function yC(n){return n?ep(n)?n:Gl(n)[0]||n:null}function by(n){if(n.hasAttribute("tabindex")&&!n.hasAttribute("data-tabindex")||!n.getAttribute("role")?.includes("dialog"))return;const o=M0(n).filter(c=>{const d=c.getAttribute("data-tabindex")||"";return ep(c)||c.hasAttribute("data-tabindex")&&!d.startsWith("-")}),l=n.getAttribute("tabindex");o.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 ap(n){const{context:r,children:o,disabled:l=!1,initialFocus:c=!0,returnFocus:d=!0,restoreFocus:m=!1,modal:g=!0,closeOnFocusOut:b=!0,openInteractionType:h="",nextFocusableElement:v,previousFocusableElement:x,beforeContentFocusGuardRef:S,externalTree:j,getInsideElements:N}=n,k="rootStore"in r?r.rootStore:r,O=k.useState("open"),E=k.useState("domReferenceElement"),T=k.useState("floatingElement"),{events:_,dataRef:w}=k.context,I=nt(()=>w.current.floatingContext?.nodeId),A=c===!1,U=fm(E)&&A,M=on(c),K=on(d),oe=on(h),Z=on(O),ee=qr(j),G=Y0(),te=p.useRef(!1),X=p.useRef(!1),C=p.useRef(!1),B=p.useRef(null),H=p.useRef(""),z=p.useRef(""),L=p.useRef(null),D=p.useRef(null),q=wa(L,S,G?.beforeInsideRef),V=wa(D,G?.afterInsideRef),Q=Gn(),ne=Gn(),F=Hl(),Te=G!=null,me=mm(T),he=nt((Re=me)=>Re?Gl(Re):[]),Le=nt(()=>N?.().filter(Re=>Re!=null)??[]);p.useEffect(()=>{if(l||!g)return;function Re(De){De.key==="Tab"&&We(me,jn(vt(me)))&&he().length===0&&!U&&Es(De)}const ze=vt(me);return pt(ze,"keydown",Re)},[l,me,g,U,he]),p.useEffect(()=>{if(l||!O)return;const Re=vt(me);function ze(){C.current=!1}function De(Be){const ae=Dn(Be),de=Le(),ue=We(T,ae)||We(E,ae)||We(G?.portalNode,ae)||de.some(Ce=>Ce===ae||We(Ce,ae));C.current=!ue,z.current=Be.pointerType||"keyboard",ae?.closest(`[${B0}]`)&&(X.current=!0,ne.start(0,()=>{X.current=!1}))}function ye(){z.current="keyboard"}return ws(pt(Re,"pointerdown",De,!0),pt(Re,"pointerup",ze,!0),pt(Re,"pointercancel",ze,!0),pt(Re,"keydown",ye,!0),ze)},[l,T,E,me,O,G,ne,Le]),p.useEffect(()=>{if(l||!b)return;const Re=vt(me);function ze(){X.current=!0,ne.start(0,()=>{X.current=!1})}function De(de){const ue=Dn(de);ep(ue)&&(B.current=ue)}function ye(de){const ue=de.relatedTarget,Ce=de.currentTarget,fe=Dn(de);g&&ue==null&&fe!=null&&We(T,fe)&&gy(fe),queueMicrotask(()=>{const be=I(),qe=k.context.triggerElements,se=Le(),Y=ue?.hasAttribute(Pl("focus-guard"))&&[L.current,D.current,G?.beforeInsideRef.current,G?.afterInsideRef.current,G?.beforeOutsideRef.current,G?.afterOutsideRef.current,$s(x),$s(v)].includes(ue),ge=!(We(E,ue)||We(T,ue)||We(ue,T)||We(G?.portalNode,ue)||se.some(J=>J===ue||We(J,ue))||ue!=null&&qe.hasElement(ue)||qe.hasMatchingElement(J=>We(J,ue))||Y||ee&&(Yr(ee.nodesRef.current,be).find(J=>We(J.context?.elements.floating,ue)||We(J.context?.elements.domReference,ue))||cy(ee.nodesRef.current,be).find(J=>[J.context?.elements.floating,mm(J.context?.elements.floating)].includes(ue)||J.context?.elements.domReference===ue)));if(Ce===E&&me&&by(me),m&&Ce!==E&&!su(fe)&&jn(Re)===Re.body){if(Bt(me)&&(me.focus(),m==="popup")){F.request(()=>{me.focus()});return}const J=he(),we=B.current,Xe=(we&&J.includes(we)?we:null)||J[J.length-1]||me;Bt(Xe)&&Xe.focus()}if(w.current.insideReactTree){w.current.insideReactTree=!1;return}(U||!g)&&ue&&ge&&!X.current&&(U||ue!==xy())&&(te.current=!0,k.setOpen(!1,jt(vo,de)))})}function Be(){C.current||(w.current.insideReactTree=!0,Q.start(0,()=>{w.current.insideReactTree=!1}))}const ae=Bt(E)?E:null;if(!(!T&&!ae))return ws(ae&&pt(ae,"focusout",ye),ae&&pt(ae,"pointerdown",ze),T&&pt(T,"focusin",De),T&&pt(T,"focusout",ye),T&&G&&pt(T,"focusout",Be,!0))},[l,E,T,me,g,ee,G,k,b,m,he,U,I,w,Q,ne,F,v,x,Le]),p.useEffect(()=>{if(l||!T||!O)return;const Re=Array.from(G?.portalNode?.querySelectorAll(`[${Pl("portal")}]`)||[]),De=(ee?cy(ee.nodesRef.current,I()):[]).find(Ce=>fm(Ce.context?.elements.domReference||null))?.context?.elements.domReference,Be=[...[T,...Re,L.current,D.current,G?.beforeOutsideRef.current,G?.afterOutsideRef.current,...Le()],De,$s(x),$s(v),U?E:null].filter(Ce=>Ce!=null),ae=py(Be,{ariaHidden:g||U,mark:!1}),de=[T,...Re].filter(Ce=>Ce!=null),ue=py(de);return()=>{ue(),ae()}},[O,l,E,T,g,G,U,ee,I,v,x,Le]),Ge(()=>{if(!O||l||!Bt(me))return;const Re=vt(me),ze=jn(Re);queueMicrotask(()=>{const De=M.current,ye=typeof De=="function"?De(oe.current||""):De;if(ye===void 0||ye===!1||We(me,ze))return;let ae=null;const de=()=>(ae==null&&(ae=he(me)),ae[0]||me);let ue;ye===!0||ye===null?ue=de():ue=$s(ye),ue=ue||de();const Ce=We(me,jn(Re));jc(ue,{preventScroll:ue===me,shouldFocus(){if(!Z.current)return!1;if(Ce)return!0;const fe=jn(Re);return!(fe!==ue&&We(me,fe))}})})},[l,O,me,he,M,oe,Z]),Ge(()=>{if(l||!me)return;const Re=vt(me),ze=jn(Re),De=oe.current==null;gy(ze);function ye(ae){if(ae.open||(H.current=bC(ae.nativeEvent,z.current)),ae.reason===dn&&ae.nativeEvent.type==="mouseleave"&&(te.current=!0),ae.reason===qm)if(ae.nested)te.current=!1;else if(b0(ae.nativeEvent)||y0(ae.nativeEvent))te.current=!1;else{let de=!1;vt(me).createElement("div").focus({get preventScroll(){return de=!0,!1}}),de?te.current=!1:te.current=!0}}_.on("openchange",ye);function Be(){const ae=K.current;let de=typeof ae=="function"?ae(H.current):ae;if(de===void 0||de===!1)return null;de===null&&(de=!0);const ue=E?.isConnected?E:null,Ce=ze?.isConnected&&bn(ze)!=="body"?ze:null;let fe=De?Ce||ue:ue||Ce;return fe||(fe=xy()||null),typeof de=="boolean"?fe:$s(de)||fe||null}return()=>{_.off("openchange",ye);const ae=jn(Re),de=Le(),ue=We(T,ae)||de.some(be=>be===ae||We(be,ae))||ee&&Yr(ee.nodesRef.current,I(),!1).some(be=>We(be.context?.elements.floating,ae)),Ce=K.current,fe=Be();queueMicrotask(()=>{const be=yC(fe),qe=typeof Ce!="boolean";Ce&&!te.current&&Bt(be)&&(!(!qe&&be!==ae&&ae!==Re.body)||ue)&&be.focus({preventScroll:!0}),te.current=!1})}},[l,T,me,K,oe,_,ee,E,I,Le]),Ge(()=>{if(!wo||O||!T)return;const Re=jn(vt(T));!Bt(Re)||!nu(Re)||We(T,Re)&&Re.blur()},[O,T]),Ge(()=>{if(!(l||!G))return G.setFocusManagerState({modal:g,closeOnFocusOut:b,open:O,onOpenChange:k.setOpen,domReference:E}),()=>{G.setFocusManagerState(null)}},[l,G,g,O,k,b,E]),Ge(()=>{if(!(l||!me))return by(me),()=>{queueMicrotask(op)}},[l,me]);const Ve=!l&&(g?!U:!0)&&(Te||g);return i.jsxs(p.Fragment,{children:[Ve&&i.jsx(Hr,{"data-type":"inside",ref:q,onFocus:Re=>{if(g){const ze=he();jc(ze[ze.length-1])}else G?.portalNode&&(te.current=!1,Sa(Re,G.portalNode)?tp(E)?.focus():$s(x??G.beforeOutsideRef)?.focus())}}),o,Ve&&i.jsx(Hr,{"data-type":"inside",ref:V,onFocus:Re=>{g?jc(he()[0]):G?.portalNode&&(b&&(te.current=!0),Sa(Re,G.portalNode)?D0(E)?.focus():$s(v??G.afterOutsideRef)?.focus())}})]})}function X0(n,r={}){const{enabled:o=!0,event:l="click",toggle:c=!0,ignoreMouse:d=!1,stickIfOpen:m=!0,touchOpenDelay:g=0,reason:b=yo}=r,h="rootStore"in n?n.rootStore:n,v=h.context.dataRef,x=p.useRef(void 0),S=Hl(),j=Gn(),N=p.useMemo(()=>{function k(E,T,_,w){const I=jt(b,T,_);E&&w==="touch"&&g>0?j.start(g,()=>{h.setOpen(!0,I)}):h.setOpen(E,I)}function O(E,T,_){const w=v.current.openEvent,I=h.select("domReferenceElement")!==T;return E&&I||!E||!c?!0:w&&m?!_(w.type):!1}return{onPointerDown(E){x.current=E.pointerType},onMouseDown(E){const T=x.current,_=E.nativeEvent,w=h.select("open");if(E.button!==0||l==="click"||Yl(T,!0)&&d)return;const I=O(w,E.currentTarget,M=>M==="click"||M==="mousedown"),A=Dn(_);if(nu(A)){k(I,_,A,T);return}const U=E.currentTarget;S.request(()=>{k(I,_,U,T)})},onClick(E){if(l==="mousedown-only")return;const T=x.current;if(l==="mousedown"&&T){x.current=void 0;return}if(Yl(T,!0)&&d)return;const _=h.select("open"),w=O(_,E.currentTarget,I=>I==="click"||I==="mousedown"||I==="keydown"||I==="keyup");k(w,E.nativeEvent,E.currentTarget,T)},onKeyDown(){x.current=void 0}}},[v,l,d,b,h,m,c,S,j,g]);return p.useMemo(()=>o?{reference:N}:Ut,[o,N])}function vC(){return!1}function SC(n){return{escapeKey:typeof n=="boolean"?n:n?.escapeKey??!1,outsidePress:typeof n=="boolean"?n:n?.outsidePress??!0}}function lp(n,r={}){const{enabled:o=!0,escapeKey:l=!0,outsidePress:c=!0,outsidePressEvent:d="sloppy",referencePress:m=vC,bubbles:g,externalTree:b}=r,h="rootStore"in n?n.rootStore:n,v=h.useState("open"),x=h.useState("floatingElement"),{dataRef:S}=h.context,j=qr(b),N=nt(typeof c=="function"?c:()=>!1),k=typeof c=="function"?N:c,O=k!==!1,E=nt(()=>d),{escapeKey:T,outsidePress:_}=SC(g),w=p.useRef(!1),I=p.useRef(!1),A=p.useRef(!1),U=p.useRef(!1),M=p.useRef(""),K=p.useRef(null),oe=Gn(),Z=Gn(),ee=nt(()=>{Z.clear(),S.current.insideReactTree=!1}),G=nt(q=>{const V=S.current.floatingContext?.nodeId;return(j?Yr(j.nodesRef.current,V):[]).some(ne=>ne.context?.open&&!ne.context.dataRef.current[q])}),te=nt(q=>Df(q,h.select("floatingElement"))||Df(q,h.select("domReferenceElement"))),X=nt(q=>{m()&&h.setOpen(!1,jt(yo,q.nativeEvent))}),C=nt(q=>{if(!v||!o||!l||q.key!=="Escape"||U.current||!T&&G("__escapeKeyBubbles"))return;const V=Lw(q)?q.nativeEvent:q,Q=jt(Qc,V);h.setOpen(!1,Q),Q.isCanceled||q.preventDefault(),!T&&!Q.isPropagationAllowed&&q.stopPropagation()}),B=nt(()=>{S.current.insideReactTree=!0,Z.start(0,ee)}),H=nt(q=>{if(!v||!o||q.button!==0)return;const V=Dn(q.nativeEvent);We(h.select("floatingElement"),V)&&(w.current||(w.current=!0,I.current=!1))}),z=nt(q=>{!v||!o||(q.defaultPrevented||q.nativeEvent.defaultPrevented)&&w.current&&(I.current=!0)});p.useEffect(()=>{if(!v||!o)return;S.current.__escapeKeyBubbles=T,S.current.__outsidePressBubbles=_;const q=new fs,V=new fs;function Q(){q.clear(),U.current=!0}function ne(){q.start(wo?5:0,()=>{U.current=!1})}function F(){A.current=!0,V.start(0,()=>{A.current=!1})}function Te(){w.current=!1,I.current=!1}function me(){const se=M.current,Y=se==="pen"||!se?"mouse":se,ge=E(),J=typeof ge=="function"?ge():ge;return typeof J=="string"?J:J[Y]}function he(se){const Y=me();return Y==="intentional"&&se.type!=="click"||Y==="sloppy"&&se.type==="click"}function Le(se){const Y=S.current.floatingContext?.nodeId,ge=j&&Yr(j.nodesRef.current,Y).some(J=>Df(se,J.context?.elements.floating));return te(se)||ge}function Ve(se){if(he(se)){se.type!=="click"&&!te(se)&&(V.clear(),A.current=!1),ee();return}if(S.current.insideReactTree){ee();return}const Y=Dn(se),ge=`[${Pl("inert")}]`,J=xt(Y)?Y.getRootNode():null,we=Array.from((Ta(J)?J:vt(h.select("floatingElement"))).querySelectorAll(ge)),Xe=h.context.triggerElements;if(Y&&(Xe.hasElement(Y)||Xe.hasMatchingElement(Me=>We(Me,Y))))return;let je=xt(Y)?Y:null;for(;je&&!er(je);){const Me=ar(je);if(er(Me)||!xt(Me))break;je=Me}if(!(we.length&&xt(Y)&&!Bw(Y)&&!We(Y,h.select("floatingElement"))&&we.every(Me=>!We(je,Me)))){if(Bt(Y)&&!("touches"in se)){const Me=er(Y),$e=Fn(Y),rt=/auto|scroll/,Nt=Me||rt.test($e.overflowX),kt=Me||rt.test($e.overflowY),bt=Nt&&Y.clientWidth>0&&Y.scrollWidth>Y.clientWidth,yn=kt&&Y.clientHeight>0&&Y.scrollHeight>Y.clientHeight,an=$e.direction==="rtl",Ke=yn&&(an?se.offsetX<=Y.offsetWidth-Y.clientWidth:se.offsetX>Y.clientWidth),Tt=bt&&se.offsetY>Y.clientHeight;if(Ke||Tt)return}if(!Le(se)){if(me()==="intentional"&&A.current){V.clear(),A.current=!1;return}typeof k=="function"&&!k(se)||G("__outsidePressBubbles")||(h.setOpen(!1,jt(qm,se)),ee())}}}function Re(se){me()!=="sloppy"||se.pointerType==="touch"||!h.select("open")||!o||te(se)||Ve(se)}function ze(se){if(me()!=="sloppy"||!h.select("open")||!o||te(se))return;const Y=se.touches[0];Y&&(K.current={startTime:Date.now(),startX:Y.clientX,startY:Y.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},oe.start(1e3,()=>{K.current&&(K.current.dismissOnTouchEnd=!1,K.current.dismissOnMouseDown=!1)}))}function De(se,Y){const ge=Dn(se);if(!ge)return;const J=pt(ge,se.type,()=>{Y(se),J()})}function ye(se){M.current="touch",De(se,ze)}function Be(se){oe.clear(),se.type==="pointerdown"&&(M.current=se.pointerType),!(se.type==="mousedown"&&K.current&&!K.current.dismissOnMouseDown)&&De(se,Y=>{Y.type==="pointerdown"?Re(Y):Ve(Y)})}function ae(se){if(!w.current)return;const Y=I.current;if(Te(),me()==="intentional"){if(se.type==="pointercancel"){Y&&F();return}if(!Le(se)){if(Y){F();return}typeof k=="function"&&!k(se)||(V.clear(),A.current=!0,ee())}}}function de(se){if(me()!=="sloppy"||!K.current||te(se))return;const Y=se.touches[0];if(!Y)return;const ge=Math.abs(Y.clientX-K.current.startX),J=Math.abs(Y.clientY-K.current.startY),we=Math.sqrt(ge*ge+J*J);we>5&&(K.current.dismissOnTouchEnd=!0),we>10&&(Ve(se),oe.clear(),K.current=null)}function ue(se){De(se,de)}function Ce(se){me()!=="sloppy"||!K.current||te(se)||(K.current.dismissOnTouchEnd&&Ve(se),oe.clear(),K.current=null)}function fe(se){De(se,Ce)}const be=vt(x),qe=ws(l&&ws(pt(be,"keydown",C),pt(be,"compositionstart",Q),pt(be,"compositionend",ne)),O&&ws(pt(be,"click",Be,!0),pt(be,"pointerdown",Be,!0),pt(be,"pointerup",ae,!0),pt(be,"pointercancel",ae,!0),pt(be,"mousedown",Be,!0),pt(be,"mouseup",ae,!0),pt(be,"touchstart",ye,!0),pt(be,"touchmove",ue,!0),pt(be,"touchend",fe,!0)));return()=>{qe(),q.clear(),V.clear(),Te(),A.current=!1}},[S,x,l,O,k,v,o,T,_,C,ee,E,G,te,j,h,oe]),p.useEffect(ee,[k,ee]);const L=p.useMemo(()=>({onKeyDown:C,onPointerDown:X,onClick:X}),[C,X]),D=p.useMemo(()=>({onKeyDown:C,onPointerDown:z,onMouseDown:z,onClickCapture:B,onMouseDownCapture(q){B(),H(q)},onPointerDownCapture(q){B(),H(q)},onMouseUpCapture:B,onTouchEndCapture:B,onTouchMoveCapture:B}),[C,B,H,z]);return p.useMemo(()=>o?{reference:L,floating:D,trigger:L}:{},[o,L,D])}function yy(n,r,o){let{reference:l,floating:c}=n;const d=as(r),m=Wm(r),g=Jm(m),b=qn(r),h=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 N=Vr(r);return N&&(j[m]+=S*(N==="end"?1:-1)*(o&&h?-1:1)),j}async function EC(n,r){var o;r===void 0&&(r={});const{x:l,y:c,platform:d,rects:m,elements:g,strategy:b}=n,{boundary:h="clippingAncestors",rootBoundary:v="viewport",elementContext:x="floating",altBoundary:S=!1,padding:j=0}=ir(r,n),N=j0(j),O=g[S?x==="floating"?"reference":"floating":x],E=Ic(await d.getClippingRect({element:(o=await(d.isElement==null?void 0:d.isElement(O)))==null||o?O:O.contextElement||await(d.getDocumentElement==null?void 0:d.getDocumentElement(g.floating)),boundary:h,rootBoundary:v,strategy:b})),T=x==="floating"?{x:l,y:c,width:m.floating.width,height:m.floating.height}:m.reference,_=await(d.getOffsetParent==null?void 0:d.getOffsetParent(g.floating)),w=await(d.isElement==null?void 0:d.isElement(_))&&await(d.getScale==null?void 0:d.getScale(_))||{x:1,y:1},I=Ic(d.convertOffsetParentRelativeRectToViewportRelativeRect?await d.convertOffsetParentRelativeRectToViewportRelativeRect({elements:g,rect:T,offsetParent:_,strategy:b}):T);return{top:(E.top-I.top+N.top)/w.y,bottom:(I.bottom-E.bottom+N.bottom)/w.y,left:(E.left-I.left+N.left)/w.x,right:(I.right-E.right+N.right)/w.x}}const NC=50,jC=async(n,r,o)=>{const{placement:l="bottom",strategy:c="absolute",middleware:d=[],platform:m}=o,g=m.detectOverflow?m:{...m,detectOverflow:EC},b=await(m.isRTL==null?void 0:m.isRTL(r));let h=await m.getElementRects({reference:n,floating:r,strategy:c}),{x:v,y:x}=yy(h,l,b),S=l,j=0;const N={};for(let k=0;k<d.length;k++){const O=d[k];if(!O)continue;const{name:E,fn:T}=O,{x:_,y:w,data:I,reset:A}=await T({x:v,y:x,initialPlacement:l,placement:S,strategy:c,middlewareData:N,rects:h,platform:g,elements:{reference:n,floating:r}});v=_??v,x=w??x,N[E]={...N[E],...I},A&&j<NC&&(j++,typeof A=="object"&&(A.placement&&(S=A.placement),A.rects&&(h=A.rects===!0?await m.getElementRects({reference:n,floating:r,strategy:c}):A.rects),{x:v,y:x}=yy(h,S,b)),k=-1)}return{x:v,y:x,placement:S,strategy:c,middlewareData:N}},TC=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(r){var o,l;const{placement:c,middlewareData:d,rects:m,initialPlacement:g,platform:b,elements:h}=r,{mainAxis:v=!0,crossAxis:x=!0,fallbackPlacements:S,fallbackStrategy:j="bestFit",fallbackAxisSideDirection:N="none",flipAlignment:k=!0,...O}=ir(n,r);if((o=d.arrow)!=null&&o.alignmentOffset)return{};const E=qn(c),T=as(g),_=qn(g)===g,w=await(b.isRTL==null?void 0:b.isRTL(h.floating)),I=S||(_||!k?[Lc(g)]:Kw(g)),A=N!=="none";!S&&A&&I.push(...Ww(g,k,N,w));const U=[g,...I],M=await b.detectOverflow(r,O),K=[];let oe=((l=d.flip)==null?void 0:l.overflows)||[];if(v&&K.push(M[E]),x){const te=$w(c,m,w);K.push(M[te[0]],M[te[1]])}if(oe=[...oe,{placement:c,overflows:K}],!K.every(te=>te<=0)){var Z,ee;const te=(((Z=d.flip)==null?void 0:Z.index)||0)+1,X=U[te];if(X&&(!(x==="alignment"?T!==as(X):!1)||oe.every(H=>as(H.placement)===T?H.overflows[0]>0:!0)))return{data:{index:te,overflows:oe},reset:{placement:X}};let C=(ee=oe.filter(B=>B.overflows[0]<=0).sort((B,H)=>B.overflows[1]-H.overflows[1])[0])==null?void 0:ee.placement;if(!C)switch(j){case"bestFit":{var G;const B=(G=oe.filter(H=>{if(A){const z=as(H.placement);return z===T||z==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(z=>z>0).reduce((z,L)=>z+L,0)]).sort((H,z)=>H[1]-z[1])[0])==null?void 0:G[0];B&&(C=B);break}case"initialPlacement":C=g;break}if(c!==C)return{reset:{placement:C}}}return{}}}};function vy(n,r){return{top:n.top-r.height,right:n.right-r.width,bottom:n.bottom-r.height,left:n.left-r.width}}function Sy(n){return Gw.some(r=>n[r]>=0)}const wC=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(r){const{rects:o,platform:l}=r,{strategy:c="referenceHidden",...d}=ir(n,r);switch(c){case"referenceHidden":{const m=await l.detectOverflow(r,{...d,elementContext:"reference"}),g=vy(m,o.reference);return{data:{referenceHiddenOffsets:g,referenceHidden:Sy(g)}}}case"escaped":{const m=await l.detectOverflow(r,{...d,altBoundary:!0}),g=vy(m,o.floating);return{data:{escapedOffsets:g,escaped:Sy(g)}}}default:return{}}}}},$0=new Set(["left","top"]);async function CC(n,r){const{placement:o,platform:l,elements:c}=n,d=await(l.isRTL==null?void 0:l.isRTL(c.floating)),m=qn(o),g=Vr(o),b=as(o)==="y",h=$0.has(m)?-1:1,v=d&&b?-1:1,x=ir(r,n);let{mainAxis:S,crossAxis:j,alignmentAxis:N}=typeof x=="number"?{mainAxis:x,crossAxis:0,alignmentAxis:null}:{mainAxis:x.mainAxis||0,crossAxis:x.crossAxis||0,alignmentAxis:x.alignmentAxis};return g&&typeof N=="number"&&(j=g==="end"?N*-1:N),b?{x:j*v,y:S*h}:{x:S*h,y:j*v}}const RC=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(r){var o,l;const{x:c,y:d,placement:m,middlewareData:g}=r,b=await CC(r,n);return m===((o=g.offset)==null?void 0:o.placement)&&(l=g.arrow)!=null&&l.alignmentOffset?{}:{x:c+b.x,y:d+b.y,data:{...b,placement:m}}}}},OC=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(r){const{x:o,y:l,placement:c,platform:d}=r,{mainAxis:m=!0,crossAxis:g=!1,limiter:b={fn:T=>{let{x:_,y:w}=T;return{x:_,y:w}}},...h}=ir(n,r),v={x:o,y:l},x=await d.detectOverflow(r,h),S=as(c),j=Zm(S);let N=v[j],k=v[S];const O=(T,_)=>N0(_+x[T==="y"?"top":"left"],_,_-x[T==="y"?"bottom":"right"]);m&&(N=O(j,N)),g&&(k=O(S,k));const E=b.fn({...r,[j]:N,[S]:k});return{...E,data:{x:E.x-o,y:E.y-l,enabled:{[j]:m,[S]:g}}}}}},kC=function(n){return n===void 0&&(n={}),{options:n,fn(r){var o,l;const{x:c,y:d,placement:m,rects:g,middlewareData:b}=r,{offset:h=0,mainAxis:v=!0,crossAxis:x=!0}=ir(n,r),S={x:c,y:d},j=as(m),N=Zm(j);let k=S[N],O=S[j];const E=ir(h,r),T=typeof E=="number"?{mainAxis:E,crossAxis:0}:{mainAxis:(o=E.mainAxis)!=null?o:0,crossAxis:(l=E.crossAxis)!=null?l:0};if(v){const I=N==="y"?"height":"width",A=g.reference[N]-g.floating[I]+T.mainAxis,U=g.reference[N]+g.reference[I]-T.mainAxis;k<A?k=A:k>U&&(k=U)}if(x){var _,w;const I=N==="y"?"width":"height",A=$0.has(qn(m)),U=g.reference[j]-g.floating[I]+(A&&((_=b.offset)==null?void 0:_[j])||0)+(A?0:T.crossAxis),M=g.reference[j]+g.reference[I]+(A?0:((w=b.offset)==null?void 0:w[j])||0)-(A?T.crossAxis:0);O<U?O=U:O>M&&(O=M)}return{[N]:k,[j]:O}}}},_C=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(r){const{placement:o,rects:l,platform:c,elements:d}=r,{apply:m=()=>{},...g}=ir(n,r),b=await c.detectOverflow(r,g),h=qn(o),v=Vr(o),x=as(o)==="y",{width:S,height:j}=l.floating;let N,k;h==="top"||h==="bottom"?(N=h,k=v===(await(c.isRTL==null?void 0:c.isRTL(d.floating))?"start":"end")?"left":"right"):(k=h,N=v==="end"?"top":"bottom");const O=j-b.top-b.bottom,E=S-b.left-b.right,T=Ca(j-b[N],O),_=Ca(S-b[k],E),w=r.middlewareData.shift,I=!w;let A=T,U=_;w!=null&&w.enabled.x&&(U=E),w!=null&&w.enabled.y&&(A=O),I&&!v&&(x?U=S-2*nr(b.left,b.right):A=j-2*nr(b.top,b.bottom)),await m({...r,availableWidth:U,availableHeight:A});const M=await c.getDimensions(d.floating);return S!==M.width||j!==M.height?{reset:{rects:!0}}:{}}}};function K0(n){const r=Fn(n);let o=parseFloat(r.width)||0,l=parseFloat(r.height)||0;const c=Bt(n),d=c?n.offsetWidth:o,m=c?n.offsetHeight:l,g=zc(o)!==d||zc(l)!==m;return g&&(o=d,l=m),{width:o,height:l,$:g}}function ip(n){return xt(n)?n:n.contextElement}function Ea(n){const r=ip(n);if(!Bt(r))return sr(1);const o=r.getBoundingClientRect(),{width:l,height:c,$:d}=K0(r);let m=(d?zc(o.width):o.width)/l,g=(d?zc(o.height):o.height)/c;return(!m||!Number.isFinite(m))&&(m=1),(!g||!Number.isFinite(g))&&(g=1),{x:m,y:g}}const MC=sr(0);function Q0(n){const r=Xt(n);return!Bm()||!r.visualViewport?MC:{x:r.visualViewport.offsetLeft,y:r.visualViewport.offsetTop}}function AC(n,r,o){return r===void 0&&(r=!1),!!o&&r&&o===Xt(n)}function Eo(n,r,o,l){r===void 0&&(r=!1),o===void 0&&(o=!1);const c=n.getBoundingClientRect(),d=ip(n);let m=sr(1);r&&(l?xt(l)&&(m=Ea(l)):m=Ea(n));const g=AC(d,o,l)?Q0(d):sr(0);let b=(c.left+g.x)/m.x,h=(c.top+g.y)/m.y,v=c.width/m.x,x=c.height/m.y;if(d&&l){const S=Xt(d),j=xt(l)?Xt(l):l;let N=S,k=rm(N);for(;k&&j!==N;){const O=Ea(k),E=k.getBoundingClientRect(),T=Fn(k),_=E.left+(k.clientLeft+parseFloat(T.paddingLeft))*O.x,w=E.top+(k.clientTop+parseFloat(T.paddingTop))*O.y;b*=O.x,h*=O.y,v*=O.x,x*=O.y,b+=_,h+=w,N=Xt(k),k=rm(N)}}return Ic({width:v,height:x,x:b,y:h})}function ru(n,r){const o=Xc(n).scrollLeft;return r?r.left+o:Eo(cr(n)).left+o}function Z0(n,r){const o=n.getBoundingClientRect(),l=o.left+r.scrollLeft-ru(n,o),c=o.top+r.scrollTop;return{x:l,y:c}}function DC(n){let{elements:r,rect:o,offsetParent:l,strategy:c}=n;const d=c==="fixed",m=cr(l),g=r?Gc(r.floating):!1;if(l===m||g&&d)return o;let b={scrollLeft:0,scrollTop:0},h=sr(1);const v=sr(0),x=Bt(l);if((x||!d)&&((bn(l)!=="body"||jo(m))&&(b=Xc(l)),x)){const j=Eo(l);h=Ea(l),v.x=j.x+l.clientLeft,v.y=j.y+l.clientTop}const S=m&&!x&&!d?Z0(m,b):sr(0);return{width:o.width*h.x,height:o.height*h.y,x:o.x*h.x-b.scrollLeft*h.x+v.x+S.x,y:o.y*h.y-b.scrollTop*h.y+v.y+S.y}}function zC(n){return n.getClientRects?Array.from(n.getClientRects()):[]}function LC(n){const r=Xc(n),o=n.ownerDocument.body,l=nr(n.scrollWidth,n.clientWidth,o.scrollWidth,o.clientWidth),c=nr(n.scrollHeight,n.clientHeight,o.scrollHeight,o.clientHeight);let d=-r.scrollLeft+ru(n);const m=-r.scrollTop;return Fn(o).direction==="rtl"&&(d+=nr(n.clientWidth,o.clientWidth)-l),{width:l,height:c,x:d,y:m}}const IC=25;function BC(n,r,o){o===void 0&&(o="viewport");const l=o==="layoutViewport",c=Xt(n),d=cr(n),m=c.visualViewport;let g=d.clientWidth,b=d.clientHeight,h=0,v=0;if(m){const S=!Bm()||r==="fixed";l?S||(h=-m.offsetLeft,v=-m.offsetTop):(g=m.width,b=m.height,S&&(h=m.offsetLeft,v=m.offsetTop))}if(ru(d)<=0){const S=d.ownerDocument,j=S.body,N=getComputedStyle(j),k=S.compatMode==="CSS1Compat"&&parseFloat(N.marginLeft)+parseFloat(N.marginRight)||0,O=Math.abs(d.clientWidth-j.clientWidth-k),E=getComputedStyle(d).scrollbarGutter==="stable both-edges"?O/2:O;E<=IC&&(g-=E)}return{width:g,height:b,x:h,y:v}}function UC(n,r){const o=Eo(n,!0,r==="fixed"),l=o.top+n.clientTop,c=o.left+n.clientLeft,d=Ea(n),m=n.clientWidth*d.x,g=n.clientHeight*d.y,b=c*d.x,h=l*d.y;return{width:m,height:g,x:b,y:h}}function Ey(n,r,o){let l;if(r==="viewport"||r==="layoutViewport")l=BC(n,o,r);else if(r==="document")l=LC(cr(n));else if(xt(r))l=UC(r,o);else{const c=Q0(n);l={x:r.x-c.x,y:r.y-c.y,width:r.width,height:r.height}}return Ic(l)}function HC(n,r){const o=r.get(n);if(o)return o;let l=Il(n,[],!1).filter(g=>xt(g)&&bn(g)!=="body"),c=null;const d=Fn(n).position==="fixed";let m=d?ar(n):n;for(;xt(m)&&!er(m);){const g=Fn(m),b=Im(m),h=c?c.position:d?"fixed":"";!b&&(h==="fixed"||h==="absolute"&&g.position==="static")?l=l.filter(x=>x!==m):c=g,m=ar(m)}return r.set(n,l),l}function YC(n){let{element:r,boundary:o,rootBoundary:l,strategy:c}=n;const m=[...o==="clippingAncestors"?Gc(r)?[]:HC(r,this._c):[].concat(o),l],g=Ey(r,m[0],c);let b=g.top,h=g.right,v=g.bottom,x=g.left;for(let S=1;S<m.length;S++){const j=Ey(r,m[S],c);b=nr(j.top,b),h=Ca(j.right,h),v=Ca(j.bottom,v),x=nr(j.left,x)}return{width:h-x,height:v-b,x,y:b}}function PC(n){const{width:r,height:o}=K0(n);return{width:r,height:o}}function VC(n,r,o){const l=Bt(r),c=cr(r),d=o==="fixed",m=Eo(n,!0,d,r);let g={scrollLeft:0,scrollTop:0};const b=sr(0);if((l||!d)&&((bn(r)!=="body"||jo(c))&&(g=Xc(r)),l)){const S=Eo(r,!0,d,r);b.x=S.x+r.clientLeft,b.y=S.y+r.clientTop}!l&&c&&(b.x=ru(c));const h=c&&!l&&!d?Z0(c,g):sr(0),v=m.left+g.scrollLeft-b.x-h.x,x=m.top+g.scrollTop-b.y-h.y;return{x:v,y:x,width:m.width,height:m.height}}function Uf(n){return Fn(n).position==="static"}function Ny(n,r){if(!Bt(n)||Fn(n).position==="fixed")return null;if(r)return r(n);let o=n.offsetParent;return cr(n)===o&&(o=o.ownerDocument.body),o}function J0(n,r){const o=Xt(n);if(Gc(n))return o;if(!Bt(n)){let c=ar(n);for(;c&&!er(c);){if(xt(c)&&!Uf(c))return c;c=ar(c)}return o}let l=Ny(n,r);for(;l&&O2(l)&&Uf(l);)l=Ny(l,r);return l&&er(l)&&Uf(l)&&!Im(l)?o:l||M2(n)||o}const qC=async function(n){const r=this.getOffsetParent||J0,o=this.getDimensions,l=await o(n.floating);return{reference:VC(n.reference,await r(n.floating),n.strategy),floating:{x:0,y:0,width:l.width,height:l.height}}};function FC(n){return Fn(n).direction==="rtl"}const GC={convertOffsetParentRelativeRectToViewportRelativeRect:DC,getDocumentElement:cr,getClippingRect:YC,getOffsetParent:J0,getElementRects:qC,getClientRects:zC,getDimensions:PC,getScale:Ea,isElement:xt,isRTL:FC};function W0(n,r){return n.x===r.x&&n.y===r.y&&n.width===r.width&&n.height===r.height}function XC(n,r,o){let l=null,c;const d=cr(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:N,width:k,height:O}=S;if(v||r(),!k||!O)return;const E=fc(N),T=fc(d.clientWidth-(j+k)),_=fc(d.clientHeight-(N+O)),w=fc(j),A={rootMargin:-E+"px "+-T+"px "+-_+"px "+-w+"px",threshold:nr(0,Ca(1,x))||1};let U=!0;function M(K){const oe=K[0].intersectionRatio;if(!W0(S,n.getBoundingClientRect()))return g();if(oe!==x){if(!U)return g();oe?g(!1,oe):c=setTimeout(()=>{g(!1,1e-7)},1e3)}U=!1}try{l=new IntersectionObserver(M,{...A,root:d.ownerDocument})}catch{l=new IntersectionObserver(M,A)}l.observe(n)}const b=Xt(n),h=()=>g(o);return b.addEventListener("resize",h),g(!0),()=>{b.removeEventListener("resize",h),m()}}function jy(n,r,o,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,h=ip(n),v=c||d?[...h?Il(h):[],...r?Il(r):[]]:[];v.forEach(E=>{c&&E.addEventListener("scroll",o),d&&E.addEventListener("resize",o)});const x=h&&g?XC(h,o,d):null;let S=-1,j=null;m&&(j=new ResizeObserver(E=>{let[T]=E;T&&T.target===h&&j&&r&&(j.unobserve(r),cancelAnimationFrame(S),S=requestAnimationFrame(()=>{var _;(_=j)==null||_.observe(r)})),o()}),h&&!b&&j.observe(h),r&&j.observe(r));let N,k=b?Eo(n):null;b&&O();function O(){const E=Eo(n);k&&!W0(k,E)&&o(),k=E,N=requestAnimationFrame(O)}return o(),()=>{var E;v.forEach(T=>{c&&T.removeEventListener("scroll",o),d&&T.removeEventListener("resize",o)}),x?.(),(E=j)==null||E.disconnect(),j=null,b&&cancelAnimationFrame(N)}}const $C=RC,KC=OC,QC=TC,ZC=_C,JC=wC,WC=kC,eR=(n,r,o)=>{const l=new Map,c=o??{},d={...GC,...c.platform,_c:l};return jC(n,r,{...c,platform:d})};var tR=typeof document<"u",nR=function(){},Tc=tR?p.useLayoutEffect:nR;function Bc(n,r){if(n===r)return!0;if(typeof n!=typeof r)return!1;if(typeof n=="function"&&n.toString()===r.toString())return!0;let o,l,c;if(n&&r&&typeof n=="object"){if(Array.isArray(n)){if(o=n.length,o!==r.length)return!1;for(l=o;l--!==0;)if(!Bc(n[l],r[l]))return!1;return!0}if(c=Object.keys(n),o=c.length,o!==Object.keys(r).length)return!1;for(l=o;l--!==0;)if(!{}.hasOwnProperty.call(r,c[l]))return!1;for(l=o;l--!==0;){const d=c[l];if(!(d==="_owner"&&n.$$typeof)&&!Bc(n[d],r[d]))return!1}return!0}return n!==n&&r!==r}function e1(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function Ty(n,r){const o=e1(n);return Math.round(r*o)/o}function Hf(n){const r=p.useRef(n);return Tc(()=>{r.current=n}),r}function sR(n){n===void 0&&(n={});const{placement:r="bottom",strategy:o="absolute",middleware:l=[],platform:c,elements:{reference:d,floating:m}={},transform:g=!0,whileElementsMounted:b,open:h}=n,[v,x]=p.useState({x:0,y:0,strategy:o,placement:r,middlewareData:{},isPositioned:!1}),[S,j]=p.useState(l);Bc(S,l)||j(l);const[N,k]=p.useState(null),[O,E]=p.useState(null),T=p.useCallback(H=>{H!==A.current&&(A.current=H,k(H))},[]),_=p.useCallback(H=>{H!==U.current&&(U.current=H,E(H))},[]),w=d||N,I=m||O,A=p.useRef(null),U=p.useRef(null),M=p.useRef(v),K=b!=null,oe=Hf(b),Z=Hf(c),ee=Hf(h),G=p.useCallback(()=>{if(!A.current||!U.current)return;const H={placement:r,strategy:o,middleware:S};Z.current&&(H.platform=Z.current),eR(A.current,U.current,H).then(z=>{const L={...z,isPositioned:ee.current!==!1};te.current&&!Bc(M.current,L)&&(M.current=L,lr.flushSync(()=>{x(L)}))})},[S,r,o,Z,ee]);Tc(()=>{h===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,x(H=>({...H,isPositioned:!1})))},[h]);const te=p.useRef(!1);Tc(()=>(te.current=!0,()=>{te.current=!1}),[]),Tc(()=>{if(w&&(A.current=w),I&&(U.current=I),w&&I){if(oe.current)return oe.current(w,I,G);G()}},[w,I,G,oe,K]);const X=p.useMemo(()=>({reference:A,floating:U,setReference:T,setFloating:_}),[T,_]),C=p.useMemo(()=>({reference:w,floating:I}),[w,I]),B=p.useMemo(()=>{const H={position:o,left:0,top:0};if(!C.floating)return H;const z=Ty(C.floating,v.x),L=Ty(C.floating,v.y);return g?{...H,transform:"translate("+z+"px, "+L+"px)",...e1(C.floating)>=1.5&&{willChange:"transform"}}:{position:o,left:z,top:L}},[o,g,C.floating,v.x,v.y]);return p.useMemo(()=>({...v,update:G,refs:X,elements:C,floatingStyles:B}),[v,G,X,C,B])}const rR=(n,r)=>{const o=$C(n);return{name:o.name,fn:o.fn,options:[n,r]}},oR=(n,r)=>{const o=KC(n);return{name:o.name,fn:o.fn,options:[n,r]}},aR=(n,r)=>({fn:WC(n).fn,options:[n,r]}),lR=(n,r)=>{const o=QC(n);return{name:o.name,fn:o.fn,options:[n,r]}},iR=(n,r)=>{const o=ZC(n);return{name:o.name,fn:o.fn,options:[n,r]}},cR=(n,r)=>{const o=JC(n);return{name:o.name,fn:o.fn,options:[n,r]}};function t1(n){const r=p.useRef(!0);r.current&&(r.current=!1,n())}const Ye=(n,r,o,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 Yf={exports:{}},Pf={};var wy;function uR(){if(wy)return Pf;wy=1;var n=Vl();function r(x,S){return x===S&&(x!==0||1/x===1/S)||x!==x&&S!==S}var o=typeof Object.is=="function"?Object.is:r,l=n.useState,c=n.useEffect,d=n.useLayoutEffect,m=n.useDebugValue;function g(x,S){var j=S(),N=l({inst:{value:j,getSnapshot:S}}),k=N[0].inst,O=N[1];return d(function(){k.value=j,k.getSnapshot=S,b(k)&&O({inst:k})},[x,j,S]),c(function(){return b(k)&&O({inst:k}),x(function(){b(k)&&O({inst:k})})},[x]),m(j),j}function b(x){var S=x.getSnapshot;x=x.value;try{var j=S();return!o(x,j)}catch{return!0}}function h(x,S){return S()}var v=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:g;return Pf.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:v,Pf}var Cy;function n1(){return Cy||(Cy=1,Yf.exports=uR()),Yf.exports}var s1=n1(),Vf={exports:{}},qf={};var Ry;function dR(){if(Ry)return qf;Ry=1;var n=Vl(),r=n1();function o(h,v){return h===v&&(h!==0||1/h===1/v)||h!==h&&v!==v}var l=typeof Object.is=="function"?Object.is:o,c=r.useSyncExternalStore,d=n.useRef,m=n.useEffect,g=n.useMemo,b=n.useDebugValue;return qf.useSyncExternalStoreWithSelector=function(h,v,x,S,j){var N=d(null);if(N.current===null){var k={hasValue:!1,value:null};N.current=k}else k=N.current;N=g(function(){function E(A){if(!T){if(T=!0,_=A,A=S(A),j!==void 0&&k.hasValue){var U=k.value;if(j(U,A))return w=U}return w=A}if(U=w,l(_,A))return U;var M=S(A);return j!==void 0&&j(U,M)?(_=A,U):(_=A,w=M)}var T=!1,_,w,I=x===void 0?null:x;return[function(){return E(v())},I===null?void 0:function(){return E(I())}]},[v,x,S,j]);var O=c(h,N[0],N[1]);return m(function(){k.hasValue=!0,k.value=O},[O]),b(O),O},qf}var Oy;function fR(){return Oy||(Oy=1,Vf.exports=dR()),Vf.exports}var mR=fR();const bm=[];let ym;function pR(){return ym}function hR(n){bm.push(n)}function r1(n){const r=(o,l)=>{const c=zn(xR).current;let d;try{ym=c;for(const m of bm)m.before(c);d=n(o,l);for(const m of bm)m.after(c);c.didInitialize=!0}finally{ym=void 0}return d};return r.displayName=n.displayName||n.name,r}function gR(n){return p.forwardRef(r1(n))}function xR(){return{didInitialize:!1}}const bR=Vm(19),yR=bR?SR:ER;function o1(n,r,o,l,c){return yR(n,r,o,l,c)}function vR(n,r,o,l,c){const d=p.useCallback(()=>r(n.getSnapshot(),o,l,c),[n,r,o,l,c]);return s1.useSyncExternalStore(n.subscribe,d,d)}hR({before(n){n.syncIndex=0,n.didInitialize||(n.syncTick=1,n.syncHooks=[],n.didChangeStore=!0,n.getSnapshot=()=>{let r=!1;for(let o=0;o<n.syncHooks.length;o+=1){const l=n.syncHooks[o],c=l.selector(l.store.state,l.a1,l.a2,l.a3);Object.is(l.value,c)||(r=!0,l.value=c)}return r&&(n.syncTick+=1),n.syncTick})},after(n){n.syncHooks.length>0&&(n.didChangeStore&&(n.didChangeStore=!1,n.subscribe=r=>{const o=new Set;for(const c of n.syncHooks)o.add(c.store);const l=[];for(const c of o)l.push(c.subscribe(r));return()=>{for(const c of l)c()}}),s1.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot))}});function SR(n,r,o,l,c){const d=pR();if(!d)return vR(n,r,o,l,c);const m=d.syncIndex;d.syncIndex+=1;let g;return d.didInitialize?(g=d.syncHooks[m],(g.store!==n||g.selector!==r||!Object.is(g.a1,o)||!Object.is(g.a2,l)||!Object.is(g.a3,c))&&(g.store!==n&&(d.didChangeStore=!0),g.store=n,g.selector=r,g.a1=o,g.a2=l,g.a3=c,g.value=r(n.getSnapshot(),o,l,c))):(g={store:n,selector:r,a1:o,a2:l,a3:c,value:r(n.getSnapshot(),o,l,c)},d.syncHooks.push(g)),g.value}function ER(n,r,o,l,c){return mR.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getSnapshot,d=>r(d,o,l,c))}class NR{constructor(r){this.state=r,this.listeners=new Set,this.updateTick=0}subscribe=r=>(this.listeners.add(r),()=>{this.listeners.delete(r)});getSnapshot=()=>this.state;setState(r){if(this.state===r)return;this.state=r,this.updateTick+=1;const o=this.updateTick;for(const l of this.listeners){if(o!==this.updateTick)return;l(r)}}update(r){for(const o in r)if(!Object.is(this.state[o],r[o])){this.setState({...this.state,...r});return}}set(r,o){Object.is(this.state[r],o)||this.setState({...this.state,[r]:o})}notifyAll(){const r={...this.state};this.setState(r)}use(r,o,l,c){return o1(this,r,o,l,c)}}class ou extends NR{constructor(r,o={},l){super(r),this.context=o,this.selectors=l}useSyncedValue(r,o){p.useDebugValue(r);const l=this;Ge(()=>{l.state[r]!==o&&l.set(r,o)},[l,r,o])}useSyncedValueWithCleanup(r,o){const l=this;Ge(()=>(l.state[r]!==o&&l.set(r,o),()=>{l.set(r,void 0)}),[l,r,o])}useSyncedValues(r){const o=this,l=Object.values(r);Ge(()=>{o.update(r)},[o,...l])}useControlledProp(r,o){p.useDebugValue(r);const l=this,c=o!==void 0;Ge(()=>{c&&!Object.is(l.state[r],o)&&l.setState({...l.state,[r]:o})},[l,r,o,c])}select(r,o,l,c){const d=this.selectors[r];return d(this.state,o,l,c)}useState(r,o,l,c){return p.useDebugValue(r),o1(this,this.selectors[r],o,l,c)}useContextCallback(r,o){p.useDebugValue(r);const l=nt(o??un);this.context[r]=l}useStateSetter(r){const o=p.useRef(void 0);return o.current===void 0&&(o.current=l=>{this.set(r,l)}),o.current}observe(r,o){let l;typeof r=="function"?l=r:l=this.selectors[r];let c=l(this.state);return o(c,c,this),this.subscribe(d=>{const m=l(d);if(!Object.is(c,m)){const g=c;c=m,o(m,g,this)}})}}const jR={open:Ye(n=>n.open),transitionStatus:Ye(n=>n.transitionStatus),domReferenceElement:Ye(n=>n.domReferenceElement),referenceElement:Ye(n=>n.positionReference??n.referenceElement),floatingElement:Ye(n=>n.floatingElement),floatingId:Ye(n=>n.floatingId)};class au extends ou{constructor(r){const{syncOnly:o,nested:l,onOpenChange:c,triggerElements:d,...m}=r;super({...m,positionReference:m.referenceElement,domReferenceElement:m.referenceElement},{onOpenChange:c,dataRef:{current:{}},events:P0(),nested:l,triggerElements:d},jR),this.syncOnly=o}syncOpenEvent=(r,o)=>{(!r||!this.state.open||o!=null&&Iw(o))&&(this.context.dataRef.current.openEvent=r?o:void 0)};dispatchOpenChange=(r,o)=>{this.syncOpenEvent(r,o.event);const l={open:r,reason:o.reason,nativeEvent:o.event,nested:this.context.nested,triggerElement:o.trigger};this.context.events.emit("openchange",l)};setOpen=(r,o)=>{if(this.syncOnly){this.context.onOpenChange?.(r,o);return}this.dispatchOpenChange(r,o),this.context.onOpenChange?.(r,o)}}function a1(n){const{popupStore:r,treatPopupAsFloatingElement:o=!1,floatingRootContext:l,floatingId:c,nested:d,onOpenChange:m}=n,g=r.useState("open"),b=r.useState("activeTriggerElement"),h=r.useState(o?"popupElement":"positionerElement"),v=r.context.triggerElements,x=m,S=p.useRef(null);l===void 0&&S.current===null&&(S.current=new au({open:g,transitionStatus:void 0,referenceElement:b,floatingElement:h,triggerElements:v,onOpenChange:x,floatingId:c,syncOnly:!0,nested:d}));const j=l??S.current;return r.useSyncedValue("floatingId",c),Ge(()=>{const N={open:g,floatingId:c,referenceElement:b,floatingElement:h};xt(b)&&(N.domReferenceElement=b),j.state.positionReference===j.state.referenceElement&&(N.positionReference=b),j.update(N)},[g,c,b,h,j]),j.context.onOpenChange=x,j.context.nested=d,j}const lu={tabIndex:-1,[dm]:""};function l1(n){return r=>r==="touch"?n.current:!0}function i1(n,r,o=!1){const l=So(),c=ur()!=null,d=p.useRef(null);n===void 0&&d.current===null&&(d.current=r(l,c));const m=n??d.current;return a1({popupStore:m,treatPopupAsFloatingElement:o,floatingRootContext:m.state.floatingRootContext,floatingId:l,nested:c,onOpenChange:m.setOpen}),{store:m,internalStore:d.current}}function TR(n,r){const o=p.useRef(null),l=p.useRef(null);return p.useCallback(c=>{if(n===void 0)return;let d=!1;if(o.current!==null){const m=o.current,g=l.current,b=r.context.triggerElements.getById(m);g&&b===g&&(r.context.triggerElements.delete(m),d=!0),o.current=null,l.current=null}if(c!==null&&(o.current=n,l.current=c,r.context.triggerElements.add(n,c),d=!0),d){const m=r.context.triggerElements.size;r.select("open")&&r.state.triggerCount!==m&&r.set("triggerCount",m)}},[r,n])}function cp(n,r,o,l=!1){r?n.preventUnmountingOnClose=!1:l&&(n.preventUnmountingOnClose=!0);const c=o?.id??null;(c||r)&&(n.activeTriggerId=c,n.activeTriggerElement=o??null)}function c1(n){let r=!1;return n.preventUnmountOnClose=()=>{r=!0},()=>r}function u1(n,r,o,l){t1(()=>{r===void 0&&n.state.open===!1&&o&&(n.state={...n.state,open:!0,activeTriggerId:l,preventUnmountingOnClose:!1})})}function d1(n,r,o,l){const c=o.useState("isMountedByTrigger",n),d=TR(n,o),m=nt(g=>{if(d(g),!g)return;const b=o.select("open"),h=o.select("activeTriggerId");if(h===n){o.update({activeTriggerElement:g,...b?l:null});return}h==null&&b&&o.update({activeTriggerId:n,activeTriggerElement:g,...l})});return Ge(()=>{c&&o.update({activeTriggerElement:r.current,...l})},[c,o,r,...Object.values(l)]),{registerTrigger:m,isMountedByThisTrigger:c}}function up(n,r={}){const{closeOnActiveTriggerUnmount:o=!1}=r,l=n.useState("open"),c=n.useState("triggerCount");Ge(()=>{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 h=n.context.triggerElements.getById(g);h?h!==n.state.activeTriggerElement&&(m.activeTriggerElement=h):b=g}if(!b&&!g&&d===1){const h=n.context.triggerElements.entries().next();if(!h.done){const[v,x]=h.value;m.activeTriggerId=v,m.activeTriggerElement=x}}(m.triggerCount!==void 0||m.activeTriggerId!==void 0||m.activeTriggerElement!==void 0)&&n.update(m),b&&o&&queueMicrotask(()=>{if(n.select("open")&&n.select("activeTriggerId")===b&&!n.context.triggerElements.getById(b)){const h=jt(f0);n.setOpen(!1,h),h.isCanceled||n.update({activeTriggerId:null,activeTriggerElement:null})}})},[l,n,c,o])}function dp(n,r,o){const{mounted:l,setMounted:c,transitionStatus:d}=kw(n),m=r.useState("preventUnmountingOnClose"),g=n?!1:m;r.useSyncedValues({mounted:l,transitionStatus:d,preventUnmountingOnClose:g});const b=nt(()=>{c(!1),r.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),o?.(),r.context.onOpenChangeComplete?.(!1)});return Wc({enabled:l&&!n&&!g,open:n,ref:r.context.popupRef,onComplete(){n||b()}}),{forceUnmount:b,transitionStatus:d}}function fp(n,r){n.useSyncedValues(r),Ge(()=>()=>{n.update({activeTriggerProps:Ut,inactiveTriggerProps:Ut,popupProps:Ut})},[n])}function f1(n,r){Ge(()=>{!r&&n.state.openMethod!==null&&n.set("openMethod",null)},[r,n]),Ge(()=>()=>{n.state.openMethod!==null&&n.set("openMethod",null)},[n])}class Xl{constructor(){this.elementsSet=new Set,this.idMap=new Map}add(r,o){const l=this.idMap.get(r);l!==o&&(l!==void 0&&this.elementsSet.delete(l),this.elementsSet.add(o),this.idMap.set(r,o))}delete(r){const o=this.idMap.get(r);o&&(this.elementsSet.delete(o),this.idMap.delete(r))}hasElement(r){return this.elementsSet.has(r)}hasMatchingElement(r){for(const o of this.elementsSet)if(r(o))return!0;return!1}getById(r){return this.idMap.get(r)}entries(){return this.idMap.entries()}elements(){return this.elementsSet.values()}get size(){return this.idMap.size}}function wR(){return new au({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new Xl,floatingId:void 0,syncOnly:!1,nested:!1,onOpenChange:void 0})}function mp(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:wR(),floatingId:void 0,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:Ut,inactiveTriggerProps:Ut,popupProps:Ut}}function m1(n,r,o=!1){return new au({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:n,floatingId:r,syncOnly:!0,nested:o,onOpenChange:void 0})}const Dl=Ye(n=>n.triggerIdProp??n.activeTriggerId),pp=Ye(n=>n.openProp??n.open),ky=Ye(n=>(n.popupElement?.id??n.floatingId)||void 0);function p1(n,r){return r!==void 0&&pp(n)&&Dl(n)===r}function CR(n,r){return p1(n,r)?!0:r!==void 0&&pp(n)&&Dl(n)==null&&n.triggerCount===1}const hp={open:pp,mounted:Ye(n=>n.mounted),transitionStatus:Ye(n=>n.transitionStatus),floatingRootContext:Ye(n=>n.floatingRootContext),triggerCount:Ye(n=>n.triggerCount),preventUnmountingOnClose:Ye(n=>n.preventUnmountingOnClose),payload:Ye(n=>n.payload),activeTriggerId:Dl,activeTriggerElement:Ye(n=>n.mounted?n.activeTriggerElement:null),popupId:ky,isTriggerActive:Ye((n,r)=>r!==void 0&&Dl(n)===r),isOpenedByTrigger:Ye((n,r)=>p1(n,r)),isMountedByTrigger:Ye((n,r)=>r!==void 0&&Dl(n)===r&&n.mounted),triggerProps:Ye((n,r)=>r?n.activeTriggerProps:n.inactiveTriggerProps),triggerPopupId:Ye((n,r)=>CR(n,r)?ky(n):void 0),popupProps:Ye(n=>n.popupProps),popupElement:Ye(n=>n.popupElement),positionerElement:Ye(n=>n.positionerElement)};function RR(n){const{open:r=!1,onOpenChange:o,elements:l={}}=n,c=So(),d=ur()!=null,m=zn(()=>new au({open:r,transitionStatus:void 0,onOpenChange:o,referenceElement:l.reference??null,floatingElement:l.floating??null,triggerElements:new Xl,floatingId:c,syncOnly:!1,nested:d})).current;return Ge(()=>{const g={open:r,floatingId:c};l.reference!==void 0&&(g.referenceElement=l.reference,g.domReferenceElement=xt(l.reference)?l.reference:null),l.floating!==void 0&&(g.floatingElement=l.floating),m.update(g)},[r,c,l.reference,l.floating,m]),m.context.onOpenChange=o,m.context.nested=d,m}function OR(n={}){const{nodeId:r,externalTree:o}=n,l=RR(n),c=n.rootContext||l,d=c.useState("referenceElement"),m=c.useState("floatingElement"),g=c.useState("domReferenceElement"),b=c.useState("open"),h=c.useState("floatingId"),[v,x]=p.useState(null),[S,j]=p.useState(void 0),[N,k]=p.useState(void 0),O=p.useRef(null),E=qr(o),T=p.useMemo(()=>({reference:d,floating:m,domReference:g}),[d,m,g]),_=sR({...n,elements:{...T,...v&&{reference:v}}}),w=xt(S)?S:null,I=N===void 0?c.state.floatingElement:N;c.useSyncedValue("referenceElement",S??null),c.useSyncedValue("domReferenceElement",S===void 0?g:w),c.useSyncedValue("floatingElement",I);const A=p.useCallback(ee=>{const G=xt(ee)?{getBoundingClientRect:()=>ee.getBoundingClientRect(),getClientRects:()=>ee.getClientRects(),contextElement:ee}:ee;x(G),_.refs.setReference(G)},[_.refs]),U=p.useCallback(ee=>{(xt(ee)||ee===null)&&(O.current=ee,j(ee)),(xt(_.refs.reference.current)||_.refs.reference.current===null||ee!==null&&!xt(ee))&&_.refs.setReference(ee)},[_.refs,j]),M=p.useCallback(ee=>{k(ee),_.refs.setFloating(ee)},[_.refs]),K=p.useMemo(()=>({..._.refs,setReference:U,setFloating:M,setPositionReference:A,domReference:O}),[_.refs,U,M,A]),oe=p.useMemo(()=>({..._.elements,domReference:g}),[_.elements,g]),Z=p.useMemo(()=>({..._,dataRef:c.context.dataRef,open:b,onOpenChange:c.setOpen,events:c.context.events,floatingId:h,refs:K,elements:oe,nodeId:r,rootStore:c}),[_,K,oe,r,c,b,h]);return Ge(()=>{g&&(O.current=g)},[g]),Ge(()=>{c.context.dataRef.current.floatingContext=Z;const ee=E?.nodesRef.current.find(G=>G.id===r);ee&&(ee.context=Z)}),p.useMemo(()=>({..._,context:Z,refs:K,elements:oe,rootStore:c}),[_,K,oe,Z,c])}const Ff=Gm&&wo;function kR(n,r={}){const{enabled:o=!0,delay:l}=r,c="rootStore"in n?n.rootStore:n,{events:d,dataRef:m}=c.context,g=p.useRef(!1),b=p.useRef(null),h=p.useRef(!0),v=Gn();p.useEffect(()=>{const S=c.select("domReferenceElement");if(!o)return;const j=Xt(S);function N(){const E=c.select("domReferenceElement");!c.select("open")&&Bt(E)&&E===jn(vt(E))&&(g.current=!0)}function k(){h.current=!0}function O(){h.current=!1}return ws(pt(j,"blur",N),Ff&&pt(j,"keydown",k,!0),Ff&&pt(j,"pointerdown",O,!0))},[c,o]),p.useEffect(()=>{if(!o)return;function S(j){if(j.reason===yo||j.reason===Qc){const N=c.select("domReferenceElement");xt(N)&&(b.current=N,g.current=!0)}}return d.on("openchange",S),()=>{d.off("openchange",S)}},[d,o,c]);const x=p.useMemo(()=>{function S(){g.current=!1,b.current=null}return{onMouseLeave(){S()},onFocus(j){const N=j.currentTarget;if(g.current){if(b.current===N)return;S()}const k=Dn(j.nativeEvent);if(xt(k)){if(Ff&&!j.relatedTarget){if(!h.current&&!nu(k))return}else if(!Hw(k))return}const O=Dc(j.relatedTarget,c.context.triggerElements),{nativeEvent:E,currentTarget:T}=j,_=typeof l=="function"?l():l;if(c.select("open")&&O||_===0||_===void 0){c.setOpen(!0,jt(Al,E,T));return}v.start(_,()=>{g.current||c.setOpen(!0,jt(Al,E,T))})},onBlur(j){S();const N=j.relatedTarget,k=j.nativeEvent,O=xt(N)&&N.hasAttribute(Pl("focus-guard"))&&N.getAttribute("data-type")==="outside";v.start(0,()=>{const E=c.select("domReferenceElement"),T=jn(vt(E));!N&&T===E||We(m.current.floatingContext?.refs.floating.current,T)||We(E,T)||O||Dc(N??T,c.context.triggerElements)||c.setOpen(!1,jt(Al,k))})}}},[m,l,c,v]);return p.useMemo(()=>o?{reference:x,trigger:x}:{},[o,x])}class gp{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 fs,this.restTimeout=new fs,this.handleCloseOptions=void 0}static create(){return new gp}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose}const Uc=new WeakMap;function Hc(n){if(!n.performedPointerEventsMutation)return;const r=n.pointerEventsScopeElement;r&&Uc.get(r)===n&&(n.pointerEventsScopeElement?.style.removeProperty("pointer-events"),n.pointerEventsReferenceElement?.style.removeProperty("pointer-events"),n.pointerEventsFloatingElement?.style.removeProperty("pointer-events"),Uc.delete(r)),n.performedPointerEventsMutation=!1,n.pointerEventsScopeElement=null,n.pointerEventsReferenceElement=null,n.pointerEventsFloatingElement=null}function h1(n,r){const{scopeElement:o,referenceElement:l,floatingElement:c}=r,d=Uc.get(o);d&&d!==n&&Hc(d),Hc(n),n.performedPointerEventsMutation=!0,n.pointerEventsScopeElement=o,n.pointerEventsReferenceElement=l,n.pointerEventsFloatingElement=c,Uc.set(o,n),o.style.pointerEvents="none",l.style.pointerEvents="auto",c.style.pointerEvents="auto"}function g1(n){const r=n.context.dataRef.current,o=zn(()=>r.hoverInteractionState??gp.create()).current;return r.hoverInteractionState||(r.hoverInteractionState=o),$m(r.hoverInteractionState.disposeEffect),r.hoverInteractionState}function x1(n,r={}){const{enabled:o=!0,closeDelay:l=0,nodeId:c}=r,d="rootStore"in n?n.rootStore:n,m=d.useState("open"),g=d.useState("floatingElement"),b=d.useState("domReferenceElement"),{dataRef:h}=d.context,v=qr(),x=ur(),S=g1(d),j=Gn(),N=nt(()=>E0(h.current.openEvent?.type,S.interactedInside)),k=nt(()=>Pw(h.current.openEvent?.type)),O=nt(()=>{Hc(S)});Ge(()=>{m||(S.pointerType=void 0,S.restTimeoutPending=!1,S.interactedInside=!1,O())},[m,S,O]),p.useEffect(()=>O,[O]),Ge(()=>{if(o&&m&&S.handleCloseOptions?.blockPointerEvents&&k()&&xt(b)&&g){const E=b,T=g,_=vt(g),w=v?.nodesRef.current.find(M=>M.id===x)?.context?.elements.floating;w&&(w.style.pointerEvents="");const I=S.pointerEventsScopeElement!==T?S.pointerEventsScopeElement:null,A=w!==T?w:null,U=S.handleCloseOptions?.getScope?.()??I??A??E.closest("[data-rootownerid]")??_.body;return h1(S,{scopeElement:U,referenceElement:E,floatingElement:T}),()=>{O()}}},[o,m,b,g,S,k,v,x,O]),p.useEffect(()=>{if(!o)return;function E(){return!!(v&&x&&Yr(v.nodesRef.current,x).length>0)}function T(M){const K=pm(l,"close",S.pointerType),oe=()=>{d.setOpen(!1,jt(dn,M)),v?.events.emit("floating.closed",M)};K?S.openChangeTimeout.start(K,oe):(S.openChangeTimeout.clear(),oe())}function _(M){const K=Dn(M);if(!Uw(K)){S.interactedInside=!1;return}S.interactedInside=K?.closest("[aria-haspopup]")!=null}function w(){S.openChangeTimeout.clear(),j.clear(),v?.events.off("floating.closed",A),O()}function I(M){if(E()&&v){v.events.on("floating.closed",A);return}if(Dc(M.relatedTarget,d.context.triggerElements))return;const K=h.current.floatingContext?.nodeId??c,oe=M.relatedTarget;if(!(v&&K&&xt(oe)&&Yr(v.nodesRef.current,K,!1).some(ee=>We(ee.context?.elements.floating,oe)))){if(S.handler){S.handler(M);return}O(),k()&&!N()&&T(M)}}function A(M){!v||!x||E()||j.start(0,()=>{v.events.off("floating.closed",A),d.setOpen(!1,jt(dn,M)),v.events.emit("floating.closed",M)})}const U=g;return ws(U&&pt(U,"mouseenter",w),U&&pt(U,"mouseleave",I),U&&pt(U,"pointerdown",_,!0),()=>{v?.events.off("floating.closed",A)})},[o,g,d,h,l,c,k,N,O,S,v,x,j])}const _R={current:null};function b1(n,r={}){const{enabled:o=!0,delay:l=0,handleClose:c=null,mouseOnly:d=!1,restMs:m=0,move:g=!0,triggerElementRef:b=_R,externalTree:h,isActiveTrigger:v=!0,getHandleCloseContext:x,isClosing:S,shouldOpen:j}=r,N="rootStore"in n?n.rootStore:n,{dataRef:k,events:O}=N.context,E=qr(h),T=g1(N),_=p.useRef(!1),w=on(c),I=on(l),A=on(m),U=on(o),M=on(j),K=on(S),oe=nt(()=>E0(k.current.openEvent?.type,T.interactedInside)),Z=nt(()=>M.current?.()!==!1),ee=nt((X,C,B)=>{const H=N.context.triggerElements;if(H.hasElement(C))return!X||!We(X,C);if(!xt(B))return!1;const z=B;return H.hasMatchingElement(L=>We(L,z))&&(!X||!We(X,z))}),G=nt(()=>{if(!T.handler)return;vt(N.select("domReferenceElement")).removeEventListener("mousemove",T.handler),T.handler=void 0}),te=nt(()=>{Hc(T)});return v&&(T.handleCloseOptions=w.current?.__options),p.useEffect(()=>G,[G]),p.useEffect(()=>{if(!o)return;function X(C){C.open?_.current=!1:(_.current=C.reason===dn,G(),T.openChangeTimeout.clear(),T.restTimeout.clear(),T.blockMouseMove=!0,T.restTimeoutPending=!1)}return O.on("openchange",X),()=>{O.off("openchange",X)}},[o,O,T,G]),p.useEffect(()=>{if(!o)return;function X(z,L=!0){const D=pm(I.current,"close",T.pointerType);D?T.openChangeTimeout.start(D,()=>{N.setOpen(!1,jt(dn,z)),E?.events.emit("floating.closed",z)}):L&&(T.openChangeTimeout.clear(),N.setOpen(!1,jt(dn,z)),E?.events.emit("floating.closed",z))}const C=b.current??(v?N.select("domReferenceElement"):null);if(!xt(C))return;function B(z){if(T.openChangeTimeout.clear(),T.blockMouseMove=!1,d&&!Yl(T.pointerType))return;const L=sy(A.current),D=pm(I.current,"open",T.pointerType),q=Dn(z),V=z.currentTarget??null,Q=N.select("domReferenceElement");let ne=V;if(xt(q)&&!N.context.triggerElements.hasElement(q)){for(const De of N.context.triggerElements.elements())if(We(De,q)){ne=De;break}}xt(V)&&xt(Q)&&!N.context.triggerElements.hasElement(V)&&We(V,Q)&&(ne=Q);const F=ne==null?!1:ee(Q,ne,q),Te=N.select("open"),me=K.current?.()??N.select("transitionStatus")==="ending",he=!Te&&me&&_.current,Le=!F&&xt(ne)&&xt(Q)&&We(Q,ne)&&he,Ve=L>0&&!D,Re=F&&(Te||he)||Le,ze=!Te||F;if(Re){Z()&&N.setOpen(!0,jt(dn,z,ne));return}Ve||(D?T.openChangeTimeout.start(D,()=>{ze&&Z()&&N.setOpen(!0,jt(dn,z,ne))}):ze&&Z()&&N.setOpen(!0,jt(dn,z,ne)))}function H(z){if(oe()){te();return}G();const L=N.select("domReferenceElement"),D=vt(L);T.restTimeout.clear(),T.restTimeoutPending=!1;const q=k.current.floatingContext??x?.();if(Dc(z.relatedTarget,N.context.triggerElements))return;if(w.current&&q){N.select("open")||T.openChangeTimeout.clear();const Q=b.current;T.handler=w.current({...q,tree:E,x:z.clientX,y:z.clientY,onClose(){te(),G(),U.current&&!oe()&&Q===N.select("domReferenceElement")&&X(z,!0)}}),D.addEventListener("mousemove",T.handler),T.handler(z);return}(T.pointerType!=="touch"||!We(N.select("floatingElement"),z.relatedTarget))&&X(z)}return g?ws(pt(C,"mousemove",B,{once:!0}),pt(C,"mouseenter",B),pt(C,"mouseleave",H)):ws(pt(C,"mouseenter",B),pt(C,"mouseleave",H))},[G,te,k,I,N,o,w,T,v,ee,oe,d,g,A,b,E,U,x,K,Z]),p.useMemo(()=>{if(!o)return;function X(C){T.pointerType=C.pointerType}return{onPointerDown:X,onPointerEnter:X,onMouseMove(C){const{nativeEvent:B}=C,H=C.currentTarget,z=N.select("domReferenceElement"),L=N.select("open"),D=ee(z,H,C.target);if(d&&!Yl(T.pointerType))return;if(L&&D&&T.handleCloseOptions?.blockPointerEvents){const Q=N.select("floatingElement");if(Q){const ne=T.handleCloseOptions?.getScope?.()??H.ownerDocument.body;h1(T,{scopeElement:ne,referenceElement:H,floatingElement:Q})}}const q=sy(A.current);if(L&&!D||q===0||!D&&T.restTimeoutPending&&C.movementX**2+C.movementY**2<2)return;T.restTimeout.clear();function V(){if(T.restTimeoutPending=!1,oe())return;const Q=N.select("open");!T.blockMouseMove&&(!Q||D)&&Z()&&N.setOpen(!0,jt(dn,B,H))}T.pointerType==="touch"?lr.flushSync(()=>{V()}):D&&L?V():(T.restTimeoutPending=!0,T.restTimeout.start(q,V))}}},[o,T,oe,ee,d,N,A,Z])}const MR="Escape";function iu(n,r,o){switch(n){case"vertical":return r;case"horizontal":return o;default:return r||o}}function pc(n,r){return iu(r,n===S0||n===Qm,n===eu||n===tu)}function Gf(n,r,o){return iu(r,n===Qm,o?n===eu:n===tu)||n==="Enter"||n===" "||n===""}function AR(n,r,o){return iu(r,o?n===eu:n===tu,n===Qm)}function DR(n,r,o,l){const c=o?n===tu:n===eu,d=n===S0;return r==="both"||r==="horizontal"&&l?n===MR:iu(r,c,d)}function zR(n,r){const{listRef:o,activeIndex:l,onNavigate:c=()=>{},enabled:d=!0,selectedIndex:m=null,allowEscape:g=!1,loopFocus:b=!1,nested:h=!1,rtl:v=!1,virtual:x=!1,focusItemOnOpen:S="auto",focusItemOnHover:j=!0,openOnArrowKeyDown:N=!0,disabledIndices:k=void 0,orientation:O="vertical",parentOrientation:E,id:T,resetOnPointerLeave:_=!0,externalTree:w,grid:I}=r,A=I!=null,U="rootStore"in n?n.rootStore:n,M=U.useState("open"),K=U.useState("floatingElement"),oe=U.useState("domReferenceElement"),Z=U.context.dataRef,ee=mm(K),G=fm(oe),te=on(ee),X=ur(),C=qr(w),B=p.useRef(S),H=p.useRef(m??-1),z=p.useRef(null),L=p.useRef(!0),D=nt(se=>{c(H.current===-1?null:H.current,se)}),q=p.useRef(!!K),V=p.useRef(M),Q=p.useRef(!1),ne=p.useRef(!1),F=p.useRef(null),Te=on(k),me=on(M),he=on(m),Le=on(_),Ve=Hl(),Re=Hl(),ze=nt(()=>{function se(we){x?C?.events.emit("virtualfocus",we):F.current=jc(we,{sync:Q.current,preventScroll:!0})}const Y=o.current[H.current],ge=ne.current;Y&&se(Y),(Q.current?we=>we():we=>Ve.request(we))(()=>{const we=o.current[H.current]||Y;if(!we)return;Y||se(we),ue&&(ge||!L.current)&&we.scrollIntoView?.({block:"nearest",inline:"nearest"})})});Ge(()=>{Z.current.orientation=O},[Z,O]),Ge(()=>{d&&(M&&K?(H.current=m??-1,B.current&&m!=null&&(ne.current=!0,D())):q.current&&(H.current=-1,D()))},[d,M,K,m,D]),Ge(()=>{if(d){if(!M){Q.current=!1;return}if(K)if(l==null){if(Q.current=!1,he.current!=null)return;if(q.current&&(H.current=-1,ze()),(!V.current||!q.current)&&B.current&&(z.current!=null||B.current===!0&&z.current==null)){let se=0;const Y=()=>{o.current[0]==null?(se<2&&(se?J=>Re.request(J):queueMicrotask)(Y),se+=1):(H.current=z.current==null||Gf(z.current,O,v)||h?zf(o):ly(o),z.current=null,D())};Y()}}else ay(o.current,l)||(H.current=l,ze(),ne.current=!1)}},[d,M,K,l,he,h,o,O,v,D,ze,Re]),Ge(()=>{if(!d||K||!C||x||!q.current)return;const se=C.nodesRef.current,Y=se.find(we=>we.id===X)?.context?.elements.floating,ge=jn(vt(oe??Y??null)),J=se.some(we=>we.context&&We(we.context.elements.floating,ge));Y&&!J&&L.current&&Y.focus({preventScroll:!0})},[d,K,oe,C,X,x]),Ge(()=>{V.current=M,q.current=!!K}),Ge(()=>{M||(z.current=null,B.current=S)},[M,S]);const De=l!=null,ye=nt(se=>{if(!me.current)return;const Y=o.current.indexOf(se.currentTarget);Y!==-1&&(H.current!==Y||l!==Y)&&(H.current=Y,D(se))}),Be=nt(()=>E??C?.nodesRef.current.find(se=>se.id===X)?.context?.dataRef?.current.orientation),ae=nt(()=>zf(o,Te.current)),de=nt(se=>{if(L.current=!1,Q.current=!0,se.which===229||!me.current&&se.currentTarget===te.current)return;if(h&&DR(se.key,O,v,A)){pc(se.key,Be())||Es(se),U.setOpen(!1,jt(cm,se.nativeEvent)),Bt(oe)&&(x?C?.events.emit("virtualfocus",oe):oe.focus());return}const Y=H.current,ge=zf(o,k),J=ly(o,k);if(G||(se.key==="Home"&&(Es(se),H.current=ge,D(se)),se.key==="End"&&(Es(se),H.current=J,D(se))),I!=null){const we=I(se,H.current,o,O,b,v,k,ge,J);if(we!=null&&(H.current=we,D(se)),O==="both")return}if(pc(se.key,O)){if(Es(se),M&&!x&&jn(se.currentTarget.ownerDocument)===se.currentTarget){H.current=Gf(se.key,O,v)?ge:J,D(se);return}Gf(se.key,O,v)?b?Y>=J?g&&Y!==o.current.length?H.current=-1:(Q.current=!1,H.current=ge):H.current=va(o.current,{startingIndex:Y,disabledIndices:k}):H.current=Math.min(J,va(o.current,{startingIndex:Y,disabledIndices:k})):b?Y<=ge?g&&Y!==-1?H.current=o.current.length:(Q.current=!1,H.current=J):H.current=va(o.current,{startingIndex:Y,decrement:!0,disabledIndices:k}):H.current=Math.max(ge,va(o.current,{startingIndex:Y,decrement:!0,disabledIndices:k})),ay(o.current,H.current)&&(H.current=-1),D(se)}}),ue=p.useMemo(()=>({onFocus(Y){Q.current=!0,ye(Y)},onClick:({currentTarget:Y})=>Y.focus({preventScroll:!0}),onMouseMove(Y){Q.current=!0,ne.current=!1,j&&ye(Y)},onPointerLeave(Y){if(!me.current||!L.current||Y.pointerType==="touch")return;Q.current=!0;const ge=Y.relatedTarget;if(!(!j||o.current.includes(ge))&&Le.current&&(F.current?.(),F.current=null,H.current=-1,D(Y),!x)){const J=te.current,we=jn(vt(J));J&&We(J,we)&&J.focus({preventScroll:!0})}}}),[ye,me,te,j,o,D,Le,x]),Ce=p.useMemo(()=>x&&M&&De&&{"aria-activedescendant":`${T}-${l}`},[x,M,De,T,l]),fe=p.useMemo(()=>({"aria-orientation":O==="both"?void 0:O,...G?{}:Ce,onKeyDown(se){if(se.key==="Tab"&&se.shiftKey&&M&&!x){const Y=Dn(se.nativeEvent);if(Y&&!We(te.current,Y))return;Es(se),U.setOpen(!1,jt(vo,se.nativeEvent)),Bt(oe)&&oe.focus();return}de(se)},onPointerMove(){L.current=!0}}),[Ce,de,te,O,G,U,M,x,oe]),be=p.useMemo(()=>{function se(J){U.setOpen(!0,jt(cm,J.nativeEvent,J.currentTarget))}function Y(J){S==="auto"&&b0(J.nativeEvent)&&(B.current=!x)}function ge(J){B.current=S,S==="auto"&&y0(J.nativeEvent)&&(B.current=!0)}return{onKeyDown(J){const we=U.select("open");L.current=!1;const Xe=J.key.startsWith("Arrow"),je=AR(J.key,Be(),v),Me=pc(J.key,O),$e=(h?je:Me)||J.key==="Enter"||J.key.trim()==="";if(x&&we)return de(J);if(!(!we&&!N&&Xe)){if($e){const rt=pc(J.key,Be());z.current=h&&rt?null:J.key}if(h){je&&(Es(J),we?(H.current=ae(),D(J)):se(J));return}Me&&(he.current!=null&&(H.current=he.current),Es(J),!we&&N?se(J):de(J),we&&D(J))}},onFocus(J){U.select("open")&&!x&&(H.current=-1,D(J))},onPointerDown:ge,onPointerEnter:ge,onMouseDown:Y,onClick:Y}},[de,S,ae,h,D,U,N,O,Be,v,he,x]),qe=p.useMemo(()=>({...Ce,...be}),[Ce,be]);return p.useMemo(()=>d?{reference:qe,floating:fe,item:ue,trigger:be}:{},[d,qe,fe,be,ue])}function LR(n,r){const{listRef:o,elementsRef:l,activeIndex:c,onMatch:d,disabledIndices:m,onTyping:g,enabled:b=!0,resetMs:h=750,selectedIndex:v=null}=r,x="rootStore"in n?n.rootStore:n,S=x.useState("open"),j=Gn(),N=p.useRef(""),k=p.useRef(v??c??-1),O=p.useRef(null),E=nt(w=>{function I(te){const X=l?.current[te];return!X||su(X)}function A(te){return I(te)?m==null||!T0(Ac,te,m):!1}function U(te,X,C=0){if(te.length===0)return-1;const B=(C%te.length+te.length)%te.length,H=X.toLowerCase();for(let z=0;z<te.length;z+=1){const L=(B+z)%te.length;if(!(!te[L]?.toLowerCase().startsWith(H)||!A(L)))return L}return-1}const M=o.current;if(N.current.length>0&&w.key===" "&&(Es(w),g?.(!0)),N.current.length>0&&N.current[0]!==" "&&U(M,N.current)===-1&&w.key!==" "&&g?.(!1),M==null||w.key.length!==1||w.ctrlKey||w.metaKey||w.altKey)return;S&&w.key!==" "&&(Es(w),g?.(!0));const K=N.current==="";K&&(k.current=v??c??-1),M.every((te,X)=>te&&A(X)?te[0]?.toLowerCase()!==te[1]?.toLowerCase():!0)&&N.current===w.key&&(N.current="",k.current=O.current),N.current+=w.key,j.start(h,()=>{N.current="",k.current=O.current,g?.(!1)});const ee=((K?v??c??-1:k.current)??0)+1,G=U(M,N.current,ee);G!==-1?(d?.(G),O.current=G):w.key!==" "&&(N.current="",g?.(!1))}),T=nt(w=>{const I=w.relatedTarget,A=x.select("domReferenceElement"),U=x.select("floatingElement");We(A,I)||We(U,I)||(j.clear(),N.current="",k.current=O.current,g?.(!1))});Ge(()=>{!S&&v!==null||(j.clear(),O.current=null,N.current!==""&&(N.current=""))},[S,v,j]),Ge(()=>{S&&N.current===""&&(k.current=v??c??-1)},[S,v,c]);const _=p.useMemo(()=>({onKeyDown:E,onBlur:T}),[E,T]);return p.useMemo(()=>b?{reference:_,floating:_}:{},[b,_])}const _y=.1,IR=_y*_y,Lt=.5;function hc(n,r,o,l,c,d){return l>=r!=d>=r&&n<=(c-o)*(r-l)/(d-l)+o}function gc(n,r,o,l,c,d,m,g,b,h){let v=!1;return hc(n,r,o,l,c,d)&&(v=!v),hc(n,r,c,d,m,g)&&(v=!v),hc(n,r,m,g,b,h)&&(v=!v),hc(n,r,b,h,o,l)&&(v=!v),v}function BR(n,r,o){return n>=o.x&&n<=o.x+o.width&&r>=o.y&&r<=o.y+o.height}function xc(n,r,o,l,c,d){const m=Math.min(o,c),g=Math.max(o,c),b=Math.min(l,d),h=Math.max(l,d);return n>=m&&n<=g&&r>=b&&r<=h}function y1(n={}){const{blockPointerEvents:r=!1}=n,o=new fs,l=({x:c,y:d,placement:m,elements:g,onClose:b,nodeId:h,tree:v})=>{const x=m?.split("-")[0];let S=!1,j=null,N=null,k=typeof performance<"u"?performance.now():0;function O(T,_){const w=performance.now(),I=w-k;if(j===null||N===null||I===0)return j=T,N=_,k=w,!1;const A=T-j,U=_-N,M=A*A+U*U,K=I*I*IR;return j=T,N=_,k=w,M<K}function E(){o.clear(),b()}return function(_){o.clear();const w=g.domReference,I=g.floating;if(!w||!I||x==null||c==null||d==null)return;const{clientX:A,clientY:U}=_,M=Dn(_),K=_.type==="mouseleave",oe=We(I,M),Z=We(w,M);if(oe&&(S=!0,!K))return;if(Z&&(S=!1,!K)){S=!0;return}if(K&&xt(_.relatedTarget)&&We(I,_.relatedTarget))return;function ee(){return!!(v&&Yr(v.nodesRef.current,h).length>0)}function G(){ee()||E()}if(ee())return;const te=w.getBoundingClientRect(),X=I.getBoundingClientRect(),C=c>X.right-X.width/2,B=d>X.bottom-X.height/2,H=X.width>te.width,z=X.height>te.height,L=(H?te:X).left,D=(H?te:X).right,q=(z?te:X).top,V=(z?te:X).bottom;if(x==="top"&&d>=te.bottom-1||x==="bottom"&&d<=te.top+1||x==="left"&&c>=te.right-1||x==="right"&&c<=te.left+1){G();return}let Q=!1;switch(x){case"top":Q=xc(A,U,L,te.top+1,D,X.bottom-1);break;case"bottom":Q=xc(A,U,L,X.top+1,D,te.bottom-1);break;case"left":Q=xc(A,U,X.right-1,V,te.left+1,q);break;case"right":Q=xc(A,U,te.right-1,V,X.left+1,q);break}if(Q)return;if(S&&!BR(A,U,te)){G();return}if(!K&&O(A,U)){G();return}let ne=!1;switch(x){case"top":{const F=H?Lt/2:Lt*4,Te=H||C?c+F:c-F,me=H?c-F:C?c+F:c-F,he=d+Lt+1,Le=C||H?X.bottom-Lt:X.top,Ve=C?H?X.bottom-Lt:X.top:X.bottom-Lt;ne=gc(A,U,Te,he,me,he,X.left,Le,X.right,Ve);break}case"bottom":{const F=H?Lt/2:Lt*4,Te=H||C?c+F:c-F,me=H?c-F:C?c+F:c-F,he=d-Lt,Le=C||H?X.top+Lt:X.bottom,Ve=C?H?X.top+Lt:X.bottom:X.top+Lt;ne=gc(A,U,Te,he,me,he,X.left,Le,X.right,Ve);break}case"left":{const F=z?Lt/2:Lt*4,Te=z||B?d+F:d-F,me=z?d-F:B?d+F:d-F,he=c+Lt+1,Le=B||z?X.right-Lt:X.left,Ve=B?z?X.right-Lt:X.left:X.right-Lt;ne=gc(A,U,Le,X.top,Ve,X.bottom,he,Te,he,me);break}case"right":{const F=z?Lt/2:Lt*4,Te=z||B?d+F:d-F,me=z?d-F:B?d+F:d-F,he=c-Lt,Le=B||z?X.left+Lt:X.right,Ve=B?z?X.left+Lt:X.right:X.left+Lt;ne=gc(A,U,he,Te,he,me,Le,X.top,Ve,X.bottom);break}}ne?S||o.start(40,G):G()}};return l.__options={...n,blockPointerEvents:r},l}const UR=p.createContext(void 0);function v1(n){return p.useContext(UR)}const HR="ArrowUp",YR="ArrowDown",PR="ArrowLeft",VR="ArrowRight",qR="Home",FR="End",GR=new Set([PR,VR]),XR=new Set([HR,YR]),$R=new Set([...GR,...XR]),xp=new Set([...$R,qR,FR]);function bp(n){return n==="starting"?mC:Ut}const KR={...Fl,...$c},QR=p.forwardRef(function(r,o){const{render:l,className:c,style:d,finalFocus:m,...g}=r,{store:b}=To(),{side:h,align:v}=u0(),x=v1()!=null,S=b.useState("open"),j=b.useState("transitionStatus"),N=b.useState("popupProps"),k=b.useState("mounted"),O=b.useState("instantType"),E=b.useState("activeTriggerElement"),T=b.useState("parent"),_=b.useState("lastOpenChangeReason"),w=b.useState("rootId"),I=b.useState("floatingRootContext"),A=b.useState("floatingTreeRoot"),U=b.useState("closeDelay"),M=b.useState("activeTriggerElement"),K=b.useState("hoverEnabled"),oe=b.useState("disabled"),Z=b.useState("openMethod"),ee=T.type==="context-menu";Wc({open:S,ref:b.context.popupRef,onComplete(){S&&b.context.onOpenChangeComplete?.(!0)}}),p.useEffect(()=>{function B(H){b.setOpen(!1,jt(H.reason,H.domEvent))}return A.events.on("close",B),()=>{A.events.off("close",B)}},[A.events,b]),x1(I,{enabled:K&&!oe&&!ee&&T.type!=="menubar",closeDelay:U});const G=p.useCallback(B=>{b.set("popupElement",B)},[b]),te={transitionStatus:j,side:h,align:v,open:S,nested:T.type==="menu",instant:O},X=fn("div",r,{state:te,ref:[o,b.context.popupRef,G],stateAttributesMapping:KR,props:[N,{onKeyDown(B){x&&xp.has(B.key)&&B.stopPropagation()}},bp(j),g,{"data-rootownerid":w}]});let C=T.type===void 0||ee;return(E||T.type==="menubar"&&_!==qm)&&(C=!0),i.jsx(ap,{context:I,openInteractionType:Z,modal:ee,disabled:!k,returnFocus:m===void 0?C:m,initialFocus:T.type!=="menu",restoreFocus:!0,externalTree:T.type!=="menubar"?A:void 0,previousFocusableElement:M,nextFocusableElement:T.type===void 0?b.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:T.type===void 0?b.context.beforeContentFocusGuardRef:void 0,children:X})}),S1=p.createContext(void 0);function ZR(){const n=p.useContext(S1);if(n===void 0)throw new Error(En(32));return n}const JR=p.forwardRef(function(r,o){const{keepMounted:l=!1,...c}=r,{store:d}=To();return d.useState("mounted")||l?i.jsx(S1.Provider,{value:l,children:i.jsx(np,{ref:o,...c})}):null});function yp(n){return Vm(19)?n:n?"true":void 0}const WR=p.createContext(void 0);function E1(){return p.useContext(WR)?.direction??"ltr"}const eO=n=>({name:"arrow",options:n,async fn(r){const{x:o,y:l,placement:c,rects:d,platform:m,elements:g,middlewareData:b}=r,{element:h,padding:v=0,offsetParent:x="real"}=ir(n,r)||{};if(h==null)return{};const S=j0(v),j={x:o,y:l},N=Wm(c),k=Jm(N),O=await m.getDimensions(h),E=N==="y",T=E?"top":"left",_=E?"bottom":"right",w=E?"clientHeight":"clientWidth",I=d.reference[k]+d.reference[N]-j[N]-d.floating[k],A=j[N]-d.reference[N],U=x==="real"?await m.getOffsetParent?.(h):g.floating;let M=g.floating[w]||d.floating[k];(!M||!await m.isElement?.(U))&&(M=g.floating[w]||d.floating[k]);const K=I/2-A/2,oe=M/2-O[k]/2-1,Z=Math.min(S[T],oe),ee=Math.min(S[_],oe),G=Z,te=M-O[k]-ee,X=M/2-O[k]/2+K,C=N0(G,X,te),B=!b.arrow&&Vr(c)!=null&&X!==C&&d.reference[k]/2-(X<G?Z:ee)-O[k]/2<0,H=B?X<G?X-G:X-te:0;return{[N]:j[N]+H,data:{[N]:C,centerOffset:X-C-H,...B&&{alignmentOffset:H}},reset:B}}}),tO=(n,r)=>({...eO(n),options:[n,r]}),nO=cR().fn,sO={name:"hide",async fn(n){const{width:r,height:o,x:l,y:c}=n.rects.reference,d=r===0&&o===0&&l===0&&c===0;return{data:{referenceHidden:(await nO(n)).data?.referenceHidden||d}}}},wc={sideX:"left",sideY:"top"},N1={name:"adaptiveOrigin",async fn(n){const{x:r,y:o,rects:{floating:l},elements:{floating:c},platform:d,strategy:m,placement:g}=n,b=Xt(c),h=b.getComputedStyle(c);if(!(h.transitionDuration!=="0s"&&h.transitionDuration!==""))return{x:r,y:o,data:wc};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=vt(c);S={width:T.documentElement.clientWidth,height:T.documentElement.clientHeight}}else await d.isElement?.(x)&&(S=await d.getDimensions(x));const j=qn(g);let N=r,k=o;j==="left"&&(N=S.width-(r+l.width)),j==="top"&&(k=S.height-(o+l.height));const O=j==="left"?"right":wc.sideX,E=j==="top"?"bottom":wc.sideY;return{x:N,y:k,data:{sideX:O,sideY:E}}}};function j1(n,r,o){const l=n==="inline-start"||n==="inline-end";return{top:"top",right:l?o?"inline-start":"inline-end":"right",bottom:"bottom",left:l?o?"inline-end":"inline-start":"left"}[r]}function My(n,r,o){const{rects:l,placement:c}=n;return{side:j1(r,qn(c),o),align:Vr(c)||"center",anchor:{width:l.reference.width,height:l.reference.height},positioner:{width:l.floating.width,height:l.floating.height}}}function T1(n){const{anchor:r,positionMethod:o="absolute",side:l="bottom",sideOffset:c=0,align:d="center",alignOffset:m=0,collisionBoundary:g,collisionPadding:b=5,sticky:h=!1,arrowPadding:v=5,disableAnchorTracking:x=!1,inline:S,keepMounted:j=!1,floatingRootContext:N,mounted:k,collisionAvoidance:O,shiftCrossAxis:E=!1,nodeId:T,adaptiveOrigin:_,lazyFlip:w=!1,externalTree:I}=n,[A,U]=p.useState(null);!k&&A!==null&&U(null);const M=O.side||"flip",K=O.align||"flip",oe=O.fallbackAxisSide||"end",Z=typeof r=="function"?r:void 0,ee=nt(Z),G=Z?ee:r,te=on(r),X=on(k),B=E1()==="rtl",H=A||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":B?"left":"right","inline-start":B?"right":"left"}[l],z=d==="center"?H:`${H}-${d}`;let L=b;const D=1,q=l==="bottom"?D:0,V=l==="top"?D:0,Q=l==="right"?D:0,ne=l==="left"?D:0;typeof L=="number"?L={top:L+q,right:L+ne,bottom:L+V,left:L+Q}:L&&(L={top:(L.top||0)+q,right:(L.right||0)+ne,bottom:(L.bottom||0)+V,left:(L.left||0)+Q});const F={boundary:g==="clipping-ancestors"?"clippingAncestors":g,padding:L},Te=p.useRef(null),me=on(c),he=on(m),Le=typeof c!="function"?c:0,Ve=typeof m!="function"?m:0,Re=[];S&&Re.push(S),Re.push(rR(Ke=>{const Tt=My(Ke,l,B),tn=typeof me.current=="function"?me.current(Tt):me.current,qt=typeof he.current=="function"?he.current(Tt):he.current;return{mainAxis:tn,crossAxis:qt,alignmentAxis:qt}},[Le,Ve,B,l]));const ze=K==="none"&&M!=="shift",De=!ze&&(h||E||M==="shift"),ye=M==="none"?null:lR({...F,padding:{top:L.top+D,right:L.right+D,bottom:L.bottom+D,left:L.left+D},mainAxis:!E&&M==="flip",crossAxis:K==="flip"?"alignment":!1,fallbackAxisSideDirection:oe}),Be=ze?null:oR(Ke=>{const Tt=vt(Ke.elements.floating).documentElement;return{...F,rootBoundary:E?{x:0,y:0,width:Tt.clientWidth,height:Tt.clientHeight}:void 0,mainAxis:K!=="none",crossAxis:De,limiter:h||E?void 0:aR(tn=>{if(!Te.current)return{};const{width:qt,height:re}=Te.current.getBoundingClientRect(),ve=as(qn(tn.placement)),Oe=ve==="y"?qt:re,Qe=ve==="y"?L.left+L.right:L.top+L.bottom;return{offset:Oe/2+Qe/2}})}},[F,h,E,L,K]);M==="shift"||K==="shift"||d==="center"?Re.push(Be,ye):Re.push(ye,Be),Re.push(iR({...F,apply({elements:{floating:Ke},availableWidth:Tt,availableHeight:tn,rects:qt}){if(!X.current)return;const re=Ke.style;re.setProperty("--available-width",`${Tt}px`),re.setProperty("--available-height",`${tn}px`);const ve=Xt(Ke).devicePixelRatio||1,{x:Oe,y:Qe,width:tt,height:at}=qt.reference,st=(Math.round((Oe+tt)*ve)-Math.round(Oe*ve))/ve,Pt=(Math.round((Qe+at)*ve)-Math.round(Qe*ve))/ve;re.setProperty("--anchor-width",`${st}px`),re.setProperty("--anchor-height",`${Pt}px`)}}),tO(Ke=>({element:Te.current||vt(Ke.elements.floating).createElement("div"),padding:v,offsetParent:"floating"}),[v]),{name:"transformOrigin",fn(Ke){const{elements:Tt,middlewareData:tn,placement:qt,rects:re,y:ve}=Ke,Oe=qn(qt),Qe=as(Oe),tt=Te.current,at=tn.arrow?.x||0,st=tn.arrow?.y||0,Pt=tt?.clientWidth||0,Xn=tt?.clientHeight||0,$t=at+Pt/2,mn=st+Xn/2,dr=Math.abs(tn.shift?.y||0),Ln=re.reference.height/2,Rs=typeof c=="function"?c(My(Ke,l,B)):c,Kl=dr>Rs,ps={top:`${$t}px calc(100% + ${Rs}px)`,bottom:`${$t}px ${-Rs}px`,left:`calc(100% + ${Rs}px) ${mn}px`,right:`${-Rs}px ${mn}px`}[Oe],nn=`${$t}px ${re.reference.y+Ln-ve}px`;return Tt.floating.style.setProperty("--transform-origin",De&&Qe==="y"&&Kl?nn:ps),{}}},sO,_),Ge(()=>{!k&&N&&N.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[k,N]);const ae=p.useMemo(()=>({elementResize:!x&&typeof ResizeObserver<"u",layoutShift:!x&&typeof IntersectionObserver<"u"}),[x]),{refs:de,elements:ue,x:Ce,y:fe,middlewareData:be,update:qe,placement:se,context:Y,isPositioned:ge,floatingStyles:J}=OR({rootContext:N,open:j?k:void 0,placement:z,middleware:Re,strategy:o,whileElementsMounted:j?void 0:(...Ke)=>jy(...Ke,ae),nodeId:T,externalTree:I}),{sideX:we,sideY:Xe}=be.adaptiveOrigin||wc,je=ge?o:"fixed",Me=p.useMemo(()=>{const Ke=_?{position:je,[we]:Ce,[Xe]:fe}:{position:je,...J};return ge||(Ke.opacity=0),Ke},[_,je,we,Ce,Xe,fe,J,ge]),$e=p.useRef(null);Ge(()=>{if(!k)return;const Ke=te.current,Tt=typeof Ke=="function"?Ke():Ke,qt=(Ay(Tt)?Tt.current:Tt)||null||null;qt!==$e.current&&(de.setPositionReference(qt),$e.current=qt)},[k,de,G,te]),p.useEffect(()=>{if(!k)return;const Ke=te.current;typeof Ke!="function"&&Ay(Ke)&&Ke.current!==$e.current&&(de.setPositionReference(Ke.current),$e.current=Ke.current)},[k,de,G,te]),p.useEffect(()=>{if(j&&k&&ue.reference&&ue.floating)return jy(ue.reference,ue.floating,qe,ae)},[j,k,ue,qe,ae]);const rt=qn(se),Nt=j1(l,rt,B),kt=Vr(se)||"center",bt=!!be.hide?.referenceHidden;Ge(()=>{w&&k&&ge&&U(rt)},[w,k,ge,rt]);const yn=p.useMemo(()=>({position:"absolute",top:be.arrow?.y,left:be.arrow?.x}),[be.arrow]),an=be.arrow?.centerOffset!==0;return p.useMemo(()=>({positionerStyles:Me,arrowStyles:yn,arrowRef:Te,arrowUncentered:an,side:Nt,align:kt,physicalSide:rt,anchorHidden:bt,refs:de,context:Y,isPositioned:ge,update:qe}),[Me,yn,Te,an,Nt,kt,rt,bt,de,Y,ge,qe])}function Ay(n){return n!=null&&"current"in n}function rO(n){const{children:r,elementsRef:o,labelsRef:l,onMapChange:c}=n,d=nt(c),m=p.useRef(0),g=zn(aO).current,b=zn(oO).current,[h,v]=p.useState(0),x=p.useRef(h),S=nt((E,T)=>{b.set(E,T??null),x.current+=1,v(x.current)}),j=nt(E=>{b.delete(E),x.current+=1,v(x.current)}),N=p.useMemo(()=>{const E=new Map;return Array.from(b.keys()).filter(_=>_.isConnected).sort(lO).forEach((_,w)=>{const I=b.get(_)??{};E.set(_,{...I,index:w})}),E},[b,h]);Ge(()=>{if(typeof MutationObserver!="function"||N.size===0)return;const E=new MutationObserver(T=>{const _=new Set,w=I=>_.has(I)?_.delete(I):_.add(I);T.forEach(I=>{I.removedNodes.forEach(w),I.addedNodes.forEach(w)}),_.size===0&&(x.current+=1,v(x.current))});return N.forEach((T,_)=>{_.parentElement&&E.observe(_.parentElement,{childList:!0})}),()=>{E.disconnect()}},[N]),Ge(()=>{x.current===h&&(o.current.length!==N.size&&(o.current.length=N.size),l&&l.current.length!==N.size&&(l.current.length=N.size),m.current=N.size),d(N)},[d,N,o,l,h]),Ge(()=>()=>{o.current=[]},[o]),Ge(()=>()=>{l&&(l.current=[])},[l]);const k=nt(E=>(g.add(E),()=>{g.delete(E)}));Ge(()=>{g.forEach(E=>E(N))},[g,N]);const O=p.useMemo(()=>({register:S,unregister:j,subscribeMapChange:k,elementsRef:o,labelsRef:l,nextIndexRef:m}),[S,j,k,o,l,m]);return i.jsx(h0.Provider,{value:O,children:r})}function oO(){return new Map}function aO(){return new Set}function lO(n,r){const o=n.compareDocumentPosition(r);return o&Node.DOCUMENT_POSITION_FOLLOWING||o&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:o&Node.DOCUMENT_POSITION_PRECEDING||o&Node.DOCUMENT_POSITION_CONTAINS?1:0}const vp=p.forwardRef(function(r,o){const{cutout:l,...c}=r;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:o,role:"presentation","data-base-ui-inert":"",...c,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:d}})});function w1(n,r,{styles:o,transitionStatus:l,props:c,refs:d,hidden:m,inert:g=!1}){const b={...o};return g&&(b.pointerEvents="none"),fn("div",n,{state:r,ref:d,props:[{role:"presentation",hidden:m,style:b},bp(l),c],stateAttributesMapping:Fl})}let Dy={},zy={},Ly="";function iO(n){if(typeof document>"u")return!1;const r=vt(n);return Xt(r).innerWidth-r.documentElement.clientWidth>0}function cO(n){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const o=vt(n),l=o.documentElement,c=o.body,d=jo(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 h=d.offsetWidth;return d.style.overflowY=m,l.style.scrollbarGutter=g,b===h}function uO(n){const r=vt(n),o=r.documentElement,l=r.body,c=jo(o)?o: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 dO(n){const r=vt(n),o=r.documentElement,l=r.body,c=Xt(o);let d=0,m=0,g=!1;const b=Ns.create();if(wo&&(c.visualViewport?.scale??1)!==1)return()=>{};function h(){const j=c.getComputedStyle(o),N=c.getComputedStyle(l),E=(j.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";d=o.scrollTop,m=o.scrollLeft,Dy={scrollbarGutter:o.style.scrollbarGutter,overflowY:o.style.overflowY,overflowX:o.style.overflowX},Ly=o.style.scrollBehavior,zy={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=o.scrollHeight>o.clientHeight,_=o.scrollWidth>o.clientWidth,w=j.overflowY==="scroll"||N.overflowY==="scroll",I=j.overflowX==="scroll"||N.overflowX==="scroll",A=Math.max(0,c.innerWidth-l.clientWidth),U=Math.max(0,c.innerHeight-l.clientHeight),M=parseFloat(N.marginTop)+parseFloat(N.marginBottom),K=parseFloat(N.marginLeft)+parseFloat(N.marginRight),oe=jo(o)?o:l;if(g=cO(n),g){o.style.scrollbarGutter=E,oe.style.overflowY="hidden",oe.style.overflowX="hidden";return}Object.assign(o.style,{scrollbarGutter:E,overflowY:"hidden",overflowX:"hidden"}),(T||w)&&(o.style.overflowY="scroll"),(_||I)&&(o.style.overflowX="scroll"),Object.assign(l.style,{position:"relative",height:M||U?`calc(100dvh - ${M+U}px)`:"100dvh",width:K||A?`calc(100vw - ${K+A}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),l.scrollTop=d,l.scrollLeft=m,o.setAttribute("data-base-ui-scroll-locked",""),o.style.scrollBehavior="unset"}function v(){Object.assign(o.style,Dy),Object.assign(l.style,zy),g||(o.scrollTop=d,o.scrollLeft=m,o.removeAttribute("data-base-ui-scroll-locked"),o.style.scrollBehavior=Ly)}function x(){v(),b.request(h)}h();const S=pt(c,"resize",x);return()=>{b.cancel(),v(),typeof c.removeEventListener=="function"&&S()}}class fO{lockCount=0;restore=null;timeoutLock=fs.create();timeoutUnlock=fs.create();acquire(r){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(r)),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(r){if(this.lockCount===0||this.restore!==null)return;const l=vt(r).documentElement,c=Xt(l).getComputedStyle(l).overflowY;if(c==="hidden"||c==="clip"){this.restore=un;return}const d=Jc||!iO(r);this.restore=d?uO(r):dO(r)}}const mO=new fO;function C1(n=!0,r=null){Ge(()=>{if(n)return mO.acquire(r)},[n,r])}const pO=20;function R1(n,r,o,l){const[c,d]=p.useState(!1);Ge(()=>{if(!n||!r||o==null){d(!1);return}const m=vt(o).documentElement.clientWidth,g=o.offsetWidth;d(m>0&&g>0&&g>=m-pO)},[n,r,o]),C1(n&&(!r||c),l)}const hO=p.forwardRef(function(r,o){const{anchor:l,positionMethod:c="absolute",className:d,render:m,side:g,align:b,sideOffset:h=0,alignOffset:v=0,collisionBoundary:x="clipping-ancestors",collisionPadding:S=5,arrowPadding:j=5,sticky:N=!1,disableAnchorTracking:k=!1,collisionAvoidance:O=pC,style:E,...T}=r,{store:_}=To(),w=ZR(),I=Kc(!0),A=_.useState("parent"),U=_.useState("floatingRootContext"),M=_.useState("floatingTreeRoot"),K=_.useState("mounted"),oe=_.useState("open"),Z=_.useState("modal"),ee=_.useState("openMethod"),G=_.useState("activeTriggerElement"),te=_.useState("transitionStatus"),X=_.useState("positionerElement"),C=_.useState("instantType"),B=_.useState("hasViewport"),H=_.useState("lastOpenChangeReason"),z=_.useState("floatingNodeId"),L=_.useState("floatingParentNodeId"),D=U.useState("domReferenceElement"),q=p.useRef(null),V=Km(X,!1,!1);let Q=l,ne=h,F=v,Te=b,me=O;A.type==="context-menu"&&(Q=l??A.context?.anchor,Te=Te??"start",!g&&Te!=="center"&&(F=r.alignOffset??2,ne=r.sideOffset??-5));let he=g,Le=Te;A.type==="menu"?(he=he??"inline-end",Le=Le??"start",me=r.collisionAvoidance??U0):A.type==="menubar"&&(he=he??(A.context.orientation==="vertical"?"inline-end":"bottom"),Le=Le??"start");const Ve=A.type==="context-menu",Re=T1({anchor:Q,floatingRootContext:U,positionMethod:I?"fixed":c,mounted:K,side:he,sideOffset:ne,align:Le,alignOffset:F,arrowPadding:Ve?0:j,collisionBoundary:x,collisionPadding:S,sticky:N,nodeId:z,keepMounted:w,disableAnchorTracking:k,collisionAvoidance:me,shiftCrossAxis:Ve&&!("side"in me&&me.side==="flip"),externalTree:M,adaptiveOrigin:B?N1:void 0});p.useEffect(()=>{function Ce(fe){fe.open&&(fe.parentNodeId===z&&_.set("hoverEnabled",!1),fe.nodeId!==z&&fe.parentNodeId===_.select("floatingParentNodeId")&&_.setOpen(!1,jt(_l)))}return M.events.on("menuopenchange",Ce),()=>{M.events.off("menuopenchange",Ce)}},[_,M.events,z]),p.useEffect(()=>{if(_.select("floatingParentNodeId")==null)return;function Ce(fe){if(fe.open||fe.nodeId!==_.select("floatingParentNodeId"))return;const be=fe.reason??_l;_.setOpen(!1,jt(be))}return M.events.on("menuopenchange",Ce),()=>{M.events.off("menuopenchange",Ce)}},[M.events,_]);const ze=Gn();p.useEffect(()=>{oe||ze.clear()},[oe,ze]),p.useEffect(()=>{function Ce(fe){if(!(!oe||fe.nodeId!==_.select("floatingParentNodeId")))if(fe.target&&G&&G!==fe.target){const be=_.select("closeDelay");be>0?ze.isStarted()||ze.start(be,()=>{_.setOpen(!1,jt(_l))}):_.setOpen(!1,jt(_l))}else ze.clear()}return M.events.on("itemhover",Ce),()=>{M.events.off("itemhover",Ce)}},[M.events,oe,G,_,ze]),p.useEffect(()=>{const Ce={open:oe,nodeId:z,parentNodeId:L,reason:_.select("lastOpenChangeReason")};M.events.emit("menuopenchange",Ce)},[M.events,oe,_,z,L]),Ge(()=>{const Ce=D,fe=q.current;if(Ce&&(q.current=Ce),fe&&Ce&&Ce!==fe){_.set("instantType",void 0);const be=new AbortController;return V(()=>{_.set("instantType","trigger-change")},be.signal),()=>{be.abort()}}},[D,V,_]);const De={open:oe,side:Re.side,align:Re.align,anchorHidden:Re.anchorHidden,nested:A.type==="menu",instant:C},ye=A.type==="menubar"&&A.context.modal;R1(oe&&(ye||Z&&H!==dn),ee==="touch",X,G);const ae=w1(r,De,{styles:Re.positionerStyles,transitionStatus:te,props:T,refs:[o,_.useStateSetter("positionerElement")],hidden:!K,inert:!oe}),de=K&&A.type!=="menu"&&(A.type!=="menubar"&&Z&&H!==dn||A.type==="menubar"&&A.context.modal);let ue=null;return A.type==="menubar"?ue=A.context.contentElement:A.type===void 0&&(ue=G),i.jsxs(c0.Provider,{value:Re,children:[de&&i.jsx(vp,{ref:A.type==="context-menu"||A.type==="nested-context-menu"?A.context.internalBackdropRef:null,inert:yp(!oe),cutout:ue}),i.jsx(F0,{id:z,children:i.jsx(rO,{elementsRef:_.context.itemDomElements,labelsRef:_.context.itemLabels,children:ae})})]})}),gO=p.createContext(null);function O1(n){return p.useContext(gO)}function xO(n){const r=p.useRef(""),o=p.useCallback(c=>{c.defaultPrevented||(r.current=c.pointerType,n(c,c.pointerType))},[n]);return{onClick:p.useCallback(c=>{if(c.detail===0){n(c,"keyboard");return}"pointerType"in c?n(c,c.pointerType):n(c,r.current),r.current=""},[n]),onPointerDown:o}}function bO(n,r){const o=p.useRef(n),l=nt(r);Ge(()=>{o.current!==n&&l(o.current)},[n,l]),Ge(()=>{o.current=n},[n])}function k1(n,r){const o=nt((d,m)=>{(typeof n=="function"?n():n)||r(m||(Jc?"touch":""))}),{onClick:l,onPointerDown:c}=xO(o);return p.useMemo(()=>({onClick:l,onPointerDown:c}),[l,c])}function yO(n){const[r,o]=p.useState(null),l=k1(n,o);return bO(n,c=>{c&&!n&&o(null)}),p.useMemo(()=>({openMethod:r,triggerProps:l}),[r,l])}const vO={...hp,disabled:Ye(n=>n.parent.type==="menubar"&&n.parent.context.disabled||n.disabled),modal:Ye(n=>(n.parent.type===void 0||n.parent.type==="context-menu")&&(n.modal??!0)),openMethod:Ye(n=>n.openMethod),allowMouseEnter:Ye(n=>n.allowMouseEnter),highlightItemOnHover:Ye(n=>n.highlightItemOnHover),stickIfOpen:Ye(n=>n.stickIfOpen),parent:Ye(n=>n.parent),rootId:Ye(n=>n.parent.type==="menu"?n.parent.store.select("rootId"):n.parent.type!==void 0?n.parent.context.rootId:n.rootId),activeIndex:Ye(n=>n.activeIndex),isActive:Ye((n,r)=>n.activeIndex===r),hoverEnabled:Ye(n=>n.hoverEnabled),instantType:Ye(n=>n.instantType),lastOpenChangeReason:Ye(n=>n.openChangeReason),floatingTreeRoot:Ye(n=>n.parent.type==="menu"?n.parent.store.select("floatingTreeRoot"):n.floatingTreeRoot),floatingNodeId:Ye(n=>n.floatingNodeId),floatingParentNodeId:Ye(n=>n.floatingParentNodeId),itemProps:Ye(n=>n.itemProps),closeDelay:Ye(n=>n.closeDelay),hasViewport:Ye(n=>n.hasViewport),keyboardEventRelay:Ye(n=>{if(n.keyboardEventRelay)return n.keyboardEventRelay;if(n.parent.type==="menu")return n.parent.store.select("keyboardEventRelay")})};class Sp extends ou{constructor(r){super({...SO(),...r},{positionerRef:p.createRef(),popupRef:p.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:p.createRef(),beforeContentFocusGuardRef:p.createRef(),onOpenChangeComplete:void 0,triggerElements:new Xl},vO),this.unsubscribeParentListener=this.observe("parent",o=>{if(this.unsubscribeParentListener?.(),o.type==="menu"){let l=o.store.select("rootId"),c=o.store.select("floatingTreeRoot"),d=o.store.select("keyboardEventRelay");this.unsubscribeParentListener=o.store.subscribe(()=>{const m=o.store.select("rootId"),g=o.store.select("floatingTreeRoot"),b=o.store.select("keyboardEventRelay");l===m&&c===g&&d===b||(l=m,c=g,d=b,this.notifyAll())}),this.context.allowMouseUpTriggerRef=o.store.context.allowMouseUpTriggerRef;return}o.type!==void 0&&(this.context.allowMouseUpTriggerRef=o.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(r,o){this.state.floatingRootContext.context.events.emit("setOpen",{open:r,eventDetails:o})}static useStore(r,o){const l=zn(()=>new Sp(o)).current;return r??l}unsubscribeParentListener=null}function SO(){return{...mp(),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:Ut,keyboardEventRelay:void 0,closeDelay:0,hasViewport:!1}}const EO=p.createContext(void 0);function NO(){return p.useContext(EO)}const jO=r1(function(r){const{children:o,open:l,onOpenChange:c,onOpenChangeComplete:d,defaultOpen:m=!1,disabled:g=!1,modal:b,loopFocus:h=!0,orientation:v="vertical",actionsRef:x,closeParentOnEsc:S=!1,handle:j,triggerId:N,defaultTriggerId:k=null,highlightItemOnHover:O=!0}=r,E=Kc(!0),T=To(!0),_=O1(!0),w=NO(),I=p.useMemo(()=>w&&T?{type:"menu",store:T.store}:_?{type:"menubar",context:_}:E&&!T?{type:"context-menu",context:E}:{type:void 0},[E,T,_,w]),A=Sp.useStore(j?.store,{open:m,openProp:l,activeTriggerId:k,triggerIdProp:N,parent:I});u1(A,l,m,k),A.useControlledProp("openProp",l),A.useControlledProp("triggerIdProp",N),A.useContextCallback("onOpenChangeComplete",d);const U=So(),M=So(),K=A.useState("floatingTreeRoot"),oe=rp(K),Z=ur(),ee=A.useState("open"),G=A.useState("activeTriggerElement"),te=A.useState("positionerElement"),X=A.useState("hoverEnabled"),C=A.useState("disabled"),B=A.useState("lastOpenChangeReason"),H=A.useState("parent"),z=A.useState("activeIndex"),L=A.useState("payload"),D=A.useState("floatingParentNodeId"),q=p.useRef(null),V=p.useRef(H.type!=="context-menu"),Q=Gn(),ne=p.useRef(!0),F=Gn(),Te=D!=null,{openMethod:me,triggerProps:he}=yO(ee);A.useSyncedValues({disabled:g,highlightItemOnHover:O,modal:H.type===void 0?b:void 0,openMethod:me,rootId:U}),up(A);const{forceUnmount:Le}=dp(ee,A,()=>{A.update({allowMouseEnter:!1,stickIfOpen:!0})});Ge(()=>{E&&!T?A.update({parent:{type:"context-menu",context:E},floatingNodeId:oe,floatingParentNodeId:Z}):T&&A.update({floatingNodeId:oe,floatingParentNodeId:Z})},[E,T,oe,Z,A]),p.useEffect(()=>{if(ee||(q.current=null),H.type==="context-menu"){if(!ee){Q.clear(),V.current=!1;return}Q.start(500,()=>{V.current=!0})}},[Q,ee,H.type]),Ge(()=>{!ee&&!X&&A.set("hoverEnabled",!0)},[ee,X,A]);const Ve=nt((we,Xe)=>{const je=Xe.reason;if(ee===we&&Xe.trigger===G&&B===je)return;const Me=c1(Xe);if(!we&&Xe.trigger==null&&(Xe.trigger=G??void 0),c?.(we,Xe),Xe.isCanceled)return;A.state.floatingRootContext.dispatchOpenChange(we,Xe);const $e=Xe.event;if(we===!1&&$e?.type==="click"&&$e.pointerType==="touch"&&!ne.current)return;we&&je===Al?(ne.current=!1,F.start(300,()=>{ne.current=!0})):(ne.current=!0,F.clear());const rt=(je===yo||je===m0)&&$e.detail===0&&$e?.isTrusted,Nt=!we&&(je===Qc||je==null),kt={open:we,openChangeReason:je};q.current=Xe.event??null,cp(kt,we,Xe.trigger,Me()),A.update(kt),H.type==="menubar"&&(je===Al||je===vo||je===dn||je===cm||je===_l)?A.set("instantType","group"):rt||Nt?A.set("instantType",rt?"click":"dismiss"):A.set("instantType",void 0)}),Re=a1({popupStore:A,floatingId:M,nested:Z!=null,onOpenChange:Ve}),ze=Re.context.events;p.useEffect(()=>{const we=({open:Xe,eventDetails:je})=>Ve(Xe,je);return ze.on("setOpen",we),()=>{ze?.off("setOpen",we)}},[ze,Ve]);const De=p.useCallback(()=>{A.setOpen(!1,jt(Fm))},[A]);p.useImperativeHandle(x,()=>({unmount:Le,close:De}),[Le,De]);let ye;H.type==="context-menu"&&(ye=H.context),p.useImperativeHandle(ye?.positionerRef,()=>te,[te]),p.useImperativeHandle(ye?.actionsRef,()=>({setOpen:Ve}),[Ve]);const Be=lp(Re,{enabled:!C,bubbles:{escapeKey:S&&H.type==="menu"},outsidePress(){return H.type!=="context-menu"||q.current?.type==="contextmenu"?!0:V.current},externalTree:Te?K:void 0}),ae=E1(),de=p.useCallback(we=>{A.select("activeIndex")!==we&&A.set("activeIndex",we)},[A]),ue=zR(Re,{enabled:!C,listRef:A.context.itemDomElements,activeIndex:z,nested:H.type!==void 0,loopFocus:h,orientation:v,parentOrientation:H.type==="menubar"?H.context.orientation:void 0,rtl:ae==="rtl",disabledIndices:Ac,onNavigate:de,openOnArrowKeyDown:H.type!=="context-menu",externalTree:Te?K:void 0,focusItemOnHover:O}),Ce=p.useCallback(we=>{A.context.typingRef.current=we},[A]),fe=LR(Re,{enabled:!C,listRef:A.context.itemLabels,elementsRef:A.context.itemDomElements,activeIndex:z,resetMs:fC,onMatch:we=>{ee&&we!==z&&A.set("activeIndex",we)},onTyping:Ce}),be=p.useMemo(()=>{const we=tr(fe.reference,ue.reference,Be.reference,{onMouseMove(){A.set("allowMouseEnter",!0)}},he);return we["aria-haspopup"]="menu",we["aria-expanded"]=ee,we},[A,fe.reference,ue.reference,Be.reference,he,ee]),qe=p.useMemo(()=>{const we=tr(ue.trigger,Be.trigger,he);return we["aria-haspopup"]="menu",we["aria-expanded"]=!1,we},[ue.trigger,Be.trigger,he]),se=p.useMemo(()=>tr(lu,{id:M,role:"menu","aria-labelledby":G?.id,onMouseMove(){A.set("allowMouseEnter",!0),H.type==="menu"&&A.set("hoverEnabled",!1)},onClick(){A.select("hoverEnabled")&&A.set("hoverEnabled",!1)},onKeyDown(we){const Xe=A.select("keyboardEventRelay");Xe&&!we.isPropagationStopped()&&Xe(we)}},fe.floating,ue.floating,Be.floating),[G,M,H.type,A,fe.floating,ue.floating,Be.floating]),Y=ue.item??Ut;fp(A,{floatingRootContext:Re,activeTriggerProps:be,inactiveTriggerProps:qe,popupProps:se,itemProps:Y});const ge=p.useMemo(()=>({store:A,parent:I}),[A,I]),J=i.jsx(d0.Provider,{value:ge,children:typeof o=="function"?o({payload:L}):o});return H.type===void 0||H.type==="context-menu"?i.jsx(G0,{externalTree:K,children:J}):J});function TO(n){const r=n.getBoundingClientRect(),o=Xt(n);if(Xm)return r;const l=o.getComputedStyle(n,"::before"),c=o.getComputedStyle(n,"::after");if(!(l.content!=="none"||c.content!=="none"))return r;const m=parseFloat(l.width)||0,g=parseFloat(l.height)||0,b=parseFloat(c.width)||0,h=parseFloat(c.height)||0,v=Math.max(r.width,m,b),x=Math.max(r.height,g,h),S=v-r.width,j=x-r.height;return{left:r.left-S/2,right:r.right+S/2,top:r.top-j/2,bottom:r.bottom+j/2}}function wO(n={}){const{highlightItemOnHover:r,highlightedIndex:o,onHighlightedIndexChange:l}=Pm(),{ref:c,index:d}=g0(n),m=o===d,g=p.useRef(null),b=wa(c,g);return{compositeProps:{tabIndex:m?0:-1,onFocus(){l(d)},onMouseMove(){const v=g.current;if(!r||!v)return;const x=v.hasAttribute("disabled")||v.ariaDisabled==="true";!m&&!x&&v.focus()}},compositeRef:b,index:d}}function CO(n){const{render:r,className:o,style:l,state:c=Ut,props:d=Ac,refs:m=Ac,metadata:g,stateAttributesMapping:b,tag:h="div",...v}=n,{compositeProps:x,compositeRef:S}=wO({metadata:g});return fn(h,n,{state:c,ref:[...m,S],props:[x,...d,v],stateAttributesMapping:b})}function _1(n){if(Bt(n)&&n.hasAttribute("data-rootownerid"))return n.getAttribute("data-rootownerid")??void 0;if(!er(n))return _1(ar(n))}function M1(n,r){const o=p.useRef(null);function l(d){lr.flushSync(()=>{n.setOpen(!1,jt(vo,d.nativeEvent,d.currentTarget))}),iC(o.current)?.focus()}function c(d){const m=n.select("positionerElement");if(m&&Sa(d,m))n.context.beforeContentFocusGuardRef.current?.focus();else{lr.flushSync(()=>{n.setOpen(!1,jt(vo,d.nativeEvent,d.currentTarget))});let g=lC(n.context.triggerFocusTargetRef.current||r.current);for(;g!==null&&We(m,g);){const b=g;if(g=tp(g),g===b)break}g?.focus()}}return{preFocusGuardRef:o,handlePreFocusGuardFocus:l,handleFocusTargetFocus:c}}function RO(n){const{enabled:r=!0,mouseDownAction:o,open:l}=n,c=p.useRef(!1);return p.useMemo(()=>r?{onMouseDown:d=>{(o==="open"&&!l||o==="close"&&l)&&(c.current=!0,vt(d.currentTarget).addEventListener("click",()=>{c.current=!1},{once:!0}))},onClick:d=>{c.current&&(c.current=!1,d.preventBaseUIHandler())}}:Ut,[r,o,l])}const bc=2,OO=gR(function(r,o){const{render:l,className:c,style:d,disabled:m=!1,nativeButton:g=!0,id:b,openOnHover:h,delay:v=100,closeDelay:x=0,handle:S,payload:j,...N}=r,k=To(!0),O=S?.store??k?.store;if(!O)throw new Error(En(85));const E=Co(b),T=O.useState("isTriggerActive",E),_=O.useState("floatingRootContext"),w=O.useState("isOpenedByTrigger",E),I=O.useState("triggerPopupId",E),A=p.useRef(null),U=_O(),M=Pm(!0),K=qr(),oe=p.useMemo(()=>K??new sp,[K]),Z=rp(oe),ee=ur(),{registerTrigger:G,isMountedByThisTrigger:te}=d1(E,A,O,{payload:j,closeDelay:x,parent:U,floatingTreeRoot:oe,floatingNodeId:Z,floatingParentNodeId:ee,keyboardEventRelay:M?.relayKeyboardEvent}),X=U.type==="menubar",C=O.useState("disabled"),B=m||C||X&&U.context.disabled,{getButtonProps:H,buttonRef:z}=ql({disabled:B,native:g});p.useEffect(()=>{!w&&U.type===void 0&&(O.context.allowMouseUpTriggerRef.current=!1)},[O,w,U.type]);const L=p.useRef(null),D=Gn(),q=nt(ue=>{if(!L.current)return;D.clear(),O.context.allowMouseUpTriggerRef.current=!1;const Ce=ue.target;if(We(L.current,Ce)||We(O.select("positionerElement"),Ce)||Ce===L.current||Ce!=null&&_1(Ce)===O.select("rootId"))return;const fe=TO(L.current);ue.clientX>=fe.left-bc&&ue.clientX<=fe.right+bc&&ue.clientY>=fe.top-bc&&ue.clientY<=fe.bottom+bc||oe.events.emit("close",{domEvent:ue,reason:pw})});p.useEffect(()=>{w&&O.select("lastOpenChangeReason")===dn&&vt(L.current).addEventListener("mouseup",q,{once:!0})},[w,q,O]);const V=X&&U.context.hasSubmenuOpen,ne=b1(_,{enabled:(h??V)&&!B&&U.type!=="context-menu"&&(!X||V&&!te),handleClose:y1({blockPointerEvents:!X}),mouseOnly:!0,move:!1,restMs:U.type===void 0?v:void 0,delay:{close:x},triggerElementRef:A,externalTree:oe,isActiveTrigger:T,isClosing:()=>O.select("transitionStatus")==="ending"}),F=kO(w,O.select("lastOpenChangeReason")),Te=X0(_,{enabled:!B&&U.type!=="context-menu",event:w&&X?"click":"mousedown",toggle:!0,ignoreMouse:!1,stickIfOpen:U.type===void 0?F:!1}),me=kR(_,{enabled:!B&&V}),he=RO({open:w,enabled:X,mouseDownAction:"open"}),Le=p.useMemo(()=>tr(me.reference,Te.reference),[me.reference,Te.reference]),Ve=O.useState("triggerProps",te),{preFocusGuardRef:Re,handlePreFocusGuardFocus:ze,handleFocusTargetFocus:De}=M1(O,A),ye={disabled:B,open:w},Be=[L,o,z,G,A],ae=[Le,ne??Ut,Ve,{"aria-haspopup":"menu","aria-controls":I,id:E,onMouseDown:ue=>{if(O.select("open"))return;D.start(200,()=>{O.context.allowMouseUpTriggerRef.current=!0}),vt(ue.currentTarget).addEventListener("mouseup",q,{once:!0})}},X?{role:"menuitem"}:{},he,N,H],de=fn("button",r,{enabled:!X,stateAttributesMapping:im,state:ye,ref:Be,props:ae});return X?i.jsx(CO,{tag:"button",render:l,className:c,style:d,state:ye,refs:Be,props:ae,stateAttributesMapping:im}):w?i.jsxs(p.Fragment,{children:[i.jsx(Hr,{ref:Re,onFocus:ze},`${E}-pre-focus-guard`),i.jsx(p.Fragment,{children:de},E),i.jsx(Hr,{ref:O.context.triggerFocusTargetRef,onFocus:De},`${E}-post-focus-guard`)]}):i.jsx(p.Fragment,{children:de},E)});function kO(n,r){const o=Gn(),[l,c]=p.useState(!1);return Ge(()=>{n&&r==="trigger-hover"?(c(!0),o.start(I0,()=>{c(!1)})):n||(o.clear(),c(!1))},[n,r,o]),l}function _O(){const n=Kc(!0),r=To(!0),o=O1();return p.useMemo(()=>o?{type:"menubar",context:o}:n&&!r?{type:"context-menu",context:n}:{type:void 0},[n,r,o])}const MO=p.forwardRef(function(r,o){const{className:l,render:c,orientation:d="horizontal",style:m,...g}=r;return fn("div",r,{state:{orientation:d},ref:o,props:[{role:"separator","aria-orientation":d},g]})});function cu({...n}){return i.jsx(jO,{"data-slot":"dropdown-menu",...n})}function uu({...n}){return i.jsx(OO,{"data-slot":"dropdown-menu-trigger",...n})}function du({align:n="start",alignOffset:r=0,side:o="bottom",sideOffset:l=4,className:c,...d}){return i.jsx(JR,{children:i.jsx(hO,{className:"isolate z-50 outline-none",align:n,alignOffset:r,side:o,sideOffset:l,children:i.jsx(QR,{"data-slot":"dropdown-menu-content",className:et("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 AO({...n}){return i.jsx(Aw,{"data-slot":"dropdown-menu-group",...n})}function DO({className:n,inset:r,...o}){return i.jsx(Dw,{"data-slot":"dropdown-menu-label","data-inset":r,className:et("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",n),...o})}function ds({className:n,inset:r,variant:o="default",...l}){return i.jsx(zw,{"data-slot":"dropdown-menu-item","data-inset":r,"data-variant":o,className:et("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 Ep({className:n,...r}){return i.jsx(MO,{"data-slot":"dropdown-menu-separator",className:et("-mx-1 my-1 h-px bg-border",n),...r})}const zO={propose_create_entity:"新建实体",propose_update_entity:"更新实体",propose_add_relation:"新增关系",propose_outline_node:"新建大纲节点"},LO={character:"角色",setting:"设定",location:"地点",hook:"伏笔"};function IO(n){const r=n.focus_entity_id??n.focus_node_id??"",o=n.focus_entity_type?LO[n.focus_entity_type]??n.focus_entity_type:n.focus_node_id?"大纲节点":"";return o?`${o} ${r}`:r||"当前内容"}const BO=n=>typeof n=="object"&&n!==null?n:{};function UO({disabled:n,onClose:r}){const o=St(b=>b.sessions),l=St(b=>b.currentSessionId),c=St(b=>b.setCurrentSession),d=St(b=>b.newSession),m=o?.find(b=>b.id===l)??null,g=m?m.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(Ll,{className:"size-4 shrink-0 text-muted-foreground"}),i.jsxs(cu,{children:[i.jsx(uu,{render:i.jsxs(Se,{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:g,children:g}),i.jsx(ZN,{className:"size-3.5 shrink-0 text-muted-foreground"})]})}),i.jsxs(du,{align:"start",className:"w-64",children:[i.jsx(AO,{children:i.jsx(DO,{children:"会话(本项目)"})}),i.jsx(Ep,{}),o&&o.length===0&&i.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"暂无历史会话"}),o?.map(b=>i.jsx(ds,{onClick:()=>c(b.id),className:et(b.id===l&&"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:b.lastMessage||"(空会话)"}),i.jsxs("span",{className:"text-xs text-muted-foreground",children:[b.messageCount," 条 · ",xo(b.updatedAt)]})]})},b.id))]})]}),i.jsx(Se,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground",disabled:n,onClick:d,"aria-label":"新会话",title:"新会话",children:i.jsx(Om,{className:"size-4"})}),r&&i.jsx(Se,{variant:"ghost",size:"icon-sm",className:"ml-auto shrink-0 text-muted-foreground",onClick:r,"aria-label":"关闭聊天面板",children:i.jsx(or,{className:"size-4"})})]})}function HO(){const n=St(l=>l.disconnected),r=St(l=>l.setDisconnected),o=St(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(km,{className:"size-3.5 shrink-0"}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:"上次会话已取消"}),i.jsx(Se,{size:"xs",variant:"outline",className:"shrink-0",onClick:o,children:"重新发送"}),i.jsx("button",{className:"shrink-0 rounded p-0.5 hover:bg-destructive/15",onClick:()=>r(!1),"aria-label":"关闭断连提示",children:i.jsx(or,{className:"size-3.5"})})]}):null}function YO(){const n=St(o=>o.streamError),r=St(o=>o.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(wm,{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:()=>r(null),"aria-label":"关闭错误提示",children:i.jsx(or,{className:"size-3.5"})})]}):null}function A1({toolName:n,args:r,result:o,status:l}){const[c,d]=p.useState(!1),m=l==="ok"||o!==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(Rv,{className:et("size-3 shrink-0 transition-transform",c&&"rotate-90")}),i.jsx($j,{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 r=="string"?r:JSON.stringify(r??{},null,2)})]})}function PO({message:n,toolResults:r}){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 o=Array.isArray(n.toolCalls)?n.toolCalls:[];return i.jsxs("div",{className:"space-y-1.5",children:[o.map((l,c)=>{const d=BO(l),m=d.id??`hist-${c}`,g=m?r.get(m):void 0;return i.jsx(A1,{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 VO({proposal:n}){const r=St(d=>d.confirmProposal),o=St(d=>d.rejectProposal),l=zO[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(kv,{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(Se,{size:"xs",disabled:c,onClick:()=>{r(n.proposalId)},children:"确认"}),i.jsx(Se,{size:"xs",variant:"outline",disabled:c,onClick:()=>{o(n.proposalId)},children:"拒绝"})]})]})}function qO(){const n=St(o=>o.focusContext),r=St(o=>o.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(kv,{className:"size-3.5 shrink-0 text-primary"}),i.jsxs("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:["正在讨论:",IO(n)]}),i.jsx("button",{className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted",onClick:r,"aria-label":"清除讨论上下文",children:i.jsx(or,{className:"size-3.5"})})]}):null}function FO({disabled:n}){const[r,o]=p.useState(""),l=St(g=>g.streaming),c=St(g=>g.sendMessage),d=!n&&!l&&r.trim().length>0,m=()=>{d&&(c(r),o(""))};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:r,onChange:g=>o(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(Se,{onClick:m,disabled:!d,className:"shrink-0",children:[l?i.jsx(Pc,{className:"size-4 animate-spin"}):i.jsx(zj,{className:"size-4"}),l?"思考中":"发送"]})]})})}function GO({disabled:n}){const r=St(h=>h.messages),o=St(h=>h.messagesLoading),l=St(h=>h.streamTools),c=St(h=>h.proposals),d=p.useRef(null),m=p.useMemo(()=>{const h=new Map;for(const v of r)v.role==="tool"&&v.toolCallId&&h.set(v.toolCallId,v);return h},[r]),g=r.length;if(p.useEffect(()=>{const h=d.current;h&&(h.scrollTop=h.scrollHeight)},[g,o,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(Ll,{className:"size-8 text-muted-foreground/40"}),i.jsx("p",{className:"text-sm text-muted-foreground/70",children:"打开项目后可用"})]});if(o)return i.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 p-4",children:[0,1].map(h=>i.jsx("div",{className:"animate-pulse rounded-lg bg-muted/60",style:{height:40,width:h%2?"70%":"90%"}},h))});const b=r.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(Ll,{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:[r.map(h=>i.jsx(PO,{message:h,toolResults:m},h.id)),l.map(h=>i.jsx(A1,{toolName:h.tool,args:h.args,result:h.result,status:h.status},h.id)),c.map(h=>i.jsx(VO,{proposal:h},h.proposalId))]})})}function Iy({onClose:n}){const o=!Ae(l=>l.config);return i.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[i.jsx(UO,{disabled:o,onClose:n}),!o&&i.jsxs(i.Fragment,{children:[i.jsx(HO,{}),i.jsx(YO,{})]}),i.jsx(GO,{disabled:o}),!o&&i.jsxs(i.Fragment,{children:[i.jsx(qO,{}),i.jsx(FO,{disabled:o})]})]})}function XO({open:n,onClose:r}){return Mv("(min-width: 1024px)")?i.jsx("aside",{className:"flex min-w-0 flex-[4_1_40%] flex-col border-l border-border bg-background",children:i.jsx(Iy,{})}):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:r}),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(Iy,{onClose:r})})]}):null}function $O(n){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",r.appendChild(o),o.styleSheet?o.styleSheet.cssText=n:o.appendChild(document.createTextNode(n))}const KO=n=>{switch(n){case"success":return JO;case"info":return ek;case"warning":return WO;case"error":return tk;default:return null}},QO=Array(12).fill(0),ZO=({visible:n,className:r})=>_e.createElement("div",{className:["sonner-loading-wrapper",r].filter(Boolean).join(" "),"data-visible":n},_e.createElement("div",{className:"sonner-spinner"},QO.map((o,l)=>_e.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${l}`})))),JO=_e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},_e.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"})),WO=_e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},_e.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"})),ek=_e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},_e.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"})),tk=_e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},_e.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"})),nk=_e.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"},_e.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),_e.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),sk=()=>{const[n,r]=_e.useState(document.hidden);return _e.useEffect(()=>{const o=()=>{r(document.hidden)};return document.addEventListener("visibilitychange",o),()=>window.removeEventListener("visibilitychange",o)},[]),n};let vm=1;class rk{constructor(){this.subscribe=r=>(this.subscribers.push(r),()=>{const o=this.subscribers.indexOf(r);this.subscribers.splice(o,1)}),this.publish=r=>{this.subscribers.forEach(o=>o(r))},this.addToast=r=>{this.publish(r),this.toasts=[...this.toasts,r]},this.create=r=>{var o;const{message:l,...c}=r,d=typeof r?.id=="number"||((o=r.id)==null?void 0:o.length)>0?r.id:vm++,m=this.toasts.find(b=>b.id===d),g=r.dismissible===void 0?!0:r.dismissible;return this.dismissedToasts.has(d)&&this.dismissedToasts.delete(d),m?this.toasts=this.toasts.map(b=>b.id===d?(this.publish({...b,...r,id:d,title:l}),{...b,...r,id:d,dismissible:g,title:l}):b):this.addToast({title:l,...c,dismissible:g,id:d}),d},this.dismiss=r=>(r?(this.dismissedToasts.add(r),requestAnimationFrame(()=>this.subscribers.forEach(o=>o({id:r,dismiss:!0})))):this.toasts.forEach(o=>{this.subscribers.forEach(l=>l({id:o.id,dismiss:!0}))}),r),this.message=(r,o)=>this.create({...o,message:r}),this.error=(r,o)=>this.create({...o,message:r,type:"error"}),this.success=(r,o)=>this.create({...o,type:"success",message:r}),this.info=(r,o)=>this.create({...o,type:"info",message:r}),this.warning=(r,o)=>this.create({...o,type:"warning",message:r}),this.loading=(r,o)=>this.create({...o,type:"loading",message:r}),this.promise=(r,o)=>{if(!o)return;let l;o.loading!==void 0&&(l=this.create({...o,promise:r,type:"loading",message:o.loading,description:typeof o.description!="function"?o.description:void 0}));const c=Promise.resolve(r instanceof Function?r():r);let d=l!==void 0,m;const g=c.then(async h=>{if(m=["resolve",h],_e.isValidElement(h))d=!1,this.create({id:l,type:"default",message:h});else if(ak(h)&&!h.ok){d=!1;const x=typeof o.error=="function"?await o.error(`HTTP error! status: ${h.status}`):o.error,S=typeof o.description=="function"?await o.description(`HTTP error! status: ${h.status}`):o.description,N=typeof x=="object"&&!_e.isValidElement(x)?x:{message:x};this.create({id:l,type:"error",description:S,...N})}else if(h instanceof Error){d=!1;const x=typeof o.error=="function"?await o.error(h):o.error,S=typeof o.description=="function"?await o.description(h):o.description,N=typeof x=="object"&&!_e.isValidElement(x)?x:{message:x};this.create({id:l,type:"error",description:S,...N})}else if(o.success!==void 0){d=!1;const x=typeof o.success=="function"?await o.success(h):o.success,S=typeof o.description=="function"?await o.description(h):o.description,N=typeof x=="object"&&!_e.isValidElement(x)?x:{message:x};this.create({id:l,type:"success",description:S,...N})}}).catch(async h=>{if(m=["reject",h],o.error!==void 0){d=!1;const v=typeof o.error=="function"?await o.error(h):o.error,x=typeof o.description=="function"?await o.description(h):o.description,j=typeof v=="object"&&!_e.isValidElement(v)?v:{message:v};this.create({id:l,type:"error",description:x,...j})}}).finally(()=>{d&&(this.dismiss(l),l=void 0),o.finally==null||o.finally.call(o)}),b=()=>new Promise((h,v)=>g.then(()=>m[0]==="reject"?v(m[1]):h(m[1])).catch(v));return typeof l!="string"&&typeof l!="number"?{unwrap:b}:Object.assign(l,{unwrap:b})},this.custom=(r,o)=>{const l=o?.id||vm++;return this.create({jsx:r(l),id:l,...o}),l},this.getActiveToasts=()=>this.toasts.filter(r=>!this.dismissedToasts.has(r.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const An=new rk,ok=(n,r)=>{const o=r?.id||vm++;return An.addToast({title:n,...r,id:o}),o},ak=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",lk=ok,ik=()=>An.toasts,ck=()=>An.getActiveToasts(),By=Object.assign(lk,{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:ik,getToasts:ck});$O("[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 yc(n){return n.label!==void 0}const uk=3,dk="24px",fk="16px",Uy=4e3,mk=356,pk=14,hk=45,gk=200;function Ss(...n){return n.filter(Boolean).join(" ")}function xk(n){const[r,o]=n.split("-"),l=[];return r&&l.push(r),o&&l.push(o),l}const bk=n=>{var r,o,l,c,d,m,g,b,h;const{invert:v,toast:x,unstyled:S,interacting:j,setHeights:N,visibleToasts:k,heights:O,index:E,toasts:T,expanded:_,removeToast:w,defaultRichColors:I,closeButton:A,style:U,cancelButtonStyle:M,actionButtonStyle:K,className:oe="",descriptionClassName:Z="",duration:ee,position:G,gap:te,expandByDefault:X,classNames:C,icons:B,closeButtonAriaLabel:H="Close toast"}=n,[z,L]=_e.useState(null),[D,q]=_e.useState(null),[V,Q]=_e.useState(!1),[ne,F]=_e.useState(!1),[Te,me]=_e.useState(!1),[he,Le]=_e.useState(!1),[Ve,Re]=_e.useState(!1),[ze,De]=_e.useState(0),[ye,Be]=_e.useState(0),ae=_e.useRef(x.duration||ee||Uy),de=_e.useRef(null),ue=_e.useRef(null),Ce=E===0,fe=E+1<=k,be=x.type,qe=x.dismissible!==!1,se=x.className||"",Y=x.descriptionClassName||"",ge=_e.useMemo(()=>O.findIndex(ve=>ve.toastId===x.id)||0,[O,x.id]),J=_e.useMemo(()=>{var ve;return(ve=x.closeButton)!=null?ve:A},[x.closeButton,A]),we=_e.useMemo(()=>x.duration||ee||Uy,[x.duration,ee]),Xe=_e.useRef(0),je=_e.useRef(0),Me=_e.useRef(0),$e=_e.useRef(null),[rt,Nt]=G.split("-"),kt=_e.useMemo(()=>O.reduce((ve,Oe,Qe)=>Qe>=ge?ve:ve+Oe.height,0),[O,ge]),bt=sk(),yn=x.invert||v,an=be==="loading";je.current=_e.useMemo(()=>ge*te+kt,[ge,kt]),_e.useEffect(()=>{ae.current=we},[we]),_e.useEffect(()=>{Q(!0)},[]),_e.useEffect(()=>{const ve=ue.current;if(ve){const Oe=ve.getBoundingClientRect().height;return Be(Oe),N(Qe=>[{toastId:x.id,height:Oe,position:x.position},...Qe]),()=>N(Qe=>Qe.filter(tt=>tt.toastId!==x.id))}},[N,x.id]),_e.useLayoutEffect(()=>{if(!V)return;const ve=ue.current,Oe=ve.style.height;ve.style.height="auto";const Qe=ve.getBoundingClientRect().height;ve.style.height=Oe,Be(Qe),N(tt=>tt.find(st=>st.toastId===x.id)?tt.map(st=>st.toastId===x.id?{...st,height:Qe}:st):[{toastId:x.id,height:Qe,position:x.position},...tt])},[V,x.title,x.description,N,x.id,x.jsx,x.action,x.cancel]);const Ke=_e.useCallback(()=>{F(!0),De(je.current),N(ve=>ve.filter(Oe=>Oe.toastId!==x.id)),setTimeout(()=>{w(x)},gk)},[x,w,N,je]);_e.useEffect(()=>{if(x.promise&&be==="loading"||x.duration===1/0||x.type==="loading")return;let ve;return _||j||bt?(()=>{if(Me.current<Xe.current){const tt=new Date().getTime()-Xe.current;ae.current=ae.current-tt}Me.current=new Date().getTime()})():ae.current!==1/0&&(Xe.current=new Date().getTime(),ve=setTimeout(()=>{x.onAutoClose==null||x.onAutoClose.call(x,x),Ke()},ae.current)),()=>clearTimeout(ve)},[_,j,x,be,bt,Ke]),_e.useEffect(()=>{x.delete&&(Ke(),x.onDismiss==null||x.onDismiss.call(x,x))},[Ke,x.delete]);function Tt(){var ve;if(B?.loading){var Oe;return _e.createElement("div",{className:Ss(C?.loader,x==null||(Oe=x.classNames)==null?void 0:Oe.loader,"sonner-loader"),"data-visible":be==="loading"},B.loading)}return _e.createElement(ZO,{className:Ss(C?.loader,x==null||(ve=x.classNames)==null?void 0:ve.loader),visible:be==="loading"})}const tn=x.icon||B?.[be]||KO(be);var qt,re;return _e.createElement("li",{tabIndex:0,ref:ue,className:Ss(oe,se,C?.toast,x==null||(r=x.classNames)==null?void 0:r.toast,C?.default,C?.[be],x==null||(o=x.classNames)==null?void 0:o[be]),"data-sonner-toast":"","data-rich-colors":(qt=x.richColors)!=null?qt:I,"data-styled":!(x.jsx||x.unstyled||S),"data-mounted":V,"data-promise":!!x.promise,"data-swiped":Ve,"data-removed":ne,"data-visible":fe,"data-y-position":rt,"data-x-position":Nt,"data-index":E,"data-front":Ce,"data-swiping":Te,"data-dismissible":qe,"data-type":be,"data-invert":yn,"data-swipe-out":he,"data-swipe-direction":D,"data-expanded":!!(_||X&&V),"data-testid":x.testId,style:{"--index":E,"--toasts-before":E,"--z-index":T.length-E,"--offset":`${ne?ze:je.current}px`,"--initial-height":X?"auto":`${ye}px`,...U,...x.style},onDragEnd:()=>{me(!1),L(null),$e.current=null},onPointerDown:ve=>{ve.button!==2&&(an||!qe||(de.current=new Date,De(je.current),ve.target.setPointerCapture(ve.pointerId),ve.target.tagName!=="BUTTON"&&(me(!0),$e.current={x:ve.clientX,y:ve.clientY})))},onPointerUp:()=>{var ve,Oe,Qe;if(he||!qe)return;$e.current=null;const tt=Number(((ve=ue.current)==null?void 0:ve.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),at=Number(((Oe=ue.current)==null?void 0:Oe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),st=new Date().getTime()-((Qe=de.current)==null?void 0:Qe.getTime()),Pt=z==="x"?tt:at,Xn=Math.abs(Pt)/st;if(Math.abs(Pt)>=hk||Xn>.11){De(je.current),x.onDismiss==null||x.onDismiss.call(x,x),q(z==="x"?tt>0?"right":"left":at>0?"down":"up"),Ke(),Le(!0);return}else{var $t,mn;($t=ue.current)==null||$t.style.setProperty("--swipe-amount-x","0px"),(mn=ue.current)==null||mn.style.setProperty("--swipe-amount-y","0px")}Re(!1),me(!1),L(null)},onPointerMove:ve=>{var Oe,Qe,tt;if(!$e.current||!qe||((Oe=window.getSelection())==null?void 0:Oe.toString().length)>0)return;const st=ve.clientY-$e.current.y,Pt=ve.clientX-$e.current.x;var Xn;const $t=(Xn=n.swipeDirections)!=null?Xn:xk(G);!z&&(Math.abs(Pt)>1||Math.abs(st)>1)&&L(Math.abs(Pt)>Math.abs(st)?"x":"y");let mn={x:0,y:0};const dr=Ln=>1/(1.5+Math.abs(Ln)/20);if(z==="y"){if($t.includes("top")||$t.includes("bottom"))if($t.includes("top")&&st<0||$t.includes("bottom")&&st>0)mn.y=st;else{const Ln=st*dr(st);mn.y=Math.abs(Ln)<Math.abs(st)?Ln:st}}else if(z==="x"&&($t.includes("left")||$t.includes("right")))if($t.includes("left")&&Pt<0||$t.includes("right")&&Pt>0)mn.x=Pt;else{const Ln=Pt*dr(Pt);mn.x=Math.abs(Ln)<Math.abs(Pt)?Ln:Pt}(Math.abs(mn.x)>0||Math.abs(mn.y)>0)&&Re(!0),(Qe=ue.current)==null||Qe.style.setProperty("--swipe-amount-x",`${mn.x}px`),(tt=ue.current)==null||tt.style.setProperty("--swipe-amount-y",`${mn.y}px`)}},J&&!x.jsx&&be!=="loading"?_e.createElement("button",{"aria-label":H,"data-disabled":an,"data-close-button":!0,onClick:an||!qe?()=>{}:()=>{Ke(),x.onDismiss==null||x.onDismiss.call(x,x)},className:Ss(C?.closeButton,x==null||(l=x.classNames)==null?void 0:l.closeButton)},(re=B?.close)!=null?re:nk):null,(be||x.icon||x.promise)&&x.icon!==null&&(B?.[be]!==null||x.icon)?_e.createElement("div",{"data-icon":"",className:Ss(C?.icon,x==null||(c=x.classNames)==null?void 0:c.icon)},x.promise||x.type==="loading"&&!x.icon?x.icon||Tt():null,x.type!=="loading"?tn:null):null,_e.createElement("div",{"data-content":"",className:Ss(C?.content,x==null||(d=x.classNames)==null?void 0:d.content)},_e.createElement("div",{"data-title":"",className:Ss(C?.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?_e.createElement("div",{"data-description":"",className:Ss(Z,Y,C?.description,x==null||(g=x.classNames)==null?void 0:g.description)},typeof x.description=="function"?x.description():x.description):null),_e.isValidElement(x.cancel)?x.cancel:x.cancel&&yc(x.cancel)?_e.createElement("button",{"data-button":!0,"data-cancel":!0,style:x.cancelButtonStyle||M,onClick:ve=>{yc(x.cancel)&&qe&&(x.cancel.onClick==null||x.cancel.onClick.call(x.cancel,ve),Ke())},className:Ss(C?.cancelButton,x==null||(b=x.classNames)==null?void 0:b.cancelButton)},x.cancel.label):null,_e.isValidElement(x.action)?x.action:x.action&&yc(x.action)?_e.createElement("button",{"data-button":!0,"data-action":!0,style:x.actionButtonStyle||K,onClick:ve=>{yc(x.action)&&(x.action.onClick==null||x.action.onClick.call(x.action,ve),!ve.defaultPrevented&&Ke())},className:Ss(C?.actionButton,x==null||(h=x.classNames)==null?void 0:h.actionButton)},x.action.label):null)};function Hy(){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 yk(n,r){const o={};return[n,r].forEach((l,c)=>{const d=c===1,m=d?"--mobile-offset":"--offset",g=d?fk:dk;function b(h){["top","right","bottom","left"].forEach(v=>{o[`${m}-${v}`]=typeof h=="number"?`${h}px`:h})}typeof l=="number"||typeof l=="string"?b(l):typeof l=="object"?["top","right","bottom","left"].forEach(h=>{l[h]===void 0?o[`${m}-${h}`]=g:o[`${m}-${h}`]=typeof l[h]=="number"?`${l[h]}px`:l[h]}):b(g)}),o}const vk=_e.forwardRef(function(r,o){const{id:l,invert:c,position:d="bottom-right",hotkey:m=["altKey","KeyT"],expand:g,closeButton:b,className:h,offset:v,mobileOffset:x,theme:S="light",richColors:j,duration:N,style:k,visibleToasts:O=uk,toastOptions:E,dir:T=Hy(),gap:_=pk,icons:w,containerAriaLabel:I="Notifications"}=r,[A,U]=_e.useState([]),M=_e.useMemo(()=>l?A.filter(V=>V.toasterId===l):A.filter(V=>!V.toasterId),[A,l]),K=_e.useMemo(()=>Array.from(new Set([d].concat(M.filter(V=>V.position).map(V=>V.position)))),[M,d]),[oe,Z]=_e.useState([]),[ee,G]=_e.useState(!1),[te,X]=_e.useState(!1),[C,B]=_e.useState(S!=="system"?S:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),H=_e.useRef(null),z=m.join("+").replace(/Key/g,"").replace(/Digit/g,""),L=_e.useRef(null),D=_e.useRef(!1),q=_e.useCallback(V=>{U(Q=>{var ne;return(ne=Q.find(F=>F.id===V.id))!=null&&ne.delete||An.dismiss(V.id),Q.filter(({id:F})=>F!==V.id)})},[]);return _e.useEffect(()=>An.subscribe(V=>{if(V.dismiss){requestAnimationFrame(()=>{U(Q=>Q.map(ne=>ne.id===V.id?{...ne,delete:!0}:ne))});return}setTimeout(()=>{_w.flushSync(()=>{U(Q=>{const ne=Q.findIndex(F=>F.id===V.id);return ne!==-1?[...Q.slice(0,ne),{...Q[ne],...V},...Q.slice(ne+1)]:[V,...Q]})})})}),[A]),_e.useEffect(()=>{if(S!=="system"){B(S);return}if(S==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?B("dark"):B("light")),typeof window>"u")return;const V=window.matchMedia("(prefers-color-scheme: dark)");try{V.addEventListener("change",({matches:Q})=>{B(Q?"dark":"light")})}catch{V.addListener(({matches:ne})=>{try{B(ne?"dark":"light")}catch(F){console.error(F)}})}},[S]),_e.useEffect(()=>{A.length<=1&&G(!1)},[A]),_e.useEffect(()=>{const V=Q=>{var ne;if(m.every(me=>Q[me]||Q.code===me)){var Te;G(!0),(Te=H.current)==null||Te.focus()}Q.code==="Escape"&&(document.activeElement===H.current||(ne=H.current)!=null&&ne.contains(document.activeElement))&&G(!1)};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[m]),_e.useEffect(()=>{if(H.current)return()=>{L.current&&(L.current.focus({preventScroll:!0}),L.current=null,D.current=!1)}},[H.current]),_e.createElement("section",{ref:o,"aria-label":`${I} ${z}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},K.map((V,Q)=>{var ne;const[F,Te]=V.split("-");return M.length?_e.createElement("ol",{key:V,dir:T==="auto"?Hy():T,tabIndex:-1,ref:H,className:h,"data-sonner-toaster":!0,"data-sonner-theme":C,"data-y-position":F,"data-x-position":Te,style:{"--front-toast-height":`${((ne=oe[0])==null?void 0:ne.height)||0}px`,"--width":`${mk}px`,"--gap":`${_}px`,...k,...yk(v,x)},onBlur:me=>{D.current&&!me.currentTarget.contains(me.relatedTarget)&&(D.current=!1,L.current&&(L.current.focus({preventScroll:!0}),L.current=null))},onFocus:me=>{me.target instanceof HTMLElement&&me.target.dataset.dismissible==="false"||D.current||(D.current=!0,L.current=me.relatedTarget)},onMouseEnter:()=>G(!0),onMouseMove:()=>G(!0),onMouseLeave:()=>{te||G(!1)},onDragEnd:()=>G(!1),onPointerDown:me=>{me.target instanceof HTMLElement&&me.target.dataset.dismissible==="false"||X(!0)},onPointerUp:()=>X(!1)},M.filter(me=>!me.position&&Q===0||me.position===V).map((me,he)=>{var Le,Ve;return _e.createElement(bk,{key:me.id,icons:w,index:he,toast:me,defaultRichColors:j,duration:(Le=E?.duration)!=null?Le:N,className:E?.className,descriptionClassName:E?.descriptionClassName,invert:c,visibleToasts:O,closeButton:(Ve=E?.closeButton)!=null?Ve:b,interacting:te,position:V,style:E?.style,unstyled:E?.unstyled,classNames:E?.classNames,cancelButtonStyle:E?.cancelButtonStyle,actionButtonStyle:E?.actionButtonStyle,closeButtonAriaLabel:E?.closeButtonAriaLabel,removeToast:q,toasts:M.filter(Re=>Re.position==me.position),heights:oe.filter(Re=>Re.position==me.position),setHeights:Z,expandByDefault:g,gap:_,expanded:ee,swipeDirections:r.swipeDirections})})):null}))}),D1=p.createContext(!1),z1=p.createContext(void 0);function Ro(n){const r=p.useContext(z1);if(n===!1&&r===void 0)throw new Error(En(27));return r}const Sk={...Fl,...$c},Ek=p.forwardRef(function(r,o){const{render:l,className:c,style:d,forceRender:m=!1,...g}=r,{store:b}=Ro(),h=b.useState("open"),v=b.useState("nested"),x=b.useState("mounted"),S=b.useState("transitionStatus");return fn("div",r,{state:{open:h,transitionStatus:S},ref:[b.context.backdropRef,o],stateAttributesMapping:Sk,props:[{role:"presentation",hidden:!x,style:{userSelect:"none",WebkitUserSelect:"none"}},g],enabled:m||!v})}),L1=p.forwardRef(function(r,o){const{render:l,className:c,style:d,disabled:m=!1,nativeButton:g=!0,...b}=r,{store:h}=Ro(),v=h.useState("open"),{getButtonProps:x,buttonRef:S}=ql({disabled:m,native:g}),j={disabled:m};function N(k){v&&h.setOpen(!1,jt(p0,k.nativeEvent))}return fn("button",r,{state:j,ref:[o,S],props:[{onClick:N},b,x]})}),Nk=p.forwardRef(function(r,o){const{render:l,className:c,style:d,id:m,...g}=r,{store:b}=Ro(),h=Co(m);return b.useSyncedValueWithCleanup("descriptionElementId",h),fn("p",r,{ref:o,props:[{id:h},g]})});let jk=(function(n){return n.nestedDialogs="--nested-dialogs",n})({}),Tk=(function(n){return n[n.open=po.open]="open",n[n.closed=po.closed]="closed",n[n.startingStyle=po.startingStyle]="startingStyle",n[n.endingStyle=po.endingStyle]="endingStyle",n.nested="data-nested",n.nestedDialogOpen="data-nested-dialog-open",n})({});const I1=p.createContext(void 0);function wk(){const n=p.useContext(I1);if(n===void 0)throw new Error(En(26));return n}const Ck={...Fl,...$c,nestedDialogOpen(n){return n?{[Tk.nestedDialogOpen]:""}:null}},Rk=p.forwardRef(function(r,o){const{render:l,className:c,style:d,finalFocus:m,initialFocus:g,...b}=r,{store:h}=Ro(),v=h.useState("descriptionElementId"),x=h.useState("disablePointerDismissal"),S=h.useState("floatingRootContext"),j=h.useState("popupProps"),N=h.useState("modal"),k=h.useState("mounted"),O=h.useState("nested"),E=h.useState("nestedOpenDialogCount"),T=h.useState("open"),_=h.useState("openMethod"),w=h.useState("titleElementId"),I=h.useState("transitionStatus"),A=h.useState("role"),U=S.useState("floatingId"),M=b.id??U;wk(),Wc({open:T,ref:h.context.popupRef,onComplete(){T&&h.context.onOpenChangeComplete?.(!0)}});const K=g===void 0?l1(h.context.popupRef):g,oe=E>0,Z=h.useStateSetter("popupElement"),G=fn("div",r,{state:{open:T,nested:O,transitionStatus:I,nestedDialogOpen:oe},props:[j,{id:M,"aria-labelledby":w??void 0,"aria-describedby":v??void 0,role:A,...lu,hidden:!k,onKeyDown(te){xp.has(te.key)&&te.stopPropagation()},style:{[jk.nestedDialogs]:E}},b],ref:[o,h.context.popupRef,Z],stateAttributesMapping:Ck});return i.jsx(ap,{context:S,openInteractionType:_,disabled:!k,closeOnFocusOut:!x,initialFocus:K,returnFocus:m,modal:N!==!1,restoreFocus:"popup",children:G})}),Ok=p.forwardRef(function(r,o){const{keepMounted:l=!1,...c}=r,{store:d}=Ro(),m=d.useState("mounted"),g=d.useState("modal"),b=d.useState("open");return m||l?i.jsx(I1.Provider,{value:l,children:i.jsxs(np,{ref:o,...c,children:[m&&g===!0&&i.jsx(vp,{ref:d.context.internalBackdropRef,inert:yp(!b)}),r.children]})}):null});function kk(n){const{store:r,actionsRef:o}=n,l=r.useState("open");f1(r,l),up(r);const{forceUnmount:c}=dp(l,r),d=p.useCallback(()=>{r.setOpen(!1,jt(Fm))},[r]);p.useImperativeHandle(o,()=>({unmount:c,close:d}),[c,d])}function _k({store:n,parentContext:r,isDrawer:o}){const l=n.useState("open"),c=n.useState("disablePointerDismissal"),d=n.useState("modal"),m=n.useState("popupElement"),g=n.useState("floatingRootContext"),[b,h]=p.useState(0),[v,x]=p.useState(0),S=b===0,j=lp(g,{outsidePressEvent(){return n.context.internalBackdropRef.current||n.context.backdropRef.current?"intentional":{mouse:d==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(E){if(!n.context.outsidePressEnabledRef.current||"button"in E&&E.button!==0||"touches"in E&&E.touches.length!==1)return!1;const T=Dn(E);return S&&!c?d&&(n.context.internalBackdropRef.current||n.context.backdropRef.current)?n.context.internalBackdropRef.current===T||n.context.backdropRef.current===T||We(T,m)&&!T?.hasAttribute("data-base-ui-portal"):!0:!1},escapeKey:S});C1(l&&d===!0,m),n.useContextCallback("onNestedDialogOpen",(E,T)=>{h(E),x(T)}),n.useContextCallback("onNestedDialogClose",()=>{h(0),x(0)}),p.useEffect(()=>(r?.onNestedDialogOpen&&l&&r.onNestedDialogOpen(b+1,v+(o?1:0)),r?.onNestedDialogClose&&!l&&r.onNestedDialogClose(),()=>{r?.onNestedDialogClose&&l&&r.onNestedDialogClose()}),[o,l,b,v,r]);const N=j.reference??Ut,k=j.trigger??Ut,O=j.floating??Ut;return fp(n,{activeTriggerProps:N,inactiveTriggerProps:k,popupProps:O,nestedOpenDialogCount:b,nestedOpenDrawerCount:v}),null}const Mk={...hp,modal:Ye(n=>n.modal),nested:Ye(n=>n.nested),nestedOpenDialogCount:Ye(n=>n.nestedOpenDialogCount),nestedOpenDrawerCount:Ye(n=>n.nestedOpenDrawerCount),disablePointerDismissal:Ye(n=>n.disablePointerDismissal),openMethod:Ye(n=>n.openMethod),descriptionElementId:Ye(n=>n.descriptionElementId),titleElementId:Ye(n=>n.titleElementId),viewportElement:Ye(n=>n.viewportElement),role:Ye(n=>n.role)};class Np extends ou{constructor(r,o,l=!1){const c=new Xl,d=Ak(r);d.floatingRootContext=m1(c,o,l),super(d,{popupRef:p.createRef(),backdropRef:p.createRef(),internalBackdropRef:p.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:c,onOpenChange:void 0,onOpenChangeComplete:void 0},Mk)}setOpen=(r,o)=>{if(o.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!r&&o.trigger==null&&this.state.activeTriggerId!=null&&(o.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(r,o),o.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(r,o);const l={open:r};cp(l,r,o.trigger),this.update(l)};static useStore(r,o){return i1(r,(c,d)=>new Np(o,c,d),!0).store}}function Ak(n={}){return{...mp(),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 Dk(n,r="dialog"){const{children:o,open:l,defaultOpen:c=!1,onOpenChange:d,onOpenChangeComplete:m,disablePointerDismissal:g=!1,modal:b=!0,actionsRef:h,handle:v,triggerId:x,defaultTriggerId:S=null}=n,j=r==="drawer",N=r==="alert-dialog",k=N?!0:b,O=N||g,E=N?"alertdialog":"dialog",T=Ro(!0),w={modal:k,disablePointerDismissal:O,nested:!!T,role:E},I=Np.useStore(v?.store,{open:c,openProp:l,activeTriggerId:S,triggerIdProp:x,...w});t1(()=>{const Z=l===void 0&&I.state.open===!1&&c===!0?{open:!0,activeTriggerId:S}:null;N?I.update(Z?{...w,...Z}:w):Z&&I.update(Z)}),I.useControlledProp("openProp",l),I.useControlledProp("triggerIdProp",x),I.useSyncedValues(w),I.useContextCallback("onOpenChange",d),I.useContextCallback("onOpenChangeComplete",m);const A=I.useState("open"),U=I.useState("mounted"),M=I.useState("payload");kk({store:I,actionsRef:h});const K=A||U,oe=p.useMemo(()=>({store:I}),[I]);return i.jsx(D1.Provider,{value:!1,children:i.jsxs(z1.Provider,{value:oe,children:[K&&i.jsx(_k,{store:I,parentContext:T?.store.context,isDrawer:j}),typeof o=="function"?o({payload:M}):o]})})}function zk(n){const r=p.useContext(D1)?"drawer":"dialog";return Dk(n,r)}const Lk=p.forwardRef(function(r,o){const{render:l,className:c,style:d,id:m,...g}=r,{store:b}=Ro(),h=Co(m);return b.useSyncedValueWithCleanup("titleElementId",h),fn("h2",r,{ref:o,props:[{id:h},g]})});function Ks({...n}){return i.jsx(zk,{"data-slot":"dialog",...n})}function Ik({...n}){return i.jsx(Ok,{"data-slot":"dialog-portal",...n})}function Bk({className:n,...r}){return i.jsx(Ek,{"data-slot":"dialog-overlay",className:et("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),...r})}function Qs({className:n,children:r,showCloseButton:o=!0,...l}){return i.jsxs(Ik,{children:[i.jsx(Bk,{}),i.jsxs(Rk,{"data-slot":"dialog-content",className:et("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:[r,o&&i.jsxs(L1,{"data-slot":"dialog-close",render:i.jsx(Se,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm"}),children:[i.jsx(or,{}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Zs({className:n,...r}){return i.jsx("div",{"data-slot":"dialog-header",className:et("flex flex-col gap-2",n),...r})}function Js({className:n,showCloseButton:r=!1,children:o,...l}){return i.jsxs("div",{"data-slot":"dialog-footer",className:et("-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:[o,r&&i.jsx(L1,{render:i.jsx(Se,{variant:"outline"}),children:"Close"})]})}function Ws({className:n,...r}){return i.jsx(Lk,{"data-slot":"dialog-title",className:et("font-heading text-base leading-none font-medium",n),...r})}function Uk({className:n,...r}){return i.jsx(Nk,{"data-slot":"dialog-description",className:et("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",n),...r})}const rs={volume:"卷",chapter:"章",scene:"场"},Hk={volume:"chapter",chapter:"scene",scene:null};function ms({title:n,description:r,confirmLabel:o,danger:l=!1,onConfirm:c,onClose:d}){const[m,g]=p.useState(null),[b,h]=p.useState(!1);async function v(){h(!0),g(null);try{await c(),d()}catch(x){g(x instanceof Ie?x.message:"操作失败,请稍后重试")}finally{h(!1)}}return i.jsx(Ks,{open:!0,onOpenChange:x=>!x&&d(),children:i.jsxs(Qs,{className:"sm:max-w-md",children:[i.jsx(Zs,{children:i.jsx(Ws,{children:n})}),i.jsx("p",{className:"text-sm text-muted-foreground",children:r}),m&&i.jsx("p",{className:"mt-2 text-sm text-destructive",children:m}),i.jsxs(Js,{children:[i.jsx(Se,{variant:"outline",type:"button",onClick:d,disabled:b,children:"取消"}),i.jsx(Se,{variant:l?"destructive":"default",type:"button",onClick:()=>{v()},disabled:b,children:o})]})]})})}const Yy="ai-editor:theme";function B1(){const[n,r]=p.useState("light");p.useEffect(()=>{const c=localStorage.getItem(Yy)==="dark"?"dark":"light";r(c),document.documentElement.classList.toggle("dark",c==="dark")},[]);function o(){const l=n==="dark"?"light":"dark";localStorage.setItem(Yy,l),document.documentElement.classList.toggle("dark",l==="dark"),r(l)}return{theme:n,toggleTheme:o}}const Yk=({...n})=>{const{theme:r="light"}=B1();return i.jsx(vk,{theme:r,position:"top-right",className:"toaster group",icons:{success:i.jsx(Cm,{className:"size-4"}),info:i.jsx(Ov,{className:"size-4"}),warning:i.jsx(km,{className:"size-4"}),error:i.jsx(jj,{className:"size-4"}),loading:i.jsx(Pc,{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 Pk(n,r){return n!==null&&n.id!==r}function Vk(){const n=ke(o=>o.confirmState),r=ke(o=>o.resolveConfirm);return n===null?null:i.jsx(ms,{title:n.title,description:n.description??"",confirmLabel:"确认",danger:n.danger,onConfirm:async()=>r(!0),onClose:()=>r(!1)})}function qk(){const n=ke(c=>c.toast),r=ke(c=>c.error),o=ke(c=>c.clearError),l=p.useRef(null);return p.useEffect(()=>{!n||!Pk(n,l.current)||(l.current=n.id,n.kind==="error"?By.error(n.text,{duration:nm}):By.success(n.text,{duration:nm}))},[n]),i.jsxs(i.Fragment,{children:[i.jsx(Yk,{}),i.jsx(Vk,{}),r&&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(wm,{className:"size-4 shrink-0"}),i.jsx("p",{className:"min-w-0 flex-1",children:r.message}),i.jsx("button",{type:"button","aria-label":"关闭错误提示",onClick:o,className:"shrink-0 rounded p-0.5 hover:bg-destructive/15",children:i.jsx(or,{className:"size-4"})})]})]})}function Fk({chatOpen:n,onToggleChat:r}){const o=Ae(v=>v.config),l=Ae(v=>v.configLoading),c=Ae(v=>v.outline),d=ke(v=>v.setFocusOutlineNode),m=ke(v=>v.notifyDataChanged),g=Mv("(min-width: 1024px)"),b=o?.currentPosition!=null?Iv(c,o.currentPosition)??o.currentPosition:null,h=l?"加载中…":o?.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:h})]}),i.jsxs("a",{href:"#/outline",onClick:()=>{o?.currentPosition!=null&&d(o.currentPosition)},title:o?.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(Se,{variant:"ghost",size:"icon-sm",className:"ml-auto shrink-0 text-muted-foreground",onClick:m,"aria-label":"刷新数据",title:"刷新数据",children:i.jsx(_j,{className:"size-4"})}),i.jsxs("span",{className:"shrink-0 text-sm text-muted-foreground",children:["语言: ",o?.language??"—"]}),!g&&i.jsx(Se,{variant:"ghost",size:"icon-sm",className:n?"bg-secondary text-foreground":"text-muted-foreground",onClick:r,"aria-label":n?"关闭聊天面板":"打开聊天面板",children:i.jsx(Ll,{className:"size-4"})})]})}const Gk=[{label:"概览",href:"#/",segment:null,icon:fj},{label:"大纲",href:"#/outline",segment:"outline",icon:pj},{label:"画布",href:"#/canvas",segment:"canvas",icon:Uj},{label:"实体关系",href:"#/entities/character",segment:"entities",icon:Ej},{label:"伏笔",href:"#/hooks",segment:"hooks",icon:Oj},{label:"时间轴",href:"#/timeline",segment:"timeline",icon:KN},{label:"回收站",href:"#/trash",segment:"trash",icon:_v}];function Xk({route:n}){const r=n.segments[0]??null,o=Ae(d=>d.loadError==="NO_PROJECT_OPEN"),l=ke(d=>d.showToast),c=(d,m)=>{!o||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:Gk.map(d=>{const m=d.icon,g=r===d.segment;return i.jsxs("a",{href:d.href,"aria-current":g?"page":void 0,onClick:b=>c(b,d),className:et("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 $k({route:n,chatOpen:r,onToggleChat:o,children:l}){const c=Ae(d=>d.loadConfig);return p.useEffect(()=>{c()},[c]),i.jsxs("main",{className:"flex min-w-0 flex-[5_1_50%] flex-col",children:[i.jsx(Fk,{chatOpen:r,onToggleChat:o}),i.jsx("div",{className:"shrink-0 px-3 py-2",children:i.jsx(Xk,{route:n})}),i.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-6",children:l})]})}function zl(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 Kk(n,r){switch(n){case"PROJECT_ALREADY_EXISTS":return"同名书籍已存在,请换一个书名";case"SCHEMA_VERSION_MISMATCH":return r;case"VALIDATION_ERROR":return r;case"NO_PROJECT_OPEN":return"";case"CLIENT_NETWORK_ERROR":return"无法连接服务,请确认 ai-editor 服务已启动";default:return"导入失败,请稍后重试"}}function Qk(n,r){return n==="CLIENT_NETWORK_ERROR"?"无法连接服务,请确认 ai-editor 服务已启动":r}function Cc(n){const r=n.trim();return r===""?"请输入书名":/[\\/]|^\.+$|[\u0000-\u001f]/.test(r)?"书名不能包含 /、\\ 或为 . / ..":null}let Py=(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 Zk={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Ml={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Jk={disabled:!1,...Ml},Wk={valid(n){return n===null?null:n?{[Py.valid]:""}:{[Py.invalid]:""}}},e_={invalid:void 0,name:void 0,validityData:{state:Zk,errors:[],error:"",value:"",initialValue:null},setValidityData:un,disabled:void 0,touched:Ml.touched,setTouched:un,dirty:Ml.dirty,setDirty:un,filled:Ml.filled,setFilled:un,focused:Ml.focused,setFocused:un,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:Jk,markedDirtyRef:{current:!1},registerFieldControl:un,validation:{getValidationProps:(n,r=Ut)=>r,inputRef:{current:null},registerInput:un,commit:async()=>{},change:un}},t_=p.createContext(e_);function U1(n=!0){const r=p.useContext(t_);if(r.setValidityData===un&&!n)throw new Error(En(28));return r}const n_=p.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:un,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function s_(){return p.useContext(n_)}const r_=p.createContext({controlId:void 0,registerControlId:un,labelId:void 0,setLabelId:un,messageIds:[],setMessageIds:un,getDescriptionProps:n=>n});function H1(){return p.useContext(r_)}function o_(n={}){const{id:r,implicit:o=!1,controlRef:l}=n,{controlId:c,registerControlId:d}=H1(),m=Co(r),g=o?c:void 0,b=zn(()=>Symbol("labelable-control")),h=p.useRef(!1),v=p.useRef(r!=null),x=nt(()=>{!h.current||d===un||(h.current=!1,d(b.current,void 0))});return Ge(()=>{if(d===un)return;let S;if(o){const j=l?.current;xt(j)&&j.closest("label")!=null?S=r??null:S=g??m}else if(r!=null)v.current=!0,S=r;else if(v.current)S=m;else{x();return}if(S===void 0){x();return}h.current=!0,d(b.current,S)},[r,l,g,d,o,m,b,x]),p.useEffect(()=>x,[x]),c??m}function a_(n,r,o,l,c=!0,d){const{registerFieldControl:m}=U1(),g=p.useRef(null);g.current||(g.current=Symbol()),Ge(()=>{const b=g.current;return!b||!c?void 0:(m(b,{controlRef:n,getValue:l,id:r,name:d,value:o}),()=>{m(b,void 0)})},[n,c,l,r,d,m,o])}const l_=p.forwardRef(function(r,o){const{render:l,className:c,id:d,name:m,value:g,disabled:b=!1,onValueChange:h,defaultValue:v,autoFocus:x=!1,style:S,...j}=r,{state:N,name:k,disabled:O,setTouched:E,setDirty:T,validityData:_,setFocused:w,setFilled:I,validationMode:A,validation:U}=U1(),{clearErrors:M}=s_(),K=O||b,oe=k??m,Z={...N,disabled:K},{labelId:ee}=H1(),G=o_({id:d});Ge(()=>{const L=g!=null;U.inputRef.current?.value||L&&g!==""?I(!0):L&&g===""&&I(!1)},[U.inputRef,I,g]);const te=p.useRef(null);Ge(()=>{x&&te.current===jn(vt(te.current))&&w(!0)},[x,w]);const[X]=hw({controlled:g,default:v,name:"FieldControl",state:"value"}),C=g!==void 0,B=C?X:void 0,H=nt(()=>U.inputRef.current?.value);return a_(U.inputRef,G,B,H,!K,m),fn("input",r,{ref:[o,te],state:Z,props:[{id:G,disabled:K,name:oe,ref:U.inputRef,"aria-labelledby":ee,autoFocus:x,...C?{value:B}:{defaultValue:v},onChange(L){const D=L.currentTarget.value;h?.(D,jt(f0,L.nativeEvent)),T(D!==_.initialValue),I(D!==""),L.nativeEvent.defaultPrevented||(M(oe),U.change(D))},onFocus(){w(!0)},onBlur(L){E(!0),w(!1),A==="onBlur"&&U.commit(L.currentTarget.value)},onKeyDown(L){L.currentTarget.tagName==="INPUT"&&L.key==="Enter"&&(E(!0),U.commit(L.currentTarget.value))}},j,L=>U.getValidationProps(K,L)],stateAttributesMapping:Wk})}),i_=p.forwardRef(function(r,o){return i.jsx(l_,{ref:o,...r})});function Ot({className:n,type:r,...o}){return i.jsx(i_,{type:r,"data-slot":"input",className:et("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),...o})}function c_(n){const r=new Date(n);if(Number.isNaN(r.getTime()))return n;const o=c=>String(c).padStart(2,"0");return r.getFullYear()===new Date().getFullYear()?`${o(r.getMonth()+1)}-${o(r.getDate())}`:`${String(r.getFullYear()).slice(-2)}-${o(r.getMonth()+1)}-${o(r.getDate())}`}function u_(){const n=St(m=>m.sessions),r=St(m=>m.sessionsLoading),o=St(m=>m.sessionsError),l=St(m=>m.loadSessions),c=St(m=>m.currentSessionId),d=St(m=>m.setCurrentSession);return p.useEffect(()=>{n===null&&!r&&o===null&&l()},[n,r,o,l]),n===null?o!==null?o==="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(Se,{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:et("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(Ll,{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:xo(m.updatedAt)})]})},m.id))})}function d_(){const{theme:n,toggleTheme:r}=B1(),o=Ae(fe=>fe.config),l=Ae(fe=>fe.bookshelf),c=Ae(fe=>fe.bookshelfLoading),d=Ae(fe=>fe.bookshelfError),m=Ae(fe=>fe.loadBookshelf),g=Ae(fe=>fe.openProjectAt),b=Ae(fe=>fe.createProjectAt),[h,v]=p.useState(null),[x,S]=p.useState(!1),[j,N]=p.useState(""),[k,O]=p.useState(null),[E,T]=p.useState(!1),[_,w]=p.useState(!1),[I,A]=p.useState(null),[U,M]=p.useState(""),[K,oe]=p.useState(null),[Z,ee]=p.useState(!1),[G,te]=p.useState(!1),[X,C]=p.useState(""),[B,H]=p.useState(!1),[z,L]=p.useState(null),[D,q]=p.useState(""),[V,Q]=p.useState(null),[ne,F]=p.useState(!1),Te=p.useRef(null);p.useEffect(()=>{!c&&l===null&&d===null&&m()},[c,l,d,m]);async function me(fe){try{await g(fe),v(fe)}catch(be){ke.getState().showToast(zl(be instanceof Ie?be.code:null),"error")}}const he=o?.id??null,Le=p.useRef(he);p.useEffect(()=>{Le.current!==he&&(Le.current=he,v(null),L(null))},[he]);function Ve(){N(""),O(null),S(!1)}async function Re(fe){fe.preventDefault();const be=j.trim(),qe=Cc(be);if(qe!==null){O(qe);return}if(!l){O("书架未加载,请稍后重试");return}T(!0),O(null);try{await b(Bv(l.rootPath,be),{name:be,language:"zh"}),ke.getState().showToast(`已创建并打开《${be}》`),await m();const se=Ae.getState().bookshelf?.books.find(Y=>Y.name===be);se&&v(se.path),N(""),S(!1)}catch(se){O(zl(se instanceof Ie?se.code:null))}finally{T(!1)}}async function ze(fe){if(!B){H(!0);try{const{blob:be,filename:qe}=await vT(),se=URL.createObjectURL(be),Y=document.createElement("a");Y.href=se,Y.download=qe,document.body.appendChild(Y),Y.click(),Y.remove(),setTimeout(()=>URL.revokeObjectURL(se),0),ke.getState().showToast(`已导出《${fe}》备份`)}catch(be){ke.getState().showToast(Qk(be instanceof Ie?be.code:null,be instanceof Ie?be.message:"导出失败,请重试"),"error")}finally{H(!1)}}}function De(fe){const be=fe.target.files?.[0]??null;if(A(be),oe(null),be){const qe=be.name.replace(/\.zip$/i,""),se=U.trim()===""?qe:U;M(se),ye(se)}}function ye(fe){const be=fe.trim(),qe=se=>l?.books.some(Y=>Y.name===se)??!1;if(G){if(be===`${X} (2)`||be===X&&qe(be))return;if(qe(be)){C(be),M(`${be} (2)`);return}te(!1),C("");return}be!==""&&qe(be)&&(C(be),te(!0),M(`${be} (2)`))}function Be(fe){const be=fe.target.value;M(be),ye(be)}async function ae(fe,be){const qe=fe.trim();if(!I){oe("请选择备份文件");return}const se=Cc(qe);if(se!==null){oe(se);return}ee(!0),oe(null);try{const Y=await ST(I,qe);ke.getState().showToast(Y.mode==="restored"?`已恢复备份《${Y.name}》`:`已导入为新书《${Y.name}》`),await m(),w(!1),A(null),M(""),te(!1),C("")}catch(Y){const ge=Kk(Y instanceof Ie?Y.code:null,Y instanceof Ie?Y.message:"导入失败,请重试");oe(ge),ge!==""&&ke.getState().showToast(ge,"error")}finally{ee(!1)}}function de(fe){L(fe.path),q(fe.name),Q(null),window.setTimeout(()=>Te.current?.focus(),150)}function ue(){L(null),q(""),Q(null)}async function Ce(){if(z===null||ne)return;const fe=D.trim();if(fe===Ae.getState().config?.name){ue();return}const be=Cc(fe);if(be!==null){Q(be);return}F(!0),Q(null);try{await TT(fe),ke.getState().showToast(`已重命名为《${fe}》`),await Promise.all([m(),Ae.getState().loadConfig()]),ue()}catch(qe){(qe instanceof Ie?qe.code:null)==="PROJECT_ALREADY_EXISTS"?Q("书架已有同名书籍,请换一个名字"):qe instanceof Ie&&qe.code!==ct?Q(qe.message):Q("无法连接服务,请确认 ai-editor 服务已启动")}finally{F(!1)}}return i.jsxs("aside",{className:"flex min-w-0 flex-[1_1_10%] flex-col border-r border-border bg-sidebar",children:[i.jsxs("a",{href:"#/",className:"flex h-12 shrink-0 items-center gap-1.5 border-b border-border 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:"我的小说"})]}),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(Se,{variant:"ghost",size:"icon-xs",onClick:()=>w(!0),"aria-label":"导入备份",title:"导入备份(zip)",children:i.jsx(Gj,{})}),x?i.jsx(Se,{variant:"ghost",size:"icon-xs",onClick:Ve,"aria-label":"取消新建项目",title:"取消新建",children:i.jsx(or,{})}):i.jsx(Se,{variant:"ghost",size:"icon-xs",onClick:()=>S(!0),"aria-label":"新建项目",title:"新建项目",children:i.jsx(Om,{})})]})]}),x&&i.jsxs("form",{onSubmit:Re,className:"mb-1 flex flex-col gap-1 px-1","aria-label":"新建项目",children:[i.jsx(Ot,{value:j,onChange:fe=>N(fe.target.value),onKeyDown:fe=>{fe.key==="Escape"&&Ve()},onBlur:Ve,placeholder:"书名,回车创建",maxLength:60,disabled:E,autoFocus:!0,"aria-label":"书名"}),k&&i.jsx("p",{className:"text-xs text-destructive",children:k})]}),d!==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:d===ct?"无法连接服务":"书架加载失败"}),i.jsx(Se,{variant:"ghost",size:"xs",onClick:()=>{m()},children:"重试"})]}),c&&l===null&&i.jsx("div",{className:"space-y-1 px-1 py-2",children:[0,1,2].map(fe=>i.jsx("div",{className:"h-8 animate-pulse rounded-lg bg-muted"},fe))}),d===null&&!c&&l&&l.books.length===0&&i.jsx("p",{className:"px-1 py-2 text-xs text-muted-foreground/70",children:"还没有书,先创建一本"}),d===null&&l&&l.books.length>0&&i.jsx("ul",{className:"space-y-0.5",children:l.books.map(fe=>{const be=h===fe.path,qe=o!==null&&fe.name===o.name,se=z===fe.path;return i.jsxs("li",{children:[i.jsxs("div",{className:"flex items-center",children:[se?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(Oc,{className:"size-3.5 shrink-0 text-primary"}),i.jsx(Ot,{ref:Te,value:D,onChange:Y=>q(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"?(Y.preventDefault(),Ce()):Y.key==="Escape"&&ue()},onBlur:()=>{Ce()},maxLength:60,disabled:ne,"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:`打开《${fe.name}》`,onClick:()=>{me(fe.path)},className:et("flex h-8 min-w-0 flex-1 items-center gap-1.5 rounded-lg px-2 text-left text-sm transition-colors",qe?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[i.jsx(Oc,{className:et("size-3.5 shrink-0",qe?"text-primary":"text-muted-foreground/60")}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:fe.name}),i.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground/60",title:ls(fe.updatedAt),children:c_(fe.updatedAt)})]}),qe&&i.jsx("button",{type:"button",onClick:()=>{ze(fe.name)},disabled:B,"aria-label":`导出《${fe.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(Pc,{className:"size-3.5 animate-spin"}):i.jsx(rj,{className:"size-3.5"})}),i.jsx("button",{type:"button",onClick:()=>v(Y=>Y===fe.path?null:fe.path),"aria-expanded":be,"aria-label":be?`收起《${fe.name}》会话`:`展开《${fe.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(Rv,{className:et("size-4 transition-transform duration-200",be&&"rotate-90")})}),qe&&i.jsxs(cu,{children:[i.jsx(uu,{render:i.jsx("button",{type:"button","aria-label":`《${fe.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(Rm,{className:"size-3.5"})})}),i.jsx(du,{children:i.jsx(ds,{onClick:()=>de(fe),children:"重命名"})})]})]}),se&&V&&i.jsx("p",{className:"px-2 pb-1 text-xs text-destructive",children:V}),be&&i.jsx(u_,{})]},fe.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(Ij,{className:"size-4 shrink-0"}),i.jsx("span",{className:"truncate",children:"设置"})]}),i.jsxs(Se,{variant:"ghost",size:"sm",className:"justify-start text-muted-foreground",onClick:r,"aria-label":"切换主题",children:[n==="dark"?i.jsx(Pj,{className:"size-4 shrink-0"}):i.jsx(vj,{className:"size-4 shrink-0"}),i.jsx("span",{className:"truncate",children:n==="dark"?"浅色模式":"深色模式"})]})]}),i.jsx(Ks,{open:_,onOpenChange:fe=>{w(fe),fe||(oe(null),A(null),M(""),te(!1),C(""))},children:i.jsxs(Qs,{className:"sm:max-w-sm",children:[i.jsxs(Zs,{children:[i.jsx(Ws,{children:"导入书籍"}),i.jsx(Uk,{children:"从备份 zip 导入;与书架已有书 id 匹配时覆盖恢复,否则导入为新书(同名可重命名或保持原样并存)"})]}),i.jsxs("form",{id:"import-book-form",onSubmit:fe=>{fe.preventDefault(),ae(U)},className:"flex flex-col gap-3",children:[i.jsx("input",{type:"file",accept:".zip,application/zip",onChange:De,disabled:Z,"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(Ot,{value:U,onChange:Be,placeholder:"书名(默认取文件名)",maxLength:60,disabled:Z}),G&&i.jsxs("p",{className:"text-sm text-primary",children:["书架已有同名书籍《",X,"》——可重命名导入,或保持原样(服务端自动去重)"]}),K&&i.jsx("p",{className:"text-sm text-destructive",children:K})]}),i.jsxs(Js,{children:[i.jsx(Se,{variant:"outline",type:"button",onClick:()=>w(!1),disabled:Z,children:"取消"}),G?i.jsxs(i.Fragment,{children:[i.jsx(Se,{variant:"outline",type:"button",onClick:()=>{ae(X)},disabled:Z||I===null,children:Z?"导入中…":"保持原样导入"}),i.jsx(Se,{type:"button",onClick:()=>{ae(U)},disabled:Z||I===null,children:Z?"导入中…":"重命名导入"})]}):i.jsx(Se,{type:"submit",form:"import-book-form",disabled:Z||I===null,children:Z?"导入中…":"导入"})]})]})})]})}function f_({route:n,children:r}){const[o,l]=p.useState(!1);return i.jsxs("div",{className:"flex h-screen overflow-hidden",children:[i.jsx(d_,{}),i.jsx($k,{route:n,chatOpen:o,onToggleChat:()=>l(c=>!c),children:r}),i.jsx(XO,{open:o,onClose:()=>l(!1)}),i.jsx(qk,{})]})}class m_ extends p.Component{state={error:null};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,o){console.error("[ErrorBoundary] 渲染异常:",r,o.componentStack)}render(){const{error:r}=this.state;return r===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(wm,{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:r.message||String(r)}),i.jsxs("div",{className:"mt-2 flex gap-2",children:[i.jsxs(Se,{type:"button",onClick:()=>window.location.reload(),children:[i.jsx(Aj,{className:"size-4"}),"重新加载"]}),i.jsx(Se,{variant:"outline",type:"button",onClick:()=>{window.location.hash="#/",window.location.reload()},children:"回到首页"})]})]})})}}function Cs(n){const r=ke(l=>l.dataVersion),o=p.useRef(r);p.useEffect(()=>{r!==o.current&&(o.current=r,n())},[r])}const Vy={character:"人物",setting:"设定",location:"地点",hook:"伏笔",event:"事件"},qy=["character","setting","location","hook"];function p_(n){const r={volumes:0,chapters:0,scenes:0,updatedAt:null},o=l=>{for(const c of l)c.type==="volume"?r.volumes+=1:c.type==="chapter"?r.chapters+=1:r.scenes+=1,(r.updatedAt===null||c.updatedAt>r.updatedAt)&&(r.updatedAt=c.updatedAt),c.type!=="scene"&&c.children&&o(c.children)};return o(n),r}function Xf(n){return n instanceof Ie?n.code:null}function Fy(){const n=Ae(ye=>ye.config),r=Ae(ye=>ye.configLoading),o=Ae(ye=>ye.outline),l=Ae(ye=>ye.outlineLoading),c=Ae(ye=>ye.loadOutline),d=Ae(ye=>ye.bookshelf),m=Ae(ye=>ye.bookshelfLoading),g=Ae(ye=>ye.bookshelfError),b=Ae(ye=>ye.loadBookshelf),h=Ae(ye=>ye.openProjectAt),v=Ae(ye=>ye.createProjectAt),x=St(ye=>ye.sessions),S=St(ye=>ye.sessionsLoading),j=St(ye=>ye.sessionsError),N=St(ye=>ye.loadSessions),k=St(ye=>ye.setCurrentSession),O=St(ye=>ye.currentSessionId),E=ke(ye=>ye.setFocusOutlineNode),[T,_]=p.useState(""),[w,I]=p.useState(null),[A,U]=p.useState(null),[M,K]=p.useState(!1),[oe,Z]=p.useState(!1),[ee,G]=p.useState(""),[te,X]=p.useState(null),[C,B]=p.useState(!1),[H,z]=p.useState(null),[L,D]=p.useState(!1),[q,V]=p.useState(null),[Q,ne]=p.useState(0),[F,Te]=p.useState(!1),me=n===null&&!r,he=o?p_(o.children):null,Le=n?.currentPosition!=null?Iv(o,n.currentPosition)??n.currentPosition:null;p.useEffect(()=>{me&&!m&&d===null&&g===null&&b()},[me,m,d,g,b]),p.useEffect(()=>{Te(!1)},[n?.id]),Cs(()=>{ne(ye=>ye+1),c(),N()}),p.useEffect(()=>{U(null)},[n?.id]),p.useEffect(()=>{n!==null&&o===null&&!l&&!F&&(Te(!0),c())},[n,o,l,F,c]),p.useEffect(()=>{if(n===null)return;let ye=!1;return z(null),D(!0),V(null),Promise.allSettled(qy.map(async Be=>({type:Be,total:(await bo(Be,{limit:1})).total}))).then(Be=>{if(ye)return;const ae={};let de=!1;for(const ue of Be)ue.status==="fulfilled"?ae[ue.value.type]=ue.value.total:de=!0;z(ae),V(de?"要素统计加载失败":null),D(!1)}),()=>{ye=!0}},[n,Q]),p.useEffect(()=>{n!==null&&x===null&&!S&&j===null&&N()},[n,x,S,j,N]);async function Ve(ye){ye.preventDefault();const Be=T.trim(),ae=Cc(Be);if(ae!==null){I(ae);return}if(!d){I("书架未加载,请稍后重试");return}B(!0),I(null);try{await v(Bv(d.rootPath,Be),{name:Be,language:"zh"}),await b(),ke.getState().showToast(`已创建并打开《${Be}》`),_("")}catch(de){I(zl(Xf(de)))}finally{B(!1)}}async function Re(ye){if(ye.preventDefault(),!ee.trim()){X("请输入项目目录路径(绝对路径)");return}B(!0),X(null);try{await h(ee.trim())}catch(Be){X(zl(Xf(Be)))}finally{B(!1)}}async function ze(ye){U(null);try{await h(ye)}catch(Be){U(zl(Xf(Be)))}}function De(){n?.currentPosition!=null&&E(n.currentPosition)}if(r)return i.jsx("section",{children:i.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"加载中…"})});if(me){let ye=function(ue){return i.jsxs("form",{onSubmit:Ve,className:ue,children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Ot,{value:T,onChange:Ce=>_(Ce.target.value),placeholder:"书名",maxLength:60,disabled:C}),i.jsx(Se,{type:"submit",disabled:C||d===null,children:"新建"})]}),w&&i.jsx("p",{className:"text-left text-sm text-destructive",children:w})]})};const Be=d===null&&m,ae=g!==null,de=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===ct?"无法连接服务,请确认 ai-editor 服务已启动后重试。":"书架加载失败,请重试。"}),i.jsx(Se,{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:Be?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:[de?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(ue=>i.jsx("li",{children:i.jsxs("button",{type:"button",title:`打开《${ue.name}》`,onClick:()=>{ze(ue.path)},className:"flex w-full items-center gap-3 px-3 py-2.5 text-left transition-colors hover:bg-muted",children:[i.jsx(Oc,{className:"size-4 shrink-0 text-muted-foreground/60"}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:ue.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:xo(ue.updatedAt)})]})},ue.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(ue=>!ue),children:M?"收起":"新建一本…"}),M&&ye("mt-2 flex flex-col gap-2 text-left")]})]}):ae?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/书名/),写作数据互不干扰"}),ye("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:()=>Z(ue=>!ue),children:oe?"收起":"打开其他路径…"}),oe&&i.jsxs("form",{onSubmit:Re,className:"mt-2 flex flex-col gap-2 text-left",children:[i.jsx(Ot,{value:ee,onChange:ue=>G(ue.target.value),placeholder:"/absolute/path/to/project(须含 project.json)",disabled:C}),i.jsx("div",{children:i.jsx(Se,{type:"submit",variant:"outline",disabled:C,children:"打开"})}),te&&i.jsx("p",{className:"text-sm text-destructive",children:te})]})]})]})})]})}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:De,className:"text-primary hover:underline",children:Le??n.currentPosition}):i.jsx("span",{className:"text-muted-foreground",children:"未设置"})}),i.jsx("a",{href:"#/outline",onClick:De,className:am({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:"创作要素"}),L&&H===null?i.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[0,1,2,3].map(ye=>i.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-muted"},ye))}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2",children:qy.map(ye=>i.jsxs("a",{href:`#/entities/${ye}`,className:"group rounded-lg border border-border bg-background p-3 transition-colors hover:border-primary/40 hover:bg-muted",title:`查看${Vy[ye]}列表`,children:[i.jsx("p",{className:"font-serif text-2xl font-semibold text-foreground",children:H?.[ye]??"–"}),i.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground transition-colors group-hover:text-foreground",children:Vy[ye]})]},ye))}),q!==null&&i.jsxs("div",{className:"mt-2 flex items-center gap-2 text-xs text-destructive",children:[q,i.jsx(Se,{variant:"outline",size:"xs",type:"button",onClick:()=>ne(ye=>ye+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:"大纲概览"}),o===null&&(l||!F)?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"})]}):o===null?i.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm text-muted-foreground",children:["大纲加载失败",i.jsx(Se,{variant:"outline",size:"xs",type:"button",onClick:()=>Te(!1),children:"重试"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"mt-3 text-sm text-foreground",children:["卷 ",he?.volumes??0," · 章 ",he?.chapters??0," · 场景"," ",he?.scenes??0]}),i.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["最近更新: ",he?.updatedAt?xo(he.updatedAt):"—"]}),o.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(Se,{variant:"ghost",size:"xs",type:"button",onClick:()=>k(null),children:"和 AI 聊聊设定"})]}),i.jsx("div",{className:"mt-3",children:i.jsx("a",{href:"#/outline",onClick:De,className:et(am({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(Se,{variant:"outline",size:"xs",type:"button",onClick:()=>{N()},children:"重试"})]}):i.jsx("div",{className:"mt-3 space-y-2",children:[0,1,2].map(ye=>i.jsx("div",{className:"h-8 animate-pulse rounded-md bg-muted"},ye))}):x.length===0?i.jsxs("div",{className:"mt-3",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"还没有会话,和 AI 聊聊设定吧"}),i.jsx(Se,{variant:"outline",size:"sm",className:"mt-3",type:"button",onClick:()=>k(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(ye=>i.jsx("li",{children:i.jsxs("button",{type:"button",title:ye.lastMessage||"空会话",onClick:()=>k(ye.id),className:et("flex w-full items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-muted",O===ye.id&&"bg-accent/40 hover:bg-accent/40"),children:[i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:ye.lastMessage||"(空会话)"}),i.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[ye.messageCount," 条消息"]}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:xo(ye.updatedAt)})]})},ye.id))}),i.jsx("div",{className:"mt-3",children:i.jsx(Se,{variant:"outline",size:"sm",type:"button",onClick:()=>k(null),children:"开始新对话"})})]})]})]})]})}const Gy={plants:"埋设",advances:"推进",resolves:"回收"},h_={plants:wj,advances:lj,resolves:Cm};function Y1({mark:n}){const r=h_[n.relationType];return i.jsx("span",{className:"shrink-0 rounded px-0.5 text-muted-foreground hover:text-foreground",title:`${Gy[n.relationType]}伏笔:${n.hookName}`,"aria-label":`${Gy[n.relationType]}伏笔:${n.hookName}`,children:i.jsx(r,{className:"size-3"})})}const jp=["plants","advances","resolves"],Xy=["plants","advances","resolves"];function $y(n){const r=Xy.indexOf(n);return r===-1?Xy.length:r}function P1(n){const r=new Map;for(const o of n){if(!jp.includes(o.relationType)||o.sourceType!=="outline_node"||o.targetType!=="hook")continue;const l={relationType:o.relationType,hookId:o.targetId,hookName:o.targetName??o.targetId},c=r.get(o.sourceId);c===void 0?r.set(o.sourceId,[l]):c.push(l)}for(const o of r.values())o.sort((l,c)=>$y(l.relationType)-$y(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 r}const Sn="root",Ky={id:Sn,label:"(根)",depth:0};function g_(n,r){if(r==="volume")return[Ky];const o=r==="chapter"?[Ky]:[],l=(c,d)=>{for(const m of c)r==="chapter"&&m.type==="volume"?o.push({id:m.id,label:m.title,depth:d}):r==="scene"&&m.type==="chapter"&&o.push({id:m.id,label:m.title,depth:d}),m.children&&l(m.children,d+1)};return l(n,1),o}function Br(n,r){for(const o of n){if(o.id===r)return o;if(o.type!=="scene"&&o.children){const l=Br(o.children,r);if(l)return l}}return null}function Tp(n,r,o=[]){for(const l of n){const c=[...o,l.id];if(l.id===r)return c;if(l.type!=="scene"&&l.children){const d=Tp(l.children,r,c);if(d)return d}}return null}function rr(n,r=0,o=[]){for(const l of n)o.push({id:l.id,label:l.title,depth:r}),l.type!=="scene"&&l.children&&rr(l.children,r+1,o);return o}function x_(n,r,o){const l=Br(n,r);if(!l)return!1;const c=d=>d.id===o?!0:d.type!=="scene"&&d.children?d.children.some(m=>c(m)):!1;return c(l)}function vc(n,r,o){return r===n.id||x_(o,n.id,r)?!1:g_(o,n.type).some(l=>l.id===r)}function V1(n,r){const o=r.trim();return o!==""&&o!==n.trim()}function q1(n,r){return r.trim()!==(n??"").trim()}function b_(n){return n==="OUTLINE_NODE_NOT_FOUND"?"abandon":"restore"}function F1(n,r){if(r===Sn)return n;const o=l=>{for(const c of l){if(c.id===r)return c.children??[];if(c.children){const d=o(c.children);if(d)return d}}return null};return o(n)}function Qy(n,r,o){const l=o===void 0?n:n.filter(d=>d.id!==o);if(r.kind==="end")return l.length;const c=l.findIndex(d=>d.id===r.nodeId);return c===-1?l.length:r.kind==="before"?c:c+1}function Zy(n,r){return n===null||r===null?n===r:n.kind==="root-end"||r.kind==="root-end"?n.kind===r.kind:n.kind===r.kind&&n.nodeId===r.nodeId}function Sm(n,r){const o=(l,c)=>{for(const d of l){if(d.id===r)return c;if(d.children){const m=o(d.children,d.id);if(m!==null)return m}}return null};return o(n,Sn)}function y_(n,r){const o=Sm(n,r);if(o===null)return null;const c=(F1(n,o)??[]).findIndex(d=>d.id===r);return c===-1?null:{parentId:o,index:c}}function Jy(n,r,o,l){const c=y_(n,r);return c===null||c.parentId!==o?!1:l===c.index}function Sc(n){return n instanceof Ie?n.code:null}function ga(n){switch(n){case"OUTLINE_NODE_NOT_FOUND":return"节点不存在(可能已被彻底删除),大纲已刷新";case"CLIENT_NETWORK_ERROR":return"无法连接服务,请确认 ai-editor 服务已启动";default:return"操作失败,请稍后重试"}}function Rc(n,r,o,l,c){return i.jsx("input",{autoFocus:!0,value:n,onChange:d=>r(d.target.value),onKeyDown:o,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 Wy({type:n,onTypeChange:r,value:o,onChange:l,onKeyDown:c,onCancel:d,className:m}){return i.jsxs("div",{className:et("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:()=>r(g),className:et("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:rs[g]},g))}),Rc(o,l,c,d,`新${rs[n]}标题,Enter 创建`)]})}function v_(){const n=Ae(Y=>Y.outline),r=Ae(Y=>Y.outlineLoading),o=Ae(Y=>Y.config),l=Ae(Y=>Y.configLoading),c=Ae(Y=>Y.loadOutline),d=ke(Y=>Y.focusOutlineNodeId),m=ke(Y=>Y.clearFocusOutlineNode);Cs(()=>{c()});const[g,b]=p.useState(!1),[h,v]=p.useState(null),[x,S]=p.useState(new Set),[j,N]=p.useState(null),[k,O]=p.useState(!1),[E,T]=p.useState(null),[_,w]=p.useState(null),[I,A]=p.useState(null),[U,M]=p.useState(""),[K,oe]=p.useState(null),[Z,ee]=p.useState(""),[G,te]=p.useState(null),[X,C]=p.useState(null),[B,H]=p.useState(null),z=o===null&&!l;p.useEffect(()=>{n===null&&!r&&!g&&(b(!0),c())},[n,r,g,c]),p.useEffect(()=>{if(n===null){H(null);return}let Y=!1;return Promise.all(jp.map(ge=>ja({source_type:"outline_node",relation_type:ge,depth:1}).then(J=>J.relations).catch(()=>[]))).then(ge=>{Y||H(P1(ge.flat()))}),()=>{Y=!0}},[n]),p.useEffect(()=>{if(E===null)return;const Y=setTimeout(()=>T(null),3e3);return()=>clearTimeout(Y)},[E]),p.useEffect(()=>{if(d===null||n===null)return;const Y=d,ge=Tp(n.children,Y);if(ge===null){m();return}S(we=>{if(ge.every(je=>!we.has(je)))return we;const Xe=new Set(we);for(const je of ge)Xe.delete(je);return Xe});const J=setTimeout(()=>{const we=document.querySelector(`[data-node-id="${Y}"]`);we&&(we.scrollIntoView({block:"center"}),w(Y)),m()},0);return()=>clearTimeout(J)},[d,n,m]),p.useEffect(()=>{if(_===null)return;const Y=setTimeout(()=>w(null),3e3);return()=>clearTimeout(Y)},[_]);async function L(Y,ge){Y&&q(Y),await c(),ge&&T(ge)}function D(Y){S(ge=>{const J=new Set(ge);return J.has(Y)?J.delete(Y):J.add(Y),J})}function q(Y){S(ge=>{if(!ge.has(Y))return ge;const J=new Set(ge);return J.delete(Y),J})}function V(Y,ge=[]){for(const J of Y)J.type!=="scene"&&J.children&&J.children.length>0&&(ge.push(J.id),V(J.children,ge));return ge}function Q(Y,ge){he(),A({nodeId:Y.id,field:ge}),M(ge==="title"?Y.title:Y.summary??"")}function ne(){A(null),M("")}async function F(Y,ge){if(!I||I.nodeId!==Y.id||I.field!==ge||k)return;const J=U;if(!(ge==="title"?V1(Y.title,J):q1(Y.summary,J))){ne();return}O(!0);try{await zv(Y.id,ge==="title"?{title:J.trim()}:{summary:J.trim()}),ne(),ke.getState().showToast("已保存"),await L()}catch(Xe){const je=Sc(Xe);if(b_(je)==="abandon"){ne(),v(ga(je)),await L();return}v(ga(je))}finally{O(!1)}}function Te(Y,ge){return J=>{J.key==="Enter"?(J.preventDefault(),F(Y,ge)):J.key==="Escape"&&ne()}}function me(Y,ge){ne(),oe({parentId:Y,type:ge}),ee(""),Y!==Sn&&q(Y)}function he(){oe(null),ee("")}async function Le(){if(!K)return;const Y=Z.trim(),{parentId:ge,type:J}=K;if(!Y){he();return}he();try{const we=await oT({type:J,title:Y,parent_id:ge});ke.getState().showToast(`已创建${rs[J]}《${Y}》`),await L(ge,we.id)}catch(we){v(ga(Sc(we)))}}function Ve(Y){Y.key==="Enter"?(Y.preventDefault(),Le()):Y.key==="Escape"&&he()}function Re(Y,ge){Y.dataTransfer.setData("text/plain",ge.id),Y.dataTransfer.effectAllowed="move",te(ge.id),C(null)}function ze(){te(null),C(null)}function De(Y){const ge=Y.currentTarget.getBoundingClientRect();return Y.clientY<ge.top+ge.height/2?"before":"after"}function ye(Y,ge){Y.stopPropagation();const J=G?Br(n?.children??[],G):null;if(!J)return;const we=Sm(n?.children??[],ge)??Sn;if(!vc(J,we,n?.children??[]))return;Y.preventDefault(),Y.dataTransfer.dropEffect="move";const Xe={kind:De(Y),nodeId:ge};C(je=>Zy(je,Xe)?je:Xe)}function Be(Y,ge){Y.currentTarget.contains(Y.relatedTarget)||C(J=>J!==null&&J.kind!=="root-end"&&J.nodeId===ge?null:J)}async function ae(Y,ge){if(Y.stopPropagation(),Y.preventDefault(),!G)return;const J=Br(n?.children??[],G);if(!J)return;const we=Sm(n?.children??[],ge)??Sn;if(!vc(J,we,n?.children??[]))return;if(ge===J.id){te(null),C(null);return}const Xe=F1(n?.children??[],we)??[],je=Qy(Xe,{kind:De(Y),nodeId:ge},J.id);if(Jy(n?.children??[],J.id,we,je)){te(null),C(null);return}O(!0);try{await Bb(J.id,{parent_id:we,order:je}),ke.getState().showToast(`已移动《${J.title}》`),await L(we)}catch(Me){v(ga(Sc(Me)))}finally{O(!1),te(null),C(null)}}function de(Y){const ge=G?Br(n?.children??[],G):null;!ge||!vc(ge,Sn,n?.children??[])||(Y.preventDefault(),Y.dataTransfer.dropEffect="move",C(J=>Zy(J,{kind:"root-end"})?J:{kind:"root-end"}))}function ue(Y){Y.currentTarget.contains(Y.relatedTarget)||C(ge=>ge?.kind==="root-end"?null:ge)}async function Ce(Y){if(Y.preventDefault(),!G)return;const ge=Br(n?.children??[],G);if(!ge||!vc(ge,Sn,n?.children??[]))return;const J=Qy(n?.children??[],{kind:"end"},ge.id);if(Jy(n?.children??[],ge.id,Sn,J)){te(null),C(null);return}O(!0);try{await Bb(ge.id,{parent_id:Sn,order:J}),ke.getState().showToast(`已移动《${ge.title}》`),await L()}catch(we){v(ga(Sc(we)))}finally{O(!1),te(null),C(null)}}async function fe(){if(j)try{const Y=await aT(j.id),{children:ge,relations:J,deltas:we}=Y.cascaded,Xe=[];ge>0&&Xe.push(`${ge} 个子节点`),J>0&&Xe.push(`${J} 条关联`),we>0&&Xe.push(`${we} 条变化记录`),ke.getState().showToast(`已移入回收站${Xe.length>0?`(含 ${Xe.join("、")})`:""}`),N(null),await L()}catch(Y){if(Y instanceof Ie&&Y.code==="OUTLINE_NODE_NOT_FOUND"){v(ga("OUTLINE_NODE_NOT_FOUND")),N(null),await L();return}throw Y}}function be(){return K?.parentId!==Sn?null:i.jsx(Wy,{className:"mb-1",type:K.type,onTypeChange:Y=>oe({parentId:Sn,type:Y}),value:Z,onChange:ee,onKeyDown:Ve,onCancel:he})}function qe(Y,ge){return Y.map(J=>{const we=J.type!=="scene"&&(J.children?.length??0)>0,Xe=x.has(J.id),je=o?.currentPosition===J.id,Me=Hk[J.type],$e=I?.nodeId===J.id&&I.field==="title",rt=I?.nodeId===J.id&&I.field==="summary",Nt=X?.kind==="before"&&X.nodeId===J.id,kt=X?.kind==="after"&&X.nodeId===J.id,bt=G===J.id,yn=K?.parentId===J.id,an=J.id===_;return i.jsxs("div",{children:[i.jsxs("div",{"data-node-id":J.id,draggable:!$e&&!rt&&!bt&&!k,onDragStart:Ke=>Re(Ke,J),onDragEnd:ze,onDragOver:Ke=>ye(Ke,J.id),onDragLeave:Ke=>Be(Ke,J.id),onDrop:Ke=>{ae(Ke,J.id)},className:et("relative cursor-grab rounded-md px-2 py-1 transition-colors hover:bg-muted/60 active:cursor-grabbing",J.id===E&&"bg-accent/40",an&&"bg-accent ring-1 ring-inset ring-ring",bt&&"opacity-50"),style:{paddingLeft:ge*20+8},title:"拖动到目标行即可移动(上半=插前、下半=插后)",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[we?i.jsx("button",{type:"button",className:"w-4 shrink-0 text-muted-foreground hover:text-foreground",onClick:()=>D(J.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:rs[J.type]}),$e?Rc(U,M,Te(J,"title"),()=>{F(J,"title")},"标题"):i.jsx("span",{className:et("min-w-0 cursor-text truncate text-sm hover:underline",an?"text-accent-foreground":"text-foreground"),title:"点击编辑标题",onClick:()=>Q(J,"title"),children:J.title}),B!==null&&(B.get(J.id)?.length??0)>0&&i.jsx("span",{className:"flex shrink-0 items-center gap-0.5",children:(B.get(J.id)??[]).map(Ke=>i.jsx(Y1,{mark:Ke},`${Ke.relationType}-${Ke.hookId}`))}),Me!==null&&i.jsx("button",{type:"button",className:"shrink-0 rounded px-1 text-muted-foreground hover:bg-muted hover:text-foreground",title:`就地新建${rs[Me]}`,"aria-label":`新建${rs[Me]}`,onClick:()=>me(J.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/${J.id}`),children:i.jsx(Oc,{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:()=>N(J),children:i.jsx(_v,{className:"size-3.5"})}),je&&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:ls(J.updatedAt)})]}),rt||J.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"}),rt?Rc(U,M,Te(J,"summary"),()=>{F(J,"summary")},"摘要"):i.jsx("span",{className:"min-w-0 cursor-text truncate text-xs text-muted-foreground hover:underline",title:"点击编辑摘要",onClick:()=>Q(J,"summary"),children:J.summary})]}):null,Nt&&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"})]}),we&&!Xe&&i.jsx("div",{children:qe(J.children??[],ge+1)}),yn&&i.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-1",style:{paddingLeft:(ge+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:rs[K.type]}),Rc(Z,ee,Ve,he,`新${rs[K.type]}标题,Enter 创建`)]})]},J.id)})}function se(){n&&(x.size>0?S(new Set):S(new Set(V(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(Se,{variant:"outline",type:"button",onClick:se,disabled:!n||n.children.length===0,children:x.size>0?"全部展开":"全部折叠"}),i.jsx(Se,{type:"button",onClick:()=>me(Sn,"volume"),children:"+ 新建"})]})]}),h&&i.jsx("div",{className:"mb-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:h}),z?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:"回到首页打开或创建书籍"})]}):r&&n===null?i.jsx("div",{className:"space-y-2 rounded-md border border-zinc-200 p-3",children:Array.from({length:6},(Y,ge)=>i.jsx("div",{className:"h-5 animate-pulse rounded bg-zinc-100",style:{width:`${92-ge%3*24}%`,marginLeft:ge%3*20}},ge))}):n===null?i.jsxs("div",{className:"rounded-md border border-zinc-200 p-4 text-sm text-zinc-600",children:["大纲加载失败",i.jsx(Se,{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(Wy,{type:K.type,onTypeChange:Y=>oe({parentId:Sn,type:Y}),value:Z,onChange:ee,onKeyDown:Ve,onCancel:he})})]}):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(Se,{className:"mt-4",type:"button",onClick:()=>me(Sn,"volume"),children:"新建第一卷"})]}):i.jsxs("div",{className:et("rounded-md border border-border p-2",X?.kind==="root-end"&&"ring-1 ring-inset ring-accent"),onDragOver:de,onDragLeave:ue,onDrop:Y=>{Ce(Y)},children:[be(),qe(n.children,0)]}),j&&i.jsx(ms,{title:"移入回收站",description:`将《${j.title}》移入回收站。子节点与关联的关系、变化记录将一并移入,可在回收站还原。`,confirmLabel:"移入回收站",danger:!0,onConfirm:fe,onClose:()=>N(null)})]})}const jl=20;function S_(n,r){return Math.max(1,Math.ceil(n/r))}const E_={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:"描述"}},wp={planted:"已埋设",progressing:"推进中",resolved:"已回收",abandoned:"已弃用"},Cp={immediate:"立即",near_term:"近期",mid_arc:"中段",slow_burn:"慢热",endgame:"终局"};function $f(n,r,o){return o==null||o===""?"—":n==="hook"&&r==="status"?wp[String(o)]??String(o):n==="hook"&&r==="payoff_timing"?Cp[String(o)]??String(o):String(o)}const ev={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"}};function Rp(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:wp},{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:Cp},{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:"time_label",label:"时间标注",control:"text"},{key:"tags",label:"标签",control:"tags"}]}}const N_={belongs_to:"所属",owns:"拥有",masters:"掌握",ally:"盟友",rival:"对手",mentor:"师徒",family:"家族",kills:"击杀",appears_in:"出现于",occurs_at:"发生于",plot_edge:"剧情连线",plants:"埋设",advances:"推进",resolves:"回收",depends_on:"依赖",involves:"涉及"};function ho(n){return N_[n]??n}function Op(n,r){const o={};for(const l of new Set([...Object.keys(n),...Object.keys(r)])){const c=r[l];if(c===void 0)continue;const d=tv(n[l]),m=tv(c);JSON.stringify(d)!==JSON.stringify(m)&&(o[l]=c)}return Object.keys(o).length>0?o:null}function tv(n){return n==null||n===""||Array.isArray(n)&&n.length===0?null:n}const Kf={character:"人物",setting:"设定",location:"地点",hook:"伏笔",event:"事件"},xa="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 kp({source:n,onCreated:r,onClose:o}){const l=Ae(M=>M.outline),[c,d]=p.useState("character"),[m,g]=p.useState(null),[b,h]=p.useState(""),[v,x]=p.useState("character"),[S,j]=p.useState(null),[N,k]=p.useState(""),[O,E]=p.useState(tm[0]),[T,_]=p.useState(null),[w,I]=p.useState(!1);p.useEffect(()=>{n||(h(""),g(null),bo(c,{limit:100}).then(M=>g(M.items)).catch(()=>g([])))},[n,c]),p.useEffect(()=>{if(k(""),v==="outline_node"){j(null);return}j(null),bo(v,{limit:100}).then(M=>j(M.items)).catch(()=>j([]))},[v]);const A=rr(l?.children??[]);async function U(M){if(M.preventDefault(),!n&&!b){_("请选择源实体");return}if(!N){_("请选择关联对象");return}I(!0),_(null);try{const K={source_type:n?n.type:c,source_id:n?n.id:b,target_type:v,target_id:N,relation_type:O};await Oa(K),ke.getState().showToast("已建立关系"),await r(),o()}catch(K){K instanceof Ie&&K.code==="RELATION_EXISTS"?_("这条关系已经存在"):_(K instanceof Ie?K.message:"创建失败,请重试")}finally{I(!1)}}return i.jsx(Ks,{open:!0,onOpenChange:M=>!M&&o(),children:i.jsxs(Qs,{className:"sm:max-w-2xl",children:[i.jsx(Zs,{children:i.jsx(Ws,{children:"新增关联"})}),i.jsxs("form",{id:"create-relation-form",onSubmit:U,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:M=>d(M.target.value),className:xa,children:Na.map(M=>i.jsx("option",{value:M,children:Kf[M]},M))}),i.jsxs("select",{value:b,onChange:M=>h(M.target.value),className:xa,children:[i.jsxs("option",{value:"",children:["选择",Kf[c],"…"]}),(m??[]).map(M=>i.jsx("option",{value:M.id,children:M.name},M.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:M=>E(M.target.value),className:xa,children:tm.map(M=>i.jsx("option",{value:M,children:ho(M)},M))}),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:M=>x(M.target.value),className:xa,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:N,onChange:M=>k(M.target.value),className:xa,children:[i.jsx("option",{value:"",children:"选择大纲节点…"}),A.map(M=>i.jsxs("option",{value:M.id,children:[" ".repeat(M.depth),M.label]},M.id))]}):i.jsxs("select",{value:N,onChange:M=>k(M.target.value),className:xa,children:[i.jsxs("option",{value:"",children:["选择",Kf[v],"…"]}),(S??[]).map(M=>i.jsx("option",{value:M.id,children:M.name},M.id))]})]})]}),T&&i.jsx("p",{className:"text-sm text-destructive",children:T})]}),i.jsxs(Js,{children:[i.jsx(Se,{variant:"outline",type:"button",onClick:o,disabled:w,children:"取消"}),i.jsx(Se,{type:"submit",form:"create-relation-form",disabled:w,children:"建立"})]})]})})}const G1={character:"人物",setting:"设定",location:"地点",hook:"伏笔",outline_node:"大纲节点"},nv={endpointType:"",relationType:"",nameQuery:""};function j_(n,r){const o=r.nameQuery.trim().toLowerCase();return n.filter(l=>{if(r.endpointType!==""&&l.sourceType!==r.endpointType&&l.targetType!==r.endpointType||r.relationType!==""&&l.relationType!==r.relationType)return!1;if(o){const c=(l.sourceName??l.sourceId).toLowerCase(),d=(l.targetName??l.targetId).toLowerCase();if(!c.includes(o)&&!d.includes(o))return!1}return!0})}function sv({type:n}){return i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:G1[n]??n})}function Qf({type:n,id:r,name:o}){const l=o??r;if(!(Na.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(sv,{type:n})]});const d=n==="outline_node"?`/outline/${r}`:`/entities/${n}/${r}`;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(sv,{type:n})]})}function rv(n,r){const o=r==="source"?n.sourceName:n.targetName,l=r==="source"?n.sourceId:n.targetId;return o??l}function X1({reloadKey:n,onOpenCreate:r,scope:o}){const[l,c]=p.useState(null),[d,m]=p.useState(!1),[g,b]=p.useState(null),[h,v]=p.useState(0),[x,S]=p.useState(nv),[j,N]=p.useState(null);p.useEffect(()=>{let E=!1;m(!0),b(null);const T=o!==void 0?{source_type:o.type,source_id:o.id,depth:1}:{depth:1};return ja(T).then(_=>{E||c(_.relations)}).catch(_=>{E||(c(null),b(_ instanceof Ie?_.code:ct))}).finally(()=>{E||m(!1)}),()=>{E=!0}},[n,h,o?.type,o?.id]);async function k(){if(j)try{await qc(j.id),ke.getState().showToast("已删除关系"),N(null),v(E=>E+1)}catch(E){throw E}}const O=l===null?[]:j_(l,x);return i.jsxs("div",{children:[o===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:E=>S(T=>({...T,endpointType:E.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(G1).map(([E,T])=>i.jsx("option",{value:E,children:T},E))]}),i.jsxs("select",{value:x.relationType,onChange:E=>S(T=>({...T,relationType:E.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:"全部关系类型"}),tm.map(E=>i.jsx("option",{value:E,children:ho(E)},E))]}),i.jsx(Ot,{value:x.nameQuery,onChange:E=>S(T=>({...T,nameQuery:E.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===ct?"无法连接服务,请确认 ai-editor 服务已启动。":"关系加载失败,请重试。",i.jsx(Se,{variant:"outline",className:"ml-3",type:"button",onClick:()=>v(E=>E+1),children:"重试"})]}),d&&l===null&&g===null&&i.jsx("div",{className:"overflow-hidden rounded-md border border-border",children:Array.from({length:5},(E,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(Se,{className:"mt-4",type:"button",onClick:r,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(Se,{variant:"outline",className:"mt-4",type:"button",onClick:()=>S(nv),children:"清空过滤"})]}),!d&&l!==null&&O.length>0&&i.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[o===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(E=>i.jsxs("li",{className:"flex items-center gap-2 px-3 py-2 text-sm",children:[o!==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:[ho(E.relationType)," →"]}),i.jsx("span",{className:"min-w-0 flex-1",children:i.jsx(Qf,{type:E.targetType,id:E.targetId,name:E.targetName})})]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"w-1/4 min-w-0 shrink-0",children:i.jsx(Qf,{type:E.sourceType,id:E.sourceId,name:E.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:[ho(E.relationType)," →"]}),i.jsx("span",{className:"min-w-0 flex-1",children:i.jsx(Qf,{type:E.targetType,id:E.targetId,name:E.targetName})})]}),i.jsx(Se,{variant:"outline",type:"button",className:"h-7 w-14 shrink-0 px-2 text-xs text-destructive hover:bg-destructive/10",onClick:()=>N(E),children:"删除"})]},E.id))})]}),j&&i.jsx(ms,{title:"删除关系",description:`删除关系「${rv(j,"source")} ${ho(j.relationType)} ${rv(j,"target")}」?物理删除不可恢复,可重新建立。`,confirmLabel:"删除",danger:!0,onConfirm:k,onClose:()=>N(null)})]})}const T_={set:"设为",update:"更新",add:"追加",remove:"移除"},w_={character:"人物",setting:"设定",location:"地点",hook:"伏笔",outline_node:"大纲节点"};function _p(n){return w_[n]??n}function os(n){return n==null?"空":typeof n=="object"?JSON.stringify(n):String(n)}function C_(n){switch(n.op){case"set":return`${n.field} = ${os(n.to)}`;case"update":return`${n.field} ${os(n.from)} → ${os(n.to)}`;case"add":return`${n.field} +${os(n.value??n.to)}`;case"remove":return`${n.field} -${os(n.value??n.to)}`}}function R_(n,r){const o=[];for(const l of new Set([...Object.keys(n),...Object.keys(r)])){const c=n[l]??null,d=r[l]??null;JSON.stringify(c)!==JSON.stringify(d)&&o.push({field:l,from:n[l],to:r[l]})}return o}function $1({changes:n,skipped:r}){const o=r?new Set(r):null;return i.jsx("div",{className:"flex flex-wrap items-center gap-1",children:n.map((l,c)=>{const d=o?.has(c)??!1;return i.jsxs("span",{title:d?"该变更未应用(数据与变更记录不一致,见冲突标注)":void 0,className:et("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:et("shrink-0 font-medium",d?"text-destructive":"text-foreground/70"),children:T_[l.op]}),C_(l)]},c)})})}function O_({nodeId:n,reloadKey:r}){const[o,l]=p.useState(null),[c,d]=p.useState(!1),[m,g]=p.useState(null),[b,h]=p.useState(0);return p.useEffect(()=>{let v=!1;return d(!0),g(null),mT(n).then(x=>{v||l([...x.deltas].sort((S,j)=>S.order-j.order))}).catch(x=>{v||g(x instanceof Ie?x.code:ct)}).finally(()=>{v||d(!1)}),()=>{v=!0}},[n,b,r]),i.jsxs("div",{children:[c&&o===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===ct?"无法连接服务,请确认 ai-editor 服务已启动":"变更记录加载失败"}),m!=="OUTLINE_NODE_NOT_FOUND"&&i.jsx(Se,{variant:"outline",size:"xs",type:"button",onClick:()=>h(v=>v+1),children:"重试"})]}),!c&&m===null&&o!==null&&o.length===0&&i.jsx("p",{className:"py-1 text-xs text-muted-foreground",children:"该节点没有变更记录"}),!c&&m===null&&o!==null&&o.length>0&&i.jsx("ul",{className:"divide-y divide-border/70",children:o.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:ls(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:[_p(v.targetType),"《",v.targetName??v.targetId,"》"]}),i.jsx($1,{changes:v.changes})]})]},v.id))})]})}const k_=Na.filter(n=>n!=="event").map(n=>({value:n,label:_p(n)})),__={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"]},M_={character:Ec("character"),setting:Ec("setting"),location:Ec("location"),hook:Ec("hook")};function Ec(n){return Object.fromEntries(Rp(n).map(r=>[r.key,r.label]))}const A_={character:["personality","abilities"],setting:["rules"]},D_={character:["age"],hook:["half_life"]};function Em(n,r){return(A_[n]??[]).includes(r)}function z_(n,r){return(D_[n]??[]).includes(r)}function L_(n){return(__[n]??[]).filter(o=>o!=="custom_fields").map(o=>({key:o,label:M_[n]?.[o]??o,array:Em(n,o)}))}function K1(n){if(n!==void 0){if(n===null)return null;if(typeof n=="string"||typeof n=="number")return n}}function ov(n){return n.array?{options:["add","remove"],default:"add"}:K1(n.currentValue)!==void 0?{options:["update","set"],default:"update"}:{options:["set"],default:"set"}}function I_(n){const r=n.rawValue.trim();if(r==="")return{error:"请填写值"};const o=Number(r),l=n.numeric&&!Number.isNaN(o)?o:r;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=K1(n.currentValue);return c===void 0?{error:"无法确定旧值(当前数据无此字段或类型不可表达),请改用「设为」"}:{change:{field:n.field,op:"update",from:c,to:l}}}}}const ba="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",B_={set:"设为",update:"更新",add:"追加",remove:"移除"};function U_({nodeId:n,onCreated:r,onClose:o}){const[l,c]=p.useState(""),[d,m]=p.useState(""),[g,b]=p.useState(""),[h,v]=p.useState("add"),[x,S]=p.useState(""),[j,N]=p.useState(""),[k,O]=p.useState(!1),[E,T]=p.useState(null),[_,w]=p.useState(null),[I,A]=p.useState(null),[U,M]=p.useState(0),[K,oe]=p.useState(null),[Z,ee]=p.useState(null);p.useEffect(()=>{if(m(""),oe(null),ee(null),l===""){w(null),A(null);return}let z=!1;return w(null),A(null),bo(l).then(L=>{z||w(L.items)}).catch(L=>{z||(w(null),A(L instanceof Ie?L.code:ct))}),()=>{z=!0}},[l,U]),p.useEffect(()=>{if(l===""||d==="")return;let z=!1;return oe(null),ee(null),mo(l,d).then(L=>{z||oe(L.data)}).catch(L=>{z||(oe(null),ee(L instanceof Ie?L.code:ct))}),()=>{z=!0}},[l,d]),p.useEffect(()=>{b(""),S(""),T(null)},[l,d]);const G=L_(l),te=K?.[g],X=ov({array:Em(l,g),currentValue:te});function C(z){b(z),v(ov({array:Em(l,z),currentValue:K?.[z]}).default)}async function B(){if(k)return;if(l===""||d===""){T("请选择变更目标");return}if(g===""){T("请选择变更字段");return}const z=j.trim();if(z===""){T("请填写描述(本节点触发了什么变化)");return}const L=I_({field:g,op:h,rawValue:x,numeric:z_(l,g),currentValue:te});if("error"in L){T(L.error);return}O(!0),T(null);try{await Am({node_id:n,target_type:l,target_id:d,changes:[L.change],description:z}),ke.getState().showToast("已记录变更"),r()}catch(D){if(D instanceof Ie&&D.code==="OUTLINE_NODE_NOT_FOUND"){ke.getState().showToast("节点不存在(可能已被删除),无法记录变更","error"),o();return}T(D instanceof Ie?D.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:z=>c(z.target.value),className:et(ba,l===""&&"text-muted-foreground"),"aria-label":"目标类型",children:[i.jsx("option",{value:"",children:"请选择目标类型"}),k_.map(z=>i.jsx("option",{value:z.value,children:z.label},z.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:"请先选择目标类型"}):I!==null?i.jsxs("div",{className:"flex items-center gap-2 text-xs text-destructive",children:[i.jsx("span",{children:I===ct?"无法连接服务,请确认 ai-editor 服务已启动":"实体列表加载失败"}),i.jsx(Se,{variant:"outline",size:"xs",type:"button",onClick:()=>M(z=>z+1),children:"重试"})]}):_===null?i.jsx("p",{className:"py-1 text-xs text-muted-foreground",children:"加载中…"}):_.length===0?i.jsxs("p",{className:"py-1 text-xs text-muted-foreground",children:["暂无",av(H)]}):i.jsxs("select",{value:d,onChange:z=>m(z.target.value),className:et(ba,d===""&&"text-muted-foreground"),"aria-label":"目标实体",children:[i.jsxs("option",{value:"",children:["请选择",av(H)]}),_.map(z=>i.jsx("option",{value:z.id,children:z.name},z.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:z=>C(z.target.value),className:et(ba,g===""&&"text-muted-foreground"),"aria-label":"变更字段",children:[i.jsx("option",{value:"",children:"请选择字段"}),G.map(z=>i.jsx("option",{value:z.key,children:z.label},z.key))]})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"操作"}),i.jsx("select",{value:h,onChange:z=>v(z.target.value),className:et(ba,"min-w-20"),"aria-label":"操作",children:X.options.map(z=>i.jsx("option",{value:z,children:B_[z]},z))})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:h==="set"||h==="update"?"新值":h==="add"?"追加值":"移除值"}),i.jsx("input",{value:x,onChange:z=>S(z.target.value),placeholder:h==="remove"?"按值匹配删除":"",className:ba})]})]}),h==="update"&&i.jsx("p",{className:"text-xs text-muted-foreground",children:Z!==null?i.jsxs(i.Fragment,{children:["目标数据获取失败,无法自动取旧值(",Z==="ENTITY_NOT_FOUND"?"目标已不存在":"请稍后重试",")——可将操作改为「设为」"]}):i.jsxs(i.Fragment,{children:["旧值:",os(te),"(自动取自目标当前数据,无需手填)"]})}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"描述"}),i.jsx("textarea",{value:j,onChange:z=>N(z.target.value),rows:2,maxLength:500,placeholder:"本节点触发了什么变化,如:张三获得断剑认可",className:et(ba,"resize-none")})]}),E!==null&&i.jsx("p",{className:"text-sm text-destructive",children:E}),i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[i.jsx(Se,{variant:"ghost",size:"sm",type:"button",onClick:o,disabled:k,children:"取消"}),i.jsx(Se,{size:"sm",type:"button",onClick:()=>{B()},disabled:k,children:k?"提交中…":"创建变更"})]})]})}function av(n){return _p(n)}function Mp({items:n,className:r}){return i.jsx("nav",{"aria-label":"面包屑",className:et("inline-flex items-center gap-1",r),children:n.map((o,l)=>{const c=l===n.length-1;return i.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.href?i.jsx("button",{type:"button",onClick:()=>Tn(o.href),className:"rounded-md px-2.5 py-1 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:o.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:o.label}),!c&&i.jsx("span",{className:"select-none text-sm text-muted-foreground/40",children:"›"})]},l)})})}const H_={inner:"内心冲突",personal:"人际冲突",extra_personal:"社会冲突"};function Y_(n){switch(n){case"scene":return[{key:"goal",label:"场景目标",control:"textarea",maxLength:1e3},{key:"conflict_levels",label:"冲突层次",control:"checkbox-group",options:wv,optionsLabels:H_},{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 P_(n,r){return wv.includes(r)?n.includes(r)?n.filter(o=>o!==r):[...n,r]:n}function V_(n){const r=[],o=(l,c)=>{for(const d of l)d.type==="scene"?r.push({id:d.id,label:d.title,depth:c}):d.children&&o(d.children,c+1)};return o(n,0),r}function q_(n){return typeof n=="string"&&n!==""?n:""}const Nm="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 Tl({title:n,children:r,className:o,action:l}){return i.jsxs("div",{className:et("rounded-xl border border-border bg-card p-4",o),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]}),r]})}function F_({nodeId:n}){const r=Ae(V=>V.outline),o=Ae(V=>V.outlineLoading),l=Ae(V=>V.config),c=Ae(V=>V.configLoading),d=Ae(V=>V.loadOutline),m=Ae(V=>V.updateConfig),[g,b]=p.useState(!1),[h,v]=p.useState(""),[x,S]=p.useState(""),[j,N]=p.useState(null),[k,O]=p.useState(!1),[E,T]=p.useState(null),[_,w]=p.useState(!1),[I,A]=p.useState(!1),[U,M]=p.useState(0),[K,oe]=p.useState(!1),[Z,ee]=p.useState(0);p.useEffect(()=>{r===null&&!o&&!g&&(b(!0),d())},[r,o,g,d]),Cs(()=>{d(),M(V=>V+1),ee(V=>V+1)});const G=r===null?null:Br(r.children,n),te=r!==null&&G===null,X=G?Y_(G.type):[],C=V_(r?.children??[]),B=l?.currentPosition===n;p.useEffect(()=>{G!==null&&(v(G.title),S(G.summary??""),N(JSON.parse(JSON.stringify(G.data??{}))))},[G]);async function H(){if(G===null||k)return;const V=h.trim();if(V===""){T("标题不能为空");return}const Q={};V1(G.title,h)&&(Q.title=V),q1(G.summary,x)&&(Q.summary=x.trim());const ne=Op(G.data??{},j??{});if(ne!==null&&(Q.data=ne),Object.keys(Q).length===0){ke.getState().showToast("没有变更");return}O(!0),T(null);try{await zv(G.id,Q),ke.getState().showToast("已保存"),await d()}catch(F){if(F instanceof Ie&&F.code==="OUTLINE_NODE_NOT_FOUND"){await d();return}T(F instanceof Ie?F.message:"保存失败,请重试")}finally{O(!1)}}function z(V,Q){N(ne=>ne&&{...ne,[V]:Q})}async function L(){if(!(G===null||_||B)){w(!0);try{await m({current_position:G.id}),ke.getState().showToast("已设为当前位置")}catch{ke.getState().showToast("设置失败:该节点可能已删除,无法设为当前位置","error")}finally{w(!1)}}}if(te)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(Se,{variant:"outline",type:"button",onClick:()=>Tn("/outline"),children:"返回大纲"})]})]})});const D=l===null&&!c,q=[{label:"大纲",href:"/outline"}];if(G!==null){const V=Tp(r?.children??[],n)??[];for(const Q of V.slice(0,-1)){const ne=Br(r?.children??[],Q);ne&&q.push({label:ne.title,href:`/outline/${Q}`})}q.push({label:G.title})}return i.jsxs("section",{children:[i.jsxs("div",{className:"mb-1 flex items-center gap-3",children:[i.jsx(Mp,{items:q}),i.jsx("h1",{className:"min-w-0 truncate text-xl font-semibold",children:G?.title??"…"}),i.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[i.jsx(Se,{variant:"outline",type:"button",disabled:G===null||B||_,title:B?"当前节点已是创作进度位置":"标记为创作进度位置(InfoBar 展示 + 定位跳转基准)",onClick:()=>{L()},children:B?"当前位置":"设为当前位置"}),i.jsx(Se,{type:"button",onClick:()=>{H()},disabled:G===null||k,children:k?"保存中…":"保存"})]})]}),G&&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:rs[G.type]}),i.jsxs("span",{children:["更新于 ",ls(G.updatedAt)]}),B&&i.jsx("span",{className:"shrink-0 rounded bg-accent px-1.5 py-0.5 text-xs text-accent-foreground",children:"当前位置"})]}),D?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&&r===null?i.jsx("div",{className:"space-y-2 rounded-md border border-border p-3",children:Array.from({length:6},(V,Q)=>i.jsx("div",{className:"h-5 animate-pulse rounded bg-muted",style:{width:`${92-Q%3*24}%`,marginLeft:Q%3*20}},Q))}):r===null?i.jsxs("div",{className:"rounded-md border border-border p-4 text-sm text-muted-foreground",children:["大纲加载失败",i.jsx(Se,{variant:"outline",className:"ml-3",type:"button",onClick:()=>b(!1),children:"重试"})]}):G===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(Tl,{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(Ot,{value:h,onChange:V=>v(V.target.value),maxLength:200,placeholder:`${rs[G.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:V=>S(V.target.value),maxLength:200,rows:3,placeholder:"一句话概括本节点内容(可选)",className:Nm})]})]})}),i.jsxs(Tl,{title:`结构化信息(${rs[G.type]})`,children:[i.jsx("div",{className:"flex flex-col gap-3",children:X.map(V=>i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:V.label}),i.jsx(G_,{field:V,value:j?.[V.key],sceneOptions:C,onChange:Q=>z(V.key,Q)})]},V.key))}),E&&i.jsx("p",{className:"mt-3 text-sm text-destructive",children:E})]}),i.jsxs(Tl,{title:"变更记录",action:i.jsx(Se,{variant:"outline",size:"sm",type:"button",onClick:()=>oe(V=>!V),children:K?"收起":"+ 新建变更"}),children:[K&&i.jsx(U_,{nodeId:n,onCreated:()=>{oe(!1),ee(V=>V+1)},onClose:()=>oe(!1)}),i.jsx(O_,{nodeId:n,reloadKey:Z})]}),i.jsx(Tl,{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(Tl,{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(Se,{variant:"outline",type:"button",className:"h-8 px-2 text-xs",onClick:()=>A(!0),children:"+ 新增关联"})]}),i.jsx(X1,{scope:{type:"outline_node",id:n},reloadKey:U,onOpenCreate:()=>A(!0)})]})})]}),I&&G!==null&&i.jsx(kp,{source:{type:"outline_node",id:G.id,name:G.title},onCreated:()=>M(V=>V+1),onClose:()=>A(!1)})]})}function G_({field:n,value:r,sceneOptions:o,onChange:l}){switch(n.control){case"textarea":return i.jsx("textarea",{value:typeof r=="string"?r:"",onChange:c=>l(c.target.value),maxLength:n.maxLength,rows:3,className:Nm});case"checkbox-group":{const c=Array.isArray(r)?r:[];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(P_(c,d)),className:"size-4 accent-primary"}),n.optionsLabels?.[d]??d]},d))})}case"scene-select":{const c=q_(r),d=c!==""&&!o.some(m=>m.id===c);return i.jsxs("select",{value:c,onChange:m=>l(m.target.value),className:et(Nm,c===""&&"text-muted-foreground"),children:[i.jsx("option",{value:"",children:"(未设置)"}),d&&i.jsxs("option",{value:c,children:[c,"(已删除)"]}),o.map(m=>i.jsxs("option",{value:m.id,children:[" ".repeat(m.depth),m.label]},m.id))]})}default:return i.jsx(Ot,{value:typeof r=="string"?r:"",onChange:c=>l(c.target.value),maxLength:n.maxLength,className:"h-8 text-sm"})}}const go={volume:248,chapter:208,scene:168},Ts={volume:96,chapter:88,scene:76},Lr={padX:48,padY:48,colGap:304,rowGap:28,indentChapter:28,indentScene:56},Q1=.5,Z1=2,X_="ai-editor:canvas:";function jm(n){return Math.min(Z1,Math.max(Q1,n))}function $_(n){if(!n)return[];const r=[],o=(l,c,d)=>{for(const m of l)r.push({id:m.id,type:m.type,title:m.title,summary:m.summary,parentId:c,depth:d}),m.type!=="scene"&&m.children&&o(m.children,m.id,d+1)};return o(n.children,null,0),r}function lv(n){const r={};let o=0;for(const l of n){if(l.depth!==0)continue;const c=Lr.padX+o*Lr.colGap;let d=Lr.padY;r[l.id]={x:c,y:d},d+=Ts[l.type]+Lr.rowGap;for(const m of n)if(m.parentId===l.id){r[m.id]={x:c+Lr.indentChapter,y:d},d+=Ts[m.type]+Lr.rowGap;for(const g of n)g.parentId===m.id&&(r[g.id]={x:c+Lr.indentScene,y:d},d+=Ts.scene+Lr.rowGap)}o+=1}return r}function J1(n){return`${X_}${n}`}function K_(n){if(typeof n!="object"||n===null)return null;const r=n.nodes;if(typeof r!="object"||r===null||Array.isArray(r))return null;const o={};for(const[d,m]of Object.entries(r)){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;o[d]={x:g.x,y:g.y}}const l=n.zoom,c=typeof l=="number"&&Number.isFinite(l)?jm(l):1;return{nodes:o,zoom:c}}function Q_(n){try{const r=localStorage.getItem(J1(n));return r===null?null:K_(JSON.parse(r))}catch{return null}}function Zf(n,r){try{localStorage.setItem(J1(n),JSON.stringify(r))}catch{}}function iv(n,r,o){const l={};for(const c of o)l[c.id]=n?.[c.id]??r[c.id];return l}function Z_(n){const r=[];for(const o of n){if(o.relationType!==LN||o.sourceType!=="outline_node"||o.targetType!=="outline_node")continue;const l=o.metadata?.label,c=typeof l=="string"&&l.trim()!==""?l.trim():void 0;r.push({id:o.id,sourceId:o.sourceId,targetId:o.targetId,label:c})}return r.sort((o,l)=>o.id<l.id?-1:o.id>l.id?1:0),r}function J_(n){return n.filter(r=>r.type==="scene")}function W_(n,r){return n.filter(o=>r.has(o.sourceId)&&r.has(o.targetId))}function cv(n,r){const o=Math.max(32,Math.abs(r.x-n.x)*.5),l=n.x+o,c=r.x-o;return`M ${n.x} ${n.y} C ${l} ${n.y}, ${c} ${r.y}, ${r.x} ${r.y}`}function e3(n,r){const o=Math.max(32,Math.abs(r.x-n.x)*.5),l={x:n.x+o,y:n.y},c={x:r.x-o,y:r.y};return{x:(n.x+3*l.x+3*c.x+r.x)/8,y:(n.y+3*l.y+3*c.y+r.y)/8}}function Jf(n,r){return{x:n.x+go[r]/2,y:n.y+Ts[r]/2}}function uv(n,r,o,l){const c=r.x-n.x,d=r.y-n.y;if(c===0&&d===0)return n;const m=c===0?Number.POSITIVE_INFINITY:o/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 js={highlight:"#a855f7",scene:"#f59e0b",chapter:"#3b82f6",volume:"#06b6d4",default:"#94a3b8"};function t3(n,r={}){if(r.onPath||r.selected)return js.highlight;switch(n){case"scene":return js.scene;case"chapter":return js.chapter;case"volume":return js.volume;default:return js.default}}function n3(n={}){return n.onPath||n.selected?2.5:1.5}function s3(n={}){return n.offPath?.2:1}const W1="canvas-edge-arrow";function r3(){return`url(#${W1})`}const Yc={w:180,h:120},Nc=4,o3=1,a3=.02;function l3(n,r,o,l){let c=Number.POSITIVE_INFINITY,d=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY,b=0;for(const w of n){const I=r[w.id];I&&(c=Math.min(c,I.x),d=Math.min(d,I.y),m=Math.max(m,I.x+go[w.type]),g=Math.max(g,I.y+Ts[w.type]),b+=1)}if(b===0)return{nodeRects:[],viewportRect:null};const h=m-c,v=g-d,x=Yc.w-2*Nc,S=Yc.h-2*Nc,j=Math.min(x/h,S/v),N=Math.min(o3,Math.max(a3,j)),k=Nc+(x-h*N)/2,O=Nc+(S-v*N)/2,E=[];for(const w of n){const I=r[w.id];I&&E.push({id:w.id,x:k+(I.x-c)*N,y:O+(I.y-d)*N,w:go[w.type]*N,h:Ts[w.type]*N,type:w.type})}let T=null;const _=o>0?o:1;if(l!==null&&l.width>0&&l.height>0){const w={x:l.x/_,y:l.y/_,width:l.width/_,height:l.height/_};T={x:k+(w.x-c)*N,y:O+(w.y-d)*N,w:w.width*N,h:w.height*N}}return{nodeRects:E,viewportRect:T}}function i3(n,r){const o=new Set([n]),l=new Set,c=[n];for(;c.length>0;){const d=c.pop();for(const m of r)m.sourceId!==d||l.has(m.id)||(l.add(m.id),o.has(m.targetId)||(o.add(m.targetId),c.push(m.targetId)))}return{nodeIds:o,edgeIds:l}}function dv(n){switch(n){case"RELATION_EXISTS":return"这条连线已经存在";case"VALIDATION_ERROR":return"连线参数有误";case"CLIENT_NETWORK_ERROR":return"无法连接服务,请确认 ai-editor 服务已启动";default:return null}}function c3(){const n=Ae(re=>re.outline),r=Ae(re=>re.outlineLoading),o=Ae(re=>re.config),l=Ae(re=>re.configLoading),c=Ae(re=>re.loadOutline),[d,m]=p.useState({}),[g,b]=p.useState(1),[h,v]=p.useState(!1),[x,S]=p.useState(!0),[j,N]=p.useState(!1),[k,O]=p.useState(null),[E,T]=p.useState(null),[_,w]=p.useState(null),[I,A]=p.useState(null),[U,M]=p.useState(null),[K,oe]=p.useState(null),[Z,ee]=p.useState(null),[G,te]=p.useState(null),[X,C]=p.useState(null),[B,H]=p.useState(null),[z,L]=p.useState(!1),D=p.useRef(null),q=p.useRef(null),V=p.useRef(null),Q=p.useRef(d);Q.current=d;const ne=p.useRef(0),F=o?.id??null,Te=o===null&&!l,me=p.useCallback(async()=>{if(F===null)return;const ve=++ne.current;try{const Oe=await ja({source_type:"outline_node",relation_type:"plot_edge",depth:1});if(ve!==ne.current)return;O(Z_(Oe.relations)),T(null)}catch(Oe){if(ve!==ne.current)return;T(Oe instanceof Ie?Oe.code:ct)}},[F]);Cs(()=>{c(),me()});const he=p.useMemo(()=>$_(n),[n]),Le=p.useMemo(()=>new Map(he.map(re=>[re.id,re])),[he]),[Ve,Re]=p.useState(null);p.useEffect(()=>{if(F===null){Re(null),m({}),b(1);return}const re=Q_(F);Re(F),b(re?.zoom??1),m(re?.nodes??{})},[F]);const ze=Ve===F;p.useEffect(()=>{he.length===0||!ze||m(re=>iv(re,lv(he),he))},[he,ze]),p.useEffect(()=>{if(!(F===null||!ze))return V.current!==null&&window.clearTimeout(V.current),V.current=window.setTimeout(()=>{Zf(F,{nodes:d,zoom:g})},300),()=>{V.current!==null&&(window.clearTimeout(V.current),V.current=null,Q.current===d&&F!==null&&ze&&Zf(F,{nodes:d,zoom:g}))}},[d,F,g,ze]),p.useEffect(()=>{F===null||!ze||Zf(F,{nodes:d,zoom:g})},[g,F,ze]),p.useEffect(()=>{n===null&&!r&&!j&&(N(!0),c())},[n,r,j,c]),p.useEffect(()=>{if(F===null){O(null),T(null);return}me()},[F,me]),p.useEffect(()=>{if(n===null){w(null);return}let re=!1;return Promise.all(jp.map(ve=>ja({source_type:"outline_node",relation_type:ve,depth:1}).then(Oe=>Oe.relations).catch(()=>[]))).then(ve=>{re||w(P1(ve.flat()))}),()=>{re=!0}},[n]);const De=p.useRef(null),ye=p.useRef(null),Be=p.useCallback(()=>{const re=D.current,ve=q.current;if(re===null||ve===null)return;const Oe=re.getBoundingClientRect(),Qe=ve.getBoundingClientRect(),tt={x:Math.round(Oe.left-Qe.left),y:Math.round(Oe.top-Qe.top),width:Math.round(Oe.width),height:Math.round(Oe.height)};oe(at=>at!==null&&at.x===tt.x&&at.y===tt.y&&at.width===tt.width&&at.height===tt.height?at:tt)},[]),ae=p.useCallback(re=>{if(D.current=re,De.current?.(),De.current=null,ye.current?.(),ye.current=null,re===null)return;const ve=Qe=>{Qe.preventDefault(),b(tt=>jm(Math.round((tt+(Qe.deltaY<0?.1:-.1))*10)/10))};re.addEventListener("wheel",ve,{passive:!1}),De.current=()=>re.removeEventListener("wheel",ve),Be();const Oe=new ResizeObserver(()=>Be());Oe.observe(re),ye.current=()=>Oe.disconnect()},[Be]);p.useEffect(()=>()=>{De.current?.(),De.current=null,ye.current?.(),ye.current=null},[]),p.useEffect(()=>{if(G===null)return;const re=ve=>{ve.key==="Escape"&&te(null)};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[G]);const de=h?J_(he):he,ue=p.useMemo(()=>new Set(de.map(re=>re.id)),[de]),Ce=p.useMemo(()=>W_(k??[],ue),[k,ue]);p.useEffect(()=>{U!==null&&!ue.has(U)&&M(null)},[U,ue]);const fe=p.useMemo(()=>{const re=[];for(const ve of Ce){const Oe=d[ve.sourceId],Qe=d[ve.targetId],tt=Le.get(ve.sourceId),at=Le.get(ve.targetId);if(!Oe||!Qe||!tt||!at)continue;const st=Jf(Oe,tt.type),Pt=Jf(Qe,at.type),Xn=uv(st,Pt,go[tt.type],Ts[tt.type]),$t=uv(Pt,st,go[at.type],Ts[at.type]);re.push({edge:ve,d:cv(Xn,$t),mid:e3(Xn,$t),targetType:at.type})}return re},[Ce,d,Le]),be=p.useMemo(()=>U!==null&&G===null?i3(U,Ce):null,[U,G,Ce]),qe=p.useMemo(()=>fe.map(re=>{const ve=re.edge.id===I,Oe=be?.edgeIds.has(re.edge.id)??!1;return{...re,stroke:t3(re.targetType,{onPath:Oe,selected:ve}),strokeWidth:n3({onPath:Oe,selected:ve}),opacity:s3({offPath:be!==null&&!Oe}),dash:Oe||ve}}),[fe,be,I]),se=p.useMemo(()=>l3(de,d,g,K),[de,d,g,K]),Y=p.useMemo(()=>{let re=0,ve=0;for(const Oe of he){const Qe=d[Oe.id];Qe&&(re=Math.max(re,Qe.x+go[Oe.type]),ve=Math.max(ve,Qe.y+Ts[Oe.type]))}return{w:re+96,h:ve+96}},[he,d]),ge=p.useMemo(()=>fe.find(re=>re.edge.id===I)??null,[fe,I]),J=p.useMemo(()=>{if(G===null||X===null)return null;const re=Le.get(G),ve=d[G];return!re||!ve?null:cv(Jf(ve,re.type),X)},[G,X,d,Le]);function we(re,ve){const Oe=q.current?.getBoundingClientRect();return Oe?{x:(re-Oe.left)/g,y:(ve-Oe.top)/g}:{x:0,y:0}}function Xe(re,ve){if(re.target.closest("[data-canvas-handle]")||re.button!==0)return;re.preventDefault();const Oe=d[ve.id];Oe&&(re.currentTarget.setPointerCapture(re.pointerId),ee({nodeId:ve.id,startClientX:re.clientX,startClientY:re.clientY,origX:Oe.x,origY:Oe.y}))}function je(re,ve){if(Z===null||Z.nodeId!==ve)return;const Oe=(re.clientX-Z.startClientX)/g,Qe=(re.clientY-Z.startClientY)/g;m(tt=>tt[ve]?{...tt,[ve]:{x:Z.origX+Oe,y:Z.origY+Qe}}:tt)}function Me(){ee(null)}function $e(re,ve){re.stopPropagation(),re.preventDefault(),re.button===0&&(re.currentTarget.setPointerCapture(re.pointerId),A(null),te(ve.id),C(we(re.clientX,re.clientY)))}function rt(re){G!==null&&C(we(re.clientX,re.clientY))}async function Nt(re){if(G===null)return;const ve=G,tt=document.elementFromPoint(re.clientX,re.clientY)?.closest("[data-canvas-node-id]")?.getAttribute("data-canvas-node-id")??null;if(te(null),C(null),!(tt===null||tt===ve))try{await Oa({source_type:"outline_node",source_id:ve,target_type:"outline_node",target_id:tt,relation_type:"plot_edge"}),ke.getState().showToast("已建立连线"),await me()}catch(at){const st=at instanceof Ie?at.code:null,Pt=dv(st);if(Pt!==null){ke.getState().showToast(Pt,"error"),await me();return}ke.getState().showToast(at instanceof Ie?at.message:"创建失败,请重试","error")}}const kt=p.useRef(!1);function bt(re){kt.current=!1,H({edgeId:re.id,draft:re.label??""})}async function yn(re,ve){if(!z){L(!0),H(null);try{const Oe=ve.trim();await fT(re,Oe===""?{}:{label:Oe}),ke.getState().showToast("已保存标签"),await me()}catch(Oe){ke.getState().showToast(Oe instanceof Ie?Oe.message:"保存失败,请重试","error")}finally{L(!1)}}}function an(re){re.key==="Enter"?(re.preventDefault(),kt.current=!0,B!==null&&yn(B.edgeId,B.draft)):re.key==="Escape"&&(re.preventDefault(),kt.current=!0,H(null))}function Ke(){kt.current||B!==null&&yn(B.edgeId,B.draft)}async function Tt(){if(ge===null)return;const re=ge.edge;if(await ke.getState().confirm({title:"删除连线",description:`删除连线「${re.label??"未命名"}」?物理删除不可恢复,可随时重建。`,danger:!0}))try{kt.current=!0,H(null),await qc(re.id),ke.getState().showToast("已删除连线"),A(null),await me()}catch(Oe){const Qe=Oe instanceof Ie?Oe.code:null,tt=dv(Qe);ke.getState().showToast(tt??(Oe instanceof Ie?Oe.message:"删除失败,请重试"),"error"),Qe==="RELATION_NOT_FOUND"&&(A(null),await me())}}function tn(){m(re=>iv(re,lv(he),he))}function qt(re){b(ve=>jm(Math.round((ve+re)*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(Se,{variant:"outline",type:"button",onClick:tn,disabled:he.length===0,children:"重新布局"}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Se,{variant:"outline",size:"icon-sm",type:"button","aria-label":"缩小",disabled:g<=Q1,onClick:()=>qt(-.1),children:i.jsx(bj,{})}),i.jsxs("span",{className:"w-12 text-center text-sm tabular-nums text-muted-foreground",children:[Math.round(g*100),"%"]}),i.jsx(Se,{variant:"outline",size:"icon-sm",type:"button","aria-label":"放大",disabled:g>=Z1,onClick:()=>qt(.1),children:i.jsx(Om,{})})]}),i.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-secondary/30 p-1",role:"group","aria-label":"显示模式",children:[!1,!0].map(re=>i.jsx("button",{type:"button",onClick:()=>v(re),"aria-pressed":h===re,className:et("rounded-md px-2.5 py-1 text-xs transition-colors",h===re?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:re?"仅场景":"全部节点"},String(re)))}),i.jsxs(Se,{variant:"ghost",size:"sm",type:"button",onClick:()=>S(re=>!re),"aria-expanded":x,children:[i.jsx(Ov,{}),"画布说明"]})]}),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(or,{className:"size-3"})})]}),E!==null&&i.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[E===ct?"无法连接服务,请确认 ai-editor 服务已启动。":"连线加载失败,请重试。",i.jsx(Se,{variant:"outline",className:"ml-3",type:"button",onClick:()=>{me()},children:"重试"})]}),Te?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&&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},(re,ve)=>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"})]},ve))}):n===null?i.jsxs("div",{className:"rounded-md border border-border p-4 text-sm text-muted-foreground",children:["大纲加载失败",i.jsx(Se,{variant:"outline",className:"ml-3",type:"button",onClick:()=>N(!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(Se,{className:"mt-4",type:"button",onClick:()=>Tn("/outline"),children:"去大纲"})]}):de.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(Se,{variant:"outline",className:"mt-4",type:"button",onClick:()=>v(!1),children:"显示全部节点"})]}):i.jsxs("div",{ref:ae,className:"relative min-h-0 flex-1 overflow-auto rounded-md border border-border bg-muted/20",onScroll:Be,onClick:re=>{re.target===re.currentTarget&&A(null)},children:[i.jsxs("div",{ref:q,className:"relative",style:{width:Y.w,height:Y.h,transform:`scale(${g})`,transformOrigin:"0 0"},onClick:re=>{re.target===re.currentTarget&&A(null)},children:[i.jsxs("svg",{className:"pointer-events-none absolute left-0 top-0",width:Y.w,height:Y.h,style:{overflow:"visible"},children:[i.jsx("defs",{children:i.jsx("marker",{id:W1,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"})})}),qe.map(({edge:re,d:ve,stroke:Oe,strokeWidth:Qe,opacity:tt,dash:at})=>{const st=re.id===I;return i.jsxs("g",{opacity:tt,children:[i.jsx("path",{d:ve,fill:"none",stroke:Oe,strokeWidth:Qe,strokeDasharray:at?"6 4":void 0,vectorEffect:"non-scaling-stroke",markerEnd:r3(),className:at?"canvas-edge-flow":void 0}),i.jsx("path",{d:ve,fill:"none",stroke:"transparent",strokeWidth:14,vectorEffect:"non-scaling-stroke",className:"pointer-events-auto cursor-pointer",onClick:()=>A(st?null:re.id)})]},re.id)}),J!==null&&i.jsx("path",{d:J,fill:"none",stroke:"var(--primary)",strokeWidth:2,strokeDasharray:"6 4",vectorEffect:"non-scaling-stroke"})]}),qe.map(({edge:re,mid:ve,opacity:Oe})=>{const Qe=re.id===I;return Qe&&B!==null&&B.edgeId===re.id?i.jsx("div",{className:"absolute z-20 -translate-x-1/2 -translate-y-1/2",style:{left:ve.x,top:ve.y},children:i.jsx(Ot,{value:B.draft,onChange:at=>H({edgeId:re.id,draft:at.target.value}),onKeyDown:an,onBlur:Ke,onFocus:at=>at.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-${re.id}`):i.jsx("span",{className:et("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",Qe&&"pointer-events-auto cursor-text"),style:{left:ve.x,top:ve.y,opacity:Oe,...Qe?{borderColor:js.highlight,color:js.highlight}:{}},title:Qe?re.label===void 0?"添加标签":"编辑标签":void 0,onClick:at=>{at.stopPropagation(),bt(re)},children:re.label??(Qe?"+ 标签":"未命名连线")},`label-${re.id}`)}),ge!==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:ge.mid.x,top:ge.mid.y+26},children:[i.jsx("span",{className:"max-w-36 truncate px-1.5 text-xs text-muted-foreground",children:ge.edge.label??"未命名连线"}),i.jsx(Se,{variant:"outline",size:"xs",type:"button",className:"text-destructive hover:bg-destructive/10",onClick:()=>{Tt()},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(or,{className:"size-3.5"})})]}),de.map(re=>{const ve=d[re.id];if(!ve)return null;const Oe=_?.get(re.id)??[],Qe=G===re.id,tt=Z?.nodeId===re.id,at=be?.nodeIds.has(re.id)??!1;return i.jsxs("div",{"data-canvas-node-id":re.id,className:et("group absolute cursor-grab touch-none select-none rounded-lg border bg-card p-2.5 transition-colors active:cursor-grabbing",Qe?"border-primary ring-2 ring-ring/40":"border-border",tt&&"opacity-80"),style:{left:ve.x,top:ve.y,width:go[re.type],height:Ts[re.type],...be!==null?{opacity:at?1:.2,boxShadow:at?`0 0 0 2px ${js.highlight}`:void 0}:{}},title:"拖动调整位置",onPointerDown:st=>Xe(st,re),onPointerMove:st=>je(st,re.id),onPointerUp:Me,onMouseEnter:()=>M(re.id),onMouseLeave:()=>M(st=>st===re.id?null:st),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:rs[re.type]}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",title:re.title,children:re.title}),Oe.length>0&&i.jsx("span",{className:"flex shrink-0 items-center gap-0.5",children:Oe.map(st=>i.jsx(Y1,{mark:st},`${st.relationType}-${st.hookId}`))})]}),re.summary&&i.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-4 text-muted-foreground",children:re.summary}),i.jsx("span",{"data-canvas-handle":!0,className:et("absolute top-1/2 -right-2 h-4 w-4 -translate-y-1/2 cursor-crosshair rounded-full border bg-card transition-colors",Qe?"border-primary bg-primary/10":"border-border hover:border-primary hover:bg-accent"),title:"拖出连线","aria-label":"拖出连线",onPointerDown:st=>$e(st,re),onPointerMove:rt,onPointerUp:Nt})]},re.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:Yc.w,height:Yc.h,children:[se.nodeRects.map(re=>i.jsx("rect",{x:re.x,y:re.y,width:re.w,height:re.h,rx:2,fill:js[re.type],opacity:.85},re.id)),se.viewportRect!==null&&i.jsx("rect",{x:se.viewportRect.x,y:se.viewportRect.y,width:se.viewportRect.w,height:se.viewportRect.h,fill:"none",stroke:js.highlight,strokeWidth:1})]})})]})]})}const ya={character:"人物",setting:"设定",location:"地点",hook:"伏笔",event:"事件"},fv=[{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 mv({type:n}){const r=n==="relations",o=Na.includes(n)?n:"character",[l,c]=p.useState(null),[d,m]=p.useState(0),[g,b]=p.useState(!1),[h,v]=p.useState(null),[x,S]=p.useState(""),[j,N]=p.useState(""),[k,O]=p.useState(0),[E,T]=p.useState("updated_at"),[_,w]=p.useState("desc"),[I,A]=p.useState(0);Cs(()=>A(F=>F+1));const[U,M]=p.useState(!1),[K,oe]=p.useState(""),[Z,ee]=p.useState(""),[G,te]=p.useState(null),[X,C]=p.useState(!1),B=E_[o],H=ev[o],z=S_(d,jl),L=Math.floor(k/jl)+1;p.useEffect(()=>{S(""),N(""),O(0),T("updated_at"),w("desc"),c(null),v(null),M(!1)},[n]),p.useEffect(()=>{const F=setTimeout(()=>{N(x.trim()),O(0)},300);return()=>clearTimeout(F)},[x]),p.useEffect(()=>{if(r)return;let F=!1;return b(!0),v(null),bo(o,{q:j||void 0,offset:k,limit:jl,sort:E,order:_}).then(Te=>{F||(c(Te.items),m(Te.total))}).catch(Te=>{F||(c(null),v(Te instanceof Ie?Te.code:ct))}).finally(()=>{F||b(!1)}),()=>{F=!0}},[o,j,k,E,_,I,r]);function D(F){const Te=fv.find(me=>me.value===F);Te&&(T(Te.sort),w(Te.order),O(0))}function q(){oe(""),ee(""),te(null),M(!0)}function V(){M(!1),te(null)}async function Q(F){F.preventDefault();const Te=K.trim();if(!Te){te("请输入名称");return}C(!0),te(null);try{const me=ev[o],he={};Z.trim()&&(he[me.key]=Z.trim());const Le=await Mm(o,{name:Te,data:he});ke.getState().showToast(`已创建${ya[o]}《${Te}》`),M(!1),Tn(`/entities/${o}/${Le.id}`)}catch(me){te(me instanceof Ie?me.message:"创建失败,请重试")}finally{C(!1)}}function ne(){S(""),N(""),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:[Na.map(F=>i.jsx("button",{type:"button",onClick:()=>Tn(`/entities/${F}`),className:et("rounded-md px-3 py-1.5 text-sm",!r&&o===F?"bg-zinc-900 text-white":"text-zinc-500 hover:bg-zinc-100 hover:text-zinc-800"),children:ya[F]},F)),i.jsx("button",{type:"button",onClick:()=>Tn("/entities/relations"),className:et("rounded-md px-3 py-1.5 text-sm",r?"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:[!r&&i.jsx(Ot,{value:x,onChange:F=>S(F.target.value),placeholder:`搜索${ya[o]}名称…`,className:"w-52"}),i.jsx(Se,{type:"button",onClick:r?()=>M(!0):q,children:r?"+ 建立关联":"+ 新建"})]})]}),r?i.jsx(X1,{reloadKey:I,onOpenCreate:()=>M(!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:`${E}:${_}`,onChange:F=>D(F.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:fv.map(F=>i.jsx("option",{value:F.value,children:F.label},F.value))})]}),i.jsxs("span",{className:"ml-auto text-sm text-zinc-400",children:["共 ",d," 个"]})]}),U&&i.jsxs("form",{id:"create-entity-row",onSubmit:Q,className:"mb-3 flex flex-wrap items-center gap-2 rounded-md border border-border bg-card px-3 py-2",children:[i.jsx(Ot,{value:K,onChange:F=>oe(F.target.value),onKeyDown:F=>{F.key==="Escape"&&V()},placeholder:`名称(如:${o==="character"?"张三":"示例名称"})`,maxLength:100,disabled:X,autoFocus:!0,"aria-label":"名称",className:"w-48"}),H.input==="select"?i.jsxs("select",{value:Z,onChange:F=>ee(F.target.value),disabled:X,"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(F=>i.jsx("option",{value:F,children:$f(o,H.key,F)},F))]}):i.jsx(Ot,{value:Z,onChange:F=>ee(F.target.value),placeholder:`${H.label}(选填)`,disabled:X,"aria-label":H.label,className:"w-40"}),i.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[i.jsx(Se,{variant:"outline",type:"button",size:"sm",onClick:V,disabled:X,children:"取消"}),i.jsx(Se,{type:"submit",size:"sm",disabled:X,children:X?"创建中…":"创建"})]}),G&&i.jsx("p",{className:"w-full text-sm text-destructive",children:G})]}),h!==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:[h===ct?"无法连接服务,请确认 ai-editor 服务已启动。":"列表加载失败,请重试。",i.jsx(Se,{variant:"outline",className:"ml-3",type:"button",onClick:()=>A(F=>F+1),children:"重试"})]}),g&&l===null&&h===null&&i.jsx("div",{className:"overflow-hidden rounded-md border border-zinc-200",children:Array.from({length:6},(F,Te)=>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"}),B.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"})]},Te))}),!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,"」的",ya[o]]}),i.jsx(Se,{variant:"outline",className:"mt-4",type:"button",onClick:ne,children:"清空搜索"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"text-sm text-zinc-600",children:["还没有",ya[o],",新建一个"]}),i.jsxs(Se,{className:"mt-4",type:"button",onClick:q,children:["+ 新建",ya[o]]})]})}),!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:B.label1}),B.key2&&i.jsx("th",{className:"px-3 py-2 font-normal",children:B.label2}),i.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"更新时间"})]})}),i.jsx("tbody",{children:l.map(F=>i.jsxs("tr",{className:"cursor-pointer border-b border-zinc-100 transition-colors last:border-0 hover:bg-zinc-50",onClick:()=>Tn(`/entities/${o}/${F.id}`),title:`打开《${F.name}》`,children:[i.jsx("td",{className:"max-w-64 truncate px-3 py-2 font-medium text-zinc-800",children:F.name}),i.jsx("td",{className:"max-w-40 truncate px-3 py-2 text-zinc-600",children:$f(o,B.key1,F.summary[B.key1])}),B.key2&&i.jsx("td",{className:"max-w-40 truncate px-3 py-2 text-zinc-600",children:$f(o,B.key2,F.summary[B.key2])}),i.jsx("td",{className:"whitespace-nowrap px-3 py-2 text-right text-xs text-zinc-400",children:ls(F.updatedAt)})]},F.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:L<=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((L-2)*jl),children:"‹ 上一页"}),i.jsxs("span",{className:"text-zinc-500",children:["第 ",L," / ",z," 页"]}),i.jsx("button",{type:"button",disabled:L>=z||g,className:"rounded-md border border-zinc-300 px-3 py-1 text-zinc-600 hover:bg-zinc-100 disabled:opacity-40",onClick:()=>O(L*jl),children:"下一页 ›"})]})]}),r&&U&&i.jsx(kp,{source:null,onCreated:()=>A(F=>F+1),onClose:()=>M(!1)})]})}function u3({type:n,id:r,currentData:o,deltaCount:l}){const c=Ae(T=>T.outline),d=Ae(T=>T.config),m=Ae(T=>T.loadOutline),[g,b]=p.useState(()=>{const T=Ae.getState().config?.currentPosition??"",_=Ae.getState().outline?.children??[];return T!==""&&rr(_).some(w=>w.id===T)?T:""}),[h,v]=p.useState(!1),[x,S]=p.useState(null),[j,N]=p.useState(null);p.useEffect(()=>{b(T=>{if(T!=="")return T;const _=d?.currentPosition??"";return _!==""&&rr(c?.children??[]).some(w=>w.id===_)?_:""})},[d?.currentPosition,c]);const k=rr(c?.children??[]),O=new Map(k.map(T=>[T.id,T.label]));async function E(){if(!(!g||h)){v(!0),N(null);try{const T=await pT({target_type:n,target_id:r,at_node_id:g});S(T)}catch(T){S(null),T instanceof Ie&&T.code==="OUTLINE_NODE_NOT_FOUND"?N("该节点已不存在,请重新选择计算节点"):N(T instanceof Ie?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(Se,{variant:"outline",size:"xs",type:"button",onClick:()=>{m()},children:"加载大纲"})]}):i.jsxs("select",{value:g,onChange:T=>b(T.target.value),"aria-label":"计算节点",className:et("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:"请选择大纲节点"}),k.map(T=>i.jsxs("option",{value:T.id,children:[" ".repeat(T.depth),T.label]},T.id))]})]}),i.jsx(Se,{variant:"outline",size:"sm",type:"button",disabled:!g||h,onClick:()=>{E()},children:h?"计算中…":"计算"})]}),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}),h&&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"})]}),!h&&x!==null&&i.jsx(d3,{result:x,currentData:o,nodeTitles:O})]})]})}function d3({result:n,currentData:r,nodeTitles:o}){const l=R_(r,n.state),c=o.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(km,{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,":记录应为 ",os(d.expected),",实际为 ",os(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?"(无)":os(d.from)," →"," ",d.to===void 0?"(已移除)":os(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:["《",o.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,":记录应为 ",os(g.expected),",实际 ",os(g.actual),"(已跳过)"]},g.index))}),i.jsx("div",{className:"mt-1.5",children:i.jsx($1,{changes:d.changes,skipped:d.skipped?.map(g=>g.index)})})]},m))})]})]})}const f3={character:"人物",setting:"设定",location:"地点",hook:"伏笔",event:"事件"};function wl(n,r){const o=n[r];return o==null?"":String(o)}function m3({values:n,onChange:r,placeholder:o}){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(Ot,{value:l,onChange:d=>{const m=[...n];m[c]=d.target.value,r(m)},placeholder:o,className:"h-8 flex-1 text-sm"}),i.jsx(Se,{variant:"outline",type:"button",className:"h-8 px-2 text-xs",onClick:()=>r(n.filter((d,m)=>m!==c)),children:"删除"})]},c)),i.jsx(Se,{variant:"outline",type:"button",className:"h-8 self-start px-2 text-xs",onClick:()=>r([...n,""]),children:"+ 添加"})]})}function p3({value:n,onChange:r}){const[o,l]=p.useState(()=>Object.entries(n??{}).map(([d,m])=>({key:d,value:String(m??"")})));p.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);r(m)}return i.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.map((d,m)=>i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Ot,{value:d.key,onChange:g=>c(o.map((b,h)=>h===m?{...b,key:g.target.value}:b)),placeholder:"键",className:"h-8 w-28 text-sm"}),i.jsx(Ot,{value:d.value,onChange:g=>c(o.map((b,h)=>h===m?{...b,value:g.target.value}:b)),placeholder:"值",className:"h-8 flex-1 text-sm"}),i.jsx(Se,{variant:"outline",type:"button",className:"h-8 px-2 text-xs",onClick:()=>c(o.filter((g,b)=>b!==m)),children:"删除"})]},m)),i.jsx(Se,{variant:"outline",type:"button",className:"h-8 self-start px-2 text-xs",onClick:()=>c([...o,{key:"",value:""}]),children:"+ 添加字段"})]})}function h3({type:n,id:r}){const o=n,[l,c]=p.useState(null),[d,m]=p.useState(!1),[g,b]=p.useState(!1),[h,v]=p.useState(null),[x,S]=p.useState(null),[j,N]=p.useState(!1),[k,O]=p.useState(null),[E,T]=p.useState(!1),[_,w]=p.useState(null),[I,A]=p.useState(!1),[U,M]=p.useState(!1),K=Rp(o);async function oe(){m(!0),v(null),b(!1);try{const C=await mo(o,r);c(C),S(JSON.parse(JSON.stringify(C.data)))}catch(C){c(null),S(null),C instanceof Ie&&C.code==="ENTITY_NOT_FOUND"?b(!0):v(C instanceof Ie?C.code:ct)}finally{m(!1)}}p.useEffect(()=>{oe()},[o,r]),Cs(()=>{oe()});async function Z(){if(!l||!x||j)return;const C=Op(l.data,x);if(!C){ke.getState().showToast("没有变更");return}N(!0),O(null);try{await Ra(o,r,{data:C}),ke.getState().showToast("已保存"),await oe()}catch(B){if(B instanceof Ie&&B.code==="ENTITY_NOT_FOUND"){b(!0);return}O(B instanceof Ie?B.message:"保存失败,请重试")}finally{N(!1)}}function ee(C,B){S(H=>H&&{...H,[C]:B})}async function G(){if(l)try{const C=await Vc(o,r),B=[];C.cascaded.relations>0&&B.push(`${C.cascaded.relations} 条关联`),C.cascaded.deltas>0&&B.push(`${C.cascaded.deltas} 条变更记录`),ke.getState().showToast(`已移入回收站,可随时还原${B.length>0?`(含 ${B.join("、")})`:""}`),A(!1),Tn(`/entities/${o}`)}catch(C){throw C}}async function te(){if(_)try{await qc(_.id),ke.getState().showToast("已删除关系"),w(null),await oe()}catch(C){throw C}}function X(C,B){return(B==="source"?C.sourceId:C.targetId)===r?l?.name??"本实体":(B==="source"?C.sourceName:C.targetName)??(B==="source"?C.sourceId:C.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(Se,{variant:"outline",type:"button",onClick:()=>Tn(`/entities/${o}`),children:"返回列表"})]})]})}):i.jsxs("section",{children:[i.jsxs("div",{className:"mb-1 flex items-center gap-3",children:[i.jsx(Mp,{items:[{label:"实体",href:"/entities/character"},{label:f3[o],href:`/entities/${o}`},{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(Se,{variant:"outline",type:"button",onClick:()=>{Z()},disabled:!l||j,children:j?"保存中…":"保存"}),i.jsx(Se,{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:["创建于 ",ls(l.createdAt)," · 更新于 ",ls(l.updatedAt)," ·"," ",i.jsxs("button",{type:"button",onClick:()=>M(C=>!C),title:"展开状态预览:计算该实体在任意大纲节点处的累积状态",className:"text-muted-foreground underline-offset-2 hover:text-primary hover:underline",children:["变更记录 ",l.deltaCount," 条"]})]}),l&&U&&i.jsx(u3,{type:o,id:r,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},(C,B)=>i.jsx("div",{className:"h-9 animate-pulse rounded bg-zinc-100"},B))}),i.jsx("div",{className:"space-y-3 rounded-md border border-zinc-200 p-4",children:Array.from({length:3},(C,B)=>i.jsx("div",{className:"h-9 animate-pulse rounded bg-zinc-100"},B))})]}),!d&&!l&&h!==null&&i.jsxs("div",{className:"rounded-md border border-zinc-200 p-4 text-sm text-zinc-600",children:[h===ct?"无法连接服务,请确认 ai-editor 服务已启动。":"详情加载失败,请重试。",i.jsx(Se,{variant:"outline",className:"ml-3",type:"button",onClick:()=>{oe()},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(C=>i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-zinc-700",children:C.label}),i.jsx(g3,{field:C,value:x[C.key],onChange:B=>ee(C.key,B)})]},C.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(p3,{value:x.custom_fields,onChange:C=>ee("custom_fields",C)})]})]}),k&&i.jsx("p",{className:"mt-3 text-sm text-red-600",children:k})]}),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(Se,{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(C=>{const B=C.sourceId===r,H=X(C,"source"),z=X(C,"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:[ho(C.relationType)," ",B?"→":"←"]}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-zinc-700",children:z}),i.jsx(Se,{variant:"outline",type:"button",className:"h-7 shrink-0 px-2 text-xs text-red-600 hover:bg-red-50",onClick:()=>w(C),children:"删除"})]},C.id)})})]})]}),E&&i.jsx(kp,{source:{type:o,id:r,name:l?.name??""},onCreated:oe,onClose:()=>T(!1)}),_&&i.jsx(ms,{title:"删除关系",description:`删除关系「${X(_,"source")} ${ho(_.relationType)} ${X(_,"target")}」?物理删除不可恢复,可重新建立。`,confirmLabel:"删除",danger:!0,onConfirm:te,onClose:()=>w(null)}),I&&i.jsx(ms,{title:"移入回收站",description:`将《${l?.name??""}》移入回收站。关联关系与变更记录将一并移入,可在回收站还原。`,confirmLabel:"移入回收站",danger:!0,onConfirm:G,onClose:()=>A(!1)})]})}function g3({field:n,value:r,onChange:o}){switch(n.control){case"textarea":return i.jsx("textarea",{value:wl({[n.key]:r},n.key),onChange:l=>o(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(Ot,{type:"number",value:wl({[n.key]:r},n.key),onChange:l=>o(l.target.value===""?void 0:Number(l.target.value)),className:"h-8 text-sm"});case"tags":return i.jsx(m3,{values:Array.isArray(r)?r:[],onChange:o,placeholder:"输入后回车添加下一项"});case"select":return i.jsx("select",{value:wl({[n.key]:r},n.key),onChange:l=>o(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:r===!0,onChange:l=>o(l.target.checked),className:"h-4 w-4 accent-zinc-900"});case"outline-node":return i.jsx(x3,{value:wl({[n.key]:r},n.key),onChange:o});default:return i.jsx(Ot,{value:wl({[n.key]:r},n.key),onChange:l=>o(l.target.value),className:"h-8 text-sm"})}}function x3({value:n,onChange:r}){const o=Ae(c=>c.outline),l=rr(o?.children??[]);return i.jsxs("select",{value:n,onChange:c=>r(c.target.value===""?null:c.target.value),className:et("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 b3(n){return n==="resolved"?"resolved":n==="abandoned"?"abandoned":"active"}function y3(n){const r={active:[],resolved:[],abandoned:[]};for(const o of n)r[b3(o.summary.status)].push(o);return r}function Ur(n,r){return n.filter(o=>o.relationType===r)}function eS(n,r){return Ur(n,"depends_on").filter(o=>o.sourceId===r).map(o=>o.targetName??o.targetId)}function v3(n,r){return Ur(n,"depends_on").filter(o=>o.targetId===r).map(o=>o.sourceName??o.sourceId)}function pv(n,r){return v3(n,r).length}function S3(n,r){return Ur(n,"involves").map(o=>o.sourceId===r?o.targetName??o.targetId:o.sourceName??o.sourceId)}const E3=3;function N3(n){const r=n.maxDepth??E3,o=[],l=new Set([n.startHookId]),c=[{hookId:n.startHookId,depth:0}];for(;c.length>0;){const{hookId:d,depth:m}=c.shift();if(o.push({hookId:d,name:n.names.get(d)??d,depth:m}),!(m>=r))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 o}function tS(n,r){if(!n)return!1;const o=[...n.children];for(;o.length>0;){const l=o.pop();if(l.id===r)return l.deleted!==!0;l.type!=="scene"&&l.children&&o.push(...l.children)}return!1}function j3(n){if(!n)return null;let r=null;const o=l=>{if(l.deleted!==!0&&(r=l.id,l.type!=="scene"&&l.children))for(const c of l.children)o(c)};for(const l of n.children)o(l);return r}function T3(n,r){const o=n?.currentPosition;return o!=null&&o!==""&&tS(r,o)?o:j3(r)}const nS={advance:"progressing",resolve:"resolved",abandon:"abandoned"},w3={advance:"advances",resolve:"resolves"};function hv(n){const r=n.status;return typeof r=="string"&&r!==""?r:"planted"}function sS(n,r){return{field:"status",op:"update",from:n,to:r}}function C3(n,r,o){return{source_type:"outline_node",source_id:o,target_type:"hook",target_id:r,relation_type:w3[n]}}function R3(n,r){return{source_type:"outline_node",source_id:r,target_type:"hook",target_id:n,relation_type:"plants"}}function rS(n){return{status:n}}async function O3(n){const r=nS[n.kind];await Am({node_id:n.nodeId,target_type:"hook",target_id:n.hookId,changes:[sS(n.fromStatus,r)],description:n.description});try{await Oa(C3(n.kind,n.hookId,n.nodeId))}catch(o){if(!(o instanceof Ie&&o.code==="RELATION_EXISTS"))throw o}await Ra("hook",n.hookId,{data:rS(r)})}async function k3(n){await Am({node_id:n.nodeId,target_type:"hook",target_id:n.hookId,changes:[sS(n.fromStatus,"abandoned")],description:n.description}),await Ra("hook",n.hookId,{data:rS("abandoned")})}const Wf={advance:"推进",resolve:"回收",abandon:"废弃"};function _3(n){return n==="resolved"||n==="abandoned"}function Cl(n,r){const o=n[r];return o==null?"":String(o)}function M3(){const[n,r]=p.useState(null),[o,l]=p.useState(!1),[c,d]=p.useState(null),[m,g]=p.useState(0);Cs(()=>g(je=>je+1));const[b,h]=p.useState([]),[v,x]=p.useState(!1),[S,j]=p.useState(null),[N,k]=p.useState(!1),[O,E]=p.useState(null),[T,_]=p.useState(null),[w,I]=p.useState("advance"),[A,U]=p.useState(""),[M,K]=p.useState(""),[oe,Z]=p.useState(null),[ee,G]=p.useState(!1),[te,X]=p.useState(null),[C,B]=p.useState(null),[H,z]=p.useState(null),[L,D]=p.useState(!1),[q,V]=p.useState(null),[Q,ne]=p.useState(!1),[F,Te]=p.useState(""),[me,he]=p.useState({}),[Le,Ve]=p.useState(""),[Re,ze]=p.useState(null),[De,ye]=p.useState(!1),[Be,ae]=p.useState({}),de=Ae(je=>je.config),ue=Ae(je=>je.outline),Ce=rr(ue?.children??[]),fe=n===null?null:y3(n);p.useEffect(()=>{let je=!1;return l(!0),d(null),x(!1),ae({}),bo("hook",{}).then(Me=>{je||r(Me.items)}).catch(Me=>{je||(r(null),d(Me instanceof Ie?Me.code:ct))}),ja({source_type:"hook",relation_type:"depends_on",depth:1}).then(Me=>{je||h(Me.relations)}).catch(()=>{je||x(!0)}).finally(()=>{je||l(!1)}),()=>{je=!0}},[m]),p.useEffect(()=>{Ae.getState().outline===null&&Ae.getState().config!==null&&Ae.getState().loadOutline()},[]);async function be(je){j(null),k(!0),E(null);try{j(await mo("hook",je.id))}catch(Me){E(Me instanceof Ie?Me.message:"详情加载失败,请重试")}finally{k(!1)}}async function qe(je,Me){_(null),Z(null),K("");try{const $e=await mo("hook",Me.id),rt=Ae.getState().config?.currentPosition,Nt=rt!=null&&rt!==""&&tS(ue,rt)?rt:"";U(Nt),I(je),_($e)}catch{ke.getState().showToast("无法读取伏笔状态,请重试","error")}}async function se(){const je=T;if(!je||ee)return;const Me=w;G(!0),Z(null);try{if(Me==="abandon"){const $e=T3(de,ue);if($e===null){Z("大纲为空,无法记录废弃变更");return}await k3({hookId:je.id,fromStatus:hv(je.data),nodeId:$e,description:M.trim()})}else{if(A===""){Z("请选择大纲节点");return}await O3({kind:Me,hookId:je.id,fromStatus:hv(je.data),nodeId:A,description:M.trim()})}ke.getState().showToast(`已${Wf[Me]}`),_(null),g($e=>$e+1)}catch($e){Z($e instanceof Ie?$e.message:"操作失败,请重试")}finally{G(!1)}}async function Y(je){X(null),z(null);try{const Me=await mo("hook",je.id);X(Me),B(JSON.parse(JSON.stringify(Me.data)))}catch{ke.getState().showToast("无法读取伏笔数据,请重试","error")}}async function ge(){if(!te||!C||L)return;const je=Op(te.data,C);if(!je){ke.getState().showToast("没有变更"),X(null);return}D(!0),z(null);try{await Ra("hook",te.id,{data:je}),ke.getState().showToast("已保存"),X(null),g(Me=>Me+1)}catch(Me){z(Me instanceof Ie?Me.message:"保存失败,请重试")}finally{D(!1)}}async function J(je){je.preventDefault();const Me=F.trim();if(!Me){ze("请输入名称");return}ye(!0),ze(null);try{const $e=await Mm("hook",{name:Me,data:me});if(Le!=="")try{await Oa(R3($e.id,Le))}catch(rt){ke.getState().showToast(`已创建伏笔《${Me}》,但埋点关联失败:${rt instanceof Ie?rt.message:"未知错误"}`,"error"),ne(!1),g(Nt=>Nt+1);return}ke.getState().showToast(`已创建伏笔《${Me}》`),ne(!1),Te(""),he({}),Ve(""),g(rt=>rt+1)}catch($e){ze($e instanceof Ie?$e.message:"创建失败,请重试")}finally{ye(!1)}}async function we(){const je=q;if(je)try{const Me=await Vc("hook",je.id),$e=[];Me.cascaded.relations>0&&$e.push(`${Me.cascaded.relations} 条关联`),Me.cascaded.deltas>0&&$e.push(`${Me.cascaded.deltas} 条变更记录`),ke.getState().showToast(`已移入回收站,可随时还原${$e.length>0?`(含 ${$e.join("、")})`:""}`),V(null),g(rt=>rt+1)}catch(Me){throw Me}}async function Xe(je){if(Be[je.id]){ae(Me=>{const $e={...Me};return delete $e[je.id],$e});return}ae(Me=>({...Me,[je.id]:{status:"loading",nodes:[]}}));try{const Me=new Map,$e=new Map,rt=[{id:je.id,depth:0}],Nt=new Set;for(;rt.length>0;){const{id:bt,depth:yn}=rt.shift();if(Nt.has(bt))continue;Nt.add(bt);const an=await mo("hook",bt);$e.set(bt,an.name);const Ke=Ur(an.relations,"depends_on").filter(Tt=>Tt.sourceId===bt);if(Me.set(bt,Ke),!(yn>=2))for(const Tt of Ke)$e.has(Tt.targetId)||$e.set(Tt.targetId,Tt.targetName??Tt.targetId),rt.push({id:Tt.targetId,depth:yn+1})}const kt=N3({startHookId:je.id,depsOf:Me,names:$e});ae(bt=>({...bt,[je.id]:{status:"ready",nodes:kt}}))}catch{ae(Me=>({...Me,[je.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(Se,{type:"button",className:"ml-auto",onClick:()=>ne(!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===ct?"无法连接服务,请确认 ai-editor 服务已启动。":"伏笔池加载失败,请重试。",i.jsx(Se,{variant:"outline",className:"ml-auto h-7 px-2 text-xs",type:"button",onClick:()=>g(je=>je+1),children:"重试"})]}),o&&fe===null&&c===null&&i.jsx("div",{className:"space-y-4",children:Array.from({length:3},(je,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},($e,rt)=>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"})]},rt))]},Me))}),!o&&fe!==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(Se,{className:"mt-4",type:"button",onClick:()=>ne(!0),children:"+ 新建伏笔"})]}),fe!==null&&n&&n.length>0&&i.jsxs("div",{className:"space-y-4",children:[i.jsx(em,{title:"活跃",icon:i.jsx("span",{className:"size-2 shrink-0 rounded-full bg-primary"}),hooks:fe.active,depEdges:b,depEdgesFailed:v,chains:Be,onToggleChain:Xe,onDetail:be,onLifecycle:qe,onEdit:Y,onDelete:V}),i.jsx(em,{title:"已回收",icon:i.jsx(Cm,{className:"size-3.5 shrink-0 text-primary"}),hooks:fe.resolved,depEdges:b,depEdgesFailed:v,chains:Be,onToggleChain:Xe,onDetail:be,onLifecycle:qe,onEdit:Y,onDelete:V}),i.jsx(em,{title:"已废弃",icon:i.jsx(nj,{className:"size-3.5 shrink-0 text-muted-foreground"}),hooks:fe.abandoned,depEdges:b,depEdgesFailed:v,chains:Be,onToggleChain:Xe,onDetail:be,onLifecycle:qe,onEdit:Y,onDelete:V})]}),i.jsx(Ks,{open:Q,onOpenChange:je=>!je&&ne(!1),children:i.jsxs(Qs,{className:"sm:max-w-md",children:[i.jsx(Zs,{children:i.jsx(Ws,{children:"新建伏笔"})}),i.jsxs("form",{id:"create-hook-form",onSubmit:J,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(Ot,{value:F,onChange:je=>Te(je.target.value),placeholder:"如:身世之谜",maxLength:100})]}),i.jsx(gv,{fields:D3,data:me,onChange:he,nodeOptions:Ce}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"埋点节点(选填,可空)"}),i.jsx(Tm,{value:Le,onChange:Ve,nodeOptions:Ce})]}),Re&&i.jsx("p",{className:"text-sm text-destructive",children:Re})]}),i.jsxs(Js,{children:[i.jsx(Se,{variant:"outline",type:"button",onClick:()=>ne(!1),disabled:De,children:"取消"}),i.jsx(Se,{type:"submit",form:"create-hook-form",disabled:De,children:"创建"})]})]})}),i.jsx(Ks,{open:S!==null||N,onOpenChange:je=>!je&&j(null),children:i.jsxs(Qs,{className:"sm:max-w-lg",children:[i.jsx(Zs,{children:i.jsx(Ws,{children:"伏笔详情"})}),N&&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(A3,{detail:S}),i.jsx(Js,{children:i.jsx(Se,{variant:"outline",type:"button",onClick:()=>j(null),children:"关闭"})})]})}),T&&i.jsx(Ks,{open:!0,onOpenChange:je=>!je&&!ee&&_(null),children:i.jsxs(Qs,{className:"sm:max-w-md",children:[i.jsx(Zs,{children:i.jsxs(Ws,{children:[Wf[w],"伏笔《",T.name,"》"]})}),i.jsxs("div",{className:"flex flex-col gap-3",children:[w!=="abandon"&&i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"大纲节点(默认当前位置)"}),i.jsx(Tm,{value:A,onChange:U,nodeOptions:Ce,placeholder:"请选择节点"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"描述"}),i.jsx("textarea",{value:M,onChange:je=>K(je.target.value),rows:2,placeholder:w==="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 → ",nS[w],w==="advance"&&" + advances 关系",w==="resolve"&&" + resolves 关系"," + 同步 status"]}),w==="resolve"&&v&&i.jsx("p",{className:"mt-2 text-sm text-destructive",children:"依赖关系加载失败,无法确认依赖者"}),w==="resolve"&&!v&&pv(b,T.id)>0&&i.jsxs("p",{className:"mt-2 text-sm text-destructive",children:["有 ",pv(b,T.id)," 个伏笔依赖此伏笔"]})]}),oe&&i.jsx("p",{className:"text-sm text-destructive",children:oe})]}),i.jsxs(Js,{children:[i.jsx(Se,{variant:"outline",type:"button",onClick:()=>_(null),disabled:ee,children:"取消"}),i.jsx(Se,{type:"button",onClick:()=>{se()},disabled:ee,children:ee?"提交中…":`确认${Wf[w]}`})]})]})}),te&&C&&i.jsx(Ks,{open:!0,onOpenChange:je=>!je&&!L&&X(null),children:i.jsxs(Qs,{className:"sm:max-w-md",children:[i.jsx(Zs,{children:i.jsxs(Ws,{children:["编辑伏笔《",te.name,"》"]})}),i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsx(gv,{fields:Rp("hook"),data:C,onChange:je=>B(Me=>Me&&{...Me,...je}),nodeOptions:Ce}),H&&i.jsx("p",{className:"text-sm text-destructive",children:H})]}),i.jsxs(Js,{children:[i.jsx(Se,{variant:"outline",type:"button",onClick:()=>X(null),disabled:L,children:"取消"}),i.jsx(Se,{type:"button",onClick:()=>{ge()},disabled:L,children:L?"保存中…":"保存"})]})]})}),q&&i.jsx(ms,{title:"移入回收站",description:`将《${q.name}》移入回收站。关联关系与变更记录将一并移入,可在回收站还原。`,confirmLabel:"移入回收站",danger:!0,onConfirm:we,onClose:()=>V(null)})]})}function em({title:n,icon:r,hooks:o,depEdges:l,depEdgesFailed:c,chains:d,onToggleChain:m,onDetail:g,onLifecycle:b,onEdit:h,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:[r,i.jsx("span",{children:n}),i.jsxs("span",{className:"text-muted-foreground",children:["(",o.length,")"]})]}),o.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:o.map(x=>{const S=_3(x.summary.status),j=c?[]:eS(l,x.id),N=d[x.id],k=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}),k&&i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:k}),i.jsx("span",{className:"ml-auto shrink-0",children:i.jsxs(cu,{children:[i.jsx(uu,{render:i.jsx(Se,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground","aria-label":`${x.name} 操作`,children:i.jsx(Rm,{})})}),i.jsxs(du,{align:"end",children:[i.jsx(ds,{onClick:()=>g(x),children:"详情"}),i.jsx(ds,{disabled:S,onClick:()=>b("advance",x),children:"推进"}),i.jsx(ds,{disabled:S,onClick:()=>b("resolve",x),children:"回收"}),i.jsx(ds,{disabled:S,onClick:()=>b("abandon",x),children:"废弃"}),i.jsx(ds,{onClick:()=>h(x),children:"编辑"}),i.jsx(Ep,{}),i.jsx(ds,{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("、")]}),N?.status==="loading"&&i.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"依赖链展开中…"}),N?.status==="error"&&i.jsx("p",{className:"mt-0.5 text-xs text-destructive",children:"依赖链加载失败"}),N?.status==="ready"&&N.nodes.length>1&&i.jsx("ul",{className:"mt-1 space-y-0.5 border-l border-border pl-2",children:N.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 A3({detail:n}){const r=n.id,o=typeof n.data.status=="string"?n.data.status:"",l=typeof n.data.category=="string"?n.data.category:"",c=Ur(n.relations,"plants"),d=Ur(n.relations,"advances"),m=Ur(n.relations,"resolves"),g=eS(n.relations,r),b=Ur(n.relations,"depends_on").filter(x=>x.targetId===r).map(x=>x.sourceName??x.sourceId),h=S3(n.relations,r),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}),o&&i.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:wp[o]??o})]}),i.jsxs("p",{className:"text-xs text-muted-foreground",children:["创建于 ",ls(n.createdAt)," · 更新于 ",ls(n.updatedAt)]}),i.jsx(fo,{title:"埋点节点(plants)",items:c.map(x=>x.sourceName??x.sourceId)}),i.jsx(fo,{title:"推进节点(advances)",items:d.map(x=>x.sourceName??x.sourceId)}),i.jsx(fo,{title:"回收节点(resolves)",items:m.map(x=>x.sourceName??x.sourceId)}),i.jsx(fo,{title:"预计回收节点",items:v?[v]:[]}),i.jsx(fo,{title:"依赖(depends_on)",items:g}),i.jsx(fo,{title:"被依赖(其他伏笔依赖本伏笔)",items:b}),i.jsx(fo,{title:"涉及(involves)",items:h})]})}function fo({title:n,items:r}){return i.jsxs("div",{children:[i.jsx("p",{className:"mb-0.5 text-xs font-medium text-muted-foreground",children:n}),r.length===0?i.jsx("p",{className:"text-xs text-muted-foreground/70",children:"无"}):i.jsx("ul",{className:"flex flex-wrap gap-1",children:r.map((o,l)=>i.jsx("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:o},`${o}-${l}`))})]})}const D3=[{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:Cp},{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 gv({fields:n,data:r,onChange:o,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(z3,{field:c,value:r[c.key],nodeOptions:l,onValue:d=>o({...r,[c.key]:d})})]},c.key))})}function z3({field:n,value:r,nodeOptions:o,onValue:l}){switch(n.control){case"textarea":return i.jsx("textarea",{value:Cl({[n.key]:r},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(Ot,{type:"number",value:Cl({[n.key]:r},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:Cl({[n.key]:r},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:r===!0,onChange:c=>l(c.target.checked),className:"h-4 w-4 accent-primary"});case"outline-node":return i.jsx(Tm,{value:Cl({[n.key]:r},n.key),onChange:l,nodeOptions:o});default:return i.jsx(Ot,{value:Cl({[n.key]:r},n.key),onChange:c=>l(c.target.value),placeholder:n.key==="category"?`如:${IN.join(" / ")}`:void 0,className:"h-8 text-sm"})}}function Tm({value:n,onChange:r,nodeOptions:o,placeholder:l="未设置"}){return i.jsxs("select",{value:n,onChange:c=>r(c.target.value),className:et("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}),o.map(c=>i.jsxs("option",{value:c.id,children:[" ".repeat(c.depth),c.label]},c.id))]})}function L3(n,r,o){const l=o===void 0?n:n.filter(d=>d!==o);if(r.kind==="end")return l.length;const c=l.indexOf(r.id);return c===-1?l.length:r.kind==="before"?c:c+1}function oS(n){const r=n.summary.tags;return Array.isArray(r)?r.filter(o=>typeof o=="string"):[]}function I3(n){const r=new Set,o=[];for(const l of n)for(const c of oS(l))c!==""&&!r.has(c)&&(r.add(c),o.push(c));return o}function B3(n,r){return r===null||r===""?n:n.filter(o=>oS(o).includes(r))}function aS(n){const r=[],o=new Set;for(const l of n.split(/[,,、\n]/)){const c=l.trim();c!==""&&!o.has(c)&&(o.add(c),r.push(c))}return r}function lS(n){return Array.isArray(n)?n.filter(r=>typeof r=="string").join(","):""}function U3(n){const r=n.data;return{name:n.name,description:typeof r.description=="string"?r.description:"",timeLabel:typeof r.time_label=="string"?r.time_label:"",tagsInput:lS(r.tags)}}function iS(n,r){const o={};r.name.trim()!==n.name&&(o.name=r.name.trim());const l={};r.description.trim()!==""&&(l.description=r.description.trim()),r.timeLabel.trim()!==""&&(l.time_label=r.timeLabel.trim());const c=aS(r.tagsInput);c.length>0&&(l.tags=c);const d={};for(const m of["description","time_label","tags"])JSON.stringify(l[m])!==JSON.stringify(n.data[m])&&(d[m]=l[m]);return Object.keys(d).length>0&&(o.data=d),o.name===void 0&&o.data===void 0?null:o}const xv={name:"",description:"",timeLabel:"",tagsInput:""};function H3(){const[n,r]=p.useState(null),[o,l]=p.useState(!1),[c,d]=p.useState(null),[m,g]=p.useState(0);Cs(()=>g(ae=>ae+1));const[b,h]=p.useState([]),[v,x]=p.useState(!1),[S,j]=p.useState(null),[N,k]=p.useState(null),[O,E]=p.useState(null),[T,_]=p.useState(!1),[w,I]=p.useState(!1),[A,U]=p.useState(xv),[M,K]=p.useState(""),[oe,Z]=p.useState(null),[ee,G]=p.useState(!1),[te,X]=p.useState(null),[C,B]=p.useState(null),[H,z]=p.useState(null),[L,D]=p.useState(!1),[q,V]=p.useState(null),Q=Ae(ae=>ae.outline),ne=rr(Q?.children??[]);p.useEffect(()=>{let ae=!1;return l(!0),d(null),x(!1),Promise.allSettled([bo("event",{}).then(de=>{ae||r(de.items)}).catch(de=>{ae||(r(null),d(de instanceof Ie?de.code:ct))}),ja({source_type:"event",relation_type:"occurs_in",depth:1}).then(de=>{ae||h(de.relations)}).catch(()=>{ae||x(!0)})]).finally(()=>{ae||l(!1)}),()=>{ae=!0}},[m]),p.useEffect(()=>{Ae.getState().outline===null&&Ae.getState().config!==null&&Ae.getState().loadOutline()},[]);async function F(ae){ae.preventDefault();const de=A.name.trim();if(!de){Z("请输入名称");return}G(!0),Z(null);try{const ue={};A.description.trim()!==""&&(ue.description=A.description.trim()),A.timeLabel.trim()!==""&&(ue.time_label=A.timeLabel.trim());const Ce=aS(A.tagsInput);Ce.length>0&&(ue.tags=Ce);const fe=await Mm("event",{name:de,data:ue});if(M!=="")try{await Oa({source_type:"event",source_id:fe.id,target_type:"outline_node",target_id:M,relation_type:"occurs_in"})}catch(be){ke.getState().showToast(`已创建事件《${de}》,但节点关联失败:${be instanceof Ie?be.message:"未知错误"}`,"error"),I(!1),g(qe=>qe+1);return}ke.getState().showToast(`已创建事件《${de}》`),I(!1),U(xv),K(""),g(be=>be+1)}catch(ue){Z(ue instanceof Ie?ue.message:"创建失败,请重试")}finally{G(!1)}}function Te(ae){const de=ae.summary;X(ae),z(null),B({name:ae.name,description:typeof de.description=="string"?de.description:"",timeLabel:typeof de.time_label=="string"?de.time_label:"",tagsInput:lS(de.tags)})}async function me(){const ae=te,de=C;if(!(!ae||!de||L)){D(!0),z(null);try{const ue=iS({name:ae.name,data:ae.summary},de);if(ue===null){ke.getState().showToast("没有变更"),X(null);return}await Ra("event",ae.id,ue),ke.getState().showToast("已保存"),X(null),g(Ce=>Ce+1)}catch(ue){z(ue instanceof Ie?ue.message:"保存失败,请重试")}finally{D(!1)}}}async function he(){const ae=q;if(ae)try{const de=await Vc("event",ae.id),ue=[];de.cascaded.relations>0&&ue.push(`${de.cascaded.relations} 条关联`),de.cascaded.deltas>0&&ue.push(`${de.cascaded.deltas} 条变更记录`),ke.getState().showToast(`已移入回收站,可随时还原${ue.length>0?`(含 ${ue.join("、")})`:""}`),V(null),g(Ce=>Ce+1)}catch(de){throw de}}function Le(ae){const de=ae.currentTarget.getBoundingClientRect();return ae.clientY<de.top+de.height/2?"before":"after"}function Ve(ae,de){ae.preventDefault(),ae.dataTransfer.dropEffect="move";const ue=Le(ae);E(Ce=>Ce!==null&&Ce.kind!=="end"&&Ce.kind===ue&&Ce.id===de?Ce:{kind:ue,id:de})}async function Re(ae,de){if(ae.preventDefault(),!N||T)return;if(de===N){k(null),E(null);return}const ue=(n??[]).map(fe=>fe.id),Ce=L3(ue,{kind:Le(ae),id:de},N);_(!0);try{await dT(N,{order:Ce}),ke.getState().showToast("已调整事件顺序"),g(fe=>fe+1)}catch(fe){ke.getState().showToast(fe instanceof Ie?`排序失败:${fe.message}`:"排序失败,请重试","error")}finally{_(!1),k(null),E(null)}}const ze=n===null?[]:I3(n),De=n===null?null:B3(n,S),ye=ae=>v?0:b.filter(de=>de.sourceId===ae).length,Be=!v;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(Se,{type:"button",className:"ml-auto",onClick:()=>I(!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===ct?"无法连接服务,请确认 ai-editor 服务已启动。":"时间轴加载失败,请重试。",i.jsx(Se,{variant:"outline",className:"ml-auto h-7 px-2 text-xs",type:"button",onClick:()=>g(ae=>ae+1),children:"重试"})]}),o&&n===null&&c===null&&i.jsx("div",{className:"space-y-2",children:Array.from({length:4},(ae,de)=>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"})]},de))}),!o&&n!==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:"还没有事件。先定义一个关键事件,再把它们排成故事的时间骨架。"}),i.jsx(Se,{className:"mt-4",type:"button",onClick:()=>I(!0),children:"+ 新建事件"})]}),n!==null&&n.length>0&&i.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-1.5",children:[i.jsx("button",{type:"button",onClick:()=>j(null),className:et("rounded-full px-2.5 py-0.5 text-xs transition-colors",S===null?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"),children:"全部"}),ze.map(ae=>i.jsx("button",{type:"button",onClick:()=>j(de=>de===ae?null:ae),className:et("rounded-full px-2.5 py-0.5 text-xs transition-colors",S===ae?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"),children:ae},ae))]}),!o&&De!==null&&De.length>0&&i.jsx("ul",{className:"divide-y divide-border/70 overflow-hidden rounded-md border border-border",children:De.map(ae=>{const de=ae.summary,ue=typeof de.time_label=="string"?de.time_label:"",Ce=Array.isArray(de.tags)?de.tags.filter(se=>typeof se=="string"):[],fe=ye(ae.id),be=O?.kind==="before"&&O.id===ae.id,qe=O?.kind==="after"&&O.id===ae.id;return i.jsxs("li",{draggable:!T,onDragStart:se=>{se.dataTransfer.setData("text/plain",ae.id),se.dataTransfer.effectAllowed="move",k(ae.id),E(null)},onDragEnd:()=>{k(null),E(null)},onDragOver:se=>Ve(se,ae.id),onDrop:se=>{Re(se,ae.id)},className:"relative px-3 py-2",children:[be&&i.jsx("div",{className:"absolute inset-x-0 -top-px h-0.5 bg-primary"}),qe&&i.jsx("div",{className:"absolute inset-x-0 -bottom-px h-0.5 bg-primary"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"cursor-grab text-muted-foreground/60 active:cursor-grabbing",title:"拖拽调整事件先后顺序","aria-hidden":"true",children:i.jsx(cj,{className:"size-4"})}),i.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",title:ae.name,children:ae.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ue!==""?ue:"未标注时间"}),Ce.map(se=>i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:se},se)),Be&&i.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[fe," 节点"]}),i.jsx("span",{className:"ml-auto shrink-0",children:i.jsxs(cu,{children:[i.jsx(uu,{render:i.jsx(Se,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground","aria-label":`${ae.name} 操作`,children:i.jsx(Rm,{})})}),i.jsxs(du,{align:"end",children:[i.jsx(ds,{onClick:()=>Tn(`/timeline/${ae.id}`),children:"详情"}),i.jsx(ds,{onClick:()=>Te(ae),children:"编辑"}),i.jsx(Ep,{}),i.jsx(ds,{variant:"destructive",onClick:()=>V(ae),children:"移入回收站"})]})]})})]})]},ae.id)})}),!o&&n!==null&&n.length>0&&De!==null&&De.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:["没有匹配「",S,"」的事件"]}),i.jsx(Ks,{open:w,onOpenChange:ae=>!ae&&I(!1),children:i.jsxs(Qs,{className:"sm:max-w-md",children:[i.jsx(Zs,{children:i.jsx(Ws,{children:"新建事件"})}),i.jsxs("form",{id:"create-event-form",onSubmit:F,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(Ot,{value:A.name,onChange:ae=>U(de=>({...de,name:ae.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:A.description,onChange:ae=>U(de=>({...de,description:ae.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(Ot,{value:A.timeLabel,onChange:ae=>U(de=>({...de,timeLabel:ae.target.value})),placeholder:"如:第二天黄昏(自由文本,不参与排序)"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"标签"}),i.jsx(Ot,{value:A.tagsInput,onChange:ae=>U(de=>({...de,tagsInput:ae.target.value})),placeholder:"如:主线,战争(逗号/回车分隔)"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"关联大纲节点(选填,可空)"}),i.jsx(Y3,{value:M,onChange:K,nodeOptions:ne})]}),oe&&i.jsx("p",{className:"text-sm text-destructive",children:oe})]}),i.jsxs(Js,{children:[i.jsx(Se,{variant:"outline",type:"button",onClick:()=>I(!1),disabled:ee,children:"取消"}),i.jsx(Se,{type:"submit",form:"create-event-form",disabled:ee,children:"创建"})]})]})}),te&&C&&i.jsx(Ks,{open:!0,onOpenChange:ae=>!ae&&!L&&X(null),children:i.jsxs(Qs,{className:"sm:max-w-md",children:[i.jsx(Zs,{children:i.jsxs(Ws,{children:["编辑事件《",te.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(Ot,{value:C.name,onChange:ae=>B(de=>de&&{...de,name:ae.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:C.description,onChange:ae=>B(de=>de&&{...de,description:ae.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(Ot,{value:C.timeLabel,onChange:ae=>B(de=>de&&{...de,timeLabel:ae.target.value}),placeholder:"如:第二天黄昏(自由文本,不参与排序)"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"标签"}),i.jsx(Ot,{value:C.tagsInput,onChange:ae=>B(de=>de&&{...de,tagsInput:ae.target.value}),placeholder:"如:主线,战争(逗号/回车分隔)"})]}),H&&i.jsx("p",{className:"text-sm text-destructive",children:H})]}),i.jsxs(Js,{children:[i.jsx(Se,{variant:"outline",type:"button",onClick:()=>X(null),disabled:L,children:"取消"}),i.jsx(Se,{type:"button",onClick:()=>{me()},disabled:L,children:L?"保存中…":"保存"})]})]})}),q&&i.jsx(ms,{title:"移入回收站",description:`将《${q.name}》移入回收站。关联关系与变更记录将一并移入,可在回收站还原。`,confirmLabel:"移入回收站",danger:!0,onConfirm:he,onClose:()=>V(null)})]})}function Y3({value:n,onChange:r,nodeOptions:o,placeholder:l="未设置"}){return i.jsxs("select",{value:n,onChange:c=>r(c.target.value),className:et("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}),o.map(c=>i.jsxs("option",{value:c.id,children:[" ".repeat(c.depth),c.label]},c.id))]})}const cS=p.createContext(void 0);function $l(n){const r=p.useContext(cS);if(r===void 0&&!n)throw new Error(En(47));return r}function P3(){return{...mp(),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 V3={...hp,disabled:Ye(n=>n.disabled),instantType:Ye(n=>n.instantType),openMethod:Ye(n=>n.openMethod),openChangeReason:Ye(n=>n.openChangeReason),modal:Ye(n=>n.modal),focusManagerModal:Ye(n=>n.focusManagerModal),stickIfOpen:Ye(n=>n.stickIfOpen),titleElementId:Ye(n=>n.titleElementId),descriptionElementId:Ye(n=>n.descriptionElementId),openOnHover:Ye(n=>n.openOnHover),closeDelay:Ye(n=>n.closeDelay),hasViewport:Ye(n=>n.hasViewport)};class Ap extends ou{constructor(r,o,l=!1){const c={...P3(),...r},d=new Xl;c.open&&r?.mounted===void 0&&(c.mounted=!0),c.floatingRootContext=m1(d,o,l),super(c,{popupRef:p.createRef(),backdropRef:p.createRef(),internalBackdropRef:p.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:p.createRef(),beforeContentFocusGuardRef:p.createRef(),stickIfOpenTimeout:new fs,triggerElements:d},V3)}setOpen=(r,o)=>{const l=o.reason===dn,c=o.reason===yo&&o.event.detail===0,d=!r&&(o.reason===Qc||o.reason==null),m=c1(o),g=this.select("activeTriggerId");if(!r&&o.reason===p0&&o.trigger==null&&g!=null&&(o.trigger=this.context.triggerElements.getById(g)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(r,o),o.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(r,o);const b=()=>{const h={open:r,openChangeReason:o.reason};cp(h,r,o.trigger,m()),this.update(h)};l?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(I0,()=>{this.set("stickIfOpen",!1)}),lr.flushSync(b)):b(),c||d?this.set("instantType",c?"click":"dismiss"):o.reason===vo?this.set("instantType","focus"):this.set("instantType",void 0)};static useStore(r,o){const{store:l,internalStore:c}=i1(r,(d,m)=>new Ap(o,d,m));return p.useEffect(()=>c?.disposeEffect(),[c]),l}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()}function bv({props:n}){const{children:r,open:o,defaultOpen:l=!1,onOpenChange:c,onOpenChangeComplete:d,modal:m=!1,handle:g,triggerId:b,defaultTriggerId:h=null}=n,v=Ap.useStore(g?.store,{modal:m,open:l,openProp:o,activeTriggerId:h,triggerIdProp:b});u1(v,o,l,h),v.useControlledProp("openProp",o),v.useControlledProp("triggerIdProp",b);const x=v.useState("open"),S=v.useState("mounted"),j=v.useState("payload"),N=ur()!=null;v.useContextCallback("onOpenChange",c),v.useContextCallback("onOpenChangeComplete",d),f1(v,x),up(v);const{forceUnmount:k}=dp(x,v,()=>{v.update({stickIfOpen:!0,openChangeReason:null})});v.useSyncedValues({modal:m,nested:N}),p.useEffect(()=>{x||v.context.stickIfOpenTimeout.clear()},[v,x]);const O=p.useCallback(()=>{v.setOpen(!1,jt(Fm))},[v]);p.useImperativeHandle(n.actionsRef,()=>({unmount:k,close:O}),[k,O]);const E=x||S,T=p.useMemo(()=>({store:v}),[v]);return i.jsxs(cS.Provider,{value:T,children:[E&&i.jsx(F3,{store:v,modal:m}),typeof r=="function"?r({payload:j}):r]})}function q3(n){return $l(!0)?i.jsx(bv,{props:n}):i.jsx(G0,{children:i.jsx(bv,{props:n})})}function F3({store:n,modal:r}){const o=n.useState("floatingRootContext"),l=lp(o,{outsidePressEvent:{mouse:r==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),c=l.reference??Ut,d=l.trigger??Ut,m=p.useMemo(()=>tr(lu,l.floating),[l.floating]);return fp(n,{activeTriggerProps:c,inactiveTriggerProps:d,popupProps:m}),null}const G3=300,X3=p.forwardRef(function(r,o){const{render:l,className:c,style:d,disabled:m=!1,nativeButton:g=!0,handle:b,payload:h,openOnHover:v=!1,delay:x=G3,closeDelay:S=0,id:j,...N}=r,k=$l(!0),O=b?.store??k?.store;if(!O)throw new Error(En(74));const E=Co(j),T=O.useState("isTriggerActive",E),_=O.useState("floatingRootContext"),w=O.useState("isOpenedByTrigger",E),I=O.useState("triggerPopupId",E),A=p.useRef(null),{registerTrigger:U,isMountedByThisTrigger:M}=d1(E,A,O,{payload:h,disabled:m,openOnHover:v,closeDelay:S}),K=O.useState("openChangeReason"),oe=O.useState("stickIfOpen"),Z=O.useState("openMethod"),ee=O.useState("focusManagerModal"),G=b1(_,{enabled:!m&&_!=null&&v&&(Z!=="touch"||K!==yo),mouseOnly:!0,move:!1,handleClose:y1(),restMs:x,delay:{close:S},triggerElementRef:A,isActiveTrigger:T,isClosing:()=>O.select("transitionStatus")==="ending"}),te=X0(_,{enabled:_!=null,stickIfOpen:oe}),X=k1(()=>O.select("open"),ne=>{O.set("openMethod",ne)}),C=O.useState("triggerProps",M),{getButtonProps:B,buttonRef:H}=ql({disabled:m,native:g}),z={open(ne){return ne&&K===yo?im.open(ne):fw.open(ne)}},{preFocusGuardRef:L,handlePreFocusGuardFocus:D,handleFocusTargetFocus:q}=M1(O,A),Q=fn("button",r,{state:{disabled:m,open:w},ref:[H,o,U,A],props:[te.reference,G,C,X,{[B0]:"",id:E,"aria-haspopup":"dialog","aria-expanded":w,"aria-controls":I},N,B],stateAttributesMapping:z});return M&&!ee?i.jsxs(p.Fragment,{children:[i.jsx(Hr,{ref:L,onFocus:D}),i.jsx(p.Fragment,{children:Q},E),i.jsx(Hr,{ref:O.context.triggerFocusTargetRef,onFocus:q})]}):i.jsx(p.Fragment,{children:Q},E)}),uS=p.createContext(void 0);function $3(){const n=p.useContext(uS);if(n===void 0)throw new Error(En(45));return n}const K3=p.forwardRef(function(r,o){const{keepMounted:l=!1,...c}=r,{store:d}=$l();return d.useState("mounted")||l?i.jsx(uS.Provider,{value:l,children:i.jsx(np,{ref:o,...c})}):null}),dS=p.createContext(void 0);function Q3(){const n=p.useContext(dS);if(!n)throw new Error(En(46));return n}const Z3=p.forwardRef(function(r,o){const{render:l,className:c,style:d,anchor:m,positionMethod:g="absolute",side:b="bottom",align:h="center",sideOffset:v=0,alignOffset:x=0,collisionBoundary:S="clipping-ancestors",collisionPadding:j=5,arrowPadding:N=5,sticky:k=!1,disableAnchorTracking:O=!1,collisionAvoidance:E=U0,...T}=r,{store:_}=$l(),w=$3(),I=rp(),A=_.useState("floatingRootContext"),U=_.useState("mounted"),M=_.useState("open"),K=_.useState("openChangeReason"),oe=_.useState("activeTriggerElement"),Z=_.useState("modal"),ee=_.useState("openMethod"),G=_.useState("positionerElement"),te=_.useState("instantType"),X=_.useState("transitionStatus"),C=_.useState("hasViewport"),B=p.useRef(null),H=Km(G,!1,!1),z=T1({anchor:m,floatingRootContext:A,positionMethod:g,mounted:U,side:b,sideOffset:v,align:h,alignOffset:x,arrowPadding:N,collisionBoundary:S,collisionPadding:j,sticky:k,disableAnchorTracking:O,keepMounted:w,nodeId:I,collisionAvoidance:E,adaptiveOrigin:C?N1:void 0}),L=A.useState("domReferenceElement");Ge(()=>{const Q=L,ne=B.current;if(Q&&(B.current=Q),ne&&Q&&Q!==ne){_.set("instantType",void 0);const F=new AbortController;return H(()=>{_.set("instantType","trigger-change")},F.signal),()=>{F.abort()}}},[L,H,_]),R1(M&&Z===!0&&K!==dn,ee==="touch",G,oe);const D=p.useCallback(Q=>{_.set("positionerElement",Q)},[_]),q={open:M,side:z.side,align:z.align,anchorHidden:z.anchorHidden,instant:te},V=w1(r,q,{styles:z.positionerStyles,transitionStatus:X,props:T,refs:[o,D],hidden:!U,inert:!M});return i.jsxs(dS.Provider,{value:z,children:[U&&Z===!0&&K!==dn&&i.jsx(vp,{ref:_.context.internalBackdropRef,inert:yp(!M),cutout:oe}),i.jsx(F0,{id:I,children:V})]})}),J3=p.createContext(void 0);function W3(){const[n,r]=p.useState(0),o=nt(()=>(r(c=>c+1),()=>{r(c=>Math.max(0,c-1))}));return{context:p.useMemo(()=>({register:o}),[o]),hasClosePart:n>0}}function eM(n){const{value:r,children:o}=n;return i.jsx(J3.Provider,{value:r,children:o})}const tM={...Fl,...$c},nM=p.forwardRef(function(r,o){const{render:l,className:c,style:d,initialFocus:m,finalFocus:g,...b}=r,{store:h}=$l(),v=Q3(),x=v1()!=null,{context:S,hasClosePart:j}=W3(),N=h.useState("open"),k=h.useState("openMethod"),O=h.useState("instantType"),E=h.useState("transitionStatus"),T=h.useState("popupProps"),_=h.useState("titleElementId"),w=h.useState("descriptionElementId"),I=h.useState("modal"),A=h.useState("mounted"),U=h.useState("openChangeReason"),M=h.useState("activeTriggerElement"),K=h.useState("floatingRootContext"),oe=K.useState("floatingId"),Z=h.useState("disabled"),ee=h.useState("openOnHover"),G=h.useState("closeDelay"),te=b.id??oe;Wc({open:N,ref:h.context.popupRef,onComplete(){N&&h.context.onOpenChangeComplete?.(!0)}}),x1(K,{enabled:ee&&!Z,closeDelay:G});const X=m===void 0?l1(h.context.popupRef):m,C=I!==!1&&j;h.useSyncedValue("focusManagerModal",C);const B=p.useCallback(L=>{h.set("popupElement",L)},[h]),H={open:N,side:v.side,align:v.align,instant:O,transitionStatus:E},z=fn("div",r,{state:H,ref:[o,h.context.popupRef,B],props:[T,{id:te,role:"dialog",...lu,"aria-labelledby":_,"aria-describedby":w,onKeyDown(L){x&&xp.has(L.key)&&L.stopPropagation()}},bp(E),b],stateAttributesMapping:tM});return i.jsx(ap,{context:K,openInteractionType:k,modal:C,disabled:!A||U===dn,initialFocus:X,returnFocus:g,restoreFocus:"popup",previousFocusableElement:Bt(M)?M:void 0,nextFocusableElement:h.context.triggerFocusTargetRef,beforeContentFocusGuardRef:h.context.beforeContentFocusGuardRef,children:i.jsx(eM,{value:S,children:z})})});function sM({...n}){return i.jsx(q3,{"data-slot":"popover",...n})}function rM({...n}){return i.jsx(X3,{"data-slot":"popover-trigger",...n})}function oM({align:n="start",alignOffset:r=0,side:o="bottom",sideOffset:l=8,className:c,...d}){return i.jsx(K3,{children:i.jsx(Z3,{className:"isolate z-50 outline-none",align:n,alignOffset:r,side:o,sideOffset:l,children:i.jsx(nM,{"data-slot":"popover-content",className:et("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})})})}const fS="occurs_in";function aM(n,r){return n.filter(o=>o.relationType===fS&&o.sourceId===r)}function lM(n,r){return{source_type:"event",source_id:n,target_type:"outline_node",target_id:r,relation_type:fS}}function iM({id:n}){const[r,o]=p.useState(null),[l,c]=p.useState(!1),[d,m]=p.useState(!1),[g,b]=p.useState(null),[h,v]=p.useState(null),[x,S]=p.useState(!1),[j,N]=p.useState(null),[k,O]=p.useState(!1),[E,T]=p.useState(""),[_,w]=p.useState(null),[I,A]=p.useState(!1),[U,M]=p.useState(null),[K,oe]=p.useState(!1),Z=Ae(z=>z.outline),ee=rr(Z?.children??[]);async function G(){c(!0),b(null),m(!1);try{const z=await mo("event",n);o(z),v(U3(z))}catch(z){o(null),v(null),z instanceof Ie&&z.code==="ENTITY_NOT_FOUND"?m(!0):b(z instanceof Ie?z.code:ct)}finally{c(!1)}}p.useEffect(()=>{G()},[n]),Cs(()=>{G()}),p.useEffect(()=>{Ae.getState().outline===null&&Ae.getState().config!==null&&Ae.getState().loadOutline()},[]);async function te(){if(!r||!h||x)return;const z=iS({name:r.name,data:r.data},h);if(z===null){ke.getState().showToast("没有变更");return}S(!0),N(null);try{await Ra("event",n,z),ke.getState().showToast("已保存"),await G()}catch(L){if(L instanceof Ie&&L.code==="ENTITY_NOT_FOUND"){m(!0);return}N(L instanceof Ie?L.message:"保存失败,请重试")}finally{S(!1)}}async function X(){if(!(E===""||I)){A(!0),w(null);try{await Oa(lM(n,E)),ke.getState().showToast("已关联大纲节点"),O(!1),await G()}catch(z){if(z instanceof Ie&&z.code==="RELATION_EXISTS"){w("这条关系已经存在");return}w(z instanceof Ie?z.message:"关联失败,请重试")}finally{A(!1)}}}async function C(){if(U)try{await qc(U.id),ke.getState().showToast("已取消关联"),M(null),await G()}catch(z){throw z}}async function B(){if(r)try{const z=await Vc("event",n),L=[];z.cascaded.relations>0&&L.push(`${z.cascaded.relations} 条关联`),z.cascaded.deltas>0&&L.push(`${z.cascaded.deltas} 条变更记录`),ke.getState().showToast(`已移入回收站,可随时还原${L.length>0?`(含 ${L.join("、")})`:""}`),oe(!1),Tn("/timeline")}catch(z){throw z}}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(Se,{variant:"outline",type:"button",onClick:()=>Tn("/timeline"),children:"返回列表"})]})]})});const H=r===null?[]:aM(r.relations,n);return i.jsxs("section",{children:[i.jsxs("div",{className:"mb-1 flex items-center gap-3",children:[i.jsx(Mp,{items:[{label:"时间轴",href:"/timeline"},{label:r?.name??"…"}]}),i.jsx("h1",{className:"min-w-0 truncate text-xl font-semibold",children:r?.name??"…"}),i.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[i.jsx(Se,{variant:"outline",type:"button",onClick:()=>{te()},disabled:!r||x,children:x?"保存中…":"保存"}),i.jsx(Se,{variant:"outline",type:"button",disabled:!r,className:"text-destructive hover:bg-destructive/10",onClick:()=>oe(!0),children:"移入回收站"})]})]}),r&&i.jsxs("p",{className:"mb-4 text-xs text-muted-foreground",children:["创建于 ",ls(r.createdAt)," · 更新于 ",ls(r.updatedAt)]}),l&&!r&&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},(z,L)=>i.jsx("div",{className:"h-9 animate-pulse rounded bg-muted"},L))}),i.jsx("div",{className:"space-y-3 rounded-md border border-border p-4",children:Array.from({length:3},(z,L)=>i.jsx("div",{className:"h-9 animate-pulse rounded bg-muted"},L))})]}),!l&&!r&&g!==null&&i.jsxs("div",{className:"rounded-md border border-border p-4 text-sm text-muted-foreground",children:[g===ct?"无法连接服务,请确认 ai-editor 服务已启动。":"详情加载失败,请重试。",i.jsx(Se,{variant:"outline",className:"ml-3",type:"button",onClick:()=>{G()},children:"重试"})]}),r&&h&&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(Ot,{value:h.name,onChange:z=>v(L=>L&&{...L,name:z.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:h.description,onChange:z=>v(L=>L&&{...L,description:z.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:"时间标签"}),i.jsx(Ot,{value:h.timeLabel,onChange:z=>v(L=>L&&{...L,timeLabel:z.target.value}),placeholder:"如:第二天黄昏(自由文本,不参与排序)"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:"标签"}),i.jsx(Ot,{value:h.tagsInput,onChange:z=>v(L=>L&&{...L,tagsInput:z.target.value}),placeholder:"如:主线,战争(逗号/回车分隔)"})]}),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(sM,{open:k,onOpenChange:z=>{z?(T(""),w(null),O(!0)):I||O(!1)},children:[i.jsx(rM,{render:i.jsx(Se,{variant:"outline",type:"button",className:"h-8 px-2 text-xs",children:"+ 关联场景/章节"})}),i.jsxs(oM,{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(cM,{value:E,onChange:T,nodeOptions:ee,placeholder:"请选择节点"})]}),_&&i.jsx("p",{className:"text-sm text-destructive",children:_}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(Se,{variant:"outline",type:"button",size:"sm",onClick:()=>O(!1),disabled:I,children:"取消"}),i.jsx(Se,{type:"button",size:"sm",onClick:()=>{X()},disabled:I||E==="",children:I?"关联中…":"关联"})]})]})]})]}),H.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:H.map(z=>i.jsxs("li",{className:"flex items-center gap-2 py-2 text-sm",children:[i.jsx("button",{type:"button",onClick:()=>Tn(`/outline/${z.targetId}`),title:"跳转大纲定位",className:"min-w-0 flex-1 truncate text-left text-foreground underline-offset-2 hover:text-primary hover:underline",children:z.targetName??z.targetId}),i.jsx(Se,{variant:"outline",type:"button",className:"h-7 shrink-0 px-2 text-xs text-destructive hover:bg-destructive/10",onClick:()=>M(z),children:"取消关联"})]},z.id))})]})]}),U&&i.jsx(ms,{title:"取消关联",description:`取消《${U.targetName??U.targetId}》与事件的关联?物理删除不可恢复,可重新建立。`,confirmLabel:"取消关联",danger:!0,onConfirm:C,onClose:()=>M(null)}),K&&i.jsx(ms,{title:"移入回收站",description:`将《${r?.name??""}》移入回收站。关联关系与变更记录将一并移入,可在回收站还原。`,confirmLabel:"移入回收站",danger:!0,onConfirm:B,onClose:()=>oe(!1)})]})}function cM({value:n,onChange:r,nodeOptions:o,placeholder:l="未设置"}){return i.jsxs("select",{value:n,onChange:c=>r(c.target.value),className:et("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}),o.map(c=>i.jsxs("option",{value:c.id,children:[" ".repeat(c.depth),c.label]},c.id))]})}function uM(n,r){const o=[];return n>0&&o.push(`${n} 条关系`),r>0&&o.push(`${r} 条变更记录`),o.length>0?`已还原,连带恢复 ${o.join("、")}`:"已还原"}function dM(n){return n>0?`已还原(含 ${n} 个子节点)`:"已还原"}function fM(n){return/软删祖先\s+([^\s,,]+)/.exec(n)?.[1]??null}const yv={character:"人物",setting:"设定",location:"地点",hook:"伏笔",event:"事件"},mM={volume:"卷",chapter:"章",scene:"场"};function vv({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 pM(){const[n,r]=p.useState(null),[o,l]=p.useState(!1),[c,d]=p.useState(null),[m,g]=p.useState(0);Cs(()=>g(w=>w+1));const[b,h]=p.useState(null),[v,x]=p.useState(null);p.useEffect(()=>{let w=!1;return l(!0),d(null),lT().then(I=>{w||r(I)}).catch(I=>{w||d(I instanceof Ie?I.code:ct)}).finally(()=>{w||l(!1)}),()=>{w=!0}},[m]);async function S(){g(w=>w+1)}function j(w){return w instanceof Ie&&(w.code==="ENTITY_NOT_FOUND"||w.code==="OUTLINE_NODE_NOT_FOUND")}function N(w){ke.getState().showError(w instanceof Ie?w.code:ct,w instanceof Ie?w.message:"操作失败,请重试")}async function k(w){try{const I=await iT(w.type,w.id);ke.getState().showToast(uM(I.restoredRelations,I.restoredDeltas)),await S()}catch(I){if(j(I)){ke.getState().showToast("该对象已不存在","error"),await S();return}N(I)}}async function O(w){x(null);try{const I=await Ub(w.id);ke.getState().showToast(dM(I.restoredChildren)),await S(),Ae.getState().loadOutline()}catch(I){if(I instanceof Ie&&I.code==="OUTLINE_ANCESTOR_DELETED"){const A=fM(I.message);if(A===null){ke.getState().showError("OUTLINE_ANCESTOR_DELETED","上级节点也在回收站,请先还原上级");return}x({node:w,ancestorId:A,ancestorName:n?.nodes.find(U=>U.id===A)?.title??A});return}if(j(I)){ke.getState().showToast("该对象已不存在","error"),await S();return}N(I)}}async function E(){const w=v;if(w)try{await Ub(w.ancestorId),Ae.getState().loadOutline(),await O(w.node)}catch(I){if(j(I)){ke.getState().showToast("该对象已不存在","error"),x(null),await S();return}N(I)}}async function T(){if(b)try{b.kind==="entity"?await cT(b.item.type,b.item.id):(await uT(b.item.id),Ae.getState().loadOutline()),ke.getState().showToast("已彻底删除"),await S()}catch(w){if(j(w)){ke.getState().showToast("该对象已不存在","error"),await S();return}throw w}}const _=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(Se,{variant:"outline",type:"button",className:"ml-auto",onClick:()=>{S()},disabled:o,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===ct?"无法连接服务,请确认 ai-editor 服务已启动。":"回收站加载失败,请重试。",i.jsx(Se,{variant:"outline",className:"ml-3",type:"button",onClick:()=>{S()},children:"重试"})]}),o&&n===null&&c===null&&i.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:[0,1].map(w=>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},(I,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))]},w))}),!o&&_&&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&&!_&&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(w=>i.jsxs("li",{className:"flex items-center gap-2 px-3 py-2",children:[i.jsx(vv,{label:yv[w.type]}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",title:w.name,children:w.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:xo(w.deletedAt)}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[i.jsx(Se,{variant:"outline",size:"xs",type:"button",onClick:()=>{k(w)},children:"还原"}),i.jsx(Se,{variant:"outline",size:"xs",type:"button",className:"text-destructive hover:bg-destructive/10",onClick:()=>h({kind:"entity",item:w}),children:"彻底删除"})]})]},w.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(w=>i.jsxs("li",{className:"px-3 py-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(vv,{label:mM[w.type]}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",title:w.title,children:w.title}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:xo(w.deletedAt)}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[i.jsx(Se,{variant:"outline",size:"xs",type:"button",onClick:()=>{O(w)},children:"还原"}),i.jsx(Se,{variant:"outline",size:"xs",type:"button",className:"text-destructive hover:bg-destructive/10",onClick:()=>h({kind:"node",item:w}),children:"彻底删除"})]})]}),v?.node.id===w.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(Se,{variant:"outline",size:"xs",type:"button",className:"border-destructive/40 text-destructive hover:bg-destructive/10",onClick:()=>{E()},children:["还原上级《",v.ancestorName,"》"]})]})]},w.id))})]})]}),b&&i.jsx(ms,{title:"彻底删除",description:b.kind==="entity"?`将彻底删除《${b.item.name}》(${yv[b.item.type]})及其关联关系、变更记录,不可恢复。`:`将彻底删除《${b.item.title}》及整棵子树、关联关系、变更记录,不可恢复。`,confirmLabel:"确认彻底删除",danger:!0,onConfirm:T,onClose:()=>h(null)})]})}function Sv(n,r=new Date){const o=new Date(n);if(Number.isNaN(o.getTime()))return n;const l=m=>String(m).padStart(2,"0"),c=`${l(o.getHours())}:${l(o.getMinutes())}`;return o.getFullYear()===r.getFullYear()?`${l(o.getMonth()+1)}-${l(o.getDate())} ${c}`:`${String(o.getFullYear()).slice(-2)}-${l(o.getMonth()+1)}-${l(o.getDate())} ${c}`}function Ev(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 Nv=[{value:null,label:"关闭"},...BN.map(n=>({value:n,label:`每 ${n} 分钟`}))];let Rl=0;function hM(){const n=ke(Z=>Z.showToast),r=ke(Z=>Z.showError),o=ke(Z=>Z.notifyDataChanged),l=Ae(Z=>Z.config),c=Ae(Z=>Z.configLoading),d=Ae(Z=>Z.updateConfig),m=Ae(Z=>Z.loadConfig),g=Ae(Z=>Z.loadOutline),[b,h]=p.useState(!1),[v,x]=p.useState(null),[S,j]=p.useState(!1),[N,k]=p.useState(null),[O,E]=p.useState(!1),[T,_]=p.useState(null);async function w(){if(Ae.getState().config===null)return;const Z=++Rl;j(!0),k(null);try{const ee=await ET();if(Z!==Rl)return;x(ee.backups)}catch(ee){if(Z!==Rl)return;const G=ee instanceof Ie?ee.code:ct;k(G)}finally{Z===Rl&&j(!1)}}const I=l?.id??null,A=p.useRef(null);p.useEffect(()=>{if(I===null){Rl++,x(null),k(null),_(null),A.current=null;return}A.current!==I&&(A.current=I,w())},[I]);async function U(Z){if(l===null)return;const ee=Z==="null"?null:Number(Z);if(ee!==l.backupFrequencyMinutes){h(!0);try{await d({backup_frequency_minutes:ee}),n(ee===null?"已关闭自动备份":`自动备份频率已设为每 ${ee} 分钟`)}catch(G){G instanceof Ie&&G.code===ct?r("CLIENT_NETWORK_ERROR","无法连接服务,频率未保存"):n("频率保存失败,请重试","error")}finally{h(!1)}}}async function M(){if(!(l===null||O)){E(!0);try{await NT(),n("已备份"),await w()}catch(Z){n(Z instanceof Ie&&Z.code!==ct?Z.message:"无法连接服务,备份失败","error")}finally{E(!1)}}}async function K(){if(T===null)return;const Z=await jT(T.fileName);n(`已恢复备份,覆盖前状态已自动快照(${Z.snapshot.fileName})`),await Promise.all([m(),g()]),o(),St.getState().clearSessions(),St.getState().loadSessions(),w()}const oe=l===null?"":Nv.some(Z=>String(Z.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 items-center gap-2",children:[i.jsx("select",{value:oe,onChange:Z=>{U(Z.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:Nv.map(Z=>i.jsx("option",{value:String(Z.value),children:Z.label},String(Z.value)))}),i.jsxs(Se,{onClick:()=>{M()},disabled:l===null||O,type:"button",children:[O?i.jsx(Pc,{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"})]}):N!==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:N===ct?"无法连接服务":"备份列表加载失败"}),i.jsx(Se,{variant:"ghost",size:"xs",onClick:()=>{w()},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(Z=>i.jsxs("li",{className:"flex items-center gap-2 px-2 py-1.5",children:[i.jsx("span",{className:"min-w-0 flex-1 text-sm",title:Z.fileName,children:Sv(Z.createdAt)}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Ev(Z.size)}),i.jsx(Se,{variant:"outline",size:"xs",onClick:()=>_(Z),children:"加载"})]},Z.fileName))}):null})]}),T!==null&&i.jsx(ms,{title:"加载备份",description:`${Sv(T.createdAt)} · ${Ev(T.size)}。将覆盖当前项目数据;覆盖前会自动备份当前状态(可回退)`,confirmLabel:"确认加载",danger:!0,onConfirm:K,onClose:()=>_(null)})]})}function Ol(n){return n instanceof Ie?n.code:ct}function gM(){const n=ke(z=>z.showToast),r=ke(z=>z.showError),o=ke(z=>z.notifyDataChanged),l=Ae(z=>z.config),c=Ae(z=>z.configLoading),d=Ae(z=>z.updateConfig),[m,g]=p.useState(!0),[b,h]=p.useState(""),[v,x]=p.useState(!1),[S,j]=p.useState(void 0),[N,k]=p.useState(""),[O,E]=p.useState(!1),[T,_]=p.useState(null),[w,I]=p.useState(null),[A,U]=p.useState(""),[M,K]=p.useState(null),[oe,Z]=p.useState(!1),[ee,G]=p.useState(null);async function te(){try{const z=await wT();h(z.model),x(z.apiKeySet),j(z.apiKeyMasked)}catch(z){r(Ol(z),"读取 LLM 配置失败")}finally{g(!1)}}p.useEffect(()=>{te()},[]),p.useEffect(()=>{const z=Ae.getState();z.config===null&&!z.configLoading&&z.loadConfig()},[]),p.useEffect(()=>{if(l===null){K(null);return}l.id!==M&&(U(l.prompt),K(l.id))},[l,M]);async function X(){G(null),Z(!0);try{const z=A.trim();await d({prompt:z}),U(z),n("提示词已保存,仅影响新请求"),o()}catch(z){Ol(z)===ct?r("CLIENT_NETWORK_ERROR","无法连接服务,提示词未保存"):G("保存失败,请重试")}finally{Z(!1)}}async function C(){if(!b.trim()){_("模型名不能为空");return}_(null),E(!0);try{await Of({model:b.trim()}),n("已保存,仅影响新请求"),h(b.trim())}catch(z){Ol(z)===ct?r("CLIENT_NETWORK_ERROR","无法连接服务,模型配置未保存"):_("保存失败,请重试")}finally{E(!1)}}async function B(){if(!N.trim()){I("请输入新 key");return}I(null),E(!0);try{await Of({api_key:N.trim()}),k(""),n("Key 已保存,仅影响新请求"),await te()}catch(z){Ol(z)===ct?r("CLIENT_NETWORK_ERROR","无法连接服务,Key 未保存"):I("保存失败,请重试")}finally{E(!1)}}async function H(){I(null),E(!0);try{await Of({api_key:""}),k(""),n("Key 已清除"),await te()}catch(z){Ol(z)===ct?r("CLIENT_NETWORK_ERROR","无法连接服务,Key 未清除"):I("清除失败,请重试")}finally{E(!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(Ot,{value:b,onChange:z=>h(z.target.value),placeholder:"deepseek-v4-flash"}),i.jsx(Se,{onClick:()=>{C()},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(Ot,{value:N,onChange:z=>k(z.target.value),placeholder:"输入新 key(覆盖旧 key)"}),i.jsx(Se,{onClick:()=>{B()},disabled:O,type:"button",children:"保存 Key"}),i.jsx(Se,{variant:"outline",onClick:()=>{H()},disabled:O,type:"button",children:"清除 Key"})]}),w&&i.jsx("p",{className:"mt-1 text-sm text-red-600",children:w})]}),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:z=>U(z.target.value),rows:6,disabled:l===null||l.id!==M,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(Se,{onClick:()=>{X()},disabled:oe||l===null||l.id!==M,type:"button",children:"保存提示词"}),l===null&&!c&&i.jsx("p",{className:"text-xs text-muted-foreground/70",children:"打开项目后可用"})]}),ee&&i.jsx("p",{className:"mt-1 text-sm text-destructive",children:ee})]}),i.jsx(hM,{})]})]})}function xM(n){const[r,o,l]=n.segments;switch(r){case void 0:return i.jsx(Fy,{});case"outline":return o!==void 0?i.jsx(F_,{nodeId:o},o):i.jsx(v_,{});case"canvas":return i.jsx(c3,{});case"entities":{if(o==="relations")return i.jsx(mv,{type:"relations"});const c=o!==void 0&&Na.includes(o)?o:"character";return l!==void 0?i.jsx(h3,{type:c,id:l},`${c}:${l}`):i.jsx(mv,{type:c})}case"hooks":return i.jsx(M3,{});case"timeline":return o!==void 0?i.jsx(iM,{id:o},o):i.jsx(H3,{});case"trash":return i.jsx(pM,{});case"settings":return i.jsx(gM,{});default:return i.jsx(Fy,{})}}function bM(){const n=HN();return i.jsx(f_,{route:n,children:xM(n)})}const mS=document.getElementById("root");if(!mS)throw new Error("#root 元素缺失(index.html)");zN.createRoot(mS).render(i.jsx(p.StrictMode,{children:i.jsx(m_,{children:i.jsx(bM,{})})}));