(function(){const f=document.createElement("link").relList;if(f&&f.supports&&f.supports("modulepreload"))return;for(const m of document.querySelectorAll('link[rel="modulepreload"]'))o(m);new MutationObserver(m=>{for(const v of m)if(v.type==="childList")for(const _ of v.addedNodes)_.tagName==="LINK"&&_.rel==="modulepreload"&&o(_)}).observe(document,{childList:!0,subtree:!0});function s(m){const v={};return m.integrity&&(v.integrity=m.integrity),m.referrerPolicy&&(v.referrerPolicy=m.referrerPolicy),m.crossOrigin==="use-credentials"?v.credentials="include":m.crossOrigin==="anonymous"?v.credentials="omit":v.credentials="same-origin",v}function o(m){if(m.ep)return;m.ep=!0;const v=s(m);fetch(m.href,v)}})();function Gy(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var co={exports:{}},Uu={};/** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var ah;function Vy(){if(ah)return Uu;ah=1;var i=Symbol.for("react.transitional.element"),f=Symbol.for("react.fragment");function s(o,m,v){var _=null;if(v!==void 0&&(_=""+v),m.key!==void 0&&(_=""+m.key),"key"in m){v={};for(var N in m)N!=="key"&&(v[N]=m[N])}else v=m;return m=v.ref,{$$typeof:i,type:o,key:_,ref:m!==void 0?m:null,props:v}}return Uu.Fragment=f,Uu.jsx=s,Uu.jsxs=s,Uu}var nh;function Qy(){return nh||(nh=1,co.exports=Vy()),co.exports}var y=Qy(),fo={exports:{}},Ru={},oo={exports:{}},so={};/** * @license React * scheduler.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var uh;function Zy(){return uh||(uh=1,(function(i){function f(O,V){var ot=O.length;O.push(V);t:for(;0>>1,Qt=O[Gt];if(0>>1;Gtm(Q,ot))km(st,Q)?(O[Gt]=st,O[k]=ot,Gt=k):(O[Gt]=Q,O[C]=ot,Gt=C);else if(km(st,ot))O[Gt]=st,O[k]=ot,Gt=k;else break t}}return V}function m(O,V){var ot=O.sortIndex-V.sortIndex;return ot!==0?ot:O.id-V.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var v=performance;i.unstable_now=function(){return v.now()}}else{var _=Date,N=_.now();i.unstable_now=function(){return _.now()-N}}var x=[],S=[],R=1,A=null,q=3,et=!1,tt=!1,dt=!1,ft=!1,G=typeof setTimeout=="function"?setTimeout:null,pt=typeof clearTimeout=="function"?clearTimeout:null,St=typeof setImmediate<"u"?setImmediate:null;function P(O){for(var V=s(S);V!==null;){if(V.callback===null)o(S);else if(V.startTime<=O)o(S),V.sortIndex=V.expirationTime,f(x,V);else break;V=s(S)}}function nt(O){if(dt=!1,P(O),!tt)if(s(x)!==null)tt=!0,H||(H=!0,Lt());else{var V=s(S);V!==null&&qt(nt,V.startTime-O)}}var H=!1,W=-1,nl=5,ul=-1;function vl(){return ft?!0:!(i.unstable_now()-ulO&&vl());){var Gt=A.callback;if(typeof Gt=="function"){A.callback=null,q=A.priorityLevel;var Qt=Gt(A.expirationTime<=O);if(O=i.unstable_now(),typeof Qt=="function"){A.callback=Qt,P(O),V=!0;break l}A===s(x)&&o(x),P(O)}else o(x);A=s(x)}if(A!==null)V=!0;else{var b=s(S);b!==null&&qt(nt,b.startTime-O),V=!1}}break t}finally{A=null,q=ot,et=!1}V=void 0}}finally{V?Lt():H=!1}}}var Lt;if(typeof St=="function")Lt=function(){St(rl)};else if(typeof MessageChannel<"u"){var lt=new MessageChannel,it=lt.port2;lt.port1.onmessage=rl,Lt=function(){it.postMessage(null)}}else Lt=function(){G(rl,0)};function qt(O,V){W=G(function(){O(i.unstable_now())},V)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(O){O.callback=null},i.unstable_forceFrameRate=function(O){0>O||125Gt?(O.sortIndex=ot,f(S,O),s(x)===null&&O===s(S)&&(dt?(pt(W),W=-1):dt=!0,qt(nt,ot-Gt))):(O.sortIndex=Qt,f(x,O),tt||et||(tt=!0,H||(H=!0,Lt()))),O},i.unstable_shouldYield=vl,i.unstable_wrapCallback=function(O){var V=q;return function(){var ot=q;q=V;try{return O.apply(this,arguments)}finally{q=ot}}}})(so)),so}var ih;function Ky(){return ih||(ih=1,oo.exports=Zy()),oo.exports}var ro={exports:{}},yt={};/** * @license React * react.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var ch;function Jy(){if(ch)return yt;ch=1;var i=Symbol.for("react.transitional.element"),f=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),v=Symbol.for("react.consumer"),_=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),S=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),q=Symbol.iterator;function et(b){return b===null||typeof b!="object"?null:(b=q&&b[q]||b["@@iterator"],typeof b=="function"?b:null)}var tt={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},dt=Object.assign,ft={};function G(b,C,Q){this.props=b,this.context=C,this.refs=ft,this.updater=Q||tt}G.prototype.isReactComponent={},G.prototype.setState=function(b,C){if(typeof b!="object"&&typeof b!="function"&&b!=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,b,C,"setState")},G.prototype.forceUpdate=function(b){this.updater.enqueueForceUpdate(this,b,"forceUpdate")};function pt(){}pt.prototype=G.prototype;function St(b,C,Q){this.props=b,this.context=C,this.refs=ft,this.updater=Q||tt}var P=St.prototype=new pt;P.constructor=St,dt(P,G.prototype),P.isPureReactComponent=!0;var nt=Array.isArray;function H(){}var W={H:null,A:null,T:null,S:null},nl=Object.prototype.hasOwnProperty;function ul(b,C,Q){var k=Q.ref;return{$$typeof:i,type:b,key:C,ref:k!==void 0?k:null,props:Q}}function vl(b,C){return ul(b.type,C,b.props)}function rl(b){return typeof b=="object"&&b!==null&&b.$$typeof===i}function Lt(b){var C={"=":"=0",":":"=2"};return"$"+b.replace(/[=:]/g,function(Q){return C[Q]})}var lt=/\/+/g;function it(b,C){return typeof b=="object"&&b!==null&&b.key!=null?Lt(""+b.key):C.toString(36)}function qt(b){switch(b.status){case"fulfilled":return b.value;case"rejected":throw b.reason;default:switch(typeof b.status=="string"?b.then(H,H):(b.status="pending",b.then(function(C){b.status==="pending"&&(b.status="fulfilled",b.value=C)},function(C){b.status==="pending"&&(b.status="rejected",b.reason=C)})),b.status){case"fulfilled":return b.value;case"rejected":throw b.reason}}throw b}function O(b,C,Q,k,st){var ht=typeof b;(ht==="undefined"||ht==="boolean")&&(b=null);var Dt=!1;if(b===null)Dt=!0;else switch(ht){case"bigint":case"string":case"number":Dt=!0;break;case"object":switch(b.$$typeof){case i:case f:Dt=!0;break;case R:return Dt=b._init,O(Dt(b._payload),C,Q,k,st)}}if(Dt)return st=st(b),Dt=k===""?"."+it(b,0):k,nt(st)?(Q="",Dt!=null&&(Q=Dt.replace(lt,"$&/")+"/"),O(st,C,Q,"",function(te){return te})):st!=null&&(rl(st)&&(st=vl(st,Q+(st.key==null||b&&b.key===st.key?"":(""+st.key).replace(lt,"$&/")+"/")+Dt)),C.push(st)),1;Dt=0;var tl=k===""?".":k+":";if(nt(b))for(var Pt=0;Pt"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(f){console.error(f)}}return i(),ho.exports=ky(),ho.exports}/** * @license React * react-dom-client.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var rh;function Wy(){if(rh)return Ru;rh=1;var i=Ky(),f=bo(),s=$y();function o(t){var l="https://react.dev/errors/"+t;if(1Qt||(t.current=Gt[Qt],Gt[Qt]=null,Qt--)}function Q(t,l){Qt++,Gt[Qt]=t.current,t.current=l}var k=b(null),st=b(null),ht=b(null),Dt=b(null);function tl(t,l){switch(Q(ht,l),Q(st,t),Q(k,null),l.nodeType){case 9:case 11:t=(t=l.documentElement)&&(t=t.namespaceURI)?Md(t):0;break;default:if(t=l.tagName,l=l.namespaceURI)l=Md(l),t=xd(l,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}C(k),Q(k,t)}function Pt(){C(k),C(st),C(ht)}function te(t){t.memoizedState!==null&&Q(Dt,t);var l=k.current,e=xd(l,t.type);l!==e&&(Q(st,t),Q(k,e))}function se(t){st.current===t&&(C(k),C(st)),Dt.current===t&&(C(Dt),Ou._currentValue=ot)}var Oe,Da;function Ml(t){if(Oe===void 0)try{throw Error()}catch(e){var l=e.stack.trim().match(/\n( *(at )?)/);Oe=l&&l[1]||"",Da=-1)":-1n||h[a]!==E[n]){var j=` `+h[a].replace(" at new "," at ");return t.displayName&&j.includes("")&&(j=j.replace("",t.displayName)),j}while(1<=a&&0<=n);break}}}finally{we=!1,Error.prepareStackTrace=e}return(e=t?t.displayName||t.name:"")?Ml(e):""}function ja(t,l){switch(t.tag){case 26:case 27:case 5:return Ml(t.type);case 16:return Ml("Lazy");case 13:return t.child!==l&&l!==null?Ml("Suspense Fallback"):Ml("Suspense");case 19:return Ml("SuspenseList");case 0:case 15:return cn(t.type,!1);case 11:return cn(t.type.render,!1);case 1:return cn(t.type,!0);case 31:return Ml("Activity");default:return""}}function fn(t){try{var l="",e=null;do l+=ja(t,e),e=t,t=t.return;while(t);return l}catch(a){return` Error generating stack: `+a.message+` `+a.stack}}var Be=Object.prototype.hasOwnProperty,Dl=i.unstable_scheduleCallback,Zn=i.unstable_cancelCallback,tc=i.unstable_shouldYield,Ca=i.unstable_requestPaint,Z=i.unstable_now,Bu=i.unstable_getCurrentPriorityLevel,Ua=i.unstable_ImmediatePriority,Tt=i.unstable_UserBlockingPriority,aa=i.unstable_NormalPriority,il=i.unstable_LowPriority,Kl=i.unstable_IdlePriority,dl=i.log,Ul=i.unstable_setDisableYieldValue,jl=null,Rl=null;function Ll(t){if(typeof dl=="function"&&Ul(t),Rl&&typeof Rl.setStrictMode=="function")try{Rl.setStrictMode(jl,t)}catch{}}var Gl=Math.clz32?Math.clz32:Ql,na=Math.log,Ra=Math.LN2;function Ql(t){return t>>>=0,t===0?32:31-(na(t)/Ra|0)|0}var ze=256,Ee=262144,De=4194304;function re(t){var l=t&42;if(l!==0)return l;switch(t&-t){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 t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function Ha(t,l,e){var a=t.pendingLanes;if(a===0)return 0;var n=0,u=t.suspendedLanes,c=t.pingedLanes;t=t.warmLanes;var r=a&134217727;return r!==0?(a=r&~u,a!==0?n=re(a):(c&=r,c!==0?n=re(c):e||(e=r&~t,e!==0&&(n=re(e))))):(r=a&~u,r!==0?n=re(r):c!==0?n=re(c):e||(e=a&~t,e!==0&&(n=re(e)))),n===0?0:l!==0&&l!==n&&(l&u)===0&&(u=n&-n,e=l&-l,u>=e||u===32&&(e&4194048)!==0)?l:n}function je(t,l){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&l)===0}function on(t,l){switch(t){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Yu(){var t=De;return De<<=1,(De&62914560)===0&&(De=4194304),t}function sn(t){for(var l=[],e=0;31>e;e++)l.push(t);return l}function g(t,l){t.pendingLanes|=l,l!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function d(t,l,e,a,n,u){var c=t.pendingLanes;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=e,t.entangledLanes&=e,t.errorRecoveryDisabledLanes&=e,t.shellSuspendCounter=0;var r=t.entanglements,h=t.expirationTimes,E=t.hiddenUpdates;for(e=c&~e;0"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var wl=/[\n"\\]/g;function hl(t){return t.replace(wl,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function le(t,l,e,a,n,u,c,r){t.name="",c!=null&&typeof c!="function"&&typeof c!="symbol"&&typeof c!="boolean"?t.type=c:t.removeAttribute("type"),l!=null?c==="number"?(l===0&&t.value===""||t.value!=l)&&(t.value=""+_t(l)):t.value!==""+_t(l)&&(t.value=""+_t(l)):c!=="submit"&&c!=="reset"||t.removeAttribute("value"),l!=null?rn(t,c,_t(l)):e!=null?rn(t,c,_t(e)):a!=null&&t.removeAttribute("value"),n==null&&u!=null&&(t.defaultChecked=!!u),n!=null&&(t.checked=n&&typeof n!="function"&&typeof n!="symbol"),r!=null&&typeof r!="function"&&typeof r!="symbol"&&typeof r!="boolean"?t.name=""+_t(r):t.removeAttribute("name")}function qa(t,l,e,a,n,u,c,r){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(t.type=u),l!=null||e!=null){if(!(u!=="submit"&&u!=="reset"||l!=null)){Ba(t);return}e=e!=null?""+_t(e):"",l=l!=null?""+_t(l):e,r||l===t.value||(t.value=l),t.defaultValue=l}a=a??n,a=typeof a!="function"&&typeof a!="symbol"&&!!a,t.checked=r?t.checked:!!a,t.defaultChecked=!!a,c!=null&&typeof c!="function"&&typeof c!="symbol"&&typeof c!="boolean"&&(t.name=c),Ba(t)}function rn(t,l,e){l==="number"&&Ya(t.ownerDocument)===t||t.defaultValue===""+e||(t.defaultValue=""+e)}function Ye(t,l,e,a){if(t=t.options,l){l={};for(var n=0;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ic=!1;if(Xe)try{var Jn={};Object.defineProperty(Jn,"passive",{get:function(){ic=!0}}),window.addEventListener("test",Jn,Jn),window.removeEventListener("test",Jn,Jn)}catch{ic=!1}var ua=null,cc=null,Lu=null;function xo(){if(Lu)return Lu;var t,l=cc,e=l.length,a,n="value"in ua?ua.value:ua.textContent,u=n.length;for(t=0;t=Wn),Uo=" ",Ro=!1;function Ho(t,l){switch(t){case"keyup":return sm.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function wo(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var yn=!1;function dm(t,l){switch(t){case"compositionend":return wo(l);case"keypress":return l.which!==32?null:(Ro=!0,Uo);case"textInput":return t=l.data,t===Uo&&Ro?null:t;default:return null}}function hm(t,l){if(yn)return t==="compositionend"||!dc&&Ho(t,l)?(t=xo(),Lu=cc=ua=null,yn=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:e,offset:l-t};t=a}t:{for(;e;){if(e.nextSibling){e=e.nextSibling;break t}e=e.parentNode}e=void 0}e=Qo(e)}}function Ko(t,l){return t&&l?t===l?!0:t&&t.nodeType===3?!1:l&&l.nodeType===3?Ko(t,l.parentNode):"contains"in t?t.contains(l):t.compareDocumentPosition?!!(t.compareDocumentPosition(l)&16):!1:!1}function Jo(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var l=Ya(t.document);l instanceof t.HTMLIFrameElement;){try{var e=typeof l.contentWindow.location.href=="string"}catch{e=!1}if(e)t=l.contentWindow;else break;l=Ya(t.document)}return l}function yc(t){var l=t&&t.nodeName&&t.nodeName.toLowerCase();return l&&(l==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||l==="textarea"||t.contentEditable==="true")}var Tm=Xe&&"documentMode"in document&&11>=document.documentMode,vn=null,vc=null,tu=null,gc=!1;function ko(t,l,e){var a=e.window===e?e.document:e.nodeType===9?e:e.ownerDocument;gc||vn==null||vn!==Ya(a)||(a=vn,"selectionStart"in a&&yc(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}),tu&&Pn(tu,a)||(tu=a,a=Ri(vc,"onSelect"),0>=c,n-=c,Ce=1<<32-Gl(l)+n|e<gt?(Ot=I,I=null):Ot=I.sibling;var Yt=M(T,I,z[gt],U);if(Yt===null){I===null&&(I=Ot);break}t&&I&&Yt.alternate===null&&l(T,I),p=u(Yt,p,gt),Bt===null?at=Yt:Bt.sibling=Yt,Bt=Yt,I=Ot}if(gt===z.length)return e(T,I),jt&&Ge(T,gt),at;if(I===null){for(;gtgt?(Ot=I,I=null):Ot=I.sibling;var xa=M(T,I,Yt.value,U);if(xa===null){I===null&&(I=Ot);break}t&&I&&xa.alternate===null&&l(T,I),p=u(xa,p,gt),Bt===null?at=xa:Bt.sibling=xa,Bt=xa,I=Ot}if(Yt.done)return e(T,I),jt&&Ge(T,gt),at;if(I===null){for(;!Yt.done;gt++,Yt=z.next())Yt=w(T,Yt.value,U),Yt!==null&&(p=u(Yt,p,gt),Bt===null?at=Yt:Bt.sibling=Yt,Bt=Yt);return jt&&Ge(T,gt),at}for(I=a(I);!Yt.done;gt++,Yt=z.next())Yt=D(I,T,gt,Yt.value,U),Yt!==null&&(t&&Yt.alternate!==null&&I.delete(Yt.key===null?gt:Yt.key),p=u(Yt,p,gt),Bt===null?at=Yt:Bt.sibling=Yt,Bt=Yt);return t&&I.forEach(function(Ly){return l(T,Ly)}),jt&&Ge(T,gt),at}function Ft(T,p,z,U){if(typeof z=="object"&&z!==null&&z.type===dt&&z.key===null&&(z=z.props.children),typeof z=="object"&&z!==null){switch(z.$$typeof){case et:t:{for(var at=z.key;p!==null;){if(p.key===at){if(at=z.type,at===dt){if(p.tag===7){e(T,p.sibling),U=n(p,z.props.children),U.return=T,T=U;break t}}else if(p.elementType===at||typeof at=="object"&&at!==null&&at.$$typeof===nl&&$a(at)===p.type){e(T,p.sibling),U=n(p,z.props),iu(U,z),U.return=T,T=U;break t}e(T,p);break}else l(T,p);p=p.sibling}z.type===dt?(U=Qa(z.props.children,T.mode,U,z.key),U.return=T,T=U):(U=Fu(z.type,z.key,z.props,null,T.mode,U),iu(U,z),U.return=T,T=U)}return c(T);case tt:t:{for(at=z.key;p!==null;){if(p.key===at)if(p.tag===4&&p.stateNode.containerInfo===z.containerInfo&&p.stateNode.implementation===z.implementation){e(T,p.sibling),U=n(p,z.children||[]),U.return=T,T=U;break t}else{e(T,p);break}else l(T,p);p=p.sibling}U=Ec(z,T.mode,U),U.return=T,T=U}return c(T);case nl:return z=$a(z),Ft(T,p,z,U)}if(qt(z))return $(T,p,z,U);if(Lt(z)){if(at=Lt(z),typeof at!="function")throw Error(o(150));return z=at.call(z),ct(T,p,z,U)}if(typeof z.then=="function")return Ft(T,p,ni(z),U);if(z.$$typeof===St)return Ft(T,p,ti(T,z),U);ui(T,z)}return typeof z=="string"&&z!==""||typeof z=="number"||typeof z=="bigint"?(z=""+z,p!==null&&p.tag===6?(e(T,p.sibling),U=n(p,z),U.return=T,T=U):(e(T,p),U=zc(z,T.mode,U),U.return=T,T=U),c(T)):e(T,p)}return function(T,p,z,U){try{uu=0;var at=Ft(T,p,z,U);return xn=null,at}catch(I){if(I===Mn||I===ei)throw I;var Bt=ae(29,I,null,T.mode);return Bt.lanes=U,Bt.return=T,Bt}finally{}}}var Fa=gs(!0),ps=gs(!1),sa=!1;function wc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Bc(t,l){t=t.updateQueue,l.updateQueue===t&&(l.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function ra(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function da(t,l,e){var a=t.updateQueue;if(a===null)return null;if(a=a.shared,(Xt&2)!==0){var n=a.pending;return n===null?l.next=l:(l.next=n.next,n.next=l),a.pending=l,l=Wu(t),ls(t,null,e),l}return $u(t,a,l,e),Wu(t)}function cu(t,l,e){if(l=l.updateQueue,l!==null&&(l=l.shared,(e&4194048)!==0)){var a=l.lanes;a&=t.pendingLanes,e|=a,l.lanes=e,X(t,e)}}function Yc(t,l){var e=t.updateQueue,a=t.alternate;if(a!==null&&(a=a.updateQueue,e===a)){var n=null,u=null;if(e=e.firstBaseUpdate,e!==null){do{var c={lane:e.lane,tag:e.tag,payload:e.payload,callback:null,next:null};u===null?n=u=c:u=u.next=c,e=e.next}while(e!==null);u===null?n=u=l:u=u.next=l}else n=u=l;e={baseState:a.baseState,firstBaseUpdate:n,lastBaseUpdate:u,shared:a.shared,callbacks:a.callbacks},t.updateQueue=e;return}t=e.lastBaseUpdate,t===null?e.firstBaseUpdate=l:t.next=l,e.lastBaseUpdate=l}var qc=!1;function fu(){if(qc){var t=An;if(t!==null)throw t}}function ou(t,l,e,a){qc=!1;var n=t.updateQueue;sa=!1;var u=n.firstBaseUpdate,c=n.lastBaseUpdate,r=n.shared.pending;if(r!==null){n.shared.pending=null;var h=r,E=h.next;h.next=null,c===null?u=E:c.next=E,c=h;var j=t.alternate;j!==null&&(j=j.updateQueue,r=j.lastBaseUpdate,r!==c&&(r===null?j.firstBaseUpdate=E:r.next=E,j.lastBaseUpdate=h))}if(u!==null){var w=n.baseState;c=0,j=E=h=null,r=u;do{var M=r.lane&-536870913,D=M!==r.lane;if(D?(Nt&M)===M:(a&M)===M){M!==0&&M===En&&(qc=!0),j!==null&&(j=j.next={lane:0,tag:r.tag,payload:r.payload,callback:null,next:null});t:{var $=t,ct=r;M=l;var Ft=e;switch(ct.tag){case 1:if($=ct.payload,typeof $=="function"){w=$.call(Ft,w,M);break t}w=$;break t;case 3:$.flags=$.flags&-65537|128;case 0:if($=ct.payload,M=typeof $=="function"?$.call(Ft,w,M):$,M==null)break t;w=A({},w,M);break t;case 2:sa=!0}}M=r.callback,M!==null&&(t.flags|=64,D&&(t.flags|=8192),D=n.callbacks,D===null?n.callbacks=[M]:D.push(M))}else D={lane:M,tag:r.tag,payload:r.payload,callback:r.callback,next:null},j===null?(E=j=D,h=w):j=j.next=D,c|=M;if(r=r.next,r===null){if(r=n.shared.pending,r===null)break;D=r,r=D.next,D.next=null,n.lastBaseUpdate=D,n.shared.pending=null}}while(!0);j===null&&(h=w),n.baseState=h,n.firstBaseUpdate=E,n.lastBaseUpdate=j,u===null&&(n.shared.lanes=0),ga|=c,t.lanes=c,t.memoizedState=w}}function bs(t,l){if(typeof t!="function")throw Error(o(191,t));t.call(l)}function Ss(t,l){var e=t.callbacks;if(e!==null)for(t.callbacks=null,t=0;tu?u:8;var c=O.T,r={};O.T=r,nf(t,!1,l,e);try{var h=n(),E=O.S;if(E!==null&&E(r,h),h!==null&&typeof h=="object"&&typeof h.then=="function"){var j=Dm(h,a);du(t,l,j,fe(t))}else du(t,l,a,fe(t))}catch(w){du(t,l,{then:function(){},status:"rejected",reason:w},fe())}finally{V.p=u,c!==null&&r.types!==null&&(c.types=r.types),O.T=c}}function wm(){}function ef(t,l,e,a){if(t.tag!==5)throw Error(o(476));var n=Is(t).queue;Fs(t,n,l,ot,e===null?wm:function(){return Ps(t),e(a)})}function Is(t){var l=t.memoizedState;if(l!==null)return l;l={memoizedState:ot,baseState:ot,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ke,lastRenderedState:ot},next:null};var e={};return l.next={memoizedState:e,baseState:e,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ke,lastRenderedState:e},next:null},t.memoizedState=l,t=t.alternate,t!==null&&(t.memoizedState=l),l}function Ps(t){var l=Is(t);l.next===null&&(l=t.alternate.memoizedState),du(t,l.next.queue,{},fe())}function af(){return Yl(Ou)}function tr(){return bl().memoizedState}function lr(){return bl().memoizedState}function Bm(t){for(var l=t.return;l!==null;){switch(l.tag){case 24:case 3:var e=fe();t=ra(e);var a=da(l,t,e);a!==null&&(Pl(a,l,e),cu(a,l,e)),l={cache:Cc()},t.payload=l;return}l=l.return}}function Ym(t,l,e){var a=fe();e={lane:a,revertLane:0,gesture:null,action:e,hasEagerState:!1,eagerState:null,next:null},yi(t)?ar(l,e):(e=Tc(t,l,e,a),e!==null&&(Pl(e,t,a),nr(e,l,a)))}function er(t,l,e){var a=fe();du(t,l,e,a)}function du(t,l,e,a){var n={lane:a,revertLane:0,gesture:null,action:e,hasEagerState:!1,eagerState:null,next:null};if(yi(t))ar(l,n);else{var u=t.alternate;if(t.lanes===0&&(u===null||u.lanes===0)&&(u=l.lastRenderedReducer,u!==null))try{var c=l.lastRenderedState,r=u(c,e);if(n.hasEagerState=!0,n.eagerState=r,ee(r,c))return $u(t,l,n,0),It===null&&ku(),!1}catch{}finally{}if(e=Tc(t,l,n,a),e!==null)return Pl(e,t,a),nr(e,l,a),!0}return!1}function nf(t,l,e,a){if(a={lane:2,revertLane:Bf(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},yi(t)){if(l)throw Error(o(479))}else l=Tc(t,e,a,2),l!==null&&Pl(l,t,2)}function yi(t){var l=t.alternate;return t===vt||l!==null&&l===vt}function ar(t,l){On=fi=!0;var e=t.pending;e===null?l.next=l:(l.next=e.next,e.next=l),t.pending=l}function nr(t,l,e){if((e&4194048)!==0){var a=l.lanes;a&=t.pendingLanes,e|=a,l.lanes=e,X(t,e)}}var hu={readContext:Yl,use:ri,useCallback:ml,useContext:ml,useEffect:ml,useImperativeHandle:ml,useLayoutEffect:ml,useInsertionEffect:ml,useMemo:ml,useReducer:ml,useRef:ml,useState:ml,useDebugValue:ml,useDeferredValue:ml,useTransition:ml,useSyncExternalStore:ml,useId:ml,useHostTransitionStatus:ml,useFormState:ml,useActionState:ml,useOptimistic:ml,useMemoCache:ml,useCacheRefresh:ml};hu.useEffectEvent=ml;var ur={readContext:Yl,use:ri,useCallback:function(t,l){return Zl().memoizedState=[t,l===void 0?null:l],t},useContext:Yl,useEffect:Gs,useImperativeHandle:function(t,l,e){e=e!=null?e.concat([t]):null,hi(4194308,4,Ks.bind(null,l,t),e)},useLayoutEffect:function(t,l){return hi(4194308,4,t,l)},useInsertionEffect:function(t,l){hi(4,2,t,l)},useMemo:function(t,l){var e=Zl();l=l===void 0?null:l;var a=t();if(Ia){Ll(!0);try{t()}finally{Ll(!1)}}return e.memoizedState=[a,l],a},useReducer:function(t,l,e){var a=Zl();if(e!==void 0){var n=e(l);if(Ia){Ll(!0);try{e(l)}finally{Ll(!1)}}}else n=l;return a.memoizedState=a.baseState=n,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:n},a.queue=t,t=t.dispatch=Ym.bind(null,vt,t),[a.memoizedState,t]},useRef:function(t){var l=Zl();return t={current:t},l.memoizedState=t},useState:function(t){t=Fc(t);var l=t.queue,e=er.bind(null,vt,l);return l.dispatch=e,[t.memoizedState,e]},useDebugValue:tf,useDeferredValue:function(t,l){var e=Zl();return lf(e,t,l)},useTransition:function(){var t=Fc(!1);return t=Fs.bind(null,vt,t.queue,!0,!1),Zl().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,l,e){var a=vt,n=Zl();if(jt){if(e===void 0)throw Error(o(407));e=e()}else{if(e=l(),It===null)throw Error(o(349));(Nt&127)!==0||Ms(a,l,e)}n.memoizedState=e;var u={value:e,getSnapshot:l};return n.queue=u,Gs(Ns.bind(null,a,u,t),[t]),a.flags|=2048,jn(9,{destroy:void 0},xs.bind(null,a,u,e,l),null),e},useId:function(){var t=Zl(),l=It.identifierPrefix;if(jt){var e=Ue,a=Ce;e=(a&~(1<<32-Gl(a)-1)).toString(32)+e,l="_"+l+"R_"+e,e=oi++,0<\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof a.is=="string"?c.createElement("select",{is:a.is}):c.createElement("select"),a.multiple?u.multiple=!0:a.size&&(u.size=a.size);break;default:u=typeof a.is=="string"?c.createElement(n,{is:a.is}):c.createElement(n)}}u[Ut]=l,u[bt]=a;t:for(c=l.child;c!==null;){if(c.tag===5||c.tag===6)u.appendChild(c.stateNode);else if(c.tag!==4&&c.tag!==27&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===l)break t;for(;c.sibling===null;){if(c.return===null||c.return===l)break t;c=c.return}c.sibling.return=c.return,c=c.sibling}l.stateNode=u;t:switch(Xl(u,n,a),n){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break t;case"img":a=!0;break t;default:a=!1}a&&ke(l)}}return al(l),bf(l,l.type,t===null?null:t.memoizedProps,l.pendingProps,e),null;case 6:if(t&&l.stateNode!=null)t.memoizedProps!==a&&ke(l);else{if(typeof a!="string"&&l.stateNode===null)throw Error(o(166));if(t=ht.current,_n(l)){if(t=l.stateNode,e=l.memoizedProps,a=null,n=Bl,n!==null)switch(n.tag){case 27:case 5:a=n.memoizedProps}t[Ut]=l,t=!!(t.nodeValue===e||a!==null&&a.suppressHydrationWarning===!0||Ed(t.nodeValue,e)),t||fa(l,!0)}else t=Hi(t).createTextNode(a),t[Ut]=l,l.stateNode=t}return al(l),null;case 31:if(e=l.memoizedState,t===null||t.memoizedState!==null){if(a=_n(l),e!==null){if(t===null){if(!a)throw Error(o(318));if(t=l.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(o(557));t[Ut]=l}else Za(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;al(l),t=!1}else e=Nc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=e),t=!0;if(!t)return l.flags&256?(ue(l),l):(ue(l),null);if((l.flags&128)!==0)throw Error(o(558))}return al(l),null;case 13:if(a=l.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(n=_n(l),a!==null&&a.dehydrated!==null){if(t===null){if(!n)throw Error(o(318));if(n=l.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(o(317));n[Ut]=l}else Za(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;al(l),n=!1}else n=Nc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=n),n=!0;if(!n)return l.flags&256?(ue(l),l):(ue(l),null)}return ue(l),(l.flags&128)!==0?(l.lanes=e,l):(e=a!==null,t=t!==null&&t.memoizedState!==null,e&&(a=l.child,n=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(n=a.alternate.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==n&&(a.flags|=2048)),e!==t&&e&&(l.child.flags|=8192),Si(l,l.updateQueue),al(l),null);case 4:return Pt(),t===null&&Lf(l.stateNode.containerInfo),al(l),null;case 10:return Qe(l.type),al(l),null;case 19:if(C(pl),a=l.memoizedState,a===null)return al(l),null;if(n=(l.flags&128)!==0,u=a.rendering,u===null)if(n)yu(a,!1);else{if(yl!==0||t!==null&&(t.flags&128)!==0)for(t=l.child;t!==null;){if(u=ci(t),u!==null){for(l.flags|=128,yu(a,!1),t=u.updateQueue,l.updateQueue=t,Si(l,t),l.subtreeFlags=0,t=e,e=l.child;e!==null;)es(e,t),e=e.sibling;return Q(pl,pl.current&1|2),jt&&Ge(l,a.treeForkCount),l.child}t=t.sibling}a.tail!==null&&Z()>Ai&&(l.flags|=128,n=!0,yu(a,!1),l.lanes=4194304)}else{if(!n)if(t=ci(u),t!==null){if(l.flags|=128,n=!0,t=t.updateQueue,l.updateQueue=t,Si(l,t),yu(a,!0),a.tail===null&&a.tailMode==="hidden"&&!u.alternate&&!jt)return al(l),null}else 2*Z()-a.renderingStartTime>Ai&&e!==536870912&&(l.flags|=128,n=!0,yu(a,!1),l.lanes=4194304);a.isBackwards?(u.sibling=l.child,l.child=u):(t=a.last,t!==null?t.sibling=u:l.child=u,a.last=u)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=Z(),t.sibling=null,e=pl.current,Q(pl,n?e&1|2:e&1),jt&&Ge(l,a.treeForkCount),t):(al(l),null);case 22:case 23:return ue(l),Lc(),a=l.memoizedState!==null,t!==null?t.memoizedState!==null!==a&&(l.flags|=8192):a&&(l.flags|=8192),a?(e&536870912)!==0&&(l.flags&128)===0&&(al(l),l.subtreeFlags&6&&(l.flags|=8192)):al(l),e=l.updateQueue,e!==null&&Si(l,e.retryQueue),e=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),a=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(a=l.memoizedState.cachePool.pool),a!==e&&(l.flags|=2048),t!==null&&C(ka),null;case 24:return e=null,t!==null&&(e=t.memoizedState.cache),l.memoizedState.cache!==e&&(l.flags|=2048),Qe(Tl),al(l),null;case 25:return null;case 30:return null}throw Error(o(156,l.tag))}function Vm(t,l){switch(Mc(l),l.tag){case 1:return t=l.flags,t&65536?(l.flags=t&-65537|128,l):null;case 3:return Qe(Tl),Pt(),t=l.flags,(t&65536)!==0&&(t&128)===0?(l.flags=t&-65537|128,l):null;case 26:case 27:case 5:return se(l),null;case 31:if(l.memoizedState!==null){if(ue(l),l.alternate===null)throw Error(o(340));Za()}return t=l.flags,t&65536?(l.flags=t&-65537|128,l):null;case 13:if(ue(l),t=l.memoizedState,t!==null&&t.dehydrated!==null){if(l.alternate===null)throw Error(o(340));Za()}return t=l.flags,t&65536?(l.flags=t&-65537|128,l):null;case 19:return C(pl),null;case 4:return Pt(),null;case 10:return Qe(l.type),null;case 22:case 23:return ue(l),Lc(),t!==null&&C(ka),t=l.flags,t&65536?(l.flags=t&-65537|128,l):null;case 24:return Qe(Tl),null;case 25:return null;default:return null}}function Or(t,l){switch(Mc(l),l.tag){case 3:Qe(Tl),Pt();break;case 26:case 27:case 5:se(l);break;case 4:Pt();break;case 31:l.memoizedState!==null&&ue(l);break;case 13:ue(l);break;case 19:C(pl);break;case 10:Qe(l.type);break;case 22:case 23:ue(l),Lc(),t!==null&&C(ka);break;case 24:Qe(Tl)}}function vu(t,l){try{var e=l.updateQueue,a=e!==null?e.lastEffect:null;if(a!==null){var n=a.next;e=n;do{if((e.tag&t)===t){a=void 0;var u=e.create,c=e.inst;a=u(),c.destroy=a}e=e.next}while(e!==n)}}catch(r){kt(l,l.return,r)}}function ya(t,l,e){try{var a=l.updateQueue,n=a!==null?a.lastEffect:null;if(n!==null){var u=n.next;a=u;do{if((a.tag&t)===t){var c=a.inst,r=c.destroy;if(r!==void 0){c.destroy=void 0,n=l;var h=e,E=r;try{E()}catch(j){kt(n,h,j)}}}a=a.next}while(a!==u)}}catch(j){kt(l,l.return,j)}}function Dr(t){var l=t.updateQueue;if(l!==null){var e=t.stateNode;try{Ss(l,e)}catch(a){kt(t,t.return,a)}}}function jr(t,l,e){e.props=Pa(t.type,t.memoizedProps),e.state=t.memoizedState;try{e.componentWillUnmount()}catch(a){kt(t,l,a)}}function gu(t,l){try{var e=t.ref;if(e!==null){switch(t.tag){case 26:case 27:case 5:var a=t.stateNode;break;case 30:a=t.stateNode;break;default:a=t.stateNode}typeof e=="function"?t.refCleanup=e(a):e.current=a}}catch(n){kt(t,l,n)}}function Re(t,l){var e=t.ref,a=t.refCleanup;if(e!==null)if(typeof a=="function")try{a()}catch(n){kt(t,l,n)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof e=="function")try{e(null)}catch(n){kt(t,l,n)}else e.current=null}function Cr(t){var l=t.type,e=t.memoizedProps,a=t.stateNode;try{t:switch(l){case"button":case"input":case"select":case"textarea":e.autoFocus&&a.focus();break t;case"img":e.src?a.src=e.src:e.srcSet&&(a.srcset=e.srcSet)}}catch(n){kt(t,t.return,n)}}function Sf(t,l,e){try{var a=t.stateNode;ry(a,t.type,e,l),a[bt]=l}catch(n){kt(t,t.return,n)}}function Ur(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&_a(t.type)||t.tag===4}function Tf(t){t:for(;;){for(;t.sibling===null;){if(t.return===null||Ur(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&_a(t.type)||t.flags&2||t.child===null||t.tag===4)continue t;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function _f(t,l,e){var a=t.tag;if(a===5||a===6)t=t.stateNode,l?(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e).insertBefore(t,l):(l=e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,l.appendChild(t),e=e._reactRootContainer,e!=null||l.onclick!==null||(l.onclick=qe));else if(a!==4&&(a===27&&_a(t.type)&&(e=t.stateNode,l=null),t=t.child,t!==null))for(_f(t,l,e),t=t.sibling;t!==null;)_f(t,l,e),t=t.sibling}function Ti(t,l,e){var a=t.tag;if(a===5||a===6)t=t.stateNode,l?e.insertBefore(t,l):e.appendChild(t);else if(a!==4&&(a===27&&_a(t.type)&&(e=t.stateNode),t=t.child,t!==null))for(Ti(t,l,e),t=t.sibling;t!==null;)Ti(t,l,e),t=t.sibling}function Rr(t){var l=t.stateNode,e=t.memoizedProps;try{for(var a=t.type,n=l.attributes;n.length;)l.removeAttributeNode(n[0]);Xl(l,a,e),l[Ut]=t,l[bt]=e}catch(u){kt(t,t.return,u)}}var $e=!1,El=!1,zf=!1,Hr=typeof WeakSet=="function"?WeakSet:Set,Cl=null;function Qm(t,l){if(t=t.containerInfo,Qf=Gi,t=Jo(t),yc(t)){if("selectionStart"in t)var e={start:t.selectionStart,end:t.selectionEnd};else t:{e=(e=t.ownerDocument)&&e.defaultView||window;var a=e.getSelection&&e.getSelection();if(a&&a.rangeCount!==0){e=a.anchorNode;var n=a.anchorOffset,u=a.focusNode;a=a.focusOffset;try{e.nodeType,u.nodeType}catch{e=null;break t}var c=0,r=-1,h=-1,E=0,j=0,w=t,M=null;l:for(;;){for(var D;w!==e||n!==0&&w.nodeType!==3||(r=c+n),w!==u||a!==0&&w.nodeType!==3||(h=c+a),w.nodeType===3&&(c+=w.nodeValue.length),(D=w.firstChild)!==null;)M=w,w=D;for(;;){if(w===t)break l;if(M===e&&++E===n&&(r=c),M===u&&++j===a&&(h=c),(D=w.nextSibling)!==null)break;w=M,M=w.parentNode}w=D}e=r===-1||h===-1?null:{start:r,end:h}}else e=null}e=e||{start:0,end:0}}else e=null;for(Zf={focusedElem:t,selectionRange:e},Gi=!1,Cl=l;Cl!==null;)if(l=Cl,t=l.child,(l.subtreeFlags&1028)!==0&&t!==null)t.return=l,Cl=t;else for(;Cl!==null;){switch(l=Cl,u=l.alternate,t=l.flags,l.tag){case 0:if((t&4)!==0&&(t=l.updateQueue,t=t!==null?t.events:null,t!==null))for(e=0;e title"))),Xl(u,a,e),u[Ut]=t,mt(u),a=u;break t;case"link":var c=Ld("link","href",n).get(a+(e.href||""));if(c){for(var r=0;rFt&&(c=Ft,Ft=ct,ct=c);var T=Zo(r,ct),p=Zo(r,Ft);if(T&&p&&(D.rangeCount!==1||D.anchorNode!==T.node||D.anchorOffset!==T.offset||D.focusNode!==p.node||D.focusOffset!==p.offset)){var z=w.createRange();z.setStart(T.node,T.offset),D.removeAllRanges(),ct>Ft?(D.addRange(z),D.extend(p.node,p.offset)):(z.setEnd(p.node,p.offset),D.addRange(z))}}}}for(w=[],D=r;D=D.parentNode;)D.nodeType===1&&w.push({element:D,left:D.scrollLeft,top:D.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;re?32:e,O.T=null,e=Df,Df=null;var u=ba,c=ta;if(Ol=0,wn=ba=null,ta=0,(Xt&6)!==0)throw Error(o(331));var r=Xt;if(Xt|=4,Kr(u.current),Vr(u,u.current,c,e),Xt=r,zu(0,!1),Rl&&typeof Rl.onPostCommitFiberRoot=="function")try{Rl.onPostCommitFiberRoot(jl,u)}catch{}return!0}finally{V.p=n,O.T=a,sd(t,l)}}function dd(t,l,e){l=ye(e,l),l=of(t.stateNode,l,2),t=da(t,l,2),t!==null&&(g(t,2),He(t))}function kt(t,l,e){if(t.tag===3)dd(t,t,e);else for(;l!==null;){if(l.tag===3){dd(l,t,e);break}else if(l.tag===1){var a=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(pa===null||!pa.has(a))){t=ye(e,t),e=hr(2),a=da(l,e,2),a!==null&&(mr(e,a,l,t),g(a,2),He(a));break}}l=l.return}}function Rf(t,l,e){var a=t.pingCache;if(a===null){a=t.pingCache=new Jm;var n=new Set;a.set(l,n)}else n=a.get(l),n===void 0&&(n=new Set,a.set(l,n));n.has(e)||(Mf=!0,n.add(e),t=Im.bind(null,t,l,e),l.then(t,t))}function Im(t,l,e){var a=t.pingCache;a!==null&&a.delete(l),t.pingedLanes|=t.suspendedLanes&e,t.warmLanes&=~e,It===t&&(Nt&e)===e&&(yl===4||yl===3&&(Nt&62914560)===Nt&&300>Z()-Ei?(Xt&2)===0&&Bn(t,0):xf|=e,Hn===Nt&&(Hn=0)),He(t)}function hd(t,l){l===0&&(l=Yu()),t=Va(t,l),t!==null&&(g(t,l),He(t))}function Pm(t){var l=t.memoizedState,e=0;l!==null&&(e=l.retryLane),hd(t,e)}function ty(t,l){var e=0;switch(t.tag){case 31:case 13:var a=t.stateNode,n=t.memoizedState;n!==null&&(e=n.retryLane);break;case 19:a=t.stateNode;break;case 22:a=t.stateNode._retryCache;break;default:throw Error(o(314))}a!==null&&a.delete(l),hd(t,e)}function ly(t,l){return Dl(t,l)}var ji=null,qn=null,Hf=!1,Ci=!1,wf=!1,Ta=0;function He(t){t!==qn&&t.next===null&&(qn===null?ji=qn=t:qn=qn.next=t),Ci=!0,Hf||(Hf=!0,ay())}function zu(t,l){if(!wf&&Ci){wf=!0;do for(var e=!1,a=ji;a!==null;){if(t!==0){var n=a.pendingLanes;if(n===0)var u=0;else{var c=a.suspendedLanes,r=a.pingedLanes;u=(1<<31-Gl(42|t)+1)-1,u&=n&~(c&~r),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(e=!0,gd(a,u))}else u=Nt,u=Ha(a,a===It?u:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(u&3)===0||je(a,u)||(e=!0,gd(a,u));a=a.next}while(e);wf=!1}}function ey(){md()}function md(){Ci=Hf=!1;var t=0;Ta!==0&&hy()&&(t=Ta);for(var l=Z(),e=null,a=ji;a!==null;){var n=a.next,u=yd(a,l);u===0?(a.next=null,e===null?ji=n:e.next=n,n===null&&(qn=e)):(e=a,(t!==0||(u&3)!==0)&&(Ci=!0)),a=n}Ol!==0&&Ol!==5||zu(t),Ta!==0&&(Ta=0)}function yd(t,l){for(var e=t.suspendedLanes,a=t.pingedLanes,n=t.expirationTimes,u=t.pendingLanes&-62914561;0r)break;var j=h.transferSize,w=h.initiatorType;j&&Ad(w)&&(h=h.responseEnd,c+=j*(h"u"?null:document;function Bd(t,l,e){var a=Xn;if(a&&typeof l=="string"&&l){var n=hl(l);n='link[rel="'+t+'"][href="'+n+'"]',typeof e=="string"&&(n+='[crossorigin="'+e+'"]'),wd.has(n)||(wd.add(n),t={rel:t,crossOrigin:e,href:l},a.querySelector(n)===null&&(l=a.createElement("link"),Xl(l,"link",t),mt(l),a.head.appendChild(l)))}}function _y(t){la.D(t),Bd("dns-prefetch",t,null)}function zy(t,l){la.C(t,l),Bd("preconnect",t,l)}function Ey(t,l,e){la.L(t,l,e);var a=Xn;if(a&&t&&l){var n='link[rel="preload"][as="'+hl(l)+'"]';l==="image"&&e&&e.imageSrcSet?(n+='[imagesrcset="'+hl(e.imageSrcSet)+'"]',typeof e.imageSizes=="string"&&(n+='[imagesizes="'+hl(e.imageSizes)+'"]')):n+='[href="'+hl(t)+'"]';var u=n;switch(l){case"style":u=Ln(t);break;case"script":u=Gn(t)}Te.has(u)||(t=A({rel:"preload",href:l==="image"&&e&&e.imageSrcSet?void 0:t,as:l},e),Te.set(u,t),a.querySelector(n)!==null||l==="style"&&a.querySelector(xu(u))||l==="script"&&a.querySelector(Nu(u))||(l=a.createElement("link"),Xl(l,"link",t),mt(l),a.head.appendChild(l)))}}function Ay(t,l){la.m(t,l);var e=Xn;if(e&&t){var a=l&&typeof l.as=="string"?l.as:"script",n='link[rel="modulepreload"][as="'+hl(a)+'"][href="'+hl(t)+'"]',u=n;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Gn(t)}if(!Te.has(u)&&(t=A({rel:"modulepreload",href:t},l),Te.set(u,t),e.querySelector(n)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(e.querySelector(Nu(u)))return}a=e.createElement("link"),Xl(a,"link",t),mt(a),e.head.appendChild(a)}}}function My(t,l,e){la.S(t,l,e);var a=Xn;if(a&&t){var n=wt(a).hoistableStyles,u=Ln(t);l=l||"default";var c=n.get(u);if(!c){var r={loading:0,preload:null};if(c=a.querySelector(xu(u)))r.loading=5;else{t=A({rel:"stylesheet",href:t,"data-precedence":l},e),(e=Te.get(u))&&If(t,e);var h=c=a.createElement("link");mt(h),Xl(h,"link",t),h._p=new Promise(function(E,j){h.onload=E,h.onerror=j}),h.addEventListener("load",function(){r.loading|=1}),h.addEventListener("error",function(){r.loading|=2}),r.loading|=4,Bi(c,l,a)}c={type:"stylesheet",instance:c,count:1,state:r},n.set(u,c)}}}function xy(t,l){la.X(t,l);var e=Xn;if(e&&t){var a=wt(e).hoistableScripts,n=Gn(t),u=a.get(n);u||(u=e.querySelector(Nu(n)),u||(t=A({src:t,async:!0},l),(l=Te.get(n))&&Pf(t,l),u=e.createElement("script"),mt(u),Xl(u,"link",t),e.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function Ny(t,l){la.M(t,l);var e=Xn;if(e&&t){var a=wt(e).hoistableScripts,n=Gn(t),u=a.get(n);u||(u=e.querySelector(Nu(n)),u||(t=A({src:t,async:!0,type:"module"},l),(l=Te.get(n))&&Pf(t,l),u=e.createElement("script"),mt(u),Xl(u,"link",t),e.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function Yd(t,l,e,a){var n=(n=ht.current)?wi(n):null;if(!n)throw Error(o(446));switch(t){case"meta":case"title":return null;case"style":return typeof e.precedence=="string"&&typeof e.href=="string"?(l=Ln(e.href),e=wt(n).hoistableStyles,a=e.get(l),a||(a={type:"style",instance:null,count:0,state:null},e.set(l,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(e.rel==="stylesheet"&&typeof e.href=="string"&&typeof e.precedence=="string"){t=Ln(e.href);var u=wt(n).hoistableStyles,c=u.get(t);if(c||(n=n.ownerDocument||n,c={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(t,c),(u=n.querySelector(xu(t)))&&!u._p&&(c.instance=u,c.state.loading=5),Te.has(t)||(e={rel:"preload",as:"style",href:e.href,crossOrigin:e.crossOrigin,integrity:e.integrity,media:e.media,hrefLang:e.hrefLang,referrerPolicy:e.referrerPolicy},Te.set(t,e),u||Oy(n,t,e,c.state))),l&&a===null)throw Error(o(528,""));return c}if(l&&a!==null)throw Error(o(529,""));return null;case"script":return l=e.async,e=e.src,typeof e=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=Gn(e),e=wt(n).hoistableScripts,a=e.get(l),a||(a={type:"script",instance:null,count:0,state:null},e.set(l,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,t))}}function Ln(t){return'href="'+hl(t)+'"'}function xu(t){return'link[rel="stylesheet"]['+t+"]"}function qd(t){return A({},t,{"data-precedence":t.precedence,precedence:null})}function Oy(t,l,e,a){t.querySelector('link[rel="preload"][as="style"]['+l+"]")?a.loading=1:(l=t.createElement("link"),a.preload=l,l.addEventListener("load",function(){return a.loading|=1}),l.addEventListener("error",function(){return a.loading|=2}),Xl(l,"link",e),mt(l),t.head.appendChild(l))}function Gn(t){return'[src="'+hl(t)+'"]'}function Nu(t){return"script[async]"+t}function Xd(t,l,e){if(l.count++,l.instance===null)switch(l.type){case"style":var a=t.querySelector('style[data-href~="'+hl(e.href)+'"]');if(a)return l.instance=a,mt(a),a;var n=A({},e,{"data-href":e.href,"data-precedence":e.precedence,href:null,precedence:null});return a=(t.ownerDocument||t).createElement("style"),mt(a),Xl(a,"style",n),Bi(a,e.precedence,t),l.instance=a;case"stylesheet":n=Ln(e.href);var u=t.querySelector(xu(n));if(u)return l.state.loading|=4,l.instance=u,mt(u),u;a=qd(e),(n=Te.get(n))&&If(a,n),u=(t.ownerDocument||t).createElement("link"),mt(u);var c=u;return c._p=new Promise(function(r,h){c.onload=r,c.onerror=h}),Xl(u,"link",a),l.state.loading|=4,Bi(u,e.precedence,t),l.instance=u;case"script":return u=Gn(e.src),(n=t.querySelector(Nu(u)))?(l.instance=n,mt(n),n):(a=e,(n=Te.get(u))&&(a=A({},e),Pf(a,n)),t=t.ownerDocument||t,n=t.createElement("script"),mt(n),Xl(n,"link",a),t.head.appendChild(n),l.instance=n);case"void":return null;default:throw Error(o(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(a=l.instance,l.state.loading|=4,Bi(a,e.precedence,t));return l.instance}function Bi(t,l,e){for(var a=e.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),n=a.length?a[a.length-1]:null,u=n,c=0;c title"):null)}function Dy(t,l,e){if(e===1||l.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;switch(l.rel){case"stylesheet":return t=l.disabled,typeof l.precedence=="string"&&t==null;default:return!0}case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function Vd(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function jy(t,l,e,a){if(e.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(e.state.loading&4)===0){if(e.instance===null){var n=Ln(a.href),u=l.querySelector(xu(n));if(u){l=u._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(t.count++,t=qi.bind(t),l.then(t,t)),e.state.loading|=4,e.instance=u,mt(u);return}u=l.ownerDocument||l,a=qd(a),(n=Te.get(n))&&If(a,n),u=u.createElement("link"),mt(u);var c=u;c._p=new Promise(function(r,h){c.onload=r,c.onerror=h}),Xl(u,"link",a),e.instance=u}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(e,l),(l=e.state.preload)&&(e.state.loading&3)===0&&(t.count++,e=qi.bind(t),l.addEventListener("load",e),l.addEventListener("error",e))}}var to=0;function Cy(t,l){return t.stylesheets&&t.count===0&&Li(t,t.stylesheets),0to?50:800)+l);return t.unsuspend=e,function(){t.unsuspend=null,clearTimeout(a),clearTimeout(n)}}:null}function qi(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Li(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Xi=null;function Li(t,l){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Xi=new Map,l.forEach(Uy,t),Xi=null,qi.call(t))}function Uy(t,l){if(!(l.state.loading&4)){var e=Xi.get(t);if(e)var a=e.get(null);else{e=new Map,Xi.set(t,e);for(var n=t.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(f){console.error(f)}}return i(),fo.exports=Wy(),fo.exports}var Iy=Fy(),K=bo();const $i=Gy(K),vo={role:"角色",birth:"生卒",born:"出生",death:"卒年",dynasty:"朝代",era:"年代",nickname:"别称",alias:"别称",title:"头衔",name:"名称",function:"职能",summary:"概要",type:"类型",category:"分类",status:"状态",location:"地点",place:"地点",org:"组织",organization:"组织",party:"党派",nation:"国家",year:"年份",date:"日期",period:"时期",event:"事件",cause:"原因",effect:"影响",result:"结果",note:"备注",sla:"SLA"},hh=6,Py=36;function t0(i,f){const s=i.trim();return s.length<=f?s:`${s.slice(0,f-1)}…`}function l0(i){if(i==null)return null;if(typeof i=="string")return i.trim()||null;if(typeof i=="number"||typeof i=="boolean")return String(i);if(Array.isArray(i)){const f=i.map(s=>typeof s=="string"||typeof s=="number"?String(s):null).filter(Boolean);return f.length?f.join("、"):null}if(typeof i=="object")try{return JSON.stringify(i)}catch{return null}return null}function Nh(i){const f=i.toLowerCase();return vo[i]||vo[f]||i}const e0=(()=>{const i={};for(const[f,s]of Object.entries(vo))i[s]||(i[s]=f);return i})();function a0(i){const f=i.trim();return f&&(e0[f]||f)}function n0(i){return Nh(i)}function Fi(i,f=hh){const s=typeof f=="number"?{max:f}:f,o=s.max??(s.full?64:hh),m=!!s.full;if(!i||typeof i!="object")return[];const v=[];for(const[_,N]of Object.entries(i)){const x=l0(N);if(!x)continue;const S=m?x:t0(x,Py);if(v.push({key:_,label:Nh(_),value:S,fullValue:x}),v.length>=o)break}return v}function u0(i){const f=Fi(i,3);return f.length?f.map(s=>`${s.label} ${s.value}`).join(" · "):null}function i0(i){try{return new URL(i).hostname.replace(/^www\./,"")}catch{return i.slice(0,32)}}function mh(i){if(i==null||!Number.isFinite(i))return null;try{return new Date(i).toLocaleDateString()}catch{return null}}function yh(i){if(!i.trim())return null;const f=Date.parse(i);return Number.isFinite(f)?f:null}function c0(i){return i.split(` `).map(f=>f.trim()).filter(Boolean).map(f=>{const s=f.indexOf("|");return s>=0?{title:f.slice(0,s).trim(),url:f.slice(s+1).trim()}:{url:f}}).filter(f=>f.url)}function f0(i){return(i??[]).map(f=>f.title?`${f.title}|${f.url}`:f.url).join(` `)}const So=[{id:"text",label:"标题",kind:"title",always:!0,rowHeight:22,isEmpty:i=>{var f;return!((f=i.text)!=null&&f.trim())},preview:i=>{var f;return((f=i.text)==null?void 0:f.trim())||"未命名"},commit:(i,f)=>[{type:"update_text",nodeId:i,text:f.trim()||"未命名"}]},{id:"imageUrl",label:"配图",kind:"image",imageRow:!0,rowHeight:64,isEmpty:i=>{var f;return!((f=i.imageUrl)!=null&&f.trim())},preview:i=>{var f;return((f=i.imageUrl)==null?void 0:f.trim())||null},commit:(i,f)=>[{type:"update_node_meta",nodeId:i,patch:{imageUrl:f.trim()||null}}]},{id:"note",label:"摘要",kind:"textarea",rowHeight:18,isEmpty:i=>{var f;return!((f=i.note)!=null&&f.trim())},preview:i=>{var s;const f=(s=i.note)==null?void 0:s.trim();return f?f.length>72?`${f.slice(0,72)}…`:f:null},commit:(i,f)=>[{type:"update_node_meta",nodeId:i,patch:{note:f.trim()||null}}]},{id:"tags",label:"标签",kind:"tags",rowHeight:18,isEmpty:i=>{var f;return!(((f=i.tags)==null?void 0:f.length)>0)},preview:i=>{var f;return(f=i.tags)!=null&&f.length?i.tags.slice(0,4).map(s=>`#${s}`).join(" "):null},commit:(i,f)=>{const s=f.split(/[,,]/).map(o=>o.trim()).filter(Boolean);return[{type:"update_node_meta",nodeId:i,patch:{tags:s}}]}},{id:"links",label:"来源",kind:"links",rowHeight:18,isEmpty:i=>{var f;return!(((f=i.links)==null?void 0:f.length)>0)},preview:i=>{var m,v,_;const f=(m=i.links)==null?void 0:m[0];if(!f)return null;const s=((v=f.title)==null?void 0:v.trim())||i0(f.url),o=(((_=i.links)==null?void 0:_.length)??0)>1?` +${i.links.length-1}`:"";return`${s}${o}`},commit:(i,f)=>[{type:"update_node_meta",nodeId:i,patch:{links:c0(f)}}]},{id:"startAt",label:"开始",kind:"datetime",rowHeight:18,isEmpty:i=>i.startAt==null,preview:i=>mh(i.startAt),commit:(i,f)=>[{type:"update_node_meta",nodeId:i,patch:{startAt:yh(f)}}]},{id:"dueAt",label:"截止",kind:"datetime",rowHeight:18,isEmpty:i=>i.dueAt==null,preview:i=>mh(i.dueAt),commit:(i,f)=>[{type:"update_node_meta",nodeId:i,patch:{dueAt:yh(f)}}]},{id:"pinned",label:"固定",kind:"flag",rowHeight:18,isEmpty:i=>!i.pinned,preview:i=>i.pinned?"已钉住":null,commit:(i,f)=>[{type:"set_pinned",nodeId:i,pinned:f==="1"||f==="true"}]},{id:"description",label:"属性",kind:"textarea",rowHeight:36,isEmpty:i=>!i.description||Object.keys(i.description).length===0,preview:i=>u0(i.description),commit:(i,f)=>{const s=f.trim();if(!s)return[{type:"update_node_meta",nodeId:i,patch:{description:null}}];try{const o=JSON.parse(s);if(!o||typeof o!="object"||Array.isArray(o))throw new Error("description must be a JSON object");return[{type:"update_node_meta",nodeId:i,patch:{description:o}}]}catch{return[]}}}],o0=Object.fromEntries(So.map(i=>[i.id,i]));function s0(i,f=new Set){const s=[];for(const o of So)(o.always||!o.isEmpty(i)||f.has(o.id))&&s.push({def:o,preview:o.preview(i)});return s}function r0(i,f=new Set){return So.filter(s=>!s.always&&s.isEmpty(i)&&!f.has(s.id))}function d0(i,f){switch(f){case"text":return i.text??"";case"note":return i.note??"";case"description":return i.description?JSON.stringify(i.description,null,2):"";case"imageUrl":return i.imageUrl??"";case"tags":return(i.tags??[]).join(", ");case"links":return f0(i.links);case"startAt":return vh(i.startAt);case"dueAt":return vh(i.dueAt);case"pinned":return i.pinned?"1":"0";default:return""}}function vh(i){if(i==null||!Number.isFinite(i))return"";const f=new Date(i),s=o=>String(o).padStart(2,"0");return`${f.getFullYear()}-${s(f.getMonth()+1)}-${s(f.getDate())}T${s(f.getHours())}:${s(f.getMinutes())}`}function h0(i,f,s){return o0[f].commit(i.id,s,i)}const gh={comfortable:288,compact:248},ea=40,Ii=12,Al=14,oe=10,Oa={comfortable:108,compact:90},Qn=18,Oh=24;function Pi(i,f,s=new Set,o={}){var R,A,q,et;const m=!!o.expanded,v=f?gh.compact:gh.comfortable;let _=0;if((R=i.imageUrl)!=null&&R.trim()&&(_+=(f?Oa.compact:Oa.comfortable)+oe),(A=i.note)!=null&&A.trim())if(m){const tt=Math.min(12,Math.max(2,Math.ceil(i.note.trim().length/(f?28:34))));_+=tt*(f?15:16)+oe}else _+=(f?40:48)+oe;const N=Fi(i.description,{full:m,max:m?64:6});if(N.length)if(m){const tt=f?4:5;let dt=0;for(const ft of N){const G=Math.min(8,Math.max(1,Math.ceil(ft.fullValue.length/(f?18:22))));dt+=Qn+Math.max(0,G-1)*(f?14:15),dt+=tt}_+=dt+oe}else _+=N.length*Qn+Math.max(0,N.length-1)*4+oe;(!!((q=i.tags)!=null&&q.length)||!!((et=i.links)!=null&&et.length)||i.startAt!=null||i.dueAt!=null||!!i.pinned)&&(_+=Oh+oe),_>0&&(_-=oe);const S=ea+Ii*2+Math.max(_,8);return{w:v,h:Math.max(S,f?88:104)}}const m0='"Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif';function _e(i,f=400){return`${f===400?"":`${f} `}${i}px ${m0}`}function ph(i,f,s){const o=(s==null?void 0:s.weight)==="heavy",m=Math.max(.5,f);if(o){i.shadowColor=s!=null&&s.selected?"rgba(0, 0, 0, 0.62)":"rgba(0, 0, 0, 0.5)",i.shadowBlur=(s!=null&&s.selected?28:22)/m,i.shadowOffsetX=0,i.shadowOffsetY=7/m;return}i.shadowColor=s!=null&&s.selected?"rgba(0, 0, 0, 0.45)":"rgba(0, 0, 0, 0.28)",i.shadowBlur=(s!=null&&s.selected?18:12)/m,i.shadowOffsetX=0,i.shadowOffsetY=3/m}function mo(i){i.shadowColor="transparent",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0}function y0(i,f,s=.14){i.save(),i.globalAlpha=s,i.fillStyle=f,i.fill(),i.restore()}function v0(i,f,s,o,m,v=10){i.save(),i.beginPath();const N=Math.min(v,o/2);i.moveTo(f+N,s),i.lineTo(f+4,s),i.lineTo(f+4,s+o),i.lineTo(f+N,s+o),i.quadraticCurveTo(f,s+o,f,s+o-N),i.lineTo(f,s+N),i.quadraticCurveTo(f,s,f+N,s),i.closePath(),i.fillStyle=m,i.globalAlpha=.95,i.fill(),i.restore()}function Dh(i,f,s,o,m,v){const N=16/Math.max(.75,Math.min(1.2,v));i.font=_e(10/Math.max(.75,Math.min(1.2,v)),500);const S=i.measureText(f).width+12;i.beginPath();const R=N/2;return i.moveTo(s+R,o),i.arcTo(s+S,o,s+S,o+N,R),i.arcTo(s+S,o+N,s,o+N,R),i.arcTo(s,o+N,s,o,R),i.arcTo(s,o,s+S,o,R),i.closePath(),i.fillStyle=m.glassHeader??"rgba(255,255,255,0.06)",i.fill(),i.strokeStyle=m.glassBorder??m.border,i.lineWidth=1/Math.max(.5,v),i.stroke(),i.fillStyle=m.labelSecondary,i.textBaseline="middle",i.fillText(f,s+6,o+N/2),S+4}const Hu=new Map;function go(i,f){const s=Hu.get(i);if(s instanceof HTMLImageElement)return s;if(s==="loading"||s==="error")return null;Hu.set(i,"loading");const o=new Image;return o.decoding="async",o.crossOrigin="anonymous",o.onload=()=>{Hu.set(i,o),f()},o.onerror=()=>{Hu.set(i,"error"),f()},o.src=i,null}function g0(i){return Hu.get(i)==="error"}const Na={comfortable:36,compact:30},p0="/topo/ne-router.png";function b0(i,f,s){var N,x;if(s!=null&&s.asTopology){const S=f?Na.compact:Na.comfortable,R=f?18:20,A=6,q=f?6:8;return{w:Math.max(f?72:88,S+q*2),h:S+A+R+q}}if(s!=null&&s.asCard||i.stylePreset==="card")return Pi(i,f,new Set,{expanded:s==null?void 0:s.expanded});let o=f?168:212,m=f?48:60;const v=!!((N=i.tags)!=null&&N.length)||!!((x=i.links)!=null&&x.length)||i.dueAt!=null||!!i.note;m+=v?f?20:26:f?8:10;const _=i.stylePreset;return _==="title"?(o*=1.18,m*=1.15):_==="decision"?(o*=1.08,m*=1.12):_==="note"&&(m*=1.12),i.imageUrl&&(o=Math.max(o,f?200:248),m+=f?78:96),{w:o,h:m}}function bh(i,f,s,o,m,v,_){if(i.beginPath(),f==="decision"){const N=s+m/2,x=o+v/2;i.moveTo(N,o),i.lineTo(s+m,x),i.lineTo(N,o+v),i.lineTo(s,x),i.closePath()}else if(f==="note"){const N=Math.min(12,m*.12);i.moveTo(s,o),i.lineTo(s+m-N,o),i.lineTo(s+m,o+N),i.lineTo(s+m,o+v),i.lineTo(s,o+v),i.closePath()}else if(f==="title"){const N=v/2;Wi(i,s,o,m,v,N)}else Wi(i,s,o,m,v,_)}function Wi(i,f,s,o,m,v){const _=Math.min(v,o/2,m/2);i.moveTo(f+_,s),i.arcTo(f+o,s,f+o,s+m,_),i.arcTo(f+o,s+m,f,s+m,_),i.arcTo(f,s+m,f,s,_),i.arcTo(f,s,f+o,s,_),i.closePath()}function un(i,f,s,o){const m=f.replace(/\s+/g," ").trim();if(!m)return[];const v=[];let _=m;for(;_&&v.lengthS*.4&&(S=R);let A=_.slice(0,S).trimEnd();if(_=_.slice(S).trimStart(),v.length===o-1&&_){for(;A.length>1&&i.measureText(`${A}…`).width>s;)A=A.slice(0,-1);v.push(`${A}…`);break}v.push(A)}return v}function S0(i){var s,o;const f=[];if(i.icon){const m=T0[i.icon];m&&f.push(m)}return i.collapsed&&f.push("▸"),(s=i.links)!=null&&s.length&&f.push("🔗"),i.imageUrl&&f.push("🖼"),i.dueAt!=null&&f.push("⏰"),(o=i.tags)!=null&&o.length&&f.push(`#${i.tags.length}`),i.pinned&&f.push("📌"),f}const T0={server:"[服]",database:"[库]",cloud:"[云]",person:"[人]",folder:"[夹]",doc:"[档]",link:"[链]",warning:"[警]",check:"[✓]",star:"[★]",gear:"[设]",globe:"[球]",router:"[路]"};function _0(i){try{return new URL(i).hostname.replace(/^www\./,"")}catch{return i.slice(0,28)}}function Sh(i){if(i==null||!Number.isFinite(i))return null;try{return new Date(i).toLocaleDateString()}catch{return null}}function z0(i,f,s=!1){var R,A;const{w:o}=Pi(i,f,new Set,{expanded:s});let m=ea+Math.max(4,Ii-4);const v=o-Al*2;(R=i.imageUrl)!=null&&R.trim()&&(m+=(f?Oa.compact:Oa.comfortable)+oe);const _=(A=i.note)==null?void 0:A.trim();if(_){const q=s?f?10:12:f?2:3,et=f?28:34,tt=Math.min(q,Math.max(1,Math.ceil(_.length/et)));m+=tt*(f?15:16)+oe}const N=Fi(i.description,{full:s,max:s?64:6}),x=[],S=f?4:5;for(const q of N){const et=f?18:22,tt=s?Math.min(8,Math.max(1,Math.ceil(q.fullValue.length/et))):1,dt=f?14:15,ft=Qn+Math.max(0,tt-1)*dt;x.push({key:q.key,label:q.label,value:q.value,fullValue:q.fullValue,x:Al,y:m,w:v,h:ft}),m+=ft+S}return x}function E0(i,f,s=!1){var S,R;const{w:o}=Pi(i,f,new Set,{expanded:s}),m=[],v=(i.text||"未命名").trim();m.push({key:"__title",label:"标题",value:v,fullValue:v,x:28,y:4,w:o-32-Al,h:ea-8});let _=ea+Math.max(4,Ii-4);const N=o-Al*2;(S=i.imageUrl)!=null&&S.trim()&&(_+=(f?Oa.compact:Oa.comfortable)+oe);const x=(R=i.note)==null?void 0:R.trim();if(x){const A=s?f?10:12:f?2:3,q=f?28:34,dt=Math.min(A,Math.max(1,Math.ceil(x.length/q)))*(f?15:16);m.push({key:"__note",label:"摘要",value:x,fullValue:x,x:Al,y:_,w:N,h:dt})}return[...m,...z0(i,f,s)]}function A0(i,f,s,o,m,v,_,N){let x=o;const S=_?4:5;for(let R=0;R{i.fillText(O,s+Al,qt+V*it)}),i.restore();return}i.beginPath(),i.arc(s+16,o+ea/2,7,0,Math.PI*2),i.fillStyle=N,i.globalAlpha=.22,i.fill(),i.globalAlpha=1,i.beginPath(),i.arc(s+16,o+ea/2,4,0,Math.PI*2),i.fillStyle=N,i.fill(),i.fillStyle=m.labelPrimary,i.font=_e(_?13:14,600),i.textBaseline="middle";const tt=A-32-Al,dt=un(i,f.text||"未命名",tt,R?_?2:3:_?1:2);if(dt.length===1)i.fillText(dt[0],s+28,o+ea/2);else{const it=o+ea/2-(dt.length-1)*14/2;dt.forEach((qt,O)=>{i.fillText(qt,s+28,it+O*14)})}let ft=o+ea+Math.max(4,Ii-4);const G=A-Al*2,pt=(nl=f.imageUrl)==null?void 0:nl.trim();if(pt){const lt=_?Oa.compact:Oa.comfortable,it=go(pt,x);if(i.save(),i.beginPath(),Wi(i,s+Al,ft,G,lt,10),i.clip(),i.fillStyle=m.glassHeader,i.fillRect(s+Al,ft,G,lt),it&&it.naturalWidth>0){const qt=Math.max(G/it.naturalWidth,lt/it.naturalHeight),O=it.naturalWidth*qt,V=it.naturalHeight*qt;i.drawImage(it,s+Al+(G-O)/2,ft+(lt-V)/2,O,V)}else i.fillStyle=m.labelSecondary,i.font=_e(11,500),i.textBaseline="middle",i.fillText(g0(pt)?"配图失败":"加载中…",s+Al+10,ft+lt/2);i.restore(),ft+=lt+oe}const St=(ul=f.note)==null?void 0:ul.trim();if(St){i.fillStyle=m.labelSecondary,i.font=_e(_?11.5:12.5,400),i.textBaseline="top";const it=un(i,St,G,R?_?10:12:_?2:3),qt=_?15:16;for(let O=0;Os+A-Al-24)break;R&<>s+A-Al-24&&(lt=s+Al,ft+=Oh)}}i.restore()}const x0=1280,N0=.82;function O0(i){return new Promise((f,s)=>{const o=new FileReader;o.onload=()=>f(String(o.result||"")),o.onerror=()=>s(o.error||new Error("read failed")),o.readAsDataURL(i)})}function D0(i){return new Promise((f,s)=>{const o=new Image;o.onload=()=>f(o),o.onerror=()=>s(new Error("image decode failed")),o.src=i})}async function j0(i){const f=await O0(i),s=await D0(f),o=Math.min(1,x0/Math.max(s.width,s.height)),m=Math.max(1,Math.round(s.width*o)),v=Math.max(1,Math.round(s.height*o)),_=document.createElement("canvas");_.width=m,_.height=v;const N=_.getContext("2d");if(!N)throw new Error("canvas unavailable");N.drawImage(s,0,0,m,v);const x=i.type==="image/png"&&i.size<4e5&&o===1,S=x?"image/png":"image/jpeg";return{dataUrl:_.toDataURL(S,x?void 0:N0),mimeType:S}}async function C0(i){if(!i.type.startsWith("image/"))throw new Error("请选择图片文件");if(i.size>20*1024*1024)throw new Error("原图过大(请小于 20MB)");const{dataUrl:f,mimeType:s}=await j0(i),o=await fetch("/api/uploads",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataBase64:f,mimeType:s,filename:i.name})}),m=await o.json().catch(()=>({}));if(!o.ok||!m.ok||!m.url)throw new Error(m.message||`上传失败 (${o.status})`);return m.url}function Th(i){return i?Object.entries(i).map(([f,s],o)=>({id:`${f}-${o}`,key:n0(f),value:s==null?"":typeof s=="string"?s:typeof s=="number"||typeof s=="boolean"?String(s):Array.isArray(s)?s.map(String).join("、"):JSON.stringify(s)})):[]}function yo(i){const f={};for(const s of i){const o=a0(s.key);o&&(f[o]=s.value.trim())}return Object.keys(f).length?f:null}function jh({node:i,applyOps:f,accent:s,variant:o="overlay",onDragHandlePointerDown:m,showStylePreset:v}){const[_,N]=K.useState(()=>new Set),[x,S]=K.useState(!1);K.useEffect(()=>{N(new Set),S(!1)},[i.id]);const R=K.useMemo(()=>s0(i,_),[i,_]),A=K.useMemo(()=>R.filter(G=>G.def.id!=="text"&&G.def.id!=="description"),[R]),q=!U0(i)||_.has("description"),et=K.useMemo(()=>r0(i,_).filter(G=>G.id!=="description"),[i,_]),tt=(G,pt)=>{const St=h0(i,G,pt);St.length&&(f(St,`prop ${G}`),!pt.trim()&&G!=="text"&&N(P=>{const nt=new Set(P);return nt.delete(G),nt}))},dt=G=>{const pt=i.description??null;JSON.stringify(pt)!==JSON.stringify(G)&&(f([{type:"update_node_meta",nodeId:i.id,patch:{description:G}}],"prop description"),G||N(P=>{const nt=new Set(P);return nt.delete("description"),nt}))},ft=G=>y.jsx(H0,{def:G,node:i,onCommit:pt=>tt(G.id,pt),onClear:()=>{tt(G.id,""),N(pt=>{const St=new Set(pt);return St.delete(G.id),St})}},G.id);return y.jsxs("div",{className:`ns-editor${o==="panel"?" ns-editor--panel":""}`,style:s&&o==="overlay"?{"--ns-brand":s}:void 0,children:[y.jsxs("div",{className:"ns-editor__header","data-ns-drag-handle":!0,onPointerDown:m,children:[y.jsx("span",{className:"ns-editor__dot",style:s?{background:s}:void 0}),y.jsx("input",{className:"ns-editor__title",defaultValue:i.text,onPointerDown:G=>G.stopPropagation(),onBlur:G=>{G.target.value!==i.text&&tt("text",G.target.value)},onKeyDown:G=>{G.key==="Enter"&&G.target.blur()}},`title-${i.id}-${i.version}`)]}),y.jsxs("div",{className:"ns-editor__body",children:[v?y.jsxs("div",{className:"ns-row",children:[y.jsx("span",{className:"ns-row__label",children:"类型"}),y.jsx("div",{className:"ns-row__ctrl",children:y.jsxs("select",{value:i.stylePreset,onChange:G=>{f([{type:"set_style_preset",nodeId:i.id,stylePreset:G.target.value}],"style")},children:[y.jsx("option",{value:"default",children:"默认外形"}),y.jsx("option",{value:"title",children:"title"}),y.jsx("option",{value:"decision",children:"决策"}),y.jsx("option",{value:"risk",children:"风险"}),y.jsx("option",{value:"note",children:"便签"}),y.jsx("option",{value:"muted",children:"弱化"})]})}),y.jsx("span",{})]}):null,o==="panel"?y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"ns-row",children:[y.jsx("span",{className:"ns-row__label",children:"强调色"}),y.jsx("div",{className:"ns-row__ctrl",children:y.jsx("input",{type:"text",placeholder:"#e74c3c",defaultValue:i.accentColor??"",onBlur:G=>{const St=G.target.value.trim()||null;(i.accentColor??null)!==St&&f([{type:"update_node_meta",nodeId:i.id,patch:{accentColor:St}}])}},`ac-${i.id}-${i.version}`)}),y.jsx("span",{})]}),y.jsxs("div",{className:"ns-row",children:[y.jsx("span",{className:"ns-row__label",children:"图标"}),y.jsx("div",{className:"ns-row__ctrl",children:y.jsxs("select",{value:i.icon??"",onChange:G=>{const pt=G.target.value;f([{type:"update_node_meta",nodeId:i.id,patch:{icon:pt||null}}])},children:[y.jsx("option",{value:"",children:"无"}),y.jsx("option",{value:"router",children:"路由器"}),y.jsx("option",{value:"server",children:"🖥 服务器"}),y.jsx("option",{value:"database",children:"🗄 数据库"}),y.jsx("option",{value:"cloud",children:"☁ 云"}),y.jsx("option",{value:"person",children:"👤 人物"}),y.jsx("option",{value:"folder",children:"📁 文件夹"}),y.jsx("option",{value:"doc",children:"📄 文档"}),y.jsx("option",{value:"link",children:"🔗 链接"}),y.jsx("option",{value:"warning",children:"⚠ 警告"}),y.jsx("option",{value:"check",children:"✓ 完成"}),y.jsx("option",{value:"star",children:"★ 星标"}),y.jsx("option",{value:"gear",children:"⚙ 设置"}),y.jsx("option",{value:"globe",children:"🌐 全球"})]})}),y.jsx("span",{})]})]}):null,A.map(({def:G})=>ft(G)),q?y.jsx(R0,{nodeId:i.id,version:i.version,description:i.description,onCommit:dt}):y.jsx("button",{type:"button",className:"ns-kv__reveal",onClick:()=>N(G=>new Set(G).add("description")),children:"+ 添加属性列表"})]}),et.length>0?y.jsxs("div",{className:"ns-add",onPointerDown:G=>G.stopPropagation(),children:[x?y.jsx("div",{className:"ns-add__menu",children:et.map(G=>y.jsx("button",{type:"button",className:"ns-add__item",onClick:pt=>{pt.preventDefault(),pt.stopPropagation(),N(St=>new Set(St).add(G.id)),S(!1)},children:G.label},G.id))}):null,y.jsx("button",{type:"button",className:"ns-add__btn",onClick:G=>{G.preventDefault(),G.stopPropagation(),S(pt=>!pt)},children:"+ 添加字段"})]}):null]})}function U0(i){return!i.description||Object.keys(i.description).length===0}function R0({nodeId:i,version:f,description:s,onCommit:o}){const[m,v]=K.useState(()=>Th(s)),_=K.useRef(m);_.current=m,K.useEffect(()=>{v(Th(s))},[i,f,s]);const N=x=>{v(x),_.current=x,o(yo(x))};return y.jsxs("div",{className:"ns-kv",onPointerDown:x=>x.stopPropagation(),children:[y.jsx("div",{className:"ns-kv__title",children:"属性"}),y.jsx("ul",{className:"ns-kv__list",children:m.map(x=>y.jsxs("li",{className:"ns-kv__row",children:[y.jsx("input",{className:"ns-kv__key",value:x.key,placeholder:"名称","aria-label":"属性名",onChange:S=>{const R=S.target.value;v(A=>A.map(q=>q.id===x.id?{...q,key:R}:q))},onBlur:()=>o(yo(_.current))}),y.jsx("input",{className:"ns-kv__val",value:x.value,placeholder:"内容","aria-label":"属性值",onChange:S=>{const R=S.target.value;v(A=>A.map(q=>q.id===x.id?{...q,value:R}:q))},onBlur:()=>o(yo(_.current))}),y.jsx("button",{type:"button",className:"ns-kv__del",title:"删除",onClick:()=>N(_.current.filter(S=>S.id!==x.id)),children:"×"})]},x.id))}),y.jsx("button",{type:"button",className:"ns-kv__add",onClick:()=>{v(x=>[...x,{id:`new-${Date.now()}`,key:"",value:""}])},children:"+ 添加一项"})]})}function H0({def:i,node:f,onCommit:s,onClear:o}){const m=d0(f,i.id),v=!i.always,[_,N]=K.useState(!1),[x,S]=K.useState(null),R=K.useRef(null);return i.kind==="image"?y.jsxs("div",{className:"ns-row",children:[y.jsx("span",{className:"ns-row__label",children:i.label}),y.jsxs("div",{className:"ns-row__ctrl ns-row__ctrl--image",onPointerDown:A=>A.stopPropagation(),children:[m?y.jsx("img",{className:"ns-thumb",src:m,alt:""}):null,y.jsxs("div",{className:"ns-image-actions",children:[y.jsx("button",{type:"button",className:"ns-image-pick",disabled:_,onClick:()=>{var A;return(A=R.current)==null?void 0:A.click()},children:_?"上传中…":"选择文件"}),y.jsx("input",{ref:R,type:"file",accept:"image/jpeg,image/png,image/webp,image/gif",hidden:!0,onChange:A=>{var et;const q=(et=A.target.files)==null?void 0:et[0];A.target.value="",q&&(S(null),N(!0),C0(q).then(tt=>s(tt)).catch(tt=>S(String((tt==null?void 0:tt.message)||tt||"上传失败"))).finally(()=>N(!1)))}}),y.jsx("input",{className:"ns-image-url",defaultValue:m,placeholder:"或粘贴图片 URL",onBlur:A=>{const q=A.target.value.trim();q!==(m||"")&&s(q)},onKeyDown:A=>{A.key==="Enter"&&A.target.blur()}},`${i.id}-${f.id}-${f.version}`),v?y.jsx("button",{type:"button",className:"ns-row__clear",title:"清除",onClick:o,children:"×"}):null]}),x?y.jsx("div",{className:"ns-image-err",children:x}):null,y.jsx("div",{className:"ns-image-hint",children:"支持本地选图或粘贴 https://… 链接"})]})]}):y.jsxs("div",{className:"ns-row",children:[y.jsx("span",{className:"ns-row__label",children:i.label}),y.jsxs("div",{className:"ns-row__ctrl",onPointerDown:A=>A.stopPropagation(),children:[i.kind==="textarea"||i.kind==="links"?y.jsx("textarea",{defaultValue:m,rows:i.kind==="links"?3:2,placeholder:i.kind==="links"?"标题|url 每行一条":"",onBlur:A=>s(A.target.value)},`${i.id}-${f.id}-${f.version}`):i.kind==="datetime"?y.jsx("input",{type:"datetime-local",defaultValue:m,onBlur:A=>s(A.target.value)},`${i.id}-${f.id}-${f.version}`):i.kind==="flag"?y.jsx("button",{type:"button",onClick:()=>s(f.pinned?"0":"1"),children:f.pinned?"解钉":"钉住"}):y.jsx("input",{defaultValue:m,placeholder:i.kind==="tags"?"逗号分隔":"",onBlur:A=>s(A.target.value),onKeyDown:A=>{A.key==="Enter"&&A.target.blur()}},`${i.id}-${f.id}-${f.version}`),v?y.jsx("button",{type:"button",className:"ns-row__clear",title:"清除",onClick:o,children:"×"}):null]})]})}function w0({node:i,applyOps:f,screenX:s,screenY:o,zoom:m,accent:v,width:_,showStylePreset:N}){return y.jsx("div",{className:"ns-overlay",style:{left:s,top:o,width:_,transform:`translate(-50%, -50%) scale(${m})`},children:y.jsx(jh,{node:i,applyOps:f,accent:v,showStylePreset:N})})}const _h=i=>{let f;const s=new Set,o=(S,R)=>{const A=typeof S=="function"?S(f):S;if(!Object.is(A,f)){const q=f;f=R??(typeof A!="object"||A===null)?A:Object.assign({},f,A),s.forEach(et=>et(f,q))}},m=()=>f,N={setState:o,getState:m,getInitialState:()=>x,subscribe:S=>(s.add(S),()=>s.delete(S))},x=f=i(o,m,N);return N},B0=(i=>i?_h(i):_h),Y0=i=>i;function q0(i,f=Y0){const s=$i.useSyncExternalStore(i.subscribe,$i.useCallback(()=>f(i.getState()),[i,f]),$i.useCallback(()=>f(i.getInitialState()),[i,f]));return $i.useDebugValue(s),s}const zh=i=>{const f=B0(i),s=o=>q0(f,o);return Object.assign(s,f),s},X0=(i=>i?zh(i):zh);async function en(i,f){const s=await fetch(i,{...f,headers:{"Content-Type":"application/json",...(f==null?void 0:f.headers)??{}}}),o=await s.json();if(!s.ok)throw new Error(o.message??o.error??s.statusText);return o}function L0(i,f){const s={...i};for(const[o,m]of Object.entries(f))s[o]={...m};for(const o of Object.keys(s))o in f||delete s[o];return s}function Eh(i,f,s){const o={...f};for(const[m,v]of Object.entries(i))!s.has(m)&&o[m]&&(o[m]={...v});for(const m of s)f[m]?o[m]={...f[m]}:i[m]&&(o[m]={...i[m]});return o}const Ah=new Map,Ct=X0((i,f)=>({canvases:[],canvasId:null,canvas:null,nodes:[],edges:[],positions:{},selectedIds:[],selectedEdgeId:null,highlightIds:[],highlightEdgeIds:[],highlightStyle:null,fitViewport:null,leftCollapsed:!1,themeId:localStorage.getItem("mind-map:theme")??"abyss",lastChangeSetId:null,trash:[],loadCanvases:async()=>{const s=await en("/api/canvases");i({canvases:s.canvases}),!f().canvasId&&s.canvases[0]&&await f().openCanvas(s.canvases[0].id)},openCanvas:async s=>{const o=await en(`/api/canvases/${s}`);i({canvasId:s,canvas:o.canvas,nodes:o.nodes,edges:o.edges,positions:o.positions,selectedIds:[],selectedEdgeId:null,themeId:o.canvas.prefs.themeId??f().themeId}),await f().loadTrash()},createCanvas:async s=>{const o=await en("/api/canvases",{method:"POST",body:JSON.stringify({title:s})});await f().loadCanvases(),i({canvasId:o.canvas.id,canvas:o.canvas,nodes:o.nodes,edges:o.edges,positions:o.positions,selectedIds:[]})},patchLocal:s=>{i(o=>({nodes:s.nodes??o.nodes,edges:s.edges??o.edges,positions:s.positions??o.positions,canvas:s.canvas??o.canvas}))},requestFitViewport:s=>i({fitViewport:s}),consumeFitViewport:()=>{const s=f().fitViewport;return s&&i({fitViewport:null}),s},applyOps:async(s,o)=>{const m=f().canvasId;if(!m)return;const v=s.some(q=>q.type==="delete_node"||q.type==="restore_node"),_=s.some(q=>q.type==="set_prefs"||q.type==="update_text"),N=s.length>0&&s.every(q=>q.type==="set_pinned"),x=new Set(s.filter(q=>q.type==="set_pinned"&&q.pinned===!0).map(q=>q.nodeId)),S={...f().positions},R=await en(`/api/canvases/${m}/ops`,{method:"POST",body:JSON.stringify({ops:s,origin:"user",summary:o})}),A=N&&x.size>0?Eh(S,R.positions,x):L0(S,R.positions);i({canvas:R.canvas,nodes:R.nodes,edges:R.edges,positions:A,lastChangeSetId:R.changeSetId,themeId:R.canvas.prefs.themeId,...R.fitViewport?{fitViewport:R.fitViewport}:{}}),N&&x.size>0&&Ah.set(m,{positions:{...A},pinnedIds:[...x],until:Date.now()+2e3}),_&&f().loadCanvases(),v&&f().loadTrash()},applyCanvasPayload:(s,o)=>{const m=s.canvas.id,v=Ah.get(m),_=f().positions;let N=s.positions;if(o!=null&&o.preserveUnpinned||v&&v.until>Date.now()){const x=new Set((v==null?void 0:v.pinnedIds)??s.nodes.filter(S=>S.pinned&&S.pos).map(S=>S.id));N=Eh((v==null?void 0:v.positions)??_,s.positions,x)}i({canvasId:m,canvas:s.canvas,nodes:s.nodes,edges:s.edges,positions:N,themeId:s.canvas.prefs.themeId??f().themeId})},undo:async()=>{const s=f().canvasId,o=f().lastChangeSetId;if(!s||!o)return;const m=await en(`/api/canvases/${s}/undo`,{method:"POST",body:JSON.stringify({changeSetId:o})});await f().openCanvas(s),i({lastChangeSetId:m.changeSetId})},setSelection:s=>i({selectedIds:s,selectedEdgeId:null}),setSelectedEdge:s=>i({selectedEdgeId:s,selectedIds:s?[]:f().selectedIds}),flashHighlight:s=>{const o=Array.isArray(s)?{nodeIds:s}:s,m=o.nodeIds??[],v=o.edgeIds??[],_=o.style??null,N=Math.max(500,Math.min(6e4,o.ttlMs??2200));i({highlightIds:m,highlightEdgeIds:v,highlightStyle:_,selectedIds:m.length?m:f().selectedIds,selectedEdgeId:v.length===1?v[0]:f().selectedEdgeId}),window.setTimeout(()=>{const x=Ct.getState();x.highlightIds.length===m.length&&x.highlightIds.every((S,R)=>S===m[R])&&x.highlightEdgeIds.length===v.length&&x.highlightEdgeIds.every((S,R)=>S===v[R])&&i({highlightIds:[],highlightEdgeIds:[],highlightStyle:null})},N)},setThemeId:s=>{localStorage.setItem("mind-map:theme",s),i({themeId:s})},setCollapsedPanels:(s,o)=>{s==="left"&&i({leftCollapsed:o})},setPrefs:async s=>{await f().applyOps([{type:"set_prefs",prefs:s}],"update prefs")},setStylePreset:async(s,o)=>{await f().applyOps([{type:"set_style_preset",nodeId:s,stylePreset:o}],"style")},loadTrash:async()=>{const s=f().canvasId;if(!s)return;const o=await en(`/api/canvases/${s}/trash`);i({trash:o.nodes})},restoreFromTrash:async s=>{const o=f().canvasId;o&&(await en(`/api/canvases/${o}/trash/${s}/restore`,{method:"POST"}),await f().openCanvas(o),await f().loadTrash())}}));function G0(){const i=Ct(S=>S.canvas),f=Ct(S=>S.nodes),s=Ct(S=>S.edges),o=Ct(S=>S.selectedIds),m=Ct(S=>S.selectedEdgeId),v=Ct(S=>S.applyOps),_=(i==null?void 0:i.prefs.inspectorMode)??"selection",N=K.useMemo(()=>o[0]?f.find(S=>S.id===o[0]):void 0,[f,o]),x=K.useMemo(()=>m?s.find(S=>S.id===m):void 0,[s,m]);return _==="selection"&&!N&&!x?y.jsx("div",{className:"inspector muted",children:"选中节点或边以编辑属性"}):x&&!N?y.jsx(Q0,{edge:x,applyOps:v}):N?y.jsx(V0,{node:N,applyOps:v}):y.jsx("div",{className:"inspector muted",children:"选中节点或边以编辑属性"})}function V0({node:i,applyOps:f}){return y.jsxs("div",{className:"inspector",children:[y.jsx("div",{className:"inspector__title",children:"节点属性"}),y.jsx(jh,{node:i,applyOps:f,variant:"panel",showStylePreset:!0}),y.jsx("div",{className:"inspector__row",style:{marginTop:8},children:y.jsx("button",{type:"button",onClick:()=>void f([{type:"set_collapsed",nodeId:i.id,collapsed:!i.collapsed}]),children:i.collapsed?"展开":"折叠"})})]})}function Q0({edge:i,applyOps:f}){var m;const[s,o]=K.useState(((m=i.tags)==null?void 0:m.join(", "))??"");return K.useEffect(()=>{var v;o(((v=i.tags)==null?void 0:v.join(", "))??"")},[i.id,i.version,i.tags]),y.jsxs("div",{className:"inspector",children:[y.jsx("div",{className:"inspector__title",children:"边属性"}),y.jsxs("label",{className:"inspector__field",children:[y.jsx("span",{children:"标签"}),y.jsx("input",{defaultValue:i.label??"",onBlur:v=>{f([{type:"update_edge_meta",edgeId:i.id,patch:{label:v.target.value||null}}])}},`el-${i.id}-${i.version}`)]}),y.jsxs("label",{className:"inspector__field",children:[y.jsx("span",{children:"备注"}),y.jsx("textarea",{defaultValue:i.note??"",rows:2,onBlur:v=>{f([{type:"update_edge_meta",edgeId:i.id,patch:{note:v.target.value||null}}])}},`en-${i.id}-${i.version}`)]}),y.jsxs("label",{className:"inspector__field",children:[y.jsx("span",{children:"线粗 (1-5)"}),y.jsx("input",{type:"number",min:1,max:5,defaultValue:i.weight??1,onBlur:v=>{const _=Number(v.target.value),N=Number.isFinite(_)?Math.max(1,Math.min(5,Math.round(_))):null;f([{type:"update_edge_meta",edgeId:i.id,patch:{weight:N}}])}},`ew-${i.id}-${i.version}`)]}),y.jsxs("label",{className:"inspector__field",children:[y.jsx("span",{children:"线型"}),y.jsxs("select",{defaultValue:i.lineStyle??(i.kind==="relation"?"dashed":"solid"),onChange:v=>{const _=v.target.value;f([{type:"update_edge_meta",edgeId:i.id,patch:{lineStyle:_}}])},children:[y.jsx("option",{value:"solid",children:"实线"}),y.jsx("option",{value:"dashed",children:"虚线"}),y.jsx("option",{value:"dotted",children:"点线"})]},`es-${i.id}-${i.version}`)]}),y.jsxs("label",{className:"inspector__field",children:[y.jsx("span",{children:"箭头"}),y.jsxs("select",{defaultValue:i.direction??(i.kind==="relation"?"forward":"none"),onChange:v=>{const _=v.target.value;f([{type:"update_edge_meta",edgeId:i.id,patch:{direction:_}}])},children:[y.jsx("option",{value:"forward",children:"单向 →"}),y.jsx("option",{value:"both",children:"双向 ↔"}),y.jsx("option",{value:"none",children:"无箭头"})]},`ed-${i.id}-${i.version}`)]}),y.jsxs("label",{className:"inspector__field",children:[y.jsx("span",{children:"标签(逗号分隔)"}),y.jsx("input",{value:s,onChange:v=>o(v.target.value),onBlur:()=>{const v=s.split(/[,,]/).map(_=>_.trim()).filter(Boolean);f([{type:"update_edge_meta",edgeId:i.id,patch:{tags:v}}])}})]}),y.jsxs("div",{className:"muted",style:{fontSize:11},children:[i.kind," · ",i.from.slice(0,8)," → ",i.to.slice(0,8)]})]})}const Ch={bgBase:"#101014",bgLayer1:"#1b1e28",labelPrimary:"#f4f5f7",labelSecondary:"#a5adb8",brand:"#5e6ad2",border:"rgba(255,255,255,0.08)",bubble:"rgba(37,42,58,0.9)",warn:"#f59e5b",error:"#ef4444",glassFill:"rgba(45, 52, 68, 0.96)",glassBorder:"rgba(255, 255, 255, 0.22)",glassHighlight:"rgba(255, 255, 255, 0.06)",glassHeader:"rgba(255, 255, 255, 0.05)"},Z0={bgBase:"#f4f5f7",bgLayer1:"#ffffff",labelPrimary:"#1f2329",labelSecondary:"#646a73",brand:"#5e6ad2",border:"rgba(0,0,0,0.08)",bubble:"rgba(255,255,255,0.92)",warn:"#d97706",error:"#dc2626",glassFill:"rgba(255, 255, 255, 0.96)",glassBorder:"rgba(0, 0, 0, 0.12)",glassHighlight:"rgba(255, 255, 255, 0.4)",glassHeader:"rgba(0, 0, 0, 0.03)"};function K0(){try{const i=document.documentElement.dataset.colorScheme;if(i==="light"||i==="dark")return i;if(matchMedia("(prefers-color-scheme: light)").matches)return"light"}catch{}return"dark"}const J0=Ch,Uh=[{key:"bgBase",css:"--dsw-alias-bg-base"},{key:"bgLayer1",css:"--dsw-alias-bg-layer-1"},{key:"labelPrimary",css:"--dsw-alias-label-primary"},{key:"labelSecondary",css:"--dsw-alias-label-secondary"},{key:"brand",css:"--dsw-alias-brand-primary"},{key:"border",css:"--dsw-alias-border-l1"},{key:"bubble",css:"--dsw-specific-bubble"},{key:"warn",css:"--dsw-alias-state-warn-primary"},{key:"error",css:"--dsw-alias-state-error-primary"}];function k0(i){try{return getComputedStyle(document.documentElement).getPropertyValue(i).trim()}catch{return""}}function $0(i=window.location.search){const f=new URLSearchParams(i),s=document.documentElement;for(const{key:m,css:v}of Uh){const _=f.get(`t_${m}`);_&&s.style.setProperty(v,decodeURIComponent(_))}const o=f.get("colorScheme");(o==="light"||o==="dark")&&(s.dataset.colorScheme=o)}function W0(){const f=K0()==="light"?Z0:Ch,s={...f};for(const{key:o,css:m}of Uh){const v=k0(m);v&&(s[o]=v)}return s.glassFill=f.glassFill,s.glassBorder=f.glassBorder,s.glassHighlight=f.glassHighlight,s.glassHeader=f.glassHeader,s}function F0(i,f=8){const s=i.startsWith("#")?i:J0.brand,o=/^#?([0-9a-f]{6})$/i.exec(s.trim()),m=o?parseInt(o[1],16):6187730,v=m>>16&255,_=m>>8&255,N=m&255,x=Math.max(v,_,N)/255,S=Math.min(v,_,N)/255,R=(x+S)/2;let A=0,q=0;if(x!==S){const tt=x-S;q=R>.5?tt/(2-x-S):tt/(x+S);const dt=v/255,ft=_/255,G=N/255;switch(x){case dt:A=((ft-G)/tt+(ft{const _=(v+i/30)%12,N=s-o*Math.max(Math.min(_-3,9-_,1),-1);return Math.round(255*N).toString(16).padStart(2,"0")};return`#${m(0)}${m(8)}${m(4)}`}function po(i,f){const s=new Map;for(const _ of f){if(_.deletedAt||_.kind!=="hierarchy"||!_.isPrimaryParent)continue;const N=s.get(_.from)??[];N.push(_.to),s.set(_.from,N)}const o=[i],m=new Set([i]),v=[i];for(;v.length;){const _=v.shift();for(const N of s.get(_)??[])m.has(N)||(m.add(N),o.push(N),v.push(N))}return o}function Mh(i,f,s){return po(f,s).includes(i)}function P0(i,f,s){if(f)return s&&s.ids.includes(i)?{x:f.x+s.dx,y:f.y+s.dy}:f}function tv({node:i,x:f,y:s}){var _;const o=(i.tags??[]).slice(0,4),m=(i.note??"").trim(),v=((_=i.links)==null?void 0:_.length)??0;return y.jsxs("div",{className:"hover-card",style:{left:f,top:s},children:[y.jsx("div",{className:"hover-card__title",children:i.text}),m?y.jsx("div",{className:"hover-card__note",children:m.slice(0,120)}):null,o.length?y.jsx("div",{className:"hover-card__tags",children:o.map(N=>y.jsx("span",{className:"hover-card__tag",children:N},N))}):null,y.jsxs("div",{className:"hover-card__meta",children:[v?`${v} 链接`:null,i.dueAt!=null?`${v?" · ":""}截止 ${new Date(i.dueAt).toLocaleDateString()}`:null,i.stylePreset!=="default"?`${v||i.dueAt?" · ":""}${i.stylePreset}`:null]})]})}function lv({label:i,value:f,x:s,y:o}){return y.jsxs("div",{className:"prop-tooltip",style:{left:s,top:o},role:"tooltip",children:[y.jsx("div",{className:"prop-tooltip__label",children:i}),y.jsx("div",{className:"prop-tooltip__value",children:f})]})}function Rh(i,f){const s=URL.createObjectURL(i),o=document.createElement("a");o.href=s,o.download=f,o.click(),window.setTimeout(()=>URL.revokeObjectURL(s),2e3)}function ev(i,f,s){Rh(new Blob([i],{type:s}),f)}function av(i,f){return new Promise((s,o)=>{i.toBlob(m=>{if(!m){o(new Error("png_encode_failed"));return}Rh(m,f),s()},"image/png")})}async function nv(i){i.fitView(),await new Promise(f=>requestAnimationFrame(()=>requestAnimationFrame(()=>f()))),await new Promise(f=>setTimeout(f,40)),await av(i.canvas,i.filename)}async function uv(i,f){const s=await fetch(`/api/canvases/${encodeURIComponent(i)}/export.svg`);if(!s.ok)throw new Error(`svg_export_${s.status}`);const o=await s.text();ev(o,f,"image/svg+xml;charset=utf-8")}const iv={unnamed:"未命名",newNode:"新节点",leftChild:"左侧子主题",rightChild:"右侧子主题",sibling:"兄弟节点",relationLabel:"关联",toolbarAria:"画布工具",controlsAria:"视图控制",backRosterTitle:"返回画布列表",backRoster:"返回",toolSelect:"选择",toolPan:"平移",toolLink:"连线",dragNode:"单点",dragBranch:"整枝",dragNodeTitle:"单点拖拽:只移动当前节点 (N);按住 Shift 也可临时单点",dragBranchTitle:"整枝拖拽:节点与子孙一起移动 (B)",bubble:"气泡",card:"卡片",topology:"拓扑",bubbleTitle:"气泡视图:精简标题",cardTitle:"卡片视图:单击展开全文 · 悬停属性看详情 · 双击编辑",topologyTitle:"拓扑视图:路由器图标 + 链路",unpin:"解钉",unpinTitle:"取消钉住:让选中节点重新参与自动布局",undo:"撤销",fullscreen:"全屏",exitFullscreen:"退出全屏",zoomIn:"放大",zoomInTitle:"放大 (+)",zoomOut:"缩小",zoomOutTitle:"缩小 (-)",fit:"适应画布",fitTitle:"适应画布 (F)",lock:"锁定",unlock:"解锁",lockTitle:"锁定画布 (L)",unlockTitle:"解锁画布 (L)",addLeftChildTitle:"添加左侧子主题",addRightChildTitle:"添加右侧子主题",hintLocked:"已锁定 · 仅浏览/缩放/平移",hintNodeDrag:"单点拖 · 只移动当前节点 · Shift 临时单点 · Esc 取消",hintBranchDrag:"整枝拖 · 空白钉住 · 落到节点换父 · N 单点 · Esc 取消",exportPng:"PNG",exportPngTitle:"导出 PNG(先适应画布再截取)",exportSvg:"SVG",exportSvgTitle:"导出 SVG 矢量图"},cv={unnamed:"Untitled",newNode:"New node",leftChild:"Left child",rightChild:"Right child",sibling:"Sibling",relationLabel:"Link",toolbarAria:"Canvas tools",controlsAria:"View controls",backRosterTitle:"Back to canvas list",backRoster:"Back",toolSelect:"Select",toolPan:"Pan",toolLink:"Link",dragNode:"Node",dragBranch:"Branch",dragNodeTitle:"Move node only (N); hold Shift for temporary node-drag",dragBranchTitle:"Move node with descendants (B)",bubble:"Bubble",card:"Card",topology:"Topology",bubbleTitle:"Bubble view: title only",cardTitle:"Card view: click expand · hover props · double-click edit",topologyTitle:"Topology view: router icons + links",unpin:"Unpin",unpinTitle:"Unpin selected node for auto layout",undo:"Undo",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",zoomIn:"Zoom in",zoomInTitle:"Zoom in (+)",zoomOut:"Zoom out",zoomOutTitle:"Zoom out (-)",fit:"Fit",fitTitle:"Fit view (F)",lock:"Lock",unlock:"Unlock",lockTitle:"Lock canvas (L)",unlockTitle:"Unlock canvas (L)",addLeftChildTitle:"Add left child",addRightChildTitle:"Add right child",hintLocked:"Locked · browse / zoom / pan only",hintNodeDrag:"Node drag · Shift temp node · Esc cancel",hintBranchDrag:"Branch drag · pin on blank · drop to reparent · N node · Esc cancel",exportPng:"PNG",exportPngTitle:"Export PNG (fit view, then capture)",exportSvg:"SVG",exportSvgTitle:"Export SVG vector"},fv={zh:iv,en:cv};function wu(i){const f=String(i??"").trim().toLowerCase();return f.startsWith("zh")?"zh":f?"en":typeof navigator<"u"&&String(navigator.language||"").toLowerCase().startsWith("zh")?"zh":"en"}function ov(i){const f=wu(i);return fv[f]}const sv="dsh-mind-map:locale";function Hh(){try{const i=new URLSearchParams(window.location.search),f=i.get("lang")||i.get("locale");return f?wu(f):null}catch{return null}}function wh(){var i;try{const f=(i=document.documentElement)==null?void 0:i.lang;return f?wu(f):null}catch{return null}}function rv(){return Hh()||wh()||wu(navigator.language)}function dv(){const[i,f]=K.useState(rv);K.useEffect(()=>{const o=N=>{const x=wu(N);f(S=>S===x?S:x)},m=N=>{const x=N==null?void 0:N.data;!x||typeof x!="object"||x.type===sv&&o(x.lang??x.locale)};window.addEventListener("message",m);const v=new MutationObserver(()=>{const N=wh();N&&o(N)});v.observe(document.documentElement,{attributes:!0,attributeFilter:["lang"]});const _=Hh();return _&&o(_),()=>{window.removeEventListener("message",m),v.disconnect()}},[]);const s=K.useMemo(()=>ov(i),[i]);return{locale:i,U:s}}const hv=200,an=168,nn=118;function xh(){var sn;const{U:i}=dv(),f=K.useRef(null),s=K.useRef(null),o=K.useRef(null),m=Ct(g=>g.nodes),v=Ct(g=>g.edges),_=Ct(g=>g.positions),N=Ct(g=>g.selectedIds),x=Ct(g=>g.highlightIds),S=Ct(g=>g.highlightEdgeIds),R=Ct(g=>g.highlightStyle),A=Ct(g=>g.canvas),q=Ct(g=>g.canvasId),et=Ct(g=>g.applyOps),tt=Ct(g=>g.setPrefs),dt=Ct(g=>g.patchLocal),ft=Ct(g=>g.setSelection),G=Ct(g=>g.undo),pt=Ct(g=>g.lastChangeSetId),St=typeof window<"u"&&(()=>{try{const g=new URLSearchParams(window.location.search);return g.get("embed")==="1"||g.get("embed")==="true"}catch{return!1}})(),P=K.useCallback(()=>{var g;try{(g=window.parent)==null||g.postMessage({type:"dsh-mind-map:back"},"*")}catch{}},[]),nt=K.useCallback(async()=>{var d;const g=o.current;if(g)try{if(document.fullscreenElement){await document.exitFullscreen();return}await g.requestFullscreen()}catch{try{(d=window.parent)==null||d.postMessage({type:"dsh-mind-map:fullscreen"},"*")}catch{}}},[]);K.useEffect(()=>{const g=()=>V(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",g),()=>document.removeEventListener("fullscreenchange",g)},[]);const[H,W]=K.useState({x:0,y:0,zoom:1}),nl=Ct(g=>g.fitViewport),ul=Ct(g=>g.consumeFitViewport);K.useEffect(()=>{if(!nl)return;const g=ul();g&&W(g)},[nl,ul]);const[vl,rl]=K.useState("select"),[Lt,lt]=K.useState("node"),[it,qt]=K.useState(!1),[O,V]=K.useState(!1),[ot,Gt]=K.useState(0),[Qt,b]=K.useState(0),[C,Q]=K.useState(null),[k,st]=K.useState(null),[ht,Dt]=K.useState(null),[tl,Pt]=K.useState(null),[te,se]=K.useState(null),[Oe,Da]=K.useState(null),[Ml,we]=K.useState(null),[cn,ja]=K.useState(null),[fn,Be]=K.useState(!1),[Dl,Zn]=K.useState({w:1,h:1}),[tc,Ca]=K.useState(null),Z=K.useRef({mode:"none",lastX:0,lastY:0,space:!1,nodeId:null,startX:0,startY:0,moved:!1,alt:!1,forcePin:!1,startWorldX:0,startWorldY:0,subtreeIds:[]}),Bu=K.useRef(null);Bu.current=Ml;const Ua=K.useRef(!1),Tt=K.useMemo(()=>W0(),[ot]),aa=K.useMemo(()=>F0(Tt.brand,8),[Tt.brand]);K.useEffect(()=>{var Y;const g=()=>Gt(X=>X+1),d=window.matchMedia("(prefers-color-scheme: light)");return(Y=d.addEventListener)==null||Y.call(d,"change",g),()=>{var X;return(X=d.removeEventListener)==null?void 0:X.call(d,"change",g)}},[]);const il=(A==null?void 0:A.prefs.density)==="compact",Kl=(A==null?void 0:A.prefs.nodeViewMode)??"card",dl=Kl==="card",Ul=Kl==="topology",jl=K.useCallback(g=>b0(g,il,{asCard:dl,asTopology:Ul,expanded:dl&&ht===g.id}),[il,dl,Ul,ht]),Rl=il?160:hv,Ll=K.useCallback(g=>!Ul||g.type!=="create_node"||g.icon!=null?g:{...g,icon:"router"},[Ul]),Gl=(A==null?void 0:A.prefs.branchColoring)!==!1,na=K.useMemo(()=>{const g=new Map;if(!Gl)return g;const d=m.filter(F=>F.deletedAt?!1:!v.some(L=>L.kind==="hierarchy"&&L.isPrimaryParent&&L.to===F.id));let Y=0;for(const F of d)g.set(F.id,aa[Y%aa.length]),Y++;const X=(F,L)=>{for(const J of v)J.kind==="hierarchy"&&J.isPrimaryParent&&J.from===F&&(g.set(J.to,L),X(J.to,L))};for(const[F,L]of g)X(F,L);return g},[m,v,aa,Gl]),Ra=K.useCallback((g,d)=>{const X=o.current.getBoundingClientRect();return{x:(g-X.left-X.width/2-H.x)/H.zoom,y:(d-X.top-X.height/2-H.y)/H.zoom}},[H]),Ql=K.useCallback(g=>P0(g,_[g],Ml),[_,Ml]),ze=K.useCallback((g,d,Y)=>{for(let X=m.length-1;X>=0;X--){const F=m[X];if(F.deletedAt||Y!=null&&Y.has(F.id))continue;const L=Ql(F.id);if(!L)continue;const{w:J,h:rt}=jl(F);if(g>=L.x-J/2&&g<=L.x+J/2&&d>=L.y-rt/2&&d<=L.y+rt/2)return F.id}return null},[m,Ql,il]),Ee=K.useMemo(()=>{let g=0,d=0,Y=0,X=0,F=!1;for(const J of m){if(J.deletedAt)continue;const rt=_[J.id];rt&&(F?(g=Math.min(g,rt.x),d=Math.max(d,rt.x),Y=Math.min(Y,rt.y),X=Math.max(X,rt.y)):(g=rt.x,d=rt.x,Y=rt.y,X=rt.y,F=!0))}if(!F)return{minX:-200,maxX:200,minY:-120,maxY:120};const L=80;return{minX:g-L,maxX:d+L,minY:Y-L,maxY:X+L}},[m,_]),De=K.useCallback(g=>{W(d=>({...d,zoom:Math.min(4,Math.max(.02,g))}))},[]),re=K.useCallback(()=>{const{minX:g,maxX:d,minY:Y,maxY:X}=Ee,F=Math.max(40,d-g),L=Math.max(40,X-Y),J=Dl.w||1,rt=Dl.h||1,Rt=Math.min(2.5,Math.max(.12,Math.min(J*.86/F,rt*.86/L))),zt=(g+d)/2,Ut=(Y+X)/2;W({x:-zt*Rt,y:-Ut*Rt,zoom:Rt})},[Ee,Dl]),Ha=K.useCallback((g,d)=>{const Y=s.current;if(!Y)return;const X=Y.getBoundingClientRect(),{minX:F,maxX:L,minY:J,maxY:rt}=Ee,Rt=Math.max(1,L-F),zt=Math.max(1,rt-J),Ut=F+(g-X.left)/X.width*Rt,bt=J+(d-X.top)/X.height*zt;W(B=>({...B,x:-Ut*B.zoom,y:-bt*B.zoom}))},[Ee]),je=K.useCallback(()=>{var bt;const g=f.current;if(!g)return;const d=g.getContext("2d");if(!d)return;const Y=window.devicePixelRatio||1;d.setTransform(Y,0,0,Y,0,0);const X=g.clientWidth,F=g.clientHeight;d.clearRect(0,0,X,F),d.fillStyle=Tt.bgBase,d.fillRect(0,0,X,F),d.save(),d.translate(X/2+H.x,F/2+H.y),d.scale(H.zoom,H.zoom),d.strokeStyle=Tt.border,d.lineWidth=1/H.zoom;const L=48,J=Math.floor((-X/2-H.x)/H.zoom/L)*L-L*2,rt=Math.ceil((X/2-H.x)/H.zoom/L)*L+L*2,Rt=Math.floor((-F/2-H.y)/H.zoom/L)*L-L*2,zt=Math.ceil((F/2-H.y)/H.zoom/L)*L+L*2;d.globalAlpha=.35,d.beginPath();for(let B=J;B<=rt;B+=L)d.moveTo(B,Rt),d.lineTo(B,zt);for(let B=Rt;B<=zt;B+=L)d.moveTo(J,B),d.lineTo(rt,B);d.stroke(),d.globalAlpha=1;for(const B of v){if((A==null?void 0:A.prefs.showRelationEdges)===!1&&B.kind==="relation")continue;const xt=Ql(B.from),ut=Ql(B.to);if(!xt||!ut)continue;const Ht=m.find(Kt=>Kt.id===B.from),Vt=m.find(Kt=>Kt.id===B.to),Zt=Ht?jl(Ht).w:Rl,gl=Vt?jl(Vt).w:Rl,ol=Ht?jl(Ht).h:40,Sl=Vt?jl(Vt).h:40;d.beginPath();let Et,wt,mt,ll,Hl;if(Ul){const Kt=il?Na.compact:Na.comfortable,_t=il?4:6;Et=xt.x,wt=xt.y-ol/2+_t+Kt/2,mt=ut.x,ll=ut.y-Sl/2+_t+Kt/2,Hl=(Et+mt)/2,d.moveTo(Et,wt),d.lineTo(mt,ll)}else Et=xt.x+(ut.x>=xt.x?Zt/2:-Zt/2),wt=xt.y,mt=ut.x+(ut.x>=xt.x?-gl/2:gl/2),ll=ut.y,Hl=(Et+mt)/2,d.moveTo(Et,wt),d.bezierCurveTo(Hl,wt,Hl,ll,mt,ll);const de=Math.max(1,Math.min(5,B.weight??1)),Ae=Ul?B.lineStyle??"solid":B.lineStyle??(B.kind==="relation"?"dashed":"solid");Ae==="dotted"?d.setLineDash([2/H.zoom,4/H.zoom]):Ae==="dashed"?d.setLineDash([6/H.zoom,4/H.zoom]):d.setLineDash([]);const sl=S.includes(B.id),xl=(R==null?void 0:R.edgeColor)??Tt.brand,cl=(R==null?void 0:R.edgeWidth)??3.6,Jl=sl?xl:Ul?"#2563eb":B.kind==="relation"?Tt.labelSecondary:na.get(B.to)??Tt.brand;d.strokeStyle=Jl,d.lineWidth=(sl?cl:Ul?1.8+(de-1)*.5:1.2+(de-1)*.7)/H.zoom,d.stroke(),d.setLineDash([]);const he=B.direction??(Ul?"none":B.kind==="relation"?"forward":"none");if(he==="forward"||he==="both"){const Kt=Ul?Math.atan2(ll-wt,mt-Et):Math.atan2(0,mt-Hl||(mt>=xt.x?1:-1)),_t=8/H.zoom;d.beginPath(),d.fillStyle=Jl,d.moveTo(mt,ll),d.lineTo(mt-_t*Math.cos(Kt-.45),ll-_t*Math.sin(Kt-.45)),d.lineTo(mt-_t*Math.cos(Kt+.45),ll-_t*Math.sin(Kt+.45)),d.closePath(),d.fill()}if(he==="both"){const Kt=Ul?Math.atan2(wt-ll,Et-mt):Math.atan2(0,Et-Hl||(xt.x>=ut.x?1:-1)),_t=8/H.zoom;d.beginPath(),d.fillStyle=Jl,d.moveTo(Et,wt),d.lineTo(Et-_t*Math.cos(Kt-.45),wt-_t*Math.sin(Kt-.45)),d.lineTo(Et-_t*Math.cos(Kt+.45),wt-_t*Math.sin(Kt+.45)),d.closePath(),d.fill()}B.label&&H.zoom>=.25&&(d.fillStyle=Tt.labelSecondary,d.font="11px sans-serif",d.fillText(B.label,Hl,(wt+ll)/2-6))}if(Oe){const B=Ql(Oe.fromId);if(B){const xt=m.find(Zt=>Zt.id===Oe.fromId),ut=xt?jl(xt).h:40;let Ht=B.x,Vt=B.y;if(Ul){const Zt=il?Na.compact:Na.comfortable,gl=il?4:6;Vt=B.y-ut/2+gl+Zt/2}d.beginPath(),d.setLineDash([4/H.zoom,4/H.zoom]),d.strokeStyle=Ul?"#2563eb":Tt.brand,d.moveTo(Ht,Vt),d.lineTo(Oe.x,Oe.y),d.stroke(),d.setLineDash([])}}const Ut=(A==null?void 0:A.prefs.nodeBadges)??"icons";for(const B of m){if(B.deletedAt)continue;const xt=Ql(B.id);if(!xt)continue;const ut=!!(Ml!=null&&Ml.ids.includes(B.id)),{w:Ht,h:Vt}=jl(B),Zt=xt.x-Ht/2,gl=xt.y-Vt/2,ol=B.accentColor??na.get(B.id)??Tt.bubble,Sl=N.includes(B.id),Et=x.includes(B.id),wt=(R==null?void 0:R.nodeColor)??Tt.brand,mt=k===B.id,ll=cn===B.id,Hl=fn&≪if(ut&&(d.globalAlpha=.7),Ul){const sl=il?Na.compact:Na.comfortable,xl=il?4:6,cl=Zt+(Ht-sl)/2,Nl=gl+xl;Et&&(R==null?void 0:R.nodeGlow)!==!1?(d.shadowColor=wt,d.shadowBlur=14/H.zoom):(Sl||mt)&&(d.shadowColor=ol,d.shadowBlur=10/H.zoom);const Jl=go(p0,()=>b(_t=>_t+1));if(Jl&&Jl.naturalWidth>0?d.drawImage(Jl,cl,Nl,sl,sl):(d.fillStyle=ol,d.beginPath(),(bt=d.roundRect)==null||bt.call(d,cl,Nl,sl,sl,6),d.roundRect||d.rect(cl,Nl,sl,sl),d.fill()),mo(d),Sl||mt||ll||Et){d.strokeStyle=Hl?Tt.warn:ll||Et?Tt.brand:ol,d.lineWidth=1.6/H.zoom,d.beginPath();const _t=6;d.moveTo(cl+_t,Nl),d.arcTo(cl+sl,Nl,cl+sl,Nl+sl,_t),d.arcTo(cl+sl,Nl+sl,cl,Nl+sl,_t),d.arcTo(cl,Nl+sl,cl,Nl,_t),d.arcTo(cl,Nl,cl+sl,Nl,_t),d.closePath(),d.stroke()}d.fillStyle=Tt.labelPrimary,d.font=_e(il?11:12,600),d.textAlign="center",d.textBaseline="top";const he=Nl+sl+4;un(d,B.text||i.unnamed,Ht-4,il?1:2).forEach((_t,wa)=>{d.fillText(_t,Zt+Ht/2,he+wa*(il?13:14))}),d.textAlign="left",d.globalAlpha=ut?.7:1;continue}Et&&(R==null?void 0:R.nodeGlow)!==!1?(d.shadowColor=wt,d.shadowBlur=14/H.zoom):dl?ph(d,H.zoom,{selected:Sl,weight:"heavy"}):ph(d,H.zoom,{selected:Sl}),d.fillStyle=dl?Tt.glassFill:Tt.bgLayer1;const de=dl?"card":B.stylePreset,Ae=dl?il?14:16:B.stylePreset==="title"?Vt/2:12;if(bh(d,de,Zt,gl,Ht,Vt,Ae),d.fill(),mo(d),d.globalAlpha=ut?.7:1,y0(d,ol,dl?.08:B.stylePreset==="title"?.22:.14),!dl&&B.stylePreset!=="decision"&&B.stylePreset!=="title"&&B.stylePreset!=="note"&&v0(d,Zt,gl,Vt,ol,12),!dl&&B.stylePreset==="note"?d.setLineDash([4/H.zoom,3/H.zoom]):d.setLineDash([]),dl?(d.strokeStyle=Hl?Tt.warn:ll||Et?Tt.brand:Sl||mt?ol:Tt.glassBorder,d.lineWidth=(ll||Et||Sl||mt?1.8:1.25)/H.zoom):(d.strokeStyle=Hl?Tt.warn:ll?Tt.brand:B.stylePreset==="risk"?Tt.warn:Et?wt:Sl||mt?Tt.brand:ol,d.lineWidth=(ll||Et||Sl||B.stylePreset==="title"||B.stylePreset==="decision"?2.4:1.35)/H.zoom),!dl&&B.stylePreset==="muted"&&(d.globalAlpha=ut?.4:.55),mo(d),d.stroke(),d.setLineDash([]),d.globalAlpha=ut?.7:1,dl)if(!(tl===B.id))M0(d,B,Zt,gl,Tt,H.zoom,il,ol,()=>b(xl=>xl+1),{expanded:ht===B.id});else{d.beginPath(),d.arc(Zt+16,gl+20,4,0,Math.PI*2),d.fillStyle=ol,d.fill(),d.fillStyle=Tt.labelPrimary,d.font=_e(14,600),d.textBaseline="middle";const xl=un(d,B.text||i.unnamed,Ht-44,1);d.fillText(xl[0]??"?",Zt+28,gl+20)}else{const xl=14+(B.stylePreset==="decision"||B.stylePreset==="title"||B.stylePreset==="note"?0:4);let cl=gl+12;if(B.imageUrl){const wl=il?64:78,hl=Ht-xl-12,le=go(B.imageUrl,()=>b(qa=>qa+1));if(d.save(),d.beginPath(),bh(d,"default",Zt+xl,cl,hl,wl,8),d.clip(),le&&le.naturalWidth>0){const qa=Math.min(hl/le.naturalWidth,wl/le.naturalHeight),rn=le.naturalWidth*qa,Ye=le.naturalHeight*qa;d.fillStyle="rgba(0,0,0,0.22)",d.fillRect(Zt+xl,cl,hl,wl),d.drawImage(le,Zt+xl+(hl-rn)/2,cl+(wl-Ye)/2,rn,Ye)}else d.fillStyle=Tt.border,d.fillRect(Zt+xl,cl,hl,wl);d.restore(),cl+=wl+8}d.fillStyle=B.stylePreset==="muted"?Tt.labelSecondary:Tt.labelPrimary;const Nl=il?12:B.stylePreset==="title"?15:13,Jl=B.stylePreset==="title"||B.stylePreset==="decision"?600:500;d.font=_e(Nl,Jl),d.textBaseline="top";const he=Ht-xl-12,Kt=(il||B.stylePreset==="title",2),_t=un(d,B.text||i.unnamed,he,Kt),wa=Nl+3,lc=_t.length*wa,Ba=Ut!=="off"&&H.zoom>=.35?Ut==="tags"?(B.tags??[]).slice(0,2).map(wl=>`#${wl}`):S0(B).slice(0,4):[],qu=Ba.length?20:0;let Ya=cl;if(!B.imageUrl){const wl=Vt-16-qu;Ya=gl+Math.max(10,(wl-lc)/2)}if(_t.forEach((wl,hl)=>{d.fillText(wl,Zt+xl,Ya+hl*wa)}),Ba.length){let wl=Zt+xl;const hl=gl+Vt-22;for(const le of Ba)wl+=Dh(d,le,wl,hl,Tt,H.zoom)}}d.globalAlpha=1}d.restore()},[Tt,H,v,Ql,m,na,N,x,S,R,k,Oe,Ml,cn,fn,Rl,il,dl,Ul,ht,tl,jl,A==null?void 0:A.prefs.showRelationEdges,A==null?void 0:A.prefs.nodeBadges,Qt,i]),on=K.useCallback(()=>{const g=s.current;if(!g)return;const d=g.getContext("2d");if(!d)return;const Y=window.devicePixelRatio||1;g.width=Math.floor(an*Y),g.height=Math.floor(nn*Y),g.style.width=`${an}px`,g.style.height=`${nn}px`,d.setTransform(Y,0,0,Y,0,0),d.clearRect(0,0,an,nn),d.fillStyle=Tt.bgLayer1,d.fillRect(0,0,an,nn);const{minX:X,maxX:F,minY:L,maxY:J}=Ee,rt=Math.max(1,F-X),Rt=Math.max(1,J-L),zt=an/rt,Ut=nn/Rt,bt=Math.min(zt,Ut),B=(an-rt*bt)/2,xt=(nn-Rt*bt)/2,ut=(Et,wt)=>({x:B+(Et-X)*bt,y:xt+(wt-L)*bt});d.strokeStyle=Tt.border,d.lineWidth=1;for(const Et of v){if(Et.kind!=="hierarchy")continue;const wt=Ql(Et.from),mt=Ql(Et.to);if(!wt||!mt)continue;const ll=ut(wt.x,wt.y),Hl=ut(mt.x,mt.y);d.beginPath(),d.moveTo(ll.x,ll.y),d.lineTo(Hl.x,Hl.y),d.stroke()}for(const Et of m){if(Et.deletedAt)continue;const wt=Ql(Et.id);if(!wt)continue;const mt=ut(wt.x,wt.y);d.fillStyle=na.get(Et.id)??Tt.brand,d.beginPath(),d.arc(mt.x,mt.y,2.2,0,Math.PI*2),d.fill()}const Ht=Dl.w/H.zoom,Vt=Dl.h/H.zoom,Zt=-H.x/H.zoom,gl=-H.y/H.zoom,ol=ut(Zt-Ht/2,gl-Vt/2),Sl=ut(Zt+Ht/2,gl+Vt/2);d.strokeStyle=Tt.brand,d.lineWidth=1.5,d.strokeRect(ol.x,ol.y,Math.max(4,Sl.x-ol.x),Math.max(4,Sl.y-ol.y))},[Tt,Ee,v,Ql,m,na,Dl,H]);K.useEffect(()=>{const g=f.current,d=o.current;if(!g||!d)return;const Y=()=>{const F=d.getBoundingClientRect(),L=window.devicePixelRatio||1;g.width=Math.floor(F.width*L),g.height=Math.floor(F.height*L),g.style.width=`${F.width}px`,g.style.height=`${F.height}px`,Zn({w:F.width,h:F.height}),je(),on()};Y();const X=new ResizeObserver(Y);return X.observe(d),()=>X.disconnect()},[je,on]),K.useEffect(()=>{je(),on()},[je,on]),K.useEffect(()=>{const g=Y=>{var F,L;const X=(F=Y.target)==null?void 0:F.tagName;if(!(X==="INPUT"||X==="TEXTAREA")){if(!Y.metaKey&&!Y.ctrlKey&&!Y.altKey){const J=Y.key.toLowerCase();J==="v"&&rl("select"),J==="h"&&rl("pan"),J==="c"&&rl("link"),J==="b"&<("branch"),J==="n"&<("node"),J==="l"&&qt(rt=>!rt),J==="f"&&re(),(J==="="||J==="+")&&De(H.zoom*1.15),(J==="-"||J==="_")&&De(H.zoom/1.15)}if(Y.code==="Space"&&(Z.current.space=!0),Y.key==="Alt"&&(Z.current.alt=!0),Y.key==="Escape"&&Z.current.mode==="node"){Y.preventDefault(),Z.current.mode="none",Z.current.nodeId=null,Z.current.moved=!1,we(null),ja(null),Be(!1),Ca(null);return}if(Y.key==="Escape"&&(tl||ht||te)){Y.preventDefault(),Pt(null),Dt(null),se(null);return}if(!it){if(Y.key==="Tab"&&!it){Y.preventDefault();const J=N[0];et([Ll(J?{type:"create_node",text:i.newNode,parentId:J}:{type:"create_node",text:i.newNode})])}if(Y.key==="ArrowLeft"&&N[0]&&!C&&(Y.preventDefault(),et([Ll({type:"create_node",text:i.leftChild,parentId:N[0],sidePref:-1})])),Y.key==="ArrowRight"&&N[0]&&!C&&(Y.preventDefault(),et([Ll({type:"create_node",text:i.rightChild,parentId:N[0],sidePref:1})])),(Y.key==="Delete"||Y.key==="Backspace")&&!C){const J=N[0];J&&et([{type:"delete_node",nodeId:J}])}if(Y.key==="Enter"&&N[0]&&!C){Y.preventDefault();const J=((L=v.find(rt=>rt.kind==="hierarchy"&&rt.isPrimaryParent&&rt.to===N[0]))==null?void 0:L.from)??null;et([Ll(J?{type:"create_node",text:i.sibling,parentId:J}:{type:"create_node",text:i.newNode})])}}}},d=Y=>{Y.code==="Space"&&(Z.current.space=!1),Y.key==="Alt"&&(Z.current.alt=!1)};return window.addEventListener("keydown",g),window.addEventListener("keyup",d),()=>{window.removeEventListener("keydown",g),window.removeEventListener("keyup",d)}},[et,A,N,C,v,it,re,De,H.zoom,i,Ll,G,pt,tl,ht,te]);const Yu=tc??(vl==="pan"||Z.current.space?"grab":vl==="link"?"crosshair":"default");return y.jsxs("div",{className:`canvas-host${it?" is-locked":""}`,ref:o,style:{cursor:Yu},onWheel:g=>{g.preventDefault();const d=g.deltaY>0?.9:1.1;W(Y=>({...Y,zoom:Math.min(4,Math.max(.02,Y.zoom*d))}))},onPointerDown:g=>{var L;const d=g.target;if((L=d==null?void 0:d.closest)!=null&&L.call(d,".canvas-toolbar, .canvas-controls, .canvas-minimap, .edit-overlay, .node-handles, .hover-card, .inspector"))return;const Y=Ra(g.clientX,g.clientY),X=ze(Y.x,Y.y);if(Z.current.lastX=g.clientX,Z.current.lastY=g.clientY,Z.current.startX=g.clientX,Z.current.startY=g.clientY,Z.current.moved=!1,Z.current.alt=g.altKey,Z.current.forcePin=g.ctrlKey||g.metaKey,Z.current.startWorldX=Y.x,Z.current.startWorldY=Y.y,Z.current.subtreeIds=[],g.currentTarget.setPointerCapture(g.pointerId),vl==="pan"||Z.current.space||g.button===1||g.button===2||!X&&vl!=="link"){Z.current.mode="pan",Z.current.nodeId=null,X||ft([]),Ca("grabbing");return}if(it){ft(X?[X]:[]),Z.current.mode="none";return}if(X&&(vl==="link"||g.altKey)){Z.current.mode="link",Z.current.nodeId=X,ft([X]),Da({fromId:X,x:Y.x,y:Y.y});return}if(X&&vl==="select"){Z.current.mode="node",Z.current.nodeId=X;const J=g.shiftKey||Lt==="node";Z.current.subtreeIds=J?[X]:po(X,v),ft([X]);return}Z.current.mode="pan",Ca("grabbing")},onPointerMove:g=>{var F;let d=Ra(g.clientX,g.clientY);const Y=g.clientX-Z.current.startX,X=g.clientY-Z.current.startY;if(Math.hypot(Y,X)>4&&(Z.current.moved=!0),Z.current.mode==="pan"){const L=g.clientX-Z.current.lastX,J=g.clientY-Z.current.lastY;Z.current.lastX=g.clientX,Z.current.lastY=g.clientY,W(rt=>({...rt,x:rt.x+L,y:rt.y+J}));return}if(Z.current.mode==="link"&&Z.current.nodeId){Da({fromId:Z.current.nodeId,x:d.x,y:d.y});return}if(Z.current.mode==="node"&&Z.current.nodeId&&Z.current.moved){const L=Z.current.nodeId,J=o.current;if(J){const B=J.getBoundingClientRect(),xt=48;let ut=0,Ht=0;g.clientXB.right-xt&&(ut=-12),g.clientYB.bottom-xt&&(Ht=-12),(ut||Ht)&&(W(Vt=>({...Vt,x:Vt.x+ut,y:Vt.y+Ht})),Z.current.startWorldX+=ut/H.zoom,Z.current.startWorldY+=Ht/H.zoom,d=Ra(g.clientX,g.clientY))}const rt=d.x-Z.current.startWorldX,Rt=d.y-Z.current.startWorldY,zt=Z.current.subtreeIds.length>0?Z.current.subtreeIds:po(L,v);if(we({rootId:L,dx:rt,dy:Rt,ids:zt}),Ca("grabbing"),Z.current.forcePin=g.ctrlKey||g.metaKey,Z.current.forcePin){ja(null),Be(!1),st(null);return}const Ut=new Set(zt),bt=ze(d.x,d.y,Ut);if(st(bt),bt&&bt!==L){const B=Mh(bt,L,v);ja(bt),Be(B)}else ja(null),Be(!1)}if(Z.current.mode==="none"&&!Ml){const L=ze(d.x,d.y);if(st(L),dl&&L&&H.zoom>=.35&&tl!==L){const J=m.find(Rt=>Rt.id===L),rt=J?Ql(L):null;if(J&&rt){const{w:Rt,h:zt}=jl(J),Ut=d.x-(rt.x-Rt/2),bt=d.y-(rt.y-zt/2),xt=E0(J,il,ht===J.id).find(ut=>Ut>=ut.x&&Ut<=ut.x+ut.w&&bt>=ut.y&&bt<=ut.y+ut.h);if(xt){const ut=(F=o.current)==null?void 0:F.getBoundingClientRect(),Ht=ut?g.clientX-ut.left+14:Dl.w/2+H.x+d.x*H.zoom+14,Vt=ut?g.clientY-ut.top+14:Dl.h/2+H.y+d.y*H.zoom+14;se({label:xt.label,value:xt.fullValue,x:Ht,y:Vt})}else se(null)}else se(null)}else se(null)}},onPointerUp:g=>{var rt;const d=Ra(g.clientX,g.clientY),Y=Z.current.mode,X=Z.current.nodeId,F=Z.current.moved,L=Bu.current,J=Z.current.forcePin||g.ctrlKey||g.metaKey;if(!it&&Y==="link"&&X){const Rt=ze(d.x,d.y);Rt&&Rt!==X&&et([{type:"link",from:X,to:Rt,kind:"relation",label:i.relationLabel}]),Da(null)}else if(!it&&Y==="node"&&X&&F&&L){const Rt=new Set(L.ids),zt=J||fn?null:ze(d.x,d.y,Rt);if(zt&&zt!==X&&!Mh(zt,X,v)&&zt){const bt=(((rt=_[zt])==null?void 0:rt.x)??0)<=0?-1:1,B={..._};for(const xt of L.ids){const ut=_[xt];ut&&(B[xt]={x:ut.x+L.dx,y:ut.y+L.dy})}dt({positions:B}),we(null),et([{type:"move_node",nodeId:X,newParentId:zt,sidePref:bt}])}else{const bt={..._},B=[],xt=m.map(ut=>{if(!Rt.has(ut.id))return ut;const Ht=_[ut.id];if(!Ht)return ut;const Vt={x:Ht.x+L.dx,y:Ht.y+L.dy};return bt[ut.id]=Vt,B.push({type:"set_pinned",nodeId:ut.id,pinned:!0,pos:Vt}),{...ut,pinned:!0,pos:Vt}});dt({positions:bt,nodes:xt}),we(null),et(B,"drag pin")}}else Y==="node"&&X&&!F?(ft([X]),dl&&(Dt(Rt=>Rt===X?null:X),tl&&tl!==X&&Pt(null))):Y==="pan"&&!F&&(Dt(null),Pt(null),se(null));Z.current.mode="none",Z.current.nodeId=null,Z.current.forcePin=!1,Z.current.subtreeIds=[],Da(null),we(null),ja(null),Be(!1),Ca(null)},onContextMenu:g=>g.preventDefault(),onDoubleClick:g=>{if(it)return;const d=Ra(g.clientX,g.clientY),Y=ze(d.x,d.y);if(Y){if(dl){ft([Y]),Dt(Y),Pt(Y),se(null);return}const X=m.find(J=>J.id===Y),F=o.current.getBoundingClientRect(),L=Ql(Y);Q({id:Y,text:X.text,x:F.width/2+H.x+L.x*H.zoom-70,y:F.height/2+H.y+L.y*H.zoom-16})}else vl==="select"&&et([Ll({type:"create_node",text:i.newNode,...N[0]?{parentId:N[0]}:{},sidePref:d.x<0?-1:1})])},children:[y.jsx("canvas",{ref:f}),y.jsxs("div",{className:"canvas-toolbar",role:"toolbar","aria-label":i.toolbarAria,onPointerDown:g=>g.stopPropagation(),children:[St?y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"canvas-toolbar__group",children:y.jsx("button",{type:"button",className:"canvas-tool-btn",title:i.backRosterTitle,onClick:P,children:i.backRoster})}),y.jsx("div",{className:"canvas-toolbar__sep"})]}):null,y.jsx("div",{className:"canvas-toolbar__group",children:[["select",i.toolSelect,"V"],["pan",i.toolPan,"H"],["link",i.toolLink,"C"]].map(([g,d,Y])=>y.jsx("button",{type:"button",className:`canvas-tool-btn${vl===g?" is-active":""}`,title:`${d} (${Y})`,"aria-pressed":vl===g,onClick:()=>rl(g),children:d},g))}),y.jsx("div",{className:"canvas-toolbar__sep"}),y.jsxs("div",{className:"canvas-toolbar__group",children:[y.jsx("button",{type:"button",className:`canvas-tool-btn${Lt==="node"?" is-active":""}`,title:i.dragNodeTitle,"aria-pressed":Lt==="node",onClick:()=>lt("node"),children:i.dragNode}),y.jsx("button",{type:"button",className:`canvas-tool-btn${Lt==="branch"?" is-active":""}`,title:i.dragBranchTitle,"aria-pressed":Lt==="branch",onClick:()=>lt("branch"),children:i.dragBranch})]}),y.jsx("div",{className:"canvas-toolbar__sep"}),y.jsxs("div",{className:"canvas-toolbar__group",children:[y.jsx("button",{type:"button",className:`canvas-tool-btn${Kl==="bubble"?" is-active":""}`,title:i.bubbleTitle,"aria-pressed":Kl==="bubble",disabled:it,onClick:()=>{Kl!=="bubble"&&tt({nodeViewMode:"bubble"})},children:i.bubble}),y.jsx("button",{type:"button",className:`canvas-tool-btn${Kl==="card"?" is-active":""}`,title:i.cardTitle,"aria-pressed":Kl==="card",disabled:it,onClick:()=>{Kl!=="card"&&tt({nodeViewMode:"card"})},children:i.card}),y.jsx("button",{type:"button",className:`canvas-tool-btn${Kl==="topology"?" is-active":""}`,title:i.topologyTitle,"aria-pressed":Kl==="topology",disabled:it,onClick:()=>{Kl!=="topology"&&tt({nodeViewMode:"topology"})},children:i.topology}),y.jsx("button",{type:"button",className:"canvas-tool-btn",title:i.unpinTitle,disabled:it||!N[0]||!((sn=m.find(g=>g.id===N[0]))!=null&&sn.pinned),onClick:()=>{N[0]&&et([{type:"set_pinned",nodeId:N[0],pinned:!1}])},children:i.unpin})]}),y.jsx("div",{className:"canvas-toolbar__sep"}),y.jsx("div",{className:"canvas-toolbar__group",children:y.jsx("button",{type:"button",className:"canvas-tool-btn",title:i.undo,disabled:!pt,onClick:()=>void G(),children:i.undo})}),y.jsx("div",{className:"canvas-toolbar__sep"}),y.jsxs("div",{className:"canvas-toolbar__group",children:[y.jsx("button",{type:"button",className:"canvas-tool-btn",title:i.exportPngTitle,onClick:()=>{const g=f.current;if(!g)return;const d=((A==null?void 0:A.title)??"mindmap").replace(/[\\/:*?"<>|]+/g,"_");nv({fitView:re,canvas:g,filename:`${d}.png`}).catch(()=>{})},children:i.exportPng}),y.jsx("button",{type:"button",className:"canvas-tool-btn",title:i.exportSvgTitle,disabled:!q,onClick:()=>{if(!q)return;const g=((A==null?void 0:A.title)??"mindmap").replace(/[\\/:*?"<>|]+/g,"_");uv(q,`${g}.svg`).catch(()=>{})},children:i.exportSvg})]}),y.jsxs("span",{className:"canvas-toolbar__zoom",children:[Math.round(H.zoom*100),"%"]})]}),y.jsxs("div",{className:"canvas-controls",role:"toolbar","aria-label":i.controlsAria,onPointerDown:g=>g.stopPropagation(),children:[y.jsx("button",{type:"button",className:"canvas-controls__btn",title:O?i.exitFullscreen:i.fullscreen,"aria-label":O?i.exitFullscreen:i.fullscreen,onClick:()=>void nt(),children:y.jsx(mv,{exit:O})}),y.jsx("button",{type:"button",className:"canvas-controls__btn",title:i.zoomInTitle,"aria-label":i.zoomIn,onClick:()=>De(H.zoom*1.2),children:y.jsx(yv,{})}),y.jsx("button",{type:"button",className:"canvas-controls__btn",title:i.zoomOutTitle,"aria-label":i.zoomOut,onClick:()=>De(H.zoom/1.2),children:y.jsx(vv,{})}),y.jsx("button",{type:"button",className:"canvas-controls__btn",title:i.fitTitle,"aria-label":i.fit,onClick:re,children:y.jsx(gv,{})}),y.jsx("button",{type:"button",className:`canvas-controls__btn${it?" is-active":""}`,title:it?i.unlockTitle:i.lockTitle,"aria-label":it?i.unlock:i.lock,"aria-pressed":it,onClick:()=>qt(g=>!g),children:y.jsx(pv,{locked:it})})]}),y.jsx("div",{className:"canvas-minimap",onPointerDown:g=>{g.stopPropagation(),Ua.current=!0,g.currentTarget.setPointerCapture(g.pointerId),Ha(g.clientX,g.clientY)},onPointerMove:g=>{Ua.current&&Ha(g.clientX,g.clientY)},onPointerUp:()=>{Ua.current=!1},onPointerCancel:()=>{Ua.current=!1},children:y.jsx("canvas",{ref:s,width:an,height:nn})}),C&&y.jsx("input",{className:"edit-overlay",style:{left:C.x,top:C.y},autoFocus:!0,value:C.text,onChange:g=>Q({...C,text:g.target.value}),onBlur:()=>{et([{type:"update_text",nodeId:C.id,text:C.text}]),Q(null)},onKeyDown:g=>{g.key==="Enter"&&g.target.blur(),g.key==="Escape"&&Q(null)}}),!it&&N[0]&&!Ml&&_[N[0]]&&(()=>{const g=N[0],d=m.find(zt=>zt.id===g);if(!d||d.deletedAt)return null;const Y=_[g],{w:X}=jl(d),F=Dl.w/2+H.x+Y.x*H.zoom,L=Dl.h/2+H.y+Y.y*H.zoom,J=X/2*H.zoom,rt=il?100:140,Rt=zt=>{const Ut=zt<0?i.leftChild:i.rightChild,bt=il?160:200;et([Ll({type:"create_node",text:Ut,parentId:g,sidePref:zt,pos:{x:Y.x+zt*(X/2+bt/2+rt),y:Y.y}})])};return y.jsxs("div",{className:"node-handles",onPointerDown:zt=>zt.stopPropagation(),children:[y.jsx("button",{type:"button",className:"node-handle node-handle--left",style:{left:F-J-14,top:L-10},title:i.addLeftChildTitle,onClick:()=>Rt(-1),children:"+"}),y.jsx("button",{type:"button",className:"node-handle node-handle--right",style:{left:F+J-2,top:L-10},title:i.addRightChildTitle,onClick:()=>Rt(1),children:"+"})]})})(),(A==null?void 0:A.prefs.showHoverCard)!==!1&&k&&!Ml&&!dl&&(()=>{const g=m.find(L=>L.id===k);if(!g)return null;const d=g?_[g.id]:null;if(!d)return null;const{h:Y}=jl(g),X=Dl.w/2+H.x+d.x*H.zoom+12,F=Dl.h/2+H.y+d.y*H.zoom+Y/2*H.zoom+8;return y.jsx(tv,{node:g,x:X,y:F})})(),dl&&te?y.jsx(lv,{label:te.label,value:te.value,x:te.x,y:te.y}):null,!it&&!Ml&&dl&&tl&&H.zoom>=.35&&(()=>{const g=tl,d=m.find(J=>J.id===g);if(!d||d.deletedAt)return null;const Y=_[g];if(!Y)return null;const{w:X}=jl(d),F=Dl.w/2+H.x+Y.x*H.zoom,L=Dl.h/2+H.y+Y.y*H.zoom;return y.jsx(w0,{node:d,applyOps:et,screenX:F,screenY:L,zoom:H.zoom,width:X,accent:na.get(g),showStylePreset:!1})})(),y.jsx("div",{className:"canvas-hint muted",children:it?i.hintLocked:Lt==="node"?i.hintNodeDrag:i.hintBranchDrag})]})}function mv({exit:i}){return i?y.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16","aria-hidden":"true",children:y.jsx("path",{fill:"currentColor",d:"M7 14H5v5h5v-2H7v-3zm12 0h-2v3h-3v2h5v-5zM7 5h3V3H5v5h2V5zm10 0v3h2V3h-5v2h3z"})}):y.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16","aria-hidden":"true",children:y.jsx("path",{fill:"currentColor",d:"M7 14H5v5h5v-2H7v-3zm0-9h3V3H5v5h2V5zm12 9h-2v3h-3v2h5v-5zm-2-9V3h-3v2h3v3h2V5h-2z"})})}function yv(){return y.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16","aria-hidden":"true",children:y.jsx("path",{fill:"currentColor",d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"})})}function vv(){return y.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16","aria-hidden":"true",children:y.jsx("path",{fill:"currentColor",d:"M19 13H5v-2h14v2z"})})}function gv(){return y.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16","aria-hidden":"true",children:y.jsx("path",{fill:"currentColor",d:"M3 5v4h2V7h2V5H3zm0 10v4h4v-2H5v-2H3zm14-10v2h2v2h2V5h-4zm4 10h-2v2h-2v2h4v-4zM7 9h10v6H7V9z"})})}function pv({locked:i}){return i?y.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16","aria-hidden":"true",children:y.jsx("path",{fill:"currentColor",d:"M12 17a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm6-7h-1V7a5 5 0 0 0-10 0v3H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8a2 2 0 0 0-2-2zM9 7a3 3 0 0 1 6 0v3H9V7z"})}):y.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16","aria-hidden":"true",children:y.jsx("path",{fill:"currentColor",d:"M12 17a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm6-7h-1V7a5 5 0 0 0-9.9-1h2.1A3 3 0 0 1 15 7v3H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8a2 2 0 0 0-2-2z"})})}function bv(){try{return new URLSearchParams(window.location.search)}catch{return new URLSearchParams}}function Sv(){const i=K.useMemo(()=>bv(),[]),f=i.get("embed")==="1"||i.get("embed")==="true",s=i.get("canvasId")||"",{canvases:o,canvasId:m,canvas:v,nodes:_,selectedIds:N,leftCollapsed:x,loadCanvases:S,createCanvas:R,openCanvas:A,undo:q,setCollapsedPanels:et,setPrefs:tt,applyOps:dt,trash:ft,restoreFromTrash:G}=Ct();K.useEffect(()=>{$0()},[]),K.useEffect(()=>{(async()=>{if(await S(),s){await A(s);return}Ct.getState().canvasId||await R("未命名画布")})()},[S,R,A,s]),K.useEffect(()=>{const P=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws`;let nt=null,H=!1,W,nl,ul=800;const vl=(Lt,lt)=>{window.clearTimeout(nl),nl=window.setTimeout(async()=>{if(Ct.getState().canvasId===Lt)try{const it=await fetch(`/api/canvases/${Lt}`).then(qt=>qt.json());Ct.getState().applyCanvasPayload(it,{preserveUnpinned:lt})}catch{Ct.getState().openCanvas(Lt)}},120)},rl=()=>{if(!H){try{nt=new WebSocket(P)}catch{W=window.setTimeout(rl,ul),ul=Math.min(8e3,ul*1.6);return}nt.onopen=()=>{ul=800},nt.onmessage=Lt=>{try{const lt=JSON.parse(String(Lt.data));if(lt.type==="canvas/event"&<.canvasId&<.canvasId===Ct.getState().canvasId&&(lt.fitViewport&&Ct.getState().requestFitViewport(lt.fitViewport),vl(lt.canvasId,lt.preserveUnpinned===!0)),lt.type==="canvas/highlight"&<.canvasId&<.canvasId===Ct.getState().canvasId){const it=Array.isArray(lt.nodeIds)?lt.nodeIds:[],qt=Array.isArray(lt.edgeIds)?lt.edgeIds:[];Ct.getState().flashHighlight({nodeIds:it,edgeIds:qt,style:lt.style&&typeof lt.style=="object"?lt.style:null,ttlMs:typeof lt.ttlMs=="number"?lt.ttlMs:qt.length?5e3:2200})}}catch{}},nt.onclose=()=>{H||(W=window.setTimeout(rl,ul),ul=Math.min(8e3,ul*1.6))},nt.onerror=()=>{try{nt==null||nt.close()}catch{}}}};return rl(),()=>{H=!0,window.clearTimeout(W),window.clearTimeout(nl);try{nt==null||nt.close()}catch{}}},[]),K.useEffect(()=>{const P=m;if(!P)return;const nt=window.setTimeout(()=>{fetch(`/api/canvases/${P}/activity`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({selectionIds:N,focusNodeId:(v==null?void 0:v.focusNodeId)??null,viewport:(v==null?void 0:v.viewport)??{x:0,y:0,zoom:1}})})},200);return()=>window.clearTimeout(nt)},[m,N,v==null?void 0:v.focusNodeId,v==null?void 0:v.viewport]);const pt=v==null?void 0:v.focusNodeId,St=_.filter(P=>!P.deletedAt);return f?y.jsx("div",{className:"app-shell embed",children:y.jsx("div",{className:"main embed-main",children:y.jsx(xh,{})})}):y.jsxs("div",{className:"app-shell",children:[y.jsxs("header",{className:"topbar",children:[y.jsx("div",{className:"brand",children:"Mind Map"}),y.jsx("button",{type:"button",onClick:()=>et("left",!x),children:x?"目录":"收目录"}),y.jsx("button",{type:"button",onClick:()=>void R(),children:"新建"}),y.jsx("button",{type:"button",onClick:()=>void q(),disabled:!Ct.getState().lastChangeSetId,children:"撤销"}),y.jsxs("button",{type:"button",onClick:()=>void tt({density:(v==null?void 0:v.prefs.density)==="compact"?"comfortable":"compact"}),children:["密度: ",(v==null?void 0:v.prefs.density)??"comfortable"]}),y.jsxs("button",{type:"button",onClick:()=>void tt({branchColoring:!((v==null?void 0:v.prefs.branchColoring)??!0)}),children:["分色: ",(v==null?void 0:v.prefs.branchColoring)===!1?"关":"开"]}),y.jsxs("button",{type:"button",onClick:()=>{const P=(v==null?void 0:v.prefs.nodeViewMode)??"card";tt({nodeViewMode:P==="bubble"?"card":P==="card"?"topology":"bubble"})},children:["模式:"," ",(v==null?void 0:v.prefs.nodeViewMode)==="bubble"?"气泡":(v==null?void 0:v.prefs.nodeViewMode)==="topology"?"拓扑":"卡片"]}),y.jsx("button",{type:"button",onClick:()=>{const P=m;P&&fetch(`/api/canvases/${P}/export.json`).then(nt=>nt.json()).then(nt=>{const H=new Blob([JSON.stringify(nt,null,2)],{type:"application/json"}),W=document.createElement("a");W.href=URL.createObjectURL(H),W.download=`${(v==null?void 0:v.title)??"mindmap"}.json`,W.click()})},children:"导出JSON"}),y.jsx("button",{type:"button",onClick:()=>{const P=m;if(!P)return;const nt=((v==null?void 0:v.title)??"mindmap").replace(/[\\/:*?"<>|]+/g,"_");fetch(`/api/canvases/${P}/export.svg`).then(H=>{if(!H.ok)throw new Error(String(H.status));return H.text()}).then(H=>{const W=document.createElement("a");W.href=URL.createObjectURL(new Blob([H],{type:"image/svg+xml;charset=utf-8"})),W.download=`${nt}.svg`,W.click()}).catch(()=>{})},children:"导出SVG"}),y.jsx("button",{type:"button",onClick:()=>{const P=document.querySelector(".canvas-host canvas");if(!P)return;const nt=((v==null?void 0:v.title)??"mindmap").replace(/[\\/:*?"<>|]+/g,"_");P.toBlob(H=>{if(!H)return;const W=document.createElement("a");W.href=URL.createObjectURL(H),W.download=`${nt}.png`,W.click()})},children:"导出PNG"}),y.jsx("div",{className:"spacer"})]}),y.jsxs("div",{className:`main ${x?"left-collapsed":""}`,children:[y.jsxs("aside",{className:"panel",style:{display:x?"none":void 0},children:[y.jsx("div",{className:"panel-header",children:"目录"}),y.jsxs("div",{className:"panel-body",children:[y.jsx("div",{className:"muted",style:{marginBottom:8},children:"画布"}),o.map(P=>y.jsx("div",{className:`canvas-list-item ${P.id===m?"active":""}`,onClick:()=>void A(P.id),children:P.title},P.id)),y.jsx("div",{className:"muted",style:{margin:"12px 0 8px"},children:"大纲"}),St.map(P=>y.jsxs("div",{className:`outline-item ${N.includes(P.id)?"active":""}`,onClick:()=>{Ct.getState().setSelection([P.id]),dt([{type:"set_focus",nodeId:P.id}])},children:[P.id===pt?"◎ ":"• ",P.text]},P.id)),y.jsx("div",{className:"muted",style:{margin:"12px 0 8px"},children:"属性"}),y.jsx(G0,{}),y.jsxs("div",{className:"muted",style:{margin:"12px 0 8px"},children:["回收站 (",ft.length,")"]}),ft.length===0&&y.jsx("div",{className:"muted",children:"空"}),ft.map(P=>y.jsxs("div",{className:"trash-item",children:[y.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:P.text}),y.jsx("button",{type:"button",onClick:()=>void G(P.id),children:"恢复"})]},P.id))]})]}),y.jsx(xh,{})]})]})}Iy.createRoot(document.getElementById("root")).render(y.jsx(Sv,{}));