@clawos-dev/clawd 0.2.266 → 0.2.267

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,10 +34,10 @@ var wy=e=>{throw TypeError(e)};var Sy=(e,t,n)=>t.has(e)||wy("Cannot "+n);var ul=
34
34
  `+dp+e}var hp=!1;function fp(e,t){if(!e||hp)return"";hp=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(c){var r=c}Reflect.construct(e,[],t)}else{try{t.call()}catch(c){r=c}e.call(t.prototype)}else{try{throw Error()}catch(c){r=c}e()}}catch(c){if(c&&r&&typeof c.stack=="string"){for(var i=c.stack.split(`
35
35
  `),s=r.stack.split(`
36
36
  `),o=i.length-1,a=s.length-1;1<=o&&0<=a&&i[o]!==s[a];)a--;for(;1<=o&&0<=a;o--,a--)if(i[o]!==s[a]){if(o!==1||a!==1)do if(o--,a--,0>a||i[o]!==s[a]){var l=`
37
- `+i[o].replace(" at new "," at ");return e.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",e.displayName)),l}while(1<=o&&0<=a);break}}}finally{hp=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Rl(e):""}function UA(e){switch(e.tag){case 5:return Rl(e.type);case 16:return Rl("Lazy");case 13:return Rl("Suspense");case 19:return Rl("SuspenseList");case 0:case 2:case 15:return e=fp(e.type,!1),e;case 11:return e=fp(e.type.render,!1),e;case 1:return e=fp(e.type,!0),e;default:return""}}function qm(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Yo:return"Fragment";case Xo:return"Portal";case Um:return"Profiler";case H0:return"StrictMode";case Wm:return"Suspense";case Vm:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case cC:return(e.displayName||"Context")+".Consumer";case lC:return(e._context.displayName||"Context")+".Provider";case U0:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case W0:return t=e.displayName||null,t!==null?t:qm(e.type)||"Memo";case es:t=e._payload,e=e._init;try{return qm(e(t))}catch{}}return null}function WA(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return qm(t);case 8:return t===H0?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function bs(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function dC(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function VA(e){var t=dC(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Cu(e){e._valueTracker||(e._valueTracker=VA(e))}function hC(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=dC(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Gd(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Km(e,t){var n=t.checked;return bt({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function My(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=bs(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function fC(e,t){t=t.checked,t!=null&&F0(e,"checked",t,!1)}function Gm(e,t){fC(e,t);var n=bs(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Xm(e,t.type,n):t.hasOwnProperty("defaultValue")&&Xm(e,t.type,bs(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Ay(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Xm(e,t,n){(t!=="number"||Gd(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Ml=Array.isArray;function da(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+bs(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Ym(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(G(91));return bt({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function jy(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(G(92));if(Ml(n)){if(1<n.length)throw Error(G(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:bs(n)}}function pC(e,t){var n=bs(t.value),r=bs(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function Dy(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function mC(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Zm(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?mC(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Eu,gC=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Eu=Eu||document.createElement("div"),Eu.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Eu.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function lc(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Wl={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},qA=["Webkit","ms","Moz","O"];Object.keys(Wl).forEach(function(e){qA.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Wl[t]=Wl[e]})});function vC(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Wl.hasOwnProperty(e)&&Wl[e]?(""+t).trim():t+"px"}function _C(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=vC(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var KA=bt({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Qm(e,t){if(t){if(KA[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(G(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(G(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(G(61))}if(t.style!=null&&typeof t.style!="object")throw Error(G(62))}}function Jm(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var eg=null;function V0(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var tg=null,ha=null,fa=null;function Ly(e){if(e=Jc(e)){if(typeof tg!="function")throw Error(G(280));var t=e.stateNode;t&&(t=sf(t),tg(e.stateNode,e.type,t))}}function xC(e){ha?fa?fa.push(e):fa=[e]:ha=e}function yC(){if(ha){var e=ha,t=fa;if(fa=ha=null,Ly(e),t)for(e=0;e<t.length;e++)Ly(t[e])}}function bC(e,t){return e(t)}function wC(){}var pp=!1;function SC(e,t,n){if(pp)return e(t,n);pp=!0;try{return bC(e,t,n)}finally{pp=!1,(ha!==null||fa!==null)&&(wC(),yC())}}function cc(e,t){var n=e.stateNode;if(n===null)return null;var r=sf(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(G(231,t,typeof n));return n}var ng=!1;if(Ni)try{var hl={};Object.defineProperty(hl,"passive",{get:function(){ng=!0}}),window.addEventListener("test",hl,hl),window.removeEventListener("test",hl,hl)}catch{ng=!1}function GA(e,t,n,r,i,s,o,a,l){var c=Array.prototype.slice.call(arguments,3);try{t.apply(n,c)}catch(u){this.onError(u)}}var Vl=!1,Xd=null,Yd=!1,rg=null,XA={onError:function(e){Vl=!0,Xd=e}};function YA(e,t,n,r,i,s,o,a,l){Vl=!1,Xd=null,GA.apply(XA,arguments)}function ZA(e,t,n,r,i,s,o,a,l){if(YA.apply(this,arguments),Vl){if(Vl){var c=Xd;Vl=!1,Xd=null}else throw Error(G(198));Yd||(Yd=!0,rg=c)}}function wo(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function kC(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Oy(e){if(wo(e)!==e)throw Error(G(188))}function QA(e){var t=e.alternate;if(!t){if(t=wo(e),t===null)throw Error(G(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var s=i.alternate;if(s===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===s.child){for(s=i.child;s;){if(s===n)return Oy(i),e;if(s===r)return Oy(i),t;s=s.sibling}throw Error(G(188))}if(n.return!==r.return)n=i,r=s;else{for(var o=!1,a=i.child;a;){if(a===n){o=!0,n=i,r=s;break}if(a===r){o=!0,r=i,n=s;break}a=a.sibling}if(!o){for(a=s.child;a;){if(a===n){o=!0,n=s,r=i;break}if(a===r){o=!0,r=s,n=i;break}a=a.sibling}if(!o)throw Error(G(189))}}if(n.alternate!==r)throw Error(G(190))}if(n.tag!==3)throw Error(G(188));return n.stateNode.current===n?e:t}function CC(e){return e=QA(e),e!==null?EC(e):null}function EC(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=EC(e);if(t!==null)return t;e=e.sibling}return null}var NC=nr.unstable_scheduleCallback,By=nr.unstable_cancelCallback,JA=nr.unstable_shouldYield,e5=nr.unstable_requestPaint,It=nr.unstable_now,t5=nr.unstable_getCurrentPriorityLevel,q0=nr.unstable_ImmediatePriority,TC=nr.unstable_UserBlockingPriority,Zd=nr.unstable_NormalPriority,n5=nr.unstable_LowPriority,PC=nr.unstable_IdlePriority,ef=null,Qr=null;function r5(e){if(Qr&&typeof Qr.onCommitFiberRoot=="function")try{Qr.onCommitFiberRoot(ef,e,void 0,(e.current.flags&128)===128)}catch{}}var Ir=Math.clz32?Math.clz32:o5,i5=Math.log,s5=Math.LN2;function o5(e){return e>>>=0,e===0?32:31-(i5(e)/s5|0)|0}var Nu=64,Tu=4194304;function Al(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64: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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Qd(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,s=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~i;a!==0?r=Al(a):(s&=o,s!==0&&(r=Al(s)))}else o=n&~i,o!==0?r=Al(o):s!==0&&(r=Al(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,s=t&-t,i>=s||i===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Ir(t),i=1<<n,r|=e[n],t&=~i;return r}function a5(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function l5(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,s=e.pendingLanes;0<s;){var o=31-Ir(s),a=1<<o,l=i[o];l===-1?(!(a&n)||a&r)&&(i[o]=a5(a,t)):l<=t&&(e.expiredLanes|=a),s&=~a}}function ig(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function IC(){var e=Nu;return Nu<<=1,!(Nu&4194240)&&(Nu=64),e}function mp(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Zc(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ir(t),e[t]=n}function c5(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var i=31-Ir(n),s=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~s}}function K0(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ir(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var Je=0;function RC(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var MC,G0,AC,jC,DC,sg=!1,Pu=[],ds=null,hs=null,fs=null,uc=new Map,dc=new Map,is=[],u5="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function zy(e,t){switch(e){case"focusin":case"focusout":ds=null;break;case"dragenter":case"dragleave":hs=null;break;case"mouseover":case"mouseout":fs=null;break;case"pointerover":case"pointerout":uc.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":dc.delete(t.pointerId)}}function fl(e,t,n,r,i,s){return e===null||e.nativeEvent!==s?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:s,targetContainers:[i]},t!==null&&(t=Jc(t),t!==null&&G0(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function d5(e,t,n,r,i){switch(t){case"focusin":return ds=fl(ds,e,t,n,r,i),!0;case"dragenter":return hs=fl(hs,e,t,n,r,i),!0;case"mouseover":return fs=fl(fs,e,t,n,r,i),!0;case"pointerover":var s=i.pointerId;return uc.set(s,fl(uc.get(s)||null,e,t,n,r,i)),!0;case"gotpointercapture":return s=i.pointerId,dc.set(s,fl(dc.get(s)||null,e,t,n,r,i)),!0}return!1}function LC(e){var t=qs(e.target);if(t!==null){var n=wo(t);if(n!==null){if(t=n.tag,t===13){if(t=kC(n),t!==null){e.blockedOn=t,DC(e.priority,function(){AC(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function yd(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=og(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);eg=r,n.target.dispatchEvent(r),eg=null}else return t=Jc(n),t!==null&&G0(t),e.blockedOn=n,!1;t.shift()}return!0}function $y(e,t,n){yd(e)&&n.delete(t)}function h5(){sg=!1,ds!==null&&yd(ds)&&(ds=null),hs!==null&&yd(hs)&&(hs=null),fs!==null&&yd(fs)&&(fs=null),uc.forEach($y),dc.forEach($y)}function pl(e,t){e.blockedOn===t&&(e.blockedOn=null,sg||(sg=!0,nr.unstable_scheduleCallback(nr.unstable_NormalPriority,h5)))}function hc(e){function t(i){return pl(i,e)}if(0<Pu.length){pl(Pu[0],e);for(var n=1;n<Pu.length;n++){var r=Pu[n];r.blockedOn===e&&(r.blockedOn=null)}}for(ds!==null&&pl(ds,e),hs!==null&&pl(hs,e),fs!==null&&pl(fs,e),uc.forEach(t),dc.forEach(t),n=0;n<is.length;n++)r=is[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<is.length&&(n=is[0],n.blockedOn===null);)LC(n),n.blockedOn===null&&is.shift()}var pa=Li.ReactCurrentBatchConfig,Jd=!0;function f5(e,t,n,r){var i=Je,s=pa.transition;pa.transition=null;try{Je=1,X0(e,t,n,r)}finally{Je=i,pa.transition=s}}function p5(e,t,n,r){var i=Je,s=pa.transition;pa.transition=null;try{Je=4,X0(e,t,n,r)}finally{Je=i,pa.transition=s}}function X0(e,t,n,r){if(Jd){var i=og(e,t,n,r);if(i===null)Cp(e,t,r,eh,n),zy(e,r);else if(d5(i,e,t,n,r))r.stopPropagation();else if(zy(e,r),t&4&&-1<u5.indexOf(e)){for(;i!==null;){var s=Jc(i);if(s!==null&&MC(s),s=og(e,t,n,r),s===null&&Cp(e,t,r,eh,n),s===i)break;i=s}i!==null&&r.stopPropagation()}else Cp(e,t,r,null,n)}}var eh=null;function og(e,t,n,r){if(eh=null,e=V0(r),e=qs(e),e!==null)if(t=wo(e),t===null)e=null;else if(n=t.tag,n===13){if(e=kC(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return eh=e,null}function OC(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(t5()){case q0:return 1;case TC:return 4;case Zd:case n5:return 16;case PC:return 536870912;default:return 16}default:return 16}}var as=null,Y0=null,bd=null;function BC(){if(bd)return bd;var e,t=Y0,n=t.length,r,i="value"in as?as.value:as.textContent,s=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[s-r];r++);return bd=i.slice(e,1<r?1-r:void 0)}function wd(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Iu(){return!0}function Fy(){return!1}function sr(e){function t(n,r,i,s,o){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=s,this.target=o,this.currentTarget=null;for(var a in e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(s):s[a]);return this.isDefaultPrevented=(s.defaultPrevented!=null?s.defaultPrevented:s.returnValue===!1)?Iu:Fy,this.isPropagationStopped=Fy,this}return bt(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Iu)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Iu)},persist:function(){},isPersistent:Iu}),t}var Ua={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Z0=sr(Ua),Qc=bt({},Ua,{view:0,detail:0}),m5=sr(Qc),gp,vp,ml,tf=bt({},Qc,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Q0,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==ml&&(ml&&e.type==="mousemove"?(gp=e.screenX-ml.screenX,vp=e.screenY-ml.screenY):vp=gp=0,ml=e),gp)},movementY:function(e){return"movementY"in e?e.movementY:vp}}),Hy=sr(tf),g5=bt({},tf,{dataTransfer:0}),v5=sr(g5),_5=bt({},Qc,{relatedTarget:0}),_p=sr(_5),x5=bt({},Ua,{animationName:0,elapsedTime:0,pseudoElement:0}),y5=sr(x5),b5=bt({},Ua,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),w5=sr(b5),S5=bt({},Ua,{data:0}),Uy=sr(S5),k5={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},C5={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},E5={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function N5(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=E5[e])?!!t[e]:!1}function Q0(){return N5}var T5=bt({},Qc,{key:function(e){if(e.key){var t=k5[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=wd(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?C5[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Q0,charCode:function(e){return e.type==="keypress"?wd(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?wd(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),P5=sr(T5),I5=bt({},tf,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Wy=sr(I5),R5=bt({},Qc,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Q0}),M5=sr(R5),A5=bt({},Ua,{propertyName:0,elapsedTime:0,pseudoElement:0}),j5=sr(A5),D5=bt({},tf,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),L5=sr(D5),O5=[9,13,27,32],J0=Ni&&"CompositionEvent"in window,ql=null;Ni&&"documentMode"in document&&(ql=document.documentMode);var B5=Ni&&"TextEvent"in window&&!ql,zC=Ni&&(!J0||ql&&8<ql&&11>=ql),Vy=" ",qy=!1;function $C(e,t){switch(e){case"keyup":return O5.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function FC(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Zo=!1;function z5(e,t){switch(e){case"compositionend":return FC(t);case"keypress":return t.which!==32?null:(qy=!0,Vy);case"textInput":return e=t.data,e===Vy&&qy?null:e;default:return null}}function $5(e,t){if(Zo)return e==="compositionend"||!J0&&$C(e,t)?(e=BC(),bd=Y0=as=null,Zo=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return zC&&t.locale!=="ko"?null:t.data;default:return null}}var F5={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Ky(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!F5[e.type]:t==="textarea"}function HC(e,t,n,r){xC(r),t=th(t,"onChange"),0<t.length&&(n=new Z0("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Kl=null,fc=null;function H5(e){JC(e,0)}function nf(e){var t=ea(e);if(hC(t))return e}function U5(e,t){if(e==="change")return t}var UC=!1;if(Ni){var xp;if(Ni){var yp="oninput"in document;if(!yp){var Gy=document.createElement("div");Gy.setAttribute("oninput","return;"),yp=typeof Gy.oninput=="function"}xp=yp}else xp=!1;UC=xp&&(!document.documentMode||9<document.documentMode)}function Xy(){Kl&&(Kl.detachEvent("onpropertychange",WC),fc=Kl=null)}function WC(e){if(e.propertyName==="value"&&nf(fc)){var t=[];HC(t,fc,e,V0(e)),SC(H5,t)}}function W5(e,t,n){e==="focusin"?(Xy(),Kl=t,fc=n,Kl.attachEvent("onpropertychange",WC)):e==="focusout"&&Xy()}function V5(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return nf(fc)}function q5(e,t){if(e==="click")return nf(t)}function K5(e,t){if(e==="input"||e==="change")return nf(t)}function G5(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var jr=typeof Object.is=="function"?Object.is:G5;function pc(e,t){if(jr(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Hm.call(t,i)||!jr(e[i],t[i]))return!1}return!0}function Yy(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Zy(e,t){var n=Yy(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Yy(n)}}function VC(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?VC(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function qC(){for(var e=window,t=Gd();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Gd(e.document)}return t}function e_(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function X5(e){var t=qC(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&VC(n.ownerDocument.documentElement,n)){if(r!==null&&e_(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!e.extend&&s>r&&(i=r,r=s,s=i),i=Zy(n,s);var o=Zy(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var Y5=Ni&&"documentMode"in document&&11>=document.documentMode,Qo=null,ag=null,Gl=null,lg=!1;function Qy(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;lg||Qo==null||Qo!==Gd(r)||(r=Qo,"selectionStart"in r&&e_(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Gl&&pc(Gl,r)||(Gl=r,r=th(ag,"onSelect"),0<r.length&&(t=new Z0("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Qo)))}function Ru(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Jo={animationend:Ru("Animation","AnimationEnd"),animationiteration:Ru("Animation","AnimationIteration"),animationstart:Ru("Animation","AnimationStart"),transitionend:Ru("Transition","TransitionEnd")},bp={},KC={};Ni&&(KC=document.createElement("div").style,"AnimationEvent"in window||(delete Jo.animationend.animation,delete Jo.animationiteration.animation,delete Jo.animationstart.animation),"TransitionEvent"in window||delete Jo.transitionend.transition);function rf(e){if(bp[e])return bp[e];if(!Jo[e])return e;var t=Jo[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in KC)return bp[e]=t[n];return e}var GC=rf("animationend"),XC=rf("animationiteration"),YC=rf("animationstart"),ZC=rf("transitionend"),QC=new Map,Jy="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Ns(e,t){QC.set(e,t),bo(t,[e])}for(var wp=0;wp<Jy.length;wp++){var Sp=Jy[wp],Z5=Sp.toLowerCase(),Q5=Sp[0].toUpperCase()+Sp.slice(1);Ns(Z5,"on"+Q5)}Ns(GC,"onAnimationEnd");Ns(XC,"onAnimationIteration");Ns(YC,"onAnimationStart");Ns("dblclick","onDoubleClick");Ns("focusin","onFocus");Ns("focusout","onBlur");Ns(ZC,"onTransitionEnd");ka("onMouseEnter",["mouseout","mouseover"]);ka("onMouseLeave",["mouseout","mouseover"]);ka("onPointerEnter",["pointerout","pointerover"]);ka("onPointerLeave",["pointerout","pointerover"]);bo("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));bo("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));bo("onBeforeInput",["compositionend","keypress","textInput","paste"]);bo("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));bo("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));bo("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var jl="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),J5=new Set("cancel close invalid load scroll toggle".split(" ").concat(jl));function e1(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,ZA(r,t,void 0,e),e.currentTarget=null}function JC(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var s=void 0;if(t)for(var o=r.length-1;0<=o;o--){var a=r[o],l=a.instance,c=a.currentTarget;if(a=a.listener,l!==s&&i.isPropagationStopped())break e;e1(i,a,c),s=l}else for(o=0;o<r.length;o++){if(a=r[o],l=a.instance,c=a.currentTarget,a=a.listener,l!==s&&i.isPropagationStopped())break e;e1(i,a,c),s=l}}}if(Yd)throw e=rg,Yd=!1,rg=null,e}function ut(e,t){var n=t[fg];n===void 0&&(n=t[fg]=new Set);var r=e+"__bubble";n.has(r)||(e2(t,e,2,!1),n.add(r))}function kp(e,t,n){var r=0;t&&(r|=4),e2(n,e,r,t)}var Mu="_reactListening"+Math.random().toString(36).slice(2);function mc(e){if(!e[Mu]){e[Mu]=!0,aC.forEach(function(n){n!=="selectionchange"&&(J5.has(n)||kp(n,!1,e),kp(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Mu]||(t[Mu]=!0,kp("selectionchange",!1,t))}}function e2(e,t,n,r){switch(OC(t)){case 1:var i=f5;break;case 4:i=p5;break;default:i=X0}n=i.bind(null,t,n,e),i=void 0,!ng||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):i!==void 0?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function Cp(e,t,n,r,i){var s=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var a=r.stateNode.containerInfo;if(a===i||a.nodeType===8&&a.parentNode===i)break;if(o===4)for(o=r.return;o!==null;){var l=o.tag;if((l===3||l===4)&&(l=o.stateNode.containerInfo,l===i||l.nodeType===8&&l.parentNode===i))return;o=o.return}for(;a!==null;){if(o=qs(a),o===null)return;if(l=o.tag,l===5||l===6){r=s=o;continue e}a=a.parentNode}}r=r.return}SC(function(){var c=s,u=V0(n),d=[];e:{var f=QC.get(e);if(f!==void 0){var p=Z0,m=e;switch(e){case"keypress":if(wd(n)===0)break e;case"keydown":case"keyup":p=P5;break;case"focusin":m="focus",p=_p;break;case"focusout":m="blur",p=_p;break;case"beforeblur":case"afterblur":p=_p;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":p=Hy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=v5;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=M5;break;case GC:case XC:case YC:p=y5;break;case ZC:p=j5;break;case"scroll":p=m5;break;case"wheel":p=L5;break;case"copy":case"cut":case"paste":p=w5;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=Wy}var v=(t&4)!==0,y=!v&&e==="scroll",_=v?f!==null?f+"Capture":null:f;v=[];for(var x=c,b;x!==null;){b=x;var w=b.stateNode;if(b.tag===5&&w!==null&&(b=w,_!==null&&(w=cc(x,_),w!=null&&v.push(gc(x,w,b)))),y)break;x=x.return}0<v.length&&(f=new p(f,m,null,n,u),d.push({event:f,listeners:v}))}}if(!(t&7)){e:{if(f=e==="mouseover"||e==="pointerover",p=e==="mouseout"||e==="pointerout",f&&n!==eg&&(m=n.relatedTarget||n.fromElement)&&(qs(m)||m[Ti]))break e;if((p||f)&&(f=u.window===u?u:(f=u.ownerDocument)?f.defaultView||f.parentWindow:window,p?(m=n.relatedTarget||n.toElement,p=c,m=m?qs(m):null,m!==null&&(y=wo(m),m!==y||m.tag!==5&&m.tag!==6)&&(m=null)):(p=null,m=c),p!==m)){if(v=Hy,w="onMouseLeave",_="onMouseEnter",x="mouse",(e==="pointerout"||e==="pointerover")&&(v=Wy,w="onPointerLeave",_="onPointerEnter",x="pointer"),y=p==null?f:ea(p),b=m==null?f:ea(m),f=new v(w,x+"leave",p,n,u),f.target=y,f.relatedTarget=b,w=null,qs(u)===c&&(v=new v(_,x+"enter",m,n,u),v.target=b,v.relatedTarget=y,w=v),y=w,p&&m)t:{for(v=p,_=m,x=0,b=v;b;b=Lo(b))x++;for(b=0,w=_;w;w=Lo(w))b++;for(;0<x-b;)v=Lo(v),x--;for(;0<b-x;)_=Lo(_),b--;for(;x--;){if(v===_||_!==null&&v===_.alternate)break t;v=Lo(v),_=Lo(_)}v=null}else v=null;p!==null&&t1(d,f,p,v,!1),m!==null&&y!==null&&t1(d,y,m,v,!0)}}e:{if(f=c?ea(c):window,p=f.nodeName&&f.nodeName.toLowerCase(),p==="select"||p==="input"&&f.type==="file")var S=U5;else if(Ky(f))if(UC)S=K5;else{S=V5;var k=W5}else(p=f.nodeName)&&p.toLowerCase()==="input"&&(f.type==="checkbox"||f.type==="radio")&&(S=q5);if(S&&(S=S(e,c))){HC(d,S,n,u);break e}k&&k(e,f,c),e==="focusout"&&(k=f._wrapperState)&&k.controlled&&f.type==="number"&&Xm(f,"number",f.value)}switch(k=c?ea(c):window,e){case"focusin":(Ky(k)||k.contentEditable==="true")&&(Qo=k,ag=c,Gl=null);break;case"focusout":Gl=ag=Qo=null;break;case"mousedown":lg=!0;break;case"contextmenu":case"mouseup":case"dragend":lg=!1,Qy(d,n,u);break;case"selectionchange":if(Y5)break;case"keydown":case"keyup":Qy(d,n,u)}var T;if(J0)e:{switch(e){case"compositionstart":var N="onCompositionStart";break e;case"compositionend":N="onCompositionEnd";break e;case"compositionupdate":N="onCompositionUpdate";break e}N=void 0}else Zo?$C(e,n)&&(N="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(N="onCompositionStart");N&&(zC&&n.locale!=="ko"&&(Zo||N!=="onCompositionStart"?N==="onCompositionEnd"&&Zo&&(T=BC()):(as=u,Y0="value"in as?as.value:as.textContent,Zo=!0)),k=th(c,N),0<k.length&&(N=new Uy(N,e,null,n,u),d.push({event:N,listeners:k}),T?N.data=T:(T=FC(n),T!==null&&(N.data=T)))),(T=B5?z5(e,n):$5(e,n))&&(c=th(c,"onBeforeInput"),0<c.length&&(u=new Uy("onBeforeInput","beforeinput",null,n,u),d.push({event:u,listeners:c}),u.data=T))}JC(d,t)})}function gc(e,t,n){return{instance:e,listener:t,currentTarget:n}}function th(e,t){for(var n=t+"Capture",r=[];e!==null;){var i=e,s=i.stateNode;i.tag===5&&s!==null&&(i=s,s=cc(e,n),s!=null&&r.unshift(gc(e,s,i)),s=cc(e,t),s!=null&&r.push(gc(e,s,i))),e=e.return}return r}function Lo(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function t1(e,t,n,r,i){for(var s=t._reactName,o=[];n!==null&&n!==r;){var a=n,l=a.alternate,c=a.stateNode;if(l!==null&&l===r)break;a.tag===5&&c!==null&&(a=c,i?(l=cc(n,s),l!=null&&o.unshift(gc(n,l,a))):i||(l=cc(n,s),l!=null&&o.push(gc(n,l,a)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var ej=/\r\n?/g,tj=/\u0000|\uFFFD/g;function n1(e){return(typeof e=="string"?e:""+e).replace(ej,`
38
- `).replace(tj,"")}function Au(e,t,n){if(t=n1(t),n1(e)!==t&&n)throw Error(G(425))}function nh(){}var cg=null,ug=null;function dg(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var hg=typeof setTimeout=="function"?setTimeout:void 0,nj=typeof clearTimeout=="function"?clearTimeout:void 0,r1=typeof Promise=="function"?Promise:void 0,rj=typeof queueMicrotask=="function"?queueMicrotask:typeof r1<"u"?function(e){return r1.resolve(null).then(e).catch(ij)}:hg;function ij(e){setTimeout(function(){throw e})}function Ep(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"){if(r===0){e.removeChild(i),hc(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=i}while(n);hc(t)}function ps(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function i1(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var Wa=Math.random().toString(36).slice(2),Kr="__reactFiber$"+Wa,vc="__reactProps$"+Wa,Ti="__reactContainer$"+Wa,fg="__reactEvents$"+Wa,sj="__reactListeners$"+Wa,oj="__reactHandles$"+Wa;function qs(e){var t=e[Kr];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ti]||n[Kr]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=i1(e);e!==null;){if(n=e[Kr])return n;e=i1(e)}return t}e=n,n=e.parentNode}return null}function Jc(e){return e=e[Kr]||e[Ti],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ea(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(G(33))}function sf(e){return e[vc]||null}var pg=[],ta=-1;function Ts(e){return{current:e}}function ht(e){0>ta||(e.current=pg[ta],pg[ta]=null,ta--)}function ct(e,t){ta++,pg[ta]=e.current,e.current=t}var ws={},bn=Ts(ws),Hn=Ts(!1),ro=ws;function Ca(e,t){var n=e.type.contextTypes;if(!n)return ws;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Un(e){return e=e.childContextTypes,e!=null}function rh(){ht(Hn),ht(bn)}function s1(e,t,n){if(bn.current!==ws)throw Error(G(168));ct(bn,t),ct(Hn,n)}function t2(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(G(108,WA(e)||"Unknown",i));return bt({},n,r)}function ih(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ws,ro=bn.current,ct(bn,e),ct(Hn,Hn.current),!0}function o1(e,t,n){var r=e.stateNode;if(!r)throw Error(G(169));n?(e=t2(e,t,ro),r.__reactInternalMemoizedMergedChildContext=e,ht(Hn),ht(bn),ct(bn,e)):ht(Hn),ct(Hn,n)}var xi=null,of=!1,Np=!1;function n2(e){xi===null?xi=[e]:xi.push(e)}function aj(e){of=!0,n2(e)}function Ps(){if(!Np&&xi!==null){Np=!0;var e=0,t=Je;try{var n=xi;for(Je=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}xi=null,of=!1}catch(i){throw xi!==null&&(xi=xi.slice(e+1)),NC(q0,Ps),i}finally{Je=t,Np=!1}}return null}var na=[],ra=0,sh=null,oh=0,hr=[],fr=0,io=null,yi=1,bi="";function $s(e,t){na[ra++]=oh,na[ra++]=sh,sh=e,oh=t}function r2(e,t,n){hr[fr++]=yi,hr[fr++]=bi,hr[fr++]=io,io=e;var r=yi;e=bi;var i=32-Ir(r)-1;r&=~(1<<i),n+=1;var s=32-Ir(t)+i;if(30<s){var o=i-i%5;s=(r&(1<<o)-1).toString(32),r>>=o,i-=o,yi=1<<32-Ir(t)+i|n<<i|r,bi=s+e}else yi=1<<s|n<<i|r,bi=e}function t_(e){e.return!==null&&($s(e,1),r2(e,1,0))}function n_(e){for(;e===sh;)sh=na[--ra],na[ra]=null,oh=na[--ra],na[ra]=null;for(;e===io;)io=hr[--fr],hr[fr]=null,bi=hr[--fr],hr[fr]=null,yi=hr[--fr],hr[fr]=null}var Jn=null,Qn=null,ft=!1,Pr=null;function i2(e,t){var n=mr(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function a1(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,Jn=e,Qn=ps(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Jn=e,Qn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=io!==null?{id:yi,overflow:bi}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=mr(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,Jn=e,Qn=null,!0):!1;default:return!1}}function mg(e){return(e.mode&1)!==0&&(e.flags&128)===0}function gg(e){if(ft){var t=Qn;if(t){var n=t;if(!a1(e,t)){if(mg(e))throw Error(G(418));t=ps(n.nextSibling);var r=Jn;t&&a1(e,t)?i2(r,n):(e.flags=e.flags&-4097|2,ft=!1,Jn=e)}}else{if(mg(e))throw Error(G(418));e.flags=e.flags&-4097|2,ft=!1,Jn=e}}}function l1(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Jn=e}function ju(e){if(e!==Jn)return!1;if(!ft)return l1(e),ft=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!dg(e.type,e.memoizedProps)),t&&(t=Qn)){if(mg(e))throw s2(),Error(G(418));for(;t;)i2(e,t),t=ps(t.nextSibling)}if(l1(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(G(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){Qn=ps(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}Qn=null}}else Qn=Jn?ps(e.stateNode.nextSibling):null;return!0}function s2(){for(var e=Qn;e;)e=ps(e.nextSibling)}function Ea(){Qn=Jn=null,ft=!1}function r_(e){Pr===null?Pr=[e]:Pr.push(e)}var lj=Li.ReactCurrentBatchConfig;function gl(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(G(309));var r=n.stateNode}if(!r)throw Error(G(147,e));var i=r,s=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===s?t.ref:(t=function(o){var a=i.refs;o===null?delete a[s]:a[s]=o},t._stringRef=s,t)}if(typeof e!="string")throw Error(G(284));if(!n._owner)throw Error(G(290,e))}return e}function Du(e,t){throw e=Object.prototype.toString.call(t),Error(G(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function c1(e){var t=e._init;return t(e._payload)}function o2(e){function t(_,x){if(e){var b=_.deletions;b===null?(_.deletions=[x],_.flags|=16):b.push(x)}}function n(_,x){if(!e)return null;for(;x!==null;)t(_,x),x=x.sibling;return null}function r(_,x){for(_=new Map;x!==null;)x.key!==null?_.set(x.key,x):_.set(x.index,x),x=x.sibling;return _}function i(_,x){return _=_s(_,x),_.index=0,_.sibling=null,_}function s(_,x,b){return _.index=b,e?(b=_.alternate,b!==null?(b=b.index,b<x?(_.flags|=2,x):b):(_.flags|=2,x)):(_.flags|=1048576,x)}function o(_){return e&&_.alternate===null&&(_.flags|=2),_}function a(_,x,b,w){return x===null||x.tag!==6?(x=jp(b,_.mode,w),x.return=_,x):(x=i(x,b),x.return=_,x)}function l(_,x,b,w){var S=b.type;return S===Yo?u(_,x,b.props.children,w,b.key):x!==null&&(x.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===es&&c1(S)===x.type)?(w=i(x,b.props),w.ref=gl(_,x,b),w.return=_,w):(w=Pd(b.type,b.key,b.props,null,_.mode,w),w.ref=gl(_,x,b),w.return=_,w)}function c(_,x,b,w){return x===null||x.tag!==4||x.stateNode.containerInfo!==b.containerInfo||x.stateNode.implementation!==b.implementation?(x=Dp(b,_.mode,w),x.return=_,x):(x=i(x,b.children||[]),x.return=_,x)}function u(_,x,b,w,S){return x===null||x.tag!==7?(x=Js(b,_.mode,w,S),x.return=_,x):(x=i(x,b),x.return=_,x)}function d(_,x,b){if(typeof x=="string"&&x!==""||typeof x=="number")return x=jp(""+x,_.mode,b),x.return=_,x;if(typeof x=="object"&&x!==null){switch(x.$$typeof){case ku:return b=Pd(x.type,x.key,x.props,null,_.mode,b),b.ref=gl(_,null,x),b.return=_,b;case Xo:return x=Dp(x,_.mode,b),x.return=_,x;case es:var w=x._init;return d(_,w(x._payload),b)}if(Ml(x)||dl(x))return x=Js(x,_.mode,b,null),x.return=_,x;Du(_,x)}return null}function f(_,x,b,w){var S=x!==null?x.key:null;if(typeof b=="string"&&b!==""||typeof b=="number")return S!==null?null:a(_,x,""+b,w);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case ku:return b.key===S?l(_,x,b,w):null;case Xo:return b.key===S?c(_,x,b,w):null;case es:return S=b._init,f(_,x,S(b._payload),w)}if(Ml(b)||dl(b))return S!==null?null:u(_,x,b,w,null);Du(_,b)}return null}function p(_,x,b,w,S){if(typeof w=="string"&&w!==""||typeof w=="number")return _=_.get(b)||null,a(x,_,""+w,S);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case ku:return _=_.get(w.key===null?b:w.key)||null,l(x,_,w,S);case Xo:return _=_.get(w.key===null?b:w.key)||null,c(x,_,w,S);case es:var k=w._init;return p(_,x,b,k(w._payload),S)}if(Ml(w)||dl(w))return _=_.get(b)||null,u(x,_,w,S,null);Du(x,w)}return null}function m(_,x,b,w){for(var S=null,k=null,T=x,N=x=0,L=null;T!==null&&N<b.length;N++){T.index>N?(L=T,T=null):L=T.sibling;var P=f(_,T,b[N],w);if(P===null){T===null&&(T=L);break}e&&T&&P.alternate===null&&t(_,T),x=s(P,x,N),k===null?S=P:k.sibling=P,k=P,T=L}if(N===b.length)return n(_,T),ft&&$s(_,N),S;if(T===null){for(;N<b.length;N++)T=d(_,b[N],w),T!==null&&(x=s(T,x,N),k===null?S=T:k.sibling=T,k=T);return ft&&$s(_,N),S}for(T=r(_,T);N<b.length;N++)L=p(T,_,N,b[N],w),L!==null&&(e&&L.alternate!==null&&T.delete(L.key===null?N:L.key),x=s(L,x,N),k===null?S=L:k.sibling=L,k=L);return e&&T.forEach(function(O){return t(_,O)}),ft&&$s(_,N),S}function v(_,x,b,w){var S=dl(b);if(typeof S!="function")throw Error(G(150));if(b=S.call(b),b==null)throw Error(G(151));for(var k=S=null,T=x,N=x=0,L=null,P=b.next();T!==null&&!P.done;N++,P=b.next()){T.index>N?(L=T,T=null):L=T.sibling;var O=f(_,T,P.value,w);if(O===null){T===null&&(T=L);break}e&&T&&O.alternate===null&&t(_,T),x=s(O,x,N),k===null?S=O:k.sibling=O,k=O,T=L}if(P.done)return n(_,T),ft&&$s(_,N),S;if(T===null){for(;!P.done;N++,P=b.next())P=d(_,P.value,w),P!==null&&(x=s(P,x,N),k===null?S=P:k.sibling=P,k=P);return ft&&$s(_,N),S}for(T=r(_,T);!P.done;N++,P=b.next())P=p(T,_,N,P.value,w),P!==null&&(e&&P.alternate!==null&&T.delete(P.key===null?N:P.key),x=s(P,x,N),k===null?S=P:k.sibling=P,k=P);return e&&T.forEach(function(I){return t(_,I)}),ft&&$s(_,N),S}function y(_,x,b,w){if(typeof b=="object"&&b!==null&&b.type===Yo&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case ku:e:{for(var S=b.key,k=x;k!==null;){if(k.key===S){if(S=b.type,S===Yo){if(k.tag===7){n(_,k.sibling),x=i(k,b.props.children),x.return=_,_=x;break e}}else if(k.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===es&&c1(S)===k.type){n(_,k.sibling),x=i(k,b.props),x.ref=gl(_,k,b),x.return=_,_=x;break e}n(_,k);break}else t(_,k);k=k.sibling}b.type===Yo?(x=Js(b.props.children,_.mode,w,b.key),x.return=_,_=x):(w=Pd(b.type,b.key,b.props,null,_.mode,w),w.ref=gl(_,x,b),w.return=_,_=w)}return o(_);case Xo:e:{for(k=b.key;x!==null;){if(x.key===k)if(x.tag===4&&x.stateNode.containerInfo===b.containerInfo&&x.stateNode.implementation===b.implementation){n(_,x.sibling),x=i(x,b.children||[]),x.return=_,_=x;break e}else{n(_,x);break}else t(_,x);x=x.sibling}x=Dp(b,_.mode,w),x.return=_,_=x}return o(_);case es:return k=b._init,y(_,x,k(b._payload),w)}if(Ml(b))return m(_,x,b,w);if(dl(b))return v(_,x,b,w);Du(_,b)}return typeof b=="string"&&b!==""||typeof b=="number"?(b=""+b,x!==null&&x.tag===6?(n(_,x.sibling),x=i(x,b),x.return=_,_=x):(n(_,x),x=jp(b,_.mode,w),x.return=_,_=x),o(_)):n(_,x)}return y}var Na=o2(!0),a2=o2(!1),ah=Ts(null),lh=null,ia=null,i_=null;function s_(){i_=ia=lh=null}function o_(e){var t=ah.current;ht(ah),e._currentValue=t}function vg(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function ma(e,t){lh=e,i_=ia=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Fn=!0),e.firstContext=null)}function xr(e){var t=e._currentValue;if(i_!==e)if(e={context:e,memoizedValue:t,next:null},ia===null){if(lh===null)throw Error(G(308));ia=e,lh.dependencies={lanes:0,firstContext:e}}else ia=ia.next=e;return t}var Ks=null;function a_(e){Ks===null?Ks=[e]:Ks.push(e)}function l2(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,a_(t)):(n.next=i.next,i.next=n),t.interleaved=n,Pi(e,r)}function Pi(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var ts=!1;function l_(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function c2(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function ki(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ms(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ge&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Pi(e,n)}return i=r.interleaved,i===null?(t.next=t,a_(r)):(t.next=i.next,i.next=t),r.interleaved=t,Pi(e,n)}function Sd(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,K0(e,n)}}function u1(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=t:s=s.next=t}else i=s=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ch(e,t,n,r){var i=e.updateQueue;ts=!1;var s=i.firstBaseUpdate,o=i.lastBaseUpdate,a=i.shared.pending;if(a!==null){i.shared.pending=null;var l=a,c=l.next;l.next=null,o===null?s=c:o.next=c,o=l;var u=e.alternate;u!==null&&(u=u.updateQueue,a=u.lastBaseUpdate,a!==o&&(a===null?u.firstBaseUpdate=c:a.next=c,u.lastBaseUpdate=l))}if(s!==null){var d=i.baseState;o=0,u=c=l=null,a=s;do{var f=a.lane,p=a.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var m=e,v=a;switch(f=t,p=n,v.tag){case 1:if(m=v.payload,typeof m=="function"){d=m.call(p,d,f);break e}d=m;break e;case 3:m.flags=m.flags&-65537|128;case 0:if(m=v.payload,f=typeof m=="function"?m.call(p,d,f):m,f==null)break e;d=bt({},d,f);break e;case 2:ts=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[a]:f.push(a))}else p={eventTime:p,lane:f,tag:a.tag,payload:a.payload,callback:a.callback,next:null},u===null?(c=u=p,l=d):u=u.next=p,o|=f;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;f=a,a=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(!0);if(u===null&&(l=d),i.baseState=l,i.firstBaseUpdate=c,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else s===null&&(i.shared.lanes=0);oo|=o,e.lanes=o,e.memoizedState=d}}function d1(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],i=r.callback;if(i!==null){if(r.callback=null,r=n,typeof i!="function")throw Error(G(191,i));i.call(r)}}}var eu={},Jr=Ts(eu),_c=Ts(eu),xc=Ts(eu);function Gs(e){if(e===eu)throw Error(G(174));return e}function c_(e,t){switch(ct(xc,t),ct(_c,e),ct(Jr,eu),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Zm(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Zm(t,e)}ht(Jr),ct(Jr,t)}function Ta(){ht(Jr),ht(_c),ht(xc)}function u2(e){Gs(xc.current);var t=Gs(Jr.current),n=Zm(t,e.type);t!==n&&(ct(_c,e),ct(Jr,n))}function u_(e){_c.current===e&&(ht(Jr),ht(_c))}var _t=Ts(0);function uh(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Tp=[];function d_(){for(var e=0;e<Tp.length;e++)Tp[e]._workInProgressVersionPrimary=null;Tp.length=0}var kd=Li.ReactCurrentDispatcher,Pp=Li.ReactCurrentBatchConfig,so=0,yt=null,Wt=null,tn=null,dh=!1,Xl=!1,yc=0,cj=0;function mn(){throw Error(G(321))}function h_(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!jr(e[n],t[n]))return!1;return!0}function f_(e,t,n,r,i,s){if(so=s,yt=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,kd.current=e===null||e.memoizedState===null?fj:pj,e=n(r,i),Xl){s=0;do{if(Xl=!1,yc=0,25<=s)throw Error(G(301));s+=1,tn=Wt=null,t.updateQueue=null,kd.current=mj,e=n(r,i)}while(Xl)}if(kd.current=hh,t=Wt!==null&&Wt.next!==null,so=0,tn=Wt=yt=null,dh=!1,t)throw Error(G(300));return e}function p_(){var e=yc!==0;return yc=0,e}function Ur(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return tn===null?yt.memoizedState=tn=e:tn=tn.next=e,tn}function yr(){if(Wt===null){var e=yt.alternate;e=e!==null?e.memoizedState:null}else e=Wt.next;var t=tn===null?yt.memoizedState:tn.next;if(t!==null)tn=t,Wt=e;else{if(e===null)throw Error(G(310));Wt=e,e={memoizedState:Wt.memoizedState,baseState:Wt.baseState,baseQueue:Wt.baseQueue,queue:Wt.queue,next:null},tn===null?yt.memoizedState=tn=e:tn=tn.next=e}return tn}function bc(e,t){return typeof t=="function"?t(e):t}function Ip(e){var t=yr(),n=t.queue;if(n===null)throw Error(G(311));n.lastRenderedReducer=e;var r=Wt,i=r.baseQueue,s=n.pending;if(s!==null){if(i!==null){var o=i.next;i.next=s.next,s.next=o}r.baseQueue=i=s,n.pending=null}if(i!==null){s=i.next,r=r.baseState;var a=o=null,l=null,c=s;do{var u=c.lane;if((so&u)===u)l!==null&&(l=l.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),r=c.hasEagerState?c.eagerState:e(r,c.action);else{var d={lane:u,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};l===null?(a=l=d,o=r):l=l.next=d,yt.lanes|=u,oo|=u}c=c.next}while(c!==null&&c!==s);l===null?o=r:l.next=a,jr(r,t.memoizedState)||(Fn=!0),t.memoizedState=r,t.baseState=o,t.baseQueue=l,n.lastRenderedState=r}if(e=n.interleaved,e!==null){i=e;do s=i.lane,yt.lanes|=s,oo|=s,i=i.next;while(i!==e)}else i===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Rp(e){var t=yr(),n=t.queue;if(n===null)throw Error(G(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,s=t.memoizedState;if(i!==null){n.pending=null;var o=i=i.next;do s=e(s,o.action),o=o.next;while(o!==i);jr(s,t.memoizedState)||(Fn=!0),t.memoizedState=s,t.baseQueue===null&&(t.baseState=s),n.lastRenderedState=s}return[s,r]}function d2(){}function h2(e,t){var n=yt,r=yr(),i=t(),s=!jr(r.memoizedState,i);if(s&&(r.memoizedState=i,Fn=!0),r=r.queue,m_(m2.bind(null,n,r,e),[e]),r.getSnapshot!==t||s||tn!==null&&tn.memoizedState.tag&1){if(n.flags|=2048,wc(9,p2.bind(null,n,r,i,t),void 0,null),on===null)throw Error(G(349));so&30||f2(n,t,i)}return i}function f2(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=yt.updateQueue,t===null?(t={lastEffect:null,stores:null},yt.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function p2(e,t,n,r){t.value=n,t.getSnapshot=r,g2(t)&&v2(e)}function m2(e,t,n){return n(function(){g2(t)&&v2(e)})}function g2(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!jr(e,n)}catch{return!0}}function v2(e){var t=Pi(e,1);t!==null&&Rr(t,e,1,-1)}function h1(e){var t=Ur();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:bc,lastRenderedState:e},t.queue=e,e=e.dispatch=hj.bind(null,yt,e),[t.memoizedState,e]}function wc(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=yt.updateQueue,t===null?(t={lastEffect:null,stores:null},yt.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function _2(){return yr().memoizedState}function Cd(e,t,n,r){var i=Ur();yt.flags|=e,i.memoizedState=wc(1|t,n,void 0,r===void 0?null:r)}function af(e,t,n,r){var i=yr();r=r===void 0?null:r;var s=void 0;if(Wt!==null){var o=Wt.memoizedState;if(s=o.destroy,r!==null&&h_(r,o.deps)){i.memoizedState=wc(t,n,s,r);return}}yt.flags|=e,i.memoizedState=wc(1|t,n,s,r)}function f1(e,t){return Cd(8390656,8,e,t)}function m_(e,t){return af(2048,8,e,t)}function x2(e,t){return af(4,2,e,t)}function y2(e,t){return af(4,4,e,t)}function b2(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function w2(e,t,n){return n=n!=null?n.concat([e]):null,af(4,4,b2.bind(null,t,e),n)}function g_(){}function S2(e,t){var n=yr();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&h_(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function k2(e,t){var n=yr();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&h_(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function C2(e,t,n){return so&21?(jr(n,t)||(n=IC(),yt.lanes|=n,oo|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Fn=!0),e.memoizedState=n)}function uj(e,t){var n=Je;Je=n!==0&&4>n?n:4,e(!0);var r=Pp.transition;Pp.transition={};try{e(!1),t()}finally{Je=n,Pp.transition=r}}function E2(){return yr().memoizedState}function dj(e,t,n){var r=vs(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},N2(e))T2(t,n);else if(n=l2(e,t,n,r),n!==null){var i=Nn();Rr(n,e,r,i),P2(n,t,r)}}function hj(e,t,n){var r=vs(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(N2(e))T2(t,i);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var o=t.lastRenderedState,a=s(o,n);if(i.hasEagerState=!0,i.eagerState=a,jr(a,o)){var l=t.interleaved;l===null?(i.next=i,a_(t)):(i.next=l.next,l.next=i),t.interleaved=i;return}}catch{}finally{}n=l2(e,t,i,r),n!==null&&(i=Nn(),Rr(n,e,r,i),P2(n,t,r))}}function N2(e){var t=e.alternate;return e===yt||t!==null&&t===yt}function T2(e,t){Xl=dh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function P2(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,K0(e,n)}}var hh={readContext:xr,useCallback:mn,useContext:mn,useEffect:mn,useImperativeHandle:mn,useInsertionEffect:mn,useLayoutEffect:mn,useMemo:mn,useReducer:mn,useRef:mn,useState:mn,useDebugValue:mn,useDeferredValue:mn,useTransition:mn,useMutableSource:mn,useSyncExternalStore:mn,useId:mn,unstable_isNewReconciler:!1},fj={readContext:xr,useCallback:function(e,t){return Ur().memoizedState=[e,t===void 0?null:t],e},useContext:xr,useEffect:f1,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Cd(4194308,4,b2.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Cd(4194308,4,e,t)},useInsertionEffect:function(e,t){return Cd(4,2,e,t)},useMemo:function(e,t){var n=Ur();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ur();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=dj.bind(null,yt,e),[r.memoizedState,e]},useRef:function(e){var t=Ur();return e={current:e},t.memoizedState=e},useState:h1,useDebugValue:g_,useDeferredValue:function(e){return Ur().memoizedState=e},useTransition:function(){var e=h1(!1),t=e[0];return e=uj.bind(null,e[1]),Ur().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=yt,i=Ur();if(ft){if(n===void 0)throw Error(G(407));n=n()}else{if(n=t(),on===null)throw Error(G(349));so&30||f2(r,t,n)}i.memoizedState=n;var s={value:n,getSnapshot:t};return i.queue=s,f1(m2.bind(null,r,s,e),[e]),r.flags|=2048,wc(9,p2.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=Ur(),t=on.identifierPrefix;if(ft){var n=bi,r=yi;n=(r&~(1<<32-Ir(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=yc++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=cj++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},pj={readContext:xr,useCallback:S2,useContext:xr,useEffect:m_,useImperativeHandle:w2,useInsertionEffect:x2,useLayoutEffect:y2,useMemo:k2,useReducer:Ip,useRef:_2,useState:function(){return Ip(bc)},useDebugValue:g_,useDeferredValue:function(e){var t=yr();return C2(t,Wt.memoizedState,e)},useTransition:function(){var e=Ip(bc)[0],t=yr().memoizedState;return[e,t]},useMutableSource:d2,useSyncExternalStore:h2,useId:E2,unstable_isNewReconciler:!1},mj={readContext:xr,useCallback:S2,useContext:xr,useEffect:m_,useImperativeHandle:w2,useInsertionEffect:x2,useLayoutEffect:y2,useMemo:k2,useReducer:Rp,useRef:_2,useState:function(){return Rp(bc)},useDebugValue:g_,useDeferredValue:function(e){var t=yr();return Wt===null?t.memoizedState=e:C2(t,Wt.memoizedState,e)},useTransition:function(){var e=Rp(bc)[0],t=yr().memoizedState;return[e,t]},useMutableSource:d2,useSyncExternalStore:h2,useId:E2,unstable_isNewReconciler:!1};function Er(e,t){if(e&&e.defaultProps){t=bt({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function _g(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:bt({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var lf={isMounted:function(e){return(e=e._reactInternals)?wo(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Nn(),i=vs(e),s=ki(r,i);s.payload=t,n!=null&&(s.callback=n),t=ms(e,s,i),t!==null&&(Rr(t,e,i,r),Sd(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Nn(),i=vs(e),s=ki(r,i);s.tag=1,s.payload=t,n!=null&&(s.callback=n),t=ms(e,s,i),t!==null&&(Rr(t,e,i,r),Sd(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Nn(),r=vs(e),i=ki(n,r);i.tag=2,t!=null&&(i.callback=t),t=ms(e,i,r),t!==null&&(Rr(t,e,r,n),Sd(t,e,r))}};function p1(e,t,n,r,i,s,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,s,o):t.prototype&&t.prototype.isPureReactComponent?!pc(n,r)||!pc(i,s):!0}function I2(e,t,n){var r=!1,i=ws,s=t.contextType;return typeof s=="object"&&s!==null?s=xr(s):(i=Un(t)?ro:bn.current,r=t.contextTypes,s=(r=r!=null)?Ca(e,i):ws),t=new t(n,s),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=lf,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=s),t}function m1(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&lf.enqueueReplaceState(t,t.state,null)}function xg(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},l_(e);var s=t.contextType;typeof s=="object"&&s!==null?i.context=xr(s):(s=Un(t)?ro:bn.current,i.context=Ca(e,s)),i.state=e.memoizedState,s=t.getDerivedStateFromProps,typeof s=="function"&&(_g(e,t,s,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(t=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),t!==i.state&&lf.enqueueReplaceState(i,i.state,null),ch(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function Pa(e,t){try{var n="",r=t;do n+=UA(r),r=r.return;while(r);var i=n}catch(s){i=`
37
+ `+i[o].replace(" at new "," at ");return e.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",e.displayName)),l}while(1<=o&&0<=a);break}}}finally{hp=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Rl(e):""}function UA(e){switch(e.tag){case 5:return Rl(e.type);case 16:return Rl("Lazy");case 13:return Rl("Suspense");case 19:return Rl("SuspenseList");case 0:case 2:case 15:return e=fp(e.type,!1),e;case 11:return e=fp(e.type.render,!1),e;case 1:return e=fp(e.type,!0),e;default:return""}}function qm(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Yo:return"Fragment";case Xo:return"Portal";case Um:return"Profiler";case H0:return"StrictMode";case Wm:return"Suspense";case Vm:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case cC:return(e.displayName||"Context")+".Consumer";case lC:return(e._context.displayName||"Context")+".Provider";case U0:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case W0:return t=e.displayName||null,t!==null?t:qm(e.type)||"Memo";case es:t=e._payload,e=e._init;try{return qm(e(t))}catch{}}return null}function WA(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return qm(t);case 8:return t===H0?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function bs(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function dC(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function VA(e){var t=dC(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Cu(e){e._valueTracker||(e._valueTracker=VA(e))}function hC(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=dC(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Gd(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Km(e,t){var n=t.checked;return bt({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function My(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=bs(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function fC(e,t){t=t.checked,t!=null&&F0(e,"checked",t,!1)}function Gm(e,t){fC(e,t);var n=bs(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Xm(e,t.type,n):t.hasOwnProperty("defaultValue")&&Xm(e,t.type,bs(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Ay(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Xm(e,t,n){(t!=="number"||Gd(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Ml=Array.isArray;function da(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+bs(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Ym(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(G(91));return bt({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function jy(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(G(92));if(Ml(n)){if(1<n.length)throw Error(G(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:bs(n)}}function pC(e,t){var n=bs(t.value),r=bs(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function Dy(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function mC(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Zm(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?mC(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Eu,gC=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Eu=Eu||document.createElement("div"),Eu.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Eu.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function lc(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Wl={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},qA=["Webkit","ms","Moz","O"];Object.keys(Wl).forEach(function(e){qA.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Wl[t]=Wl[e]})});function vC(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Wl.hasOwnProperty(e)&&Wl[e]?(""+t).trim():t+"px"}function _C(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=vC(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var KA=bt({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Qm(e,t){if(t){if(KA[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(G(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(G(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(G(61))}if(t.style!=null&&typeof t.style!="object")throw Error(G(62))}}function Jm(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var eg=null;function V0(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var tg=null,ha=null,fa=null;function Ly(e){if(e=Jc(e)){if(typeof tg!="function")throw Error(G(280));var t=e.stateNode;t&&(t=sf(t),tg(e.stateNode,e.type,t))}}function xC(e){ha?fa?fa.push(e):fa=[e]:ha=e}function yC(){if(ha){var e=ha,t=fa;if(fa=ha=null,Ly(e),t)for(e=0;e<t.length;e++)Ly(t[e])}}function bC(e,t){return e(t)}function wC(){}var pp=!1;function SC(e,t,n){if(pp)return e(t,n);pp=!0;try{return bC(e,t,n)}finally{pp=!1,(ha!==null||fa!==null)&&(wC(),yC())}}function cc(e,t){var n=e.stateNode;if(n===null)return null;var r=sf(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(G(231,t,typeof n));return n}var ng=!1;if(Ni)try{var hl={};Object.defineProperty(hl,"passive",{get:function(){ng=!0}}),window.addEventListener("test",hl,hl),window.removeEventListener("test",hl,hl)}catch{ng=!1}function GA(e,t,n,r,i,s,o,a,l){var c=Array.prototype.slice.call(arguments,3);try{t.apply(n,c)}catch(u){this.onError(u)}}var Vl=!1,Xd=null,Yd=!1,rg=null,XA={onError:function(e){Vl=!0,Xd=e}};function YA(e,t,n,r,i,s,o,a,l){Vl=!1,Xd=null,GA.apply(XA,arguments)}function ZA(e,t,n,r,i,s,o,a,l){if(YA.apply(this,arguments),Vl){if(Vl){var c=Xd;Vl=!1,Xd=null}else throw Error(G(198));Yd||(Yd=!0,rg=c)}}function wo(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function kC(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Oy(e){if(wo(e)!==e)throw Error(G(188))}function QA(e){var t=e.alternate;if(!t){if(t=wo(e),t===null)throw Error(G(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var s=i.alternate;if(s===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===s.child){for(s=i.child;s;){if(s===n)return Oy(i),e;if(s===r)return Oy(i),t;s=s.sibling}throw Error(G(188))}if(n.return!==r.return)n=i,r=s;else{for(var o=!1,a=i.child;a;){if(a===n){o=!0,n=i,r=s;break}if(a===r){o=!0,r=i,n=s;break}a=a.sibling}if(!o){for(a=s.child;a;){if(a===n){o=!0,n=s,r=i;break}if(a===r){o=!0,r=s,n=i;break}a=a.sibling}if(!o)throw Error(G(189))}}if(n.alternate!==r)throw Error(G(190))}if(n.tag!==3)throw Error(G(188));return n.stateNode.current===n?e:t}function CC(e){return e=QA(e),e!==null?EC(e):null}function EC(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=EC(e);if(t!==null)return t;e=e.sibling}return null}var NC=nr.unstable_scheduleCallback,By=nr.unstable_cancelCallback,JA=nr.unstable_shouldYield,e5=nr.unstable_requestPaint,It=nr.unstable_now,t5=nr.unstable_getCurrentPriorityLevel,q0=nr.unstable_ImmediatePriority,TC=nr.unstable_UserBlockingPriority,Zd=nr.unstable_NormalPriority,n5=nr.unstable_LowPriority,PC=nr.unstable_IdlePriority,ef=null,Qr=null;function r5(e){if(Qr&&typeof Qr.onCommitFiberRoot=="function")try{Qr.onCommitFiberRoot(ef,e,void 0,(e.current.flags&128)===128)}catch{}}var Ir=Math.clz32?Math.clz32:o5,i5=Math.log,s5=Math.LN2;function o5(e){return e>>>=0,e===0?32:31-(i5(e)/s5|0)|0}var Nu=64,Tu=4194304;function Al(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64: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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Qd(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,s=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~i;a!==0?r=Al(a):(s&=o,s!==0&&(r=Al(s)))}else o=n&~i,o!==0?r=Al(o):s!==0&&(r=Al(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,s=t&-t,i>=s||i===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Ir(t),i=1<<n,r|=e[n],t&=~i;return r}function a5(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function l5(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,s=e.pendingLanes;0<s;){var o=31-Ir(s),a=1<<o,l=i[o];l===-1?(!(a&n)||a&r)&&(i[o]=a5(a,t)):l<=t&&(e.expiredLanes|=a),s&=~a}}function ig(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function IC(){var e=Nu;return Nu<<=1,!(Nu&4194240)&&(Nu=64),e}function mp(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Zc(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ir(t),e[t]=n}function c5(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var i=31-Ir(n),s=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~s}}function K0(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ir(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var et=0;function RC(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var MC,G0,AC,jC,DC,sg=!1,Pu=[],ds=null,hs=null,fs=null,uc=new Map,dc=new Map,is=[],u5="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function zy(e,t){switch(e){case"focusin":case"focusout":ds=null;break;case"dragenter":case"dragleave":hs=null;break;case"mouseover":case"mouseout":fs=null;break;case"pointerover":case"pointerout":uc.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":dc.delete(t.pointerId)}}function fl(e,t,n,r,i,s){return e===null||e.nativeEvent!==s?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:s,targetContainers:[i]},t!==null&&(t=Jc(t),t!==null&&G0(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function d5(e,t,n,r,i){switch(t){case"focusin":return ds=fl(ds,e,t,n,r,i),!0;case"dragenter":return hs=fl(hs,e,t,n,r,i),!0;case"mouseover":return fs=fl(fs,e,t,n,r,i),!0;case"pointerover":var s=i.pointerId;return uc.set(s,fl(uc.get(s)||null,e,t,n,r,i)),!0;case"gotpointercapture":return s=i.pointerId,dc.set(s,fl(dc.get(s)||null,e,t,n,r,i)),!0}return!1}function LC(e){var t=qs(e.target);if(t!==null){var n=wo(t);if(n!==null){if(t=n.tag,t===13){if(t=kC(n),t!==null){e.blockedOn=t,DC(e.priority,function(){AC(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function yd(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=og(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);eg=r,n.target.dispatchEvent(r),eg=null}else return t=Jc(n),t!==null&&G0(t),e.blockedOn=n,!1;t.shift()}return!0}function $y(e,t,n){yd(e)&&n.delete(t)}function h5(){sg=!1,ds!==null&&yd(ds)&&(ds=null),hs!==null&&yd(hs)&&(hs=null),fs!==null&&yd(fs)&&(fs=null),uc.forEach($y),dc.forEach($y)}function pl(e,t){e.blockedOn===t&&(e.blockedOn=null,sg||(sg=!0,nr.unstable_scheduleCallback(nr.unstable_NormalPriority,h5)))}function hc(e){function t(i){return pl(i,e)}if(0<Pu.length){pl(Pu[0],e);for(var n=1;n<Pu.length;n++){var r=Pu[n];r.blockedOn===e&&(r.blockedOn=null)}}for(ds!==null&&pl(ds,e),hs!==null&&pl(hs,e),fs!==null&&pl(fs,e),uc.forEach(t),dc.forEach(t),n=0;n<is.length;n++)r=is[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<is.length&&(n=is[0],n.blockedOn===null);)LC(n),n.blockedOn===null&&is.shift()}var pa=Li.ReactCurrentBatchConfig,Jd=!0;function f5(e,t,n,r){var i=et,s=pa.transition;pa.transition=null;try{et=1,X0(e,t,n,r)}finally{et=i,pa.transition=s}}function p5(e,t,n,r){var i=et,s=pa.transition;pa.transition=null;try{et=4,X0(e,t,n,r)}finally{et=i,pa.transition=s}}function X0(e,t,n,r){if(Jd){var i=og(e,t,n,r);if(i===null)Cp(e,t,r,eh,n),zy(e,r);else if(d5(i,e,t,n,r))r.stopPropagation();else if(zy(e,r),t&4&&-1<u5.indexOf(e)){for(;i!==null;){var s=Jc(i);if(s!==null&&MC(s),s=og(e,t,n,r),s===null&&Cp(e,t,r,eh,n),s===i)break;i=s}i!==null&&r.stopPropagation()}else Cp(e,t,r,null,n)}}var eh=null;function og(e,t,n,r){if(eh=null,e=V0(r),e=qs(e),e!==null)if(t=wo(e),t===null)e=null;else if(n=t.tag,n===13){if(e=kC(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return eh=e,null}function OC(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(t5()){case q0:return 1;case TC:return 4;case Zd:case n5:return 16;case PC:return 536870912;default:return 16}default:return 16}}var as=null,Y0=null,bd=null;function BC(){if(bd)return bd;var e,t=Y0,n=t.length,r,i="value"in as?as.value:as.textContent,s=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[s-r];r++);return bd=i.slice(e,1<r?1-r:void 0)}function wd(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Iu(){return!0}function Fy(){return!1}function sr(e){function t(n,r,i,s,o){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=s,this.target=o,this.currentTarget=null;for(var a in e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(s):s[a]);return this.isDefaultPrevented=(s.defaultPrevented!=null?s.defaultPrevented:s.returnValue===!1)?Iu:Fy,this.isPropagationStopped=Fy,this}return bt(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Iu)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Iu)},persist:function(){},isPersistent:Iu}),t}var Ua={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Z0=sr(Ua),Qc=bt({},Ua,{view:0,detail:0}),m5=sr(Qc),gp,vp,ml,tf=bt({},Qc,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Q0,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==ml&&(ml&&e.type==="mousemove"?(gp=e.screenX-ml.screenX,vp=e.screenY-ml.screenY):vp=gp=0,ml=e),gp)},movementY:function(e){return"movementY"in e?e.movementY:vp}}),Hy=sr(tf),g5=bt({},tf,{dataTransfer:0}),v5=sr(g5),_5=bt({},Qc,{relatedTarget:0}),_p=sr(_5),x5=bt({},Ua,{animationName:0,elapsedTime:0,pseudoElement:0}),y5=sr(x5),b5=bt({},Ua,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),w5=sr(b5),S5=bt({},Ua,{data:0}),Uy=sr(S5),k5={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},C5={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},E5={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function N5(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=E5[e])?!!t[e]:!1}function Q0(){return N5}var T5=bt({},Qc,{key:function(e){if(e.key){var t=k5[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=wd(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?C5[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Q0,charCode:function(e){return e.type==="keypress"?wd(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?wd(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),P5=sr(T5),I5=bt({},tf,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Wy=sr(I5),R5=bt({},Qc,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Q0}),M5=sr(R5),A5=bt({},Ua,{propertyName:0,elapsedTime:0,pseudoElement:0}),j5=sr(A5),D5=bt({},tf,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),L5=sr(D5),O5=[9,13,27,32],J0=Ni&&"CompositionEvent"in window,ql=null;Ni&&"documentMode"in document&&(ql=document.documentMode);var B5=Ni&&"TextEvent"in window&&!ql,zC=Ni&&(!J0||ql&&8<ql&&11>=ql),Vy=" ",qy=!1;function $C(e,t){switch(e){case"keyup":return O5.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function FC(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Zo=!1;function z5(e,t){switch(e){case"compositionend":return FC(t);case"keypress":return t.which!==32?null:(qy=!0,Vy);case"textInput":return e=t.data,e===Vy&&qy?null:e;default:return null}}function $5(e,t){if(Zo)return e==="compositionend"||!J0&&$C(e,t)?(e=BC(),bd=Y0=as=null,Zo=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return zC&&t.locale!=="ko"?null:t.data;default:return null}}var F5={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Ky(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!F5[e.type]:t==="textarea"}function HC(e,t,n,r){xC(r),t=th(t,"onChange"),0<t.length&&(n=new Z0("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Kl=null,fc=null;function H5(e){JC(e,0)}function nf(e){var t=ea(e);if(hC(t))return e}function U5(e,t){if(e==="change")return t}var UC=!1;if(Ni){var xp;if(Ni){var yp="oninput"in document;if(!yp){var Gy=document.createElement("div");Gy.setAttribute("oninput","return;"),yp=typeof Gy.oninput=="function"}xp=yp}else xp=!1;UC=xp&&(!document.documentMode||9<document.documentMode)}function Xy(){Kl&&(Kl.detachEvent("onpropertychange",WC),fc=Kl=null)}function WC(e){if(e.propertyName==="value"&&nf(fc)){var t=[];HC(t,fc,e,V0(e)),SC(H5,t)}}function W5(e,t,n){e==="focusin"?(Xy(),Kl=t,fc=n,Kl.attachEvent("onpropertychange",WC)):e==="focusout"&&Xy()}function V5(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return nf(fc)}function q5(e,t){if(e==="click")return nf(t)}function K5(e,t){if(e==="input"||e==="change")return nf(t)}function G5(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var jr=typeof Object.is=="function"?Object.is:G5;function pc(e,t){if(jr(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Hm.call(t,i)||!jr(e[i],t[i]))return!1}return!0}function Yy(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Zy(e,t){var n=Yy(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Yy(n)}}function VC(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?VC(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function qC(){for(var e=window,t=Gd();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Gd(e.document)}return t}function e_(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function X5(e){var t=qC(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&VC(n.ownerDocument.documentElement,n)){if(r!==null&&e_(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!e.extend&&s>r&&(i=r,r=s,s=i),i=Zy(n,s);var o=Zy(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var Y5=Ni&&"documentMode"in document&&11>=document.documentMode,Qo=null,ag=null,Gl=null,lg=!1;function Qy(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;lg||Qo==null||Qo!==Gd(r)||(r=Qo,"selectionStart"in r&&e_(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Gl&&pc(Gl,r)||(Gl=r,r=th(ag,"onSelect"),0<r.length&&(t=new Z0("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Qo)))}function Ru(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Jo={animationend:Ru("Animation","AnimationEnd"),animationiteration:Ru("Animation","AnimationIteration"),animationstart:Ru("Animation","AnimationStart"),transitionend:Ru("Transition","TransitionEnd")},bp={},KC={};Ni&&(KC=document.createElement("div").style,"AnimationEvent"in window||(delete Jo.animationend.animation,delete Jo.animationiteration.animation,delete Jo.animationstart.animation),"TransitionEvent"in window||delete Jo.transitionend.transition);function rf(e){if(bp[e])return bp[e];if(!Jo[e])return e;var t=Jo[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in KC)return bp[e]=t[n];return e}var GC=rf("animationend"),XC=rf("animationiteration"),YC=rf("animationstart"),ZC=rf("transitionend"),QC=new Map,Jy="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Ns(e,t){QC.set(e,t),bo(t,[e])}for(var wp=0;wp<Jy.length;wp++){var Sp=Jy[wp],Z5=Sp.toLowerCase(),Q5=Sp[0].toUpperCase()+Sp.slice(1);Ns(Z5,"on"+Q5)}Ns(GC,"onAnimationEnd");Ns(XC,"onAnimationIteration");Ns(YC,"onAnimationStart");Ns("dblclick","onDoubleClick");Ns("focusin","onFocus");Ns("focusout","onBlur");Ns(ZC,"onTransitionEnd");ka("onMouseEnter",["mouseout","mouseover"]);ka("onMouseLeave",["mouseout","mouseover"]);ka("onPointerEnter",["pointerout","pointerover"]);ka("onPointerLeave",["pointerout","pointerover"]);bo("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));bo("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));bo("onBeforeInput",["compositionend","keypress","textInput","paste"]);bo("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));bo("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));bo("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var jl="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),J5=new Set("cancel close invalid load scroll toggle".split(" ").concat(jl));function e1(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,ZA(r,t,void 0,e),e.currentTarget=null}function JC(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var s=void 0;if(t)for(var o=r.length-1;0<=o;o--){var a=r[o],l=a.instance,c=a.currentTarget;if(a=a.listener,l!==s&&i.isPropagationStopped())break e;e1(i,a,c),s=l}else for(o=0;o<r.length;o++){if(a=r[o],l=a.instance,c=a.currentTarget,a=a.listener,l!==s&&i.isPropagationStopped())break e;e1(i,a,c),s=l}}}if(Yd)throw e=rg,Yd=!1,rg=null,e}function ut(e,t){var n=t[fg];n===void 0&&(n=t[fg]=new Set);var r=e+"__bubble";n.has(r)||(e2(t,e,2,!1),n.add(r))}function kp(e,t,n){var r=0;t&&(r|=4),e2(n,e,r,t)}var Mu="_reactListening"+Math.random().toString(36).slice(2);function mc(e){if(!e[Mu]){e[Mu]=!0,aC.forEach(function(n){n!=="selectionchange"&&(J5.has(n)||kp(n,!1,e),kp(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Mu]||(t[Mu]=!0,kp("selectionchange",!1,t))}}function e2(e,t,n,r){switch(OC(t)){case 1:var i=f5;break;case 4:i=p5;break;default:i=X0}n=i.bind(null,t,n,e),i=void 0,!ng||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):i!==void 0?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function Cp(e,t,n,r,i){var s=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var a=r.stateNode.containerInfo;if(a===i||a.nodeType===8&&a.parentNode===i)break;if(o===4)for(o=r.return;o!==null;){var l=o.tag;if((l===3||l===4)&&(l=o.stateNode.containerInfo,l===i||l.nodeType===8&&l.parentNode===i))return;o=o.return}for(;a!==null;){if(o=qs(a),o===null)return;if(l=o.tag,l===5||l===6){r=s=o;continue e}a=a.parentNode}}r=r.return}SC(function(){var c=s,u=V0(n),d=[];e:{var f=QC.get(e);if(f!==void 0){var p=Z0,m=e;switch(e){case"keypress":if(wd(n)===0)break e;case"keydown":case"keyup":p=P5;break;case"focusin":m="focus",p=_p;break;case"focusout":m="blur",p=_p;break;case"beforeblur":case"afterblur":p=_p;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":p=Hy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=v5;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=M5;break;case GC:case XC:case YC:p=y5;break;case ZC:p=j5;break;case"scroll":p=m5;break;case"wheel":p=L5;break;case"copy":case"cut":case"paste":p=w5;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=Wy}var v=(t&4)!==0,y=!v&&e==="scroll",_=v?f!==null?f+"Capture":null:f;v=[];for(var x=c,b;x!==null;){b=x;var w=b.stateNode;if(b.tag===5&&w!==null&&(b=w,_!==null&&(w=cc(x,_),w!=null&&v.push(gc(x,w,b)))),y)break;x=x.return}0<v.length&&(f=new p(f,m,null,n,u),d.push({event:f,listeners:v}))}}if(!(t&7)){e:{if(f=e==="mouseover"||e==="pointerover",p=e==="mouseout"||e==="pointerout",f&&n!==eg&&(m=n.relatedTarget||n.fromElement)&&(qs(m)||m[Ti]))break e;if((p||f)&&(f=u.window===u?u:(f=u.ownerDocument)?f.defaultView||f.parentWindow:window,p?(m=n.relatedTarget||n.toElement,p=c,m=m?qs(m):null,m!==null&&(y=wo(m),m!==y||m.tag!==5&&m.tag!==6)&&(m=null)):(p=null,m=c),p!==m)){if(v=Hy,w="onMouseLeave",_="onMouseEnter",x="mouse",(e==="pointerout"||e==="pointerover")&&(v=Wy,w="onPointerLeave",_="onPointerEnter",x="pointer"),y=p==null?f:ea(p),b=m==null?f:ea(m),f=new v(w,x+"leave",p,n,u),f.target=y,f.relatedTarget=b,w=null,qs(u)===c&&(v=new v(_,x+"enter",m,n,u),v.target=b,v.relatedTarget=y,w=v),y=w,p&&m)t:{for(v=p,_=m,x=0,b=v;b;b=Lo(b))x++;for(b=0,w=_;w;w=Lo(w))b++;for(;0<x-b;)v=Lo(v),x--;for(;0<b-x;)_=Lo(_),b--;for(;x--;){if(v===_||_!==null&&v===_.alternate)break t;v=Lo(v),_=Lo(_)}v=null}else v=null;p!==null&&t1(d,f,p,v,!1),m!==null&&y!==null&&t1(d,y,m,v,!0)}}e:{if(f=c?ea(c):window,p=f.nodeName&&f.nodeName.toLowerCase(),p==="select"||p==="input"&&f.type==="file")var S=U5;else if(Ky(f))if(UC)S=K5;else{S=V5;var k=W5}else(p=f.nodeName)&&p.toLowerCase()==="input"&&(f.type==="checkbox"||f.type==="radio")&&(S=q5);if(S&&(S=S(e,c))){HC(d,S,n,u);break e}k&&k(e,f,c),e==="focusout"&&(k=f._wrapperState)&&k.controlled&&f.type==="number"&&Xm(f,"number",f.value)}switch(k=c?ea(c):window,e){case"focusin":(Ky(k)||k.contentEditable==="true")&&(Qo=k,ag=c,Gl=null);break;case"focusout":Gl=ag=Qo=null;break;case"mousedown":lg=!0;break;case"contextmenu":case"mouseup":case"dragend":lg=!1,Qy(d,n,u);break;case"selectionchange":if(Y5)break;case"keydown":case"keyup":Qy(d,n,u)}var T;if(J0)e:{switch(e){case"compositionstart":var N="onCompositionStart";break e;case"compositionend":N="onCompositionEnd";break e;case"compositionupdate":N="onCompositionUpdate";break e}N=void 0}else Zo?$C(e,n)&&(N="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(N="onCompositionStart");N&&(zC&&n.locale!=="ko"&&(Zo||N!=="onCompositionStart"?N==="onCompositionEnd"&&Zo&&(T=BC()):(as=u,Y0="value"in as?as.value:as.textContent,Zo=!0)),k=th(c,N),0<k.length&&(N=new Uy(N,e,null,n,u),d.push({event:N,listeners:k}),T?N.data=T:(T=FC(n),T!==null&&(N.data=T)))),(T=B5?z5(e,n):$5(e,n))&&(c=th(c,"onBeforeInput"),0<c.length&&(u=new Uy("onBeforeInput","beforeinput",null,n,u),d.push({event:u,listeners:c}),u.data=T))}JC(d,t)})}function gc(e,t,n){return{instance:e,listener:t,currentTarget:n}}function th(e,t){for(var n=t+"Capture",r=[];e!==null;){var i=e,s=i.stateNode;i.tag===5&&s!==null&&(i=s,s=cc(e,n),s!=null&&r.unshift(gc(e,s,i)),s=cc(e,t),s!=null&&r.push(gc(e,s,i))),e=e.return}return r}function Lo(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function t1(e,t,n,r,i){for(var s=t._reactName,o=[];n!==null&&n!==r;){var a=n,l=a.alternate,c=a.stateNode;if(l!==null&&l===r)break;a.tag===5&&c!==null&&(a=c,i?(l=cc(n,s),l!=null&&o.unshift(gc(n,l,a))):i||(l=cc(n,s),l!=null&&o.push(gc(n,l,a)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var ej=/\r\n?/g,tj=/\u0000|\uFFFD/g;function n1(e){return(typeof e=="string"?e:""+e).replace(ej,`
38
+ `).replace(tj,"")}function Au(e,t,n){if(t=n1(t),n1(e)!==t&&n)throw Error(G(425))}function nh(){}var cg=null,ug=null;function dg(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var hg=typeof setTimeout=="function"?setTimeout:void 0,nj=typeof clearTimeout=="function"?clearTimeout:void 0,r1=typeof Promise=="function"?Promise:void 0,rj=typeof queueMicrotask=="function"?queueMicrotask:typeof r1<"u"?function(e){return r1.resolve(null).then(e).catch(ij)}:hg;function ij(e){setTimeout(function(){throw e})}function Ep(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"){if(r===0){e.removeChild(i),hc(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=i}while(n);hc(t)}function ps(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function i1(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var Wa=Math.random().toString(36).slice(2),Kr="__reactFiber$"+Wa,vc="__reactProps$"+Wa,Ti="__reactContainer$"+Wa,fg="__reactEvents$"+Wa,sj="__reactListeners$"+Wa,oj="__reactHandles$"+Wa;function qs(e){var t=e[Kr];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ti]||n[Kr]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=i1(e);e!==null;){if(n=e[Kr])return n;e=i1(e)}return t}e=n,n=e.parentNode}return null}function Jc(e){return e=e[Kr]||e[Ti],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ea(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(G(33))}function sf(e){return e[vc]||null}var pg=[],ta=-1;function Ts(e){return{current:e}}function ht(e){0>ta||(e.current=pg[ta],pg[ta]=null,ta--)}function ct(e,t){ta++,pg[ta]=e.current,e.current=t}var ws={},bn=Ts(ws),Hn=Ts(!1),ro=ws;function Ca(e,t){var n=e.type.contextTypes;if(!n)return ws;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Un(e){return e=e.childContextTypes,e!=null}function rh(){ht(Hn),ht(bn)}function s1(e,t,n){if(bn.current!==ws)throw Error(G(168));ct(bn,t),ct(Hn,n)}function t2(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(G(108,WA(e)||"Unknown",i));return bt({},n,r)}function ih(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ws,ro=bn.current,ct(bn,e),ct(Hn,Hn.current),!0}function o1(e,t,n){var r=e.stateNode;if(!r)throw Error(G(169));n?(e=t2(e,t,ro),r.__reactInternalMemoizedMergedChildContext=e,ht(Hn),ht(bn),ct(bn,e)):ht(Hn),ct(Hn,n)}var xi=null,of=!1,Np=!1;function n2(e){xi===null?xi=[e]:xi.push(e)}function aj(e){of=!0,n2(e)}function Ps(){if(!Np&&xi!==null){Np=!0;var e=0,t=et;try{var n=xi;for(et=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}xi=null,of=!1}catch(i){throw xi!==null&&(xi=xi.slice(e+1)),NC(q0,Ps),i}finally{et=t,Np=!1}}return null}var na=[],ra=0,sh=null,oh=0,hr=[],fr=0,io=null,yi=1,bi="";function $s(e,t){na[ra++]=oh,na[ra++]=sh,sh=e,oh=t}function r2(e,t,n){hr[fr++]=yi,hr[fr++]=bi,hr[fr++]=io,io=e;var r=yi;e=bi;var i=32-Ir(r)-1;r&=~(1<<i),n+=1;var s=32-Ir(t)+i;if(30<s){var o=i-i%5;s=(r&(1<<o)-1).toString(32),r>>=o,i-=o,yi=1<<32-Ir(t)+i|n<<i|r,bi=s+e}else yi=1<<s|n<<i|r,bi=e}function t_(e){e.return!==null&&($s(e,1),r2(e,1,0))}function n_(e){for(;e===sh;)sh=na[--ra],na[ra]=null,oh=na[--ra],na[ra]=null;for(;e===io;)io=hr[--fr],hr[fr]=null,bi=hr[--fr],hr[fr]=null,yi=hr[--fr],hr[fr]=null}var Jn=null,Qn=null,ft=!1,Pr=null;function i2(e,t){var n=mr(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function a1(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,Jn=e,Qn=ps(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Jn=e,Qn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=io!==null?{id:yi,overflow:bi}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=mr(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,Jn=e,Qn=null,!0):!1;default:return!1}}function mg(e){return(e.mode&1)!==0&&(e.flags&128)===0}function gg(e){if(ft){var t=Qn;if(t){var n=t;if(!a1(e,t)){if(mg(e))throw Error(G(418));t=ps(n.nextSibling);var r=Jn;t&&a1(e,t)?i2(r,n):(e.flags=e.flags&-4097|2,ft=!1,Jn=e)}}else{if(mg(e))throw Error(G(418));e.flags=e.flags&-4097|2,ft=!1,Jn=e}}}function l1(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Jn=e}function ju(e){if(e!==Jn)return!1;if(!ft)return l1(e),ft=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!dg(e.type,e.memoizedProps)),t&&(t=Qn)){if(mg(e))throw s2(),Error(G(418));for(;t;)i2(e,t),t=ps(t.nextSibling)}if(l1(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(G(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){Qn=ps(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}Qn=null}}else Qn=Jn?ps(e.stateNode.nextSibling):null;return!0}function s2(){for(var e=Qn;e;)e=ps(e.nextSibling)}function Ea(){Qn=Jn=null,ft=!1}function r_(e){Pr===null?Pr=[e]:Pr.push(e)}var lj=Li.ReactCurrentBatchConfig;function gl(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(G(309));var r=n.stateNode}if(!r)throw Error(G(147,e));var i=r,s=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===s?t.ref:(t=function(o){var a=i.refs;o===null?delete a[s]:a[s]=o},t._stringRef=s,t)}if(typeof e!="string")throw Error(G(284));if(!n._owner)throw Error(G(290,e))}return e}function Du(e,t){throw e=Object.prototype.toString.call(t),Error(G(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function c1(e){var t=e._init;return t(e._payload)}function o2(e){function t(_,x){if(e){var b=_.deletions;b===null?(_.deletions=[x],_.flags|=16):b.push(x)}}function n(_,x){if(!e)return null;for(;x!==null;)t(_,x),x=x.sibling;return null}function r(_,x){for(_=new Map;x!==null;)x.key!==null?_.set(x.key,x):_.set(x.index,x),x=x.sibling;return _}function i(_,x){return _=_s(_,x),_.index=0,_.sibling=null,_}function s(_,x,b){return _.index=b,e?(b=_.alternate,b!==null?(b=b.index,b<x?(_.flags|=2,x):b):(_.flags|=2,x)):(_.flags|=1048576,x)}function o(_){return e&&_.alternate===null&&(_.flags|=2),_}function a(_,x,b,w){return x===null||x.tag!==6?(x=jp(b,_.mode,w),x.return=_,x):(x=i(x,b),x.return=_,x)}function l(_,x,b,w){var S=b.type;return S===Yo?u(_,x,b.props.children,w,b.key):x!==null&&(x.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===es&&c1(S)===x.type)?(w=i(x,b.props),w.ref=gl(_,x,b),w.return=_,w):(w=Pd(b.type,b.key,b.props,null,_.mode,w),w.ref=gl(_,x,b),w.return=_,w)}function c(_,x,b,w){return x===null||x.tag!==4||x.stateNode.containerInfo!==b.containerInfo||x.stateNode.implementation!==b.implementation?(x=Dp(b,_.mode,w),x.return=_,x):(x=i(x,b.children||[]),x.return=_,x)}function u(_,x,b,w,S){return x===null||x.tag!==7?(x=Js(b,_.mode,w,S),x.return=_,x):(x=i(x,b),x.return=_,x)}function d(_,x,b){if(typeof x=="string"&&x!==""||typeof x=="number")return x=jp(""+x,_.mode,b),x.return=_,x;if(typeof x=="object"&&x!==null){switch(x.$$typeof){case ku:return b=Pd(x.type,x.key,x.props,null,_.mode,b),b.ref=gl(_,null,x),b.return=_,b;case Xo:return x=Dp(x,_.mode,b),x.return=_,x;case es:var w=x._init;return d(_,w(x._payload),b)}if(Ml(x)||dl(x))return x=Js(x,_.mode,b,null),x.return=_,x;Du(_,x)}return null}function f(_,x,b,w){var S=x!==null?x.key:null;if(typeof b=="string"&&b!==""||typeof b=="number")return S!==null?null:a(_,x,""+b,w);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case ku:return b.key===S?l(_,x,b,w):null;case Xo:return b.key===S?c(_,x,b,w):null;case es:return S=b._init,f(_,x,S(b._payload),w)}if(Ml(b)||dl(b))return S!==null?null:u(_,x,b,w,null);Du(_,b)}return null}function p(_,x,b,w,S){if(typeof w=="string"&&w!==""||typeof w=="number")return _=_.get(b)||null,a(x,_,""+w,S);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case ku:return _=_.get(w.key===null?b:w.key)||null,l(x,_,w,S);case Xo:return _=_.get(w.key===null?b:w.key)||null,c(x,_,w,S);case es:var k=w._init;return p(_,x,b,k(w._payload),S)}if(Ml(w)||dl(w))return _=_.get(b)||null,u(x,_,w,S,null);Du(x,w)}return null}function m(_,x,b,w){for(var S=null,k=null,T=x,N=x=0,L=null;T!==null&&N<b.length;N++){T.index>N?(L=T,T=null):L=T.sibling;var P=f(_,T,b[N],w);if(P===null){T===null&&(T=L);break}e&&T&&P.alternate===null&&t(_,T),x=s(P,x,N),k===null?S=P:k.sibling=P,k=P,T=L}if(N===b.length)return n(_,T),ft&&$s(_,N),S;if(T===null){for(;N<b.length;N++)T=d(_,b[N],w),T!==null&&(x=s(T,x,N),k===null?S=T:k.sibling=T,k=T);return ft&&$s(_,N),S}for(T=r(_,T);N<b.length;N++)L=p(T,_,N,b[N],w),L!==null&&(e&&L.alternate!==null&&T.delete(L.key===null?N:L.key),x=s(L,x,N),k===null?S=L:k.sibling=L,k=L);return e&&T.forEach(function(O){return t(_,O)}),ft&&$s(_,N),S}function v(_,x,b,w){var S=dl(b);if(typeof S!="function")throw Error(G(150));if(b=S.call(b),b==null)throw Error(G(151));for(var k=S=null,T=x,N=x=0,L=null,P=b.next();T!==null&&!P.done;N++,P=b.next()){T.index>N?(L=T,T=null):L=T.sibling;var O=f(_,T,P.value,w);if(O===null){T===null&&(T=L);break}e&&T&&O.alternate===null&&t(_,T),x=s(O,x,N),k===null?S=O:k.sibling=O,k=O,T=L}if(P.done)return n(_,T),ft&&$s(_,N),S;if(T===null){for(;!P.done;N++,P=b.next())P=d(_,P.value,w),P!==null&&(x=s(P,x,N),k===null?S=P:k.sibling=P,k=P);return ft&&$s(_,N),S}for(T=r(_,T);!P.done;N++,P=b.next())P=p(T,_,N,P.value,w),P!==null&&(e&&P.alternate!==null&&T.delete(P.key===null?N:P.key),x=s(P,x,N),k===null?S=P:k.sibling=P,k=P);return e&&T.forEach(function(I){return t(_,I)}),ft&&$s(_,N),S}function y(_,x,b,w){if(typeof b=="object"&&b!==null&&b.type===Yo&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case ku:e:{for(var S=b.key,k=x;k!==null;){if(k.key===S){if(S=b.type,S===Yo){if(k.tag===7){n(_,k.sibling),x=i(k,b.props.children),x.return=_,_=x;break e}}else if(k.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===es&&c1(S)===k.type){n(_,k.sibling),x=i(k,b.props),x.ref=gl(_,k,b),x.return=_,_=x;break e}n(_,k);break}else t(_,k);k=k.sibling}b.type===Yo?(x=Js(b.props.children,_.mode,w,b.key),x.return=_,_=x):(w=Pd(b.type,b.key,b.props,null,_.mode,w),w.ref=gl(_,x,b),w.return=_,_=w)}return o(_);case Xo:e:{for(k=b.key;x!==null;){if(x.key===k)if(x.tag===4&&x.stateNode.containerInfo===b.containerInfo&&x.stateNode.implementation===b.implementation){n(_,x.sibling),x=i(x,b.children||[]),x.return=_,_=x;break e}else{n(_,x);break}else t(_,x);x=x.sibling}x=Dp(b,_.mode,w),x.return=_,_=x}return o(_);case es:return k=b._init,y(_,x,k(b._payload),w)}if(Ml(b))return m(_,x,b,w);if(dl(b))return v(_,x,b,w);Du(_,b)}return typeof b=="string"&&b!==""||typeof b=="number"?(b=""+b,x!==null&&x.tag===6?(n(_,x.sibling),x=i(x,b),x.return=_,_=x):(n(_,x),x=jp(b,_.mode,w),x.return=_,_=x),o(_)):n(_,x)}return y}var Na=o2(!0),a2=o2(!1),ah=Ts(null),lh=null,ia=null,i_=null;function s_(){i_=ia=lh=null}function o_(e){var t=ah.current;ht(ah),e._currentValue=t}function vg(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function ma(e,t){lh=e,i_=ia=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Fn=!0),e.firstContext=null)}function xr(e){var t=e._currentValue;if(i_!==e)if(e={context:e,memoizedValue:t,next:null},ia===null){if(lh===null)throw Error(G(308));ia=e,lh.dependencies={lanes:0,firstContext:e}}else ia=ia.next=e;return t}var Ks=null;function a_(e){Ks===null?Ks=[e]:Ks.push(e)}function l2(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,a_(t)):(n.next=i.next,i.next=n),t.interleaved=n,Pi(e,r)}function Pi(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var ts=!1;function l_(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function c2(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function ki(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ms(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ge&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Pi(e,n)}return i=r.interleaved,i===null?(t.next=t,a_(r)):(t.next=i.next,i.next=t),r.interleaved=t,Pi(e,n)}function Sd(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,K0(e,n)}}function u1(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=t:s=s.next=t}else i=s=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ch(e,t,n,r){var i=e.updateQueue;ts=!1;var s=i.firstBaseUpdate,o=i.lastBaseUpdate,a=i.shared.pending;if(a!==null){i.shared.pending=null;var l=a,c=l.next;l.next=null,o===null?s=c:o.next=c,o=l;var u=e.alternate;u!==null&&(u=u.updateQueue,a=u.lastBaseUpdate,a!==o&&(a===null?u.firstBaseUpdate=c:a.next=c,u.lastBaseUpdate=l))}if(s!==null){var d=i.baseState;o=0,u=c=l=null,a=s;do{var f=a.lane,p=a.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var m=e,v=a;switch(f=t,p=n,v.tag){case 1:if(m=v.payload,typeof m=="function"){d=m.call(p,d,f);break e}d=m;break e;case 3:m.flags=m.flags&-65537|128;case 0:if(m=v.payload,f=typeof m=="function"?m.call(p,d,f):m,f==null)break e;d=bt({},d,f);break e;case 2:ts=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[a]:f.push(a))}else p={eventTime:p,lane:f,tag:a.tag,payload:a.payload,callback:a.callback,next:null},u===null?(c=u=p,l=d):u=u.next=p,o|=f;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;f=a,a=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(!0);if(u===null&&(l=d),i.baseState=l,i.firstBaseUpdate=c,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else s===null&&(i.shared.lanes=0);oo|=o,e.lanes=o,e.memoizedState=d}}function d1(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],i=r.callback;if(i!==null){if(r.callback=null,r=n,typeof i!="function")throw Error(G(191,i));i.call(r)}}}var eu={},Jr=Ts(eu),_c=Ts(eu),xc=Ts(eu);function Gs(e){if(e===eu)throw Error(G(174));return e}function c_(e,t){switch(ct(xc,t),ct(_c,e),ct(Jr,eu),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Zm(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Zm(t,e)}ht(Jr),ct(Jr,t)}function Ta(){ht(Jr),ht(_c),ht(xc)}function u2(e){Gs(xc.current);var t=Gs(Jr.current),n=Zm(t,e.type);t!==n&&(ct(_c,e),ct(Jr,n))}function u_(e){_c.current===e&&(ht(Jr),ht(_c))}var _t=Ts(0);function uh(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Tp=[];function d_(){for(var e=0;e<Tp.length;e++)Tp[e]._workInProgressVersionPrimary=null;Tp.length=0}var kd=Li.ReactCurrentDispatcher,Pp=Li.ReactCurrentBatchConfig,so=0,yt=null,Wt=null,tn=null,dh=!1,Xl=!1,yc=0,cj=0;function mn(){throw Error(G(321))}function h_(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!jr(e[n],t[n]))return!1;return!0}function f_(e,t,n,r,i,s){if(so=s,yt=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,kd.current=e===null||e.memoizedState===null?fj:pj,e=n(r,i),Xl){s=0;do{if(Xl=!1,yc=0,25<=s)throw Error(G(301));s+=1,tn=Wt=null,t.updateQueue=null,kd.current=mj,e=n(r,i)}while(Xl)}if(kd.current=hh,t=Wt!==null&&Wt.next!==null,so=0,tn=Wt=yt=null,dh=!1,t)throw Error(G(300));return e}function p_(){var e=yc!==0;return yc=0,e}function Ur(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return tn===null?yt.memoizedState=tn=e:tn=tn.next=e,tn}function yr(){if(Wt===null){var e=yt.alternate;e=e!==null?e.memoizedState:null}else e=Wt.next;var t=tn===null?yt.memoizedState:tn.next;if(t!==null)tn=t,Wt=e;else{if(e===null)throw Error(G(310));Wt=e,e={memoizedState:Wt.memoizedState,baseState:Wt.baseState,baseQueue:Wt.baseQueue,queue:Wt.queue,next:null},tn===null?yt.memoizedState=tn=e:tn=tn.next=e}return tn}function bc(e,t){return typeof t=="function"?t(e):t}function Ip(e){var t=yr(),n=t.queue;if(n===null)throw Error(G(311));n.lastRenderedReducer=e;var r=Wt,i=r.baseQueue,s=n.pending;if(s!==null){if(i!==null){var o=i.next;i.next=s.next,s.next=o}r.baseQueue=i=s,n.pending=null}if(i!==null){s=i.next,r=r.baseState;var a=o=null,l=null,c=s;do{var u=c.lane;if((so&u)===u)l!==null&&(l=l.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),r=c.hasEagerState?c.eagerState:e(r,c.action);else{var d={lane:u,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};l===null?(a=l=d,o=r):l=l.next=d,yt.lanes|=u,oo|=u}c=c.next}while(c!==null&&c!==s);l===null?o=r:l.next=a,jr(r,t.memoizedState)||(Fn=!0),t.memoizedState=r,t.baseState=o,t.baseQueue=l,n.lastRenderedState=r}if(e=n.interleaved,e!==null){i=e;do s=i.lane,yt.lanes|=s,oo|=s,i=i.next;while(i!==e)}else i===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Rp(e){var t=yr(),n=t.queue;if(n===null)throw Error(G(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,s=t.memoizedState;if(i!==null){n.pending=null;var o=i=i.next;do s=e(s,o.action),o=o.next;while(o!==i);jr(s,t.memoizedState)||(Fn=!0),t.memoizedState=s,t.baseQueue===null&&(t.baseState=s),n.lastRenderedState=s}return[s,r]}function d2(){}function h2(e,t){var n=yt,r=yr(),i=t(),s=!jr(r.memoizedState,i);if(s&&(r.memoizedState=i,Fn=!0),r=r.queue,m_(m2.bind(null,n,r,e),[e]),r.getSnapshot!==t||s||tn!==null&&tn.memoizedState.tag&1){if(n.flags|=2048,wc(9,p2.bind(null,n,r,i,t),void 0,null),on===null)throw Error(G(349));so&30||f2(n,t,i)}return i}function f2(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=yt.updateQueue,t===null?(t={lastEffect:null,stores:null},yt.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function p2(e,t,n,r){t.value=n,t.getSnapshot=r,g2(t)&&v2(e)}function m2(e,t,n){return n(function(){g2(t)&&v2(e)})}function g2(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!jr(e,n)}catch{return!0}}function v2(e){var t=Pi(e,1);t!==null&&Rr(t,e,1,-1)}function h1(e){var t=Ur();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:bc,lastRenderedState:e},t.queue=e,e=e.dispatch=hj.bind(null,yt,e),[t.memoizedState,e]}function wc(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=yt.updateQueue,t===null?(t={lastEffect:null,stores:null},yt.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function _2(){return yr().memoizedState}function Cd(e,t,n,r){var i=Ur();yt.flags|=e,i.memoizedState=wc(1|t,n,void 0,r===void 0?null:r)}function af(e,t,n,r){var i=yr();r=r===void 0?null:r;var s=void 0;if(Wt!==null){var o=Wt.memoizedState;if(s=o.destroy,r!==null&&h_(r,o.deps)){i.memoizedState=wc(t,n,s,r);return}}yt.flags|=e,i.memoizedState=wc(1|t,n,s,r)}function f1(e,t){return Cd(8390656,8,e,t)}function m_(e,t){return af(2048,8,e,t)}function x2(e,t){return af(4,2,e,t)}function y2(e,t){return af(4,4,e,t)}function b2(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function w2(e,t,n){return n=n!=null?n.concat([e]):null,af(4,4,b2.bind(null,t,e),n)}function g_(){}function S2(e,t){var n=yr();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&h_(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function k2(e,t){var n=yr();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&h_(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function C2(e,t,n){return so&21?(jr(n,t)||(n=IC(),yt.lanes|=n,oo|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Fn=!0),e.memoizedState=n)}function uj(e,t){var n=et;et=n!==0&&4>n?n:4,e(!0);var r=Pp.transition;Pp.transition={};try{e(!1),t()}finally{et=n,Pp.transition=r}}function E2(){return yr().memoizedState}function dj(e,t,n){var r=vs(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},N2(e))T2(t,n);else if(n=l2(e,t,n,r),n!==null){var i=Nn();Rr(n,e,r,i),P2(n,t,r)}}function hj(e,t,n){var r=vs(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(N2(e))T2(t,i);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var o=t.lastRenderedState,a=s(o,n);if(i.hasEagerState=!0,i.eagerState=a,jr(a,o)){var l=t.interleaved;l===null?(i.next=i,a_(t)):(i.next=l.next,l.next=i),t.interleaved=i;return}}catch{}finally{}n=l2(e,t,i,r),n!==null&&(i=Nn(),Rr(n,e,r,i),P2(n,t,r))}}function N2(e){var t=e.alternate;return e===yt||t!==null&&t===yt}function T2(e,t){Xl=dh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function P2(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,K0(e,n)}}var hh={readContext:xr,useCallback:mn,useContext:mn,useEffect:mn,useImperativeHandle:mn,useInsertionEffect:mn,useLayoutEffect:mn,useMemo:mn,useReducer:mn,useRef:mn,useState:mn,useDebugValue:mn,useDeferredValue:mn,useTransition:mn,useMutableSource:mn,useSyncExternalStore:mn,useId:mn,unstable_isNewReconciler:!1},fj={readContext:xr,useCallback:function(e,t){return Ur().memoizedState=[e,t===void 0?null:t],e},useContext:xr,useEffect:f1,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Cd(4194308,4,b2.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Cd(4194308,4,e,t)},useInsertionEffect:function(e,t){return Cd(4,2,e,t)},useMemo:function(e,t){var n=Ur();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ur();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=dj.bind(null,yt,e),[r.memoizedState,e]},useRef:function(e){var t=Ur();return e={current:e},t.memoizedState=e},useState:h1,useDebugValue:g_,useDeferredValue:function(e){return Ur().memoizedState=e},useTransition:function(){var e=h1(!1),t=e[0];return e=uj.bind(null,e[1]),Ur().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=yt,i=Ur();if(ft){if(n===void 0)throw Error(G(407));n=n()}else{if(n=t(),on===null)throw Error(G(349));so&30||f2(r,t,n)}i.memoizedState=n;var s={value:n,getSnapshot:t};return i.queue=s,f1(m2.bind(null,r,s,e),[e]),r.flags|=2048,wc(9,p2.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=Ur(),t=on.identifierPrefix;if(ft){var n=bi,r=yi;n=(r&~(1<<32-Ir(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=yc++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=cj++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},pj={readContext:xr,useCallback:S2,useContext:xr,useEffect:m_,useImperativeHandle:w2,useInsertionEffect:x2,useLayoutEffect:y2,useMemo:k2,useReducer:Ip,useRef:_2,useState:function(){return Ip(bc)},useDebugValue:g_,useDeferredValue:function(e){var t=yr();return C2(t,Wt.memoizedState,e)},useTransition:function(){var e=Ip(bc)[0],t=yr().memoizedState;return[e,t]},useMutableSource:d2,useSyncExternalStore:h2,useId:E2,unstable_isNewReconciler:!1},mj={readContext:xr,useCallback:S2,useContext:xr,useEffect:m_,useImperativeHandle:w2,useInsertionEffect:x2,useLayoutEffect:y2,useMemo:k2,useReducer:Rp,useRef:_2,useState:function(){return Rp(bc)},useDebugValue:g_,useDeferredValue:function(e){var t=yr();return Wt===null?t.memoizedState=e:C2(t,Wt.memoizedState,e)},useTransition:function(){var e=Rp(bc)[0],t=yr().memoizedState;return[e,t]},useMutableSource:d2,useSyncExternalStore:h2,useId:E2,unstable_isNewReconciler:!1};function Er(e,t){if(e&&e.defaultProps){t=bt({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function _g(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:bt({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var lf={isMounted:function(e){return(e=e._reactInternals)?wo(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Nn(),i=vs(e),s=ki(r,i);s.payload=t,n!=null&&(s.callback=n),t=ms(e,s,i),t!==null&&(Rr(t,e,i,r),Sd(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Nn(),i=vs(e),s=ki(r,i);s.tag=1,s.payload=t,n!=null&&(s.callback=n),t=ms(e,s,i),t!==null&&(Rr(t,e,i,r),Sd(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Nn(),r=vs(e),i=ki(n,r);i.tag=2,t!=null&&(i.callback=t),t=ms(e,i,r),t!==null&&(Rr(t,e,r,n),Sd(t,e,r))}};function p1(e,t,n,r,i,s,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,s,o):t.prototype&&t.prototype.isPureReactComponent?!pc(n,r)||!pc(i,s):!0}function I2(e,t,n){var r=!1,i=ws,s=t.contextType;return typeof s=="object"&&s!==null?s=xr(s):(i=Un(t)?ro:bn.current,r=t.contextTypes,s=(r=r!=null)?Ca(e,i):ws),t=new t(n,s),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=lf,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=s),t}function m1(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&lf.enqueueReplaceState(t,t.state,null)}function xg(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},l_(e);var s=t.contextType;typeof s=="object"&&s!==null?i.context=xr(s):(s=Un(t)?ro:bn.current,i.context=Ca(e,s)),i.state=e.memoizedState,s=t.getDerivedStateFromProps,typeof s=="function"&&(_g(e,t,s,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(t=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),t!==i.state&&lf.enqueueReplaceState(i,i.state,null),ch(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function Pa(e,t){try{var n="",r=t;do n+=UA(r),r=r.return;while(r);var i=n}catch(s){i=`
39
39
  Error generating stack: `+s.message+`
40
- `+s.stack}return{value:e,source:t,stack:i,digest:null}}function Mp(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function yg(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var gj=typeof WeakMap=="function"?WeakMap:Map;function R2(e,t,n){n=ki(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){ph||(ph=!0,Ig=r),yg(e,t)},n}function M2(e,t,n){n=ki(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){yg(e,t)}}var s=e.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){yg(e,t),typeof r!="function"&&(gs===null?gs=new Set([this]):gs.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function g1(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new gj;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=Ij.bind(null,e,t,n),t.then(e,e))}function v1(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function _1(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=ki(-1,1),t.tag=2,ms(n,t,1))),n.lanes|=1),e)}var vj=Li.ReactCurrentOwner,Fn=!1;function kn(e,t,n,r){t.child=e===null?a2(t,null,n,r):Na(t,e.child,n,r)}function x1(e,t,n,r,i){n=n.render;var s=t.ref;return ma(t,i),r=f_(e,t,n,r,s,i),n=p_(),e!==null&&!Fn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Ii(e,t,i)):(ft&&n&&t_(t),t.flags|=1,kn(e,t,r,i),t.child)}function y1(e,t,n,r,i){if(e===null){var s=n.type;return typeof s=="function"&&!k_(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=s,A2(e,t,s,r,i)):(e=Pd(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(s=e.child,!(e.lanes&i)){var o=s.memoizedProps;if(n=n.compare,n=n!==null?n:pc,n(o,r)&&e.ref===t.ref)return Ii(e,t,i)}return t.flags|=1,e=_s(s,r),e.ref=t.ref,e.return=t,t.child=e}function A2(e,t,n,r,i){if(e!==null){var s=e.memoizedProps;if(pc(s,r)&&e.ref===t.ref)if(Fn=!1,t.pendingProps=r=s,(e.lanes&i)!==0)e.flags&131072&&(Fn=!0);else return t.lanes=e.lanes,Ii(e,t,i)}return bg(e,t,n,r,i)}function j2(e,t,n){var r=t.pendingProps,i=r.children,s=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},ct(oa,Yn),Yn|=n;else{if(!(n&1073741824))return e=s!==null?s.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,ct(oa,Yn),Yn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,ct(oa,Yn),Yn|=r}else s!==null?(r=s.baseLanes|n,t.memoizedState=null):r=n,ct(oa,Yn),Yn|=r;return kn(e,t,i,n),t.child}function D2(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function bg(e,t,n,r,i){var s=Un(n)?ro:bn.current;return s=Ca(t,s),ma(t,i),n=f_(e,t,n,r,s,i),r=p_(),e!==null&&!Fn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Ii(e,t,i)):(ft&&r&&t_(t),t.flags|=1,kn(e,t,n,i),t.child)}function b1(e,t,n,r,i){if(Un(n)){var s=!0;ih(t)}else s=!1;if(ma(t,i),t.stateNode===null)Ed(e,t),I2(t,n,r),xg(t,n,r,i),r=!0;else if(e===null){var o=t.stateNode,a=t.memoizedProps;o.props=a;var l=o.context,c=n.contextType;typeof c=="object"&&c!==null?c=xr(c):(c=Un(n)?ro:bn.current,c=Ca(t,c));var u=n.getDerivedStateFromProps,d=typeof u=="function"||typeof o.getSnapshotBeforeUpdate=="function";d||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||l!==c)&&m1(t,o,r,c),ts=!1;var f=t.memoizedState;o.state=f,ch(t,r,o,i),l=t.memoizedState,a!==r||f!==l||Hn.current||ts?(typeof u=="function"&&(_g(t,n,u,r),l=t.memoizedState),(a=ts||p1(t,n,a,r,f,l,c))?(d||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),o.props=r,o.state=l,o.context=c,r=a):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,c2(e,t),a=t.memoizedProps,c=t.type===t.elementType?a:Er(t.type,a),o.props=c,d=t.pendingProps,f=o.context,l=n.contextType,typeof l=="object"&&l!==null?l=xr(l):(l=Un(n)?ro:bn.current,l=Ca(t,l));var p=n.getDerivedStateFromProps;(u=typeof p=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==d||f!==l)&&m1(t,o,r,l),ts=!1,f=t.memoizedState,o.state=f,ch(t,r,o,i);var m=t.memoizedState;a!==d||f!==m||Hn.current||ts?(typeof p=="function"&&(_g(t,n,p,r),m=t.memoizedState),(c=ts||p1(t,n,c,r,f,m,l)||!1)?(u||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,m,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,m,l)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=m),o.props=r,o.state=m,o.context=l,r=c):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return wg(e,t,n,r,s,i)}function wg(e,t,n,r,i,s){D2(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return i&&o1(t,n,!1),Ii(e,t,s);r=t.stateNode,vj.current=t;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=Na(t,e.child,null,s),t.child=Na(t,null,a,s)):kn(e,t,a,s),t.memoizedState=r.state,i&&o1(t,n,!0),t.child}function L2(e){var t=e.stateNode;t.pendingContext?s1(e,t.pendingContext,t.pendingContext!==t.context):t.context&&s1(e,t.context,!1),c_(e,t.containerInfo)}function w1(e,t,n,r,i){return Ea(),r_(i),t.flags|=256,kn(e,t,n,r),t.child}var Sg={dehydrated:null,treeContext:null,retryLane:0};function kg(e){return{baseLanes:e,cachePool:null,transitions:null}}function O2(e,t,n){var r=t.pendingProps,i=_t.current,s=!1,o=(t.flags&128)!==0,a;if((a=o)||(a=e!==null&&e.memoizedState===null?!1:(i&2)!==0),a?(s=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),ct(_t,i&1),e===null)return gg(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,s?(r=t.mode,s=t.child,o={mode:"hidden",children:o},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=o):s=df(o,r,0,null),e=Js(e,r,n,null),s.return=t,e.return=t,s.sibling=e,t.child=s,t.child.memoizedState=kg(n),t.memoizedState=Sg,e):v_(t,o));if(i=e.memoizedState,i!==null&&(a=i.dehydrated,a!==null))return _j(e,t,o,r,a,i,n);if(s){s=r.fallback,o=t.mode,i=e.child,a=i.sibling;var l={mode:"hidden",children:r.children};return!(o&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=l,t.deletions=null):(r=_s(i,l),r.subtreeFlags=i.subtreeFlags&14680064),a!==null?s=_s(a,s):(s=Js(s,o,n,null),s.flags|=2),s.return=t,r.return=t,r.sibling=s,t.child=r,r=s,s=t.child,o=e.child.memoizedState,o=o===null?kg(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},s.memoizedState=o,s.childLanes=e.childLanes&~n,t.memoizedState=Sg,r}return s=e.child,e=s.sibling,r=_s(s,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function v_(e,t){return t=df({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Lu(e,t,n,r){return r!==null&&r_(r),Na(t,e.child,null,n),e=v_(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function _j(e,t,n,r,i,s,o){if(n)return t.flags&256?(t.flags&=-257,r=Mp(Error(G(422))),Lu(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(s=r.fallback,i=t.mode,r=df({mode:"visible",children:r.children},i,0,null),s=Js(s,i,o,null),s.flags|=2,r.return=t,s.return=t,r.sibling=s,t.child=r,t.mode&1&&Na(t,e.child,null,o),t.child.memoizedState=kg(o),t.memoizedState=Sg,s);if(!(t.mode&1))return Lu(e,t,o,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var a=r.dgst;return r=a,s=Error(G(419)),r=Mp(s,r,void 0),Lu(e,t,o,r)}if(a=(o&e.childLanes)!==0,Fn||a){if(r=on,r!==null){switch(o&-o){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|o)?0:i,i!==0&&i!==s.retryLane&&(s.retryLane=i,Pi(e,i),Rr(r,e,i,-1))}return S_(),r=Mp(Error(G(421))),Lu(e,t,o,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=Rj.bind(null,e),i._reactRetry=t,null):(e=s.treeContext,Qn=ps(i.nextSibling),Jn=t,ft=!0,Pr=null,e!==null&&(hr[fr++]=yi,hr[fr++]=bi,hr[fr++]=io,yi=e.id,bi=e.overflow,io=t),t=v_(t,r.children),t.flags|=4096,t)}function S1(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),vg(e.return,t,n)}function Ap(e,t,n,r,i){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i)}function B2(e,t,n){var r=t.pendingProps,i=r.revealOrder,s=r.tail;if(kn(e,t,r.children,n),r=_t.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&S1(e,n,t);else if(e.tag===19)S1(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(ct(_t,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&uh(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Ap(t,!1,i,n,s);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&uh(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Ap(t,!0,n,null,s);break;case"together":Ap(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Ed(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Ii(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),oo|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(G(153));if(t.child!==null){for(e=t.child,n=_s(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=_s(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function xj(e,t,n){switch(t.tag){case 3:L2(t),Ea();break;case 5:u2(t);break;case 1:Un(t.type)&&ih(t);break;case 4:c_(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;ct(ah,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(ct(_t,_t.current&1),t.flags|=128,null):n&t.child.childLanes?O2(e,t,n):(ct(_t,_t.current&1),e=Ii(e,t,n),e!==null?e.sibling:null);ct(_t,_t.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return B2(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),ct(_t,_t.current),r)break;return null;case 22:case 23:return t.lanes=0,j2(e,t,n)}return Ii(e,t,n)}var z2,Cg,$2,F2;z2=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Cg=function(){};$2=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,Gs(Jr.current);var s=null;switch(n){case"input":i=Km(e,i),r=Km(e,r),s=[];break;case"select":i=bt({},i,{value:void 0}),r=bt({},r,{value:void 0}),s=[];break;case"textarea":i=Ym(e,i),r=Ym(e,r),s=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=nh)}Qm(n,r);var o;n=null;for(c in i)if(!r.hasOwnProperty(c)&&i.hasOwnProperty(c)&&i[c]!=null)if(c==="style"){var a=i[c];for(o in a)a.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(ac.hasOwnProperty(c)?s||(s=[]):(s=s||[]).push(c,null));for(c in r){var l=r[c];if(a=i!=null?i[c]:void 0,r.hasOwnProperty(c)&&l!==a&&(l!=null||a!=null))if(c==="style")if(a){for(o in a)!a.hasOwnProperty(o)||l&&l.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in l)l.hasOwnProperty(o)&&a[o]!==l[o]&&(n||(n={}),n[o]=l[o])}else n||(s||(s=[]),s.push(c,n)),n=l;else c==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(s=s||[]).push(c,l)):c==="children"?typeof l!="string"&&typeof l!="number"||(s=s||[]).push(c,""+l):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(ac.hasOwnProperty(c)?(l!=null&&c==="onScroll"&&ut("scroll",e),s||a===l||(s=[])):(s=s||[]).push(c,l))}n&&(s=s||[]).push("style",n);var c=s;(t.updateQueue=c)&&(t.flags|=4)}};F2=function(e,t,n,r){n!==r&&(t.flags|=4)};function vl(e,t){if(!ft)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function gn(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function yj(e,t,n){var r=t.pendingProps;switch(n_(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return gn(t),null;case 1:return Un(t.type)&&rh(),gn(t),null;case 3:return r=t.stateNode,Ta(),ht(Hn),ht(bn),d_(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(ju(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Pr!==null&&(Ag(Pr),Pr=null))),Cg(e,t),gn(t),null;case 5:u_(t);var i=Gs(xc.current);if(n=t.type,e!==null&&t.stateNode!=null)$2(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(G(166));return gn(t),null}if(e=Gs(Jr.current),ju(t)){r=t.stateNode,n=t.type;var s=t.memoizedProps;switch(r[Kr]=t,r[vc]=s,e=(t.mode&1)!==0,n){case"dialog":ut("cancel",r),ut("close",r);break;case"iframe":case"object":case"embed":ut("load",r);break;case"video":case"audio":for(i=0;i<jl.length;i++)ut(jl[i],r);break;case"source":ut("error",r);break;case"img":case"image":case"link":ut("error",r),ut("load",r);break;case"details":ut("toggle",r);break;case"input":My(r,s),ut("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!s.multiple},ut("invalid",r);break;case"textarea":jy(r,s),ut("invalid",r)}Qm(n,s),i=null;for(var o in s)if(s.hasOwnProperty(o)){var a=s[o];o==="children"?typeof a=="string"?r.textContent!==a&&(s.suppressHydrationWarning!==!0&&Au(r.textContent,a,e),i=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(s.suppressHydrationWarning!==!0&&Au(r.textContent,a,e),i=["children",""+a]):ac.hasOwnProperty(o)&&a!=null&&o==="onScroll"&&ut("scroll",r)}switch(n){case"input":Cu(r),Ay(r,s,!0);break;case"textarea":Cu(r),Dy(r);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(r.onclick=nh)}r=i,t.updateQueue=r,r!==null&&(t.flags|=4)}else{o=i.nodeType===9?i:i.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=mC(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[Kr]=t,e[vc]=r,z2(e,t,!1,!1),t.stateNode=e;e:{switch(o=Jm(n,r),n){case"dialog":ut("cancel",e),ut("close",e),i=r;break;case"iframe":case"object":case"embed":ut("load",e),i=r;break;case"video":case"audio":for(i=0;i<jl.length;i++)ut(jl[i],e);i=r;break;case"source":ut("error",e),i=r;break;case"img":case"image":case"link":ut("error",e),ut("load",e),i=r;break;case"details":ut("toggle",e),i=r;break;case"input":My(e,r),i=Km(e,r),ut("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=bt({},r,{value:void 0}),ut("invalid",e);break;case"textarea":jy(e,r),i=Ym(e,r),ut("invalid",e);break;default:i=r}Qm(n,i),a=i;for(s in a)if(a.hasOwnProperty(s)){var l=a[s];s==="style"?_C(e,l):s==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&gC(e,l)):s==="children"?typeof l=="string"?(n!=="textarea"||l!=="")&&lc(e,l):typeof l=="number"&&lc(e,""+l):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(ac.hasOwnProperty(s)?l!=null&&s==="onScroll"&&ut("scroll",e):l!=null&&F0(e,s,l,o))}switch(n){case"input":Cu(e),Ay(e,r,!1);break;case"textarea":Cu(e),Dy(e);break;case"option":r.value!=null&&e.setAttribute("value",""+bs(r.value));break;case"select":e.multiple=!!r.multiple,s=r.value,s!=null?da(e,!!r.multiple,s,!1):r.defaultValue!=null&&da(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=nh)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return gn(t),null;case 6:if(e&&t.stateNode!=null)F2(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(G(166));if(n=Gs(xc.current),Gs(Jr.current),ju(t)){if(r=t.stateNode,n=t.memoizedProps,r[Kr]=t,(s=r.nodeValue!==n)&&(e=Jn,e!==null))switch(e.tag){case 3:Au(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Au(r.nodeValue,n,(e.mode&1)!==0)}s&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Kr]=t,t.stateNode=r}return gn(t),null;case 13:if(ht(_t),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ft&&Qn!==null&&t.mode&1&&!(t.flags&128))s2(),Ea(),t.flags|=98560,s=!1;else if(s=ju(t),r!==null&&r.dehydrated!==null){if(e===null){if(!s)throw Error(G(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(G(317));s[Kr]=t}else Ea(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;gn(t),s=!1}else Pr!==null&&(Ag(Pr),Pr=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||_t.current&1?Vt===0&&(Vt=3):S_())),t.updateQueue!==null&&(t.flags|=4),gn(t),null);case 4:return Ta(),Cg(e,t),e===null&&mc(t.stateNode.containerInfo),gn(t),null;case 10:return o_(t.type._context),gn(t),null;case 17:return Un(t.type)&&rh(),gn(t),null;case 19:if(ht(_t),s=t.memoizedState,s===null)return gn(t),null;if(r=(t.flags&128)!==0,o=s.rendering,o===null)if(r)vl(s,!1);else{if(Vt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=uh(e),o!==null){for(t.flags|=128,vl(s,!1),r=o.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)s=n,e=r,s.flags&=14680066,o=s.alternate,o===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=o.childLanes,s.lanes=o.lanes,s.child=o.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=o.memoizedProps,s.memoizedState=o.memoizedState,s.updateQueue=o.updateQueue,s.type=o.type,e=o.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return ct(_t,_t.current&1|2),t.child}e=e.sibling}s.tail!==null&&It()>Ia&&(t.flags|=128,r=!0,vl(s,!1),t.lanes=4194304)}else{if(!r)if(e=uh(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),vl(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!ft)return gn(t),null}else 2*It()-s.renderingStartTime>Ia&&n!==1073741824&&(t.flags|=128,r=!0,vl(s,!1),t.lanes=4194304);s.isBackwards?(o.sibling=t.child,t.child=o):(n=s.last,n!==null?n.sibling=o:t.child=o,s.last=o)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=It(),t.sibling=null,n=_t.current,ct(_t,r?n&1|2:n&1),t):(gn(t),null);case 22:case 23:return w_(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Yn&1073741824&&(gn(t),t.subtreeFlags&6&&(t.flags|=8192)):gn(t),null;case 24:return null;case 25:return null}throw Error(G(156,t.tag))}function bj(e,t){switch(n_(t),t.tag){case 1:return Un(t.type)&&rh(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ta(),ht(Hn),ht(bn),d_(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return u_(t),null;case 13:if(ht(_t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(G(340));Ea()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ht(_t),null;case 4:return Ta(),null;case 10:return o_(t.type._context),null;case 22:case 23:return w_(),null;case 24:return null;default:return null}}var Ou=!1,xn=!1,wj=typeof WeakSet=="function"?WeakSet:Set,le=null;function sa(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){kt(e,t,r)}else n.current=null}function Eg(e,t,n){try{n()}catch(r){kt(e,t,r)}}var k1=!1;function Sj(e,t){if(cg=Jd,e=qC(),e_(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,c=0,u=0,d=e,f=null;t:for(;;){for(var p;d!==n||i!==0&&d.nodeType!==3||(a=o+i),d!==s||r!==0&&d.nodeType!==3||(l=o+r),d.nodeType===3&&(o+=d.nodeValue.length),(p=d.firstChild)!==null;)f=d,d=p;for(;;){if(d===e)break t;if(f===n&&++c===i&&(a=o),f===s&&++u===r&&(l=o),(p=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=p}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(ug={focusedElem:e,selectionRange:n},Jd=!1,le=t;le!==null;)if(t=le,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,le=e;else for(;le!==null;){t=le;try{var m=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(m!==null){var v=m.memoizedProps,y=m.memoizedState,_=t.stateNode,x=_.getSnapshotBeforeUpdate(t.elementType===t.type?v:Er(t.type,v),y);_.__reactInternalSnapshotBeforeUpdate=x}break;case 3:var b=t.stateNode.containerInfo;b.nodeType===1?b.textContent="":b.nodeType===9&&b.documentElement&&b.removeChild(b.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(G(163))}}catch(w){kt(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,le=e;break}le=t.return}return m=k1,k1=!1,m}function Yl(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var s=i.destroy;i.destroy=void 0,s!==void 0&&Eg(t,n,s)}i=i.next}while(i!==r)}}function cf(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Ng(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function H2(e){var t=e.alternate;t!==null&&(e.alternate=null,H2(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Kr],delete t[vc],delete t[fg],delete t[sj],delete t[oj])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function U2(e){return e.tag===5||e.tag===3||e.tag===4}function C1(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||U2(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Tg(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=nh));else if(r!==4&&(e=e.child,e!==null))for(Tg(e,t,n),e=e.sibling;e!==null;)Tg(e,t,n),e=e.sibling}function Pg(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Pg(e,t,n),e=e.sibling;e!==null;)Pg(e,t,n),e=e.sibling}var cn=null,Nr=!1;function Vi(e,t,n){for(n=n.child;n!==null;)W2(e,t,n),n=n.sibling}function W2(e,t,n){if(Qr&&typeof Qr.onCommitFiberUnmount=="function")try{Qr.onCommitFiberUnmount(ef,n)}catch{}switch(n.tag){case 5:xn||sa(n,t);case 6:var r=cn,i=Nr;cn=null,Vi(e,t,n),cn=r,Nr=i,cn!==null&&(Nr?(e=cn,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):cn.removeChild(n.stateNode));break;case 18:cn!==null&&(Nr?(e=cn,n=n.stateNode,e.nodeType===8?Ep(e.parentNode,n):e.nodeType===1&&Ep(e,n),hc(e)):Ep(cn,n.stateNode));break;case 4:r=cn,i=Nr,cn=n.stateNode.containerInfo,Nr=!0,Vi(e,t,n),cn=r,Nr=i;break;case 0:case 11:case 14:case 15:if(!xn&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&Eg(n,t,o),i=i.next}while(i!==r)}Vi(e,t,n);break;case 1:if(!xn&&(sa(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){kt(n,t,a)}Vi(e,t,n);break;case 21:Vi(e,t,n);break;case 22:n.mode&1?(xn=(r=xn)||n.memoizedState!==null,Vi(e,t,n),xn=r):Vi(e,t,n);break;default:Vi(e,t,n)}}function E1(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new wj),t.forEach(function(r){var i=Mj.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function kr(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];try{var s=e,o=t,a=o;e:for(;a!==null;){switch(a.tag){case 5:cn=a.stateNode,Nr=!1;break e;case 3:cn=a.stateNode.containerInfo,Nr=!0;break e;case 4:cn=a.stateNode.containerInfo,Nr=!0;break e}a=a.return}if(cn===null)throw Error(G(160));W2(s,o,i),cn=null,Nr=!1;var l=i.alternate;l!==null&&(l.return=null),i.return=null}catch(c){kt(i,t,c)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)V2(t,e),t=t.sibling}function V2(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(kr(t,e),Br(e),r&4){try{Yl(3,e,e.return),cf(3,e)}catch(v){kt(e,e.return,v)}try{Yl(5,e,e.return)}catch(v){kt(e,e.return,v)}}break;case 1:kr(t,e),Br(e),r&512&&n!==null&&sa(n,n.return);break;case 5:if(kr(t,e),Br(e),r&512&&n!==null&&sa(n,n.return),e.flags&32){var i=e.stateNode;try{lc(i,"")}catch(v){kt(e,e.return,v)}}if(r&4&&(i=e.stateNode,i!=null)){var s=e.memoizedProps,o=n!==null?n.memoizedProps:s,a=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{a==="input"&&s.type==="radio"&&s.name!=null&&fC(i,s),Jm(a,o);var c=Jm(a,s);for(o=0;o<l.length;o+=2){var u=l[o],d=l[o+1];u==="style"?_C(i,d):u==="dangerouslySetInnerHTML"?gC(i,d):u==="children"?lc(i,d):F0(i,u,d,c)}switch(a){case"input":Gm(i,s);break;case"textarea":pC(i,s);break;case"select":var f=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!s.multiple;var p=s.value;p!=null?da(i,!!s.multiple,p,!1):f!==!!s.multiple&&(s.defaultValue!=null?da(i,!!s.multiple,s.defaultValue,!0):da(i,!!s.multiple,s.multiple?[]:"",!1))}i[vc]=s}catch(v){kt(e,e.return,v)}}break;case 6:if(kr(t,e),Br(e),r&4){if(e.stateNode===null)throw Error(G(162));i=e.stateNode,s=e.memoizedProps;try{i.nodeValue=s}catch(v){kt(e,e.return,v)}}break;case 3:if(kr(t,e),Br(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{hc(t.containerInfo)}catch(v){kt(e,e.return,v)}break;case 4:kr(t,e),Br(e);break;case 13:kr(t,e),Br(e),i=e.child,i.flags&8192&&(s=i.memoizedState!==null,i.stateNode.isHidden=s,!s||i.alternate!==null&&i.alternate.memoizedState!==null||(y_=It())),r&4&&E1(e);break;case 22:if(u=n!==null&&n.memoizedState!==null,e.mode&1?(xn=(c=xn)||u,kr(t,e),xn=c):kr(t,e),Br(e),r&8192){if(c=e.memoizedState!==null,(e.stateNode.isHidden=c)&&!u&&e.mode&1)for(le=e,u=e.child;u!==null;){for(d=le=u;le!==null;){switch(f=le,p=f.child,f.tag){case 0:case 11:case 14:case 15:Yl(4,f,f.return);break;case 1:sa(f,f.return);var m=f.stateNode;if(typeof m.componentWillUnmount=="function"){r=f,n=f.return;try{t=r,m.props=t.memoizedProps,m.state=t.memoizedState,m.componentWillUnmount()}catch(v){kt(r,n,v)}}break;case 5:sa(f,f.return);break;case 22:if(f.memoizedState!==null){T1(d);continue}}p!==null?(p.return=f,le=p):T1(d)}u=u.sibling}e:for(u=null,d=e;;){if(d.tag===5){if(u===null){u=d;try{i=d.stateNode,c?(s=i.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none"):(a=d.stateNode,l=d.memoizedProps.style,o=l!=null&&l.hasOwnProperty("display")?l.display:null,a.style.display=vC("display",o))}catch(v){kt(e,e.return,v)}}}else if(d.tag===6){if(u===null)try{d.stateNode.nodeValue=c?"":d.memoizedProps}catch(v){kt(e,e.return,v)}}else if((d.tag!==22&&d.tag!==23||d.memoizedState===null||d===e)&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===e)break e;for(;d.sibling===null;){if(d.return===null||d.return===e)break e;u===d&&(u=null),d=d.return}u===d&&(u=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:kr(t,e),Br(e),r&4&&E1(e);break;case 21:break;default:kr(t,e),Br(e)}}function Br(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(U2(n)){var r=n;break e}n=n.return}throw Error(G(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(lc(i,""),r.flags&=-33);var s=C1(e);Pg(e,s,i);break;case 3:case 4:var o=r.stateNode.containerInfo,a=C1(e);Tg(e,a,o);break;default:throw Error(G(161))}}catch(l){kt(e,e.return,l)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function kj(e,t,n){le=e,q2(e)}function q2(e,t,n){for(var r=(e.mode&1)!==0;le!==null;){var i=le,s=i.child;if(i.tag===22&&r){var o=i.memoizedState!==null||Ou;if(!o){var a=i.alternate,l=a!==null&&a.memoizedState!==null||xn;a=Ou;var c=xn;if(Ou=o,(xn=l)&&!c)for(le=i;le!==null;)o=le,l=o.child,o.tag===22&&o.memoizedState!==null?P1(i):l!==null?(l.return=o,le=l):P1(i);for(;s!==null;)le=s,q2(s),s=s.sibling;le=i,Ou=a,xn=c}N1(e)}else i.subtreeFlags&8772&&s!==null?(s.return=i,le=s):N1(e)}}function N1(e){for(;le!==null;){var t=le;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:xn||cf(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!xn)if(n===null)r.componentDidMount();else{var i=t.elementType===t.type?n.memoizedProps:Er(t.type,n.memoizedProps);r.componentDidUpdate(i,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var s=t.updateQueue;s!==null&&d1(t,s,r);break;case 3:var o=t.updateQueue;if(o!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}d1(t,o,n)}break;case 5:var a=t.stateNode;if(n===null&&t.flags&4){n=a;var l=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&n.focus();break;case"img":l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var c=t.alternate;if(c!==null){var u=c.memoizedState;if(u!==null){var d=u.dehydrated;d!==null&&hc(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(G(163))}xn||t.flags&512&&Ng(t)}catch(f){kt(t,t.return,f)}}if(t===e){le=null;break}if(n=t.sibling,n!==null){n.return=t.return,le=n;break}le=t.return}}function T1(e){for(;le!==null;){var t=le;if(t===e){le=null;break}var n=t.sibling;if(n!==null){n.return=t.return,le=n;break}le=t.return}}function P1(e){for(;le!==null;){var t=le;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{cf(4,t)}catch(l){kt(t,n,l)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var i=t.return;try{r.componentDidMount()}catch(l){kt(t,i,l)}}var s=t.return;try{Ng(t)}catch(l){kt(t,s,l)}break;case 5:var o=t.return;try{Ng(t)}catch(l){kt(t,o,l)}}}catch(l){kt(t,t.return,l)}if(t===e){le=null;break}var a=t.sibling;if(a!==null){a.return=t.return,le=a;break}le=t.return}}var Cj=Math.ceil,fh=Li.ReactCurrentDispatcher,__=Li.ReactCurrentOwner,gr=Li.ReactCurrentBatchConfig,Ge=0,on=null,Ot=null,hn=0,Yn=0,oa=Ts(0),Vt=0,Sc=null,oo=0,uf=0,x_=0,Zl=null,$n=null,y_=0,Ia=1/0,_i=null,ph=!1,Ig=null,gs=null,Bu=!1,ls=null,mh=0,Ql=0,Rg=null,Nd=-1,Td=0;function Nn(){return Ge&6?It():Nd!==-1?Nd:Nd=It()}function vs(e){return e.mode&1?Ge&2&&hn!==0?hn&-hn:lj.transition!==null?(Td===0&&(Td=IC()),Td):(e=Je,e!==0||(e=window.event,e=e===void 0?16:OC(e.type)),e):1}function Rr(e,t,n,r){if(50<Ql)throw Ql=0,Rg=null,Error(G(185));Zc(e,n,r),(!(Ge&2)||e!==on)&&(e===on&&(!(Ge&2)&&(uf|=n),Vt===4&&ss(e,hn)),Wn(e,r),n===1&&Ge===0&&!(t.mode&1)&&(Ia=It()+500,of&&Ps()))}function Wn(e,t){var n=e.callbackNode;l5(e,t);var r=Qd(e,e===on?hn:0);if(r===0)n!==null&&By(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&By(n),t===1)e.tag===0?aj(I1.bind(null,e)):n2(I1.bind(null,e)),rj(function(){!(Ge&6)&&Ps()}),n=null;else{switch(RC(r)){case 1:n=q0;break;case 4:n=TC;break;case 16:n=Zd;break;case 536870912:n=PC;break;default:n=Zd}n=eE(n,K2.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function K2(e,t){if(Nd=-1,Td=0,Ge&6)throw Error(G(327));var n=e.callbackNode;if(ga()&&e.callbackNode!==n)return null;var r=Qd(e,e===on?hn:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=gh(e,r);else{t=r;var i=Ge;Ge|=2;var s=X2();(on!==e||hn!==t)&&(_i=null,Ia=It()+500,Qs(e,t));do try{Tj();break}catch(a){G2(e,a)}while(!0);s_(),fh.current=s,Ge=i,Ot!==null?t=0:(on=null,hn=0,t=Vt)}if(t!==0){if(t===2&&(i=ig(e),i!==0&&(r=i,t=Mg(e,i))),t===1)throw n=Sc,Qs(e,0),ss(e,r),Wn(e,It()),n;if(t===6)ss(e,r);else{if(i=e.current.alternate,!(r&30)&&!Ej(i)&&(t=gh(e,r),t===2&&(s=ig(e),s!==0&&(r=s,t=Mg(e,s))),t===1))throw n=Sc,Qs(e,0),ss(e,r),Wn(e,It()),n;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(G(345));case 2:Fs(e,$n,_i);break;case 3:if(ss(e,r),(r&130023424)===r&&(t=y_+500-It(),10<t)){if(Qd(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){Nn(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=hg(Fs.bind(null,e,$n,_i),t);break}Fs(e,$n,_i);break;case 4:if(ss(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var o=31-Ir(r);s=1<<o,o=t[o],o>i&&(i=o),r&=~s}if(r=i,r=It()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Cj(r/1960))-r,10<r){e.timeoutHandle=hg(Fs.bind(null,e,$n,_i),r);break}Fs(e,$n,_i);break;case 5:Fs(e,$n,_i);break;default:throw Error(G(329))}}}return Wn(e,It()),e.callbackNode===n?K2.bind(null,e):null}function Mg(e,t){var n=Zl;return e.current.memoizedState.isDehydrated&&(Qs(e,t).flags|=256),e=gh(e,t),e!==2&&(t=$n,$n=n,t!==null&&Ag(t)),e}function Ag(e){$n===null?$n=e:$n.push.apply($n,e)}function Ej(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],s=i.getSnapshot;i=i.value;try{if(!jr(s(),i))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ss(e,t){for(t&=~x_,t&=~uf,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Ir(t),r=1<<n;e[n]=-1,t&=~r}}function I1(e){if(Ge&6)throw Error(G(327));ga();var t=Qd(e,0);if(!(t&1))return Wn(e,It()),null;var n=gh(e,t);if(e.tag!==0&&n===2){var r=ig(e);r!==0&&(t=r,n=Mg(e,r))}if(n===1)throw n=Sc,Qs(e,0),ss(e,t),Wn(e,It()),n;if(n===6)throw Error(G(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Fs(e,$n,_i),Wn(e,It()),null}function b_(e,t){var n=Ge;Ge|=1;try{return e(t)}finally{Ge=n,Ge===0&&(Ia=It()+500,of&&Ps())}}function ao(e){ls!==null&&ls.tag===0&&!(Ge&6)&&ga();var t=Ge;Ge|=1;var n=gr.transition,r=Je;try{if(gr.transition=null,Je=1,e)return e()}finally{Je=r,gr.transition=n,Ge=t,!(Ge&6)&&Ps()}}function w_(){Yn=oa.current,ht(oa)}function Qs(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,nj(n)),Ot!==null)for(n=Ot.return;n!==null;){var r=n;switch(n_(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&rh();break;case 3:Ta(),ht(Hn),ht(bn),d_();break;case 5:u_(r);break;case 4:Ta();break;case 13:ht(_t);break;case 19:ht(_t);break;case 10:o_(r.type._context);break;case 22:case 23:w_()}n=n.return}if(on=e,Ot=e=_s(e.current,null),hn=Yn=t,Vt=0,Sc=null,x_=uf=oo=0,$n=Zl=null,Ks!==null){for(t=0;t<Ks.length;t++)if(n=Ks[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,s=n.pending;if(s!==null){var o=s.next;s.next=i,r.next=o}n.pending=r}Ks=null}return e}function G2(e,t){do{var n=Ot;try{if(s_(),kd.current=hh,dh){for(var r=yt.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}dh=!1}if(so=0,tn=Wt=yt=null,Xl=!1,yc=0,__.current=null,n===null||n.return===null){Vt=1,Sc=t,Ot=null;break}e:{var s=e,o=n.return,a=n,l=t;if(t=hn,a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var c=l,u=a,d=u.tag;if(!(u.mode&1)&&(d===0||d===11||d===15)){var f=u.alternate;f?(u.updateQueue=f.updateQueue,u.memoizedState=f.memoizedState,u.lanes=f.lanes):(u.updateQueue=null,u.memoizedState=null)}var p=v1(o);if(p!==null){p.flags&=-257,_1(p,o,a,s,t),p.mode&1&&g1(s,c,t),t=p,l=c;var m=t.updateQueue;if(m===null){var v=new Set;v.add(l),t.updateQueue=v}else m.add(l);break e}else{if(!(t&1)){g1(s,c,t),S_();break e}l=Error(G(426))}}else if(ft&&a.mode&1){var y=v1(o);if(y!==null){!(y.flags&65536)&&(y.flags|=256),_1(y,o,a,s,t),r_(Pa(l,a));break e}}s=l=Pa(l,a),Vt!==4&&(Vt=2),Zl===null?Zl=[s]:Zl.push(s),s=o;do{switch(s.tag){case 3:s.flags|=65536,t&=-t,s.lanes|=t;var _=R2(s,l,t);u1(s,_);break e;case 1:a=l;var x=s.type,b=s.stateNode;if(!(s.flags&128)&&(typeof x.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(gs===null||!gs.has(b)))){s.flags|=65536,t&=-t,s.lanes|=t;var w=M2(s,a,t);u1(s,w);break e}}s=s.return}while(s!==null)}Z2(n)}catch(S){t=S,Ot===n&&n!==null&&(Ot=n=n.return);continue}break}while(!0)}function X2(){var e=fh.current;return fh.current=hh,e===null?hh:e}function S_(){(Vt===0||Vt===3||Vt===2)&&(Vt=4),on===null||!(oo&268435455)&&!(uf&268435455)||ss(on,hn)}function gh(e,t){var n=Ge;Ge|=2;var r=X2();(on!==e||hn!==t)&&(_i=null,Qs(e,t));do try{Nj();break}catch(i){G2(e,i)}while(!0);if(s_(),Ge=n,fh.current=r,Ot!==null)throw Error(G(261));return on=null,hn=0,Vt}function Nj(){for(;Ot!==null;)Y2(Ot)}function Tj(){for(;Ot!==null&&!JA();)Y2(Ot)}function Y2(e){var t=J2(e.alternate,e,Yn);e.memoizedProps=e.pendingProps,t===null?Z2(e):Ot=t,__.current=null}function Z2(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=bj(n,t),n!==null){n.flags&=32767,Ot=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Vt=6,Ot=null;return}}else if(n=yj(n,t,Yn),n!==null){Ot=n;return}if(t=t.sibling,t!==null){Ot=t;return}Ot=t=e}while(t!==null);Vt===0&&(Vt=5)}function Fs(e,t,n){var r=Je,i=gr.transition;try{gr.transition=null,Je=1,Pj(e,t,n,r)}finally{gr.transition=i,Je=r}return null}function Pj(e,t,n,r){do ga();while(ls!==null);if(Ge&6)throw Error(G(327));n=e.finishedWork;var i=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(G(177));e.callbackNode=null,e.callbackPriority=0;var s=n.lanes|n.childLanes;if(c5(e,s),e===on&&(Ot=on=null,hn=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Bu||(Bu=!0,eE(Zd,function(){return ga(),null})),s=(n.flags&15990)!==0,n.subtreeFlags&15990||s){s=gr.transition,gr.transition=null;var o=Je;Je=1;var a=Ge;Ge|=4,__.current=null,Sj(e,n),V2(n,e),X5(ug),Jd=!!cg,ug=cg=null,e.current=n,kj(n),e5(),Ge=a,Je=o,gr.transition=s}else e.current=n;if(Bu&&(Bu=!1,ls=e,mh=i),s=e.pendingLanes,s===0&&(gs=null),r5(n.stateNode),Wn(e,It()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)i=t[n],r(i.value,{componentStack:i.stack,digest:i.digest});if(ph)throw ph=!1,e=Ig,Ig=null,e;return mh&1&&e.tag!==0&&ga(),s=e.pendingLanes,s&1?e===Rg?Ql++:(Ql=0,Rg=e):Ql=0,Ps(),null}function ga(){if(ls!==null){var e=RC(mh),t=gr.transition,n=Je;try{if(gr.transition=null,Je=16>e?16:e,ls===null)var r=!1;else{if(e=ls,ls=null,mh=0,Ge&6)throw Error(G(331));var i=Ge;for(Ge|=4,le=e.current;le!==null;){var s=le,o=s.child;if(le.flags&16){var a=s.deletions;if(a!==null){for(var l=0;l<a.length;l++){var c=a[l];for(le=c;le!==null;){var u=le;switch(u.tag){case 0:case 11:case 15:Yl(8,u,s)}var d=u.child;if(d!==null)d.return=u,le=d;else for(;le!==null;){u=le;var f=u.sibling,p=u.return;if(H2(u),u===c){le=null;break}if(f!==null){f.return=p,le=f;break}le=p}}}var m=s.alternate;if(m!==null){var v=m.child;if(v!==null){m.child=null;do{var y=v.sibling;v.sibling=null,v=y}while(v!==null)}}le=s}}if(s.subtreeFlags&2064&&o!==null)o.return=s,le=o;else e:for(;le!==null;){if(s=le,s.flags&2048)switch(s.tag){case 0:case 11:case 15:Yl(9,s,s.return)}var _=s.sibling;if(_!==null){_.return=s.return,le=_;break e}le=s.return}}var x=e.current;for(le=x;le!==null;){o=le;var b=o.child;if(o.subtreeFlags&2064&&b!==null)b.return=o,le=b;else e:for(o=x;le!==null;){if(a=le,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:cf(9,a)}}catch(S){kt(a,a.return,S)}if(a===o){le=null;break e}var w=a.sibling;if(w!==null){w.return=a.return,le=w;break e}le=a.return}}if(Ge=i,Ps(),Qr&&typeof Qr.onPostCommitFiberRoot=="function")try{Qr.onPostCommitFiberRoot(ef,e)}catch{}r=!0}return r}finally{Je=n,gr.transition=t}}return!1}function R1(e,t,n){t=Pa(n,t),t=R2(e,t,1),e=ms(e,t,1),t=Nn(),e!==null&&(Zc(e,1,t),Wn(e,t))}function kt(e,t,n){if(e.tag===3)R1(e,e,n);else for(;t!==null;){if(t.tag===3){R1(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(gs===null||!gs.has(r))){e=Pa(n,e),e=M2(t,e,1),t=ms(t,e,1),e=Nn(),t!==null&&(Zc(t,1,e),Wn(t,e));break}}t=t.return}}function Ij(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Nn(),e.pingedLanes|=e.suspendedLanes&n,on===e&&(hn&n)===n&&(Vt===4||Vt===3&&(hn&130023424)===hn&&500>It()-y_?Qs(e,0):x_|=n),Wn(e,t)}function Q2(e,t){t===0&&(e.mode&1?(t=Tu,Tu<<=1,!(Tu&130023424)&&(Tu=4194304)):t=1);var n=Nn();e=Pi(e,t),e!==null&&(Zc(e,t,n),Wn(e,n))}function Rj(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Q2(e,n)}function Mj(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(G(314))}r!==null&&r.delete(t),Q2(e,n)}var J2;J2=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Hn.current)Fn=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Fn=!1,xj(e,t,n);Fn=!!(e.flags&131072)}else Fn=!1,ft&&t.flags&1048576&&r2(t,oh,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ed(e,t),e=t.pendingProps;var i=Ca(t,bn.current);ma(t,n),i=f_(null,t,r,e,i,n);var s=p_();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Un(r)?(s=!0,ih(t)):s=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,l_(t),i.updater=lf,t.stateNode=i,i._reactInternals=t,xg(t,r,e,n),t=wg(null,t,r,!0,s,n)):(t.tag=0,ft&&s&&t_(t),kn(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ed(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=jj(r),e=Er(r,e),i){case 0:t=bg(null,t,r,e,n);break e;case 1:t=b1(null,t,r,e,n);break e;case 11:t=x1(null,t,r,e,n);break e;case 14:t=y1(null,t,r,Er(r.type,e),n);break e}throw Error(G(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Er(r,i),bg(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Er(r,i),b1(e,t,r,i,n);case 3:e:{if(L2(t),e===null)throw Error(G(387));r=t.pendingProps,s=t.memoizedState,i=s.element,c2(e,t),ch(t,r,null,n);var o=t.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){i=Pa(Error(G(423)),t),t=w1(e,t,r,n,i);break e}else if(r!==i){i=Pa(Error(G(424)),t),t=w1(e,t,r,n,i);break e}else for(Qn=ps(t.stateNode.containerInfo.firstChild),Jn=t,ft=!0,Pr=null,n=a2(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ea(),r===i){t=Ii(e,t,n);break e}kn(e,t,r,n)}t=t.child}return t;case 5:return u2(t),e===null&&gg(t),r=t.type,i=t.pendingProps,s=e!==null?e.memoizedProps:null,o=i.children,dg(r,i)?o=null:s!==null&&dg(r,s)&&(t.flags|=32),D2(e,t),kn(e,t,o,n),t.child;case 6:return e===null&&gg(t),null;case 13:return O2(e,t,n);case 4:return c_(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Na(t,null,r,n):kn(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Er(r,i),x1(e,t,r,i,n);case 7:return kn(e,t,t.pendingProps,n),t.child;case 8:return kn(e,t,t.pendingProps.children,n),t.child;case 12:return kn(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,s=t.memoizedProps,o=i.value,ct(ah,r._currentValue),r._currentValue=o,s!==null)if(jr(s.value,o)){if(s.children===i.children&&!Hn.current){t=Ii(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var l=a.firstContext;l!==null;){if(l.context===r){if(s.tag===1){l=ki(-1,n&-n),l.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),vg(s.return,n,t),a.lanes|=n;break}l=l.next}}else if(s.tag===10)o=s.type===t.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(G(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),vg(o,n,t),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===t){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}kn(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,ma(t,n),i=xr(i),r=r(i),t.flags|=1,kn(e,t,r,n),t.child;case 14:return r=t.type,i=Er(r,t.pendingProps),i=Er(r.type,i),y1(e,t,r,i,n);case 15:return A2(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Er(r,i),Ed(e,t),t.tag=1,Un(r)?(e=!0,ih(t)):e=!1,ma(t,n),I2(t,r,i),xg(t,r,i,n),wg(null,t,r,!0,e,n);case 19:return B2(e,t,n);case 22:return j2(e,t,n)}throw Error(G(156,t.tag))};function eE(e,t){return NC(e,t)}function Aj(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function mr(e,t,n,r){return new Aj(e,t,n,r)}function k_(e){return e=e.prototype,!(!e||!e.isReactComponent)}function jj(e){if(typeof e=="function")return k_(e)?1:0;if(e!=null){if(e=e.$$typeof,e===U0)return 11;if(e===W0)return 14}return 2}function _s(e,t){var n=e.alternate;return n===null?(n=mr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Pd(e,t,n,r,i,s){var o=2;if(r=e,typeof e=="function")k_(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Yo:return Js(n.children,i,s,t);case H0:o=8,i|=8;break;case Um:return e=mr(12,n,t,i|2),e.elementType=Um,e.lanes=s,e;case Wm:return e=mr(13,n,t,i),e.elementType=Wm,e.lanes=s,e;case Vm:return e=mr(19,n,t,i),e.elementType=Vm,e.lanes=s,e;case uC:return df(n,i,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case lC:o=10;break e;case cC:o=9;break e;case U0:o=11;break e;case W0:o=14;break e;case es:o=16,r=null;break e}throw Error(G(130,e==null?e:typeof e,""))}return t=mr(o,n,t,i),t.elementType=e,t.type=r,t.lanes=s,t}function Js(e,t,n,r){return e=mr(7,e,r,t),e.lanes=n,e}function df(e,t,n,r){return e=mr(22,e,r,t),e.elementType=uC,e.lanes=n,e.stateNode={isHidden:!1},e}function jp(e,t,n){return e=mr(6,e,null,t),e.lanes=n,e}function Dp(e,t,n){return t=mr(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Dj(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=mp(0),this.expirationTimes=mp(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=mp(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function C_(e,t,n,r,i,s,o,a,l){return e=new Dj(e,t,n,a,l),t===1?(t=1,s===!0&&(t|=8)):t=0,s=mr(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},l_(s),e}function Lj(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Xo,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function tE(e){if(!e)return ws;e=e._reactInternals;e:{if(wo(e)!==e||e.tag!==1)throw Error(G(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Un(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(G(171))}if(e.tag===1){var n=e.type;if(Un(n))return t2(e,n,t)}return t}function nE(e,t,n,r,i,s,o,a,l){return e=C_(n,r,!0,e,i,s,o,a,l),e.context=tE(null),n=e.current,r=Nn(),i=vs(n),s=ki(r,i),s.callback=t??null,ms(n,s,i),e.current.lanes=i,Zc(e,i,r),Wn(e,r),e}function hf(e,t,n,r){var i=t.current,s=Nn(),o=vs(i);return n=tE(n),t.context===null?t.context=n:t.pendingContext=n,t=ki(s,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=ms(i,t,o),e!==null&&(Rr(e,i,o,s),Sd(e,i,o)),o}function vh(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function M1(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function E_(e,t){M1(e,t),(e=e.alternate)&&M1(e,t)}function Oj(){return null}var rE=typeof reportError=="function"?reportError:function(e){console.error(e)};function N_(e){this._internalRoot=e}ff.prototype.render=N_.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(G(409));hf(e,t,null,null)};ff.prototype.unmount=N_.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ao(function(){hf(null,e,null,null)}),t[Ti]=null}};function ff(e){this._internalRoot=e}ff.prototype.unstable_scheduleHydration=function(e){if(e){var t=jC();e={blockedOn:null,target:e,priority:t};for(var n=0;n<is.length&&t!==0&&t<is[n].priority;n++);is.splice(n,0,e),n===0&&LC(e)}};function T_(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function pf(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function A1(){}function Bj(e,t,n,r,i){if(i){if(typeof r=="function"){var s=r;r=function(){var c=vh(o);s.call(c)}}var o=nE(t,r,e,0,null,!1,!1,"",A1);return e._reactRootContainer=o,e[Ti]=o.current,mc(e.nodeType===8?e.parentNode:e),ao(),o}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var a=r;r=function(){var c=vh(l);a.call(c)}}var l=C_(e,0,!1,null,null,!1,!1,"",A1);return e._reactRootContainer=l,e[Ti]=l.current,mc(e.nodeType===8?e.parentNode:e),ao(function(){hf(t,l,n,r)}),l}function mf(e,t,n,r,i){var s=n._reactRootContainer;if(s){var o=s;if(typeof i=="function"){var a=i;i=function(){var l=vh(o);a.call(l)}}hf(t,o,e,i)}else o=Bj(n,t,e,i,r);return vh(o)}MC=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Al(t.pendingLanes);n!==0&&(K0(t,n|1),Wn(t,It()),!(Ge&6)&&(Ia=It()+500,Ps()))}break;case 13:ao(function(){var r=Pi(e,1);if(r!==null){var i=Nn();Rr(r,e,1,i)}}),E_(e,1)}};G0=function(e){if(e.tag===13){var t=Pi(e,134217728);if(t!==null){var n=Nn();Rr(t,e,134217728,n)}E_(e,134217728)}};AC=function(e){if(e.tag===13){var t=vs(e),n=Pi(e,t);if(n!==null){var r=Nn();Rr(n,e,t,r)}E_(e,t)}};jC=function(){return Je};DC=function(e,t){var n=Je;try{return Je=e,t()}finally{Je=n}};tg=function(e,t,n){switch(t){case"input":if(Gm(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=sf(r);if(!i)throw Error(G(90));hC(r),Gm(r,i)}}}break;case"textarea":pC(e,n);break;case"select":t=n.value,t!=null&&da(e,!!n.multiple,t,!1)}};bC=b_;wC=ao;var zj={usingClientEntryPoint:!1,Events:[Jc,ea,sf,xC,yC,b_]},_l={findFiberByHostInstance:qs,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},$j={bundleType:_l.bundleType,version:_l.version,rendererPackageName:_l.rendererPackageName,rendererConfig:_l.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Li.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=CC(e),e===null?null:e.stateNode},findFiberByHostInstance:_l.findFiberByHostInstance||Oj,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var zu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zu.isDisabled&&zu.supportsFiber)try{ef=zu.inject($j),Qr=zu}catch{}}ir.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=zj;ir.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!T_(t))throw Error(G(200));return Lj(e,t,null,n)};ir.createRoot=function(e,t){if(!T_(e))throw Error(G(299));var n=!1,r="",i=rE;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=C_(e,1,!1,null,null,n,!1,r,i),e[Ti]=t.current,mc(e.nodeType===8?e.parentNode:e),new N_(t)};ir.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(G(188)):(e=Object.keys(e).join(","),Error(G(268,e)));return e=CC(t),e=e===null?null:e.stateNode,e};ir.flushSync=function(e){return ao(e)};ir.hydrate=function(e,t,n){if(!pf(t))throw Error(G(200));return mf(null,e,t,!0,n)};ir.hydrateRoot=function(e,t,n){if(!T_(e))throw Error(G(405));var r=n!=null&&n.hydratedSources||null,i=!1,s="",o=rE;if(n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),t=nE(t,null,e,1,n??null,i,!1,s,o),e[Ti]=t.current,mc(e),r)for(e=0;e<r.length;e++)n=r[e],i=n._getVersion,i=i(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,i]:t.mutableSourceEagerHydrationData.push(n,i);return new ff(t)};ir.render=function(e,t,n){if(!pf(t))throw Error(G(200));return mf(null,e,t,!1,n)};ir.unmountComponentAtNode=function(e){if(!pf(e))throw Error(G(40));return e._reactRootContainer?(ao(function(){mf(null,null,e,!1,function(){e._reactRootContainer=null,e[Ti]=null})}),!0):!1};ir.unstable_batchedUpdates=b_;ir.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!pf(n))throw Error(G(200));if(e==null||e._reactInternals===void 0)throw Error(G(38));return mf(e,t,n,!1,r)};ir.version="18.3.1-next-f1338f8080-20240426";function iE(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(iE)}catch(e){console.error(e)}}iE(),iC.exports=ir;var tu=iC.exports;const jg=Xc(tu);var j1=tu;Fm.createRoot=j1.createRoot,Fm.hydrateRoot=j1.hydrateRoot;const sE="(prefers-color-scheme: dark)",Fj=["light","dark","system"],oE="clawd-standalone:theme-source",Hj="light",Uj={colorPrimary:"#1677ff",colorBgContainer:"#fff",colorText:"#000",colorBorder:"#d9d9d9"};function Wj(){try{const e=localStorage.getItem(oE);if(e!==null&&Fj.includes(e))return e}catch{}return Hj}function Vj(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(sE).matches}function D1(e){return{mode:e==="dark"||e==="system"&&Vj()?"dark":"light",...Uj}}function qj(e){let t=Wj();const n=new Set,r=()=>{const s=D1(t);for(const o of n)o(s)};typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(sE).addEventListener("change",()=>{t==="system"&&r()});const i={gateway:{call:()=>Promise.reject(new Error("standalone-host: gateway.call not supported"))},self:{call:()=>Promise.reject(new Error("standalone-host: self.call removed; use useDaemonClient()"))},kv:{get:async s=>{const o=localStorage.getItem(`clawd-standalone:kv:${s}`);if(o==null)return null;try{return JSON.parse(o)}catch{return null}},set:async(s,o)=>{localStorage.setItem(`clawd-standalone:kv:${s}`,JSON.stringify(o))}},logger:{info:(s,o)=>{var a;console.info("[ext]",s,o??""),(a=e.logClient)==null||a.push({level:"info",msg:String(s),meta:o})},warn:(s,o)=>{var a;console.warn("[ext]",s,o??""),(a=e.logClient)==null||a.push({level:"warn",msg:String(s),meta:o})},error:(s,o)=>{var a;console.error("[ext]",s,o??""),(a=e.logClient)==null||a.push({level:"error",msg:String(s),meta:o})}},get theme(){return D1(t)},on(){return()=>{}},onThemeChange(s){return n.add(s),()=>{n.delete(s)}}};return i.getThemeSource=()=>t,i.setThemeSource=s=>{t=s;try{localStorage.setItem(oE,s)}catch{}r()},e.notifier&&(i.notifier=e.notifier),i}const aE=g.createContext(null);function L1({host:e,children:t}){return h.jsx(aE.Provider,{value:e,children:t})}function P_(){const e=g.useContext(aE);if(!e)throw new Error("HostProvider missing");return e}var lE={exports:{}};/*!
40
+ `+s.stack}return{value:e,source:t,stack:i,digest:null}}function Mp(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function yg(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var gj=typeof WeakMap=="function"?WeakMap:Map;function R2(e,t,n){n=ki(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){ph||(ph=!0,Ig=r),yg(e,t)},n}function M2(e,t,n){n=ki(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){yg(e,t)}}var s=e.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){yg(e,t),typeof r!="function"&&(gs===null?gs=new Set([this]):gs.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function g1(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new gj;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=Ij.bind(null,e,t,n),t.then(e,e))}function v1(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function _1(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=ki(-1,1),t.tag=2,ms(n,t,1))),n.lanes|=1),e)}var vj=Li.ReactCurrentOwner,Fn=!1;function kn(e,t,n,r){t.child=e===null?a2(t,null,n,r):Na(t,e.child,n,r)}function x1(e,t,n,r,i){n=n.render;var s=t.ref;return ma(t,i),r=f_(e,t,n,r,s,i),n=p_(),e!==null&&!Fn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Ii(e,t,i)):(ft&&n&&t_(t),t.flags|=1,kn(e,t,r,i),t.child)}function y1(e,t,n,r,i){if(e===null){var s=n.type;return typeof s=="function"&&!k_(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=s,A2(e,t,s,r,i)):(e=Pd(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(s=e.child,!(e.lanes&i)){var o=s.memoizedProps;if(n=n.compare,n=n!==null?n:pc,n(o,r)&&e.ref===t.ref)return Ii(e,t,i)}return t.flags|=1,e=_s(s,r),e.ref=t.ref,e.return=t,t.child=e}function A2(e,t,n,r,i){if(e!==null){var s=e.memoizedProps;if(pc(s,r)&&e.ref===t.ref)if(Fn=!1,t.pendingProps=r=s,(e.lanes&i)!==0)e.flags&131072&&(Fn=!0);else return t.lanes=e.lanes,Ii(e,t,i)}return bg(e,t,n,r,i)}function j2(e,t,n){var r=t.pendingProps,i=r.children,s=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},ct(oa,Yn),Yn|=n;else{if(!(n&1073741824))return e=s!==null?s.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,ct(oa,Yn),Yn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,ct(oa,Yn),Yn|=r}else s!==null?(r=s.baseLanes|n,t.memoizedState=null):r=n,ct(oa,Yn),Yn|=r;return kn(e,t,i,n),t.child}function D2(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function bg(e,t,n,r,i){var s=Un(n)?ro:bn.current;return s=Ca(t,s),ma(t,i),n=f_(e,t,n,r,s,i),r=p_(),e!==null&&!Fn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Ii(e,t,i)):(ft&&r&&t_(t),t.flags|=1,kn(e,t,n,i),t.child)}function b1(e,t,n,r,i){if(Un(n)){var s=!0;ih(t)}else s=!1;if(ma(t,i),t.stateNode===null)Ed(e,t),I2(t,n,r),xg(t,n,r,i),r=!0;else if(e===null){var o=t.stateNode,a=t.memoizedProps;o.props=a;var l=o.context,c=n.contextType;typeof c=="object"&&c!==null?c=xr(c):(c=Un(n)?ro:bn.current,c=Ca(t,c));var u=n.getDerivedStateFromProps,d=typeof u=="function"||typeof o.getSnapshotBeforeUpdate=="function";d||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||l!==c)&&m1(t,o,r,c),ts=!1;var f=t.memoizedState;o.state=f,ch(t,r,o,i),l=t.memoizedState,a!==r||f!==l||Hn.current||ts?(typeof u=="function"&&(_g(t,n,u,r),l=t.memoizedState),(a=ts||p1(t,n,a,r,f,l,c))?(d||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),o.props=r,o.state=l,o.context=c,r=a):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,c2(e,t),a=t.memoizedProps,c=t.type===t.elementType?a:Er(t.type,a),o.props=c,d=t.pendingProps,f=o.context,l=n.contextType,typeof l=="object"&&l!==null?l=xr(l):(l=Un(n)?ro:bn.current,l=Ca(t,l));var p=n.getDerivedStateFromProps;(u=typeof p=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==d||f!==l)&&m1(t,o,r,l),ts=!1,f=t.memoizedState,o.state=f,ch(t,r,o,i);var m=t.memoizedState;a!==d||f!==m||Hn.current||ts?(typeof p=="function"&&(_g(t,n,p,r),m=t.memoizedState),(c=ts||p1(t,n,c,r,f,m,l)||!1)?(u||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,m,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,m,l)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=m),o.props=r,o.state=m,o.context=l,r=c):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return wg(e,t,n,r,s,i)}function wg(e,t,n,r,i,s){D2(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return i&&o1(t,n,!1),Ii(e,t,s);r=t.stateNode,vj.current=t;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=Na(t,e.child,null,s),t.child=Na(t,null,a,s)):kn(e,t,a,s),t.memoizedState=r.state,i&&o1(t,n,!0),t.child}function L2(e){var t=e.stateNode;t.pendingContext?s1(e,t.pendingContext,t.pendingContext!==t.context):t.context&&s1(e,t.context,!1),c_(e,t.containerInfo)}function w1(e,t,n,r,i){return Ea(),r_(i),t.flags|=256,kn(e,t,n,r),t.child}var Sg={dehydrated:null,treeContext:null,retryLane:0};function kg(e){return{baseLanes:e,cachePool:null,transitions:null}}function O2(e,t,n){var r=t.pendingProps,i=_t.current,s=!1,o=(t.flags&128)!==0,a;if((a=o)||(a=e!==null&&e.memoizedState===null?!1:(i&2)!==0),a?(s=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),ct(_t,i&1),e===null)return gg(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,s?(r=t.mode,s=t.child,o={mode:"hidden",children:o},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=o):s=df(o,r,0,null),e=Js(e,r,n,null),s.return=t,e.return=t,s.sibling=e,t.child=s,t.child.memoizedState=kg(n),t.memoizedState=Sg,e):v_(t,o));if(i=e.memoizedState,i!==null&&(a=i.dehydrated,a!==null))return _j(e,t,o,r,a,i,n);if(s){s=r.fallback,o=t.mode,i=e.child,a=i.sibling;var l={mode:"hidden",children:r.children};return!(o&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=l,t.deletions=null):(r=_s(i,l),r.subtreeFlags=i.subtreeFlags&14680064),a!==null?s=_s(a,s):(s=Js(s,o,n,null),s.flags|=2),s.return=t,r.return=t,r.sibling=s,t.child=r,r=s,s=t.child,o=e.child.memoizedState,o=o===null?kg(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},s.memoizedState=o,s.childLanes=e.childLanes&~n,t.memoizedState=Sg,r}return s=e.child,e=s.sibling,r=_s(s,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function v_(e,t){return t=df({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Lu(e,t,n,r){return r!==null&&r_(r),Na(t,e.child,null,n),e=v_(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function _j(e,t,n,r,i,s,o){if(n)return t.flags&256?(t.flags&=-257,r=Mp(Error(G(422))),Lu(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(s=r.fallback,i=t.mode,r=df({mode:"visible",children:r.children},i,0,null),s=Js(s,i,o,null),s.flags|=2,r.return=t,s.return=t,r.sibling=s,t.child=r,t.mode&1&&Na(t,e.child,null,o),t.child.memoizedState=kg(o),t.memoizedState=Sg,s);if(!(t.mode&1))return Lu(e,t,o,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var a=r.dgst;return r=a,s=Error(G(419)),r=Mp(s,r,void 0),Lu(e,t,o,r)}if(a=(o&e.childLanes)!==0,Fn||a){if(r=on,r!==null){switch(o&-o){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|o)?0:i,i!==0&&i!==s.retryLane&&(s.retryLane=i,Pi(e,i),Rr(r,e,i,-1))}return S_(),r=Mp(Error(G(421))),Lu(e,t,o,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=Rj.bind(null,e),i._reactRetry=t,null):(e=s.treeContext,Qn=ps(i.nextSibling),Jn=t,ft=!0,Pr=null,e!==null&&(hr[fr++]=yi,hr[fr++]=bi,hr[fr++]=io,yi=e.id,bi=e.overflow,io=t),t=v_(t,r.children),t.flags|=4096,t)}function S1(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),vg(e.return,t,n)}function Ap(e,t,n,r,i){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i)}function B2(e,t,n){var r=t.pendingProps,i=r.revealOrder,s=r.tail;if(kn(e,t,r.children,n),r=_t.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&S1(e,n,t);else if(e.tag===19)S1(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(ct(_t,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&uh(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Ap(t,!1,i,n,s);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&uh(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Ap(t,!0,n,null,s);break;case"together":Ap(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Ed(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Ii(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),oo|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(G(153));if(t.child!==null){for(e=t.child,n=_s(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=_s(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function xj(e,t,n){switch(t.tag){case 3:L2(t),Ea();break;case 5:u2(t);break;case 1:Un(t.type)&&ih(t);break;case 4:c_(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;ct(ah,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(ct(_t,_t.current&1),t.flags|=128,null):n&t.child.childLanes?O2(e,t,n):(ct(_t,_t.current&1),e=Ii(e,t,n),e!==null?e.sibling:null);ct(_t,_t.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return B2(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),ct(_t,_t.current),r)break;return null;case 22:case 23:return t.lanes=0,j2(e,t,n)}return Ii(e,t,n)}var z2,Cg,$2,F2;z2=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Cg=function(){};$2=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,Gs(Jr.current);var s=null;switch(n){case"input":i=Km(e,i),r=Km(e,r),s=[];break;case"select":i=bt({},i,{value:void 0}),r=bt({},r,{value:void 0}),s=[];break;case"textarea":i=Ym(e,i),r=Ym(e,r),s=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=nh)}Qm(n,r);var o;n=null;for(c in i)if(!r.hasOwnProperty(c)&&i.hasOwnProperty(c)&&i[c]!=null)if(c==="style"){var a=i[c];for(o in a)a.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(ac.hasOwnProperty(c)?s||(s=[]):(s=s||[]).push(c,null));for(c in r){var l=r[c];if(a=i!=null?i[c]:void 0,r.hasOwnProperty(c)&&l!==a&&(l!=null||a!=null))if(c==="style")if(a){for(o in a)!a.hasOwnProperty(o)||l&&l.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in l)l.hasOwnProperty(o)&&a[o]!==l[o]&&(n||(n={}),n[o]=l[o])}else n||(s||(s=[]),s.push(c,n)),n=l;else c==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(s=s||[]).push(c,l)):c==="children"?typeof l!="string"&&typeof l!="number"||(s=s||[]).push(c,""+l):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(ac.hasOwnProperty(c)?(l!=null&&c==="onScroll"&&ut("scroll",e),s||a===l||(s=[])):(s=s||[]).push(c,l))}n&&(s=s||[]).push("style",n);var c=s;(t.updateQueue=c)&&(t.flags|=4)}};F2=function(e,t,n,r){n!==r&&(t.flags|=4)};function vl(e,t){if(!ft)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function gn(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function yj(e,t,n){var r=t.pendingProps;switch(n_(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return gn(t),null;case 1:return Un(t.type)&&rh(),gn(t),null;case 3:return r=t.stateNode,Ta(),ht(Hn),ht(bn),d_(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(ju(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Pr!==null&&(Ag(Pr),Pr=null))),Cg(e,t),gn(t),null;case 5:u_(t);var i=Gs(xc.current);if(n=t.type,e!==null&&t.stateNode!=null)$2(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(G(166));return gn(t),null}if(e=Gs(Jr.current),ju(t)){r=t.stateNode,n=t.type;var s=t.memoizedProps;switch(r[Kr]=t,r[vc]=s,e=(t.mode&1)!==0,n){case"dialog":ut("cancel",r),ut("close",r);break;case"iframe":case"object":case"embed":ut("load",r);break;case"video":case"audio":for(i=0;i<jl.length;i++)ut(jl[i],r);break;case"source":ut("error",r);break;case"img":case"image":case"link":ut("error",r),ut("load",r);break;case"details":ut("toggle",r);break;case"input":My(r,s),ut("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!s.multiple},ut("invalid",r);break;case"textarea":jy(r,s),ut("invalid",r)}Qm(n,s),i=null;for(var o in s)if(s.hasOwnProperty(o)){var a=s[o];o==="children"?typeof a=="string"?r.textContent!==a&&(s.suppressHydrationWarning!==!0&&Au(r.textContent,a,e),i=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(s.suppressHydrationWarning!==!0&&Au(r.textContent,a,e),i=["children",""+a]):ac.hasOwnProperty(o)&&a!=null&&o==="onScroll"&&ut("scroll",r)}switch(n){case"input":Cu(r),Ay(r,s,!0);break;case"textarea":Cu(r),Dy(r);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(r.onclick=nh)}r=i,t.updateQueue=r,r!==null&&(t.flags|=4)}else{o=i.nodeType===9?i:i.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=mC(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[Kr]=t,e[vc]=r,z2(e,t,!1,!1),t.stateNode=e;e:{switch(o=Jm(n,r),n){case"dialog":ut("cancel",e),ut("close",e),i=r;break;case"iframe":case"object":case"embed":ut("load",e),i=r;break;case"video":case"audio":for(i=0;i<jl.length;i++)ut(jl[i],e);i=r;break;case"source":ut("error",e),i=r;break;case"img":case"image":case"link":ut("error",e),ut("load",e),i=r;break;case"details":ut("toggle",e),i=r;break;case"input":My(e,r),i=Km(e,r),ut("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=bt({},r,{value:void 0}),ut("invalid",e);break;case"textarea":jy(e,r),i=Ym(e,r),ut("invalid",e);break;default:i=r}Qm(n,i),a=i;for(s in a)if(a.hasOwnProperty(s)){var l=a[s];s==="style"?_C(e,l):s==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&gC(e,l)):s==="children"?typeof l=="string"?(n!=="textarea"||l!=="")&&lc(e,l):typeof l=="number"&&lc(e,""+l):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(ac.hasOwnProperty(s)?l!=null&&s==="onScroll"&&ut("scroll",e):l!=null&&F0(e,s,l,o))}switch(n){case"input":Cu(e),Ay(e,r,!1);break;case"textarea":Cu(e),Dy(e);break;case"option":r.value!=null&&e.setAttribute("value",""+bs(r.value));break;case"select":e.multiple=!!r.multiple,s=r.value,s!=null?da(e,!!r.multiple,s,!1):r.defaultValue!=null&&da(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=nh)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return gn(t),null;case 6:if(e&&t.stateNode!=null)F2(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(G(166));if(n=Gs(xc.current),Gs(Jr.current),ju(t)){if(r=t.stateNode,n=t.memoizedProps,r[Kr]=t,(s=r.nodeValue!==n)&&(e=Jn,e!==null))switch(e.tag){case 3:Au(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Au(r.nodeValue,n,(e.mode&1)!==0)}s&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Kr]=t,t.stateNode=r}return gn(t),null;case 13:if(ht(_t),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ft&&Qn!==null&&t.mode&1&&!(t.flags&128))s2(),Ea(),t.flags|=98560,s=!1;else if(s=ju(t),r!==null&&r.dehydrated!==null){if(e===null){if(!s)throw Error(G(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(G(317));s[Kr]=t}else Ea(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;gn(t),s=!1}else Pr!==null&&(Ag(Pr),Pr=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||_t.current&1?Vt===0&&(Vt=3):S_())),t.updateQueue!==null&&(t.flags|=4),gn(t),null);case 4:return Ta(),Cg(e,t),e===null&&mc(t.stateNode.containerInfo),gn(t),null;case 10:return o_(t.type._context),gn(t),null;case 17:return Un(t.type)&&rh(),gn(t),null;case 19:if(ht(_t),s=t.memoizedState,s===null)return gn(t),null;if(r=(t.flags&128)!==0,o=s.rendering,o===null)if(r)vl(s,!1);else{if(Vt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=uh(e),o!==null){for(t.flags|=128,vl(s,!1),r=o.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)s=n,e=r,s.flags&=14680066,o=s.alternate,o===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=o.childLanes,s.lanes=o.lanes,s.child=o.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=o.memoizedProps,s.memoizedState=o.memoizedState,s.updateQueue=o.updateQueue,s.type=o.type,e=o.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return ct(_t,_t.current&1|2),t.child}e=e.sibling}s.tail!==null&&It()>Ia&&(t.flags|=128,r=!0,vl(s,!1),t.lanes=4194304)}else{if(!r)if(e=uh(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),vl(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!ft)return gn(t),null}else 2*It()-s.renderingStartTime>Ia&&n!==1073741824&&(t.flags|=128,r=!0,vl(s,!1),t.lanes=4194304);s.isBackwards?(o.sibling=t.child,t.child=o):(n=s.last,n!==null?n.sibling=o:t.child=o,s.last=o)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=It(),t.sibling=null,n=_t.current,ct(_t,r?n&1|2:n&1),t):(gn(t),null);case 22:case 23:return w_(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Yn&1073741824&&(gn(t),t.subtreeFlags&6&&(t.flags|=8192)):gn(t),null;case 24:return null;case 25:return null}throw Error(G(156,t.tag))}function bj(e,t){switch(n_(t),t.tag){case 1:return Un(t.type)&&rh(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ta(),ht(Hn),ht(bn),d_(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return u_(t),null;case 13:if(ht(_t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(G(340));Ea()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ht(_t),null;case 4:return Ta(),null;case 10:return o_(t.type._context),null;case 22:case 23:return w_(),null;case 24:return null;default:return null}}var Ou=!1,xn=!1,wj=typeof WeakSet=="function"?WeakSet:Set,le=null;function sa(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){kt(e,t,r)}else n.current=null}function Eg(e,t,n){try{n()}catch(r){kt(e,t,r)}}var k1=!1;function Sj(e,t){if(cg=Jd,e=qC(),e_(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,c=0,u=0,d=e,f=null;t:for(;;){for(var p;d!==n||i!==0&&d.nodeType!==3||(a=o+i),d!==s||r!==0&&d.nodeType!==3||(l=o+r),d.nodeType===3&&(o+=d.nodeValue.length),(p=d.firstChild)!==null;)f=d,d=p;for(;;){if(d===e)break t;if(f===n&&++c===i&&(a=o),f===s&&++u===r&&(l=o),(p=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=p}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(ug={focusedElem:e,selectionRange:n},Jd=!1,le=t;le!==null;)if(t=le,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,le=e;else for(;le!==null;){t=le;try{var m=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(m!==null){var v=m.memoizedProps,y=m.memoizedState,_=t.stateNode,x=_.getSnapshotBeforeUpdate(t.elementType===t.type?v:Er(t.type,v),y);_.__reactInternalSnapshotBeforeUpdate=x}break;case 3:var b=t.stateNode.containerInfo;b.nodeType===1?b.textContent="":b.nodeType===9&&b.documentElement&&b.removeChild(b.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(G(163))}}catch(w){kt(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,le=e;break}le=t.return}return m=k1,k1=!1,m}function Yl(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var s=i.destroy;i.destroy=void 0,s!==void 0&&Eg(t,n,s)}i=i.next}while(i!==r)}}function cf(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Ng(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function H2(e){var t=e.alternate;t!==null&&(e.alternate=null,H2(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Kr],delete t[vc],delete t[fg],delete t[sj],delete t[oj])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function U2(e){return e.tag===5||e.tag===3||e.tag===4}function C1(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||U2(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Tg(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=nh));else if(r!==4&&(e=e.child,e!==null))for(Tg(e,t,n),e=e.sibling;e!==null;)Tg(e,t,n),e=e.sibling}function Pg(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Pg(e,t,n),e=e.sibling;e!==null;)Pg(e,t,n),e=e.sibling}var cn=null,Nr=!1;function Vi(e,t,n){for(n=n.child;n!==null;)W2(e,t,n),n=n.sibling}function W2(e,t,n){if(Qr&&typeof Qr.onCommitFiberUnmount=="function")try{Qr.onCommitFiberUnmount(ef,n)}catch{}switch(n.tag){case 5:xn||sa(n,t);case 6:var r=cn,i=Nr;cn=null,Vi(e,t,n),cn=r,Nr=i,cn!==null&&(Nr?(e=cn,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):cn.removeChild(n.stateNode));break;case 18:cn!==null&&(Nr?(e=cn,n=n.stateNode,e.nodeType===8?Ep(e.parentNode,n):e.nodeType===1&&Ep(e,n),hc(e)):Ep(cn,n.stateNode));break;case 4:r=cn,i=Nr,cn=n.stateNode.containerInfo,Nr=!0,Vi(e,t,n),cn=r,Nr=i;break;case 0:case 11:case 14:case 15:if(!xn&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&Eg(n,t,o),i=i.next}while(i!==r)}Vi(e,t,n);break;case 1:if(!xn&&(sa(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){kt(n,t,a)}Vi(e,t,n);break;case 21:Vi(e,t,n);break;case 22:n.mode&1?(xn=(r=xn)||n.memoizedState!==null,Vi(e,t,n),xn=r):Vi(e,t,n);break;default:Vi(e,t,n)}}function E1(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new wj),t.forEach(function(r){var i=Mj.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function kr(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];try{var s=e,o=t,a=o;e:for(;a!==null;){switch(a.tag){case 5:cn=a.stateNode,Nr=!1;break e;case 3:cn=a.stateNode.containerInfo,Nr=!0;break e;case 4:cn=a.stateNode.containerInfo,Nr=!0;break e}a=a.return}if(cn===null)throw Error(G(160));W2(s,o,i),cn=null,Nr=!1;var l=i.alternate;l!==null&&(l.return=null),i.return=null}catch(c){kt(i,t,c)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)V2(t,e),t=t.sibling}function V2(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(kr(t,e),Br(e),r&4){try{Yl(3,e,e.return),cf(3,e)}catch(v){kt(e,e.return,v)}try{Yl(5,e,e.return)}catch(v){kt(e,e.return,v)}}break;case 1:kr(t,e),Br(e),r&512&&n!==null&&sa(n,n.return);break;case 5:if(kr(t,e),Br(e),r&512&&n!==null&&sa(n,n.return),e.flags&32){var i=e.stateNode;try{lc(i,"")}catch(v){kt(e,e.return,v)}}if(r&4&&(i=e.stateNode,i!=null)){var s=e.memoizedProps,o=n!==null?n.memoizedProps:s,a=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{a==="input"&&s.type==="radio"&&s.name!=null&&fC(i,s),Jm(a,o);var c=Jm(a,s);for(o=0;o<l.length;o+=2){var u=l[o],d=l[o+1];u==="style"?_C(i,d):u==="dangerouslySetInnerHTML"?gC(i,d):u==="children"?lc(i,d):F0(i,u,d,c)}switch(a){case"input":Gm(i,s);break;case"textarea":pC(i,s);break;case"select":var f=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!s.multiple;var p=s.value;p!=null?da(i,!!s.multiple,p,!1):f!==!!s.multiple&&(s.defaultValue!=null?da(i,!!s.multiple,s.defaultValue,!0):da(i,!!s.multiple,s.multiple?[]:"",!1))}i[vc]=s}catch(v){kt(e,e.return,v)}}break;case 6:if(kr(t,e),Br(e),r&4){if(e.stateNode===null)throw Error(G(162));i=e.stateNode,s=e.memoizedProps;try{i.nodeValue=s}catch(v){kt(e,e.return,v)}}break;case 3:if(kr(t,e),Br(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{hc(t.containerInfo)}catch(v){kt(e,e.return,v)}break;case 4:kr(t,e),Br(e);break;case 13:kr(t,e),Br(e),i=e.child,i.flags&8192&&(s=i.memoizedState!==null,i.stateNode.isHidden=s,!s||i.alternate!==null&&i.alternate.memoizedState!==null||(y_=It())),r&4&&E1(e);break;case 22:if(u=n!==null&&n.memoizedState!==null,e.mode&1?(xn=(c=xn)||u,kr(t,e),xn=c):kr(t,e),Br(e),r&8192){if(c=e.memoizedState!==null,(e.stateNode.isHidden=c)&&!u&&e.mode&1)for(le=e,u=e.child;u!==null;){for(d=le=u;le!==null;){switch(f=le,p=f.child,f.tag){case 0:case 11:case 14:case 15:Yl(4,f,f.return);break;case 1:sa(f,f.return);var m=f.stateNode;if(typeof m.componentWillUnmount=="function"){r=f,n=f.return;try{t=r,m.props=t.memoizedProps,m.state=t.memoizedState,m.componentWillUnmount()}catch(v){kt(r,n,v)}}break;case 5:sa(f,f.return);break;case 22:if(f.memoizedState!==null){T1(d);continue}}p!==null?(p.return=f,le=p):T1(d)}u=u.sibling}e:for(u=null,d=e;;){if(d.tag===5){if(u===null){u=d;try{i=d.stateNode,c?(s=i.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none"):(a=d.stateNode,l=d.memoizedProps.style,o=l!=null&&l.hasOwnProperty("display")?l.display:null,a.style.display=vC("display",o))}catch(v){kt(e,e.return,v)}}}else if(d.tag===6){if(u===null)try{d.stateNode.nodeValue=c?"":d.memoizedProps}catch(v){kt(e,e.return,v)}}else if((d.tag!==22&&d.tag!==23||d.memoizedState===null||d===e)&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===e)break e;for(;d.sibling===null;){if(d.return===null||d.return===e)break e;u===d&&(u=null),d=d.return}u===d&&(u=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:kr(t,e),Br(e),r&4&&E1(e);break;case 21:break;default:kr(t,e),Br(e)}}function Br(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(U2(n)){var r=n;break e}n=n.return}throw Error(G(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(lc(i,""),r.flags&=-33);var s=C1(e);Pg(e,s,i);break;case 3:case 4:var o=r.stateNode.containerInfo,a=C1(e);Tg(e,a,o);break;default:throw Error(G(161))}}catch(l){kt(e,e.return,l)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function kj(e,t,n){le=e,q2(e)}function q2(e,t,n){for(var r=(e.mode&1)!==0;le!==null;){var i=le,s=i.child;if(i.tag===22&&r){var o=i.memoizedState!==null||Ou;if(!o){var a=i.alternate,l=a!==null&&a.memoizedState!==null||xn;a=Ou;var c=xn;if(Ou=o,(xn=l)&&!c)for(le=i;le!==null;)o=le,l=o.child,o.tag===22&&o.memoizedState!==null?P1(i):l!==null?(l.return=o,le=l):P1(i);for(;s!==null;)le=s,q2(s),s=s.sibling;le=i,Ou=a,xn=c}N1(e)}else i.subtreeFlags&8772&&s!==null?(s.return=i,le=s):N1(e)}}function N1(e){for(;le!==null;){var t=le;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:xn||cf(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!xn)if(n===null)r.componentDidMount();else{var i=t.elementType===t.type?n.memoizedProps:Er(t.type,n.memoizedProps);r.componentDidUpdate(i,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var s=t.updateQueue;s!==null&&d1(t,s,r);break;case 3:var o=t.updateQueue;if(o!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}d1(t,o,n)}break;case 5:var a=t.stateNode;if(n===null&&t.flags&4){n=a;var l=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&n.focus();break;case"img":l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var c=t.alternate;if(c!==null){var u=c.memoizedState;if(u!==null){var d=u.dehydrated;d!==null&&hc(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(G(163))}xn||t.flags&512&&Ng(t)}catch(f){kt(t,t.return,f)}}if(t===e){le=null;break}if(n=t.sibling,n!==null){n.return=t.return,le=n;break}le=t.return}}function T1(e){for(;le!==null;){var t=le;if(t===e){le=null;break}var n=t.sibling;if(n!==null){n.return=t.return,le=n;break}le=t.return}}function P1(e){for(;le!==null;){var t=le;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{cf(4,t)}catch(l){kt(t,n,l)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var i=t.return;try{r.componentDidMount()}catch(l){kt(t,i,l)}}var s=t.return;try{Ng(t)}catch(l){kt(t,s,l)}break;case 5:var o=t.return;try{Ng(t)}catch(l){kt(t,o,l)}}}catch(l){kt(t,t.return,l)}if(t===e){le=null;break}var a=t.sibling;if(a!==null){a.return=t.return,le=a;break}le=t.return}}var Cj=Math.ceil,fh=Li.ReactCurrentDispatcher,__=Li.ReactCurrentOwner,gr=Li.ReactCurrentBatchConfig,Ge=0,on=null,Ot=null,hn=0,Yn=0,oa=Ts(0),Vt=0,Sc=null,oo=0,uf=0,x_=0,Zl=null,$n=null,y_=0,Ia=1/0,_i=null,ph=!1,Ig=null,gs=null,Bu=!1,ls=null,mh=0,Ql=0,Rg=null,Nd=-1,Td=0;function Nn(){return Ge&6?It():Nd!==-1?Nd:Nd=It()}function vs(e){return e.mode&1?Ge&2&&hn!==0?hn&-hn:lj.transition!==null?(Td===0&&(Td=IC()),Td):(e=et,e!==0||(e=window.event,e=e===void 0?16:OC(e.type)),e):1}function Rr(e,t,n,r){if(50<Ql)throw Ql=0,Rg=null,Error(G(185));Zc(e,n,r),(!(Ge&2)||e!==on)&&(e===on&&(!(Ge&2)&&(uf|=n),Vt===4&&ss(e,hn)),Wn(e,r),n===1&&Ge===0&&!(t.mode&1)&&(Ia=It()+500,of&&Ps()))}function Wn(e,t){var n=e.callbackNode;l5(e,t);var r=Qd(e,e===on?hn:0);if(r===0)n!==null&&By(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&By(n),t===1)e.tag===0?aj(I1.bind(null,e)):n2(I1.bind(null,e)),rj(function(){!(Ge&6)&&Ps()}),n=null;else{switch(RC(r)){case 1:n=q0;break;case 4:n=TC;break;case 16:n=Zd;break;case 536870912:n=PC;break;default:n=Zd}n=eE(n,K2.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function K2(e,t){if(Nd=-1,Td=0,Ge&6)throw Error(G(327));var n=e.callbackNode;if(ga()&&e.callbackNode!==n)return null;var r=Qd(e,e===on?hn:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=gh(e,r);else{t=r;var i=Ge;Ge|=2;var s=X2();(on!==e||hn!==t)&&(_i=null,Ia=It()+500,Qs(e,t));do try{Tj();break}catch(a){G2(e,a)}while(!0);s_(),fh.current=s,Ge=i,Ot!==null?t=0:(on=null,hn=0,t=Vt)}if(t!==0){if(t===2&&(i=ig(e),i!==0&&(r=i,t=Mg(e,i))),t===1)throw n=Sc,Qs(e,0),ss(e,r),Wn(e,It()),n;if(t===6)ss(e,r);else{if(i=e.current.alternate,!(r&30)&&!Ej(i)&&(t=gh(e,r),t===2&&(s=ig(e),s!==0&&(r=s,t=Mg(e,s))),t===1))throw n=Sc,Qs(e,0),ss(e,r),Wn(e,It()),n;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(G(345));case 2:Fs(e,$n,_i);break;case 3:if(ss(e,r),(r&130023424)===r&&(t=y_+500-It(),10<t)){if(Qd(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){Nn(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=hg(Fs.bind(null,e,$n,_i),t);break}Fs(e,$n,_i);break;case 4:if(ss(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var o=31-Ir(r);s=1<<o,o=t[o],o>i&&(i=o),r&=~s}if(r=i,r=It()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Cj(r/1960))-r,10<r){e.timeoutHandle=hg(Fs.bind(null,e,$n,_i),r);break}Fs(e,$n,_i);break;case 5:Fs(e,$n,_i);break;default:throw Error(G(329))}}}return Wn(e,It()),e.callbackNode===n?K2.bind(null,e):null}function Mg(e,t){var n=Zl;return e.current.memoizedState.isDehydrated&&(Qs(e,t).flags|=256),e=gh(e,t),e!==2&&(t=$n,$n=n,t!==null&&Ag(t)),e}function Ag(e){$n===null?$n=e:$n.push.apply($n,e)}function Ej(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],s=i.getSnapshot;i=i.value;try{if(!jr(s(),i))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ss(e,t){for(t&=~x_,t&=~uf,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Ir(t),r=1<<n;e[n]=-1,t&=~r}}function I1(e){if(Ge&6)throw Error(G(327));ga();var t=Qd(e,0);if(!(t&1))return Wn(e,It()),null;var n=gh(e,t);if(e.tag!==0&&n===2){var r=ig(e);r!==0&&(t=r,n=Mg(e,r))}if(n===1)throw n=Sc,Qs(e,0),ss(e,t),Wn(e,It()),n;if(n===6)throw Error(G(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Fs(e,$n,_i),Wn(e,It()),null}function b_(e,t){var n=Ge;Ge|=1;try{return e(t)}finally{Ge=n,Ge===0&&(Ia=It()+500,of&&Ps())}}function ao(e){ls!==null&&ls.tag===0&&!(Ge&6)&&ga();var t=Ge;Ge|=1;var n=gr.transition,r=et;try{if(gr.transition=null,et=1,e)return e()}finally{et=r,gr.transition=n,Ge=t,!(Ge&6)&&Ps()}}function w_(){Yn=oa.current,ht(oa)}function Qs(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,nj(n)),Ot!==null)for(n=Ot.return;n!==null;){var r=n;switch(n_(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&rh();break;case 3:Ta(),ht(Hn),ht(bn),d_();break;case 5:u_(r);break;case 4:Ta();break;case 13:ht(_t);break;case 19:ht(_t);break;case 10:o_(r.type._context);break;case 22:case 23:w_()}n=n.return}if(on=e,Ot=e=_s(e.current,null),hn=Yn=t,Vt=0,Sc=null,x_=uf=oo=0,$n=Zl=null,Ks!==null){for(t=0;t<Ks.length;t++)if(n=Ks[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,s=n.pending;if(s!==null){var o=s.next;s.next=i,r.next=o}n.pending=r}Ks=null}return e}function G2(e,t){do{var n=Ot;try{if(s_(),kd.current=hh,dh){for(var r=yt.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}dh=!1}if(so=0,tn=Wt=yt=null,Xl=!1,yc=0,__.current=null,n===null||n.return===null){Vt=1,Sc=t,Ot=null;break}e:{var s=e,o=n.return,a=n,l=t;if(t=hn,a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var c=l,u=a,d=u.tag;if(!(u.mode&1)&&(d===0||d===11||d===15)){var f=u.alternate;f?(u.updateQueue=f.updateQueue,u.memoizedState=f.memoizedState,u.lanes=f.lanes):(u.updateQueue=null,u.memoizedState=null)}var p=v1(o);if(p!==null){p.flags&=-257,_1(p,o,a,s,t),p.mode&1&&g1(s,c,t),t=p,l=c;var m=t.updateQueue;if(m===null){var v=new Set;v.add(l),t.updateQueue=v}else m.add(l);break e}else{if(!(t&1)){g1(s,c,t),S_();break e}l=Error(G(426))}}else if(ft&&a.mode&1){var y=v1(o);if(y!==null){!(y.flags&65536)&&(y.flags|=256),_1(y,o,a,s,t),r_(Pa(l,a));break e}}s=l=Pa(l,a),Vt!==4&&(Vt=2),Zl===null?Zl=[s]:Zl.push(s),s=o;do{switch(s.tag){case 3:s.flags|=65536,t&=-t,s.lanes|=t;var _=R2(s,l,t);u1(s,_);break e;case 1:a=l;var x=s.type,b=s.stateNode;if(!(s.flags&128)&&(typeof x.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(gs===null||!gs.has(b)))){s.flags|=65536,t&=-t,s.lanes|=t;var w=M2(s,a,t);u1(s,w);break e}}s=s.return}while(s!==null)}Z2(n)}catch(S){t=S,Ot===n&&n!==null&&(Ot=n=n.return);continue}break}while(!0)}function X2(){var e=fh.current;return fh.current=hh,e===null?hh:e}function S_(){(Vt===0||Vt===3||Vt===2)&&(Vt=4),on===null||!(oo&268435455)&&!(uf&268435455)||ss(on,hn)}function gh(e,t){var n=Ge;Ge|=2;var r=X2();(on!==e||hn!==t)&&(_i=null,Qs(e,t));do try{Nj();break}catch(i){G2(e,i)}while(!0);if(s_(),Ge=n,fh.current=r,Ot!==null)throw Error(G(261));return on=null,hn=0,Vt}function Nj(){for(;Ot!==null;)Y2(Ot)}function Tj(){for(;Ot!==null&&!JA();)Y2(Ot)}function Y2(e){var t=J2(e.alternate,e,Yn);e.memoizedProps=e.pendingProps,t===null?Z2(e):Ot=t,__.current=null}function Z2(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=bj(n,t),n!==null){n.flags&=32767,Ot=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Vt=6,Ot=null;return}}else if(n=yj(n,t,Yn),n!==null){Ot=n;return}if(t=t.sibling,t!==null){Ot=t;return}Ot=t=e}while(t!==null);Vt===0&&(Vt=5)}function Fs(e,t,n){var r=et,i=gr.transition;try{gr.transition=null,et=1,Pj(e,t,n,r)}finally{gr.transition=i,et=r}return null}function Pj(e,t,n,r){do ga();while(ls!==null);if(Ge&6)throw Error(G(327));n=e.finishedWork;var i=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(G(177));e.callbackNode=null,e.callbackPriority=0;var s=n.lanes|n.childLanes;if(c5(e,s),e===on&&(Ot=on=null,hn=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Bu||(Bu=!0,eE(Zd,function(){return ga(),null})),s=(n.flags&15990)!==0,n.subtreeFlags&15990||s){s=gr.transition,gr.transition=null;var o=et;et=1;var a=Ge;Ge|=4,__.current=null,Sj(e,n),V2(n,e),X5(ug),Jd=!!cg,ug=cg=null,e.current=n,kj(n),e5(),Ge=a,et=o,gr.transition=s}else e.current=n;if(Bu&&(Bu=!1,ls=e,mh=i),s=e.pendingLanes,s===0&&(gs=null),r5(n.stateNode),Wn(e,It()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)i=t[n],r(i.value,{componentStack:i.stack,digest:i.digest});if(ph)throw ph=!1,e=Ig,Ig=null,e;return mh&1&&e.tag!==0&&ga(),s=e.pendingLanes,s&1?e===Rg?Ql++:(Ql=0,Rg=e):Ql=0,Ps(),null}function ga(){if(ls!==null){var e=RC(mh),t=gr.transition,n=et;try{if(gr.transition=null,et=16>e?16:e,ls===null)var r=!1;else{if(e=ls,ls=null,mh=0,Ge&6)throw Error(G(331));var i=Ge;for(Ge|=4,le=e.current;le!==null;){var s=le,o=s.child;if(le.flags&16){var a=s.deletions;if(a!==null){for(var l=0;l<a.length;l++){var c=a[l];for(le=c;le!==null;){var u=le;switch(u.tag){case 0:case 11:case 15:Yl(8,u,s)}var d=u.child;if(d!==null)d.return=u,le=d;else for(;le!==null;){u=le;var f=u.sibling,p=u.return;if(H2(u),u===c){le=null;break}if(f!==null){f.return=p,le=f;break}le=p}}}var m=s.alternate;if(m!==null){var v=m.child;if(v!==null){m.child=null;do{var y=v.sibling;v.sibling=null,v=y}while(v!==null)}}le=s}}if(s.subtreeFlags&2064&&o!==null)o.return=s,le=o;else e:for(;le!==null;){if(s=le,s.flags&2048)switch(s.tag){case 0:case 11:case 15:Yl(9,s,s.return)}var _=s.sibling;if(_!==null){_.return=s.return,le=_;break e}le=s.return}}var x=e.current;for(le=x;le!==null;){o=le;var b=o.child;if(o.subtreeFlags&2064&&b!==null)b.return=o,le=b;else e:for(o=x;le!==null;){if(a=le,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:cf(9,a)}}catch(S){kt(a,a.return,S)}if(a===o){le=null;break e}var w=a.sibling;if(w!==null){w.return=a.return,le=w;break e}le=a.return}}if(Ge=i,Ps(),Qr&&typeof Qr.onPostCommitFiberRoot=="function")try{Qr.onPostCommitFiberRoot(ef,e)}catch{}r=!0}return r}finally{et=n,gr.transition=t}}return!1}function R1(e,t,n){t=Pa(n,t),t=R2(e,t,1),e=ms(e,t,1),t=Nn(),e!==null&&(Zc(e,1,t),Wn(e,t))}function kt(e,t,n){if(e.tag===3)R1(e,e,n);else for(;t!==null;){if(t.tag===3){R1(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(gs===null||!gs.has(r))){e=Pa(n,e),e=M2(t,e,1),t=ms(t,e,1),e=Nn(),t!==null&&(Zc(t,1,e),Wn(t,e));break}}t=t.return}}function Ij(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Nn(),e.pingedLanes|=e.suspendedLanes&n,on===e&&(hn&n)===n&&(Vt===4||Vt===3&&(hn&130023424)===hn&&500>It()-y_?Qs(e,0):x_|=n),Wn(e,t)}function Q2(e,t){t===0&&(e.mode&1?(t=Tu,Tu<<=1,!(Tu&130023424)&&(Tu=4194304)):t=1);var n=Nn();e=Pi(e,t),e!==null&&(Zc(e,t,n),Wn(e,n))}function Rj(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Q2(e,n)}function Mj(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(G(314))}r!==null&&r.delete(t),Q2(e,n)}var J2;J2=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Hn.current)Fn=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Fn=!1,xj(e,t,n);Fn=!!(e.flags&131072)}else Fn=!1,ft&&t.flags&1048576&&r2(t,oh,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ed(e,t),e=t.pendingProps;var i=Ca(t,bn.current);ma(t,n),i=f_(null,t,r,e,i,n);var s=p_();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Un(r)?(s=!0,ih(t)):s=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,l_(t),i.updater=lf,t.stateNode=i,i._reactInternals=t,xg(t,r,e,n),t=wg(null,t,r,!0,s,n)):(t.tag=0,ft&&s&&t_(t),kn(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ed(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=jj(r),e=Er(r,e),i){case 0:t=bg(null,t,r,e,n);break e;case 1:t=b1(null,t,r,e,n);break e;case 11:t=x1(null,t,r,e,n);break e;case 14:t=y1(null,t,r,Er(r.type,e),n);break e}throw Error(G(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Er(r,i),bg(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Er(r,i),b1(e,t,r,i,n);case 3:e:{if(L2(t),e===null)throw Error(G(387));r=t.pendingProps,s=t.memoizedState,i=s.element,c2(e,t),ch(t,r,null,n);var o=t.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){i=Pa(Error(G(423)),t),t=w1(e,t,r,n,i);break e}else if(r!==i){i=Pa(Error(G(424)),t),t=w1(e,t,r,n,i);break e}else for(Qn=ps(t.stateNode.containerInfo.firstChild),Jn=t,ft=!0,Pr=null,n=a2(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ea(),r===i){t=Ii(e,t,n);break e}kn(e,t,r,n)}t=t.child}return t;case 5:return u2(t),e===null&&gg(t),r=t.type,i=t.pendingProps,s=e!==null?e.memoizedProps:null,o=i.children,dg(r,i)?o=null:s!==null&&dg(r,s)&&(t.flags|=32),D2(e,t),kn(e,t,o,n),t.child;case 6:return e===null&&gg(t),null;case 13:return O2(e,t,n);case 4:return c_(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Na(t,null,r,n):kn(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Er(r,i),x1(e,t,r,i,n);case 7:return kn(e,t,t.pendingProps,n),t.child;case 8:return kn(e,t,t.pendingProps.children,n),t.child;case 12:return kn(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,s=t.memoizedProps,o=i.value,ct(ah,r._currentValue),r._currentValue=o,s!==null)if(jr(s.value,o)){if(s.children===i.children&&!Hn.current){t=Ii(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var l=a.firstContext;l!==null;){if(l.context===r){if(s.tag===1){l=ki(-1,n&-n),l.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),vg(s.return,n,t),a.lanes|=n;break}l=l.next}}else if(s.tag===10)o=s.type===t.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(G(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),vg(o,n,t),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===t){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}kn(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,ma(t,n),i=xr(i),r=r(i),t.flags|=1,kn(e,t,r,n),t.child;case 14:return r=t.type,i=Er(r,t.pendingProps),i=Er(r.type,i),y1(e,t,r,i,n);case 15:return A2(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Er(r,i),Ed(e,t),t.tag=1,Un(r)?(e=!0,ih(t)):e=!1,ma(t,n),I2(t,r,i),xg(t,r,i,n),wg(null,t,r,!0,e,n);case 19:return B2(e,t,n);case 22:return j2(e,t,n)}throw Error(G(156,t.tag))};function eE(e,t){return NC(e,t)}function Aj(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function mr(e,t,n,r){return new Aj(e,t,n,r)}function k_(e){return e=e.prototype,!(!e||!e.isReactComponent)}function jj(e){if(typeof e=="function")return k_(e)?1:0;if(e!=null){if(e=e.$$typeof,e===U0)return 11;if(e===W0)return 14}return 2}function _s(e,t){var n=e.alternate;return n===null?(n=mr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Pd(e,t,n,r,i,s){var o=2;if(r=e,typeof e=="function")k_(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Yo:return Js(n.children,i,s,t);case H0:o=8,i|=8;break;case Um:return e=mr(12,n,t,i|2),e.elementType=Um,e.lanes=s,e;case Wm:return e=mr(13,n,t,i),e.elementType=Wm,e.lanes=s,e;case Vm:return e=mr(19,n,t,i),e.elementType=Vm,e.lanes=s,e;case uC:return df(n,i,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case lC:o=10;break e;case cC:o=9;break e;case U0:o=11;break e;case W0:o=14;break e;case es:o=16,r=null;break e}throw Error(G(130,e==null?e:typeof e,""))}return t=mr(o,n,t,i),t.elementType=e,t.type=r,t.lanes=s,t}function Js(e,t,n,r){return e=mr(7,e,r,t),e.lanes=n,e}function df(e,t,n,r){return e=mr(22,e,r,t),e.elementType=uC,e.lanes=n,e.stateNode={isHidden:!1},e}function jp(e,t,n){return e=mr(6,e,null,t),e.lanes=n,e}function Dp(e,t,n){return t=mr(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Dj(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=mp(0),this.expirationTimes=mp(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=mp(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function C_(e,t,n,r,i,s,o,a,l){return e=new Dj(e,t,n,a,l),t===1?(t=1,s===!0&&(t|=8)):t=0,s=mr(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},l_(s),e}function Lj(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Xo,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function tE(e){if(!e)return ws;e=e._reactInternals;e:{if(wo(e)!==e||e.tag!==1)throw Error(G(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Un(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(G(171))}if(e.tag===1){var n=e.type;if(Un(n))return t2(e,n,t)}return t}function nE(e,t,n,r,i,s,o,a,l){return e=C_(n,r,!0,e,i,s,o,a,l),e.context=tE(null),n=e.current,r=Nn(),i=vs(n),s=ki(r,i),s.callback=t??null,ms(n,s,i),e.current.lanes=i,Zc(e,i,r),Wn(e,r),e}function hf(e,t,n,r){var i=t.current,s=Nn(),o=vs(i);return n=tE(n),t.context===null?t.context=n:t.pendingContext=n,t=ki(s,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=ms(i,t,o),e!==null&&(Rr(e,i,o,s),Sd(e,i,o)),o}function vh(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function M1(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function E_(e,t){M1(e,t),(e=e.alternate)&&M1(e,t)}function Oj(){return null}var rE=typeof reportError=="function"?reportError:function(e){console.error(e)};function N_(e){this._internalRoot=e}ff.prototype.render=N_.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(G(409));hf(e,t,null,null)};ff.prototype.unmount=N_.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ao(function(){hf(null,e,null,null)}),t[Ti]=null}};function ff(e){this._internalRoot=e}ff.prototype.unstable_scheduleHydration=function(e){if(e){var t=jC();e={blockedOn:null,target:e,priority:t};for(var n=0;n<is.length&&t!==0&&t<is[n].priority;n++);is.splice(n,0,e),n===0&&LC(e)}};function T_(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function pf(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function A1(){}function Bj(e,t,n,r,i){if(i){if(typeof r=="function"){var s=r;r=function(){var c=vh(o);s.call(c)}}var o=nE(t,r,e,0,null,!1,!1,"",A1);return e._reactRootContainer=o,e[Ti]=o.current,mc(e.nodeType===8?e.parentNode:e),ao(),o}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var a=r;r=function(){var c=vh(l);a.call(c)}}var l=C_(e,0,!1,null,null,!1,!1,"",A1);return e._reactRootContainer=l,e[Ti]=l.current,mc(e.nodeType===8?e.parentNode:e),ao(function(){hf(t,l,n,r)}),l}function mf(e,t,n,r,i){var s=n._reactRootContainer;if(s){var o=s;if(typeof i=="function"){var a=i;i=function(){var l=vh(o);a.call(l)}}hf(t,o,e,i)}else o=Bj(n,t,e,i,r);return vh(o)}MC=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Al(t.pendingLanes);n!==0&&(K0(t,n|1),Wn(t,It()),!(Ge&6)&&(Ia=It()+500,Ps()))}break;case 13:ao(function(){var r=Pi(e,1);if(r!==null){var i=Nn();Rr(r,e,1,i)}}),E_(e,1)}};G0=function(e){if(e.tag===13){var t=Pi(e,134217728);if(t!==null){var n=Nn();Rr(t,e,134217728,n)}E_(e,134217728)}};AC=function(e){if(e.tag===13){var t=vs(e),n=Pi(e,t);if(n!==null){var r=Nn();Rr(n,e,t,r)}E_(e,t)}};jC=function(){return et};DC=function(e,t){var n=et;try{return et=e,t()}finally{et=n}};tg=function(e,t,n){switch(t){case"input":if(Gm(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=sf(r);if(!i)throw Error(G(90));hC(r),Gm(r,i)}}}break;case"textarea":pC(e,n);break;case"select":t=n.value,t!=null&&da(e,!!n.multiple,t,!1)}};bC=b_;wC=ao;var zj={usingClientEntryPoint:!1,Events:[Jc,ea,sf,xC,yC,b_]},_l={findFiberByHostInstance:qs,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},$j={bundleType:_l.bundleType,version:_l.version,rendererPackageName:_l.rendererPackageName,rendererConfig:_l.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Li.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=CC(e),e===null?null:e.stateNode},findFiberByHostInstance:_l.findFiberByHostInstance||Oj,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var zu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zu.isDisabled&&zu.supportsFiber)try{ef=zu.inject($j),Qr=zu}catch{}}ir.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=zj;ir.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!T_(t))throw Error(G(200));return Lj(e,t,null,n)};ir.createRoot=function(e,t){if(!T_(e))throw Error(G(299));var n=!1,r="",i=rE;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=C_(e,1,!1,null,null,n,!1,r,i),e[Ti]=t.current,mc(e.nodeType===8?e.parentNode:e),new N_(t)};ir.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(G(188)):(e=Object.keys(e).join(","),Error(G(268,e)));return e=CC(t),e=e===null?null:e.stateNode,e};ir.flushSync=function(e){return ao(e)};ir.hydrate=function(e,t,n){if(!pf(t))throw Error(G(200));return mf(null,e,t,!0,n)};ir.hydrateRoot=function(e,t,n){if(!T_(e))throw Error(G(405));var r=n!=null&&n.hydratedSources||null,i=!1,s="",o=rE;if(n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),t=nE(t,null,e,1,n??null,i,!1,s,o),e[Ti]=t.current,mc(e),r)for(e=0;e<r.length;e++)n=r[e],i=n._getVersion,i=i(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,i]:t.mutableSourceEagerHydrationData.push(n,i);return new ff(t)};ir.render=function(e,t,n){if(!pf(t))throw Error(G(200));return mf(null,e,t,!1,n)};ir.unmountComponentAtNode=function(e){if(!pf(e))throw Error(G(40));return e._reactRootContainer?(ao(function(){mf(null,null,e,!1,function(){e._reactRootContainer=null,e[Ti]=null})}),!0):!1};ir.unstable_batchedUpdates=b_;ir.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!pf(n))throw Error(G(200));if(e==null||e._reactInternals===void 0)throw Error(G(38));return mf(e,t,n,!1,r)};ir.version="18.3.1-next-f1338f8080-20240426";function iE(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(iE)}catch(e){console.error(e)}}iE(),iC.exports=ir;var tu=iC.exports;const jg=Xc(tu);var j1=tu;Fm.createRoot=j1.createRoot,Fm.hydrateRoot=j1.hydrateRoot;const sE="(prefers-color-scheme: dark)",Fj=["light","dark","system"],oE="clawd-standalone:theme-source",Hj="light",Uj={colorPrimary:"#1677ff",colorBgContainer:"#fff",colorText:"#000",colorBorder:"#d9d9d9"};function Wj(){try{const e=localStorage.getItem(oE);if(e!==null&&Fj.includes(e))return e}catch{}return Hj}function Vj(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(sE).matches}function D1(e){return{mode:e==="dark"||e==="system"&&Vj()?"dark":"light",...Uj}}function qj(e){let t=Wj();const n=new Set,r=()=>{const s=D1(t);for(const o of n)o(s)};typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(sE).addEventListener("change",()=>{t==="system"&&r()});const i={gateway:{call:()=>Promise.reject(new Error("standalone-host: gateway.call not supported"))},self:{call:()=>Promise.reject(new Error("standalone-host: self.call removed; use useDaemonClient()"))},kv:{get:async s=>{const o=localStorage.getItem(`clawd-standalone:kv:${s}`);if(o==null)return null;try{return JSON.parse(o)}catch{return null}},set:async(s,o)=>{localStorage.setItem(`clawd-standalone:kv:${s}`,JSON.stringify(o))}},logger:{info:(s,o)=>{var a;console.info("[ext]",s,o??""),(a=e.logClient)==null||a.push({level:"info",msg:String(s),meta:o})},warn:(s,o)=>{var a;console.warn("[ext]",s,o??""),(a=e.logClient)==null||a.push({level:"warn",msg:String(s),meta:o})},error:(s,o)=>{var a;console.error("[ext]",s,o??""),(a=e.logClient)==null||a.push({level:"error",msg:String(s),meta:o})}},get theme(){return D1(t)},on(){return()=>{}},onThemeChange(s){return n.add(s),()=>{n.delete(s)}}};return i.getThemeSource=()=>t,i.setThemeSource=s=>{t=s;try{localStorage.setItem(oE,s)}catch{}r()},e.notifier&&(i.notifier=e.notifier),i}const aE=g.createContext(null);function L1({host:e,children:t}){return h.jsx(aE.Provider,{value:e,children:t})}function P_(){const e=g.useContext(aE);if(!e)throw new Error("HostProvider missing");return e}var lE={exports:{}};/*!
41
41
  Copyright (c) 2018 Jed Watson.
42
42
  Licensed under the MIT License (MIT), see
43
43
  http://jedwatson.github.io/classnames
@@ -92,7 +92,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
92
92
  0 -6px 16px 0 rgba(0, 0, 0, 0.08),
93
93
  0 -3px 6px -4px rgba(0, 0, 0, 0.12),
94
94
  0 -9px 28px 8px rgba(0, 0, 0, 0.05)
95
- `,boxShadowTabsOverflowLeft:"inset 10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowRight:"inset -10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowTop:"inset 0 10px 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowBottom:"inset 0 -10px 8px -8px rgba(0, 0, 0, 0.08)"}),r)}var ob=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const a4={lineHeight:!0,lineHeightSM:!0,lineHeightLG:!0,lineHeightHeading1:!0,lineHeightHeading2:!0,lineHeightHeading3:!0,lineHeightHeading4:!0,lineHeightHeading5:!0,opacityLoading:!0,fontWeightStrong:!0,zIndexPopupBase:!0,zIndexBase:!0,opacityImage:!0},l4={motionBase:!0,motionUnit:!0},c4={screenXS:!0,screenXSMin:!0,screenXSMax:!0,screenSM:!0,screenSMMin:!0,screenSMMax:!0,screenMD:!0,screenMDMin:!0,screenMDMax:!0,screenLG:!0,screenLGMin:!0,screenLGMax:!0,screenXL:!0,screenXLMin:!0,screenXLMax:!0,screenXXL:!0,screenXXLMin:!0},GE=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:i}=t,s=ob(t,["override"]);let o=Object.assign(Object.assign({},r),{override:i});return o=KE(o),s&&Object.entries(s).forEach(([a,l])=>{const{theme:c}=l,u=ob(l,["theme"]);let d=u;c&&(d=GE(Object.assign(Object.assign({},o),u),{override:u},c)),o[a]=d}),o};function XE(){const{token:e,hashed:t,theme:n,override:r,cssVar:i}=st.useContext(VE),s=`${s4}-${t||""}`,o=n||WE,[a,l,c]=X3(o,[Nc,e],{salt:s,override:r,getComputedToken:GE,formatToken:KE,cssVar:i&&{prefix:i.prefix,key:i.key,unitless:a4,ignore:l4,preserve:c4}});return[o,c,t?l:"",a,i]}const u4=()=>({display:"inline-flex",alignItems:"center",color:"inherit",fontStyle:"normal",lineHeight:0,textAlign:"center",textTransform:"none",verticalAlign:"-0.125em",textRendering:"optimizeLegibility","-webkit-font-smoothing":"antialiased","-moz-osx-font-smoothing":"grayscale","> *":{lineHeight:1},svg:{display:"inline-block"}}),d4=e=>({[`.${e}`]:Object.assign(Object.assign({},u4()),{[`.${e} .${e}-icon`]:{display:"block"}})}),h4=(e,t)=>{const[n,r]=XE();return SD({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>d4(e))},f4=Object.assign({},Ha),{useId:ab}=f4,p4=()=>"",m4=typeof ab>"u"?p4:ab;function g4(e,t,n){var r;const i=e||{},s=i.inherit===!1||!t?Object.assign(Object.assign({},bh),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:bh.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=m4();return fE(()=>{var a,l;if(!e)return t;const c=Object.assign({},s.components);Object.keys(e.components||{}).forEach(f=>{c[f]=Object.assign(Object.assign({},c[f]),e.components[f])});const u=`css-var-${o.replace(/:/g,"")}`,d=((a=i.cssVar)!==null&&a!==void 0?a:s.cssVar)&&Object.assign(Object.assign(Object.assign({prefix:n==null?void 0:n.prefixCls},typeof s.cssVar=="object"?s.cssVar:{}),typeof i.cssVar=="object"?i.cssVar:{}),{key:typeof i.cssVar=="object"&&((l=i.cssVar)===null||l===void 0?void 0:l.key)||u});return Object.assign(Object.assign(Object.assign({},s),i),{token:Object.assign(Object.assign({},s.token),i.token),components:c,cssVar:d})},[i,s],(a,l)=>a.some((c,u)=>{const d=l[u];return!S3(c,d,!0)}))}var v4=["children"],YE=g.createContext({});function _4(e){var t=e.children,n=Fg(e,v4);return g.createElement(YE.Provider,{value:n},t)}var x4=function(e){mE(n,e);var t=vE(n);function n(){return Va(this,n),t.apply(this,arguments)}return qa(n,[{key:"render",value:function(){return this.props.children}}]),n}(g.Component);function y4(e){var t=g.useReducer(function(a){return a+1},0),n=Ze(t,2),r=n[1],i=g.useRef(e),s=cv(function(){return i.current}),o=cv(function(a){i.current=typeof a=="function"?a(i.current):a,r()});return[s,o]}var Qi="none",Uu="appear",Wu="enter",Vu="leave",lb="none",Tr="prepare",aa="start",la="active",z_="end",ZE="prepared";function cb(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit".concat(e)]="webkit".concat(t),n["Moz".concat(e)]="moz".concat(t),n["ms".concat(e)]="MS".concat(t),n["O".concat(e)]="o".concat(t.toLowerCase()),n}function b4(e,t){var n={animationend:cb("Animation","AnimationEnd"),transitionend:cb("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var w4=b4(Oi(),typeof window<"u"?window:{}),QE={};if(Oi()){var S4=document.createElement("div");QE=S4.style}var qu={};function JE(e){if(qu[e])return qu[e];var t=w4[e];if(t)for(var n=Object.keys(t),r=n.length,i=0;i<r;i+=1){var s=n[i];if(Object.prototype.hasOwnProperty.call(t,s)&&s in QE)return qu[e]=t[s],qu[e]}return""}var eN=JE("animationend"),tN=JE("transitionend"),nN=!!(eN&&tN),ub=eN||"animationend",db=tN||"transitionend";function hb(e,t){if(!e)return null;if(Ct(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const k4=function(e){var t=g.useRef();function n(i){i&&(i.removeEventListener(db,e),i.removeEventListener(ub,e))}function r(i){t.current&&t.current!==i&&n(t.current),i&&i!==t.current&&(i.addEventListener(db,e),i.addEventListener(ub,e),t.current=i)}return g.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var rN=Oi()?g.useLayoutEffect:g.useEffect;const C4=function(){var e=g.useRef(null);function t(){zg.cancel(e.current)}function n(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var s=zg(function(){i<=1?r({isCanceled:function(){return s!==e.current}}):n(r,i-1)});e.current=s}return g.useEffect(function(){return function(){t()}},[]),[n,t]};var E4=[Tr,aa,la,z_],N4=[Tr,ZE],iN=!1,T4=!0;function sN(e){return e===la||e===z_}const P4=function(e,t,n){var r=uv(lb),i=Ze(r,2),s=i[0],o=i[1],a=C4(),l=Ze(a,2),c=l[0],u=l[1];function d(){o(Tr,!0)}var f=t?N4:E4;return rN(function(){if(s!==lb&&s!==z_){var p=f.indexOf(s),m=f[p+1],v=n(s);v===iN?o(m,!0):m&&c(function(y){function _(){y.isCanceled()||o(m,!0)}v===!0?_():Promise.resolve(v).then(_)})}},[e,s]),g.useEffect(function(){return function(){u()}},[]),[d,s]};function I4(e,t,n,r){var i=r.motionEnter,s=i===void 0?!0:i,o=r.motionAppear,a=o===void 0?!0:o,l=r.motionLeave,c=l===void 0?!0:l,u=r.motionDeadline,d=r.motionLeaveImmediately,f=r.onAppearPrepare,p=r.onEnterPrepare,m=r.onLeavePrepare,v=r.onAppearStart,y=r.onEnterStart,_=r.onLeaveStart,x=r.onAppearActive,b=r.onEnterActive,w=r.onLeaveActive,S=r.onAppearEnd,k=r.onEnterEnd,T=r.onLeaveEnd,N=r.onVisibleChanged,L=uv(),P=Ze(L,2),O=P[0],I=P[1],R=y4(Qi),j=Ze(R,2),z=j[0],$=j[1],F=uv(null),A=Ze(F,2),B=A[0],E=A[1],H=z(),q=g.useRef(!1),M=g.useRef(null);function re(){return n()}var oe=g.useRef(!1);function V(){$(Qi),E(null,!0)}var pe=cv(function(Ue){var nt=z();if(nt!==Qi){var mt=re();if(!(Ue&&!Ue.deadline&&Ue.target!==mt)){var Xt=oe.current,pn;nt===Uu&&Xt?pn=S==null?void 0:S(mt,Ue):nt===Wu&&Xt?pn=k==null?void 0:k(mt,Ue):nt===Vu&&Xt&&(pn=T==null?void 0:T(mt,Ue)),Xt&&pn!==!1&&V()}}}),Oe=k4(pe),ie=Ze(Oe,1),Me=ie[0],Fe=function(nt){switch(nt){case Uu:return we(we(we({},Tr,f),aa,v),la,x);case Wu:return we(we(we({},Tr,p),aa,y),la,b);case Vu:return we(we(we({},Tr,m),aa,_),la,w);default:return{}}},We=g.useMemo(function(){return Fe(H)},[H]),ge=P4(H,!e,function(Ue){if(Ue===Tr){var nt=We[Tr];return nt?nt(re()):iN}if(wt in We){var mt;E(((mt=We[wt])===null||mt===void 0?void 0:mt.call(We,re(),null))||null)}return wt===la&&H!==Qi&&(Me(re()),u>0&&(clearTimeout(M.current),M.current=setTimeout(function(){pe({deadline:!0})},u))),wt===ZE&&V(),T4}),qe=Ze(ge,2),Gt=qe[0],wt=qe[1],Rt=sN(wt);oe.current=Rt;var ln=g.useRef(null);rN(function(){if(!(q.current&&ln.current===t)){I(t);var Ue=q.current;q.current=!0;var nt;!Ue&&t&&a&&(nt=Uu),Ue&&t&&s&&(nt=Wu),(Ue&&!t&&c||!Ue&&d&&!t&&c)&&(nt=Vu);var mt=Fe(nt);nt&&(e||mt[Tr])?($(nt),Gt()):$(Qi),ln.current=t}},[t]),g.useEffect(function(){(H===Uu&&!a||H===Wu&&!s||H===Vu&&!c)&&$(Qi)},[a,s,c]),g.useEffect(function(){return function(){q.current=!1,clearTimeout(M.current)}},[]);var Bt=g.useRef(!1);g.useEffect(function(){O&&(Bt.current=!0),O!==void 0&&H===Qi&&((Bt.current||O)&&(N==null||N(O)),Bt.current=!0)},[O,H]);var at=B;return We[Tr]&&wt===aa&&(at=Be({transition:"none"},at)),[H,wt,at,O??t]}function R4(e){var t=e;Ct(e)==="object"&&(t=e.transitionSupport);function n(i,s){return!!(i.motionName&&t&&s!==!1)}var r=g.forwardRef(function(i,s){var o=i.visible,a=o===void 0?!0:o,l=i.removeOnLeave,c=l===void 0?!0:l,u=i.forceRender,d=i.children,f=i.motionName,p=i.leavedClassName,m=i.eventProps,v=g.useContext(YE),y=v.motion,_=n(i,y),x=g.useRef(),b=g.useRef();function w(){try{return x.current instanceof HTMLElement?x.current:o3(b.current)}catch{return null}}var S=I4(_,a,w,i),k=Ze(S,4),T=k[0],N=k[1],L=k[2],P=k[3],O=g.useRef(P);P&&(O.current=!0);var I=g.useCallback(function(A){x.current=A,u3(s,A)},[s]),R,j=Be(Be({},m),{},{visible:a});if(!d)R=null;else if(T===Qi)P?R=d(Be({},j),I):!c&&O.current&&p?R=d(Be(Be({},j),{},{className:p}),I):u||!c&&!p?R=d(Be(Be({},j),{},{style:{display:"none"}}),I):R=null;else{var z;N===Tr?z="prepare":sN(N)?z="active":N===aa&&(z="start");var $=hb(f,"".concat(T,"-").concat(z));R=d(Be(Be({},j),{},{className:Gj(hb(f,T),we(we({},$,$&&z),f,typeof f=="string")),style:L}),I)}if(g.isValidElement(R)&&d3(R)){var F=h3(R);F||(R=g.cloneElement(R,{ref:I}))}return g.createElement(x4,{ref:b},R)});return r.displayName="CSSMotion",r}const M4=R4(nN);var dv="add",hv="keep",fv="remove",Vp="removed";function A4(e){var t;return e&&Ct(e)==="object"&&"key"in e?t=e:t={key:e},Be(Be({},t),{},{key:String(t.key)})}function pv(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(A4)}function j4(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=[],r=0,i=t.length,s=pv(e),o=pv(t);s.forEach(function(c){for(var u=!1,d=r;d<i;d+=1){var f=o[d];if(f.key===c.key){r<d&&(n=n.concat(o.slice(r,d).map(function(p){return Be(Be({},p),{},{status:dv})})),r=d),n.push(Be(Be({},f),{},{status:hv})),r+=1,u=!0;break}}u||n.push(Be(Be({},c),{},{status:fv}))}),r<i&&(n=n.concat(o.slice(r).map(function(c){return Be(Be({},c),{},{status:dv})})));var a={};n.forEach(function(c){var u=c.key;a[u]=(a[u]||0)+1});var l=Object.keys(a).filter(function(c){return a[c]>1});return l.forEach(function(c){n=n.filter(function(u){var d=u.key,f=u.status;return d!==c||f!==fv}),n.forEach(function(u){u.key===c&&(u.status=hv)})}),n}var D4=["component","children","onVisibleChanged","onAllRemoved"],L4=["status"],O4=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function B4(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:M4,n=function(r){mE(s,r);var i=vE(s);function s(){var o;Va(this,s);for(var a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];return o=i.call.apply(i,[this].concat(l)),we(Og(o),"state",{keyEntities:[]}),we(Og(o),"removeKey",function(u){o.setState(function(d){var f=d.keyEntities.map(function(p){return p.key!==u?p:Be(Be({},p),{},{status:Vp})});return{keyEntities:f}},function(){var d=o.state.keyEntities,f=d.filter(function(p){var m=p.status;return m!==Vp}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return qa(s,[{key:"render",value:function(){var a=this,l=this.state.keyEntities,c=this.props,u=c.component,d=c.children,f=c.onVisibleChanged;c.onAllRemoved;var p=Fg(c,D4),m=u||g.Fragment,v={};return O4.forEach(function(y){v[y]=p[y],delete p[y]}),delete p.keys,g.createElement(m,p,l.map(function(y,_){var x=y.status,b=Fg(y,L4),w=x===dv||x===hv;return g.createElement(t,_h({},v,{key:b.key,visible:w,eventProps:b,onVisibleChanged:function(k){f==null||f(k,{key:b.key}),k||a.removeKey(b.key)}}),function(S,k){return d(Be(Be({},S),{},{index:_}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(a,l){var c=a.keys,u=l.keyEntities,d=pv(c),f=j4(u,d);return{keyEntities:f.filter(function(p){var m=u.find(function(v){var y=v.key;return p.key===y});return!(m&&m.status===Vp&&p.status===fv)})}}}]),s}(g.Component);return we(n,"defaultProps",{component:"div"}),n}B4(nN);const fb=g.createContext(!0);function z4(e){const t=g.useContext(fb),{children:n}=e,[,r]=XE(),{motion:i}=r,s=g.useRef(!1);return s.current||(s.current=t!==i),s.current?g.createElement(fb.Provider,{value:i},g.createElement(_4,{motion:i},n)):n}const $4=()=>null;var F4=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const H4=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let oN;function U4(){return oN||av}function W4(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const V4=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:i}=e;t!==void 0&&(oN=t),r&&W4(r)&&JD(U4(),r)},q4=e=>{const{children:t,csp:n,autoInsertSpaceInButton:r,alert:i,anchor:s,form:o,locale:a,componentSize:l,direction:c,space:u,splitter:d,virtual:f,dropdownMatchSelectWidth:p,popupMatchSelectWidth:m,popupOverflow:v,legacyLocale:y,parentContext:_,iconPrefixCls:x,theme:b,componentDisabled:w,segmented:S,statistic:k,spin:T,calendar:N,carousel:L,cascader:P,collapse:O,typography:I,checkbox:R,descriptions:j,divider:z,drawer:$,skeleton:F,steps:A,image:B,layout:E,list:H,mentions:q,modal:M,progress:re,result:oe,slider:V,breadcrumb:pe,menu:Oe,pagination:ie,input:Me,textArea:Fe,empty:We,badge:ge,radio:qe,rate:Gt,switch:wt,transfer:Rt,avatar:ln,message:Bt,tag:at,table:Ue,card:nt,tabs:mt,timeline:Xt,timePicker:pn,upload:U,notification:Q,tree:ve,colorPicker:Se,datePicker:J,rangePicker:Xe,flex:Yt,wave:Zt,dropdown:ue,warning:Ne,tour:Qe,tooltip:Dn,popover:Qt,popconfirm:il,floatButton:Ao,floatButtonGroup:xu,variant:yu,inputNumber:lp,treeSelect:cp}=e,bu=g.useCallback((Tt,$t)=>{const{prefixCls:or}=e;if($t)return $t;const Ln=or||_.getPrefixCls("");return Tt?`${Ln}-${Tt}`:Ln},[_.getPrefixCls,e.prefixCls]),jo=x||_.iconPrefixCls||qE,Do=n||_.csp;h4(jo,Do);const sl=g4(b,_.theme,{prefixCls:bu("")}),ol={csp:Do,autoInsertSpaceInButton:r,alert:i,anchor:s,locale:a||y,direction:c,space:u,splitter:d,virtual:f,popupMatchSelectWidth:m??p,popupOverflow:v,getPrefixCls:bu,iconPrefixCls:jo,theme:sl,segmented:S,statistic:k,spin:T,calendar:N,carousel:L,cascader:P,collapse:O,typography:I,checkbox:R,descriptions:j,divider:z,drawer:$,skeleton:F,steps:A,image:B,input:Me,textArea:Fe,layout:E,list:H,mentions:q,modal:M,progress:re,result:oe,slider:V,breadcrumb:pe,menu:Oe,pagination:ie,empty:We,badge:ge,radio:qe,rate:Gt,switch:wt,transfer:Rt,avatar:ln,message:Bt,tag:at,table:Ue,card:nt,tabs:mt,timeline:Xt,timePicker:pn,upload:U,notification:Q,tree:ve,colorPicker:Se,datePicker:J,rangePicker:Xe,flex:Yt,wave:Zt,dropdown:ue,warning:Ne,tour:Qe,tooltip:Dn,popover:Qt,popconfirm:il,floatButton:Ao,floatButtonGroup:xu,variant:yu,inputNumber:lp,treeSelect:cp},Ui=Object.assign({},_);Object.keys(ol).forEach(Tt=>{ol[Tt]!==void 0&&(Ui[Tt]=ol[Tt])}),H4.forEach(Tt=>{const $t=e[Tt];$t&&(Ui[Tt]=$t)}),typeof r<"u"&&(Ui.button=Object.assign({autoInsertSpace:r},Ui.button));const Wi=fE(()=>Ui,Ui,(Tt,$t)=>{const or=Object.keys(Tt),Ln=Object.keys($t);return or.length!==Ln.length||or.some(Z=>Tt[Z]!==$t[Z])}),{layer:al}=g.useContext(Tf),wu=g.useMemo(()=>({prefixCls:jo,csp:Do,layer:al?"antd":void 0}),[jo,Do,al]);let zt=g.createElement(g.Fragment,null,g.createElement($4,{dropdownMatchSelectWidth:p}),t);const ll=g.useMemo(()=>{var Tt,$t,or,Ln;return RD(((Tt=Rf.Form)===null||Tt===void 0?void 0:Tt.defaultValidateMessages)||{},((or=($t=Wi.locale)===null||$t===void 0?void 0:$t.Form)===null||or===void 0?void 0:or.defaultValidateMessages)||{},((Ln=Wi.form)===null||Ln===void 0?void 0:Ln.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[Wi,o==null?void 0:o.validateMessages]);Object.keys(ll).length>0&&(zt=g.createElement(AD.Provider,{value:ll},zt)),a&&(zt=g.createElement(LD,{locale:a,_ANT_MARK__:DD},zt)),zt=g.createElement(ND.Provider,{value:wu},zt),l&&(zt=g.createElement(t4,{size:l},zt)),zt=g.createElement(z4,null,zt);const cl=g.useMemo(()=>{const Tt=sl||{},{algorithm:$t,token:or,components:Ln,cssVar:Z}=Tt,_e=F4(Tt,["algorithm","token","components","cssVar"]),xe=$t&&(!Array.isArray($t)||$t.length>0)?Ug($t):WE,Ye={};Object.entries(Ln||{}).forEach(([fA,pA])=>{const fi=Object.assign({},pA);"algorithm"in fi&&(fi.algorithm===!0?fi.theme=xe:(Array.isArray(fi.algorithm)||typeof fi.algorithm=="function")&&(fi.theme=Ug(fi.algorithm)),delete fi.algorithm),Ye[fA]=fi});const hi=Object.assign(Object.assign({},Nc),or);return Object.assign(Object.assign({},_e),{theme:xe,token:hi,components:Ye,override:Object.assign({override:hi},Ye),cssVar:Z})},[sl]);return b&&(zt=g.createElement(VE.Provider,{value:cl},zt)),Wi.warning&&(zt=g.createElement(MD.Provider,{value:Wi.warning},zt)),w!==void 0&&(zt=g.createElement(e4,{disabled:w},zt)),g.createElement(Mf.Provider,{value:Wi},zt)},Ga=e=>{const t=g.useContext(Mf),n=g.useContext($E);return g.createElement(q4,Object.assign({parentContext:t,legacyLocale:n},e))};Ga.ConfigContext=Mf;Ga.SizeContext=Tc;Ga.config=V4;Ga.useConfig=n4;Object.defineProperty(Ga,"SizeContext",{get:()=>Tc});const lr=(e,t)=>new xt(e).setA(t).toRgbString(),Bo=(e,t)=>new xt(e).lighten(t).toHexString(),K4=e=>{const t=Aa(e,{theme:"dark"});return{1:t[0],2:t[1],3:t[2],4:t[3],5:t[6],6:t[5],7:t[4],8:t[6],9:t[5],10:t[4]}},G4=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:lr(r,.85),colorTextSecondary:lr(r,.65),colorTextTertiary:lr(r,.45),colorTextQuaternary:lr(r,.25),colorFill:lr(r,.18),colorFillSecondary:lr(r,.12),colorFillTertiary:lr(r,.08),colorFillQuaternary:lr(r,.04),colorBgSolid:lr(r,.95),colorBgSolidHover:lr(r,1),colorBgSolidActive:lr(r,.9),colorBgElevated:Bo(n,12),colorBgContainer:Bo(n,8),colorBgLayout:Bo(n,0),colorBgSpotlight:Bo(n,26),colorBgBlur:lr(r,.04),colorBorder:Bo(n,26),colorBorderSecondary:Bo(n,19)}},X4=(e,t)=>{const n=Object.keys(O_).map(s=>{const o=Aa(e[s],{theme:"dark"});return Array.from({length:10},()=>1).reduce((a,l,c)=>(a[`${s}-${c+1}`]=o[c],a[`${s}${c+1}`]=o[c],a),{})}).reduce((s,o)=>(s=Object.assign(Object.assign({},s),o),s),{}),r=t??B_(e),i=UE(e,{generateColorPalettes:K4,generateNeutralColorPalettes:G4});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),i),{colorPrimaryBg:i.colorPrimaryBorder,colorPrimaryBgHover:i.colorPrimaryBorderHover})},pb={defaultSeed:bh.token,defaultAlgorithm:B_,darkAlgorithm:X4};function mb({children:e}){const t=P_(),[n,r]=g.useState(t.theme);return g.useEffect(()=>t.onThemeChange(r),[t]),h.jsx(Ga,{theme:{algorithm:n.mode==="dark"?pb.darkAlgorithm:pb.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}var Ke;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},e.find=(i,s)=>{for(const o of i)if(s(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Ke||(Ke={}));var gb;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(gb||(gb={}));const ce=Ke.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ns=e=>{switch(typeof e){case"undefined":return ce.undefined;case"string":return ce.string;case"number":return Number.isNaN(e)?ce.nan:ce.number;case"boolean":return ce.boolean;case"function":return ce.function;case"bigint":return ce.bigint;case"symbol":return ce.symbol;case"object":return Array.isArray(e)?ce.array:e===null?ce.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?ce.promise:typeof Map<"u"&&e instanceof Map?ce.map:typeof Set<"u"&&e instanceof Set?ce.set:typeof Date<"u"&&e instanceof Date?ce.date:ce.object;default:return ce.unknown}},K=Ke.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ri extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(o))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof Ri))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ke.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ri.create=e=>new Ri(e);const mv=(e,t)=>{let n;switch(e.code){case K.invalid_type:e.received===ce.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case K.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Ke.jsonStringifyReplacer)}`;break;case K.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ke.joinValues(e.keys,", ")}`;break;case K.invalid_union:n="Invalid input";break;case K.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ke.joinValues(e.options)}`;break;case K.invalid_enum_value:n=`Invalid enum value. Expected ${Ke.joinValues(e.options)}, received '${e.received}'`;break;case K.invalid_arguments:n="Invalid function arguments";break;case K.invalid_return_type:n="Invalid function return type";break;case K.invalid_date:n="Invalid date";break;case K.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Ke.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case K.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case K.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case K.custom:n="Invalid input";break;case K.invalid_intersection_types:n="Intersection results could not be merged";break;case K.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case K.not_finite:n="Number must be finite";break;default:n=t.defaultError,Ke.assertNever(e)}return{message:n}};let Y4=mv;function Z4(){return Y4}const Q4=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,s=[...n,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(o,{data:t,defaultError:a}).message;return{...i,path:s,message:a}};function se(e,t){const n=Z4(),r=Q4({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===mv?void 0:mv].filter(i=>!!i)});e.common.issues.push(r)}class Tn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const i of n){if(i.status==="aborted")return Ce;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const i of n){const s=await i.key,o=await i.value;r.push({key:s,value:o})}return Tn.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const i of n){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Ce;s.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:t.value,value:r}}}const Ce=Object.freeze({status:"aborted"}),Dl=e=>({status:"dirty",value:e}),Sr=e=>({status:"valid",value:e}),vb=e=>e.status==="aborted",_b=e=>e.status==="dirty",ja=e=>e.status==="valid",wh=e=>typeof Promise<"u"&&e instanceof Promise;var me;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(me||(me={}));class ii{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const xb=(e,t)=>{if(ja(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ri(e.common.issues);return this._error=n,this._error}}};function Re(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,a)=>{const{message:l}=e;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:i}}class He{get description(){return this._def.description}_getType(t){return ns(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ns(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Tn,ctx:{common:t.parent.common,data:t.data,parsedType:ns(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(wh(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ns(t)},i=this._parseSync({data:t,path:r.path,parent:r});return xb(r,i)}"~validate"(t){var r,i;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ns(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:n});return ja(s)?{value:s.value}:{issues:n.common.issues}}catch(s){(i=(r=s==null?void 0:s.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(s=>ja(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ns(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await(wh(i)?i:Promise.resolve(i));return xb(r,s)}refine(t,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{const o=t(i),a=()=>s.addIssue({code:K.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new uo({schema:this,typeName:Ee.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ei.create(this,this._def)}nullable(){return ho.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ei.create(this)}promise(){return Th.create(this,this._def)}or(t){return kh.create([this,t],this._def)}and(t){return Ch.create(this,t,this._def)}transform(t){return new uo({...Re(this._def),schema:this,typeName:Ee.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Ph({...Re(this._def),innerType:this,defaultValue:n,typeName:Ee.ZodDefault})}brand(){return new uN({typeName:Ee.ZodBranded,type:this,...Re(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Ih({...Re(this._def),innerType:this,catchValue:n,typeName:Ee.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return F_.create(this,t)}readonly(){return Rh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const J4=/^c[^\s-]{8,}$/i,eL=/^[0-9a-z]+$/,tL=/^[0-9A-HJKMNP-TV-Z]{26}$/i,nL=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,rL=/^[a-z0-9_-]{21}$/i,iL=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,sL=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,oL=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,aL="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let qp;const lL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,cL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,uL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,dL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,hL=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,fL=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,aN="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",pL=new RegExp(`^${aN}$`);function lN(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function mL(e){return new RegExp(`^${lN(e)}$`)}function gL(e){let t=`${aN}T${lN(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function vL(e,t){return!!((t==="v4"||!t)&&lL.test(e)||(t==="v6"||!t)&&uL.test(e))}function _L(e,t){if(!iL.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function xL(e,t){return!!((t==="v4"||!t)&&cL.test(e)||(t==="v6"||!t)&&dL.test(e))}class wi extends He{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==ce.string){const s=this._getOrReturnCtx(t);return se(s,{code:K.invalid_type,expected:ce.string,received:s.parsedType}),Ce}const r=new Tn;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),se(i,{code:K.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),se(i,{code:K.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=t.data.length>s.value,a=t.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(t,i),o?se(i,{code:K.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&se(i,{code:K.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")oL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"email",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")qp||(qp=new RegExp(aL,"u")),qp.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"emoji",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")nL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"uuid",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")rL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"nanoid",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")J4.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"cuid",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")eL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"cuid2",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")tL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"ulid",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),se(i,{validation:"url",code:K.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"regex",code:K.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),se(i,{code:K.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),se(i,{code:K.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),se(i,{code:K.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?gL(s).test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{code:K.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?pL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{code:K.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?mL(s).test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{code:K.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?sL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"duration",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?vL(t.data,s.version)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"ip",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?_L(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"jwt",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?xL(t.data,s.version)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"cidr",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?hL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"base64",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?fL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"base64url",code:K.invalid_string,message:s.message}),r.dirty()):Ke.assertNever(s);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:K.invalid_string,...me.errToObj(r)})}_addCheck(t){return new wi({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...me.errToObj(t)})}url(t){return this._addCheck({kind:"url",...me.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...me.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...me.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...me.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...me.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...me.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...me.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...me.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...me.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...me.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...me.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...me.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...me.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...me.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...me.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...me.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...me.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...me.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...me.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...me.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...me.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...me.errToObj(n)})}nonempty(t){return this.min(1,me.errToObj(t))}trim(){return new wi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new wi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new wi({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}wi.create=e=>new wi({checks:[],typeName:Ee.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Re(e)});function yL(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),o=Number.parseInt(t.toFixed(i).replace(".",""));return s%o/10**i}class Da extends He{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==ce.number){const s=this._getOrReturnCtx(t);return se(s,{code:K.invalid_type,expected:ce.number,received:s.parsedType}),Ce}let r;const i=new Tn;for(const s of this._def.checks)s.kind==="int"?Ke.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),se(r,{code:K.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),se(r,{code:K.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),se(r,{code:K.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?yL(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),se(r,{code:K.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),se(r,{code:K.not_finite,message:s.message}),i.dirty()):Ke.assertNever(s);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,me.toString(n))}gt(t,n){return this.setLimit("min",t,!1,me.toString(n))}lte(t,n){return this.setLimit("max",t,!0,me.toString(n))}lt(t,n){return this.setLimit("max",t,!1,me.toString(n))}setLimit(t,n,r,i){return new Da({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:me.toString(i)}]})}_addCheck(t){return new Da({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:me.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:me.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:me.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:me.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:me.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:me.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:me.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:me.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:me.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Ke.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Da.create=e=>new Da({checks:[],typeName:Ee.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Re(e)});class Pc extends He{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==ce.bigint)return this._getInvalidInput(t);let r;const i=new Tn;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),se(r,{code:K.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),se(r,{code:K.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),se(r,{code:K.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Ke.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return se(n,{code:K.invalid_type,expected:ce.bigint,received:n.parsedType}),Ce}gte(t,n){return this.setLimit("min",t,!0,me.toString(n))}gt(t,n){return this.setLimit("min",t,!1,me.toString(n))}lte(t,n){return this.setLimit("max",t,!0,me.toString(n))}lt(t,n){return this.setLimit("max",t,!1,me.toString(n))}setLimit(t,n,r,i){return new Pc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:me.toString(i)}]})}_addCheck(t){return new Pc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:me.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:me.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:me.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:me.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:me.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Pc.create=e=>new Pc({checks:[],typeName:Ee.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Re(e)});class gv extends He{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==ce.boolean){const r=this._getOrReturnCtx(t);return se(r,{code:K.invalid_type,expected:ce.boolean,received:r.parsedType}),Ce}return Sr(t.data)}}gv.create=e=>new gv({typeName:Ee.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Re(e)});class Sh extends He{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==ce.date){const s=this._getOrReturnCtx(t);return se(s,{code:K.invalid_type,expected:ce.date,received:s.parsedType}),Ce}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return se(s,{code:K.invalid_date}),Ce}const r=new Tn;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),se(i,{code:K.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),se(i,{code:K.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):Ke.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Sh({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:me.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:me.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}Sh.create=e=>new Sh({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Ee.ZodDate,...Re(e)});class yb extends He{_parse(t){if(this._getType(t)!==ce.symbol){const r=this._getOrReturnCtx(t);return se(r,{code:K.invalid_type,expected:ce.symbol,received:r.parsedType}),Ce}return Sr(t.data)}}yb.create=e=>new yb({typeName:Ee.ZodSymbol,...Re(e)});class vv extends He{_parse(t){if(this._getType(t)!==ce.undefined){const r=this._getOrReturnCtx(t);return se(r,{code:K.invalid_type,expected:ce.undefined,received:r.parsedType}),Ce}return Sr(t.data)}}vv.create=e=>new vv({typeName:Ee.ZodUndefined,...Re(e)});class _v extends He{_parse(t){if(this._getType(t)!==ce.null){const r=this._getOrReturnCtx(t);return se(r,{code:K.invalid_type,expected:ce.null,received:r.parsedType}),Ce}return Sr(t.data)}}_v.create=e=>new _v({typeName:Ee.ZodNull,...Re(e)});class bb extends He{constructor(){super(...arguments),this._any=!0}_parse(t){return Sr(t.data)}}bb.create=e=>new bb({typeName:Ee.ZodAny,...Re(e)});class xv extends He{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Sr(t.data)}}xv.create=e=>new xv({typeName:Ee.ZodUnknown,...Re(e)});class Ss extends He{_parse(t){const n=this._getOrReturnCtx(t);return se(n,{code:K.invalid_type,expected:ce.never,received:n.parsedType}),Ce}}Ss.create=e=>new Ss({typeName:Ee.ZodNever,...Re(e)});class wb extends He{_parse(t){if(this._getType(t)!==ce.undefined){const r=this._getOrReturnCtx(t);return se(r,{code:K.invalid_type,expected:ce.void,received:r.parsedType}),Ce}return Sr(t.data)}}wb.create=e=>new wb({typeName:Ee.ZodVoid,...Re(e)});class ei extends He{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==ce.array)return se(n,{code:K.invalid_type,expected:ce.array,received:n.parsedType}),Ce;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(o||a)&&(se(n,{code:o?K.too_big:K.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(se(n,{code:K.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(se(n,{code:K.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>i.type._parseAsync(new ii(n,o,n.path,a)))).then(o=>Tn.mergeArray(r,o));const s=[...n.data].map((o,a)=>i.type._parseSync(new ii(n,o,n.path,a)));return Tn.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new ei({...this._def,minLength:{value:t,message:me.toString(n)}})}max(t,n){return new ei({...this._def,maxLength:{value:t,message:me.toString(n)}})}length(t,n){return new ei({...this._def,exactLength:{value:t,message:me.toString(n)}})}nonempty(t){return this.min(1,t)}}ei.create=(e,t)=>new ei({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ee.ZodArray,...Re(t)});function Ko(e){if(e instanceof jt){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Ei.create(Ko(r))}return new jt({...e._def,shape:()=>t})}else return e instanceof ei?new ei({...e._def,type:Ko(e.element)}):e instanceof Ei?Ei.create(Ko(e.unwrap())):e instanceof ho?ho.create(Ko(e.unwrap())):e instanceof lo?lo.create(e.items.map(t=>Ko(t))):e}class jt extends He{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=Ke.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==ce.object){const c=this._getOrReturnCtx(t);return se(c,{code:K.invalid_type,expected:ce.object,received:c.parsedType}),Ce}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ss&&this._def.unknownKeys==="strip"))for(const c in i.data)o.includes(c)||a.push(c);const l=[];for(const c of o){const u=s[c],d=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new ii(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Ss){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")a.length>0&&(se(i,{code:K.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const d=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new ii(i,d,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const d=await u.key,f=await u.value;c.push({key:d,value:f,alwaysSet:u.alwaysSet})}return c}).then(c=>Tn.mergeObjectSync(r,c)):Tn.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return me.errToObj,new jt({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,o;const i=((o=(s=this._def).errorMap)==null?void 0:o.call(s,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:me.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new jt({...this._def,unknownKeys:"strip"})}passthrough(){return new jt({...this._def,unknownKeys:"passthrough"})}extend(t){return new jt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new jt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ee.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new jt({...this._def,catchall:t})}pick(t){const n={};for(const r of Ke.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new jt({...this._def,shape:()=>n})}omit(t){const n={};for(const r of Ke.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new jt({...this._def,shape:()=>n})}deepPartial(){return Ko(this)}partial(t){const n={};for(const r of Ke.objectKeys(this.shape)){const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new jt({...this._def,shape:()=>n})}required(t){const n={};for(const r of Ke.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Ei;)s=s._def.innerType;n[r]=s}return new jt({...this._def,shape:()=>n})}keyof(){return cN(Ke.objectKeys(this.shape))}}jt.create=(e,t)=>new jt({shape:()=>e,unknownKeys:"strip",catchall:Ss.create(),typeName:Ee.ZodObject,...Re(t)});jt.strictCreate=(e,t)=>new jt({shape:()=>e,unknownKeys:"strict",catchall:Ss.create(),typeName:Ee.ZodObject,...Re(t)});jt.lazycreate=(e,t)=>new jt({shape:e,unknownKeys:"strip",catchall:Ss.create(),typeName:Ee.ZodObject,...Re(t)});class kh extends He{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function i(s){for(const a of s)if(a.result.status==="valid")return a.result;for(const a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(a=>new Ri(a.ctx.common.issues));return se(n,{code:K.invalid_union,unionErrors:o}),Ce}if(n.common.async)return Promise.all(r.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(l=>new Ri(l));return se(n,{code:K.invalid_union,unionErrors:a}),Ce}}get options(){return this._def.options}}kh.create=(e,t)=>new kh({options:e,typeName:Ee.ZodUnion,...Re(t)});const vi=e=>e instanceof bv?vi(e.schema):e instanceof uo?vi(e.innerType()):e instanceof Nh?[e.value]:e instanceof co?e.options:e instanceof wv?Ke.objectValues(e.enum):e instanceof Ph?vi(e._def.innerType):e instanceof vv?[void 0]:e instanceof _v?[null]:e instanceof Ei?[void 0,...vi(e.unwrap())]:e instanceof ho?[null,...vi(e.unwrap())]:e instanceof uN||e instanceof Rh?vi(e.unwrap()):e instanceof Ih?vi(e._def.innerType):[];class $_ extends He{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ce.object)return se(n,{code:K.invalid_type,expected:ce.object,received:n.parsedType}),Ce;const r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(se(n,{code:K.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Ce)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const i=new Map;for(const s of n){const o=vi(s.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of o){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,s)}}return new $_({typeName:Ee.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Re(r)})}}function yv(e,t){const n=ns(e),r=ns(t);if(e===t)return{valid:!0,data:e};if(n===ce.object&&r===ce.object){const i=Ke.objectKeys(t),s=Ke.objectKeys(e).filter(a=>i.indexOf(a)!==-1),o={...e,...t};for(const a of s){const l=yv(e[a],t[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===ce.array&&r===ce.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<e.length;s++){const o=e[s],a=t[s],l=yv(o,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===ce.date&&r===ce.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Ch extends He{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(vb(s)||vb(o))return Ce;const a=yv(s.value,o.value);return a.valid?((_b(s)||_b(o))&&n.dirty(),{status:n.value,value:a.data}):(se(r,{code:K.invalid_intersection_types}),Ce)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Ch.create=(e,t,n)=>new Ch({left:e,right:t,typeName:Ee.ZodIntersection,...Re(n)});class lo extends He{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.array)return se(r,{code:K.invalid_type,expected:ce.array,received:r.parsedType}),Ce;if(r.data.length<this._def.items.length)return se(r,{code:K.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ce;!this._def.rest&&r.data.length>this._def.items.length&&(se(r,{code:K.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const s=[...r.data].map((o,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new ii(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>Tn.mergeArray(n,o)):Tn.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new lo({...this._def,rest:t})}}lo.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new lo({items:e,typeName:Ee.ZodTuple,rest:null,...Re(t)})};class Eh extends He{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.object)return se(r,{code:K.invalid_type,expected:ce.object,received:r.parsedType}),Ce;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in r.data)i.push({key:s._parse(new ii(r,a,r.path,a)),value:o._parse(new ii(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Tn.mergeObjectAsync(n,i):Tn.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof He?new Eh({keyType:t,valueType:n,typeName:Ee.ZodRecord,...Re(r)}):new Eh({keyType:wi.create(),valueType:t,typeName:Ee.ZodRecord,...Re(n)})}}class Sb extends He{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.map)return se(r,{code:K.invalid_type,expected:ce.map,received:r.parsedType}),Ce;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new ii(r,a,r.path,[c,"key"])),value:s._parse(new ii(r,l,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Ce;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of o){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Ce;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}}}}Sb.create=(e,t,n)=>new Sb({valueType:t,keyType:e,typeName:Ee.ZodMap,...Re(n)});class Ic extends He{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.set)return se(r,{code:K.invalid_type,expected:ce.set,received:r.parsedType}),Ce;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(se(r,{code:K.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(se(r,{code:K.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const s=this._def.valueType;function o(l){const c=new Set;for(const u of l){if(u.status==="aborted")return Ce;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}const a=[...r.data.values()].map((l,c)=>s._parse(new ii(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(t,n){return new Ic({...this._def,minSize:{value:t,message:me.toString(n)}})}max(t,n){return new Ic({...this._def,maxSize:{value:t,message:me.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Ic.create=(e,t)=>new Ic({valueType:e,minSize:null,maxSize:null,typeName:Ee.ZodSet,...Re(t)});class bv extends He{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}bv.create=(e,t)=>new bv({getter:e,typeName:Ee.ZodLazy,...Re(t)});class Nh extends He{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return se(n,{received:n.data,code:K.invalid_literal,expected:this._def.value}),Ce}return{status:"valid",value:t.data}}get value(){return this._def.value}}Nh.create=(e,t)=>new Nh({value:e,typeName:Ee.ZodLiteral,...Re(t)});function cN(e,t){return new co({values:e,typeName:Ee.ZodEnum,...Re(t)})}class co extends He{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return se(n,{expected:Ke.joinValues(r),received:n.parsedType,code:K.invalid_type}),Ce}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return se(n,{received:n.data,code:K.invalid_enum_value,options:r}),Ce}return Sr(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return co.create(t,{...this._def,...n})}exclude(t,n=this._def){return co.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}co.create=cN;class wv extends He{_parse(t){const n=Ke.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==ce.string&&r.parsedType!==ce.number){const i=Ke.objectValues(n);return se(r,{expected:Ke.joinValues(i),received:r.parsedType,code:K.invalid_type}),Ce}if(this._cache||(this._cache=new Set(Ke.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=Ke.objectValues(n);return se(r,{received:r.data,code:K.invalid_enum_value,options:i}),Ce}return Sr(t.data)}get enum(){return this._def.values}}wv.create=(e,t)=>new wv({values:e,typeName:Ee.ZodNativeEnum,...Re(t)});class Th extends He{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ce.promise&&n.common.async===!1)return se(n,{code:K.invalid_type,expected:ce.promise,received:n.parsedType}),Ce;const r=n.parsedType===ce.promise?n.data:Promise.resolve(n.data);return Sr(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Th.create=(e,t)=>new Th({type:e,typeName:Ee.ZodPromise,...Re(t)});class uo extends He{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ee.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:o=>{se(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return Ce;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?Ce:l.status==="dirty"||n.value==="dirty"?Dl(l.value):l});{if(n.value==="aborted")return Ce;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?Ce:a.status==="dirty"||n.value==="dirty"?Dl(a.value):a}}if(i.type==="refinement"){const o=a=>{const l=i.refinement(a,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Ce:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Ce:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ja(o))return Ce;const a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>ja(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:n.value,value:a})):Ce);Ke.assertNever(i)}}uo.create=(e,t,n)=>new uo({schema:e,typeName:Ee.ZodEffects,effect:t,...Re(n)});uo.createWithPreprocess=(e,t,n)=>new uo({schema:t,effect:{type:"preprocess",transform:e},typeName:Ee.ZodEffects,...Re(n)});class Ei extends He{_parse(t){return this._getType(t)===ce.undefined?Sr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Ei.create=(e,t)=>new Ei({innerType:e,typeName:Ee.ZodOptional,...Re(t)});class ho extends He{_parse(t){return this._getType(t)===ce.null?Sr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ho.create=(e,t)=>new ho({innerType:e,typeName:Ee.ZodNullable,...Re(t)});class Ph extends He{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===ce.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Ph.create=(e,t)=>new Ph({innerType:e,typeName:Ee.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Re(t)});class Ih extends He{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return wh(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ri(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ri(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Ih.create=(e,t)=>new Ih({innerType:e,typeName:Ee.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Re(t)});class kb extends He{_parse(t){if(this._getType(t)!==ce.nan){const r=this._getOrReturnCtx(t);return se(r,{code:K.invalid_type,expected:ce.nan,received:r.parsedType}),Ce}return{status:"valid",value:t.data}}}kb.create=e=>new kb({typeName:Ee.ZodNaN,...Re(e)});class uN extends He{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class F_ extends He{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Ce:s.status==="dirty"?(n.dirty(),Dl(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Ce:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new F_({in:t,out:n,typeName:Ee.ZodPipeline})}}class Rh extends He{_parse(t){const n=this._def.innerType._parse(t),r=i=>(ja(i)&&(i.value=Object.freeze(i.value)),i);return wh(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}Rh.create=(e,t)=>new Rh({innerType:e,typeName:Ee.ZodReadonly,...Re(t)});var Ee;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Ee||(Ee={}));const C=wi.create,Y=Da.create,Te=gv.create,_a=xv.create;Ss.create;const be=ei.create,D=jt.create;kh.create;const ai=$_.create;Ch.create;lo.create;const nu=Eh.create,ee=Nh.create,et=co.create;Th.create;Ei.create;ho.create;const bL=["owner"],wL=["agent","owner","user-upload"],dN=D({id:C().min(1),relPath:C().min(1),from:et(wL),label:C().optional(),size:Y().int().nonnegative(),mime:C().min(1),addedAt:Y().int().nonnegative(),lastEditedAt:Y().int().nonnegative().optional(),stale:Te().optional()});D({sessionId:C().min(1),relPath:C().min(1),ttlSeconds:Y().int().positive().nullable().optional(),view:et(["raw","md-rendered"]).optional()});D({url:C().min(1),expiresAt:Y().int().nonnegative().nullable()});D({sessionId:C().min(1),relPath:C().min(1),label:C().optional(),origin:ee("agent").optional()});D({entry:dN});D({sessionId:C().min(1),relPath:C().min(1)});D({removed:ee(!0)});D({sessionId:C().min(1)});D({entries:be(dN)});D({attachmentId:C().min(1),url:C().min(1),relPath:C().min(1),sizeBytes:Y().int().nonnegative(),mimeType:C().min(1)});const SL=ai("type",[D({type:ee("persona"),id:C().min(1)}).strict(),D({type:ee("chat"),id:C().min(1)}).strict(),D({type:ee("*")}).strict()]),kL=et(["read","send","admin"]),H_=D({resource:SL,actions:be(kL).min(1)}).strict(),CL=D({id:C().min(1),secretHash:C().regex(/^[a-f0-9]{64}$/),displayName:C(),grants:be(H_),issuedAt:Y().int().nonnegative(),expiresAt:Y().int().positive().optional(),maxUses:Y().int().positive().optional(),usedCount:Y().int().nonnegative(),peerOwnerId:C().min(1).optional(),firstUsedByPeerAt:Y().int().positive().optional(),peerDisplayName:C().optional()}).strict(),EL=CL.omit({secretHash:!0});D({type:ee("whoami:ok"),owner:D({id:C(),kind:et(["owner","guest"]),displayName:C(),ownerId:C(),provider:C()}).strict(),capability:EL,grantedPersonas:be(D({id:C().min(1),displayName:C()}).strict())}).strict();D({selfUrl:C().min(1)});D({type:ee("contact:handshake:ok"),owner:D({id:C(),ownerId:C(),provider:C(),displayName:C()}),grants:be(H_)});D({deviceId:C().min(1),remoteAccessAllowed:Te()}).strict();D({type:ee("contact:setRemoteAccess:ok"),deviceId:C().min(1),remoteAccessAllowed:Te()}).strict();D({type:ee("contact:remote-access-updated"),deviceId:C().min(1),remoteAccessAllowed:Te()}).strict();const NL=D({deviceId:C().min(1),ownerId:C().min(1),provider:C().min(1),displayName:C(),remoteUrl:C().min(1),connectToken:C(),grants:be(H_),addedAt:Y().int().nonnegative(),pinnedAt:Y().int().nullable().default(null),remoteAccessAllowed:Te().default(!1)}).strict(),hN=NL;D({deviceId:C().min(1)}).strict();D({type:ee("contact:remove:ok"),deviceId:C().min(1)}).strict();D({type:ee("contact:list:ok"),contacts:be(hN)}).strict();D({type:ee("contact:added"),contact:hN}).strict();D({type:ee("contact:removed"),deviceId:C().min(1)}).strict();D({deviceId:C().min(1),pinned:Te()}).strict();D({type:ee("contact:pin:ok"),deviceId:C().min(1),pinnedAt:Y().int().nullable()}).strict();D({type:ee("contact:pinned"),deviceId:C().min(1),pinnedAt:Y().int().nullable()}).strict();const TL=D({deviceId:C().min(1),name:C().min(1),url:C().min(1)});D({type:ee("device:list:ok"),devices:be(TL)});D({deviceId:C().min(1),url:C().min(1).optional(),name:C().optional()});D({type:ee("device:connect:ok"),deviceId:C(),name:C(),url:C()});const fN=D({ownerId:C().min(1),provider:C().min(1),displayName:C().min(1),avatarUrl:C().optional(),unionId:C().optional()});D({type:ee("auth:login:start:ok"),authUrl:C().min(1),state:C().min(1)});D({type:ee("auth:getIdentity:ok"),identity:fN.nullable(),deviceId:C().min(1)});D({type:ee("auth:logout:ok")});D({type:ee("auth:login:done"),identity:fN});D({type:ee("auth:login:failed"),reason:C()});const U_=ai("kind",[D({kind:ee("success"),text:C(),filePaths:be(C()).optional()}),D({kind:ee("failure"),reason:C()})]);D({targetPersona:C().min(1).optional(),dispatchId:C().min(1).optional(),prompt:C(),targetDeviceId:C().min(1).optional(),model:C().min(1).optional(),sessionLabel:C().min(1).max(60).optional()}).refine(e=>e.targetPersona!==void 0||e.dispatchId!==void 0,{message:"either targetPersona (new dispatch) or dispatchId (follow-up) is required"}).refine(e=>!(e.dispatchId!==void 0&&e.targetDeviceId!==void 0),{message:"cross-device dispatch cannot be continued (dispatchId + targetDeviceId are mutually exclusive)"});D({dispatchId:C().min(1),outcome:U_});const PL=["running","completed","failed"],pN=et(PL),IL=D({dispatchId:C().min(1),sourceSessionId:C().min(1),sourcePersonaId:C().min(1).optional(),targetPersonaId:C().min(1),workerSessionId:C().min(1).optional(),taskText:C(),status:pN,outcome:U_.optional(),meta:nu(_a()).optional(),createdAt:C().min(1),completedAt:C().min(1).optional(),deliveredAt:C().min(1).optional()});D({sourceSessionId:C().min(1).optional()});D({records:be(IL)});D({dispatchId:C().min(1)});D({type:ee("personaDispatch:get:ok"),status:pN,outcome:U_.optional()});const RL=/^[a-z0-9][a-z0-9-]*$/;et(["stopped","starting","running","crashed","invalid"]);const ML=new Set(["localhost","127.0.0.1"]);function AL(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&ML.has(t.hostname))}const Ku=D({id:C().regex(RL),name:C().min(1),version:C().min(1),apiVersion:ee("1"),runtime:D({startCommand:C().min(1)}).passthrough().optional(),entry:D({url:C().url().refine(AL,{message:"INVALID_URL_SCHEME: only https or http://localhost is allowed"})}).strict().optional()}).passthrough().superRefine((e,t)=>{var i;const n=!!e.runtime,r=!!((i=e.entry)!=null&&i.url);n&&r&&t.addIssue({code:K.custom,message:"INVALID_MANIFEST: entry.url and runtime cannot coexist"}),!n&&!r&&t.addIssue({code:K.custom,message:"INVALID_MANIFEST: must have either entry.url or runtime"})}),jL=ai("kind",[D({kind:ee("local"),port:Y().int().min(1).max(65535)}),D({kind:ee("hosted"),url:C().url()})]);ai("state",[D({extId:C(),manifest:Ku,state:ee("stopped")}),D({extId:C(),manifest:Ku,state:ee("starting")}),D({extId:C(),manifest:Ku,state:ee("running"),target:jL}),D({extId:C(),manifest:Ku,state:ee("crashed")}),D({extId:C(),manifest:_a().nullable(),state:ee("invalid"),invalidReason:C().min(1)})]);D({snapshotHash:C().min(1),version:C().min(1),publishedAt:Y()});const DL=ai("kind",[D({kind:ee("p2p-tunnel"),ownerPrincipalId:C().min(1),extId:C().min(1)})]);ai("kind",[D({kind:ee("p2p-tunnel"),ownerPrincipalId:C().min(1),extId:C().min(1),snapshotHash:C().min(1)})]);D({extId:C().min(1),name:C().min(1),version:C().min(1),contentHash:C().min(1),publishedAt:Y()});const LL=ai("kind",[D({kind:ee("clean")}),D({kind:ee("ready-new-version"),fromVersion:C().min(1),toVersion:C().min(1)}),D({kind:ee("error-same-hash"),version:C().min(1)}),D({kind:ee("error-version-not-bumped"),localVersion:C().min(1),publishedVersion:C().min(1)}),D({kind:ee("error-version-regression"),localVersion:C().min(1),publishedVersion:C().min(1)})]);D({localManifest:D({name:C().min(1),version:C().min(1),contentHash:C().min(1)}),publishState:ai("kind",[D({kind:ee("unpublished")}),D({kind:ee("published"),version:C().min(1),contentHash:C().min(1),publishedAt:Y()})]),check:LL});D({extId:C().min(1),newVersion:C().min(1).nullish()});D({extId:C().min(1)});D({extId:C().min(1),snapshotHash:C().min(1)});D({channelRef:DL,snapshotHash:C().min(1),zipBase64:C().min(1)});D({id:C().min(1),peerDeviceId:C().min(1),senderDeviceId:C().min(1),text:C().min(1),createdAt:Y().int().nonnegative(),readBy:nu(C().min(1),Y().int().positive()).default({}),origin:D({kind:ee("persona"),personaId:C().min(1)}).optional()}).strict();D({peerDeviceId:C().min(1).optional(),id:C().min(1),text:C().min(1),createdAt:Y().int().nonnegative(),origin:D({kind:ee("persona"),personaId:C().min(1)}).optional()}).strict();D({peerDeviceId:C().min(1),sinceCreatedAt:Y().int().nonnegative().optional()}).strict();D({peerDeviceId:C().min(1),upToCreatedAt:Y().int().nonnegative()}).strict();D({peerDeviceId:C().min(1).optional(),text:C().min(1)});D({peerDeviceId:C().min(1).optional(),command:C().min(1),timeoutMs:Y().int().positive().optional()}).strict();D({type:ee("peerExec:run:ok"),stdout:C(),stderr:C(),exitCode:Y().int().nullable(),timedOut:Te(),stdoutTruncated:Te(),stderrTruncated:Te()}).strict();const mN=ai("kind",[D({kind:ee("at"),at:C().min(1)}),D({kind:ee("every"),everyMs:Y().int().positive(),anchorMs:Y().int().nonnegative().optional()}),D({kind:ee("cron"),expr:C().min(1),tz:C().min(1).optional()})]),ru=C().trim().min(1);D({personaId:ru,name:C().min(1),schedule:mN,prompt:C().min(1),targetPersona:C().min(1).optional(),timeoutMs:Y().int().positive().optional()});D({personaId:ru,onlyMine:Te().optional()});D({personaId:ru,shiftId:C().min(1)});const OL=D({name:C().min(1).optional(),schedule:mN.optional(),prompt:C().min(1).optional(),targetPersona:C().min(1).optional(),timeoutMs:Y().int().positive().optional(),enabled:Te().optional()});D({personaId:ru,shiftId:C().min(1),patch:OL});D({personaId:ru,shiftId:C().min(1),limit:Y().int().positive().optional()});const BL=D({personaId:C(),label:C(),model:C().optional(),public:Te(),iconKey:C().optional(),tool:C().optional(),createdAt:Y(),updatedAt:Y()}).strict(),zL=D({name:C().min(1),description:C().optional()}),$L=D({id:C().min(1)}),FL=D({permissions:D({defaultMode:C().optional(),allow:be(C()).optional(),deny:be(C()).optional()}).optional(),sandbox:D({enabled:Te().optional(),autoAllowBashIfSandboxed:Te().optional(),allowUnsandboxedCommands:Te().optional(),excludedCommands:be(C()).optional(),filesystem:D({denyRead:be(C()).optional(),allowRead:be(C()).optional(),denyWrite:be(C()).optional(),allowWrite:be(C()).optional()}).optional(),network:D({allowedDomains:be(C()).optional(),allowLocalBinding:Te().optional()}).optional()}).optional()});BL.extend({personality:C().optional(),skills:be(zL).optional(),plugins:be($L).optional(),sandboxSettings:FL.nullable().optional()});D({label:C().min(1),personality:C(),model:C().optional(),tool:C().optional(),public:Te().optional(),iconKey:C().optional()}).strict();D({personaId:C().min(1)});D({personaId:C().min(1),patch:D({label:C().min(1).optional(),model:C().optional(),tool:C().optional(),personality:C().optional(),public:Te().optional(),iconKey:C().nullable().optional()}).strict()}).strict();D({writableRoots:be(C()).optional(),denyRead:be(C()).optional(),network:Te().optional()}).strict();const gN=["ready","session:info","session:status","session:event","session:deleted","session:rewound","session:cleared","permission:request","session:question","session:question:cleared","pong","error","subscribed","unsubscribed","auth:ok","tunnel:ready","tunnel:exited","tunnel:unavailable","session:control","session:pty","contact:added","contact:pinned","contact:removed","contact:remote-access-updated","inbox:event","friend:reverseTokenOffered","auth:login:done","auth:login:failed","appBuilder:project-updated","appBuilder:publish-progress","appBuilder:publish-failed"],vN=["idle","running","running-idle","stopped","error","observing"],HL=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools"],UL=["builtin","global","project","plugin"],WL=["builtin","global","project","policy","plugin"],_N=et(["owner","guest"]);D({id:C().min(1),kind:_N,displayName:C(),feishuUnionId:C().optional()}).strict();const VL=D({did:C().min(1),displayName:C(),feishuUnionId:C().optional(),principal:_N}).strict(),qL=et(vN),KL=D({input_tokens:Y().int().nonnegative().optional(),cache_read_input_tokens:Y().int().nonnegative().optional(),cache_creation_input_tokens:Y().int().nonnegative().optional(),output_tokens:Y().int().nonnegative().optional()}),GL=D({inputTokens:Y().int().nonnegative(),outputTokens:Y().int().nonnegative(),cacheReadTokens:Y().int().nonnegative().optional(),cacheCreateTokens:Y().int().nonnegative().optional()}),xN={gitBranch:C().optional(),resolvedModel:C().optional(),contextUsage:GL.optional(),contextWindowSize:Y().int().positive().optional()},XL=D(xN),YL=D({id:C().min(1),label:C().min(1),description:C().optional(),contextWindowSize:Y().int().positive(),default:Te().optional()}),ZL=D({id:C().min(1),label:C().min(1),description:C().optional()}),QL=D({name:C().min(1),type:et(["string","select","toggle"]),label:C().min(1),description:C().optional(),options:be(D({value:C(),label:C(),description:C().optional()})).optional(),default:_a().optional(),scope:et(["core","tool-specific"])});D({tool:C().min(1)});const JL=D({rewind:Te(),subagents:Te(),tui:Te(),observe:Te(),fileSharing:Te(),fork:Te()});D({tool:C().min(1),toolSessionIdLabel:C().optional(),models:be(YL),permissionModes:be(ZL),configSchema:be(QL),features:JL});const eO=D({tool:C().min(1),pattern:C().min(1),createdAt:C().min(1).optional()});D({sessionId:C().min(1),cwd:C().min(1),tool:ee("claude").or(C().min(1)).default("claude"),toolSessionId:C().optional(),label:C().optional(),model:C().optional(),permissionMode:C().optional(),effort:C().optional(),...xN,permissionRules:be(eO).optional(),pinnedAt:Y().int().nonnegative().nullable().optional(),pinSortOrder:Y().int().nullable().optional(),unreadAt:C().min(1).nullable().optional(),iconKey:C().optional(),forkedFromSessionId:C().min(1).optional(),ephemeral:Te().optional(),ownerPersonaId:C().min(1).optional(),appBuilderProject:C().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),chatId:C().min(1).optional(),creatorPrincipalId:C().min(1).optional(),creatorDisplayName:C().min(1).optional(),creatorFeishuUnionId:C().min(1).optional(),originOwnerPrincipalId:C().min(1).optional(),originOwnerPersonaId:C().min(1).optional(),dispatchedFromSessionId:C().min(1).optional(),shiftFiredFromSessionId:C().min(1).optional(),createdAt:C().min(1),updatedAt:C().min(1)});const On={seq:Y().int().nonnegative().optional(),ts:C().optional(),uuid:C().optional()},tO=et(HL),nO=D({readCount:Y().int().nonnegative().optional(),searchCount:Y().int().nonnegative().optional(),bashCount:Y().int().nonnegative().optional(),editFileCount:Y().int().nonnegative().optional(),linesAdded:Y().int().nonnegative().optional(),linesRemoved:Y().int().nonnegative().optional(),otherToolCount:Y().int().nonnegative().optional()}),rO=D({oldStart:Y().int().nonnegative(),oldLines:Y().int().nonnegative(),newStart:Y().int().nonnegative(),newLines:Y().int().nonnegative(),lines:be(C())}),iO=D({agentId:C().optional(),agentType:C().optional(),status:C().optional(),prompt:C().optional(),filePath:C().optional(),structuredPatch:be(rO).optional(),stats:D({durationMs:Y().int().nonnegative().optional(),tokens:Y().int().nonnegative().optional(),toolUseCount:Y().int().nonnegative().optional(),toolStats:nO.optional(),usage:KL.optional()}).optional()}),sO=D({path:C(),content:C(),mtimeMs:Y().optional()}),oO=D({label:C().min(1),description:C().optional()}),yN=D({question:C().min(1),multiSelect:Te(),options:be(oO).min(1)});ai("kind",[D({...On,kind:ee("session_init"),toolSessionId:C().optional()}),D({...On,kind:ee("thinking"),text:C(),partialId:C().optional()}),D({...On,kind:ee("text"),text:C(),partialId:C().optional()}),D({...On,kind:ee("user_text"),text:C(),meta:tO.optional(),taskId:C().optional(),parentToolUseId:C().optional(),sender:VL.optional()}),D({...On,kind:ee("tool_call"),toolUseId:C(),tool:C(),toolKind:C().optional(),input:_a()}),D({...On,kind:ee("tool_result"),toolUseId:C(),output:_a().optional(),error:C().optional(),toolResultExtra:iO.optional(),sourceToolAssistantUUID:C().optional(),askQuestionAnswers:nu(C(),C()).optional()}),D({...On,kind:ee("attachment_memories"),memories:be(sO)}),D({...On,kind:ee("permission_request"),requestId:C(),tool:C(),input:_a(),toolUseId:C().optional()}),D({...On,kind:ee("ask_user_question"),toolUseId:C(),questions:be(yN)}),D({...On,kind:ee("turn_end")}),D({...On,kind:ee("subagent_progress"),toolUseId:C(),agentId:C(),status:et(["started","running","completed","failed"]),description:C().optional(),lastToolName:C().optional(),prompt:C().optional(),stats:D({durationMs:Y().int().nonnegative().optional(),tokens:Y().int().nonnegative().optional(),toolUseCount:Y().int().nonnegative().optional()}).optional()}),D({...On,kind:ee("error"),message:C()}),D({...On,kind:ee("meta_update"),patch:XL}),D({...On,kind:ee("meta-text"),text:C(),metaSource:et(["cc","owner"]).optional()})]);D({cwd:C().min(1).optional(),tool:C().optional(),label:C().optional(),model:C().optional(),permissionMode:C().optional(),effort:C().optional(),iconKey:C().optional(),forkedFromSessionId:C().min(1).optional(),ephemeral:Te().optional(),ownerPersonaId:C().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null,{message:"cwd 与 ownerPersonaId 至少传一个"});D({originOnly:Te().optional(),ownerPersonaId:C().min(1).optional(),limit:Y().int().positive().optional(),offset:Y().int().nonnegative().optional()});D({sessionId:C().min(1)});D({sessionId:C().min(1),patch:D({label:C().optional(),model:C().optional(),permissionMode:C().optional(),effort:C().optional(),cwd:C().optional(),iconKey:C().optional(),ephemeral:ee(!1).optional()})});D({sessionId:C().min(1),text:C()});D({sessionId:C().min(1),userMessageId:C().min(1),dryRun:Te().optional()});D({canRewind:Te(),error:C().optional(),filesChanged:be(C()).optional(),insertions:Y().int().nonnegative().optional(),deletions:Y().int().nonnegative().optional()});D({sessionId:C().min(1),userMessageId:C().min(1)});const aO=D({oldStart:Y().int().nonnegative(),oldLines:Y().int().nonnegative(),newStart:Y().int().nonnegative(),newLines:Y().int().nonnegative(),lines:be(C())}),lO=D({filePath:C().min(1),hunks:be(aO),insertions:Y().int().nonnegative(),deletions:Y().int().nonnegative(),status:et(["modified","added","deleted"]).optional()});D({canRewind:Te(),error:C().optional(),files:be(lO),totalInsertions:Y().int().nonnegative(),totalDeletions:Y().int().nonnegative()});D({userMessageIds:be(C())});D({sessionId:C().min(1),toolSessionId:C().min(1)});D({cwd:C().min(1),toolSessionId:C().min(1),messageUuid:C().min(1)});D({forkedToolSessionId:C().min(1),forkedFilePath:C().min(1)});D({sessionId:C().min(1),toolSessionId:C().min(1),jsonlPath:C().optional()});D({sessionId:C().min(1),afterSeq:Y().int().min(-1)});D({sessionId:C().min(1),permissionRequestId:C().min(1),allow:Te(),permanent:Te().optional(),pattern:C().optional()});D({projectPath:C().min(1)});D({sessionId:C().min(1),limit:Y().int().positive().max(5e3).optional(),offset:Y().int().nonnegative().optional(),slim:Te().optional()});D({cwd:C().min(1),toolSessionId:C().min(1)});D({cwd:C().min(1),toolSessionId:C().min(1),subagentId:C().min(1)});D({cwd:C().min(1).optional(),path:C().optional(),showHidden:Te().optional()});D({cwd:C().min(1),path:C().min(1)});D({cwd:C().min(1),tool:C().optional()});D({name:C().min(1),source:et(UL),path:C().optional(),description:C().optional(),plugin:C().optional()});const cO=D({name:C().min(1),source:et(WL),path:C().optional(),description:C().optional(),whenToUse:C().optional(),plugin:C().optional()});D({cwd:C().min(1),tool:C().optional()});D({agents:be(cO)});D({sessionId:C().optional()});D({sessionId:C().min(1).optional()});D({sessionId:C().min(1),pinned:Te()});D({type:ee("peerSession:upsert:ok")});D({sessionId:C().min(1)});D({type:ee("peerSession:remove:ok")});D({orderedIds:be(C().min(1)).min(1)});D({cwd:C().min(1)});D({isGitRoot:Te(),gitRoot:C().nullable()});D({cwd:C().min(1)});D({branch:C().nullable()});D({cwd:C().min(1)});D({branches:be(C()),head:C().nullable()});D({}).optional();const uO=D({cwd:C().min(1),updatedAt:C().min(1)});D({dirs:be(uO)});D({type:ee("session:question"),sessionId:C().min(1),toolUseId:C().min(1),requestId:C().min(1),questions:be(yN).min(1)});D({type:ee("session:question:cleared"),sessionId:C().min(1),toolUseId:C().min(1),answers:nu(C(),C()).optional()});D({sessionId:C().min(1),toolUseId:C().min(1),answers:nu(C(),C())});D({ok:ee(!0)});D({sessionId:C().min(1),toolUseId:C().min(1)});D({ok:ee(!0)});D({type:ee("auth"),token:C().min(1),scheme:ee("bearer").optional(),clientInfo:D({name:C().min(1),version:C().min(1),instanceId:C().min(1)}).optional()});D({type:ee("auth:ok"),version:C().min(1).optional(),protocolVersion:Y().int().nonnegative().optional()});D({type:ee("tunnel:ready"),url:C().min(1),subdomain:C().min(1)});D({type:ee("tunnel:exited"),code:Y().int().nullable(),subdomain:C().nullable(),url:C().nullable()});D({type:ee("tunnel:unavailable"),reason:C().min(1),failedAt:C().min(1)});const dO=D({sessionId:C().min(1),status:qL,freshSpawn:Te(),pendingPermissionRequestIds:be(C().min(1)),pendingQuestionToolUseIds:be(C().min(1))});D({type:ee("info"),version:C(),protocolVersion:Y(),hostname:C(),os:C(),tools:be(D({id:C(),available:Te()})),runningSessions:be(dO),tokenRole:et(bL).optional(),isLoopback:Te().optional(),httpBaseUrl:C().optional(),httpToken:C().optional()});const hO=6173,fO=6272,Xa=/^[a-z][a-z0-9-]{0,39}$/,iu=D({name:C().regex(Xa,{message:"kebab-case, 小写字母开头,只允许小写字母 / 数字 / -,最长 40 字符"}),port:Y().int().min(hO).max(fO),createdAt:C().datetime(),devCommand:C().min(1),prodUrl:C().url().optional(),readyPattern:C().optional(),publishJob:D({jobId:C().min(1),stage:et(["build","deploy","verify"]),startedAt:Y().int().nonnegative()}).optional()}),pO=["install-pending","installing","starting-dev-server","running","stopped","failed"],bN=et(pO),W_=iu.extend({isRunning:Te(),boundSessionId:C().nullable(),stage:bN.optional(),stageReason:C().optional(),publishJob:D({jobId:C().min(1),stage:et(["build","deploy","verify"]),startedAt:Y().int().nonnegative(),status:et(["in-flight","interrupted"])}).optional()});D({}).strict();D({projects:be(W_)}).strict();D({sessionId:C().min(1)}).strict();D({project:W_.nullable()}).strict();D({sessionId:C().min(1),name:C().min(1)}).strict();D({project:iu}).strict();D({name:C()}).strict();D({}).strict();D({name:C(),newPort:Y().int()}).strict();D({project:iu}).strict();D({name:C().regex(Xa),url:C().url()}).strict();D({project:iu}).strict();D({sessionId:C().min(1),force:Te().optional()}).strict();D({project:iu}).strict();const mO=["installing","failed"];D({sessionId:C().min(1),stage:et(mO),reason:C().optional()}).strict();D({ok:ee(!0)}).strict();D({sessionId:C().min(1)}).strict();D({ok:ee(!0)}).strict();D({type:ee("appBuilder:project-updated"),project:W_,stage:bN,stageReason:C().optional()}).strict();D({name:C().regex(Xa)});D({jobId:C().min(1),status:et(["started","already-publishing"])}).strict();D({name:C().regex(Xa)});D({ok:ee(!0)}).strict();D({type:ee("appBuilder:publish-progress"),name:C().regex(Xa),jobId:C().min(1),stage:et(["build","deploy","verify"]),status:et(["started","completed"])}).strict();D({type:ee("appBuilder:publish-failed"),name:C().regex(Xa),jobId:C().min(1),stage:et(["build","deploy","verify","unknown"]),errorSummary:C()}).strict();D({});const gO=["allowed","conditional","denied"],vO=et(gO),_O=D({name:C().min(1),status:vO,description:C().min(1),args:be(D({name:C(),required:Te()})).nullable(),reason:C().optional()});D({type:ee("meta:methods"),methods:be(_O)});const Cb=1,xO=["daemon","main","renderer"],yO=et(xO),bO=["debug","info","warn","error"],wO=et(bO);D({ts:Y().int(),source:yO,level:wO,msg:C(),ownerPrincipalId:C(),deviceId:C(),appVersion:C(),daemonVersion:C().optional(),os:C(),meta_json:C().optional(),sessionId:C().optional()});D({v:ee(1),visitorId:C().min(1),displayName:C(),provider:C(),iat:Y(),exp:Y()});const SO=D({visitorId:C(),displayName:C(),avatarUrl:C().optional(),provider:C(),firstSeen:Y(),lastSeen:Y()});D({visitors:be(SO)});const kO=new Set(["localhost","127.0.0.1","0.0.0.0","::1"]);let pi=null;function CO(){if(pi!==null)return pi;if(typeof window>"u")return pi=!1,!1;if(kO.has(window.location.hostname)||window.location.protocol==="file:")return pi=!0,!0;if(new URLSearchParams(window.location.search).get("debug")==="1"){pi=!0;try{sessionStorage.setItem("debug","1")}catch{}}else try{pi=sessionStorage.getItem("debug")==="1"}catch{pi=!1}return pi}function Ae(e,...t){CO()&&console.log(`[${e}][${new Date().toISOString()}]`,...t)}function Gu(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}const EO=e=>{const t=[1e3,2e3,4e3,8e3,16e3,3e4];return t[Math.min(e,t.length-1)]},NO=new Set(["auth:ok","pong","error"]),Eb=new Set(gN.filter(e=>!NO.has(e)));let TO=0;const Nb=()=>`r${++TO}`;function PO(e){let t=e.url,n=e.authToken,r=e.selfIdentity;const i=e.clientInfo,s=e.requestTimeoutMs??3e4,o=e.pingIntervalMs??3e4,a=e.watchdogMs??6e4,l=e.authTimeoutMs??1e4,c=e.backoffMs??EO;let u=null,d=!1,f=0,p=null,m=null,v=null,y=null,_=!1,x="disconnected";const b=new Map,w=new Map;let S=null;const k=(B,E)=>{var H;B==="ready"&&(S=E),(H=w.get(B))==null||H.forEach(q=>{try{q(E)}catch{}})},T=B=>{x!==B&&(x=B,k("status",B))},N=(B,E)=>{const H=w.get(B)??new Set;if(H.add(E),w.set(B,H),B==="ready"&&S!==null)try{E(S)}catch{}return()=>H.delete(E)},L=()=>{m&&(clearInterval(m),m=null),v&&(clearTimeout(v),v=null),y&&(clearTimeout(y),y=null)},P=()=>{v&&clearTimeout(v),v=setTimeout(()=>{try{u==null||u.close(4e3,"pong watchdog")}catch{}},a)},O=()=>{m&&clearInterval(m),m=setInterval(()=>{(u==null?void 0:u.readyState)===1&&u.send(JSON.stringify({type:"ping",requestId:Nb()}))},o),P()},I=B=>{for(const[,E]of b)clearTimeout(E.timer),E.reject(new Error(B));b.clear()},R=[],j=()=>{if(R.length===0)return;const B=R.splice(0);for(const E of B)(u==null?void 0:u.readyState)===1&&!_?E.doSend():(clearTimeout(E.timer),E.reject(new Error("NOT_CONNECTED")))},z=B=>{if(R.length===0)return;const E=R.splice(0);for(const H of E)clearTimeout(H.timer),H.reject(new Error(B))},$=()=>{if(d)return;const B=c(f);B<0||(k("daemon:reconnecting",{attempt:f+1,nextDelayMs:B,scheduledAt:Date.now()}),p&&clearTimeout(p),p=setTimeout(()=>{f+=1,A()},B))},F=B=>{P();const E=String(B.type??"");if(E==="auth:ok"){Ae("daemon-client","auth:ok received → connected",{url:t}),y&&(clearTimeout(y),y=null),_=!1,f=0,T("connected"),k("daemon:connected",{url:t}),O(),j();return}if(E==="pong")return;if(E==="ready"){const q=Number(B.protocolVersion??-1);q!==Cb&&k("daemon:version-mismatch",{daemonProtocol:q,supportedProtocol:Cb}),k("ready",B);return}const H=B.requestId;if(typeof H=="string"&&b.has(H)){const q=b.get(H);if(b.delete(H),clearTimeout(q.timer),E==="error"){const M=String(B.code??"ERR"),re=String(B.message??"unknown");q.reject(new Error(`${M}: ${re}`))}else Eb.has(E)&&k(E,B),q.resolve(B);return}Eb.has(E)&&k(E,B)},A=()=>{p&&(clearTimeout(p),p=null),Ae("daemon-client","connect →",{url:t,token:Gu(n),attempt:f}),T("connecting");let B;try{B=new WebSocket(t)}catch(E){T("disconnected"),k("daemon:disconnected",{reason:(E==null?void 0:E.message)??"ws constructor failed"}),$();return}u=B,_=!!n,B.onopen=()=>{if(B!==u){Ae("daemon-client","onopen → stale (replaced before opened), ignore");return}if(n){Ae("daemon-client","onopen → send auth frame",{token:Gu(n)});const E={type:"auth",token:n};r!=null&&r.principalId&&(E.selfPrincipalId=r.principalId),r!=null&&r.displayName&&(E.selfDisplayName=r.displayName),i&&(E.clientInfo=i),B.send(JSON.stringify(E)),y=setTimeout(()=>{try{B.close(4001,"auth handshake timeout")}catch{}},l)}else Ae("daemon-client","onopen → no token, treat as connected (daemon authMode=none)"),f=0,T("connected"),k("daemon:connected",{url:t}),O(),j()},B.onclose=E=>{if(B!==u){Ae("daemon-client","onclose → stale, ignore",{code:E.code,reason:E.reason});return}const H=E.reason||(E.code===1008?"auth failed":`close ${E.code}`);if(Ae("daemon-client","onclose →",{code:E.code,reason:H,awaitingAuth:_,manualStop:d}),L(),I(`connection closed: ${H}`),u=null,E.code===4401?T("revoked"):T("disconnected"),k("daemon:disconnected",{reason:H}),E.code===1008||E.code===4401){z(`connection closed: ${H}`);return}d?z(`connection closed: ${H}`):$()},B.onerror=()=>{},B.onmessage=E=>{if(B!==u)return;let H;try{H=JSON.parse(String(E.data))}catch{return}F(H)}};return{start(){d=!1,f=0,A()},stop(){d=!0,p&&(clearTimeout(p),p=null),L();try{u==null||u.close(1e3,"shutdown")}catch{}u=null,I("shutdown"),z("shutdown"),T("disconnected")},switchProfile(B){Ae("daemon-client","switchProfile →",{url:B.url,token:Gu(B.authToken)},"prev:",{url:t,token:Gu(n)}),t=B.url,n=B.authToken,B.selfIdentity!==void 0&&(r=B.selfIdentity),f=0,d=!0,p&&(clearTimeout(p),p=null),L(),I("switch profile"),z("switch profile");try{u==null||u.close(1e3,"switch profile")}catch{}u=null,d=!1,A()},request(B,E){return new Promise((H,q)=>{const M=Nb(),re=setTimeout(()=>{b.delete(M);const V=R.findIndex(pe=>pe.timer===re);V>=0&&R.splice(V,1),q(new Error(`request timeout: ${B}`))},s),oe=()=>{b.set(M,{resolve:V=>H(V),reject:q,timer:re}),u.send(JSON.stringify({...E,type:B,requestId:M}))};(u==null?void 0:u.readyState)===1&&!_?oe():d||u==null&&p==null?(clearTimeout(re),q(new Error("NOT_CONNECTED"))):R.push({doSend:oe,reject:q,timer:re})})},on:N,get isOpen(){return(u==null?void 0:u.readyState)===1&&!_},get url(){return t},getStatus(){return x}}}function IO(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}function RO(e){return e?{id:e.id,mode:e.mode,url:e.url,token:IO(e.token),name:e.name}:null}function Xu(e){return e?Array.isArray(e)?e.map(RO):{_notArray:typeof e,_value:e}:null}function Tb(e){return e==null?null:typeof e=="object"&&"value"in e?e.value:e}const MO="ws://127.0.0.1:18790",Pb="daemon:profiles",Ib="daemon:active-profile-id";function AO(){return Math.random().toString(36).slice(2,10)}function jO(e){const t=e.trim(),n=t.indexOf("#");if(n<0)return{url:t};const r=t.slice(0,n),i=new URLSearchParams(t.slice(n+1)).get("token")??void 0;return{url:r,token:i}}function DO(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.name=="string"&&(t.mode==="localhost"||t.mode==="remote")&&typeof t.url=="string"&&(t.token===void 0||typeof t.token=="string")}function wN(e){let t={profiles:[],activeId:null},n=!1,r=null;const i=new Set,s=()=>{for(const l of i)l(t)},o=async()=>{Ae("profile-store","persist →",Xu(t.profiles),"active:",t.activeId),await e.kv.set(Pb,t.profiles),await e.kv.set(Ib,t.activeId)},a=async()=>{if(!n){if(r){await r;return}r=(async()=>{var l;try{let c=null;try{const d=await e.kv.get(Pb);c=Tb(d)}catch{c=null}let u=null;try{const d=await e.kv.get(Ib);u=Tb(d)??null}catch{u=null}if(Ae("profile-store","ensureLoaded read kv →","profiles:",Xu(c),"activeId:",u),Array.isArray(c)&&c.length>0){const d=c.filter(DO),f=u&&d.some(p=>p.id===u)?u:((l=d[0])==null?void 0:l.id)??null;t={profiles:d,activeId:f},n=!0,Ae("profile-store","ensureLoaded → use kv profiles",Xu(d),"active:",f);return}t={profiles:[{id:"default",name:"本机",mode:"localhost",url:MO}],activeId:"default"},Ae("profile-store","ensureLoaded → fallback synthesized default (NO token)",Xu(t.profiles)),n=!0,await o()}finally{r=null}})(),await r}};return{async load(){return await a(),s(),t},async snapshot(){return await a(),t},async upsert(l){var y;await a();let c=l.url,u=l.token;if(c&&c.includes("#")){const _=jO(c);c=_.url,!u&&_.token&&(u=_.token)}const d=l.id?t.profiles.find(_=>_.id===l.id):void 0,f=u!=null&&u.trim()?u.trim():d==null?void 0:d.token;if(l.mode==="remote"&&!f)throw new Error("remote mode requires token");const p=l.id??AO(),m={id:p,name:((y=l.name)==null?void 0:y.trim())||(d==null?void 0:d.name)||(l.mode==="remote"?"远程":"本机"),mode:l.mode,url:c.trim(),token:f};return t={profiles:[...t.profiles.filter(_=>_.id!==p),m],activeId:p},await o(),s(),m},async delete(l){var d;await a();const c=t.profiles.filter(f=>f.id!==l);let u=t.activeId;u===l&&(u=((d=c[0])==null?void 0:d.id)??null),t={profiles:c,activeId:u},await o(),s()},async activate(l){await a(),t.profiles.some(c=>c.id===l)&&(t={...t,activeId:l},await o(),s())},subscribe(l){return i.add(l),()=>i.delete(l)},getActive(){return n?t.profiles.find(l=>l.id===t.activeId)??null:null}}}const Rb="clawd.client-instance-id";let LO={name:"clawd-web",version:"unknown"};function OO(){let e=null;try{e=localStorage.getItem(Rb),e||(e=crypto.randomUUID(),localStorage.setItem(Rb,e))}catch{e=e??crypto.randomUUID()}return{...LO,instanceId:e}}function Mb(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}const SN=g.createContext(null);function BO({host:e,children:t}){const[n,r]=g.useState(null),i=g.useMemo(()=>async()=>{const s=wN(e),o=await s.load(),a=o.profiles.find(c=>c.id===o.activeId)??o.profiles[0];if(!a)throw new Error("DaemonProvider: profile store has no profiles after load");return Ae("daemon-context","bootstrap → createDaemonClient",{id:a.id,url:a.url,token:Mb(a.token)}),{client:PO({url:a.url,authToken:a.token,clientInfo:OO()}),store:s}},[e]);return g.useEffect(()=>{let s=!0,o=null,a=null;return i().then(l=>{s&&(l.client.start(),o=l,r(l),a=l.store.subscribe(()=>{const c=l.store.getActive();if(!c){Ae("daemon-context","subscribe → no active profile, skip switchProfile");return}Ae("daemon-context","subscribe → switchProfile",{id:c.id,url:c.url,token:Mb(c.token)}),l.client.switchProfile({url:c.url,authToken:c.token})}))}),()=>{s=!1,a==null||a(),o==null||o.client.stop()}},[i]),n?h.jsx(SN.Provider,{value:n,children:t}):null}function Is(){const e=g.useContext(SN);if(!e)throw new Error("useDaemonClient must be used inside <DaemonProvider>");return e.client}function zO(){const e=Is(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i.mode,o=s==="tui"?"tui":"sdk";Ae("daemon-context","useDaemonMode ready.mode =",{rawMode:s,resolved:o}),n(o)}),[e]),t}const kN=g.createContext(null);function $O({cache:e,children:t}){return g.createElement(kN.Provider,{value:e},t)}function ko(){const e=g.useContext(kN);if(!e)throw new Error("useCache must be used inside <CacheProvider>");return e}function si(e){const t=ko(),n=g.useCallback(i=>t.observe(e,()=>i()),[t,e]),r=g.useCallback(()=>t.read(e),[t,e]);return g.useSyncExternalStore(n,r,r)}const CN={actionsLevel:"none",httpBaseUrl:null,httpToken:null},EN=g.createContext(CN);function Af(){return g.useContext(EN)}function FO(e){return e!=null&&e.httpBaseUrl?{actionsLevel:e.tokenRole==="owner"?"owner":"none",httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken??null}:CN}function HO(){const e=si("daemon-info");return g.useMemo(()=>FO(e),[e])}function UO({children:e}){const t=HO();return st.createElement(EN.Provider,{value:t},e)}function WO(e,t,n){if(!e.httpBaseUrl)return null;const r=encodeURIComponent(n);return`${e.httpBaseUrl}/session/${encodeURIComponent(t.sessionId)}/files?path=${r}`}function VO(e){const t=new Map;return{observe(n,r){let i=t.get(n);i||(i={data:void 0,hasData:!1,listeners:new Set},t.set(n,i));const s=l=>r(l);i.listeners.add(s);const o=i.listeners.size===1;s(i.hasData?i.data:void 0),o&&e.onFirstObserver(n);let a=!1;return()=>{if(a)return;a=!0;const l=t.get(n);l&&(l.listeners.delete(s),l.listeners.size===0&&(t.delete(n),e.onLastObserver(n)))}},read(n){const r=t.get(n);return r!=null&&r.hasData?r.data:void 0},setData(n,r){const i=t.get(n);if(!i)return;const s=i.hasData?i.data:void 0,o=r(s);i.data=o,i.hasData=!0;for(const a of i.listeners)a(o)}}}function qO(){const e=[],t=new Map,n=r=>{for(const i of e)if(i.pattern.test(r))return i.source;return null};return{register(r,i){e.push({pattern:r,source:i})},activate(r){if(t.has(r))return;const i=n(r);if(!i)throw new Error(`no source registered for key: ${r}`);t.set(r,i.start(r))},deactivate(r){const i=t.get(r);i&&(t.delete(r),i())}}}function KO(e){return{request:(t,n)=>e.request(t,n),onFrame(t){const n=[];for(const r of gN)n.push(e.on(r,i=>t(r,i)));return()=>{for(const r of n)r()}},onConnect(t){return e.on("daemon:connected",()=>t())},get isConnected(){return e.isOpen}}}function NN(e){const t=(e??"claude")==="claude";return{rewind:t,subagents:t,tui:t,observe:t,fileSharing:t,fork:t}}const GO=e=>({tool:e,models:[{id:"",label:"Default",contextWindowSize:2e5,default:!0}],permissionModes:[{id:"",label:"Default"}],configSchema:[],features:NN(e)});function XO(e,t){return{start(n){const r=n.replace(/^capabilities\//,"");let i=!1;const s=async()=>{try{const a=await e.request("capabilities:get",{tool:r});if(i)return;t(n,()=>a)}catch{if(i)return;t(n,()=>GO(r))}},o=e.onConnect(()=>{s()});return s(),()=>{i=!0,o()}}}}function YO(e,t){return{start(n){let r=!1;const i=async()=>{try{const a=await e.request("session:list",void 0);if(r)return;t(n,()=>a.sessions??[])}catch{}},s=e.onFrame((a,l)=>{if(a==="session:info"){const c=l;if(c.chatId!==void 0)return;t(n,u=>[c,...(u??[]).filter(d=>d.sessionId!==c.sessionId)])}else if(a==="session:deleted"){const c=l;t(n,u=>(u??[]).filter(d=>d.sessionId!==c.sessionId))}}),o=e.onConnect(()=>{i()});return i(),()=>{r=!0,s(),o()}}}}const Rc={sessionId:null,events:[],lastSeq:-1,pendingPermissions:[],status:"idle",pendingQuestions:{}};function Kp(e,t){const n=t;if(n.kind==="permission_request"&&typeof n.requestId=="string"){if(e.some(i=>i.requestId===n.requestId))return e;const r={requestId:n.requestId,tool:typeof n.tool=="string"?n.tool:"",input:n.input,...typeof n.toolUseId=="string"&&n.toolUseId?{toolUseId:n.toolUseId}:{}};return[...e,r]}if(n.kind==="tool_result"&&typeof n.toolUseId=="string"&&n.toolUseId){const r=e.findIndex(i=>i.toolUseId===n.toolUseId);if(r>=0)return e.filter((i,s)=>s!==r)}return e}function TN(e,t,n){const r=n===void 0?e.sessionId:n;switch(t.type){case"session:change":return{...Rc,sessionId:t.sessionId};case"session:event":{if(!r||t.sessionId!==r)return e;const i=typeof t.event.seq=="number"?t.event.seq:-1,s=[...e.events,t.event],o=i>e.lastSeq?i:e.lastSeq,a=Kp(e.pendingPermissions,t.event);return{...e,events:s,lastSeq:o,pendingPermissions:a}}case"session:status":return!r||t.sessionId!==r?e:{...e,status:t.status};case"session:events":{if(!r||t.sessionId!==r)return e;const i=t.events.map(o=>o.event),s=i.reduce((o,a)=>Kp(o,a),[]);return{...e,sessionId:t.sessionId,events:i,lastSeq:t.latestSeq,pendingPermissions:s}}case"session:events:append":{if(!r||t.sessionId!==r)return e;const i=new Set;for(const c of e.events){const u=c.seq;typeof u=="number"&&i.add(u)}const s=[];for(const c of t.events)typeof c.seq=="number"&&(i.has(c.seq)||s.push(c.event));const o=t.latestSeq>e.lastSeq?t.latestSeq:e.lastSeq;if(s.length===0)return o===e.lastSeq?e:{...e,lastSeq:o};const a=[...e.events,...s].sort((c,u)=>{const d=c.seq??-1,f=u.seq??-1;return d-f}),l=s.reduce((c,u)=>Kp(c,u),e.pendingPermissions);return{...e,events:a,lastSeq:o,pendingPermissions:l}}case"permission:request":{if(!r||t.sessionId!==r||e.pendingPermissions.some(s=>s.requestId===t.requestId))return e;const i={requestId:t.requestId,tool:t.tool,input:t.input,...t.toolUseId?{toolUseId:t.toolUseId}:{}};return{...e,pendingPermissions:[...e.pendingPermissions,i]}}case"permission:clear":{if(!r||r!==t.sessionId)return e;const i=t.requestId,s=e.pendingPermissions.findIndex(c=>c.requestId===i),o=s>=0?e.pendingPermissions.filter((c,u)=>u!==s):e.pendingPermissions;if(e.events.length===0)return o===e.pendingPermissions?e:{...e,pendingPermissions:o};const a=e.events.length-1,l=e.events[a];return l.kind==="permission_request"&&l.requestId===i?{...e,pendingPermissions:o,events:e.events.slice(0,a)}:o===e.pendingPermissions?e:{...e,pendingPermissions:o}}case"session:question":return!r||t.sessionId!==r?e:{...e,pendingQuestions:{...e.pendingQuestions,[t.toolUseId]:{toolUseId:t.toolUseId,requestId:t.requestId,questions:t.questions}}};case"session:question:clear":{if(!r||t.sessionId!==r||!(t.toolUseId in e.pendingQuestions))return e;const{[t.toolUseId]:i,...s}=e.pendingQuestions;return{...e,pendingQuestions:s}}case"session:question:submitted":{if(!r||t.sessionId!==r)return e;const i=e.pendingQuestions[t.toolUseId];return i?{...e,pendingQuestions:{...e.pendingQuestions,[t.toolUseId]:{...i,submittedAnswers:t.answers}}}:e}case"session:rewound":return!r||t.sessionId!==r?e:{...e,pendingPermissions:[],status:"idle"};case"ready":{if(!r)return e;const i=t.runningSessions.find(o=>o.sessionId===r);if(i!=null&&i.freshSpawn)return{...Rc,sessionId:r};const s=(i==null?void 0:i.status)??"idle";return s===e.status?e:{...e,status:s}}case"daemon:disconnected":return{...e,pendingPermissions:[]};default:return e}}const ZO="session/";function QO(e){return{sid:e.slice(ZO.length)}}const JO=new Set(vN);function PN(e){return JO.has(e)}function Ab(e){return PN(e)?e:"idle"}function eB(e,t){return{start(n){const{sid:r}=QO(n);let i=!1,s=-1;const o=f=>{t(n,p=>TN(p??Rc,f,r))},a=async f=>{const p=f==="baseline"?-1:s;try{const m=await e.request("session:events",{sessionId:r,afterSeq:p});if(i)return;const v=m.events??[],y=m.latestSeq??-1;if(f==="baseline")o({type:"session:events",sessionId:r,events:v,latestSeq:y}),s=y;else{const _=m.bufferStartSeq??0,x=y<p||_>p+1;o({type:x?"session:events":"session:events:append",sessionId:r,events:v,latestSeq:y}),s=Math.max(s,y)}}catch{}},l=async()=>{try{const f=await e.request("info");if(i)return;o({type:"ready",runningSessions:(f.runningSessions??[]).map(p=>({sessionId:p.sessionId,freshSpawn:p.freshSpawn,status:Ab(p.status)}))})}catch{}},c=async()=>{try{await e.request("session:subscribe",{sessionId:r})}catch{}i||(await a(s<0?"baseline":"delta"),!i&&await l())},u=e.onFrame((f,p)=>{if(!i)if(f==="session:event"){const m=p;if(m.sessionId!==r)return;const v=m.event.seq;Ae("session-events","push session:event",{sid:r,kind:m.event.kind,seq:v,lastSeqBefore:s}),o({type:"session:event",sessionId:m.sessionId,event:m.event}),typeof v=="number"&&v>s&&(s=v)}else if(f==="session:status"){const m=p;if(m.sessionId!==r)return;if(!PN(m.status)){Ae("session-events","push session:status drop",{sid:r,status:m.status});return}Ae("session-events","push session:status",{sid:r,status:m.status}),o({type:"session:status",sessionId:m.sessionId,status:m.status})}else if(f==="session:cleared"){if(p.sessionId!==r)return;Ae("session-events","push session:cleared",{sid:r}),o({type:"session:change",sessionId:r}),s=-1}else if(f==="permission:request"){const m=p;if(m.sessionId!==r)return;o({type:"permission:request",sessionId:m.sessionId,requestId:m.requestId,tool:m.tool,input:m.input,...typeof m.toolUseId=="string"&&m.toolUseId?{toolUseId:m.toolUseId}:{}})}else if(f==="session:question"){const m=p;if(m.sessionId!==r)return;o({type:"session:question",sessionId:m.sessionId,toolUseId:m.toolUseId,requestId:m.requestId,questions:m.questions})}else if(f==="session:question:cleared"){const m=p;if(m.sessionId!==r)return;m.answers&&Object.keys(m.answers).length>0?o({type:"session:question:submitted",sessionId:m.sessionId,toolUseId:m.toolUseId,answers:m.answers}):o({type:"session:question:clear",sessionId:m.sessionId,toolUseId:m.toolUseId})}else if(f==="session:rewound"){const m=p;if(m.sessionId!==r)return;o({type:"session:rewound",sessionId:m.sessionId,userMessageId:m.userMessageId})}else f==="ready"&&o({type:"ready",runningSessions:(p.runningSessions??[]).map(v=>({sessionId:v.sessionId,freshSpawn:v.freshSpawn,status:Ab(v.status)}))})}),d=e.onConnect(()=>{c()});return e.isConnected&&c(),()=>{i=!0,u(),d(),e.request("session:unsubscribe",{sessionId:r}).catch(()=>{})}}}}const tB=new Set(["tunnel:ready","tunnel:exited","tunnel:unavailable"]);function nB(e,t){return{start(n){let r=!1;const i=async()=>{try{const a=await e.request("info",void 0);if(r)return;t(n,()=>a)}catch{}},s=e.onConnect(()=>{i()}),o=e.onFrame(a=>{tB.has(a)&&i()});return i(),()=>{r=!0,s(),o()}}}}function rB(){return{start(){return()=>{}}}}function iB(e,t){return{start(n){let r=!1;const i=async()=>{try{const o=await e.request("persona:list",{});if(r)return;t(n,()=>o.personas??[])}catch{}},s=e.onConnect(()=>{i()});return i(),()=>{r=!0,s()}}}}function sB(e){const t=KO(e),n=qO();let r=null;const i=(o,a)=>{r==null||r.setData(o,a)};n.register(/^capabilities\//,XO(t,i)),n.register(/^sessions$/,YO(t,i)),n.register(/^session\//,eB(t,i)),n.register(/^personas$/,iB(t,i)),n.register(/^persona-detail\//,rB()),n.register(/^daemon-info$/,nB(t,i));const s=VO({onFirstObserver:o=>{o&&n.activate(o)},onLastObserver:o=>{o&&n.deactivate(o)}});return r=s,{cache:s,channel:t}}class V_{constructor(t){this.client=t}info(){return this.client.request("info")}attachmentSignUrl(t){return this.client.request("attachment.signUrl",t)}attachmentGroupAdd(t,n,r){return this.client.request("attachment.groupAdd",{sessionId:t,relPath:n,...r?{label:r}:{}})}attachmentGroupRemove(t,n){return this.client.request("attachment.groupRemove",{sessionId:t,relPath:n})}attachmentGroupList(t){return this.client.request("attachment.groupList",{sessionId:t})}sessionCreate(t){return this.client.request("session:create",t)}appBuilderListProjects(){return this.client.request("appBuilder:listProjects",{})}appBuilderGetProject(t){return this.client.request("appBuilder:getProject",{sessionId:t})}appBuilderUpdateProjectPort(t,n){return this.client.request("appBuilder:updateProjectPort",{name:t,newPort:n})}appBuilderStartDevServer(t,n){return this.client.request("appBuilder:startDevServer",{sessionId:t,...n!=null&&n.force?{force:!0}:{}})}appBuilderStopDevServer(t){return this.client.request("appBuilder:stopDevServer",{sessionId:t})}appBuilderPublish(t){return this.client.request("appBuilder:publish",{name:t})}appBuilderDismissPublishJob(t){return this.client.request("appBuilder:dismissPublishJob",{name:t})}sessionList(){return this.client.request("session:list")}sessionGet(t){return this.client.request("session:get",{sessionId:t})}sessionUpdate(t,n){return this.client.request("session:update",{sessionId:t,patch:n})}sessionDelete(t){return this.client.request("session:delete",{sessionId:t})}sessionSend(t,n){return this.client.request("session:send",{sessionId:t,text:n})}sessionStop(t){return this.client.request("session:stop",{sessionId:t})}sessionInterrupt(t){return this.client.request("session:interrupt",{sessionId:t})}sessionRewind(t){return this.client.request("session:rewind",t)}sessionRewindableMessageIds(t){return this.client.request("session:rewindable-message-ids",{sessionId:t})}sessionRewindDiff(t){return this.client.request("session:rewind-diff",t)}sessionNew(t){return this.client.request("session:new",{sessionId:t})}sessionFork(t){return this.client.request("session:fork",t)}sessionResume(t,n){return this.client.request("session:resume",{sessionId:t,toolSessionId:n})}sessionObserve(t){return this.client.request("session:observe",t)}sessionEvents(t,n){return this.client.request("session:events",{sessionId:t,afterSeq:n})}sessionSubscribe(t){return this.client.request("session:subscribe",{sessionId:t})}sessionUnsubscribe(t){return this.client.request("session:unsubscribe",{sessionId:t})}pinSession(t,n){return this.client.request("session:pin",{sessionId:t,pinned:n})}markSessionRead(t){return this.client.request("session:markRead",{sessionId:t})}reorderPins(t){return this.client.request("session:reorderPins",{orderedIds:t})}peerSessionUpsert(t){return this.client.request("peerSession:upsert",t)}peerSessionRemove(t){return this.client.request("peerSession:remove",{sessionId:t})}permissionRespond(t){return this.client.request("permission:respond",t)}answerQuestion(t){return this.client.request("session:answerQuestion",t)}cancelQuestion(t){return this.client.request("session:cancelQuestion",t)}historyProjects(){return this.client.request("history:projects")}historyList(t){return this.client.request("history:list",{projectPath:t})}historyRead(t){return this.client.request("history:read",t)}historySubagents(t){return this.client.request("history:subagents",t)}historySubagentRead(t){return this.client.request("history:subagent-read",t)}listRecentDirs(){return this.client.request("history:recentDirs",{})}getGitRoot(t){return this.client.request("git:root",{cwd:t})}getGitBranch(t){return this.client.request("git:branch",{cwd:t})}listGitBranches(t){return this.client.request("git:branches",{cwd:t})}personaCreate(t){return this.client.request("persona:create",t)}personaList(){return this.client.request("persona:list",{})}personaGet(t){return this.client.request("persona:get",{personaId:t})}personaUpdate(t,n){return this.client.request("persona:update",{personaId:t,patch:n})}personaDelete(t){return this.client.request("persona:delete",{personaId:t})}visitorList(){return this.client.request("visitor:list",{})}workspaceList(t={}){return this.client.request("workspace:list",t)}workspaceRead(t){return this.client.request("workspace:read",t)}skillsList(t,n){return this.client.request("skills:list",{cwd:t,...n?{tool:n}:{}})}agentsList(t,n){return this.client.request("agents:list",{cwd:t,...n?{tool:n}:{}})}capabilitiesGet(t="claude"){return this.client.request("capabilities:get",{tool:t})}shiftList(){return this.client.request("shift:list")}}function oB(e){const[t,n]=g.useState(e.isOpen?{kind:"connected",url:""}:{kind:"connecting"});return g.useEffect(()=>{const r=e.on("ready",l=>{const c=l;n(u=>({kind:"connected",url:u.kind==="connected"?u.url:"",mode:u.kind==="connected"?u.mode:void 0,daemonVersion:c.version,protocolVersion:c.protocolVersion}))}),i=e.on("daemon:connected",l=>{const c=l;n(u=>({kind:"connected",url:c.url,mode:c.mode,daemonVersion:u.kind==="connected"?u.daemonVersion:void 0,protocolVersion:u.kind==="connected"?u.protocolVersion:void 0}))}),s=e.on("daemon:disconnected",l=>{const c=(l==null?void 0:l.reason)??"";/auth failed|auth timeout|auth required|auth handshake timeout/i.test(c)?n({kind:"auth-failed",reason:c}):n({kind:"disconnected",reason:c})}),o=e.on("daemon:reconnecting",l=>{const c=l;n({kind:"reconnecting",attempt:c.attempt,nextDelayMs:c.nextDelayMs,scheduledAt:c.scheduledAt??Date.now()})}),a=e.on("daemon:version-mismatch",l=>{const c=l;n({kind:"version-mismatch",daemonProtocol:c.daemonProtocol,supportedProtocol:c.supportedProtocol})});return()=>{r(),i(),s(),o(),a()}},[e]),t}function aB(e){const t=ko(),n=si(e.kind==="connected"?"sessions":""),r=g.useCallback(async()=>{t.setData("sessions",i=>i??[])},[t]);return{sessions:n??[],loading:!1,loaded:n!==void 0,error:null,refresh:r}}function Ya(){const e=Is();return g.useMemo(()=>new V_(e),[e])}function IN(e){return{personaId:e.personaId,label:e.label,model:e.model,tool:e.tool,iconKey:e.iconKey,public:e.public,createdAt:e.createdAt,updatedAt:e.updatedAt}}function RN(){const e=ko(),t=Ya(),n=si("personas")??[],r=g.useMemo(()=>n.map(s=>IN(s)),[n]),i=g.useCallback(async()=>{const s=await t.personaList();e.setData("personas",()=>s.personas??[])},[t,e]);return{personas:r,raw:n,loaded:si("personas")!==void 0,refresh:i}}function MN(e){const{raw:t}=RN(),n=ko(),r=Ya(),i=e?t.find(a=>a.personaId===e)??null:null,s=i?IN(i):null,o=g.useCallback(async()=>{if(!e)return;const a=await r.personaList();n.setData("personas",()=>a.personas??[])},[e,r,n]);return{persona:s,raw:i,loaded:!!s,refresh:o}}function lB(e){const t=Ya(),n=ko(),r=e?`persona-detail/${e}`:"",i=si(r),s=g.useCallback(async()=>{const o={personality:"",skills:[],plugins:[],sandboxSettings:null};if(!e)return o;const a=await t.personaGet(e);let l;if("persona"in a&&a.persona===null)l=o;else{const c=a;l={personality:c.personality??"",skills:c.skills??[],plugins:c.plugins??[],sandboxSettings:c.sandboxSettings??null}}return n.setData(r,()=>l),l},[t,n,e,r]);return g.useEffect(()=>{e&&s()},[e,s]),{personality:(i==null?void 0:i.personality)??"",skills:(i==null?void 0:i.skills)??[],plugins:(i==null?void 0:i.plugins)??[],sandboxSettings:(i==null?void 0:i.sandboxSettings)??null,loaded:i!==void 0,refresh:s}}function AN(){const e=ko(),t=Ya();return g.useCallback(async()=>{const n=await t.personaList();e.setData("personas",()=>n.personas??[])},[e,t])}function cB(){const e=Ya(),t=AN();return g.useCallback(async(n,r)=>{const i=await e.personaUpdate(n,r);return await t(),i},[e,t])}function uB(){const e=Ya(),t=AN();return g.useCallback(async n=>{await e.personaDelete(n),await t()},[e,t])}const jb="clawd:sidebar:tree-collapsed";function dB(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function hB(e){const t=dB(e);if(!Array.isArray(t))return new Set;const n=new Set;for(const r of t)typeof r=="string"&&n.add(r);return n}function fB(){const e=P_(),[t,n]=g.useState(()=>new Set),r=g.useRef(t);r.current=t,g.useEffect(()=>{let l=!1;return(async()=>{try{const c=await e.kv.get(jb);if(l)return;n(hB(c))}catch{}})(),()=>{l=!0}},[e]);const i=g.useCallback(l=>{e.kv.set(jb,[...l]).catch(()=>{})},[e]),s=g.useCallback(l=>r.current.has(l),[]),o=g.useCallback(l=>{n(c=>{const u=new Set(c);return u.has(l)?u.delete(l):u.add(l),i(u),u})},[i]),a=g.useCallback(l=>{n(c=>{let u=!1;const d=new Set;for(const f of c)l.has(f)?d.add(f):u=!0;return u?(i(d),d):c})},[i]);return{isCollapsed:s,toggle:o,prune:a}}const q_=g.createContext(null);function pB(){const e=g.useContext(q_);if(!e)throw new Error("SessionTreeCollapsedContext.Provider missing — wrap SessionTreeNode tree with <SessionTreeCollapsedContext.Provider value={useSessionTreeCollapsed()}>");return e}/**
95
+ `,boxShadowTabsOverflowLeft:"inset 10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowRight:"inset -10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowTop:"inset 0 10px 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowBottom:"inset 0 -10px 8px -8px rgba(0, 0, 0, 0.08)"}),r)}var ob=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const a4={lineHeight:!0,lineHeightSM:!0,lineHeightLG:!0,lineHeightHeading1:!0,lineHeightHeading2:!0,lineHeightHeading3:!0,lineHeightHeading4:!0,lineHeightHeading5:!0,opacityLoading:!0,fontWeightStrong:!0,zIndexPopupBase:!0,zIndexBase:!0,opacityImage:!0},l4={motionBase:!0,motionUnit:!0},c4={screenXS:!0,screenXSMin:!0,screenXSMax:!0,screenSM:!0,screenSMMin:!0,screenSMMax:!0,screenMD:!0,screenMDMin:!0,screenMDMax:!0,screenLG:!0,screenLGMin:!0,screenLGMax:!0,screenXL:!0,screenXLMin:!0,screenXLMax:!0,screenXXL:!0,screenXXLMin:!0},GE=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:i}=t,s=ob(t,["override"]);let o=Object.assign(Object.assign({},r),{override:i});return o=KE(o),s&&Object.entries(s).forEach(([a,l])=>{const{theme:c}=l,u=ob(l,["theme"]);let d=u;c&&(d=GE(Object.assign(Object.assign({},o),u),{override:u},c)),o[a]=d}),o};function XE(){const{token:e,hashed:t,theme:n,override:r,cssVar:i}=st.useContext(VE),s=`${s4}-${t||""}`,o=n||WE,[a,l,c]=X3(o,[Nc,e],{salt:s,override:r,getComputedToken:GE,formatToken:KE,cssVar:i&&{prefix:i.prefix,key:i.key,unitless:a4,ignore:l4,preserve:c4}});return[o,c,t?l:"",a,i]}const u4=()=>({display:"inline-flex",alignItems:"center",color:"inherit",fontStyle:"normal",lineHeight:0,textAlign:"center",textTransform:"none",verticalAlign:"-0.125em",textRendering:"optimizeLegibility","-webkit-font-smoothing":"antialiased","-moz-osx-font-smoothing":"grayscale","> *":{lineHeight:1},svg:{display:"inline-block"}}),d4=e=>({[`.${e}`]:Object.assign(Object.assign({},u4()),{[`.${e} .${e}-icon`]:{display:"block"}})}),h4=(e,t)=>{const[n,r]=XE();return SD({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>d4(e))},f4=Object.assign({},Ha),{useId:ab}=f4,p4=()=>"",m4=typeof ab>"u"?p4:ab;function g4(e,t,n){var r;const i=e||{},s=i.inherit===!1||!t?Object.assign(Object.assign({},bh),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:bh.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=m4();return fE(()=>{var a,l;if(!e)return t;const c=Object.assign({},s.components);Object.keys(e.components||{}).forEach(f=>{c[f]=Object.assign(Object.assign({},c[f]),e.components[f])});const u=`css-var-${o.replace(/:/g,"")}`,d=((a=i.cssVar)!==null&&a!==void 0?a:s.cssVar)&&Object.assign(Object.assign(Object.assign({prefix:n==null?void 0:n.prefixCls},typeof s.cssVar=="object"?s.cssVar:{}),typeof i.cssVar=="object"?i.cssVar:{}),{key:typeof i.cssVar=="object"&&((l=i.cssVar)===null||l===void 0?void 0:l.key)||u});return Object.assign(Object.assign(Object.assign({},s),i),{token:Object.assign(Object.assign({},s.token),i.token),components:c,cssVar:d})},[i,s],(a,l)=>a.some((c,u)=>{const d=l[u];return!S3(c,d,!0)}))}var v4=["children"],YE=g.createContext({});function _4(e){var t=e.children,n=Fg(e,v4);return g.createElement(YE.Provider,{value:n},t)}var x4=function(e){mE(n,e);var t=vE(n);function n(){return Va(this,n),t.apply(this,arguments)}return qa(n,[{key:"render",value:function(){return this.props.children}}]),n}(g.Component);function y4(e){var t=g.useReducer(function(a){return a+1},0),n=Ze(t,2),r=n[1],i=g.useRef(e),s=cv(function(){return i.current}),o=cv(function(a){i.current=typeof a=="function"?a(i.current):a,r()});return[s,o]}var Qi="none",Uu="appear",Wu="enter",Vu="leave",lb="none",Tr="prepare",aa="start",la="active",z_="end",ZE="prepared";function cb(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit".concat(e)]="webkit".concat(t),n["Moz".concat(e)]="moz".concat(t),n["ms".concat(e)]="MS".concat(t),n["O".concat(e)]="o".concat(t.toLowerCase()),n}function b4(e,t){var n={animationend:cb("Animation","AnimationEnd"),transitionend:cb("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var w4=b4(Oi(),typeof window<"u"?window:{}),QE={};if(Oi()){var S4=document.createElement("div");QE=S4.style}var qu={};function JE(e){if(qu[e])return qu[e];var t=w4[e];if(t)for(var n=Object.keys(t),r=n.length,i=0;i<r;i+=1){var s=n[i];if(Object.prototype.hasOwnProperty.call(t,s)&&s in QE)return qu[e]=t[s],qu[e]}return""}var eN=JE("animationend"),tN=JE("transitionend"),nN=!!(eN&&tN),ub=eN||"animationend",db=tN||"transitionend";function hb(e,t){if(!e)return null;if(Ct(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const k4=function(e){var t=g.useRef();function n(i){i&&(i.removeEventListener(db,e),i.removeEventListener(ub,e))}function r(i){t.current&&t.current!==i&&n(t.current),i&&i!==t.current&&(i.addEventListener(db,e),i.addEventListener(ub,e),t.current=i)}return g.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var rN=Oi()?g.useLayoutEffect:g.useEffect;const C4=function(){var e=g.useRef(null);function t(){zg.cancel(e.current)}function n(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var s=zg(function(){i<=1?r({isCanceled:function(){return s!==e.current}}):n(r,i-1)});e.current=s}return g.useEffect(function(){return function(){t()}},[]),[n,t]};var E4=[Tr,aa,la,z_],N4=[Tr,ZE],iN=!1,T4=!0;function sN(e){return e===la||e===z_}const P4=function(e,t,n){var r=uv(lb),i=Ze(r,2),s=i[0],o=i[1],a=C4(),l=Ze(a,2),c=l[0],u=l[1];function d(){o(Tr,!0)}var f=t?N4:E4;return rN(function(){if(s!==lb&&s!==z_){var p=f.indexOf(s),m=f[p+1],v=n(s);v===iN?o(m,!0):m&&c(function(y){function _(){y.isCanceled()||o(m,!0)}v===!0?_():Promise.resolve(v).then(_)})}},[e,s]),g.useEffect(function(){return function(){u()}},[]),[d,s]};function I4(e,t,n,r){var i=r.motionEnter,s=i===void 0?!0:i,o=r.motionAppear,a=o===void 0?!0:o,l=r.motionLeave,c=l===void 0?!0:l,u=r.motionDeadline,d=r.motionLeaveImmediately,f=r.onAppearPrepare,p=r.onEnterPrepare,m=r.onLeavePrepare,v=r.onAppearStart,y=r.onEnterStart,_=r.onLeaveStart,x=r.onAppearActive,b=r.onEnterActive,w=r.onLeaveActive,S=r.onAppearEnd,k=r.onEnterEnd,T=r.onLeaveEnd,N=r.onVisibleChanged,L=uv(),P=Ze(L,2),O=P[0],I=P[1],R=y4(Qi),j=Ze(R,2),z=j[0],$=j[1],F=uv(null),A=Ze(F,2),B=A[0],E=A[1],H=z(),q=g.useRef(!1),M=g.useRef(null);function re(){return n()}var oe=g.useRef(!1);function V(){$(Qi),E(null,!0)}var pe=cv(function(Ue){var nt=z();if(nt!==Qi){var mt=re();if(!(Ue&&!Ue.deadline&&Ue.target!==mt)){var Xt=oe.current,pn;nt===Uu&&Xt?pn=S==null?void 0:S(mt,Ue):nt===Wu&&Xt?pn=k==null?void 0:k(mt,Ue):nt===Vu&&Xt&&(pn=T==null?void 0:T(mt,Ue)),Xt&&pn!==!1&&V()}}}),Oe=k4(pe),ie=Ze(Oe,1),Me=ie[0],Fe=function(nt){switch(nt){case Uu:return we(we(we({},Tr,f),aa,v),la,x);case Wu:return we(we(we({},Tr,p),aa,y),la,b);case Vu:return we(we(we({},Tr,m),aa,_),la,w);default:return{}}},We=g.useMemo(function(){return Fe(H)},[H]),ge=P4(H,!e,function(Ue){if(Ue===Tr){var nt=We[Tr];return nt?nt(re()):iN}if(wt in We){var mt;E(((mt=We[wt])===null||mt===void 0?void 0:mt.call(We,re(),null))||null)}return wt===la&&H!==Qi&&(Me(re()),u>0&&(clearTimeout(M.current),M.current=setTimeout(function(){pe({deadline:!0})},u))),wt===ZE&&V(),T4}),qe=Ze(ge,2),Gt=qe[0],wt=qe[1],Rt=sN(wt);oe.current=Rt;var ln=g.useRef(null);rN(function(){if(!(q.current&&ln.current===t)){I(t);var Ue=q.current;q.current=!0;var nt;!Ue&&t&&a&&(nt=Uu),Ue&&t&&s&&(nt=Wu),(Ue&&!t&&c||!Ue&&d&&!t&&c)&&(nt=Vu);var mt=Fe(nt);nt&&(e||mt[Tr])?($(nt),Gt()):$(Qi),ln.current=t}},[t]),g.useEffect(function(){(H===Uu&&!a||H===Wu&&!s||H===Vu&&!c)&&$(Qi)},[a,s,c]),g.useEffect(function(){return function(){q.current=!1,clearTimeout(M.current)}},[]);var Bt=g.useRef(!1);g.useEffect(function(){O&&(Bt.current=!0),O!==void 0&&H===Qi&&((Bt.current||O)&&(N==null||N(O)),Bt.current=!0)},[O,H]);var at=B;return We[Tr]&&wt===aa&&(at=Be({transition:"none"},at)),[H,wt,at,O??t]}function R4(e){var t=e;Ct(e)==="object"&&(t=e.transitionSupport);function n(i,s){return!!(i.motionName&&t&&s!==!1)}var r=g.forwardRef(function(i,s){var o=i.visible,a=o===void 0?!0:o,l=i.removeOnLeave,c=l===void 0?!0:l,u=i.forceRender,d=i.children,f=i.motionName,p=i.leavedClassName,m=i.eventProps,v=g.useContext(YE),y=v.motion,_=n(i,y),x=g.useRef(),b=g.useRef();function w(){try{return x.current instanceof HTMLElement?x.current:o3(b.current)}catch{return null}}var S=I4(_,a,w,i),k=Ze(S,4),T=k[0],N=k[1],L=k[2],P=k[3],O=g.useRef(P);P&&(O.current=!0);var I=g.useCallback(function(A){x.current=A,u3(s,A)},[s]),R,j=Be(Be({},m),{},{visible:a});if(!d)R=null;else if(T===Qi)P?R=d(Be({},j),I):!c&&O.current&&p?R=d(Be(Be({},j),{},{className:p}),I):u||!c&&!p?R=d(Be(Be({},j),{},{style:{display:"none"}}),I):R=null;else{var z;N===Tr?z="prepare":sN(N)?z="active":N===aa&&(z="start");var $=hb(f,"".concat(T,"-").concat(z));R=d(Be(Be({},j),{},{className:Gj(hb(f,T),we(we({},$,$&&z),f,typeof f=="string")),style:L}),I)}if(g.isValidElement(R)&&d3(R)){var F=h3(R);F||(R=g.cloneElement(R,{ref:I}))}return g.createElement(x4,{ref:b},R)});return r.displayName="CSSMotion",r}const M4=R4(nN);var dv="add",hv="keep",fv="remove",Vp="removed";function A4(e){var t;return e&&Ct(e)==="object"&&"key"in e?t=e:t={key:e},Be(Be({},t),{},{key:String(t.key)})}function pv(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(A4)}function j4(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=[],r=0,i=t.length,s=pv(e),o=pv(t);s.forEach(function(c){for(var u=!1,d=r;d<i;d+=1){var f=o[d];if(f.key===c.key){r<d&&(n=n.concat(o.slice(r,d).map(function(p){return Be(Be({},p),{},{status:dv})})),r=d),n.push(Be(Be({},f),{},{status:hv})),r+=1,u=!0;break}}u||n.push(Be(Be({},c),{},{status:fv}))}),r<i&&(n=n.concat(o.slice(r).map(function(c){return Be(Be({},c),{},{status:dv})})));var a={};n.forEach(function(c){var u=c.key;a[u]=(a[u]||0)+1});var l=Object.keys(a).filter(function(c){return a[c]>1});return l.forEach(function(c){n=n.filter(function(u){var d=u.key,f=u.status;return d!==c||f!==fv}),n.forEach(function(u){u.key===c&&(u.status=hv)})}),n}var D4=["component","children","onVisibleChanged","onAllRemoved"],L4=["status"],O4=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function B4(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:M4,n=function(r){mE(s,r);var i=vE(s);function s(){var o;Va(this,s);for(var a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];return o=i.call.apply(i,[this].concat(l)),we(Og(o),"state",{keyEntities:[]}),we(Og(o),"removeKey",function(u){o.setState(function(d){var f=d.keyEntities.map(function(p){return p.key!==u?p:Be(Be({},p),{},{status:Vp})});return{keyEntities:f}},function(){var d=o.state.keyEntities,f=d.filter(function(p){var m=p.status;return m!==Vp}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return qa(s,[{key:"render",value:function(){var a=this,l=this.state.keyEntities,c=this.props,u=c.component,d=c.children,f=c.onVisibleChanged;c.onAllRemoved;var p=Fg(c,D4),m=u||g.Fragment,v={};return O4.forEach(function(y){v[y]=p[y],delete p[y]}),delete p.keys,g.createElement(m,p,l.map(function(y,_){var x=y.status,b=Fg(y,L4),w=x===dv||x===hv;return g.createElement(t,_h({},v,{key:b.key,visible:w,eventProps:b,onVisibleChanged:function(k){f==null||f(k,{key:b.key}),k||a.removeKey(b.key)}}),function(S,k){return d(Be(Be({},S),{},{index:_}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(a,l){var c=a.keys,u=l.keyEntities,d=pv(c),f=j4(u,d);return{keyEntities:f.filter(function(p){var m=u.find(function(v){var y=v.key;return p.key===y});return!(m&&m.status===Vp&&p.status===fv)})}}}]),s}(g.Component);return we(n,"defaultProps",{component:"div"}),n}B4(nN);const fb=g.createContext(!0);function z4(e){const t=g.useContext(fb),{children:n}=e,[,r]=XE(),{motion:i}=r,s=g.useRef(!1);return s.current||(s.current=t!==i),s.current?g.createElement(fb.Provider,{value:i},g.createElement(_4,{motion:i},n)):n}const $4=()=>null;var F4=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const H4=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let oN;function U4(){return oN||av}function W4(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const V4=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:i}=e;t!==void 0&&(oN=t),r&&W4(r)&&JD(U4(),r)},q4=e=>{const{children:t,csp:n,autoInsertSpaceInButton:r,alert:i,anchor:s,form:o,locale:a,componentSize:l,direction:c,space:u,splitter:d,virtual:f,dropdownMatchSelectWidth:p,popupMatchSelectWidth:m,popupOverflow:v,legacyLocale:y,parentContext:_,iconPrefixCls:x,theme:b,componentDisabled:w,segmented:S,statistic:k,spin:T,calendar:N,carousel:L,cascader:P,collapse:O,typography:I,checkbox:R,descriptions:j,divider:z,drawer:$,skeleton:F,steps:A,image:B,layout:E,list:H,mentions:q,modal:M,progress:re,result:oe,slider:V,breadcrumb:pe,menu:Oe,pagination:ie,input:Me,textArea:Fe,empty:We,badge:ge,radio:qe,rate:Gt,switch:wt,transfer:Rt,avatar:ln,message:Bt,tag:at,table:Ue,card:nt,tabs:mt,timeline:Xt,timePicker:pn,upload:U,notification:Q,tree:ve,colorPicker:Se,datePicker:J,rangePicker:Xe,flex:Yt,wave:Zt,dropdown:ue,warning:Ne,tour:Je,tooltip:Dn,popover:Qt,popconfirm:il,floatButton:Ao,floatButtonGroup:xu,variant:yu,inputNumber:lp,treeSelect:cp}=e,bu=g.useCallback((Tt,$t)=>{const{prefixCls:or}=e;if($t)return $t;const Ln=or||_.getPrefixCls("");return Tt?`${Ln}-${Tt}`:Ln},[_.getPrefixCls,e.prefixCls]),jo=x||_.iconPrefixCls||qE,Do=n||_.csp;h4(jo,Do);const sl=g4(b,_.theme,{prefixCls:bu("")}),ol={csp:Do,autoInsertSpaceInButton:r,alert:i,anchor:s,locale:a||y,direction:c,space:u,splitter:d,virtual:f,popupMatchSelectWidth:m??p,popupOverflow:v,getPrefixCls:bu,iconPrefixCls:jo,theme:sl,segmented:S,statistic:k,spin:T,calendar:N,carousel:L,cascader:P,collapse:O,typography:I,checkbox:R,descriptions:j,divider:z,drawer:$,skeleton:F,steps:A,image:B,input:Me,textArea:Fe,layout:E,list:H,mentions:q,modal:M,progress:re,result:oe,slider:V,breadcrumb:pe,menu:Oe,pagination:ie,empty:We,badge:ge,radio:qe,rate:Gt,switch:wt,transfer:Rt,avatar:ln,message:Bt,tag:at,table:Ue,card:nt,tabs:mt,timeline:Xt,timePicker:pn,upload:U,notification:Q,tree:ve,colorPicker:Se,datePicker:J,rangePicker:Xe,flex:Yt,wave:Zt,dropdown:ue,warning:Ne,tour:Je,tooltip:Dn,popover:Qt,popconfirm:il,floatButton:Ao,floatButtonGroup:xu,variant:yu,inputNumber:lp,treeSelect:cp},Ui=Object.assign({},_);Object.keys(ol).forEach(Tt=>{ol[Tt]!==void 0&&(Ui[Tt]=ol[Tt])}),H4.forEach(Tt=>{const $t=e[Tt];$t&&(Ui[Tt]=$t)}),typeof r<"u"&&(Ui.button=Object.assign({autoInsertSpace:r},Ui.button));const Wi=fE(()=>Ui,Ui,(Tt,$t)=>{const or=Object.keys(Tt),Ln=Object.keys($t);return or.length!==Ln.length||or.some(Z=>Tt[Z]!==$t[Z])}),{layer:al}=g.useContext(Tf),wu=g.useMemo(()=>({prefixCls:jo,csp:Do,layer:al?"antd":void 0}),[jo,Do,al]);let zt=g.createElement(g.Fragment,null,g.createElement($4,{dropdownMatchSelectWidth:p}),t);const ll=g.useMemo(()=>{var Tt,$t,or,Ln;return RD(((Tt=Rf.Form)===null||Tt===void 0?void 0:Tt.defaultValidateMessages)||{},((or=($t=Wi.locale)===null||$t===void 0?void 0:$t.Form)===null||or===void 0?void 0:or.defaultValidateMessages)||{},((Ln=Wi.form)===null||Ln===void 0?void 0:Ln.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[Wi,o==null?void 0:o.validateMessages]);Object.keys(ll).length>0&&(zt=g.createElement(AD.Provider,{value:ll},zt)),a&&(zt=g.createElement(LD,{locale:a,_ANT_MARK__:DD},zt)),zt=g.createElement(ND.Provider,{value:wu},zt),l&&(zt=g.createElement(t4,{size:l},zt)),zt=g.createElement(z4,null,zt);const cl=g.useMemo(()=>{const Tt=sl||{},{algorithm:$t,token:or,components:Ln,cssVar:Z}=Tt,_e=F4(Tt,["algorithm","token","components","cssVar"]),xe=$t&&(!Array.isArray($t)||$t.length>0)?Ug($t):WE,Ye={};Object.entries(Ln||{}).forEach(([fA,pA])=>{const fi=Object.assign({},pA);"algorithm"in fi&&(fi.algorithm===!0?fi.theme=xe:(Array.isArray(fi.algorithm)||typeof fi.algorithm=="function")&&(fi.theme=Ug(fi.algorithm)),delete fi.algorithm),Ye[fA]=fi});const hi=Object.assign(Object.assign({},Nc),or);return Object.assign(Object.assign({},_e),{theme:xe,token:hi,components:Ye,override:Object.assign({override:hi},Ye),cssVar:Z})},[sl]);return b&&(zt=g.createElement(VE.Provider,{value:cl},zt)),Wi.warning&&(zt=g.createElement(MD.Provider,{value:Wi.warning},zt)),w!==void 0&&(zt=g.createElement(e4,{disabled:w},zt)),g.createElement(Mf.Provider,{value:Wi},zt)},Ga=e=>{const t=g.useContext(Mf),n=g.useContext($E);return g.createElement(q4,Object.assign({parentContext:t,legacyLocale:n},e))};Ga.ConfigContext=Mf;Ga.SizeContext=Tc;Ga.config=V4;Ga.useConfig=n4;Object.defineProperty(Ga,"SizeContext",{get:()=>Tc});const lr=(e,t)=>new xt(e).setA(t).toRgbString(),Bo=(e,t)=>new xt(e).lighten(t).toHexString(),K4=e=>{const t=Aa(e,{theme:"dark"});return{1:t[0],2:t[1],3:t[2],4:t[3],5:t[6],6:t[5],7:t[4],8:t[6],9:t[5],10:t[4]}},G4=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:lr(r,.85),colorTextSecondary:lr(r,.65),colorTextTertiary:lr(r,.45),colorTextQuaternary:lr(r,.25),colorFill:lr(r,.18),colorFillSecondary:lr(r,.12),colorFillTertiary:lr(r,.08),colorFillQuaternary:lr(r,.04),colorBgSolid:lr(r,.95),colorBgSolidHover:lr(r,1),colorBgSolidActive:lr(r,.9),colorBgElevated:Bo(n,12),colorBgContainer:Bo(n,8),colorBgLayout:Bo(n,0),colorBgSpotlight:Bo(n,26),colorBgBlur:lr(r,.04),colorBorder:Bo(n,26),colorBorderSecondary:Bo(n,19)}},X4=(e,t)=>{const n=Object.keys(O_).map(s=>{const o=Aa(e[s],{theme:"dark"});return Array.from({length:10},()=>1).reduce((a,l,c)=>(a[`${s}-${c+1}`]=o[c],a[`${s}${c+1}`]=o[c],a),{})}).reduce((s,o)=>(s=Object.assign(Object.assign({},s),o),s),{}),r=t??B_(e),i=UE(e,{generateColorPalettes:K4,generateNeutralColorPalettes:G4});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),i),{colorPrimaryBg:i.colorPrimaryBorder,colorPrimaryBgHover:i.colorPrimaryBorderHover})},pb={defaultSeed:bh.token,defaultAlgorithm:B_,darkAlgorithm:X4};function mb({children:e}){const t=P_(),[n,r]=g.useState(t.theme);return g.useEffect(()=>t.onThemeChange(r),[t]),h.jsx(Ga,{theme:{algorithm:n.mode==="dark"?pb.darkAlgorithm:pb.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}var Ke;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},e.find=(i,s)=>{for(const o of i)if(s(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Ke||(Ke={}));var gb;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(gb||(gb={}));const ce=Ke.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ns=e=>{switch(typeof e){case"undefined":return ce.undefined;case"string":return ce.string;case"number":return Number.isNaN(e)?ce.nan:ce.number;case"boolean":return ce.boolean;case"function":return ce.function;case"bigint":return ce.bigint;case"symbol":return ce.symbol;case"object":return Array.isArray(e)?ce.array:e===null?ce.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?ce.promise:typeof Map<"u"&&e instanceof Map?ce.map:typeof Set<"u"&&e instanceof Set?ce.set:typeof Date<"u"&&e instanceof Date?ce.date:ce.object;default:return ce.unknown}},K=Ke.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ri extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(o))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof Ri))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ke.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ri.create=e=>new Ri(e);const mv=(e,t)=>{let n;switch(e.code){case K.invalid_type:e.received===ce.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case K.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Ke.jsonStringifyReplacer)}`;break;case K.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ke.joinValues(e.keys,", ")}`;break;case K.invalid_union:n="Invalid input";break;case K.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ke.joinValues(e.options)}`;break;case K.invalid_enum_value:n=`Invalid enum value. Expected ${Ke.joinValues(e.options)}, received '${e.received}'`;break;case K.invalid_arguments:n="Invalid function arguments";break;case K.invalid_return_type:n="Invalid function return type";break;case K.invalid_date:n="Invalid date";break;case K.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Ke.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case K.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case K.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case K.custom:n="Invalid input";break;case K.invalid_intersection_types:n="Intersection results could not be merged";break;case K.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case K.not_finite:n="Number must be finite";break;default:n=t.defaultError,Ke.assertNever(e)}return{message:n}};let Y4=mv;function Z4(){return Y4}const Q4=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,s=[...n,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(o,{data:t,defaultError:a}).message;return{...i,path:s,message:a}};function se(e,t){const n=Z4(),r=Q4({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===mv?void 0:mv].filter(i=>!!i)});e.common.issues.push(r)}class Tn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const i of n){if(i.status==="aborted")return Ce;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const i of n){const s=await i.key,o=await i.value;r.push({key:s,value:o})}return Tn.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const i of n){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Ce;s.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:t.value,value:r}}}const Ce=Object.freeze({status:"aborted"}),Dl=e=>({status:"dirty",value:e}),Sr=e=>({status:"valid",value:e}),vb=e=>e.status==="aborted",_b=e=>e.status==="dirty",ja=e=>e.status==="valid",wh=e=>typeof Promise<"u"&&e instanceof Promise;var me;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(me||(me={}));class ii{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const xb=(e,t)=>{if(ja(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ri(e.common.issues);return this._error=n,this._error}}};function Re(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,a)=>{const{message:l}=e;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:i}}class He{get description(){return this._def.description}_getType(t){return ns(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ns(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Tn,ctx:{common:t.parent.common,data:t.data,parsedType:ns(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(wh(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ns(t)},i=this._parseSync({data:t,path:r.path,parent:r});return xb(r,i)}"~validate"(t){var r,i;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ns(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:n});return ja(s)?{value:s.value}:{issues:n.common.issues}}catch(s){(i=(r=s==null?void 0:s.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(s=>ja(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ns(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await(wh(i)?i:Promise.resolve(i));return xb(r,s)}refine(t,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{const o=t(i),a=()=>s.addIssue({code:K.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new uo({schema:this,typeName:Ee.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ei.create(this,this._def)}nullable(){return ho.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ei.create(this)}promise(){return Th.create(this,this._def)}or(t){return kh.create([this,t],this._def)}and(t){return Ch.create(this,t,this._def)}transform(t){return new uo({...Re(this._def),schema:this,typeName:Ee.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Ph({...Re(this._def),innerType:this,defaultValue:n,typeName:Ee.ZodDefault})}brand(){return new uN({typeName:Ee.ZodBranded,type:this,...Re(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Ih({...Re(this._def),innerType:this,catchValue:n,typeName:Ee.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return F_.create(this,t)}readonly(){return Rh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const J4=/^c[^\s-]{8,}$/i,eL=/^[0-9a-z]+$/,tL=/^[0-9A-HJKMNP-TV-Z]{26}$/i,nL=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,rL=/^[a-z0-9_-]{21}$/i,iL=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,sL=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,oL=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,aL="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let qp;const lL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,cL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,uL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,dL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,hL=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,fL=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,aN="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",pL=new RegExp(`^${aN}$`);function lN(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function mL(e){return new RegExp(`^${lN(e)}$`)}function gL(e){let t=`${aN}T${lN(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function vL(e,t){return!!((t==="v4"||!t)&&lL.test(e)||(t==="v6"||!t)&&uL.test(e))}function _L(e,t){if(!iL.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function xL(e,t){return!!((t==="v4"||!t)&&cL.test(e)||(t==="v6"||!t)&&dL.test(e))}class wi extends He{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==ce.string){const s=this._getOrReturnCtx(t);return se(s,{code:K.invalid_type,expected:ce.string,received:s.parsedType}),Ce}const r=new Tn;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),se(i,{code:K.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),se(i,{code:K.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=t.data.length>s.value,a=t.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(t,i),o?se(i,{code:K.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&se(i,{code:K.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")oL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"email",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")qp||(qp=new RegExp(aL,"u")),qp.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"emoji",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")nL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"uuid",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")rL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"nanoid",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")J4.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"cuid",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")eL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"cuid2",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")tL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"ulid",code:K.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),se(i,{validation:"url",code:K.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"regex",code:K.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),se(i,{code:K.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),se(i,{code:K.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),se(i,{code:K.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?gL(s).test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{code:K.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?pL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{code:K.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?mL(s).test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{code:K.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?sL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"duration",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?vL(t.data,s.version)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"ip",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?_L(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"jwt",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?xL(t.data,s.version)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"cidr",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?hL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"base64",code:K.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?fL.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"base64url",code:K.invalid_string,message:s.message}),r.dirty()):Ke.assertNever(s);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:K.invalid_string,...me.errToObj(r)})}_addCheck(t){return new wi({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...me.errToObj(t)})}url(t){return this._addCheck({kind:"url",...me.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...me.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...me.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...me.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...me.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...me.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...me.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...me.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...me.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...me.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...me.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...me.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...me.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...me.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...me.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...me.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...me.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...me.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...me.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...me.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...me.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...me.errToObj(n)})}nonempty(t){return this.min(1,me.errToObj(t))}trim(){return new wi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new wi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new wi({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}wi.create=e=>new wi({checks:[],typeName:Ee.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Re(e)});function yL(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),o=Number.parseInt(t.toFixed(i).replace(".",""));return s%o/10**i}class Da extends He{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==ce.number){const s=this._getOrReturnCtx(t);return se(s,{code:K.invalid_type,expected:ce.number,received:s.parsedType}),Ce}let r;const i=new Tn;for(const s of this._def.checks)s.kind==="int"?Ke.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),se(r,{code:K.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),se(r,{code:K.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),se(r,{code:K.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?yL(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),se(r,{code:K.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),se(r,{code:K.not_finite,message:s.message}),i.dirty()):Ke.assertNever(s);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,me.toString(n))}gt(t,n){return this.setLimit("min",t,!1,me.toString(n))}lte(t,n){return this.setLimit("max",t,!0,me.toString(n))}lt(t,n){return this.setLimit("max",t,!1,me.toString(n))}setLimit(t,n,r,i){return new Da({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:me.toString(i)}]})}_addCheck(t){return new Da({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:me.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:me.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:me.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:me.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:me.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:me.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:me.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:me.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:me.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Ke.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Da.create=e=>new Da({checks:[],typeName:Ee.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Re(e)});class Pc extends He{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==ce.bigint)return this._getInvalidInput(t);let r;const i=new Tn;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),se(r,{code:K.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),se(r,{code:K.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),se(r,{code:K.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Ke.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return se(n,{code:K.invalid_type,expected:ce.bigint,received:n.parsedType}),Ce}gte(t,n){return this.setLimit("min",t,!0,me.toString(n))}gt(t,n){return this.setLimit("min",t,!1,me.toString(n))}lte(t,n){return this.setLimit("max",t,!0,me.toString(n))}lt(t,n){return this.setLimit("max",t,!1,me.toString(n))}setLimit(t,n,r,i){return new Pc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:me.toString(i)}]})}_addCheck(t){return new Pc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:me.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:me.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:me.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:me.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:me.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Pc.create=e=>new Pc({checks:[],typeName:Ee.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Re(e)});class gv extends He{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==ce.boolean){const r=this._getOrReturnCtx(t);return se(r,{code:K.invalid_type,expected:ce.boolean,received:r.parsedType}),Ce}return Sr(t.data)}}gv.create=e=>new gv({typeName:Ee.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Re(e)});class Sh extends He{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==ce.date){const s=this._getOrReturnCtx(t);return se(s,{code:K.invalid_type,expected:ce.date,received:s.parsedType}),Ce}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return se(s,{code:K.invalid_date}),Ce}const r=new Tn;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),se(i,{code:K.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),se(i,{code:K.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):Ke.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Sh({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:me.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:me.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}Sh.create=e=>new Sh({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Ee.ZodDate,...Re(e)});class yb extends He{_parse(t){if(this._getType(t)!==ce.symbol){const r=this._getOrReturnCtx(t);return se(r,{code:K.invalid_type,expected:ce.symbol,received:r.parsedType}),Ce}return Sr(t.data)}}yb.create=e=>new yb({typeName:Ee.ZodSymbol,...Re(e)});class vv extends He{_parse(t){if(this._getType(t)!==ce.undefined){const r=this._getOrReturnCtx(t);return se(r,{code:K.invalid_type,expected:ce.undefined,received:r.parsedType}),Ce}return Sr(t.data)}}vv.create=e=>new vv({typeName:Ee.ZodUndefined,...Re(e)});class _v extends He{_parse(t){if(this._getType(t)!==ce.null){const r=this._getOrReturnCtx(t);return se(r,{code:K.invalid_type,expected:ce.null,received:r.parsedType}),Ce}return Sr(t.data)}}_v.create=e=>new _v({typeName:Ee.ZodNull,...Re(e)});class bb extends He{constructor(){super(...arguments),this._any=!0}_parse(t){return Sr(t.data)}}bb.create=e=>new bb({typeName:Ee.ZodAny,...Re(e)});class xv extends He{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Sr(t.data)}}xv.create=e=>new xv({typeName:Ee.ZodUnknown,...Re(e)});class Ss extends He{_parse(t){const n=this._getOrReturnCtx(t);return se(n,{code:K.invalid_type,expected:ce.never,received:n.parsedType}),Ce}}Ss.create=e=>new Ss({typeName:Ee.ZodNever,...Re(e)});class wb extends He{_parse(t){if(this._getType(t)!==ce.undefined){const r=this._getOrReturnCtx(t);return se(r,{code:K.invalid_type,expected:ce.void,received:r.parsedType}),Ce}return Sr(t.data)}}wb.create=e=>new wb({typeName:Ee.ZodVoid,...Re(e)});class ei extends He{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==ce.array)return se(n,{code:K.invalid_type,expected:ce.array,received:n.parsedType}),Ce;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(o||a)&&(se(n,{code:o?K.too_big:K.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(se(n,{code:K.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(se(n,{code:K.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>i.type._parseAsync(new ii(n,o,n.path,a)))).then(o=>Tn.mergeArray(r,o));const s=[...n.data].map((o,a)=>i.type._parseSync(new ii(n,o,n.path,a)));return Tn.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new ei({...this._def,minLength:{value:t,message:me.toString(n)}})}max(t,n){return new ei({...this._def,maxLength:{value:t,message:me.toString(n)}})}length(t,n){return new ei({...this._def,exactLength:{value:t,message:me.toString(n)}})}nonempty(t){return this.min(1,t)}}ei.create=(e,t)=>new ei({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ee.ZodArray,...Re(t)});function Ko(e){if(e instanceof jt){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Ei.create(Ko(r))}return new jt({...e._def,shape:()=>t})}else return e instanceof ei?new ei({...e._def,type:Ko(e.element)}):e instanceof Ei?Ei.create(Ko(e.unwrap())):e instanceof ho?ho.create(Ko(e.unwrap())):e instanceof lo?lo.create(e.items.map(t=>Ko(t))):e}class jt extends He{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=Ke.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==ce.object){const c=this._getOrReturnCtx(t);return se(c,{code:K.invalid_type,expected:ce.object,received:c.parsedType}),Ce}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ss&&this._def.unknownKeys==="strip"))for(const c in i.data)o.includes(c)||a.push(c);const l=[];for(const c of o){const u=s[c],d=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new ii(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Ss){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")a.length>0&&(se(i,{code:K.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const d=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new ii(i,d,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const d=await u.key,f=await u.value;c.push({key:d,value:f,alwaysSet:u.alwaysSet})}return c}).then(c=>Tn.mergeObjectSync(r,c)):Tn.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return me.errToObj,new jt({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,o;const i=((o=(s=this._def).errorMap)==null?void 0:o.call(s,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:me.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new jt({...this._def,unknownKeys:"strip"})}passthrough(){return new jt({...this._def,unknownKeys:"passthrough"})}extend(t){return new jt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new jt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ee.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new jt({...this._def,catchall:t})}pick(t){const n={};for(const r of Ke.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new jt({...this._def,shape:()=>n})}omit(t){const n={};for(const r of Ke.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new jt({...this._def,shape:()=>n})}deepPartial(){return Ko(this)}partial(t){const n={};for(const r of Ke.objectKeys(this.shape)){const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new jt({...this._def,shape:()=>n})}required(t){const n={};for(const r of Ke.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Ei;)s=s._def.innerType;n[r]=s}return new jt({...this._def,shape:()=>n})}keyof(){return cN(Ke.objectKeys(this.shape))}}jt.create=(e,t)=>new jt({shape:()=>e,unknownKeys:"strip",catchall:Ss.create(),typeName:Ee.ZodObject,...Re(t)});jt.strictCreate=(e,t)=>new jt({shape:()=>e,unknownKeys:"strict",catchall:Ss.create(),typeName:Ee.ZodObject,...Re(t)});jt.lazycreate=(e,t)=>new jt({shape:e,unknownKeys:"strip",catchall:Ss.create(),typeName:Ee.ZodObject,...Re(t)});class kh extends He{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function i(s){for(const a of s)if(a.result.status==="valid")return a.result;for(const a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(a=>new Ri(a.ctx.common.issues));return se(n,{code:K.invalid_union,unionErrors:o}),Ce}if(n.common.async)return Promise.all(r.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(l=>new Ri(l));return se(n,{code:K.invalid_union,unionErrors:a}),Ce}}get options(){return this._def.options}}kh.create=(e,t)=>new kh({options:e,typeName:Ee.ZodUnion,...Re(t)});const vi=e=>e instanceof bv?vi(e.schema):e instanceof uo?vi(e.innerType()):e instanceof Nh?[e.value]:e instanceof co?e.options:e instanceof wv?Ke.objectValues(e.enum):e instanceof Ph?vi(e._def.innerType):e instanceof vv?[void 0]:e instanceof _v?[null]:e instanceof Ei?[void 0,...vi(e.unwrap())]:e instanceof ho?[null,...vi(e.unwrap())]:e instanceof uN||e instanceof Rh?vi(e.unwrap()):e instanceof Ih?vi(e._def.innerType):[];class $_ extends He{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ce.object)return se(n,{code:K.invalid_type,expected:ce.object,received:n.parsedType}),Ce;const r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(se(n,{code:K.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Ce)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const i=new Map;for(const s of n){const o=vi(s.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of o){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,s)}}return new $_({typeName:Ee.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Re(r)})}}function yv(e,t){const n=ns(e),r=ns(t);if(e===t)return{valid:!0,data:e};if(n===ce.object&&r===ce.object){const i=Ke.objectKeys(t),s=Ke.objectKeys(e).filter(a=>i.indexOf(a)!==-1),o={...e,...t};for(const a of s){const l=yv(e[a],t[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===ce.array&&r===ce.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<e.length;s++){const o=e[s],a=t[s],l=yv(o,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===ce.date&&r===ce.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Ch extends He{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(vb(s)||vb(o))return Ce;const a=yv(s.value,o.value);return a.valid?((_b(s)||_b(o))&&n.dirty(),{status:n.value,value:a.data}):(se(r,{code:K.invalid_intersection_types}),Ce)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Ch.create=(e,t,n)=>new Ch({left:e,right:t,typeName:Ee.ZodIntersection,...Re(n)});class lo extends He{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.array)return se(r,{code:K.invalid_type,expected:ce.array,received:r.parsedType}),Ce;if(r.data.length<this._def.items.length)return se(r,{code:K.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ce;!this._def.rest&&r.data.length>this._def.items.length&&(se(r,{code:K.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const s=[...r.data].map((o,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new ii(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>Tn.mergeArray(n,o)):Tn.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new lo({...this._def,rest:t})}}lo.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new lo({items:e,typeName:Ee.ZodTuple,rest:null,...Re(t)})};class Eh extends He{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.object)return se(r,{code:K.invalid_type,expected:ce.object,received:r.parsedType}),Ce;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in r.data)i.push({key:s._parse(new ii(r,a,r.path,a)),value:o._parse(new ii(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Tn.mergeObjectAsync(n,i):Tn.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof He?new Eh({keyType:t,valueType:n,typeName:Ee.ZodRecord,...Re(r)}):new Eh({keyType:wi.create(),valueType:t,typeName:Ee.ZodRecord,...Re(n)})}}class Sb extends He{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.map)return se(r,{code:K.invalid_type,expected:ce.map,received:r.parsedType}),Ce;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new ii(r,a,r.path,[c,"key"])),value:s._parse(new ii(r,l,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Ce;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of o){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Ce;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}}}}Sb.create=(e,t,n)=>new Sb({valueType:t,keyType:e,typeName:Ee.ZodMap,...Re(n)});class Ic extends He{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.set)return se(r,{code:K.invalid_type,expected:ce.set,received:r.parsedType}),Ce;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(se(r,{code:K.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(se(r,{code:K.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const s=this._def.valueType;function o(l){const c=new Set;for(const u of l){if(u.status==="aborted")return Ce;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}const a=[...r.data.values()].map((l,c)=>s._parse(new ii(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(t,n){return new Ic({...this._def,minSize:{value:t,message:me.toString(n)}})}max(t,n){return new Ic({...this._def,maxSize:{value:t,message:me.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Ic.create=(e,t)=>new Ic({valueType:e,minSize:null,maxSize:null,typeName:Ee.ZodSet,...Re(t)});class bv extends He{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}bv.create=(e,t)=>new bv({getter:e,typeName:Ee.ZodLazy,...Re(t)});class Nh extends He{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return se(n,{received:n.data,code:K.invalid_literal,expected:this._def.value}),Ce}return{status:"valid",value:t.data}}get value(){return this._def.value}}Nh.create=(e,t)=>new Nh({value:e,typeName:Ee.ZodLiteral,...Re(t)});function cN(e,t){return new co({values:e,typeName:Ee.ZodEnum,...Re(t)})}class co extends He{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return se(n,{expected:Ke.joinValues(r),received:n.parsedType,code:K.invalid_type}),Ce}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return se(n,{received:n.data,code:K.invalid_enum_value,options:r}),Ce}return Sr(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return co.create(t,{...this._def,...n})}exclude(t,n=this._def){return co.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}co.create=cN;class wv extends He{_parse(t){const n=Ke.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==ce.string&&r.parsedType!==ce.number){const i=Ke.objectValues(n);return se(r,{expected:Ke.joinValues(i),received:r.parsedType,code:K.invalid_type}),Ce}if(this._cache||(this._cache=new Set(Ke.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=Ke.objectValues(n);return se(r,{received:r.data,code:K.invalid_enum_value,options:i}),Ce}return Sr(t.data)}get enum(){return this._def.values}}wv.create=(e,t)=>new wv({values:e,typeName:Ee.ZodNativeEnum,...Re(t)});class Th extends He{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ce.promise&&n.common.async===!1)return se(n,{code:K.invalid_type,expected:ce.promise,received:n.parsedType}),Ce;const r=n.parsedType===ce.promise?n.data:Promise.resolve(n.data);return Sr(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Th.create=(e,t)=>new Th({type:e,typeName:Ee.ZodPromise,...Re(t)});class uo extends He{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ee.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:o=>{se(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return Ce;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?Ce:l.status==="dirty"||n.value==="dirty"?Dl(l.value):l});{if(n.value==="aborted")return Ce;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?Ce:a.status==="dirty"||n.value==="dirty"?Dl(a.value):a}}if(i.type==="refinement"){const o=a=>{const l=i.refinement(a,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Ce:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Ce:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ja(o))return Ce;const a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>ja(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:n.value,value:a})):Ce);Ke.assertNever(i)}}uo.create=(e,t,n)=>new uo({schema:e,typeName:Ee.ZodEffects,effect:t,...Re(n)});uo.createWithPreprocess=(e,t,n)=>new uo({schema:t,effect:{type:"preprocess",transform:e},typeName:Ee.ZodEffects,...Re(n)});class Ei extends He{_parse(t){return this._getType(t)===ce.undefined?Sr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Ei.create=(e,t)=>new Ei({innerType:e,typeName:Ee.ZodOptional,...Re(t)});class ho extends He{_parse(t){return this._getType(t)===ce.null?Sr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ho.create=(e,t)=>new ho({innerType:e,typeName:Ee.ZodNullable,...Re(t)});class Ph extends He{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===ce.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Ph.create=(e,t)=>new Ph({innerType:e,typeName:Ee.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Re(t)});class Ih extends He{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return wh(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ri(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ri(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Ih.create=(e,t)=>new Ih({innerType:e,typeName:Ee.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Re(t)});class kb extends He{_parse(t){if(this._getType(t)!==ce.nan){const r=this._getOrReturnCtx(t);return se(r,{code:K.invalid_type,expected:ce.nan,received:r.parsedType}),Ce}return{status:"valid",value:t.data}}}kb.create=e=>new kb({typeName:Ee.ZodNaN,...Re(e)});class uN extends He{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class F_ extends He{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Ce:s.status==="dirty"?(n.dirty(),Dl(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Ce:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new F_({in:t,out:n,typeName:Ee.ZodPipeline})}}class Rh extends He{_parse(t){const n=this._def.innerType._parse(t),r=i=>(ja(i)&&(i.value=Object.freeze(i.value)),i);return wh(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}Rh.create=(e,t)=>new Rh({innerType:e,typeName:Ee.ZodReadonly,...Re(t)});var Ee;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Ee||(Ee={}));const C=wi.create,Y=Da.create,Te=gv.create,_a=xv.create;Ss.create;const be=ei.create,D=jt.create;kh.create;const ai=$_.create;Ch.create;lo.create;const nu=Eh.create,ee=Nh.create,Qe=co.create;Th.create;Ei.create;ho.create;const bL=["owner"],wL=["agent","owner","user-upload"],dN=D({id:C().min(1),relPath:C().min(1),from:Qe(wL),label:C().optional(),size:Y().int().nonnegative(),mime:C().min(1),addedAt:Y().int().nonnegative(),lastEditedAt:Y().int().nonnegative().optional(),stale:Te().optional()});D({sessionId:C().min(1),relPath:C().min(1),ttlSeconds:Y().int().positive().nullable().optional(),view:Qe(["raw","md-rendered"]).optional()});D({url:C().min(1),expiresAt:Y().int().nonnegative().nullable()});D({sessionId:C().min(1),relPath:C().min(1),label:C().optional(),origin:ee("agent").optional()});D({entry:dN});D({sessionId:C().min(1),relPath:C().min(1)});D({removed:ee(!0)});D({sessionId:C().min(1)});D({entries:be(dN)});D({attachmentId:C().min(1),url:C().min(1),relPath:C().min(1),sizeBytes:Y().int().nonnegative(),mimeType:C().min(1)});const SL=ai("type",[D({type:ee("persona"),id:C().min(1)}).strict(),D({type:ee("chat"),id:C().min(1)}).strict(),D({type:ee("*")}).strict()]),kL=Qe(["read","send","admin"]),H_=D({resource:SL,actions:be(kL).min(1)}).strict(),CL=D({id:C().min(1),secretHash:C().regex(/^[a-f0-9]{64}$/),displayName:C(),grants:be(H_),issuedAt:Y().int().nonnegative(),expiresAt:Y().int().positive().optional(),maxUses:Y().int().positive().optional(),usedCount:Y().int().nonnegative(),peerOwnerId:C().min(1).optional(),firstUsedByPeerAt:Y().int().positive().optional(),peerDisplayName:C().optional()}).strict(),EL=CL.omit({secretHash:!0});D({type:ee("whoami:ok"),owner:D({id:C(),kind:Qe(["owner","guest"]),displayName:C(),ownerId:C(),provider:C()}).strict(),capability:EL,grantedPersonas:be(D({id:C().min(1),displayName:C()}).strict())}).strict();D({selfUrl:C().min(1)});D({type:ee("contact:handshake:ok"),owner:D({id:C(),ownerId:C(),provider:C(),displayName:C()}),grants:be(H_)});D({deviceId:C().min(1),remoteAccessAllowed:Te()}).strict();D({type:ee("contact:setRemoteAccess:ok"),deviceId:C().min(1),remoteAccessAllowed:Te()}).strict();D({type:ee("contact:remote-access-updated"),deviceId:C().min(1),remoteAccessAllowed:Te()}).strict();const NL=D({deviceId:C().min(1),ownerId:C().min(1),provider:C().min(1),displayName:C(),remoteUrl:C().min(1),connectToken:C(),grants:be(H_),addedAt:Y().int().nonnegative(),pinnedAt:Y().int().nullable().default(null),remoteAccessAllowed:Te().default(!1)}).strict(),hN=NL;D({deviceId:C().min(1)}).strict();D({type:ee("contact:remove:ok"),deviceId:C().min(1)}).strict();D({type:ee("contact:list:ok"),contacts:be(hN)}).strict();D({type:ee("contact:added"),contact:hN}).strict();D({type:ee("contact:removed"),deviceId:C().min(1)}).strict();D({deviceId:C().min(1),pinned:Te()}).strict();D({type:ee("contact:pin:ok"),deviceId:C().min(1),pinnedAt:Y().int().nullable()}).strict();D({type:ee("contact:pinned"),deviceId:C().min(1),pinnedAt:Y().int().nullable()}).strict();const TL=D({deviceId:C().min(1),name:C().min(1),url:C().min(1)});D({type:ee("device:list:ok"),devices:be(TL)});D({deviceId:C().min(1),url:C().min(1).optional(),name:C().optional()});D({type:ee("device:connect:ok"),deviceId:C(),name:C(),url:C()});const fN=D({ownerId:C().min(1),provider:C().min(1),displayName:C().min(1),avatarUrl:C().optional(),unionId:C().optional()});D({type:ee("auth:login:start:ok"),authUrl:C().min(1),state:C().min(1)});D({type:ee("auth:getIdentity:ok"),identity:fN.nullable(),deviceId:C().min(1)});D({type:ee("auth:logout:ok")});D({type:ee("auth:login:done"),identity:fN});D({type:ee("auth:login:failed"),reason:C()});const U_=ai("kind",[D({kind:ee("success"),text:C(),filePaths:be(C()).optional()}),D({kind:ee("failure"),reason:C()})]);D({targetPersona:C().min(1).optional(),dispatchId:C().min(1).optional(),prompt:C(),targetDeviceId:C().min(1).optional(),model:C().min(1).optional(),sessionLabel:C().min(1).max(60).optional()}).refine(e=>e.targetPersona!==void 0||e.dispatchId!==void 0,{message:"either targetPersona (new dispatch) or dispatchId (follow-up) is required"}).refine(e=>!(e.dispatchId!==void 0&&e.targetDeviceId!==void 0),{message:"cross-device dispatch cannot be continued (dispatchId + targetDeviceId are mutually exclusive)"});D({dispatchId:C().min(1),outcome:U_});const PL=["running","completed","failed"],pN=Qe(PL),IL=D({dispatchId:C().min(1),sourceSessionId:C().min(1),sourcePersonaId:C().min(1).optional(),targetPersonaId:C().min(1),workerSessionId:C().min(1).optional(),taskText:C(),status:pN,outcome:U_.optional(),meta:nu(_a()).optional(),createdAt:C().min(1),completedAt:C().min(1).optional(),deliveredAt:C().min(1).optional()});D({sourceSessionId:C().min(1).optional()});D({records:be(IL)});D({dispatchId:C().min(1)});D({type:ee("personaDispatch:get:ok"),status:pN,outcome:U_.optional()});const RL=/^[a-z0-9][a-z0-9-]*$/;Qe(["stopped","starting","running","crashed","invalid"]);const ML=new Set(["localhost","127.0.0.1"]);function AL(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&ML.has(t.hostname))}const Ku=D({id:C().regex(RL),name:C().min(1),version:C().min(1),apiVersion:ee("1"),runtime:D({startCommand:C().min(1)}).passthrough().optional(),entry:D({url:C().url().refine(AL,{message:"INVALID_URL_SCHEME: only https or http://localhost is allowed"})}).strict().optional()}).passthrough().superRefine((e,t)=>{var i;const n=!!e.runtime,r=!!((i=e.entry)!=null&&i.url);n&&r&&t.addIssue({code:K.custom,message:"INVALID_MANIFEST: entry.url and runtime cannot coexist"}),!n&&!r&&t.addIssue({code:K.custom,message:"INVALID_MANIFEST: must have either entry.url or runtime"})}),jL=ai("kind",[D({kind:ee("local"),port:Y().int().min(1).max(65535)}),D({kind:ee("hosted"),url:C().url()})]);ai("state",[D({extId:C(),manifest:Ku,state:ee("stopped")}),D({extId:C(),manifest:Ku,state:ee("starting")}),D({extId:C(),manifest:Ku,state:ee("running"),target:jL}),D({extId:C(),manifest:Ku,state:ee("crashed")}),D({extId:C(),manifest:_a().nullable(),state:ee("invalid"),invalidReason:C().min(1)})]);D({snapshotHash:C().min(1),version:C().min(1),publishedAt:Y()});const DL=ai("kind",[D({kind:ee("p2p-tunnel"),ownerPrincipalId:C().min(1),extId:C().min(1)})]);ai("kind",[D({kind:ee("p2p-tunnel"),ownerPrincipalId:C().min(1),extId:C().min(1),snapshotHash:C().min(1)})]);D({extId:C().min(1),name:C().min(1),version:C().min(1),contentHash:C().min(1),publishedAt:Y()});const LL=ai("kind",[D({kind:ee("clean")}),D({kind:ee("ready-new-version"),fromVersion:C().min(1),toVersion:C().min(1)}),D({kind:ee("error-same-hash"),version:C().min(1)}),D({kind:ee("error-version-not-bumped"),localVersion:C().min(1),publishedVersion:C().min(1)}),D({kind:ee("error-version-regression"),localVersion:C().min(1),publishedVersion:C().min(1)})]);D({localManifest:D({name:C().min(1),version:C().min(1),contentHash:C().min(1)}),publishState:ai("kind",[D({kind:ee("unpublished")}),D({kind:ee("published"),version:C().min(1),contentHash:C().min(1),publishedAt:Y()})]),check:LL});D({extId:C().min(1),newVersion:C().min(1).nullish()});D({extId:C().min(1)});D({extId:C().min(1),snapshotHash:C().min(1)});D({channelRef:DL,snapshotHash:C().min(1),zipBase64:C().min(1)});D({id:C().min(1),peerDeviceId:C().min(1),senderDeviceId:C().min(1),text:C().min(1),createdAt:Y().int().nonnegative(),readBy:nu(C().min(1),Y().int().positive()).default({}),origin:D({kind:ee("persona"),personaId:C().min(1)}).optional()}).strict();D({peerDeviceId:C().min(1).optional(),id:C().min(1),text:C().min(1),createdAt:Y().int().nonnegative(),origin:D({kind:ee("persona"),personaId:C().min(1)}).optional()}).strict();D({peerDeviceId:C().min(1),sinceCreatedAt:Y().int().nonnegative().optional()}).strict();D({peerDeviceId:C().min(1),upToCreatedAt:Y().int().nonnegative()}).strict();D({peerDeviceId:C().min(1).optional(),text:C().min(1)});D({peerDeviceId:C().min(1).optional(),command:C().min(1),timeoutMs:Y().int().positive().optional()}).strict();D({type:ee("peerExec:run:ok"),stdout:C(),stderr:C(),exitCode:Y().int().nullable(),timedOut:Te(),stdoutTruncated:Te(),stderrTruncated:Te()}).strict();const mN=ai("kind",[D({kind:ee("at"),at:C().min(1)}),D({kind:ee("every"),everyMs:Y().int().positive(),anchorMs:Y().int().nonnegative().optional()}),D({kind:ee("cron"),expr:C().min(1),tz:C().min(1).optional()})]),ru=C().trim().min(1);D({personaId:ru,name:C().min(1),schedule:mN,prompt:C().min(1),targetPersona:C().min(1).optional(),timeoutMs:Y().int().positive().optional()});D({personaId:ru,onlyMine:Te().optional()});D({personaId:ru,shiftId:C().min(1)});const OL=D({name:C().min(1).optional(),schedule:mN.optional(),prompt:C().min(1).optional(),targetPersona:C().min(1).optional(),timeoutMs:Y().int().positive().optional(),enabled:Te().optional()});D({personaId:ru,shiftId:C().min(1),patch:OL});D({personaId:ru,shiftId:C().min(1),limit:Y().int().positive().optional()});const BL=D({personaId:C(),label:C(),model:C().optional(),public:Te(),iconKey:C().optional(),tool:C().optional(),createdAt:Y(),updatedAt:Y()}).strict(),zL=D({name:C().min(1),description:C().optional()}),$L=D({id:C().min(1)}),FL=D({permissions:D({defaultMode:C().optional(),allow:be(C()).optional(),deny:be(C()).optional()}).optional(),sandbox:D({enabled:Te().optional(),autoAllowBashIfSandboxed:Te().optional(),allowUnsandboxedCommands:Te().optional(),excludedCommands:be(C()).optional(),filesystem:D({denyRead:be(C()).optional(),allowRead:be(C()).optional(),denyWrite:be(C()).optional(),allowWrite:be(C()).optional()}).optional(),network:D({allowedDomains:be(C()).optional(),allowLocalBinding:Te().optional()}).optional()}).optional()});BL.extend({personality:C().optional(),skills:be(zL).optional(),plugins:be($L).optional(),sandboxSettings:FL.nullable().optional()});D({label:C().min(1),personality:C(),model:C().optional(),tool:C().optional(),public:Te().optional(),iconKey:C().optional()}).strict();D({personaId:C().min(1)});D({personaId:C().min(1),patch:D({label:C().min(1).optional(),model:C().optional(),tool:C().optional(),personality:C().optional(),public:Te().optional(),iconKey:C().nullable().optional()}).strict()}).strict();D({writableRoots:be(C()).optional(),denyRead:be(C()).optional(),network:Te().optional()}).strict();const gN=["ready","session:info","session:status","session:event","session:deleted","session:rewound","session:cleared","permission:request","session:question","session:question:cleared","pong","error","subscribed","unsubscribed","auth:ok","tunnel:ready","tunnel:exited","tunnel:unavailable","session:control","session:pty","contact:added","contact:pinned","contact:removed","contact:remote-access-updated","inbox:event","friend:reverseTokenOffered","auth:login:done","auth:login:failed","appBuilder:project-updated","appBuilder:publish-progress","appBuilder:publish-failed"],vN=["idle","running","running-idle","stopped","error","observing"],HL=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools"],UL=["builtin","global","project","plugin"],WL=["builtin","global","project","policy","plugin"],_N=Qe(["owner","guest"]);D({id:C().min(1),kind:_N,displayName:C(),feishuUnionId:C().optional()}).strict();const VL=D({did:C().min(1),displayName:C(),feishuUnionId:C().optional(),principal:_N}).strict(),qL=Qe(vN),KL=D({input_tokens:Y().int().nonnegative().optional(),cache_read_input_tokens:Y().int().nonnegative().optional(),cache_creation_input_tokens:Y().int().nonnegative().optional(),output_tokens:Y().int().nonnegative().optional()}),GL=D({inputTokens:Y().int().nonnegative(),outputTokens:Y().int().nonnegative(),cacheReadTokens:Y().int().nonnegative().optional(),cacheCreateTokens:Y().int().nonnegative().optional()}),xN={gitBranch:C().optional(),resolvedModel:C().optional(),contextUsage:GL.optional(),contextWindowSize:Y().int().positive().optional()},XL=D(xN),YL=D({id:C().min(1),label:C().min(1),description:C().optional(),contextWindowSize:Y().int().positive(),default:Te().optional()}),ZL=D({id:C().min(1),label:C().min(1),description:C().optional()}),QL=D({name:C().min(1),type:Qe(["string","select","toggle"]),label:C().min(1),description:C().optional(),options:be(D({value:C(),label:C(),description:C().optional()})).optional(),default:_a().optional(),scope:Qe(["core","tool-specific"])});D({tool:C().min(1)});const JL=D({rewind:Te(),subagents:Te(),tui:Te(),observe:Te(),fileSharing:Te(),fork:Te()});D({tool:C().min(1),toolSessionIdLabel:C().optional(),models:be(YL),permissionModes:be(ZL),configSchema:be(QL),features:JL});const eO=D({tool:C().min(1),pattern:C().min(1),createdAt:C().min(1).optional()});D({sessionId:C().min(1),cwd:C().min(1),tool:ee("claude").or(C().min(1)).default("claude"),toolSessionId:C().optional(),label:C().optional(),model:C().optional(),permissionMode:C().optional(),effort:C().optional(),...xN,permissionRules:be(eO).optional(),pinnedAt:Y().int().nonnegative().nullable().optional(),pinSortOrder:Y().int().nullable().optional(),unreadAt:C().min(1).nullable().optional(),iconKey:C().optional(),forkedFromSessionId:C().min(1).optional(),ephemeral:Te().optional(),ownerPersonaId:C().min(1).optional(),appBuilderProject:C().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),chatId:C().min(1).optional(),creatorPrincipalId:C().min(1).optional(),creatorDisplayName:C().min(1).optional(),creatorFeishuUnionId:C().min(1).optional(),originOwnerPrincipalId:C().min(1).optional(),originOwnerPersonaId:C().min(1).optional(),dispatchedFromSessionId:C().min(1).optional(),shiftFiredFromSessionId:C().min(1).optional(),createdAt:C().min(1),updatedAt:C().min(1)});const On={seq:Y().int().nonnegative().optional(),ts:C().optional(),uuid:C().optional()},tO=Qe(HL),nO=D({readCount:Y().int().nonnegative().optional(),searchCount:Y().int().nonnegative().optional(),bashCount:Y().int().nonnegative().optional(),editFileCount:Y().int().nonnegative().optional(),linesAdded:Y().int().nonnegative().optional(),linesRemoved:Y().int().nonnegative().optional(),otherToolCount:Y().int().nonnegative().optional()}),rO=D({oldStart:Y().int().nonnegative(),oldLines:Y().int().nonnegative(),newStart:Y().int().nonnegative(),newLines:Y().int().nonnegative(),lines:be(C())}),iO=D({agentId:C().optional(),agentType:C().optional(),status:C().optional(),prompt:C().optional(),filePath:C().optional(),structuredPatch:be(rO).optional(),stats:D({durationMs:Y().int().nonnegative().optional(),tokens:Y().int().nonnegative().optional(),toolUseCount:Y().int().nonnegative().optional(),toolStats:nO.optional(),usage:KL.optional()}).optional()}),sO=D({path:C(),content:C(),mtimeMs:Y().optional()}),oO=D({label:C().min(1),description:C().optional()}),yN=D({question:C().min(1),multiSelect:Te(),options:be(oO).min(1)});ai("kind",[D({...On,kind:ee("session_init"),toolSessionId:C().optional()}),D({...On,kind:ee("thinking"),text:C(),partialId:C().optional()}),D({...On,kind:ee("text"),text:C(),partialId:C().optional()}),D({...On,kind:ee("user_text"),text:C(),meta:tO.optional(),taskId:C().optional(),parentToolUseId:C().optional(),sender:VL.optional()}),D({...On,kind:ee("tool_call"),toolUseId:C(),tool:C(),toolKind:C().optional(),input:_a()}),D({...On,kind:ee("tool_result"),toolUseId:C(),output:_a().optional(),error:C().optional(),toolResultExtra:iO.optional(),sourceToolAssistantUUID:C().optional(),askQuestionAnswers:nu(C(),C()).optional()}),D({...On,kind:ee("attachment_memories"),memories:be(sO)}),D({...On,kind:ee("permission_request"),requestId:C(),tool:C(),input:_a(),toolUseId:C().optional()}),D({...On,kind:ee("ask_user_question"),toolUseId:C(),questions:be(yN)}),D({...On,kind:ee("turn_end")}),D({...On,kind:ee("subagent_progress"),toolUseId:C(),agentId:C(),status:Qe(["started","running","completed","failed"]),description:C().optional(),lastToolName:C().optional(),prompt:C().optional(),stats:D({durationMs:Y().int().nonnegative().optional(),tokens:Y().int().nonnegative().optional(),toolUseCount:Y().int().nonnegative().optional()}).optional()}),D({...On,kind:ee("error"),message:C()}),D({...On,kind:ee("meta_update"),patch:XL}),D({...On,kind:ee("meta-text"),text:C(),metaSource:Qe(["cc","owner"]).optional()})]);D({cwd:C().min(1).optional(),tool:C().optional(),label:C().optional(),model:C().optional(),permissionMode:C().optional(),effort:C().optional(),iconKey:C().optional(),forkedFromSessionId:C().min(1).optional(),ephemeral:Te().optional(),ownerPersonaId:C().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null,{message:"cwd 与 ownerPersonaId 至少传一个"});D({originOnly:Te().optional(),ownerPersonaId:C().min(1).optional(),limit:Y().int().positive().optional(),offset:Y().int().nonnegative().optional()});D({sessionId:C().min(1)});D({sessionId:C().min(1),patch:D({label:C().optional(),model:C().optional(),permissionMode:C().optional(),effort:C().optional(),cwd:C().optional(),iconKey:C().optional(),ephemeral:ee(!1).optional()})});D({sessionId:C().min(1),text:C()});D({sessionId:C().min(1),userMessageId:C().min(1),dryRun:Te().optional()});D({canRewind:Te(),error:C().optional(),filesChanged:be(C()).optional(),insertions:Y().int().nonnegative().optional(),deletions:Y().int().nonnegative().optional()});D({sessionId:C().min(1),userMessageId:C().min(1)});const aO=D({oldStart:Y().int().nonnegative(),oldLines:Y().int().nonnegative(),newStart:Y().int().nonnegative(),newLines:Y().int().nonnegative(),lines:be(C())}),lO=D({filePath:C().min(1),hunks:be(aO),insertions:Y().int().nonnegative(),deletions:Y().int().nonnegative(),status:Qe(["modified","added","deleted"]).optional()});D({canRewind:Te(),error:C().optional(),files:be(lO),totalInsertions:Y().int().nonnegative(),totalDeletions:Y().int().nonnegative()});D({userMessageIds:be(C())});D({sessionId:C().min(1),toolSessionId:C().min(1)});D({cwd:C().min(1),toolSessionId:C().min(1),messageUuid:C().min(1)});D({forkedToolSessionId:C().min(1),forkedFilePath:C().min(1)});D({sessionId:C().min(1),toolSessionId:C().min(1),jsonlPath:C().optional()});D({sessionId:C().min(1),afterSeq:Y().int().min(-1)});D({sessionId:C().min(1),permissionRequestId:C().min(1),allow:Te(),permanent:Te().optional(),pattern:C().optional()});D({projectPath:C().min(1)});D({sessionId:C().min(1),limit:Y().int().positive().max(5e3).optional(),offset:Y().int().nonnegative().optional(),slim:Te().optional()});D({cwd:C().min(1),toolSessionId:C().min(1)});D({cwd:C().min(1),toolSessionId:C().min(1),subagentId:C().min(1)});D({cwd:C().min(1).optional(),path:C().optional(),showHidden:Te().optional()});D({cwd:C().min(1),path:C().min(1)});D({cwd:C().min(1),tool:C().optional()});D({name:C().min(1),source:Qe(UL),path:C().optional(),description:C().optional(),plugin:C().optional()});const cO=D({name:C().min(1),source:Qe(WL),path:C().optional(),description:C().optional(),whenToUse:C().optional(),plugin:C().optional()});D({cwd:C().min(1),tool:C().optional()});D({agents:be(cO)});D({sessionId:C().optional()});D({sessionId:C().min(1).optional()});D({sessionId:C().min(1),pinned:Te()});D({type:ee("peerSession:upsert:ok")});D({sessionId:C().min(1)});D({type:ee("peerSession:remove:ok")});D({orderedIds:be(C().min(1)).min(1)});D({cwd:C().min(1)});D({isGitRoot:Te(),gitRoot:C().nullable()});D({cwd:C().min(1)});D({branch:C().nullable()});D({cwd:C().min(1)});D({branches:be(C()),head:C().nullable()});D({}).optional();const uO=D({cwd:C().min(1),updatedAt:C().min(1)});D({dirs:be(uO)});D({type:ee("session:question"),sessionId:C().min(1),toolUseId:C().min(1),requestId:C().min(1),questions:be(yN).min(1)});D({type:ee("session:question:cleared"),sessionId:C().min(1),toolUseId:C().min(1),answers:nu(C(),C()).optional()});D({sessionId:C().min(1),toolUseId:C().min(1),answers:nu(C(),C())});D({ok:ee(!0)});D({sessionId:C().min(1),toolUseId:C().min(1)});D({ok:ee(!0)});D({type:ee("auth"),token:C().min(1),scheme:ee("bearer").optional(),clientInfo:D({name:C().min(1),version:C().min(1),instanceId:C().min(1)}).optional()});D({type:ee("auth:ok"),version:C().min(1).optional(),protocolVersion:Y().int().nonnegative().optional()});D({type:ee("tunnel:ready"),url:C().min(1),subdomain:C().min(1)});D({type:ee("tunnel:exited"),code:Y().int().nullable(),subdomain:C().nullable(),url:C().nullable()});D({type:ee("tunnel:unavailable"),reason:C().min(1),failedAt:C().min(1)});const dO=D({sessionId:C().min(1),status:qL,freshSpawn:Te(),pendingPermissionRequestIds:be(C().min(1)),pendingQuestionToolUseIds:be(C().min(1))});D({type:ee("info"),version:C(),protocolVersion:Y(),hostname:C(),os:C(),tools:be(D({id:C(),available:Te()})),runningSessions:be(dO),tokenRole:Qe(bL).optional(),isLoopback:Te().optional(),httpBaseUrl:C().optional(),httpToken:C().optional(),daemonSource:Qe(["ota","packaged"]).optional(),globalCliVersion:C().nullable().optional()});const hO=6173,fO=6272,Xa=/^[a-z][a-z0-9-]{0,39}$/,iu=D({name:C().regex(Xa,{message:"kebab-case, 小写字母开头,只允许小写字母 / 数字 / -,最长 40 字符"}),port:Y().int().min(hO).max(fO),createdAt:C().datetime(),devCommand:C().min(1),prodUrl:C().url().optional(),readyPattern:C().optional(),publishJob:D({jobId:C().min(1),stage:Qe(["build","deploy","verify"]),startedAt:Y().int().nonnegative()}).optional()}),pO=["install-pending","installing","starting-dev-server","running","stopped","failed"],bN=Qe(pO),W_=iu.extend({isRunning:Te(),boundSessionId:C().nullable(),stage:bN.optional(),stageReason:C().optional(),publishJob:D({jobId:C().min(1),stage:Qe(["build","deploy","verify"]),startedAt:Y().int().nonnegative(),status:Qe(["in-flight","interrupted"])}).optional()});D({}).strict();D({projects:be(W_)}).strict();D({sessionId:C().min(1)}).strict();D({project:W_.nullable()}).strict();D({sessionId:C().min(1),name:C().min(1)}).strict();D({project:iu}).strict();D({name:C()}).strict();D({}).strict();D({name:C(),newPort:Y().int()}).strict();D({project:iu}).strict();D({name:C().regex(Xa),url:C().url()}).strict();D({project:iu}).strict();D({sessionId:C().min(1),force:Te().optional()}).strict();D({project:iu}).strict();const mO=["installing","failed"];D({sessionId:C().min(1),stage:Qe(mO),reason:C().optional()}).strict();D({ok:ee(!0)}).strict();D({sessionId:C().min(1)}).strict();D({ok:ee(!0)}).strict();D({type:ee("appBuilder:project-updated"),project:W_,stage:bN,stageReason:C().optional()}).strict();D({name:C().regex(Xa)});D({jobId:C().min(1),status:Qe(["started","already-publishing"])}).strict();D({name:C().regex(Xa)});D({ok:ee(!0)}).strict();D({type:ee("appBuilder:publish-progress"),name:C().regex(Xa),jobId:C().min(1),stage:Qe(["build","deploy","verify"]),status:Qe(["started","completed"])}).strict();D({type:ee("appBuilder:publish-failed"),name:C().regex(Xa),jobId:C().min(1),stage:Qe(["build","deploy","verify","unknown"]),errorSummary:C()}).strict();D({});const gO=["allowed","conditional","denied"],vO=Qe(gO),_O=D({name:C().min(1),status:vO,description:C().min(1),args:be(D({name:C(),required:Te()})).nullable(),reason:C().optional()});D({type:ee("meta:methods"),methods:be(_O)});const Cb=1,xO=["daemon","main","renderer"],yO=Qe(xO),bO=["debug","info","warn","error"],wO=Qe(bO);D({ts:Y().int(),source:yO,level:wO,msg:C(),ownerPrincipalId:C(),deviceId:C(),appVersion:C(),daemonVersion:C().optional(),os:C(),meta_json:C().optional(),sessionId:C().optional()});D({v:ee(1),visitorId:C().min(1),displayName:C(),provider:C(),iat:Y(),exp:Y()});const SO=D({visitorId:C(),displayName:C(),avatarUrl:C().optional(),provider:C(),firstSeen:Y(),lastSeen:Y()});D({visitors:be(SO)});const kO=new Set(["localhost","127.0.0.1","0.0.0.0","::1"]);let pi=null;function CO(){if(pi!==null)return pi;if(typeof window>"u")return pi=!1,!1;if(kO.has(window.location.hostname)||window.location.protocol==="file:")return pi=!0,!0;if(new URLSearchParams(window.location.search).get("debug")==="1"){pi=!0;try{sessionStorage.setItem("debug","1")}catch{}}else try{pi=sessionStorage.getItem("debug")==="1"}catch{pi=!1}return pi}function Ae(e,...t){CO()&&console.log(`[${e}][${new Date().toISOString()}]`,...t)}function Gu(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}const EO=e=>{const t=[1e3,2e3,4e3,8e3,16e3,3e4];return t[Math.min(e,t.length-1)]},NO=new Set(["auth:ok","pong","error"]),Eb=new Set(gN.filter(e=>!NO.has(e)));let TO=0;const Nb=()=>`r${++TO}`;function PO(e){let t=e.url,n=e.authToken,r=e.selfIdentity;const i=e.clientInfo,s=e.requestTimeoutMs??3e4,o=e.pingIntervalMs??3e4,a=e.watchdogMs??6e4,l=e.authTimeoutMs??1e4,c=e.backoffMs??EO;let u=null,d=!1,f=0,p=null,m=null,v=null,y=null,_=!1,x="disconnected";const b=new Map,w=new Map;let S=null;const k=(B,E)=>{var H;B==="ready"&&(S=E),(H=w.get(B))==null||H.forEach(q=>{try{q(E)}catch{}})},T=B=>{x!==B&&(x=B,k("status",B))},N=(B,E)=>{const H=w.get(B)??new Set;if(H.add(E),w.set(B,H),B==="ready"&&S!==null)try{E(S)}catch{}return()=>H.delete(E)},L=()=>{m&&(clearInterval(m),m=null),v&&(clearTimeout(v),v=null),y&&(clearTimeout(y),y=null)},P=()=>{v&&clearTimeout(v),v=setTimeout(()=>{try{u==null||u.close(4e3,"pong watchdog")}catch{}},a)},O=()=>{m&&clearInterval(m),m=setInterval(()=>{(u==null?void 0:u.readyState)===1&&u.send(JSON.stringify({type:"ping",requestId:Nb()}))},o),P()},I=B=>{for(const[,E]of b)clearTimeout(E.timer),E.reject(new Error(B));b.clear()},R=[],j=()=>{if(R.length===0)return;const B=R.splice(0);for(const E of B)(u==null?void 0:u.readyState)===1&&!_?E.doSend():(clearTimeout(E.timer),E.reject(new Error("NOT_CONNECTED")))},z=B=>{if(R.length===0)return;const E=R.splice(0);for(const H of E)clearTimeout(H.timer),H.reject(new Error(B))},$=()=>{if(d)return;const B=c(f);B<0||(k("daemon:reconnecting",{attempt:f+1,nextDelayMs:B,scheduledAt:Date.now()}),p&&clearTimeout(p),p=setTimeout(()=>{f+=1,A()},B))},F=B=>{P();const E=String(B.type??"");if(E==="auth:ok"){Ae("daemon-client","auth:ok received → connected",{url:t}),y&&(clearTimeout(y),y=null),_=!1,f=0,T("connected"),k("daemon:connected",{url:t}),O(),j();return}if(E==="pong")return;if(E==="ready"){const q=Number(B.protocolVersion??-1);q!==Cb&&k("daemon:version-mismatch",{daemonProtocol:q,supportedProtocol:Cb}),k("ready",B);return}const H=B.requestId;if(typeof H=="string"&&b.has(H)){const q=b.get(H);if(b.delete(H),clearTimeout(q.timer),E==="error"){const M=String(B.code??"ERR"),re=String(B.message??"unknown");q.reject(new Error(`${M}: ${re}`))}else Eb.has(E)&&k(E,B),q.resolve(B);return}Eb.has(E)&&k(E,B)},A=()=>{p&&(clearTimeout(p),p=null),Ae("daemon-client","connect →",{url:t,token:Gu(n),attempt:f}),T("connecting");let B;try{B=new WebSocket(t)}catch(E){T("disconnected"),k("daemon:disconnected",{reason:(E==null?void 0:E.message)??"ws constructor failed"}),$();return}u=B,_=!!n,B.onopen=()=>{if(B!==u){Ae("daemon-client","onopen → stale (replaced before opened), ignore");return}if(n){Ae("daemon-client","onopen → send auth frame",{token:Gu(n)});const E={type:"auth",token:n};r!=null&&r.principalId&&(E.selfPrincipalId=r.principalId),r!=null&&r.displayName&&(E.selfDisplayName=r.displayName),i&&(E.clientInfo=i),B.send(JSON.stringify(E)),y=setTimeout(()=>{try{B.close(4001,"auth handshake timeout")}catch{}},l)}else Ae("daemon-client","onopen → no token, treat as connected (daemon authMode=none)"),f=0,T("connected"),k("daemon:connected",{url:t}),O(),j()},B.onclose=E=>{if(B!==u){Ae("daemon-client","onclose → stale, ignore",{code:E.code,reason:E.reason});return}const H=E.reason||(E.code===1008?"auth failed":`close ${E.code}`);if(Ae("daemon-client","onclose →",{code:E.code,reason:H,awaitingAuth:_,manualStop:d}),L(),I(`connection closed: ${H}`),u=null,E.code===4401?T("revoked"):T("disconnected"),k("daemon:disconnected",{reason:H}),E.code===1008||E.code===4401){z(`connection closed: ${H}`);return}d?z(`connection closed: ${H}`):$()},B.onerror=()=>{},B.onmessage=E=>{if(B!==u)return;let H;try{H=JSON.parse(String(E.data))}catch{return}F(H)}};return{start(){d=!1,f=0,A()},stop(){d=!0,p&&(clearTimeout(p),p=null),L();try{u==null||u.close(1e3,"shutdown")}catch{}u=null,I("shutdown"),z("shutdown"),T("disconnected")},switchProfile(B){Ae("daemon-client","switchProfile →",{url:B.url,token:Gu(B.authToken)},"prev:",{url:t,token:Gu(n)}),t=B.url,n=B.authToken,B.selfIdentity!==void 0&&(r=B.selfIdentity),f=0,d=!0,p&&(clearTimeout(p),p=null),L(),I("switch profile"),z("switch profile");try{u==null||u.close(1e3,"switch profile")}catch{}u=null,d=!1,A()},request(B,E){return new Promise((H,q)=>{const M=Nb(),re=setTimeout(()=>{b.delete(M);const V=R.findIndex(pe=>pe.timer===re);V>=0&&R.splice(V,1),q(new Error(`request timeout: ${B}`))},s),oe=()=>{b.set(M,{resolve:V=>H(V),reject:q,timer:re}),u.send(JSON.stringify({...E,type:B,requestId:M}))};(u==null?void 0:u.readyState)===1&&!_?oe():d||u==null&&p==null?(clearTimeout(re),q(new Error("NOT_CONNECTED"))):R.push({doSend:oe,reject:q,timer:re})})},on:N,get isOpen(){return(u==null?void 0:u.readyState)===1&&!_},get url(){return t},getStatus(){return x}}}function IO(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}function RO(e){return e?{id:e.id,mode:e.mode,url:e.url,token:IO(e.token),name:e.name}:null}function Xu(e){return e?Array.isArray(e)?e.map(RO):{_notArray:typeof e,_value:e}:null}function Tb(e){return e==null?null:typeof e=="object"&&"value"in e?e.value:e}const MO="ws://127.0.0.1:18790",Pb="daemon:profiles",Ib="daemon:active-profile-id";function AO(){return Math.random().toString(36).slice(2,10)}function jO(e){const t=e.trim(),n=t.indexOf("#");if(n<0)return{url:t};const r=t.slice(0,n),i=new URLSearchParams(t.slice(n+1)).get("token")??void 0;return{url:r,token:i}}function DO(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.name=="string"&&(t.mode==="localhost"||t.mode==="remote")&&typeof t.url=="string"&&(t.token===void 0||typeof t.token=="string")}function wN(e){let t={profiles:[],activeId:null},n=!1,r=null;const i=new Set,s=()=>{for(const l of i)l(t)},o=async()=>{Ae("profile-store","persist →",Xu(t.profiles),"active:",t.activeId),await e.kv.set(Pb,t.profiles),await e.kv.set(Ib,t.activeId)},a=async()=>{if(!n){if(r){await r;return}r=(async()=>{var l;try{let c=null;try{const d=await e.kv.get(Pb);c=Tb(d)}catch{c=null}let u=null;try{const d=await e.kv.get(Ib);u=Tb(d)??null}catch{u=null}if(Ae("profile-store","ensureLoaded read kv →","profiles:",Xu(c),"activeId:",u),Array.isArray(c)&&c.length>0){const d=c.filter(DO),f=u&&d.some(p=>p.id===u)?u:((l=d[0])==null?void 0:l.id)??null;t={profiles:d,activeId:f},n=!0,Ae("profile-store","ensureLoaded → use kv profiles",Xu(d),"active:",f);return}t={profiles:[{id:"default",name:"本机",mode:"localhost",url:MO}],activeId:"default"},Ae("profile-store","ensureLoaded → fallback synthesized default (NO token)",Xu(t.profiles)),n=!0,await o()}finally{r=null}})(),await r}};return{async load(){return await a(),s(),t},async snapshot(){return await a(),t},async upsert(l){var y;await a();let c=l.url,u=l.token;if(c&&c.includes("#")){const _=jO(c);c=_.url,!u&&_.token&&(u=_.token)}const d=l.id?t.profiles.find(_=>_.id===l.id):void 0,f=u!=null&&u.trim()?u.trim():d==null?void 0:d.token;if(l.mode==="remote"&&!f)throw new Error("remote mode requires token");const p=l.id??AO(),m={id:p,name:((y=l.name)==null?void 0:y.trim())||(d==null?void 0:d.name)||(l.mode==="remote"?"远程":"本机"),mode:l.mode,url:c.trim(),token:f};return t={profiles:[...t.profiles.filter(_=>_.id!==p),m],activeId:p},await o(),s(),m},async delete(l){var d;await a();const c=t.profiles.filter(f=>f.id!==l);let u=t.activeId;u===l&&(u=((d=c[0])==null?void 0:d.id)??null),t={profiles:c,activeId:u},await o(),s()},async activate(l){await a(),t.profiles.some(c=>c.id===l)&&(t={...t,activeId:l},await o(),s())},subscribe(l){return i.add(l),()=>i.delete(l)},getActive(){return n?t.profiles.find(l=>l.id===t.activeId)??null:null}}}const Rb="clawd.client-instance-id";let LO={name:"clawd-web",version:"unknown"};function OO(){let e=null;try{e=localStorage.getItem(Rb),e||(e=crypto.randomUUID(),localStorage.setItem(Rb,e))}catch{e=e??crypto.randomUUID()}return{...LO,instanceId:e}}function Mb(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}const SN=g.createContext(null);function BO({host:e,children:t}){const[n,r]=g.useState(null),i=g.useMemo(()=>async()=>{const s=wN(e),o=await s.load(),a=o.profiles.find(c=>c.id===o.activeId)??o.profiles[0];if(!a)throw new Error("DaemonProvider: profile store has no profiles after load");return Ae("daemon-context","bootstrap → createDaemonClient",{id:a.id,url:a.url,token:Mb(a.token)}),{client:PO({url:a.url,authToken:a.token,clientInfo:OO()}),store:s}},[e]);return g.useEffect(()=>{let s=!0,o=null,a=null;return i().then(l=>{s&&(l.client.start(),o=l,r(l),a=l.store.subscribe(()=>{const c=l.store.getActive();if(!c){Ae("daemon-context","subscribe → no active profile, skip switchProfile");return}Ae("daemon-context","subscribe → switchProfile",{id:c.id,url:c.url,token:Mb(c.token)}),l.client.switchProfile({url:c.url,authToken:c.token})}))}),()=>{s=!1,a==null||a(),o==null||o.client.stop()}},[i]),n?h.jsx(SN.Provider,{value:n,children:t}):null}function Is(){const e=g.useContext(SN);if(!e)throw new Error("useDaemonClient must be used inside <DaemonProvider>");return e.client}function zO(){const e=Is(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i.mode,o=s==="tui"?"tui":"sdk";Ae("daemon-context","useDaemonMode ready.mode =",{rawMode:s,resolved:o}),n(o)}),[e]),t}const kN=g.createContext(null);function $O({cache:e,children:t}){return g.createElement(kN.Provider,{value:e},t)}function ko(){const e=g.useContext(kN);if(!e)throw new Error("useCache must be used inside <CacheProvider>");return e}function si(e){const t=ko(),n=g.useCallback(i=>t.observe(e,()=>i()),[t,e]),r=g.useCallback(()=>t.read(e),[t,e]);return g.useSyncExternalStore(n,r,r)}const CN={actionsLevel:"none",httpBaseUrl:null,httpToken:null},EN=g.createContext(CN);function Af(){return g.useContext(EN)}function FO(e){return e!=null&&e.httpBaseUrl?{actionsLevel:e.tokenRole==="owner"?"owner":"none",httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken??null}:CN}function HO(){const e=si("daemon-info");return g.useMemo(()=>FO(e),[e])}function UO({children:e}){const t=HO();return st.createElement(EN.Provider,{value:t},e)}function WO(e,t,n){if(!e.httpBaseUrl)return null;const r=encodeURIComponent(n);return`${e.httpBaseUrl}/session/${encodeURIComponent(t.sessionId)}/files?path=${r}`}function VO(e){const t=new Map;return{observe(n,r){let i=t.get(n);i||(i={data:void 0,hasData:!1,listeners:new Set},t.set(n,i));const s=l=>r(l);i.listeners.add(s);const o=i.listeners.size===1;s(i.hasData?i.data:void 0),o&&e.onFirstObserver(n);let a=!1;return()=>{if(a)return;a=!0;const l=t.get(n);l&&(l.listeners.delete(s),l.listeners.size===0&&(t.delete(n),e.onLastObserver(n)))}},read(n){const r=t.get(n);return r!=null&&r.hasData?r.data:void 0},setData(n,r){const i=t.get(n);if(!i)return;const s=i.hasData?i.data:void 0,o=r(s);i.data=o,i.hasData=!0;for(const a of i.listeners)a(o)}}}function qO(){const e=[],t=new Map,n=r=>{for(const i of e)if(i.pattern.test(r))return i.source;return null};return{register(r,i){e.push({pattern:r,source:i})},activate(r){if(t.has(r))return;const i=n(r);if(!i)throw new Error(`no source registered for key: ${r}`);t.set(r,i.start(r))},deactivate(r){const i=t.get(r);i&&(t.delete(r),i())}}}function KO(e){return{request:(t,n)=>e.request(t,n),onFrame(t){const n=[];for(const r of gN)n.push(e.on(r,i=>t(r,i)));return()=>{for(const r of n)r()}},onConnect(t){return e.on("daemon:connected",()=>t())},get isConnected(){return e.isOpen}}}function NN(e){const t=(e??"claude")==="claude";return{rewind:t,subagents:t,tui:t,observe:t,fileSharing:t,fork:t}}const GO=e=>({tool:e,models:[{id:"",label:"Default",contextWindowSize:2e5,default:!0}],permissionModes:[{id:"",label:"Default"}],configSchema:[],features:NN(e)});function XO(e,t){return{start(n){const r=n.replace(/^capabilities\//,"");let i=!1;const s=async()=>{try{const a=await e.request("capabilities:get",{tool:r});if(i)return;t(n,()=>a)}catch{if(i)return;t(n,()=>GO(r))}},o=e.onConnect(()=>{s()});return s(),()=>{i=!0,o()}}}}function YO(e,t){return{start(n){let r=!1;const i=async()=>{try{const a=await e.request("session:list",void 0);if(r)return;t(n,()=>a.sessions??[])}catch{}},s=e.onFrame((a,l)=>{if(a==="session:info"){const c=l;if(c.chatId!==void 0)return;t(n,u=>[c,...(u??[]).filter(d=>d.sessionId!==c.sessionId)])}else if(a==="session:deleted"){const c=l;t(n,u=>(u??[]).filter(d=>d.sessionId!==c.sessionId))}}),o=e.onConnect(()=>{i()});return i(),()=>{r=!0,s(),o()}}}}const Rc={sessionId:null,events:[],lastSeq:-1,pendingPermissions:[],status:"idle",pendingQuestions:{}};function Kp(e,t){const n=t;if(n.kind==="permission_request"&&typeof n.requestId=="string"){if(e.some(i=>i.requestId===n.requestId))return e;const r={requestId:n.requestId,tool:typeof n.tool=="string"?n.tool:"",input:n.input,...typeof n.toolUseId=="string"&&n.toolUseId?{toolUseId:n.toolUseId}:{}};return[...e,r]}if(n.kind==="tool_result"&&typeof n.toolUseId=="string"&&n.toolUseId){const r=e.findIndex(i=>i.toolUseId===n.toolUseId);if(r>=0)return e.filter((i,s)=>s!==r)}return e}function TN(e,t,n){const r=n===void 0?e.sessionId:n;switch(t.type){case"session:change":return{...Rc,sessionId:t.sessionId};case"session:event":{if(!r||t.sessionId!==r)return e;const i=typeof t.event.seq=="number"?t.event.seq:-1,s=[...e.events,t.event],o=i>e.lastSeq?i:e.lastSeq,a=Kp(e.pendingPermissions,t.event);return{...e,events:s,lastSeq:o,pendingPermissions:a}}case"session:status":return!r||t.sessionId!==r?e:{...e,status:t.status};case"session:events":{if(!r||t.sessionId!==r)return e;const i=t.events.map(o=>o.event),s=i.reduce((o,a)=>Kp(o,a),[]);return{...e,sessionId:t.sessionId,events:i,lastSeq:t.latestSeq,pendingPermissions:s}}case"session:events:append":{if(!r||t.sessionId!==r)return e;const i=new Set;for(const c of e.events){const u=c.seq;typeof u=="number"&&i.add(u)}const s=[];for(const c of t.events)typeof c.seq=="number"&&(i.has(c.seq)||s.push(c.event));const o=t.latestSeq>e.lastSeq?t.latestSeq:e.lastSeq;if(s.length===0)return o===e.lastSeq?e:{...e,lastSeq:o};const a=[...e.events,...s].sort((c,u)=>{const d=c.seq??-1,f=u.seq??-1;return d-f}),l=s.reduce((c,u)=>Kp(c,u),e.pendingPermissions);return{...e,events:a,lastSeq:o,pendingPermissions:l}}case"permission:request":{if(!r||t.sessionId!==r||e.pendingPermissions.some(s=>s.requestId===t.requestId))return e;const i={requestId:t.requestId,tool:t.tool,input:t.input,...t.toolUseId?{toolUseId:t.toolUseId}:{}};return{...e,pendingPermissions:[...e.pendingPermissions,i]}}case"permission:clear":{if(!r||r!==t.sessionId)return e;const i=t.requestId,s=e.pendingPermissions.findIndex(c=>c.requestId===i),o=s>=0?e.pendingPermissions.filter((c,u)=>u!==s):e.pendingPermissions;if(e.events.length===0)return o===e.pendingPermissions?e:{...e,pendingPermissions:o};const a=e.events.length-1,l=e.events[a];return l.kind==="permission_request"&&l.requestId===i?{...e,pendingPermissions:o,events:e.events.slice(0,a)}:o===e.pendingPermissions?e:{...e,pendingPermissions:o}}case"session:question":return!r||t.sessionId!==r?e:{...e,pendingQuestions:{...e.pendingQuestions,[t.toolUseId]:{toolUseId:t.toolUseId,requestId:t.requestId,questions:t.questions}}};case"session:question:clear":{if(!r||t.sessionId!==r||!(t.toolUseId in e.pendingQuestions))return e;const{[t.toolUseId]:i,...s}=e.pendingQuestions;return{...e,pendingQuestions:s}}case"session:question:submitted":{if(!r||t.sessionId!==r)return e;const i=e.pendingQuestions[t.toolUseId];return i?{...e,pendingQuestions:{...e.pendingQuestions,[t.toolUseId]:{...i,submittedAnswers:t.answers}}}:e}case"session:rewound":return!r||t.sessionId!==r?e:{...e,pendingPermissions:[],status:"idle"};case"ready":{if(!r)return e;const i=t.runningSessions.find(o=>o.sessionId===r);if(i!=null&&i.freshSpawn)return{...Rc,sessionId:r};const s=(i==null?void 0:i.status)??"idle";return s===e.status?e:{...e,status:s}}case"daemon:disconnected":return{...e,pendingPermissions:[]};default:return e}}const ZO="session/";function QO(e){return{sid:e.slice(ZO.length)}}const JO=new Set(vN);function PN(e){return JO.has(e)}function Ab(e){return PN(e)?e:"idle"}function eB(e,t){return{start(n){const{sid:r}=QO(n);let i=!1,s=-1;const o=f=>{t(n,p=>TN(p??Rc,f,r))},a=async f=>{const p=f==="baseline"?-1:s;try{const m=await e.request("session:events",{sessionId:r,afterSeq:p});if(i)return;const v=m.events??[],y=m.latestSeq??-1;if(f==="baseline")o({type:"session:events",sessionId:r,events:v,latestSeq:y}),s=y;else{const _=m.bufferStartSeq??0,x=y<p||_>p+1;o({type:x?"session:events":"session:events:append",sessionId:r,events:v,latestSeq:y}),s=Math.max(s,y)}}catch{}},l=async()=>{try{const f=await e.request("info");if(i)return;o({type:"ready",runningSessions:(f.runningSessions??[]).map(p=>({sessionId:p.sessionId,freshSpawn:p.freshSpawn,status:Ab(p.status)}))})}catch{}},c=async()=>{try{await e.request("session:subscribe",{sessionId:r})}catch{}i||(await a(s<0?"baseline":"delta"),!i&&await l())},u=e.onFrame((f,p)=>{if(!i)if(f==="session:event"){const m=p;if(m.sessionId!==r)return;const v=m.event.seq;Ae("session-events","push session:event",{sid:r,kind:m.event.kind,seq:v,lastSeqBefore:s}),o({type:"session:event",sessionId:m.sessionId,event:m.event}),typeof v=="number"&&v>s&&(s=v)}else if(f==="session:status"){const m=p;if(m.sessionId!==r)return;if(!PN(m.status)){Ae("session-events","push session:status drop",{sid:r,status:m.status});return}Ae("session-events","push session:status",{sid:r,status:m.status}),o({type:"session:status",sessionId:m.sessionId,status:m.status})}else if(f==="session:cleared"){if(p.sessionId!==r)return;Ae("session-events","push session:cleared",{sid:r}),o({type:"session:change",sessionId:r}),s=-1}else if(f==="permission:request"){const m=p;if(m.sessionId!==r)return;o({type:"permission:request",sessionId:m.sessionId,requestId:m.requestId,tool:m.tool,input:m.input,...typeof m.toolUseId=="string"&&m.toolUseId?{toolUseId:m.toolUseId}:{}})}else if(f==="session:question"){const m=p;if(m.sessionId!==r)return;o({type:"session:question",sessionId:m.sessionId,toolUseId:m.toolUseId,requestId:m.requestId,questions:m.questions})}else if(f==="session:question:cleared"){const m=p;if(m.sessionId!==r)return;m.answers&&Object.keys(m.answers).length>0?o({type:"session:question:submitted",sessionId:m.sessionId,toolUseId:m.toolUseId,answers:m.answers}):o({type:"session:question:clear",sessionId:m.sessionId,toolUseId:m.toolUseId})}else if(f==="session:rewound"){const m=p;if(m.sessionId!==r)return;o({type:"session:rewound",sessionId:m.sessionId,userMessageId:m.userMessageId})}else f==="ready"&&o({type:"ready",runningSessions:(p.runningSessions??[]).map(v=>({sessionId:v.sessionId,freshSpawn:v.freshSpawn,status:Ab(v.status)}))})}),d=e.onConnect(()=>{c()});return e.isConnected&&c(),()=>{i=!0,u(),d(),e.request("session:unsubscribe",{sessionId:r}).catch(()=>{})}}}}const tB=new Set(["tunnel:ready","tunnel:exited","tunnel:unavailable"]);function nB(e,t){return{start(n){let r=!1;const i=async()=>{try{const a=await e.request("info",void 0);if(r)return;t(n,()=>a)}catch{}},s=e.onConnect(()=>{i()}),o=e.onFrame(a=>{tB.has(a)&&i()});return i(),()=>{r=!0,s(),o()}}}}function rB(){return{start(){return()=>{}}}}function iB(e,t){return{start(n){let r=!1;const i=async()=>{try{const o=await e.request("persona:list",{});if(r)return;t(n,()=>o.personas??[])}catch{}},s=e.onConnect(()=>{i()});return i(),()=>{r=!0,s()}}}}function sB(e){const t=KO(e),n=qO();let r=null;const i=(o,a)=>{r==null||r.setData(o,a)};n.register(/^capabilities\//,XO(t,i)),n.register(/^sessions$/,YO(t,i)),n.register(/^session\//,eB(t,i)),n.register(/^personas$/,iB(t,i)),n.register(/^persona-detail\//,rB()),n.register(/^daemon-info$/,nB(t,i));const s=VO({onFirstObserver:o=>{o&&n.activate(o)},onLastObserver:o=>{o&&n.deactivate(o)}});return r=s,{cache:s,channel:t}}class V_{constructor(t){this.client=t}info(){return this.client.request("info")}attachmentSignUrl(t){return this.client.request("attachment.signUrl",t)}attachmentGroupAdd(t,n,r){return this.client.request("attachment.groupAdd",{sessionId:t,relPath:n,...r?{label:r}:{}})}attachmentGroupRemove(t,n){return this.client.request("attachment.groupRemove",{sessionId:t,relPath:n})}attachmentGroupList(t){return this.client.request("attachment.groupList",{sessionId:t})}sessionCreate(t){return this.client.request("session:create",t)}appBuilderListProjects(){return this.client.request("appBuilder:listProjects",{})}appBuilderGetProject(t){return this.client.request("appBuilder:getProject",{sessionId:t})}appBuilderUpdateProjectPort(t,n){return this.client.request("appBuilder:updateProjectPort",{name:t,newPort:n})}appBuilderStartDevServer(t,n){return this.client.request("appBuilder:startDevServer",{sessionId:t,...n!=null&&n.force?{force:!0}:{}})}appBuilderStopDevServer(t){return this.client.request("appBuilder:stopDevServer",{sessionId:t})}appBuilderPublish(t){return this.client.request("appBuilder:publish",{name:t})}appBuilderDismissPublishJob(t){return this.client.request("appBuilder:dismissPublishJob",{name:t})}sessionList(){return this.client.request("session:list")}sessionGet(t){return this.client.request("session:get",{sessionId:t})}sessionUpdate(t,n){return this.client.request("session:update",{sessionId:t,patch:n})}sessionDelete(t){return this.client.request("session:delete",{sessionId:t})}sessionSend(t,n){return this.client.request("session:send",{sessionId:t,text:n})}sessionStop(t){return this.client.request("session:stop",{sessionId:t})}sessionInterrupt(t){return this.client.request("session:interrupt",{sessionId:t})}sessionRewind(t){return this.client.request("session:rewind",t)}sessionRewindableMessageIds(t){return this.client.request("session:rewindable-message-ids",{sessionId:t})}sessionRewindDiff(t){return this.client.request("session:rewind-diff",t)}sessionNew(t){return this.client.request("session:new",{sessionId:t})}sessionFork(t){return this.client.request("session:fork",t)}sessionResume(t,n){return this.client.request("session:resume",{sessionId:t,toolSessionId:n})}sessionObserve(t){return this.client.request("session:observe",t)}sessionEvents(t,n){return this.client.request("session:events",{sessionId:t,afterSeq:n})}sessionSubscribe(t){return this.client.request("session:subscribe",{sessionId:t})}sessionUnsubscribe(t){return this.client.request("session:unsubscribe",{sessionId:t})}pinSession(t,n){return this.client.request("session:pin",{sessionId:t,pinned:n})}markSessionRead(t){return this.client.request("session:markRead",{sessionId:t})}reorderPins(t){return this.client.request("session:reorderPins",{orderedIds:t})}peerSessionUpsert(t){return this.client.request("peerSession:upsert",t)}peerSessionRemove(t){return this.client.request("peerSession:remove",{sessionId:t})}permissionRespond(t){return this.client.request("permission:respond",t)}answerQuestion(t){return this.client.request("session:answerQuestion",t)}cancelQuestion(t){return this.client.request("session:cancelQuestion",t)}historyProjects(){return this.client.request("history:projects")}historyList(t){return this.client.request("history:list",{projectPath:t})}historyRead(t){return this.client.request("history:read",t)}historySubagents(t){return this.client.request("history:subagents",t)}historySubagentRead(t){return this.client.request("history:subagent-read",t)}listRecentDirs(){return this.client.request("history:recentDirs",{})}getGitRoot(t){return this.client.request("git:root",{cwd:t})}getGitBranch(t){return this.client.request("git:branch",{cwd:t})}listGitBranches(t){return this.client.request("git:branches",{cwd:t})}personaCreate(t){return this.client.request("persona:create",t)}personaList(){return this.client.request("persona:list",{})}personaGet(t){return this.client.request("persona:get",{personaId:t})}personaUpdate(t,n){return this.client.request("persona:update",{personaId:t,patch:n})}personaDelete(t){return this.client.request("persona:delete",{personaId:t})}visitorList(){return this.client.request("visitor:list",{})}workspaceList(t={}){return this.client.request("workspace:list",t)}workspaceRead(t){return this.client.request("workspace:read",t)}skillsList(t,n){return this.client.request("skills:list",{cwd:t,...n?{tool:n}:{}})}agentsList(t,n){return this.client.request("agents:list",{cwd:t,...n?{tool:n}:{}})}capabilitiesGet(t="claude"){return this.client.request("capabilities:get",{tool:t})}shiftList(){return this.client.request("shift:list")}}function oB(e){const[t,n]=g.useState(e.isOpen?{kind:"connected",url:""}:{kind:"connecting"});return g.useEffect(()=>{const r=e.on("ready",l=>{const c=l;n(u=>({kind:"connected",url:u.kind==="connected"?u.url:"",mode:u.kind==="connected"?u.mode:void 0,daemonVersion:c.version,protocolVersion:c.protocolVersion,daemonSource:c.daemonSource,globalCliVersion:c.globalCliVersion}))}),i=e.on("daemon:connected",l=>{const c=l;n(u=>({kind:"connected",url:c.url,mode:c.mode,daemonVersion:u.kind==="connected"?u.daemonVersion:void 0,protocolVersion:u.kind==="connected"?u.protocolVersion:void 0,daemonSource:u.kind==="connected"?u.daemonSource:void 0,globalCliVersion:u.kind==="connected"?u.globalCliVersion:void 0}))}),s=e.on("daemon:disconnected",l=>{const c=(l==null?void 0:l.reason)??"";/auth failed|auth timeout|auth required|auth handshake timeout/i.test(c)?n({kind:"auth-failed",reason:c}):n({kind:"disconnected",reason:c})}),o=e.on("daemon:reconnecting",l=>{const c=l;n({kind:"reconnecting",attempt:c.attempt,nextDelayMs:c.nextDelayMs,scheduledAt:c.scheduledAt??Date.now()})}),a=e.on("daemon:version-mismatch",l=>{const c=l;n({kind:"version-mismatch",daemonProtocol:c.daemonProtocol,supportedProtocol:c.supportedProtocol})});return()=>{r(),i(),s(),o(),a()}},[e]),t}function aB(e){const t=ko(),n=si(e.kind==="connected"?"sessions":""),r=g.useCallback(async()=>{t.setData("sessions",i=>i??[])},[t]);return{sessions:n??[],loading:!1,loaded:n!==void 0,error:null,refresh:r}}function Ya(){const e=Is();return g.useMemo(()=>new V_(e),[e])}function IN(e){return{personaId:e.personaId,label:e.label,model:e.model,tool:e.tool,iconKey:e.iconKey,public:e.public,createdAt:e.createdAt,updatedAt:e.updatedAt}}function RN(){const e=ko(),t=Ya(),n=si("personas")??[],r=g.useMemo(()=>n.map(s=>IN(s)),[n]),i=g.useCallback(async()=>{const s=await t.personaList();e.setData("personas",()=>s.personas??[])},[t,e]);return{personas:r,raw:n,loaded:si("personas")!==void 0,refresh:i}}function MN(e){const{raw:t}=RN(),n=ko(),r=Ya(),i=e?t.find(a=>a.personaId===e)??null:null,s=i?IN(i):null,o=g.useCallback(async()=>{if(!e)return;const a=await r.personaList();n.setData("personas",()=>a.personas??[])},[e,r,n]);return{persona:s,raw:i,loaded:!!s,refresh:o}}function lB(e){const t=Ya(),n=ko(),r=e?`persona-detail/${e}`:"",i=si(r),s=g.useCallback(async()=>{const o={personality:"",skills:[],plugins:[],sandboxSettings:null};if(!e)return o;const a=await t.personaGet(e);let l;if("persona"in a&&a.persona===null)l=o;else{const c=a;l={personality:c.personality??"",skills:c.skills??[],plugins:c.plugins??[],sandboxSettings:c.sandboxSettings??null}}return n.setData(r,()=>l),l},[t,n,e,r]);return g.useEffect(()=>{e&&s()},[e,s]),{personality:(i==null?void 0:i.personality)??"",skills:(i==null?void 0:i.skills)??[],plugins:(i==null?void 0:i.plugins)??[],sandboxSettings:(i==null?void 0:i.sandboxSettings)??null,loaded:i!==void 0,refresh:s}}function AN(){const e=ko(),t=Ya();return g.useCallback(async()=>{const n=await t.personaList();e.setData("personas",()=>n.personas??[])},[e,t])}function cB(){const e=Ya(),t=AN();return g.useCallback(async(n,r)=>{const i=await e.personaUpdate(n,r);return await t(),i},[e,t])}function uB(){const e=Ya(),t=AN();return g.useCallback(async n=>{await e.personaDelete(n),await t()},[e,t])}const jb="clawd:sidebar:tree-collapsed";function dB(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function hB(e){const t=dB(e);if(!Array.isArray(t))return new Set;const n=new Set;for(const r of t)typeof r=="string"&&n.add(r);return n}function fB(){const e=P_(),[t,n]=g.useState(()=>new Set),r=g.useRef(t);r.current=t,g.useEffect(()=>{let l=!1;return(async()=>{try{const c=await e.kv.get(jb);if(l)return;n(hB(c))}catch{}})(),()=>{l=!0}},[e]);const i=g.useCallback(l=>{e.kv.set(jb,[...l]).catch(()=>{})},[e]),s=g.useCallback(l=>r.current.has(l),[]),o=g.useCallback(l=>{n(c=>{const u=new Set(c);return u.has(l)?u.delete(l):u.add(l),i(u),u})},[i]),a=g.useCallback(l=>{n(c=>{let u=!1;const d=new Set;for(const f of c)l.has(f)?d.add(f):u=!0;return u?(i(d),d):c})},[i]);return{isCollapsed:s,toggle:o,prune:a}}const q_=g.createContext(null);function pB(){const e=g.useContext(q_);if(!e)throw new Error("SessionTreeCollapsedContext.Provider missing — wrap SessionTreeNode tree with <SessionTreeCollapsedContext.Provider value={useSessionTreeCollapsed()}>");return e}/**
96
96
  * @license lucide-react v0.577.0 - ISC
97
97
  *
98
98
  * This source code is licensed under the ISC license.
@@ -485,7 +485,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
485
485
  `)},O8=0,Fo=[];function B8(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(O8++)[0],s=g.useState(JT)[0],o=g.useRef(e);g.useEffect(function(){o.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var v=s8([e.lockRef.current],(e.shards||[]).map(hw),!0).filter(Boolean);return v.forEach(function(y){return y.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,y){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var _=rd(v),x=n.current,b="deltaX"in v?v.deltaX:x[0]-_[0],w="deltaY"in v?v.deltaY:x[1]-_[1],S,k=v.target,T=Math.abs(b)>Math.abs(w)?"h":"v";if("touches"in v&&T==="h"&&k.type==="range")return!1;var N=window.getSelection(),L=N&&N.anchorNode,P=L?L===k||L.contains(k):!1;if(P)return!1;var O=uw(T,k);if(!O)return!0;if(O?S=T:(S=T==="v"?"h":"v",O=uw(T,k)),!O)return!1;if(!r.current&&"changedTouches"in v&&(b||w)&&(r.current=S),!S)return!0;var I=r.current||S;return j8(I,y,v,I==="h"?b:w)},[]),l=g.useCallback(function(v){var y=v;if(!(!Fo.length||Fo[Fo.length-1]!==s)){var _="deltaY"in y?dw(y):rd(y),x=t.current.filter(function(S){return S.name===y.type&&(S.target===y.target||y.target===S.shadowParent)&&D8(S.delta,_)})[0];if(x&&x.should){y.cancelable&&y.preventDefault();return}if(!x){var b=(o.current.shards||[]).map(hw).filter(Boolean).filter(function(S){return S.contains(y.target)}),w=b.length>0?a(y,b[0]):!o.current.noIsolation;w&&y.cancelable&&y.preventDefault()}}},[]),c=g.useCallback(function(v,y,_,x){var b={name:v,delta:y,target:_,should:x,shadowParent:z8(_)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(w){return w!==b})},1)},[]),u=g.useCallback(function(v){n.current=rd(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,dw(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,rd(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return Fo.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,$o),document.addEventListener("touchmove",l,$o),document.addEventListener("touchstart",u,$o),function(){Fo=Fo.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,$o),document.removeEventListener("touchmove",l,$o),document.removeEventListener("touchstart",u,$o)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:L8(i)}):null,p?g.createElement(N8,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function z8(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const $8=p8(QT,B8);var cx=g.forwardRef(function(e,t){return g.createElement(Hf,Gr({},e,{ref:t,sideCar:$8}))});cx.classNames=Hf.classNames;var Mv=["Enter"," "],F8=["ArrowDown","PageUp","Home"],rP=["ArrowUp","PageDown","End"],H8=[...F8,...rP],U8={ltr:[...Mv,"ArrowRight"],rtl:[...Mv,"ArrowLeft"]},W8={ltr:["ArrowLeft"],rtl:["ArrowRight"]},cu="Menu",[Lc,V8,q8]=dT(cu),[No,iP]=Eo(cu,[q8,Ff,UT]),Uf=Ff(),sP=UT(),[K8,To]=No(cu),[G8,uu]=No(cu),oP=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Uf(t),[l,c]=g.useState(null),u=g.useRef(!1),d=Mi(s),f=hT(i);return g.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),h.jsx(BT,{...a,children:h.jsx(K8,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(G8,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};oP.displayName=cu;var X8="MenuAnchor",ux=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Uf(n);return h.jsx(zT,{...i,...r,ref:t})});ux.displayName=X8;var dx="MenuPortal",[Y8,aP]=No(dx,{forceMount:void 0}),lP=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=To(dx,t);return h.jsx(Y8,{scope:t,forceMount:n,children:h.jsx(zi,{present:n||s.open,children:h.jsx(lx,{asChild:!0,container:i,children:r})})})};lP.displayName=dx;var vr="MenuContent",[Z8,hx]=No(vr),cP=g.forwardRef((e,t)=>{const n=aP(vr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=To(vr,e.__scopeMenu),o=uu(vr,e.__scopeMenu);return h.jsx(Lc.Provider,{scope:e.__scopeMenu,children:h.jsx(zi,{present:r||s.open,children:h.jsx(Lc.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(Q8,{...i,ref:t}):h.jsx(J8,{...i,ref:t})})})})}),Q8=g.forwardRef((e,t)=>{const n=To(vr,e.__scopeMenu),r=g.useRef(null),i=qt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return XT(s)},[]),h.jsx(fx,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),J8=g.forwardRef((e,t)=>{const n=To(vr,e.__scopeMenu);return h.jsx(fx,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),e9=jc("MenuContent.ScrollLock"),fx=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...v}=e,y=To(vr,n),_=uu(vr,n),x=Uf(n),b=sP(n),w=V8(n),[S,k]=g.useState(null),T=g.useRef(null),N=qt(t,T,y.onContentChange),L=g.useRef(0),P=g.useRef(""),O=g.useRef(0),I=g.useRef(null),R=g.useRef("right"),j=g.useRef(0),z=m?cx:g.Fragment,$=m?{as:e9,allowPinchZoom:!0}:void 0,F=B=>{var pe,Oe;const E=P.current+B,H=w().filter(ie=>!ie.disabled),q=document.activeElement,M=(pe=H.find(ie=>ie.ref.current===q))==null?void 0:pe.textValue,re=H.map(ie=>ie.textValue),oe=h9(re,E,M),V=(Oe=H.find(ie=>ie.textValue===oe))==null?void 0:Oe.ref.current;(function ie(Me){P.current=Me,window.clearTimeout(L.current),Me!==""&&(L.current=window.setTimeout(()=>ie(""),1e3))})(E),V&&setTimeout(()=>V.focus())};g.useEffect(()=>()=>window.clearTimeout(L.current),[]),mT();const A=g.useCallback(B=>{var H,q;return R.current===((H=I.current)==null?void 0:H.side)&&p9(B,(q=I.current)==null?void 0:q.area)},[]);return h.jsx(Z8,{scope:n,searchRef:P,onItemEnter:g.useCallback(B=>{A(B)&&B.preventDefault()},[A]),onItemLeave:g.useCallback(B=>{var E;A(B)||((E=T.current)==null||E.focus(),k(null))},[A]),onTriggerLeave:g.useCallback(B=>{A(B)&&B.preventDefault()},[A]),pointerGraceTimerRef:O,onPointerGraceIntentChange:g.useCallback(B=>{I.current=B},[]),children:h.jsx(z,{...$,children:h.jsx(J_,{asChild:!0,trapped:i,onMountAutoFocus:Pe(s,B=>{var E;B.preventDefault(),(E=T.current)==null||E.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(Lf,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(e8,{asChild:!0,...b,dir:_.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:k,onEntryFocus:Pe(l,B=>{_.isUsingKeyboardRef.current||B.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx($T,{role:"menu","aria-orientation":"vertical","data-state":CP(y.open),"data-radix-menu-content":"",dir:_.dir,...x,...v,ref:N,style:{outline:"none",...v.style},onKeyDown:Pe(v.onKeyDown,B=>{const H=B.target.closest("[data-radix-menu-content]")===B.currentTarget,q=B.ctrlKey||B.altKey||B.metaKey,M=B.key.length===1;H&&(B.key==="Tab"&&B.preventDefault(),!q&&M&&F(B.key));const re=T.current;if(B.target!==re||!H8.includes(B.key))return;B.preventDefault();const V=w().filter(pe=>!pe.disabled).map(pe=>pe.ref.current);rP.includes(B.key)&&V.reverse(),u9(V)}),onBlur:Pe(e.onBlur,B=>{B.currentTarget.contains(B.target)||(window.clearTimeout(L.current),P.current="")}),onPointerMove:Pe(e.onPointerMove,Oc(B=>{const E=B.target,H=j.current!==B.clientX;if(B.currentTarget.contains(E)&&H){const q=B.clientX>j.current?"right":"left";R.current=q,j.current=B.clientX}}))})})})})})})});cP.displayName=vr;var t9="MenuGroup",px=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{role:"group",...r,ref:t})});px.displayName=t9;var n9="MenuLabel",uP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{...r,ref:t})});uP.displayName=n9;var Bh="MenuItem",fw="menu.itemSelect",Wf=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=uu(Bh,e.__scopeMenu),a=hx(Bh,e.__scopeMenu),l=qt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(fw,{bubbles:!0,cancelable:!0});d.addEventListener(fw,p=>r==null?void 0:r(p),{once:!0}),uT(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(dP,{...i,ref:l,disabled:n,onClick:Pe(e.onClick,u),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Pe(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Pe(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||Mv.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});Wf.displayName=Bh;var dP=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=hx(Bh,n),a=sP(n),l=g.useRef(null),c=qt(t,l),[u,d]=g.useState(!1),[f,p]=g.useState("");return g.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),h.jsx(Lc.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(t8,{asChild:!0,...a,focusable:!r,children:h.jsx(Et.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Pe(e.onPointerMove,Oc(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(e.onPointerLeave,Oc(m=>o.onItemLeave(m))),onFocus:Pe(e.onFocus,()=>d(!0)),onBlur:Pe(e.onBlur,()=>d(!1))})})})}),r9="MenuCheckboxItem",hP=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(vP,{scope:e.__scopeMenu,checked:n,children:h.jsx(Wf,{role:"menuitemcheckbox","aria-checked":zh(n)?"mixed":n,...i,ref:t,"data-state":gx(n),onSelect:Pe(i.onSelect,()=>r==null?void 0:r(zh(n)?!0:!n),{checkForDefaultPrevented:!1})})})});hP.displayName=r9;var fP="MenuRadioGroup",[i9,s9]=No(fP,{value:void 0,onValueChange:()=>{}}),pP=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=Mi(r);return h.jsx(i9,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(px,{...i,ref:t})})});pP.displayName=fP;var mP="MenuRadioItem",gP=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=s9(mP,e.__scopeMenu),s=n===i.value;return h.jsx(vP,{scope:e.__scopeMenu,checked:s,children:h.jsx(Wf,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":gx(s),onSelect:Pe(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});gP.displayName=mP;var mx="MenuItemIndicator",[vP,o9]=No(mx,{checked:!1}),_P=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=o9(mx,n);return h.jsx(zi,{present:r||zh(s.checked)||s.checked===!0,children:h.jsx(Et.span,{...i,ref:t,"data-state":gx(s.checked)})})});_P.displayName=mx;var a9="MenuSeparator",xP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});xP.displayName=a9;var l9="MenuArrow",yP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Uf(n);return h.jsx(FT,{...i,...r,ref:t})});yP.displayName=l9;var c9="MenuSub",[jne,bP]=No(c9),Ll="MenuSubTrigger",wP=g.forwardRef((e,t)=>{const n=To(Ll,e.__scopeMenu),r=uu(Ll,e.__scopeMenu),i=bP(Ll,e.__scopeMenu),s=hx(Ll,e.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>u,[u]),g.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),h.jsx(ux,{asChild:!0,...c,children:h.jsx(dP,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":CP(n.open),...e,ref:ou(t,i.onTriggerChange),onClick:d=>{var f;(f=e.onClick)==null||f.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Pe(e.onPointerMove,Oc(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Pe(e.onPointerLeave,Oc(d=>{var p,m;u();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const v=(m=n.content)==null?void 0:m.dataset.side,y=v==="right",_=y?-5:5,x=f[y?"left":"right"],b=f[y?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+_,y:d.clientY},{x,y:f.top},{x:b,y:f.top},{x:b,y:f.bottom},{x,y:f.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Pe(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||U8[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});wP.displayName=Ll;var SP="MenuSubContent",kP=g.forwardRef((e,t)=>{const n=aP(vr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=To(vr,e.__scopeMenu),o=uu(vr,e.__scopeMenu),a=bP(SP,e.__scopeMenu),l=g.useRef(null),c=qt(t,l);return h.jsx(Lc.Provider,{scope:e.__scopeMenu,children:h.jsx(zi,{present:r||s.open,children:h.jsx(Lc.Slot,{scope:e.__scopeMenu,children:h.jsx(fx,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:c,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var d;o.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:Pe(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Pe(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Pe(e.onKeyDown,u=>{var p;const d=u.currentTarget.contains(u.target),f=W8[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});kP.displayName=SP;function CP(e){return e?"open":"closed"}function zh(e){return e==="indeterminate"}function gx(e){return zh(e)?"indeterminate":e?"checked":"unchecked"}function u9(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function d9(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function h9(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=d9(e,Math.max(s,0));i.length===1&&(o=o.filter(c=>c!==n));const l=o.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function f9(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function p9(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return f9(n,t)}function Oc(e){return t=>t.pointerType==="mouse"?e(t):void 0}var m9=oP,g9=ux,v9=lP,_9=cP,x9=px,y9=uP,b9=Wf,w9=hP,S9=pP,k9=gP,C9=_P,E9=xP,N9=yP,T9=wP,P9=kP,Vf="DropdownMenu",[I9]=Eo(Vf,[iP]),Mn=iP(),[R9,EP]=I9(Vf),NP=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=Mn(t),c=g.useRef(null),[u,d]=Df({prop:i,defaultProp:s??!1,onChange:o,caller:Vf});return h.jsx(R9,{scope:t,triggerId:to(),triggerRef:c,contentId:to(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(m9,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};NP.displayName=Vf;var TP="DropdownMenuTrigger",PP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=EP(TP,n),o=Mn(n);return h.jsx(g9,{asChild:!0,...o,children:h.jsx(Et.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:ou(t,s.triggerRef),onPointerDown:Pe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Pe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});PP.displayName=TP;var M9="DropdownMenuPortal",IP=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Mn(t);return h.jsx(v9,{...r,...n})};IP.displayName=M9;var RP="DropdownMenuContent",MP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=EP(RP,n),s=Mn(n),o=g.useRef(!1);return h.jsx(_9,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Pe(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Pe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!i.modal||u)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});MP.displayName=RP;var A9="DropdownMenuGroup",j9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(x9,{...i,...r,ref:t})});j9.displayName=A9;var D9="DropdownMenuLabel",AP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(y9,{...i,...r,ref:t})});AP.displayName=D9;var L9="DropdownMenuItem",jP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(b9,{...i,...r,ref:t})});jP.displayName=L9;var O9="DropdownMenuCheckboxItem",DP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(w9,{...i,...r,ref:t})});DP.displayName=O9;var B9="DropdownMenuRadioGroup",z9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(S9,{...i,...r,ref:t})});z9.displayName=B9;var $9="DropdownMenuRadioItem",F9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(k9,{...i,...r,ref:t})});F9.displayName=$9;var H9="DropdownMenuItemIndicator",LP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(C9,{...i,...r,ref:t})});LP.displayName=H9;var U9="DropdownMenuSeparator",OP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(E9,{...i,...r,ref:t})});OP.displayName=U9;var W9="DropdownMenuArrow",V9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(N9,{...i,...r,ref:t})});V9.displayName=W9;var q9="DropdownMenuSubTrigger",K9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(T9,{...i,...r,ref:t})});K9.displayName=q9;var G9="DropdownMenuSubContent",X9=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(P9,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});X9.displayName=G9;var Y9=NP,Z9=PP,Q9=IP,BP=MP,zP=AP,$P=jP,FP=DP,J9=LP,HP=OP;const UP=Y9,WP=Z9,vx=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(Q9,{children:h.jsx(BP,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));vx.displayName=BP.displayName;const Ys=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx($P,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Ys.displayName=$P.displayName;const eH=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(FP,{ref:i,checked:n,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-7 pr-2 text-sm outline-none","focus:bg-bg-200 focus:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(J9,{children:h.jsx(Za,{className:"h-3.5 w-3.5"})})}),t]}));eH.displayName=FP.displayName;const VP=g.forwardRef(({className:e,...t},n)=>h.jsx(HP,{ref:n,className:ne("-mx-1 my-1 h-px bg-border",e),...t}));VP.displayName=HP.displayName;const tH=g.forwardRef(({className:e,...t},n)=>h.jsx(zP,{ref:n,className:ne("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));tH.displayName=zP.displayName;function nH({iconKey:e,className:t}){const n=lT(e);if(!n)return h.jsx(K_,{className:ne("w-3.5 h-3.5 shrink-0 text-text-400",t),"data-testid":"session-icon-default","aria-label":"未分类"});const r=n.Icon;return h.jsx(r,{className:ne("w-3.5 h-3.5 shrink-0",n.colorClass,t),"data-testid":`session-icon-${n.key}`,"aria-label":n.label})}var rH=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),iH="VisuallyHidden",qP=g.forwardRef((e,t)=>h.jsx(Et.span,{...e,ref:t,style:{...rH,...e.style}}));qP.displayName=iH;var sH=qP,[qf]=Eo("Tooltip",[Ff]),Kf=Ff(),KP="TooltipProvider",oH=700,Av="tooltip.open",[aH,_x]=qf(KP),GP=e=>{const{__scopeTooltip:t,delayDuration:n=oH,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=g.useRef(!0),a=g.useRef(!1),l=g.useRef(0);return g.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),h.jsx(aH,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:g.useCallback(()=>{window.clearTimeout(l.current),o.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:g.useCallback(c=>{a.current=c},[]),disableHoverableContent:i,children:s})};GP.displayName=KP;var Bc="Tooltip",[lH,Gf]=qf(Bc),XP=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=_x(Bc,e.__scopeTooltip),c=Kf(t),[u,d]=g.useState(null),f=to(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,y=g.useRef(!1),[_,x]=Df({prop:r,defaultProp:i??!1,onChange:T=>{T?(l.onOpen(),document.dispatchEvent(new CustomEvent(Av))):l.onClose(),s==null||s(T)},caller:Bc}),b=g.useMemo(()=>_?y.current?"delayed-open":"instant-open":"closed",[_]),w=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,y.current=!1,x(!0)},[x]),S=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{y.current=!0,x(!0),p.current=0},v)},[v,x]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(BT,{...c,children:h.jsx(lH,{scope:t,contentId:f,open:_,stateAttribute:b,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?k():w()},[l.isOpenDelayedRef,k,w]),onTriggerLeave:g.useCallback(()=>{m?S():(window.clearTimeout(p.current),p.current=0)},[S,m]),onOpen:w,onClose:S,disableHoverableContent:m,children:n})})};XP.displayName=Bc;var jv="TooltipTrigger",YP=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Gf(jv,n),s=_x(jv,n),o=Kf(n),a=g.useRef(null),l=qt(t,a,i.onTriggerChange),c=g.useRef(!1),u=g.useRef(!1),d=g.useCallback(()=>c.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),h.jsx(zT,{asChild:!0,...o,children:h.jsx(Et.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Pe(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Pe(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Pe(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Pe(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Pe(e.onBlur,i.onClose),onClick:Pe(e.onClick,i.onClose)})})});YP.displayName=jv;var cH="TooltipPortal",[Dne,uH]=qf(cH,{forceMount:void 0}),Oa="TooltipContent",ZP=g.forwardRef((e,t)=>{const n=uH(Oa,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Gf(Oa,e.__scopeTooltip);return h.jsx(zi,{present:r||o.open,children:o.disableHoverableContent?h.jsx(QP,{side:i,...s,ref:t}):h.jsx(dH,{side:i,...s,ref:t})})}),dH=g.forwardRef((e,t)=>{const n=Gf(Oa,e.__scopeTooltip),r=_x(Oa,e.__scopeTooltip),i=g.useRef(null),s=qt(t,i),[o,a]=g.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:d}=r,f=g.useCallback(()=>{a(null),d(!1)},[d]),p=g.useCallback((m,v)=>{const y=m.currentTarget,_={x:m.clientX,y:m.clientY},x=gH(_,y.getBoundingClientRect()),b=vH(_,x),w=_H(v.getBoundingClientRect()),S=yH([...b,...w]);a(S),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=y=>p(y,u),v=y=>p(y,l);return l.addEventListener("pointerleave",m),u.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",v)}}},[l,u,p,f]),g.useEffect(()=>{if(o){const m=v=>{const y=v.target,_={x:v.clientX,y:v.clientY},x=(l==null?void 0:l.contains(y))||(u==null?void 0:u.contains(y)),b=!xH(_,o);x?f():b&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(QP,{...e,ref:s})}),[hH,fH]=qf(Bc,{isInside:!1}),pH=i$("TooltipContent"),QP=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=Gf(Oa,n),c=Kf(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(Av,u),()=>document.removeEventListener(Av,u)),[u]),g.useEffect(()=>{if(l.trigger){const d=f=>{const p=f.target;p!=null&&p.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),h.jsx(Lf,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs($T,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[h.jsx(pH,{children:r}),h.jsx(hH,{scope:n,isInside:!0,children:h.jsx(sH,{id:l.contentId,role:"tooltip",children:i||r})})]})})});ZP.displayName=Oa;var JP="TooltipArrow",mH=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Kf(n);return fH(JP,n).isInside?null:h.jsx(FT,{...i,...r,ref:t})});mH.displayName=JP;function gH(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function vH(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function _H(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function xH(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function yH(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),bH(t)}function bH(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var wH=GP,SH=XP,kH=YP,eI=ZP;const xx=wH,yx=SH,bx=kH,Xf=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(eI,{ref:r,sideOffset:t,className:ne("z-50 overflow-hidden rounded-sm border border-border bg-bg-0 px-2 py-1 text-xs text-text-300 shadow-md",e),...n}));Xf.displayName=eI.displayName;function tI({value:e,onChange:t}){return h.jsx(xx,{delayDuration:150,children:h.jsx("div",{className:"flex items-center gap-1 flex-wrap","data-testid":"session-icon-picker",children:aT.map(n=>{const r=n.Icon,i=e===n.key;return h.jsxs(yx,{children:[h.jsx(bx,{asChild:!0,children:h.jsx("button",{type:"button",onClick:()=>t(i?null:n.key),"data-testid":`session-icon-option-${n.key}`,"aria-label":n.label,"aria-pressed":i,className:ne("w-8 h-8 rounded-md flex items-center justify-center transition-colors cursor-pointer",i?"bg-text-100/10 ring-1 ring-text-100/30":"hover:bg-text-100/5"),children:h.jsx(r,{className:ne("w-4 h-4",n.colorClass)})})}),h.jsx(Xf,{side:"bottom",children:n.label})]},n.key)})})})}function CH({open:e,initialLabel:t,initialIconKey:n,placeholder:r,onSubmit:i,onCancel:s}){const[o,a]=g.useState(t),[l,c]=g.useState(n);return g.useEffect(()=>{e&&(a(t),c(n))},[e,t,n]),g.useEffect(()=>{if(!e)return;const u=d=>{d.key==="Escape"&&s()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e,s]),e?tu.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:s,"data-testid":"session-edit-dialog-overlay",children:h.jsxs("div",{"data-testid":"session-edit-dialog",className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:u=>u.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:"Edit session"}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:"Label"}),h.jsx("input",{autoFocus:!0,type:"text",value:o,onChange:u=>a(u.target.value),placeholder:r,"data-testid":"session-edit-dialog-label",className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:"Icon"}),h.jsx(tI,{value:l,onChange:c})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:s,className:"px-4 py-1.5 text-[12px] text-text-300 rounded-lg hover:bg-text-100/5 transition-colors cursor-pointer",children:"Cancel"}),h.jsx("button",{type:"button",onClick:()=>i({label:o.trim(),iconKey:l}),"data-testid":"session-edit-dialog-save",className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer",children:"Save"})]})]})}),document.body):null}const EH=10,NH=20,TH=16,PH=20,IH=60,RH=4;function MH({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,depth:c=0,chevron:u,showCopyResume:d=!0,contactDisplayName:f}){const[p,m]=g.useState(!1),v=!!e.pinnedAt,y=c===0,_=EH+c*NH,x=g.useCallback(async()=>{const k=e.toolSessionId;if(!k)return;const N=`cd ${`'${e.cwd.replace(/'/g,"'\\''")}'`} && claude --resume ${k} --permission-mode bypassPermissions`;try{await navigator.clipboard.writeText(N)}catch{}},[e.toolSessionId,e.cwd]),b=e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label||e.cwd.split("/").filter(Boolean).pop()||e.sessionId.slice(0,8),w=e.originOwnerPrincipalId,S=w?`@${f??`…${w.slice(-8)}`}`:null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:_,display:"grid",gridTemplateColumns:`${TH}px ${PH}px 1fr auto ${IH}px`,gridTemplateAreas:'"chev icon name dot time" ". . sub sub sub"',columnGap:`${RH}px`,rowGap:"2px",alignItems:"center"},className:ne("group relative rounded-lg cursor-pointer transition-all duration-150 pr-2.5 py-1.5",t?"bg-accent-dim":"hover:bg-sidebar-hover-bg"),children:[t?h.jsx("span",{"aria-hidden":"true",className:"absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-7 rounded-r-full bg-accent"}):null,h.jsx("div",{style:{gridArea:"chev"},className:"flex items-center justify-center",children:u??null}),h.jsx("div",{style:{gridArea:"icon"},className:"flex items-center justify-center",children:h.jsx(nH,{iconKey:e.iconKey})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[e.dispatchedFromSessionId?h.jsx(YB,{"data-testid":`dispatched-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"dispatched from another session",children:h.jsx("title",{children:"由另一个 session dispatch 派生"})}):null,e.shiftFiredFromSessionId?h.jsx(bB,{"data-testid":`shift-fired-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"fired by clawd-shift scheduler",children:h.jsx("title",{children:"由 shift 排班到点 fire 派生"})}):null,h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:ne("text-[13px] truncate min-w-0","group-hover:whitespace-normal group-hover:overflow-visible group-hover:break-words",t?"text-text-100 font-medium":"text-text-200"),children:b})]}),i?h.jsx(CB,{"data-testid":`awaiting-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):n?h.jsx("span",{"data-testid":`unread-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):r?h.jsx("span",{"data-testid":`running-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null,h.jsx("span",{style:{gridArea:"time"},className:ne("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?Zz(e.updatedAt):""}),h.jsxs("span",{style:{gridArea:"sub"},className:ne("flex items-center gap-1.5 text-[11px] text-text-400/70 min-w-0","group-hover:flex-wrap"),children:[S?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${S.replace(/^@/,"")} 的设备上`,className:"shrink-0 inline-flex items-center px-1.5 py-0 rounded text-[10px] bg-accent-dim/40 text-accent border border-accent/20 max-w-[120px] truncate",children:S}):null,h.jsx("span",{"data-testid":`session-subtitle-${e.sessionId}`,className:ne("block text-[11px] text-text-400/70 truncate font-mono min-w-0","group-hover:whitespace-normal group-hover:overflow-visible group-hover:break-all"),children:e.cwd.replace(/^\/Users\/[^/]+/,"~")})]}),o||a||l?h.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 transition-opacity",children:h.jsxs(UP,{modal:!1,children:[h.jsx(WP,{asChild:!0,children:h.jsx("button",{type:"button",onClick:k=>k.stopPropagation(),className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"session actions","data-testid":`session-menu-${e.sessionId}`,children:h.jsx(Sv,{className:"w-4 h-4"})})}),h.jsxs(vx,{align:"end",onClick:k=>k.stopPropagation(),children:[l&&y&&h.jsxs(Ys,{onSelect:()=>l(e.sessionId,!v),"data-testid":`session-${v?"unpin":"pin"}-${e.sessionId}`,children:[v?h.jsx(I6,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(HN,{className:"w-3 h-3 mr-2 text-text-400"}),v?"Unpin":"Pin"]}),o&&h.jsxs(Ys,{onSelect:()=>m(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(FN,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),d&&e.toolSessionId?h.jsxs(Ys,{onSelect:()=>void x(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(su,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||d&&e.toolSessionId)&&a&&h.jsx(VP,{}),a&&h.jsxs(Ys,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(X_,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})}):null]}),o?h.jsx(CH,{open:p,initialLabel:e.label??"",initialIconKey:e.iconKey??null,placeholder:e.cwd.split("/").pop()||"",onSubmit:k=>{o(e.sessionId,k),m(!1)},onCancel:()=>m(!1)}):null]})}function wx({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,getContactDisplayName:u,showCopyResume:d}){const f=e.children.length>0,{isCollapsed:p,toggle:m}=pB(),v=!p(e.session.sessionId),y=g.useCallback(x=>{x.stopPropagation(),m(e.session.sessionId)},[m,e.session.sessionId]),_=f?h.jsx("button",{type:"button",onClick:y,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":v?"collapse":"expand","aria-expanded":v,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:v?h.jsx(li,{className:"w-3 h-3"}):h.jsx(ci,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(MH,{session:e.session,active:n===e.session.sessionId,hasUnread:(r==null?void 0:r.has(e.session.sessionId))??!1,running:(i==null?void 0:i.has(e.session.sessionId))??!1,awaitingUser:(s==null?void 0:s.has(e.session.sessionId))??!1,onSelect:()=>o(e.session.sessionId),onEdit:a,onDelete:l,onPin:c,showCopyResume:d,depth:t,chevron:_,contactDisplayName:e.session.originOwnerPrincipalId?u==null?void 0:u(e.session.originOwnerPrincipalId):void 0}),f&&v?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(x=>h.jsx(wx,{node:x,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,getContactDisplayName:u,showCopyResume:d},x.session.sessionId))}):null]})}function AH(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function nI(e){e=e.filter(s=>!s.ephemeral);const t=new Map;for(const s of e)t.set(s.sessionId,s);const n=new Map,r=[];for(const s of e){const o=AH(s);if(o&&t.has(o)){const a=n.get(o)??[];a.push(s),n.set(o,a)}else r.push(s)}const i=s=>{const a=[...n.get(s.sessionId)??[]].sort((l,c)=>l.createdAt<c.createdAt?-1:l.createdAt>c.createdAt?1:0);return{session:s,children:a.map(i)}};return[...r].sort(jH).map(i)}function rI(e){return[...e].sort((t,n)=>t.session.updatedAt<n.session.updatedAt?1:t.session.updatedAt>n.session.updatedAt?-1:0)}function jH(e,t){const n=typeof e.pinnedAt=="number",r=typeof t.pinnedAt=="number";if(n&&r){const i=typeof e.pinSortOrder=="number",s=typeof t.pinSortOrder=="number";return i&&s?e.pinSortOrder-t.pinSortOrder:i?-1:s?1:t.pinnedAt-e.pinnedAt}return n?-1:r||e.updatedAt<t.updatedAt?1:e.updatedAt>t.updatedAt?-1:0}function DH(e,t){if(e.appBuilderProject)return`[app] ${e.appBuilderProject}`;if(e.label)return e.label;const n=e.cwd.split("/").filter(Boolean).pop();return n||((e.ownerPersonaId?t==null?void 0:t(e.ownerPersonaId):void 0)??"")}function pw(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}function iI(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function sI(e){return e.key==="Enter"&&!e.shiftKey&&!iI(e)}function LH(e,t){const n=g.useRef(!1),r=g.useCallback(()=>{n.current=!0},[]),i=g.useCallback(()=>{setTimeout(()=>{n.current=!1},0)},[]);return{onKeyDown:g.useCallback(o=>{const a=o.nativeEvent;if(sI({key:o.key,shiftKey:o.shiftKey,compositionActive:n.current,nativeIsComposing:a.isComposing,keyCode:a.keyCode})){o.preventDefault(),e();return}t&&o.key==="Escape"&&(o.preventDefault(),t())},[e,t]),onCompositionStart:r,onCompositionEnd:i}}const OH={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function BH({personas:e,activePersonaId:t,onSelectPersona:n,onCreateSession:r,sessions:i,activeSessionId:s,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,isPersonaExpanded:p,onTogglePersonaExpanded:m,onEditSession:v,onPinSession:y,showCopyResume:_,treatSessionsAsRoots:x,searchQuery:b}){const[w,S]=g.useState(null),[k,T]=g.useState(()=>new Set),N=p??(I=>k.has(I)),L=g.useCallback(I=>{if(m){m(I);return}T(R=>{const j=new Set(R);return j.has(I)?j.delete(I):j.add(I),j})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(I=>!I.ephemeral),[i]);if(e.length===0)return h.jsx(zH,{});const O=(b??"").trim();return O?h.jsx(q_.Provider,{value:OH,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(I=>{const R=P?P.filter(F=>F.ownerPersonaId===I.personaId).sort((F,A)=>A.updatedAt>F.updatedAt?1:-1):[],j=pw(I.label,O),z=R.filter(F=>pw(DH(F),O));if(!j&&z.length===0)return null;const $=j?R:z;return h.jsx(mw,{persona:I,active:I.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:$,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:y,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},I.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(I=>{const R=P?P.filter(j=>j.ownerPersonaId===I.personaId).sort((j,z)=>z.updatedAt>j.updatedAt?1:-1):[];return h.jsx(mw,{persona:I,active:I.personaId===t,editing:I.personaId===w,onSelectPersona:n,onStartCreateSession:r?()=>S(I.personaId):void 0,onSubmitCreateSession:j=>{S(null),r==null||r(I.personaId,j)},onCancelCreateSession:()=>S(null),personaSessions:R,collapsed:!N(I.personaId),onToggleCollapsed:()=>L(I.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:y,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},I.personaId)})})}function zH(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function mw({persona:e,active:t,editing:n,onSelectPersona:r,onStartCreateSession:i,onSubmitCreateSession:s,onCancelCreateSession:o,personaSessions:a,collapsed:l,onToggleCollapsed:c,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:y,onPinSession:_,showCopyResume:x,treatSessionsAsRoots:b,ownerPrincipalId:w,creatorDisplayNameByOwnerId:S}){const k=oI(e.iconKey),T=a.length>0,N=!l,L=g.useMemo(()=>{const I=[],R=new Map;for(const j of a){const z=j.creatorPrincipalId;if(!z||w&&z===w){I.push(j);continue}const $=z,F=(S==null?void 0:S.get($))??`…${$.slice(-8)}`,A=R.get($);A?A.sessions.push(j):R.set($,{groupKey:$,displayName:F,sessions:[j]})}return{self:I,byPeer:[...R.values()]}},[a,w,S]),P=L.byPeer.length>0,O=g.useMemo(()=>N&&!P?rI(nI(a)):[],[N,P,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:ne("group flex items-center gap-1 px-2 py-1.5 cursor-pointer",t?"bg-accent-dim text-text-100":"hover:bg-bg-200 text-text-200"),onClick:()=>r==null?void 0:r(e.personaId),role:"button",tabIndex:0,children:[T?h.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),c()},"aria-label":N?"collapse":"expand","aria-expanded":N,"data-testid":`persona-chevron-${e.personaId}`,className:"flex h-4 w-4 shrink-0 items-center justify-center text-text-400 hover:text-text-100",children:N?h.jsx(li,{className:"h-3 w-3"}):h.jsx(ci,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(k.Component,{className:ne("h-3.5 w-3.5 shrink-0",k.colorClass),"aria-hidden":"true"}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),T?h.jsx("span",{className:"shrink-0 text-[10px] text-text-400 tabular-nums","aria-label":`${a.length} sessions`,children:a.length}):null,i?h.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),i()},"aria-label":"新建会话",title:"新建会话","data-testid":`persona-create-session-${e.personaId}`,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-text-400 opacity-0 hover:bg-text-100/10 hover:text-text-100 focus-visible:opacity-100 group-hover:opacity-100",children:h.jsx(D6,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx($H,{personaId:e.personaId,iconKey:e.iconKey,onSubmit:s,onCancel:o}):null,T&&N?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:P?h.jsxs(h.Fragment,{children:[L.self.length>0&&h.jsx(gw,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:L.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:y,onPinSession:_,showCopyResume:x}),L.byPeer.map(I=>h.jsx(gw,{groupKey:`${e.personaId}-peer-${I.groupKey}`,label:I.displayName,testId:`persona-sessions-${e.personaId}-peer-${I.groupKey}`,sessions:I.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:y,onPinSession:_,showCopyResume:x},`${e.personaId}-peer-${I.groupKey}`))]}):O.map(I=>h.jsx(wx,{node:I,depth:b?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:R=>m==null?void 0:m(R),onDelete:v,onEdit:y,onPin:_,showCopyResume:x},I.session.sessionId))}):null]})}function gw({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d}){const[f,p]=g.useState(!1),m=!f,v=g.useMemo(()=>m?rI(nI(n)):[],[m,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>p(y=>!y),"aria-label":m?"collapse":"expand","aria-expanded":m,"data-testid":`${t}-chevron`,className:"flex items-center gap-1 w-full pl-7 pr-2 py-0.5 text-[11px] text-text-400 hover:text-text-200 transition-colors",children:[m?h.jsx(li,{className:"h-3 w-3"}):h.jsx(ci,{className:"h-3 w-3"}),h.jsx(Y_,{className:"h-3 w-3","aria-hidden":!0}),h.jsx("span",{className:"truncate",children:e}),h.jsx("span",{className:"ml-auto tabular-nums",children:n.length})]}),m&&h.jsx("div",{children:v.map(y=>h.jsx(wx,{node:y,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:_=>a==null?void 0:a(_),onDelete:l,onEdit:c,onPin:u,showCopyResume:d},y.session.sessionId))})]})}function $H({personaId:e,iconKey:t,onSubmit:n,onCancel:r}){const[i,s]=g.useState(""),o=g.useRef(null),a=oI(t),l=i.trim(),c=l.length>0;g.useEffect(()=>{var f;(f=o.current)==null||f.focus()},[]);const u=g.useCallback(()=>{c&&n(l)},[c,l,n]),d=LH(u,r);return h.jsxs("div",{className:"flex items-center gap-1.5 pl-9 pr-2 py-1","data-testid":`persona-new-session-row-${e}`,children:[h.jsx(a.Component,{className:ne("h-3 w-3 shrink-0",a.colorClass),"aria-hidden":"true"}),h.jsx("input",{ref:o,type:"text",value:i,onChange:f=>s(f.target.value),...d,onBlur:r,placeholder:"session label...","data-testid":`persona-new-session-input-${e}`,className:"flex-1 min-w-0 bg-bg-100 border border-text-100/15 rounded px-1.5 py-0.5 text-[12px] text-text-100 placeholder:text-text-400 focus:outline-none focus:border-text-100/40"}),h.jsx("button",{type:"button",onMouseDown:f=>{f.preventDefault(),u()},disabled:!c,"aria-label":"确认",title:"确认(Enter)","data-testid":`persona-new-session-confirm-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-text-300",children:h.jsx(Za,{className:"h-3 w-3"})}),h.jsx("button",{type:"button",onMouseDown:f=>{f.preventDefault(),r()},"aria-label":"取消",title:"取消(Esc)","data-testid":`persona-new-session-cancel-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100",children:h.jsx(Rn,{className:"h-3 w-3"})})]})}function oI(e){const t=lT(e);return t?{Component:t.Icon,colorClass:t.colorClass}:{Component:tz,colorClass:"text-text-400"}}function FH(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function HH(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function UH(e){return e/100*window.innerHeight}function WH(e){return e/100*window.innerWidth}function VH(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function Ol({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=VH(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=HH(t,i);break}case"em":{r=FH(t,i);break}case"vh":{r=UH(i);break}case"vw":{r=WH(i);break}}return r}function En(e){return parseFloat(e.toFixed(3))}function Ba({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,i)=>(r+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,r),0)}function Dv(e){const{panels:t}=e,n=Ba({group:e});return n===0?t.map(r=>({groupResizeBehavior:r.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:r.panelConstraints.disabled,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:s}=r;let o=0;if(s.collapsedSize!==void 0){const u=Ol({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=En(u/n*100)}let a;if(s.defaultSize!==void 0){const u=Ol({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=En(u/n*100)}let l=0;if(s.minSize!==void 0){const u=Ol({groupSize:n,panelElement:i,styleProp:s.minSize});l=En(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=Ol({groupSize:n,panelElement:i,styleProp:s.maxSize});c=En(u/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:o,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:l,maxSize:c,panelId:r.id}})}function it(e,t="Assertion error"){if(!e)throw Error(t)}function Lv(e,t){return Array.from(t).sort(e==="horizontal"?qH:KH)}function qH(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function KH(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function aI(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function lI(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function GH({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const o of t){const{x:a,y:l}=lI(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return it(i,"No rect found"),i}let id;function XH(){return id===void 0&&(typeof matchMedia=="function"?id=!!matchMedia("(pointer:coarse)").matches:id=!1),id}function cI(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=Lv(n,Array.from(t.children).filter(aI).map(m=>({element:m}))).map(({element:m})=>m),o=[];let a=!1,l=!1,c=-1,u=-1,d=0,f,p=[];{let m=-1;for(const v of s)v.hasAttribute("data-panel")&&(m++,v.hasAttribute("data-disabled")||(d++,c===-1&&(c=m),u=m))}if(d>1){let m=-1;for(const v of s)if(v.hasAttribute("data-panel")){m++;const y=r.find(_=>_.element===v);if(y){if(f){const _=f.element.getBoundingClientRect(),x=v.getBoundingClientRect();let b;if(l){const w=n==="horizontal"?new DOMRect(_.right,_.top,0,_.height):new DOMRect(_.left,_.bottom,_.width,0),S=n==="horizontal"?new DOMRect(x.left,x.top,0,x.height):new DOMRect(x.left,x.top,x.width,0);switch(p.length){case 0:{b=[w,S];break}case 1:{const k=p[0],T=GH({orientation:n,rects:[_,x],targetRect:k.element.getBoundingClientRect()});b=[k,T===_?S:w];break}default:{b=p;break}}}else p.length?b=p:b=[n==="horizontal"?new DOMRect(_.right,x.top,x.left-_.right,x.height):new DOMRect(x.left,_.bottom,x.width,x.top-_.bottom)];for(const w of b){let S="width"in w?w:w.element.getBoundingClientRect();const k=XH()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(S.width<k){const N=k-S.width;S=new DOMRect(S.x-N/2,S.y,S.width+N,S.height)}if(S.height<k){const N=k-S.height;S=new DOMRect(S.x,S.y-N/2,S.width,S.height+N)}const T=m<=c||m>u;!a&&!T&&o.push({group:e,groupSize:Ba({group:e}),panels:[f,y],separator:"width"in w?void 0:w,rect:S}),a=!1}}l=!1,f=y,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const y=i.find(_=>_.element===v);y?p.push(y):(f=void 0,p=[])}else l=!0}return o}var os;class uI{constructor(){ky(this,os,{})}addListener(t,n){const r=ul(this,os)[t];return r===void 0?ul(this,os)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=ul(this,os)[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,s=null;const o=Array.from(r);for(let a=0;a<o.length;a++){const l=o[a];try{l.call(null,n)}catch(c){s===null&&(i=!0,s=c)}}if(i)throw s}}removeAllListeners(){Cy(this,os,{})}removeListener(t,n){const r=ul(this,os)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}os=new WeakMap;let ba={cursorFlags:0,state:"inactive"};const Sx=new uI;function po(){return ba}function YH(e){return Sx.addListener("change",e)}function ZH(e){const t=ba,n={...ba};n.cursorFlags=e,ba=n,Sx.emit("change",{prev:t,next:n})}function wa(e){const t=ba;ba=e,Sx.emit("change",{prev:t,next:e})}const QH=e=>e,om=()=>{},dI=1,hI=2,fI=4,pI=8,vw=3,_w=12;let sd;function xw(){return sd===void 0&&(sd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(sd=!0)),sd}function JH({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(!(r===0&&i===0)){switch(n){case"active":{if(e&&xw()){const s=(e&dI)!==0,o=(e&hI)!==0,a=(e&fI)!==0,l=(e&pI)!==0;if(s)return a?"se-resize":l?"ne-resize":"e-resize";if(o)return a?"sw-resize":l?"nw-resize":"w-resize";if(a)return"s-resize";if(l)return"n-resize"}break}}return xw()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const yw=new WeakMap;function kx(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=yw.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const r=po();switch(r.state){case"active":case"hover":{const i=JH({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(o=>o.group),state:r.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}yw.set(e,{prevStyle:t,styleSheet:n})}let Yr=new Map;const mI=new uI;function e7(e){Yr=new Map(Yr),Yr.delete(e)}function bw(e,t){for(const[n]of Yr)if(n.id===e)return n}function xs(e,t){for(const[n,r]of Yr)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Po(){return Yr}function Cx(e,t){return mI.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function Di(e,t,n){const r=Yr.get(e);Yr=new Map(Yr),Yr.set(e,t),mI.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function gI(e){const t=po();let n=!1;switch(t.state){case"active":wa({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(kx(e),n=!0,t.hitRegions.forEach(r=>{const i=xs(r.group.id,!0);Di(r.group,i,{isUserInteraction:!0})}))}return n}function ww(e){e.defaultPrevented||gI(e.currentTarget)}function t7(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=lI(n,s.rect);switch(e){case"horizontal":{o.x<=i.x&&(r=s,i=o);break}case"vertical":{o.y<=i.y&&(r=s,i=o);break}}}return r?{distance:i,hitRegion:r}:void 0}function n7(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function r7(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Cw(e),b:Cw(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();it(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:kw(Sw(n.a)),b:kw(Sw(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}const i7=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function s7(e){const t=getComputedStyle(vI(e)??e).display;return t==="flex"||t==="inline-flex"}function o7(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||s7(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||i7.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Sw(e){let t=e.length;for(;t--;){const n=e[t];if(it(n,"Missing node"),o7(n))return n}return null}function kw(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Cw(e){const t=[];for(;e;)t.push(e),e=vI(e);return t}function vI(e){const{parentNode:t}=e;return n7(t)?t.host:t}function a7(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function l7({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!aI(n)||n.contains(e)||e.contains(n))return!0;if(r7(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(a7(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Ex(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=cI(i),o=t7(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&l7({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function c7(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function _n(e,t,n=0){return Math.abs(En(e)-En(t))<=n}function qr(e,t){return _n(e,t)?0:e>t?1:-1}function ca({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){const{collapsedSize:i=0,collapsible:s,disabled:o,maxSize:a=100,minSize:l=0}=t;if(o&&!e)return n;if(qr(r,l)<0)if(s){const c=(i+l)/2;qr(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=En(r),r}function zc({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(_n(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;it(u!=null,"Invalid first pivot index"),it(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,y=n[v];it(y,`Panel constraints not found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:b=0}=y;if(x){const w=a[v];if(it(w!=null,`Previous layout not found for panel index ${v}`),_n(w,_)){const S=b-w;qr(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}{const v=e<0?u:d,y=n[v];it(y,`No panel constraints found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:b=0}=y;if(x){const w=a[v];if(it(w!=null,`Previous layout not found for panel index ${v}`),_n(w,b)){const S=w-_;qr(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}break}default:{const v=e<0?d:u,y=n[v];it(y,`Panel constraints not found for index ${v}`);const _=a[v],{collapsible:x,collapsedSize:b,minSize:w}=y;if(x&&qr(_,w)<0)if(e>0){const S=w-b,k=S/2,T=_+e;qr(T,w)<0&&(e=qr(e,k)<=0?0:S)}else{const S=w-b,k=100-S/2,T=_-e;qr(T,w)<0&&(e=qr(100+e,k)>0?0:-S)}break}}{const v=e<0?1:-1;let y=e<0?d:u,_=0;for(;;){const b=a[y];it(b!=null,`Previous layout not found for panel index ${y}`);const w=ca({overrideDisabledPanels:o,panelConstraints:n[y],prevSize:b,size:100})-b;if(_+=w,y+=v,y<0||y>=n.length)break}const x=Math.min(Math.abs(e),Math.abs(_));e=e<0?0-x:x}{let v=e<0?u:d;for(;v>=0&&v<n.length;){const y=Math.abs(e)-Math.abs(f),_=a[v];it(_!=null,`Previous layout not found for panel index ${v}`);const x=_-y,b=ca({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:_,size:x});if(!_n(_,b)&&(f+=_-b,c[v]=b,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(c7(l,c))return i;{const v=e<0?d:u,y=a[v];it(y!=null,`Previous layout not found for panel index ${v}`);const _=y+f,x=ca({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:y,size:_});if(c[v]=x,!_n(x,_)){let b=_-x,w=e<0?d:u;for(;w>=0&&w<n.length;){const S=c[w];it(S!=null,`Previous layout not found for panel index ${w}`);const k=S+b,T=ca({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:S,size:k});if(_n(S,T)||(b-=T-S,c[w]=T),_n(b,0))break;e>0?w--:w++}}}const p=Object.values(c).reduce((v,y)=>y+v,0);if(!_n(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,y,_)=>(v[m[_]]=y,v),{})}function mo(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||qr(e[n],t[n])!==0)return!1;return!0}function go({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((a,l)=>a+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(a=>`${a}%`).join(", ")}`);if(!_n(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];it(l!=null,`No layout data found for index ${a}`);const c=100/i*l;r[a]=c}let s=0;for(let a=0;a<t.length;a++){const l=n[a];it(l!=null,`No layout data found for index ${a}`);const c=r[a];it(c!=null,`No layout data found for index ${a}`);const u=ca({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!_n(s,0))for(let a=0;a<t.length;a++){const l=r[a];it(l!=null,`No layout data found for index ${a}`);const c=l+s,u=ca({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,_n(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function _I({groupId:e,panelId:t}){const n=()=>{const l=Po();for(const[c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:f,groupSize:p,separatorToPanels:m}]of l)if(c.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:c,groupSize:p,layout:f,separatorToPanels:m};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(c=>c.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(c=>c.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:l,panels:c,prevLayout:u,derivedPanelConstraints:d})=>{const f=s(),p=c.findIndex(y=>y.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((y,_)=>{const x=d[_];return(x==null?void 0:x.collapsible)&&_n(x.collapsedSize,u[x.panelId])}))){const y=c.slice(0,p).reduce((_,x)=>_+u[x.id],0);return{...u,[t]:En(100-y)}}return zc({delta:v?f-l:l-f,initialLayout:u,panelConstraints:d,pivotIndices:v?[p-1,p]:[p,p+1],prevLayout:u,trigger:"imperative-api"})},a=l=>{const c=s();if(l===c)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:f,groupSize:p,layout:m,separatorToPanels:v}=n(),y=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),_=go({layout:y,panelConstraints:d});mo(m,_)||Di(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:_,separatorToPanels:v})};return{collapse:()=>{const{collapsible:l,collapsedSize:c}=r(),{mutableValues:u}=i(),d=s();l&&d!==c&&(u.expandToSize=d,a(c))},expand:()=>{const{collapsible:l,collapsedSize:c,minSize:u}=r(),{mutableValues:d}=i(),f=s();if(l&&f===c){let p=d.expandToSize??u;p===0&&(p=1),a(p)}},getSize:()=>{const{group:l}=n(),c=s(),{element:u}=i(),d=l.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:l,collapsedSize:c}=r(),u=s();return l&&_n(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=Ba({group:c}),f=Ol({groupSize:d,panelElement:u,styleProp:l}),p=En(f/d*100);a(p)}}}function Ew(e){if(e.defaultPrevented)return;const t=Po();Ex(e,t).forEach(n=>{if(n.separator&&!n.separator.disableDoubleClick){const r=n.panels.find(i=>i.panelConstraints.defaultSize!==void 0);if(r){const i=r.panelConstraints.defaultSize,s=_I({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function Od(e){const t=Po();for(const[n]of t)if(n.separators.some(r=>r.element===e))return n;throw Error("Could not find parent Group for separator element")}function xI({groupId:e}){const t=()=>{const n=Po();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:s,groupSize:o,layout:a,separatorToPanels:l}=t(),c=go({layout:n,panelConstraints:i});return r?a:(mo(a,c)||Di(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function Os(e,t){const n=Od(e),r=xs(n.id,!0),i=n.separators.find(u=>u.element===e);it(i,"Matching separator not found");const s=r.separatorToPanels.get(i);it(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=xI({groupId:n.id}).getLayout(),l=zc({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=go({layout:l,panelConstraints:r.derivedPanelConstraints});mo(a,c)||Di(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function Nw(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=Od(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Os(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Os(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Os(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Os(t,-5);break}case"End":{e.preventDefault(),Os(t,100);break}case"Enter":{e.preventDefault();const r=Od(t),i=xs(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);it(l,"Matching separator not found");const c=a.get(l);it(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(it(d,"Panel metadata not found"),d.collapsible){const f=o[u.id],p=d.collapsedSize===f?r.mutableState.expandedPanelSizes[u.id]??d.minSize:d.collapsedSize;Os(t,p-f)}break}case"F6":{e.preventDefault();const r=Od(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);it(i!==null,"Index not found");const s=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[s].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Os(t,-100);break}}}function Tw(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Po(),n=Ex(e,t),r=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({focusVisible:!1,preventScroll:!0})));const o=t.get(s.group);o&&r.set(s.group,o.layout)}),wa({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function yI({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:o}){let a=0;n.forEach(c=>{const{group:u,groupSize:d}=c,{orientation:f,panels:p}=u,{disableCursor:m}=u.mutableState;let v=0;s?f==="horizontal"?v=(t.clientX-s.x)/d*100:v=(t.clientY-s.y)/d*100:f==="horizontal"?v=t.clientX<0?-100:100:v=t.clientY<0?-100:100;const y=r.get(u),_=i.get(u);if(!y||!_)return;const{defaultLayoutDeferred:x,derivedPanelConstraints:b,groupSize:w,layout:S,separatorToPanels:k}=_;if(b&&S&&k){const T=zc({delta:v,initialLayout:y,panelConstraints:b,pivotIndices:c.panels.map(N=>p.indexOf(N)),prevLayout:S,trigger:"mouse-or-touch"});if(mo(T,S)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?dI:hI;break}case"vertical":{a|=v<0?fI:pI;break}}}else Di(c.group,{defaultLayoutDeferred:x,derivedPanelConstraints:b,groupSize:w,layout:T,separatorToPanels:k})}});let l=0;t.movementX===0?l|=o&vw:l|=a&vw,t.movementY===0?l|=o&_w:l|=a&_w,ZH(l),kx(e)}function Pw(e){const t=Po(),n=po();switch(n.state){case"active":yI({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function Iw(e){var r,i;if(e.defaultPrevented)return;const t=po(),n=Po();switch(t.state){case"active":{if(e.buttons===0){wa({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=xs(s.group.id,!0);Di(s.group,o,{isUserInteraction:!0})});return}for(const s of t.hitRegions)if(s.separator){const{element:o}=s.separator;(r=o.hasPointerCapture)!=null&&r.call(o,e.pointerId)||((i=o.setPointerCapture)==null||i.call(o,e.pointerId))}yI({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=Ex(e,n);s.length===0?t.state!=="inactive"&&wa({cursorFlags:0,state:"inactive"}):wa({cursorFlags:0,hitRegions:s,state:"hover"}),kx(e.currentTarget);break}}}function Rw(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(po().state){case"hover":wa({cursorFlags:0,state:"inactive"})}}function Mw(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||gI(e.currentTarget)&&e.preventDefault()}function Aw(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=En(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=En((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function u7(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=Ba({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:En(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function d7(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function h7({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,s=0,o=!1;const a=new Map,l=[];for(const d of e.panels){const f=r[d.id]??0;switch(d.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{o=!0;const p=f/100*n,m=En(p/t*100);a.set(d.id,m),i+=m;break}case"preserve-relative-size":default:{l.push(d.id),s+=f;break}}}if(!o||l.length===0)return r;const c=100-i,u={...r};if(a.forEach((d,f)=>{u[f]=d}),s>0)for(const d of l){const f=r[d]??0;u[d]=En(f/s*c)}else{const d=En(c/l.length);for(const f of l)u[f]=d}return u}function f7(e,t){const n=e.map(i=>i.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!r.includes(i))return!1;return!0}const Ho=new Map;function p7(e){let t=!0;it(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const v of m){const{borderBoxSize:y,target:_}=v;if(_===e.element){if(t){const x=Ba({group:e});if(x===0)return;const b=xs(e.id);if(!b)return;const w=Dv(e),S=b.defaultLayoutDeferred?Aw(w):b.layout,k=h7({group:e,nextGroupSize:x,prevGroupSize:b.groupSize,prevLayout:S}),T=go({layout:k,panelConstraints:w});if(!b.defaultLayoutDeferred&&mo(b.layout,T)&&d7(b.derivedPanelConstraints,w)&&b.groupSize===x)return;Di(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:w,groupSize:x,layout:T,separatorToPanels:b.separatorToPanels})}}else u7(e,_,y)}});s.observe(e.element),e.panels.forEach(m=>{it(!r.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.onResize&&s.observe(m.element)});const o=Ba({group:e}),a=Dv(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(f7(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??Aw(a),d=go({layout:u,panelConstraints:a}),f=e.element.ownerDocument;Ho.set(f,(Ho.get(f)??0)+1);const p=new Map;return cI(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),Di(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{it(!i.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),i.add(m.id),m.element.addEventListener("keydown",Nw)}),Ho.get(f)===1&&(f.addEventListener("contextmenu",ww,!0),f.addEventListener("dblclick",Ew,!0),f.addEventListener("pointerdown",Tw,!0),f.addEventListener("pointerleave",Pw),f.addEventListener("pointermove",Iw),f.addEventListener("pointerout",Rw),f.addEventListener("pointerup",Mw,!0)),function(){t=!1,Ho.set(f,Math.max(0,(Ho.get(f)??0)-1)),e7(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",Nw)}),Ho.get(f)||(f.removeEventListener("contextmenu",ww,!0),f.removeEventListener("dblclick",Ew,!0),f.removeEventListener("pointerdown",Tw,!0),f.removeEventListener("pointerleave",Pw),f.removeEventListener("pointermove",Iw),f.removeEventListener("pointerout",Rw),f.removeEventListener("pointerup",Mw,!0)),s.disconnect()}}function m7(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function Nx(e){const t=g.useId();return`${e??t}`}const Io=typeof window<"u"?g.useLayoutEffect:g.useEffect;function nc(e){const t=g.useRef(e);return Io(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function Tx(...e){return nc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function Px(e){const t=g.useRef({...e});return Io(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const bI=g.createContext(null);function g7(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:QH});g.useImperativeHandle(t,()=>n.current,[]),Io(()=>{Object.assign(n.current,xI({groupId:e}))})}function Ix({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:s,groupRef:o,id:a,onLayoutChange:l,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){const m=g.useRef({onLayoutChange:{},onLayoutChanged:{}}),v=nc(O=>{mo(m.current.onLayoutChange,O)||(m.current.onLayoutChange=O,l==null||l(O))}),y=nc((O,I)=>{mo(m.current.onLayoutChanged,O)||(m.current.onLayoutChanged=O,c==null||c(O,{isUserInteraction:I}))}),_=Nx(a),x=g.useRef(null),[b,w]=m7(),S=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),k=Tx(x,s);g7(_,o);const T=nc((O,I)=>{const R=po(),j=bw(O),z=xs(O);if(z){let $=!1;switch(R.state){case"active":{$=R.hitRegions.some(F=>F.group===j);break}}return{flexGrow:z.layout[I]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[I])return{flexGrow:n==null?void 0:n[I]}}),N=Px({defaultLayout:n,disableCursor:r}),L=g.useMemo(()=>({get disableCursor(){return!!N.disableCursor},getPanelStyles:T,id:_,orientation:u,registerPanel:O=>{const I=S.current;return I.panels=Lv(u,[...I.panels,O]),w(),()=>{I.panels=I.panels.filter(R=>R!==O),w()}},registerSeparator:O=>{const I=S.current;return I.separators=Lv(u,[...I.separators,O]),w(),()=>{I.separators=I.separators.filter(R=>R!==O),w()}},updatePanelProps:(O,{disabled:I})=>{const R=S.current.panels.find($=>$.id===O);R&&(R.panelConstraints.disabled=I);const j=bw(_),z=xs(_);j&&z&&Di(j,{...z,derivedPanelConstraints:Dv(j)})},updateSeparatorProps:(O,{disabled:I,disableDoubleClick:R})=>{const j=S.current.separators.find(z=>z.id===O);j&&(j.disabled=I,j.disableDoubleClick=R)}}),[T,_,w,u,N]),P=g.useRef(null);return Io(()=>{const O=x.current;if(O===null)return;const I=S.current;let R;if(N.defaultLayout!==void 0&&Object.keys(N.defaultLayout).length===I.panels.length){R={};for(const E of I.panels){const H=N.defaultLayout[E.id];H!==void 0&&(R[E.id]=H)}}const j={disabled:!!i,element:O,id:_,mutableState:{defaultLayout:R,disableCursor:!!N.disableCursor,expandedPanelSizes:S.current.lastExpandedPanelSizes,layouts:S.current.layouts},orientation:u,panels:I.panels,resizeTargetMinimumSize:I.resizeTargetMinimumSize,separators:I.separators};P.current=j;const z=p7(j),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:A}=xs(j.id,!0);!$&&F.length>0&&(v(A),y(A,!1));const B=Cx(_,E=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:q,layout:M}=E.next;if(H||q.length===0)return;const re=j.panels.map(({id:V})=>V).join(",");j.mutableState.layouts[re]=M,q.forEach(V=>{if(V.collapsible){const{layout:pe}=E.prev??{};if(pe){const Oe=_n(V.collapsedSize,M[V.panelId]),ie=_n(V.collapsedSize,pe[V.panelId]);Oe&&!ie&&(j.mutableState.expandedPanelSizes[V.panelId]=pe[V.panelId])}}});const oe=po().state!=="active";v(M),oe&&y(M,E.isUserInteraction)});return()=>{P.current=null,z(),B()}},[i,_,y,v,u,b,N]),g.useEffect(()=>{const O=P.current;O&&(O.mutableState.defaultLayout=n,O.mutableState.disableCursor=!!r)}),h.jsx(bI.Provider,{value:L,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:k,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}Ix.displayName="Group";function Rx(){const e=g.useContext(bI);return it(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function v7(e,t){const{id:n}=Rx(),r=g.useRef({collapse:om,expand:om,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:om});g.useImperativeHandle(t,()=>r.current,[]),Io(()=>{Object.assign(r.current,_I({groupId:n,panelId:e}))})}function $c({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,disabled:s,elementRef:o,groupResizeBehavior:a="preserve-relative-size",id:l,maxSize:c="100%",minSize:u="0%",onResize:d,panelRef:f,style:p,...m}){const v=!!l,y=Nx(l),_=Px({disabled:s}),x=g.useRef(null),b=Tx(x,o),{getPanelStyles:w,id:S,orientation:k,registerPanel:T,updatePanelProps:N}=Rx(),L=d!==null,P=nc((j,z,$)=>{d==null||d(j,l,$)});Io(()=>{const j=x.current;if(j!==null){const z={element:j,id:y,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:L?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:c,minSize:u}};return T(z)}},[a,n,r,i,L,y,v,c,u,P,T,_]),g.useEffect(()=>{N(y,{disabled:s})},[s,y,N]),v7(y,f);const O=()=>{const j=w(S,y);if(j)return JSON.stringify(j)},I=g.useSyncExternalStore(j=>Cx(S,j),O,O);let R;return I?R=JSON.parse(I):i!==void 0?R={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:R={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":y,id:y,ref:b,style:{..._7,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...R},children:h.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...p,touchAction:k==="horizontal"?"pan-y":"pan-x"},children:e})})}$c.displayName="Panel";const _7={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function x7({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,s;const o=e[n],a=t.find(l=>l.panelId===n);if(a){const l=a.maxSize,c=a.collapsible?a.collapsedSize:a.minSize,u=[r,r+1];s=go({layout:zc({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=go({layout:zc({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function Mx({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=Nx(s),c=Px({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),y=g.useRef(null),_=Tx(y,i),{disableCursor:x,id:b,orientation:w,registerSeparator:S,updateSeparatorProps:k}=Rx(),T=w==="horizontal"?"vertical":"horizontal";Io(()=>{const P=y.current;if(P!==null){const O={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},I=S(O),R=YH(z=>{p(z.next.state!=="inactive"&&z.next.hitRegions.some($=>$.separator===O)?z.next.state:"inactive")}),j=Cx(b,z=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:A}=z.next,B=A.get(O);if(B){const E=B[0],H=B.indexOf(E);d(x7({layout:F,panelConstraints:$,panelId:E.id,panelIndex:H}))}});return()=>{R(),j(),I()}}},[b,l,S,c]),g.useEffect(()=>{k(l,{disabled:n,disableDoubleClick:r})},[n,r,l,k]);let N;n&&!x&&(N="not-allowed");let L;if(n)L="disabled";else switch(f){case"active":{L="active";break}default:m?L="focus":L=f}return h.jsx("div",{...a,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":T,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":L,"data-testid":l,id:l,onBlur:()=>v(!1),onFocus:()=>v(!0),ref:_,role:"separator",style:{flexBasis:"auto",cursor:N,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}Mx.displayName="Separator";function y7(e,t,n,r=!0){const i=g.useRef({sid:null,tsid:void 0});g.useEffect(()=>{const s=i.current;i.current={sid:t,tsid:n},!(!r||!n||s.sid===t&&(s.tsid===void 0||s.tsid===null)&&typeof n=="string")&&e.sessionObserve({sessionId:t,toolSessionId:n}).catch(()=>{})},[e,t,n,r])}function b7(e,t,n){const r=g.useRef(e),i=g.useRef(t),s=g.useRef(n);s.current=n,g.useEffect(()=>{const o=r.current,a=i.current;r.current=e,i.current=t;const l=o!==e,c=typeof a=="string"&&t==null;!l&&!c||s.current()},[e,t])}const w7=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function S7(e){const t=new Map,n=new Map,r=new Map;for(const i of e)if(i.kind==="tool_call"&&i.tool==="CronCreate"){const s=i.input;if(!s||typeof s.cron!="string"||typeof s.prompt!="string")continue;const o=i.ts;t.set(i.toolUseId,{cron:s.cron,prompt:s.prompt,recurring:s.recurring!==!1,ts:typeof o=="string"?o:"",toolUseId:i.toolUseId})}else if(i.kind==="tool_call"&&i.tool==="CronDelete"){const s=i.input;if(!s||typeof s.id!="string")continue;n.set(i.toolUseId,s.id)}else if(i.kind==="tool_result"){const s=t.get(i.toolUseId);if(s){if(t.delete(i.toolUseId),i.error||typeof i.output!="string")continue;const a=i.output.match(w7);if(!a)continue;r.set(a[1],{id:a[1],cron:s.cron,prompt:s.prompt,recurring:s.recurring,humanSchedule:a[2],createdAt:s.ts,toolUseId:s.toolUseId});continue}const o=n.get(i.toolUseId);o!==void 0&&(n.delete(i.toolUseId),i.error||r.delete(o))}return Array.from(r.values()).sort((i,s)=>i.createdAt.localeCompare(s.createdAt))}const k7=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function C7(e){return k7.includes(e)}function wI(e){return e==="in_progress"||e==="completed"?e:"pending"}function E7(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.subject=="string"&&n.subject?n.subject:typeof n.content=="string"&&n.content?n.content:null;if(!r)return e;const i=typeof n.activeForm=="string"?n.activeForm:void 0,s=typeof n.description=="string"?n.description:void 0;return[...e,{id:String(e.length+1),content:r,status:wI(n.status),activeForm:i,description:s}]}function N7(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.taskId=="string"&&n.taskId?n.taskId:typeof n.id=="string"&&n.id?n.id:null;if(!r)return e;const i=e.findIndex(a=>a.id===r);if(i<0)return e;const s=[...e],o={...s[i]};return"status"in n&&(o.status=wI(n.status)),typeof n.subject=="string"&&(o.content=n.subject),typeof n.content=="string"&&(o.content=n.content),typeof n.activeForm=="string"&&(o.activeForm=n.activeForm),typeof n.description=="string"&&(o.description=n.description),s[i]=o,s}function T7(e){let t=[],n=-1;for(let r=0;r<e.length;r++){const i=e[r];if(i.kind==="task-event")switch(n=r,i.name){case"TaskCreate":t=E7(t,i.input);break;case"TaskUpdate":t=N7(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function P7(e){const{tasks:t,lastEventIndex:n}=T7(e);let r=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind==="todo-checklist"){r=c;break}const i=[],s=new Map,o=new Map,a=new Map,l=(c,u)=>{var f,p,m;const d={agentId:u.agentId,status:u.status};u.description?d.description=u.description:(f=c.progress)!=null&&f.description&&(d.description=c.progress.description),u.lastToolName?d.lastToolName=u.lastToolName:(p=c.progress)!=null&&p.lastToolName&&(d.lastToolName=c.progress.lastToolName),u.stats?d.stats=u.stats:(m=c.progress)!=null&&m.stats&&(d.stats=c.progress.stats),c.progress=d};for(let c=0;c<e.length;c++){const u=e[c];switch(u.kind){case"tool-call":{const d={kind:"merged-tool",seq:u.seq,tool:u.tool,toolKind:u.toolKind,toolUseId:u.toolUseId,input:u.input,pending:!0};s.set(u.toolUseId,i.length),i.push(d);break}case"tool-result":{const d=s.get(u.toolUseId);if(d!==void 0){const p=i[d];p.output=u.output,p.error=u.error,p.pending=!1,s.delete(u.toolUseId);break}const f=o.get(u.toolUseId);if(f!==void 0){const p=i[f];p.output=u.output,p.error=u.error,p.pending=!1,u.toolResultExtra&&(p.toolResultExtra=u.toolResultExtra);break}break}case"agent-call":{const d={kind:"merged-agent",seq:u.seq,toolUseId:u.toolUseId,description:u.description,input:u.input,pending:!0,notifications:[]};o.set(u.toolUseId,i.length),i.push(d);const f=a.get(u.toolUseId);f&&(l(d,f),a.delete(u.toolUseId));break}case"agent-progress":{const d=o.get(u.toolUseId);if(d!==void 0){l(i[d],u);break}a.set(u.toolUseId,u);break}case"agent-notification":{const d=u.parentToolUseId;if(d){const f=o.get(d);if(f!==void 0){i[f].notifications.push({text:u.text,taskId:u.taskId});break}}i.push({kind:"agent-notification",seq:u.seq,text:u.text,taskId:u.taskId,parentToolUseId:u.parentToolUseId});break}case"todo-checklist":{c===r&&u.todos.length>0&&i.push({kind:"todo-checklist",seq:u.seq,toolUseId:u.toolUseId,todos:u.todos});break}case"task-event":{c===n&&t.length>0&&i.push({kind:"plan-card",seq:u.seq,tasks:t});break}default:i.push(u)}}return i}const I7=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,R7=/<builder-preview\b[^>]*\/>/gi;function SI(e){return e?e.replace(I7,"").replace(R7,"").trim():""}const M7=SI;function A7(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const j7=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,D7=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,L7={};function jw(e,t){return(L7.jsx?D7:j7).test(e)}const O7=/[ \t\n\f\r]/g;function B7(e){return typeof e=="object"?e.type==="text"?Dw(e.value):!1:Dw(e)}function Dw(e){return e.replace(O7,"")===""}class du{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}du.prototype.normal={};du.prototype.property={};du.prototype.space=void 0;function kI(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new du(n,r,t)}function Ov(e){return e.toLowerCase()}class Vn{constructor(t,n){this.attribute=n,this.property=t}}Vn.prototype.attribute="";Vn.prototype.booleanish=!1;Vn.prototype.boolean=!1;Vn.prototype.commaOrSpaceSeparated=!1;Vn.prototype.commaSeparated=!1;Vn.prototype.defined=!1;Vn.prototype.mustUseProperty=!1;Vn.prototype.number=!1;Vn.prototype.overloadedBoolean=!1;Vn.prototype.property="";Vn.prototype.spaceSeparated=!1;Vn.prototype.space=void 0;let z7=0;const Ie=Ro(),Mt=Ro(),Bv=Ro(),X=Ro(),lt=Ro(),Sa=Ro(),Xn=Ro();function Ro(){return 2**++z7}const zv=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ie,booleanish:Mt,commaOrSpaceSeparated:Xn,commaSeparated:Sa,number:X,overloadedBoolean:Bv,spaceSeparated:lt},Symbol.toStringTag,{value:"Module"})),am=Object.keys(zv);class Ax extends Vn{constructor(t,n,r,i){let s=-1;if(super(t,n),Lw(this,"space",i),typeof r=="number")for(;++s<am.length;){const o=am[s];Lw(this,am[s],(r&zv[o])===zv[o])}}}Ax.prototype.defined=!0;function Lw(e,t,n){n&&(e[t]=n)}function el(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Ax(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Ov(r)]=r,n[Ov(s.attribute)]=r}return new du(t,n,e.space)}const CI=el({properties:{ariaActiveDescendant:null,ariaAtomic:Mt,ariaAutoComplete:null,ariaBusy:Mt,ariaChecked:Mt,ariaColCount:X,ariaColIndex:X,ariaColSpan:X,ariaControls:lt,ariaCurrent:null,ariaDescribedBy:lt,ariaDetails:null,ariaDisabled:Mt,ariaDropEffect:lt,ariaErrorMessage:null,ariaExpanded:Mt,ariaFlowTo:lt,ariaGrabbed:Mt,ariaHasPopup:null,ariaHidden:Mt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:lt,ariaLevel:X,ariaLive:null,ariaModal:Mt,ariaMultiLine:Mt,ariaMultiSelectable:Mt,ariaOrientation:null,ariaOwns:lt,ariaPlaceholder:null,ariaPosInSet:X,ariaPressed:Mt,ariaReadOnly:Mt,ariaRelevant:null,ariaRequired:Mt,ariaRoleDescription:lt,ariaRowCount:X,ariaRowIndex:X,ariaRowSpan:X,ariaSelected:Mt,ariaSetSize:X,ariaSort:null,ariaValueMax:X,ariaValueMin:X,ariaValueNow:X,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function EI(e,t){return t in e?e[t]:t}function NI(e,t){return EI(e,t.toLowerCase())}const $7=el({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Sa,acceptCharset:lt,accessKey:lt,action:null,allow:null,allowFullScreen:Ie,allowPaymentRequest:Ie,allowUserMedia:Ie,alt:null,as:null,async:Ie,autoCapitalize:null,autoComplete:lt,autoFocus:Ie,autoPlay:Ie,blocking:lt,capture:null,charSet:null,checked:Ie,cite:null,className:lt,cols:X,colSpan:null,content:null,contentEditable:Mt,controls:Ie,controlsList:lt,coords:X|Sa,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ie,defer:Ie,dir:null,dirName:null,disabled:Ie,download:Bv,draggable:Mt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ie,formTarget:null,headers:lt,height:X,hidden:Bv,high:X,href:null,hrefLang:null,htmlFor:lt,httpEquiv:lt,id:null,imageSizes:null,imageSrcSet:null,inert:Ie,inputMode:null,integrity:null,is:null,isMap:Ie,itemId:null,itemProp:lt,itemRef:lt,itemScope:Ie,itemType:lt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ie,low:X,manifest:null,max:null,maxLength:X,media:null,method:null,min:null,minLength:X,multiple:Ie,muted:Ie,name:null,nonce:null,noModule:Ie,noValidate:Ie,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ie,optimum:X,pattern:null,ping:lt,placeholder:null,playsInline:Ie,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ie,referrerPolicy:null,rel:lt,required:Ie,reversed:Ie,rows:X,rowSpan:X,sandbox:lt,scope:null,scoped:Ie,seamless:Ie,selected:Ie,shadowRootClonable:Ie,shadowRootDelegatesFocus:Ie,shadowRootMode:null,shape:null,size:X,sizes:null,slot:null,span:X,spellCheck:Mt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:X,step:null,style:null,tabIndex:X,target:null,title:null,translate:null,type:null,typeMustMatch:Ie,useMap:null,value:Mt,width:X,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:lt,axis:null,background:null,bgColor:null,border:X,borderColor:null,bottomMargin:X,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ie,declare:Ie,event:null,face:null,frame:null,frameBorder:null,hSpace:X,leftMargin:X,link:null,longDesc:null,lowSrc:null,marginHeight:X,marginWidth:X,noResize:Ie,noHref:Ie,noShade:Ie,noWrap:Ie,object:null,profile:null,prompt:null,rev:null,rightMargin:X,rules:null,scheme:null,scrolling:Mt,standby:null,summary:null,text:null,topMargin:X,valueType:null,version:null,vAlign:null,vLink:null,vSpace:X,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ie,disableRemotePlayback:Ie,prefix:null,property:null,results:X,security:null,unselectable:null},space:"html",transform:NI}),F7=el({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Xn,accentHeight:X,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:X,amplitude:X,arabicForm:null,ascent:X,attributeName:null,attributeType:null,azimuth:X,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:X,by:null,calcMode:null,capHeight:X,className:lt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:X,diffuseConstant:X,direction:null,display:null,dur:null,divisor:X,dominantBaseline:null,download:Ie,dx:null,dy:null,edgeMode:null,editable:null,elevation:X,enableBackground:null,end:null,event:null,exponent:X,externalResourcesRequired:null,fill:null,fillOpacity:X,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Sa,g2:Sa,glyphName:Sa,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:X,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:X,horizOriginX:X,horizOriginY:X,id:null,ideographic:X,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:X,k:X,k1:X,k2:X,k3:X,k4:X,kernelMatrix:Xn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:X,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:X,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:X,overlineThickness:X,paintOrder:null,panose1:null,path:null,pathLength:X,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:lt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:X,pointsAtY:X,pointsAtZ:X,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Xn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Xn,rev:Xn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Xn,requiredFeatures:Xn,requiredFonts:Xn,requiredFormats:Xn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:X,specularExponent:X,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:X,strikethroughThickness:X,string:null,stroke:null,strokeDashArray:Xn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:X,strokeOpacity:X,strokeWidth:null,style:null,surfaceScale:X,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Xn,tabIndex:X,tableValues:null,target:null,targetX:X,targetY:X,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Xn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:X,underlineThickness:X,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:X,values:null,vAlphabetic:X,vMathematical:X,vectorEffect:null,vHanging:X,vIdeographic:X,version:null,vertAdvY:X,vertOriginX:X,vertOriginY:X,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:X,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:EI}),TI=el({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),PI=el({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:NI}),II=el({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),H7={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},U7=/[A-Z]/g,Ow=/-[a-z]/g,W7=/^data[-\w.:]+$/i;function V7(e,t){const n=Ov(t);let r=t,i=Vn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&W7.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Ow,K7);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Ow.test(s)){let o=s.replace(U7,q7);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Ax}return new i(r,t)}function q7(e){return"-"+e.toLowerCase()}function K7(e){return e.charAt(1).toUpperCase()}const G7=kI([CI,$7,TI,PI,II],"html"),jx=kI([CI,F7,TI,PI,II],"svg");function X7(e){return e.join(" ").trim()}var Dx={},Bw=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Y7=/\n/g,Z7=/^\s*/,Q7=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,J7=/^:\s*/,eU=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,tU=/^[;\s]*/,nU=/^\s+|\s+$/g,rU=`
486
486
  `,zw="/",$w="*",Vs="",iU="comment",sU="declaration";function oU(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(m){var v=m.match(Y7);v&&(n+=v.length);var y=m.lastIndexOf(rU);r=~y?m.length-y:r+m.length}function s(){var m={line:n,column:r};return function(v){return v.position=new o(m),c(),v}}function o(m){this.start=m,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function a(m){var v=new Error(t.source+":"+n+":"+r+": "+m);if(v.reason=m,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function l(m){var v=m.exec(e);if(v){var y=v[0];return i(y),e=e.slice(y.length),v}}function c(){l(Z7)}function u(m){var v;for(m=m||[];v=d();)v!==!1&&m.push(v);return m}function d(){var m=s();if(!(zw!=e.charAt(0)||$w!=e.charAt(1))){for(var v=2;Vs!=e.charAt(v)&&($w!=e.charAt(v)||zw!=e.charAt(v+1));)++v;if(v+=2,Vs===e.charAt(v-1))return a("End of comment missing");var y=e.slice(2,v-2);return r+=2,i(y),e=e.slice(v),r+=2,m({type:iU,comment:y})}}function f(){var m=s(),v=l(Q7);if(v){if(d(),!l(J7))return a("property missing ':'");var y=l(eU),_=m({type:sU,property:Fw(v[0].replace(Bw,Vs)),value:y?Fw(y[0].replace(Bw,Vs)):Vs});return l(tU),_}}function p(){var m=[];u(m);for(var v;v=f();)v!==!1&&(m.push(v),u(m));return m}return c(),p()}function Fw(e){return e?e.replace(nU,Vs):Vs}var aU=oU,lU=Kd&&Kd.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Dx,"__esModule",{value:!0});Dx.default=uU;const cU=lU(aU);function uU(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,cU.default)(e),i=typeof t=="function";return r.forEach(s=>{if(s.type!=="declaration")return;const{property:o,value:a}=s;i?t(o,a,s):a&&(n=n||{},n[o]=a)}),n}var Yf={};Object.defineProperty(Yf,"__esModule",{value:!0});Yf.camelCase=void 0;var dU=/^--[a-zA-Z0-9_-]+$/,hU=/-([a-z])/g,fU=/^[^-]+$/,pU=/^-(webkit|moz|ms|o|khtml)-/,mU=/^-(ms)-/,gU=function(e){return!e||fU.test(e)||dU.test(e)},vU=function(e,t){return t.toUpperCase()},Hw=function(e,t){return"".concat(t,"-")},_U=function(e,t){return t===void 0&&(t={}),gU(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(mU,Hw):e=e.replace(pU,Hw),e.replace(hU,vU))};Yf.camelCase=_U;var xU=Kd&&Kd.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},yU=xU(Dx),bU=Yf;function $v(e,t){var n={};return!e||typeof e!="string"||(0,yU.default)(e,function(r,i){r&&i&&(n[(0,bU.camelCase)(r,t)]=i)}),n}$v.default=$v;var wU=$v;const SU=Xc(wU),RI=MI("end"),Lx=MI("start");function MI(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function kU(e){const t=Lx(e),n=RI(e);if(t&&n)return{start:t,end:n}}function rc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Uw(e.position):"start"in e||"end"in e?Uw(e):"line"in e||"column"in e?Fv(e):""}function Fv(e){return Ww(e&&e.line)+":"+Ww(e&&e.column)}function Uw(e){return Fv(e&&e.start)+"-"+Fv(e&&e.end)}function Ww(e){return e&&typeof e=="number"?e:1}class wn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=rc(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}wn.prototype.file="";wn.prototype.name="";wn.prototype.reason="";wn.prototype.message="";wn.prototype.stack="";wn.prototype.column=void 0;wn.prototype.line=void 0;wn.prototype.ancestors=void 0;wn.prototype.cause=void 0;wn.prototype.fatal=void 0;wn.prototype.place=void 0;wn.prototype.ruleId=void 0;wn.prototype.source=void 0;const Ox={}.hasOwnProperty,CU=new Map,EU=/[A-Z]/g,NU=new Set(["table","tbody","thead","tfoot","tr"]),TU=new Set(["td","th"]),AI="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function PU(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=OU(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=LU(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?jx:G7,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=jI(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function jI(e,t,n){if(t.type==="element")return IU(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return RU(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return AU(e,t,n);if(t.type==="mdxjsEsm")return MU(e,t);if(t.type==="root")return jU(e,t,n);if(t.type==="text")return DU(e,t)}function IU(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=jx,e.schema=i),e.ancestors.push(t);const s=LI(e,t.tagName,!1),o=BU(e,t);let a=zx(e,t);return NU.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!B7(l):!0})),DI(e,o,s,t),Bx(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function RU(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Fc(e,t.position)}function MU(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Fc(e,t.position)}function AU(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=jx,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:LI(e,t.name,!0),o=zU(e,t),a=zx(e,t);return DI(e,o,s,t),Bx(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function jU(e,t,n){const r={};return Bx(r,zx(e,t)),e.create(t,e.Fragment,r,n)}function DU(e,t){return t.value}function DI(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Bx(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function LU(e,t,n){return r;function r(i,s,o,a){const c=Array.isArray(o.children)?n:t;return a?c(s,o,a):c(s,o)}}function OU(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=Lx(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function BU(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Ox.call(t.properties,i)){const s=$U(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&TU.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function zU(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else Fc(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else Fc(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function zx(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:CU;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;o=l+"-"+c,i.set(l,c+1)}}const a=jI(e,s,o);a!==void 0&&n.push(a)}return n}function $U(e,t,n){const r=V7(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?A7(n):X7(n)),r.property==="style"){let i=typeof n=="object"?n:FU(e,String(n));return e.stylePropertyNameCase==="css"&&(i=HU(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?H7[r.property]||r.property:r.attribute,n]}}function FU(e,t){try{return SU(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new wn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=AI+"#cannot-parse-style-attribute",i}}function LI(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=jw(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=jw(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Ox.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Fc(e)}function Fc(e,t){const n=new wn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=AI+"#cannot-handle-mdx-estrees-without-createevaluater",n}function HU(e){const t={};let n;for(n in e)Ox.call(e,n)&&(t[UU(n)]=e[n]);return t}function UU(e){let t=e.replace(EU,WU);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function WU(e){return"-"+e.toLowerCase()}const lm={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},VU={};function $x(e,t){const n=VU,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return OI(e,r,i)}function OI(e,t,n){if(qU(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Vw(e.children,t,n)}return Array.isArray(e)?Vw(e,t,n):""}function Vw(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=OI(e[i],t,n);return r.join("")}function qU(e){return!!(e&&typeof e=="object")}const qw=document.createElement("i");function Fx(e){const t="&"+e+";";qw.innerHTML=t;const n=qw.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function tr(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function pr(e,t){return e.length>0?(tr(e,e.length,0,t),e):t}const Kw={}.hasOwnProperty;function BI(e){const t={};let n=-1;for(;++n<e.length;)KU(t,e[n]);return t}function KU(e,t){let n;for(n in t){const i=(Kw.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){Kw.call(i,o)||(i[o]=[]);const a=s[o];GU(i[o],Array.isArray(a)?a:a?[a]:[])}}}function GU(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);tr(e,0,0,r)}function zI(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ar(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Cn=js(/[A-Za-z]/),yn=js(/[\dA-Za-z]/),XU=js(/[#-'*+\--9=?A-Z^-~]/);function $h(e){return e!==null&&(e<32||e===127)}const Hv=js(/\d/),YU=js(/[\dA-Fa-f]/),ZU=js(/[!-/:-@[-`{-~]/);function ye(e){return e!==null&&e<-2}function ot(e){return e!==null&&(e<0||e===32)}function ze(e){return e===-2||e===-1||e===32}const Zf=js(new RegExp("\\p{P}|\\p{S}","u")),vo=js(/\s/);function js(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function tl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&yn(e.charCodeAt(n+1))&&yn(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Ve(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return ze(l)?(e.enter(n),a(l)):t(l)}function a(l){return ze(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const QU={tokenize:JU};function JU(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Ve(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return ye(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const eW={tokenize:tW},Gw={tokenize:nW};function tW(e){const t=this,n=[];let r=0,i,s,o;return a;function a(b){if(r<n.length){const w=n[r];return t.containerState=w[1],e.attempt(w[0].continuation,l,c)(b)}return c(b)}function l(b){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&x();const w=t.events.length;let S=w,k;for(;S--;)if(t.events[S][0]==="exit"&&t.events[S][1].type==="chunkFlow"){k=t.events[S][1].end;break}_(r);let T=w;for(;T<t.events.length;)t.events[T][1].end={...k},T++;return tr(t.events,S+1,0,t.events.slice(w)),t.events.length=T,c(b)}return a(b)}function c(b){if(r===n.length){if(!i)return f(b);if(i.currentConstruct&&i.currentConstruct.concrete)return m(b);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Gw,u,d)(b)}function u(b){return i&&x(),_(r),f(b)}function d(b){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(b)}function f(b){return t.containerState={},e.attempt(Gw,p,m)(b)}function p(b){return r++,n.push([t.currentConstruct,t.containerState]),f(b)}function m(b){if(b===null){i&&x(),_(0),e.consume(b);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),v(b)}function v(b){if(b===null){y(e.exit("chunkFlow"),!0),_(0),e.consume(b);return}return ye(b)?(e.consume(b),y(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(b),v)}function y(b,w){const S=t.sliceStream(b);if(w&&S.push(null),b.previous=s,s&&(s.next=b),s=b,i.defineSkip(b.start),i.write(S),t.parser.lazy[b.start.line]){let k=i.events.length;for(;k--;)if(i.events[k][1].start.offset<o&&(!i.events[k][1].end||i.events[k][1].end.offset>o))return;const T=t.events.length;let N=T,L,P;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){if(L){P=t.events[N][1].end;break}L=!0}for(_(r),k=T;k<t.events.length;)t.events[k][1].end={...P},k++;tr(t.events,N+1,0,t.events.slice(T)),t.events.length=k}}function _(b){let w=n.length;for(;w-- >b;){const S=n[w];t.containerState=S[1],S[0].exit.call(t,e)}n.length=b}function x(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function nW(e,t,n){return Ve(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function za(e){if(e===null||ot(e)||vo(e))return 1;if(Zf(e))return 2}function Qf(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const Uv={name:"attention",resolveAll:rW,tokenize:iW};function rW(e,t){let n=-1,r,i,s,o,a,l,c,u;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[r][1].end},f={...e[n][1].start};Xw(d,-l),Xw(f,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=pr(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=pr(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=pr(c,Qf(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=pr(c,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,c=pr(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,tr(e,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function iW(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=za(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const c=e.exit("attentionSequence"),u=za(l),d=!u||u===2&&i||n.includes(l),f=!i||i===2&&u||n.includes(r);return c._open=!!(s===42?d:d&&(i||!f)),c._close=!!(s===42?f:f&&(u||!d)),t(l)}}function Xw(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const sW={name:"autolink",tokenize:oW};function oW(e,t,n){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return Cn(p)?(e.consume(p),o):p===64?n(p):c(p)}function o(p){return p===43||p===45||p===46||yn(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||yn(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||$h(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),u):XU(p)?(e.consume(p),c):n(p)}function u(p){return yn(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,u):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||yn(p))&&r++<63){const m=p===45?f:d;return e.consume(p),m}return n(p)}}const hu={partial:!0,tokenize:aW};function aW(e,t,n){return r;function r(s){return ze(s)?Ve(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||ye(s)?t(s):n(s)}}const $I={continuation:{tokenize:cW},exit:uW,name:"blockQuote",tokenize:lW};function lW(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return ze(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function cW(e,t,n){const r=this;return i;function i(o){return ze(o)?Ve(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt($I,t,n)(o)}}function uW(e){e.exit("blockQuote")}const FI={name:"characterEscape",tokenize:dW};function dW(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return ZU(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const HI={name:"characterReference",tokenize:hW};function hW(e,t,n){const r=this;let i=0,s,o;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,o=yn,u(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=YU,u):(e.enter("characterReferenceValue"),s=7,o=Hv,u(d))}function u(d){if(d===59&&i){const f=e.exit("characterReferenceValue");return o===yn&&!Fx(r.sliceSerialize(f))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(d)&&i++<s?(e.consume(d),u):n(d)}}const Yw={partial:!0,tokenize:pW},Zw={concrete:!0,name:"codeFenced",tokenize:fW};function fW(e,t,n){const r=this,i={partial:!0,tokenize:S};let s=0,o=0,a;return l;function l(k){return c(k)}function c(k){const T=r.events[r.events.length-1];return s=T&&T[1].type==="linePrefix"?T[2].sliceSerialize(T[1],!0).length:0,a=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(k)}function u(k){return k===a?(o++,e.consume(k),u):o<3?n(k):(e.exit("codeFencedFenceSequence"),ze(k)?Ve(e,d,"whitespace")(k):d(k))}function d(k){return k===null||ye(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(Yw,v,w)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(k))}function f(k){return k===null||ye(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):ze(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ve(e,p,"whitespace")(k)):k===96&&k===a?n(k):(e.consume(k),f)}function p(k){return k===null||ye(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||ye(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(k)):k===96&&k===a?n(k):(e.consume(k),m)}function v(k){return e.attempt(i,w,y)(k)}function y(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),_}function _(k){return s>0&&ze(k)?Ve(e,x,"linePrefix",s+1)(k):x(k)}function x(k){return k===null||ye(k)?e.check(Yw,v,w)(k):(e.enter("codeFlowValue"),b(k))}function b(k){return k===null||ye(k)?(e.exit("codeFlowValue"),x(k)):(e.consume(k),b)}function w(k){return e.exit("codeFenced"),t(k)}function S(k,T,N){let L=0;return P;function P(z){return k.enter("lineEnding"),k.consume(z),k.exit("lineEnding"),O}function O(z){return k.enter("codeFencedFence"),ze(z)?Ve(k,I,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(z):I(z)}function I(z){return z===a?(k.enter("codeFencedFenceSequence"),R(z)):N(z)}function R(z){return z===a?(L++,k.consume(z),R):L>=o?(k.exit("codeFencedFenceSequence"),ze(z)?Ve(k,j,"whitespace")(z):j(z)):N(z)}function j(z){return z===null||ye(z)?(k.exit("codeFencedFence"),T(z)):N(z)}}}function pW(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const cm={name:"codeIndented",tokenize:gW},mW={partial:!0,tokenize:vW};function gW(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),Ve(e,s,"linePrefix",5)(c)}function s(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?l(c):ye(c)?e.attempt(mW,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||ye(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function vW(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):ye(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Ve(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):ye(o)?i(o):n(o)}}const _W={name:"codeText",previous:yW,resolve:xW,tokenize:bW};function xW(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function yW(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function bW(e,t,n){let r=0,i,s;return o;function o(d){return e.enter("codeText"),e.enter("codeTextSequence"),a(d)}function a(d){return d===96?(e.consume(d),r++,a):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(s=e.enter("codeTextSequence"),i=0,u(d)):ye(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||ye(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),c)}function u(d){return d===96?(e.consume(d),i++,u):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",c(d))}}class wW{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&wl(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),wl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),wl(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);wl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);wl(this.left,n.reverse())}}}function wl(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function UI(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new wW(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type==="chunkFlow"&&u.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,SW(u,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=u.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},a=u.slice(i,n),a.unshift(r),u.splice(i,n-i+1,a))}}return tr(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function SW(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],c={};let u,d,f=-1,p=n,m=0,v=0;const y=[v];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(v=f+1,y.push(v),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):y.pop(),f=y.length;f--;){const _=a.slice(y[f],y[f+1]),x=s.pop();l.push([x,x+_.length-1]),e.splice(x,2,_)}for(l.reverse(),f=-1;++f<l.length;)c[m+l[f][0]]=m+l[f][1],m+=l[f][1]-l[f][0]-1;return c}const kW={resolve:EW,tokenize:NW},CW={partial:!0,tokenize:TW};function EW(e){return UI(e),e}function NW(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):ye(a)?e.check(CW,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function TW(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Ve(e,s,"linePrefix")}function s(o){if(o===null||ye(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function WI(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return d;function d(_){return _===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(_),e.exit(s),f):_===null||_===32||_===41||$h(_)?n(_):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),v(_))}function f(_){return _===62?(e.enter(s),e.consume(_),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(_))}function p(_){return _===62?(e.exit("chunkString"),e.exit(a),f(_)):_===null||_===60||ye(_)?n(_):(e.consume(_),_===92?m:p)}function m(_){return _===60||_===62||_===92?(e.consume(_),p):p(_)}function v(_){return!u&&(_===null||_===41||ot(_))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(_)):u<c&&_===40?(e.consume(_),u++,v):_===41?(e.consume(_),u--,v):_===null||_===32||_===40||$h(_)?n(_):(e.consume(_),_===92?y:v)}function y(_){return _===40||_===41||_===92?(e.consume(_),v):v(_)}}function VI(e,t,n,r,i,s){const o=this;let a=0,l;return c;function c(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),u}function u(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):ye(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||ye(p)||a++>999?(e.exit("chunkString"),u(p)):(e.consume(p),l||(l=!ze(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function qI(e,t,n,r,i,s){let o;return a;function a(f){return f===34||f===39||f===40?(e.enter(r),e.enter(i),e.consume(f),e.exit(i),o=f===40?41:f,l):n(f)}function l(f){return f===o?(e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):(e.enter(s),c(f))}function c(f){return f===o?(e.exit(s),l(o)):f===null?n(f):ye(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ve(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===o||f===null||ye(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?d:u)}function d(f){return f===o||f===92?(e.consume(f),u):u(f)}}function ic(e,t){let n;return r;function r(i){return ye(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):ze(i)?Ve(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const PW={name:"definition",tokenize:RW},IW={partial:!0,tokenize:MW};function RW(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return VI.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Ar(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return ot(p)?ic(e,c)(p):c(p)}function c(p){return WI(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(IW,d,d)(p)}function d(p){return ze(p)?Ve(e,f,"whitespace")(p):f(p)}function f(p){return p===null||ye(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function MW(e,t,n){return r;function r(a){return ot(a)?ic(e,i)(a):n(a)}function i(a){return qI(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return ze(a)?Ve(e,o,"whitespace")(a):o(a)}function o(a){return a===null||ye(a)?t(a):n(a)}}const AW={name:"hardBreakEscape",tokenize:jW};function jW(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return ye(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const DW={name:"headingAtx",resolve:LW,tokenize:OW};function LW(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},tr(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function OW(e,t,n){let r=0;return i;function i(u){return e.enter("atxHeading"),s(u)}function s(u){return e.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(e.consume(u),o):u===null||ot(u)?(e.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||ye(u)?(e.exit("atxHeading"),t(u)):ze(u)?Ve(e,a,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||ot(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}const BW=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Qw=["pre","script","style","textarea"],zW={concrete:!0,name:"htmlFlow",resolveTo:HW,tokenize:UW},$W={partial:!0,tokenize:VW},FW={partial:!0,tokenize:WW};function HW(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function UW(e,t,n){const r=this;let i,s,o,a,l;return c;function c(M){return u(M)}function u(M){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(M),d}function d(M){return M===33?(e.consume(M),f):M===47?(e.consume(M),s=!0,v):M===63?(e.consume(M),i=3,r.interrupt?t:E):Cn(M)?(e.consume(M),o=String.fromCharCode(M),y):n(M)}function f(M){return M===45?(e.consume(M),i=2,p):M===91?(e.consume(M),i=5,a=0,m):Cn(M)?(e.consume(M),i=4,r.interrupt?t:E):n(M)}function p(M){return M===45?(e.consume(M),r.interrupt?t:E):n(M)}function m(M){const re="CDATA[";return M===re.charCodeAt(a++)?(e.consume(M),a===re.length?r.interrupt?t:I:m):n(M)}function v(M){return Cn(M)?(e.consume(M),o=String.fromCharCode(M),y):n(M)}function y(M){if(M===null||M===47||M===62||ot(M)){const re=M===47,oe=o.toLowerCase();return!re&&!s&&Qw.includes(oe)?(i=1,r.interrupt?t(M):I(M)):BW.includes(o.toLowerCase())?(i=6,re?(e.consume(M),_):r.interrupt?t(M):I(M)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(M):s?x(M):b(M))}return M===45||yn(M)?(e.consume(M),o+=String.fromCharCode(M),y):n(M)}function _(M){return M===62?(e.consume(M),r.interrupt?t:I):n(M)}function x(M){return ze(M)?(e.consume(M),x):P(M)}function b(M){return M===47?(e.consume(M),P):M===58||M===95||Cn(M)?(e.consume(M),w):ze(M)?(e.consume(M),b):P(M)}function w(M){return M===45||M===46||M===58||M===95||yn(M)?(e.consume(M),w):S(M)}function S(M){return M===61?(e.consume(M),k):ze(M)?(e.consume(M),S):b(M)}function k(M){return M===null||M===60||M===61||M===62||M===96?n(M):M===34||M===39?(e.consume(M),l=M,T):ze(M)?(e.consume(M),k):N(M)}function T(M){return M===l?(e.consume(M),l=null,L):M===null||ye(M)?n(M):(e.consume(M),T)}function N(M){return M===null||M===34||M===39||M===47||M===60||M===61||M===62||M===96||ot(M)?S(M):(e.consume(M),N)}function L(M){return M===47||M===62||ze(M)?b(M):n(M)}function P(M){return M===62?(e.consume(M),O):n(M)}function O(M){return M===null||ye(M)?I(M):ze(M)?(e.consume(M),O):n(M)}function I(M){return M===45&&i===2?(e.consume(M),$):M===60&&i===1?(e.consume(M),F):M===62&&i===4?(e.consume(M),H):M===63&&i===3?(e.consume(M),E):M===93&&i===5?(e.consume(M),B):ye(M)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check($W,q,R)(M)):M===null||ye(M)?(e.exit("htmlFlowData"),R(M)):(e.consume(M),I)}function R(M){return e.check(FW,j,q)(M)}function j(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),z}function z(M){return M===null||ye(M)?R(M):(e.enter("htmlFlowData"),I(M))}function $(M){return M===45?(e.consume(M),E):I(M)}function F(M){return M===47?(e.consume(M),o="",A):I(M)}function A(M){if(M===62){const re=o.toLowerCase();return Qw.includes(re)?(e.consume(M),H):I(M)}return Cn(M)&&o.length<8?(e.consume(M),o+=String.fromCharCode(M),A):I(M)}function B(M){return M===93?(e.consume(M),E):I(M)}function E(M){return M===62?(e.consume(M),H):M===45&&i===2?(e.consume(M),E):I(M)}function H(M){return M===null||ye(M)?(e.exit("htmlFlowData"),q(M)):(e.consume(M),H)}function q(M){return e.exit("htmlFlow"),t(M)}}function WW(e,t,n){const r=this;return i;function i(o){return ye(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function VW(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(hu,t,n)}}const qW={name:"htmlText",tokenize:KW};function KW(e,t,n){const r=this;let i,s,o;return a;function a(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),l}function l(E){return E===33?(e.consume(E),c):E===47?(e.consume(E),S):E===63?(e.consume(E),b):Cn(E)?(e.consume(E),N):n(E)}function c(E){return E===45?(e.consume(E),u):E===91?(e.consume(E),s=0,m):Cn(E)?(e.consume(E),x):n(E)}function u(E){return E===45?(e.consume(E),p):n(E)}function d(E){return E===null?n(E):E===45?(e.consume(E),f):ye(E)?(o=d,F(E)):(e.consume(E),d)}function f(E){return E===45?(e.consume(E),p):d(E)}function p(E){return E===62?$(E):E===45?f(E):d(E)}function m(E){const H="CDATA[";return E===H.charCodeAt(s++)?(e.consume(E),s===H.length?v:m):n(E)}function v(E){return E===null?n(E):E===93?(e.consume(E),y):ye(E)?(o=v,F(E)):(e.consume(E),v)}function y(E){return E===93?(e.consume(E),_):v(E)}function _(E){return E===62?$(E):E===93?(e.consume(E),_):v(E)}function x(E){return E===null||E===62?$(E):ye(E)?(o=x,F(E)):(e.consume(E),x)}function b(E){return E===null?n(E):E===63?(e.consume(E),w):ye(E)?(o=b,F(E)):(e.consume(E),b)}function w(E){return E===62?$(E):b(E)}function S(E){return Cn(E)?(e.consume(E),k):n(E)}function k(E){return E===45||yn(E)?(e.consume(E),k):T(E)}function T(E){return ye(E)?(o=T,F(E)):ze(E)?(e.consume(E),T):$(E)}function N(E){return E===45||yn(E)?(e.consume(E),N):E===47||E===62||ot(E)?L(E):n(E)}function L(E){return E===47?(e.consume(E),$):E===58||E===95||Cn(E)?(e.consume(E),P):ye(E)?(o=L,F(E)):ze(E)?(e.consume(E),L):$(E)}function P(E){return E===45||E===46||E===58||E===95||yn(E)?(e.consume(E),P):O(E)}function O(E){return E===61?(e.consume(E),I):ye(E)?(o=O,F(E)):ze(E)?(e.consume(E),O):L(E)}function I(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),i=E,R):ye(E)?(o=I,F(E)):ze(E)?(e.consume(E),I):(e.consume(E),j)}function R(E){return E===i?(e.consume(E),i=void 0,z):E===null?n(E):ye(E)?(o=R,F(E)):(e.consume(E),R)}function j(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||ot(E)?L(E):(e.consume(E),j)}function z(E){return E===47||E===62||ot(E)?L(E):n(E)}function $(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function F(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),A}function A(E){return ze(E)?Ve(e,B,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):B(E)}function B(E){return e.enter("htmlTextData"),o(E)}}const Hx={name:"labelEnd",resolveAll:ZW,resolveTo:QW,tokenize:JW},GW={tokenize:eV},XW={tokenize:tV},YW={tokenize:nV};function ZW(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&tr(e,0,e.length,n),e}function QW(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},u={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",c,t]],a=pr(a,e.slice(s+1,s+r+3)),a=pr(a,[["enter",u,t]]),a=pr(a,Qf(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=pr(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=pr(a,e.slice(o+1)),a=pr(a,[["exit",l,t]]),tr(e,s,e.length,a),e}function JW(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(f){return s?s._inactive?d(f):(o=r.parser.defined.includes(Ar(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),l):n(f)}function l(f){return f===40?e.attempt(GW,u,o?u:d)(f):f===91?e.attempt(XW,u,o?c:d)(f):o?u(f):d(f)}function c(f){return e.attempt(YW,u,d)(f)}function u(f){return t(f)}function d(f){return s._balanced=!0,n(f)}}function eV(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return ot(d)?ic(e,s)(d):s(d)}function s(d){return d===41?u(d):WI(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return ot(d)?ic(e,l)(d):u(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?qI(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return ot(d)?ic(e,u)(d):u(d)}function u(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function tV(e,t,n){const r=this;return i;function i(a){return VI.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Ar(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function nV(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const rV={name:"labelStartImage",resolveAll:Hx.resolveAll,tokenize:iV};function iV(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const sV={name:"labelStartLink",resolveAll:Hx.resolveAll,tokenize:oV};function oV(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const um={name:"lineEnding",tokenize:aV};function aV(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ve(e,t,"linePrefix")}}const Bd={name:"thematicBreak",tokenize:lV};function lV(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,a(c)}function a(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||ye(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),ze(c)?Ve(e,a,"whitespace")(c):a(c))}}const zn={continuation:{tokenize:hV},exit:pV,name:"list",tokenize:dV},cV={partial:!0,tokenize:mV},uV={partial:!0,tokenize:fV};function dV(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(p){const m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:Hv(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Bd,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return Hv(p)&&++o<10?(e.consume(p),l):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(hu,r.interrupt?n:u,e.attempt(cV,f,d))}function u(p){return r.containerState.initialBlankLine=!0,s++,f(p)}function d(p){return ze(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):n(p)}function f(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function hV(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(hu,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ve(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!ze(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(uV,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ve(e,e.attempt(zn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function fV(e,t,n){const r=this;return Ve(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function pV(e){e.exit(this.containerState.type)}function mV(e,t,n){const r=this;return Ve(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!ze(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Jw={name:"setextUnderline",resolveTo:gV,tokenize:vV};function gV(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function vV(e,t,n){const r=this;let i;return s;function s(c){let u=r.events.length,d;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){d=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),ze(c)?Ve(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||ye(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const _V={tokenize:xV};function xV(e){const t=this,n=e.attempt(hu,r,e.attempt(this.parser.constructs.flowInitial,i,Ve(e,e.attempt(this.parser.constructs.flow,i,e.attempt(kW,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const yV={resolveAll:GI()},bV=KI("string"),wV=KI("text");function KI(e){return{resolveAll:GI(e==="text"?SV:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(u){return c(u)?s(u):a(u)}function a(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),l}function l(u){return c(u)?(n.exit("data"),s(u)):(n.consume(u),l)}function c(u){if(u===null)return!0;const d=i[u];let f=-1;if(d)for(;++f<d.length;){const p=d[f];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function GI(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function SV(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,a=0,l;for(;s--;){const c=i[s];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(c===-2)l=!0,a++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const c={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const kV={42:zn,43:zn,45:zn,48:zn,49:zn,50:zn,51:zn,52:zn,53:zn,54:zn,55:zn,56:zn,57:zn,62:$I},CV={91:PW},EV={[-2]:cm,[-1]:cm,32:cm},NV={35:DW,42:Bd,45:[Jw,Bd],60:zW,61:Jw,95:Bd,96:Zw,126:Zw},TV={38:HI,92:FI},PV={[-5]:um,[-4]:um,[-3]:um,33:rV,38:HI,42:Uv,60:[sW,qW],91:sV,92:[AW,FI],93:Hx,95:Uv,96:_W},IV={null:[Uv,yV]},RV={null:[42,95]},MV={null:[]},AV=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:RV,contentInitial:CV,disable:MV,document:kV,flow:NV,flowInitial:EV,insideSpan:IV,string:TV,text:PV},Symbol.toStringTag,{value:"Module"}));function jV(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:T(S),check:T(k),consume:x,enter:b,exit:w,interrupt:T(k,{interrupt:!0})},c={code:null,containerState:{},defineSkip:v,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d};let u=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(O){return o=pr(o,O),y(),o[o.length-1]!==null?[]:(N(t,0),c.events=Qf(s,c.events,c),c.events)}function f(O,I){return LV(p(O),I)}function p(O){return DV(o,O)}function m(){const{_bufferIndex:O,_index:I,line:R,column:j,offset:z}=r;return{_bufferIndex:O,_index:I,line:R,column:j,offset:z}}function v(O){i[O.line]=O.column,P()}function y(){let O;for(;r._index<o.length;){const I=o[r._index];if(typeof I=="string")for(O=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===O&&r._bufferIndex<I.length;)_(I.charCodeAt(r._bufferIndex));else _(I)}}function _(O){u=u(O)}function x(O){ye(O)?(r.line++,r.column=1,r.offset+=O===-3?2:1,P()):O!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=O}function b(O,I){const R=I||{};return R.type=O,R.start=m(),c.events.push(["enter",R,c]),a.push(R),R}function w(O){const I=a.pop();return I.end=m(),c.events.push(["exit",I,c]),I}function S(O,I){N(O,I.from)}function k(O,I){I.restore()}function T(O,I){return R;function R(j,z,$){let F,A,B,E;return Array.isArray(j)?q(j):"tokenize"in j?q([j]):H(j);function H(V){return pe;function pe(Oe){const ie=Oe!==null&&V[Oe],Me=Oe!==null&&V.null,Fe=[...Array.isArray(ie)?ie:ie?[ie]:[],...Array.isArray(Me)?Me:Me?[Me]:[]];return q(Fe)(Oe)}}function q(V){return F=V,A=0,V.length===0?$:M(V[A])}function M(V){return pe;function pe(Oe){return E=L(),B=V,V.partial||(c.currentConstruct=V),V.name&&c.parser.constructs.disable.null.includes(V.name)?oe():V.tokenize.call(I?Object.assign(Object.create(c),I):c,l,re,oe)(Oe)}}function re(V){return O(B,E),z}function oe(V){return E.restore(),++A<F.length?M(F[A]):$}}}function N(O,I){O.resolveAll&&!s.includes(O)&&s.push(O),O.resolve&&tr(c.events,I,c.events.length-I,O.resolve(c.events.slice(I),c)),O.resolveTo&&(c.events=O.resolveTo(c.events,c))}function L(){const O=m(),I=c.previous,R=c.currentConstruct,j=c.events.length,z=Array.from(a);return{from:j,restore:$};function $(){r=O,c.previous=I,c.currentConstruct=R,c.events.length=j,a=z,P()}}function P(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function DV(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function LV(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
487
487
  `;break}case-3:{o=`\r
488
- `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function OV(e){const r={constructs:BI([AV,...(e||{}).extensions||[]]),content:i(QU),defined:[],document:i(eW),flow:i(_V),lazy:{},string:i(bV),text:i(wV)};return r;function i(s){return o;function o(a){return jV(r,s,a)}}}function BV(e){for(;!UI(e););return e}const eS=/[\0\t\n\r]/g;function zV(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const l=[];let c,u,d,f,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),d=0,t="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if(eS.lastIndex=d,c=eS.exec(s),f=c&&c.index!==void 0?c.index:s.length,p=s.charCodeAt(f),!c){t=s.slice(d);break}if(p===10&&d===f&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<f&&(l.push(s.slice(d,f)),e+=f-d),p){case 0:{l.push(65533),e++;break}case 9:{for(u=Math.ceil(e/4)*4,l.push(-2);e++<u;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=f+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const $V=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function FV(e){return e.replace($V,HV)}function HV(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return zI(n.slice(s?2:1),s?16:10)}return Fx(n)||e}const XI={}.hasOwnProperty;function UV(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),WV(n)(BV(OV(n).document().write(zV()(e,t,!0))))}function WV(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Bt),autolinkProtocol:L,autolinkEmail:L,atxHeading:s(Gt),blockQuote:s(Me),characterEscape:L,characterReference:L,codeFenced:s(Fe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Fe,o),codeText:s(We,o),codeTextData:L,data:L,codeFlowValue:L,definition:s(ge),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(qe),hardBreakEscape:s(wt),hardBreakTrailing:s(wt),htmlFlow:s(Rt,o),htmlFlowData:L,htmlText:s(Rt,o),htmlTextData:L,image:s(ln),label:o,link:s(Bt),listItem:s(Ue),listItemValue:f,listOrdered:s(at,d),listUnordered:s(at),paragraph:s(nt),reference:M,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Gt),strong:s(mt),thematicBreak:s(pn)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:ie,autolinkProtocol:Oe,blockQuote:l(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:oe,characterReferenceMarkerNumeric:oe,characterReferenceValue:V,characterReference:pe,codeFenced:l(y),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:P,codeIndented:l(_),codeText:l(z),codeTextData:P,data:P,definition:l(),definitionDestinationString:w,definitionLabelString:x,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(I),hardBreakTrailing:l(I),htmlFlow:l(R),htmlFlowData:P,htmlText:l(j),htmlTextData:P,image:l(F),label:B,labelText:A,lineEnding:O,link:l($),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:re,resourceDestinationString:E,resourceTitleString:H,resource:q,setextHeading:l(N),setextHeadingLineSequence:T,setextHeadingText:k,strong:l(),thematicBreak:l()}};YI(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let Q={type:"root",children:[]};const ve={stack:[Q],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},Se=[];let J=-1;for(;++J<U.length;)if(U[J][1].type==="listOrdered"||U[J][1].type==="listUnordered")if(U[J][0]==="enter")Se.push(J);else{const Xe=Se.pop();J=i(U,Xe,J)}for(J=-1;++J<U.length;){const Xe=t[U[J][0]];XI.call(Xe,U[J][1].type)&&Xe[U[J][1].type].call(Object.assign({sliceSerialize:U[J][2].sliceSerialize},ve),U[J][1])}if(ve.tokenStack.length>0){const Xe=ve.tokenStack[ve.tokenStack.length-1];(Xe[1]||tS).call(ve,void 0,Xe[0])}for(Q.position={start:Gi(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:Gi(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},J=-1;++J<t.transforms.length;)Q=t.transforms[J](Q)||Q;return Q}function i(U,Q,ve){let Se=Q-1,J=-1,Xe=!1,Yt,Zt,ue,Ne;for(;++Se<=ve;){const Qe=U[Se];switch(Qe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Qe[0]==="enter"?J++:J--,Ne=void 0;break}case"lineEndingBlank":{Qe[0]==="enter"&&(Yt&&!Ne&&!J&&!ue&&(ue=Se),Ne=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ne=void 0}if(!J&&Qe[0]==="enter"&&Qe[1].type==="listItemPrefix"||J===-1&&Qe[0]==="exit"&&(Qe[1].type==="listUnordered"||Qe[1].type==="listOrdered")){if(Yt){let Dn=Se;for(Zt=void 0;Dn--;){const Qt=U[Dn];if(Qt[1].type==="lineEnding"||Qt[1].type==="lineEndingBlank"){if(Qt[0]==="exit")continue;Zt&&(U[Zt][1].type="lineEndingBlank",Xe=!0),Qt[1].type="lineEnding",Zt=Dn}else if(!(Qt[1].type==="linePrefix"||Qt[1].type==="blockQuotePrefix"||Qt[1].type==="blockQuotePrefixWhitespace"||Qt[1].type==="blockQuoteMarker"||Qt[1].type==="listItemIndent"))break}ue&&(!Zt||ue<Zt)&&(Yt._spread=!0),Yt.end=Object.assign({},Zt?U[Zt][1].start:Qe[1].end),U.splice(Zt||Se,0,["exit",Yt,Qe[2]]),Se++,ve++}if(Qe[1].type==="listItemPrefix"){const Dn={type:"listItem",_spread:!1,start:Object.assign({},Qe[1].start),end:void 0};Yt=Dn,U.splice(Se,0,["enter",Dn,Qe[2]]),Se++,ve++,ue=void 0,Ne=!0}}}return U[Q][1]._spread=Xe,ve}function s(U,Q){return ve;function ve(Se){a.call(this,U(Se),Se),Q&&Q.call(this,Se)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(U,Q,ve){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([Q,ve||void 0]),U.position={start:Gi(Q.start),end:void 0}}function l(U){return Q;function Q(ve){U&&U.call(this,ve),c.call(this,ve)}}function c(U,Q){const ve=this.stack.pop(),Se=this.tokenStack.pop();if(Se)Se[0].type!==U.type&&(Q?Q.call(this,U,Se[0]):(Se[1]||tS).call(this,U,Se[0]));else throw new Error("Cannot close `"+U.type+"` ("+rc({start:U.start,end:U.end})+"): it’s not open");ve.position.end=Gi(U.end)}function u(){return $x(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(U){if(this.data.expectingFirstListItemValue){const Q=this.stack[this.stack.length-2];Q.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function p(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.lang=U}function m(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.meta=U}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function y(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function _(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U.replace(/(\r?\n|\r)$/g,"")}function x(U){const Q=this.resume(),ve=this.stack[this.stack.length-1];ve.label=Q,ve.identifier=Ar(this.sliceSerialize(U)).toLowerCase()}function b(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.title=U}function w(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.url=U}function S(U){const Q=this.stack[this.stack.length-1];if(!Q.depth){const ve=this.sliceSerialize(U).length;Q.depth=ve}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function T(U){const Q=this.stack[this.stack.length-1];Q.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function N(){this.data.setextHeadingSlurpLineEnding=void 0}function L(U){const ve=this.stack[this.stack.length-1].children;let Se=ve[ve.length-1];(!Se||Se.type!=="text")&&(Se=Xt(),Se.position={start:Gi(U.start),end:void 0},ve.push(Se)),this.stack.push(Se)}function P(U){const Q=this.stack.pop();Q.value+=this.sliceSerialize(U),Q.position.end=Gi(U.end)}function O(U){const Q=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ve=Q.children[Q.children.length-1];ve.position.end=Gi(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Q.type)&&(L.call(this,U),P.call(this,U))}function I(){this.data.atHardBreak=!0}function R(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U}function j(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U}function z(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U}function $(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Q,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function F(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Q,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function A(U){const Q=this.sliceSerialize(U),ve=this.stack[this.stack.length-2];ve.label=FV(Q),ve.identifier=Ar(Q).toLowerCase()}function B(){const U=this.stack[this.stack.length-1],Q=this.resume(),ve=this.stack[this.stack.length-1];if(this.data.inReference=!0,ve.type==="link"){const Se=U.children;ve.children=Se}else ve.alt=Q}function E(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.url=U}function H(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.title=U}function q(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function re(U){const Q=this.resume(),ve=this.stack[this.stack.length-1];ve.label=Q,ve.identifier=Ar(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function oe(U){this.data.characterReferenceType=U.type}function V(U){const Q=this.sliceSerialize(U),ve=this.data.characterReferenceType;let Se;ve?(Se=zI(Q,ve==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Se=Fx(Q);const J=this.stack[this.stack.length-1];J.value+=Se}function pe(U){const Q=this.stack.pop();Q.position.end=Gi(U.end)}function Oe(U){P.call(this,U);const Q=this.stack[this.stack.length-1];Q.url=this.sliceSerialize(U)}function ie(U){P.call(this,U);const Q=this.stack[this.stack.length-1];Q.url="mailto:"+this.sliceSerialize(U)}function Me(){return{type:"blockquote",children:[]}}function Fe(){return{type:"code",lang:null,meta:null,value:""}}function We(){return{type:"inlineCode",value:""}}function ge(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function qe(){return{type:"emphasis",children:[]}}function Gt(){return{type:"heading",depth:0,children:[]}}function wt(){return{type:"break"}}function Rt(){return{type:"html",value:""}}function ln(){return{type:"image",title:null,url:"",alt:null}}function Bt(){return{type:"link",title:null,url:"",children:[]}}function at(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function Ue(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function nt(){return{type:"paragraph",children:[]}}function mt(){return{type:"strong",children:[]}}function Xt(){return{type:"text",value:""}}function pn(){return{type:"thematicBreak"}}}function Gi(e){return{line:e.line,column:e.column,offset:e.offset}}function YI(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?YI(e,r):VV(e,r)}}function VV(e,t){let n;for(n in t)if(XI.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function tS(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+rc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+rc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+rc({start:t.start,end:t.end})+") is still open")}function qV(e){const t=this;t.parser=n;function n(r){return UV(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function KV(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function GV(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
488
+ `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function OV(e){const r={constructs:BI([AV,...(e||{}).extensions||[]]),content:i(QU),defined:[],document:i(eW),flow:i(_V),lazy:{},string:i(bV),text:i(wV)};return r;function i(s){return o;function o(a){return jV(r,s,a)}}}function BV(e){for(;!UI(e););return e}const eS=/[\0\t\n\r]/g;function zV(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const l=[];let c,u,d,f,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),d=0,t="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if(eS.lastIndex=d,c=eS.exec(s),f=c&&c.index!==void 0?c.index:s.length,p=s.charCodeAt(f),!c){t=s.slice(d);break}if(p===10&&d===f&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<f&&(l.push(s.slice(d,f)),e+=f-d),p){case 0:{l.push(65533),e++;break}case 9:{for(u=Math.ceil(e/4)*4,l.push(-2);e++<u;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=f+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const $V=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function FV(e){return e.replace($V,HV)}function HV(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return zI(n.slice(s?2:1),s?16:10)}return Fx(n)||e}const XI={}.hasOwnProperty;function UV(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),WV(n)(BV(OV(n).document().write(zV()(e,t,!0))))}function WV(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Bt),autolinkProtocol:L,autolinkEmail:L,atxHeading:s(Gt),blockQuote:s(Me),characterEscape:L,characterReference:L,codeFenced:s(Fe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Fe,o),codeText:s(We,o),codeTextData:L,data:L,codeFlowValue:L,definition:s(ge),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(qe),hardBreakEscape:s(wt),hardBreakTrailing:s(wt),htmlFlow:s(Rt,o),htmlFlowData:L,htmlText:s(Rt,o),htmlTextData:L,image:s(ln),label:o,link:s(Bt),listItem:s(Ue),listItemValue:f,listOrdered:s(at,d),listUnordered:s(at),paragraph:s(nt),reference:M,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Gt),strong:s(mt),thematicBreak:s(pn)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:ie,autolinkProtocol:Oe,blockQuote:l(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:oe,characterReferenceMarkerNumeric:oe,characterReferenceValue:V,characterReference:pe,codeFenced:l(y),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:P,codeIndented:l(_),codeText:l(z),codeTextData:P,data:P,definition:l(),definitionDestinationString:w,definitionLabelString:x,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(I),hardBreakTrailing:l(I),htmlFlow:l(R),htmlFlowData:P,htmlText:l(j),htmlTextData:P,image:l(F),label:B,labelText:A,lineEnding:O,link:l($),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:re,resourceDestinationString:E,resourceTitleString:H,resource:q,setextHeading:l(N),setextHeadingLineSequence:T,setextHeadingText:k,strong:l(),thematicBreak:l()}};YI(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let Q={type:"root",children:[]};const ve={stack:[Q],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},Se=[];let J=-1;for(;++J<U.length;)if(U[J][1].type==="listOrdered"||U[J][1].type==="listUnordered")if(U[J][0]==="enter")Se.push(J);else{const Xe=Se.pop();J=i(U,Xe,J)}for(J=-1;++J<U.length;){const Xe=t[U[J][0]];XI.call(Xe,U[J][1].type)&&Xe[U[J][1].type].call(Object.assign({sliceSerialize:U[J][2].sliceSerialize},ve),U[J][1])}if(ve.tokenStack.length>0){const Xe=ve.tokenStack[ve.tokenStack.length-1];(Xe[1]||tS).call(ve,void 0,Xe[0])}for(Q.position={start:Gi(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:Gi(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},J=-1;++J<t.transforms.length;)Q=t.transforms[J](Q)||Q;return Q}function i(U,Q,ve){let Se=Q-1,J=-1,Xe=!1,Yt,Zt,ue,Ne;for(;++Se<=ve;){const Je=U[Se];switch(Je[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Je[0]==="enter"?J++:J--,Ne=void 0;break}case"lineEndingBlank":{Je[0]==="enter"&&(Yt&&!Ne&&!J&&!ue&&(ue=Se),Ne=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ne=void 0}if(!J&&Je[0]==="enter"&&Je[1].type==="listItemPrefix"||J===-1&&Je[0]==="exit"&&(Je[1].type==="listUnordered"||Je[1].type==="listOrdered")){if(Yt){let Dn=Se;for(Zt=void 0;Dn--;){const Qt=U[Dn];if(Qt[1].type==="lineEnding"||Qt[1].type==="lineEndingBlank"){if(Qt[0]==="exit")continue;Zt&&(U[Zt][1].type="lineEndingBlank",Xe=!0),Qt[1].type="lineEnding",Zt=Dn}else if(!(Qt[1].type==="linePrefix"||Qt[1].type==="blockQuotePrefix"||Qt[1].type==="blockQuotePrefixWhitespace"||Qt[1].type==="blockQuoteMarker"||Qt[1].type==="listItemIndent"))break}ue&&(!Zt||ue<Zt)&&(Yt._spread=!0),Yt.end=Object.assign({},Zt?U[Zt][1].start:Je[1].end),U.splice(Zt||Se,0,["exit",Yt,Je[2]]),Se++,ve++}if(Je[1].type==="listItemPrefix"){const Dn={type:"listItem",_spread:!1,start:Object.assign({},Je[1].start),end:void 0};Yt=Dn,U.splice(Se,0,["enter",Dn,Je[2]]),Se++,ve++,ue=void 0,Ne=!0}}}return U[Q][1]._spread=Xe,ve}function s(U,Q){return ve;function ve(Se){a.call(this,U(Se),Se),Q&&Q.call(this,Se)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(U,Q,ve){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([Q,ve||void 0]),U.position={start:Gi(Q.start),end:void 0}}function l(U){return Q;function Q(ve){U&&U.call(this,ve),c.call(this,ve)}}function c(U,Q){const ve=this.stack.pop(),Se=this.tokenStack.pop();if(Se)Se[0].type!==U.type&&(Q?Q.call(this,U,Se[0]):(Se[1]||tS).call(this,U,Se[0]));else throw new Error("Cannot close `"+U.type+"` ("+rc({start:U.start,end:U.end})+"): it’s not open");ve.position.end=Gi(U.end)}function u(){return $x(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(U){if(this.data.expectingFirstListItemValue){const Q=this.stack[this.stack.length-2];Q.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function p(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.lang=U}function m(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.meta=U}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function y(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function _(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U.replace(/(\r?\n|\r)$/g,"")}function x(U){const Q=this.resume(),ve=this.stack[this.stack.length-1];ve.label=Q,ve.identifier=Ar(this.sliceSerialize(U)).toLowerCase()}function b(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.title=U}function w(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.url=U}function S(U){const Q=this.stack[this.stack.length-1];if(!Q.depth){const ve=this.sliceSerialize(U).length;Q.depth=ve}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function T(U){const Q=this.stack[this.stack.length-1];Q.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function N(){this.data.setextHeadingSlurpLineEnding=void 0}function L(U){const ve=this.stack[this.stack.length-1].children;let Se=ve[ve.length-1];(!Se||Se.type!=="text")&&(Se=Xt(),Se.position={start:Gi(U.start),end:void 0},ve.push(Se)),this.stack.push(Se)}function P(U){const Q=this.stack.pop();Q.value+=this.sliceSerialize(U),Q.position.end=Gi(U.end)}function O(U){const Q=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ve=Q.children[Q.children.length-1];ve.position.end=Gi(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Q.type)&&(L.call(this,U),P.call(this,U))}function I(){this.data.atHardBreak=!0}function R(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U}function j(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U}function z(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U}function $(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Q,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function F(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Q,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function A(U){const Q=this.sliceSerialize(U),ve=this.stack[this.stack.length-2];ve.label=FV(Q),ve.identifier=Ar(Q).toLowerCase()}function B(){const U=this.stack[this.stack.length-1],Q=this.resume(),ve=this.stack[this.stack.length-1];if(this.data.inReference=!0,ve.type==="link"){const Se=U.children;ve.children=Se}else ve.alt=Q}function E(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.url=U}function H(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.title=U}function q(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function re(U){const Q=this.resume(),ve=this.stack[this.stack.length-1];ve.label=Q,ve.identifier=Ar(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function oe(U){this.data.characterReferenceType=U.type}function V(U){const Q=this.sliceSerialize(U),ve=this.data.characterReferenceType;let Se;ve?(Se=zI(Q,ve==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Se=Fx(Q);const J=this.stack[this.stack.length-1];J.value+=Se}function pe(U){const Q=this.stack.pop();Q.position.end=Gi(U.end)}function Oe(U){P.call(this,U);const Q=this.stack[this.stack.length-1];Q.url=this.sliceSerialize(U)}function ie(U){P.call(this,U);const Q=this.stack[this.stack.length-1];Q.url="mailto:"+this.sliceSerialize(U)}function Me(){return{type:"blockquote",children:[]}}function Fe(){return{type:"code",lang:null,meta:null,value:""}}function We(){return{type:"inlineCode",value:""}}function ge(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function qe(){return{type:"emphasis",children:[]}}function Gt(){return{type:"heading",depth:0,children:[]}}function wt(){return{type:"break"}}function Rt(){return{type:"html",value:""}}function ln(){return{type:"image",title:null,url:"",alt:null}}function Bt(){return{type:"link",title:null,url:"",children:[]}}function at(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function Ue(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function nt(){return{type:"paragraph",children:[]}}function mt(){return{type:"strong",children:[]}}function Xt(){return{type:"text",value:""}}function pn(){return{type:"thematicBreak"}}}function Gi(e){return{line:e.line,column:e.column,offset:e.offset}}function YI(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?YI(e,r):VV(e,r)}}function VV(e,t){let n;for(n in t)if(XI.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function tS(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+rc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+rc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+rc({start:t.start,end:t.end})+") is still open")}function qV(e){const t=this;t.parser=n;function n(r){return UV(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function KV(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function GV(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
489
489
  `}]}function XV(e,t){const n=t.value?t.value+`
490
490
  `:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function YV(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ZV(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function QV(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=tl(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let o,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=s+1,a+=1,e.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)}function JV(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function eq(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function ZI(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function tq(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ZI(e,t);const i={src:tl(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function nq(e,t){const n={src:tl(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function rq(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function iq(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ZI(e,t);const i={href:tl(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function sq(e,t){const n={href:tl(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function oq(e,t,n){const r=e.all(t),i=n?aq(n):QI(t),s={},o=[];if(typeof t.checked=="boolean"){const u=r[0];let d;u&&u.type==="element"&&u.tagName==="p"?d=u:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const u=r[a];(i||a!==0||u.type!=="element"||u.tagName!=="p")&&o.push({type:"text",value:`
491
491
  `}),u.type==="element"&&u.tagName==="p"&&!i?o.push(...u.children):o.push(u)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&o.push({type:"text",value:`
@@ -513,7 +513,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
513
513
  `))}function l(p,m,v,y){const _=v.enter("tableCell"),x=v.enter("phrasing"),b=v.containerPhrasing(p,{...y,before:s,after:s});return x(),_(),b}function c(p,m){return YK(p,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function u(p,m,v){const y=p.children;let _=-1;const x=[],b=m.enter("table");for(;++_<y.length;)x[_]=d(y[_],m,v);return b(),x}function d(p,m,v){const y=p.children;let _=-1;const x=[],b=m.enter("tableRow");for(;++_<y.length;)x[_]=l(y[_],p,m,v);return b(),x}function f(p,m,v){let y=yR.inlineCode(p,m,v);return v.stack.includes("tableCell")&&(y=y.replace(/\|/g,"\\$&")),y}}function OG(){return{exit:{taskListCheckValueChecked:NS,taskListCheckValueUnchecked:NS,paragraph:zG}}}function BG(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:$G}}}function NS(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function zG(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function $G(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=yR.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function FG(){return[xK(),$K(),WK(),IG(),OG()]}function HG(e){return{extensions:[yK(),FK(e),VK(),LG(e),BG()]}}const UG={tokenize:XG,partial:!0},bR={tokenize:YG,partial:!0},wR={tokenize:ZG,partial:!0},SR={tokenize:QG,partial:!0},WG={tokenize:JG,partial:!0},kR={name:"wwwAutolink",tokenize:KG,previous:ER},CR={name:"protocolAutolink",tokenize:GG,previous:NR},$i={name:"emailAutolink",tokenize:qG,previous:TR},di={};function VG(){return{text:di}}let Bs=48;for(;Bs<123;)di[Bs]=$i,Bs++,Bs===58?Bs=65:Bs===91&&(Bs=97);di[43]=$i;di[45]=$i;di[46]=$i;di[95]=$i;di[72]=[$i,CR];di[104]=[$i,CR];di[87]=[$i,kR];di[119]=[$i,kR];function qG(e,t,n){const r=this;let i,s;return o;function o(d){return!Gv(d)||!TR.call(r,r.previous)||Zx(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(d))}function a(d){return Gv(d)?(e.consume(d),a):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(WG,u,c)(d):d===45||d===95||yn(d)?(s=!0,e.consume(d),l):u(d)}function c(d){return e.consume(d),i=!0,l}function u(d){return s&&i&&Cn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function KG(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!ER.call(r,r.previous)||Zx(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(UG,e.attempt(bR,e.attempt(wR,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function GG(e,t,n){const r=this;let i="",s=!1;return o;function o(d){return(d===72||d===104)&&NR.call(r,r.previous)&&!Zx(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),a):n(d)}function a(d){if(Cn(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),a;if(d===58){const f=i.toLowerCase();if(f==="http"||f==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),s?c:(s=!0,l)):n(d)}function c(d){return d===null||$h(d)||ot(d)||vo(d)||Zf(d)?n(d):e.attempt(bR,e.attempt(wR,u),n)(d)}function u(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function XG(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function YG(e,t,n){let r,i,s;return o;function o(c){return c===46||c===95?e.check(SR,l,a)(c):c===null||ot(c)||vo(c)||c!==45&&Zf(c)?l(c):(s=!0,e.consume(c),o)}function a(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),o}function l(c){return i||r||!s?n(c):t(c)}}function ZG(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(SR,t,s)(o):o===null||ot(o)||vo(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function QG(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||ot(a)||vo(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||ot(a)||vo(a)?t(a):r(a)}function s(a){return Cn(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):Cn(a)?(e.consume(a),o):n(a)}}function JG(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return yn(s)?n(s):t(s)}}function ER(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ot(e)}function NR(e){return!Cn(e)}function TR(e){return!(e===47||Gv(e))}function Gv(e){return e===43||e===45||e===46||e===95||yn(e)}function Zx(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const eX={tokenize:lX,partial:!0};function tX(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:sX,continuation:{tokenize:oX},exit:aX}},text:{91:{name:"gfmFootnoteCall",tokenize:iX},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:nX,resolveTo:rX}}}}function nX(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const c=Ar(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function rX(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function iX(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(s>999||d===93&&!o||d===null||d===91||ot(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return i.includes(Ar(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return ot(d)||(o=!0),s++,e.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(e.consume(d),s++,c):c(d)}}function sX(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(m)}function u(m){if(o>999||m===93&&!a||m===null||m===91||ot(m))return n(m);if(m===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return s=Ar(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return ot(m)||(a=!0),o++,e.consume(m),m===92?d:u}function d(m){return m===91||m===92||m===93?(e.consume(m),o++,u):u(m)}function f(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),Ve(e,p,"gfmFootnoteDefinitionWhitespace")):n(m)}function p(m){return t(m)}}function oX(e,t,n){return e.check(hu,t,e.attempt(eX,t,n))}function aX(e){e.exit("gfmFootnoteDefinition")}function lX(e,t,n){const r=this;return Ve(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function cX(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},f=[["enter",u,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",d,a]],p=a.parser.constructs.insideSpan.null;p&&tr(f,f.length,0,Qf(p,o.slice(c+1,l),a)),tr(f,f.length,0,[["exit",d,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",u,a]]),tr(o,c-1,l-c+3,f),l=c+f.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const c=this.previous,u=this.events;let d=0;return f;function f(m){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(m):(o.enter("strikethroughSequenceTemporary"),p(m))}function p(m){const v=za(c);if(m===126)return d>1?l(m):(o.consume(m),d++,p);if(d<2&&!n)return l(m);const y=o.exit("strikethroughSequenceTemporary"),_=za(m);return y._open=!_||_===2&&!!v,y._close=!v||v===2&&!!_,a(m)}}}class uX{constructor(){this.map=[]}add(t,n,r){dX(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function dX(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function hX(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function fX(){return{flow:{null:{name:"table",tokenize:pX,resolveAll:mX}}}}function pX(e,t,n){const r=this;let i=0,s=0,o;return a;function a(P){let O=r.events.length-1;for(;O>-1;){const j=r.events[O][1].type;if(j==="lineEnding"||j==="linePrefix")O--;else break}const I=O>-1?r.events[O][1].type:null,R=I==="tableHead"||I==="tableRow"?k:l;return R===k&&r.parser.lazy[r.now().line]?n(P):R(P)}function l(P){return e.enter("tableHead"),e.enter("tableRow"),c(P)}function c(P){return P===124||(o=!0,s+=1),u(P)}function u(P){return P===null?n(P):ye(P)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),p):n(P):ze(P)?Ve(e,u,"whitespace")(P):(s+=1,o&&(o=!1,i+=1),P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),o=!0,u):(e.enter("data"),d(P)))}function d(P){return P===null||P===124||ot(P)?(e.exit("data"),u(P)):(e.consume(P),P===92?f:d)}function f(P){return P===92||P===124?(e.consume(P),d):d(P)}function p(P){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(P):(e.enter("tableDelimiterRow"),o=!1,ze(P)?Ve(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):m(P))}function m(P){return P===45||P===58?y(P):P===124?(o=!0,e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),v):S(P)}function v(P){return ze(P)?Ve(e,y,"whitespace")(P):y(P)}function y(P){return P===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),_):P===45?(s+=1,_(P)):P===null||ye(P)?w(P):S(P)}function _(P){return P===45?(e.enter("tableDelimiterFiller"),x(P)):S(P)}function x(P){return P===45?(e.consume(P),x):P===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),b):(e.exit("tableDelimiterFiller"),b(P))}function b(P){return ze(P)?Ve(e,w,"whitespace")(P):w(P)}function w(P){return P===124?m(P):P===null||ye(P)?!o||i!==s?S(P):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(P)):S(P)}function S(P){return n(P)}function k(P){return e.enter("tableRow"),T(P)}function T(P){return P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),T):P===null||ye(P)?(e.exit("tableRow"),t(P)):ze(P)?Ve(e,T,"whitespace")(P):(e.enter("data"),N(P))}function N(P){return P===null||P===124||ot(P)?(e.exit("data"),T(P)):(e.consume(P),P===92?L:N)}function L(P){return P===92||P===124?(e.consume(P),N):N(P)}}function mX(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,u,d;const f=new uX;for(;++n<e.length;){const p=e[n],m=p[1];p[0]==="enter"?m.type==="tableHead"?(a=!1,l!==0&&(TS(f,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",c,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,u={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",u,t]])),i=m.type==="tableDelimiterRow"?2:u?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],d=cd(f,t,s,i,void 0,d),s=[0,0,0,0]),o[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],d=cd(f,t,s,i,void 0,d)),s=o,o=[s[1],n,0,0])):m.type==="tableHead"?(a=!0,l=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],d=cd(f,t,s,i,n,d)):o[1]!==0&&(d=cd(f,t,o,i,n,d)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&TS(f,t,l,c,u),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=hX(t.events,n))}return e}function cd(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},Go(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Go(t.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=Go(t.events,n[2]),u=Go(t.events,n[3]),d={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,v=n[3]-n[2]-1;e.add(m,v,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(s.end=Object.assign({},Go(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function TS(e,t,n,r,i){const s=[],o=Go(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function Go(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const gX={name:"tasklistCheck",tokenize:_X};function vX(){return{text:{91:gX}}}function _X(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return ot(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return ye(l)?t(l):ze(l)?e.check({tokenize:xX},t,n)(l):n(l)}}function xX(e,t,n){return Ve(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function yX(e){return BI([VG(),tX(),cX(e),fX(),vX()])}const bX={};function Wc(e){const t=this,n=e||bX,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(yX(n)),s.push(FG()),o.push(HG(n))}const wX=/<command-name>([\s\S]*?)<\/command-name>/i,SX=/<command-message>([\s\S]*?)<\/command-message>/i,kX=/<command-args>([\s\S]*?)<\/command-args>/i,CX=/<(local-command-[a-z]+|command-(?:stdout|stderr))>[\s\S]*?<\/\1>/gi;function np(e){if(!e)return{commandName:null,commandMessage:null,commandArgs:null,body:""};const t=e.match(wX),n=e.match(SX),r=e.match(kX);let i=e;return t&&(i=i.replace(t[0],"")),n&&(i=i.replace(n[0],"")),r&&(i=i.replace(r[0],"")),i=i.replace(CX,""),i=i.trim(),{commandName:t?t[1].trim():null,commandMessage:n?n[1].trim():null,commandArgs:r?r[1].trim():null,body:i}}const EX=/\.(png|jpe?g|webp|gif|svg)$/i;function NX(e,t){if((typeof t=="string"?t:null)!==e)return!1;try{const r=new URL(e);return EX.test(r.pathname)}catch{return!1}}function TX(e){try{return new URL(e).pathname.split("/").filter(Boolean).pop()??""}catch{return""}}const Vc={a:({node:e,href:t,children:n,...r})=>typeof t=="string"&&NX(t,n)?h.jsxs("span",{className:"my-1 inline-flex flex-col items-start gap-1 align-top",children:[h.jsx("img",{src:t,alt:TX(t),className:"max-w-full h-auto rounded border border-border"}),h.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"max-w-full truncate text-[11px] text-text-300 underline decoration-dotted underline-offset-2 hover:text-text-100",children:t})]}):h.jsx("a",{...r,href:t,target:"_blank",rel:"noopener noreferrer",children:n})};function PX({text:e,forkTarget:t}){const{body:n}=np(e);return n?h.jsxs("div",{className:"group flex min-w-0 max-w-full flex-col items-start","data-testid":"msg-line-assistant-wrapper",children:[h.jsx("div",{"data-testid":"msg-line-assistant",className:"assistant-markdown w-full min-w-0 max-w-full py-1 break-words",children:h.jsx(Hc,{remarkPlugins:[Wc],components:Vc,children:n})}),t?h.jsxs("div",{className:"mt-1 flex flex-row items-center gap-1",children:[t.onFork?h.jsxs("button",{type:"button","data-testid":"assistant-msg-fork","aria-label":"fork from this message",title:"从这条消息派生新 session(截断之后的对话)",onClick:()=>t.onFork(t.messageUuid),className:"inline-flex items-center justify-start gap-1 h-7 w-7 md:h-6 md:w-auto md:px-1.5 rounded-md text-[11px] text-text-400/60 md:text-text-400 hover:bg-text-100/5 hover:text-text-200 md:opacity-0 md:group-hover:opacity-100 md:transition-opacity cursor-pointer",children:[h.jsx(LN,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{className:"hidden md:inline",children:"Fork"})]}):null,t.onQuickAsk?h.jsxs("button",{type:"button","data-testid":"assistant-msg-quick-ask","aria-label":"quick ask from this message",title:"快速问答:从这条消息派生临时会话,关闭即删",onClick:()=>t.onQuickAsk(t.messageUuid),className:"inline-flex items-center justify-start gap-1 h-7 w-7 md:h-6 md:w-auto md:px-1.5 rounded-md text-[11px] text-text-400/60 md:text-text-400 hover:bg-text-100/5 hover:text-text-200 md:opacity-0 md:group-hover:opacity-100 md:transition-opacity cursor-pointer",children:[h.jsx(zN,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{className:"hidden md:inline",children:"问一下"})]}):null]}):null]}):null}function IX({text:e}){const[t,n]=g.useState(!1);return e?h.jsxs("div",{"data-testid":"msg-line-thinking",className:"text-[12px] text-text-400",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"flex items-center gap-1 hover:text-text-300 transition-colors cursor-pointer","aria-expanded":t,"data-testid":"msg-line-thinking-toggle",children:[t?h.jsx(li,{className:"w-3 h-3"}):h.jsx(ci,{className:"w-3 h-3"}),h.jsx("span",{children:"💭 Thinking"})]}),t?h.jsx("div",{className:"ml-4 mt-1 italic text-text-400 whitespace-pre-wrap break-words",children:e}):null]}):null}function PR(e){if(!e)return!1;const n=e.split("#")[0].split("?")[0].toLowerCase();return n.endsWith(".md")||n.endsWith(".markdown")}const RX=new Set(["Write","Edit","MultiEdit","NotebookEdit"]);function Xv(e){return RX.has(e)}function MX({tool:e,relPath:t,scope:n,onShareFile:r}){if(!Xv(e)||!t||!n||!r)return null;const i=PR(t)?"md-rendered":"raw";return h.jsx("span",{"data-testid":"file-edit-hover-row",className:"inline-flex shrink-0 items-center gap-1",children:h.jsx("span",{role:"button",tabIndex:0,"data-testid":"file-edit-share-btn","aria-label":"Share link",title:"Share link",onClick:s=>{s.stopPropagation(),r(t,i)},onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.stopPropagation(),s.preventDefault(),r(t,i))},className:"inline-flex h-3.5 w-3.5 items-center justify-center text-text-400 hover:text-text-200 cursor-pointer",children:h.jsx(G_,{className:"h-3.5 w-3.5"})})})}function AX(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.file_path=="string"&&t.file_path||typeof t.notebook_path=="string"&&t.notebook_path||typeof t.path=="string"&&t.path||null||null}function IR(e,t){const[n,r]=g.useState({kind:"idle"});return g.useEffect(()=>{let i=!1,s=null;r({kind:"loading"});const o={};return t&&(o.Authorization=`Bearer ${t}`),fetch(e,{headers:o,credentials:"omit"}).then(async a=>{if(!a.ok)throw new Error(`HTTP ${a.status}`);return a.blob()}).then(a=>{if(i)return;const l=URL.createObjectURL(a);s=l,r({kind:"ready",objectUrl:l})}).catch(a=>{i||r({kind:"error",message:a.message})}),()=>{i=!0,s&&URL.revokeObjectURL(s)}},[e,t]),n}function jX({url:e,bearerToken:t,alt:n,className:r}){const i=IR(e,t);return h.jsxs("div",{"data-testid":"blob-image","data-state":i.kind,className:ne("relative inline-flex items-center justify-center rounded-md border border-border bg-bg-0",r),children:[i.kind==="loading"?h.jsx("div",{className:"flex h-24 w-32 items-center justify-center",children:h.jsx(rr,{className:"h-4 w-4 animate-spin text-text-400"})}):null,i.kind==="error"?h.jsxs("div",{className:"flex h-24 w-32 items-center justify-center gap-1 px-2 text-[11px] text-text-400",children:[h.jsx(Rs,{className:"h-3 w-3"}),h.jsx("span",{title:i.message,children:"加载失败"})]}):null,i.kind==="ready"?h.jsx("img",{src:i.objectUrl,alt:n,className:"block max-h-[180px] max-w-[420px] rounded-md object-contain"}):null]})}function DX({url:e,bearerToken:t,className:n}){const r=IR(e,t);return h.jsxs("div",{"data-testid":"blob-video","data-state":r.kind,className:ne("relative inline-flex items-center justify-center rounded-md border border-border bg-bg-0",n),children:[r.kind==="loading"?h.jsx(rr,{className:"h-4 w-4 animate-spin text-text-400"}):null,r.kind==="error"?h.jsx("span",{className:"px-2 text-[11px] text-text-400",children:"加载失败"}):null,r.kind==="ready"?h.jsx("video",{src:r.objectUrl,controls:!0,className:"block max-h-[240px] max-w-[420px] rounded-md"}):null]})}const LX=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg"]),OX=new Set([".mp4",".webm",".mov"]),BX=new Set([".pdf"]);function zX(e){const t=e.lastIndexOf("."),n=t>=0?e.slice(t).toLowerCase():"";return LX.has(n)?"image":OX.has(n)?"video":BX.has(n)?"pdf":"binary"}function RR(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function $X({relPath:e,scope:t,size:n}){const r=Af();if(r.actionsLevel==="none")return null;const i=WO(r,t,e);if(!i)return null;const s=zX(e);return s==="image"?h.jsx("div",{"data-testid":"file-edit-inline-preview","data-kind":"image",className:"mt-2",children:h.jsx(jX,{url:i,bearerToken:r.httpToken,alt:e})}):s==="video"?h.jsx("div",{"data-testid":"file-edit-inline-preview","data-kind":"video",className:"mt-2",children:h.jsx(DX,{url:i,bearerToken:r.httpToken})}):s==="pdf"?h.jsx(FX,{relPath:e,url:i,size:n}):typeof n=="number"&&n>=1024*1024?h.jsxs("div",{"data-testid":"file-edit-inline-preview","data-kind":"binary",className:"mt-2 inline-flex items-center gap-1.5 rounded border border-border bg-bg-50 px-2 py-1 text-[11px] text-text-400",children:[h.jsx(Ms,{className:"h-3 w-3"}),h.jsx("span",{className:"font-mono",children:e.split("/").pop()}),h.jsx("span",{children:"·"}),h.jsx("span",{children:RR(n)})]}):null}function FX({relPath:e,url:t,size:n}){return h.jsxs("a",{"data-testid":"file-edit-inline-preview","data-kind":"pdf",href:t,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1.5 rounded border border-border bg-bg-50 px-2 py-1 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(Ms,{className:"h-3 w-3"}),h.jsx("span",{className:"font-mono",children:e.split("/").pop()}),typeof n=="number"?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:"·"}),h.jsx("span",{children:RR(n)})]}):null,h.jsx(Mc,{className:"h-3 w-3"})]})}const HX={Bash:UN,Read:Ms,Edit:FN,Write:n6,Grep:kv,Glob:kv};function UX(e){return HX[e]??rz}function WX(e){if(!e||typeof e!="object")return"";const t=e,n=t.command??t.file_path??t.path??t.pattern??t.query??t.url??t.description;if(typeof n=="string")return n;for(const r of Object.values(t))if(typeof r=="string"&&r)return r;return""}function MR({tool:e,input:t,output:n,error:r,pending:i=!1,expandedBody:s,fileScope:o,onOpenInTab:a,onPreviewMarkdown:l,onShareFile:c}){const[u,d]=g.useState(!1),f=!!r,p=UX(e),m=WX(t),v=AX(t);return h.jsxs("div",{"data-testid":"msg-line-tool","data-tool":e,className:ne("group min-w-0 max-w-full rounded-md border px-3 py-2 text-[13px]",f?"border-destructive/40 bg-destructive/5":"border-border bg-bg-50"),children:[h.jsxs("button",{type:"button",onClick:()=>d(y=>!y),"aria-expanded":u,"data-testid":"msg-line-tool-header",className:"flex w-full items-center gap-2 text-left cursor-pointer min-w-0",children:[f?h.jsx(Rs,{className:"w-4 h-4 text-destructive shrink-0"}):h.jsx(p,{className:ne("w-4 h-4 shrink-0",i?"text-text-400":"text-text-300")}),h.jsx("span",{className:"font-medium text-text-100 shrink-0",children:e}),m?(()=>{if(f||!Xv(e)||!v)return null;const _=PR(v)&&l?l:a;return _?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"msg-line-tool-preview","data-clickable":"true",title:m,onClick:x=>{x.stopPropagation(),_(v)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.stopPropagation(),x.preventDefault(),_(v))},className:"text-[12px] text-accent font-mono truncate min-w-0 max-w-full cursor-pointer underline underline-offset-2 hover:opacity-80",children:m}):null})()??h.jsx("span",{"data-testid":"msg-line-tool-preview",className:"text-[12px] text-text-400 font-mono truncate min-w-0 max-w-full",title:m,children:m}):null,h.jsx("span",{"aria-hidden":"true","data-testid":"msg-line-tool-header-spacer",className:"flex-1 min-w-0 self-stretch"}),i?h.jsx(rr,{"data-testid":"msg-line-tool-pending",className:"w-3 h-3 text-text-400 animate-spin shrink-0"}):null,!f&&o?h.jsx(MX,{tool:e,relPath:v,scope:o,...c?{onShareFile:c}:{}}):null]}),u?s!==void 0?h.jsxs("div",{"data-testid":"msg-line-tool-body",className:"mt-2 min-w-0 text-[12px]",children:[s,f?h.jsxs("div",{className:"mt-2",children:[h.jsx("div",{className:"text-destructive mb-0.5",children:"error"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-destructive/40 rounded p-2 overflow-auto text-destructive",children:String(r)})]}):null]}):h.jsxs("div",{"data-testid":"msg-line-tool-body",className:"mt-2 min-w-0 space-y-1 text-[12px]",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-text-400 mb-0.5",children:"input"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 overflow-auto text-text-200",children:JSON.stringify(t,null,2)})]}),n!==void 0?h.jsxs("div",{children:[h.jsx("div",{className:"text-text-400 mb-0.5",children:"output"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 overflow-auto text-text-200",children:typeof n=="string"?n:JSON.stringify(n,null,2)})]}):null,f?h.jsxs("div",{children:[h.jsx("div",{className:"text-destructive mb-0.5",children:"error"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-destructive/40 rounded p-2 overflow-auto text-destructive",children:String(r)})]}):null]}):null,!f&&o&&v&&Xv(e)?h.jsx($X,{relPath:v,scope:o}):null]})}var VX=Symbol.for("react.lazy"),Wh=Ha[" use ".trim().toString()];function qX(e){return typeof e=="object"&&e!==null&&"then"in e}function AR(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===VX&&"_payload"in e&&qX(e._payload)}function KX(e){const t=XX(e),n=g.forwardRef((r,i)=>{let{children:s,...o}=r;AR(s)&&typeof Wh=="function"&&(s=Wh(s._payload));const a=g.Children.toArray(s),l=a.find(ZX);if(l){const c=l.props.children,u=a.map(d=>d===l?g.Children.count(c)>1?g.Children.only(null):g.isValidElement(c)?c.props.children:null:d);return h.jsx(t,{...o,ref:i,children:g.isValidElement(c)?g.cloneElement(c,void 0,u):null})}return h.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}var GX=KX("Slot");function XX(e){const t=g.forwardRef((n,r)=>{let{children:i,...s}=n;if(AR(i)&&typeof Wh=="function"&&(i=Wh(i._payload)),g.isValidElement(i)){const o=JX(i),a=QX(s,i.props);return i.type!==g.Fragment&&(a.ref=r?ou(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var YX=Symbol("radix.slottable");function ZX(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===YX}function QX(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function JX(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const PS=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,IS=qN,eY=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return IS(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:s}=t,o=Object.keys(i).map(c=>{const u=n==null?void 0:n[c],d=s==null?void 0:s[c];if(u===null)return null;const f=PS(u)||PS(d);return i[c][f]}),a=n&&Object.entries(n).reduce((c,u)=>{let[d,f]=u;return f===void 0||(c[d]=f),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:d,className:f,...p}=u;return Object.entries(p).every(m=>{let[v,y]=m;return Array.isArray(y)?y.includes({...s,...a}[v]):{...s,...a}[v]===y})?[...c,d,f]:c},[]);return IS(e,o,l,n==null?void 0:n.class,n==null?void 0:n.className)},tY=eY("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-accent text-accent-contrast hover:bg-accent-hover",destructive:"bg-destructive text-white hover:bg-destructive-hover",outline:"border border-border bg-transparent text-text-100 hover:bg-bg-200",ghost:"bg-transparent text-text-200 hover:bg-bg-200 hover:text-text-100"},size:{sm:"h-8 px-3 text-xs",md:"h-9 px-4",lg:"h-11 px-6 text-base"}},defaultVariants:{variant:"default",size:"md"}}),ni=g.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},s)=>{const o=r?GX:"button";return h.jsx(o,{ref:s,className:ne(tY({variant:t,size:n}),e),...i})});ni.displayName="Button";function nY({tool:e,input:t,onRespond:n,onInterrupt:r}){return h.jsxs("div",{"data-testid":"msg-line-permission",className:"min-w-0 max-w-full rounded-md border border-warning/40 bg-warning-dim/60 px-3 py-2.5 text-[13px]",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 mb-1.5",children:[h.jsx(V6,{className:"w-4 h-4 text-warning shrink-0"}),h.jsxs("span",{className:"min-w-0 font-medium text-text-100 truncate",children:["权限请求:",e]}),r?h.jsx("button",{type:"button",onClick:r,"data-testid":"msg-line-permission-interrupt","aria-label":"interrupt current turn",title:"中断当前轮次(不杀进程)",className:"ml-auto h-6 w-6 rounded-md flex items-center justify-center text-text-400 hover:bg-text-100/10 hover:text-text-200 transition-colors cursor-pointer",children:h.jsx($N,{className:"w-3.5 h-3.5",strokeWidth:2})}):null]}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 mb-2 max-h-[140px] overflow-auto text-[12px] text-text-200",children:JSON.stringify(t,null,2)}),h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(ni,{size:"sm",variant:"default",onClick:()=>n(!0,!1),"data-testid":"msg-line-permission-allow",children:"Allow"}),h.jsx(ni,{size:"sm",variant:"outline",onClick:()=>n(!0,!0),"data-testid":"msg-line-permission-allow-always",children:"Allow Always"}),h.jsx(ni,{size:"sm",variant:"destructive",onClick:()=>n(!1,!1),"data-testid":"msg-line-permission-deny",children:"Deny"})]})]})}function rY({message:e}){return h.jsxs("div",{"data-testid":"msg-line-error",className:"flex min-w-0 max-w-full items-start gap-2 text-destructive text-[13px] rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2",children:[h.jsx(Ac,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}const RS=/\[attachment:(image|file):([^\]]+)\]/g;function iY(e){const t=[];let n;for(;(n=RS.exec(e))!==null;){const i=n[2],s=decodeURIComponent(i.split("/").pop()??"file");t.push({type:n[1],url:i,fileName:s})}const r=e.replace(RS,"").trim();return{attachments:t,text:r}}function sY(e,t){const n=t.filter(i=>i.status==="done"&&i.url);return n.length===0?e:n.map(i=>`[attachment:${i.mimeType.startsWith("image/")?"image":"file"}:${i.url}]`).join(`
514
514
  `)+`
515
515
  `+e}const oY=/\[skill:(.+?):(\/[^\]]+)\]/g;function aY(e){const t=[],n=e.replace(oY,(r,i)=>(t.push(i),""));return{skills:t,text:t.length>0?n.trim():e}}function lY({text:e,senderDisplayName:t,rewindTarget:n}){const r=SI(e),{attachments:i,text:s}=iY(r),{skills:o,text:a}=aY(s),{commandName:l,body:c}=np(a),u=c.length>0;return u||i.length>0||!!l||o.length>0?(l||o.length>0)&&!u&&i.length===0?h.jsxs("div",{className:"flex min-w-0 max-w-full justify-end gap-1.5 py-2 mt-2","data-testid":"msg-line-user",children:[o.map((f,p)=>h.jsxs("span",{"data-testid":"user-skill-chip",className:"inline-flex items-center rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300",children:["/",f]},`${f}-${p}`)),l?h.jsx("span",{className:"inline-flex items-center rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300",children:l}):null]}):h.jsxs("div",{className:"group flex min-w-0 max-w-full flex-col items-end py-2 mt-2","data-testid":"msg-line-user",children:[h.jsxs("div",{className:"min-w-0 max-w-[85%] rounded-2xl rounded-br-sm bg-accent px-3.5 py-2 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:[i.length>0?h.jsx(cY,{attachments:i}):null,o.length>0?h.jsx("div",{className:ne("flex flex-wrap gap-1.5",(u||l)&&"mb-1.5"),children:o.map((f,p)=>h.jsxs("span",{"data-testid":"user-skill-chip",className:"inline-flex items-center rounded-md bg-white/15 px-2 py-0.5 text-[11px] font-mono text-white/90",children:["/",f]},`${f}-${p}`))}):null,l?h.jsx("div",{className:ne("flex",u&&"mb-1.5"),children:h.jsx("span",{"data-testid":"user-command-chip",className:"inline-flex items-center rounded-md bg-white/15 px-2 py-0.5 text-[11px] font-mono text-white/90",children:l})}):null,u?h.jsx("div",{className:"text-[14px] text-white font-medium leading-relaxed",children:c}):null]}),t?h.jsx("div",{"data-testid":"user-msg-sender-label",className:"mt-1 text-[11px] text-text-400",children:t}):null,n?h.jsxs("button",{type:"button","data-testid":"user-msg-rewind","aria-label":"rewind to this message",title:"回退到这条消息(会撤销之后 CC 的文件编辑)",onClick:()=>n.onRewind(n.userMessageId),className:"mt-1 inline-flex items-center gap-1 h-6 px-1.5 rounded-md text-[11px] text-text-400 hover:bg-text-100/5 hover:text-text-200 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:[h.jsx(WN,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{children:"Rewind"})]}):null]}):null}function cY({attachments:e}){return h.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5","data-testid":"user-attachment-row",children:e.map(t=>h.jsx(uY,{attachment:t},t.url))})}function uY({attachment:e}){return e.type==="image"?h.jsx("img",{src:e.url,alt:e.fileName,"data-testid":"user-attachment-image",className:"h-16 w-16 rounded object-cover shrink-0 border border-bg-300/50"}):h.jsxs("div",{"data-testid":"user-attachment-file",className:"flex items-center gap-1.5 rounded-md border border-bg-300 bg-bg-100/60 px-2 py-1 text-[12px] text-text-200",children:[h.jsx(Ms,{className:"h-3.5 w-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"max-w-[140px] truncate",children:e.fileName})]})}const dY={"task-notification":"子任务通知","slash-command":"斜杠命令","local-command":"本地命令输出","system-reminder":"系统提醒","skill-hint":"Skill 注入","meta-text":"系统消息","attachment-skills":"技能列表","attachment-deferred-tools":"Deferred 工具变更"},hY={"task-notification":Lb,"slash-command":G6,"local-command":UN,"system-reminder":Lb,"skill-hint":Mh,"meta-text":ON,"attachment-skills":Mh,"attachment-deferred-tools":A6};function fY({metaKind:e,text:t}){const[n,r]=g.useState(!1),i=hY[e];if(e==="slash-command"){const{commandName:o,commandMessage:a,commandArgs:l,body:c}=np(t),u=o??(a?`/${a}`:null),d=!!(l&&l.length>0),f=c.length>0;return!u&&!d&&!f?null:h.jsxs("div",{"data-testid":"msg-line-user-meta","data-meta-kind":e,className:"flex min-w-0 max-w-full flex-col items-end gap-0.5 py-1",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 max-w-full",children:[u?h.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300 shrink-0",children:[h.jsx(i,{className:"w-3 h-3 opacity-70"}),u]}):null,d?h.jsx("span",{"data-testid":"user-meta-command-args",className:"min-w-0 text-[12px] text-text-200 whitespace-pre-wrap break-words max-w-[70ch] [overflow-wrap:anywhere]",children:l}):null]}),f?h.jsx("span",{className:"ml-2 max-w-[60%] truncate text-[11px] text-text-400",children:c}):null]})}const s=t.replace(/\s+/g," ").trim().slice(0,80);return h.jsxs("div",{"data-testid":"msg-line-user-meta","data-meta-kind":e,className:"flex min-w-0 max-w-full flex-col items-start gap-1 py-1",children:[h.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>r(o=>!o),className:ne("group inline-flex items-center gap-1.5 rounded-md border border-bg-200/60 bg-bg-100/40","px-2 py-1 text-[11px] text-text-400 hover:bg-bg-200/40 transition-colors max-w-full"),children:[h.jsx(i,{className:"w-3 h-3 opacity-70 shrink-0"}),h.jsx("span",{className:"font-medium shrink-0",children:dY[e]}),h.jsx("span",{className:"truncate text-text-400/80 max-w-[60ch]",children:s}),n?h.jsx(li,{className:"w-3 h-3 opacity-60 shrink-0"}):h.jsx(ci,{className:"w-3 h-3 opacity-60 shrink-0"})]}),n?h.jsx("pre",{"data-testid":"user-meta-body",className:"w-full max-w-full whitespace-pre-wrap break-words text-[11px] text-text-400 bg-bg-50/60 rounded-md p-2 border border-bg-200/60 [overflow-wrap:anywhere]",children:t}):null]})}function pY({text:e,metaSource:t}){return t==="owner"?h.jsx("div",{className:"flex min-w-0 max-w-full flex-col items-start py-1.5","data-testid":"msg-line-owner-meta",children:h.jsxs("div",{className:ne("inline-flex min-w-0 max-w-[85%] items-start gap-2 rounded-md","border-l-[3px] border-accent bg-accent-dim px-3 py-2"),children:[h.jsx(w6,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-accent","aria-label":"补充信息"}),h.jsx("span",{className:"min-w-0 text-[12px] leading-relaxed text-text-100 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}):h.jsxs("div",{className:"flex min-w-0 max-w-full items-start gap-1.5 py-1 text-[11px] text-text-400","data-testid":"msg-line-cc-meta",children:[h.jsx(ON,{className:"mt-0.5 h-3 w-3 shrink-0"}),h.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}function zr(e,t){const r=new RegExp(`<${t}\\b[^>]*>([\\s\\S]*?)</${t}>`,"i").exec(e);if(!r)return;const i=r[1].trim();return i||void 0}function wm(e,t){const r=new RegExp(`${t}\\s*=\\s*"([^"]+)"`,"i").exec(e);if(!r)return;const i=Number(r[1]);return Number.isFinite(i)?i:void 0}function jR(e){var i,s,o;const t={};if(!e)return t;t.taskId=zr(e,"task-id"),t.toolUseId=zr(e,"tool-use-id"),t.outputFile=zr(e,"output-file"),t.status=zr(e,"status"),t.summary=zr(e,"summary"),t.result=zr(e,"result");const n=zr(e,"usage");if(n){const a=(i=/<total_tokens>\s*(\d+)\s*<\/total_tokens>/i.exec(n))==null?void 0:i[1],l=(s=/<tool_uses>\s*(\d+)\s*<\/tool_uses>/i.exec(n))==null?void 0:s[1],c=(o=/<duration_ms>\s*(\d+)\s*<\/duration_ms>/i.exec(n))==null?void 0:o[1];a&&(t.totalTokens=Number(a)),l&&(t.toolUses=Number(l)),c&&(t.durationMs=Number(c))}const r=zr(e,"worktree");if(r)t.worktreePath=zr(r,"worktreePath"),t.worktreeBranch=zr(r,"worktreeBranch");else{const a=/<worktree\b([^>]*)\/>/i.exec(e);if(a){const l=a[1],c=/worktreePath\s*=\s*"([^"]+)"/i.exec(l),u=/worktreeBranch\s*=\s*"([^"]+)"/i.exec(l);c&&(t.worktreePath=c[1]),u&&(t.worktreeBranch=u[1])}}if(t.totalTokens===void 0&&t.toolUses===void 0&&t.durationMs===void 0){const a=wm(e,"total_tokens"),l=wm(e,"tool_uses"),c=wm(e,"duration_ms");a!==void 0&&(t.totalTokens=a),l!==void 0&&(t.toolUses=l),c!==void 0&&(t.durationMs=c)}return t}function mY(e){if(!e||!Number.isFinite(e))return null;if(e<1e3)return`${e}ms`;const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}m${r.toString().padStart(2,"0")}s`}function gY({text:e,taskId:t,parentToolUseId:n}){const r=g.useMemo(()=>jR(e),[e]),[i,s]=g.useState(!1),o=t??r.taskId,a=n??r.toolUseId,l=r.status==="failed"?h.jsx(Rs,{className:"w-3.5 h-3.5 text-error"}):r.status==="completed"?h.jsx(jf,{className:"w-3.5 h-3.5 text-success"}):h.jsx(K_,{className:"w-3.5 h-3.5 text-text-400"}),c=r.status??"unknown",u=mY(r.durationMs);return h.jsxs("div",{"data-testid":"msg-line-agent-notification","data-task-id":o??"","data-parent-tool-use-id":a??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/40",children:[h.jsxs("button",{type:"button","aria-expanded":i,onClick:()=>s(d=>!d),className:ne("flex w-full min-w-0 items-start gap-2 px-2.5 py-1.5 text-left text-[12px]","hover:bg-bg-200/40 rounded-md transition-colors"),children:[h.jsx("span",{className:"mt-[2px] shrink-0",children:l}),h.jsxs("span",{className:"flex-1 min-w-0",children:[h.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[h.jsx("span",{className:"font-medium text-text-200",children:"子任务"}),h.jsx("span",{className:"text-text-400 text-[11px] font-mono",children:o?o.slice(0,12):"未知"}),h.jsx("span",{className:"text-text-400 text-[11px] uppercase tracking-wide",children:c}),u?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",u]}):null,r.totalTokens?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",r.totalTokens," tok"]}):null,r.toolUses?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",r.toolUses," tools"]}):null]}),r.summary?h.jsx("span",{className:"block truncate text-text-300 text-[12px] mt-0.5",children:r.summary}):null]}),i?h.jsx(li,{className:"w-3.5 h-3.5 mt-[3px] text-text-400 shrink-0"}):h.jsx(ci,{className:"w-3.5 h-3.5 mt-[3px] text-text-400 shrink-0"})]}),i?h.jsxs("div",{"data-testid":"agent-notification-body",className:"min-w-0 border-t border-bg-200/60 px-3 py-2 text-[12px] text-text-300 space-y-2",children:[r.worktreePath||r.worktreeBranch?h.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-400",children:[h.jsx(LN,{className:"w-3 h-3"}),r.worktreeBranch?h.jsx("span",{className:"font-mono",children:r.worktreeBranch}):null,r.worktreePath?h.jsx("span",{className:"truncate font-mono",children:r.worktreePath}):null]}):null,r.outputFile?h.jsxs("div",{className:"text-[11px] text-text-400",children:[h.jsx("span",{children:"输出文件:"}),h.jsx("span",{className:"font-mono",children:r.outputFile})]}):null,a?h.jsxs("div",{className:"text-[11px] text-text-400",children:[h.jsx("span",{children:"父工具调用:"}),h.jsx("span",{className:"font-mono",children:a})]}):null,r.result?h.jsx("div",{"data-testid":"agent-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(Hc,{remarkPlugins:[Wc],components:Vc,children:r.result})}):h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细结果"})]}):null]})}const DR=g.createContext(null);function vY({children:e}){const[t,n]=g.useState({agentId:null}),r=g.useCallback((o,a)=>{n({agentId:o,agentType:a})},[]),i=g.useCallback(()=>{n(o=>({agentId:null,agentType:o.agentType}))},[]),s=g.useMemo(()=>({state:t,open:r,close:i}),[t,r,i]);return h.jsx(DR.Provider,{value:s,children:e})}function LR(){return g.useContext(DR)}function _Y(e){if(e==null)return null;if(typeof e=="string")return e;if(Array.isArray(e)){const t=[];for(const n of e)if(n&&typeof n=="object"){const r=n;r.type==="text"&&typeof r.text=="string"&&t.push(r.text)}else typeof n=="string"&&t.push(n);return t.length?t.join(`
516
- `):null}if(typeof e=="object"){const t=e;if(typeof t.text=="string")return t.text}return null}function MS(e){if(!e||!Number.isFinite(e))return null;if(e<1e3)return`${e}ms`;const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}m${r.toString().padStart(2,"0")}s`}function xY(e){return!e||!Number.isFinite(e)?null:e<1e3?`${e} tok`:e<1e4?`${(e/1e3).toFixed(1)}k tok`:`${Math.round(e/1e3)}k tok`}const yY={readCount:"read",searchCount:"search",bashCount:"bash",editFileCount:"edit",linesAdded:"+lines",linesRemoved:"-lines",otherToolCount:"other"};function bY(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e)){if(!r||r<=0)continue;const i=yY[n]??n;t.push(`${i}:${r}`)}return t}function wY({description:e,input:t,output:n,error:r,pending:i,notifications:s,toolResultExtra:o,progress:a}){const[l,c]=g.useState(!1),u=LR(),d=g.useMemo(()=>{if(!t||typeof t!="object")return null;const N=t;return typeof N.prompt=="string"?N.prompt:null},[t]),f=(o==null?void 0:o.prompt)??d,p=g.useMemo(()=>_Y(n),[n]),m=o==null?void 0:o.stats,v=a==null?void 0:a.stats,y=MS((m==null?void 0:m.durationMs)??(v==null?void 0:v.durationMs)),_=xY((m==null?void 0:m.tokens)??(v==null?void 0:v.tokens)),x=bY(m==null?void 0:m.toolStats),b=i&&(a!=null&&a.lastToolName)?`now:${a.lastToolName}`:null,w=!!(o!=null&&o.agentType||y||_||x.length>0||b),S=(o==null?void 0:o.agentId)??(a==null?void 0:a.agentId),k=g.useMemo(()=>s.map(N=>({taskId:N.taskId,text:N.text,parsed:jR(N.text)})),[s]),T=r?h.jsx(Rs,{className:"w-3.5 h-3.5 text-error"}):i?h.jsx(rr,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx(jf,{className:"w-3.5 h-3.5 text-green-500"});return h.jsxs("div",{"data-testid":"msg-line-agent-call","data-pending":i?"true":"false","data-has-error":r?"true":"false","data-notification-count":s.length,"data-has-stats":w?"true":"false","data-agent-id":S??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("button",{type:"button","aria-expanded":l,onClick:()=>c(N=>!N),className:ne("flex w-full min-w-0 items-center gap-2 px-2.5 py-1.5 text-left text-[13px]","hover:bg-bg-200/40 rounded-md transition-colors"),children:[h.jsx("span",{className:"w-5 h-5 flex items-center justify-center text-[10px] rounded bg-violet-500/10 text-violet-500 shrink-0","aria-hidden":!0,children:h.jsx(oz,{className:"w-3 h-3"})}),h.jsx("span",{className:"shrink-0",children:T}),h.jsx("span",{className:"flex-1 min-w-0 truncate font-medium text-text-200",children:e}),w?null:s.length>0?h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums shrink-0",children:[s.length," 次通知"]}):null,S&&(u!=null&&u.open)?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"open-subagent-btn-header","data-agent-id":S,"aria-label":"打开子 agent 对话",onClick:N=>{N.stopPropagation(),u.open(S,o==null?void 0:o.agentType)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.stopPropagation(),N.preventDefault(),u.open(S,o==null?void 0:o.agentType))},className:"shrink-0 inline-flex items-center justify-center w-3.5 h-3.5 text-text-400 hover:text-text-200",children:h.jsx(Mc,{className:"w-3.5 h-3.5"})}):null,l?h.jsx(li,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(ci,{className:"w-3.5 h-3.5 text-text-400 shrink-0"})]}),i&&(a!=null&&a.description)?h.jsx("div",{"data-testid":"agent-call-progress-desc",className:"px-3 pt-0 pb-1 text-[12px] text-text-300 truncate",children:a.description}):null,w?h.jsxs("div",{"data-testid":"agent-call-stats",className:"flex items-center gap-1.5 flex-wrap px-3 pb-1.5 pt-0 text-[11px] text-text-400",children:[o!=null&&o.agentType?h.jsx("span",{"data-testid":"agent-call-stats-type",className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-violet-400 font-medium",children:o.agentType}):null,y?h.jsx("span",{className:"tabular-nums",children:y}):null,_?h.jsx("span",{className:"tabular-nums",children:_}):null,b?h.jsx("span",{"data-testid":"agent-call-stats-now",className:"font-mono tabular-nums text-blue-400",children:b}):null,x.map(N=>h.jsx("span",{className:"font-mono tabular-nums text-text-400/80",children:N},N)),s.length>0?h.jsxs("span",{className:"tabular-nums text-text-400/70",children:["· ",s.length," 次通知"]}):null]}):null,l?h.jsxs("div",{"data-testid":"agent-call-body",className:"min-w-0 border-t border-bg-200/60 px-3 py-2 space-y-3",children:[r?h.jsx("div",{className:"text-[12px] text-error whitespace-pre-wrap",children:r}):null,k.map((N,L)=>{const P=N.parsed,O=MS(P.durationMs);return h.jsxs("div",{"data-testid":"agent-call-notification","data-task-id":N.taskId??"",className:"min-w-0 rounded-md border border-bg-200/60 bg-bg-0/40 p-2 space-y-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-400 flex-wrap",children:[h.jsx("span",{className:"font-mono",children:(N.taskId??P.taskId??"未知").slice(0,12)}),h.jsx("span",{className:"uppercase tracking-wide",children:P.status??"unknown"}),O?h.jsxs("span",{className:"tabular-nums",children:["· ",O]}):null,P.totalTokens?h.jsxs("span",{className:"tabular-nums",children:["· ",P.totalTokens," tok"]}):null,P.toolUses?h.jsxs("span",{className:"tabular-nums",children:["· ",P.toolUses," tools"]}):null,P.worktreeBranch?h.jsxs("span",{className:"font-mono",children:["· ",P.worktreeBranch]}):null]}),P.summary?h.jsx("div",{className:"text-[12px] text-text-300",children:P.summary}):null,P.result?h.jsx("div",{"data-testid":"agent-call-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(Hc,{remarkPlugins:[Wc],components:Vc,children:P.result})}):null]},`${N.taskId??"n"}-${L}`)}),f?h.jsxs("div",{"data-testid":"agent-call-prompt-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"任务指令"}),h.jsx("pre",{"data-testid":"agent-call-prompt",className:"max-w-full whitespace-pre-wrap break-words text-[11px] text-text-300 bg-bg-50/60 rounded p-2 border border-bg-200/60 max-h-64 overflow-auto [overflow-wrap:anywhere]",children:f})]}):null,p?h.jsxs("div",{"data-testid":"agent-call-result-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"子 agent 报告"}),h.jsx("div",{"data-testid":"agent-call-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(Hc,{remarkPlugins:[Wc],components:Vc,children:p})})]}):null,!p&&k.length===0&&!r&&!f?h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细信息"}):null,S&&(u!=null&&u.open)?h.jsx("div",{className:"flex justify-end",children:h.jsxs("button",{type:"button","data-testid":"open-subagent-btn","data-agent-id":S,onClick:()=>u.open(S,o==null?void 0:o.agentType),className:ne("inline-flex items-center gap-1 rounded-md border border-bg-200/60","bg-bg-100/40 hover:bg-bg-200/40 transition-colors","px-2 py-1 text-[11px] text-text-300"),children:[h.jsx(Mc,{className:"w-3 h-3"}),h.jsx("span",{children:"打开子 agent 对话"})]})}):null]}):null]})}function OR({title:e,items:t,live:n,progressColor:r="bg-green-500",listKind:i,children:s}){const[o,a]=g.useState(!!n),l=t.length,c=t.filter(d=>d.status==="completed").length,u=l>0?Math.round(c/l*100):0;return h.jsxs("div",{"data-testid":"msg-line-checklist","data-list-kind":i,className:"min-w-0 max-w-full py-1",children:[h.jsxs("button",{type:"button",onClick:()=>a(d=>!d),"aria-expanded":o,className:"flex items-center gap-2.5 w-full text-left rounded-md px-1.5 py-1 hover:bg-text-100/5 cursor-pointer",children:[o?h.jsx(li,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(ci,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"text-[13px] font-medium text-text-200",children:e}),h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums",children:[c,"/",l]}),h.jsx("div",{className:"flex-1 max-w-[120px] h-1.5 rounded-full bg-text-100/10 overflow-hidden",children:h.jsx("div",{className:ne("h-full rounded-full transition-all duration-300",r),style:{width:`${u}%`}})})]}),o?h.jsxs("div",{"data-testid":"checklist-body",className:"ml-6 mt-0.5",children:[h.jsx("div",{className:"space-y-px",children:t.map((d,f)=>h.jsxs("div",{className:"flex min-w-0 items-start gap-2 py-0.5 px-1",children:[h.jsx("span",{className:"w-4 h-4 mt-0.5 flex items-center justify-center shrink-0",children:d.status==="completed"?h.jsx(Za,{className:"w-3.5 h-3.5 text-green-500"}):d.status==="in_progress"&&n?h.jsx(rr,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx("span",{className:"w-2 h-2 rounded-full border border-text-400/40"})}),h.jsx("span",{className:ne("min-w-0 text-[13px] leading-snug break-words [overflow-wrap:anywhere]",d.status==="completed"?"text-text-400 line-through":"text-text-200"),children:d.status==="in_progress"&&d.activeForm?d.activeForm:d.content})]},`${f}-${d.content}`))}),s]}):null]})}function SY({todos:e,live:t}){return h.jsx(OR,{title:"Tasks",items:e,live:t,progressColor:"bg-green-500",listKind:"todo"})}function kY({tasks:e,live:t}){return h.jsx(OR,{title:"Plan",items:e,live:t,progressColor:"bg-blue-500",listKind:"plan"})}function CY(e){if(!e||!Number.isFinite(e))return null;const t=Date.now()-e;if(t<0)return null;const n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const s=Math.floor(i/24);if(s<7)return`${s}d ago`;const o=Math.floor(s/7);return o<5?`${o}w ago`:new Date(e).toISOString().slice(0,10)}function EY(e){return(e.split("/").pop()??e)||e}function NY({memories:e}){return!e||e.length===0?null:h.jsxs("div",{"data-testid":"memory-callout",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[12px] text-text-300 border-b border-bg-200/60",children:[h.jsx(TB,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}),h.jsx("span",{className:"font-medium",children:"项目记忆"}),h.jsxs("span",{className:"text-text-400 tabular-nums",children:["· ",e.length]})]}),h.jsx("ul",{className:"divide-y divide-bg-200/40",children:e.map(t=>h.jsx(TY,{memory:t},t.path))})]})}function TY({memory:e}){const[t,n]=g.useState(!1),r=CY(e.mtimeMs),i=e.content.replace(/\s+/g," ").trim().slice(0,80);return h.jsxs("li",{className:"px-2.5 py-1.5",children:[h.jsxs("button",{type:"button","aria-expanded":t,onClick:()=>n(s=>!s),className:ne("flex w-full items-center gap-1.5 text-left text-[12px]","hover:bg-bg-200/30 rounded-sm py-0.5"),children:[t?h.jsx(li,{className:"w-3 h-3 text-text-400 shrink-0"}):h.jsx(ci,{className:"w-3 h-3 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-300 shrink-0 max-w-[20ch] truncate",title:e.path,children:EY(e.path)}),h.jsx("span",{className:"flex-1 min-w-0 truncate text-text-400/80",children:i}),r?h.jsx("span",{className:"shrink-0 text-[11px] text-text-400 tabular-nums",children:r}):null]}),t?h.jsx("pre",{"data-testid":"memory-callout-body",className:"mt-1 max-w-full whitespace-pre-wrap break-words text-[12px] text-text-300 bg-bg-50/60 rounded-md p-2 border border-bg-200/60 [overflow-wrap:anywhere]",children:e.content}):null]})}function PY({toolUseId:e,questions:t,onSubmit:n,onCancel:r,submittedAnswers:i}){const[s,o]=g.useState({}),[a,l]=g.useState({}),[c,u]=g.useState({}),[d,f]=g.useState(!1),[p,m]=g.useState(!1),v=i!==void 0&&Object.keys(i).length>0,y=v||p,_=!n&&!v,x=(S,k)=>{const T={labels:new Set,freeText:""};if(!v||!i)return T;const N=i[S];if(typeof N!="string")return T;const L=N.split(",").map(R=>R.trim()).filter(Boolean),P=new Set(k.map(R=>R.label)),O=new Set,I=[];for(const R of L)P.has(R)?O.add(R):I.push(R);return{labels:O,freeText:I.join(", ")}},b=g.useMemo(()=>t.every(S=>{if((c[S.question]??"").trim().length>0)return!0;if(S.multiSelect){const T=a[S.question];return!!(T&&T.size>0)}return typeof s[S.question]=="string"&&s[S.question].length>0}),[t,s,a,c]),w=async()=>{if(!b||d||y||_||!n)return;const S={};for(const k of t){const T=(c[k.question]??"").trim();if(k.multiSelect){const N=a[k.question],L=N?k.options.filter(P=>N.has(P.label)).map(P=>P.label):[];if(T.length>0&&L.push(T),L.length===0)continue;S[k.question]=L.join(", ")}else if(T.length>0)S[k.question]=T;else{const N=s[k.question];typeof N=="string"&&(S[k.question]=N)}}f(!0);try{await n(S),m(!0)}finally{f(!1)}};return h.jsxs("div",{"data-testid":"msg-line-question","data-tool-use-id":e,className:"min-w-0 max-w-full rounded-md border border-accent/40 bg-accent/5 px-3 py-2.5 text-[13px]",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 mb-2",children:[h.jsx(HB,{className:"w-4 h-4 text-accent shrink-0"}),h.jsx("span",{className:"min-w-0 font-medium text-text-100",children:"需要你的回答 / Need your answer"}),t.length>1?h.jsxs("span",{className:"ml-auto text-[12px] text-text-400","data-testid":"msg-line-question-count",children:[t.length," 个问题"]}):null]}),h.jsx("div",{className:"flex flex-col gap-3 mb-3",children:t.map((S,k)=>{const T=`q-${k}`,N=`${e}-${k}`,L=x(S.question,S.options),P=y||_,O=c[S.question]??"",I=v?L.freeText:p?(c[S.question]??"").trim():"";return h.jsxs("div",{"data-testid":"msg-line-question-item",children:[S.question?h.jsx("div",{className:"text-text-200 mb-1.5",children:S.question}):null,h.jsx("div",{className:"flex flex-col gap-1",children:S.options.map((R,j)=>{var F;const z=`${T}-${j}`,$=v?L.labels.has(R.label):S.multiSelect?!!((F=a[S.question])!=null&&F.has(R.label)):s[S.question]===R.label;return h.jsxs("label",{className:"flex min-w-0 items-start gap-2 cursor-pointer select-none py-1 px-2 rounded hover:bg-bg-100",children:[h.jsx("input",{type:S.multiSelect?"checkbox":"radio",name:N,value:R.label,checked:$,disabled:y||_,onChange:()=>{y||_||(S.multiSelect?l(A=>{const B=new Set(A[S.question]??[]);return B.has(R.label)?B.delete(R.label):B.add(R.label),{...A,[S.question]:B}}):o(A=>({...A,[S.question]:R.label})))},className:"mt-0.5","data-testid":"msg-line-question-option"}),h.jsxs("span",{className:"flex min-w-0 flex-col",children:[h.jsx("span",{className:"text-text-100 [overflow-wrap:anywhere]",children:R.label}),R.description?h.jsx("span",{className:"text-[12px] text-text-400 [overflow-wrap:anywhere]",children:R.description}):null]})]},z)})}),P?I.length>0?h.jsx("div",{className:"mt-2 rounded-lg border border-accent/15 bg-bg-100/60 px-3 py-2 text-[13px] leading-relaxed text-text-200 [overflow-wrap:anywhere]","data-testid":"msg-line-question-freetext-result",children:I}):null:h.jsx("textarea",{rows:3,value:O,placeholder:"或自行输入回答...",onChange:R=>{const j=R.target.value;u(z=>({...z,[S.question]:j}))},className:"mt-2 w-full resize-y rounded-lg border border-accent/20 bg-bg-000/60 px-3 py-2 text-[13px] leading-relaxed text-text-100 placeholder:text-text-400 outline-none transition-colors focus:border-accent/60 focus:bg-bg-000","data-testid":"msg-line-question-freetext"})]},T)})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ni,{size:"sm",variant:"default",onClick:()=>void w(),disabled:!b||d||y||_,"data-testid":"msg-line-question-submit",children:y?"已提交 / Submitted":_?"已结束 / Ended":"提交 / Submit"}),r&&!y&&!_?h.jsx(ni,{size:"sm",variant:"ghost",onClick:()=>void r(),disabled:d,"data-testid":"msg-line-question-cancel",children:"跳过 / Skip"}):null]})]})}function IY({toolUseId:e,questions:t,historicalAnswers:n,realtimeAnswers:r,onSubmit:i,onCancel:s}){const o=r??n,a=g.useCallback(async c=>{i&&await i(e,c)},[i,e]),l=g.useCallback(async()=>{s&&await s(e)},[s,e]);return h.jsx(PY,{toolUseId:e,questions:t,onSubmit:i?a:void 0,...s?{onCancel:l}:{},submittedAnswers:o})}function RY(){const e=new Map,t=(n,r)=>`${n}::${r}`;return{register(n,r,i){e.set(t(n,r),i)},resolve(n,r){return n?e.get(t(n,r))??null:null},reset(){e.clear()}}}const pu=RY();function BR({lines:e,onPermissionRespond:t,onPermissionInterrupt:n,topSlot:r,onRewind:i,rewindableUserMessageIds:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v}){const y=g.useMemo(()=>P7(e),[e]);return h.jsxs("div",{"data-testid":"message-list",className:"flex w-full min-w-0 max-w-full flex-col gap-2 px-4 py-3",children:[r,y.map(_=>MY(_,{onRewind:i,rewindableUserMessageIds:s,onPermissionRespond:t,onPermissionInterrupt:n,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v}))]})}function MY(e,t){const{onRewind:n,rewindableUserMessageIds:r,onPermissionRespond:i,onPermissionInterrupt:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v}=t,y=`${e.kind}-${e.seq}`;switch(e.kind){case"session-init":return null;case"user-text":{const _=typeof e.uuid=="string"?e.uuid:void 0,x=!!(n&&_&&(!r||r.has(_)));return h.jsx(lY,{text:e.text,senderDisplayName:e.senderDisplayName,rewindTarget:x&&_&&n?{userMessageId:_,onRewind:n}:void 0},y)}case"user-meta":return h.jsx(fY,{metaKind:e.metaKind,text:e.text},y);case"meta-text":return h.jsx(pY,{text:e.text,metaSource:e.metaSource},y);case"agent-notification":return h.jsx(gY,{text:e.text,taskId:e.taskId,parentToolUseId:e.parentToolUseId},y);case"assistant-text":{const _=typeof e.uuid=="string"?e.uuid:void 0,x=_&&(o||a)?{messageUuid:_,onFork:o,onQuickAsk:a}:void 0;return h.jsx(PX,{text:M7(e.text),forkTarget:x},y)}case"assistant-thinking":return h.jsx(IX,{text:e.text},y);case"permission-inline":return h.jsx(nY,{tool:e.tool,input:e.input,onRespond:i??(()=>{}),onInterrupt:s},y);case"error":return h.jsx(rY,{message:e.message},y);case"turn-end":return null;case"merged-tool":return AY(e,y,{fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v});case"merged-agent":return h.jsx(wY,{description:e.description,input:e.input,output:e.output,error:e.error,pending:e.pending,notifications:e.notifications,toolResultExtra:e.toolResultExtra,progress:e.progress},y);case"plan-card":return h.jsx(kY,{tasks:e.tasks},y);case"todo-checklist":return h.jsx(SY,{todos:e.todos},y);case"memory-callout":return h.jsx(NY,{memories:e.memories},y);case"question-card":{const _=d===void 0||d.has(e.toolUseId);return h.jsx(IY,{toolUseId:e.toolUseId,questions:e.questions,historicalAnswers:e.submittedAnswers,realtimeAnswers:l==null?void 0:l[e.toolUseId],onSubmit:_?c:void 0,..._&&u?{onCancel:u}:{}},y)}default:return null}}function AY(e,t,n){const r=pu.resolve(e.toolKind,e.tool),i=r?r.render({input:e.input,output:e.output,error:e.error,pending:e.pending,toolUseId:e.toolUseId,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}}):null;return h.jsx(st.Fragment,{children:i??h.jsx(MR,{tool:e.tool,input:e.input,output:e.output,error:e.error,pending:e.pending,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}})},t)}function $d(e){return e==="codex"?"Codex":"Claude Code"}const jY={builtin:"Commands",global:"Global",project:"Project",plugin:"Plugin"},AS={builtin:0,global:1,project:2,plugin:3};function DY({query:e,skills:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>zR(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++)a[d].source!==u&&(c.add(d),u=a[d].source);return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.length===0?null:h.jsx("div",{"data-testid":"cc-skill-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:a.map((c,u)=>{const d=u===n,f=l.has(u);return h.jsxs(st.Fragment,{children:[f?h.jsx("div",{className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:jY[c.source]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":`cc-skill-item-${c.name}`,onMouseEnter:()=>r(u),onClick:()=>i(c),className:ne("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsxs("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:["/",c.name]}),c.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-auto",children:c.description}):null]})]},`${c.source}/${c.name}`)})})}function zR(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>i.name.toLowerCase().includes(n)||(i.description??"").toLowerCase().includes(n)):e.slice();return r.sort((i,s)=>(AS[i.source]??9)-(AS[s.source]??9)),r.slice(0,30)}const LY={builtin:"Built-in",global:"Global",project:"Project",policy:"Policy",plugin:"Plugin",persona:"My personas",contact:"People","remote-persona":"Remote personas"},jS={builtin:0,global:1,project:2,policy:3,plugin:4,persona:5,contact:6,"remote-persona":7};function Vh(e){switch(e.kind){case"persona":return"persona";case"contact":return"contact";case"remote-persona":return"remote-persona";case"cc-agent":return e.agent.source}}function OY(e){switch(e.kind){case"persona":return`persona/${e.persona.personaId}`;case"contact":return`contact/${e.contact.deviceId}`;case"remote-persona":return`remote/${e.deviceId}/${e.persona.personaId}`;case"cc-agent":return`${e.agent.source}/${e.agent.name}`}}function BY(e){switch(e.kind){case"persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"contact":return`${e.contact.displayName} ${e.contact.deviceId}`.toLowerCase();case"remote-persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"cc-agent":{const t=e.agent;return`${t.name} ${t.description??""} ${t.whenToUse??""}`.toLowerCase()}}}function zY(e){switch(e.kind){case"persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-persona-${e.persona.personaId}`};case"contact":return{displayName:`@${e.contact.displayName}`,description:e.contact.deviceId,testid:`cc-agent-item-contact-${e.contact.deviceId}`};case"remote-persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-remote-${e.deviceId}-${e.persona.personaId}`};case"cc-agent":return{displayName:`@${e.agent.name}`,description:e.agent.description,whenToUse:e.agent.whenToUse,plugin:e.agent.plugin,testid:`cc-agent-item-${e.agent.name}`}}}function $R(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>BY(i).includes(n)):e.slice();return r.sort((i,s)=>(jS[Vh(i)]??9)-(jS[Vh(s)]??9)),r.slice(0,30)}function DS({query:e,entries:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>$R(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++){const f=Vh(a[d]);f!==u&&(c.add(d),u=f)}return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.length===0?null:h.jsx("div",{"data-testid":"cc-agent-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:a.map((c,u)=>{const d=u===n,f=l.has(u),p=Vh(c),m=zY(c);return h.jsxs(st.Fragment,{children:[f?h.jsx("div",{"data-testid":`cc-agent-group-header-${p}`,"data-source":p,className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:LY[p]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":m.testid,onMouseEnter:()=>r(u),onClick:()=>i(c),className:ne("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsx("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:m.displayName}),m.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-2",children:m.description}):null,m.whenToUse?h.jsx("span",{className:"text-[10px] text-text-400/70 italic truncate ml-auto",children:m.whenToUse}):null,m.plugin?h.jsx("span",{className:"text-[10px] text-text-400/70 ml-2 shrink-0",children:m.plugin}):null]})]},OY(c))})})}function $Y({attachment:e,onRemove:t,onOpenPreview:n}){const r=e.mimeType.startsWith("image/"),i=e.status==="error",s=e.status==="uploading",o=r&&e.status==="done"&&!!e.previewUrl&&!!n;return h.jsxs("div",{"data-testid":`attachment-pill-${e.id}`,className:ne("group relative flex items-center gap-1.5 rounded-lg border px-2 py-1.5 text-[12px] transition-colors",i?"border-red-400/40 bg-red-500/5":"border-bg-300 bg-bg-100"),children:[r&&e.previewUrl?h.jsxs("div",{className:"relative h-7 w-7 shrink-0",children:[h.jsx("img",{src:e.previewUrl,alt:e.fileName,onClick:o?n:void 0,"data-testid":`attachment-thumb-${e.id}`,className:ne("h-7 w-7 rounded object-cover",o&&"cursor-pointer hover:opacity-80",s&&"opacity-40")}),s?h.jsx(rr,{"data-testid":`attachment-spinner-${e.id}`,className:"absolute inset-0 m-auto h-3.5 w-3.5 animate-spin text-text-200"}):null]}):h.jsx("div",{className:"relative flex h-7 w-7 items-center justify-center rounded bg-text-100/5 shrink-0",children:s?h.jsx(rr,{"data-testid":`attachment-spinner-${e.id}`,className:"h-3.5 w-3.5 animate-spin text-text-400"}):h.jsx(Ms,{className:"h-3.5 w-3.5 text-text-400"})}),h.jsx("span",{className:ne("max-w-[120px] truncate text-text-200",s&&"text-text-400"),title:e.error??e.fileName,children:e.fileName}),i?h.jsx(Rs,{className:"h-3 w-3 text-red-400 shrink-0"}):null,h.jsx("button",{type:"button",onClick:t,"data-testid":`attachment-remove-${e.id}`,className:"flex h-4 w-4 items-center justify-center rounded-full text-text-400 hover:text-text-100 hover:bg-text-100/10 transition-colors cursor-pointer shrink-0","aria-label":"remove",children:h.jsx(Rn,{className:"h-3 w-3"})})]})}function FY({attachments:e,onRemove:t,onOpenPreview:n}){return e.length===0?null:h.jsx("div",{"data-testid":"attachment-row",className:"flex flex-wrap gap-1.5 mb-2 px-1",children:e.map(r=>h.jsx($Y,{attachment:r,onRemove:()=>t(r.id),onOpenPreview:n?()=>n(r):void 0},r.id))})}class Bl extends Error{constructor(t,n,r){super(n),this.code=t,this.status=r,this.name="UploadAttachmentError"}}async function HY(e){if(!e.httpBaseUrl)throw new Bl("TUNNEL_NOT_READY","daemon httpBaseUrl unavailable");if(!e.httpToken)throw new Bl("NO_AUTH","daemon httpToken unavailable");const t=new URLSearchParams({sessionId:e.sessionId,fileName:e.file.name,mimeType:e.file.type||"application/octet-stream"}),n=`${e.httpBaseUrl.replace(/\/$/,"")}/attachments/upload?${t.toString()}`;let r;try{r=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${e.httpToken}`,"Content-Type":e.file.type||"application/octet-stream"},body:e.file})}catch(i){throw new Bl("NETWORK_ERROR",i.message)}if(!r.ok){let i="UPLOAD_FAILED",s=`HTTP ${r.status}`;try{const o=await r.json();o.code&&(i=o.code),o.message&&(s=o.message)}catch{}throw new Bl(i,s,r.status)}return await r.json()}const LS=25*1024*1024,UY="image/*,.txt,.md,.markdown,.csv,.json,.log,.yaml,.yml,.html,.xml,.pdf",WY=["image/","text/"],VY=new Set(["application/json","application/xml","application/x-yaml","application/yaml","application/pdf"]),qY=new Set(["txt","md","markdown","csv","json","log","yaml","yml","html","xml","pdf"]);function KY(e){var r;const t=(e.type||"").toLowerCase();if(t&&WY.some(i=>t.startsWith(i))||t&&VY.has(t))return!0;const n=((r=e.name.split(".").pop())==null?void 0:r.toLowerCase())??"";return n.length>0&&qY.has(n)}let GY=0;const XY=()=>`att-${++GY}-${Date.now()}`;function YY(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(typeof r.result=="string"?r.result:""),r.onerror=()=>n(r.error??new Error("read failed")),r.readAsDataURL(e)})}function ZY(e){const[t,n]=g.useState(e.initial??[]),r=g.useCallback(async o=>{const a=Array.from(o);if(a.length===0)return;const l=[],c=[],u=[];for(const d of a){const f={id:XY(),fileName:d.name,mimeType:d.type||"application/octet-stream"};if(!KY(d)){c.push({...f,url:null,status:"error",error:"不支持的文件类型"});continue}if(d.size>LS){c.push({...f,url:null,status:"error",error:`超过 ${Math.round(LS/1024/1024)}MB 上限`});continue}if(e.sessionId==null){u.push({id:f.id,file:d,mimeType:f.mimeType}),c.push({...f,url:null,status:"uploading"});continue}const p=f.mimeType.startsWith("image/")?URL.createObjectURL(d):void 0;c.push({...f,url:null,status:"uploading",...p?{previewUrl:p}:{}}),l.push({id:f.id,file:d})}n(d=>[...d,...c]);for(const d of u)try{const f=await YY(d.file);n(p=>p.map(m=>m.id===d.id?{...m,url:f,status:"done",...d.mimeType.startsWith("image/")?{previewUrl:f}:{}}:m))}catch(f){n(p=>p.map(m=>m.id===d.id?{...m,status:"error",error:f.message??"read failed"}:m))}l.length!==0&&await Promise.all(l.map(async d=>{try{const f=await HY({httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken,sessionId:e.sessionId,file:d.file});n(p=>p.map(m=>m.id===d.id?{...m,url:f.url,status:"done"}:m))}catch(f){const p=f instanceof Bl?f.code:"UPLOAD_FAILED",m=f.message??"upload failed";n(v=>v.map(y=>y.id===d.id?{...y,status:"error",error:`${p}: ${m}`}:y))}}))},[e.sessionId,e.httpBaseUrl,e.httpToken]),i=g.useCallback(o=>{n(a=>a.filter(l=>l.id!==o))},[]),s=g.useCallback(()=>{n([])},[]);return{attachments:t,setAttachments:n,addFiles:r,removeAttachment:i,clearAttachments:s}}const Yv=new Map,QY=[];function OS(e){if(e)return Yv.get(e)}function BS(e,t){e&&(t.draft.length===0&&t.attachments.length===0?Yv.delete(e):Yv.set(e,t))}function JY(e,t){return e.replace(/(^|\s)\/(\S+)/g,(n,r,i)=>{const s=t.find(o=>o.name===i&&o.path);return s!=null&&s.path?`${r}[skill:${i}:${s.path}]`:n})}function eZ({api:e,cwd:t,sessionKey:n,onSend:r,disabled:i,onNewSession:s,onClearSession:o,tool:a,spawnableContacts:l=QY,ensureRemotePersonas:c,remotePersonasByDeviceId:u}){const d=OS(n),[f,p]=g.useState((d==null?void 0:d.draft)??""),[m,v]=g.useState(!1),y=g.useRef(null),_=g.useRef(!1),x=g.useCallback(()=>{_.current=!0},[]),b=g.useCallback(()=>{_.current=!1},[]),w=Af(),{attachments:S,setAttachments:k,addFiles:T,removeAttachment:N,clearAttachments:L}=ZY({httpBaseUrl:w.httpBaseUrl,httpToken:w.httpToken,sessionId:n,initial:(d==null?void 0:d.attachments)??[]}),[P,O]=g.useState([]),[I,R]=g.useState(!1),[j,z]=g.useState(0),[$,F]=g.useState(!1),[A,B]=g.useState([]),[E,H]=g.useState(!1),[q,M]=g.useState(0),[re,oe]=g.useState(!1),[V,pe]=g.useState([]),[Oe,ie]=g.useState(!1),[Me,Fe]=g.useState(null),[We,ge]=g.useState(!1),qe=g.useRef(null),Gt=g.useMemo(()=>{const ue=[];return s&&ue.push({name:"new",source:"builtin",description:"在当前目录下新建会话"}),o&&n&&ue.push({name:"clear",source:"builtin",description:"清除当前会话"}),ue},[s,o,n]),wt=g.useMemo(()=>[...Gt,...P],[Gt,P]),Rt=g.useMemo(()=>{const ue=f.match(/^\/(\S*)$/);return ue?ue[1]:null},[f]),ln=Rt!==null&&!$,Bt=g.useMemo(()=>Rt!==null?zR(wt,Rt):[],[wt,Rt]),at=g.useMemo(()=>{const ue=f.match(/^@(\S*)$/);return ue?ue[1]:null},[f]),Ue=at!==null&&!re,nt=g.useMemo(()=>Me?((u==null?void 0:u.get(Me.deviceId))??[]).map(Ne=>({kind:"remote-persona",persona:Ne,deviceId:Me.deviceId})):[...A.map(ue=>({kind:"cc-agent",agent:ue})),...V.map(ue=>({kind:"persona",persona:ue})),...l.map(ue=>({kind:"contact",contact:ue}))],[Me,u,A,V,l]),mt=g.useMemo(()=>at!==null?$R(nt,at):[],[nt,at]),Xt=g.useRef(f);g.useEffect(()=>{f!==Xt.current&&(F(!1),oe(!1),Xt.current=f)},[f]);const pn=g.useCallback(()=>{F(!0)},[]),U=g.useCallback(()=>{oe(!0)},[]),Q=g.useRef(f),ve=g.useRef(S);g.useEffect(()=>{Q.current=f},[f]),g.useEffect(()=>{ve.current=S},[S]);const Se=g.useRef(n);g.useEffect(()=>{const ue=Se.current;if(ue===n)return;BS(ue,{draft:Q.current,attachments:ve.current});const Ne=OS(n);p((Ne==null?void 0:Ne.draft)??""),k((Ne==null?void 0:Ne.attachments)??[]),z(0),M(0),F(!1),oe(!1),Fe(null),qe.current=null,ge(!1),queueMicrotask(()=>{Ne!=null&&Ne.draft?FR(y.current):Wo(y.current)}),Se.current=n},[n,k]),g.useEffect(()=>()=>{BS(Se.current,{draft:Q.current,attachments:ve.current})},[]),g.useEffect(()=>{z(0)},[Rt]),g.useEffect(()=>{M(0)},[at]),g.useEffect(()=>{at===null&&Me&&(Fe(null),qe.current=null,ge(!1))},[at,Me]),g.useEffect(()=>{if(!ln||I)return;if(!e){R(!0);return}let ue=!1;return(async()=>{try{const Ne=await e.skillsList(t,a);ue||(O(Ne.skills??[]),R(!0))}catch{ue||R(!0)}})(),()=>{ue=!0}},[ln,I,e,t,a]),g.useEffect(()=>{if(!Ue||E)return;if(!e){H(!0);return}let ue=!1;return(async()=>{try{const Ne=await e.agentsList(t,a);ue||(B(Ne.agents??[]),H(!0))}catch{ue||H(!0)}})(),()=>{ue=!0}},[Ue,E,e,t,a]),g.useEffect(()=>{if(!Ue||Oe)return;if(!e){ie(!0);return}let ue=!1;return(async()=>{try{const Ne=await e.personaList();ue||(pe((Ne.personas??[]).map(Qe=>({personaId:Qe.personaId,label:Qe.label,iconKey:Qe.iconKey}))),ie(!0))}catch{ue||ie(!0)}})(),()=>{ue=!0}},[Ue,Oe,e]);const J=g.useCallback(ue=>{switch(ue.kind){case"persona":p(`@persona/${ue.persona.personaId} `);break;case"cc-agent":p(`@"${ue.agent.name} (agent)" `);break;case"contact":{const Ne=ue.contact.deviceId;Fe({deviceId:Ne,displayName:ue.contact.displayName}),qe.current=Ne,ge(!0),Promise.resolve(c==null?void 0:c(Ne)).finally(()=>{qe.current===Ne&&ge(!1)}),p("@"),oe(!1),setTimeout(()=>{var Qe;return(Qe=y.current)==null?void 0:Qe.focus()},0);return}case"remote-persona":p(`@persona/${ue.persona.personaId}@${ue.deviceId} `),Fe(null);break}oe(!1),setTimeout(()=>{var Ne;return(Ne=y.current)==null?void 0:Ne.focus()},0)},[c]),Xe=g.useCallback(()=>{Fe(null),qe.current=null,ge(!1),p("@"),setTimeout(()=>{var ue;return(ue=y.current)==null?void 0:ue.focus()},0)},[]),Yt=g.useCallback(ue=>{if(ue.source==="builtin"&&ue.name==="new"&&s){p(""),L(),Wo(y.current),s(t);return}if(ue.source==="builtin"&&ue.name==="clear"&&o){p(""),L(),Wo(y.current),o();return}p(`/${ue.name} `),setTimeout(()=>{var Ne;return(Ne=y.current)==null?void 0:Ne.focus()},0)},[s,t,L,o]),Zt=g.useCallback(async()=>{const ue=f.trim(),Ne=S.filter(Qe=>Qe.status==="done");if(!(!ue&&Ne.length===0)&&!(m||i)){if(ue==="/new"&&s){v(!0);try{await s(t),p(""),L(),Wo(y.current)}finally{v(!1)}return}if(ue==="/clear"&&o){v(!0);try{await o(),p(""),L(),Wo(y.current)}finally{v(!1)}return}v(!0);try{const Qe=a==="codex"?JY(ue,P):ue,Dn=sY(Qe,S);await r(Dn),p(""),L(),Wo(y.current)}finally{v(!1)}}},[f,S,m,i,r,s,t,L,o,a,P]);return{draft:f,setDraft:p,sending:m,textareaRef:y,isComposingRef:_,onCompositionStart:x,onCompositionEnd:b,attachments:S,addFiles:T,removeAttachment:N,skillSelectorVisible:ln,filteredSkills:Bt,slashQuery:Rt??"",activeSkillIdx:j,setActiveSkillIdx:z,selectSkill:Yt,dismissSkillSelector:pn,agentSelectorVisible:Ue,filteredAgents:mt,mentionQuery:at,activeAgentIdx:q,setActiveAgentIdx:M,selectAgent:J,dismissAgentSelector:U,drilldown:Me,drilldownLoading:We,exitDrilldown:Xe,doSend:Zt}}const tZ=120;function FR(e){e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,tZ)}px`)}function Wo(e){e&&(e.style.height="auto")}const nZ={spawnableContacts:[],ensureRemotePersonas:()=>Promise.resolve(),remotePersonasByDeviceId:new Map},rZ=g.createContext(nZ);function iZ(){return g.useContext(rZ)}function sZ({url:e,fileName:t,onClose:n}){const[r,i]=g.useState(!1);g.useEffect(()=>{const o=a=>{a.key==="Escape"&&n()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n]);const s=async()=>{try{const a=await(await fetch(e)).blob();await navigator.clipboard.write([new ClipboardItem({[a.type]:a})]),i(!0),setTimeout(()=>i(!1),2e3)}catch{zS(e,t)}};return h.jsx("div",{"data-testid":"image-lightbox",className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60",onClick:n,role:"dialog","aria-modal":"true",children:h.jsxs("div",{className:"relative",onClick:o=>o.stopPropagation(),children:[h.jsx("img",{src:e,alt:t,className:"max-h-[90vh] max-w-[92vw] rounded-lg object-contain shadow-2xl"}),h.jsxs("div",{className:"absolute right-2 top-2 flex items-center gap-1.5",children:[h.jsxs("button",{type:"button",onClick:s,"data-testid":"image-lightbox-copy",className:"flex cursor-pointer items-center gap-1 rounded-full border border-bg-300 bg-bg-50/95 px-2 py-0.5 text-[11px] font-medium text-text-200 shadow transition-colors hover:bg-bg-100",children:[h.jsx(su,{className:"h-3 w-3"}),r?"Copied":"Copy"]}),h.jsxs("button",{type:"button",onClick:()=>zS(e,t),"data-testid":"image-lightbox-save",className:"flex cursor-pointer items-center gap-1 rounded-full border border-bg-300 bg-bg-50/95 px-2 py-0.5 text-[11px] font-medium text-text-200 shadow transition-colors hover:bg-bg-100",children:[h.jsx(QB,{className:"h-3.5 w-3.5"}),"Save"]}),h.jsx("button",{type:"button",onClick:n,"data-testid":"image-lightbox-close","aria-label":"close",className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded-full border border-bg-300 bg-bg-50/95 text-text-300 transition-colors hover:bg-bg-100 hover:text-text-100",children:h.jsx(Rn,{className:"h-3 w-3"})})]})]})})}function zS(e,t){const n=document.createElement("a");n.href=e,n.download=t||"image",n.click()}function oZ({meta:e,api:t,cwd:n,tool:r,onSend:i,sessionKey:s,disabled:o=!1,placeholder:a,className:l,awaitingUser:c=!1,onAbort:u,onNewSession:d,onClearSession:f}){const p=(e==null?void 0:e.streamInProgress)??!1,m=g.useRef(null),v=iZ(),y=eZ({...t?{api:t}:{},cwd:n,...r?{tool:r}:{},sessionKey:s,onSend:i,disabled:o,...d?{onNewSession:d}:{},...f?{onClearSession:f}:{},spawnableContacts:v.spawnableContacts,ensureRemotePersonas:v.ensureRemotePersonas,remotePersonasByDeviceId:v.remotePersonasByDeviceId}),{draft:_,setDraft:x,sending:b,textareaRef:w,attachments:S,addFiles:k,removeAttachment:T,skillSelectorVisible:N,filteredSkills:L,slashQuery:P,activeSkillIdx:O,setActiveSkillIdx:I,selectSkill:R,dismissSkillSelector:j,agentSelectorVisible:z,filteredAgents:$,mentionQuery:F,activeAgentIdx:A,setActiveAgentIdx:B,selectAgent:E,dismissAgentSelector:H,drilldown:q,drilldownLoading:M,exitDrilldown:re,doSend:oe}=y,V=!!t,pe=b||o||p,ie=(_.trim().length>0||S.some(J=>J.status==="done"))&&!o&&!b&&!c,Me=a??(c?"Answer the question above first...":pe?"Queue a message...":`Message ${$d(r)}...`),Fe=g.useRef(!1),We=g.useCallback(()=>{Fe.current=!0},[]),ge=g.useCallback(()=>{Fe.current=!1},[]),qe=g.useCallback(J=>{if(N&&L.length>0){if(J.key==="ArrowDown")return J.preventDefault(),I(O>=L.length-1?0:O+1),!0;if(J.key==="ArrowUp")return J.preventDefault(),I(O<=0?L.length-1:O-1),!0;if(J.key==="Tab"||J.key==="Enter"&&!J.shiftKey){J.preventDefault();const Xe=L[O];return Xe&&R(Xe),!0}if(J.key==="Escape")return J.preventDefault(),j(),!0}return!1},[N,L,O,I,R,j]),Gt=g.useCallback(J=>{if(z&&$.length>0){if(J.key==="ArrowDown")return J.preventDefault(),B(A>=$.length-1?0:A+1),!0;if(J.key==="ArrowUp")return J.preventDefault(),B(A<=0?$.length-1:A-1),!0;if(J.key==="Tab"||J.key==="Enter"&&!J.shiftKey){J.preventDefault();const Xe=$[A];return Xe&&E(Xe),!0}if(J.key==="Escape")return J.preventDefault(),q?re():H(),!0}return!1},[z,$,A,B,E,H,q,re]),wt=g.useCallback(J=>{const Xe=J.nativeEvent;J.key==="Enter"&&iI({compositionActive:Fe.current,nativeIsComposing:Xe.isComposing,keyCode:Xe.keyCode})||qe(J)||Gt(J)||sI({key:J.key,shiftKey:J.shiftKey,compositionActive:Fe.current,nativeIsComposing:Xe.isComposing,keyCode:Xe.keyCode})&&(J.preventDefault(),ie&&oe())},[qe,Gt,ie,oe]),Rt=g.useCallback(J=>{x(J.target.value),FR(J.target)},[x]),ln=g.useCallback(J=>{J.target.files&&k(J.target.files),J.target.value=""},[k]),Bt=g.useCallback(J=>{if(!V)return;const Xe=Array.from(J.clipboardData.items).map(Yt=>Yt.getAsFile()).filter(Yt=>!!(Yt&&Yt.type.startsWith("image/")));Xe.length!==0&&(J.preventDefault(),k(Xe))},[k,V]),[at,Ue]=g.useState(null),nt=g.useCallback(J=>{J.previewUrl&&Ue({url:J.previewUrl,name:J.fileName})},[]),[mt,Xt]=g.useState(!1),pn=g.useCallback(J=>{V&&(J.preventDefault(),Xt(!0))},[V]),U=g.useCallback(()=>Xt(!1),[]),Q=g.useCallback(J=>{V&&(J.preventDefault(),Xt(!1),J.dataTransfer.files.length>0&&k(J.dataTransfer.files))},[k,V]),ve=p&&!c&&typeof u=="function",Se=o||c;return h.jsxs("div",{"data-testid":"chat-input",className:ne("shrink-0 border-t border-bg-300/20 px-4 py-3",l),onDragOver:pn,onDragLeave:U,onDrop:Q,children:[h.jsxs("div",{className:"max-w-3xl mx-auto relative",children:[V?h.jsx("input",{ref:m,type:"file",multiple:!0,accept:UY,hidden:!0,onChange:ln,"data-testid":"chat-input-file"}):null,h.jsxs("div",{"data-testid":"chat-input-bare",className:ne("flex flex-col gap-2"),children:[c||b||p?h.jsxs("div",{"data-testid":"chat-input-status-bar",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsxs("div",{className:"flex gap-1",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{children:c?"Waiting for your answer":`${r==="codex"?"Codex":"Claude"} is working`})]}):null,N?h.jsx(DY,{query:P,skills:L,activeIndex:O,onActiveIndexChange:I,onSelect:R}):null,z?q?!v.remotePersonasByDeviceId.has(q.deviceId)&&M?h.jsx("div",{"data-testid":"cc-agent-remote-loading",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`正在加载 @${q.displayName} 的 persona…`}):$.length>0?h.jsx(DS,{query:F??"",entries:$,activeIndex:A,onActiveIndexChange:B,onSelect:E}):h.jsx("div",{"data-testid":"cc-agent-remote-empty",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`@${q.displayName} 暂无可派活的 persona(可能离线或未公开)`}):h.jsx(DS,{query:F??"",entries:$,activeIndex:A,onActiveIndexChange:B,onSelect:E}):null,S.length>0?h.jsx(FY,{attachments:S,onRemove:T,onOpenPreview:nt}):null,h.jsxs("div",{"data-testid":"bare-chat-input-frame",className:ne("flex items-end gap-2 rounded-xl border border-bg-300 bg-bg-50 px-3 py-2 transition-colors duration-200",Se?"opacity-60":null,mt?"border-accent/60 bg-accent/5":null),children:[V?h.jsx("button",{type:"button",onClick:()=>{var J;return(J=m.current)==null?void 0:J.click()},disabled:pe,"data-testid":"chat-input-attach","aria-label":"attach files",className:ne("flex h-8 w-8 shrink-0 self-end items-center justify-center rounded-md transition-colors",pe?"cursor-default text-text-400/50":"cursor-pointer text-text-400 hover:bg-text-100/5 hover:text-text-200"),children:h.jsx(E6,{className:"h-4 w-4"})}):null,h.jsx("textarea",{ref:w,"data-testid":"chat-input-textarea",value:_,onChange:Rt,onKeyDown:wt,onCompositionStart:We,onCompositionEnd:ge,onPaste:Bt,placeholder:Me,disabled:Se,readOnly:Se,rows:1,className:"flex-1 resize-none bg-transparent border-0 outline-none text-[14px] text-text-100 placeholder:text-text-400 leading-relaxed py-1 min-h-[22px] max-h-[120px] overflow-y-auto disabled:cursor-not-allowed"}),h.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 pb-0.5",children:[ve?h.jsx("button",{type:"button",onClick:u,"data-testid":"chat-input-abort","aria-label":"interrupt",title:"中断当前轮次(不杀进程)",className:"h-8 w-8 rounded-full flex items-center justify-center border border-text-400/40 text-text-400 hover:bg-text-100/5 hover:text-text-100 transition-colors cursor-pointer",children:h.jsx($N,{className:"w-3.5 h-3.5",strokeWidth:2.5})}):null,h.jsx("button",{type:"button",onClick:()=>{ie&&oe()},disabled:!ie,"data-testid":"chat-input-send","aria-label":"send",className:ne("h-8 w-8 rounded-full flex items-center justify-center transition-colors",ie?"bg-accent text-white hover:bg-accent-hover cursor-pointer shadow-sm":"bg-[var(--text-400-dim)] text-[var(--text-400-dim-fg)] cursor-default"),children:h.jsx(SB,{className:"w-4 h-4",strokeWidth:2.5})})]})]})]})]}),at?h.jsx(sZ,{url:at.url,fileName:at.name,onClose:()=>Ue(null)}):null]})}function aZ(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function lZ({meta:e,tool:t,connState:n,onOpenConfig:r,models:i,liveGitBranch:s,liveWorktreeRoot:o,onForceStop:a,cronActiveCount:l,onCronClick:c,onOpenFiles:u,onTogglePin:d,isHolded:f=!1,onToggleHold:p,personaName:m,onOpenPersona:v,className:y}){const _=e.procAlive??!1,x=e.streamInProgress??!1,b=e.permissionMode,w=b&&b!=="default"?b:null,S=w==="bypassPermissions"?"YOLO":w==="plan"?"Plan":null,k=e.model??"",T=cZ(i,k),N=e.contextPct??null,L=N==null?"":N>=80?"text-red-400":N>=50?"text-amber-400":"text-text-500",P=s!==void 0?s:e.gitBranch??null,O=o??e.cwd??"",R=!!e.sessionLabel&&e.sessionLabel!==e.sessionId?e.sessionLabel:aZ(O),j=O,z=e.pinnedAt!=null;return h.jsxs("div",{"data-testid":"chat-header",className:ne("relative flex flex-col justify-center shrink-0 px-4 pr-14 py-2 gap-1",y),children:[h.jsxs("div",{className:"flex items-center min-w-0 gap-2 text-[13px]",children:[d?h.jsx("button",{type:"button",onClick:()=>d(!z),"data-testid":"chat-header-pin-toggle","data-pinned":z?"true":"false","aria-pressed":z,title:z?"Unpin session":"Pin session",className:ne("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md cursor-pointer transition-colors",z?"text-amber-400 hover:bg-amber-500/10":"text-text-500 hover:text-text-200 hover:bg-text-100/5"),children:h.jsx(HN,{className:ne("w-3.5 h-3.5",z&&"fill-current")})}):null,p?h.jsx("button",{type:"button",onClick:()=>p(!f),"data-testid":"chat-header-hold-toggle","data-holded":f?"true":"false","aria-pressed":f,title:f?"Release hold":"Hold session",className:ne("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md cursor-pointer transition-colors",f?"text-amber-400 hover:bg-amber-500/10":"text-text-500 hover:text-text-200 hover:bg-text-100/5"),children:h.jsx(MB,{className:ne("w-3.5 h-3.5",f&&"fill-current")})}):null,h.jsx("span",{className:"font-semibold text-text-100 truncate","data-testid":"chat-header-worktree",title:j,children:R}),P?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500 shrink-0",children:":"}),h.jsx("span",{className:"font-mono text-text-300 truncate","data-testid":"chat-header-git",title:P,children:P})]}):null]}),h.jsxs("div",{className:"flex items-center min-w-0 gap-2 text-[11px]",children:[S?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("desktop"),"data-testid":"chat-header-mode-chip",className:ne("hidden md:inline-flex shrink-0 px-2 py-0.5 rounded-md font-semibold cursor-pointer transition-colors",w==="bypassPermissions"?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"bg-blue-500/15 text-blue-400 hover:bg-blue-500/25"),children:S}),h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("mobile"),"aria-hidden":"true",tabIndex:-1,className:ne("inline-flex md:hidden shrink-0 px-2 py-0.5 rounded-md font-semibold cursor-pointer transition-colors",w==="bypassPermissions"?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"bg-blue-500/15 text-blue-400 hover:bg-blue-500/25"),children:S})]}):null,k||i?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("desktop"),"data-testid":"chat-header-model-chip",className:"hidden md:inline-flex shrink-0 font-mono text-text-400 cursor-pointer hover:text-text-200 transition-colors",children:T}),h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("mobile"),"aria-hidden":"true",tabIndex:-1,className:"inline-flex md:hidden shrink-0 font-mono text-text-400 cursor-pointer hover:text-text-200 transition-colors",children:T})]}):null,N!=null?h.jsxs("span",{className:ne("shrink-0 font-mono",L),"data-testid":"chat-header-ctx",children:["ctx:",N,"%"]}):null,h.jsxs("span",{"data-testid":"chat-header-proc-status",className:"inline-flex items-center gap-1 text-text-500 shrink-0",title:x?`${$d(t)} 正在跑当前 turn`:_?`${$d(t)} 进程仍活,等下一轮输入`:`${$d(t)} 进程未运行(发送消息会自动启动)`,children:[h.jsx("span",{className:ne("w-1.5 h-1.5 rounded-full",x?"bg-green-500":"bg-text-400/50")}),h.jsx("span",{children:x?"running":"idle"})]}),_&&a?h.jsxs("button",{type:"button",onClick:a,"data-testid":"chat-header-force-stop",title:t==="codex"?"强制停止 Codex 进程":"强制停止 Claude Code 进程(会丢失 initialize / 预热缓存)",className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-400 hover:bg-red-500/10 hover:text-red-400 transition-colors cursor-pointer",children:[h.jsx(k6,{className:"w-3 h-3"}),h.jsx("span",{children:"Stop"})]}):null,m&&v||u||l&&l>0&&c?h.jsx("span",{className:"text-text-500 shrink-0","aria-hidden":"true",children:"·"}):null,m&&v?h.jsxs("button",{type:"button",onClick:v,"data-testid":"chat-header-persona",title:m,className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-300 hover:bg-bg-200 hover:text-text-100 transition-colors cursor-pointer",children:[h.jsx(Y_,{className:"w-3 h-3"}),h.jsx("span",{className:"truncate max-w-[80px] md:max-w-[120px]",children:m})]}):null,u?h.jsxs("button",{type:"button",onClick:u,"data-testid":"chat-header-files",title:"Edited Files",className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-300 hover:bg-bg-200 hover:text-text-100 transition-colors cursor-pointer",children:[h.jsx(s6,{className:"w-3 h-3"}),h.jsx("span",{className:"hidden md:inline",children:"Edited Files"})]}):null,l&&l>0&&c?h.jsxs("button",{type:"button","data-testid":"chat-header-cron-button",onClick:c,"aria-label":"Cron tasks",title:`${l} active cron task${l===1?"":"s"}`,className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-400 hover:bg-accent-dim hover:text-accent transition-colors cursor-pointer",children:[h.jsx(VB,{className:"w-3 h-3"}),h.jsx("span",{"data-testid":"chat-header-cron-badge",className:"font-mono",children:l})]}):null]}),r?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings",onClick:()=>r("desktop"),title:"Session settings",className:"hidden md:flex absolute right-4 top-3 z-10 h-7 w-7 items-center justify-center rounded-md bg-transparent text-text-300 transition-colors duration-150 hover:bg-bg-200 hover:text-text-100 cursor-pointer outline-none",children:h.jsx(Sv,{className:"w-4 h-4"})}),h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings-mobile",onClick:()=>r("mobile"),title:"Session settings",className:"flex md:hidden absolute right-4 top-3 z-10 h-7 w-7 items-center justify-center rounded-md bg-transparent text-text-300 transition-colors duration-150 hover:bg-bg-200 hover:text-text-100 cursor-pointer outline-none",children:h.jsx(Sv,{className:"w-4 h-4"})})]}):null]})}function cZ(e,t){if(!t)return"default";const n=t.toLowerCase(),r=[["opus","Opus"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[a,l]of r){if(!n.includes(a))continue;const c=n.match(new RegExp(`${a}-(\\d+)-(\\d+)`));return c?`${l} ${c[1]}.${c[2]}`:l}const i=e??[],s=i.find(a=>a.id===t);if(s)return s.label;const o=i.find(a=>a.id&&t.toLowerCase().includes(a.id.toLowerCase()));return o?o.label:t}function uZ(e){return e==="TodoWrite"}function dZ(e){if(!e||typeof e!="object")return null;const t=e;if(!Array.isArray(t.todos))return null;const n=[];for(const r of t.todos){if(!r||typeof r!="object")continue;const i=r,s=typeof i.content=="string"?i.content:"";if(!s)continue;const o=i.status==="in_progress"||i.status==="completed"?i.status:"pending",a=typeof i.activeForm=="string"?i.activeForm:void 0;n.push({content:s,status:o,activeForm:a})}return n}function hZ(e,t,n){var s;const r=[],i=new Map;for(let o=0;o<e.length;o++){const a=e[o],l=typeof a.seq=="number"?a.seq:o;switch(a.kind){case"session_init":r.push({kind:"session-init",seq:l,toolSessionId:a.toolSessionId});break;case"text":$S(r,l,"assistant-text",a.text,a.partialId,a.uuid);break;case"thinking":$S(r,l,"assistant-thinking",a.text,a.partialId);break;case"user_text":{a.meta==="task-notification"?r.push({kind:"agent-notification",seq:l,text:a.text,taskId:a.taskId,parentToolUseId:a.parentToolUseId}):a.meta?r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text}):r.push({kind:"user-text",seq:l,text:a.text,uuid:a.uuid,senderDisplayName:(s=a.sender)==null?void 0:s.displayName});break}case"tool_call":HR(r,l,a.toolUseId,a.tool,a.input,a.toolKind);break;case"tool_result":{const c=i.get(a.toolUseId);if(c!==void 0){if(a.askQuestionAnswers){const d=r[c];d.submittedAnswers=a.askQuestionAnswers}i.delete(a.toolUseId);break}const u={kind:"tool-result",seq:l,toolUseId:a.toolUseId,output:a.output,error:a.error};a.toolResultExtra&&(u.toolResultExtra=a.toolResultExtra),r.push(u);break}case"attachment_memories":r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"permission_request":{if(!t||a.requestId!==t)break;r.push({kind:"permission-inline",seq:l,requestId:a.requestId,tool:a.tool,input:a.input});break}case"ask_user_question":i.set(a.toolUseId,r.length),r.push({kind:"question-card",seq:l,toolUseId:a.toolUseId,questions:a.questions});break;case"turn_end":r.push({kind:"turn-end",seq:l});break;case"subagent_progress":{const c={kind:"agent-progress",seq:l,toolUseId:a.toolUseId,agentId:a.agentId,status:a.status};a.description&&(c.description=a.description),a.lastToolName&&(c.lastToolName=a.lastToolName),a.prompt&&(c.prompt=a.prompt),a.stats&&(c.stats=a.stats),r.push(c);break}case"error":r.push({kind:"error",seq:l,message:a.message});break}}return r}function HR(e,t,n,r,i,s){if(uZ(r)){const o=dZ(i);if(o){e.push({kind:"todo-checklist",seq:t,toolUseId:n,todos:o});return}}if(r==="Agent"){const o=i??{},a=typeof o.description=="string"&&o.description?o.description:typeof o.subagent_type=="string"&&o.subagent_type?o.subagent_type:"Subagent";e.push({kind:"agent-call",seq:t,toolUseId:n,description:a,input:i});return}if(C7(r)){e.push({kind:"task-event",seq:t,toolUseId:n,name:r,input:i});return}e.push({kind:"tool-call",seq:t,toolUseId:n,tool:r,toolKind:s,input:i})}function $S(e,t,n,r,i,s){let o=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind===n){o=c;break}const a=o>=0?e[o]:null;if(i){if(a&&a.partialId===i){const u=n==="assistant-text"?{kind:n,seq:a.seq,text:a.text+r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:a.text+r,partialId:i};e[o]=u;return}const c=n==="assistant-text"?{kind:n,seq:t,text:r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r,partialId:i};e.push(c);return}if(a&&a.partialId){const c=n==="assistant-text"?{kind:n,seq:a.seq,text:r,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:r};e[o]=c;return}const l=n==="assistant-text"?{kind:n,seq:t,text:r,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r};e.push(l)}const fZ="AskUserQuestion";function UR(e,t=0,n){const r=[],i=new Map;let s=t;for(const o of e){const a=s++,l=o.toolUseId??`hist-${a}`;switch(o.kind){case"user-text":o.meta==="task-notification"?r.push({kind:"agent-notification",seq:a,text:o.text??"",taskId:o.taskId,parentToolUseId:o.parentToolUseId}):o.meta?r.push({kind:"user-meta",seq:a,metaKind:o.meta,text:o.text??""}):r.push({kind:"user-text",seq:a,text:o.text??"",uuid:o.uuid});break;case"assistant-text":r.push({kind:"assistant-text",seq:a,text:o.text??"",uuid:o.uuid});break;case"tool_call":{if(o.tool===fZ){const c=o.input??{},u=Array.isArray(c.questions)?c.questions:[];i.set(l,r.length),r.push({kind:"question-card",seq:a,toolUseId:l,questions:u});break}HR(r,a,l,o.tool??"",o.input,n);break}case"tool_result":{const c=i.get(l);if(c!==void 0){if(o.askQuestionAnswers){const d=r[c];d.submittedAnswers=o.askQuestionAnswers}i.delete(l);break}const u={kind:"tool-result",seq:a,toolUseId:l,output:o.output};o.error!==void 0&&(u.error=o.error),o.toolResultExtra&&(u.toolResultExtra=o.toolResultExtra),r.push(u);break}case"attachment_memories":o.memories&&o.memories.length>0&&r.push({kind:"memory-callout",seq:a,memories:o.memories});break}}return r}function pZ({api:e,cwd:t,toolSessionId:n}){const r=LR(),i=(r==null?void 0:r.state.agentId)??null,s=r==null?void 0:r.state.agentType,[o,a]=g.useState([]),[l,c]=g.useState(!1),[u,d]=g.useState(null);g.useEffect(()=>{if(!i)return;let p=!1;return c(!0),d(null),a([]),e.historySubagentRead({cwd:t,toolSessionId:n,subagentId:i}).then(m=>{p||a(m.messages??[])}).catch(m=>{p||d(m instanceof Error?m.message:String(m))}).finally(()=>{p||c(!1)}),()=>{p=!0}},[i,t,n,e]);const f=g.useMemo(()=>o.length>0?UR(o,0,"claude"):[],[o]);return!r||!i?null:h.jsxs("div",{"data-testid":"subagent-drawer","data-agent-id":i,className:ne("fixed inset-y-0 right-0 z-50 w-[min(560px,92vw)]","flex flex-col border-l border-bg-200/60 bg-bg-50 shadow-xl"),style:{paddingTop:"env(safe-area-inset-top)"},children:[h.jsxs("div",{className:"flex flex-col gap-0.5 px-3 py-2 border-b border-bg-200/60",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s?h.jsx("span",{className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-[11px] text-violet-400 font-medium",children:s}):null,h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate",title:i,children:i})]}),h.jsx("button",{type:"button","aria-label":"关闭",onClick:()=>r.close(),className:"p-1 rounded hover:bg-bg-200/50 text-text-400 hover:text-text-200",children:h.jsx(Rn,{className:"w-4 h-4"})})]}),!l&&!u&&o.length>0?h.jsxs("div",{className:"text-[11px] text-text-400",children:[o.length," 条消息 · 首条为主会话派发的任务指令"]}):null]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden px-3 py-2",children:l?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(rr,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"加载中…"})]}):u?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-error",children:[h.jsx(Rs,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:u})]}):f.length===0?h.jsx("div",{className:"text-[12px] text-text-400 italic",children:"无消息"}):h.jsx(BR,{lines:f})})]})}function FS(e,t){let n=0;for(const r of e.lines)r.startsWith(t)&&n++;return n}function mZ(e,t){const n=e.findIndex(c=>c.kind==="user-text"&&c.uuid===t);if(n<0)return{userMessageId:t,files:[],totalInsertions:0,totalDeletions:0,anchorFound:!1};let r=e.length;for(let c=n+1;c<e.length;c++)if(e[c].kind==="user-text"){r=c;break}const i=[],s=new Map;for(let c=n+1;c<r;c++){const u=e[c];if(u.kind!=="tool-result")continue;const d=u.toolResultExtra;if(!(d!=null&&d.filePath)||!d.structuredPatch||d.structuredPatch.length===0)continue;const f=d.filePath;let p=s.get(f);p||(p={filePath:f,hunks:[],insertions:0,deletions:0},s.set(f,p),i.push(f));for(const m of d.structuredPatch)p.hunks.push(m),p.insertions+=FS(m,"+"),p.deletions+=FS(m,"-")}const o=i.map(c=>s.get(c)),a=o.reduce((c,u)=>c+u.insertions,0),l=o.reduce((c,u)=>c+u.deletions,0);return{userMessageId:t,files:o,totalInsertions:a,totalDeletions:l,anchorFound:!0}}function gZ({open:e,onOpenChange:t,api:n,sessionId:r,userMessageId:i,lines:s,procAlive:o,onApplied:a,onNoChanges:l}){const c=g.useMemo(()=>mZ(s,i),[s,i]),[u,d]=g.useState(null),[f,p]=g.useState(!1),[m,v]=g.useState(!1),[y,_]=g.useState(null);g.useEffect(()=>{if(!e)return;let k=!1;return p(!0),d(null),(async()=>{try{const T=await n.sessionRewindDiff({sessionId:r,userMessageId:i});k||(d(T),!T.canRewind&&!T.error&&T.files.length===0&&(l==null||l(i)))}catch{k||d(null)}finally{k||p(!1)}})(),()=>{k=!0}},[e,n,r,i]);const x=g.useMemo(()=>{if(u){const k=!u.canRewind&&!u.error&&u.files.length===0;if(u.canRewind||k)return{source:"rpc",anchorFound:!0,files:u.files.map(T=>({filePath:T.filePath,hunks:T.hunks,insertions:T.insertions,deletions:T.deletions})),totalInsertions:u.totalInsertions,totalDeletions:u.totalDeletions}}return{source:"local",anchorFound:c.anchorFound,files:c.files,totalInsertions:c.totalInsertions,totalDeletions:c.totalDeletions,rpcError:u==null?void 0:u.error}},[u,c]),b=g.useCallback(async()=>{v(!0),_(null);try{const k=await n.sessionRewind({sessionId:r,userMessageId:i,dryRun:!1});if(!k.canRewind){_(k.error??"回退失败");return}a==null||a(),t(!1)}catch(k){_(k.message||"回退失败")}finally{v(!1)}},[n,r,i,a,t]);if(!e)return null;const w=x.files.length>0,S=!f&&!m&&x.anchorFound&&w&&!y;return h.jsxs("div",{"data-testid":"rewind-preview-drawer",className:"fixed right-0 top-0 bottom-0 z-40 flex flex-col border-l border-bg-300/40 bg-bg-0 shadow-xl",style:{width:480,minWidth:480},children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bg-300/30 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(WN,{className:"w-4 h-4 text-text-300"}),h.jsx("span",{className:"text-[14px] font-semibold text-text-100",children:"Rewind 预览"})]}),h.jsx("button",{type:"button",onClick:()=>t(!1),"data-testid":"rewind-drawer-close",className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:bg-text-100/5 hover:text-text-200 cursor-pointer","aria-label":"close",children:h.jsx(Rn,{className:"w-4 h-4"})})]}),y?h.jsxs("div",{"data-testid":"rewind-error-banner",className:"mx-4 mt-3 flex items-start gap-2 rounded-md border border-red-400/40 bg-red-500/10 px-3 py-2 text-[12px] text-red-400",children:[h.jsx(Ac,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{children:y})]}):null,h.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3",children:f?h.jsxs("div",{"data-testid":"rewind-loading",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(rr,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"正在读取快照…"})]}):x.anchorFound?w?h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":"rewind-summary",className:"rounded-md border border-bg-300 bg-bg-100/40 px-3 py-2 text-[12px] text-text-200",children:[h.jsxs("div",{children:["将回退 ",h.jsx("span",{className:"font-semibold text-text-100",children:x.files.length})," ","个文件,",h.jsxs("span",{className:"text-green-500 font-mono",children:["+",x.totalInsertions]})," / ",h.jsxs("span",{className:"text-red-400 font-mono",children:["-",x.totalDeletions]})]}),x.source==="local"?h.jsx("div",{"data-testid":"rewind-source-hint",className:"mt-1 text-text-400 text-[11px]",children:"基于对话里 tool_result 估算(未读到 CC 快照,数字可能与实际磁盘略有差异)"}):null]}),x.files.map(k=>h.jsx(_Z,{file:k},k.filePath))]}):h.jsxs("div",{"data-testid":"rewind-no-changes",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300 space-y-1",children:[h.jsx("div",{children:"磁盘上的文件已经和这个时刻的快照完全一致——没有需要回退的改动。"}),h.jsx("div",{className:"text-text-400 text-[11px]",children:"可能这条消息之后 Claude 没落盘编辑,或之前已经 rewind 过了。"})]}):h.jsx("div",{"data-testid":"rewind-no-anchor",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:"未能在当前消息流中找到对应的用户消息(可能已被历史裁剪)。"})}),h.jsxs("div",{className:"flex flex-col gap-2 px-4 py-3 border-t border-bg-300/30 shrink-0",children:[w&&x.anchorFound&&!o?h.jsxs("div",{"data-testid":"rewind-needs-cc",className:"flex items-start gap-2 rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:[h.jsx(Ac,{className:"w-4 h-4 shrink-0 mt-0.5 text-warning"}),h.jsx("span",{children:'Claude Code 进程当前未运行。点击"确认回退"时会自动启动它再执行 — 可能需要等一两秒。'})]}):null,h.jsxs("div",{className:"flex items-center justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:()=>t(!1),className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button",disabled:!S,onClick:()=>void b(),"data-testid":"rewind-apply",className:ne("h-8 px-3 rounded-md text-[12px] font-medium transition-colors",S?"bg-accent text-white hover:bg-accent-hover cursor-pointer":"bg-bg-200 text-text-400 cursor-not-allowed"),children:m?"回退中…":"确认回退"})]})]})]})}function vZ(e){return e.replace(/^\/Users\/[^/]+/,"~")}function _Z({file:e}){const[t,n]=g.useState(!0);return h.jsxs("div",{"data-testid":"rewind-file-block","data-file":e.filePath,className:"rounded-md border border-bg-300 overflow-hidden bg-bg-0",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"w-full flex items-center gap-1.5 px-3 py-2 text-[12px] hover:bg-text-100/5 cursor-pointer",children:[t?h.jsx(li,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(ci,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-200 truncate flex-1 text-left",title:e.filePath,children:vZ(e.filePath)}),h.jsxs("span",{className:"font-mono shrink-0 text-text-400",children:[h.jsxs("span",{className:"text-green-500",children:["+",e.insertions]})," ",h.jsxs("span",{className:"text-red-400",children:["-",e.deletions]})]})]}),t?h.jsx("div",{className:"border-t border-bg-300",children:e.hunks.map(r=>h.jsx(xZ,{hunk:r},`${r.oldStart}-${r.oldLines}-${r.newStart}-${r.newLines}`))}):null]})}function xZ({hunk:e}){const t=`@@ -${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines} @@`;return h.jsxs("div",{className:"text-[11px] font-mono leading-relaxed",children:[h.jsx("div",{className:"px-3 py-1 text-text-400 bg-bg-100/40 border-b border-bg-300",children:t}),e.lines.map((n,r)=>{const i=n.charAt(0),s=i==="+"?"bg-green-500/10 text-green-300":i==="-"?"bg-red-500/10 text-red-300":"text-text-300";return h.jsx("div",{className:ne("px-3 whitespace-pre",s),children:n.length>0?n:" "},r)})]})}var rp="Dialog",[WR]=Eo(rp),[yZ,Or]=WR(rp),VR=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!0}=e,a=g.useRef(null),l=g.useRef(null),[c,u]=Df({prop:r,defaultProp:i??!1,onChange:s,caller:rp});return h.jsx(yZ,{scope:t,triggerRef:a,contentRef:l,contentId:to(),titleId:to(),descriptionId:to(),open:c,onOpenChange:u,onOpenToggle:g.useCallback(()=>u(d=>!d),[u]),modal:o,children:n})};VR.displayName=rp;var qR="DialogTrigger",bZ=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(qR,n),s=qt(t,i.triggerRef);return h.jsx(Et.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":ey(i.open),...r,ref:s,onClick:Pe(e.onClick,i.onOpenToggle)})});bZ.displayName=qR;var Qx="DialogPortal",[wZ,KR]=WR(Qx,{forceMount:void 0}),GR=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,s=Or(Qx,t);return h.jsx(wZ,{scope:t,forceMount:n,children:g.Children.map(r,o=>h.jsx(zi,{present:n||s.open,children:h.jsx(lx,{asChild:!0,container:i,children:o})}))})};GR.displayName=Qx;var qh="DialogOverlay",XR=g.forwardRef((e,t)=>{const n=KR(qh,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Or(qh,e.__scopeDialog);return s.modal?h.jsx(zi,{present:r||s.open,children:h.jsx(kZ,{...i,ref:t})}):null});XR.displayName=qh;var SZ=jc("DialogOverlay.RemoveScroll"),kZ=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(qh,n);return h.jsx(cx,{as:SZ,allowPinchZoom:!0,shards:[i.contentRef],children:h.jsx(Et.div,{"data-state":ey(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),_o="DialogContent",YR=g.forwardRef((e,t)=>{const n=KR(_o,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Or(_o,e.__scopeDialog);return h.jsx(zi,{present:r||s.open,children:s.modal?h.jsx(CZ,{...i,ref:t}):h.jsx(EZ,{...i,ref:t})})});YR.displayName=_o;var CZ=g.forwardRef((e,t)=>{const n=Or(_o,e.__scopeDialog),r=g.useRef(null),i=qt(t,n.contentRef,r);return g.useEffect(()=>{const s=r.current;if(s)return XT(s)},[]),h.jsx(ZR,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Pe(e.onCloseAutoFocus,s=>{var o;s.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Pe(e.onPointerDownOutside,s=>{const o=s.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&s.preventDefault()}),onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault())})}),EZ=g.forwardRef((e,t)=>{const n=Or(_o,e.__scopeDialog),r=g.useRef(!1),i=g.useRef(!1);return h.jsx(ZR,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),ZR=g.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...o}=e,a=Or(_o,n),l=g.useRef(null),c=qt(t,l);return mT(),h.jsxs(h.Fragment,{children:[h.jsx(J_,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:h.jsx(Lf,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":ey(a.open),...o,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),h.jsxs(h.Fragment,{children:[h.jsx(NZ,{titleId:a.titleId}),h.jsx(PZ,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Jx="DialogTitle",QR=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(Jx,n);return h.jsx(Et.h2,{id:i.titleId,...r,ref:t})});QR.displayName=Jx;var JR="DialogDescription",eM=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(JR,n);return h.jsx(Et.p,{id:i.descriptionId,...r,ref:t})});eM.displayName=JR;var tM="DialogClose",nM=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(tM,n);return h.jsx(Et.button,{type:"button",...r,ref:t,onClick:Pe(e.onClick,()=>i.onOpenChange(!1))})});nM.displayName=tM;function ey(e){return e?"open":"closed"}var rM="DialogTitleWarning",[Lne,iM]=Qz(rM,{contentName:_o,titleName:Jx,docsSlug:"dialog"}),NZ=({titleId:e})=>{const t=iM(rM),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
516
+ `):null}if(typeof e=="object"){const t=e;if(typeof t.text=="string")return t.text}return null}function MS(e){if(!e||!Number.isFinite(e))return null;if(e<1e3)return`${e}ms`;const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}m${r.toString().padStart(2,"0")}s`}function xY(e){return!e||!Number.isFinite(e)?null:e<1e3?`${e} tok`:e<1e4?`${(e/1e3).toFixed(1)}k tok`:`${Math.round(e/1e3)}k tok`}const yY={readCount:"read",searchCount:"search",bashCount:"bash",editFileCount:"edit",linesAdded:"+lines",linesRemoved:"-lines",otherToolCount:"other"};function bY(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e)){if(!r||r<=0)continue;const i=yY[n]??n;t.push(`${i}:${r}`)}return t}function wY({description:e,input:t,output:n,error:r,pending:i,notifications:s,toolResultExtra:o,progress:a}){const[l,c]=g.useState(!1),u=LR(),d=g.useMemo(()=>{if(!t||typeof t!="object")return null;const N=t;return typeof N.prompt=="string"?N.prompt:null},[t]),f=(o==null?void 0:o.prompt)??d,p=g.useMemo(()=>_Y(n),[n]),m=o==null?void 0:o.stats,v=a==null?void 0:a.stats,y=MS((m==null?void 0:m.durationMs)??(v==null?void 0:v.durationMs)),_=xY((m==null?void 0:m.tokens)??(v==null?void 0:v.tokens)),x=bY(m==null?void 0:m.toolStats),b=i&&(a!=null&&a.lastToolName)?`now:${a.lastToolName}`:null,w=!!(o!=null&&o.agentType||y||_||x.length>0||b),S=(o==null?void 0:o.agentId)??(a==null?void 0:a.agentId),k=g.useMemo(()=>s.map(N=>({taskId:N.taskId,text:N.text,parsed:jR(N.text)})),[s]),T=r?h.jsx(Rs,{className:"w-3.5 h-3.5 text-error"}):i?h.jsx(rr,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx(jf,{className:"w-3.5 h-3.5 text-green-500"});return h.jsxs("div",{"data-testid":"msg-line-agent-call","data-pending":i?"true":"false","data-has-error":r?"true":"false","data-notification-count":s.length,"data-has-stats":w?"true":"false","data-agent-id":S??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("button",{type:"button","aria-expanded":l,onClick:()=>c(N=>!N),className:ne("flex w-full min-w-0 items-center gap-2 px-2.5 py-1.5 text-left text-[13px]","hover:bg-bg-200/40 rounded-md transition-colors"),children:[h.jsx("span",{className:"w-5 h-5 flex items-center justify-center text-[10px] rounded bg-violet-500/10 text-violet-500 shrink-0","aria-hidden":!0,children:h.jsx(oz,{className:"w-3 h-3"})}),h.jsx("span",{className:"shrink-0",children:T}),h.jsx("span",{className:"flex-1 min-w-0 truncate font-medium text-text-200",children:e}),w?null:s.length>0?h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums shrink-0",children:[s.length," 次通知"]}):null,S&&(u!=null&&u.open)?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"open-subagent-btn-header","data-agent-id":S,"aria-label":"打开子 agent 对话",onClick:N=>{N.stopPropagation(),u.open(S,o==null?void 0:o.agentType)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.stopPropagation(),N.preventDefault(),u.open(S,o==null?void 0:o.agentType))},className:"shrink-0 inline-flex items-center justify-center w-3.5 h-3.5 text-text-400 hover:text-text-200",children:h.jsx(Mc,{className:"w-3.5 h-3.5"})}):null,l?h.jsx(li,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(ci,{className:"w-3.5 h-3.5 text-text-400 shrink-0"})]}),i&&(a!=null&&a.description)?h.jsx("div",{"data-testid":"agent-call-progress-desc",className:"px-3 pt-0 pb-1 text-[12px] text-text-300 truncate",children:a.description}):null,w?h.jsxs("div",{"data-testid":"agent-call-stats",className:"flex items-center gap-1.5 flex-wrap px-3 pb-1.5 pt-0 text-[11px] text-text-400",children:[o!=null&&o.agentType?h.jsx("span",{"data-testid":"agent-call-stats-type",className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-violet-400 font-medium",children:o.agentType}):null,y?h.jsx("span",{className:"tabular-nums",children:y}):null,_?h.jsx("span",{className:"tabular-nums",children:_}):null,b?h.jsx("span",{"data-testid":"agent-call-stats-now",className:"font-mono tabular-nums text-blue-400",children:b}):null,x.map(N=>h.jsx("span",{className:"font-mono tabular-nums text-text-400/80",children:N},N)),s.length>0?h.jsxs("span",{className:"tabular-nums text-text-400/70",children:["· ",s.length," 次通知"]}):null]}):null,l?h.jsxs("div",{"data-testid":"agent-call-body",className:"min-w-0 border-t border-bg-200/60 px-3 py-2 space-y-3",children:[r?h.jsx("div",{className:"text-[12px] text-error whitespace-pre-wrap",children:r}):null,k.map((N,L)=>{const P=N.parsed,O=MS(P.durationMs);return h.jsxs("div",{"data-testid":"agent-call-notification","data-task-id":N.taskId??"",className:"min-w-0 rounded-md border border-bg-200/60 bg-bg-0/40 p-2 space-y-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-400 flex-wrap",children:[h.jsx("span",{className:"font-mono",children:(N.taskId??P.taskId??"未知").slice(0,12)}),h.jsx("span",{className:"uppercase tracking-wide",children:P.status??"unknown"}),O?h.jsxs("span",{className:"tabular-nums",children:["· ",O]}):null,P.totalTokens?h.jsxs("span",{className:"tabular-nums",children:["· ",P.totalTokens," tok"]}):null,P.toolUses?h.jsxs("span",{className:"tabular-nums",children:["· ",P.toolUses," tools"]}):null,P.worktreeBranch?h.jsxs("span",{className:"font-mono",children:["· ",P.worktreeBranch]}):null]}),P.summary?h.jsx("div",{className:"text-[12px] text-text-300",children:P.summary}):null,P.result?h.jsx("div",{"data-testid":"agent-call-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(Hc,{remarkPlugins:[Wc],components:Vc,children:P.result})}):null]},`${N.taskId??"n"}-${L}`)}),f?h.jsxs("div",{"data-testid":"agent-call-prompt-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"任务指令"}),h.jsx("pre",{"data-testid":"agent-call-prompt",className:"max-w-full whitespace-pre-wrap break-words text-[11px] text-text-300 bg-bg-50/60 rounded p-2 border border-bg-200/60 max-h-64 overflow-auto [overflow-wrap:anywhere]",children:f})]}):null,p?h.jsxs("div",{"data-testid":"agent-call-result-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"子 agent 报告"}),h.jsx("div",{"data-testid":"agent-call-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(Hc,{remarkPlugins:[Wc],components:Vc,children:p})})]}):null,!p&&k.length===0&&!r&&!f?h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细信息"}):null,S&&(u!=null&&u.open)?h.jsx("div",{className:"flex justify-end",children:h.jsxs("button",{type:"button","data-testid":"open-subagent-btn","data-agent-id":S,onClick:()=>u.open(S,o==null?void 0:o.agentType),className:ne("inline-flex items-center gap-1 rounded-md border border-bg-200/60","bg-bg-100/40 hover:bg-bg-200/40 transition-colors","px-2 py-1 text-[11px] text-text-300"),children:[h.jsx(Mc,{className:"w-3 h-3"}),h.jsx("span",{children:"打开子 agent 对话"})]})}):null]}):null]})}function OR({title:e,items:t,live:n,progressColor:r="bg-green-500",listKind:i,children:s}){const[o,a]=g.useState(!!n),l=t.length,c=t.filter(d=>d.status==="completed").length,u=l>0?Math.round(c/l*100):0;return h.jsxs("div",{"data-testid":"msg-line-checklist","data-list-kind":i,className:"min-w-0 max-w-full py-1",children:[h.jsxs("button",{type:"button",onClick:()=>a(d=>!d),"aria-expanded":o,className:"flex items-center gap-2.5 w-full text-left rounded-md px-1.5 py-1 hover:bg-text-100/5 cursor-pointer",children:[o?h.jsx(li,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(ci,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"text-[13px] font-medium text-text-200",children:e}),h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums",children:[c,"/",l]}),h.jsx("div",{className:"flex-1 max-w-[120px] h-1.5 rounded-full bg-text-100/10 overflow-hidden",children:h.jsx("div",{className:ne("h-full rounded-full transition-all duration-300",r),style:{width:`${u}%`}})})]}),o?h.jsxs("div",{"data-testid":"checklist-body",className:"ml-6 mt-0.5",children:[h.jsx("div",{className:"space-y-px",children:t.map((d,f)=>h.jsxs("div",{className:"flex min-w-0 items-start gap-2 py-0.5 px-1",children:[h.jsx("span",{className:"w-4 h-4 mt-0.5 flex items-center justify-center shrink-0",children:d.status==="completed"?h.jsx(Za,{className:"w-3.5 h-3.5 text-green-500"}):d.status==="in_progress"&&n?h.jsx(rr,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx("span",{className:"w-2 h-2 rounded-full border border-text-400/40"})}),h.jsx("span",{className:ne("min-w-0 text-[13px] leading-snug break-words [overflow-wrap:anywhere]",d.status==="completed"?"text-text-400 line-through":"text-text-200"),children:d.status==="in_progress"&&d.activeForm?d.activeForm:d.content})]},`${f}-${d.content}`))}),s]}):null]})}function SY({todos:e,live:t}){return h.jsx(OR,{title:"Tasks",items:e,live:t,progressColor:"bg-green-500",listKind:"todo"})}function kY({tasks:e,live:t}){return h.jsx(OR,{title:"Plan",items:e,live:t,progressColor:"bg-blue-500",listKind:"plan"})}function CY(e){if(!e||!Number.isFinite(e))return null;const t=Date.now()-e;if(t<0)return null;const n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const s=Math.floor(i/24);if(s<7)return`${s}d ago`;const o=Math.floor(s/7);return o<5?`${o}w ago`:new Date(e).toISOString().slice(0,10)}function EY(e){return(e.split("/").pop()??e)||e}function NY({memories:e}){return!e||e.length===0?null:h.jsxs("div",{"data-testid":"memory-callout",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[12px] text-text-300 border-b border-bg-200/60",children:[h.jsx(TB,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}),h.jsx("span",{className:"font-medium",children:"项目记忆"}),h.jsxs("span",{className:"text-text-400 tabular-nums",children:["· ",e.length]})]}),h.jsx("ul",{className:"divide-y divide-bg-200/40",children:e.map(t=>h.jsx(TY,{memory:t},t.path))})]})}function TY({memory:e}){const[t,n]=g.useState(!1),r=CY(e.mtimeMs),i=e.content.replace(/\s+/g," ").trim().slice(0,80);return h.jsxs("li",{className:"px-2.5 py-1.5",children:[h.jsxs("button",{type:"button","aria-expanded":t,onClick:()=>n(s=>!s),className:ne("flex w-full items-center gap-1.5 text-left text-[12px]","hover:bg-bg-200/30 rounded-sm py-0.5"),children:[t?h.jsx(li,{className:"w-3 h-3 text-text-400 shrink-0"}):h.jsx(ci,{className:"w-3 h-3 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-300 shrink-0 max-w-[20ch] truncate",title:e.path,children:EY(e.path)}),h.jsx("span",{className:"flex-1 min-w-0 truncate text-text-400/80",children:i}),r?h.jsx("span",{className:"shrink-0 text-[11px] text-text-400 tabular-nums",children:r}):null]}),t?h.jsx("pre",{"data-testid":"memory-callout-body",className:"mt-1 max-w-full whitespace-pre-wrap break-words text-[12px] text-text-300 bg-bg-50/60 rounded-md p-2 border border-bg-200/60 [overflow-wrap:anywhere]",children:e.content}):null]})}function PY({toolUseId:e,questions:t,onSubmit:n,onCancel:r,submittedAnswers:i}){const[s,o]=g.useState({}),[a,l]=g.useState({}),[c,u]=g.useState({}),[d,f]=g.useState(!1),[p,m]=g.useState(!1),v=i!==void 0&&Object.keys(i).length>0,y=v||p,_=!n&&!v,x=(S,k)=>{const T={labels:new Set,freeText:""};if(!v||!i)return T;const N=i[S];if(typeof N!="string")return T;const L=N.split(",").map(R=>R.trim()).filter(Boolean),P=new Set(k.map(R=>R.label)),O=new Set,I=[];for(const R of L)P.has(R)?O.add(R):I.push(R);return{labels:O,freeText:I.join(", ")}},b=g.useMemo(()=>t.every(S=>{if((c[S.question]??"").trim().length>0)return!0;if(S.multiSelect){const T=a[S.question];return!!(T&&T.size>0)}return typeof s[S.question]=="string"&&s[S.question].length>0}),[t,s,a,c]),w=async()=>{if(!b||d||y||_||!n)return;const S={};for(const k of t){const T=(c[k.question]??"").trim();if(k.multiSelect){const N=a[k.question],L=N?k.options.filter(P=>N.has(P.label)).map(P=>P.label):[];if(T.length>0&&L.push(T),L.length===0)continue;S[k.question]=L.join(", ")}else if(T.length>0)S[k.question]=T;else{const N=s[k.question];typeof N=="string"&&(S[k.question]=N)}}f(!0);try{await n(S),m(!0)}finally{f(!1)}};return h.jsxs("div",{"data-testid":"msg-line-question","data-tool-use-id":e,className:"min-w-0 max-w-full rounded-md border border-accent/40 bg-accent/5 px-3 py-2.5 text-[13px]",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 mb-2",children:[h.jsx(HB,{className:"w-4 h-4 text-accent shrink-0"}),h.jsx("span",{className:"min-w-0 font-medium text-text-100",children:"需要你的回答 / Need your answer"}),t.length>1?h.jsxs("span",{className:"ml-auto text-[12px] text-text-400","data-testid":"msg-line-question-count",children:[t.length," 个问题"]}):null]}),h.jsx("div",{className:"flex flex-col gap-3 mb-3",children:t.map((S,k)=>{const T=`q-${k}`,N=`${e}-${k}`,L=x(S.question,S.options),P=y||_,O=c[S.question]??"",I=v?L.freeText:p?(c[S.question]??"").trim():"";return h.jsxs("div",{"data-testid":"msg-line-question-item",children:[S.question?h.jsx("div",{className:"text-text-200 mb-1.5",children:S.question}):null,h.jsx("div",{className:"flex flex-col gap-1",children:S.options.map((R,j)=>{var F;const z=`${T}-${j}`,$=v?L.labels.has(R.label):S.multiSelect?!!((F=a[S.question])!=null&&F.has(R.label)):s[S.question]===R.label;return h.jsxs("label",{className:"flex min-w-0 items-start gap-2 cursor-pointer select-none py-1 px-2 rounded hover:bg-bg-100",children:[h.jsx("input",{type:S.multiSelect?"checkbox":"radio",name:N,value:R.label,checked:$,disabled:y||_,onChange:()=>{y||_||(S.multiSelect?l(A=>{const B=new Set(A[S.question]??[]);return B.has(R.label)?B.delete(R.label):B.add(R.label),{...A,[S.question]:B}}):o(A=>({...A,[S.question]:R.label})))},className:"mt-0.5","data-testid":"msg-line-question-option"}),h.jsxs("span",{className:"flex min-w-0 flex-col",children:[h.jsx("span",{className:"text-text-100 [overflow-wrap:anywhere]",children:R.label}),R.description?h.jsx("span",{className:"text-[12px] text-text-400 [overflow-wrap:anywhere]",children:R.description}):null]})]},z)})}),P?I.length>0?h.jsx("div",{className:"mt-2 rounded-lg border border-accent/15 bg-bg-100/60 px-3 py-2 text-[13px] leading-relaxed text-text-200 [overflow-wrap:anywhere]","data-testid":"msg-line-question-freetext-result",children:I}):null:h.jsx("textarea",{rows:3,value:O,placeholder:"或自行输入回答...",onChange:R=>{const j=R.target.value;u(z=>({...z,[S.question]:j}))},className:"mt-2 w-full resize-y rounded-lg border border-accent/20 bg-bg-000/60 px-3 py-2 text-[13px] leading-relaxed text-text-100 placeholder:text-text-400 outline-none transition-colors focus:border-accent/60 focus:bg-bg-000","data-testid":"msg-line-question-freetext"})]},T)})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ni,{size:"sm",variant:"default",onClick:()=>void w(),disabled:!b||d||y||_,"data-testid":"msg-line-question-submit",children:y?"已提交 / Submitted":_?"已结束 / Ended":"提交 / Submit"}),r&&!y&&!_?h.jsx(ni,{size:"sm",variant:"ghost",onClick:()=>void r(),disabled:d,"data-testid":"msg-line-question-cancel",children:"跳过 / Skip"}):null]})]})}function IY({toolUseId:e,questions:t,historicalAnswers:n,realtimeAnswers:r,onSubmit:i,onCancel:s}){const o=r??n,a=g.useCallback(async c=>{i&&await i(e,c)},[i,e]),l=g.useCallback(async()=>{s&&await s(e)},[s,e]);return h.jsx(PY,{toolUseId:e,questions:t,onSubmit:i?a:void 0,...s?{onCancel:l}:{},submittedAnswers:o})}function RY(){const e=new Map,t=(n,r)=>`${n}::${r}`;return{register(n,r,i){e.set(t(n,r),i)},resolve(n,r){return n?e.get(t(n,r))??null:null},reset(){e.clear()}}}const pu=RY();function BR({lines:e,onPermissionRespond:t,onPermissionInterrupt:n,topSlot:r,onRewind:i,rewindableUserMessageIds:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v}){const y=g.useMemo(()=>P7(e),[e]);return h.jsxs("div",{"data-testid":"message-list",className:"flex w-full min-w-0 max-w-full flex-col gap-2 px-4 py-3",children:[r,y.map(_=>MY(_,{onRewind:i,rewindableUserMessageIds:s,onPermissionRespond:t,onPermissionInterrupt:n,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v}))]})}function MY(e,t){const{onRewind:n,rewindableUserMessageIds:r,onPermissionRespond:i,onPermissionInterrupt:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v}=t,y=`${e.kind}-${e.seq}`;switch(e.kind){case"session-init":return null;case"user-text":{const _=typeof e.uuid=="string"?e.uuid:void 0,x=!!(n&&_&&(!r||r.has(_)));return h.jsx(lY,{text:e.text,senderDisplayName:e.senderDisplayName,rewindTarget:x&&_&&n?{userMessageId:_,onRewind:n}:void 0},y)}case"user-meta":return h.jsx(fY,{metaKind:e.metaKind,text:e.text},y);case"meta-text":return h.jsx(pY,{text:e.text,metaSource:e.metaSource},y);case"agent-notification":return h.jsx(gY,{text:e.text,taskId:e.taskId,parentToolUseId:e.parentToolUseId},y);case"assistant-text":{const _=typeof e.uuid=="string"?e.uuid:void 0,x=_&&(o||a)?{messageUuid:_,onFork:o,onQuickAsk:a}:void 0;return h.jsx(PX,{text:M7(e.text),forkTarget:x},y)}case"assistant-thinking":return h.jsx(IX,{text:e.text},y);case"permission-inline":return h.jsx(nY,{tool:e.tool,input:e.input,onRespond:i??(()=>{}),onInterrupt:s},y);case"error":return h.jsx(rY,{message:e.message},y);case"turn-end":return null;case"merged-tool":return AY(e,y,{fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v});case"merged-agent":return h.jsx(wY,{description:e.description,input:e.input,output:e.output,error:e.error,pending:e.pending,notifications:e.notifications,toolResultExtra:e.toolResultExtra,progress:e.progress},y);case"plan-card":return h.jsx(kY,{tasks:e.tasks},y);case"todo-checklist":return h.jsx(SY,{todos:e.todos},y);case"memory-callout":return h.jsx(NY,{memories:e.memories},y);case"question-card":{const _=d===void 0||d.has(e.toolUseId);return h.jsx(IY,{toolUseId:e.toolUseId,questions:e.questions,historicalAnswers:e.submittedAnswers,realtimeAnswers:l==null?void 0:l[e.toolUseId],onSubmit:_?c:void 0,..._&&u?{onCancel:u}:{}},y)}default:return null}}function AY(e,t,n){const r=pu.resolve(e.toolKind,e.tool),i=r?r.render({input:e.input,output:e.output,error:e.error,pending:e.pending,toolUseId:e.toolUseId,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}}):null;return h.jsx(st.Fragment,{children:i??h.jsx(MR,{tool:e.tool,input:e.input,output:e.output,error:e.error,pending:e.pending,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}})},t)}function $d(e){return e==="codex"?"Codex":"Claude Code"}const jY={builtin:"Commands",global:"Global",project:"Project",plugin:"Plugin"},AS={builtin:0,global:1,project:2,plugin:3};function DY({query:e,skills:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>zR(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++)a[d].source!==u&&(c.add(d),u=a[d].source);return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.length===0?null:h.jsx("div",{"data-testid":"cc-skill-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:a.map((c,u)=>{const d=u===n,f=l.has(u);return h.jsxs(st.Fragment,{children:[f?h.jsx("div",{className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:jY[c.source]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":`cc-skill-item-${c.name}`,onMouseEnter:()=>r(u),onClick:()=>i(c),className:ne("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsxs("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:["/",c.name]}),c.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-auto",children:c.description}):null]})]},`${c.source}/${c.name}`)})})}function zR(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>i.name.toLowerCase().includes(n)||(i.description??"").toLowerCase().includes(n)):e.slice();return r.sort((i,s)=>(AS[i.source]??9)-(AS[s.source]??9)),r.slice(0,30)}const LY={builtin:"Built-in",global:"Global",project:"Project",policy:"Policy",plugin:"Plugin",persona:"My personas",contact:"People","remote-persona":"Remote personas"},jS={builtin:0,global:1,project:2,policy:3,plugin:4,persona:5,contact:6,"remote-persona":7};function Vh(e){switch(e.kind){case"persona":return"persona";case"contact":return"contact";case"remote-persona":return"remote-persona";case"cc-agent":return e.agent.source}}function OY(e){switch(e.kind){case"persona":return`persona/${e.persona.personaId}`;case"contact":return`contact/${e.contact.deviceId}`;case"remote-persona":return`remote/${e.deviceId}/${e.persona.personaId}`;case"cc-agent":return`${e.agent.source}/${e.agent.name}`}}function BY(e){switch(e.kind){case"persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"contact":return`${e.contact.displayName} ${e.contact.deviceId}`.toLowerCase();case"remote-persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"cc-agent":{const t=e.agent;return`${t.name} ${t.description??""} ${t.whenToUse??""}`.toLowerCase()}}}function zY(e){switch(e.kind){case"persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-persona-${e.persona.personaId}`};case"contact":return{displayName:`@${e.contact.displayName}`,description:e.contact.deviceId,testid:`cc-agent-item-contact-${e.contact.deviceId}`};case"remote-persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-remote-${e.deviceId}-${e.persona.personaId}`};case"cc-agent":return{displayName:`@${e.agent.name}`,description:e.agent.description,whenToUse:e.agent.whenToUse,plugin:e.agent.plugin,testid:`cc-agent-item-${e.agent.name}`}}}function $R(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>BY(i).includes(n)):e.slice();return r.sort((i,s)=>(jS[Vh(i)]??9)-(jS[Vh(s)]??9)),r.slice(0,30)}function DS({query:e,entries:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>$R(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++){const f=Vh(a[d]);f!==u&&(c.add(d),u=f)}return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.length===0?null:h.jsx("div",{"data-testid":"cc-agent-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:a.map((c,u)=>{const d=u===n,f=l.has(u),p=Vh(c),m=zY(c);return h.jsxs(st.Fragment,{children:[f?h.jsx("div",{"data-testid":`cc-agent-group-header-${p}`,"data-source":p,className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:LY[p]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":m.testid,onMouseEnter:()=>r(u),onClick:()=>i(c),className:ne("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsx("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:m.displayName}),m.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-2",children:m.description}):null,m.whenToUse?h.jsx("span",{className:"text-[10px] text-text-400/70 italic truncate ml-auto",children:m.whenToUse}):null,m.plugin?h.jsx("span",{className:"text-[10px] text-text-400/70 ml-2 shrink-0",children:m.plugin}):null]})]},OY(c))})})}function $Y({attachment:e,onRemove:t,onOpenPreview:n}){const r=e.mimeType.startsWith("image/"),i=e.status==="error",s=e.status==="uploading",o=r&&e.status==="done"&&!!e.previewUrl&&!!n;return h.jsxs("div",{"data-testid":`attachment-pill-${e.id}`,className:ne("group relative flex items-center gap-1.5 rounded-lg border px-2 py-1.5 text-[12px] transition-colors",i?"border-red-400/40 bg-red-500/5":"border-bg-300 bg-bg-100"),children:[r&&e.previewUrl?h.jsxs("div",{className:"relative h-7 w-7 shrink-0",children:[h.jsx("img",{src:e.previewUrl,alt:e.fileName,onClick:o?n:void 0,"data-testid":`attachment-thumb-${e.id}`,className:ne("h-7 w-7 rounded object-cover",o&&"cursor-pointer hover:opacity-80",s&&"opacity-40")}),s?h.jsx(rr,{"data-testid":`attachment-spinner-${e.id}`,className:"absolute inset-0 m-auto h-3.5 w-3.5 animate-spin text-text-200"}):null]}):h.jsx("div",{className:"relative flex h-7 w-7 items-center justify-center rounded bg-text-100/5 shrink-0",children:s?h.jsx(rr,{"data-testid":`attachment-spinner-${e.id}`,className:"h-3.5 w-3.5 animate-spin text-text-400"}):h.jsx(Ms,{className:"h-3.5 w-3.5 text-text-400"})}),h.jsx("span",{className:ne("max-w-[120px] truncate text-text-200",s&&"text-text-400"),title:e.error??e.fileName,children:e.fileName}),i?h.jsx(Rs,{className:"h-3 w-3 text-red-400 shrink-0"}):null,h.jsx("button",{type:"button",onClick:t,"data-testid":`attachment-remove-${e.id}`,className:"flex h-4 w-4 items-center justify-center rounded-full text-text-400 hover:text-text-100 hover:bg-text-100/10 transition-colors cursor-pointer shrink-0","aria-label":"remove",children:h.jsx(Rn,{className:"h-3 w-3"})})]})}function FY({attachments:e,onRemove:t,onOpenPreview:n}){return e.length===0?null:h.jsx("div",{"data-testid":"attachment-row",className:"flex flex-wrap gap-1.5 mb-2 px-1",children:e.map(r=>h.jsx($Y,{attachment:r,onRemove:()=>t(r.id),onOpenPreview:n?()=>n(r):void 0},r.id))})}class Bl extends Error{constructor(t,n,r){super(n),this.code=t,this.status=r,this.name="UploadAttachmentError"}}async function HY(e){if(!e.httpBaseUrl)throw new Bl("TUNNEL_NOT_READY","daemon httpBaseUrl unavailable");if(!e.httpToken)throw new Bl("NO_AUTH","daemon httpToken unavailable");const t=new URLSearchParams({sessionId:e.sessionId,fileName:e.file.name,mimeType:e.file.type||"application/octet-stream"}),n=`${e.httpBaseUrl.replace(/\/$/,"")}/attachments/upload?${t.toString()}`;let r;try{r=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${e.httpToken}`,"Content-Type":e.file.type||"application/octet-stream"},body:e.file})}catch(i){throw new Bl("NETWORK_ERROR",i.message)}if(!r.ok){let i="UPLOAD_FAILED",s=`HTTP ${r.status}`;try{const o=await r.json();o.code&&(i=o.code),o.message&&(s=o.message)}catch{}throw new Bl(i,s,r.status)}return await r.json()}const LS=25*1024*1024,UY="image/*,.txt,.md,.markdown,.csv,.json,.log,.yaml,.yml,.html,.xml,.pdf",WY=["image/","text/"],VY=new Set(["application/json","application/xml","application/x-yaml","application/yaml","application/pdf"]),qY=new Set(["txt","md","markdown","csv","json","log","yaml","yml","html","xml","pdf"]);function KY(e){var r;const t=(e.type||"").toLowerCase();if(t&&WY.some(i=>t.startsWith(i))||t&&VY.has(t))return!0;const n=((r=e.name.split(".").pop())==null?void 0:r.toLowerCase())??"";return n.length>0&&qY.has(n)}let GY=0;const XY=()=>`att-${++GY}-${Date.now()}`;function YY(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(typeof r.result=="string"?r.result:""),r.onerror=()=>n(r.error??new Error("read failed")),r.readAsDataURL(e)})}function ZY(e){const[t,n]=g.useState(e.initial??[]),r=g.useCallback(async o=>{const a=Array.from(o);if(a.length===0)return;const l=[],c=[],u=[];for(const d of a){const f={id:XY(),fileName:d.name,mimeType:d.type||"application/octet-stream"};if(!KY(d)){c.push({...f,url:null,status:"error",error:"不支持的文件类型"});continue}if(d.size>LS){c.push({...f,url:null,status:"error",error:`超过 ${Math.round(LS/1024/1024)}MB 上限`});continue}if(e.sessionId==null){u.push({id:f.id,file:d,mimeType:f.mimeType}),c.push({...f,url:null,status:"uploading"});continue}const p=f.mimeType.startsWith("image/")?URL.createObjectURL(d):void 0;c.push({...f,url:null,status:"uploading",...p?{previewUrl:p}:{}}),l.push({id:f.id,file:d})}n(d=>[...d,...c]);for(const d of u)try{const f=await YY(d.file);n(p=>p.map(m=>m.id===d.id?{...m,url:f,status:"done",...d.mimeType.startsWith("image/")?{previewUrl:f}:{}}:m))}catch(f){n(p=>p.map(m=>m.id===d.id?{...m,status:"error",error:f.message??"read failed"}:m))}l.length!==0&&await Promise.all(l.map(async d=>{try{const f=await HY({httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken,sessionId:e.sessionId,file:d.file});n(p=>p.map(m=>m.id===d.id?{...m,url:f.url,status:"done"}:m))}catch(f){const p=f instanceof Bl?f.code:"UPLOAD_FAILED",m=f.message??"upload failed";n(v=>v.map(y=>y.id===d.id?{...y,status:"error",error:`${p}: ${m}`}:y))}}))},[e.sessionId,e.httpBaseUrl,e.httpToken]),i=g.useCallback(o=>{n(a=>a.filter(l=>l.id!==o))},[]),s=g.useCallback(()=>{n([])},[]);return{attachments:t,setAttachments:n,addFiles:r,removeAttachment:i,clearAttachments:s}}const Yv=new Map,QY=[];function OS(e){if(e)return Yv.get(e)}function BS(e,t){e&&(t.draft.length===0&&t.attachments.length===0?Yv.delete(e):Yv.set(e,t))}function JY(e,t){return e.replace(/(^|\s)\/(\S+)/g,(n,r,i)=>{const s=t.find(o=>o.name===i&&o.path);return s!=null&&s.path?`${r}[skill:${i}:${s.path}]`:n})}function eZ({api:e,cwd:t,sessionKey:n,onSend:r,disabled:i,onNewSession:s,onClearSession:o,tool:a,spawnableContacts:l=QY,ensureRemotePersonas:c,remotePersonasByDeviceId:u}){const d=OS(n),[f,p]=g.useState((d==null?void 0:d.draft)??""),[m,v]=g.useState(!1),y=g.useRef(null),_=g.useRef(!1),x=g.useCallback(()=>{_.current=!0},[]),b=g.useCallback(()=>{_.current=!1},[]),w=Af(),{attachments:S,setAttachments:k,addFiles:T,removeAttachment:N,clearAttachments:L}=ZY({httpBaseUrl:w.httpBaseUrl,httpToken:w.httpToken,sessionId:n,initial:(d==null?void 0:d.attachments)??[]}),[P,O]=g.useState([]),[I,R]=g.useState(!1),[j,z]=g.useState(0),[$,F]=g.useState(!1),[A,B]=g.useState([]),[E,H]=g.useState(!1),[q,M]=g.useState(0),[re,oe]=g.useState(!1),[V,pe]=g.useState([]),[Oe,ie]=g.useState(!1),[Me,Fe]=g.useState(null),[We,ge]=g.useState(!1),qe=g.useRef(null),Gt=g.useMemo(()=>{const ue=[];return s&&ue.push({name:"new",source:"builtin",description:"在当前目录下新建会话"}),o&&n&&ue.push({name:"clear",source:"builtin",description:"清除当前会话"}),ue},[s,o,n]),wt=g.useMemo(()=>[...Gt,...P],[Gt,P]),Rt=g.useMemo(()=>{const ue=f.match(/^\/(\S*)$/);return ue?ue[1]:null},[f]),ln=Rt!==null&&!$,Bt=g.useMemo(()=>Rt!==null?zR(wt,Rt):[],[wt,Rt]),at=g.useMemo(()=>{const ue=f.match(/^@(\S*)$/);return ue?ue[1]:null},[f]),Ue=at!==null&&!re,nt=g.useMemo(()=>Me?((u==null?void 0:u.get(Me.deviceId))??[]).map(Ne=>({kind:"remote-persona",persona:Ne,deviceId:Me.deviceId})):[...A.map(ue=>({kind:"cc-agent",agent:ue})),...V.map(ue=>({kind:"persona",persona:ue})),...l.map(ue=>({kind:"contact",contact:ue}))],[Me,u,A,V,l]),mt=g.useMemo(()=>at!==null?$R(nt,at):[],[nt,at]),Xt=g.useRef(f);g.useEffect(()=>{f!==Xt.current&&(F(!1),oe(!1),Xt.current=f)},[f]);const pn=g.useCallback(()=>{F(!0)},[]),U=g.useCallback(()=>{oe(!0)},[]),Q=g.useRef(f),ve=g.useRef(S);g.useEffect(()=>{Q.current=f},[f]),g.useEffect(()=>{ve.current=S},[S]);const Se=g.useRef(n);g.useEffect(()=>{const ue=Se.current;if(ue===n)return;BS(ue,{draft:Q.current,attachments:ve.current});const Ne=OS(n);p((Ne==null?void 0:Ne.draft)??""),k((Ne==null?void 0:Ne.attachments)??[]),z(0),M(0),F(!1),oe(!1),Fe(null),qe.current=null,ge(!1),queueMicrotask(()=>{Ne!=null&&Ne.draft?FR(y.current):Wo(y.current)}),Se.current=n},[n,k]),g.useEffect(()=>()=>{BS(Se.current,{draft:Q.current,attachments:ve.current})},[]),g.useEffect(()=>{z(0)},[Rt]),g.useEffect(()=>{M(0)},[at]),g.useEffect(()=>{at===null&&Me&&(Fe(null),qe.current=null,ge(!1))},[at,Me]),g.useEffect(()=>{if(!ln||I)return;if(!e){R(!0);return}let ue=!1;return(async()=>{try{const Ne=await e.skillsList(t,a);ue||(O(Ne.skills??[]),R(!0))}catch{ue||R(!0)}})(),()=>{ue=!0}},[ln,I,e,t,a]),g.useEffect(()=>{if(!Ue||E)return;if(!e){H(!0);return}let ue=!1;return(async()=>{try{const Ne=await e.agentsList(t,a);ue||(B(Ne.agents??[]),H(!0))}catch{ue||H(!0)}})(),()=>{ue=!0}},[Ue,E,e,t,a]),g.useEffect(()=>{if(!Ue||Oe)return;if(!e){ie(!0);return}let ue=!1;return(async()=>{try{const Ne=await e.personaList();ue||(pe((Ne.personas??[]).map(Je=>({personaId:Je.personaId,label:Je.label,iconKey:Je.iconKey}))),ie(!0))}catch{ue||ie(!0)}})(),()=>{ue=!0}},[Ue,Oe,e]);const J=g.useCallback(ue=>{switch(ue.kind){case"persona":p(`@persona/${ue.persona.personaId} `);break;case"cc-agent":p(`@"${ue.agent.name} (agent)" `);break;case"contact":{const Ne=ue.contact.deviceId;Fe({deviceId:Ne,displayName:ue.contact.displayName}),qe.current=Ne,ge(!0),Promise.resolve(c==null?void 0:c(Ne)).finally(()=>{qe.current===Ne&&ge(!1)}),p("@"),oe(!1),setTimeout(()=>{var Je;return(Je=y.current)==null?void 0:Je.focus()},0);return}case"remote-persona":p(`@persona/${ue.persona.personaId}@${ue.deviceId} `),Fe(null);break}oe(!1),setTimeout(()=>{var Ne;return(Ne=y.current)==null?void 0:Ne.focus()},0)},[c]),Xe=g.useCallback(()=>{Fe(null),qe.current=null,ge(!1),p("@"),setTimeout(()=>{var ue;return(ue=y.current)==null?void 0:ue.focus()},0)},[]),Yt=g.useCallback(ue=>{if(ue.source==="builtin"&&ue.name==="new"&&s){p(""),L(),Wo(y.current),s(t);return}if(ue.source==="builtin"&&ue.name==="clear"&&o){p(""),L(),Wo(y.current),o();return}p(`/${ue.name} `),setTimeout(()=>{var Ne;return(Ne=y.current)==null?void 0:Ne.focus()},0)},[s,t,L,o]),Zt=g.useCallback(async()=>{const ue=f.trim(),Ne=S.filter(Je=>Je.status==="done");if(!(!ue&&Ne.length===0)&&!(m||i)){if(ue==="/new"&&s){v(!0);try{await s(t),p(""),L(),Wo(y.current)}finally{v(!1)}return}if(ue==="/clear"&&o){v(!0);try{await o(),p(""),L(),Wo(y.current)}finally{v(!1)}return}v(!0);try{const Je=a==="codex"?JY(ue,P):ue,Dn=sY(Je,S);await r(Dn),p(""),L(),Wo(y.current)}finally{v(!1)}}},[f,S,m,i,r,s,t,L,o,a,P]);return{draft:f,setDraft:p,sending:m,textareaRef:y,isComposingRef:_,onCompositionStart:x,onCompositionEnd:b,attachments:S,addFiles:T,removeAttachment:N,skillSelectorVisible:ln,filteredSkills:Bt,slashQuery:Rt??"",activeSkillIdx:j,setActiveSkillIdx:z,selectSkill:Yt,dismissSkillSelector:pn,agentSelectorVisible:Ue,filteredAgents:mt,mentionQuery:at,activeAgentIdx:q,setActiveAgentIdx:M,selectAgent:J,dismissAgentSelector:U,drilldown:Me,drilldownLoading:We,exitDrilldown:Xe,doSend:Zt}}const tZ=120;function FR(e){e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,tZ)}px`)}function Wo(e){e&&(e.style.height="auto")}const nZ={spawnableContacts:[],ensureRemotePersonas:()=>Promise.resolve(),remotePersonasByDeviceId:new Map},rZ=g.createContext(nZ);function iZ(){return g.useContext(rZ)}function sZ({url:e,fileName:t,onClose:n}){const[r,i]=g.useState(!1);g.useEffect(()=>{const o=a=>{a.key==="Escape"&&n()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n]);const s=async()=>{try{const a=await(await fetch(e)).blob();await navigator.clipboard.write([new ClipboardItem({[a.type]:a})]),i(!0),setTimeout(()=>i(!1),2e3)}catch{zS(e,t)}};return h.jsx("div",{"data-testid":"image-lightbox",className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60",onClick:n,role:"dialog","aria-modal":"true",children:h.jsxs("div",{className:"relative",onClick:o=>o.stopPropagation(),children:[h.jsx("img",{src:e,alt:t,className:"max-h-[90vh] max-w-[92vw] rounded-lg object-contain shadow-2xl"}),h.jsxs("div",{className:"absolute right-2 top-2 flex items-center gap-1.5",children:[h.jsxs("button",{type:"button",onClick:s,"data-testid":"image-lightbox-copy",className:"flex cursor-pointer items-center gap-1 rounded-full border border-bg-300 bg-bg-50/95 px-2 py-0.5 text-[11px] font-medium text-text-200 shadow transition-colors hover:bg-bg-100",children:[h.jsx(su,{className:"h-3 w-3"}),r?"Copied":"Copy"]}),h.jsxs("button",{type:"button",onClick:()=>zS(e,t),"data-testid":"image-lightbox-save",className:"flex cursor-pointer items-center gap-1 rounded-full border border-bg-300 bg-bg-50/95 px-2 py-0.5 text-[11px] font-medium text-text-200 shadow transition-colors hover:bg-bg-100",children:[h.jsx(QB,{className:"h-3.5 w-3.5"}),"Save"]}),h.jsx("button",{type:"button",onClick:n,"data-testid":"image-lightbox-close","aria-label":"close",className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded-full border border-bg-300 bg-bg-50/95 text-text-300 transition-colors hover:bg-bg-100 hover:text-text-100",children:h.jsx(Rn,{className:"h-3 w-3"})})]})]})})}function zS(e,t){const n=document.createElement("a");n.href=e,n.download=t||"image",n.click()}function oZ({meta:e,api:t,cwd:n,tool:r,onSend:i,sessionKey:s,disabled:o=!1,placeholder:a,className:l,awaitingUser:c=!1,onAbort:u,onNewSession:d,onClearSession:f}){const p=(e==null?void 0:e.streamInProgress)??!1,m=g.useRef(null),v=iZ(),y=eZ({...t?{api:t}:{},cwd:n,...r?{tool:r}:{},sessionKey:s,onSend:i,disabled:o,...d?{onNewSession:d}:{},...f?{onClearSession:f}:{},spawnableContacts:v.spawnableContacts,ensureRemotePersonas:v.ensureRemotePersonas,remotePersonasByDeviceId:v.remotePersonasByDeviceId}),{draft:_,setDraft:x,sending:b,textareaRef:w,attachments:S,addFiles:k,removeAttachment:T,skillSelectorVisible:N,filteredSkills:L,slashQuery:P,activeSkillIdx:O,setActiveSkillIdx:I,selectSkill:R,dismissSkillSelector:j,agentSelectorVisible:z,filteredAgents:$,mentionQuery:F,activeAgentIdx:A,setActiveAgentIdx:B,selectAgent:E,dismissAgentSelector:H,drilldown:q,drilldownLoading:M,exitDrilldown:re,doSend:oe}=y,V=!!t,pe=b||o||p,ie=(_.trim().length>0||S.some(J=>J.status==="done"))&&!o&&!b&&!c,Me=a??(c?"Answer the question above first...":pe?"Queue a message...":`Message ${$d(r)}...`),Fe=g.useRef(!1),We=g.useCallback(()=>{Fe.current=!0},[]),ge=g.useCallback(()=>{Fe.current=!1},[]),qe=g.useCallback(J=>{if(N&&L.length>0){if(J.key==="ArrowDown")return J.preventDefault(),I(O>=L.length-1?0:O+1),!0;if(J.key==="ArrowUp")return J.preventDefault(),I(O<=0?L.length-1:O-1),!0;if(J.key==="Tab"||J.key==="Enter"&&!J.shiftKey){J.preventDefault();const Xe=L[O];return Xe&&R(Xe),!0}if(J.key==="Escape")return J.preventDefault(),j(),!0}return!1},[N,L,O,I,R,j]),Gt=g.useCallback(J=>{if(z&&$.length>0){if(J.key==="ArrowDown")return J.preventDefault(),B(A>=$.length-1?0:A+1),!0;if(J.key==="ArrowUp")return J.preventDefault(),B(A<=0?$.length-1:A-1),!0;if(J.key==="Tab"||J.key==="Enter"&&!J.shiftKey){J.preventDefault();const Xe=$[A];return Xe&&E(Xe),!0}if(J.key==="Escape")return J.preventDefault(),q?re():H(),!0}return!1},[z,$,A,B,E,H,q,re]),wt=g.useCallback(J=>{const Xe=J.nativeEvent;J.key==="Enter"&&iI({compositionActive:Fe.current,nativeIsComposing:Xe.isComposing,keyCode:Xe.keyCode})||qe(J)||Gt(J)||sI({key:J.key,shiftKey:J.shiftKey,compositionActive:Fe.current,nativeIsComposing:Xe.isComposing,keyCode:Xe.keyCode})&&(J.preventDefault(),ie&&oe())},[qe,Gt,ie,oe]),Rt=g.useCallback(J=>{x(J.target.value),FR(J.target)},[x]),ln=g.useCallback(J=>{J.target.files&&k(J.target.files),J.target.value=""},[k]),Bt=g.useCallback(J=>{if(!V)return;const Xe=Array.from(J.clipboardData.items).map(Yt=>Yt.getAsFile()).filter(Yt=>!!(Yt&&Yt.type.startsWith("image/")));Xe.length!==0&&(J.preventDefault(),k(Xe))},[k,V]),[at,Ue]=g.useState(null),nt=g.useCallback(J=>{J.previewUrl&&Ue({url:J.previewUrl,name:J.fileName})},[]),[mt,Xt]=g.useState(!1),pn=g.useCallback(J=>{V&&(J.preventDefault(),Xt(!0))},[V]),U=g.useCallback(()=>Xt(!1),[]),Q=g.useCallback(J=>{V&&(J.preventDefault(),Xt(!1),J.dataTransfer.files.length>0&&k(J.dataTransfer.files))},[k,V]),ve=p&&!c&&typeof u=="function",Se=o||c;return h.jsxs("div",{"data-testid":"chat-input",className:ne("shrink-0 border-t border-bg-300/20 px-4 py-3",l),onDragOver:pn,onDragLeave:U,onDrop:Q,children:[h.jsxs("div",{className:"max-w-3xl mx-auto relative",children:[V?h.jsx("input",{ref:m,type:"file",multiple:!0,accept:UY,hidden:!0,onChange:ln,"data-testid":"chat-input-file"}):null,h.jsxs("div",{"data-testid":"chat-input-bare",className:ne("flex flex-col gap-2"),children:[c||b||p?h.jsxs("div",{"data-testid":"chat-input-status-bar",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsxs("div",{className:"flex gap-1",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{children:c?"Waiting for your answer":`${r==="codex"?"Codex":"Claude"} is working`})]}):null,N?h.jsx(DY,{query:P,skills:L,activeIndex:O,onActiveIndexChange:I,onSelect:R}):null,z?q?!v.remotePersonasByDeviceId.has(q.deviceId)&&M?h.jsx("div",{"data-testid":"cc-agent-remote-loading",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`正在加载 @${q.displayName} 的 persona…`}):$.length>0?h.jsx(DS,{query:F??"",entries:$,activeIndex:A,onActiveIndexChange:B,onSelect:E}):h.jsx("div",{"data-testid":"cc-agent-remote-empty",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`@${q.displayName} 暂无可派活的 persona(可能离线或未公开)`}):h.jsx(DS,{query:F??"",entries:$,activeIndex:A,onActiveIndexChange:B,onSelect:E}):null,S.length>0?h.jsx(FY,{attachments:S,onRemove:T,onOpenPreview:nt}):null,h.jsxs("div",{"data-testid":"bare-chat-input-frame",className:ne("flex items-end gap-2 rounded-xl border border-bg-300 bg-bg-50 px-3 py-2 transition-colors duration-200",Se?"opacity-60":null,mt?"border-accent/60 bg-accent/5":null),children:[V?h.jsx("button",{type:"button",onClick:()=>{var J;return(J=m.current)==null?void 0:J.click()},disabled:pe,"data-testid":"chat-input-attach","aria-label":"attach files",className:ne("flex h-8 w-8 shrink-0 self-end items-center justify-center rounded-md transition-colors",pe?"cursor-default text-text-400/50":"cursor-pointer text-text-400 hover:bg-text-100/5 hover:text-text-200"),children:h.jsx(E6,{className:"h-4 w-4"})}):null,h.jsx("textarea",{ref:w,"data-testid":"chat-input-textarea",value:_,onChange:Rt,onKeyDown:wt,onCompositionStart:We,onCompositionEnd:ge,onPaste:Bt,placeholder:Me,disabled:Se,readOnly:Se,rows:1,className:"flex-1 resize-none bg-transparent border-0 outline-none text-[14px] text-text-100 placeholder:text-text-400 leading-relaxed py-1 min-h-[22px] max-h-[120px] overflow-y-auto disabled:cursor-not-allowed"}),h.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 pb-0.5",children:[ve?h.jsx("button",{type:"button",onClick:u,"data-testid":"chat-input-abort","aria-label":"interrupt",title:"中断当前轮次(不杀进程)",className:"h-8 w-8 rounded-full flex items-center justify-center border border-text-400/40 text-text-400 hover:bg-text-100/5 hover:text-text-100 transition-colors cursor-pointer",children:h.jsx($N,{className:"w-3.5 h-3.5",strokeWidth:2.5})}):null,h.jsx("button",{type:"button",onClick:()=>{ie&&oe()},disabled:!ie,"data-testid":"chat-input-send","aria-label":"send",className:ne("h-8 w-8 rounded-full flex items-center justify-center transition-colors",ie?"bg-accent text-white hover:bg-accent-hover cursor-pointer shadow-sm":"bg-[var(--text-400-dim)] text-[var(--text-400-dim-fg)] cursor-default"),children:h.jsx(SB,{className:"w-4 h-4",strokeWidth:2.5})})]})]})]})]}),at?h.jsx(sZ,{url:at.url,fileName:at.name,onClose:()=>Ue(null)}):null]})}function aZ(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function lZ({meta:e,tool:t,connState:n,onOpenConfig:r,models:i,liveGitBranch:s,liveWorktreeRoot:o,onForceStop:a,cronActiveCount:l,onCronClick:c,onOpenFiles:u,onTogglePin:d,isHolded:f=!1,onToggleHold:p,personaName:m,onOpenPersona:v,className:y}){const _=e.procAlive??!1,x=e.streamInProgress??!1,b=e.permissionMode,w=b&&b!=="default"?b:null,S=w==="bypassPermissions"?"YOLO":w==="plan"?"Plan":null,k=e.model??"",T=cZ(i,k),N=e.contextPct??null,L=N==null?"":N>=80?"text-red-400":N>=50?"text-amber-400":"text-text-500",P=s!==void 0?s:e.gitBranch??null,O=o??e.cwd??"",R=!!e.sessionLabel&&e.sessionLabel!==e.sessionId?e.sessionLabel:aZ(O),j=O,z=e.pinnedAt!=null;return h.jsxs("div",{"data-testid":"chat-header",className:ne("relative flex flex-col justify-center shrink-0 px-4 pr-14 py-2 gap-1",y),children:[h.jsxs("div",{className:"flex items-center min-w-0 gap-2 text-[13px]",children:[d?h.jsx("button",{type:"button",onClick:()=>d(!z),"data-testid":"chat-header-pin-toggle","data-pinned":z?"true":"false","aria-pressed":z,title:z?"Unpin session":"Pin session",className:ne("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md cursor-pointer transition-colors",z?"text-amber-400 hover:bg-amber-500/10":"text-text-500 hover:text-text-200 hover:bg-text-100/5"),children:h.jsx(HN,{className:ne("w-3.5 h-3.5",z&&"fill-current")})}):null,p?h.jsx("button",{type:"button",onClick:()=>p(!f),"data-testid":"chat-header-hold-toggle","data-holded":f?"true":"false","aria-pressed":f,title:f?"Release hold":"Hold session",className:ne("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md cursor-pointer transition-colors",f?"text-amber-400 hover:bg-amber-500/10":"text-text-500 hover:text-text-200 hover:bg-text-100/5"),children:h.jsx(MB,{className:ne("w-3.5 h-3.5",f&&"fill-current")})}):null,h.jsx("span",{className:"font-semibold text-text-100 truncate","data-testid":"chat-header-worktree",title:j,children:R}),P?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500 shrink-0",children:":"}),h.jsx("span",{className:"font-mono text-text-300 truncate","data-testid":"chat-header-git",title:P,children:P})]}):null]}),h.jsxs("div",{className:"flex items-center min-w-0 gap-2 text-[11px]",children:[S?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("desktop"),"data-testid":"chat-header-mode-chip",className:ne("hidden md:inline-flex shrink-0 px-2 py-0.5 rounded-md font-semibold cursor-pointer transition-colors",w==="bypassPermissions"?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"bg-blue-500/15 text-blue-400 hover:bg-blue-500/25"),children:S}),h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("mobile"),"aria-hidden":"true",tabIndex:-1,className:ne("inline-flex md:hidden shrink-0 px-2 py-0.5 rounded-md font-semibold cursor-pointer transition-colors",w==="bypassPermissions"?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"bg-blue-500/15 text-blue-400 hover:bg-blue-500/25"),children:S})]}):null,k||i?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("desktop"),"data-testid":"chat-header-model-chip",className:"hidden md:inline-flex shrink-0 font-mono text-text-400 cursor-pointer hover:text-text-200 transition-colors",children:T}),h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("mobile"),"aria-hidden":"true",tabIndex:-1,className:"inline-flex md:hidden shrink-0 font-mono text-text-400 cursor-pointer hover:text-text-200 transition-colors",children:T})]}):null,N!=null?h.jsxs("span",{className:ne("shrink-0 font-mono",L),"data-testid":"chat-header-ctx",children:["ctx:",N,"%"]}):null,h.jsxs("span",{"data-testid":"chat-header-proc-status",className:"inline-flex items-center gap-1 text-text-500 shrink-0",title:x?`${$d(t)} 正在跑当前 turn`:_?`${$d(t)} 进程仍活,等下一轮输入`:`${$d(t)} 进程未运行(发送消息会自动启动)`,children:[h.jsx("span",{className:ne("w-1.5 h-1.5 rounded-full",x?"bg-green-500":"bg-text-400/50")}),h.jsx("span",{children:x?"running":"idle"})]}),_&&a?h.jsxs("button",{type:"button",onClick:a,"data-testid":"chat-header-force-stop",title:t==="codex"?"强制停止 Codex 进程":"强制停止 Claude Code 进程(会丢失 initialize / 预热缓存)",className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-400 hover:bg-red-500/10 hover:text-red-400 transition-colors cursor-pointer",children:[h.jsx(k6,{className:"w-3 h-3"}),h.jsx("span",{children:"Stop"})]}):null,m&&v||u||l&&l>0&&c?h.jsx("span",{className:"text-text-500 shrink-0","aria-hidden":"true",children:"·"}):null,m&&v?h.jsxs("button",{type:"button",onClick:v,"data-testid":"chat-header-persona",title:m,className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-300 hover:bg-bg-200 hover:text-text-100 transition-colors cursor-pointer",children:[h.jsx(Y_,{className:"w-3 h-3"}),h.jsx("span",{className:"truncate max-w-[80px] md:max-w-[120px]",children:m})]}):null,u?h.jsxs("button",{type:"button",onClick:u,"data-testid":"chat-header-files",title:"Edited Files",className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-300 hover:bg-bg-200 hover:text-text-100 transition-colors cursor-pointer",children:[h.jsx(s6,{className:"w-3 h-3"}),h.jsx("span",{className:"hidden md:inline",children:"Edited Files"})]}):null,l&&l>0&&c?h.jsxs("button",{type:"button","data-testid":"chat-header-cron-button",onClick:c,"aria-label":"Cron tasks",title:`${l} active cron task${l===1?"":"s"}`,className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-400 hover:bg-accent-dim hover:text-accent transition-colors cursor-pointer",children:[h.jsx(VB,{className:"w-3 h-3"}),h.jsx("span",{"data-testid":"chat-header-cron-badge",className:"font-mono",children:l})]}):null]}),r?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings",onClick:()=>r("desktop"),title:"Session settings",className:"hidden md:flex absolute right-4 top-3 z-10 h-7 w-7 items-center justify-center rounded-md bg-transparent text-text-300 transition-colors duration-150 hover:bg-bg-200 hover:text-text-100 cursor-pointer outline-none",children:h.jsx(Sv,{className:"w-4 h-4"})}),h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings-mobile",onClick:()=>r("mobile"),title:"Session settings",className:"flex md:hidden absolute right-4 top-3 z-10 h-7 w-7 items-center justify-center rounded-md bg-transparent text-text-300 transition-colors duration-150 hover:bg-bg-200 hover:text-text-100 cursor-pointer outline-none",children:h.jsx(Sv,{className:"w-4 h-4"})})]}):null]})}function cZ(e,t){if(!t)return"default";const n=t.toLowerCase(),r=[["opus","Opus"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[a,l]of r){if(!n.includes(a))continue;const c=n.match(new RegExp(`${a}-(\\d+)-(\\d+)`));return c?`${l} ${c[1]}.${c[2]}`:l}const i=e??[],s=i.find(a=>a.id===t);if(s)return s.label;const o=i.find(a=>a.id&&t.toLowerCase().includes(a.id.toLowerCase()));return o?o.label:t}function uZ(e){return e==="TodoWrite"}function dZ(e){if(!e||typeof e!="object")return null;const t=e;if(!Array.isArray(t.todos))return null;const n=[];for(const r of t.todos){if(!r||typeof r!="object")continue;const i=r,s=typeof i.content=="string"?i.content:"";if(!s)continue;const o=i.status==="in_progress"||i.status==="completed"?i.status:"pending",a=typeof i.activeForm=="string"?i.activeForm:void 0;n.push({content:s,status:o,activeForm:a})}return n}function hZ(e,t,n){var s;const r=[],i=new Map;for(let o=0;o<e.length;o++){const a=e[o],l=typeof a.seq=="number"?a.seq:o;switch(a.kind){case"session_init":r.push({kind:"session-init",seq:l,toolSessionId:a.toolSessionId});break;case"text":$S(r,l,"assistant-text",a.text,a.partialId,a.uuid);break;case"thinking":$S(r,l,"assistant-thinking",a.text,a.partialId);break;case"user_text":{a.meta==="task-notification"?r.push({kind:"agent-notification",seq:l,text:a.text,taskId:a.taskId,parentToolUseId:a.parentToolUseId}):a.meta?r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text}):r.push({kind:"user-text",seq:l,text:a.text,uuid:a.uuid,senderDisplayName:(s=a.sender)==null?void 0:s.displayName});break}case"tool_call":HR(r,l,a.toolUseId,a.tool,a.input,a.toolKind);break;case"tool_result":{const c=i.get(a.toolUseId);if(c!==void 0){if(a.askQuestionAnswers){const d=r[c];d.submittedAnswers=a.askQuestionAnswers}i.delete(a.toolUseId);break}const u={kind:"tool-result",seq:l,toolUseId:a.toolUseId,output:a.output,error:a.error};a.toolResultExtra&&(u.toolResultExtra=a.toolResultExtra),r.push(u);break}case"attachment_memories":r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"permission_request":{if(!t||a.requestId!==t)break;r.push({kind:"permission-inline",seq:l,requestId:a.requestId,tool:a.tool,input:a.input});break}case"ask_user_question":i.set(a.toolUseId,r.length),r.push({kind:"question-card",seq:l,toolUseId:a.toolUseId,questions:a.questions});break;case"turn_end":r.push({kind:"turn-end",seq:l});break;case"subagent_progress":{const c={kind:"agent-progress",seq:l,toolUseId:a.toolUseId,agentId:a.agentId,status:a.status};a.description&&(c.description=a.description),a.lastToolName&&(c.lastToolName=a.lastToolName),a.prompt&&(c.prompt=a.prompt),a.stats&&(c.stats=a.stats),r.push(c);break}case"error":r.push({kind:"error",seq:l,message:a.message});break}}return r}function HR(e,t,n,r,i,s){if(uZ(r)){const o=dZ(i);if(o){e.push({kind:"todo-checklist",seq:t,toolUseId:n,todos:o});return}}if(r==="Agent"){const o=i??{},a=typeof o.description=="string"&&o.description?o.description:typeof o.subagent_type=="string"&&o.subagent_type?o.subagent_type:"Subagent";e.push({kind:"agent-call",seq:t,toolUseId:n,description:a,input:i});return}if(C7(r)){e.push({kind:"task-event",seq:t,toolUseId:n,name:r,input:i});return}e.push({kind:"tool-call",seq:t,toolUseId:n,tool:r,toolKind:s,input:i})}function $S(e,t,n,r,i,s){let o=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind===n){o=c;break}const a=o>=0?e[o]:null;if(i){if(a&&a.partialId===i){const u=n==="assistant-text"?{kind:n,seq:a.seq,text:a.text+r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:a.text+r,partialId:i};e[o]=u;return}const c=n==="assistant-text"?{kind:n,seq:t,text:r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r,partialId:i};e.push(c);return}if(a&&a.partialId){const c=n==="assistant-text"?{kind:n,seq:a.seq,text:r,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:r};e[o]=c;return}const l=n==="assistant-text"?{kind:n,seq:t,text:r,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r};e.push(l)}const fZ="AskUserQuestion";function UR(e,t=0,n){const r=[],i=new Map;let s=t;for(const o of e){const a=s++,l=o.toolUseId??`hist-${a}`;switch(o.kind){case"user-text":o.meta==="task-notification"?r.push({kind:"agent-notification",seq:a,text:o.text??"",taskId:o.taskId,parentToolUseId:o.parentToolUseId}):o.meta?r.push({kind:"user-meta",seq:a,metaKind:o.meta,text:o.text??""}):r.push({kind:"user-text",seq:a,text:o.text??"",uuid:o.uuid});break;case"assistant-text":r.push({kind:"assistant-text",seq:a,text:o.text??"",uuid:o.uuid});break;case"tool_call":{if(o.tool===fZ){const c=o.input??{},u=Array.isArray(c.questions)?c.questions:[];i.set(l,r.length),r.push({kind:"question-card",seq:a,toolUseId:l,questions:u});break}HR(r,a,l,o.tool??"",o.input,n);break}case"tool_result":{const c=i.get(l);if(c!==void 0){if(o.askQuestionAnswers){const d=r[c];d.submittedAnswers=o.askQuestionAnswers}i.delete(l);break}const u={kind:"tool-result",seq:a,toolUseId:l,output:o.output};o.error!==void 0&&(u.error=o.error),o.toolResultExtra&&(u.toolResultExtra=o.toolResultExtra),r.push(u);break}case"attachment_memories":o.memories&&o.memories.length>0&&r.push({kind:"memory-callout",seq:a,memories:o.memories});break}}return r}function pZ({api:e,cwd:t,toolSessionId:n}){const r=LR(),i=(r==null?void 0:r.state.agentId)??null,s=r==null?void 0:r.state.agentType,[o,a]=g.useState([]),[l,c]=g.useState(!1),[u,d]=g.useState(null);g.useEffect(()=>{if(!i)return;let p=!1;return c(!0),d(null),a([]),e.historySubagentRead({cwd:t,toolSessionId:n,subagentId:i}).then(m=>{p||a(m.messages??[])}).catch(m=>{p||d(m instanceof Error?m.message:String(m))}).finally(()=>{p||c(!1)}),()=>{p=!0}},[i,t,n,e]);const f=g.useMemo(()=>o.length>0?UR(o,0,"claude"):[],[o]);return!r||!i?null:h.jsxs("div",{"data-testid":"subagent-drawer","data-agent-id":i,className:ne("fixed inset-y-0 right-0 z-50 w-[min(560px,92vw)]","flex flex-col border-l border-bg-200/60 bg-bg-50 shadow-xl"),style:{paddingTop:"env(safe-area-inset-top)"},children:[h.jsxs("div",{className:"flex flex-col gap-0.5 px-3 py-2 border-b border-bg-200/60",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s?h.jsx("span",{className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-[11px] text-violet-400 font-medium",children:s}):null,h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate",title:i,children:i})]}),h.jsx("button",{type:"button","aria-label":"关闭",onClick:()=>r.close(),className:"p-1 rounded hover:bg-bg-200/50 text-text-400 hover:text-text-200",children:h.jsx(Rn,{className:"w-4 h-4"})})]}),!l&&!u&&o.length>0?h.jsxs("div",{className:"text-[11px] text-text-400",children:[o.length," 条消息 · 首条为主会话派发的任务指令"]}):null]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden px-3 py-2",children:l?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(rr,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"加载中…"})]}):u?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-error",children:[h.jsx(Rs,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:u})]}):f.length===0?h.jsx("div",{className:"text-[12px] text-text-400 italic",children:"无消息"}):h.jsx(BR,{lines:f})})]})}function FS(e,t){let n=0;for(const r of e.lines)r.startsWith(t)&&n++;return n}function mZ(e,t){const n=e.findIndex(c=>c.kind==="user-text"&&c.uuid===t);if(n<0)return{userMessageId:t,files:[],totalInsertions:0,totalDeletions:0,anchorFound:!1};let r=e.length;for(let c=n+1;c<e.length;c++)if(e[c].kind==="user-text"){r=c;break}const i=[],s=new Map;for(let c=n+1;c<r;c++){const u=e[c];if(u.kind!=="tool-result")continue;const d=u.toolResultExtra;if(!(d!=null&&d.filePath)||!d.structuredPatch||d.structuredPatch.length===0)continue;const f=d.filePath;let p=s.get(f);p||(p={filePath:f,hunks:[],insertions:0,deletions:0},s.set(f,p),i.push(f));for(const m of d.structuredPatch)p.hunks.push(m),p.insertions+=FS(m,"+"),p.deletions+=FS(m,"-")}const o=i.map(c=>s.get(c)),a=o.reduce((c,u)=>c+u.insertions,0),l=o.reduce((c,u)=>c+u.deletions,0);return{userMessageId:t,files:o,totalInsertions:a,totalDeletions:l,anchorFound:!0}}function gZ({open:e,onOpenChange:t,api:n,sessionId:r,userMessageId:i,lines:s,procAlive:o,onApplied:a,onNoChanges:l}){const c=g.useMemo(()=>mZ(s,i),[s,i]),[u,d]=g.useState(null),[f,p]=g.useState(!1),[m,v]=g.useState(!1),[y,_]=g.useState(null);g.useEffect(()=>{if(!e)return;let k=!1;return p(!0),d(null),(async()=>{try{const T=await n.sessionRewindDiff({sessionId:r,userMessageId:i});k||(d(T),!T.canRewind&&!T.error&&T.files.length===0&&(l==null||l(i)))}catch{k||d(null)}finally{k||p(!1)}})(),()=>{k=!0}},[e,n,r,i]);const x=g.useMemo(()=>{if(u){const k=!u.canRewind&&!u.error&&u.files.length===0;if(u.canRewind||k)return{source:"rpc",anchorFound:!0,files:u.files.map(T=>({filePath:T.filePath,hunks:T.hunks,insertions:T.insertions,deletions:T.deletions})),totalInsertions:u.totalInsertions,totalDeletions:u.totalDeletions}}return{source:"local",anchorFound:c.anchorFound,files:c.files,totalInsertions:c.totalInsertions,totalDeletions:c.totalDeletions,rpcError:u==null?void 0:u.error}},[u,c]),b=g.useCallback(async()=>{v(!0),_(null);try{const k=await n.sessionRewind({sessionId:r,userMessageId:i,dryRun:!1});if(!k.canRewind){_(k.error??"回退失败");return}a==null||a(),t(!1)}catch(k){_(k.message||"回退失败")}finally{v(!1)}},[n,r,i,a,t]);if(!e)return null;const w=x.files.length>0,S=!f&&!m&&x.anchorFound&&w&&!y;return h.jsxs("div",{"data-testid":"rewind-preview-drawer",className:"fixed right-0 top-0 bottom-0 z-40 flex flex-col border-l border-bg-300/40 bg-bg-0 shadow-xl",style:{width:480,minWidth:480},children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bg-300/30 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(WN,{className:"w-4 h-4 text-text-300"}),h.jsx("span",{className:"text-[14px] font-semibold text-text-100",children:"Rewind 预览"})]}),h.jsx("button",{type:"button",onClick:()=>t(!1),"data-testid":"rewind-drawer-close",className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:bg-text-100/5 hover:text-text-200 cursor-pointer","aria-label":"close",children:h.jsx(Rn,{className:"w-4 h-4"})})]}),y?h.jsxs("div",{"data-testid":"rewind-error-banner",className:"mx-4 mt-3 flex items-start gap-2 rounded-md border border-red-400/40 bg-red-500/10 px-3 py-2 text-[12px] text-red-400",children:[h.jsx(Ac,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{children:y})]}):null,h.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3",children:f?h.jsxs("div",{"data-testid":"rewind-loading",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(rr,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"正在读取快照…"})]}):x.anchorFound?w?h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":"rewind-summary",className:"rounded-md border border-bg-300 bg-bg-100/40 px-3 py-2 text-[12px] text-text-200",children:[h.jsxs("div",{children:["将回退 ",h.jsx("span",{className:"font-semibold text-text-100",children:x.files.length})," ","个文件,",h.jsxs("span",{className:"text-green-500 font-mono",children:["+",x.totalInsertions]})," / ",h.jsxs("span",{className:"text-red-400 font-mono",children:["-",x.totalDeletions]})]}),x.source==="local"?h.jsx("div",{"data-testid":"rewind-source-hint",className:"mt-1 text-text-400 text-[11px]",children:"基于对话里 tool_result 估算(未读到 CC 快照,数字可能与实际磁盘略有差异)"}):null]}),x.files.map(k=>h.jsx(_Z,{file:k},k.filePath))]}):h.jsxs("div",{"data-testid":"rewind-no-changes",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300 space-y-1",children:[h.jsx("div",{children:"磁盘上的文件已经和这个时刻的快照完全一致——没有需要回退的改动。"}),h.jsx("div",{className:"text-text-400 text-[11px]",children:"可能这条消息之后 Claude 没落盘编辑,或之前已经 rewind 过了。"})]}):h.jsx("div",{"data-testid":"rewind-no-anchor",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:"未能在当前消息流中找到对应的用户消息(可能已被历史裁剪)。"})}),h.jsxs("div",{className:"flex flex-col gap-2 px-4 py-3 border-t border-bg-300/30 shrink-0",children:[w&&x.anchorFound&&!o?h.jsxs("div",{"data-testid":"rewind-needs-cc",className:"flex items-start gap-2 rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:[h.jsx(Ac,{className:"w-4 h-4 shrink-0 mt-0.5 text-warning"}),h.jsx("span",{children:'Claude Code 进程当前未运行。点击"确认回退"时会自动启动它再执行 — 可能需要等一两秒。'})]}):null,h.jsxs("div",{className:"flex items-center justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:()=>t(!1),className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button",disabled:!S,onClick:()=>void b(),"data-testid":"rewind-apply",className:ne("h-8 px-3 rounded-md text-[12px] font-medium transition-colors",S?"bg-accent text-white hover:bg-accent-hover cursor-pointer":"bg-bg-200 text-text-400 cursor-not-allowed"),children:m?"回退中…":"确认回退"})]})]})]})}function vZ(e){return e.replace(/^\/Users\/[^/]+/,"~")}function _Z({file:e}){const[t,n]=g.useState(!0);return h.jsxs("div",{"data-testid":"rewind-file-block","data-file":e.filePath,className:"rounded-md border border-bg-300 overflow-hidden bg-bg-0",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"w-full flex items-center gap-1.5 px-3 py-2 text-[12px] hover:bg-text-100/5 cursor-pointer",children:[t?h.jsx(li,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(ci,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-200 truncate flex-1 text-left",title:e.filePath,children:vZ(e.filePath)}),h.jsxs("span",{className:"font-mono shrink-0 text-text-400",children:[h.jsxs("span",{className:"text-green-500",children:["+",e.insertions]})," ",h.jsxs("span",{className:"text-red-400",children:["-",e.deletions]})]})]}),t?h.jsx("div",{className:"border-t border-bg-300",children:e.hunks.map(r=>h.jsx(xZ,{hunk:r},`${r.oldStart}-${r.oldLines}-${r.newStart}-${r.newLines}`))}):null]})}function xZ({hunk:e}){const t=`@@ -${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines} @@`;return h.jsxs("div",{className:"text-[11px] font-mono leading-relaxed",children:[h.jsx("div",{className:"px-3 py-1 text-text-400 bg-bg-100/40 border-b border-bg-300",children:t}),e.lines.map((n,r)=>{const i=n.charAt(0),s=i==="+"?"bg-green-500/10 text-green-300":i==="-"?"bg-red-500/10 text-red-300":"text-text-300";return h.jsx("div",{className:ne("px-3 whitespace-pre",s),children:n.length>0?n:" "},r)})]})}var rp="Dialog",[WR]=Eo(rp),[yZ,Or]=WR(rp),VR=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!0}=e,a=g.useRef(null),l=g.useRef(null),[c,u]=Df({prop:r,defaultProp:i??!1,onChange:s,caller:rp});return h.jsx(yZ,{scope:t,triggerRef:a,contentRef:l,contentId:to(),titleId:to(),descriptionId:to(),open:c,onOpenChange:u,onOpenToggle:g.useCallback(()=>u(d=>!d),[u]),modal:o,children:n})};VR.displayName=rp;var qR="DialogTrigger",bZ=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(qR,n),s=qt(t,i.triggerRef);return h.jsx(Et.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":ey(i.open),...r,ref:s,onClick:Pe(e.onClick,i.onOpenToggle)})});bZ.displayName=qR;var Qx="DialogPortal",[wZ,KR]=WR(Qx,{forceMount:void 0}),GR=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,s=Or(Qx,t);return h.jsx(wZ,{scope:t,forceMount:n,children:g.Children.map(r,o=>h.jsx(zi,{present:n||s.open,children:h.jsx(lx,{asChild:!0,container:i,children:o})}))})};GR.displayName=Qx;var qh="DialogOverlay",XR=g.forwardRef((e,t)=>{const n=KR(qh,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Or(qh,e.__scopeDialog);return s.modal?h.jsx(zi,{present:r||s.open,children:h.jsx(kZ,{...i,ref:t})}):null});XR.displayName=qh;var SZ=jc("DialogOverlay.RemoveScroll"),kZ=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(qh,n);return h.jsx(cx,{as:SZ,allowPinchZoom:!0,shards:[i.contentRef],children:h.jsx(Et.div,{"data-state":ey(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),_o="DialogContent",YR=g.forwardRef((e,t)=>{const n=KR(_o,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Or(_o,e.__scopeDialog);return h.jsx(zi,{present:r||s.open,children:s.modal?h.jsx(CZ,{...i,ref:t}):h.jsx(EZ,{...i,ref:t})})});YR.displayName=_o;var CZ=g.forwardRef((e,t)=>{const n=Or(_o,e.__scopeDialog),r=g.useRef(null),i=qt(t,n.contentRef,r);return g.useEffect(()=>{const s=r.current;if(s)return XT(s)},[]),h.jsx(ZR,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Pe(e.onCloseAutoFocus,s=>{var o;s.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Pe(e.onPointerDownOutside,s=>{const o=s.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&s.preventDefault()}),onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault())})}),EZ=g.forwardRef((e,t)=>{const n=Or(_o,e.__scopeDialog),r=g.useRef(!1),i=g.useRef(!1);return h.jsx(ZR,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),ZR=g.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...o}=e,a=Or(_o,n),l=g.useRef(null),c=qt(t,l);return mT(),h.jsxs(h.Fragment,{children:[h.jsx(J_,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:h.jsx(Lf,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":ey(a.open),...o,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),h.jsxs(h.Fragment,{children:[h.jsx(NZ,{titleId:a.titleId}),h.jsx(PZ,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Jx="DialogTitle",QR=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(Jx,n);return h.jsx(Et.h2,{id:i.titleId,...r,ref:t})});QR.displayName=Jx;var JR="DialogDescription",eM=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(JR,n);return h.jsx(Et.p,{id:i.descriptionId,...r,ref:t})});eM.displayName=JR;var tM="DialogClose",nM=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Or(tM,n);return h.jsx(Et.button,{type:"button",...r,ref:t,onClick:Pe(e.onClick,()=>i.onOpenChange(!1))})});nM.displayName=tM;function ey(e){return e?"open":"closed"}var rM="DialogTitleWarning",[Lne,iM]=Qz(rM,{contentName:_o,titleName:Jx,docsSlug:"dialog"}),NZ=({titleId:e})=>{const t=iM(rM),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
517
517
 
518
518
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
519
519
 
@@ -554,4 +554,4 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
554
554
  * Fabrice Bellard's javascript vt100 for jslinux:
555
555
  * http://bellard.org/jslinux/
556
556
  * Copyright (c) 2011 Fabrice Bellard
557
- */var qee=2,Kee=1,Gee=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var d;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((d=this._terminal.options.overviewRuler)==null?void 0:d.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),i=Math.max(0,parseInt(n.getPropertyValue("width"))),s=window.getComputedStyle(this._terminal.element),o={top:parseInt(s.getPropertyValue("padding-top")),bottom:parseInt(s.getPropertyValue("padding-bottom")),right:parseInt(s.getPropertyValue("padding-right")),left:parseInt(s.getPropertyValue("padding-left"))},a=o.top+o.bottom,l=o.right+o.left,c=r-a,u=i-l-t;return{cols:Math.max(qee,Math.floor(u/e.css.cell.width)),rows:Math.max(Kee,Math.floor(c/e.css.cell.height))}}};let Lm;function Om(){return{count:0,byteSum:0,firstT:null,lastT:null}}const Bm=32,Lk=320;function Xee({sessionId:e,client:t}){const n=g.useRef(null),r=g.useRef(null),i=g.useRef(null),s=g.useRef([]),o=g.useRef(Om()),a=g.useRef(!1),[l,c]=g.useState("collapsed"),[u,d]=g.useState(null);g.useEffect(()=>{const v=n.current;if(!v)return;let y=!1;const _=(T,N)=>getComputedStyle(document.documentElement).getPropertyValue(T).trim()||N,x=_("--bg-0","#1B1B1B"),b=_("--text-100","#ECECEC"),w=new Vee({fontFamily:"ui-monospace, SF Mono, Menlo, monospace",fontSize:12,lineHeight:1.2,theme:{background:x,foreground:b},minimumContrastRatio:4.5,cursorBlink:!0,convertEol:!1,scrollback:5e3,allowProposedApi:!0,cols:120,rows:40}),S=new Gee;w.loadAddon(S),Ae("xterm-mount",{sessionId:e,hostChildCount:v.childNodes.length}),Lm!==e&&(Ae("xterm-trace",`===== SWITCH ${Lm??"(initial)"} → ${e} =====`),Lm=e),Ae("xterm-trace","effect-setup-start",{sessionId:e,t:performance.now()}),o.current=Om(),w.open(v);const k=w.onData(T=>{const N=btoa(unescape(encodeURIComponent(T)));t.request("session:pty:input",{sessionId:e,data:N}).catch(()=>{})});return(async()=>{var R;let T=0,N=null,L=null;try{Ae("xterm-trace","snapshot-rpc-start",{sessionId:e,t:performance.now()});const j=await t.request("session:pty:snapshot",{sessionId:e});if(Ae("xterm-trace","snapshot-rpc-resolved",{sessionId:e,cancelled:y,byteLen:((R=j==null?void 0:j.data)==null?void 0:R.length)??0,atSeq:j==null?void 0:j.atSeq,t:performance.now()}),y)return;if(j!=null&&j.ok&&typeof j.data=="string"&&j.data.length>0){const z=atob(j.data),$=new Uint8Array(z.length);for(let F=0;F<z.length;F++)$[F]=z.charCodeAt(F);N=$}j!=null&&j.ok&&typeof j.atSeq=="number"&&(T=j.atSeq),j!=null&&j.ok&&j.popupKind!=null&&(L=j.popupKind)}catch{}if(y)return;r.current=w,i.current=S;let P=!1,O;const I=w.onRender(()=>{if(!P){P=!0;try{S.fit(),N&&w.write(N),Ae("xterm-trace","snapshot-flush",{sessionId:e,atSeq:T,pendingFrameCount:s.current.length,frameStatsBeforeFlush:{...o.current},t:performance.now()}),o.current=Om();const j=s.current;s.current=[];let z=0;for(const $ of j){if($.seq!==void 0&&$.seq<=T){z++;continue}w.write($.bytes)}z>0&&Ae("xterm-trace","snapshot-flush-dropped",{sessionId:e,dropped:z,atSeq:T}),a.current=!0,L!=null&&(d(L),c("expanded"),requestAnimationFrame(()=>w.focus())),t.request("session:pty:resize",{sessionId:e,cols:w.cols,rows:w.rows}).catch(()=>{})}catch{}w.scrollToBottom(),O?O():setTimeout(()=>O==null?void 0:O(),0)}});O=()=>I.dispose()})(),()=>{Ae("xterm-trace","cleanup-start",{sessionId:e,pendingFrameCount:s.current.length,termReady:a.current,frameStatsThisMount:{...o.current},t:performance.now()}),y=!0,k.dispose(),w.dispose(),r.current=null,i.current=null,a.current=!1,s.current=[],Ae("xterm-trace","cleanup-cleared-pending",{sessionId:e,t:performance.now()})}},[e,t]),g.useEffect(()=>{const v=t.on("session:pty",_=>{const x=_;if(x.sessionId!==e||typeof x.data!="string")return;const b=o.current;b.count++,b.byteSum+=x.data.length;const w=performance.now();b.firstT===null&&(b.firstT=w),b.lastT=w;try{const S=atob(x.data),k=new Uint8Array(S.length);for(let T=0;T<S.length;T++)k[T]=S.charCodeAt(T);a.current&&r.current?r.current.write(k):s.current.push({seq:x.seq,bytes:k})}catch{}}),y=t.on("session:control",_=>{const x=_;if(x.sessionId===e)switch(x.kind){case"popup_open":(x.popupKind==="permission"||x.popupKind==="question")&&(d(x.popupKind),c("expanded"),requestAnimationFrame(()=>{var b;return(b=r.current)==null?void 0:b.focus()}));break;case"popup_close":d(null),c("collapsed");break}});return()=>{v(),y(),Ae("xterm-trace","cleanup-off-listener",{sessionId:e,t:performance.now()})}},[e,t]),g.useEffect(()=>{const v=n.current;if(!v)return;let y=0,_=0;const x=()=>{const w=i.current,S=r.current;if(!(!w||!S)){try{w.fit()}catch{return}try{S.refresh(0,S.rows-1)}catch{}S.cols===y&&S.rows===_||(y=S.cols,_=S.rows,t.request("session:pty:resize",{sessionId:e,cols:S.cols,rows:S.rows}).catch(()=>{}))}},b=new ResizeObserver(()=>x());return b.observe(v),()=>b.disconnect()},[e,t]);const f=()=>{c(v=>{const y=v==="collapsed"?"expanded":"collapsed";return y==="expanded"&&requestAnimationFrame(()=>{var _;return(_=r.current)==null?void 0:_.focus()}),y})},p=l==="expanded"?Lk:Bm,m=Lk-Bm;return h.jsxs("div",{className:"border-t border-border bg-bg-0 overflow-hidden",style:{height:p},"data-testid":"xterm-panel","data-state":l,"data-mode":"tui","data-popup-kind":u??"",children:[h.jsxs("button",{type:"button",onClick:f,className:"flex items-center justify-between w-full px-3 py-1 text-xs text-text-200 bg-bg-200 hover:bg-bg-300 cursor-pointer border-b border-border",style:{height:Bm,flexShrink:0},"data-testid":"xterm-panel-toggle",children:[h.jsxs("span",{className:"font-mono",children:[u==="permission"&&"⚠️ CC 需要权限确认 — 在下方终端按数字键 / Enter 选择",u==="question"&&"❓ CC 在问问题 — 在下方终端用 ↑/↓ + Enter 选择",u===null&&(l==="collapsed"?"▴ 展开原生 TUI 终端":"▾ 收起 TUI 终端")]}),h.jsx("span",{className:"text-text-200 text-[10px] opacity-60",children:l==="expanded"?"点击收起":"点击展开"})]}),h.jsx("div",{ref:n,className:"p-1",style:{height:m},"data-testid":"xterm-panel-host"})]})}function rA(e,t){const n=ko(),r=e?`session/${e}`:"",i=si(r)??Rc,s=g.useCallback(d=>{!e||!r||n.setData(r,f=>TN(f??Rc,d,e))},[n,r,e]),o=g.useCallback(()=>{e&&s({type:"session:change",sessionId:e})},[s,e]),a=g.useCallback(d=>{e&&s({type:"permission:clear",sessionId:e,requestId:d})},[s,e]),l=g.useCallback(d=>{e&&s({type:"permission:request",sessionId:e,requestId:d.requestId,tool:d.tool,input:d.input,...d.toolUseId?{toolUseId:d.toolUseId}:{}})},[s,e]),c=g.useCallback(d=>{e&&s({type:"session:question:clear",sessionId:e,toolUseId:d})},[s,e]),u=g.useCallback((d,f)=>{e&&s({type:"session:question:submitted",sessionId:e,toolUseId:d,answers:f})},[s,e]);return{...i,reset:o,clearPermission:a,restorePermission:l,clearQuestion:c,markQuestionSubmitted:u}}function my(e){const t=si(e?`capabilities/${e}`:"");return e?{capabilities:t??null,loading:!t}:{capabilities:null,loading:!1}}const Yee=50;function Zee({api:e,sessionId:t,toolSessionId:n,pageSize:r=Yee}){const[i,s]=g.useState({messages:[],total:0,loading:!1,hasMore:!1,error:null}),o=g.useRef(0),a=g.useRef(n),l=g.useRef(null),c=g.useRef(0);g.useEffect(()=>{const d=a.current;if(a.current=n,!(l.current!==t)&&!(typeof d=="string"&&d!==n))return;if(s({messages:[],total:0,loading:!1,hasMore:!1,error:null}),o.current=0,!t){l.current=null;return}l.current=t;const m=++c.current;s(v=>({...v,loading:!0,error:null})),(async()=>{try{const v=await e.historyRead({sessionId:t,limit:r});if(m!==c.current)return;o.current=v.offset,s({messages:v.messages??[],total:v.total??0,loading:!1,hasMore:v.offset>0,error:null})}catch(v){if(m!==c.current)return;s({messages:[],total:0,loading:!1,hasMore:!1,error:v.message??"history load failed"})}})()},[e,t,n,r]);const u=g.useCallback(async()=>{if(!t)return;const d=o.current;if(d<=0)return;const f=Math.max(0,d-r),p=d-f;s(m=>({...m,loading:!0,error:null}));try{const m=await e.historyRead({sessionId:t,limit:p,offset:f});o.current=m.offset,s(v=>({...v,messages:[...m.messages??[],...v.messages],loading:!1,hasMore:m.offset>0}))}catch(m){s(v=>({...v,loading:!1,error:m.message??"load more failed"}))}},[e,t,r]);return{...i,loadMore:u}}function Ok(e){const t=np(e);return t.commandName?t.commandArgs?`${t.commandName} ${t.commandArgs}`:t.commandName:e}function Bk(e){return e.kind==="user-text"||e.kind==="user-meta"&&e.metaKind==="slash-command"}function Qee(e,t){const n=t.find(Bk);if(!n)return e;const r=Ok(n.text);for(let i=e.length-1;i>=0;i--){const s=e[i];if(Bk(s)&&Ok(s.text)===r)return e.slice(0,i)}return e}const Jee=1e6;function ete(e){if(!e)return;const t=e.contextUsage,n=e.contextWindowSize;if(!t||!n||n<=0)return;const r=t.inputTokens+(t.cacheReadTokens??0)+(t.cacheCreateTokens??0);if(!(r<=0))return Math.round(r/n*100)}function iA(e){const t=Is(),n=g.useMemo(()=>new V_(t),[t]),r=si("sessions"),i=g.useMemo(()=>r==null?void 0:r.find(F=>F.sessionId===e),[r,e]),s=i==null?void 0:i.toolSessionId,o=i==null?void 0:i.tool,a=rA(e),{events:l,pendingPermissions:c,status:u,clearPermission:d,restorePermission:f}=a,p=Zee({api:n,sessionId:e,toolSessionId:s}),m=g.useMemo(()=>p.messages.filter(F=>!F.isSidechain),[p.messages]),v=g.useMemo(()=>UR(m,0,o),[m,o]),y=c[0]??null,_=g.useMemo(()=>hZ(l,(y==null?void 0:y.requestId)??null),[l,y==null?void 0:y.requestId]),x=g.useMemo(()=>Qee(v,_),[v,_]),b=g.useMemo(()=>_.map((F,A)=>({...F,seq:Jee+A})),[_]),w=g.useMemo(()=>[...x,...b],[x,b]),S=hM(u),k=LZ(u),T=(i==null?void 0:i.resolvedModel)??(i==null?void 0:i.model),N=g.useMemo(()=>({sessionLabel:(i==null?void 0:i.label)??e,sessionId:e,...T?{model:T}:{},...(()=>{const F=i==null?void 0:i.gitBranch;return F?{gitBranch:F}:{}})(),...(()=>{const F=ete(i);return F!==void 0?{contextPct:F}:{}})(),...i!=null&&i.cwd?{cwd:i.cwd}:{},...(()=>{const F=i==null?void 0:i.permissionMode;return F?{permissionMode:F}:{}})(),procAlive:S,streamInProgress:k,pinnedAt:(i==null?void 0:i.pinnedAt)??null}),[i,e,T,S,k]),L=g.useMemo(()=>t.isOpen?u==="error"?{kind:"error",message:"session error"}:{kind:"ready"}:{kind:"closed"},[t.isOpen,u]),P=g.useCallback(async F=>{await n.sessionSend(e,F)},[n,e]),O=g.useCallback(async F=>{if(!(i!=null&&i.cwd)||!s)throw new Error("fork requires sessionFile with cwd + toolSessionId");await n.sessionFork({cwd:i.cwd,toolSessionId:s,messageUuid:F})},[n,i==null?void 0:i.cwd,s]),I=g.useCallback(async F=>{await n.sessionRewind({sessionId:e,userMessageId:F,dryRun:!1})},[n,e]),R=g.useCallback(async F=>{await n.sessionUpdate(e,{model:F})},[n,e]),j=g.useCallback(async()=>{await n.sessionNew(e)},[n,e]),z=g.useCallback(async(F,A)=>{const B=c.find(E=>E.requestId===F);B&&d(F);try{await n.permissionRespond({sessionId:e,permissionRequestId:F,allow:A==="allow"})}catch(E){throw!((E==null?void 0:E.message)??"").startsWith("PERMISSION_REQUEST_STALE")&&B&&f(B),E}},[n,e,c,d,f]),$=g.useCallback(async()=>{await p.loadMore()},[p]);return g.useMemo(()=>({lines:w,connState:L,meta:N,historyDone:!p.hasMore,historyLoading:p.loading,pendingPermissions:c,sendText:P,fork:O,rewind:I,switchModel:R,clearSession:j,respondPermission:z,loadMoreHistory:$}),[w,L,N,p.hasMore,p.loading,c,P,O,I,R,j,z,$])}function tte({api:e,open:t,onOpenChange:n,scope:r,sessionId:i,onShareFile:s,onOpenInTab:o}){const[a,l]=g.useState([]),[c,u]=g.useState(null);g.useEffect(()=>{if(!t)return;let f=!1;return(async()=>{try{const p=await e.attachmentGroupList(i);if(f)return;l(p.entries)}catch(p){f||u(p.message)}})(),()=>{f=!0}},[e,i,t]);async function d(f){try{await e.attachmentGroupRemove(i,f.relPath),l(p=>f.from==="owner"?p.filter(m=>m.relPath!==f.relPath):p.map(m=>m.relPath===f.relPath?{...m,stale:!0}:m))}catch(p){u(p.message)}}return t?h.jsx(xx,{delayDuration:120,children:h.jsxs("div",{"data-testid":"files-drawer",className:"fixed inset-y-0 right-0 z-50 flex w-[420px] flex-col border-l border-border bg-elevated shadow-2xl",children:[h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[13px] font-semibold text-text-100",children:[h.jsx(a6,{className:"h-4 w-4"}),"Edited Files"]}),h.jsx("button",{type:"button",onClick:()=>n(!1),className:"flex h-7 w-7 items-center justify-center rounded text-text-400 hover:bg-bg-200 hover:text-text-100","aria-label":"Close drawer",children:h.jsx(Rn,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto",children:[h.jsx(nte,{title:`Session files (${a.length})`,subtitle:"agent Write/Edit 自动入清单",children:a.length===0?h.jsx(ite,{text:"还没有文件。agent Write/Edit 会自动加入清单。"}):a.map(f=>h.jsx(rte,{entry:f,onShareLink:()=>s(f.relPath),...o?{onOpenInTab:()=>o(f.relPath)}:{},onRemove:()=>d(f)},f.id))}),c?h.jsx("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-[11px] text-destructive",children:c}):null]})]})}):null}function nte({title:e,subtitle:t,children:n}){return h.jsxs("div",{className:"border-b border-border last:border-b-0",children:[h.jsx("div",{className:"sticky top-0 z-10 flex items-start justify-between bg-elevated px-4 py-2",children:h.jsxs("div",{className:"flex-1",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-text-300",children:e}),t?h.jsx("div",{className:"mt-0.5 text-[11px] text-text-400",children:t}):null]})}),h.jsx("div",{className:"flex flex-col",children:n})]})}function rte({entry:e,onShareLink:t,onOpenInTab:n,onRemove:r}){var l;const i=(l=e.mime)!=null&&l.startsWith("image/")?p6:Ms,s=e.relPath.lastIndexOf("/"),o=s>=0?e.relPath.slice(0,s+1):"",a=s>=0?e.relPath.slice(s+1):e.relPath;return h.jsxs("div",{"data-testid":"files-drawer-group-row",className:ne("group flex items-center gap-2 px-4 py-2 hover:bg-bg-200",e.stale&&"opacity-50"),children:[h.jsx(i,{className:"h-4 w-4 shrink-0 text-text-400"}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsxs(yx,{children:[h.jsx(bx,{asChild:!0,children:h.jsxs("span",{className:"flex min-w-0 items-baseline text-[13px] text-text-100",children:[o?h.jsx("span",{className:"truncate text-text-400",children:o}):null,h.jsx("span",{className:"shrink-0",children:a})]})}),h.jsx(Xf,{side:"top",align:"start",className:"max-w-[380px] break-all",children:e.relPath})]}),e.stale&&h.jsx("span",{className:"rounded bg-text-100/10 px-1 py-0 text-[10px] uppercase text-text-400",children:"stale"})]}),h.jsxs("div",{className:"flex items-center gap-1.5 truncate text-[11px] text-text-400",children:[h.jsx("span",{children:e.from}),h.jsx("span",{children:"·"}),h.jsx("span",{children:ste(e.addedAt)})]})]}),!e.stale&&h.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[n?h.jsx(zm,{icon:h.jsx(Mc,{className:"h-3.5 w-3.5"}),title:"Open in tab",onClick:n}):null,h.jsx(zm,{icon:h.jsx(G_,{className:"h-3.5 w-3.5"}),title:"Share link",onClick:t}),e.from==="owner"&&h.jsx(zm,{icon:h.jsx(X_,{className:"h-3.5 w-3.5"}),title:"Remove",onClick:r})]})]})}function zm({icon:e,title:t,onClick:n}){return h.jsx("button",{type:"button",onClick:n,title:t,"aria-label":t,className:"flex h-7 w-7 items-center justify-center rounded text-text-400 hover:bg-text-100/10 hover:text-text-100",children:e})}function ite({text:e}){return h.jsx("div",{className:"px-4 py-3 text-[12px] italic text-text-400",children:e})}function ste(e){const t=Date.now()-e;return t<6e4?`${Math.max(1,Math.floor(t/1e3))}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function ote({persona:e,open:t,onClose:n,onTogglePublic:r,guestShareUrl:i,onChangeIcon:s,onDelete:o,embedded:a,onLoadPersonality:l,onSavePersonality:c,onDirtyChange:u,initialPersonality:d,onShareCapability:f,readOnly:p=!1,onChangeTool:m}){const[v,y]=g.useState(!1),[_,x]=g.useState(!1),b=()=>{i&&navigator.clipboard.writeText(i).then(()=>{x(!0),setTimeout(()=>x(!1),2e3)})},w=k=>{y(k),u==null||u(k)},S=()=>{v&&!window.confirm("修改未保存,确定关闭?")||n()};return t?h.jsxs(h.Fragment,{children:[!a&&h.jsx("div",{className:"absolute inset-0 z-30 bg-black/30",onClick:S,"aria-hidden":"true"}),h.jsxs("aside",{className:a?"flex h-full w-full flex-col bg-bg-0":"absolute right-0 top-0 z-40 flex h-full w-[420px] flex-col bg-bg-0 border-l border-border shadow-xl","data-testid":"persona-settings-drawer",children:[h.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx(H6,{className:"h-4 w-4 text-text-300"}),h.jsx("span",{className:"text-[13px] font-medium text-text-100 truncate",children:"Persona 设置"})]}),h.jsx("button",{type:"button",onClick:S,"aria-label":"关闭",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-text-100",children:h.jsx(Rn,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-6 flex flex-col gap-4",children:[h.jsxs("header",{className:"flex items-start justify-between gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h2",{className:"text-lg font-semibold text-text-100 truncate",children:e.label}),e.public?h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-bg-200 px-1.5 py-0.5 text-[10px] text-text-200",children:[h.jsx(h6,{className:"h-3 w-3"})," 公开"]}):h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-error-dim px-1.5 py-0.5 text-[10px] text-error",children:[h.jsx(u6,{className:"h-3 w-3"})," 已关闭"]})]}),h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate","data-testid":"persona-id-subtitle",children:e.personaId})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[f?h.jsxs("button",{type:"button",onClick:f,"aria-label":"分享给他人",title:"分享给他人",className:"inline-flex items-center gap-1 rounded-sm px-2 py-1.5 text-xs text-text-200 hover:bg-bg-200 hover:text-text-100",children:[h.jsx(G_,{className:"h-3.5 w-3.5"}),"分享"]}):null,o?h.jsx("button",{type:"button",onClick:o,"aria-label":"删除 persona",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-error",children:h.jsx(X_,{className:"h-4 w-4"})}):null]})]}),h.jsx("hr",{className:"border-border"}),r?h.jsxs(h.Fragment,{children:[h.jsxs("section",{className:"flex items-center justify-between gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"公开访问"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"开启后这个 persona 才会出现在「邀请联系人」的可选列表里。关闭即拒所有新分享(已颁出的 token 不受影响)。"})]}),h.jsx(ate,{checked:e.public??!1,onChange:k=>r(k)})]}),e.public?h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"guest-share-link",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(BN,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"访客分享链接"})]}),i?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{readOnly:!0,value:i,onFocus:k=>k.currentTarget.select(),className:"min-w-0 flex-1 truncate rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"guest-share-link-input"}),h.jsx("button",{type:"button",onClick:b,className:"flex shrink-0 items-center gap-1 rounded border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200","data-testid":"guest-share-link-copy",children:_?h.jsxs(h.Fragment,{children:[h.jsx(Za,{className:"h-3 w-3"})," 已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(su,{className:"h-3 w-3"})," 复制"]})})]}),h.jsx("span",{className:"text-[11px] text-text-400",children:"任何 TTC 员工打开此链接(飞书登录)即可在该 persona 下交互。"})]}):h.jsx("span",{className:"text-[11px] text-text-400","data-testid":"guest-share-link-no-tunnel",children:"需先开启 tunnel(公网访问)才能生成可分享给外部的链接。"})]}):null,h.jsx("hr",{className:"border-border"})]}):null,s?h.jsxs("section",{className:"flex flex-col gap-1.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"默认图标"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"新建该 persona 的 session 会默认继承此图标。"}),h.jsx(tI,{value:e.iconKey??null,onChange:s})]}):null,s?h.jsx("hr",{className:"border-border"}):null,m&&!p?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex flex-col gap-1.5",children:[h.jsx("span",{className:"text-[12px] font-medium text-text-200",children:"Agent"}),h.jsx("div",{className:"flex gap-2",children:["claude","codex"].map(k=>h.jsx("button",{type:"button","data-testid":`persona-edit-tool-${k}`,onClick:()=>m(k),className:ne("flex-1 rounded-md border px-3 py-2 text-[12px]",(e.tool??"claude")===k?"border-accent bg-accent/10 text-accent":"border-bg-300 text-text-300"),children:k==="claude"?"Claude Code":"Codex"},k))}),h.jsx("span",{className:"text-[11px] text-text-400",children:"切换只影响之后新建的会话,已有会话保持原 tool。"})]}),h.jsx("hr",{className:"border-border"})]}):null,l?h.jsxs(h.Fragment,{children:[h.jsx(dte,{onLoad:l,...c?{onSave:c}:{},onDirtyChange:w,initialPersonality:d,readOnly:p}),h.jsx("hr",{className:"border-border"})]}):null,h.jsx(lte,{settings:e.sandboxSettings??null}),h.jsx("hr",{className:"border-border"}),h.jsx(cte,{skills:e.skills??[]}),h.jsx("hr",{className:"border-border"}),h.jsx(ute,{plugins:e.plugins??[]})]})]})]}):null}function ate({checked:e,onChange:t}){return h.jsx("button",{type:"button",role:"switch","aria-checked":e,onClick:()=>t(!e),"data-testid":"persona-public-toggle",className:ne("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors",e?"bg-success":"bg-bg-300"),children:h.jsx("span",{className:ne("inline-block h-5 w-5 rounded-full bg-bg-0 shadow transition-transform",e?"translate-x-[22px]":"translate-x-0.5")})})}function lte({settings:e}){var t,n,r,i,s,o,a,l,c,u,d,f,p;return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-sandbox-setting-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Sandbox Setting"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"约束此 persona 的沙箱权限(只读,需通过文件修改)。"})]}),e==null?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-sandbox-setting-empty",children:"暂无 sandbox 配置"}):h.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-bg-100 px-3 py-2",children:[h.jsx(gd,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),h.jsx(gd,{label:"沙箱启用",value:$m((n=e.sandbox)==null?void 0:n.enabled)}),h.jsx(gd,{label:"沙箱内自动放行 Bash",value:$m((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),h.jsx(gd,{label:"允许非沙箱命令",value:$m((i=e.sandbox)==null?void 0:i.allowUnsandboxedCommands)}),h.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border pt-1.5",children:[h.jsx(Il,{label:"沙箱外命令",paths:(s=e.sandbox)==null?void 0:s.excludedCommands}),h.jsx(Il,{label:"允许读取",paths:(a=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:a.allowRead}),h.jsx(Il,{label:"拒绝读取",paths:(c=(l=e.sandbox)==null?void 0:l.filesystem)==null?void 0:c.denyRead}),h.jsx(Il,{label:"允许写入",paths:(d=(u=e.sandbox)==null?void 0:u.filesystem)==null?void 0:d.allowWrite}),h.jsx(Il,{label:"拒绝写入",paths:(p=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:p.denyWrite})]})]})]})}function $m(e){return e===!0?"是":e===!1?"否":"—"}function gd({label:e,value:t}){return h.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px]",children:[h.jsx("span",{className:"text-text-300",children:e}),h.jsx("span",{className:"font-mono text-text-100",children:t})]})}function Il({label:e,paths:t}){const n=!t||t.length===0;return h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[11px] text-text-300",children:e}),n?h.jsx("span",{className:"text-[11px] text-text-400",children:"—"}):h.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((r,i)=>h.jsx("span",{className:"rounded-sm border border-border bg-bg-0 px-1.5 py-0.5 font-mono text-[11px] text-text-200",children:r},`${e}-${i}-${r}`))})]})}function cte({skills:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-skills-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Persona Skills"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 私有 skills(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/skills/"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-skills-empty",children:"暂无 skills"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsxs("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-skill-row",children:[h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.name}),t.description?h.jsx("span",{className:"text-[12px] text-text-300",children:t.description}):h.jsx("span",{className:"text-[11px] text-text-400 italic",children:"无描述"})]},t.name))})]})}function ute({plugins:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-plugins-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Enabled Plugins"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 已启用的插件(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/settings.json"})," ","的 ",h.jsx("code",{className:"font-mono",children:"enabledPlugins"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-plugins-empty",children:"暂无启用插件"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsx("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-plugin-row",children:h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.id})},t.id))})]})}function dte({onLoad:e,onSave:t,onDirtyChange:n,initialPersonality:r,readOnly:i=!1}){const s=r!==void 0,[o,a]=g.useState(s),[l,c]=g.useState(s?r:""),[u,d]=g.useState(s?r:""),[f,p]=g.useState(null),[m,v]=g.useState(!1),[y,_]=g.useState(null),x=st.useRef(e),b=st.useRef(t),w=st.useRef(n);st.useEffect(()=>{x.current=e,b.current=t,w.current=n});const S=st.useCallback(()=>{a(!1),p(null),x.current().then(L=>{c(L),d(L),a(!0)}).catch(L=>{p(L instanceof Error?L.message:String(L))})},[]);st.useEffect(()=>{s||S()},[s,S]);const k=!i&&o&&u!==l;st.useEffect(()=>{i||w.current(k)},[k,i]);const T=()=>{b.current&&(v(!0),_(null),b.current(u).then(()=>{c(u),v(!1)}).catch(L=>{_(L instanceof Error?L.message:String(L)),v(!1)}))},N=()=>{d(l),_(null)};return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-personality-section",children:[h.jsx("span",{className:"text-[12px] font-medium text-text-200",children:"人格 (Personality)"}),f?h.jsxs("div",{"data-testid":"persona-personality-load-error",className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error flex items-center justify-between gap-2",children:[h.jsxs("span",{children:["加载失败:",f]}),h.jsx("button",{type:"button",onClick:S,className:"rounded-sm border border-error px-2 py-0.5 text-[11px] hover:bg-error/10",children:"重试"})]}):null,y?h.jsxs("div",{"data-testid":"persona-personality-save-error",className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error",children:["保存失败:",y]}):null,h.jsx("textarea",{"data-testid":"persona-personality-textarea",value:u,onChange:L=>d(L.target.value),readOnly:i,disabled:!i&&(!o||m),placeholder:o?"":"加载中…",rows:8,className:"min-h-[8rem] max-h-[18rem] resize-y rounded-md border border-border bg-bg-100 px-2 py-1.5 font-mono text-[11px] text-text-100 disabled:opacity-60"}),!i&&h.jsxs("p",{className:"text-[10px] text-text-400",children:["写入到 ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/CLAUDE.md"}),"。 修改只对新启动的 sub-session 生效。"]}),o&&k?h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:N,disabled:m,className:"rounded-sm border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200 disabled:opacity-60",children:"放弃"}),h.jsx("button",{type:"button",onClick:T,disabled:m,"data-testid":"persona-personality-save-btn",className:"rounded-sm bg-accent-dim px-2 py-1 text-[12px] text-text-100 hover:opacity-90 disabled:opacity-60",children:m?"保存中…":"保存"})]}):null]})}function hte({personaId:e,open:t,onClose:n,api:r,embedded:i,onDirtyChange:s,onShareCapability:o,viewerRole:a="owner"}){const{persona:l}=MN(e),c=lB(e),u=cB(),d=uB(),{httpBaseUrl:f}=Af(),p=g.useMemo(()=>!(l!=null&&l.public)||!f||/^https?:\/\/(127\.0\.0\.1|localhost|0\.0\.0\.0|\[?::1\]?)([:/]|$)/i.test(f)?null:`${f}/s/${e}`,[l==null?void 0:l.public,f,e]),m=g.useCallback(S=>{u(e,{public:S}).catch(k=>{Ae("persona","togglePublic failed",k)})},[u,e]),v=g.useCallback(S=>{u(e,{iconKey:S}).catch(k=>{Ae("persona","changeIcon failed",k)})},[u,e]),y=g.useCallback(S=>{u(e,{tool:S}).catch(k=>{Ae("persona","changeTool failed",k)})},[u,e]),_=g.useCallback(()=>{l&&confirm(`删除 persona "${l.label}"?`)&&(d(e).catch(S=>{Ae("persona","delete failed",S)}),n())},[l,d,e,n]),x=g.useCallback(async()=>c.loaded?c.personality:(await c.refresh()).personality,[c]),b=g.useCallback(async S=>{await u(e,{personality:S}),await c.refresh()},[u,e,c]);if(!l)return null;const w=a==="guest";return h.jsx(ote,{embedded:i,persona:{...l,skills:c.skills,plugins:c.plugins,sandboxSettings:c.sandboxSettings},open:t,onClose:n,onLoadPersonality:x,onDirtyChange:s,readOnly:w,...w?{}:{onTogglePublic:m,guestShareUrl:p,onChangeIcon:v,onChangeTool:y,onDelete:_,onSavePersonality:b,...o?{onShareCapability:o}:{}}})}function fte({api:e,open:t,onOpenChange:n,personaId:r,personaName:i,viewerRole:s}){return t?h.jsxs("div",{"data-testid":"persona-drawer",className:"fixed inset-y-0 right-0 z-50 flex w-[420px] flex-col border-l border-border bg-elevated shadow-2xl",children:[h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-[13px] font-semibold text-text-100",children:[h.jsx(Y_,{className:"h-4 w-4 shrink-0"}),h.jsxs("span",{className:"truncate",title:i,children:["Persona · ",i]})]}),h.jsx("button",{type:"button",onClick:()=>n(!1),className:"flex h-7 w-7 items-center justify-center rounded text-text-400 hover:bg-bg-200 hover:text-text-100","aria-label":"Close drawer",children:h.jsx(Rn,{className:"h-4 w-4"})})]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:h.jsx(hte,{personaId:r,open:!0,onClose:()=>n(!1),api:e,embedded:!0,...s?{viewerRole:s}:{}},r)})]}):null}function pte(e){try{const t=new URL(e);return t.protocol==="ws:"?t.protocol="http:":t.protocol==="wss:"&&(t.protocol="https:"),`${t.protocol}//${t.host}`}catch{return e}}function mte(e,t){try{const n=new URL(e),r=new URL(t);return n.protocol=r.protocol,n.host=r.host,n.toString()}catch{return e}}async function gy(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return mte(s.url,pte(t.url))}async function gte(e,t,n,r,i=60){const s=window.open("about:blank","_blank");try{const o=await gy(e,t,n,r,i);s?s.location.href=o:window.open(o,"_blank")}catch(o){throw s&&s.close(),o}}async function vte(e){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.setAttribute("readonly",""),document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}const _te={...Vc,h1:({node:e,...t})=>h.jsx("h1",{...t,className:"mt-4 mb-3 text-[18px] font-semibold leading-tight text-text-100"}),h2:({node:e,...t})=>h.jsx("h2",{...t,className:"mt-4 mb-2 text-[16px] font-semibold leading-tight text-text-100"}),h3:({node:e,...t})=>h.jsx("h3",{...t,className:"mt-3 mb-2 text-[14px] font-semibold leading-tight text-text-100"}),h4:({node:e,...t})=>h.jsx("h4",{...t,className:"mt-3 mb-1 text-[13px] font-semibold text-text-100"}),h5:({node:e,...t})=>h.jsx("h5",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-100"}),h6:({node:e,...t})=>h.jsx("h6",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-300"}),p:({node:e,...t})=>h.jsx("p",{...t,className:"my-2 leading-relaxed"}),ul:({node:e,...t})=>h.jsx("ul",{...t,className:"my-2 list-disc space-y-1 pl-5"}),ol:({node:e,...t})=>h.jsx("ol",{...t,className:"my-2 list-decimal space-y-1 pl-5"}),li:({node:e,...t})=>h.jsx("li",{...t,className:"leading-relaxed"}),blockquote:({node:e,...t})=>h.jsx("blockquote",{...t,className:"my-2 border-l-2 border-border pl-3 italic text-text-300"}),code:({node:e,className:t,children:n,...r})=>t?h.jsx("code",{...r,className:`${t} font-mono text-[12px]`,children:n}):h.jsx("code",{...r,className:"rounded bg-bg-50 px-1 py-0.5 font-mono text-[12px] text-text-100",children:n}),pre:({node:e,...t})=>h.jsx("pre",{...t,className:"my-2 overflow-auto rounded border border-border bg-bg-0 p-3 text-[12px] font-mono text-text-100"}),hr:({node:e,...t})=>h.jsx("hr",{...t,className:"my-3 border-border"}),table:({node:e,...t})=>h.jsx("table",{...t,className:"my-2 w-full border-collapse text-[12px]"}),thead:({node:e,...t})=>h.jsx("thead",{...t,className:"bg-bg-50"}),th:({node:e,...t})=>h.jsx("th",{...t,className:"border border-border px-2 py-1 text-left font-semibold"}),td:({node:e,...t})=>h.jsx("td",{...t,className:"border border-border px-2 py-1"}),strong:({node:e,...t})=>h.jsx("strong",{...t,className:"font-semibold text-text-100"}),em:({node:e,...t})=>h.jsx("em",{...t,className:"italic"})};function xte(e){const t=e.split("/");return t[t.length-1]||e}function sA({relPath:e,loadMarkdown:t,headerRight:n,showTitleBar:r=!1}){const[i,s]=g.useState(null),[o,a]=g.useState(null),[l,c]=g.useState(!1);return g.useEffect(()=>{if(!e)return;let u=!1;return c(!0),a(null),s(null),(async()=>{try{const d=await t(e);if(u)return;s(d)}catch(d){if(u)return;a(d.message||String(d))}finally{u||c(!1)}})(),()=>{u=!0}},[e,t]),h.jsxs("div",{className:"flex flex-col h-full",children:[r&&e?h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[h.jsx("div",{"data-testid":"md-preview-title",className:"truncate text-[13px] font-medium text-text-100",title:e,children:xte(e)}),h.jsx("div",{className:"flex items-center gap-1",children:n})]}):null,h.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 text-[13px] text-text-100",children:l?h.jsx("div",{"data-testid":"md-preview-loading",className:"text-text-400",children:"Loading…"}):o?h.jsx("div",{"data-testid":"md-preview-error",className:"text-destructive whitespace-pre-wrap",children:o}):i!==null?h.jsx("div",{"data-testid":"md-preview-content",className:"max-w-none",children:h.jsx(Hc,{remarkPlugins:[Wc],components:_te,children:i})}):null})]})}function yte({open:e,onOpenChange:t,relPath:n,loadMarkdown:r,onShare:i}){return e?h.jsx("div",{"data-testid":"md-preview-drawer",className:"fixed inset-y-0 right-0 z-50 flex w-1/2 max-w-[900px] flex-col border-l border-border bg-elevated shadow-2xl",children:h.jsx(sA,{relPath:n,loadMarkdown:r,showTitleBar:!0,headerRight:h.jsxs(h.Fragment,{children:[i?h.jsx("button",{type:"button","data-testid":"md-preview-share","aria-label":"Share rendered preview link",onClick:i,className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(BN,{className:"h-4 w-4"})}):null,h.jsx("button",{type:"button","aria-label":"Close preview",onClick:()=>t(!1),className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(Rn,{className:"h-4 w-4"})})]})})}):null}function bte({left:e,right:t,stage:n,onExpand:r,onCollapse:i}){const s=n==="stopped",[o,a]=g.useState(!1);async function l(){if(!o){a(!0);try{await r()}catch{}finally{a(!1)}}}async function c(){if(!o){a(!0);try{await i()}catch{}finally{a(!1)}}}return h.jsxs("div",{className:"flex h-full w-full min-h-0","data-testid":"two-pane-layout",children:[h.jsxs("div",{className:"relative flex min-w-0 flex-1 flex-col","data-testid":"two-pane-left",children:[s&&h.jsx("button",{type:"button",disabled:o,className:"absolute right-14 top-2 z-10 rounded border border-border bg-elevated px-2 py-1 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed",onClick:l,children:o?"启动中…":"展开预览"}),e]}),!s&&h.jsxs("div",{className:"flex w-1/2 min-w-[320px] flex-col border-l border-bg-200","data-testid":"two-pane-right",children:[h.jsx("div",{className:"flex items-center justify-end gap-2 border-b border-bg-200 bg-bg-50 px-2 py-1",children:h.jsx("button",{type:"button",disabled:o,className:"rounded px-2 py-1 text-[12px] text-text-300 hover:bg-bg-100 disabled:opacity-50",onClick:c,children:"收起预览"})}),h.jsx("div",{className:"min-h-0 flex-1",children:t})]})]})}const oA=sM,wte=oM,aA=g.forwardRef(({className:e,...t},n)=>h.jsx(ty,{ref:n,className:ne("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));aA.displayName=ty.displayName;const vy=g.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(wte,{children:[h.jsx(aA,{}),h.jsxs(ny,{ref:r,className:ne("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2","gap-4 rounded-lg border border-border bg-elevated p-6 shadow-lg",e),...n,children:[t,h.jsxs(aM,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-accent",children:[h.jsx(Rn,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));vy.displayName=ny.displayName;const _y=({className:e,...t})=>h.jsx("div",{className:ne("flex flex-col space-y-1.5 text-left",e),...t});_y.displayName="DialogHeader";const xy=({className:e,...t})=>h.jsx("div",{className:ne("flex flex-row justify-end gap-2",e),...t});xy.displayName="DialogFooter";const yy=g.forwardRef(({className:e,...t},n)=>h.jsx(ry,{ref:n,className:ne("text-lg font-semibold leading-none text-text-100",e),...t}));yy.displayName=ry.displayName;const lA=g.forwardRef(({className:e,...t},n)=>h.jsx(iy,{ref:n,className:ne("text-sm text-text-300",e),...t}));lA.displayName=iy.displayName;const Ste=6173,kte=6182;function Cte({open:e,onOpenChange:t,projectName:n,currentPort:r,allUsedPorts:i,onUpdate:s}){const o=[];for(let v=Ste;v<=kte;v++)(v===r||!i.includes(v))&&o.push(v);const[a,l]=g.useState(r),[c,u]=g.useState(!1),[d,f]=g.useState(null),p=a!==r&&!c;async function m(){if(p){u(!0),f(null);try{await s(a),t(!1)}catch(v){f((v==null?void 0:v.message)??String(v))}finally{u(!1)}}}return h.jsx(oA,{open:e,onOpenChange:t,children:h.jsxs(vy,{className:"max-w-md",children:[h.jsxs(_y,{children:[h.jsxs(yy,{children:["改端口 · ",n]}),h.jsxs(lA,{children:["手改通常发生在系统其他进程占了默认分配的端口、dev server 起不来时。 提交后 daemon 会停 dev server → 写 ",h.jsx("code",{className:"mx-1 rounded bg-bg-100 px-1 py-0.5 text-[11px]",children:".clawd-project.json"})," → 用新端口重新起。"]})]}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsx("label",{className:"text-xs text-text-400",children:"新端口(仅显示段内可用 + 当前端口)"}),h.jsx("select",{className:"h-9 rounded-md border border-border bg-elevated px-3 py-1 text-sm text-text-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent",value:a,onChange:v=>l(Number(v.target.value)),disabled:c,children:o.map(v=>h.jsxs("option",{value:v,children:[v,v===r?"(当前)":""]},v))}),o.length===1&&h.jsx("div",{className:"text-[11px] text-text-400",children:"端口段已全被其它 project 占用,没有可换的;先删一个 idle project 释放端口。"}),d&&h.jsx("div",{className:"rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px] text-destructive",children:d})]}),h.jsxs(xy,{children:[h.jsx(ni,{variant:"ghost",onClick:()=>t(!1),disabled:c,children:"取消"}),h.jsx(ni,{onClick:m,disabled:!p,children:c?"应用中…":"应用新端口"})]})]})})}const zk=[{stage:"build",label:"构建"},{stage:"deploy",label:"部署到阿里云"},{stage:"verify",label:"验证可访问性"}];function Ete({currentStage:e,onCancel:t}){const n=zk.findIndex(r=>r.stage===e);return h.jsxs("div",{"data-testid":"publish-progress",className:"flex items-center gap-3 border-b border-bg-200 bg-bg-50 px-3 py-1.5 text-[12px]",children:[zk.map((r,i)=>{const s=i<n,o=i===n,a=s?"text-text-300":o?"text-text-200":"text-text-500/50";return h.jsxs("span",{className:`flex items-center gap-1 ${a}`,children:[s?h.jsx(jf,{className:"size-3.5"}):o?h.jsx(rr,{className:"size-3.5 animate-spin"}):h.jsx(DN,{className:"size-3.5"}),h.jsxs("span",{children:[r.label,o?"中…":""]})]},r.stage)}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const Nte={build:"构建",deploy:"部署",verify:"验证"};function Tte({stage:e,onRetry:t,onDismiss:n}){return h.jsxs("div",{"data-testid":"publish-interrupted-banner",className:"flex items-center gap-2 border-b border-yellow-400/40 bg-yellow-400/10 px-3 py-1.5 text-[12px]",children:[h.jsx(Ac,{className:"size-3.5 text-yellow-500"}),h.jsxs("span",{className:"text-text-200",children:["上次发布在 ",h.jsxs("strong",{className:"font-medium",children:["[",Nte[e],"]"]})," ","阶段被中断(daemon 重启)"]}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded bg-accent-main-100 px-2 py-0.5 text-[11px] text-oncolor-100 hover:opacity-90",children:"重新发布"}),h.jsx("button",{type:"button",onClick:n,className:"rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const Pte={build:"构建",deploy:"部署",verify:"验证",unknown:"未知"};function Ite({stage:e,onFocusChat:t,onClose:n}){return h.jsxs("div",{"data-testid":"publish-failed-banner",className:"flex items-center gap-2 border-b border-destructive/40 bg-destructive/10 px-3 py-1.5 text-[12px]",children:[h.jsx(Rs,{className:"size-3.5 text-destructive"}),h.jsxs("button",{type:"button",onClick:t,className:"flex-1 text-left text-text-200 hover:underline",children:["发布失败:",h.jsxs("strong",{className:"font-medium",children:["[",Pte[e],"]"]})," ","已通知 assistant 接管 →"]}),h.jsx("button",{type:"button",onClick:n,"aria-label":"关闭失败提示",className:"rounded p-0.5 text-text-400 hover:bg-bg-100 hover:text-text-200",children:h.jsx(Rn,{className:"size-3.5"})})]})}const $k={"install-pending":{label:"等装依赖…",step:"1/3"},installing:{label:"安装依赖中…(可能要几十秒到几分钟)",step:"2/3"},"starting-dev-server":{label:"启动 dev server…(等监听端口才挂 iframe)",step:"3/3"}};function Rte({project:e,previewHost:t,previewScheme:n,onUpdatePort:r,allUsedPorts:i,publishSlot:s,publishInFlightStage:o,onDismissPublishJob:a,onRetryPublish:l,publishFailureBanner:c,onPublishFailureBannerClose:u,onPublishFailureBannerFocusChat:d}){var _,x;const[f,p]=g.useState(!1);if(!e)return h.jsx("div",{className:"flex h-full w-full items-center justify-center p-6 text-center text-[13px] text-text-400",children:"未绑定 project"});const m=e.stage??(e.isRunning?"running":"stopped"),v=t?`${n}://${t}/preview/${e.port}/`:null,y=e.prodUrl??null;return h.jsxs("div",{className:"flex h-full w-full flex-col","data-testid":"preview-pane",children:[h.jsxs("header",{className:"flex items-center justify-between gap-2 border-b border-bg-200 bg-bg-50 px-3 py-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[12px]",children:[h.jsx("span",{className:"font-medium text-text-200",children:e.name}),h.jsx("span",{className:"rounded bg-bg-100 px-1.5 py-0.5 text-[11px] text-text-400",children:e.port}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-text-500",children:m==="running"?"dev":m})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[y?h.jsxs("a",{href:y,target:"_blank",rel:"noopener noreferrer",title:`打开线上:${y}`,className:"inline-flex items-center gap-1 rounded border border-bg-200 px-2 py-0.5 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(Mc,{className:"size-3"}),"打开线上"]}):null,s,h.jsxs(UP,{children:[h.jsx(WP,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":"Project settings",className:"rounded p-1 text-text-400 hover:bg-bg-100",children:h.jsx($6,{className:"size-3.5"})})}),h.jsxs(vx,{align:"end",children:[h.jsx(Ys,{onSelect:()=>p(!0),children:"Update Port…"}),h.jsxs(Ys,{disabled:!0,title:"rename not supported yet",onSelect:b=>b.preventDefault(),children:["Name: ",e.name]})]})]})]})]}),c?h.jsx(Ite,{stage:c.stage,onClose:()=>u==null?void 0:u(),onFocusChat:()=>d==null?void 0:d()}):null,((_=e.publishJob)==null?void 0:_.status)==="in-flight"?h.jsx(Ete,{currentStage:o??e.publishJob.stage,onCancel:()=>void(a==null?void 0:a())}):null,((x=e.publishJob)==null?void 0:x.status)==="interrupted"?h.jsx(Tte,{stage:e.publishJob.stage,onRetry:()=>void(l==null?void 0:l()),onDismiss:()=>void(a==null?void 0:a())}):null,h.jsx("div",{className:"min-h-0 flex-1",children:m==="failed"?h.jsx(Mte,{reason:e.stageReason}):m==="stopped"?null:m==="running"?v?h.jsx("iframe",{"data-testid":"preview-iframe",className:"size-full border-0 bg-white",src:v,title:"preview"}):h.jsx(Fk,{label:"等 tunnel 起来…",step:"-"}):h.jsx(Fk,{label:$k[m].label,step:$k[m].step})}),h.jsx(Cte,{open:f,onOpenChange:p,projectName:e.name,currentPort:e.port,allUsedPorts:i,onUpdate:async b=>{await r(b)}})]})}function Fk({label:e,step:t}){return h.jsxs("div",{"data-testid":"preview-spinner",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(rr,{className:"size-6 animate-spin text-accent-main-100"}),h.jsx("div",{className:"text-[13px] text-text-200",children:e}),h.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-500",children:t}),h.jsx("div",{className:"mt-2 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度"})]})}function Mte({reason:e}){return h.jsxs("div",{"data-testid":"preview-failed",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(Rs,{className:"size-6 text-destructive"}),h.jsx("div",{className:"text-[13px] text-text-200",children:"project 启动失败"}),h.jsx("div",{className:"max-w-[400px] text-[12px] text-text-400",children:e??"未知原因 —— 看 ~/.clawd/clawd.log 排查"}),h.jsx("div",{className:"mt-1 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度 / 跟它说怎么修"})]})}function Ate({error:e,onClose:t}){const[n,r]=g.useState(!1),i=async()=>{var a;if(!e)return;const s=e.message;let o=!1;try{(a=navigator.clipboard)!=null&&a.writeText&&(await navigator.clipboard.writeText(s),o=!0)}catch{o=!1}if(!o){const l=document.createElement("textarea");l.value=s,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.select();try{document.execCommand("copy"),o=!0}catch{o=!1}finally{document.body.removeChild(l)}}o&&(r(!0),setTimeout(()=>r(!1),1500))};return h.jsx(oA,{open:!!e,onOpenChange:s=>{s||(r(!1),t())},children:h.jsxs(vy,{className:"max-w-lg",children:[h.jsx(_y,{children:h.jsx(yy,{children:(e==null?void 0:e.title)??"错误"})}),h.jsx("pre",{"data-testid":"rpc-error-message",className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded border border-bg-200 bg-bg-50 px-3 py-2 text-[12px] text-text-200",children:(e==null?void 0:e.message)??""}),h.jsxs(xy,{children:[h.jsx(ni,{variant:"ghost",onClick:i,className:"gap-1.5",children:n?h.jsxs(h.Fragment,{children:[h.jsx(Za,{className:"size-3.5"}),"已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(su,{className:"size-3.5"}),"复制"]})}),h.jsx(ni,{onClick:t,children:"关闭"})]})]})})}function jte(e,t){for(const n of[e,t])if(n)try{const r=new URL(n),i=r.protocol==="https:"||r.protocol==="wss:"?"https":"http";return{host:r.host,scheme:i}}catch{}return{host:null,scheme:"https"}}const Dte={codex:"on-request",claude:"bypassPermissions"};function Lte(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??Dte[e.sourceTool??"claude"]??"bypassPermissions",forkedFromSessionId:e.sourceSessionId};return e.sourceOwnerPersonaId&&(t.ownerPersonaId=e.sourceOwnerPersonaId),e.sourceTool&&(t.tool=e.sourceTool),t}async function Ote(e,t,n){if(!t.toolSessionId)return null;const{forkedToolSessionId:r}=await e.sessionFork({cwd:t.cwd,toolSessionId:t.toolSessionId,messageUuid:n}),i=await e.sessionCreate({...Lte({cwd:t.cwd,sourceSessionId:t.sessionId,sourcePermissionMode:t.permissionMode,sourceOwnerPersonaId:t.ownerPersonaId,sourceTool:t.tool}),ephemeral:!0});return await e.sessionResume(i.sessionId,r),i}function vd(e){return e!=null&&e.ephemeral!==!1}async function Bte(e,t){return!t.stillEphemeral||!t.nextHold?!1:(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0)}const zte=300;function $te(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function cA(e,t){const n=P_(),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>{let a=!1;return(async()=>{try{const l=await n.kv.get(e);if(a)return;const c=$te(l);typeof c=="number"&&Number.isFinite(c)&&c>0?i(c):i(t)}catch{a||i(t)}})(),()=>{a=!0}},[n,e,t]);const o=g.useCallback(a=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,n.kv.set(e,a).catch(()=>{})},zte)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function Fte(){return{quickAsk:null,mds:[],active:null}}function Hte(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function Ute(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function Wte(e){if(!e.quickAsk)return e;const t=e.active==="quick-ask",n=e.mds[0],r=t?n?{kind:"md",relPath:n}:null:e.active;return{...e,quickAsk:null,active:r}}function Vte(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function qte(e,t){const n=e.mds.indexOf(t);if(n<0)return e;const r=e.mds.filter(l=>l!==t);if(!(e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===t))return{...e,mds:r};const s=r[n],o=n>0?r[n-1]:void 0;let a=null;return s?a={kind:"md",relPath:s}:o?a={kind:"md",relPath:o}:e.quickAsk&&(a="quick-ask"),{...e,mds:r,active:a}}function Kte(e,t){return{...e,active:t}}function Gte(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function uA(e){return e.quickAsk!==null||e.mds.length>0}function Xte(e){return e.split("/").pop()||e}function Yte({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:i,loadMarkdown:s,quickAskSession:o,onToggleHold:a,holdIds:l}){if(!uA(e))return null;const c=[];e.quickAsk&&c.push({id:"quick-ask",label:"问一下",title:"问一下",icon:h.jsx(Mh,{className:"w-3.5 h-3.5"})});for(const u of e.mds)c.push({id:{kind:"md",relPath:u},label:Xte(u),title:u,icon:h.jsx(Ms,{className:"w-3.5 h-3.5"})});return h.jsxs("div",{className:"flex flex-col h-full bg-bg-0 border-l border-text-100/10",children:[h.jsx(xx,{delayDuration:200,skipDelayDuration:100,children:h.jsx("div",{className:["flex items-stretch h-9 border-b border-text-100/10 shrink-0 overflow-x-auto","[scrollbar-width:none] [-ms-overflow-style:none]","[&::-webkit-scrollbar]:hidden"].join(" "),role:"tablist",children:c.map(u=>{const d=Gte(e.active,u.id),f=u.id==="quick-ask"?"quick-ask":`md:${u.id.relPath}`;return h.jsxs(yx,{children:[h.jsx(bx,{asChild:!0,children:h.jsxs("div",{role:"tab","aria-selected":d,"data-tab-title":u.title,onClick:()=>n(u.id),className:["group relative flex items-center gap-2 px-3 h-full cursor-pointer select-none","text-[12px] max-w-[180px] shrink-0 transition-colors duration-100",d?"text-text-100":"text-text-400 hover:text-text-100 hover:bg-text-100/[0.04]"].join(" "),children:[u.icon,h.jsx("span",{className:"truncate",children:u.label}),h.jsx("button",{type:"button","aria-label":`关闭 ${u.label}`,className:["ml-1 rounded p-0.5 shrink-0 transition-opacity","hover:bg-text-100/10",d?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-70"].join(" "),onClick:p=>{p.stopPropagation(),u.id==="quick-ask"?r():i(u.id.relPath)},children:h.jsx(Rn,{className:"w-3 h-3"})}),d?h.jsx("span",{"aria-hidden":"true",className:"absolute left-2 right-2 -bottom-px h-[2px] rounded-full bg-accent"}):null]})}),h.jsx(Xf,{side:"bottom",align:"start",className:"max-w-sm break-all",children:u.title})]},f)})})}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.quickAsk&&o?h.jsx("div",{className:"absolute inset-0",style:{display:e.active==="quick-ask"?"block":"none"},children:h.jsx(Qte,{session:o,api:t,holdIds:l,...a?{onToggleHold:a}:{}})}):null,e.mds.map(u=>{const d=e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===u;return h.jsx("div",{className:"absolute inset-0",style:{display:d?"block":"none"},children:h.jsx(sA,{relPath:u,loadMarkdown:s,showTitleBar:!1})},`md-body:${u}`)})]})]})}function Zte({state:e,extras:t}){const{api:n,session:r,holdIds:i,onToggleHold:s}=t,o=Is(),[a,l]=g.useState(Fte()),c=g.useRef(a);c.current=a;const u=g.useRef(!1),d=g.useCallback(async T=>{const N=c.current.quickAsk,L=await Ote(n,r,T);if(L){if(u.current){n.sessionDelete(L.sessionId).catch(()=>{});return}vd(N)&&n.sessionDelete(N.sessionId).catch(()=>{}),l(P=>Hte(P,{sessionId:L.sessionId}))}},[n,r]),f=g.useCallback(async(T,N)=>{const L=c.current.quickAsk,P=(L==null?void 0:L.sessionId)===T;try{await Bte(n,{sessionId:T,stillEphemeral:P&&vd(L),nextHold:N})&&l(I=>Vte(I))}catch(O){Ae("quick-ask","promote failed",O);return}s==null||s(T,N)},[n,s]),p=g.useCallback(T=>{l(N=>Ute(N,T))},[]),m=g.useCallback(T=>{l(N=>Kte(N,T))},[]),v=g.useCallback(()=>{const T=c.current.quickAsk;vd(T)&&n.sessionDelete(T.sessionId).catch(()=>{}),l(N=>Wte(N))},[n]),y=g.useCallback(T=>{l(N=>qte(N,T))},[]);g.useEffect(()=>()=>{u.current=!0;const T=c.current.quickAsk;vd(T)&&n.sessionDelete(T.sessionId).catch(()=>{})},[]);const _=si("sessions")??[],x=a.quickAsk?_.find(T=>T.sessionId===a.quickAsk.sessionId)??{sessionId:a.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,b=g.useCallback(async T=>{const N=await gy(n,o,r.sessionId,T,60),L=await fetch(N);if(!L.ok)throw new Error(`fetch ${L.status} ${L.statusText}`);return L.text()},[n,o,r.sessionId]),w=h.jsx(by,{state:e,extras:t,onQuickAskInternal:d,onPreviewMdInternal:p}),{initialSize:S,setSize:k}=cA("chat-panel-right-slot-width",480);return uA(a)?h.jsxs(Ix,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx($c,{id:"chat",minSize:"400px",children:w}),h.jsx(Mx,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx($c,{id:"right-slot",defaultSize:`${S}px`,minSize:"360px",maxSize:"800px",onResize:T=>k(T.inPixels),children:h.jsx(Yte,{state:a,api:n,onSwitchTab:m,onCloseQuickAsk:v,onCloseMd:y,loadMarkdown:b,quickAskSession:x,holdIds:i,onToggleHold:f})})]}):w}function Qte({session:e,api:t,holdIds:n,onToggleHold:r}){const i=iA(e.sessionId);return h.jsx(by,{state:i,extras:{session:e,api:t,holdIds:n,...r?{onToggleHold:r}:{}}})}function Jte({extras:e}){const t=iA(e.session.sessionId);if(e.session.appBuilderProject){const n=h.jsx(by,{state:t,extras:e});return h.jsx(ene,{state:t,chat:n,extras:e})}return h.jsx(Zte,{state:t,extras:e})}function ene({state:e,chat:t,extras:n}){var N;const r=si("daemon-info"),i=Is(),s=n.api,o=n.session,a=o.appBuilderProject,[l,c]=g.useState(null),u=g.useCallback(()=>{s.appBuilderGetProject(o.sessionId).then(L=>c(L.project)).catch(()=>c(null))},[s,o.sessionId]);g.useEffect(()=>{u()},[u]);const[d,f]=g.useState([]),p=g.useCallback(()=>{s.appBuilderListProjects().then(L=>f(L.projects)).catch(()=>f([]))},[s]);g.useEffect(()=>{p()},[p]),g.useEffect(()=>i.on("appBuilder:project-updated",P=>{const O=P;O!=null&&O.project&&(O.project.name===a&&c(O.project),f(I=>{const R=I.findIndex(z=>z.name===O.project.name);if(R<0)return[...I,O.project];const j=I.slice();return j[R]=O.project,j}))}),[i,a]);const{host:m,scheme:v}=jte(i.url,r==null?void 0:r.tunnelUrl),[y,_]=g.useState(void 0),[x,b]=g.useState(null);g.useEffect(()=>{const L=i.on("appBuilder:publish-progress",O=>{const I=O;!I||I.name!==a||I.status==="started"&&_(I.stage)}),P=i.on("appBuilder:publish-failed",O=>{const I=O;!I||I.name!==a||(_(void 0),b({stage:I.stage}))});return()=>{L(),P()}},[i,a]),g.useEffect(()=>{_(void 0),b(null)},[a]);const[w,S]=g.useState(null),k=h.jsx("button",{type:"button",className:"rounded bg-accent-main-100 px-2.5 py-1 text-[12px] text-oncolor-100 hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",disabled:((N=l==null?void 0:l.publishJob)==null?void 0:N.status)==="in-flight",onClick:async()=>{try{await s.appBuilderPublish(a)}catch(L){S({title:"发布请求失败",message:(L==null?void 0:L.message)??String(L)})}},children:"发布上线"}),T=(l==null?void 0:l.stage)??(l!=null&&l.isRunning?"running":"stopped");return h.jsxs(h.Fragment,{children:[h.jsx(bte,{left:t,stage:T,onExpand:async()=>{await s.appBuilderStartDevServer(o.sessionId)},onCollapse:async()=>{await s.appBuilderStopDevServer(o.sessionId)},right:h.jsx(Rte,{project:l,previewHost:m,previewScheme:v,allUsedPorts:d.map(L=>L.port),onUpdatePort:async L=>{await s.appBuilderUpdateProjectPort(a,L),p()},publishSlot:k,publishInFlightStage:y,onDismissPublishJob:async()=>{try{await s.appBuilderDismissPublishJob(a)}catch(L){S({title:"取消发布失败",message:(L==null?void 0:L.message)??String(L)})}},onRetryPublish:async()=>{try{await s.appBuilderPublish(a)}catch(L){S({title:"重新发布失败",message:(L==null?void 0:L.message)??String(L)})}},publishFailureBanner:x,onPublishFailureBannerClose:()=>b(null),onPublishFailureBannerFocusChat:()=>{}})}),h.jsx(Ate,{error:w,onClose:()=>S(null)})]})}function tne({headerMeta:e,connState:t,models:n,liveGitBranch:r,liveWorktreeRoot:i,onOpenConfig:s,onForceStop:o,cronActiveCount:a,onCronClick:l,lines:c,pendingPermissions:u,procAlive:d,rewindableUserMessageIds:f,onPermissionRespond:p,onPermissionInterrupt:m,onRewind:v,onFork:y,onQuickAsk:_,topSlot:x,realtimeQuestionAnswers:b,onSubmitQuestion:w,onCancelQuestion:S,liveQuestionToolUseIds:k,api:T,cwd:N,tool:L,sessionKey:P,onSend:O,awaitingUser:I,onAbort:R,onNewSession:j,onClearSession:z,chatRootRef:$,chatBodyRef:F,topSentinelRef:A,drawers:B,xtermSlot:E,fileSharingScope:H,onShareFile:q,onOpenInTab:M,onPreviewMarkdown:re,onOpenFiles:oe,onTogglePin:V,isHolded:pe,onToggleHold:Oe,personaName:ie,onOpenPersona:Me}){return h.jsx(vY,{children:h.jsxs("div",{ref:$,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-0",children:[h.jsx(lZ,{meta:e,...L?{tool:L}:{},connState:t,...n?{models:n}:{},...r!==void 0?{liveGitBranch:r}:{},...i!==void 0?{liveWorktreeRoot:i}:{},...s?{onOpenConfig:s}:{},...o?{onForceStop:o}:{},cronActiveCount:a,...l?{onCronClick:l}:{},...oe?{onOpenFiles:oe}:{},...V?{onTogglePin:V}:{},isHolded:pe??!1,...Oe?{onToggleHold:Oe}:{},...ie?{personaName:ie}:{},...Me?{onOpenPersona:Me}:{}}),h.jsxs("div",{ref:F,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none"},children:[A?h.jsx("div",{ref:A,"data-testid":"top-sentinel","aria-hidden":"true",style:{height:1}}):null,h.jsx(BR,{lines:c,...p?{onPermissionRespond:p}:{},...m&&d?{onPermissionInterrupt:m}:{},topSlot:x,...v?{onRewind:v}:{},rewindableUserMessageIds:f,...y?{onFork:y}:{},..._?{onQuickAsk:_}:{},realtimeQuestionAnswers:b,onSubmitQuestion:w,...S?{onCancelQuestion:S}:{},liveQuestionToolUseIds:k,...H?{fileSharingScope:H}:{},...q?{onShareFile:q}:{},...M?{onOpenInTab:M}:{},...re?{onPreviewMarkdown:re}:{}})]}),E,h.jsx(oZ,{meta:e,...T?{api:T}:{},cwd:N,...L?{tool:L}:{},sessionKey:P,onSend:O,awaitingUser:I,...R?{onAbort:R}:{},...j?{onNewSession:j}:{},...z?{onClearSession:z}:{}}),B]})})}function by({state:e,extras:t,onQuickAskInternal:n,onPreviewMdInternal:r}){const{session:i,api:s,models:o,liveGitBranch:a,liveWorktreeRoot:l,onNewSession:c,onTurnEnd:u,onOpenConfig:d,onFork:f,onQuickAsk:p,viewerRole:m,holdIds:v,onToggleHold:y}=t,{capabilities:_}=my(i.tool||"claude"),x=(_==null?void 0:_.features)??NN(i.tool),[b,w]=g.useState(null),[S,k]=g.useState(!1),[T,N]=g.useState(!1),L=Af(),P=!!s&&L.actionsLevel==="owner"&&x.fileSharing,O=MN(i.ownerPersonaId??null).persona,I=(O==null?void 0:O.label)??null,R=!!I&&!!i.ownerPersonaId,j=g.useCallback(()=>{N(!1),k(!0)},[]),z=g.useCallback(()=>{k(!1),N(!0)},[]),$=g.useCallback((Z,_e)=>{w({kind:Z,text:_e}),setTimeout(()=>{w(xe=>(xe==null?void 0:xe.text)===_e?null:xe)},2e3)},[]),F=Is(),A=zO(),B=rA(i.sessionId,i.toolSessionId),{events:E,pendingQuestions:H,clearQuestion:q,markQuestionSubmitted:M,status:re}=B,oe=e.historyLoading,V=hM(re);g.useEffect(()=>{Ae("chat-panel","sessionStatus",{sessionId:i.sessionId,sessionStatus:re,procAlive:V})},[re,V,i.sessionId]);const pe=e.lines,Oe=e.pendingPermissions,ie=Oe[0]??null,Me=g.useMemo(()=>S7(E),[E]),[Fe,We]=g.useState(!1),[ge,qe]=g.useState(null),[Gt,wt]=g.useState(()=>new Set);y7(s,i.sessionId,i.toolSessionId,x.observe);const Rt=g.useRef(i.sessionId);g.useEffect(()=>{if(Rt.current=i.sessionId,!x.rewind){qe(null);return}let Z=!1;return qe(null),(async()=>{try{const _e=await s.sessionRewindableMessageIds(i.sessionId);if(Z)return;qe(new Set(_e.userMessageIds))}catch{Z||qe(null)}})(),()=>{Z=!0}},[s,i.sessionId,x.rewind]);const ln=g.useCallback(()=>{const Z=i.sessionId;s.sessionRewindableMessageIds(Z).then(_e=>{Rt.current===Z&&qe(new Set(_e.userMessageIds))}).catch(()=>{})},[s,i.sessionId]),Bt=g.useMemo(()=>{if(ge!==null){const Ye=new Set(ge);for(const hi of Gt)Ye.delete(hi);return Ye}const Z=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),_e=new Set;let xe=null;for(const Ye of pe)Ye.kind==="user-text"?xe=Ye.uuid??null:xe&&Ye.kind==="tool-call"&&Z.has(Ye.tool)&&!Gt.has(xe)&&_e.add(xe);return _e},[pe,Gt,ge]),at=g.useRef(u);at.current=u,b7(i.sessionId,i.toolSessionId,()=>{pn(null),wt(new Set)});const Ue=DZ({sessionStatus:re}),nt=g.useRef(null);g.useEffect(()=>{var xe;const Z=nt.current,_e=(Z==null?void 0:Z.sid)===i.sessionId;_e&&Z.phase===Ue||(nt.current={sid:i.sessionId,phase:Ue},Ae("session-phase",Ue,{sid:i.sessionId,phase:Ue,prev:_e?Z.phase:null,desc:jZ[Ue]}),_e&&Z.phase==="turn-running"&&Ue!=="turn-running"&&((xe=at.current)==null||xe.call(at),ln()))},[Ue,i.sessionId,ln]);const mt=g.useCallback(()=>{s.sessionInterrupt(i.sessionId).catch(()=>{})},[s,i.sessionId]),[Xt,pn]=g.useState(null),U=g.useCallback(Z=>{pn(Z)},[]),[Q,ve]=g.useState(!1),Se=g.useCallback(()=>{s.sessionStop(i.sessionId).catch(()=>{}),ve(!1)},[s,i.sessionId]),J=g.useCallback(Z=>{s.pinSession(i.sessionId,Z).catch(_e=>{Ae("chat-panel","pinSession failed",{err:_e==null?void 0:_e.message})})},[s,i.sessionId]),Xe=(v==null?void 0:v.has(i.sessionId))??!1,Yt=g.useCallback(Z=>{y==null||y(i.sessionId,Z)},[y,i.sessionId]),Zt=g.useRef(0),ue=g.useRef(null);g.useEffect(()=>{const Z=_e=>{if(_e.key!=="Escape")return;if(!V){Zt.current=0;return}if(_e.isComposing)return;const Ye=_e.target;if(Ye&&Ye.closest("[data-cc-chat-root]")!==ue.current)return;const hi=Date.now();hi-Zt.current<2e3?(Zt.current=0,ve(!0)):(Zt.current=hi,mt())};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[mt,V]);const Ne=g.useRef(null),Qe=g.useRef(null),Dn=g.useRef(!0),Qt=g.useRef(null),il=g.useRef(0),Ao=g.useRef(0);g.useEffect(()=>{Dn.current=!0,Qt.current=null,il.current=0,Ao.current=0},[i.sessionId]),g.useEffect(()=>{We(!1)},[i.sessionId]);const xu=g.useRef(e);xu.current=e;const yu=g.useCallback(()=>{var xe;const Z=Ne.current;if(!Z||Qt.current!==null)return;const _e=xu.current;_e.historyDone||_e.historyLoading||(Qt.current={distFromBottom:Z.scrollHeight-Z.scrollTop},(xe=_e.loadMoreHistory)==null||xe.call(_e))},[]);g.useEffect(()=>{const Z=Ne.current,_e=Qe.current;if(!Z||!_e)return;const xe=new IntersectionObserver(Ye=>{for(const hi of Ye)hi.isIntersecting&&yu()},{root:Z,threshold:0});return xe.observe(_e),()=>xe.disconnect()},[yu]),g.useEffect(()=>{const Z=Ne.current;if(!Z)return;const _e=150,xe=Ye=>{Date.now()<Ao.current&&(Ye.preventDefault(),Ao.current=Date.now()+_e)};return Z.addEventListener("wheel",xe,{passive:!1}),()=>Z.removeEventListener("wheel",xe)},[]),g.useEffect(()=>{const Z=Ne.current;if(!Z)return;const _e=32,xe=()=>{const Ye=Z.scrollHeight-Z.scrollTop-Z.clientHeight;Dn.current=Ye<=_e};return Z.addEventListener("scroll",xe,{passive:!0}),()=>Z.removeEventListener("scroll",xe)},[]),g.useLayoutEffect(()=>{const Z=Ne.current;if(!Z)return;const _e=il.current,xe=pe.length;il.current=xe;const Ye=Qt.current;if(Ye!==null&&xe>_e){Qt.current=null,Z.scrollTop=Z.scrollHeight-Ye.distFromBottom,Ao.current=Date.now()+200;return}Ye!==null&&(Qt.current={distFromBottom:Z.scrollHeight-Z.scrollTop}),Dn.current&&(Z.scrollTop=Z.scrollHeight)},[pe,ie==null?void 0:ie.requestId]);const lp=g.useMemo(()=>{const Z={};for(const[_e,xe]of Object.entries(H))xe.submittedAnswers&&(Z[_e]=xe.submittedAnswers);return Z},[H]),cp=g.useMemo(()=>new Set(Object.keys(H)),[H]),bu=g.useCallback(async(Z,_e)=>{try{await s.answerQuestion({sessionId:i.sessionId,toolUseId:Z,answers:_e}),M(Z,_e)}catch{}},[s,i.sessionId,M]),jo=g.useCallback(async Z=>{try{await s.cancelQuestion({sessionId:i.sessionId,toolUseId:Z}),q(Z)}catch{}},[s,i.sessionId,q]),Do=g.useCallback(async(Z,_e)=>{var xe;if(ie)try{await((xe=e.respondPermission)==null?void 0:xe.call(e,ie.requestId,Z?"allow":"deny"))}catch{}},[e,ie]),sl=g.useCallback(async()=>{const Z=i.sessionId;try{await s.sessionStop(Z)}catch{}e.clearSession?await e.clearSession():await s.sessionNew(Z)},[e,s,i.sessionId]),ol=g.useMemo(()=>oe&&pe.length===0?h.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:h.jsx(rr,{className:"w-4 h-4 text-text-400 animate-spin"})}):e.historyDone?null:h.jsx("div",{className:"flex justify-center py-2",children:h.jsx("button",{type:"button",onClick:()=>{var Z;return void((Z=e.loadMoreHistory)==null?void 0:Z.call(e))},disabled:oe,"data-testid":"history-load-more",className:"text-[12px] text-text-400 hover:text-text-200 cursor-pointer px-3 py-1 rounded-md border border-bg-300 hover:bg-bg-100 transition-colors disabled:opacity-60",children:oe?"加载中…":"Load earlier messages"})}),[oe,pe.length,e.historyDone,e.loadMoreHistory]),Ui=e.meta,Wi=h.jsxs(h.Fragment,{children:[i.toolSessionId&&x.subagents?h.jsx(pZ,{api:s,cwd:i.cwd,toolSessionId:i.toolSessionId}):null,Xt&&x.rewind?h.jsx(gZ,{open:!0,onOpenChange:Z=>{Z||pn(null)},api:s,sessionId:i.sessionId,userMessageId:Xt,lines:pe,procAlive:V,onNoChanges:Z=>{wt(_e=>{if(_e.has(Z))return _e;const xe=new Set(_e);return xe.add(Z),xe})}}):null,Q?h.jsx(nne,{onConfirm:Se,onCancel:()=>ve(!1)}):null,h.jsx(AZ,{open:Fe,onClose:()=>We(!1),jobs:Me})]}),al={kind:"session",sessionId:i.sessionId},wu=g.useCallback(async Z=>{if(s)try{await gte(s,F,i.sessionId,Z)}catch(_e){const xe=_e.message;Ae("chat-panel","open-in-tab failed",{err:xe}),$("err",`Open in tab 失败:${xe}`)}},[s,F,i.sessionId,$]),[zt,ll]=g.useState(!1),[cl,Tt]=g.useState(null),$t=g.useCallback(Z=>{if(r){r(Z);return}Tt(Z),ll(!0)},[r]),or=g.useCallback(async Z=>{if(!s)throw new Error("daemon api not ready");const _e=await gy(s,F,i.sessionId,Z,60),xe=await fetch(_e);if(!xe.ok)throw new Error(`fetch ${xe.status} ${xe.statusText}`);return await xe.text()},[s,F,i.sessionId]),Ln=g.useCallback(async(Z,_e)=>{if(s)try{const{url:xe}=await s.attachmentSignUrl({sessionId:i.sessionId,relPath:Z,ttlSeconds:86400,..._e?{view:_e}:{}}),Ye=await vte(xe);$(Ye?"ok":"err",Ye?"分享链接已复制到剪贴板(24h 有效)":"复制失败:请手动复制")}catch(xe){const Ye=xe.message;Ae("chat-panel","share-file failed",{err:Ye}),$("err",`生成分享链接失败:${Ye}`)}},[s,i.sessionId,$]);return h.jsxs(h.Fragment,{children:[h.jsx(tne,{headerMeta:Ui,connState:e.connState,...o?{models:o}:{},...a!==void 0?{liveGitBranch:a}:{},...l!==void 0?{liveWorktreeRoot:l}:{},...d?{onOpenConfig:d}:{},onForceStop:()=>ve(!0),cronActiveCount:Me.length,onCronClick:()=>We(!0),lines:pe,pendingPermissions:Oe,procAlive:V,rewindableUserMessageIds:Bt,onPermissionRespond:Do,onPermissionInterrupt:mt,onRewind:x.rewind?U:void 0,...f&&x.fork?{onFork:f}:{},...n&&x.fork?{onQuickAsk:n}:p&&x.fork?{onQuickAsk:p}:{},topSlot:ol,realtimeQuestionAnswers:lp,onSubmitQuestion:bu,onCancelQuestion:jo,liveQuestionToolUseIds:cp,api:s,cwd:i.cwd,...i.tool?{tool:i.tool}:{},sessionKey:i.sessionId,onSend:e.sendText,awaitingUser:Oe.length>0||Object.values(H).some(Z=>!Z.submittedAnswers),onAbort:mt,...c?{onNewSession:c}:{},onClearSession:sl,chatRootRef:ue,chatBodyRef:Ne,topSentinelRef:Qe,drawers:Wi,xtermSlot:A==="tui"&&V&&x.tui?h.jsx(Xee,{sessionId:i.sessionId,client:F},i.sessionId):null,fileSharingScope:al,...s?{onShareFile:Ln}:{},...s?{onOpenInTab:wu}:{},...s?{onPreviewMarkdown:$t}:{},...P?{onOpenFiles:j}:{},onTogglePin:J,isHolded:Xe,...y?{onToggleHold:Yt}:{},...R?{personaName:I}:{},...R?{onOpenPersona:z}:{}}),P&&s?h.jsx(tte,{api:s,open:S,onOpenChange:k,scope:al,sessionId:i.sessionId,onShareFile:Ln,onOpenInTab:wu}):null,s?h.jsx(yte,{open:zt,onOpenChange:ll,relPath:cl,loadMarkdown:or,onShare:cl?()=>void Ln(cl,"md-rendered"):void 0}):null,R&&s&&i.ownerPersonaId?h.jsx(fte,{api:s,open:T,onOpenChange:N,personaId:i.ownerPersonaId,personaName:I??"",...m?{viewerRole:m}:{}}):null,b?h.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:b.kind==="ok"?"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-[12px] text-emerald-700 shadow-md dark:text-emerald-300":"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive shadow-md",children:b.text}):null]})}function nne({onConfirm:e,onCancel:t}){return h.jsx("div",{role:"dialog","aria-modal":"true","data-testid":"force-stop-confirm",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:t,children:h.jsxs("div",{className:"max-w-sm w-[92%] rounded-lg border border-red-400/40 bg-bg-0 p-4 shadow-xl",onClick:n=>n.stopPropagation(),children:[h.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[h.jsx(Ac,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),h.jsx("div",{className:"text-[14px] text-text-100",children:"强制停止会话进程?会丢失 initialize / 预热缓存,下一次发送需要重新 spawn。"})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:t,className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button","data-testid":"force-stop-confirm-ok",onClick:e,className:"h-8 px-3 rounded-md bg-red-500 text-white text-[12px] font-medium hover:bg-red-600 cursor-pointer",children:"强制停止"})]})]})})}function rne({current:e,models:t,onSelect:n}){return h.jsxs("div",{children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-2",children:"Model"}),h.jsx("div",{className:"flex flex-wrap gap-1.5","data-testid":"config-model-selector",children:t.map(r=>{const i=(e||"")===r.id;return h.jsx("button",{type:"button",onClick:()=>n(r.id),"data-testid":`config-model-${r.id||"default"}`,className:ne("px-3 py-1.5 rounded-lg text-[12px] font-medium transition-colors cursor-pointer",i?"bg-accent text-white shadow-sm":"bg-bg-100 text-text-300 hover:bg-bg-200 hover:text-text-100"),children:r.label},r.id||"default")})})]})}function ine({current:e,modes:t,onSelect:n}){var i;const r=(i=t.find(s=>s.id===(e||"")))==null?void 0:i.description;return h.jsxs("div",{children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-2",children:"Permission Mode"}),h.jsx("div",{className:"flex flex-wrap gap-1.5","data-testid":"config-mode-selector",children:t.map(s=>{const o=(e||"")===s.id;return h.jsx("button",{type:"button",onClick:()=>n(s.id),"data-testid":`config-mode-${s.id||"default"}`,className:ne("px-3 py-1.5 rounded-lg text-[12px] font-medium transition-colors cursor-pointer",o?"bg-accent text-white shadow-sm":"bg-bg-100 text-text-300 hover:bg-bg-200 hover:text-text-100"),children:s.label},s.id||"default")})}),r?h.jsx("p",{className:"text-[11px] text-text-400 mt-1.5",children:r}):null]})}function sne({open:e,onOpenChange:t,session:n,onPatch:r,embedded:i=!1,viewerRole:s="owner"}){var m;const{capabilities:o}=my(e?n.tool||"claude":null),a=(o==null?void 0:o.models)??[],l=(o==null?void 0:o.permissionModes)??[],c=((m=o==null?void 0:o.configSchema.find(v=>v.name==="permissionMode"))==null?void 0:m.default)??"",u=n.permissionMode&&l.some(v=>v.id===n.permissionMode)?n.permissionMode:c,d=g.useMemo(()=>(o==null?void 0:o.configSchema.filter(v=>v.scope==="tool-specific"))??[],[o]),f=(o==null?void 0:o.toolSessionIdLabel)??"Tool Session ID";if(!e)return null;const p=h.jsxs("div",{className:"flex-1 min-h-0 flex flex-col px-4 py-4 gap-6 overflow-y-auto",children:[h.jsxs("div",{className:"shrink-0",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1",children:"Working Directory"}),h.jsx("div",{className:"text-[12px] font-mono text-text-300 bg-bg-100 rounded-lg px-3 py-2 truncate","data-testid":"config-cwd",title:n.cwd,children:n.cwd})]}),h.jsx("div",{className:"shrink-0",children:h.jsx(rne,{current:n.model??"",models:a,onSelect:v=>void r({model:v})})}),h.jsx("div",{className:"shrink-0",children:h.jsx(ine,{current:u,modes:l,onSelect:v=>void r({permissionMode:v})})}),d.length>0?h.jsx("div",{className:"shrink-0",children:h.jsx(one,{fields:d,session:n,onPatch:r})}):null,h.jsx("div",{className:"shrink-0",children:h.jsx(Hk,{testId:"config-session-id",label:"Clawd Session ID",value:n.sessionId})}),n.toolSessionId?h.jsx("div",{className:"shrink-0",children:h.jsx(Hk,{testId:"config-tool-session-id",label:f,value:n.toolSessionId})}):null]});return i?h.jsxs("div",{"data-testid":"config-drawer",className:"h-full w-full flex flex-col",children:[h.jsx("div",{className:"flex items-center px-4 py-3 border-b border-bg-300/30 shrink-0",children:h.jsx("span",{className:"text-[14px] font-semibold text-text-100",children:"Session Settings"})}),p]}):h.jsxs("div",{"data-testid":"config-drawer",className:"h-full w-full flex flex-col border-l border-bg-300/40 bg-bg-0 min-w-0",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bg-300/30 shrink-0",children:[h.jsx("span",{className:"text-[14px] font-semibold text-text-100",children:"Session Settings"}),h.jsx("button",{type:"button",onClick:()=>t(!1),"data-testid":"config-drawer-close",className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"Close",children:h.jsx(Rn,{className:"w-4 h-4"})})]}),p]})}function Hk({testId:e,label:t,value:n}){const[r,i]=g.useState(!1),s=g.useRef(null);g.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const o=()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(n).then(()=>{i(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>i(!1),2e3)},()=>{})};return h.jsxs("div",{"data-testid":e,children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1",children:t}),h.jsxs("button",{type:"button",onClick:o,"data-testid":`${e}-copy`,title:r?"Copied":`Copy: ${n}`,className:"w-full flex items-center gap-2 text-[12px] font-mono text-text-300 bg-bg-100 hover:bg-bg-200 rounded-lg px-3 py-2 transition-colors cursor-pointer text-left group",children:[h.jsx("span",{className:"truncate flex-1 min-w-0","data-testid":`${e}-value`,children:n}),r?h.jsx(Za,{className:"w-3.5 h-3.5 shrink-0 text-accent"}):h.jsx(su,{className:"w-3.5 h-3.5 shrink-0 opacity-60 group-hover:opacity-100 transition-opacity"})]})]})}function one({fields:e,session:t,onPatch:n}){return h.jsxs("div",{"data-testid":"config-advanced",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-2",children:"Advanced"}),h.jsx("div",{className:"space-y-3",children:e.map(r=>h.jsx(ane,{field:r,session:t,onPatch:n},r.name))})]})}function ane({field:e,session:t,onPatch:n}){if(e.type!=="select"||!e.options)return null;const r=t[e.name]??"",i=e.options.some(s=>s.value===r)?r:e.default??"";return h.jsxs("div",{"data-testid":`config-advanced-${e.name}`,children:[h.jsx("div",{className:"text-[11px] text-text-400 mb-1.5",children:e.label}),h.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.options.map(s=>{const o=i===s.value;return h.jsx("button",{type:"button","data-testid":`config-advanced-${e.name}-${s.value||"default"}`,onClick:()=>void n({[e.name]:s.value}),className:ne("px-3 py-1.5 rounded-lg text-[12px] font-medium transition-colors cursor-pointer",o?"bg-accent text-white shadow-sm":"bg-bg-100 text-text-300 hover:bg-bg-200 hover:text-text-100"),children:s.label},s.value||"default")})})]})}function lne(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitBranch(t);i(l.branch??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{branch:r,loading:s,refresh:()=>void a()}}function cne(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitRoot(t);i(l.gitRoot??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{worktreeRoot:r,loading:s,refresh:()=>void a()}}function une({api:e,session:t,focused:n,totalPanes:r,onFocus:i,onClose:s,onNewSession:o,onOpenConfig:a,onConfigPatch:l,onFork:c,onQuickAsk:u,className:d,viewerRole:f="owner",holdIds:p,onToggleHold:m}){const{capabilities:v}=my(t.tool),[y,_]=g.useState(0),[x,b]=g.useState(!1),{initialSize:w,setSize:S}=cA("clawd:panel:config-px",360),{branch:k}=lne(e,t.cwd,y),{worktreeRoot:T}=cne(e,t.cwd,y),N=r>1,L=P=>{P==="desktop"?b(!0):a()};return h.jsxs("div",{className:`group/pane relative flex-1 ${d??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${N?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:i,"data-testid":`session-pane-${t.sessionId}`,children:[h.jsxs(Ix,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx($c,{id:"chat",minSize:"400px",children:h.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:h.jsx(dne,{api:e,session:t,models:v==null?void 0:v.models,liveGitBranch:k,liveWorktreeRoot:T,onNewSession:o,onTurnEnd:()=>_(P=>P+1),onOpenConfig:L,onFork:c,onQuickAsk:u,viewerRole:f,holdIds:p,onToggleHold:m})})}),x&&h.jsxs(h.Fragment,{children:[h.jsx(Mx,{className:"hidden md:block w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx($c,{id:"config",defaultSize:`${w}px`,minSize:"360px",maxSize:"560px",onResize:P=>S(P.inPixels),children:h.jsx("div",{className:"hidden md:flex h-full",children:h.jsx(sne,{open:x,onOpenChange:b,session:t,onPatch:l,viewerRole:f})})})]})]}),N&&h.jsx("button",{type:"button",onClick:P=>{P.stopPropagation(),s()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:h.jsx(Rn,{className:"w-3.5 h-3.5"})})]})}function dne({api:e,session:t,models:n,liveGitBranch:r,liveWorktreeRoot:i,onNewSession:s,onTurnEnd:o,onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:u,holdIds:d,onToggleHold:f}){return h.jsx(Jte,{extras:{session:t,api:e,...n?{models:n}:{},...r!==void 0?{liveGitBranch:r}:{},...i!==void 0?{liveWorktreeRoot:i}:{},onNewSession:s,onTurnEnd:o,onOpenConfig:a,...l?{onFork:p=>{l(p)}}:{},...c?{onQuickAsk:p=>{c(p)}}:{},...u?{viewerRole:u}:{},...d?{holdIds:d}:{},...f?{onToggleHold:f}:{}}})}function hne({personas:e,sessions:t,api:n,selfPrincipalId:r,selectedPersonaId:i,selectedSessionId:s,selectedSession:o,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,onCloseSession:f,onConfigPatch:p}){return h.jsxs("div",{className:"flex h-screen min-h-0 bg-bg-50","data-testid":"guest-share-page",children:[h.jsx("aside",{className:"w-[280px] shrink-0 overflow-y-auto border-r border-border bg-bg-50",children:h.jsx(BH,{personas:e,sessions:t,activePersonaId:i,activeSessionId:s,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,showCopyResume:!1,treatSessionsAsRoots:!0,...r?{ownerPrincipalId:r}:{},isPersonaExpanded:()=>!0})}),h.jsx("main",{className:"flex-1 min-w-0 min-h-0 flex",children:o?h.jsx(une,{api:n,session:o,focused:!0,totalPanes:1,onFocus:()=>{},onClose:f,onNewSession:()=>{},onOpenConfig:()=>{},onConfigPatch:p,viewerRole:"guest"}):h.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-xs text-text-400","data-testid":"guest-share-empty",children:"选择左侧 persona 开始对话"})})]})}function fne(){const e=Is(),t=g.useMemo(()=>new V_(e),[e]),n=oB(e),{sessions:r,refresh:i}=aB(n),{personas:s}=RN(),o=fB(),a=g.useMemo(()=>{const w=window.location.pathname.match(/^\/s\/([^/]+)/);return w?decodeURIComponent(w[1]):null},[]),l=g.useMemo(()=>r.filter(w=>!w.ephemeral),[r]),c=g.useMemo(()=>a?s.filter(w=>w.personaId===a):s,[s,a]),[u,d]=g.useState(null),[f,p]=g.useState(null),[m,v]=g.useState(null);g.useEffect(()=>{let w=!1;return e.request("whoami",{}).then(S=>{w||d(S.capability.id)}).catch(()=>{}),()=>{w=!0}},[e]),g.useEffect(()=>{a&&p(a)},[a]);const y=g.useCallback(async(w,S)=>{const k=await t.sessionCreate({ownerPersonaId:w,...S.trim()?{label:S.trim()}:{}});await i(),p(w),v(k.sessionId)},[t,i]),_=g.useCallback(async w=>{await t.sessionDelete(w),await i(),v(S=>S===w?null:S)},[t,i]),x=g.useCallback(async(w,S)=>{await t.sessionUpdate(w,{label:S.label,iconKey:S.iconKey===null?"":S.iconKey}),await i()},[t,i]),b=g.useMemo(()=>l.find(w=>w.sessionId===m)??null,[l,m]);return h.jsx(q_.Provider,{value:o,children:h.jsx(hne,{personas:c,sessions:l,api:t,selfPrincipalId:u,selectedPersonaId:f,selectedSessionId:m,selectedSession:b,onSelectPersona:p,onSelectSession:v,onCreateSession:(w,S)=>void y(w,S),onDeleteSession:w=>void _(w),onEditSession:(w,S)=>void x(w,S),onCloseSession:()=>v(null),onConfigPatch:async()=>{}})})}const Uk="https://app.ttcadvisory.com";function pne({onAuthed:e}){const[t,n]=g.useState(!1),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>()=>{s.current&&window.removeEventListener("message",s.current)},[]);const o=g.useCallback(()=>{s.current&&(window.removeEventListener("message",s.current),s.current=null),n(!0),i(null);const a=window.location.origin,l=`${Uk}/auth/authorize?callback_url=${encodeURIComponent(a)}&auto=1`,c=async d=>{if(d.origin!==Uk)return;const f=d.data;if((f==null?void 0:f.type)==="AUTH_CANCEL"){u(),n(!1);return}if(!((f==null?void 0:f.type)!=="AUTH_SUCCESS"||!f.token)){u();try{const p=await fetch(`${window.location.origin}/share/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ttcToken:f.token})});if(!p.ok){const v=await p.json().catch(()=>({}));throw new Error(v.code??`exchange failed (${p.status})`)}const m=await p.json();if(!m.visitorToken)throw new Error("no visitorToken in response");e(m.visitorToken)}catch(p){i(p instanceof Error?p.message:String(p)),n(!1)}}},u=()=>{window.removeEventListener("message",c),s.current=null};s.current=d=>void c(d),window.addEventListener("message",s.current),window.open(l,"ttc-login","width=480,height=640")},[e]);return h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 font-sans text-text-100","data-testid":"guest-login",children:h.jsxs("div",{className:"flex w-full max-w-xs flex-col gap-3 rounded-lg border border-border bg-bg-100 px-5 py-6",children:[h.jsx("h1",{className:"text-base font-semibold",children:"登录后进入分享"}),h.jsx("p",{className:"text-[11px] leading-snug text-text-400",children:"使用飞书账号登录,即可在浏览器里与分享给你的 persona 交互,无需安装。"}),r?h.jsxs("p",{className:"text-[11px] leading-snug text-error","data-testid":"guest-login-error",children:["登录失败:",r]}):null,h.jsx("button",{type:"button",disabled:t,onClick:()=>o(),"data-testid":"guest-login-button",className:"w-full rounded border border-border bg-bg-50 px-2 py-1.5 text-xs text-text-200 transition-colors hover:bg-text-100/5 hover:text-text-100 disabled:opacity-50",children:t?"请在弹窗中完成授权…":"飞书登录"})]})})}const j0="clawd-visitor:token";function mne(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}function gne(){return{async getUrl(e){const t=localStorage.getItem(j0);if(!t)throw new Error("NO_VISITOR_TOKEN");const n=mne(window.location,{});return await wN(e).upsert({id:"guest",name:"访客",mode:"remote",url:n,token:t}),{url:n}}}}function vne(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function _ne(){const e=Is(),t=g.useMemo(()=>sB(e),[e]);return h.jsx($O,{cache:t.cache,children:h.jsx(UO,{children:h.jsx(fne,{})})})}function xne({host:e}){const[t]=g.useState(()=>localStorage.getItem(j0)),[n,r]=g.useState(!1),[i,s]=g.useState(null);return g.useEffect(()=>vne(e),[e]),g.useEffect(()=>{if(!t)return;let o=!1;return gne().getUrl(e).then(()=>{o||r(!0)}).catch(a=>{o||s(a instanceof Error?a.message:String(a))}),()=>{o=!0}},[e,t]),t?h.jsx(L1,{host:e,children:h.jsx(mb,{children:i?h.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-center text-xs text-error","data-testid":"guest-share-connect-error",children:["连接失败:",i]}):n?h.jsx(BO,{host:e,children:h.jsx(_ne,{})}):h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-xs text-text-400",children:"正在连接…"})})}):h.jsx(L1,{host:e,children:h.jsx(mb,{children:h.jsx(pne,{onAuthed:o=>{localStorage.setItem(j0,o),window.location.reload()}})})})}function yne({filePath:e,oldString:t,newString:n,content:r}){const i=g.useMemo(()=>r!=null?r.split(/\r?\n/).map(s=>({type:"add",text:s})):bne(t??"",n??""),[t,n,r]);return h.jsxs("div",{"data-testid":"inline-diff",className:"min-w-0 max-w-full rounded-lg border border-bg-300/60 bg-bg-50 overflow-hidden text-[12px] font-mono",children:[h.jsx("div",{className:"flex min-w-0 items-center gap-2 px-3 py-1.5 border-b border-bg-300/40 bg-bg-100/30",children:h.jsx("span",{className:"min-w-0 text-text-400 truncate",title:e,children:e})}),h.jsx("div",{className:"max-h-[320px] max-w-full overflow-auto",children:i.map((s,o)=>h.jsxs("div",{"data-testid":`diff-line-${s.type}`,className:ne("flex min-w-max gap-2 px-3 py-0.5 whitespace-pre",s.type==="add"?"bg-success/10 text-success":s.type==="remove"?"bg-error/10 text-error":"text-text-300"),children:[h.jsx("span",{className:"w-3 shrink-0 select-none opacity-60",children:s.type==="add"?"+":s.type==="remove"?"-":" "}),h.jsx("span",{className:"flex-1",children:s.text||" "})]},o))})]})}function bne(e,t){const n=e.split(/\r?\n/),r=t.split(/\r?\n/),i=n.length,s=r.length,o=Array.from({length:i+1},()=>new Array(s+1).fill(0));for(let u=i-1;u>=0;u--)for(let d=s-1;d>=0;d--)o[u][d]=n[u]===r[d]?o[u+1][d+1]+1:Math.max(o[u+1][d],o[u][d+1]);const a=[];let l=0,c=0;for(;l<i&&c<s;)n[l]===r[c]?(a.push({type:"equal",text:n[l]}),l++,c++):o[l+1][c]>=o[l][c+1]?(a.push({type:"remove",text:n[l]}),l++):(a.push({type:"add",text:r[c]}),c++);for(;l<i;)a.push({type:"remove",text:n[l++]});for(;c<s;)a.push({type:"add",text:r[c++]});return a}function wne({items:e}){return e.length===0?null:h.jsxs("div",{"data-testid":"todo-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1.5",children:"Todos"}),h.jsx("ul",{className:"flex flex-col gap-1",children:e.map((t,n)=>{const r=t.status==="in_progress"&&t.activeForm||t.content;return h.jsxs("li",{"data-testid":`todo-item-${t.status}`,className:"flex items-start gap-2",children:[h.jsx(Sne,{status:t.status}),h.jsx("span",{className:ne("flex-1 leading-snug",t.status==="completed"?"text-text-400 line-through":t.status==="in_progress"?"text-text-100 font-medium":"text-text-200"),children:r})]},n)})})]})}function Sne({status:e}){return e==="completed"?h.jsx(jf,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?h.jsx(rr,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):h.jsx(DN,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function kne(e){const t=e??{};return Array.isArray(t.todos)?t.todos.map(n=>{if(!n||typeof n!="object")return null;const r=n,i=typeof r.content=="string"?r.content:"",s=r.status==="pending"||r.status==="in_progress"||r.status==="completed"?r.status:"pending",o=typeof r.activeForm=="string"?r.activeForm:void 0;return{content:i,status:s,activeForm:o}}).filter(n=>n!==null):[]}function Cne({description:e,prompt:t,subagentType:n}){return h.jsxs("div",{"data-testid":"task-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsxs("div",{className:"flex items-center gap-2 text-text-200 font-medium",children:[h.jsx(K_,{className:"w-3.5 h-3.5 text-accent shrink-0"}),h.jsx("span",{className:"truncate",children:e||"subagent task"}),n?h.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded-md text-[10px] font-mono bg-accent/10 text-accent",children:n}):null]}),t?h.jsx("div",{className:"mt-1 text-[12px] text-text-400 leading-snug line-clamp-3",children:t}):null]})}function Ene(e){const t=e??{};return{description:typeof t.description=="string"?t.description:"",prompt:typeof t.prompt=="string"?t.prompt:void 0,subagentType:typeof t.subagent_type=="string"?t.subagent_type:void 0}}const Nne={render:({input:e})=>st.createElement(wne,{items:kne(e)})},Tne={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=Ene(e);return st.createElement(Cne,{description:t,prompt:n,subagentType:r})}},dA={render:({input:e,output:t,error:n,pending:r,fileScope:i,onShareFile:s,onOpenInTab:o,onPreviewMarkdown:a})=>{const l=Ine(e),c=l?st.createElement(yne,{filePath:l.filePath,oldString:l.oldString,newString:l.newString,content:l.content}):void 0;return st.createElement(MR,{tool:Pne(e),input:e,output:t,error:n,pending:r,expandedBody:c,...i?{fileScope:i}:{},...s?{onShareFile:s}:{},...o?{onOpenInTab:o}:{},...a?{onPreviewMarkdown:a}:{}})}};function Pne(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function Ine(e){const t=e??{},n=typeof t.file_path=="string"?t.file_path:null;if(!n)return null;const r=typeof t.old_string=="string"?t.old_string:void 0,i=typeof t.new_string=="string"?t.new_string:void 0,s=typeof t.content=="string"?t.content:void 0;return r==null&&i==null&&s==null?null:{filePath:n,oldString:r,newString:i,content:s}}pu.register("claude","TodoWrite",Nne);pu.register("claude","Task",Tne);pu.register("claude","Edit",dA);pu.register("claude","Write",dA);const hA=document.getElementById("root");if(!hA)throw new Error("guest-main: #root not found");const Rne=qj({});Fm.createRoot(hA).render(h.jsx(st.StrictMode,{children:h.jsx(xne,{host:Rne})}));
557
+ */var qee=2,Kee=1,Gee=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var d;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((d=this._terminal.options.overviewRuler)==null?void 0:d.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),i=Math.max(0,parseInt(n.getPropertyValue("width"))),s=window.getComputedStyle(this._terminal.element),o={top:parseInt(s.getPropertyValue("padding-top")),bottom:parseInt(s.getPropertyValue("padding-bottom")),right:parseInt(s.getPropertyValue("padding-right")),left:parseInt(s.getPropertyValue("padding-left"))},a=o.top+o.bottom,l=o.right+o.left,c=r-a,u=i-l-t;return{cols:Math.max(qee,Math.floor(u/e.css.cell.width)),rows:Math.max(Kee,Math.floor(c/e.css.cell.height))}}};let Lm;function Om(){return{count:0,byteSum:0,firstT:null,lastT:null}}const Bm=32,Lk=320;function Xee({sessionId:e,client:t}){const n=g.useRef(null),r=g.useRef(null),i=g.useRef(null),s=g.useRef([]),o=g.useRef(Om()),a=g.useRef(!1),[l,c]=g.useState("collapsed"),[u,d]=g.useState(null);g.useEffect(()=>{const v=n.current;if(!v)return;let y=!1;const _=(T,N)=>getComputedStyle(document.documentElement).getPropertyValue(T).trim()||N,x=_("--bg-0","#1B1B1B"),b=_("--text-100","#ECECEC"),w=new Vee({fontFamily:"ui-monospace, SF Mono, Menlo, monospace",fontSize:12,lineHeight:1.2,theme:{background:x,foreground:b},minimumContrastRatio:4.5,cursorBlink:!0,convertEol:!1,scrollback:5e3,allowProposedApi:!0,cols:120,rows:40}),S=new Gee;w.loadAddon(S),Ae("xterm-mount",{sessionId:e,hostChildCount:v.childNodes.length}),Lm!==e&&(Ae("xterm-trace",`===== SWITCH ${Lm??"(initial)"} → ${e} =====`),Lm=e),Ae("xterm-trace","effect-setup-start",{sessionId:e,t:performance.now()}),o.current=Om(),w.open(v);const k=w.onData(T=>{const N=btoa(unescape(encodeURIComponent(T)));t.request("session:pty:input",{sessionId:e,data:N}).catch(()=>{})});return(async()=>{var R;let T=0,N=null,L=null;try{Ae("xterm-trace","snapshot-rpc-start",{sessionId:e,t:performance.now()});const j=await t.request("session:pty:snapshot",{sessionId:e});if(Ae("xterm-trace","snapshot-rpc-resolved",{sessionId:e,cancelled:y,byteLen:((R=j==null?void 0:j.data)==null?void 0:R.length)??0,atSeq:j==null?void 0:j.atSeq,t:performance.now()}),y)return;if(j!=null&&j.ok&&typeof j.data=="string"&&j.data.length>0){const z=atob(j.data),$=new Uint8Array(z.length);for(let F=0;F<z.length;F++)$[F]=z.charCodeAt(F);N=$}j!=null&&j.ok&&typeof j.atSeq=="number"&&(T=j.atSeq),j!=null&&j.ok&&j.popupKind!=null&&(L=j.popupKind)}catch{}if(y)return;r.current=w,i.current=S;let P=!1,O;const I=w.onRender(()=>{if(!P){P=!0;try{S.fit(),N&&w.write(N),Ae("xterm-trace","snapshot-flush",{sessionId:e,atSeq:T,pendingFrameCount:s.current.length,frameStatsBeforeFlush:{...o.current},t:performance.now()}),o.current=Om();const j=s.current;s.current=[];let z=0;for(const $ of j){if($.seq!==void 0&&$.seq<=T){z++;continue}w.write($.bytes)}z>0&&Ae("xterm-trace","snapshot-flush-dropped",{sessionId:e,dropped:z,atSeq:T}),a.current=!0,L!=null&&(d(L),c("expanded"),requestAnimationFrame(()=>w.focus())),t.request("session:pty:resize",{sessionId:e,cols:w.cols,rows:w.rows}).catch(()=>{})}catch{}w.scrollToBottom(),O?O():setTimeout(()=>O==null?void 0:O(),0)}});O=()=>I.dispose()})(),()=>{Ae("xterm-trace","cleanup-start",{sessionId:e,pendingFrameCount:s.current.length,termReady:a.current,frameStatsThisMount:{...o.current},t:performance.now()}),y=!0,k.dispose(),w.dispose(),r.current=null,i.current=null,a.current=!1,s.current=[],Ae("xterm-trace","cleanup-cleared-pending",{sessionId:e,t:performance.now()})}},[e,t]),g.useEffect(()=>{const v=t.on("session:pty",_=>{const x=_;if(x.sessionId!==e||typeof x.data!="string")return;const b=o.current;b.count++,b.byteSum+=x.data.length;const w=performance.now();b.firstT===null&&(b.firstT=w),b.lastT=w;try{const S=atob(x.data),k=new Uint8Array(S.length);for(let T=0;T<S.length;T++)k[T]=S.charCodeAt(T);a.current&&r.current?r.current.write(k):s.current.push({seq:x.seq,bytes:k})}catch{}}),y=t.on("session:control",_=>{const x=_;if(x.sessionId===e)switch(x.kind){case"popup_open":(x.popupKind==="permission"||x.popupKind==="question")&&(d(x.popupKind),c("expanded"),requestAnimationFrame(()=>{var b;return(b=r.current)==null?void 0:b.focus()}));break;case"popup_close":d(null),c("collapsed");break}});return()=>{v(),y(),Ae("xterm-trace","cleanup-off-listener",{sessionId:e,t:performance.now()})}},[e,t]),g.useEffect(()=>{const v=n.current;if(!v)return;let y=0,_=0;const x=()=>{const w=i.current,S=r.current;if(!(!w||!S)){try{w.fit()}catch{return}try{S.refresh(0,S.rows-1)}catch{}S.cols===y&&S.rows===_||(y=S.cols,_=S.rows,t.request("session:pty:resize",{sessionId:e,cols:S.cols,rows:S.rows}).catch(()=>{}))}},b=new ResizeObserver(()=>x());return b.observe(v),()=>b.disconnect()},[e,t]);const f=()=>{c(v=>{const y=v==="collapsed"?"expanded":"collapsed";return y==="expanded"&&requestAnimationFrame(()=>{var _;return(_=r.current)==null?void 0:_.focus()}),y})},p=l==="expanded"?Lk:Bm,m=Lk-Bm;return h.jsxs("div",{className:"border-t border-border bg-bg-0 overflow-hidden",style:{height:p},"data-testid":"xterm-panel","data-state":l,"data-mode":"tui","data-popup-kind":u??"",children:[h.jsxs("button",{type:"button",onClick:f,className:"flex items-center justify-between w-full px-3 py-1 text-xs text-text-200 bg-bg-200 hover:bg-bg-300 cursor-pointer border-b border-border",style:{height:Bm,flexShrink:0},"data-testid":"xterm-panel-toggle",children:[h.jsxs("span",{className:"font-mono",children:[u==="permission"&&"⚠️ CC 需要权限确认 — 在下方终端按数字键 / Enter 选择",u==="question"&&"❓ CC 在问问题 — 在下方终端用 ↑/↓ + Enter 选择",u===null&&(l==="collapsed"?"▴ 展开原生 TUI 终端":"▾ 收起 TUI 终端")]}),h.jsx("span",{className:"text-text-200 text-[10px] opacity-60",children:l==="expanded"?"点击收起":"点击展开"})]}),h.jsx("div",{ref:n,className:"p-1",style:{height:m},"data-testid":"xterm-panel-host"})]})}function rA(e,t){const n=ko(),r=e?`session/${e}`:"",i=si(r)??Rc,s=g.useCallback(d=>{!e||!r||n.setData(r,f=>TN(f??Rc,d,e))},[n,r,e]),o=g.useCallback(()=>{e&&s({type:"session:change",sessionId:e})},[s,e]),a=g.useCallback(d=>{e&&s({type:"permission:clear",sessionId:e,requestId:d})},[s,e]),l=g.useCallback(d=>{e&&s({type:"permission:request",sessionId:e,requestId:d.requestId,tool:d.tool,input:d.input,...d.toolUseId?{toolUseId:d.toolUseId}:{}})},[s,e]),c=g.useCallback(d=>{e&&s({type:"session:question:clear",sessionId:e,toolUseId:d})},[s,e]),u=g.useCallback((d,f)=>{e&&s({type:"session:question:submitted",sessionId:e,toolUseId:d,answers:f})},[s,e]);return{...i,reset:o,clearPermission:a,restorePermission:l,clearQuestion:c,markQuestionSubmitted:u}}function my(e){const t=si(e?`capabilities/${e}`:"");return e?{capabilities:t??null,loading:!t}:{capabilities:null,loading:!1}}const Yee=50;function Zee({api:e,sessionId:t,toolSessionId:n,pageSize:r=Yee}){const[i,s]=g.useState({messages:[],total:0,loading:!1,hasMore:!1,error:null}),o=g.useRef(0),a=g.useRef(n),l=g.useRef(null),c=g.useRef(0);g.useEffect(()=>{const d=a.current;if(a.current=n,!(l.current!==t)&&!(typeof d=="string"&&d!==n))return;if(s({messages:[],total:0,loading:!1,hasMore:!1,error:null}),o.current=0,!t){l.current=null;return}l.current=t;const m=++c.current;s(v=>({...v,loading:!0,error:null})),(async()=>{try{const v=await e.historyRead({sessionId:t,limit:r});if(m!==c.current)return;o.current=v.offset,s({messages:v.messages??[],total:v.total??0,loading:!1,hasMore:v.offset>0,error:null})}catch(v){if(m!==c.current)return;s({messages:[],total:0,loading:!1,hasMore:!1,error:v.message??"history load failed"})}})()},[e,t,n,r]);const u=g.useCallback(async()=>{if(!t)return;const d=o.current;if(d<=0)return;const f=Math.max(0,d-r),p=d-f;s(m=>({...m,loading:!0,error:null}));try{const m=await e.historyRead({sessionId:t,limit:p,offset:f});o.current=m.offset,s(v=>({...v,messages:[...m.messages??[],...v.messages],loading:!1,hasMore:m.offset>0}))}catch(m){s(v=>({...v,loading:!1,error:m.message??"load more failed"}))}},[e,t,r]);return{...i,loadMore:u}}function Ok(e){const t=np(e);return t.commandName?t.commandArgs?`${t.commandName} ${t.commandArgs}`:t.commandName:e}function Bk(e){return e.kind==="user-text"||e.kind==="user-meta"&&e.metaKind==="slash-command"}function Qee(e,t){const n=t.find(Bk);if(!n)return e;const r=Ok(n.text);for(let i=e.length-1;i>=0;i--){const s=e[i];if(Bk(s)&&Ok(s.text)===r)return e.slice(0,i)}return e}const Jee=1e6;function ete(e){if(!e)return;const t=e.contextUsage,n=e.contextWindowSize;if(!t||!n||n<=0)return;const r=t.inputTokens+(t.cacheReadTokens??0)+(t.cacheCreateTokens??0);if(!(r<=0))return Math.round(r/n*100)}function iA(e){const t=Is(),n=g.useMemo(()=>new V_(t),[t]),r=si("sessions"),i=g.useMemo(()=>r==null?void 0:r.find(F=>F.sessionId===e),[r,e]),s=i==null?void 0:i.toolSessionId,o=i==null?void 0:i.tool,a=rA(e),{events:l,pendingPermissions:c,status:u,clearPermission:d,restorePermission:f}=a,p=Zee({api:n,sessionId:e,toolSessionId:s}),m=g.useMemo(()=>p.messages.filter(F=>!F.isSidechain),[p.messages]),v=g.useMemo(()=>UR(m,0,o),[m,o]),y=c[0]??null,_=g.useMemo(()=>hZ(l,(y==null?void 0:y.requestId)??null),[l,y==null?void 0:y.requestId]),x=g.useMemo(()=>Qee(v,_),[v,_]),b=g.useMemo(()=>_.map((F,A)=>({...F,seq:Jee+A})),[_]),w=g.useMemo(()=>[...x,...b],[x,b]),S=hM(u),k=LZ(u),T=(i==null?void 0:i.resolvedModel)??(i==null?void 0:i.model),N=g.useMemo(()=>({sessionLabel:(i==null?void 0:i.label)??e,sessionId:e,...T?{model:T}:{},...(()=>{const F=i==null?void 0:i.gitBranch;return F?{gitBranch:F}:{}})(),...(()=>{const F=ete(i);return F!==void 0?{contextPct:F}:{}})(),...i!=null&&i.cwd?{cwd:i.cwd}:{},...(()=>{const F=i==null?void 0:i.permissionMode;return F?{permissionMode:F}:{}})(),procAlive:S,streamInProgress:k,pinnedAt:(i==null?void 0:i.pinnedAt)??null}),[i,e,T,S,k]),L=g.useMemo(()=>t.isOpen?u==="error"?{kind:"error",message:"session error"}:{kind:"ready"}:{kind:"closed"},[t.isOpen,u]),P=g.useCallback(async F=>{await n.sessionSend(e,F)},[n,e]),O=g.useCallback(async F=>{if(!(i!=null&&i.cwd)||!s)throw new Error("fork requires sessionFile with cwd + toolSessionId");await n.sessionFork({cwd:i.cwd,toolSessionId:s,messageUuid:F})},[n,i==null?void 0:i.cwd,s]),I=g.useCallback(async F=>{await n.sessionRewind({sessionId:e,userMessageId:F,dryRun:!1})},[n,e]),R=g.useCallback(async F=>{await n.sessionUpdate(e,{model:F})},[n,e]),j=g.useCallback(async()=>{await n.sessionNew(e)},[n,e]),z=g.useCallback(async(F,A)=>{const B=c.find(E=>E.requestId===F);B&&d(F);try{await n.permissionRespond({sessionId:e,permissionRequestId:F,allow:A==="allow"})}catch(E){throw!((E==null?void 0:E.message)??"").startsWith("PERMISSION_REQUEST_STALE")&&B&&f(B),E}},[n,e,c,d,f]),$=g.useCallback(async()=>{await p.loadMore()},[p]);return g.useMemo(()=>({lines:w,connState:L,meta:N,historyDone:!p.hasMore,historyLoading:p.loading,pendingPermissions:c,sendText:P,fork:O,rewind:I,switchModel:R,clearSession:j,respondPermission:z,loadMoreHistory:$}),[w,L,N,p.hasMore,p.loading,c,P,O,I,R,j,z,$])}function tte({api:e,open:t,onOpenChange:n,scope:r,sessionId:i,onShareFile:s,onOpenInTab:o}){const[a,l]=g.useState([]),[c,u]=g.useState(null);g.useEffect(()=>{if(!t)return;let f=!1;return(async()=>{try{const p=await e.attachmentGroupList(i);if(f)return;l(p.entries)}catch(p){f||u(p.message)}})(),()=>{f=!0}},[e,i,t]);async function d(f){try{await e.attachmentGroupRemove(i,f.relPath),l(p=>f.from==="owner"?p.filter(m=>m.relPath!==f.relPath):p.map(m=>m.relPath===f.relPath?{...m,stale:!0}:m))}catch(p){u(p.message)}}return t?h.jsx(xx,{delayDuration:120,children:h.jsxs("div",{"data-testid":"files-drawer",className:"fixed inset-y-0 right-0 z-50 flex w-[420px] flex-col border-l border-border bg-elevated shadow-2xl",children:[h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[13px] font-semibold text-text-100",children:[h.jsx(a6,{className:"h-4 w-4"}),"Edited Files"]}),h.jsx("button",{type:"button",onClick:()=>n(!1),className:"flex h-7 w-7 items-center justify-center rounded text-text-400 hover:bg-bg-200 hover:text-text-100","aria-label":"Close drawer",children:h.jsx(Rn,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto",children:[h.jsx(nte,{title:`Session files (${a.length})`,subtitle:"agent Write/Edit 自动入清单",children:a.length===0?h.jsx(ite,{text:"还没有文件。agent Write/Edit 会自动加入清单。"}):a.map(f=>h.jsx(rte,{entry:f,onShareLink:()=>s(f.relPath),...o?{onOpenInTab:()=>o(f.relPath)}:{},onRemove:()=>d(f)},f.id))}),c?h.jsx("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-[11px] text-destructive",children:c}):null]})]})}):null}function nte({title:e,subtitle:t,children:n}){return h.jsxs("div",{className:"border-b border-border last:border-b-0",children:[h.jsx("div",{className:"sticky top-0 z-10 flex items-start justify-between bg-elevated px-4 py-2",children:h.jsxs("div",{className:"flex-1",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-text-300",children:e}),t?h.jsx("div",{className:"mt-0.5 text-[11px] text-text-400",children:t}):null]})}),h.jsx("div",{className:"flex flex-col",children:n})]})}function rte({entry:e,onShareLink:t,onOpenInTab:n,onRemove:r}){var l;const i=(l=e.mime)!=null&&l.startsWith("image/")?p6:Ms,s=e.relPath.lastIndexOf("/"),o=s>=0?e.relPath.slice(0,s+1):"",a=s>=0?e.relPath.slice(s+1):e.relPath;return h.jsxs("div",{"data-testid":"files-drawer-group-row",className:ne("group flex items-center gap-2 px-4 py-2 hover:bg-bg-200",e.stale&&"opacity-50"),children:[h.jsx(i,{className:"h-4 w-4 shrink-0 text-text-400"}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsxs(yx,{children:[h.jsx(bx,{asChild:!0,children:h.jsxs("span",{className:"flex min-w-0 items-baseline text-[13px] text-text-100",children:[o?h.jsx("span",{className:"truncate text-text-400",children:o}):null,h.jsx("span",{className:"shrink-0",children:a})]})}),h.jsx(Xf,{side:"top",align:"start",className:"max-w-[380px] break-all",children:e.relPath})]}),e.stale&&h.jsx("span",{className:"rounded bg-text-100/10 px-1 py-0 text-[10px] uppercase text-text-400",children:"stale"})]}),h.jsxs("div",{className:"flex items-center gap-1.5 truncate text-[11px] text-text-400",children:[h.jsx("span",{children:e.from}),h.jsx("span",{children:"·"}),h.jsx("span",{children:ste(e.addedAt)})]})]}),!e.stale&&h.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[n?h.jsx(zm,{icon:h.jsx(Mc,{className:"h-3.5 w-3.5"}),title:"Open in tab",onClick:n}):null,h.jsx(zm,{icon:h.jsx(G_,{className:"h-3.5 w-3.5"}),title:"Share link",onClick:t}),e.from==="owner"&&h.jsx(zm,{icon:h.jsx(X_,{className:"h-3.5 w-3.5"}),title:"Remove",onClick:r})]})]})}function zm({icon:e,title:t,onClick:n}){return h.jsx("button",{type:"button",onClick:n,title:t,"aria-label":t,className:"flex h-7 w-7 items-center justify-center rounded text-text-400 hover:bg-text-100/10 hover:text-text-100",children:e})}function ite({text:e}){return h.jsx("div",{className:"px-4 py-3 text-[12px] italic text-text-400",children:e})}function ste(e){const t=Date.now()-e;return t<6e4?`${Math.max(1,Math.floor(t/1e3))}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function ote({persona:e,open:t,onClose:n,onTogglePublic:r,guestShareUrl:i,onChangeIcon:s,onDelete:o,embedded:a,onLoadPersonality:l,onSavePersonality:c,onDirtyChange:u,initialPersonality:d,onShareCapability:f,readOnly:p=!1,onChangeTool:m}){const[v,y]=g.useState(!1),[_,x]=g.useState(!1),b=()=>{i&&navigator.clipboard.writeText(i).then(()=>{x(!0),setTimeout(()=>x(!1),2e3)})},w=k=>{y(k),u==null||u(k)},S=()=>{v&&!window.confirm("修改未保存,确定关闭?")||n()};return t?h.jsxs(h.Fragment,{children:[!a&&h.jsx("div",{className:"absolute inset-0 z-30 bg-black/30",onClick:S,"aria-hidden":"true"}),h.jsxs("aside",{className:a?"flex h-full w-full flex-col bg-bg-0":"absolute right-0 top-0 z-40 flex h-full w-[420px] flex-col bg-bg-0 border-l border-border shadow-xl","data-testid":"persona-settings-drawer",children:[h.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx(H6,{className:"h-4 w-4 text-text-300"}),h.jsx("span",{className:"text-[13px] font-medium text-text-100 truncate",children:"Persona 设置"})]}),h.jsx("button",{type:"button",onClick:S,"aria-label":"关闭",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-text-100",children:h.jsx(Rn,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-6 flex flex-col gap-4",children:[h.jsxs("header",{className:"flex items-start justify-between gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h2",{className:"text-lg font-semibold text-text-100 truncate",children:e.label}),e.public?h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-bg-200 px-1.5 py-0.5 text-[10px] text-text-200",children:[h.jsx(h6,{className:"h-3 w-3"})," 公开"]}):h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-error-dim px-1.5 py-0.5 text-[10px] text-error",children:[h.jsx(u6,{className:"h-3 w-3"})," 已关闭"]})]}),h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate","data-testid":"persona-id-subtitle",children:e.personaId})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[f?h.jsxs("button",{type:"button",onClick:f,"aria-label":"分享给他人",title:"分享给他人",className:"inline-flex items-center gap-1 rounded-sm px-2 py-1.5 text-xs text-text-200 hover:bg-bg-200 hover:text-text-100",children:[h.jsx(G_,{className:"h-3.5 w-3.5"}),"分享"]}):null,o?h.jsx("button",{type:"button",onClick:o,"aria-label":"删除 persona",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-error",children:h.jsx(X_,{className:"h-4 w-4"})}):null]})]}),h.jsx("hr",{className:"border-border"}),r?h.jsxs(h.Fragment,{children:[h.jsxs("section",{className:"flex items-center justify-between gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"公开访问"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"开启后这个 persona 才会出现在「邀请联系人」的可选列表里。关闭即拒所有新分享(已颁出的 token 不受影响)。"})]}),h.jsx(ate,{checked:e.public??!1,onChange:k=>r(k)})]}),e.public?h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"guest-share-link",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(BN,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"访客分享链接"})]}),i?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{readOnly:!0,value:i,onFocus:k=>k.currentTarget.select(),className:"min-w-0 flex-1 truncate rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"guest-share-link-input"}),h.jsx("button",{type:"button",onClick:b,className:"flex shrink-0 items-center gap-1 rounded border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200","data-testid":"guest-share-link-copy",children:_?h.jsxs(h.Fragment,{children:[h.jsx(Za,{className:"h-3 w-3"})," 已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(su,{className:"h-3 w-3"})," 复制"]})})]}),h.jsx("span",{className:"text-[11px] text-text-400",children:"任何 TTC 员工打开此链接(飞书登录)即可在该 persona 下交互。"})]}):h.jsx("span",{className:"text-[11px] text-text-400","data-testid":"guest-share-link-no-tunnel",children:"需先开启 tunnel(公网访问)才能生成可分享给外部的链接。"})]}):null,h.jsx("hr",{className:"border-border"})]}):null,s?h.jsxs("section",{className:"flex flex-col gap-1.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"默认图标"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"新建该 persona 的 session 会默认继承此图标。"}),h.jsx(tI,{value:e.iconKey??null,onChange:s})]}):null,s?h.jsx("hr",{className:"border-border"}):null,m&&!p?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex flex-col gap-1.5",children:[h.jsx("span",{className:"text-[12px] font-medium text-text-200",children:"Agent"}),h.jsx("div",{className:"flex gap-2",children:["claude","codex"].map(k=>h.jsx("button",{type:"button","data-testid":`persona-edit-tool-${k}`,onClick:()=>m(k),className:ne("flex-1 rounded-md border px-3 py-2 text-[12px]",(e.tool??"claude")===k?"border-accent bg-accent/10 text-accent":"border-bg-300 text-text-300"),children:k==="claude"?"Claude Code":"Codex"},k))}),h.jsx("span",{className:"text-[11px] text-text-400",children:"切换只影响之后新建的会话,已有会话保持原 tool。"})]}),h.jsx("hr",{className:"border-border"})]}):null,l?h.jsxs(h.Fragment,{children:[h.jsx(dte,{onLoad:l,...c?{onSave:c}:{},onDirtyChange:w,initialPersonality:d,readOnly:p}),h.jsx("hr",{className:"border-border"})]}):null,h.jsx(lte,{settings:e.sandboxSettings??null}),h.jsx("hr",{className:"border-border"}),h.jsx(cte,{skills:e.skills??[]}),h.jsx("hr",{className:"border-border"}),h.jsx(ute,{plugins:e.plugins??[]})]})]})]}):null}function ate({checked:e,onChange:t}){return h.jsx("button",{type:"button",role:"switch","aria-checked":e,onClick:()=>t(!e),"data-testid":"persona-public-toggle",className:ne("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors",e?"bg-success":"bg-bg-300"),children:h.jsx("span",{className:ne("inline-block h-5 w-5 rounded-full bg-bg-0 shadow transition-transform",e?"translate-x-[22px]":"translate-x-0.5")})})}function lte({settings:e}){var t,n,r,i,s,o,a,l,c,u,d,f,p;return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-sandbox-setting-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Sandbox Setting"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"约束此 persona 的沙箱权限(只读,需通过文件修改)。"})]}),e==null?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-sandbox-setting-empty",children:"暂无 sandbox 配置"}):h.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-bg-100 px-3 py-2",children:[h.jsx(gd,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),h.jsx(gd,{label:"沙箱启用",value:$m((n=e.sandbox)==null?void 0:n.enabled)}),h.jsx(gd,{label:"沙箱内自动放行 Bash",value:$m((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),h.jsx(gd,{label:"允许非沙箱命令",value:$m((i=e.sandbox)==null?void 0:i.allowUnsandboxedCommands)}),h.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border pt-1.5",children:[h.jsx(Il,{label:"沙箱外命令",paths:(s=e.sandbox)==null?void 0:s.excludedCommands}),h.jsx(Il,{label:"允许读取",paths:(a=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:a.allowRead}),h.jsx(Il,{label:"拒绝读取",paths:(c=(l=e.sandbox)==null?void 0:l.filesystem)==null?void 0:c.denyRead}),h.jsx(Il,{label:"允许写入",paths:(d=(u=e.sandbox)==null?void 0:u.filesystem)==null?void 0:d.allowWrite}),h.jsx(Il,{label:"拒绝写入",paths:(p=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:p.denyWrite})]})]})]})}function $m(e){return e===!0?"是":e===!1?"否":"—"}function gd({label:e,value:t}){return h.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px]",children:[h.jsx("span",{className:"text-text-300",children:e}),h.jsx("span",{className:"font-mono text-text-100",children:t})]})}function Il({label:e,paths:t}){const n=!t||t.length===0;return h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[11px] text-text-300",children:e}),n?h.jsx("span",{className:"text-[11px] text-text-400",children:"—"}):h.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((r,i)=>h.jsx("span",{className:"rounded-sm border border-border bg-bg-0 px-1.5 py-0.5 font-mono text-[11px] text-text-200",children:r},`${e}-${i}-${r}`))})]})}function cte({skills:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-skills-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Persona Skills"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 私有 skills(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/skills/"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-skills-empty",children:"暂无 skills"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsxs("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-skill-row",children:[h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.name}),t.description?h.jsx("span",{className:"text-[12px] text-text-300",children:t.description}):h.jsx("span",{className:"text-[11px] text-text-400 italic",children:"无描述"})]},t.name))})]})}function ute({plugins:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-plugins-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Enabled Plugins"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 已启用的插件(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/settings.json"})," ","的 ",h.jsx("code",{className:"font-mono",children:"enabledPlugins"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-plugins-empty",children:"暂无启用插件"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsx("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-plugin-row",children:h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.id})},t.id))})]})}function dte({onLoad:e,onSave:t,onDirtyChange:n,initialPersonality:r,readOnly:i=!1}){const s=r!==void 0,[o,a]=g.useState(s),[l,c]=g.useState(s?r:""),[u,d]=g.useState(s?r:""),[f,p]=g.useState(null),[m,v]=g.useState(!1),[y,_]=g.useState(null),x=st.useRef(e),b=st.useRef(t),w=st.useRef(n);st.useEffect(()=>{x.current=e,b.current=t,w.current=n});const S=st.useCallback(()=>{a(!1),p(null),x.current().then(L=>{c(L),d(L),a(!0)}).catch(L=>{p(L instanceof Error?L.message:String(L))})},[]);st.useEffect(()=>{s||S()},[s,S]);const k=!i&&o&&u!==l;st.useEffect(()=>{i||w.current(k)},[k,i]);const T=()=>{b.current&&(v(!0),_(null),b.current(u).then(()=>{c(u),v(!1)}).catch(L=>{_(L instanceof Error?L.message:String(L)),v(!1)}))},N=()=>{d(l),_(null)};return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-personality-section",children:[h.jsx("span",{className:"text-[12px] font-medium text-text-200",children:"人格 (Personality)"}),f?h.jsxs("div",{"data-testid":"persona-personality-load-error",className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error flex items-center justify-between gap-2",children:[h.jsxs("span",{children:["加载失败:",f]}),h.jsx("button",{type:"button",onClick:S,className:"rounded-sm border border-error px-2 py-0.5 text-[11px] hover:bg-error/10",children:"重试"})]}):null,y?h.jsxs("div",{"data-testid":"persona-personality-save-error",className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error",children:["保存失败:",y]}):null,h.jsx("textarea",{"data-testid":"persona-personality-textarea",value:u,onChange:L=>d(L.target.value),readOnly:i,disabled:!i&&(!o||m),placeholder:o?"":"加载中…",rows:8,className:"min-h-[8rem] max-h-[18rem] resize-y rounded-md border border-border bg-bg-100 px-2 py-1.5 font-mono text-[11px] text-text-100 disabled:opacity-60"}),!i&&h.jsxs("p",{className:"text-[10px] text-text-400",children:["写入到 ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/CLAUDE.md"}),"。 修改只对新启动的 sub-session 生效。"]}),o&&k?h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:N,disabled:m,className:"rounded-sm border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200 disabled:opacity-60",children:"放弃"}),h.jsx("button",{type:"button",onClick:T,disabled:m,"data-testid":"persona-personality-save-btn",className:"rounded-sm bg-accent-dim px-2 py-1 text-[12px] text-text-100 hover:opacity-90 disabled:opacity-60",children:m?"保存中…":"保存"})]}):null]})}function hte({personaId:e,open:t,onClose:n,api:r,embedded:i,onDirtyChange:s,onShareCapability:o,viewerRole:a="owner"}){const{persona:l}=MN(e),c=lB(e),u=cB(),d=uB(),{httpBaseUrl:f}=Af(),p=g.useMemo(()=>!(l!=null&&l.public)||!f||/^https?:\/\/(127\.0\.0\.1|localhost|0\.0\.0\.0|\[?::1\]?)([:/]|$)/i.test(f)?null:`${f}/s/${e}`,[l==null?void 0:l.public,f,e]),m=g.useCallback(S=>{u(e,{public:S}).catch(k=>{Ae("persona","togglePublic failed",k)})},[u,e]),v=g.useCallback(S=>{u(e,{iconKey:S}).catch(k=>{Ae("persona","changeIcon failed",k)})},[u,e]),y=g.useCallback(S=>{u(e,{tool:S}).catch(k=>{Ae("persona","changeTool failed",k)})},[u,e]),_=g.useCallback(()=>{l&&confirm(`删除 persona "${l.label}"?`)&&(d(e).catch(S=>{Ae("persona","delete failed",S)}),n())},[l,d,e,n]),x=g.useCallback(async()=>c.loaded?c.personality:(await c.refresh()).personality,[c]),b=g.useCallback(async S=>{await u(e,{personality:S}),await c.refresh()},[u,e,c]);if(!l)return null;const w=a==="guest";return h.jsx(ote,{embedded:i,persona:{...l,skills:c.skills,plugins:c.plugins,sandboxSettings:c.sandboxSettings},open:t,onClose:n,onLoadPersonality:x,onDirtyChange:s,readOnly:w,...w?{}:{onTogglePublic:m,guestShareUrl:p,onChangeIcon:v,onChangeTool:y,onDelete:_,onSavePersonality:b,...o?{onShareCapability:o}:{}}})}function fte({api:e,open:t,onOpenChange:n,personaId:r,personaName:i,viewerRole:s}){return t?h.jsxs("div",{"data-testid":"persona-drawer",className:"fixed inset-y-0 right-0 z-50 flex w-[420px] flex-col border-l border-border bg-elevated shadow-2xl",children:[h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-[13px] font-semibold text-text-100",children:[h.jsx(Y_,{className:"h-4 w-4 shrink-0"}),h.jsxs("span",{className:"truncate",title:i,children:["Persona · ",i]})]}),h.jsx("button",{type:"button",onClick:()=>n(!1),className:"flex h-7 w-7 items-center justify-center rounded text-text-400 hover:bg-bg-200 hover:text-text-100","aria-label":"Close drawer",children:h.jsx(Rn,{className:"h-4 w-4"})})]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:h.jsx(hte,{personaId:r,open:!0,onClose:()=>n(!1),api:e,embedded:!0,...s?{viewerRole:s}:{}},r)})]}):null}function pte(e){try{const t=new URL(e);return t.protocol==="ws:"?t.protocol="http:":t.protocol==="wss:"&&(t.protocol="https:"),`${t.protocol}//${t.host}`}catch{return e}}function mte(e,t){try{const n=new URL(e),r=new URL(t);return n.protocol=r.protocol,n.host=r.host,n.toString()}catch{return e}}async function gy(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return mte(s.url,pte(t.url))}async function gte(e,t,n,r,i=60){const s=window.open("about:blank","_blank");try{const o=await gy(e,t,n,r,i);s?s.location.href=o:window.open(o,"_blank")}catch(o){throw s&&s.close(),o}}async function vte(e){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.setAttribute("readonly",""),document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}const _te={...Vc,h1:({node:e,...t})=>h.jsx("h1",{...t,className:"mt-4 mb-3 text-[18px] font-semibold leading-tight text-text-100"}),h2:({node:e,...t})=>h.jsx("h2",{...t,className:"mt-4 mb-2 text-[16px] font-semibold leading-tight text-text-100"}),h3:({node:e,...t})=>h.jsx("h3",{...t,className:"mt-3 mb-2 text-[14px] font-semibold leading-tight text-text-100"}),h4:({node:e,...t})=>h.jsx("h4",{...t,className:"mt-3 mb-1 text-[13px] font-semibold text-text-100"}),h5:({node:e,...t})=>h.jsx("h5",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-100"}),h6:({node:e,...t})=>h.jsx("h6",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-300"}),p:({node:e,...t})=>h.jsx("p",{...t,className:"my-2 leading-relaxed"}),ul:({node:e,...t})=>h.jsx("ul",{...t,className:"my-2 list-disc space-y-1 pl-5"}),ol:({node:e,...t})=>h.jsx("ol",{...t,className:"my-2 list-decimal space-y-1 pl-5"}),li:({node:e,...t})=>h.jsx("li",{...t,className:"leading-relaxed"}),blockquote:({node:e,...t})=>h.jsx("blockquote",{...t,className:"my-2 border-l-2 border-border pl-3 italic text-text-300"}),code:({node:e,className:t,children:n,...r})=>t?h.jsx("code",{...r,className:`${t} font-mono text-[12px]`,children:n}):h.jsx("code",{...r,className:"rounded bg-bg-50 px-1 py-0.5 font-mono text-[12px] text-text-100",children:n}),pre:({node:e,...t})=>h.jsx("pre",{...t,className:"my-2 overflow-auto rounded border border-border bg-bg-0 p-3 text-[12px] font-mono text-text-100"}),hr:({node:e,...t})=>h.jsx("hr",{...t,className:"my-3 border-border"}),table:({node:e,...t})=>h.jsx("table",{...t,className:"my-2 w-full border-collapse text-[12px]"}),thead:({node:e,...t})=>h.jsx("thead",{...t,className:"bg-bg-50"}),th:({node:e,...t})=>h.jsx("th",{...t,className:"border border-border px-2 py-1 text-left font-semibold"}),td:({node:e,...t})=>h.jsx("td",{...t,className:"border border-border px-2 py-1"}),strong:({node:e,...t})=>h.jsx("strong",{...t,className:"font-semibold text-text-100"}),em:({node:e,...t})=>h.jsx("em",{...t,className:"italic"})};function xte(e){const t=e.split("/");return t[t.length-1]||e}function sA({relPath:e,loadMarkdown:t,headerRight:n,showTitleBar:r=!1}){const[i,s]=g.useState(null),[o,a]=g.useState(null),[l,c]=g.useState(!1);return g.useEffect(()=>{if(!e)return;let u=!1;return c(!0),a(null),s(null),(async()=>{try{const d=await t(e);if(u)return;s(d)}catch(d){if(u)return;a(d.message||String(d))}finally{u||c(!1)}})(),()=>{u=!0}},[e,t]),h.jsxs("div",{className:"flex flex-col h-full",children:[r&&e?h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[h.jsx("div",{"data-testid":"md-preview-title",className:"truncate text-[13px] font-medium text-text-100",title:e,children:xte(e)}),h.jsx("div",{className:"flex items-center gap-1",children:n})]}):null,h.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 text-[13px] text-text-100",children:l?h.jsx("div",{"data-testid":"md-preview-loading",className:"text-text-400",children:"Loading…"}):o?h.jsx("div",{"data-testid":"md-preview-error",className:"text-destructive whitespace-pre-wrap",children:o}):i!==null?h.jsx("div",{"data-testid":"md-preview-content",className:"max-w-none",children:h.jsx(Hc,{remarkPlugins:[Wc],components:_te,children:i})}):null})]})}function yte({open:e,onOpenChange:t,relPath:n,loadMarkdown:r,onShare:i}){return e?h.jsx("div",{"data-testid":"md-preview-drawer",className:"fixed inset-y-0 right-0 z-50 flex w-1/2 max-w-[900px] flex-col border-l border-border bg-elevated shadow-2xl",children:h.jsx(sA,{relPath:n,loadMarkdown:r,showTitleBar:!0,headerRight:h.jsxs(h.Fragment,{children:[i?h.jsx("button",{type:"button","data-testid":"md-preview-share","aria-label":"Share rendered preview link",onClick:i,className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(BN,{className:"h-4 w-4"})}):null,h.jsx("button",{type:"button","aria-label":"Close preview",onClick:()=>t(!1),className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(Rn,{className:"h-4 w-4"})})]})})}):null}function bte({left:e,right:t,stage:n,onExpand:r,onCollapse:i}){const s=n==="stopped",[o,a]=g.useState(!1);async function l(){if(!o){a(!0);try{await r()}catch{}finally{a(!1)}}}async function c(){if(!o){a(!0);try{await i()}catch{}finally{a(!1)}}}return h.jsxs("div",{className:"flex h-full w-full min-h-0","data-testid":"two-pane-layout",children:[h.jsxs("div",{className:"relative flex min-w-0 flex-1 flex-col","data-testid":"two-pane-left",children:[s&&h.jsx("button",{type:"button",disabled:o,className:"absolute right-14 top-2 z-10 rounded border border-border bg-elevated px-2 py-1 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed",onClick:l,children:o?"启动中…":"展开预览"}),e]}),!s&&h.jsxs("div",{className:"flex w-1/2 min-w-[320px] flex-col border-l border-bg-200","data-testid":"two-pane-right",children:[h.jsx("div",{className:"flex items-center justify-end gap-2 border-b border-bg-200 bg-bg-50 px-2 py-1",children:h.jsx("button",{type:"button",disabled:o,className:"rounded px-2 py-1 text-[12px] text-text-300 hover:bg-bg-100 disabled:opacity-50",onClick:c,children:"收起预览"})}),h.jsx("div",{className:"min-h-0 flex-1",children:t})]})]})}const oA=sM,wte=oM,aA=g.forwardRef(({className:e,...t},n)=>h.jsx(ty,{ref:n,className:ne("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));aA.displayName=ty.displayName;const vy=g.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(wte,{children:[h.jsx(aA,{}),h.jsxs(ny,{ref:r,className:ne("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2","gap-4 rounded-lg border border-border bg-elevated p-6 shadow-lg",e),...n,children:[t,h.jsxs(aM,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-accent",children:[h.jsx(Rn,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));vy.displayName=ny.displayName;const _y=({className:e,...t})=>h.jsx("div",{className:ne("flex flex-col space-y-1.5 text-left",e),...t});_y.displayName="DialogHeader";const xy=({className:e,...t})=>h.jsx("div",{className:ne("flex flex-row justify-end gap-2",e),...t});xy.displayName="DialogFooter";const yy=g.forwardRef(({className:e,...t},n)=>h.jsx(ry,{ref:n,className:ne("text-lg font-semibold leading-none text-text-100",e),...t}));yy.displayName=ry.displayName;const lA=g.forwardRef(({className:e,...t},n)=>h.jsx(iy,{ref:n,className:ne("text-sm text-text-300",e),...t}));lA.displayName=iy.displayName;const Ste=6173,kte=6182;function Cte({open:e,onOpenChange:t,projectName:n,currentPort:r,allUsedPorts:i,onUpdate:s}){const o=[];for(let v=Ste;v<=kte;v++)(v===r||!i.includes(v))&&o.push(v);const[a,l]=g.useState(r),[c,u]=g.useState(!1),[d,f]=g.useState(null),p=a!==r&&!c;async function m(){if(p){u(!0),f(null);try{await s(a),t(!1)}catch(v){f((v==null?void 0:v.message)??String(v))}finally{u(!1)}}}return h.jsx(oA,{open:e,onOpenChange:t,children:h.jsxs(vy,{className:"max-w-md",children:[h.jsxs(_y,{children:[h.jsxs(yy,{children:["改端口 · ",n]}),h.jsxs(lA,{children:["手改通常发生在系统其他进程占了默认分配的端口、dev server 起不来时。 提交后 daemon 会停 dev server → 写 ",h.jsx("code",{className:"mx-1 rounded bg-bg-100 px-1 py-0.5 text-[11px]",children:".clawd-project.json"})," → 用新端口重新起。"]})]}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsx("label",{className:"text-xs text-text-400",children:"新端口(仅显示段内可用 + 当前端口)"}),h.jsx("select",{className:"h-9 rounded-md border border-border bg-elevated px-3 py-1 text-sm text-text-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent",value:a,onChange:v=>l(Number(v.target.value)),disabled:c,children:o.map(v=>h.jsxs("option",{value:v,children:[v,v===r?"(当前)":""]},v))}),o.length===1&&h.jsx("div",{className:"text-[11px] text-text-400",children:"端口段已全被其它 project 占用,没有可换的;先删一个 idle project 释放端口。"}),d&&h.jsx("div",{className:"rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px] text-destructive",children:d})]}),h.jsxs(xy,{children:[h.jsx(ni,{variant:"ghost",onClick:()=>t(!1),disabled:c,children:"取消"}),h.jsx(ni,{onClick:m,disabled:!p,children:c?"应用中…":"应用新端口"})]})]})})}const zk=[{stage:"build",label:"构建"},{stage:"deploy",label:"部署到阿里云"},{stage:"verify",label:"验证可访问性"}];function Ete({currentStage:e,onCancel:t}){const n=zk.findIndex(r=>r.stage===e);return h.jsxs("div",{"data-testid":"publish-progress",className:"flex items-center gap-3 border-b border-bg-200 bg-bg-50 px-3 py-1.5 text-[12px]",children:[zk.map((r,i)=>{const s=i<n,o=i===n,a=s?"text-text-300":o?"text-text-200":"text-text-500/50";return h.jsxs("span",{className:`flex items-center gap-1 ${a}`,children:[s?h.jsx(jf,{className:"size-3.5"}):o?h.jsx(rr,{className:"size-3.5 animate-spin"}):h.jsx(DN,{className:"size-3.5"}),h.jsxs("span",{children:[r.label,o?"中…":""]})]},r.stage)}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const Nte={build:"构建",deploy:"部署",verify:"验证"};function Tte({stage:e,onRetry:t,onDismiss:n}){return h.jsxs("div",{"data-testid":"publish-interrupted-banner",className:"flex items-center gap-2 border-b border-yellow-400/40 bg-yellow-400/10 px-3 py-1.5 text-[12px]",children:[h.jsx(Ac,{className:"size-3.5 text-yellow-500"}),h.jsxs("span",{className:"text-text-200",children:["上次发布在 ",h.jsxs("strong",{className:"font-medium",children:["[",Nte[e],"]"]})," ","阶段被中断(daemon 重启)"]}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded bg-accent-main-100 px-2 py-0.5 text-[11px] text-oncolor-100 hover:opacity-90",children:"重新发布"}),h.jsx("button",{type:"button",onClick:n,className:"rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const Pte={build:"构建",deploy:"部署",verify:"验证",unknown:"未知"};function Ite({stage:e,onFocusChat:t,onClose:n}){return h.jsxs("div",{"data-testid":"publish-failed-banner",className:"flex items-center gap-2 border-b border-destructive/40 bg-destructive/10 px-3 py-1.5 text-[12px]",children:[h.jsx(Rs,{className:"size-3.5 text-destructive"}),h.jsxs("button",{type:"button",onClick:t,className:"flex-1 text-left text-text-200 hover:underline",children:["发布失败:",h.jsxs("strong",{className:"font-medium",children:["[",Pte[e],"]"]})," ","已通知 assistant 接管 →"]}),h.jsx("button",{type:"button",onClick:n,"aria-label":"关闭失败提示",className:"rounded p-0.5 text-text-400 hover:bg-bg-100 hover:text-text-200",children:h.jsx(Rn,{className:"size-3.5"})})]})}const $k={"install-pending":{label:"等装依赖…",step:"1/3"},installing:{label:"安装依赖中…(可能要几十秒到几分钟)",step:"2/3"},"starting-dev-server":{label:"启动 dev server…(等监听端口才挂 iframe)",step:"3/3"}};function Rte({project:e,previewHost:t,previewScheme:n,onUpdatePort:r,allUsedPorts:i,publishSlot:s,publishInFlightStage:o,onDismissPublishJob:a,onRetryPublish:l,publishFailureBanner:c,onPublishFailureBannerClose:u,onPublishFailureBannerFocusChat:d}){var _,x;const[f,p]=g.useState(!1);if(!e)return h.jsx("div",{className:"flex h-full w-full items-center justify-center p-6 text-center text-[13px] text-text-400",children:"未绑定 project"});const m=e.stage??(e.isRunning?"running":"stopped"),v=t?`${n}://${t}/preview/${e.port}/`:null,y=e.prodUrl??null;return h.jsxs("div",{className:"flex h-full w-full flex-col","data-testid":"preview-pane",children:[h.jsxs("header",{className:"flex items-center justify-between gap-2 border-b border-bg-200 bg-bg-50 px-3 py-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[12px]",children:[h.jsx("span",{className:"font-medium text-text-200",children:e.name}),h.jsx("span",{className:"rounded bg-bg-100 px-1.5 py-0.5 text-[11px] text-text-400",children:e.port}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-text-500",children:m==="running"?"dev":m})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[y?h.jsxs("a",{href:y,target:"_blank",rel:"noopener noreferrer",title:`打开线上:${y}`,className:"inline-flex items-center gap-1 rounded border border-bg-200 px-2 py-0.5 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(Mc,{className:"size-3"}),"打开线上"]}):null,s,h.jsxs(UP,{children:[h.jsx(WP,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":"Project settings",className:"rounded p-1 text-text-400 hover:bg-bg-100",children:h.jsx($6,{className:"size-3.5"})})}),h.jsxs(vx,{align:"end",children:[h.jsx(Ys,{onSelect:()=>p(!0),children:"Update Port…"}),h.jsxs(Ys,{disabled:!0,title:"rename not supported yet",onSelect:b=>b.preventDefault(),children:["Name: ",e.name]})]})]})]})]}),c?h.jsx(Ite,{stage:c.stage,onClose:()=>u==null?void 0:u(),onFocusChat:()=>d==null?void 0:d()}):null,((_=e.publishJob)==null?void 0:_.status)==="in-flight"?h.jsx(Ete,{currentStage:o??e.publishJob.stage,onCancel:()=>void(a==null?void 0:a())}):null,((x=e.publishJob)==null?void 0:x.status)==="interrupted"?h.jsx(Tte,{stage:e.publishJob.stage,onRetry:()=>void(l==null?void 0:l()),onDismiss:()=>void(a==null?void 0:a())}):null,h.jsx("div",{className:"min-h-0 flex-1",children:m==="failed"?h.jsx(Mte,{reason:e.stageReason}):m==="stopped"?null:m==="running"?v?h.jsx("iframe",{"data-testid":"preview-iframe",className:"size-full border-0 bg-white",src:v,title:"preview"}):h.jsx(Fk,{label:"等 tunnel 起来…",step:"-"}):h.jsx(Fk,{label:$k[m].label,step:$k[m].step})}),h.jsx(Cte,{open:f,onOpenChange:p,projectName:e.name,currentPort:e.port,allUsedPorts:i,onUpdate:async b=>{await r(b)}})]})}function Fk({label:e,step:t}){return h.jsxs("div",{"data-testid":"preview-spinner",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(rr,{className:"size-6 animate-spin text-accent-main-100"}),h.jsx("div",{className:"text-[13px] text-text-200",children:e}),h.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-500",children:t}),h.jsx("div",{className:"mt-2 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度"})]})}function Mte({reason:e}){return h.jsxs("div",{"data-testid":"preview-failed",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(Rs,{className:"size-6 text-destructive"}),h.jsx("div",{className:"text-[13px] text-text-200",children:"project 启动失败"}),h.jsx("div",{className:"max-w-[400px] text-[12px] text-text-400",children:e??"未知原因 —— 看 ~/.clawd/clawd.log 排查"}),h.jsx("div",{className:"mt-1 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度 / 跟它说怎么修"})]})}function Ate({error:e,onClose:t}){const[n,r]=g.useState(!1),i=async()=>{var a;if(!e)return;const s=e.message;let o=!1;try{(a=navigator.clipboard)!=null&&a.writeText&&(await navigator.clipboard.writeText(s),o=!0)}catch{o=!1}if(!o){const l=document.createElement("textarea");l.value=s,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.select();try{document.execCommand("copy"),o=!0}catch{o=!1}finally{document.body.removeChild(l)}}o&&(r(!0),setTimeout(()=>r(!1),1500))};return h.jsx(oA,{open:!!e,onOpenChange:s=>{s||(r(!1),t())},children:h.jsxs(vy,{className:"max-w-lg",children:[h.jsx(_y,{children:h.jsx(yy,{children:(e==null?void 0:e.title)??"错误"})}),h.jsx("pre",{"data-testid":"rpc-error-message",className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded border border-bg-200 bg-bg-50 px-3 py-2 text-[12px] text-text-200",children:(e==null?void 0:e.message)??""}),h.jsxs(xy,{children:[h.jsx(ni,{variant:"ghost",onClick:i,className:"gap-1.5",children:n?h.jsxs(h.Fragment,{children:[h.jsx(Za,{className:"size-3.5"}),"已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(su,{className:"size-3.5"}),"复制"]})}),h.jsx(ni,{onClick:t,children:"关闭"})]})]})})}function jte(e,t){for(const n of[e,t])if(n)try{const r=new URL(n),i=r.protocol==="https:"||r.protocol==="wss:"?"https":"http";return{host:r.host,scheme:i}}catch{}return{host:null,scheme:"https"}}const Dte={codex:"on-request",claude:"bypassPermissions"};function Lte(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??Dte[e.sourceTool??"claude"]??"bypassPermissions",forkedFromSessionId:e.sourceSessionId};return e.sourceOwnerPersonaId&&(t.ownerPersonaId=e.sourceOwnerPersonaId),e.sourceTool&&(t.tool=e.sourceTool),t}async function Ote(e,t,n){if(!t.toolSessionId)return null;const{forkedToolSessionId:r}=await e.sessionFork({cwd:t.cwd,toolSessionId:t.toolSessionId,messageUuid:n}),i=await e.sessionCreate({...Lte({cwd:t.cwd,sourceSessionId:t.sessionId,sourcePermissionMode:t.permissionMode,sourceOwnerPersonaId:t.ownerPersonaId,sourceTool:t.tool}),ephemeral:!0});return await e.sessionResume(i.sessionId,r),i}function vd(e){return e!=null&&e.ephemeral!==!1}async function Bte(e,t){return!t.stillEphemeral||!t.nextHold?!1:(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0)}const zte=300;function $te(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function cA(e,t){const n=P_(),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>{let a=!1;return(async()=>{try{const l=await n.kv.get(e);if(a)return;const c=$te(l);typeof c=="number"&&Number.isFinite(c)&&c>0?i(c):i(t)}catch{a||i(t)}})(),()=>{a=!0}},[n,e,t]);const o=g.useCallback(a=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,n.kv.set(e,a).catch(()=>{})},zte)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function Fte(){return{quickAsk:null,mds:[],active:null}}function Hte(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function Ute(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function Wte(e){if(!e.quickAsk)return e;const t=e.active==="quick-ask",n=e.mds[0],r=t?n?{kind:"md",relPath:n}:null:e.active;return{...e,quickAsk:null,active:r}}function Vte(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function qte(e,t){const n=e.mds.indexOf(t);if(n<0)return e;const r=e.mds.filter(l=>l!==t);if(!(e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===t))return{...e,mds:r};const s=r[n],o=n>0?r[n-1]:void 0;let a=null;return s?a={kind:"md",relPath:s}:o?a={kind:"md",relPath:o}:e.quickAsk&&(a="quick-ask"),{...e,mds:r,active:a}}function Kte(e,t){return{...e,active:t}}function Gte(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function uA(e){return e.quickAsk!==null||e.mds.length>0}function Xte(e){return e.split("/").pop()||e}function Yte({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:i,loadMarkdown:s,quickAskSession:o,onToggleHold:a,holdIds:l}){if(!uA(e))return null;const c=[];e.quickAsk&&c.push({id:"quick-ask",label:"问一下",title:"问一下",icon:h.jsx(Mh,{className:"w-3.5 h-3.5"})});for(const u of e.mds)c.push({id:{kind:"md",relPath:u},label:Xte(u),title:u,icon:h.jsx(Ms,{className:"w-3.5 h-3.5"})});return h.jsxs("div",{className:"flex flex-col h-full bg-bg-0 border-l border-text-100/10",children:[h.jsx(xx,{delayDuration:200,skipDelayDuration:100,children:h.jsx("div",{className:["flex items-stretch h-9 border-b border-text-100/10 shrink-0 overflow-x-auto","[scrollbar-width:none] [-ms-overflow-style:none]","[&::-webkit-scrollbar]:hidden"].join(" "),role:"tablist",children:c.map(u=>{const d=Gte(e.active,u.id),f=u.id==="quick-ask"?"quick-ask":`md:${u.id.relPath}`;return h.jsxs(yx,{children:[h.jsx(bx,{asChild:!0,children:h.jsxs("div",{role:"tab","aria-selected":d,"data-tab-title":u.title,onClick:()=>n(u.id),className:["group relative flex items-center gap-2 px-3 h-full cursor-pointer select-none","text-[12px] max-w-[180px] shrink-0 transition-colors duration-100",d?"text-text-100":"text-text-400 hover:text-text-100 hover:bg-text-100/[0.04]"].join(" "),children:[u.icon,h.jsx("span",{className:"truncate",children:u.label}),h.jsx("button",{type:"button","aria-label":`关闭 ${u.label}`,className:["ml-1 rounded p-0.5 shrink-0 transition-opacity","hover:bg-text-100/10",d?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-70"].join(" "),onClick:p=>{p.stopPropagation(),u.id==="quick-ask"?r():i(u.id.relPath)},children:h.jsx(Rn,{className:"w-3 h-3"})}),d?h.jsx("span",{"aria-hidden":"true",className:"absolute left-2 right-2 -bottom-px h-[2px] rounded-full bg-accent"}):null]})}),h.jsx(Xf,{side:"bottom",align:"start",className:"max-w-sm break-all",children:u.title})]},f)})})}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.quickAsk&&o?h.jsx("div",{className:"absolute inset-0",style:{display:e.active==="quick-ask"?"block":"none"},children:h.jsx(Qte,{session:o,api:t,holdIds:l,...a?{onToggleHold:a}:{}})}):null,e.mds.map(u=>{const d=e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===u;return h.jsx("div",{className:"absolute inset-0",style:{display:d?"block":"none"},children:h.jsx(sA,{relPath:u,loadMarkdown:s,showTitleBar:!1})},`md-body:${u}`)})]})]})}function Zte({state:e,extras:t}){const{api:n,session:r,holdIds:i,onToggleHold:s}=t,o=Is(),[a,l]=g.useState(Fte()),c=g.useRef(a);c.current=a;const u=g.useRef(!1),d=g.useCallback(async T=>{const N=c.current.quickAsk,L=await Ote(n,r,T);if(L){if(u.current){n.sessionDelete(L.sessionId).catch(()=>{});return}vd(N)&&n.sessionDelete(N.sessionId).catch(()=>{}),l(P=>Hte(P,{sessionId:L.sessionId}))}},[n,r]),f=g.useCallback(async(T,N)=>{const L=c.current.quickAsk,P=(L==null?void 0:L.sessionId)===T;try{await Bte(n,{sessionId:T,stillEphemeral:P&&vd(L),nextHold:N})&&l(I=>Vte(I))}catch(O){Ae("quick-ask","promote failed",O);return}s==null||s(T,N)},[n,s]),p=g.useCallback(T=>{l(N=>Ute(N,T))},[]),m=g.useCallback(T=>{l(N=>Kte(N,T))},[]),v=g.useCallback(()=>{const T=c.current.quickAsk;vd(T)&&n.sessionDelete(T.sessionId).catch(()=>{}),l(N=>Wte(N))},[n]),y=g.useCallback(T=>{l(N=>qte(N,T))},[]);g.useEffect(()=>()=>{u.current=!0;const T=c.current.quickAsk;vd(T)&&n.sessionDelete(T.sessionId).catch(()=>{})},[]);const _=si("sessions")??[],x=a.quickAsk?_.find(T=>T.sessionId===a.quickAsk.sessionId)??{sessionId:a.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,b=g.useCallback(async T=>{const N=await gy(n,o,r.sessionId,T,60),L=await fetch(N);if(!L.ok)throw new Error(`fetch ${L.status} ${L.statusText}`);return L.text()},[n,o,r.sessionId]),w=h.jsx(by,{state:e,extras:t,onQuickAskInternal:d,onPreviewMdInternal:p}),{initialSize:S,setSize:k}=cA("chat-panel-right-slot-width",480);return uA(a)?h.jsxs(Ix,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx($c,{id:"chat",minSize:"400px",children:w}),h.jsx(Mx,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx($c,{id:"right-slot",defaultSize:`${S}px`,minSize:"360px",maxSize:"800px",onResize:T=>k(T.inPixels),children:h.jsx(Yte,{state:a,api:n,onSwitchTab:m,onCloseQuickAsk:v,onCloseMd:y,loadMarkdown:b,quickAskSession:x,holdIds:i,onToggleHold:f})})]}):w}function Qte({session:e,api:t,holdIds:n,onToggleHold:r}){const i=iA(e.sessionId);return h.jsx(by,{state:i,extras:{session:e,api:t,holdIds:n,...r?{onToggleHold:r}:{}}})}function Jte({extras:e}){const t=iA(e.session.sessionId);if(e.session.appBuilderProject){const n=h.jsx(by,{state:t,extras:e});return h.jsx(ene,{state:t,chat:n,extras:e})}return h.jsx(Zte,{state:t,extras:e})}function ene({state:e,chat:t,extras:n}){var N;const r=si("daemon-info"),i=Is(),s=n.api,o=n.session,a=o.appBuilderProject,[l,c]=g.useState(null),u=g.useCallback(()=>{s.appBuilderGetProject(o.sessionId).then(L=>c(L.project)).catch(()=>c(null))},[s,o.sessionId]);g.useEffect(()=>{u()},[u]);const[d,f]=g.useState([]),p=g.useCallback(()=>{s.appBuilderListProjects().then(L=>f(L.projects)).catch(()=>f([]))},[s]);g.useEffect(()=>{p()},[p]),g.useEffect(()=>i.on("appBuilder:project-updated",P=>{const O=P;O!=null&&O.project&&(O.project.name===a&&c(O.project),f(I=>{const R=I.findIndex(z=>z.name===O.project.name);if(R<0)return[...I,O.project];const j=I.slice();return j[R]=O.project,j}))}),[i,a]);const{host:m,scheme:v}=jte(i.url,r==null?void 0:r.tunnelUrl),[y,_]=g.useState(void 0),[x,b]=g.useState(null);g.useEffect(()=>{const L=i.on("appBuilder:publish-progress",O=>{const I=O;!I||I.name!==a||I.status==="started"&&_(I.stage)}),P=i.on("appBuilder:publish-failed",O=>{const I=O;!I||I.name!==a||(_(void 0),b({stage:I.stage}))});return()=>{L(),P()}},[i,a]),g.useEffect(()=>{_(void 0),b(null)},[a]);const[w,S]=g.useState(null),k=h.jsx("button",{type:"button",className:"rounded bg-accent-main-100 px-2.5 py-1 text-[12px] text-oncolor-100 hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",disabled:((N=l==null?void 0:l.publishJob)==null?void 0:N.status)==="in-flight",onClick:async()=>{try{await s.appBuilderPublish(a)}catch(L){S({title:"发布请求失败",message:(L==null?void 0:L.message)??String(L)})}},children:"发布上线"}),T=(l==null?void 0:l.stage)??(l!=null&&l.isRunning?"running":"stopped");return h.jsxs(h.Fragment,{children:[h.jsx(bte,{left:t,stage:T,onExpand:async()=>{await s.appBuilderStartDevServer(o.sessionId)},onCollapse:async()=>{await s.appBuilderStopDevServer(o.sessionId)},right:h.jsx(Rte,{project:l,previewHost:m,previewScheme:v,allUsedPorts:d.map(L=>L.port),onUpdatePort:async L=>{await s.appBuilderUpdateProjectPort(a,L),p()},publishSlot:k,publishInFlightStage:y,onDismissPublishJob:async()=>{try{await s.appBuilderDismissPublishJob(a)}catch(L){S({title:"取消发布失败",message:(L==null?void 0:L.message)??String(L)})}},onRetryPublish:async()=>{try{await s.appBuilderPublish(a)}catch(L){S({title:"重新发布失败",message:(L==null?void 0:L.message)??String(L)})}},publishFailureBanner:x,onPublishFailureBannerClose:()=>b(null),onPublishFailureBannerFocusChat:()=>{}})}),h.jsx(Ate,{error:w,onClose:()=>S(null)})]})}function tne({headerMeta:e,connState:t,models:n,liveGitBranch:r,liveWorktreeRoot:i,onOpenConfig:s,onForceStop:o,cronActiveCount:a,onCronClick:l,lines:c,pendingPermissions:u,procAlive:d,rewindableUserMessageIds:f,onPermissionRespond:p,onPermissionInterrupt:m,onRewind:v,onFork:y,onQuickAsk:_,topSlot:x,realtimeQuestionAnswers:b,onSubmitQuestion:w,onCancelQuestion:S,liveQuestionToolUseIds:k,api:T,cwd:N,tool:L,sessionKey:P,onSend:O,awaitingUser:I,onAbort:R,onNewSession:j,onClearSession:z,chatRootRef:$,chatBodyRef:F,topSentinelRef:A,drawers:B,xtermSlot:E,fileSharingScope:H,onShareFile:q,onOpenInTab:M,onPreviewMarkdown:re,onOpenFiles:oe,onTogglePin:V,isHolded:pe,onToggleHold:Oe,personaName:ie,onOpenPersona:Me}){return h.jsx(vY,{children:h.jsxs("div",{ref:$,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-0",children:[h.jsx(lZ,{meta:e,...L?{tool:L}:{},connState:t,...n?{models:n}:{},...r!==void 0?{liveGitBranch:r}:{},...i!==void 0?{liveWorktreeRoot:i}:{},...s?{onOpenConfig:s}:{},...o?{onForceStop:o}:{},cronActiveCount:a,...l?{onCronClick:l}:{},...oe?{onOpenFiles:oe}:{},...V?{onTogglePin:V}:{},isHolded:pe??!1,...Oe?{onToggleHold:Oe}:{},...ie?{personaName:ie}:{},...Me?{onOpenPersona:Me}:{}}),h.jsxs("div",{ref:F,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none"},children:[A?h.jsx("div",{ref:A,"data-testid":"top-sentinel","aria-hidden":"true",style:{height:1}}):null,h.jsx(BR,{lines:c,...p?{onPermissionRespond:p}:{},...m&&d?{onPermissionInterrupt:m}:{},topSlot:x,...v?{onRewind:v}:{},rewindableUserMessageIds:f,...y?{onFork:y}:{},..._?{onQuickAsk:_}:{},realtimeQuestionAnswers:b,onSubmitQuestion:w,...S?{onCancelQuestion:S}:{},liveQuestionToolUseIds:k,...H?{fileSharingScope:H}:{},...q?{onShareFile:q}:{},...M?{onOpenInTab:M}:{},...re?{onPreviewMarkdown:re}:{}})]}),E,h.jsx(oZ,{meta:e,...T?{api:T}:{},cwd:N,...L?{tool:L}:{},sessionKey:P,onSend:O,awaitingUser:I,...R?{onAbort:R}:{},...j?{onNewSession:j}:{},...z?{onClearSession:z}:{}}),B]})})}function by({state:e,extras:t,onQuickAskInternal:n,onPreviewMdInternal:r}){const{session:i,api:s,models:o,liveGitBranch:a,liveWorktreeRoot:l,onNewSession:c,onTurnEnd:u,onOpenConfig:d,onFork:f,onQuickAsk:p,viewerRole:m,holdIds:v,onToggleHold:y}=t,{capabilities:_}=my(i.tool||"claude"),x=(_==null?void 0:_.features)??NN(i.tool),[b,w]=g.useState(null),[S,k]=g.useState(!1),[T,N]=g.useState(!1),L=Af(),P=!!s&&L.actionsLevel==="owner"&&x.fileSharing,O=MN(i.ownerPersonaId??null).persona,I=(O==null?void 0:O.label)??null,R=!!I&&!!i.ownerPersonaId,j=g.useCallback(()=>{N(!1),k(!0)},[]),z=g.useCallback(()=>{k(!1),N(!0)},[]),$=g.useCallback((Z,_e)=>{w({kind:Z,text:_e}),setTimeout(()=>{w(xe=>(xe==null?void 0:xe.text)===_e?null:xe)},2e3)},[]),F=Is(),A=zO(),B=rA(i.sessionId,i.toolSessionId),{events:E,pendingQuestions:H,clearQuestion:q,markQuestionSubmitted:M,status:re}=B,oe=e.historyLoading,V=hM(re);g.useEffect(()=>{Ae("chat-panel","sessionStatus",{sessionId:i.sessionId,sessionStatus:re,procAlive:V})},[re,V,i.sessionId]);const pe=e.lines,Oe=e.pendingPermissions,ie=Oe[0]??null,Me=g.useMemo(()=>S7(E),[E]),[Fe,We]=g.useState(!1),[ge,qe]=g.useState(null),[Gt,wt]=g.useState(()=>new Set);y7(s,i.sessionId,i.toolSessionId,x.observe);const Rt=g.useRef(i.sessionId);g.useEffect(()=>{if(Rt.current=i.sessionId,!x.rewind){qe(null);return}let Z=!1;return qe(null),(async()=>{try{const _e=await s.sessionRewindableMessageIds(i.sessionId);if(Z)return;qe(new Set(_e.userMessageIds))}catch{Z||qe(null)}})(),()=>{Z=!0}},[s,i.sessionId,x.rewind]);const ln=g.useCallback(()=>{const Z=i.sessionId;s.sessionRewindableMessageIds(Z).then(_e=>{Rt.current===Z&&qe(new Set(_e.userMessageIds))}).catch(()=>{})},[s,i.sessionId]),Bt=g.useMemo(()=>{if(ge!==null){const Ye=new Set(ge);for(const hi of Gt)Ye.delete(hi);return Ye}const Z=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),_e=new Set;let xe=null;for(const Ye of pe)Ye.kind==="user-text"?xe=Ye.uuid??null:xe&&Ye.kind==="tool-call"&&Z.has(Ye.tool)&&!Gt.has(xe)&&_e.add(xe);return _e},[pe,Gt,ge]),at=g.useRef(u);at.current=u,b7(i.sessionId,i.toolSessionId,()=>{pn(null),wt(new Set)});const Ue=DZ({sessionStatus:re}),nt=g.useRef(null);g.useEffect(()=>{var xe;const Z=nt.current,_e=(Z==null?void 0:Z.sid)===i.sessionId;_e&&Z.phase===Ue||(nt.current={sid:i.sessionId,phase:Ue},Ae("session-phase",Ue,{sid:i.sessionId,phase:Ue,prev:_e?Z.phase:null,desc:jZ[Ue]}),_e&&Z.phase==="turn-running"&&Ue!=="turn-running"&&((xe=at.current)==null||xe.call(at),ln()))},[Ue,i.sessionId,ln]);const mt=g.useCallback(()=>{s.sessionInterrupt(i.sessionId).catch(()=>{})},[s,i.sessionId]),[Xt,pn]=g.useState(null),U=g.useCallback(Z=>{pn(Z)},[]),[Q,ve]=g.useState(!1),Se=g.useCallback(()=>{s.sessionStop(i.sessionId).catch(()=>{}),ve(!1)},[s,i.sessionId]),J=g.useCallback(Z=>{s.pinSession(i.sessionId,Z).catch(_e=>{Ae("chat-panel","pinSession failed",{err:_e==null?void 0:_e.message})})},[s,i.sessionId]),Xe=(v==null?void 0:v.has(i.sessionId))??!1,Yt=g.useCallback(Z=>{y==null||y(i.sessionId,Z)},[y,i.sessionId]),Zt=g.useRef(0),ue=g.useRef(null);g.useEffect(()=>{const Z=_e=>{if(_e.key!=="Escape")return;if(!V){Zt.current=0;return}if(_e.isComposing)return;const Ye=_e.target;if(Ye&&Ye.closest("[data-cc-chat-root]")!==ue.current)return;const hi=Date.now();hi-Zt.current<2e3?(Zt.current=0,ve(!0)):(Zt.current=hi,mt())};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[mt,V]);const Ne=g.useRef(null),Je=g.useRef(null),Dn=g.useRef(!0),Qt=g.useRef(null),il=g.useRef(0),Ao=g.useRef(0);g.useEffect(()=>{Dn.current=!0,Qt.current=null,il.current=0,Ao.current=0},[i.sessionId]),g.useEffect(()=>{We(!1)},[i.sessionId]);const xu=g.useRef(e);xu.current=e;const yu=g.useCallback(()=>{var xe;const Z=Ne.current;if(!Z||Qt.current!==null)return;const _e=xu.current;_e.historyDone||_e.historyLoading||(Qt.current={distFromBottom:Z.scrollHeight-Z.scrollTop},(xe=_e.loadMoreHistory)==null||xe.call(_e))},[]);g.useEffect(()=>{const Z=Ne.current,_e=Je.current;if(!Z||!_e)return;const xe=new IntersectionObserver(Ye=>{for(const hi of Ye)hi.isIntersecting&&yu()},{root:Z,threshold:0});return xe.observe(_e),()=>xe.disconnect()},[yu]),g.useEffect(()=>{const Z=Ne.current;if(!Z)return;const _e=150,xe=Ye=>{Date.now()<Ao.current&&(Ye.preventDefault(),Ao.current=Date.now()+_e)};return Z.addEventListener("wheel",xe,{passive:!1}),()=>Z.removeEventListener("wheel",xe)},[]),g.useEffect(()=>{const Z=Ne.current;if(!Z)return;const _e=32,xe=()=>{const Ye=Z.scrollHeight-Z.scrollTop-Z.clientHeight;Dn.current=Ye<=_e};return Z.addEventListener("scroll",xe,{passive:!0}),()=>Z.removeEventListener("scroll",xe)},[]),g.useLayoutEffect(()=>{const Z=Ne.current;if(!Z)return;const _e=il.current,xe=pe.length;il.current=xe;const Ye=Qt.current;if(Ye!==null&&xe>_e){Qt.current=null,Z.scrollTop=Z.scrollHeight-Ye.distFromBottom,Ao.current=Date.now()+200;return}Ye!==null&&(Qt.current={distFromBottom:Z.scrollHeight-Z.scrollTop}),Dn.current&&(Z.scrollTop=Z.scrollHeight)},[pe,ie==null?void 0:ie.requestId]);const lp=g.useMemo(()=>{const Z={};for(const[_e,xe]of Object.entries(H))xe.submittedAnswers&&(Z[_e]=xe.submittedAnswers);return Z},[H]),cp=g.useMemo(()=>new Set(Object.keys(H)),[H]),bu=g.useCallback(async(Z,_e)=>{try{await s.answerQuestion({sessionId:i.sessionId,toolUseId:Z,answers:_e}),M(Z,_e)}catch{}},[s,i.sessionId,M]),jo=g.useCallback(async Z=>{try{await s.cancelQuestion({sessionId:i.sessionId,toolUseId:Z}),q(Z)}catch{}},[s,i.sessionId,q]),Do=g.useCallback(async(Z,_e)=>{var xe;if(ie)try{await((xe=e.respondPermission)==null?void 0:xe.call(e,ie.requestId,Z?"allow":"deny"))}catch{}},[e,ie]),sl=g.useCallback(async()=>{const Z=i.sessionId;try{await s.sessionStop(Z)}catch{}e.clearSession?await e.clearSession():await s.sessionNew(Z)},[e,s,i.sessionId]),ol=g.useMemo(()=>oe&&pe.length===0?h.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:h.jsx(rr,{className:"w-4 h-4 text-text-400 animate-spin"})}):e.historyDone?null:h.jsx("div",{className:"flex justify-center py-2",children:h.jsx("button",{type:"button",onClick:()=>{var Z;return void((Z=e.loadMoreHistory)==null?void 0:Z.call(e))},disabled:oe,"data-testid":"history-load-more",className:"text-[12px] text-text-400 hover:text-text-200 cursor-pointer px-3 py-1 rounded-md border border-bg-300 hover:bg-bg-100 transition-colors disabled:opacity-60",children:oe?"加载中…":"Load earlier messages"})}),[oe,pe.length,e.historyDone,e.loadMoreHistory]),Ui=e.meta,Wi=h.jsxs(h.Fragment,{children:[i.toolSessionId&&x.subagents?h.jsx(pZ,{api:s,cwd:i.cwd,toolSessionId:i.toolSessionId}):null,Xt&&x.rewind?h.jsx(gZ,{open:!0,onOpenChange:Z=>{Z||pn(null)},api:s,sessionId:i.sessionId,userMessageId:Xt,lines:pe,procAlive:V,onNoChanges:Z=>{wt(_e=>{if(_e.has(Z))return _e;const xe=new Set(_e);return xe.add(Z),xe})}}):null,Q?h.jsx(nne,{onConfirm:Se,onCancel:()=>ve(!1)}):null,h.jsx(AZ,{open:Fe,onClose:()=>We(!1),jobs:Me})]}),al={kind:"session",sessionId:i.sessionId},wu=g.useCallback(async Z=>{if(s)try{await gte(s,F,i.sessionId,Z)}catch(_e){const xe=_e.message;Ae("chat-panel","open-in-tab failed",{err:xe}),$("err",`Open in tab 失败:${xe}`)}},[s,F,i.sessionId,$]),[zt,ll]=g.useState(!1),[cl,Tt]=g.useState(null),$t=g.useCallback(Z=>{if(r){r(Z);return}Tt(Z),ll(!0)},[r]),or=g.useCallback(async Z=>{if(!s)throw new Error("daemon api not ready");const _e=await gy(s,F,i.sessionId,Z,60),xe=await fetch(_e);if(!xe.ok)throw new Error(`fetch ${xe.status} ${xe.statusText}`);return await xe.text()},[s,F,i.sessionId]),Ln=g.useCallback(async(Z,_e)=>{if(s)try{const{url:xe}=await s.attachmentSignUrl({sessionId:i.sessionId,relPath:Z,ttlSeconds:86400,..._e?{view:_e}:{}}),Ye=await vte(xe);$(Ye?"ok":"err",Ye?"分享链接已复制到剪贴板(24h 有效)":"复制失败:请手动复制")}catch(xe){const Ye=xe.message;Ae("chat-panel","share-file failed",{err:Ye}),$("err",`生成分享链接失败:${Ye}`)}},[s,i.sessionId,$]);return h.jsxs(h.Fragment,{children:[h.jsx(tne,{headerMeta:Ui,connState:e.connState,...o?{models:o}:{},...a!==void 0?{liveGitBranch:a}:{},...l!==void 0?{liveWorktreeRoot:l}:{},...d?{onOpenConfig:d}:{},onForceStop:()=>ve(!0),cronActiveCount:Me.length,onCronClick:()=>We(!0),lines:pe,pendingPermissions:Oe,procAlive:V,rewindableUserMessageIds:Bt,onPermissionRespond:Do,onPermissionInterrupt:mt,onRewind:x.rewind?U:void 0,...f&&x.fork?{onFork:f}:{},...n&&x.fork?{onQuickAsk:n}:p&&x.fork?{onQuickAsk:p}:{},topSlot:ol,realtimeQuestionAnswers:lp,onSubmitQuestion:bu,onCancelQuestion:jo,liveQuestionToolUseIds:cp,api:s,cwd:i.cwd,...i.tool?{tool:i.tool}:{},sessionKey:i.sessionId,onSend:e.sendText,awaitingUser:Oe.length>0||Object.values(H).some(Z=>!Z.submittedAnswers),onAbort:mt,...c?{onNewSession:c}:{},onClearSession:sl,chatRootRef:ue,chatBodyRef:Ne,topSentinelRef:Je,drawers:Wi,xtermSlot:A==="tui"&&V&&x.tui?h.jsx(Xee,{sessionId:i.sessionId,client:F},i.sessionId):null,fileSharingScope:al,...s?{onShareFile:Ln}:{},...s?{onOpenInTab:wu}:{},...s?{onPreviewMarkdown:$t}:{},...P?{onOpenFiles:j}:{},onTogglePin:J,isHolded:Xe,...y?{onToggleHold:Yt}:{},...R?{personaName:I}:{},...R?{onOpenPersona:z}:{}}),P&&s?h.jsx(tte,{api:s,open:S,onOpenChange:k,scope:al,sessionId:i.sessionId,onShareFile:Ln,onOpenInTab:wu}):null,s?h.jsx(yte,{open:zt,onOpenChange:ll,relPath:cl,loadMarkdown:or,onShare:cl?()=>void Ln(cl,"md-rendered"):void 0}):null,R&&s&&i.ownerPersonaId?h.jsx(fte,{api:s,open:T,onOpenChange:N,personaId:i.ownerPersonaId,personaName:I??"",...m?{viewerRole:m}:{}}):null,b?h.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:b.kind==="ok"?"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-[12px] text-emerald-700 shadow-md dark:text-emerald-300":"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive shadow-md",children:b.text}):null]})}function nne({onConfirm:e,onCancel:t}){return h.jsx("div",{role:"dialog","aria-modal":"true","data-testid":"force-stop-confirm",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:t,children:h.jsxs("div",{className:"max-w-sm w-[92%] rounded-lg border border-red-400/40 bg-bg-0 p-4 shadow-xl",onClick:n=>n.stopPropagation(),children:[h.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[h.jsx(Ac,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),h.jsx("div",{className:"text-[14px] text-text-100",children:"强制停止会话进程?会丢失 initialize / 预热缓存,下一次发送需要重新 spawn。"})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:t,className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button","data-testid":"force-stop-confirm-ok",onClick:e,className:"h-8 px-3 rounded-md bg-red-500 text-white text-[12px] font-medium hover:bg-red-600 cursor-pointer",children:"强制停止"})]})]})})}function rne({current:e,models:t,onSelect:n}){return h.jsxs("div",{children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-2",children:"Model"}),h.jsx("div",{className:"flex flex-wrap gap-1.5","data-testid":"config-model-selector",children:t.map(r=>{const i=(e||"")===r.id;return h.jsx("button",{type:"button",onClick:()=>n(r.id),"data-testid":`config-model-${r.id||"default"}`,className:ne("px-3 py-1.5 rounded-lg text-[12px] font-medium transition-colors cursor-pointer",i?"bg-accent text-white shadow-sm":"bg-bg-100 text-text-300 hover:bg-bg-200 hover:text-text-100"),children:r.label},r.id||"default")})})]})}function ine({current:e,modes:t,onSelect:n}){var i;const r=(i=t.find(s=>s.id===(e||"")))==null?void 0:i.description;return h.jsxs("div",{children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-2",children:"Permission Mode"}),h.jsx("div",{className:"flex flex-wrap gap-1.5","data-testid":"config-mode-selector",children:t.map(s=>{const o=(e||"")===s.id;return h.jsx("button",{type:"button",onClick:()=>n(s.id),"data-testid":`config-mode-${s.id||"default"}`,className:ne("px-3 py-1.5 rounded-lg text-[12px] font-medium transition-colors cursor-pointer",o?"bg-accent text-white shadow-sm":"bg-bg-100 text-text-300 hover:bg-bg-200 hover:text-text-100"),children:s.label},s.id||"default")})}),r?h.jsx("p",{className:"text-[11px] text-text-400 mt-1.5",children:r}):null]})}function sne({open:e,onOpenChange:t,session:n,onPatch:r,embedded:i=!1,viewerRole:s="owner"}){var m;const{capabilities:o}=my(e?n.tool||"claude":null),a=(o==null?void 0:o.models)??[],l=(o==null?void 0:o.permissionModes)??[],c=((m=o==null?void 0:o.configSchema.find(v=>v.name==="permissionMode"))==null?void 0:m.default)??"",u=n.permissionMode&&l.some(v=>v.id===n.permissionMode)?n.permissionMode:c,d=g.useMemo(()=>(o==null?void 0:o.configSchema.filter(v=>v.scope==="tool-specific"))??[],[o]),f=(o==null?void 0:o.toolSessionIdLabel)??"Tool Session ID";if(!e)return null;const p=h.jsxs("div",{className:"flex-1 min-h-0 flex flex-col px-4 py-4 gap-6 overflow-y-auto",children:[h.jsxs("div",{className:"shrink-0",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1",children:"Working Directory"}),h.jsx("div",{className:"text-[12px] font-mono text-text-300 bg-bg-100 rounded-lg px-3 py-2 truncate","data-testid":"config-cwd",title:n.cwd,children:n.cwd})]}),h.jsx("div",{className:"shrink-0",children:h.jsx(rne,{current:n.model??"",models:a,onSelect:v=>void r({model:v})})}),h.jsx("div",{className:"shrink-0",children:h.jsx(ine,{current:u,modes:l,onSelect:v=>void r({permissionMode:v})})}),d.length>0?h.jsx("div",{className:"shrink-0",children:h.jsx(one,{fields:d,session:n,onPatch:r})}):null,h.jsx("div",{className:"shrink-0",children:h.jsx(Hk,{testId:"config-session-id",label:"Clawd Session ID",value:n.sessionId})}),n.toolSessionId?h.jsx("div",{className:"shrink-0",children:h.jsx(Hk,{testId:"config-tool-session-id",label:f,value:n.toolSessionId})}):null]});return i?h.jsxs("div",{"data-testid":"config-drawer",className:"h-full w-full flex flex-col",children:[h.jsx("div",{className:"flex items-center px-4 py-3 border-b border-bg-300/30 shrink-0",children:h.jsx("span",{className:"text-[14px] font-semibold text-text-100",children:"Session Settings"})}),p]}):h.jsxs("div",{"data-testid":"config-drawer",className:"h-full w-full flex flex-col border-l border-bg-300/40 bg-bg-0 min-w-0",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bg-300/30 shrink-0",children:[h.jsx("span",{className:"text-[14px] font-semibold text-text-100",children:"Session Settings"}),h.jsx("button",{type:"button",onClick:()=>t(!1),"data-testid":"config-drawer-close",className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"Close",children:h.jsx(Rn,{className:"w-4 h-4"})})]}),p]})}function Hk({testId:e,label:t,value:n}){const[r,i]=g.useState(!1),s=g.useRef(null);g.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const o=()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(n).then(()=>{i(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>i(!1),2e3)},()=>{})};return h.jsxs("div",{"data-testid":e,children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1",children:t}),h.jsxs("button",{type:"button",onClick:o,"data-testid":`${e}-copy`,title:r?"Copied":`Copy: ${n}`,className:"w-full flex items-center gap-2 text-[12px] font-mono text-text-300 bg-bg-100 hover:bg-bg-200 rounded-lg px-3 py-2 transition-colors cursor-pointer text-left group",children:[h.jsx("span",{className:"truncate flex-1 min-w-0","data-testid":`${e}-value`,children:n}),r?h.jsx(Za,{className:"w-3.5 h-3.5 shrink-0 text-accent"}):h.jsx(su,{className:"w-3.5 h-3.5 shrink-0 opacity-60 group-hover:opacity-100 transition-opacity"})]})]})}function one({fields:e,session:t,onPatch:n}){return h.jsxs("div",{"data-testid":"config-advanced",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-2",children:"Advanced"}),h.jsx("div",{className:"space-y-3",children:e.map(r=>h.jsx(ane,{field:r,session:t,onPatch:n},r.name))})]})}function ane({field:e,session:t,onPatch:n}){if(e.type!=="select"||!e.options)return null;const r=t[e.name]??"",i=e.options.some(s=>s.value===r)?r:e.default??"";return h.jsxs("div",{"data-testid":`config-advanced-${e.name}`,children:[h.jsx("div",{className:"text-[11px] text-text-400 mb-1.5",children:e.label}),h.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.options.map(s=>{const o=i===s.value;return h.jsx("button",{type:"button","data-testid":`config-advanced-${e.name}-${s.value||"default"}`,onClick:()=>void n({[e.name]:s.value}),className:ne("px-3 py-1.5 rounded-lg text-[12px] font-medium transition-colors cursor-pointer",o?"bg-accent text-white shadow-sm":"bg-bg-100 text-text-300 hover:bg-bg-200 hover:text-text-100"),children:s.label},s.value||"default")})})]})}function lne(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitBranch(t);i(l.branch??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{branch:r,loading:s,refresh:()=>void a()}}function cne(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitRoot(t);i(l.gitRoot??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{worktreeRoot:r,loading:s,refresh:()=>void a()}}function une({api:e,session:t,focused:n,totalPanes:r,onFocus:i,onClose:s,onNewSession:o,onOpenConfig:a,onConfigPatch:l,onFork:c,onQuickAsk:u,className:d,viewerRole:f="owner",holdIds:p,onToggleHold:m}){const{capabilities:v}=my(t.tool),[y,_]=g.useState(0),[x,b]=g.useState(!1),{initialSize:w,setSize:S}=cA("clawd:panel:config-px",360),{branch:k}=lne(e,t.cwd,y),{worktreeRoot:T}=cne(e,t.cwd,y),N=r>1,L=P=>{P==="desktop"?b(!0):a()};return h.jsxs("div",{className:`group/pane relative flex-1 ${d??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${N?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:i,"data-testid":`session-pane-${t.sessionId}`,children:[h.jsxs(Ix,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx($c,{id:"chat",minSize:"400px",children:h.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:h.jsx(dne,{api:e,session:t,models:v==null?void 0:v.models,liveGitBranch:k,liveWorktreeRoot:T,onNewSession:o,onTurnEnd:()=>_(P=>P+1),onOpenConfig:L,onFork:c,onQuickAsk:u,viewerRole:f,holdIds:p,onToggleHold:m})})}),x&&h.jsxs(h.Fragment,{children:[h.jsx(Mx,{className:"hidden md:block w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx($c,{id:"config",defaultSize:`${w}px`,minSize:"360px",maxSize:"560px",onResize:P=>S(P.inPixels),children:h.jsx("div",{className:"hidden md:flex h-full",children:h.jsx(sne,{open:x,onOpenChange:b,session:t,onPatch:l,viewerRole:f})})})]})]}),N&&h.jsx("button",{type:"button",onClick:P=>{P.stopPropagation(),s()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:h.jsx(Rn,{className:"w-3.5 h-3.5"})})]})}function dne({api:e,session:t,models:n,liveGitBranch:r,liveWorktreeRoot:i,onNewSession:s,onTurnEnd:o,onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:u,holdIds:d,onToggleHold:f}){return h.jsx(Jte,{extras:{session:t,api:e,...n?{models:n}:{},...r!==void 0?{liveGitBranch:r}:{},...i!==void 0?{liveWorktreeRoot:i}:{},onNewSession:s,onTurnEnd:o,onOpenConfig:a,...l?{onFork:p=>{l(p)}}:{},...c?{onQuickAsk:p=>{c(p)}}:{},...u?{viewerRole:u}:{},...d?{holdIds:d}:{},...f?{onToggleHold:f}:{}}})}function hne({personas:e,sessions:t,api:n,selfPrincipalId:r,selectedPersonaId:i,selectedSessionId:s,selectedSession:o,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,onCloseSession:f,onConfigPatch:p}){return h.jsxs("div",{className:"flex h-screen min-h-0 bg-bg-50","data-testid":"guest-share-page",children:[h.jsx("aside",{className:"w-[280px] shrink-0 overflow-y-auto border-r border-border bg-bg-50",children:h.jsx(BH,{personas:e,sessions:t,activePersonaId:i,activeSessionId:s,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,showCopyResume:!1,treatSessionsAsRoots:!0,...r?{ownerPrincipalId:r}:{},isPersonaExpanded:()=>!0})}),h.jsx("main",{className:"flex-1 min-w-0 min-h-0 flex",children:o?h.jsx(une,{api:n,session:o,focused:!0,totalPanes:1,onFocus:()=>{},onClose:f,onNewSession:()=>{},onOpenConfig:()=>{},onConfigPatch:p,viewerRole:"guest"}):h.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-xs text-text-400","data-testid":"guest-share-empty",children:"选择左侧 persona 开始对话"})})]})}function fne(){const e=Is(),t=g.useMemo(()=>new V_(e),[e]),n=oB(e),{sessions:r,refresh:i}=aB(n),{personas:s}=RN(),o=fB(),a=g.useMemo(()=>{const w=window.location.pathname.match(/^\/s\/([^/]+)/);return w?decodeURIComponent(w[1]):null},[]),l=g.useMemo(()=>r.filter(w=>!w.ephemeral),[r]),c=g.useMemo(()=>a?s.filter(w=>w.personaId===a):s,[s,a]),[u,d]=g.useState(null),[f,p]=g.useState(null),[m,v]=g.useState(null);g.useEffect(()=>{let w=!1;return e.request("whoami",{}).then(S=>{w||d(S.capability.id)}).catch(()=>{}),()=>{w=!0}},[e]),g.useEffect(()=>{a&&p(a)},[a]);const y=g.useCallback(async(w,S)=>{const k=await t.sessionCreate({ownerPersonaId:w,...S.trim()?{label:S.trim()}:{}});await i(),p(w),v(k.sessionId)},[t,i]),_=g.useCallback(async w=>{await t.sessionDelete(w),await i(),v(S=>S===w?null:S)},[t,i]),x=g.useCallback(async(w,S)=>{await t.sessionUpdate(w,{label:S.label,iconKey:S.iconKey===null?"":S.iconKey}),await i()},[t,i]),b=g.useMemo(()=>l.find(w=>w.sessionId===m)??null,[l,m]);return h.jsx(q_.Provider,{value:o,children:h.jsx(hne,{personas:c,sessions:l,api:t,selfPrincipalId:u,selectedPersonaId:f,selectedSessionId:m,selectedSession:b,onSelectPersona:p,onSelectSession:v,onCreateSession:(w,S)=>void y(w,S),onDeleteSession:w=>void _(w),onEditSession:(w,S)=>void x(w,S),onCloseSession:()=>v(null),onConfigPatch:async()=>{}})})}const Uk="https://app.ttcadvisory.com";function pne({onAuthed:e}){const[t,n]=g.useState(!1),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>()=>{s.current&&window.removeEventListener("message",s.current)},[]);const o=g.useCallback(()=>{s.current&&(window.removeEventListener("message",s.current),s.current=null),n(!0),i(null);const a=window.location.origin,l=`${Uk}/auth/authorize?callback_url=${encodeURIComponent(a)}&auto=1`,c=async d=>{if(d.origin!==Uk)return;const f=d.data;if((f==null?void 0:f.type)==="AUTH_CANCEL"){u(),n(!1);return}if(!((f==null?void 0:f.type)!=="AUTH_SUCCESS"||!f.token)){u();try{const p=await fetch(`${window.location.origin}/share/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ttcToken:f.token})});if(!p.ok){const v=await p.json().catch(()=>({}));throw new Error(v.code??`exchange failed (${p.status})`)}const m=await p.json();if(!m.visitorToken)throw new Error("no visitorToken in response");e(m.visitorToken)}catch(p){i(p instanceof Error?p.message:String(p)),n(!1)}}},u=()=>{window.removeEventListener("message",c),s.current=null};s.current=d=>void c(d),window.addEventListener("message",s.current),window.open(l,"ttc-login","width=480,height=640")},[e]);return h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 font-sans text-text-100","data-testid":"guest-login",children:h.jsxs("div",{className:"flex w-full max-w-xs flex-col gap-3 rounded-lg border border-border bg-bg-100 px-5 py-6",children:[h.jsx("h1",{className:"text-base font-semibold",children:"登录后进入分享"}),h.jsx("p",{className:"text-[11px] leading-snug text-text-400",children:"使用飞书账号登录,即可在浏览器里与分享给你的 persona 交互,无需安装。"}),r?h.jsxs("p",{className:"text-[11px] leading-snug text-error","data-testid":"guest-login-error",children:["登录失败:",r]}):null,h.jsx("button",{type:"button",disabled:t,onClick:()=>o(),"data-testid":"guest-login-button",className:"w-full rounded border border-border bg-bg-50 px-2 py-1.5 text-xs text-text-200 transition-colors hover:bg-text-100/5 hover:text-text-100 disabled:opacity-50",children:t?"请在弹窗中完成授权…":"飞书登录"})]})})}const j0="clawd-visitor:token";function mne(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}function gne(){return{async getUrl(e){const t=localStorage.getItem(j0);if(!t)throw new Error("NO_VISITOR_TOKEN");const n=mne(window.location,{});return await wN(e).upsert({id:"guest",name:"访客",mode:"remote",url:n,token:t}),{url:n}}}}function vne(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function _ne(){const e=Is(),t=g.useMemo(()=>sB(e),[e]);return h.jsx($O,{cache:t.cache,children:h.jsx(UO,{children:h.jsx(fne,{})})})}function xne({host:e}){const[t]=g.useState(()=>localStorage.getItem(j0)),[n,r]=g.useState(!1),[i,s]=g.useState(null);return g.useEffect(()=>vne(e),[e]),g.useEffect(()=>{if(!t)return;let o=!1;return gne().getUrl(e).then(()=>{o||r(!0)}).catch(a=>{o||s(a instanceof Error?a.message:String(a))}),()=>{o=!0}},[e,t]),t?h.jsx(L1,{host:e,children:h.jsx(mb,{children:i?h.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-center text-xs text-error","data-testid":"guest-share-connect-error",children:["连接失败:",i]}):n?h.jsx(BO,{host:e,children:h.jsx(_ne,{})}):h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-xs text-text-400",children:"正在连接…"})})}):h.jsx(L1,{host:e,children:h.jsx(mb,{children:h.jsx(pne,{onAuthed:o=>{localStorage.setItem(j0,o),window.location.reload()}})})})}function yne({filePath:e,oldString:t,newString:n,content:r}){const i=g.useMemo(()=>r!=null?r.split(/\r?\n/).map(s=>({type:"add",text:s})):bne(t??"",n??""),[t,n,r]);return h.jsxs("div",{"data-testid":"inline-diff",className:"min-w-0 max-w-full rounded-lg border border-bg-300/60 bg-bg-50 overflow-hidden text-[12px] font-mono",children:[h.jsx("div",{className:"flex min-w-0 items-center gap-2 px-3 py-1.5 border-b border-bg-300/40 bg-bg-100/30",children:h.jsx("span",{className:"min-w-0 text-text-400 truncate",title:e,children:e})}),h.jsx("div",{className:"max-h-[320px] max-w-full overflow-auto",children:i.map((s,o)=>h.jsxs("div",{"data-testid":`diff-line-${s.type}`,className:ne("flex min-w-max gap-2 px-3 py-0.5 whitespace-pre",s.type==="add"?"bg-success/10 text-success":s.type==="remove"?"bg-error/10 text-error":"text-text-300"),children:[h.jsx("span",{className:"w-3 shrink-0 select-none opacity-60",children:s.type==="add"?"+":s.type==="remove"?"-":" "}),h.jsx("span",{className:"flex-1",children:s.text||" "})]},o))})]})}function bne(e,t){const n=e.split(/\r?\n/),r=t.split(/\r?\n/),i=n.length,s=r.length,o=Array.from({length:i+1},()=>new Array(s+1).fill(0));for(let u=i-1;u>=0;u--)for(let d=s-1;d>=0;d--)o[u][d]=n[u]===r[d]?o[u+1][d+1]+1:Math.max(o[u+1][d],o[u][d+1]);const a=[];let l=0,c=0;for(;l<i&&c<s;)n[l]===r[c]?(a.push({type:"equal",text:n[l]}),l++,c++):o[l+1][c]>=o[l][c+1]?(a.push({type:"remove",text:n[l]}),l++):(a.push({type:"add",text:r[c]}),c++);for(;l<i;)a.push({type:"remove",text:n[l++]});for(;c<s;)a.push({type:"add",text:r[c++]});return a}function wne({items:e}){return e.length===0?null:h.jsxs("div",{"data-testid":"todo-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1.5",children:"Todos"}),h.jsx("ul",{className:"flex flex-col gap-1",children:e.map((t,n)=>{const r=t.status==="in_progress"&&t.activeForm||t.content;return h.jsxs("li",{"data-testid":`todo-item-${t.status}`,className:"flex items-start gap-2",children:[h.jsx(Sne,{status:t.status}),h.jsx("span",{className:ne("flex-1 leading-snug",t.status==="completed"?"text-text-400 line-through":t.status==="in_progress"?"text-text-100 font-medium":"text-text-200"),children:r})]},n)})})]})}function Sne({status:e}){return e==="completed"?h.jsx(jf,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?h.jsx(rr,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):h.jsx(DN,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function kne(e){const t=e??{};return Array.isArray(t.todos)?t.todos.map(n=>{if(!n||typeof n!="object")return null;const r=n,i=typeof r.content=="string"?r.content:"",s=r.status==="pending"||r.status==="in_progress"||r.status==="completed"?r.status:"pending",o=typeof r.activeForm=="string"?r.activeForm:void 0;return{content:i,status:s,activeForm:o}}).filter(n=>n!==null):[]}function Cne({description:e,prompt:t,subagentType:n}){return h.jsxs("div",{"data-testid":"task-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsxs("div",{className:"flex items-center gap-2 text-text-200 font-medium",children:[h.jsx(K_,{className:"w-3.5 h-3.5 text-accent shrink-0"}),h.jsx("span",{className:"truncate",children:e||"subagent task"}),n?h.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded-md text-[10px] font-mono bg-accent/10 text-accent",children:n}):null]}),t?h.jsx("div",{className:"mt-1 text-[12px] text-text-400 leading-snug line-clamp-3",children:t}):null]})}function Ene(e){const t=e??{};return{description:typeof t.description=="string"?t.description:"",prompt:typeof t.prompt=="string"?t.prompt:void 0,subagentType:typeof t.subagent_type=="string"?t.subagent_type:void 0}}const Nne={render:({input:e})=>st.createElement(wne,{items:kne(e)})},Tne={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=Ene(e);return st.createElement(Cne,{description:t,prompt:n,subagentType:r})}},dA={render:({input:e,output:t,error:n,pending:r,fileScope:i,onShareFile:s,onOpenInTab:o,onPreviewMarkdown:a})=>{const l=Ine(e),c=l?st.createElement(yne,{filePath:l.filePath,oldString:l.oldString,newString:l.newString,content:l.content}):void 0;return st.createElement(MR,{tool:Pne(e),input:e,output:t,error:n,pending:r,expandedBody:c,...i?{fileScope:i}:{},...s?{onShareFile:s}:{},...o?{onOpenInTab:o}:{},...a?{onPreviewMarkdown:a}:{}})}};function Pne(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function Ine(e){const t=e??{},n=typeof t.file_path=="string"?t.file_path:null;if(!n)return null;const r=typeof t.old_string=="string"?t.old_string:void 0,i=typeof t.new_string=="string"?t.new_string:void 0,s=typeof t.content=="string"?t.content:void 0;return r==null&&i==null&&s==null?null:{filePath:n,oldString:r,newString:i,content:s}}pu.register("claude","TodoWrite",Nne);pu.register("claude","Task",Tne);pu.register("claude","Edit",dA);pu.register("claude","Write",dA);const hA=document.getElementById("root");if(!hA)throw new Error("guest-main: #root not found");const Rne=qj({});Fm.createRoot(hA).render(h.jsx(st.StrictMode,{children:h.jsx(xne,{host:Rne})}));