@anhlp/alp-cli 0.0.1-beta.3 → 0.0.1-beta.6
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.
- package/dist/THIRD-PARTY-NOTICES.txt +51 -1
- package/dist/acp/main.js +1 -1
- package/dist/acp.js +300 -92
- package/dist/alp-web/THIRD-PARTY-NOTICES.txt +3256 -0
- package/dist/alp-web/alp-boundary.json +16 -0
- package/dist/alp-web/apple-touch-icon.png +0 -0
- package/dist/alp-web/assets/TerminalPanel-CqTsgY-W.js +22 -0
- package/dist/alp-web/assets/TerminalPanel-DLuoa74B.css +1 -0
- package/dist/alp-web/assets/highlighter-BnicKQ_d.js +18 -0
- package/dist/alp-web/assets/index-BMbDUCHW.css +1 -0
- package/dist/alp-web/assets/index-B_RFaj2C.js +59 -0
- package/dist/alp-web/favicon-attention.svg +6 -0
- package/dist/alp-web/favicon-running.svg +6 -0
- package/dist/alp-web/favicon.svg +5 -0
- package/dist/alp-web/index.html +20 -0
- package/dist/alp-web.js +10119 -0
- package/dist/alpd.js +30333 -15153
- package/dist/backup.js +2 -2
- package/dist/build-manifest.json +120 -2
- package/dist/cli.js +34 -3
- package/dist/daemon.d.ts +1 -1
- package/dist/daemon.js +5 -0
- package/dist/interfaces.d.ts +22 -2
- package/dist/interfaces.js +182 -37
- package/dist/paths.d.ts +1 -0
- package/dist/paths.js +2 -1
- package/dist/roles.d.ts +15 -0
- package/dist/roles.js +18 -0
- package/dist/schedules.d.ts +2 -0
- package/dist/schedules.js +45 -0
- package/dist/self-update.d.ts +152 -0
- package/dist/self-update.js +390 -0
- package/dist/sessions.d.ts +7 -1
- package/dist/sessions.js +44 -12
- package/dist/tasks.js +22 -8
- package/dist/terminal-native/README.md +201 -0
- package/dist/terminal-native/prebuilt/darwin-arm64/manifest.json +11 -0
- package/dist/terminal-native/prebuilt/darwin-arm64/terminal-owner +0 -0
- package/dist/terminal-native/prebuilt/darwin-x64/manifest.json +11 -0
- package/dist/terminal-native/prebuilt/darwin-x64/terminal-owner +0 -0
- package/dist/terminal-native/prebuilt/linux-arm64-glibc/manifest.json +10 -0
- package/dist/terminal-native/prebuilt/linux-arm64-glibc/terminal-owner +0 -0
- package/dist/terminal-native/prebuilt/linux-arm64-musl/manifest.json +10 -0
- package/dist/terminal-native/prebuilt/linux-arm64-musl/terminal-owner +0 -0
- package/dist/terminal-native/prebuilt/linux-x64-glibc/manifest.json +10 -0
- package/dist/terminal-native/prebuilt/linux-x64-glibc/terminal-owner +0 -0
- package/dist/terminal-native/prebuilt/linux-x64-musl/manifest.json +10 -0
- package/dist/terminal-native/prebuilt/linux-x64-musl/terminal-owner +0 -0
- package/dist/terminal-native/terminal-owner.c +389 -0
- package/dist/terminal.d.ts +13 -0
- package/dist/terminal.js +80 -0
- package/dist/usage.d.ts +1 -1
- package/dist/usage.js +22 -7
- package/dist/web-service.d.ts +56 -0
- package/dist/web-service.js +143 -0
- package/package.json +11 -4
- package/src/backup.js +1 -1
- package/src/cli.js +40 -4
- package/src/daemon.js +3 -0
- package/src/interfaces.js +227 -32
- package/src/paths.js +3 -1
- package/src/roles.js +28 -0
- package/src/schedules.js +38 -0
- package/src/self-update.js +406 -0
- package/src/sessions.js +44 -13
- package/src/tasks.js +22 -8
- package/src/terminal.js +78 -0
- package/src/usage.js +22 -7
- package/src/web-service.js +187 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-CqTsgY-W.js","assets/TerminalPanel-DLuoa74B.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
function Rk(s,t){for(var i=0;i<t.length;i++){const a=t[i];if(typeof a!="string"&&!Array.isArray(a)){for(const l in a)if(l!=="default"&&!(l in s)){const u=Object.getOwnPropertyDescriptor(a,l);u&&Object.defineProperty(s,l,u.get?u:{enumerable:!0,get:()=>a[l]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))a(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&a(d)}).observe(document,{childList:!0,subtree:!0});function i(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function a(l){if(l.ep)return;l.ep=!0;const u=i(l);fetch(l.href,u)}})();function _k(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var _d={exports:{}},Lr={};var px;function Lk(){if(px)return Lr;px=1;var s=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function i(a,l,u){var d=null;if(u!==void 0&&(d=""+u),l.key!==void 0&&(d=""+l.key),"key"in l){u={};for(var h in l)h!=="key"&&(u[h]=l[h])}else u=l;return l=u.ref,{$$typeof:s,type:a,key:d,ref:l!==void 0?l:null,props:u}}return Lr.Fragment=t,Lr.jsx=i,Lr.jsxs=i,Lr}var gx;function Ok(){return gx||(gx=1,_d.exports=Lk()),_d.exports}var o=Ok(),Ld={exports:{}},Ie={};var xx;function Dk(){if(xx)return Ie;xx=1;var s=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),y=Symbol.iterator;function v(T){return T===null||typeof T!="object"?null:(T=y&&T[y]||T["@@iterator"],typeof T=="function"?T:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,j={};function A(T,z,F){this.props=T,this.context=z,this.refs=j,this.updater=F||k}A.prototype.isReactComponent={},A.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},A.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function R(){}R.prototype=A.prototype;function q(T,z,F){this.props=T,this.context=z,this.refs=j,this.updater=F||k}var L=q.prototype=new R;L.constructor=q,S(L,A.prototype),L.isPureReactComponent=!0;var O=Array.isArray,B={H:null,A:null,T:null,S:null,V:null},_=Object.prototype.hasOwnProperty;function W(T,z,F,Z,ie,re){return F=re.ref,{$$typeof:s,type:T,key:z,ref:F!==void 0?F:null,props:re}}function E(T,z){return W(T.type,z,void 0,void 0,void 0,T.props)}function V(T){return typeof T=="object"&&T!==null&&T.$$typeof===s}function U(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(F){return z[F]})}var de=/\/+/g;function J(T,z){return typeof T=="object"&&T!==null&&T.key!=null?U(""+T.key):z.toString(36)}function me(){}function se(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(me,me):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function fe(T,z,F,Z,ie){var re=typeof T;(re==="undefined"||re==="boolean")&&(T=null);var le=!1;if(T===null)le=!0;else switch(re){case"bigint":case"string":case"number":le=!0;break;case"object":switch(T.$$typeof){case s:case t:le=!0;break;case x:return le=T._init,fe(le(T._payload),z,F,Z,ie)}}if(le)return ie=ie(T),le=Z===""?"."+J(T,0):Z,O(ie)?(F="",le!=null&&(F=le.replace(de,"$&/")+"/"),fe(ie,z,F,"",function(Ne){return Ne})):ie!=null&&(V(ie)&&(ie=E(ie,F+(ie.key==null||T&&T.key===ie.key?"":(""+ie.key).replace(de,"$&/")+"/")+le)),z.push(ie)),1;le=0;var ve=Z===""?".":Z+":";if(O(T))for(var Re=0;Re<T.length;Re++)Z=T[Re],re=ve+J(Z,Re),le+=fe(Z,z,F,re,ie);else if(Re=v(T),typeof Re=="function")for(T=Re.call(T),Re=0;!(Z=T.next()).done;)Z=Z.value,re=ve+J(Z,Re++),le+=fe(Z,z,F,re,ie);else if(re==="object"){if(typeof T.then=="function")return fe(se(T),z,F,Z,ie);throw z=String(T),Error("Objects are not valid as a React child (found: "+(z==="[object Object]"?"object with keys {"+Object.keys(T).join(", ")+"}":z)+"). If you meant to render a collection of children, use an array instead.")}return le}function H(T,z,F){if(T==null)return T;var Z=[],ie=0;return fe(T,Z,"","",function(re){return z.call(F,re,ie++)}),Z}function P(T){if(T._status===-1){var z=T._result;z=z(),z.then(function(F){(T._status===0||T._status===-1)&&(T._status=1,T._result=F)},function(F){(T._status===0||T._status===-1)&&(T._status=2,T._result=F)}),T._status===-1&&(T._status=0,T._result=z)}if(T._status===1)return T._result.default;throw T._result}var oe=typeof reportError=="function"?reportError:function(T){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var z=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof T=="object"&&T!==null&&typeof T.message=="string"?String(T.message):String(T),error:T});if(!window.dispatchEvent(z))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",T);return}console.error(T)};function xe(){}return Ie.Children={map:H,forEach:function(T,z,F){H(T,function(){z.apply(this,arguments)},F)},count:function(T){var z=0;return H(T,function(){z++}),z},toArray:function(T){return H(T,function(z){return z})||[]},only:function(T){if(!V(T))throw Error("React.Children.only expected to receive a single React element child.");return T}},Ie.Component=A,Ie.Fragment=i,Ie.Profiler=l,Ie.PureComponent=q,Ie.StrictMode=a,Ie.Suspense=m,Ie.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=B,Ie.__COMPILER_RUNTIME={__proto__:null,c:function(T){return B.H.useMemoCache(T)}},Ie.cache=function(T){return function(){return T.apply(null,arguments)}},Ie.cloneElement=function(T,z,F){if(T==null)throw Error("The argument must be a React element, but you passed "+T+".");var Z=S({},T.props),ie=T.key,re=void 0;if(z!=null)for(le in z.ref!==void 0&&(re=void 0),z.key!==void 0&&(ie=""+z.key),z)!_.call(z,le)||le==="key"||le==="__self"||le==="__source"||le==="ref"&&z.ref===void 0||(Z[le]=z[le]);var le=arguments.length-2;if(le===1)Z.children=F;else if(1<le){for(var ve=Array(le),Re=0;Re<le;Re++)ve[Re]=arguments[Re+2];Z.children=ve}return W(T.type,ie,void 0,void 0,re,Z)},Ie.createContext=function(T){return T={$$typeof:d,_currentValue:T,_currentValue2:T,_threadCount:0,Provider:null,Consumer:null},T.Provider=T,T.Consumer={$$typeof:u,_context:T},T},Ie.createElement=function(T,z,F){var Z,ie={},re=null;if(z!=null)for(Z in z.key!==void 0&&(re=""+z.key),z)_.call(z,Z)&&Z!=="key"&&Z!=="__self"&&Z!=="__source"&&(ie[Z]=z[Z]);var le=arguments.length-2;if(le===1)ie.children=F;else if(1<le){for(var ve=Array(le),Re=0;Re<le;Re++)ve[Re]=arguments[Re+2];ie.children=ve}if(T&&T.defaultProps)for(Z in le=T.defaultProps,le)ie[Z]===void 0&&(ie[Z]=le[Z]);return W(T,re,void 0,void 0,null,ie)},Ie.createRef=function(){return{current:null}},Ie.forwardRef=function(T){return{$$typeof:h,render:T}},Ie.isValidElement=V,Ie.lazy=function(T){return{$$typeof:x,_payload:{_status:-1,_result:T},_init:P}},Ie.memo=function(T,z){return{$$typeof:p,type:T,compare:z===void 0?null:z}},Ie.startTransition=function(T){var z=B.T,F={};B.T=F;try{var Z=T(),ie=B.S;ie!==null&&ie(F,Z),typeof Z=="object"&&Z!==null&&typeof Z.then=="function"&&Z.then(xe,oe)}catch(re){oe(re)}finally{B.T=z}},Ie.unstable_useCacheRefresh=function(){return B.H.useCacheRefresh()},Ie.use=function(T){return B.H.use(T)},Ie.useActionState=function(T,z,F){return B.H.useActionState(T,z,F)},Ie.useCallback=function(T,z){return B.H.useCallback(T,z)},Ie.useContext=function(T){return B.H.useContext(T)},Ie.useDebugValue=function(){},Ie.useDeferredValue=function(T,z){return B.H.useDeferredValue(T,z)},Ie.useEffect=function(T,z,F){var Z=B.H;if(typeof F=="function")throw Error("useEffect CRUD overload is not enabled in this build of React.");return Z.useEffect(T,z)},Ie.useId=function(){return B.H.useId()},Ie.useImperativeHandle=function(T,z,F){return B.H.useImperativeHandle(T,z,F)},Ie.useInsertionEffect=function(T,z){return B.H.useInsertionEffect(T,z)},Ie.useLayoutEffect=function(T,z){return B.H.useLayoutEffect(T,z)},Ie.useMemo=function(T,z){return B.H.useMemo(T,z)},Ie.useOptimistic=function(T,z){return B.H.useOptimistic(T,z)},Ie.useReducer=function(T,z,F){return B.H.useReducer(T,z,F)},Ie.useRef=function(T){return B.H.useRef(T)},Ie.useState=function(T){return B.H.useState(T)},Ie.useSyncExternalStore=function(T,z,F){return B.H.useSyncExternalStore(T,z,F)},Ie.useTransition=function(){return B.H.useTransition()},Ie.version="19.1.0",Ie}var yx;function Vf(){return yx||(yx=1,Ld.exports=Dk()),Ld.exports}var w=Vf();const qk=_k(w),Bk=Rk({__proto__:null,default:qk},[w]);var Od={exports:{}},Or={},Dd={exports:{}},qd={};var bx;function $k(){return bx||(bx=1,(function(s){function t(H,P){var oe=H.length;H.push(P);e:for(;0<oe;){var xe=oe-1>>>1,T=H[xe];if(0<l(T,P))H[xe]=P,H[oe]=T,oe=xe;else break e}}function i(H){return H.length===0?null:H[0]}function a(H){if(H.length===0)return null;var P=H[0],oe=H.pop();if(oe!==P){H[0]=oe;e:for(var xe=0,T=H.length,z=T>>>1;xe<z;){var F=2*(xe+1)-1,Z=H[F],ie=F+1,re=H[ie];if(0>l(Z,oe))ie<T&&0>l(re,Z)?(H[xe]=re,H[ie]=oe,xe=ie):(H[xe]=Z,H[F]=oe,xe=F);else if(ie<T&&0>l(re,oe))H[xe]=re,H[ie]=oe,xe=ie;else break e}}return P}function l(H,P){var oe=H.sortIndex-P.sortIndex;return oe!==0?oe:H.id-P.id}if(s.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;s.unstable_now=function(){return u.now()}}else{var d=Date,h=d.now();s.unstable_now=function(){return d.now()-h}}var m=[],p=[],x=1,y=null,v=3,k=!1,S=!1,j=!1,A=!1,R=typeof setTimeout=="function"?setTimeout:null,q=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function O(H){for(var P=i(p);P!==null;){if(P.callback===null)a(p);else if(P.startTime<=H)a(p),P.sortIndex=P.expirationTime,t(m,P);else break;P=i(p)}}function B(H){if(j=!1,O(H),!S)if(i(m)!==null)S=!0,_||(_=!0,J());else{var P=i(p);P!==null&&fe(B,P.startTime-H)}}var _=!1,W=-1,E=5,V=-1;function U(){return A?!0:!(s.unstable_now()-V<E)}function de(){if(A=!1,_){var H=s.unstable_now();V=H;var P=!0;try{e:{S=!1,j&&(j=!1,q(W),W=-1),k=!0;var oe=v;try{t:{for(O(H),y=i(m);y!==null&&!(y.expirationTime>H&&U());){var xe=y.callback;if(typeof xe=="function"){y.callback=null,v=y.priorityLevel;var T=xe(y.expirationTime<=H);if(H=s.unstable_now(),typeof T=="function"){y.callback=T,O(H),P=!0;break t}y===i(m)&&a(m),O(H)}else a(m);y=i(m)}if(y!==null)P=!0;else{var z=i(p);z!==null&&fe(B,z.startTime-H),P=!1}}break e}finally{y=null,v=oe,k=!1}P=void 0}}finally{P?J():_=!1}}}var J;if(typeof L=="function")J=function(){L(de)};else if(typeof MessageChannel<"u"){var me=new MessageChannel,se=me.port2;me.port1.onmessage=de,J=function(){se.postMessage(null)}}else J=function(){R(de,0)};function fe(H,P){W=R(function(){H(s.unstable_now())},P)}s.unstable_IdlePriority=5,s.unstable_ImmediatePriority=1,s.unstable_LowPriority=4,s.unstable_NormalPriority=3,s.unstable_Profiling=null,s.unstable_UserBlockingPriority=2,s.unstable_cancelCallback=function(H){H.callback=null},s.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):E=0<H?Math.floor(1e3/H):5},s.unstable_getCurrentPriorityLevel=function(){return v},s.unstable_next=function(H){switch(v){case 1:case 2:case 3:var P=3;break;default:P=v}var oe=v;v=P;try{return H()}finally{v=oe}},s.unstable_requestPaint=function(){A=!0},s.unstable_runWithPriority=function(H,P){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var oe=v;v=H;try{return P()}finally{v=oe}},s.unstable_scheduleCallback=function(H,P,oe){var xe=s.unstable_now();switch(typeof oe=="object"&&oe!==null?(oe=oe.delay,oe=typeof oe=="number"&&0<oe?xe+oe:xe):oe=xe,H){case 1:var T=-1;break;case 2:T=250;break;case 5:T=1073741823;break;case 4:T=1e4;break;default:T=5e3}return T=oe+T,H={id:x++,callback:P,priorityLevel:H,startTime:oe,expirationTime:T,sortIndex:-1},oe>xe?(H.sortIndex=oe,t(p,H),i(m)===null&&H===i(p)&&(j?(q(W),W=-1):j=!0,fe(B,oe-xe))):(H.sortIndex=T,t(m,H),S||k||(S=!0,_||(_=!0,J()))),H},s.unstable_shouldYield=U,s.unstable_wrapCallback=function(H){var P=v;return function(){var oe=v;v=P;try{return H.apply(this,arguments)}finally{v=oe}}}})(qd)),qd}var vx;function Uk(){return vx||(vx=1,Dd.exports=$k()),Dd.exports}var Bd={exports:{}},Pt={};var wx;function Hk(){if(wx)return Pt;wx=1;var s=Vf();function t(m){var p="https://react.dev/errors/"+m;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var x=2;x<arguments.length;x++)p+="&args[]="+encodeURIComponent(arguments[x])}return"Minified React error #"+m+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(){}var a={d:{f:i,r:function(){throw Error(t(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},l=Symbol.for("react.portal");function u(m,p,x){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:l,key:y==null?null:""+y,children:m,containerInfo:p,implementation:x}}var d=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(m,p){if(m==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return Pt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,Pt.createPortal=function(m,p){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(t(299));return u(m,p,null,x)},Pt.flushSync=function(m){var p=d.T,x=a.p;try{if(d.T=null,a.p=2,m)return m()}finally{d.T=p,a.p=x,a.d.f()}},Pt.preconnect=function(m,p){typeof m=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,a.d.C(m,p))},Pt.prefetchDNS=function(m){typeof m=="string"&&a.d.D(m)},Pt.preinit=function(m,p){if(typeof m=="string"&&p&&typeof p.as=="string"){var x=p.as,y=h(x,p.crossOrigin),v=typeof p.integrity=="string"?p.integrity:void 0,k=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;x==="style"?a.d.S(m,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:y,integrity:v,fetchPriority:k}):x==="script"&&a.d.X(m,{crossOrigin:y,integrity:v,fetchPriority:k,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},Pt.preinitModule=function(m,p){if(typeof m=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var x=h(p.as,p.crossOrigin);a.d.M(m,{crossOrigin:x,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&a.d.M(m)},Pt.preload=function(m,p){if(typeof m=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var x=p.as,y=h(x,p.crossOrigin);a.d.L(m,x,{crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},Pt.preloadModule=function(m,p){if(typeof m=="string")if(p){var x=h(p.as,p.crossOrigin);a.d.m(m,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:x,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else a.d.m(m)},Pt.requestFormReset=function(m){a.d.r(m)},Pt.unstable_batchedUpdates=function(m,p){return m(p)},Pt.useFormState=function(m,p,x){return d.H.useFormState(m,p,x)},Pt.useFormStatus=function(){return d.H.useHostTransitionStatus()},Pt.version="19.1.0",Pt}var kx;function Ik(){if(kx)return Bd.exports;kx=1;function s(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(t){console.error(t)}}return s(),Bd.exports=Hk(),Bd.exports}var jx;function Gk(){if(jx)return Or;jx=1;var s=Uk(),t=Vf(),i=Ik();function a(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var r=2;r<arguments.length;r++)n+="&args[]="+encodeURIComponent(arguments[r])}return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function u(e){var n=e,r=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(r=n.return),e=n.return;while(e)}return n.tag===3?r:null}function d(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function h(e){if(u(e)!==e)throw Error(a(188))}function m(e){var n=e.alternate;if(!n){if(n=u(e),n===null)throw Error(a(188));return n!==e?null:e}for(var r=e,c=n;;){var f=r.return;if(f===null)break;var g=f.alternate;if(g===null){if(c=f.return,c!==null){r=c;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===r)return h(f),e;if(g===c)return h(f),n;g=g.sibling}throw Error(a(188))}if(r.return!==c.return)r=f,c=g;else{for(var b=!1,N=f.child;N;){if(N===r){b=!0,r=f,c=g;break}if(N===c){b=!0,c=f,r=g;break}N=N.sibling}if(!b){for(N=g.child;N;){if(N===r){b=!0,r=g,c=f;break}if(N===c){b=!0,c=g,r=f;break}N=N.sibling}if(!b)throw Error(a(189))}}if(r.alternate!==c)throw Error(a(190))}if(r.tag!==3)throw Error(a(188));return r.stateNode.current===r?e:n}function p(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=p(e),n!==null)return n;e=e.sibling}return null}var x=Object.assign,y=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),R=Symbol.for("react.provider"),q=Symbol.for("react.consumer"),L=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),W=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),V=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),de=Symbol.iterator;function J(e){return e===null||typeof e!="object"?null:(e=de&&e[de]||e["@@iterator"],typeof e=="function"?e:null)}var me=Symbol.for("react.client.reference");function se(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===me?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case S:return"Fragment";case A:return"Profiler";case j:return"StrictMode";case B:return"Suspense";case _:return"SuspenseList";case V:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case k:return"Portal";case L:return(e.displayName||"Context")+".Provider";case q:return(e._context.displayName||"Context")+".Consumer";case O:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case W:return n=e.displayName||null,n!==null?n:se(e.type)||"Memo";case E:n=e._payload,e=e._init;try{return se(e(n))}catch{}}return null}var fe=Array.isArray,H=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oe={pending:!1,data:null,method:null,action:null},xe=[],T=-1;function z(e){return{current:e}}function F(e){0>T||(e.current=xe[T],xe[T]=null,T--)}function Z(e,n){T++,xe[T]=e.current,e.current=n}var ie=z(null),re=z(null),le=z(null),ve=z(null);function Re(e,n){switch(Z(le,n),Z(re,e),Z(ie,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?Gg(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=Gg(n),e=Yg(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}F(ie),Z(ie,e)}function Ne(){F(ie),F(re),F(le)}function et(e){e.memoizedState!==null&&Z(ve,e);var n=ie.current,r=Yg(n,e.type);n!==r&&(Z(re,e),Z(ie,r))}function Ue(e){re.current===e&&(F(ie),F(re)),ve.current===e&&(F(ve),Er._currentValue=oe)}var Qe=Object.prototype.hasOwnProperty,We=s.unstable_scheduleCallback,ye=s.unstable_cancelCallback,ge=s.unstable_shouldYield,Ce=s.unstable_requestPaint,je=s.unstable_now,Ut=s.unstable_getCurrentPriorityLevel,ln=s.unstable_ImmediatePriority,ze=s.unstable_UserBlockingPriority,it=s.unstable_NormalPriority,gt=s.unstable_LowPriority,At=s.unstable_IdlePriority,$n=s.log,_n=s.unstable_setDisableYieldValue,cn=null,xt=null;function zt(e){if(typeof $n=="function"&&_n(e),xt&&typeof xt.setStrictMode=="function")try{xt.setStrictMode(cn,e)}catch{}}var Ct=Math.clz32?Math.clz32:he,Un=Math.log,vn=Math.LN2;function he(e){return e>>>=0,e===0?32:31-(Un(e)/vn|0)|0}var Ae=256,ht=4194304;function jt(e){var n=e&42;if(n!==0)return n;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194048;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function bt(e,n,r){var c=e.pendingLanes;if(c===0)return 0;var f=0,g=e.suspendedLanes,b=e.pingedLanes;e=e.warmLanes;var N=c&134217727;return N!==0?(c=N&~g,c!==0?f=jt(c):(b&=N,b!==0?f=jt(b):r||(r=N&~e,r!==0&&(f=jt(r))))):(N=c&~g,N!==0?f=jt(N):b!==0?f=jt(b):r||(r=c&~e,r!==0&&(f=jt(r)))),f===0?0:n!==0&&n!==f&&(n&g)===0&&(g=f&-f,r=n&-n,g>=r||g===32&&(r&4194048)!==0)?n:f}function C(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function G(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ce(){var e=Ae;return Ae<<=1,(Ae&4194048)===0&&(Ae=256),e}function ue(){var e=ht;return ht<<=1,(ht&62914560)===0&&(ht=4194304),e}function pe(e){for(var n=[],r=0;31>r;r++)n.push(e);return n}function He(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ze(e,n,r,c,f,g){var b=e.pendingLanes;e.pendingLanes=r,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=r,e.entangledLanes&=r,e.errorRecoveryDisabledLanes&=r,e.shellSuspendCounter=0;var N=e.entanglements,M=e.expirationTimes,K=e.hiddenUpdates;for(r=b&~r;0<r;){var ee=31-Ct(r),ae=1<<ee;N[ee]=0,M[ee]=-1;var X=K[ee];if(X!==null)for(K[ee]=null,ee=0;ee<X.length;ee++){var Q=X[ee];Q!==null&&(Q.lane&=-536870913)}r&=~ae}c!==0&&St(e,c,0),g!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=g&~(b&~n))}function St(e,n,r){e.pendingLanes|=n,e.suspendedLanes&=~n;var c=31-Ct(n);e.entangledLanes|=n,e.entanglements[c]=e.entanglements[c]|1073741824|r&4194090}function Ke(e,n){var r=e.entangledLanes|=n;for(e=e.entanglements;r;){var c=31-Ct(r),f=1<<c;f&n|e[c]&n&&(e[c]|=n),r&=~f}}function lt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function ni(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function si(){var e=P.p;return e!==0?e:(e=window.event,e===void 0?32:cx(e.type))}function un(e,n){var r=P.p;try{return P.p=e,n()}finally{P.p=r}}var Hn=Math.random().toString(36).slice(2),Ft="__reactFiber$"+Hn,Jt="__reactProps$"+Hn,Hi="__reactContainer$"+Hn,Nc="__reactEvents$"+Hn,kv="__reactListeners$"+Hn,jv="__reactHandles$"+Hn,zh="__reactResources$"+Hn,Ua="__reactMarker$"+Hn;function Tc(e){delete e[Ft],delete e[Jt],delete e[Nc],delete e[kv],delete e[jv]}function Ii(e){var n=e[Ft];if(n)return n;for(var r=e.parentNode;r;){if(n=r[Hi]||r[Ft]){if(r=n.alternate,n.child!==null||r!==null&&r.child!==null)for(e=Xg(e);e!==null;){if(r=e[Ft])return r;e=Xg(e)}return n}e=r,r=e.parentNode}return null}function Gi(e){if(e=e[Ft]||e[Hi]){var n=e.tag;if(n===5||n===6||n===13||n===26||n===27||n===3)return e}return null}function Ha(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(a(33))}function Yi(e){var n=e[zh];return n||(n=e[zh]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Dt(e){e[Ua]=!0}var Rh=new Set,_h={};function ii(e,n){Vi(e,n),Vi(e+"Capture",n)}function Vi(e,n){for(_h[e]=n,e=0;e<n.length;e++)Rh.add(n[e])}var Sv=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Lh={},Oh={};function Nv(e){return Qe.call(Oh,e)?!0:Qe.call(Lh,e)?!1:Sv.test(e)?Oh[e]=!0:(Lh[e]=!0,!1)}function mo(e,n,r){if(Nv(n))if(r===null)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var c=n.toLowerCase().slice(0,5);if(c!=="data-"&&c!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+r)}}function po(e,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttribute(n,""+r)}}function Zn(e,n,r,c){if(c===null)e.removeAttribute(r);else{switch(typeof c){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(r);return}e.setAttributeNS(n,r,""+c)}}var Ac,Dh;function Ki(e){if(Ac===void 0)try{throw Error()}catch(r){var n=r.stack.trim().match(/\n( *(at )?)/);Ac=n&&n[1]||"",Dh=-1<r.stack.indexOf(`
|
|
3
|
+
at`)?" (<anonymous>)":-1<r.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
+
`+Ac+e+Dh}var Cc=!1;function Ec(e,n){if(!e||Cc)return"";Cc=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(n){var ae=function(){throw Error()};if(Object.defineProperty(ae.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ae,[])}catch(Q){var X=Q}Reflect.construct(e,[],ae)}else{try{ae.call()}catch(Q){X=Q}e.call(ae.prototype)}}else{try{throw Error()}catch(Q){X=Q}(ae=e())&&typeof ae.catch=="function"&&ae.catch(function(){})}}catch(Q){if(Q&&X&&typeof Q.stack=="string")return[Q.stack,X.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=c.DetermineComponentFrameRoot(),b=g[0],N=g[1];if(b&&N){var M=b.split(`
|
|
5
|
+
`),K=N.split(`
|
|
6
|
+
`);for(f=c=0;c<M.length&&!M[c].includes("DetermineComponentFrameRoot");)c++;for(;f<K.length&&!K[f].includes("DetermineComponentFrameRoot");)f++;if(c===M.length||f===K.length)for(c=M.length-1,f=K.length-1;1<=c&&0<=f&&M[c]!==K[f];)f--;for(;1<=c&&0<=f;c--,f--)if(M[c]!==K[f]){if(c!==1||f!==1)do if(c--,f--,0>f||M[c]!==K[f]){var ee=`
|
|
7
|
+
`+M[c].replace(" at new "," at ");return e.displayName&&ee.includes("<anonymous>")&&(ee=ee.replace("<anonymous>",e.displayName)),ee}while(1<=c&&0<=f);break}}}finally{Cc=!1,Error.prepareStackTrace=r}return(r=e?e.displayName||e.name:"")?Ki(r):""}function Tv(e){switch(e.tag){case 26:case 27:case 5:return Ki(e.type);case 16:return Ki("Lazy");case 13:return Ki("Suspense");case 19:return Ki("SuspenseList");case 0:case 15:return Ec(e.type,!1);case 11:return Ec(e.type.render,!1);case 1:return Ec(e.type,!0);case 31:return Ki("Activity");default:return""}}function qh(e){try{var n="";do n+=Tv(e),e=e.return;while(e);return n}catch(r){return`
|
|
8
|
+
Error generating stack: `+r.message+`
|
|
9
|
+
`+r.stack}}function wn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Bh(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Av(e){var n=Bh(e)?"checked":"value",r=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),c=""+e[n];if(!e.hasOwnProperty(n)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var f=r.get,g=r.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(b){c=""+b,g.call(this,b)}}),Object.defineProperty(e,n,{enumerable:r.enumerable}),{getValue:function(){return c},setValue:function(b){c=""+b},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function go(e){e._valueTracker||(e._valueTracker=Av(e))}function $h(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var r=n.getValue(),c="";return e&&(c=Bh(e)?e.checked?"true":"false":e.value),e=c,e!==r?(n.setValue(e),!0):!1}function xo(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Cv=/[\n"\\]/g;function kn(e){return e.replace(Cv,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function Mc(e,n,r,c,f,g,b,N){e.name="",b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?e.type=b:e.removeAttribute("type"),n!=null?b==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+wn(n)):e.value!==""+wn(n)&&(e.value=""+wn(n)):b!=="submit"&&b!=="reset"||e.removeAttribute("value"),n!=null?zc(e,b,wn(n)):r!=null?zc(e,b,wn(r)):c!=null&&e.removeAttribute("value"),f==null&&g!=null&&(e.defaultChecked=!!g),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?e.name=""+wn(N):e.removeAttribute("name")}function Uh(e,n,r,c,f,g,b,N){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(e.type=g),n!=null||r!=null){if(!(g!=="submit"&&g!=="reset"||n!=null))return;r=r!=null?""+wn(r):"",n=n!=null?""+wn(n):r,N||n===e.value||(e.value=n),e.defaultValue=n}c=c??f,c=typeof c!="function"&&typeof c!="symbol"&&!!c,e.checked=N?e.checked:!!c,e.defaultChecked=!!c,b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(e.name=b)}function zc(e,n,r){n==="number"&&xo(e.ownerDocument)===e||e.defaultValue===""+r||(e.defaultValue=""+r)}function Fi(e,n,r,c){if(e=e.options,n){n={};for(var f=0;f<r.length;f++)n["$"+r[f]]=!0;for(r=0;r<e.length;r++)f=n.hasOwnProperty("$"+e[r].value),e[r].selected!==f&&(e[r].selected=f),f&&c&&(e[r].defaultSelected=!0)}else{for(r=""+wn(r),n=null,f=0;f<e.length;f++){if(e[f].value===r){e[f].selected=!0,c&&(e[f].defaultSelected=!0);return}n!==null||e[f].disabled||(n=e[f])}n!==null&&(n.selected=!0)}}function Hh(e,n,r){if(n!=null&&(n=""+wn(n),n!==e.value&&(e.value=n),r==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=r!=null?""+wn(r):""}function Ih(e,n,r,c){if(n==null){if(c!=null){if(r!=null)throw Error(a(92));if(fe(c)){if(1<c.length)throw Error(a(93));c=c[0]}r=c}r==null&&(r=""),n=r}r=wn(n),e.defaultValue=r,c=e.textContent,c===r&&c!==""&&c!==null&&(e.value=c)}function Xi(e,n){if(n){var r=e.firstChild;if(r&&r===e.lastChild&&r.nodeType===3){r.nodeValue=n;return}}e.textContent=n}var Ev=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Gh(e,n,r){var c=n.indexOf("--")===0;r==null||typeof r=="boolean"||r===""?c?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":c?e.setProperty(n,r):typeof r!="number"||r===0||Ev.has(n)?n==="float"?e.cssFloat=r:e[n]=(""+r).trim():e[n]=r+"px"}function Yh(e,n,r){if(n!=null&&typeof n!="object")throw Error(a(62));if(e=e.style,r!=null){for(var c in r)!r.hasOwnProperty(c)||n!=null&&n.hasOwnProperty(c)||(c.indexOf("--")===0?e.setProperty(c,""):c==="float"?e.cssFloat="":e[c]="");for(var f in n)c=n[f],n.hasOwnProperty(f)&&r[f]!==c&&Gh(e,f,c)}else for(var g in n)n.hasOwnProperty(g)&&Gh(e,g,n[g])}function Rc(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Mv=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),zv=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function yo(e){return zv.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}var _c=null;function Lc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Pi=null,Qi=null;function Vh(e){var n=Gi(e);if(n&&(e=n.stateNode)){var r=e[Jt]||null;e:switch(e=n.stateNode,n.type){case"input":if(Mc(e,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name),n=r.name,r.type==="radio"&&n!=null){for(r=e;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll('input[name="'+kn(""+n)+'"][type="radio"]'),n=0;n<r.length;n++){var c=r[n];if(c!==e&&c.form===e.form){var f=c[Jt]||null;if(!f)throw Error(a(90));Mc(c,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(n=0;n<r.length;n++)c=r[n],c.form===e.form&&$h(c)}break e;case"textarea":Hh(e,r.value,r.defaultValue);break e;case"select":n=r.value,n!=null&&Fi(e,!!r.multiple,n,!1)}}}var Oc=!1;function Kh(e,n,r){if(Oc)return e(n,r);Oc=!0;try{var c=e(n);return c}finally{if(Oc=!1,(Pi!==null||Qi!==null)&&(sl(),Pi&&(n=Pi,e=Qi,Qi=Pi=null,Vh(n),e)))for(n=0;n<e.length;n++)Vh(e[n])}}function Ia(e,n){var r=e.stateNode;if(r===null)return null;var c=r[Jt]||null;if(c===null)return null;r=c[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(e=e.type,c=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!c;break e;default:e=!1}if(e)return null;if(r&&typeof r!="function")throw Error(a(231,n,typeof r));return r}var Jn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Dc=!1;if(Jn)try{var Ga={};Object.defineProperty(Ga,"passive",{get:function(){Dc=!0}}),window.addEventListener("test",Ga,Ga),window.removeEventListener("test",Ga,Ga)}catch{Dc=!1}var ws=null,qc=null,bo=null;function Fh(){if(bo)return bo;var e,n=qc,r=n.length,c,f="value"in ws?ws.value:ws.textContent,g=f.length;for(e=0;e<r&&n[e]===f[e];e++);var b=r-e;for(c=1;c<=b&&n[r-c]===f[g-c];c++);return bo=f.slice(e,1<c?1-c:void 0)}function vo(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function wo(){return!0}function Xh(){return!1}function en(e){function n(r,c,f,g,b){this._reactName=r,this._targetInst=f,this.type=c,this.nativeEvent=g,this.target=b,this.currentTarget=null;for(var N in e)e.hasOwnProperty(N)&&(r=e[N],this[N]=r?r(g):g[N]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?wo:Xh,this.isPropagationStopped=Xh,this}return x(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=wo)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=wo)},persist:function(){},isPersistent:wo}),n}var ai={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ko=en(ai),Ya=x({},ai,{view:0,detail:0}),Rv=en(Ya),Bc,$c,Va,jo=x({},Ya,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Hc,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!==Va&&(Va&&e.type==="mousemove"?(Bc=e.screenX-Va.screenX,$c=e.screenY-Va.screenY):$c=Bc=0,Va=e),Bc)},movementY:function(e){return"movementY"in e?e.movementY:$c}}),Ph=en(jo),_v=x({},jo,{dataTransfer:0}),Lv=en(_v),Ov=x({},Ya,{relatedTarget:0}),Uc=en(Ov),Dv=x({},ai,{animationName:0,elapsedTime:0,pseudoElement:0}),qv=en(Dv),Bv=x({},ai,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),$v=en(Bv),Uv=x({},ai,{data:0}),Qh=en(Uv),Hv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Iv={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"},Gv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Yv(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=Gv[e])?!!n[e]:!1}function Hc(){return Yv}var Vv=x({},Ya,{key:function(e){if(e.key){var n=Hv[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=vo(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Iv[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Hc,charCode:function(e){return e.type==="keypress"?vo(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?vo(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Kv=en(Vv),Fv=x({},jo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Wh=en(Fv),Xv=x({},Ya,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Hc}),Pv=en(Xv),Qv=x({},ai,{propertyName:0,elapsedTime:0,pseudoElement:0}),Wv=en(Qv),Zv=x({},jo,{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}),Jv=en(Zv),ew=x({},ai,{newState:0,oldState:0}),tw=en(ew),nw=[9,13,27,32],Ic=Jn&&"CompositionEvent"in window,Ka=null;Jn&&"documentMode"in document&&(Ka=document.documentMode);var sw=Jn&&"TextEvent"in window&&!Ka,Zh=Jn&&(!Ic||Ka&&8<Ka&&11>=Ka),Jh=" ",em=!1;function tm(e,n){switch(e){case"keyup":return nw.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function nm(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Wi=!1;function iw(e,n){switch(e){case"compositionend":return nm(n);case"keypress":return n.which!==32?null:(em=!0,Jh);case"textInput":return e=n.data,e===Jh&&em?null:e;default:return null}}function aw(e,n){if(Wi)return e==="compositionend"||!Ic&&tm(e,n)?(e=Fh(),bo=qc=ws=null,Wi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Zh&&n.locale!=="ko"?null:n.data;default:return null}}var rw={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 sm(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!rw[e.type]:n==="textarea"}function im(e,n,r,c){Pi?Qi?Qi.push(c):Qi=[c]:Pi=c,n=cl(n,"onChange"),0<n.length&&(r=new ko("onChange","change",null,r,c),e.push({event:r,listeners:n}))}var Fa=null,Xa=null;function ow(e){Bg(e,0)}function So(e){var n=Ha(e);if($h(n))return e}function am(e,n){if(e==="change")return n}var rm=!1;if(Jn){var Gc;if(Jn){var Yc="oninput"in document;if(!Yc){var om=document.createElement("div");om.setAttribute("oninput","return;"),Yc=typeof om.oninput=="function"}Gc=Yc}else Gc=!1;rm=Gc&&(!document.documentMode||9<document.documentMode)}function lm(){Fa&&(Fa.detachEvent("onpropertychange",cm),Xa=Fa=null)}function cm(e){if(e.propertyName==="value"&&So(Xa)){var n=[];im(n,Xa,e,Lc(e)),Kh(ow,n)}}function lw(e,n,r){e==="focusin"?(lm(),Fa=n,Xa=r,Fa.attachEvent("onpropertychange",cm)):e==="focusout"&&lm()}function cw(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return So(Xa)}function uw(e,n){if(e==="click")return So(n)}function dw(e,n){if(e==="input"||e==="change")return So(n)}function fw(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var dn=typeof Object.is=="function"?Object.is:fw;function Pa(e,n){if(dn(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var r=Object.keys(e),c=Object.keys(n);if(r.length!==c.length)return!1;for(c=0;c<r.length;c++){var f=r[c];if(!Qe.call(n,f)||!dn(e[f],n[f]))return!1}return!0}function um(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function dm(e,n){var r=um(e);e=0;for(var c;r;){if(r.nodeType===3){if(c=e+r.textContent.length,e<=n&&c>=n)return{node:r,offset:n-e};e=c}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=um(r)}}function fm(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?fm(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function hm(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=xo(e.document);n instanceof e.HTMLIFrameElement;){try{var r=typeof n.contentWindow.location.href=="string"}catch{r=!1}if(r)e=n.contentWindow;else break;n=xo(e.document)}return n}function Vc(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}var hw=Jn&&"documentMode"in document&&11>=document.documentMode,Zi=null,Kc=null,Qa=null,Fc=!1;function mm(e,n,r){var c=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;Fc||Zi==null||Zi!==xo(c)||(c=Zi,"selectionStart"in c&&Vc(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Qa&&Pa(Qa,c)||(Qa=c,c=cl(Kc,"onSelect"),0<c.length&&(n=new ko("onSelect","select",null,n,r),e.push({event:n,listeners:c}),n.target=Zi)))}function ri(e,n){var r={};return r[e.toLowerCase()]=n.toLowerCase(),r["Webkit"+e]="webkit"+n,r["Moz"+e]="moz"+n,r}var Ji={animationend:ri("Animation","AnimationEnd"),animationiteration:ri("Animation","AnimationIteration"),animationstart:ri("Animation","AnimationStart"),transitionrun:ri("Transition","TransitionRun"),transitionstart:ri("Transition","TransitionStart"),transitioncancel:ri("Transition","TransitionCancel"),transitionend:ri("Transition","TransitionEnd")},Xc={},pm={};Jn&&(pm=document.createElement("div").style,"AnimationEvent"in window||(delete Ji.animationend.animation,delete Ji.animationiteration.animation,delete Ji.animationstart.animation),"TransitionEvent"in window||delete Ji.transitionend.transition);function oi(e){if(Xc[e])return Xc[e];if(!Ji[e])return e;var n=Ji[e],r;for(r in n)if(n.hasOwnProperty(r)&&r in pm)return Xc[e]=n[r];return e}var gm=oi("animationend"),xm=oi("animationiteration"),ym=oi("animationstart"),mw=oi("transitionrun"),pw=oi("transitionstart"),gw=oi("transitioncancel"),bm=oi("transitionend"),vm=new Map,Pc="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Pc.push("scrollEnd");function Ln(e,n){vm.set(e,n),ii(n,[e])}var wm=new WeakMap;function jn(e,n){if(typeof e=="object"&&e!==null){var r=wm.get(e);return r!==void 0?r:(n={value:e,source:n,stack:qh(n)},wm.set(e,n),n)}return{value:e,source:n,stack:qh(n)}}var Sn=[],ea=0,Qc=0;function No(){for(var e=ea,n=Qc=ea=0;n<e;){var r=Sn[n];Sn[n++]=null;var c=Sn[n];Sn[n++]=null;var f=Sn[n];Sn[n++]=null;var g=Sn[n];if(Sn[n++]=null,c!==null&&f!==null){var b=c.pending;b===null?f.next=f:(f.next=b.next,b.next=f),c.pending=f}g!==0&&km(r,f,g)}}function To(e,n,r,c){Sn[ea++]=e,Sn[ea++]=n,Sn[ea++]=r,Sn[ea++]=c,Qc|=c,e.lanes|=c,e=e.alternate,e!==null&&(e.lanes|=c)}function Wc(e,n,r,c){return To(e,n,r,c),Ao(e)}function ta(e,n){return To(e,null,null,n),Ao(e)}function km(e,n,r){e.lanes|=r;var c=e.alternate;c!==null&&(c.lanes|=r);for(var f=!1,g=e.return;g!==null;)g.childLanes|=r,c=g.alternate,c!==null&&(c.childLanes|=r),g.tag===22&&(e=g.stateNode,e===null||e._visibility&1||(f=!0)),e=g,g=g.return;return e.tag===3?(g=e.stateNode,f&&n!==null&&(f=31-Ct(r),e=g.hiddenUpdates,c=e[f],c===null?e[f]=[n]:c.push(n),n.lane=r|536870912),g):null}function Ao(e){if(50<wr)throw wr=0,sd=null,Error(a(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var na={};function xw(e,n,r,c){this.tag=e,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fn(e,n,r,c){return new xw(e,n,r,c)}function Zc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function es(e,n){var r=e.alternate;return r===null?(r=fn(e.tag,n,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=n,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&65011712,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,n=e.dependencies,r.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function jm(e,n){e.flags&=65011714;var r=e.alternate;return r===null?(e.childLanes=0,e.lanes=n,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=r.childLanes,e.lanes=r.lanes,e.child=r.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=r.memoizedProps,e.memoizedState=r.memoizedState,e.updateQueue=r.updateQueue,e.type=r.type,n=r.dependencies,e.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function Co(e,n,r,c,f,g){var b=0;if(c=e,typeof e=="function")Zc(e)&&(b=1);else if(typeof e=="string")b=bk(e,r,ie.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case V:return e=fn(31,r,n,f),e.elementType=V,e.lanes=g,e;case S:return li(r.children,f,g,n);case j:b=8,f|=24;break;case A:return e=fn(12,r,n,f|2),e.elementType=A,e.lanes=g,e;case B:return e=fn(13,r,n,f),e.elementType=B,e.lanes=g,e;case _:return e=fn(19,r,n,f),e.elementType=_,e.lanes=g,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case R:case L:b=10;break e;case q:b=9;break e;case O:b=11;break e;case W:b=14;break e;case E:b=16,c=null;break e}b=29,r=Error(a(130,e===null?"null":typeof e,"")),c=null}return n=fn(b,r,n,f),n.elementType=e,n.type=c,n.lanes=g,n}function li(e,n,r,c){return e=fn(7,e,c,n),e.lanes=r,e}function Jc(e,n,r){return e=fn(6,e,null,n),e.lanes=r,e}function eu(e,n,r){return n=fn(4,e.children!==null?e.children:[],e.key,n),n.lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var sa=[],ia=0,Eo=null,Mo=0,Nn=[],Tn=0,ci=null,ts=1,ns="";function ui(e,n){sa[ia++]=Mo,sa[ia++]=Eo,Eo=e,Mo=n}function Sm(e,n,r){Nn[Tn++]=ts,Nn[Tn++]=ns,Nn[Tn++]=ci,ci=e;var c=ts;e=ns;var f=32-Ct(c)-1;c&=~(1<<f),r+=1;var g=32-Ct(n)+f;if(30<g){var b=f-f%5;g=(c&(1<<b)-1).toString(32),c>>=b,f-=b,ts=1<<32-Ct(n)+f|r<<f|c,ns=g+e}else ts=1<<g|r<<f|c,ns=e}function tu(e){e.return!==null&&(ui(e,1),Sm(e,1,0))}function nu(e){for(;e===Eo;)Eo=sa[--ia],sa[ia]=null,Mo=sa[--ia],sa[ia]=null;for(;e===ci;)ci=Nn[--Tn],Nn[Tn]=null,ns=Nn[--Tn],Nn[Tn]=null,ts=Nn[--Tn],Nn[Tn]=null}var Qt=null,vt=null,nt=!1,di=null,In=!1,su=Error(a(519));function fi(e){var n=Error(a(418,""));throw Ja(jn(n,e)),su}function Nm(e){var n=e.stateNode,r=e.type,c=e.memoizedProps;switch(n[Ft]=e,n[Jt]=c,r){case"dialog":Xe("cancel",n),Xe("close",n);break;case"iframe":case"object":case"embed":Xe("load",n);break;case"video":case"audio":for(r=0;r<jr.length;r++)Xe(jr[r],n);break;case"source":Xe("error",n);break;case"img":case"image":case"link":Xe("error",n),Xe("load",n);break;case"details":Xe("toggle",n);break;case"input":Xe("invalid",n),Uh(n,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0),go(n);break;case"select":Xe("invalid",n);break;case"textarea":Xe("invalid",n),Ih(n,c.value,c.defaultValue,c.children),go(n)}r=c.children,typeof r!="string"&&typeof r!="number"&&typeof r!="bigint"||n.textContent===""+r||c.suppressHydrationWarning===!0||Ig(n.textContent,r)?(c.popover!=null&&(Xe("beforetoggle",n),Xe("toggle",n)),c.onScroll!=null&&Xe("scroll",n),c.onScrollEnd!=null&&Xe("scrollend",n),c.onClick!=null&&(n.onclick=ul),n=!0):n=!1,n||fi(e)}function Tm(e){for(Qt=e.return;Qt;)switch(Qt.tag){case 5:case 13:In=!1;return;case 27:case 3:In=!0;return;default:Qt=Qt.return}}function Wa(e){if(e!==Qt)return!1;if(!nt)return Tm(e),nt=!0,!1;var n=e.tag,r;if((r=n!==3&&n!==27)&&((r=n===5)&&(r=e.type,r=!(r!=="form"&&r!=="button")||bd(e.type,e.memoizedProps)),r=!r),r&&vt&&fi(e),Tm(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));e:{for(e=e.nextSibling,n=0;e;){if(e.nodeType===8)if(r=e.data,r==="/$"){if(n===0){vt=Dn(e.nextSibling);break e}n--}else r!=="$"&&r!=="$!"&&r!=="$?"||n++;e=e.nextSibling}vt=null}}else n===27?(n=vt,qs(e.type)?(e=jd,jd=null,vt=e):vt=n):vt=Qt?Dn(e.stateNode.nextSibling):null;return!0}function Za(){vt=Qt=null,nt=!1}function Am(){var e=di;return e!==null&&(sn===null?sn=e:sn.push.apply(sn,e),di=null),e}function Ja(e){di===null?di=[e]:di.push(e)}var iu=z(null),hi=null,ss=null;function ks(e,n,r){Z(iu,n._currentValue),n._currentValue=r}function is(e){e._currentValue=iu.current,F(iu)}function au(e,n,r){for(;e!==null;){var c=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,c!==null&&(c.childLanes|=n)):c!==null&&(c.childLanes&n)!==n&&(c.childLanes|=n),e===r)break;e=e.return}}function ru(e,n,r,c){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var g=f.dependencies;if(g!==null){var b=f.child;g=g.firstContext;e:for(;g!==null;){var N=g;g=f;for(var M=0;M<n.length;M++)if(N.context===n[M]){g.lanes|=r,N=g.alternate,N!==null&&(N.lanes|=r),au(g.return,r,e),c||(b=null);break e}g=N.next}}else if(f.tag===18){if(b=f.return,b===null)throw Error(a(341));b.lanes|=r,g=b.alternate,g!==null&&(g.lanes|=r),au(b,r,e),b=null}else b=f.child;if(b!==null)b.return=f;else for(b=f;b!==null;){if(b===e){b=null;break}if(f=b.sibling,f!==null){f.return=b.return,b=f;break}b=b.return}f=b}}function er(e,n,r,c){e=null;for(var f=n,g=!1;f!==null;){if(!g){if((f.flags&524288)!==0)g=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var b=f.alternate;if(b===null)throw Error(a(387));if(b=b.memoizedProps,b!==null){var N=f.type;dn(f.pendingProps.value,b.value)||(e!==null?e.push(N):e=[N])}}else if(f===ve.current){if(b=f.alternate,b===null)throw Error(a(387));b.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(Er):e=[Er])}f=f.return}e!==null&&ru(n,e,r,c),n.flags|=262144}function zo(e){for(e=e.firstContext;e!==null;){if(!dn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function mi(e){hi=e,ss=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Xt(e){return Cm(hi,e)}function Ro(e,n){return hi===null&&mi(e),Cm(e,n)}function Cm(e,n){var r=n._currentValue;if(n={context:n,memoizedValue:r,next:null},ss===null){if(e===null)throw Error(a(308));ss=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else ss=ss.next=n;return r}var yw=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(r,c){e.push(c)}};this.abort=function(){n.aborted=!0,e.forEach(function(r){return r()})}},bw=s.unstable_scheduleCallback,vw=s.unstable_NormalPriority,Rt={$$typeof:L,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ou(){return{controller:new yw,data:new Map,refCount:0}}function tr(e){e.refCount--,e.refCount===0&&bw(vw,function(){e.controller.abort()})}var nr=null,lu=0,aa=0,ra=null;function ww(e,n){if(nr===null){var r=nr=[];lu=0,aa=ud(),ra={status:"pending",value:void 0,then:function(c){r.push(c)}}}return lu++,n.then(Em,Em),n}function Em(){if(--lu===0&&nr!==null){ra!==null&&(ra.status="fulfilled");var e=nr;nr=null,aa=0,ra=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function kw(e,n){var r=[],c={status:"pending",value:null,reason:null,then:function(f){r.push(f)}};return e.then(function(){c.status="fulfilled",c.value=n;for(var f=0;f<r.length;f++)(0,r[f])(n)},function(f){for(c.status="rejected",c.reason=f,f=0;f<r.length;f++)(0,r[f])(void 0)}),c}var Mm=H.S;H.S=function(e,n){typeof n=="object"&&n!==null&&typeof n.then=="function"&&ww(e,n),Mm!==null&&Mm(e,n)};var pi=z(null);function cu(){var e=pi.current;return e!==null?e:mt.pooledCache}function _o(e,n){n===null?Z(pi,pi.current):Z(pi,n.pool)}function zm(){var e=cu();return e===null?null:{parent:Rt._currentValue,pool:e}}var sr=Error(a(460)),Rm=Error(a(474)),Lo=Error(a(542)),uu={then:function(){}};function _m(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Oo(){}function Lm(e,n,r){switch(r=e[r],r===void 0?e.push(n):r!==n&&(n.then(Oo,Oo),n=r),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Dm(e),e;default:if(typeof n.status=="string")n.then(Oo,Oo);else{if(e=mt,e!==null&&100<e.shellSuspendCounter)throw Error(a(482));e=n,e.status="pending",e.then(function(c){if(n.status==="pending"){var f=n;f.status="fulfilled",f.value=c}},function(c){if(n.status==="pending"){var f=n;f.status="rejected",f.reason=c}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Dm(e),e}throw ir=n,sr}}var ir=null;function Om(){if(ir===null)throw Error(a(459));var e=ir;return ir=null,e}function Dm(e){if(e===sr||e===Lo)throw Error(a(483))}var js=!1;function du(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function fu(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ss(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ns(e,n,r){var c=e.updateQueue;if(c===null)return null;if(c=c.shared,(at&2)!==0){var f=c.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),c.pending=n,n=Ao(e),km(e,null,r),n}return To(e,c,n,r),Ao(e)}function ar(e,n,r){if(n=n.updateQueue,n!==null&&(n=n.shared,(r&4194048)!==0)){var c=n.lanes;c&=e.pendingLanes,r|=c,n.lanes=r,Ke(e,r)}}function hu(e,n){var r=e.updateQueue,c=e.alternate;if(c!==null&&(c=c.updateQueue,r===c)){var f=null,g=null;if(r=r.firstBaseUpdate,r!==null){do{var b={lane:r.lane,tag:r.tag,payload:r.payload,callback:null,next:null};g===null?f=g=b:g=g.next=b,r=r.next}while(r!==null);g===null?f=g=n:g=g.next=n}else f=g=n;r={baseState:c.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:c.shared,callbacks:c.callbacks},e.updateQueue=r;return}e=r.lastBaseUpdate,e===null?r.firstBaseUpdate=n:e.next=n,r.lastBaseUpdate=n}var mu=!1;function rr(){if(mu){var e=ra;if(e!==null)throw e}}function or(e,n,r,c){mu=!1;var f=e.updateQueue;js=!1;var g=f.firstBaseUpdate,b=f.lastBaseUpdate,N=f.shared.pending;if(N!==null){f.shared.pending=null;var M=N,K=M.next;M.next=null,b===null?g=K:b.next=K,b=M;var ee=e.alternate;ee!==null&&(ee=ee.updateQueue,N=ee.lastBaseUpdate,N!==b&&(N===null?ee.firstBaseUpdate=K:N.next=K,ee.lastBaseUpdate=M))}if(g!==null){var ae=f.baseState;b=0,ee=K=M=null,N=g;do{var X=N.lane&-536870913,Q=X!==N.lane;if(Q?(Je&X)===X:(c&X)===X){X!==0&&X===aa&&(mu=!0),ee!==null&&(ee=ee.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var De=e,_e=N;X=n;var dt=r;switch(_e.tag){case 1:if(De=_e.payload,typeof De=="function"){ae=De.call(dt,ae,X);break e}ae=De;break e;case 3:De.flags=De.flags&-65537|128;case 0:if(De=_e.payload,X=typeof De=="function"?De.call(dt,ae,X):De,X==null)break e;ae=x({},ae,X);break e;case 2:js=!0}}X=N.callback,X!==null&&(e.flags|=64,Q&&(e.flags|=8192),Q=f.callbacks,Q===null?f.callbacks=[X]:Q.push(X))}else Q={lane:X,tag:N.tag,payload:N.payload,callback:N.callback,next:null},ee===null?(K=ee=Q,M=ae):ee=ee.next=Q,b|=X;if(N=N.next,N===null){if(N=f.shared.pending,N===null)break;Q=N,N=Q.next,Q.next=null,f.lastBaseUpdate=Q,f.shared.pending=null}}while(!0);ee===null&&(M=ae),f.baseState=M,f.firstBaseUpdate=K,f.lastBaseUpdate=ee,g===null&&(f.shared.lanes=0),_s|=b,e.lanes=b,e.memoizedState=ae}}function qm(e,n){if(typeof e!="function")throw Error(a(191,e));e.call(n)}function Bm(e,n){var r=e.callbacks;if(r!==null)for(e.callbacks=null,e=0;e<r.length;e++)qm(r[e],n)}var oa=z(null),Do=z(0);function $m(e,n){e=ds,Z(Do,e),Z(oa,n),ds=e|n.baseLanes}function pu(){Z(Do,ds),Z(oa,oa.current)}function gu(){ds=Do.current,F(oa),F(Do)}var Ts=0,Ge=null,ct=null,Et=null,qo=!1,la=!1,gi=!1,Bo=0,lr=0,ca=null,jw=0;function Nt(){throw Error(a(321))}function xu(e,n){if(n===null)return!1;for(var r=0;r<n.length&&r<e.length;r++)if(!dn(e[r],n[r]))return!1;return!0}function yu(e,n,r,c,f,g){return Ts=g,Ge=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,H.H=e===null||e.memoizedState===null?kp:jp,gi=!1,g=r(c,f),gi=!1,la&&(g=Hm(n,r,c,f)),Um(e),g}function Um(e){H.H=Yo;var n=ct!==null&&ct.next!==null;if(Ts=0,Et=ct=Ge=null,qo=!1,lr=0,ca=null,n)throw Error(a(300));e===null||qt||(e=e.dependencies,e!==null&&zo(e)&&(qt=!0))}function Hm(e,n,r,c){Ge=e;var f=0;do{if(la&&(ca=null),lr=0,la=!1,25<=f)throw Error(a(301));if(f+=1,Et=ct=null,e.updateQueue!=null){var g=e.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}H.H=Mw,g=n(r,c)}while(la);return g}function Sw(){var e=H.H,n=e.useState()[0];return n=typeof n.then=="function"?cr(n):n,e=e.useState()[0],(ct!==null?ct.memoizedState:null)!==e&&(Ge.flags|=1024),n}function bu(){var e=Bo!==0;return Bo=0,e}function vu(e,n,r){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~r}function wu(e){if(qo){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}qo=!1}Ts=0,Et=ct=Ge=null,la=!1,lr=Bo=0,ca=null}function tn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Et===null?Ge.memoizedState=Et=e:Et=Et.next=e,Et}function Mt(){if(ct===null){var e=Ge.alternate;e=e!==null?e.memoizedState:null}else e=ct.next;var n=Et===null?Ge.memoizedState:Et.next;if(n!==null)Et=n,ct=e;else{if(e===null)throw Ge.alternate===null?Error(a(467)):Error(a(310));ct=e,e={memoizedState:ct.memoizedState,baseState:ct.baseState,baseQueue:ct.baseQueue,queue:ct.queue,next:null},Et===null?Ge.memoizedState=Et=e:Et=Et.next=e}return Et}function ku(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function cr(e){var n=lr;return lr+=1,ca===null&&(ca=[]),e=Lm(ca,e,n),n=Ge,(Et===null?n.memoizedState:Et.next)===null&&(n=n.alternate,H.H=n===null||n.memoizedState===null?kp:jp),e}function $o(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return cr(e);if(e.$$typeof===L)return Xt(e)}throw Error(a(438,String(e)))}function ju(e){var n=null,r=Ge.updateQueue;if(r!==null&&(n=r.memoCache),n==null){var c=Ge.alternate;c!==null&&(c=c.updateQueue,c!==null&&(c=c.memoCache,c!=null&&(n={data:c.data.map(function(f){return f.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),r===null&&(r=ku(),Ge.updateQueue=r),r.memoCache=n,r=n.data[n.index],r===void 0)for(r=n.data[n.index]=Array(e),c=0;c<e;c++)r[c]=U;return n.index++,r}function as(e,n){return typeof n=="function"?n(e):n}function Uo(e){var n=Mt();return Su(n,ct,e)}function Su(e,n,r){var c=e.queue;if(c===null)throw Error(a(311));c.lastRenderedReducer=r;var f=e.baseQueue,g=c.pending;if(g!==null){if(f!==null){var b=f.next;f.next=g.next,g.next=b}n.baseQueue=f=g,c.pending=null}if(g=e.baseState,f===null)e.memoizedState=g;else{n=f.next;var N=b=null,M=null,K=n,ee=!1;do{var ae=K.lane&-536870913;if(ae!==K.lane?(Je&ae)===ae:(Ts&ae)===ae){var X=K.revertLane;if(X===0)M!==null&&(M=M.next={lane:0,revertLane:0,action:K.action,hasEagerState:K.hasEagerState,eagerState:K.eagerState,next:null}),ae===aa&&(ee=!0);else if((Ts&X)===X){K=K.next,X===aa&&(ee=!0);continue}else ae={lane:0,revertLane:K.revertLane,action:K.action,hasEagerState:K.hasEagerState,eagerState:K.eagerState,next:null},M===null?(N=M=ae,b=g):M=M.next=ae,Ge.lanes|=X,_s|=X;ae=K.action,gi&&r(g,ae),g=K.hasEagerState?K.eagerState:r(g,ae)}else X={lane:ae,revertLane:K.revertLane,action:K.action,hasEagerState:K.hasEagerState,eagerState:K.eagerState,next:null},M===null?(N=M=X,b=g):M=M.next=X,Ge.lanes|=ae,_s|=ae;K=K.next}while(K!==null&&K!==n);if(M===null?b=g:M.next=N,!dn(g,e.memoizedState)&&(qt=!0,ee&&(r=ra,r!==null)))throw r;e.memoizedState=g,e.baseState=b,e.baseQueue=M,c.lastRenderedState=g}return f===null&&(c.lanes=0),[e.memoizedState,c.dispatch]}function Nu(e){var n=Mt(),r=n.queue;if(r===null)throw Error(a(311));r.lastRenderedReducer=e;var c=r.dispatch,f=r.pending,g=n.memoizedState;if(f!==null){r.pending=null;var b=f=f.next;do g=e(g,b.action),b=b.next;while(b!==f);dn(g,n.memoizedState)||(qt=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),r.lastRenderedState=g}return[g,c]}function Im(e,n,r){var c=Ge,f=Mt(),g=nt;if(g){if(r===void 0)throw Error(a(407));r=r()}else r=n();var b=!dn((ct||f).memoizedState,r);b&&(f.memoizedState=r,qt=!0),f=f.queue;var N=Vm.bind(null,c,f,e);if(ur(2048,8,N,[e]),f.getSnapshot!==n||b||Et!==null&&Et.memoizedState.tag&1){if(c.flags|=2048,ua(9,Ho(),Ym.bind(null,c,f,r,n),null),mt===null)throw Error(a(349));g||(Ts&124)!==0||Gm(c,n,r)}return r}function Gm(e,n,r){e.flags|=16384,e={getSnapshot:n,value:r},n=Ge.updateQueue,n===null?(n=ku(),Ge.updateQueue=n,n.stores=[e]):(r=n.stores,r===null?n.stores=[e]:r.push(e))}function Ym(e,n,r,c){n.value=r,n.getSnapshot=c,Km(n)&&Fm(e)}function Vm(e,n,r){return r(function(){Km(n)&&Fm(e)})}function Km(e){var n=e.getSnapshot;e=e.value;try{var r=n();return!dn(e,r)}catch{return!0}}function Fm(e){var n=ta(e,2);n!==null&&xn(n,e,2)}function Tu(e){var n=tn();if(typeof e=="function"){var r=e;if(e=r(),gi){zt(!0);try{r()}finally{zt(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:as,lastRenderedState:e},n}function Xm(e,n,r,c){return e.baseState=r,Su(e,ct,typeof c=="function"?c:as)}function Nw(e,n,r,c,f){if(Go(e))throw Error(a(485));if(e=n.action,e!==null){var g={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(b){g.listeners.push(b)}};H.T!==null?r(!0):g.isTransition=!1,c(g),r=n.pending,r===null?(g.next=n.pending=g,Pm(n,g)):(g.next=r.next,n.pending=r.next=g)}}function Pm(e,n){var r=n.action,c=n.payload,f=e.state;if(n.isTransition){var g=H.T,b={};H.T=b;try{var N=r(f,c),M=H.S;M!==null&&M(b,N),Qm(e,n,N)}catch(K){Au(e,n,K)}finally{H.T=g}}else try{g=r(f,c),Qm(e,n,g)}catch(K){Au(e,n,K)}}function Qm(e,n,r){r!==null&&typeof r=="object"&&typeof r.then=="function"?r.then(function(c){Wm(e,n,c)},function(c){return Au(e,n,c)}):Wm(e,n,r)}function Wm(e,n,r){n.status="fulfilled",n.value=r,Zm(n),e.state=r,n=e.pending,n!==null&&(r=n.next,r===n?e.pending=null:(r=r.next,n.next=r,Pm(e,r)))}function Au(e,n,r){var c=e.pending;if(e.pending=null,c!==null){c=c.next;do n.status="rejected",n.reason=r,Zm(n),n=n.next;while(n!==c)}e.action=null}function Zm(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function Jm(e,n){return n}function ep(e,n){if(nt){var r=mt.formState;if(r!==null){e:{var c=Ge;if(nt){if(vt){t:{for(var f=vt,g=In;f.nodeType!==8;){if(!g){f=null;break t}if(f=Dn(f.nextSibling),f===null){f=null;break t}}g=f.data,f=g==="F!"||g==="F"?f:null}if(f){vt=Dn(f.nextSibling),c=f.data==="F!";break e}}fi(c)}c=!1}c&&(n=r[0])}}return r=tn(),r.memoizedState=r.baseState=n,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jm,lastRenderedState:n},r.queue=c,r=bp.bind(null,Ge,c),c.dispatch=r,c=Tu(!1),g=Ru.bind(null,Ge,!1,c.queue),c=tn(),f={state:n,dispatch:null,action:e,pending:null},c.queue=f,r=Nw.bind(null,Ge,f,g,r),f.dispatch=r,c.memoizedState=e,[n,r,!1]}function tp(e){var n=Mt();return np(n,ct,e)}function np(e,n,r){if(n=Su(e,n,Jm)[0],e=Uo(as)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var c=cr(n)}catch(b){throw b===sr?Lo:b}else c=n;n=Mt();var f=n.queue,g=f.dispatch;return r!==n.memoizedState&&(Ge.flags|=2048,ua(9,Ho(),Tw.bind(null,f,r),null)),[c,g,e]}function Tw(e,n){e.action=n}function sp(e){var n=Mt(),r=ct;if(r!==null)return np(n,r,e);Mt(),n=n.memoizedState,r=Mt();var c=r.queue.dispatch;return r.memoizedState=e,[n,c,!1]}function ua(e,n,r,c){return e={tag:e,create:r,deps:c,inst:n,next:null},n=Ge.updateQueue,n===null&&(n=ku(),Ge.updateQueue=n),r=n.lastEffect,r===null?n.lastEffect=e.next=e:(c=r.next,r.next=e,e.next=c,n.lastEffect=e),e}function Ho(){return{destroy:void 0,resource:void 0}}function ip(){return Mt().memoizedState}function Io(e,n,r,c){var f=tn();c=c===void 0?null:c,Ge.flags|=e,f.memoizedState=ua(1|n,Ho(),r,c)}function ur(e,n,r,c){var f=Mt();c=c===void 0?null:c;var g=f.memoizedState.inst;ct!==null&&c!==null&&xu(c,ct.memoizedState.deps)?f.memoizedState=ua(n,g,r,c):(Ge.flags|=e,f.memoizedState=ua(1|n,g,r,c))}function ap(e,n){Io(8390656,8,e,n)}function rp(e,n){ur(2048,8,e,n)}function op(e,n){return ur(4,2,e,n)}function lp(e,n){return ur(4,4,e,n)}function cp(e,n){if(typeof n=="function"){e=e();var r=n(e);return function(){typeof r=="function"?r():n(null)}}if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function up(e,n,r){r=r!=null?r.concat([e]):null,ur(4,4,cp.bind(null,n,e),r)}function Cu(){}function dp(e,n){var r=Mt();n=n===void 0?null:n;var c=r.memoizedState;return n!==null&&xu(n,c[1])?c[0]:(r.memoizedState=[e,n],e)}function fp(e,n){var r=Mt();n=n===void 0?null:n;var c=r.memoizedState;if(n!==null&&xu(n,c[1]))return c[0];if(c=e(),gi){zt(!0);try{e()}finally{zt(!1)}}return r.memoizedState=[c,n],c}function Eu(e,n,r){return r===void 0||(Ts&1073741824)!==0?e.memoizedState=n:(e.memoizedState=r,e=pg(),Ge.lanes|=e,_s|=e,r)}function hp(e,n,r,c){return dn(r,n)?r:oa.current!==null?(e=Eu(e,r,c),dn(e,n)||(qt=!0),e):(Ts&42)===0?(qt=!0,e.memoizedState=r):(e=pg(),Ge.lanes|=e,_s|=e,n)}function mp(e,n,r,c,f){var g=P.p;P.p=g!==0&&8>g?g:8;var b=H.T,N={};H.T=N,Ru(e,!1,n,r);try{var M=f(),K=H.S;if(K!==null&&K(N,M),M!==null&&typeof M=="object"&&typeof M.then=="function"){var ee=kw(M,c);dr(e,n,ee,gn(e))}else dr(e,n,c,gn(e))}catch(ae){dr(e,n,{then:function(){},status:"rejected",reason:ae},gn())}finally{P.p=g,H.T=b}}function Aw(){}function Mu(e,n,r,c){if(e.tag!==5)throw Error(a(476));var f=pp(e).queue;mp(e,f,n,oe,r===null?Aw:function(){return gp(e),r(c)})}function pp(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:as,lastRenderedState:oe},next:null};var r={};return n.next={memoizedState:r,baseState:r,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:as,lastRenderedState:r},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function gp(e){var n=pp(e).next.queue;dr(e,n,{},gn())}function zu(){return Xt(Er)}function xp(){return Mt().memoizedState}function yp(){return Mt().memoizedState}function Cw(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var r=gn();e=Ss(r);var c=Ns(n,e,r);c!==null&&(xn(c,n,r),ar(c,n,r)),n={cache:ou()},e.payload=n;return}n=n.return}}function Ew(e,n,r){var c=gn();r={lane:c,revertLane:0,action:r,hasEagerState:!1,eagerState:null,next:null},Go(e)?vp(n,r):(r=Wc(e,n,r,c),r!==null&&(xn(r,e,c),wp(r,n,c)))}function bp(e,n,r){var c=gn();dr(e,n,r,c)}function dr(e,n,r,c){var f={lane:c,revertLane:0,action:r,hasEagerState:!1,eagerState:null,next:null};if(Go(e))vp(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var b=n.lastRenderedState,N=g(b,r);if(f.hasEagerState=!0,f.eagerState=N,dn(N,b))return To(e,n,f,0),mt===null&&No(),!1}catch{}if(r=Wc(e,n,f,c),r!==null)return xn(r,e,c),wp(r,n,c),!0}return!1}function Ru(e,n,r,c){if(c={lane:2,revertLane:ud(),action:c,hasEagerState:!1,eagerState:null,next:null},Go(e)){if(n)throw Error(a(479))}else n=Wc(e,r,c,2),n!==null&&xn(n,e,2)}function Go(e){var n=e.alternate;return e===Ge||n!==null&&n===Ge}function vp(e,n){la=qo=!0;var r=e.pending;r===null?n.next=n:(n.next=r.next,r.next=n),e.pending=n}function wp(e,n,r){if((r&4194048)!==0){var c=n.lanes;c&=e.pendingLanes,r|=c,n.lanes=r,Ke(e,r)}}var Yo={readContext:Xt,use:$o,useCallback:Nt,useContext:Nt,useEffect:Nt,useImperativeHandle:Nt,useLayoutEffect:Nt,useInsertionEffect:Nt,useMemo:Nt,useReducer:Nt,useRef:Nt,useState:Nt,useDebugValue:Nt,useDeferredValue:Nt,useTransition:Nt,useSyncExternalStore:Nt,useId:Nt,useHostTransitionStatus:Nt,useFormState:Nt,useActionState:Nt,useOptimistic:Nt,useMemoCache:Nt,useCacheRefresh:Nt},kp={readContext:Xt,use:$o,useCallback:function(e,n){return tn().memoizedState=[e,n===void 0?null:n],e},useContext:Xt,useEffect:ap,useImperativeHandle:function(e,n,r){r=r!=null?r.concat([e]):null,Io(4194308,4,cp.bind(null,n,e),r)},useLayoutEffect:function(e,n){return Io(4194308,4,e,n)},useInsertionEffect:function(e,n){Io(4,2,e,n)},useMemo:function(e,n){var r=tn();n=n===void 0?null:n;var c=e();if(gi){zt(!0);try{e()}finally{zt(!1)}}return r.memoizedState=[c,n],c},useReducer:function(e,n,r){var c=tn();if(r!==void 0){var f=r(n);if(gi){zt(!0);try{r(n)}finally{zt(!1)}}}else f=n;return c.memoizedState=c.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},c.queue=e,e=e.dispatch=Ew.bind(null,Ge,e),[c.memoizedState,e]},useRef:function(e){var n=tn();return e={current:e},n.memoizedState=e},useState:function(e){e=Tu(e);var n=e.queue,r=bp.bind(null,Ge,n);return n.dispatch=r,[e.memoizedState,r]},useDebugValue:Cu,useDeferredValue:function(e,n){var r=tn();return Eu(r,e,n)},useTransition:function(){var e=Tu(!1);return e=mp.bind(null,Ge,e.queue,!0,!1),tn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,r){var c=Ge,f=tn();if(nt){if(r===void 0)throw Error(a(407));r=r()}else{if(r=n(),mt===null)throw Error(a(349));(Je&124)!==0||Gm(c,n,r)}f.memoizedState=r;var g={value:r,getSnapshot:n};return f.queue=g,ap(Vm.bind(null,c,g,e),[e]),c.flags|=2048,ua(9,Ho(),Ym.bind(null,c,g,r,n),null),r},useId:function(){var e=tn(),n=mt.identifierPrefix;if(nt){var r=ns,c=ts;r=(c&~(1<<32-Ct(c)-1)).toString(32)+r,n="«"+n+"R"+r,r=Bo++,0<r&&(n+="H"+r.toString(32)),n+="»"}else r=jw++,n="«"+n+"r"+r.toString(32)+"»";return e.memoizedState=n},useHostTransitionStatus:zu,useFormState:ep,useActionState:ep,useOptimistic:function(e){var n=tn();n.memoizedState=n.baseState=e;var r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=r,n=Ru.bind(null,Ge,!0,r),r.dispatch=n,[e,n]},useMemoCache:ju,useCacheRefresh:function(){return tn().memoizedState=Cw.bind(null,Ge)}},jp={readContext:Xt,use:$o,useCallback:dp,useContext:Xt,useEffect:rp,useImperativeHandle:up,useInsertionEffect:op,useLayoutEffect:lp,useMemo:fp,useReducer:Uo,useRef:ip,useState:function(){return Uo(as)},useDebugValue:Cu,useDeferredValue:function(e,n){var r=Mt();return hp(r,ct.memoizedState,e,n)},useTransition:function(){var e=Uo(as)[0],n=Mt().memoizedState;return[typeof e=="boolean"?e:cr(e),n]},useSyncExternalStore:Im,useId:xp,useHostTransitionStatus:zu,useFormState:tp,useActionState:tp,useOptimistic:function(e,n){var r=Mt();return Xm(r,ct,e,n)},useMemoCache:ju,useCacheRefresh:yp},Mw={readContext:Xt,use:$o,useCallback:dp,useContext:Xt,useEffect:rp,useImperativeHandle:up,useInsertionEffect:op,useLayoutEffect:lp,useMemo:fp,useReducer:Nu,useRef:ip,useState:function(){return Nu(as)},useDebugValue:Cu,useDeferredValue:function(e,n){var r=Mt();return ct===null?Eu(r,e,n):hp(r,ct.memoizedState,e,n)},useTransition:function(){var e=Nu(as)[0],n=Mt().memoizedState;return[typeof e=="boolean"?e:cr(e),n]},useSyncExternalStore:Im,useId:xp,useHostTransitionStatus:zu,useFormState:sp,useActionState:sp,useOptimistic:function(e,n){var r=Mt();return ct!==null?Xm(r,ct,e,n):(r.baseState=e,[e,r.queue.dispatch])},useMemoCache:ju,useCacheRefresh:yp},da=null,fr=0;function Vo(e){var n=fr;return fr+=1,da===null&&(da=[]),Lm(da,e,n)}function hr(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function Ko(e,n){throw n.$$typeof===y?Error(a(525)):(e=Object.prototype.toString.call(n),Error(a(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function Sp(e){var n=e._init;return n(e._payload)}function Np(e){function n($,D){if(e){var Y=$.deletions;Y===null?($.deletions=[D],$.flags|=16):Y.push(D)}}function r($,D){if(!e)return null;for(;D!==null;)n($,D),D=D.sibling;return null}function c($){for(var D=new Map;$!==null;)$.key!==null?D.set($.key,$):D.set($.index,$),$=$.sibling;return D}function f($,D){return $=es($,D),$.index=0,$.sibling=null,$}function g($,D,Y){return $.index=Y,e?(Y=$.alternate,Y!==null?(Y=Y.index,Y<D?($.flags|=67108866,D):Y):($.flags|=67108866,D)):($.flags|=1048576,D)}function b($){return e&&$.alternate===null&&($.flags|=67108866),$}function N($,D,Y,te){return D===null||D.tag!==6?(D=Jc(Y,$.mode,te),D.return=$,D):(D=f(D,Y),D.return=$,D)}function M($,D,Y,te){var Se=Y.type;return Se===S?ee($,D,Y.props.children,te,Y.key):D!==null&&(D.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===E&&Sp(Se)===D.type)?(D=f(D,Y.props),hr(D,Y),D.return=$,D):(D=Co(Y.type,Y.key,Y.props,null,$.mode,te),hr(D,Y),D.return=$,D)}function K($,D,Y,te){return D===null||D.tag!==4||D.stateNode.containerInfo!==Y.containerInfo||D.stateNode.implementation!==Y.implementation?(D=eu(Y,$.mode,te),D.return=$,D):(D=f(D,Y.children||[]),D.return=$,D)}function ee($,D,Y,te,Se){return D===null||D.tag!==7?(D=li(Y,$.mode,te,Se),D.return=$,D):(D=f(D,Y),D.return=$,D)}function ae($,D,Y){if(typeof D=="string"&&D!==""||typeof D=="number"||typeof D=="bigint")return D=Jc(""+D,$.mode,Y),D.return=$,D;if(typeof D=="object"&&D!==null){switch(D.$$typeof){case v:return Y=Co(D.type,D.key,D.props,null,$.mode,Y),hr(Y,D),Y.return=$,Y;case k:return D=eu(D,$.mode,Y),D.return=$,D;case E:var te=D._init;return D=te(D._payload),ae($,D,Y)}if(fe(D)||J(D))return D=li(D,$.mode,Y,null),D.return=$,D;if(typeof D.then=="function")return ae($,Vo(D),Y);if(D.$$typeof===L)return ae($,Ro($,D),Y);Ko($,D)}return null}function X($,D,Y,te){var Se=D!==null?D.key:null;if(typeof Y=="string"&&Y!==""||typeof Y=="number"||typeof Y=="bigint")return Se!==null?null:N($,D,""+Y,te);if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case v:return Y.key===Se?M($,D,Y,te):null;case k:return Y.key===Se?K($,D,Y,te):null;case E:return Se=Y._init,Y=Se(Y._payload),X($,D,Y,te)}if(fe(Y)||J(Y))return Se!==null?null:ee($,D,Y,te,null);if(typeof Y.then=="function")return X($,D,Vo(Y),te);if(Y.$$typeof===L)return X($,D,Ro($,Y),te);Ko($,Y)}return null}function Q($,D,Y,te,Se){if(typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint")return $=$.get(Y)||null,N(D,$,""+te,Se);if(typeof te=="object"&&te!==null){switch(te.$$typeof){case v:return $=$.get(te.key===null?Y:te.key)||null,M(D,$,te,Se);case k:return $=$.get(te.key===null?Y:te.key)||null,K(D,$,te,Se);case E:var Ve=te._init;return te=Ve(te._payload),Q($,D,Y,te,Se)}if(fe(te)||J(te))return $=$.get(Y)||null,ee(D,$,te,Se,null);if(typeof te.then=="function")return Q($,D,Y,Vo(te),Se);if(te.$$typeof===L)return Q($,D,Y,Ro(D,te),Se);Ko(D,te)}return null}function De($,D,Y,te){for(var Se=null,Ve=null,Ee=D,Le=D=0,$t=null;Ee!==null&&Le<Y.length;Le++){Ee.index>Le?($t=Ee,Ee=null):$t=Ee.sibling;var tt=X($,Ee,Y[Le],te);if(tt===null){Ee===null&&(Ee=$t);break}e&&Ee&&tt.alternate===null&&n($,Ee),D=g(tt,D,Le),Ve===null?Se=tt:Ve.sibling=tt,Ve=tt,Ee=$t}if(Le===Y.length)return r($,Ee),nt&&ui($,Le),Se;if(Ee===null){for(;Le<Y.length;Le++)Ee=ae($,Y[Le],te),Ee!==null&&(D=g(Ee,D,Le),Ve===null?Se=Ee:Ve.sibling=Ee,Ve=Ee);return nt&&ui($,Le),Se}for(Ee=c(Ee);Le<Y.length;Le++)$t=Q(Ee,$,Le,Y[Le],te),$t!==null&&(e&&$t.alternate!==null&&Ee.delete($t.key===null?Le:$t.key),D=g($t,D,Le),Ve===null?Se=$t:Ve.sibling=$t,Ve=$t);return e&&Ee.forEach(function(Is){return n($,Is)}),nt&&ui($,Le),Se}function _e($,D,Y,te){if(Y==null)throw Error(a(151));for(var Se=null,Ve=null,Ee=D,Le=D=0,$t=null,tt=Y.next();Ee!==null&&!tt.done;Le++,tt=Y.next()){Ee.index>Le?($t=Ee,Ee=null):$t=Ee.sibling;var Is=X($,Ee,tt.value,te);if(Is===null){Ee===null&&(Ee=$t);break}e&&Ee&&Is.alternate===null&&n($,Ee),D=g(Is,D,Le),Ve===null?Se=Is:Ve.sibling=Is,Ve=Is,Ee=$t}if(tt.done)return r($,Ee),nt&&ui($,Le),Se;if(Ee===null){for(;!tt.done;Le++,tt=Y.next())tt=ae($,tt.value,te),tt!==null&&(D=g(tt,D,Le),Ve===null?Se=tt:Ve.sibling=tt,Ve=tt);return nt&&ui($,Le),Se}for(Ee=c(Ee);!tt.done;Le++,tt=Y.next())tt=Q(Ee,$,Le,tt.value,te),tt!==null&&(e&&tt.alternate!==null&&Ee.delete(tt.key===null?Le:tt.key),D=g(tt,D,Le),Ve===null?Se=tt:Ve.sibling=tt,Ve=tt);return e&&Ee.forEach(function(zk){return n($,zk)}),nt&&ui($,Le),Se}function dt($,D,Y,te){if(typeof Y=="object"&&Y!==null&&Y.type===S&&Y.key===null&&(Y=Y.props.children),typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case v:e:{for(var Se=Y.key;D!==null;){if(D.key===Se){if(Se=Y.type,Se===S){if(D.tag===7){r($,D.sibling),te=f(D,Y.props.children),te.return=$,$=te;break e}}else if(D.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===E&&Sp(Se)===D.type){r($,D.sibling),te=f(D,Y.props),hr(te,Y),te.return=$,$=te;break e}r($,D);break}else n($,D);D=D.sibling}Y.type===S?(te=li(Y.props.children,$.mode,te,Y.key),te.return=$,$=te):(te=Co(Y.type,Y.key,Y.props,null,$.mode,te),hr(te,Y),te.return=$,$=te)}return b($);case k:e:{for(Se=Y.key;D!==null;){if(D.key===Se)if(D.tag===4&&D.stateNode.containerInfo===Y.containerInfo&&D.stateNode.implementation===Y.implementation){r($,D.sibling),te=f(D,Y.children||[]),te.return=$,$=te;break e}else{r($,D);break}else n($,D);D=D.sibling}te=eu(Y,$.mode,te),te.return=$,$=te}return b($);case E:return Se=Y._init,Y=Se(Y._payload),dt($,D,Y,te)}if(fe(Y))return De($,D,Y,te);if(J(Y)){if(Se=J(Y),typeof Se!="function")throw Error(a(150));return Y=Se.call(Y),_e($,D,Y,te)}if(typeof Y.then=="function")return dt($,D,Vo(Y),te);if(Y.$$typeof===L)return dt($,D,Ro($,Y),te);Ko($,Y)}return typeof Y=="string"&&Y!==""||typeof Y=="number"||typeof Y=="bigint"?(Y=""+Y,D!==null&&D.tag===6?(r($,D.sibling),te=f(D,Y),te.return=$,$=te):(r($,D),te=Jc(Y,$.mode,te),te.return=$,$=te),b($)):r($,D)}return function($,D,Y,te){try{fr=0;var Se=dt($,D,Y,te);return da=null,Se}catch(Ee){if(Ee===sr||Ee===Lo)throw Ee;var Ve=fn(29,Ee,null,$.mode);return Ve.lanes=te,Ve.return=$,Ve}}}var fa=Np(!0),Tp=Np(!1),An=z(null),Gn=null;function As(e){var n=e.alternate;Z(_t,_t.current&1),Z(An,e),Gn===null&&(n===null||oa.current!==null||n.memoizedState!==null)&&(Gn=e)}function Ap(e){if(e.tag===22){if(Z(_t,_t.current),Z(An,e),Gn===null){var n=e.alternate;n!==null&&n.memoizedState!==null&&(Gn=e)}}else Cs()}function Cs(){Z(_t,_t.current),Z(An,An.current)}function rs(e){F(An),Gn===e&&(Gn=null),F(_t)}var _t=z(0);function Fo(e){for(var n=e;n!==null;){if(n.tag===13){var r=n.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||r.data==="$?"||kd(r)))return n}else if(n.tag===19&&n.memoizedProps.revealOrder!==void 0){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}function _u(e,n,r,c){n=e.memoizedState,r=r(c,n),r=r==null?n:x({},n,r),e.memoizedState=r,e.lanes===0&&(e.updateQueue.baseState=r)}var Lu={enqueueSetState:function(e,n,r){e=e._reactInternals;var c=gn(),f=Ss(c);f.payload=n,r!=null&&(f.callback=r),n=Ns(e,f,c),n!==null&&(xn(n,e,c),ar(n,e,c))},enqueueReplaceState:function(e,n,r){e=e._reactInternals;var c=gn(),f=Ss(c);f.tag=1,f.payload=n,r!=null&&(f.callback=r),n=Ns(e,f,c),n!==null&&(xn(n,e,c),ar(n,e,c))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var r=gn(),c=Ss(r);c.tag=2,n!=null&&(c.callback=n),n=Ns(e,c,r),n!==null&&(xn(n,e,r),ar(n,e,r))}};function Cp(e,n,r,c,f,g,b){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(c,g,b):n.prototype&&n.prototype.isPureReactComponent?!Pa(r,c)||!Pa(f,g):!0}function Ep(e,n,r,c){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(r,c),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(r,c),n.state!==e&&Lu.enqueueReplaceState(n,n.state,null)}function xi(e,n){var r=n;if("ref"in n){r={};for(var c in n)c!=="ref"&&(r[c]=n[c])}if(e=e.defaultProps){r===n&&(r=x({},r));for(var f in e)r[f]===void 0&&(r[f]=e[f])}return r}var Xo=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)};function Mp(e){Xo(e)}function zp(e){console.error(e)}function Rp(e){Xo(e)}function Po(e,n){try{var r=e.onUncaughtError;r(n.value,{componentStack:n.stack})}catch(c){setTimeout(function(){throw c})}}function _p(e,n,r){try{var c=e.onCaughtError;c(r.value,{componentStack:r.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function Ou(e,n,r){return r=Ss(r),r.tag=3,r.payload={element:null},r.callback=function(){Po(e,n)},r}function Lp(e){return e=Ss(e),e.tag=3,e}function Op(e,n,r,c){var f=r.type.getDerivedStateFromError;if(typeof f=="function"){var g=c.value;e.payload=function(){return f(g)},e.callback=function(){_p(n,r,c)}}var b=r.stateNode;b!==null&&typeof b.componentDidCatch=="function"&&(e.callback=function(){_p(n,r,c),typeof f!="function"&&(Ls===null?Ls=new Set([this]):Ls.add(this));var N=c.stack;this.componentDidCatch(c.value,{componentStack:N!==null?N:""})})}function zw(e,n,r,c,f){if(r.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(n=r.alternate,n!==null&&er(n,r,f,!0),r=An.current,r!==null){switch(r.tag){case 13:return Gn===null?ad():r.alternate===null&&wt===0&&(wt=3),r.flags&=-257,r.flags|=65536,r.lanes=f,c===uu?r.flags|=16384:(n=r.updateQueue,n===null?r.updateQueue=new Set([c]):n.add(c),od(e,c,f)),!1;case 22:return r.flags|=65536,c===uu?r.flags|=16384:(n=r.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([c])},r.updateQueue=n):(r=n.retryQueue,r===null?n.retryQueue=new Set([c]):r.add(c)),od(e,c,f)),!1}throw Error(a(435,r.tag))}return od(e,c,f),ad(),!1}if(nt)return n=An.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=f,c!==su&&(e=Error(a(422),{cause:c}),Ja(jn(e,r)))):(c!==su&&(n=Error(a(423),{cause:c}),Ja(jn(n,r))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,c=jn(c,r),f=Ou(e.stateNode,c,f),hu(e,f),wt!==4&&(wt=2)),!1;var g=Error(a(520),{cause:c});if(g=jn(g,r),vr===null?vr=[g]:vr.push(g),wt!==4&&(wt=2),n===null)return!0;c=jn(c,r),r=n;do{switch(r.tag){case 3:return r.flags|=65536,e=f&-f,r.lanes|=e,e=Ou(r.stateNode,c,e),hu(r,e),!1;case 1:if(n=r.type,g=r.stateNode,(r.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(Ls===null||!Ls.has(g))))return r.flags|=65536,f&=-f,r.lanes|=f,f=Lp(f),Op(f,e,r,c),hu(r,f),!1}r=r.return}while(r!==null);return!1}var Dp=Error(a(461)),qt=!1;function Ht(e,n,r,c){n.child=e===null?Tp(n,null,r,c):fa(n,e.child,r,c)}function qp(e,n,r,c,f){r=r.render;var g=n.ref;if("ref"in c){var b={};for(var N in c)N!=="ref"&&(b[N]=c[N])}else b=c;return mi(n),c=yu(e,n,r,b,g,f),N=bu(),e!==null&&!qt?(vu(e,n,f),os(e,n,f)):(nt&&N&&tu(n),n.flags|=1,Ht(e,n,c,f),n.child)}function Bp(e,n,r,c,f){if(e===null){var g=r.type;return typeof g=="function"&&!Zc(g)&&g.defaultProps===void 0&&r.compare===null?(n.tag=15,n.type=g,$p(e,n,g,c,f)):(e=Co(r.type,null,c,n,n.mode,f),e.ref=n.ref,e.return=n,n.child=e)}if(g=e.child,!Gu(e,f)){var b=g.memoizedProps;if(r=r.compare,r=r!==null?r:Pa,r(b,c)&&e.ref===n.ref)return os(e,n,f)}return n.flags|=1,e=es(g,c),e.ref=n.ref,e.return=n,n.child=e}function $p(e,n,r,c,f){if(e!==null){var g=e.memoizedProps;if(Pa(g,c)&&e.ref===n.ref)if(qt=!1,n.pendingProps=c=g,Gu(e,f))(e.flags&131072)!==0&&(qt=!0);else return n.lanes=e.lanes,os(e,n,f)}return Du(e,n,r,c,f)}function Up(e,n,r){var c=n.pendingProps,f=c.children,g=e!==null?e.memoizedState:null;if(c.mode==="hidden"){if((n.flags&128)!==0){if(c=g!==null?g.baseLanes|r:r,e!==null){for(f=n.child=e.child,g=0;f!==null;)g=g|f.lanes|f.childLanes,f=f.sibling;n.childLanes=g&~c}else n.childLanes=0,n.child=null;return Hp(e,n,c,r)}if((r&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&_o(n,g!==null?g.cachePool:null),g!==null?$m(n,g):pu(),Ap(n);else return n.lanes=n.childLanes=536870912,Hp(e,n,g!==null?g.baseLanes|r:r,r)}else g!==null?(_o(n,g.cachePool),$m(n,g),Cs(),n.memoizedState=null):(e!==null&&_o(n,null),pu(),Cs());return Ht(e,n,f,r),n.child}function Hp(e,n,r,c){var f=cu();return f=f===null?null:{parent:Rt._currentValue,pool:f},n.memoizedState={baseLanes:r,cachePool:f},e!==null&&_o(n,null),pu(),Ap(n),e!==null&&er(e,n,c,!0),null}function Qo(e,n){var r=n.ref;if(r===null)e!==null&&e.ref!==null&&(n.flags|=4194816);else{if(typeof r!="function"&&typeof r!="object")throw Error(a(284));(e===null||e.ref!==r)&&(n.flags|=4194816)}}function Du(e,n,r,c,f){return mi(n),r=yu(e,n,r,c,void 0,f),c=bu(),e!==null&&!qt?(vu(e,n,f),os(e,n,f)):(nt&&c&&tu(n),n.flags|=1,Ht(e,n,r,f),n.child)}function Ip(e,n,r,c,f,g){return mi(n),n.updateQueue=null,r=Hm(n,c,r,f),Um(e),c=bu(),e!==null&&!qt?(vu(e,n,g),os(e,n,g)):(nt&&c&&tu(n),n.flags|=1,Ht(e,n,r,g),n.child)}function Gp(e,n,r,c,f){if(mi(n),n.stateNode===null){var g=na,b=r.contextType;typeof b=="object"&&b!==null&&(g=Xt(b)),g=new r(c,g),n.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Lu,n.stateNode=g,g._reactInternals=n,g=n.stateNode,g.props=c,g.state=n.memoizedState,g.refs={},du(n),b=r.contextType,g.context=typeof b=="object"&&b!==null?Xt(b):na,g.state=n.memoizedState,b=r.getDerivedStateFromProps,typeof b=="function"&&(_u(n,r,b,c),g.state=n.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(b=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),b!==g.state&&Lu.enqueueReplaceState(g,g.state,null),or(n,c,g,f),rr(),g.state=n.memoizedState),typeof g.componentDidMount=="function"&&(n.flags|=4194308),c=!0}else if(e===null){g=n.stateNode;var N=n.memoizedProps,M=xi(r,N);g.props=M;var K=g.context,ee=r.contextType;b=na,typeof ee=="object"&&ee!==null&&(b=Xt(ee));var ae=r.getDerivedStateFromProps;ee=typeof ae=="function"||typeof g.getSnapshotBeforeUpdate=="function",N=n.pendingProps!==N,ee||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(N||K!==b)&&Ep(n,g,c,b),js=!1;var X=n.memoizedState;g.state=X,or(n,c,g,f),rr(),K=n.memoizedState,N||X!==K||js?(typeof ae=="function"&&(_u(n,r,ae,c),K=n.memoizedState),(M=js||Cp(n,r,M,c,X,K,b))?(ee||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount()),typeof g.componentDidMount=="function"&&(n.flags|=4194308)):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=c,n.memoizedState=K),g.props=c,g.state=K,g.context=b,c=M):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),c=!1)}else{g=n.stateNode,fu(e,n),b=n.memoizedProps,ee=xi(r,b),g.props=ee,ae=n.pendingProps,X=g.context,K=r.contextType,M=na,typeof K=="object"&&K!==null&&(M=Xt(K)),N=r.getDerivedStateFromProps,(K=typeof N=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(b!==ae||X!==M)&&Ep(n,g,c,M),js=!1,X=n.memoizedState,g.state=X,or(n,c,g,f),rr();var Q=n.memoizedState;b!==ae||X!==Q||js||e!==null&&e.dependencies!==null&&zo(e.dependencies)?(typeof N=="function"&&(_u(n,r,N,c),Q=n.memoizedState),(ee=js||Cp(n,r,ee,c,X,Q,M)||e!==null&&e.dependencies!==null&&zo(e.dependencies))?(K||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(c,Q,M),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(c,Q,M)),typeof g.componentDidUpdate=="function"&&(n.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof g.componentDidUpdate!="function"||b===e.memoizedProps&&X===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&X===e.memoizedState||(n.flags|=1024),n.memoizedProps=c,n.memoizedState=Q),g.props=c,g.state=Q,g.context=M,c=ee):(typeof g.componentDidUpdate!="function"||b===e.memoizedProps&&X===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&X===e.memoizedState||(n.flags|=1024),c=!1)}return g=c,Qo(e,n),c=(n.flags&128)!==0,g||c?(g=n.stateNode,r=c&&typeof r.getDerivedStateFromError!="function"?null:g.render(),n.flags|=1,e!==null&&c?(n.child=fa(n,e.child,null,f),n.child=fa(n,null,r,f)):Ht(e,n,r,f),n.memoizedState=g.state,e=n.child):e=os(e,n,f),e}function Yp(e,n,r,c){return Za(),n.flags|=256,Ht(e,n,r,c),n.child}var qu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Bu(e){return{baseLanes:e,cachePool:zm()}}function $u(e,n,r){return e=e!==null?e.childLanes&~r:0,n&&(e|=Cn),e}function Vp(e,n,r){var c=n.pendingProps,f=!1,g=(n.flags&128)!==0,b;if((b=g)||(b=e!==null&&e.memoizedState===null?!1:(_t.current&2)!==0),b&&(f=!0,n.flags&=-129),b=(n.flags&32)!==0,n.flags&=-33,e===null){if(nt){if(f?As(n):Cs(),nt){var N=vt,M;if(M=N){e:{for(M=N,N=In;M.nodeType!==8;){if(!N){N=null;break e}if(M=Dn(M.nextSibling),M===null){N=null;break e}}N=M}N!==null?(n.memoizedState={dehydrated:N,treeContext:ci!==null?{id:ts,overflow:ns}:null,retryLane:536870912,hydrationErrors:null},M=fn(18,null,null,0),M.stateNode=N,M.return=n,n.child=M,Qt=n,vt=null,M=!0):M=!1}M||fi(n)}if(N=n.memoizedState,N!==null&&(N=N.dehydrated,N!==null))return kd(N)?n.lanes=32:n.lanes=536870912,null;rs(n)}return N=c.children,c=c.fallback,f?(Cs(),f=n.mode,N=Wo({mode:"hidden",children:N},f),c=li(c,f,r,null),N.return=n,c.return=n,N.sibling=c,n.child=N,f=n.child,f.memoizedState=Bu(r),f.childLanes=$u(e,b,r),n.memoizedState=qu,c):(As(n),Uu(n,N))}if(M=e.memoizedState,M!==null&&(N=M.dehydrated,N!==null)){if(g)n.flags&256?(As(n),n.flags&=-257,n=Hu(e,n,r)):n.memoizedState!==null?(Cs(),n.child=e.child,n.flags|=128,n=null):(Cs(),f=c.fallback,N=n.mode,c=Wo({mode:"visible",children:c.children},N),f=li(f,N,r,null),f.flags|=2,c.return=n,f.return=n,c.sibling=f,n.child=c,fa(n,e.child,null,r),c=n.child,c.memoizedState=Bu(r),c.childLanes=$u(e,b,r),n.memoizedState=qu,n=f);else if(As(n),kd(N)){if(b=N.nextSibling&&N.nextSibling.dataset,b)var K=b.dgst;b=K,c=Error(a(419)),c.stack="",c.digest=b,Ja({value:c,source:null,stack:null}),n=Hu(e,n,r)}else if(qt||er(e,n,r,!1),b=(r&e.childLanes)!==0,qt||b){if(b=mt,b!==null&&(c=r&-r,c=(c&42)!==0?1:lt(c),c=(c&(b.suspendedLanes|r))!==0?0:c,c!==0&&c!==M.retryLane))throw M.retryLane=c,ta(e,c),xn(b,e,c),Dp;N.data==="$?"||ad(),n=Hu(e,n,r)}else N.data==="$?"?(n.flags|=192,n.child=e.child,n=null):(e=M.treeContext,vt=Dn(N.nextSibling),Qt=n,nt=!0,di=null,In=!1,e!==null&&(Nn[Tn++]=ts,Nn[Tn++]=ns,Nn[Tn++]=ci,ts=e.id,ns=e.overflow,ci=n),n=Uu(n,c.children),n.flags|=4096);return n}return f?(Cs(),f=c.fallback,N=n.mode,M=e.child,K=M.sibling,c=es(M,{mode:"hidden",children:c.children}),c.subtreeFlags=M.subtreeFlags&65011712,K!==null?f=es(K,f):(f=li(f,N,r,null),f.flags|=2),f.return=n,c.return=n,c.sibling=f,n.child=c,c=f,f=n.child,N=e.child.memoizedState,N===null?N=Bu(r):(M=N.cachePool,M!==null?(K=Rt._currentValue,M=M.parent!==K?{parent:K,pool:K}:M):M=zm(),N={baseLanes:N.baseLanes|r,cachePool:M}),f.memoizedState=N,f.childLanes=$u(e,b,r),n.memoizedState=qu,c):(As(n),r=e.child,e=r.sibling,r=es(r,{mode:"visible",children:c.children}),r.return=n,r.sibling=null,e!==null&&(b=n.deletions,b===null?(n.deletions=[e],n.flags|=16):b.push(e)),n.child=r,n.memoizedState=null,r)}function Uu(e,n){return n=Wo({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function Wo(e,n){return e=fn(22,e,null,n),e.lanes=0,e.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null},e}function Hu(e,n,r){return fa(n,e.child,null,r),e=Uu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Kp(e,n,r){e.lanes|=n;var c=e.alternate;c!==null&&(c.lanes|=n),au(e.return,n,r)}function Iu(e,n,r,c,f){var g=e.memoizedState;g===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:c,tail:r,tailMode:f}:(g.isBackwards=n,g.rendering=null,g.renderingStartTime=0,g.last=c,g.tail=r,g.tailMode=f)}function Fp(e,n,r){var c=n.pendingProps,f=c.revealOrder,g=c.tail;if(Ht(e,n,c.children,r),c=_t.current,(c&2)!==0)c=c&1|2,n.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Kp(e,r,n);else if(e.tag===19)Kp(e,r,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}c&=1}switch(Z(_t,c),f){case"forwards":for(r=n.child,f=null;r!==null;)e=r.alternate,e!==null&&Fo(e)===null&&(f=r),r=r.sibling;r=f,r===null?(f=n.child,n.child=null):(f=r.sibling,r.sibling=null),Iu(n,!1,f,r,g);break;case"backwards":for(r=null,f=n.child,n.child=null;f!==null;){if(e=f.alternate,e!==null&&Fo(e)===null){n.child=f;break}e=f.sibling,f.sibling=r,r=f,f=e}Iu(n,!0,r,null,g);break;case"together":Iu(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function os(e,n,r){if(e!==null&&(n.dependencies=e.dependencies),_s|=n.lanes,(r&n.childLanes)===0)if(e!==null){if(er(e,n,r,!1),(r&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(a(153));if(n.child!==null){for(e=n.child,r=es(e,e.pendingProps),n.child=r,r.return=n;e.sibling!==null;)e=e.sibling,r=r.sibling=es(e,e.pendingProps),r.return=n;r.sibling=null}return n.child}function Gu(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&zo(e)))}function Rw(e,n,r){switch(n.tag){case 3:Re(n,n.stateNode.containerInfo),ks(n,Rt,e.memoizedState.cache),Za();break;case 27:case 5:et(n);break;case 4:Re(n,n.stateNode.containerInfo);break;case 10:ks(n,n.type,n.memoizedProps.value);break;case 13:var c=n.memoizedState;if(c!==null)return c.dehydrated!==null?(As(n),n.flags|=128,null):(r&n.child.childLanes)!==0?Vp(e,n,r):(As(n),e=os(e,n,r),e!==null?e.sibling:null);As(n);break;case 19:var f=(e.flags&128)!==0;if(c=(r&n.childLanes)!==0,c||(er(e,n,r,!1),c=(r&n.childLanes)!==0),f){if(c)return Fp(e,n,r);n.flags|=128}if(f=n.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Z(_t,_t.current),c)break;return null;case 22:case 23:return n.lanes=0,Up(e,n,r);case 24:ks(n,Rt,e.memoizedState.cache)}return os(e,n,r)}function Xp(e,n,r){if(e!==null)if(e.memoizedProps!==n.pendingProps)qt=!0;else{if(!Gu(e,r)&&(n.flags&128)===0)return qt=!1,Rw(e,n,r);qt=(e.flags&131072)!==0}else qt=!1,nt&&(n.flags&1048576)!==0&&Sm(n,Mo,n.index);switch(n.lanes=0,n.tag){case 16:e:{e=n.pendingProps;var c=n.elementType,f=c._init;if(c=f(c._payload),n.type=c,typeof c=="function")Zc(c)?(e=xi(c,e),n.tag=1,n=Gp(null,n,c,e,r)):(n.tag=0,n=Du(null,n,c,e,r));else{if(c!=null){if(f=c.$$typeof,f===O){n.tag=11,n=qp(null,n,c,e,r);break e}else if(f===W){n.tag=14,n=Bp(null,n,c,e,r);break e}}throw n=se(c)||c,Error(a(306,n,""))}}return n;case 0:return Du(e,n,n.type,n.pendingProps,r);case 1:return c=n.type,f=xi(c,n.pendingProps),Gp(e,n,c,f,r);case 3:e:{if(Re(n,n.stateNode.containerInfo),e===null)throw Error(a(387));c=n.pendingProps;var g=n.memoizedState;f=g.element,fu(e,n),or(n,c,null,r);var b=n.memoizedState;if(c=b.cache,ks(n,Rt,c),c!==g.cache&&ru(n,[Rt],r,!0),rr(),c=b.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:b.cache},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){n=Yp(e,n,c,r);break e}else if(c!==f){f=jn(Error(a(424)),n),Ja(f),n=Yp(e,n,c,r);break e}else for(e=n.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,vt=Dn(e.firstChild),Qt=n,nt=!0,di=null,In=!0,r=Tp(n,null,c,r),n.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(Za(),c===f){n=os(e,n,r);break e}Ht(e,n,c,r)}n=n.child}return n;case 26:return Qo(e,n),e===null?(r=Zg(n.type,null,n.pendingProps,null))?n.memoizedState=r:nt||(r=n.type,e=n.pendingProps,c=dl(le.current).createElement(r),c[Ft]=n,c[Jt]=e,Gt(c,r,e),Dt(c),n.stateNode=c):n.memoizedState=Zg(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return et(n),e===null&&nt&&(c=n.stateNode=Pg(n.type,n.pendingProps,le.current),Qt=n,In=!0,f=vt,qs(n.type)?(jd=f,vt=Dn(c.firstChild)):vt=f),Ht(e,n,n.pendingProps.children,r),Qo(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&nt&&((f=c=vt)&&(c=rk(c,n.type,n.pendingProps,In),c!==null?(n.stateNode=c,Qt=n,vt=Dn(c.firstChild),In=!1,f=!0):f=!1),f||fi(n)),et(n),f=n.type,g=n.pendingProps,b=e!==null?e.memoizedProps:null,c=g.children,bd(f,g)?c=null:b!==null&&bd(f,b)&&(n.flags|=32),n.memoizedState!==null&&(f=yu(e,n,Sw,null,null,r),Er._currentValue=f),Qo(e,n),Ht(e,n,c,r),n.child;case 6:return e===null&&nt&&((e=r=vt)&&(r=ok(r,n.pendingProps,In),r!==null?(n.stateNode=r,Qt=n,vt=null,e=!0):e=!1),e||fi(n)),null;case 13:return Vp(e,n,r);case 4:return Re(n,n.stateNode.containerInfo),c=n.pendingProps,e===null?n.child=fa(n,null,c,r):Ht(e,n,c,r),n.child;case 11:return qp(e,n,n.type,n.pendingProps,r);case 7:return Ht(e,n,n.pendingProps,r),n.child;case 8:return Ht(e,n,n.pendingProps.children,r),n.child;case 12:return Ht(e,n,n.pendingProps.children,r),n.child;case 10:return c=n.pendingProps,ks(n,n.type,c.value),Ht(e,n,c.children,r),n.child;case 9:return f=n.type._context,c=n.pendingProps.children,mi(n),f=Xt(f),c=c(f),n.flags|=1,Ht(e,n,c,r),n.child;case 14:return Bp(e,n,n.type,n.pendingProps,r);case 15:return $p(e,n,n.type,n.pendingProps,r);case 19:return Fp(e,n,r);case 31:return c=n.pendingProps,r=n.mode,c={mode:c.mode,children:c.children},e===null?(r=Wo(c,r),r.ref=n.ref,n.child=r,r.return=n,n=r):(r=es(e.child,c),r.ref=n.ref,n.child=r,r.return=n,n=r),n;case 22:return Up(e,n,r);case 24:return mi(n),c=Xt(Rt),e===null?(f=cu(),f===null&&(f=mt,g=ou(),f.pooledCache=g,g.refCount++,g!==null&&(f.pooledCacheLanes|=r),f=g),n.memoizedState={parent:c,cache:f},du(n),ks(n,Rt,f)):((e.lanes&r)!==0&&(fu(e,n),or(n,null,null,r),rr()),f=e.memoizedState,g=n.memoizedState,f.parent!==c?(f={parent:c,cache:c},n.memoizedState=f,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=f),ks(n,Rt,c)):(c=g.cache,ks(n,Rt,c),c!==f.cache&&ru(n,[Rt],r,!0))),Ht(e,n,n.pendingProps.children,r),n.child;case 29:throw n.pendingProps}throw Error(a(156,n.tag))}function ls(e){e.flags|=4}function Pp(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!sx(n)){if(n=An.current,n!==null&&((Je&4194048)===Je?Gn!==null:(Je&62914560)!==Je&&(Je&536870912)===0||n!==Gn))throw ir=uu,Rm;e.flags|=8192}}function Zo(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?ue():536870912,e.lanes|=n,ga|=n)}function mr(e,n){if(!nt)switch(e.tailMode){case"hidden":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e.tail=null:r.sibling=null;break;case"collapsed":r=e.tail;for(var c=null;r!==null;)r.alternate!==null&&(c=r),r=r.sibling;c===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:c.sibling=null}}function yt(e){var n=e.alternate!==null&&e.alternate.child===e.child,r=0,c=0;if(n)for(var f=e.child;f!==null;)r|=f.lanes|f.childLanes,c|=f.subtreeFlags&65011712,c|=f.flags&65011712,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)r|=f.lanes|f.childLanes,c|=f.subtreeFlags,c|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=c,e.childLanes=r,n}function _w(e,n,r){var c=n.pendingProps;switch(nu(n),n.tag){case 31:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return yt(n),null;case 1:return yt(n),null;case 3:return r=n.stateNode,c=null,e!==null&&(c=e.memoizedState.cache),n.memoizedState.cache!==c&&(n.flags|=2048),is(Rt),Ne(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Wa(n)?ls(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Am())),yt(n),null;case 26:return r=n.memoizedState,e===null?(ls(n),r!==null?(yt(n),Pp(n,r)):(yt(n),n.flags&=-16777217)):r?r!==e.memoizedState?(ls(n),yt(n),Pp(n,r)):(yt(n),n.flags&=-16777217):(e.memoizedProps!==c&&ls(n),yt(n),n.flags&=-16777217),null;case 27:Ue(n),r=le.current;var f=n.type;if(e!==null&&n.stateNode!=null)e.memoizedProps!==c&&ls(n);else{if(!c){if(n.stateNode===null)throw Error(a(166));return yt(n),null}e=ie.current,Wa(n)?Nm(n):(e=Pg(f,c,r),n.stateNode=e,ls(n))}return yt(n),null;case 5:if(Ue(n),r=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==c&&ls(n);else{if(!c){if(n.stateNode===null)throw Error(a(166));return yt(n),null}if(e=ie.current,Wa(n))Nm(n);else{switch(f=dl(le.current),e){case 1:e=f.createElementNS("http://www.w3.org/2000/svg",r);break;case 2:e=f.createElementNS("http://www.w3.org/1998/Math/MathML",r);break;default:switch(r){case"svg":e=f.createElementNS("http://www.w3.org/2000/svg",r);break;case"math":e=f.createElementNS("http://www.w3.org/1998/Math/MathML",r);break;case"script":e=f.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild);break;case"select":e=typeof c.is=="string"?f.createElement("select",{is:c.is}):f.createElement("select"),c.multiple?e.multiple=!0:c.size&&(e.size=c.size);break;default:e=typeof c.is=="string"?f.createElement(r,{is:c.is}):f.createElement(r)}}e[Ft]=n,e[Jt]=c;e:for(f=n.child;f!==null;){if(f.tag===5||f.tag===6)e.appendChild(f.stateNode);else if(f.tag!==4&&f.tag!==27&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===n)break e;for(;f.sibling===null;){if(f.return===null||f.return===n)break e;f=f.return}f.sibling.return=f.return,f=f.sibling}n.stateNode=e;e:switch(Gt(e,r,c),r){case"button":case"input":case"select":case"textarea":e=!!c.autoFocus;break e;case"img":e=!0;break e;default:e=!1}e&&ls(n)}}return yt(n),n.flags&=-16777217,null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==c&&ls(n);else{if(typeof c!="string"&&n.stateNode===null)throw Error(a(166));if(e=le.current,Wa(n)){if(e=n.stateNode,r=n.memoizedProps,c=null,f=Qt,f!==null)switch(f.tag){case 27:case 5:c=f.memoizedProps}e[Ft]=n,e=!!(e.nodeValue===r||c!==null&&c.suppressHydrationWarning===!0||Ig(e.nodeValue,r)),e||fi(n)}else e=dl(e).createTextNode(c),e[Ft]=n,n.stateNode=e}return yt(n),null;case 13:if(c=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=Wa(n),c!==null&&c.dehydrated!==null){if(e===null){if(!f)throw Error(a(318));if(f=n.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(a(317));f[Ft]=n}else Za(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;yt(n),f=!1}else f=Am(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return n.flags&256?(rs(n),n):(rs(n),null)}if(rs(n),(n.flags&128)!==0)return n.lanes=r,n;if(r=c!==null,e=e!==null&&e.memoizedState!==null,r){c=n.child,f=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(f=c.alternate.memoizedState.cachePool.pool);var g=null;c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(g=c.memoizedState.cachePool.pool),g!==f&&(c.flags|=2048)}return r!==e&&r&&(n.child.flags|=8192),Zo(n,n.updateQueue),yt(n),null;case 4:return Ne(),e===null&&md(n.stateNode.containerInfo),yt(n),null;case 10:return is(n.type),yt(n),null;case 19:if(F(_t),f=n.memoizedState,f===null)return yt(n),null;if(c=(n.flags&128)!==0,g=f.rendering,g===null)if(c)mr(f,!1);else{if(wt!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(g=Fo(e),g!==null){for(n.flags|=128,mr(f,!1),e=g.updateQueue,n.updateQueue=e,Zo(n,e),n.subtreeFlags=0,e=r,r=n.child;r!==null;)jm(r,e),r=r.sibling;return Z(_t,_t.current&1|2),n.child}e=e.sibling}f.tail!==null&&je()>tl&&(n.flags|=128,c=!0,mr(f,!1),n.lanes=4194304)}else{if(!c)if(e=Fo(g),e!==null){if(n.flags|=128,c=!0,e=e.updateQueue,n.updateQueue=e,Zo(n,e),mr(f,!0),f.tail===null&&f.tailMode==="hidden"&&!g.alternate&&!nt)return yt(n),null}else 2*je()-f.renderingStartTime>tl&&r!==536870912&&(n.flags|=128,c=!0,mr(f,!1),n.lanes=4194304);f.isBackwards?(g.sibling=n.child,n.child=g):(e=f.last,e!==null?e.sibling=g:n.child=g,f.last=g)}return f.tail!==null?(n=f.tail,f.rendering=n,f.tail=n.sibling,f.renderingStartTime=je(),n.sibling=null,e=_t.current,Z(_t,c?e&1|2:e&1),n):(yt(n),null);case 22:case 23:return rs(n),gu(),c=n.memoizedState!==null,e!==null?e.memoizedState!==null!==c&&(n.flags|=8192):c&&(n.flags|=8192),c?(r&536870912)!==0&&(n.flags&128)===0&&(yt(n),n.subtreeFlags&6&&(n.flags|=8192)):yt(n),r=n.updateQueue,r!==null&&Zo(n,r.retryQueue),r=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(r=e.memoizedState.cachePool.pool),c=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(c=n.memoizedState.cachePool.pool),c!==r&&(n.flags|=2048),e!==null&&F(pi),null;case 24:return r=null,e!==null&&(r=e.memoizedState.cache),n.memoizedState.cache!==r&&(n.flags|=2048),is(Rt),yt(n),null;case 25:return null;case 30:return null}throw Error(a(156,n.tag))}function Lw(e,n){switch(nu(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return is(Rt),Ne(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return Ue(n),null;case 13:if(rs(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(a(340));Za()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return F(_t),null;case 4:return Ne(),null;case 10:return is(n.type),null;case 22:case 23:return rs(n),gu(),e!==null&&F(pi),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return is(Rt),null;case 25:return null;default:return null}}function Qp(e,n){switch(nu(n),n.tag){case 3:is(Rt),Ne();break;case 26:case 27:case 5:Ue(n);break;case 4:Ne();break;case 13:rs(n);break;case 19:F(_t);break;case 10:is(n.type);break;case 22:case 23:rs(n),gu(),e!==null&&F(pi);break;case 24:is(Rt)}}function pr(e,n){try{var r=n.updateQueue,c=r!==null?r.lastEffect:null;if(c!==null){var f=c.next;r=f;do{if((r.tag&e)===e){c=void 0;var g=r.create,b=r.inst;c=g(),b.destroy=c}r=r.next}while(r!==f)}}catch(N){ft(n,n.return,N)}}function Es(e,n,r){try{var c=n.updateQueue,f=c!==null?c.lastEffect:null;if(f!==null){var g=f.next;c=g;do{if((c.tag&e)===e){var b=c.inst,N=b.destroy;if(N!==void 0){b.destroy=void 0,f=n;var M=r,K=N;try{K()}catch(ee){ft(f,M,ee)}}}c=c.next}while(c!==g)}}catch(ee){ft(n,n.return,ee)}}function Wp(e){var n=e.updateQueue;if(n!==null){var r=e.stateNode;try{Bm(n,r)}catch(c){ft(e,e.return,c)}}}function Zp(e,n,r){r.props=xi(e.type,e.memoizedProps),r.state=e.memoizedState;try{r.componentWillUnmount()}catch(c){ft(e,n,c)}}function gr(e,n){try{var r=e.ref;if(r!==null){switch(e.tag){case 26:case 27:case 5:var c=e.stateNode;break;case 30:c=e.stateNode;break;default:c=e.stateNode}typeof r=="function"?e.refCleanup=r(c):r.current=c}}catch(f){ft(e,n,f)}}function Yn(e,n){var r=e.ref,c=e.refCleanup;if(r!==null)if(typeof c=="function")try{c()}catch(f){ft(e,n,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof r=="function")try{r(null)}catch(f){ft(e,n,f)}else r.current=null}function Jp(e){var n=e.type,r=e.memoizedProps,c=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":r.autoFocus&&c.focus();break e;case"img":r.src?c.src=r.src:r.srcSet&&(c.srcset=r.srcSet)}}catch(f){ft(e,e.return,f)}}function Yu(e,n,r){try{var c=e.stateNode;tk(c,e.type,r,n),c[Jt]=n}catch(f){ft(e,e.return,f)}}function eg(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&qs(e.type)||e.tag===4}function Vu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||eg(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&qs(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ku(e,n,r){var c=e.tag;if(c===5||c===6)e=e.stateNode,n?(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r).insertBefore(e,n):(n=r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,n.appendChild(e),r=r._reactRootContainer,r!=null||n.onclick!==null||(n.onclick=ul));else if(c!==4&&(c===27&&qs(e.type)&&(r=e.stateNode,n=null),e=e.child,e!==null))for(Ku(e,n,r),e=e.sibling;e!==null;)Ku(e,n,r),e=e.sibling}function Jo(e,n,r){var c=e.tag;if(c===5||c===6)e=e.stateNode,n?r.insertBefore(e,n):r.appendChild(e);else if(c!==4&&(c===27&&qs(e.type)&&(r=e.stateNode),e=e.child,e!==null))for(Jo(e,n,r),e=e.sibling;e!==null;)Jo(e,n,r),e=e.sibling}function tg(e){var n=e.stateNode,r=e.memoizedProps;try{for(var c=e.type,f=n.attributes;f.length;)n.removeAttributeNode(f[0]);Gt(n,c,r),n[Ft]=e,n[Jt]=r}catch(g){ft(e,e.return,g)}}var cs=!1,Tt=!1,Fu=!1,ng=typeof WeakSet=="function"?WeakSet:Set,Bt=null;function Ow(e,n){if(e=e.containerInfo,xd=xl,e=hm(e),Vc(e)){if("selectionStart"in e)var r={start:e.selectionStart,end:e.selectionEnd};else e:{r=(r=e.ownerDocument)&&r.defaultView||window;var c=r.getSelection&&r.getSelection();if(c&&c.rangeCount!==0){r=c.anchorNode;var f=c.anchorOffset,g=c.focusNode;c=c.focusOffset;try{r.nodeType,g.nodeType}catch{r=null;break e}var b=0,N=-1,M=-1,K=0,ee=0,ae=e,X=null;t:for(;;){for(var Q;ae!==r||f!==0&&ae.nodeType!==3||(N=b+f),ae!==g||c!==0&&ae.nodeType!==3||(M=b+c),ae.nodeType===3&&(b+=ae.nodeValue.length),(Q=ae.firstChild)!==null;)X=ae,ae=Q;for(;;){if(ae===e)break t;if(X===r&&++K===f&&(N=b),X===g&&++ee===c&&(M=b),(Q=ae.nextSibling)!==null)break;ae=X,X=ae.parentNode}ae=Q}r=N===-1||M===-1?null:{start:N,end:M}}else r=null}r=r||{start:0,end:0}}else r=null;for(yd={focusedElem:e,selectionRange:r},xl=!1,Bt=n;Bt!==null;)if(n=Bt,e=n.child,(n.subtreeFlags&1024)!==0&&e!==null)e.return=n,Bt=e;else for(;Bt!==null;){switch(n=Bt,g=n.alternate,e=n.flags,n.tag){case 0:break;case 11:case 15:break;case 1:if((e&1024)!==0&&g!==null){e=void 0,r=n,f=g.memoizedProps,g=g.memoizedState,c=r.stateNode;try{var De=xi(r.type,f,r.elementType===r.type);e=c.getSnapshotBeforeUpdate(De,g),c.__reactInternalSnapshotBeforeUpdate=e}catch(_e){ft(r,r.return,_e)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,r=e.nodeType,r===9)wd(e);else if(r===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":wd(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(a(163))}if(e=n.sibling,e!==null){e.return=n.return,Bt=e;break}Bt=n.return}}function sg(e,n,r){var c=r.flags;switch(r.tag){case 0:case 11:case 15:Ms(e,r),c&4&&pr(5,r);break;case 1:if(Ms(e,r),c&4)if(e=r.stateNode,n===null)try{e.componentDidMount()}catch(b){ft(r,r.return,b)}else{var f=xi(r.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(f,n,e.__reactInternalSnapshotBeforeUpdate)}catch(b){ft(r,r.return,b)}}c&64&&Wp(r),c&512&&gr(r,r.return);break;case 3:if(Ms(e,r),c&64&&(e=r.updateQueue,e!==null)){if(n=null,r.child!==null)switch(r.child.tag){case 27:case 5:n=r.child.stateNode;break;case 1:n=r.child.stateNode}try{Bm(e,n)}catch(b){ft(r,r.return,b)}}break;case 27:n===null&&c&4&&tg(r);case 26:case 5:Ms(e,r),n===null&&c&4&&Jp(r),c&512&&gr(r,r.return);break;case 12:Ms(e,r);break;case 13:Ms(e,r),c&4&&rg(e,r),c&64&&(e=r.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(r=Yw.bind(null,r),lk(e,r))));break;case 22:if(c=r.memoizedState!==null||cs,!c){n=n!==null&&n.memoizedState!==null||Tt,f=cs;var g=Tt;cs=c,(Tt=n)&&!g?zs(e,r,(r.subtreeFlags&8772)!==0):Ms(e,r),cs=f,Tt=g}break;case 30:break;default:Ms(e,r)}}function ig(e){var n=e.alternate;n!==null&&(e.alternate=null,ig(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&Tc(n)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var pt=null,nn=!1;function us(e,n,r){for(r=r.child;r!==null;)ag(e,n,r),r=r.sibling}function ag(e,n,r){if(xt&&typeof xt.onCommitFiberUnmount=="function")try{xt.onCommitFiberUnmount(cn,r)}catch{}switch(r.tag){case 26:Tt||Yn(r,n),us(e,n,r),r.memoizedState?r.memoizedState.count--:r.stateNode&&(r=r.stateNode,r.parentNode.removeChild(r));break;case 27:Tt||Yn(r,n);var c=pt,f=nn;qs(r.type)&&(pt=r.stateNode,nn=!1),us(e,n,r),Nr(r.stateNode),pt=c,nn=f;break;case 5:Tt||Yn(r,n);case 6:if(c=pt,f=nn,pt=null,us(e,n,r),pt=c,nn=f,pt!==null)if(nn)try{(pt.nodeType===9?pt.body:pt.nodeName==="HTML"?pt.ownerDocument.body:pt).removeChild(r.stateNode)}catch(g){ft(r,n,g)}else try{pt.removeChild(r.stateNode)}catch(g){ft(r,n,g)}break;case 18:pt!==null&&(nn?(e=pt,Fg(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,r.stateNode),_r(e)):Fg(pt,r.stateNode));break;case 4:c=pt,f=nn,pt=r.stateNode.containerInfo,nn=!0,us(e,n,r),pt=c,nn=f;break;case 0:case 11:case 14:case 15:Tt||Es(2,r,n),Tt||Es(4,r,n),us(e,n,r);break;case 1:Tt||(Yn(r,n),c=r.stateNode,typeof c.componentWillUnmount=="function"&&Zp(r,n,c)),us(e,n,r);break;case 21:us(e,n,r);break;case 22:Tt=(c=Tt)||r.memoizedState!==null,us(e,n,r),Tt=c;break;default:us(e,n,r)}}function rg(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{_r(e)}catch(r){ft(n,n.return,r)}}function Dw(e){switch(e.tag){case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new ng),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new ng),n;default:throw Error(a(435,e.tag))}}function Xu(e,n){var r=Dw(e);n.forEach(function(c){var f=Vw.bind(null,e,c);r.has(c)||(r.add(c),c.then(f,f))})}function hn(e,n){var r=n.deletions;if(r!==null)for(var c=0;c<r.length;c++){var f=r[c],g=e,b=n,N=b;e:for(;N!==null;){switch(N.tag){case 27:if(qs(N.type)){pt=N.stateNode,nn=!1;break e}break;case 5:pt=N.stateNode,nn=!1;break e;case 3:case 4:pt=N.stateNode.containerInfo,nn=!0;break e}N=N.return}if(pt===null)throw Error(a(160));ag(g,b,f),pt=null,nn=!1,g=f.alternate,g!==null&&(g.return=null),f.return=null}if(n.subtreeFlags&13878)for(n=n.child;n!==null;)og(n,e),n=n.sibling}var On=null;function og(e,n){var r=e.alternate,c=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:hn(n,e),mn(e),c&4&&(Es(3,e,e.return),pr(3,e),Es(5,e,e.return));break;case 1:hn(n,e),mn(e),c&512&&(Tt||r===null||Yn(r,r.return)),c&64&&cs&&(e=e.updateQueue,e!==null&&(c=e.callbacks,c!==null&&(r=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=r===null?c:r.concat(c))));break;case 26:var f=On;if(hn(n,e),mn(e),c&512&&(Tt||r===null||Yn(r,r.return)),c&4){var g=r!==null?r.memoizedState:null;if(c=e.memoizedState,r===null)if(c===null)if(e.stateNode===null){e:{c=e.type,r=e.memoizedProps,f=f.ownerDocument||f;t:switch(c){case"title":g=f.getElementsByTagName("title")[0],(!g||g[Ua]||g[Ft]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=f.createElement(c),f.head.insertBefore(g,f.querySelector("head > title"))),Gt(g,c,r),g[Ft]=e,Dt(g),c=g;break e;case"link":var b=tx("link","href",f).get(c+(r.href||""));if(b){for(var N=0;N<b.length;N++)if(g=b[N],g.getAttribute("href")===(r.href==null||r.href===""?null:r.href)&&g.getAttribute("rel")===(r.rel==null?null:r.rel)&&g.getAttribute("title")===(r.title==null?null:r.title)&&g.getAttribute("crossorigin")===(r.crossOrigin==null?null:r.crossOrigin)){b.splice(N,1);break t}}g=f.createElement(c),Gt(g,c,r),f.head.appendChild(g);break;case"meta":if(b=tx("meta","content",f).get(c+(r.content||""))){for(N=0;N<b.length;N++)if(g=b[N],g.getAttribute("content")===(r.content==null?null:""+r.content)&&g.getAttribute("name")===(r.name==null?null:r.name)&&g.getAttribute("property")===(r.property==null?null:r.property)&&g.getAttribute("http-equiv")===(r.httpEquiv==null?null:r.httpEquiv)&&g.getAttribute("charset")===(r.charSet==null?null:r.charSet)){b.splice(N,1);break t}}g=f.createElement(c),Gt(g,c,r),f.head.appendChild(g);break;default:throw Error(a(468,c))}g[Ft]=e,Dt(g),c=g}e.stateNode=c}else nx(f,e.type,e.stateNode);else e.stateNode=ex(f,c,e.memoizedProps);else g!==c?(g===null?r.stateNode!==null&&(r=r.stateNode,r.parentNode.removeChild(r)):g.count--,c===null?nx(f,e.type,e.stateNode):ex(f,c,e.memoizedProps)):c===null&&e.stateNode!==null&&Yu(e,e.memoizedProps,r.memoizedProps)}break;case 27:hn(n,e),mn(e),c&512&&(Tt||r===null||Yn(r,r.return)),r!==null&&c&4&&Yu(e,e.memoizedProps,r.memoizedProps);break;case 5:if(hn(n,e),mn(e),c&512&&(Tt||r===null||Yn(r,r.return)),e.flags&32){f=e.stateNode;try{Xi(f,"")}catch(Q){ft(e,e.return,Q)}}c&4&&e.stateNode!=null&&(f=e.memoizedProps,Yu(e,f,r!==null?r.memoizedProps:f)),c&1024&&(Fu=!0);break;case 6:if(hn(n,e),mn(e),c&4){if(e.stateNode===null)throw Error(a(162));c=e.memoizedProps,r=e.stateNode;try{r.nodeValue=c}catch(Q){ft(e,e.return,Q)}}break;case 3:if(ml=null,f=On,On=fl(n.containerInfo),hn(n,e),On=f,mn(e),c&4&&r!==null&&r.memoizedState.isDehydrated)try{_r(n.containerInfo)}catch(Q){ft(e,e.return,Q)}Fu&&(Fu=!1,lg(e));break;case 4:c=On,On=fl(e.stateNode.containerInfo),hn(n,e),mn(e),On=c;break;case 12:hn(n,e),mn(e);break;case 13:hn(n,e),mn(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(ed=je()),c&4&&(c=e.updateQueue,c!==null&&(e.updateQueue=null,Xu(e,c)));break;case 22:f=e.memoizedState!==null;var M=r!==null&&r.memoizedState!==null,K=cs,ee=Tt;if(cs=K||f,Tt=ee||M,hn(n,e),Tt=ee,cs=K,mn(e),c&8192)e:for(n=e.stateNode,n._visibility=f?n._visibility&-2:n._visibility|1,f&&(r===null||M||cs||Tt||yi(e)),r=null,n=e;;){if(n.tag===5||n.tag===26){if(r===null){M=r=n;try{if(g=M.stateNode,f)b=g.style,typeof b.setProperty=="function"?b.setProperty("display","none","important"):b.display="none";else{N=M.stateNode;var ae=M.memoizedProps.style,X=ae!=null&&ae.hasOwnProperty("display")?ae.display:null;N.style.display=X==null||typeof X=="boolean"?"":(""+X).trim()}}catch(Q){ft(M,M.return,Q)}}}else if(n.tag===6){if(r===null){M=n;try{M.stateNode.nodeValue=f?"":M.memoizedProps}catch(Q){ft(M,M.return,Q)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===e)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;r===n&&(r=null),n=n.return}r===n&&(r=null),n.sibling.return=n.return,n=n.sibling}c&4&&(c=e.updateQueue,c!==null&&(r=c.retryQueue,r!==null&&(c.retryQueue=null,Xu(e,r))));break;case 19:hn(n,e),mn(e),c&4&&(c=e.updateQueue,c!==null&&(e.updateQueue=null,Xu(e,c)));break;case 30:break;case 21:break;default:hn(n,e),mn(e)}}function mn(e){var n=e.flags;if(n&2){try{for(var r,c=e.return;c!==null;){if(eg(c)){r=c;break}c=c.return}if(r==null)throw Error(a(160));switch(r.tag){case 27:var f=r.stateNode,g=Vu(e);Jo(e,g,f);break;case 5:var b=r.stateNode;r.flags&32&&(Xi(b,""),r.flags&=-33);var N=Vu(e);Jo(e,N,b);break;case 3:case 4:var M=r.stateNode.containerInfo,K=Vu(e);Ku(e,K,M);break;default:throw Error(a(161))}}catch(ee){ft(e,e.return,ee)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function lg(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;lg(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function Ms(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)sg(e,n.alternate,n),n=n.sibling}function yi(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Es(4,n,n.return),yi(n);break;case 1:Yn(n,n.return);var r=n.stateNode;typeof r.componentWillUnmount=="function"&&Zp(n,n.return,r),yi(n);break;case 27:Nr(n.stateNode);case 26:case 5:Yn(n,n.return),yi(n);break;case 22:n.memoizedState===null&&yi(n);break;case 30:yi(n);break;default:yi(n)}e=e.sibling}}function zs(e,n,r){for(r=r&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var c=n.alternate,f=e,g=n,b=g.flags;switch(g.tag){case 0:case 11:case 15:zs(f,g,r),pr(4,g);break;case 1:if(zs(f,g,r),c=g,f=c.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(K){ft(c,c.return,K)}if(c=g,f=c.updateQueue,f!==null){var N=c.stateNode;try{var M=f.shared.hiddenCallbacks;if(M!==null)for(f.shared.hiddenCallbacks=null,f=0;f<M.length;f++)qm(M[f],N)}catch(K){ft(c,c.return,K)}}r&&b&64&&Wp(g),gr(g,g.return);break;case 27:tg(g);case 26:case 5:zs(f,g,r),r&&c===null&&b&4&&Jp(g),gr(g,g.return);break;case 12:zs(f,g,r);break;case 13:zs(f,g,r),r&&b&4&&rg(f,g);break;case 22:g.memoizedState===null&&zs(f,g,r),gr(g,g.return);break;case 30:break;default:zs(f,g,r)}n=n.sibling}}function Pu(e,n){var r=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(r=e.memoizedState.cachePool.pool),e=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(e=n.memoizedState.cachePool.pool),e!==r&&(e!=null&&e.refCount++,r!=null&&tr(r))}function Qu(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&tr(e))}function Vn(e,n,r,c){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)cg(e,n,r,c),n=n.sibling}function cg(e,n,r,c){var f=n.flags;switch(n.tag){case 0:case 11:case 15:Vn(e,n,r,c),f&2048&&pr(9,n);break;case 1:Vn(e,n,r,c);break;case 3:Vn(e,n,r,c),f&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&tr(e)));break;case 12:if(f&2048){Vn(e,n,r,c),e=n.stateNode;try{var g=n.memoizedProps,b=g.id,N=g.onPostCommit;typeof N=="function"&&N(b,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(M){ft(n,n.return,M)}}else Vn(e,n,r,c);break;case 13:Vn(e,n,r,c);break;case 23:break;case 22:g=n.stateNode,b=n.alternate,n.memoizedState!==null?g._visibility&2?Vn(e,n,r,c):xr(e,n):g._visibility&2?Vn(e,n,r,c):(g._visibility|=2,ha(e,n,r,c,(n.subtreeFlags&10256)!==0)),f&2048&&Pu(b,n);break;case 24:Vn(e,n,r,c),f&2048&&Qu(n.alternate,n);break;default:Vn(e,n,r,c)}}function ha(e,n,r,c,f){for(f=f&&(n.subtreeFlags&10256)!==0,n=n.child;n!==null;){var g=e,b=n,N=r,M=c,K=b.flags;switch(b.tag){case 0:case 11:case 15:ha(g,b,N,M,f),pr(8,b);break;case 23:break;case 22:var ee=b.stateNode;b.memoizedState!==null?ee._visibility&2?ha(g,b,N,M,f):xr(g,b):(ee._visibility|=2,ha(g,b,N,M,f)),f&&K&2048&&Pu(b.alternate,b);break;case 24:ha(g,b,N,M,f),f&&K&2048&&Qu(b.alternate,b);break;default:ha(g,b,N,M,f)}n=n.sibling}}function xr(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var r=e,c=n,f=c.flags;switch(c.tag){case 22:xr(r,c),f&2048&&Pu(c.alternate,c);break;case 24:xr(r,c),f&2048&&Qu(c.alternate,c);break;default:xr(r,c)}n=n.sibling}}var yr=8192;function ma(e){if(e.subtreeFlags&yr)for(e=e.child;e!==null;)ug(e),e=e.sibling}function ug(e){switch(e.tag){case 26:ma(e),e.flags&yr&&e.memoizedState!==null&&wk(On,e.memoizedState,e.memoizedProps);break;case 5:ma(e);break;case 3:case 4:var n=On;On=fl(e.stateNode.containerInfo),ma(e),On=n;break;case 22:e.memoizedState===null&&(n=e.alternate,n!==null&&n.memoizedState!==null?(n=yr,yr=16777216,ma(e),yr=n):ma(e));break;default:ma(e)}}function dg(e){var n=e.alternate;if(n!==null&&(e=n.child,e!==null)){n.child=null;do n=e.sibling,e.sibling=null,e=n;while(e!==null)}}function br(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var r=0;r<n.length;r++){var c=n[r];Bt=c,hg(c,e)}dg(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)fg(e),e=e.sibling}function fg(e){switch(e.tag){case 0:case 11:case 15:br(e),e.flags&2048&&Es(9,e,e.return);break;case 3:br(e);break;case 12:br(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,el(e)):br(e);break;default:br(e)}}function el(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var r=0;r<n.length;r++){var c=n[r];Bt=c,hg(c,e)}dg(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Es(8,n,n.return),el(n);break;case 22:r=n.stateNode,r._visibility&2&&(r._visibility&=-3,el(n));break;default:el(n)}e=e.sibling}}function hg(e,n){for(;Bt!==null;){var r=Bt;switch(r.tag){case 0:case 11:case 15:Es(8,r,n);break;case 23:case 22:if(r.memoizedState!==null&&r.memoizedState.cachePool!==null){var c=r.memoizedState.cachePool.pool;c!=null&&c.refCount++}break;case 24:tr(r.memoizedState.cache)}if(c=r.child,c!==null)c.return=r,Bt=c;else e:for(r=e;Bt!==null;){c=Bt;var f=c.sibling,g=c.return;if(ig(c),c===r){Bt=null;break e}if(f!==null){f.return=g,Bt=f;break e}Bt=g}}}var qw={getCacheForType:function(e){var n=Xt(Rt),r=n.data.get(e);return r===void 0&&(r=e(),n.data.set(e,r)),r}},Bw=typeof WeakMap=="function"?WeakMap:Map,at=0,mt=null,Fe=null,Je=0,rt=0,pn=null,Rs=!1,pa=!1,Wu=!1,ds=0,wt=0,_s=0,bi=0,Zu=0,Cn=0,ga=0,vr=null,sn=null,Ju=!1,ed=0,tl=1/0,nl=null,Ls=null,It=0,Os=null,xa=null,ya=0,td=0,nd=null,mg=null,wr=0,sd=null;function gn(){if((at&2)!==0&&Je!==0)return Je&-Je;if(H.T!==null){var e=aa;return e!==0?e:ud()}return si()}function pg(){Cn===0&&(Cn=(Je&536870912)===0||nt?ce():536870912);var e=An.current;return e!==null&&(e.flags|=32),Cn}function xn(e,n,r){(e===mt&&(rt===2||rt===9)||e.cancelPendingCommit!==null)&&(ba(e,0),Ds(e,Je,Cn,!1)),He(e,r),((at&2)===0||e!==mt)&&(e===mt&&((at&2)===0&&(bi|=r),wt===4&&Ds(e,Je,Cn,!1)),Kn(e))}function gg(e,n,r){if((at&6)!==0)throw Error(a(327));var c=!r&&(n&124)===0&&(n&e.expiredLanes)===0||C(e,n),f=c?Hw(e,n):rd(e,n,!0),g=c;do{if(f===0){pa&&!c&&Ds(e,n,0,!1);break}else{if(r=e.current.alternate,g&&!$w(r)){f=rd(e,n,!1),g=!1;continue}if(f===2){if(g=n,e.errorRecoveryDisabledLanes&g)var b=0;else b=e.pendingLanes&-536870913,b=b!==0?b:b&536870912?536870912:0;if(b!==0){n=b;e:{var N=e;f=vr;var M=N.current.memoizedState.isDehydrated;if(M&&(ba(N,b).flags|=256),b=rd(N,b,!1),b!==2){if(Wu&&!M){N.errorRecoveryDisabledLanes|=g,bi|=g,f=4;break e}g=sn,sn=f,g!==null&&(sn===null?sn=g:sn.push.apply(sn,g))}f=b}if(g=!1,f!==2)continue}}if(f===1){ba(e,0),Ds(e,n,0,!0);break}e:{switch(c=e,g=f,g){case 0:case 1:throw Error(a(345));case 4:if((n&4194048)!==n)break;case 6:Ds(c,n,Cn,!Rs);break e;case 2:sn=null;break;case 3:case 5:break;default:throw Error(a(329))}if((n&62914560)===n&&(f=ed+300-je(),10<f)){if(Ds(c,n,Cn,!Rs),bt(c,0,!0)!==0)break e;c.timeoutHandle=Vg(xg.bind(null,c,r,sn,nl,Ju,n,Cn,bi,ga,Rs,g,2,-0,0),f);break e}xg(c,r,sn,nl,Ju,n,Cn,bi,ga,Rs,g,0,-0,0)}}break}while(!0);Kn(e)}function xg(e,n,r,c,f,g,b,N,M,K,ee,ae,X,Q){if(e.timeoutHandle=-1,ae=n.subtreeFlags,(ae&8192||(ae&16785408)===16785408)&&(Cr={stylesheets:null,count:0,unsuspend:vk},ug(n),ae=kk(),ae!==null)){e.cancelPendingCommit=ae(Sg.bind(null,e,n,g,r,c,f,b,N,M,ee,1,X,Q)),Ds(e,g,b,!K);return}Sg(e,n,g,r,c,f,b,N,M)}function $w(e){for(var n=e;;){var r=n.tag;if((r===0||r===11||r===15)&&n.flags&16384&&(r=n.updateQueue,r!==null&&(r=r.stores,r!==null)))for(var c=0;c<r.length;c++){var f=r[c],g=f.getSnapshot;f=f.value;try{if(!dn(g(),f))return!1}catch{return!1}}if(r=n.child,n.subtreeFlags&16384&&r!==null)r.return=n,n=r;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Ds(e,n,r,c){n&=~Zu,n&=~bi,e.suspendedLanes|=n,e.pingedLanes&=~n,c&&(e.warmLanes|=n),c=e.expirationTimes;for(var f=n;0<f;){var g=31-Ct(f),b=1<<g;c[g]=-1,f&=~b}r!==0&&St(e,r,n)}function sl(){return(at&6)===0?(kr(0),!1):!0}function id(){if(Fe!==null){if(rt===0)var e=Fe.return;else e=Fe,ss=hi=null,wu(e),da=null,fr=0,e=Fe;for(;e!==null;)Qp(e.alternate,e),e=e.return;Fe=null}}function ba(e,n){var r=e.timeoutHandle;r!==-1&&(e.timeoutHandle=-1,sk(r)),r=e.cancelPendingCommit,r!==null&&(e.cancelPendingCommit=null,r()),id(),mt=e,Fe=r=es(e.current,null),Je=n,rt=0,pn=null,Rs=!1,pa=C(e,n),Wu=!1,ga=Cn=Zu=bi=_s=wt=0,sn=vr=null,Ju=!1,(n&8)!==0&&(n|=n&32);var c=e.entangledLanes;if(c!==0)for(e=e.entanglements,c&=n;0<c;){var f=31-Ct(c),g=1<<f;n|=e[f],c&=~g}return ds=n,No(),r}function yg(e,n){Ge=null,H.H=Yo,n===sr||n===Lo?(n=Om(),rt=3):n===Rm?(n=Om(),rt=4):rt=n===Dp?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,pn=n,Fe===null&&(wt=1,Po(e,jn(n,e.current)))}function bg(){var e=H.H;return H.H=Yo,e===null?Yo:e}function vg(){var e=H.A;return H.A=qw,e}function ad(){wt=4,Rs||(Je&4194048)!==Je&&An.current!==null||(pa=!0),(_s&134217727)===0&&(bi&134217727)===0||mt===null||Ds(mt,Je,Cn,!1)}function rd(e,n,r){var c=at;at|=2;var f=bg(),g=vg();(mt!==e||Je!==n)&&(nl=null,ba(e,n)),n=!1;var b=wt;e:do try{if(rt!==0&&Fe!==null){var N=Fe,M=pn;switch(rt){case 8:id(),b=6;break e;case 3:case 2:case 9:case 6:An.current===null&&(n=!0);var K=rt;if(rt=0,pn=null,va(e,N,M,K),r&&pa){b=0;break e}break;default:K=rt,rt=0,pn=null,va(e,N,M,K)}}Uw(),b=wt;break}catch(ee){yg(e,ee)}while(!0);return n&&e.shellSuspendCounter++,ss=hi=null,at=c,H.H=f,H.A=g,Fe===null&&(mt=null,Je=0,No()),b}function Uw(){for(;Fe!==null;)wg(Fe)}function Hw(e,n){var r=at;at|=2;var c=bg(),f=vg();mt!==e||Je!==n?(nl=null,tl=je()+500,ba(e,n)):pa=C(e,n);e:do try{if(rt!==0&&Fe!==null){n=Fe;var g=pn;t:switch(rt){case 1:rt=0,pn=null,va(e,n,g,1);break;case 2:case 9:if(_m(g)){rt=0,pn=null,kg(n);break}n=function(){rt!==2&&rt!==9||mt!==e||(rt=7),Kn(e)},g.then(n,n);break e;case 3:rt=7;break e;case 4:rt=5;break e;case 7:_m(g)?(rt=0,pn=null,kg(n)):(rt=0,pn=null,va(e,n,g,7));break;case 5:var b=null;switch(Fe.tag){case 26:b=Fe.memoizedState;case 5:case 27:var N=Fe;if(!b||sx(b)){rt=0,pn=null;var M=N.sibling;if(M!==null)Fe=M;else{var K=N.return;K!==null?(Fe=K,il(K)):Fe=null}break t}}rt=0,pn=null,va(e,n,g,5);break;case 6:rt=0,pn=null,va(e,n,g,6);break;case 8:id(),wt=6;break e;default:throw Error(a(462))}}Iw();break}catch(ee){yg(e,ee)}while(!0);return ss=hi=null,H.H=c,H.A=f,at=r,Fe!==null?0:(mt=null,Je=0,No(),wt)}function Iw(){for(;Fe!==null&&!ge();)wg(Fe)}function wg(e){var n=Xp(e.alternate,e,ds);e.memoizedProps=e.pendingProps,n===null?il(e):Fe=n}function kg(e){var n=e,r=n.alternate;switch(n.tag){case 15:case 0:n=Ip(r,n,n.pendingProps,n.type,void 0,Je);break;case 11:n=Ip(r,n,n.pendingProps,n.type.render,n.ref,Je);break;case 5:wu(n);default:Qp(r,n),n=Fe=jm(n,ds),n=Xp(r,n,ds)}e.memoizedProps=e.pendingProps,n===null?il(e):Fe=n}function va(e,n,r,c){ss=hi=null,wu(n),da=null,fr=0;var f=n.return;try{if(zw(e,f,n,r,Je)){wt=1,Po(e,jn(r,e.current)),Fe=null;return}}catch(g){if(f!==null)throw Fe=f,g;wt=1,Po(e,jn(r,e.current)),Fe=null;return}n.flags&32768?(nt||c===1?e=!0:pa||(Je&536870912)!==0?e=!1:(Rs=e=!0,(c===2||c===9||c===3||c===6)&&(c=An.current,c!==null&&c.tag===13&&(c.flags|=16384))),jg(n,e)):il(n)}function il(e){var n=e;do{if((n.flags&32768)!==0){jg(n,Rs);return}e=n.return;var r=_w(n.alternate,n,ds);if(r!==null){Fe=r;return}if(n=n.sibling,n!==null){Fe=n;return}Fe=n=e}while(n!==null);wt===0&&(wt=5)}function jg(e,n){do{var r=Lw(e.alternate,e);if(r!==null){r.flags&=32767,Fe=r;return}if(r=e.return,r!==null&&(r.flags|=32768,r.subtreeFlags=0,r.deletions=null),!n&&(e=e.sibling,e!==null)){Fe=e;return}Fe=e=r}while(e!==null);wt=6,Fe=null}function Sg(e,n,r,c,f,g,b,N,M){e.cancelPendingCommit=null;do al();while(It!==0);if((at&6)!==0)throw Error(a(327));if(n!==null){if(n===e.current)throw Error(a(177));if(g=n.lanes|n.childLanes,g|=Qc,Ze(e,r,g,b,N,M),e===mt&&(Fe=mt=null,Je=0),xa=n,Os=e,ya=r,td=g,nd=f,mg=c,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Kw(it,function(){return Eg(),null})):(e.callbackNode=null,e.callbackPriority=0),c=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||c){c=H.T,H.T=null,f=P.p,P.p=2,b=at,at|=4;try{Ow(e,n,r)}finally{at=b,P.p=f,H.T=c}}It=1,Ng(),Tg(),Ag()}}function Ng(){if(It===1){It=0;var e=Os,n=xa,r=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||r){r=H.T,H.T=null;var c=P.p;P.p=2;var f=at;at|=4;try{og(n,e);var g=yd,b=hm(e.containerInfo),N=g.focusedElem,M=g.selectionRange;if(b!==N&&N&&N.ownerDocument&&fm(N.ownerDocument.documentElement,N)){if(M!==null&&Vc(N)){var K=M.start,ee=M.end;if(ee===void 0&&(ee=K),"selectionStart"in N)N.selectionStart=K,N.selectionEnd=Math.min(ee,N.value.length);else{var ae=N.ownerDocument||document,X=ae&&ae.defaultView||window;if(X.getSelection){var Q=X.getSelection(),De=N.textContent.length,_e=Math.min(M.start,De),dt=M.end===void 0?_e:Math.min(M.end,De);!Q.extend&&_e>dt&&(b=dt,dt=_e,_e=b);var $=dm(N,_e),D=dm(N,dt);if($&&D&&(Q.rangeCount!==1||Q.anchorNode!==$.node||Q.anchorOffset!==$.offset||Q.focusNode!==D.node||Q.focusOffset!==D.offset)){var Y=ae.createRange();Y.setStart($.node,$.offset),Q.removeAllRanges(),_e>dt?(Q.addRange(Y),Q.extend(D.node,D.offset)):(Y.setEnd(D.node,D.offset),Q.addRange(Y))}}}}for(ae=[],Q=N;Q=Q.parentNode;)Q.nodeType===1&&ae.push({element:Q,left:Q.scrollLeft,top:Q.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;N<ae.length;N++){var te=ae[N];te.element.scrollLeft=te.left,te.element.scrollTop=te.top}}xl=!!xd,yd=xd=null}finally{at=f,P.p=c,H.T=r}}e.current=n,It=2}}function Tg(){if(It===2){It=0;var e=Os,n=xa,r=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||r){r=H.T,H.T=null;var c=P.p;P.p=2;var f=at;at|=4;try{sg(e,n.alternate,n)}finally{at=f,P.p=c,H.T=r}}It=3}}function Ag(){if(It===4||It===3){It=0,Ce();var e=Os,n=xa,r=ya,c=mg;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?It=5:(It=0,xa=Os=null,Cg(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(Ls=null),ni(r),n=n.stateNode,xt&&typeof xt.onCommitFiberRoot=="function")try{xt.onCommitFiberRoot(cn,n,void 0,(n.current.flags&128)===128)}catch{}if(c!==null){n=H.T,f=P.p,P.p=2,H.T=null;try{for(var g=e.onRecoverableError,b=0;b<c.length;b++){var N=c[b];g(N.value,{componentStack:N.stack})}}finally{H.T=n,P.p=f}}(ya&3)!==0&&al(),Kn(e),f=e.pendingLanes,(r&4194090)!==0&&(f&42)!==0?e===sd?wr++:(wr=0,sd=e):wr=0,kr(0)}}function Cg(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,tr(n)))}function al(e){return Ng(),Tg(),Ag(),Eg()}function Eg(){if(It!==5)return!1;var e=Os,n=td;td=0;var r=ni(ya),c=H.T,f=P.p;try{P.p=32>r?32:r,H.T=null,r=nd,nd=null;var g=Os,b=ya;if(It=0,xa=Os=null,ya=0,(at&6)!==0)throw Error(a(331));var N=at;if(at|=4,fg(g.current),cg(g,g.current,b,r),at=N,kr(0,!1),xt&&typeof xt.onPostCommitFiberRoot=="function")try{xt.onPostCommitFiberRoot(cn,g)}catch{}return!0}finally{P.p=f,H.T=c,Cg(e,n)}}function Mg(e,n,r){n=jn(r,n),n=Ou(e.stateNode,n,2),e=Ns(e,n,2),e!==null&&(He(e,2),Kn(e))}function ft(e,n,r){if(e.tag===3)Mg(e,e,r);else for(;n!==null;){if(n.tag===3){Mg(n,e,r);break}else if(n.tag===1){var c=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Ls===null||!Ls.has(c))){e=jn(r,e),r=Lp(2),c=Ns(n,r,2),c!==null&&(Op(r,c,n,e),He(c,2),Kn(c));break}}n=n.return}}function od(e,n,r){var c=e.pingCache;if(c===null){c=e.pingCache=new Bw;var f=new Set;c.set(n,f)}else f=c.get(n),f===void 0&&(f=new Set,c.set(n,f));f.has(r)||(Wu=!0,f.add(r),e=Gw.bind(null,e,n,r),n.then(e,e))}function Gw(e,n,r){var c=e.pingCache;c!==null&&c.delete(n),e.pingedLanes|=e.suspendedLanes&r,e.warmLanes&=~r,mt===e&&(Je&r)===r&&(wt===4||wt===3&&(Je&62914560)===Je&&300>je()-ed?(at&2)===0&&ba(e,0):Zu|=r,ga===Je&&(ga=0)),Kn(e)}function zg(e,n){n===0&&(n=ue()),e=ta(e,n),e!==null&&(He(e,n),Kn(e))}function Yw(e){var n=e.memoizedState,r=0;n!==null&&(r=n.retryLane),zg(e,r)}function Vw(e,n){var r=0;switch(e.tag){case 13:var c=e.stateNode,f=e.memoizedState;f!==null&&(r=f.retryLane);break;case 19:c=e.stateNode;break;case 22:c=e.stateNode._retryCache;break;default:throw Error(a(314))}c!==null&&c.delete(n),zg(e,r)}function Kw(e,n){return We(e,n)}var rl=null,wa=null,ld=!1,ol=!1,cd=!1,vi=0;function Kn(e){e!==wa&&e.next===null&&(wa===null?rl=wa=e:wa=wa.next=e),ol=!0,ld||(ld=!0,Xw())}function kr(e,n){if(!cd&&ol){cd=!0;do for(var r=!1,c=rl;c!==null;){if(e!==0){var f=c.pendingLanes;if(f===0)var g=0;else{var b=c.suspendedLanes,N=c.pingedLanes;g=(1<<31-Ct(42|e)+1)-1,g&=f&~(b&~N),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(r=!0,Og(c,g))}else g=Je,g=bt(c,c===mt?g:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(g&3)===0||C(c,g)||(r=!0,Og(c,g));c=c.next}while(r);cd=!1}}function Fw(){Rg()}function Rg(){ol=ld=!1;var e=0;vi!==0&&(nk()&&(e=vi),vi=0);for(var n=je(),r=null,c=rl;c!==null;){var f=c.next,g=_g(c,n);g===0?(c.next=null,r===null?rl=f:r.next=f,f===null&&(wa=r)):(r=c,(e!==0||(g&3)!==0)&&(ol=!0)),c=f}kr(e)}function _g(e,n){for(var r=e.suspendedLanes,c=e.pingedLanes,f=e.expirationTimes,g=e.pendingLanes&-62914561;0<g;){var b=31-Ct(g),N=1<<b,M=f[b];M===-1?((N&r)===0||(N&c)!==0)&&(f[b]=G(N,n)):M<=n&&(e.expiredLanes|=N),g&=~N}if(n=mt,r=Je,r=bt(e,e===n?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),c=e.callbackNode,r===0||e===n&&(rt===2||rt===9)||e.cancelPendingCommit!==null)return c!==null&&c!==null&&ye(c),e.callbackNode=null,e.callbackPriority=0;if((r&3)===0||C(e,r)){if(n=r&-r,n===e.callbackPriority)return n;switch(c!==null&&ye(c),ni(r)){case 2:case 8:r=ze;break;case 32:r=it;break;case 268435456:r=At;break;default:r=it}return c=Lg.bind(null,e),r=We(r,c),e.callbackPriority=n,e.callbackNode=r,n}return c!==null&&c!==null&&ye(c),e.callbackPriority=2,e.callbackNode=null,2}function Lg(e,n){if(It!==0&&It!==5)return e.callbackNode=null,e.callbackPriority=0,null;var r=e.callbackNode;if(al()&&e.callbackNode!==r)return null;var c=Je;return c=bt(e,e===mt?c:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),c===0?null:(gg(e,c,n),_g(e,je()),e.callbackNode!=null&&e.callbackNode===r?Lg.bind(null,e):null)}function Og(e,n){if(al())return null;gg(e,n,!0)}function Xw(){ik(function(){(at&6)!==0?We(ln,Fw):Rg()})}function ud(){return vi===0&&(vi=ce()),vi}function Dg(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:yo(""+e)}function qg(e,n){var r=n.ownerDocument.createElement("input");return r.name=n.name,r.value=n.value,e.id&&r.setAttribute("form",e.id),n.parentNode.insertBefore(r,n),e=new FormData(e),r.parentNode.removeChild(r),e}function Pw(e,n,r,c,f){if(n==="submit"&&r&&r.stateNode===f){var g=Dg((f[Jt]||null).action),b=c.submitter;b&&(n=(n=b[Jt]||null)?Dg(n.formAction):b.getAttribute("formAction"),n!==null&&(g=n,b=null));var N=new ko("action","action",null,c,f);e.push({event:N,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(vi!==0){var M=b?qg(f,b):new FormData(f);Mu(r,{pending:!0,data:M,method:f.method,action:g},null,M)}}else typeof g=="function"&&(N.preventDefault(),M=b?qg(f,b):new FormData(f),Mu(r,{pending:!0,data:M,method:f.method,action:g},g,M))},currentTarget:f}]})}}for(var dd=0;dd<Pc.length;dd++){var fd=Pc[dd],Qw=fd.toLowerCase(),Ww=fd[0].toUpperCase()+fd.slice(1);Ln(Qw,"on"+Ww)}Ln(gm,"onAnimationEnd"),Ln(xm,"onAnimationIteration"),Ln(ym,"onAnimationStart"),Ln("dblclick","onDoubleClick"),Ln("focusin","onFocus"),Ln("focusout","onBlur"),Ln(mw,"onTransitionRun"),Ln(pw,"onTransitionStart"),Ln(gw,"onTransitionCancel"),Ln(bm,"onTransitionEnd"),Vi("onMouseEnter",["mouseout","mouseover"]),Vi("onMouseLeave",["mouseout","mouseover"]),Vi("onPointerEnter",["pointerout","pointerover"]),Vi("onPointerLeave",["pointerout","pointerover"]),ii("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ii("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ii("onBeforeInput",["compositionend","keypress","textInput","paste"]),ii("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ii("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ii("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var jr="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(" "),Zw=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(jr));function Bg(e,n){n=(n&4)!==0;for(var r=0;r<e.length;r++){var c=e[r],f=c.event;c=c.listeners;e:{var g=void 0;if(n)for(var b=c.length-1;0<=b;b--){var N=c[b],M=N.instance,K=N.currentTarget;if(N=N.listener,M!==g&&f.isPropagationStopped())break e;g=N,f.currentTarget=K;try{g(f)}catch(ee){Xo(ee)}f.currentTarget=null,g=M}else for(b=0;b<c.length;b++){if(N=c[b],M=N.instance,K=N.currentTarget,N=N.listener,M!==g&&f.isPropagationStopped())break e;g=N,f.currentTarget=K;try{g(f)}catch(ee){Xo(ee)}f.currentTarget=null,g=M}}}}function Xe(e,n){var r=n[Nc];r===void 0&&(r=n[Nc]=new Set);var c=e+"__bubble";r.has(c)||($g(n,e,2,!1),r.add(c))}function hd(e,n,r){var c=0;n&&(c|=4),$g(r,e,c,n)}var ll="_reactListening"+Math.random().toString(36).slice(2);function md(e){if(!e[ll]){e[ll]=!0,Rh.forEach(function(r){r!=="selectionchange"&&(Zw.has(r)||hd(r,!1,e),hd(r,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[ll]||(n[ll]=!0,hd("selectionchange",!1,n))}}function $g(e,n,r,c){switch(cx(n)){case 2:var f=Nk;break;case 8:f=Tk;break;default:f=Cd}r=f.bind(null,n,r,e),f=void 0,!Dc||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(f=!0),c?f!==void 0?e.addEventListener(n,r,{capture:!0,passive:f}):e.addEventListener(n,r,!0):f!==void 0?e.addEventListener(n,r,{passive:f}):e.addEventListener(n,r,!1)}function pd(e,n,r,c,f){var g=c;if((n&1)===0&&(n&2)===0&&c!==null)e:for(;;){if(c===null)return;var b=c.tag;if(b===3||b===4){var N=c.stateNode.containerInfo;if(N===f)break;if(b===4)for(b=c.return;b!==null;){var M=b.tag;if((M===3||M===4)&&b.stateNode.containerInfo===f)return;b=b.return}for(;N!==null;){if(b=Ii(N),b===null)return;if(M=b.tag,M===5||M===6||M===26||M===27){c=g=b;continue e}N=N.parentNode}}c=c.return}Kh(function(){var K=g,ee=Lc(r),ae=[];e:{var X=vm.get(e);if(X!==void 0){var Q=ko,De=e;switch(e){case"keypress":if(vo(r)===0)break e;case"keydown":case"keyup":Q=Kv;break;case"focusin":De="focus",Q=Uc;break;case"focusout":De="blur",Q=Uc;break;case"beforeblur":case"afterblur":Q=Uc;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Q=Ph;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Q=Lv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Q=Pv;break;case gm:case xm:case ym:Q=qv;break;case bm:Q=Wv;break;case"scroll":case"scrollend":Q=Rv;break;case"wheel":Q=Jv;break;case"copy":case"cut":case"paste":Q=$v;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Q=Wh;break;case"toggle":case"beforetoggle":Q=tw}var _e=(n&4)!==0,dt=!_e&&(e==="scroll"||e==="scrollend"),$=_e?X!==null?X+"Capture":null:X;_e=[];for(var D=K,Y;D!==null;){var te=D;if(Y=te.stateNode,te=te.tag,te!==5&&te!==26&&te!==27||Y===null||$===null||(te=Ia(D,$),te!=null&&_e.push(Sr(D,te,Y))),dt)break;D=D.return}0<_e.length&&(X=new Q(X,De,null,r,ee),ae.push({event:X,listeners:_e}))}}if((n&7)===0){e:{if(X=e==="mouseover"||e==="pointerover",Q=e==="mouseout"||e==="pointerout",X&&r!==_c&&(De=r.relatedTarget||r.fromElement)&&(Ii(De)||De[Hi]))break e;if((Q||X)&&(X=ee.window===ee?ee:(X=ee.ownerDocument)?X.defaultView||X.parentWindow:window,Q?(De=r.relatedTarget||r.toElement,Q=K,De=De?Ii(De):null,De!==null&&(dt=u(De),_e=De.tag,De!==dt||_e!==5&&_e!==27&&_e!==6)&&(De=null)):(Q=null,De=K),Q!==De)){if(_e=Ph,te="onMouseLeave",$="onMouseEnter",D="mouse",(e==="pointerout"||e==="pointerover")&&(_e=Wh,te="onPointerLeave",$="onPointerEnter",D="pointer"),dt=Q==null?X:Ha(Q),Y=De==null?X:Ha(De),X=new _e(te,D+"leave",Q,r,ee),X.target=dt,X.relatedTarget=Y,te=null,Ii(ee)===K&&(_e=new _e($,D+"enter",De,r,ee),_e.target=Y,_e.relatedTarget=dt,te=_e),dt=te,Q&&De)t:{for(_e=Q,$=De,D=0,Y=_e;Y;Y=ka(Y))D++;for(Y=0,te=$;te;te=ka(te))Y++;for(;0<D-Y;)_e=ka(_e),D--;for(;0<Y-D;)$=ka($),Y--;for(;D--;){if(_e===$||$!==null&&_e===$.alternate)break t;_e=ka(_e),$=ka($)}_e=null}else _e=null;Q!==null&&Ug(ae,X,Q,_e,!1),De!==null&&dt!==null&&Ug(ae,dt,De,_e,!0)}}e:{if(X=K?Ha(K):window,Q=X.nodeName&&X.nodeName.toLowerCase(),Q==="select"||Q==="input"&&X.type==="file")var Se=am;else if(sm(X))if(rm)Se=dw;else{Se=cw;var Ve=lw}else Q=X.nodeName,!Q||Q.toLowerCase()!=="input"||X.type!=="checkbox"&&X.type!=="radio"?K&&Rc(K.elementType)&&(Se=am):Se=uw;if(Se&&(Se=Se(e,K))){im(ae,Se,r,ee);break e}Ve&&Ve(e,X,K),e==="focusout"&&K&&X.type==="number"&&K.memoizedProps.value!=null&&zc(X,"number",X.value)}switch(Ve=K?Ha(K):window,e){case"focusin":(sm(Ve)||Ve.contentEditable==="true")&&(Zi=Ve,Kc=K,Qa=null);break;case"focusout":Qa=Kc=Zi=null;break;case"mousedown":Fc=!0;break;case"contextmenu":case"mouseup":case"dragend":Fc=!1,mm(ae,r,ee);break;case"selectionchange":if(hw)break;case"keydown":case"keyup":mm(ae,r,ee)}var Ee;if(Ic)e:{switch(e){case"compositionstart":var Le="onCompositionStart";break e;case"compositionend":Le="onCompositionEnd";break e;case"compositionupdate":Le="onCompositionUpdate";break e}Le=void 0}else Wi?tm(e,r)&&(Le="onCompositionEnd"):e==="keydown"&&r.keyCode===229&&(Le="onCompositionStart");Le&&(Zh&&r.locale!=="ko"&&(Wi||Le!=="onCompositionStart"?Le==="onCompositionEnd"&&Wi&&(Ee=Fh()):(ws=ee,qc="value"in ws?ws.value:ws.textContent,Wi=!0)),Ve=cl(K,Le),0<Ve.length&&(Le=new Qh(Le,e,null,r,ee),ae.push({event:Le,listeners:Ve}),Ee?Le.data=Ee:(Ee=nm(r),Ee!==null&&(Le.data=Ee)))),(Ee=sw?iw(e,r):aw(e,r))&&(Le=cl(K,"onBeforeInput"),0<Le.length&&(Ve=new Qh("onBeforeInput","beforeinput",null,r,ee),ae.push({event:Ve,listeners:Le}),Ve.data=Ee)),Pw(ae,e,K,r,ee)}Bg(ae,n)})}function Sr(e,n,r){return{instance:e,listener:n,currentTarget:r}}function cl(e,n){for(var r=n+"Capture",c=[];e!==null;){var f=e,g=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||g===null||(f=Ia(e,r),f!=null&&c.unshift(Sr(e,f,g)),f=Ia(e,n),f!=null&&c.push(Sr(e,f,g))),e.tag===3)return c;e=e.return}return[]}function ka(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Ug(e,n,r,c,f){for(var g=n._reactName,b=[];r!==null&&r!==c;){var N=r,M=N.alternate,K=N.stateNode;if(N=N.tag,M!==null&&M===c)break;N!==5&&N!==26&&N!==27||K===null||(M=K,f?(K=Ia(r,g),K!=null&&b.unshift(Sr(r,K,M))):f||(K=Ia(r,g),K!=null&&b.push(Sr(r,K,M)))),r=r.return}b.length!==0&&e.push({event:n,listeners:b})}var Jw=/\r\n?/g,ek=/\u0000|\uFFFD/g;function Hg(e){return(typeof e=="string"?e:""+e).replace(Jw,`
|
|
10
|
+
`).replace(ek,"")}function Ig(e,n){return n=Hg(n),Hg(e)===n}function ul(){}function ut(e,n,r,c,f,g){switch(r){case"children":typeof c=="string"?n==="body"||n==="textarea"&&c===""||Xi(e,c):(typeof c=="number"||typeof c=="bigint")&&n!=="body"&&Xi(e,""+c);break;case"className":po(e,"class",c);break;case"tabIndex":po(e,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":po(e,r,c);break;case"style":Yh(e,c,g);break;case"data":if(n!=="object"){po(e,"data",c);break}case"src":case"href":if(c===""&&(n!=="a"||r!=="href")){e.removeAttribute(r);break}if(c==null||typeof c=="function"||typeof c=="symbol"||typeof c=="boolean"){e.removeAttribute(r);break}c=yo(""+c),e.setAttribute(r,c);break;case"action":case"formAction":if(typeof c=="function"){e.setAttribute(r,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof g=="function"&&(r==="formAction"?(n!=="input"&&ut(e,n,"name",f.name,f,null),ut(e,n,"formEncType",f.formEncType,f,null),ut(e,n,"formMethod",f.formMethod,f,null),ut(e,n,"formTarget",f.formTarget,f,null)):(ut(e,n,"encType",f.encType,f,null),ut(e,n,"method",f.method,f,null),ut(e,n,"target",f.target,f,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){e.removeAttribute(r);break}c=yo(""+c),e.setAttribute(r,c);break;case"onClick":c!=null&&(e.onclick=ul);break;case"onScroll":c!=null&&Xe("scroll",e);break;case"onScrollEnd":c!=null&&Xe("scrollend",e);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(a(61));if(r=c.__html,r!=null){if(f.children!=null)throw Error(a(60));e.innerHTML=r}}break;case"multiple":e.multiple=c&&typeof c!="function"&&typeof c!="symbol";break;case"muted":e.muted=c&&typeof c!="function"&&typeof c!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(c==null||typeof c=="function"||typeof c=="boolean"||typeof c=="symbol"){e.removeAttribute("xlink:href");break}r=yo(""+c),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":c!=null&&typeof c!="function"&&typeof c!="symbol"?e.setAttribute(r,""+c):e.removeAttribute(r);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":c&&typeof c!="function"&&typeof c!="symbol"?e.setAttribute(r,""):e.removeAttribute(r);break;case"capture":case"download":c===!0?e.setAttribute(r,""):c!==!1&&c!=null&&typeof c!="function"&&typeof c!="symbol"?e.setAttribute(r,c):e.removeAttribute(r);break;case"cols":case"rows":case"size":case"span":c!=null&&typeof c!="function"&&typeof c!="symbol"&&!isNaN(c)&&1<=c?e.setAttribute(r,c):e.removeAttribute(r);break;case"rowSpan":case"start":c==null||typeof c=="function"||typeof c=="symbol"||isNaN(c)?e.removeAttribute(r):e.setAttribute(r,c);break;case"popover":Xe("beforetoggle",e),Xe("toggle",e),mo(e,"popover",c);break;case"xlinkActuate":Zn(e,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":Zn(e,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":Zn(e,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":Zn(e,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":Zn(e,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":Zn(e,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":Zn(e,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":Zn(e,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":Zn(e,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":mo(e,"is",c);break;case"innerText":case"textContent":break;default:(!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(r=Mv.get(r)||r,mo(e,r,c))}}function gd(e,n,r,c,f,g){switch(r){case"style":Yh(e,c,g);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(a(61));if(r=c.__html,r!=null){if(f.children!=null)throw Error(a(60));e.innerHTML=r}}break;case"children":typeof c=="string"?Xi(e,c):(typeof c=="number"||typeof c=="bigint")&&Xi(e,""+c);break;case"onScroll":c!=null&&Xe("scroll",e);break;case"onScrollEnd":c!=null&&Xe("scrollend",e);break;case"onClick":c!=null&&(e.onclick=ul);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!_h.hasOwnProperty(r))e:{if(r[0]==="o"&&r[1]==="n"&&(f=r.endsWith("Capture"),n=r.slice(2,f?r.length-7:void 0),g=e[Jt]||null,g=g!=null?g[r]:null,typeof g=="function"&&e.removeEventListener(n,g,f),typeof c=="function")){typeof g!="function"&&g!==null&&(r in e?e[r]=null:e.hasAttribute(r)&&e.removeAttribute(r)),e.addEventListener(n,c,f);break e}r in e?e[r]=c:c===!0?e.setAttribute(r,""):mo(e,r,c)}}}function Gt(e,n,r){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Xe("error",e),Xe("load",e);var c=!1,f=!1,g;for(g in r)if(r.hasOwnProperty(g)){var b=r[g];if(b!=null)switch(g){case"src":c=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(a(137,n));default:ut(e,n,g,b,r,null)}}f&&ut(e,n,"srcSet",r.srcSet,r,null),c&&ut(e,n,"src",r.src,r,null);return;case"input":Xe("invalid",e);var N=g=b=f=null,M=null,K=null;for(c in r)if(r.hasOwnProperty(c)){var ee=r[c];if(ee!=null)switch(c){case"name":f=ee;break;case"type":b=ee;break;case"checked":M=ee;break;case"defaultChecked":K=ee;break;case"value":g=ee;break;case"defaultValue":N=ee;break;case"children":case"dangerouslySetInnerHTML":if(ee!=null)throw Error(a(137,n));break;default:ut(e,n,c,ee,r,null)}}Uh(e,g,N,M,K,b,f,!1),go(e);return;case"select":Xe("invalid",e),c=b=g=null;for(f in r)if(r.hasOwnProperty(f)&&(N=r[f],N!=null))switch(f){case"value":g=N;break;case"defaultValue":b=N;break;case"multiple":c=N;default:ut(e,n,f,N,r,null)}n=g,r=b,e.multiple=!!c,n!=null?Fi(e,!!c,n,!1):r!=null&&Fi(e,!!c,r,!0);return;case"textarea":Xe("invalid",e),g=f=c=null;for(b in r)if(r.hasOwnProperty(b)&&(N=r[b],N!=null))switch(b){case"value":c=N;break;case"defaultValue":f=N;break;case"children":g=N;break;case"dangerouslySetInnerHTML":if(N!=null)throw Error(a(91));break;default:ut(e,n,b,N,r,null)}Ih(e,c,f,g),go(e);return;case"option":for(M in r)r.hasOwnProperty(M)&&(c=r[M],c!=null)&&(M==="selected"?e.selected=c&&typeof c!="function"&&typeof c!="symbol":ut(e,n,M,c,r,null));return;case"dialog":Xe("beforetoggle",e),Xe("toggle",e),Xe("cancel",e),Xe("close",e);break;case"iframe":case"object":Xe("load",e);break;case"video":case"audio":for(c=0;c<jr.length;c++)Xe(jr[c],e);break;case"image":Xe("error",e),Xe("load",e);break;case"details":Xe("toggle",e);break;case"embed":case"source":case"link":Xe("error",e),Xe("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(K in r)if(r.hasOwnProperty(K)&&(c=r[K],c!=null))switch(K){case"children":case"dangerouslySetInnerHTML":throw Error(a(137,n));default:ut(e,n,K,c,r,null)}return;default:if(Rc(n)){for(ee in r)r.hasOwnProperty(ee)&&(c=r[ee],c!==void 0&&gd(e,n,ee,c,r,void 0));return}}for(N in r)r.hasOwnProperty(N)&&(c=r[N],c!=null&&ut(e,n,N,c,r,null))}function tk(e,n,r,c){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,g=null,b=null,N=null,M=null,K=null,ee=null;for(Q in r){var ae=r[Q];if(r.hasOwnProperty(Q)&&ae!=null)switch(Q){case"checked":break;case"value":break;case"defaultValue":M=ae;default:c.hasOwnProperty(Q)||ut(e,n,Q,null,c,ae)}}for(var X in c){var Q=c[X];if(ae=r[X],c.hasOwnProperty(X)&&(Q!=null||ae!=null))switch(X){case"type":g=Q;break;case"name":f=Q;break;case"checked":K=Q;break;case"defaultChecked":ee=Q;break;case"value":b=Q;break;case"defaultValue":N=Q;break;case"children":case"dangerouslySetInnerHTML":if(Q!=null)throw Error(a(137,n));break;default:Q!==ae&&ut(e,n,X,Q,c,ae)}}Mc(e,b,N,M,K,ee,g,f);return;case"select":Q=b=N=X=null;for(g in r)if(M=r[g],r.hasOwnProperty(g)&&M!=null)switch(g){case"value":break;case"multiple":Q=M;default:c.hasOwnProperty(g)||ut(e,n,g,null,c,M)}for(f in c)if(g=c[f],M=r[f],c.hasOwnProperty(f)&&(g!=null||M!=null))switch(f){case"value":X=g;break;case"defaultValue":N=g;break;case"multiple":b=g;default:g!==M&&ut(e,n,f,g,c,M)}n=N,r=b,c=Q,X!=null?Fi(e,!!r,X,!1):!!c!=!!r&&(n!=null?Fi(e,!!r,n,!0):Fi(e,!!r,r?[]:"",!1));return;case"textarea":Q=X=null;for(N in r)if(f=r[N],r.hasOwnProperty(N)&&f!=null&&!c.hasOwnProperty(N))switch(N){case"value":break;case"children":break;default:ut(e,n,N,null,c,f)}for(b in c)if(f=c[b],g=r[b],c.hasOwnProperty(b)&&(f!=null||g!=null))switch(b){case"value":X=f;break;case"defaultValue":Q=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(a(91));break;default:f!==g&&ut(e,n,b,f,c,g)}Hh(e,X,Q);return;case"option":for(var De in r)X=r[De],r.hasOwnProperty(De)&&X!=null&&!c.hasOwnProperty(De)&&(De==="selected"?e.selected=!1:ut(e,n,De,null,c,X));for(M in c)X=c[M],Q=r[M],c.hasOwnProperty(M)&&X!==Q&&(X!=null||Q!=null)&&(M==="selected"?e.selected=X&&typeof X!="function"&&typeof X!="symbol":ut(e,n,M,X,c,Q));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var _e in r)X=r[_e],r.hasOwnProperty(_e)&&X!=null&&!c.hasOwnProperty(_e)&&ut(e,n,_e,null,c,X);for(K in c)if(X=c[K],Q=r[K],c.hasOwnProperty(K)&&X!==Q&&(X!=null||Q!=null))switch(K){case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(a(137,n));break;default:ut(e,n,K,X,c,Q)}return;default:if(Rc(n)){for(var dt in r)X=r[dt],r.hasOwnProperty(dt)&&X!==void 0&&!c.hasOwnProperty(dt)&&gd(e,n,dt,void 0,c,X);for(ee in c)X=c[ee],Q=r[ee],!c.hasOwnProperty(ee)||X===Q||X===void 0&&Q===void 0||gd(e,n,ee,X,c,Q);return}}for(var $ in r)X=r[$],r.hasOwnProperty($)&&X!=null&&!c.hasOwnProperty($)&&ut(e,n,$,null,c,X);for(ae in c)X=c[ae],Q=r[ae],!c.hasOwnProperty(ae)||X===Q||X==null&&Q==null||ut(e,n,ae,X,c,Q)}var xd=null,yd=null;function dl(e){return e.nodeType===9?e:e.ownerDocument}function Gg(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Yg(e,n){if(e===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&n==="foreignObject"?0:e}function bd(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var vd=null;function nk(){var e=window.event;return e&&e.type==="popstate"?e===vd?!1:(vd=e,!0):(vd=null,!1)}var Vg=typeof setTimeout=="function"?setTimeout:void 0,sk=typeof clearTimeout=="function"?clearTimeout:void 0,Kg=typeof Promise=="function"?Promise:void 0,ik=typeof queueMicrotask=="function"?queueMicrotask:typeof Kg<"u"?function(e){return Kg.resolve(null).then(e).catch(ak)}:Vg;function ak(e){setTimeout(function(){throw e})}function qs(e){return e==="head"}function Fg(e,n){var r=n,c=0,f=0;do{var g=r.nextSibling;if(e.removeChild(r),g&&g.nodeType===8)if(r=g.data,r==="/$"){if(0<c&&8>c){r=c;var b=e.ownerDocument;if(r&1&&Nr(b.documentElement),r&2&&Nr(b.body),r&4)for(r=b.head,Nr(r),b=r.firstChild;b;){var N=b.nextSibling,M=b.nodeName;b[Ua]||M==="SCRIPT"||M==="STYLE"||M==="LINK"&&b.rel.toLowerCase()==="stylesheet"||r.removeChild(b),b=N}}if(f===0){e.removeChild(g),_r(n);return}f--}else r==="$"||r==="$?"||r==="$!"?f++:c=r.charCodeAt(0)-48;else c=0;r=g}while(r);_r(n)}function wd(e){var n=e.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var r=n;switch(n=n.nextSibling,r.nodeName){case"HTML":case"HEAD":case"BODY":wd(r),Tc(r);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(r.rel.toLowerCase()==="stylesheet")continue}e.removeChild(r)}}function rk(e,n,r,c){for(;e.nodeType===1;){var f=r;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!c&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(c){if(!e[Ua])switch(n){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(g=e.getAttribute("rel"),g==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(g!==f.rel||e.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||e.getAttribute("title")!==(f.title==null?null:f.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(g=e.getAttribute("src"),(g!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&g&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var g=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===g)return e}else return e;if(e=Dn(e.nextSibling),e===null)break}return null}function ok(e,n,r){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!r||(e=Dn(e.nextSibling),e===null))return null;return e}function kd(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState==="complete"}function lk(e,n){var r=e.ownerDocument;if(e.data!=="$?"||r.readyState==="complete")n();else{var c=function(){n(),r.removeEventListener("DOMContentLoaded",c)};r.addEventListener("DOMContentLoaded",c),e._reactRetry=c}}function Dn(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?"||n==="F!"||n==="F")break;if(n==="/$")return null}}return e}var jd=null;function Xg(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var r=e.data;if(r==="$"||r==="$!"||r==="$?"){if(n===0)return e;n--}else r==="/$"&&n++}e=e.previousSibling}return null}function Pg(e,n,r){switch(n=dl(r),e){case"html":if(e=n.documentElement,!e)throw Error(a(452));return e;case"head":if(e=n.head,!e)throw Error(a(453));return e;case"body":if(e=n.body,!e)throw Error(a(454));return e;default:throw Error(a(451))}}function Nr(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);Tc(e)}var En=new Map,Qg=new Set;function fl(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var fs=P.d;P.d={f:ck,r:uk,D:dk,C:fk,L:hk,m:mk,X:gk,S:pk,M:xk};function ck(){var e=fs.f(),n=sl();return e||n}function uk(e){var n=Gi(e);n!==null&&n.tag===5&&n.type==="form"?gp(n):fs.r(e)}var ja=typeof document>"u"?null:document;function Wg(e,n,r){var c=ja;if(c&&typeof n=="string"&&n){var f=kn(n);f='link[rel="'+e+'"][href="'+f+'"]',typeof r=="string"&&(f+='[crossorigin="'+r+'"]'),Qg.has(f)||(Qg.add(f),e={rel:e,crossOrigin:r,href:n},c.querySelector(f)===null&&(n=c.createElement("link"),Gt(n,"link",e),Dt(n),c.head.appendChild(n)))}}function dk(e){fs.D(e),Wg("dns-prefetch",e,null)}function fk(e,n){fs.C(e,n),Wg("preconnect",e,n)}function hk(e,n,r){fs.L(e,n,r);var c=ja;if(c&&e&&n){var f='link[rel="preload"][as="'+kn(n)+'"]';n==="image"&&r&&r.imageSrcSet?(f+='[imagesrcset="'+kn(r.imageSrcSet)+'"]',typeof r.imageSizes=="string"&&(f+='[imagesizes="'+kn(r.imageSizes)+'"]')):f+='[href="'+kn(e)+'"]';var g=f;switch(n){case"style":g=Sa(e);break;case"script":g=Na(e)}En.has(g)||(e=x({rel:"preload",href:n==="image"&&r&&r.imageSrcSet?void 0:e,as:n},r),En.set(g,e),c.querySelector(f)!==null||n==="style"&&c.querySelector(Tr(g))||n==="script"&&c.querySelector(Ar(g))||(n=c.createElement("link"),Gt(n,"link",e),Dt(n),c.head.appendChild(n)))}}function mk(e,n){fs.m(e,n);var r=ja;if(r&&e){var c=n&&typeof n.as=="string"?n.as:"script",f='link[rel="modulepreload"][as="'+kn(c)+'"][href="'+kn(e)+'"]',g=f;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=Na(e)}if(!En.has(g)&&(e=x({rel:"modulepreload",href:e},n),En.set(g,e),r.querySelector(f)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(r.querySelector(Ar(g)))return}c=r.createElement("link"),Gt(c,"link",e),Dt(c),r.head.appendChild(c)}}}function pk(e,n,r){fs.S(e,n,r);var c=ja;if(c&&e){var f=Yi(c).hoistableStyles,g=Sa(e);n=n||"default";var b=f.get(g);if(!b){var N={loading:0,preload:null};if(b=c.querySelector(Tr(g)))N.loading=5;else{e=x({rel:"stylesheet",href:e,"data-precedence":n},r),(r=En.get(g))&&Sd(e,r);var M=b=c.createElement("link");Dt(M),Gt(M,"link",e),M._p=new Promise(function(K,ee){M.onload=K,M.onerror=ee}),M.addEventListener("load",function(){N.loading|=1}),M.addEventListener("error",function(){N.loading|=2}),N.loading|=4,hl(b,n,c)}b={type:"stylesheet",instance:b,count:1,state:N},f.set(g,b)}}}function gk(e,n){fs.X(e,n);var r=ja;if(r&&e){var c=Yi(r).hoistableScripts,f=Na(e),g=c.get(f);g||(g=r.querySelector(Ar(f)),g||(e=x({src:e,async:!0},n),(n=En.get(f))&&Nd(e,n),g=r.createElement("script"),Dt(g),Gt(g,"link",e),r.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(f,g))}}function xk(e,n){fs.M(e,n);var r=ja;if(r&&e){var c=Yi(r).hoistableScripts,f=Na(e),g=c.get(f);g||(g=r.querySelector(Ar(f)),g||(e=x({src:e,async:!0,type:"module"},n),(n=En.get(f))&&Nd(e,n),g=r.createElement("script"),Dt(g),Gt(g,"link",e),r.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(f,g))}}function Zg(e,n,r,c){var f=(f=le.current)?fl(f):null;if(!f)throw Error(a(446));switch(e){case"meta":case"title":return null;case"style":return typeof r.precedence=="string"&&typeof r.href=="string"?(n=Sa(r.href),r=Yi(f).hoistableStyles,c=r.get(n),c||(c={type:"style",instance:null,count:0,state:null},r.set(n,c)),c):{type:"void",instance:null,count:0,state:null};case"link":if(r.rel==="stylesheet"&&typeof r.href=="string"&&typeof r.precedence=="string"){e=Sa(r.href);var g=Yi(f).hoistableStyles,b=g.get(e);if(b||(f=f.ownerDocument||f,b={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(e,b),(g=f.querySelector(Tr(e)))&&!g._p&&(b.instance=g,b.state.loading=5),En.has(e)||(r={rel:"preload",as:"style",href:r.href,crossOrigin:r.crossOrigin,integrity:r.integrity,media:r.media,hrefLang:r.hrefLang,referrerPolicy:r.referrerPolicy},En.set(e,r),g||yk(f,e,r,b.state))),n&&c===null)throw Error(a(528,""));return b}if(n&&c!==null)throw Error(a(529,""));return null;case"script":return n=r.async,r=r.src,typeof r=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=Na(r),r=Yi(f).hoistableScripts,c=r.get(n),c||(c={type:"script",instance:null,count:0,state:null},r.set(n,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,e))}}function Sa(e){return'href="'+kn(e)+'"'}function Tr(e){return'link[rel="stylesheet"]['+e+"]"}function Jg(e){return x({},e,{"data-precedence":e.precedence,precedence:null})}function yk(e,n,r,c){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?c.loading=1:(n=e.createElement("link"),c.preload=n,n.addEventListener("load",function(){return c.loading|=1}),n.addEventListener("error",function(){return c.loading|=2}),Gt(n,"link",r),Dt(n),e.head.appendChild(n))}function Na(e){return'[src="'+kn(e)+'"]'}function Ar(e){return"script[async]"+e}function ex(e,n,r){if(n.count++,n.instance===null)switch(n.type){case"style":var c=e.querySelector('style[data-href~="'+kn(r.href)+'"]');if(c)return n.instance=c,Dt(c),c;var f=x({},r,{"data-href":r.href,"data-precedence":r.precedence,href:null,precedence:null});return c=(e.ownerDocument||e).createElement("style"),Dt(c),Gt(c,"style",f),hl(c,r.precedence,e),n.instance=c;case"stylesheet":f=Sa(r.href);var g=e.querySelector(Tr(f));if(g)return n.state.loading|=4,n.instance=g,Dt(g),g;c=Jg(r),(f=En.get(f))&&Sd(c,f),g=(e.ownerDocument||e).createElement("link"),Dt(g);var b=g;return b._p=new Promise(function(N,M){b.onload=N,b.onerror=M}),Gt(g,"link",c),n.state.loading|=4,hl(g,r.precedence,e),n.instance=g;case"script":return g=Na(r.src),(f=e.querySelector(Ar(g)))?(n.instance=f,Dt(f),f):(c=r,(f=En.get(g))&&(c=x({},r),Nd(c,f)),e=e.ownerDocument||e,f=e.createElement("script"),Dt(f),Gt(f,"link",c),e.head.appendChild(f),n.instance=f);case"void":return null;default:throw Error(a(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(c=n.instance,n.state.loading|=4,hl(c,r.precedence,e));return n.instance}function hl(e,n,r){for(var c=r.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=c.length?c[c.length-1]:null,g=f,b=0;b<c.length;b++){var N=c[b];if(N.dataset.precedence===n)g=N;else if(g!==f)break}g?g.parentNode.insertBefore(e,g.nextSibling):(n=r.nodeType===9?r.head:r,n.insertBefore(e,n.firstChild))}function Sd(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function Nd(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var ml=null;function tx(e,n,r){if(ml===null){var c=new Map,f=ml=new Map;f.set(r,c)}else f=ml,c=f.get(r),c||(c=new Map,f.set(r,c));if(c.has(e))return c;for(c.set(e,null),r=r.getElementsByTagName(e),f=0;f<r.length;f++){var g=r[f];if(!(g[Ua]||g[Ft]||e==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var b=g.getAttribute(n)||"";b=e+b;var N=c.get(b);N?N.push(g):c.set(b,[g])}}return c}function nx(e,n,r){e=e.ownerDocument||e,e.head.insertBefore(r,n==="title"?e.querySelector("head > title"):null)}function bk(e,n,r){if(r===1||n.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;return n.rel==="stylesheet"?(e=n.disabled,typeof n.precedence=="string"&&e==null):!0;case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function sx(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}var Cr=null;function vk(){}function wk(e,n,r){if(Cr===null)throw Error(a(475));var c=Cr;if(n.type==="stylesheet"&&(typeof r.media!="string"||matchMedia(r.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var f=Sa(r.href),g=e.querySelector(Tr(f));if(g){e=g._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(c.count++,c=pl.bind(c),e.then(c,c)),n.state.loading|=4,n.instance=g,Dt(g);return}g=e.ownerDocument||e,r=Jg(r),(f=En.get(f))&&Sd(r,f),g=g.createElement("link"),Dt(g);var b=g;b._p=new Promise(function(N,M){b.onload=N,b.onerror=M}),Gt(g,"link",r),n.instance=g}c.stylesheets===null&&(c.stylesheets=new Map),c.stylesheets.set(n,e),(e=n.state.preload)&&(n.state.loading&3)===0&&(c.count++,n=pl.bind(c),e.addEventListener("load",n),e.addEventListener("error",n))}}function kk(){if(Cr===null)throw Error(a(475));var e=Cr;return e.stylesheets&&e.count===0&&Td(e,e.stylesheets),0<e.count?function(n){var r=setTimeout(function(){if(e.stylesheets&&Td(e,e.stylesheets),e.unsuspend){var c=e.unsuspend;e.unsuspend=null,c()}},6e4);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r)}}:null}function pl(){if(this.count--,this.count===0){if(this.stylesheets)Td(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var gl=null;function Td(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,gl=new Map,n.forEach(jk,e),gl=null,pl.call(e))}function jk(e,n){if(!(n.state.loading&4)){var r=gl.get(e);if(r)var c=r.get(null);else{r=new Map,gl.set(e,r);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<f.length;g++){var b=f[g];(b.nodeName==="LINK"||b.getAttribute("media")!=="not all")&&(r.set(b.dataset.precedence,b),c=b)}c&&r.set(null,c)}f=n.instance,b=f.getAttribute("data-precedence"),g=r.get(b)||c,g===c&&r.set(null,f),r.set(b,f),this.count++,c=pl.bind(this),f.addEventListener("load",c),f.addEventListener("error",c),g?g.parentNode.insertBefore(f,g.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),n.state.loading|=4}}var Er={$$typeof:L,Provider:null,Consumer:null,_currentValue:oe,_currentValue2:oe,_threadCount:0};function Sk(e,n,r,c,f,g,b,N){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=pe(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pe(0),this.hiddenUpdates=pe(null),this.identifierPrefix=c,this.onUncaughtError=f,this.onCaughtError=g,this.onRecoverableError=b,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=N,this.incompleteTransitions=new Map}function ix(e,n,r,c,f,g,b,N,M,K,ee,ae){return e=new Sk(e,n,r,b,N,M,K,ae),n=1,g===!0&&(n|=24),g=fn(3,null,null,n),e.current=g,g.stateNode=e,n=ou(),n.refCount++,e.pooledCache=n,n.refCount++,g.memoizedState={element:c,isDehydrated:r,cache:n},du(g),e}function ax(e){return e?(e=na,e):na}function rx(e,n,r,c,f,g){f=ax(f),c.context===null?c.context=f:c.pendingContext=f,c=Ss(n),c.payload={element:r},g=g===void 0?null:g,g!==null&&(c.callback=g),r=Ns(e,c,n),r!==null&&(xn(r,e,n),ar(r,e,n))}function ox(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var r=e.retryLane;e.retryLane=r!==0&&r<n?r:n}}function Ad(e,n){ox(e,n),(e=e.alternate)&&ox(e,n)}function lx(e){if(e.tag===13){var n=ta(e,67108864);n!==null&&xn(n,e,67108864),Ad(e,67108864)}}var xl=!0;function Nk(e,n,r,c){var f=H.T;H.T=null;var g=P.p;try{P.p=2,Cd(e,n,r,c)}finally{P.p=g,H.T=f}}function Tk(e,n,r,c){var f=H.T;H.T=null;var g=P.p;try{P.p=8,Cd(e,n,r,c)}finally{P.p=g,H.T=f}}function Cd(e,n,r,c){if(xl){var f=Ed(c);if(f===null)pd(e,n,c,yl,r),ux(e,c);else if(Ck(f,e,n,r,c))c.stopPropagation();else if(ux(e,c),n&4&&-1<Ak.indexOf(e)){for(;f!==null;){var g=Gi(f);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var b=jt(g.pendingLanes);if(b!==0){var N=g;for(N.pendingLanes|=2,N.entangledLanes|=2;b;){var M=1<<31-Ct(b);N.entanglements[1]|=M,b&=~M}Kn(g),(at&6)===0&&(tl=je()+500,kr(0))}}break;case 13:N=ta(g,2),N!==null&&xn(N,g,2),sl(),Ad(g,2)}if(g=Ed(c),g===null&&pd(e,n,c,yl,r),g===f)break;f=g}f!==null&&c.stopPropagation()}else pd(e,n,c,null,r)}}function Ed(e){return e=Lc(e),Md(e)}var yl=null;function Md(e){if(yl=null,e=Ii(e),e!==null){var n=u(e);if(n===null)e=null;else{var r=n.tag;if(r===13){if(e=d(n),e!==null)return e;e=null}else if(r===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null)}}return yl=e,null}function cx(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Ut()){case ln:return 2;case ze:return 8;case it:case gt:return 32;case At:return 268435456;default:return 32}default:return 32}}var zd=!1,Bs=null,$s=null,Us=null,Mr=new Map,zr=new Map,Hs=[],Ak="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function ux(e,n){switch(e){case"focusin":case"focusout":Bs=null;break;case"dragenter":case"dragleave":$s=null;break;case"mouseover":case"mouseout":Us=null;break;case"pointerover":case"pointerout":Mr.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":zr.delete(n.pointerId)}}function Rr(e,n,r,c,f,g){return e===null||e.nativeEvent!==g?(e={blockedOn:n,domEventName:r,eventSystemFlags:c,nativeEvent:g,targetContainers:[f]},n!==null&&(n=Gi(n),n!==null&&lx(n)),e):(e.eventSystemFlags|=c,n=e.targetContainers,f!==null&&n.indexOf(f)===-1&&n.push(f),e)}function Ck(e,n,r,c,f){switch(n){case"focusin":return Bs=Rr(Bs,e,n,r,c,f),!0;case"dragenter":return $s=Rr($s,e,n,r,c,f),!0;case"mouseover":return Us=Rr(Us,e,n,r,c,f),!0;case"pointerover":var g=f.pointerId;return Mr.set(g,Rr(Mr.get(g)||null,e,n,r,c,f)),!0;case"gotpointercapture":return g=f.pointerId,zr.set(g,Rr(zr.get(g)||null,e,n,r,c,f)),!0}return!1}function dx(e){var n=Ii(e.target);if(n!==null){var r=u(n);if(r!==null){if(n=r.tag,n===13){if(n=d(r),n!==null){e.blockedOn=n,un(e.priority,function(){if(r.tag===13){var c=gn();c=lt(c);var f=ta(r,c);f!==null&&xn(f,r,c),Ad(r,c)}});return}}else if(n===3&&r.stateNode.current.memoizedState.isDehydrated){e.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}e.blockedOn=null}function bl(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var r=Ed(e.nativeEvent);if(r===null){r=e.nativeEvent;var c=new r.constructor(r.type,r);_c=c,r.target.dispatchEvent(c),_c=null}else return n=Gi(r),n!==null&&lx(n),e.blockedOn=r,!1;n.shift()}return!0}function fx(e,n,r){bl(e)&&r.delete(n)}function Ek(){zd=!1,Bs!==null&&bl(Bs)&&(Bs=null),$s!==null&&bl($s)&&($s=null),Us!==null&&bl(Us)&&(Us=null),Mr.forEach(fx),zr.forEach(fx)}function vl(e,n){e.blockedOn===n&&(e.blockedOn=null,zd||(zd=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Ek)))}var wl=null;function hx(e){wl!==e&&(wl=e,s.unstable_scheduleCallback(s.unstable_NormalPriority,function(){wl===e&&(wl=null);for(var n=0;n<e.length;n+=3){var r=e[n],c=e[n+1],f=e[n+2];if(typeof c!="function"){if(Md(c||r)===null)continue;break}var g=Gi(r);g!==null&&(e.splice(n,3),n-=3,Mu(g,{pending:!0,data:f,method:r.method,action:c},c,f))}}))}function _r(e){function n(M){return vl(M,e)}Bs!==null&&vl(Bs,e),$s!==null&&vl($s,e),Us!==null&&vl(Us,e),Mr.forEach(n),zr.forEach(n);for(var r=0;r<Hs.length;r++){var c=Hs[r];c.blockedOn===e&&(c.blockedOn=null)}for(;0<Hs.length&&(r=Hs[0],r.blockedOn===null);)dx(r),r.blockedOn===null&&Hs.shift();if(r=(e.ownerDocument||e).$$reactFormReplay,r!=null)for(c=0;c<r.length;c+=3){var f=r[c],g=r[c+1],b=f[Jt]||null;if(typeof g=="function")b||hx(r);else if(b){var N=null;if(g&&g.hasAttribute("formAction")){if(f=g,b=g[Jt]||null)N=b.formAction;else if(Md(f)!==null)continue}else N=b.action;typeof N=="function"?r[c+1]=N:(r.splice(c,3),c-=3),hx(r)}}}function Rd(e){this._internalRoot=e}kl.prototype.render=Rd.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(a(409));var r=n.current,c=gn();rx(r,c,e,n,null,null)},kl.prototype.unmount=Rd.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;rx(e.current,2,null,e,null,null),sl(),n[Hi]=null}};function kl(e){this._internalRoot=e}kl.prototype.unstable_scheduleHydration=function(e){if(e){var n=si();e={blockedOn:null,target:e,priority:n};for(var r=0;r<Hs.length&&n!==0&&n<Hs[r].priority;r++);Hs.splice(r,0,e),r===0&&dx(e)}};var mx=t.version;if(mx!=="19.1.0")throw Error(a(527,mx,"19.1.0"));P.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(a(188)):(e=Object.keys(e).join(","),Error(a(268,e)));return e=m(n),e=e!==null?p(e):null,e=e===null?null:e.stateNode,e};var Mk={bundleType:0,version:"19.1.0",rendererPackageName:"react-dom",currentDispatcherRef:H,reconcilerVersion:"19.1.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var jl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!jl.isDisabled&&jl.supportsFiber)try{cn=jl.inject(Mk),xt=jl}catch{}}return Or.createRoot=function(e,n){if(!l(e))throw Error(a(299));var r=!1,c="",f=Mp,g=zp,b=Rp,N=null;return n!=null&&(n.unstable_strictMode===!0&&(r=!0),n.identifierPrefix!==void 0&&(c=n.identifierPrefix),n.onUncaughtError!==void 0&&(f=n.onUncaughtError),n.onCaughtError!==void 0&&(g=n.onCaughtError),n.onRecoverableError!==void 0&&(b=n.onRecoverableError),n.unstable_transitionCallbacks!==void 0&&(N=n.unstable_transitionCallbacks)),n=ix(e,1,!1,null,null,r,c,f,g,b,N,null),e[Hi]=n.current,md(e),new Rd(n)},Or.hydrateRoot=function(e,n,r){if(!l(e))throw Error(a(299));var c=!1,f="",g=Mp,b=zp,N=Rp,M=null,K=null;return r!=null&&(r.unstable_strictMode===!0&&(c=!0),r.identifierPrefix!==void 0&&(f=r.identifierPrefix),r.onUncaughtError!==void 0&&(g=r.onUncaughtError),r.onCaughtError!==void 0&&(b=r.onCaughtError),r.onRecoverableError!==void 0&&(N=r.onRecoverableError),r.unstable_transitionCallbacks!==void 0&&(M=r.unstable_transitionCallbacks),r.formState!==void 0&&(K=r.formState)),n=ix(e,1,!0,n,r??null,c,f,g,b,N,M,K),n.context=ax(null),r=n.current,c=gn(),c=lt(c),f=Ss(c),f.callback=null,Ns(r,f,c),r=c,n.current.lanes=r,He(n,r),Kn(n),e[Hi]=n.current,md(e),new kl(n)},Or.version="19.1.0",Or}var Sx;function Yk(){if(Sx)return Od.exports;Sx=1;function s(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(t){console.error(t)}}return s(),Od.exports=Gk(),Od.exports}var Vk=Yk();const Kk=1,mf=16*1024*1024;class Kf extends Error{constructor(t){super(t?.message??"ALP daemon request failed"),this.code=t?.code,this.data=t?.data}}const Fk=Object.freeze({failed:1e3,notFound:1001,forbidden:1003,conflict:1004,unavailable:1005,protocol:1006}),Hl=Object.freeze({maxReadBytes:1024*1024,maxListEntries:1e3,maxPathLength:4096,maxPreviewBytes:50*1024*1024,maxPreviewChunkBytes:8*1024*1024,maxFindEntries:1e3}),Ti=Object.freeze({maxPerPrincipal:4,maxPerDaemon:16,maxInputBytes:64*1024,maxOutputFrameBytes:64*1024,replayBytes:1024*1024,idleMs:1800*1e3,maxLifetimeMs:480*60*1e3,reconnectMs:60*1e3,minCols:2,maxCols:500,minRows:1,maxRows:200}),Sl=s=>typeof s=="string"&&/^term_[0-9a-f]{32}$/.test(s),Xk=new Set([".git",".alp",".ssh",".gnupg",".aws",".azure",".kube",".docker","gcloud"]),Pk=new Set([".netrc","_netrc",".npmrc",".yarnrc.yml",".pypirc",".pgpass",".htpasswd",".git-credentials",".dockercfg",".boto",".s3cfg",".mcp.json","auth.json","kubeconfig","settings.local.json",".vault-token","application_default_credentials.json","token.json"]),Qk=new Set(["gh/hosts.yml"]),Wk=new Set(["credential","credentials","secret","secrets"]),Zk=new Set(["ts","tsx","mts","cts","js","jsx","mjs","cjs","py","go","rs","java","kt","kts","rb","php","cs","swift","c","cc","cpp","h","hpp","m","mm","scala","dart","vue","svelte"]),Jk=new Set(["pem","key","p12","pfx","p8","jks","keystore","ppk","der","gpg","pgp","asc","kdbx","ovpn","tfstate","tfvars"]),e2=/^(?:\.env|id_|service[-_]?account)|_history$|\.tfstate\.backup$/;function Bi(s){let t="";for(const i of String(s).toLowerCase().split(/[\\/]/)){if(!i)continue;if(Qk.has(`${t}/${i}`)||(t=i,Xk.has(i)||Pk.has(i)||e2.test(i)))return!0;const a=i.lastIndexOf("."),l=a>=0?i.slice(a+1):"";if(Jk.has(l))return!0;const u=i.replace(/^\.+/,"").split(".");if(u.length>1&&u.pop(),u.some(d=>Wk.has(d))&&!Zk.has(l))return!0}return!1}const yb=Symbol.for("@anhlp/alp-client/AlpClientError");class st extends Error{constructor(t,{reason:i,cause:a,data:l}){super(t,a===void 0?void 0:{cause:a}),this.name="AlpClientError",this.reason=i,this.data=l,Object.defineProperty(this,yb,{value:!0})}}function Ff(s,t){return typeof s=="object"&&s!==null&&s[yb]===!0&&(t===void 0||s.reason===t)}function no(s){let t=0;for(let i=0;i<s.length;i++){const a=s.charCodeAt(i);a<128?t+=1:a<2048?t+=2:a>=55296&&a<=56319&&i+1<s.length&&(s.charCodeAt(i+1)&64512)===56320?(t+=4,i++):t+=3}return t}const t2=2147483647;function pf(s,t="timeoutMs"){if(!(s===void 0||s===1/0)){if(typeof s!="number"||Number.isNaN(s)||s<0)throw new TypeError(`${t} must be a non-negative number of milliseconds`);return s>t2?void 0:s}}const Dr="ALP daemon connection closed",n2=4096,s2=s=>{setTimeout(()=>{throw s},0)};function i2(s){for(const t of["send","onMessage","onClose","close"])if(typeof s?.[t]!="function")throw new TypeError(`ALP transport must implement ${t}()`)}const Nx=s=>new st("ALP request aborted",{reason:"aborted",cause:s.reason}),qr=(s,t)=>Object.prototype.hasOwnProperty.call(s,t);class a2{#e;#j=0;#p=new Map;#n=new Set;#i=new Set;#m=new Set;#r=new Set;#f=[];#a;#s;#g;#c;#y;constructor(t,{maxPending:i=n2,maxFrame:a=mf,timeoutMs:l,onListenerError:u=s2}={}){i2(t),this.#e=t,this.#s=i,this.#g=a,pf(l),this.#c=l,this.#y=u,this.#f.push(t.onMessage(d=>this.#h(d))),this.#f.push(t.onClose(d=>this.#S(this.#w(d)))),t.state==="closed"&&this.#S(new st(Dr,{reason:"disconnected"}))}get closed(){return this.#a!==void 0}get pendingCount(){return this.#p.size}request(t,i={},{signal:a,timeoutMs:l=this.#c}={}){if(this.#a)return Promise.reject(new st(Dr,{reason:this.#a.reason==="closed"?"closed":"disconnected",cause:this.#a}));if(a?.aborted)return Promise.reject(Nx(a));if(this.#p.size>=this.#s)return Promise.reject(new st(`Too many ALP requests waiting for an answer (${this.#s})`,{reason:"overloaded"}));let u;try{u=pf(l)}catch(m){return Promise.reject(m)}const d=++this.#j;let h;try{h=JSON.stringify({jsonrpc:"2.0",id:d,method:t,params:i})}catch(m){return Promise.reject(m)}return no(h)>=this.#g?Promise.reject(new st(`ALP request ${t} exceeds the ${this.#g}-byte frame limit`,{reason:"send_failed"})):new Promise((m,p)=>{let x;const y=()=>{this.#p.delete(d)&&(v(),p(Nx(a)))},v=()=>{x!==void 0&&clearTimeout(x),a?.removeEventListener("abort",y)};this.#p.set(d,{resolve:m,reject:p,cleanup:v}),u!==void 0&&(x=setTimeout(()=>{this.#p.delete(d)&&(v(),p(new st(`ALP request ${t} timed out after ${l} ms`,{reason:"timeout"})))},u)),a?.addEventListener("abort",y,{once:!0});try{this.#e.send(h)}catch(k){this.#e.state==="closed"?this.#S(new st(Dr,{reason:"disconnected",cause:k})):this.#p.delete(d)&&(v(),p(new st(`Could not send ALP request ${t}: ${k instanceof Error?k.message:String(k)}`,{reason:"send_failed",cause:k})))}})}onEvent(t){return this.#v(this.#n,t)}onNotification(t){return this.#v(this.#i,t)}onRequest(t){return this.#v(this.#r,t)}onClose(t){return this.#v(this.#m,t)}close(){this.#a||this.#S(new st(Dr,{reason:"closed"}))}#v(t,i){if(typeof i!="function")throw new TypeError("ALP client listener must be a function");return this.#a?()=>!1:(t.add(i),()=>t.delete(i))}#w(t={}){if(t.error instanceof st)return t.error;const i=t.code!==void 0||t.reason?{code:t.code,reason:t.reason}:void 0;return new st(t.error?.message??Dr,{reason:"disconnected",cause:t.error,data:i})}#b(t){this.#S(new st(t,{reason:"protocol"}))}#d(t,...i){try{t(...i)}catch(a){this.#y(a)}}#h(t){if(this.#a)return;if(typeof t!="string")return this.#b("Invalid frame from ALP daemon");let i;try{i=JSON.parse(t)}catch{return this.#b("Invalid frame from ALP daemon")}if(typeof i!="object"||i===null||Array.isArray(i))return this.#b("Invalid frame from ALP daemon");const a=i.id!==void 0&&i.id!==null;if(i.method==="event"){for(const u of[...this.#n])this.#d(u,i.params);for(const u of[...this.#i])this.#d(u,i.method,i.params);return}if(typeof i.method=="string"&&a&&!qr(i,"result")&&!qr(i,"error"))return this.#k(i.id,i.method,i.params??{});if(typeof i.method=="string"&&!a){for(const u of[...this.#i])this.#d(u,i.method,i.params);return}const l=this.#p.get(i.id);l&&(this.#p.delete(i.id),l.cleanup(),qr(i,"error")&&typeof i.error=="object"&&i.error!==null?l.reject(new Kf(i.error)):qr(i,"result")&&!qr(i,"error")?l.resolve(i.result):l.reject(new st("Malformed response from ALP daemon",{reason:"protocol",data:{id:i.id}})))}#k(t,i,a){const l=m=>{try{const p=JSON.stringify({jsonrpc:"2.0",id:t,...m});return no(p)<this.#g?p:void 0}catch{return}},u=m=>{if(!this.#a){if(m===void 0)return this.#S(new st("ALP reply exceeds the frame limit",{reason:"protocol"}));try{this.#e.send(m)}catch(p){this.#S(new st("Could not send ALP reply",{reason:"send_failed",cause:p}))}}},d=m=>{const p=m&&typeof m.code=="number"?m.code:1e3,x=m instanceof Error?m.message:String(m),y=x.length>2e3?`${x.slice(0,2e3)}...`:x,v=m&&m.data!==void 0?{data:m.data}:{};return l({error:{code:p,message:y,...v}})??l({error:{code:p,message:y}})??l({error:{code:-32603,message:"The reply could not be sent"}})},[h]=this.#r;if(!h)return u(d(Object.assign(new Error(`Unknown method '${i}'`),{code:-32601})));Promise.resolve().then(async()=>{try{const m=await h(i,a),p=l({result:m===void 0?{}:m});u(p??d(new Error(`The result of ${i} cannot be serialized or exceeds the ${this.#g}-byte frame limit`)))}catch(m){u(d(m))}})}#S(t){if(this.#a)return;this.#a=t;for(const l of this.#f.splice(0))try{l()}catch{}try{this.#e.close()}catch{}const i=[...this.#p.values()];this.#p.clear();for(const l of i)l.cleanup(),l.reject(t);const a=[...this.#m];this.#n.clear(),this.#i.clear(),this.#r.clear(),this.#m.clear();for(const l of a)this.#d(l,t)}}const r2="principal.agent";function Tx(s,t={name:"alp",version:"0"},i,{agent:a=!1}={}){return s.request("daemon.hello",{protocolVersion:Kk,client:t,...a?{capabilities:[r2]}:{}},i)}function o2(s,{initialMs:t=250,maxMs:i=1e4,factor:a=2,jitter:l=.2}={},u=Math.random){const d=Math.min(i,t*a**Math.max(0,s-1));return Math.max(0,Math.round(d*(1+l*(2*u()-1))))}function l2(s){return!(s instanceof Kf&&s.code===Fk.protocol)}function c2(){if(typeof globalThis.AbortController=="function"){const i=new globalThis.AbortController;return{signal:i.signal,abort:a=>i.abort(a)}}const s=new Set,t={aborted:!1,reason:void 0,addEventListener(i,a){s.add(a)},removeEventListener(i,a){s.delete(a)}};return{signal:t,abort(i){if(!t.aborted){t.aborted=!0,t.reason=i;for(const a of[...s])a();s.clear()}}}}function Ax({connect:s,onConnect:t,onDisconnect:i,backoff:a={},maxAttempts:l=1/0,stableMs:u=5e3,shouldRetry:d=l2,client:h,random:m=Math.random}){if(typeof s!="function")throw new TypeError("createReconnectingClient needs connect()");let p="connecting",x,y=0,v=!1,k;const S=c2(),j=new Set,A=new Set,R=new Set,q=new Set,L=h?.onListenerError??(E=>{setTimeout(()=>{throw E},0)}),O=(E,...V)=>{try{E(...V)}catch(U){L(U)}},B=(E,V)=>{p=E;for(const U of[...R])if(O(U,E,V),p!==E)return;if(E==="open"&&x)for(const U of[...q])q.delete(U),U.resolve(x);if(E==="stopped")for(const U of[...q])q.delete(U),U.reject(V??new st("ALP connection stopped",{reason:"closed"}))},_=E=>{if(p!=="stopped"){if(y>=l||!d(E))return B("stopped",E);B("waiting",E),p==="waiting"&&(k=setTimeout(()=>{k=void 0,W()},o2(y,a,m)))}},W=async()=>{if(p==="stopped")return;y++,B("connecting");const{signal:E}=S;if(p!=="connecting"||E.aborted)return;let V;const U=()=>V?.close();E.addEventListener("abort",U,{once:!0});try{const se=await s({attempt:y,signal:E});if(E.aborted){try{se.close()}catch{}return}if(V=new a2(se,h),V.onEvent(fe=>{for(const H of[...j])O(H,fe)}),V.onNotification((fe,H)=>{for(const P of[...A])O(P,fe,H)}),t&&await t(V,{attempt:y,reconnect:v,signal:E}),E.aborted){V.close();return}if(V.closed)throw new st("ALP connection closed during onConnect",{reason:"disconnected"})}catch(se){return V?.close(),E.aborted?void 0:_(se instanceof Error?se:new Error(String(se)))}finally{E.removeEventListener("abort",U)}const de=V;x=de;const J=v;v=!0;const me=Date.now();de.onClose(se=>{x===de&&(x=void 0,Date.now()-me>=u&&(y=0),O(()=>i?.(se,{reconnect:J})),_(se))}),B("open")};return W(),{get state(){return p},get client(){return x},get attempt(){return y},ready({signal:E}={}){return p==="open"&&x?Promise.resolve(x):p==="stopped"?Promise.reject(new st("ALP connection stopped",{reason:"closed"})):new Promise((V,U)=>{const de={resolve:me=>{E?.removeEventListener("abort",J),V(me)},reject:me=>{E?.removeEventListener("abort",J),U(me)}},J=()=>{q.delete(de),U(new st("Waiting for the ALP connection was aborted",{reason:"aborted",cause:E?.reason}))};if(E?.aborted)return J();q.add(de),E?.addEventListener("abort",J,{once:!0})})},request(E,V,U){return p!=="open"||!x?Promise.reject(new st("ALP daemon connection closed",{reason:p==="stopped"?"closed":"disconnected"})):x.request(E,V,U)},onEvent(E){return j.add(E),()=>j.delete(E)},onNotification(E){return A.add(E),()=>A.delete(E)},onState(E){return R.add(E),()=>R.delete(E)},stop(){if(p==="stopped")return;k!==void 0&&(clearTimeout(k),k=void 0),S.abort(new st("ALP connection stopped",{reason:"closed"}));const E=x;x=void 0,B("stopped"),E?.close(),j.clear(),A.clear(),R.clear()}}}const wi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function u2(s){let t="",i=0;for(;i+2<s.length;i+=3){const a=s[i]<<16|s[i+1]<<8|s[i+2];t+=wi[a>>18]+wi[a>>12&63]+wi[a>>6&63]+wi[a&63]}if(i<s.length){const a=s[i]<<16|(i+1<s.length?s[i+1]:0)<<8;t+=wi[a>>18]+wi[a>>12&63]+(i+1<s.length?wi[a>>6&63]:"=")+"="}return t}async function bb(s){const t=globalThis.crypto?.subtle;if(!t)throw new Error("SHA-256 needs WebCrypto here; pass sha256 yourself");const i=new Uint8Array(await t.digest("SHA-256",s));return Array.from(i,a=>a.toString(16).padStart(2,"0")).join("")}function $d(s){const t={begin:i=>s.request("attachment.begin",i),chunk:i=>s.request("attachment.chunk",i),commit:i=>s.request("attachment.commit",i),abort:i=>s.request("attachment.abort",{uploadId:i}),get:i=>s.request("attachment.get",{attachmentId:i}),delete:i=>s.request("attachment.delete",{attachmentId:i}),upload({sessionId:i,name:a,mimeType:l,data:u,requestId:d,sha256:h,maxChunkBytes:m,signal:p,onBegun:x,onProgress:y}){let v,k=!1,S;const j=()=>k||(p?.aborted??!1),A=()=>S??p?.reason??new Error("Upload aborted"),R=()=>{v&&t.abort(v).catch(()=>{})};p?.addEventListener?.("abort",R,{once:!0});const q=(async()=>{try{if(j())throw A();const L=h??await bb(u);if(j())throw A();const O=await t.begin({sessionId:i,name:a,size:u.length,mimeType:l,sha256:L,requestId:d});v=O.uploadId;try{x?.(O.uploadId)}catch(W){throw O.state!=="committed"&&await t.abort(O.uploadId).catch(()=>{}),W}if(j())throw O.state!=="committed"&&await t.abort(O.uploadId).catch(()=>{}),A();if(O.state==="committed"&&O.attachmentId)return(await t.get(O.attachmentId)).attachment;const B=Math.max(1,Math.min(O.maxChunkBytes,m??1/0));let _=O.received;for(let W=0;_<u.length;){if(j())throw await t.abort(O.uploadId).catch(()=>{}),A();const E=Math.min(u.length,_+B);try{const{received:V}=await t.chunk({uploadId:O.uploadId,offset:_,data:u2(u.subarray(_,E))});_=V}catch(V){if(j())throw await t.abort(O.uploadId).catch(()=>{}),A();const U=V?.data;if(U?.reason!=="offset_mismatch"||!Number.isSafeInteger(U.received)||++W>3)throw V;_=U.received;continue}if(j())throw await t.abort(O.uploadId).catch(()=>{}),A();try{y?.(_,u.length)}catch(V){throw await t.abort(O.uploadId).catch(()=>{}),V}}if(j())throw await t.abort(O.uploadId).catch(()=>{}),A();return(await t.commit({uploadId:O.uploadId,sha256:L})).attachment}finally{p?.removeEventListener?.("abort",R)}})();return Object.defineProperty(q,"uploadId",{get:()=>v,enumerable:!0}),q.abort=async L=>{k=!0,S=L??new Error("Upload aborted"),v&&await t.abort(v).catch(()=>{})},q}};return t}function d2(s,t){const i=t.capabilities.includes("terminal.watch")&&!!s.onNotification;let a=!1,l="",u="",d=!1,h;const m=new Map,p=s.onNotification?.((j,A)=>{a||!i||j!=="terminal.changed"||!/^[0-9a-f]{32}$/.test(A?.watchId)||!/^[0-9a-f]{32}$/.test(A?.cursor)||(m.size>=4&&!m.has(A.watchId)&&m.delete(m.keys().next().value??""),m.set(A.watchId,A.cursor),A.watchId===l&&A.cursor!==u&&(d=!0,x()))});function x(){return a?Promise.resolve():h||(h=(async()=>{do{d=!1;try{const j=await s.request(i?"terminal.watch":"terminal.list",{...t.workspaceId?{workspaceId:t.workspaceId}:{},...i&&u?{after:u}:{}});if(a)return;if(!Array.isArray(j?.terminals))throw new Error("Invalid terminal directory snapshot");if(i){if(!/^[0-9a-f]{32}$/.test(j.watchId)||!/^[0-9a-f]{32}$/.test(j.cursor)||typeof j.reset!="boolean")throw new Error("Invalid terminal directory cursor");l=j.watchId,u=j.cursor,d=m.has(l)&&m.get(l)!==u,m.clear()}t.onSnapshot(j.terminals)}catch(j){t.onError?.(j);return}}while(d&&!a)})().finally(()=>{h=void 0}),h)}const y=i?void 0:setInterval(()=>{x()},t.pollMs??5e3);let v=()=>{};function k(j=!0){a||(a=!0,y!==void 0&&clearInterval(y),p?.(),v(),m.clear(),i&&j&&s.request("terminal.unwatch",{}).catch(()=>{}))}return v=s.onClose(()=>k(!1)),a&&v(),t.onMode?.(i?"events":"polling"),{ready:x(),refresh:x,close:k,mode:i?"events":"polling"}}class Ra extends Error{constructor(t="The gateway refused this access token. It may be mistyped, revoked, rotated or expired."){super(t),this.name="AuthenticationError"}}class Pe extends Error{constructor(t){super(t),this.name="ConfigurationError"}}class Ni extends Error{constructor(t){super(t),this.name="TransientError"}}class vb extends Error{constructor(t,i){super(t),this.name="CreateOutcomeUnknownError",this.sessionId=i}}const f2=new Set(["attachment_unsupported","attachment_limit","attachment_unavailable","attachment_too_large","attachment_forbidden","attachment_referenced","quota_exceeded","invalid_name","invalid_data","hash_mismatch","upload_incomplete","chunk_conflict","offset_mismatch","request_conflict","persistence_failed","upload_expired"]),h2=s=>s&&typeof s=="object"&&s.data&&typeof s.data.reason=="string"?s.data.reason:void 0,Xf=s=>s instanceof Kf||!!s&&typeof s=="object"&&typeof s.code=="number"&&!Ff(s);function Ud(s){const t=Xf(s)?s.code:void 0;return t===1001||t===1003||t===-32601||t===-32602}function Be(s){if(s instanceof Ra)return{message:s.message,sent:"no",terminal:!0};if(s instanceof Pe)return{message:s.message,sent:"no",terminal:!0};if(s instanceof Ni)return{message:s.message,sent:"no",terminal:!1};if(s instanceof vb)return{message:s.message,sent:"unknown",terminal:!1};if(Ff(s))switch(s.reason){case"send_failed":case"overloaded":return{message:"The request could not be sent. Nothing reached the host.",sent:"no",terminal:!1};case"closed":return{message:"Disconnected from the host.",sent:"unknown",terminal:!1};case"timeout":return{message:"The host did not answer in time. The request may still have run.",sent:"unknown",terminal:!1};case"aborted":return{message:"Stopped waiting for the host. The request may still have run.",sent:"unknown",terminal:!1};case"protocol":return{message:"The host sent something this app does not understand.",sent:"unknown",terminal:!1};default:return{message:"The connection dropped before the host answered. The request may still have run.",sent:"unknown",terminal:!1}}if(Xf(s)){const t=typeof s.code=="number"?s.code:1e3,i=h2(s),a={code:t,...i?{reason:i}:{},sent:"yes",terminal:!1};if(t===1e3&&(i==="gateway_timeout"||i==="daemon_disconnected"))return{...a,sent:"unknown",message:i==="gateway_timeout"?"The host took too long to answer. The request may still have run.":"The gateway lost the host before it answered. The request may still have run."};if(t===1004&&i==="outcome_unknown")return{...a,sent:"unknown",message:"The host cannot tell whether the agent received this message. Check the conversation before sending it again."};if(i&&f2.has(i)&&s.message)return{...a,message:/[.!?]$/.test(s.message)?s.message:`${s.message}.`};if(t===1005&&i==="not_sent")return{...a,sent:"no",message:"The gateway was too busy to pass the request on. Nothing reached the host."};if(t===1005&&i==="rate_limited")return{...a,sent:"no",message:"Too many requests at once. Wait a moment and try again."};if(t===1005&&i==="too_many_pending")return{...a,sent:"no",message:"Too many requests are waiting. Wait a moment and try again."};if(t===1005&&i==="busy")return{...a,message:"Tasks are locked by another writer on the host. Try again in a moment."};if(t===1003&&i==="grant"){const l=s.data?.permission;return{...a,message:`Your access token does not allow this${l?` (needs ${l})`:""}.`}}return t===1003&&i==="mode"?{...a,message:"Your access token cannot drive a session in this mode. Ask the host owner for a token with that mode, or use a session in a granted mode."}:t===1003&&i==="outside_workspace"?{...a,message:"That workspace is not granted to your access token."}:t===1003&&i==="spec_field"?{...a,message:"The host refused one of the session settings."}:t===1003&&i==="content_type"?{...a,message:s.message?/[.!?]$/.test(s.message)?s.message:`${s.message}.`:"This message contains content the host does not accept."}:t===1003?{...a,message:"The host refused this request."}:t===1001?{...a,message:"Not found on the host. It may have been removed or expired."}:t===1004&&i==="revision_conflict"?{...a,message:"It changed on the host meanwhile. The latest version is shown; try again if you still want to."}:t===1004&&i==="task_state"?{...a,message:"The task's current state does not allow that."}:t===1004&&i==="key_conflict"?{...a,message:"That request id was already used for something else."}:t===-32601?{...a,message:"The host does not offer this through the gateway."}:t===-32602?{...a,message:"The host refused the request as invalid."}:t===1006?{...a,terminal:!0,message:"This host speaks a different protocol version. Update ALP on the host or this app."}:{...a,message:s.message?`The host could not do that: ${s.message}`:"The host could not do that."}}return{message:s instanceof Error&&s.message?s.message:"Something went wrong.",sent:"unknown",terminal:!1}}const Ir=Object.freeze({blocked_path:"This file is never shown remotely: secrets, keys, .git and ALP configuration are blocked.",ignored:"This file is ignored by .gitignore, so it is hidden by default.",linked:"This path is a link, or it changed while it was read. Links are not followed.",binary:"Binary preview unavailable",too_large:"This file is too large to display",not_found:"This file or folder is not on the host. It may have been moved or removed.",invalid_path:"That is not a valid path in this workspace.",not_directory:"The workspace folder cannot be read on the host."});class Ai extends Error{constructor(t){super(t.message),this.name="FileAccessError",this.failure=t,this.reason=t.reason}}function m2(s){if(s instanceof Ai)return s.failure;const t=Be(s),i=t.reason;if(!Xf(s)||!i)return t;const a=Ir[i];return!a||i==="not_found"&&t.code!==1001?t:{...t,message:a}}const Hd=["name","modified","size"],Id=Object.freeze({name:"Name",modified:"Modified",size:"Size"});function Cx(s){const t=Hd.indexOf(s);return Hd[(t+1)%Hd.length]}function Qs(s){if(typeof s!="string")return;let t=s;for(;t.startsWith("./");)t=t.slice(2);if(!(!t||t.length>Hl.maxPathLength)&&!(t.startsWith("/")||/^[a-zA-Z]:/.test(t)||/[\\\0]/.test(t))&&!t.split("/").some(i=>!i||i==="."||i===".."))return t}const gf=s=>{const t=typeof s=="string"?Date.parse(s):NaN;return Number.isFinite(t)?t:0};function p2(s,t){const i=t?`${t}/`:"",a=[],l=new Set;for(const d of Array.isArray(s?.entries)?s.entries:[]){if(!d||typeof d!="object")continue;const{name:h,kind:m}=d;if(typeof h!="string"||!h||h.includes("/")||m!=="file"&&m!=="directory")continue;const p=Qs(d.path);if(!(!p||p!==`${i}${h}`||Bi(p)||l.has(p))&&(l.add(p),a.push({name:h,path:p,kind:m,...m==="file"&&typeof d.size=="number"&&Number.isFinite(d.size)&&d.size>=0?{size:d.size}:{},...typeof d.modifiedAt=="string"&&gf(d.modifiedAt)?{modifiedAt:d.modifiedAt}:{}}),a.length>=Hl.maxListEntries))break}const u=Array.isArray(s?.entries)&&s.entries.length>Hl.maxListEntries;return{entries:a,truncated:s?.truncated===!0||u}}const g2=s=>s.startsWith(".");function x2(s,t){return[...s].sort((i,a)=>i.kind!==a.kind?i.kind==="directory"?-1:1:t==="modified"?gf(a.modifiedAt)-gf(i.modifiedAt)||i.name.localeCompare(a.name):t==="size"&&(a.size??0)-(i.size??0)||i.name.localeCompare(a.name))}function y2(s,t){return s.includes(t)?s.filter(i=>i!==t):[...s,t]}function b2(s,t,{sort:i,showHidden:a}){const l=new Set(t),u=[],d=(h,m)=>{const p=s[h];if(!p||p.status==="loading"){u.push({kind:"status",path:h,depth:m,status:"loading"});return}if(p.status==="error"){u.push({kind:"status",path:h,depth:m,status:"error",...p.error?{message:p.error}:{}});return}const x=x2((p.entries??[]).filter(y=>a||!g2(y.name)),i);x.length||u.push({kind:"status",path:h,depth:m,status:"empty"});for(const y of x){const v=y.kind==="directory"&&l.has(y.path);u.push({kind:"entry",entry:y,depth:m,open:v}),v&&d(y.path,m+1)}p.truncated&&u.push({kind:"status",path:h,depth:m,status:"truncated"})};return d("",0),u}function v2(s){return typeof s!="number"||!Number.isFinite(s)||s<0?"":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function w2(s){if(!s)return 0;const t=s.split(`
|
|
11
|
+
`).length;return s.endsWith(`
|
|
12
|
+
`)?t-1:t}const k2=s=>/\.(md|markdown|mdx)$/i.test(s),j2=0,Vr=1,Ex=Object.freeze({unsupportedData:4003,tooLarge:4009}),S2=250,N2=123;function xf(s){const t=/^([a-z][a-z0-9+.-]*:\/\/)(?:[^/?#\\]*@)?([^/?#\\@]*)([^?#]*)/i.exec(String(s));return t?`${t[1]}${t[2]}${t[3]}`:"<websocket>"}function Mx(s,t){const a=((s instanceof Error?s.message:String(s??"")).split(String(t)).join(xf(t))||"WebSocket error").replace(/[a-z][a-z0-9+.-]*:\/\/[^\s'"<>]+/gi,u=>xf(u)),l=new Error(a);return s instanceof Error&&s.name&&(l.name=s.name),l}function T2(s){let t=s;for(;no(t)>N2;)t=t.slice(0,-1);return t}function _l(s,t,i){if(!(s.readyState!==j2&&s.readyState!==Vr)){try{t===void 0?s.close():s.close(t,T2(i??""));return}catch{}try{s.close()}catch{}}}function wb(s){typeof s.addEventListener=="function"&&s.addEventListener("error",()=>{})}function _a(s,t,i){if(typeof s.addEventListener=="function")return s.addEventListener(t,i),()=>s.removeEventListener?.(t,i);const a=`on${t}`,l=s[a];return s[a]=u=>{l?.(u),i(u)},()=>{s[a]=l??null}}const kb=s=>{const t=s?.error instanceof Error&&s.error.message||typeof s?.message=="string"&&s.message||"WebSocket error";return s?.error instanceof Error&&s.error.message?s.error:new Error(t)};function A2(s,{maxFrame:t=mf,maxBufferedBytes:i=4*mf}={}){if(s.readyState!==Vr)throw new st("WebSocket is not open",{reason:"disconnected"});wb(s);try{s.binaryType="arraybuffer"}catch{}const a=new Set,l=new Set;let u;const d=[];let h,m;const p=y=>{if(u)return;u=y,m!==void 0&&clearTimeout(m);for(const k of d.splice(0))k();a.clear();const v=[...l];l.clear();for(const k of v)k(y)},x=(y,v)=>{const k=new st(y,{reason:"protocol"});_l(s,v,y),p({error:k})};return d.push(_a(s,"message",y=>{if(u)return;const v=y?.data;if(typeof v!="string")return x("Binary WebSocket messages are not ALP frames",Ex.unsupportedData);if(no(v)>t)return x(`ALP frame exceeds ${t} bytes`,Ex.tooLarge);for(const k of v.includes(`
|
|
13
|
+
`)?v.split(`
|
|
14
|
+
`):[v]){if(u)return;if(k.trim())for(const S of[...a])S(k)}})),d.push(_a(s,"close",y=>p({error:h,code:typeof y?.code=="number"?y.code:void 0,reason:typeof y?.reason=="string"&&y.reason?y.reason:void 0}))),d.push(_a(s,"error",y=>{h||(h=kb(y),m=setTimeout(()=>p({error:h}),S2),_l(s))})),{get state(){return u||s.readyState!==Vr?"closed":"open"},send(y){if(u||s.readyState!==Vr)throw new st("WebSocket is not open",{reason:"send_failed"});if((s.bufferedAmount??0)+no(y)>i)throw new st(`WebSocket send buffer is over ${i} bytes`,{reason:"send_failed"});s.send(y)},onMessage(y){return u?()=>!1:(a.add(y),()=>a.delete(y))},onClose(y){return u?()=>!1:(l.add(y),()=>l.delete(y))},close(){_l(s,1e3,"client closed"),p({code:1e3,reason:"client closed"})}}}function C2(s,{WebSocket:t,protocols:i,createSocket:a,signal:l,timeoutMs:u=15e3,...d}={}){const h=xf(s);let m;try{m=pf(u)}catch(y){return Promise.reject(y)}if(l?.aborted)return Promise.reject(new st(`Connecting to ${h} was aborted`,{reason:"aborted",cause:l.reason}));const p=t??globalThis.WebSocket;if(!a&&typeof p!="function")return Promise.reject(new TypeError("No WebSocket implementation: pass options.WebSocket or options.createSocket"));let x;try{x=a?a(s,i):i===void 0?new p(s):new p(s,i)}catch(y){return Promise.reject(new st(`Could not connect to ${h}`,{reason:"disconnected",cause:Mx(y,s)}))}return wb(x),new Promise((y,v)=>{const k=[];let S;const j=()=>{for(const L of k.splice(0))L();S!==void 0&&clearTimeout(S),l?.removeEventListener("abort",R)},A=L=>{j(),_l(x),v(L)},R=()=>A(new st(`Connecting to ${h} was aborted`,{reason:"aborted",cause:l?.reason})),q=()=>{j();try{y(A2(x,d))}catch(L){v(L)}};if(x.readyState===Vr)return q();k.push(_a(x,"open",q)),k.push(_a(x,"error",L=>A(new st(`Could not connect to ${h}`,{reason:"disconnected",cause:Mx(kb(L),s)})))),k.push(_a(x,"close",L=>A(new st(`Could not connect to ${h}`,{reason:"disconnected",data:{code:L?.code,reason:L?.reason||void 0}})))),l?.addEventListener("abort",R,{once:!0}),m!==void 0&&(S=setTimeout(()=>A(new st(`Connecting to ${h} timed out after ${u} ms`,{reason:"timeout"})),m))})}const E2=new Set(["localhost","127.0.0.1"]);function jb(s){let t;try{t=new URL(String(s).trim())}catch{throw new Pe("Enter the gateway address, such as https://alp.example.com or http://127.0.0.1:7434.")}if(t.username||t.password||t.search||t.hash)throw new Pe("Use a gateway address without a user name, password, query or fragment.");if(t.protocol!=="https:"&&!(t.protocol==="http:"&&E2.has(t.hostname)))throw new Pe("Use https, or http only on this machine (127.0.0.1 or localhost, for example through an SSH tunnel).");return`${t.origin}${t.pathname.replace(/\/+$/,"")}`}const Nl=s=>Array.isArray(s)&&s.every(t=>typeof t=="string");function M2(s){if(!s||typeof s!="object")return;const{websocket:t,subprotocols:i,principal:a}=s;if(t!=="/v1/ws"||!Nl(i)||!i.includes("alp.v1")||!a||typeof a.id!="string"||!Nl(a.permissions)||!Nl(a.workspaces)||a.modes!==void 0&&!Nl(a.modes))return;const l={id:a.id,...typeof a.label=="string"?{label:a.label}:{},permissions:[...a.permissions],workspaces:[...a.workspaces],...Array.isArray(a.workspaceRoots)?{workspaceRoots:a.workspaceRoots.filter(u=>u&&typeof u.path=="string"&&typeof u.canonical=="string").map(u=>({path:u.path,canonical:u.canonical}))}:{},...a.modes?{modes:[...a.modes]}:{}};return{websocket:t,subprotocols:i,principal:l}}async function z2(s){try{const t=await s.json();return typeof t?.error=="string"?t.error:void 0}catch{return}}function R2(s,t){const i=new AbortController,a=setTimeout(()=>i.abort(new Ni("The gateway did not answer in time.")),t),l=()=>i.abort(s?.reason);return s?.aborted?l():s?.addEventListener("abort",l,{once:!0}),{signal:i.signal,done(){clearTimeout(a),s?.removeEventListener("abort",l)}}}async function _2({url:s,token:t,signal:i,timeoutMs:a=15e3,fetch:l=globalThis.fetch.bind(globalThis),WebSocket:u}){const d=jb(s);if(!t||/\s/.test(t))throw new Ra("Enter the access token printed by alp-gateway credential create.");const h=R2(i,a);let m;try{m=await l(`${d}/v1/tickets`,{method:"POST",credentials:"omit",cache:"no-store",redirect:"error",referrerPolicy:"no-referrer",headers:{authorization:`Bearer ${t}`},signal:h.signal})}catch(p){throw h.done(),i?.aborted?i.reason??p:h.signal.reason instanceof Ni?h.signal.reason:new Ni("Cannot reach the gateway. Check that it is running at this address and that it allows this page's origin (alp-gateway serve --origin).")}try{if(m.status===401)throw new Ra;if(m.status===403){const v=await z2(m);throw new Pe(v==="tls_required"?"The gateway only accepts this connection over HTTPS.":"The gateway does not allow this page's origin. Start it with --origin set to this page's address.")}if(m.status===421)throw new Pe("The gateway does not know this host name. Add it with alp-gateway serve --public-host.");if(m.status===429)throw new Ni("The gateway is limiting requests from this address. Wait a moment.");if(m.status!==201)throw new Ni(`The gateway is not ready (HTTP ${m.status}).`);const p=M2(await m.json().catch(()=>{}));if(!p)throw new Pe("The gateway answered with an unexpected ticket. Check that the address points to an ALP gateway.");const x=`${d.replace(/^http/,"ws")}${p.websocket}`;return{transport:await C2(x,{protocols:p.subprotocols,signal:h.signal,timeoutMs:a,...u?{WebSocket:u}:{}}).catch(v=>{throw i?.aborted?i.reason??v:new Ni("The gateway accepted the token but the live connection failed. Retrying may help.")}),principal:p.principal}}finally{h.done()}}function Ll(s,t){return!s||!t?void 0:(s.workspaceRoots?.length?s.workspaceRoots:s.workspaces.map(a=>({path:a,canonical:a}))).find(a=>a.path===t||a.canonical===t)}function Te(s,t){return s?s.permissions.includes(t)?!0:t.endsWith(".read")&&s.permissions.includes(t.replace(/\.read$/,".write")):!1}const Pf="alp-web:link-token",L2=/^alpgw1\.[a-f0-9]{16}\.[A-Za-z0-9_-]{43}$/,O2="This link's access token is no longer valid. Run `alp web` again to open ALP with a new link.",D2="This page is not on this machine's loopback address, so it did not use the access token in its link. Open the address `alp web` printed.",q2="The access token in this link is incomplete or damaged. Run `alp web` again, or copy its whole address.",B2=new Set(["127.0.0.1","localhost"]),Sb=s=>typeof s=="string"&&L2.test(s);function $2(s){const t=String(s??"").replace(/^#/,"");if(!t)return;const i=new URLSearchParams(t);if(!i.has("token"))return;const a=i.get("token");return Sb(a)?{token:a}:{malformed:!0}}const Nb=s=>s.protocol==="http:"&&B2.has(s.hostname);function U2(s){let t;try{t=s?.getItem(Pf)}catch{return}if(t!=null){if(Sb(t))return t;Kr(s)}}function Kr(s){try{s?.removeItem(Pf)}catch{}}function Tb({location:s,history:t,storage:i}){const a=$2(s.hash);a&&t.replaceState(t.state,"",`${s.pathname}${s.search}`);const l=Nb(s);if(a&&("malformed"in a||!l))return Kr(i),{error:"malformed"in a?q2:D2};if(a){try{i?.setItem(Pf,a.token)}catch{}return{url:s.origin,token:a.token}}if(!l)return;const u=U2(i);return u?{url:s.origin,token:u}:void 0}const H2="http://127.0.0.1:7434",Ab=({location:s,dev:t=!1})=>!t&&Nb(s);function I2({location:s,remembered:t,dev:i=!1}){return t||(Ab({location:s,dev:i})?s.origin:H2)}function sc(s=16){const t=new Uint8Array(Math.ceil(s/2));return globalThis.crypto.getRandomValues(t),Array.from(t,i=>i.toString(16).padStart(2,"0")).join("").slice(0,s)}const G2=()=>`web_${sc(16)}`,Tl=()=>`web-msg-${sc(20)}`,Y2=()=>`web-task-${sc(16)}`,Qf=()=>`web-conv-${sc(16)}`,V2="Files in the workspace are not changed or restored: only the conversation goes back.",K2="Files are not copied: the fork works on the current files of where it runs.",yf={runtime_unsupported:"This session runs on a runtime that cannot fork or rewind its conversation.",not_persistent:"This session keeps no native conversation to fork or rewind.",not_root:"Only a main conversation can be forked or rewound; an agent's work belongs to its requester."},Al=Object.freeze({session_busy:"The session or one of its agents is still working. Wait until everything is idle, then try again.",stale_generation:"The conversation changed since this view loaded. It was reloaded; check it and try again.",turn_not_found:"That message is no longer part of this conversation. It was reloaded; try again.",turn_in_progress:"A turn is still running. Wait until it ends, then try again.",empty_prefix:"Nothing comes before the first message. Start a new session instead.",boundary_unmapped:"The agent's runtime cannot go back to exactly this point (that turn was not started by ALP). Choose another message.",runtime_unsupported:yf.runtime_unsupported,native_refused:"The agent's runtime refused it. Nothing changed.",outcome_unknown:"The host cannot tell whether it happened. Check the session list and this conversation before trying again; a new attempt is a new request.",key_conflict:"That request id was already used for something else. Try again.",branch_not_found:"That branch is no longer kept on the host.",not_root:yf.not_root,outside_workspace:"That workspace is not granted to your access token.",attachment_forbidden:"This conversation holds an attachment your access token may not use.",request_conflict:"A session with that id already exists.",persistence_failed:"The host could not finish saving it. Trying again finishes it.",invalid_params:"The host did not accept this request for this session. Reload the page and try again; if it keeps happening, this app and the host may run different versions of ALP."}),F2=s=>typeof s?.data?.reason=="string"?s.data.reason:void 0;function Oi(s){const t=s,i=F2(t),a=typeof t?.code=="number"?t.code:void 0,l=Be(s),u=l.sent!=="yes"&&i!=="outcome_unknown",d=i==="stale_generation"||i==="turn_not_found";if(i==="persistence_failed")return{message:Al.persistence_failed,reason:i,code:a,retrySame:!0,reload:!1};if(a===1003&&i==="grant")return{message:`Your access token cannot do this (it needs ${typeof t?.data?.permission=="string"?t.data.permission:"session.write"}).`,reason:i,code:a,retrySame:!1,reload:!1};if(a===1003&&i==="mode"){const h=Array.isArray(t?.data?.modes)?t.data.modes.filter(m=>typeof m=="string"):[];return{message:`Your access token cannot drive this conversation in its mode${h.length?` (it may use ${h.join(", ")})`:""}. Ask the host owner for a token with that mode.`,reason:i,code:a,retrySame:!1,reload:!1}}if(i&&Al[i])return{message:Al[i],reason:i,code:a,retrySame:!1,reload:d};if(u){const h=l.sent==="no"?" Trying again is safe.":" It may have happened: trying again sends the same request, which the host answers only once.";return{message:`${l.message}${l.terminal?"":h}`,...i?{reason:i}:{},code:a,retrySame:!l.terminal,reload:!1}}return a===-32601?{message:"This host does not offer it. Update ALP on the host.",code:a,retrySame:!1,reload:!1}:a===-32602?{message:Al.invalid_params,...i?{reason:i}:{},code:a,retrySame:!1,reload:!1}:{message:s instanceof Error&&s.message?s.message:"Something went wrong.",...i?{reason:i}:{},code:a,retrySame:!1,reload:d}}function X2({capabilities:s,canRead:t,canWrite:i,summary:a,busy:l=!1,generation:u,online:d=!0,driveBlock:h}){const m=a?.conversation,p=(k=void 0)=>({shown:!1,...k?{reason:k}:{}}),x=m?.reason?yf[m.reason]??`Not available here (${m.reason}).`:void 0,y=s.includes("session.history")&&!!u,v=k=>s.includes(`session.${k}`)?!m||m[k]!==!0?p(x):!i||k==="fork"&&!t?p("Your access token cannot change this conversation (it needs session.write)."):h?p(h):y?d?k==="rewind"&&l?{shown:!0,reason:"Wait until main and its agents are idle."}:{shown:!0}:{shown:!0,reason:"Reconnecting…"}:p("This host does not keep a history generation for this view."):p();return{fork:v("fork"),rewind:v("rewind")}}const P2="Restart the agent's process on the same conversation and settings, for example after a new sign-in. Its messages, history and files stay.",Fr=Object.freeze({session_busy:"The agent or one of its agents is still working. Wait until everything is idle, then reload.",session_closed:"The session is closed. Send it a message to open it again on its conversation.",no_history:"The agent has no conversation to keep yet. Send it a message first, or start a new session.",native_refused:"The agent could not be restarted on its conversation. The session was closed with its conversation kept; send it a message to open it again.",runtime_unsupported:"This session runs on a runtime the host cannot reload.",not_root:"Only the main agent of a session can be reloaded."});function Q2(s){const t=Oi(s),i=t.reason?Fr[t.reason]:void 0;return i?{...t,message:i}:t}function W2({capabilities:s,canRead:t,canWrite:i,summary:a,root:l,closed:u=!1,busy:d=!1,generation:h,online:m=!0,driveBlock:p}){const x=k=>({shown:!0,enabled:!1,reason:k}),y=s.includes("session.resumeCommand")?t?m?{shown:!0,enabled:!0}:x("Reconnecting…"):x("Your access token cannot read this session."):{shown:!1,enabled:!1};return{reload:(()=>{if(!s.includes("session.reload"))return{shown:!1,enabled:!1};if(!l)return x(Fr.not_root);const k=a?.conversation;return k?.reload!==!0?x(k?.reason==="not_persistent"?"This session keeps no native conversation to reload.":Fr.runtime_unsupported):i?p?x(p):u?x(Fr.session_closed):!s.includes("session.history")||!h?x("The conversation is still loading."):m?d?x("Wait until main and its agents are idle."):{shown:!0,enabled:!0}:x("Reconnecting…"):x("Your access token cannot reload agents (it needs session.write).")})(),resume:y}}function Z2(s,t={}){const i=new Map,a=s.turnOrder??[];for(const l of s.entries){if(l.sessionId!==s.rootId)continue;const u=l.item;if(u.kind!=="user_message"||typeof u.clientMessageId!="string")continue;const d=s.prompts[u.clientMessageId];if(!d||d.state!=="accepted"||d.result!=="turn"||!d.turnId)continue;const h=a.indexOf(d.turnId);h<0||i.set(l.key,{turnId:d.turnId,index:h,later:a.length-h,rewindable:h>0||!!t.hasOlder,ended:s.turns[d.turnId]==="ended",text:typeof u.text=="string"?u.text:""})}return i}function Wf(s){return s?.kind!=="notice"||typeof s.id!="string"?null:s.id.startsWith("rewind:")&&s.id.length>7?{kind:"rewind",branchId:s.id.slice(7)}:s.id.startsWith("fork:")&&s.id.length>5?{kind:"fork",sessionId:s.id.slice(5)}:null}const J2=s=>`${s} later turn${s===1?"":"s"}`,ej=s=>`${s} turn${s===1?"":"s"}`;function tj(s,t,i){const a=t?.find(u=>u.branchId===i)?.turns;if(typeof a=="number")return a;const l=/(\d+) later turn/.exec(String(s?.text??""));return l?Number(l[1]):void 0}const Il=Object.freeze({capability:"This host does not offer Git changes. Update ALP on the host.",registry:"This host does not list its workspaces, so Git changes cannot be shown. Update ALP on the host.",projectRead:"This access token cannot read Git status (needs project.read).",filesRead:"This access token cannot read file contents, so diffs are hidden (needs files.read).",workspace:"Choose a workspace to see its changes.",unregistered:"This workspace is not registered on the host, so its Git changes cannot be shown. The host owner can add it as a project.",loading:"Loading workspaces…"}),Gl=Object.freeze({not_repository:"Not a git repository",unknown_ref:"The base branch is not known in this repository.",invalid_compare:"The host refused this comparison. Pick Uncommitted or a branch name Git accepts.",stale_snapshot:"The checkout changed since this list was loaded. It was loaded again from the start.",invalid_cursor:"The rest of this list is no longer available. It was loaded again from the start.",git_unavailable:"Git is not available on the host.",git_failed:"Git failed on the host. Try again; the host's logs may say why.",blocked_path:"This file is never shown remotely: secrets, keys, .git and ALP configuration are blocked.",invalid_path:"That is not a valid path in this workspace."}),Cb=Object.freeze([{id:"uncommitted",label:"Uncommitted"},{id:"base",label:"Committed"},{id:"staged",label:"Staged"},{id:"unstaged",label:"Unstaged"}]),zx=Object.freeze({modified:"Modified",added:"New",deleted:"Deleted",renamed:"Renamed",copied:"Copied",typechange:"Type changed",untracked:"Untracked",conflicted:"Conflicted"}),nj=Object.freeze({modified:"M",added:"A",deleted:"D",renamed:"R",copied:"C",typechange:"T",untracked:"U",conflicted:"!"}),Eb=Object.freeze({binary:"Binary file",too_large:"Diff too large to display",withheld:"Content withheld: it looks like it holds a private key.",symlink:"Symbolic link: its target is not shown.",submodule:"Submodule: its content is not shown."});class gs extends Error{constructor(t){super(t.message),this.name="GitAccessError",this.failure=t,this.reason=t.reason}}function zi(s){if(s instanceof gs)return s.failure;const t=Be(s);if(t.code===1003&&t.reason==="grant"){const a=s?.data?.permission;return a==="files.read"?{...t,message:Il.filesRead}:a==="project.read"?{...t,message:Il.projectRead}:t}const i=t.reason?Gl[t.reason]:void 0;return i?{...t,message:i}:t}function sj(s){const t=zi(s);return t.code===1004&&t.reason==="stale_snapshot"||t.code===-32602&&t.reason==="invalid_cursor"}function Zf(s){const t=s.workspace;if(!t)return;const i=Ll(s.principal??void 0,t),a=new Set([t,...i?[i.path,i.canonical]:[]]);return s.registry.workspaces.filter(l=>a.has(l.directory)&&!l.archivedAt).sort((l,u)=>+!!u.pinnedAt-+!!l.pinnedAt||String(l.createdAt).localeCompare(String(u.createdAt))||l.id.localeCompare(u.id))[0]}function Gd(s){const t=l=>({status:!1,reason:l,message:Il[l]});if(!s.workspace)return t("workspace");if(!s.connection.capabilities.includes("workspace.git"))return t("capability");if(!Te(s.principal??void 0,"project.read"))return t("projectRead");if(!s.connection.capabilities.includes("workspace.registry"))return t("registry");const i=Zf(s);if(!i)return t(s.registry.loading?"loading":"unregistered");const a=Te(s.principal??void 0,"files.read");return{status:!0,workspaceId:i.id,content:a,...a?{}:{contentMessage:Il.filesRead}}}function ij(s){const t=typeof s=="string"&&s?Qs(s):void 0;return t&&!Bi(t)?t:void 0}function aj({mode:s,baseRef:t,ignoreWhitespace:i}){const a=Cb.some(l=>l.id===s)?s:"uncommitted";return{mode:a,...a==="base"&&t?{baseRef:t}:{},...i?{ignoreWhitespace:!0}:{}}}function Rx(s,t){const i=Array.isArray(t?.files)?t.files:[],a=Number.isSafeInteger(t?.hiddenCount)&&t.hiddenCount>0?t.hiddenCount:0,l=s&&s.snapshot===t.snapshot?s:void 0;return{compare:t.compare,snapshot:t.snapshot,files:l?[...l.files,...i]:[...i],hiddenCount:(l?.hiddenCount??0)+a,truncated:t.truncated===!0,...typeof t.nextCursor=="string"&&t.nextCursor?{nextCursor:t.nextCursor}:{}}}function rj(s){const t=[];for(const i of Array.isArray(s?.hunks)?s.hunks:[]){t.push({type:"hunk",text:`@@ -${i.oldStart},${i.oldCount} +${i.newStart},${i.newCount} @@${i.context?` ${i.context}`:""}`});let a=i.oldStart,l=i.newStart;for(const u of Array.isArray(i.lines)?i.lines:[]){const d=u.noNewline===!0?{noNewline:!0}:{};u.type==="add"?t.push({type:"add",text:u.content,newLine:l++,...d}):u.type==="remove"?t.push({type:"remove",text:u.content,oldLine:a++,...d}):t.push({type:"context",text:u.content,oldLine:a++,newLine:l++,...d})}}return t}function oj(s){let t=0,i=0;for(const a of s)t+=a.additions||0,i+=a.deletions||0;return{additions:t,deletions:i}}function _x(s){if(!Number.isFinite(s)||s<1e3)return String(Math.max(0,Math.floor(s||0)));const t=s/1e3;return`${t>=10?Math.round(t):Math.round(t*10)/10}k`}function Lx(s){const i=[s.branch??(s.detached&&s.head?`Detached at ${s.head.slice(0,7)}`:s.head?s.head.slice(0,7):"No commits yet")];if(s.upstream){const{ref:a,ahead:l,behind:u}=s.upstream;i.push(`${a}${l||u?` (${[l?`↑${l}`:"",u?`↓${u}`:""].filter(Boolean).join(" ")})`:""}`)}return i.join(" · ")}function lj(s){return s?s.replace(/^refs\/(heads|remotes)\//,"").trim():"base"}const Mb=Object.freeze(["image/png","image/jpeg","image/gif","image/webp"]),Ci=Object.freeze({maxCount:4,maxBytes:2*1024*1024,maxTotalBytes:2.5*1024*1024});function cj(s,t=!0){const i={maxCount:0,maxBytes:0,maxTotalBytes:0};if(!t)return i;if(s===void 0)return{...Ci};if(!s||typeof s!="object"||Array.isArray(s))return i;const a=s;if(!["maxCount","maxBytes","maxTotalBytes"].every(u=>Number.isSafeInteger(a[u])&&a[u]>=0))return i;const l=Math.min(Ci.maxTotalBytes,a.maxTotalBytes);return{maxCount:Math.min(Ci.maxCount,a.maxCount),maxBytes:Math.min(Ci.maxBytes,l,a.maxBytes),maxTotalBytes:l}}const Ri=s=>s>=1024*1024?`${(s/1024/1024).toFixed(1).replace(/\.0$/,"")} MB`:`${Math.max(1,Math.round(s/1024))} KB`;function zb(s){const t=String(s?.type??"").split(";",1)[0].trim().toLowerCase(),i=t==="image/jpg"?"image/jpeg":t;return Mb.includes(i)?i:null}function Ox(s){if(!s)return[];const t=Array.from(s.files??[]);return t.length?t:Array.from(s.items??[]).filter(i=>i?.kind==="file").map(i=>i.getAsFile?.()).filter(i=>!!i)}function uj(s){let t="";for(let i=0;i<s.length;i+=32768)t+=String.fromCharCode(...s.subarray(i,i+32768));return btoa(t)}let dj=0;function Rb(s,t,i,a,l=Ci){const u=s.reduce((d,h)=>d+h.size,0);return i?!l.maxCount||!l.maxBytes||!l.maxTotalBytes?"This connection takes no images.":s.length>=l.maxCount?`A message carries at most ${l.maxCount} images.`:a>l.maxBytes?`${t} is ${Ri(a)}; an image is at most ${Ri(l.maxBytes)}.`:u+a>l.maxTotalBytes?`The images of a message are at most ${Ri(l.maxTotalBytes)} together.`:null:`${t} is not a PNG, JPEG, GIF or WebP image.`}async function fj(s,t,i=Ci){const a=[];let l=null;for(const u of Array.from(t)){const d=String(u.name||"image"),h=zb(u),m=Rb([...s,...a],d,h,u.size,i);if(m||!h){l??=m;continue}let p;try{p=uj(new Uint8Array(await u.arrayBuffer()))}catch{l??=`Could not read ${d}.`;continue}a.push({id:`image-${++dj}`,type:"image",mimeType:h,data:p,name:d,size:u.size})}return{added:a,error:l}}function Xr(s,t,i=Ci){const a=[...s];let l=null;for(const u of t){const d=Rb(a,u.name,u.mimeType,u.size,i);if(d){l??=d;continue}a.push(u)}return{attachments:a,error:l}}function hj(s,t=[]){return[...s.trim()||!t.length?[{type:"text",text:s}]:[],...t.map(i=>({type:"image",mimeType:i.mimeType,data:i.data,...i.name?{name:i.name.slice(0,255)}:{}}))]}const _b=s=>`data:${s.mimeType};base64,${s.data}`,Ks=Object.freeze({maxObjectBytes:0,maxPerPrompt:0,maxPromptBytes:0,maxChunkBytes:0}),Dx=["maxObjectBytes","maxPerPrompt","maxPromptBytes","maxChunkBytes"];function mj(s,t){if(!t||!s||typeof s!="object"||Array.isArray(s))return{...Ks};const i=s;if(!Dx.every(h=>Number.isSafeInteger(i[h])&&i[h]>=0))return{...Ks};const[a,l,u,d]=Dx.map(h=>i[h]);return!l||!u||!d?{...Ks}:{maxObjectBytes:Math.min(a,u),maxPerPrompt:l,maxPromptBytes:u,maxChunkBytes:d}}const Lb=s=>s<1024?`${s} B`:Ri(s),Ob=s=>!!s&&s.maxPerPrompt>0&&s.maxPromptBytes>0&&s.maxChunkBytes>0;function pj({capable:s,permitted:t,writable:i,limits:a,session:l,known:u=!0}){if(!s)return"The host behind this gateway does not store files.";if(!i)return"Your access token cannot send messages.";if(!t)return"Your access token cannot upload files (it needs attachments.write).";if(!Ob(a))return"This connection takes no files.";if(!u)return null;const d=l?.promptAttachments;if(!Array.isArray(d)||!d.length){const h=typeof l?.agent=="string"?l.agent:"This agent",m=typeof l?.runtime=="string"?l.runtime:"a runtime";return`${h} runs on ${m} here, which cannot read attached files.`}return null}function gj(s){const t=String(s??"").normalize("NFC").replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}/\\]/gu,"").trim();let i="",a=0;for(const l of t){const u=new TextEncoder().encode(l).length;if(a+u>255)break;i+=l,a+=u}return i.trim()||"file"}const xj=/^[a-z0-9][a-z0-9!#$&^_.+-]{0,126}\/[a-z0-9][a-z0-9!#$&^_.+-]{0,126}$/;function yj(s){const t=String(s?.type??"").split(";",1)[0].trim().toLowerCase();return xj.test(t)?t:"application/octet-stream"}function Db(s,t,i,a){const l=s.reduce((u,d)=>u+d.size,0);return Ob(a)?s.length>=a.maxPerPrompt?`A message carries at most ${a.maxPerPrompt} files.`:i>a.maxObjectBytes?`${t} is ${Ri(i)}; a file is at most ${Ri(a.maxObjectBytes)}.`:l+i>a.maxPromptBytes?`The files of a message are at most ${Ri(a.maxPromptBytes)} together.`:null:"This connection takes no files."}let bj=0;async function vj(s,t,i){const a=[];let l=null;for(const u of Array.from(t)){const d=gj(u.name),h=Db([...s,...a],d,u.size,i);if(h){l??=h;continue}let m;try{m=new Uint8Array(await u.arrayBuffer())}catch{l??=`Could not read ${d}.`;continue}a.push({id:`file-${++bj}`,type:"file",name:d,mimeType:yj(u),size:m.length,data:m})}return{added:a,error:l}}function Ol(s,t,i){const a=[...s];let l=null;for(const u of t){const d=Db(a,u.name,u.size,i);if(d){l??=d;continue}a.push(u)}return{attachments:a,error:l}}const qx=(s,t,i=0)=>`${s}:file-${t}${i?`.${i}`:""}`;async function wj(s,{sessionId:t,file:i,requestId:a,digest:l}){try{const u=await s.begin({sessionId:t,name:i.name,size:i.data.length,mimeType:i.mimeType,sha256:await l(i.data),requestId:a});return u?.state!=="uploading"||typeof u.uploadId!="string"?!1:(await s.abort(u.uploadId),!0)}catch{return!1}}function kj(s,t=[],i=[]){const a=hj(s,t);if(!i.length)return a;if(i.some(l=>typeof l.attachmentId!="string"))throw new Error("A file of this message is not uploaded yet.");return[...s.trim()?[{type:"text",text:s}]:[],...t.map(l=>({type:"image",mimeType:l.mimeType,data:l.data,...l.name?{name:l.name.slice(0,255)}:{}})),...i.map(l=>({type:"attachment",attachmentId:l.attachmentId}))]}function jj(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&typeof t.attachmentId=="string"&&typeof t.name=="string"&&Number.isSafeInteger(t.size)&&t.size>=0).map(t=>({attachmentId:t.attachmentId,name:t.name,size:t.size})):[]}function xs(s){return{rootId:s,cursor:0,entries:[],positions:{},sessions:{},order:[],running:{},closed:{},questions:{},prompts:{},turns:{},turnOrder:[],historyUnavailable:!1,reset:0}}function Yd(s,t){const i=s.positions[t.key];if(i!==void 0){const a=s.entries.slice();return a[i]=t,{...s,entries:a}}return{...s,entries:[...s.entries,t],positions:{...s.positions,[t.key]:s.entries.length}}}const Ea=(s,t)=>{if(!(t in s))return s;const i={...s};return delete i[t],i};function Bx(s,t){if(typeof t!="string"||!t)return s;const i=s.turnOrder??[];return i.includes(t)?s:{...s,turnOrder:[...i,t]}}function Ei(s,t){if(!t||typeof t!="object"||!t.event||typeof t.sessionId!="string")return s;const i=typeof t.cursor=="number";if(i&&t.cursor<=s.cursor)return s;let a=i?{...s,cursor:t.cursor}:s;const l=t.sessionId,u=typeof t.ts=="string"?t.ts:"",d=t.event;d.type==="item"&&!a.sessions[l]&&(a={...a,sessions:{...a.sessions,[l]:{id:l}},order:a.order.includes(l)?a.order:[...a.order,l]});const h=()=>`${l}:${d.type}:${t.cursor??`${t.epoch}:${t.seq}`}`;switch(d.type){case"session.opened":case"session.updated":{const m=d.session&&typeof d.session=="object"?d.session:{},p=a.sessions[l];return a={...a,sessions:{...a.sessions,[l]:{...p,...m,id:l,...d.type==="session.opened"?{status:m.busy?"running":"idle"}:{}}},order:a.order.includes(l)?a.order:[...a.order,l]},d.type==="session.opened"&&(a={...a,closed:Ea(a.closed,l)}),a}case"session.closed":{const m=a.sessions[l];return{...a,closed:{...a.closed,[l]:!0},running:Ea(a.running,l),questions:Object.fromEntries(Object.entries(a.questions).filter(([,p])=>p.sessionId!==l)),sessions:m?{...a.sessions,[l]:{...m,status:"closed",busy:!1}}:a.sessions}}case"session.failed":return Yd(a,{key:h(),sessionId:l,ts:u,item:{kind:"session_event",id:h(),level:"error",text:d.error?.message?`The session failed: ${d.error.message}`:"The session failed."}});case"prompt.accepted":{if(typeof d.clientMessageId!="string")return a;const m=d.result==="turn"||d.result==="steer"?d.result:void 0;return a={...a,prompts:{...a.prompts,[d.clientMessageId]:{state:"accepted",...typeof d.turnId=="string"?{turnId:d.turnId}:{},...m?{result:m}:{}}}},m==="turn"&&l===a.rootId?Bx(a,d.turnId):a}case"prompt.failed":return typeof d.clientMessageId=="string"?{...a,prompts:{...a.prompts,[d.clientMessageId]:{state:"failed",...d.error?.code?{errorCode:d.error.code}:{},...d.error?.message?{error:d.error.message}:{}}}}:a;case"turn.started":{l===a.rootId&&(a=Bx(a,d.turnId));const m=a.sessions[l],p=a.turns[d.turnId]==="ended"?a.turns:{...a.turns,[String(d.turnId)]:"running"};return{...a,turns:p,running:{...a.running,[l]:String(d.turnId)},...m?{sessions:{...a.sessions,[l]:{...m,status:"running",busy:!0}}}:{}}}case"turn.ended":{const m=a.sessions[l];return a={...a,running:Ea(a.running,l),turns:{...a.turns,[String(d.turnId)]:"ended"},...m&&m.status!=="closed"?{sessions:{...a.sessions,[l]:{...m,status:"idle"}}}:{}},(d.state==="failed"||d.state==="canceled")&&(a=Yd(a,{key:h(),sessionId:l,ts:u,item:{kind:"turn_end",id:h(),state:d.state,...d.error?.message?{error:d.error.message}:{}}})),a}case"item":{const m=d.item;return!m||typeof m!="object"||typeof m.id!="string"||typeof m.kind!="string"||!["user_message","assistant_message","notice","tool_call","todo","compaction"].includes(m.kind)?a:Yd(a,{key:`${l}:${m.id}`,sessionId:l,ts:u,item:m})}case"usage":{const m=a.sessions[l];return!d.usage||typeof d.usage!="object"||Array.isArray(d.usage)?a:{...a,sessions:{...a.sessions,[l]:{...m,id:l,usage:d.usage}}}}case"question":{const m=d.question;return!m||typeof m.id!="string"?a:{...a,questions:{...a.questions,[m.id]:m}}}case"question.resolved":return typeof d.questionId=="string"?{...a,questions:Ea(a.questions,d.questionId)}:a;default:return a}}function $x(s,t,i){let a=t.reset?{...xs(s.rootId),reset:s.reset+1}:{...s,questions:{}};const l=i.filter(p=>typeof p?.cursor=="number").sort((p,x)=>p.cursor-x.cursor),u=i.filter(p=>typeof p?.cursor!="number"),d=a.cursor;for(const p of l)a=Ei(a,p);for(const p of u)a=Ei(a,p);const h=t.session,m=a.rootId;if(h&&(h.id===void 0||h.id===m)){const p=a.sessions[m];a={...a,sessions:{...a.sessions,[m]:{...p,...h,id:m}},order:a.order.includes(m)?a.order:[m,...a.order]},h.status==="closed"?a={...a,closed:{...a.closed,[m]:!0},running:Ea(a.running,m)}:h.status==="idle"&&!h.busy&&(a={...a,running:Ea(a.running,m)})}return t.reset&&(a={...a,historyUnavailable:a.cursor===d}),a}function qb(s){return(s.order.includes(s.rootId)?s.order:[s.rootId,...s.order]).map(i=>({id:i,session:s.sessions[i],running:i in s.running,closed:!!s.closed[i]}))}function Sj(s,t){return s.entries.filter(i=>i.sessionId===t)}function Ux(s,t){const i=s.prompts[t];if(!i)return!1;if(i.state==="failed")return i.errorCode!=="outcome_unknown";const a=Object.values(s.running);if(!i.turnId)return a.length===0;const l=s.turns[i.turnId];return l==="ended"||l==="running"&&!a.includes(i.turnId)}function Hx(s){const t=new Set;for(const i of s.entries)i.item.kind==="user_message"&&typeof i.item.clientMessageId=="string"&&t.add(i.item.clientMessageId);return t}function bf(s,t){return s.oversized?{sessionId:t,epoch:"history",seq:s.cursor,cursor:s.cursor,ts:"",event:{type:"item",item:{kind:"notice",id:`oversized:${s.cursor}`,level:"warning",text:`History event ${s.cursor} is too large to display (${s.oversized.bytes} bytes).`}}}:s}function Nj(s,t){let i=xs(s.rootId);for(const d of t)i=Ei(i,bf(d,s.rootId));const a=i.entries.slice(),l={...i.positions};for(const d of s.entries){const h=l[d.key];h!==void 0?a[h]=d:(l[d.key]=a.length,a.push(d))}const u={...i.sessions};for(const[d,h]of Object.entries(s.sessions))u[d]={...u[d],...h};return{...s,entries:a,positions:l,sessions:u,order:[...new Set([...i.order,...s.order])],prompts:{...i.prompts,...s.prompts},turns:{...i.turns,...s.turns},turnOrder:[...new Set([...i.turnOrder,...s.turnOrder??[]])]}}const Tj={codex:"Codex",claude:"Claude",acp:"ACP",antigravity:"Antigravity"},Aj={"read-only":"Read only","workspace-write":"Workspace write","full-access":"Full access"},Bb=s=>s==="custom"?"Custom":s,rn=s=>typeof s=="string"&&s.trim()?s:void 0;function Ix(s){if(!Array.isArray(s))return[];const t=new Map;for(const i of s){const a=rn(i?.id);if(!a||t.has(a))continue;const l=Array.isArray(i.efforts)?[...new Set(i.efforts.filter(d=>!!rn(d)))]:[],u=rn(i.effort);t.set(a,{id:a,label:rn(i.label)??a,efforts:l,...u&&l.includes(u)?{effort:u}:{}})}return[...t.values()]}function Vs(s){if(s.replace(/[\s_-]+/g,"").toLowerCase()==="xhigh")return"Extra high";const i=s.replace(/[_-]+/g," ").replace(/\s+/g," ").trim();return i?i.charAt(0).toUpperCase()+i.slice(1).toLowerCase():s}function $b(s,t,i){if(t)return s.find(l=>l.id===t);if(!i?.model)return;const a=i.runtime?`${i.runtime}:${i.model}`:i.model;return s.find(l=>l.id===a)??s.find(l=>l.id===i.model)}function Ub(s){return(s?.efforts??[]).map(t=>({id:t,label:Vs(t)}))}function Cj(s,t){return t&&s?.efforts.includes(t)?t:void 0}function Gx(s,t){const i=t.team&&s.teams.some(d=>d.id===t.team)?t.team:void 0,a=t.mode&&s.modes.some(d=>d.id===t.mode)?t.mode:s.defaultMode??s.modes[0]?.id,l=t.model?s.models.find(d=>d.id===t.model):void 0,u=t.thinkingByModel?.[l?.id??"default"];return{...i?{team:i}:{},...a?{mode:a}:{},...l?{model:l.id}:{},...u&&(!l||l.efforts.includes(u))?{thinking:u}:{}}}function Yx(s,t,{persist:i=!1}={}){return{cwd:s,...i?{persist:!0}:{},...t.team?{workflow:t.team}:{},...t.mode?{mode:t.mode}:{},...t.model?{model:t.model}:{},...t.thinking?{thinking:t.thinking}:{}}}function Ej(s){const t=s?.preview;if(!t||typeof t!="object")return;const i=rn(t.team),a=rn(t.agent);return!i||!a?void 0:{teams:Array.isArray(t.teams)?t.teams.filter(u=>rn(u?.id)).map(u=>({id:u.id,label:rn(u.label)??u.id,...rn(u.description)?{description:u.description}:{}})):[],team:i,agent:a,...rn(t.teamLabel)?{teamLabel:t.teamLabel}:{},runtime:rn(t.runtime)??"",model:rn(t.model)??"",mode:rn(t.mode)??"",thinking:rn(t.thinking)??""}}function Mj(s,t=[]){const i=$b(t,void 0,s),a=[{key:"team",label:"Team",value:s.teamLabel??s.teams.find(l=>l.id===s.team)?.label??Bb(s.team)},{key:"agent",label:"Agent",value:s.agent}];return s.runtime&&a.push({key:"runtime",label:"Runtime",value:Tj[s.runtime]??s.runtime}),s.model&&a.push({key:"model",label:"Model",value:i?.label??s.model}),s.thinking&&a.push({key:"thinking",label:"Thinking",value:Vs(s.thinking)}),s.mode&&a.push({key:"mode",label:"Permissions",value:Aj[s.mode]??s.mode}),a}function Hb(s){return JSON.stringify([typeof s?.workflow=="string"?s.workflow:"",typeof s?.model=="string"?s.model:""])}function Vx(s,t){if(!(!t||s.some(i=>i.id===t.team)))return{id:t.team,label:t.teamLabel??Bb(t.team)}}function zj(s,t){return t&&!s.some(i=>i.id===t.id)?[t,...s]:s}function Rj({chosen:s,previewTeam:t,previewSettled:i,previewError:a,previewBlocked:l,previewNeedsRead:u,teams:d,teamsKnown:h,teamsUnavailable:m}){return s?{team:s}:t?{team:t}:i?d.length?{team:d[0].id}:h?{}:{wait:_j({previewError:a,previewBlocked:l,previewNeedsRead:u,teamsUnavailable:m}),stuck:!0}:{wait:"Checking what would run…"}}function _j({previewError:s,previewBlocked:t,previewNeedsRead:i,teamsUnavailable:a}){const l=a?.reason==="capability"?"this host does not list teams (no team capability)":a?.reason==="permission"?"your access token cannot list teams (it lacks project.read)":a?.reason==="failed"?`the team list failed${a.message?` (${Vd(a.message)})`:""}`:"the team list is not available",u=t?`the preview is not available${s?` (${Vd(s)})`:""}`:`the preview failed${s?` (${Vd(s)})`:""}`,d=[];(a?.reason==="failed"||!t)&&d.push("use Retry in the preview to ask again");const h=[];a?.reason==="permission"&&h.push("project.read"),t&&i&&h.push("session.read"),h.length&&d.push(`reconnect with a token that has ${h.join(" or ")}`),d.length||d.push("connect to a host that lists teams or previews sessions");const m=d.join(", or ");return`Cannot tell which team would run: ${l}, and ${u}. To start, ${m}.`}function Vd(s){return String(s).trim().replace(/[.。]+$/,"")}function Lj(s,t,i){return String(t??"").trim()?`${s} Your first message was not sent; it is back in the New session box${i?` of ${i}`:""}.`:s}async function Oj(s,t,i,{mounted:a,describe:l,nameOf:u}){const d=s.startOrigin();try{return await s.createSession(t)}catch(h){throw a()||(i.trim()&&s.keepUnsentDraft(i,d),s.notify("error",Lj(l(h).message,i,d.workspace?u(d.workspace):void 0))),h}}const Ib="session.configure.live",Ma=Object.freeze({session_busy:"The session or one of its agents is working. Wait until everything is idle, then try again.",session_closed:"The session is closed. Send it a message to open it, then change its configuration.",not_root:"Only the main agent of a session can be changed; an agent keeps the team and model it started with.",not_persistent:"This session is not kept, so it cannot continue its conversation with a new configuration.",runtime_unsupported:"The host cannot change this session's model or team while it runs. Start a new session instead.",runtime_mismatch:"A session keeps its runtime. To use another runtime's model, start a new session with it.",agent_mismatch:"That team runs another main agent. Start a new session with that team.",permission_escalation:"The change would give the session more permissions or new commands than it has. Start a new session for it.",team_not_found:"The host defines no such team for this project.",invalid_params:"The host does not offer this model or thinking for this session.",native_refused:"The agent's runtime did not take the new configuration. The session keeps its own.",stale_generation:"The conversation changed since this view loaded. It was reloaded; try again.",key_conflict:"That request id was already used for something else. Try again.",outcome_unknown:"The host cannot tell whether the change happened. Check the session before trying again.",persistence_failed:"The host could not store the change. Check the session before trying again.",turn_in_progress:"A turn of this conversation has not ended. Try again when it has."}),Gb=new Set(["runtime_mismatch","agent_mismatch","permission_escalation","runtime_unsupported"]);function Kx(s){const t=Oi(s),a=s?.data?.action==="session.create",l=t.reason?Ma[t.reason]:void 0,u=t.reason==="grant"?t.message:l??t.message;return{...t,message:u,newSession:a||!!t.reason&&Gb.has(t.reason)}}const Dj=s=>/^([a-z]+)[:/]/.exec(s)?.[1];function qj(s,t){const i=t.runtime,a=i?s.filter(u=>Dj(u.id)===i):[],l=t.model?a.find(u=>u.id===`${i}:${t.model}`)??a.find(u=>u.id===t.model):void 0;return{same:a,current:l,others:s.length-a.length}}function Bj({capabilities:s,canWrite:t,canTeam:i,summary:a,closed:l=!1,busy:u=!1,configuring:d=!1,generation:h,online:m=!0,driveBlock:p}){const x=A=>({enabled:!1,reason:A});if(!s.includes(Ib)){const A="Set when the session started: this host cannot change it on a running session.";return{shown:!1,reason:A,model:x(A),thinking:x(A),team:x(A)}}const y=a?.conversation,k=(()=>{if(y?.configure!==!0)return y?.reason==="not_persistent"?Ma.not_persistent:y?.reason==="not_root"?Ma.not_root:Ma.runtime_unsupported;if(!t)return"Your access token cannot change this session (it needs session.write).";if(p)return p;if(l)return Ma.session_closed;if(!s.includes("session.history")||!h)return"The conversation is still loading.";if(!m)return"Reconnecting…";if(d)return"Applying the last change…";if(u)return"Wait until main and its agents are idle."})(),S=k?x(k):{enabled:!0},j=k?x(k):i?{enabled:!0}:x("Your access token cannot change the team (it needs session.team.write).");return{shown:!0,model:S,thinking:S,team:j}}function $j(s,t){if(!t)return s;const i=s?.workflow&&typeof s.workflow=="object"?s.workflow:{};return{...s,model:t.model,thinking:t.thinking,mode:t.mode,runtime:t.runtime,workflow:{...i,mode:t.team,supervisor:t.supervisor,...typeof t.maxPeers=="number"?{maxPeers:t.maxPeers}:{}},teamLabel:t.teamLabel??s?.teamLabel??(t.team==="custom"?void 0:t.team)}}function Uj(s,t,i){const a=s.effective,u=`${a.teamLabel??a.team} · main runs ${i??a.model}${a.thinking?` · ${t(a.thinking)}`:""}`;return s.status==="unchanged"?`Nothing to change: ${u}.`:`Changed: ${u}.${s.restarted?" The agent restarted on the same conversation.":""}`}const Jf="alp-web:preferences",vf=1,Hj=["interrupt","steer","queue"],Ij=["enter","mod-enter"],Gj=["system","light","dark","zinc","midnight","claude","ghostty","pureBlack"],Yj=["full","collapseToolCalls","collapseTurns"],Vj=["github","catppuccin","dracula","tokyo-night","one","nord","gruvbox","solarized"],zn=Object.freeze({uiFontSize:[10,21,14],contentFontSize:[10,21,15],codeFontSize:[9,22,12],contentMaxWidth:[600,4e3,820],terminalScrollback:[0,1e6,1e4]}),Kj=200,Yb=Object.freeze({header:["new-session","history","search"],footer:["tasks"]}),Vb=new Set(["tasks"]),so=s=>Yb[s].map(t=>({id:t,visible:!Vb.has(t)})),Kb=Object.freeze({grouping:"project",sort:"created",titleSource:"title",rowItems:Object.freeze({branch:!1,project:!1,host:!0,labels:!0}),trailing:"timestamp",projectFilters:[]}),Fj=64;function Fx(s){const t=Di(s)?s:{},i=Di(t.rowItems)?t.rowItems:{},a=Kb;return{grouping:t.grouping==="status"?"status":"project",sort:t.sort==="lastPrompt"?"lastPrompt":"created",titleSource:t.titleSource==="branch"?"branch":"title",rowItems:Object.fromEntries(Object.entries(a.rowItems).map(([l,u])=>[l,typeof i[l]=="boolean"?i[l]:u])),trailing:t.trailing==="none"?"none":"timestamp",projectFilters:[...new Set(Array.isArray(t.projectFilters)?t.projectFilters.filter(l=>typeof l=="string"&&l&&l.length<=4096):[])].slice(0,Fj)}}const Kd=Object.freeze({sendBehavior:"steer",sendShortcut:"enter",theme:"system",uiFontFamily:"",monoFontFamily:"",uiFontSize:14,contentFontSize:15,codeFontSize:12,contentMaxWidth:null,syntaxTheme:"one",chatDisplay:"collapseTurns",chatOutline:!0,terminalScrollback:1e4,sidebar:Object.freeze({header:so("header"),footer:so("footer")}),sidebarDisplay:Kb,newSession:Object.freeze({})});function Br(s,[t,i,a]){return typeof s=="number"&&Number.isFinite(s)?Math.min(i,Math.max(t,Math.round(s))):a}function Xx(s){if(typeof s!="string")return"";const t=s.trim();return t.length<=Kj&&!/[;{}<>\\()]/.test(t)?t:""}function Px(s,t){const i=Yb[t],a=[];for(const l of Array.isArray(s)?s:[])Di(l)&&i.includes(l.id)&&!a.some(u=>u.id===l.id)&&a.push({id:l.id,visible:typeof l.visible=="boolean"?l.visible:!Vb.has(l.id)});for(const l of so(t))a.some(u=>u.id===l.id)||a.push(l);return a}const Xj=200,Pj=64,Di=s=>!!s&&typeof s=="object"&&!Array.isArray(s),Fd=s=>typeof s=="string"&&s.trim()&&s.length<=Xj?s:void 0;function Fb(s){if(!Di(s))return{};const t=s,i={};for(const a of["team","mode","model"]){const l=Fd(t[a]);l&&(i[a]=l)}if(Di(t.thinkingByModel)){const a={};for(const[l,u]of Object.entries(t.thinkingByModel).slice(0,Pj)){const d=Fd(u);Fd(l)&&d&&!Object.hasOwn(Object.prototype,l)&&(a[l]=d)}Object.keys(a).length&&(i.thinkingByModel=a)}return i}function _i(s){const t=()=>({...Kd,sidebar:{header:so("header"),footer:so("footer")},sidebarDisplay:Fx(null),newSession:{}});if(typeof s!="string"||!s)return t();let i;try{i=JSON.parse(s)}catch{return t()}if(!Di(i)||i.v!==vf)return t();const a=(u,d)=>u.includes(i[d])?i[d]:Kd[d],l=Di(i.sidebar)?i.sidebar:{};return{sendBehavior:a(Hj,"sendBehavior"),sendShortcut:a(Ij,"sendShortcut"),theme:a(Gj,"theme"),uiFontFamily:Xx(i.uiFontFamily),monoFontFamily:Xx(i.monoFontFamily),uiFontSize:Br(i.uiFontSize,zn.uiFontSize),contentFontSize:Br(i.contentFontSize,zn.contentFontSize),codeFontSize:Br(i.codeFontSize,zn.codeFontSize),contentMaxWidth:typeof i.contentMaxWidth=="number"&&Number.isFinite(i.contentMaxWidth)?Br(i.contentMaxWidth,zn.contentMaxWidth):null,syntaxTheme:a(Vj,"syntaxTheme"),chatDisplay:a(Yj,"chatDisplay"),chatOutline:typeof i.chatOutline=="boolean"?i.chatOutline:Kd.chatOutline,terminalScrollback:Br(i.terminalScrollback,zn.terminalScrollback),sidebar:{header:Px(l.header,"header"),footer:Px(l.footer,"footer")},sidebarDisplay:Fx(i.sidebarDisplay),newSession:Fb(i.newSession)}}const Qj=["sendBehavior","sendShortcut","theme","uiFontFamily","monoFontFamily","uiFontSize","contentFontSize","codeFontSize","contentMaxWidth","syntaxTheme","chatDisplay","chatOutline","terminalScrollback","sidebar","sidebarDisplay","newSession"];function Wj(s){const t=_i(JSON.stringify({...s,v:vf}));return JSON.stringify({v:vf,...Object.fromEntries(Qj.map(i=>[i,t[i]]))})}function Qx(s){if(!s)return _i(null);try{return _i(s.getItem(Jf))}catch{return _i(null)}}function Zj(s,t){if(!s)return!1;try{return s.setItem(Jf,Wj(t)),!0}catch{return!1}}function Jj(s,t){const i={...s.thinkingByModel??{}},a=t.model||"default";return t.thinking?i[a]=t.thinking:delete i[a],Fb({team:t.team,mode:t.mode,model:t.model,thinkingByModel:i})}const io=Object.freeze({capability:"The host has not allowed remote terminals (its owner runs: alp terminal allow --yes)",permission:"Your access token cannot open terminals (it needs terminal.exec)",workspace:"Open a workspace to use a terminal.",registry:"This host does not list its workspaces, so it cannot open a terminal here. Update ALP on the host.",loading:"Loading the host's workspaces…",unregistered:"This workspace is not in the host's workspace list, so a terminal cannot open here.",offline:"Not connected to the host."}),qC="This shell runs on the daemon host as the account that runs alpd. The workspace is not a sandbox: the shell can read and write anything that account can, and use the network.",eS=Object.freeze({"root-only":"Limited protection on this Linux host: closing the terminal may not stop background processes.",none:"Process cleanup is not guaranteed on Windows: closing the terminal may not stop background processes."});function BC(s){return s==="root-only"||s==="none"?eS[s]:void 0}const $C="Runs on the daemon host as the account that runs alpd · the workspace is not a sandbox",Wx={terminal_disabled:io.capability,terminal_unsupported:"Terminals are not available on the daemon host (its terminal owner did not load).",terminal_limit:"Too many terminals are open on the host. Close one and try again.",input_too_large:"That input was too large for the terminal."},tS={closed:"closed",idle:"ended after being idle",lifetime:"reached its maximum lifetime",detached:"nobody reattached in time",revoked:"access was revoked",disabled:"the host turned terminals off",shutdown:"the host stopped"};function UC(s){const t=[];return Number.isSafeInteger(s.exitCode)&&t.push(`code ${s.exitCode}`),Number.isSafeInteger(s.signal)&&s.signal&&t.push(`signal ${s.signal}`),s.reason&&s.reason!=="exited"&&t.push(tS[s.reason]??s.reason),t.length?`Process exited (${t.join(" / ")})`:"Process exited"}const Zx=(s,t)=>{const i=t-s+1;return`\r
|
|
15
|
+
\x1B[2m[output lost: ${i} output ${i===1?"event":"events"} (#${s}${i>1?`–${t}`:""}) are no longer kept by the host]\x1B[0m\r
|
|
16
|
+
`};function wf(s){const t=s&&typeof s=="object"?s:{},i=a=>{const l=t[a];return Number.isSafeInteger(l)&&l>=1?Math.min(l,Ti[a]):Ti[a]};return{maxPerPrincipal:i("maxPerPrincipal"),maxPerDaemon:i("maxPerDaemon"),maxInputBytes:i("maxInputBytes"),maxOutputFrameBytes:i("maxOutputFrameBytes"),replayBytes:i("replayBytes"),idleMs:i("idleMs"),maxLifetimeMs:i("maxLifetimeMs"),reconnectMs:i("reconnectMs")}}function Xb(s){const t=[];if(!s.workspace)t.push("workspace");else if(s.connection.phase!=="open"&&!s.connection.capabilities.length)t.push("offline");else if(s.connection.capabilities.includes("terminal")||t.push("capability"),Te(s.principal??void 0,"terminal.exec")||t.push("permission"),!t.length)if(!s.connection.capabilities.includes("workspace.registry"))t.push("registry");else{const i=Zf(s);if(i)return{ok:!0,workspaceId:i.id};t.push(s.registry.loading?"loading":"unregistered")}return{ok:!1,reasons:t,messages:t.map(i=>io[i])}}function nS(s,t){let i=0,a=0;for(;a<s.length;){const l=s.codePointAt(a)??0,u=l<128?1:l<2048?2:l<65536?3:4;if(i+u>t)break;i+=u,a+=l>65535?2:1}return[s.slice(0,a),s.slice(a)]}function Jx(s,t){const i=(a,l,u)=>Math.min(u,Math.max(l,Number.isFinite(a)?Math.floor(a):l));return{cols:i(s,Ti.minCols,Ti.maxCols),rows:i(t,Ti.minRows,Ti.maxRows)}}const ey=s=>s?.protection==="root-only"||s?.protection==="none"?s.protection:void 0;class sS{#e={status:"idle"};#j=new Set;#p=new Set;#n=[];#i=0;#m=0;#r=null;#f=0;#a=null;#s="";#g=!1;#c;#y;#v={cols:80,rows:24};#w=null;#b=!0;#d;constructor(t){this.#d={limits:wf(void 0),inputDelayMs:5,resizeDelayMs:120,maxHistoryChars:Ti.replayBytes,newRequestId:()=>globalThis.crypto.randomUUID(),...t}}get workspaceId(){return this.#d.workspaceId}getState(){return this.#e}get lastSeq(){return this.#m}subscribe(t){return this.#j.add(t),()=>{this.#j.delete(t)}}onOutput(t){return this.#p.add(t),()=>{this.#p.delete(t)}}history(){return this.#n.join("")}get accepting(){return this.#e.status==="running"}#h(t){this.#e={...this.#e,...t};for(const i of[...this.#j])i()}#k(t){if(t){for(this.#n.push(t),this.#i+=t.length;this.#i>this.#d.maxHistoryChars&&this.#n.length>1;)this.#i-=this.#n.shift().length;for(const i of[...this.#p])i(t)}}#S(){const{storage:t,storageKey:i}=this.#d;try{const a=t&&i?t.getItem(i):null;return Sl(a)?a:void 0}catch{return}}#C(t){const{storage:i,storageKey:a}=this.#d;if(!(!i||!a))try{t?i.setItem(a,t):i.removeItem(a)}catch{}}start(t,i){if(this.#e.status!=="idle")return;t!==void 0&&i!==void 0&&(this.#v=Jx(t,i));const a=this.#d.initialTerminalId,l=this.#S()??(Sl(a)?a:void 0);l?(this.#C(l),this.#h({terminalId:l}),this.#E(0,!0)):this.#z()}restart(){const{status:t,terminalId:i}=this.#e;["exited","gone","failed","closed"].includes(t)&&(i&&t==="exited"&&this.#d.request("terminal.close",{terminalId:i}).catch(()=>{}),this.#C(void 0),this.#M(),this.#k("\x1Bc"),this.#n=[],this.#i=0,this.#e={status:"idle"},this.#z())}#M(){this.#f+=1,this.#m=0,this.#r=null,this.#s="",this.#w=null,this.#a=null}async#z(){const t=++this.#f;this.#a??=this.#d.newRequestId(),this.#h({status:"starting",error:void 0});let i;try{i=await this.#d.request("terminal.create",{workspaceId:this.#d.workspaceId,cols:this.#v.cols,rows:this.#v.rows,requestId:this.#a})}catch(l){if(t!==this.#f)return;if(Be(l).sent!=="yes"){this.#h({status:"reconnecting"}),this.#b&&this.#U();return}this.#a=null,this.#h({status:"failed",error:Xd(l)});return}if(t!==this.#f){const l=i?.terminal?.terminalId;if(this.#e.status==="closed"&&Sl(l))try{await this.#d.request("terminal.close",{terminalId:l})}catch{}return}const a=i?.terminal?.terminalId;if(!Sl(a)){this.#a=null,this.#h({status:"failed",error:"The host sent something this app does not understand."});return}this.#a=null,this.#w={cols:i.terminal.cols,rows:i.terminal.rows},this.#C(a),this.#h({terminalId:a,protection:ey(i.terminal)}),await this.#E(0,!1)}#U(){setTimeout(()=>{this.#b&&this.#e.status==="reconnecting"&&this.connected()},1e3)}async#E(t,i){const a=this.#e.terminalId,l=++this.#f;this.#r=[],this.#h({status:"attaching",error:void 0});let u;try{u=await this.#d.request("terminal.attach",{terminalId:a,...t>0?{after:t}:{}})}catch(p){if(l!==this.#f)return;this.#r=null;const x=Be(p);if(x.sent!=="yes"){this.#h({status:"reconnecting"}),this.#b&&this.#U();return}if(x.code===1001){if(this.#C(void 0),i&&!this.#m){this.#h({terminalId:void 0}),this.#z();return}this.#h({status:"gone",error:"This terminal has ended and the host no longer keeps it."});return}this.#h({status:"failed",error:Xd(p)});return}if(l!==this.#f)return;const d=this.#r??[];this.#r=null;const h=u?.gap;h&&Number.isSafeInteger(h.fromSeq)&&Number.isSafeInteger(h.toSeq)&&h.toSeq>=h.fromSeq&&h.toSeq>this.#m&&(this.#k(Zx(Math.max(h.fromSeq,this.#m+1),h.toSeq)),this.#m=h.toSeq);const m=u?.terminal;m&&Number.isSafeInteger(m.cols)&&(this.#w??={cols:m.cols,rows:m.rows}),this.#h({status:"running",protection:ey(m)??this.#e.protection});for(const p of d)this.#T(p);this.#e.status==="running"&&m?.state==="exited"&&this.#h({status:"exited",exit:{exitCode:m.exitCode??null,signal:m.signal??null,reason:m.endReason??"exited"}}),this.#e.status==="running"&&this.#D(0)}event(t){if(!(!t||t.terminalId!==this.#e.terminalId)){if(this.#r){this.#r.push(t);return}this.#T(t)}}#T(t){if(t.type==="detached"){if(t.reason==="slow_consumer"){this.#b?this.#E(this.#m,!1):this.#h({status:"reconnecting"});return}this.#f+=1,this.#s="",this.#h({status:"replaced"});return}!Number.isSafeInteger(t.seq)||t.seq<=this.#m||(t.seq>this.#m+1&&this.#k(Zx(this.#m+1,t.seq-1)),this.#m=t.seq,t.type==="output"&&typeof t.data=="string"?this.#k(t.data):t.type==="exit"&&(this.#s="",this.#h({status:"exited",exit:{exitCode:t.exitCode??null,signal:t.signal??null,reason:typeof t.reason=="string"?t.reason:"exited"}})))}input(t){return!this.accepting||typeof t!="string"||!t?!1:(this.#s+=t,!this.#g&&this.#c===void 0&&(this.#c=setTimeout(()=>{this.#c=void 0,this.#l()},this.#d.inputDelayMs)),!0)}async#l(){if(this.#g||!this.#s||!this.accepting)return;const[t,i]=nS(this.#s,this.#d.limits.maxInputBytes);if(!t){this.#s="";return}this.#s=i,this.#g=!0;const a=this.#e.terminalId;try{await this.#d.request("terminal.input",{terminalId:a,data:t})}catch(l){const u=Be(l);if(this.#s="",u.reason!=="terminal_exited"&&u.reason!=="not_attached"){const d=u.sent==="yes"?`Input was not delivered: ${Xd(l)}`:"The last input may not have reached the shell (the connection dropped). It is not sent again.";this.#h({lost:d}),this.#k(`\r
|
|
17
|
+
\x1B[2m[${d}]\x1B[0m\r
|
|
18
|
+
`)}}finally{this.#g=!1}this.#s&&this.#l()}resize(t,i){this.#v=Jx(t,i),this.#D(this.#d.resizeDelayMs)}#D(t){this.#y!==void 0&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.#y=void 0,this.#H()},t)}async#H(){if(!this.accepting)return;const t=this.#v;if(!(this.#w&&this.#w.cols===t.cols&&this.#w.rows===t.rows))try{const i=await this.#d.request("terminal.resize",{terminalId:this.#e.terminalId,cols:t.cols,rows:t.rows});this.#w={cols:Number(i?.cols??t.cols),rows:Number(i?.rows??t.rows)}}catch{this.#w=null}}reattach(){this.#e.status!=="replaced"||!this.#e.terminalId||this.#E(this.#m,!1)}connected(){this.#b=!0;const{status:t,terminalId:i}=this.#e;t!=="reconnecting"&&t!=="attaching"&&t!=="starting"&&t!=="running"||(this.#w=null,i?this.#E(this.#m,!1):this.#a&&this.#z())}disconnected(){this.#b=!1,this.#f+=1,this.#r=null,this.#s&&(this.#s="",this.#h({lost:"Input typed while the connection dropped was not sent."})),["running","attaching","starting"].includes(this.#e.status)&&this.#h({status:"reconnecting"})}async close(){const{terminalId:t,status:i}=this.#e;if(this.dispose(),this.#C(void 0),this.#h({status:"closed"}),!(!t||i==="gone"||i==="closed"))try{await this.#d.request("terminal.close",{terminalId:t})}catch{}}#I(){this.#f+=1,this.#c!==void 0&&clearTimeout(this.#c),this.#y!==void 0&&clearTimeout(this.#y),this.#c=this.#y=void 0,this.#s=""}dispose(){this.#I(),this.#p.clear()}dismissLost(){this.#e.lost&&this.#h({lost:void 0})}}function Xd(s){const t=Be(s);return t.reason&&Wx[t.reason]?Wx[t.reason]:t.code===1003&&t.reason==="grant"?io.permission:t.code===1003&&t.reason==="outside_workspace"?"This workspace is not granted to your access token.":t.message}const iS=["attach.after","prompt.receipts"],ty={name:"alp-web",version:"0.10.0"},ny="Stop is waiting for this message’s outcome.",aS=15e3,rS=200,sy={"read-only":"Read only","workspace-write":"Workspace write","full-access":"Full access"};function ic(s,t){const i=s.tree,a=i&&i.rootId===t?Object.keys(i.projection.questions).length>0:!1;return i&&i.rootId===t&&i.status==="attached"?a:a||(s.attention[t]??0)>0}function ao(s,t){return s.turnAttention[t]?.reason}function Pd(s){if(!s||s.reason!=="finished"&&s.reason!=="error"||typeof s.at!="string")return;const t=Date.parse(s.at),i=s.reason==="error"&&typeof s.message=="string"&&s.message.trim()?s.message:void 0;return{reason:s.reason,at:Number.isFinite(t)?t:Date.now(),hostAt:s.at,...typeof s.turnId=="string"?{turnId:s.turnId}:{},...i?{message:i}:{}}}function oS(s){const t=Object.entries(s.turnAttention).filter(([i])=>s.tree?.rootId===i||s.sessions.list.some(a=>a.id===i&&!a.archived));return t.length===Object.keys(s.turnAttention).length?s.turnAttention:Object.fromEntries(t)}const iy="This access token cannot list files (needs project.read).",kf="This access token cannot read files (needs files.read).",Pb="This host does not offer file reading. Update ALP on the host.",Qb=100;function lS(s){if(typeof s!="string")return;const t=s.trim();return t&&t.length<=253&&!/[\p{Cc}\p{Cf}]/u.test(t)?t:void 0}function ay(s,t){const i=(Array.isArray(s?.sessions)?s.sessions:[]).filter(a=>a&&typeof a.id=="string"&&!a.parentId);return t?i.sort((a,l)=>String(l.updatedAt??l.createdAt??"").localeCompare(String(a.updatedAt??a.createdAt??""))):i}function cS(){try{return globalThis.sessionStorage??void 0}catch{return}}function an(s=""){return{connection:{phase:"idle",gateway:s,attempt:0,capabilities:[]},principal:null,workspace:null,catalog:{status:"idle",teams:[],modes:[],models:[]},sessions:{status:"idle",list:[]},registry:{workspaces:[],revision:0},terminalDirectory:{items:[],mode:"idle"},history:{status:"idle",list:[],query:""},attention:{},turnAttention:{},selected:null,focus:null,tree:null,prompts:[],queued:[],busy:{},tasks:{status:"idle",visible:!1,rows:[],unreadable:0,creates:[],busy:{}},settings:{status:"idle",models:[]},notice:null,preferences:_i(null)}}class $r extends Error{constructor(){super("The message was discarded."),this.name="DiscardedError"}}class ry extends Error{constructor(t,i,a){super(i.message),this.name="UploadError",this.fileName=t,this.failure=i,this.dropped=a}}class uS{#e;#j=new Set;#p=!1;#n;#i=null;#m="";#r=new Map;#f=new Map;#a=null;#s=null;#g=new Map;#c=new Map;#y=new Map;#v=new Map;#w=new Map;#b=new Map;#d=new Map;#h=new WeakMap;#k(t,i){const a=(this.#h.get(t)??Promise.resolve()).then(i);return this.#h.set(t,a.catch(()=>{})),a}#S=new WeakSet;#C=!1;#M=null;#z=new Set;#U=0;#E=!1;#T=null;#l={};#D={};#H=new Map;#I;#ie;#ae;#N=null;#X=null;#P=null;#q=new Map;#Le=0;#G=0;#ge={visible:!0,focused:!0};#et=0;#R=new Map;#Y=new Map;#B;constructor(t={}){this.#n={open:_2,reconnecting:Ax,backoff:{initialMs:500,maxMs:15e3},stableMs:5e3,requestTimeoutMs:3e4,createTimeoutMs:12e4,taskPollMs:5e3,sessionPollMs:15e3,attentionPollMs:5e3,attentionWatchPollMs:6e4,historyPageSize:rS,releaseTimeoutMs:5e3,busyUnseenMs:aS,...t},this.#e={...an(),preferences:Qx(t.storage)}}getState(){return this.#e}subscribe(t){return this.#j.add(t),()=>{this.#j.delete(t)}}#t(t){const i=typeof t=="function"?t(this.#e):t;this.#e={...this.#e,...i},this.#tt(),this.#e.queued.length&&this.#Nt()}#tt(){this.#p||(this.#p=!0,queueMicrotask(()=>{this.#p=!1;for(const t of[...this.#j])t()}))}#u(t,i,a){this.#t({notice:{id:++this.#et,level:t,text:i,...a?.action?{action:a.action}:{}}})}dismissNotice(){this.#t({notice:null})}notify(t,i){this.#u(t,i)}#o(){const t=this.#i?.alp;if(!t||t.state!=="open"||!t.client)throw new Pe(this.#e.connection.phase==="reconnecting"?"Reconnecting to the host. Try again in a moment.":"Not connected to a host.");return t.client}connect({url:t,token:i,link:a=!1}){this.#re(),a||Kr(this.#n.linkStorage);let l;try{l=jb(t)}catch(k){this.#t({connection:{...this.#e.connection,phase:"failed",gateway:String(t),error:Be(k)}});return}const u=String(i??"").trim();if(!u){this.#t({connection:{...this.#e.connection,phase:"failed",gateway:l,error:Be(new Ra("Enter an access token."))}});return}this.#m=u,this.#e={...an(l),preferences:this.#e.preferences},this.#t({connection:{phase:"connecting",gateway:l,attempt:1,capabilities:[],...a?{link:!0}:{}}});const d={opened:!1,...a?{link:!0}:{}};this.#i=d;const{open:h,reconnecting:m,backoff:p,stableMs:x,requestTimeoutMs:y}=this.#n,v=m({connect:async({signal:k})=>{const{transport:S,principal:j}=await h({url:l,token:this.#m,signal:k});if(this.#i!==d)throw S.close(),new Error("This connection was replaced.");return d.principal=j,S},onConnect:(k,S)=>this.#st(d,k,S.signal),onDisconnect:()=>{if(this.#i===d){this.#B?.close(!1),this.#B=void 0;for(const k of this.#R.values())k.disconnected();this.#s=null,this.#g.clear(),this.#a=null;for(const k of this.#r.values())k.attaching=null}},shouldRetry:k=>!Be(k).terminal,backoff:p,stableMs:x,client:{timeoutMs:y}});d.alp=v,v.onEvent(k=>{this.#i===d&&this.#ut(k)&&this.#dt(k)}),v.onNotification((k,S)=>{if(this.#i===d){if(k==="catalog.updated"){this.#Je();return}if(k==="terminal.event")for(const j of this.#R.values())j.event(S)}}),v.onState((k,S)=>{this.#i===d&&this.#nt(d,k,S)})}showError(t){this.#re(),this.#t({connection:{...an(this.#e.connection.gateway).connection,phase:"failed",error:{message:t,sent:"no",terminal:!0}}})}disconnect({keepTerminals:t=!1,keepLink:i=!1}={}){i||Kr(this.#n.linkStorage),this.#re({keepTerminals:t})}#re({keepTerminals:t=!1}={}){const i=this.#i;this.#i=null,this.#m="",this.#xe(),this.#r.clear(),this.#c.clear(),this.#f.clear(),this.#K.clear(),this.#ne.clear(),this.#F.clear(),this.#te.clear(),this.#g.clear();const a=[...this.#x.values()];this.#x.clear();for(const u of a)clearTimeout(u.retry),u.observer?.stop(),u.done();this.#O.clear(),this.#pe.clear(),this.#$!==void 0&&(clearTimeout(this.#$),this.#$=void 0),this.#a=null,this.#s=null,this.#M=null,this.#U+=1,this.#l={},this.#N=null;const l=this.#lt(t?null:i);if(i?.alp){const u=i.alp;l?l.then(()=>u.stop()):u.stop()}i&&this.#t({...an(this.#e.connection.gateway),preferences:this.#e.preferences})}#nt(t,i,a){const l=this.#e.connection;if(i==="open"){t.opened=!0,this.#t({connection:{...l,phase:"open",attempt:0,error:void 0}}),this.#at();return}if(i==="connecting"){this.#t({connection:{...l,phase:t.opened?"reconnecting":"connecting",attempt:t.alp?.attempt??l.attempt}});return}if(i==="waiting"){if(!t.opened&&!t.link)return this.#Oe(a??new Error("Could not connect."));if(!t.opened){this.#t({connection:{...l,phase:"connecting",error:a?Be(a):void 0}});return}this.#xe(),this.#t({connection:{...l,phase:"reconnecting",error:a?Be(a):void 0}});return}i==="stopped"&&a&&this.#Oe(a)}#Oe(t){const i=this.#e.connection.gateway;let a=Be(t);this.#i?.link&&t instanceof Ra&&(Kr(this.#n.linkStorage),a={...a,message:O2}),this.#re(),this.#t({connection:{...an(i).connection,phase:"failed",error:a}})}async#st(t,i,a){const l=await Tx(i,ty,{signal:a,timeoutMs:15e3});if(this.#i!==t)throw new Error("This connection was replaced.");const u=Array.isArray(l?.capabilities)?l.capabilities.filter(m=>typeof m=="string"):[],d=iS.filter(m=>!u.includes(m));if(d.length)throw new Pe(`The host behind this gateway is too old for this app (it lacks ${d.join(", ")}). Update ALP on the host.`);this.#it(t.principal,u,typeof l?.daemonVersion=="string"?l.daemonVersion:void 0,lS(l?.hostname),cj(l?.promptImageLimits,u.includes("prompt.images")),mj(l?.attachmentLimits,u.includes("attachments")),u.includes("terminal")?wf(l?.terminalLimits):void 0),this.#s=null,this.#a=null;const h=this.#e.selected;if(h&&h!==this.#T&&!this.#r.get(h)?.gone){this.#_(h).failed=null;try{if(await this.#ce(i,h,a),this.#i!==t||a.aborted)throw new Error("This connection was replaced.");this.#s={client:i,root:h}}catch(m){if(this.#i!==t||a.aborted||!Ud(m))throw m;this.#Be(h,m)}}}#it(t,i,a,l,u,d={...Ks},h=void 0){this.#D={};const m=this.#e.workspace,p=m&&Ll(t,m)?m:t.workspaces[0]??null,x=JSON.stringify(t)!==JSON.stringify(this.#e.principal);p!==m&&(this.#l={},this.#N=null),this.#t(y=>({principal:t,registry:x?an().registry:{...y.registry,loading:!1},connection:{...y.connection,capabilities:i,...a?{daemonVersion:a}:{},hostname:l,promptImageLimits:u,attachmentLimits:d,terminalLimits:h},...p!==y.workspace?{workspace:p,selected:null,focus:null,tree:null,sessions:an().sessions,history:an().history,attention:{},turnAttention:{},tasks:{...an().tasks,visible:y.tasks.visible}}:{},...x||p!==y.workspace?{catalog:an().catalog}:{}}))}#at(){this.#ot();for(const t of this.#R.values())t.connected();this.#V(),this.#wt();for(const[t,i]of this.#x)i.attempts=0,i.exhausted=!1,this.#A(t);this.refreshRegistry(),this.#e.workspace&&(this.refreshSessions(),this.refreshAttention(),this.#e.history.status!=="idle"&&this.loadHistory({quiet:!0}),this.#e.catalog.status!=="ready"&&this.#Ne(),this.#e.tasks.visible&&this.refreshTasks()),this.#rt()}#rt(){this.#xe(),this.#ie=setInterval(()=>{this.#e.workspace&&this.#e.connection.phase==="open"&&this.refreshSessions({quiet:!0})},this.#n.sessionPollMs);const t=this.hasCapability("question.watch")?this.#n.attentionWatchPollMs:this.#n.attentionPollMs;this.#ae=setInterval(()=>{this.#e.workspace&&this.#e.connection.phase==="open"&&this.refreshAttention()},t),this.#I=setInterval(()=>{this.#e.tasks.visible&&this.#e.workspace&&this.#e.connection.phase==="open"&&this.refreshTasks({quiet:!0})},this.#n.taskPollMs)}#xe(){this.#ie!==void 0&&clearInterval(this.#ie),this.#I!==void 0&&clearInterval(this.#I),this.#ae!==void 0&&clearInterval(this.#ae),this.#ie=this.#I=this.#ae=void 0}hasCapability(t){return this.#e.connection.capabilities.includes(t)}terminalGate(){return Xb(this.#e)}#ot(){this.#B?.close(),this.#B=void 0;const t=this.#i;!t||!this.hasCapability("terminal")||!Te(this.#e.principal??void 0,"terminal.exec")||(this.#B=d2(this.#o(),{capabilities:this.#e.connection.capabilities,onMode:i=>{this.#i===t&&this.#t(a=>({terminalDirectory:{...a.terminalDirectory,mode:i}}))},onSnapshot:i=>{this.#i===t&&this.#t(a=>({terminalDirectory:{...a.terminalDirectory,items:i,error:void 0}}))},onError:i=>{this.#i===t&&this.#t(a=>({terminalDirectory:{...a.terminalDirectory,error:Be(i).message}}))}}))}openListedTerminal(t,i){const a=this.terminalTabs(t),l=a.tabs.find(h=>h.session.getState().terminalId===i);if(l){this.selectTerminal(t,l.key);return}if(!this.#e.terminalDirectory.items.some(h=>h.terminalId===i&&h.workspaceId===t&&h.state==="running")||a.tabs.length>=32)return;const u=globalThis.crypto.randomUUID(),d=this.#ye(t,u,a.storage,a.storageKey,i);a.tabs=[...a.tabs,{key:u,session:d}],a.active=u,this.#Q(t)}terminal(t){let i=this.#Y.get(t)??this.terminalTabs(t);return i.tabs.length||(this.addTerminal(t),i=this.terminalTabs(t)),(i.tabs.find(a=>a.key===i.active)??i.tabs[0]).session}terminalTabs(t){const i=this.terminalGate();if(!i.ok||i.workspaceId!==t)throw new Pe(i.ok?"That workspace is not the open one.":i.messages.join(" "));let a=this.#Y.get(t);if(a)return a;const l=this.#n.terminalStorage===void 0?cS():this.#n.terminalStorage??void 0,u=`alp-web.terminal|${this.#e.connection.gateway}|${this.#e.principal?.id??""}|${t}`;let d=["default"],h="default";try{const m=JSON.parse(l?.getItem(`${u}|tabs`)??"null");m?.v===1&&Array.isArray(m.keys)&&m.keys.length<=32&&m.keys.every(p=>typeof p=="string"&&/^(default|[a-zA-Z0-9-]{1,64})$/.test(p))&&new Set(m.keys).size===m.keys.length&&(d=m.keys,h=d.includes(m.active)?m.active:d[0]??null)}catch{}return a={tabs:d.map(m=>({key:m,session:this.#ye(t,m,l,u)})),active:h,storage:l,storageKey:u},this.#Y.set(t,a),a}#ye(t,i,a,l,u){const d=new sS({workspaceId:t,...u?{initialTerminalId:u}:{},request:(h,m)=>this.#o().request(h,m,{timeoutMs:this.#n.requestTimeoutMs}),limits:this.#e.connection.terminalLimits??wf(void 0),...a?{storage:a,storageKey:i==="default"?l:`${l}|${i}`}:{},...this.#n.terminalOptions});return this.#R.set(JSON.stringify([t,i]),d),d}#Q(t){const i=this.#Y.get(t);if(i){try{i.storage?.setItem(`${i.storageKey}|tabs`,JSON.stringify({v:1,keys:i.tabs.map(a=>a.key),active:i.active}))}catch{}this.#t({})}}addTerminal(t){const i=this.terminalTabs(t);if(i.tabs.length>=32)return i.active;const a=globalThis.crypto.randomUUID();return i.tabs=[...i.tabs,{key:a,session:this.#ye(t,a,i.storage,i.storageKey)}],i.active=a,this.#Q(t),a}selectTerminal(t,i){const a=this.terminalTabs(t);a.tabs.some(l=>l.key===i)&&(a.active=i,this.#Q(t))}closeTerminalTab(t,i){const a=this.terminalTabs(t),l=a.tabs.findIndex(d=>d.key===i);if(l<0)return Promise.resolve();const u=a.tabs[l];return a.tabs=a.tabs.filter(d=>d.key!==i),a.active===i&&(a.active=a.tabs[Math.min(l,a.tabs.length-1)]?.key??null),this.#R.delete(JSON.stringify([t,i])),this.#Q(t),u.session.close()}closeTerminal(t=Zf(this.#e)?.id){const i=t?this.#Y.get(t):void 0;if(!t||!i)return Promise.resolve();const a=i.tabs;i.tabs=[],i.active=null;for(const l of a)this.#R.delete(JSON.stringify([t,l.key]));return this.#Q(t),Promise.allSettled(a.map(l=>l.session.close()))}#lt(t){this.#B?.close(),this.#B=void 0;const i=t?.alp?.state==="open"?t.alp.client:void 0,a=[];for(const l of this.#R.values()){const{terminalId:u,status:d}=l.getState();l.dispose(),i&&u&&d!=="gone"&&d!=="closed"&&a.push(i.request("terminal.close",{terminalId:u},{timeoutMs:1e3}).catch(()=>{}))}return this.#R.clear(),this.#Y.clear(),a.length?Promise.allSettled(a):void 0}#_(t){let i=this.#r.get(t);return i||(i={projection:xs(t),attaching:null,gone:null,failed:null},this.#r.set(t,i),this.#f.set(t,t)),i}#W(t){for(const i of t.order)this.#f.set(i,t.rootId);return t}#ct(t){const i=t?.sessionId;if(typeof i!="string")return;let a=this.#f.get(i);if(!a){const l=t.event?.type==="session.opened"?t.event.session?.parentId:void 0;a=typeof l=="string"&&this.#f.get(l)||void 0,a&&this.#f.set(i,a)}return a===this.#a?a:void 0}#ut(t){const i=t?.event;if(i?.type==="question"){const a=i.question?.id,l=i.question?.rootId;return typeof a=="string"&&typeof l=="string"&&this.#X?.events.push({id:a,root:l}),this.#N&&typeof a=="string"&&typeof l=="string"&&this.#N.get(a)!==l&&(this.#N.set(a,l),this.#be()),t.cursor!==void 0||!!this.#a&&l===this.#a}if(i?.type==="attention"&&t.cursor===void 0)return typeof t.sessionId=="string"&&(this.#P&&this.#P.push([t.sessionId,i.attention??null]),this.#ft(t.sessionId,i.attention)),!1;if(i?.type==="turn.ended"&&t.cursor===void 0){if(typeof t.sessionId=="string"){const a=t.sessionId;this.#e.sessions.list.some(l=>l.id===a&&(l.status==="running"||l.busy))&&this.#t(l=>({sessions:{...l.sessions,list:l.sessions.list.map(u=>u.id===a?{...u,busy:!1,...u.status==="running"?{status:"idle"}:{}}:u)}})),this.#De(a,i)}return!1}if(i?.type==="question.resolved"){if(typeof i.questionId=="string"&&this.#X?.events.push({id:i.questionId}),this.#N?.delete(i.questionId)&&this.#be(),t.cursor!==void 0)return!0;const a=this.#a?this.#r.get(this.#a):void 0;return a?Object.hasOwn(a.projection.questions,i.questionId)||!!a.attaching?.buffer.some(l=>l.event?.type==="question"&&l.event.question?.id===i.questionId):!1}return!0}#be(){if(!this.#N)return;const t={};for(const i of this.#N.values())t[i]=(t[i]??0)+1;JSON.stringify(t)!==JSON.stringify(this.#e.attention)&&this.#t({attention:t})}#dt(t){const i=this.#ct(t);if(!i)return;const a=this.#r.get(i);if(!a)return;if(t.event?.type==="history.reset"&&t.sessionId===i){this.#qe(i,t.event.generation);return}if(a.attaching){a.attaching.buffer.push(t);return}a.projection=this.#W(Ei(a.projection,t)),this.#L(i);const l=t.event?.type;t.sessionId===i&&l==="turn.ended"?this.#De(i,t.event):t.sessionId===i&&l==="turn.started"&&(this.#q.delete(i),this.#Z(i))}get#oe(){return this.hasCapability("session.attention")&&this.hasCapability("question.watch")}#ft(t,i){this.#q.delete(t);const a=Pd(i);if(!a){this.#Z(t);return}if(this.#le(t)){this.#Z(t),this.#ve(t,a);return}this.#e.history.list.some(l=>l.id===t&&l.archived)||this.#e.turnAttention[t]?.hostAt!==a.hostAt&&this.#t(l=>({turnAttention:{...l.turnAttention,[t]:a}}))}#ve(t,i){if(!this.#oe||this.#e.connection.phase!=="open")return;const a={},l=this.#l;this.#q.set(t,a);const u=()=>{this.#q.get(t)===a&&(this.#q.delete(t),!(l!==this.#l||this.#e.turnAttention[t])&&(this.#e.history.list.some(d=>d.id===t&&d.archived)||this.#t(d=>({turnAttention:{...d.turnAttention,[t]:i}}))))};try{this.#o().request("session.attention.clear",{sessionId:t,...i.hostAt?{at:i.hostAt}:{}}).then(()=>{this.#q.get(t)===a&&this.#q.delete(t)},u)}catch{u()}}#Z(t){this.#e.turnAttention[t]&&this.#t(i=>{const{[t]:a,...l}=i.turnAttention;return{turnAttention:l}})}#De(t,i){if(this.#oe)return;const a=i?.state==="completed"?"finished":i?.state==="failed"?"error":void 0;if(!a){this.#Z(t);return}if(this.#le(t)||this.#e.history.list.some(d=>d.id===t&&d.archived))return;const l=typeof i?.error?.message=="string"&&i.error.message.trim()?i.error.message:void 0,u={reason:a,at:Date.now(),...typeof i?.turnId=="string"?{turnId:i.turnId}:{},...a==="error"&&l?{message:l}:{}};this.#t(d=>({turnAttention:{...d.turnAttention,[t]:u}}))}#le(t){const i=this.#e.focus??this.#e.selected;return this.#ge.visible&&this.#ge.focused&&(i===t||this.#e.selected===t)}setPresence({visible:t,focused:i}){this.#ge={visible:!!t,focused:!!i};const a=this.#e.focus??this.#e.selected;a&&this.#le(a)&&this.clearAttention(a)}clearAttention(t){const i=t?this.#e.turnAttention[t]:void 0;!t||!i||(this.#Z(t),this.#ve(t,i))}async#ce(t,i,a,l=0){const u=this.#_(i),d={buffer:[]};u.attaching=d,this.#a=i;const h=this.#y.get(i)??0;this.#e.selected===i&&this.#t(m=>({tree:{rootId:i,status:"attaching",projection:u.projection,...m.tree?.rootId===i&&m.tree.error?{}:{}}}));try{if(this.hasCapability("session.history")&&!this.#c.has(i)){const y=await t.request("session.history",{sessionId:i},{timeoutMs:this.#n.requestTimeoutMs,...a?{signal:a}:{}});if(u.attaching!==d)return;u.projection=xs(i);for(const v of y.items)u.projection=Ei(u.projection,bf(v,i));this.#W(u.projection),u.projection={...u.projection,cursor:y.tipCursor},this.#c.set(i,{generation:y.generation,olderCursor:y.olderCursor,hasOlder:y.hasOlder})}const m=u.projection.cursor,p=this.#c.get(i),x=await t.request("session.attach",{sessionId:i,...p?{after:m,generation:p.generation}:m>0?{after:m}:{}},{timeoutMs:this.#n.requestTimeoutMs,...a?{signal:a}:{}});if(u.attaching!==d)return;u.attaching=null,u.gone=null,u.failed=null,this.#we(i,u,x,d.buffer),(this.#y.get(i)??0)!==h&&this.#c.get(i)?.generation!==this.#v.get(i)&&(this.#c.delete(i),queueMicrotask(()=>{this.#ke(t,i)}))}catch(m){if(u.attaching!==d)throw m;if(m?.data?.reason==="stale_cursor"&&l<1&&this.#c.has(i))return this.#c.delete(i),u.projection=xs(i),u.attaching===d&&(u.attaching=null),this.#ce(t,i,a,l+1);throw u.attaching===d&&(u.attaching=null),t===this.#i?.alp?.client&&this.#a===i&&(this.#a=null),m}}#we(t,i,a,l){i.projection=this.#W($x(i.projection,a??{},l)),a?.reset&&!i.projection.historyUnavailable&&this.#u("info","The host restarted this conversation's history; it was loaded again from the beginning."),this.#L(t,"attached")}#qe(t,i){if(typeof i!="string"||!i||this.#c.get(t)?.generation===i||this.#v.get(t)===i)return;this.#v.set(t,i),this.#y.set(t,(this.#y.get(t)??0)+1),this.#c.delete(t);const a=this.#r.get(t);a&&this.#Qe(t,a.projection);const l=this.#s?.root===t?this.#s.client:void 0;a&&l&&!a.attaching&&this.#ke(l,t)}#ke(t,i){return this.#k(t,()=>this.#ht(t,i))}async#ht(t,i){if(!(t!==this.#i?.alp?.client||this.#e.selected!==i)&&!(this.#s?.client!==t||this.#s.root!==i)){this.#c.delete(i);try{await this.#ce(t,i)}catch(a){this.#Se(t,i,a)}}}async loadOlder(){const t=this.#e.selected;if(!t)return;const i=this.#c.get(t),a=this.#r.get(t),l=this.#s?.root===t?this.#s.client:null;if(!i?.hasOlder||i.loading||!a||!l)return;const u={...i,loading:!0,error:void 0};this.#c.set(t,u),this.#L(t);try{const d=await l.request("session.history",{sessionId:t,before:i.olderCursor},{timeoutMs:this.#n.requestTimeoutMs});if(this.#c.get(t)!==u)return;if(d.generation!==i.generation)throw new Error("History changed; reconnect to refresh it.");a.projection=this.#W(Nj(a.projection,d.items)),this.#c.set(t,{generation:d.generation,olderCursor:d.olderCursor,hasOlder:d.hasOlder})}catch(d){this.#c.get(t)===u&&this.#c.set(t,{...i,error:Be(d).message})}this.#L(t)}#Be(t,i){const a=this.#_(t);a.gone=Be(i),a.attaching=null,this.#a===t&&(this.#a=null),this.#e.selected===t&&this.#t({tree:{rootId:t,status:"gone",error:a.gone,projection:a.projection}})}#L(t,i){if(this.#e.selected!==t){this.#A(t);return}const a=this.#r.get(t);if(!a)return;const l=Hx(a.projection),u=a.projection.prompts;for(const h of this.#O.get(t)??[]){const m=u[h];(m?.state==="failed"&&m.errorCode!=="outcome_unknown"||m?.turnId&&a.projection.turns[m.turnId]==="ended")&&this.#O.get(t)?.delete(h)}let d=this.#e.prompts.filter(h=>h.rootId!==t||!l.has(h.id));d=d.map(h=>{const m=u[h.id];if(h.rootId!==t||m?.state!=="failed")return h;const p=m.errorCode==="outcome_unknown",x=p?"unknown":"failed";if(h.status===x)return h;const y=p?"The host cannot tell whether the agent took the message":"The agent did not take the message";return{...h,status:x,error:m.error?`${y}: ${m.error}`:`${y}.`,retrySameId:!1}}),this.#t(h=>({tree:{rootId:t,status:i??(h.tree?.rootId===t?h.tree.status:"attached"),projection:a.projection,...this.#c.has(t)?{older:this.#c.get(t)}:{},...i==="attached"?{}:h.tree?.rootId===t&&h.tree.error?{error:h.tree.error}:{}},...d.length!==h.prompts.length||d.some((m,p)=>m!==h.prompts[p])?{prompts:d}:{},sessions:this.#$e(h.sessions,t,a.projection),busy:{...h.busy,interrupt:this.#x.has(t)&&!this.#x.get(t)?.exhausted}})),this.#A(t)}#$e(t,i,a){const l=t.list.findIndex(p=>p.id===i);if(l<0)return t;const u=t.list[l],d=a.sessions[i],h=a.closed[i]?"closed":i in a.running?"running":d?.status==="closed"||u.status==="closed"&&!d?"closed":"idle";if(u.status===h&&(!d?.title||d.title===u.title))return t;const m=t.list.slice();return m[l]={...u,status:h,...d?.title?{title:d.title}:{}},{...t,list:m}}async#V(){const t=this.#i?.alp?.client;if(t){if(this.#S.has(t)){this.#E=!0;return}this.#S.add(t);try{for(;;){this.#E=!1;const i=await this.#k(t,()=>this.#mt(t));if(t!==this.#i?.alp?.client||!i&&!this.#E)break}}finally{this.#S.delete(t)}}}async#mt(t){if(this.#i?.alp?.state!=="open"||t!==this.#i.alp.client)return!1;const i=this.#e.selected;this.#s&&this.#s.client!==t&&(this.#s=null);const a=this.#s;if(a&&a.root!==i)return this.#s=null,this.#a===a.root&&(this.#a=null),await this.#J(a),!0;if(!i||i===this.#T||this.#s?.root===i)return!1;const l=this.#_(i);if(l.gone)return this.#t({tree:{rootId:i,status:"gone",error:l.gone,projection:l.projection}}),!1;if(l.failed)return this.#t({tree:{rootId:i,status:"error",error:l.failed,projection:l.projection}}),!1;const u=this.#g.get(i);try{return this.#g.delete(i),this.#s={client:t,root:i},await this.#ce(t,i),t!==this.#i?.alp?.client?!0:(this.#s={client:t,root:i},this.#e.selected!==i)}catch(d){return u&&t===this.#i?.alp?.client&&(this.#s?.client===t&&this.#s.root===i&&(this.#s=null),await this.#J(u)),this.#Se(t,i,d),!1}}async#J(t){const i=this.#x.get(t.root)?.observer;i&&i.state!=="stopped"?(this.#g.set(t.root,t),i.ready().catch(()=>{}).then(()=>this.#je(t.root,t))):(this.#g.delete(t.root),await t.client.request("session.release",{sessionId:t.root},{timeoutMs:this.#n.releaseTimeoutMs}).catch(()=>{}))}#je(t,i){const a=this.#g.get(t);!a||i&&a!==i||this.#k(a.client,async()=>{this.#g.get(t)===a&&(this.#g.delete(t),this.#i?.alp?.client===a.client&&(this.#s?.client===a.client&&this.#s.root===t||await a.client.request("session.release",{sessionId:t},{timeoutMs:this.#n.releaseTimeoutMs}).catch(()=>{})))})}#Se(t,i,a){if(t!==this.#i?.alp?.client)return;if(Ud(a)){this.#Be(i,a);return}const l=this.#_(i);l.failed=Be(a),this.#e.selected===i&&this.#t({tree:{rootId:i,status:"error",error:l.failed,projection:l.projection}})}retryAttach(){const t=this.#e.selected;if(!t)return;const i=this.#r.get(t);i&&(i.gone=null,i.failed=null);const a=this.#i?.alp?.client;a&&this.#k(a,async()=>{const l=this.#s;l?.client===a&&l.root===t&&(this.#s=null,this.#a===t&&(this.#a=null),await this.#J(l))}).finally(()=>this.#V())}selectWorkspace(t){const i=this.#e.principal,a=t&&(Ll(i??void 0,t)||this.#e.registry.workspaces.some(l=>l.managedWorktree&&l.directory===t))?t:null;a!==this.#e.workspace&&(this.#l={},this.#N=null,this.#t(l=>({workspace:a,selected:null,focus:null,tree:null,sessions:an().sessions,history:an().history,attention:{},turnAttention:{},catalog:an().catalog,tasks:{...an().tasks,visible:l.tasks.visible}})),this.#V(),a&&this.#e.connection.phase==="open"&&(this.refreshSessions(),this.refreshAttention(),this.#Ne(),this.#e.tasks.visible&&this.refreshTasks()))}async refreshRegistry(){if(!this.hasCapability("workspace.registry")||!Te(this.#e.principal??void 0,"project.read")||this.#e.registry.loading)return;const t=this.#D,i=this.#i;this.#t(a=>({registry:{...a.registry,loading:!0}}));try{const a=[];let l,u=0;do{const d=await this.#o().request("workspace.list",{limit:500,...l?{cursor:l}:{}});a.push(...d.workspaces),u=d.revision,l=d.nextCursor}while(l);t===this.#D&&i===this.#i&&this.#t({registry:{workspaces:a,revision:u}})}catch(a){t===this.#D&&i===this.#i&&this.#t(l=>({registry:{...l.registry,loading:!1,error:a instanceof Error?a.message:String(a)}}))}}async pinWorkspace(t,i){if(!Te(this.#e.principal??void 0,"workspace.write")){this.#u("error","Ask the host owner to add workspace.write to your credential to change shared pins.");return}const a=()=>this.#o().request("workspace.update",{workspaceId:t,pinned:i,ifRevision:this.#e.registry.revision,requestId:globalThis.crypto.randomUUID()});try{try{await a()}catch(l){if(l?.data?.reason!=="stale_revision")throw l;await this.refreshRegistry(),await a()}await this.refreshRegistry()}catch(l){this.#u("error",`Pin was not saved. ${l instanceof Error?l.message:String(l)} Refresh and try again.`),await this.refreshRegistry()}}async renameWorkspace(t,i){if(!Te(this.#e.principal??void 0,"workspace.write"))return this.#u("error","Ask the host owner to add workspace.write to your credential to rename shared workspaces."),!1;try{return await this.#o().request("workspace.update",{workspaceId:t,title:i.trim()||null,ifRevision:this.#e.registry.revision,requestId:globalThis.crypto.randomUUID()}),await this.refreshRegistry(),!0}catch(a){return this.#u("error",`Name was not saved. ${a instanceof Error?a.message:String(a)} Refresh and try again.`),await this.refreshRegistry(),!1}}async worktreeOptions(t){return(await this.#o().request("workspace.worktree.options",{workspaceId:t})).mappingIds}async mutateWorktree(t,i,a){if(!this.hasCapability("workspace.worktree")||!Te(this.#e.principal??void 0,"workspace.manage"))return!1;const l=t+":"+i+":"+(a??"");let u=this.#H.get(l);u||(u={workspaceId:i,...a?{mappingId:a}:{},ifRevision:this.#e.registry.revision,requestId:globalThis.crypto.randomUUID()},this.#H.set(l,u));try{return await this.#o().request("workspace.worktree."+t,u),this.#H.delete(l),await this.refreshRegistry(),!0}catch(d){return d?.data?.reason==="stale_revision"&&this.#H.delete(l),this.#u("error",`Worktree ${t} was not confirmed. ${d instanceof Error?d.message:String(d)} Retry the same operation to reconcile its outcome.`),await this.refreshRegistry(),!1}}async registerProject(t){if(!Te(this.#e.principal??void 0,"workspace.write")){this.#u("error","Ask the host owner to add workspace.write to your credential. To add another directory, the owner must grant it locally first.");return}try{await this.#o().request("project.register",{directory:t,ifRevision:this.#e.registry.revision,requestId:globalThis.crypto.randomUUID()}),await this.refreshRegistry()}catch(i){this.#u("error",`Project was not added. ${i instanceof Error?i.message:String(i)} Refresh and try again.`),await this.refreshRegistry()}}async listWorkspaceSessions(t){if(!Te(this.#e.principal??void 0,"session.read")||this.#e.connection.phase!=="open")return{};const i=this.#o(),a=await Promise.all(t.map(async l=>{try{const u=await i.request("session.list",{projectRoot:l,rootsOnly:!0,includeClosed:!0});return[l,(Array.isArray(u?.sessions)?u.sessions:[]).filter(d=>d&&typeof d.id=="string"&&!d.parentId&&!d.archived)]}catch{return null}}));return Object.fromEntries(a.filter(Boolean))}async refreshSessions({quiet:t=!1}={}){this.refreshRegistry();const i=this.#e.workspace;if(!i)return;const a=this.#l;t||this.#t(u=>({sessions:{...u.sessions,status:u.sessions.list.length?u.sessions.status:"loading",error:void 0}}));const l=Date.now();try{const d=await this.#o().request("session.list",{projectRoot:i,rootsOnly:!0,includeClosed:!0});if(a!==this.#l)return;const h=(Array.isArray(d?.sessions)?d.sessions:[]).filter(m=>m&&typeof m.id=="string"&&!m.parentId&&!m.archived).sort((m,p)=>String(p.updatedAt??p.createdAt??"").localeCompare(String(m.updatedAt??m.createdAt??"")));this.#t(m=>{let p={status:"ready",list:h};for(const[S,j]of this.#r)p=this.#$e(p,S,j.projection);const x=m.selected&&!h.some(S=>S.id===m.selected)?m.sessions.list.find(S=>S.id===m.selected):void 0,v=this.#oe?[]:Object.keys(m.turnAttention).filter(S=>m.turnAttention[S].at<l&&h.some(j=>j.id===S&&(j.status==="running"||j.busy))),k=v.length?Object.fromEntries(Object.entries(m.turnAttention).filter(([S])=>!v.includes(S))):m.turnAttention;return{sessions:x?{...p,list:[x,...p.list]}:p,turnAttention:k}})}catch(u){if(a!==this.#l)return;t||this.#t(d=>({sessions:{...d.sessions,status:"error",error:Be(u)}}))}}async refreshAttention(){const t=this.#e.workspace;if(!t||!Te(this.#e.principal??void 0,"session.read"))return;const i=this.#l,a=++this.#Le,l=this.hasCapability("question.watch"),u=l?{read:a,events:[]}:null;this.#X=u;const d=this.#oe,h=d?[]:null;this.#P=h;try{const m=l&&this.hasCapability("question.watch.turns"),p=await this.#o().request(l?"question.watch":"question.list",{projectRoot:t,...m?{turns:!0}:{},...d?{attention:!0}:{}});if(i!==this.#l||a!==this.#Le)return;d&&Array.isArray(p?.attention)&&this.#pt(p.attention,h??[]);const x=new Map;for(const y of Array.isArray(p?.questions)?p.questions:[])typeof y?.id=="string"&&typeof y.rootId=="string"&&x.set(y.id,y.rootId);for(const y of u?.events??[])y.root?x.set(y.id,y.root):x.delete(y.id);this.#N=x,this.#be(),l||(this.#N=null)}catch{}finally{this.#X===u&&(this.#X=null),this.#P===h&&(this.#P=null)}}#pt(t,i){const a=new Map;for(const u of t)typeof u?.sessionId=="string"&&Pd(u.attention)&&a.set(u.sessionId,u.attention);for(const[u,d]of i)a.set(u,d);const l={};for(const[u,d]of a){const h=Pd(d);if(!h||this.#e.history.list.some(p=>p.id===u&&p.archived))continue;if(this.#le(u)){this.#ve(u,h);continue}const m=this.#e.turnAttention[u];l[u]=m?.hostAt===h.hostAt?m:h}JSON.stringify(l)!==JSON.stringify(this.#e.turnAttention)&&this.#t({turnAttention:l})}get historyPaged(){return this.hasCapability("session.list.page")}async loadHistory({quiet:t=!1,query:i=this.#e.history.query}={}){const a=this.#e.workspace;if(!a)return;const l=this.#l,u=++this.#G,d=this.historyPaged,h=i.trim();t||this.#t(m=>({history:{...m.history,status:"loading",error:void 0,query:i}}));try{const m=await this.#o().request("session.list",{projectRoot:a,rootsOnly:!0,includeClosed:!0,includeArchived:!0,...d?{limit:this.#n.historyPageSize,...h?{query:h}:{}}:{}});if(l!==this.#l||u!==this.#G)return;const p=d&&typeof m?.nextCursor=="string"?m.nextCursor:void 0;this.#t({history:{status:"ready",list:ay(m,!d),query:i,...p?{nextCursor:p}:{}}})}catch(m){if(l!==this.#l||u!==this.#G)return;(!t||this.#e.history.status!=="ready")&&this.#t(p=>({history:{...p.history,status:"error",error:Be(m),query:i}}))}}async loadMoreHistory(){const t=this.#e.workspace,{status:i,nextCursor:a,query:l,more:u}=this.#e.history;if(!t||i!=="ready"||!a||u==="loading")return;const d=this.#l,h=this.#G,m=l.trim();this.#t(p=>({history:{...p.history,more:"loading"}}));try{const p=await this.#o().request("session.list",{projectRoot:t,rootsOnly:!0,includeClosed:!0,includeArchived:!0,limit:this.#n.historyPageSize,cursor:a,...m?{query:m}:{}});if(d!==this.#l)return;if(h!==this.#G){this.#Ue();return}const x=typeof p?.nextCursor=="string"?p.nextCursor:void 0;this.#t(y=>{const v=new Set(y.history.list.map(A=>A.id)),{more:k,nextCursor:S,...j}=y.history;return{history:{...j,list:[...j.list,...ay(p,!1).filter(A=>!v.has(A.id))],...x?{nextCursor:x}:{}}}})}catch{if(d!==this.#l)return;if(h!==this.#G){this.#Ue();return}this.#t(p=>({history:{...p.history,more:"error"}}))}}#Ue(){if(this.#e.history.more!=="loading")return;const{more:t,...i}=this.#e.history;this.#t({history:i})}get filesSearchable(){return this.hasCapability("workspace.files")}async searchWorkspaceFiles({query:t="",limit:i=Qb}={}){const a=this.#e.workspace;if(!a)throw new Pe("Choose a workspace first.");if(!this.filesSearchable)throw new Pe("The host does not offer file search. Update ALP on the host.");if(!Te(this.#e.principal??void 0,"project.read"))throw new Pe(iy);let l;try{l=await this.#o().request("workspace.files.search",{projectRoot:a,query:String(t).slice(0,200),limit:i})}catch(d){throw Be(d).code===1003?new Pe(iy):d}return{files:(Array.isArray(l?.files)?l.files:[]).filter(d=>d&&typeof d.path=="string"&&d.path).map(d=>({path:String(d.path)})),truncated:l?.truncated===!0}}get filesReadable(){return this.hasCapability("workspace.files.read")}get canReadFiles(){return Te(this.#e.principal??void 0,"files.read")}#He(t,i){const a=(d,h,m=!1)=>new Ai({message:d,reason:h,sent:"no",terminal:m}),l=this.#e.workspace;if(!l)throw a("Choose a workspace first.","workspace");if(!this.filesReadable)throw a(Pb,"capability",!0);if(!this.canReadFiles)throw a(kf,"grant",!0);if(t===void 0||t===""){if(i)throw a(Ir.invalid_path,"invalid_path");return{workspace:l,path:void 0}}const u=Qs(t);if(!u)throw a(Ir.invalid_path,"invalid_path");if(Bi(u))throw a(Ir.blocked_path,"blocked_path");return{workspace:l,path:u}}#Ie(t){const i=m2(t);return i.code===1003&&i.reason==="grant"?new Ai({...i,message:kf}):new Ai(i)}async listWorkspaceFiles({path:t,includeIgnored:i=!1}={}){const a=this.#He(t,!1);let l;try{l=await this.#o().request("workspace.files.list",{projectRoot:a.workspace,...a.path?{path:a.path}:{},...i?{includeIgnored:!0}:{}})}catch(u){throw this.#Ie(u)}return p2(l,a.path??"")}async readWorkspaceFile({path:t,includeIgnored:i=!1}){const a=this.#He(t,!0);let l;try{l=await this.#o().request("workspace.files.read",{projectRoot:a.workspace,path:a.path,...i?{includeIgnored:!0}:{}})}catch(d){throw this.#Ie(d)}const u=typeof l?.content=="string"?l.content:void 0;if(u===void 0||u.length>Hl.maxReadBytes)throw new Ai({message:u===void 0?"The host sent something this app does not understand.":Ir.too_large,...u===void 0?{}:{reason:"too_large"},sent:"yes",terminal:!1});return{path:a.path,content:u,size:typeof l?.size=="number"&&Number.isFinite(l.size)?l.size:u.length,...typeof l?.modifiedAt=="string"?{modifiedAt:l.modifiedAt}:{}}}get gitAccess(){return Gd(this.#e)}async gitStatus(){const t=Gd(this.#e);if(!t.status)throw new gs({message:t.message,reason:t.reason,sent:"no",terminal:t.reason!=="loading"});let i;try{i=await this.#o().request("workspace.git.status",{workspaceId:t.workspaceId})}catch(a){throw new gs(zi(a))}if(!i||typeof i!="object"||typeof i.state!="string"||!Array.isArray(i.files))throw new gs({message:"The host sent something this app does not understand.",sent:"yes",terminal:!1});return i}async gitDiff({compare:t,path:i,cursor:a}){const l=Gd(this.#e);if(!l.status)throw new gs({message:l.message,reason:l.reason,sent:"no",terminal:l.reason!=="loading"});if(!l.content)throw new gs({message:l.contentMessage,reason:"grant",sent:"no",terminal:!0});const u=i===void 0?void 0:ij(i);if(i!==void 0&&!u){const h=Qs(i)?"blocked_path":"invalid_path";throw new gs({message:Gl[h],reason:h,sent:"no",terminal:!1})}let d;try{d=await this.#o().request("workspace.git.diff",{workspaceId:l.workspaceId,compare:aj(t),...u?{path:u}:{},...a?{cursor:a}:{}})}catch(h){throw new gs(zi(h))}if(!d||typeof d!="object"||typeof d.snapshot!="string"||!Array.isArray(d.files))throw new gs({message:"The host sent something this app does not understand.",sent:"yes",terminal:!1});return d}isArchived(t){return t?!!this.#e.history.list.find(i=>i.id===t)?.archived&&!this.#e.sessions.list.some(i=>i.id===t):!1}async#Ne(){const t=this.#e.workspace,i=this.#e.principal;if(!t||!i)return;const a=this.#l;this.#t(l=>({catalog:{...l.catalog,status:"loading",error:void 0}}));try{const l=this.#o(),[u,d,h]=await Promise.all([this.#Ge(l,i,t),Te(i,"session.read")?l.request("catalog.get",{}).catch(()=>{}):void 0,this.hasCapability("library")&&Te(i,"session.read")?l.request("library.models",{}).catch(()=>{}):void 0]);if(a!==this.#l)return;const m=i.modes,x=(Array.isArray(d?.modes)&&d.modes.length?d.modes:Object.keys(sy).map(k=>({id:k}))).filter(k=>typeof k?.id=="string"&&(!m||m.includes(k.id))).map(k=>({id:k.id,label:typeof k.label=="string"?k.label:sy[k.id]??k.id,...typeof k.description=="string"?{description:k.description}:{}})),y=Ix(h?.models),v=x.some(k=>k.id==="full-access")?"full-access":x[0]?.id;this.#t({catalog:{status:"ready",...u,modes:x,models:y,...v?{defaultMode:v}:{}}})}catch(l){if(a!==this.#l)return;this.#t(u=>({catalog:{...u.catalog,status:"error",error:Be(l)}}))}}async#Ge(t,i,a){if(!this.hasCapability("team"))return{teams:[],teamsKnown:!1,teamsUnavailable:{reason:"capability"}};if(!Te(i,"project.read"))return{teams:[],teamsKnown:!1,teamsUnavailable:{reason:"permission"}};try{const l=await t.request("team.list",{projectRoot:a});return Array.isArray(l?.teams)?{teams:l.teams.filter(d=>typeof d?.id=="string"&&!d.error).map(d=>({id:d.id,label:typeof d.label=="string"?d.label:d.id,...typeof d.description=="string"?{description:d.description}:{}})),teamsKnown:!0}:{teams:[],teamsKnown:!1,teamsUnavailable:{reason:"failed",message:"The host answered team.list in a form this app does not read."}}}catch(l){return{teams:[],teamsKnown:!1,teamsUnavailable:{reason:"failed",message:Be(l).message}}}}startOrigin(){return{workspace:this.#e.workspace,connection:this.#U}}keepUnsentDraft(t,i){if(!t||!i?.workspace||i.connection!==this.#U)return;const a={workspace:i.workspace,text:String(t)};for(const l of this.#z)if(l(a)){this.#M=null;return}this.#M=a}takeUnsentDrafts(t){return this.#z.add(t),()=>{this.#z.delete(t)}}unsentDraft(){const t=this.#M;return t&&t.workspace===this.#e.workspace?t.text:""}clearUnsentDraft(t){(t===void 0||this.#M?.text===t)&&(this.#M=null)}async retryTeams(){const{workspace:t,principal:i,catalog:a}=this.#e;if(!t||!i||a.status!=="ready"||a.teamsUnavailable?.reason!=="failed"||this.#C)return;const l=this.#l;this.#C=!0;try{const u=await this.#Ge(this.#o(),i,t);if(l!==this.#l||this.#e.workspace!==t||this.#e.catalog.status!=="ready")return;this.#t(d=>({catalog:{...d.catalog,teams:u.teams,teamsKnown:u.teamsKnown,teamsUnavailable:u.teamsUnavailable}}))}catch{}finally{this.#C=!1}}selectSession(t){if(this.clearAttention(t),t===this.#e.selected)return;const i=t?this.#_(t):void 0;i&&(i.failed=null),this.#t({selected:t,focus:t,tree:t&&i?{rootId:t,status:i.gone?"gone":"detached",...i.gone?{error:i.gone}:{},projection:i.projection}:null}),this.#V()}focusSession(t){const i=this.#e.tree?.projection;!i||t!==i.rootId&&!i.sessions[t]||(this.clearAttention(t),this.#t({focus:t}))}async createSession({team:t,mode:i,model:a,thinking:l,title:u,prompt:d,files:h=[]}={}){const m=this.#e.workspace;if(!m)throw new Pe("Choose a workspace first.");if(this.#T||this.#e.busy.create)throw new Pe("A new session is already starting.");const p=this.#o(),x=G2(),y=this.#l;this.#T=x,this.#t(A=>({busy:{...A.busy,create:!0}}));const v=this.#_(x),k={id:x,projectRoot:m,status:"initializing",...u?{title:u}:{},createdAt:new Date().toISOString()};this.#t(A=>({selected:x,focus:x,tree:{rootId:x,status:"attaching",projection:v.projection},sessions:{...A.sessions,list:[k,...A.sessions.list.filter(R=>R.id!==x)]}}));const S=()=>y===this.#l&&p===this.#i?.alp?.client,j=()=>{if(!S())throw new Pe("The connection or workspace changed while starting the session.")};try{return await this.#k(p,async()=>{j();const A=this.#s;A&&A.client===p&&(this.#s=null,this.#a=null,await this.#J(A)),j();const R={buffer:[]};v.attaching=R,this.#a=x;const q={cwd:m,persist:!0,...t?{workflow:t}:{},...i?{mode:i}:{},...a?{model:a}:{},...l?{thinking:l}:{}};this.#s={client:p,root:x};try{await p.request("session.create",{sessionId:x,spec:q,history:"skip"},{timeoutMs:this.#n.createTimeoutMs}),j(),this.#s={client:p,root:x}}catch(L){if(!S())throw L;v.attaching=null;const O=Be(L);throw O.sent!=="unknown"?(this.#s?.client===p&&this.#s.root===x&&(this.#s=null,await this.#J({client:p,root:x})),S()&&(this.#r.delete(x),this.#c.delete(x),this.#f.delete(x),this.#a===x&&(this.#a=null),this.#t(B=>({...B.selected===x?{selected:null,focus:null,tree:null}:{},sessions:{...B.sessions,list:B.sessions.list.filter(_=>_.id!==x)}}))),L):(this.refreshSessions(),new vb(`${O.message} If the new session shows in the list, open it and send your message there; otherwise start again.`,x))}try{let L;if(this.hasCapability("session.history")){const B=await p.request("session.history",{sessionId:x,limit:1},{timeoutMs:this.#n.requestTimeoutMs});j(),L=B.generation,this.#c.set(x,{generation:L,hasOlder:!1})}const O=await p.request("session.attach",{sessionId:x,...L?{generation:L,after:0}:{}},{timeoutMs:this.#n.requestTimeoutMs});j(),v.attaching===R&&(v.attaching=null,v.failed=null,this.#we(x,v,O,R.buffer))}catch(L){if(!S())throw L;v.attaching===R&&(v.attaching=null),this.#a===x&&(this.#a=null),this.#Se(p,x,L)}return u?.trim()&&await this.renameSession(x,u.trim()).catch(()=>{}),j(),this.#Ct({team:t,mode:i,model:a,thinking:l}),(d?.trim()||h.length)&&await this.sendPrompt(d??"",x,[],h,{keepRefused:!0}).catch(L=>this.#u("error",Be(L).message)),this.refreshSessions({quiet:!0}),x})}finally{this.#T===x&&(this.#T=null,this.#t(A=>({busy:{...A.busy,create:!1}}))),this.#V()}}async renameSession(t,i){const u=(await this.#o().request("session.rename",{sessionId:t,title:i}))?.session,d=m=>m.id===t?{...m,...u&&typeof u=="object"?u:{},title:i}:m;this.#t(m=>({sessions:{...m.sessions,list:m.sessions.list.map(d)},history:{...m.history,list:m.history.list.map(d)}}));const h=this.#r.get(t);h&&(h.projection={...h.projection,sessions:{...h.projection.sessions,[t]:{...h.projection.sessions[t],id:t,title:i}}},this.#L(t))}async archiveSession(t){const i=this.#o(),a=this.#l;if(await i.request("session.archive",{sessionId:t,archived:!0}),a!==this.#l)return;this.#e.selected===t&&this.selectSession(null);const{[t]:l,...u}=this.#e.attention,{[t]:d,...h}=this.#e.turnAttention;this.#t(m=>({turnAttention:h,sessions:{...m.sessions,list:m.sessions.list.filter(p=>p.id!==t)},history:{...m.history,list:m.history.list.map(p=>p.id===t?{...p,archived:!0}:p)},attention:u}))}async restoreSession(t){const i=this.#o(),a=this.#l,l=await i.request("session.archive",{sessionId:t,archived:!1});if(a!==this.#l)return;const u=l?.session&&typeof l.session=="object"?l.session:void 0;this.#t(d=>{const m={...d.history.list.find(p=>p.id===t)??{},...u??{},id:t,archived:!1};return{history:{...d.history,list:d.history.list.map(p=>p.id===t?m:p)},sessions:{...d.sessions,list:d.sessions.list.some(p=>p.id===t)?d.sessions.list:[m,...d.sessions.list]}}}),this.refreshSessions({quiet:!0})}#ue(t){const i=this.#e.sessions.list.find(l=>l.id===t)??this.#e.history.list.find(l=>l.id===t),a=this.#r.get(t)?.projection.sessions[t];return{...i??{},...a??{},...a?.conversation?{}:i?.conversation?{conversation:i.conversation}:{}}}conversationGate(t=this.#e.tree?.rootId){const{principal:i,connection:a}=this.#e,l=t?this.#r.get(t):void 0,u=!!t&&!!l&&(this.rootBusy(t)||Object.keys(l.projection.running).length>0||Object.keys(l.projection.questions).length>0);return X2({capabilities:a.capabilities,canRead:Te(i??void 0,"session.read"),canWrite:Te(i??void 0,"session.write"),summary:t?this.#ue(t):null,busy:u,generation:t?this.#c.get(t)?.generation??null:null,online:a.phase==="open",driveBlock:t&&t===this.#e.tree?.rootId?this.driveBlock():void 0})}agentControls(t){const{principal:i,connection:a}=this.#e,l=this.#e.tree?.rootId,u=l?this.#r.get(l):void 0,d=!!l&&t===l,h=d&&!!u&&(this.rootBusy(l)||Object.keys(u.projection.running).length>0||Object.keys(u.projection.questions).length>0);return W2({capabilities:a.capabilities,canRead:Te(i??void 0,"session.read"),canWrite:Te(i??void 0,"session.write"),summary:d?this.#ue(l):null,root:d,closed:d&&!!u?.projection.closed[l],busy:h,generation:d?this.#c.get(l)?.generation??null:null,online:a.phase==="open",driveBlock:d?this.driveBlock():void 0})}async copyResumeCommand(t,i){try{const a=await this.#o().request("session.resumeCommand",{sessionId:t});if(typeof a?.display!="string"||!a.display)throw new Pe("The host answered no command.");return await i(a.display),this.#u("info",`Copied the resume command: ${a.display}`),a}catch(a){this.#u("error",`Could not copy the resume command: ${Be(a).message}`);return}}async reloadAgent({sessionId:t,requestId:i}){const{root:a,generation:l,client:u}=this.#de();if(t!==a)throw new Pe(Fr.not_root);this.#u("info","Reloading the agent…");try{const d=await u.request("session.reload",{sessionId:a,requestId:i,ifGeneration:l},{timeoutMs:this.#n.createTimeoutMs});return this.#Te(d.session),this.refreshSessions({quiet:!0}),this.#u("info","Reloaded the agent: it restarted on the same conversation."),d}catch(d){throw this.#fe(a,d),this.#u("error",Q2(d).message),d}}rootSummary(t=this.#e.tree?.rootId){return t?this.#ue(t):{}}historyGeneration(t){return this.#c.get(t)?.generation}#Te(t){if(!t||typeof t.id!="string")return;const i=t.id,a=u=>u.id===i?{...u,...t}:u;this.#t(u=>({sessions:{...u.sessions,list:u.sessions.list.map(a)},history:{...u.history,list:u.history.list.map(a)}}));const l=this.#r.get(i);l&&(l.projection={...l.projection,sessions:{...l.projection.sessions,[i]:{...l.projection.sessions[i],...t,id:i}}},this.#L(i))}#de(){const t=this.#e.tree?.rootId??this.#e.selected;if(!t)throw new Pe("Open a session first.");const i=this.#c.get(t)?.generation;if(!i)throw new Pe("The conversation is still loading. Try again in a moment.");return{root:t,generation:i,client:this.#o()}}#fe(t,i){if(!Oi(i).reload)return;const a=this.#s?.root===t?this.#s.client:void 0;this.#c.delete(t),a&&this.#ke(a,t)}async rewindConversation({beforeTurnId:t,requestId:i}){const{root:a,generation:l,client:u}=this.#de();try{const d=await u.request("session.rewind",{sessionId:a,requestId:i,ifGeneration:l,beforeTurnId:t},{timeoutMs:this.#n.createTimeoutMs});return this.#Te(d.session),this.#qe(a,d.generation),this.refreshSessions({quiet:!0}),d}catch(d){throw this.#fe(a,d),d}}async forkConversation({requestId:t,boundary:i,branchId:a,workspaceId:l,directory:u,title:d}){const{root:h,generation:m,client:p}=this.#de();let x;try{x=await p.request("session.fork",{sessionId:h,requestId:t,ifGeneration:m,...i?{boundary:i}:{},...a?{branchId:a}:{},...l?{workspaceId:l}:{},...d?.trim()?{title:d.trim()}:{}},{timeoutMs:this.#n.createTimeoutMs})}catch(y){throw this.#fe(h,y),y}return this.#gt(x.session,u),x}#gt(t,i){const a=t?.id;typeof a=="string"&&(i&&i!==this.#e.workspace&&this.selectWorkspace(i),this.#t(l=>({sessions:{...l.sessions,list:[t,...l.sessions.list.filter(u=>u.id!==a)]}})),this.selectSession(a),this.refreshSessions({quiet:!0}))}worktreeForkSource(){const{workspace:t,principal:i,registry:a}=this.#e;if(!t||!this.hasCapability("workspace.worktree")||!this.hasCapability("workspace.registry")||!Te(i??void 0,"workspace.manage"))return null;const l=i?.workspaceRoots?.find(u=>u.path===t)?.canonical;return a.workspaces.find(u=>!u.managedWorktree&&!u.archivedAt&&(u.directory===t||u.directory===l))??null}async forkIntoWorktree({requestId:t,worktreeKey:i=t,mappingId:a,boundary:l,branchId:u,title:d}){const h=this.worktreeForkSource();if(!h)throw new Pe("Worktrees are not available for this workspace.");const m=this.#d.get(t)??i;this.#d.set(t,m);try{let p=this.#w.get(m);if(!p){let y=this.#b.get(m);y||(y={workspaceId:h.id,mappingId:a,ifRevision:this.#e.registry.revision,requestId:`${m}:worktree`},this.#b.set(m,y));let v;try{v=await this.#o().request("workspace.worktree.create",y,{timeoutMs:this.#n.createTimeoutMs})}catch(k){throw(k?.data?.reason==="stale_revision"||Be(k).sent==="yes")&&this.#b.delete(m),k}p={id:v.workspace.id,directory:v.workspace.directory},this.#w.set(m,p),this.#b.delete(m),await this.refreshRegistry()}const x=await this.forkConversation({requestId:t,boundary:l,branchId:u,workspaceId:p.id,directory:p.directory,title:d});return this.#d.delete(t),x}catch(p){throw Oi(p).retrySame||this.#d.delete(t),p}}async worktreeForkDestinations(){const t=this.worktreeForkSource();return t?this.worktreeOptions(t.id):[]}driveBlock(){const{principal:t,tree:i}=this.#e;if(!t)return"Not connected.";if(!Te(t,"session.write"))return"Your access token can view sessions but not send messages.";if(!i)return;const a=t.modes;if(a){const l=qb(i.projection).find(u=>u.session?.mode&&!a.includes(u.session.mode));if(l)return`Your access token can only drive sessions in ${a.join(", ")} mode; this conversation runs in ${l.session?.mode}.`}}#xt(t,i){return this.#k(t,async()=>{if(!(t!==this.#i?.alp?.client||this.#e.selected!==i))try{await this.#yt(t,i)}finally{this.#V()}})}async#yt(t,i){const a=this.#_(i),l=a.projection.sessions[i],u=this.#e.sessions.list.find(y=>y.id===i);if(!(a.projection.closed[i]||l?.status==="closed"||!l&&u?.status==="closed"))return;const h=l?.projectRoot??u?.projectRoot??this.#e.workspace??"",m=Ll(this.#e.principal??void 0,h)?.path??this.#e.workspace??h,p=l?.mode??u?.mode,x={buffer:[]};a.attaching=x,this.#a=i;try{if(await t.request("session.create",{sessionId:i,spec:{cwd:m,...p?{mode:p}:{}},resume:!0,history:"skip"},{timeoutMs:this.#n.createTimeoutMs}),t!==this.#i?.alp?.client)return;if(this.#s={client:t,root:i},this.hasCapability("session.history")&&!this.#c.has(i)){const S=await t.request("session.history",{sessionId:i},{timeoutMs:this.#n.requestTimeoutMs});if(a.attaching!==x)return;a.projection=xs(i);for(const j of S.items)a.projection=Ei(a.projection,bf(j,i));this.#W(a.projection),a.projection={...a.projection,cursor:S.tipCursor},this.#c.set(i,{generation:S.generation,olderCursor:S.olderCursor,hasOlder:S.hasOlder})}const y=a.projection.cursor,v=this.#c.get(i),k=await t.request("session.attach",{sessionId:i,...v?{after:y,generation:v.generation}:y>0?{after:y}:{}},{timeoutMs:this.#n.requestTimeoutMs});a.attaching===x&&(a.attaching=null,this.#we(i,a,k,x.buffer))}catch(y){throw a.attaching===x&&(a.attaching=null),y}}async sendPrompt(t,i=this.#e.selected,a=[],l=[],{keepRefused:u=!1}={}){const d=String(t??"");if(!i||!d.trim()&&!a.length&&!l.length)return;const h=this.driveBlock();if(h)throw new Pe(h);const m=Xr([],a,this.#e.connection.promptImageLimits);if(m.error)throw new Pe(m.error);const p=l.length?this.#Ye(i,l):null;if(p&&!u)throw new Pe(p);const x=Tl(),y={id:x,rootId:i,text:d,...a.length?{images:a}:{},...l.length?{files:l.map(v=>({...v,received:0,error:void 0})),uploadKey:x}:{},delivery:this.rootBusy(i)?"steer":"auto",status:"sending",retrySameId:!0,at:Date.now()};if(this.clearAttention(i),p){this.#t(v=>({prompts:[...v.prompts,{...y,status:"failed",error:p}]})),this.#Ee(y);return}this.#t(v=>({prompts:[...v.prompts,y]})),this.#Ee(y),await this.#Ve(y)}fileGate(t=this.#e.selected){const{connection:i,principal:a}=this.#e,l=t?this.#r.get(t)?.projection.sessions[t]??this.#e.sessions.list.find(u=>u.id===t):void 0;return pj({capable:i.capabilities.includes("attachments"),permitted:Te(a??void 0,"attachments.write"),writable:Te(a??void 0,"session.write"),limits:i.attachmentLimits,session:l,known:!!t})}#Ye(t,i){return this.fileGate(t)??Ol([],i,this.#e.connection.attachmentLimits??Ks).error}#bt(t,i){const a=this.#vt(t,i);this.#he.set(i.id,a);const l=()=>{this.#he.get(i.id)===a&&this.#he.delete(i.id)};return a.then(l,l),a}#he=new Map;#ee(t){return this.#e.prompts.some(i=>i.id===t)}async#vt(t,i){const a=i.files??[],l=i.uploadKey??i.id,u=this.#e.connection.attachmentLimits??Ks,d=(p,x)=>this.#t(y=>({prompts:y.prompts.map(v=>v.id===i.id&&v.files?{...v,files:v.files.map((k,S)=>S===p?{...k,...x}:k)}:v)})),h=$d(t),m=[...a];for(const[p,x]of a.entries())if(!x.attachmentId){if(!this.#ee(i.id))throw new $r;d(p,{error:void 0,received:x.received??0,started:!0});try{const y=await h.upload({sessionId:i.rootId,name:x.name,mimeType:x.mimeType,data:x.data,requestId:qx(l,p,x.attempt),maxChunkBytes:u.maxChunkBytes,onProgress:v=>{if(!this.#ee(i.id))throw new $r;d(p,{received:v})}});if(typeof y?.attachmentId!="string")throw new Error(`The host did not answer an attachment for ${x.name}.`);m[p]={...x,attachmentId:y.attachmentId,received:x.size,error:void 0},d(p,{attachmentId:y.attachmentId,received:x.size,error:void 0})}catch(y){if(y instanceof $r||!this.#ee(i.id))throw new $r;const v=Be(y);throw d(p,{error:v.message}),new ry(x.name,v,Ff(y)&&["closed","disconnected","send_failed"].includes(y.reason))}}return m}#wt(){for(const t of this.#e.prompts)t.status!=="failed"||!t.resumeUpload||t.resumeUpload>3||this.retryPrompt(t.id,{resume:!0}).catch(()=>{})}async#Ve(t){const i=t.rootId,a=this.#te.get(i),l=(async()=>{a&&await a.catch(()=>{});const u=this.#e.prompts.find(h=>h.id===t.id);if(!u||u.status!=="sending")return;const d=this.rootBusy(i,t.id)?"steer":"auto";d!==u.delivery&&this.#t(h=>({prompts:h.prompts.map(m=>m.id===t.id?{...m,delivery:d}:m)})),await this.#Ke({...u,delivery:d})})();this.#te.set(i,l);try{await l}finally{this.#te.get(i)===l&&this.#te.delete(i)}}#te=new Map;rootBusy(t=this.#e.selected,i){if(!t)return!1;const a=this.#r.get(t);if(a&&t in a.projection.running||this.#x.has(t))return!0;for(const u of this.#O.get(t)??[]){if(u===i)continue;const d=a?.projection.prompts[u];if(!this.#F.has(u)&&(!d||d.errorCode==="outcome_unknown"))return!0}if(this.#e.prompts.some(u=>u.rootId===t&&u.id!==i&&u.status==="unknown")||this.#e.prompts.some(u=>u.rootId===t&&u.id!==i&&u.status==="sending"&&!u.accepted&&this.#pe.has(u.id)))return!0;const l=this.#K.get(t);if(!l||!a)return!1;for(const[u]of l){if(u===i)continue;const d=a.projection.prompts[u];if(!(d?.state==="failed"||!d&&!this.#F.has(u)||(!d?.turnId||!a.projection.turns[d.turnId])&&Date.now()-(this.#ne.get(u)??0)>this.#Pe)&&(!d||!Ux(a.projection,u)))return!0}return!1}async configureMode(t){const i=this.#e.selected;if(!i||!t)return;const a=this.#e.principal?.modes,l=this.driveBlock()??(a&&!a.includes(t)?`Your access token can only use ${a.join(", ")} mode.`:void 0);if(l){this.#u("error",l);return}if(!this.#e.busy.mode){this.#t(u=>({busy:{...u.busy,mode:!0}}));try{const u=await this.#o().request("session.configure",{sessionId:i,mode:t},{timeoutMs:this.#n.requestTimeoutMs}),d=this.#r.get(i),h=typeof u?.session?.mode=="string"?u.session.mode:t;d&&(d.projection={...d.projection,sessions:{...d.projection.sessions,[i]:{...d.projection.sessions[i],id:i,mode:h}}},this.#L(i)),this.#t(m=>({sessions:{...m.sessions,list:m.sessions.list.map(p=>p.id===i?{...p,mode:h}:p)}}))}catch(u){this.#u("error",Be(u).message)}finally{this.#t(u=>({busy:{...u.busy,mode:!1}}))}}}liveConfigure(){const{principal:t,connection:i,busy:a}=this.#e,l=this.#e.tree?.rootId,u=l?this.#r.get(l):void 0,d=!!l&&!!u&&(this.rootBusy(l)||Object.keys(u.projection.running).length>0||Object.keys(u.projection.questions).length>0);return Bj({capabilities:i.capabilities,canWrite:Te(t??void 0,"session.write"),canTeam:Te(t??void 0,"session.team.write"),summary:l?this.#ue(l):null,closed:!!l&&!!u?.projection.closed[l],busy:d,configuring:!!a.configure||!!a.mode,generation:l?this.#c.get(l)?.generation??null:null,online:i.phase==="open",driveBlock:l?this.driveBlock():void 0})}async previewConfigure(t={}){const i=this.#e.tree?.rootId;if(!i||!this.hasCapability(Ib)||!Te(this.#e.principal??void 0,"session.read"))return;const a=await this.#o().request("session.configure.preview",{sessionId:i,...t},{timeoutMs:this.#n.requestTimeoutMs});return a?.preview&&typeof a.preview=="object"?a.preview:void 0}#me;async configureLive(t){const i=this.#e.tree?.rootId,a=Object.fromEntries(Object.entries(t).filter(([h,m])=>["model","thinking","team"].includes(h)&&typeof m=="string"&&m));if(!i||!Object.keys(a).length||this.#e.busy.configure)return;const l=this.liveConfigure(),u=a.team?l.team:a.model?l.model:l.thinking;if(!l.shown||!u.enabled){this.#u("error",u.reason??l.reason??"This change is not available now.");return}this.#t(h=>({busy:{...h.busy,configure:!0}}));const d=JSON.stringify([i,a]);try{if(a.team){const v=await this.previewConfigure(a).catch(()=>{});if(v&&!v.allowed){const k=v.reason??"runtime_unsupported";this.#u("error",Ma[k]??v.message??"The host would not take this change.",Gb.has(k)?{action:"new-session"}:void 0);return}}const{generation:h,client:m}=this.#de(),p=this.#me?.key===d?this.#me.requestId:Qf();this.#me=void 0;let x;try{x=await m.request("session.configure",{sessionId:i,...a,requestId:p,ifGeneration:h},{timeoutMs:this.#n.createTimeoutMs})}catch(v){const k=Kx(v);k.retrySame&&(this.#me={key:d,requestId:p}),this.#fe(i,v),this.#u("error",k.message,k.newSession?{action:"new-session"}:void 0);return}const y=x?.configured;if(this.#Te($j(x.session,y?.effective)),this.refreshSessions({quiet:!0}),y){const v=this.#e.catalog.models.find(k=>k.id===`${y.effective.runtime}:${y.effective.model}`)?.label;this.#u("info",Uj(y,Vs,v))}return x}catch(h){this.#u("error",Kx(h).message);return}finally{this.#t(h=>({busy:{...h.busy,configure:!1}}))}}async#Ke(t){const i=a=>this.#t(l=>({prompts:l.prompts.map(u=>u.id===t.id?{...u,...a}:u)}));this.#pe.add(t.id);try{const a=this.#o();!(this.#T===t.rootId&&this.#s?.client===a&&this.#s.root===t.rootId)&&this.#e.selected===t.rootId&&await this.#xt(a,t.rootId);const u=Xr([],t.images??[],this.#e.connection.promptImageLimits);if(u.error)throw new Pe(u.error);let d=t.files??[];if(d.length){const p=this.#Ye(t.rootId,d);if(p)throw new Pe(p);if(d=await this.#bt(a,t),!this.#ee(t.id))return}if(!this.#ee(t.id))return;i({submitted:!0});let h=this.#O.get(t.rootId);h||this.#O.set(t.rootId,h=new Set),h.add(t.id);const m=await a.request("session.prompt",{sessionId:t.rootId,clientMessageId:t.id,delivery:t.delivery,content:kj(t.text,t.images,d)},{timeoutMs:this.#n.requestTimeoutMs});if(m?.outcome==="unknown"){i({status:"unknown",error:"The host cannot tell whether the agent took the message.",retrySameId:!1});return}if(m?.outcome==="failed"){this.#Re(t.rootId,t.id),i({status:"failed",error:m.error?.message?`The agent did not take the message: ${m.error.message}`:"The agent did not take the message.",retrySameId:!1});return}this.#F.add(t.id),this.#St(),this.#Fe(t)?this.#Ae(t.id):i({accepted:!0})}catch(a){if(this.#Fe(t))return this.#Ae(t.id);if(a instanceof $r)return;if(a instanceof ry){const u=a.dropped,d=this.#e.prompts.find(h=>h.id===t.id)?.resumeUpload??0;i({status:"failed",error:`Could not upload ${a.fileName}: ${a.failure.message}${u?" The upload continues when the connection is back.":""}`,retrySameId:!0,resumeUpload:u?d+1:0});return}const l=Be(a);t.files?.length&&(l.reason==="attachment_unavailable"||l.code===1001)&&await this.#kt(t,a),l.sent==="no"?i({status:"failed",error:l.message,retrySameId:!0}):l.sent==="yes"&&l.reason!=="outcome_unknown"?i({status:"failed",error:l.message,retrySameId:!1}):i({status:"unknown",error:l.message,retrySameId:l.reason!=="outcome_unknown"})}finally{this.#pe.delete(t.id),this.#e.prompts.find(l=>l.id===t.id)?.status==="failed"?this.#Re(t.rootId,t.id):this.#A(t.rootId)}}async#kt(t,i){const a=i?.data,u=(this.#e.prompts.find(h=>h.id===t.id)?.files??[]).filter(h=>typeof h.attachmentId=="string");let d;if(a?.reason==="attachment_unavailable"){const h=u.filter(m=>m.attachmentId===a?.attachmentId);d=new Set((h.length?h:u).map(m=>m.attachmentId))}else{let h;try{h=$d(this.#o())}catch{return}const m=await Promise.all(u.map(p=>h.get(p.attachmentId).then(()=>!1,x=>Be(x).code===1001)));d=new Set(u.filter((p,x)=>m[x]).map(p=>p.attachmentId))}d.size&&this.#t(h=>({prompts:h.prompts.map(m=>m.id===t.id&&m.files?{...m,files:m.files.map(p=>p.attachmentId&&d.has(p.attachmentId)?{...p,attachmentId:void 0,received:0,started:!1,attempt:(p.attempt??0)+1}:p)}:m)}))}#pe=new Set;#Fe(t){const i=this.#r.get(t.rootId);return!!i&&Hx(i.projection).has(t.id)}#Ae(t){this.#t(i=>({prompts:i.prompts.filter(a=>a.id!==t)}))}async retryPrompt(t,{resume:i=!1}={}){const a=this.#e.prompts.find(d=>d.id===t);if(!a||a.status==="sending")return;const l=i?a.resumeUpload:0,u=a.retrySameId?{...a,status:"sending",error:void 0,accepted:!1,resumeUpload:l}:{...a,id:Tl(),delivery:this.rootBusy(a.rootId,a.id)?"steer":"auto",status:"sending",error:void 0,retrySameId:!0,accepted:!1,resumeUpload:l,...a.files?.length?{uploadKey:a.uploadKey??a.id}:{}};if(this.#t(d=>({prompts:d.prompts.map(h=>h.id===t?u:h)})),u.id===a.id)return this.#Ke(u);this.#Xe(a.rootId,a.id),this.#Ee(u),await this.#Ve(u)}#Xe(t,i){this.#K.get(t)?.delete(i),this.#ne.delete(i),this.#F.delete(i)}discardPrompt(t){const i=this.#e.prompts.find(a=>a.id===t);i&&this.#Xe(i.rootId,t),this.#Ae(t),i&&this.#jt(i)}#jt(t){const i=(t.files??[]).map((u,d)=>({file:u,slot:d})).filter(({file:u})=>u.started&&!u.attachmentId);if(!i.length)return;const a=t.uploadKey??t.id,l=this.#he.get(t.id)??Promise.resolve();this.#Ce=this.#Ce.then(()=>l.catch(()=>{})).then(async()=>{let u;try{u=this.#o()}catch{return}const d=$d(u);for(const{file:h,slot:m}of i)await wj(d,{sessionId:t.rootId,file:h,requestId:qx(a,m,h.attempt),digest:bb})})}#Ce=Promise.resolve();abandonedUploads(){return this.#Ce}#K=new Map;#Ee(t){let i=this.#K.get(t.rootId);i||this.#K.set(t.rootId,i=new Map),i.set(t.id,this.#r.get(t.rootId)?.projection.reset??0),this.#ne.set(t.id,Date.now())}#ne=new Map;#F=new Set;#$;get#Pe(){return this.#n.busyUnseenMs}#St(){this.#$!==void 0&&clearTimeout(this.#$),this.#$=setTimeout(()=>{this.#$=void 0,this.#i&&this.#t(t=>({busy:{...t.busy}}))},this.#Pe+100)}#Qe(t,i){const a=this.#K.get(t);if(!a)return!0;for(const[l,u]of a){const d=i.historyUnavailable&&i.reset>u&&Object.keys(i.running).length===0;(Ux(i,l)||d)&&(a.delete(l),this.#ne.delete(l),this.#F.delete(l))}return a.size===0}queuePrompt(t){const i=this.#e.selected,a=String(t??"");if(!i||!a.trim())return;const l=this.driveBlock();if(l)throw new Pe(l);this.#t(u=>({queued:[...u.queued,{id:Tl(),rootId:i,text:a}]}))}interruptAndSend(t){const i=this.#e.selected,a=String(t??"");if(!i||!a.trim())return;const l=this.driveBlock();if(l)throw new Pe(l);this.#t(u=>({queued:[{id:Tl(),rootId:i,text:a},...u.queued]})),this.interrupt()}editQueued(t){const i=this.#e.queued.find(a=>a.id===t);return i?(this.#t(a=>({queued:a.queued.filter(l=>l.id!==t)})),i.text):null}async sendQueuedNow(t){const i=this.#e.queued.find(a=>a.id===t);!i||i.rootId!==this.#e.selected||(this.#t(a=>({queued:a.queued.filter(l=>l.id!==t)})),await this.sendPrompt(i.text))}#Me=!1;#Nt(){this.#Me||(this.#Me=!0,queueMicrotask(()=>{this.#Me=!1,this.#Tt()}))}#Tt(){const{selected:t,tree:i,connection:a,prompts:l,queued:u}=this.#e;if(!t||a.phase!=="open"||!i||i.rootId!==t||i.status!=="attached"||t in i.projection.running||l.some(h=>h.rootId===t)||!this.#Qe(t,i.projection)||this.driveBlock())return;const d=u.find(h=>h.rootId===t);d&&this.sendQueuedNow(d.id).catch(()=>{})}#O=new Map;#x=new Map;async interrupt(){const t=this.#e.selected;if(!t)return;const i=this.#x.get(t);if(i)return i.attempts=0,i.exhausted=!1,i.observer?.state==="stopped"&&this.#We(t,i),this.#A(t),i.promise;if(!this.hasCapability("session.interrupt.turn")){this.#u("error","This host cannot safely stop a specific turn. Upgrade the host to use Stop.");return}const a=this.#r.get(t)?.projection,l=a?.running[t],u=l?void 0:[...new Set([...this.#O.get(t)??[],...this.#e.prompts.filter(x=>x.rootId===t&&x.status!=="failed").map(x=>x.id)])].find(x=>{const y=a?.prompts[x];return!y||y.state==="failed"&&y.errorCode==="outcome_unknown"||y.state==="accepted"&&(!y.turnId||a?.turns[y.turnId]!=="ended")});if(!l&&!u)return;const d=this.#e.prompts.find(x=>x.id===u);if(d&&!d.submitted){this.discardPrompt(d.id),this.#u("info","Message canceled before sending.");return}let h=()=>{};const m=new Promise(x=>{h=()=>x(void 0)}),p={...l?{turnId:l}:{messageId:u},done:h,promise:m};return this.#x.set(t,p),this.#We(t,p),this.#t(x=>({busy:{...x.busy,interrupt:!0}})),l||this.#u("info",ny),this.#A(t),m}#We(t,i){const a=this.#i,l=this.#e.principal?.id,{open:u,backoff:d,stableMs:h,requestTimeoutMs:m}=this.#n,p=this.#e.connection.gateway,x=this.#m;let y=null,v=!1;i.observed??=this.#r.get(t)?.projection??xs(t);const k=()=>this.#i===a&&this.#x.get(t)===i,S=Ax({connect:async({signal:j})=>{const A=await u({url:p,token:x,signal:j});if(!k())throw A.transport.close(),new Pe("This Stop is no longer waiting.");if(A.principal.id!==l||!Te(A.principal,"session.read")||!Te(A.principal,"session.write"))throw A.transport.close(),new Ra("Stop access changed. Reconnect with the original access before trying again.");return A.transport},onConnect:async(j,{signal:A})=>{const R=await Tx(j,ty,{signal:A,timeoutMs:m}),q=Array.isArray(R.capabilities)?R.capabilities:[];if(!q.includes("session.interrupt.turn")||!q.includes("attach.after"))throw new Pe("This host cannot safely observe and stop a specific turn.");y=[];const L=await j.request("session.attach",{sessionId:t,after:i.observed?.cursor??0},{signal:A,timeoutMs:m});k()&&(i.observed=$x(i.observed??xs(t),L,y),i.observed={...i.observed,cursor:Math.max(i.observed.cursor,L.cursor??0)},y=null,this.#A(t))},onDisconnect:()=>{y=null},shouldRetry:j=>!Be(j).terminal&&!Ud(j),backoff:d,stableMs:h,client:{timeoutMs:m}});i.observer=S,S.onEvent(j=>{if(!(!k()||j.sessionId!==t)){if(y){y.push(j);return}i.observed=Ei(i.observed??xs(t),j),this.#A(t)}}),S.onState((j,A)=>{k()&&(j==="open"?(v&&(i.attempts=0,i.exhausted=!1),v=!0,this.#A(t)):j==="stopped"&&(this.#je(t),i.exhausted=!0,this.#e.selected===t&&this.#t(R=>({busy:{...R.busy,interrupt:!1}})),this.#u("error",`Stop is unresolved: ${Be(A).message}`)))})}#ze(t){const i=this.#x.get(t);i&&(this.#x.delete(t),this.#je(t),clearTimeout(i.retry),i.observer?.stop(),i.done(),this.#e.notice?.text===ny&&this.#t({notice:null}),this.#e.selected===t&&this.#t(a=>({busy:{...a.busy,interrupt:!1}})))}#Re(t,i){this.#O.get(t)?.delete(i),this.#x.get(t)?.messageId===i&&(this.#u("info","The agent did not take that message. There is no turn to stop."),this.#ze(t))}#A(t){const i=this.#x.get(t);if(!i)return;const a=this.#r.get(t)?.projection,l=[i.observed,a].filter(m=>!!m).sort((m,p)=>(p?.cursor??0)-(m?.cursor??0)),u=i.messageId?l.map(m=>m?.prompts[i.messageId]).find(Boolean):void 0;if(u?.state==="failed"&&u.errorCode!=="outcome_unknown"){this.#Re(t,i.messageId);return}if(!i.turnId&&u?.state==="accepted"&&u.turnId&&(i.turnId=u.turnId),i.turnId&&l.some(m=>m?.turns[i.turnId]==="ended")){this.#ze(t);return}const d=i.observer?.state==="open"?i.observer.client:void 0,h=d??(this.#e.connection.phase==="open"?this.#i?.alp?.client:void 0);if(!(!i.turnId||i.sending||i.exhausted||i.observer?.state==="stopped"||!h)){if(!d&&!this.hasCapability("session.interrupt.turn")){i.warned||(i.warned=!0,this.#u("error","Stop is still waiting: this host cannot safely stop a specific turn."));return}clearTimeout(i.retry),i.sending=!0,i.attempts=(i.attempts??0)+1,this.#e.selected===t&&this.#t(m=>({busy:{...m.busy,interrupt:!0}})),h.request("session.interrupt",{sessionId:t,turnId:i.turnId},{timeoutMs:this.#n.requestTimeoutMs}).then(m=>{this.#x.get(t)===i&&typeof m?.interrupted=="boolean"&&this.#ze(t)},m=>{this.#x.get(t)===i&&this.#u("error",`Stop is still waiting for this turn's outcome: ${Be(m).message}`)}).finally(()=>{i.sending=!1,this.#x.get(t)===i&&((i.attempts??0)<3?i.retry=setTimeout(()=>this.#A(t),250):(i.exhausted=!0,this.#e.selected===t&&this.#t(m=>({busy:{...m.busy,interrupt:!1}})),this.#u("error","Stop is unresolved. Try Stop again to check this same turn.")))})}}async answerQuestion(t,{text:i,dismiss:a=!1}){const l=`question:${t}`;this.#t(u=>({busy:{...u.busy,[l]:!0}}));try{await this.#o().request("question.answer",a?{questionId:t,dismiss:!0,reason:"Declined in ALP web"}:{questionId:t,text:String(i??"")});const u=this.#e.selected,d=u?this.#r.get(u):void 0;if(d&&u&&d.projection.questions[t]){const h={...d.projection.questions};delete h[t],d.projection={...d.projection,questions:h},this.#L(u)}this.refreshAttention()}catch(u){const d=Be(u);this.#u("error",d.code===1001?"That question is no longer waiting for an answer.":d.message)}finally{this.#t(u=>({busy:{...u.busy,[l]:!1}}))}}setTasksVisible(t){this.#_e=Math.max(0,this.#_e+(t?1:-1));const i=this.#_e>0;this.#e.tasks.visible!==i&&(this.#t(a=>({tasks:{...a.tasks,visible:i}})),i&&this.refreshTasks())}#_e=0;tasksBlock(){const{principal:t}=this.#e;if(!t)return"Not connected.";if(!this.hasCapability("task"))return"This host does not offer tasks.";if(!Te(t,"project.read"))return"Your access token cannot read this workspace's tasks."}async refreshTasks({quiet:t=!1}={}){const i=this.#e.workspace;if(!i||this.tasksBlock())return;const a=this.#l;t||this.#t(l=>({tasks:{...l.tasks,status:l.tasks.rows.length?l.tasks.status:"loading",error:void 0}}));try{const l=await this.#o().request("task.list",{projectRoot:i});if(a!==this.#l||t&&l?.revision&&l.revision===this.#e.tasks.revision)return;const u=Array.isArray(l?.tasks)?l.tasks:[];this.#t(d=>({tasks:{...d.tasks,status:"ready",rows:u,revision:l?.revision,unreadable:Array.isArray(l?.unreadable)?l.unreadable.length:0,error:void 0,creates:this.#At(d.tasks.creates,u)}}))}catch(l){if(a!==this.#l)return;(!t||this.#e.tasks.status!=="ready")&&this.#t(u=>({tasks:{...u.tasks,status:"error",error:Be(l)}}))}}#At(t,i){return t.map(a=>{if(a.status!=="unknown")return a;const l=i.find(u=>u.title===a.title&&u.status!=="closed");return l?{...a,match:l.id}:{...a,match:void 0}})}async createTask({title:t,priority:i=2}){const a=this.#e.workspace,l=String(t??"").trim();if(!a||!l)return;const u={requestId:Y2(),title:l,priority:i,status:"creating"};this.#t(d=>({tasks:{...d.tasks,creates:[...d.tasks.creates,u],message:void 0}})),await this.#Ze(u)}async#Ze(t){const i=this.#e.workspace,a=this.#l,l=u=>this.#t(d=>({tasks:{...d.tasks,creates:u?d.tasks.creates.map(h=>h.requestId===t.requestId?{...h,...u}:h):d.tasks.creates.filter(h=>h.requestId!==t.requestId)}}));try{const u=await this.#o().request("task.create",{projectRoot:i,title:t.title,priority:t.priority,requestId:t.requestId});if(a!==this.#l)return;l(null),this.#t(d=>({tasks:{...d.tasks,message:{level:"info",text:u?.duplicate?`Task ${u.id} already existed for this request.`:`Created task ${u?.id??""}.`}}})),await this.refreshTasks({quiet:!1})}catch(u){if(a!==this.#l)return;const d=Be(u);d.sent==="unknown"||d.code===1e3?(l({status:"unknown",error:`${d.message} The list was read again: check it before creating this task again.`}),await this.refreshTasks()):l({status:"failed",error:d.message})}}async retryTaskCreate(t){const i=this.#e.tasks.creates.find(l=>l.requestId===t);if(!i||i.status==="creating")return;const a={...i,status:"creating",error:void 0,match:void 0};this.#t(l=>({tasks:{...l.tasks,creates:l.tasks.creates.map(u=>u.requestId===t?a:u)}})),await this.#Ze(a)}dismissTaskCreate(t){this.#t(i=>({tasks:{...i.tasks,creates:i.tasks.creates.filter(a=>a.requestId!==t)}}))}async changeTask(t,i){const a=this.#e.workspace;if(!a||!t?.id)return;const l=this.#l;this.#t(u=>({tasks:{...u.tasks,busy:{...u.tasks.busy,[t.id]:!0},message:void 0}}));try{const u=this.#o();"gate"in i?await u.request("task.gate.resolve",{projectRoot:a,id:t.id,gate:i.gate,channel:"web",...i.choice?{choice:i.choice}:{},...i.reject?{reject:!0}:{},ifRev:t.rev}):await u.request("task.update",{projectRoot:a,id:t.id,action:i.action,...i.action==="close"?{note:"Closed in ALP web"}:{},ifRev:t.rev})}catch(u){if(l!==this.#l)return;const d=Be(u);this.#t(h=>({tasks:{...h.tasks,message:{level:"error",text:d.sent==="unknown"?`${d.message} The list was read again.`:d.message}}}))}finally{l===this.#l&&(this.#t(u=>({tasks:{...u.tasks,busy:{...u.tasks.busy,[t.id]:!1}}})),await this.refreshTasks())}}setSendBehavior(t){this.#se({sendBehavior:t})}setTheme(t){this.#se({theme:t})}updatePreferences(t){this.#se(t)}#se(t){const i=_i(JSON.stringify({...this.#e.preferences,...t,v:1}));this.#t({preferences:i}),Zj(this.#n.storage,i)}#Ct(t){this.#se({newSession:Jj(this.#e.preferences.newSession,t)})}resetPreferences(){this.#se(_i(null))}reloadPreferences(){const t=Qx(this.#n.storage);JSON.stringify(t)!==JSON.stringify(this.#e.preferences)&&this.#t({preferences:t})}previewBlock(){const{principal:t,workspace:i}=this.#e;if(!t)return"Not connected.";if(!Te(t,"session.read"))return"Your access token cannot read sessions, so the host cannot say what would run.";if(!i)return"Choose a workspace first."}async previewSession(t,{signal:i}={}){const a=this.previewBlock();if(a)throw new Pe(a);const l=await this.#o().request("session.preview",{spec:{...t,cwd:this.#e.workspace}},{timeoutMs:this.#n.requestTimeoutMs,...i?{signal:i}:{}}),u=Ej(l);if(!u)throw new Pe("The host answered the preview in a form this app does not read.");return u}libraryBlock(){const{principal:t,workspace:i}=this.#e;if(!t)return"Not connected.";if(!this.hasCapability("library"))return"This host does not offer its library.";if(!Te(t,"project.read"))return"Your access token cannot read this workspace's configuration.";if(!i)return"Choose a workspace first."}async listLibrary(t){const i=this.libraryBlock();if(i)throw new Pe(i);const a=await this.#o().request("library.list",{kind:t,projectRoot:this.#e.workspace},{timeoutMs:this.#n.requestTimeoutMs});return(Array.isArray(a?.entries)?a.entries:[]).filter(l=>l&&typeof l.name=="string")}async getLibraryEntry(t,i){const a=this.libraryBlock();if(a)throw new Pe(a);const l=await this.#o().request("library.get",{kind:t,name:i,projectRoot:this.#e.workspace},{timeoutMs:this.#n.requestTimeoutMs});if(!l||typeof l!="object"||!l.content||typeof l.content!="object"||Array.isArray(l.content))throw new Pe("The host answered library.get in a form this app does not read.");const u=d=>Array.isArray(d)?d.filter(h=>typeof h=="string"):[];return{kind:typeof l.kind=="string"?l.kind:t,name:typeof l.name=="string"?l.name:i,source:typeof l.source=="string"?l.source:"unknown",...typeof l.overrides=="string"?{overrides:l.overrides}:{},content:l.content,...typeof l.revision=="string"||l.revision===null?{revision:l.revision}:{},usedBy:u(l.usedBy),...Array.isArray(l.librarySkills)?{librarySkills:u(l.librarySkills)}:{},secrets:u(l.secrets)}}libraryWriteBlock(t){const i=this.libraryBlock();return i||(Te(this.#e.principal??void 0,"library.write")?this.hasCapability("library.project.write")?["agents","skills"].includes(t)?null:"Executable and administrative configuration is edited on the host.":"Update the host to support safe project instruction editing.":"This token does not grant library.write.")}async writeLibrary(t,i,a){const l=this.libraryWriteBlock(i);if(l)throw new Pe(l);return this.#o().request(`library.${t}`,{...a,kind:i,scope:"project",projectRoot:this.#e.workspace},{timeoutMs:this.#n.requestTimeoutMs})}#Je(){this.#e.catalog.status==="ready"&&this.#Ne(),this.#e.settings.status==="ready"&&this.loadSettings()}async refreshModels(){!this.#e.principal||!Te(this.#e.principal,"session.read")||!this.hasCapability("catalog.live")||(await this.#o().request("catalog.refresh",{},{timeoutMs:Math.max(this.#n.requestTimeoutMs??0,6e4)}),this.#Je())}async loadSettings(){const t=this.#e.principal;if(!t)return;const i=this.#l;this.#t(a=>({settings:{...a.settings,status:"loading",error:void 0}}));try{const a=this.#o(),[l,u]=await Promise.all([this.hasCapability("settings.language")&&Te(t,"session.read")?a.request("settings.language.get",{}).catch(()=>{}):void 0,this.hasCapability("library")&&Te(t,"session.read")?a.request("library.models",{}).catch(()=>{}):void 0]);if(i!==this.#l)return;this.#t({settings:{status:"ready",...l&&typeof l.applies=="string"?{language:l}:{},models:Ix(u?.models)}})}catch(a){if(i!==this.#l)return;this.#t(l=>({settings:{...l.settings,status:"error",error:Be(a)}}))}}}const dS=s=>s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Wb=(...s)=>s.filter((t,i,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===i).join(" ").trim();var fS={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const hS=w.forwardRef(({color:s="currentColor",size:t=24,strokeWidth:i=2,absoluteStrokeWidth:a,className:l="",children:u,iconNode:d,...h},m)=>w.createElement("svg",{ref:m,...fS,width:t,height:t,stroke:s,strokeWidth:a?Number(i)*24/Number(t):i,className:Wb("lucide",l),...h},[...d.map(([p,x])=>w.createElement(p,x)),...Array.isArray(u)?u:[u]]));const ne=(s,t)=>{const i=w.forwardRef(({className:a,...l},u)=>w.createElement(hS,{ref:u,iconNode:t,className:Wb(`lucide-${dS(s)}`,a),...l}));return i.displayName=`${s}`,i};const ac=ne("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);const mS=ne("ArrowDownUp",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"m21 8-4-4-4 4",key:"1c9v7m"}],["path",{d:"M17 4v16",key:"7dpous"}]]);const pS=ne("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);const gS=ne("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);const Zb=ne("ArrowLeftToLine",[["path",{d:"M3 19V5",key:"rwsyhb"}],["path",{d:"m13 6-6 6 6 6",key:"1yhaz7"}],["path",{d:"M7 12h14",key:"uoisry"}]]);const eh=ne("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const Jb=ne("ArrowRightToLine",[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]]);const Dl=ne("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);const rc=ne("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);const xS=ne("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);const yS=ne("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);const Oa=ne("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);const bS=ne("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);const Pr=ne("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);const vS=ne("CheckCheck",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);const oc=ne("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Xn=ne("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const th=ne("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const Wn=ne("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Js=ne("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const lc=ne("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const e0=ne("CircleDashed",[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]]);const t0=ne("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);const wS=ne("CircleGauge",[["path",{d:"M15.6 2.7a10 10 0 1 0 5.7 5.7",key:"1e0p6d"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M13.4 10.6 19 5",key:"1kr7tw"}]]);const kS=ne("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const n0=ne("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);const jS=ne("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const SS=ne("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);const NS=ne("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const s0=ne("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);const TS=ne("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const i0=ne("CopyX",[["line",{x1:"12",x2:"18",y1:"12",y2:"18",key:"1rg63v"}],["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const bs=ne("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const jf=ne("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);const AS=ne("Crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]);const CS=ne("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);const nh=ne("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);const ES=ne("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const lo=ne("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const MS=ne("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);const Sf=ne("FileDiff",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]);const sh=ne("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const a0=ne("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);const ih=ne("Files",[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]]);const zS=ne("FolderCog",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"M10.3 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v3.3",key:"1k8050"}],["path",{d:"m21.7 19.4-.9-.3",key:"1qgwi9"}],["path",{d:"m15.2 16.9-.9-.3",key:"1t7mvx"}],["path",{d:"m16.6 21.7.3-.9",key:"1j67ps"}],["path",{d:"m19.1 15.2.3-.9",key:"18r7jp"}],["path",{d:"m19.6 21.7-.4-1",key:"z2vh2"}],["path",{d:"m16.8 15.3-.4-1",key:"1ei7r6"}],["path",{d:"m14.3 19.6 1-.4",key:"11sv9r"}],["path",{d:"m20.7 16.8 1-.4",key:"19m87a"}]]);const oy=ne("FolderGit2",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["path",{d:"M18 19c-2.8 0-5-2.2-5-5v8",key:"pkpw2h"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]);const RS=ne("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);const ly=ne("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const Da=ne("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const _S=ne("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);const Fs=ne("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);const LS=ne("GitCompareArrows",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]]);const r0=ne("GitFork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]);const o0=ne("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);const cc=ne("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const OS=ne("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const ah=ne("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);const DS=ne("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);const qS=ne("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);const rh=ne("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);const qi=ne("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);const BS=ne("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);const $S=ne("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);const uc=ne("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const qa=ne("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const US=ne("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);const HS=ne("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);const cy=ne("MessageSquarePlus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);const IS=ne("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);const GS=ne("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);const YS=ne("Minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]);const l0=ne("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);const VS=ne("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);const KS=ne("PanelBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]]);const $a=ne("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);const oh=ne("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const FS=ne("PanelTop",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]);const $i=ne("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);const XS=ne("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);const c0=ne("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);const PS=ne("PlugZap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]);const QS=ne("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);const vs=ne("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const co=ne("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);const uo=ne("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const WS=ne("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);const u0=ne("Rows2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]]);const ZS=ne("Scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);const Ws=ne("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);const Qr=ne("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const JS=ne("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);const lh=ne("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const d0=ne("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);const dc=ne("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const eN=ne("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const tN=ne("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);const nN=ne("Space",[["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]);const sN=ne("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);const fc=ne("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);const hc=ne("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);const iN=ne("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const aN=ne("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);const f0=ne("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const ch=ne("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);const rN=ne("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const h0=ne("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const oN=ne("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);const m0=ne("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);const Yl=ne("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);const lN=ne("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);const cN=ne("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const p0=ne("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);const Zt=ne("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);var uN=Object.defineProperty,uh=(s,t)=>uN(s,"name",{value:t,configurable:!0});function Nf(s,t){if(typeof s=="function")return s(t);s!=null&&(s.current=t)}uh(Nf,"setRef");function g0(...s){return t=>{let i=!1;const a=s.map(l=>{const u=Nf(l,t);return!i&&typeof u=="function"&&(i=!0),u});if(i)return()=>{for(let l=0;l<a.length;l++){const u=a[l];typeof u=="function"?u():Nf(s[l],null)}}}}uh(g0,"composeRefs");function x0(...s){return w.useCallback(g0(...s),s)}uh(x0,"useComposedRefs");var dN=Object.defineProperty,bn=(s,t)=>dN(s,"name",{value:t,configurable:!0});function y0(s){const t=w.forwardRef((i,a)=>{let{children:l,...u}=i,d=null,h=!1;const m=[];l=S0(l),w.Children.forEach(l,v=>{if(k0(v)){h=!0;const k=v;let S="child"in k.props?k.props.child:k.props.children;for(;dh(S)&&typeof Vl=="function";)S=Vl(S._payload);d=mN(k,S),m.push(d?.props?.children)}else m.push(v)}),d?d=w.cloneElement(d,void 0,m):!h&&w.Children.count(l)===1&&w.isValidElement(l)&&(d=l);const p=d?w0(d):void 0,x=x0(a,p);if(!d){if(l||l===0)throw new Error(h?xN(s):gN(s));return l}const y=v0(u,d.props??{});return d.type!==w.Fragment&&(y.ref=a?x:p),w.cloneElement(d,y)});return t.displayName=`${s}.Slot`,t}bn(y0,"createSlot");var fN=y0("Slot"),b0=Symbol.for("radix.slottable");function hN(s){const t=bn(i=>"child"in i?i.children(i.child):i.children,"Slottable");return t.displayName=`${s}.Slottable`,t.__radixId=b0,t}bn(hN,"createSlottable");var mN=bn((s,t)=>"child"in s.props?w.isValidElement(t)?w.cloneElement(t,void 0,s.props.children(t.props.children)):null:w.isValidElement(t)?t:null,"getSlottableElementFromSlottable");function v0(s,t){const i={...t};for(const a in t){const l=s[a],u=t[a];/^on[A-Z]/.test(a)?l&&u?i[a]=(...h)=>{const m=u(...h);return l(...h),m}:l&&(i[a]=l):a==="style"?i[a]={...l,...u}:a==="className"?i[a]=[l,u].filter(Boolean).join(" "):a==="aria-describedby"&&(i[a]=N0(u,l))}return{...s,...i}}bn(v0,"mergeProps");function w0(s){let t=Object.getOwnPropertyDescriptor(s.props,"ref")?.get,i=t&&"isReactWarning"in t&&t.isReactWarning;return i?s.ref:(t=Object.getOwnPropertyDescriptor(s,"ref")?.get,i=t&&"isReactWarning"in t&&t.isReactWarning,i?s.props.ref:s.props.ref||s.ref)}bn(w0,"getElementRef");function k0(s){return w.isValidElement(s)&&typeof s.type=="function"&&"__radixId"in s.type&&s.type.__radixId===b0}bn(k0,"isSlottable");var pN=Symbol.for("react.lazy");function dh(s){return s!=null&&typeof s=="object"&&"$$typeof"in s&&s.$$typeof===pN&&"_payload"in s&&j0(s._payload)}bn(dh,"isLazyComponent");function j0(s){return typeof s=="object"&&s!==null&&"then"in s}bn(j0,"isPromiseLike");function S0(s){let t=s;for(;dh(t)&&typeof Vl=="function";)t=Vl(t._payload);return t}bn(S0,"useUnwrappedLazy");function N0(...s){const t=new Set;for(const i of s)if(typeof i=="string")for(const a of String(i).trim().split(/\s+/))a&&t.add(a);return t.size>0?Array.from(t).join(" "):void 0}bn(N0,"concatAriaDescribedby");var gN=bn(s=>`${s} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),xN=bn(s=>`${s} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Vl=Bk[" use ".trim().toString()];function T0(s){var t,i,a="";if(typeof s=="string"||typeof s=="number")a+=s;else if(typeof s=="object")if(Array.isArray(s)){var l=s.length;for(t=0;t<l;t++)s[t]&&(i=T0(s[t]))&&(a&&(a+=" "),a+=i)}else for(i in s)s[i]&&(a&&(a+=" "),a+=i);return a}function A0(){for(var s,t,i=0,a="",l=arguments.length;i<l;i++)(s=arguments[i])&&(t=T0(s))&&(a&&(a+=" "),a+=t);return a}const uy=s=>typeof s=="boolean"?`${s}`:s===0?"0":s,dy=A0,yN=(s,t)=>i=>{var a;if(t?.variants==null)return dy(s,i?.class,i?.className);const{variants:l,defaultVariants:u}=t,d=Object.keys(l).map(p=>{const x=i?.[p],y=u?.[p];if(x===null)return null;const v=uy(x)||uy(y);return l[p][v]}),h=i&&Object.entries(i).reduce((p,x)=>{let[y,v]=x;return v===void 0||(p[y]=v),p},{}),m=t==null||(a=t.compoundVariants)===null||a===void 0?void 0:a.reduce((p,x)=>{let{class:y,className:v,...k}=x;return Object.entries(k).every(S=>{let[j,A]=S;return Array.isArray(A)?A.includes({...u,...h}[j]):{...u,...h}[j]===A})?[...p,y,v]:p},[]);return dy(s,d,m,i?.class,i?.className)},bN=(s,t)=>{const i=new Array(s.length+t.length);for(let a=0;a<s.length;a++)i[a]=s[a];for(let a=0;a<t.length;a++)i[s.length+a]=t[a];return i},vN=(s,t)=>({classGroupId:s,validator:t}),C0=(s=new Map,t=null,i)=>({nextPart:s,validators:t,classGroupId:i}),Kl="-",fy=[],wN="arbitrary..",kN=s=>{const t=SN(s),{conflictingClassGroups:i,conflictingClassGroupModifiers:a}=s;return{getClassGroupId:d=>{if(d.startsWith("[")&&d.endsWith("]"))return jN(d);const h=d.split(Kl),m=h[0]===""&&h.length>1?1:0;return E0(h,m,t)},getConflictingClassGroupIds:(d,h)=>{if(h){const m=a[d],p=i[d];return m?p?bN(p,m):m:p||fy}return i[d]||fy}}},E0=(s,t,i)=>{if(s.length-t===0)return i.classGroupId;const l=s[t],u=i.nextPart.get(l);if(u){const p=E0(s,t+1,u);if(p)return p}const d=i.validators;if(d===null)return;const h=t===0?s.join(Kl):s.slice(t).join(Kl),m=d.length;for(let p=0;p<m;p++){const x=d[p];if(x.validator(h))return x.classGroupId}},jN=s=>s.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=s.slice(1,-1),i=t.indexOf(":"),a=t.slice(0,i);return a?wN+a:void 0})(),SN=s=>{const{theme:t,classGroups:i}=s;return NN(i,t)},NN=(s,t)=>{const i=C0();for(const a in s){const l=s[a];fh(l,i,a,t)}return i},fh=(s,t,i,a)=>{const l=s.length;for(let u=0;u<l;u++){const d=s[u];TN(d,t,i,a)}},TN=(s,t,i,a)=>{if(typeof s=="string"){AN(s,t,i);return}if(typeof s=="function"){CN(s,t,i,a);return}EN(s,t,i,a)},AN=(s,t,i)=>{const a=s===""?t:M0(t,s);a.classGroupId=i},CN=(s,t,i,a)=>{if(MN(s)){fh(s(a),t,i,a);return}t.validators===null&&(t.validators=[]),t.validators.push(vN(i,s))},EN=(s,t,i,a)=>{const l=Object.entries(s),u=l.length;for(let d=0;d<u;d++){const[h,m]=l[d];fh(m,M0(t,h),i,a)}},M0=(s,t)=>{let i=s;const a=t.split(Kl),l=a.length;for(let u=0;u<l;u++){const d=a[u];let h=i.nextPart.get(d);h||(h=C0(),i.nextPart.set(d,h)),i=h}return i},MN=s=>"isThemeGetter"in s&&s.isThemeGetter===!0,zN=s=>{if(s<1)return{get:()=>{},set:()=>{}};let t=0,i=Object.create(null),a=Object.create(null);const l=(u,d)=>{i[u]=d,t++,t>s&&(t=0,a=i,i=Object.create(null))};return{get(u){let d=i[u];if(d!==void 0)return d;if((d=a[u])!==void 0)return l(u,d),d},set(u,d){u in i?i[u]=d:l(u,d)}}},Tf="!",hy=":",RN=[],my=(s,t,i,a,l)=>({modifiers:s,hasImportantModifier:t,baseClassName:i,maybePostfixModifierPosition:a,isExternal:l}),_N=s=>{const{prefix:t,experimentalParseClassName:i}=s;let a=l=>{const u=[];let d=0,h=0,m=0,p;const x=l.length;for(let j=0;j<x;j++){const A=l[j];if(d===0&&h===0){if(A===hy){u.push(l.slice(m,j)),m=j+1;continue}if(A==="/"){p=j;continue}}A==="["?d++:A==="]"?d--:A==="("?h++:A===")"&&h--}const y=u.length===0?l:l.slice(m);let v=y,k=!1;y.endsWith(Tf)?(v=y.slice(0,-1),k=!0):y.startsWith(Tf)&&(v=y.slice(1),k=!0);const S=p&&p>m?p-m:void 0;return my(u,k,v,S)};if(t){const l=t+hy,u=a;a=d=>d.startsWith(l)?u(d.slice(l.length)):my(RN,!1,d,void 0,!0)}if(i){const l=a;a=u=>i({className:u,parseClassName:l})}return a},LN=s=>{const t=new Map;return s.orderSensitiveModifiers.forEach((i,a)=>{t.set(i,1e6+a)}),i=>{const a=[];let l=[];for(let u=0;u<i.length;u++){const d=i[u],h=d[0]==="[",m=t.has(d);h||m?(l.length>0&&(l.sort(),a.push(...l),l=[]),a.push(d)):l.push(d)}return l.length>0&&(l.sort(),a.push(...l)),a}},ON=s=>({cache:zN(s.cacheSize),parseClassName:_N(s),sortModifiers:LN(s),postfixLookupClassGroupIds:DN(s),...kN(s)}),DN=s=>{const t=Object.create(null),i=s.postfixLookupClassGroups;if(i)for(let a=0;a<i.length;a++)t[i[a]]=!0;return t},qN=/\s+/,BN=(s,t)=>{const{parseClassName:i,getClassGroupId:a,getConflictingClassGroupIds:l,sortModifiers:u,postfixLookupClassGroupIds:d}=t,h=[],m=s.trim().split(qN);let p="";for(let x=m.length-1;x>=0;x-=1){const y=m[x],{isExternal:v,modifiers:k,hasImportantModifier:S,baseClassName:j,maybePostfixModifierPosition:A}=i(y);if(v){p=y+(p.length>0?" "+p:p);continue}let R=!!A,q;if(R){const W=j.substring(0,A);q=a(W);const E=q&&d[q]?a(j):void 0;E&&E!==q&&(q=E,R=!1)}else q=a(j);if(!q){if(!R){p=y+(p.length>0?" "+p:p);continue}if(q=a(j),!q){p=y+(p.length>0?" "+p:p);continue}R=!1}const L=k.length===0?"":k.length===1?k[0]:u(k).join(":"),O=S?L+Tf:L,B=O+q;if(h.indexOf(B)>-1)continue;h.push(B);const _=l(q,R);for(let W=0;W<_.length;++W){const E=_[W];h.push(O+E)}p=y+(p.length>0?" "+p:p)}return p},$N=(...s)=>{let t=0,i,a,l="";for(;t<s.length;)(i=s[t++])&&(a=z0(i))&&(l&&(l+=" "),l+=a);return l},z0=s=>{if(typeof s=="string")return s;let t,i="";for(let a=0;a<s.length;a++)s[a]&&(t=z0(s[a]))&&(i&&(i+=" "),i+=t);return i},UN=(s,...t)=>{let i,a,l,u;const d=m=>{const p=t.reduce((x,y)=>y(x),s());return i=ON(p),a=i.cache.get,l=i.cache.set,u=h,h(m)},h=m=>{const p=a(m);if(p)return p;const x=BN(m,i);return l(m,x),x};return u=d,(...m)=>u($N(...m))},HN=[],Lt=s=>{const t=i=>i[s]||HN;return t.isThemeGetter=!0,t.themeKey=s,t},R0=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,_0=/^\((?:(\w[\w-]*):)?(.+)\)$/i,IN=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,GN=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,YN=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,VN=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,KN=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,FN=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Gs=s=>IN.test(s),Ye=s=>!!s&&!Number.isNaN(Number(s)),Fn=s=>!!s&&Number.isInteger(Number(s)),Qd=s=>s.endsWith("%")&&Ye(s.slice(0,-1)),hs=s=>GN.test(s),L0=()=>!0,XN=s=>YN.test(s)&&!VN.test(s),hh=()=>!1,PN=s=>KN.test(s),QN=s=>FN.test(s),WN=s=>!we(s)&&!ke(s),ZN=s=>s.startsWith("@container")&&(s[10]==="/"&&s[11]!==void 0||s[11]==="s"&&s[16]!==void 0&&s.startsWith("-size/",10)||s[11]==="n"&&s[18]!==void 0&&s.startsWith("-normal/",10)),JN=s=>ei(s,q0,hh),we=s=>R0.test(s),ki=s=>ei(s,B0,XN),py=s=>ei(s,o3,Ye),e3=s=>ei(s,U0,L0),t3=s=>ei(s,$0,hh),gy=s=>ei(s,O0,hh),n3=s=>ei(s,D0,QN),Cl=s=>ei(s,H0,PN),ke=s=>_0.test(s),Ur=s=>Ui(s,B0),s3=s=>Ui(s,$0),xy=s=>Ui(s,O0),i3=s=>Ui(s,q0),a3=s=>Ui(s,D0),El=s=>Ui(s,H0,!0),r3=s=>Ui(s,U0,!0),ei=(s,t,i)=>{const a=R0.exec(s);return a?a[1]?t(a[1]):i(a[2]):!1},Ui=(s,t,i=!1)=>{const a=_0.exec(s);return a?a[1]?t(a[1]):i:!1},O0=s=>s==="position"||s==="percentage",D0=s=>s==="image"||s==="url",q0=s=>s==="length"||s==="size"||s==="bg-size",B0=s=>s==="length",o3=s=>s==="number",$0=s=>s==="family-name",U0=s=>s==="number"||s==="weight",H0=s=>s==="shadow",l3=()=>{const s=Lt("color"),t=Lt("font"),i=Lt("text"),a=Lt("font-weight"),l=Lt("tracking"),u=Lt("leading"),d=Lt("breakpoint"),h=Lt("container"),m=Lt("spacing"),p=Lt("radius"),x=Lt("shadow"),y=Lt("inset-shadow"),v=Lt("text-shadow"),k=Lt("drop-shadow"),S=Lt("blur"),j=Lt("perspective"),A=Lt("aspect"),R=Lt("ease"),q=Lt("animate"),L=()=>["auto","avoid","all","avoid-page","page","left","right","column"],O=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],B=()=>[...O(),ke,we],_=()=>["auto","hidden","clip","visible","scroll"],W=()=>["auto","contain","none"],E=()=>[ke,we,m],V=()=>[Gs,"full","auto",...E()],U=()=>[Fn,"none","subgrid",ke,we],de=()=>["auto",{span:["full",Fn,ke,we]},Fn,ke,we],J=()=>[Fn,"auto",ke,we],me=()=>["auto","min","max","fr",ke,we],se=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],fe=()=>["start","end","center","stretch","center-safe","end-safe"],H=()=>["auto",...E()],P=()=>[Gs,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...E()],oe=()=>[h,Gs,"screen","full","dvw","lvw","svw","min","max","fit",...E()],xe=()=>[Gs,"screen","full","lh","dvh","lvh","svh","min","max","fit",...E()],T=()=>[s,ke,we],z=()=>[...O(),xy,gy,{position:[ke,we]}],F=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Z=()=>["auto","cover","contain",i3,JN,{size:[ke,we]}],ie=()=>[Qd,Ur,ki],re=()=>["","none","full",p,ke,we],le=()=>["",Ye,Ur,ki],ve=()=>["solid","dashed","dotted","double"],Re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ne=()=>[Ye,Qd,xy,gy],et=()=>["","none",S,ke,we],Ue=()=>["none",Ye,ke,we],Qe=()=>["none",Ye,ke,we],We=()=>[Ye,ke,we],ye=()=>[Gs,"full",...E()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[hs],breakpoint:[hs],color:[L0],container:[hs],"drop-shadow":[hs],ease:["in","out","in-out"],font:[WN],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[hs],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[hs],shadow:[hs],spacing:["px",Ye],text:[hs],"text-shadow":[hs],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Gs,we,ke,A]}],container:["container"],"container-type":[{"@container":["","normal","size",ke,we]}],"container-named":[ZN],columns:[{columns:[Ye,"auto",we,ke,h]}],"break-after":[{"break-after":L()}],"break-before":[{"break-before":L()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:B()}],overflow:[{overflow:_()}],"overflow-x":[{"overflow-x":_()}],"overflow-y":[{"overflow-y":_()}],overscroll:[{overscroll:W()}],"overscroll-x":[{"overscroll-x":W()}],"overscroll-y":[{"overscroll-y":W()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:V()}],"inset-x":[{"inset-x":V()}],"inset-y":[{"inset-y":V()}],start:[{"inset-s":V(),start:V()}],end:[{"inset-e":V(),end:V()}],"inset-bs":[{"inset-bs":V()}],"inset-be":[{"inset-be":V()}],top:[{top:V()}],right:[{right:V()}],bottom:[{bottom:V()}],left:[{left:V()}],visibility:["visible","invisible","collapse"],z:[{z:[Fn,"auto",ke,we]}],basis:[{basis:[Gs,"full","auto",h,...E()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ye,Gs,"auto","initial","none",we]}],grow:[{grow:["",Ye,ke,we]}],shrink:[{shrink:["",Ye,ke,we]}],order:[{order:[Fn,"first","last","none",ke,we]}],"grid-cols":[{"grid-cols":U()}],"col-start-end":[{col:de()}],"col-start":[{"col-start":J()}],"col-end":[{"col-end":J()}],"grid-rows":[{"grid-rows":U()}],"row-start-end":[{row:de()}],"row-start":[{"row-start":J()}],"row-end":[{"row-end":J()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":me()}],"auto-rows":[{"auto-rows":me()}],gap:[{gap:E()}],"gap-x":[{"gap-x":E()}],"gap-y":[{"gap-y":E()}],"justify-content":[{justify:[...se(),"normal"]}],"justify-items":[{"justify-items":[...fe(),"normal"]}],"justify-self":[{"justify-self":["auto",...fe()]}],"align-content":[{content:["normal",...se()]}],"align-items":[{items:[...fe(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...fe(),{baseline:["","last"]}]}],"place-content":[{"place-content":se()}],"place-items":[{"place-items":[...fe(),"baseline"]}],"place-self":[{"place-self":["auto",...fe()]}],p:[{p:E()}],px:[{px:E()}],py:[{py:E()}],ps:[{ps:E()}],pe:[{pe:E()}],pbs:[{pbs:E()}],pbe:[{pbe:E()}],pt:[{pt:E()}],pr:[{pr:E()}],pb:[{pb:E()}],pl:[{pl:E()}],m:[{m:H()}],mx:[{mx:H()}],my:[{my:H()}],ms:[{ms:H()}],me:[{me:H()}],mbs:[{mbs:H()}],mbe:[{mbe:H()}],mt:[{mt:H()}],mr:[{mr:H()}],mb:[{mb:H()}],ml:[{ml:H()}],"space-x":[{"space-x":E()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":E()}],"space-y-reverse":["space-y-reverse"],size:[{size:P()}],"inline-size":[{inline:["auto",...oe()]}],"min-inline-size":[{"min-inline":["auto",...oe()]}],"max-inline-size":[{"max-inline":["none",...oe()]}],"block-size":[{block:["auto",...xe()]}],"min-block-size":[{"min-block":["auto",...xe()]}],"max-block-size":[{"max-block":["none",...xe()]}],w:[{w:[h,"screen",...P()]}],"min-w":[{"min-w":[h,"screen","none",...P()]}],"max-w":[{"max-w":[h,"screen","none","prose",{screen:[d]},...P()]}],h:[{h:["screen","lh",...P()]}],"min-h":[{"min-h":["screen","lh","none",...P()]}],"max-h":[{"max-h":["screen","lh","none",...P()]}],"font-size":[{text:["base",i,Ur,ki]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,r3,e3]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Qd,we]}],"font-family":[{font:[s3,t3,t]}],"font-features":[{"font-features":[we]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[l,ke,we]}],"line-clamp":[{"line-clamp":[Ye,"none",ke,py]}],leading:[{leading:["none",u,...E()]}],"list-image":[{"list-image":["none",ke,we]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ke,we]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:T()}],"text-color":[{text:T()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ve(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ye,"from-font","auto",ke,ki]}],"text-decoration-color":[{decoration:T()}],"underline-offset":[{"underline-offset":[Ye,"auto",ke,we]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:E()}],"tab-size":[{tab:[Fn,ke,we]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ke,we]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ke,we]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:z()}],"bg-repeat":[{bg:F()}],"bg-size":[{bg:Z()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Fn,ke,we],radial:["",ke,we],conic:["",Fn,ke,we]},a3,n3]}],"bg-color":[{bg:T()}],"gradient-from-pos":[{from:ie()}],"gradient-via-pos":[{via:ie()}],"gradient-to-pos":[{to:ie()}],"gradient-from":[{from:T()}],"gradient-via":[{via:T()}],"gradient-to":[{to:T()}],rounded:[{rounded:re()}],"rounded-s":[{"rounded-s":re()}],"rounded-e":[{"rounded-e":re()}],"rounded-t":[{"rounded-t":re()}],"rounded-r":[{"rounded-r":re()}],"rounded-b":[{"rounded-b":re()}],"rounded-l":[{"rounded-l":re()}],"rounded-ss":[{"rounded-ss":re()}],"rounded-se":[{"rounded-se":re()}],"rounded-ee":[{"rounded-ee":re()}],"rounded-es":[{"rounded-es":re()}],"rounded-tl":[{"rounded-tl":re()}],"rounded-tr":[{"rounded-tr":re()}],"rounded-br":[{"rounded-br":re()}],"rounded-bl":[{"rounded-bl":re()}],"border-w":[{border:le()}],"border-w-x":[{"border-x":le()}],"border-w-y":[{"border-y":le()}],"border-w-s":[{"border-s":le()}],"border-w-e":[{"border-e":le()}],"border-w-bs":[{"border-bs":le()}],"border-w-be":[{"border-be":le()}],"border-w-t":[{"border-t":le()}],"border-w-r":[{"border-r":le()}],"border-w-b":[{"border-b":le()}],"border-w-l":[{"border-l":le()}],"divide-x":[{"divide-x":le()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":le()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ve(),"hidden","none"]}],"divide-style":[{divide:[...ve(),"hidden","none"]}],"border-color":[{border:T()}],"border-color-x":[{"border-x":T()}],"border-color-y":[{"border-y":T()}],"border-color-s":[{"border-s":T()}],"border-color-e":[{"border-e":T()}],"border-color-bs":[{"border-bs":T()}],"border-color-be":[{"border-be":T()}],"border-color-t":[{"border-t":T()}],"border-color-r":[{"border-r":T()}],"border-color-b":[{"border-b":T()}],"border-color-l":[{"border-l":T()}],"divide-color":[{divide:T()}],"outline-style":[{outline:[...ve(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ye,ke,we]}],"outline-w":[{outline:["",Ye,Ur,ki]}],"outline-color":[{outline:T()}],shadow:[{shadow:["","inner","none",x,El,Cl]}],"shadow-color":[{shadow:T()}],"inset-shadow":[{"inset-shadow":["none",y,El,Cl]}],"inset-shadow-color":[{"inset-shadow":T()}],"ring-w":[{ring:le()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:T()}],"ring-offset-w":[{"ring-offset":[Ye,ki]}],"ring-offset-color":[{"ring-offset":T()}],"inset-ring-w":[{"inset-ring":le()}],"inset-ring-color":[{"inset-ring":T()}],"text-shadow":[{"text-shadow":["none",v,El,Cl]}],"text-shadow-color":[{"text-shadow":T()}],opacity:[{opacity:[Ye,ke,we]}],"mix-blend":[{"mix-blend":[...Re(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Re()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ye]}],"mask-image-linear-from-pos":[{"mask-linear-from":Ne()}],"mask-image-linear-to-pos":[{"mask-linear-to":Ne()}],"mask-image-linear-from-color":[{"mask-linear-from":T()}],"mask-image-linear-to-color":[{"mask-linear-to":T()}],"mask-image-t-from-pos":[{"mask-t-from":Ne()}],"mask-image-t-to-pos":[{"mask-t-to":Ne()}],"mask-image-t-from-color":[{"mask-t-from":T()}],"mask-image-t-to-color":[{"mask-t-to":T()}],"mask-image-r-from-pos":[{"mask-r-from":Ne()}],"mask-image-r-to-pos":[{"mask-r-to":Ne()}],"mask-image-r-from-color":[{"mask-r-from":T()}],"mask-image-r-to-color":[{"mask-r-to":T()}],"mask-image-b-from-pos":[{"mask-b-from":Ne()}],"mask-image-b-to-pos":[{"mask-b-to":Ne()}],"mask-image-b-from-color":[{"mask-b-from":T()}],"mask-image-b-to-color":[{"mask-b-to":T()}],"mask-image-l-from-pos":[{"mask-l-from":Ne()}],"mask-image-l-to-pos":[{"mask-l-to":Ne()}],"mask-image-l-from-color":[{"mask-l-from":T()}],"mask-image-l-to-color":[{"mask-l-to":T()}],"mask-image-x-from-pos":[{"mask-x-from":Ne()}],"mask-image-x-to-pos":[{"mask-x-to":Ne()}],"mask-image-x-from-color":[{"mask-x-from":T()}],"mask-image-x-to-color":[{"mask-x-to":T()}],"mask-image-y-from-pos":[{"mask-y-from":Ne()}],"mask-image-y-to-pos":[{"mask-y-to":Ne()}],"mask-image-y-from-color":[{"mask-y-from":T()}],"mask-image-y-to-color":[{"mask-y-to":T()}],"mask-image-radial":[{"mask-radial":[ke,we]}],"mask-image-radial-from-pos":[{"mask-radial-from":Ne()}],"mask-image-radial-to-pos":[{"mask-radial-to":Ne()}],"mask-image-radial-from-color":[{"mask-radial-from":T()}],"mask-image-radial-to-color":[{"mask-radial-to":T()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":O()}],"mask-image-conic-pos":[{"mask-conic":[Ye]}],"mask-image-conic-from-pos":[{"mask-conic-from":Ne()}],"mask-image-conic-to-pos":[{"mask-conic-to":Ne()}],"mask-image-conic-from-color":[{"mask-conic-from":T()}],"mask-image-conic-to-color":[{"mask-conic-to":T()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:z()}],"mask-repeat":[{mask:F()}],"mask-size":[{mask:Z()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ke,we]}],filter:[{filter:["","none",ke,we]}],blur:[{blur:et()}],brightness:[{brightness:[Ye,ke,we]}],contrast:[{contrast:[Ye,ke,we]}],"drop-shadow":[{"drop-shadow":["","none",k,El,Cl]}],"drop-shadow-color":[{"drop-shadow":T()}],grayscale:[{grayscale:["",Ye,ke,we]}],"hue-rotate":[{"hue-rotate":[Ye,ke,we]}],invert:[{invert:["",Ye,ke,we]}],saturate:[{saturate:[Ye,ke,we]}],sepia:[{sepia:["",Ye,ke,we]}],"backdrop-filter":[{"backdrop-filter":["","none",ke,we]}],"backdrop-blur":[{"backdrop-blur":et()}],"backdrop-brightness":[{"backdrop-brightness":[Ye,ke,we]}],"backdrop-contrast":[{"backdrop-contrast":[Ye,ke,we]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ye,ke,we]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ye,ke,we]}],"backdrop-invert":[{"backdrop-invert":["",Ye,ke,we]}],"backdrop-opacity":[{"backdrop-opacity":[Ye,ke,we]}],"backdrop-saturate":[{"backdrop-saturate":[Ye,ke,we]}],"backdrop-sepia":[{"backdrop-sepia":["",Ye,ke,we]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":E()}],"border-spacing-x":[{"border-spacing-x":E()}],"border-spacing-y":[{"border-spacing-y":E()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ke,we]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ye,"initial",ke,we]}],ease:[{ease:["linear","initial",R,ke,we]}],delay:[{delay:[Ye,ke,we]}],animate:[{animate:["none",q,ke,we]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[j,ke,we]}],"perspective-origin":[{"perspective-origin":B()}],rotate:[{rotate:Ue()}],"rotate-x":[{"rotate-x":Ue()}],"rotate-y":[{"rotate-y":Ue()}],"rotate-z":[{"rotate-z":Ue()}],scale:[{scale:Qe()}],"scale-x":[{"scale-x":Qe()}],"scale-y":[{"scale-y":Qe()}],"scale-z":[{"scale-z":Qe()}],"scale-3d":["scale-3d"],skew:[{skew:We()}],"skew-x":[{"skew-x":We()}],"skew-y":[{"skew-y":We()}],transform:[{transform:[ke,we,"","none","gpu","cpu"]}],"transform-origin":[{origin:B()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ye()}],"translate-x":[{"translate-x":ye()}],"translate-y":[{"translate-y":ye()}],"translate-z":[{"translate-z":ye()}],"translate-none":["translate-none"],zoom:[{zoom:[Fn,ke,we]}],accent:[{accent:T()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:T()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ke,we]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":T()}],"scrollbar-track-color":[{"scrollbar-track":T()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":E()}],"scroll-mx":[{"scroll-mx":E()}],"scroll-my":[{"scroll-my":E()}],"scroll-ms":[{"scroll-ms":E()}],"scroll-me":[{"scroll-me":E()}],"scroll-mbs":[{"scroll-mbs":E()}],"scroll-mbe":[{"scroll-mbe":E()}],"scroll-mt":[{"scroll-mt":E()}],"scroll-mr":[{"scroll-mr":E()}],"scroll-mb":[{"scroll-mb":E()}],"scroll-ml":[{"scroll-ml":E()}],"scroll-p":[{"scroll-p":E()}],"scroll-px":[{"scroll-px":E()}],"scroll-py":[{"scroll-py":E()}],"scroll-ps":[{"scroll-ps":E()}],"scroll-pe":[{"scroll-pe":E()}],"scroll-pbs":[{"scroll-pbs":E()}],"scroll-pbe":[{"scroll-pbe":E()}],"scroll-pt":[{"scroll-pt":E()}],"scroll-pr":[{"scroll-pr":E()}],"scroll-pb":[{"scroll-pb":E()}],"scroll-pl":[{"scroll-pl":E()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ke,we]}],fill:[{fill:["none",...T()]}],"stroke-w":[{stroke:[Ye,Ur,ki,py]}],stroke:[{stroke:["none",...T()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["start","end","right","left"],"inset-y":["inset-bs","inset-be","top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["ps","pe","pr","pl"],py:["pbs","pbe","pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["ms","me","mr","ml"],my:["mbs","mbe","mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-s","border-w-e","border-w-r","border-w-l"],"border-w-y":["border-w-bs","border-w-be","border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-s","border-color-e","border-color-r","border-color-l"],"border-color-y":["border-color-bs","border-color-be","border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-ms","scroll-me","scroll-mr","scroll-ml"],"scroll-my":["scroll-mbs","scroll-mbe","scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-ps","scroll-pe","scroll-pr","scroll-pl"],"scroll-py":["scroll-pbs","scroll-pbe","scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},c3=UN(l3);function I(...s){return c3(A0(s))}const u3=yN("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-45 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground border border-border hover:bg-accent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground",ghost:"hover:bg-accent hover:text-accent-foreground",destructive:"bg-destructive/15 text-destructive border border-destructive/40 hover:bg-destructive/25",link:"text-highlight underline-offset-4 hover:underline"},size:{default:"h-9 px-4",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 px-5",icon:"size-9","icon-sm":"size-7 rounded-md"}},defaultVariants:{variant:"default",size:"default"}});function be({className:s,variant:t,size:i,asChild:a=!1,type:l,...u}){const d=a?fN:"button";return o.jsx(d,{"data-slot":"button",type:a?void 0:l??"button",className:I(u3({variant:t,size:i}),s),...u})}const I0="w-full min-w-0 rounded-md border border-input bg-background/60 px-3 text-sm text-foreground placeholder:text-muted-foreground/80 outline-none transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive";function Qn({className:s,type:t="text",...i}){return o.jsx("input",{"data-slot":"input",type:t,className:I(I0,"h-9",s),...i})}function mh({className:s,children:t,...i}){return o.jsx("select",{"data-slot":"select",className:I(I0,"h-9 appearance-none pr-8",s),style:{backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2395a39a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")`,backgroundPosition:"right 0.6rem center",backgroundSize:"16px",backgroundRepeat:"no-repeat"},...i,children:t})}function ro({className:s,...t}){return o.jsx("label",{"data-slot":"label",className:I("text-xs font-medium text-muted-foreground",s),...t})}function Kt({className:s,label:t}){return o.jsxs("span",{role:"status",className:I("inline-flex items-center gap-2 text-muted-foreground",s),children:[o.jsx(uc,{"aria-hidden":!0,className:"size-4 animate-spin"}),t?o.jsx("span",{children:t}):o.jsx("span",{className:"sr-only",children:"Loading"})]})}const G0=w.createContext(null);function d3({controller:s,children:t}){return o.jsx(G0.Provider,{value:s,children:t})}function Oe(){const s=w.useContext(G0);if(!s)throw new Error("useController outside ControllerProvider");return s}function Me(){const s=Oe();return w.useSyncExternalStore(w.useCallback(t=>s.subscribe(t),[s]),()=>s.getState())}function Y0(s){const[t,i]=w.useState(!1),[a,l]=w.useState(null);return{run:w.useCallback(async(...d)=>{i(!0),l(null);try{return await s(...d),!0}catch(h){return l(h instanceof Error?h.message:String(h)),!1}finally{i(!1)}},[s]),pending:t,error:a,clearError:()=>l(null)}}const f3="M1196 972L1193 1004L1180 1053L1163 1087L1141 1117L1114 1143L1079 1166L1052 1178L1011 1189L970 1193L284 1193L217 1183L158 1156L113 1117L89 1084L68 1036L59 988L58 284L62 246L72 208L86 177L108 145L132 120L168 94L197 80L237 68L284 63L970 63L1030 71L1086 94L1123 121L1160 164L1182 208L1193 252L1196 285Z",h3="M717 377L693 495L641 803L566 803L566 801L644 371L717 371ZM594 443L531 803L462 803L469 764L447 780L424 792L402 800L371 806L345 807L309 803L278 794L256 784L238 773L216 755L202 740L184 714L170 684L163 659L160 637L160 607L164 582L171 559L180 539L196 514L231 479L250 466L280 451L313 441L345 437L377 438L405 443L431 452L463 469L483 484L509 511L522 439L589 438L594 439ZM1092 639L1086 671L1077 696L1067 715L1047 742L1031 758L1001 780L967 796L937 804L908 807L872 805L832 795L804 782L779 765L759 747L737 887L669 888L665 887L665 880L737 439L803 439L797 478L809 468L836 452L857 444L885 438L915 437L941 440L974 449L996 459L1031 483L1050 502L1071 533L1083 561L1089 584L1092 604ZM223 616L223 639L227 661L236 683L249 702L262 715L282 729L307 740L335 746L369 746L385 743L403 737L431 721L455 698L466 682L478 654L482 633L482 609L477 583L465 556L454 541L436 524L409 508L384 500L362 497L336 498L314 503L289 514L271 526L254 542L239 563L228 589ZM772 613L772 640L775 657L784 681L798 702L812 716L829 728L859 741L885 746L918 746L934 743L952 737L984 718L1004 698L1015 682L1027 654L1031 631L1031 610L1026 583L1015 558L1002 540L978 519L958 508L933 500L912 497L886 498L863 503L838 514L820 526L803 542L785 568L777 588Z";function V0({className:s}){return o.jsxs("svg",{viewBox:"0 0 1254 1254","aria-hidden":!0,className:I("shrink-0",s),children:[o.jsx("defs",{children:o.jsxs("linearGradient",{id:"alp-logo-tile",x1:"180",y1:"120",x2:"1080",y2:"1160",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{stopColor:"#1d1e20"}),o.jsx("stop",{offset:"1",stopColor:"#111214"})]})}),o.jsx("path",{fill:"url(#alp-logo-tile)",d:f3}),o.jsx("path",{fill:"#fff",fillRule:"evenodd",d:h3})]})}const K0="alp-web:gateway",F0=!1;function m3(){let s=null;try{s=window.localStorage.getItem(K0)}catch{}return I2({location:window.location,remembered:s,dev:F0})}function p3(){const s=Oe(),{connection:t}=Me();return o.jsx("main",{className:"flex min-h-full items-center justify-center bg-[radial-gradient(ellipse_at_top,_var(--glow)_0%,_var(--background)_55%)] px-4 py-10",children:o.jsxs("div",{className:"w-full max-w-md space-y-4","data-testid":"link-connecting",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(V0,{className:"size-10"}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"ALP"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Opening ALP on this machine"})]})]}),o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx(Kt,{label:"Connecting…"}),t.attempt>1?o.jsxs("span",{children:["Waiting for alp web (attempt ",t.attempt,")"]}):null]}),t.error?o.jsx("p",{className:"text-sm text-muted-foreground",children:t.error.message}):null,o.jsx(be,{size:"sm",variant:"ghost",onClick:()=>s.disconnect(),children:"Use another access token"})]})})}function g3(){const s=Oe(),{connection:t}=Me(),[i,a]=w.useState(()=>t.gateway||m3()),[l,u]=w.useState(""),d=t.phase==="connecting",h=t.phase==="failed"?t.error:void 0;if(d&&t.link)return o.jsx(p3,{});const m=p=>{p.preventDefault();try{window.localStorage.setItem(K0,i.trim())}catch{}s.connect({url:i,token:l})};return o.jsx("main",{className:"flex min-h-full items-center justify-center bg-[radial-gradient(ellipse_at_top,_var(--glow)_0%,_var(--background)_55%)] px-4 py-10",children:o.jsxs("div",{className:"w-full max-w-md",children:[o.jsxs("div",{className:"mb-8 flex items-center gap-3",children:[o.jsx(V0,{className:"size-10"}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"ALP"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect to your agents on an ALP host"})]})]}),o.jsxs("form",{onSubmit:m,className:"space-y-5 rounded-xl border border-border bg-card/80 p-6 shadow-xl shadow-[var(--shadow)] backdrop-blur","aria-describedby":h?"connect-error":void 0,children:[o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ro,{htmlFor:"gateway",children:"Gateway address"}),o.jsx(Qn,{id:"gateway",name:"gateway",inputMode:"url",autoComplete:"url",spellCheck:!1,value:i,onChange:p=>a(p.target.value),placeholder:"https://alp.example.com",required:!0,disabled:d})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ro,{htmlFor:"token",children:"Access token"}),o.jsx(Qn,{id:"token",name:"token",type:"password",autoComplete:"off",spellCheck:!1,value:l,onChange:p=>u(p.target.value),placeholder:"alpgw1.…",required:!0,disabled:d}),o.jsxs("p",{className:"flex items-start gap-1.5 text-xs text-muted-foreground",children:[o.jsx(dc,{"aria-hidden":!0,className:"mt-0.5 size-3.5 shrink-0 text-highlight"}),"Kept in this tab's memory only. Reloading or disconnecting forgets it."]})]}),h?o.jsx("div",{id:"connect-error",role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:h.message}):null,o.jsx(be,{type:"submit",className:"w-full",disabled:d||!i.trim()||!l.trim(),children:d?o.jsx(Kt,{className:"text-primary-foreground",label:"Connecting…"}):o.jsxs(o.Fragment,{children:[o.jsx(PS,{"aria-hidden":!0})," Connect"]})})]}),o.jsxs("details",{className:"mt-5 rounded-lg border border-border/70 bg-card/40 px-4 py-3 text-sm text-muted-foreground",children:[o.jsxs("summary",{className:"flex cursor-pointer items-center gap-2 font-medium text-foreground/90",children:[o.jsx(DS,{"aria-hidden":!0,className:"size-4"})," Getting a token"]}),o.jsxs("div",{className:"mt-3 space-y-2",children:[Ab({location:window.location,dev:F0})?o.jsxs(o.Fragment,{children:[o.jsxs("p",{children:["On this machine, run ",o.jsx("code",{className:"font-mono",children:"alp web"}),": it opens this page with a link that signs you in. ",o.jsx("code",{className:"font-mono",children:"alp web --print"})," prints the link instead, and ",o.jsx("code",{className:"font-mono",children:"alp web rotate"})," replaces its token, signing out every open page."]}),o.jsx("p",{children:"To use a standalone gateway instead, create a token for the workspaces you want to open, then start the gateway with this page's address as an allowed origin:"})]}):o.jsx("p",{children:"On the ALP host, create a token for the workspaces you want to open here, then start the gateway with this page's address as an allowed origin:"}),o.jsx("pre",{className:"overflow-x-auto rounded-md bg-background px-3 py-2 font-mono text-xs text-foreground/90",children:`alp-gateway credential create --label web \\
|
|
19
|
+
--workspace /path/to/project
|
|
20
|
+
alp-gateway serve --origin ${typeof window>"u"?"http://127.0.0.1:7435":window.location.origin}`}),o.jsx("p",{children:"From another machine, use the host's HTTPS address, or an SSH tunnel to the gateway's port (127.0.0.1:7434 by default)."})]})]})]})})}function ti({open:s,onClose:t,title:i,description:a,children:l,className:u,footer:d}){const h=w.useRef(null),m=w.useId();return w.useEffect(()=>{const p=h.current;p&&(s&&!p.open&&p.showModal(),!s&&p.open&&p.close())},[s]),o.jsx("dialog",{ref:h,"aria-labelledby":m,onCancel:p=>{p.preventDefault(),t()},onClick:p=>{p.target===h.current&&t()},className:I("m-auto w-[min(92vw,32rem)] max-h-[88dvh] overflow-hidden rounded-xl border border-border bg-popover p-0 text-popover-foreground shadow-2xl shadow-[var(--shadow)]",u),children:s?o.jsxs("div",{className:"flex max-h-[88dvh] flex-col",children:[o.jsxs("header",{className:"flex items-start justify-between gap-4 border-b border-border px-5 py-4",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("h2",{id:m,className:"text-base font-semibold",children:i}),a?o.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a}):null]}),o.jsx(be,{variant:"ghost",size:"icon-sm","aria-label":"Close",onClick:t,children:o.jsx(Zt,{})})]}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:l}),d?o.jsx("footer",{className:"flex flex-wrap justify-end gap-2 border-t border-border px-5 py-3",children:d}):null]}):null})}function Ot(s){const t=s.replace(/[\\/]+$/,"");return t.split(/[\\/]/).pop()||t||s}function Mi(s,t=Date.now()){if(!s)return"";const i=Date.parse(s);if(Number.isNaN(i))return"";const a=Math.max(0,Math.round((t-i)/1e3));if(a<45)return"just now";const l=Math.round(a/60);if(l<60)return`${l} min ago`;const u=Math.round(l/60);if(u<24)return`${u} h ago`;const d=Math.round(u/24);return d<7?`${d} d ago`:new Date(i).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function X0(s){if(!s)return"";const t=Date.parse(s);return Number.isNaN(t)?"":new Date(t).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}const x3={"read-only":"Read only","workspace-write":"Workspace write","full-access":"Full access"},Fl=s=>s?x3[s]??s:"";function Pn(s,t){return s?.title?s.title:`Session ${(s?.id??t??"").replace(/^(web_|ses_)/,"").slice(0,6)}`}function y3(s,t=Date.now()){const i=Date.parse(s??"");if(!Number.isFinite(i))return"";const a=Math.max(0,t-i);if(a<6e4)return"now";if(a<36e5)return`${Math.floor(a/6e4)}m`;if(a<864e5)return`${Math.floor(a/36e5)}h`;if(a<7*864e5)return`${Math.floor(a/864e5)}d`;const l=new Date(i);return`${l.toLocaleDateString("en-US",{month:"short"})} ${l.getDate()}`}function b3({session:s,onClose:t}){const i=Oe(),[a,l]=w.useState(s?.title??""),[u,d]=w.useState(s);s!==u&&(d(s),l(s?.title??""));const h=Y0(w.useCallback((m,p)=>i.renameSession(m,p),[i]));return w.useEffect(()=>{s&&h.clearError()},[s]),o.jsx(ti,{open:!!s,onClose:t,title:"Rename session",footer:o.jsxs(o.Fragment,{children:[o.jsx(be,{variant:"ghost",onClick:t,children:"Cancel"}),o.jsx(be,{type:"submit",form:"rename-session",disabled:h.pending||!a.trim(),children:"Save"})]}),children:o.jsxs("form",{id:"rename-session",className:"space-y-1.5",onSubmit:async m=>{m.preventDefault(),s&&await h.run(s.id,a.trim())&&t()},children:[o.jsx(ro,{htmlFor:"rename-title",children:"Title"}),o.jsx(Qn,{id:"rename-title",value:a,onChange:m=>l(m.target.value),maxLength:200,autoFocus:!0}),h.error?o.jsx("p",{role:"alert",className:"text-xs text-destructive",children:h.error}):null]})})}function v3({session:s,onClose:t}){const i=Oe(),a=Y0(w.useCallback(l=>i.archiveSession(l),[i]));return w.useEffect(()=>{s&&a.clearError()},[s]),o.jsx(ti,{open:!!s,onClose:t,title:"Archive session?",description:o.jsxs(o.Fragment,{children:["“",Pn(s??void 0),"” stops and leaves the list. Its history stays on the host."]}),footer:o.jsxs(o.Fragment,{children:[o.jsx(be,{variant:"ghost",onClick:t,children:"Cancel"}),o.jsx(be,{variant:"destructive",disabled:a.pending,onClick:async()=>{s&&await a.run(s.id)&&t()},children:"Archive"})]}),children:a.error?o.jsx("p",{role:"alert",className:"text-xs text-destructive",children:a.error}):o.jsx("p",{className:"text-sm text-muted-foreground",children:"Running work in this session is stopped."})})}function P0({version:s,connection:t,principal:i,preferences:a,browser:l={}}){const u=h=>h===void 0?"unknown":h?"yes":"no",d=h=>h?.length?[...h].sort().join(", "):"none";return[{title:"App",rows:[["Version",`ALP web v${s}`],["Theme",a.theme],["Content width",a.contentMaxWidth===null?"default":`${a.contentMaxWidth}px`],["Chat display",a.chatDisplay],["Default send",a.sendBehavior]]},{title:"Browser",rows:[["User agent",l.userAgent??"unknown"],["Language",l.language??"unknown"],["Online",u(l.online)],["Secure context",u(l.secure)],["Viewport",l.viewport??"unknown"],["Color scheme",l.colorScheme??"unknown"]]},{title:"Connection",rows:[["Gateway",t.gateway],["State",t.phase==="reconnecting"?`reconnecting (attempt ${t.attempt})`:t.phase],["Host",t.hostname??"unknown"],["ALP on the host",t.daemonVersion??"unknown"],["Capabilities",d(t.capabilities)]]},{title:"Access token",rows:[["Name",i?.label??"unknown"],["Id",i?.id??"unknown"],["Permissions",d(i?.permissions)],["Modes",i?.modes?d(i.modes):"any"],["Projects",String(i?.workspaces?.length??0)]]}]}function w3(s){const t=[`ALP web diagnostics, ${(s.now??new Date).toISOString()}`];for(const i of P0(s)){t.push("",`## ${i.title}`);for(const[a,l]of i.rows)t.push(`${a}: ${l}`)}return t.join(`
|
|
21
|
+
`)}const k3="modulepreload",j3=function(s){return"/"+s},yy={},Q0=function(t,i,a){let l=Promise.resolve();if(i&&i.length>0){let m=function(p){return Promise.all(p.map(x=>Promise.resolve(x).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),h=d?.nonce||d?.getAttribute("nonce");l=m(i.map(p=>{if(p=j3(p),p in yy)return;yy[p]=!0;const x=p.endsWith(".css"),y=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${y}`))return;const v=document.createElement("link");if(v.rel=x?"stylesheet":k3,x||(v.as="script"),v.crossOrigin="",v.href=p,h&&v.setAttribute("nonce",h),document.head.appendChild(v),x)return new Promise((k,S)=>{v.addEventListener("load",k),v.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${p}`)))})}))}function u(d){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=d,window.dispatchEvent(h),!h.defaultPrevented)throw d}return l.then(d=>{for(const h of d||[])h.status==="rejected"&&u(h.reason);return t().catch(u)})},S3={keyword:"#ff7b72",comment:"#8b949e",string:"#a5d6ff",number:"#79c0ff",literal:"#79c0ff",function:"#d2a8ff",definition:"#d2a8ff",class:"#ffa657",type:"#ff7b72",tag:"#7ee787",attribute:"#79c0ff",property:"#79c0ff",variable:"#c9d1d9",operator:"#79c0ff",punctuation:"#c9d1d9",regexp:"#a5d6ff",escape:"#79c0ff",meta:"#8b949e",heading:"#79c0ff",link:"#a5d6ff"},N3={keyword:"#cf222e",comment:"#6e7781",string:"#0a3069",number:"#0550ae",literal:"#0550ae",function:"#8250df",definition:"#8250df",class:"#953800",type:"#cf222e",tag:"#116329",attribute:"#0550ae",property:"#0550ae",variable:"#24292f",operator:"#0550ae",punctuation:"#24292f",regexp:"#0a3069",escape:"#0550ae",meta:"#6e7781",heading:"#0550ae",link:"#0a3069"},T3=[{id:"github",label:"GitHub"},{id:"catppuccin",label:"Catppuccin"},{id:"dracula",label:"Dracula"},{id:"tokyo-night",label:"Tokyo Night"},{id:"one",label:"One"},{id:"nord",label:"Nord"},{id:"gruvbox",label:"Gruvbox"},{id:"solarized",label:"Solarized"}];function ji(s){return{keyword:s.keyword,comment:s.comment,string:s.string,number:s.number,literal:s.number,function:s.function,definition:s.function,class:s.type,type:s.type,tag:s.tag,attribute:s.attribute,property:s.attribute,variable:s.base,operator:s.operator,punctuation:s.base,regexp:s.string,escape:s.number,meta:s.comment,heading:s.function,link:s.string}}const A3={base:"#4c4f69",keyword:"#8839ef",comment:"#8c8fa1",string:"#40a02b",number:"#fe640b",function:"#1e66f5",type:"#df8e1d",tag:"#8839ef",attribute:"#df8e1d",operator:"#04a5e5"},C3={base:"#cdd6f4",keyword:"#cba6f7",comment:"#9399b2",string:"#a6e3a1",number:"#fab387",function:"#89b4fa",type:"#f9e2af",tag:"#cba6f7",attribute:"#f9e2af",operator:"#89dceb"},E3={base:"#f8f8f2",keyword:"#ff79c6",comment:"#6272a4",string:"#f1fa8c",number:"#bd93f9",function:"#50fa7b",type:"#8be9fd",tag:"#ff79c6",attribute:"#50fa7b",operator:"#ff79c6"},M3={base:"#3760bf",keyword:"#9854f1",comment:"#848cb5",string:"#587539",number:"#b15c00",function:"#2e7de9",type:"#007197",tag:"#f52a65",attribute:"#8c6c3e",operator:"#006a83"},z3={base:"#c0caf5",keyword:"#bb9af7",comment:"#565f89",string:"#9ece6a",number:"#ff9e64",function:"#7aa2f7",type:"#2ac3de",tag:"#f7768e",attribute:"#e0af68",operator:"#89ddff"},R3={base:"#383a42",keyword:"#a626a4",comment:"#a0a1a7",string:"#50a14f",number:"#986801",function:"#4078f2",type:"#c18401",tag:"#e45649",attribute:"#986801",operator:"#0184bc"},_3={base:"#abb2bf",keyword:"#c678dd",comment:"#5c6370",string:"#98c379",number:"#d19a66",function:"#61afef",type:"#e5c07b",tag:"#e06c75",attribute:"#d19a66",operator:"#56b6c2"},L3={base:"#2e3440",keyword:"#5e81ac",comment:"#6b7280",string:"#4f6f3a",number:"#8f5e91",function:"#2e6f8e",type:"#3b7f87",tag:"#5e81ac",attribute:"#8f5e91",operator:"#5e81ac"},O3={base:"#d8dee9",keyword:"#81a1c1",comment:"#616e88",string:"#a3be8c",number:"#b48ead",function:"#88c0d0",type:"#8fbcbb",tag:"#81a1c1",attribute:"#8fbcbb",operator:"#81a1c1"},D3={base:"#3c3836",keyword:"#9d0006",comment:"#928374",string:"#79740e",number:"#8f3f71",function:"#427b58",type:"#b57614",tag:"#076678",attribute:"#b57614",operator:"#af3a03"},q3={base:"#ebdbb2",keyword:"#fb4934",comment:"#928374",string:"#b8bb26",number:"#d3869b",function:"#8ec07c",type:"#fabd2f",tag:"#83a598",attribute:"#fabd2f",operator:"#fe8019"},B3={base:"#657b83",keyword:"#859900",comment:"#93a1a1",string:"#2aa198",number:"#d33682",function:"#268bd2",type:"#b58900",tag:"#268bd2",attribute:"#b58900",operator:"#859900"},$3={base:"#839496",keyword:"#859900",comment:"#586e75",string:"#2aa198",number:"#d33682",function:"#268bd2",type:"#b58900",tag:"#268bd2",attribute:"#b58900",operator:"#859900"};function U3(s,t){const i=t==="dark";switch(s){case"github":return i?S3:N3;case"catppuccin":return ji(i?C3:A3);case"dracula":return ji(E3);case"tokyo-night":return ji(i?z3:M3);case"one":return ji(i?_3:R3);case"nord":return ji(i?O3:L3);case"gruvbox":return ji(i?q3:D3);case"solarized":return ji(i?$3:B3)}}const by={typescript:"ts",javascript:"js",python:"py",rust:"rs",golang:"go","c++":"cpp",csharp:"cs","c#":"cs",objc:"m","objective-c":"m",markdown:"md",elixir:"ex"};function H3(s){const t=s?.trim().split(/\s+/)[0]?.toLowerCase().replace(/^\./,"");return t?`code.${Object.hasOwn(by,t)?by[t]:t}`:null}const I3=T3.map(s=>({value:s.id,label:s.label}));let Af=null,vy=null;const Cf=new Set;function G3(){return vy??=Q0(()=>import("./highlighter-BnicKQ_d.js"),[]).then(s=>{Af=s;for(const t of Cf)t();return s}),vy}function Y3(){const[,s]=w.useReducer(t=>t+1,0);return w.useEffect(()=>{if(!Af)return Cf.add(s),G3(),()=>{Cf.delete(s)}},[]),Af}const V3=768*1024;function mc(s,t){const i=Y3();return w.useMemo(()=>{if(!i||!t||s.length>V3||!i.isLanguageSupported(t))return null;try{return i.highlightCode(s,t)}catch{return null}},[i,s,t])}function pc({tokens:s}){return w.createElement(w.Fragment,null,s.map((t,i)=>t.style?w.createElement("span",{key:i,style:{color:`var(--syntax-${t.style})`}},t.text):t.text))}const K3=["keyword","comment","string","number","literal","function","definition","class","type","tag","attribute","property","variable","operator","punctuation","regexp","escape","meta","heading","link"];function F3(s,t){const i=U3(s,t),a=document.documentElement.style;for(const l of K3)a.setProperty(`--syntax-${l}`,i[l])}const Wd=[{value:"light",label:"Light",group:"primary",swatch:"#ffffff"},{value:"dark",label:"Dark",group:"primary",swatch:"#2D8B62"},{value:"system",label:"System",group:"primary"},{value:"zinc",label:"Zinc",group:"variant",swatch:"#808080"},{value:"midnight",label:"Midnight",group:"variant",swatch:"#4A6BA8"},{value:"claude",label:"Claude",group:"variant",swatch:"#D97757"},{value:"ghostty",label:"Ghostty",group:"variant",swatch:"#8caaee"},{value:"pureBlack",label:"Pure black",group:"variant",swatch:"#000000"}],wy={light:"#ffffff",dark:"#181b1a",zinc:"#18181b",midnight:"#161820",claude:"#1f1f1e",ghostty:"#282c34",pureBlack:"#000000"};function X3(s,t="one"){const i=document.documentElement,a=typeof window.matchMedia=="function"?window.matchMedia("(prefers-color-scheme: light)"):null,l=()=>{const u=s==="system"?a?.matches?"light":"dark":s,d=u==="light"?"light":"dark";i.dataset.theme=u,i.classList.toggle("dark",d==="dark"),i.style.colorScheme=d,document.querySelector('meta[name="color-scheme"]')?.setAttribute("content",d),document.querySelector('meta[name="theme-color"]')?.setAttribute("content",wy[u]??wy.dark),F3(t,d)};return l(),s!=="system"||!a?()=>{}:(a.addEventListener("change",l),()=>a.removeEventListener("change",l))}const W0='"Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',Z0='"JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace';function J0(s){return s.contentMaxWidth??zn.contentMaxWidth[2]}function P3(s){const t=document.documentElement.style;t.setProperty("--app-font-sans",s.uiFontFamily||W0),t.setProperty("--app-font-mono",s.monoFontFamily||Z0),t.setProperty("--ui-scale",String(s.uiFontSize/zn.uiFontSize[2])),t.setProperty("--content-font-size",`${s.contentFontSize}px`),t.setProperty("--code-font-size",`${s.codeFontSize}px`),t.setProperty("--content-width",`${J0(s)}px`)}const Q3={red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#9333ea",cyan:"#0891b2",white:"#ffffff",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#f59e0b",brightBlue:"#3b82f6",brightMagenta:"#a855f7",brightCyan:"#06b6d4",brightWhite:"#fafafa"},W3={red:"#e07070",green:"#5dba80",yellow:"#d4a44a",blue:"#6a9de0",magenta:"#b07ad0",cyan:"#4aabb8",white:"#d4d4d8",brightRed:"#e89090",brightGreen:"#7ecf9a",brightYellow:"#e0be6e",brightBlue:"#8ab4e8",brightMagenta:"#c49ae0",brightCyan:"#6ec2cc",brightWhite:"#f0f0f2"};function HC(){const s=document.documentElement,t=getComputedStyle(s),i=d=>t.getPropertyValue(d).trim(),a=s.dataset.theme==="light",l=i("--background"),u=i("--foreground");return{background:l,foreground:u,cursor:u,cursorAccent:l,selectionBackground:a?"rgba(0, 0, 0, 0.15)":"rgba(255, 255, 255, 0.2)",selectionForeground:u,black:i("--terminal-black"),brightBlack:i("--terminal-bright-black"),...a?Q3:W3}}function e1({checked:s,onCheckedChange:t,className:i,...a}){return o.jsx("button",{type:"button",role:"switch","aria-checked":s,onClick:()=>t(!s),"data-slot":"switch",className:I("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s?"bg-primary":"bg-input",i),...a,children:o.jsx("span",{"aria-hidden":!0,className:I("pointer-events-none block size-4 rounded-full bg-white shadow transition-transform",s?"translate-x-4":"translate-x-0.5")})})}const Ef=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,t1=s=>s.replace(/\t/g," ").match(/^ */)[0].length,ky=s=>s.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim());function n1(s,t,i){const a=Ef.exec(s[t]),l=/\d/.test(a[2]),u=[];let d=t;for(;d<s.length;){const h=s[d],m=Ef.exec(h),p=t1(h);if(m&&p===i&&/\d/.test(m[2])===l){u.push({text:m[3],children:[]}),d++;continue}if(m&&p>i&&u.length){const x=n1(s,d,p);u.at(-1).children.push(x.block),d=x.next;continue}if(!m&&h.trim()&&p>i&&u.length){const x=u.at(-1);if(x.children.length)break;x.text+=` ${h.trim()}`,d++;continue}break}return{block:{kind:"list",ordered:l,start:l&&Number.parseInt(a[2],10)||1,items:u},next:d}}function Z3(s){const t=s.replace(/\r\n?/g,`
|
|
22
|
+
`).split(`
|
|
23
|
+
`),i=[];let a=[];const l=()=>{a.length&&i.push({kind:"paragraph",text:a.join(`
|
|
24
|
+
`)}),a=[]};for(let u=0;u<t.length;u++){const d=t[u],h=/^\s*(```+|~~~+)\s*([\w+-]*)\s*$/.exec(d);if(h){l();const x=[];let y=u+1;for(;y<t.length&&!t[y].trim().startsWith(h[1]);)x.push(t[y++]);i.push({kind:"code",lang:h[2],text:x.join(`
|
|
25
|
+
`)}),u=y;continue}const m=/^\s{0,3}(#{1,6})\s+(.*?)\s*#*\s*$/.exec(d);if(m){l(),i.push({kind:"heading",level:m[1].length,text:m[2]});continue}if(/^\s{0,3}([-*_])(\s*\1){2,}\s*$/.test(d)){l(),i.push({kind:"rule"});continue}if(d.trim().startsWith("|")&&u+1<t.length&&/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(t[u+1])){l();const x=ky(d),y=[];let v=u+2;for(;v<t.length&&t[v].trim().startsWith("|");)y.push(ky(t[v++]));i.push({kind:"table",head:x,rows:y}),u=v-1;continue}if(Ef.test(d)){l();const{block:x,next:y}=n1(t,u,t1(d));i.push(x),u=y-1;continue}const p=/^\s*>\s?(.*)$/.exec(d);if(p){l();const x=i.at(-1);x?.kind==="quote"?x.text+=`
|
|
26
|
+
${p[1]}`:i.push({kind:"quote",text:p[1]});continue}if(!d.trim()){l();continue}a.push(d)}return l(),i}const s1=String.raw`(?!\))[^()\s]{0,2048}(?:\([^()\s]{0,2048}\)[^()\s]{0,2048})?`,i1=String.raw`[^[\]\n]{1,1000}`,J3=new RegExp(["(`[^`\\n]{1,1000}`)",String.raw`(\*\*[^*\n]{1,1000}?\*\*|__[^_\n]{1,1000}?__)`,String.raw`(~~[^~\n]{1,1000}?~~)`,String.raw`(\[${i1}\]\(${s1}\))`,String.raw`((?:https?:\/\/|mailto:)[^\s<>()]{0,2048}[^\s<>().,;:!?'"`+"`"+String.raw`*])`,String.raw`(\*[^*\s][^*\n]{0,1000}?\*|(?<![\w])_[^_\s][^_\n]{0,1000}?_(?![\w]))`].join("|")),e4=new RegExp(String.raw`^\[(${i1})\]\((${s1})\)$`);function t4(s){const t=e4.exec(s);return t?{text:t[1],href:t[2]}:void 0}const gc=w.createContext(null),n4="cursor-pointer text-highlight underline-offset-2 hover:underline focus-visible:underline outline-none";function jy({target:s,links:t,children:i,title:a}){return o.jsx("button",{type:"button",className:I("inline break-words text-left [overflow-wrap:anywhere]",n4),title:a,"data-testid":"chat-file-link","data-path":s.path,onClick:()=>t.open(s),children:o.jsx(gc.Provider,{value:null,children:i})})}const a1=s=>/^(https?:\/\/|mailto:)/i.test(s)?s:void 0;function Sy({href:s,children:t}){const i=a1(s);return i?o.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"break-words text-highlight [overflow-wrap:anywhere] hover:underline",children:o.jsx(gc.Provider,{value:null,children:t})}):o.jsx(o.Fragment,{children:t})}function qn({text:s}){const t=w.useContext(gc),i=[];let a=s,l=0;for(;a;){const u=J3.exec(a);if(!u){i.push(a);break}u.index&&i.push(a.slice(0,u.index));const[d,h,m,p,x,y,v]=u;if(h){const k=h.slice(1,-1),S=t?.resolve(k,"code"),j=o.jsx("code",{className:I("rounded-md bg-muted px-1 py-0.5 font-mono text-(length:--code-font-size)",S?"text-highlight":"text-foreground"),children:k});i.push(S&&t?o.jsx(jy,{target:S,links:t,title:`Open ${S.path}${S.line?`:${S.line}`:""}`,children:j},l++):o.jsx(w.Fragment,{children:j},l++))}else if(m)i.push(o.jsx("strong",{className:"font-semibold text-foreground",children:o.jsx(qn,{text:m.slice(2,-2)})},l++));else if(p)i.push(o.jsx("s",{className:"text-muted-foreground",children:o.jsx(qn,{text:p.slice(2,-2)})},l++));else if(x){const k=t4(x),S=!k||a1(k.href)?void 0:t?.resolve(k.href,"href");k?i.push(S&&t?o.jsx(jy,{target:S,links:t,title:`Open ${S.path}${S.line?`:${S.line}`:""}`,children:o.jsx(qn,{text:k.text})},l++):o.jsx(Sy,{href:k.href,children:o.jsx(qn,{text:k.text})},l++)):i.push(x)}else y?i.push(o.jsx(Sy,{href:y,children:y},l++)):v&&i.push(o.jsx("em",{className:"italic",children:o.jsx(qn,{text:v.slice(1,-1)})},l++));a=a.slice(u.index+d.length)}return o.jsx(o.Fragment,{children:i})}const s4=["","mt-6 mb-3 border-b border-border pb-2 text-[1.867em] leading-[1.286] font-bold","mt-6 mb-3 border-b border-border pb-2 text-[1.6em] leading-[1.292] font-bold","mt-4 mb-2 text-[1.4em] leading-[1.333] font-semibold","mt-4 mb-2 text-[1.267em] leading-[1.316] font-semibold","mt-3 mb-1 text-[1.133em] leading-[1.294] font-semibold","mt-3 mb-1 text-[1.133em] leading-[1.294] font-semibold uppercase tracking-[0.5px] text-muted-foreground"];function r1({blocks:s,nested:t}){return o.jsx(o.Fragment,{children:s.map((i,a)=>{const l=s[a+1];switch(i.kind){case"code":return o.jsx(i4,{text:i.text,lang:i.lang},a);case"heading":{const u=`h${Math.min(i.level+1,6)}`;return o.jsx(u,{className:I("text-foreground first:mt-0",s4[i.level]),children:o.jsx(qn,{text:i.text})},a)}case"list":{const u=i.ordered?"ol":"ul",d=t?"mb-0":l?l.kind==="list"?"mb-2":"mb-4":"mb-0";return o.jsx(u,{className:I("mt-1 pl-2.5",d),...i.ordered&&i.start!==1?{start:i.start}:{},children:i.items.map((h,m)=>o.jsxs("li",{className:"mb-1 flex items-start",children:[o.jsx("span",{"aria-hidden":!0,className:I("mr-1 shrink-0 select-none text-muted-foreground",i.ordered&&"min-w-3"),children:i.ordered?`${i.start+m}.`:"•"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx(qn,{text:h.text}),h.children.length?o.jsx(r1,{blocks:h.children,nested:!0}):null]})]},m))},a)}case"quote":return o.jsx("blockquote",{className:"my-3 whitespace-pre-wrap rounded-r-md border-l-4 border-muted bg-card px-4 py-3 text-foreground/80",children:o.jsx(qn,{text:i.text})},a);case"table":return o.jsx("div",{className:"my-3 overflow-x-auto rounded-md border border-border",children:o.jsxs("table",{className:"w-full border-collapse text-left",children:[o.jsx("thead",{className:"bg-muted",children:o.jsx("tr",{children:i.head.map((u,d)=>o.jsx("th",{className:"border-b border-r border-border p-2 font-semibold last:border-r-0",children:o.jsx(qn,{text:u})},d))})}),o.jsx("tbody",{children:i.rows.map((u,d)=>o.jsx("tr",{className:"border-b border-border last:border-b-0",children:i.head.map((h,m)=>o.jsx("td",{className:"border-r border-border p-2 align-top last:border-r-0",children:o.jsx(qn,{text:u[m]??""})},m))},d))})]})},a);case"rule":return o.jsx("hr",{className:"my-2.5 border-0 border-t border-border"},a);default:return o.jsx("p",{className:I("whitespace-pre-wrap",t?"mb-0":"mb-3"),children:o.jsx(qn,{text:i.text})},a)}})})}function i4({text:s,lang:t}){const i=mc(s,H3(t));return o.jsx("pre",{className:"my-3 overflow-x-auto rounded-md border border-border bg-muted p-3 font-mono text-(length:--code-font-size) leading-[1.5] text-foreground","data-language":t||void 0,children:o.jsx("code",{children:i?i.map((a,l)=>o.jsxs(w.Fragment,{children:[l?`
|
|
27
|
+
`:null,o.jsx(pc,{tokens:a})]},l)):s})})}function fo({text:s,className:t}){const i=w.useMemo(()=>Z3(s),[s]);return o.jsx("div",{className:I("min-w-0 break-words text-(length:--content-font-size) leading-[1.4] text-foreground [overflow-wrap:anywhere]",t),children:o.jsx(r1,{blocks:i})})}const Xl="‹hidden on the host›",a4=new Set(["instructions","body","houseRules"]),r4={instructions:"AGENT.md",config:"agent.json",body:"SKILL.md",server:"Server",hook:"Hook",team:"team.json",houseRules:"HOUSE_RULES.md",provider:"Provider"},Ny=s=>s!==null&&typeof s=="object"&&!Array.isArray(s)&&Object.keys(s).length===1&&s.$secret==="keep";function o4(s){const t=[];for(const[i,a]of Object.entries(s??{})){const l=r4[i]??i;if(a4.has(i)&&typeof a=="string"){t.push({key:i,label:l,kind:"text",text:a});continue}if(a===void 0)continue;const u=Ny(a)?Xl:JSON.stringify(a,(d,h)=>Ny(h)?Xl:h,2);t.push({key:i,label:l,kind:"json",text:u})}return t}const Ml={none:"/favicon.svg",running:"/favicon-running.svg",attention:"/favicon-attention.svg"},Ty=220;function l4({status:s,waiting:t=!1,reason:i}){return t?"needs_input":s==="error"||i==="error"?"failed":s==="running"||s==="initializing"?"running":i==="finished"?"attention":"done"}function c4(s,t=!1){return s.includes("running")?"running":t||s.includes("needs_input")||s.includes("attention")?"attention":"none"}function u4({root:s,name:t,reason:i,message:a}){const l=i==="error"?(a?o1(a):"")||"Encountered an error.":"Finished working.";return{title:i==="finished"?"Agent finished":"Agent needs attention",body:`${t}: ${l}`,tag:`alp-${i}-${s}`}}function d4(s,t){return Object.entries(t).filter(([i,a])=>a.at!==s[i]?.at).map(([i])=>i)}function o1(s){const t=s.replace(/```[\s\S]*?```/g," ").replace(/[`*_>#~[\]]/g,"").replace(/\s+/g," ").trim();return t.length>Ty?`${t.slice(0,Ty-3).trimEnd()}...`:t}function f4(s,t){return Object.entries(t).filter(([i,a])=>a>0&&a>(s[i]??0)).map(([i])=>i)}const Ay=(s,t)=>s.visible&&s.focused&&s.shown===t,l1="fixed z-50 max-h-[min(60vh,28rem)] min-w-40 max-w-[min(92vw,26rem)] overflow-y-auto rounded-lg border border-border bg-popover p-1 shadow-xl shadow-[var(--shadow)]";function Mf({items:s,close:t,openPage:i}){return o.jsx(o.Fragment,{children:s.map(a=>o.jsxs(w.Fragment,{children:[a.group?o.jsx("div",{role:"separator",className:"-mx-1 my-1 h-px bg-border"}):null,o.jsxs("button",{type:"button",role:a.checked===void 0?"menuitem":a.keepOpen?"menuitemcheckbox":"menuitemradio","aria-checked":a.checked,disabled:a.disabled,title:a.title,"data-testid":a.testId,"aria-haspopup":a.page?"menu":void 0,onClick:l=>{if(l.stopPropagation(),a.page&&i){i(a.page);return}a.keepOpen||t(),a.onSelect()},className:I("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm outline-none hover:bg-accent focus-visible:bg-accent disabled:opacity-45 [&_svg]:size-3.5",a.destructive?"text-destructive":"text-foreground"),children:[a.icon,o.jsx("span",{className:"min-w-0 flex-1 truncate",children:a.label}),a.indicator?o.jsx("span",{"aria-label":"On",className:"size-1.5 shrink-0 rounded-full bg-highlight"}):null,a.hint?o.jsx("span",{className:"ml-3 font-mono text-xs text-muted-foreground",children:a.hint}):null,a.value?o.jsx("span",{className:"ml-3 max-w-[50%] truncate text-xs text-muted-foreground",children:a.value}):null,a.page?o.jsx(Wn,{"aria-hidden":!0,className:"text-muted-foreground"}):null,a.checked?o.jsx(oc,{"aria-hidden":!0,className:"ml-2 text-foreground"}):null]})]},a.id??a.label))})}function c1(s,t){return i=>{const a=Array.from(s.current?.querySelectorAll('[role^="menuitem"]:not([disabled])')??[]),l=a.indexOf(document.activeElement);i.key==="Escape"?(i.preventDefault(),i.stopPropagation(),t()):i.key==="ArrowDown"?(i.preventDefault(),a[(l+1)%a.length]?.focus()):i.key==="ArrowUp"?(i.preventDefault(),a[(l-1+a.length)%a.length]?.focus()):i.key==="Home"?(i.preventDefault(),a[0]?.focus()):i.key==="End"?(i.preventDefault(),a.at(-1)?.focus()):i.key==="Tab"&&t(!1)}}function u1({label:s,at:t,items:i,onClose:a,testId:l,fallbackFocus:u}){const d=w.useRef(null),[h,m]=w.useState({visibility:"hidden"}),p=w.useRef(null),x=w.useCallback((y=!0)=>{if(a(),!y)return;const v=p.current;v?.focus(),setTimeout(()=>{v&&!v.isConnected&&u?.()?.focus()},0)},[a,u]);return w.useLayoutEffect(()=>{if(!t)return;p.current=document.activeElement;const y=d.current?.offsetWidth??0,v=d.current?.offsetHeight??0;m({left:Math.max(8,Math.min(t.x,window.innerWidth-y-8)),top:Math.max(8,Math.min(t.y,window.innerHeight-v-8))})},[t]),w.useLayoutEffect(()=>{t&&h.visibility!=="hidden"&&d.current?.querySelector('[role^="menuitem"]:not([disabled])')?.focus()},[h]),w.useEffect(()=>{if(!t)return;const y=()=>x(!1),v=k=>{d.current?.contains(k.target)||x(!1)};return window.addEventListener("resize",y),window.addEventListener("scroll",y,!0),window.addEventListener("blur",y),document.addEventListener("pointerdown",v,!0),()=>{window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0),window.removeEventListener("blur",y),document.removeEventListener("pointerdown",v,!0)}},[t,x]),t?o.jsx("div",{ref:d,role:"menu","aria-label":s,"data-testid":l,onKeyDown:c1(d,x),onContextMenu:y=>y.preventDefault(),style:h,className:l1,children:o.jsx(Mf,{items:i,close:()=>x()})}):null}function Vt({label:s,title:t,trigger:i,triggerClassName:a,items:l,pages:u,width:d,align:h="end",onOpenChange:m,disabled:p,openRequest:x,onOpenRequestHandled:y,testId:v}){const[k,S]=w.useState(!1),[j,A]=w.useState(null),[R,q]=w.useState({}),L=w.useRef(null),O=w.useRef(null),B=w.useId(),_=w.useCallback(J=>{S(J),J||A(null),m?.(J)},[m]);w.useEffect(()=>{x&&(p||_(!0),y?.())},[x]);const W=()=>Array.from(O.current?.querySelectorAll('[role^="menuitem"]:not([disabled])')??[]);w.useLayoutEffect(()=>{if(!k||!L.current)return;const J=L.current.getBoundingClientRect(),me=O.current?.offsetHeight??0,se=J.bottom+4+me<=window.innerHeight-8;q({top:se?J.bottom+4:Math.max(8,J.top-4-me),...h==="end"?{right:Math.max(8,window.innerWidth-J.right)}:{left:Math.max(8,J.left)}})},[k,h]),w.useEffect(()=>{k&&W()[0]?.focus()},[k,j]),w.useEffect(()=>{if(!k)return;const J=()=>_(!1),me=fe=>{fe.target instanceof Node&&fe.target.contains(L.current)&&_(!1)};window.addEventListener("resize",J),window.addEventListener("scroll",me,!0);const se=fe=>{!O.current?.contains(fe.target)&&!L.current?.contains(fe.target)&&_(!1)};return document.addEventListener("pointerdown",se),()=>{document.removeEventListener("pointerdown",se),window.removeEventListener("resize",J),window.removeEventListener("scroll",me,!0)}},[k,_]);const E=(J=!0)=>{_(!1),J&&L.current?.focus()},V=j?u?.[j]:void 0,U=c1(O,E),de=J=>{if(V&&(J.key==="Escape"||J.key==="ArrowLeft")){J.preventDefault(),J.stopPropagation(),A(null);return}U(J)};return o.jsxs(o.Fragment,{children:[o.jsx("button",{ref:L,type:"button","aria-label":s,title:t??s,disabled:p,"aria-haspopup":"menu","aria-expanded":k,"aria-controls":k?B:void 0,"data-testid":v,onClick:J=>{J.stopPropagation(),_(!k)},onKeyDown:J=>{J.key==="ArrowDown"&&!k&&(J.preventDefault(),_(!0))},className:a,children:i}),k?o.jsx("div",{ref:O,id:B,role:"menu","aria-label":V?V.title:s,onKeyDown:de,style:d?{...R,width:d}:R,className:l1,"data-page":j??void 0,children:V?o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",role:"menuitem",onClick:J=>{J.stopPropagation(),A(null)},"aria-label":`Back from ${V.title}`,className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent [&_svg]:size-3.5",children:[o.jsx(th,{"aria-hidden":!0}),V.title]}),o.jsx("div",{role:"separator",className:"-mx-1 my-1 h-px bg-border"}),o.jsx(Mf,{items:V.items,close:()=>E()})]}):o.jsx(Mf,{items:l,close:()=>E(),openPage:u?A:void 0})}):null]})}const h4=[{id:"general",title:"General"},{id:"workspaces",title:"Projects & Workspaces"},{id:"tabs-panes",title:"Tabs & Panes"},{id:"layout",title:"Layout"},{id:"agent-input",title:"Agent Input"}],xc=[{action:"command-center.toggle",combo:"Mod+K",section:"general",label:"Toggle command center"},{action:"command-center.files",combo:"Mod+P",section:"general",label:"Search files"},{action:"shortcuts.toggle",combo:"Shift+?",section:"general",label:"Show keyboard shortcuts",scope:"other",note:"Available when focus is not in a text field."},{action:"settings.toggle",combo:"Mod+,",section:"general",label:"Toggle settings"},{action:"session.new",combo:"Mod+N",section:"workspaces",label:"New session"},{action:"session.archive",combo:"Mod+Shift+Backspace",section:"workspaces",label:"Archive session"},{action:"session.index",combo:"Alt+Digit",section:"workspaces",label:"Jump to session",display:["alt","1-9"]},{action:"session.relative",combo:"Alt+[",delta:-1,section:"workspaces",label:"Previous session"},{action:"session.relative",combo:"Alt+]",delta:1,section:"workspaces",label:"Next session"},{action:"tab.menu",combo:"Mod+T",section:"tabs-panes",label:"New tab"},{action:"tab.agent",combo:"Mod+Shift+A",section:"tabs-panes",label:"New agent"},{action:"tab.changes",combo:"Mod+Shift+G",section:"tabs-panes",label:"Changes"},{action:"tab.files",combo:"Mod+Shift+E",section:"tabs-panes",label:"Files"},{action:"tab.terminal",combo:"Mod+Shift+T",section:"tabs-panes",label:"New terminal"},{action:"tab.close",combo:"Alt+Shift+W",section:"tabs-panes",label:"Close current tab"},{action:"tab.index",combo:"Alt+Shift+Digit",section:"tabs-panes",label:"Jump to tab",display:["alt","shift","1-9"]},{action:"tab.relative",combo:"Alt+Shift+[",delta:-1,section:"tabs-panes",label:"Previous tab"},{action:"tab.relative",combo:"Alt+Shift+]",delta:1,section:"tabs-panes",label:"Next tab"},{action:"pane.split.right",combo:"Cmd+\\",section:"tabs-panes",label:"Split pane right",mac:!0},{action:"pane.split.down",combo:"Cmd+Shift+\\",section:"tabs-panes",label:"Split pane down",mac:!0},{action:"pane.focus.left",combo:"Cmd+Shift+ArrowLeft",section:"tabs-panes",label:"Focus pane left",mac:!0,scope:"other"},{action:"pane.focus.right",combo:"Cmd+Shift+ArrowRight",section:"tabs-panes",label:"Focus pane right",mac:!0,scope:"other"},{action:"pane.focus.up",combo:"Cmd+Shift+ArrowUp",section:"tabs-panes",label:"Focus pane up",mac:!0,scope:"other"},{action:"pane.focus.down",combo:"Cmd+Shift+ArrowDown",section:"tabs-panes",label:"Focus pane down",mac:!0,scope:"other"},{action:"pane.move.left",combo:"Cmd+Alt+Shift+ArrowLeft",section:"tabs-panes",label:"Move tab left",mac:!0},{action:"pane.move.right",combo:"Cmd+Alt+Shift+ArrowRight",section:"tabs-panes",label:"Move tab right",mac:!0},{action:"pane.move.up",combo:"Cmd+Alt+Shift+ArrowUp",section:"tabs-panes",label:"Move tab up",mac:!0},{action:"pane.move.down",combo:"Cmd+Alt+Shift+ArrowDown",section:"tabs-panes",label:"Move tab down",mac:!0},{action:"pane.close",combo:"Cmd+Shift+W",section:"tabs-panes",label:"Close pane",mac:!0,note:"Some browsers keep this key to close the window."},{action:"sidebar.left",combo:"Mod+B",section:"layout",label:"Toggle left sidebar"},{action:"sidebar.right",combo:"Mod+E",section:"layout",label:"Toggle Explorer sidebar"},{action:"sidebar.right",combo:"Ctrl+`"},{action:"sidebar.both",combo:"Mod+.",section:"layout",label:"Toggle both sidebars"},{action:"composer.focus",combo:"Mod+L",section:"agent-input",label:"Focus message input",handledElsewhere:!0},{action:"composer.mode",combo:"Shift+Tab",section:"agent-input",label:"Cycle agent mode",handledElsewhere:!0},{action:"agent.interrupt",combo:"Escape",section:"agent-input",label:"Interrupt agent",handledElsewhere:!0}],Cy={"[":"BracketLeft","]":"BracketRight",",":"Comma",".":"Period","`":"Backquote","?":"Slash","\\":"Backslash"};function d1(s,t){const i=s.split("+"),a=i.pop()??"",l={meta:!1,ctrl:!1,alt:!1,shift:!1};for(const u of i)u==="Mod"?l[t?"meta":"ctrl"]=!0:u==="Cmd"?l.meta=!0:u==="Ctrl"?l.ctrl=!0:u==="Alt"?l.alt=!0:u==="Shift"&&(l.shift=!0);return{key:a,mods:l}}function m4(s,{mac:t,editable:i=!1,bindings:a=xc}){for(const l of a){if(l.handledElsewhere||l.mac&&!t||l.scope==="other"&&i)continue;const{key:u,mods:d}=d1(l.combo,t);if(!(s.metaKey!==d.meta||s.ctrlKey!==d.ctrl||s.altKey!==d.alt||s.shiftKey!==d.shift)){if(u==="Digit"){const h=/^Digit([1-9])$/.exec(s.code);if(h)return{binding:l,index:Number(h[1])};continue}if(u.length===1&&/[A-Za-z]/.test(u)?s.code===`Key${u.toUpperCase()}`:Cy[u]&&s.code===Cy[u]||s.key===u)return{binding:l}}}return null}function ph(s,t){if(s.display)return s.display;const{key:i,mods:a}=d1(s.combo,t),l=[];return a.ctrl&&l.push("ctrl"),a.meta&&l.push("mod"),a.alt&&l.push("alt"),a.shift&&i!=="?"&&l.push("shift"),l.push(i),l}const p4={Backspace:"⌫",Enter:"⏎",Escape:"Esc",Space:"␣",ArrowLeft:"←",ArrowRight:"→",ArrowUp:"↑",ArrowDown:"↓"};function gh(s,t){const i=l=>p4[l]??(l.length===1?l.toUpperCase():l);if(t){const l=["ctrl","alt","shift","mod"],u={ctrl:"⌃",alt:"⌥",shift:"⇧",mod:"⌘"};return l.filter(d=>s.includes(d)).map(d=>u[d]).join("")+s.filter(d=>!l.includes(d)).map(i).join("")}const a={mod:"Ctrl",ctrl:"Ctrl",alt:"Alt",shift:"Shift"};return s.map(l=>a[l]??i(l)).join("+")}function Pl(s,t){const i=xc.find(a=>a.action===s&&a.label&&(!a.mac||t));return i?gh(ph(i,t),t):""}function g4(s,t=""){const i=t.trim().toLowerCase();return h4.map(a=>({...a,rows:xc.filter(l=>l.section===a.id&&l.label&&(!l.mac||s)).map(l=>({id:`${l.action}:${l.combo}`,label:l.label,keys:gh(ph(l,s),s),...l.note?{note:l.note}:{}})).filter(l=>!i||l.label.toLowerCase().includes(i)||l.keys.toLowerCase().includes(i))})).filter(a=>a.rows.length)}function f1(s){const t=s;if(!t||typeof t.closest!="function")return!1;if(t.isContentEditable)return!0;const i=String(t.tagName??"").toLowerCase();return i==="textarea"||i==="select"?!0:i!=="input"?!1:!["button","checkbox","radio","submit","reset","range","color","file"].includes(String(t.type??"").toLowerCase())}function ho(){const s=globalThis.navigator;return/Mac|iPhone|iPad/.test(String(s?.platform||s?.userAgent||""))}const x4=[["needs_input","Needs input"],["failed","Failed"],["attention","Ready to review"],["running","Working"],["done","Done"]],y4=7,Ey=s=>{const t=Date.parse(s??"");return Number.isFinite(t)?t:0};function My(s,t){const i=a=>Ey(t==="lastPrompt"?a.updatedAt??a.createdAt:a.createdAt);return[...s].sort((a,l)=>i(l)-i(a)||a.id.localeCompare(l.id))}function b4(s,t,i){const a=s.filter((l,u)=>u<y4||i(l)!=="done");return{visible:t?[...s]:a,canToggle:a.length<s.length}}function v4(s,t){return x4.map(([i,a])=>({bucket:i,label:a,sessions:s.filter(l=>t(l)===i)})).filter(i=>i.sessions.length>0)}function h1(s,t){return s.filter(i=>t.includes(i))}function w4(s,t){const i=h1(t,s);return i.length?s.filter(a=>i.includes(a)):[...s]}function m1(){return o.jsxs("span",{"aria-hidden":!0,className:"relative flex size-[14px] items-center justify-center",children:[o.jsx("span",{className:"absolute inset-[1px] rounded-full border-[1.5px] border-dot-running opacity-30"}),o.jsx("span",{className:"absolute inset-[1px] animate-spin rounded-full border-[1.5px] border-transparent border-t-dot-running opacity-90 [animation-duration:900ms]"}),o.jsx("span",{className:"size-1.5 rounded-full bg-dot-running"})]})}function xh({bucket:s}){const t=s==="running"?"Running":s==="needs_input"?"Waiting for your answer":s==="failed"?"Failed":s==="attention"?"Finished":"Idle";return o.jsxs("span",{className:"flex h-5 w-4 shrink-0 items-center justify-center",title:t,"data-status":s,children:[s==="running"?o.jsx(m1,{}):s==="needs_input"?o.jsx(Js,{"aria-hidden":!0,className:"size-3 fill-dot-warning text-sidebar"}):o.jsx("span",{"aria-hidden":!0,className:I("size-1.5 rounded-full",s==="failed"?"bg-dot-danger":s==="attention"?"bg-dot-success":"bg-extra-muted opacity-30")}),o.jsx("span",{className:"sr-only",children:t})]})}function k4({workspaceId:s,managed:t,online:i,open:a,onClose:l}){const u=Oe(),[d,h]=w.useState(!1),m=R=>{l()},[p,x]=w.useState([]),[y,v]=w.useState(""),[k,S]=w.useState(""),j=async()=>{if(S(""),!t){h(!0);try{const R=await u.worktreeOptions(s);x(R),v(R[0]??"")}catch(R){S(R instanceof Error?R.message:String(R))}finally{h(!1)}}},A=async()=>{h(!0);try{await u.mutateWorktree(t?"remove":"create",s,t?void 0:y)?(m(!1),S("")):S("The operation is not confirmed. Retry to reconcile.")}finally{h(!1)}};return w.useEffect(()=>{a&&j()},[a]),o.jsxs(ti,{open:a,onClose:()=>{d||m()},title:t?"Remove managed worktree":"Create managed worktree",children:[o.jsx("p",{children:t?"Delete this checkout’s files. Its Git branch remains. Saved sessions, active work, claims, leases, results and dirty files prevent removal.":"Create a clean checkout from the current committed HEAD in a host-approved destination."}),t?null:p.length?o.jsxs("label",{className:"mt-2 block",children:["Destination",o.jsx("select",{"aria-label":"Worktree destination",className:"mt-1 w-full rounded border border-border bg-background p-1",value:y,onChange:R=>v(R.target.value),children:p.map(R=>o.jsx("option",{children:R},R))})]}):o.jsx("p",{className:"mt-2",children:d?"Loading destinations…":"Ask the host owner to configure a destination mapping and grant its ID to this credential."}),k?o.jsx("p",{role:"alert",className:"mt-2",children:k}):null,o.jsxs("div",{className:"mt-3 flex gap-3",children:[o.jsx("button",{type:"button",disabled:d||!i||!t&&!y,onClick:()=>{A()},children:d?"Working…":t?"Delete checkout files":"Create checkout"}),o.jsx("button",{type:"button",disabled:d,onClick:()=>m(),children:"Cancel"})]})]})}const zy=["#7a6aa8","#3d7ea6","#388068","#a4673a","#b05c80","#6a70b8","#368080","#b06260","#8f7838","#5179b0"];function j4(s){let t=0;for(const i of s)t=t*31+i.charCodeAt(0)>>>0;return zy[t%zy.length]}const Rn="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",Ql="hover:bg-sidebar-hover active:bg-secondary",S4="https://github.com/phucanh08/alp/issues/new",N4="https://github.com/phucanh08/alp/releases";function ql({icon:s,label:t,onClick:i,disabled:a,title:l,active:u,shortcut:d,testId:h}){return o.jsx("div",{className:"px-2",children:o.jsxs("button",{type:"button",onClick:i,disabled:a,title:l,"aria-current":u?"page":void 0,"data-testid":h,className:I("group flex min-h-9 w-full items-center gap-2 rounded-lg px-2 py-1 md:min-h-7 text-left text-sm text-muted-foreground hover:text-foreground disabled:pointer-events-none disabled:opacity-45",Ql,u&&"bg-sidebar-hover text-foreground",Rn),children:[o.jsx(s,{"aria-hidden":!0,className:"size-[18px] shrink-0 md:size-3.5"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),d?o.jsx("kbd",{"aria-hidden":!0,className:"hidden rounded-md bg-secondary/50 px-1 py-px font-sans text-[length:calc(11px*var(--ui-scale))] leading-4 text-muted-foreground md:group-hover:inline",children:d}):null]})})}function T4({query:s,onQuery:t,open:i,onOpen:a,onClose:l,focusRequest:u,shortcut:d}){const h=w.useRef(null);return w.useEffect(()=>{i&&h.current?.focus()},[i,u]),i?o.jsx("div",{className:"px-2",children:o.jsxs("div",{className:"flex min-h-9 w-full items-center gap-2 rounded-lg bg-sidebar-hover px-2 py-1 md:min-h-7 focus-within:ring-1 focus-within:ring-border",children:[o.jsx(Ws,{"aria-hidden":!0,className:"size-[18px] shrink-0 text-foreground md:size-3.5"}),o.jsx("input",{ref:h,type:"search",value:s,onChange:m=>t(m.target.value),"aria-label":"Search sessions",placeholder:"Search sessions…",onKeyDown:m=>{m.key==="Escape"&&(m.preventDefault(),l())},onBlur:()=>{s.trim()||l()},className:"min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden"}),o.jsx("button",{type:"button","aria-label":"Clear search",title:"Clear search",onMouseDown:m=>m.preventDefault(),onClick:l,className:I("-mr-1 flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-secondary hover:text-foreground",Rn),children:o.jsx(Zt,{"aria-hidden":!0,className:"size-3.5"})})]})}):o.jsx(ql,{icon:Ws,label:"Search",onClick:a,shortcut:d})}function yh(s,t,i){return l4({status:s.status,waiting:t,reason:i})}function Zd({title:s,children:t,testId:i}){return o.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-2 pl-2 pr-1 md:min-h-9","data-testid":i,children:[o.jsx("h2",{className:"select-none text-xs text-muted-foreground",children:s}),t]})}function A4({session:s,title:t,meta:i,trailing:a,bucket:l,selected:u,canWrite:d,onSelect:h,onRename:m,onArchive:p}){const[x,y]=w.useState(!1),v=s.status==="closed"?"Closed":`Updated ${Mi(s.updatedAt??s.createdAt)}`;return o.jsxs("li",{className:I("group relative mb-0.5 rounded-lg",u?"bg-sidebar-selected":"hover:bg-sidebar-hover active:bg-secondary",x&&!u&&"bg-sidebar-hover"),children:[o.jsxs("button",{type:"button",onClick:h,"aria-current":u?"true":void 0,"data-testid":"session-row",title:`${t} · ${v}`,className:I("flex min-h-11 w-full min-w-0 items-start gap-2 rounded-lg py-2 pl-4 pr-3 text-left md:min-h-9",d&&"max-md:pr-8",Rn),children:[o.jsx(xh,{bucket:l}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[o.jsx("span",{className:I("min-w-0 flex-1 truncate text-sm leading-5 text-foreground",u||x?"opacity-100":"opacity-[0.76] group-hover:opacity-100"),children:t}),a?o.jsx("span",{className:I("shrink-0 text-xs text-muted-foreground tabular-nums",d&&"md:group-hover:invisible",x&&"invisible"),"data-testid":"sidebar-workspace-timestamp",children:a}):null]}),i.length?o.jsx("span",{className:"mt-0.5 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground","data-testid":"sidebar-row-meta",children:i.map(k=>o.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1","data-meta":k.key,children:[o.jsx(k.icon,{"aria-hidden":!0,className:"size-3 shrink-0"}),o.jsx("span",{className:"truncate",children:k.text})]},k.key))}):null]})]}),d?o.jsxs("div",{className:I("absolute right-[5px] top-[13px] flex opacity-100 md:top-[9px] md:opacity-0 group-hover:opacity-100 group-focus-within:opacity-100",x&&"opacity-100"),children:[o.jsx("span",{"aria-hidden":!0,className:I("pointer-events-none absolute inset-y-0 right-full hidden w-6 bg-linear-to-r md:block from-transparent",u?"to-sidebar-selected":"to-sidebar-hover")}),o.jsx(Vt,{label:`Actions for ${t}`,onOpenChange:y,trigger:o.jsx(CS,{"aria-hidden":!0,className:"size-3.5"}),triggerClassName:I("flex size-[18px] items-center justify-center rounded text-muted-foreground hover:bg-secondary hover:text-foreground",u?"bg-sidebar-selected":"bg-sidebar-hover",Rn),items:[{label:"Rename",icon:o.jsx($i,{"aria-hidden":!0}),onSelect:m},{label:"Archive",icon:o.jsx(ac,{"aria-hidden":!0}),onSelect:p,destructive:!0}]})]}):null]})}function C4({path:s,name:t,worktree:i,expanded:a,canWrite:l,actions:u,onToggle:d,onNewSession:h}){const[m,p]=w.useState(!1);return o.jsxs("div",{className:I("group relative mb-1 flex min-h-11 items-center rounded-lg md:min-h-9",Ql,m&&"bg-sidebar-hover"),children:[o.jsxs("button",{type:"button",onClick:d,"aria-expanded":a,title:s,"data-testid":"project-row","data-workspace":s,className:I("flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded-lg p-2 pr-16 text-left md:min-h-9",Rn),children:[o.jsxs("span",{"aria-hidden":!0,className:"flex h-5 w-4 shrink-0 items-center justify-center",children:[i?o.jsx(Fs,{className:"size-3.5 text-muted-foreground group-hover:hidden group-focus-within:hidden"}):o.jsx("span",{className:"flex size-4 items-center justify-center rounded-[4px] text-[length:calc(9px*var(--ui-scale))] font-medium leading-none text-white group-hover:hidden group-focus-within:hidden",style:{backgroundColor:j4(s)},children:t.slice(0,1).toUpperCase()}),o.jsx("span",{className:I("hidden size-3.5 text-muted-foreground group-hover:block group-focus-within:block transition-transform",a?"rotate-90":""),children:"›"})]}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-muted-foreground",children:t})]}),o.jsxs("div",{className:I("absolute right-1.5 flex items-center gap-0.5 md:opacity-0 group-hover:opacity-100 group-focus-within:opacity-100",m&&"opacity-100"),children:[u.length?o.jsx(Vt,{label:`Project actions for ${t}`,title:"Project actions",onOpenChange:p,testId:"project-actions",trigger:o.jsx(nh,{"aria-hidden":!0,className:"size-[15px]"}),items:u,triggerClassName:I("flex size-6 items-center justify-center rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground",Rn)}):null,l?o.jsx("button",{type:"button",onClick:h,"aria-label":`Start a session in ${t}`,title:`New session in ${t}`,className:I("flex size-6 items-center justify-center rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground",Rn),children:o.jsx(vs,{"aria-hidden":!0,className:"size-[15px]"})}):null]})]})}const zf=I("relative flex size-11 items-center justify-center rounded-md text-muted-foreground hover:text-foreground md:size-7 [&_svg]:size-5 md:[&_svg]:size-4",Rn);function Jd({label:s,title:t,onClick:i,children:a,testId:l}){return o.jsx("button",{type:"button","aria-label":s,title:t??s,onClick:i,"data-testid":l,className:zf,children:a})}function E4({display:s,projects:t,onChange:i}){const a=h1(s.projectFilters,t),l=h=>i({projectFilters:a.includes(h)?a.filter(m=>m!==h):[...a,h]}),u={grouping:{title:"Grouping",items:[{label:"Project",icon:o.jsx(Da,{"aria-hidden":!0}),checked:s.grouping==="project",onSelect:()=>i({grouping:"project"}),testId:"sidebar-grouping-project"},{label:"Status",icon:o.jsx(e0,{"aria-hidden":!0}),checked:s.grouping==="status",onSelect:()=>i({grouping:"status"}),testId:"sidebar-grouping-status"}]},sort:{title:"Sort",items:[{label:"Created",checked:s.sort==="created",onSelect:()=>i({sort:"created"}),testId:"sidebar-sort-created"},{label:"Last prompt",checked:s.sort==="lastPrompt",onSelect:()=>i({sort:"lastPrompt"}),testId:"sidebar-sort-lastPrompt"}]},titleSource:{title:"Title",items:[{label:"Title",icon:o.jsx(oN,{"aria-hidden":!0}),checked:s.titleSource==="title",onSelect:()=>i({titleSource:"title"}),testId:"sidebar-workspace-title-source-title"},{label:"Branch name",icon:o.jsx(Fs,{"aria-hidden":!0}),checked:s.titleSource==="branch",onSelect:()=>i({titleSource:"branch"}),testId:"sidebar-workspace-title-source-branch"}]},show:{title:"Show",items:[...[["branch","Branch",Fs],["project","Project",Da],["host","Host",Qr],["labels","Labels",f0]].map(([h,m,p])=>({label:m,icon:o.jsx(p,{"aria-hidden":!0}),checked:s.rowItems[h],keepOpen:!0,testId:`sidebar-row-item-${h}`,onSelect:()=>i({rowItems:{...s.rowItems,[h]:!s.rowItems[h]}})})),{label:"Last activity",icon:o.jsx(SS,{"aria-hidden":!0}),checked:s.trailing==="timestamp",keepOpen:!0,group:!0,testId:"sidebar-workspace-trailing-timestamp",onSelect:()=>i({trailing:s.trailing==="timestamp"?"none":"timestamp"})}]},projectFilter:{title:"Project",items:[{label:"All projects",checked:a.length===0,keepOpen:!0,onSelect:()=>i({projectFilters:[]}),testId:"sidebar-project-filter-all"},...t.map((h,m)=>({id:h,label:Ot(h),title:h,checked:a.includes(h),keepOpen:!0,group:m===0,onSelect:()=>l(h),testId:"sidebar-project-filter-item"}))]}},d=[{label:"Grouping",page:"grouping",value:s.grouping==="project"?"Project":"Status",onSelect:()=>{},testId:"sidebar-display-grouping"},...s.grouping==="project"?[{label:"Sort",page:"sort",value:s.sort==="created"?"Created":"Last prompt",onSelect:()=>{},testId:"sidebar-display-sort"}]:[],{label:"Title",page:"titleSource",value:s.titleSource==="title"?"Title":"Branch name",onSelect:()=>{},testId:"sidebar-display-title-source"},{label:"Show",page:"show",onSelect:()=>{},testId:"sidebar-display-show"},...t.length>1?[{label:"Project",page:"projectFilter",indicator:a.length>0,group:!0,onSelect:()=>{},testId:"sidebar-display-project-filter"}]:[]];return o.jsx(Vt,{label:"Display preferences",align:"end",width:232,items:d,pages:u,testId:"sidebar-display-preferences-menu",trigger:o.jsx(JS,{"aria-hidden":!0,className:"size-3.5"}),triggerClassName:I("flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-sidebar-hover hover:text-foreground",Rn)})}function M4({open:s,onClose:t,unregistered:i}){const a=Oe(),{principal:l,connection:u,registry:d}=Me(),[h,m]=w.useState("");w.useEffect(()=>{s&&m(i[0]??"")},[s]);const p=Te(l??void 0,"workspace.write"),x=u.capabilities.includes("workspace.registry"),y=async()=>{h&&(await a.registerProject(h),t())};return o.jsx(ti,{open:s,onClose:t,title:"Add project",description:"A project is a directory the host owner granted to this access token. Adding it puts it in the host's shared workspace list. For another directory, the owner grants it first (alp-gateway credential create --workspace).",footer:x&&p&&i.length?o.jsxs(o.Fragment,{children:[o.jsx(be,{variant:"ghost",onClick:t,children:"Cancel"}),o.jsx(be,{disabled:!h||u.phase!=="open"||!!d.loading,onClick:()=>{y()},children:"Register project"})]}):o.jsx(be,{variant:"secondary",onClick:t,children:"Close"}),children:x?p?i.length?o.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Existing granted directory"}),o.jsx("select",{"aria-label":"Existing granted directory",value:h,onChange:v=>m(v.target.value),className:"w-full rounded-md border border-input bg-background p-2 text-sm",children:i.map(v=>o.jsx("option",{value:v,children:v},v))})]}):o.jsx("p",{className:"text-sm text-muted-foreground",children:"Every directory this token grants is already a project."}):o.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Ask the host owner to add workspace.write to your credential."}):o.jsx("p",{className:"text-sm text-muted-foreground",children:"This host does not list its workspaces. Update ALP on the host."})})}function z4({row:s,onClose:t}){const i=Oe(),[a,l]=w.useState("");w.useEffect(()=>{l(s?.title??"")},[s]);const u=async()=>{s&&await i.renameWorkspace(s.id,a)&&t()};return o.jsx(ti,{open:!!s,onClose:t,title:"Rename workspace",footer:o.jsxs(o.Fragment,{children:[o.jsx(be,{variant:"ghost",onClick:t,children:"Cancel"}),o.jsx(be,{onClick:()=>{u()},children:"Rename"})]}),children:o.jsx("form",{onSubmit:d=>{d.preventDefault(),u()},children:o.jsx(Qn,{"aria-label":"Workspace name",value:a,maxLength:200,placeholder:s?Ot(s.directory):"",onChange:d=>l(d.target.value),autoFocus:!0})})})}function R4({onNewSession:s,onRename:t,onArchive:i,onSettings:a,onShortcuts:l,onNavigate:u,onClose:d,onHistory:h,historyOpen:m,onTasks:p,tasksOpen:x,onOpenSession:y,searchRequest:v,onSearchRequestHandled:k}){const S=Oe(),j=Me(),{principal:A,workspace:R,sessions:q,selected:L,connection:O,preferences:B}=j,_=B.sidebarDisplay,W=w.useMemo(()=>ho(),[]),[E,V]=w.useState(!1),[U,de]=w.useState(!1),[J,me]=w.useState(""),[se,fe]=w.useState({}),[H,P]=w.useState(!1),[oe,xe]=w.useState(null),[T,z]=w.useState(null),F=Te(A??void 0,"session.write"),Z=Te(A??void 0,"workspace.write"),ie=O.capabilities.includes("workspace.worktree")&&Te(A??void 0,"workspace.manage"),re=O.phase==="open",le=j.registry,ve=C=>le.workspaces.filter(G=>!G.archivedAt&&(G.directory===C||A?.workspaceRoots?.some(ce=>ce.path===C&&ce.canonical===G.directory))).sort((G,ce)=>G.createdAt.localeCompare(ce.createdAt)||G.id.localeCompare(ce.id)),Re=[...new Set([...A?.workspaces??[],...le.workspaces.filter(C=>C.managedWorktree&&!C.archivedAt).map(C=>C.directory)])],Ne=w4(Re,_.projectFilters),et=Ne.filter(C=>!!ve(C)[0]?.pinnedAt),Ue=Ne.filter(C=>!et.includes(C)),Qe=(A?.workspaces??[]).filter(C=>!ve(C).length),We=J.trim().toLowerCase(),ye=C=>!We||Pn(C).toLowerCase().includes(We),[ge,Ce]=w.useState({}),je=Re.filter(C=>C!==R).join(`
|
|
28
|
+
`);w.useEffect(()=>{if(_.grouping!=="status"||!re)return;let C=!0;const G=()=>{S.listWorkspaceSessions(je?je.split(`
|
|
29
|
+
`):[]).then(ue=>{C&&Ce(ue)})};G();const ce=setInterval(G,15e3);return()=>{C=!1,clearInterval(ce)}},[S,_.grouping,re,je]);const Ut=C=>S.updatePreferences({sidebarDisplay:{..._,...C}}),ln=C=>{if(C===R){V(G=>!G);return}V(!1),S.selectWorkspace(C)},ze=C=>{C!==R&&(V(!1),S.selectWorkspace(C)),s(),u()},it=(C,G)=>{C!==R&&S.selectWorkspace(C),S.selectSession(G),y(),u()},gt=()=>{me(""),de(!1)},[At,$n]=w.useState(0);w.useEffect(()=>{v&&(de(!0),V(!1),$n(C=>C+1),k?.())},[v]);const _n=O.hostname??O.gateway.replace(/^https?:\/\//,""),cn=(C,G)=>{navigator.clipboard?.writeText(C).then(()=>S.notify("info",`${G} copied`),()=>S.notify("error",`Could not copy the ${G.toLowerCase()}.`))},xt=C=>ve(C)[0],zt=C=>xt(C)?.title||Ot(C),Ct=(C,G)=>{const ce=xt(C),ue=ce?.branch||void 0,pe=[];return _.rowItems.branch&&ue&&pe.push({key:"branch",icon:Fs,text:ue}),_.rowItems.project&&pe.push({key:"project",icon:Da,text:zt(C)}),_.rowItems.host&&pe.push({key:"host",icon:Qr,text:_n}),_.rowItems.labels&&ce?.labels.length&&pe.push({key:"labels",icon:f0,text:ce.labels.join(", ")}),{title:_.titleSource==="branch"&&ue?ue:Pn(G),meta:pe,trailing:_.trailing==="timestamp"?y3(G.updatedAt??G.createdAt):""}},Un=C=>yh(C,ic(j,C.id),ao(j,C.id)),vn=(C,G)=>{const ce=Ct(C,G);return o.jsx(A4,{session:G,title:ce.title,meta:ce.meta,trailing:ce.trailing,selected:G.id===L&&!m,canWrite:F,bucket:Un(G),onSelect:()=>it(C,G.id),onRename:()=>t(G),onArchive:()=>i(G)},G.id)},he=C=>{const G=xt(C),ce=[];if(G){const ue=Z?void 0:"Ask the host owner for workspace.write to change shared pins and names.";ce.push({label:G.pinnedAt?"Unpin":"Pin to top",icon:G.pinnedAt?o.jsx(XS,{"aria-hidden":!0}):o.jsx(c0,{"aria-hidden":!0}),disabled:!Z||!re,title:ue,onSelect:()=>{S.pinWorkspace(G.id,!G.pinnedAt)},testId:G.pinnedAt?"project-unpin":"project-pin"},{label:"Rename workspace",icon:o.jsx($i,{"aria-hidden":!0}),disabled:!Z||!re,title:ue,onSelect:()=>xe(G),testId:"project-rename"})}else O.capabilities.includes("workspace.registry")&&Z&&(A?.workspaces??[]).includes(C)&&ce.push({label:"Add to projects",icon:o.jsx(ly,{"aria-hidden":!0}),disabled:!re,onSelect:()=>{S.registerProject(C)},testId:"project-register"});return ce.push({label:"Copy path",icon:o.jsx(bs,{"aria-hidden":!0}),group:ce.length>0,onSelect:()=>cn(C,"Path"),testId:"project-copy-path"}),G?.branch&&ce.push({label:"Copy branch name",icon:o.jsx(Fs,{"aria-hidden":!0}),onSelect:()=>cn(G.branch,"Branch name"),testId:"project-copy-branch"}),G&&ie&&ce.push({label:G.managedWorktree?"Remove worktree":"Create worktree",icon:o.jsx(Fs,{"aria-hidden":!0}),group:!0,disabled:!re,onSelect:()=>z({row:G}),testId:G.managedWorktree?"project-remove-worktree":"project-create-worktree"}),ce.push({label:"Open project settings",icon:o.jsx(zS,{"aria-hidden":!0}),group:!0,onSelect:()=>a("projects"),testId:"project-settings"}),ce},Ae=C=>{const G=C===R&&(!E||!!We),ce=xt(C),ue=My(q.list.filter(ye),_.sort),pe=b4(ue,!!se[C]||!!We,Un);return o.jsxs("div",{className:I(G&&"pb-3"),"data-testid":"sidebar-project","data-path":C,"data-workspace-id":ce?.id,"data-pinned":ce?.pinnedAt?"true":void 0,"data-branch":ce?.branch??void 0,"data-worktree":ce?.managedWorktree?"true":void 0,children:[o.jsx(C4,{path:C,name:zt(C),worktree:!!ce?.managedWorktree,expanded:G,canWrite:F&&re,actions:he(C),onToggle:()=>ln(C),onNewSession:()=>ze(C)}),G?o.jsxs("div",{children:[q.status==="loading"&&!q.list.length?o.jsx("div",{className:"py-2 pl-4",children:o.jsx(Kt,{label:"Loading sessions…",className:"text-xs"})}):null,q.status==="error"?o.jsxs("div",{className:"mx-1 mb-1 rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-xs text-destructive",role:"alert",children:[q.error?.message," ",o.jsx("button",{type:"button",className:"text-highlight underline-offset-4 hover:underline",onClick:()=>{S.refreshSessions()},children:"Try again"})]}):null,q.status==="ready"&&!q.list.length?F&&re?o.jsxs("button",{type:"button",onClick:()=>ze(C),"aria-label":`Start a session in ${zt(C)}`,className:I("group mb-0.5 flex min-h-11 w-full items-center md:min-h-9 gap-2 rounded-lg py-2 pl-4 pr-3 text-left text-sm text-muted-foreground hover:text-foreground",Ql,Rn),children:[o.jsx("span",{className:"flex h-5 w-4 shrink-0 items-center justify-center",children:o.jsx(vs,{"aria-hidden":!0,className:"size-3.5"})}),o.jsx("span",{className:"truncate",children:"New session"})]}):o.jsx("p",{className:"flex min-h-9 items-center py-2 pl-10 pr-3 text-sm text-muted-foreground",children:"No sessions yet"}):null,We&&q.list.length&&!ue.length?o.jsxs("p",{className:"flex min-h-9 items-center py-2 pl-10 pr-3 text-sm text-muted-foreground",children:["No sessions match “",J.trim(),"”"]}):null,o.jsx("ul",{children:pe.visible.map(He=>vn(C,He))}),pe.canToggle||se[C]?o.jsx("button",{type:"button",onClick:()=>fe(He=>({...He,[C]:!He[C]})),"data-testid":"sidebar-show-more",className:I("flex min-h-9 w-full items-center rounded-lg py-1 pl-10 pr-3 text-left text-xs text-muted-foreground hover:text-foreground",Ql,Rn),children:se[C]?"Show less":"Show more"}):null]}):null]},C)},ht=()=>{const C=[...R?q.list.map(ue=>({path:R,session:ue})):[],...Object.entries(ge).filter(([ue])=>Ne.includes(ue)&&ue!==R).flatMap(([ue,pe])=>pe.map(He=>({path:ue,session:He})))].filter(ue=>Ne.includes(ue.path)&&ye(ue.session)),G=My(C.map(ue=>ue.session),"lastPrompt").map(ue=>C.find(pe=>pe.session===ue)),ce=v4(G.map(ue=>ue.session),Un);return ce.length?ce.map(ue=>o.jsxs("div",{"data-testid":`sidebar-status-${ue.bucket}`,children:[o.jsx(Zd,{title:ue.label}),o.jsx("ul",{children:ue.sessions.map(pe=>{const He=G.find(Ze=>Ze.session===pe);return vn(He.path,pe)})})]},ue.bucket)):o.jsx("p",{className:"px-2 py-3 text-sm text-muted-foreground",children:We?`No sessions match “${J.trim()}”`:"No sessions yet"})},jt=C=>{switch(C){case"new-session":return o.jsx(ql,{icon:vs,label:"New session",onClick:()=>{s(),u()},disabled:!R||!F||!re,title:F?void 0:"Your access token cannot start sessions.",shortcut:Pl("session.new",W)});case"history":return o.jsx(ql,{icon:cc,label:"History",onClick:()=>{h(),u()},active:m,disabled:!R,testId:"sidebar-history"});case"search":return o.jsx(T4,{query:J,onQuery:me,open:U,onOpen:()=>{de(!0),V(!1)},onClose:gt,focusRequest:At});case"tasks":return o.jsx(ql,{icon:rh,label:"Tasks",onClick:()=>{p?.(),u()},active:x,disabled:!R||!p,testId:"sidebar-tasks"})}},bt=B.sidebar.footer.filter(C=>C.visible);return o.jsxs("nav",{"aria-label":"Workspaces and sessions",className:"relative flex h-full min-h-0 flex-col bg-sidebar",children:[o.jsx("div",{className:"flex shrink-0 flex-col gap-0.5 border-b border-border pb-1.5 pt-2",children:B.sidebar.header.filter(C=>C.visible).map(C=>o.jsx(w.Fragment,{children:jt(C.id)},C.id))}),d?o.jsx("button",{type:"button","aria-label":"Close sessions",onClick:d,className:I("absolute right-[9.5px] top-3 z-10 flex size-8 items-center justify-center rounded-lg bg-sidebar text-muted-foreground hover:text-foreground",Rn),children:o.jsx(Zt,{"aria-hidden":!0,className:"size-4"})}):null,o.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 pb-4 pt-0.5",children:[_.grouping==="project"&&et.length?o.jsxs("div",{"data-testid":"sidebar-pinned",children:[o.jsx(Zd,{title:"Pinned",testId:"sidebar-pinned-header"}),et.map(Ae)]}):null,o.jsx(Zd,{title:"Workspaces",children:o.jsx(E4,{display:_,projects:Re,onChange:Ut})}),le.error?o.jsxs("p",{role:"alert",className:"px-2 pb-2 text-xs text-destructive",children:[le.error," ",o.jsx("button",{type:"button",className:"underline",onClick:()=>{S.refreshRegistry()},children:"Retry"})]}):null,Re.length?_.grouping==="status"?ht():Ue.map(Ae):o.jsxs("div",{className:"mt-1 px-2 py-3 text-sm","data-testid":"sidebar-no-projects",children:[o.jsx("p",{className:"text-foreground",children:"No projects yet"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This access token grants no workspace. The host owner adds one with alp-gateway credential create --workspace."})]})]}),bt.length?o.jsx("div",{className:"flex shrink-0 flex-col gap-0.5 border-t border-border py-1.5","data-testid":"sidebar-footer-items",children:bt.map(C=>o.jsx(w.Fragment,{children:jt(C.id)},C.id))}):null,o.jsxs("div",{className:"flex shrink-0 items-center border-t border-border px-2 py-1.5","data-testid":"sidebar-footer-bottom-line",children:[o.jsx(Jd,{label:"Add project",onClick:()=>P(!0),testId:"sidebar-add-project",children:o.jsx(ly,{"aria-hidden":!0})}),o.jsx(Jd,{label:"Usage",onClick:()=>a("usage"),testId:"sidebar-usage-icon",children:o.jsx(wS,{"aria-hidden":!0})}),o.jsx(Vt,{label:"Hosts",title:`${A?.label??"Access token"} · ${_n}${re?"":" · reconnecting"}`,align:"start",testId:"sidebar-hosts-trigger",trigger:o.jsxs(o.Fragment,{children:[o.jsx(Qr,{"aria-hidden":!0,className:"!size-[19px] md:!size-[15px]"}),o.jsx("span",{"aria-hidden":!0,className:I("absolute bottom-[11px] right-[11px] size-1.5 md:bottom-[5px] md:right-[5px] rounded-full ring-2 ring-sidebar",re?"bg-dot-success":"bg-dot-warning")})]}),triggerClassName:zf,items:[{label:_n,icon:o.jsx(Qr,{"aria-hidden":!0}),hint:re?"Online":"Reconnecting",onSelect:()=>a("host"),testId:"sidebar-host-option"},{label:"Connections",icon:o.jsx(l0,{"aria-hidden":!0}),onSelect:()=>a("connections")},{label:"Disconnect",icon:o.jsx(US,{"aria-hidden":!0}),destructive:!0,group:!0,onSelect:()=>S.disconnect(),testId:"sidebar-disconnect"}]}),o.jsx("span",{className:"flex-1"}),o.jsx(Vt,{label:"Help and support",align:"start",testId:"sidebar-help-trigger",trigger:o.jsx(kS,{"aria-hidden":!0}),triggerClassName:zf,items:[{label:"Run diagnostics",onSelect:()=>a("diagnostics")},...l?[{label:"Keyboard shortcuts",hint:Pl("shortcuts.toggle",W)||void 0,onSelect:l}]:[],{label:"Report an issue",group:!0,onSelect:()=>{window.open(S4,"_blank","noopener,noreferrer")}},{label:"What's new",onSelect:()=>{window.open(N4,"_blank","noopener,noreferrer")}}]}),o.jsx(Jd,{label:"Settings",onClick:()=>a(),testId:"sidebar-settings",children:o.jsx(lh,{"aria-hidden":!0})})]}),o.jsx(M4,{open:H,onClose:()=>P(!1),unregistered:Qe}),o.jsx(z4,{row:oe,onClose:()=>xe(null)}),T?o.jsx(k4,{workspaceId:T.row.id,managed:!!T.row.managedWorktree,online:re,open:!0,onClose:()=>z(null)}):null]})}const _4=6e3,Wr=()=>typeof window<"u"&&"Notification"in window;function L4(){const[s,t]=w.useState(()=>Wr()?Notification.permission:"unsupported");w.useEffect(()=>{if(!Wr())return;const a=()=>t(Notification.permission);return window.addEventListener("focus",a),document.addEventListener("visibilitychange",a),()=>{window.removeEventListener("focus",a),document.removeEventListener("visibilitychange",a)}},[]);const i=w.useCallback(async()=>{if(Wr())try{t(await Notification.requestPermission())}catch{t(Notification.permission)}},[]);return{permission:s,request:i}}function O4({onOpenSession:s}){const t=Me(),i=Oe(),{workspace:a,sessions:l,tree:u,attention:d,selected:h,focus:m}=t,p=w.useMemo(()=>oS(t),[t.turnAttention,l,u]);w.useEffect(()=>{const L=()=>i.setPresence({visible:document.visibilityState==="visible",focused:document.hasFocus()});return L(),window.addEventListener("focus",L),window.addEventListener("blur",L),document.addEventListener("visibilitychange",L),()=>{window.removeEventListener("focus",L),window.removeEventListener("blur",L),document.removeEventListener("visibilitychange",L)}},[i]);const x=c4(l.list.map(L=>yh(L,ic(t,L.id),ao(t,L.id))),Object.keys(p).length>0);w.useEffect(()=>{let L=document.querySelector('link[rel="icon"]');L||(L=document.createElement("link"),L.rel="icon",document.head.append(L)),L.type="image/svg+xml",L.href=Ml[x],L.dataset.status=x},[x]),w.useEffect(()=>()=>{const L=document.querySelector('link[rel="icon"]');L&&(L.href=Ml.none,L.dataset.status="none")},[]);const y=u?.rootId,v=y?l.list.find(L=>L.id===y):void 0,k=y?Pn({id:y,title:u?.projection.sessions[y]?.title??v?.title}):a?Ot(a):"ALP";w.useEffect(()=>(document.title=k,()=>{document.title="ALP"}),[k]);const S=w.useRef({attention:d,live:{}}),j=w.useMemo(()=>{const L=S.current;L.attention!==d&&(L.live={}),L.attention=d;const O={...d};for(const[B,_]of Object.entries(L.live))O[B]=Math.max(O[B]??0,_);if(u){const B=Object.keys(u.projection.questions).length;O[u.rootId]=u.status==="attached"?B:Math.max(B,d[u.rootId]??0),u.status==="attached"&&(L.live[u.rootId]=B)}return O},[d,u]),A=w.useRef({workspace:null,since:Date.now(),counts:{}}),R=w.useRef(s);R.current=s,w.useEffect(()=>{const L=A.current;if(L.workspace!==a){A.current={workspace:a,since:Date.now(),counts:j};return}const O=f4(L.counts,j);if(L.counts=j,!O.length||!Wr()||Notification.permission!=="granted")return;const B=Date.now()-L.since<_4,_={visible:document.visibilityState==="visible",focused:document.hasFocus(),shown:m??h};for(const W of O){const V=(u?.rootId===W?Object.values(u.projection.questions):[]).sort((de,J)=>(Date.parse(J.askedAt??"")||0)-(Date.parse(de.askedAt??"")||0))[0];if(B&&!(V&&(Date.parse(V.askedAt??"")||0)>=L.since)||Ay(_,W)||V?.sessionId&&Ay(_,V.sessionId))continue;const U=Pn(l.list.find(de=>de.id===W)??{id:W,title:u?.rootId===W?u.projection.sessions[W]?.title:void 0});try{const de=new Notification("Agent needs attention",{body:`${U}: ${V?.body?o1(V.body):"Waiting for your answer."}`,tag:`alp-question-${W}`,icon:Ml.attention});de.onclick=()=>{window.focus(),R.current(W),de.close()}}catch{}}},[j,a,u,l,h,m]);const q=w.useRef({workspace:a,entries:p});w.useEffect(()=>{const L=q.current,O=L.workspace===a?d4(L.entries,p):[];if(q.current={workspace:a,entries:p},!(!O.length||!Wr()||Notification.permission!=="granted"))for(const B of O){const _=p[B];if(!_)continue;const W=Pn(l.list.find(de=>de.id===B)??{id:B,title:u?.rootId===B?u.projection.sessions[B]?.title:void 0}),{title:E,body:V,tag:U}=u4({root:B,name:W,reason:_.reason,message:_.message});try{const de=new Notification(E,{body:V,tag:U,icon:Ml.attention});de.onclick=()=>{window.focus(),R.current(B),de.close()}}catch{}}},[p,a,l,u])}const p1=[{id:"general",label:"General",icon:lh},{id:"appearance",label:"Appearance",icon:VS},{id:"sidebar",label:"Sidebar",icon:$a},{id:"chat",label:"Chat",icon:IS},{id:"terminal",label:"Terminal",icon:hc},{id:"editor",label:"Editor",icon:NS},{id:"files",label:"Files",icon:ih},{id:"diagnostics",label:"Diagnostics",icon:aN},{id:"about",label:"About",icon:ah}],g1=[{id:"host",label:"Overview",icon:Qr},{id:"projects",label:"Projects",icon:oy},{id:"connections",label:"Connections",icon:l0},{id:"pair-device",label:"Pair device",icon:tN},{id:"alp-templates",label:"Templates",icon:Yl},{id:"alp-agents",label:"Agents",icon:Oa},{id:"alp-skills",label:"Skills",icon:yS},{id:"alp-hooks",label:"Hooks",icon:lN},{id:"alp-mcp",label:"MCP servers",icon:QS},{id:"metadata",label:"Metadata",icon:sN},{id:"voice",label:"Voice",icon:GS},{id:"workspaces",label:"Workspaces",icon:oy},{id:"providers",label:"Providers",icon:bS},{id:"usage",label:"Usage",icon:_S},{id:"terminals",label:"Terminals",icon:hc},{id:"plugins",label:"Plugins",icon:xS}],D4=Object.fromEntries([...p1,...g1].map(s=>[s.id,s.label])),q4={"new-session":{label:"New session",icon:vs},history:{label:"History",icon:cc},search:{label:"Search",icon:Ws},tasks:{label:"Tasks",icon:rh}},B4="Readable **content** and `code` preview.\n\n```ts\n// The highlight theme, code font and code size\nexport function greet(name: string): string {\n return `Hello, ${name}!`;\n}\n```";function $4(){return o.jsx("section",{className:"mb-6 rounded-lg border border-border bg-background p-4","aria-label":"Live preview of content typography, syntax theme, and code font","data-testid":"appearance-preview",children:o.jsx(fo,{text:B4})})}const yc="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset";function ot({title:s,action:t,children:i}){return o.jsxs("section",{className:"mb-6",children:[s||t?o.jsxs("div",{className:"mb-3 ml-1 flex items-center justify-between gap-2",children:[s?o.jsx("h3",{className:"text-xs font-normal text-muted-foreground",children:s}):o.jsx("span",{}),t]}):null,o.jsx("div",{className:"overflow-hidden rounded-lg border border-border bg-card",children:i})]})}function $e({title:s,hint:t,children:i,first:a}){return o.jsxs("div",{className:I("flex flex-wrap items-center justify-between gap-3 p-4",!a&&"border-t border-border"),children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"text-sm text-foreground",children:s}),t?o.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:t}):null]}),i!==void 0?o.jsx("div",{className:"min-w-0 max-w-full text-sm text-muted-foreground",children:i}):null]})}function on({what:s,why:t}){return o.jsx(ot,{children:o.jsxs("div",{className:"flex items-start gap-3 p-4",role:"note",children:[o.jsx(rc,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),o.jsxs("div",{children:[o.jsxs("p",{className:"text-sm",children:[s," is not available in this beta"]}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t})]})]})})}function La({label:s,value:t,options:i,onChange:a}){return o.jsx(mh,{"aria-label":s,value:t,onChange:l=>a?.(l.target.value),disabled:!a,className:"h-8 w-auto rounded-lg border-border bg-transparent pl-3 text-sm text-foreground disabled:cursor-default disabled:opacity-100",children:i.map(l=>o.jsx("option",{value:l.value,children:l.label},l.value))})}function U4(){const{permission:s,request:t}=L4(),i=s==="unsupported"?"This browser cannot show notifications.":s==="denied"?"Blocked in this browser. Allow notifications for this site in the browser settings to get them.":s==="granted"?"On: a notification when a session waits for your answer while you are elsewhere. The tab icon shows it too.":"Get a notification when a session waits for your answer while you are elsewhere. The browser asks first.";return o.jsx($e,{title:"Notifications",hint:i,children:s==="default"?o.jsx(be,{size:"sm",variant:"secondary",onClick:()=>{t()},children:"Enable"}):o.jsx("span",{className:"text-sm text-muted-foreground","data-testid":"notification-permission",children:s==="granted"?"Allowed":s==="denied"?"Blocked":"Unavailable"})})}function H4(s,t,i){return t==="mod-enter"?s==="interrupt"?`When the agent is running, ${i}+Enter interrupts. Enter inserts a new line.`:s==="queue"?`When the agent is running, ${i}+Enter queues. Enter inserts a new line.`:`When the agent is running, ${i}+Enter steers the active turn. Enter inserts a new line.`:s==="interrupt"?"When the agent is running, Enter interrupts. Command/Ctrl+Enter queues.":s==="queue"?"When the agent is running, Enter queues. Command/Ctrl+Enter submits.":"When the agent is running, Enter steers the active turn. Command/Ctrl+Enter queues."}const Ry=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent)?"⌘":"Ctrl";function I4({mobile:s}){const t=Oe(),{preferences:i}=Me();return o.jsxs(o.Fragment,{children:[o.jsx(ot,{title:"General",children:o.jsx($e,{first:!0,title:"Language",hint:"App language. This beta speaks English; the agents' language is a host setting (Host › Overview).",children:o.jsx(La,{label:"Language",value:"system",options:[{value:"system",label:"System"}]})})}),o.jsxs(ot,{title:"Sending",children:[s?null:o.jsx($e,{first:!0,title:"Send shortcut",children:o.jsx(La,{label:"Send shortcut",value:i.sendShortcut,onChange:a=>t.updatePreferences({sendShortcut:a}),options:[{value:"enter",label:"Enter"},{value:"mod-enter",label:`${Ry}+Enter`}]})}),o.jsx($e,{first:s,title:"Default send",hint:H4(i.sendBehavior,s?"enter":i.sendShortcut,Ry),children:o.jsx(La,{label:"Default send",value:i.sendBehavior,onChange:a=>t.setSendBehavior(a),options:[{value:"interrupt",label:"Interrupt"},{value:"steer",label:"Steer"},{value:"queue",label:"Queue"}]})})]}),o.jsxs(ot,{title:"This browser",children:[o.jsx($e,{first:!0,title:"Saved settings",hint:"Every App setting and your last New session choices (team, model, thinking, permissions) stay in this browser. The access token never does.",children:o.jsx(be,{size:"sm",variant:"secondary",onClick:()=>t.resetPreferences(),children:"Reset"})}),o.jsx(U4,{})]})]})}function Zr({label:s,value:t,placeholder:i,numeric:a,limits:l,width:u="w-28",onCommit:d}){const[h,m]=w.useState(t);w.useEffect(()=>m(t),[t]);const p=()=>{if(!a||!l){h.trim()!==t?d(h.trim()):m(t);return}const x=Number.parseInt(h,10);if(!Number.isFinite(x)){m(t);return}const y=String(Math.min(l[1],Math.max(l[0],x)));m(y),y!==t&&d(y)};return o.jsx(Qn,{"aria-label":s,value:h,placeholder:i,inputMode:a?"numeric":void 0,onChange:x=>m(a?x.target.value.replace(/[^\d]/g,""):x.target.value),onBlur:p,onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),p())},onFocus:x=>x.target.select(),className:I("h-8",u,a&&"text-right tabular-nums")})}function ef({title:s,hint:t,label:i,value:a,limits:l,onCommit:u}){return o.jsx($e,{title:s,hint:t,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx(Zr,{label:i,value:String(a),numeric:!0,limits:l,width:"w-16",onCommit:d=>u(Number(d))}),o.jsx("span",{className:"text-xs",children:"px"})]})})}function G4(){const s=Oe(),{preferences:t}=Me(),i=Wd.find(a=>a.value===t.theme)?.swatch;return o.jsxs(o.Fragment,{children:[o.jsx(ot,{title:"Theme",children:o.jsx($e,{first:!0,title:"Theme",children:o.jsxs("span",{className:"flex items-center gap-2",children:[i?o.jsx("span",{"aria-hidden":!0,className:"size-3 rounded-full border border-border",style:{backgroundColor:i},"data-testid":"theme-swatch"}):null,o.jsxs(mh,{"aria-label":"Theme",value:t.theme,onChange:a=>s.setTheme(a.target.value),className:"h-8 w-auto rounded-lg border-border bg-transparent pl-3 text-sm text-foreground",children:[Wd.filter(a=>a.group==="primary").map(a=>o.jsx("option",{value:a.value,children:a.label},a.value)),o.jsx("option",{disabled:!0,children:"──────"}),Wd.filter(a=>a.group==="variant").map(a=>o.jsx("option",{value:a.value,children:a.label},a.value))]})]})})}),o.jsxs(ot,{title:"Fonts",children:[o.jsx($e,{first:!0,title:"Interface font",hint:"Used across the app. Leave empty for the system default",children:o.jsx(Zr,{label:"Interface font family",value:t.uiFontFamily,placeholder:W0,width:"w-64 max-w-full",onCommit:a=>s.updatePreferences({uiFontFamily:a})})}),o.jsx(ef,{title:"Interface size",hint:"Used for navigation, controls, and labels",label:"Interface font size",value:t.uiFontSize,limits:zn.uiFontSize,onCommit:a=>s.updatePreferences({uiFontSize:a})}),o.jsx(ef,{title:"Content size",hint:"Used for chat text and rendered Markdown",label:"Content font size",value:t.contentFontSize,limits:zn.contentFontSize,onCommit:a=>s.updatePreferences({contentFontSize:a})}),o.jsx($e,{title:"Code font",hint:"Used in code, diffs, and the terminal output. Leave empty for the system default",children:o.jsx(Zr,{label:"Code font family",value:t.monoFontFamily,placeholder:Z0,width:"w-64 max-w-full",onCommit:a=>s.updatePreferences({monoFontFamily:a})})}),o.jsx(ef,{title:"Code size",hint:"Used for code, diffs, and terminal output",label:"Code font size",value:t.codeFontSize,limits:zn.codeFontSize,onCommit:a=>s.updatePreferences({codeFontSize:a})})]}),o.jsx(ot,{title:"Layout",children:o.jsx($e,{first:!0,title:"Content width",hint:"Max width of chat and Markdown files on wide screens",children:o.jsxs("span",{className:"flex items-center gap-2",children:[t.contentMaxWidth!==null?o.jsx(be,{size:"sm",variant:"ghost","aria-label":"Reset content width to default",onClick:()=>s.updatePreferences({contentMaxWidth:null}),children:"Reset"}):null,o.jsx(Zr,{label:"Content width in pixels",value:String(J0(t)),numeric:!0,limits:zn.contentMaxWidth,width:"w-20",onCommit:a=>s.updatePreferences({contentMaxWidth:Number(a)})}),o.jsx("span",{className:"text-xs",children:"px"})]})})}),o.jsx(ot,{title:"Syntax",children:o.jsx($e,{first:!0,title:"Highlight theme",hint:"Colors for code, independent of the app theme",children:o.jsx(La,{label:"Highlight theme",value:t.syntaxTheme,onChange:a=>s.updatePreferences({syntaxTheme:a}),options:I3})})}),o.jsx($4,{})]})}function Y4(){const s=Oe(),{preferences:t}=Me(),i=(u,d)=>s.updatePreferences({sidebar:{...t.sidebar,[u]:d}}),a=(u,d,h)=>{const m=[...t.sidebar[u]];[m[d],m[d+h]]=[m[d+h],m[d]],i(u,m)},l=(u,d,h)=>o.jsxs(ot,{title:d,children:[o.jsx("p",{className:"px-4 pt-3 text-xs text-muted-foreground",children:h}),t.sidebar[u].map((m,p,x)=>{const y=q4[m.id];return o.jsxs("div",{className:I("flex items-center gap-2 p-4",p>0&&"border-t border-border"),"data-testid":`sidebar-nav-item-${m.id}`,children:[o.jsx(y.icon,{"aria-hidden":!0,strokeWidth:1.75,className:"size-4 shrink-0 text-muted-foreground"}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:y.label}),o.jsx(be,{size:"icon",variant:"ghost",className:"size-7","aria-label":`Move ${y.label} up`,disabled:p===0,onClick:()=>a(u,p,-1),children:o.jsx(Dl,{"aria-hidden":!0})}),o.jsx(be,{size:"icon",variant:"ghost",className:"size-7","aria-label":`Move ${y.label} down`,disabled:p===x.length-1,onClick:()=>a(u,p,1),children:o.jsx(pS,{"aria-hidden":!0})}),o.jsx(e1,{checked:m.visible,"aria-label":y.label,onCheckedChange:v=>i(u,x.map(k=>k.id===m.id?{...k,visible:v}:k))})]},m.id)})]});return o.jsxs(o.Fragment,{children:[l("header","Header","Choose which items appear at the top of the sidebar and in what order"),l("footer","Footer","Choose which rows appear at the bottom of the sidebar and in what order. The host and Settings row always shows")]})}function V4(){const s=Oe(),{preferences:t}=Me();return o.jsxs(o.Fragment,{children:[o.jsxs(ot,{title:"Detail level",children:[o.jsx($e,{first:!0,title:"Chat display",hint:"How much of an agent's work the chat shows",children:o.jsx(La,{label:"Chat display",value:t.chatDisplay,onChange:i=>s.updatePreferences({chatDisplay:i}),options:[{value:"full",label:"Full"},{value:"collapseToolCalls",label:"Collapse tool calls"},{value:"collapseTurns",label:"Collapse turns"}]})}),o.jsx($e,{title:"Chat outline",hint:"Show an outline for jumping between prompts",children:o.jsx(e1,{checked:t.chatOutline,"aria-label":"Chat outline",onCheckedChange:i=>s.updatePreferences({chatOutline:i})})})]}),o.jsx(on,{what:"Always expand reasoning",why:"ALP's hosts do not send the agents' reasoning, so there is nothing to expand."})]})}function K4(){const s=Oe(),{preferences:t}=Me();return o.jsx(ot,{title:"Terminal",children:o.jsx($e,{first:!0,title:"Terminal scrollback",hint:"Lines kept in the built-in terminal buffer",children:o.jsx(Zr,{label:"Terminal scrollback lines",value:String(t.terminalScrollback),numeric:!0,limits:zn.terminalScrollback,onCommit:i=>s.updatePreferences({terminalScrollback:Number(i)})})})})}function F4(){return o.jsx(ot,{title:"Files",children:o.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground","data-testid":"file-panel-settings-empty",children:"File panels appear here when a plugin adds one"})})}function X4(){const s=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: light)").matches;return{userAgent:navigator.userAgent,language:navigator.language,online:navigator.onLine,secure:window.isSecureContext,viewport:`${window.innerWidth}×${window.innerHeight} @${window.devicePixelRatio}x`,colorScheme:s?"light":"dark"}}function P4(){const{connection:s,principal:t,preferences:i}=Me(),[a,l]=w.useState(null),[u,d]=w.useState("idle"),h=()=>{d("idle"),l({version:"0.0.1-beta.6",connection:s,principal:t,preferences:i,browser:X4(),now:new Date})},m=async()=>{if(a)try{await navigator.clipboard.writeText(w3(a)),d("copied")}catch{d("failed")}};return o.jsxs(o.Fragment,{children:[o.jsx(ot,{title:"Diagnostics",children:o.jsx($e,{first:!0,title:"App diagnostic",hint:"Collect connection, host and browser details. Providers, logs and the daemon itself: run alp doctor on the host.",children:o.jsx(be,{size:"sm",variant:"secondary","data-testid":"settings-diagnostics-run",onClick:h,children:a?"Refresh":"Run"})})}),a?o.jsxs(o.Fragment,{children:[o.jsxs(ot,{title:`Diagnostic, ${a.now?.toLocaleTimeString()??""}`,action:o.jsx(be,{size:"sm",variant:"ghost",className:"h-7 text-xs","data-testid":"settings-diagnostics-copy",onClick:()=>{m()},children:u==="copied"?"Copied":"Copy diagnostic"}),children:[u==="failed"?o.jsx("p",{role:"alert",className:"px-4 py-3 text-xs text-destructive",children:"Failed to copy diagnostic. Select the values below instead."}):null,o.jsx("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:"It holds no access token, prompts or files."})]}),P0(a).map(p=>o.jsx(ot,{title:p.title,children:p.rows.map(([x,y],v)=>o.jsx($e,{first:v===0,title:x,children:o.jsx("span",{className:"break-all font-mono text-xs","data-testid":`diagnostics-${x.toLowerCase().replace(/\W+/g,"-")}`,children:y})},x))},p.title))]}):null]})}function x1(s){return s.hostname??s.gateway.replace(/^https?:\/\//,"")}const _y=s=>s?.trim().replace(/^v/i,"")||null,Q4="https://github.com/phucanh08/alp/releases";function W4(){const{connection:s}=Me(),t=x1(s),i=_y(s.daemonVersion),a=s.phase!=="open",l=!!i&&i!==_y("0.0.1-beta.6");return o.jsxs(o.Fragment,{children:[o.jsxs(ot,{title:"About",children:[o.jsxs($e,{first:!0,title:"App version",hint:"This device",children:["v","0.0.1-beta.6"]}),o.jsx("a",{href:Q4,target:"_blank",rel:"noopener noreferrer","data-testid":"settings-whats-new",className:I("block hover:bg-sidebar-hover",yc),children:o.jsx($e,{title:"What's new",hint:"Release notes for every version",children:o.jsx(Wn,{"aria-hidden":!0,className:"size-4"})})})]}),o.jsx(ot,{title:"Connected hosts",children:o.jsx($e,{first:!0,title:t,hint:a?"Offline":l?"Version differs from this device":"ALP on the host, through the gateway (ALP JSON-RPC v1)",children:o.jsx("span",{"data-testid":"connected-host-version",children:i?`v${i}`:"unknown"})})})]})}function Z4(){const s=Oe(),{principal:t,connection:i,settings:a}=Me(),[l,u]=w.useState(!1);w.useEffect(()=>{s.loadSettings()},[s]);const d=["session.read","session.write","project.read","project.write","workspace.write","workspace.manage","files.read","library.write","terminal.exec"];return o.jsxs(o.Fragment,{children:[o.jsxs(ot,{title:"Host",children:[o.jsx($e,{first:!0,title:"Machine",hint:"The host's name, as it reports it.",children:i.hostname??"unknown"}),o.jsx($e,{title:"ALP",children:i.daemonVersion??"unknown"}),o.jsx($e,{title:"Gateway",children:o.jsx("span",{className:"break-all font-mono text-xs",children:i.gateway})}),o.jsx($e,{title:"Agents' language",hint:"Set on the host with alp; read only here.",children:a.status==="loading"?o.jsx(Kt,{label:"Loading…",className:"text-xs"}):a.language?`${a.language.applies}${a.language.language?"":" (default)"}`:"Not available"}),a.status==="error"?o.jsx("p",{role:"alert",className:"border-t border-border px-4 py-3 text-xs text-destructive",children:a.error?.message}):null]}),o.jsx(ot,{title:`Models new sessions can pick${a.models.length?` (${a.models.length})`:""}`,action:s.hasCapability("catalog.live")?o.jsx(be,{size:"sm",variant:"ghost",className:"h-7 text-xs","data-testid":"settings-models-refresh",disabled:l,onClick:()=>{u(!0),s.refreshModels().catch(()=>{}).finally(()=>u(!1))},children:l?"Refreshing…":"Refresh"}):void 0,children:a.models.length?o.jsx("ul",{className:"max-h-72 divide-y divide-border overflow-y-auto",children:a.models.map(h=>o.jsxs("li",{className:"flex items-center justify-between gap-3 px-4 py-2 text-sm",children:[o.jsx("span",{className:"min-w-0 truncate",children:h.label}),o.jsx("span",{className:"shrink-0 font-mono text-[length:calc(11px*var(--ui-scale))] text-muted-foreground",children:h.id})]},h.id))}):o.jsx($e,{first:!0,title:a.status==="ready"?"None listed":"Loading…"})}),o.jsxs(ot,{title:"Access token",children:[o.jsxs($e,{first:!0,title:"Name",children:[t?.label??"—"," ",o.jsxs("span",{className:"font-mono text-xs",children:["(",t?.id,")"]})]}),o.jsx($e,{title:"Allows",children:o.jsx("span",{className:"flex flex-wrap justify-end gap-1",children:d.map(h=>{const m=Te(t??void 0,h);return o.jsxs("span",{className:I("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs [&_svg]:size-3",m?"bg-primary/15 text-highlight":"bg-secondary text-muted-foreground"),children:[m?o.jsx(lc,{"aria-hidden":!0}):o.jsx(rc,{"aria-hidden":!0}),h]},h)})})}),o.jsx($e,{title:"Modes",hint:"Permissions a session may run with.",children:t?.modes?t.modes.map(Fl).join(", "):"Any"})]})]})}function J4(){const{principal:s,registry:t}=Me();return w.useCallback(i=>t.workspaces.filter(a=>!a.archivedAt&&(a.directory===i||s?.workspaceRoots?.some(l=>l.path===i&&l.canonical===a.directory))),[s,t])}function y1(s,t){if(!s)return"This host does not list its workspaces. Update ALP on the host.";if(!Te(t??void 0,"project.read"))return"Your access token cannot read the host's workspace list (it needs project.read)."}function eT(){const s=Oe(),{principal:t,workspace:i,registry:a,connection:l}=Me(),u=J4(),[d,h]=w.useState(""),m=t?.workspaces??[],p=y1(s.hasCapability("workspace.registry"),t);w.useEffect(()=>{p||s.refreshRegistry()},[s,p]);const x=p?[]:m.filter(k=>!u(k).length),y=Te(t??void 0,"workspace.write"),v=l.phase==="open";return o.jsxs(o.Fragment,{children:[o.jsx(ot,{title:"Projects this token opens",children:m.length?m.map((k,S)=>o.jsx($e,{first:S===0,title:Ot(k),hint:o.jsx("span",{className:"break-all font-mono",children:k}),children:o.jsxs("span",{className:"flex items-center gap-2",children:[p?null:o.jsx("span",{className:"text-xs","data-testid":"project-registered",children:u(k).length?"Registered":"Not registered"}),k===i?o.jsx("span",{className:"text-highlight","data-testid":"project-current",children:"Current"}):o.jsx(be,{size:"sm",variant:"secondary",onClick:()=>s.selectWorkspace(k),children:"Open"})]})},k)):o.jsx($e,{first:!0,title:"No projects",hint:"This access token grants no workspace."})}),p?null:o.jsxs(ot,{title:"Register a project",children:[o.jsx($e,{first:!0,title:"Granted directory",hint:y?"Registering adds a granted directory to the host's shared workspace list, so terminals, Git and worktrees can use it. It changes no files.":"Ask the host owner to add workspace.write to your credential to register projects.",children:y&&x.length?o.jsxs("form",{className:"flex flex-wrap items-center gap-2",onSubmit:k=>{k.preventDefault(),d&&s.registerProject(d).then(()=>h(""))},children:[o.jsx(La,{label:"Directory to register",value:d,onChange:h,options:[{value:"",label:"Choose a directory"},...x.map(k=>({value:k,label:Ot(k)}))]}),o.jsx(be,{size:"sm",type:"submit",disabled:!d||!v||a.loading,children:"Register"})]}):y?o.jsx("span",{className:"text-xs",children:"Every granted directory is registered"}):null}),a.error?o.jsx("p",{role:"alert",className:"border-t border-border px-4 py-3 text-xs text-destructive",children:a.error}):null]}),o.jsx(on,{what:"Granting or removing projects",why:"The access token decides which projects you can open. The host owner grants them with alp-gateway credential create --workspace."})]})}function tT({row:s,first:t,writable:i,online:a,busy:l}){const u=Oe(),{workspace:d,principal:h}=Me(),[m,p]=w.useState(!1),[x,y]=w.useState(s.title??""),v=s.title||Ot(s.directory),k=h?.workspaces?.some(A=>A===s.directory||h.workspaceRoots?.some(R=>R.path===A&&R.canonical===s.directory))||s.managedWorktree,S=h?.workspaceRoots?.find(A=>A.canonical===s.directory)?.path??s.directory,j=async()=>{await u.renameWorkspace(s.id,x)&&p(!1)};return o.jsxs("div",{className:I("flex flex-col gap-2 p-4",!t&&"border-t border-border"),"data-testid":"settings-workspace-row","data-workspace-id":s.id,children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[o.jsx("span",{className:"truncate",children:v}),s.pinnedAt?o.jsx(c0,{"aria-label":"Pinned",className:"size-3 shrink-0 text-muted-foreground"}):null,s.managedWorktree?o.jsx("span",{className:"rounded-full bg-secondary px-2 py-0.5 text-[length:calc(11px*var(--ui-scale))] text-muted-foreground",children:"Worktree"}):null]}),o.jsx("div",{className:"mt-1 break-all font-mono text-xs text-muted-foreground",children:s.directory}),s.branch!==void 0?o.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:s.branch||"Detached HEAD"}):null]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx(be,{size:"sm",variant:"ghost","aria-pressed":!!s.pinnedAt,disabled:!i||!a||l,onClick:()=>{u.pinWorkspace(s.id,!s.pinnedAt)},"aria-label":`${s.pinnedAt?"Unpin":"Pin"} workspace ${v}`,children:s.pinnedAt?"Unpin":"Pin"}),o.jsx(be,{size:"sm",variant:"ghost",disabled:!i||!a||l,onClick:()=>{y(s.title??""),p(A=>!A)},"aria-label":`Rename workspace ${v}`,children:"Rename"}),k?S===d?o.jsx("span",{className:"text-xs text-highlight",children:"Open"}):o.jsx(be,{size:"sm",variant:"secondary",onClick:()=>u.selectWorkspace(S),children:"Open"}):null]})]}),m?o.jsxs("form",{className:"flex flex-wrap items-center gap-2",onSubmit:A=>{A.preventDefault(),j()},children:[o.jsx(Qn,{"aria-label":`New name for ${v}`,value:x,maxLength:200,onChange:A=>y(A.target.value),placeholder:Ot(s.directory),className:"h-8 min-w-0 flex-1",autoFocus:!0}),o.jsx(be,{size:"sm",type:"submit",disabled:!a||l,children:"Save"}),o.jsx(be,{size:"sm",variant:"ghost",type:"button",onClick:()=>p(!1),children:"Cancel"})]}):null]})}function nT(){const s=Oe(),{principal:t,registry:i,connection:a}=Me(),l=y1(s.hasCapability("workspace.registry"),t);if(w.useEffect(()=>{l||s.refreshRegistry()},[s,l]),l)return o.jsx(on,{what:"Workspace settings",why:l});const u=Te(t??void 0,"workspace.write"),d=a.phase==="open",h=i.workspaces.filter(m=>!m.archivedAt).sort((m,p)=>+!!p.pinnedAt-+!!m.pinnedAt||(m.title||Ot(m.directory)).localeCompare(p.title||Ot(p.directory))||m.id.localeCompare(p.id));return o.jsxs(o.Fragment,{children:[o.jsxs(ot,{title:`Shared with every client of this host${h.length?` (${h.length})`:""}`,action:o.jsx(be,{size:"sm",variant:"ghost",className:"h-7 text-xs",disabled:i.loading||!d,onClick:()=>{s.refreshRegistry()},children:i.loading?"Refreshing…":"Refresh"}),children:[i.error?o.jsx("p",{role:"alert",className:"px-4 py-3 text-xs text-destructive",children:i.error}):null,h.length?h.map((m,p)=>o.jsx(tT,{row:m,first:p===0&&!i.error,writable:u,online:d,busy:!!i.loading},m.id)):o.jsx($e,{first:!i.error,title:i.loading?"Loading…":"No workspaces",hint:i.loading?void 0:"Register a granted directory under Host › Projects."})]}),u?null:o.jsx(ot,{children:o.jsx($e,{first:!0,title:"Read only",hint:"Pins and names are shared with every client of this host. Ask the host owner to add workspace.write to your credential to change them."})}),o.jsx(on,{what:"Archiving workspaces, labels and placement",why:"The host's owner manages them with alp on the host."})]})}function sT({onNavigate:s}){const t=Me(),i=t.connection.capabilities.includes("terminal"),a=Te(t.principal??void 0,"terminal.exec"),l=Xb(t),u=!l.ok&&l.reasons.includes("unregistered"),d=Te(t.principal??void 0,"workspace.write"),h=(m,p)=>o.jsxs("span",{className:I("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs [&_svg]:size-3",m?"bg-primary/15 text-highlight":"bg-secondary text-muted-foreground"),children:[m?o.jsx(lc,{"aria-hidden":!0}):o.jsx(rc,{"aria-hidden":!0}),p]});return o.jsxs(o.Fragment,{children:[o.jsxs(ot,{title:"Remote terminals",children:[o.jsx($e,{first:!0,title:"Host",hint:i?"The host's owner allowed remote terminals.":io.capability,children:o.jsx("span",{"data-testid":"terminals-host",children:h(i,i?"Allowed":"Not allowed")})}),o.jsx($e,{title:"Access token",hint:a?"Your access token may open terminals (terminal.exec).":io.permission,children:o.jsx("span",{"data-testid":"terminals-token",children:h(a,a?"terminal.exec":"No terminal.exec")})}),o.jsx($e,{title:"This workspace",hint:l.ok?"A terminal can open here from the + menu (Terminal).":[...l.messages,u?d?"Register it under Host › Projects; the terminal opens once it is in the list.":"Registering it needs workspace.write: ask the host owner to register it, or to add workspace.write to your credential.":""].filter(Boolean).join(" "),children:o.jsxs("span",{className:"flex items-center gap-2",children:[u&&d?o.jsx(be,{size:"sm",variant:"secondary","data-testid":"terminals-register",onClick:()=>s("projects"),children:"Register in Projects"}):null,o.jsx("span",{"data-testid":"terminals-workspace",children:h(l.ok,l.ok?"Ready":"Not available")})]})})]}),o.jsx(on,{what:"Changing the host's terminal switch",why:"Only the host's owner turns remote terminals on or off, on the host: alp terminal allow --yes, alp terminal deny, alp terminal status. Font and colors are under App › Terminal."})]})}function iT(){const s=Oe(),{connection:t}=Me(),i=t.gateway.startsWith("https:");return o.jsxs(ot,{title:"This connection",children:[o.jsx($e,{first:!0,title:"Gateway",children:o.jsx("span",{className:"break-all font-mono text-xs",children:t.gateway})}),o.jsx($e,{title:"State",children:t.phase==="open"?"Connected":t.phase==="reconnecting"?`Reconnecting (attempt ${t.attempt})`:t.phase}),o.jsx($e,{title:"Transport",hint:i?"TLS to the gateway.":"Plain HTTP, allowed only on this machine (loopback or an SSH tunnel).",children:i?"HTTPS / WSS":"Loopback HTTP / WS"}),o.jsx($e,{title:"Access token",hint:"Kept in this tab's memory only. Disconnecting forgets it.",children:o.jsx(be,{size:"sm",variant:"destructive",onClick:()=>s.disconnect(),children:"Disconnect"})})]})}function aT({kind:s,name:t,onClose:i}){const a=Oe(),[l,u]=w.useState({status:"loading"});w.useEffect(()=>{let h=!0;return u({status:"loading"}),a.getLibraryEntry(s,t).then(m=>{h&&u({status:"ready",entry:m})},m=>{h&&u({status:"error",error:Be(m).message})}),()=>{h=!1}},[a,s,t]);const d=l.entry;return o.jsx(ot,{title:t,action:o.jsx(be,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:i,children:"Close"}),children:o.jsxs("div",{"data-testid":"library-entry","aria-label":`${t} content`,role:"group",children:[l.status==="loading"?o.jsx("div",{className:"p-4",children:o.jsx(Kt,{label:"Loading…",className:"text-xs"})}):null,l.status==="error"?o.jsx("p",{role:"alert",className:"p-4 text-xs text-destructive",children:l.error}):null,d?o.jsxs(o.Fragment,{children:[o.jsx($e,{first:!0,title:"Source",hint:d.usedBy.length?`Used by ${d.usedBy.join(", ")}`:void 0,children:o.jsxs("span",{className:"text-xs",children:[d.source,d.overrides?` · overrides ${d.overrides}`:""]})}),d.librarySkills?.length?o.jsx($e,{title:"Skills the library gives it",children:d.librarySkills.join(", ")}):null,o4(d.content).map(h=>o.jsxs("div",{className:"border-t border-border p-4",children:[o.jsx("div",{className:"mb-2 font-mono text-xs text-muted-foreground",children:h.label}),o.jsx("pre",{className:"max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md bg-secondary p-3 font-mono text-xs text-foreground",children:h.text})]},h.key)),d.secrets.length?o.jsxs("p",{className:"border-t border-border px-4 py-3 text-xs text-muted-foreground",children:[d.secrets.length===1?"One value that can hold a secret is":`${d.secrets.length} values that can hold secrets are`," shown as ",Xl,": the gateway keeps them on the host."]}):null]}):null]})})}function rT({kind:s,selected:t,onChanged:i}){const a=Oe(),[l,u]=w.useState(""),[d,h]=w.useState(""),[m,p]=w.useState(""),[x,y]=w.useState(null),[v,k]=w.useState(!1),[S,j]=w.useState(!1),[A,R]=w.useState(null),[q,L]=w.useState(null);w.useEffect(()=>{let B=!0;return k(!1),R(null),L(null),h(""),t?a.getLibraryEntry(s,t).then(_=>{if(B){if(_.source!=="project"||_.overrides||_.secrets.length||_.revision===void 0){L("This entry holds configuration the host runs or values kept on the host, so it is read only here.");return}u(t),y(_.revision),p(JSON.stringify(_.content,null,2)),k(!0)}},_=>{B&&R(Be(_).message)}):(u(""),y(null),p(JSON.stringify(s==="skills"?{body:""}:{instructions:"",config:{description:""}},null,2)),k(!0)),()=>{B=!1}},[a,s,t]);const O=async B=>{j(!0),R(null);try{const _=B==="save"?{name:l,content:JSON.parse(m),revision:x}:B==="delete"?{name:l,revision:x}:{from:l,to:d},W=await a.writeLibrary(B,s,_);B==="save"&&y(W.revision),(B==="delete"||B==="rename")&&k(!1),i()}catch(_){R(Be(_).message)}finally{j(!1)}};return o.jsx(ot,{title:t?"Edit project instructions":"New project instructions",children:o.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents and skills only. Host entries, executable configuration, references and extra files cannot be changed here."}),A?o.jsx("p",{role:"alert",className:"text-xs text-destructive",children:A}):null,q?o.jsx("p",{role:"note",className:"text-xs text-muted-foreground",children:q}):null,v?o.jsxs(o.Fragment,{children:[o.jsx(Qn,{"aria-label":"Entry name",value:l,onChange:B=>u(B.target.value),disabled:S||!!t,placeholder:"Entry name"}),o.jsx("textarea",{"aria-label":"Instruction entry JSON",className:"min-h-48 rounded border border-border bg-background p-2 font-mono text-xs",value:m,onChange:B=>p(B.target.value),disabled:S}),o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsx(be,{size:"sm",disabled:S||!l.trim(),onClick:()=>{O("save")},children:"Save project entry"}),t?o.jsx(be,{size:"sm",variant:"secondary",disabled:S,onClick:()=>{O("delete")},children:"Delete project entry"}):null]}),t?o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsx(Qn,{"aria-label":"New entry name",value:d,onChange:B=>h(B.target.value),placeholder:"New name",disabled:S}),o.jsx(be,{size:"sm",variant:"secondary",disabled:S||!d.trim(),onClick:()=>{O("duplicate")},children:"Duplicate"}),o.jsx(be,{size:"sm",variant:"secondary",disabled:S||!d.trim(),onClick:()=>{O("rename")},children:"Rename"})]}):null]}):null]})})}function Ta({kind:s,noun:t}){const i=Oe(),{workspace:a}=Me(),[l,u]=w.useState({status:"loading",entries:[]}),[d,h]=w.useState(null),m=i.libraryBlock(),p=w.useCallback(()=>{let v=!0;return u(k=>({...k,status:"loading",error:void 0})),i.listLibrary(s).then(k=>{v&&u({status:"ready",entries:k})},k=>{v&&u({status:"error",entries:[],error:Be(k).message})}),()=>{v=!1}},[i,s]);if(w.useEffect(()=>m?void 0:p(),[p,m,a]),w.useEffect(()=>{h(null)},[s,a]),m)return o.jsx(on,{what:`Listing ${t}`,why:m});const x=d?l.entries.find(v=>v.name===d):void 0,y=x&&x.source==="project"&&!x.overrides?x.name:null;return o.jsxs(o.Fragment,{children:[o.jsxs(ot,{title:a?`As ${Ot(a)} sees them`:void 0,action:o.jsx(be,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>p(),children:"Refresh"}),children:[l.status==="loading"&&!l.entries.length?o.jsx("div",{className:"p-4",children:o.jsx(Kt,{label:"Loading…",className:"text-xs"})}):null,l.status==="error"?o.jsx("p",{role:"alert",className:"p-4 text-xs text-destructive",children:l.error}):null,l.status==="ready"&&!l.entries.length?o.jsx($e,{first:!0,title:`No ${t}`}):null,l.entries.map((v,k)=>o.jsx("button",{type:"button",onClick:()=>h(S=>S===v.name?null:v.name),"aria-expanded":d===v.name,"data-testid":`library-row-${v.name}`,className:I("block w-full text-left hover:bg-sidebar-hover",yc,d===v.name&&"bg-sidebar-hover"),children:o.jsx($e,{first:k===0,title:o.jsx("span",{className:"font-mono text-[length:calc(13px*var(--ui-scale))]",children:v.name}),hint:[v.description,v.usedBy?.length?`Used by ${v.usedBy.join(", ")}`:""].filter(Boolean).join(" · ")||void 0,children:o.jsxs("span",{className:"text-xs",children:[v.source,v.overrides?` · overrides ${v.overrides}`:""]})})},`${v.source}:${v.name}`))]}),i.libraryWriteBlock(s)?null:o.jsx(rT,{kind:s,selected:y,onChanged:()=>p()},`${s}:${a}:${y??"new"}`),d?o.jsx(aT,{kind:s,name:d,onClose:()=>h(null)}):null,i.libraryWriteBlock(s)?o.jsx(on,{what:`Editing ${t}`,why:`${i.libraryWriteBlock(s)} Open an entry to read it. Values that can hold secrets (environment, headers, MCP URLs and arguments, hook commands) show as ${Xl}. Changes configure commands the host runs, so edit them on the host with alp.`}):null]})}function oT({page:s,mobile:t,onNavigate:i}){switch(s){case"general":return o.jsx(I4,{mobile:t});case"appearance":return o.jsx(G4,{});case"sidebar":return o.jsx(Y4,{});case"chat":return o.jsx(V4,{});case"terminal":return o.jsx(K4,{});case"files":return o.jsx(F4,{});case"editor":return o.jsx(on,{what:"Editor",why:"This app opens a workspace's files read only (the Files panel); changing them is the agents' work, or yours on the host."});case"diagnostics":return o.jsx(P4,{});case"about":return o.jsx(W4,{});case"host":return o.jsx(Z4,{});case"projects":return o.jsx(eT,{});case"connections":return o.jsx(iT,{});case"alp-templates":return o.jsx(Ta,{kind:"teams",noun:"templates"});case"alp-agents":return o.jsx(Ta,{kind:"agents",noun:"agents"});case"alp-skills":return o.jsx(Ta,{kind:"skills",noun:"skills"});case"alp-hooks":return o.jsx(Ta,{kind:"hooks",noun:"hooks"});case"alp-mcp":return o.jsx(Ta,{kind:"mcp",noun:"MCP servers"});case"providers":return o.jsxs(o.Fragment,{children:[o.jsx(Ta,{kind:"providers",noun:"providers"}),o.jsx(on,{what:"Adding, testing or diagnosing providers",why:"Tests run commands on the host; they are not offered remotely."})]});case"pair-device":return o.jsx(on,{what:"Pairing a device",why:"This app is the remote client: open it on the other device and connect with an access token."});case"voice":return o.jsx(on,{what:"Voice",why:"Paseo's dictation and voice mode turn speech into prompts with a speech provider set up on the host. ALP's agents take text, and its hosts have no speech provider to set up."});case"metadata":return o.jsx(on,{what:"Metadata generation",why:"A host setting the gateway does not expose."});case"workspaces":return o.jsx(nT,{});case"usage":return o.jsx(on,{what:"Usage and limits",why:"Account-wide on the host; check with alp usage there."});case"terminals":return o.jsx(sT,{onNavigate:i});case"plugins":return o.jsx(on,{what:"Plugins",why:"Installing plugins changes the host; not offered remotely."})}}function Ly({page:s,label:t,icon:i,selected:a,onSelect:l,mobile:u}){return o.jsxs("button",{type:"button",onClick:()=>l(s),"aria-current":a?"page":void 0,"data-testid":`settings-${s}`,className:I("flex min-h-7 w-full items-center gap-2 rounded-lg px-2 py-1 text-left text-sm text-muted-foreground hover:bg-sidebar-hover hover:text-foreground",yc,a&&"bg-sidebar-hover text-foreground",u&&"min-h-10"),children:[o.jsx(i,{"aria-hidden":!0,strokeWidth:1.75,className:"size-4 shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),u?o.jsx(Wn,{"aria-hidden":!0,className:"size-4 text-extra-muted"}):null]})}function Oy({page:s,onSelect:t,mobile:i}){const{connection:a}=Me(),l=x1(a);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-2",children:[o.jsx("p",{className:"px-2 py-1 text-sm text-extra-muted",children:"App"}),p1.map(u=>o.jsx(Ly,{page:u.id,label:u.label,icon:u.icon,selected:s===u.id,onSelect:t,mobile:i},u.id))]}),o.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-2",children:[o.jsx("p",{className:"px-2 py-1 text-sm text-extra-muted",children:"Host"}),o.jsxs("div",{className:"flex min-h-7 items-center gap-2 px-2 py-1 text-sm",title:a.gateway,"data-testid":"settings-host-label",children:[o.jsx("span",{className:"flex size-4 items-center justify-center",children:o.jsx("span",{className:I("size-2 rounded-full",a.phase==="open"?"bg-dot-success":"bg-dot-warning")})}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-foreground",children:l})]}),g1.map(u=>o.jsx(Ly,{page:u.id,label:u.label,icon:u.icon,selected:s===u.id,onSelect:t,mobile:i},u.id))]})]})}function lT({onClose:s,mobile:t,initialPage:i}){const[a,l]=w.useState(i??(t?null:"general"));w.useEffect(()=>{const h=m=>{m.key==="Escape"&&!(m.target instanceof HTMLElement&&m.target.closest('[role="menu"],dialog'))&&s()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[s]);const u=(h,m)=>o.jsx("div",{className:"flex h-14 shrink-0 items-center gap-2 border-b border-border px-2 md:h-9",children:o.jsxs("button",{type:"button",onClick:m,className:I("flex min-h-7 items-center gap-2 rounded-lg px-2 py-1 text-sm text-muted-foreground hover:bg-sidebar-hover hover:text-foreground",yc),children:[o.jsx(eh,{"aria-hidden":!0,className:"size-4"}),h]})}),d=a?o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:o.jsxs("div",{className:"mx-auto w-full max-w-[720px] p-4 pt-14",children:[o.jsx("h2",{className:"mb-6 ml-1 text-[length:calc(26px*var(--ui-scale))] font-semibold text-foreground","data-testid":"settings-detail-header-title",children:D4[a]}),o.jsx(oT,{page:a,mobile:t,onNavigate:l})]})}):null;return t?o.jsxs("div",{role:"region","aria-label":"Settings",className:"flex h-dvh flex-col bg-background",children:[a?u("Settings",()=>l(null)):u("Back",s),a?d:o.jsx("nav",{"aria-label":"Settings",className:"min-h-0 flex-1 overflow-y-auto",children:o.jsx(Oy,{page:null,onSelect:l,mobile:!0})})]}):o.jsxs("div",{role:"region","aria-label":"Settings",className:"flex h-dvh overflow-hidden bg-background",children:[o.jsxs("nav",{"aria-label":"Settings",className:"flex w-[320px] shrink-0 flex-col border-r border-border bg-sidebar","data-testid":"settings-sidebar",children:[u("Back",s),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:o.jsx(Oy,{page:a,onSelect:l,mobile:!1})})]}),o.jsx("main",{className:"flex min-w-0 flex-1 flex-col","data-testid":"settings-detail-pane",children:d})]})}const cT=[{key:"list",label:"List"},{key:"board",label:"Board"},{key:"epics",label:"Epics"}],uT=["open","ready","closed","all"],Wl=(s,t)=>s.priority-t.priority||s.id.localeCompare(t.id),b1=(s,t)=>(t.closed?.at??t.updatedAt??"").localeCompare(s.closed?.at??s.updatedAt??"")||s.id.localeCompare(t.id);function bh(s){return s.status==="closed"?"closed":s.approvals?.length?"approve":s.status==="review"?"review":s.status==="in_progress"?"progress":s.type==="epic"?s.progress?.done?"progress":"ready":s.ready?"ready":"blocked"}const Dy={approve:"Needs approval",review:"In review",progress:"In progress",ready:"Ready",blocked:"Blocked",closed:"Closed"},v1=s=>!!s.ready&&s.status!=="closed";function dT(s){const t=s.filter(i=>i.status==="closed").length;return{open:s.length-t,ready:s.filter(v1).length,closed:t,all:s.length}}function fT(s,t,i=""){const a=i.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.filter(l=>{if(t==="open"&&l.status==="closed"||t==="ready"&&!v1(l)||t==="closed"&&l.status!=="closed")return!1;if(!a.length)return!0;const u=[l.id,l.title,l.type??"",l.assignee??"",...l.labels??[]].join(" ").toLowerCase();return a.every(d=>u.includes(d))})}const hT=[{key:"approve",title:"Waiting for your approval"},{key:"review",title:"In review"},{key:"progress",title:"In progress"},{key:"ready",title:"Ready"},{key:"waiting",title:"Blocked or waiting"},{key:"epics",title:"Epics"},{key:"closed",title:"Closed"}];function mT(s){return s.status==="closed"?"closed":s.approvals?.length?"approve":s.status==="review"?"review":s.status==="in_progress"?"progress":s.type==="epic"?"epics":s.ready?"ready":"waiting"}function pT(s){return hT.map(t=>{const i=s.filter(a=>mT(a)===t.key);return{...t,tasks:i.sort(t.key==="closed"?b1:Wl)}}).filter(t=>t.tasks.length)}const gT=[{key:"approve",title:"Needs approval"},{key:"blocked",title:"Blocked"},{key:"ready",title:"Ready"},{key:"progress",title:"In progress"},{key:"review",title:"In review"},{key:"closed",title:"Closed"}];function xT(s){return gT.map(t=>({...t,tasks:s.filter(i=>i.type!=="epic"&&bh(i)===t.key).sort(t.key==="closed"?b1:Wl)})).filter(t=>t.tasks.length||t.key==="blocked"||t.key==="ready"||t.key==="progress")}function yT(s,t){return t.filter(i=>i.type==="epic"||i.progress).sort(Wl).map(i=>{const a=s.filter(d=>d.parent===i.id).sort(Wl),l=i.progress?.done??a.filter(d=>d.status==="closed").length,u=i.progress?.total??a.length;return{epic:i,children:a,done:l,total:u,percent:u?Math.round(l/u*100):0}})}function w1(s,t=Date.now()){const i=s?Date.parse(s):NaN;if(Number.isNaN(i))return"";const a=Math.max(0,Math.floor((t-i)/6e4));return a<60?`${a}m`:a<1440?`${Math.floor(a/60)}h`:a<1440*14?`${Math.floor(a/1440)}d`:`${Math.floor(a/10080)}w`}const oo="main",k1=5,Gr=.1,zl=.15,qy=.4,bT=16,vT=1030,By=()=>({root:{kind:"pane",id:oo},focused:oo,assign:{},actives:{}});function Yt(s){return s.kind==="pane"?[s.id]:s.children.flatMap(Yt)}function j1(s){return s.kind==="pane"?1:1+Math.max(...s.children.map(j1))}const S1=s=>s.kind==="pane"?[s.id]:[s.id,...s.children.flatMap(S1)];function $y(s,t){const i=new Set(S1(s));let a=1;for(;i.has(`${t}-${a}`);)a+=1;return`${t}-${a}`}function Si(s,t){const i=Yt(s.root),a=s.assign[t];return a&&i.includes(a)?a:i.includes(s.focused)?s.focused:i[0]}function wT(s,t,i){const a=Object.fromEntries(Yt(s.root).map(l=>[l,[]]));for(const l of t)a[Si(s,i(l))].push(l);return a}function bc(s,t){if(s.kind==="pane")return s.id===t?[]:null;for(let i=0;i<s.children.length;i+=1){const a=bc(s.children[i],t);if(a)return[i,...a]}return null}const vh=(s,t)=>t.reduce((i,a)=>i.children[a],s);function Zl(s,t,i){if(!t.length)return i(s);const a=s,[l,...u]=t;return{...a,children:a.children.map((d,h)=>h===l?Zl(d,u,i):d)}}function Rf(s,{target:t,position:i,key:a}){const l=bc(s.root,t);if(!l)return null;const u=i==="left"||i==="right"?"horizontal":"vertical",d=i==="right"||i==="bottom",h=$y(s.root,"pane"),m={kind:"pane",id:h},p=l.slice(0,-1),x=l.length?vh(s.root,p):null,y=l[l.length-1]??0;let v;if(x&&x.direction===u){const k=x.sizes[y]??0,S=d?y+1:y,j=x.sizes.slice();j.splice(S,0,k/2),j[y+(d?0:1)]=k/2;const A=x.children.slice();A.splice(S,0,m),v=Zl(s.root,p,()=>({...x,children:A,sizes:j}))}else{const k=$y(s.root,"group");v=Zl(s.root,l,S=>({kind:"group",id:k,direction:u,children:d?[S,m]:[m,S],sizes:[.5,.5]}))}return j1(v)>k1?null:{...s,root:v,focused:h,assign:a?{...s.assign,[a]:h}:s.assign}}function N1(s,t){const i=bc(s,t);if(!i||!i.length)return null;for(let a=i.length-1;a>=0;a-=1){const l=vh(s,i.slice(0,a)),u=i[a];for(let d=u-1;d>=0;d-=1){const h=Yt(l.children[d]);if(h.length)return h[h.length-1]}for(let d=u+1;d<l.children.length;d+=1){const h=Yt(l.children[d]);if(h.length)return h[0]}}return null}function Uy(s,t){const i=bc(s.root,t);if(!i||!i.length)return null;const a=N1(s.root,t),l=i.slice(0,-1),u=vh(s.root,l),d=i[i.length-1],h=u.children.filter((S,j)=>j!==d),m=u.sizes.filter((S,j)=>j!==d),p=m.reduce((S,j)=>S+j,0)||1,x=Zl(s.root,l,()=>h.length===1?h[0]:{...u,children:h,sizes:m.map(S=>S/p)}),y=Object.fromEntries(Object.entries(s.assign).filter(([,S])=>S!==t)),v=Object.fromEntries(Object.entries(s.actives).filter(([S])=>S!==t)),k=s.focused===t?a??Yt(x)[0]:s.focused;return{root:x,focused:k,assign:y,actives:v}}function kT(s,t,i){return Yt(s.root).includes(i)?{...s,focused:i,assign:{...s.assign,[t]:i},actives:{...s.actives,[i]:t}}:s}function T1(s){const t=s.length;if(!t)return[];if(t===1)return[1];if(t*Gr>1)return s.map(()=>1/t);const i=s.map(m=>Number.isFinite(m)&&m>0?m:0),a=i.reduce((m,p)=>m+p,0),l=a>0?i.map(m=>m/a):i.map(()=>1/t),u=l.map(()=>0),d=new Set(l.map((m,p)=>p));let h=1;for(;d.size;){let m=0;for(const x of d)m+=l[x];if(m<=0){for(const x of d)u[x]=h/d.size;break}const p=[...d].filter(x=>l[x]/m*h<Gr);if(!p.length){for(const x of d)u[x]=l[x]/m*h;break}for(const x of p)u[x]=Gr,d.delete(x),h-=Gr}return u}function jT(s,t,i){const a=l=>l.kind==="pane"?l:l.id===t&&i.length===l.children.length?{...l,sizes:T1(i)}:{...l,children:l.children.map(a)};return{...s,root:a(s.root)}}function _f(s,t={left:0,top:0,right:1,bottom:1}){if(s.kind==="pane")return[{id:s.id,...t}];const i=[];let a=0;for(let l=0;l<s.children.length;l+=1){const u=s.sizes[l]??0;if(s.direction==="horizontal"){const d=t.right-t.left;i.push(..._f(s.children[l],{...t,left:t.left+d*a,right:t.left+d*(a+u)}))}else{const d=t.bottom-t.top;i.push(..._f(s.children[l],{...t,top:t.top+d*a,bottom:t.top+d*(a+u)}))}a+=u}return i}function Hy(s,t,i){const a=_f(s),l=a.find(p=>p.id===t);if(!l)return null;const u=i==="left"||i==="right",d=(p,x,y,v)=>x<y?y-x:v<p?p-v:0,h=(p,x,y,v)=>Math.max(0,Math.min(x,v)-Math.max(p,y)),m=a.filter(p=>p.id!==t).map(p=>{const x=i==="left"?l.left-p.right:i==="right"?p.left-l.right:i==="up"?l.top-p.bottom:p.top-l.bottom;if(x<-1e-6)return null;const[y,v,k,S]=u?[p.top,p.bottom,l.top,l.bottom]:[p.left,p.right,l.left,l.right],j=Math.abs(u?(p.top+p.bottom)/2-(l.top+l.bottom)/2:(p.left+p.right)/2-(l.left+l.right)/2);return{id:p.id,primary:x,secondary:d(y,v,k,S),overlap:h(y,v,k,S),center:j}}).filter(p=>!!p);return m.sort((p,x)=>p.primary-x.primary||p.secondary-x.secondary||x.overlap-p.overlap||p.center-x.center||String(p?.id).localeCompare(String(x?.id))),m[0]?.id??null}function ST({width:s,height:t,x:i,y:a}){const l=s*((1-qy)/2),u=t*((1-qy)/2);if(i>=l&&i<=s-l&&a>=u&&a<=t-u)return"center";if(i<=s*zl)return"left";if(i>=s-s*zl)return"right";if(a<=t*zl)return"top";if(a>=t-t*zl)return"bottom";const d=[["left",i],["right",s-i],["top",a],["bottom",t-a]];return d.sort((h,m)=>h[1]-m[1]),d[0][0]}const Lf=s=>!!s&&typeof s=="object"&&!Array.isArray(s),Bl=s=>typeof s=="string"&&!!s.trim()&&s.length<=vT;function A1(s,t,i){if(!Lf(s)||i>k1)return null;const a=s;if(!Bl(a.id)||t.has(a.id))return null;if(t.add(a.id),a.kind==="pane")return{kind:"pane",id:a.id};if(a.kind!=="group"||a.direction!=="horizontal"&&a.direction!=="vertical"||!Array.isArray(a.children)||!Array.isArray(a.sizes)||a.children.length!==a.sizes.length||a.children.length<2)return null;const l=[];for(const d of a.children){const h=A1(d,t,i+1);if(!h)return null;l.push(h)}const u=a.sizes.map(d=>typeof d=="number"&&Number.isFinite(d)&&d>0?d:0);return{kind:"group",id:a.id,direction:a.direction,children:l,sizes:T1(u)}}function NT(s){if(!Lf(s))return;const t=s,i=A1(t.root,new Set,1);if(!i||i.kind==="pane")return;const a=Yt(i);if(a.length>bT)return;const l=(m,p)=>{const x={};if(!Lf(m))return x;for(const[y,v]of Object.entries(m).slice(0,100))Bl(y)&&Bl(v)&&p(y,v)&&(x[y]=v);return x},u=l(t.assign,(m,p)=>a.includes(p)),d=l(t.actives,m=>a.includes(m)),h=Bl(t.focused)&&a.includes(t.focused)?t.focused:a[0];return{root:i,focused:h,assign:u,actives:d}}const C1="alp-web:layout",Of=1,TT=["changes","terminal","diff","files","agents","tasks"],E1=Object.freeze({initial:320,min:200,max:600}),M1=Object.freeze({initial:320,min:240,max:720}),AT=20,CT=50,z1=300,R1=1024,ET=R1+5,Df=s=>!!s&&typeof s=="object"&&!Array.isArray(s),_1=s=>typeof s=="string"&&s.trim()&&s.length<=z1?s:void 0,MT=s=>typeof s=="string"&&s.trim()&&s.length<=R1?s:void 0,Iy=s=>typeof s=="string"&&s.trim()&&s.length<=ET?s:void 0,Hr=(s,t=()=>!0,i=_1)=>Array.isArray(s)?[...new Set(s.map(i).filter(a=>!!a&&t(a)))].slice(0,CT):[];function Jl(s,t){if(!(typeof s!="number"||!Number.isFinite(s)))return Math.round(Math.min(t.max,Math.max(t.min,s)))}const zT=(s,t)=>`${s}
|
|
30
|
+
${t}`;function RT(s){if(!Df(s))return;const t=s,i=_1(t.session),a=Iy(t.active),l=NT(t.panes),u=Hr(t.files,d=>Qs(d)===d&&!Bi(d),MT);return{...i?{session:i}:{},agents:i?Hr(t.agents,d=>d!==i):[],tasks:Hr(t.tasks),panels:Hr(t.panels,d=>TT.includes(d)),order:Hr(t.order,void 0,Iy),...u.length?{files:u}:{},...a?{active:a}:{},...l?{panes:l}:{},at:typeof t.at=="number"&&Number.isFinite(t.at)?t.at:0}}function L1(s){const t={workspaces:{}};if(typeof s!="string"||!s)return t;let i;try{i=JSON.parse(s)}catch{return t}if(!Df(i)||i.v!==Of)return t;const a={};if(Df(i.workspaces)){const d=Object.entries(i.workspaces).map(([h,m])=>[h,RT(m)]).filter(([h,m])=>h.length<=2*z1&&m).sort((h,m)=>(m[1]?.at??0)-(h[1]?.at??0)).slice(0,AT);for(const[h,m]of d)m&&(a[h]=m)}const l=Jl(i.sidebarWidth,E1),u=Jl(i.dockWidth,M1);return{...l?{sidebarWidth:l}:{},...u?{dockWidth:u}:{},workspaces:a}}function _T(s){const t=L1(JSON.stringify({...s,v:Of}));return JSON.stringify({v:Of,...t})}function wh(s){if(!s)return{workspaces:{}};try{return L1(s.getItem(C1))}catch{return{workspaces:{}}}}function O1(s,t){if(!s)return!1;try{return s.setItem(C1,_T(t(wh(s)))),!0}catch{return!1}}const LT=(s,t)=>s.workspaces[t];function D1(s,t,i){const a=new Map(i.map((l,u)=>[l,u]));return s.map((l,u)=>({tab:l,index:u,rank:a.get(t(l))??i.length+u})).sort((l,u)=>l.rank-u.rank).map(l=>l.tab)}function qf(s,t,i){if(s.indexOf(t)<0)return s;const l=s.filter(d=>d!==t),u=Math.max(0,Math.min(l.length,i));return[...l.slice(0,u),t,...l.slice(u)]}function ec(){try{return window.localStorage}catch{return}}const yn=s=>`${s.kind}:${s.id}`;function kh(s,t,i,a){const l=s.findIndex(d=>yn(d)===yn(t));if(l<0)return[];let u=i==="left"?s.slice(0,l):i==="right"?s.slice(l+1):s.filter((d,h)=>h!==l);return t.kind==="agent"&&t.id!==a&&(u=u.filter(d=>!(d.kind==="agent"&&d.id===a))),u}function Gy({tabs:s,active:t,selected:i,closing:a,keep:l}){const u=new Set(a.map(yn)),d=a.some(x=>x.kind==="agent"&&x.id===i),h=new Set(s.filter(x=>!u.has(yn(x))&&!(d&&x.kind==="agent")).map(yn)),m=!!t&&u.has(yn(t));let p=t&&!m?t:null;if(t&&m)if(l&&h.has(yn(l)))p=l;else{const x=s.findIndex(y=>yn(y)===yn(t));p=s.slice(x+1).find(y=>h.has(yn(y)))??s.slice(0,x).reverse().find(y=>h.has(yn(y)))??null}else p&&!h.has(yn(p))&&(p=s.find(x=>h.has(yn(x)))??null);return{closingRoot:d,next:p}}const tf=s=>s.kind==="draft"||s.kind==="launcher",nf={kind:"draft",id:"new"},qe=s=>`${s.kind}:${s.id}`,q1=w.createContext(null);function kt(){const s=w.useContext(q1);if(!s)throw new Error("useTabs outside TabsProvider");return s}const sf=s=>{if(!s)return null;const t=s.indexOf(":"),i=s.slice(0,t),a=s.slice(t+1);return a?i==="agent"||i==="task"?{kind:i,id:a}:i==="file"?Qs(a)===a&&!Bi(a)?{kind:i,id:a}:null:i==="panel"?{kind:i,id:a}:null:null};function OT({children:s}){const t=Oe(),{selected:i,focus:a,workspace:l,connection:u,sessions:d,tree:h}=Me(),[m,p]=w.useState([]),[x,y]=w.useState([]),[v,k]=w.useState([]),[S,j]=w.useState({}),[A,R]=w.useState([]),[q,L]=w.useState(!1),[O,B]=w.useState([]),[_,W]=w.useState(null),[E,V]=w.useState([]),[U,de]=w.useState(By),[J,me]=w.useState(null),se=l?zT(u.gateway,l):null,[fe,H]=w.useState(null),P=w.useRef(null),[oe,xe]=w.useState(!1),T=w.useCallback(()=>{P.current=null,xe(!1)},[]),z=()=>{const C=P.current;return new Set(C?[C.session,...C.agents].map(G=>`agent:${G}`):[])},F=w.useRef(null),Z=w.useCallback(C=>{const G=t.getState().focus;t.focusSession(C);const ce=t.getState().focus;ce!==G&&(F.current=ce)},[t]);w.useEffect(()=>{const C=P.current;C&&(i?C.session!==i:C.attempted)&&T(),p(i?[i]:[]),W(G=>{if(G?.kind==="draft"&&t.getState().busy.create)return G;if(i&&C?.session===i&&C.active){const ce=sf(C.active);if(ce&&ce.kind!=="agent")return ce}return i&&C?.session===i&&!C.active&&G?.kind==="launcher"?G:i?{kind:"agent",id:i}:G&&G.kind!=="agent"?G:null})},[i,t,T]),w.useEffect(()=>{const C=se?LT(wh(ec()),se):void 0;y(C?.tasks??[]),k(C?.files??[]),j({}),R(C?.panels??[]),V(C?.order??[]);const G=C?.panes??By(),ce=new Set(Object.values(G.assign)),ue=Yt(G.root).length>1?Yt(G.root).filter(Ze=>!ce.has(Ze)).map((Ze,St)=>({pane:Ze,id:`n${St+1}`})):[];de(ue.length?{...G,assign:{...G.assign,...Object.fromEntries(ue.map(Ze=>[`launcher:${Ze.id}`,Ze.pane]))}}:G),me(null),L(!1),B(ue.map(Ze=>Ze.id));const pe=sf(C?.active);P.current=C?.session?{session:C.session,agents:C.agents,active:C.active}:null,xe(!!C?.session);const He=ue.find(Ze=>Ze.pane===G.focused);W(Ze=>pe&&pe.kind!=="agent"&&(pe.kind==="task"?C?.tasks.includes(pe.id):pe.kind==="file"?C?.files?.includes(pe.id):C?.panels.includes(pe.id))?pe:(Ze&&Ze.kind!=="agent"?null:Ze)??(He?{kind:"launcher",id:He.id}:null)),H(se)},[se]),w.useEffect(()=>{const C=P.current;!C||C.attempted||i||d.status!=="ready"||(_?.kind!=="draft"&&d.list.some(G=>G.id===C.session)?(C.attempted=!0,t.selectSession(C.session)):T())},[d,i,_,t,T]),w.useEffect(()=>{const C=P.current;if(!C||!h||h.rootId!==i||C.session!==i)return;if(h.status==="gone"||h.status==="error"){T();return}if(h.status!=="attached")return;T();const G=C.agents.filter(ue=>h.projection.sessions[ue]);if(!G.length)return;p(ue=>[...ue,...G.filter(pe=>!ue.includes(pe))]);const ce=sf(C.active);ce?.kind==="agent"&&G.includes(ce.id)&&(t.focusSession(ce.id),W(ce))},[h,i,t,T]),w.useEffect(()=>{if(!(!a||!i)){if(p(C=>C.includes(a)?C:[...C,a]),F.current===a){F.current=null;return}W(C=>C?.kind==="draft"&&t.getState().busy.create||C&&P.current?.session===i&&a===i&&C.kind!=="agent"?C:{kind:"agent",id:a})}},[a,i,t]);const ie=w.useMemo(()=>D1([...m.map(C=>({kind:"agent",id:C})),...x.map(C=>({kind:"task",id:C})),...v.map(C=>({kind:"file",id:C})),...A.map(C=>({kind:"panel",id:C})),...q?[nf]:[],...O.map(C=>({kind:"launcher",id:C}))],qe,E),[m,x,v,A,q,O,E]),re=w.useMemo(()=>Yt(U.root),[U.root]),le=w.useMemo(()=>wT(U,ie,qe),[U,ie]),ve=_?Si(U,qe(_)):re.includes(U.focused)?U.focused:re[0],Re=le[ve]??[],Ne=w.useCallback(C=>{if(C===ve)return _;const G=le[C]??[],ce=U.actives[C];return G.find(ue=>qe(ue)===ce)??G[0]??null},[ve,_,le,U.actives]);w.useEffect(()=>{fe===se&&de(C=>{const G=new Set(ie.map(qe)),ce=z(),ue=Yt(C.root);let pe=!1;const He={};for(const[Ke,lt]of Object.entries(C.assign))(G.has(Ke)||ce.has(Ke))&&ue.includes(lt)?He[Ke]=lt:pe=!0;for(const Ke of G)He[Ke]||(He[Ke]=ve,pe=!0);let Ze=C.actives;const St=_?qe(_):null;return St&&G.has(St)&&Ze[ve]!==St&&(Ze={...Ze,[ve]:St},pe=!0),C.focused!==ve&&(pe=!0),pe?{...C,focused:ve,assign:He,actives:Ze}:C})},[fe,se,ie,_,ve]),w.useEffect(()=>{if(fe!==se||oe||re.length<2)return;const C=re.filter(G=>!(le[G]??[]).length);C.length&&de(G=>{let ce=G;for(const ue of C)ce=Uy(ce,ue)??ce;return ce})},[fe,se,oe,re,le]),w.useEffect(()=>{J&&(!re.includes(J)||re.length<2)&&me(null)},[J,re]),w.useEffect(()=>{if(!se||fe!==se)return;const C=i??P.current?.session,G=ie.filter(pe=>!tf(pe)).map(qe),ce=new Set([...G,...z()]),ue=re.length>1?{root:U.root,focused:ve,assign:Object.fromEntries(Object.entries(U.assign).filter(([pe])=>ce.has(pe))),actives:Object.fromEntries(Object.entries(U.actives).filter(([,pe])=>ce.has(pe)))}:void 0;O1(ec(),pe=>({...pe,workspaces:{...pe.workspaces,[se]:{...C?{session:C}:{},agents:C?[...m.filter(He=>He!==C),...P.current?.agents??[]]:[],tasks:x,files:v,panels:A,order:G,..._&&!tf(_)?{active:qe(_)}:P.current?.active?{active:P.current.active}:{},...ue?{panes:ue}:{},at:Date.now()}}}))},[se,fe,i,m,x,v,A,ie,_,re,U,ve]);const et=C=>{const G=P.current;G&&!tf(C)&&(G.active=qe(C))},Ue=w.useCallback(C=>{C.kind==="agent"&&t.focusSession(C.id),et(C),W(C)},[t]),Qe=w.useCallback((C,G)=>{const ce=!!t.getState().busy.create;let ue=C;if(ce&&ue.some(Ke=>Ke.kind==="draft")&&(t.notify("info","The new session is still starting. Its tab opens once it is ready."),ue=ue.filter(Ke=>Ke.kind!=="draft")),!ue.length)return;const pe=new Set(ue.map(qe));let He=!1;const Ze={};for(const Ke of re){const lt=le[Ke]??[],ni=Ke===ve?_:Ne(Ke),si=Gy({tabs:lt,active:ni,selected:i,closing:ue,keep:G&<.some(un=>qe(un)===qe(G))?G:void 0});He||=si.closingRoot,Ze[Ke]=si.next}let St=Ze[ve]??null;if(!St&&re.length>1){const Ke=N1(U.root,ve);St=(Ke?Ze[Ke]:null)??re.map(lt=>Ze[lt]).find(Boolean)??null}T(),p(Ke=>He?[]:Ke.filter(lt=>!pe.has(`agent:${lt}`))),y(Ke=>Ke.filter(lt=>!pe.has(`task:${lt}`))),k(Ke=>Ke.filter(lt=>!pe.has(`file:${lt}`))),R(Ke=>Ke.filter(lt=>!pe.has(`panel:${lt}`))),pe.has("panel:terminal")&&t.closeTerminal(),pe.has(qe(nf))&&L(!1),B(Ke=>Ke.filter(lt=>!pe.has(`launcher:${lt}`))),de(Ke=>({...Ke,actives:Object.fromEntries(re.flatMap(lt=>Ze[lt]?[[lt,qe(Ze[lt])]]:[]))})),He?t.selectSession(null):St?.kind==="agent"?t.focusSession(St.id):a&&pe.has(`agent:${a}`)&&i&&Z(i),W(St)},[re,le,ve,_,Ne,U.root,i,a,t,Z,T]),We=w.useCallback(C=>Qe([C]),[Qe]),ye=w.useCallback((C,G,ce)=>{const ue=kh(ce??le[Si(U,qe(C))]??[],C,G,i);ue.length&&Qe(ue,C)},[le,U,i,Qe]),ge=w.useCallback((C,G,ce)=>{const ue=qe(C),pe=ie.map(qe),He=new Set((le[G]??[]).map(qe));He.delete(ue);const Ze=qf([...pe.filter(un=>He.has(un)),ue],ue,ce),St=pe.filter(un=>un!==ue),Ke=St.flatMap((un,Hn)=>He.has(un)?[Hn]:[]),lt=Ke.length?Ke[Ke.length-1]+1:St.length,ni=[...St.slice(0,lt),ue,...St.slice(lt)];let si=0;return ni.map(un=>un===ue||He.has(un)?Ze[si++]:un)},[ie,le]),Ce=w.useCallback((C,G,ce)=>{V(ce?qf(ie.map(qe),qe(C),G):ge(C,Si(U,qe(C)),G))},[ie,ge,U]),je=w.useCallback(C=>{if(C===ve||!re.includes(C))return;const G=Ne(C);G?Ue(G):(de(ce=>({...ce,focused:C})),W(null))},[ve,re,Ne,Ue]),Ut=w.useCallback((C,G)=>{const ce=Si(C,qe(G)),ue=Ne(ce);if(!ue||qe(ue)!==qe(G))return C;const pe=Gy({tabs:le[ce]??[],active:G,selected:null,closing:[G]}).next,He={...C.actives};return pe?He[ce]=qe(pe):delete He[ce],{...C,actives:He}},[Ne,le]),ln=w.useCallback((C,G,ce)=>{if(!re.includes(G))return;const ue=(le[G]??[]).filter(pe=>qe(pe)!==qe(C));V(ge(C,G,ce??ue.length)),de(pe=>kT(Ut(pe,C),qe(C),G)),Ue(C)},[re,le,ge,Ut,Ue]),ze=w.useCallback((C,G,ce)=>{const ue=Si(U,qe(C));if(ue===G&&(le[ue]??[]).length<2)return;const pe=Rf(Ut(U,C),{target:G,position:ce,key:qe(C)});pe&&(de(pe),Ue(C))},[U,le,Ut,Ue]),it=!!l,gt=w.useCallback((C,G=ve)=>{if(!it)return;const ce=new Set(O);let ue=1;for(;ce.has(`n${ue}`);)ue+=1;const pe={kind:"launcher",id:`n${ue}`},He=Rf(U,{target:G,position:C,key:qe(pe)});He&&(de(He),B(Ze=>[...Ze,pe.id]),W(pe))},[it,O,U,ve]),At=w.useCallback((C,G)=>{const ce=`launcher:${C}`,ue=Si(U,ce);de(pe=>({...pe,focused:ue})),B(pe=>pe.filter(He=>He!==C)),G()},[U]),$n=w.useCallback(C=>{if(re.length<2||!re.includes(C))return;const G=le[C]??[];G.length?Qe(G):de(ce=>Uy(ce,C)??ce)},[re,le,Qe]),_n=w.useCallback(C=>{const G=Hy(U.root,ve,C);return G?(je(G),!0):!1},[U.root,ve,je]),cn=w.useCallback(C=>{const G=Hy(U.root,ve,C);return!G||!_?!1:(ln(_,G),!0)},[U.root,ve,_,ln]),xt=w.useCallback((C,G)=>de(ce=>jT(ce,C,G)),[]),zt=w.useCallback(C=>me(G=>G===C?null:C),[]),Ct=w.useCallback(C=>{y(G=>G.includes(C)?G:[...G,C]),et({kind:"task",id:C}),W({kind:"task",id:C})},[]),Un=w.useCallback((C,G)=>{const ce=Qs(C);!ce||Bi(ce)||(k(ue=>ue.includes(ce)?ue:[...ue,ce]),j(ue=>({...ue,[ce]:{...G?{line:G}:{},nonce:(ue[ce]?.nonce??0)+1}})),et({kind:"file",id:ce}),W({kind:"file",id:ce}))},[]),vn=w.useCallback(C=>S[C],[S]),he=w.useCallback(C=>{t.focusSession(C),p(G=>G.includes(C)?G:[...G,C]),et({kind:"agent",id:C}),W({kind:"agent",id:C})},[t]),Ae=w.useCallback(C=>{R(G=>G.includes(C)?G:[...G,C]),et({kind:"panel",id:C}),W({kind:"panel",id:C})},[]),ht=w.useCallback(()=>{L(!0),W(nf)},[]),jt=w.useCallback(C=>{L(!1),W(G=>G?.kind!=="draft"?G:t.getState().selected===C?{kind:"agent",id:C}:null)},[t]),bt=w.useMemo(()=>({tabs:ie,row:Re,active:_,panes:U,byPane:le,focusedPane:ve,activeOf:Ne,focusPane:je,splitEmpty:gt,canSplitEmpty:it,launch:At,splitWith:ze,moveTabToPane:ln,closePane:$n,focusAdjacent:_n,moveTabAdjacent:cn,resize:xt,maximized:J,toggleMaximized:zt,activate:Ue,close:We,closeOthers:ye,move:Ce,openTask:Ct,openFile:Un,fileTarget:vn,openAgent:he,openPanel:Ae,openDraft:ht,finishDraft:jt}),[ie,Re,_,U,le,ve,Ne,je,gt,it,At,ze,ln,$n,_n,cn,xt,J,zt,Ue,We,ye,Ce,Ct,Un,vn,he,Ae,ht,jt]);return o.jsx(q1.Provider,{value:bt,children:s})}const Xs="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",DT=I("flex w-full min-w-0 items-start gap-2 rounded-lg py-2 pl-2 pr-3 text-left",Xs),qT=[0,1,2,3,4],BT={list:$S,board:TS,epics:ch},$T={approve:o0,review:lo,progress:uc,ready:lc,waiting:n0,epics:ch,closed:e0},UT={approve:"bg-dot-warning",review:"bg-dot-running",progress:"border-2 border-dot-warning",ready:"bg-dot-success",blocked:"bg-dot-danger",closed:"border-2 border-border"},HT={blocked:"border-l-dot-danger",ready:"border-l-dot-success",approve:"border-l-dot-warning"};function jh({state:s}){return o.jsx("span",{role:"img","aria-label":Dy[s],title:Dy[s],className:I("inline-block size-[9px] shrink-0 rounded-full",UT[s])})}function B1({value:s}){return o.jsxs("span",{className:I("shrink-0 rounded border px-1 text-[length:calc(10.5px*var(--ui-scale))] font-semibold tabular-nums leading-4",s===0?"border-destructive text-destructive":s===1?"border-warning text-warning":"border-border text-muted-foreground"),children:["P",s]})}function $1({onPicked:s,onOpen:t,current:i}){const a=Oe(),{openTask:l,active:u}=kt(),d=E=>{(t??l)(E),s?.()},{tasks:h,principal:m,workspace:p}=Me(),[x,y]=w.useState(""),[v,k]=w.useState(2),[S,j]=w.useState({view:"list",filter:"open",query:""}),A=a.tasksBlock(),R=Te(m??void 0,"project.write");w.useEffect(()=>(a.setTasksVisible(!0),()=>a.setTasksVisible(!1)),[a]);const q=h.rows,L=w.useMemo(()=>dT(q),[q]),O=w.useMemo(()=>fT(q,S.filter,S.query),[q,S.filter,S.query]);if(!p)return o.jsx("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:"Choose a workspace to see its tasks."});if(A)return o.jsxs("p",{className:"flex items-start gap-2 px-4 py-6 text-sm text-muted-foreground",children:[o.jsx(qa,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0"}),A]});const B=E=>t?i===E:u?.kind==="task"&&u.id===E,_=E=>j(V=>({...V,view:E})),W=h.status==="ready"||q.length>0;return o.jsxs("div",{className:"@container flex min-h-0 flex-col gap-2 p-2","data-testid":"task-board","data-view":S.view,children:[o.jsxs("div",{className:"flex items-center gap-1.5 px-1 pt-1",children:[o.jsx("h2",{className:"text-sm font-semibold",children:"Tasks"}),W?o.jsxs("span",{className:"text-xs text-muted-foreground","data-testid":"tasks-open-count",children:[L.open," open"]}):null,o.jsx("span",{className:"flex-1"}),o.jsx("div",{role:"group","aria-label":"Task view",className:"flex rounded-lg border border-border bg-card p-0.5",children:cT.map(E=>{const V=BT[E.key],U=S.view===E.key;return o.jsxs("button",{type:"button","aria-pressed":U,title:E.label,onClick:()=>_(E.key),className:I("flex h-6 items-center gap-1 rounded-md px-1.5 text-xs",U?"bg-secondary font-semibold text-foreground":"text-muted-foreground hover:text-foreground",Xs),children:[o.jsx(V,{"aria-hidden":!0,className:"size-3.5"}),o.jsx("span",{className:"sr-only @[340px]:not-sr-only",children:E.label})]},E.key)})}),o.jsx("button",{type:"button","aria-label":"Refresh tasks",title:"Refresh tasks",onClick:()=>{a.refreshTasks()},className:I("flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-sidebar-hover hover:text-foreground",Xs),children:o.jsx(co,{"aria-hidden":!0,className:I("size-3.5",h.status==="loading"&&"animate-spin")})})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-1",children:[o.jsx("div",{role:"group","aria-label":"Task filter",className:"flex flex-wrap gap-1",children:uT.map(E=>{const V=S.filter===E;return o.jsxs("button",{type:"button","aria-pressed":V,onClick:()=>j(U=>({...U,filter:E})),"data-testid":`tasks-filter-${E}`,className:I("h-6 rounded-full border px-2.5 text-xs",V?"border-foreground bg-foreground font-semibold text-background":"border-border text-foreground hover:bg-secondary",Xs),children:[E[0].toUpperCase()+E.slice(1)," ",o.jsx("span",{className:"text-[length:calc(11px*var(--ui-scale))] opacity-60",children:L[E]})]},E)})}),o.jsxs("label",{className:"flex h-7 min-w-[160px] flex-1 items-center gap-1.5 rounded-lg border border-border bg-card px-2 focus-within:border-ring",children:[o.jsx(Ws,{"aria-hidden":!0,className:"size-3.5 shrink-0 text-muted-foreground"}),o.jsx("input",{type:"text",role:"searchbox",value:S.query,onChange:E=>j(V=>({...V,query:E.target.value})),"aria-label":"Filter tasks",placeholder:"Filter by id, title, label, agent",className:"min-w-0 flex-1 bg-transparent text-xs text-foreground outline-none placeholder:text-muted-foreground"})]})]}),R?o.jsxs("form",{className:"flex gap-1.5 px-1",onSubmit:E=>{E.preventDefault(),x.trim()&&(a.createTask({title:x,priority:v}),y(""))},children:[o.jsx(ro,{htmlFor:"task-title",className:"sr-only",children:"New task"}),o.jsx(Qn,{id:"task-title",value:x,onChange:E=>y(E.target.value),placeholder:"New task…",maxLength:200,className:"h-8 min-w-0 flex-1"}),o.jsx(ro,{htmlFor:"task-priority",className:"sr-only",children:"Priority"}),o.jsx(mh,{id:"task-priority",value:v,onChange:E=>k(Number(E.target.value)),className:"h-8 w-16 text-xs",children:qT.map(E=>o.jsxs("option",{value:E,children:["P",E]},E))}),o.jsx(be,{type:"submit",size:"icon-sm",className:"size-8","aria-label":"Add task",title:"Add task",disabled:!x.trim(),children:o.jsx(vs,{"aria-hidden":!0})})]}):o.jsx("p",{className:"px-2 text-xs text-muted-foreground",children:"Your access token can read tasks but not change them."}),h.creates.map(E=>o.jsx("div",{role:E.status==="creating"?"status":"alert",className:I("mx-1 rounded-lg border px-3 py-2 text-xs",E.status==="creating"?"border-border text-muted-foreground":E.status==="unknown"?"border-warning/40 bg-warning/5 text-warning":"border-destructive/40 bg-destructive/5 text-destructive"),children:E.status==="creating"?o.jsx(Kt,{label:`Creating “${E.title}”…`}):o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"mb-1.5 font-medium text-foreground",children:["“",E.title,"”"]}),o.jsx("p",{children:E.error}),E.match?o.jsxs("p",{className:"mt-1 text-foreground/90",children:["A task with this title is in the list (",E.match,"); it was probably created."]}):null,o.jsxs("div",{className:"mt-2 flex gap-2",children:[o.jsxs(be,{size:"sm",variant:"secondary",onClick:()=>{a.retryTaskCreate(E.requestId)},children:[o.jsx(uo,{"aria-hidden":!0})," Create again"]}),o.jsx(be,{size:"sm",variant:"ghost",onClick:()=>a.dismissTaskCreate(E.requestId),children:"Dismiss"})]})]})},E.requestId)),h.message?o.jsx("p",{role:h.message.level==="error"?"alert":"status",className:I("mx-1 rounded-md px-3 py-1.5 text-xs",h.message.level==="error"?"bg-destructive/10 text-destructive":"bg-primary/10 text-highlight"),children:h.message.text}):null,h.status==="loading"&&!q.length?o.jsx(Kt,{label:"Loading tasks…",className:"px-2 text-xs"}):null,h.status==="error"?o.jsx("p",{role:"alert",className:"mx-1 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:h.error?.message}):null,h.unreadable?o.jsxs("p",{className:"px-2 text-xs text-warning",children:[h.unreadable," task file(s) on the host could not be read."]}):null,h.status==="ready"&&!q.length?o.jsx(Bf,{text:"No tasks yet. Add one here, with alp task add, or ask main to plan the work."}):null,q.length&&!O.length?o.jsx(Bf,{text:S.query.trim()?"No tasks match.":S.filter==="open"?"All tasks are closed.":S.filter==="ready"?"No task is ready.":"No closed tasks."}):null,O.length&&S.view==="list"?o.jsx(IT,{tasks:O,isCurrent:B,onOpen:d,canWrite:R}):null,O.length&&S.view==="board"?o.jsx(GT,{tasks:O,isCurrent:B,onOpen:d}):null,O.length&&S.view==="epics"?o.jsx(YT,{all:q,shown:O,isCurrent:B,onOpen:d}):null]})}function Bf({text:s}){return o.jsx("p",{role:"status",className:"mx-1 rounded-lg border border-dashed border-border px-4 py-5 text-center text-xs text-muted-foreground",children:s})}function U1({task:s,isCurrent:t,onOpen:i,testId:a="task-row"}){const l=t(s.id),u=bh(s),d=s.blockedBy?.length?`after ${s.blockedBy.join(", ")}`:"",h=s.waits?.length&&!s.approvals?.length?`waits on ${s.waits.join("; ")}`:"";return o.jsx("div",{className:I("rounded-lg",l?"bg-sidebar-selected":"hover:bg-sidebar-hover"),"data-testid":a,children:o.jsxs("button",{type:"button",className:DT,onClick:()=>i(s.id),"aria-current":l?"true":void 0,title:s.title,children:[o.jsx("span",{className:"flex h-5 w-4 shrink-0 items-center justify-center",children:o.jsx(jh,{state:u})}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:I("line-clamp-2 text-sm leading-5",s.status==="closed"?"text-muted-foreground line-through":"text-foreground/90"),children:s.title}),o.jsxs("span",{className:"mt-0.5 flex flex-wrap items-center gap-x-1.5 text-xs text-muted-foreground",children:[o.jsx("span",{className:"font-mono",children:s.id}),o.jsxs("span",{children:["P",s.priority]}),s.type&&s.type!=="task"?o.jsx("span",{children:s.type}):null,o.jsx("span",{children:String(s.status).replace("_"," ")}),s.assignee?o.jsxs("span",{children:["· @",s.assignee]}):null,s.progress?o.jsxs("span",{children:["· ",s.progress.done,"/",s.progress.total]}):null,s.approvals?.length?o.jsx("span",{className:"text-dot-warning",children:"· needs approval"}):null,d?o.jsxs("span",{className:"text-dot-danger",children:["· ",d]}):null,h?o.jsxs("span",{children:["· ",h]}):null,s.parent?o.jsxs("span",{children:["· in ",s.parent]}):null,(s.labels??[]).map(m=>o.jsxs("span",{className:"text-info",children:["#",m]},m)),o.jsx("span",{className:"ml-auto tabular-nums",children:w1(s.status==="closed"?s.closed?.at:s.updatedAt)})]})]})]})})}function IT({tasks:s,isCurrent:t,onOpen:i,canWrite:a}){const l=Oe(),{tasks:u}=Me(),d=w.useMemo(()=>pT(s),[s]),[h,m]=w.useState({});return o.jsx("div",{className:"space-y-1","data-testid":"tasks-list-view",children:d.map(p=>{const x=h[p.key]??!1,y=$T[p.key]??jS;return o.jsxs("section",{"aria-label":p.title,"data-testid":`tasks-section-${p.key}`,children:[o.jsxs("button",{type:"button","aria-expanded":!x,onClick:()=>m(v=>({...v,[p.key]:!x})),className:I("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground hover:text-foreground",Xs),children:[x?o.jsx(Wn,{"aria-hidden":!0,className:"size-3.5"}):o.jsx(Xn,{"aria-hidden":!0,className:"size-3.5"}),o.jsx(y,{"aria-hidden":!0,className:"size-3.5"}),o.jsx("span",{className:"font-semibold",children:p.title}),o.jsx("span",{className:"tabular-nums opacity-70",children:p.tasks.length})]}),x?null:o.jsx("ul",{"aria-label":p.title,children:p.tasks.map(v=>o.jsxs("li",{className:"mb-0.5",children:[o.jsx(U1,{task:v,isCurrent:t,onOpen:i}),p.key==="approve"&&a?v.approvals.map(k=>o.jsxs("div",{className:"ml-8 mr-2 mb-1 flex items-center gap-2 rounded-md bg-warning/[0.06] px-2 py-1 text-xs",children:[o.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:k.note||"Waiting for your approval"}),k.options?.length?k.options.map(S=>o.jsx(be,{size:"sm",className:"h-6 px-2 text-xs",disabled:!!u.busy[v.id],"aria-label":`Approve ${v.id}: ${S}`,onClick:()=>{l.changeTask(v,{gate:k.gate,choice:S})},children:S},S)):o.jsx(be,{size:"sm",className:"h-6 px-2 text-xs",disabled:!!u.busy[v.id],"aria-label":`Approve ${v.id}`,onClick:()=>{l.changeTask(v,{gate:k.gate})},children:"Approve"}),k.rejected?null:o.jsx(be,{size:"sm",variant:"secondary",className:"h-6 px-2 text-xs",disabled:!!u.busy[v.id],"aria-label":`Reject ${v.id}`,onClick:()=>{l.changeTask(v,{gate:k.gate,reject:!0})},children:"Reject"})]},k.gate)):null]},v.id))})]},p.key)})})}function GT({tasks:s,isCurrent:t,onOpen:i}){const a=w.useMemo(()=>xT(s),[s]);return o.jsx("div",{className:"flex items-start gap-2.5 overflow-x-auto px-1 pb-2","data-testid":"tasks-board-view",children:a.map(l=>o.jsxs("section",{"aria-label":l.title,"data-testid":`tasks-column-${l.key}`,className:"flex max-h-[640px] w-[248px] shrink-0 flex-col rounded-[10px] border border-border bg-card",children:[o.jsxs("h3",{className:"flex items-center gap-2 border-b border-border px-3 py-2 text-xs font-semibold",children:[o.jsx(jh,{state:l.key}),o.jsx("span",{className:"flex-1",children:l.title}),o.jsx("span",{className:"font-normal tabular-nums text-muted-foreground",children:l.tasks.length})]}),o.jsxs("ul",{className:"min-h-0 space-y-2 overflow-y-auto p-2",children:[l.tasks.map(u=>{const d=t(u.id);return o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>i(u.id),"aria-current":d?"true":void 0,title:u.title,"data-testid":"task-card",className:I("flex w-full flex-col gap-1 rounded-lg border border-l-[3px] border-border bg-background p-2.5 text-left hover:border-muted-foreground",HT[l.key],d&&"bg-sidebar-selected",Xs),children:[o.jsxs("span",{className:"flex w-full items-center gap-1.5 text-xs text-muted-foreground",children:[o.jsx(B1,{value:u.priority}),o.jsx("span",{className:"font-mono",children:u.id}),o.jsx("span",{className:"flex-1"}),o.jsx("span",{className:"tabular-nums",children:w1(l.key==="closed"?u.closed?.at:u.updatedAt)})]}),o.jsx("span",{className:I("line-clamp-3 text-[length:calc(13px*var(--ui-scale))] leading-[18px]",l.key==="closed"&&"text-muted-foreground"),children:u.title}),u.assignee?o.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["@",u.assignee]}):null,u.blockedBy?.length?o.jsxs("span",{className:"truncate text-xs text-dot-danger",children:["after ",u.blockedBy.join(", ")]}):null,u.labels?.length?o.jsx("span",{className:"flex flex-wrap gap-1.5 text-xs text-info",children:u.labels.map(h=>o.jsxs("span",{children:["#",h]},h))}):null]})},u.id)}),l.tasks.length?null:o.jsx("li",{className:"px-1 py-2 text-xs text-muted-foreground",children:"Nothing here"})]})]},l.key))})}function YT({all:s,shown:t,isCurrent:i,onOpen:a}){const l=w.useMemo(()=>yT(s,t),[s,t]),[u,d]=w.useState({});return l.length?o.jsx("ul",{className:"space-y-2 px-1","data-testid":"tasks-epics-view",children:l.map(({epic:h,children:m,done:p,total:x,percent:y})=>{const v=u[h.id]??h.status!=="closed",k=i(h.id);return o.jsxs("li",{className:"rounded-[10px] border border-border bg-card p-3","data-testid":"epic",children:[o.jsxs("button",{type:"button",onClick:()=>a(h.id),"aria-current":k?"true":void 0,title:h.title,className:I("flex w-full min-w-0 items-center gap-2 rounded-md text-left",k&&"text-highlight",Xs),children:[o.jsx(jh,{state:bh(h)}),o.jsx(ch,{"aria-hidden":!0,className:"size-3.5 shrink-0 text-muted-foreground"}),o.jsx(B1,{value:h.priority}),o.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:h.id}),o.jsx("span",{className:I("min-w-0 flex-1 truncate text-sm",h.status==="closed"&&"text-muted-foreground line-through"),children:h.title}),o.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground","data-testid":"epic-progress",children:[p,"/",x]})]}),o.jsx("div",{role:"progressbar","aria-label":`${h.id} progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":y,className:"mt-2 h-1.5 overflow-hidden rounded-full bg-secondary",children:o.jsx("div",{className:"h-full rounded-full bg-dot-success",style:{width:`${y}%`}})}),m.length?o.jsxs("button",{type:"button","aria-expanded":v,onClick:()=>d(S=>({...S,[h.id]:!v})),className:I("mt-2 flex items-center gap-1 rounded-md text-xs text-muted-foreground hover:text-foreground",Xs),children:[v?o.jsx(Xn,{"aria-hidden":!0,className:"size-3"}):o.jsx(Wn,{"aria-hidden":!0,className:"size-3"}),m.length," ",m.length===1?"task":"tasks"]}):null,v&&m.length?o.jsx("ul",{className:"mt-1 border-l border-border pl-2","aria-label":`Tasks of ${h.id}`,children:m.map(S=>o.jsx("li",{children:o.jsx(U1,{task:S,isCurrent:i,onOpen:a,testId:"epic-task"})},S.id))}):null]},h.id)})}):o.jsx(Bf,{text:"No epics here. An epic is a task other tasks name as their parent."})}const H1="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",af=I("flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground [&_svg]:size-4",H1);function rf({testId:s,children:t}){return o.jsxs("div",{className:"flex min-h-full flex-col items-center justify-center gap-2 p-6 text-center",role:"note","data-testid":s,children:[o.jsx(ih,{"aria-hidden":!0,strokeWidth:1.5,className:"size-6 text-extra-muted"}),t]})}function VT({onPicked:s}){const t=Oe(),{workspace:i,connection:a,principal:l}=Me(),{openFile:u,active:d}=kt(),h=a.capabilities.includes("workspace.files.read"),m=Te(l??void 0,"files.read"),[p,x]=w.useState({}),[y,v]=w.useState([]),[k,S]=w.useState("name"),[j,A]=w.useState(!1),R=w.useRef(0),q=w.useCallback((U,de)=>{const J=R.current;x(me=>({...me,[U]:me[U]?.status==="ready"?me[U]:{status:"loading"}})),t.listWorkspaceFiles({...U?{path:U}:{},includeIgnored:de}).then(me=>{R.current===J&&x(se=>({...se,[U]:{status:"ready",entries:me.entries,truncated:me.truncated}}))},me=>{R.current===J&&x(se=>({...se,[U]:{status:"error",error:me instanceof Ai||me instanceof Error?me.message:"Could not list this folder."}}))})},[t]),L=`${a.gateway}
|
|
31
|
+
${i??""}`,O=w.useRef(L),B=w.useRef(y);if(B.current=y,w.useEffect(()=>{if(!h||!m||!i||a.phase!=="open")return;R.current+=1;const U=O.current===L;if(O.current=L,x({}),U||v([]),q("",j),U)for(const de of B.current)q(de,j)},[h,m,i,L,a.phase,j,q]),!h)return o.jsx(rf,{testId:"files-unavailable",children:o.jsx("p",{className:"max-w-[300px] text-sm text-muted-foreground",children:Pb})});if(!m)return o.jsxs(rf,{testId:"files-forbidden",children:[o.jsxs("p",{className:"flex max-w-[300px] items-start gap-2 text-sm text-foreground",children:[o.jsx(qa,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),kf]}),o.jsxs("p",{className:"max-w-[300px] text-xs leading-5 text-muted-foreground",children:["File reading is never granted by default. The host owner can create a token that allows it: ",o.jsx("code",{className:"font-mono",children:"alp-gateway credential create --permission files.read"})," (with the other permissions it needs)."]})]});if(!i)return o.jsx(rf,{testId:"files-no-workspace",children:o.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a workspace to browse its files."})});const _=b2(p,y,{sort:k,showHidden:j}),W=U=>{const de=!y.includes(U);v(J=>y2(J,U)),de&&p[U]?.status!=="ready"&&q(U,j)},E=()=>{R.current+=1,x({}),q("",j);for(const U of y)q(U,j)},V=d?.kind==="file"?d.id:void 0;return o.jsxs("div",{className:"flex min-h-full flex-col","data-testid":"files-panel",children:[o.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2 py-1",children:[o.jsxs("span",{className:"min-w-0 flex-1 truncate px-1 text-xs text-muted-foreground",children:["Sorted by ",Id[k].toLowerCase()]}),o.jsx("button",{type:"button",className:af,onClick:()=>S(Cx),"aria-label":`Sort by ${Id[Cx(k)].toLowerCase()}`,title:`Sort: ${Id[k]}`,"data-testid":"files-sort","data-sort":k,children:o.jsx(mS,{"aria-hidden":!0})}),o.jsx("button",{type:"button",className:af,onClick:()=>A(U=>!U),"aria-pressed":j,"aria-label":"Show hidden files",title:j?"Hide hidden files":"Show hidden files","data-testid":"files-show-hidden",children:j?o.jsx(lo,{"aria-hidden":!0}):o.jsx(ES,{"aria-hidden":!0})}),o.jsx("button",{type:"button",className:af,onClick:E,"aria-label":"Refresh files",title:"Refresh","data-testid":"files-refresh",children:o.jsx(co,{"aria-hidden":!0})})]}),o.jsx("ul",{className:"py-1",role:"tree","aria-label":"Workspace files",children:_.map(U=>{const de={paddingLeft:8+U.depth*14};if(U.kind==="status"){const H=U.status==="loading"?"Loading…":U.status==="empty"?U.path?"Empty folder":"No files to show":U.status==="truncated"?"Only the first 1000 entries are shown.":U.message??"Could not list this folder.";return o.jsxs("li",{role:"none",style:de,className:I("py-1 pr-3 text-xs",U.status==="error"?"text-destructive":"text-muted-foreground"),"data-testid":`files-${U.status}`,children:[H,U.status==="error"?o.jsx("button",{type:"button",className:"ml-2 text-highlight hover:underline",onClick:()=>q(U.path,j),children:"Retry"}):null]},`status:${U.path}`)}const{entry:J}=U,me=J.kind==="directory",se=!me&&V===J.path,fe=me?U.open?RS:Da:a0;return o.jsx("li",{role:"treeitem","aria-expanded":me?U.open:void 0,"aria-selected":se||void 0,children:o.jsxs("button",{type:"button",style:de,title:J.path,onClick:()=>{me?W(J.path):(u(J.path),s?.())},className:I("flex w-full min-w-0 items-center gap-1.5 py-1 pr-3 text-left text-[length:calc(13px*var(--ui-scale))]",se?"bg-sidebar-selected text-foreground":"text-foreground/85 hover:bg-sidebar-hover",H1),"data-testid":"files-entry","data-path":J.path,"data-kind":J.kind,children:[o.jsx(Wn,{"aria-hidden":!0,className:I("size-3.5 shrink-0 text-extra-muted transition-transform",!me&&"invisible",U.open&&"rotate-90")}),o.jsx(fe,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),o.jsx("span",{className:"truncate",children:J.name})]})},J.path)})})]})}const KT=Object.freeze(["shell","read","edit","write","search","fetch","sub_agent","plan","plain_text","unknown"]),Bn=400,FT=1e6,Sh=s=>typeof s=="object"&&s!==null&&!Array.isArray(s),Mn=s=>typeof s=="string"?s:"",za=s=>s.split(`
|
|
32
|
+
`).find(t=>t.trim())?.trim()??"";function I1(s){const t=Sh(s)?s.type:void 0;return typeof t=="string"&&KT.includes(t)?t:"unknown"}function $l(s,t=[]){if(!s)return s;const i=s.replace(/\\/g,"/");for(const a of t){if(!a)continue;const l=a.replace(/\\/g,"/").replace(/\/+$/,"");if(l){if(i===l)return".";if(i.startsWith(`${l}/`))return i.slice(l.length+1)}}return s}function Yy(s){const t=String(s??"").trim();return t?/[:./]/.test(t)||t.includes("__")?t:t.replace(/[._-]+/g," ").split(" ").filter(Boolean).join(" ").toLowerCase().replace(/^./,i=>i.toUpperCase()):"Tool"}function XT(s){if(typeof s=="string")return za(s);if(Sh(s)){const t=Object.values(s).find(i=>typeof i=="string"&&i.trim());if(typeof t=="string")return za(t)}return""}const PT={shell:"terminal",read:"eye",edit:"pencil",write:"pencil",search:"search",fetch:"search",sub_agent:"bot",plan:"brain",plain_text:"wrench",unknown:"wrench"};function QT(s,t=[]){const i=typeof s?.name=="string"?s.name:"",a=I1(s?.detail),l=Sh(s?.detail)?s.detail:{},d=i.trim().toLowerCase()==="task"||i==="alp_delegate"?"bot":PT[a];switch(a){case"shell":return{kind:a,label:"Shell",secondary:za(Mn(l.command)),icon:d};case"read":return{kind:a,label:"Read",secondary:$l(Mn(l.filePath),t),icon:d};case"edit":return{kind:a,label:"Edit",secondary:$l(Mn(l.filePath),t),icon:d};case"write":return{kind:a,label:"Write",secondary:$l(Mn(l.filePath),t),icon:d};case"search":return{kind:a,label:"Search",secondary:za(Mn(l.query)),icon:d};case"fetch":return{kind:a,label:"Fetch",secondary:Mn(l.url),icon:d};case"sub_agent":return{kind:a,label:Mn(l.subAgentType).trim()||"Task",secondary:za(Mn(l.description)),icon:d};case"plan":return{kind:a,label:"Plan",secondary:"",icon:d};case"plain_text":return{kind:a,label:Yy(i),secondary:za(Mn(l.label)),icon:d};default:{if(i==="alp_delegate")return{kind:a,label:"Delegate",secondary:`to ${l.input?.agent??"an agent"}`,icon:d};const h=i.startsWith("alp_")?i.replace(/^alp_/,"").replace(/^\w/,m=>m.toUpperCase()):Yy(i);return{kind:a,label:h,secondary:XT(l.input),icon:d}}}}function tc(s){if(!s)return[];const t=s.replace(/\r\n?/g,`
|
|
33
|
+
`).split(`
|
|
34
|
+
`);return t.length>1&&t.at(-1)===""&&t.pop(),t}function G1(s,t=Bn){const i=Math.max(0,Math.floor(t));return s.length>i?{shown:s.slice(0,i),hidden:s.length-i}:{shown:s,hidden:0}}function WT(s){const t=tc(s),i=[],a=[],l=[];let u=0,d=0,h=0,m=0,p="";for(const x of t){if(h>0||m>0){if(x.startsWith("+")){i.push({type:"add",text:x.slice(1),newLine:d++}),m--;continue}if(x.startsWith("-")){i.push({type:"remove",text:x.slice(1),oldLine:u++}),h--;continue}if(x.startsWith("\\")){i.push({type:"meta",text:x});continue}if(x.startsWith(" ")||x===""){i.push({type:"context",text:x.slice(1),oldLine:u++,newLine:d++}),h--,m--;continue}h=0,m=0}const v=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)$/.exec(x);if(v){u=Number(v[1]),d=Number(v[3]),h=v[2]===void 0?1:Number(v[2]),m=v[4]===void 0?1:Number(v[4]),p&&(a.push(p),l.push(i.length),p=""),i.push({type:"hunk",text:x});continue}if(x.startsWith("diff --git ")){p=x.replace(/^diff --git a\/(.*?) b\/.*$/,"$1");continue}if(x.startsWith("+++ ")){const k=x.slice(4).replace(/^b\//,"").replace(/\t.*$/,"");k!=="/dev/null"&&(p=k);continue}if(x.startsWith("--- ")){const k=x.slice(4).replace(/^a\//,"").replace(/\t.*$/,"");k!=="/dev/null"&&!p&&(p=k);continue}if(!(x.startsWith("index ")||/^(new|deleted) file mode /.test(x)||/^(similarity|rename|old mode|new mode)/.test(x))){if(x.startsWith("@@")){i.push({type:"hunk",text:x});continue}x.startsWith("+")?i.push({type:"add",text:x.slice(1)}):x.startsWith("-")?i.push({type:"remove",text:x.slice(1)}):x.startsWith("\\")?i.push({type:"meta",text:x}):i.push({type:"context",text:x.startsWith(" ")?x.slice(1):x})}}if(a.length>1)for(let x=a.length-1;x>=0;x--)i.splice(l[x],0,{type:"file",text:a[x]});return i}function ZT(s,t,{cellLimit:i=FT}={}){const a=tc(s),l=tc(t);let u=0;for(;u<a.length&&u<l.length&&a[u]===l[u];)u++;let d=0;for(;d<a.length-u&&d<l.length-u&&a[a.length-1-d]===l[l.length-1-d];)d++;const h=[];for(let y=0;y<u;y++)h.push({type:"context",text:a[y],oldLine:y+1,newLine:y+1});const m=a.length-u-d,p=l.length-u-d;let x=!0;if(m&&p&&m*p<=i){const y=p+1,v=new Uint32Array((m+1)*y);for(let j=m-1;j>=0;j--)for(let A=p-1;A>=0;A--)v[j*y+A]=a[u+j]===l[u+A]?v[(j+1)*y+A+1]+1:Math.max(v[(j+1)*y+A],v[j*y+A+1]);let k=0,S=0;for(;k<m&&S<p;)a[u+k]===l[u+S]?(h.push({type:"context",text:a[u+k],oldLine:u+k+1,newLine:u+S+1}),k++,S++):v[(k+1)*y+S]>=v[k*y+S+1]?(h.push({type:"remove",text:a[u+k],oldLine:u+k+1}),k++):(h.push({type:"add",text:l[u+S],newLine:u+S+1}),S++);for(;k<m;k++)h.push({type:"remove",text:a[u+k],oldLine:u+k+1});for(;S<p;S++)h.push({type:"add",text:l[u+S],newLine:u+S+1})}else{x=!(m&&p);for(let y=0;y<m;y++)h.push({type:"remove",text:a[u+y],oldLine:u+y+1});for(let y=0;y<p;y++)h.push({type:"add",text:l[u+y],newLine:u+y+1})}for(let y=d;y>0;y--)h.push({type:"context",text:a[a.length-y],oldLine:a.length-y+1,newLine:l.length-y+1});return{lines:h,exact:x}}function Y1(s,t){const i=Mn(s?.unifiedDiff);if(i){const u=WT(i);return{lines:u,numbered:u.some(d=>d.type==="hunk"&&/^@@ -\d/.test(d.text)),exact:!0}}const{lines:a,exact:l}=ZT(Mn(s?.oldString),Mn(s?.newString),t);return{lines:a,numbered:!1,exact:l}}function JT(s){let t=0,i=0;for(const a of s)a.type==="add"?t++:a.type==="remove"&&i++;return{added:t,removed:i}}function e5(s){if(!(typeof s!="string"||!s.trim()))try{const t=new URL(s.trim());return t.protocol==="http:"||t.protocol==="https:"?t.href:void 0}catch{return}}function nc(s){if(s==null)return"";if(typeof s=="string")return s;try{return JSON.stringify(s,null,2)??String(s)}catch{return String(s)}}const Li=(()=>{let s={mode:"uncommitted",ignoreWhitespace:!1,focus:null,focusScope:""};const t=new Set;return{get:()=>s,set(i){s={...s,...i};for(const a of[...t])a()},subscribe(i){return t.add(i),()=>{t.delete(i)}}}})(),t5=()=>w.useSyncExternalStore(Li.subscribe,Li.get,Li.get);function Vy(s,t=""){Li.set({focus:s,focusScope:t})}const n5=15e3,vc="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",$f=I("flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground disabled:opacity-50 [&_svg]:size-4",vc);function Ky({testId:s,reason:t,children:i}){return o.jsxs("div",{className:"flex min-h-full flex-col items-center justify-center gap-2 p-6 text-center",role:"note","data-testid":s,"data-reason":t,children:[o.jsx(Sf,{"aria-hidden":!0,strokeWidth:1.5,className:"size-6 text-extra-muted"}),i]})}function s5(s,t){const i=Oe(),[a,l]=w.useState({loading:!1,at:0}),u=w.useRef(0),d=w.useCallback(()=>{const h=++u.current;l(m=>({...m,loading:!0})),i.gitStatus().then(m=>{u.current===h&&l({status:m,loading:!1,at:Date.now()})},m=>{if(u.current===h){const p=zi(m);l({error:p.message,reason:p.reason,loading:!1,at:Date.now()})}})},[i]);return w.useEffect(()=>{s?d():(u.current++,l({loading:!1,at:0}))},[s,t,d]),{...a,load:d}}function i5(s,t,i){const a=Oe(),[l,u]=w.useState({loading:!1,more:!1}),d=w.useRef(0),h=w.useRef(i);h.current=i;const m=w.useCallback(x=>{const y=++d.current,{path:v,...k}=h.current;u(S=>({...S,loading:!0,error:void 0,notice:x})),a.gitDiff({compare:k,...v?{path:v}:{}}).then(S=>{d.current===y&&u({diff:Rx(void 0,S),loading:!1,more:!1,notice:x})},S=>{d.current===y&&u({error:zi(S).message,loading:!1,more:!1,notice:x})})},[a]),p=w.useCallback(()=>{const x=l.diff?.nextCursor;if(!x||l.more)return;const y=d.current,{path:v,...k}=h.current;u(S=>({...S,more:!0})),a.gitDiff({compare:k,...v?{path:v}:{},cursor:x}).then(S=>{d.current===y&&u(j=>({...j,diff:Rx(j.diff,S),more:!1}))},S=>{if(d.current===y){if(sj(S)){m(zi(S).reason==="stale_snapshot"?Gl.stale_snapshot:Gl.invalid_cursor);return}u(j=>({...j,more:!1,error:zi(S).message}))}})},[a,l.diff?.nextCursor,l.more,m]);return w.useEffect(()=>{s?m():(d.current++,u({loading:!1,more:!1}))},[s,t,m]),{...l,load:m,loadMore:p}}function a5(s,t,i){const a=w.useRef({refresh:s,lastAt:t,enabled:i});a.current={refresh:s,lastAt:t,enabled:i},w.useEffect(()=>{const l=()=>{const{refresh:u,lastAt:d,enabled:h}=a.current;h&&document.visibilityState!=="hidden"&&Date.now()-d>n5&&u()};return window.addEventListener("focus",l),document.addEventListener("visibilitychange",l),()=>{window.removeEventListener("focus",l),document.removeEventListener("visibilitychange",l)}},[])}function V1({additions:s,deletions:t,testId:i}){return o.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs tabular-nums","data-testid":i,children:[o.jsxs("span",{className:"text-dot-success",children:["+",_x(s)]}),o.jsxs("span",{className:"text-destructive",children:["-",_x(t)]})]})}const Fy={add:"bg-[rgba(46,160,67,0.15)]",remove:"bg-[rgba(248,81,73,0.15)]",context:"",hunk:"bg-muted/60 text-muted-foreground"},r5={add:"+",remove:"-",context:" "};function o5({file:s}){const t=w.useMemo(()=>rj(s),[s]),[i,a]=w.useState(Bn),{shown:l,hidden:u}=G1(t,i);if(s.kind!=="text")return o.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground","data-testid":"git-file-kind","data-kind":s.kind,children:Eb[s.kind]});if(!t.length&&s.change==="renamed"&&s.oldPath)return o.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground","data-testid":"git-file-rename",children:["Renamed ",s.oldPath," → ",s.path]});if(!t.length)return o.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground","data-testid":"git-file-empty",children:"No changes to display"});const d=String(Math.max(0,...t.map(m=>"oldLine"in m?Math.max(m.oldLine??0,m.newLine??0):0))).length,h=m=>o.jsx("span",{"aria-hidden":!0,className:"shrink-0 select-none pr-2 text-right text-muted-foreground tabular-nums",style:{minWidth:`${d+1}ch`},children:m??""});return o.jsxs("div",{className:"overflow-auto bg-card font-mono text-(length:--code-font-size) leading-[1.5] text-foreground","data-testid":"git-hunks",children:[o.jsx("div",{className:"min-w-max py-1",children:l.map((m,p)=>m.type==="hunk"?o.jsx("div",{className:I("whitespace-pre px-3",Fy.hunk),"data-diff":"hunk",children:m.text},p):o.jsxs("div",{className:I("flex whitespace-pre px-3",Fy[m.type]),"data-diff":m.type,children:[h(m.oldLine),h(m.newLine),o.jsx("span",{"aria-hidden":!0,className:I("w-[2ch] shrink-0 select-none",m.type==="add"?"text-dot-success":m.type==="remove"?"text-destructive":"text-muted-foreground"),children:r5[m.type]}),o.jsx("span",{children:m.text||" "}),m.noNewline?o.jsx("span",{className:"ml-2 select-none text-muted-foreground",title:"No newline at end of file",children:"⏎̸"}):null]},p))}),u?o.jsxs("button",{type:"button","data-testid":"git-hunks-more",onClick:()=>a(m=>m+Bn),className:"sticky left-0 block px-3 py-1.5 font-sans text-xs text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[`Show ${Math.min(u,Bn)} more line${Math.min(u,Bn)===1?"":"s"}`,u>Bn?` (${u} hidden)`:""]}):null]})}function K1({change:s}){const t=s==="deleted"?"text-destructive":s==="added"||s==="untracked"?"text-dot-success":s==="conflicted"?"text-destructive":"text-highlight";return o.jsx("span",{"aria-label":zx[s],title:zx[s],className:I("w-3 shrink-0 text-center font-mono text-[length:calc(11px*var(--ui-scale))] font-semibold",t),children:nj[s]})}function F1({path:s,oldPath:t}){const i=s.lastIndexOf("/");return o.jsxs("span",{className:"min-w-0 flex-1 truncate text-[length:calc(13px*var(--ui-scale))]",title:t?`${t} → ${s}`:s,children:[t?o.jsxs("span",{className:"text-muted-foreground",children:[t," → "]}):null,o.jsx("span",{className:"text-foreground",children:i>=0?s.slice(i+1):s}),i>=0?o.jsx("span",{className:"ml-1.5 text-xs text-muted-foreground",children:s.slice(0,i)}):null]})}function l5({file:s,open:t,onToggle:i,onOpenDiff:a}){return o.jsxs("li",{className:"border-b border-border/60","data-testid":"git-file","data-path":s.path,"data-kind":s.kind,"data-change":s.change,children:[o.jsxs("div",{className:"flex items-center",children:[o.jsxs("button",{type:"button",onClick:i,"aria-expanded":t,className:I("flex min-w-0 flex-1 items-center gap-1.5 py-1.5 pl-2 pr-1 text-left hover:bg-sidebar-hover",vc),"data-testid":"git-file-toggle",children:[o.jsx(Wn,{"aria-hidden":!0,className:I("size-3.5 shrink-0 text-extra-muted transition-transform",t&&"rotate-90")}),o.jsx(K1,{change:s.change}),o.jsx(F1,{path:s.path,oldPath:s.oldPath}),s.kind==="text"?o.jsx(V1,{additions:s.additions,deletions:s.deletions}):o.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Eb[s.kind].split(":")[0]})]}),a?o.jsx("button",{type:"button",className:I($f,"mr-1"),onClick:a,"aria-label":`Open ${s.path} in Diff`,title:"Open in Diff","data-testid":"git-file-open-diff",children:o.jsx(LS,{"aria-hidden":!0})}):null]}),t?o.jsx(o5,{file:s}):null]})}function c5({file:s}){return o.jsxs("li",{className:"flex items-center gap-1.5 border-b border-border/60 py-1.5 pl-7 pr-2","data-testid":"git-status-file","data-path":s.path,"data-change":s.change,children:[o.jsx(K1,{change:s.change}),o.jsx(F1,{path:s.path,oldPath:s.oldPath}),o.jsx("span",{className:"shrink-0 text-[length:calc(11px*var(--ui-scale))] text-muted-foreground",children:[s.staged?"staged":"",s.unstaged?"unstaged":""].filter(Boolean).join(" · ")})]})}function Xy({count:s}){return s?o.jsxs("p",{className:"flex items-center gap-1.5 px-3 py-2 text-xs text-muted-foreground","data-testid":"git-hidden",children:[o.jsx(qa,{"aria-hidden":!0,className:"size-3.5"}),`${s} changed file${s===1?" is":"s are"} not shown remotely (secrets, keys, .git or ALP configuration).`]}):null}function Py({status:s,mode:t}){return o.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 border-b border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"git-branch",children:[o.jsx(Fs,{"aria-hidden":!0,className:"size-3.5 shrink-0"}),o.jsxs("span",{className:"min-w-0 flex-1 truncate",title:Lx(s),children:[o.jsx("span",{className:"text-foreground","data-testid":"git-branch-name",children:Lx(s)}),t==="base"?o.jsxs("span",{children:[` → ${lj(s.baseRef)}`,s.aheadBehind?` (${s.aheadBehind.ahead} ahead, ${s.aheadBehind.behind} behind)`:""]}):null]}),o.jsx("span",{className:"shrink-0",title:"Commit, push, pull, merge and branch switching are not available remotely; use Git on the host.","data-testid":"git-read-only",children:"Read only"})]})}function u5({mode:s,setMode:t,content:i,ignoreWhitespace:a,totals:l,refreshing:u,onRefresh:d,testId:h}){return o.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2 py-1","data-testid":h,children:[i?o.jsx("select",{"aria-label":"Diff mode",value:s,onChange:m=>t(m.target.value),"data-testid":"git-mode",className:I("h-7 rounded-md bg-transparent px-1 text-xs text-foreground hover:bg-secondary",vc),children:Cb.map(m=>o.jsx("option",{value:m.id,children:m.label},m.id))}):o.jsx("span",{className:"px-1 text-xs text-muted-foreground",children:"Uncommitted"}),o.jsx("span",{className:"min-w-0 flex-1"}),l?o.jsx(V1,{additions:l.additions,deletions:l.deletions,testId:"git-totals"}):null,i?o.jsx("button",{type:"button",className:I($f,a&&"bg-secondary text-foreground"),onClick:()=>Li.set({ignoreWhitespace:!a}),"aria-pressed":a,"aria-label":a?"Show whitespace":"Hide whitespace",title:a?"Show whitespace":"Hide whitespace","data-testid":"git-whitespace",children:o.jsx(nN,{"aria-hidden":!0})}):null,o.jsx("button",{type:"button",className:$f,onClick:d,disabled:u,"aria-label":u?"Refreshing":"Refresh",title:u?"Refreshing":"Refresh","data-testid":"git-refresh",children:o.jsx(co,{"aria-hidden":!0,className:I(u&&"animate-spin")})})]})}function X1({variant:s,onOpenDiff:t}){const i=Oe(),a=Me(),l=i.gitAccess,u=t5(),d=a.connection.phase==="open",h=`${a.connection.gateway}
|
|
35
|
+
${a.workspace??""}
|
|
36
|
+
${l.status?l.workspaceId:""}`,m=s==="diff"&&u.focusScope===h?u.focus:null,p=s5(d&&l.status,h),x=p.status?.state==="repository",y=l.status&&l.content,v={mode:u.mode,baseRef:u.mode==="base"?p.status?.baseRef??null:null,ignoreWhitespace:u.ignoreWhitespace,...m?{path:m}:{}},k=`${h}
|
|
37
|
+
${v.mode}
|
|
38
|
+
${v.baseRef??""}
|
|
39
|
+
${v.ignoreWhitespace}
|
|
40
|
+
${m??""}
|
|
41
|
+
${p.at}`,S=i5(d&&!!y&&x,k,v),[j,A]=w.useState([]);w.useEffect(()=>A([]),[h,u.mode]);const R=w.useCallback(()=>{p.load()},[p.load]);a5(R,p.at,d&&l.status);const q=`${s}-panel`;if(!l.status)return o.jsx(Ky,{testId:`panel-unavailable-${s}`,reason:l.reason,children:l.reason==="projectRead"?o.jsxs("p",{className:"flex max-w-[300px] items-start gap-2 text-sm text-foreground",children:[o.jsx(qa,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),l.message]}):o.jsx("p",{className:"max-w-[300px] text-sm text-muted-foreground",children:l.message})});const L=E=>o.jsx(u5,{mode:u.mode,setMode:V=>Li.set({mode:V}),content:!!y,ignoreWhitespace:u.ignoreWhitespace,totals:E,refreshing:p.loading||S.loading,onRefresh:R,testId:`${s}-toolbar`});if(!p.status)return o.jsxs("div",{className:"flex min-h-full flex-col","data-testid":q,children:[L(),p.error?o.jsxs("p",{className:"px-3 py-4 text-sm text-destructive",role:"alert","data-testid":"git-error",children:[p.error," ",o.jsx("button",{type:"button",className:"ml-1 text-highlight hover:underline",onClick:R,children:"Retry"})]}):o.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground","data-testid":"git-loading",children:"Checking repository..."})]});if(p.status.state!=="repository")return o.jsxs(Ky,{testId:"changes-not-git",reason:p.status.state,children:[o.jsx("p",{className:"max-w-[300px] text-sm text-muted-foreground",children:p.status.state==="unsupported"?"This workspace is inside a Git repository but is not its top level, so its changes are not shown.":"Not a git repository"}),o.jsx("button",{type:"button",className:"text-xs text-highlight hover:underline",onClick:R,children:"Refresh"})]});if(!y){const E=p.status.files;return o.jsxs("div",{className:"flex min-h-full flex-col","data-testid":q,"data-content":"none",children:[L(),o.jsx(Py,{status:p.status,mode:"uncommitted"}),o.jsxs("p",{className:"flex items-start gap-1.5 px-3 py-2 text-xs text-muted-foreground","data-testid":"git-content-forbidden",children:[o.jsx(qa,{"aria-hidden":!0,className:"mt-0.5 size-3.5 shrink-0"}),l.contentMessage]}),E.length?o.jsx("ul",{"aria-label":"Changed files",children:E.map(V=>o.jsx(c5,{file:V},`${V.oldPath??""}
|
|
42
|
+
${V.path}`))}):o.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground","data-testid":"git-empty",children:"No changes to display"}),o.jsx(Xy,{count:p.status.hiddenCount}),p.status.truncated?o.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground","data-testid":"git-truncated",children:["Only the first ",E.length," changed files are shown."]}):null]})}const O=S.diff?.files??[],B=E=>s==="diff"||j.includes(E),_=E=>A(V=>V.includes(E)?V.filter(U=>U!==E):[...V,E]),W=u.mode==="uncommitted"?"base":"uncommitted";return o.jsxs("div",{className:"flex min-h-full flex-col","data-testid":q,"data-content":"diff",children:[L(S.diff?oj(O):void 0),o.jsx(Py,{status:p.status,mode:u.mode}),m?o.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3 py-1 text-xs text-muted-foreground","data-testid":"git-focus",children:[o.jsx("span",{className:"min-w-0 flex-1 truncate",children:m}),o.jsx("button",{type:"button",className:"text-highlight hover:underline",onClick:()=>Vy(null),"data-testid":"git-focus-clear",children:"All files"})]}):null,S.notice?o.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground",role:"status","data-testid":"git-notice",children:S.notice}):null,S.error?o.jsxs("p",{className:"px-3 py-2 text-sm text-destructive",role:"alert","data-testid":"git-error",children:[S.error," ",o.jsx("button",{type:"button",className:"ml-1 text-highlight hover:underline",onClick:()=>S.load(),children:"Retry"})]}):null,S.loading&&!S.diff?o.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground","data-testid":"git-loading",children:"Loading changes…"}):null,S.diff&&!O.length&&!S.error?o.jsxs("div",{className:"flex flex-col items-center gap-2 px-3 py-6 text-center","data-testid":"git-empty",children:[o.jsx("p",{className:"text-sm text-muted-foreground",children:"No changes to display"}),!m&&!u.ignoreWhitespace?o.jsx("button",{type:"button",className:"text-xs text-highlight hover:underline",onClick:()=>Li.set({mode:W}),"data-testid":"changes-empty-switch-mode",children:W==="base"?"See committed changes":"See uncommitted changes"}):null]}):null,O.length?o.jsx("ul",{"aria-label":s==="diff"?"Diff":"Changed files",children:O.map(E=>o.jsx(l5,{file:E,open:B(E.path),onToggle:()=>_(E.path),onOpenDiff:s==="changes"&&t?()=>{Vy(E.path,h),t()}:void 0},`${E.oldPath??""}
|
|
43
|
+
${E.path}`))}):null,o.jsx(Xy,{count:S.diff?.hiddenCount??0}),S.diff?.nextCursor?o.jsx("button",{type:"button",onClick:S.loadMore,disabled:S.more,className:I("mx-3 my-2 self-start rounded-md px-2 py-1 text-xs text-highlight hover:bg-secondary disabled:opacity-60",vc),"data-testid":"git-load-more",children:S.more?"Loading…":"Load more"}):S.diff?.truncated?o.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground","data-testid":"git-truncated",children:"Only some untracked files are shown: the host limits how many it reads."}):null]})}function d5({onOpenDiff:s}){return o.jsx(X1,{variant:"changes",onOpenDiff:s})}function f5(){return o.jsx(X1,{variant:"diff"})}const h5=w.lazy(()=>Q0(()=>import("./TerminalPanel-CqTsgY-W.js"),__vite__mapDeps([0,1])).then(s=>({default:s.TerminalPanel}))),Zs={changes:{label:"Changes",icon:Sf},terminal:{label:"Terminal",icon:hc},diff:{label:"Diff",icon:Sf},files:{label:"Files",icon:ih},agents:{label:"Agents",icon:Oa},tasks:{label:"Tasks",icon:qi}},m5="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",p5=I("flex w-full min-w-0 items-start gap-2 rounded-lg py-2 pl-2 pr-3 text-left",m5);function g5({onPicked:s}){const{openAgent:t,active:i}=kt(),{tree:a}=Me();if(!a)return o.jsx("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:"Open a session to see its agents."});const l=qb(a.projection),u=new Set(Object.values(a.projection.questions).map(d=>d.sessionId));return o.jsx("ul",{className:"p-2","aria-label":"Agents in this session",children:l.map(d=>{const h=d.session,m=d.id===a.rootId,p=i?.kind==="agent"&&i.id===d.id,x=u.has(d.id)?"needs_input":d.running?"running":"done";return o.jsx("li",{className:I("mb-0.5 rounded-lg",p?"bg-sidebar-selected":"hover:bg-sidebar-hover",!m&&"ml-4"),children:o.jsxs("button",{type:"button",onClick:()=>{t(d.id),s?.()},"aria-current":p?"true":void 0,className:p5,"data-testid":"agent-row",children:[o.jsx(xh,{bucket:x}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:I("truncate text-sm leading-5",p?"text-foreground":"text-foreground/80"),children:h?.agent??(m?"main":"agent")}),o.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:d.closed?"closed":d.running?"working":"idle"})]}),o.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:[m?"main conversation":"assignment",Fl(h?.mode),h?.model].filter(Boolean).join(" · ")})]})]})},d.id)})})}function x5({kind:s}){const t=Zs[s];return o.jsxs("div",{className:"flex min-h-full flex-col items-center justify-center gap-2 p-6 text-center",role:"note","data-testid":`panel-unavailable-${s}`,children:[o.jsx(t.icon,{"aria-hidden":!0,strokeWidth:1.5,className:"size-6 text-extra-muted"}),o.jsxs("p",{className:"text-sm text-foreground",children:[t.label," is not available in this beta"]}),o.jsx("p",{className:"max-w-[300px] text-xs leading-5 text-muted-foreground",children:t.unavailable})]})}function P1({kind:s,onPicked:t}){const{openPanel:i}=kt();return s==="agents"?o.jsx(g5,{onPicked:t}):s==="tasks"?o.jsx($1,{onPicked:t}):s==="files"?o.jsx(VT,{onPicked:t}):s==="changes"?o.jsx(d5,{onOpenDiff:()=>{i("diff"),t?.()}}):s==="diff"?o.jsx(f5,{}):s==="terminal"?o.jsx(w.Suspense,{fallback:o.jsx("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:"Loading the terminal…"}),children:o.jsx(h5,{})}):o.jsx(x5,{kind:s})}const Qy="outline-none focus-visible:ring-2 focus-visible:ring-ring";function Q1({label:s,icon:t,title:i,badge:a,active:l,onSelect:u,onClose:d,testId:h,tabRef:m,onMenu:p,dragging:x,wrapper:y,...v}){return o.jsxs("div",{role:"presentation",...y,onContextMenu:p?k=>{k.preventDefault(),p({x:k.clientX,y:k.clientY})}:void 0,className:I("group relative mx-0.5 flex h-7 max-w-[220px] shrink-0 items-center rounded-md",l?"bg-secondary":"hover:bg-card",x&&"z-10 opacity-80 ring-1 ring-border"),children:[o.jsxs("button",{ref:m,type:"button",role:"tab","aria-selected":l,onClick:u,title:i,"data-testid":h,...v,onKeyDown:k=>{if(d&&(k.key==="Delete"||k.key==="Backspace")&&!k.repeat)k.preventDefault(),d();else if(p&&(k.key==="ContextMenu"||k.key==="F10"&&k.shiftKey)){k.preventDefault();const S=k.currentTarget.getBoundingClientRect();p({x:S.left,y:S.bottom+4})}},className:I("flex h-7 min-w-0 items-center gap-1 rounded-md pl-2 text-sm",d?"pr-7":"pr-2",Qy,l?"text-foreground":"text-muted-foreground"),children:[o.jsx("span",{className:"flex size-3.5 shrink-0 items-center justify-center text-muted-foreground",children:t}),o.jsx("span",{className:"truncate",children:s}),a?o.jsx("span",{className:"ml-0.5 rounded-full bg-background/60 px-1.5 text-[length:calc(11px*var(--ui-scale))] leading-4 text-muted-foreground",children:a}):null]}),d?o.jsx("button",{type:"button","aria-label":`Close ${s}`,title:"Close tab",onClick:d,className:I("absolute right-1 flex size-[18px] items-center justify-center rounded-sm text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:opacity-100",Qy,l?"opacity-100":"opacity-0 group-hover:opacity-100"),children:o.jsx(Zt,{"aria-hidden":!0,className:"size-3"})}):null]})}const y5="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",b5=["changes","diff","files","agents","tasks"],W1=new Set(["files","changes"]);function v5(s=["files","changes"]){const[t,i]=w.useState(()=>({tabs:s.map(d=>({id:d,kind:d})),active:s[0]??null})),a=w.useCallback(d=>i(h=>({...h,active:d})),[]),l=w.useCallback(d=>i(h=>{if(W1.has(d))return h;const m=h.tabs.findIndex(y=>y.id===d),p=h.tabs.filter(y=>y.id!==d),x=h.active!==d?h.active:p[Math.min(m,p.length-1)]?.id??null;return{tabs:p,active:x}}),[]),u=w.useCallback(d=>i(h=>h.tabs.some(m=>m.id===d)?{...h,active:d}:{tabs:[...h.tabs,{id:d,kind:d}],active:d}),[]);return w.useMemo(()=>({...t,select:a,close:l,launch:u}),[t,a,l,u])}function w5({dock:s,onClose:t}){const{tree:i,tasks:a}=Me(),l=i?Object.keys(i.projection.running).length:0,u=a.rows.filter(v=>v.status!=="closed").length,d={agents:l,tasks:u},h=w.useRef({}),m=s.tabs.find(v=>v.id===s.active)??null,p=b5.filter(v=>!s.tabs.some(k=>k.kind===v)),x=v=>{const k=v.key==="ArrowRight"?1:v.key==="ArrowLeft"?-1:0;if(!k||!s.tabs.length||!(v.target instanceof HTMLElement)||v.target.getAttribute("role")!=="tab")return;v.preventDefault();const S=s.tabs.findIndex(A=>A.id===s.active),j=s.tabs[(S+k+s.tabs.length)%s.tabs.length].id;s.select(j),h.current[j]?.focus()},y=I("flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-card hover:text-foreground",y5);return o.jsxs("aside",{"aria-label":"Explorer",className:"flex h-full min-h-0 flex-col bg-sidebar","data-testid":"workspace-explorer-sidebar",children:[o.jsxs("div",{className:"relative flex h-14 shrink-0 items-center border-b border-border md:h-9",children:[o.jsxs("div",{role:"tablist","aria-label":"Explorer tabs",onKeyDown:x,className:"flex min-w-0 flex-1 items-center overflow-x-auto px-1 [scrollbar-width:none]",children:[s.tabs.map(v=>{const k=Zs[v.kind];return o.jsx(Q1,{tabRef:S=>{h.current[v.id]=S},id:`dock-tab-${v.id}`,"aria-controls":"dock-panel",tabIndex:v.id===s.active?0:-1,testId:"explorer-tab","data-tab":v.id,label:k.label,icon:o.jsx(k.icon,{"aria-hidden":!0,className:"size-3.5"}),badge:d[v.kind],active:v.id===s.active,onSelect:()=>s.select(v.id),onClose:W1.has(v.kind)?void 0:()=>s.close(v.id)},v.id)}),o.jsx(Vt,{label:"New explorer tab",title:"New tab",align:"start",testId:"workspace-new-tab-button",disabled:!p.length,trigger:o.jsx(vs,{"aria-hidden":!0,className:"size-3.5"}),triggerClassName:I(y,"mx-1 text-extra-muted"),items:p.map(v=>{const k=Zs[v];return{label:k.label,icon:o.jsx(k.icon,{"aria-hidden":!0}),testId:`workspace-new-tab-menu-${v}`,onSelect:()=>s.launch(v)}})})]}),t?o.jsx("button",{type:"button","aria-label":"Close panel",onClick:t,className:I(y,"mr-1.5 size-8 rounded-lg"),children:o.jsx(Zt,{"aria-hidden":!0,className:"size-4"})}):null]}),o.jsx("div",{...m?{role:"tabpanel","aria-labelledby":`dock-tab-${m.id}`}:{},id:"dock-panel",className:"min-h-0 flex-1 overflow-y-auto",children:m?o.jsx(P1,{kind:m.kind,onPicked:t}):null})]})}const k5=[{id:"today",label:"Today"},{id:"yesterday",label:"Yesterday"},{id:"thisWeek",label:"This week"},{id:"thisMonth",label:"This month"},{id:"older",label:"Older"}],j5=1440*60*1e3;function S5(s,t=new Date){const i=s?Date.parse(s):NaN;if(Number.isNaN(i))return"older";const a=new Date(i),l=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),u=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime();if(u>=l)return"today";if(u>=new Date(t.getFullYear(),t.getMonth(),t.getDate()-1).getTime())return"yesterday";const d=Math.round((l-u)/j5);return d<=7?"thisWeek":d<=30?"thisMonth":"older"}function N5(s,t="",i=new Date){const a=t.toLowerCase().split(/\s+/).filter(Boolean),l=a.length?s.filter(d=>a.every(h=>`${d.title??""}
|
|
44
|
+
${d.id}`.toLowerCase().includes(h))):s,u=new Map;for(const d of l){const h=S5(d.updatedAt??d.createdAt,i);u.set(h,[...u.get(h)??[],d])}return k5.filter(d=>u.has(d.id)).map(d=>({...d,sessions:u.get(d.id)}))}const Nh="outline-none focus-visible:ring-2 focus-visible:ring-ring",Wy=I("flex size-8 shrink-0 items-center justify-center rounded-lg text-extra-muted hover:bg-secondary hover:text-foreground [&_svg]:size-[18px]",Nh),Zy={initializing:"Starting",idle:"Idle",running:"Running",error:"Error",closed:"Closed"};function T5(s,t){return s.tree?.rootId===t&&s.tree.status==="attached"?Object.keys(s.tree.projection.questions).length:Math.max(s.attention[t]??0,s.tree?.rootId===t?Object.keys(s.tree.projection.questions).length:0,1)}function of({children:s,tone:t="muted",icon:i,testId:a}){return o.jsxs("span",{"data-testid":a,className:I("inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-px text-xs leading-5",t==="warning"?"bg-dot-warning/15 text-dot-warning":t==="success"?"bg-dot-success/15 text-dot-success":t==="danger"?"bg-dot-danger/15 text-dot-danger":"bg-secondary text-muted-foreground"),children:[i,s]})}function A5({session:s,project:t,selected:i,waiting:a,reason:l,onOpen:u}){const d=Pn(s),h=Mi(s.updatedAt??s.createdAt);return o.jsxs("button",{type:"button",onClick:u,"data-testid":"history-row","data-session":s.id,"aria-current":i?"true":void 0,className:I("flex w-full min-w-0 items-center gap-3 rounded-lg px-3 py-2 text-left text-sm md:rounded-none",i?"bg-secondary":"hover:bg-card active:bg-secondary",Nh),children:[o.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5 md:flex-row md:items-center md:gap-2",children:[o.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[o.jsx("span",{className:"shrink-0 truncate text-foreground max-md:hidden md:max-w-[320px]",children:t}),o.jsx(Wn,{"aria-hidden":!0,className:"size-3 shrink-0 text-muted-foreground max-md:hidden"}),o.jsx(Oa,{"aria-hidden":!0,className:"size-3.5 shrink-0 text-muted-foreground"}),o.jsx("span",{className:"min-w-0 truncate text-muted-foreground max-md:text-foreground","data-testid":"history-row-title",children:d}),s.archived?o.jsx(of,{icon:o.jsx(ac,{"aria-hidden":!0,className:"size-3"}),children:"Archived"}):null,a?o.jsxs(of,{tone:"warning",children:[a," pending"]}):null,!a&&l?o.jsx(of,{tone:l==="error"?"danger":"success",testId:"history-row-attention",children:l==="error"?"Needs attention":"Finished"}):null]}),o.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-xs text-muted-foreground md:hidden",children:[o.jsx("span",{className:"truncate",children:t}),o.jsx("span",{className:"opacity-70",children:"·"}),o.jsx("span",{className:"truncate",children:Zy[s.status]??s.status}),o.jsx("span",{className:"opacity-70",children:"·"}),o.jsx("span",{className:"shrink-0",children:h})]})]}),o.jsxs("span",{className:"hidden shrink-0 items-center gap-3 text-muted-foreground md:flex",children:[o.jsx("span",{className:"w-[132px] truncate",children:s.teamLabel??""}),o.jsx("span",{className:"w-[72px] truncate",children:Zy[s.status]??s.status}),o.jsx("span",{className:"w-[72px] truncate text-right",children:h})]})]})}function C5({navOpen:s,onToggleNav:t,onOpen:i,onBack:a}){const l=Oe(),u=Me(),{history:d,workspace:h,selected:m,connection:p}=u,[x,y]=w.useState(""),[v,k]=w.useState(""),S=p.phase==="open",j=p.capabilities.includes("session.list.page");w.useEffect(()=>{const O=setTimeout(()=>k(x),200);return()=>clearTimeout(O)},[x]);const A=j?v.trim():"";w.useEffect(()=>{h&&S&&l.loadHistory({quiet:d.status==="ready"&&d.query===A,query:A})},[h,S,l,A]);const R=w.useMemo(()=>N5(d.list,j?"":v),[d.list,v,j]),q=h?Ot(h):"",L=!!v.trim();return o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"history-screen",children:[o.jsxs("header",{className:"flex h-14 shrink-0 items-center gap-1 border-b border-border bg-background px-2 md:h-9 md:gap-2 md:px-3",children:[o.jsx("button",{type:"button","aria-label":s?"Close sessions":"Open sessions","aria-expanded":s,title:"Toggle sidebar",onClick:t,className:I(Wy,"md:-ml-1.5"),children:o.jsx($a,{"aria-hidden":!0,strokeWidth:1.5})}),o.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground md:font-light",children:"History"}),o.jsx("button",{type:"button","aria-label":"Refresh history",title:"Refresh",onClick:()=>{l.loadHistory()},disabled:!S,className:I(Wy,"md:-mr-1.5 disabled:opacity-45"),children:o.jsx(co,{"aria-hidden":!0,strokeWidth:1.5,className:I(d.status==="loading"&&"animate-spin")})})]}),o.jsx("div",{className:"px-3 pt-4 md:px-6",children:o.jsxs("div",{className:"flex h-9 w-full max-w-md items-center gap-2 rounded-lg border border-border bg-card px-2.5 focus-within:ring-1 focus-within:ring-ring",children:[o.jsx(Ws,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),o.jsx("input",{type:"search",value:x,onChange:O=>y(O.target.value),placeholder:"Search history","aria-label":"Search history","data-testid":"history-search",className:"min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden"}),x?o.jsx("button",{type:"button","aria-label":"Clear search",onClick:()=>y(""),className:I("flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",Nh),children:o.jsx(Zt,{"aria-hidden":!0,className:"size-3.5"})}):null]})}),o.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 pb-6 pt-4 md:px-6",children:[d.status==="loading"&&!d.list.length?o.jsx("div",{className:"flex justify-center py-16",children:o.jsx(Kt,{label:"Loading history…"})}):null,d.status==="error"&&!d.list.length?o.jsxs("div",{role:"alert",className:"flex flex-col items-center gap-4 py-16 text-sm text-muted-foreground",children:[o.jsxs("span",{children:["Unable to load sessions",d.error?.message?`: ${d.error.message}`:""]}),o.jsx(be,{variant:"ghost",onClick:()=>{l.loadHistory()},children:"Try again"})]}):null,d.status!=="loading"&&d.status!=="error"&&!R.length?o.jsxs("div",{className:"flex flex-col items-center gap-6 py-16 text-sm text-muted-foreground","data-testid":"history-empty",children:[o.jsx("span",{children:L?"No sessions match":"No sessions yet"}),L?o.jsx(be,{variant:"ghost",onClick:()=>y(""),children:"Clear search"}):o.jsxs(be,{variant:"ghost",onClick:a,children:[o.jsx(th,{"aria-hidden":!0})," Back"]})]}):null,R.map(O=>o.jsxs("section",{"aria-label":O.label,className:"mb-2",children:[o.jsx("h2",{className:"mb-2 mt-2 px-3 text-sm font-medium text-muted-foreground",children:O.label}),o.jsx("div",{className:"flex flex-col gap-1 md:gap-0",children:O.sessions.map(B=>o.jsx(A5,{session:B,project:q,selected:B.id===m,waiting:B.archived||!ic(u,B.id)?0:T5(u,B.id),reason:B.archived?void 0:ao(u,B.id),onOpen:()=>{l.selectSession(B.id),i()}},B.id))})]},O.id)),j&&d.nextCursor&&d.status==="ready"?o.jsxs("div",{className:"flex items-center justify-center gap-3 py-4","data-testid":"history-more",children:[o.jsx(be,{variant:"ghost",onClick:()=>{l.loadMoreHistory()},disabled:d.more==="loading"||!S,children:d.more==="loading"?"Loading...":"Load more"}),d.more==="error"?o.jsx("span",{role:"alert",className:"text-sm text-destructive",children:"Unable to load more sessions"}):null]}):null]})]})}function E5({sessionId:s}){const t=Oe(),{connection:i}=Me(),[a,l]=w.useState(!1),[u,d]=w.useState(null),h=async()=>{l(!0),d(null);try{await t.restoreSession(s)}catch(m){d(m instanceof Error?m.message:String(m))}finally{l(!1)}};return o.jsx("div",{className:"px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:px-4 md:pb-4",children:o.jsxs("div",{className:"mx-auto flex w-full max-w-(--content-width) flex-col gap-2",children:[o.jsxs("div",{className:"flex items-center justify-center gap-3 rounded-2xl border border-border bg-card px-4 py-3 md:px-6 md:py-4","data-testid":"archived-callout",children:[o.jsx("span",{className:"text-(length:--content-font-size) text-muted-foreground",children:"This session is archived"}),o.jsx(be,{size:"sm",variant:"secondary",disabled:a||i.phase!=="open",onClick:()=>{h()},children:"Unarchive"})]}),u?o.jsx("p",{role:"alert",className:"text-center text-sm text-destructive",children:u}):null]})})}function M5(s,{enabled:t=!0,allowInModal:i=[]}={}){const a=w.useRef(s);a.current=s;const l=w.useMemo(()=>ho(),[]);w.useEffect(()=>{if(!t)return;const u=d=>{if(d.defaultPrevented||d.isComposing||d.repeat)return;const h=m4(d,{mac:l,editable:f1(d.target)});!h||(document.querySelector("dialog[open]")||document.querySelector("[data-modal-overlay]"))&&!i.includes(h.binding.action)||a.current(h.binding,h.index)!==!1&&(d.preventDefault(),d.stopPropagation())};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[t,l,i.join(",")])}function z5({open:s,onClose:t}){const[i,a]=w.useState(""),l=w.useMemo(()=>ho(),[]);w.useEffect(()=>{s||a("")},[s]);const u=g4(l,i);return o.jsx(ti,{open:s,onClose:t,title:"Shortcuts",className:"w-[min(92vw,36rem)]",children:o.jsxs("div",{className:"space-y-4","data-testid":"keyboard-shortcuts-dialog",children:[o.jsxs("div",{className:"flex h-9 items-center gap-2 rounded-lg border border-border bg-card px-2.5 focus-within:ring-1 focus-within:ring-ring",children:[o.jsx(Ws,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),o.jsx("input",{type:"search",autoFocus:!0,value:i,onChange:d=>a(d.target.value),placeholder:"Search shortcuts",onKeyDown:d=>{d.key==="Escape"&&(d.preventDefault(),t())},"aria-label":"Search shortcuts",className:"min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden"})]}),u.map(d=>o.jsxs("section",{"aria-label":d.title,className:"space-y-2",children:[o.jsx("h3",{className:"text-xs font-medium text-muted-foreground",children:d.title}),o.jsx("div",{className:"overflow-hidden rounded-lg border border-secondary",children:d.rows.map(h=>o.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-secondary px-4 py-2.5 last:border-b-0","data-testid":"shortcut-row",children:[o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"block text-sm text-foreground",children:h.label}),"note"in h&&h.note?o.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:h.note}):null]}),o.jsx("kbd",{className:"shrink-0 rounded-md bg-secondary/60 px-1.5 py-0.5 font-sans text-xs text-muted-foreground",children:h.keys})]},h.id))})]},d.id)),u.length?null:o.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"No results"})]})})}const R5=5,_5=5,Jy=10,L5=s=>s.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);function O5(s,t){let i=0;for(const a of t)a===s[i]&&(i+=1);return i===s.length}function eb(s,t){const i=t.toLowerCase();if(!i)return;if(i===s)return 0;const a=L5(i);if(a.includes(s))return 1;if(i.startsWith(s))return 2;if(a.some(l=>l.startsWith(s)))return 3;if(i.includes(s))return 4;if(O5(s,i))return 6}function Uf(s,t,i=[]){const a=s.toLowerCase().split(/\s+/).filter(Boolean);let l=0;for(const u of a){let d;for(const h of t){const m=eb(u,h);m!==void 0&&(d===void 0||m<d)&&(d=m)}if(d===void 0)for(const h of i){const m=eb(u,h);m!==void 0&&(d===void 0||m+Jy<d)&&(d=m+Jy)}if(d===void 0)return;l+=d}return l}const tb=s=>s.bucket==="needs_input"?0:s.attention?1:s.bucket==="running"?2:3;function D5(s){return s.map((t,i)=>({session:t,index:i})).sort((t,i)=>tb(t.session)-tb(i.session)||(Date.parse(i.session.updatedAt??"")||0)-(Date.parse(t.session.updatedAt??"")||0)||t.index-i.index).map(t=>t.session)}function q5(s){const t=String(s).replace(/\\/g,"/"),i=t.lastIndexOf("/");return{path:t,title:i>=0?t.slice(i+1):t,subtitle:i>=0?t.slice(0,i):""}}function B5(s,t=null){return s.map(i=>{const l=i.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||i;return{path:i,title:l,subtitle:i,...i===t?{current:!0}:{}}})}const $5=(s,t)=>s.title.localeCompare(t.title,void 0,{numeric:!0,sensitivity:"base"})||s.subtitle.localeCompare(t.subtitle);function U5(s,t){const i=[...s].sort($5),a=t.trim();return a?i.map((l,u)=>({workspace:l,index:u,score:Uf(a,[l.title,l.subtitle])})).filter(l=>l.score!==void 0).sort((l,u)=>l.score-u.score||l.index-u.index).map(l=>l.workspace):i.slice(0,_5)}function H5({actions:s,sessions:t,query:i,workspaces:a=[],files:l,scope:u=null}){const d=i.trim(),h={id:"files",title:"Files",rows:(l??[]).map(j=>({kind:"file",item:j}))};if(u==="files")return l?.length?[h]:[];const m=[{id:"workspace",title:"Workspace actions",rank:-1,rows:[]},{id:"actions",title:"Actions",rank:0,rows:[]},{id:"alp",title:"ALP",rank:1,rows:[]}];for(const j of s){const A=m.find(q=>q.id===j.group);if(!A)continue;if(!d){j.always&&A.rows.push({row:{kind:"action",item:j},score:0});continue}const R=Uf(d,[j.label],j.keywords);R!==void 0&&A.rows.push({row:{kind:"action",item:j},score:R})}const p=j=>j.reduce((A,R)=>Math.min(A,R.score),1/0),y=m.filter(j=>j.rows.length).map(j=>({...j,rows:[...j.rows].sort((A,R)=>A.score-R.score)})).sort((j,A)=>d&&p(j.rows)-p(A.rows)||j.rank-A.rank).map(j=>({id:j.id,title:j.title,rows:j.rows.map(A=>A.row)})),v=D5(t),k=d?v.map((j,A)=>({session:j,index:A,score:Uf(d,[j.title],[j.id,j.subtitle??""])})).filter(j=>j.score!==void 0).sort((j,A)=>j.score-A.score||j.index-A.index).map(j=>j.session):v.slice(0,R5),S=U5(a,d);return S.length&&y.push({id:"workspaces",title:"Workspaces",rows:S.map(j=>({kind:"workspace",item:j}))}),k.length&&y.push({id:"sessions",title:"Sessions",rows:k.map(j=>({kind:"session",item:j}))}),d&&l?.length&&y.push(h),y}const I5=100,Jr=Object.freeze({entries:[],loading:!1,error:null,truncated:!1});class G5{state=Jr;#e=null;#j=null;#p=0;#n;#i;#m;#r;constructor({search:t,onChange:i=()=>{},debounceMs:a=I5}){this.#i=t,this.#m=i,this.#r=a}#f(t){this.state=t,this.#m(t)}update({enabled:t,source:i,query:a}){const l=t&&i?`${i}\0${a}`:null;if(l===this.#j)return;if(this.#j=l,this.#a(),!l){this.#e=null,this.state!==Jr&&this.#f(Jr);return}const u=this.#e===i;this.#e=i;const d=++this.#p;this.#f({entries:u?this.state.entries:[],loading:!0,error:null,truncated:u?this.state.truncated:!1});const h=async()=>{this.#n=void 0;try{const m=await this.#i(a);if(d!==this.#p)return;this.#f({entries:(m?.files??[]).map(p=>q5(p.path)),loading:!1,error:null,truncated:m?.truncated===!0})}catch(m){if(d!==this.#p)return;this.#f({entries:[],loading:!1,error:Be(m).message,truncated:!1})}};this.#n=setTimeout(()=>{h()},a.trim()?this.#r:0)}#a(){this.#n!==void 0&&clearTimeout(this.#n),this.#n=void 0,this.#p+=1}dispose(){this.#a(),this.#j=null}}function Y5({enabled:s,source:t,query:i,search:a}){const[l,u]=w.useState(Jr),d=w.useRef(a);d.current=a;const h=w.useRef(null);return h.current||(h.current=new G5({search:m=>d.current(m),onChange:u})),w.useEffect(()=>{h.current?.update({enabled:s,source:t,query:i})},[s,t,i]),w.useEffect(()=>()=>{h.current?.dispose()},[]),s&&t?l:Jr}function V5({open:s,scope:t=null,onClose:i,actions:a,sessions:l,workspaces:u=[],files:d,onOpenSession:h,onSelectWorkspace:m,onPickFile:p,mac:x}){const y=w.useRef(null),v=w.useRef(null),k=w.useRef(null),S=w.useRef(null),[j,A]=w.useState(""),[R,q]=w.useState(t),[L,O]=w.useState(0),B=w.useId(),_=!!d?.available,W=Y5({enabled:s&&_&&(R==="files"||!!j.trim()),source:d?.source??null,query:j,search:d?.search??(()=>Promise.resolve({files:[]}))});w.useEffect(()=>{const T=y.current;if(T&&(s&&!T.open&&(S.current=document.activeElement,A(""),q(t),O(0),T.showModal(),v.current?.focus()),!s&&T.open)){T.close(),A("");const z=S.current;S.current=null,z?.isConnected&&z.focus()}},[s]),w.useEffect(()=>{s&&t&&q(t)},[s,t]);const E=w.useMemo(()=>s?H5({actions:a.filter(T=>!T.disabled),sessions:l,query:j,workspaces:u,scope:R,..._?{files:W.entries}:{}}):[],[s,a,l,j,u,R,_,W.entries]),V=E.flatMap(T=>T.rows),U=Math.min(L,Math.max(0,V.length-1)),de=new Map(a.map(T=>[T.id,T]));w.useEffect(()=>{k.current?.querySelector(`[data-index="${U}"]`)?.scrollIntoView({block:"nearest"})},[U]);const J=T=>{const z=V[T];z&&(i(),z.kind==="session"?h(z.item.id):z.kind==="workspace"?m?.(z.item.path):z.kind==="file"?p?.(z.item.path):setTimeout(()=>de.get(z.item.id)?.run(),0))},me=T=>{if(T.key==="ArrowDown"||T.key==="ArrowUp"){if(T.preventDefault(),!V.length)return;const z=T.key==="ArrowDown"?1:-1;O((U+z+V.length)%V.length)}else T.key==="Enter"&&!T.nativeEvent.isComposing?(T.preventDefault(),J(U)):T.key==="Backspace"&&!j.trim()&&R?(T.preventDefault(),q(null),O(0)):T.key.toLowerCase()==="k"&&(x?T.metaKey:T.ctrlKey)&&!T.shiftKey&&!T.altKey?(T.preventDefault(),i()):T.code==="KeyP"&&(x?T.metaKey:T.ctrlKey)&&!T.shiftKey&&!T.altKey&&(T.preventDefault(),q("files"),O(0))},se=R==="files",fe=se?"Search files...":_?"Search commands, files, workspaces, and agents...":"Search commands, workspaces, sessions and agents...",H=_&&W.loading,P=se&&!_?"This host does not offer file search. Update ALP on the host to search the workspace's files.":(se||j.trim())&&W.error?W.error:null,oe=se?H?"":_&&!W.error?"No files":"":"No matches";let xe=-1;return o.jsx("dialog",{ref:y,"aria-label":"Command center","data-testid":"command-center-panel",onCancel:T=>{T.preventDefault(),i()},onClick:T=>{T.target===y.current&&i()},className:"mx-auto mt-12 mb-auto w-[min(92vw,640px)] max-h-[min(80dvh,560px)] overflow-hidden rounded-lg border border-border bg-popover p-0 text-popover-foreground shadow-2xl shadow-[var(--shadow)] backdrop:bg-black/50",children:s?o.jsxs("div",{className:"flex max-h-[min(80dvh,560px)] flex-col",onKeyDown:me,children:[o.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-4 py-3","data-testid":"command-center-header",children:[se?o.jsxs("button",{type:"button","aria-label":"Files",title:"Remove the Files scope","data-testid":"command-center-files-scope",onClick:()=>{q(null),O(0),v.current?.focus()},className:"flex h-7 shrink-0 items-center gap-1 rounded-md bg-secondary px-2 text-sm text-foreground hover:bg-secondary/80 outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[o.jsx(Da,{"aria-hidden":!0,className:"size-3.5"}),o.jsx("span",{children:"Files"}),o.jsx(Zt,{"aria-hidden":!0,className:"size-3"})]}):null,o.jsx("input",{ref:v,type:"text",role:"combobox","aria-expanded":!0,"aria-controls":B,"aria-activedescendant":V.length?`${B}-${U}`:void 0,"aria-label":se?"Search files":"Search commands and sessions",placeholder:fe,value:j,autoComplete:"off",spellCheck:!1,onChange:T=>{A(T.target.value),O(0)},"data-testid":"command-center-input",className:"min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground"}),o.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center","data-testid":"command-center-file-search-status",children:H?o.jsx("span",{role:"progressbar","aria-label":"Searching files...",title:"Searching files...","data-testid":"command-center-file-search-loading",children:o.jsx(uc,{"aria-hidden":!0,className:"size-3.5 animate-spin text-muted-foreground"})}):null})]}),P?o.jsx("p",{role:W.error?"alert":"note",className:"shrink-0 border-b border-border px-4 py-2 text-xs text-muted-foreground","data-testid":"command-center-file-search-error",children:P}):null,o.jsx("div",{ref:k,id:B,role:"listbox","aria-label":"Results",className:"min-h-0 flex-1 overflow-y-auto py-1","data-testid":"command-center-results",children:V.length===0?oe?o.jsx("p",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:oe}):null:E.map((T,z)=>o.jsxs("div",{role:"group","aria-label":T.title,className:I(z>0&&"mt-1 border-t border-border pt-1"),children:[o.jsx("div",{className:"px-4 pb-1 pt-2 text-xs text-muted-foreground","aria-hidden":!0,children:T.title}),T.rows.map(F=>{xe+=1;const Z=xe,ie=Z===U;if(F.kind==="session")return o.jsxs("div",{id:`${B}-${Z}`,role:"option","aria-selected":ie,"data-index":Z,"data-testid":`command-center-session-${F.item.id}`,onMouseMove:()=>{ie||O(Z)},onClick:()=>J(Z),className:I("flex min-h-14 cursor-pointer items-center gap-3 px-4 py-2",ie&&"bg-secondary"),children:[o.jsx(xh,{bucket:F.item.bucket}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"truncate text-sm leading-[18px] text-foreground",children:F.item.title}),F.item.subtitle?o.jsx("div",{className:"truncate text-xs leading-4 text-muted-foreground","data-testid":"command-center-session-subtitle",children:F.item.subtitle}):null]})]},`session:${F.item.id}`);if(F.kind==="workspace"||F.kind==="file"){const ve=F.item,Re=F.kind==="workspace"?Da:a0,Ne=F.kind==="workspace"&&F.item.current;return o.jsxs("div",{id:`${B}-${Z}`,role:"option","aria-selected":ie,"data-index":Z,"data-testid":`command-center-${F.kind}`,"data-path":ve.path,"aria-current":Ne?"true":void 0,onMouseMove:()=>{ie||O(Z)},onClick:()=>J(Z),className:I("flex min-h-11 cursor-pointer items-center gap-3 px-4 py-2",ie&&"bg-secondary"),children:[o.jsx("span",{className:"flex w-4 shrink-0 justify-center text-muted-foreground",children:o.jsx(Re,{"aria-hidden":!0,className:"size-4"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"truncate text-sm leading-[18px] text-foreground",children:ve.title}),ve.subtitle?o.jsx("div",{className:"truncate text-xs leading-4 text-muted-foreground",children:ve.subtitle}):null]}),Ne?o.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:"Current"}):null]},`${F.kind}:${ve.path}`)}const le=de.get(F.item.id)?.icon;return o.jsxs("div",{id:`${B}-${Z}`,role:"option","aria-selected":ie,"data-index":Z,"data-testid":`command-center-action-${F.item.id}`,onMouseMove:()=>{ie||O(Z)},onClick:()=>J(Z),className:I("flex min-h-9 cursor-pointer items-center gap-3 px-4 py-2",ie&&"bg-secondary"),children:[o.jsx("span",{className:"flex w-4 shrink-0 justify-center text-muted-foreground",children:le?o.jsx(le,{"aria-hidden":!0,className:"size-4"}):null}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-sm leading-[18px] text-foreground",children:F.item.label}),F.item.shortcut?o.jsx("kbd",{className:"shrink-0 rounded bg-secondary px-1.5 py-px font-sans text-xs text-muted-foreground",children:F.item.shortcut}):null]},`action:${F.item.id}`)})]},T.id))})]}):null})}const Th=w.createContext({id:oo,focused:!0}),K5=()=>w.useContext(Th).focused,Rl=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent);function Z1({meter:s,imageLimits:t,images:i=!1,imagesUnavailable:a,files:l=!1,fileLimits:u,filesUnavailable:d,onSend:h,onQueue:m,onInterruptSend:p,onStop:x,queued:y,onEditQueued:v,onSendQueued:k,running:S,stopping:j,blocked:A,disabledReason:R,placeholder:q,controls:L,tracks:O,onCycleMode:B,sendBehavior:_="steer",sendShortcut:W="enter",startLabel:E,startHold:V,initialText:U,addText:de,autoFocus:J,inputId:me}){const[se,fe]=w.useState(U??"");w.useEffect(()=>{de&&fe(he=>he.trim()?`${he.replace(/\s+$/,"")}
|
|
45
|
+
|
|
46
|
+
${de.text}`:de.text)},[de]);const[H,P]=w.useState(null),[oe,xe]=w.useState([]),[T,z]=w.useState([]),F=w.useRef(null),Z=w.useRef(null),ie=A??R,re=!!se.trim()||oe.length>0||T.length>0,le=!oe.length&&!T.length,ve=S&&_==="queue"&&le,Re=S&&_==="interrupt"&&le&&!!p,Ne=w.useRef(oe),et=w.useRef(t);et.current=t;const Ue=he=>{Ne.current=he,xe(he)},Qe=w.useRef(T),We=w.useRef(u??Ks);We.current=u??Ks;const ye=he=>{Qe.current=he,z(he)},ge=async he=>{if(!he.length||ie)return;const Ae=[],ht=[];let jt=null;for(const C of he)i&&(zb(C)||!l&&C.type.startsWith("image/"))?Ae.push(C):l?ht.push(C):jt??=!i&&C.type.startsWith("image/")?a??"This session takes no images.":d??a??"This session takes no files.";let bt=null;if(Ae.length){const{added:C,error:G}=await fj(Ne.current,Ae,et.current),{attachments:ce,error:ue}=Xr(Ne.current,C,et.current);Ue(ce),bt??=G??ue}if(ht.length){const{added:C,error:G}=await vj(Qe.current,ht,We.current),{attachments:ce,error:ue}=Ol(Qe.current,C,We.current);ye(ce),bt??=G??ue}P(jt??bt)},[Ce,je]=w.useState(!1),Ut=K5(),ln=w.useId(),ze=me??`composer-${ln}`,it=w.useRef({running:S,stopping:j,blocked:A,onStop:x,paneFocused:Ut});it.current={running:S,stopping:j,blocked:A,onStop:x,paneFocused:Ut},w.useEffect(()=>{const he=Ae=>{if(Ae.defaultPrevented||Ae.isComposing||!it.current.paneFocused)return;if(Ae.key.toLowerCase()==="l"&&(Rl?Ae.metaKey&&!Ae.ctrlKey:Ae.ctrlKey&&!Ae.metaKey)&&!Ae.altKey&&!Ae.shiftKey){if(!Z.current||Z.current.disabled)return;Ae.preventDefault(),Z.current.focus();return}if(Ae.key!=="Escape")return;const{running:ht,stopping:jt,blocked:bt,onStop:C}=it.current,G=Ae.target,ce=G===Z.current,ue=G===document.body||G===document.documentElement||G===null;!ht||jt||bt||!(ce||ue)||document.querySelector('[role="dialog"], [role="menu"]')||C()};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[]),w.useLayoutEffect(()=>{const he=Z.current;he&&(he.style.height="auto",he.style.height=`${Math.min(he.scrollHeight,280)}px`)},[se]);const gt=async()=>{const he=se.trim(),Ae=Ne.current,ht=Qe.current;if(!he&&!Ae.length&&!ht.length&&!E||ie||E&&V)return;const jt=Xr([],Ae,et.current);if(jt.error){P(jt.error);return}if(ht.length){if(!l){P(d??"This session takes no files.");return}const bt=Ol([],ht,We.current);if(bt.error){P(bt.error);return}}fe(""),Ue([]),ye([]),P(null);try{await h(he,Ae,ht)}catch(bt){fe(he),Ue(Xr(Ae,Ne.current,et.current).attachments),ye(Ol(ht,Qe.current,We.current).attachments),P(bt instanceof Error?bt.message:String(bt))}},At=()=>{const he=se.trim();if(Ne.current.length||Qe.current.length)return void gt();if(!(!he||ie))try{m(he),fe(""),P(null)}catch(Ae){P(Ae instanceof Error?Ae.message:String(Ae))}},$n=()=>{const he=se.trim();if(Ne.current.length||Qe.current.length||!p)return void gt();if(!(!he||ie))try{p(he),fe(""),P(null)}catch(Ae){P(Ae instanceof Error?Ae.message:String(Ae))}},_n=()=>S?_==="queue"?At():_==="interrupt"?$n():void gt():void gt(),cn=()=>_==="queue"?void gt():At(),xt=Rl?"⌘":"Ctrl",zt=S?ve?"Queue message":Re?"Interrupt and send":"Send and steer":"Send",Ct=!S||W==="mod-enter"?zt:`${zt} (${xt}+Enter ${_==="queue"?"sends and steers":"queues"})`,Un=he=>{const Ae=v(he);Ae!=null&&(fe(ht=>ht.trim()?`${ht}
|
|
47
|
+
${Ae}`:Ae),Z.current?.focus())},vn="inline-flex size-7 shrink-0 items-center justify-center rounded-full transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4";return o.jsx("div",{className:"px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:px-4 md:pb-4",children:o.jsxs("div",{className:"mx-auto flex w-full max-w-(--content-width) flex-col gap-3",children:[O?o.jsx("div",{className:"-mb-1 flex min-w-0 flex-wrap items-center gap-2","data-testid":"composer-tracks",children:O}):null,y.length?o.jsx("ul",{"aria-label":"Queued messages",className:"flex flex-col gap-2",children:y.map(he=>o.jsxs("li",{"data-testid":"queued-message",className:"flex items-center justify-between gap-2 rounded-lg border border-border bg-card px-3 py-2",children:[o.jsx("span",{className:"line-clamp-2 min-w-0 flex-1 whitespace-pre-wrap text-sm text-foreground [overflow-wrap:anywhere]",children:he.text}),o.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[o.jsx("button",{type:"button","aria-label":"Edit queued message",title:"Edit",onClick:()=>Un(he.id),className:"flex size-8 items-center justify-center rounded-full bg-muted text-foreground outline-none hover:bg-bubble focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5",children:o.jsx($i,{"aria-hidden":!0})}),o.jsx("button",{type:"button","aria-label":"Send queued message now",title:"Send now",disabled:!!ie,onClick:()=>k(he.id),className:"flex size-8 items-center justify-center rounded-full bg-primary text-primary-foreground outline-none hover:bg-primary/85 focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-3.5",children:o.jsx(Dl,{"aria-hidden":!0})})]})]},he.id))}):null,A?o.jsx("p",{className:"px-1 text-sm text-warning",role:"note",children:A}):null,H?o.jsx("p",{className:"px-1 text-sm text-destructive",role:"alert",children:H}):null,o.jsxs("div",{className:I("relative flex flex-col gap-3 rounded-2xl border border-input bg-card px-3 py-2 transition-colors duration-200 focus-within:border-[var(--input-focus)] md:px-4 md:pb-3 md:pt-4",ie&&"border-dotted"),"data-testid":"composer-box",onDragOver:he=>{Array.from(he.dataTransfer?.types??[]).includes("Files")&&he.preventDefault()},onDrop:he=>{const Ae=Ox(he.dataTransfer);Ae.length&&(he.preventDefault(),ge(Ae))},children:[oe.length?o.jsx("ul",{"aria-label":"Attached images",className:"flex flex-wrap gap-2",children:oe.map(he=>o.jsxs("li",{"data-testid":"composer-attachment",className:"relative size-16 overflow-hidden rounded-lg border border-border bg-muted",children:[o.jsx("img",{src:_b(he),alt:he.name,title:he.name,className:"size-full object-cover"}),o.jsx("button",{type:"button","aria-label":`Remove ${he.name}`,title:"Remove",onClick:()=>Ue(Ne.current.filter(Ae=>Ae.id!==he.id)),className:"absolute right-0.5 top-0.5 flex size-5 items-center justify-center rounded-full bg-background/90 text-foreground outline-none hover:bg-background focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3",children:o.jsx(Zt,{"aria-hidden":!0})})]},he.id))}):null,T.length?o.jsx("ul",{"aria-label":"Attached files",className:"flex flex-wrap gap-2",children:T.map(he=>o.jsxs("li",{"data-testid":"composer-file",className:"flex h-9 max-w-[16rem] items-center gap-2 rounded-lg border border-border bg-muted pl-2 pr-1 text-[length:calc(13px*var(--ui-scale))] text-foreground",children:[o.jsx(sh,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),o.jsx("span",{className:"min-w-0 truncate",title:he.name,children:he.name}),o.jsx("span",{className:"shrink-0 text-muted-foreground",children:Lb(he.size)}),o.jsx("button",{type:"button","aria-label":`Remove ${he.name}`,title:"Remove",onClick:()=>ye(Qe.current.filter(Ae=>Ae.id!==he.id)),className:"flex size-6 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none hover:bg-background hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3",children:o.jsx(Zt,{"aria-hidden":!0})})]},he.id))}):null,!Ce&&!se&&!ie?o.jsxs("span",{"aria-hidden":!0,className:"pointer-events-none absolute right-4 top-3 hidden text-xs text-muted-foreground/80 [@media(pointer:fine)]:md:block","data-testid":"composer-focus-hint",children:[Rl?"⌘L":"Ctrl+L"," to focus"]}):null,o.jsx("label",{htmlFor:ze,className:"sr-only",children:"Message"}),o.jsx("textarea",{id:ze,ref:Z,rows:1,value:se,disabled:!!ie,placeholder:ie&&!A?ie:q,onChange:he=>fe(he.target.value),onPaste:he=>{const Ae=Ox(he.clipboardData).filter(ht=>l||ht.type.startsWith("image/"));Ae.length&&(he.preventDefault(),ge(Ae))},onFocus:()=>je(!0),onBlur:()=>je(!1),autoFocus:J,"aria-keyshortcuts":Rl?"Meta+L":"Control+L",onKeyDown:he=>{if(he.key==="Tab"&&he.shiftKey&&B&&!he.nativeEvent.isComposing){he.preventDefault(),he.repeat||B();return}if(he.key!=="Enter"||he.shiftKey||he.nativeEvent.isComposing)return;const Ae=he.metaKey||he.ctrlKey;W==="mod-enter"&&!Ae||(he.preventDefault(),W==="enter"&&Ae&&S?cn():_n())},className:"max-h-[280px] min-h-[21px] w-full resize-none bg-transparent text-(length:--content-font-size) leading-[1.4] text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed"}),o.jsxs("div",{className:"-mx-1.5 flex min-h-7 shrink-0 items-end justify-between",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 items-end",children:[l||i&&!E?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button","aria-label":l?"Attach files":"Attach images",title:l?"Attach files":"Attach images",disabled:!!ie,onClick:()=>F.current?.click(),className:I(vn,"mr-1 text-muted-foreground hover:bg-muted hover:text-foreground"),"data-testid":"composer-attach",children:o.jsx(vs,{"aria-hidden":!0})}),o.jsx("input",{ref:F,type:"file",accept:l?void 0:Mb.join(","),multiple:!0,hidden:!0,"data-testid":"composer-attach-input",onChange:he=>{const Ae=Array.from(he.target.files??[]);he.target.value="",ge(Ae)}})]}):null,L]}),o.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,E?o.jsx("button",{type:"button","aria-label":E,title:V??E,onClick:()=>{gt()},disabled:!!ie||!!V,className:I(vn,"ml-1 bg-primary text-primary-foreground hover:bg-primary/85"),"data-testid":"composer-start",children:o.jsx(Dl,{"aria-hidden":!0})}):re?o.jsx("button",{type:"button","aria-label":zt,title:Ct,onClick:_n,disabled:!!ie,className:I(vn,"ml-1 bg-primary text-primary-foreground hover:bg-primary/85"),children:o.jsx(Dl,{"aria-hidden":!0})}):S?o.jsx("button",{type:"button","aria-label":"Interrupt agent",title:"Interrupt agent",onClick:x,disabled:j||!!A,className:I(vn,"ml-1 bg-[#dc2626] text-white hover:bg-[#dc2626]/85"),children:o.jsx(iN,{"aria-hidden":!0,className:"fill-current"})}):null]})]})]})]})})}const nb=["approve","review","progress","ready","blocked"];function sb(s){return s.status==="closed"?"closed":s.approvals?.length?"approve":s.status==="review"?"review":s.status==="in_progress"?"progress":s.type==="epic"?s.progress?.done?"progress":"ready":s.ready?"ready":"blocked"}function F5(s,t){const i=new Map(t.map(p=>[p.id,p])),a=s.map(p=>{const x=i.get(p.id),y=x?sb(x):p.status==="completed"?"closed":p.status==="in_progress"?"progress":"ready";return{id:p.id,title:x?.title??p.text,state:y}}),l=new Set(a.map(p=>p.id)),u=t.filter(p=>p.status!=="closed"&&p.type!=="epic").map(p=>({id:String(p.id),title:String(p.title??p.id),state:sb(p),priority:typeof p.priority=="number"?p.priority:9})).sort((p,x)=>nb.indexOf(p.state)-nb.indexOf(x.state)||p.priority-x.priority||p.id.localeCompare(x.id)).map(({id:p,title:x,state:y})=>({id:p,title:x,state:y})),d=a.filter(p=>p.state==="closed").length,h=a.length?`Tasks · ${d}/${a.length}`:u.length?`Tasks · ${u.length}`:"Tasks",m=a.length?`ALP tasks: ${d} of ${a.length} done in this session, ${u.length} open`:u.length?`ALP tasks: ${u.length} open`:"ALP tasks";return{label:h,title:m,mine:a.length,lines:[...a,...u.filter(p=>!l.has(p.id))]}}const ib={approve:{label:"Approve",icon:o0},review:{label:"Review",icon:lo},progress:{label:"In progress",icon:uc},ready:{label:"Ready",icon:lc},blocked:{label:"Blocked",icon:n0},closed:{label:"Done",icon:vS}},ab=8,X5=2e4,P5="inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border border-border bg-card px-3 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-expanded:bg-muted aria-expanded:text-foreground [&_svg]:size-3.5 [&_svg]:shrink-0";function Q5({worked:s}){const t=Oe(),{tasks:i}=Me(),{openTask:a,openPanel:l}=kt(),u=t.tasksBlock();if(w.useEffect(()=>{if(u)return;t.refreshTasks({quiet:!0});const p=window.setInterval(()=>{t.getState().connection.phase==="open"&&t.refreshTasks({quiet:!0})},X5);return()=>window.clearInterval(p)},[t,u]),u)return null;const d=F5(s,i.rows),h=d.lines.slice(0,ab),m=d.lines.length-ab;return o.jsx(Vt,{label:"Tasks",title:d.title,align:"start",triggerClassName:I(P5),onOpenChange:p=>{p&&t.refreshTasks({quiet:!0})},trigger:o.jsxs(o.Fragment,{children:[o.jsx(qi,{"aria-hidden":!0}),o.jsx("span",{className:"truncate","data-testid":"tasks-pill-label",children:d.label})]}),items:[...h.map((p,x)=>{const y=ib[p.state].icon;return{id:`task:${p.id}`,label:`${ib[p.state].label} · ${p.title}`,icon:o.jsx(y,{"aria-hidden":!0}),onSelect:()=>a(p.id),group:x===d.mine&&x>0}}),{id:"all-tasks",label:m>0?`All tasks (${m} more)`:"All tasks",icon:o.jsx(qi,{"aria-hidden":!0}),onSelect:()=>l("tasks"),group:h.length>0}]})}const eo=s=>typeof s=="number"&&Number.isFinite(s)&&s>=0?s:null;function J1(s){const t=eo(s?.contextWindowUsedTokens),i=eo(s?.contextWindowMaxTokens);if(t===null||i===null||i<=0)return null;const a=t/i*100;return{percentage:Math.round(a),share:a,usedTokens:t,maxTokens:i}}const W5=s=>Math.max(0,Math.min(100,s));function rb(s){return s>90?"danger":s>=70?"warning":"normal"}function to(s){return s>=1e6?`${Math.round(s/1e6)}m`:s>=1e3?`${Math.round(s/1e3)}k`:Math.round(s).toString()}function Z5(s){return typeof s!="number"||!Number.isFinite(s)||s<=0?null:s<.01?`$${s.toFixed(4)}`:`$${s.toFixed(2)}`}function J5(s){const t=eo(s?.inputTokens),i=eo(s?.cachedInputTokens),a=eo(s?.outputTokens),l=[];return t!==null&&l.push(`${to(t)} input${i?` (${to(i)} cached)`:""}`),a!==null&&l.push(`${to(a)} output`),l.length?l.join(" · "):null}function eA(s){const t=J1(s);return t?`Context window ${t.percentage}% used`:"Context window: No context data"}const Ca=14,Hf=2,If=(Ca-Hf)/2,lf=2*Math.PI*If,tA={normal:"text-muted-foreground",warning:"text-warning",danger:"text-destructive"};function ob({usage:s,className:t}){const[i,a]=w.useState(!1),l=w.useId(),u=J1(s),d=Z5(s?.totalCostUsd),h=J5(s),m=u?W5(u.share):0,p=Ca/2;return o.jsxs("div",{className:I("relative flex",t),onPointerEnter:x=>{x.pointerType==="mouse"&&a(!0)},onPointerLeave:x=>{x.pointerType==="mouse"&&a(!1)},children:[o.jsx("button",{type:"button","aria-label":eA(s),"aria-describedby":i?l:void 0,"data-testid":"context-window-meter","data-level":u?rb(u.share):"none",onFocus:()=>a(!0),onBlur:()=>a(!1),onClick:()=>a(!0),onKeyDown:x=>{x.key==="Escape"&&i&&(x.preventDefault(),a(!1))},className:"inline-flex size-7 shrink-0 items-center justify-center rounded-full outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring",children:o.jsxs("svg",{width:Ca,height:Ca,viewBox:`0 0 ${Ca} ${Ca}`,"aria-hidden":!0,children:[o.jsx("circle",{cx:p,cy:p,r:If,fill:"none",stroke:"currentColor",strokeWidth:Hf,className:"text-muted"}),u?o.jsx("circle",{cx:p,cy:p,r:If,fill:"none",stroke:"currentColor",strokeWidth:Hf,strokeLinecap:"round",strokeDasharray:lf,strokeDashoffset:lf-m/100*lf,transform:`rotate(-90 ${p} ${p})`,className:tA[rb(u.share)],"data-testid":"context-window-ring"}):null]})}),i?o.jsxs("div",{role:"tooltip",id:l,"data-testid":"context-window-details",className:"absolute bottom-full right-0 z-50 mb-2 flex w-max min-w-[200px] max-w-[300px] flex-col gap-1.5 rounded-lg border border-border bg-popover px-2 py-1 text-popover-foreground shadow-md",children:[o.jsx("span",{className:"text-sm text-foreground",children:"Context window"}),u?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"text-sm text-foreground",children:[u.percentage,"% used"]}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:[to(u.usedTokens)," / ",to(u.maxTokens)," tokens"]})]}):o.jsx("span",{className:"text-xs text-muted-foreground",children:"No context data"}),h?o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last reported ",h]}):null,d?o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Session cost ",d]}):null]}):null]})}function nA({question:s,onAnswer:t,onDecline:i,busy:a,blocked:l}){const[u,d]=w.useState(null),[h,m]=w.useState(""),[p,x]=w.useState(null);w.useEffect(()=>{a||x(null)},[a]);const y=a||!!l,v=w.useId(),k=s.options??[],S=h.trim()||(u!=null?k[u]:""),j=()=>{S&&!y&&(x("submit"),t(S))},A=()=>{y||(x("dismiss"),i())},R=s.agent&&s.agent!=="main"?s.agent:null;return o.jsxs("section",{"aria-label":`Question from ${s.agent}`,className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-3","data-testid":"question",children:[o.jsxs("div",{className:"flex flex-col gap-1 px-3 pt-1",children:[R?o.jsxs("p",{className:"text-[length:calc(13px*var(--ui-scale))] text-muted-foreground",children:[R," asks"]}):null,o.jsx("p",{className:"whitespace-pre-wrap text-(length:--content-font-size) leading-[1.467] text-foreground [overflow-wrap:anywhere]","data-testid":"question-text",children:s.body})]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[k.length?o.jsx("div",{className:"flex flex-col gap-1",role:"radiogroup","aria-label":s.body,onKeyDown:q=>{if(!["ArrowDown","ArrowUp","ArrowRight","ArrowLeft"].includes(q.key))return;q.preventDefault();const L=q.key==="ArrowDown"||q.key==="ArrowRight"?1:-1,O=((u??(L>0?-1:0))+L+k.length)%k.length;d(O),m(""),q.currentTarget.querySelectorAll('[role="radio"]')[O]?.focus()},children:k.map((q,L)=>{const O=u===L;return o.jsxs("button",{type:"button",role:"radio","aria-checked":O,disabled:y,tabIndex:O||u==null&&L===0?0:-1,onClick:()=>{d(O?null:L),m("")},className:I("flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-(length:--content-font-size) leading-[1.467] outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring active:opacity-90 disabled:pointer-events-none disabled:opacity-50",O?"bg-muted text-foreground":"text-muted-foreground"),children:[o.jsx("span",{"aria-hidden":!0,className:I("flex size-[18px] shrink-0 items-center justify-center rounded-full border",O?"border-primary":"border-input"),children:O?o.jsx("span",{className:"size-2.5 rounded-full bg-primary"}):null}),o.jsx("span",{className:"min-w-0 flex-1 [overflow-wrap:anywhere]",children:q})]},`${L}:${q}`)})}):null,o.jsx("label",{htmlFor:v,className:"sr-only",children:k.length?"Other answer":"Your answer"}),o.jsx("input",{id:v,value:h,disabled:y,autoComplete:"off",onChange:q=>{m(q.target.value),q.target.value&&d(null)},onKeyDown:q=>{q.key==="Enter"&&!q.nativeEvent.isComposing&&(q.preventDefault(),j())},placeholder:k.length?"Other...":"Type your answer...",className:"w-full rounded-lg border border-transparent bg-muted p-3 text-(length:--content-font-size) text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-input disabled:cursor-not-allowed disabled:opacity-50"})]}),o.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[o.jsx("button",{type:"button",disabled:y,onClick:A,className:"flex min-h-9 items-center justify-center gap-2 rounded-md border border-input bg-card px-3 py-2 text-sm text-muted-foreground outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",children:p==="dismiss"&&a?o.jsx(Kt,{label:""}):o.jsxs(o.Fragment,{children:[o.jsx(Zt,{"aria-hidden":!0,className:"size-3.5"}),"Dismiss"]})}),o.jsx("button",{type:"button",disabled:y||!S,onClick:j,className:I("flex min-h-9 items-center justify-center gap-2 rounded-md border border-primary bg-primary px-3 py-2 text-sm text-primary-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring active:opacity-90",(y||!S)&&"pointer-events-none opacity-50"),children:p==="submit"&&a?o.jsx(Kt,{label:"",className:"text-primary-foreground"}):o.jsxs(o.Fragment,{children:[o.jsx(oc,{"aria-hidden":!0,className:"size-3.5"}),"Submit"]})})]}),l?o.jsx("p",{className:"px-1 text-xs text-muted-foreground",children:l}):null]})}const sA=/^(.+?):(\d+)(?::\d+)?(?:-(\d+)(?::\d+)?)?$/,iA=/^L(\d+)(?:C\d+)?(?:-L?(\d+)(?:C\d+)?)?$/i,aA=/^[a-z][a-z0-9+-]*:/i,rA=/\.[a-z0-9_+-]{1,12}$/i;function oA(s){try{return decodeURIComponent(s)}catch{return s}}function lb(s,t){const i=s?Number(s):void 0,a=t?Number(t):void 0;return i!==void 0&&(!Number.isSafeInteger(i)||i<=0)||a!==void 0&&(!Number.isSafeInteger(a)||i===void 0||a<i)?null:{...i?{line:i}:{},...a&&a!==i?{lineEnd:a}:{}}}const lA=s=>s.replace(/\/+$/,"");function cA(s,{roots:t,kind:i}){let a=String(s??"").trim().replace(/^['"`]+|['"`]+$/g,"");if(!a||a.length>4096||/\s/.test(a))return;if(i==="href"){if(/^file:\/\//i.test(a))a=a.replace(/^file:\/\/(localhost)?/i,"");else if(aA.test(a)&&!/^[a-zA-Z]:[\\/]/.test(a))return;a=oA(a)}else if(a.includes("://"))return;if(a.startsWith("~")||a.startsWith("#"))return;let l={};const u=a.indexOf("#");if(u>=0){const m=iA.exec(a.slice(u+1)),p=m?lb(m[1],m[2]):null;if(!p)return;l=p,a=a.slice(0,u)}else{const m=sA.exec(a);if(m){const p=lb(m[2],m[3]);if(!p)return;l=p,a=m[1]}}let d=a;if(d.startsWith("/")){const m=t.map(lA).filter(Boolean).find(p=>d.startsWith(`${p}/`));if(!m)return;d=d.slice(m.length+1)}const h=Qs(d);if(!(!h||Bi(h))&&!(i==="code"&&(!h.includes("/")&&!a.startsWith("./")||!rA.test(h.split("/").pop()??"")&&!("line"in l))))return{path:h,...l}}function ev(s){if(!Number.isFinite(s)||s<0)return"0s";const t=Math.floor(s/1e3);if(t<60)return`${t}s`;const i=Math.floor(t/60);if(i<60)return t%60?`${i}m ${t%60}s`:`${i}m`;const a=Math.floor(i/60);return i%60?`${a}h ${i%60}m`:`${a}h`}const Gf=950,uA=[[1,0,.78,0,.56,.34],[.78,1,.56,0,.34,0],[.56,.78,.34,1,0,0],[.34,.56,0,.78,0,1],[0,.34,0,.56,1,.78],[0,0,1,.34,.78,.56]],cb=()=>Math.floor(Date.now()%Gf*6/Gf);function Ah({size:s=14,className:t}){const[i,a]=w.useState(cb);w.useEffect(()=>{if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;const d=window.setInterval(()=>a(cb()),Gf/6);return()=>window.clearInterval(d)},[]);const l=Math.max(1,Math.round(s*.12)),u=Math.max(2,(s-l*2)/3);return o.jsx("span",{"aria-hidden":!0,className:I("relative inline-flex shrink-0 items-center justify-center",t),style:{width:s,height:s},children:o.jsx("span",{className:"relative",style:{width:u*2+l,height:u*3+l*2},children:uA[i].map((d,h)=>o.jsx("span",{className:"absolute rounded-full bg-current transition-opacity duration-100",style:{width:u,height:u,left:h%2*(u+l),top:Math.floor(h/2)*(u+l),opacity:d}},h))})})}function dA({since:s,className:t}){const[i,a]=w.useState(Date.now);return w.useEffect(()=>{const l=window.setInterval(()=>a(Date.now()),1e3);return()=>window.clearInterval(l)},[]),o.jsx("span",{className:I("tabular-nums",t),children:ev(i-s)})}function tv({text:s,label:t,className:i}){const[a,l]=w.useState(!1),u=w.useRef(void 0);return w.useEffect(()=>()=>window.clearTimeout(u.current),[]),o.jsx("button",{type:"button","aria-label":a?"Copied":t,title:a?"Copied":t,onClick:()=>{const d=s();d&&navigator.clipboard?.writeText(d).then(()=>{l(!0),window.clearTimeout(u.current),u.current=window.setTimeout(()=>l(!1),1500)}).catch(()=>{})},className:I("flex shrink-0 items-center justify-center rounded p-1 text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5",i),children:a?o.jsx(oc,{"aria-hidden":!0}):o.jsx(bs,{"aria-hidden":!0})})}function ub({children:s,tone:t}){return o.jsx("pre",{className:I("max-h-[360px] overflow-auto bg-card p-3 font-mono text-(length:--code-font-size) leading-[1.5] whitespace-pre",t==="error"?"text-destructive":"text-foreground"),children:s})}function nv(s){const[t,i]=w.useState(Bn),{shown:a,hidden:l}=G1(s,t),u=l?o.jsxs("button",{type:"button","data-testid":"tool-detail-more",onClick:()=>i(d=>d+Bn),className:"sticky left-0 block px-3 py-1.5 font-sans text-xs text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[`Show ${Math.min(l,Bn)} more line${Math.min(l,Bn)===1?"":"s"}`,l>Bn?` (${l} hidden)`:""]}):null;return{shown:a,more:u}}const sv="max-h-[360px] overflow-auto bg-card font-mono text-(length:--code-font-size) leading-[1.5] text-foreground";function Ps({text:s,startLine:t,testId:i,filename:a}){const l=w.useMemo(()=>tc(s),[s]),u=mc(w.useMemo(()=>l.join(`
|
|
48
|
+
`),[l]),a),d=u?.length===l.length?u:null,{shown:h,more:m}=nv(l),p=t!=null?String(t+l.length-1).length:0;return o.jsxs("div",{className:sv,"data-testid":i,children:[o.jsx("div",{className:"min-w-max py-2",children:h.map((x,y)=>o.jsxs("div",{className:"flex whitespace-pre px-3",children:[t!=null?o.jsx("span",{"aria-hidden":!0,className:"mr-3 shrink-0 select-none text-right text-muted-foreground tabular-nums",style:{minWidth:`${p}ch`},children:t+y}):null,o.jsx("span",{children:d?.[y]?.length?o.jsx(pc,{tokens:d[y]}):x||" "})]},y))}),m]})}const db={add:"bg-[rgba(46,160,67,0.15)]",remove:"bg-[rgba(248,81,73,0.15)]",context:"",hunk:"bg-muted/60 text-muted-foreground",file:"bg-muted font-sans font-medium",meta:"text-muted-foreground italic"},fA={add:"+",remove:"-",context:" ",hunk:"",file:"",meta:""};function hA({detail:s}){const{lines:t,numbered:i}=w.useMemo(()=>Y1(s),[s]),a=w.useMemo(()=>t.filter(x=>x.type==="add"||x.type==="remove"||x.type==="context"),[t]),l=mc(w.useMemo(()=>a.map(x=>x.text).join(`
|
|
49
|
+
`),[a]),typeof s?.filePath=="string"?s.filePath:null),u=w.useMemo(()=>{const x=new Map;return l?.length===a.length&&a.forEach((y,v)=>x.set(y,l[v])),x},[a,l]),{shown:d,more:h}=nv(t);if(!t.length)return o.jsx(iv,{children:"No changes to show."});const m=i?String(Math.max(0,...t.map(x=>Math.max(x.oldLine??0,x.newLine??0)))).length:0,p=x=>i?o.jsx("span",{"aria-hidden":!0,className:"shrink-0 select-none pr-2 text-right text-muted-foreground tabular-nums",style:{minWidth:`${m+1}ch`},children:x??""}):null;return o.jsxs("div",{className:sv,"data-testid":"tool-diff",children:[o.jsx("div",{className:"min-w-max py-2",children:d.map((x,y)=>x.type==="hunk"||x.type==="file"||x.type==="meta"?o.jsx("div",{className:I("whitespace-pre px-3",db[x.type],x.type==="file"&&y>0&&"mt-2"),"data-diff":x.type,children:x.text},y):o.jsxs("div",{className:I("flex whitespace-pre px-3",db[x.type]),"data-diff":x.type,children:[p(x.oldLine),p(x.newLine),o.jsx("span",{"aria-hidden":!0,className:I("w-[2ch] shrink-0 select-none",x.type==="add"?"text-dot-success":x.type==="remove"?"text-destructive":"text-muted-foreground"),children:fA[x.type]}),o.jsx("span",{children:u.get(x)?.length?o.jsx(pc,{tokens:u.get(x)}):x.text||" "})]},y))}),h]})}function iv({children:s}){return o.jsx("p",{className:"bg-card px-3 py-2.5 text-sm text-muted-foreground",children:s})}function mA({title:s,children:t}){return o.jsxs("div",{children:[o.jsx("p",{className:"bg-card px-3 pt-2 text-xs font-medium text-muted-foreground",children:s}),t]})}function av({url:s,children:t}){const i=e5(s);return i?o.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"break-all text-foreground underline decoration-muted-foreground underline-offset-2 hover:decoration-foreground",children:t??s}):o.jsx("span",{className:"break-all",children:t??s})}function pA({detail:s,roots:t}){const i=Array.isArray(s.filePaths)?s.filePaths.filter(d=>typeof d=="string"):[],a=Array.isArray(s.webResults)?s.webResults.filter(d=>d&&typeof d.url=="string"):[],l=[typeof s.numMatches=="number"?`${s.numMatches} match${s.numMatches===1?"":"es"}`:"",typeof s.numFiles=="number"?`${s.numFiles} file${s.numFiles===1?"":"s"}`:"",s.truncated?"truncated":""].filter(Boolean).join(" · "),u=typeof s.content=="string"?s.content:"";return o.jsxs(o.Fragment,{children:[l?o.jsx("p",{className:"bg-card px-3 pt-2 text-xs text-muted-foreground",children:l}):null,u?o.jsx(Ps,{text:u,testId:"tool-search-content"}):null,i.length?o.jsx(Ps,{text:i.map(d=>$l(d,t)).join(`
|
|
50
|
+
`),testId:"tool-search-files"}):null,a.length?o.jsx("ul",{className:"max-h-[360px] space-y-2 overflow-auto bg-card px-3 py-2.5 text-sm","data-testid":"tool-search-web",children:a.map((d,h)=>o.jsxs("li",{className:"min-w-0",children:[o.jsx(av,{url:String(d.url),children:d.title?.trim()||d.url}),d.title?.trim()?o.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:d.url}):null]},h))}):null]})}function gA({detail:s}){const t=typeof s.result=="string"?s.result:"";return o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"bg-card px-3 py-2.5 font-mono text-(length:--code-font-size) leading-[1.5]",children:[o.jsx(av,{url:String(s.url??"")}),typeof s.code=="number"?o.jsx("span",{className:"ml-2 text-muted-foreground",children:s.code}):null]}),typeof s.prompt=="string"&&s.prompt.trim()?o.jsx(mA,{title:"Prompt",children:o.jsx("p",{className:"bg-card px-3 pb-2.5 pt-1 text-sm whitespace-pre-wrap [overflow-wrap:anywhere]",children:s.prompt})}):null,t?o.jsx(Ps,{text:t,testId:"tool-fetch-result"}):null]})}function xA({detail:s}){const t=nc(s?.input),i=nc(s?.output);return o.jsxs(o.Fragment,{children:[t?o.jsx(Ps,{text:t,testId:"tool-unknown-input"}):null,i?o.jsx(Ps,{text:i,testId:"tool-unknown-output"}):null]})}function ms(s,t){const i=a=>typeof a=="string"&&a.length>0;switch(s){case"shell":return!0;case"read":case"write":return i(t.content);case"edit":return i(t.unifiedDiff)||i(t.oldString)||i(t.newString);case"search":return i(t.content)||t.filePaths?.length>0||t.webResults?.length>0||typeof t.numFiles=="number"||typeof t.numMatches=="number";case"fetch":return i(t.url)||i(t.result);case"sub_agent":return i(t.description)||i(t.log);case"plan":return i(t.text)&&t.text.trim().length>0;case"plain_text":return i(t.text);default:return!!nc(t?.input)||!!nc(t?.output)}}function yA({item:s,roots:t}){const i=s.detail??{},a=I1(i),l=s.status;let u=null;switch(a){case"shell":{const d=String(i.output??"").replace(/^\n+/,"");u=o.jsxs(ub,{children:[o.jsx("span",{className:"text-muted-foreground",children:"$ "}),String(i.command??"").replace(/\n+$/,""),d?`
|
|
51
|
+
|
|
52
|
+
${d}`:l==="running"?`
|
|
53
|
+
|
|
54
|
+
Running…`:""]});break}case"read":ms(a,i)&&(u=o.jsx(Ps,{text:i.content,startLine:Number.isInteger(i.offset)&&i.offset>0?i.offset:1,testId:"tool-file-content",filename:i.filePath}));break;case"write":ms(a,i)&&(u=o.jsx(Ps,{text:i.content,startLine:1,testId:"tool-file-content",filename:i.filePath}));break;case"edit":ms(a,i)&&(u=o.jsx(hA,{detail:i}));break;case"search":ms(a,i)&&(u=o.jsx(pA,{detail:i,roots:t}));break;case"fetch":ms(a,i)&&(u=o.jsx(gA,{detail:i}));break;case"sub_agent":ms(a,i)&&(u=o.jsxs(o.Fragment,{children:[typeof i.description=="string"&&i.description.trim()?o.jsx("p",{className:"bg-card px-3 py-2.5 text-sm whitespace-pre-wrap [overflow-wrap:anywhere]","data-testid":"tool-sub-agent-description",children:i.description}):null,typeof i.log=="string"&&i.log.trim()?o.jsx(Ps,{text:i.log.replace(/^\n+/,""),testId:"tool-sub-agent-log"}):null]}));break;case"plan":ms(a,i)&&(u=o.jsx("div",{className:"max-h-[480px] overflow-auto bg-card px-4 py-3","data-testid":"tool-plan",children:o.jsx(fo,{text:i.text,className:"text-sm leading-5"})}));break;case"plain_text":ms(a,i)&&(u=o.jsx("p",{className:"max-h-[360px] overflow-auto bg-card px-3 py-2.5 text-sm whitespace-pre-wrap [overflow-wrap:anywhere]",children:i.text}));break;default:ms(a,i)&&(u=o.jsx(xA,{detail:i}))}return o.jsxs("div",{className:"divide-y divide-border",children:[u,s.error?o.jsx(ub,{tone:"error",children:s.error}):null,!u&&!s.error?o.jsx(iv,{children:l==="running"?"Running…":"No output."}):null]})}const Ys=s=>s?.item?.kind,rv=s=>s.item?.detail??{};function bA(s){return Ys(s)==="tool_call"&&rv(s).type!=="plan"}const vA=s=>typeof s=="string"&&/(^|[_.\-\s])(grep|glob|search|find)$/i.test(s.trim());function ov(s){const t=new Set,i=new Set;let a=0,l=0,u=0;for(const d of s){if(Ys(d)!=="tool_call")continue;const h=rv(d);h.type==="edit"||h.type==="write"?t.add(h.filePath??d.key):h.type==="shell"?a+=1:h.type==="read"?i.add(h.filePath??d.key):h.type==="search"||vA(d.item.name)?l+=1:u+=1}return{editedFileCount:t.size,commandCount:a,readFileCount:i.size,searchCount:l,otherToolCount:u}}const wA=s=>Object.values(s).some(t=>t>0);function lv(s){const i=[[s.editedFileCount,"edited {n} file","edited {n} files"],[s.commandCount,"ran {n} command","ran {n} commands"],[s.readFileCount,"read {n} file","read {n} files"],[s.searchCount,"searched {n} time","searched {n} times"],[s.otherToolCount,"used {n} other tool","used {n} other tools"]].filter(([l])=>l>0).map(([l,u,d])=>(l===1?u:d).replace("{n}",String(l)));if(!i.length)return"";const a=i.length===1?i[0]:i.length===2?`${i[0]} and ${i[1]}`:`${i.slice(0,-1).join(", ")}, and ${i.at(-1)}`;return a[0].toLocaleUpperCase()+a.slice(1)}function kA(s,{display:t,running:i,expandedTurns:a=new Set,isBoundary:l=()=>!1}){const u=t==="collapseTurns"?jA(s,i,a,l):s.map(d=>({type:"entry",key:d.key,entry:d}));return t==="full"?u:SA(u)}function jA(s,t,i,a){const l=[],u=(h,m)=>m?{type:"entry",key:h.key,entry:h,nested:m}:{type:"entry",key:h.key,entry:h};let d=0;for(;d<s.length;){const h=s[d];if(Ys(h)!=="user_message"||a(h)){l.push(u(h)),d+=1;continue}let m=d;for(;m<s.length&&Ys(s[m])==="user_message"&&!a(s[m]);)m+=1;let p=m;for(;p<s.length&&Ys(s[p])!=="user_message"&&!a(s[p]);)p+=1;const x=s[m-1];for(let A=d;A<m;A+=1)l.push(u(s[A]));const y=s.slice(m,p),v=p<s.length||!t;let k=-1;for(let A=y.length-1;A>=0;A-=1)if(Ys(y[A])==="assistant_message"){k=A;break}const S=k>0?y.slice(0,k):[],j=ov(S);if(!v||k<=0||!wA(j)&&!S.some(A=>Ys(A)==="assistant_message"))for(const A of y)l.push(u(A));else{const A=i.has(x.key);l.push({type:"turn",key:`turn:${x.key}`,entries:S,summary:j,expanded:A});for(const R of S)(A||Ys(R)==="compaction")&&l.push(u(R,A));for(const R of y.slice(k))l.push(u(R))}d=p}return l}function SA(s){const t=[];let i=[];const a=()=>{if(i.length>1)t.push({type:"group",key:`group:${i[0].key}`,entries:i,summary:ov(i),loading:i.some(l=>l.item.status==="running")});else for(const l of i)t.push({type:"entry",key:l.key,entry:l});i=[]};for(const l of s){if(l.type==="entry"&&!l.nested&&bA(l.entry)){i.push(l.entry);continue}a(),t.push(l)}return a(),t}const cv=w.createContext(null),wc=()=>w.useContext(cv);function Ch(){const s=w.useRef(null);return{take:()=>s.current??=Qf(),settle:t=>{t||(s.current=null)},reset:()=>{s.current=null}}}function NA({entryKey:s}){const t=wc(),i=t?.turns.get(s);return!t||!t.rewind.shown||!i?.rewindable?null:o.jsxs("button",{type:"button","data-testid":"rewind-action","aria-label":"Rewind to here…",title:t.rewind.reason??"Rewind to here… (the conversation only; files are not changed)",disabled:!!t.rewind.reason,onClick:()=>t.askRewind(s),className:"flex shrink-0 items-center gap-1 rounded p-1 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-45 [&_svg]:size-3.5",children:[o.jsx(m0,{"aria-hidden":!0}),o.jsx("span",{children:"Rewind to here…"})]})}function TA({userKeys:s}){const t=wc();if(!t||!t.fork.shown)return null;const i=[...s].reverse().map(a=>t.turns.get(a)).find(Boolean);return i?.ended?o.jsxs("button",{type:"button","data-testid":"fork-action","aria-label":"Fork from here…",title:t.fork.reason??"Fork from here… (a new session with this conversation; files are not copied)",disabled:!!t.fork.reason,onClick:()=>t.askFork(i.turnId),className:"flex shrink-0 items-center gap-1 rounded p-1 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-45 [&_svg]:size-3.5",children:[o.jsx(r0,{"aria-hidden":!0}),o.jsx("span",{children:"Fork from here…"})]}):null}function AA({turn:s,onClose:t,onDone:i}){const a=Oe(),l=Ch(),[u,d]=w.useState(!1),[h,m]=w.useState(null);w.useEffect(()=>{m(null),l.reset()},[s?.turnId]);const p=()=>{u||t()},x=async()=>{if(s){d(!0),m(null);try{await a.rewindConversation({beforeTurnId:s.turnId,requestId:l.take()}),l.reset(),i(s.text)}catch(y){const v=Oi(y);l.settle(v.retrySame),m(v.message)}finally{d(!1)}}};return o.jsx(ti,{open:!!s,onClose:p,title:"Rewind conversation",className:"w-[min(92vw,34rem)]",footer:o.jsxs(o.Fragment,{children:[o.jsx(be,{variant:"ghost",onClick:p,disabled:u,children:"Cancel"}),o.jsxs(be,{variant:"destructive",onClick:()=>{x()},disabled:u,"data-testid":"rewind-confirm",children:[o.jsx(m0,{"aria-hidden":!0}),u?"Rewinding…":h?"Try again":"Rewind"]})]}),children:s?o.jsxs("div",{className:"space-y-3 text-sm","data-testid":"rewind-dialog",children:[o.jsxs("p",{children:["The conversation goes back to ",o.jsx("strong",{children:"before this message"}),", under the same session. The agent continues from there and no longer sees what came after."]}),o.jsx("blockquote",{className:"max-h-28 overflow-y-auto whitespace-pre-wrap rounded-md border-l-2 border-border bg-muted/50 px-3 py-2 text-muted-foreground [overflow-wrap:anywhere]",children:s.text||"(no text)"}),o.jsxs("p",{children:["This message and what came after it (",ej(s.later),") move to a branch. The branch is kept: you can restore it as a new session from the timeline."]}),o.jsxs("p",{className:"rounded-md bg-[rgba(245,158,11,0.1)] px-3 py-2 font-medium","data-testid":"rewind-files-note",children:[V2," Undo file changes yourself if you need to."]}),o.jsx("p",{className:"text-muted-foreground",children:"The message is put back in the composer so you can edit and send it again."}),h?o.jsx("p",{role:"alert",className:"text-destructive",children:h}):null]}):null})}function CA({turnId:s,title:t,onClose:i}){const a=Oe(),{registry:l,connection:u}=Me(),d=Ch(),[h,m]=w.useState(!1),[p,x]=w.useState(null),[y,v]=w.useState("tab"),[k,S]=w.useState(null),[j,A]=w.useState(""),[R,q]=w.useState(!1),L=a.worktreeForkSource(),O=w.useRef(null),B=!!L&&u.phase==="open";w.useEffect(()=>{if(x(null),v("tab"),q(!1),d.reset(),O.current=null,!s||!B)return;let V=!0;return a.worktreeForkDestinations().then(U=>{V&&(S(U),A(U[0]??""))},()=>{V&&S([])}),()=>{V=!1}},[s,B]);const _=()=>{h||i()},W=async()=>{if(s){m(!0),x(null);try{if(y==="worktree"){const V=d.take();O.current??=V,await a.forkIntoWorktree({requestId:V,worktreeKey:`${O.current}:${j}`,mappingId:j,boundary:{throughTurnId:s}})}else await a.forkConversation({requestId:d.take(),boundary:{throughTurnId:s}});d.reset(),q(!1),i()}catch(V){const U=Oi(V);d.settle(U.retrySame),q(U.retrySame),x(U.message)}finally{m(!1)}}},E=(V,U,de,J=R)=>o.jsxs("label",{className:I("flex cursor-pointer items-start gap-2 rounded-md border border-border p-2",y===V&&"border-ring bg-accent/40",J&&"cursor-not-allowed opacity-50"),children:[o.jsx("input",{type:"radio",name:"fork-target",className:"mt-1",checked:y===V,disabled:J||h,onChange:()=>v(V),"aria-label":U}),o.jsxs("span",{children:[o.jsx("span",{className:"block font-medium",children:U}),o.jsx("span",{className:"block text-muted-foreground",children:de})]})]});return o.jsx(ti,{open:!!s,onClose:_,title:"Fork conversation",className:"w-[min(92vw,34rem)]",footer:o.jsxs(o.Fragment,{children:[o.jsx(be,{variant:"ghost",onClick:_,disabled:h,children:"Cancel"}),o.jsxs(be,{onClick:()=>{W()},disabled:h||y==="worktree"&&!j,"data-testid":"fork-confirm",children:[o.jsx(r0,{"aria-hidden":!0}),h?"Forking…":p?"Try again":"Fork"]})]}),children:s?o.jsxs("div",{className:"space-y-3 text-sm","data-testid":"fork-dialog",children:[o.jsx("p",{children:"A new session continues this conversation from the end of this turn. This session stays as it is."}),o.jsxs("div",{className:"space-y-2",role:"radiogroup","aria-label":"Where the fork runs",children:[E("tab","In a new tab","Same workspace: the new session opens in its own tab."),B?E("worktree","In a new worktree","A clean checkout of the last commit, made first; uncommitted changes here are not in it."):null]}),y==="worktree"?k===null?o.jsx("p",{className:"text-muted-foreground",children:"Loading destinations…"}):k.length?o.jsxs("label",{className:"block",children:["Destination",o.jsx("select",{"aria-label":"Worktree destination",className:"mt-1 w-full rounded border border-border bg-background p-1",value:j,onChange:V=>A(V.target.value),disabled:h||R,children:k.map(V=>o.jsx("option",{children:V},V))})]}):o.jsx("p",{className:"text-muted-foreground",children:"Ask the host owner to configure a worktree destination and grant it to this credential."}):null,R?o.jsx("p",{className:"text-muted-foreground","data-testid":"fork-pinned",children:"Trying again sends the same fork to the same place, so where it runs cannot change now."}):null,o.jsxs("p",{className:"rounded-md bg-[rgba(147,197,253,0.1)] px-3 py-2 font-medium","data-testid":"fork-files-note",children:[K2," Only the conversation is forked."]}),p?o.jsx("p",{role:"alert",className:"text-destructive",children:p}):null]}):null})}function uv({children:s,testId:t}){return o.jsxs("div",{className:"flex items-center gap-2 px-1 py-3 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground","data-testid":t,role:"note",children:[o.jsx("span",{"aria-hidden":!0,className:"h-px min-w-6 flex-1 bg-border"}),o.jsx("span",{className:"flex min-w-0 flex-wrap items-center justify-center gap-x-2 gap-y-1 text-center [&_svg]:size-3.5",children:s}),o.jsx("span",{"aria-hidden":!0,className:"h-px min-w-6 flex-1 bg-border"})]})}function EA({item:s,branchId:t}){const i=Oe(),a=wc(),l=i.rootSummary(a?.root),u=tj(s,l.branches,t),d=Ch(),[h,m]=w.useState(!1),[p,x]=w.useState(null),y=async()=>{m(!0),x(null);try{await i.forkConversation({requestId:d.take(),branchId:t,title:`${l.title||"Session"} (restored)`}),d.reset()}catch(v){const k=Oi(v);d.settle(k.retrySame),x(k.message)}finally{m(!1)}};return o.jsxs("div",{className:"flex flex-col items-stretch pb-4","data-branch-id":t,children:[o.jsxs(uv,{testId:"rewind-marker",children:[o.jsx(cc,{"aria-hidden":!0}),o.jsxs("span",{children:["Conversation rewound here",typeof u=="number"?` — ${J2(u)} kept in a branch`:" — the later turns are kept in a branch",". Files were not changed."]}),a?.fork.shown?o.jsxs(be,{size:"sm",variant:"secondary",className:"h-7",disabled:h||!!a.fork.reason,title:a.fork.reason,onClick:()=>{y()},"data-testid":"restore-branch",children:[o.jsx(uo,{"aria-hidden":!0}),h?"Restoring…":"Restore as new session"]}):null]}),p?o.jsx("p",{role:"alert",className:"self-center pb-2 text-xs text-destructive",children:p}):null]})}function MA({item:s}){const t=Oe(),{sessions:i}=Me(),a=wc(),l=t.rootSummary(a?.root).forkedFrom,u=l?i.list.find(h=>h.id===l.sessionId):void 0,d=l?.branchId?"a restored branch of":l?.boundary==="before"?"before a message of":l?.boundary==="through"?"a turn of":"the conversation of";return o.jsxs(uv,{testId:"fork-marker",children:[o.jsx(Fs,{"aria-hidden":!0}),l?o.jsxs("span",{children:["Forked from ",d," ",u?o.jsx("button",{type:"button",className:"text-highlight underline-offset-4 hover:underline",onClick:()=>t.selectSession(u.id),"data-testid":"fork-source",children:u.title||u.id}):o.jsx("span",{children:"another session"}),". Files were not copied."]}):o.jsx("span",{children:s.text||"Forked from another session. Files were not copied."})]})}function zA({item:s}){const t=Wf(s);return t?t.kind==="rewind"?o.jsx(EA,{item:s,branchId:t.branchId}):o.jsx(MA,{item:s}):null}function kc({icon:s,label:t,secondary:i,status:a,trailing:l,detail:u,testId:d,kind:h,open:m,onToggle:p}){const[x,y]=w.useState(!1),v=m??x,k=p??(()=>y(R=>!R)),S=w.useId(),j=a==="failed",A=a==="running";return o.jsxs("div",{className:"-mx-[13px]","data-testid":d,"data-tool-kind":h,children:[o.jsxs("button",{type:"button",onClick:k,"aria-expanded":v,"aria-controls":v&&u?S:void 0,className:I("group/badge flex w-full min-w-0 items-center rounded-lg border border-transparent px-2 py-1 text-left text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring active:opacity-90",v&&u&&"rounded-b-none border-border bg-card"),children:[o.jsxs("span",{"aria-hidden":!0,className:"relative mr-1 flex size-[22px] shrink-0 items-center justify-center",children:[o.jsx("span",{className:I("-ml-px flex",v?"hidden":"group-hover/badge:hidden"),children:j?o.jsx(h0,{className:"size-3 text-destructive opacity-80"}):o.jsx(s,{className:I("size-3",v?"text-foreground":"text-muted-foreground group-hover/badge:text-foreground")})}),o.jsx(Wn,{className:I("-ml-1 size-3 scale-[1.3] text-foreground",v?"block rotate-90":"hidden group-hover/badge:block")})]}),o.jsx("span",{className:I("shrink-0 text-muted-foreground",(v||A)&&"text-foreground",A&&"animate-pulse opacity-70","group-hover/badge:text-foreground"),children:t}),i?o.jsx("span",{className:I("ml-2 min-w-0 flex-1 truncate text-muted-foreground group-hover/badge:text-foreground",v&&"text-foreground"),children:i}):o.jsx("span",{className:"flex-1"}),l]}),v&&u?o.jsx("div",{id:S,className:"min-w-0 overflow-hidden rounded-b-lg border border-t-0 border-border",children:u()}):null]})}const RA={terminal:hc,eye:lo,pencil:$i,search:Ws,bot:Oa,brain:Pr,wrench:p0};function _A(){const{workspace:s,principal:t}=Me();return w.useMemo(()=>s?[s,...(t?.workspaceRoots??[]).filter(i=>i.path===s).map(i=>i.canonical)]:[],[s,t])}function LA({detail:s}){const{added:t,removed:i}=w.useMemo(()=>JT(Y1(s).lines),[s]);return!t&&!i?null:o.jsxs("span",{className:"ml-2 shrink-0 text-xs tabular-nums","data-testid":"tool-diff-stat",children:[o.jsxs("span",{className:"text-dot-success",children:["+",t]})," ",o.jsxs("span",{className:"text-destructive",children:["−",i]})]})}function dv({item:s}){const t=_A(),i=s.status,a=QT(s,t),l=a.kind==="shell"&&i!=="running"?s.detail.exitCode:null;return o.jsx(kc,{testId:"tool-call",kind:a.kind,icon:RA[a.icon],label:a.label,secondary:a.secondary,status:i,trailing:l!=null?o.jsxs("span",{className:I("ml-2 shrink-0 text-xs tabular-nums",l===0?"text-muted-foreground opacity-0 group-hover/badge:opacity-100 group-aria-expanded/badge:opacity-100":"text-destructive"),children:["exit ",l]}):a.kind==="edit"?o.jsx(LA,{detail:s.detail}):null,detail:()=>o.jsx(yA,{item:s,roots:t})})}function OA({item:s}){const t=s.items??[],i=t.filter(l=>l.status==="completed").length,a=t.find(l=>l.status==="in_progress");return o.jsx(kc,{icon:rh,label:"Tasks",secondary:a?a.text:`${i} of ${t.length} done`,detail:()=>o.jsx("ul",{className:"space-y-1 bg-card p-2 text-sm",children:t.length?t.map(l=>o.jsxs("li",{className:"flex items-start gap-2 px-1",children:[o.jsx("span",{"aria-hidden":!0,className:I("mt-[5px] size-2 shrink-0 rounded-full",l.status==="completed"?"bg-dot-success":l.status==="in_progress"?"bg-dot-warning":"border border-muted-foreground/60")}),o.jsx("span",{className:I("min-w-0",l.status==="completed"&&"text-muted-foreground line-through"),children:l.text})]},l.id)):o.jsx("li",{className:"px-1 text-muted-foreground",children:"No tasks."})})})}function Ul({level:s,children:t}){const i=s==="error"?Js:s==="warning"?h0:ah;return o.jsxs("div",{className:I("flex items-start gap-2 rounded-md px-3 py-2.5 text-sm leading-5 text-foreground",s==="error"?"bg-[rgba(239,68,68,0.1)]":s==="warning"?"bg-[rgba(245,158,11,0.1)]":"bg-[rgba(147,197,253,0.1)]"),children:[o.jsx("span",{"aria-hidden":!0,className:"flex h-5 shrink-0 items-center",children:o.jsx(i,{className:I("size-4",s==="error"?"text-destructive":s==="warning"?"text-warning":"text-info")})}),o.jsx("span",{className:"min-w-0 flex-1 break-words",children:t})]})}function DA({icon:s,children:t}){return o.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground",children:[o.jsx("span",{"aria-hidden":!0,className:"h-px flex-1 bg-border"}),o.jsxs("span",{className:"flex items-center gap-2 [&_svg]:size-3",children:[s,t]}),o.jsx("span",{"aria-hidden":!0,className:"h-px flex-1 bg-border"})]})}function qA({count:s}){return o.jsxs("span",{className:"mb-2 inline-flex items-center gap-1.5 rounded-full bg-muted px-2.5 py-1 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground","data-testid":"user-message-images",children:[o.jsx(OS,{"aria-hidden":!0,className:"size-3.5"}),s===1?"1 image":`${s} images`]})}function fv({files:s,testId:t}){return o.jsx("ul",{"aria-label":"Attached files",className:"mb-2 flex max-w-full flex-wrap justify-end gap-2",children:s.map(i=>o.jsxs("li",{"data-testid":t,className:I("flex h-8 max-w-[18rem] items-center gap-1.5 rounded-full bg-muted px-2.5 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground",i.failed&&"text-destructive"),children:[o.jsx(sh,{"aria-hidden":!0,className:"size-3.5 shrink-0"}),o.jsx("span",{className:"min-w-0 truncate text-foreground",title:i.name,children:i.name}),o.jsx("span",{className:"shrink-0",children:Lb(i.size)}),i.progress?o.jsx("span",{className:"shrink-0","data-testid":"file-progress",children:i.progress}):null]},i.key))})}function BA({text:s,ts:t,images:i,files:a=[],entryKey:l}){const u=!i&&!a.length;return o.jsxs("div",{className:"group/user flex flex-col items-end",children:[i?o.jsx(qA,{count:i}):null,a.length?o.jsx(fv,{testId:"user-message-file",files:a.map(d=>({key:d.attachmentId,name:d.name,size:d.size}))}):null,s||u?o.jsx("div",{className:"min-w-0 max-w-full rounded-2xl rounded-tr-sm bg-bubble p-4 text-(length:--content-font-size) leading-[1.4] text-foreground whitespace-pre-wrap [overflow-wrap:anywhere]","data-testid":"user-message",children:s}):null,o.jsxs("div",{className:"mt-2 flex h-6 items-center gap-2 opacity-0 transition-opacity group-hover/user:opacity-100 focus-within:opacity-100",children:[o.jsx("span",{className:"text-[length:calc(13px*var(--ui-scale))] text-muted-foreground",children:X0(t)}),o.jsx(NA,{entryKey:l}),o.jsx(tv,{text:()=>s,label:"Copy message",className:"-mr-1"})]})]})}function $A(){const{workspace:s,principal:t,connection:i}=Me(),{openFile:a}=kt(),l=i.capabilities.includes("workspace.files.read")&&Te(t??void 0,"files.read");return w.useMemo(()=>{if(!l||!s)return null;const u=[s,...(t?.workspaceRoots??[]).filter(d=>d.path===s).map(d=>d.canonical)];return{resolve:(d,h)=>cA(d,{roots:u,kind:h}),open:d=>a(d.path,d.line)}},[l,s,t,a])}function UA({text:s}){const t=$A();return o.jsx(gc.Provider,{value:t,children:o.jsx(fo,{text:s})})}function HA({row:s}){return o.jsx(kc,{testId:"tool-call-group",icon:p0,label:lv(s.summary),status:s.loading?"running":void 0,detail:()=>o.jsx("div",{className:"max-h-[400px] overflow-y-auto px-[13px] py-1",children:o.jsx("div",{className:"border-l border-border pl-3",children:s.entries.map(t=>o.jsx(dv,{item:t.item},t.key))})})})}function IA({row:s,onToggle:t}){return o.jsx(kc,{testId:"turn-summary",icon:BS,label:lv(s.summary)||"View turn details",open:s.expanded,onToggle:t})}function GA({entry:s,compactBottom:t}){const i=s.item;switch(i.kind){case"user_message":return o.jsx(BA,{entryKey:s.key,text:i.text,ts:s.ts,images:typeof i.images=="number"&&i.images>0?i.images:void 0,files:jj(i.attachments)});case"assistant_message":return o.jsx("div",{className:I("pt-3",t?"pb-0":"pb-3"),"data-testid":"assistant-message",children:o.jsx(UA,{text:i.text})});case"tool_call":return o.jsx(dv,{item:i});case"todo":return o.jsx(OA,{item:i});case"notice":return Wf(i)?o.jsx(zA,{item:i}):o.jsx(Ul,{level:i.level==="error"||i.level==="warning"?i.level:"info",children:i.text});case"compaction":return o.jsx(DA,{icon:i.status==="running"?o.jsx(Ah,{size:12}):i.status==="failed"?o.jsx(Js,{className:"text-destructive"}):o.jsx(ZS,{}),children:i.status==="running"?"Compacting context…":i.status==="failed"?"Compacting the context failed":"Context compacted"});case"turn_end":return i.state==="canceled"?o.jsxs("p",{className:"flex items-center gap-2 py-1 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground",children:[o.jsx(rc,{"aria-hidden":!0,className:"size-3.5"}),"Stopped."]}):o.jsx(Ul,{level:"error",children:`The turn failed${i.error?`: ${i.error}`:"."}`});case"session_event":return o.jsx(Ul,{level:i.level==="error"?"error":i.level==="warning"?"warning":"info",children:i.text});default:return null}}function YA({prompt:s,gap:t,onRetry:i,onDiscard:a}){return o.jsxs("div",{className:"flex flex-col items-end gap-2",style:t?{marginTop:t}:void 0,"data-testid":"pending-message","aria-busy":s.status==="sending",children:[s.images?.length?o.jsx("div",{className:"flex flex-wrap justify-end gap-2",children:s.images.map(l=>o.jsx("img",{src:_b(l),alt:l.name,title:l.name,className:"size-16 rounded-lg border border-border object-cover"},l.id))}):null,s.files?.length?o.jsx(fv,{testId:"pending-file",files:s.files.map((l,u)=>({key:`${u}`,name:l.name,size:l.size,failed:!!l.error,progress:l.attachmentId?"Uploaded":l.error?"Not uploaded":s.status==="sending"?`${l.size?Math.floor((l.received??0)/l.size*100):0}%`:void 0}))}):null,s.text||!s.images?.length&&!s.files?.length?o.jsx("div",{className:I("min-w-0 max-w-full rounded-2xl rounded-tr-sm p-4 text-(length:--content-font-size) leading-[1.4] whitespace-pre-wrap [overflow-wrap:anywhere]",s.status==="sending"?"bg-bubble opacity-70":s.status==="failed"?"border border-destructive/40 bg-destructive/5":"border border-warning/40 bg-warning/5"),children:s.text}):null,s.status==="sending"?o.jsxs("span",{role:"status",className:"flex h-6 items-center gap-2 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground",children:[o.jsx(Ah,{size:12}),s.accepted?"Delivered":"Sending…"]}):o.jsxs("div",{className:"flex max-w-full flex-wrap items-center justify-end gap-2 text-[length:calc(13px*var(--ui-scale))]",role:"alert",children:[o.jsx("span",{className:s.status==="failed"?"text-destructive":"text-warning",children:s.status==="failed"?s.error??"Not sent.":`${s.error??"Not confirmed."}${s.retrySameId?" Sending it again is safe: the host ignores a repeat.":""}`}),o.jsxs(be,{size:"sm",variant:"secondary",onClick:i,children:[o.jsx(uo,{"aria-hidden":!0})," ",s.status==="failed"?"Retry":"Send again"]}),o.jsxs(be,{size:"sm",variant:"ghost",onClick:a,children:[o.jsx(rN,{"aria-hidden":!0})," Discard"]})]})]})}function VA({entries:s,startTs:t,userKeys:i}){const a=s.at(-1)?.ts,l=Date.parse(t??""),u=Date.parse(a??""),d=Number.isFinite(l)&&Number.isFinite(u)&&u>=l?`Worked for ${ev(u-l)}`:"",h=X0(a),m=d||h,p=()=>s.map(x=>x.item.kind==="assistant_message"?x.item.text:"").filter(Boolean).join(`
|
|
55
|
+
|
|
56
|
+
`);return o.jsx("div",{className:"mt-[13px] flex min-h-6 items-center self-start pb-8",children:o.jsxs("div",{className:"flex h-6 items-center gap-2",children:[o.jsx(tv,{text:p,label:"Copy turn",className:"-ml-1"}),o.jsx(TA,{userKeys:i}),m?o.jsxs("span",{className:"group/time relative text-[length:calc(13px*var(--ui-scale))] text-muted-foreground",title:d&&h?`Ended ${h}`:void 0,children:[o.jsx("span",{className:I(d&&h&&"group-hover/time:invisible"),children:m}),d&&h?o.jsx("span",{className:"invisible absolute left-0 top-0 whitespace-nowrap group-hover/time:visible",children:h}):null]}):null]})})}const ys=s=>{const t=s?.item?.kind;return t?t==="user_message"?"user":t==="assistant_message"?"assistant":t==="tool_call"||t==="todo"?"tool":"other":null};function hv(s,t){return!s||!t?0:s==="user"&&t==="user"?4:s==="user"&&t==="assistant"||s==="tool"&&t==="tool"?0:s==="user"&&t==="tool"?16:s==="assistant"&&t==="tool"||s==="tool"&&t==="assistant"?4:16}const mv=s=>!!Wf(s.item);function KA(s,t){const i=[];let a=[],l,u=null;const d=p=>{a.some(x=>ys(x)!=="user")&&i.push({type:"footer",key:p,entries:a.filter(x=>ys(x)!=="user"),startTs:l,userKeys:a.filter(x=>ys(x)==="user").map(x=>x.key)}),a=[]},h=p=>p?p.type==="entry"?ys(p.entry):"tool":null,m=p=>p?.type==="entry"&&mv(p.entry);return s.forEach((p,x)=>{const y=h(p);if(p.type==="entry"&&m(p)){d(`footer:${p.key}`),i.push({type:"entry",entry:p.entry,gap:0,compactBottom:!1}),u=null;return}y==="user"&&a.some(j=>ys(j)!=="user")&&(d(`footer:${p.key}`),u=null),p.type==="entry"&&y==="user"&&u!=="user"&&(l=p.entry.ts);const v=s[x+1],k=v?h(v)==="user"||m(v):!t,S=hv(u,y);p.type==="entry"?(i.push({type:"entry",entry:p.entry,gap:S,compactBottom:y==="assistant"&&k,nested:p.nested}),a.push(p.entry)):p.type==="group"?(i.push({type:"group",row:p,gap:S}),a.push(...p.entries)):(i.push({type:"turn",row:p,gap:S}),p.expanded||a.push(...p.entries.filter(j=>ys(j)!=="other"))),u=y}),t||d("footer:end"),i}function FA({prompts:s,active:t,onJump:i}){const[a,l]=w.useState(null);return s.length<2?null:o.jsx("nav",{"aria-label":"Chat outline","data-testid":"chat-outline-rail",onMouseLeave:()=>l(null),className:"absolute right-1 top-1/2 z-10 flex max-h-[70%] w-9 -translate-y-1/2 flex-col items-end overflow-y-auto py-2 [scrollbar-width:none]",children:s.map((u,d)=>{const h=a===null?0:Math.max(0,1-Math.abs(a-d)/3),m=u.key===t?18:10;return o.jsxs("div",{className:"relative flex h-2 w-full shrink-0 items-center justify-end",children:[o.jsx("button",{type:"button","aria-label":`Jump to prompt: ${u.text.slice(0,80)}`,"aria-current":u.key===t?"true":void 0,onMouseEnter:()=>l(d),onFocus:()=>l(d),onBlur:()=>l(null),onClick:()=>i(u.key),className:"flex h-2 w-full items-center justify-end pr-1 outline-none focus-visible:ring-2 focus-visible:ring-ring",children:o.jsx("span",{"aria-hidden":!0,className:I("block rounded-full transition-[width,height]",u.key===t?"bg-foreground":"bg-extra-muted"),style:{width:m+h*(26-m),height:h>.5?4:2}})}),a===d?o.jsx("div",{role:"tooltip",className:"pointer-events-none absolute right-10 top-1/2 w-[260px] -translate-y-1/2 rounded-lg border border-border bg-popover px-3 py-2 text-xs text-popover-foreground shadow-md shadow-(color:--shadow)",children:o.jsx("span",{className:"line-clamp-2",children:u.text})}):null]},u.key)})})}function XA({entries:s,prompts:t,agentOf:i,running:a,runningAgent:l,historyUnavailable:u,older:d,onLoadOlder:h,onRetry:m,onDiscard:p,emptyText:x,tail:y}){const v=w.useRef(null),k=w.useRef(null),S=async()=>{const z=v.current;if(!z||!h)return;const F=[...z.querySelectorAll("[data-entry-key]")].find(Z=>Z.getBoundingClientRect().bottom>z.getBoundingClientRect().top);k.current=F?{key:F.dataset.entryKey,top:F.getBoundingClientRect().top}:null,j.current=!1,await h()},j=w.useRef(!0),[A,R]=w.useState(!1),q=w.useRef(0),L=()=>{const z=v.current;z&&(j.current=!0,q.current=Date.now()+700,R(!1),z.scrollTo({top:z.scrollHeight,behavior:window.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"}))},O=s.at(-1),B=`${s.length}:${O?.key}:${O?.item?.text?.length??0}:${O?.item?.status??""}:${t.length}:${a}:${w.Children.count(y)}`;w.useLayoutEffect(()=>{const z=v.current;if(z&&k.current&&!d?.loading){const F=k.current,Z=[...z.querySelectorAll("[data-entry-key]")].find(ie=>ie.dataset.entryKey===F.key);Z&&(z.scrollTop+=Z.getBoundingClientRect().top-F.top),k.current=null}z&&j.current&&(z.scrollTop=z.scrollHeight),z&&z.scrollHeight-z.scrollTop-z.clientHeight<80&&(j.current=!0,R(!1))},[B,d?.loading]),w.useEffect(()=>{const z=v.current;if(!z||typeof ResizeObserver>"u")return;const F=new ResizeObserver(()=>{j.current&&(z.scrollTop=z.scrollHeight)});return F.observe(z),()=>F.disconnect()},[]);const _=w.useRef(null);if(!a)_.current=null;else if(_.current==null){const z=[...s].reverse().find(Z=>ys(Z)==="user"),F=Date.parse(z?.ts??"");_.current=Number.isFinite(F)&&Date.now()-F<6*36e5?Math.min(F,Date.now()):Date.now()}const{chatDisplay:W,chatOutline:E}=Me().preferences,[V,U]=w.useState(()=>new Set),de=z=>U(F=>{const Z=new Set(F);return Z.has(z)?Z.delete(z):Z.add(z),Z}),J=w.useMemo(()=>KA(kA(s,{display:W,running:a,expandedTurns:V,isBoundary:mv}),a),[s,a,W,V]),me=w.useMemo(()=>s.filter(z=>ys(z)==="user").map(z=>({key:z.key,text:String(z.item.text??"").trim()||"Message"})),[s]),[se,fe]=w.useState(null),[H,P]=w.useState(!1),oe=w.useRef(null);w.useEffect(()=>{const z=oe.current;if(!z||typeof ResizeObserver>"u")return;const F=new ResizeObserver(()=>P(z.clientWidth>=918));return F.observe(z),()=>F.disconnect()},[]);const xe=()=>{const z=v.current;if(!z||!E)return;const F=z.getBoundingClientRect().top+8;let Z=null;for(const ie of me){const re=z.querySelector(`[data-entry-key="${CSS.escape(ie.key)}"]`);re&&re.getBoundingClientRect().top<=F&&(Z=ie.key)}fe(Z??me[0]?.key??null)};w.useEffect(xe,[me,E]);const T=z=>{const F=v.current?.querySelector(`[data-entry-key="${CSS.escape(z)}"]`);F&&(j.current=!1,q.current=0,F.scrollIntoView({block:"start",behavior:window.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"}),fe(z))};return o.jsxs("div",{ref:oe,className:"relative flex min-h-0 flex-1 flex-col",children:[o.jsx("div",{ref:v,onScroll:z=>{const F=z.currentTarget;xe();const Z=F.scrollHeight-F.scrollTop-F.clientHeight<80;!Z&&Date.now()<q.current||(j.current=Z,R(!Z))},onWheel:()=>{q.current=0},onTouchStart:()=>{q.current=0},onKeyDown:()=>{q.current=0},className:"min-h-0 flex-1 overflow-y-auto overscroll-contain [overflow-anchor:none] px-3 md:px-4",role:"log","aria-label":"Conversation","aria-live":"off",children:o.jsxs("div",{className:"mx-auto flex w-full max-w-(--content-width) flex-col px-2 py-4",children:[d?.hasOlder?o.jsxs("div",{className:"mb-4 flex flex-col items-center gap-2",children:[o.jsx(be,{variant:"ghost",disabled:d.loading,onClick:()=>{S()},children:d.loading?"Loading…":"Load older messages"}),d.error?o.jsx("p",{role:"alert",className:"text-xs text-destructive",children:d.error}):null]}):null,u?o.jsx("div",{className:"mb-4",children:o.jsx(Ul,{level:"warning",children:"Earlier history of this conversation is no longer available on the host."})}):null,!s.length&&!t.length?o.jsx("p",{className:"py-12 text-center text-sm text-muted-foreground",children:x}):null,J.map(z=>z.type==="footer"?o.jsx(VA,{entries:z.entries,startTs:z.startTs,userKeys:z.userKeys},z.key):z.type==="group"?o.jsx("div",{className:"flex flex-col",style:z.gap?{marginTop:z.gap}:void 0,children:o.jsx(HA,{row:z.row})},z.row.key):z.type==="turn"?o.jsx("div",{className:"flex flex-col",style:z.gap?{marginTop:z.gap}:void 0,children:o.jsx(IA,{row:z.row,onToggle:()=>de(z.row.key.slice(5))})},z.row.key):o.jsx("div",{"data-entry-key":z.entry.key,className:I("flex flex-col",z.nested&&"ml-[9px] border-l border-border pl-3"),"data-nested":z.nested||void 0,style:z.gap?{marginTop:z.gap}:void 0,children:o.jsx(GA,{entry:z.entry,compactBottom:z.compactBottom})},z.entry.key)),t.map((z,F)=>o.jsx(YA,{prompt:z,gap:F>0?4:hv(J.at(-1)?.type==="entry"?ys(J.at(-1).entry):null,"user"),onRetry:()=>m(z.id),onDiscard:()=>p(z.id)},z.id)),a?o.jsx("div",{className:"mt-[13px] flex min-h-6 items-center self-start pb-8","data-testid":"working",role:"status","aria-label":`${l} is working`,children:o.jsxs("div",{className:"flex h-6 items-center gap-3 text-foreground",children:[o.jsx(Ah,{size:14,className:"-ml-0.5"}),o.jsx(dA,{since:_.current??Date.now(),className:"text-[length:calc(13px*var(--ui-scale))] text-muted-foreground"})]})}):null,y?o.jsx("div",{className:"flex flex-col gap-2 pb-4",children:y}):null]})}),E&&H?o.jsx(FA,{prompts:me,active:se,onJump:T}):null,A?o.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-3 flex justify-center",children:o.jsx("button",{type:"button",onClick:L,"aria-label":"Scroll to bottom",title:"Scroll to bottom","data-testid":"scroll-to-bottom",className:"pointer-events-auto flex size-12 items-center justify-center rounded-full bg-secondary text-foreground shadow-md shadow-black/30 outline-none hover:bg-bubble focus-visible:ring-2 focus-visible:ring-ring",children:o.jsx(Xn,{"aria-hidden":!0,className:"size-6"})})}):null]})}function PA({onNewSession:s}){const{principal:t,workspace:i,sessions:a}=Me(),l=Te(t??void 0,"session.write");return o.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-16",children:o.jsxs("div",{className:"max-w-sm text-center",children:[o.jsx("span",{className:"mx-auto mb-4 flex size-12 items-center justify-center rounded-xl bg-primary/10 text-highlight",children:o.jsx(cy,{"aria-hidden":!0,className:"size-6"})}),o.jsx("h2",{className:"text-base font-medium",children:i?"Pick a session or start a new one":"Choose a workspace"}),o.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground",children:i?a.list.length?"Your sessions run on the host and keep their history between visits.":"This workspace has no sessions yet.":"Your access token decides which workspaces you can open."}),i&&l?o.jsxs(be,{className:"mt-5",onClick:s,children:[o.jsx(cy,{"aria-hidden":!0})," New session"]}):null]})})}const jc="inline-flex h-7 min-w-0 shrink items-center gap-1 rounded-2xl px-2 text-sm text-muted-foreground [&_svg]:size-3.5 [&_svg]:shrink-0";function Yr({icon:s,label:t,title:i}){return o.jsxs("span",{title:i,className:jc,children:[s,o.jsx("span",{className:"truncate",children:t})]})}const QA={"read-only":eN,"workspace-write":dc,"full-access":d0},fb=s=>s&&QA[s]||dc;function pv({mode:s,modes:t,disabled:i,locked:a,onSelect:l}){const u=fb(s),d=t.find(h=>h.id===s)?.label??Fl(s);return t.length<2&&t[0]?.id===s?o.jsx(Yr,{icon:o.jsx(u,{"aria-hidden":!0}),label:d,title:"Permissions"}):o.jsx(Vt,{label:"Permissions",title:a?`Permissions: ${d}. They change once the agent and its team are idle.`:`Permissions: ${d}`,align:"start",disabled:i,triggerClassName:I(jc,"outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-expanded:bg-muted aria-expanded:text-foreground disabled:pointer-events-none disabled:opacity-60"),trigger:o.jsxs(o.Fragment,{children:[o.jsx(u,{"aria-hidden":!0}),o.jsx("span",{className:"truncate","data-testid":"mode-control-label",children:d}),o.jsx(Xn,{"aria-hidden":!0,className:"!size-3 opacity-70"})]}),items:t.map(h=>{const m=fb(h.id);return{id:h.id,label:h.label??Fl(h.id),icon:o.jsx(m,{"aria-hidden":!0}),checked:h.id===s,onSelect:()=>{h.id!==s&&l(h.id)}}})})}const cf=I(jc,"outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-expanded:bg-muted aria-expanded:text-foreground disabled:pointer-events-none disabled:opacity-60");function WA({team:s,teamId:t,model:i,thinking:a,runtime:l}){const u=Oe(),{catalog:d,busy:h}=Me(),m=u.liveConfigure(),{same:p,current:x,others:y}=qj(d.models,{runtime:l,model:i}),v=x?.label??i,k=a?Vs(a):void 0,S=Ub(x),j=!!h.configure,A=(O,B)=>O.enabled?B:`${B}. ${O.reason??m.reason??""}`.trim(),R=(O,B,_)=>o.jsx("span",{className:"inline-flex min-w-0",title:O.enabled&&!j?void 0:j?`${B}. Applying the last change…`:A(O,B),children:_});if(!m.shown)return o.jsxs(o.Fragment,{children:[s?o.jsx(Yr,{icon:o.jsx(Yl,{"aria-hidden":!0}),label:s,title:`Team: ${s}. ${m.reason}`}):null,v?o.jsx(Yr,{icon:o.jsx(jf,{"aria-hidden":!0}),label:v,title:`Main agent's model: ${v}. ${m.reason}`}):null,k?o.jsx(Yr,{icon:o.jsx(Pr,{"aria-hidden":!0}),label:k,title:`Thinking: ${k}. ${m.reason}`}):null]});const q=d.teams.length?d.teams:t?[{id:t,label:s??t}]:[],L=!t||q.some(O=>O.id===t);return o.jsxs(o.Fragment,{children:[s||t?R(m.team,`Team: ${s??t}`,o.jsx(Vt,{label:"Team",title:A(m.team,`Team: ${s??t}`),align:"start",disabled:!m.team.enabled||j,testId:"session-team",triggerClassName:cf,trigger:o.jsxs(o.Fragment,{children:[o.jsx(Yl,{"aria-hidden":!0}),o.jsx("span",{className:"truncate","data-testid":"team-label",children:s??t}),o.jsx(Xn,{"aria-hidden":!0,className:"!size-3 opacity-70"})]}),items:[...L?[]:[{id:t,label:s??t,checked:!0,onSelect:()=>{}}],...q.map(O=>({id:O.id,label:O.label,checked:O.id===t,...O.id===t?{}:{title:"Restarts main on the same conversation with this team"},onSelect:()=>{O.id!==t&&u.configureLive({team:O.id})}}))]})):null,v?R(p.length?m.model:{enabled:!1},`Main agent's model: ${v}`,o.jsx(Vt,{label:"Model",title:A(m.model,`Main agent's model: ${v}`),align:"start",disabled:!m.model.enabled||j||!p.length,testId:"session-model",triggerClassName:cf,trigger:o.jsxs(o.Fragment,{children:[o.jsx(jf,{"aria-hidden":!0}),o.jsx("span",{className:"truncate","data-testid":"model-label",children:v}),o.jsx(Xn,{"aria-hidden":!0,className:"!size-3 opacity-70"})]}),items:[...p.map(O=>({id:O.id,label:O.label,checked:O.id===x?.id,onSelect:()=>{O.id!==x?.id&&u.configureLive({model:O.id})}})),...y?[{id:"other-runtimes",label:"Other runtimes: start a new session",disabled:!0,group:!0,title:"A session keeps its runtime. To use another runtime's model, start a new session with it.",onSelect:()=>{}}]:[]]})):null,k?S.length?R(m.thinking,`Thinking: ${k}`,o.jsx(Vt,{label:"Thinking",title:A(m.thinking,`Thinking: ${k}`),align:"start",disabled:!m.thinking.enabled||j,testId:"session-thinking",triggerClassName:cf,trigger:o.jsxs(o.Fragment,{children:[o.jsx(Pr,{"aria-hidden":!0}),o.jsx("span",{className:"truncate","data-testid":"session-thinking-label",children:k}),o.jsx(Xn,{"aria-hidden":!0,className:"!size-3 opacity-70"})]}),items:S.map(O=>({id:O.id,label:O.label,checked:O.id===a,onSelect:()=>{O.id!==a&&u.configureLive({thinking:O.id})}}))})):o.jsx(Yr,{icon:o.jsx(Pr,{"aria-hidden":!0}),label:k,title:`Thinking: ${k}`}):null]})}function ZA({sessionId:s}){const t=Oe(),{openAgent:i}=kt(),{tree:a,prompts:l,queued:u,busy:d,sessions:h,connection:m,preferences:p,catalog:x,principal:y}=Me(),[v,k]=w.useState(null),[S,j]=w.useState(null),[A,R]=w.useState(void 0),q=a?.projection,L=!!a?.older?.hasOlder,O=w.useMemo(()=>q?Z2(q,{hasOlder:L}):new Map,[q,L]);if(!a)return null;const B=a.projection,_=a.rootId,W=s,E=h.list.find(ge=>ge.id===_),V=B.sessions[_],U=ge=>B.sessions[ge]?.agent??(ge===_?"main":"agent"),de=_ in B.running,J=de||t.rootBusy(_),me=W in B.running,se=!!B.closed[_]||!V&&E?.status==="closed",fe=Object.values(B.questions),H=t.driveBlock(),P=l.filter(ge=>ge.rootId===_),oe=t.fileGate(_);if(a.status==="gone")return o.jsx("div",{className:"flex flex-1 items-center justify-center px-6",children:o.jsxs("div",{className:"max-w-sm text-center",role:"alert",children:[o.jsx(Js,{"aria-hidden":!0,className:"mx-auto mb-3 size-8 text-destructive"}),o.jsx("h2",{className:"font-medium",children:"This session is no longer available"}),o.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground",children:a.error?.message??"The host no longer has it, or your access token cannot see it."}),o.jsx(be,{className:"mt-4",variant:"secondary",onClick:()=>{t.selectSession(null),t.refreshSessions()},children:"Back to sessions"})]})});const xe=a.status==="attaching"||a.status==="detached",T=Sj(B,W),z=V?.teamLabel??E?.teamLabel,F=V?.mode??E?.mode,Z=V?.model??E?.model,ie=Te(y??void 0,"session.write"),re=x.modes.length?x.modes:F?[{id:F}]:[],le=J||Object.keys(B.running).length>0,ve=!!F&&re.length>1&&!d.mode&&!H&&ie&&!le&&m.phase==="open",Re=()=>{if(!ve)return;const ge=re.findIndex(Ce=>Ce.id===F);t.configureMode(re[(ge+1)%re.length].id)},et=(W===_?[...T].reverse().find(ge=>ge.item.kind==="todo"):void 0)?.item?.items??[],Ue=t.conversationGate(_),Qe=W===_&&(Ue.fork.shown||Ue.rewind.shown)?{root:_,fork:Ue.fork,rewind:Ue.rewind,turns:O,askRewind:ge=>{const Ce=O.get(ge);Ce&&k(Ce)},askFork:ge=>j(ge)}:null,We=V?.title??E?.title??"Session",ye=fe.length?fe.map(ge=>o.jsx(nA,{question:ge,busy:!!d[`question:${ge.id}`],blocked:H,onAnswer:Ce=>{t.answerQuestion(ge.id,{text:Ce})},onDecline:()=>{t.answerQuestion(ge.id,{dismiss:!0})}},ge.id)):null;return o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[a.status==="error"?o.jsxs("div",{role:"alert",className:"flex items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:[o.jsx("span",{className:"min-w-0 flex-1",children:a.error?.message??"Could not load this session."}),o.jsxs(be,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>t.retryAttach(),children:[o.jsx(uo,{"aria-hidden":!0})," Try again"]})]}):null,xe&&!T.length?o.jsx("div",{className:"flex flex-1 items-center justify-center",children:o.jsx(Kt,{label:m.phase==="open"?"Loading conversation…":"Waiting for the connection…"})}):o.jsx(cv.Provider,{value:Qe,children:o.jsx(XA,{entries:T,prompts:W===_?P:[],agentOf:U,running:me,runningAgent:U(W),historyUnavailable:B.historyUnavailable,older:a.older,onLoadOlder:()=>t.loadOlder(),onRetry:ge=>{t.retryPrompt(ge)},onDiscard:ge=>t.discardPrompt(ge),emptyText:W===_?se?"Nothing here yet.":"Send a message to start.":"This agent has not written anything yet.",tail:ye})}),o.jsx(AA,{turn:v,onClose:()=>k(null),onDone:ge=>{k(null),ge&&R({id:Date.now(),text:ge})}}),o.jsx(CA,{turnId:S,title:We,onClose:()=>j(null)}),xe&&!T.length&&ye?o.jsx("div",{className:"px-3 pb-3 md:px-4",children:o.jsx("div",{className:"mx-auto flex w-full max-w-(--content-width) flex-col gap-2 px-2",children:ye})}):null,W===_&&t.isArchived(_)?o.jsx(E5,{sessionId:_}):W===_?o.jsxs(o.Fragment,{children:[se&&!de?o.jsx("p",{className:"mx-auto w-full max-w-(--content-width) px-4 pb-2 text-center text-xs text-muted-foreground",children:"This session is closed on the host. Sending a message reopens it."}):null,o.jsx(Z1,{meter:o.jsx(ob,{usage:V?.usage}),images:V?.promptImages===!0&&m.capabilities.includes("prompt.images")&&!!m.promptImageLimits?.maxBytes,imageLimits:m.promptImageLimits,imagesUnavailable:`${U(_)} runs on ${V?.runtime??"a runtime"} here, which takes no images.`,files:!oe,fileLimits:m.attachmentLimits,filesUnavailable:oe??void 0,addText:A,onSend:(ge,Ce,je)=>t.sendPrompt(ge,void 0,Ce,je),onQueue:ge=>t.queuePrompt(ge),onInterruptSend:ge=>t.interruptAndSend(ge),onStop:()=>{t.interrupt()},queued:u.filter(ge=>ge.rootId===_),onEditQueued:ge=>t.editQueued(ge),onSendQueued:ge=>{t.sendQueuedNow(ge)},running:J,stopping:!!d.interrupt,blocked:H,disabledReason:m.phase!=="open"?"Reconnecting…":xe?"Loading…":void 0,placeholder:`Message ${U(_)}…`,sendBehavior:p.sendBehavior,sendShortcut:p.sendShortcut,onCycleMode:ve?Re:void 0,tracks:o.jsx(Q5,{worked:et}),controls:o.jsxs(o.Fragment,{children:[o.jsx(WA,{team:z,teamId:V?.workflow?.mode??E?.workflow?.mode,model:Z,thinking:V?.thinking??E?.thinking,runtime:V?.runtime??E?.runtime}),F?o.jsx(pv,{mode:F,modes:re,locked:le,disabled:!!d.mode||!!d.configure||!!H||!ie||m.phase!=="open"||le,onSelect:ge=>{t.configureMode(ge)}}):null]})})]}):o.jsx("div",{className:"px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:px-4 md:pb-4",children:o.jsxs("div",{className:"mx-auto flex w-full max-w-(--content-width) items-center gap-3 rounded-2xl border border-dotted border-input bg-card px-3 py-2 text-(length:--content-font-size) leading-[1.4] text-muted-foreground md:px-4 md:py-3",children:[o.jsxs("span",{className:"min-w-0 flex-1",children:[U(W)," works on an assignment from main. Talk to main to steer it."]}),o.jsx(ob,{usage:B.sessions[W]?.usage}),o.jsxs(be,{size:"sm",variant:"secondary",onClick:()=>i(_),children:[o.jsx(eh,{"aria-hidden":!0})," Main"]})]})})]})}const JA=250,uf=I(jc,"outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-expanded:bg-muted aria-expanded:text-foreground disabled:pointer-events-none disabled:opacity-60");function eC(s){const t=Oe(),{connection:i}=Me(),[a,l]=w.useState({status:"idle"}),[u,d]=w.useState(0),h=s?JSON.stringify(s):"",m=i.phase==="open";w.useEffect(()=>{if(!s)return;const x=t.previewBlock();if(x){l(S=>({...S,status:"blocked",error:x}));return}if(!m)return;const y=new AbortController,v=Hb(s);l(S=>({status:"loading",preview:S.preview,base:S.base}));const k=setTimeout(()=>{t.previewSession(s,{signal:y.signal}).then(S=>{y.signal.aborted||l({status:"ready",preview:S,base:v})},S=>{y.signal.aborted||l(j=>({...j,status:"error",error:Be(S).message}))})},JA);return()=>{clearTimeout(k),y.abort()}},[h,m,t,u]);const p=w.useCallback(()=>d(x=>x+1),[]);return{...a,retry:p}}function tC(){const s=Oe(),{finishDraft:t}=kt(),{catalog:i,workspace:a,preferences:l,busy:u,connection:d,principal:h}=Me(),m=s.fileGate(null),p=l.newSession,[x,y]=w.useState(()=>Gx(i,p)),[v,k]=w.useState("");w.useEffect(()=>{i.status==="ready"&&y(Gx(i,s.getState().preferences.newSession))},[i,s]);const[S,j]=w.useState(),A=Hb({workflow:x.team,model:x.model}),R=S?.base===A?S.preview:void 0,q=$b(i.models,x.model,R),L=q?Cj(q,x.thinking):void 0,O={...x,...L?{thinking:L}:{thinking:void 0}},B=a&&i.status!=="loading"?Yx(a,O):null,_=eC(B);w.useEffect(()=>{_.status==="ready"&&_.preview&&_.base&&j({preview:_.preview,base:_.base})},[_.status,_.preview,_.base]);const W=_.status==="ready"&&_.base===A,E=_.status==="blocked"||_.status==="error",V=!!u.create,de=Te(h??void 0,"session.write")?void 0:"Your access token can view sessions but not start them.",J=i.teams.length?i.teams:R?.teams??[],me=Vx(J,R),[se,fe]=w.useState(),H=se?.workspace===a?se:void 0;w.useEffect(()=>{me&&fe(ze=>ze?.workspace===a&&ze.team?.id===me.id&&ze.team.label===me.label?ze:{team:me,workspace:a})},[me?.id,me?.label,a]);const P=!!a&&d.phase==="open"&&!!x.team&&!H&&i.status==="ready";w.useEffect(()=>{if(!P||!a||s.previewBlock())return;const ze=new AbortController;return s.previewSession(Yx(a,{}),{signal:ze.signal}).then(it=>{if(ze.signal.aborted)return;const gt=Vx(i.teams.length?i.teams:it.teams,it);fe(At=>At?.workspace===a?At:{workspace:a,...gt?{team:gt}:{}})},()=>{}),()=>ze.abort()},[P,a,s]);const oe=zj(J,me??H?.team),xe=Rj({chosen:x.team,previewTeam:R?.team,previewSettled:E,previewError:_.error,previewBlocked:_.status==="blocked",previewNeedsRead:!Te(h??void 0,"session.read"),teams:J,teamsKnown:i.teamsKnown,teamsUnavailable:i.teamsUnavailable}),T="stuck"in xe&&xe.stuck?xe.wait:void 0,z=()=>{_.retry(),s.retryTeams()},F=i.teamsUnavailable?.reason==="failed",Z=xe.team,ie=Z?Z===R?.team&&R.teamLabel||oe.find(ze=>ze.id===Z)?.label||Z:"Team",re=xe.wait??(!E&&!W?"Checking what would run…":void 0),le=x.model?i.models.find(ze=>ze.id===x.model)?.label??x.model:q?q.label:R?.model||"Default model",ve=Ub(q),Re=L?Vs(L):R?.thinking?Vs(R.thinking):q?.effort?Vs(q.effort):"Default",Ne=`composer-${w.useId()}`,et=()=>setTimeout(()=>document.getElementById(Ne)?.focus(),0),Ue=ze=>{y(it=>({...it,...ze})),et()},Qe=ze=>{y(it=>({...it,model:ze||void 0,thinking:p.thinkingByModel?.[ze||"default"]})),et()},[We]=w.useState(()=>s.unsentDraft()),[ye,ge]=w.useState();w.useEffect(()=>{We&&s.clearUnsentDraft(We);const ze=At=>ge($n=>({id:($n?.id??0)+1,text:At})),it=s.takeUnsentDrafts(At=>At.workspace!==s.getState().workspace?!1:(ze(At.text),!0)),gt=s.unsentDraft();return gt&&(s.clearUnsentDraft(gt),ze(gt)),it},[We,s]);const Ce=w.useRef(!1),je=w.useRef(!0);w.useEffect(()=>(je.current=!0,()=>{je.current=!1}),[]);const Ut=async(ze,it=[],gt=[])=>{if(!(Ce.current||s.getState().busy.create||re)){Ce.current=!0;try{const At=await Oj(s,{...Z?{team:Z}:{},...O.mode?{mode:O.mode}:{},...O.model?{model:O.model}:{},...O.thinking?{thinking:O.thinking}:{},...v.trim()?{title:v.trim()}:{},...ze.trim()?{prompt:ze}:{},...gt.length?{files:gt}:{}},ze,{mounted:()=>je.current,describe:Be,nameOf:Ot});t(At)}finally{Ce.current=!1}}},ln=o.jsxs(o.Fragment,{children:[o.jsx(Vt,{label:"Team",title:`Team: ${ie}`,align:"start",disabled:V,testId:"new-session-team",triggerClassName:uf,trigger:o.jsxs(o.Fragment,{children:[o.jsx(Yl,{"aria-hidden":!0}),o.jsx("span",{className:"truncate",children:ie}),o.jsx(Xn,{"aria-hidden":!0,className:"!size-3 opacity-70"})]}),items:[...oe.map(ze=>({id:ze.id,label:ze.label,checked:Z===ze.id,onSelect:()=>Ue({team:ze.id})}))]}),i.models.length?o.jsx(Vt,{label:"Model",title:`Main agent's model: ${le}`,align:"start",disabled:V,testId:"new-session-model",triggerClassName:uf,trigger:o.jsxs(o.Fragment,{children:[o.jsx(jf,{"aria-hidden":!0}),o.jsx("span",{className:"truncate",children:le}),o.jsx(Xn,{"aria-hidden":!0,className:"!size-3 opacity-70"})]}),items:[{id:"",label:"Team default",checked:!x.model,onSelect:()=>Qe("")},...i.models.map((ze,it)=>({id:ze.id,label:ze.label,checked:x.model===ze.id,group:it===0,onSelect:()=>Qe(ze.id)}))]}):null,ve.length?o.jsx(Vt,{label:"Thinking",title:`Thinking: ${Re}`,align:"start",disabled:V,testId:"new-session-thinking",triggerClassName:uf,trigger:o.jsxs(o.Fragment,{children:[o.jsx(Pr,{"aria-hidden":!0}),o.jsx("span",{className:"truncate","data-testid":"thinking-label",children:Re}),o.jsx(Xn,{"aria-hidden":!0,className:"!size-3 opacity-70"})]}),items:[{id:"",label:q?.effort?`Default (${Vs(q.effort)})`:"Default",checked:!L,onSelect:()=>Ue({thinking:void 0})},...ve.map((ze,it)=>({id:ze.id,label:ze.label,checked:L===ze.id,group:it===0,onSelect:()=>Ue({thinking:ze.id})}))]}):null,x.mode?o.jsx(pv,{mode:x.mode,modes:i.modes,locked:!1,disabled:V,onSelect:ze=>Ue({mode:ze})}):null]});return o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"new-session-screen",children:[o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:o.jsxs("div",{className:"mx-auto flex w-full max-w-[820px] flex-col gap-5 px-4 pb-6 pt-10 md:pt-16",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-medium text-foreground",children:"New session"}),a?o.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Runs on the host in ",o.jsx("span",{className:"font-mono text-foreground/90",children:Ot(a)}),". Your first message starts it."]}):null]}),i.status==="loading"?o.jsx(Kt,{label:"Loading teams and models…",className:"text-xs"}):null,i.status==="error"?o.jsx("p",{role:"alert",className:"text-xs text-destructive",children:i.error?.message}):null,o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsx("label",{htmlFor:"new-title",className:"text-xs font-medium text-muted-foreground",children:"Title (optional)"}),o.jsx(Qn,{id:"new-title",value:v,onChange:ze=>k(ze.target.value),maxLength:200,disabled:V,placeholder:"Named after your first message when empty",className:"bg-transparent"})]}),o.jsx(nC,{state:_,models:i.models,onRetry:z,retryWhenBlocked:F}),T?o.jsxs("p",{role:"alert","data-testid":"new-session-stuck",className:"flex items-start gap-2 text-xs text-destructive",children:[o.jsx(Js,{"aria-hidden":!0,className:"mt-0.5 size-3.5 shrink-0"}),T]}):null]})}),o.jsx(Z1,{onSend:Ut,sendShortcut:l.sendShortcut,onQueue:()=>{},onStop:()=>{},queued:[],onEditQueued:()=>null,onSendQueued:()=>{},running:!1,stopping:!1,blocked:de,disabledReason:d.phase!=="open"?"Reconnecting…":V?"Starting…":a?i.status==="loading"?"Loading…":void 0:"Choose a workspace first.",startHold:re,placeholder:"What should main work on?",startLabel:"Start session",initialText:We,addText:ye,autoFocus:!0,inputId:Ne,controls:ln,files:!m,fileLimits:d.attachmentLimits,filesUnavailable:m??void 0})]})}function nC({state:s,models:t,onRetry:i,retryWhenBlocked:a}){const l=s.preview?Mj(s.preview,t):[];return o.jsxs("section",{"aria-label":"Session preview","data-testid":"session-preview","aria-busy":s.status==="loading",className:"overflow-hidden rounded-lg border border-border bg-card",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-2.5",children:[o.jsx("h3",{className:"text-xs font-normal text-muted-foreground",children:"This session will run"}),s.status==="loading"?o.jsx(Kt,{label:"Checking…",className:"text-xs"}):null]}),s.status==="blocked"?o.jsxs("div",{className:"flex items-start justify-between gap-3 px-4 py-3",children:[o.jsxs("p",{role:"note",className:"text-xs text-muted-foreground",children:["Preview not available: ",s.error]}),a?o.jsx("button",{type:"button",onClick:i,className:"shrink-0 rounded-md px-2 py-0.5 text-xs text-foreground outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring",children:"Retry"}):null]}):null,s.status==="error"?o.jsxs("div",{className:"flex items-start justify-between gap-3 px-4 py-3",children:[o.jsxs("p",{role:"alert",className:"flex items-start gap-2 text-xs text-destructive",children:[o.jsx(Js,{"aria-hidden":!0,className:"mt-0.5 size-3.5 shrink-0"}),s.error]}),o.jsx("button",{type:"button",onClick:i,className:"shrink-0 rounded-md px-2 py-0.5 text-xs text-foreground outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring",children:"Retry"})]}):null,l.length?o.jsx("dl",{className:I("grid grid-cols-[auto_1fr] gap-x-6 gap-y-2 px-4 py-3 text-sm",s.status!=="ready"&&"opacity-60"),children:l.map(u=>o.jsxs(w.Fragment,{children:[o.jsx("dt",{className:"text-muted-foreground",children:u.label}),o.jsx("dd",{className:"min-w-0 truncate text-foreground","data-testid":`preview-${u.key}`,children:u.value})]},u.key))}):s.status==="idle"||s.status==="loading"&&!s.preview?o.jsx("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:"Asking the host…"}):null]})}const sC={open:"Open",in_progress:"In progress",review:"In review",closed:"Closed"},iC={open:"text-muted-foreground",in_progress:"text-dot-running",review:"text-dot-warning",closed:"text-highlight"};function ps({label:s,children:t}){return o.jsxs(o.Fragment,{children:[o.jsx("dt",{className:"text-muted-foreground",children:s}),o.jsx("dd",{className:"min-w-0 break-words",children:t})]})}function gv({id:s,onOpenTask:t}){const i=Oe(),{openTask:a}=kt(),l=t??a,{tasks:u,principal:d}=Me(),h=u.rows.find(y=>y.id===s),m=Te(d??void 0,"project.write"),p=i.tasksBlock();if(w.useEffect(()=>(i.setTasksVisible(!0),()=>i.setTasksVisible(!1)),[i]),p)return o.jsxs("p",{className:"m-auto flex max-w-sm items-start gap-2 px-6 text-sm text-muted-foreground",children:[o.jsx(qa,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0"}),p]});if(!h)return o.jsx("div",{className:"flex flex-1 items-center justify-center px-6",children:u.status==="loading"||u.status==="idle"?o.jsx(Kt,{label:"Loading the task…"}):o.jsxs("p",{className:"max-w-sm text-center text-sm text-muted-foreground",role:"status",children:["Task ",s," is no longer in this workspace's list."]})});const x=!!u.busy[h.id];return o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"task-detail",children:o.jsxs("article",{className:"mx-auto w-full max-w-(--content-width) px-4 py-6 sm:px-6",children:[o.jsxs("p",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[o.jsx("span",{className:"font-mono",children:h.id}),h.type?o.jsxs("span",{children:["· ",h.type]}):null,o.jsxs("span",{children:["· P",h.priority]}),o.jsxs("span",{className:I("inline-flex items-center gap-1",iC[h.status]),children:[o.jsx(t0,{"aria-hidden":!0,className:"size-3"}),sC[h.status]??h.status]}),h.status!=="closed"&&h.ready?o.jsx("span",{className:"text-info",children:"· ready"}):null]}),o.jsx("h2",{className:I("text-xl font-normal leading-snug",h.status==="closed"&&"text-muted-foreground"),children:h.title}),u.message?.level==="error"?o.jsx("p",{role:u.message.level==="error"?"alert":"status",className:I("mt-4 rounded-md px-3 py-2 text-xs",u.message.level==="error"?"bg-destructive/10 text-destructive":"bg-primary/10 text-highlight"),children:u.message.text}):null,h.approvals?.map(y=>o.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 rounded-xl border border-warning/40 bg-warning/[0.06] px-4 py-3 text-sm",children:[o.jsx(dc,{"aria-hidden":!0,className:"size-4 shrink-0 text-warning"}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"text-warning",children:"Needs your approval"}),y.note?o.jsxs("span",{className:"text-muted-foreground",children:[": ",y.note]}):null]}),y.rejected?o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Rejected ",Mi(y.rejected.at)]}):null,m?y.options?.length?y.options.map(v=>o.jsx(be,{size:"sm",disabled:x,onClick:()=>{i.changeTask(h,{gate:y.gate,choice:v})},children:v},v)):o.jsx(be,{size:"sm",disabled:x,onClick:()=>{i.changeTask(h,{gate:y.gate})},children:"Approve"}):null,m&&!y.rejected?o.jsx(be,{size:"sm",variant:"secondary",disabled:x,onClick:()=>{i.changeTask(h,{gate:y.gate,reject:!0})},children:"Reject"}):null]},y.gate)),o.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[m?h.status==="closed"?o.jsxs(be,{size:"sm",variant:"secondary",disabled:x,onClick:()=>{i.changeTask(h,{action:"reopen"})},children:[o.jsx(uo,{"aria-hidden":!0})," Reopen"]}):o.jsxs(be,{size:"sm",variant:"secondary",disabled:x,onClick:()=>{i.changeTask(h,{action:"close"})},children:[o.jsx(oc,{"aria-hidden":!0})," Close task"]}):o.jsx("p",{className:"text-xs text-muted-foreground",children:"Your access token can read tasks but not change them."}),x?o.jsx(Kt,{label:"Saving…",className:"text-xs"}):null]}),h.description?o.jsx("section",{"aria-label":"Description",className:"mt-6 text-(length:--content-font-size) leading-[1.5]",children:o.jsx(fo,{text:h.description})}):o.jsx("p",{className:"mt-6 text-sm text-muted-foreground",children:"No description."}),h.handoff?o.jsxs("section",{"aria-label":"Handoff",className:"mt-6 rounded-xl border border-border bg-card px-4 py-3",children:[o.jsxs("p",{className:"mb-1 text-xs text-muted-foreground",children:["Handoff · ",h.handoff.outcome,h.handoff.agent?` · ${h.handoff.agent}`:""]}),o.jsx("p",{className:"whitespace-pre-wrap text-sm",children:h.handoff.summary})]}):null,h.closed?o.jsxs("section",{"aria-label":"Closed",className:"mt-4 rounded-xl border border-border bg-card px-4 py-3",children:[o.jsxs("p",{className:"mb-1 text-xs text-muted-foreground",children:["Closed ",Mi(h.closed.at)," · ",h.closed.reason]}),h.closed.summary?o.jsx("p",{className:"whitespace-pre-wrap text-sm",children:h.closed.summary}):null]}):null,o.jsxs("dl",{className:"mt-6 grid grid-cols-[8rem_1fr] gap-x-4 gap-y-2 border-t border-border pt-4 text-sm",children:[h.assignee?o.jsx(ps,{label:"Assignee",children:h.assignee}):null,h.progress?o.jsxs(ps,{label:"Progress",children:[h.progress.done," of ",h.progress.total," done"]}):null,h.parent?o.jsx(ps,{label:"Parent",children:o.jsx("button",{type:"button",className:"font-mono text-highlight hover:underline",onClick:()=>l(h.parent),children:h.parent})}):null,h.blockedBy?.length?o.jsx(ps,{label:"Blocked by",children:h.blockedBy.map((y,v)=>o.jsxs(w.Fragment,{children:[v?", ":"",o.jsx("button",{type:"button",className:"font-mono text-highlight hover:underline",onClick:()=>l(y),children:y})]},y))}):null,h.waits?.length?o.jsx(ps,{label:"Waits on",children:h.waits.join("; ")}):null,h.labels?.length?o.jsx(ps,{label:"Labels",children:o.jsx("span",{className:"flex flex-wrap gap-1",children:h.labels.map(y=>o.jsx("span",{className:"rounded-full bg-secondary px-2 py-0.5 text-xs",children:y},y))})}):null,h.paths?.length?o.jsx(ps,{label:"Paths",children:o.jsx("span",{className:"space-y-0.5",children:h.paths.map(y=>o.jsx("span",{className:"block font-mono text-xs",children:y},y))})}):null,h.createdAt?o.jsx(ps,{label:"Created",children:Mi(h.createdAt)}):null,o.jsx(ps,{label:"Updated",children:Mi(h.updatedAt)})]})]})})}const aC=s=>Math.round(s*5/3),rC=200*1024,oC=s=>s instanceof Ai?s.failure:{message:s instanceof Error?s.message:"Something went wrong.",sent:"unknown",terminal:!1};function lC({path:s}){const t=Oe(),{fileTarget:i}=kt(),a=i(s),[l,u]=w.useState({status:"loading"}),[d,h]=w.useState(!1),[m,p]=w.useState(()=>a?.line?"source":"preview"),[x,y]=w.useState(!1),[v,k]=w.useState(0),S=w.useRef(null),j=aC(Me().preferences.codeFontSize);w.useEffect(()=>{let W=!0;return u(E=>E.status==="ready"?E:{status:"loading"}),t.readWorkspaceFile({path:s,includeIgnored:d}).then(E=>{W&&u({status:"ready",content:E.content,size:E.size,...E.modifiedAt?{modifiedAt:E.modifiedAt}:{}})},E=>{W&&u({status:"error",failure:oC(E)})}),()=>{W=!1}},[t,s,d,v]),w.useEffect(()=>{a?.line&&p("source")},[a?.nonce,a?.line]);const A=k2(s)&&(l.status!=="ready"||l.size<=rC),R=!A||m==="source",q=l.status==="ready";w.useEffect(()=>{!q||!R||!a?.line||!S.current||(S.current.scrollTop=Math.max(0,(a.line-1)*j-3*j))},[q,R,a?.line,a?.nonce,j]);const L=()=>{navigator.clipboard?.writeText(s).then(()=>{y(!0),setTimeout(()=>y(!1),1500)},()=>t.notify("error",`Could not copy ${s}.`))},O=()=>k(W=>W+1),B=l.status==="ready"?w2(l.content):0,_=mc(l.status==="ready"&&R?l.content:"",s);return o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"file-view","data-path":s,children:[o.jsxs("div",{className:"flex min-h-11 shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-border px-4 py-1.5 text-xs text-muted-foreground",children:[o.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-(length:--code-font-size) text-foreground",title:s,"data-testid":"file-view-path",children:s}),l.status==="ready"?o.jsxs("span",{"data-testid":"file-view-meta",children:[v2(l.size)," · ",B," ",B===1?"line":"lines"]}):null,A&&l.status==="ready"?o.jsxs("span",{className:"flex rounded-md border border-border p-0.5",role:"group","aria-label":"View",children:[o.jsxs("button",{type:"button","aria-pressed":m==="preview",onClick:()=>p("preview"),className:I("flex items-center gap-1 rounded px-2 py-0.5",m==="preview"?"bg-secondary text-foreground":"hover:text-foreground"),children:[o.jsx(lo,{"aria-hidden":!0,className:"size-3.5"}),"Preview"]}),o.jsxs("button",{type:"button","aria-pressed":m==="source",onClick:()=>p("source"),className:I("flex items-center gap-1 rounded px-2 py-0.5",m==="source"?"bg-secondary text-foreground":"hover:text-foreground"),children:[o.jsx(MS,{"aria-hidden":!0,className:"size-3.5"}),"Source"]})]}):null,o.jsx(be,{size:"icon-sm",variant:"ghost",onClick:L,"aria-label":"Copy path",title:x?"Copied":"Copy path","data-testid":"file-view-copy-path",children:o.jsx(bs,{"aria-hidden":!0})}),o.jsx(be,{size:"icon-sm",variant:"ghost",onClick:O,"aria-label":"Refresh",title:"Refresh","data-testid":"file-view-refresh",children:o.jsx(co,{"aria-hidden":!0})})]}),l.status==="loading"?o.jsx("div",{className:"flex flex-1 items-center justify-center","data-testid":"file-view-loading",children:o.jsx(Kt,{label:"Reading the file…"})}):l.status==="error"?o.jsx(cC,{failure:l.failure,onRetry:O,onShowIgnored:()=>h(!0)}):R?o.jsx("div",{ref:S,className:"relative min-h-0 flex-1 overflow-auto","data-testid":"file-view-source",children:o.jsxs("div",{className:"relative flex min-w-max font-mono text-(length:--code-font-size)",style:{lineHeight:`${j}px`},children:[a?.line&&a.line<=B?o.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 bg-highlight/10",style:{top:8+(a.line-1)*j,height:j},"data-testid":"file-view-target-line"}):null,o.jsx("pre",{"aria-hidden":!0,className:"sticky left-0 z-[1] select-none border-r border-border bg-background py-2 pl-3 pr-3 text-right text-extra-muted","data-testid":"file-view-gutter",children:Array.from({length:Math.max(B,1)},(W,E)=>E+1).join(`
|
|
57
|
+
`)}),o.jsx("pre",{className:"relative py-2 pl-4 pr-6 text-foreground","data-testid":"file-view-content",children:_?_.map((W,E)=>o.jsxs(w.Fragment,{children:[E?`
|
|
58
|
+
`:null,o.jsx(pc,{tokens:W})]},E)):l.content})]})}):o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"file-view-preview",children:o.jsx("article",{className:"mx-auto w-full max-w-(--content-width) px-4 py-6 sm:px-6",children:o.jsx(fo,{text:l.content})})})]})}function cC({failure:s,onRetry:t,onShowIgnored:i}){const a=s.reason==="binary"||s.reason==="too_large"||s.reason==="blocked_path"||s.reason==="grant"||s.reason==="capability";return o.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center","data-testid":"file-view-error","data-reason":s.reason??"",children:[o.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",role:a?"note":"alert",children:s.message}),s.reason==="too_large"?o.jsx("p",{className:"text-xs text-extra-muted",children:"Files over 1 MB are not read remotely."}):null,s.reason==="ignored"?o.jsx(be,{size:"sm",variant:"secondary",onClick:i,"data-testid":"file-view-show-ignored",children:"Show anyway"}):a?null:o.jsx(be,{size:"sm",variant:"outline",onClick:t,"data-testid":"file-view-retry",children:"Retry"})]})}const Eh="outline-none focus-visible:ring-2 focus-visible:ring-ring",df=I("flex size-8 shrink-0 items-center justify-center rounded-lg text-extra-muted hover:bg-secondary hover:text-foreground [&_svg]:size-[18px]",Eh);function uC({navOpen:s,onToggleNav:t,explorerOpen:i,onToggleExplorer:a,onRename:l,onArchive:u}){const{tree:d,sessions:h,workspace:m,connection:p,principal:x}=Me(),y=d?.rootId,v=y?d.projection.sessions[y]:void 0,k=y?h.list.find(L=>L.id===y):void 0,S=y?Pn({id:y,title:v?.title??k?.title}):m?Ot(m):"ALP",j=!!y&&y in d.projection.running,A=!!y&&!!d.projection.closed[y],R=Te(x??void 0,"session.write"),q=k??(y?{id:y,title:v?.title}:void 0);return o.jsxs("header",{className:"flex h-14 shrink-0 items-center justify-between gap-2 border-b border-border bg-background px-2 md:h-9 md:px-3",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 md:gap-2",children:[o.jsx("button",{type:"button","aria-label":s?"Close sessions":"Open sessions","aria-expanded":s,title:"Toggle sidebar",onClick:t,className:I(df,"md:-ml-1.5"),children:o.jsx($a,{"aria-hidden":!0,strokeWidth:1.5})}),o.jsxs("div",{className:"flex min-w-0 flex-1 flex-col md:flex-none md:flex-row md:items-center md:gap-2",children:[o.jsx("h1",{className:"min-w-0 truncate text-sm font-normal text-foreground md:font-light",title:S,"data-testid":"workspace-header-title",children:S}),y&&m?o.jsx("span",{className:"min-w-0 truncate text-xs text-muted-foreground md:text-sm",title:m,children:Ot(m)}):null]}),y&&q?o.jsx(Vt,{label:"Session actions",align:"start",trigger:o.jsx(nh,{"aria-hidden":!0,className:"size-[18px]"}),triggerClassName:df,items:[{label:"Rename",icon:o.jsx($i,{"aria-hidden":!0}),onSelect:()=>l(q),disabled:!R},{label:"Copy session ID",icon:o.jsx(bs,{"aria-hidden":!0}),onSelect:()=>{navigator.clipboard?.writeText(y)}},{label:"Archive",icon:o.jsx(ac,{"aria-hidden":!0}),onSelect:()=>u(q),disabled:!R,destructive:!0}]}):null,o.jsx("span",{className:"sr-only","aria-live":"polite",children:p.phase!=="open"?"Reconnecting":y?j?"Agent is working":A?"Session closed":"Agent is idle":""})]}),o.jsx("div",{className:"flex shrink-0 items-center gap-1 md:gap-2",children:o.jsx("button",{type:"button","aria-label":"Agents and tasks","aria-expanded":i,title:"Toggle explorer",onClick:a,className:I(df,"md:-mr-1.5"),"data-testid":"workspace-explorer-toggle",children:o.jsx(oh,{"aria-hidden":!0,strokeWidth:1.5})})})]})}function dC(s){const{tree:t,tasks:i,sessions:a}=Me();if(s.kind==="agent"){const u=t?.projection,d=u?.sessions[s.id],h=s.id===t?.rootId,m=!!u&&Object.values(u.questions).some(k=>k.sessionId===s.id),p=!!u&&s.id in u.running,x=h?a.list.find(k=>k.id===s.id):void 0,y=d?.agent??(h?"main":"agent"),v=h?Pn({id:s.id,title:d?.title??x?.title}):d?.title??y;return{label:v,icon:m?o.jsxs("span",{className:"relative flex size-3.5","data-status":"needs_input",children:[o.jsx(Oa,{"aria-hidden":!0,className:"size-3.5"}),o.jsx(Js,{"aria-hidden":!0,className:"absolute -bottom-0.5 -right-0.5 size-2 fill-dot-warning text-background"})]}):p?o.jsx(m1,{}):o.jsx(Oa,{"aria-hidden":!0,className:"size-3.5"}),title:h?`${v} · ${y}`:`${y} · assignment from main`}}if(s.kind==="draft")return{label:"New session",icon:o.jsx(fc,{"aria-hidden":!0,className:"size-3.5"}),title:"New session"};if(s.kind==="launcher")return{label:"New tab",icon:o.jsx(vs,{"aria-hidden":!0,className:"size-3.5"}),title:"New tab"};if(s.kind==="file")return{label:Ot(s.id),icon:o.jsx(sh,{"aria-hidden":!0,className:"size-3.5"}),title:s.id};if(s.kind==="panel"){const u=Zs[s.id];return{label:u.label,icon:o.jsx(u.icon,{"aria-hidden":!0,className:"size-3.5"}),title:u.label}}const l=i.rows.find(u=>u.id===s.id);return{label:l?.title??s.id,icon:l?.approvals?.length?o.jsx(d0,{"aria-hidden":!0,className:"size-3.5 text-dot-warning"}):l?.status==="closed"?o.jsx(t0,{"aria-hidden":!0,className:"size-3.5 text-highlight"}):o.jsx(qi,{"aria-hidden":!0,className:"size-3.5"}),title:`Task ${s.id}`}}function fC({tab:s,active:t,onSelect:i,onClose:a,onMenu:l,dragging:u,wrapper:d}){const h=dC(s);return o.jsx(Q1,{label:h.label,icon:h.icon,title:h.title,active:t,onSelect:i,onClose:a,onMenu:l,dragging:u,wrapper:d,testId:"workspace-tab","data-tab":qe(s)})}function hC(s,t,i=!1){const{tabs:a,byPane:l,close:u,closeOthers:d}=kt(),{selected:h,sessions:m,tree:p,principal:x}=Me(),y=Oe(),v=Te(x??void 0,"session.write"),k=i?a:l[s]??[],S=i?a:void 0;return j=>{const A=`workspace-tab-context-${qe(j)}`,R=_=>kh(k,j,_,h).length===0,q=[],L=_=>{navigator.clipboard?.writeText(_).catch(()=>{})},O=j.kind==="agent"?y.agentControls(j.id):void 0;if(j.kind==="agent"&&O?.resume.shown&&q.push({id:"copy-resume-command",label:"Copy resume command",icon:o.jsx(bs,{"aria-hidden":!0}),disabled:!O.resume.enabled,title:O.resume.reason,testId:`${A}-copy-resume-command`,onSelect:()=>{y.copyResumeCommand(j.id,_=>navigator.clipboard?navigator.clipboard.writeText(_):Promise.reject(new Error("The browser gives no clipboard here.")))}}),j.kind==="agent"){if(q.push({id:"copy-agent-id",label:"Copy agent id",icon:o.jsx(bs,{"aria-hidden":!0}),hint:j.id.slice(0,7),testId:`${A}-copy-agent-id`,onSelect:()=>L(j.id)}),j.id===h){const W=m.list.find(E=>E.id===j.id)??{id:j.id,title:p?.projection.sessions[j.id]?.title};q.push({id:"rename",label:"Rename",icon:o.jsx($i,{"aria-hidden":!0}),disabled:!v,testId:`${A}-rename`,onSelect:()=>t(W)})}}else j.kind==="file"?q.push({id:"copy-path",label:"Copy path",icon:o.jsx(bs,{"aria-hidden":!0}),testId:`${A}-copy-path`,onSelect:()=>L(j.id)}):j.kind==="task"&&q.push({id:"copy-task-id",label:"Copy task id",icon:o.jsx(bs,{"aria-hidden":!0}),hint:j.id,testId:`${A}-copy-task-id`,onSelect:()=>L(j.id)});const B=[{id:"close-left",label:"Close to the left",icon:o.jsx(Zb,{"aria-hidden":!0}),disabled:R("left"),testId:`${A}-close-left`,onSelect:()=>d(j,"left",S)},{id:"close-right",label:"Close to the right",icon:o.jsx(Jb,{"aria-hidden":!0}),disabled:R("right"),testId:`${A}-close-right`,onSelect:()=>d(j,"right",S)},{id:"close-others",label:"Close other tabs",icon:o.jsx(i0,{"aria-hidden":!0}),disabled:R("others"),testId:`${A}-close-others`,onSelect:()=>d(j,"others",S)},...O?.reload.shown?[{id:"reload-agent",label:"Reload agent",icon:o.jsx(WS,{"aria-hidden":!0}),disabled:!O.reload.enabled,title:O.reload.reason??P2,testId:`${A}-reload-agent`,onSelect:()=>{y.reloadAgent({sessionId:j.id,requestId:Qf()}).catch(()=>{})}}]:[],{id:"close",label:"Close",icon:o.jsx(Zt,{"aria-hidden":!0}),testId:`${A}-close`,onSelect:()=>u(j)}];return q.some(_=>_.id==="rename")&&(B[0]={...B[0],group:!0}),[...q,...B]}}const mC=5,Sc=w.createContext({target:null,setTarget:()=>{},splits:!1}),hb=(s,t,i)=>Array.from(s?.querySelectorAll("[data-drag-tab]")??[]).filter(a=>a.dataset.dragTab!==t).filter(a=>{const l=a.getBoundingClientRect();return l.left+l.width/2<i}).length;function pC(s,t=!1){const{tabs:i,byPane:a,move:l,moveTabToPane:u,splitWith:d}=kt(),h=w.useContext(Sc),m=t?i:a[s]??[],p=w.useRef(null),[x,y]=w.useState(null),v=w.useRef(!1),k=A=>R=>{if(R.button!==0||R.target.closest('[aria-label^="Close "]'))return;const q=qe(A),L=R.clientX,O=R.clientY,B=m.map(qe);let _=!1,W=B.indexOf(q),E=null;v.current=!1;const V=(se,fe)=>se===fe||!!se&&!!fe&&se.pane===fe.pane&&se.kind===fe.kind&&(se.kind==="row"?se.index===fe.index:se.position===fe.position),U=se=>{if(!_&&Math.hypot(se.clientX-L,se.clientY-O)<mC)return;_=!0;const fe=E;E=null;const H=h.splits?document.elementFromPoint(se.clientX,se.clientY):null,P=H?.closest("[data-pane-row]"),oe=H?.closest("[data-pane-body]");if(P&&P.dataset.paneRow!==s)E={pane:P.dataset.paneRow,kind:"row",index:hb(P,q,se.clientX)};else if(oe&&!P){const xe=oe.getBoundingClientRect(),T=ST({width:xe.width,height:xe.height,x:se.clientX-xe.left,y:se.clientY-xe.top}),z=oe.dataset.paneBody;(z!==s||T!=="center"&&B.length>1)&&(E={pane:z,kind:"zone",position:T})}if(V(fe,E)||h.setTarget(E),E){y(null);return}if(oe&&!P){W=-1,y(xe=>xe&&null);return}W=hb(p.current,q,se.clientX),y({key:q,order:qf(B,q,W)})},de=se=>()=>{if(window.removeEventListener("pointermove",U),window.removeEventListener("pointerup",J),window.removeEventListener("pointercancel",me),_){v.current=!0,setTimeout(()=>{v.current=!1},0);const fe=E;se&&fe?.kind==="row"?u(A,fe.pane,fe.index):se&&fe?.kind==="zone"?fe.position==="center"?u(A,fe.pane):d(A,fe.pane,fe.position):se&&W>=0&&l(A,W,t)}h.setTarget(null),y(null)},J=de(!0),me=de(!1);window.addEventListener("pointermove",U),window.addEventListener("pointerup",J),window.addEventListener("pointercancel",me)},S=A=>{v.current&&(v.current=!1,A.stopPropagation(),A.preventDefault())},j=x?D1(m,qe,x.order):m;return{row:p,shown:j,dragging:x?.key??null,wrapper:A=>({onPointerDown:k(A),onClickCapture:S,"data-drag-tab":qe(A)})}}const xv=["terminal","diff"],yv=["tasks","agents"],mb=I("flex size-7 shrink-0 items-center justify-center rounded-md text-extra-muted hover:bg-card hover:text-foreground [&_svg]:size-3.5",Eh);function gC({paneId:s=oo,whole:t=!1,onNewSession:i,onRename:a,menuRequest:l,onMenuRequestHandled:u}){const{activeOf:d,activate:h,close:m,openPanel:p,focusedPane:x,panes:y,splitEmpty:v,canSplitEmpty:k,maximized:S,toggleMaximized:j}=kt(),A=pC(s,t),R=w.useContext(Sc),q=hC(s,a,t),[L,O]=w.useState(null),B=w.useCallback(()=>O(null),[]),_=w.useCallback(()=>A.row.current?.querySelector('[role="tab"][aria-selected="true"]'),[A.row]),{workspace:W,principal:E,connection:V}=Me(),U=Te(E??void 0,"session.write");if(!W)return null;const de=d(s),J=s===x,me=Yt(y.root).length>1,se=ho(),fe=(P,oe=!1)=>{const xe=Zs[P];return{label:xe.label,icon:o.jsx(xe.icon,{"aria-hidden":!0}),onSelect:()=>p(P),group:oe}},H=R.target?.kind==="row"&&R.target.pane===s;return o.jsxs("div",{className:I("flex h-9 shrink-0 items-center border-b border-border bg-background",H&&"bg-secondary/60"),"data-pane-row":s,children:[o.jsxs("div",{ref:A.row,role:"tablist","aria-label":"Open tabs",className:"flex min-w-0 flex-1 items-center overflow-x-auto px-1 [scrollbar-width:none]",children:[A.shown.map(P=>o.jsx(fC,{tab:P,active:!!de&&qe(de)===qe(P),onSelect:()=>h(P),onClose:()=>m(P),onMenu:oe=>O({tab:P,at:oe}),dragging:A.dragging===qe(P),wrapper:A.wrapper(P)},qe(P))),o.jsx(Vt,{label:"New tab",align:"start",openRequest:J?l:void 0,onOpenRequestHandled:u,testId:"workspace-new-tab",trigger:o.jsx(vs,{"aria-hidden":!0,className:"size-4"}),triggerClassName:I("mx-1 flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-card hover:text-foreground",Eh),items:[{label:"Agent",icon:o.jsx(fc,{"aria-hidden":!0}),onSelect:i,disabled:!U||V.phase!=="open"},...xv.map(P=>fe(P)),...yv.map((P,oe)=>fe(P,oe===0))]})]}),R.splits?o.jsxs("div",{className:"flex shrink-0 items-center gap-0.5 pr-1",children:[me?o.jsx("button",{type:"button",className:mb,"aria-pressed":S===s,onClick:()=>j(s),"aria-label":S===s?"Restore pane":"Maximize pane",title:S===s?"Restore pane":"Maximize pane","data-testid":S===s?"workspace-restore-pane":"workspace-maximize-pane",children:S===s?o.jsx(YS,{"aria-hidden":!0}):o.jsx(HS,{"aria-hidden":!0})}):null,o.jsx(Vt,{label:"More actions",testId:"workspace-split-pane-menu",trigger:o.jsx(nh,{"aria-hidden":!0,className:"size-3.5"}),triggerClassName:mb,items:[{id:"split-right",label:"Split pane right",icon:o.jsx(s0,{"aria-hidden":!0}),hint:Pl("pane.split.right",se)||void 0,disabled:!k,testId:"workspace-split-pane-right",onSelect:()=>v("right")},{id:"split-down",label:"Split pane down",icon:o.jsx(u0,{"aria-hidden":!0}),hint:Pl("pane.split.down",se)||void 0,disabled:!k,testId:"workspace-split-pane-down",onSelect:()=>v("bottom")}]})]}):null,o.jsx(u1,{label:"Tab actions",at:L?.at??null,items:L?q(L.tab):[],onClose:B,fallbackFocus:_,testId:L?`workspace-tab-context-${qe(L.tab)}`:void 0})]})}function xC({paneId:s=oo,onNewSession:t}){const{activeOf:i}=kt(),{tree:a,workspace:l}=Me(),u=i(s);return u?.kind==="draft"?o.jsx(tC,{}):u?.kind==="launcher"?o.jsx(yC,{launcher:u.id},u.id):u?.kind==="task"?o.jsx(gv,{id:u.id}):u?.kind==="file"?o.jsx(lC,{path:u.id},`${l??""}
|
|
59
|
+
${u.id}`):u?.kind==="panel"?o.jsx("div",{className:I("min-h-0 flex-1",u.id==="terminal"?"overflow-hidden":"overflow-y-auto"),children:o.jsx(P1,{kind:u.id})}):u?.kind==="agent"&&a?o.jsx(ZA,{sessionId:u.id},u.id):o.jsx(PA,{onNewSession:t})}function yC({launcher:s}){const{launch:t,openPanel:i,openDraft:a}=kt(),{principal:l,connection:u}=Me(),d=Te(l??void 0,"session.write"),h=w.useRef(null),m=w.useContext(Th).focused;w.useEffect(()=>{m&&h.current?.focus({preventScroll:!0})},[]);const p=k=>{const S=k.key==="ArrowDown"?1:k.key==="ArrowUp"?-1:0;if(!S)return;k.preventDefault();const j=Array.from(k.currentTarget.querySelectorAll("button:not(:disabled)")),A=j.indexOf(document.activeElement);j[(A+S+j.length)%j.length]?.focus()},x="flex min-h-11 items-center gap-2 rounded-lg border border-transparent bg-card px-3 text-left text-sm text-foreground outline-none hover:bg-secondary focus-visible:border-ring disabled:pointer-events-none disabled:opacity-50",y=[[{id:"agent",label:"Agent",icon:o.jsx(fc,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),disabled:!d||u.phase!=="open",run:a},...xv.map(k=>{const S=Zs[k];return{id:k,label:S.label,icon:o.jsx(S.icon,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),run:()=>i(k)}})],yv.map(k=>{const S=Zs[k];return{id:k,label:S.label,icon:o.jsx(S.icon,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),run:()=>i(k)}})];let v=-1;return o.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-6","data-testid":"workspace-pane-new-tab-panel",children:o.jsx("div",{className:"flex w-full max-w-[380px] flex-col gap-12",onKeyDown:p,children:y.map((k,S)=>o.jsx("div",{className:"flex flex-col gap-1",children:k.map(j=>(v+=1,o.jsxs("button",{ref:v===0?h:void 0,type:"button",disabled:j.disabled,className:x,"data-testid":`workspace-pane-new-tab-${j.id}`,onClick:()=>t(s,j.run),children:[j.icon,o.jsx("span",{className:"min-w-0 flex-1 truncate",children:j.label})]},j.id)))},S))})})}function bC({position:s}){const t={center:"inset-2",left:"inset-y-0 left-0 w-1/2",right:"inset-y-0 right-0 w-1/2",top:"inset-x-0 top-0 h-1/2",bottom:"inset-x-0 bottom-0 h-1/2"}[s];return o.jsx("div",{"aria-hidden":!0,"data-testid":"workspace-drop-zone","data-position":s,className:I("pointer-events-none absolute z-40 rounded-md border-2 border-highlight bg-highlight/20",t)})}const vC=[{position:"left",label:"Split pane left",icon:o.jsx($a,{"aria-hidden":!0})},{position:"top",label:"Split pane up",icon:o.jsx(FS,{"aria-hidden":!0})},{position:"right",label:"Split pane right",icon:o.jsx(oh,{"aria-hidden":!0})},{position:"bottom",label:"Split pane down",icon:o.jsx(KS,{"aria-hidden":!0})}];function wC(s){const t=s.target;return s.shiftKey||window.getSelection()?.toString()?!0:!!t.closest?.('input, textarea, select, [contenteditable=""], [contenteditable="true"], a[href], .xterm')}function bv({id:s,props:t,whole:i=!1}){const{focusedPane:a,focusPane:l,panes:u,splitEmpty:d,canSplitEmpty:h}=kt(),[m,p]=w.useState(null),x=w.useContext(Sc),y=s===a,v=Yt(u.root).length>1,k=w.useMemo(()=>({id:s,focused:y}),[s,y]),S=x.target?.kind==="zone"&&x.target.pane===s?x.target.position:null,j=A=>{!y&&!A.target.closest?.('[role="menu"]')&&l(s)};return o.jsx(Th.Provider,{value:k,children:o.jsxs("section",{"aria-label":v?`Pane${y?" (focused)":""}`:void 0,"data-testid":`workspace-pane-${s}`,"data-focused":y?"true":"false",onPointerDownCapture:j,onFocusCapture:j,className:I("relative flex min-h-0 min-w-0 flex-1 flex-col bg-background",v&&!y&&"[&_[role=tab][aria-selected=true]]:text-muted-foreground"),children:[o.jsx(gC,{paneId:s,whole:i,...t}),o.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col","data-pane-body":s,onContextMenu:x.splits&&h?A=>{wC(A)||(A.preventDefault(),p({x:A.clientX,y:A.clientY}))}:void 0,children:[o.jsx(xC,{paneId:s,onNewSession:t.onNewSession}),S?o.jsx(bC,{position:S}):null]}),o.jsx(u1,{label:"Pane actions",at:m,onClose:()=>p(null),testId:m?`workspace-pane-context-${s}`:void 0,items:m?vC.map(({position:A,label:R,icon:q})=>({id:`split-${A}`,label:R,icon:q,testId:`workspace-pane-split-${A}`,disabled:!Rf(u,{target:s,position:A}),onSelect:()=>d(A,s)})):[]})]})})}function kC({group:s,index:t,container:i,onPreview:a}){const{resize:l}=kt(),[u,d]=w.useState(!1),h=s.direction==="horizontal",m=(s.sizes[t]??0)+(s.sizes[t+1]??0),p=s.sizes.slice(0,t).reduce((S,j)=>S+j,0),x=S=>{const j=Gr,A=Math.min(m-j,Math.max(j,S)),R=s.sizes.slice();return R[t]=A,R[t+1]=m-A,R},y=S=>l(s.id,x(S)),v=S=>{if(S.button!==0||!i.current)return;S.preventDefault();const j=S.currentTarget,A=i.current.getBoundingClientRect();j.setPointerCapture(S.pointerId),d(!0);let R=null;const q=O=>{const B=h?(O.clientX-A.left)/A.width:(O.clientY-A.top)/A.height;R=x(B-p),a(R)},L=()=>{j.removeEventListener("pointermove",q),j.removeEventListener("pointerup",L),j.removeEventListener("pointercancel",L),j.removeEventListener("lostpointercapture",L),d(!1),R&&l(s.id,R),a(null)};j.addEventListener("pointermove",q),j.addEventListener("pointerup",L),j.addEventListener("pointercancel",L),j.addEventListener("lostpointercapture",L)},k=S=>{const j=S.shiftKey?.1:.02,A=h?"ArrowLeft":"ArrowUp",R=h?"ArrowRight":"ArrowDown",q=s.sizes[t]??0;if(S.key===A)y(q-j);else if(S.key===R)y(q+j);else if(S.key==="Home")y(0);else if(S.key==="End")y(m);else return;S.preventDefault()};return o.jsx("div",{role:"separator","aria-orientation":h?"vertical":"horizontal","aria-label":"Resize panes",tabIndex:0,"aria-valuenow":Math.round((s.sizes[t]??0)*100),"aria-valuemin":0,"aria-valuemax":100,"data-testid":"workspace-split-resize-handle",onPointerDown:v,onKeyDown:k,className:I("group relative z-10 shrink-0 touch-none bg-border outline-none",h?"w-px cursor-col-resize":"h-px cursor-row-resize"),children:o.jsx("span",{"aria-hidden":!0,className:I("absolute bg-ring opacity-0 transition-opacity delay-100 group-hover:opacity-100 group-focus-visible:opacity-100",h?"inset-y-0 -left-[4px] w-[9px]":"inset-x-0 -top-[4px] h-[9px]",u&&"opacity-100")})})}function vv({node:s,props:t}){const i=w.useRef(null),[a,l]=w.useState(null);if(s.kind==="pane")return o.jsx(bv,{id:s.id,props:t});const u={...s,sizes:a&&a.length===s.sizes.length?a:s.sizes};return o.jsx("div",{ref:i,className:I("flex min-h-0 min-w-0 flex-1",s.direction==="horizontal"?"flex-row":"flex-col"),"data-testid":"workspace-split-group","data-direction":s.direction,children:s.children.map((d,h)=>o.jsxs(w.Fragment,{children:[o.jsx("div",{className:"flex min-h-0 min-w-0",style:{flexGrow:u.sizes[h]??0,flexShrink:1,flexBasis:0},"data-testid":"split-group-child",children:o.jsx(vv,{node:d,props:t})}),h<s.children.length-1?o.jsx(kC,{group:u,index:h,container:i,onPreview:l}):null]},d.id))})}function jC(s){const{panes:t,focusedPane:i,maximized:a}=kt(),[l,u]=w.useState(null),d=w.useMemo(()=>({target:l,setTarget:u,splits:s.splits}),[l,s.splits]),h=Yt(t.root),m=!s.splits||h.length<2?i:a&&h.includes(a)?a:null;return o.jsx(Sc.Provider,{value:d,children:o.jsx("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"workspace-panes","data-panes":h.length,children:m?o.jsx(bv,{id:m,props:s,whole:!s.splits&&h.length>1}):o.jsx(vv,{node:t.root,props:s})})})}const SC="outline-none focus-visible:ring-2 focus-visible:ring-ring",ff=I("flex size-8 shrink-0 items-center justify-center rounded-lg text-extra-muted hover:bg-secondary hover:text-foreground [&_svg]:size-[18px]",SC);function NC({navOpen:s,onToggleNav:t,onClose:i}){const{workspace:a}=Me(),[l,u]=w.useState(null),d=w.useRef(null),h=w.useRef(null);w.useEffect(()=>(d.current?.focus(),()=>{setTimeout(()=>document.querySelector('[data-focused="true"] [role="tab"][aria-selected="true"]')?.focus(),0)}),[]);const m=w.useRef({task:l,onClose:i});return m.current={task:l,onClose:i},w.useEffect(()=>{const p=x=>{if(x.key!=="Escape"||x.defaultPrevented||x.isComposing)return;const y=x.target;f1(y)&&y.value||document.querySelector('dialog[open], [role="menu"], [data-modal-overlay]')||(x.preventDefault(),m.current.task&&!TC(h.current)?u(null):m.current.onClose())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[]),o.jsxs("section",{"aria-label":"ALP tasks","data-testid":"alp-tasks-screen",ref:h,className:"flex min-h-0 flex-1 flex-col bg-background text-foreground",children:[o.jsxs("header",{className:"flex h-14 shrink-0 items-center gap-2 border-b border-border px-2 md:h-9 md:px-3",children:[o.jsx("button",{type:"button","aria-label":s?"Close sessions":"Open sessions","aria-expanded":s,title:"Toggle sidebar",onClick:t,className:I(ff,"md:-ml-1.5"),children:o.jsx($a,{"aria-hidden":!0,strokeWidth:1.5})}),o.jsx(qi,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),o.jsx("h1",{className:"min-w-0 truncate text-sm",children:"ALP tasks"}),a?o.jsx("span",{className:"min-w-0 truncate text-xs text-muted-foreground md:text-sm",title:a,children:Ot(a)}):null,o.jsx("span",{className:"flex-1"}),o.jsx("button",{ref:d,type:"button",className:ff,"aria-label":"Close tasks",title:"Close",onClick:i,"data-testid":"alp-tasks-screen-close",children:o.jsx(Zt,{"aria-hidden":!0,strokeWidth:1.5})})]}),o.jsxs("div",{className:"@container flex min-h-0 flex-1",children:[o.jsx("div",{className:I("min-h-0 min-w-0 overflow-y-auto",l?"hidden @[820px]:block @[820px]:w-2/5 @[820px]:shrink-0 @[820px]:border-r @[820px]:border-border":"flex-1"),children:o.jsx($1,{onOpen:u,current:l})}),l?o.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[o.jsx("div",{className:"flex h-10 shrink-0 items-center border-b border-border px-2 @[820px]:hidden",children:o.jsxs("button",{type:"button",className:I(ff,"w-auto gap-1.5 px-2 text-sm text-muted-foreground"),onClick:()=>u(null),"aria-label":"Back to tasks",children:[o.jsx(eh,{"aria-hidden":!0})," Tasks"]})}),o.jsx(gv,{id:l,onOpenTask:u},l)]}):null]})]})}const TC=s=>(s?.getBoundingClientRect().width??0)>=820,Yf={sidebar:E1,dock:M1},AC=400,wv=(s,t=0)=>{const{min:i,max:a}=Yf[s];return{min:i,max:Math.max(i,Math.min(a,(typeof window>"u"?1/0:window.innerWidth)-t-AC))}};function pb(s,t=0){const i=s==="sidebar"?"sidebarWidth":"dockWidth",[a,l]=w.useState(()=>wh(ec())[i]??Yf[s].initial),u=w.useCallback(h=>{O1(ec(),m=>({...m,[i]:h}))},[i]),[,d]=w.useReducer(h=>h+1,0);return w.useEffect(()=>(window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)),[]),{width:Jl(a,wv(s,t))??Yf[s].initial,setWidth:l,save:u,reserved:t}}function gb({which:s,side:t,width:i,reserved:a=0,onWidth:l,onCommit:u,testId:d}){const[h,m]=w.useState(!1),{min:p,max:x}=wv(s,a),y=w.useRef(null);w.useEffect(()=>()=>y.current?.(),[]);const v=j=>Jl(j,{min:p,max:x})??i,k=j=>{if(j.button!==0)return;j.preventDefault();const A=j.clientX,R=i;let q=i;const L=j.currentTarget;L.setPointerCapture(j.pointerId),m(!0);const O=document.body.style.cursor;document.body.style.cursor="col-resize";const B=W=>{const E=W.clientX-A;q=v(R+(t==="right"?E:-E)),l(q)},_=()=>{y.current=null,L.removeEventListener("pointermove",B),L.removeEventListener("pointerup",_),L.removeEventListener("pointercancel",_),L.removeEventListener("lostpointercapture",_),document.body.style.cursor=O,m(!1),u(q)};y.current=_,L.addEventListener("pointermove",B),L.addEventListener("pointerup",_),L.addEventListener("pointercancel",_),L.addEventListener("lostpointercapture",_)},S=j=>{const A=j.shiftKey?48:16,R=t==="right"?1:-1;let q=null;if(j.key==="ArrowRight"?q=i+A*R:j.key==="ArrowLeft"?q=i-A*R:j.key==="Home"?q=p:j.key==="End"&&(q=x),q===null)return;j.preventDefault();const L=v(q);l(L),u(L)};return o.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":s==="sidebar"?"Resize sidebar":"Resize explorer",tabIndex:0,"aria-valuenow":i,"aria-valuemin":p,"aria-valuemax":x,"data-testid":d,onPointerDown:k,onKeyDown:S,className:I("group absolute inset-y-0 z-10 w-2.5 cursor-col-resize touch-none outline-none",t==="right"?"-right-[5px]":"-left-[5px]"),children:o.jsx("span",{"aria-hidden":!0,className:I("absolute inset-y-0 left-1/2 w-[3px] -translate-x-1/2 bg-ring opacity-0 transition-opacity delay-100 group-hover:opacity-100 group-focus-visible:opacity-100",h&&"opacity-100")})})}function xb(s){const t=w.useCallback(i=>{const a=window.matchMedia(s);return a.addEventListener("change",i),()=>a.removeEventListener("change",i)},[s]);return w.useSyncExternalStore(t,()=>window.matchMedia(s).matches,()=>!1)}function CC(){const s=Oe(),{openDraft:t}=kt(),{notice:i}=Me();return w.useEffect(()=>{if(!i)return;const a=setTimeout(()=>s.dismissNotice(),8e3);return()=>clearTimeout(a)},[i,s]),i?o.jsxs("div",{role:i.level==="error"?"alert":"status",className:I("mx-auto my-2 flex w-[min(92%,28rem)] shrink-0 items-start gap-2 rounded-lg border px-3 py-2.5 text-sm shadow-xl shadow-[var(--shadow)]",i.level==="error"?"border-destructive/40 bg-[var(--notice-error)] text-destructive":"border-border bg-popover text-foreground"),children:[i.level==="error"?o.jsx(Js,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0"}):o.jsx(ah,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0 text-info"}),o.jsx("span",{className:"min-w-0 flex-1",children:i.text}),i.action==="new-session"?o.jsx(be,{size:"sm",variant:"secondary",className:"h-7 shrink-0 text-xs",onClick:()=>{s.dismissNotice(),t()},children:"New session"}):null,o.jsx(be,{size:"icon-sm",variant:"ghost","aria-label":"Dismiss",onClick:()=>s.dismissNotice(),children:o.jsx(Zt,{"aria-hidden":!0})})]}):null}function hf(){const s=Oe(),{connection:t}=Me();return t.phase!=="reconnecting"?null:o.jsxs("div",{role:"status",className:"flex items-center gap-2 border-b border-warning/30 bg-warning/10 px-4 py-2 text-xs text-warning",children:[o.jsx(cN,{"aria-hidden":!0,className:"size-4 shrink-0"}),o.jsxs("span",{className:"min-w-0 flex-1",children:["Connection to the host lost. Reconnecting",t.attempt>1?` (attempt ${t.attempt})`:"","… Work on the host keeps running."]}),o.jsx(be,{size:"sm",variant:"ghost",className:"h-7 text-xs text-warning",onClick:()=>s.disconnect(),children:"Disconnect"})]})}function EC({settings:s,history:t,splits:i,onAction:a}){const l=Oe(),{tabs:u,row:d,active:h,activate:m,close:p,openPanel:x,panes:y,focusedPane:v,splitEmpty:k,canSplitEmpty:S,closePane:j,focusAdjacent:A,moveTabAdjacent:R}=kt(),q=i?d:u,{workspace:L}=Me(),O=Yt(y.root).length>1,{sessions:B,selected:_}=Me();return M5((W,E)=>{if(s&&W.action!=="settings.toggle")return!1;const V=(U,de,J)=>U.length?de<0?J>0?0:U.length-1:(de+J+U.length)%U.length:-1;switch(W.action){case"session.index":{const U=B.list[(E??1)-1];return U?(l.selectSession(U.id),a("session.opened",W)):!1}case"session.relative":{const U=V(B.list,B.list.findIndex(de=>de.id===_),W.delta??1);return U<0?!1:(l.selectSession(B.list[U].id),a("session.opened",W))}case"tab.index":{const U=q[(E??1)-1];return U?(m(U),a("tab.shown",W)):!1}case"tab.relative":{const U=V(q,h?q.findIndex(de=>qe(de)===qe(h)):-1,W.delta??1);return U<0?!1:(m(q[U]),a("tab.shown",W))}case"tab.close":return!h||t?!1:(p(h),!0);case"tab.changes":case"tab.files":case"tab.terminal":{const U=W.action.slice(4);return x(U),a("tab.shown",W)}case"pane.split.right":case"pane.split.down":if(!i||t||!L||!S)return!1;k(W.action==="pane.split.right"?"right":"bottom");return;case"pane.focus.left":case"pane.focus.right":case"pane.focus.up":case"pane.focus.down":if(!i||t||!O)return!1;A(W.action.slice(11));return;case"pane.move.left":case"pane.move.right":case"pane.move.up":case"pane.move.down":if(!i||t||!O)return!1;R(W.action.slice(10));return;case"pane.close":if(!i||t||!O)return!1;j(v);return;default:return a(W.action,W,E)}},{allowInModal:["settings.toggle"]}),null}function Wt(s,t,i){const a=xc.find(l=>l.action===s&&l.label&&(!l.mac||t)&&(i===void 0||l.delta===i));return a?gh(ph(a,t),t):void 0}function MC({open:s,scope:t,onClose:i,history:a,splits:l,onAction:u,onOpenSession:d}){const h=Me(),m=Oe(),{workspace:p,principal:x,connection:y,sessions:v,tree:k,selected:S}=h,{tabs:j,row:A,active:R,activate:q,close:L,closeOthers:O,openPanel:B,openFile:_,panes:W,focusedPane:E,splitEmpty:V,canSplitEmpty:U,closePane:de,focusAdjacent:J,moveTabAdjacent:me}=kt(),se=l?A:j,fe=(ye,ge)=>O(ye,ge,l?void 0:j),H=Yt(W.root).length>1,P=ye=>!R||kh(se,R,ye,S).length===0,oe=w.useMemo(()=>ho(),[]),xe=Te(x??void 0,"session.write"),T=y.phase==="open",z=k?.rootId,F=!a&&!!p,Z=R?se.findIndex(ye=>qe(ye)===qe(R)):-1,ie=ye=>{if(!se.length)return;const ge=Z<0?ye>0?0:se.length-1:(Z+ye+se.length)%se.length;q(se[ge]),u("tab.shown")},re=(ye,ge,Ce,je)=>({id:ye,label:Ce,group:"workspace",icon:Zs[ge].icon,shortcut:je,disabled:!p,keywords:["tab","panel"],run:()=>{B(ge),u("tab.shown")}}),le=[{id:"new-session",label:"New session",group:"workspace",always:!0,icon:fc,shortcut:Wt("session.new",oe),keywords:["new agent","start"],disabled:!p||!xe||!T,run:()=>u("session.new")},re("new-terminal","terminal","New terminal",Wt("tab.terminal",oe)),re("open-changes","changes","Open Changes",Wt("tab.changes",oe)),re("open-files","files","Open Files",Wt("tab.files",oe)),re("open-diff","diff","Open Diff"),re("open-agents","agents","Open Agents"),{id:"tab-previous",label:"Previous tab",group:"workspace",icon:th,shortcut:Wt("tab.relative",oe,-1),disabled:!F||se.length<2,run:()=>ie(-1)},{id:"tab-next",label:"Next tab",group:"workspace",icon:Wn,shortcut:Wt("tab.relative",oe,1),disabled:!F||se.length<2,run:()=>ie(1)},{id:"tab-close",label:"Close current tab",group:"workspace",icon:Zt,shortcut:Wt("tab.close",oe),disabled:!F||!R,run:()=>{R&&L(R)}},{id:"tab-close-left",label:"Close to the left",group:"workspace",icon:Zb,keywords:["tabs"],disabled:!F||P("left"),run:()=>{R&&fe(R,"left")}},{id:"tab-close-right",label:"Close to the right",group:"workspace",icon:Jb,keywords:["tabs"],disabled:!F||P("right"),run:()=>{R&&fe(R,"right")}},{id:"tab-close-others",label:"Close other tabs",group:"workspace",icon:i0,disabled:!F||P("others"),run:()=>{R&&fe(R,"others")}},{id:"session-rename",label:"Rename session",group:"workspace",icon:$i,disabled:!z||!xe,run:()=>u("session.rename")},{id:"session-copy-id",label:"Copy session ID",group:"workspace",icon:bs,keywords:["agent id"],disabled:!z,run:()=>{z&&navigator.clipboard?.writeText(z).catch(()=>{})}},{id:"session-archive",label:"Archive session",group:"workspace",icon:ac,shortcut:Wt("session.archive",oe),disabled:!z||!xe,run:()=>u("session.archive")},...l?ve():[],{id:"toggle-explorer",label:"Toggle explorer",group:"workspace",icon:oh,shortcut:Wt("sidebar.right",oe),disabled:a,run:()=>u("sidebar.right")},{id:"history",label:"History",group:"actions",always:!0,icon:cc,keywords:["archived","sessions"],disabled:!p,run:()=>u("history")},{id:"settings",label:"Settings",group:"actions",always:!0,icon:lh,shortcut:Wt("settings.toggle",oe),keywords:["preferences","theme"],run:()=>u("settings.toggle")},{id:"shortcuts",label:"Keyboard shortcuts",group:"actions",always:!0,icon:qS,shortcut:Wt("shortcuts.toggle",oe),keywords:["keys","help"],run:()=>u("shortcuts.toggle")},{id:"toggle-sidebar",label:"Toggle left sidebar",group:"actions",icon:$a,shortcut:Wt("sidebar.left",oe),run:()=>u("sidebar.left")},{id:"search-sessions",label:"Search sessions in the sidebar",group:"actions",icon:Ws,keywords:["filter","find"],disabled:!p,run:()=>u("search")},{id:"alp-open-tasks",label:"Open ALP tasks",group:"alp",always:!0,icon:qi,keywords:["tasks","todo","alp","panel"],disabled:!p,run:()=>{B("tasks"),u("tab.shown")}},{id:"alp-open-tasks-screen",label:"Open ALP tasks full screen",group:"alp",always:!0,icon:qi,keywords:["tasks","todo","alp","phone"],disabled:!p,run:()=>u("tasks.screen")}];function ve(){const ye=F,ge=(je,Ut)=>({id:`pane-focus-${je}`,label:Ut,group:"workspace",icon:AS,keywords:["pane","focus",je],disabled:!ye||!H,run:()=>{J(je)}}),Ce=(je,Ut)=>({id:`pane-move-tab-${je}`,label:Ut,group:"workspace",icon:gS,keywords:["pane","tab","move",je],disabled:!ye||!H||!R,run:()=>{me(je)}});return[{id:"pane-split-right",label:"Split pane right",group:"workspace",icon:s0,shortcut:Wt("pane.split.right",oe),keywords:["split","pane","vertical"],disabled:!ye||!U,run:()=>V("right")},{id:"pane-split-down",label:"Split pane down",group:"workspace",icon:u0,shortcut:Wt("pane.split.down",oe),keywords:["split","pane","horizontal"],disabled:!ye||!U,run:()=>V("bottom")},ge("left","Focus pane left"),ge("right","Focus pane right"),ge("up","Focus pane up"),ge("down","Focus pane down"),Ce("left","Move tab left"),Ce("right","Move tab right"),Ce("up","Move tab up"),Ce("down","Move tab down"),{id:"pane-close",label:"Close pane",group:"workspace",icon:Zt,shortcut:Wt("pane.close",oe),keywords:["pane","close"],disabled:!ye||!H,run:()=>de(E)}]}const Re=v.list.map(ye=>({id:ye.id,title:Pn(ye),subtitle:[p?Ot(p):"",ye.status==="closed"?"Closed":Mi(ye.updatedAt??ye.createdAt)].filter(Boolean).join(" · "),bucket:yh(ye,ic(h,ye.id),ao(h,ye.id)),attention:!!ao(h,ye.id),updatedAt:ye.updatedAt??ye.createdAt})),Ne=ye=>{ye===h.selected?(q({kind:"agent",id:ye}),u("session.opened")):d(ye)},et=w.useMemo(()=>B5(x?.workspaces??[],p),[x,p]),Ue=w.useMemo(()=>({available:y.capabilities.includes("workspace.files"),source:p,search:ye=>m.searchWorkspaceFiles({query:ye,limit:Qb})}),[y.capabilities,p,m]),Qe=ye=>{if(m.filesReadable&&m.canReadFiles){_(ye),u("tab.shown");return}const ge=m.filesReadable?"this access token cannot read files":"this host does not offer file reading",Ce=navigator.clipboard?.writeText(ye);if(!Ce){m.notify("error",`Could not copy ${ye}.`);return}Ce.then(()=>m.notify("info",`Copied ${ye} (${ge})`),()=>m.notify("error",`Could not copy ${ye}.`))},We=ye=>{m.selectWorkspace(ye),u("tab.shown")};return o.jsx(V5,{open:s,scope:t,onClose:i,actions:le,sessions:Re,workspaces:et,files:Ue,onOpenSession:Ne,onSelectWorkspace:We,onPickFile:Qe,mac:oe})}function zC({onOpenSession:s}){return O4({onOpenSession:s}),null}function RC({request:s}){const{openDraft:t}=kt();return w.useEffect(()=>{s&&t()},[s,t]),null}function _C(){const s=xb("(min-width: 1024px)"),t=xb("(min-width: 768px)"),[i,a]=w.useState(!1),[l,u]=w.useState(!1),d=v5(),h=pb("sidebar"),[m,p]=w.useState(0),[x,y]=w.useState(!1),[v,k]=w.useState(null),[S,j]=w.useState(null),[A,R]=w.useState(!1),[q,L]=w.useState(!1),[O,B]=w.useState(0),[_,W]=w.useState(!1),[E,V]=w.useState(0),[U,de]=w.useState(!1),J=()=>{R(!1),de(!1)},me=()=>{de(!1),R(!0)},se=A||U,fe=Oe(),{selected:H,workspace:P,principal:oe,connection:xe,sessions:T,tree:z}=Me(),F=Te(oe??void 0,"session.write");w.useEffect(()=>{H&&(R(!1),de(!1))},[H]);const[Z,ie]=w.useState(!1),[re,le]=w.useState(!1),ve=t?!Z:i,Re=pb("dock",t&&ve?h.width:0),Ne=s?!re:l;w.useEffect(()=>{if(!i&&!l)return;const Ce=je=>{je.key==="Escape"&&(a(!1),u(!1))};return window.addEventListener("keydown",Ce),()=>window.removeEventListener("keydown",Ce)},[i,l]);const et=()=>p(Ce=>Ce+1),Ue=()=>t?ie(Ce=>!Ce):a(Ce=>!Ce),Qe=()=>s?le(Ce=>!Ce):u(Ce=>!Ce),We=()=>{t?ie(!1):a(!0)},ye=()=>{const Ce=z?.rootId;return Ce?T.list.find(je=>je.id===Ce)??{id:Ce,title:z.projection.sessions[Ce]?.title}:null},ge=Ce=>{switch(Ce){case"session.new":case"tab.agent":if(!P||!F||xe.phase!=="open")return!1;J(),et();return;case"session.archive":{const je=ye();if(!je||!F||fe.isArchived(je.id))return!1;j(je);return}case"session.opened":case"tab.shown":J();return;case"search":We(),B(je=>je+1);return;case"command-center.toggle":W(je=>je?!1:{scope:null});return;case"command-center.files":W({scope:"files"});return;case"history":if(!P)return!1;me();return;case"session.rename":{const je=ye();if(!je||!F)return!1;k(je);return}case"shortcuts.toggle":L(je=>!je);return;case"tasks.screen":if(!P)return!1;R(!1),de(!0);return;case"settings.toggle":W(!1),y(je=>!je);return;case"tab.menu":if(!P||se)return!1;V(je=>je+1);return;case"sidebar.left":Ue();return;case"sidebar.right":Qe();return;case"sidebar.both":{const je=!ve&&!Ne;t?ie(!je):a(je),s?le(!je):u(je);return}default:return!1}};return o.jsxs(OT,{children:[o.jsxs("div",{className:"flex h-dvh overflow-hidden",...x?{inert:!0,"aria-hidden":!0}:{},children:[!t&&i?o.jsx("div",{className:"fixed inset-0 z-30 bg-black/60","aria-hidden":!0,onClick:()=>a(!1)}):null,t&&Z?null:o.jsxs("div",{className:I("z-40 shrink-0 border-r border-border bg-sidebar",t?"relative":"fixed inset-y-0 left-0 w-[min(100vw,22rem)] transition-transform duration-200",!t&&!i&&"-translate-x-full"),style:t?{width:h.width}:void 0,"data-testid":"sidebar-column",...!t&&!i?{inert:!0}:{},children:[t?o.jsx(gb,{which:"sidebar",side:"right",width:h.width,onWidth:h.setWidth,onCommit:h.save,testId:"left-sidebar-resize-handle"}):null,o.jsx(R4,{onNewSession:()=>{J(),et()},onRename:k,onArchive:j,onSettings:Ce=>y(Ce??!0),onShortcuts:()=>L(!0),onNavigate:()=>a(!1),onClose:t?void 0:()=>a(!1),onHistory:()=>me(),historyOpen:A,onTasks:()=>{P&&(R(!1),de(!0))},tasksOpen:U,onOpenSession:()=>J(),searchRequest:O,onSearchRequestHandled:()=>B(0)})]}),o.jsxs("main",{className:"flex min-w-0 flex-1 flex-col bg-background",children:[U?o.jsxs(o.Fragment,{children:[o.jsx(hf,{}),o.jsx(NC,{navOpen:ve,onToggleNav:Ue,onClose:J})]}):A?o.jsxs(o.Fragment,{children:[o.jsx(hf,{}),o.jsx(C5,{navOpen:ve,onToggleNav:Ue,onOpen:()=>J(),onBack:()=>J()})]}):o.jsxs(o.Fragment,{children:[o.jsx(uC,{navOpen:ve,onToggleNav:Ue,explorerOpen:Ne,onToggleExplorer:Qe,onRename:k,onArchive:j}),o.jsx(hf,{}),o.jsx(jC,{splits:t,onNewSession:et,onRename:k,menuRequest:E,onMenuRequestHandled:()=>V(0)})]}),o.jsx(CC,{})]}),Ne&&!se?o.jsxs(o.Fragment,{children:[s?null:o.jsx("div",{className:"fixed inset-0 z-30 bg-black/60","aria-hidden":!0,onClick:()=>u(!1)}),o.jsxs("div",{className:I("shrink-0 border-l border-border bg-sidebar",s?"relative":"fixed inset-y-0 right-0 z-40 w-[min(100vw,24rem)] shadow-2xl"),style:s?{width:Re.width}:void 0,"data-testid":"explorer-column",children:[s?o.jsx(gb,{which:"dock",side:"left",width:Re.width,reserved:Re.reserved,onWidth:Re.setWidth,onCommit:Re.save,testId:"workspace-explorer-sidebar-resize-handle"}):null,o.jsx(w5,{dock:d,onClose:s?void 0:()=>u(!1)})]})]}):null,o.jsx(RC,{request:m}),o.jsx(zC,{onOpenSession:Ce=>{fe.selectSession(Ce),J(),y(!1)}}),o.jsx(b3,{session:v,onClose:()=>k(null)}),o.jsx(v3,{session:S,onClose:()=>j(null)}),o.jsx(z5,{open:q,onClose:()=>L(!1)}),o.jsx(MC,{open:!!_,scope:_?_.scope:null,onClose:()=>W(!1),history:se,splits:t,onAction:ge,onOpenSession:Ce=>{fe.selectSession(Ce),J(),a(!1)}}),o.jsx(EC,{settings:!!x,history:se,splits:t,onAction:ge})]}),x?o.jsx("div",{className:"fixed inset-0 z-50","data-modal-overlay":!0,children:o.jsx(lT,{mobile:!t,initialPage:typeof x=="string"?x:void 0,onClose:()=>y(!1)})}):null]})}function LC(){const{principal:s,connection:t,preferences:i}=Me();w.useLayoutEffect(()=>X3(i.theme,i.syntaxTheme),[i.theme,i.syntaxTheme]);const{uiFontFamily:a,monoFontFamily:l,uiFontSize:u,contentFontSize:d,codeFontSize:h,contentMaxWidth:m}=i;return w.useLayoutEffect(()=>P3({uiFontFamily:a,monoFontFamily:l,uiFontSize:u,contentFontSize:d,codeFontSize:h,contentMaxWidth:m}),[a,l,u,d,h,m]),!!s&&(t.phase==="open"||t.phase==="reconnecting")?o.jsx(_C,{}):o.jsx(g3,{})}function OC(){try{return window.localStorage}catch{return}}function DC(){try{return window.sessionStorage}catch{return}}const Mh=DC(),Aa=Tb({location:window.location,history:window.history,storage:Mh}),Ba=new uS({storage:OC(),linkStorage:Mh});Aa&&"token"in Aa?Ba.connect({url:Aa.url,token:Aa.token,link:!0}):Aa&&Ba.showError(Aa.error);window.addEventListener("pagehide",()=>Ba.disconnect({keepTerminals:!0,keepLink:!0}));window.addEventListener("pageshow",s=>{if(!s.persisted)return;const t=Tb({location:window.location,history:window.history,storage:Mh});t&&"token"in t&&Ba.connect({url:t.url,token:t.token,link:!0})});window.addEventListener("storage",s=>{(s.key===Jf||s.key===null)&&Ba.reloadPreferences()});Vk.createRoot(document.getElementById("root")).render(o.jsx(w.StrictMode,{children:o.jsx(d3,{controller:Ba,children:o.jsx(LC,{})})}));export{be as B,Z0 as D,uo as R,hc as S,$C as T,Me as a,d0 as b,qC as c,UC as e,o as j,BC as p,w as r,HC as t,Oe as u};
|