teamtrail 0.52.0 → 0.52.1
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.
|
@@ -6,7 +6,7 @@ var fw=Object.defineProperty;var mw=(e,t,s)=>t in e?fw(e,t,{enumerable:!0,config
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Gf;function pw(){if(Gf)return xe;Gf=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),
|
|
9
|
+
*/var Gf;function pw(){if(Gf)return xe;Gf=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),k=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=k&&T[k]||T["@@iterator"],typeof T=="function"?T:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,S={};function I(T,P,de){this.props=T,this.context=P,this.refs=S,this.updater=de||j}I.prototype.isReactComponent={},I.prototype.setState=function(T,P){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,P,"setState")},I.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function $(){}$.prototype=I.prototype;function _(T,P,de){this.props=T,this.context=P,this.refs=S,this.updater=de||j}var O=_.prototype=new $;O.constructor=_,N(O,I.prototype),O.isPureReactComponent=!0;var D=Array.isArray,q=Object.prototype.hasOwnProperty,H={current:null},G={key:!0,ref:!0,__self:!0,__source:!0};function oe(T,P,de){var me,we={},je=null,ge=null;if(P!=null)for(me in P.ref!==void 0&&(ge=P.ref),P.key!==void 0&&(je=""+P.key),P)q.call(P,me)&&!G.hasOwnProperty(me)&&(we[me]=P[me]);var Se=arguments.length-2;if(Se===1)we.children=de;else if(1<Se){for(var ve=Array(Se),Fe=0;Fe<Se;Fe++)ve[Fe]=arguments[Fe+2];we.children=ve}if(T&&T.defaultProps)for(me in Se=T.defaultProps,Se)we[me]===void 0&&(we[me]=Se[me]);return{$$typeof:e,type:T,key:je,ref:ge,props:we,_owner:H.current}}function Q(T,P){return{$$typeof:e,type:T.type,key:P,ref:T.ref,props:T.props,_owner:T._owner}}function ke(T){return typeof T=="object"&&T!==null&&T.$$typeof===e}function Oe(T){var P={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(de){return P[de]})}var Te=/\/+/g;function ne(T,P){return typeof T=="object"&&T!==null&&T.key!=null?Oe(""+T.key):P.toString(36)}function ce(T,P,de,me,we){var je=typeof T;(je==="undefined"||je==="boolean")&&(T=null);var ge=!1;if(T===null)ge=!0;else switch(je){case"string":case"number":ge=!0;break;case"object":switch(T.$$typeof){case e:case t:ge=!0}}if(ge)return ge=T,we=we(ge),T=me===""?"."+ne(ge,0):me,D(we)?(de="",T!=null&&(de=T.replace(Te,"$&/")+"/"),ce(we,P,de,"",function(Fe){return Fe})):we!=null&&(ke(we)&&(we=Q(we,de+(!we.key||ge&&ge.key===we.key?"":(""+we.key).replace(Te,"$&/")+"/")+T)),P.push(we)),1;if(ge=0,me=me===""?".":me+":",D(T))for(var Se=0;Se<T.length;Se++){je=T[Se];var ve=me+ne(je,Se);ge+=ce(je,P,de,ve,we)}else if(ve=w(T),typeof ve=="function")for(T=ve.call(T),Se=0;!(je=T.next()).done;)je=je.value,ve=me+ne(je,Se++),ge+=ce(je,P,de,ve,we);else if(je==="object")throw P=String(T),Error("Objects are not valid as a React child (found: "+(P==="[object Object]"?"object with keys {"+Object.keys(T).join(", ")+"}":P)+"). If you meant to render a collection of children, use an array instead.");return ge}function F(T,P,de){if(T==null)return T;var me=[],we=0;return ce(T,me,"","",function(je){return P.call(de,je,we++)}),me}function J(T){if(T._status===-1){var P=T._result;P=P(),P.then(function(de){(T._status===0||T._status===-1)&&(T._status=1,T._result=de)},function(de){(T._status===0||T._status===-1)&&(T._status=2,T._result=de)}),T._status===-1&&(T._status=0,T._result=P)}if(T._status===1)return T._result.default;throw T._result}var ie={current:null},W={transition:null},X={ReactCurrentDispatcher:ie,ReactCurrentBatchConfig:W,ReactCurrentOwner:H};function z(){throw Error("act(...) is not supported in production builds of React.")}return xe.Children={map:F,forEach:function(T,P,de){F(T,function(){P.apply(this,arguments)},de)},count:function(T){var P=0;return F(T,function(){P++}),P},toArray:function(T){return F(T,function(P){return P})||[]},only:function(T){if(!ke(T))throw Error("React.Children.only expected to receive a single React element child.");return T}},xe.Component=I,xe.Fragment=s,xe.Profiler=a,xe.PureComponent=_,xe.StrictMode=o,xe.Suspense=f,xe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=X,xe.act=z,xe.cloneElement=function(T,P,de){if(T==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+T+".");var me=N({},T.props),we=T.key,je=T.ref,ge=T._owner;if(P!=null){if(P.ref!==void 0&&(je=P.ref,ge=H.current),P.key!==void 0&&(we=""+P.key),T.type&&T.type.defaultProps)var Se=T.type.defaultProps;for(ve in P)q.call(P,ve)&&!G.hasOwnProperty(ve)&&(me[ve]=P[ve]===void 0&&Se!==void 0?Se[ve]:P[ve])}var ve=arguments.length-2;if(ve===1)me.children=de;else if(1<ve){Se=Array(ve);for(var Fe=0;Fe<ve;Fe++)Se[Fe]=arguments[Fe+2];me.children=Se}return{$$typeof:e,type:T.type,key:we,ref:je,props:me,_owner:ge}},xe.createContext=function(T){return T={$$typeof:d,_currentValue:T,_currentValue2:T,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},T.Provider={$$typeof:l,_context:T},T.Consumer=T},xe.createElement=oe,xe.createFactory=function(T){var P=oe.bind(null,T);return P.type=T,P},xe.createRef=function(){return{current:null}},xe.forwardRef=function(T){return{$$typeof:h,render:T}},xe.isValidElement=ke,xe.lazy=function(T){return{$$typeof:v,_payload:{_status:-1,_result:T},_init:J}},xe.memo=function(T,P){return{$$typeof:p,type:T,compare:P===void 0?null:P}},xe.startTransition=function(T){var P=W.transition;W.transition={};try{T()}finally{W.transition=P}},xe.unstable_act=z,xe.useCallback=function(T,P){return ie.current.useCallback(T,P)},xe.useContext=function(T){return ie.current.useContext(T)},xe.useDebugValue=function(){},xe.useDeferredValue=function(T){return ie.current.useDeferredValue(T)},xe.useEffect=function(T,P){return ie.current.useEffect(T,P)},xe.useId=function(){return ie.current.useId()},xe.useImperativeHandle=function(T,P,de){return ie.current.useImperativeHandle(T,P,de)},xe.useInsertionEffect=function(T,P){return ie.current.useInsertionEffect(T,P)},xe.useLayoutEffect=function(T,P){return ie.current.useLayoutEffect(T,P)},xe.useMemo=function(T,P){return ie.current.useMemo(T,P)},xe.useReducer=function(T,P,de){return ie.current.useReducer(T,P,de)},xe.useRef=function(T){return ie.current.useRef(T)},xe.useState=function(T){return ie.current.useState(T)},xe.useSyncExternalStore=function(T,P,de){return ie.current.useSyncExternalStore(T,P,de)},xe.useTransition=function(){return ie.current.useTransition()},xe.version="18.3.1",xe}var qf;function wd(){return qf||(qf=1,xc.exports=pw()),xc.exports}/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.production.min.js
|
|
12
12
|
*
|
|
@@ -14,7 +14,7 @@ var fw=Object.defineProperty;var mw=(e,t,s)=>t in e?fw(e,t,{enumerable:!0,config
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Qf;function gw(){if(Qf)return qi;Qf=1;var e=wd(),t=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function d(h,f,p){var k
|
|
17
|
+
*/var Qf;function gw(){if(Qf)return qi;Qf=1;var e=wd(),t=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function d(h,f,p){var v,k={},w=null,j=null;p!==void 0&&(w=""+p),f.key!==void 0&&(w=""+f.key),f.ref!==void 0&&(j=f.ref);for(v in f)o.call(f,v)&&!l.hasOwnProperty(v)&&(k[v]=f[v]);if(h&&h.defaultProps)for(v in f=h.defaultProps,f)k[v]===void 0&&(k[v]=f[v]);return{$$typeof:t,type:h,key:w,ref:j,props:k,_owner:a.current}}return qi.Fragment=s,qi.jsx=d,qi.jsxs=d,qi}var Yf;function vw(){return Yf||(Yf=1,wc.exports=gw()),wc.exports}var i=vw(),No={},jc={exports:{}},xt={},Sc={exports:{}},Nc={};/**
|
|
18
18
|
* @license React
|
|
19
19
|
* scheduler.production.min.js
|
|
20
20
|
*
|
|
@@ -22,7 +22,7 @@ var fw=Object.defineProperty;var mw=(e,t,s)=>t in e?fw(e,t,{enumerable:!0,config
|
|
|
22
22
|
*
|
|
23
23
|
* This source code is licensed under the MIT license found in the
|
|
24
24
|
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/var Jf;function kw(){return Jf||(Jf=1,(function(e){function t(W,X){var z=W.length;W.push(X);e:for(;0<z;){var T=z-1>>>1,P=W[T];if(0<a(P,X))W[T]=X,W[z]=P,z=T;else break e}}function s(W){return W.length===0?null:W[0]}function o(W){if(W.length===0)return null;var X=W[0],z=W.pop();if(z!==X){W[0]=z;e:for(var T=0,P=W.length,de=P>>>1;T<de;){var me=2*(T+1)-1,we=W[me],je=me+1,ge=W[je];if(0>a(we,z))je<P&&0>a(ge,we)?(W[T]=ge,W[je]=z,T=je):(W[T]=we,W[me]=z,T=me);else if(je<P&&0>a(ge,z))W[T]=ge,W[je]=z,T=je;else break e}}return X}function a(W,X){var z=W.sortIndex-X.sortIndex;return z!==0?z:W.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var d=Date,h=d.now();e.unstable_now=function(){return d.now()-h}}var f=[],p=[],
|
|
25
|
+
*/var Jf;function kw(){return Jf||(Jf=1,(function(e){function t(W,X){var z=W.length;W.push(X);e:for(;0<z;){var T=z-1>>>1,P=W[T];if(0<a(P,X))W[T]=X,W[z]=P,z=T;else break e}}function s(W){return W.length===0?null:W[0]}function o(W){if(W.length===0)return null;var X=W[0],z=W.pop();if(z!==X){W[0]=z;e:for(var T=0,P=W.length,de=P>>>1;T<de;){var me=2*(T+1)-1,we=W[me],je=me+1,ge=W[je];if(0>a(we,z))je<P&&0>a(ge,we)?(W[T]=ge,W[je]=z,T=je):(W[T]=we,W[me]=z,T=me);else if(je<P&&0>a(ge,z))W[T]=ge,W[je]=z,T=je;else break e}}return X}function a(W,X){var z=W.sortIndex-X.sortIndex;return z!==0?z:W.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var d=Date,h=d.now();e.unstable_now=function(){return d.now()-h}}var f=[],p=[],v=1,k=null,w=3,j=!1,N=!1,S=!1,I=typeof setTimeout=="function"?setTimeout:null,$=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function O(W){for(var X=s(p);X!==null;){if(X.callback===null)o(p);else if(X.startTime<=W)o(p),X.sortIndex=X.expirationTime,t(f,X);else break;X=s(p)}}function D(W){if(S=!1,O(W),!N)if(s(f)!==null)N=!0,J(q);else{var X=s(p);X!==null&&ie(D,X.startTime-W)}}function q(W,X){N=!1,S&&(S=!1,$(oe),oe=-1),j=!0;var z=w;try{for(O(X),k=s(f);k!==null&&(!(k.expirationTime>X)||W&&!Oe());){var T=k.callback;if(typeof T=="function"){k.callback=null,w=k.priorityLevel;var P=T(k.expirationTime<=X);X=e.unstable_now(),typeof P=="function"?k.callback=P:k===s(f)&&o(f),O(X)}else o(f);k=s(f)}if(k!==null)var de=!0;else{var me=s(p);me!==null&&ie(D,me.startTime-X),de=!1}return de}finally{k=null,w=z,j=!1}}var H=!1,G=null,oe=-1,Q=5,ke=-1;function Oe(){return!(e.unstable_now()-ke<Q)}function Te(){if(G!==null){var W=e.unstable_now();ke=W;var X=!0;try{X=G(!0,W)}finally{X?ne():(H=!1,G=null)}}else H=!1}var ne;if(typeof _=="function")ne=function(){_(Te)};else if(typeof MessageChannel<"u"){var ce=new MessageChannel,F=ce.port2;ce.port1.onmessage=Te,ne=function(){F.postMessage(null)}}else ne=function(){I(Te,0)};function J(W){G=W,H||(H=!0,ne())}function ie(W,X){oe=I(function(){W(e.unstable_now())},X)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(W){W.callback=null},e.unstable_continueExecution=function(){N||j||(N=!0,J(q))},e.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Q=0<W?Math.floor(1e3/W):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_getFirstCallbackNode=function(){return s(f)},e.unstable_next=function(W){switch(w){case 1:case 2:case 3:var X=3;break;default:X=w}var z=w;w=X;try{return W()}finally{w=z}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(W,X){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var z=w;w=W;try{return X()}finally{w=z}},e.unstable_scheduleCallback=function(W,X,z){var T=e.unstable_now();switch(typeof z=="object"&&z!==null?(z=z.delay,z=typeof z=="number"&&0<z?T+z:T):z=T,W){case 1:var P=-1;break;case 2:P=250;break;case 5:P=1073741823;break;case 4:P=1e4;break;default:P=5e3}return P=z+P,W={id:v++,callback:X,priorityLevel:W,startTime:z,expirationTime:P,sortIndex:-1},z>T?(W.sortIndex=z,t(p,W),s(f)===null&&W===s(p)&&(S?($(oe),oe=-1):S=!0,ie(D,z-T))):(W.sortIndex=P,t(f,W),N||j||(N=!0,J(q))),W},e.unstable_shouldYield=Oe,e.unstable_wrapCallback=function(W){var X=w;return function(){var z=w;w=X;try{return W.apply(this,arguments)}finally{w=z}}}})(Nc)),Nc}var Xf;function yw(){return Xf||(Xf=1,Sc.exports=kw()),Sc.exports}/**
|
|
26
26
|
* @license React
|
|
27
27
|
* react-dom.production.min.js
|
|
28
28
|
*
|
|
@@ -30,14 +30,14 @@ var fw=Object.defineProperty;var mw=(e,t,s)=>t in e?fw(e,t,{enumerable:!0,config
|
|
|
30
30
|
*
|
|
31
31
|
* This source code is licensed under the MIT license found in the
|
|
32
32
|
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/var Zf;function ww(){if(Zf)return xt;Zf=1;var e=wd(),t=yw();function s(n){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+n,c=1;c<arguments.length;c++)r+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+n+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,a={};function l(n,r){d(n,r),d(n+"Capture",r)}function d(n,r){for(a[n]=r,n=0;n<r.length;n++)o.add(r[n])}var h=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),f=Object.prototype.hasOwnProperty,p=/^[: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]*$/,
|
|
33
|
+
*/var Zf;function ww(){if(Zf)return xt;Zf=1;var e=wd(),t=yw();function s(n){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+n,c=1;c<arguments.length;c++)r+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+n+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,a={};function l(n,r){d(n,r),d(n+"Capture",r)}function d(n,r){for(a[n]=r,n=0;n<r.length;n++)o.add(r[n])}var h=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),f=Object.prototype.hasOwnProperty,p=/^[: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]*$/,v={},k={};function w(n){return f.call(k,n)?!0:f.call(v,n)?!1:p.test(n)?k[n]=!0:(v[n]=!0,!1)}function j(n,r,c,u){if(c!==null&&c.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return u?!1:c!==null?!c.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function N(n,r,c,u){if(r===null||typeof r>"u"||j(n,r,c,u))return!0;if(u)return!1;if(c!==null)switch(c.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function S(n,r,c,u,m,g,x){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=u,this.attributeNamespace=m,this.mustUseProperty=c,this.propertyName=n,this.type=r,this.sanitizeURL=g,this.removeEmptyString=x}var I={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){I[n]=new S(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var r=n[0];I[r]=new S(r,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){I[n]=new S(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){I[n]=new S(n,2,!1,n,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){I[n]=new S(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){I[n]=new S(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){I[n]=new S(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){I[n]=new S(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){I[n]=new S(n,5,!1,n.toLowerCase(),null,!1,!1)});var $=/[\-:]([a-z])/g;function _(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var r=n.replace($,_);I[r]=new S(r,1,!1,n,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var r=n.replace($,_);I[r]=new S(r,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(n){var r=n.replace($,_);I[r]=new S(r,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){I[n]=new S(n,1,!1,n.toLowerCase(),null,!1,!1)}),I.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){I[n]=new S(n,1,!1,n.toLowerCase(),null,!0,!0)});function O(n,r,c,u){var m=I.hasOwnProperty(r)?I[r]:null;(m!==null?m.type!==0:u||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(N(r,c,m,u)&&(c=null),u||m===null?w(r)&&(c===null?n.removeAttribute(r):n.setAttribute(r,""+c)):m.mustUseProperty?n[m.propertyName]=c===null?m.type===3?!1:"":c:(r=m.attributeName,u=m.attributeNamespace,c===null?n.removeAttribute(r):(m=m.type,c=m===3||m===4&&c===!0?"":""+c,u?n.setAttributeNS(u,r,c):n.setAttribute(r,c))))}var D=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,q=Symbol.for("react.element"),H=Symbol.for("react.portal"),G=Symbol.for("react.fragment"),oe=Symbol.for("react.strict_mode"),Q=Symbol.for("react.profiler"),ke=Symbol.for("react.provider"),Oe=Symbol.for("react.context"),Te=Symbol.for("react.forward_ref"),ne=Symbol.for("react.suspense"),ce=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),ie=Symbol.for("react.offscreen"),W=Symbol.iterator;function X(n){return n===null||typeof n!="object"?null:(n=W&&n[W]||n["@@iterator"],typeof n=="function"?n:null)}var z=Object.assign,T;function P(n){if(T===void 0)try{throw Error()}catch(c){var r=c.stack.trim().match(/\n( *(at )?)/);T=r&&r[1]||""}return`
|
|
34
34
|
`+T+n}var de=!1;function me(n,r){if(!n||de)return"";de=!0;var c=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(L){var u=L}Reflect.construct(n,[],r)}else{try{r.call()}catch(L){u=L}n.call(r.prototype)}else{try{throw Error()}catch(L){u=L}n()}}catch(L){if(L&&u&&typeof L.stack=="string"){for(var m=L.stack.split(`
|
|
35
35
|
`),g=u.stack.split(`
|
|
36
36
|
`),x=m.length-1,b=g.length-1;1<=x&&0<=b&&m[x]!==g[b];)b--;for(;1<=x&&0<=b;x--,b--)if(m[x]!==g[b]){if(x!==1||b!==1)do if(x--,b--,0>b||m[x]!==g[b]){var C=`
|
|
37
37
|
`+m[x].replace(" at new "," at ");return n.displayName&&C.includes("<anonymous>")&&(C=C.replace("<anonymous>",n.displayName)),C}while(1<=x&&0<=b);break}}}finally{de=!1,Error.prepareStackTrace=c}return(n=n?n.displayName||n.name:"")?P(n):""}function we(n){switch(n.tag){case 5:return P(n.type);case 16:return P("Lazy");case 13:return P("Suspense");case 19:return P("SuspenseList");case 0:case 2:case 15:return n=me(n.type,!1),n;case 11:return n=me(n.type.render,!1),n;case 1:return n=me(n.type,!0),n;default:return""}}function je(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case G:return"Fragment";case H:return"Portal";case Q:return"Profiler";case oe:return"StrictMode";case ne:return"Suspense";case ce:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Oe:return(n.displayName||"Context")+".Consumer";case ke:return(n._context.displayName||"Context")+".Provider";case Te:var r=n.render;return n=n.displayName,n||(n=r.displayName||r.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case F:return r=n.displayName||null,r!==null?r:je(n.type)||"Memo";case J:r=n._payload,n=n._init;try{return je(n(r))}catch{}}return null}function ge(n){var r=n.type;switch(n.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=r.render,n=n.displayName||n.name||"",r.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return je(r);case 8:return r===oe?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r}return null}function Se(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function ve(n){var r=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Fe(n){var r=ve(n)?"checked":"value",c=Object.getOwnPropertyDescriptor(n.constructor.prototype,r),u=""+n[r];if(!n.hasOwnProperty(r)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var m=c.get,g=c.set;return Object.defineProperty(n,r,{configurable:!0,get:function(){return m.call(this)},set:function(x){u=""+x,g.call(this,x)}}),Object.defineProperty(n,r,{enumerable:c.enumerable}),{getValue:function(){return u},setValue:function(x){u=""+x},stopTracking:function(){n._valueTracker=null,delete n[r]}}}}function Cn(n){n._valueTracker||(n._valueTracker=Fe(n))}function mr(n){if(!n)return!1;var r=n._valueTracker;if(!r)return!0;var c=r.getValue(),u="";return n&&(u=ve(n)?n.checked?"true":"false":n.value),n=u,n!==c?(r.setValue(n),!0):!1}function ks(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function Ca(n,r){var c=r.checked;return z({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:c??n._wrapperState.initialChecked})}function Zd(n,r){var c=r.defaultValue==null?"":r.defaultValue,u=r.checked!=null?r.checked:r.defaultChecked;c=Se(r.value!=null?r.value:c),n._wrapperState={initialChecked:u,initialValue:c,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function eu(n,r){r=r.checked,r!=null&&O(n,"checked",r,!1)}function Ta(n,r){eu(n,r);var c=Se(r.value),u=r.type;if(c!=null)u==="number"?(c===0&&n.value===""||n.value!=c)&&(n.value=""+c):n.value!==""+c&&(n.value=""+c);else if(u==="submit"||u==="reset"){n.removeAttribute("value");return}r.hasOwnProperty("value")?Ea(n,r.type,c):r.hasOwnProperty("defaultValue")&&Ea(n,r.type,Se(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(n.defaultChecked=!!r.defaultChecked)}function tu(n,r,c){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var u=r.type;if(!(u!=="submit"&&u!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+n._wrapperState.initialValue,c||r===n.value||(n.value=r),n.defaultValue=r}c=n.name,c!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,c!==""&&(n.name=c)}function Ea(n,r,c){(r!=="number"||ks(n.ownerDocument)!==n)&&(c==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+c&&(n.defaultValue=""+c))}var ci=Array.isArray;function ys(n,r,c,u){if(n=n.options,r){r={};for(var m=0;m<c.length;m++)r["$"+c[m]]=!0;for(c=0;c<n.length;c++)m=r.hasOwnProperty("$"+n[c].value),n[c].selected!==m&&(n[c].selected=m),m&&u&&(n[c].defaultSelected=!0)}else{for(c=""+Se(c),r=null,m=0;m<n.length;m++){if(n[m].value===c){n[m].selected=!0,u&&(n[m].defaultSelected=!0);return}r!==null||n[m].disabled||(r=n[m])}r!==null&&(r.selected=!0)}}function Aa(n,r){if(r.dangerouslySetInnerHTML!=null)throw Error(s(91));return z({},r,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function nu(n,r){var c=r.value;if(c==null){if(c=r.children,r=r.defaultValue,c!=null){if(r!=null)throw Error(s(92));if(ci(c)){if(1<c.length)throw Error(s(93));c=c[0]}r=c}r==null&&(r=""),c=r}n._wrapperState={initialValue:Se(c)}}function su(n,r){var c=Se(r.value),u=Se(r.defaultValue);c!=null&&(c=""+c,c!==n.value&&(n.value=c),r.defaultValue==null&&n.defaultValue!==c&&(n.defaultValue=c)),u!=null&&(n.defaultValue=""+u)}function iu(n){var r=n.textContent;r===n._wrapperState.initialValue&&r!==""&&r!==null&&(n.value=r)}function ru(n){switch(n){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Ia(n,r){return n==null||n==="http://www.w3.org/1999/xhtml"?ru(r):n==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var pr,ou=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,c,u,m){MSApp.execUnsafeLocalFunction(function(){return n(r,c,u,m)})}:n})(function(n,r){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=r;else{for(pr=pr||document.createElement("div"),pr.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=pr.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;r.firstChild;)n.appendChild(r.firstChild)}});function di(n,r){if(r){var c=n.firstChild;if(c&&c===n.lastChild&&c.nodeType===3){c.nodeValue=r;return}}n.textContent=r}var ui={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},vk=["Webkit","ms","Moz","O"];Object.keys(ui).forEach(function(n){vk.forEach(function(r){r=r+n.charAt(0).toUpperCase()+n.substring(1),ui[r]=ui[n]})});function au(n,r,c){return r==null||typeof r=="boolean"||r===""?"":c||typeof r!="number"||r===0||ui.hasOwnProperty(n)&&ui[n]?(""+r).trim():r+"px"}function lu(n,r){n=n.style;for(var c in r)if(r.hasOwnProperty(c)){var u=c.indexOf("--")===0,m=au(c,r[c],u);c==="float"&&(c="cssFloat"),u?n.setProperty(c,m):n[c]=m}}var kk=z({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ra(n,r){if(r){if(kk[n]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(s(137,n));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(s(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(s(61))}if(r.style!=null&&typeof r.style!="object")throw Error(s(62))}}function Ma(n,r){if(n.indexOf("-")===-1)return typeof r.is=="string";switch(n){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 La=null;function Oa(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Pa=null,ws=null,xs=null;function cu(n){if(n=Mi(n)){if(typeof Pa!="function")throw Error(s(280));var r=n.stateNode;r&&(r=Dr(r),Pa(n.stateNode,n.type,r))}}function du(n){ws?xs?xs.push(n):xs=[n]:ws=n}function uu(){if(ws){var n=ws,r=xs;if(xs=ws=null,cu(n),r)for(n=0;n<r.length;n++)cu(r[n])}}function hu(n,r){return n(r)}function fu(){}var _a=!1;function mu(n,r,c){if(_a)return n(r,c);_a=!0;try{return hu(n,r,c)}finally{_a=!1,(ws!==null||xs!==null)&&(fu(),uu())}}function hi(n,r){var c=n.stateNode;if(c===null)return null;var u=Dr(c);if(u===null)return null;c=u[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(n=n.type,u=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!u;break e;default:n=!1}if(n)return null;if(c&&typeof c!="function")throw Error(s(231,r,typeof c));return c}var Da=!1;if(h)try{var fi={};Object.defineProperty(fi,"passive",{get:function(){Da=!0}}),window.addEventListener("test",fi,fi),window.removeEventListener("test",fi,fi)}catch{Da=!1}function yk(n,r,c,u,m,g,x,b,C){var L=Array.prototype.slice.call(arguments,3);try{r.apply(c,L)}catch(U){this.onError(U)}}var mi=!1,gr=null,vr=!1,za=null,wk={onError:function(n){mi=!0,gr=n}};function xk(n,r,c,u,m,g,x,b,C){mi=!1,gr=null,yk.apply(wk,arguments)}function jk(n,r,c,u,m,g,x,b,C){if(xk.apply(this,arguments),mi){if(mi){var L=gr;mi=!1,gr=null}else throw Error(s(198));vr||(vr=!0,za=L)}}function Xn(n){var r=n,c=n;if(n.alternate)for(;r.return;)r=r.return;else{n=r;do r=n,(r.flags&4098)!==0&&(c=r.return),n=r.return;while(n)}return r.tag===3?c:null}function pu(n){if(n.tag===13){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function gu(n){if(Xn(n)!==n)throw Error(s(188))}function Sk(n){var r=n.alternate;if(!r){if(r=Xn(n),r===null)throw Error(s(188));return r!==n?null:n}for(var c=n,u=r;;){var m=c.return;if(m===null)break;var g=m.alternate;if(g===null){if(u=m.return,u!==null){c=u;continue}break}if(m.child===g.child){for(g=m.child;g;){if(g===c)return gu(m),n;if(g===u)return gu(m),r;g=g.sibling}throw Error(s(188))}if(c.return!==u.return)c=m,u=g;else{for(var x=!1,b=m.child;b;){if(b===c){x=!0,c=m,u=g;break}if(b===u){x=!0,u=m,c=g;break}b=b.sibling}if(!x){for(b=g.child;b;){if(b===c){x=!0,c=g,u=m;break}if(b===u){x=!0,u=g,c=m;break}b=b.sibling}if(!x)throw Error(s(189))}}if(c.alternate!==u)throw Error(s(190))}if(c.tag!==3)throw Error(s(188));return c.stateNode.current===c?n:r}function vu(n){return n=Sk(n),n!==null?ku(n):null}function ku(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var r=ku(n);if(r!==null)return r;n=n.sibling}return null}var yu=t.unstable_scheduleCallback,wu=t.unstable_cancelCallback,Nk=t.unstable_shouldYield,bk=t.unstable_requestPaint,We=t.unstable_now,$k=t.unstable_getCurrentPriorityLevel,Ba=t.unstable_ImmediatePriority,xu=t.unstable_UserBlockingPriority,kr=t.unstable_NormalPriority,Ck=t.unstable_LowPriority,ju=t.unstable_IdlePriority,yr=null,Zt=null;function Tk(n){if(Zt&&typeof Zt.onCommitFiberRoot=="function")try{Zt.onCommitFiberRoot(yr,n,void 0,(n.current.flags&128)===128)}catch{}}var Ft=Math.clz32?Math.clz32:Ik,Ek=Math.log,Ak=Math.LN2;function Ik(n){return n>>>=0,n===0?32:31-(Ek(n)/Ak|0)|0}var wr=64,xr=4194304;function pi(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function jr(n,r){var c=n.pendingLanes;if(c===0)return 0;var u=0,m=n.suspendedLanes,g=n.pingedLanes,x=c&268435455;if(x!==0){var b=x&~m;b!==0?u=pi(b):(g&=x,g!==0&&(u=pi(g)))}else x=c&~m,x!==0?u=pi(x):g!==0&&(u=pi(g));if(u===0)return 0;if(r!==0&&r!==u&&(r&m)===0&&(m=u&-u,g=r&-r,m>=g||m===16&&(g&4194240)!==0))return r;if((u&4)!==0&&(u|=c&16),r=n.entangledLanes,r!==0)for(n=n.entanglements,r&=u;0<r;)c=31-Ft(r),m=1<<c,u|=n[c],r&=~m;return u}function Rk(n,r){switch(n){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Mk(n,r){for(var c=n.suspendedLanes,u=n.pingedLanes,m=n.expirationTimes,g=n.pendingLanes;0<g;){var x=31-Ft(g),b=1<<x,C=m[x];C===-1?((b&c)===0||(b&u)!==0)&&(m[x]=Rk(b,r)):C<=r&&(n.expiredLanes|=b),g&=~b}}function Fa(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function Su(){var n=wr;return wr<<=1,(wr&4194240)===0&&(wr=64),n}function Ua(n){for(var r=[],c=0;31>c;c++)r.push(n);return r}function gi(n,r,c){n.pendingLanes|=r,r!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,r=31-Ft(r),n[r]=c}function Lk(n,r){var c=n.pendingLanes&~r;n.pendingLanes=r,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=r,n.mutableReadLanes&=r,n.entangledLanes&=r,r=n.entanglements;var u=n.eventTimes;for(n=n.expirationTimes;0<c;){var m=31-Ft(c),g=1<<m;r[m]=0,u[m]=-1,n[m]=-1,c&=~g}}function Wa(n,r){var c=n.entangledLanes|=r;for(n=n.entanglements;c;){var u=31-Ft(c),m=1<<u;m&r|n[u]&r&&(n[u]|=r),c&=~m}}var Ce=0;function Nu(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var bu,Ha,$u,Cu,Tu,Ka=!1,Sr=[],Tn=null,En=null,An=null,vi=new Map,ki=new Map,In=[],Ok="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Eu(n,r){switch(n){case"focusin":case"focusout":Tn=null;break;case"dragenter":case"dragleave":En=null;break;case"mouseover":case"mouseout":An=null;break;case"pointerover":case"pointerout":vi.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":ki.delete(r.pointerId)}}function yi(n,r,c,u,m,g){return n===null||n.nativeEvent!==g?(n={blockedOn:r,domEventName:c,eventSystemFlags:u,nativeEvent:g,targetContainers:[m]},r!==null&&(r=Mi(r),r!==null&&Ha(r)),n):(n.eventSystemFlags|=u,r=n.targetContainers,m!==null&&r.indexOf(m)===-1&&r.push(m),n)}function Pk(n,r,c,u,m){switch(r){case"focusin":return Tn=yi(Tn,n,r,c,u,m),!0;case"dragenter":return En=yi(En,n,r,c,u,m),!0;case"mouseover":return An=yi(An,n,r,c,u,m),!0;case"pointerover":var g=m.pointerId;return vi.set(g,yi(vi.get(g)||null,n,r,c,u,m)),!0;case"gotpointercapture":return g=m.pointerId,ki.set(g,yi(ki.get(g)||null,n,r,c,u,m)),!0}return!1}function Au(n){var r=Zn(n.target);if(r!==null){var c=Xn(r);if(c!==null){if(r=c.tag,r===13){if(r=pu(c),r!==null){n.blockedOn=r,Tu(n.priority,function(){$u(c)});return}}else if(r===3&&c.stateNode.current.memoizedState.isDehydrated){n.blockedOn=c.tag===3?c.stateNode.containerInfo:null;return}}}n.blockedOn=null}function Nr(n){if(n.blockedOn!==null)return!1;for(var r=n.targetContainers;0<r.length;){var c=Ga(n.domEventName,n.eventSystemFlags,r[0],n.nativeEvent);if(c===null){c=n.nativeEvent;var u=new c.constructor(c.type,c);La=u,c.target.dispatchEvent(u),La=null}else return r=Mi(c),r!==null&&Ha(r),n.blockedOn=c,!1;r.shift()}return!0}function Iu(n,r,c){Nr(n)&&c.delete(r)}function _k(){Ka=!1,Tn!==null&&Nr(Tn)&&(Tn=null),En!==null&&Nr(En)&&(En=null),An!==null&&Nr(An)&&(An=null),vi.forEach(Iu),ki.forEach(Iu)}function wi(n,r){n.blockedOn===r&&(n.blockedOn=null,Ka||(Ka=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,_k)))}function xi(n){function r(m){return wi(m,n)}if(0<Sr.length){wi(Sr[0],n);for(var c=1;c<Sr.length;c++){var u=Sr[c];u.blockedOn===n&&(u.blockedOn=null)}}for(Tn!==null&&wi(Tn,n),En!==null&&wi(En,n),An!==null&&wi(An,n),vi.forEach(r),ki.forEach(r),c=0;c<In.length;c++)u=In[c],u.blockedOn===n&&(u.blockedOn=null);for(;0<In.length&&(c=In[0],c.blockedOn===null);)Au(c),c.blockedOn===null&&In.shift()}var js=D.ReactCurrentBatchConfig,br=!0;function Dk(n,r,c,u){var m=Ce,g=js.transition;js.transition=null;try{Ce=1,Va(n,r,c,u)}finally{Ce=m,js.transition=g}}function zk(n,r,c,u){var m=Ce,g=js.transition;js.transition=null;try{Ce=4,Va(n,r,c,u)}finally{Ce=m,js.transition=g}}function Va(n,r,c,u){if(br){var m=Ga(n,r,c,u);if(m===null)dl(n,r,u,$r,c),Eu(n,u);else if(Pk(m,n,r,c,u))u.stopPropagation();else if(Eu(n,u),r&4&&-1<Ok.indexOf(n)){for(;m!==null;){var g=Mi(m);if(g!==null&&bu(g),g=Ga(n,r,c,u),g===null&&dl(n,r,u,$r,c),g===m)break;m=g}m!==null&&u.stopPropagation()}else dl(n,r,u,null,c)}}var $r=null;function Ga(n,r,c,u){if($r=null,n=Oa(u),n=Zn(n),n!==null)if(r=Xn(n),r===null)n=null;else if(c=r.tag,c===13){if(n=pu(r),n!==null)return n;n=null}else if(c===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;n=null}else r!==n&&(n=null);return $r=n,null}function Ru(n){switch(n){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch($k()){case Ba:return 1;case xu:return 4;case kr:case Ck:return 16;case ju:return 536870912;default:return 16}default:return 16}}var Rn=null,qa=null,Cr=null;function Mu(){if(Cr)return Cr;var n,r=qa,c=r.length,u,m="value"in Rn?Rn.value:Rn.textContent,g=m.length;for(n=0;n<c&&r[n]===m[n];n++);var x=c-n;for(u=1;u<=x&&r[c-u]===m[g-u];u++);return Cr=m.slice(n,1<u?1-u:void 0)}function Tr(n){var r=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&r===13&&(n=13)):n=r,n===10&&(n=13),32<=n||n===13?n:0}function Er(){return!0}function Lu(){return!1}function bt(n){function r(c,u,m,g,x){this._reactName=c,this._targetInst=m,this.type=u,this.nativeEvent=g,this.target=x,this.currentTarget=null;for(var b in n)n.hasOwnProperty(b)&&(c=n[b],this[b]=c?c(g):g[b]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?Er:Lu,this.isPropagationStopped=Lu,this}return z(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var c=this.nativeEvent;c&&(c.preventDefault?c.preventDefault():typeof c.returnValue!="unknown"&&(c.returnValue=!1),this.isDefaultPrevented=Er)},stopPropagation:function(){var c=this.nativeEvent;c&&(c.stopPropagation?c.stopPropagation():typeof c.cancelBubble!="unknown"&&(c.cancelBubble=!0),this.isPropagationStopped=Er)},persist:function(){},isPersistent:Er}),r}var Ss={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Qa=bt(Ss),ji=z({},Ss,{view:0,detail:0}),Bk=bt(ji),Ya,Ja,Si,Ar=z({},ji,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Za,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==Si&&(Si&&n.type==="mousemove"?(Ya=n.screenX-Si.screenX,Ja=n.screenY-Si.screenY):Ja=Ya=0,Si=n),Ya)},movementY:function(n){return"movementY"in n?n.movementY:Ja}}),Ou=bt(Ar),Fk=z({},Ar,{dataTransfer:0}),Uk=bt(Fk),Wk=z({},ji,{relatedTarget:0}),Xa=bt(Wk),Hk=z({},Ss,{animationName:0,elapsedTime:0,pseudoElement:0}),Kk=bt(Hk),Vk=z({},Ss,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),Gk=bt(Vk),qk=z({},Ss,{data:0}),Pu=bt(qk),Qk={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Yk={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"},Jk={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Xk(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=Jk[n])?!!r[n]:!1}function Za(){return Xk}var Zk=z({},ji,{key:function(n){if(n.key){var r=Qk[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=Tr(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?Yk[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Za,charCode:function(n){return n.type==="keypress"?Tr(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Tr(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),ey=bt(Zk),ty=z({},Ar,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),_u=bt(ty),ny=z({},ji,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Za}),sy=bt(ny),iy=z({},Ss,{propertyName:0,elapsedTime:0,pseudoElement:0}),ry=bt(iy),oy=z({},Ar,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),ay=bt(oy),ly=[9,13,27,32],el=h&&"CompositionEvent"in window,Ni=null;h&&"documentMode"in document&&(Ni=document.documentMode);var cy=h&&"TextEvent"in window&&!Ni,Du=h&&(!el||Ni&&8<Ni&&11>=Ni),zu=" ",Bu=!1;function Fu(n,r){switch(n){case"keyup":return ly.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Uu(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Ns=!1;function dy(n,r){switch(n){case"compositionend":return Uu(r);case"keypress":return r.which!==32?null:(Bu=!0,zu);case"textInput":return n=r.data,n===zu&&Bu?null:n;default:return null}}function uy(n,r){if(Ns)return n==="compositionend"||!el&&Fu(n,r)?(n=Mu(),Cr=qa=Rn=null,Ns=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return Du&&r.locale!=="ko"?null:r.data;default:return null}}var hy={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 Wu(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!hy[n.type]:r==="textarea"}function Hu(n,r,c,u){du(u),r=Or(r,"onChange"),0<r.length&&(c=new Qa("onChange","change",null,c,u),n.push({event:c,listeners:r}))}var bi=null,$i=null;function fy(n){lh(n,0)}function Ir(n){var r=Es(n);if(mr(r))return n}function my(n,r){if(n==="change")return r}var Ku=!1;if(h){var tl;if(h){var nl="oninput"in document;if(!nl){var Vu=document.createElement("div");Vu.setAttribute("oninput","return;"),nl=typeof Vu.oninput=="function"}tl=nl}else tl=!1;Ku=tl&&(!document.documentMode||9<document.documentMode)}function Gu(){bi&&(bi.detachEvent("onpropertychange",qu),$i=bi=null)}function qu(n){if(n.propertyName==="value"&&Ir($i)){var r=[];Hu(r,$i,n,Oa(n)),mu(fy,r)}}function py(n,r,c){n==="focusin"?(Gu(),bi=r,$i=c,bi.attachEvent("onpropertychange",qu)):n==="focusout"&&Gu()}function gy(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Ir($i)}function vy(n,r){if(n==="click")return Ir(r)}function ky(n,r){if(n==="input"||n==="change")return Ir(r)}function yy(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var Ut=typeof Object.is=="function"?Object.is:yy;function Ci(n,r){if(Ut(n,r))return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;var c=Object.keys(n),u=Object.keys(r);if(c.length!==u.length)return!1;for(u=0;u<c.length;u++){var m=c[u];if(!f.call(r,m)||!Ut(n[m],r[m]))return!1}return!0}function Qu(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Yu(n,r){var c=Qu(n);n=0;for(var u;c;){if(c.nodeType===3){if(u=n+c.textContent.length,n<=r&&u>=r)return{node:c,offset:r-n};n=u}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=Qu(c)}}function Ju(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?Ju(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function Xu(){for(var n=window,r=ks();r instanceof n.HTMLIFrameElement;){try{var c=typeof r.contentWindow.location.href=="string"}catch{c=!1}if(c)n=r.contentWindow;else break;r=ks(n.document)}return r}function sl(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r&&(r==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||r==="textarea"||n.contentEditable==="true")}function wy(n){var r=Xu(),c=n.focusedElem,u=n.selectionRange;if(r!==c&&c&&c.ownerDocument&&Ju(c.ownerDocument.documentElement,c)){if(u!==null&&sl(c)){if(r=u.start,n=u.end,n===void 0&&(n=r),"selectionStart"in c)c.selectionStart=r,c.selectionEnd=Math.min(n,c.value.length);else if(n=(r=c.ownerDocument||document)&&r.defaultView||window,n.getSelection){n=n.getSelection();var m=c.textContent.length,g=Math.min(u.start,m);u=u.end===void 0?g:Math.min(u.end,m),!n.extend&&g>u&&(m=u,u=g,g=m),m=Yu(c,g);var x=Yu(c,u);m&&x&&(n.rangeCount!==1||n.anchorNode!==m.node||n.anchorOffset!==m.offset||n.focusNode!==x.node||n.focusOffset!==x.offset)&&(r=r.createRange(),r.setStart(m.node,m.offset),n.removeAllRanges(),g>u?(n.addRange(r),n.extend(x.node,x.offset)):(r.setEnd(x.node,x.offset),n.addRange(r)))}}for(r=[],n=c;n=n.parentNode;)n.nodeType===1&&r.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof c.focus=="function"&&c.focus(),c=0;c<r.length;c++)n=r[c],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var xy=h&&"documentMode"in document&&11>=document.documentMode,bs=null,il=null,Ti=null,rl=!1;function Zu(n,r,c){var u=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;rl||bs==null||bs!==ks(u)||(u=bs,"selectionStart"in u&&sl(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),Ti&&Ci(Ti,u)||(Ti=u,u=Or(il,"onSelect"),0<u.length&&(r=new Qa("onSelect","select",null,r,c),n.push({event:r,listeners:u}),r.target=bs)))}function Rr(n,r){var c={};return c[n.toLowerCase()]=r.toLowerCase(),c["Webkit"+n]="webkit"+r,c["Moz"+n]="moz"+r,c}var $s={animationend:Rr("Animation","AnimationEnd"),animationiteration:Rr("Animation","AnimationIteration"),animationstart:Rr("Animation","AnimationStart"),transitionend:Rr("Transition","TransitionEnd")},ol={},eh={};h&&(eh=document.createElement("div").style,"AnimationEvent"in window||(delete $s.animationend.animation,delete $s.animationiteration.animation,delete $s.animationstart.animation),"TransitionEvent"in window||delete $s.transitionend.transition);function Mr(n){if(ol[n])return ol[n];if(!$s[n])return n;var r=$s[n],c;for(c in r)if(r.hasOwnProperty(c)&&c in eh)return ol[n]=r[c];return n}var th=Mr("animationend"),nh=Mr("animationiteration"),sh=Mr("animationstart"),ih=Mr("transitionend"),rh=new Map,oh="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Mn(n,r){rh.set(n,r),l(r,[n])}for(var al=0;al<oh.length;al++){var ll=oh[al],jy=ll.toLowerCase(),Sy=ll[0].toUpperCase()+ll.slice(1);Mn(jy,"on"+Sy)}Mn(th,"onAnimationEnd"),Mn(nh,"onAnimationIteration"),Mn(sh,"onAnimationStart"),Mn("dblclick","onDoubleClick"),Mn("focusin","onFocus"),Mn("focusout","onBlur"),Mn(ih,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ei="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(" "),Ny=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ei));function ah(n,r,c){var u=n.type||"unknown-event";n.currentTarget=c,jk(u,r,void 0,n),n.currentTarget=null}function lh(n,r){r=(r&4)!==0;for(var c=0;c<n.length;c++){var u=n[c],m=u.event;u=u.listeners;e:{var g=void 0;if(r)for(var x=u.length-1;0<=x;x--){var b=u[x],C=b.instance,L=b.currentTarget;if(b=b.listener,C!==g&&m.isPropagationStopped())break e;ah(m,b,L),g=C}else for(x=0;x<u.length;x++){if(b=u[x],C=b.instance,L=b.currentTarget,b=b.listener,C!==g&&m.isPropagationStopped())break e;ah(m,b,L),g=C}}}if(vr)throw n=za,vr=!1,za=null,n}function Me(n,r){var c=r[gl];c===void 0&&(c=r[gl]=new Set);var u=n+"__bubble";c.has(u)||(ch(r,n,2,!1),c.add(u))}function cl(n,r,c){var u=0;r&&(u|=4),ch(c,n,u,r)}var Lr="_reactListening"+Math.random().toString(36).slice(2);function Ai(n){if(!n[Lr]){n[Lr]=!0,o.forEach(function(c){c!=="selectionchange"&&(Ny.has(c)||cl(c,!1,n),cl(c,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[Lr]||(r[Lr]=!0,cl("selectionchange",!1,r))}}function ch(n,r,c,u){switch(Ru(r)){case 1:var m=Dk;break;case 4:m=zk;break;default:m=Va}c=m.bind(null,r,c,n),m=void 0,!Da||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(m=!0),u?m!==void 0?n.addEventListener(r,c,{capture:!0,passive:m}):n.addEventListener(r,c,!0):m!==void 0?n.addEventListener(r,c,{passive:m}):n.addEventListener(r,c,!1)}function dl(n,r,c,u,m){var g=u;if((r&1)===0&&(r&2)===0&&u!==null)e:for(;;){if(u===null)return;var x=u.tag;if(x===3||x===4){var b=u.stateNode.containerInfo;if(b===m||b.nodeType===8&&b.parentNode===m)break;if(x===4)for(x=u.return;x!==null;){var C=x.tag;if((C===3||C===4)&&(C=x.stateNode.containerInfo,C===m||C.nodeType===8&&C.parentNode===m))return;x=x.return}for(;b!==null;){if(x=Zn(b),x===null)return;if(C=x.tag,C===5||C===6){u=g=x;continue e}b=b.parentNode}}u=u.return}mu(function(){var L=g,U=Oa(c),K=[];e:{var B=rh.get(n);if(B!==void 0){var ee=Qa,se=n;switch(n){case"keypress":if(Tr(c)===0)break e;case"keydown":case"keyup":ee=ey;break;case"focusin":se="focus",ee=Xa;break;case"focusout":se="blur",ee=Xa;break;case"beforeblur":case"afterblur":ee=Xa;break;case"click":if(c.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ee=Ou;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ee=Uk;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ee=sy;break;case th:case nh:case sh:ee=Kk;break;case ih:ee=ry;break;case"scroll":ee=Bk;break;case"wheel":ee=ay;break;case"copy":case"cut":case"paste":ee=Gk;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ee=_u}var re=(r&4)!==0,He=!re&&n==="scroll",A=re?B!==null?B+"Capture":null:B;re=[];for(var E=L,R;E!==null;){R=E;var Y=R.stateNode;if(R.tag===5&&Y!==null&&(R=Y,A!==null&&(Y=hi(E,A),Y!=null&&re.push(Ii(E,Y,R)))),He)break;E=E.return}0<re.length&&(B=new ee(B,se,null,c,U),K.push({event:B,listeners:re}))}}if((r&7)===0){e:{if(B=n==="mouseover"||n==="pointerover",ee=n==="mouseout"||n==="pointerout",B&&c!==La&&(se=c.relatedTarget||c.fromElement)&&(Zn(se)||se[fn]))break e;if((ee||B)&&(B=U.window===U?U:(B=U.ownerDocument)?B.defaultView||B.parentWindow:window,ee?(se=c.relatedTarget||c.toElement,ee=L,se=se?Zn(se):null,se!==null&&(He=Xn(se),se!==He||se.tag!==5&&se.tag!==6)&&(se=null)):(ee=null,se=L),ee!==se)){if(re=Ou,Y="onMouseLeave",A="onMouseEnter",E="mouse",(n==="pointerout"||n==="pointerover")&&(re=_u,Y="onPointerLeave",A="onPointerEnter",E="pointer"),He=ee==null?B:Es(ee),R=se==null?B:Es(se),B=new re(Y,E+"leave",ee,c,U),B.target=He,B.relatedTarget=R,Y=null,Zn(U)===L&&(re=new re(A,E+"enter",se,c,U),re.target=R,re.relatedTarget=He,Y=re),He=Y,ee&&se)t:{for(re=ee,A=se,E=0,R=re;R;R=Cs(R))E++;for(R=0,Y=A;Y;Y=Cs(Y))R++;for(;0<E-R;)re=Cs(re),E--;for(;0<R-E;)A=Cs(A),R--;for(;E--;){if(re===A||A!==null&&re===A.alternate)break t;re=Cs(re),A=Cs(A)}re=null}else re=null;ee!==null&&dh(K,B,ee,re,!1),se!==null&&He!==null&&dh(K,He,se,re,!0)}}e:{if(B=L?Es(L):window,ee=B.nodeName&&B.nodeName.toLowerCase(),ee==="select"||ee==="input"&&B.type==="file")var ae=my;else if(Wu(B))if(Ku)ae=ky;else{ae=gy;var ue=py}else(ee=B.nodeName)&&ee.toLowerCase()==="input"&&(B.type==="checkbox"||B.type==="radio")&&(ae=vy);if(ae&&(ae=ae(n,L))){Hu(K,ae,c,U);break e}ue&&ue(n,B,L),n==="focusout"&&(ue=B._wrapperState)&&ue.controlled&&B.type==="number"&&Ea(B,"number",B.value)}switch(ue=L?Es(L):window,n){case"focusin":(Wu(ue)||ue.contentEditable==="true")&&(bs=ue,il=L,Ti=null);break;case"focusout":Ti=il=bs=null;break;case"mousedown":rl=!0;break;case"contextmenu":case"mouseup":case"dragend":rl=!1,Zu(K,c,U);break;case"selectionchange":if(xy)break;case"keydown":case"keyup":Zu(K,c,U)}var he;if(el)e:{switch(n){case"compositionstart":var fe="onCompositionStart";break e;case"compositionend":fe="onCompositionEnd";break e;case"compositionupdate":fe="onCompositionUpdate";break e}fe=void 0}else Ns?Fu(n,c)&&(fe="onCompositionEnd"):n==="keydown"&&c.keyCode===229&&(fe="onCompositionStart");fe&&(Du&&c.locale!=="ko"&&(Ns||fe!=="onCompositionStart"?fe==="onCompositionEnd"&&Ns&&(he=Mu()):(Rn=U,qa="value"in Rn?Rn.value:Rn.textContent,Ns=!0)),ue=Or(L,fe),0<ue.length&&(fe=new Pu(fe,n,null,c,U),K.push({event:fe,listeners:ue}),he?fe.data=he:(he=Uu(c),he!==null&&(fe.data=he)))),(he=cy?dy(n,c):uy(n,c))&&(L=Or(L,"onBeforeInput"),0<L.length&&(U=new Pu("onBeforeInput","beforeinput",null,c,U),K.push({event:U,listeners:L}),U.data=he))}lh(K,r)})}function Ii(n,r,c){return{instance:n,listener:r,currentTarget:c}}function Or(n,r){for(var c=r+"Capture",u=[];n!==null;){var m=n,g=m.stateNode;m.tag===5&&g!==null&&(m=g,g=hi(n,c),g!=null&&u.unshift(Ii(n,g,m)),g=hi(n,r),g!=null&&u.push(Ii(n,g,m))),n=n.return}return u}function Cs(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function dh(n,r,c,u,m){for(var g=r._reactName,x=[];c!==null&&c!==u;){var b=c,C=b.alternate,L=b.stateNode;if(C!==null&&C===u)break;b.tag===5&&L!==null&&(b=L,m?(C=hi(c,g),C!=null&&x.unshift(Ii(c,C,b))):m||(C=hi(c,g),C!=null&&x.push(Ii(c,C,b)))),c=c.return}x.length!==0&&n.push({event:r,listeners:x})}var by=/\r\n?/g,$y=/\u0000|\uFFFD/g;function uh(n){return(typeof n=="string"?n:""+n).replace(by,`
|
|
38
38
|
`).replace($y,"")}function Pr(n,r,c){if(r=uh(r),uh(n)!==r&&c)throw Error(s(425))}function _r(){}var ul=null,hl=null;function fl(n,r){return n==="textarea"||n==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var ml=typeof setTimeout=="function"?setTimeout:void 0,Cy=typeof clearTimeout=="function"?clearTimeout:void 0,hh=typeof Promise=="function"?Promise:void 0,Ty=typeof queueMicrotask=="function"?queueMicrotask:typeof hh<"u"?function(n){return hh.resolve(null).then(n).catch(Ey)}:ml;function Ey(n){setTimeout(function(){throw n})}function pl(n,r){var c=r,u=0;do{var m=c.nextSibling;if(n.removeChild(c),m&&m.nodeType===8)if(c=m.data,c==="/$"){if(u===0){n.removeChild(m),xi(r);return}u--}else c!=="$"&&c!=="$?"&&c!=="$!"||u++;c=m}while(c);xi(r)}function Ln(n){for(;n!=null;n=n.nextSibling){var r=n.nodeType;if(r===1||r===3)break;if(r===8){if(r=n.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return n}function fh(n){n=n.previousSibling;for(var r=0;n;){if(n.nodeType===8){var c=n.data;if(c==="$"||c==="$!"||c==="$?"){if(r===0)return n;r--}else c==="/$"&&r++}n=n.previousSibling}return null}var Ts=Math.random().toString(36).slice(2),en="__reactFiber$"+Ts,Ri="__reactProps$"+Ts,fn="__reactContainer$"+Ts,gl="__reactEvents$"+Ts,Ay="__reactListeners$"+Ts,Iy="__reactHandles$"+Ts;function Zn(n){var r=n[en];if(r)return r;for(var c=n.parentNode;c;){if(r=c[fn]||c[en]){if(c=r.alternate,r.child!==null||c!==null&&c.child!==null)for(n=fh(n);n!==null;){if(c=n[en])return c;n=fh(n)}return r}n=c,c=n.parentNode}return null}function Mi(n){return n=n[en]||n[fn],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function Es(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(s(33))}function Dr(n){return n[Ri]||null}var vl=[],As=-1;function On(n){return{current:n}}function Le(n){0>As||(n.current=vl[As],vl[As]=null,As--)}function Re(n,r){As++,vl[As]=n.current,n.current=r}var Pn={},lt=On(Pn),gt=On(!1),es=Pn;function Is(n,r){var c=n.type.contextTypes;if(!c)return Pn;var u=n.stateNode;if(u&&u.__reactInternalMemoizedUnmaskedChildContext===r)return u.__reactInternalMemoizedMaskedChildContext;var m={},g;for(g in c)m[g]=r[g];return u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=r,n.__reactInternalMemoizedMaskedChildContext=m),m}function vt(n){return n=n.childContextTypes,n!=null}function zr(){Le(gt),Le(lt)}function mh(n,r,c){if(lt.current!==Pn)throw Error(s(168));Re(lt,r),Re(gt,c)}function ph(n,r,c){var u=n.stateNode;if(r=r.childContextTypes,typeof u.getChildContext!="function")return c;u=u.getChildContext();for(var m in u)if(!(m in r))throw Error(s(108,ge(n)||"Unknown",m));return z({},c,u)}function Br(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Pn,es=lt.current,Re(lt,n),Re(gt,gt.current),!0}function gh(n,r,c){var u=n.stateNode;if(!u)throw Error(s(169));c?(n=ph(n,r,es),u.__reactInternalMemoizedMergedChildContext=n,Le(gt),Le(lt),Re(lt,n)):Le(gt),Re(gt,c)}var mn=null,Fr=!1,kl=!1;function vh(n){mn===null?mn=[n]:mn.push(n)}function Ry(n){Fr=!0,vh(n)}function _n(){if(!kl&&mn!==null){kl=!0;var n=0,r=Ce;try{var c=mn;for(Ce=1;n<c.length;n++){var u=c[n];do u=u(!0);while(u!==null)}mn=null,Fr=!1}catch(m){throw mn!==null&&(mn=mn.slice(n+1)),yu(Ba,_n),m}finally{Ce=r,kl=!1}}return null}var Rs=[],Ms=0,Ur=null,Wr=0,At=[],It=0,ts=null,pn=1,gn="";function ns(n,r){Rs[Ms++]=Wr,Rs[Ms++]=Ur,Ur=n,Wr=r}function kh(n,r,c){At[It++]=pn,At[It++]=gn,At[It++]=ts,ts=n;var u=pn;n=gn;var m=32-Ft(u)-1;u&=~(1<<m),c+=1;var g=32-Ft(r)+m;if(30<g){var x=m-m%5;g=(u&(1<<x)-1).toString(32),u>>=x,m-=x,pn=1<<32-Ft(r)+m|c<<m|u,gn=g+n}else pn=1<<g|c<<m|u,gn=n}function yl(n){n.return!==null&&(ns(n,1),kh(n,1,0))}function wl(n){for(;n===Ur;)Ur=Rs[--Ms],Rs[Ms]=null,Wr=Rs[--Ms],Rs[Ms]=null;for(;n===ts;)ts=At[--It],At[It]=null,gn=At[--It],At[It]=null,pn=At[--It],At[It]=null}var $t=null,Ct=null,Pe=!1,Wt=null;function yh(n,r){var c=Ot(5,null,null,0);c.elementType="DELETED",c.stateNode=r,c.return=n,r=n.deletions,r===null?(n.deletions=[c],n.flags|=16):r.push(c)}function wh(n,r){switch(n.tag){case 5:var c=n.type;return r=r.nodeType!==1||c.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(n.stateNode=r,$t=n,Ct=Ln(r.firstChild),!0):!1;case 6:return r=n.pendingProps===""||r.nodeType!==3?null:r,r!==null?(n.stateNode=r,$t=n,Ct=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(c=ts!==null?{id:pn,overflow:gn}:null,n.memoizedState={dehydrated:r,treeContext:c,retryLane:1073741824},c=Ot(18,null,null,0),c.stateNode=r,c.return=n,n.child=c,$t=n,Ct=null,!0):!1;default:return!1}}function xl(n){return(n.mode&1)!==0&&(n.flags&128)===0}function jl(n){if(Pe){var r=Ct;if(r){var c=r;if(!wh(n,r)){if(xl(n))throw Error(s(418));r=Ln(c.nextSibling);var u=$t;r&&wh(n,r)?yh(u,c):(n.flags=n.flags&-4097|2,Pe=!1,$t=n)}}else{if(xl(n))throw Error(s(418));n.flags=n.flags&-4097|2,Pe=!1,$t=n}}}function xh(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;$t=n}function Hr(n){if(n!==$t)return!1;if(!Pe)return xh(n),Pe=!0,!1;var r;if((r=n.tag!==3)&&!(r=n.tag!==5)&&(r=n.type,r=r!=="head"&&r!=="body"&&!fl(n.type,n.memoizedProps)),r&&(r=Ct)){if(xl(n))throw jh(),Error(s(418));for(;r;)yh(n,r),r=Ln(r.nextSibling)}if(xh(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));e:{for(n=n.nextSibling,r=0;n;){if(n.nodeType===8){var c=n.data;if(c==="/$"){if(r===0){Ct=Ln(n.nextSibling);break e}r--}else c!=="$"&&c!=="$!"&&c!=="$?"||r++}n=n.nextSibling}Ct=null}}else Ct=$t?Ln(n.stateNode.nextSibling):null;return!0}function jh(){for(var n=Ct;n;)n=Ln(n.nextSibling)}function Ls(){Ct=$t=null,Pe=!1}function Sl(n){Wt===null?Wt=[n]:Wt.push(n)}var My=D.ReactCurrentBatchConfig;function Li(n,r,c){if(n=c.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(c._owner){if(c=c._owner,c){if(c.tag!==1)throw Error(s(309));var u=c.stateNode}if(!u)throw Error(s(147,n));var m=u,g=""+n;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===g?r.ref:(r=function(x){var b=m.refs;x===null?delete b[g]:b[g]=x},r._stringRef=g,r)}if(typeof n!="string")throw Error(s(284));if(!c._owner)throw Error(s(290,n))}return n}function Kr(n,r){throw n=Object.prototype.toString.call(r),Error(s(31,n==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":n))}function Sh(n){var r=n._init;return r(n._payload)}function Nh(n){function r(A,E){if(n){var R=A.deletions;R===null?(A.deletions=[E],A.flags|=16):R.push(E)}}function c(A,E){if(!n)return null;for(;E!==null;)r(A,E),E=E.sibling;return null}function u(A,E){for(A=new Map;E!==null;)E.key!==null?A.set(E.key,E):A.set(E.index,E),E=E.sibling;return A}function m(A,E){return A=Kn(A,E),A.index=0,A.sibling=null,A}function g(A,E,R){return A.index=R,n?(R=A.alternate,R!==null?(R=R.index,R<E?(A.flags|=2,E):R):(A.flags|=2,E)):(A.flags|=1048576,E)}function x(A){return n&&A.alternate===null&&(A.flags|=2),A}function b(A,E,R,Y){return E===null||E.tag!==6?(E=mc(R,A.mode,Y),E.return=A,E):(E=m(E,R),E.return=A,E)}function C(A,E,R,Y){var ae=R.type;return ae===G?U(A,E,R.props.children,Y,R.key):E!==null&&(E.elementType===ae||typeof ae=="object"&&ae!==null&&ae.$$typeof===J&&Sh(ae)===E.type)?(Y=m(E,R.props),Y.ref=Li(A,E,R),Y.return=A,Y):(Y=go(R.type,R.key,R.props,null,A.mode,Y),Y.ref=Li(A,E,R),Y.return=A,Y)}function L(A,E,R,Y){return E===null||E.tag!==4||E.stateNode.containerInfo!==R.containerInfo||E.stateNode.implementation!==R.implementation?(E=pc(R,A.mode,Y),E.return=A,E):(E=m(E,R.children||[]),E.return=A,E)}function U(A,E,R,Y,ae){return E===null||E.tag!==7?(E=ds(R,A.mode,Y,ae),E.return=A,E):(E=m(E,R),E.return=A,E)}function K(A,E,R){if(typeof E=="string"&&E!==""||typeof E=="number")return E=mc(""+E,A.mode,R),E.return=A,E;if(typeof E=="object"&&E!==null){switch(E.$$typeof){case q:return R=go(E.type,E.key,E.props,null,A.mode,R),R.ref=Li(A,null,E),R.return=A,R;case H:return E=pc(E,A.mode,R),E.return=A,E;case J:var Y=E._init;return K(A,Y(E._payload),R)}if(ci(E)||X(E))return E=ds(E,A.mode,R,null),E.return=A,E;Kr(A,E)}return null}function B(A,E,R,Y){var ae=E!==null?E.key:null;if(typeof R=="string"&&R!==""||typeof R=="number")return ae!==null?null:b(A,E,""+R,Y);if(typeof R=="object"&&R!==null){switch(R.$$typeof){case q:return R.key===ae?C(A,E,R,Y):null;case H:return R.key===ae?L(A,E,R,Y):null;case J:return ae=R._init,B(A,E,ae(R._payload),Y)}if(ci(R)||X(R))return ae!==null?null:U(A,E,R,Y,null);Kr(A,R)}return null}function ee(A,E,R,Y,ae){if(typeof Y=="string"&&Y!==""||typeof Y=="number")return A=A.get(R)||null,b(E,A,""+Y,ae);if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case q:return A=A.get(Y.key===null?R:Y.key)||null,C(E,A,Y,ae);case H:return A=A.get(Y.key===null?R:Y.key)||null,L(E,A,Y,ae);case J:var ue=Y._init;return ee(A,E,R,ue(Y._payload),ae)}if(ci(Y)||X(Y))return A=A.get(R)||null,U(E,A,Y,ae,null);Kr(E,Y)}return null}function se(A,E,R,Y){for(var ae=null,ue=null,he=E,fe=E=0,nt=null;he!==null&&fe<R.length;fe++){he.index>fe?(nt=he,he=null):nt=he.sibling;var $e=B(A,he,R[fe],Y);if($e===null){he===null&&(he=nt);break}n&&he&&$e.alternate===null&&r(A,he),E=g($e,E,fe),ue===null?ae=$e:ue.sibling=$e,ue=$e,he=nt}if(fe===R.length)return c(A,he),Pe&&ns(A,fe),ae;if(he===null){for(;fe<R.length;fe++)he=K(A,R[fe],Y),he!==null&&(E=g(he,E,fe),ue===null?ae=he:ue.sibling=he,ue=he);return Pe&&ns(A,fe),ae}for(he=u(A,he);fe<R.length;fe++)nt=ee(he,A,fe,R[fe],Y),nt!==null&&(n&&nt.alternate!==null&&he.delete(nt.key===null?fe:nt.key),E=g(nt,E,fe),ue===null?ae=nt:ue.sibling=nt,ue=nt);return n&&he.forEach(function(Vn){return r(A,Vn)}),Pe&&ns(A,fe),ae}function re(A,E,R,Y){var ae=X(R);if(typeof ae!="function")throw Error(s(150));if(R=ae.call(R),R==null)throw Error(s(151));for(var ue=ae=null,he=E,fe=E=0,nt=null,$e=R.next();he!==null&&!$e.done;fe++,$e=R.next()){he.index>fe?(nt=he,he=null):nt=he.sibling;var Vn=B(A,he,$e.value,Y);if(Vn===null){he===null&&(he=nt);break}n&&he&&Vn.alternate===null&&r(A,he),E=g(Vn,E,fe),ue===null?ae=Vn:ue.sibling=Vn,ue=Vn,he=nt}if($e.done)return c(A,he),Pe&&ns(A,fe),ae;if(he===null){for(;!$e.done;fe++,$e=R.next())$e=K(A,$e.value,Y),$e!==null&&(E=g($e,E,fe),ue===null?ae=$e:ue.sibling=$e,ue=$e);return Pe&&ns(A,fe),ae}for(he=u(A,he);!$e.done;fe++,$e=R.next())$e=ee(he,A,fe,$e.value,Y),$e!==null&&(n&&$e.alternate!==null&&he.delete($e.key===null?fe:$e.key),E=g($e,E,fe),ue===null?ae=$e:ue.sibling=$e,ue=$e);return n&&he.forEach(function(hw){return r(A,hw)}),Pe&&ns(A,fe),ae}function He(A,E,R,Y){if(typeof R=="object"&&R!==null&&R.type===G&&R.key===null&&(R=R.props.children),typeof R=="object"&&R!==null){switch(R.$$typeof){case q:e:{for(var ae=R.key,ue=E;ue!==null;){if(ue.key===ae){if(ae=R.type,ae===G){if(ue.tag===7){c(A,ue.sibling),E=m(ue,R.props.children),E.return=A,A=E;break e}}else if(ue.elementType===ae||typeof ae=="object"&&ae!==null&&ae.$$typeof===J&&Sh(ae)===ue.type){c(A,ue.sibling),E=m(ue,R.props),E.ref=Li(A,ue,R),E.return=A,A=E;break e}c(A,ue);break}else r(A,ue);ue=ue.sibling}R.type===G?(E=ds(R.props.children,A.mode,Y,R.key),E.return=A,A=E):(Y=go(R.type,R.key,R.props,null,A.mode,Y),Y.ref=Li(A,E,R),Y.return=A,A=Y)}return x(A);case H:e:{for(ue=R.key;E!==null;){if(E.key===ue)if(E.tag===4&&E.stateNode.containerInfo===R.containerInfo&&E.stateNode.implementation===R.implementation){c(A,E.sibling),E=m(E,R.children||[]),E.return=A,A=E;break e}else{c(A,E);break}else r(A,E);E=E.sibling}E=pc(R,A.mode,Y),E.return=A,A=E}return x(A);case J:return ue=R._init,He(A,E,ue(R._payload),Y)}if(ci(R))return se(A,E,R,Y);if(X(R))return re(A,E,R,Y);Kr(A,R)}return typeof R=="string"&&R!==""||typeof R=="number"?(R=""+R,E!==null&&E.tag===6?(c(A,E.sibling),E=m(E,R),E.return=A,A=E):(c(A,E),E=mc(R,A.mode,Y),E.return=A,A=E),x(A)):c(A,E)}return He}var Os=Nh(!0),bh=Nh(!1),Vr=On(null),Gr=null,Ps=null,Nl=null;function bl(){Nl=Ps=Gr=null}function $l(n){var r=Vr.current;Le(Vr),n._currentValue=r}function Cl(n,r,c){for(;n!==null;){var u=n.alternate;if((n.childLanes&r)!==r?(n.childLanes|=r,u!==null&&(u.childLanes|=r)):u!==null&&(u.childLanes&r)!==r&&(u.childLanes|=r),n===c)break;n=n.return}}function _s(n,r){Gr=n,Nl=Ps=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&r)!==0&&(kt=!0),n.firstContext=null)}function Rt(n){var r=n._currentValue;if(Nl!==n)if(n={context:n,memoizedValue:r,next:null},Ps===null){if(Gr===null)throw Error(s(308));Ps=n,Gr.dependencies={lanes:0,firstContext:n}}else Ps=Ps.next=n;return r}var ss=null;function Tl(n){ss===null?ss=[n]:ss.push(n)}function $h(n,r,c,u){var m=r.interleaved;return m===null?(c.next=c,Tl(r)):(c.next=m.next,m.next=c),r.interleaved=c,vn(n,u)}function vn(n,r){n.lanes|=r;var c=n.alternate;for(c!==null&&(c.lanes|=r),c=n,n=n.return;n!==null;)n.childLanes|=r,c=n.alternate,c!==null&&(c.childLanes|=r),c=n,n=n.return;return c.tag===3?c.stateNode:null}var Dn=!1;function El(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ch(n,r){n=n.updateQueue,r.updateQueue===n&&(r.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function kn(n,r){return{eventTime:n,lane:r,tag:0,payload:null,callback:null,next:null}}function zn(n,r,c){var u=n.updateQueue;if(u===null)return null;if(u=u.shared,(Ne&2)!==0){var m=u.pending;return m===null?r.next=r:(r.next=m.next,m.next=r),u.pending=r,vn(n,c)}return m=u.interleaved,m===null?(r.next=r,Tl(u)):(r.next=m.next,m.next=r),u.interleaved=r,vn(n,c)}function qr(n,r,c){if(r=r.updateQueue,r!==null&&(r=r.shared,(c&4194240)!==0)){var u=r.lanes;u&=n.pendingLanes,c|=u,r.lanes=c,Wa(n,c)}}function Th(n,r){var c=n.updateQueue,u=n.alternate;if(u!==null&&(u=u.updateQueue,c===u)){var m=null,g=null;if(c=c.firstBaseUpdate,c!==null){do{var x={eventTime:c.eventTime,lane:c.lane,tag:c.tag,payload:c.payload,callback:c.callback,next:null};g===null?m=g=x:g=g.next=x,c=c.next}while(c!==null);g===null?m=g=r:g=g.next=r}else m=g=r;c={baseState:u.baseState,firstBaseUpdate:m,lastBaseUpdate:g,shared:u.shared,effects:u.effects},n.updateQueue=c;return}n=c.lastBaseUpdate,n===null?c.firstBaseUpdate=r:n.next=r,c.lastBaseUpdate=r}function Qr(n,r,c,u){var m=n.updateQueue;Dn=!1;var g=m.firstBaseUpdate,x=m.lastBaseUpdate,b=m.shared.pending;if(b!==null){m.shared.pending=null;var C=b,L=C.next;C.next=null,x===null?g=L:x.next=L,x=C;var U=n.alternate;U!==null&&(U=U.updateQueue,b=U.lastBaseUpdate,b!==x&&(b===null?U.firstBaseUpdate=L:b.next=L,U.lastBaseUpdate=C))}if(g!==null){var K=m.baseState;x=0,U=L=C=null,b=g;do{var B=b.lane,ee=b.eventTime;if((u&B)===B){U!==null&&(U=U.next={eventTime:ee,lane:0,tag:b.tag,payload:b.payload,callback:b.callback,next:null});e:{var se=n,re=b;switch(B=r,ee=c,re.tag){case 1:if(se=re.payload,typeof se=="function"){K=se.call(ee,K,B);break e}K=se;break e;case 3:se.flags=se.flags&-65537|128;case 0:if(se=re.payload,B=typeof se=="function"?se.call(ee,K,B):se,B==null)break e;K=z({},K,B);break e;case 2:Dn=!0}}b.callback!==null&&b.lane!==0&&(n.flags|=64,B=m.effects,B===null?m.effects=[b]:B.push(b))}else ee={eventTime:ee,lane:B,tag:b.tag,payload:b.payload,callback:b.callback,next:null},U===null?(L=U=ee,C=K):U=U.next=ee,x|=B;if(b=b.next,b===null){if(b=m.shared.pending,b===null)break;B=b,b=B.next,B.next=null,m.lastBaseUpdate=B,m.shared.pending=null}}while(!0);if(U===null&&(C=K),m.baseState=C,m.firstBaseUpdate=L,m.lastBaseUpdate=U,r=m.shared.interleaved,r!==null){m=r;do x|=m.lane,m=m.next;while(m!==r)}else g===null&&(m.shared.lanes=0);os|=x,n.lanes=x,n.memoizedState=K}}function Eh(n,r,c){if(n=r.effects,r.effects=null,n!==null)for(r=0;r<n.length;r++){var u=n[r],m=u.callback;if(m!==null){if(u.callback=null,u=c,typeof m!="function")throw Error(s(191,m));m.call(u)}}}var Oi={},tn=On(Oi),Pi=On(Oi),_i=On(Oi);function is(n){if(n===Oi)throw Error(s(174));return n}function Al(n,r){switch(Re(_i,r),Re(Pi,n),Re(tn,Oi),n=r.nodeType,n){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Ia(null,"");break;default:n=n===8?r.parentNode:r,r=n.namespaceURI||null,n=n.tagName,r=Ia(r,n)}Le(tn),Re(tn,r)}function Ds(){Le(tn),Le(Pi),Le(_i)}function Ah(n){is(_i.current);var r=is(tn.current),c=Ia(r,n.type);r!==c&&(Re(Pi,n),Re(tn,c))}function Il(n){Pi.current===n&&(Le(tn),Le(Pi))}var _e=On(0);function Yr(n){for(var r=n;r!==null;){if(r.tag===13){var c=r.memoizedState;if(c!==null&&(c=c.dehydrated,c===null||c.data==="$?"||c.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Rl=[];function Ml(){for(var n=0;n<Rl.length;n++)Rl[n]._workInProgressVersionPrimary=null;Rl.length=0}var Jr=D.ReactCurrentDispatcher,Ll=D.ReactCurrentBatchConfig,rs=0,De=null,Je=null,et=null,Xr=!1,Di=!1,zi=0,Ly=0;function ct(){throw Error(s(321))}function Ol(n,r){if(r===null)return!1;for(var c=0;c<r.length&&c<n.length;c++)if(!Ut(n[c],r[c]))return!1;return!0}function Pl(n,r,c,u,m,g){if(rs=g,De=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Jr.current=n===null||n.memoizedState===null?Dy:zy,n=c(u,m),Di){g=0;do{if(Di=!1,zi=0,25<=g)throw Error(s(301));g+=1,et=Je=null,r.updateQueue=null,Jr.current=By,n=c(u,m)}while(Di)}if(Jr.current=to,r=Je!==null&&Je.next!==null,rs=0,et=Je=De=null,Xr=!1,r)throw Error(s(300));return n}function _l(){var n=zi!==0;return zi=0,n}function nn(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return et===null?De.memoizedState=et=n:et=et.next=n,et}function Mt(){if(Je===null){var n=De.alternate;n=n!==null?n.memoizedState:null}else n=Je.next;var r=et===null?De.memoizedState:et.next;if(r!==null)et=r,Je=n;else{if(n===null)throw Error(s(310));Je=n,n={memoizedState:Je.memoizedState,baseState:Je.baseState,baseQueue:Je.baseQueue,queue:Je.queue,next:null},et===null?De.memoizedState=et=n:et=et.next=n}return et}function Bi(n,r){return typeof r=="function"?r(n):r}function Dl(n){var r=Mt(),c=r.queue;if(c===null)throw Error(s(311));c.lastRenderedReducer=n;var u=Je,m=u.baseQueue,g=c.pending;if(g!==null){if(m!==null){var x=m.next;m.next=g.next,g.next=x}u.baseQueue=m=g,c.pending=null}if(m!==null){g=m.next,u=u.baseState;var b=x=null,C=null,L=g;do{var U=L.lane;if((rs&U)===U)C!==null&&(C=C.next={lane:0,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null}),u=L.hasEagerState?L.eagerState:n(u,L.action);else{var K={lane:U,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null};C===null?(b=C=K,x=u):C=C.next=K,De.lanes|=U,os|=U}L=L.next}while(L!==null&&L!==g);C===null?x=u:C.next=b,Ut(u,r.memoizedState)||(kt=!0),r.memoizedState=u,r.baseState=x,r.baseQueue=C,c.lastRenderedState=u}if(n=c.interleaved,n!==null){m=n;do g=m.lane,De.lanes|=g,os|=g,m=m.next;while(m!==n)}else m===null&&(c.lanes=0);return[r.memoizedState,c.dispatch]}function zl(n){var r=Mt(),c=r.queue;if(c===null)throw Error(s(311));c.lastRenderedReducer=n;var u=c.dispatch,m=c.pending,g=r.memoizedState;if(m!==null){c.pending=null;var x=m=m.next;do g=n(g,x.action),x=x.next;while(x!==m);Ut(g,r.memoizedState)||(kt=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),c.lastRenderedState=g}return[g,u]}function Ih(){}function Rh(n,r){var c=De,u=Mt(),m=r(),g=!Ut(u.memoizedState,m);if(g&&(u.memoizedState=m,kt=!0),u=u.queue,Bl(Oh.bind(null,c,u,n),[n]),u.getSnapshot!==r||g||et!==null&&et.memoizedState.tag&1){if(c.flags|=2048,Fi(9,Lh.bind(null,c,u,m,r),void 0,null),tt===null)throw Error(s(349));(rs&30)!==0||Mh(c,r,m)}return m}function Mh(n,r,c){n.flags|=16384,n={getSnapshot:r,value:c},r=De.updateQueue,r===null?(r={lastEffect:null,stores:null},De.updateQueue=r,r.stores=[n]):(c=r.stores,c===null?r.stores=[n]:c.push(n))}function Lh(n,r,c,u){r.value=c,r.getSnapshot=u,Ph(r)&&_h(n)}function Oh(n,r,c){return c(function(){Ph(r)&&_h(n)})}function Ph(n){var r=n.getSnapshot;n=n.value;try{var c=r();return!Ut(n,c)}catch{return!0}}function _h(n){var r=vn(n,1);r!==null&&Gt(r,n,1,-1)}function Dh(n){var r=nn();return typeof n=="function"&&(n=n()),r.memoizedState=r.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Bi,lastRenderedState:n},r.queue=n,n=n.dispatch=_y.bind(null,De,n),[r.memoizedState,n]}function Fi(n,r,c,u){return n={tag:n,create:r,destroy:c,deps:u,next:null},r=De.updateQueue,r===null?(r={lastEffect:null,stores:null},De.updateQueue=r,r.lastEffect=n.next=n):(c=r.lastEffect,c===null?r.lastEffect=n.next=n:(u=c.next,c.next=n,n.next=u,r.lastEffect=n)),n}function zh(){return Mt().memoizedState}function Zr(n,r,c,u){var m=nn();De.flags|=n,m.memoizedState=Fi(1|r,c,void 0,u===void 0?null:u)}function eo(n,r,c,u){var m=Mt();u=u===void 0?null:u;var g=void 0;if(Je!==null){var x=Je.memoizedState;if(g=x.destroy,u!==null&&Ol(u,x.deps)){m.memoizedState=Fi(r,c,g,u);return}}De.flags|=n,m.memoizedState=Fi(1|r,c,g,u)}function Bh(n,r){return Zr(8390656,8,n,r)}function Bl(n,r){return eo(2048,8,n,r)}function Fh(n,r){return eo(4,2,n,r)}function Uh(n,r){return eo(4,4,n,r)}function Wh(n,r){if(typeof r=="function")return n=n(),r(n),function(){r(null)};if(r!=null)return n=n(),r.current=n,function(){r.current=null}}function Hh(n,r,c){return c=c!=null?c.concat([n]):null,eo(4,4,Wh.bind(null,r,n),c)}function Fl(){}function Kh(n,r){var c=Mt();r=r===void 0?null:r;var u=c.memoizedState;return u!==null&&r!==null&&Ol(r,u[1])?u[0]:(c.memoizedState=[n,r],n)}function Vh(n,r){var c=Mt();r=r===void 0?null:r;var u=c.memoizedState;return u!==null&&r!==null&&Ol(r,u[1])?u[0]:(n=n(),c.memoizedState=[n,r],n)}function Gh(n,r,c){return(rs&21)===0?(n.baseState&&(n.baseState=!1,kt=!0),n.memoizedState=c):(Ut(c,r)||(c=Su(),De.lanes|=c,os|=c,n.baseState=!0),r)}function Oy(n,r){var c=Ce;Ce=c!==0&&4>c?c:4,n(!0);var u=Ll.transition;Ll.transition={};try{n(!1),r()}finally{Ce=c,Ll.transition=u}}function qh(){return Mt().memoizedState}function Py(n,r,c){var u=Wn(n);if(c={lane:u,action:c,hasEagerState:!1,eagerState:null,next:null},Qh(n))Yh(r,c);else if(c=$h(n,r,c,u),c!==null){var m=pt();Gt(c,n,u,m),Jh(c,r,u)}}function _y(n,r,c){var u=Wn(n),m={lane:u,action:c,hasEagerState:!1,eagerState:null,next:null};if(Qh(n))Yh(r,m);else{var g=n.alternate;if(n.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var x=r.lastRenderedState,b=g(x,c);if(m.hasEagerState=!0,m.eagerState=b,Ut(b,x)){var C=r.interleaved;C===null?(m.next=m,Tl(r)):(m.next=C.next,C.next=m),r.interleaved=m;return}}catch{}finally{}c=$h(n,r,m,u),c!==null&&(m=pt(),Gt(c,n,u,m),Jh(c,r,u))}}function Qh(n){var r=n.alternate;return n===De||r!==null&&r===De}function Yh(n,r){Di=Xr=!0;var c=n.pending;c===null?r.next=r:(r.next=c.next,c.next=r),n.pending=r}function Jh(n,r,c){if((c&4194240)!==0){var u=r.lanes;u&=n.pendingLanes,c|=u,r.lanes=c,Wa(n,c)}}var to={readContext:Rt,useCallback:ct,useContext:ct,useEffect:ct,useImperativeHandle:ct,useInsertionEffect:ct,useLayoutEffect:ct,useMemo:ct,useReducer:ct,useRef:ct,useState:ct,useDebugValue:ct,useDeferredValue:ct,useTransition:ct,useMutableSource:ct,useSyncExternalStore:ct,useId:ct,unstable_isNewReconciler:!1},Dy={readContext:Rt,useCallback:function(n,r){return nn().memoizedState=[n,r===void 0?null:r],n},useContext:Rt,useEffect:Bh,useImperativeHandle:function(n,r,c){return c=c!=null?c.concat([n]):null,Zr(4194308,4,Wh.bind(null,r,n),c)},useLayoutEffect:function(n,r){return Zr(4194308,4,n,r)},useInsertionEffect:function(n,r){return Zr(4,2,n,r)},useMemo:function(n,r){var c=nn();return r=r===void 0?null:r,n=n(),c.memoizedState=[n,r],n},useReducer:function(n,r,c){var u=nn();return r=c!==void 0?c(r):r,u.memoizedState=u.baseState=r,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:r},u.queue=n,n=n.dispatch=Py.bind(null,De,n),[u.memoizedState,n]},useRef:function(n){var r=nn();return n={current:n},r.memoizedState=n},useState:Dh,useDebugValue:Fl,useDeferredValue:function(n){return nn().memoizedState=n},useTransition:function(){var n=Dh(!1),r=n[0];return n=Oy.bind(null,n[1]),nn().memoizedState=n,[r,n]},useMutableSource:function(){},useSyncExternalStore:function(n,r,c){var u=De,m=nn();if(Pe){if(c===void 0)throw Error(s(407));c=c()}else{if(c=r(),tt===null)throw Error(s(349));(rs&30)!==0||Mh(u,r,c)}m.memoizedState=c;var g={value:c,getSnapshot:r};return m.queue=g,Bh(Oh.bind(null,u,g,n),[n]),u.flags|=2048,Fi(9,Lh.bind(null,u,g,c,r),void 0,null),c},useId:function(){var n=nn(),r=tt.identifierPrefix;if(Pe){var c=gn,u=pn;c=(u&~(1<<32-Ft(u)-1)).toString(32)+c,r=":"+r+"R"+c,c=zi++,0<c&&(r+="H"+c.toString(32)),r+=":"}else c=Ly++,r=":"+r+"r"+c.toString(32)+":";return n.memoizedState=r},unstable_isNewReconciler:!1},zy={readContext:Rt,useCallback:Kh,useContext:Rt,useEffect:Bl,useImperativeHandle:Hh,useInsertionEffect:Fh,useLayoutEffect:Uh,useMemo:Vh,useReducer:Dl,useRef:zh,useState:function(){return Dl(Bi)},useDebugValue:Fl,useDeferredValue:function(n){var r=Mt();return Gh(r,Je.memoizedState,n)},useTransition:function(){var n=Dl(Bi)[0],r=Mt().memoizedState;return[n,r]},useMutableSource:Ih,useSyncExternalStore:Rh,useId:qh,unstable_isNewReconciler:!1},By={readContext:Rt,useCallback:Kh,useContext:Rt,useEffect:Bl,useImperativeHandle:Hh,useInsertionEffect:Fh,useLayoutEffect:Uh,useMemo:Vh,useReducer:zl,useRef:zh,useState:function(){return zl(Bi)},useDebugValue:Fl,useDeferredValue:function(n){var r=Mt();return Je===null?r.memoizedState=n:Gh(r,Je.memoizedState,n)},useTransition:function(){var n=zl(Bi)[0],r=Mt().memoizedState;return[n,r]},useMutableSource:Ih,useSyncExternalStore:Rh,useId:qh,unstable_isNewReconciler:!1};function Ht(n,r){if(n&&n.defaultProps){r=z({},r),n=n.defaultProps;for(var c in n)r[c]===void 0&&(r[c]=n[c]);return r}return r}function Ul(n,r,c,u){r=n.memoizedState,c=c(u,r),c=c==null?r:z({},r,c),n.memoizedState=c,n.lanes===0&&(n.updateQueue.baseState=c)}var no={isMounted:function(n){return(n=n._reactInternals)?Xn(n)===n:!1},enqueueSetState:function(n,r,c){n=n._reactInternals;var u=pt(),m=Wn(n),g=kn(u,m);g.payload=r,c!=null&&(g.callback=c),r=zn(n,g,m),r!==null&&(Gt(r,n,m,u),qr(r,n,m))},enqueueReplaceState:function(n,r,c){n=n._reactInternals;var u=pt(),m=Wn(n),g=kn(u,m);g.tag=1,g.payload=r,c!=null&&(g.callback=c),r=zn(n,g,m),r!==null&&(Gt(r,n,m,u),qr(r,n,m))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var c=pt(),u=Wn(n),m=kn(c,u);m.tag=2,r!=null&&(m.callback=r),r=zn(n,m,u),r!==null&&(Gt(r,n,u,c),qr(r,n,u))}};function Xh(n,r,c,u,m,g,x){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(u,g,x):r.prototype&&r.prototype.isPureReactComponent?!Ci(c,u)||!Ci(m,g):!0}function Zh(n,r,c){var u=!1,m=Pn,g=r.contextType;return typeof g=="object"&&g!==null?g=Rt(g):(m=vt(r)?es:lt.current,u=r.contextTypes,g=(u=u!=null)?Is(n,m):Pn),r=new r(c,g),n.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=no,n.stateNode=r,r._reactInternals=n,u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=m,n.__reactInternalMemoizedMaskedChildContext=g),r}function ef(n,r,c,u){n=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(c,u),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(c,u),r.state!==n&&no.enqueueReplaceState(r,r.state,null)}function Wl(n,r,c,u){var m=n.stateNode;m.props=c,m.state=n.memoizedState,m.refs={},El(n);var g=r.contextType;typeof g=="object"&&g!==null?m.context=Rt(g):(g=vt(r)?es:lt.current,m.context=Is(n,g)),m.state=n.memoizedState,g=r.getDerivedStateFromProps,typeof g=="function"&&(Ul(n,r,g,c),m.state=n.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof m.getSnapshotBeforeUpdate=="function"||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(r=m.state,typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount(),r!==m.state&&no.enqueueReplaceState(m,m.state,null),Qr(n,c,m,u),m.state=n.memoizedState),typeof m.componentDidMount=="function"&&(n.flags|=4194308)}function zs(n,r){try{var c="",u=r;do c+=we(u),u=u.return;while(u);var m=c}catch(g){m=`
|
|
39
39
|
Error generating stack: `+g.message+`
|
|
40
|
-
`+g.stack}return{value:n,source:r,stack:m,digest:null}}function Hl(n,r,c){return{value:n,source:null,stack:c??null,digest:r??null}}function Kl(n,r){try{console.error(r.value)}catch(c){setTimeout(function(){throw c})}}var Fy=typeof WeakMap=="function"?WeakMap:Map;function tf(n,r,c){c=kn(-1,c),c.tag=3,c.payload={element:null};var u=r.value;return c.callback=function(){co||(co=!0,oc=u),Kl(n,r)},c}function nf(n,r,c){c=kn(-1,c),c.tag=3;var u=n.type.getDerivedStateFromError;if(typeof u=="function"){var m=r.value;c.payload=function(){return u(m)},c.callback=function(){Kl(n,r)}}var g=n.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(c.callback=function(){Kl(n,r),typeof u!="function"&&(Fn===null?Fn=new Set([this]):Fn.add(this));var x=r.stack;this.componentDidCatch(r.value,{componentStack:x!==null?x:""})}),c}function sf(n,r,c){var u=n.pingCache;if(u===null){u=n.pingCache=new Fy;var m=new Set;u.set(r,m)}else m=u.get(r),m===void 0&&(m=new Set,u.set(r,m));m.has(c)||(m.add(c),n=tw.bind(null,n,r,c),r.then(n,n))}function rf(n){do{var r;if((r=n.tag===13)&&(r=n.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return n;n=n.return}while(n!==null);return null}function of(n,r,c,u,m){return(n.mode&1)===0?(n===r?n.flags|=65536:(n.flags|=128,c.flags|=131072,c.flags&=-52805,c.tag===1&&(c.alternate===null?c.tag=17:(r=kn(-1,1),r.tag=2,zn(c,r,1))),c.lanes|=1),n):(n.flags|=65536,n.lanes=m,n)}var Uy=D.ReactCurrentOwner,kt=!1;function mt(n,r,c,u){r.child=n===null?bh(r,null,c,u):Os(r,n.child,c,u)}function af(n,r,c,u,m){c=c.render;var g=r.ref;return _s(r,m),u=Pl(n,r,c,u,g,m),c=_l(),n!==null&&!kt?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~m,yn(n,r,m)):(Pe&&c&&yl(r),r.flags|=1,mt(n,r,u,m),r.child)}function lf(n,r,c,u,m){if(n===null){var g=c.type;return typeof g=="function"&&!fc(g)&&g.defaultProps===void 0&&c.compare===null&&c.defaultProps===void 0?(r.tag=15,r.type=g,cf(n,r,g,u,m)):(n=go(c.type,null,u,r,r.mode,m),n.ref=r.ref,n.return=r,r.child=n)}if(g=n.child,(n.lanes&m)===0){var x=g.memoizedProps;if(c=c.compare,c=c!==null?c:Ci,c(x,u)&&n.ref===r.ref)return yn(n,r,m)}return r.flags|=1,n=Kn(g,u),n.ref=r.ref,n.return=r,r.child=n}function cf(n,r,c,u,m){if(n!==null){var g=n.memoizedProps;if(Ci(g,u)&&n.ref===r.ref)if(kt=!1,r.pendingProps=u=g,(n.lanes&m)!==0)(n.flags&131072)!==0&&(kt=!0);else return r.lanes=n.lanes,yn(n,r,m)}return Vl(n,r,c,u,m)}function df(n,r,c){var u=r.pendingProps,m=u.children,g=n!==null?n.memoizedState:null;if(u.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},Re(Fs,Tt),Tt|=c;else{if((c&1073741824)===0)return n=g!==null?g.baseLanes|c:c,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:n,cachePool:null,transitions:null},r.updateQueue=null,Re(Fs,Tt),Tt|=n,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},u=g!==null?g.baseLanes:c,Re(Fs,Tt),Tt|=u}else g!==null?(u=g.baseLanes|c,r.memoizedState=null):u=c,Re(Fs,Tt),Tt|=u;return mt(n,r,m,c),r.child}function uf(n,r){var c=r.ref;(n===null&&c!==null||n!==null&&n.ref!==c)&&(r.flags|=512,r.flags|=2097152)}function Vl(n,r,c,u,m){var g=vt(c)?es:lt.current;return g=Is(r,g),_s(r,m),c=Pl(n,r,c,u,g,m),u=_l(),n!==null&&!kt?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~m,yn(n,r,m)):(Pe&&u&&yl(r),r.flags|=1,mt(n,r,c,m),r.child)}function hf(n,r,c,u,m){if(vt(c)){var g=!0;Br(r)}else g=!1;if(_s(r,m),r.stateNode===null)io(n,r),Zh(r,c,u),Wl(r,c,u,m),u=!0;else if(n===null){var x=r.stateNode,b=r.memoizedProps;x.props=b;var C=x.context,L=c.contextType;typeof L=="object"&&L!==null?L=Rt(L):(L=vt(c)?es:lt.current,L=Is(r,L));var U=c.getDerivedStateFromProps,K=typeof U=="function"||typeof x.getSnapshotBeforeUpdate=="function";K||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(b!==u||C!==L)&&ef(r,x,u,L),Dn=!1;var B=r.memoizedState;x.state=B,Qr(r,u,x,m),C=r.memoizedState,b!==u||B!==C||gt.current||Dn?(typeof U=="function"&&(Ul(r,c,U,u),C=r.memoizedState),(b=Dn||Xh(r,c,b,u,B,C,L))?(K||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(r.flags|=4194308)):(typeof x.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=u,r.memoizedState=C),x.props=u,x.state=C,x.context=L,u=b):(typeof x.componentDidMount=="function"&&(r.flags|=4194308),u=!1)}else{x=r.stateNode,Ch(n,r),b=r.memoizedProps,L=r.type===r.elementType?b:Ht(r.type,b),x.props=L,K=r.pendingProps,B=x.context,C=c.contextType,typeof C=="object"&&C!==null?C=Rt(C):(C=vt(c)?es:lt.current,C=Is(r,C));var ee=c.getDerivedStateFromProps;(U=typeof ee=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(b!==K||B!==C)&&ef(r,x,u,C),Dn=!1,B=r.memoizedState,x.state=B,Qr(r,u,x,m);var se=r.memoizedState;b!==K||B!==se||gt.current||Dn?(typeof ee=="function"&&(Ul(r,c,ee,u),se=r.memoizedState),(L=Dn||Xh(r,c,L,u,B,se,C)||!1)?(U||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(u,se,C),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(u,se,C)),typeof x.componentDidUpdate=="function"&&(r.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof x.componentDidUpdate!="function"||b===n.memoizedProps&&B===n.memoizedState||(r.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||b===n.memoizedProps&&B===n.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=se),x.props=u,x.state=se,x.context=C,u=L):(typeof x.componentDidUpdate!="function"||b===n.memoizedProps&&B===n.memoizedState||(r.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||b===n.memoizedProps&&B===n.memoizedState||(r.flags|=1024),u=!1)}return Gl(n,r,c,u,g,m)}function Gl(n,r,c,u,m,g){uf(n,r);var x=(r.flags&128)!==0;if(!u&&!x)return m&&gh(r,c,!1),yn(n,r,g);u=r.stateNode,Uy.current=r;var b=x&&typeof c.getDerivedStateFromError!="function"?null:u.render();return r.flags|=1,n!==null&&x?(r.child=Os(r,n.child,null,g),r.child=Os(r,null,b,g)):mt(n,r,b,g),r.memoizedState=u.state,m&&gh(r,c,!0),r.child}function ff(n){var r=n.stateNode;r.pendingContext?mh(n,r.pendingContext,r.pendingContext!==r.context):r.context&&mh(n,r.context,!1),Al(n,r.containerInfo)}function mf(n,r,c,u,m){return Ls(),Sl(m),r.flags|=256,mt(n,r,c,u),r.child}var ql={dehydrated:null,treeContext:null,retryLane:0};function Ql(n){return{baseLanes:n,cachePool:null,transitions:null}}function pf(n,r,c){var u=r.pendingProps,m=_e.current,g=!1,x=(r.flags&128)!==0,b;if((b=x)||(b=n!==null&&n.memoizedState===null?!1:(m&2)!==0),b?(g=!0,r.flags&=-129):(n===null||n.memoizedState!==null)&&(m|=1),Re(_e,m&1),n===null)return jl(r),n=r.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((r.mode&1)===0?r.lanes=1:n.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(x=u.children,n=u.fallback,g?(u=r.mode,g=r.child,x={mode:"hidden",children:x},(u&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=x):g=vo(x,u,0,null),n=ds(n,u,c,null),g.return=r,n.return=r,g.sibling=n,r.child=g,r.child.memoizedState=Ql(c),r.memoizedState=ql,n):Yl(r,x));if(m=n.memoizedState,m!==null&&(b=m.dehydrated,b!==null))return Wy(n,r,x,u,b,m,c);if(g){g=u.fallback,x=r.mode,m=n.child,b=m.sibling;var C={mode:"hidden",children:u.children};return(x&1)===0&&r.child!==m?(u=r.child,u.childLanes=0,u.pendingProps=C,r.deletions=null):(u=Kn(m,C),u.subtreeFlags=m.subtreeFlags&14680064),b!==null?g=Kn(b,g):(g=ds(g,x,c,null),g.flags|=2),g.return=r,u.return=r,u.sibling=g,r.child=u,u=g,g=r.child,x=n.child.memoizedState,x=x===null?Ql(c):{baseLanes:x.baseLanes|c,cachePool:null,transitions:x.transitions},g.memoizedState=x,g.childLanes=n.childLanes&~c,r.memoizedState=ql,u}return g=n.child,n=g.sibling,u=Kn(g,{mode:"visible",children:u.children}),(r.mode&1)===0&&(u.lanes=c),u.return=r,u.sibling=null,n!==null&&(c=r.deletions,c===null?(r.deletions=[n],r.flags|=16):c.push(n)),r.child=u,r.memoizedState=null,u}function Yl(n,r){return r=vo({mode:"visible",children:r},n.mode,0,null),r.return=n,n.child=r}function so(n,r,c,u){return u!==null&&Sl(u),Os(r,n.child,null,c),n=Yl(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function Wy(n,r,c,u,m,g,x){if(c)return r.flags&256?(r.flags&=-257,u=Hl(Error(s(422))),so(n,r,x,u)):r.memoizedState!==null?(r.child=n.child,r.flags|=128,null):(g=u.fallback,m=r.mode,u=vo({mode:"visible",children:u.children},m,0,null),g=ds(g,m,x,null),g.flags|=2,u.return=r,g.return=r,u.sibling=g,r.child=u,(r.mode&1)!==0&&Os(r,n.child,null,x),r.child.memoizedState=Ql(x),r.memoizedState=ql,g);if((r.mode&1)===0)return so(n,r,x,null);if(m.data==="$!"){if(u=m.nextSibling&&m.nextSibling.dataset,u)var b=u.dgst;return u=b,g=Error(s(419)),u=Hl(g,u,void 0),so(n,r,x,u)}if(b=(x&n.childLanes)!==0,kt||b){if(u=tt,u!==null){switch(x&-x){case 4:m=2;break;case 16:m=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:m=32;break;case 536870912:m=268435456;break;default:m=0}m=(m&(u.suspendedLanes|x))!==0?0:m,m!==0&&m!==g.retryLane&&(g.retryLane=m,vn(n,m),Gt(u,n,m,-1))}return hc(),u=Hl(Error(s(421))),so(n,r,x,u)}return m.data==="$?"?(r.flags|=128,r.child=n.child,r=nw.bind(null,n),m._reactRetry=r,null):(n=g.treeContext,Ct=Ln(m.nextSibling),$t=r,Pe=!0,Wt=null,n!==null&&(At[It++]=pn,At[It++]=gn,At[It++]=ts,pn=n.id,gn=n.overflow,ts=r),r=Yl(r,u.children),r.flags|=4096,r)}function gf(n,r,c){n.lanes|=r;var u=n.alternate;u!==null&&(u.lanes|=r),Cl(n.return,r,c)}function Jl(n,r,c,u,m){var g=n.memoizedState;g===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:u,tail:c,tailMode:m}:(g.isBackwards=r,g.rendering=null,g.renderingStartTime=0,g.last=u,g.tail=c,g.tailMode=m)}function vf(n,r,c){var u=r.pendingProps,m=u.revealOrder,g=u.tail;if(mt(n,r,u.children,c),u=_e.current,(u&2)!==0)u=u&1|2,r.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=r.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&gf(n,c,r);else if(n.tag===19)gf(n,c,r);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===r)break e;for(;n.sibling===null;){if(n.return===null||n.return===r)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}u&=1}if(Re(_e,u),(r.mode&1)===0)r.memoizedState=null;else switch(m){case"forwards":for(c=r.child,m=null;c!==null;)n=c.alternate,n!==null&&Yr(n)===null&&(m=c),c=c.sibling;c=m,c===null?(m=r.child,r.child=null):(m=c.sibling,c.sibling=null),Jl(r,!1,m,c,g);break;case"backwards":for(c=null,m=r.child,r.child=null;m!==null;){if(n=m.alternate,n!==null&&Yr(n)===null){r.child=m;break}n=m.sibling,m.sibling=c,c=m,m=n}Jl(r,!0,c,null,g);break;case"together":Jl(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function io(n,r){(r.mode&1)===0&&n!==null&&(n.alternate=null,r.alternate=null,r.flags|=2)}function yn(n,r,c){if(n!==null&&(r.dependencies=n.dependencies),os|=r.lanes,(c&r.childLanes)===0)return null;if(n!==null&&r.child!==n.child)throw Error(s(153));if(r.child!==null){for(n=r.child,c=Kn(n,n.pendingProps),r.child=c,c.return=r;n.sibling!==null;)n=n.sibling,c=c.sibling=Kn(n,n.pendingProps),c.return=r;c.sibling=null}return r.child}function Hy(n,r,c){switch(r.tag){case 3:ff(r),Ls();break;case 5:Ah(r);break;case 1:vt(r.type)&&Br(r);break;case 4:Al(r,r.stateNode.containerInfo);break;case 10:var u=r.type._context,m=r.memoizedProps.value;Re(Vr,u._currentValue),u._currentValue=m;break;case 13:if(u=r.memoizedState,u!==null)return u.dehydrated!==null?(Re(_e,_e.current&1),r.flags|=128,null):(c&r.child.childLanes)!==0?pf(n,r,c):(Re(_e,_e.current&1),n=yn(n,r,c),n!==null?n.sibling:null);Re(_e,_e.current&1);break;case 19:if(u=(c&r.childLanes)!==0,(n.flags&128)!==0){if(u)return vf(n,r,c);r.flags|=128}if(m=r.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),Re(_e,_e.current),u)break;return null;case 22:case 23:return r.lanes=0,df(n,r,c)}return yn(n,r,c)}var kf,Xl,yf,wf;kf=function(n,r){for(var c=r.child;c!==null;){if(c.tag===5||c.tag===6)n.appendChild(c.stateNode);else if(c.tag!==4&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===r)break;for(;c.sibling===null;){if(c.return===null||c.return===r)return;c=c.return}c.sibling.return=c.return,c=c.sibling}},Xl=function(){},yf=function(n,r,c,u){var m=n.memoizedProps;if(m!==u){n=r.stateNode,is(tn.current);var g=null;switch(c){case"input":m=Ca(n,m),u=Ca(n,u),g=[];break;case"select":m=z({},m,{value:void 0}),u=z({},u,{value:void 0}),g=[];break;case"textarea":m=Aa(n,m),u=Aa(n,u),g=[];break;default:typeof m.onClick!="function"&&typeof u.onClick=="function"&&(n.onclick=_r)}Ra(c,u);var x;c=null;for(L in m)if(!u.hasOwnProperty(L)&&m.hasOwnProperty(L)&&m[L]!=null)if(L==="style"){var b=m[L];for(x in b)b.hasOwnProperty(x)&&(c||(c={}),c[x]="")}else L!=="dangerouslySetInnerHTML"&&L!=="children"&&L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&L!=="autoFocus"&&(a.hasOwnProperty(L)?g||(g=[]):(g=g||[]).push(L,null));for(L in u){var C=u[L];if(b=m!=null?m[L]:void 0,u.hasOwnProperty(L)&&C!==b&&(C!=null||b!=null))if(L==="style")if(b){for(x in b)!b.hasOwnProperty(x)||C&&C.hasOwnProperty(x)||(c||(c={}),c[x]="");for(x in C)C.hasOwnProperty(x)&&b[x]!==C[x]&&(c||(c={}),c[x]=C[x])}else c||(g||(g=[]),g.push(L,c)),c=C;else L==="dangerouslySetInnerHTML"?(C=C?C.__html:void 0,b=b?b.__html:void 0,C!=null&&b!==C&&(g=g||[]).push(L,C)):L==="children"?typeof C!="string"&&typeof C!="number"||(g=g||[]).push(L,""+C):L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&(a.hasOwnProperty(L)?(C!=null&&L==="onScroll"&&Me("scroll",n),g||b===C||(g=[])):(g=g||[]).push(L,C))}c&&(g=g||[]).push("style",c);var L=g;(r.updateQueue=L)&&(r.flags|=4)}},wf=function(n,r,c,u){c!==u&&(r.flags|=4)};function Ui(n,r){if(!Pe)switch(n.tailMode){case"hidden":r=n.tail;for(var c=null;r!==null;)r.alternate!==null&&(c=r),r=r.sibling;c===null?n.tail=null:c.sibling=null;break;case"collapsed":c=n.tail;for(var u=null;c!==null;)c.alternate!==null&&(u=c),c=c.sibling;u===null?r||n.tail===null?n.tail=null:n.tail.sibling=null:u.sibling=null}}function dt(n){var r=n.alternate!==null&&n.alternate.child===n.child,c=0,u=0;if(r)for(var m=n.child;m!==null;)c|=m.lanes|m.childLanes,u|=m.subtreeFlags&14680064,u|=m.flags&14680064,m.return=n,m=m.sibling;else for(m=n.child;m!==null;)c|=m.lanes|m.childLanes,u|=m.subtreeFlags,u|=m.flags,m.return=n,m=m.sibling;return n.subtreeFlags|=u,n.childLanes=c,r}function Ky(n,r,c){var u=r.pendingProps;switch(wl(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return dt(r),null;case 1:return vt(r.type)&&zr(),dt(r),null;case 3:return u=r.stateNode,Ds(),Le(gt),Le(lt),Ml(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(n===null||n.child===null)&&(Hr(r)?r.flags|=4:n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Wt!==null&&(cc(Wt),Wt=null))),Xl(n,r),dt(r),null;case 5:Il(r);var m=is(_i.current);if(c=r.type,n!==null&&r.stateNode!=null)yf(n,r,c,u,m),n.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!u){if(r.stateNode===null)throw Error(s(166));return dt(r),null}if(n=is(tn.current),Hr(r)){u=r.stateNode,c=r.type;var g=r.memoizedProps;switch(u[en]=r,u[Ri]=g,n=(r.mode&1)!==0,c){case"dialog":Me("cancel",u),Me("close",u);break;case"iframe":case"object":case"embed":Me("load",u);break;case"video":case"audio":for(m=0;m<Ei.length;m++)Me(Ei[m],u);break;case"source":Me("error",u);break;case"img":case"image":case"link":Me("error",u),Me("load",u);break;case"details":Me("toggle",u);break;case"input":Zd(u,g),Me("invalid",u);break;case"select":u._wrapperState={wasMultiple:!!g.multiple},Me("invalid",u);break;case"textarea":nu(u,g),Me("invalid",u)}Ra(c,g),m=null;for(var x in g)if(g.hasOwnProperty(x)){var b=g[x];x==="children"?typeof b=="string"?u.textContent!==b&&(g.suppressHydrationWarning!==!0&&Pr(u.textContent,b,n),m=["children",b]):typeof b=="number"&&u.textContent!==""+b&&(g.suppressHydrationWarning!==!0&&Pr(u.textContent,b,n),m=["children",""+b]):a.hasOwnProperty(x)&&b!=null&&x==="onScroll"&&Me("scroll",u)}switch(c){case"input":Cn(u),tu(u,g,!0);break;case"textarea":Cn(u),iu(u);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(u.onclick=_r)}u=m,r.updateQueue=u,u!==null&&(r.flags|=4)}else{x=m.nodeType===9?m:m.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=ru(c)),n==="http://www.w3.org/1999/xhtml"?c==="script"?(n=x.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof u.is=="string"?n=x.createElement(c,{is:u.is}):(n=x.createElement(c),c==="select"&&(x=n,u.multiple?x.multiple=!0:u.size&&(x.size=u.size))):n=x.createElementNS(n,c),n[en]=r,n[Ri]=u,kf(n,r,!1,!1),r.stateNode=n;e:{switch(x=Ma(c,u),c){case"dialog":Me("cancel",n),Me("close",n),m=u;break;case"iframe":case"object":case"embed":Me("load",n),m=u;break;case"video":case"audio":for(m=0;m<Ei.length;m++)Me(Ei[m],n);m=u;break;case"source":Me("error",n),m=u;break;case"img":case"image":case"link":Me("error",n),Me("load",n),m=u;break;case"details":Me("toggle",n),m=u;break;case"input":Zd(n,u),m=Ca(n,u),Me("invalid",n);break;case"option":m=u;break;case"select":n._wrapperState={wasMultiple:!!u.multiple},m=z({},u,{value:void 0}),Me("invalid",n);break;case"textarea":nu(n,u),m=Aa(n,u),Me("invalid",n);break;default:m=u}Ra(c,m),b=m;for(g in b)if(b.hasOwnProperty(g)){var C=b[g];g==="style"?lu(n,C):g==="dangerouslySetInnerHTML"?(C=C?C.__html:void 0,C!=null&&ou(n,C)):g==="children"?typeof C=="string"?(c!=="textarea"||C!=="")&&di(n,C):typeof C=="number"&&di(n,""+C):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(a.hasOwnProperty(g)?C!=null&&g==="onScroll"&&Me("scroll",n):C!=null&&O(n,g,C,x))}switch(c){case"input":Cn(n),tu(n,u,!1);break;case"textarea":Cn(n),iu(n);break;case"option":u.value!=null&&n.setAttribute("value",""+Se(u.value));break;case"select":n.multiple=!!u.multiple,g=u.value,g!=null?ys(n,!!u.multiple,g,!1):u.defaultValue!=null&&ys(n,!!u.multiple,u.defaultValue,!0);break;default:typeof m.onClick=="function"&&(n.onclick=_r)}switch(c){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}}u&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return dt(r),null;case 6:if(n&&r.stateNode!=null)wf(n,r,n.memoizedProps,u);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(c=is(_i.current),is(tn.current),Hr(r)){if(u=r.stateNode,c=r.memoizedProps,u[en]=r,(g=u.nodeValue!==c)&&(n=$t,n!==null))switch(n.tag){case 3:Pr(u.nodeValue,c,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&Pr(u.nodeValue,c,(n.mode&1)!==0)}g&&(r.flags|=4)}else u=(c.nodeType===9?c:c.ownerDocument).createTextNode(u),u[en]=r,r.stateNode=u}return dt(r),null;case 13:if(Le(_e),u=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(Pe&&Ct!==null&&(r.mode&1)!==0&&(r.flags&128)===0)jh(),Ls(),r.flags|=98560,g=!1;else if(g=Hr(r),u!==null&&u.dehydrated!==null){if(n===null){if(!g)throw Error(s(318));if(g=r.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(s(317));g[en]=r}else Ls(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;dt(r),g=!1}else Wt!==null&&(cc(Wt),Wt=null),g=!0;if(!g)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=c,r):(u=u!==null,u!==(n!==null&&n.memoizedState!==null)&&u&&(r.child.flags|=8192,(r.mode&1)!==0&&(n===null||(_e.current&1)!==0?Xe===0&&(Xe=3):hc())),r.updateQueue!==null&&(r.flags|=4),dt(r),null);case 4:return Ds(),Xl(n,r),n===null&&Ai(r.stateNode.containerInfo),dt(r),null;case 10:return $l(r.type._context),dt(r),null;case 17:return vt(r.type)&&zr(),dt(r),null;case 19:if(Le(_e),g=r.memoizedState,g===null)return dt(r),null;if(u=(r.flags&128)!==0,x=g.rendering,x===null)if(u)Ui(g,!1);else{if(Xe!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(x=Yr(n),x!==null){for(r.flags|=128,Ui(g,!1),u=x.updateQueue,u!==null&&(r.updateQueue=u,r.flags|=4),r.subtreeFlags=0,u=c,c=r.child;c!==null;)g=c,n=u,g.flags&=14680066,x=g.alternate,x===null?(g.childLanes=0,g.lanes=n,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=x.childLanes,g.lanes=x.lanes,g.child=x.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=x.memoizedProps,g.memoizedState=x.memoizedState,g.updateQueue=x.updateQueue,g.type=x.type,n=x.dependencies,g.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),c=c.sibling;return Re(_e,_e.current&1|2),r.child}n=n.sibling}g.tail!==null&&We()>Us&&(r.flags|=128,u=!0,Ui(g,!1),r.lanes=4194304)}else{if(!u)if(n=Yr(x),n!==null){if(r.flags|=128,u=!0,c=n.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),Ui(g,!0),g.tail===null&&g.tailMode==="hidden"&&!x.alternate&&!Pe)return dt(r),null}else 2*We()-g.renderingStartTime>Us&&c!==1073741824&&(r.flags|=128,u=!0,Ui(g,!1),r.lanes=4194304);g.isBackwards?(x.sibling=r.child,r.child=x):(c=g.last,c!==null?c.sibling=x:r.child=x,g.last=x)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=We(),r.sibling=null,c=_e.current,Re(_e,u?c&1|2:c&1),r):(dt(r),null);case 22:case 23:return uc(),u=r.memoizedState!==null,n!==null&&n.memoizedState!==null!==u&&(r.flags|=8192),u&&(r.mode&1)!==0?(Tt&1073741824)!==0&&(dt(r),r.subtreeFlags&6&&(r.flags|=8192)):dt(r),null;case 24:return null;case 25:return null}throw Error(s(156,r.tag))}function Vy(n,r){switch(wl(r),r.tag){case 1:return vt(r.type)&&zr(),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return Ds(),Le(gt),Le(lt),Ml(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 5:return Il(r),null;case 13:if(Le(_e),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(s(340));Ls()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return Le(_e),null;case 4:return Ds(),null;case 10:return $l(r.type._context),null;case 22:case 23:return uc(),null;case 24:return null;default:return null}}var ro=!1,ut=!1,Gy=typeof WeakSet=="function"?WeakSet:Set,te=null;function Bs(n,r){var c=n.ref;if(c!==null)if(typeof c=="function")try{c(null)}catch(u){Ue(n,r,u)}else c.current=null}function Zl(n,r,c){try{c()}catch(u){Ue(n,r,u)}}var xf=!1;function qy(n,r){if(ul=br,n=Xu(),sl(n)){if("selectionStart"in n)var c={start:n.selectionStart,end:n.selectionEnd};else e:{c=(c=n.ownerDocument)&&c.defaultView||window;var u=c.getSelection&&c.getSelection();if(u&&u.rangeCount!==0){c=u.anchorNode;var m=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{c.nodeType,g.nodeType}catch{c=null;break e}var x=0,b=-1,C=-1,L=0,U=0,K=n,B=null;t:for(;;){for(var ee;K!==c||m!==0&&K.nodeType!==3||(b=x+m),K!==g||u!==0&&K.nodeType!==3||(C=x+u),K.nodeType===3&&(x+=K.nodeValue.length),(ee=K.firstChild)!==null;)B=K,K=ee;for(;;){if(K===n)break t;if(B===c&&++L===m&&(b=x),B===g&&++U===u&&(C=x),(ee=K.nextSibling)!==null)break;K=B,B=K.parentNode}K=ee}c=b===-1||C===-1?null:{start:b,end:C}}else c=null}c=c||{start:0,end:0}}else c=null;for(hl={focusedElem:n,selectionRange:c},br=!1,te=r;te!==null;)if(r=te,n=r.child,(r.subtreeFlags&1028)!==0&&n!==null)n.return=r,te=n;else for(;te!==null;){r=te;try{var se=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(se!==null){var re=se.memoizedProps,He=se.memoizedState,A=r.stateNode,E=A.getSnapshotBeforeUpdate(r.elementType===r.type?re:Ht(r.type,re),He);A.__reactInternalSnapshotBeforeUpdate=E}break;case 3:var R=r.stateNode.containerInfo;R.nodeType===1?R.textContent="":R.nodeType===9&&R.documentElement&&R.removeChild(R.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(Y){Ue(r,r.return,Y)}if(n=r.sibling,n!==null){n.return=r.return,te=n;break}te=r.return}return se=xf,xf=!1,se}function Wi(n,r,c){var u=r.updateQueue;if(u=u!==null?u.lastEffect:null,u!==null){var m=u=u.next;do{if((m.tag&n)===n){var g=m.destroy;m.destroy=void 0,g!==void 0&&Zl(r,c,g)}m=m.next}while(m!==u)}}function oo(n,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var c=r=r.next;do{if((c.tag&n)===n){var u=c.create;c.destroy=u()}c=c.next}while(c!==r)}}function ec(n){var r=n.ref;if(r!==null){var c=n.stateNode;switch(n.tag){case 5:n=c;break;default:n=c}typeof r=="function"?r(n):r.current=n}}function jf(n){var r=n.alternate;r!==null&&(n.alternate=null,jf(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&(delete r[en],delete r[Ri],delete r[gl],delete r[Ay],delete r[Iy])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function Sf(n){return n.tag===5||n.tag===3||n.tag===4}function Nf(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Sf(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function tc(n,r,c){var u=n.tag;if(u===5||u===6)n=n.stateNode,r?c.nodeType===8?c.parentNode.insertBefore(n,r):c.insertBefore(n,r):(c.nodeType===8?(r=c.parentNode,r.insertBefore(n,c)):(r=c,r.appendChild(n)),c=c._reactRootContainer,c!=null||r.onclick!==null||(r.onclick=_r));else if(u!==4&&(n=n.child,n!==null))for(tc(n,r,c),n=n.sibling;n!==null;)tc(n,r,c),n=n.sibling}function nc(n,r,c){var u=n.tag;if(u===5||u===6)n=n.stateNode,r?c.insertBefore(n,r):c.appendChild(n);else if(u!==4&&(n=n.child,n!==null))for(nc(n,r,c),n=n.sibling;n!==null;)nc(n,r,c),n=n.sibling}var it=null,Kt=!1;function Bn(n,r,c){for(c=c.child;c!==null;)bf(n,r,c),c=c.sibling}function bf(n,r,c){if(Zt&&typeof Zt.onCommitFiberUnmount=="function")try{Zt.onCommitFiberUnmount(yr,c)}catch{}switch(c.tag){case 5:ut||Bs(c,r);case 6:var u=it,m=Kt;it=null,Bn(n,r,c),it=u,Kt=m,it!==null&&(Kt?(n=it,c=c.stateNode,n.nodeType===8?n.parentNode.removeChild(c):n.removeChild(c)):it.removeChild(c.stateNode));break;case 18:it!==null&&(Kt?(n=it,c=c.stateNode,n.nodeType===8?pl(n.parentNode,c):n.nodeType===1&&pl(n,c),xi(n)):pl(it,c.stateNode));break;case 4:u=it,m=Kt,it=c.stateNode.containerInfo,Kt=!0,Bn(n,r,c),it=u,Kt=m;break;case 0:case 11:case 14:case 15:if(!ut&&(u=c.updateQueue,u!==null&&(u=u.lastEffect,u!==null))){m=u=u.next;do{var g=m,x=g.destroy;g=g.tag,x!==void 0&&((g&2)!==0||(g&4)!==0)&&Zl(c,r,x),m=m.next}while(m!==u)}Bn(n,r,c);break;case 1:if(!ut&&(Bs(c,r),u=c.stateNode,typeof u.componentWillUnmount=="function"))try{u.props=c.memoizedProps,u.state=c.memoizedState,u.componentWillUnmount()}catch(b){Ue(c,r,b)}Bn(n,r,c);break;case 21:Bn(n,r,c);break;case 22:c.mode&1?(ut=(u=ut)||c.memoizedState!==null,Bn(n,r,c),ut=u):Bn(n,r,c);break;default:Bn(n,r,c)}}function $f(n){var r=n.updateQueue;if(r!==null){n.updateQueue=null;var c=n.stateNode;c===null&&(c=n.stateNode=new Gy),r.forEach(function(u){var m=sw.bind(null,n,u);c.has(u)||(c.add(u),u.then(m,m))})}}function Vt(n,r){var c=r.deletions;if(c!==null)for(var u=0;u<c.length;u++){var m=c[u];try{var g=n,x=r,b=x;e:for(;b!==null;){switch(b.tag){case 5:it=b.stateNode,Kt=!1;break e;case 3:it=b.stateNode.containerInfo,Kt=!0;break e;case 4:it=b.stateNode.containerInfo,Kt=!0;break e}b=b.return}if(it===null)throw Error(s(160));bf(g,x,m),it=null,Kt=!1;var C=m.alternate;C!==null&&(C.return=null),m.return=null}catch(L){Ue(m,r,L)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)Cf(r,n),r=r.sibling}function Cf(n,r){var c=n.alternate,u=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Vt(r,n),sn(n),u&4){try{Wi(3,n,n.return),oo(3,n)}catch(re){Ue(n,n.return,re)}try{Wi(5,n,n.return)}catch(re){Ue(n,n.return,re)}}break;case 1:Vt(r,n),sn(n),u&512&&c!==null&&Bs(c,c.return);break;case 5:if(Vt(r,n),sn(n),u&512&&c!==null&&Bs(c,c.return),n.flags&32){var m=n.stateNode;try{di(m,"")}catch(re){Ue(n,n.return,re)}}if(u&4&&(m=n.stateNode,m!=null)){var g=n.memoizedProps,x=c!==null?c.memoizedProps:g,b=n.type,C=n.updateQueue;if(n.updateQueue=null,C!==null)try{b==="input"&&g.type==="radio"&&g.name!=null&&eu(m,g),Ma(b,x);var L=Ma(b,g);for(x=0;x<C.length;x+=2){var U=C[x],K=C[x+1];U==="style"?lu(m,K):U==="dangerouslySetInnerHTML"?ou(m,K):U==="children"?di(m,K):O(m,U,K,L)}switch(b){case"input":Ta(m,g);break;case"textarea":su(m,g);break;case"select":var B=m._wrapperState.wasMultiple;m._wrapperState.wasMultiple=!!g.multiple;var ee=g.value;ee!=null?ys(m,!!g.multiple,ee,!1):B!==!!g.multiple&&(g.defaultValue!=null?ys(m,!!g.multiple,g.defaultValue,!0):ys(m,!!g.multiple,g.multiple?[]:"",!1))}m[Ri]=g}catch(re){Ue(n,n.return,re)}}break;case 6:if(Vt(r,n),sn(n),u&4){if(n.stateNode===null)throw Error(s(162));m=n.stateNode,g=n.memoizedProps;try{m.nodeValue=g}catch(re){Ue(n,n.return,re)}}break;case 3:if(Vt(r,n),sn(n),u&4&&c!==null&&c.memoizedState.isDehydrated)try{xi(r.containerInfo)}catch(re){Ue(n,n.return,re)}break;case 4:Vt(r,n),sn(n);break;case 13:Vt(r,n),sn(n),m=n.child,m.flags&8192&&(g=m.memoizedState!==null,m.stateNode.isHidden=g,!g||m.alternate!==null&&m.alternate.memoizedState!==null||(rc=We())),u&4&&$f(n);break;case 22:if(U=c!==null&&c.memoizedState!==null,n.mode&1?(ut=(L=ut)||U,Vt(r,n),ut=L):Vt(r,n),sn(n),u&8192){if(L=n.memoizedState!==null,(n.stateNode.isHidden=L)&&!U&&(n.mode&1)!==0)for(te=n,U=n.child;U!==null;){for(K=te=U;te!==null;){switch(B=te,ee=B.child,B.tag){case 0:case 11:case 14:case 15:Wi(4,B,B.return);break;case 1:Bs(B,B.return);var se=B.stateNode;if(typeof se.componentWillUnmount=="function"){u=B,c=B.return;try{r=u,se.props=r.memoizedProps,se.state=r.memoizedState,se.componentWillUnmount()}catch(re){Ue(u,c,re)}}break;case 5:Bs(B,B.return);break;case 22:if(B.memoizedState!==null){Af(K);continue}}ee!==null?(ee.return=B,te=ee):Af(K)}U=U.sibling}e:for(U=null,K=n;;){if(K.tag===5){if(U===null){U=K;try{m=K.stateNode,L?(g=m.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(b=K.stateNode,C=K.memoizedProps.style,x=C!=null&&C.hasOwnProperty("display")?C.display:null,b.style.display=au("display",x))}catch(re){Ue(n,n.return,re)}}}else if(K.tag===6){if(U===null)try{K.stateNode.nodeValue=L?"":K.memoizedProps}catch(re){Ue(n,n.return,re)}}else if((K.tag!==22&&K.tag!==23||K.memoizedState===null||K===n)&&K.child!==null){K.child.return=K,K=K.child;continue}if(K===n)break e;for(;K.sibling===null;){if(K.return===null||K.return===n)break e;U===K&&(U=null),K=K.return}U===K&&(U=null),K.sibling.return=K.return,K=K.sibling}}break;case 19:Vt(r,n),sn(n),u&4&&$f(n);break;case 21:break;default:Vt(r,n),sn(n)}}function sn(n){var r=n.flags;if(r&2){try{e:{for(var c=n.return;c!==null;){if(Sf(c)){var u=c;break e}c=c.return}throw Error(s(160))}switch(u.tag){case 5:var m=u.stateNode;u.flags&32&&(di(m,""),u.flags&=-33);var g=Nf(n);nc(n,g,m);break;case 3:case 4:var x=u.stateNode.containerInfo,b=Nf(n);tc(n,b,x);break;default:throw Error(s(161))}}catch(C){Ue(n,n.return,C)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function Qy(n,r,c){te=n,Tf(n)}function Tf(n,r,c){for(var u=(n.mode&1)!==0;te!==null;){var m=te,g=m.child;if(m.tag===22&&u){var x=m.memoizedState!==null||ro;if(!x){var b=m.alternate,C=b!==null&&b.memoizedState!==null||ut;b=ro;var L=ut;if(ro=x,(ut=C)&&!L)for(te=m;te!==null;)x=te,C=x.child,x.tag===22&&x.memoizedState!==null?If(m):C!==null?(C.return=x,te=C):If(m);for(;g!==null;)te=g,Tf(g),g=g.sibling;te=m,ro=b,ut=L}Ef(n)}else(m.subtreeFlags&8772)!==0&&g!==null?(g.return=m,te=g):Ef(n)}}function Ef(n){for(;te!==null;){var r=te;if((r.flags&8772)!==0){var c=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:ut||oo(5,r);break;case 1:var u=r.stateNode;if(r.flags&4&&!ut)if(c===null)u.componentDidMount();else{var m=r.elementType===r.type?c.memoizedProps:Ht(r.type,c.memoizedProps);u.componentDidUpdate(m,c.memoizedState,u.__reactInternalSnapshotBeforeUpdate)}var g=r.updateQueue;g!==null&&Eh(r,g,u);break;case 3:var x=r.updateQueue;if(x!==null){if(c=null,r.child!==null)switch(r.child.tag){case 5:c=r.child.stateNode;break;case 1:c=r.child.stateNode}Eh(r,x,c)}break;case 5:var b=r.stateNode;if(c===null&&r.flags&4){c=b;var C=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":C.autoFocus&&c.focus();break;case"img":C.src&&(c.src=C.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var L=r.alternate;if(L!==null){var U=L.memoizedState;if(U!==null){var K=U.dehydrated;K!==null&&xi(K)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}ut||r.flags&512&&ec(r)}catch(B){Ue(r,r.return,B)}}if(r===n){te=null;break}if(c=r.sibling,c!==null){c.return=r.return,te=c;break}te=r.return}}function Af(n){for(;te!==null;){var r=te;if(r===n){te=null;break}var c=r.sibling;if(c!==null){c.return=r.return,te=c;break}te=r.return}}function If(n){for(;te!==null;){var r=te;try{switch(r.tag){case 0:case 11:case 15:var c=r.return;try{oo(4,r)}catch(C){Ue(r,c,C)}break;case 1:var u=r.stateNode;if(typeof u.componentDidMount=="function"){var m=r.return;try{u.componentDidMount()}catch(C){Ue(r,m,C)}}var g=r.return;try{ec(r)}catch(C){Ue(r,g,C)}break;case 5:var x=r.return;try{ec(r)}catch(C){Ue(r,x,C)}}}catch(C){Ue(r,r.return,C)}if(r===n){te=null;break}var b=r.sibling;if(b!==null){b.return=r.return,te=b;break}te=r.return}}var Yy=Math.ceil,ao=D.ReactCurrentDispatcher,sc=D.ReactCurrentOwner,Lt=D.ReactCurrentBatchConfig,Ne=0,tt=null,qe=null,rt=0,Tt=0,Fs=On(0),Xe=0,Hi=null,os=0,lo=0,ic=0,Ki=null,yt=null,rc=0,Us=1/0,wn=null,co=!1,oc=null,Fn=null,uo=!1,Un=null,ho=0,Vi=0,ac=null,fo=-1,mo=0;function pt(){return(Ne&6)!==0?We():fo!==-1?fo:fo=We()}function Wn(n){return(n.mode&1)===0?1:(Ne&2)!==0&&rt!==0?rt&-rt:My.transition!==null?(mo===0&&(mo=Su()),mo):(n=Ce,n!==0||(n=window.event,n=n===void 0?16:Ru(n.type)),n)}function Gt(n,r,c,u){if(50<Vi)throw Vi=0,ac=null,Error(s(185));gi(n,c,u),((Ne&2)===0||n!==tt)&&(n===tt&&((Ne&2)===0&&(lo|=c),Xe===4&&Hn(n,rt)),wt(n,u),c===1&&Ne===0&&(r.mode&1)===0&&(Us=We()+500,Fr&&_n()))}function wt(n,r){var c=n.callbackNode;Mk(n,r);var u=jr(n,n===tt?rt:0);if(u===0)c!==null&&wu(c),n.callbackNode=null,n.callbackPriority=0;else if(r=u&-u,n.callbackPriority!==r){if(c!=null&&wu(c),r===1)n.tag===0?Ry(Mf.bind(null,n)):vh(Mf.bind(null,n)),Ty(function(){(Ne&6)===0&&_n()}),c=null;else{switch(Nu(u)){case 1:c=Ba;break;case 4:c=xu;break;case 16:c=kr;break;case 536870912:c=ju;break;default:c=kr}c=Ff(c,Rf.bind(null,n))}n.callbackPriority=r,n.callbackNode=c}}function Rf(n,r){if(fo=-1,mo=0,(Ne&6)!==0)throw Error(s(327));var c=n.callbackNode;if(Ws()&&n.callbackNode!==c)return null;var u=jr(n,n===tt?rt:0);if(u===0)return null;if((u&30)!==0||(u&n.expiredLanes)!==0||r)r=po(n,u);else{r=u;var m=Ne;Ne|=2;var g=Of();(tt!==n||rt!==r)&&(wn=null,Us=We()+500,ls(n,r));do try{Zy();break}catch(b){Lf(n,b)}while(!0);bl(),ao.current=g,Ne=m,qe!==null?r=0:(tt=null,rt=0,r=Xe)}if(r!==0){if(r===2&&(m=Fa(n),m!==0&&(u=m,r=lc(n,m))),r===1)throw c=Hi,ls(n,0),Hn(n,u),wt(n,We()),c;if(r===6)Hn(n,u);else{if(m=n.current.alternate,(u&30)===0&&!Jy(m)&&(r=po(n,u),r===2&&(g=Fa(n),g!==0&&(u=g,r=lc(n,g))),r===1))throw c=Hi,ls(n,0),Hn(n,u),wt(n,We()),c;switch(n.finishedWork=m,n.finishedLanes=u,r){case 0:case 1:throw Error(s(345));case 2:cs(n,yt,wn);break;case 3:if(Hn(n,u),(u&130023424)===u&&(r=rc+500-We(),10<r)){if(jr(n,0)!==0)break;if(m=n.suspendedLanes,(m&u)!==u){pt(),n.pingedLanes|=n.suspendedLanes&m;break}n.timeoutHandle=ml(cs.bind(null,n,yt,wn),r);break}cs(n,yt,wn);break;case 4:if(Hn(n,u),(u&4194240)===u)break;for(r=n.eventTimes,m=-1;0<u;){var x=31-Ft(u);g=1<<x,x=r[x],x>m&&(m=x),u&=~g}if(u=m,u=We()-u,u=(120>u?120:480>u?480:1080>u?1080:1920>u?1920:3e3>u?3e3:4320>u?4320:1960*Yy(u/1960))-u,10<u){n.timeoutHandle=ml(cs.bind(null,n,yt,wn),u);break}cs(n,yt,wn);break;case 5:cs(n,yt,wn);break;default:throw Error(s(329))}}}return wt(n,We()),n.callbackNode===c?Rf.bind(null,n):null}function lc(n,r){var c=Ki;return n.current.memoizedState.isDehydrated&&(ls(n,r).flags|=256),n=po(n,r),n!==2&&(r=yt,yt=c,r!==null&&cc(r)),n}function cc(n){yt===null?yt=n:yt.push.apply(yt,n)}function Jy(n){for(var r=n;;){if(r.flags&16384){var c=r.updateQueue;if(c!==null&&(c=c.stores,c!==null))for(var u=0;u<c.length;u++){var m=c[u],g=m.getSnapshot;m=m.value;try{if(!Ut(g(),m))return!1}catch{return!1}}}if(c=r.child,r.subtreeFlags&16384&&c!==null)c.return=r,r=c;else{if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Hn(n,r){for(r&=~ic,r&=~lo,n.suspendedLanes|=r,n.pingedLanes&=~r,n=n.expirationTimes;0<r;){var c=31-Ft(r),u=1<<c;n[c]=-1,r&=~u}}function Mf(n){if((Ne&6)!==0)throw Error(s(327));Ws();var r=jr(n,0);if((r&1)===0)return wt(n,We()),null;var c=po(n,r);if(n.tag!==0&&c===2){var u=Fa(n);u!==0&&(r=u,c=lc(n,u))}if(c===1)throw c=Hi,ls(n,0),Hn(n,r),wt(n,We()),c;if(c===6)throw Error(s(345));return n.finishedWork=n.current.alternate,n.finishedLanes=r,cs(n,yt,wn),wt(n,We()),null}function dc(n,r){var c=Ne;Ne|=1;try{return n(r)}finally{Ne=c,Ne===0&&(Us=We()+500,Fr&&_n())}}function as(n){Un!==null&&Un.tag===0&&(Ne&6)===0&&Ws();var r=Ne;Ne|=1;var c=Lt.transition,u=Ce;try{if(Lt.transition=null,Ce=1,n)return n()}finally{Ce=u,Lt.transition=c,Ne=r,(Ne&6)===0&&_n()}}function uc(){Tt=Fs.current,Le(Fs)}function ls(n,r){n.finishedWork=null,n.finishedLanes=0;var c=n.timeoutHandle;if(c!==-1&&(n.timeoutHandle=-1,Cy(c)),qe!==null)for(c=qe.return;c!==null;){var u=c;switch(wl(u),u.tag){case 1:u=u.type.childContextTypes,u!=null&&zr();break;case 3:Ds(),Le(gt),Le(lt),Ml();break;case 5:Il(u);break;case 4:Ds();break;case 13:Le(_e);break;case 19:Le(_e);break;case 10:$l(u.type._context);break;case 22:case 23:uc()}c=c.return}if(tt=n,qe=n=Kn(n.current,null),rt=Tt=r,Xe=0,Hi=null,ic=lo=os=0,yt=Ki=null,ss!==null){for(r=0;r<ss.length;r++)if(c=ss[r],u=c.interleaved,u!==null){c.interleaved=null;var m=u.next,g=c.pending;if(g!==null){var x=g.next;g.next=m,u.next=x}c.pending=u}ss=null}return n}function Lf(n,r){do{var c=qe;try{if(bl(),Jr.current=to,Xr){for(var u=De.memoizedState;u!==null;){var m=u.queue;m!==null&&(m.pending=null),u=u.next}Xr=!1}if(rs=0,et=Je=De=null,Di=!1,zi=0,sc.current=null,c===null||c.return===null){Xe=1,Hi=r,qe=null;break}e:{var g=n,x=c.return,b=c,C=r;if(r=rt,b.flags|=32768,C!==null&&typeof C=="object"&&typeof C.then=="function"){var L=C,U=b,K=U.tag;if((U.mode&1)===0&&(K===0||K===11||K===15)){var B=U.alternate;B?(U.updateQueue=B.updateQueue,U.memoizedState=B.memoizedState,U.lanes=B.lanes):(U.updateQueue=null,U.memoizedState=null)}var ee=rf(x);if(ee!==null){ee.flags&=-257,of(ee,x,b,g,r),ee.mode&1&&sf(g,L,r),r=ee,C=L;var se=r.updateQueue;if(se===null){var re=new Set;re.add(C),r.updateQueue=re}else se.add(C);break e}else{if((r&1)===0){sf(g,L,r),hc();break e}C=Error(s(426))}}else if(Pe&&b.mode&1){var He=rf(x);if(He!==null){(He.flags&65536)===0&&(He.flags|=256),of(He,x,b,g,r),Sl(zs(C,b));break e}}g=C=zs(C,b),Xe!==4&&(Xe=2),Ki===null?Ki=[g]:Ki.push(g),g=x;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var A=tf(g,C,r);Th(g,A);break e;case 1:b=C;var E=g.type,R=g.stateNode;if((g.flags&128)===0&&(typeof E.getDerivedStateFromError=="function"||R!==null&&typeof R.componentDidCatch=="function"&&(Fn===null||!Fn.has(R)))){g.flags|=65536,r&=-r,g.lanes|=r;var Y=nf(g,b,r);Th(g,Y);break e}}g=g.return}while(g!==null)}_f(c)}catch(ae){r=ae,qe===c&&c!==null&&(qe=c=c.return);continue}break}while(!0)}function Of(){var n=ao.current;return ao.current=to,n===null?to:n}function hc(){(Xe===0||Xe===3||Xe===2)&&(Xe=4),tt===null||(os&268435455)===0&&(lo&268435455)===0||Hn(tt,rt)}function po(n,r){var c=Ne;Ne|=2;var u=Of();(tt!==n||rt!==r)&&(wn=null,ls(n,r));do try{Xy();break}catch(m){Lf(n,m)}while(!0);if(bl(),Ne=c,ao.current=u,qe!==null)throw Error(s(261));return tt=null,rt=0,Xe}function Xy(){for(;qe!==null;)Pf(qe)}function Zy(){for(;qe!==null&&!Nk();)Pf(qe)}function Pf(n){var r=Bf(n.alternate,n,Tt);n.memoizedProps=n.pendingProps,r===null?_f(n):qe=r,sc.current=null}function _f(n){var r=n;do{var c=r.alternate;if(n=r.return,(r.flags&32768)===0){if(c=Ky(c,r,Tt),c!==null){qe=c;return}}else{if(c=Vy(c,r),c!==null){c.flags&=32767,qe=c;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{Xe=6,qe=null;return}}if(r=r.sibling,r!==null){qe=r;return}qe=r=n}while(r!==null);Xe===0&&(Xe=5)}function cs(n,r,c){var u=Ce,m=Lt.transition;try{Lt.transition=null,Ce=1,ew(n,r,c,u)}finally{Lt.transition=m,Ce=u}return null}function ew(n,r,c,u){do Ws();while(Un!==null);if((Ne&6)!==0)throw Error(s(327));c=n.finishedWork;var m=n.finishedLanes;if(c===null)return null;if(n.finishedWork=null,n.finishedLanes=0,c===n.current)throw Error(s(177));n.callbackNode=null,n.callbackPriority=0;var g=c.lanes|c.childLanes;if(Lk(n,g),n===tt&&(qe=tt=null,rt=0),(c.subtreeFlags&2064)===0&&(c.flags&2064)===0||uo||(uo=!0,Ff(kr,function(){return Ws(),null})),g=(c.flags&15990)!==0,(c.subtreeFlags&15990)!==0||g){g=Lt.transition,Lt.transition=null;var x=Ce;Ce=1;var b=Ne;Ne|=4,sc.current=null,qy(n,c),Cf(c,n),wy(hl),br=!!ul,hl=ul=null,n.current=c,Qy(c),bk(),Ne=b,Ce=x,Lt.transition=g}else n.current=c;if(uo&&(uo=!1,Un=n,ho=m),g=n.pendingLanes,g===0&&(Fn=null),Tk(c.stateNode),wt(n,We()),r!==null)for(u=n.onRecoverableError,c=0;c<r.length;c++)m=r[c],u(m.value,{componentStack:m.stack,digest:m.digest});if(co)throw co=!1,n=oc,oc=null,n;return(ho&1)!==0&&n.tag!==0&&Ws(),g=n.pendingLanes,(g&1)!==0?n===ac?Vi++:(Vi=0,ac=n):Vi=0,_n(),null}function Ws(){if(Un!==null){var n=Nu(ho),r=Lt.transition,c=Ce;try{if(Lt.transition=null,Ce=16>n?16:n,Un===null)var u=!1;else{if(n=Un,Un=null,ho=0,(Ne&6)!==0)throw Error(s(331));var m=Ne;for(Ne|=4,te=n.current;te!==null;){var g=te,x=g.child;if((te.flags&16)!==0){var b=g.deletions;if(b!==null){for(var C=0;C<b.length;C++){var L=b[C];for(te=L;te!==null;){var U=te;switch(U.tag){case 0:case 11:case 15:Wi(8,U,g)}var K=U.child;if(K!==null)K.return=U,te=K;else for(;te!==null;){U=te;var B=U.sibling,ee=U.return;if(jf(U),U===L){te=null;break}if(B!==null){B.return=ee,te=B;break}te=ee}}}var se=g.alternate;if(se!==null){var re=se.child;if(re!==null){se.child=null;do{var He=re.sibling;re.sibling=null,re=He}while(re!==null)}}te=g}}if((g.subtreeFlags&2064)!==0&&x!==null)x.return=g,te=x;else e:for(;te!==null;){if(g=te,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:Wi(9,g,g.return)}var A=g.sibling;if(A!==null){A.return=g.return,te=A;break e}te=g.return}}var E=n.current;for(te=E;te!==null;){x=te;var R=x.child;if((x.subtreeFlags&2064)!==0&&R!==null)R.return=x,te=R;else e:for(x=E;te!==null;){if(b=te,(b.flags&2048)!==0)try{switch(b.tag){case 0:case 11:case 15:oo(9,b)}}catch(ae){Ue(b,b.return,ae)}if(b===x){te=null;break e}var Y=b.sibling;if(Y!==null){Y.return=b.return,te=Y;break e}te=b.return}}if(Ne=m,_n(),Zt&&typeof Zt.onPostCommitFiberRoot=="function")try{Zt.onPostCommitFiberRoot(yr,n)}catch{}u=!0}return u}finally{Ce=c,Lt.transition=r}}return!1}function Df(n,r,c){r=zs(c,r),r=tf(n,r,1),n=zn(n,r,1),r=pt(),n!==null&&(gi(n,1,r),wt(n,r))}function Ue(n,r,c){if(n.tag===3)Df(n,n,c);else for(;r!==null;){if(r.tag===3){Df(r,n,c);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Fn===null||!Fn.has(u))){n=zs(c,n),n=nf(r,n,1),r=zn(r,n,1),n=pt(),r!==null&&(gi(r,1,n),wt(r,n));break}}r=r.return}}function tw(n,r,c){var u=n.pingCache;u!==null&&u.delete(r),r=pt(),n.pingedLanes|=n.suspendedLanes&c,tt===n&&(rt&c)===c&&(Xe===4||Xe===3&&(rt&130023424)===rt&&500>We()-rc?ls(n,0):ic|=c),wt(n,r)}function zf(n,r){r===0&&((n.mode&1)===0?r=1:(r=xr,xr<<=1,(xr&130023424)===0&&(xr=4194304)));var c=pt();n=vn(n,r),n!==null&&(gi(n,r,c),wt(n,c))}function nw(n){var r=n.memoizedState,c=0;r!==null&&(c=r.retryLane),zf(n,c)}function sw(n,r){var c=0;switch(n.tag){case 13:var u=n.stateNode,m=n.memoizedState;m!==null&&(c=m.retryLane);break;case 19:u=n.stateNode;break;default:throw Error(s(314))}u!==null&&u.delete(r),zf(n,c)}var Bf;Bf=function(n,r,c){if(n!==null)if(n.memoizedProps!==r.pendingProps||gt.current)kt=!0;else{if((n.lanes&c)===0&&(r.flags&128)===0)return kt=!1,Hy(n,r,c);kt=(n.flags&131072)!==0}else kt=!1,Pe&&(r.flags&1048576)!==0&&kh(r,Wr,r.index);switch(r.lanes=0,r.tag){case 2:var u=r.type;io(n,r),n=r.pendingProps;var m=Is(r,lt.current);_s(r,c),m=Pl(null,r,u,n,m,c);var g=_l();return r.flags|=1,typeof m=="object"&&m!==null&&typeof m.render=="function"&&m.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,vt(u)?(g=!0,Br(r)):g=!1,r.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,El(r),m.updater=no,r.stateNode=m,m._reactInternals=r,Wl(r,u,n,c),r=Gl(null,r,u,!0,g,c)):(r.tag=0,Pe&&g&&yl(r),mt(null,r,m,c),r=r.child),r;case 16:u=r.elementType;e:{switch(io(n,r),n=r.pendingProps,m=u._init,u=m(u._payload),r.type=u,m=r.tag=rw(u),n=Ht(u,n),m){case 0:r=Vl(null,r,u,n,c);break e;case 1:r=hf(null,r,u,n,c);break e;case 11:r=af(null,r,u,n,c);break e;case 14:r=lf(null,r,u,Ht(u.type,n),c);break e}throw Error(s(306,u,""))}return r;case 0:return u=r.type,m=r.pendingProps,m=r.elementType===u?m:Ht(u,m),Vl(n,r,u,m,c);case 1:return u=r.type,m=r.pendingProps,m=r.elementType===u?m:Ht(u,m),hf(n,r,u,m,c);case 3:e:{if(ff(r),n===null)throw Error(s(387));u=r.pendingProps,g=r.memoizedState,m=g.element,Ch(n,r),Qr(r,u,null,c);var x=r.memoizedState;if(u=x.element,g.isDehydrated)if(g={element:u,isDehydrated:!1,cache:x.cache,pendingSuspenseBoundaries:x.pendingSuspenseBoundaries,transitions:x.transitions},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){m=zs(Error(s(423)),r),r=mf(n,r,u,c,m);break e}else if(u!==m){m=zs(Error(s(424)),r),r=mf(n,r,u,c,m);break e}else for(Ct=Ln(r.stateNode.containerInfo.firstChild),$t=r,Pe=!0,Wt=null,c=bh(r,null,u,c),r.child=c;c;)c.flags=c.flags&-3|4096,c=c.sibling;else{if(Ls(),u===m){r=yn(n,r,c);break e}mt(n,r,u,c)}r=r.child}return r;case 5:return Ah(r),n===null&&jl(r),u=r.type,m=r.pendingProps,g=n!==null?n.memoizedProps:null,x=m.children,fl(u,m)?x=null:g!==null&&fl(u,g)&&(r.flags|=32),uf(n,r),mt(n,r,x,c),r.child;case 6:return n===null&&jl(r),null;case 13:return pf(n,r,c);case 4:return Al(r,r.stateNode.containerInfo),u=r.pendingProps,n===null?r.child=Os(r,null,u,c):mt(n,r,u,c),r.child;case 11:return u=r.type,m=r.pendingProps,m=r.elementType===u?m:Ht(u,m),af(n,r,u,m,c);case 7:return mt(n,r,r.pendingProps,c),r.child;case 8:return mt(n,r,r.pendingProps.children,c),r.child;case 12:return mt(n,r,r.pendingProps.children,c),r.child;case 10:e:{if(u=r.type._context,m=r.pendingProps,g=r.memoizedProps,x=m.value,Re(Vr,u._currentValue),u._currentValue=x,g!==null)if(Ut(g.value,x)){if(g.children===m.children&&!gt.current){r=yn(n,r,c);break e}}else for(g=r.child,g!==null&&(g.return=r);g!==null;){var b=g.dependencies;if(b!==null){x=g.child;for(var C=b.firstContext;C!==null;){if(C.context===u){if(g.tag===1){C=kn(-1,c&-c),C.tag=2;var L=g.updateQueue;if(L!==null){L=L.shared;var U=L.pending;U===null?C.next=C:(C.next=U.next,U.next=C),L.pending=C}}g.lanes|=c,C=g.alternate,C!==null&&(C.lanes|=c),Cl(g.return,c,r),b.lanes|=c;break}C=C.next}}else if(g.tag===10)x=g.type===r.type?null:g.child;else if(g.tag===18){if(x=g.return,x===null)throw Error(s(341));x.lanes|=c,b=x.alternate,b!==null&&(b.lanes|=c),Cl(x,c,r),x=g.sibling}else x=g.child;if(x!==null)x.return=g;else for(x=g;x!==null;){if(x===r){x=null;break}if(g=x.sibling,g!==null){g.return=x.return,x=g;break}x=x.return}g=x}mt(n,r,m.children,c),r=r.child}return r;case 9:return m=r.type,u=r.pendingProps.children,_s(r,c),m=Rt(m),u=u(m),r.flags|=1,mt(n,r,u,c),r.child;case 14:return u=r.type,m=Ht(u,r.pendingProps),m=Ht(u.type,m),lf(n,r,u,m,c);case 15:return cf(n,r,r.type,r.pendingProps,c);case 17:return u=r.type,m=r.pendingProps,m=r.elementType===u?m:Ht(u,m),io(n,r),r.tag=1,vt(u)?(n=!0,Br(r)):n=!1,_s(r,c),Zh(r,u,m),Wl(r,u,m,c),Gl(null,r,u,!0,n,c);case 19:return vf(n,r,c);case 22:return df(n,r,c)}throw Error(s(156,r.tag))};function Ff(n,r){return yu(n,r)}function iw(n,r,c,u){this.tag=n,this.key=c,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ot(n,r,c,u){return new iw(n,r,c,u)}function fc(n){return n=n.prototype,!(!n||!n.isReactComponent)}function rw(n){if(typeof n=="function")return fc(n)?1:0;if(n!=null){if(n=n.$$typeof,n===Te)return 11;if(n===F)return 14}return 2}function Kn(n,r){var c=n.alternate;return c===null?(c=Ot(n.tag,r,n.key,n.mode),c.elementType=n.elementType,c.type=n.type,c.stateNode=n.stateNode,c.alternate=n,n.alternate=c):(c.pendingProps=r,c.type=n.type,c.flags=0,c.subtreeFlags=0,c.deletions=null),c.flags=n.flags&14680064,c.childLanes=n.childLanes,c.lanes=n.lanes,c.child=n.child,c.memoizedProps=n.memoizedProps,c.memoizedState=n.memoizedState,c.updateQueue=n.updateQueue,r=n.dependencies,c.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},c.sibling=n.sibling,c.index=n.index,c.ref=n.ref,c}function go(n,r,c,u,m,g){var x=2;if(u=n,typeof n=="function")fc(n)&&(x=1);else if(typeof n=="string")x=5;else e:switch(n){case G:return ds(c.children,m,g,r);case oe:x=8,m|=8;break;case Q:return n=Ot(12,c,r,m|2),n.elementType=Q,n.lanes=g,n;case ne:return n=Ot(13,c,r,m),n.elementType=ne,n.lanes=g,n;case ce:return n=Ot(19,c,r,m),n.elementType=ce,n.lanes=g,n;case ie:return vo(c,m,g,r);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case ke:x=10;break e;case Oe:x=9;break e;case Te:x=11;break e;case F:x=14;break e;case J:x=16,u=null;break e}throw Error(s(130,n==null?n:typeof n,""))}return r=Ot(x,c,r,m),r.elementType=n,r.type=u,r.lanes=g,r}function ds(n,r,c,u){return n=Ot(7,n,u,r),n.lanes=c,n}function vo(n,r,c,u){return n=Ot(22,n,u,r),n.elementType=ie,n.lanes=c,n.stateNode={isHidden:!1},n}function mc(n,r,c){return n=Ot(6,n,null,r),n.lanes=c,n}function pc(n,r,c){return r=Ot(4,n.children!==null?n.children:[],n.key,r),r.lanes=c,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}function ow(n,r,c,u,m){this.tag=r,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ua(0),this.expirationTimes=Ua(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ua(0),this.identifierPrefix=u,this.onRecoverableError=m,this.mutableSourceEagerHydrationData=null}function gc(n,r,c,u,m,g,x,b,C){return n=new ow(n,r,c,b,C),r===1?(r=1,g===!0&&(r|=8)):r=0,g=Ot(3,null,null,r),n.current=g,g.stateNode=n,g.memoizedState={element:u,isDehydrated:c,cache:null,transitions:null,pendingSuspenseBoundaries:null},El(g),n}function aw(n,r,c){var u=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:H,key:u==null?null:""+u,children:n,containerInfo:r,implementation:c}}function Uf(n){if(!n)return Pn;n=n._reactInternals;e:{if(Xn(n)!==n||n.tag!==1)throw Error(s(170));var r=n;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(vt(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(s(171))}if(n.tag===1){var c=n.type;if(vt(c))return ph(n,c,r)}return r}function Wf(n,r,c,u,m,g,x,b,C){return n=gc(c,u,!0,n,m,g,x,b,C),n.context=Uf(null),c=n.current,u=pt(),m=Wn(c),g=kn(u,m),g.callback=r??null,zn(c,g,m),n.current.lanes=m,gi(n,m,u),wt(n,u),n}function ko(n,r,c,u){var m=r.current,g=pt(),x=Wn(m);return c=Uf(c),r.context===null?r.context=c:r.pendingContext=c,r=kn(g,x),r.payload={element:n},u=u===void 0?null:u,u!==null&&(r.callback=u),n=zn(m,r,x),n!==null&&(Gt(n,m,x,g),qr(n,m,x)),x}function yo(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function Hf(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var c=n.retryLane;n.retryLane=c!==0&&c<r?c:r}}function vc(n,r){Hf(n,r),(n=n.alternate)&&Hf(n,r)}function lw(){return null}var Kf=typeof reportError=="function"?reportError:function(n){console.error(n)};function kc(n){this._internalRoot=n}wo.prototype.render=kc.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(s(409));ko(n,r,null,null)},wo.prototype.unmount=kc.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;as(function(){ko(null,n,null,null)}),r[fn]=null}};function wo(n){this._internalRoot=n}wo.prototype.unstable_scheduleHydration=function(n){if(n){var r=Cu();n={blockedOn:null,target:n,priority:r};for(var c=0;c<In.length&&r!==0&&r<In[c].priority;c++);In.splice(c,0,n),c===0&&Au(n)}};function yc(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function xo(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function Vf(){}function cw(n,r,c,u,m){if(m){if(typeof u=="function"){var g=u;u=function(){var L=yo(x);g.call(L)}}var x=Wf(r,u,n,0,null,!1,!1,"",Vf);return n._reactRootContainer=x,n[fn]=x.current,Ai(n.nodeType===8?n.parentNode:n),as(),x}for(;m=n.lastChild;)n.removeChild(m);if(typeof u=="function"){var b=u;u=function(){var L=yo(C);b.call(L)}}var C=gc(n,0,!1,null,null,!1,!1,"",Vf);return n._reactRootContainer=C,n[fn]=C.current,Ai(n.nodeType===8?n.parentNode:n),as(function(){ko(r,C,c,u)}),C}function jo(n,r,c,u,m){var g=c._reactRootContainer;if(g){var x=g;if(typeof m=="function"){var b=m;m=function(){var C=yo(x);b.call(C)}}ko(r,x,n,m)}else x=cw(c,r,n,m,u);return yo(x)}bu=function(n){switch(n.tag){case 3:var r=n.stateNode;if(r.current.memoizedState.isDehydrated){var c=pi(r.pendingLanes);c!==0&&(Wa(r,c|1),wt(r,We()),(Ne&6)===0&&(Us=We()+500,_n()))}break;case 13:as(function(){var u=vn(n,1);if(u!==null){var m=pt();Gt(u,n,1,m)}}),vc(n,1)}},Ha=function(n){if(n.tag===13){var r=vn(n,134217728);if(r!==null){var c=pt();Gt(r,n,134217728,c)}vc(n,134217728)}},$u=function(n){if(n.tag===13){var r=Wn(n),c=vn(n,r);if(c!==null){var u=pt();Gt(c,n,r,u)}vc(n,r)}},Cu=function(){return Ce},Tu=function(n,r){var c=Ce;try{return Ce=n,r()}finally{Ce=c}},Pa=function(n,r,c){switch(r){case"input":if(Ta(n,c),r=c.name,c.type==="radio"&&r!=null){for(c=n;c.parentNode;)c=c.parentNode;for(c=c.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<c.length;r++){var u=c[r];if(u!==n&&u.form===n.form){var m=Dr(u);if(!m)throw Error(s(90));mr(u),Ta(u,m)}}}break;case"textarea":su(n,c);break;case"select":r=c.value,r!=null&&ys(n,!!c.multiple,r,!1)}},hu=dc,fu=as;var dw={usingClientEntryPoint:!1,Events:[Mi,Es,Dr,du,uu,dc]},Gi={findFiberByHostInstance:Zn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},uw={bundleType:Gi.bundleType,version:Gi.version,rendererPackageName:Gi.rendererPackageName,rendererConfig:Gi.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:D.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=vu(n),n===null?null:n.stateNode},findFiberByHostInstance:Gi.findFiberByHostInstance||lw,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var So=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!So.isDisabled&&So.supportsFiber)try{yr=So.inject(uw),Zt=So}catch{}}return xt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=dw,xt.createPortal=function(n,r){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!yc(r))throw Error(s(200));return aw(n,r,null,c)},xt.createRoot=function(n,r){if(!yc(n))throw Error(s(299));var c=!1,u="",m=Kf;return r!=null&&(r.unstable_strictMode===!0&&(c=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onRecoverableError!==void 0&&(m=r.onRecoverableError)),r=gc(n,1,!1,null,null,c,!1,u,m),n[fn]=r.current,Ai(n.nodeType===8?n.parentNode:n),new kc(r)},xt.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var r=n._reactInternals;if(r===void 0)throw typeof n.render=="function"?Error(s(188)):(n=Object.keys(n).join(","),Error(s(268,n)));return n=vu(r),n=n===null?null:n.stateNode,n},xt.flushSync=function(n){return as(n)},xt.hydrate=function(n,r,c){if(!xo(r))throw Error(s(200));return jo(null,n,r,!0,c)},xt.hydrateRoot=function(n,r,c){if(!yc(n))throw Error(s(405));var u=c!=null&&c.hydratedSources||null,m=!1,g="",x=Kf;if(c!=null&&(c.unstable_strictMode===!0&&(m=!0),c.identifierPrefix!==void 0&&(g=c.identifierPrefix),c.onRecoverableError!==void 0&&(x=c.onRecoverableError)),r=Wf(r,null,n,1,c??null,m,!1,g,x),n[fn]=r.current,Ai(n),u)for(n=0;n<u.length;n++)c=u[n],m=c._getVersion,m=m(c._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[c,m]:r.mutableSourceEagerHydrationData.push(c,m);return new wo(r)},xt.render=function(n,r,c){if(!xo(r))throw Error(s(200));return jo(null,n,r,!1,c)},xt.unmountComponentAtNode=function(n){if(!xo(n))throw Error(s(40));return n._reactRootContainer?(as(function(){jo(null,null,n,!1,function(){n._reactRootContainer=null,n[fn]=null})}),!0):!1},xt.unstable_batchedUpdates=dc,xt.unstable_renderSubtreeIntoContainer=function(n,r,c,u){if(!xo(c))throw Error(s(200));if(n==null||n._reactInternals===void 0)throw Error(s(38));return jo(n,r,c,!1,u)},xt.version="18.3.1-next-f1338f8080-20240426",xt}var em;function _p(){if(em)return jc.exports;em=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),jc.exports=ww(),jc.exports}var tm;function xw(){if(tm)return No;tm=1;var e=_p();return No.createRoot=e.createRoot,No.hydrateRoot=e.hydrateRoot,No}var jw=xw(),y=wd();const Qn="teamtrail",Z={slug:Qn,npm:"teamtrail",name:"Teamtrail",category:"The trail map for AI coding agents",tagline:"You pick the destination. Your agents walk the trail.",assistant:{name:"Scout"},labelPrefix:Qn,dataDir:`.${Qn}`,apiPrefix:`/__${Qn}`,dataDirEnv:`${Qn.toUpperCase()}_DIR`,noRegisterEnv:`${Qn.toUpperCase()}_NO_REGISTER`,tokenEnv:`${Qn.toUpperCase()}_TOKEN`},ea=`${Qn}.prefs`,ta=e=>`${Z.labelPrefix}:${e}`,xd=ta("map"),jd=ta("hitl"),Sw=e=>e==="task"||e==="execute",Sd=ta("plan-only");function Dp(e){return/^[A-Za-z0-9_@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}const Nw=e=>e.map(Dp).join(" "),bw=/^\d+\.\d+\.\d+(-[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function $w(e){return bw.test(e)?`${Z.npm}@${e}`:Z.npm}function zp(e,t){return Nw(["npx","-y",$w(e),...t])}const _o=["research","prototype","junction","task","execute"],na=[..._o,"review"],gs="plan+execute",Cw=e=>e.filter(t=>!t.archived),Tw=["verifying","rework","blocked"],Nd=["off","checks","checks+review","checks+review+human"],Bp=e=>Nd.find(t=>t===e);function cr(e){return e.type==="junction"||e.type==="prototype"?"hitl":e.type==="research"?"afk":e.hitl?"hitl":"afk"}const Ew=["task","execute"];function Fp(e,t,s=gs){return e.state==="closed"?e.closeReason==="not_planned"?"out-of-scope":"decided":e.status==="verifying"?"verifying":e.status==="blocked"?"held":e.assignee?"claimed":e.status==="rework"?"rework":s==="plan-only"&&e.type==="execute"?"parked":e.blockedBy.some(a=>{var l;return((l=t.get(a))==null?void 0:l.state)==="open"})?"blocked":"frontier"}function ti(e,t=gs){const s=new Map(e.map(o=>[o.id,o]));return new Map(e.map(o=>[o.id,Fp(o,s,t)]))}const Ve=200,Qe=56;function nm(e,t="LR",s=gs){var Te;const o=t==="LR"?330:124,a=t==="LR"?112:262,l=ti(e,s),d=new Map(e.map(ne=>[ne.id,ne])),h=new Map,f=new Set,p=ne=>{if(h.has(ne))return h.get(ne);if(f.has(ne))return 0;f.add(ne);const ce=d.get(ne),F=ce&&ce.blockedBy.length?1+Math.max(...ce.blockedBy.filter(J=>d.has(J)).map(p),-1):0;return f.delete(ne),h.set(ne,F),F},k=e.filter(ne=>l.get(ne.id)!=="out-of-scope"),v=e.filter(ne=>l.get(ne.id)==="out-of-scope"),w=[];for(const ne of k)(w[Te=p(ne.id)]??(w[Te]=[])).push(ne);const j=[],N=new Map;let S=0;w.forEach(ne=>{ne&&(ne.sort((ce,F)=>{const J=ie=>{const W=ie.blockedBy.map(X=>N.get(X)).filter(X=>X!==void 0);return W.length?W.reduce((X,z)=>X+z,0)/W.length:ie.createdAt/1e12};return J(ce)-J(F)||ce.createdAt-F.createdAt}),S=Math.max(S,ne.length),ne.forEach((ce,F)=>N.set(ce.id,F)))}),w.forEach((ne,ce)=>{if(!ne)return;const F=(S-ne.length)*a/2;ne.forEach((J,ie)=>{const W=ce*o,X=F+ie*a;j.push({ticket:J,state:l.get(J.id),layer:ce,x:t==="LR"?W:X,y:t==="LR"?X:W})})});const $=Math.max(w.length,1)*o-(o-(t==="LR"?Ve:Qe)),_=Math.max(S,1)*a-(a-(t==="LR"?Qe:Ve)),O=t==="LR"?$:_,D=t==="LR"?_:$,q=D+54,H=Math.max(1,Math.floor((O+24)/(Ve+24)));v.forEach((ne,ce)=>{j.push({ticket:ne,state:"out-of-scope",layer:-1,x:ce%H*(Ve+24),y:q+Math.floor(ce/H)*(Qe+16)})});const G=[],oe=new Map(j.map(ne=>[ne.ticket.id,ne]));for(const ne of j)for(const ce of ne.ticket.blockedBy){const F=oe.get(ce);F&&G.push({from:F,to:ne})}const Q=Math.ceil(v.length/H),ke=Math.max(O,Math.min(v.length,H)*(Ve+24)-24),Oe=v.length?q+Q*(Qe+16)-16:D;return{direction:t,nodes:j,edges:G,width:ke,graphH:D,quarantineY:q,height:Oe,quarantineH:Q*(Qe+16)+24}}const Do=["fast","balanced","strongest"],sm="balanced",Aw=[["*-mini","fast"],["*-mini-*","fast"],["*-nano","fast"],["*-nano-*","fast"],["*claude-haiku-*","fast"],["*claude-3*-haiku*","fast"],["*claude-opus-*","strongest"],["*claude-3*-opus*","strongest"],["*claude-fable-*","strongest"],["*claude-sonnet-*","balanced"],["*claude-3*-sonnet*","balanced"],["gpt-5*","strongest"],["o1","strongest"],["o1-*","strongest"],["o3","strongest"],["o3-*","strongest"],["o4-*","strongest"],["gpt-4*","balanced"]],Up=e=>Do.includes(e),bd={research:"fast",task:"balanced",execute:"balanced",junction:"strongest",prototype:"strongest",review:"strongest"};function Iw(e,t){var a,l;const s=(l=(a=t.modelMatching)==null?void 0:a.tiers)==null?void 0:l[e.type],o=bd[e.type];return t.settingsUnconfirmed&&s?Do.indexOf(s)>=Do.indexOf(o)?s:o:s??o}function im(e){return Object.fromEntries(na.map(t=>[t,Iw({type:t},e)]))}const Rw=e=>e!=="__proto__"&&e!=="constructor"&&e!=="prototype",Mw=64;function Lw(e,t){const s=[];for(let o=0;o<e.length;o++){const a=e[o];if(a!=="*"&&!(a==="?"&&t))s.push({kind:"char",c:a});else if(a==="?")s.push({kind:"one"});else if(!t||e[o+1]!=="*")s.push({kind:t?"star":"deep"});else{const l=e[o+2]==="/";o+=l?2:1,s.push({kind:l?"dirs":"deep"})}}return Ow(s)}function Ow(e){const t=[];for(const s of e){const o=t.at(-1);(o==null?void 0:o.kind)==="dirs"&&s.kind==="dirs"||(o==null?void 0:o.kind)==="deep"&&(s.kind==="deep"||s.kind==="dirs")||((o==null?void 0:o.kind)==="dirs"&&s.kind==="deep"?t[t.length-1]=s:t.push(s))}return t}function Pw({t:e,c:t,inText:s,next:o,cur:a,j:l}){switch(e.kind){case"char":return s&&t===e.c?o[l+1]:0;case"one":return s&&t!=="/"?o[l+1]:0;case"star":return o[l]||(s&&t!=="/"?a[l+1]:0);case"deep":return o[l]||(s?a[l+1]:0);case"dirs":return 0;default:return e}}function _w(e,t,s){const o=s.length,a=new Uint8Array(o+1);let l=0;for(let d=o;d>=0;d--){const h=d<o,f=h?s[d]:"";if(e.kind!=="dirs"){a[d]=Pw({t:e,c:f,inText:h,next:t,cur:a,j:d});continue}f==="/"&&t[d+1]&&(l=1),a[d]=t[d]||l}return a}function Wp(e,t,s){const o=Lw(e,s.segments);if(o.filter(l=>l.kind!=="char").length>Mw)return!1;let a=new Uint8Array(t.length+1);a[t.length]=1;for(let l=o.length-1;l>=0;l--)a=_w(o[l],a,t);return a[0]===1}function rm(e,t){return Wp(e.trim().toLowerCase(),t.trim().toLowerCase(),{segments:!1})}function Dw(e,t={}){const s=e==null?void 0:e.trim();if(!s)return{tier:sm,source:"unknown",reason:"no model reported, so it counts as balanced"};const a=Object.entries(t).find(([d])=>d.trim().toLowerCase()===s.toLowerCase())??Object.entries(t).find(([d])=>rm(d,s));if(a)return{tier:a[1],model:s,source:"project",reason:`${s} is ${a[1]} in models.json`};const l=Aw.find(([d])=>rm(d,s));return l?{tier:l[1],model:s,source:"built-in",reason:`${s} is a ${l[1]} model`}:{tier:sm,model:s,source:"unknown",reason:`${s} is not a known model, so it counts as balanced`}}const zw=["holding","challenged","invalidated","confirmed"],Bw=e=>zw.includes(e),Fw=Z.labelPrefix,Jc=" -->",Uw=7e4,Hp=e=>`<!-- ${Fw}:${e} `,Ww=e=>JSON.stringify(e).replace(/--/g,"-\\u002d"),Hw=(e,t)=>`${Hp(e)}${t}${Jc}`;function Kw(e,t){const s=e.trimEnd();if(!s.endsWith(Jc))return;const o=Hp(t),a=s.lastIndexOf(o);if(!(a===-1||s.length-a>Uw))return{before:s.slice(0,a),payload:s.slice(a+o.length,-Jc.length)}}const Vw=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/,Gw=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]+/g,qw=/\r\n|[\r\u0085\u2028\u2029]/g,Qw=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/g,Yw=e=>Vw.test(e),hs=e=>e.replace(Gw," ").trim(),Jw=e=>e.replace(qw,`
|
|
40
|
+
`+g.stack}return{value:n,source:r,stack:m,digest:null}}function Hl(n,r,c){return{value:n,source:null,stack:c??null,digest:r??null}}function Kl(n,r){try{console.error(r.value)}catch(c){setTimeout(function(){throw c})}}var Fy=typeof WeakMap=="function"?WeakMap:Map;function tf(n,r,c){c=kn(-1,c),c.tag=3,c.payload={element:null};var u=r.value;return c.callback=function(){co||(co=!0,oc=u),Kl(n,r)},c}function nf(n,r,c){c=kn(-1,c),c.tag=3;var u=n.type.getDerivedStateFromError;if(typeof u=="function"){var m=r.value;c.payload=function(){return u(m)},c.callback=function(){Kl(n,r)}}var g=n.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(c.callback=function(){Kl(n,r),typeof u!="function"&&(Fn===null?Fn=new Set([this]):Fn.add(this));var x=r.stack;this.componentDidCatch(r.value,{componentStack:x!==null?x:""})}),c}function sf(n,r,c){var u=n.pingCache;if(u===null){u=n.pingCache=new Fy;var m=new Set;u.set(r,m)}else m=u.get(r),m===void 0&&(m=new Set,u.set(r,m));m.has(c)||(m.add(c),n=tw.bind(null,n,r,c),r.then(n,n))}function rf(n){do{var r;if((r=n.tag===13)&&(r=n.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return n;n=n.return}while(n!==null);return null}function of(n,r,c,u,m){return(n.mode&1)===0?(n===r?n.flags|=65536:(n.flags|=128,c.flags|=131072,c.flags&=-52805,c.tag===1&&(c.alternate===null?c.tag=17:(r=kn(-1,1),r.tag=2,zn(c,r,1))),c.lanes|=1),n):(n.flags|=65536,n.lanes=m,n)}var Uy=D.ReactCurrentOwner,kt=!1;function mt(n,r,c,u){r.child=n===null?bh(r,null,c,u):Os(r,n.child,c,u)}function af(n,r,c,u,m){c=c.render;var g=r.ref;return _s(r,m),u=Pl(n,r,c,u,g,m),c=_l(),n!==null&&!kt?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~m,yn(n,r,m)):(Pe&&c&&yl(r),r.flags|=1,mt(n,r,u,m),r.child)}function lf(n,r,c,u,m){if(n===null){var g=c.type;return typeof g=="function"&&!fc(g)&&g.defaultProps===void 0&&c.compare===null&&c.defaultProps===void 0?(r.tag=15,r.type=g,cf(n,r,g,u,m)):(n=go(c.type,null,u,r,r.mode,m),n.ref=r.ref,n.return=r,r.child=n)}if(g=n.child,(n.lanes&m)===0){var x=g.memoizedProps;if(c=c.compare,c=c!==null?c:Ci,c(x,u)&&n.ref===r.ref)return yn(n,r,m)}return r.flags|=1,n=Kn(g,u),n.ref=r.ref,n.return=r,r.child=n}function cf(n,r,c,u,m){if(n!==null){var g=n.memoizedProps;if(Ci(g,u)&&n.ref===r.ref)if(kt=!1,r.pendingProps=u=g,(n.lanes&m)!==0)(n.flags&131072)!==0&&(kt=!0);else return r.lanes=n.lanes,yn(n,r,m)}return Vl(n,r,c,u,m)}function df(n,r,c){var u=r.pendingProps,m=u.children,g=n!==null?n.memoizedState:null;if(u.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},Re(Fs,Tt),Tt|=c;else{if((c&1073741824)===0)return n=g!==null?g.baseLanes|c:c,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:n,cachePool:null,transitions:null},r.updateQueue=null,Re(Fs,Tt),Tt|=n,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},u=g!==null?g.baseLanes:c,Re(Fs,Tt),Tt|=u}else g!==null?(u=g.baseLanes|c,r.memoizedState=null):u=c,Re(Fs,Tt),Tt|=u;return mt(n,r,m,c),r.child}function uf(n,r){var c=r.ref;(n===null&&c!==null||n!==null&&n.ref!==c)&&(r.flags|=512,r.flags|=2097152)}function Vl(n,r,c,u,m){var g=vt(c)?es:lt.current;return g=Is(r,g),_s(r,m),c=Pl(n,r,c,u,g,m),u=_l(),n!==null&&!kt?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~m,yn(n,r,m)):(Pe&&u&&yl(r),r.flags|=1,mt(n,r,c,m),r.child)}function hf(n,r,c,u,m){if(vt(c)){var g=!0;Br(r)}else g=!1;if(_s(r,m),r.stateNode===null)io(n,r),Zh(r,c,u),Wl(r,c,u,m),u=!0;else if(n===null){var x=r.stateNode,b=r.memoizedProps;x.props=b;var C=x.context,L=c.contextType;typeof L=="object"&&L!==null?L=Rt(L):(L=vt(c)?es:lt.current,L=Is(r,L));var U=c.getDerivedStateFromProps,K=typeof U=="function"||typeof x.getSnapshotBeforeUpdate=="function";K||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(b!==u||C!==L)&&ef(r,x,u,L),Dn=!1;var B=r.memoizedState;x.state=B,Qr(r,u,x,m),C=r.memoizedState,b!==u||B!==C||gt.current||Dn?(typeof U=="function"&&(Ul(r,c,U,u),C=r.memoizedState),(b=Dn||Xh(r,c,b,u,B,C,L))?(K||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(r.flags|=4194308)):(typeof x.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=u,r.memoizedState=C),x.props=u,x.state=C,x.context=L,u=b):(typeof x.componentDidMount=="function"&&(r.flags|=4194308),u=!1)}else{x=r.stateNode,Ch(n,r),b=r.memoizedProps,L=r.type===r.elementType?b:Ht(r.type,b),x.props=L,K=r.pendingProps,B=x.context,C=c.contextType,typeof C=="object"&&C!==null?C=Rt(C):(C=vt(c)?es:lt.current,C=Is(r,C));var ee=c.getDerivedStateFromProps;(U=typeof ee=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(b!==K||B!==C)&&ef(r,x,u,C),Dn=!1,B=r.memoizedState,x.state=B,Qr(r,u,x,m);var se=r.memoizedState;b!==K||B!==se||gt.current||Dn?(typeof ee=="function"&&(Ul(r,c,ee,u),se=r.memoizedState),(L=Dn||Xh(r,c,L,u,B,se,C)||!1)?(U||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(u,se,C),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(u,se,C)),typeof x.componentDidUpdate=="function"&&(r.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof x.componentDidUpdate!="function"||b===n.memoizedProps&&B===n.memoizedState||(r.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||b===n.memoizedProps&&B===n.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=se),x.props=u,x.state=se,x.context=C,u=L):(typeof x.componentDidUpdate!="function"||b===n.memoizedProps&&B===n.memoizedState||(r.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||b===n.memoizedProps&&B===n.memoizedState||(r.flags|=1024),u=!1)}return Gl(n,r,c,u,g,m)}function Gl(n,r,c,u,m,g){uf(n,r);var x=(r.flags&128)!==0;if(!u&&!x)return m&&gh(r,c,!1),yn(n,r,g);u=r.stateNode,Uy.current=r;var b=x&&typeof c.getDerivedStateFromError!="function"?null:u.render();return r.flags|=1,n!==null&&x?(r.child=Os(r,n.child,null,g),r.child=Os(r,null,b,g)):mt(n,r,b,g),r.memoizedState=u.state,m&&gh(r,c,!0),r.child}function ff(n){var r=n.stateNode;r.pendingContext?mh(n,r.pendingContext,r.pendingContext!==r.context):r.context&&mh(n,r.context,!1),Al(n,r.containerInfo)}function mf(n,r,c,u,m){return Ls(),Sl(m),r.flags|=256,mt(n,r,c,u),r.child}var ql={dehydrated:null,treeContext:null,retryLane:0};function Ql(n){return{baseLanes:n,cachePool:null,transitions:null}}function pf(n,r,c){var u=r.pendingProps,m=_e.current,g=!1,x=(r.flags&128)!==0,b;if((b=x)||(b=n!==null&&n.memoizedState===null?!1:(m&2)!==0),b?(g=!0,r.flags&=-129):(n===null||n.memoizedState!==null)&&(m|=1),Re(_e,m&1),n===null)return jl(r),n=r.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((r.mode&1)===0?r.lanes=1:n.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(x=u.children,n=u.fallback,g?(u=r.mode,g=r.child,x={mode:"hidden",children:x},(u&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=x):g=vo(x,u,0,null),n=ds(n,u,c,null),g.return=r,n.return=r,g.sibling=n,r.child=g,r.child.memoizedState=Ql(c),r.memoizedState=ql,n):Yl(r,x));if(m=n.memoizedState,m!==null&&(b=m.dehydrated,b!==null))return Wy(n,r,x,u,b,m,c);if(g){g=u.fallback,x=r.mode,m=n.child,b=m.sibling;var C={mode:"hidden",children:u.children};return(x&1)===0&&r.child!==m?(u=r.child,u.childLanes=0,u.pendingProps=C,r.deletions=null):(u=Kn(m,C),u.subtreeFlags=m.subtreeFlags&14680064),b!==null?g=Kn(b,g):(g=ds(g,x,c,null),g.flags|=2),g.return=r,u.return=r,u.sibling=g,r.child=u,u=g,g=r.child,x=n.child.memoizedState,x=x===null?Ql(c):{baseLanes:x.baseLanes|c,cachePool:null,transitions:x.transitions},g.memoizedState=x,g.childLanes=n.childLanes&~c,r.memoizedState=ql,u}return g=n.child,n=g.sibling,u=Kn(g,{mode:"visible",children:u.children}),(r.mode&1)===0&&(u.lanes=c),u.return=r,u.sibling=null,n!==null&&(c=r.deletions,c===null?(r.deletions=[n],r.flags|=16):c.push(n)),r.child=u,r.memoizedState=null,u}function Yl(n,r){return r=vo({mode:"visible",children:r},n.mode,0,null),r.return=n,n.child=r}function so(n,r,c,u){return u!==null&&Sl(u),Os(r,n.child,null,c),n=Yl(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function Wy(n,r,c,u,m,g,x){if(c)return r.flags&256?(r.flags&=-257,u=Hl(Error(s(422))),so(n,r,x,u)):r.memoizedState!==null?(r.child=n.child,r.flags|=128,null):(g=u.fallback,m=r.mode,u=vo({mode:"visible",children:u.children},m,0,null),g=ds(g,m,x,null),g.flags|=2,u.return=r,g.return=r,u.sibling=g,r.child=u,(r.mode&1)!==0&&Os(r,n.child,null,x),r.child.memoizedState=Ql(x),r.memoizedState=ql,g);if((r.mode&1)===0)return so(n,r,x,null);if(m.data==="$!"){if(u=m.nextSibling&&m.nextSibling.dataset,u)var b=u.dgst;return u=b,g=Error(s(419)),u=Hl(g,u,void 0),so(n,r,x,u)}if(b=(x&n.childLanes)!==0,kt||b){if(u=tt,u!==null){switch(x&-x){case 4:m=2;break;case 16:m=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:m=32;break;case 536870912:m=268435456;break;default:m=0}m=(m&(u.suspendedLanes|x))!==0?0:m,m!==0&&m!==g.retryLane&&(g.retryLane=m,vn(n,m),Gt(u,n,m,-1))}return hc(),u=Hl(Error(s(421))),so(n,r,x,u)}return m.data==="$?"?(r.flags|=128,r.child=n.child,r=nw.bind(null,n),m._reactRetry=r,null):(n=g.treeContext,Ct=Ln(m.nextSibling),$t=r,Pe=!0,Wt=null,n!==null&&(At[It++]=pn,At[It++]=gn,At[It++]=ts,pn=n.id,gn=n.overflow,ts=r),r=Yl(r,u.children),r.flags|=4096,r)}function gf(n,r,c){n.lanes|=r;var u=n.alternate;u!==null&&(u.lanes|=r),Cl(n.return,r,c)}function Jl(n,r,c,u,m){var g=n.memoizedState;g===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:u,tail:c,tailMode:m}:(g.isBackwards=r,g.rendering=null,g.renderingStartTime=0,g.last=u,g.tail=c,g.tailMode=m)}function vf(n,r,c){var u=r.pendingProps,m=u.revealOrder,g=u.tail;if(mt(n,r,u.children,c),u=_e.current,(u&2)!==0)u=u&1|2,r.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=r.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&gf(n,c,r);else if(n.tag===19)gf(n,c,r);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===r)break e;for(;n.sibling===null;){if(n.return===null||n.return===r)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}u&=1}if(Re(_e,u),(r.mode&1)===0)r.memoizedState=null;else switch(m){case"forwards":for(c=r.child,m=null;c!==null;)n=c.alternate,n!==null&&Yr(n)===null&&(m=c),c=c.sibling;c=m,c===null?(m=r.child,r.child=null):(m=c.sibling,c.sibling=null),Jl(r,!1,m,c,g);break;case"backwards":for(c=null,m=r.child,r.child=null;m!==null;){if(n=m.alternate,n!==null&&Yr(n)===null){r.child=m;break}n=m.sibling,m.sibling=c,c=m,m=n}Jl(r,!0,c,null,g);break;case"together":Jl(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function io(n,r){(r.mode&1)===0&&n!==null&&(n.alternate=null,r.alternate=null,r.flags|=2)}function yn(n,r,c){if(n!==null&&(r.dependencies=n.dependencies),os|=r.lanes,(c&r.childLanes)===0)return null;if(n!==null&&r.child!==n.child)throw Error(s(153));if(r.child!==null){for(n=r.child,c=Kn(n,n.pendingProps),r.child=c,c.return=r;n.sibling!==null;)n=n.sibling,c=c.sibling=Kn(n,n.pendingProps),c.return=r;c.sibling=null}return r.child}function Hy(n,r,c){switch(r.tag){case 3:ff(r),Ls();break;case 5:Ah(r);break;case 1:vt(r.type)&&Br(r);break;case 4:Al(r,r.stateNode.containerInfo);break;case 10:var u=r.type._context,m=r.memoizedProps.value;Re(Vr,u._currentValue),u._currentValue=m;break;case 13:if(u=r.memoizedState,u!==null)return u.dehydrated!==null?(Re(_e,_e.current&1),r.flags|=128,null):(c&r.child.childLanes)!==0?pf(n,r,c):(Re(_e,_e.current&1),n=yn(n,r,c),n!==null?n.sibling:null);Re(_e,_e.current&1);break;case 19:if(u=(c&r.childLanes)!==0,(n.flags&128)!==0){if(u)return vf(n,r,c);r.flags|=128}if(m=r.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),Re(_e,_e.current),u)break;return null;case 22:case 23:return r.lanes=0,df(n,r,c)}return yn(n,r,c)}var kf,Xl,yf,wf;kf=function(n,r){for(var c=r.child;c!==null;){if(c.tag===5||c.tag===6)n.appendChild(c.stateNode);else if(c.tag!==4&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===r)break;for(;c.sibling===null;){if(c.return===null||c.return===r)return;c=c.return}c.sibling.return=c.return,c=c.sibling}},Xl=function(){},yf=function(n,r,c,u){var m=n.memoizedProps;if(m!==u){n=r.stateNode,is(tn.current);var g=null;switch(c){case"input":m=Ca(n,m),u=Ca(n,u),g=[];break;case"select":m=z({},m,{value:void 0}),u=z({},u,{value:void 0}),g=[];break;case"textarea":m=Aa(n,m),u=Aa(n,u),g=[];break;default:typeof m.onClick!="function"&&typeof u.onClick=="function"&&(n.onclick=_r)}Ra(c,u);var x;c=null;for(L in m)if(!u.hasOwnProperty(L)&&m.hasOwnProperty(L)&&m[L]!=null)if(L==="style"){var b=m[L];for(x in b)b.hasOwnProperty(x)&&(c||(c={}),c[x]="")}else L!=="dangerouslySetInnerHTML"&&L!=="children"&&L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&L!=="autoFocus"&&(a.hasOwnProperty(L)?g||(g=[]):(g=g||[]).push(L,null));for(L in u){var C=u[L];if(b=m!=null?m[L]:void 0,u.hasOwnProperty(L)&&C!==b&&(C!=null||b!=null))if(L==="style")if(b){for(x in b)!b.hasOwnProperty(x)||C&&C.hasOwnProperty(x)||(c||(c={}),c[x]="");for(x in C)C.hasOwnProperty(x)&&b[x]!==C[x]&&(c||(c={}),c[x]=C[x])}else c||(g||(g=[]),g.push(L,c)),c=C;else L==="dangerouslySetInnerHTML"?(C=C?C.__html:void 0,b=b?b.__html:void 0,C!=null&&b!==C&&(g=g||[]).push(L,C)):L==="children"?typeof C!="string"&&typeof C!="number"||(g=g||[]).push(L,""+C):L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&(a.hasOwnProperty(L)?(C!=null&&L==="onScroll"&&Me("scroll",n),g||b===C||(g=[])):(g=g||[]).push(L,C))}c&&(g=g||[]).push("style",c);var L=g;(r.updateQueue=L)&&(r.flags|=4)}},wf=function(n,r,c,u){c!==u&&(r.flags|=4)};function Ui(n,r){if(!Pe)switch(n.tailMode){case"hidden":r=n.tail;for(var c=null;r!==null;)r.alternate!==null&&(c=r),r=r.sibling;c===null?n.tail=null:c.sibling=null;break;case"collapsed":c=n.tail;for(var u=null;c!==null;)c.alternate!==null&&(u=c),c=c.sibling;u===null?r||n.tail===null?n.tail=null:n.tail.sibling=null:u.sibling=null}}function dt(n){var r=n.alternate!==null&&n.alternate.child===n.child,c=0,u=0;if(r)for(var m=n.child;m!==null;)c|=m.lanes|m.childLanes,u|=m.subtreeFlags&14680064,u|=m.flags&14680064,m.return=n,m=m.sibling;else for(m=n.child;m!==null;)c|=m.lanes|m.childLanes,u|=m.subtreeFlags,u|=m.flags,m.return=n,m=m.sibling;return n.subtreeFlags|=u,n.childLanes=c,r}function Ky(n,r,c){var u=r.pendingProps;switch(wl(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return dt(r),null;case 1:return vt(r.type)&&zr(),dt(r),null;case 3:return u=r.stateNode,Ds(),Le(gt),Le(lt),Ml(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(n===null||n.child===null)&&(Hr(r)?r.flags|=4:n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Wt!==null&&(cc(Wt),Wt=null))),Xl(n,r),dt(r),null;case 5:Il(r);var m=is(_i.current);if(c=r.type,n!==null&&r.stateNode!=null)yf(n,r,c,u,m),n.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!u){if(r.stateNode===null)throw Error(s(166));return dt(r),null}if(n=is(tn.current),Hr(r)){u=r.stateNode,c=r.type;var g=r.memoizedProps;switch(u[en]=r,u[Ri]=g,n=(r.mode&1)!==0,c){case"dialog":Me("cancel",u),Me("close",u);break;case"iframe":case"object":case"embed":Me("load",u);break;case"video":case"audio":for(m=0;m<Ei.length;m++)Me(Ei[m],u);break;case"source":Me("error",u);break;case"img":case"image":case"link":Me("error",u),Me("load",u);break;case"details":Me("toggle",u);break;case"input":Zd(u,g),Me("invalid",u);break;case"select":u._wrapperState={wasMultiple:!!g.multiple},Me("invalid",u);break;case"textarea":nu(u,g),Me("invalid",u)}Ra(c,g),m=null;for(var x in g)if(g.hasOwnProperty(x)){var b=g[x];x==="children"?typeof b=="string"?u.textContent!==b&&(g.suppressHydrationWarning!==!0&&Pr(u.textContent,b,n),m=["children",b]):typeof b=="number"&&u.textContent!==""+b&&(g.suppressHydrationWarning!==!0&&Pr(u.textContent,b,n),m=["children",""+b]):a.hasOwnProperty(x)&&b!=null&&x==="onScroll"&&Me("scroll",u)}switch(c){case"input":Cn(u),tu(u,g,!0);break;case"textarea":Cn(u),iu(u);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(u.onclick=_r)}u=m,r.updateQueue=u,u!==null&&(r.flags|=4)}else{x=m.nodeType===9?m:m.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=ru(c)),n==="http://www.w3.org/1999/xhtml"?c==="script"?(n=x.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof u.is=="string"?n=x.createElement(c,{is:u.is}):(n=x.createElement(c),c==="select"&&(x=n,u.multiple?x.multiple=!0:u.size&&(x.size=u.size))):n=x.createElementNS(n,c),n[en]=r,n[Ri]=u,kf(n,r,!1,!1),r.stateNode=n;e:{switch(x=Ma(c,u),c){case"dialog":Me("cancel",n),Me("close",n),m=u;break;case"iframe":case"object":case"embed":Me("load",n),m=u;break;case"video":case"audio":for(m=0;m<Ei.length;m++)Me(Ei[m],n);m=u;break;case"source":Me("error",n),m=u;break;case"img":case"image":case"link":Me("error",n),Me("load",n),m=u;break;case"details":Me("toggle",n),m=u;break;case"input":Zd(n,u),m=Ca(n,u),Me("invalid",n);break;case"option":m=u;break;case"select":n._wrapperState={wasMultiple:!!u.multiple},m=z({},u,{value:void 0}),Me("invalid",n);break;case"textarea":nu(n,u),m=Aa(n,u),Me("invalid",n);break;default:m=u}Ra(c,m),b=m;for(g in b)if(b.hasOwnProperty(g)){var C=b[g];g==="style"?lu(n,C):g==="dangerouslySetInnerHTML"?(C=C?C.__html:void 0,C!=null&&ou(n,C)):g==="children"?typeof C=="string"?(c!=="textarea"||C!=="")&&di(n,C):typeof C=="number"&&di(n,""+C):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(a.hasOwnProperty(g)?C!=null&&g==="onScroll"&&Me("scroll",n):C!=null&&O(n,g,C,x))}switch(c){case"input":Cn(n),tu(n,u,!1);break;case"textarea":Cn(n),iu(n);break;case"option":u.value!=null&&n.setAttribute("value",""+Se(u.value));break;case"select":n.multiple=!!u.multiple,g=u.value,g!=null?ys(n,!!u.multiple,g,!1):u.defaultValue!=null&&ys(n,!!u.multiple,u.defaultValue,!0);break;default:typeof m.onClick=="function"&&(n.onclick=_r)}switch(c){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}}u&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return dt(r),null;case 6:if(n&&r.stateNode!=null)wf(n,r,n.memoizedProps,u);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(c=is(_i.current),is(tn.current),Hr(r)){if(u=r.stateNode,c=r.memoizedProps,u[en]=r,(g=u.nodeValue!==c)&&(n=$t,n!==null))switch(n.tag){case 3:Pr(u.nodeValue,c,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&Pr(u.nodeValue,c,(n.mode&1)!==0)}g&&(r.flags|=4)}else u=(c.nodeType===9?c:c.ownerDocument).createTextNode(u),u[en]=r,r.stateNode=u}return dt(r),null;case 13:if(Le(_e),u=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(Pe&&Ct!==null&&(r.mode&1)!==0&&(r.flags&128)===0)jh(),Ls(),r.flags|=98560,g=!1;else if(g=Hr(r),u!==null&&u.dehydrated!==null){if(n===null){if(!g)throw Error(s(318));if(g=r.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(s(317));g[en]=r}else Ls(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;dt(r),g=!1}else Wt!==null&&(cc(Wt),Wt=null),g=!0;if(!g)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=c,r):(u=u!==null,u!==(n!==null&&n.memoizedState!==null)&&u&&(r.child.flags|=8192,(r.mode&1)!==0&&(n===null||(_e.current&1)!==0?Xe===0&&(Xe=3):hc())),r.updateQueue!==null&&(r.flags|=4),dt(r),null);case 4:return Ds(),Xl(n,r),n===null&&Ai(r.stateNode.containerInfo),dt(r),null;case 10:return $l(r.type._context),dt(r),null;case 17:return vt(r.type)&&zr(),dt(r),null;case 19:if(Le(_e),g=r.memoizedState,g===null)return dt(r),null;if(u=(r.flags&128)!==0,x=g.rendering,x===null)if(u)Ui(g,!1);else{if(Xe!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(x=Yr(n),x!==null){for(r.flags|=128,Ui(g,!1),u=x.updateQueue,u!==null&&(r.updateQueue=u,r.flags|=4),r.subtreeFlags=0,u=c,c=r.child;c!==null;)g=c,n=u,g.flags&=14680066,x=g.alternate,x===null?(g.childLanes=0,g.lanes=n,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=x.childLanes,g.lanes=x.lanes,g.child=x.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=x.memoizedProps,g.memoizedState=x.memoizedState,g.updateQueue=x.updateQueue,g.type=x.type,n=x.dependencies,g.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),c=c.sibling;return Re(_e,_e.current&1|2),r.child}n=n.sibling}g.tail!==null&&We()>Us&&(r.flags|=128,u=!0,Ui(g,!1),r.lanes=4194304)}else{if(!u)if(n=Yr(x),n!==null){if(r.flags|=128,u=!0,c=n.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),Ui(g,!0),g.tail===null&&g.tailMode==="hidden"&&!x.alternate&&!Pe)return dt(r),null}else 2*We()-g.renderingStartTime>Us&&c!==1073741824&&(r.flags|=128,u=!0,Ui(g,!1),r.lanes=4194304);g.isBackwards?(x.sibling=r.child,r.child=x):(c=g.last,c!==null?c.sibling=x:r.child=x,g.last=x)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=We(),r.sibling=null,c=_e.current,Re(_e,u?c&1|2:c&1),r):(dt(r),null);case 22:case 23:return uc(),u=r.memoizedState!==null,n!==null&&n.memoizedState!==null!==u&&(r.flags|=8192),u&&(r.mode&1)!==0?(Tt&1073741824)!==0&&(dt(r),r.subtreeFlags&6&&(r.flags|=8192)):dt(r),null;case 24:return null;case 25:return null}throw Error(s(156,r.tag))}function Vy(n,r){switch(wl(r),r.tag){case 1:return vt(r.type)&&zr(),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return Ds(),Le(gt),Le(lt),Ml(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 5:return Il(r),null;case 13:if(Le(_e),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(s(340));Ls()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return Le(_e),null;case 4:return Ds(),null;case 10:return $l(r.type._context),null;case 22:case 23:return uc(),null;case 24:return null;default:return null}}var ro=!1,ut=!1,Gy=typeof WeakSet=="function"?WeakSet:Set,te=null;function Bs(n,r){var c=n.ref;if(c!==null)if(typeof c=="function")try{c(null)}catch(u){Ue(n,r,u)}else c.current=null}function Zl(n,r,c){try{c()}catch(u){Ue(n,r,u)}}var xf=!1;function qy(n,r){if(ul=br,n=Xu(),sl(n)){if("selectionStart"in n)var c={start:n.selectionStart,end:n.selectionEnd};else e:{c=(c=n.ownerDocument)&&c.defaultView||window;var u=c.getSelection&&c.getSelection();if(u&&u.rangeCount!==0){c=u.anchorNode;var m=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{c.nodeType,g.nodeType}catch{c=null;break e}var x=0,b=-1,C=-1,L=0,U=0,K=n,B=null;t:for(;;){for(var ee;K!==c||m!==0&&K.nodeType!==3||(b=x+m),K!==g||u!==0&&K.nodeType!==3||(C=x+u),K.nodeType===3&&(x+=K.nodeValue.length),(ee=K.firstChild)!==null;)B=K,K=ee;for(;;){if(K===n)break t;if(B===c&&++L===m&&(b=x),B===g&&++U===u&&(C=x),(ee=K.nextSibling)!==null)break;K=B,B=K.parentNode}K=ee}c=b===-1||C===-1?null:{start:b,end:C}}else c=null}c=c||{start:0,end:0}}else c=null;for(hl={focusedElem:n,selectionRange:c},br=!1,te=r;te!==null;)if(r=te,n=r.child,(r.subtreeFlags&1028)!==0&&n!==null)n.return=r,te=n;else for(;te!==null;){r=te;try{var se=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(se!==null){var re=se.memoizedProps,He=se.memoizedState,A=r.stateNode,E=A.getSnapshotBeforeUpdate(r.elementType===r.type?re:Ht(r.type,re),He);A.__reactInternalSnapshotBeforeUpdate=E}break;case 3:var R=r.stateNode.containerInfo;R.nodeType===1?R.textContent="":R.nodeType===9&&R.documentElement&&R.removeChild(R.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(Y){Ue(r,r.return,Y)}if(n=r.sibling,n!==null){n.return=r.return,te=n;break}te=r.return}return se=xf,xf=!1,se}function Wi(n,r,c){var u=r.updateQueue;if(u=u!==null?u.lastEffect:null,u!==null){var m=u=u.next;do{if((m.tag&n)===n){var g=m.destroy;m.destroy=void 0,g!==void 0&&Zl(r,c,g)}m=m.next}while(m!==u)}}function oo(n,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var c=r=r.next;do{if((c.tag&n)===n){var u=c.create;c.destroy=u()}c=c.next}while(c!==r)}}function ec(n){var r=n.ref;if(r!==null){var c=n.stateNode;switch(n.tag){case 5:n=c;break;default:n=c}typeof r=="function"?r(n):r.current=n}}function jf(n){var r=n.alternate;r!==null&&(n.alternate=null,jf(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&(delete r[en],delete r[Ri],delete r[gl],delete r[Ay],delete r[Iy])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function Sf(n){return n.tag===5||n.tag===3||n.tag===4}function Nf(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Sf(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function tc(n,r,c){var u=n.tag;if(u===5||u===6)n=n.stateNode,r?c.nodeType===8?c.parentNode.insertBefore(n,r):c.insertBefore(n,r):(c.nodeType===8?(r=c.parentNode,r.insertBefore(n,c)):(r=c,r.appendChild(n)),c=c._reactRootContainer,c!=null||r.onclick!==null||(r.onclick=_r));else if(u!==4&&(n=n.child,n!==null))for(tc(n,r,c),n=n.sibling;n!==null;)tc(n,r,c),n=n.sibling}function nc(n,r,c){var u=n.tag;if(u===5||u===6)n=n.stateNode,r?c.insertBefore(n,r):c.appendChild(n);else if(u!==4&&(n=n.child,n!==null))for(nc(n,r,c),n=n.sibling;n!==null;)nc(n,r,c),n=n.sibling}var it=null,Kt=!1;function Bn(n,r,c){for(c=c.child;c!==null;)bf(n,r,c),c=c.sibling}function bf(n,r,c){if(Zt&&typeof Zt.onCommitFiberUnmount=="function")try{Zt.onCommitFiberUnmount(yr,c)}catch{}switch(c.tag){case 5:ut||Bs(c,r);case 6:var u=it,m=Kt;it=null,Bn(n,r,c),it=u,Kt=m,it!==null&&(Kt?(n=it,c=c.stateNode,n.nodeType===8?n.parentNode.removeChild(c):n.removeChild(c)):it.removeChild(c.stateNode));break;case 18:it!==null&&(Kt?(n=it,c=c.stateNode,n.nodeType===8?pl(n.parentNode,c):n.nodeType===1&&pl(n,c),xi(n)):pl(it,c.stateNode));break;case 4:u=it,m=Kt,it=c.stateNode.containerInfo,Kt=!0,Bn(n,r,c),it=u,Kt=m;break;case 0:case 11:case 14:case 15:if(!ut&&(u=c.updateQueue,u!==null&&(u=u.lastEffect,u!==null))){m=u=u.next;do{var g=m,x=g.destroy;g=g.tag,x!==void 0&&((g&2)!==0||(g&4)!==0)&&Zl(c,r,x),m=m.next}while(m!==u)}Bn(n,r,c);break;case 1:if(!ut&&(Bs(c,r),u=c.stateNode,typeof u.componentWillUnmount=="function"))try{u.props=c.memoizedProps,u.state=c.memoizedState,u.componentWillUnmount()}catch(b){Ue(c,r,b)}Bn(n,r,c);break;case 21:Bn(n,r,c);break;case 22:c.mode&1?(ut=(u=ut)||c.memoizedState!==null,Bn(n,r,c),ut=u):Bn(n,r,c);break;default:Bn(n,r,c)}}function $f(n){var r=n.updateQueue;if(r!==null){n.updateQueue=null;var c=n.stateNode;c===null&&(c=n.stateNode=new Gy),r.forEach(function(u){var m=sw.bind(null,n,u);c.has(u)||(c.add(u),u.then(m,m))})}}function Vt(n,r){var c=r.deletions;if(c!==null)for(var u=0;u<c.length;u++){var m=c[u];try{var g=n,x=r,b=x;e:for(;b!==null;){switch(b.tag){case 5:it=b.stateNode,Kt=!1;break e;case 3:it=b.stateNode.containerInfo,Kt=!0;break e;case 4:it=b.stateNode.containerInfo,Kt=!0;break e}b=b.return}if(it===null)throw Error(s(160));bf(g,x,m),it=null,Kt=!1;var C=m.alternate;C!==null&&(C.return=null),m.return=null}catch(L){Ue(m,r,L)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)Cf(r,n),r=r.sibling}function Cf(n,r){var c=n.alternate,u=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Vt(r,n),sn(n),u&4){try{Wi(3,n,n.return),oo(3,n)}catch(re){Ue(n,n.return,re)}try{Wi(5,n,n.return)}catch(re){Ue(n,n.return,re)}}break;case 1:Vt(r,n),sn(n),u&512&&c!==null&&Bs(c,c.return);break;case 5:if(Vt(r,n),sn(n),u&512&&c!==null&&Bs(c,c.return),n.flags&32){var m=n.stateNode;try{di(m,"")}catch(re){Ue(n,n.return,re)}}if(u&4&&(m=n.stateNode,m!=null)){var g=n.memoizedProps,x=c!==null?c.memoizedProps:g,b=n.type,C=n.updateQueue;if(n.updateQueue=null,C!==null)try{b==="input"&&g.type==="radio"&&g.name!=null&&eu(m,g),Ma(b,x);var L=Ma(b,g);for(x=0;x<C.length;x+=2){var U=C[x],K=C[x+1];U==="style"?lu(m,K):U==="dangerouslySetInnerHTML"?ou(m,K):U==="children"?di(m,K):O(m,U,K,L)}switch(b){case"input":Ta(m,g);break;case"textarea":su(m,g);break;case"select":var B=m._wrapperState.wasMultiple;m._wrapperState.wasMultiple=!!g.multiple;var ee=g.value;ee!=null?ys(m,!!g.multiple,ee,!1):B!==!!g.multiple&&(g.defaultValue!=null?ys(m,!!g.multiple,g.defaultValue,!0):ys(m,!!g.multiple,g.multiple?[]:"",!1))}m[Ri]=g}catch(re){Ue(n,n.return,re)}}break;case 6:if(Vt(r,n),sn(n),u&4){if(n.stateNode===null)throw Error(s(162));m=n.stateNode,g=n.memoizedProps;try{m.nodeValue=g}catch(re){Ue(n,n.return,re)}}break;case 3:if(Vt(r,n),sn(n),u&4&&c!==null&&c.memoizedState.isDehydrated)try{xi(r.containerInfo)}catch(re){Ue(n,n.return,re)}break;case 4:Vt(r,n),sn(n);break;case 13:Vt(r,n),sn(n),m=n.child,m.flags&8192&&(g=m.memoizedState!==null,m.stateNode.isHidden=g,!g||m.alternate!==null&&m.alternate.memoizedState!==null||(rc=We())),u&4&&$f(n);break;case 22:if(U=c!==null&&c.memoizedState!==null,n.mode&1?(ut=(L=ut)||U,Vt(r,n),ut=L):Vt(r,n),sn(n),u&8192){if(L=n.memoizedState!==null,(n.stateNode.isHidden=L)&&!U&&(n.mode&1)!==0)for(te=n,U=n.child;U!==null;){for(K=te=U;te!==null;){switch(B=te,ee=B.child,B.tag){case 0:case 11:case 14:case 15:Wi(4,B,B.return);break;case 1:Bs(B,B.return);var se=B.stateNode;if(typeof se.componentWillUnmount=="function"){u=B,c=B.return;try{r=u,se.props=r.memoizedProps,se.state=r.memoizedState,se.componentWillUnmount()}catch(re){Ue(u,c,re)}}break;case 5:Bs(B,B.return);break;case 22:if(B.memoizedState!==null){Af(K);continue}}ee!==null?(ee.return=B,te=ee):Af(K)}U=U.sibling}e:for(U=null,K=n;;){if(K.tag===5){if(U===null){U=K;try{m=K.stateNode,L?(g=m.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(b=K.stateNode,C=K.memoizedProps.style,x=C!=null&&C.hasOwnProperty("display")?C.display:null,b.style.display=au("display",x))}catch(re){Ue(n,n.return,re)}}}else if(K.tag===6){if(U===null)try{K.stateNode.nodeValue=L?"":K.memoizedProps}catch(re){Ue(n,n.return,re)}}else if((K.tag!==22&&K.tag!==23||K.memoizedState===null||K===n)&&K.child!==null){K.child.return=K,K=K.child;continue}if(K===n)break e;for(;K.sibling===null;){if(K.return===null||K.return===n)break e;U===K&&(U=null),K=K.return}U===K&&(U=null),K.sibling.return=K.return,K=K.sibling}}break;case 19:Vt(r,n),sn(n),u&4&&$f(n);break;case 21:break;default:Vt(r,n),sn(n)}}function sn(n){var r=n.flags;if(r&2){try{e:{for(var c=n.return;c!==null;){if(Sf(c)){var u=c;break e}c=c.return}throw Error(s(160))}switch(u.tag){case 5:var m=u.stateNode;u.flags&32&&(di(m,""),u.flags&=-33);var g=Nf(n);nc(n,g,m);break;case 3:case 4:var x=u.stateNode.containerInfo,b=Nf(n);tc(n,b,x);break;default:throw Error(s(161))}}catch(C){Ue(n,n.return,C)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function Qy(n,r,c){te=n,Tf(n)}function Tf(n,r,c){for(var u=(n.mode&1)!==0;te!==null;){var m=te,g=m.child;if(m.tag===22&&u){var x=m.memoizedState!==null||ro;if(!x){var b=m.alternate,C=b!==null&&b.memoizedState!==null||ut;b=ro;var L=ut;if(ro=x,(ut=C)&&!L)for(te=m;te!==null;)x=te,C=x.child,x.tag===22&&x.memoizedState!==null?If(m):C!==null?(C.return=x,te=C):If(m);for(;g!==null;)te=g,Tf(g),g=g.sibling;te=m,ro=b,ut=L}Ef(n)}else(m.subtreeFlags&8772)!==0&&g!==null?(g.return=m,te=g):Ef(n)}}function Ef(n){for(;te!==null;){var r=te;if((r.flags&8772)!==0){var c=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:ut||oo(5,r);break;case 1:var u=r.stateNode;if(r.flags&4&&!ut)if(c===null)u.componentDidMount();else{var m=r.elementType===r.type?c.memoizedProps:Ht(r.type,c.memoizedProps);u.componentDidUpdate(m,c.memoizedState,u.__reactInternalSnapshotBeforeUpdate)}var g=r.updateQueue;g!==null&&Eh(r,g,u);break;case 3:var x=r.updateQueue;if(x!==null){if(c=null,r.child!==null)switch(r.child.tag){case 5:c=r.child.stateNode;break;case 1:c=r.child.stateNode}Eh(r,x,c)}break;case 5:var b=r.stateNode;if(c===null&&r.flags&4){c=b;var C=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":C.autoFocus&&c.focus();break;case"img":C.src&&(c.src=C.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var L=r.alternate;if(L!==null){var U=L.memoizedState;if(U!==null){var K=U.dehydrated;K!==null&&xi(K)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}ut||r.flags&512&&ec(r)}catch(B){Ue(r,r.return,B)}}if(r===n){te=null;break}if(c=r.sibling,c!==null){c.return=r.return,te=c;break}te=r.return}}function Af(n){for(;te!==null;){var r=te;if(r===n){te=null;break}var c=r.sibling;if(c!==null){c.return=r.return,te=c;break}te=r.return}}function If(n){for(;te!==null;){var r=te;try{switch(r.tag){case 0:case 11:case 15:var c=r.return;try{oo(4,r)}catch(C){Ue(r,c,C)}break;case 1:var u=r.stateNode;if(typeof u.componentDidMount=="function"){var m=r.return;try{u.componentDidMount()}catch(C){Ue(r,m,C)}}var g=r.return;try{ec(r)}catch(C){Ue(r,g,C)}break;case 5:var x=r.return;try{ec(r)}catch(C){Ue(r,x,C)}}}catch(C){Ue(r,r.return,C)}if(r===n){te=null;break}var b=r.sibling;if(b!==null){b.return=r.return,te=b;break}te=r.return}}var Yy=Math.ceil,ao=D.ReactCurrentDispatcher,sc=D.ReactCurrentOwner,Lt=D.ReactCurrentBatchConfig,Ne=0,tt=null,qe=null,rt=0,Tt=0,Fs=On(0),Xe=0,Hi=null,os=0,lo=0,ic=0,Ki=null,yt=null,rc=0,Us=1/0,wn=null,co=!1,oc=null,Fn=null,uo=!1,Un=null,ho=0,Vi=0,ac=null,fo=-1,mo=0;function pt(){return(Ne&6)!==0?We():fo!==-1?fo:fo=We()}function Wn(n){return(n.mode&1)===0?1:(Ne&2)!==0&&rt!==0?rt&-rt:My.transition!==null?(mo===0&&(mo=Su()),mo):(n=Ce,n!==0||(n=window.event,n=n===void 0?16:Ru(n.type)),n)}function Gt(n,r,c,u){if(50<Vi)throw Vi=0,ac=null,Error(s(185));gi(n,c,u),((Ne&2)===0||n!==tt)&&(n===tt&&((Ne&2)===0&&(lo|=c),Xe===4&&Hn(n,rt)),wt(n,u),c===1&&Ne===0&&(r.mode&1)===0&&(Us=We()+500,Fr&&_n()))}function wt(n,r){var c=n.callbackNode;Mk(n,r);var u=jr(n,n===tt?rt:0);if(u===0)c!==null&&wu(c),n.callbackNode=null,n.callbackPriority=0;else if(r=u&-u,n.callbackPriority!==r){if(c!=null&&wu(c),r===1)n.tag===0?Ry(Mf.bind(null,n)):vh(Mf.bind(null,n)),Ty(function(){(Ne&6)===0&&_n()}),c=null;else{switch(Nu(u)){case 1:c=Ba;break;case 4:c=xu;break;case 16:c=kr;break;case 536870912:c=ju;break;default:c=kr}c=Ff(c,Rf.bind(null,n))}n.callbackPriority=r,n.callbackNode=c}}function Rf(n,r){if(fo=-1,mo=0,(Ne&6)!==0)throw Error(s(327));var c=n.callbackNode;if(Ws()&&n.callbackNode!==c)return null;var u=jr(n,n===tt?rt:0);if(u===0)return null;if((u&30)!==0||(u&n.expiredLanes)!==0||r)r=po(n,u);else{r=u;var m=Ne;Ne|=2;var g=Of();(tt!==n||rt!==r)&&(wn=null,Us=We()+500,ls(n,r));do try{Zy();break}catch(b){Lf(n,b)}while(!0);bl(),ao.current=g,Ne=m,qe!==null?r=0:(tt=null,rt=0,r=Xe)}if(r!==0){if(r===2&&(m=Fa(n),m!==0&&(u=m,r=lc(n,m))),r===1)throw c=Hi,ls(n,0),Hn(n,u),wt(n,We()),c;if(r===6)Hn(n,u);else{if(m=n.current.alternate,(u&30)===0&&!Jy(m)&&(r=po(n,u),r===2&&(g=Fa(n),g!==0&&(u=g,r=lc(n,g))),r===1))throw c=Hi,ls(n,0),Hn(n,u),wt(n,We()),c;switch(n.finishedWork=m,n.finishedLanes=u,r){case 0:case 1:throw Error(s(345));case 2:cs(n,yt,wn);break;case 3:if(Hn(n,u),(u&130023424)===u&&(r=rc+500-We(),10<r)){if(jr(n,0)!==0)break;if(m=n.suspendedLanes,(m&u)!==u){pt(),n.pingedLanes|=n.suspendedLanes&m;break}n.timeoutHandle=ml(cs.bind(null,n,yt,wn),r);break}cs(n,yt,wn);break;case 4:if(Hn(n,u),(u&4194240)===u)break;for(r=n.eventTimes,m=-1;0<u;){var x=31-Ft(u);g=1<<x,x=r[x],x>m&&(m=x),u&=~g}if(u=m,u=We()-u,u=(120>u?120:480>u?480:1080>u?1080:1920>u?1920:3e3>u?3e3:4320>u?4320:1960*Yy(u/1960))-u,10<u){n.timeoutHandle=ml(cs.bind(null,n,yt,wn),u);break}cs(n,yt,wn);break;case 5:cs(n,yt,wn);break;default:throw Error(s(329))}}}return wt(n,We()),n.callbackNode===c?Rf.bind(null,n):null}function lc(n,r){var c=Ki;return n.current.memoizedState.isDehydrated&&(ls(n,r).flags|=256),n=po(n,r),n!==2&&(r=yt,yt=c,r!==null&&cc(r)),n}function cc(n){yt===null?yt=n:yt.push.apply(yt,n)}function Jy(n){for(var r=n;;){if(r.flags&16384){var c=r.updateQueue;if(c!==null&&(c=c.stores,c!==null))for(var u=0;u<c.length;u++){var m=c[u],g=m.getSnapshot;m=m.value;try{if(!Ut(g(),m))return!1}catch{return!1}}}if(c=r.child,r.subtreeFlags&16384&&c!==null)c.return=r,r=c;else{if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Hn(n,r){for(r&=~ic,r&=~lo,n.suspendedLanes|=r,n.pingedLanes&=~r,n=n.expirationTimes;0<r;){var c=31-Ft(r),u=1<<c;n[c]=-1,r&=~u}}function Mf(n){if((Ne&6)!==0)throw Error(s(327));Ws();var r=jr(n,0);if((r&1)===0)return wt(n,We()),null;var c=po(n,r);if(n.tag!==0&&c===2){var u=Fa(n);u!==0&&(r=u,c=lc(n,u))}if(c===1)throw c=Hi,ls(n,0),Hn(n,r),wt(n,We()),c;if(c===6)throw Error(s(345));return n.finishedWork=n.current.alternate,n.finishedLanes=r,cs(n,yt,wn),wt(n,We()),null}function dc(n,r){var c=Ne;Ne|=1;try{return n(r)}finally{Ne=c,Ne===0&&(Us=We()+500,Fr&&_n())}}function as(n){Un!==null&&Un.tag===0&&(Ne&6)===0&&Ws();var r=Ne;Ne|=1;var c=Lt.transition,u=Ce;try{if(Lt.transition=null,Ce=1,n)return n()}finally{Ce=u,Lt.transition=c,Ne=r,(Ne&6)===0&&_n()}}function uc(){Tt=Fs.current,Le(Fs)}function ls(n,r){n.finishedWork=null,n.finishedLanes=0;var c=n.timeoutHandle;if(c!==-1&&(n.timeoutHandle=-1,Cy(c)),qe!==null)for(c=qe.return;c!==null;){var u=c;switch(wl(u),u.tag){case 1:u=u.type.childContextTypes,u!=null&&zr();break;case 3:Ds(),Le(gt),Le(lt),Ml();break;case 5:Il(u);break;case 4:Ds();break;case 13:Le(_e);break;case 19:Le(_e);break;case 10:$l(u.type._context);break;case 22:case 23:uc()}c=c.return}if(tt=n,qe=n=Kn(n.current,null),rt=Tt=r,Xe=0,Hi=null,ic=lo=os=0,yt=Ki=null,ss!==null){for(r=0;r<ss.length;r++)if(c=ss[r],u=c.interleaved,u!==null){c.interleaved=null;var m=u.next,g=c.pending;if(g!==null){var x=g.next;g.next=m,u.next=x}c.pending=u}ss=null}return n}function Lf(n,r){do{var c=qe;try{if(bl(),Jr.current=to,Xr){for(var u=De.memoizedState;u!==null;){var m=u.queue;m!==null&&(m.pending=null),u=u.next}Xr=!1}if(rs=0,et=Je=De=null,Di=!1,zi=0,sc.current=null,c===null||c.return===null){Xe=1,Hi=r,qe=null;break}e:{var g=n,x=c.return,b=c,C=r;if(r=rt,b.flags|=32768,C!==null&&typeof C=="object"&&typeof C.then=="function"){var L=C,U=b,K=U.tag;if((U.mode&1)===0&&(K===0||K===11||K===15)){var B=U.alternate;B?(U.updateQueue=B.updateQueue,U.memoizedState=B.memoizedState,U.lanes=B.lanes):(U.updateQueue=null,U.memoizedState=null)}var ee=rf(x);if(ee!==null){ee.flags&=-257,of(ee,x,b,g,r),ee.mode&1&&sf(g,L,r),r=ee,C=L;var se=r.updateQueue;if(se===null){var re=new Set;re.add(C),r.updateQueue=re}else se.add(C);break e}else{if((r&1)===0){sf(g,L,r),hc();break e}C=Error(s(426))}}else if(Pe&&b.mode&1){var He=rf(x);if(He!==null){(He.flags&65536)===0&&(He.flags|=256),of(He,x,b,g,r),Sl(zs(C,b));break e}}g=C=zs(C,b),Xe!==4&&(Xe=2),Ki===null?Ki=[g]:Ki.push(g),g=x;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var A=tf(g,C,r);Th(g,A);break e;case 1:b=C;var E=g.type,R=g.stateNode;if((g.flags&128)===0&&(typeof E.getDerivedStateFromError=="function"||R!==null&&typeof R.componentDidCatch=="function"&&(Fn===null||!Fn.has(R)))){g.flags|=65536,r&=-r,g.lanes|=r;var Y=nf(g,b,r);Th(g,Y);break e}}g=g.return}while(g!==null)}_f(c)}catch(ae){r=ae,qe===c&&c!==null&&(qe=c=c.return);continue}break}while(!0)}function Of(){var n=ao.current;return ao.current=to,n===null?to:n}function hc(){(Xe===0||Xe===3||Xe===2)&&(Xe=4),tt===null||(os&268435455)===0&&(lo&268435455)===0||Hn(tt,rt)}function po(n,r){var c=Ne;Ne|=2;var u=Of();(tt!==n||rt!==r)&&(wn=null,ls(n,r));do try{Xy();break}catch(m){Lf(n,m)}while(!0);if(bl(),Ne=c,ao.current=u,qe!==null)throw Error(s(261));return tt=null,rt=0,Xe}function Xy(){for(;qe!==null;)Pf(qe)}function Zy(){for(;qe!==null&&!Nk();)Pf(qe)}function Pf(n){var r=Bf(n.alternate,n,Tt);n.memoizedProps=n.pendingProps,r===null?_f(n):qe=r,sc.current=null}function _f(n){var r=n;do{var c=r.alternate;if(n=r.return,(r.flags&32768)===0){if(c=Ky(c,r,Tt),c!==null){qe=c;return}}else{if(c=Vy(c,r),c!==null){c.flags&=32767,qe=c;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{Xe=6,qe=null;return}}if(r=r.sibling,r!==null){qe=r;return}qe=r=n}while(r!==null);Xe===0&&(Xe=5)}function cs(n,r,c){var u=Ce,m=Lt.transition;try{Lt.transition=null,Ce=1,ew(n,r,c,u)}finally{Lt.transition=m,Ce=u}return null}function ew(n,r,c,u){do Ws();while(Un!==null);if((Ne&6)!==0)throw Error(s(327));c=n.finishedWork;var m=n.finishedLanes;if(c===null)return null;if(n.finishedWork=null,n.finishedLanes=0,c===n.current)throw Error(s(177));n.callbackNode=null,n.callbackPriority=0;var g=c.lanes|c.childLanes;if(Lk(n,g),n===tt&&(qe=tt=null,rt=0),(c.subtreeFlags&2064)===0&&(c.flags&2064)===0||uo||(uo=!0,Ff(kr,function(){return Ws(),null})),g=(c.flags&15990)!==0,(c.subtreeFlags&15990)!==0||g){g=Lt.transition,Lt.transition=null;var x=Ce;Ce=1;var b=Ne;Ne|=4,sc.current=null,qy(n,c),Cf(c,n),wy(hl),br=!!ul,hl=ul=null,n.current=c,Qy(c),bk(),Ne=b,Ce=x,Lt.transition=g}else n.current=c;if(uo&&(uo=!1,Un=n,ho=m),g=n.pendingLanes,g===0&&(Fn=null),Tk(c.stateNode),wt(n,We()),r!==null)for(u=n.onRecoverableError,c=0;c<r.length;c++)m=r[c],u(m.value,{componentStack:m.stack,digest:m.digest});if(co)throw co=!1,n=oc,oc=null,n;return(ho&1)!==0&&n.tag!==0&&Ws(),g=n.pendingLanes,(g&1)!==0?n===ac?Vi++:(Vi=0,ac=n):Vi=0,_n(),null}function Ws(){if(Un!==null){var n=Nu(ho),r=Lt.transition,c=Ce;try{if(Lt.transition=null,Ce=16>n?16:n,Un===null)var u=!1;else{if(n=Un,Un=null,ho=0,(Ne&6)!==0)throw Error(s(331));var m=Ne;for(Ne|=4,te=n.current;te!==null;){var g=te,x=g.child;if((te.flags&16)!==0){var b=g.deletions;if(b!==null){for(var C=0;C<b.length;C++){var L=b[C];for(te=L;te!==null;){var U=te;switch(U.tag){case 0:case 11:case 15:Wi(8,U,g)}var K=U.child;if(K!==null)K.return=U,te=K;else for(;te!==null;){U=te;var B=U.sibling,ee=U.return;if(jf(U),U===L){te=null;break}if(B!==null){B.return=ee,te=B;break}te=ee}}}var se=g.alternate;if(se!==null){var re=se.child;if(re!==null){se.child=null;do{var He=re.sibling;re.sibling=null,re=He}while(re!==null)}}te=g}}if((g.subtreeFlags&2064)!==0&&x!==null)x.return=g,te=x;else e:for(;te!==null;){if(g=te,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:Wi(9,g,g.return)}var A=g.sibling;if(A!==null){A.return=g.return,te=A;break e}te=g.return}}var E=n.current;for(te=E;te!==null;){x=te;var R=x.child;if((x.subtreeFlags&2064)!==0&&R!==null)R.return=x,te=R;else e:for(x=E;te!==null;){if(b=te,(b.flags&2048)!==0)try{switch(b.tag){case 0:case 11:case 15:oo(9,b)}}catch(ae){Ue(b,b.return,ae)}if(b===x){te=null;break e}var Y=b.sibling;if(Y!==null){Y.return=b.return,te=Y;break e}te=b.return}}if(Ne=m,_n(),Zt&&typeof Zt.onPostCommitFiberRoot=="function")try{Zt.onPostCommitFiberRoot(yr,n)}catch{}u=!0}return u}finally{Ce=c,Lt.transition=r}}return!1}function Df(n,r,c){r=zs(c,r),r=tf(n,r,1),n=zn(n,r,1),r=pt(),n!==null&&(gi(n,1,r),wt(n,r))}function Ue(n,r,c){if(n.tag===3)Df(n,n,c);else for(;r!==null;){if(r.tag===3){Df(r,n,c);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Fn===null||!Fn.has(u))){n=zs(c,n),n=nf(r,n,1),r=zn(r,n,1),n=pt(),r!==null&&(gi(r,1,n),wt(r,n));break}}r=r.return}}function tw(n,r,c){var u=n.pingCache;u!==null&&u.delete(r),r=pt(),n.pingedLanes|=n.suspendedLanes&c,tt===n&&(rt&c)===c&&(Xe===4||Xe===3&&(rt&130023424)===rt&&500>We()-rc?ls(n,0):ic|=c),wt(n,r)}function zf(n,r){r===0&&((n.mode&1)===0?r=1:(r=xr,xr<<=1,(xr&130023424)===0&&(xr=4194304)));var c=pt();n=vn(n,r),n!==null&&(gi(n,r,c),wt(n,c))}function nw(n){var r=n.memoizedState,c=0;r!==null&&(c=r.retryLane),zf(n,c)}function sw(n,r){var c=0;switch(n.tag){case 13:var u=n.stateNode,m=n.memoizedState;m!==null&&(c=m.retryLane);break;case 19:u=n.stateNode;break;default:throw Error(s(314))}u!==null&&u.delete(r),zf(n,c)}var Bf;Bf=function(n,r,c){if(n!==null)if(n.memoizedProps!==r.pendingProps||gt.current)kt=!0;else{if((n.lanes&c)===0&&(r.flags&128)===0)return kt=!1,Hy(n,r,c);kt=(n.flags&131072)!==0}else kt=!1,Pe&&(r.flags&1048576)!==0&&kh(r,Wr,r.index);switch(r.lanes=0,r.tag){case 2:var u=r.type;io(n,r),n=r.pendingProps;var m=Is(r,lt.current);_s(r,c),m=Pl(null,r,u,n,m,c);var g=_l();return r.flags|=1,typeof m=="object"&&m!==null&&typeof m.render=="function"&&m.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,vt(u)?(g=!0,Br(r)):g=!1,r.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,El(r),m.updater=no,r.stateNode=m,m._reactInternals=r,Wl(r,u,n,c),r=Gl(null,r,u,!0,g,c)):(r.tag=0,Pe&&g&&yl(r),mt(null,r,m,c),r=r.child),r;case 16:u=r.elementType;e:{switch(io(n,r),n=r.pendingProps,m=u._init,u=m(u._payload),r.type=u,m=r.tag=rw(u),n=Ht(u,n),m){case 0:r=Vl(null,r,u,n,c);break e;case 1:r=hf(null,r,u,n,c);break e;case 11:r=af(null,r,u,n,c);break e;case 14:r=lf(null,r,u,Ht(u.type,n),c);break e}throw Error(s(306,u,""))}return r;case 0:return u=r.type,m=r.pendingProps,m=r.elementType===u?m:Ht(u,m),Vl(n,r,u,m,c);case 1:return u=r.type,m=r.pendingProps,m=r.elementType===u?m:Ht(u,m),hf(n,r,u,m,c);case 3:e:{if(ff(r),n===null)throw Error(s(387));u=r.pendingProps,g=r.memoizedState,m=g.element,Ch(n,r),Qr(r,u,null,c);var x=r.memoizedState;if(u=x.element,g.isDehydrated)if(g={element:u,isDehydrated:!1,cache:x.cache,pendingSuspenseBoundaries:x.pendingSuspenseBoundaries,transitions:x.transitions},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){m=zs(Error(s(423)),r),r=mf(n,r,u,c,m);break e}else if(u!==m){m=zs(Error(s(424)),r),r=mf(n,r,u,c,m);break e}else for(Ct=Ln(r.stateNode.containerInfo.firstChild),$t=r,Pe=!0,Wt=null,c=bh(r,null,u,c),r.child=c;c;)c.flags=c.flags&-3|4096,c=c.sibling;else{if(Ls(),u===m){r=yn(n,r,c);break e}mt(n,r,u,c)}r=r.child}return r;case 5:return Ah(r),n===null&&jl(r),u=r.type,m=r.pendingProps,g=n!==null?n.memoizedProps:null,x=m.children,fl(u,m)?x=null:g!==null&&fl(u,g)&&(r.flags|=32),uf(n,r),mt(n,r,x,c),r.child;case 6:return n===null&&jl(r),null;case 13:return pf(n,r,c);case 4:return Al(r,r.stateNode.containerInfo),u=r.pendingProps,n===null?r.child=Os(r,null,u,c):mt(n,r,u,c),r.child;case 11:return u=r.type,m=r.pendingProps,m=r.elementType===u?m:Ht(u,m),af(n,r,u,m,c);case 7:return mt(n,r,r.pendingProps,c),r.child;case 8:return mt(n,r,r.pendingProps.children,c),r.child;case 12:return mt(n,r,r.pendingProps.children,c),r.child;case 10:e:{if(u=r.type._context,m=r.pendingProps,g=r.memoizedProps,x=m.value,Re(Vr,u._currentValue),u._currentValue=x,g!==null)if(Ut(g.value,x)){if(g.children===m.children&&!gt.current){r=yn(n,r,c);break e}}else for(g=r.child,g!==null&&(g.return=r);g!==null;){var b=g.dependencies;if(b!==null){x=g.child;for(var C=b.firstContext;C!==null;){if(C.context===u){if(g.tag===1){C=kn(-1,c&-c),C.tag=2;var L=g.updateQueue;if(L!==null){L=L.shared;var U=L.pending;U===null?C.next=C:(C.next=U.next,U.next=C),L.pending=C}}g.lanes|=c,C=g.alternate,C!==null&&(C.lanes|=c),Cl(g.return,c,r),b.lanes|=c;break}C=C.next}}else if(g.tag===10)x=g.type===r.type?null:g.child;else if(g.tag===18){if(x=g.return,x===null)throw Error(s(341));x.lanes|=c,b=x.alternate,b!==null&&(b.lanes|=c),Cl(x,c,r),x=g.sibling}else x=g.child;if(x!==null)x.return=g;else for(x=g;x!==null;){if(x===r){x=null;break}if(g=x.sibling,g!==null){g.return=x.return,x=g;break}x=x.return}g=x}mt(n,r,m.children,c),r=r.child}return r;case 9:return m=r.type,u=r.pendingProps.children,_s(r,c),m=Rt(m),u=u(m),r.flags|=1,mt(n,r,u,c),r.child;case 14:return u=r.type,m=Ht(u,r.pendingProps),m=Ht(u.type,m),lf(n,r,u,m,c);case 15:return cf(n,r,r.type,r.pendingProps,c);case 17:return u=r.type,m=r.pendingProps,m=r.elementType===u?m:Ht(u,m),io(n,r),r.tag=1,vt(u)?(n=!0,Br(r)):n=!1,_s(r,c),Zh(r,u,m),Wl(r,u,m,c),Gl(null,r,u,!0,n,c);case 19:return vf(n,r,c);case 22:return df(n,r,c)}throw Error(s(156,r.tag))};function Ff(n,r){return yu(n,r)}function iw(n,r,c,u){this.tag=n,this.key=c,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ot(n,r,c,u){return new iw(n,r,c,u)}function fc(n){return n=n.prototype,!(!n||!n.isReactComponent)}function rw(n){if(typeof n=="function")return fc(n)?1:0;if(n!=null){if(n=n.$$typeof,n===Te)return 11;if(n===F)return 14}return 2}function Kn(n,r){var c=n.alternate;return c===null?(c=Ot(n.tag,r,n.key,n.mode),c.elementType=n.elementType,c.type=n.type,c.stateNode=n.stateNode,c.alternate=n,n.alternate=c):(c.pendingProps=r,c.type=n.type,c.flags=0,c.subtreeFlags=0,c.deletions=null),c.flags=n.flags&14680064,c.childLanes=n.childLanes,c.lanes=n.lanes,c.child=n.child,c.memoizedProps=n.memoizedProps,c.memoizedState=n.memoizedState,c.updateQueue=n.updateQueue,r=n.dependencies,c.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},c.sibling=n.sibling,c.index=n.index,c.ref=n.ref,c}function go(n,r,c,u,m,g){var x=2;if(u=n,typeof n=="function")fc(n)&&(x=1);else if(typeof n=="string")x=5;else e:switch(n){case G:return ds(c.children,m,g,r);case oe:x=8,m|=8;break;case Q:return n=Ot(12,c,r,m|2),n.elementType=Q,n.lanes=g,n;case ne:return n=Ot(13,c,r,m),n.elementType=ne,n.lanes=g,n;case ce:return n=Ot(19,c,r,m),n.elementType=ce,n.lanes=g,n;case ie:return vo(c,m,g,r);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case ke:x=10;break e;case Oe:x=9;break e;case Te:x=11;break e;case F:x=14;break e;case J:x=16,u=null;break e}throw Error(s(130,n==null?n:typeof n,""))}return r=Ot(x,c,r,m),r.elementType=n,r.type=u,r.lanes=g,r}function ds(n,r,c,u){return n=Ot(7,n,u,r),n.lanes=c,n}function vo(n,r,c,u){return n=Ot(22,n,u,r),n.elementType=ie,n.lanes=c,n.stateNode={isHidden:!1},n}function mc(n,r,c){return n=Ot(6,n,null,r),n.lanes=c,n}function pc(n,r,c){return r=Ot(4,n.children!==null?n.children:[],n.key,r),r.lanes=c,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}function ow(n,r,c,u,m){this.tag=r,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ua(0),this.expirationTimes=Ua(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ua(0),this.identifierPrefix=u,this.onRecoverableError=m,this.mutableSourceEagerHydrationData=null}function gc(n,r,c,u,m,g,x,b,C){return n=new ow(n,r,c,b,C),r===1?(r=1,g===!0&&(r|=8)):r=0,g=Ot(3,null,null,r),n.current=g,g.stateNode=n,g.memoizedState={element:u,isDehydrated:c,cache:null,transitions:null,pendingSuspenseBoundaries:null},El(g),n}function aw(n,r,c){var u=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:H,key:u==null?null:""+u,children:n,containerInfo:r,implementation:c}}function Uf(n){if(!n)return Pn;n=n._reactInternals;e:{if(Xn(n)!==n||n.tag!==1)throw Error(s(170));var r=n;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(vt(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(s(171))}if(n.tag===1){var c=n.type;if(vt(c))return ph(n,c,r)}return r}function Wf(n,r,c,u,m,g,x,b,C){return n=gc(c,u,!0,n,m,g,x,b,C),n.context=Uf(null),c=n.current,u=pt(),m=Wn(c),g=kn(u,m),g.callback=r??null,zn(c,g,m),n.current.lanes=m,gi(n,m,u),wt(n,u),n}function ko(n,r,c,u){var m=r.current,g=pt(),x=Wn(m);return c=Uf(c),r.context===null?r.context=c:r.pendingContext=c,r=kn(g,x),r.payload={element:n},u=u===void 0?null:u,u!==null&&(r.callback=u),n=zn(m,r,x),n!==null&&(Gt(n,m,x,g),qr(n,m,x)),x}function yo(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function Hf(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var c=n.retryLane;n.retryLane=c!==0&&c<r?c:r}}function vc(n,r){Hf(n,r),(n=n.alternate)&&Hf(n,r)}function lw(){return null}var Kf=typeof reportError=="function"?reportError:function(n){console.error(n)};function kc(n){this._internalRoot=n}wo.prototype.render=kc.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(s(409));ko(n,r,null,null)},wo.prototype.unmount=kc.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;as(function(){ko(null,n,null,null)}),r[fn]=null}};function wo(n){this._internalRoot=n}wo.prototype.unstable_scheduleHydration=function(n){if(n){var r=Cu();n={blockedOn:null,target:n,priority:r};for(var c=0;c<In.length&&r!==0&&r<In[c].priority;c++);In.splice(c,0,n),c===0&&Au(n)}};function yc(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function xo(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function Vf(){}function cw(n,r,c,u,m){if(m){if(typeof u=="function"){var g=u;u=function(){var L=yo(x);g.call(L)}}var x=Wf(r,u,n,0,null,!1,!1,"",Vf);return n._reactRootContainer=x,n[fn]=x.current,Ai(n.nodeType===8?n.parentNode:n),as(),x}for(;m=n.lastChild;)n.removeChild(m);if(typeof u=="function"){var b=u;u=function(){var L=yo(C);b.call(L)}}var C=gc(n,0,!1,null,null,!1,!1,"",Vf);return n._reactRootContainer=C,n[fn]=C.current,Ai(n.nodeType===8?n.parentNode:n),as(function(){ko(r,C,c,u)}),C}function jo(n,r,c,u,m){var g=c._reactRootContainer;if(g){var x=g;if(typeof m=="function"){var b=m;m=function(){var C=yo(x);b.call(C)}}ko(r,x,n,m)}else x=cw(c,r,n,m,u);return yo(x)}bu=function(n){switch(n.tag){case 3:var r=n.stateNode;if(r.current.memoizedState.isDehydrated){var c=pi(r.pendingLanes);c!==0&&(Wa(r,c|1),wt(r,We()),(Ne&6)===0&&(Us=We()+500,_n()))}break;case 13:as(function(){var u=vn(n,1);if(u!==null){var m=pt();Gt(u,n,1,m)}}),vc(n,1)}},Ha=function(n){if(n.tag===13){var r=vn(n,134217728);if(r!==null){var c=pt();Gt(r,n,134217728,c)}vc(n,134217728)}},$u=function(n){if(n.tag===13){var r=Wn(n),c=vn(n,r);if(c!==null){var u=pt();Gt(c,n,r,u)}vc(n,r)}},Cu=function(){return Ce},Tu=function(n,r){var c=Ce;try{return Ce=n,r()}finally{Ce=c}},Pa=function(n,r,c){switch(r){case"input":if(Ta(n,c),r=c.name,c.type==="radio"&&r!=null){for(c=n;c.parentNode;)c=c.parentNode;for(c=c.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<c.length;r++){var u=c[r];if(u!==n&&u.form===n.form){var m=Dr(u);if(!m)throw Error(s(90));mr(u),Ta(u,m)}}}break;case"textarea":su(n,c);break;case"select":r=c.value,r!=null&&ys(n,!!c.multiple,r,!1)}},hu=dc,fu=as;var dw={usingClientEntryPoint:!1,Events:[Mi,Es,Dr,du,uu,dc]},Gi={findFiberByHostInstance:Zn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},uw={bundleType:Gi.bundleType,version:Gi.version,rendererPackageName:Gi.rendererPackageName,rendererConfig:Gi.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:D.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=vu(n),n===null?null:n.stateNode},findFiberByHostInstance:Gi.findFiberByHostInstance||lw,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var So=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!So.isDisabled&&So.supportsFiber)try{yr=So.inject(uw),Zt=So}catch{}}return xt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=dw,xt.createPortal=function(n,r){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!yc(r))throw Error(s(200));return aw(n,r,null,c)},xt.createRoot=function(n,r){if(!yc(n))throw Error(s(299));var c=!1,u="",m=Kf;return r!=null&&(r.unstable_strictMode===!0&&(c=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onRecoverableError!==void 0&&(m=r.onRecoverableError)),r=gc(n,1,!1,null,null,c,!1,u,m),n[fn]=r.current,Ai(n.nodeType===8?n.parentNode:n),new kc(r)},xt.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var r=n._reactInternals;if(r===void 0)throw typeof n.render=="function"?Error(s(188)):(n=Object.keys(n).join(","),Error(s(268,n)));return n=vu(r),n=n===null?null:n.stateNode,n},xt.flushSync=function(n){return as(n)},xt.hydrate=function(n,r,c){if(!xo(r))throw Error(s(200));return jo(null,n,r,!0,c)},xt.hydrateRoot=function(n,r,c){if(!yc(n))throw Error(s(405));var u=c!=null&&c.hydratedSources||null,m=!1,g="",x=Kf;if(c!=null&&(c.unstable_strictMode===!0&&(m=!0),c.identifierPrefix!==void 0&&(g=c.identifierPrefix),c.onRecoverableError!==void 0&&(x=c.onRecoverableError)),r=Wf(r,null,n,1,c??null,m,!1,g,x),n[fn]=r.current,Ai(n),u)for(n=0;n<u.length;n++)c=u[n],m=c._getVersion,m=m(c._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[c,m]:r.mutableSourceEagerHydrationData.push(c,m);return new wo(r)},xt.render=function(n,r,c){if(!xo(r))throw Error(s(200));return jo(null,n,r,!1,c)},xt.unmountComponentAtNode=function(n){if(!xo(n))throw Error(s(40));return n._reactRootContainer?(as(function(){jo(null,null,n,!1,function(){n._reactRootContainer=null,n[fn]=null})}),!0):!1},xt.unstable_batchedUpdates=dc,xt.unstable_renderSubtreeIntoContainer=function(n,r,c,u){if(!xo(c))throw Error(s(200));if(n==null||n._reactInternals===void 0)throw Error(s(38));return jo(n,r,c,!1,u)},xt.version="18.3.1-next-f1338f8080-20240426",xt}var em;function _p(){if(em)return jc.exports;em=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),jc.exports=ww(),jc.exports}var tm;function xw(){if(tm)return No;tm=1;var e=_p();return No.createRoot=e.createRoot,No.hydrateRoot=e.hydrateRoot,No}var jw=xw(),y=wd();const Qn="teamtrail",Z={slug:Qn,npm:"teamtrail",name:"Teamtrail",category:"The trail map for AI coding agents",tagline:"You pick the destination. Your agents walk the trail.",assistant:{name:"Scout"},labelPrefix:Qn,dataDir:`.${Qn}`,apiPrefix:`/__${Qn}`,dataDirEnv:`${Qn.toUpperCase()}_DIR`,noRegisterEnv:`${Qn.toUpperCase()}_NO_REGISTER`,tokenEnv:`${Qn.toUpperCase()}_TOKEN`},ea=`${Qn}.prefs`,ta=e=>`${Z.labelPrefix}:${e}`,xd=ta("map"),jd=ta("hitl"),Sw=e=>e==="task"||e==="execute",Sd=ta("plan-only");function Dp(e){return/^[A-Za-z0-9_@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}const Nw=e=>e.map(Dp).join(" "),bw=/^\d+\.\d+\.\d+(-[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function $w(e){return bw.test(e)?`${Z.npm}@${e}`:Z.npm}function zp(e,t){return Nw(["npx","-y",$w(e),...t])}const _o=["research","prototype","junction","task","execute"],na=[..._o,"review"],gs="plan+execute",Cw=e=>e.filter(t=>!t.archived),Tw=["verifying","rework","blocked"],Nd=["off","checks","checks+review","checks+review+human"],Bp=e=>Nd.find(t=>t===e);function cr(e){return e.type==="junction"||e.type==="prototype"?"hitl":e.type==="research"?"afk":e.hitl?"hitl":"afk"}const Ew=["task","execute"];function Fp(e,t,s=gs){return e.state==="closed"?e.closeReason==="not_planned"?"out-of-scope":"decided":e.status==="verifying"?"verifying":e.status==="blocked"?"held":e.assignee?"claimed":e.status==="rework"?"rework":s==="plan-only"&&e.type==="execute"?"parked":e.blockedBy.some(a=>{var l;return((l=t.get(a))==null?void 0:l.state)==="open"})?"blocked":"frontier"}function ti(e,t=gs){const s=new Map(e.map(o=>[o.id,o]));return new Map(e.map(o=>[o.id,Fp(o,s,t)]))}const Ve=200,Qe=56;function nm(e,t="LR",s=gs){var Te;const o=t==="LR"?330:124,a=t==="LR"?112:262,l=ti(e,s),d=new Map(e.map(ne=>[ne.id,ne])),h=new Map,f=new Set,p=ne=>{if(h.has(ne))return h.get(ne);if(f.has(ne))return 0;f.add(ne);const ce=d.get(ne),F=ce&&ce.blockedBy.length?1+Math.max(...ce.blockedBy.filter(J=>d.has(J)).map(p),-1):0;return f.delete(ne),h.set(ne,F),F},v=e.filter(ne=>l.get(ne.id)!=="out-of-scope"),k=e.filter(ne=>l.get(ne.id)==="out-of-scope"),w=[];for(const ne of v)(w[Te=p(ne.id)]??(w[Te]=[])).push(ne);const j=[],N=new Map;let S=0;w.forEach(ne=>{ne&&(ne.sort((ce,F)=>{const J=ie=>{const W=ie.blockedBy.map(X=>N.get(X)).filter(X=>X!==void 0);return W.length?W.reduce((X,z)=>X+z,0)/W.length:ie.createdAt/1e12};return J(ce)-J(F)||ce.createdAt-F.createdAt}),S=Math.max(S,ne.length),ne.forEach((ce,F)=>N.set(ce.id,F)))}),w.forEach((ne,ce)=>{if(!ne)return;const F=(S-ne.length)*a/2;ne.forEach((J,ie)=>{const W=ce*o,X=F+ie*a;j.push({ticket:J,state:l.get(J.id),layer:ce,x:t==="LR"?W:X,y:t==="LR"?X:W})})});const $=Math.max(w.length,1)*o-(o-(t==="LR"?Ve:Qe)),_=Math.max(S,1)*a-(a-(t==="LR"?Qe:Ve)),O=t==="LR"?$:_,D=t==="LR"?_:$,q=D+54,H=Math.max(1,Math.floor((O+24)/(Ve+24)));k.forEach((ne,ce)=>{j.push({ticket:ne,state:"out-of-scope",layer:-1,x:ce%H*(Ve+24),y:q+Math.floor(ce/H)*(Qe+16)})});const G=[],oe=new Map(j.map(ne=>[ne.ticket.id,ne]));for(const ne of j)for(const ce of ne.ticket.blockedBy){const F=oe.get(ce);F&&G.push({from:F,to:ne})}const Q=Math.ceil(k.length/H),ke=Math.max(O,Math.min(k.length,H)*(Ve+24)-24),Oe=k.length?q+Q*(Qe+16)-16:D;return{direction:t,nodes:j,edges:G,width:ke,graphH:D,quarantineY:q,height:Oe,quarantineH:Q*(Qe+16)+24}}const Do=["fast","balanced","strongest"],sm="balanced",Aw=[["*-mini","fast"],["*-mini-*","fast"],["*-nano","fast"],["*-nano-*","fast"],["*claude-haiku-*","fast"],["*claude-3*-haiku*","fast"],["*claude-opus-*","strongest"],["*claude-3*-opus*","strongest"],["*claude-fable-*","strongest"],["*claude-sonnet-*","balanced"],["*claude-3*-sonnet*","balanced"],["gpt-5*","strongest"],["o1","strongest"],["o1-*","strongest"],["o3","strongest"],["o3-*","strongest"],["o4-*","strongest"],["gpt-4*","balanced"]],Up=e=>Do.includes(e),bd={research:"fast",task:"balanced",execute:"balanced",junction:"strongest",prototype:"strongest",review:"strongest"};function Iw(e,t){var a,l;const s=(l=(a=t.modelMatching)==null?void 0:a.tiers)==null?void 0:l[e.type],o=bd[e.type];return t.settingsUnconfirmed&&s?Do.indexOf(s)>=Do.indexOf(o)?s:o:s??o}function im(e){return Object.fromEntries(na.map(t=>[t,Iw({type:t},e)]))}const Rw=e=>e!=="__proto__"&&e!=="constructor"&&e!=="prototype",Mw=64;function Lw(e,t){const s=[];for(let o=0;o<e.length;o++){const a=e[o];if(a!=="*"&&!(a==="?"&&t))s.push({kind:"char",c:a});else if(a==="?")s.push({kind:"one"});else if(!t||e[o+1]!=="*")s.push({kind:t?"star":"deep"});else{const l=e[o+2]==="/";o+=l?2:1,s.push({kind:l?"dirs":"deep"})}}return Ow(s)}function Ow(e){const t=[];for(const s of e){const o=t.at(-1);(o==null?void 0:o.kind)==="dirs"&&s.kind==="dirs"||(o==null?void 0:o.kind)==="deep"&&(s.kind==="deep"||s.kind==="dirs")||((o==null?void 0:o.kind)==="dirs"&&s.kind==="deep"?t[t.length-1]=s:t.push(s))}return t}function Pw({t:e,c:t,inText:s,next:o,cur:a,j:l}){switch(e.kind){case"char":return s&&t===e.c?o[l+1]:0;case"one":return s&&t!=="/"?o[l+1]:0;case"star":return o[l]||(s&&t!=="/"?a[l+1]:0);case"deep":return o[l]||(s?a[l+1]:0);case"dirs":return 0;default:return e}}function _w(e,t,s){const o=s.length,a=new Uint8Array(o+1);let l=0;for(let d=o;d>=0;d--){const h=d<o,f=h?s[d]:"";if(e.kind!=="dirs"){a[d]=Pw({t:e,c:f,inText:h,next:t,cur:a,j:d});continue}f==="/"&&t[d+1]&&(l=1),a[d]=t[d]||l}return a}function Wp(e,t,s){const o=Lw(e,s.segments);if(o.filter(l=>l.kind!=="char").length>Mw)return!1;let a=new Uint8Array(t.length+1);a[t.length]=1;for(let l=o.length-1;l>=0;l--)a=_w(o[l],a,t);return a[0]===1}function rm(e,t){return Wp(e.trim().toLowerCase(),t.trim().toLowerCase(),{segments:!1})}function Dw(e,t={}){const s=e==null?void 0:e.trim();if(!s)return{tier:sm,source:"unknown",reason:"no model reported, so it counts as balanced"};const a=Object.entries(t).find(([d])=>d.trim().toLowerCase()===s.toLowerCase())??Object.entries(t).find(([d])=>rm(d,s));if(a)return{tier:a[1],model:s,source:"project",reason:`${s} is ${a[1]} in models.json`};const l=Aw.find(([d])=>rm(d,s));return l?{tier:l[1],model:s,source:"built-in",reason:`${s} is a ${l[1]} model`}:{tier:sm,model:s,source:"unknown",reason:`${s} is not a known model, so it counts as balanced`}}const zw=["holding","challenged","invalidated","confirmed"],Bw=e=>zw.includes(e),Fw=Z.labelPrefix,Jc=" -->",Uw=7e4,Hp=e=>`<!-- ${Fw}:${e} `,Ww=e=>JSON.stringify(e).replace(/--/g,"-\\u002d"),Hw=(e,t)=>`${Hp(e)}${t}${Jc}`;function Kw(e,t){const s=e.trimEnd();if(!s.endsWith(Jc))return;const o=Hp(t),a=s.lastIndexOf(o);if(!(a===-1||s.length-a>Uw))return{before:s.slice(0,a),payload:s.slice(a+o.length,-Jc.length)}}const Vw=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/,Gw=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]+/g,qw=/\r\n|[\r\u0085\u2028\u2029]/g,Qw=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/g,Yw=e=>Vw.test(e),hs=e=>e.replace(Gw," ").trim(),Jw=e=>e.replace(qw,`
|
|
41
41
|
`).replace(Qw,"");function sa(e,t){const s=new RegExp(`^\\\\*(?:${t})`);return Jw(e).trim().split(`
|
|
42
42
|
`).map(o=>s.test(o)?`\\${o}`:o).join(`
|
|
43
43
|
`)}function zo(e,t){const s=new RegExp(`^\\\\+(?:${t})`);return e.split(`
|
|
@@ -61,10 +61,10 @@ ${t(e.outOfScope)}`].join(`
|
|
|
61
61
|
|
|
62
62
|
`)+`
|
|
63
63
|
`}function dx(e){var o;const t={destination:"",notes:"",decisions:[],unspecified:[],outOfScope:[]},s=e.split(/^##\s+/m).slice(1);for(const a of s){const l=a.indexOf(`
|
|
64
|
-
`),d=a.slice(0,l===-1?void 0:l).trim().toLowerCase(),h=(l===-1?"":a.slice(l+1)).trim(),f=(o=Gp.find(([,
|
|
65
|
-
`).map(
|
|
64
|
+
`),d=a.slice(0,l===-1?void 0:l).trim().toLowerCase(),h=(l===-1?"":a.slice(l+1)).trim(),f=(o=Gp.find(([,k])=>k.toLowerCase()===d))==null?void 0:o[0];if(!f)continue;const p=/^_none yet\._$/i.test(h),v=p?[]:h.split(`
|
|
65
|
+
`).map(k=>k.trim()).filter(k=>k.startsWith("- "));f==="destination"?t.destination=am(h):f==="notes"?t.notes=p?"":am(h):f==="assumptions"?t.assumptions=sx(v):f==="decisions"?t.decisions=v.map(k=>{const w=k.match(lx);return w&&w[1]&&/\d/.test(w[1])?{ticketKey:w[1],text:Gs(w[2])}:{text:Gs(k.slice(2))}}):t[f]=v.map(k=>Gs(k.slice(2)))}return t}const ra={chart:["Name destination","Find frontier","Create trail","Create tickets + wire blocking","Fire research"],work:["Load trail","Claim","Resolve","Record","Update plan"],research:["Claim","Investigate","Record"]},ux=(e,t)=>`${e[0].toUpperCase()}${e.slice(1)} ${t}/${ra[e].length}`;async function hx(e,t,s={}){var d,h,f;const o=fx(t,t.mode??gs),a=await e.createMap({title:o.title,mode:o.mode,sections:o.sections,...o.verification?{verification:o.verification}:{}});await((d=s.onMapCreated)==null?void 0:d.call(s,a));const l=new Map;for(const p of o.tickets){const v=await e.createTicket(a.id,{title:p.title,type:p.type,hitl:p.hitl,body:`${p.body}
|
|
66
66
|
|
|
67
|
-
Part of trail ${a.key}.`});l.set(p.ref,
|
|
67
|
+
Part of trail ${a.key}.`});l.set(p.ref,v),await((h=s.onTicketCreated)==null?void 0:h.call(s,v,p.ref))}for(const p of o.tickets)for(const v of p.blockedBy??[]){const k=l.get(v),w=l.get(p.ref);k&&(await e.addBlocking(a.id,k.id,w.id),await((f=s.onEdgeWired)==null?void 0:f.call(s,k,w)))}return{map:a,tickets:[...l.values()]}}function fx(e,t){if(t==="plan+execute")return{...e,mode:t};const s=new Map(e.tickets.filter(a=>a.type==="execute").map(a=>[a.ref,a.blockedBy??[]])),o=a=>a.flatMap(l=>s.has(l)?o(s.get(l)):[l]);return{...e,mode:t,tickets:e.tickets.filter(a=>!s.has(a.ref)).map(a=>({...a,blockedBy:[...new Set(o(a.blockedBy??[]))]}))}}class Ae extends Error{}function Qp(e){if(e.archived)throw new Ae(`Trail ${e.key} "${e.title}" is archived: no work is taken from it. Only the trail lead can restore it in the Lookout.`)}class mx{constructor(){le(this,"tails",new Map)}run(t,s){const a=(this.tails.get(t)??Promise.resolve()).catch(()=>{}).then(s);return this.tails.set(t,a),a.finally(()=>this.tails.get(t)===a&&this.tails.delete(t)).catch(()=>{}),a}}const px={frontier:"ready",blocked:"backlog",parked:"backlog",claimed:"working",verifying:"verifying",rework:"rework",held:"blocked",decided:"done","out-of-scope":"cancelled"};function gx(e,t,s=gs){return px[Fp(e,t,s)]}const vx=["backlog","ready","working","verifying","rework","blocked"],Qi=["agent","trail lead"],kx=[{event:"claim",from:["ready","rework"],to:["working"],actors:Qi},{event:"release",from:["working"],to:["ready","rework"],actors:Qi},{event:"expire",from:["working"],to:["ready","rework"],actors:["engine","trail lead"]},{event:"complete",from:["backlog","ready","working","rework"],to:["done"],actors:Qi},{event:"submit",from:["working"],to:["verifying"],actors:Qi},{event:"checks.pass",from:["verifying"],to:["verifying","done"],actors:["engine"]},{event:"checks.fail",from:["verifying"],to:["rework","blocked"],actors:["engine"]},{event:"checks.error",from:["verifying"],to:["blocked"],actors:["engine"]},{event:"reverify",from:["verifying"],to:["verifying"],actors:["engine","trail lead"]},{event:"review.pass",from:["verifying"],to:["verifying","done"],actors:["engine"]},{event:"review.fail",from:["verifying"],to:["rework"],actors:["engine"]},{event:"review.needs_human",from:["verifying"],to:["blocked"],actors:["engine"]},{event:"approve",from:["verifying"],to:["done"],actors:["trail lead"]},{event:"reject",from:["verifying","blocked"],to:["rework"],actors:["trail lead"]},{event:"accept",from:["verifying","blocked"],to:["done"],actors:["trail lead"]},{event:"unblock",from:["blocked"],to:["ready","rework","verifying"],actors:["trail lead"]},{event:"cancel",from:vx,to:["cancelled"],actors:[...Qi,"engine"]},{event:"reopen",from:["done","cancelled"],to:["ready"],actors:["trail lead"]}],yx=e=>kx.find(t=>t.event===e),wx=new mx;function xx(e,t,s){if(s){if(!e.to.includes(s))throw new Ae(`${e.event} cannot lead to ${s}`);return s}if(e.to.length===1)return e.to[0];if(e.event==="release"||e.event==="expire")return t.status==="rework"?"rework":"ready";throw new Ae(`${e.event} needs a target: ${e.to.join(" or ")}`)}async function jx(e,t,s,o){const{to:a,actor:l}=o,d=async h=>{(s.status??null)!==h&&await e.setMeta(t,s.id,{status:h})};switch(a){case"working":s.assignee!==l&&await e.assign(t,s.id,l);return;case"ready":case"rework":s.state==="closed"&&await e.reopen(t,s.id),await d(a==="rework"?"rework":null),s.assignee&&await e.assign(t,s.id,null);return;case"verifying":case"blocked":await d(a);return;case"done":case"cancelled":await d(null),await e.close(t,s.id,a==="done"?"completed":"not_planned");return;case"backlog":throw new Ae("backlog follows from blockers; no transition leads there")}}function oa(e,t,s,o){return wx.run(`${t}/${s}`,async()=>{var p;const a=await e.loadMap(t),l=a.tickets.find(v=>v.id===s);if(!l)throw new Ae(`ticket ${s} not found`);const d=gx(l,new Map(a.tickets.map(v=>[v.id,v])),a.map.mode);if(o.expect&&d!==o.expect)throw new Ae(`${l.key} changed: it is ${d} now`);const h=yx(o.event);if(!h.from.includes(d))throw new Ae(`${l.key} is ${d}; ${o.event} needs ${h.from.join(" or ")}`);if(!h.actors.includes(o.actorKind))throw new Ae(`${o.event} is not for ${o.actorKind}s`);const f=xx(h,l,o.to);await jx(e,t,l,{to:f,actor:o.actor});try{await((p=o.journal)==null?void 0:p.append({v:1,kind:"transition",at:Date.now(),mapId:t,ticketId:s,ticketKey:l.key,event:o.event,from:d,to:f,actor:o.actor,actorKind:o.actorKind,...o.reason?{reason:o.reason}:{},...o.sessionId?{sessionId:o.sessionId}:{}}))}catch{}return{ticket:l,from:d,to:f}})}async function cm(e,t,s,o){const{assignee:a}=o,l=await e.loadMap(t),d=l.tickets.find(v=>v.id===s);if(!d)throw new Ae(`ticket ${s} not found`);Qp(l.map);const h=ti(l.tickets,l.map.mode).get(s);if(h!=="frontier"&&h!=="rework")throw new Ae(`${d.key} is ${h}, not on the frontier`);await oa(e,t,s,{event:"claim",actor:a,actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal});const p=(await e.loadMap(t)).tickets.find(v=>v.id===s);if(p.assignee!==a)throw new Ae(`${d.key} was claimed by ${p.assignee}`);return p}async function Sx(e,t,s,o={}){const l=(await e.loadMap(t)).tickets.find(d=>d.id===s);if(!l)throw new Ae(`ticket ${s} not found`);await oa(e,t,s,{event:"release",actor:o.actor??l.assignee??"trail lead",actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal})}const Yp=e=>e==="lookout",Nx=e=>e.via==="chat"?`in ${e.chatOf??"an agent"}'s chat`:void 0;function bx(e){return e.via?e.via==="chat"&&e.chatOf?{via:e.via,chatOf:e.chatOf}:{via:e.via}:{}}function Jp(e,t){return t==="lookout-limited"?`${e} is high risk: ask someone allowed to make high-risk calls.`:`${e} is high risk: decide it in the Lookout. Answers given in Slack don't count for it.`}async function Bo(e,t){const s=e.via??(e.sourceKind==="slack"?"slack":void 0);if(!s||Yp(s)||!t.ticketId)return;const o=t.key??t.ticketId,a=s==="lookout-limited"?"ask someone allowed to make high-risk calls":"decide it in the Lookout";if(!e.highRisk)throw new Ae(`Can't tell whether ${o} is high risk: ${a}.`);if(await e.highRisk(t.mapId,t.ticketId))throw new Ae(Jp(o,s))}async function $x(e,t){var d;const{mapId:s,old:o,next:a}=t;await Bo(e,{mapId:s,ticketId:o.ticketId,key:o.ticketKey??o.id}),a.ticketId&&a.ticketId!==o.ticketId&&await Bo(e,{mapId:s,ticketId:a.ticketId,key:a.ticketKey});const l=e.via??(e.sourceKind==="slack"?"slack":void 0);if(l&&!Yp(l)&&((d=o.risk)==null?void 0:d.level)==="high")throw new Ae(Jp(o.id,l))}async function $d(e,t,s,o={}){if(await Bo({...o.guard,sourceKind:s.source.kind},{mapId:t,ticketId:s.ticketId,key:s.ticketKey}),s.source.ref){const l=(await e.listDecisions(t)).find(d=>!d.postedBy&&d.source.kind===s.source.kind&&d.source.ref===s.source.ref);if(l)return l}const a=await e.createDecision(t,s);if(o.appendToTrail??!0){const l=await e.loadMap(t);await e.updateMapSections(t,{decisions:[...l.map.sections.decisions,{ticketId:a.ticketId,ticketKey:a.ticketKey,text:o.trailLine??a.summary}]})}return a}async function Cx(e,t,s,{guard:o,...a}){const d=(await e.listDecisions(t)).find(j=>j.id===s);if(!d)throw new Ae(`decision ${s} not found`);if(d.postedBy)throw new Ae(`${d.id} is ${d.postedBy}'s decision; record your own instead`);if(d.supersededBy)throw new Ae(`${d.id} is already superseded by ${d.supersededBy}`);const h={ticketId:d.ticketId,ticketKey:d.ticketKey,...a,question:a.question??d.question,supersedes:d.id};await $x({...o,sourceKind:a.source.kind},{mapId:t,old:d,next:h});const f=await e.createDecision(t,h);await e.markSuperseded(t,d.id,f.id);const v=(await e.loadMap(t)).map.sections.decisions,k=v.findIndex(j=>j.text===d.summary||!!d.ticketId&&j.ticketId===d.ticketId||!!d.ticketKey&&j.ticketKey===d.ticketKey),w={ticketId:f.ticketId,ticketKey:f.ticketKey,text:f.summary};return await e.updateMapSections(t,{decisions:k<0?[...v,w]:v.map((j,N)=>N===k?w:j)}),f}async function Tx(e,t,s){await e.setMapMode(t,s)}function Xp(e){return e==="plan-only"?_o.filter(t=>t!=="execute"):_o}function Ex(e,t){if(!Xp(e).includes(t))throw new Ae(`${t} tickets are disabled on plan-only maps`)}const Jn={lookout:{label:"Lookout",code:"CMD"},agent:{label:"Agent",code:"AGT"},slack:{label:"Slack",code:"SLK"},tracker:{label:"Tracker",code:"TRK"}},Fo=Object.keys(Jn),Ax=e=>e in Jn,Zp=" (unverified, from text)";function rr(e){return e.derived||e.decidedBy.endsWith(Zp)?"unverified":e.postedBy?"teammate":e.source.kind==="agent"&&e.decidedBy!=="trail lead"&&!e.decidedBy.startsWith("slack:")?"agent":"human"}const eg=e=>e.postedBy?`posted by ${e.postedBy} in ${e.postedIn??"the tracker"}`:void 0,dr=e=>e.supersededBy?"superseded":"active";function aa(e){const t=e.replace(/\s+/g," ").trim(),s=t.match(/^(.{20,180}?[.!?])(\s|$)/);return s?s[1]:t.slice(0,180)}function Ix(e,t,s){var o;return{...s,id:e,mapId:t,decidedAt:s.decidedAt??Date.now(),summary:((o=s.summary)==null?void 0:o.trim())||aa(s.answer),alternatives:s.alternatives??[],rationale:s.rationale??"",participants:s.participants??[{id:s.decidedBy}],transcript:s.transcript??[]}}const Rx=e=>Number(e.replace(/\D/g,""))||0;function Mx(e,t){const s=new Map(e.map(d=>[d.id,d])),o=new Set;let a=s.get(t);for(;a!=null&&a.supersedes&&s.has(a.supersedes)&&!o.has(a.id);)o.add(a.id),a=s.get(a.supersedes);const l=[];o.clear();for(let d=a;d&&!o.has(d.id);d=d.supersededBy?s.get(d.supersededBy):void 0)o.add(d.id),l.push(d);return l}async function Lx(e,t,s,o){var d,h;const l=(await e.loadMap(t)).tickets.find(f=>f.id===s);if(!l)throw new Ae(`ticket ${s} not found`);if(l.state==="closed")throw new Ae(`${l.key} is already closed`);return await Bo({...o.guard,sourceKind:(h=(d=o.decision)==null?void 0:d.source)==null?void 0:h.kind},{mapId:t,ticketId:l.id,key:l.key}),o.transcript&&await e.comment(t,s,o.author,`**HITL transcript**
|
|
68
68
|
|
|
69
69
|
${o.transcript}`),await e.comment(t,s,o.author,`**Resolution**
|
|
70
70
|
|
|
@@ -75,7 +75,7 @@ Part of trail ${a.map.key}.`});for(const h of o.blockedBy??[])await e.addBlockin
|
|
|
75
75
|
${o.reason}`),await oa(e,t,h.id,{event:"cancel",actor:o.author,actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal}),await $d(e,t,{ticketId:h.id,ticketKey:h.key,question:h.title,answer:`Out of scope: ${o.reason}`,decidedBy:o.author,source:o.source??{kind:"agent",label:o.author}},{appendToTrail:!1});const f=await e.loadMap(t);await e.updateMapSections(t,{outOfScope:[...f.map.sections.outOfScope,`${h.key} ${h.title} — ${o.reason}`]})}async function Dx(e,t,s,o){s&&zx(s),await e.setMapMeta(t,{modelMatching:s&&Bx(s),confirm:!0})}function zx(e){if(typeof e.enabled!="boolean")throw new Ae('"enabled" must be true or false');for(const[t,s]of Object.entries(e.tiers??{})){if(!na.includes(t))throw new Ae(`unknown ticket type "${t}"`);if(!Up(s))throw new Ae(`"${t}" must be fast, balanced or strongest`)}}function Bx(e){const t=Object.fromEntries(Object.entries(e.tiers??{}).filter(([,s])=>s));return Object.keys(t).length?{enabled:e.enabled,tiers:t}:{enabled:e.enabled}}async function Fx(e,t,s,o){await e.setMapArchived(t,s)}function Ux(e){return{async append(t){await fetch(`${e}/journal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}}}const tg={v:1,default:"checks",appliesTo:["execute","task"],checks:{},run:[],failFast:!0,maxAttempts:3,totalTimeoutSec:1800,noChanges:{allow:["research","junction","prototype"],else:"flag"},scope:"flag",stale:"reverify",github:{enabled:"auto",requiredChecks:[],pollSec:60}};new Set(Object.keys(tg));const Wx=2*6e4,bc=e=>e<6e4?`${Math.round(e/1e3)}s`:`${Math.round(e/6e4)}m`;function Hx(e,t){if(!e)return{tone:"unknown",label:"PR sync ?",title:"PR/CI sync state unavailable"};const s=e.repo?` · ${e.repo}`:"",o=e.lastOkAt?`last ok ${bc(t-e.lastOkAt)} ago`:"never synced";return e.state==="off"?{tone:"off",label:"PR sync off",title:`PR/CI sync off: ${e.reason??"disabled"}`}:e.state==="failed"?{tone:"failed",label:"PR sync failed",title:`${e.reason??"sync failed"}${s}
|
|
76
76
|
${o}`}:e.state==="rate-limited"?{tone:"failed",label:"PR sync paused",title:`Rate limited${s}; retrying ${e.nextAt?`in ${bc(Math.max(0,e.nextAt-t))}`:"later"}
|
|
77
77
|
${o}`}:!e.lastOkAt||e.lastOkAt!==e.lastAttemptAt||e.nextAt!==void 0&&t>e.nextAt+Wx?{tone:"stale",label:"PR sync stale",title:`No recent sync${s}
|
|
78
|
-
${o}`}:{tone:"ok",label:`PR sync ${bc(t-e.lastOkAt)}`,title:`PR/CI synced${s}, ${o}`}}class Qs{constructor(){le(this,"listeners",new Set)}on(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t){for(const s of[...this.listeners])s(t)}}let Kx=0;const Oo=(e="id")=>`${e}_${Date.now().toString(36)}${(Kx++).toString(36)}`,Xc=(e,t)=>({inputTokens:((e==null?void 0:e.inputTokens)??0)+t.inputTokens,outputTokens:((e==null?void 0:e.outputTokens)??0)+t.outputTokens,costUsd:((e==null?void 0:e.costUsd)??0)+t.costUsd,...e!=null&&e.cachedInputTokens||t.cachedInputTokens?{cachedInputTokens:((e==null?void 0:e.cachedInputTokens)??0)+(t.cachedInputTokens??0)}:{}}),ng=(e,t)=>({inputTokens:e.inputTokens-((t==null?void 0:t.inputTokens)??0),outputTokens:e.outputTokens-((t==null?void 0:t.outputTokens)??0),costUsd:e.costUsd-((t==null?void 0:t.costUsd)??0),...e.cachedInputTokens||t!=null&&t.cachedInputTokens?{cachedInputTokens:(e.cachedInputTokens??0)-((t==null?void 0:t.cachedInputTokens)??0)}:{}});function Vx(e,t,s){const o=()=>e.find(t.id)??t,a=l=>e.push({source:"session",sessionId:t.id,agent:t.agent,...l});return{id:t.id,get info(){return o()},step(l,d,h){const f=ra[s][l-1];e.patchSession(t.id,{step:l,stepLabel:f,...h?{ticketId:h}:{}}),a({tag:ux(s,l),level:"step",text:d?`${f}: ${d}`:f,ticketId:h??o().ticketId})},log(l,d="info",h){a({level:d,text:l,ticketId:o().ticketId,...h?{kind:h}:{}})},say(l){e.chat({sessionId:t.id,ticketId:o().ticketId,from:"agent",author:t.agent,text:l})},ask(l,d,h){var p;const f={id:Oo("q"),sessionId:t.id,mapId:t.mapId,ticketId:o().ticketId,agent:t.agent,text:l,suggestions:d,at:Date.now(),...h!=null&&h.urgency?{urgency:h.urgency}:{},...(p=h==null?void 0:h.blocks)!=null&&p.length?{blocks:h.blocks}:{}};return e.chat({sessionId:t.id,ticketId:f.ticketId,from:"agent",author:t.agent,text:l,questionId:f.id}),e.addPending(f),e.patchSession(t.id,{waitingOn:f.id}),a({level:"alert",kind:"asks-you",ticketId:f.ticketId,text:"Decision request · waiting on you",signal:!0}),e.awaitAnswer(f.id)},done(l=!0,d,h){e.patchSession(t.id,{status:l?"done":"failed",endedAt:Date.now(),waitingOn:void 0}),e.dropPending(t.id),a({level:l?"ok":"alert",text:d??(l?"Session closed":"Session aborted"),signal:h==null?void 0:h.signal,...h!=null&&h.kind?{kind:h.kind}:{}})},bindMap(l){var h;const d=o().usage;d&&(e.addMapUsage(l,d),(h=e.ledger())==null||h.add(l,d,t.id)),e.patchSession(t.id,{mapId:l})},usage(l){var f;const d=o().mapId;(f=e.ledger())==null||f.add(d,l,t.id),e.addMapUsage(d,l);const h=o().usage;e.patchSession(t.id,{usage:{...Xc(h,l),source:l.source??(h==null?void 0:h.source)}})},setUsage(l){var k;const d=o().usage,h=ng(l,d);if(!h.inputTokens&&!h.outputTokens&&!h.costUsd&&!h.cachedInputTokens&&(d==null?void 0:d.source)===l.source&&`${d==null?void 0:d.models}`==`${l.models}`)return;const p=o().mapId;(h.inputTokens>0||h.outputTokens>0||h.costUsd>0)&&((k=e.ledger())==null||k.add(p,h,t.id)),e.addMapUsage(p,h),e.patchSession(t.id,{usage:l})},setModel(l,d){const h=o();h.model===l&&h.tier===d||e.patchSession(t.id,{model:l,tier:d})}}}class Gx{constructor(t=400,s){le(this,"state",{sessions:[],feed:[],chats:[],pending:[],answered:[],usageByMap:{}});le(this,"changes",new Qs);le(this,"resolvers",new Map);le(this,"remote",new Map);le(this,"remoteAnswer");le(this,"host",{find:t=>this.state.sessions.find(s=>s.id===t),patchSession:(t,s)=>this.patchSession(t,s),push:t=>void this.push(t),chat:t=>this.chat(t),addPending:t=>this.set({pending:[...this.state.pending,t]}),dropPending:t=>{this.state.pending.filter(o=>o.sessionId===t).length&&this.set({pending:this.state.pending.filter(o=>o.sessionId!==t)})},awaitAnswer:t=>new Promise(s=>this.resolvers.set(t,s)),addMapUsage:(t,s)=>{this.state={...this.state,usageByMap:{...this.state.usageByMap,[t]:Xc(this.state.usageByMap[t],s)}}},ledger:()=>this.ledger});this.maxFeed=t,this.ledger=s}get snapshot(){return this.state}subscribe(t){return this.changes.on(t)}set(t){this.state={...this.state,...t},this.changes.emit(this.state)}push(t){const s={id:Oo("f"),at:t.at??Date.now(),...t};return s.source==="system"&&!s.agent&&(s.agent=Z.assistant.name),this.set({feed:[...this.state.feed,s].slice(-this.maxFeed)}),s}patchSession(t,s){this.set({sessions:this.state.sessions.map(o=>o.id===t?{...o,...s}:o)})}chat(t){this.set({chats:[...this.state.chats,{id:Oo("m"),at:Date.now(),...t}].slice(-600)})}answer(t,s,o,a){var k;const l=this.state.pending.find(v=>v.id===t),d=this.resolvers.get(t),h=!!l&&this.remote.has(l.sessionId)&&!!this.remoteAnswer;if(!l||!d&&!h)return!1;this.resolvers.delete(t);const f=bx(a),p=a.by?{by:a.by}:{};return this.chat({sessionId:l.sessionId,ticketId:l.ticketId,from:"human",author:o,text:s,...f,...p}),this.set({pending:this.state.pending.filter(v=>v.id!==t),answered:[...this.state.answered,{id:l.id,mapId:l.mapId,sessionId:l.sessionId,agent:l.agent,askedAt:l.at,answeredAt:Date.now(),...l.ticketId?{ticketId:l.ticketId}:{},...l.category?{category:l.category}:{},...(k=l.categories)!=null&&k.length?{categories:l.categories}:{},...l.urgency?{urgency:l.urgency}:{},...f,...p}].slice(-200)}),this.patchSession(l.sessionId,{waitingOn:void 0}),this.push({source:"trail lead",agent:o,level:"ok",kind:"answered",ticketId:l.ticketId,sessionId:l.sessionId,text:`Answered ${l.agent}`}),d?d(s):this.remoteAnswer(l,s,o),!0}syncRemote(t){var p;const{session:s}=t,o=s.id;if(!this.remote.has(o)&&this.state.sessions.some(k=>k.id===o))return;const a=this.remote.get(o);this.remote.set(o,s.mapId?s.usage:a);let l=this.state.usageByMap;if(s.usage&&s.mapId){const k=ng(s.usage,a);(k.inputTokens||k.outputTokens||k.costUsd)&&(l={...l,[s.mapId]:Xc(l[s.mapId],k)}),(p=this.ledger)==null||p.addTotal(s.mapId,o,s.usage)}const d=k=>k.filter(v=>v.sessionId!==o),h=new Set(this.state.answered.map(k=>k.id)),f=this.state.sessions.some(k=>k.id===o)?this.state.sessions.map(k=>k.id===o?s:k):[...this.state.sessions,s].slice(-24);this.set({sessions:f,chats:[...d(this.state.chats),...t.chats].sort((k,v)=>k.at-v.at).slice(-600),pending:[...d(this.state.pending),...t.pending],answered:[...this.state.answered,...t.answered.filter(k=>!h.has(k.id))].sort((k,v)=>k.answeredAt-v.answeredAt).slice(-200),feed:[...this.state.feed.filter(k=>k.sessionId!==o),...t.feed].sort((k,v)=>k.at-v.at).slice(-this.maxFeed),usageByMap:l})}isRemote(t){return this.remote.has(t)}startSession(t){const s={...t,id:t.id??Oo("s"),step:0,total:ra[t.mode].length,stepLabel:"BOOT",status:"running",startedAt:Date.now()};this.set({sessions:[...this.state.sessions,s].slice(-24)});const o=Vx(this.host,s,t.mode);return this.push({source:"session",sessionId:s.id,agent:s.agent,level:"info",text:`Session opened · ${t.mode}`}),o}}function qx(e,t){const s=o=>{var a;return((a=t(o))==null?void 0:a.key)??o};switch(e.kind){case"map.created":return{source:"tracker",level:"ok",text:`Trail created · label ${xd}`};case"map.updated":return{source:"tracker",level:"info",text:`Trail updated${e.section?` · ${ax[e.section].toLowerCase()}`:""}`};case"map.mode":return{source:"tracker",level:"warn",text:`Trail mode · ${e.mode}`};case"ticket.created":return{source:"tracker",level:"info",ticketId:e.ticketId,text:`Opened ${s(e.ticketId)}`};case"ticket.claimed":return{source:"tracker",level:"warn",ticketId:e.ticketId,text:`Assigned ${s(e.ticketId)} to ${e.assignee}`};case"ticket.released":return{source:"tracker",level:"info",ticketId:e.ticketId,text:`Unassigned ${s(e.ticketId)}`};case"ticket.closed":return{source:"tracker",level:e.reason==="completed"?"ok":"alert",...e.reason==="completed"?{kind:"done"}:{},ticketId:e.ticketId,text:`Closed ${s(e.ticketId)} · ${e.reason==="completed"?"completed":"not planned"}`};case"ticket.commented":return{source:"tracker",level:"info",ticketId:e.ticketId,text:`Comment on ${s(e.ticketId)}`};case"edge.added":return{source:"tracker",level:"info",ticketId:e.blockedId,text:`${s(e.blockerId)} blocks ${s(e.blockedId)}`};case"edge.removed":return{source:"tracker",level:"info",ticketId:e.blockedId,text:`${s(e.blockerId)} no longer blocks ${s(e.blockedId)}`};case"decision.recorded":return{source:"tracker",level:"ok",ticketId:e.ticketId,text:`Decision ${e.decisionId} recorded${e.ticketId?` · ${s(e.ticketId)}`:""}`};case"decision.superseded":return{source:"tracker",level:"warn",text:`Decision ${e.decisionId} superseded by ${e.supersededBy}`};case"external.changed":return{source:"tracker",level:"warn",text:"External change detected · resynced"};default:return null}}const Qx=new Set(["createMap","setMapMode","setMapArchived","setMapMeta","updateMapSections","createTicket","addBlocking","removeBlocking","editTicket","reopen","assign","comment","close","setMeta","createDecision","markSuperseded"]),Yx=5*6e4;function Jx(e){let t={status:"idle",inflight:0,writes:0,errors:0,events:[]};const s=new Qs,o=l=>{t={...t,...l},s.emit(t)};return e.subscribe(l=>{const d=l.at-Yx;o({events:[...t.events.filter(h=>h.at>=d),{at:l.at,external:l.kind==="external.changed"||"external"in l&&!!l.external}]})}),{adapter:new Proxy(e,{get(l,d,h){const f=Reflect.get(l,d,h);return typeof f!="function"?f:Qx.has(d)?async(...p)=>{const k=Date.now();o({inflight:t.inflight+1,status:"syncing"});try{const v=await f.apply(l,p),w=t.inflight-1;return o({inflight:w,writes:t.writes+1,lastWriteMs:Date.now()-k,lastWriteAt:Date.now(),status:w?"syncing":"ok",lastError:void 0}),v}catch(v){const w=t.inflight-1;throw o({inflight:w,errors:t.errors+1,status:"error",lastError:String(v.message??v)}),v}}:f.bind(l)}}),get health(){return t},subscribe:l=>s.on(l)}}function sg(e){const t={decided:0,claimed:0,frontier:0,blocked:0,parked:0,"out-of-scope":0,verifying:0,rework:0,held:0,total:e.tickets.length,resolvedPct:0};for(const s of ti(e.tickets,e.map.mode).values())t[s]++;return t.resolvedPct=t.total?Math.round((t.decided+t["out-of-scope"])/t.total*100):0,t}function ig(e){const t=sg(e);return{decided:t.decided,total:t.total-t["out-of-scope"]}}function Xx(e){const t=new Map(e.tickets.filter(d=>d.state==="open").map(d=>[d.id,d])),s=new Map,o=new Set,a=d=>{if(s.has(d))return s.get(d);if(o.has(d))return[];o.add(d);const h=t.get(d);let f=[];for(const k of h.blockedBy)if(t.has(k)){const v=a(k);v.length>f.length&&(f=v)}o.delete(d);const p=[...f,h];return s.set(d,p),p};let l=[];for(const d of t.keys()){const h=a(d);h.length>l.length&&(l=h)}return l}function Zx(e){return _o.map(t=>{const s=e.tickets.filter(o=>o.type===t);return{type:t,open:s.filter(o=>o.state==="open").length,closed:s.filter(o=>o.state==="closed").length}}).filter(t=>t.open+t.closed>0)}function ej(e,t){const s=e.pending.filter(a=>!0),o=e.answered.filter(a=>!0);return{open:s.length,oldestAt:s.length?Math.min(...s.map(a=>a.at)):void 0,answered:o.length,avgWaitMs:o.length?o.reduce((a,l)=>a+(l.answeredAt-l.askedAt),0)/o.length:void 0}}function rg(e,t){return t&&e.usageByMap[t]||{inputTokens:0,outputTokens:0,costUsd:0}}const tj=e=>e.usage?e.usage.inputTokens+e.usage.outputTokens:0,og={"claude-code":{tag:"LOG",text:"Measured from the Claude Code session transcript; cost at list price"},codex:{tag:"LOG",text:"Measured from the Codex session log; cost at list price"},reported:{tag:"SELF",text:"Self-reported by the agent (report_progress)"}};function ag(e,t){var o;const s=new Set;for(const a of e.sessions)t&&a.mapId===t&&((o=a.usage)!=null&&o.source)&&s.add(a.usage.source);return[...s].sort()}function nj(e,t){return e.replace(/^\*\*HITL transcript\*\*\s*/,"").split(/\n\n(?=\*\*[^*]+:\*\* )/).map(s=>s.match(/^\*\*([^*]+):\*\* ([\s\S]*)$/)).filter(s=>!!s).map(s=>({from:"agent",author:s[1],text:s[2].trim(),at:t}))}function sj(e,t){const s=new Set(t.map(a=>a.ticketId).filter(Boolean)),o=e.tickets.filter(a=>a.state==="closed"&&a.closeReason==="completed"&&!s.has(a.id)).map(a=>{var k;const l=[...a.comments].reverse().find(v=>v.body.startsWith("**Resolution**")),d=l?l.body.replace(/^\*\*Resolution\*\*\s*/,""):((k=e.map.sections.decisions.find(v=>v.ticketId===a.id||v.ticketKey===a.key))==null?void 0:k.text)??"",h=(l==null?void 0:l.author)??a.assignee??"unknown",f=a.comments.find(v=>v.body.startsWith("**HITL transcript**")),p=f?nj(f.body,f.createdAt):[];return{id:`T${a.key}`,mapId:e.map.id,ticketId:a.id,ticketKey:a.key,question:a.title,answer:d,summary:aa(d),alternatives:[],rationale:"",decidedBy:`${h}${Zp}`,decidedAt:a.closedAt??(l==null?void 0:l.createdAt)??a.updatedAt,participants:[...new Set([h,...p.map(v=>v.author)])].map(v=>({id:v})),source:{kind:"tracker",ref:`${e.map.id}/tickets/${a.id}`,label:`unverified, from text: ${l?`${a.key} resolution comment`:"the map’s Decisions so far"}`},transcript:p,derived:!0}});return[...t,...o].sort((a,l)=>l.decidedAt-a.decidedAt)}function ij(e,t){var o;const s=(o=t.query)==null?void 0:o.trim().toLowerCase();return e.filter(a=>(!t.mapId||a.mapId===t.mapId)&&(!t.source||a.source.kind===t.source)&&(!t.decidedBy||a.decidedBy===t.decidedBy)&&(!t.madeBy||rr(a)===t.madeBy)&&(!t.status||dr(a)===t.status)&&(!s||[a.id,a.ticketKey,a.question,a.answer,a.summary,a.rationale,a.decidedBy,...a.alternatives,...a.transcript.map(l=>l.text)].join(`
|
|
78
|
+
${o}`}:{tone:"ok",label:`PR sync ${bc(t-e.lastOkAt)}`,title:`PR/CI synced${s}, ${o}`}}class Qs{constructor(){le(this,"listeners",new Set)}on(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t){for(const s of[...this.listeners])s(t)}}let Kx=0;const Oo=(e="id")=>`${e}_${Date.now().toString(36)}${(Kx++).toString(36)}`,Xc=(e,t)=>({inputTokens:((e==null?void 0:e.inputTokens)??0)+t.inputTokens,outputTokens:((e==null?void 0:e.outputTokens)??0)+t.outputTokens,costUsd:((e==null?void 0:e.costUsd)??0)+t.costUsd,...e!=null&&e.cachedInputTokens||t.cachedInputTokens?{cachedInputTokens:((e==null?void 0:e.cachedInputTokens)??0)+(t.cachedInputTokens??0)}:{}}),ng=(e,t)=>({inputTokens:e.inputTokens-((t==null?void 0:t.inputTokens)??0),outputTokens:e.outputTokens-((t==null?void 0:t.outputTokens)??0),costUsd:e.costUsd-((t==null?void 0:t.costUsd)??0),...e.cachedInputTokens||t!=null&&t.cachedInputTokens?{cachedInputTokens:(e.cachedInputTokens??0)-((t==null?void 0:t.cachedInputTokens)??0)}:{}});function Vx(e,t,s){const o=()=>e.find(t.id)??t,a=l=>e.push({source:"session",sessionId:t.id,agent:t.agent,...l});return{id:t.id,get info(){return o()},step(l,d,h){const f=ra[s][l-1];e.patchSession(t.id,{step:l,stepLabel:f,...h?{ticketId:h}:{}}),a({tag:ux(s,l),level:"step",text:d?`${f}: ${d}`:f,ticketId:h??o().ticketId})},log(l,d="info",h){a({level:d,text:l,ticketId:o().ticketId,...h?{kind:h}:{}})},say(l){e.chat({sessionId:t.id,ticketId:o().ticketId,from:"agent",author:t.agent,text:l})},ask(l,d,h){var p;const f={id:Oo("q"),sessionId:t.id,mapId:t.mapId,ticketId:o().ticketId,agent:t.agent,text:l,suggestions:d,at:Date.now(),...h!=null&&h.urgency?{urgency:h.urgency}:{},...(p=h==null?void 0:h.blocks)!=null&&p.length?{blocks:h.blocks}:{}};return e.chat({sessionId:t.id,ticketId:f.ticketId,from:"agent",author:t.agent,text:l,questionId:f.id}),e.addPending(f),e.patchSession(t.id,{waitingOn:f.id}),a({level:"alert",kind:"asks-you",ticketId:f.ticketId,text:"Decision request · waiting on you",signal:!0}),e.awaitAnswer(f.id)},done(l=!0,d,h){e.patchSession(t.id,{status:l?"done":"failed",endedAt:Date.now(),waitingOn:void 0}),e.dropPending(t.id),a({level:l?"ok":"alert",text:d??(l?"Session closed":"Session aborted"),signal:h==null?void 0:h.signal,...h!=null&&h.kind?{kind:h.kind}:{}})},bindMap(l){var h;const d=o().usage;d&&(e.addMapUsage(l,d),(h=e.ledger())==null||h.add(l,d,t.id)),e.patchSession(t.id,{mapId:l})},usage(l){var f;const d=o().mapId;(f=e.ledger())==null||f.add(d,l,t.id),e.addMapUsage(d,l);const h=o().usage;e.patchSession(t.id,{usage:{...Xc(h,l),source:l.source??(h==null?void 0:h.source)}})},setUsage(l){var v;const d=o().usage,h=ng(l,d);if(!h.inputTokens&&!h.outputTokens&&!h.costUsd&&!h.cachedInputTokens&&(d==null?void 0:d.source)===l.source&&`${d==null?void 0:d.models}`==`${l.models}`)return;const p=o().mapId;(h.inputTokens>0||h.outputTokens>0||h.costUsd>0)&&((v=e.ledger())==null||v.add(p,h,t.id)),e.addMapUsage(p,h),e.patchSession(t.id,{usage:l})},setModel(l,d){const h=o();h.model===l&&h.tier===d||e.patchSession(t.id,{model:l,tier:d})}}}class Gx{constructor(t=400,s){le(this,"state",{sessions:[],feed:[],chats:[],pending:[],answered:[],usageByMap:{}});le(this,"changes",new Qs);le(this,"resolvers",new Map);le(this,"remote",new Map);le(this,"remoteAnswer");le(this,"host",{find:t=>this.state.sessions.find(s=>s.id===t),patchSession:(t,s)=>this.patchSession(t,s),push:t=>void this.push(t),chat:t=>this.chat(t),addPending:t=>this.set({pending:[...this.state.pending,t]}),dropPending:t=>{this.state.pending.filter(o=>o.sessionId===t).length&&this.set({pending:this.state.pending.filter(o=>o.sessionId!==t)})},awaitAnswer:t=>new Promise(s=>this.resolvers.set(t,s)),addMapUsage:(t,s)=>{this.state={...this.state,usageByMap:{...this.state.usageByMap,[t]:Xc(this.state.usageByMap[t],s)}}},ledger:()=>this.ledger});this.maxFeed=t,this.ledger=s}get snapshot(){return this.state}subscribe(t){return this.changes.on(t)}set(t){this.state={...this.state,...t},this.changes.emit(this.state)}push(t){const s={id:Oo("f"),at:t.at??Date.now(),...t};return s.source==="system"&&!s.agent&&(s.agent=Z.assistant.name),this.set({feed:[...this.state.feed,s].slice(-this.maxFeed)}),s}patchSession(t,s){this.set({sessions:this.state.sessions.map(o=>o.id===t?{...o,...s}:o)})}chat(t){this.set({chats:[...this.state.chats,{id:Oo("m"),at:Date.now(),...t}].slice(-600)})}answer(t,s,o,a){var v;const l=this.state.pending.find(k=>k.id===t),d=this.resolvers.get(t),h=!!l&&this.remote.has(l.sessionId)&&!!this.remoteAnswer;if(!l||!d&&!h)return!1;this.resolvers.delete(t);const f=bx(a),p=a.by?{by:a.by}:{};return this.chat({sessionId:l.sessionId,ticketId:l.ticketId,from:"human",author:o,text:s,...f,...p}),this.set({pending:this.state.pending.filter(k=>k.id!==t),answered:[...this.state.answered,{id:l.id,mapId:l.mapId,sessionId:l.sessionId,agent:l.agent,askedAt:l.at,answeredAt:Date.now(),...l.ticketId?{ticketId:l.ticketId}:{},...l.category?{category:l.category}:{},...(v=l.categories)!=null&&v.length?{categories:l.categories}:{},...l.urgency?{urgency:l.urgency}:{},...f,...p}].slice(-200)}),this.patchSession(l.sessionId,{waitingOn:void 0}),this.push({source:"trail lead",agent:o,level:"ok",kind:"answered",ticketId:l.ticketId,sessionId:l.sessionId,text:`Answered ${l.agent}`}),d?d(s):this.remoteAnswer(l,s,o),!0}syncRemote(t){var p;const{session:s}=t,o=s.id;if(!this.remote.has(o)&&this.state.sessions.some(v=>v.id===o))return;const a=this.remote.get(o);this.remote.set(o,s.mapId?s.usage:a);let l=this.state.usageByMap;if(s.usage&&s.mapId){const v=ng(s.usage,a);(v.inputTokens||v.outputTokens||v.costUsd)&&(l={...l,[s.mapId]:Xc(l[s.mapId],v)}),(p=this.ledger)==null||p.addTotal(s.mapId,o,s.usage)}const d=v=>v.filter(k=>k.sessionId!==o),h=new Set(this.state.answered.map(v=>v.id)),f=this.state.sessions.some(v=>v.id===o)?this.state.sessions.map(v=>v.id===o?s:v):[...this.state.sessions,s].slice(-24);this.set({sessions:f,chats:[...d(this.state.chats),...t.chats].sort((v,k)=>v.at-k.at).slice(-600),pending:[...d(this.state.pending),...t.pending],answered:[...this.state.answered,...t.answered.filter(v=>!h.has(v.id))].sort((v,k)=>v.answeredAt-k.answeredAt).slice(-200),feed:[...this.state.feed.filter(v=>v.sessionId!==o),...t.feed].sort((v,k)=>v.at-k.at).slice(-this.maxFeed),usageByMap:l})}isRemote(t){return this.remote.has(t)}startSession(t){const s={...t,id:t.id??Oo("s"),step:0,total:ra[t.mode].length,stepLabel:"BOOT",status:"running",startedAt:Date.now()};this.set({sessions:[...this.state.sessions,s].slice(-24)});const o=Vx(this.host,s,t.mode);return this.push({source:"session",sessionId:s.id,agent:s.agent,level:"info",text:`Session opened · ${t.mode}`}),o}}function qx(e,t){const s=o=>{var a;return((a=t(o))==null?void 0:a.key)??o};switch(e.kind){case"map.created":return{source:"tracker",level:"ok",text:`Trail created · label ${xd}`};case"map.updated":return{source:"tracker",level:"info",text:`Trail updated${e.section?` · ${ax[e.section].toLowerCase()}`:""}`};case"map.mode":return{source:"tracker",level:"warn",text:`Trail mode · ${e.mode}`};case"ticket.created":return{source:"tracker",level:"info",ticketId:e.ticketId,text:`Opened ${s(e.ticketId)}`};case"ticket.claimed":return{source:"tracker",level:"warn",ticketId:e.ticketId,text:`Assigned ${s(e.ticketId)} to ${e.assignee}`};case"ticket.released":return{source:"tracker",level:"info",ticketId:e.ticketId,text:`Unassigned ${s(e.ticketId)}`};case"ticket.closed":return{source:"tracker",level:e.reason==="completed"?"ok":"alert",...e.reason==="completed"?{kind:"done"}:{},ticketId:e.ticketId,text:`Closed ${s(e.ticketId)} · ${e.reason==="completed"?"completed":"not planned"}`};case"ticket.commented":return{source:"tracker",level:"info",ticketId:e.ticketId,text:`Comment on ${s(e.ticketId)}`};case"edge.added":return{source:"tracker",level:"info",ticketId:e.blockedId,text:`${s(e.blockerId)} blocks ${s(e.blockedId)}`};case"edge.removed":return{source:"tracker",level:"info",ticketId:e.blockedId,text:`${s(e.blockerId)} no longer blocks ${s(e.blockedId)}`};case"decision.recorded":return{source:"tracker",level:"ok",ticketId:e.ticketId,text:`Decision ${e.decisionId} recorded${e.ticketId?` · ${s(e.ticketId)}`:""}`};case"decision.superseded":return{source:"tracker",level:"warn",text:`Decision ${e.decisionId} superseded by ${e.supersededBy}`};case"external.changed":return{source:"tracker",level:"warn",text:"External change detected · resynced"};default:return null}}const Qx=new Set(["createMap","setMapMode","setMapArchived","setMapMeta","updateMapSections","createTicket","addBlocking","removeBlocking","editTicket","reopen","assign","comment","close","setMeta","createDecision","markSuperseded"]),Yx=5*6e4;function Jx(e){let t={status:"idle",inflight:0,writes:0,errors:0,events:[]};const s=new Qs,o=l=>{t={...t,...l},s.emit(t)};return e.subscribe(l=>{const d=l.at-Yx;o({events:[...t.events.filter(h=>h.at>=d),{at:l.at,external:l.kind==="external.changed"||"external"in l&&!!l.external}]})}),{adapter:new Proxy(e,{get(l,d,h){const f=Reflect.get(l,d,h);return typeof f!="function"?f:Qx.has(d)?async(...p)=>{const v=Date.now();o({inflight:t.inflight+1,status:"syncing"});try{const k=await f.apply(l,p),w=t.inflight-1;return o({inflight:w,writes:t.writes+1,lastWriteMs:Date.now()-v,lastWriteAt:Date.now(),status:w?"syncing":"ok",lastError:void 0}),k}catch(k){const w=t.inflight-1;throw o({inflight:w,errors:t.errors+1,status:"error",lastError:String(k.message??k)}),k}}:f.bind(l)}}),get health(){return t},subscribe:l=>s.on(l)}}function sg(e){const t={decided:0,claimed:0,frontier:0,blocked:0,parked:0,"out-of-scope":0,verifying:0,rework:0,held:0,total:e.tickets.length,resolvedPct:0};for(const s of ti(e.tickets,e.map.mode).values())t[s]++;return t.resolvedPct=t.total?Math.round((t.decided+t["out-of-scope"])/t.total*100):0,t}function ig(e){const t=sg(e);return{decided:t.decided,total:t.total-t["out-of-scope"]}}function Xx(e){const t=new Map(e.tickets.filter(d=>d.state==="open").map(d=>[d.id,d])),s=new Map,o=new Set,a=d=>{if(s.has(d))return s.get(d);if(o.has(d))return[];o.add(d);const h=t.get(d);let f=[];for(const v of h.blockedBy)if(t.has(v)){const k=a(v);k.length>f.length&&(f=k)}o.delete(d);const p=[...f,h];return s.set(d,p),p};let l=[];for(const d of t.keys()){const h=a(d);h.length>l.length&&(l=h)}return l}function Zx(e){return _o.map(t=>{const s=e.tickets.filter(o=>o.type===t);return{type:t,open:s.filter(o=>o.state==="open").length,closed:s.filter(o=>o.state==="closed").length}}).filter(t=>t.open+t.closed>0)}function ej(e,t){const s=e.pending.filter(a=>!0),o=e.answered.filter(a=>!0);return{open:s.length,oldestAt:s.length?Math.min(...s.map(a=>a.at)):void 0,answered:o.length,avgWaitMs:o.length?o.reduce((a,l)=>a+(l.answeredAt-l.askedAt),0)/o.length:void 0}}function rg(e,t){return t&&e.usageByMap[t]||{inputTokens:0,outputTokens:0,costUsd:0}}const tj=e=>e.usage?e.usage.inputTokens+e.usage.outputTokens:0,og={"claude-code":{tag:"LOG",text:"Measured from the Claude Code session transcript; cost at list price"},codex:{tag:"LOG",text:"Measured from the Codex session log; cost at list price"},reported:{tag:"SELF",text:"Self-reported by the agent (report_progress)"}};function ag(e,t){var o;const s=new Set;for(const a of e.sessions)t&&a.mapId===t&&((o=a.usage)!=null&&o.source)&&s.add(a.usage.source);return[...s].sort()}function nj(e,t){return e.replace(/^\*\*HITL transcript\*\*\s*/,"").split(/\n\n(?=\*\*[^*]+:\*\* )/).map(s=>s.match(/^\*\*([^*]+):\*\* ([\s\S]*)$/)).filter(s=>!!s).map(s=>({from:"agent",author:s[1],text:s[2].trim(),at:t}))}function sj(e,t){const s=new Set(t.map(a=>a.ticketId).filter(Boolean)),o=e.tickets.filter(a=>a.state==="closed"&&a.closeReason==="completed"&&!s.has(a.id)).map(a=>{var v;const l=[...a.comments].reverse().find(k=>k.body.startsWith("**Resolution**")),d=l?l.body.replace(/^\*\*Resolution\*\*\s*/,""):((v=e.map.sections.decisions.find(k=>k.ticketId===a.id||k.ticketKey===a.key))==null?void 0:v.text)??"",h=(l==null?void 0:l.author)??a.assignee??"unknown",f=a.comments.find(k=>k.body.startsWith("**HITL transcript**")),p=f?nj(f.body,f.createdAt):[];return{id:`T${a.key}`,mapId:e.map.id,ticketId:a.id,ticketKey:a.key,question:a.title,answer:d,summary:aa(d),alternatives:[],rationale:"",decidedBy:`${h}${Zp}`,decidedAt:a.closedAt??(l==null?void 0:l.createdAt)??a.updatedAt,participants:[...new Set([h,...p.map(k=>k.author)])].map(k=>({id:k})),source:{kind:"tracker",ref:`${e.map.id}/tickets/${a.id}`,label:`unverified, from text: ${l?`${a.key} resolution comment`:"the map’s Decisions so far"}`},transcript:p,derived:!0}});return[...t,...o].sort((a,l)=>l.decidedAt-a.decidedAt)}function ij(e,t){var o;const s=(o=t.query)==null?void 0:o.trim().toLowerCase();return e.filter(a=>(!t.mapId||a.mapId===t.mapId)&&(!t.source||a.source.kind===t.source)&&(!t.decidedBy||a.decidedBy===t.decidedBy)&&(!t.madeBy||rr(a)===t.madeBy)&&(!t.status||dr(a)===t.status)&&(!s||[a.id,a.ticketKey,a.question,a.answer,a.summary,a.rationale,a.decidedBy,...a.alternatives,...a.transcript.map(l=>l.text)].join(`
|
|
79
79
|
`).toLowerCase().includes(s)))}function rj(e,t=Date.now()){const s=Object.fromEntries(Fo.map(d=>[d,0]));let o=0,a=0,l=0;for(const d of e){s[d.source.kind]++,d.supersededBy&&o++,t-d.decidedAt<864e5&&a++;const h=rr(d);(h==="human"||h==="agent"&&d.transcript.some(f=>f.from==="human"))&&l++}return{total:e.length,active:e.length-o,superseded:o,last24h:a,human:l,bySource:s}}function la(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!t)return{front:{},body:e};const s={};for(const o of t[1].split(`
|
|
80
80
|
`)){const a=o.indexOf(":");if(a<0)continue;const l=o.slice(0,a).trim(),d=o.slice(a+1).trim();Rw(l)&&(s[l]=d.startsWith("[")?lj(d.slice(1,-1)).map(um).filter(Boolean):um(d))}return{front:s,body:t[2]}}const oj=e=>e===""||/^[\s#&*!|>'"%@`[\]{},?:-]|[:#]\s|\s$|,|["\\[\]]/.test(e)||Yw(e)||/^(true|false|null|~|\d[\d.e+-]*)$/i.test(e),aj=e=>JSON.stringify(e).replace(/[\u007f\u0085\u2028\u2029]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),dm=e=>oj(e)?aj(e):e;function um(e){if(e.startsWith('"'))try{return JSON.parse(e)}catch{return e.slice(1,-1)}return e.startsWith("'")?e.slice(1,-1).replace(/''/g,"'"):e}function lj(e){const t=[];let s="",o=!1,a=!1;for(const l of e)l==='"'&&!a&&(o=!o),a=o&&l==="\\"&&!a,l===","&&!o?(t.push(s.trim()),s=""):s+=l;return s.trim()&&t.push(s.trim()),t}function cj(e){if(!/^[\w-]+$/.test(e))throw new Error(`invalid frontmatter key: ${JSON.stringify(e)}`);return e}function Cd(e,t){return`---
|
|
81
81
|
${Object.entries(e).map(([o,a])=>`${cj(o)}: ${Array.isArray(a)?`[${a.map(dm).join(", ")}]`:dm(a)}`).join(`
|
|
@@ -102,16 +102,16 @@ ${bo(e.rationale)||"_None._"}`,`## Transcript
|
|
|
102
102
|
|
|
103
103
|
${o}`].join(`
|
|
104
104
|
|
|
105
|
-
`);return Cd(t,a)}function Zc(e){const{front:t,body:s}=la(e),o={},a=new RegExp(`^## (${dg.join("|")})\\s*$`,"gm"),l=[...s.matchAll(a)];l.forEach((
|
|
106
|
-
`),j=w<0?
|
|
107
|
-
`).map(
|
|
105
|
+
`);return Cd(t,a)}function Zc(e){const{front:t,body:s}=la(e),o={},a=new RegExp(`^## (${dg.join("|")})\\s*$`,"gm"),l=[...s.matchAll(a)];l.forEach((k,w)=>{var I;const j=s.slice(k.index+k[0].length,((I=l[w+1])==null?void 0:I.index)??s.length).trim(),N=k[1],S=N==="Transcript"?j:zo(j,Td);o[N]=/^_none\._$/i.test(j)?"":S});const d=(o.Transcript??"").split(/^### /m).slice(1).map(k=>{const w=k.indexOf(`
|
|
106
|
+
`),j=w<0?k:k.slice(0,w),N=j.lastIndexOf(" @ "),S=N<0?j:j.slice(0,N),I=N<0?"":j.slice(N+3),$=S.lastIndexOf(" · "),_=$<0?S:S.slice(0,$),O=$<0?"agent":S.slice($+3);return{author:_.trim(),from:["agent","human","system"].includes(O.trim())?O.trim():"agent",at:Date.parse(I)||0,text:w<0?"":zo(k.slice(w+1).trim(),ug)}}),h=ye(t.source),f=qt(t.source_meta),p={kind:Ax(h)?h:"tracker",...ye(t.source_ref)?{ref:ye(t.source_ref)}:{},...ye(t.source_url)?{url:ye(t.source_url)}:{},...ye(t.source_label)?{label:ye(t.source_label)}:{},...f.length?{meta:Object.fromEntries(f.map(k=>[k.slice(0,k.indexOf("=")),k.slice(k.indexOf("=")+1)]))}:{}},v=o.Decision??"";return{id:ye(t.id),mapId:ye(t.trail),ticketId:ye(t.ticket)||void 0,ticketKey:ye(t.ticket_key)||void 0,question:o.Question??"",answer:v,summary:o.Summary||aa(v),alternatives:(o.Alternatives??"").split(`
|
|
107
|
+
`).map(k=>k.trim()).filter(k=>k.startsWith("- ")).map(k=>k.slice(2)),rationale:o.Rationale??"",decidedBy:ye(t.decided_by),...ye(t.decided_by_name)?{decidedByName:ye(t.decided_by_name)}:{},decidedAt:qs(t.decided_at),participants:qt(t.participants).map(pj),source:p,supersedes:ye(t.supersedes)||void 0,supersededBy:ye(t.superseded_by)||void 0,...qt(t.assumes).length?{assumes:qt(t.assumes)}:{},transcript:d,...fj(t)}}function gj(e){return e.url?` · [${e.label??"link"}](${e.url})`:e.label?` · ${e.label}`:""}function vj(e,t,s={}){const o=[`# ${s.title??"Decisions"}`,"",`Exported ${cn(s.now??Date.now())} · ${e.length} decisions`],a=new Map;for(const l of e)a.set(l.mapId,[...a.get(l.mapId)??[],l]);for(const[l,d]of a){const h=t[l];o.push("",`## Trail ${h?`${h.key} ${h.title}`:l}`);for(const f of d){const p=Jn[f.source.kind].label;o.push("",`### ${f.id}${f.ticketKey?` · ${f.ticketKey}`:""} · ${f.question}`,"",`- **Status:** ${dr(f)}${f.supersededBy?` (superseded by ${f.supersededBy})`:""}${f.supersedes?` · supersedes ${f.supersedes}`:""}`,`- **Decided by:** ${f.decidedBy} · ${cn(f.decidedAt)}`,`- **Source:** ${p}${gj(f.source)}`,...f.participants.length?[`- **Participants:** ${f.participants.map(v=>v.name??v.id).join(", ")}`]:[],"",`**Decision:** ${f.answer}`,...f.alternatives.length?["","**Alternatives:**",...f.alternatives.map(v=>`- ${v}`)]:[],...f.rationale?["",`**Rationale:** ${f.rationale}`]:[],...f.transcript.length?["","<details><summary>Transcript</summary>","",...f.transcript.map(v=>`> **${v.author}:** ${v.text.replace(/\n/g,`
|
|
108
108
|
> `)}
|
|
109
109
|
>`),"","</details>"]:[])}}return o.join(`
|
|
110
110
|
`)+`
|
|
111
|
-
`}function ed(e,t,s){try{const o=e.get(t);return o?JSON.parse(o):s}catch{return s}}class hm{constructor(t,s="presence"){le(this,"seen");this.store=t,this.key=s,this.seen=ed(t,s,{})}snapshot(){return{...this.seen}}lastSeen(t){return this.seen[t]}lastSeenAny(){const t=Object.values(this.seen);return t.length?Math.max(...t):void 0}markSeen(t,s=Date.now()){let o=!1;for(const a of t)(this.seen[a]??0)>=s||(this.seen[a]=s,o=!0);o&&this.store.set(this.key,JSON.stringify(this.seen))}}const $c=5*6e4,kj=14*864e5;class fm{constructor(t,s="usage"){le(this,"buckets");le(this,"dirty",!1);le(this,"timer");le(this,"totals");this.store=t,this.key=s,this.buckets=ed(t,s,{}),this.totals=ed(t,`${s}.totals`,{})}addTotal(t,s,o,a=Date.now()){const l=this.totals[s],d={inputTokens:o.inputTokens-((l==null?void 0:l.inputTokens)??0),outputTokens:o.outputTokens-((l==null?void 0:l.outputTokens)??0),costUsd:o.costUsd-((l==null?void 0:l.costUsd)??0)};this.totals[s]={...o,at:a},d.inputTokens>0||d.outputTokens>0||d.costUsd>0?this.add(t,d,s,a):this.save()}add(t,s,o,a=Date.now()){var f;if(!t)return;const l=Math.floor(a/$c)*$c,d=(f=this.buckets)[t]??(f[t]=[]);let h=d.find(p=>p.at===l);h||(h={at:l,i:0,o:0,c:0,s:[]},d.push(h),d.sort((p,
|
|
112
|
-
`)}const Ed=5,mg=1.5,Cj=15,$o=e=>Math.round(e*100);function Tj(e){const t=e.filter(d=>d.findings.raised>=Ed).sort((d,h)=>h.findings.upheld/h.findings.raised-d.findings.upheld/d.findings.raised||d.key.localeCompare(h.key));if(t.length<2)return[];const[s,o]=[t[0],t[t.length-1]],[a,l]=[s.findings.upheld/s.findings.raised,o.findings.upheld/o.findings.raised];return $o(a)-$o(l)<Cj?[]:[{id:"review-findings",text:`${s.key} review findings upheld ${$o(a)}% vs ${o.key} ${$o(l)}%`,because:`${s.findings.upheld} of ${s.findings.raised} and ${o.findings.upheld} of ${o.findings.raised} failed reviews stood; a finding is overruled when you accept the work anyway`}]}function Ej(e){const t=l=>l.reworkCycles/l.tickets,s=e.filter(l=>l.tickets>=Ed).sort((l,d)=>t(l)-t(d)||l.key.localeCompare(d.key));if(s.length<2)return[];const[o,a]=[s[0],s[s.length-1]];return t(a)-t(o)<.2||t(a)<t(o)*mg?[]:[{id:"rework",text:`${a.key} work goes back to rework more: ${t(a).toFixed(1)} times per ticket vs ${o.key} ${t(o).toFixed(1)}`,because:`${a.reworkCycles} cycles on ${a.tickets} tickets, and ${o.reworkCycles} on ${o.tickets}`}]}function Aj(e,t){const s=d=>d.medianLeadMs??0,o=t.filter(d=>d.done>=Ed&&d.medianLeadMs!==void 0).sort((d,h)=>s(d)-s(h)||d.key.localeCompare(h.key));if(o.length<2)return[];const[a,l]=[o[0],o[o.length-1]];return s(l)<s(a)*mg?[]:[{id:`speed-${e}`,text:`${e} tickets: ${a.key} is faster, ${Qt(a.medianLeadMs)} vs ${l.key} ${Qt(l.medianLeadMs)}`,because:`Median first claim to done, over ${a.done} and ${l.done} done tickets`}]}function Ij(e){const t=Object.keys(e.byTypeAndVendor).sort();return[...Tj(e.byVendor),...Ej(e.byVendor),...t.flatMap(s=>Aj(s,e.byTypeAndVendor[s]))]}const Rj=e=>{if(!e.length)return;const t=[...e].sort((o,a)=>o-a),s=Math.floor(t.length/2);return t.length%2?t[s]:Math.round((t[s-1]+t[s])/2)},pg=e=>{var t;return(t=e.filter(s=>s.event==="claim"&&s.actorKind==="agent").at(-1))==null?void 0:t.actor},td=(e,t,s)=>e.filter(o=>o.mapId===t&&o.ticketId===s).sort((o,a)=>o.at-a.at);function Mj(e,t){return e.tickets.flatMap(s=>{var
|
|
113
|
-
`)},Pj=[["summary","Summary"],["productContext","Product context"],["existing","Existing implementation"],["conventions","Conventions and abstractions"],["dataModel","Data model impact"],["api","API impact"],["risks","Risks and possible regressions"],["assumptions","Assumptions"],["openQuestions","Open questions"]],Yi=Object.fromEntries(Pj);function _j(e,t){const s=new Set(e.map(o=>o.source).filter(Boolean));return t.filter(o=>!s.has(o))}const Dj=["architecture","convention","gotcha","dead-end","glossary","fact"],kg=["business-rule","product-decision","persona","ux-principle","pricing"],zj=[...Dj,...kg],Bj=e=>e.status==="confirmed"||e.status==="assumption";function Fj(e,t){return Wp(e,t.replace(/^\.\//,""),{segments:!0})}const Uj={"business-rule":3,convention:3,"product-decision":2,architecture:2,gotcha:2,"dead-end":2,"ux-principle":2},Wj=["business-rule","ux-principle","convention"],gm=600,Hj=e=>`flagged as possibly outdated by ${e}; the human is reviewing it`,Kj=new Set("the and for with from into onto that this these those than then through use uses using via all any are was were will can should must not only also each when what where which who how per our your their its".split(" ")),vm=e=>new Set((e.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(t=>!Kj.has(t)));function yg(e,t,s=4e3,o=()=>[]){const a=t.ticket?vm(`${t.ticket.title} ${t.ticket.body}`):new Set,l=new Set((t.tags??[]).map(p=>p.toLowerCase())),d=e.filter(Bj).map(p=>{const
|
|
114
|
-
`),j=
|
|
111
|
+
`}function ed(e,t,s){try{const o=e.get(t);return o?JSON.parse(o):s}catch{return s}}class hm{constructor(t,s="presence"){le(this,"seen");this.store=t,this.key=s,this.seen=ed(t,s,{})}snapshot(){return{...this.seen}}lastSeen(t){return this.seen[t]}lastSeenAny(){const t=Object.values(this.seen);return t.length?Math.max(...t):void 0}markSeen(t,s=Date.now()){let o=!1;for(const a of t)(this.seen[a]??0)>=s||(this.seen[a]=s,o=!0);o&&this.store.set(this.key,JSON.stringify(this.seen))}}const $c=5*6e4,kj=14*864e5;class fm{constructor(t,s="usage"){le(this,"buckets");le(this,"dirty",!1);le(this,"timer");le(this,"totals");this.store=t,this.key=s,this.buckets=ed(t,s,{}),this.totals=ed(t,`${s}.totals`,{})}addTotal(t,s,o,a=Date.now()){const l=this.totals[s],d={inputTokens:o.inputTokens-((l==null?void 0:l.inputTokens)??0),outputTokens:o.outputTokens-((l==null?void 0:l.outputTokens)??0),costUsd:o.costUsd-((l==null?void 0:l.costUsd)??0)};this.totals[s]={...o,at:a},d.inputTokens>0||d.outputTokens>0||d.costUsd>0?this.add(t,d,s,a):this.save()}add(t,s,o,a=Date.now()){var f;if(!t)return;const l=Math.floor(a/$c)*$c,d=(f=this.buckets)[t]??(f[t]=[]);let h=d.find(p=>p.at===l);h||(h={at:l,i:0,o:0,c:0,s:[]},d.push(h),d.sort((p,v)=>p.at-v.at)),h.i+=s.inputTokens,h.o+=s.outputTokens,h.c+=s.costUsd,h.s.includes(o)||h.s.push(o),this.save()}since(t,s){const o={inputTokens:0,outputTokens:0,costUsd:0,sessions:0},a=new Set;for(const l of this.buckets[t]??[])l.at+$c<=s||(o.inputTokens+=l.i,o.outputTokens+=l.o,o.costUsd+=l.c,l.s.forEach(d=>a.add(d)));return o.sessions=a.size,o}save(){this.dirty=!0,!this.timer&&(this.timer=setTimeout(()=>{if(this.timer=void 0,!this.dirty)return;this.dirty=!1;const t=Date.now()-kj;for(const s of Object.keys(this.buckets))this.buckets[s]=this.buckets[s].filter(o=>o.at>=t);for(const[s,o]of Object.entries(this.totals))o.at<t&&delete this.totals[s];this.store.set(this.key,JSON.stringify(this.buckets)),this.store.set(`${this.key}.totals`,JSON.stringify(this.totals))},2e3))}}function yj(e){const t=e.now??Date.now(),s=e.snaps.map(d=>{var oe;const h=d.map.id,f=e.since(h),p=Q=>!!Q&&Q>=f,v=ti(d.tickets,d.map.mode),k=new Map(d.tickets.map(Q=>[Q.id,Q])),w=(e.attention??[]).filter(Q=>Q.mapId===h),j=wj(e.activity.pending.filter(Q=>Q.mapId===h),w),N=new Set(j.map(Q=>Q.ticketId)),S=Q=>Q.state==="open"&&(N.has(Q.id)||cr(Q)==="hitl"),I=d.tickets.filter(Q=>v.get(Q.id)==="blocked").map(Q=>({ticket:Q,on:Q.blockedBy.map(ke=>k.get(ke)).filter(ke=>!!ke&&S(ke))})).filter(Q=>Q.on.length),$=e.decisions.filter(Q=>Q.mapId===h&&p(Q.decidedAt)).sort((Q,ke)=>ke.decidedAt-Q.decidedAt),_=d.tickets.filter(Q=>Q.state==="closed"&&p(Q.closedAt)).sort((Q,ke)=>(Q.closedAt??0)-(ke.closedAt??0)),O=_.filter(Q=>Q.closeReason==="completed"),D=_.filter(Q=>Q.closeReason==="not_planned"),q=d.tickets.filter(Q=>p(Q.createdAt)),H=((oe=e.ledger)==null?void 0:oe.since(h,f))??{inputTokens:0,outputTokens:0,costUsd:0,sessions:0},G=e.activity.sessions.filter(Q=>Q.mapId===h&&Q.status==="running");return{mapId:h,key:d.map.key,title:d.map.title,since:f,done:O,ruledOut:D,opened:q,blocked:I,waiting:j,needsYou:w,decisions:$,agentDecisions:$.filter(Q=>rr(Q)==="agent"),usage:H,active:G,changed:!!(_.length||q.length||$.length||j.some(Q=>p(Q.at))||H.costUsd>0)}}),o=s.filter(d=>d.changed||d.waiting.length).sort((d,h)=>+(h.mapId===e.currentMapId)-+(d.mapId===e.currentMapId)),a=d=>o.reduce((h,f)=>h+f[d].length,0),l=o.flatMap(d=>d.waiting).reduce((d,h)=>d===void 0||h.at<d?h.at:d,void 0);return{since:o.length?Math.min(...o.map(d=>d.since)):t,now:t,trails:o,totals:{done:a("done"),ruledOut:a("ruledOut"),blocked:a("blocked"),waiting:a("waiting"),oldestWaitMs:l===void 0?void 0:t-l,agentDecisions:a("agentDecisions"),usage:o.reduce((d,h)=>({inputTokens:d.inputTokens+h.usage.inputTokens,outputTokens:d.outputTokens+h.usage.outputTokens,costUsd:d.costUsd+h.usage.costUsd,sessions:d.sessions+h.usage.sessions}),{inputTokens:0,outputTokens:0,costUsd:0,sessions:0}),active:a("active")},changed:s.some(d=>d.changed)}}function wj(e,t){const s=new Map(t.filter(a=>a.kind==="question").map((a,l)=>[a.ref,l])),o=a=>s.get(a.id)??Number.MAX_SAFE_INTEGER;return[...e].sort((a,l)=>o(a)-o(l)||a.at-l.at)}const er=(e,t,s=`${t}s`)=>`${e} ${e===1?t:s}`;function xj(e){return e.trails.flatMap(t=>{const s=new Set(t.waiting.map(o=>o.ticketId));return t.blocked.filter(o=>o.on.some(a=>s.has(a.id)))})}function jj(e){return e.length===1?`, and it holds up ${e[0].ticket.title.replace(/^./,t=>t.toLowerCase())}`:e.length>1?`, holding up ${er(e.length,"ticket")}`:""}function Sj(e,t=new Date(e.now).getHours()){const s=e.totals,a=e.now-e.since>=6*36e5&&t>=5&&t<12?"Good morning.":"Welcome back.",l=[];if(s.done&&l.push(`${er(s.done,"ticket")} ${s.done===1?"is":"are"} done.`),s.agentDecisions&&l.push(`Agents made ${er(s.agentDecisions,"decision")}.`),s.waiting){const d=jj(xj(e));l.push(`${er(s.waiting,"decision")} ${s.waiting===1?"is":"are"} waiting on you${d}.`)}else l.push("Nothing is waiting on you.");return!s.done&&!s.agentDecisions&&s.ruledOut&&l.unshift(`${er(s.ruledOut,"ticket")} ruled out of scope.`),[a,...l].join(" ")}const Nj=e=>{if(!e.length)return;const t=[...e].sort((o,a)=>o-a),s=Math.floor(t.length/2);return t.length%2?t[s]:Math.round((t[s-1]+t[s])/2)};function bj(e){return e.state==="open"?"open":e.closeReason==="not_planned"?"cancelled":"done"}function fg({snap:e,journal:t,answered:s,usage:o}){const a=e.map.id,l=t.filter(S=>S.mapId===a).sort((S,I)=>S.at-I.at),d=new Map;for(const S of l)d.set(S.ticketId,[...d.get(S.ticketId)??[],S]);const h=e.tickets.filter(S=>S.type!=="review").map(S=>{var D;const I=d.get(S.id)??[],$=bj(S),_=(D=I.find(q=>q.event==="claim"))==null?void 0:D.at,O=$==="done"?S.closedAt:void 0;return{id:S.id,key:S.key,title:S.title,type:S.type,outcome:$,claimedAt:_,doneAt:O,leadMs:O&&_&&O>=_?O-_:void 0,reworks:I.filter(q=>q.to==="rework").length,reviews:{passed:I.filter(q=>q.event==="review.pass").length,failed:I.filter(q=>q.event==="review.fail").length,needsHuman:I.filter(q=>q.event==="review.needs_human").length},operatorActions:I.filter(q=>q.actorKind==="trail lead").length}}),f=h.filter(S=>S.outcome==="done"),p=Math.max(0,...f.map(S=>S.doneAt??0)),v=l.filter(S=>S.actorKind==="trail lead"),k=new Set(s.filter(S=>S.mapId===a).map(S=>S.id)).size,w=v.length,j=S=>h.reduce((I,$)=>I+S($),0),N=(o==null?void 0:o.costUsd)??0;return{mapId:a,tickets:h,done:f.length,cancelled:h.filter(S=>S.outcome==="cancelled").length,open:h.filter(S=>S.outcome==="open").length,trailLeadMs:p&&p>=e.map.createdAt?p-e.map.createdAt:void 0,medianLeadMs:Nj(f.flatMap(S=>S.leadMs===void 0?[]:[S.leadMs])),interventions:{answers:k,operatorActions:w,reworkRequested:v.filter(S=>S.event==="reject").length,total:k+w},rework:{tickets:h.filter(S=>S.reworks>0).length,cycles:j(S=>S.reworks)},reviews:{passed:j(S=>S.reviews.passed),failed:j(S=>S.reviews.failed),needsHuman:j(S=>S.reviews.needsHuman)},spend:{costUsd:Math.round(N*1e4)/1e4,tokens:((o==null?void 0:o.inputTokens)??0)+((o==null?void 0:o.outputTokens)??0),perVerifiedTicketUsd:f.length&&N?Math.round(N/f.length*1e4)/1e4:void 0}}}const Cc=e=>e.split("-")[0];function Qt(e){if(e===void 0)return"—";const t=Math.round(e/6e4);if(t<90)return`${t} min`;const s=e/36e5;return s<48?`${Math.round(s*10)/10} h`:`${Math.round(s/24*10)/10} d`}const mm=e=>e===void 0?"—":`$${e.toFixed(e<1?4:2)}`;function $j(e,t,s=Date.now()){const o=e.interventions;return[`# Trail report: ${t}`,"",`_Generated ${new Date(s).toISOString()} by Teamtrail._`,"","| Measure | Value |","| --- | --- |",`| Tickets done / cancelled / open | ${e.done} / ${e.cancelled} / ${e.open} |`,`| Trail lead time (created → last done) | ${Qt(e.trailLeadMs)} |`,`| Median ticket lead time (claim → done) | ${Qt(e.medianLeadMs)} |`,`| Human interventions | ${o.total} (${o.answers} answers, ${o.operatorActions} operator actions, ${o.reworkRequested} sent back) |`,`| Rework | ${e.rework.cycles} cycles on ${e.rework.tickets} tickets |`,`| Reviews | ${e.reviews.passed} passed, ${e.reviews.failed} failed, ${e.reviews.needsHuman} needed a human |`,`| Spend | ${mm(e.spend.costUsd)} · ${e.spend.tokens.toLocaleString("en-US")} tokens |`,`| Cost per verified ticket | ${mm(e.spend.perVerifiedTicketUsd)} |`,"","## Tickets","","| Ticket | Type | Outcome | Lead time | Rework | Reviews (pass/fail) | Operator actions |","| --- | --- | --- | --- | --- | --- | --- |",...e.tickets.map(l=>`| ${l.key} ${l.title.replace(/\|/g,"\\|")} | ${l.type} | ${l.outcome} | ${Qt(l.leadMs)} | ${l.reworks} | ${l.reviews.passed}/${l.reviews.failed} | ${l.operatorActions} |`),""].join(`
|
|
112
|
+
`)}const Ed=5,mg=1.5,Cj=15,$o=e=>Math.round(e*100);function Tj(e){const t=e.filter(d=>d.findings.raised>=Ed).sort((d,h)=>h.findings.upheld/h.findings.raised-d.findings.upheld/d.findings.raised||d.key.localeCompare(h.key));if(t.length<2)return[];const[s,o]=[t[0],t[t.length-1]],[a,l]=[s.findings.upheld/s.findings.raised,o.findings.upheld/o.findings.raised];return $o(a)-$o(l)<Cj?[]:[{id:"review-findings",text:`${s.key} review findings upheld ${$o(a)}% vs ${o.key} ${$o(l)}%`,because:`${s.findings.upheld} of ${s.findings.raised} and ${o.findings.upheld} of ${o.findings.raised} failed reviews stood; a finding is overruled when you accept the work anyway`}]}function Ej(e){const t=l=>l.reworkCycles/l.tickets,s=e.filter(l=>l.tickets>=Ed).sort((l,d)=>t(l)-t(d)||l.key.localeCompare(d.key));if(s.length<2)return[];const[o,a]=[s[0],s[s.length-1]];return t(a)-t(o)<.2||t(a)<t(o)*mg?[]:[{id:"rework",text:`${a.key} work goes back to rework more: ${t(a).toFixed(1)} times per ticket vs ${o.key} ${t(o).toFixed(1)}`,because:`${a.reworkCycles} cycles on ${a.tickets} tickets, and ${o.reworkCycles} on ${o.tickets}`}]}function Aj(e,t){const s=d=>d.medianLeadMs??0,o=t.filter(d=>d.done>=Ed&&d.medianLeadMs!==void 0).sort((d,h)=>s(d)-s(h)||d.key.localeCompare(h.key));if(o.length<2)return[];const[a,l]=[o[0],o[o.length-1]];return s(l)<s(a)*mg?[]:[{id:`speed-${e}`,text:`${e} tickets: ${a.key} is faster, ${Qt(a.medianLeadMs)} vs ${l.key} ${Qt(l.medianLeadMs)}`,because:`Median first claim to done, over ${a.done} and ${l.done} done tickets`}]}function Ij(e){const t=Object.keys(e.byTypeAndVendor).sort();return[...Tj(e.byVendor),...Ej(e.byVendor),...t.flatMap(s=>Aj(s,e.byTypeAndVendor[s]))]}const Rj=e=>{if(!e.length)return;const t=[...e].sort((o,a)=>o-a),s=Math.floor(t.length/2);return t.length%2?t[s]:Math.round((t[s-1]+t[s])/2)},pg=e=>{var t;return(t=e.filter(s=>s.event==="claim"&&s.actorKind==="agent").at(-1))==null?void 0:t.actor},td=(e,t,s)=>e.filter(o=>o.mapId===t&&o.ticketId===s).sort((o,a)=>o.at-a.at);function Mj(e,t){return e.tickets.flatMap(s=>{var k;if(s.type!=="review"||!s.reviewOf)return[];const o=td(t,e.map.id,s.id),a=pg(o);if(!a)return[];const l=((k=o.filter(w=>w.event==="claim").at(-1))==null?void 0:k.at)??0,d=td(t,e.map.id,s.reviewOf),h=d.findIndex(w=>w.at>=l&&w.event.startsWith("review."));if(h<0||d[h].event!=="review.fail")return[];const f=d.slice(h+1),p=f.findIndex(w=>w.event.startsWith("review.")),v=p<0?f:f.slice(0,p);return[{reviewer:a,upheld:!v.some(w=>w.event==="accept"&&w.actorKind==="trail lead")}]})}function Lj(e,t){var o;const s=(o=e.tickets.find(a=>a.id===t))==null?void 0:o.assignee;return s&&/^[a-z]+-\d+$/.test(s)?s:void 0}function gg(e,t){const s=a=>t.reduce((l,{ticket:d})=>l+a(d),0),o=a=>t.filter(l=>l.ticket.outcome===a).length;return{key:e,tickets:t.length,done:o("done"),cancelled:o("cancelled"),open:o("open"),medianLeadMs:Rj(t.flatMap(({ticket:a})=>a.leadMs===void 0?[]:[a.leadMs])),reworkCycles:s(a=>a.reworks),reviews:{passed:s(a=>a.reviews.passed),failed:s(a=>a.reviews.failed),needsHuman:s(a=>a.reviews.needsHuman)},answers:0,findings:{raised:0,upheld:0}}}function Co(e,t){const s=new Map;for(const o of e){const a=t(o);a&&s.set(a,[...s.get(a)??[],o])}return new Map([...s].map(([o,a])=>[o,gg(o,a)]))}const nd=(e,t)=>{const s=e.get(t)??gg(t,[]);return e.set(t,s),s};function pm(e,t,s){const o=nd(e,t);o.findings.raised+=1,s&&(o.findings.upheld+=1)}const To=e=>[...e.values()].sort((t,s)=>s.tickets-t.tickets||t.key.localeCompare(s.key));function vg(e){const t=e.flatMap(({snap:p,journal:v,answered:k,usage:w})=>fg({snap:p,journal:v,answered:k,usage:w}).tickets.map(j=>({ticket:j,agent:pg(td(v,p.map.id,j.id))??Lj(p,j.id)}))),s=p=>p.agent?Cc(p.agent):void 0,o=Co(t,p=>p.agent),a=Co(t,s),l=Co(t,p=>p.ticket.type),d=new Set;for(const{snap:p,journal:v,answered:k}of e){for(const w of k){const j=`${w.mapId}/${w.id}`;w.mapId!==p.map.id||d.has(j)||(d.add(j),nd(o,w.agent).answers+=1,nd(a,Cc(w.agent)).answers+=1)}for(const w of Mj(p,v))pm(o,w.reviewer,w.upheld),pm(a,Cc(w.reviewer),w.upheld)}const h=Object.fromEntries([...l.keys()].map(p=>[p,To(Co(t.filter(v=>v.ticket.type===p),s))])),f={trails:e.length,tickets:t.length,byAgent:To(o),byVendor:To(a),byType:To(l),byTypeAndVendor:h};return{...f,recommendations:Ij(f)}}const Oj={title:"Discovery brief: map the existing system",type:"research",body:["Investigate before anything is built, then call `submit_brief`. Cite real paths; never guess.","","- **Summary**: what this trail changes, in a few lines.","- **Product context**: who it affects, the business rules and UX principles that apply, plan or pricing constraints. Ask the human with `ask_human` when the repo doesn't tell you.","- **Existing implementation**: the files, services and modules involved, each with its path and one line.","- **Conventions and abstractions** to follow.","- **Data model impact** and **API impact**.","- **Risks and possible regressions**.","- **Assumptions** you rely on, and **open questions**.","","Implementation tickets (task, execute, prototype) can be claimed once the human accepts the brief. Afterwards, revise the planned tickets with `add_ticket` and `update_trail` if the brief changed the picture."].join(`
|
|
113
|
+
`)},Pj=[["summary","Summary"],["productContext","Product context"],["existing","Existing implementation"],["conventions","Conventions and abstractions"],["dataModel","Data model impact"],["api","API impact"],["risks","Risks and possible regressions"],["assumptions","Assumptions"],["openQuestions","Open questions"]],Yi=Object.fromEntries(Pj);function _j(e,t){const s=new Set(e.map(o=>o.source).filter(Boolean));return t.filter(o=>!s.has(o))}const Dj=["architecture","convention","gotcha","dead-end","glossary","fact"],kg=["business-rule","product-decision","persona","ux-principle","pricing"],zj=[...Dj,...kg],Bj=e=>e.status==="confirmed"||e.status==="assumption";function Fj(e,t){return Wp(e,t.replace(/^\.\//,""),{segments:!0})}const Uj={"business-rule":3,convention:3,"product-decision":2,architecture:2,gotcha:2,"dead-end":2,"ux-principle":2},Wj=["business-rule","ux-principle","convention"],gm=600,Hj=e=>`flagged as possibly outdated by ${e}; the human is reviewing it`,Kj=new Set("the and for with from into onto that this these those than then through use uses using via all any are was were will can should must not only also each when what where which who how per our your their its".split(" ")),vm=e=>new Set((e.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(t=>!Kj.has(t)));function yg(e,t,s=4e3,o=()=>[]){const a=t.ticket?vm(`${t.ticket.title} ${t.ticket.body}`):new Set,l=new Set((t.tags??[]).map(p=>p.toLowerCase())),d=e.filter(Bj).map(p=>{const v=[];let k=Uj[p.kind]??1;for(const N of p.scope){const S=t.paths.find(I=>Fj(N,I));if(S){k+=6,v.push(`path match ${N} (${S})`);break}}const w=p.tags.filter(N=>l.has(N.toLowerCase())||a.has(N.toLowerCase()));w.length&&(k+=3*w.length,v.push(`tag ${w.join(", ")}`));const j=[...vm(p.title)].filter(N=>a.has(N));return j.length&&(k+=j.length,v.push(`mentions ${j.slice(0,3).join(", ")}`)),t.trailKey&&p.sources.includes(`trail:${t.trailKey}`)&&(k+=3,v.push("same trail")),t.discovery&&kg.includes(p.kind)&&(k+=8,v.push("product context for discovery")),!v.length&&Wj.includes(p.kind)&&!p.scope.length&&v.push(`${p.kind.replace("-"," ")} for the whole project`),{e:p,score:k,why:v}}).filter(p=>p.why.length>0).sort((p,v)=>v.score-p.score||p.e.id.localeCompare(v.e.id,void 0,{numeric:!0})),h=[];let f=0;for(const{e:p,why:v}of d){const k=p.body.length>gm?`${p.body.slice(0,gm)}…`:p.body;if(f+k.length>s&&h.length)break;f+=k.length;const w=o(p);h.push({id:p.id,title:p.title,kind:p.kind,status:p.status,body:k,why:v,...w.length?{mayBeOutdated:w}:{},...p.flag?{flagged:Hj(p.flag.by)}:{}})}return h}const Vj=new RegExp("`([^`\\s]+/[^`\\s]+)`|(?:^|[\\s(])/?((?:[\\w.-]+/)+[\\w.-]+)","gm");function wg(e){const t=new Set;for(const s of e.matchAll(Vj))t.add((s[1]??s[2]).replace(/^\.?\//,"").replace(/[.,;:]+$/,""));return[...t]}const Gj=[{level:"high",label:"High risk"},{level:"medium",label:"Medium risk"},{level:"low",label:"Low risk"},{level:"none",label:"No category"}];function qj(e){return Gj.map(t=>({...t,decisions:e.filter(s=>{var o;return(((o=s.risk)==null?void 0:o.level)??"none")===t.level})})).filter(t=>t.decisions.length)}const Qj=1/3;function ca(e,t=Date.now()){const s=e.expiresAt-t;return s<=0?"expired":s<=e.ttlMs*Qj?"stalled":"live"}function Yj(e){var t;return((t=e.returned)==null?void 0:t.reason)==="trail lead"?`${e.ticketKey} returned to queue · claim of ${e.agent} released by ${e.returned.by}`:`${e.ticketKey} returned to queue after ${e.agent} went silent`}const Jj=e=>e.urgency==="fyi"||e.kind==="policy";function Xj(e){const t=e.filter(([s,o])=>na.includes(s)&&Up(o));return Object.fromEntries(t)}const km=e=>Number(e.slice(0,2))*60+Number(e.slice(3,5));function Zj(e,t){const s=new Date(t),o=s.getHours()*60+s.getMinutes(),a=km(e.from),l=km(e.to),d=l<=a;if(!(d?o>=a||o<l:o>=a&&o<l))return!1;if(!e.days)return!0;const f=d&&o<l,p=(s.getDay()+(f?6:0))%7;return e.days.includes(p)}function e0(e,t){const s=new Date(t);return s.setHours(Number(e.to.slice(0,2)),Number(e.to.slice(3,5)),0,0),s.getTime()<=t&&s.setDate(s.getDate()+1),s.getTime()}function t0(e,t){const s=e.focusUntil??0;if(s>t)return{kind:"manual",until:s};if(!e.focus||!Zj(e.focus,t))return{kind:"off"};const o=e0(e.focus,t);return(e.focusOffUntil??0)>t?{kind:"paused",until:o}:{kind:"hours",until:o}}function n0(e,t,s){const o={...e};switch(delete o.focusUntil,delete o.focusOffUntil,t.kind){case"for":return{...o,focusUntil:s+t.minutes*6e4};case"resume":return o;case"end":{const a=t0(o,s);return a.kind==="hours"?{...o,focusOffUntil:a.until}:o}default:return t}}const s0=e=>({id:e.id,key:e.key,title:e.title,...e.archived?{archived:!0}:{}});function i0(e,t){var o;const s={...e};return t.verification===null?delete s.verification:t.verification&&(s.verification=t.verification),t.guides===null||((o=t.guides)==null?void 0:o.length)===0?delete s.guides:t.guides&&(s.guides=t.guides),t.modelMatching===null?delete s.modelMatching:t.modelMatching&&(s.modelMatching=t.modelMatching),t.confirm&&delete s.settingsUnconfirmed,s}function r0(e,t,s){const o=Date.now();return{id:e,key:t,...s,state:"open",blockedBy:[],comments:[],createdAt:o,updatedAt:o}}const o0=(e,t)=>({...e,blockedBy:e.blockedBy.filter(s=>s!==t)}),a0=(e,t)=>{var s;return{...e,...(s=t.title)!=null&&s.trim()?{title:t.title.trim()}:{},...t.body!==void 0?{body:t.body}:{}}};function l0(e){const{closeReason:t,closedAt:s,...o}=e;return{...o,state:"open"}}const c0=["status","verification","checks","reviewOf","guide"];function d0(e,t){const s={...e};for(const o of c0)t[o]!==void 0&&(t[o]===null?delete s[o]:s[o]=t[o]);return t.confirm&&delete s.settingsUnconfirmed,s}function u0(e,t){const s={...e};return t?s.archived=!0:delete s.archived,s}async function xg(e){const t=await e.list(),s=t.filter(a=>!a.includes("/decisions/")).map(a=>{var l;return Number(((l=a.match(/(\d+)\.md$/))==null?void 0:l[1])??0)}),o=await Promise.all(t.filter(a=>a.endsWith("/map.md")).map(async a=>Number(ye(la(await e.read(a)).front.key).replace(/\D/g,""))||0));return Math.max(0,...s,...o)+1}const jg="### [^\\n]* @ \\d{4}-\\d\\d-\\d\\dT",Sg=`## Comments\\s*$|${jg}`,Ng=`<!-- ${Z.labelPrefix}:comments -->`,h0=new RegExp(`^## Comments[ \\t]*\\n${Ng}[ \\t]*$`,"m"),f0=new RegExp(`^(?=${jg})### `,"m"),Ad=2,bg=e=>ia(sa(e,Sg)),ym=e=>zo(Gs(e),Sg);function m0(e,t){const s=(t>=Ad?h0:/^## Comments\s*$/m).exec(e);return s?[e.slice(0,s.index),e.slice(s.index+s[0].length)]:[e,""]}function wm(e){const{front:t,body:s}=la(e),o=Number(ye(t.format))||1,[a,l]=m0(s,o),d=l.split(o>=Ad?f0:/^### /m).slice(1).map((v,k)=>{const w=v.indexOf(`
|
|
114
|
+
`),j=v.slice(0,w),N=j.lastIndexOf(" @ ");return{id:`c${k}`,author:j.slice(0,N<0?void 0:N).trim(),createdAt:N>=0&&Date.parse(j.slice(N+3))||0,body:ym(v.slice(w+1).trim())}}),h=ye(t.close_reason),f=Tw.find(v=>v===ye(t.status)),p=Bp(ye(t.verification));return{id:ye(t.id),key:`#${ye(t.id)}`,title:ye(t.title),type:ye(t.type)||"task",hitl:qt(t.labels).includes(jd)||void 0,state:ye(t.state)==="closed"?"closed":"open",closeReason:h==="completed"||h==="not_planned"?h:void 0,assignee:ye(t.assignee)||void 0,...f?{status:f}:{},...p?{verification:p}:{},...t.checks!==void 0?{checks:qt(t.checks)}:{},...ye(t.review_of)?{reviewOf:ye(t.review_of)}:{},...ye(t.guide)?{guide:ye(t.guide)}:{},blockedBy:qt(t.blocked_by),body:ym(a.trim()),comments:d,createdAt:qs(t.created),updatedAt:qs(t.updated),closedAt:qs(t.closed)||void 0}}function $g(e){const t={id:e.id,format:String(Ad),title:e.title,type:e.type,labels:[ta(e.type),...Sw(e.type)&&e.hitl?[jd]:[]],state:e.state,close_reason:e.closeReason??"",assignee:e.assignee??"",...e.status?{status:e.status}:{},...e.verification?{verification:e.verification}:{},...e.checks?{checks:e.checks}:{},...e.reviewOf?{review_of:e.reviewOf}:{},...e.guide?{guide:e.guide}:{},blocked_by:e.blockedBy,created:cn(e.createdAt),updated:cn(e.updatedAt),...e.closedAt?{closed:cn(e.closedAt)}:{}},s=e.comments.length?`
|
|
115
115
|
|
|
116
116
|
## Comments
|
|
117
117
|
${Ng}
|
|
@@ -131,37 +131,37 @@ ${bg(e.body)}`}async function g0(e,t,s){for(let o=0;;o++){const a=await t();if(s
|
|
|
131
131
|
chronic firejail systemd-run strace ltrace gdb lldb exec eval command busybox toybox parallel script
|
|
132
132
|
awk gawk mawk nawk sed gsed vim nvim vi ex emacs expect
|
|
133
133
|
`),Eo=["exec","x","dlx","install","i","add","ci","create","init","update","upgrade"],hS={npm:new Set(Eo),pnpm:new Set(Eo),yarn:new Set(Eo),bun:new Set(Eo),pip:new Set(["install","download","wheel"]),gem:new Set(["install","exec"]),cargo:new Set(["install","binstall"]),go:new Set(["install","get"]),deno:new Set(["eval","install"]),bundle:new Set(["install","exec"]),composer:new Set(["install","require","global","exec"])};function fS(e){const t=(e.split(/[\\/]/).pop()??"").toLowerCase().replace(/\.(exe|cmd|bat|com)$/,"");return t.replace(new RegExp("(?<=[a-z])[\\d.-]+$"),"")||t}const mS=e=>{var t;return((t=e.find(s=>!s.startsWith("-")))==null?void 0:t.toLowerCase())??""};function bm(e){const t=e.findIndex(s=>s.startsWith("-m"));if(!(t<0))return e[t]==="-m"?e[t+1]:e[t].slice(2)}const pS=new Set(["pip","ensurepip","pipx","uv","venv","http.server","webbrowser"]);function gS(e,t){var o;if(lS.has(e))return`runs a shell (${e}); name the program and its arguments instead`;if(cS.has(e))return`runs ${e}, which reaches the network`;if(dS.has(e))return`runs ${e}, which downloads and runs a package; use one installed in the repo`;if(uS.has(e))return`runs ${e}, which runs another program or commands; name that program instead`;if(e.startsWith("git-"))return`runs a git program directly (${e})`;const s=mS(t);if((o=hS[e])!=null&&o.has(s))return`runs ${e} ${s}, which downloads packages; use one installed in the repo`;if(e==="python"&&pS.has(bm(t)??""))return`runs python -m ${bm(t)}, which downloads or serves`;if(e==="find"&&t.some(a=>/^-(exec|execdir|ok|okdir|delete)$/.test(a)))return"runs find with -exec or -delete, which runs or removes other things"}function Ag(e){const t=e.run[0]??"";return{argv0:t,program:fS(t),args:e.run.slice(1)}}function vS(e){const{argv0:t,program:s,args:o}=Ag(e),a=Eg({argv0:t,program:s,args:o}),l=[gS(s,o),sS(s,o),s==="git"?X0(o):void 0,V0(s,o),Q0(o,a)].filter(d=>!!d);return e.cwd&&(e.cwd.startsWith("/")||e.cwd.split(/[\\/]/).includes(".."))&&l.push("cwd must stay inside the repo"),l}const kS="unknown program: Teamtrail can't tell what this runs";function yS(e){if(vS(e).length)return;const{argv0:t,program:s,args:o}=Ag(e);return aS({argv0:t,program:s,args:o})?void 0:kS}function wS(e,t={}){const s=(t.query??"").toLowerCase().split(/\s+/).filter(Boolean);return e.guides.filter(o=>{if(t.verifiedOnly&&!o.verified&&!o.builtin)return!1;const a=[o.id,o.name??"",o.summary,o.author].join(" ").toLowerCase();return s.every(l=>a.includes(l))})}const xS="unknown model",jS=e=>`${Math.round(e.firstTimeRate*100)}%`,$m=(e,t)=>`${e.model} passes ${jS(e)} of your ${t} tickets first time (${e.tickets} tickets)`;function SS(e,t){return t.firstTimeRate-e.firstTimeRate||(e.costPerVerifiedUsd??1/0)-(t.costPerVerifiedUsd??1/0)||e.key.localeCompare(t.key)}function NS(e){return[...new Set(e.scorecard.byTypeAndModel.map(s=>s.type??""))].filter(Boolean).sort().flatMap(s=>{const o=e.scorecard.byTypeAndModel.filter(f=>f.type===s&&f.enough&&f.model!==xS).sort(SS);if(o.length<2||o[0].firstTimeRate===o[1].firstTimeRate)return[];const a=o[0],l=Dw(a.model,e.models).tier,d=e.tiers[s];if(!d||l===d)return[];const h=`${$m(a,s)}; ${$m(o[1],s)}`;return[{type:s,current:d,tier:l,model:a.model??"",because:h}]})}const Cm=e=>`${Math.round(e*100)}%`,bS=e=>e===void 0?"–":`$${e.toFixed(2)}`,Ig=e=>e.replace(/[^\w .@/·-]/g,"").slice(0,60);function Tm(e,t){return[`| ${t} | Tickets | Verified first time | Rework | Attempts per verified | Cost per verified |`,"| --- | ---: | ---: | ---: | ---: | ---: |",...e.map(s=>[`| ${Ig(s.key)}${s.enough?"":" (too few)"}`,s.tickets,Cm(s.firstTimeRate),Cm(s.reworkRate),s.attemptsPerVerified??"–",`${bS(s.costPerVerifiedUsd)} |`].join(" | "))]}function $S(e,t="Agent scorecard"){return[`## ${Ig(t)}`,"",`${e.tickets} tickets with a completion, measured by Teamtrail on this repo. Groups under ${e.minSample} tickets are marked too few and aren't compared.`,"",...Tm(e.byTypeAndModel,"Ticket type · model"),"",...Tm(e.byVendor,"Vendor")].join(`
|
|
134
|
-
`)}const Tc="No area yet";function CS(e){return[`<path d="M24 210Q26 162 72 152H150Q190 158 192 210Z" fill="${e.shell}"/>`,`<path d="M24 210Q26 162 72 152H84Q58 166 58 210Z" fill="${e.shade}"/>`,`<path d="M66 154Q108 160 160 154L156 162Q108 168 70 162Z" fill="${e.side}"/>`,`<path d="M88 152L122 196L156 152Z" fill="${e.orange}"/>`,`<path d="M88 152L122 196L112 152Z" fill="${e.orangeDark}"/>`,`<circle cx="122" cy="161" r="8" fill="${e.orangeDark}"/><circle cx="124" cy="159" r="3" fill="${e.orange}"/>`].join("")}const Ec={x:112,w:15},Ac={x:136,w:10};function Em({x:e,w:t},s,o,a){const l=e+s;return[`<rect x="${l}" y="${94+o}" width="${t}" height="12" rx="${t>12?5:4}" fill="${a.glowLight}"/>`,`<rect x="${l}" y="${100+o}" width="${t}" height="6" rx="3" fill="${a.glow}"/>`,`<rect x="${l+t-6}" y="${96+o}" width="${t>12?3.5:2.5}" height="3.5" rx="1" fill="#fff"/>`].join("")}function Am({x:e,w:t},s){const o=t+3,a=t>12?6:5;return`<rect x="${e-2}" y="90" width="${o}" height="18" rx="${o/2.6}" fill="${s.glowLight}"/><rect x="${e-2+(o-a)/2}" y="96" width="${a}" height="6" rx="2" fill="${s.glass}"/>`}function TS(e,t){if(e==="closed")return[Ec,Ac].map(({x:a,w:l})=>`<rect x="${a}" y="100" width="${l}" height="4" rx="2" fill="${t.glow}"/>`).join("");if(e==="wide")return Am(Ec,t)+Am(Ac,t);const[s,o]=e==="aside"?[4,-5]:[0,0];return Em(Ec,s,o,t)+Em(Ac,s,o,t)}function ES(e,t){return e==="open"?`<rect x="124" y="114" width="16" height="9" rx="4.5" fill="${t.glowLight}"/><rect x="127" y="119" width="10" height="4" rx="2" fill="${t.glow}"/>`:e==="mid"?`<rect x="126" y="115" width="12" height="5" rx="2.5" fill="${t.glowLight}"/>`:e==="aside"?[0,1,2].map(s=>`<circle cx="${124+s*7}" cy="118" r="2.6" fill="${t.glow}"/>`).join(""):`<path d="M125 116q6 5 12 0" fill="none" stroke="${t.glow}" stroke-width="4" stroke-linecap="round"/>`}function AS({eyes:e,mouth:t},s){return TS(e,s)+ES(t,s)}function IS(e){return{shine:'<path d="M92 82h22l-14 20h-8z" fill="#fff" opacity=".08"/>',chin:[`<circle cx="100" cy="142" r="3" fill="${e.orange}"/>`,`<circle cx="109" cy="142" r="3" fill="${e.orangeDark}"/>`,[132,141,150].map(t=>`<rect x="${t}" y="139" width="5" height="7" rx="1.5" fill="${e.shellLight}"/>`).join("")].join(""),pine:`<path d="M125 42l8 11h-4l7 10h-22l7-10h-4z" fill="${e.hat}"/>`}}function RS(e,t,s,o){return[`<path d="M86 34L80 16" stroke="${o.band}" stroke-width="${s?6:4}" stroke-linecap="round"/>`,t?`<circle cx="79" cy="14" r="11" fill="${e}" opacity=".3"/>`:"",`<circle cx="79" cy="14" r="${s?8:6}" fill="${e}"/>`,t?'<circle cx="77" cy="12" r="2" fill="#fff3c4"/>':""].join("")}function MS({face:e,lamp:t,lit:s,simple:o,c:a}){const l=IS(a);return['<rect x="36" y="66" width="118" height="94" rx="22" fill="#000" opacity=".12"/>',`<path d="M50 96Q46 52 96 46" fill="none" stroke="${a.band}" stroke-width="8" stroke-linecap="round"/>`,`<path d="M44 78Q44 62 60 60L74 58V152L60 150Q44 148 44 132Z" fill="${a.side}"/>`,`<rect x="68" y="56" width="98" height="96" rx="20" fill="${a.shell}"/>`,`<rect x="72" y="60" width="8" height="84" rx="4" fill="${a.shellLight}"/>`,`<path d="M68 132H166V140Q166 152 152 152H82Q68 152 68 140Z" fill="${a.shade}"/>`,`<rect x="82" y="72" width="76" height="62" rx="16" fill="${a.frame}"/>`,`<rect x="86" y="76" width="70" height="55" rx="13" fill="${a.glass}"/>`,o?"":l.shine,e,o?"":l.chin,`<ellipse cx="50" cy="108" rx="13" ry="21" fill="${a.orangeDark}"/>`,`<ellipse cx="56" cy="108" rx="12" ry="20" fill="${a.orange}"/>`,`<ellipse cx="53" cy="104" rx="4" ry="11" fill="${a.orangeLight}"/>`,`<path d="M60 122Q64 146 88 148" fill="none" stroke="${a.band}" stroke-width="5" stroke-linecap="round"/>`,`<circle cx="90" cy="148" r="6" fill="${a.band}"/><circle cx="91.5" cy="146.5" r="2" fill="${a.orange}"/>`,RS(t,s,o,a),`<path d="M48 76Q46 30 104 28Q158 30 162 70Z" fill="${a.hat}"/>`,`<path d="M48 76Q46 34 88 29Q66 42 66 74Z" fill="${a.hatDark}"/>`,`<path d="M96 70Q96 40 126 36Q152 40 154 68Z" fill="${a.panel}"/>`,o?"":l.pine,`<path d="M150 82Q120 76 66 84L58 80Q56 72 64 70Q122 62 180 70Q190 76 182 84Z" fill="${a.brim}"/>`,'<path d="M70 84Q120 78 166 84L166 90Q120 84 70 90Z" fill="#000" opacity=".22"/>'].join("")}const LS={ground:"#4f8a48",groundLight:"#5d9a55",shell:"#eee7d3",shellLight:"#faf6ea",shade:"#c9bfa2",side:"#b3a98c",frame:"#a99f83",glass:"#13231e",glow:"#6fd197",glowLight:"#c2f2cf",orange:"#e07a2f",orangeLight:"#f29a55",orangeDark:"#a8481c",hat:"#8a5a38",hatDark:"#6b4630",brim:"#5a3a26",panel:"#ece2c6",band:"#3a4a43"},Rg={on:"#ffb347",dim:"#a8501c",alert:"#ff5a48"},OS={on:"#ffd166",dim:"#a8501c",alert:"#ff5a48"},PS={circle:100,rounded:46,square:0},_S=.94;let DS=0;function zS(e,{lamp:t=Rg,simple:s=!1,shape:o="circle",colors:a=LS}={}){const l=a,d=e.light??"on",h=o==="circle"?_S:1,f=100*(1-h),p=`scout-clip-${++DS}`,k=MS({face:AS(e,l),lamp:t[d],lit:d!=="dim",simple:s,c:l});return[`<defs><clipPath id="${p}"><rect width="200" height="200" rx="${PS[o]}"/></clipPath></defs>`,`<g clip-path="url(#${p})">`,`<rect width="200" height="200" fill="${l.ground}"/>`,`<circle cx="120" cy="88" r="74" fill="${l.groundLight}"/>`,`<g transform="translate(${f} ${f}) scale(${h})">${CS(l)}${k}</g>`,"</g>"].join("")}const Mg={crt:{id:"crt",name:"Day",blurb:"Scout looking to the side: a cap, a headset with a mic, an antenna lamp and a neckerchief.",lamp:Rg,wave:{bar:"#6f8a78",lead:"#c8581e"}},night:{id:"night",name:"Night",blurb:"The same Scout, with the antenna lamp burning brighter, for the night theme.",lamp:OS,wave:{bar:"#66828d",lead:"#e8833a"}}},BS="crt",FS={idle:{eyes:"open",mouth:"rest",light:"on"},speaking:{eyes:"open",mouth:"rest",light:"on"},thinking:{eyes:"aside",mouth:"aside",light:"dim"},alert:{eyes:"wide",mouth:"rest",light:"alert"}},US={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},xn={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function WS(e){return e?/[aeiouy]/i.test(e)?"open":/[a-z0-9]/i.test(e)?"mid":"rest":"rest"}function HS(e,t){return!e||!/[a-z0-9]/i.test(e)?0:/[aeiou]/i.test(e)?2+(e.charCodeAt(0)+t)%2:1+(e.charCodeAt(0)*7+t)%2}function KS(e,t,s){return Array.from({length:s},(o,a)=>{const l=t-(s-1-a);return l>=0&&l<e.length?HS(e[l],l):0})}function Lg({face:e={eyes:"open",mouth:"rest"},variant:t="crt",size:s,simple:o,shape:a="circle",className:l}){const{eyes:d,mouth:h,light:f}=e,p=y.useMemo(()=>zS({eyes:d,mouth:h,light:f},{lamp:Mg[t].lamp,simple:o??s<40,shape:a}),[d,h,f,t,o,s,a]);return i.jsx("svg",{className:l,width:s,height:s,viewBox:"0 0 200 200","aria-hidden":"true",dangerouslySetInnerHTML:{__html:p}})}function VS(e){const[t,s]=y.useState(!1);return y.useEffect(()=>{if(!e){s(!1);return}let o;const a=setInterval(()=>{s(!0),o=setTimeout(()=>s(!1),xn.blinkMs)},xn.blinkEveryMs);return()=>{clearInterval(a),o&&clearTimeout(o)}},[e]),t}const GS={xs:.8,sm:2,md:4,lg:6},qS=40,Im=20,Rm="(prefers-reduced-motion: reduce)",QS=40,YS=350;function JS(e,t){var h;const s=e.size??"md",o=e.state??"idle",a=((h=e.speaking)==null?void 0:h.trim())??"",l=a&&(o==="idle"||o==="speaking")?"speaking":o,d=s==="xs";return{size:s,text:a,effective:l,talking:l==="speaking"&&a.length>0,mini:d,framed:e.framed??!d,reduced:t||d}}const XS=e=>e.length*xn.msPerChar,ZS=(e,t)=>t&&(e.effective==="idle"||e.effective==="speaking"||e.effective==="alert");function e1(e,t,s,o){const a=FS[e.effective],l=s?"closed":a.eyes;let d=a.mouth,h=e.text.length-1;if(o)if(e.reduced)d="open";else{h=Math.min(e.text.length-1,Math.floor(t/xn.msPerChar));const p=Math.floor(t/xn.mouthHoldMs)*Math.round(xn.mouthHoldMs/xn.msPerChar);d=WS(e.text[Math.min(e.text.length-1,p)])}let f=a.light;return e.effective==="thinking"&&!e.reduced&&Math.floor(t/xn.thinkingStepMs)%2===1&&(f="on"),{eyes:l,mouth:d,light:f,cursor:h}}function t1(e,t){const s=typeof e.size=="number"?e.size:GS[e.size],o=e.reduced?Math.min(e.text.length-1,Im-1):t;return{base:s,px:qS*s,bars:Im,waveCursor:o}}function n1(e,{label:t,speechDone:s,cursor:o,caption:a}){const l=e.talking&&s?"idle":e.effective,d=US[l],h=e.size==="md"||e.size==="lg"||typeof e.size=="number"&&e.size>=4;return{shownState:l,status:d,ariaLabel:`${t}, ${d.toLowerCase()}`,showCaption:a??h,shown:s1(e,s,o)}}function s1(e,t,s){return e.talking?e.reduced||t?e.text:e.text.slice(0,s+1):""}function i1(){const[e,t]=y.useState(()=>{var s;return typeof window<"u"&&!!((s=window.matchMedia)!=null&&s.call(window,Rm).matches)});return y.useEffect(()=>{var a;const s=(a=window.matchMedia)==null?void 0:a.call(window,Rm);if(!s)return;const o=()=>t(s.matches);return o(),s.addEventListener("change",o),()=>s.removeEventListener("change",o)},[]),e}function r1(e,t,s){const[o,a]=y.useState(0);return y.useEffect(()=>{if(a(0),!t)return;const l=performance.now(),d=setInterval(()=>a(performance.now()-l),s);return()=>clearInterval(d)},[e,t,s]),o}function o1(e){const{key:t,talking:s,at:o}=e,a=o!==void 0,l=XS(e.text),[d,h]=y.useState(""),f=y.useRef(e.onSpeakEnd);f.current=e.onSpeakEnd,y.useEffect(()=>{if(!s||a)return;const j=setTimeout(()=>{var N;h(t),(N=f.current)==null||N.call(f)},l+YS);return()=>clearTimeout(j)},[s,t,l,a]);const p=s&&d!==t,k=r1(t,e.animate&&(p||e.thinking),p?QS:xn.thinkingStepMs),v=o??k,w=s&&(a?v>=l:d===t);return{t:v,speechDone:w}}const a1=e=>e*2,sd=3.5;function l1(e,t,s){return(e??[]).map((o,a)=>{const l=(1+2*o)*.5;return{x:a*2,y:(sd-l)/2,width:1,height:l,fill:a>=t-2&&o>0?s.lead:s.bar}})}function c1({heights:e,bars:t,unit:s,colors:o}){const a=a1(t);return i.jsx("svg",{className:`scout-wave${e?" on":""}`,width:a*s,height:sd*s,viewBox:`0 0 ${a} ${sd}`,"aria-hidden":"true",children:l1(e,t,o).map((l,d)=>i.jsx("rect",{...l},d))})}function ua({state:e="idle",size:t="md",speaking:s,variant:o=BS,framed:a,caption:l,label:d="Scout",onSpeakEnd:h,at:f,className:p,style:k}){const v=JS({state:e,size:t,speaking:s,framed:a},i1()),{text:w,effective:j,talking:N,reduced:S}=v,I=Mg[o],_=!S&&!(f!==void 0),O=`${j}|${o}|${w}`,{t:D,speechDone:q}=o1({key:O,text:w,talking:N,thinking:j==="thinking",animate:_,at:f,onSpeakEnd:h}),H=VS(ZS(v,_)),G=N&&!q,{eyes:oe,mouth:Q,light:ke,cursor:Oe}=e1(v,D,H,G),{base:Te,px:ne,bars:ce,waveCursor:F}=t1(v,Oe),J=y.useMemo(()=>G?KS(w,F,ce):null,[G,w,F,ce]),{shownState:ie,status:W,ariaLabel:X,showCaption:z,shown:T}=n1(v,{label:d,speechDone:q,cursor:Oe,caption:l}),P={...k,"--scout-u":`${Te}px`},de=i.jsx("span",{className:"scout-sprite",children:i.jsx(Lg,{face:{eyes:oe,mouth:Q,light:ke},variant:o,size:ne,simple:v.mini})});return v.framed?i.jsxs("figure",{className:`scout scout-panel scout-${ie} scout-v-${o} ${p??""}`,style:P,"data-state":ie,children:[i.jsxs("figcaption",{className:"scout-head",children:[i.jsx("span",{className:"scout-name",children:d}),i.jsx("span",{className:"scout-sep",children:"//"}),i.jsx("span",{className:"scout-status",children:W})]}),i.jsxs("div",{className:"scout-feed",role:"img","aria-label":X,children:[de,i.jsx(c1,{heights:J,bars:ce,unit:Te,colors:I.wave})]}),z&&i.jsxs("p",{className:"scout-caption","aria-hidden":"true",children:[T,N&&!q&&!S&&i.jsx("span",{className:"scout-caret",children:"_"})]}),w&&i.jsx("span",{className:"scout-sr","aria-live":"polite",children:w})]}):i.jsx("span",{className:`scout scout-bare scout-${ie} ${p??""}`,style:P,role:"img","aria-label":X,children:de})}const St="trail lead";function d1({rt:e,guard:t,setMapId:s,mapIdRef:o,snapRef:a,setChatSession:l,setSelection:d}){const h={actorKind:"trail lead",journal:e.journal};return{selectMap:f=>s(f),openChat:f=>l(f),answer:(f,p)=>e.activity.answer(f,p,St,{via:"lookout"}),claim:f=>t("Claim",()=>cm(e.adapter,o.current,f,{...h,assignee:St})),release:f=>t("Release claim",()=>Sx(e.adapter,o.current,f,{...h,actor:St})),releaseLease:f=>t("Release to queue",()=>e.leases.release(o.current,f,St)),resolve:(f,p,k={})=>t("Resolve · record answer",async()=>{var w;const v=(w=a.current)==null?void 0:w.tickets.find(j=>j.id===f);v&&!v.assignee&&await cm(e.adapter,o.current,f,{...h,assignee:St}),await Lx(e.adapter,o.current,f,{...h,answer:p,author:St,decision:{...k,source:{kind:"lookout",label:"Ticket inspector"}}})}),supersede:(f,p)=>t(`Supersede ${f.id}`,async()=>{let k=f.id;if(f.derived){const{id:v,mapId:w,derived:j,supersededBy:N,...S}=f;k=(await $d(e.adapter,f.mapId,S,{appendToTrail:!1})).id}await Cx(e.adapter,f.mapId,k,{...p,decidedBy:St,participants:[{id:St}],source:{kind:"lookout",label:"Logbook"}})}),graduate:({unspecified:f,...p})=>t(`Promote to ticket · ${f}`,async()=>{const k=await Px(e.adapter,o.current,f,p);d({kind:"ticket",id:k.id})}),ruleOut:(f,p)=>t("Rule out of scope",async()=>{await _x(e.adapter,o.current,f,{...h,reason:p,author:St,source:{kind:"lookout",label:"Ticket inspector"}}),d(null)}),setArchived:f=>t(f?"Archive trail":"Restore trail",async()=>{await Fx(e.adapter,o.current,f),f&&s(void 0)}),setMode:f=>t(`Trail mode · ${f}`,()=>Tx(e.adapter,o.current,f)),setModelMatching:f=>t(`Model matching · ${f.enabled?"on":"off"}`,()=>Dx(e.adapter,o.current,f))}}const Ge=(...e)=>e.filter(Boolean).join(" "),Ys="item",u1=/^[0-9a-f]{6,64}$/;function ur(){const e=new URLSearchParams(location.search).get("project")??void 0;return e&&u1.test(e)?e:void 0}function pe(e=ur()){return e?`${Z.apiPrefix}/p/${e}`:Z.apiPrefix}function h1(e){const t=new URLSearchParams(location.search);for(const o of["projects","project","tracker",Ys])t.delete(o);e.item&&t.set(Ys,e.item),e.id&&e.id!==e.home&&t.set("project",e.id),e.id&&e.id!==e.home&&e.tracker&&t.set("tracker",e.tracker);const s=t.toString();return`${location.pathname}${s?`?${s}`:""}`}async function f1(){var s,o;const e=await fetch(`${pe()}/verification/config`).then(a=>a.ok?a.json():void 0).catch(()=>{}),t=((s=e==null?void 0:e.approval)==null?void 0:s.state)==="approved"?(o=e.config)==null?void 0:o.default:void 0;return t&&t!=="off"?t:void 0}async function m1(e,t){var d;const s=(t.assumptions??[]).map((h,f)=>({id:`S-${f+1}`,text:h,status:"holding",tickets:[]})),o=await f1(),{map:a,tickets:l}=await hx(e,{title:t.title,...o?{verification:o}:{},sections:{destination:t.destination,notes:t.notes,decisions:[],unspecified:[],outOfScope:[],...s.length?{assumptions:s}:{}},tickets:[{ref:"discovery",...Oj}]});return await fetch(`${pe()}/briefs/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:a.id,ticketId:(d=l[0])==null?void 0:d.id})}),a}function Og(e,t){const s=URL.createObjectURL(new Blob([t],{type:"text/markdown;charset=utf-8"}));Object.assign(document.createElement("a"),{href:s,download:e}).click(),setTimeout(()=>URL.revokeObjectURL(s),1e3)}function hn(e){const t=Math.max(0,Math.floor(e/1e3));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`}function Pg(e){const t=Math.max(0,Math.floor(e/1e3)),s=o=>String(o).padStart(2,"0");return`${s(Math.floor(t/3600))}:${s(Math.floor(t%3600/60))}:${s(t%60)}`}const ha=e=>new Date(e).toTimeString().slice(0,8);function Jt(e){if(e<1e3)return`${Math.round(e)}ms`;const t=Math.round(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${String(t%60).padStart(2,"0")}s`:`${Math.floor(t/3600)}h ${String(Math.floor(t%3600/60)).padStart(2,"0")}m`}function fa(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const Js=e=>`$${e<10?e.toFixed(2):e.toFixed(1)}`,Xs=e=>new Date(e).toISOString().slice(0,10),Id=e=>new Date(e).toTimeString().slice(0,5),p1=e=>`${Xs(e)} ${Id(e)}`,_g=e=>{if(!e)return"";const t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:`${Math.round(t/60)}m ago`},hr=e=>e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",Zs={research:"Research",prototype:"Prototype",junction:"Junction",task:"Task",execute:"Execute",review:"Review"},Dg={decided:"Done",claimed:"Working",frontier:"Ready",blocked:"Backlog",parked:"Parked (plan-only)","out-of-scope":"Cancelled",verifying:"Verifying",rework:"Rework",held:"Blocked"},g1={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function Rd(e,t){return new Map((e??[]).filter(s=>s.mapId===t&&!s.returned).map(s=>[s.ticketId,s]))}function ni(){let e=0,t=0;return{start(){const s=++e;return()=>s<=t?!1:(t=s,!0)},pushed(){t=++e}}}const v1=8,k1=40;function y1(e,t){try{return new URL(e,t).origin===t}catch{return!1}}function zg(e,t){if(!Array.isArray(e))return[];const s=[];for(const o of e.slice(0,v1)){const{label:a,href:l}=o??{};if(typeof a!="string"||typeof l!="string")continue;const d=a.trim();!d||d.length>k1||!y1(l,t)||s.push({label:d,href:l})}return s}function ma(e){e==="auto"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}const w1=["auto","day","night"];function x1(e){const[t]=zg(e?[e]:[],location.origin);return t?{agents:t}:{}}const pa=e=>typeof e=="string"&&/^\/[\w/-]{1,100}$/.test(e)?e:void 0;function j1(e){const t=pa(e);return t?{themeSave:t}:{}}function S1(e){const t=pa(e);return t?{trailAgents:t}:{}}function N1(e){const t=pa(e);return t?{setup:t}:{}}function b1(e){const t=pa(e);return t?{merge:t}:{}}function $1(e){const t=e;if(typeof(t==null?void 0:t.label)!="string"||!t.label.trim()||t.label.length>60||typeof t.href!="string")return{};const s=Nn(t.href);return s?{home:{label:t.label.trim(),href:s}}:{}}let id;const ft=()=>id;function C1(e){const t=e.managed;if(!t||typeof t.name!="string")return;const s=typeof t.signOut=="string"&&new URL(t.signOut,location.href).origin===location.origin,o=zg(t.pages,location.origin),a=w1.find(l=>l===t.theme);return id={name:t.name,pages:o,...s?{signOut:t.signOut}:{},...a?{theme:a}:{},...j1(t.themeSave),...b1(t.merge),...N1(t.setup),...S1(t.trailAgents),...t.highRisk===!1?{highRisk:!1}:{},...$1(t.home),...t.tracker==="markdown"?{tracker:"markdown"}:{},...x1(t.agents)},a&&ma(a),id}const T1=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),rn=(e,t)=>e>>>t|e<<32-t;function E1(e){const t=Math.ceil((e.length+9)/64)*64,s=new Uint8Array(t);s.set(e),s[e.length]=128;const o=new DataView(s.buffer);return o.setUint32(t-8,Math.floor(e.length*8/2**32)),o.setUint32(t-4,e.length*8>>>0),s}function A1(e,t,s,o){for(let w=0;w<16;w++)o[w]=t.getUint32(s+w*4);for(let w=16;w<64;w++){const j=rn(o[w-15],7)^rn(o[w-15],18)^o[w-15]>>>3,N=rn(o[w-2],17)^rn(o[w-2],19)^o[w-2]>>>10;o[w]=o[w-16]+j+o[w-7]+N>>>0}let[a,l,d,h,f,p,k,v]=e;for(let w=0;w<64;w++){const j=v+(rn(f,6)^rn(f,11)^rn(f,25))+(f&p^~f&k)+T1[w]+o[w]>>>0,N=(rn(a,2)^rn(a,13)^rn(a,22))+(a&l^a&d^l&d)>>>0;[v,k,p,f,h,d,l,a]=[k,p,f,h+j>>>0,d,l,a,j+N>>>0]}[a,l,d,h,f,p,k,v].forEach((w,j)=>e[j]=e[j]+w>>>0)}function Ic(e){const t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=E1(e),o=new DataView(s.buffer),a=new Uint32Array(64);for(let h=0;h<s.length;h+=64)A1(t,o,h,a);const l=new Uint8Array(32),d=new DataView(l.buffer);return t.forEach((h,f)=>d.setUint32(f*4,h)),l}function I1(e,t){const s=new Uint8Array(64);s.set(e.length>64?Ic(e):e);const o=new Uint8Array(64+t.length),a=new Uint8Array(96);for(let l=0;l<64;l++)o[l]=s[l]^54,a[l]=s[l]^92;return o.set(t,64),a.set(Ic(o),64),Ic(a)}const Bg=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join(""),R1=e=>new Uint8Array((e.match(/../g)??[]).map(t=>parseInt(t,16))),Md=`${Z.slug}.session`;let Uo;const M1=e=>{const t=e;return!!t&&typeof t.id=="string"&&typeof t.secret=="string"&&typeof t.verifier=="string"};function Ld(){try{const e=JSON.parse(localStorage.getItem(Md)??"null");return M1(e)?e:Uo}catch{return Uo}}function L1(e){Uo=e;try{localStorage.setItem(Md,JSON.stringify(e))}catch{}}function Fg(){Uo=void 0;try{localStorage.removeItem(Md)}catch{}}let Od="unproven",Rc;const rd=new Set,Ug=e=>{Od=e;for(const t of rd)t(e)};function O1(e){return rd.add(e),()=>void rd.delete(e)}const P1=()=>Od==="proven",_1=()=>Od==="proven"&&Ug("unproven");function D1(){const e=new Uint8Array(16);return crypto.getRandomValues(e),Bg(e)}async function z1(){const e=Ld();if(!e)return"unknown";const t=D1(),s=await fetch(`${Z.apiPrefix}/session/prove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id,nonce:t})}).catch(()=>{});if((s==null?void 0:s.status)===404)return Fg(),"unknown";const o=s!=null&&s.ok?(await s.json().catch(()=>({}))).proof:void 0,a=Bg(I1(R1(e.verifier),new TextEncoder().encode(`${t}
|
|
135
|
-
${location.origin}`)));return o===a?"proven":"failed"}function ga(){return Rc??(Rc=z1().then(e=>(Rc=void 0,Ug(e),e))),Rc}const B1=1e4;class Wg{constructor(t=pe(),s="/events"){le(this,"inner");le(this,"listeners",[]);le(this,"closed",!1);le(this,"retryMs",1e3);this.base=t,this.path=s,this.connect()}addEventListener(t,s){var o;this.listeners.push([t,s]),(o=this.inner)==null||o.addEventListener(t,s)}set onmessage(t){this.addEventListener("message",t)}set onerror(t){this.addEventListener("error",t)}close(){var t;this.closed=!0,(t=this.inner)==null||t.close()}async connect(){if(this.closed)return;if(ft())return this.open(`${this.base}${this.path}`);if(await ga()!=="proven")return this.failed();const t=await fetch(`${Z.apiPrefix}/sign-in/stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}).then(s=>s.ok?s.json():void 0).then(s=>s==null?void 0:s.ticket).catch(()=>{});if(!this.closed){if(!t)return this.failed();this.open(`${this.base}${this.path}?ticket=${encodeURIComponent(t)}`)}}open(t){const s=new EventSource(t);this.inner=s;for(const[o,a]of this.listeners)s.addEventListener(o,a);s.addEventListener("open",()=>this.retryMs=1e3),s.addEventListener("error",()=>{s.close(),_1(),this.retry()})}failed(){for(const[t,s]of this.listeners)t==="error"&&s(new Event("error"));this.retry()}retry(){this.closed||(setTimeout(()=>void this.connect(),this.retryMs),this.retryMs=Math.min(this.retryMs*2,B1))}}function F1(){if(ft())return void fetch(`${Z.apiPrefix}/session`,{cache:"no-store"}).then(e=>e.status===401&&location.reload());ga().then(e=>e==="unknown"&&location.reload())}let Dt;const Wo=new Set,or=new Map,Ho=new Set,Ko=new Set;function Hg(e){Dt==null||Dt.addEventListener(e,t=>{for(const s of or.get(e)??[])s(t.data)})}function va(){if(!Dt){Dt=new Wg,Dt.onerror=()=>{for(const e of Ko)e();F1()},Dt.addEventListener("open",()=>{for(const e of Ho)e()}),Dt.onmessage=e=>{const t=JSON.parse(e.data).path;if(typeof t=="string")for(const s of Wo)s(t)};for(const e of or.keys())Hg(e)}}function ka(){const e=[...or.values()].some(t=>t.size>0);Wo.size||e||Ho.size||Ko.size||(Dt==null||Dt.close(),Dt=void 0)}function Pd(e){return Wo.add(e),va(),()=>{Wo.delete(e),ka()}}function si(e,t){let s=or.get(e);return s||(s=new Set,or.set(e,s),Hg(e)),s.add(t),va(),()=>{s.delete(t),ka()}}function vs(e){return Ho.add(e),va(),()=>{Ho.delete(e),ka()}}function U1(e){return Ko.add(e),va(),()=>{Ko.delete(e),ka()}}const _d=(e,t)=>`${e}/${t}`;let Yt={reached:!1,live:!1,tickets:{}},od=!1;const ad=new Set,ld=new Set,W1=ni();let cd=0;const Kg=new Map;let Vg=0;function Vo(e){Yt=e;for(const t of ad)t()}function H1(e,t){const s=Object.fromEntries(e.map(o=>[_d(o.mapId,o.ticketId),o]));for(const[o,a]of Kg)a>t&&Yt.tickets[o]&&(s[o]=Yt.tickets[o]);return s}function Mm(){const e=W1.start(),t=cd;fetch(`${pe()}/verification/sync`).then(s=>s.ok?s.json():Promise.reject()).then(s=>e()&&Vo({reached:!0,live:!0,status:Vg>t?Yt.status:s.status,tickets:H1(s.tickets,t)}),()=>Yt.reached&&Vo({...Yt,live:!1}))}function K1(e){const t=JSON.parse(e);if(t.kind==="evidence")for(const a of ld)a();if(t.kind!=="sync")return;const s=t;Vg=++cd;const o={...Yt.tickets};for(const a of s.tickets){const l=_d(a.mapId,a.ticketId);o[l]=a,Kg.set(l,cd)}Vo({reached:!0,live:!0,status:s.status,tickets:o})}function Lm(){od=!0,si("verification",K1),U1(()=>Yt.reached&&Yt.live&&Vo({...Yt,live:!1})),vs(Mm),Mm()}const ei={subscribe(e){return od||Lm(),ad.add(e),()=>void ad.delete(e)},get:()=>Yt,onEvidence(e){return od||Lm(),ld.add(e),()=>void ld.delete(e)},ticket:(e,t,s)=>e.tickets[_d(t,s)]};function V1(e){if(e!=null&&e.flags.length)return e.flags.some(t=>t.severity==="alert")?"alert":"warn"}const Om={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:R0.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function Dd(){try{const e={...Om,...JSON.parse(localStorage.getItem(ea)??"{}")};return["markdown","github","linear"].includes(e.tracker)||(e.tracker="markdown"),e}catch{return Om}}const Mc=new Map,Lc=e=>`${pe()}/file?path=${encodeURIComponent(e)}`;async function Oc(e,t){const s=await e.json().catch(()=>({})),o=new Error(s.error??`${t}: ${e.status}`);return e.status===409?Object.assign(o,{stale:!0}):e.status===404?Object.assign(o,{code:"ENOENT"}):o}const G1={async list(){return(await(await fetch(`${pe()}/list`)).json()).files},async read(e){const t=await fetch(Lc(e));if(!t.ok)throw await Oc(t,`read ${e}`);const s=await t.text(),o=t.headers.get("ETag");return o&&Mc.set(e,{text:s,etag:o}),s},async write(e,t,s){const o=(s==null?void 0:s.base)===void 0?void 0:Mc.get(e),a=o&&o.text===(s==null?void 0:s.base)?{"If-Match":o.etag}:{},l=await fetch(Lc(e),{method:"PUT",body:t,headers:a});if(!l.ok)throw await Oc(l,`write ${e}`);Mc.delete(e)},async create(e,t){const s=await fetch(Lc(e),{method:"PUT",body:t,headers:{"If-None-Match":"*"}});if(s.status===412)return!1;if(!s.ok)throw await Oc(s,`create ${e}`);return!0},watch(e){return Pd(e)}},q1=15*6e4;class Q1{constructor(t){le(this,"leases",[]);le(this,"changes",new Qs);le(this,"logged",new Set);le(this,"since",Date.now()-q1);this.activity=t}subscribe(t){return this.changes.on(t)}set(t){var s;this.leases=t;for(const o of t){const a=`${o.mapId}/${o.ticketId}/${(s=o.returned)==null?void 0:s.at}`;!o.returned||o.returned.at<this.since||this.logged.has(a)||(this.logged.add(a),this.activity.push({source:"system",level:"warn",ticketId:o.ticketId,text:Yj(o)}))}this.changes.emit(t)}async release(t,s,o){const a=await fetch(`${pe()}/agents/leases/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,ticketId:s,by:o})});if(!a.ok)throw new Error((await a.json().catch(()=>({}))).error??`HTTP ${a.status}`)}}function Y1(e){e.remoteAnswer=(t,s,o)=>{fetch(`${pe()}/agents/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t.sessionId,questionId:t.id,text:s,author:o})}).then(async a=>{if(!a.ok)throw new Error((await a.json().catch(()=>({}))).error??`HTTP ${a.status}`)}).catch(a=>e.push({source:"system",level:"alert",sessionId:t.sessionId,text:`Answer not delivered to ${t.agent} · ${a.message}`}))}}function J1(e){const t=ni(),s=()=>{const o=t.start();fetch(`${pe()}/agents/leases`).then(a=>a.ok?a.json():{leases:[]}).then(({leases:a})=>o()&&e.set(a)).catch(()=>{})};si("leases",o=>{t.pushed(),e.set(JSON.parse(o).leases)}),vs(s),s()}function X1(e){let t=0;const s=new Map,o=()=>{const a=t;fetch(`${pe()}/agents`).then(l=>l.ok?l.json():{sessions:[]}).then(({sessions:l})=>[...l].reverse().filter(d=>(s.get(d.session.id)??0)<=a).forEach(d=>e.syncRemote(d))).catch(()=>{})};si("agent",a=>{const l=JSON.parse(a);s.set(l.session.id,++t),e.syncRemote(l)}),vs(o),o()}function Pm(e,t){Y1(e),J1(t),X1(e)}function _m(e){const t=s=>`${ea}:${e}:${s}`;return{get:s=>localStorage.getItem(t(s)),set:(s,o)=>{try{localStorage.setItem(t(s),o)}catch{}}}}const Z1=["markdown","github","linear"];function eN(){const e=new URLSearchParams(location.search).get("tracker");return e&&Z1.includes(e)?e:Dd().tracker}function tN(e){let t,s;const o=new Gx,a=new Q1(o),l={},d=Ux(pe());if(e==="github"||e==="linear"){const p=new E0(e,pe());p.openEvents=k=>new Wg(pe(),k),t=p,s=fetch(`${pe()}/trackers`).then(k=>k.json()).catch(()=>{}).then(k=>{p.location=(e==="github"?k==null?void 0:k.github.repo:[k==null?void 0:k.linear.teamKey,k==null?void 0:k.linear.projectName].filter(Boolean).join(" · "))||p.location;const v=_m(`${e}:${p.location}`);l.presence=new hm(v),o.ledger=new fm(v),Pm(o,a)})}else t=new C0(G1,`./${Z.dataDir}`),s=fetch(`${pe()}/list`).then(p=>p.json()).catch(()=>({root:"default"})).then(({root:p})=>{const k=_m(p);l.presence=new hm(k),o.ledger=new fm(k),Pm(o,a)});const h=Jx(t),f=h.adapter;return{kind:e,ready:s,get presence(){return l.presence},adapter:f,journal:d,monitor:h,activity:o,leases:a}}const dn=e=>e.status==="running",Gg=e=>dn(e)&&!!e.waitingOn,nN={blocking:0,soon:1,fyi:2};function sN(e,t,s){const o=e.filter(d=>d.sessionId===t),a=o.find(d=>d.id===s);if(a)return a;const l=d=>nN[d.urgency??"soon"];return[...o].sort((d,h)=>l(d)-l(h)||d.at-h.at)[0]}function Go(e,t=Date.now()){const s=Math.floor(Math.max(0,t-e)/6e4);if(s<1)return"just now";if(s<60)return`${s} min ago`;const o=Math.floor(s/60);if(o<24)return`${o} h ago`;const a=Math.floor(o/24);return a<30?a===1?"yesterday":`${a} days ago`:`on ${new Date(e).toISOString().slice(0,10)}`}const iN=/^slack:([A-Z0-9]+)$/i;function ps(e,t){var l;const s=(l=iN.exec(e))==null?void 0:l[1];if(!s)return e;if(t!=null&&t.owners.some(d=>d.id===s))return"you (Slack)";const o=t==null?void 0:t.allow.find(d=>d.id===s),a=(o==null?void 0:o.realName)||(o==null?void 0:o.name);return a?`${a} (Slack)`:"Slack user"}function qg(e,t){const s=ps(e.decidedBy,t);return e.decidedByName?`${e.decidedByName} (${s})`:s}function fs({n:e,urgent:t,pop:s,hideZero:o}){return i.jsx("span",{className:Ge("badge",t&&"urgent",s&&t&&"pop",o&&!e&&"zero"),children:o&&!e?"":e})}function M({variant:e="default",size:t="md",on:s,className:o,type:a,...l}){return i.jsx("button",{type:a??"button",className:Ge("btn",e!=="default"&&e,t==="sm"&&"sm",s&&"on",o),...l})}function un({as:e="div",tone:t,on:s,className:o,children:a,...l}){return i.jsx(e,{className:Ge("card",t,s&&"on",o),...l,children:a})}function ya({what:e,onReviewAgain:t}){return i.jsxs("div",{className:"changed-notice edge-note edge-attention",children:[i.jsxs("p",{className:"t-meta",children:[e," changed since you opened it: read it again before you approve it."]}),i.jsx(M,{size:"sm",onClick:t,children:"Review again"})]})}function ot({on:e,title:t,sub:s,disabled:o,onClick:a}){return i.jsxs(un,{as:"button",type:"button",className:"choice",on:e,disabled:o,onClick:a,children:[i.jsx("b",{className:"choice-title t-row-title",children:t}),s&&i.jsx("span",{className:"c-sub",children:s})]})}function Ie({children:e}){return i.jsx("div",{className:"empty",children:e})}function Sn({title:e,hint:t,art:s}){return i.jsxs("div",{className:s?"empty-state has-art":"empty-state",children:[s,i.jsxs("div",{className:"es-words",children:[i.jsx("span",{className:"es-title",children:e}),t&&i.jsx("span",{className:"es-hint",children:t})]})]})}function Ze({label:e,children:t,className:s}){return i.jsxs("label",{className:Ge("field",s),children:[e,t]})}const wa=y.forwardRef(function({value:t,onValueChange:s,onSubmit:o,action:a="Send",actionDisabled:l,className:d,...h},f){return i.jsxs("form",{className:Ge("input-row",d),onSubmit:p=>{p.preventDefault(),o(t)},children:[i.jsx("textarea",{ref:f,rows:1,value:t,onChange:p=>s(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),o(t))},...h}),i.jsx(M,{type:"submit",variant:"primary",disabled:l??(h.disabled||!t.trim()),children:a})]})});function ii({text:e}){return i.jsx("span",{className:"info-tip","data-tip":e,"data-tip-scout":!0,tabIndex:0,role:"img","aria-label":e,children:i.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[i.jsx("circle",{cx:"7",cy:"3.7",r:"1.3"}),i.jsx("path",{d:"M5.6 6.300H8v4.200h1v1.200H5v-1.200h1.200V7.500h-.6z"})]})})}function ze({as:e="span",variant:t="chip",hot:s,size:o,className:a,children:l,title:d}){return i.jsx(e,{className:Ge(t==="chip"?"chip-label":"mono-label",s&&"hot",o==="sm"&&(t==="chip"?"sm":"xs"),a),title:d,children:l})}const rN=e=>typeof e=="string"?{text:e}:e,oN=e=>Ge(e.code&&"t-code",e.strong&&"strong",e.urgent&&"urgent",e.className);function V(e){const t=e.parts.filter(s=>!!s&&(typeof s=="string"||!!s.text)).map(rN);return!t.length&&!e.children?null:i.jsxs("span",{className:Ge("meta-line t-meta",e.className),children:[t.map((s,o)=>i.jsxs("span",{children:[o>0&&i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:oN(s)||void 0,title:s.tip,children:s.text})]},o)),e.children]})}function zd(e){return i.jsxs("div",{className:"ds-load-failed",role:"alert",children:[i.jsx(V,{parts:[e.what,e.reason]}),i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onRetry,children:"Retry"})]})}function ri(e){const t=Array.from({length:e.rows??0},(s,o)=>o);return i.jsxs("div",{className:Ge("ds-loading",e.className),role:"status","aria-live":"polite",children:[i.jsxs("span",{className:"ds-loading-line t-meta",children:[i.jsx("span",{className:"ds-spinner","aria-hidden":"true"}),e.label]}),t.length>0&&i.jsx("ul",{className:"ds-skeleton-list","aria-hidden":"true",children:t.map(s=>i.jsxs("li",{className:"ds-skeleton-row",children:[i.jsx("span",{className:"ds-skeleton-bar title"}),i.jsx("span",{className:"ds-skeleton-bar meta"})]},s))})]})}const aN="M25.53 10.5 A11 11 0 1 1 16 5",lN="M20 5 L14.6 1.6 L14.6 8.4 Z";function oi({variant:e="mark",state:t="ok",size:s=20,className:o="",title:a}){const l=s<=14?3:2.4;return i.jsxs("svg",{className:`scout-mark mm-${e} mm-${t} ${o}`,viewBox:"0 0 32 32",width:s,height:s,role:a?"img":void 0,"aria-label":a,"aria-hidden":a?void 0:!0,children:[e==="status"||e==="alert"?i.jsx("circle",{cx:"16",cy:"16",r:"11",fill:"none",stroke:"currentColor",strokeWidth:l,strokeDasharray:t==="syncing"?"5 3.6":void 0}):i.jsx("path",{d:aN,fill:"none",stroke:"currentColor",strokeWidth:l,strokeLinecap:"butt"}),(e==="mark"||e==="action")&&i.jsx("path",{d:lN,fill:"currentColor"}),e==="action"&&i.jsx("path",{d:"M13 11 L21.5 16 L13 21 Z",fill:"currentColor"}),(e==="mark"||e==="voice")&&i.jsx("circle",{cx:"16",cy:"16",r:e==="voice"?4:3.4,fill:"currentColor"}),e==="status"&&(t==="idle"?i.jsx("circle",{cx:"16",cy:"16",r:"3.4",fill:"none",stroke:"currentColor",strokeWidth:"1.6"}):i.jsx("circle",{cx:"16",cy:"16",r:"4.2",fill:"currentColor"})),e==="alert"&&i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"14.4",y:"8.5",width:"3.2",height:"9.5",fill:"currentColor"}),i.jsx("rect",{x:"14.4",y:"20.5",width:"3.2",height:"3.2",fill:"currentColor"})]})]})}function dd({parts:e,className:t,as:s="div"}){const o=e.filter(a=>a!=null&&a!==!1&&a!=="");return i.jsx(s,{className:Ge("meta",t),children:o.map((a,l)=>i.jsxs("span",{children:[l>0&&" · ",a]},l))})}const Dm=()=>{const e=document.documentElement.dataset.theme;return e?e==="night":matchMedia("(prefers-color-scheme: dark)").matches};function Qg(){const[e,t]=y.useState(Dm);return y.useEffect(()=>{const s=()=>t(Dm()),o=matchMedia("(prefers-color-scheme: dark)");o.addEventListener("change",s);const a=new MutationObserver(s);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{o.removeEventListener("change",s),a.disconnect()}},[]),e}function cN(){const e=()=>window.innerWidth>=1440?"wide":window.innerWidth>=1024?"laptop":"mobile",[t,s]=y.useState(e);return y.useEffect(()=>{const o=()=>s(e());return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),t}const dN=15e3,zm=["pointerdown","pointermove","keydown","wheel","touchstart"];function uN(e,t,s,o){const[a,l]=y.useState(null),[d,h]=y.useState(!1),[f,p]=y.useState(!1),k=y.useRef(),v=y.useRef(Date.now()),w=y.useRef(!1),j=s.awayMinutes*6e4,N=y.useRef(t);N.current=t;const S=y.useRef(o);S.current=o;const I=y.useCallback((H,G)=>{const oe=N.current;return yj({snaps:Object.values(oe.allSnaps),decisions:oe.decisions,activity:oe.activity,ledger:e.activity.ledger,since:Q=>{var ke;return H[Q]??G??((ke=oe.allSnaps[Q])==null?void 0:ke.map.createdAt)??Date.now()},currentMapId:oe.mapId,attention:S.current})},[e]),$=y.useCallback((H=Date.now())=>{var G;return(G=e.presence)==null?void 0:G.markSeen(N.current.maps.map(oe=>oe.id),H)},[e]),_=y.useCallback(()=>{const H=e.presence;if(!H)return;const G=H.lastSeenAny();if(G!==void 0&&Date.now()-G>=j){const oe=H.snapshot();I(oe,G).changed&&(k.current={seen:oe,any:G},h(!0),s.enabled?l(oe):p(!0))}$()},[e,j,s.enabled,I,$]);y.useEffect(()=>{!t.loaded||w.current||!e.presence||(w.current=!0,_())},[t.loaded,e,_]),y.useEffect(()=>{const H=()=>{const Q=Date.now()-v.current>=j;v.current=Date.now(),Q&&w.current&&document.visibilityState==="visible"&&_()},G=()=>{if(document.visibilityState!=="visible"){w.current&&$(Date.now()-v.current<j?Date.now():v.current);return}v.current=Date.now(),w.current&&_()};for(const Q of zm)window.addEventListener(Q,H,{passive:!0});document.addEventListener("visibilitychange",G);const oe=setInterval(()=>{w.current&&document.visibilityState==="visible"&&$(v.current)},dN);return()=>{for(const Q of zm)window.removeEventListener(Q,H);document.removeEventListener("visibilitychange",G),clearInterval(oe)}},[j,_,$]);const O=y.useMemo(()=>{var H;return a?I(a,(H=k.current)==null?void 0:H.any):void 0},[a,I,t.allSnaps,t.decisions,t.activity,o]),D=y.useMemo(()=>O?Sj(O):"",[O]);y.useEffect(()=>{a&&p(!1)},[a]);let q="none";return f?q="new":d&&(q="seen"),{shown:a!==null,status:q,briefing:O,line:D,open:()=>{const H=k.current;H&&l(H.seen)},dismiss:()=>l(null)}}function hN(e){const[t,s]=y.useState(e.leases.leases);return y.useEffect(()=>e.leases.subscribe(s),[e]),t}const fN="That changed while you were on it, so nothing was written. It is reloaded now: look again, then redo the change.";function mN(e){var X;const[t,s]=y.useState([]),[o,a]=y.useState(),[l,d]=y.useState(),[h,f]=y.useState({}),[p,k]=y.useState({}),[v,w]=y.useState(!1),[j,N]=y.useState(e.activity.snapshot),[S,I]=y.useState(e.monitor.health),$=hN(e);y.useEffect(()=>e.monitor.subscribe(I),[e]);const[_,O]=y.useState(null),[D,q]=y.useState(),[H,G]=y.useState(),oe=y.useRef(),Q=y.useRef(),ke=y.useRef(new Set),Oe=y.useRef();Oe.current=l;const Te=y.useCallback(z=>{oe.current=z,a(z),O(null)},[]),[ne]=y.useState(ni),ce=y.useCallback(async()=>{var je;const z=ne.start(),T=await e.adapter.listMaps();let P=oe.current;const de=Q.current;de&&T.some(ge=>ge.id===de)?(Q.current=void 0,P=de,P!==oe.current&&Te(P)):(!P||!T.some(ge=>ge.id===P))&&(P=(je=Cw(T)[0])==null?void 0:je.id,Te(P));const[me,we]=await Promise.all([Promise.all(T.map(ge=>e.adapter.loadMap(ge.id))),Promise.all(T.map(ge=>e.adapter.listDecisions(ge.id)))]);z()&&(s(T),f(Object.fromEntries(me.map(ge=>[ge.map.id,ge]))),k(Object.fromEntries(T.map((ge,Se)=>[ge.id,we[Se]]))),w(!0),d(me.find(ge=>ge.map.id===P)))},[e,Te,ne]);y.useEffect(()=>{let z,T=()=>{},P=()=>{},de=!0;const me=()=>{clearTimeout(z),z=setTimeout(()=>void ce().catch(ve=>q(String(ve))),40)},we=vs(me),je=(ve,Fe)=>dn(ve)&&e.activity.isRemote(ve.id)&&(!Fe||!ve.mapId||ve.mapId===Fe),ge=ve=>{var Fe;return(Fe=Oe.current)==null?void 0:Fe.tickets.find(Cn=>Cn.id===ve)},Se=ve=>{const Fe=qx(ve,ge),Cn=ve.kind==="external.changed"&&e.activity.snapshot.sessions.some(ks=>je(ks,ve.mapId)),mr=!("mapId"in ve)||!ve.mapId||ve.mapId===oe.current||ve.kind==="map.created";Fe&&!Cn&&mr&&e.activity.push(Fe),me()};return e.ready.then(()=>{de&&(T=e.adapter.subscribe(Se),P=e.activity.subscribe(N),e.activity.push({source:"system",level:"ok",text:`Online · tracker ${e.adapter.label.toLowerCase()} · ${e.adapter.location}`}),ce().catch(ve=>q(String(ve))))}),()=>{de=!1,T(),P(),we(),clearTimeout(z)}},[e,ce]),y.useEffect(()=>{o&&ce().catch(z=>q(String(z)))},[o,ce]),y.useEffect(()=>{for(const z of j.sessions)z.mode!=="chart"||!z.mapId||!e.activity.isRemote(z.id)||ke.current.has(z.id)||(ke.current.add(z.id),!(z.status!=="running"&&Date.now()-(z.endedAt??0)>6e4)&&(Q.current=z.mapId,ce().catch(T=>q(String(T)))))},[j.sessions,e,ce]);const F=(X=j.pending[0])==null?void 0:X.sessionId;y.useEffect(()=>{if(!F)return;const z=T=>e.activity.snapshot.sessions.some(P=>P.id===T&&dn(P));G(T=>z(T)?T:F)},[F,e]);const J=y.useCallback(async(z,T)=>{e.activity.push({source:"trail lead",agent:St,level:"warn",text:z});try{q(void 0),await T()}catch(P){const de=P.stale===!0,me=de?fN:P.message??String(P);q(me),e.activity.push({source:"trail lead",agent:St,level:"alert",text:`Rejected · ${me}`}),de&&ce().catch(we=>q(String(we)))}},[e,ce]),ie=y.useMemo(()=>d1({rt:e,guard:J,setMapId:Te,mapIdRef:oe,snapRef:Oe,setChatSession:G,setSelection:O}),[J,e,Te]),W=y.useMemo(()=>Object.values(h).flatMap(z=>sj(z,p[z.map.id]??[])).sort((z,T)=>T.decidedAt-z.decidedAt),[h,p]);return{maps:t,allSnaps:h,mapId:o,snap:l,activity:j,health:S,selection:_,setSelection:O,error:D,chatSession:H,decisions:W,leases:$,loaded:v,actions:ie}}function Xt(e=1e3){const[t,s]=y.useState(Date.now());return y.useEffect(()=>{const o=setInterval(()=>s(Date.now()),e);return()=>clearInterval(o)},[e]),t}function pN(){const[e,t]=y.useState(Dd),s=y.useCallback(o=>{t(a=>{const l={...a,...o};return localStorage.setItem(ea,JSON.stringify(l)),l})},[]);return[e,s]}const Yg=()=>{var e,t;return!!((e=ft())!=null&&e.theme)&&!((t=ft())!=null&&t.themeSave)},Jg=e=>{var t;return((t=ft())==null?void 0:t.theme)??e};function gN(e){const t=ft();t!=null&&t.themeSave&&(t.theme=e,ma(e),fetch(t.themeSave,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({theme:e})}).catch(()=>{}))}function vN(){const[e,t]=pN(),[s,o]=y.useReducer(l=>l+1,0);y.useEffect(()=>ma(Jg(e.theme)),[e.theme,s]);const a=y.useCallback(l=>{l.theme&&(gN(l.theme),o()),t(l)},[t]);return[e,a]}function Bd(){return y.useSyncExternalStore(ei.subscribe,ei.get)}function kN({className:e,size:t=18}){return i.jsx("span",{className:e,"aria-hidden":"true",children:i.jsx(Lg,{size:t,variant:Qg()?"night":"crt"})})}function Be({as:e="section",className:t,style:s,frameless:o,children:a,...l}){return i.jsx(e,{className:Ge("panel",o&&"frameless",t),style:s,...l,children:a})}function bn({tone:e,className:t,children:s,title:o}){return i.jsx("span",{className:Ge("pill",e,t),title:o,children:s})}function ln({label:e,value:t,layout:s="stack",urgent:o,title:a,className:l}){return i.jsxs("span",{className:Ge("readout",s!=="stack"&&s,o&&"urgent",l),title:a,children:[i.jsx("span",{className:"mono-label",children:e}),s==="inline"&&" ",i.jsx("b",{children:t})]})}function be(e){const{as:t="div",edge:s="neutral"}=e,o=e.onOpen?"button":"div";return i.jsxs(t,{className:Ge("ds-row",`edge-${s}`,e.selected&&"on",e.className),children:[i.jsxs(o,{className:"ds-row-main",...e.onOpen?{type:"button",onClick:e.onOpen}:{},title:e.titleText,"aria-current":e.current,children:[i.jsxs("span",{className:"ds-row-top",children:[i.jsx("span",{className:"ds-row-title t-row-title",children:e.title}),e.trailing&&i.jsx("span",{className:"ds-row-trail t-meta",children:e.trailing})]}),e.context&&i.jsx("span",{className:"ds-row-context",children:e.context}),e.detail&&i.jsx("span",{className:"ds-row-detail t-meta",title:e.detailText,children:e.detail})]}),e.actions&&i.jsx("span",{className:"ds-row-actions",children:e.actions}),e.below&&i.jsx("div",{className:"ds-row-below",children:e.below})]})}const Gn="#c8581e",yN={map:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M3 6l6-2.5 6 2.5 6-2.5v14.5L15 20.5 9 18l-6 2.5z"}),i.jsx("path",{d:"M9 3.5V18M15 6v14.5"}),i.jsx("path",{d:"M5.5 15c2-1 3-3 5-3.5s3-3 5-4",stroke:Gn,strokeDasharray:"2 2.2"})]}),note:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M5 3.5h14v13.5l-4 3.5H5z"}),i.jsx("path",{d:"M15 21v-4h4"}),i.jsx("path",{d:"M8.5 8h7M8.5 12h7",stroke:Gn})]}),book:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 6.5C10 4.5 7 4 3.5 4.5v14c3.5-.5 6.5 0 8.5 2 2-2 5-2.5 8.5-2v-14C17 4 14 4.5 12 6.5z"}),i.jsx("path",{d:"M12 6.5v14"}),i.jsx("path",{d:"M15 9.5l3-.5M15 13l3-.5",stroke:Gn})]}),flag:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M6 21.5V3"}),i.jsx("path",{d:"M6 4c4-1.5 7 1.5 12 0v9c-5 1.5-8-1.5-12 0z",fill:Gn,stroke:Gn})]}),tent:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 4L2.5 20h19z"}),i.jsx("path",{d:"M12 11l-4 9h8z",fill:Gn,stroke:Gn}),i.jsx("path",{d:"M12 4l-1.5-2M12 4l1.5-2"})]}),mailbox:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 21.500V14"}),i.jsx("path",{d:"M4 14V9.500A4.5 4.5 0 0 1 8.5 5h7A4.5 4.5 0 0 1 20 9.500V14z"}),i.jsx("path",{d:"M8.5 5A4.5 4.5 0 0 1 13 9.500V14"}),i.jsx("path",{d:"M16 10V6.500M16 6.500h3v2.500h-3",stroke:Gn})]})};function Xg({name:e}){return i.jsx("svg",{className:"zone-icon","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:yN[e]})}function Et({title:e,count:t,right:s,hot:o,sub:a,children:l,className:d,info:h,icon:f}){return i.jsxs("header",{className:Ge("sec-h",a&&"sub",d),children:[l,f&&i.jsx(Xg,{name:f}),e!==void 0&&i.jsx(ze,{as:a?"h3":"h2",hot:o,children:e}),h&&i.jsx(ii,{text:h}),t,s!==void 0&&i.jsx("span",{className:"sec-h-right",children:s})]})}function at(e){const{value:t,options:s,onChange:o}=e,[a,l]=y.useState(!1),[d,h]=y.useState(0),[f,p]=y.useState(),k=y.useRef(null),v=y.useRef(null),w=y.useId(),j=s.find($=>$.value===t);y.useLayoutEffect(()=>{if(!a||!k.current)return;const $=k.current.getBoundingClientRect();p({left:$.left,top:$.bottom+4,minWidth:$.width})},[a]),y.useEffect(()=>{if(!a)return;const $=O=>{var D,q;O.target instanceof Node&&((D=v.current)!=null&&D.contains(O.target)||(q=k.current)!=null&&q.contains(O.target))||l(!1)},_=()=>l(!1);return document.addEventListener("mousedown",$),window.addEventListener("resize",_),window.addEventListener("scroll",_,!0),()=>{document.removeEventListener("mousedown",$),window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0)}},[a]),y.useEffect(()=>{var $,_;a&&((_=($=v.current)==null?void 0:$.querySelector(`[data-i="${d}"]`))==null||_.scrollIntoView({block:"nearest"}))},[a,d]);const N=()=>{h(Math.max(0,s.findIndex($=>$.value===t))),l(!0)},S=$=>{var O;const _=s[$];l(!1),(O=k.current)==null||O.focus(),_&&_.value!==t&&o(_.value)},I=$=>{if(!a){["ArrowDown","ArrowUp","Enter"," "].includes($.key)&&($.preventDefault(),N());return}const _=O=>h(D=>(D+O+s.length)%s.length);if($.key==="ArrowDown")_(1);else if($.key==="ArrowUp")_(-1);else if($.key==="Home")h(0);else if($.key==="End")h(s.length-1);else if($.key==="Enter"||$.key===" ")S(d);else{if($.key==="Escape"||$.key==="Tab")return l(!1);if($.key.length===1){const O=s.findIndex(D=>D.label.toLowerCase().startsWith($.key.toLowerCase()));O>=0&&h(O);return}else return}$.preventDefault()};return i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:k,type:"button",className:Ge("select",e.compact&&"compact",a&&"open",e.className),role:"combobox","aria-haspopup":"listbox","aria-expanded":a,"aria-controls":w,"aria-label":e["aria-label"],"aria-activedescendant":a?`${w}-${d}`:void 0,disabled:e.disabled,onClick:()=>a?l(!1):N(),onKeyDown:I,children:[i.jsx("span",{className:"select-value",children:(j==null?void 0:j.label)??"—"}),i.jsx("span",{className:"select-caret","aria-hidden":"true"})]}),a&&f&&i.jsx("ul",{ref:v,id:w,className:"select-menu",role:"listbox",style:f,children:s.map(($,_)=>i.jsxs("li",{id:`${w}-${_}`,"data-i":_,role:"option","aria-selected":$.value===t,className:Ge(_===d&&"active"),onMouseEnter:()=>h(_),onMouseDown:O=>O.preventDefault(),onClick:()=>S(_),children:[i.jsx("span",{className:"select-label",children:$.label}),$.hint&&i.jsx("span",{className:"select-hint",children:$.hint})]},$.value))})]})}function wN(e){return i.jsx("div",{className:`tabs ${e.className??""}`,role:"tablist",children:e.items.map(t=>i.jsxs("button",{role:"tab","aria-selected":e.value===t.id,className:`tab ${e.value===t.id?"on":""}`,onClick:()=>e.onChange(t.id),children:[t.label,t.n!==void 0&&i.jsx("span",{className:"n",children:t.n})]},t.id))})}const xN=350;function jN(){const[e,t]=y.useState(null);if(y.useEffect(()=>{let o=0,a=null;const l=()=>{window.clearTimeout(o),a=null,t(null)},d=k=>{const v=k.getAttribute("data-tip");if(!v)return;const w=k.getBoundingClientRect(),j=w.bottom+60>window.innerHeight;t({text:v,x:w.left+w.width/2,y:j?w.top-8:w.bottom+8,above:j,scout:k.hasAttribute("data-tip-scout")})},h=k=>{var j,N;const v=(N=(j=k.target)==null?void 0:j.closest)==null?void 0:N.call(j,"[data-tip], [title]");if(!v||v instanceof SVGElement&&!v.hasAttribute("data-tip"))return null;const w=v.getAttribute("title");return w&&(v.setAttribute("data-tip",w),v.removeAttribute("title")),v},f=k=>{if(k.pointerType==="touch")return;const v=h(k);v!==a&&(l(),v&&(a=v,o=window.setTimeout(()=>a===v&&d(v),k.type==="focusin"?0:xN)))},p=k=>{a&&!a.contains(k.relatedTarget)&&l()};return document.addEventListener("pointerover",f),document.addEventListener("pointerout",p),document.addEventListener("focusin",f),document.addEventListener("focusout",l),document.addEventListener("pointerdown",l),window.addEventListener("scroll",l,!0),window.addEventListener("keydown",l),()=>{l(),document.removeEventListener("pointerover",f),document.removeEventListener("pointerout",p),document.removeEventListener("focusin",f),document.removeEventListener("focusout",l),document.removeEventListener("pointerdown",l),window.removeEventListener("scroll",l,!0),window.removeEventListener("keydown",l)}},[]),!e)return null;const s=Math.min(Math.max(e.x,140),window.innerWidth-140);if(e.scout){const o=Math.min(Math.max(e.x-24,8),window.innerWidth-340);return i.jsxs("div",{className:`scout-tip ${e.above?"above":""}`,role:"tooltip",style:{left:o,top:e.y,transform:e.above?"translateY(-100%)":void 0},children:[i.jsx(ua,{size:1,framed:!1,speaking:e.text,className:"scout-tip-face"}),i.jsx("p",{className:"scout-tip-bubble",children:e.text})]})}return i.jsx("div",{className:`tooltip ${e.above?"above":""}`,role:"tooltip",style:{left:s,top:e.y,transform:`translate(-50%, ${e.above?"-100%":"0"})`},children:e.text})}function xa({as:e="span",className:t}){return i.jsxs(e,{className:t?`tt-wordmark ${t}`:"tt-wordmark",role:"img","aria-label":Z.name,children:[Z.name.toLowerCase(),i.jsx("span",{className:"tt-wordmark-dot","aria-hidden":"true"})]})}function Zg(e){return e.bare?i.jsx("div",{className:`zone-b ${e.className??""}`,children:e.children}):i.jsxs(Be,{className:`zone ${e.className??""}`,style:e.area?{gridArea:e.area}:void 0,children:[i.jsx(Et,{className:"zone-title",icon:e.icon,title:e.title,info:e.info,count:e.count,right:e.right??null}),i.jsx("div",{className:"zone-b",children:e.children})]})}function Hs(e){return e.children.length?i.jsxs("div",{className:`bf-list ${e.urgent?"urgent":""}`,children:[i.jsx("span",{className:"mono-label",children:e.title}),i.jsx("ul",{children:e.children})]}):null}function Ao(e){return i.jsx("li",{children:i.jsxs("button",{className:"bf-row",onClick:e.onClick,title:e.title,children:[i.jsx("span",{className:"key t-code",children:e.k}),i.jsx("span",{className:"t",children:e.text}),e.meta&&i.jsx("span",{className:"t-meta",children:e.meta})]})})}function Ji(e){return i.jsxs(un,{tone:e.urgent?"urgent":void 0,className:`bf-tile ${e.className??""}`,children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("b",{children:e.value}),e.sub&&i.jsx(V,{parts:[],children:e.sub})]})}const SN=864e5;function NN(e,t){const s=new Date(e),o=s.toTimeString().slice(0,5),a=new Date(t).toDateString(),l=new Date(t-SN).toDateString();let d=` ${s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`;return s.toDateString()===a?d="":s.toDateString()===l&&(d=" yesterday"),`Since ${o}${d} · ${Jt(t-e)}`}function bN(e){const{briefing:t,bp:s,onClose:o}=e;y.useEffect(()=>{const v=w=>w.key==="Escape"&&o();return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[o]);const a=t==null?void 0:t.trails.flatMap(v=>v.waiting).sort((v,w)=>v.at-w.at)[0],l=t==null?void 0:t.totals,d=((t==null?void 0:t.trails.length)??0)>1,h=s==="mobile",f=v=>{var w,j;return v.ticketId&&((j=(w=e.snaps[v.mapId])==null?void 0:w.tickets.find(N=>N.id===v.ticketId))==null?void 0:j.title)||v.text},p=v=>{var w,j;return v.ticketId&&((j=(w=e.snaps[v.mapId])==null?void 0:w.tickets.find(N=>N.id===v.ticketId))==null?void 0:j.key)||v.agent},k=v=>{const w=($,_)=>i.jsx(Ao,{k:$.key,text:$.title,meta:_,onClick:()=>e.onTicket(v.mapId,$.id)},$.id),j=($,_)=>i.jsx(Ao,{k:$.id,text:$.summary||$.answer,title:$.risk?`${$.question}
|
|
134
|
+
`)}const Tc="No area yet";function CS(e){return[`<path d="M24 210Q26 162 72 152H150Q190 158 192 210Z" fill="${e.shell}"/>`,`<path d="M24 210Q26 162 72 152H84Q58 166 58 210Z" fill="${e.shade}"/>`,`<path d="M66 154Q108 160 160 154L156 162Q108 168 70 162Z" fill="${e.side}"/>`,`<path d="M88 152L122 196L156 152Z" fill="${e.orange}"/>`,`<path d="M88 152L122 196L112 152Z" fill="${e.orangeDark}"/>`,`<circle cx="122" cy="161" r="8" fill="${e.orangeDark}"/><circle cx="124" cy="159" r="3" fill="${e.orange}"/>`].join("")}const Ec={x:112,w:15},Ac={x:136,w:10};function Em({x:e,w:t},s,o,a){const l=e+s;return[`<rect x="${l}" y="${94+o}" width="${t}" height="12" rx="${t>12?5:4}" fill="${a.glowLight}"/>`,`<rect x="${l}" y="${100+o}" width="${t}" height="6" rx="3" fill="${a.glow}"/>`,`<rect x="${l+t-6}" y="${96+o}" width="${t>12?3.5:2.5}" height="3.5" rx="1" fill="#fff"/>`].join("")}function Am({x:e,w:t},s){const o=t+3,a=t>12?6:5;return`<rect x="${e-2}" y="90" width="${o}" height="18" rx="${o/2.6}" fill="${s.glowLight}"/><rect x="${e-2+(o-a)/2}" y="96" width="${a}" height="6" rx="2" fill="${s.glass}"/>`}function TS(e,t){if(e==="closed")return[Ec,Ac].map(({x:a,w:l})=>`<rect x="${a}" y="100" width="${l}" height="4" rx="2" fill="${t.glow}"/>`).join("");if(e==="wide")return Am(Ec,t)+Am(Ac,t);const[s,o]=e==="aside"?[4,-5]:[0,0];return Em(Ec,s,o,t)+Em(Ac,s,o,t)}function ES(e,t){return e==="open"?`<rect x="124" y="114" width="16" height="9" rx="4.5" fill="${t.glowLight}"/><rect x="127" y="119" width="10" height="4" rx="2" fill="${t.glow}"/>`:e==="mid"?`<rect x="126" y="115" width="12" height="5" rx="2.5" fill="${t.glowLight}"/>`:e==="aside"?[0,1,2].map(s=>`<circle cx="${124+s*7}" cy="118" r="2.6" fill="${t.glow}"/>`).join(""):`<path d="M125 116q6 5 12 0" fill="none" stroke="${t.glow}" stroke-width="4" stroke-linecap="round"/>`}function AS({eyes:e,mouth:t},s){return TS(e,s)+ES(t,s)}function IS(e){return{shine:'<path d="M92 82h22l-14 20h-8z" fill="#fff" opacity=".08"/>',chin:[`<circle cx="100" cy="142" r="3" fill="${e.orange}"/>`,`<circle cx="109" cy="142" r="3" fill="${e.orangeDark}"/>`,[132,141,150].map(t=>`<rect x="${t}" y="139" width="5" height="7" rx="1.5" fill="${e.shellLight}"/>`).join("")].join(""),pine:`<path d="M125 42l8 11h-4l7 10h-22l7-10h-4z" fill="${e.hat}"/>`}}function RS(e,t,s,o){return[`<path d="M86 34L80 16" stroke="${o.band}" stroke-width="${s?6:4}" stroke-linecap="round"/>`,t?`<circle cx="79" cy="14" r="11" fill="${e}" opacity=".3"/>`:"",`<circle cx="79" cy="14" r="${s?8:6}" fill="${e}"/>`,t?'<circle cx="77" cy="12" r="2" fill="#fff3c4"/>':""].join("")}function MS({face:e,lamp:t,lit:s,simple:o,c:a}){const l=IS(a);return['<rect x="36" y="66" width="118" height="94" rx="22" fill="#000" opacity=".12"/>',`<path d="M50 96Q46 52 96 46" fill="none" stroke="${a.band}" stroke-width="8" stroke-linecap="round"/>`,`<path d="M44 78Q44 62 60 60L74 58V152L60 150Q44 148 44 132Z" fill="${a.side}"/>`,`<rect x="68" y="56" width="98" height="96" rx="20" fill="${a.shell}"/>`,`<rect x="72" y="60" width="8" height="84" rx="4" fill="${a.shellLight}"/>`,`<path d="M68 132H166V140Q166 152 152 152H82Q68 152 68 140Z" fill="${a.shade}"/>`,`<rect x="82" y="72" width="76" height="62" rx="16" fill="${a.frame}"/>`,`<rect x="86" y="76" width="70" height="55" rx="13" fill="${a.glass}"/>`,o?"":l.shine,e,o?"":l.chin,`<ellipse cx="50" cy="108" rx="13" ry="21" fill="${a.orangeDark}"/>`,`<ellipse cx="56" cy="108" rx="12" ry="20" fill="${a.orange}"/>`,`<ellipse cx="53" cy="104" rx="4" ry="11" fill="${a.orangeLight}"/>`,`<path d="M60 122Q64 146 88 148" fill="none" stroke="${a.band}" stroke-width="5" stroke-linecap="round"/>`,`<circle cx="90" cy="148" r="6" fill="${a.band}"/><circle cx="91.5" cy="146.5" r="2" fill="${a.orange}"/>`,RS(t,s,o,a),`<path d="M48 76Q46 30 104 28Q158 30 162 70Z" fill="${a.hat}"/>`,`<path d="M48 76Q46 34 88 29Q66 42 66 74Z" fill="${a.hatDark}"/>`,`<path d="M96 70Q96 40 126 36Q152 40 154 68Z" fill="${a.panel}"/>`,o?"":l.pine,`<path d="M150 82Q120 76 66 84L58 80Q56 72 64 70Q122 62 180 70Q190 76 182 84Z" fill="${a.brim}"/>`,'<path d="M70 84Q120 78 166 84L166 90Q120 84 70 90Z" fill="#000" opacity=".22"/>'].join("")}const LS={ground:"#4f8a48",groundLight:"#5d9a55",shell:"#eee7d3",shellLight:"#faf6ea",shade:"#c9bfa2",side:"#b3a98c",frame:"#a99f83",glass:"#13231e",glow:"#6fd197",glowLight:"#c2f2cf",orange:"#e07a2f",orangeLight:"#f29a55",orangeDark:"#a8481c",hat:"#8a5a38",hatDark:"#6b4630",brim:"#5a3a26",panel:"#ece2c6",band:"#3a4a43"},Rg={on:"#ffb347",dim:"#a8501c",alert:"#ff5a48"},OS={on:"#ffd166",dim:"#a8501c",alert:"#ff5a48"},PS={circle:100,rounded:46,square:0},_S=.94;let DS=0;function zS(e,{lamp:t=Rg,simple:s=!1,shape:o="circle",colors:a=LS}={}){const l=a,d=e.light??"on",h=o==="circle"?_S:1,f=100*(1-h),p=`scout-clip-${++DS}`,v=MS({face:AS(e,l),lamp:t[d],lit:d!=="dim",simple:s,c:l});return[`<defs><clipPath id="${p}"><rect width="200" height="200" rx="${PS[o]}"/></clipPath></defs>`,`<g clip-path="url(#${p})">`,`<rect width="200" height="200" fill="${l.ground}"/>`,`<circle cx="120" cy="88" r="74" fill="${l.groundLight}"/>`,`<g transform="translate(${f} ${f}) scale(${h})">${CS(l)}${v}</g>`,"</g>"].join("")}const Mg={crt:{id:"crt",name:"Day",blurb:"Scout looking to the side: a cap, a headset with a mic, an antenna lamp and a neckerchief.",lamp:Rg,wave:{bar:"#6f8a78",lead:"#c8581e"}},night:{id:"night",name:"Night",blurb:"The same Scout, with the antenna lamp burning brighter, for the night theme.",lamp:OS,wave:{bar:"#66828d",lead:"#e8833a"}}},BS="crt",FS={idle:{eyes:"open",mouth:"rest",light:"on"},speaking:{eyes:"open",mouth:"rest",light:"on"},thinking:{eyes:"aside",mouth:"aside",light:"dim"},alert:{eyes:"wide",mouth:"rest",light:"alert"}},US={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},xn={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function WS(e){return e?/[aeiouy]/i.test(e)?"open":/[a-z0-9]/i.test(e)?"mid":"rest":"rest"}function HS(e,t){return!e||!/[a-z0-9]/i.test(e)?0:/[aeiou]/i.test(e)?2+(e.charCodeAt(0)+t)%2:1+(e.charCodeAt(0)*7+t)%2}function KS(e,t,s){return Array.from({length:s},(o,a)=>{const l=t-(s-1-a);return l>=0&&l<e.length?HS(e[l],l):0})}function Lg({face:e={eyes:"open",mouth:"rest"},variant:t="crt",size:s,simple:o,shape:a="circle",className:l}){const{eyes:d,mouth:h,light:f}=e,p=y.useMemo(()=>zS({eyes:d,mouth:h,light:f},{lamp:Mg[t].lamp,simple:o??s<40,shape:a}),[d,h,f,t,o,s,a]);return i.jsx("svg",{className:l,width:s,height:s,viewBox:"0 0 200 200","aria-hidden":"true",dangerouslySetInnerHTML:{__html:p}})}function VS(e){const[t,s]=y.useState(!1);return y.useEffect(()=>{if(!e){s(!1);return}let o;const a=setInterval(()=>{s(!0),o=setTimeout(()=>s(!1),xn.blinkMs)},xn.blinkEveryMs);return()=>{clearInterval(a),o&&clearTimeout(o)}},[e]),t}const GS={xs:.8,sm:2,md:4,lg:6},qS=40,Im=20,Rm="(prefers-reduced-motion: reduce)",QS=40,YS=350;function JS(e,t){var h;const s=e.size??"md",o=e.state??"idle",a=((h=e.speaking)==null?void 0:h.trim())??"",l=a&&(o==="idle"||o==="speaking")?"speaking":o,d=s==="xs";return{size:s,text:a,effective:l,talking:l==="speaking"&&a.length>0,mini:d,framed:e.framed??!d,reduced:t||d}}const XS=e=>e.length*xn.msPerChar,ZS=(e,t)=>t&&(e.effective==="idle"||e.effective==="speaking"||e.effective==="alert");function e1(e,t,s,o){const a=FS[e.effective],l=s?"closed":a.eyes;let d=a.mouth,h=e.text.length-1;if(o)if(e.reduced)d="open";else{h=Math.min(e.text.length-1,Math.floor(t/xn.msPerChar));const p=Math.floor(t/xn.mouthHoldMs)*Math.round(xn.mouthHoldMs/xn.msPerChar);d=WS(e.text[Math.min(e.text.length-1,p)])}let f=a.light;return e.effective==="thinking"&&!e.reduced&&Math.floor(t/xn.thinkingStepMs)%2===1&&(f="on"),{eyes:l,mouth:d,light:f,cursor:h}}function t1(e,t){const s=typeof e.size=="number"?e.size:GS[e.size],o=e.reduced?Math.min(e.text.length-1,Im-1):t;return{base:s,px:qS*s,bars:Im,waveCursor:o}}function n1(e,{label:t,speechDone:s,cursor:o,caption:a}){const l=e.talking&&s?"idle":e.effective,d=US[l],h=e.size==="md"||e.size==="lg"||typeof e.size=="number"&&e.size>=4;return{shownState:l,status:d,ariaLabel:`${t}, ${d.toLowerCase()}`,showCaption:a??h,shown:s1(e,s,o)}}function s1(e,t,s){return e.talking?e.reduced||t?e.text:e.text.slice(0,s+1):""}function i1(){const[e,t]=y.useState(()=>{var s;return typeof window<"u"&&!!((s=window.matchMedia)!=null&&s.call(window,Rm).matches)});return y.useEffect(()=>{var a;const s=(a=window.matchMedia)==null?void 0:a.call(window,Rm);if(!s)return;const o=()=>t(s.matches);return o(),s.addEventListener("change",o),()=>s.removeEventListener("change",o)},[]),e}function r1(e,t,s){const[o,a]=y.useState(0);return y.useEffect(()=>{if(a(0),!t)return;const l=performance.now(),d=setInterval(()=>a(performance.now()-l),s);return()=>clearInterval(d)},[e,t,s]),o}function o1(e){const{key:t,talking:s,at:o}=e,a=o!==void 0,l=XS(e.text),[d,h]=y.useState(""),f=y.useRef(e.onSpeakEnd);f.current=e.onSpeakEnd,y.useEffect(()=>{if(!s||a)return;const j=setTimeout(()=>{var N;h(t),(N=f.current)==null||N.call(f)},l+YS);return()=>clearTimeout(j)},[s,t,l,a]);const p=s&&d!==t,v=r1(t,e.animate&&(p||e.thinking),p?QS:xn.thinkingStepMs),k=o??v,w=s&&(a?k>=l:d===t);return{t:k,speechDone:w}}const a1=e=>e*2,sd=3.5;function l1(e,t,s){return(e??[]).map((o,a)=>{const l=(1+2*o)*.5;return{x:a*2,y:(sd-l)/2,width:1,height:l,fill:a>=t-2&&o>0?s.lead:s.bar}})}function c1({heights:e,bars:t,unit:s,colors:o}){const a=a1(t);return i.jsx("svg",{className:`scout-wave${e?" on":""}`,width:a*s,height:sd*s,viewBox:`0 0 ${a} ${sd}`,"aria-hidden":"true",children:l1(e,t,o).map((l,d)=>i.jsx("rect",{...l},d))})}function ua({state:e="idle",size:t="md",speaking:s,variant:o=BS,framed:a,caption:l,label:d="Scout",onSpeakEnd:h,at:f,className:p,style:v}){const k=JS({state:e,size:t,speaking:s,framed:a},i1()),{text:w,effective:j,talking:N,reduced:S}=k,I=Mg[o],_=!S&&!(f!==void 0),O=`${j}|${o}|${w}`,{t:D,speechDone:q}=o1({key:O,text:w,talking:N,thinking:j==="thinking",animate:_,at:f,onSpeakEnd:h}),H=VS(ZS(k,_)),G=N&&!q,{eyes:oe,mouth:Q,light:ke,cursor:Oe}=e1(k,D,H,G),{base:Te,px:ne,bars:ce,waveCursor:F}=t1(k,Oe),J=y.useMemo(()=>G?KS(w,F,ce):null,[G,w,F,ce]),{shownState:ie,status:W,ariaLabel:X,showCaption:z,shown:T}=n1(k,{label:d,speechDone:q,cursor:Oe,caption:l}),P={...v,"--scout-u":`${Te}px`},de=i.jsx("span",{className:"scout-sprite",children:i.jsx(Lg,{face:{eyes:oe,mouth:Q,light:ke},variant:o,size:ne,simple:k.mini})});return k.framed?i.jsxs("figure",{className:`scout scout-panel scout-${ie} scout-v-${o} ${p??""}`,style:P,"data-state":ie,children:[i.jsxs("figcaption",{className:"scout-head",children:[i.jsx("span",{className:"scout-name",children:d}),i.jsx("span",{className:"scout-sep",children:"//"}),i.jsx("span",{className:"scout-status",children:W})]}),i.jsxs("div",{className:"scout-feed",role:"img","aria-label":X,children:[de,i.jsx(c1,{heights:J,bars:ce,unit:Te,colors:I.wave})]}),z&&i.jsxs("p",{className:"scout-caption","aria-hidden":"true",children:[T,N&&!q&&!S&&i.jsx("span",{className:"scout-caret",children:"_"})]}),w&&i.jsx("span",{className:"scout-sr","aria-live":"polite",children:w})]}):i.jsx("span",{className:`scout scout-bare scout-${ie} ${p??""}`,style:P,role:"img","aria-label":X,children:de})}const St="trail lead";function d1({rt:e,guard:t,setMapId:s,mapIdRef:o,snapRef:a,setChatSession:l,setSelection:d}){const h={actorKind:"trail lead",journal:e.journal};return{selectMap:f=>s(f),openChat:f=>l(f),answer:(f,p)=>e.activity.answer(f,p,St,{via:"lookout"}),claim:f=>t("Claim",()=>cm(e.adapter,o.current,f,{...h,assignee:St})),release:f=>t("Release claim",()=>Sx(e.adapter,o.current,f,{...h,actor:St})),releaseLease:f=>t("Release to queue",()=>e.leases.release(o.current,f,St)),resolve:(f,p,v={})=>t("Resolve · record answer",async()=>{var w;const k=(w=a.current)==null?void 0:w.tickets.find(j=>j.id===f);k&&!k.assignee&&await cm(e.adapter,o.current,f,{...h,assignee:St}),await Lx(e.adapter,o.current,f,{...h,answer:p,author:St,decision:{...v,source:{kind:"lookout",label:"Ticket inspector"}}})}),supersede:(f,p)=>t(`Supersede ${f.id}`,async()=>{let v=f.id;if(f.derived){const{id:k,mapId:w,derived:j,supersededBy:N,...S}=f;v=(await $d(e.adapter,f.mapId,S,{appendToTrail:!1})).id}await Cx(e.adapter,f.mapId,v,{...p,decidedBy:St,participants:[{id:St}],source:{kind:"lookout",label:"Logbook"}})}),graduate:({unspecified:f,...p})=>t(`Promote to ticket · ${f}`,async()=>{const v=await Px(e.adapter,o.current,f,p);d({kind:"ticket",id:v.id})}),ruleOut:(f,p)=>t("Rule out of scope",async()=>{await _x(e.adapter,o.current,f,{...h,reason:p,author:St,source:{kind:"lookout",label:"Ticket inspector"}}),d(null)}),setArchived:f=>t(f?"Archive trail":"Restore trail",async()=>{await Fx(e.adapter,o.current,f),f&&s(void 0)}),setMode:f=>t(`Trail mode · ${f}`,()=>Tx(e.adapter,o.current,f)),setModelMatching:f=>t(`Model matching · ${f.enabled?"on":"off"}`,()=>Dx(e.adapter,o.current,f))}}const Ge=(...e)=>e.filter(Boolean).join(" "),Ys="item",u1=/^[0-9a-f]{6,64}$/;function ur(){const e=new URLSearchParams(location.search).get("project")??void 0;return e&&u1.test(e)?e:void 0}function pe(e=ur()){return e?`${Z.apiPrefix}/p/${e}`:Z.apiPrefix}function h1(e){const t=new URLSearchParams(location.search);for(const o of["projects","project","tracker",Ys])t.delete(o);e.item&&t.set(Ys,e.item),e.id&&e.id!==e.home&&t.set("project",e.id),e.id&&e.id!==e.home&&e.tracker&&t.set("tracker",e.tracker);const s=t.toString();return`${location.pathname}${s?`?${s}`:""}`}async function f1(){var s,o;const e=await fetch(`${pe()}/verification/config`).then(a=>a.ok?a.json():void 0).catch(()=>{}),t=((s=e==null?void 0:e.approval)==null?void 0:s.state)==="approved"?(o=e.config)==null?void 0:o.default:void 0;return t&&t!=="off"?t:void 0}async function m1(e,t){var d;const s=(t.assumptions??[]).map((h,f)=>({id:`S-${f+1}`,text:h,status:"holding",tickets:[]})),o=await f1(),{map:a,tickets:l}=await hx(e,{title:t.title,...o?{verification:o}:{},sections:{destination:t.destination,notes:t.notes,decisions:[],unspecified:[],outOfScope:[],...s.length?{assumptions:s}:{}},tickets:[{ref:"discovery",...Oj}]});return await fetch(`${pe()}/briefs/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:a.id,ticketId:(d=l[0])==null?void 0:d.id})}),a}function Og(e,t){const s=URL.createObjectURL(new Blob([t],{type:"text/markdown;charset=utf-8"}));Object.assign(document.createElement("a"),{href:s,download:e}).click(),setTimeout(()=>URL.revokeObjectURL(s),1e3)}function hn(e){const t=Math.max(0,Math.floor(e/1e3));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`}function Pg(e){const t=Math.max(0,Math.floor(e/1e3)),s=o=>String(o).padStart(2,"0");return`${s(Math.floor(t/3600))}:${s(Math.floor(t%3600/60))}:${s(t%60)}`}const ha=e=>new Date(e).toTimeString().slice(0,8);function Jt(e){if(e<1e3)return`${Math.round(e)}ms`;const t=Math.round(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${String(t%60).padStart(2,"0")}s`:`${Math.floor(t/3600)}h ${String(Math.floor(t%3600/60)).padStart(2,"0")}m`}function fa(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const Js=e=>`$${e<10?e.toFixed(2):e.toFixed(1)}`,Xs=e=>new Date(e).toISOString().slice(0,10),Id=e=>new Date(e).toTimeString().slice(0,5),p1=e=>`${Xs(e)} ${Id(e)}`,_g=e=>{if(!e)return"";const t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:`${Math.round(t/60)}m ago`},hr=e=>e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",Zs={research:"Research",prototype:"Prototype",junction:"Junction",task:"Task",execute:"Execute",review:"Review"},Dg={decided:"Done",claimed:"Working",frontier:"Ready",blocked:"Backlog",parked:"Parked (plan-only)","out-of-scope":"Cancelled",verifying:"Verifying",rework:"Rework",held:"Blocked"},g1={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function Rd(e,t){return new Map((e??[]).filter(s=>s.mapId===t&&!s.returned).map(s=>[s.ticketId,s]))}function ni(){let e=0,t=0;return{start(){const s=++e;return()=>s<=t?!1:(t=s,!0)},pushed(){t=++e}}}const v1=8,k1=40;function y1(e,t){try{return new URL(e,t).origin===t}catch{return!1}}function zg(e,t){if(!Array.isArray(e))return[];const s=[];for(const o of e.slice(0,v1)){const{label:a,href:l}=o??{};if(typeof a!="string"||typeof l!="string")continue;const d=a.trim();!d||d.length>k1||!y1(l,t)||s.push({label:d,href:l})}return s}function ma(e){e==="auto"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}const w1=["auto","day","night"];function x1(e){const[t]=zg(e?[e]:[],location.origin);return t?{agents:t}:{}}const pa=e=>typeof e=="string"&&/^\/[\w/-]{1,100}$/.test(e)?e:void 0;function j1(e){const t=pa(e);return t?{themeSave:t}:{}}function S1(e){const t=pa(e);return t?{trailAgents:t}:{}}function N1(e){const t=pa(e);return t?{setup:t}:{}}function b1(e){const t=pa(e);return t?{merge:t}:{}}function $1(e){const t=e;if(typeof(t==null?void 0:t.label)!="string"||!t.label.trim()||t.label.length>60||typeof t.href!="string")return{};const s=Nn(t.href);return s?{home:{label:t.label.trim(),href:s}}:{}}let id;const ft=()=>id;function C1(e){const t=e.managed;if(!t||typeof t.name!="string")return;const s=typeof t.signOut=="string"&&new URL(t.signOut,location.href).origin===location.origin,o=zg(t.pages,location.origin),a=w1.find(l=>l===t.theme);return id={name:t.name,pages:o,...s?{signOut:t.signOut}:{},...a?{theme:a}:{},...j1(t.themeSave),...b1(t.merge),...N1(t.setup),...S1(t.trailAgents),...t.highRisk===!1?{highRisk:!1}:{},...$1(t.home),...t.tracker==="markdown"?{tracker:"markdown"}:{},...x1(t.agents)},a&&ma(a),id}const T1=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),rn=(e,t)=>e>>>t|e<<32-t;function E1(e){const t=Math.ceil((e.length+9)/64)*64,s=new Uint8Array(t);s.set(e),s[e.length]=128;const o=new DataView(s.buffer);return o.setUint32(t-8,Math.floor(e.length*8/2**32)),o.setUint32(t-4,e.length*8>>>0),s}function A1(e,t,s,o){for(let w=0;w<16;w++)o[w]=t.getUint32(s+w*4);for(let w=16;w<64;w++){const j=rn(o[w-15],7)^rn(o[w-15],18)^o[w-15]>>>3,N=rn(o[w-2],17)^rn(o[w-2],19)^o[w-2]>>>10;o[w]=o[w-16]+j+o[w-7]+N>>>0}let[a,l,d,h,f,p,v,k]=e;for(let w=0;w<64;w++){const j=k+(rn(f,6)^rn(f,11)^rn(f,25))+(f&p^~f&v)+T1[w]+o[w]>>>0,N=(rn(a,2)^rn(a,13)^rn(a,22))+(a&l^a&d^l&d)>>>0;[k,v,p,f,h,d,l,a]=[v,p,f,h+j>>>0,d,l,a,j+N>>>0]}[a,l,d,h,f,p,v,k].forEach((w,j)=>e[j]=e[j]+w>>>0)}function Ic(e){const t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=E1(e),o=new DataView(s.buffer),a=new Uint32Array(64);for(let h=0;h<s.length;h+=64)A1(t,o,h,a);const l=new Uint8Array(32),d=new DataView(l.buffer);return t.forEach((h,f)=>d.setUint32(f*4,h)),l}function I1(e,t){const s=new Uint8Array(64);s.set(e.length>64?Ic(e):e);const o=new Uint8Array(64+t.length),a=new Uint8Array(96);for(let l=0;l<64;l++)o[l]=s[l]^54,a[l]=s[l]^92;return o.set(t,64),a.set(Ic(o),64),Ic(a)}const Bg=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join(""),R1=e=>new Uint8Array((e.match(/../g)??[]).map(t=>parseInt(t,16))),Md=`${Z.slug}.session`;let Uo;const M1=e=>{const t=e;return!!t&&typeof t.id=="string"&&typeof t.secret=="string"&&typeof t.verifier=="string"};function Ld(){try{const e=JSON.parse(localStorage.getItem(Md)??"null");return M1(e)?e:Uo}catch{return Uo}}function L1(e){Uo=e;try{localStorage.setItem(Md,JSON.stringify(e))}catch{}}function Fg(){Uo=void 0;try{localStorage.removeItem(Md)}catch{}}let Od="unproven",Rc;const rd=new Set,Ug=e=>{Od=e;for(const t of rd)t(e)};function O1(e){return rd.add(e),()=>void rd.delete(e)}const P1=()=>Od==="proven",_1=()=>Od==="proven"&&Ug("unproven");function D1(){const e=new Uint8Array(16);return crypto.getRandomValues(e),Bg(e)}async function z1(){const e=Ld();if(!e)return"unknown";const t=D1(),s=await fetch(`${Z.apiPrefix}/session/prove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id,nonce:t})}).catch(()=>{});if((s==null?void 0:s.status)===404)return Fg(),"unknown";const o=s!=null&&s.ok?(await s.json().catch(()=>({}))).proof:void 0,a=Bg(I1(R1(e.verifier),new TextEncoder().encode(`${t}
|
|
135
|
+
${location.origin}`)));return o===a?"proven":"failed"}function ga(){return Rc??(Rc=z1().then(e=>(Rc=void 0,Ug(e),e))),Rc}const B1=1e4;class Wg{constructor(t=pe(),s="/events"){le(this,"inner");le(this,"listeners",[]);le(this,"closed",!1);le(this,"retryMs",1e3);this.base=t,this.path=s,this.connect()}addEventListener(t,s){var o;this.listeners.push([t,s]),(o=this.inner)==null||o.addEventListener(t,s)}set onmessage(t){this.addEventListener("message",t)}set onerror(t){this.addEventListener("error",t)}close(){var t;this.closed=!0,(t=this.inner)==null||t.close()}async connect(){if(this.closed)return;if(ft())return this.open(`${this.base}${this.path}`);if(await ga()!=="proven")return this.failed();const t=await fetch(`${Z.apiPrefix}/sign-in/stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}).then(s=>s.ok?s.json():void 0).then(s=>s==null?void 0:s.ticket).catch(()=>{});if(!this.closed){if(!t)return this.failed();this.open(`${this.base}${this.path}?ticket=${encodeURIComponent(t)}`)}}open(t){const s=new EventSource(t);this.inner=s;for(const[o,a]of this.listeners)s.addEventListener(o,a);s.addEventListener("open",()=>this.retryMs=1e3),s.addEventListener("error",()=>{s.close(),_1(),this.retry()})}failed(){for(const[t,s]of this.listeners)t==="error"&&s(new Event("error"));this.retry()}retry(){this.closed||(setTimeout(()=>void this.connect(),this.retryMs),this.retryMs=Math.min(this.retryMs*2,B1))}}function F1(){if(ft())return void fetch(`${Z.apiPrefix}/session`,{cache:"no-store"}).then(e=>e.status===401&&location.reload());ga().then(e=>e==="unknown"&&location.reload())}let Dt;const Wo=new Set,or=new Map,Ho=new Set,Ko=new Set;function Hg(e){Dt==null||Dt.addEventListener(e,t=>{for(const s of or.get(e)??[])s(t.data)})}function va(){if(!Dt){Dt=new Wg,Dt.onerror=()=>{for(const e of Ko)e();F1()},Dt.addEventListener("open",()=>{for(const e of Ho)e()}),Dt.onmessage=e=>{const t=JSON.parse(e.data).path;if(typeof t=="string")for(const s of Wo)s(t)};for(const e of or.keys())Hg(e)}}function ka(){const e=[...or.values()].some(t=>t.size>0);Wo.size||e||Ho.size||Ko.size||(Dt==null||Dt.close(),Dt=void 0)}function Pd(e){return Wo.add(e),va(),()=>{Wo.delete(e),ka()}}function si(e,t){let s=or.get(e);return s||(s=new Set,or.set(e,s),Hg(e)),s.add(t),va(),()=>{s.delete(t),ka()}}function vs(e){return Ho.add(e),va(),()=>{Ho.delete(e),ka()}}function U1(e){return Ko.add(e),va(),()=>{Ko.delete(e),ka()}}const _d=(e,t)=>`${e}/${t}`;let Yt={reached:!1,live:!1,tickets:{}},od=!1;const ad=new Set,ld=new Set,W1=ni();let cd=0;const Kg=new Map;let Vg=0;function Vo(e){Yt=e;for(const t of ad)t()}function H1(e,t){const s=Object.fromEntries(e.map(o=>[_d(o.mapId,o.ticketId),o]));for(const[o,a]of Kg)a>t&&Yt.tickets[o]&&(s[o]=Yt.tickets[o]);return s}function Mm(){const e=W1.start(),t=cd;fetch(`${pe()}/verification/sync`).then(s=>s.ok?s.json():Promise.reject()).then(s=>e()&&Vo({reached:!0,live:!0,status:Vg>t?Yt.status:s.status,tickets:H1(s.tickets,t)}),()=>Yt.reached&&Vo({...Yt,live:!1}))}function K1(e){const t=JSON.parse(e);if(t.kind==="evidence")for(const a of ld)a();if(t.kind!=="sync")return;const s=t;Vg=++cd;const o={...Yt.tickets};for(const a of s.tickets){const l=_d(a.mapId,a.ticketId);o[l]=a,Kg.set(l,cd)}Vo({reached:!0,live:!0,status:s.status,tickets:o})}function Lm(){od=!0,si("verification",K1),U1(()=>Yt.reached&&Yt.live&&Vo({...Yt,live:!1})),vs(Mm),Mm()}const ei={subscribe(e){return od||Lm(),ad.add(e),()=>void ad.delete(e)},get:()=>Yt,onEvidence(e){return od||Lm(),ld.add(e),()=>void ld.delete(e)},ticket:(e,t,s)=>e.tickets[_d(t,s)]};function V1(e){if(e!=null&&e.flags.length)return e.flags.some(t=>t.severity==="alert")?"alert":"warn"}const Om={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:R0.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function Dd(){try{const e={...Om,...JSON.parse(localStorage.getItem(ea)??"{}")};return["markdown","github","linear"].includes(e.tracker)||(e.tracker="markdown"),e}catch{return Om}}const Mc=new Map,Lc=e=>`${pe()}/file?path=${encodeURIComponent(e)}`;async function Oc(e,t){const s=await e.json().catch(()=>({})),o=new Error(s.error??`${t}: ${e.status}`);return e.status===409?Object.assign(o,{stale:!0}):e.status===404?Object.assign(o,{code:"ENOENT"}):o}const G1={async list(){return(await(await fetch(`${pe()}/list`)).json()).files},async read(e){const t=await fetch(Lc(e));if(!t.ok)throw await Oc(t,`read ${e}`);const s=await t.text(),o=t.headers.get("ETag");return o&&Mc.set(e,{text:s,etag:o}),s},async write(e,t,s){const o=(s==null?void 0:s.base)===void 0?void 0:Mc.get(e),a=o&&o.text===(s==null?void 0:s.base)?{"If-Match":o.etag}:{},l=await fetch(Lc(e),{method:"PUT",body:t,headers:a});if(!l.ok)throw await Oc(l,`write ${e}`);Mc.delete(e)},async create(e,t){const s=await fetch(Lc(e),{method:"PUT",body:t,headers:{"If-None-Match":"*"}});if(s.status===412)return!1;if(!s.ok)throw await Oc(s,`create ${e}`);return!0},watch(e){return Pd(e)}},q1=15*6e4;class Q1{constructor(t){le(this,"leases",[]);le(this,"changes",new Qs);le(this,"logged",new Set);le(this,"since",Date.now()-q1);this.activity=t}subscribe(t){return this.changes.on(t)}set(t){var s;this.leases=t;for(const o of t){const a=`${o.mapId}/${o.ticketId}/${(s=o.returned)==null?void 0:s.at}`;!o.returned||o.returned.at<this.since||this.logged.has(a)||(this.logged.add(a),this.activity.push({source:"system",level:"warn",ticketId:o.ticketId,text:Yj(o)}))}this.changes.emit(t)}async release(t,s,o){const a=await fetch(`${pe()}/agents/leases/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,ticketId:s,by:o})});if(!a.ok)throw new Error((await a.json().catch(()=>({}))).error??`HTTP ${a.status}`)}}function Y1(e){e.remoteAnswer=(t,s,o)=>{fetch(`${pe()}/agents/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t.sessionId,questionId:t.id,text:s,author:o})}).then(async a=>{if(!a.ok)throw new Error((await a.json().catch(()=>({}))).error??`HTTP ${a.status}`)}).catch(a=>e.push({source:"system",level:"alert",sessionId:t.sessionId,text:`Answer not delivered to ${t.agent} · ${a.message}`}))}}function J1(e){const t=ni(),s=()=>{const o=t.start();fetch(`${pe()}/agents/leases`).then(a=>a.ok?a.json():{leases:[]}).then(({leases:a})=>o()&&e.set(a)).catch(()=>{})};si("leases",o=>{t.pushed(),e.set(JSON.parse(o).leases)}),vs(s),s()}function X1(e){let t=0;const s=new Map,o=()=>{const a=t;fetch(`${pe()}/agents`).then(l=>l.ok?l.json():{sessions:[]}).then(({sessions:l})=>[...l].reverse().filter(d=>(s.get(d.session.id)??0)<=a).forEach(d=>e.syncRemote(d))).catch(()=>{})};si("agent",a=>{const l=JSON.parse(a);s.set(l.session.id,++t),e.syncRemote(l)}),vs(o),o()}function Pm(e,t){Y1(e),J1(t),X1(e)}function _m(e){const t=s=>`${ea}:${e}:${s}`;return{get:s=>localStorage.getItem(t(s)),set:(s,o)=>{try{localStorage.setItem(t(s),o)}catch{}}}}const Z1=["markdown","github","linear"];function eN(){const e=new URLSearchParams(location.search).get("tracker");return e&&Z1.includes(e)?e:Dd().tracker}function tN(e){let t,s;const o=new Gx,a=new Q1(o),l={},d=Ux(pe());if(e==="github"||e==="linear"){const p=new E0(e,pe());p.openEvents=v=>new Wg(pe(),v),t=p,s=fetch(`${pe()}/trackers`).then(v=>v.json()).catch(()=>{}).then(v=>{p.location=(e==="github"?v==null?void 0:v.github.repo:[v==null?void 0:v.linear.teamKey,v==null?void 0:v.linear.projectName].filter(Boolean).join(" · "))||p.location;const k=_m(`${e}:${p.location}`);l.presence=new hm(k),o.ledger=new fm(k),Pm(o,a)})}else t=new C0(G1,`./${Z.dataDir}`),s=fetch(`${pe()}/list`).then(p=>p.json()).catch(()=>({root:"default"})).then(({root:p})=>{const v=_m(p);l.presence=new hm(v),o.ledger=new fm(v),Pm(o,a)});const h=Jx(t),f=h.adapter;return{kind:e,ready:s,get presence(){return l.presence},adapter:f,journal:d,monitor:h,activity:o,leases:a}}const dn=e=>e.status==="running",Gg=e=>dn(e)&&!!e.waitingOn,nN={blocking:0,soon:1,fyi:2};function sN(e,t,s){const o=e.filter(d=>d.sessionId===t),a=o.find(d=>d.id===s);if(a)return a;const l=d=>nN[d.urgency??"soon"];return[...o].sort((d,h)=>l(d)-l(h)||d.at-h.at)[0]}function Go(e,t=Date.now()){const s=Math.floor(Math.max(0,t-e)/6e4);if(s<1)return"just now";if(s<60)return`${s} min ago`;const o=Math.floor(s/60);if(o<24)return`${o} h ago`;const a=Math.floor(o/24);return a<30?a===1?"yesterday":`${a} days ago`:`on ${new Date(e).toISOString().slice(0,10)}`}const iN=/^slack:([A-Z0-9]+)$/i;function ps(e,t){var l;const s=(l=iN.exec(e))==null?void 0:l[1];if(!s)return e;if(t!=null&&t.owners.some(d=>d.id===s))return"you (Slack)";const o=t==null?void 0:t.allow.find(d=>d.id===s),a=(o==null?void 0:o.realName)||(o==null?void 0:o.name);return a?`${a} (Slack)`:"Slack user"}function qg(e,t){const s=ps(e.decidedBy,t);return e.decidedByName?`${e.decidedByName} (${s})`:s}function fs({n:e,urgent:t,pop:s,hideZero:o}){return i.jsx("span",{className:Ge("badge",t&&"urgent",s&&t&&"pop",o&&!e&&"zero"),children:o&&!e?"":e})}function M({variant:e="default",size:t="md",on:s,className:o,type:a,...l}){return i.jsx("button",{type:a??"button",className:Ge("btn",e!=="default"&&e,t==="sm"&&"sm",s&&"on",o),...l})}function un({as:e="div",tone:t,on:s,className:o,children:a,...l}){return i.jsx(e,{className:Ge("card",t,s&&"on",o),...l,children:a})}function ya({what:e,onReviewAgain:t}){return i.jsxs("div",{className:"changed-notice edge-note edge-attention",children:[i.jsxs("p",{className:"t-meta",children:[e," changed since you opened it: read it again before you approve it."]}),i.jsx(M,{size:"sm",onClick:t,children:"Review again"})]})}function ot({on:e,title:t,sub:s,disabled:o,onClick:a}){return i.jsxs(un,{as:"button",type:"button",className:"choice",on:e,disabled:o,onClick:a,children:[i.jsx("b",{className:"choice-title t-row-title",children:t}),s&&i.jsx("span",{className:"c-sub",children:s})]})}function Ie({children:e}){return i.jsx("div",{className:"empty",children:e})}function Sn({title:e,hint:t,art:s}){return i.jsxs("div",{className:s?"empty-state has-art":"empty-state",children:[s,i.jsxs("div",{className:"es-words",children:[i.jsx("span",{className:"es-title",children:e}),t&&i.jsx("span",{className:"es-hint",children:t})]})]})}function Ze({label:e,children:t,className:s}){return i.jsxs("label",{className:Ge("field",s),children:[e,t]})}const wa=y.forwardRef(function({value:t,onValueChange:s,onSubmit:o,action:a="Send",actionDisabled:l,className:d,...h},f){return i.jsxs("form",{className:Ge("input-row",d),onSubmit:p=>{p.preventDefault(),o(t)},children:[i.jsx("textarea",{ref:f,rows:1,value:t,onChange:p=>s(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),o(t))},...h}),i.jsx(M,{type:"submit",variant:"primary",disabled:l??(h.disabled||!t.trim()),children:a})]})});function ii({text:e}){return i.jsx("span",{className:"info-tip","data-tip":e,"data-tip-scout":!0,tabIndex:0,role:"img","aria-label":e,children:i.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[i.jsx("circle",{cx:"7",cy:"3.7",r:"1.3"}),i.jsx("path",{d:"M5.6 6.300H8v4.200h1v1.200H5v-1.200h1.200V7.500h-.6z"})]})})}function ze({as:e="span",variant:t="chip",hot:s,size:o,className:a,children:l,title:d}){return i.jsx(e,{className:Ge(t==="chip"?"chip-label":"mono-label",s&&"hot",o==="sm"&&(t==="chip"?"sm":"xs"),a),title:d,children:l})}const rN=e=>typeof e=="string"?{text:e}:e,oN=e=>Ge(e.code&&"t-code",e.strong&&"strong",e.urgent&&"urgent",e.className);function V(e){const t=e.parts.filter(s=>!!s&&(typeof s=="string"||!!s.text)).map(rN);return!t.length&&!e.children?null:i.jsxs("span",{className:Ge("meta-line t-meta",e.className),children:[t.map((s,o)=>i.jsxs("span",{children:[o>0&&i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:oN(s)||void 0,title:s.tip,children:s.text})]},o)),e.children]})}function zd(e){return i.jsxs("div",{className:"ds-load-failed",role:"alert",children:[i.jsx(V,{parts:[e.what,e.reason]}),i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onRetry,children:"Retry"})]})}function ri(e){const t=Array.from({length:e.rows??0},(s,o)=>o);return i.jsxs("div",{className:Ge("ds-loading",e.className),role:"status","aria-live":"polite",children:[i.jsxs("span",{className:"ds-loading-line t-meta",children:[i.jsx("span",{className:"ds-spinner","aria-hidden":"true"}),e.label]}),t.length>0&&i.jsx("ul",{className:"ds-skeleton-list","aria-hidden":"true",children:t.map(s=>i.jsxs("li",{className:"ds-skeleton-row",children:[i.jsx("span",{className:"ds-skeleton-bar title"}),i.jsx("span",{className:"ds-skeleton-bar meta"})]},s))})]})}const aN="M25.53 10.5 A11 11 0 1 1 16 5",lN="M20 5 L14.6 1.6 L14.6 8.4 Z";function oi({variant:e="mark",state:t="ok",size:s=20,className:o="",title:a}){const l=s<=14?3:2.4;return i.jsxs("svg",{className:`scout-mark mm-${e} mm-${t} ${o}`,viewBox:"0 0 32 32",width:s,height:s,role:a?"img":void 0,"aria-label":a,"aria-hidden":a?void 0:!0,children:[e==="status"||e==="alert"?i.jsx("circle",{cx:"16",cy:"16",r:"11",fill:"none",stroke:"currentColor",strokeWidth:l,strokeDasharray:t==="syncing"?"5 3.6":void 0}):i.jsx("path",{d:aN,fill:"none",stroke:"currentColor",strokeWidth:l,strokeLinecap:"butt"}),(e==="mark"||e==="action")&&i.jsx("path",{d:lN,fill:"currentColor"}),e==="action"&&i.jsx("path",{d:"M13 11 L21.5 16 L13 21 Z",fill:"currentColor"}),(e==="mark"||e==="voice")&&i.jsx("circle",{cx:"16",cy:"16",r:e==="voice"?4:3.4,fill:"currentColor"}),e==="status"&&(t==="idle"?i.jsx("circle",{cx:"16",cy:"16",r:"3.4",fill:"none",stroke:"currentColor",strokeWidth:"1.6"}):i.jsx("circle",{cx:"16",cy:"16",r:"4.2",fill:"currentColor"})),e==="alert"&&i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"14.4",y:"8.5",width:"3.2",height:"9.5",fill:"currentColor"}),i.jsx("rect",{x:"14.4",y:"20.5",width:"3.2",height:"3.2",fill:"currentColor"})]})]})}function dd({parts:e,className:t,as:s="div"}){const o=e.filter(a=>a!=null&&a!==!1&&a!=="");return i.jsx(s,{className:Ge("meta",t),children:o.map((a,l)=>i.jsxs("span",{children:[l>0&&" · ",a]},l))})}const Dm=()=>{const e=document.documentElement.dataset.theme;return e?e==="night":matchMedia("(prefers-color-scheme: dark)").matches};function Qg(){const[e,t]=y.useState(Dm);return y.useEffect(()=>{const s=()=>t(Dm()),o=matchMedia("(prefers-color-scheme: dark)");o.addEventListener("change",s);const a=new MutationObserver(s);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{o.removeEventListener("change",s),a.disconnect()}},[]),e}function cN(){const e=()=>window.innerWidth>=1440?"wide":window.innerWidth>=1024?"laptop":"mobile",[t,s]=y.useState(e);return y.useEffect(()=>{const o=()=>s(e());return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),t}const dN=15e3,zm=["pointerdown","pointermove","keydown","wheel","touchstart"];function uN(e,t,s,o){const[a,l]=y.useState(null),[d,h]=y.useState(!1),[f,p]=y.useState(!1),v=y.useRef(),k=y.useRef(Date.now()),w=y.useRef(!1),j=s.awayMinutes*6e4,N=y.useRef(t);N.current=t;const S=y.useRef(o);S.current=o;const I=y.useCallback((H,G)=>{const oe=N.current;return yj({snaps:Object.values(oe.allSnaps),decisions:oe.decisions,activity:oe.activity,ledger:e.activity.ledger,since:Q=>{var ke;return H[Q]??G??((ke=oe.allSnaps[Q])==null?void 0:ke.map.createdAt)??Date.now()},currentMapId:oe.mapId,attention:S.current})},[e]),$=y.useCallback((H=Date.now())=>{var G;return(G=e.presence)==null?void 0:G.markSeen(N.current.maps.map(oe=>oe.id),H)},[e]),_=y.useCallback(()=>{const H=e.presence;if(!H)return;const G=H.lastSeenAny();if(G!==void 0&&Date.now()-G>=j){const oe=H.snapshot();I(oe,G).changed&&(v.current={seen:oe,any:G},h(!0),s.enabled?l(oe):p(!0))}$()},[e,j,s.enabled,I,$]);y.useEffect(()=>{!t.loaded||w.current||!e.presence||(w.current=!0,_())},[t.loaded,e,_]),y.useEffect(()=>{const H=()=>{const Q=Date.now()-k.current>=j;k.current=Date.now(),Q&&w.current&&document.visibilityState==="visible"&&_()},G=()=>{if(document.visibilityState!=="visible"){w.current&&$(Date.now()-k.current<j?Date.now():k.current);return}k.current=Date.now(),w.current&&_()};for(const Q of zm)window.addEventListener(Q,H,{passive:!0});document.addEventListener("visibilitychange",G);const oe=setInterval(()=>{w.current&&document.visibilityState==="visible"&&$(k.current)},dN);return()=>{for(const Q of zm)window.removeEventListener(Q,H);document.removeEventListener("visibilitychange",G),clearInterval(oe)}},[j,_,$]);const O=y.useMemo(()=>{var H;return a?I(a,(H=v.current)==null?void 0:H.any):void 0},[a,I,t.allSnaps,t.decisions,t.activity,o]),D=y.useMemo(()=>O?Sj(O):"",[O]);y.useEffect(()=>{a&&p(!1)},[a]);let q="none";return f?q="new":d&&(q="seen"),{shown:a!==null,status:q,briefing:O,line:D,open:()=>{const H=v.current;H&&l(H.seen)},dismiss:()=>l(null)}}function hN(e){const[t,s]=y.useState(e.leases.leases);return y.useEffect(()=>e.leases.subscribe(s),[e]),t}const fN="That changed while you were on it, so nothing was written. It is reloaded now: look again, then redo the change.";function mN(e){var X;const[t,s]=y.useState([]),[o,a]=y.useState(),[l,d]=y.useState(),[h,f]=y.useState({}),[p,v]=y.useState({}),[k,w]=y.useState(!1),[j,N]=y.useState(e.activity.snapshot),[S,I]=y.useState(e.monitor.health),$=hN(e);y.useEffect(()=>e.monitor.subscribe(I),[e]);const[_,O]=y.useState(null),[D,q]=y.useState(),[H,G]=y.useState(),oe=y.useRef(),Q=y.useRef(),ke=y.useRef(new Set),Oe=y.useRef();Oe.current=l;const Te=y.useCallback(z=>{oe.current=z,a(z),O(null)},[]),[ne]=y.useState(ni),ce=y.useCallback(async()=>{var je;const z=ne.start(),T=await e.adapter.listMaps();let P=oe.current;const de=Q.current;de&&T.some(ge=>ge.id===de)?(Q.current=void 0,P=de,P!==oe.current&&Te(P)):(!P||!T.some(ge=>ge.id===P))&&(P=(je=Cw(T)[0])==null?void 0:je.id,Te(P));const[me,we]=await Promise.all([Promise.all(T.map(ge=>e.adapter.loadMap(ge.id))),Promise.all(T.map(ge=>e.adapter.listDecisions(ge.id)))]);z()&&(s(T),f(Object.fromEntries(me.map(ge=>[ge.map.id,ge]))),v(Object.fromEntries(T.map((ge,Se)=>[ge.id,we[Se]]))),w(!0),d(me.find(ge=>ge.map.id===P)))},[e,Te,ne]);y.useEffect(()=>{let z,T=()=>{},P=()=>{},de=!0;const me=()=>{clearTimeout(z),z=setTimeout(()=>void ce().catch(ve=>q(String(ve))),40)},we=vs(me),je=(ve,Fe)=>dn(ve)&&e.activity.isRemote(ve.id)&&(!Fe||!ve.mapId||ve.mapId===Fe),ge=ve=>{var Fe;return(Fe=Oe.current)==null?void 0:Fe.tickets.find(Cn=>Cn.id===ve)},Se=ve=>{const Fe=qx(ve,ge),Cn=ve.kind==="external.changed"&&e.activity.snapshot.sessions.some(ks=>je(ks,ve.mapId)),mr=!("mapId"in ve)||!ve.mapId||ve.mapId===oe.current||ve.kind==="map.created";Fe&&!Cn&&mr&&e.activity.push(Fe),me()};return e.ready.then(()=>{de&&(T=e.adapter.subscribe(Se),P=e.activity.subscribe(N),e.activity.push({source:"system",level:"ok",text:`Online · tracker ${e.adapter.label.toLowerCase()} · ${e.adapter.location}`}),ce().catch(ve=>q(String(ve))))}),()=>{de=!1,T(),P(),we(),clearTimeout(z)}},[e,ce]),y.useEffect(()=>{o&&ce().catch(z=>q(String(z)))},[o,ce]),y.useEffect(()=>{for(const z of j.sessions)z.mode!=="chart"||!z.mapId||!e.activity.isRemote(z.id)||ke.current.has(z.id)||(ke.current.add(z.id),!(z.status!=="running"&&Date.now()-(z.endedAt??0)>6e4)&&(Q.current=z.mapId,ce().catch(T=>q(String(T)))))},[j.sessions,e,ce]);const F=(X=j.pending[0])==null?void 0:X.sessionId;y.useEffect(()=>{if(!F)return;const z=T=>e.activity.snapshot.sessions.some(P=>P.id===T&&dn(P));G(T=>z(T)?T:F)},[F,e]);const J=y.useCallback(async(z,T)=>{e.activity.push({source:"trail lead",agent:St,level:"warn",text:z});try{q(void 0),await T()}catch(P){const de=P.stale===!0,me=de?fN:P.message??String(P);q(me),e.activity.push({source:"trail lead",agent:St,level:"alert",text:`Rejected · ${me}`}),de&&ce().catch(we=>q(String(we)))}},[e,ce]),ie=y.useMemo(()=>d1({rt:e,guard:J,setMapId:Te,mapIdRef:oe,snapRef:Oe,setChatSession:G,setSelection:O}),[J,e,Te]),W=y.useMemo(()=>Object.values(h).flatMap(z=>sj(z,p[z.map.id]??[])).sort((z,T)=>T.decidedAt-z.decidedAt),[h,p]);return{maps:t,allSnaps:h,mapId:o,snap:l,activity:j,health:S,selection:_,setSelection:O,error:D,chatSession:H,decisions:W,leases:$,loaded:k,actions:ie}}function Xt(e=1e3){const[t,s]=y.useState(Date.now());return y.useEffect(()=>{const o=setInterval(()=>s(Date.now()),e);return()=>clearInterval(o)},[e]),t}function pN(){const[e,t]=y.useState(Dd),s=y.useCallback(o=>{t(a=>{const l={...a,...o};return localStorage.setItem(ea,JSON.stringify(l)),l})},[]);return[e,s]}const Yg=()=>{var e,t;return!!((e=ft())!=null&&e.theme)&&!((t=ft())!=null&&t.themeSave)},Jg=e=>{var t;return((t=ft())==null?void 0:t.theme)??e};function gN(e){const t=ft();t!=null&&t.themeSave&&(t.theme=e,ma(e),fetch(t.themeSave,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({theme:e})}).catch(()=>{}))}function vN(){const[e,t]=pN(),[s,o]=y.useReducer(l=>l+1,0);y.useEffect(()=>ma(Jg(e.theme)),[e.theme,s]);const a=y.useCallback(l=>{l.theme&&(gN(l.theme),o()),t(l)},[t]);return[e,a]}function Bd(){return y.useSyncExternalStore(ei.subscribe,ei.get)}function kN({className:e,size:t=18}){return i.jsx("span",{className:e,"aria-hidden":"true",children:i.jsx(Lg,{size:t,variant:Qg()?"night":"crt"})})}function Be({as:e="section",className:t,style:s,frameless:o,children:a,...l}){return i.jsx(e,{className:Ge("panel",o&&"frameless",t),style:s,...l,children:a})}function bn({tone:e,className:t,children:s,title:o}){return i.jsx("span",{className:Ge("pill",e,t),title:o,children:s})}function ln({label:e,value:t,layout:s="stack",urgent:o,title:a,className:l}){return i.jsxs("span",{className:Ge("readout",s!=="stack"&&s,o&&"urgent",l),title:a,children:[i.jsx("span",{className:"mono-label",children:e}),s==="inline"&&" ",i.jsx("b",{children:t})]})}function be(e){const{as:t="div",edge:s="neutral"}=e,o=e.onOpen?"button":"div";return i.jsxs(t,{className:Ge("ds-row",`edge-${s}`,e.selected&&"on",e.className),children:[i.jsxs(o,{className:"ds-row-main",...e.onOpen?{type:"button",onClick:e.onOpen}:{},title:e.titleText,"aria-current":e.current,children:[i.jsxs("span",{className:"ds-row-top",children:[i.jsx("span",{className:"ds-row-title t-row-title",children:e.title}),e.trailing&&i.jsx("span",{className:"ds-row-trail t-meta",children:e.trailing})]}),e.context&&i.jsx("span",{className:"ds-row-context",children:e.context}),e.detail&&i.jsx("span",{className:"ds-row-detail t-meta",title:e.detailText,children:e.detail})]}),e.actions&&i.jsx("span",{className:"ds-row-actions",children:e.actions}),e.below&&i.jsx("div",{className:"ds-row-below",children:e.below})]})}const Gn="#c8581e",yN={map:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M3 6l6-2.5 6 2.5 6-2.5v14.5L15 20.5 9 18l-6 2.5z"}),i.jsx("path",{d:"M9 3.5V18M15 6v14.5"}),i.jsx("path",{d:"M5.5 15c2-1 3-3 5-3.5s3-3 5-4",stroke:Gn,strokeDasharray:"2 2.2"})]}),note:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M5 3.5h14v13.5l-4 3.5H5z"}),i.jsx("path",{d:"M15 21v-4h4"}),i.jsx("path",{d:"M8.5 8h7M8.5 12h7",stroke:Gn})]}),book:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 6.5C10 4.5 7 4 3.5 4.5v14c3.5-.5 6.5 0 8.5 2 2-2 5-2.5 8.5-2v-14C17 4 14 4.5 12 6.5z"}),i.jsx("path",{d:"M12 6.5v14"}),i.jsx("path",{d:"M15 9.5l3-.5M15 13l3-.5",stroke:Gn})]}),flag:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M6 21.5V3"}),i.jsx("path",{d:"M6 4c4-1.5 7 1.5 12 0v9c-5 1.5-8-1.5-12 0z",fill:Gn,stroke:Gn})]}),tent:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 4L2.5 20h19z"}),i.jsx("path",{d:"M12 11l-4 9h8z",fill:Gn,stroke:Gn}),i.jsx("path",{d:"M12 4l-1.5-2M12 4l1.5-2"})]}),mailbox:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 21.500V14"}),i.jsx("path",{d:"M4 14V9.500A4.5 4.5 0 0 1 8.5 5h7A4.5 4.5 0 0 1 20 9.500V14z"}),i.jsx("path",{d:"M8.5 5A4.5 4.5 0 0 1 13 9.500V14"}),i.jsx("path",{d:"M16 10V6.500M16 6.500h3v2.500h-3",stroke:Gn})]})};function Xg({name:e}){return i.jsx("svg",{className:"zone-icon","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:yN[e]})}function Et({title:e,count:t,right:s,hot:o,sub:a,children:l,className:d,info:h,icon:f}){return i.jsxs("header",{className:Ge("sec-h",a&&"sub",d),children:[l,f&&i.jsx(Xg,{name:f}),e!==void 0&&i.jsx(ze,{as:a?"h3":"h2",hot:o,children:e}),h&&i.jsx(ii,{text:h}),t,s!==void 0&&i.jsx("span",{className:"sec-h-right",children:s})]})}function at(e){const{value:t,options:s,onChange:o}=e,[a,l]=y.useState(!1),[d,h]=y.useState(0),[f,p]=y.useState(),v=y.useRef(null),k=y.useRef(null),w=y.useId(),j=s.find($=>$.value===t);y.useLayoutEffect(()=>{if(!a||!v.current)return;const $=v.current.getBoundingClientRect();p({left:$.left,top:$.bottom+4,minWidth:$.width})},[a]),y.useEffect(()=>{if(!a)return;const $=O=>{var D,q;O.target instanceof Node&&((D=k.current)!=null&&D.contains(O.target)||(q=v.current)!=null&&q.contains(O.target))||l(!1)},_=()=>l(!1);return document.addEventListener("mousedown",$),window.addEventListener("resize",_),window.addEventListener("scroll",_,!0),()=>{document.removeEventListener("mousedown",$),window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0)}},[a]),y.useEffect(()=>{var $,_;a&&((_=($=k.current)==null?void 0:$.querySelector(`[data-i="${d}"]`))==null||_.scrollIntoView({block:"nearest"}))},[a,d]);const N=()=>{h(Math.max(0,s.findIndex($=>$.value===t))),l(!0)},S=$=>{var O;const _=s[$];l(!1),(O=v.current)==null||O.focus(),_&&_.value!==t&&o(_.value)},I=$=>{if(!a){["ArrowDown","ArrowUp","Enter"," "].includes($.key)&&($.preventDefault(),N());return}const _=O=>h(D=>(D+O+s.length)%s.length);if($.key==="ArrowDown")_(1);else if($.key==="ArrowUp")_(-1);else if($.key==="Home")h(0);else if($.key==="End")h(s.length-1);else if($.key==="Enter"||$.key===" ")S(d);else{if($.key==="Escape"||$.key==="Tab")return l(!1);if($.key.length===1){const O=s.findIndex(D=>D.label.toLowerCase().startsWith($.key.toLowerCase()));O>=0&&h(O);return}else return}$.preventDefault()};return i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:v,type:"button",className:Ge("select",e.compact&&"compact",a&&"open",e.className),role:"combobox","aria-haspopup":"listbox","aria-expanded":a,"aria-controls":w,"aria-label":e["aria-label"],"aria-activedescendant":a?`${w}-${d}`:void 0,disabled:e.disabled,onClick:()=>a?l(!1):N(),onKeyDown:I,children:[i.jsx("span",{className:"select-value",children:(j==null?void 0:j.label)??"—"}),i.jsx("span",{className:"select-caret","aria-hidden":"true"})]}),a&&f&&i.jsx("ul",{ref:k,id:w,className:"select-menu",role:"listbox",style:f,children:s.map(($,_)=>i.jsxs("li",{id:`${w}-${_}`,"data-i":_,role:"option","aria-selected":$.value===t,className:Ge(_===d&&"active"),onMouseEnter:()=>h(_),onMouseDown:O=>O.preventDefault(),onClick:()=>S(_),children:[i.jsx("span",{className:"select-label",children:$.label}),$.hint&&i.jsx("span",{className:"select-hint",children:$.hint})]},$.value))})]})}function wN(e){return i.jsx("div",{className:`tabs ${e.className??""}`,role:"tablist",children:e.items.map(t=>i.jsxs("button",{role:"tab","aria-selected":e.value===t.id,className:`tab ${e.value===t.id?"on":""}`,onClick:()=>e.onChange(t.id),children:[t.label,t.n!==void 0&&i.jsx("span",{className:"n",children:t.n})]},t.id))})}const xN=350;function jN(){const[e,t]=y.useState(null);if(y.useEffect(()=>{let o=0,a=null;const l=()=>{window.clearTimeout(o),a=null,t(null)},d=v=>{const k=v.getAttribute("data-tip");if(!k)return;const w=v.getBoundingClientRect(),j=w.bottom+60>window.innerHeight;t({text:k,x:w.left+w.width/2,y:j?w.top-8:w.bottom+8,above:j,scout:v.hasAttribute("data-tip-scout")})},h=v=>{var j,N;const k=(N=(j=v.target)==null?void 0:j.closest)==null?void 0:N.call(j,"[data-tip], [title]");if(!k||k instanceof SVGElement&&!k.hasAttribute("data-tip"))return null;const w=k.getAttribute("title");return w&&(k.setAttribute("data-tip",w),k.removeAttribute("title")),k},f=v=>{if(v.pointerType==="touch")return;const k=h(v);k!==a&&(l(),k&&(a=k,o=window.setTimeout(()=>a===k&&d(k),v.type==="focusin"?0:xN)))},p=v=>{a&&!a.contains(v.relatedTarget)&&l()};return document.addEventListener("pointerover",f),document.addEventListener("pointerout",p),document.addEventListener("focusin",f),document.addEventListener("focusout",l),document.addEventListener("pointerdown",l),window.addEventListener("scroll",l,!0),window.addEventListener("keydown",l),()=>{l(),document.removeEventListener("pointerover",f),document.removeEventListener("pointerout",p),document.removeEventListener("focusin",f),document.removeEventListener("focusout",l),document.removeEventListener("pointerdown",l),window.removeEventListener("scroll",l,!0),window.removeEventListener("keydown",l)}},[]),!e)return null;const s=Math.min(Math.max(e.x,140),window.innerWidth-140);if(e.scout){const o=Math.min(Math.max(e.x-24,8),window.innerWidth-340);return i.jsxs("div",{className:`scout-tip ${e.above?"above":""}`,role:"tooltip",style:{left:o,top:e.y,transform:e.above?"translateY(-100%)":void 0},children:[i.jsx(ua,{size:1,framed:!1,speaking:e.text,className:"scout-tip-face"}),i.jsx("p",{className:"scout-tip-bubble",children:e.text})]})}return i.jsx("div",{className:`tooltip ${e.above?"above":""}`,role:"tooltip",style:{left:s,top:e.y,transform:`translate(-50%, ${e.above?"-100%":"0"})`},children:e.text})}function xa({as:e="span",className:t}){return i.jsxs(e,{className:t?`tt-wordmark ${t}`:"tt-wordmark",role:"img","aria-label":Z.name,children:[Z.name.toLowerCase(),i.jsx("span",{className:"tt-wordmark-dot","aria-hidden":"true"})]})}function Zg(e){return e.bare?i.jsx("div",{className:`zone-b ${e.className??""}`,children:e.children}):i.jsxs(Be,{className:`zone ${e.className??""}`,style:e.area?{gridArea:e.area}:void 0,children:[i.jsx(Et,{className:"zone-title",icon:e.icon,title:e.title,info:e.info,count:e.count,right:e.right??null}),i.jsx("div",{className:"zone-b",children:e.children})]})}function Hs(e){return e.children.length?i.jsxs("div",{className:`bf-list ${e.urgent?"urgent":""}`,children:[i.jsx("span",{className:"mono-label",children:e.title}),i.jsx("ul",{children:e.children})]}):null}function Ao(e){return i.jsx("li",{children:i.jsxs("button",{className:"bf-row",onClick:e.onClick,title:e.title,children:[i.jsx("span",{className:"key t-code",children:e.k}),i.jsx("span",{className:"t",children:e.text}),e.meta&&i.jsx("span",{className:"t-meta",children:e.meta})]})})}function Ji(e){return i.jsxs(un,{tone:e.urgent?"urgent":void 0,className:`bf-tile ${e.className??""}`,children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("b",{children:e.value}),e.sub&&i.jsx(V,{parts:[],children:e.sub})]})}const SN=864e5;function NN(e,t){const s=new Date(e),o=s.toTimeString().slice(0,5),a=new Date(t).toDateString(),l=new Date(t-SN).toDateString();let d=` ${s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`;return s.toDateString()===a?d="":s.toDateString()===l&&(d=" yesterday"),`Since ${o}${d} · ${Jt(t-e)}`}function bN(e){const{briefing:t,bp:s,onClose:o}=e;y.useEffect(()=>{const k=w=>w.key==="Escape"&&o();return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[o]);const a=t==null?void 0:t.trails.flatMap(k=>k.waiting).sort((k,w)=>k.at-w.at)[0],l=t==null?void 0:t.totals,d=((t==null?void 0:t.trails.length)??0)>1,h=s==="mobile",f=k=>{var w,j;return k.ticketId&&((j=(w=e.snaps[k.mapId])==null?void 0:w.tickets.find(N=>N.id===k.ticketId))==null?void 0:j.title)||k.text},p=k=>{var w,j;return k.ticketId&&((j=(w=e.snaps[k.mapId])==null?void 0:w.tickets.find(N=>N.id===k.ticketId))==null?void 0:j.key)||k.agent},v=k=>{const w=($,_)=>i.jsx(Ao,{k:$.key,text:$.title,meta:_,onClick:()=>e.onTicket(k.mapId,$.id)},$.id),j=($,_)=>i.jsx(Ao,{k:$.id,text:$.summary||$.answer,title:$.risk?`${$.question}
|
|
136
136
|
|
|
137
|
-
${$.risk.reason}`:$.question,meta:_,onClick:()=>e.onDecision($.id)},$.id),N=qj(
|
|
138
|
-
${o.headRef}`:void 0,children:[o?i.jsxs("a",{href:Nn(o.url),target:"_blank",rel:"noreferrer noopener",children:["PR #",o.number," · ",o.state,o.draft?" · draft":""]}):`PR #${s.link.number}`,i.jsx("span",{className:`ci ci-${s.checksSummary}`,children:TN[s.checksSummary]}),i.jsx("span",{className:"when",children:AN(s)})]}),s.flags.map(a=>i.jsx(bn,{className:`flag flag-${a.severity}`,title:a.text,children:a.kind},a.kind))]})}function AN(e){return e.error?"sync failed":e.syncedAt?_g(e.syncedAt):"not synced yet"}const IN={ok:"ok",failed:"error",stale:"syncing",unknown:"idle",off:"idle"};function RN({now:e}){const t=Bd();if(!t.reached)return null;const s=Hx(t.live?t.status:null,e);return i.jsxs("span",{className:`tracker-chip pr-sync tone-${s.tone}`,title:s.title,children:[i.jsx(ze,{size:"sm",children:"CI"}),i.jsx(oi,{variant:"status",state:IN[s.tone],size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:s.label})]})}function Fd(e){const t=e.role??"menu",[s,o]=y.useState(!1),a=y.useRef(null);return y.useEffect(()=>{if(!s)return;const l=d=>{var f;(d instanceof KeyboardEvent?d.key==="Escape":!((f=a.current)!=null&&f.contains(d.target)))&&o(!1)};return window.addEventListener("mousedown",l),window.addEventListener("keydown",l),()=>{window.removeEventListener("mousedown",l),window.removeEventListener("keydown",l)}},[s]),i.jsxs("div",{className:Ge("header-menu",e.className),ref:a,children:[i.jsxs(M,{variant:"ghost","aria-haspopup":t,"aria-label":e.ariaLabel,"aria-expanded":s,on:s,"data-tip":s?void 0:e.tip,onClick:()=>o(!s),children:[e.label," ",e.badge," ",i.jsx("span",{className:"caret",children:"▾"})]}),s&&i.jsx("div",{className:"header-menu-list",role:t,children:e.children(()=>o(!1))})]})}function MN(){const e=ft();if(!e)return null;const t=(s,o)=>{o(),location.assign(s)};return i.jsx(Fd,{label:e.name,tip:"Your account on the server this Lookout runs on",children:s=>i.jsxs(i.Fragment,{children:[e.home&&i.jsxs("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(e.home.href,s),children:["← ",e.home.label]}),e.pages.map(o=>i.jsx("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(o.href,s),children:o.label},o.href)),e.signOut&&i.jsx("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(e.signOut,s),children:"Sign out"})]})})}const LN={new:"While you were away: a new trip report from Scout",seen:"Reopen the last trip report",none:"No trip report yet. Scout writes one when you come back after being away."};function ON(e){const t=e.briefingStatus==="new";return i.jsx(Fd,{label:"Records",badge:i.jsxs(i.Fragment,{children:[e.knowledge>0&&i.jsx("span",{className:"n hot",children:e.knowledge}),t&&i.jsx("span",{className:"new-dot","aria-label":"new trip report"})]}),children:s=>i.jsxs(i.Fragment,{children:[i.jsxs("button",{role:"menuitem",className:"header-menu-item",disabled:e.briefingStatus==="none"&&!e.briefingOpen,title:LN[e.briefingStatus],onClick:()=>{s(),e.onBriefing()},children:[i.jsx("span",{children:"Trip report"}),t&&i.jsx("span",{className:"new-dot","aria-label":"new"})]}),i.jsxs("button",{role:"menuitem",className:"header-menu-item knowledge-btn",title:"What agents know about this codebase and product. Review suggestions, flags and stale entries",onClick:()=>{s(),e.onKnowledge()},children:[i.jsx("span",{children:"Field guide"}),e.knowledge>0&&i.jsx("span",{className:"n hot",children:e.knowledge})]}),i.jsxs("button",{role:"menuitem",className:"header-menu-item decisions-btn",title:"Every decision across your trails, with its reasoning. Search, filter and export",onClick:()=>{s(),e.onDecisions()},children:[i.jsx("span",{children:"Logbook"}),i.jsx("span",{className:"n",children:e.decisions})]}),i.jsx("button",{role:"menuitem",className:"header-menu-item stats-btn",title:"How your agents deliver across trails, by vendor, agent and ticket type.",onClick:()=>{s(),e.onStats()},children:i.jsx("span",{children:"Trail stats"})})]})})}const zt=()=>{var e;return(e=ft())==null?void 0:e.agents},ev=()=>{const e=zt();e&&location.assign(e.href)},tv=e=>{const t=e;if(!(typeof(t==null?void 0:t.on)!="boolean"||!Array.isArray(t.repos)))return{canRun:t.canRun===!0,repos:t.repos.filter(s=>typeof s=="string").slice(0,200),on:t.on,...typeof t.repo=="string"?{repo:t.repo}:{},running:Number.isInteger(t.running)?t.running:0,...typeof t.note=="string"?{note:t.note.slice(0,200)}:{}}},ja=()=>{var e;return(e=ft())==null?void 0:e.trailAgents};async function PN(e){const t=ja();if(!t)return;const s=await fetch(`${t}?trail=${encodeURIComponent(e)}`).catch(()=>{});return s!=null&&s.ok?tv(await s.json().catch(()=>{})):void 0}async function _N(e,t){const s=ja();if(!s)return{error:"This Lookout doesn't run agents."};const o=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trail:e,...t})}).catch(()=>{}),a=await(o==null?void 0:o.json().catch(()=>{}));return(o!=null&&o.ok?tv(a):void 0)??{error:typeof(a==null?void 0:a.error)=="string"?a.error.slice(0,200):"The server didn't answer."}}function DN(e){return e.running?`Agents on · ${e.running} working`:e.note?`Agents on · ${e.note}`:"Agents on · starting soon"}function nv({mapId:e}){const[
|
|
139
|
-
`);return i.jsxs("span",{className:`tracker-chip sync-${t.status}`,title:o,children:[i.jsx(ze,{size:"sm",children:"Tracker"}),i.jsx(oi,{variant:"status",state:t.status,size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:e})]})}const Bm={"start-over":{text:e=>`Archive ${e.key} and start a new trail from its idea? The old map stays as history; its tickets and decisions don't carry over.`,confirm:"Start over"},archive:{text:e=>`Archive ${e.key}? It stays as history, read-only, and no agent takes work from it.`,confirm:"Archive"}};function KN(e){const{map:t}=e,[s,o]=y.useState();return t.archived?i.jsxs("button",{role:"menuitem",className:"trail-item act","data-tip":"Make it an active trail again: agents can take work from it",onClick:()=>(e.onArchive(!1),e.onDone()),children:["Restore ",t.key]}):s?i.jsxs("div",{className:"trail-confirm",role:"group",children:[i.jsx("p",{className:"t-meta",children:Bm[s].text(t)}),i.jsxs("div",{className:"actions",children:[i.jsx(M,{variant:"primary",onClick:()=>{s==="start-over"?e.onStartOver():e.onArchive(!0),e.onDone()},children:Bm[s].confirm}),i.jsx(M,{onClick:()=>o(void 0),children:"Cancel"})]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("button",{role:"menuitem",className:"trail-item act","data-tip":"The map went wrong? Archive it and describe the idea again",onClick:()=>o("start-over"),children:["Start ",t.key," over…"]}),i.jsxs("button",{role:"menuitem",className:"trail-item act","data-tip":"Put the trail away as history",onClick:()=>o("archive"),children:["Archive ",t.key,"…"]})]})}function VN(e){const{map:t}=e.snap,s=ig(e.snap);return i.jsxs("button",{role:"menuitem",className:`trail-item ${e.on?"on":""} ${t.archived?"archived":""}`,onClick:e.onSelect,children:[i.jsx("span",{className:"key",children:t.key}),i.jsx("span",{className:"mi-title",children:t.title}),i.jsxs("span",{className:"mi-progress",children:[s.decided,"/",s.total]}),i.jsx(fs,{n:e.waiting,urgent:!!e.waiting,hideZero:!0})]})}function GN(e){var
|
|
137
|
+
${$.risk.reason}`:$.question,meta:_,onClick:()=>e.onDecision($.id)},$.id),N=qj(k.agentDecisions).flatMap($=>$.decisions.map(_=>j(_,$.label))),S=[i.jsx(Hs,{title:"Done",children:k.done.map($=>w($))},"done"),i.jsx(Hs,{title:"Ruled out",children:h?[]:k.ruledOut.map($=>w($))},"oos"),i.jsx(Hs,{title:"Blocked",children:k.blocked.map($=>w($.ticket,`needs ${$.on.map(_=>_.key).join(", ")}`))},"blocked")],I=[i.jsx(Hs,{title:"Waiting on you",urgent:!0,children:k.waiting.map($=>i.jsx(Ao,{k:p($),text:f($),meta:t.now-$.at<6e4?"now":Jt(t.now-$.at),title:$.text,onClick:()=>e.onAnswer($)},$.id))},"waiting"),i.jsx(Hs,{title:"Agent decisions",children:h?[]:N},"agent"),i.jsx(Hs,{title:"Active sessions",children:h?[]:k.active.map($=>{var O;const _=$.ticketId?(O=e.snaps[k.mapId])==null?void 0:O.tickets.find(D=>D.id===$.ticketId):void 0;return i.jsx(Ao,{k:(_==null?void 0:_.key)??$.agent,text:_?`${_.title} · ${$.stepLabel}`:$.stepLabel,meta:`${$.step}/${$.total}`,onClick:()=>e.onSession($)},$.id)})},"active")];return i.jsxs("section",{className:"bf-trail",children:[d&&i.jsxs("div",{className:"bf-trail-h",children:[i.jsx("span",{className:"key",children:k.key})," ",k.title]}),i.jsxs("div",{className:"bf-cols",children:[i.jsx("div",{children:S}),i.jsx("div",{children:I})]})]},k.mapId)};return i.jsx("div",{className:"scrim",onClick:o,children:i.jsxs(Be,{as:"div",className:"dialog briefing",role:"dialog","aria-label":"While you were away",onClick:k=>k.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"While you were away"}),t&&t.trails.length>0&&i.jsx(ze,{className:"bf-since",children:NN(t.since,t.now)}),i.jsx("button",{className:"icon-btn",onClick:o,"aria-label":"Close",children:"×"})]}),i.jsxs(un,{className:"bf-scout",children:[i.jsx(ua,{size:h?1.1:1.3,speaking:e.line||"Nothing new since you were last here.",caption:!1,framed:!1}),i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Scout"}),i.jsx("p",{children:e.line||"Nothing new since you were last here."})]})]}),t&&l&&t.trails.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"bf-tiles",children:[i.jsx(Ji,{label:"Done",value:l.done,sub:l.ruledOut?`${l.ruledOut} ruled out`:void 0}),i.jsx(Ji,{label:"Blocked",value:l.blocked,sub:l.blocked?"Needs your answer":void 0}),i.jsx(Ji,{label:"Waiting on you",value:l.waiting,sub:$N(l.oldestWaitMs),urgent:l.waiting>0}),i.jsx(Ji,{label:"Agent decisions",value:l.agentDecisions,className:"opt"}),i.jsx(Ji,{label:"Spend",value:Js(l.usage.costUsd),sub:`${fa(l.usage.inputTokens+l.usage.outputTokens)} tokens · ${l.usage.sessions} sessions${l.active?` · ${l.active} active`:""}`})]}),i.jsx("div",{className:"bf-body",children:t.trails.map(v)})]}),i.jsxs("footer",{children:[i.jsx(M,{onClick:o,children:"Dismiss"}),a?i.jsxs(M,{variant:"urgent",onClick:()=>e.onAnswer(a),children:[i.jsx(oi,{variant:"alert",size:13}),"Answer first decision"]}):i.jsx(M,{variant:"primary",onClick:e.onResume,children:"Resume trail"})]})]})})}function $N(e){if(e!==void 0)return e<6e4?"Just asked":`Oldest ${Jt(e)}`}function CN(e){const{brief:t,bp:s}=e;return i.jsx(bN,{briefing:t.briefing,line:t.line,snaps:e.snaps,bp:s,onClose:t.dismiss,onTicket:(o,a)=>{t.dismiss(),e.openTicket(o,a)},onAnswer:o=>{t.dismiss(),e.closeDecisions(),e.openChat(o.sessionId,o.ticketId,o.mapId)},onSession:o=>{t.dismiss(),e.closeDecisions(),e.openChat(o.id,o.ticketId,o.mapId)},onDecision:o=>{t.dismiss(),e.openDecisions(o)},onResume:()=>{t.dismiss(),e.closeDecisions(),s==="mobile"&&e.showPhoneHome()}})}const TN={passed:"checks passed",failing:"checks failing",pending:"checks pending",unknown:"checks unknown",none:"no checks"};function EN({mapId:e,ticketId:t}){const s=ei.ticket(Bd(),e,t);if(!s)return null;const o=s.pr;return i.jsxs("div",{className:"pr-flags",children:[i.jsxs("span",{className:`pr-chip pr-${(o==null?void 0:o.state)??"unread"}`,title:o?`${o.title}
|
|
138
|
+
${o.headRef}`:void 0,children:[o?i.jsxs("a",{href:Nn(o.url),target:"_blank",rel:"noreferrer noopener",children:["PR #",o.number," · ",o.state,o.draft?" · draft":""]}):`PR #${s.link.number}`,i.jsx("span",{className:`ci ci-${s.checksSummary}`,children:TN[s.checksSummary]}),i.jsx("span",{className:"when",children:AN(s)})]}),s.flags.map(a=>i.jsx(bn,{className:`flag flag-${a.severity}`,title:a.text,children:a.kind},a.kind))]})}function AN(e){return e.error?"sync failed":e.syncedAt?_g(e.syncedAt):"not synced yet"}const IN={ok:"ok",failed:"error",stale:"syncing",unknown:"idle",off:"idle"};function RN({now:e}){const t=Bd();if(!t.reached)return null;const s=Hx(t.live?t.status:null,e);return i.jsxs("span",{className:`tracker-chip pr-sync tone-${s.tone}`,title:s.title,children:[i.jsx(ze,{size:"sm",children:"CI"}),i.jsx(oi,{variant:"status",state:IN[s.tone],size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:s.label})]})}function Fd(e){const t=e.role??"menu",[s,o]=y.useState(!1),a=y.useRef(null);return y.useEffect(()=>{if(!s)return;const l=d=>{var f;(d instanceof KeyboardEvent?d.key==="Escape":!((f=a.current)!=null&&f.contains(d.target)))&&o(!1)};return window.addEventListener("mousedown",l),window.addEventListener("keydown",l),()=>{window.removeEventListener("mousedown",l),window.removeEventListener("keydown",l)}},[s]),i.jsxs("div",{className:Ge("header-menu",e.className),ref:a,children:[i.jsxs(M,{variant:"ghost","aria-haspopup":t,"aria-label":e.ariaLabel,"aria-expanded":s,on:s,"data-tip":s?void 0:e.tip,onClick:()=>o(!s),children:[e.label," ",e.badge," ",i.jsx("span",{className:"caret",children:"▾"})]}),s&&i.jsx("div",{className:"header-menu-list",role:t,children:e.children(()=>o(!1))})]})}function MN(){const e=ft();if(!e)return null;const t=(s,o)=>{o(),location.assign(s)};return i.jsx(Fd,{label:e.name,tip:"Your account on the server this Lookout runs on",children:s=>i.jsxs(i.Fragment,{children:[e.home&&i.jsxs("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(e.home.href,s),children:["← ",e.home.label]}),e.pages.map(o=>i.jsx("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(o.href,s),children:o.label},o.href)),e.signOut&&i.jsx("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(e.signOut,s),children:"Sign out"})]})})}const LN={new:"While you were away: a new trip report from Scout",seen:"Reopen the last trip report",none:"No trip report yet. Scout writes one when you come back after being away."};function ON(e){const t=e.briefingStatus==="new";return i.jsx(Fd,{label:"Records",badge:i.jsxs(i.Fragment,{children:[e.knowledge>0&&i.jsx("span",{className:"n hot",children:e.knowledge}),t&&i.jsx("span",{className:"new-dot","aria-label":"new trip report"})]}),children:s=>i.jsxs(i.Fragment,{children:[i.jsxs("button",{role:"menuitem",className:"header-menu-item",disabled:e.briefingStatus==="none"&&!e.briefingOpen,title:LN[e.briefingStatus],onClick:()=>{s(),e.onBriefing()},children:[i.jsx("span",{children:"Trip report"}),t&&i.jsx("span",{className:"new-dot","aria-label":"new"})]}),i.jsxs("button",{role:"menuitem",className:"header-menu-item knowledge-btn",title:"What agents know about this codebase and product. Review suggestions, flags and stale entries",onClick:()=>{s(),e.onKnowledge()},children:[i.jsx("span",{children:"Field guide"}),e.knowledge>0&&i.jsx("span",{className:"n hot",children:e.knowledge})]}),i.jsxs("button",{role:"menuitem",className:"header-menu-item decisions-btn",title:"Every decision across your trails, with its reasoning. Search, filter and export",onClick:()=>{s(),e.onDecisions()},children:[i.jsx("span",{children:"Logbook"}),i.jsx("span",{className:"n",children:e.decisions})]}),i.jsx("button",{role:"menuitem",className:"header-menu-item stats-btn",title:"How your agents deliver across trails, by vendor, agent and ticket type.",onClick:()=>{s(),e.onStats()},children:i.jsx("span",{children:"Trail stats"})})]})})}const zt=()=>{var e;return(e=ft())==null?void 0:e.agents},ev=()=>{const e=zt();e&&location.assign(e.href)},tv=e=>{const t=e;if(!(typeof(t==null?void 0:t.on)!="boolean"||!Array.isArray(t.repos)))return{canRun:t.canRun===!0,repos:t.repos.filter(s=>typeof s=="string").slice(0,200),on:t.on,...typeof t.repo=="string"?{repo:t.repo}:{},running:Number.isInteger(t.running)?t.running:0,...typeof t.note=="string"?{note:t.note.slice(0,200)}:{}}},ja=()=>{var e;return(e=ft())==null?void 0:e.trailAgents};async function PN(e){const t=ja();if(!t)return;const s=await fetch(`${t}?trail=${encodeURIComponent(e)}`).catch(()=>{});return s!=null&&s.ok?tv(await s.json().catch(()=>{})):void 0}async function _N(e,t){const s=ja();if(!s)return{error:"This Lookout doesn't run agents."};const o=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trail:e,...t})}).catch(()=>{}),a=await(o==null?void 0:o.json().catch(()=>{}));return(o!=null&&o.ok?tv(a):void 0)??{error:typeof(a==null?void 0:a.error)=="string"?a.error.slice(0,200):"The server didn't answer."}}function DN(e){return e.running?`Agents on · ${e.running} working`:e.note?`Agents on · ${e.note}`:"Agents on · starting soon"}function nv({mapId:e,onStarted:t}){const[s,o]=y.useState(),[a,l]=y.useState(),[d,h]=y.useState(!1),[f,p]=y.useState();if(y.useEffect(()=>{let w=!0;const j=()=>void PN(e).then(S=>w&&S&&o(S));j();const N=setInterval(j,15e3);return()=>{w=!1,clearInterval(N)}},[e]),!s||!s.canRun)return null;const v=async w=>{h(!0),p(void 0);const j=await _N(e,{on:w,...w&&a?{repo:a}:{}});if(h(!1),"error"in j)return p(j.error);o(j),w&&(t==null||t())},k=zt();return s.on?i.jsxs("span",{className:"start-trail",children:[i.jsx("span",{className:"start-trail-status",children:DN(s)}),i.jsx(M,{size:"sm",variant:"ghost",disabled:d,onClick:()=>void v(!1),children:"Pause"}),k&&i.jsx("a",{className:"t-meta",href:`${k.href}#trail-${encodeURIComponent(e)}`,children:"Runs"}),f&&i.jsx("span",{className:"vf-err",children:f})]}):i.jsxs("span",{className:"start-trail",children:[s.repos.length>1&&i.jsxs("select",{"aria-label":"Repository",value:a??"",onChange:w=>l(w.target.value||void 0),children:[i.jsx("option",{value:"",children:"Repository…"}),s.repos.map(w=>i.jsx("option",{value:w,children:w},w))]}),i.jsx(M,{variant:"primary",disabled:d||s.repos.length>1&&!a,onClick:()=>void v(!0),children:"Start the trail"}),!s.repos.length&&i.jsx("span",{className:"t-meta",children:"Connect a repository first."}),f&&i.jsx("span",{className:"vf-err",children:f})]})}function zN({mapId:e}){if(ja())return i.jsx(nv,{mapId:e});const t=zt();if(!t)return null;const s=()=>location.assign(`${t.href}#trail-${encodeURIComponent(e)}`);return i.jsx(M,{size:"sm",onClick:s,"data-tip":"Turn your agents on for this trail, or see them at work",children:"Run agents"})}const BN=i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"9",cy:"9",r:"3.6",fill:"currentColor"}),i.jsx("path",{d:"M9 1v2.400M9 14.600V17M1 9h2.400M14.6 9H17M3.3 3.300L5 5M13 13l1.7 1.700M3.3 14.700L5 13M13 5l1.7-1.7",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]}),FN=i.jsx("path",{d:"M15.2 11.400A6.9 6.9 0 0 1 6.6 2.800a6.9 6.9 0 1 0 8.6 8.600z",fill:"currentColor"});function UN({onToggle:e}){const t=Qg(),s=t?"Switch to the day theme":"Switch to the night theme";return i.jsx(M,{variant:"ghost",className:"icon-only","aria-label":s,"data-tip":s,onClick:()=>e(!t),children:i.jsx("svg",{viewBox:"0 0 18 18",width:"16",height:"16","aria-hidden":"true",children:t?BN:FN})})}const WN={idle:"Idle",syncing:"Syncing",ok:"Synced",error:"Sync error"};function HN({label:e,health:t,now:s}){const o=[`${WN[t.status]} · ${t.writes} writes · ${t.errors} errors`,t.lastWriteAt?`Last write ${Jt(t.lastWriteMs??0)}, ${Jt(s-t.lastWriteAt)} ago`:"No writes yet",t.lastError].filter(Boolean).join(`
|
|
139
|
+
`);return i.jsxs("span",{className:`tracker-chip sync-${t.status}`,title:o,children:[i.jsx(ze,{size:"sm",children:"Tracker"}),i.jsx(oi,{variant:"status",state:t.status,size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:e})]})}const Bm={"start-over":{text:e=>`Archive ${e.key} and start a new trail from its idea? The old map stays as history; its tickets and decisions don't carry over.`,confirm:"Start over"},archive:{text:e=>`Archive ${e.key}? It stays as history, read-only, and no agent takes work from it.`,confirm:"Archive"}};function KN(e){const{map:t}=e,[s,o]=y.useState();return t.archived?i.jsxs("button",{role:"menuitem",className:"trail-item act","data-tip":"Make it an active trail again: agents can take work from it",onClick:()=>(e.onArchive(!1),e.onDone()),children:["Restore ",t.key]}):s?i.jsxs("div",{className:"trail-confirm",role:"group",children:[i.jsx("p",{className:"t-meta",children:Bm[s].text(t)}),i.jsxs("div",{className:"actions",children:[i.jsx(M,{variant:"primary",onClick:()=>{s==="start-over"?e.onStartOver():e.onArchive(!0),e.onDone()},children:Bm[s].confirm}),i.jsx(M,{onClick:()=>o(void 0),children:"Cancel"})]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("button",{role:"menuitem",className:"trail-item act","data-tip":"The map went wrong? Archive it and describe the idea again",onClick:()=>o("start-over"),children:["Start ",t.key," over…"]}),i.jsxs("button",{role:"menuitem",className:"trail-item act","data-tip":"Put the trail away as history",onClick:()=>o("archive"),children:["Archive ",t.key,"…"]})]})}function VN(e){const{map:t}=e.snap,s=ig(e.snap);return i.jsxs("button",{role:"menuitem",className:`trail-item ${e.on?"on":""} ${t.archived?"archived":""}`,onClick:e.onSelect,children:[i.jsx("span",{className:"key",children:t.key}),i.jsx("span",{className:"mi-title",children:t.title}),i.jsxs("span",{className:"mi-progress",children:[s.decided,"/",s.total]}),i.jsx(fs,{n:e.waiting,urgent:!!e.waiting,hideZero:!0})]})}function GN(e){var v;const[t,s]=y.useState(!1),o=y.useRef(null);y.useEffect(()=>{if(!t)return;const k=w=>{var j;(w instanceof KeyboardEvent?w.key==="Escape":!((j=o.current)!=null&&j.contains(w.target)))&&s(!1)};return window.addEventListener("mousedown",k),window.addEventListener("keydown",k),()=>{window.removeEventListener("mousedown",k),window.removeEventListener("keydown",k)}},[t]);const a=Object.values(e.snaps).sort((k,w)=>w.map.createdAt-k.map.createdAt),l=a.filter(k=>!k.map.archived),d=a.filter(k=>k.map.archived),h=k=>e.activity.pending.filter(w=>w.mapId===k).length,f=e.activity.pending.filter(k=>{var w;return k.mapId!==((w=e.map)==null?void 0:w.id)}).length,p=k=>{var w;return i.jsx(VN,{snap:k,on:k.map.id===((w=e.map)==null?void 0:w.id),waiting:h(k.map.id),onSelect:()=>{e.onSelectMap(k.map.id),s(!1)}},k.map.id)};return i.jsxs("div",{className:"trail-switcher",ref:o,children:[i.jsxs("button",{className:"trail-btn",onClick:()=>s(k=>!k),"aria-haspopup":"menu","aria-expanded":t,"data-tip":"Switch trail, or start a new one",children:[i.jsx("span",{className:"trail-title",children:e.map?`${e.map.key} ${e.map.title}`:"No trail"}),((v=e.map)==null?void 0:v.archived)&&i.jsx("span",{className:"trail-archived",children:"archived"}),f>0&&i.jsx(fs,{n:f,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),t&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsx(ze,{variant:"plain",className:"menu-h",children:"Trails"}),l.map(p),i.jsx("button",{role:"menuitem",className:"trail-item new",onClick:()=>{s(!1),e.onNewTrail()},children:"+ New trail"}),d.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(ze,{variant:"plain",className:"menu-h",children:"Archived"}),d.map(p)]}),e.map&&e.onStartOver&&e.onArchive&&i.jsx("div",{className:"trail-acts",children:i.jsx(KN,{map:e.map,onStartOver:e.onStartOver,onArchive:e.onArchive,onDone:()=>s(!1)})})]})]})}function qN(e){const{map:t}=e,s=Xt(1e3),o=e.activity.pending.length,a=t&&e.snaps[t.id],l=a&&ig(a),d=t&&rg(e.activity,t.id);return i.jsxs(Be,{as:"header",className:"header",children:[i.jsxs("div",{className:"h-title",children:[i.jsxs("div",{className:"h-line1",children:[e.repo,i.jsx("span",{className:"sep",children:"/"}),i.jsx(GN,{...e})]}),i.jsxs("div",{className:"h-dest",title:t==null?void 0:t.sections.destination,children:[i.jsx(ze,{size:"sm",children:"Destination"}),(t==null?void 0:t.sections.destination)??"—"]})]}),i.jsxs("div",{className:"h-right",children:[i.jsx(HN,{label:e.trackerLabel,health:e.health,now:s}),i.jsx(RN,{now:s}),t&&l&&i.jsxs("span",{className:"trail-meta",children:[i.jsx(ln,{label:"Trail T+",value:Pg(s-t.createdAt),title:"Trail elapsed time, since it was charted"}),i.jsx(ln,{label:"Done",value:`${l.decided}/${l.total}`}),d&&i.jsx(ln,{className:"spend",label:"Spent",value:`${Js(d.costUsd)} · ${fa(d.inputTokens+d.outputTokens)} tok`,title:["Model spend and tokens for this trail, across every session",...ag(e.activity,t.id).map(h=>og[h].text)].join(`
|
|
140
140
|
`)})]}),e.attention,!e.attention&&o>0&&i.jsxs("span",{className:"waiting-chip",title:`${o} waiting on you`,children:[i.jsx(oi,{variant:"alert",size:14}),i.jsx("b",{children:o}),i.jsx("span",{className:"wl",children:" waiting on you"})]}),e.slackAlert&&i.jsx(M,{size:"sm",variant:"urgent",onClick:e.onSlack,title:e.slackAlert.why,children:e.slackAlert.label}),t&&i.jsx(M,{variant:"ghost",className:"mode-chip",onClick:e.onToggleMode,"data-tip":t.mode==="plan-only"?"Plan only: agents research and decide, but no execute tickets run. Click to switch to Plan + execute.":"Plan + execute: agents decide, then build what was decided. Click to switch to Plan only, which parks execute tickets.",children:t.mode==="plan-only"?"Plan only":"Plan + execute"}),t&&i.jsx(zN,{mapId:t.id}),i.jsx(ON,{decisions:e.decisions,onDecisions:e.onDecisions,onStats:e.onStats,knowledge:e.knowledge,onKnowledge:e.onKnowledge,briefingOpen:e.briefingOpen,briefingStatus:e.briefingStatus,onBriefing:e.onBriefing}),i.jsx(M,{variant:"ghost",onClick:e.onSettings,"data-tip":"Tracker, verification, appearance and integrations",children:"Settings"}),Yg()?null:i.jsx(UN,{onToggle:e.onToggleTheme}),i.jsx(MN,{})]})]})}const sv=y.createContext(null);function ai(){const e=y.useContext(sv);if(!e)throw new Error("useKnowledge needs a KnowledgeContext provider");return e}function QN({snap:e,t}){const s=ai();if(!s.entries.length||t.state==="closed")return null;const o=yg(s.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:wg(`${t.body}
|
|
141
|
-
${s.briefText}`)},4e3,a=>s.stale[a.id]??[]);return i.jsxs("div",{className:"kn-preview d-section",children:[i.jsxs("span",{className:"t-label","data-tip":"Picked by paths, words, trail and kind; confirmed entries and assumptions only",children:["Knowledge this agent gets · ",o.length]}),o.length>0&&i.jsx("ul",{className:"item-list inline",children:o.map(a=>i.jsxs("li",{children:[i.jsx("button",{className:"item-text kn-open",onClick:()=>s.setOpen(!0),"data-tip":a.why.join(" · "),children:a.title}),i.jsx(V,{parts:[{text:a.id,code:!0},a.status==="assumption"&&"assumption",a.mayBeOutdated&&{text:"may be outdated",className:"warn"}]})]},a.id))})]})}function Io(e,t){return(e==null?void 0:e.hash)===void 0?{hash:t,latest:t}:e.latest===t?e:{hash:e.hash,latest:t}}function Sa(e,t){const[s,o]=y.useState({key:e,shown:Io(void 0,t)});let a=s;return s.key!==e?a={key:e,shown:Io(void 0,t)}:s.shown.latest!==t&&(a={key:e,shown:Io(s.shown,t)}),a!==s&&o(a),{hash:a.shown.hash,changed:a.shown.hash!==a.shown.latest,reviewAgain:()=>o({key:e,shown:Io(void 0,t)})}}const YN={suggested:"Suggested by an agent. Not delivered to agents until you confirm it or keep it as an assumption.",confirmed:"Confirmed: agents treat it as a fact.",assumption:"Kept as an assumption: agents get it, marked as unverified.",outdated:"Outdated: kept for history, never delivered."};function JN({e}){const t=ai(),[s,o]=y.useState(!1),[a,l]=y.useState(e.title),[d,h]=y.useState(e.body);y.useEffect(()=>{o(!1),l(e.title),h(e.body)},[e.id,e.title,e.body]);const f=t.stale[e.id],p=Sa(e.id,t.hashes[e.id]);return i.jsxs("div",{className:"kn-detail",children:[i.jsx(V,{parts:[{text:e.id,code:!0},e.kind.replace("-"," "),e.status]}),s?i.jsxs(i.Fragment,{children:[i.jsx(Ze,{label:"Title",children:i.jsx("input",{value:a,onChange:k=>l(k.target.value)})}),i.jsx(Ze,{label:"Body",children:i.jsx("textarea",{rows:8,value:d,onChange:k=>h(k.target.value)})})]}):i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"t-title",children:e.title}),i.jsx("p",{className:"kn-body",children:e.body})]}),i.jsx("p",{className:"dim",children:YN[e.status]}),e.flag&&i.jsxs("p",{className:"kn-warn",children:["Flagged by ",e.flag.by,": ",e.flag.reason]}),f&&e.status!=="outdated"&&i.jsxs("p",{className:"kn-warn",children:["May be outdated: ",f.join(", ")," changed since it was confirmed. Re-confirm or edit it."]}),i.jsxs("dl",{className:"facts",children:[e.scope.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Applies to"}),i.jsx("dd",{children:e.scope.join(", ")})]}),e.tags.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Tags"}),i.jsx("dd",{children:e.tags.join(", ")})]}),i.jsx("dt",{children:"From"}),i.jsx("dd",{children:[e.createdBy,...e.sources].join(" · ")}),e.anchors.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"About files"}),i.jsx("dd",{children:e.anchors.map(k=>k.path).join(", ")})]})]}),p.changed&&i.jsx(ya,{what:"This entry",onReviewAgain:p.reviewAgain}),t.error&&i.jsx("p",{className:"vf-err",children:t.error}),i.jsx("div",{className:"actions",children:s?i.jsxs(i.Fragment,{children:[i.jsx(M,{variant:"ghost",onClick:()=>o(!1),children:"Cancel"}),i.jsx(M,{variant:"primary",disabled:!a.trim(),onClick:()=>void t.call(e.id,{kind:"edit",title:a,body:d}).then(k=>k&&o(!1)),children:"Save"})]}):i.jsxs(i.Fragment,{children:[(e.status!=="confirmed"||f)&&i.jsx(M,{variant:"primary",disabled:p.changed,onClick:()=>void t.call(e.id,{kind:"confirm"},p.hash),children:e.status==="confirmed"?"Re-confirm":"Confirm"}),e.status!=="assumption"&&e.status!=="outdated"&&i.jsx(M,{disabled:p.changed,onClick:()=>void t.call(e.id,{kind:"assumption"},p.hash),children:"Keep as assumption"}),e.flag&&i.jsx(M,{onClick:()=>void t.call(e.id,{kind:"resolve-flag"}),children:"Resolve flag"}),i.jsx(M,{variant:"ghost",onClick:()=>o(!0),children:"Edit"}),e.status!=="outdated"&&i.jsx(M,{variant:"ghost",onClick:()=>void t.call(e.id,{kind:"outdated"}),children:"Mark outdated"})]})})]})}const XN={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function ZN(){const e=ai(),[t,s]=y.useState("review"),[o,a]=y.useState(""),[l,d]=y.useState(""),[h,f]=y.useState();y.useEffect(()=>{if(!e.open)return;const S=I=>I.key==="Escape"&&e.setOpen(!1);return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[e]);const p=S=>S.status==="suggested"||!!S.flag||!!e.stale[S.id]&&S.status!=="outdated",k=(S,I)=>I==="all"?!0:I==="review"?p(S):S.status===I,v=y.useMemo(()=>{const S=l.trim().toLowerCase();return e.entries.filter(I=>k(I,t)&&(!o||I.kind===o)&&(!S||`${I.id} ${I.title} ${I.body} ${I.tags.join(" ")}`.toLowerCase().includes(S)))},[e.entries,e.stale,t,o,l]);if(!e.open)return null;const w=v.find(S=>S.id===h)??v[0],j=S=>e.entries.filter(I=>k(I,S)).length,N=[["review","Needs you"],["confirmed","Confirmed"],["assumption","Assumptions"],["outdated","Outdated"],["all","All"]];return i.jsx("div",{className:"scrim",onClick:()=>e.setOpen(!1),children:i.jsxs(Be,{as:"div",className:"dialog knowledge-view",onClick:S=>S.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Field guide"}),i.jsx(ii,{text:"What agents need to know about this codebase and product. Agents propose entries; only confirmed ones and assumptions reach them, picked for each ticket with the reason. Entries about files are flagged here when those files change. Seed it from a document with: teamtrail knowledge import <file.md>"})]}),i.jsxs("div",{className:"kn-filters",children:[N.map(([S,I])=>i.jsxs("button",{className:`chip ${t===S?"on":""}`,onClick:()=>s(S),children:[I," ",i.jsx("span",{className:"n",children:j(S)})]},S)),i.jsx(at,{compact:!0,"aria-label":"Kind",value:o,onChange:a,options:[{value:"",label:"Any kind"},...zj.map(S=>({value:S,label:S.replace("-"," ")}))]}),i.jsx("input",{className:"kn-search",placeholder:"Search",value:l,onChange:S=>d(S.target.value)})]}),i.jsxs("div",{className:"kn-body-grid",children:[i.jsx("ul",{className:"kn-list",children:v.length?v.map(S=>i.jsx(be,{as:"li",className:`kn-row st-${S.status}`,edge:p(S)?"attention":"neutral",selected:S===w,onOpen:()=>f(S.id),title:S.title,titleText:S.title,context:i.jsx(V,{parts:[{text:S.id,code:!0},S.kind.replace("-"," "),p(S)&&S.status!=="suggested"?"Needs a check":XN[S.status]]})},S.id)):i.jsx(Ie,{children:t==="review"?"Nothing needs you":"No entries"})}),w?i.jsx(JN,{e:w}):i.jsx(Ie,{children:"Pick an entry"})]})]})})}function Ud({draft:e,label:t="Save as knowledge"}){const s=ai(),[o,a]=y.useState();return o?i.jsxs(M,{size:"sm",variant:"ghost",onClick:()=>s.setOpen(!0),"data-tip":"Open it in the field guide to confirm it",children:["Saved as ",o]}):i.jsx(M,{size:"sm",variant:"ghost","data-tip":"Add it to the field guide as a suggestion; confirm it there and agents get it with related work",onClick:()=>void s.propose(e()).then(l=>l&&a(l.id)),children:t})}const eb=e=>{try{return JSON.parse(e)}catch{return}};function iv(e){const t=ni();let s=!1;const o=()=>{const h=t.start();e.load().then(f=>!s&&h()&&e.show(f),()=>{var f;return!s&&h()&&((f=e.failed)==null?void 0:f.call(e))})},{changed:a,events:l={}}=e,d=[vs(o),...a?[Pd(h=>a(h)&&o())]:[],...Object.entries(l).map(([h,f])=>si(h,p=>f(eb(p))&&o()))];return o(),{reload:o,pushed:()=>t.pushed(),stop:()=>{s=!0;for(const h of d)h()}}}function Ye(e){const t=y.useRef(e);t.current=e;const s=y.useRef(),o=y.useRef(e.version),{view:a,version:l}=e;y.useEffect(()=>{const f=t.current;o.current=f.version;const p=Object.keys(f.events??{}),k=iv({load:()=>t.current.load(),show:v=>t.current.show(v),failed:()=>{var v,w;return(w=(v=t.current).failed)==null?void 0:w.call(v)},...f.changed?{changed:v=>{var w,j;return((j=(w=t.current).changed)==null?void 0:j.call(w,v))===!0}}:{},events:Object.fromEntries(p.map(v=>[v,w=>{var j,N;return((N=(j=t.current.events)==null?void 0:j[v])==null?void 0:N.call(j,w))===!0}]))});return s.current=k,()=>{k.stop(),s.current=void 0}},[a]),y.useEffect(()=>{var f;Object.is(o.current,l)||(o.current=l,(f=s.current)==null||f.reload())},[l]);const d=y.useCallback(()=>{var f;return(f=s.current)==null?void 0:f.reload()},[]),h=y.useCallback(()=>{var f;return(f=s.current)==null?void 0:f.pushed()},[]);return{reload:d,pushed:h}}const rv=`${pe()}/knowledge`;async function Fm(e,t){const s=await fetch(`${rv}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await s.json().catch(()=>({}));if(!s.ok)throw new Error(o.error??`HTTP ${s.status}`);return o}async function tb(){const e=await fetch(rv);return e.ok?await e.json():null}function nb(e){const[t,s]=y.useState([]),[o,a]=y.useState({}),[l,d]=y.useState({}),[h,f]=y.useState(!1),[p,k]=y.useState(),{reload:v}=Ye({load:tb,show:j=>{j&&(s(j.entries),a(j.stale),d(j.hashes??{}))},changed:j=>j.startsWith("knowledge/")}),w=y.useMemo(()=>t.filter(j=>j.status==="suggested"||j.flag||o[j.id]&&j.status!=="outdated").length,[t,o]);return{entries:t,stale:o,briefText:e,attention:w,open:h,setOpen:f,error:p,hashes:l,call:(j,N,S)=>Fm("/call",{id:j,call:N,hash:S??l[j]}).then(()=>(k(void 0),v(),!0),I=>(k(I.message),v(),!1)),propose:j=>Fm("/propose",j).then(N=>(v(),N.entry),N=>(k(N.message),void 0))}}const sb=["awaiting","blocked","trail.done","resolved"];async function qn(e,t="GET",s){const o=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:s===void 0?void 0:JSON.stringify(s)}),a=await o.json().catch(()=>({}));if(!o.ok&&!a.status)throw new Error(a.error??`request failed (${o.status})`);return a}function ib(e){const t=`${e}/slack`;return{get:()=>qn(t),connectStart:s=>qn(`${t}/connect/start`,"POST",{project:s}),connectPreview:s=>qn(`${t}/connect/preview`,"POST",{code:s}),connectFinish:s=>qn(`${t}/connect/finish`,"POST",{code:s}),connectCancel:()=>qn(`${t}/connect/cancel`,"POST",{}),disconnect:()=>qn(`${t}/connect`,"DELETE"),update:s=>qn(`${t}/settings`,"PUT",s),members:()=>qn(`${t}/members`).then(s=>s.members)}}const jn=ib(pe());function rb(e){const{who:t}=e;return i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"sl-lead",children:["Connect as ",i.jsxs("b",{children:["@",t.user.name??t.user.id]})," in ",i.jsx("b",{children:t.workspace.name}),"? That Slack account becomes Scout's owner for this Teamtrail: questions and approvals reach it."]}),i.jsxs("div",{className:"c-actions",children:[i.jsx(M,{size:"sm",variant:"primary",onClick:e.onConnect,children:"Connect"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]})]})}const ob=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function ab({problem:e}){const t=e.failures===1?"A message was":`${e.failures} messages were`;return i.jsxs("div",{className:"test-line warn",title:e.code,children:[t," not delivered (last ",ob(e.at),"). ",e.message]})}function ud(e){const[t,s]=y.useState(!1),o=()=>{s(!0),jn.connectStart(ur()).then(a=>location.assign(a.url),a=>{s(!1),e.onError(a.message)})};return i.jsx(M,{size:"sm",variant:"primary",disabled:t,onClick:o,children:e.again?"Add Scout to Slack again":"Add Scout to Slack"})}function lb(e){return i.jsxs("div",{className:"test-line mentions-hint",children:[i.jsx("span",{children:"Reconnect to allow @Scout mentions: Slack needs one more permission for them."}),i.jsx(ud,{again:!0,onError:e.onError})]})}function cb({s:e,connecting:t}){return t?i.jsx("p",{className:"sl-lead",children:"Connecting Scout…"}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"sl-lead",children:"Answer agents, approve finished work and save threads as decisions from Slack. Scout is Teamtrail's Slack app: add it to your workspace and it talks to you about this machine's trails. Questions and answers pass through Teamtrail's Scout service; your trails, decisions and approvals stay here."}),e.legacy&&i.jsx("p",{className:"sl-lead",children:"You made your own Slack app with an earlier version. Scout is now one app, so add it again: your old app's tokens are deleted from this machine when you do."})]})}function db(e){return i.jsx("a",{className:["btn",e.primary&&"primary",e.small&&"sm"].filter(Boolean).join(" "),href:Nn(e.href,["slack:"]),target:"_blank",rel:"noreferrer",onClick:e.onClick,children:e.children})}function Um({onRemoved:e}){const[t,s]=y.useState(!1);if(!t)return i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>s(!0),children:"Disconnect"});const o=()=>void jn.disconnect().then(a=>{s(!1),e(a)},()=>{});return i.jsxs(i.Fragment,{children:[i.jsx(M,{size:"sm",variant:"danger",onClick:o,children:"Disconnect and forget Slack settings"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]})}function ub(e){const{s:t}=e,s=t.state==="auth-error"||t.state==="other-service";return t.connected?i.jsxs("div",{className:"c-actions",children:[s?i.jsx(ud,{again:!0,onError:e.onError}):i.jsx(M,{size:"sm",on:t.enabled,onClick:e.onToggle,children:t.enabled?"Turn off":"Turn on"}),t.links.homeWeb&&i.jsx(db,{small:!0,href:t.links.homeWeb,children:"Open Scout in Slack"}),i.jsx(Um,{onRemoved:e.onChanged})]}):i.jsxs("div",{className:"c-actions",children:[!e.busy&&i.jsx(ud,{again:t.legacy,onError:e.onError}),t.legacy&&i.jsx(Um,{onRemoved:e.onChanged})]})}const hb={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function fb({s:e}){const[t,s]=mb(e);return i.jsxs("div",{className:`sync-line ${t}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:s})]})}function mb(e){switch(e.state){case"online":return["ok","Online"];case"connecting":return["","Connecting"];case"offline":return["warn","Offline · reconnecting"];case"auth-error":return["alert",`Disconnected · ${e.error??"add Scout to Slack again"}`];case"elsewhere":{const t=e.heldBy?` (${e.heldBy})`:"";return["warn",`Connected from another ${Z.slug}${t}`]}case"other-service":return["alert","Not connected · this Teamtrail points at another Scout service"];case"unsupported":return["alert",e.error??"Not supported here"];default:return["",e.connected?"Off":"Not connected"]}}function pb(e){const{s:t,back:s}=e,o=!!s.confirm&&!t.connected;return i.jsxs(un,{className:vb(t),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:"Scout in Slack"}),t.connected&&i.jsx(bn,{className:t.enabled?"on":"",children:t.enabled?"On":"Off"})]}),t.connected&&i.jsx("div",{className:"c-loc",children:gb(t)}),t.connected&&i.jsx(fb,{s:t}),t.connected&&i.jsx("div",{className:"t-meta",children:"Scout answers in Slack only while this Teamtrail is running."}),t.delivery&&i.jsx(ab,{problem:t.delivery}),t.connected&&t.mentions===!1&&!o&&i.jsx(lb,{onError:e.onError}),!t.connected&&!o&&i.jsx(cb,{s:t,connecting:s.busy}),o&&i.jsx(rb,{who:s.confirm,onConnect:s.connect,onCancel:s.cancel}),e.error&&i.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]}),!o&&i.jsx(ub,{s:t,busy:s.busy,onError:e.onError,onChanged:e.onChanged,onToggle:e.onToggle})]})}function gb(e){var s,o,a;const t=(o=(s=e.workspace)==null?void 0:s.url)==null?void 0:o.replace(/^https?:\/\/|\/$/g,"");return[(a=e.workspace)==null?void 0:a.name,t].filter(Boolean).join(" · ")}function vb(e){const t=e.connected&&e.enabled?"active":"",s=e.connected?"":"open";return`connector ${t} ${s}`}function kb(e){const[t,s]=y.useState(e.value==="dm"?"":e.value),o=/^[CG][A-Z0-9]{6,}$/.test(t.trim());return i.jsxs("form",{className:"sl-field",onSubmit:a=>{a.preventDefault(),o&&e.onSave(t.trim())},children:[i.jsx("input",{value:t,spellCheck:!1,placeholder:"Channel ID, e.g. C0123ABCD","aria-label":"Channel ID",onChange:a=>s(a.target.value)}),i.jsx(M,{type:"submit",disabled:!o||t.trim()===e.value,children:"Save"})]})}function yb(e){const[t,s]=y.useState(),[o,a]=y.useState();y.useEffect(()=>{jn.members().then(s,h=>a(h.message))},[]);const l=new Set(e.owners.map(h=>h.id)),d=new Set(e.value.map(h=>h.id));return o?i.jsxs("div",{className:"test-line alert",children:["✕ ",o]}):t?i.jsx("div",{className:"choice-row compact sl-members",children:t.map(h=>i.jsx(ot,{on:l.has(h.id)||d.has(h.id),disabled:l.has(h.id),title:`@${h.name??h.id}`,sub:l.has(h.id)?"Owner":void 0,onClick:()=>e.onChange(d.has(h.id)?e.value.filter(f=>f.id!==h.id):[...e.value,h])},h.id))}):i.jsx("span",{className:"t-meta",children:"Loading members…"})}function wb(e){const{s:t,patch:s}=e,[o,a]=y.useState(!1),l=new Set(t.notify.events),d=o||t.notify.target!=="dm",h=t.owners[0],f=p=>{const k=l.has(p)?t.notify.events.filter(v=>v!==p):[...t.notify.events,p];s({notify:{events:k}})};return i.jsxs("div",{className:"sl-groups",children:[i.jsxs("div",{className:"sl-group",children:[i.jsx(ze,{variant:"plain",size:"sm",children:"Owner"}),i.jsxs("div",{className:"sl-owner",children:[i.jsxs("b",{children:["@",(h==null?void 0:h.name)??(h==null?void 0:h.id)]}),i.jsx("span",{className:"t-meta",children:"Added Scout from this machine"})]})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(ze,{variant:"plain",size:"sm",children:"Allowed users"}),i.jsx(yb,{value:t.allow,owners:t.owners,onChange:p=>s({allow:p})},t.state)]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(ze,{variant:"plain",size:"sm",children:"Notify"}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ot,{on:!d,title:"DM to owner",onClick:()=>{a(!1),s({notify:{target:"dm",detail:"full"}})}}),i.jsx(ot,{on:d,title:"Channel",sub:t.notify.target!=="dm"?t.notify.target:void 0,onClick:()=>a(!0)})]}),d&&i.jsxs(i.Fragment,{children:[i.jsx(Ze,{label:"Channel ID (invite @Scout there first)",children:i.jsx(kb,{value:t.notify.target,onSave:p=>s({notify:{target:p}})})}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ot,{on:t.notify.detail==="full",title:"Full questions",onClick:()=>s({notify:{detail:"full"}})}),i.jsx(ot,{on:t.notify.detail==="titles-only",title:"Titles only",onClick:()=>s({notify:{detail:"titles-only"}})})]})]}),i.jsx("div",{className:"choice-row compact",children:sb.map(p=>i.jsx(ot,{on:l.has(p),title:hb[p],onClick:()=>f(p)},p))})]}),i.jsx(dd,{className:"dim",parts:[`${t.command} decide`,`${t.command} status`,`${t.command} inbox`,"Save as decision on any message"]})]})}function xb(){if(typeof location>"u")return;const e=/(?:^#|&)slack-link=([A-Za-z0-9_-]{43})/.exec(location.hash);if(e)return history.replaceState(null,"",`${location.pathname}${location.search}`),e[1]}const Pc={code:xb()};function jb(e){const[t,s]=y.useState(),[o,a]=y.useState(),[l,d]=y.useState(),[h,f]=y.useState(!!Pc.code),p=v=>d(v.message);y.useEffect(()=>{const v=Pc.code;v&&(Pc.code=void 0,s(v),jn.connectPreview(v).then(a,p).finally(()=>f(!1)))},[]);const k=v=>{f(!0),a(void 0),v.then(e,p).finally(()=>f(!1))};return{busy:h,error:l,confirm:o,connect:()=>t&&k(jn.connectFinish(t)),cancel:()=>k(jn.connectCancel())}}function Wd(e=0){const[t,s]=y.useState(),o=y.useCallback(()=>jn.get().then(s,()=>s(null)),[]);return y.useEffect(()=>{if(o(),!e)return;const a=setInterval(()=>void o(),e);return()=>clearInterval(a)},[o,e]),[t,s]}function Sb(e){const[t,s]=Wd(3e3),o=jb(s),[a,l]=y.useState(),d=y.useRef(null);if(y.useEffect(()=>{var f;e.focus&&t&&((f=d.current)==null||f.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const h=f=>jn.update(f).then(s,()=>{});return i.jsxs("div",{ref:d,className:"slack-settings",children:[i.jsx(pb,{s:t,back:o,error:a??o.error,onError:l,onToggle:()=>void h({enabled:!t.enabled}),onChanged:f=>{l(void 0),s(f)}}),t.connected&&i.jsx(wb,{s:t,patch:f=>void h(f)})]})}function Nb(e){if(e.legacy&&!e.connected)return{label:"Add Scout to Slack again",why:"Scout is now one Slack app; your own app no longer works"};if(e.connected&&e.state==="auth-error")return{label:"Slack disconnected",why:e.error??"Add Scout again"}}let Wm;function bb(){return Wm??(Wm=jn.get().then(e=>({owners:e.owners??[],allow:e.allow??[]}),()=>{})),Wm}function li(){const[e,t]=y.useState();return y.useEffect(()=>{let s=!0;return bb().then(o=>s&&t(o)),()=>{s=!1}},[]),e}function $b(e){const{api:t,rt:s,brief:o}=e,{snap:a,actions:l}=t,[d]=Wd(15e3),h=ai(),f=d?Nb(d):void 0;return i.jsx(qN,{repo:e.repo,snaps:t.allSnaps,map:a==null?void 0:a.map,activity:t.activity,health:t.health,onNewTrail:e.onNewTrail,onStartOver:e.onStartOver,onArchive:l.setArchived,trackerLabel:s.adapter.label.toLowerCase(),onSelectMap:l.selectMap,onToggleMode:()=>a&&l.setMode(a.map.mode==="plan-only"?"plan+execute":"plan-only"),onSettings:e.onSettings,onToggleTheme:e.onToggleTheme,attention:e.attention,slackAlert:f,onSlack:e.onSlack,decisions:t.decisions.length,decisionsOpen:e.decisionsOpen,onDecisions:e.onDecisions,onStats:e.onStats,knowledge:h.attention,knowledgeOpen:h.open,onKnowledge:()=>h.setOpen(!h.open),briefingOpen:o.shown,briefingStatus:o.status,onBriefing:()=>o.shown?o.dismiss():o.open()})}const Cb="This is a high-risk call: only an owner, or someone they allowed to make high-risk calls, can make it. It waits for them.",ov=()=>{var e;return((e=ft())==null?void 0:e.highRisk)===!1};function Tb(e){var t;return(t=e.options)!=null&&t.length?i.jsx("div",{className:"suggest",children:e.options.map(s=>i.jsx("button",{className:"chip",onClick:()=>e.onPick(s),children:s},s))}):null}function Eb(e){const{pending:t}=e;return t!=null&&t.lookoutOnly&&ov()?i.jsx("p",{className:"vf-intro",children:Cb}):i.jsxs(i.Fragment,{children:[i.jsx(Tb,{options:t==null?void 0:t.suggestions,onPick:e.onSend}),i.jsx(wa,{ref:e.inputRef,className:"comms-input",value:e.draft,onValueChange:e.onDraft,onSubmit:e.onSend,disabled:!t,placeholder:t?"Answer":""})]})}function Ab(e){const{m:t}=e,s=li(),o=t.from==="human"?"human":"agent";return i.jsxs("div",{className:`msg from-${t.from} voice-${o}`,children:[i.jsx(V,{parts:[ps(t.author,s),Nx(t),ha(t.at)]}),i.jsx("div",{className:"msg-text",children:t.text}),e.stillOpen&&i.jsx("button",{className:"answer-this t-meta",onClick:e.onAnswerThis,children:"Answer this"})]})}function Ib(e){const{ticket:t}=e;return i.jsxs("div",{className:"comms-ticket",children:[i.jsxs("div",{className:"t-title",title:t&&`${t.key} ${t.title}`,children:[i.jsx("span",{className:"key",children:t==null?void 0:t.key})," ",t==null?void 0:t.title]}),i.jsx(V,{parts:[e.trail,e.agent]})]})}function Rb({id:e,text:t}){const[s,o]=y.useState(),a=s!==e;return i.jsx(ua,{size:.6,framed:!1,state:a?"speaking":"alert",speaking:a?t.slice(0,60):void 0,onSpeakEnd:()=>o(e),className:"q-avatar"})}function Mb(e){const{q:t}=e;return i.jsxs("div",{className:"msg open-q",children:[i.jsx(V,{parts:[t.agent,ha(t.at)]}),i.jsx(Rb,{id:e.chatId??t.id,text:t.text}),i.jsx("div",{className:"msg-text",children:t.text}),t.stakes&&i.jsx(V,{parts:[{text:t.stakes,strong:!0}]}),t.precedent&&i.jsx(V,{className:"open-q-precedent",parts:[t.precedent]})]})}function Lb(e){const{activity:t,sessionId:s}=e,[o,a]=y.useState(""),[l,d]=y.useState(),h=y.useRef(null),f=y.useRef(null),p=t.sessions.find(O=>O.id===s),k=t.chats.filter(O=>O.sessionId===s),v=sN(t.pending,s,l??e.questionId),w=new Set(t.pending.filter(O=>O.sessionId===s).map(O=>O.id)),j=k.find(O=>!!v&&O.questionId===v.id),N=k.filter(O=>O!==j),S=p?e.snaps[p.mapId]:void 0,I=p!=null&&p.ticketId?S==null?void 0:S.tickets.find(O=>O.id===p.ticketId):void 0;y.useEffect(()=>{const O=h.current;O==null||O.scrollTo({top:O.scrollHeight,behavior:"smooth"})},[N.length,v==null?void 0:v.id]),y.useEffect(()=>{var O;v&&!e.onBack&&((O=f.current)==null||O.focus({preventScroll:!0}))},[v==null?void 0:v.id,e.onBack]);const $=O=>{!v||!O.trim()||(e.onAnswer(v.id,O.trim()),a(""))},_=Ob(p,!!v);return i.jsxs("div",{className:`comms ${v?"asking":""}`,children:[i.jsx(Et,{title:"HITL line",right:p?i.jsx("span",{className:`status ${v?"urgent":""}`,children:_}):void 0,children:e.onBack&&i.jsx("button",{className:"back",onClick:e.onBack,"aria-label":"Back to inbox",children:"‹ Inbox"})}),p?i.jsxs(i.Fragment,{children:[i.jsx(Ib,{ticket:I,trail:S==null?void 0:S.map.title,agent:p.agent}),i.jsx("div",{className:"comms-log",ref:h,children:N.map(O=>i.jsx(Ab,{m:O,stillOpen:!!O.questionId&&w.has(O.questionId),onAnswerThis:()=>d(O.questionId)},O.id))}),v&&i.jsx(Mb,{q:v,chatId:j==null?void 0:j.id}),i.jsx(Eb,{pending:v,draft:o,onDraft:a,onSend:$,inputRef:f})]}):i.jsx(Ie,{children:"No conversation"})]})}function Ob(e,t){return e?t?"Your answer is needed":dn(e)?`${e.agent} is working…`:e.status==="done"?"Resolved · ticket closed":"Session ended":""}async function Pb(e){const[t,s]=e.ref.split("+"),o=await fetch(`${pe()}/workspaces/integration`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,a:t,b:s})});return o.ok?void 0:(await o.json().catch(()=>({}))).error??`Adding failed (${o.status})`}function _b({item:e}){const[t,s]=y.useState(!1),[o,a]=y.useState(),l=()=>{s(!0),a(void 0),Pb(e).then(a,d=>a(d.message)).finally(()=>s(!1))};return i.jsxs("div",{className:"att-action",children:[i.jsx(M,{size:"sm",className:"integration-add",disabled:t,onClick:l,children:t?"Adding…":"Add integration ticket"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}async function Db(e,t){const s=e.ref.slice(0,e.ref.lastIndexOf(":")),o=await fetch(`${pe()}/trackers/settings/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,issueId:s,choice:t})});return o.ok?void 0:(await o.json().catch(()=>({}))).error??`Saving failed (${o.status})`}function zb({item:e}){const[t,s]=y.useState(!1),[o,a]=y.useState(),l=d=>{s(!0),a(void 0),Db(e,d).then(a,h=>a(h.message)).finally(()=>s(!1))};return i.jsxs("div",{className:"att-action",children:[i.jsx(M,{size:"sm",disabled:t,onClick:()=>l("stricter"),children:"Keep stricter"}),i.jsx(M,{size:"sm",disabled:t,onClick:()=>l("as-is"),children:"Accept as is"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function Bb({item:e}){return e.kind==="integration"?i.jsx(_b,{item:e}):e.kind==="tracker-settings"&&e.ref.includes(":")?i.jsx(zb,{item:e}):null}const Fb=/(\S*\/\S*|#\d+)/g;function Ub({reasons:e}){return e.length?i.jsx("span",{className:"reason-line",children:e.map((t,s)=>i.jsxs("span",{children:[s>0&&i.jsx("span",{className:"sep",children:" · "}),t.split(Fb).map((o,a)=>a%2===1?i.jsx("span",{className:"t-code",children:o},a):o)]},t))}):null}const av={question:"Question",approval:"Approve",blocked:"Blocked",flag:"PR / CI",stalled:"Stalled","hitl-ready":"Needs you",knowledge:"Field guide",brief:"Brief",policy:"Risk",reroute:"Reroute","reroute-suggested":"Reroute?",overlap:"Overlap",integration:"Integrate",guide:"Guide","guide-checks":"Approve",trust:"Approve",model:"Model",delivery:"Delivery","tracker-settings":"Settings",precedent:"Precedent","review-limit":"Review"},Wb={question:"questions",approval:"approvals",blocked:"blocked tickets",flag:"PR / CI flags",stalled:"stalled claims","hitl-ready":"tickets for you",knowledge:"field guide entries",brief:"briefs",policy:"risky changes",reroute:"reroutes","reroute-suggested":"suggested reroutes",overlap:"overlapping claims",integration:"clashing branches",guide:"guides to approve","guide-checks":"guide checks to approve",trust:"things to approve on this machine",model:"tickets waiting for a model",delivery:"connectors not delivering","tracker-settings":"settings changed in the tracker",precedent:"changes to what you decided","review-limit":"review queues full"},Hb=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],Kb=["blocked","flag","stalled","policy","reroute","overlap","integration","model"];function lv(e,t){return t||e.urgency==="blocking"?"urgent":Kb.includes(e.kind)?"attention":"neutral"}const Vb=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function cv(e){return e.reasons.filter(t=>!Vb.some(s=>s.test(t)))}function Gb(e){const{item:t,snap:s}=e,o=s==null?void 0:s.tickets.find(h=>h.id===t.ticketId),a=t.kind==="question"&&t.agent?`${t.agent} asks`:av[t.kind],l=[];t.urgency==="blocking"&&l.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),l.push({text:a,strong:!0});const d=o&&qb(t.title,o);return d&&l.push(d),e.otherTrail&&l.push((s==null?void 0:s.map.title)??t.mapId),l}function qb(e,t){if(!e.includes(t.key))return e.includes(t.title)?{text:t.key,code:!0}:`${t.key} ${t.title}`}function Qb(e){const[t,s]=y.useState(!1),o=a=>{s(!1),a()};return i.jsxs("span",{className:"snooze",children:[i.jsx("button",{type:"button",className:"snooze-btn","aria-expanded":t,"aria-label":`Later: ${e.title}`,onClick:()=>s(!t),children:"Later"}),t&&i.jsxs("span",{className:"snooze-menu",role:"menu",children:[Hb.map(a=>i.jsx("button",{type:"button",role:"menuitem",onClick:()=>o(()=>e.onSnooze(a.minutes)),children:a.label},a.minutes)),e.canDismiss&&i.jsx("button",{type:"button",role:"menuitem",onClick:()=>o(e.onDismiss),children:"Set aside"})]})]})}const Yb=15e3;function Jb(e){const{item:t}=e,s=t.title.split(`
|
|
141
|
+
${s.briefText}`)},4e3,a=>s.stale[a.id]??[]);return i.jsxs("div",{className:"kn-preview d-section",children:[i.jsxs("span",{className:"t-label","data-tip":"Picked by paths, words, trail and kind; confirmed entries and assumptions only",children:["Knowledge this agent gets · ",o.length]}),o.length>0&&i.jsx("ul",{className:"item-list inline",children:o.map(a=>i.jsxs("li",{children:[i.jsx("button",{className:"item-text kn-open",onClick:()=>s.setOpen(!0),"data-tip":a.why.join(" · "),children:a.title}),i.jsx(V,{parts:[{text:a.id,code:!0},a.status==="assumption"&&"assumption",a.mayBeOutdated&&{text:"may be outdated",className:"warn"}]})]},a.id))})]})}function Io(e,t){return(e==null?void 0:e.hash)===void 0?{hash:t,latest:t}:e.latest===t?e:{hash:e.hash,latest:t}}function Sa(e,t){const[s,o]=y.useState({key:e,shown:Io(void 0,t)});let a=s;return s.key!==e?a={key:e,shown:Io(void 0,t)}:s.shown.latest!==t&&(a={key:e,shown:Io(s.shown,t)}),a!==s&&o(a),{hash:a.shown.hash,changed:a.shown.hash!==a.shown.latest,reviewAgain:()=>o({key:e,shown:Io(void 0,t)})}}const YN={suggested:"Suggested by an agent. Not delivered to agents until you confirm it or keep it as an assumption.",confirmed:"Confirmed: agents treat it as a fact.",assumption:"Kept as an assumption: agents get it, marked as unverified.",outdated:"Outdated: kept for history, never delivered."};function JN({e}){const t=ai(),[s,o]=y.useState(!1),[a,l]=y.useState(e.title),[d,h]=y.useState(e.body);y.useEffect(()=>{o(!1),l(e.title),h(e.body)},[e.id,e.title,e.body]);const f=t.stale[e.id],p=Sa(e.id,t.hashes[e.id]);return i.jsxs("div",{className:"kn-detail",children:[i.jsx(V,{parts:[{text:e.id,code:!0},e.kind.replace("-"," "),e.status]}),s?i.jsxs(i.Fragment,{children:[i.jsx(Ze,{label:"Title",children:i.jsx("input",{value:a,onChange:v=>l(v.target.value)})}),i.jsx(Ze,{label:"Body",children:i.jsx("textarea",{rows:8,value:d,onChange:v=>h(v.target.value)})})]}):i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"t-title",children:e.title}),i.jsx("p",{className:"kn-body",children:e.body})]}),i.jsx("p",{className:"dim",children:YN[e.status]}),e.flag&&i.jsxs("p",{className:"kn-warn",children:["Flagged by ",e.flag.by,": ",e.flag.reason]}),f&&e.status!=="outdated"&&i.jsxs("p",{className:"kn-warn",children:["May be outdated: ",f.join(", ")," changed since it was confirmed. Re-confirm or edit it."]}),i.jsxs("dl",{className:"facts",children:[e.scope.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Applies to"}),i.jsx("dd",{children:e.scope.join(", ")})]}),e.tags.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Tags"}),i.jsx("dd",{children:e.tags.join(", ")})]}),i.jsx("dt",{children:"From"}),i.jsx("dd",{children:[e.createdBy,...e.sources].join(" · ")}),e.anchors.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"About files"}),i.jsx("dd",{children:e.anchors.map(v=>v.path).join(", ")})]})]}),p.changed&&i.jsx(ya,{what:"This entry",onReviewAgain:p.reviewAgain}),t.error&&i.jsx("p",{className:"vf-err",children:t.error}),i.jsx("div",{className:"actions",children:s?i.jsxs(i.Fragment,{children:[i.jsx(M,{variant:"ghost",onClick:()=>o(!1),children:"Cancel"}),i.jsx(M,{variant:"primary",disabled:!a.trim(),onClick:()=>void t.call(e.id,{kind:"edit",title:a,body:d}).then(v=>v&&o(!1)),children:"Save"})]}):i.jsxs(i.Fragment,{children:[(e.status!=="confirmed"||f)&&i.jsx(M,{variant:"primary",disabled:p.changed,onClick:()=>void t.call(e.id,{kind:"confirm"},p.hash),children:e.status==="confirmed"?"Re-confirm":"Confirm"}),e.status!=="assumption"&&e.status!=="outdated"&&i.jsx(M,{disabled:p.changed,onClick:()=>void t.call(e.id,{kind:"assumption"},p.hash),children:"Keep as assumption"}),e.flag&&i.jsx(M,{onClick:()=>void t.call(e.id,{kind:"resolve-flag"}),children:"Resolve flag"}),i.jsx(M,{variant:"ghost",onClick:()=>o(!0),children:"Edit"}),e.status!=="outdated"&&i.jsx(M,{variant:"ghost",onClick:()=>void t.call(e.id,{kind:"outdated"}),children:"Mark outdated"})]})})]})}const XN={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function ZN(){const e=ai(),[t,s]=y.useState("review"),[o,a]=y.useState(""),[l,d]=y.useState(""),[h,f]=y.useState();y.useEffect(()=>{if(!e.open)return;const S=I=>I.key==="Escape"&&e.setOpen(!1);return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[e]);const p=S=>S.status==="suggested"||!!S.flag||!!e.stale[S.id]&&S.status!=="outdated",v=(S,I)=>I==="all"?!0:I==="review"?p(S):S.status===I,k=y.useMemo(()=>{const S=l.trim().toLowerCase();return e.entries.filter(I=>v(I,t)&&(!o||I.kind===o)&&(!S||`${I.id} ${I.title} ${I.body} ${I.tags.join(" ")}`.toLowerCase().includes(S)))},[e.entries,e.stale,t,o,l]);if(!e.open)return null;const w=k.find(S=>S.id===h)??k[0],j=S=>e.entries.filter(I=>v(I,S)).length,N=[["review","Needs you"],["confirmed","Confirmed"],["assumption","Assumptions"],["outdated","Outdated"],["all","All"]];return i.jsx("div",{className:"scrim",onClick:()=>e.setOpen(!1),children:i.jsxs(Be,{as:"div",className:"dialog knowledge-view",onClick:S=>S.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Field guide"}),i.jsx(ii,{text:"What agents need to know about this codebase and product. Agents propose entries; only confirmed ones and assumptions reach them, picked for each ticket with the reason. Entries about files are flagged here when those files change. Seed it from a document with: teamtrail knowledge import <file.md>"})]}),i.jsxs("div",{className:"kn-filters",children:[N.map(([S,I])=>i.jsxs("button",{className:`chip ${t===S?"on":""}`,onClick:()=>s(S),children:[I," ",i.jsx("span",{className:"n",children:j(S)})]},S)),i.jsx(at,{compact:!0,"aria-label":"Kind",value:o,onChange:a,options:[{value:"",label:"Any kind"},...zj.map(S=>({value:S,label:S.replace("-"," ")}))]}),i.jsx("input",{className:"kn-search",placeholder:"Search",value:l,onChange:S=>d(S.target.value)})]}),i.jsxs("div",{className:"kn-body-grid",children:[i.jsx("ul",{className:"kn-list",children:k.length?k.map(S=>i.jsx(be,{as:"li",className:`kn-row st-${S.status}`,edge:p(S)?"attention":"neutral",selected:S===w,onOpen:()=>f(S.id),title:S.title,titleText:S.title,context:i.jsx(V,{parts:[{text:S.id,code:!0},S.kind.replace("-"," "),p(S)&&S.status!=="suggested"?"Needs a check":XN[S.status]]})},S.id)):i.jsx(Ie,{children:t==="review"?"Nothing needs you":"No entries"})}),w?i.jsx(JN,{e:w}):i.jsx(Ie,{children:"Pick an entry"})]})]})})}function Ud({draft:e,label:t="Save as knowledge"}){const s=ai(),[o,a]=y.useState();return o?i.jsxs(M,{size:"sm",variant:"ghost",onClick:()=>s.setOpen(!0),"data-tip":"Open it in the field guide to confirm it",children:["Saved as ",o]}):i.jsx(M,{size:"sm",variant:"ghost","data-tip":"Add it to the field guide as a suggestion; confirm it there and agents get it with related work",onClick:()=>void s.propose(e()).then(l=>l&&a(l.id)),children:t})}const eb=e=>{try{return JSON.parse(e)}catch{return}};function iv(e){const t=ni();let s=!1;const o=()=>{const h=t.start();e.load().then(f=>!s&&h()&&e.show(f),()=>{var f;return!s&&h()&&((f=e.failed)==null?void 0:f.call(e))})},{changed:a,events:l={}}=e,d=[vs(o),...a?[Pd(h=>a(h)&&o())]:[],...Object.entries(l).map(([h,f])=>si(h,p=>f(eb(p))&&o()))];return o(),{reload:o,pushed:()=>t.pushed(),stop:()=>{s=!0;for(const h of d)h()}}}function Ye(e){const t=y.useRef(e);t.current=e;const s=y.useRef(),o=y.useRef(e.version),{view:a,version:l}=e;y.useEffect(()=>{const f=t.current;o.current=f.version;const p=Object.keys(f.events??{}),v=iv({load:()=>t.current.load(),show:k=>t.current.show(k),failed:()=>{var k,w;return(w=(k=t.current).failed)==null?void 0:w.call(k)},...f.changed?{changed:k=>{var w,j;return((j=(w=t.current).changed)==null?void 0:j.call(w,k))===!0}}:{},events:Object.fromEntries(p.map(k=>[k,w=>{var j,N;return((N=(j=t.current.events)==null?void 0:j[k])==null?void 0:N.call(j,w))===!0}]))});return s.current=v,()=>{v.stop(),s.current=void 0}},[a]),y.useEffect(()=>{var f;Object.is(o.current,l)||(o.current=l,(f=s.current)==null||f.reload())},[l]);const d=y.useCallback(()=>{var f;return(f=s.current)==null?void 0:f.reload()},[]),h=y.useCallback(()=>{var f;return(f=s.current)==null?void 0:f.pushed()},[]);return{reload:d,pushed:h}}const rv=`${pe()}/knowledge`;async function Fm(e,t){const s=await fetch(`${rv}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await s.json().catch(()=>({}));if(!s.ok)throw new Error(o.error??`HTTP ${s.status}`);return o}async function tb(){const e=await fetch(rv);return e.ok?await e.json():null}function nb(e){const[t,s]=y.useState([]),[o,a]=y.useState({}),[l,d]=y.useState({}),[h,f]=y.useState(!1),[p,v]=y.useState(),{reload:k}=Ye({load:tb,show:j=>{j&&(s(j.entries),a(j.stale),d(j.hashes??{}))},changed:j=>j.startsWith("knowledge/")}),w=y.useMemo(()=>t.filter(j=>j.status==="suggested"||j.flag||o[j.id]&&j.status!=="outdated").length,[t,o]);return{entries:t,stale:o,briefText:e,attention:w,open:h,setOpen:f,error:p,hashes:l,call:(j,N,S)=>Fm("/call",{id:j,call:N,hash:S??l[j]}).then(()=>(v(void 0),k(),!0),I=>(v(I.message),k(),!1)),propose:j=>Fm("/propose",j).then(N=>(k(),N.entry),N=>(v(N.message),void 0))}}const sb=["awaiting","blocked","trail.done","resolved"];async function qn(e,t="GET",s){const o=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:s===void 0?void 0:JSON.stringify(s)}),a=await o.json().catch(()=>({}));if(!o.ok&&!a.status)throw new Error(a.error??`request failed (${o.status})`);return a}function ib(e){const t=`${e}/slack`;return{get:()=>qn(t),connectStart:s=>qn(`${t}/connect/start`,"POST",{project:s}),connectPreview:s=>qn(`${t}/connect/preview`,"POST",{code:s}),connectFinish:s=>qn(`${t}/connect/finish`,"POST",{code:s}),connectCancel:()=>qn(`${t}/connect/cancel`,"POST",{}),disconnect:()=>qn(`${t}/connect`,"DELETE"),update:s=>qn(`${t}/settings`,"PUT",s),members:()=>qn(`${t}/members`).then(s=>s.members)}}const jn=ib(pe());function rb(e){const{who:t}=e;return i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"sl-lead",children:["Connect as ",i.jsxs("b",{children:["@",t.user.name??t.user.id]})," in ",i.jsx("b",{children:t.workspace.name}),"? That Slack account becomes Scout's owner for this Teamtrail: questions and approvals reach it."]}),i.jsxs("div",{className:"c-actions",children:[i.jsx(M,{size:"sm",variant:"primary",onClick:e.onConnect,children:"Connect"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]})]})}const ob=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function ab({problem:e}){const t=e.failures===1?"A message was":`${e.failures} messages were`;return i.jsxs("div",{className:"test-line warn",title:e.code,children:[t," not delivered (last ",ob(e.at),"). ",e.message]})}function ud(e){const[t,s]=y.useState(!1),o=()=>{s(!0),jn.connectStart(ur()).then(a=>location.assign(a.url),a=>{s(!1),e.onError(a.message)})};return i.jsx(M,{size:"sm",variant:"primary",disabled:t,onClick:o,children:e.again?"Add Scout to Slack again":"Add Scout to Slack"})}function lb(e){return i.jsxs("div",{className:"test-line mentions-hint",children:[i.jsx("span",{children:"Reconnect to allow @Scout mentions: Slack needs one more permission for them."}),i.jsx(ud,{again:!0,onError:e.onError})]})}function cb({s:e,connecting:t}){return t?i.jsx("p",{className:"sl-lead",children:"Connecting Scout…"}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"sl-lead",children:"Answer agents, approve finished work and save threads as decisions from Slack. Scout is Teamtrail's Slack app: add it to your workspace and it talks to you about this machine's trails. Questions and answers pass through Teamtrail's Scout service; your trails, decisions and approvals stay here."}),e.legacy&&i.jsx("p",{className:"sl-lead",children:"You made your own Slack app with an earlier version. Scout is now one app, so add it again: your old app's tokens are deleted from this machine when you do."})]})}function db(e){return i.jsx("a",{className:["btn",e.primary&&"primary",e.small&&"sm"].filter(Boolean).join(" "),href:Nn(e.href,["slack:"]),target:"_blank",rel:"noreferrer",onClick:e.onClick,children:e.children})}function Um({onRemoved:e}){const[t,s]=y.useState(!1);if(!t)return i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>s(!0),children:"Disconnect"});const o=()=>void jn.disconnect().then(a=>{s(!1),e(a)},()=>{});return i.jsxs(i.Fragment,{children:[i.jsx(M,{size:"sm",variant:"danger",onClick:o,children:"Disconnect and forget Slack settings"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]})}function ub(e){const{s:t}=e,s=t.state==="auth-error"||t.state==="other-service";return t.connected?i.jsxs("div",{className:"c-actions",children:[s?i.jsx(ud,{again:!0,onError:e.onError}):i.jsx(M,{size:"sm",on:t.enabled,onClick:e.onToggle,children:t.enabled?"Turn off":"Turn on"}),t.links.homeWeb&&i.jsx(db,{small:!0,href:t.links.homeWeb,children:"Open Scout in Slack"}),i.jsx(Um,{onRemoved:e.onChanged})]}):i.jsxs("div",{className:"c-actions",children:[!e.busy&&i.jsx(ud,{again:t.legacy,onError:e.onError}),t.legacy&&i.jsx(Um,{onRemoved:e.onChanged})]})}const hb={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function fb({s:e}){const[t,s]=mb(e);return i.jsxs("div",{className:`sync-line ${t}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:s})]})}function mb(e){switch(e.state){case"online":return["ok","Online"];case"connecting":return["","Connecting"];case"offline":return["warn","Offline · reconnecting"];case"auth-error":return["alert",`Disconnected · ${e.error??"add Scout to Slack again"}`];case"elsewhere":{const t=e.heldBy?` (${e.heldBy})`:"";return["warn",`Connected from another ${Z.slug}${t}`]}case"other-service":return["alert","Not connected · this Teamtrail points at another Scout service"];case"unsupported":return["alert",e.error??"Not supported here"];default:return["",e.connected?"Off":"Not connected"]}}function pb(e){const{s:t,back:s}=e,o=!!s.confirm&&!t.connected;return i.jsxs(un,{className:vb(t),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:"Scout in Slack"}),t.connected&&i.jsx(bn,{className:t.enabled?"on":"",children:t.enabled?"On":"Off"})]}),t.connected&&i.jsx("div",{className:"c-loc",children:gb(t)}),t.connected&&i.jsx(fb,{s:t}),t.connected&&i.jsx("div",{className:"t-meta",children:"Scout answers in Slack only while this Teamtrail is running."}),t.delivery&&i.jsx(ab,{problem:t.delivery}),t.connected&&t.mentions===!1&&!o&&i.jsx(lb,{onError:e.onError}),!t.connected&&!o&&i.jsx(cb,{s:t,connecting:s.busy}),o&&i.jsx(rb,{who:s.confirm,onConnect:s.connect,onCancel:s.cancel}),e.error&&i.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]}),!o&&i.jsx(ub,{s:t,busy:s.busy,onError:e.onError,onChanged:e.onChanged,onToggle:e.onToggle})]})}function gb(e){var s,o,a;const t=(o=(s=e.workspace)==null?void 0:s.url)==null?void 0:o.replace(/^https?:\/\/|\/$/g,"");return[(a=e.workspace)==null?void 0:a.name,t].filter(Boolean).join(" · ")}function vb(e){const t=e.connected&&e.enabled?"active":"",s=e.connected?"":"open";return`connector ${t} ${s}`}function kb(e){const[t,s]=y.useState(e.value==="dm"?"":e.value),o=/^[CG][A-Z0-9]{6,}$/.test(t.trim());return i.jsxs("form",{className:"sl-field",onSubmit:a=>{a.preventDefault(),o&&e.onSave(t.trim())},children:[i.jsx("input",{value:t,spellCheck:!1,placeholder:"Channel ID, e.g. C0123ABCD","aria-label":"Channel ID",onChange:a=>s(a.target.value)}),i.jsx(M,{type:"submit",disabled:!o||t.trim()===e.value,children:"Save"})]})}function yb(e){const[t,s]=y.useState(),[o,a]=y.useState();y.useEffect(()=>{jn.members().then(s,h=>a(h.message))},[]);const l=new Set(e.owners.map(h=>h.id)),d=new Set(e.value.map(h=>h.id));return o?i.jsxs("div",{className:"test-line alert",children:["✕ ",o]}):t?i.jsx("div",{className:"choice-row compact sl-members",children:t.map(h=>i.jsx(ot,{on:l.has(h.id)||d.has(h.id),disabled:l.has(h.id),title:`@${h.name??h.id}`,sub:l.has(h.id)?"Owner":void 0,onClick:()=>e.onChange(d.has(h.id)?e.value.filter(f=>f.id!==h.id):[...e.value,h])},h.id))}):i.jsx("span",{className:"t-meta",children:"Loading members…"})}function wb(e){const{s:t,patch:s}=e,[o,a]=y.useState(!1),l=new Set(t.notify.events),d=o||t.notify.target!=="dm",h=t.owners[0],f=p=>{const v=l.has(p)?t.notify.events.filter(k=>k!==p):[...t.notify.events,p];s({notify:{events:v}})};return i.jsxs("div",{className:"sl-groups",children:[i.jsxs("div",{className:"sl-group",children:[i.jsx(ze,{variant:"plain",size:"sm",children:"Owner"}),i.jsxs("div",{className:"sl-owner",children:[i.jsxs("b",{children:["@",(h==null?void 0:h.name)??(h==null?void 0:h.id)]}),i.jsx("span",{className:"t-meta",children:"Added Scout from this machine"})]})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(ze,{variant:"plain",size:"sm",children:"Allowed users"}),i.jsx(yb,{value:t.allow,owners:t.owners,onChange:p=>s({allow:p})},t.state)]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(ze,{variant:"plain",size:"sm",children:"Notify"}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ot,{on:!d,title:"DM to owner",onClick:()=>{a(!1),s({notify:{target:"dm",detail:"full"}})}}),i.jsx(ot,{on:d,title:"Channel",sub:t.notify.target!=="dm"?t.notify.target:void 0,onClick:()=>a(!0)})]}),d&&i.jsxs(i.Fragment,{children:[i.jsx(Ze,{label:"Channel ID (invite @Scout there first)",children:i.jsx(kb,{value:t.notify.target,onSave:p=>s({notify:{target:p}})})}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ot,{on:t.notify.detail==="full",title:"Full questions",onClick:()=>s({notify:{detail:"full"}})}),i.jsx(ot,{on:t.notify.detail==="titles-only",title:"Titles only",onClick:()=>s({notify:{detail:"titles-only"}})})]})]}),i.jsx("div",{className:"choice-row compact",children:sb.map(p=>i.jsx(ot,{on:l.has(p),title:hb[p],onClick:()=>f(p)},p))})]}),i.jsx(dd,{className:"dim",parts:[`${t.command} decide`,`${t.command} status`,`${t.command} inbox`,"Save as decision on any message"]})]})}function xb(){if(typeof location>"u")return;const e=/(?:^#|&)slack-link=([A-Za-z0-9_-]{43})/.exec(location.hash);if(e)return history.replaceState(null,"",`${location.pathname}${location.search}`),e[1]}const Pc={code:xb()};function jb(e){const[t,s]=y.useState(),[o,a]=y.useState(),[l,d]=y.useState(),[h,f]=y.useState(!!Pc.code),p=k=>d(k.message);y.useEffect(()=>{const k=Pc.code;k&&(Pc.code=void 0,s(k),jn.connectPreview(k).then(a,p).finally(()=>f(!1)))},[]);const v=k=>{f(!0),a(void 0),k.then(e,p).finally(()=>f(!1))};return{busy:h,error:l,confirm:o,connect:()=>t&&v(jn.connectFinish(t)),cancel:()=>v(jn.connectCancel())}}function Wd(e=0){const[t,s]=y.useState(),o=y.useCallback(()=>jn.get().then(s,()=>s(null)),[]);return y.useEffect(()=>{if(o(),!e)return;const a=setInterval(()=>void o(),e);return()=>clearInterval(a)},[o,e]),[t,s]}function Sb(e){const[t,s]=Wd(3e3),o=jb(s),[a,l]=y.useState(),d=y.useRef(null);if(y.useEffect(()=>{var f;e.focus&&t&&((f=d.current)==null||f.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const h=f=>jn.update(f).then(s,()=>{});return i.jsxs("div",{ref:d,className:"slack-settings",children:[i.jsx(pb,{s:t,back:o,error:a??o.error,onError:l,onToggle:()=>void h({enabled:!t.enabled}),onChanged:f=>{l(void 0),s(f)}}),t.connected&&i.jsx(wb,{s:t,patch:f=>void h(f)})]})}function Nb(e){if(e.legacy&&!e.connected)return{label:"Add Scout to Slack again",why:"Scout is now one Slack app; your own app no longer works"};if(e.connected&&e.state==="auth-error")return{label:"Slack disconnected",why:e.error??"Add Scout again"}}let Wm;function bb(){return Wm??(Wm=jn.get().then(e=>({owners:e.owners??[],allow:e.allow??[]}),()=>{})),Wm}function li(){const[e,t]=y.useState();return y.useEffect(()=>{let s=!0;return bb().then(o=>s&&t(o)),()=>{s=!1}},[]),e}function $b(e){const{api:t,rt:s,brief:o}=e,{snap:a,actions:l}=t,[d]=Wd(15e3),h=ai(),f=d?Nb(d):void 0;return i.jsx(qN,{repo:e.repo,snaps:t.allSnaps,map:a==null?void 0:a.map,activity:t.activity,health:t.health,onNewTrail:e.onNewTrail,onStartOver:e.onStartOver,onArchive:l.setArchived,trackerLabel:s.adapter.label.toLowerCase(),onSelectMap:l.selectMap,onToggleMode:()=>a&&l.setMode(a.map.mode==="plan-only"?"plan+execute":"plan-only"),onSettings:e.onSettings,onToggleTheme:e.onToggleTheme,attention:e.attention,slackAlert:f,onSlack:e.onSlack,decisions:t.decisions.length,decisionsOpen:e.decisionsOpen,onDecisions:e.onDecisions,onStats:e.onStats,knowledge:h.attention,knowledgeOpen:h.open,onKnowledge:()=>h.setOpen(!h.open),briefingOpen:o.shown,briefingStatus:o.status,onBriefing:()=>o.shown?o.dismiss():o.open()})}const Cb="This is a high-risk call: only an owner, or someone they allowed to make high-risk calls, can make it. It waits for them.",ov=()=>{var e;return((e=ft())==null?void 0:e.highRisk)===!1};function Tb(e){var t;return(t=e.options)!=null&&t.length?i.jsx("div",{className:"suggest",children:e.options.map(s=>i.jsx("button",{className:"chip",onClick:()=>e.onPick(s),children:s},s))}):null}function Eb(e){const{pending:t}=e;return t!=null&&t.lookoutOnly&&ov()?i.jsx("p",{className:"vf-intro",children:Cb}):i.jsxs(i.Fragment,{children:[i.jsx(Tb,{options:t==null?void 0:t.suggestions,onPick:e.onSend}),i.jsx(wa,{ref:e.inputRef,className:"comms-input",value:e.draft,onValueChange:e.onDraft,onSubmit:e.onSend,disabled:!t,placeholder:t?"Answer":""})]})}function Ab(e){const{m:t}=e,s=li(),o=t.from==="human"?"human":"agent";return i.jsxs("div",{className:`msg from-${t.from} voice-${o}`,children:[i.jsx(V,{parts:[ps(t.author,s),Nx(t),ha(t.at)]}),i.jsx("div",{className:"msg-text",children:t.text}),e.stillOpen&&i.jsx("button",{className:"answer-this t-meta",onClick:e.onAnswerThis,children:"Answer this"})]})}function Ib(e){const{ticket:t}=e;return i.jsxs("div",{className:"comms-ticket",children:[i.jsxs("div",{className:"t-title",title:t&&`${t.key} ${t.title}`,children:[i.jsx("span",{className:"key",children:t==null?void 0:t.key})," ",t==null?void 0:t.title]}),i.jsx(V,{parts:[e.trail,e.agent]})]})}function Rb({id:e,text:t}){const[s,o]=y.useState(),a=s!==e;return i.jsx(ua,{size:.6,framed:!1,state:a?"speaking":"alert",speaking:a?t.slice(0,60):void 0,onSpeakEnd:()=>o(e),className:"q-avatar"})}function Mb(e){const{q:t}=e;return i.jsxs("div",{className:"msg open-q",children:[i.jsx(V,{parts:[t.agent,ha(t.at)]}),i.jsx(Rb,{id:e.chatId??t.id,text:t.text}),i.jsx("div",{className:"msg-text",children:t.text}),t.stakes&&i.jsx(V,{parts:[{text:t.stakes,strong:!0}]}),t.precedent&&i.jsx(V,{className:"open-q-precedent",parts:[t.precedent]})]})}function Lb(e){const{activity:t,sessionId:s}=e,[o,a]=y.useState(""),[l,d]=y.useState(),h=y.useRef(null),f=y.useRef(null),p=t.sessions.find(O=>O.id===s),v=t.chats.filter(O=>O.sessionId===s),k=sN(t.pending,s,l??e.questionId),w=new Set(t.pending.filter(O=>O.sessionId===s).map(O=>O.id)),j=v.find(O=>!!k&&O.questionId===k.id),N=v.filter(O=>O!==j),S=p?e.snaps[p.mapId]:void 0,I=p!=null&&p.ticketId?S==null?void 0:S.tickets.find(O=>O.id===p.ticketId):void 0;y.useEffect(()=>{const O=h.current;O==null||O.scrollTo({top:O.scrollHeight,behavior:"smooth"})},[N.length,k==null?void 0:k.id]),y.useEffect(()=>{var O;k&&!e.onBack&&((O=f.current)==null||O.focus({preventScroll:!0}))},[k==null?void 0:k.id,e.onBack]);const $=O=>{!k||!O.trim()||(e.onAnswer(k.id,O.trim()),a(""))},_=Ob(p,!!k);return i.jsxs("div",{className:`comms ${k?"asking":""}`,children:[i.jsx(Et,{title:"HITL line",right:p?i.jsx("span",{className:`status ${k?"urgent":""}`,children:_}):void 0,children:e.onBack&&i.jsx("button",{className:"back",onClick:e.onBack,"aria-label":"Back to inbox",children:"‹ Inbox"})}),p?i.jsxs(i.Fragment,{children:[i.jsx(Ib,{ticket:I,trail:S==null?void 0:S.map.title,agent:p.agent}),i.jsx("div",{className:"comms-log",ref:h,children:N.map(O=>i.jsx(Ab,{m:O,stillOpen:!!O.questionId&&w.has(O.questionId),onAnswerThis:()=>d(O.questionId)},O.id))}),k&&i.jsx(Mb,{q:k,chatId:j==null?void 0:j.id}),i.jsx(Eb,{pending:k,draft:o,onDraft:a,onSend:$,inputRef:f})]}):i.jsx(Ie,{children:"No conversation"})]})}function Ob(e,t){return e?t?"Your answer is needed":dn(e)?`${e.agent} is working…`:e.status==="done"?"Resolved · ticket closed":"Session ended":""}async function Pb(e){const[t,s]=e.ref.split("+"),o=await fetch(`${pe()}/workspaces/integration`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,a:t,b:s})});return o.ok?void 0:(await o.json().catch(()=>({}))).error??`Adding failed (${o.status})`}function _b({item:e}){const[t,s]=y.useState(!1),[o,a]=y.useState(),l=()=>{s(!0),a(void 0),Pb(e).then(a,d=>a(d.message)).finally(()=>s(!1))};return i.jsxs("div",{className:"att-action",children:[i.jsx(M,{size:"sm",className:"integration-add",disabled:t,onClick:l,children:t?"Adding…":"Add integration ticket"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}async function Db(e,t){const s=e.ref.slice(0,e.ref.lastIndexOf(":")),o=await fetch(`${pe()}/trackers/settings/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,issueId:s,choice:t})});return o.ok?void 0:(await o.json().catch(()=>({}))).error??`Saving failed (${o.status})`}function zb({item:e}){const[t,s]=y.useState(!1),[o,a]=y.useState(),l=d=>{s(!0),a(void 0),Db(e,d).then(a,h=>a(h.message)).finally(()=>s(!1))};return i.jsxs("div",{className:"att-action",children:[i.jsx(M,{size:"sm",disabled:t,onClick:()=>l("stricter"),children:"Keep stricter"}),i.jsx(M,{size:"sm",disabled:t,onClick:()=>l("as-is"),children:"Accept as is"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function Bb({item:e}){return e.kind==="integration"?i.jsx(_b,{item:e}):e.kind==="tracker-settings"&&e.ref.includes(":")?i.jsx(zb,{item:e}):null}const Fb=/(\S*\/\S*|#\d+)/g;function Ub({reasons:e}){return e.length?i.jsx("span",{className:"reason-line",children:e.map((t,s)=>i.jsxs("span",{children:[s>0&&i.jsx("span",{className:"sep",children:" · "}),t.split(Fb).map((o,a)=>a%2===1?i.jsx("span",{className:"t-code",children:o},a):o)]},t))}):null}const av={question:"Question",approval:"Approve",blocked:"Blocked",flag:"PR / CI",stalled:"Stalled","hitl-ready":"Needs you",knowledge:"Field guide",brief:"Brief",policy:"Risk",reroute:"Reroute","reroute-suggested":"Reroute?",overlap:"Overlap",integration:"Integrate",guide:"Guide","guide-checks":"Approve",trust:"Approve",model:"Model",delivery:"Delivery","tracker-settings":"Settings",precedent:"Precedent","review-limit":"Review"},Wb={question:"questions",approval:"approvals",blocked:"blocked tickets",flag:"PR / CI flags",stalled:"stalled claims","hitl-ready":"tickets for you",knowledge:"field guide entries",brief:"briefs",policy:"risky changes",reroute:"reroutes","reroute-suggested":"suggested reroutes",overlap:"overlapping claims",integration:"clashing branches",guide:"guides to approve","guide-checks":"guide checks to approve",trust:"things to approve on this machine",model:"tickets waiting for a model",delivery:"connectors not delivering","tracker-settings":"settings changed in the tracker",precedent:"changes to what you decided","review-limit":"review queues full"},Hb=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],Kb=["blocked","flag","stalled","policy","reroute","overlap","integration","model"];function lv(e,t){return t||e.urgency==="blocking"?"urgent":Kb.includes(e.kind)?"attention":"neutral"}const Vb=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function cv(e){return e.reasons.filter(t=>!Vb.some(s=>s.test(t)))}function Gb(e){const{item:t,snap:s}=e,o=s==null?void 0:s.tickets.find(h=>h.id===t.ticketId),a=t.kind==="question"&&t.agent?`${t.agent} asks`:av[t.kind],l=[];t.urgency==="blocking"&&l.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),l.push({text:a,strong:!0});const d=o&&qb(t.title,o);return d&&l.push(d),e.otherTrail&&l.push((s==null?void 0:s.map.title)??t.mapId),l}function qb(e,t){if(!e.includes(t.key))return e.includes(t.title)?{text:t.key,code:!0}:`${t.key} ${t.title}`}function Qb(e){const[t,s]=y.useState(!1),o=a=>{s(!1),a()};return i.jsxs("span",{className:"snooze",children:[i.jsx("button",{type:"button",className:"snooze-btn","aria-expanded":t,"aria-label":`Later: ${e.title}`,onClick:()=>s(!t),children:"Later"}),t&&i.jsxs("span",{className:"snooze-menu",role:"menu",children:[Hb.map(a=>i.jsx("button",{type:"button",role:"menuitem",onClick:()=>o(()=>e.onSnooze(a.minutes)),children:a.label},a.minutes)),e.canDismiss&&i.jsx("button",{type:"button",role:"menuitem",onClick:()=>o(e.onDismiss),children:"Set aside"})]})]})}const Yb=15e3;function Jb(e){const{item:t}=e,s=t.title.split(`
|
|
142
142
|
`)[0],o=cv(t),a=e.now-t.since<Yb;return i.jsx(be,{as:"li",className:`att-item k-${t.kind} u-${t.urgency} ${e.selected?"sel":""} ${a?"incoming":""}`,edge:lv(t,e.interrupting),selected:e.selected,title:s,titleText:t.title,context:i.jsx(V,{parts:Gb({item:t,snap:e.snap,otherTrail:e.otherTrail})}),detail:o.length>0&&i.jsx(Ub,{reasons:o}),detailText:o.join(`
|
|
143
|
-
`),trailing:hn(e.now-t.since),onOpen:e.onOpen,actions:i.jsx(Qb,{title:t.title,canDismiss:Jj(t),onSnooze:e.onSnooze,onDismiss:e.onDismiss}),below:i.jsx(Bb,{item:t})})}function Xb(e){const t=[];for(const s of e){const o=t.at(-1);(o==null?void 0:o.key)===s.batchKey?o.items.push(s):t.push({key:s.batchKey,kind:s.kind,mapId:s.mapId,items:[s]})}return t}const Zb={question:"inbox-list",approval:"inbox-list approvals"};function e$(e){const{batch:t}=e,s=t.items.length>1,o=t.kind==="question"?"answer together":"review together",a=[`${t.items.length} ${Wb[t.kind]}`,e.trail,o].filter(Boolean);return i.jsxs("div",{className:`att-batch ${s?"many":""}`,children:[s&&i.jsx("span",{className:"batch-head t-label",children:a.join(" · ")}),i.jsx("ul",{className:`att-list ${Zb[t.kind]??""}`,children:e.children})]})}function Hm(e,t){e.ticketId?t.openTicket(e.mapId,e.ticketId):t.selectTrail(e.mapId)}const t$=new Set(["approval","blocked","policy","precedent","flag","stalled","hitl-ready","overlap","integration","model","tracker-settings"]);function dv(e,t){if(t$.has(e.kind))return Hm(e,t);switch(e.kind){case"question":return t.openQuestion(e.ref);case"knowledge":return t.openKnowledge();case"brief":return t.openBrief(e.mapId);case"reroute":case"reroute-suggested":return t.openReroute(e);case"guide":case"guide-checks":return t.openGuides();case"delivery":return t.openConnector(e.ref);case"trust":return t.openApprovals();default:return Hm(e,t)}}function n$(e){const t=Xt(1e3),{view:s}=e;if(!s.items.length)return i.jsx(Sn,{title:"Nothing waiting on you",hint:s.hidden?`${s.hidden} snoozed or set aside. They come back when the snooze ends.`:"When an agent needs your call, it lands here, most important first."});const o=Object.keys(e.snaps).length>1,a=h=>o&&h!==e.currentMapId,l=new Set(s.interrupting),d=h=>{var f;return(f=e.pending.find(p=>p.id===h))==null?void 0:f.sessionId};return i.jsx("div",{className:"attention-queue",children:Xb(s.items).map(h=>{var f;return i.jsx(e$,{batch:h,trail:a(h.mapId)?(f=e.snaps[h.mapId])==null?void 0:f.map.title:void 0,children:h.items.map(p=>i.jsx(Jb,{item:p,snap:e.snaps[p.mapId],otherTrail:a(p.mapId)&&h.items.length<2,selected:p.kind==="question"&&d(p.ref)===e.selected,interrupting:l.has(p.id),now:t,onOpen:()=>dv(p,e.handlers),onSnooze:
|
|
144
|
-
`)[0];return i.jsx(be,{as:"li",className:s.sessionId===e.selected?"sel":void 0,edge:s.urgency==="blocking"?"urgent":"neutral",selected:s.sessionId===e.selected,title:d,titleText:s.text,context:i.jsx(V,{parts:[s.urgency==="blocking"&&{text:"Blocking",urgent:!0},`${s.agent} asks`,a&&{text:a.key,code:!0},a==null?void 0:a.title,l]}),trailing:hn(t-s.at),onOpen:()=>e.onOpen(s.sessionId,s.ticketId)},s.id)})}):i.jsx(Sn,{title:"Nothing waiting on you",hint:"When an agent needs your call, its question lands here."})}const g$={pass:"Passed",fail:"Failed",error:"Could not run",interrupted:"Interrupted"},ar={off:"Off",checks:"Checks","checks+review":"Checks + review","checks+review+human":"Checks + review + you"},fv={off:"The agent saying “done” closes the ticket right away.",checks:"Your checks (tests, lint, typecheck…) run in the repo first. A failure goes back to the agent with the output.","checks+review":"After the checks pass, a different agent reviews the change. It is never the agent that did the work.","checks+review+human":"After checks and review, you approve it in the inbox before the ticket closes."},v$=e=>e.exitCode===0&&!e.timedOut&&!e.error;async function Qm(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`HTTP ${e.status}`);return t}const Ro=`${pe()}/verification`,fr={ticket:(e,t)=>fetch(`${Ro}/ticket?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`).then(s=>s.ok?s.json():void 0,()=>{}),inbox:()=>fetch(`${Ro}/inbox`).then(e=>e.ok?e.json().then(t=>t.items):[],()=>[]),log:e=>fetch(`${Ro}/log?path=${encodeURIComponent(e)}`).then(t=>Qm(t)),act:e=>fetch(`${Ro}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>Qm(t))};function k$(e){const[t,s]=y.useState([]),o=Object.values(e).map(l=>l.tickets.map(d=>`${d.id}:${d.state}:${d.status??""}`).join()).join("|"),{reload:a}=Ye({version:o,load:fr.inbox,show:s});return y.useEffect(()=>ei.onEvidence(a),[a]),t}function y$(e,t){return{...e,items:e.items.filter(s=>!(s.kind==="brief"&&s.mapId===t))}}function w$(e){var h;const t=[...e.activity.pending].sort((f,p)=>f.at-p.at),s=k$(e.snaps),o=(h=e.attention)==null?void 0:h.view,a=o&&e.briefShown?y$(o,e.currentMapId):o,l=a?a.items.length:t.length+s.length,d=i.jsx(Et,{hot:l>0,title:i.jsxs(i.Fragment,{children:[l>0&&i.jsx(oi,{variant:"alert",size:12}),"Waiting on you"]}),count:i.jsx(fs,{n:l,urgent:l>0,pop:!0},l)});return a&&e.attention&&e.handlers?i.jsxs("div",{className:"inbox-part",children:[d,i.jsx(qm,{activity:e.activity}),i.jsx(n$,{view:a,snaps:e.snaps,pending:e.activity.pending,currentMapId:e.currentMapId,selected:e.sessionId,handlers:e.handlers,onSnooze:e.attention.snooze,onDismiss:e.attention.dismiss})]}):i.jsxs("div",{className:"inbox-part",children:[d,i.jsx(qm,{activity:e.activity}),i.jsx(m$,{items:s,snaps:e.snaps,currentMapId:e.currentMapId,onOpen:e.onOpenTicket}),(t.length>0||!s.length)&&i.jsx(p$,{items:t,snaps:e.snaps,currentMapId:e.currentMapId,selected:e.sessionId,onOpen:e.onOpenQuestion})]})}function x$(e){const[t,s]=y.useState("list"),[o,a]=y.useState();y.useEffect(()=>{e.convRequest&&s("conv")},[e.convRequest]);const l=(k
|
|
145
|
-
`))??""),_=[
|
|
146
|
-
`).map(D=>D.trim());o({title:k.trim(),destination:w.trim(),notes:N.trim(),assumptions:O.filter(Boolean)}).then(D=>l({key:D.key,id:D.id})).catch(D=>p(D.message)).finally(()=>h(!1))},children:"Create trail"})]})]})})}const I$=e=>({title:e.title,destination:e.sections.destination,notes:e.sections.notes,assumptions:(e.sections.assumptions??[]).filter(t=>t.status!=="invalidated").map(t=>t.text)});function R$(e){return i.jsx(A$,{seed:e.seed,onClose:e.onClose,tracker:e.rt.adapter.label,onCreate:async t=>{const s=await m1(e.rt.adapter,t);return e.onCreated(s.id),s}})}function M$(e,t){const[s,o]=y.useState(!1);return{open:()=>o(!0),startOver:d=>void t.actions.setArchived(!0).then(()=>o(I$(d))),dialog:s&&i.jsx(R$,{rt:e,seed:typeof s=="object"?s:void 0,onClose:()=>o(!1),onCreated:d=>t.actions.selectMap(d)})}}const L$={gh:"your gh login",GITHUB_TOKEN:"GITHUB_TOKEN",GH_TOKEN:"GH_TOKEN",stored:"a saved token","signed-in":"your GitHub sign-in",LINEAR_API_KEY:"LINEAR_API_KEY"},Hd=e=>L$[e];function Kd(e){var t;return((t=e.account)==null?void 0:t.kind)==="user"?e.account.login:void 0}const zc=e=>!!e.auth&&!!Kd(e);function mv(e,t){const s=Kd(e);return!e.auth||!s?void 0:`Will use ${t||"the repo you pick"} as ${s} (${Hd(e.auth)})`}function O$(e){if(!e.repo)return;const t=Kd(e),s=t?` as ${t}`:"",o=e.auth?`, using ${Hd(e.auth)}`:"";return`Connected to ${e.repo}${s}${o}`}function P$(e,t){if(!e.pushedAt)return;const s=Math.floor((t-Date.parse(e.pushedAt))/864e5);return s<1?"Pushed today":s<60?`Pushed ${s}d ago`:`Pushed ${Math.floor(s/30)}mo ago`}function _$(e){const{gh:t}=e;if(!t.auth)return null;const s=mv(t,e.repo);return i.jsxs("div",{className:"gh-identity",children:[s&&i.jsx("span",{className:"t-body",children:s}),i.jsxs("span",{className:"gh-identity-actions",children:[i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another token"}),t.auth==="signed-in"&&i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onSignOut,title:"Forgets the token on this machine. To revoke it, remove Teamtrail under GitHub → Settings → Applications.",children:"Sign out"})]})]})}const D$=/^[\w.-]+\/[\w.-]+$/;function z$(e){const t=e.query.trim().toLowerCase(),o=!!e.detected&&e.repos.every(f=>f.fullName!==e.detected)?[{fullName:e.detected,private:!1},...e.repos]:e.repos,a=[...o.filter(f=>f.fullName===e.detected),...o.filter(f=>f.fullName!==e.detected)],l=t?a.filter(f=>f.fullName.toLowerCase().includes(t)):a,h=D$.test(e.query.trim())&&l.every(f=>f.fullName.toLowerCase()!==t)?e.query.trim():void 0;return{shown:l.slice(0,e.limit),matches:l.length,typed:h}}function Ym(e){const{repo:t,listed:s}=e,o=t.private?"Private":"Public";return i.jsx(be,{as:"li",className:"repo-row",selected:e.selected,title:i.jsx("span",{className:"t-code",children:t.fullName}),context:i.jsx(V,{parts:[e.detected&&{text:"This project's repo",strong:!0},s&&o,s&&P$(t,e.now),!s&&"Checked when you connect"]}),onOpen:e.onPick})}const B$=40;function Jm(e){const[t,s]=y.useState(""),o=y.useMemo(()=>Date.now(),[]),a=y.useMemo(()=>new Set(e.repos.map(k=>k.fullName)),[e.repos]),{shown:l,matches:d,typed:h}=z$({repos:e.repos,detected:e.detected,query:t,limit:B$}),f=d>l.length?`${d-l.length} more: type to narrow`:"",p=e.truncated?`Your ${e.repos.length} most recently pushed repos`:"";return i.jsxs("div",{className:"repo-picker",children:[i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:t,placeholder:"Search your repos, or type owner/name",spellCheck:!1,"aria-label":"Search repositories",onChange:k=>s(k.target.value)})]}),i.jsxs("ul",{className:"repo-list","aria-label":"Repositories",children:[h&&i.jsx(Ym,{repo:{fullName:h,private:!1},detected:h===e.detected,listed:!1,selected:h===e.value,now:o,onPick:()=>e.onChange(h)}),l.map(k=>i.jsx(Ym,{repo:k,detected:k.fullName===e.detected,listed:a.has(k.fullName),selected:k.fullName===e.value,now:o,onPick:()=>e.onChange(k.fullName)},k.fullName))]}),i.jsx(V,{parts:[!d&&!h&&"No repo matches",f,p]})]})}function F$(e){const{list:t}=e;if(!t)return i.jsx(ri,{label:"Loading your repos…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(Jm,{repos:t.repos,truncated:t.truncated,detected:t.detectedRepo??e.detected,value:e.value,onChange:e.onChange});case"no-token":return i.jsx(V,{parts:["No GitHub token found"]});case"error":return i.jsxs(i.Fragment,{children:[i.jsx(zd,{what:"Couldn't list your repos",reason:t.error,onRetry:e.onRetry}),i.jsx(Jm,{repos:[],truncated:!1,detected:e.detected,value:e.value,onChange:e.onChange})]});default:return t}}const U$={stored:"Saved token",gh:"gh CLI",GITHUB_TOKEN:"$GITHUB_TOKEN",GH_TOKEN:"$GH_TOKEN","signed-in":"Signed in with GitHub",LINEAR_API_KEY:"$LINEAR_API_KEY"},nr=e=>e==="github"||e==="linear";function pv(e){const[t,s]=y.useState(!e.source);return e.source&&!t?i.jsxs("div",{className:"ts-auth",children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("span",{className:"pill on",children:U$[e.source]}),i.jsx("button",{type:"button",className:"btn ghost sm",onClick:()=>s(!0),children:"Use another"})]}):i.jsxs("label",{className:"field",children:[i.jsxs("span",{className:"ts-label",children:[e.label,e.link&&i.jsx("a",{href:e.link.href,target:"_blank",rel:"noreferrer",children:e.link.text})]}),i.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:e.value,placeholder:e.placeholder,onChange:o=>e.onChange(o.target.value)})]})}function W$(e){const[t,s]=y.useState(!1),o=()=>{var a;return void((a=navigator.clipboard)==null?void 0:a.writeText(e.code).then(()=>s(!0),()=>{}))};return i.jsxs("div",{className:"gh-device",children:[i.jsx("span",{className:"t-label",children:"Enter this code on GitHub"}),i.jsxs("div",{className:"gh-device-row",children:[i.jsx("code",{className:"gh-device-code t-code","aria-label":"Your code",children:e.code}),i.jsx(M,{size:"sm",variant:"ghost",onClick:o,children:t?"Copied":"Copy"})]}),i.jsxs("div",{className:"gh-device-row",children:[i.jsx("a",{className:"btn primary",href:Nn(e.href),target:"_blank",rel:"noreferrer",onClick:o,children:"Open GitHub"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]}),i.jsx(ri,{label:"Waiting for you to approve on GitHub…"})]})}function H$(e){switch(e.kind){case"code":return{kind:"code",userCode:e.userCode,verificationUri:e.verificationUri,interval:e.interval,asked:0};case"unavailable":return{kind:"ended",reason:"Sign in with GitHub isn’t set up in this build"};case"error":return{kind:"ended",reason:e.error};default:return e}}function K$(e,t){switch(t.kind){case"waiting":return{...e,interval:t.interval,asked:e.asked+1};case"signed-in":return{kind:"idle"};case"expired":return{kind:"ended",reason:"The code expired before it was approved"};case"denied":return{kind:"ended",reason:"The sign-in was declined on GitHub"};case"none":return{kind:"ended",reason:"The sign-in was stopped"};case"error":return{kind:"ended",reason:t.error};default:return t}}const Bt=A0(pe());function sr(e,t){e({tracker:t});const s=new URL(location.href);s.searchParams.delete("tracker"),location.href=s.toString()}function V$(e){const[t,s]=y.useState({kind:"idle"}),o=y.useRef(e);o.current=e;const a=t.kind==="code";return y.useEffect(()=>{if(t.kind!=="code")return;let l=!0;const d=setTimeout(()=>void Bt.githubSignIn.poll().then(async h=>{l&&(h.kind==="signed-in"&&await o.current(),l&&s(K$(t,h)))},h=>l&&s({kind:"ended",reason:h.message})),Math.max(t.interval,1)*1e3);return()=>{l=!1,clearTimeout(d)}},[t]),y.useEffect(()=>{if(a)return()=>void Bt.githubSignIn.cancel().catch(()=>{})},[a]),{state:t,start(){s({kind:"starting"}),Bt.githubSignIn.start().then(l=>s(H$(l)),l=>s({kind:"ended",reason:l.message}))},cancel(){s({kind:"idle"})}}}function G$(e){const{state:t,start:s,cancel:o}=V$(e.onSignedIn);switch(t.kind){case"idle":return i.jsxs("div",{className:"gh-sign-in",children:[i.jsx(M,{variant:"primary",onClick:s,children:"Sign in with GitHub"}),i.jsx(V,{parts:["No gh login or token needed","the token stays on this machine"]}),i.jsx(V,{parts:["GitHub asks for access to your repos: it has no narrower scope for issues in private repos"]})]});case"starting":return i.jsx(ri,{label:"Asking GitHub for a code…"});case"code":return i.jsx(W$,{code:t.userCode,href:t.verificationUri,onCancel:o});case"ended":return i.jsxs("div",{className:"gh-sign-in",children:[i.jsx(M,{onClick:s,children:"Try again"}),i.jsx(V,{parts:["Didn't sign in",t.reason]})]});default:return t}}function q$(e){var d,h;const{gh:t}=e,s=t.auth&&((d=t.account)==null?void 0:d.kind)==="unknown"?`Found ${Hd(t.auth)}, but GitHub didn't accept it`:"",o=((h=t.account)==null?void 0:h.kind)==="unknown"?t.account.error:"",a=t.auth==="GITHUB_TOKEN"||t.auth==="GH_TOKEN",l=t.signIn.available&&!a;return i.jsxs(i.Fragment,{children:[s&&i.jsx(V,{parts:[s,o]}),l&&i.jsx(G$,{onSignedIn:e.onSignedIn}),l&&i.jsx("span",{className:"t-label gh-or",children:"Or paste a token"}),i.jsx(pv,{source:null,value:e.token,onChange:e.onToken,label:"Token",placeholder:"ghp_… or github_pat_…",link:{href:"https://github.com/settings/personal-access-tokens/new",text:"New token"}}),i.jsxs("span",{className:"t-meta",children:["Or run ",i.jsx("code",{className:"t-code",children:"gh auth login"})," in a terminal; this finds it in a few seconds."]}),i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:e.repo,placeholder:"owner/name",spellCheck:!1,onChange:f=>e.onRepo(f.target.value.trim())})]})]})}function gv({r:e}){var o,a;if(!e)return null;if(!e.ok)return i.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]});const t=(o=e.rate)!=null&&o.limit?`${(a=e.rate.remaining)==null?void 0:a.toLocaleString()}/${e.rate.limit.toLocaleString()} req`:"";let s="";return e.canWrite===!1?s="read-only":e.canWrite&&(s="read/write"),i.jsxs("div",{className:"test-line ok",children:["✓ ",[e.account,e.target,s,t].filter(Boolean).join(" · ")]})}function Vd(e){const[t,s]=y.useState(),[o,a]=y.useState(0);y.useEffect(()=>{if(s(void 0),!e.enabled)return;let d=!0;return e.load().then(h=>d&&s(h),h=>d&&s(e.failed(h.message))),()=>{d=!1}},[e.enabled,e.key,o]);const l=y.useCallback(()=>a(d=>d+1),[]);return{value:t,retry:l}}function Q$(e){const{value:t,retry:s}=Vd({enabled:e.enabled,key:e.auth??"",load:()=>Bt.githubRepos(),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function vv(e){const t=e.s.github,s=zc(t),[o,a]=y.useState(!s),[l,d]=y.useState(t.repo??t.detectedRepo??""),[h,f]=y.useState(""),[p,k]=y.useState(),[v,w]=y.useState(!1),{list:j,retry:N}=Q$({enabled:!o,auth:t.auth});y.useEffect(()=>{s&&!h&&a(!1)},[s]);const S=async()=>{w(!0),k(void 0);try{await Bt.connect({active:"github",github:{repo:l,token:o?h:void 0}}),e.onConnected()}catch(D){k({ok:!1,error:D.message}),w(!1)}},I=async()=>{const D=await e.reload();D&&zc(D.github)&&a(!1)},$=async()=>{await Bt.githubSignIn.signOut().catch(()=>{});const D=await e.reload();a(!D||!zc(D.github))},O=!!l&&!(!o&&!j)&&(!o||!!h||s);return i.jsxs("div",{className:"card inset tracker-setup",children:[o?i.jsx(q$,{gh:t,token:h,onToken:f,repo:l,onRepo:d,onSignedIn:I}):i.jsxs(i.Fragment,{children:[i.jsx(_$,{gh:t,repo:l,onUseAnother:()=>a(!0),onSignOut:()=>void $()}),i.jsx(F$,{list:j,detected:t.detectedRepo,value:l,onChange:d,onRetry:N})]}),i.jsx(gv,{r:p}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:v||!O,onClick:()=>void S(),children:v?"Connecting…":"Connect"})})]})}function Y$(e){return e.line?i.jsxs("div",{className:"gh-identity",children:[i.jsxs("div",{className:"ln-who",children:[i.jsx("span",{className:"t-body",children:e.line}),e.email&&i.jsx(V,{parts:[e.email]})]}),e.onUseAnother&&i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another key"})]}):null}const J$={LINEAR_API_KEY:"LINEAR_API_KEY",stored:"a saved key"},Gd=e=>J$[e]??e;function ba(e){return(e==null?void 0:e.kind)==="user"?e:void 0}const X$=e=>!!e.auth&&!!ba(e.viewer);function kv(e,t){if(e)return t?`${e} / ${t}`:e}function yv(e){const t=ba(e.viewer);if(!t)return;const s=kv(e.team,e.project)??"the team you pick",o=e.source?` (${Gd(e.source)})`:"";return`Will use ${s} in ${t.orgName} as ${t.name}${o}`}function Z$(e){const t=kv(e.teamName??e.teamKey,e.projectName);if(!e.teamId||!t)return;const s=ba(e.viewer),o=e.orgName??(s==null?void 0:s.orgName),a=o?` in ${o}`:"",l=s?` as ${s.name}`:"",d=e.auth?`, using ${Gd(e.auth)}`:"";return`Connected to ${t}${a}${l}${d}`}function eC(e,t){if(!e.activeAt)return"No issues yet";const s=Math.floor((t-Date.parse(e.activeAt))/864e5);return s<1?"Active today":s<60?`Active ${s}d ago`:`Active ${Math.floor(s/30)}mo ago`}function tC(e){var a,l;const{ln:t}=e,s=t.auth&&((a=t.viewer)==null?void 0:a.kind)==="unknown"?`Found ${Gd(t.auth)}, but Linear didn't accept it`:"",o=((l=t.viewer)==null?void 0:l.kind)==="unknown"?t.viewer.error:"";return i.jsxs(i.Fragment,{children:[s&&i.jsx(V,{parts:[s,o]}),i.jsx(pv,{source:null,value:e.apiKey,onChange:e.onKey,label:"API key",placeholder:"lin_api_…",link:{href:"https://linear.app/settings/account/security",text:"New key"}}),i.jsxs("span",{className:"t-meta",children:["Or set ",i.jsx("code",{className:"t-code",children:"LINEAR_API_KEY"})," before starting Teamtrail."]})]})}function nC(e){const{list:t}=e;if(!t)return i.jsx(ri,{label:"Loading projects…"});if(t.kind==="error")return i.jsx(zd,{what:"Couldn't list the team's projects",reason:t.error,onRetry:e.onRetry});if(t.kind!=="ok"||!t.projects.length)return null;const s=[{value:"",label:"All projects"},...t.projects.map(o=>({value:o.id,label:o.state?`${o.name} · ${o.state}`:o.name}))];return i.jsxs("label",{className:"field",children:["Project (optional)",i.jsx(at,{"aria-label":"Project",value:e.value,onChange:e.onChange,options:s})]})}function sC(e){const t=e.query.trim().toLowerCase(),s=t?e.teams.filter(o=>o.key.toLowerCase().includes(t)||o.name.toLowerCase().includes(t)):e.teams;return{shown:s.slice(0,e.limit),matches:s.length}}function iC(e,t){return t&&e.some(s=>s.id===t)?t:e.length===1?e[0].id:void 0}function rC(e){const{team:t}=e;return i.jsx(be,{as:"li",className:"repo-row team-row",selected:e.selected,title:t.name,context:i.jsx(V,{parts:[{text:t.key,code:!0},eC(t,e.now)]}),onOpen:e.onPick})}const oC=40;function aC(e){const[t,s]=y.useState(""),o=y.useMemo(()=>Date.now(),[]),{shown:a,matches:l}=sC({teams:e.teams,query:t,limit:oC}),d=l>a.length?`${l-a.length} more: type to narrow`:"",h=e.truncated?`The first ${e.teams.length} teams`:"",f=e.value?"":"Pick the team your trails go in";return i.jsxs("div",{className:"repo-picker",children:[i.jsxs("label",{className:"field",children:["Team",i.jsx("input",{value:t,placeholder:"Search your teams by key or name",spellCheck:!1,"aria-label":"Search teams",onChange:p=>s(p.target.value)})]}),i.jsx("ul",{className:"repo-list","aria-label":"Teams",children:a.map(p=>i.jsx(rC,{team:p,selected:p.id===e.value,now:o,onPick:()=>e.onChange(p.id)},p.id))}),i.jsx(V,{parts:[!l&&"No team matches",f,d,h]})]})}function lC(e){const{list:t}=e;if(!t)return i.jsx(ri,{label:"Loading teams…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(aC,{teams:t.teams,truncated:t.truncated,value:e.value,onChange:e.onChange});case"no-key":return i.jsx(V,{parts:["Paste a Linear API key to list your teams"]});case"error":return i.jsx(zd,{what:"Couldn't list your teams",reason:t.error,onRetry:e.onRetry});default:return t}}function cC(e,t){const[s,o]=y.useState(e);return y.useEffect(()=>{const a=setTimeout(()=>o(e),t);return()=>clearTimeout(a)},[e,t]),s}function dC(e){const{value:t,retry:s}=Vd({enabled:e.enabled&&!!e.teamId,key:`${e.teamId}
|
|
147
|
-
${e.apiKey??""}`,load:()=>Bt.linearProjects(e.teamId,e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function uC(e){const{value:t,retry:s}=Vd({enabled:e.enabled,key:e.apiKey??"",load:()=>Bt.linearTeams(e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function hC(e){const t=cC(e.apiKey.trim(),400),s=e.paste&&t?t:void 0,o=e.paste?!!t:!!e.ln.auth,a=uC({enabled:o,apiKey:s}),l=dC({teamId:e.teamId,apiKey:s,enabled:o}),d=a.list,h=l.list,f=(d==null?void 0:d.kind)==="ok"?d.teams:[],p=o&&!d,k=o&&!!e.teamId&&!h;return{enabled:o,list:d,teams:f,projects:h,loading:p||k,retryTeams:a.retry,retryProjects:l.retry}}function wv(e){var ne;const t=e.s.linear,s=X$(t),[o,a]=y.useState(!s),[l,d]=y.useState(""),[h,f]=y.useState(t.teamId??""),[p,k]=y.useState(t.projectId??""),[v,w]=y.useState(),[j,N]=y.useState(!1),{enabled:S,list:I,teams:$,projects:_,loading:O,retryTeams:D,retryProjects:q}=hC({ln:t,paste:o,apiKey:l,teamId:h});y.useEffect(()=>{s&&!l&&a(!1)},[s]),y.useEffect(()=>{(I==null?void 0:I.kind)==="ok"&&f(iC(I.teams,t.teamId)??"")},[I]);const H=$.find(ce=>ce.id===h),G=(_==null?void 0:_.kind)==="ok"?_.projects.find(ce=>ce.id===p):void 0,oe=(I==null?void 0:I.kind)==="ok"?I.viewer:t.viewer,Q=o?null:t.auth,ke=yv({viewer:oe,team:H==null?void 0:H.name,project:G==null?void 0:G.name,source:Q}),Oe=async()=>{if(H){N(!0),w(void 0);try{await Bt.connect({active:"linear",linear:{teamId:H.id,teamKey:H.key,teamName:H.name,projectId:G==null?void 0:G.id,projectName:G==null?void 0:G.name,apiKey:o?l.trim():void 0}}),e.onConnected()}catch(ce){w({ok:!1,error:ce.message}),N(!1)}}},Te=ce=>{f(ce),k("")};return i.jsxs("div",{className:"card inset tracker-setup linear-setup",children:[o&&i.jsx(tC,{ln:t,apiKey:l,onKey:d}),i.jsx(Y$,{line:ke,email:(ne=ba(oe))==null?void 0:ne.email,onUseAnother:o?void 0:()=>a(!0)}),S&&i.jsx(lC,{list:I,value:h,onChange:Te,onRetry:D}),H&&i.jsx(nC,{list:_,value:p,onChange:k,onRetry:q}),i.jsx(gv,{r:v}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:j||O||!H,onClick:()=>void Oe(),children:j?"Connecting…":"Connect"})})]})}function fC(e){return i.jsxs("div",{className:"c-actions",children:[e.canSwitch&&i.jsx("button",{className:"btn sm",disabled:!e.usable,onClick:e.onSwitch,children:"Switch"}),e.remote&&i.jsx("button",{className:`btn sm ${e.open?"on":""}`,disabled:!e.usable,onClick:e.onToggle,children:e.configured?"Edit":"Connect"})]})}function mC(e){return["Anything this account writes counts as you, including agents signed in as you",`${e==="github"?"people with write access":"members (not guests)"} can claim, move and close tickets; their decisions show under their name`,"settings they change wait for you in the queue, to accept or keep stricter"]}function pC(e){const{id:t,active:s,s:o}=e,a=nr(t),l=s&&o?gC(t,o):void 0;return l&&a?i.jsxs(i.Fragment,{children:[i.jsx(V,{className:"c-who",parts:[l]}),i.jsx(V,{className:"c-trust",parts:mC(t)})]}):l?i.jsx(V,{className:"c-who",parts:[l]}):s&&(t==="markdown"||a)?i.jsx("div",{className:"c-loc",children:e.location}):a&&e.configured&&o?i.jsx("div",{className:"c-loc",children:vC(t,o)}):null}function gC(e,t){if(e==="github")return O$(t.github);if(e==="linear")return Z$(t.linear)}function vC(e,t){return e==="github"?t.github.repo:[t.linear.teamKey,t.linear.projectName].filter(Boolean).join(" · ")}function kC({status:e}){var l,d;if(!e)return null;const t=(l=e.rate)!=null&&l.limit?`${((d=e.rate.remaining)==null?void 0:d.toLocaleString())??"?"}/${e.rate.limit.toLocaleString()} req`:"",s=e.queued?` · ${e.queued} queued`:"",[o,a]=yC(e,s);return i.jsxs("div",{className:`sync-line ${o}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:a}),t&&i.jsx("span",{className:"rate",children:t})]})}function yC(e,t){switch(e.state){case"online":return["ok",`Online · synced ${_g(e.lastSyncAt)}${t}`];case"offline":return["warn",`Offline${t}`];case"rate-limited":return["warn",`Rate limited · resumes ${hr(e.resetAt)}${t}`];case"auth-error":return["alert",`Credentials rejected${t}`];default:return["",`Connecting${t}`]}}function wC(e){const{id:t,active:s,configured:o,s:a}=e,l=nr(t),d=!l||!!a,h=["card connector",s?"active":"",d?"":"disabled",e.open?"open":""];return i.jsxs("div",{className:h.join(" "),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:e.name}),s&&i.jsx("span",{className:"pill on",children:"Active"})]}),i.jsx(pC,{id:t,active:s,configured:o,location:e.location,s:a}),l&&s&&i.jsx(kC,{status:a==null?void 0:a[t].status}),i.jsx(fC,{canSwitch:!s&&(!l||o),remote:l,usable:d,configured:o,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function xv(e=0){const[t,s]=y.useState(),o=y.useCallback(()=>Bt.get().then(a=>(s(a),a),()=>(s(null),void 0)),[]);return y.useEffect(()=>{if(o(),!e)return;const a=setInterval(()=>void o(),e);return()=>clearInterval(a)},[o,e]),[t,s,o]}function xC(e){const[t,,s]=xv(5e3),[o,a]=y.useState(null),l=async h=>{t&&(h==="markdown"||nr(h))&&await Bt.connect({active:h==="markdown"?"markdown":h,...h==="github"&&t.github.repo?{github:{repo:t.github.repo}}:{},...h==="linear"&&t.linear.teamId?{linear:{teamId:t.linear.teamId,teamKey:t.linear.teamKey,teamName:t.linear.teamName,projectId:t.linear.projectId,projectName:t.linear.projectName}}:{}}).catch(()=>{}),sr(e.update,h)},d=y.useMemo(()=>({github:!!(t!=null&&t.github.repo),linear:!!(t!=null&&t.linear.teamId)}),[t]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"connectors",children:I0.map(h=>{const f=h.id;return i.jsx(wC,{id:f,name:h.name,active:f===e.activeTracker,configured:nr(f)&&d[f],open:o===f,location:e.location,s:t,onSwitch:()=>void l(f),onToggle:()=>nr(f)&&a(o===f?null:f)},h.id)})}),t&&o==="github"&&i.jsx(vv,{s:t,reload:s,onConnected:()=>sr(e.update,"github")}),t&&o==="linear"&&i.jsx(wv,{s:t,onConnected:()=>sr(e.update,"linear")})]})}function jC(e,t){const s=e==null?void 0:e.github,o=e==null?void 0:e.linear,a=s&&t!=="github"?mv(s,s.repo??s.detectedRepo):void 0,l=o&&t!=="linear"?yv({viewer:o.viewer,team:o.teamName,project:o.projectName,source:o.auth}):void 0;return[{id:"markdown",title:"Local markdown",sub:"Files in .teamtrail/ in this repo"},{id:"github",title:"GitHub Issues",sub:a??"Trails as labelled issues in your repo"},{id:"linear",title:"Linear",sub:l??"Trails and tickets in your Linear team"}]}function Ee(e){return i.jsxs("section",{className:"set-sec",children:[i.jsx(ze,{as:"h4",children:e.title}),e.children]})}function jv(e){const t=[{v:"summary",title:"Summary"},{v:"full",title:"Full transcript"}];return i.jsx("div",{className:"choice-row",children:t.map(s=>i.jsx(ot,{on:e.value===s.v,title:s.title,onClick:()=>e.onChange(s.v)},s.v))})}const SC={github:"Checking for a GitHub login…",linear:"Checking for a Linear key…"};function NC(e){var I;const{prefs:t,update:s}=e,[o,,a]=xv(5e3),[l,d]=y.useState(!1),h=(I=o==null?void 0:o.pending)==null?void 0:I.target.split(":")[0],[f,p]=y.useState(!1);y.useEffect(()=>{h&&!f&&t.tracker!==h&&s({tracker:h})},[h,f,t.tracker,s]);const k=jC(o??void 0,t.tracker),v=t.tracker==="github"||t.tracker==="linear",w=v&&(o==null?void 0:o.active)===t.tracker,j=v&&!w,N=$=>{s({onboarded:!0}),sr(s,$)},S=async()=>{d(!0);const $=o&&!o.pending;t.tracker==="markdown"&&$&&await Bt.connect({active:"markdown"}).catch(()=>{}),s({onboarded:!0}),t.tracker!==e.activeTracker&&sr(s,t.tracker)};return i.jsx("div",{className:"scrim",children:i.jsxs(Be,{as:"div",className:"dialog onboarding",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(xa,{className:"onb-title"})}),i.jsxs("h2",{className:"onb-question t-heading",children:[i.jsx(kN,{className:"voice-badge",size:22}),"Where should your trails live?"]}),i.jsxs(Ee,{title:"Tracker",children:[i.jsx("div",{className:"choice-row",children:k.map($=>i.jsx(ot,{on:t.tracker===$.id,title:$.title,sub:$.sub,onClick:()=>(p(!0),s({tracker:$.id}))},$.id))}),(o==null?void 0:o.pending)&&i.jsxs("p",{className:"t-meta onb-repo-tracker",children:["This repo keeps its trails in ",o.pending.label,". Connect it here, or keep local files on this machine; the team's choice in the repo isn't changed either way."]}),o===void 0&&v&&i.jsx(ri,{label:SC[t.tracker]??"Checking…"}),o&&t.tracker==="github"&&!w&&i.jsx(vv,{s:o,reload:a,onConnected:()=>N("github")}),o&&t.tracker==="linear"&&!w&&i.jsx(wv,{s:o,onConnected:()=>N("linear")})]}),i.jsx(Ee,{title:"HITL transcript",children:i.jsx(jv,{value:t.hitlTranscript,onChange:$=>s({hitlTranscript:$})})}),i.jsx("footer",{children:i.jsx(M,{variant:"primary",disabled:l||j,onClick:()=>void S(),children:"Get started"})})]})})}function bC(e){var t;return(t=ft())!=null&&t.tracker?null:i.jsx(NC,{...e})}const lr=[{id:"trail",label:"This trail",intro:"How agents work on the trail on screen: its mode, the checks that prove work done, models and guides.",sections:[{id:"mode",title:"Trail mode"},{id:"verification",title:"Verification"},{id:"models",title:"Model matching"},{id:"team",title:"Team"}]},{id:"project",label:"Project",intro:"Where this repo keeps its trails, and the rules every agent working in it follows.",sections:[{id:"approvals",title:"Approvals"},{id:"tracker",title:"Tracker"},{id:"workspaces",title:"Workspaces"},{id:"proof",title:"Proof on pull requests"},{id:"remote-agents",title:"Remote agents"},{id:"policy",title:"Risk policy"},{id:"guides",title:"Guides"},{id:"labels",title:"Labels"}]},{id:"alerts",label:"Attention & alerts",intro:"What interrupts you, where questions reach you, and what Scout tells you when you come back.",sections:[{id:"attention",title:"Attention"},{id:"slack",title:"Slack"},{id:"trip-report",title:"Trip report"}]},{id:"you",label:"You",intro:"How the Lookout looks and reads for you, and the browsers and devices signed in to it.",sections:[{id:"appearance",title:"Appearance"},{id:"transcript",title:"HITL transcript"},{id:"agent",title:"Agent"},{id:"devices",title:"Browsers & devices"}]},{id:"projects",label:"All projects",intro:"Every repo this Lookout knows, so you can switch between them from the header.",sections:[{id:"projects",title:"Projects"}]},{id:"about",label:"About",intro:"What Teamtrail is, and what changed in each release.",sections:[{id:"changelog",title:"Changelog"}]}];function Sv(e){if(e===null)return null;const t=lr.find(a=>a.id===e);if(t)return{group:t.id};const s=lr.find(a=>a.sections.some(l=>l.id===e));if(!s)return{};const o=s.sections.find(a=>a.id===e);return{group:s.id,section:o==null?void 0:o.id}}function $C(){return i.jsxs("p",{className:"sp-elsewhere t-meta",role:"note",children:["You're looking at this Lookout from another device. You can read, answer and approve from here. What changes what runs on the machine ",Z.name," runs on, or whom it trusts, is set there: the approvals of what the repo asks it to trust, the tracker connection, Slack, the risk policy, verification levels, workspaces, guides, remote agents, your attention settings and the projects list. Paths on that machine and its tracker account are not shown here."]})}const Xm={from:"18:00",to:"09:00"};function CC(e){const t=e.focus!==void 0,s=e.focus??Xm;return i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Quiet hours"}),i.jsx(M,{size:"sm",on:t,"aria-pressed":t,onClick:()=>e.onChange(t?void 0:Xm),children:t?"On":"Off"}),t&&i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"time","aria-label":"Quiet from",value:s.from,onChange:o=>o.target.value&&e.onChange({...s,from:o.target.value})}),i.jsx("span",{className:"t-meta",children:"to"}),i.jsx("input",{type:"time","aria-label":"Quiet until",value:s.to,onChange:o=>o.target.value&&e.onChange({...s,to:o.target.value})})]})]})}const Bc=[3,5,8,12];function TC(e){const t=e&&!Bc.includes(e)?[...Bc,e].sort((s,o)=>s-o):Bc;return[{value:"off",label:"Off"},...t.map(s=>({value:String(s),label:`${s} waiting`}))]}const Zm=e=>`${e} finished ticket${e===1?"":"s"}`;function EC(e,t){const s=(e==null?void 0:e.waiting.length)??0;return t?e!=null&&e.full?`${Zm(s)} wait: agents start no new implementation work until you review some.`:`${s} of ${t} waiting: agents start new work.`:s?`${Zm(s)} wait for your review now.`:"Nothing waits for your review now."}function AC(e){const{limit:t,review:s}=e;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Review limit"}),i.jsx(at,{compact:!0,"aria-label":"Review limit",value:t?String(t):"off",options:TC(t),disabled:e.local===!1,onChange:o=>e.onChange(o==="off"?null:Number(o))})]}),i.jsxs("span",{className:"set-hint t-meta",children:["Agents finish rework and keep researching, but start no new implementation work while this many tickets wait for your review. ",EC(s,t)]})]})}function $a(){const[e,t]=y.useState();return y.useEffect(()=>{fetch(`${pe()}/machine`).then(s=>s.ok?s.json():void 0).then(s=>t(s==null?void 0:s.local),()=>t(void 0))},[]),e}const IC=[{value:"browser",label:"Browser notification"},{value:"slack-dm",label:"Slack DM"},{value:"slack-channel",label:"Slack channel"},{value:"none",label:"Nothing, I check the queue"}];function RC(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function MC(){const{view:e,error:t,savePrefs:s,saveReviewLimit:o}=hv(0),a=$a();if(!e)return null;const l=e.policy.value,d=`${Z.dataDir}/attention.json`,h=p=>void s({...e.prefs,...p}),f=typeof Notification<"u"&&Notification.permission==="denied";return i.jsxs(Ee,{title:"Attention",children:[i.jsxs("p",{className:"vf-intro",children:["Everything that needs you is ranked in Waiting on you. Only items scoring ",l.interrupt," or more interrupt you; the rest wait in the queue, and Slack gets them in a digest."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Interrupt me by"}),i.jsx(at,{compact:!0,"aria-label":"Interrupt me by",value:e.prefs.channel,options:IC,onChange:p=>{p==="browser"&&RC(),h({channel:p})}})]}),e.prefs.channel==="browser"&&f&&i.jsx("span",{className:"vf-err",children:"The browser blocks notifications for this page. Allow them in its site settings."}),i.jsx(CC,{focus:e.prefs.focus,onChange:p=>h({focus:p})}),i.jsx("span",{className:"set-hint t-meta",children:"Your channel and quiet hours stay on this machine."}),i.jsx(AC,{limit:l.reviewLimit,review:e.review,local:a,onChange:p=>void o(p)}),e.policy.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:e.policy.errors.map(p=>i.jsxs("li",{children:[d,": ",p]},p))}),i.jsx(V,{className:"set-hint",parts:[e.policy.exists?{text:d,code:!0}:"Team defaults",`interrupt at ${l.interrupt}`,l.digestMinutes?`Slack digest every ${l.digestMinutes} min`:"Slack digest off",l.reviewLimit?`review limit ${l.reviewLimit}`:"review limit off"]}),t&&i.jsx("span",{className:"vf-err",children:t})]})}const LC=[5,15,30,60];function OC(e){const{value:t}=e;return i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ot,{on:!t.enabled,title:"Off",onClick:()=>e.onChange({...t,enabled:!1})}),LC.map(s=>i.jsx(ot,{on:t.enabled&&t.awayMinutes===s,title:`Away ${s} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:s})},s))]})}const PC={repo:"Committed to the repo",machine:"Only on this machine",browser:"Only in this browser"};function Ke(e){const t=e.storage&&PC[e.storage];return i.jsxs("div",{className:"sp-slot",id:`settings-${e.id}`,children:[e.children,t&&i.jsx(V,{className:"sp-where",parts:[t]})]})}function _C(e){const[t]=Wd();return t?i.jsx(Ee,{title:"Slack",children:i.jsx(Sb,{focus:e.focus})}):null}function DC({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(Ke,{id:"attention",storage:"repo",children:i.jsx(MC,{})}),i.jsx(Ke,{id:"slack",storage:"machine",children:i.jsx(_C,{focus:t.section==="slack"})}),i.jsx(Ke,{id:"trip-report",storage:"browser",children:i.jsx(Ee,{title:"Trip report",children:i.jsx(OC,{value:e.prefs.briefing,onChange:s=>e.update({briefing:s})})})})]})}const zC=[{version:"0.32.0",date:"2026-11-13",items:["Scout has a new look: a scout companion with a cap, a headset and an antenna, looking out along the trail"]},{version:"0.31.1",date:"2026-11-13",items:["An archived trail’s held work and changes waiting for your approval stay in your queue"]},{version:"0.31.0",date:"2026-11-13",items:["Start a trail over: the trail menu archives the map that went wrong and opens New trail with its idea filled in","Archive a trail you are done with, or restore it: it stays as history, and no agent takes work from it","The empty map looks like every other empty zone, with New trail and the agent command under it"]},{version:"0.30.0",date:"2026-11-12",items:["Ask Scout more in Slack: “what's blocking #12?”, “what did we decide about retention?”, “who's working?”, as @Scout, a DM or /scout ticket, decisions and who","In a channel, the answers are seen only by you"]},{version:"0.29.3",date:"2026-11-12",items:["@Scout inbox and status in a channel now show up right away, seen only by you"]},{version:"0.29.2",date:"2026-11-12",items:["The Activity log reads in one style: a coloured bar marks what needs you (red), what went well (green) and what is held up (amber), and Slack answers show who gave them"]},{version:"0.29.1",date:"2026-11-12",items:["Scout says in Slack that it needs Teamtrail running on your computer, and how to start it, when it can’t reach yours","Ask Scout in your own words: “@Scout what’s in my inbox?” or “status of Slack live test” work, in a channel or a DM"]},{version:"0.29.0",date:"2026-11-12",items:["Ask Scout in Slack: @Scout inbox or @Scout status in a channel answers only you, or DM Scout; if you added Scout before, Settings asks you to reconnect once","A question your agent waits on gets its own Slack message with answer buttons, even right after it asked another one","Scout can be installed straight from Slack (scout.teamtrail.app/install-slack); each person then connects in Settings → Slack"]},{version:"0.28.0",date:"2026-11-12",items:["Scout is now one Slack app: Settings → Slack → Add Scout to Slack, no app to create and no tokens to paste","You confirm which Slack account becomes Scout’s owner before it connects; if you made your own Slack app before, add Scout again","High-risk calls are answered in the Lookout only, and so is approving an agent’s request to change your settings: Slack shows Open in Lookout, and Decline still works there"]},{version:"0.27.3",date:"2026-11-11",items:["On Linux, the Lookout sees every change an agent makes to a ticket again, not only the first: a claimed ticket no longer stays in the queue as waiting"]},{version:"0.27.2",date:"2026-11-11",items:["Settings, briefs, criteria, guides, reroutes and the other panels stay current through reconnects, and a GitHub or Linear map updates live again"]},{version:"0.27.1",date:"2026-11-11",items:["The map and the queue no longer miss a change made while the Lookout was loading or reconnecting"]},{version:"0.27.0",date:"2026-11-11",items:["Teamtrail opens your browser ready to sign in with one click; `teamtrail pair` does the same for another tab"]},{version:"0.26.2",date:"2026-11-11",items:["The Lookout shows the new teamtrail. wordmark"]},{version:"0.26.1",date:"2026-11-11",items:["A refreshed logo: the trail’s destination is larger, and there are light and dark versions that follow your theme"]},{version:"0.26.0",date:"2026-11-11",items:["The Lookout asks you to sign in: open the link `teamtrail` prints, and pair your phone with a QR code (again after each restart)","Your answers count only when you give them in the Lookout or Slack, and skipping discovery or changing a trail’s mode or destination waits for your Approve","Check commands, briefs, criteria and other trusted settings run only once you approve them on this machine, in Settings → Approvals","Changes made to trail files outside Teamtrail have no effect until you accept them"]}],BC=[{version:"0.10.0",date:"2026-10-31",items:["MCP server in the miloops package: `claude mcp add miloops -- npx -y miloops-cli mcp`, or the same for Codex","Connected agents start and resume missions, claim ready tickets, report steps, tokens and spend, close tickets and record decisions, live in the command center","Agent questions land in Waiting on you and the agent waits for your answer; answer in the command center or in the agent chat","/milo new, resume, status and inbox commands for Claude Code (and as a Codex prompt); `miloops connect claude|codex` sets them up","The command center follows a mission an agent just charted; sessions of agents that quit show as disconnected"]},{version:"0.9.0",date:"2026-10-31",items:["While you were away: MILO briefs you when you open the app or come back after being away: tickets done, now blocked, decisions waiting on you, agent decisions, spend and tokens since, active sessions","Briefing shows on return after 15 minutes hidden or idle; change the threshold or turn it off in Settings; reopen it from the header","Last seen per mission and usage over time are kept locally, so the briefing survives a reload","Mission title shows in full at laptop width; header readouts collapse to glyph and count","Prototype reviews link a real preview build and ask about the spike results"]},{version:"0.8.0",date:"2026-10-31",items:["Decisions: every decision across missions, newest first, with question, decision, alternatives, rationale, who decided and the full transcript","Filter decisions by mission, source, who decided and status; search; export to markdown","Supersede a decision; the chain stays visible on every record and in the mission","Decision records stored as markdown next to each mission and served by the local API with a live event stream","Resolve form: rationale and alternatives considered"]},{version:"0.7.0",date:"2026-10-31",items:["New type: Chakra Petch, Share Tech Mono and Barlow","Calmer palette; bright colour only for warnings and waiting on you","MILO mark, also used for status, action and alert glyphs","Dot-matrix signals for new decision requests and mission launches","Separate type voices for operators and agents","One-command install: npm i -g miloops-cli, then miloops in any repo","Packages renamed to @miloops-hq/core and @miloops-hq/command-center"]},{version:"0.6.0",date:"2026-10-31",items:["Named MILOOPS; MILO speaks for the platform in the activity log and onboarding","Tracker sync status, last-write latency and event pulse","Inbox: oldest question age and average wait","Critical path, decided per hour with burndown, type mix","Per-session tokens and cost, mission totals, claims per agent"]},{version:"0.5.0",date:"2026-10-31",items:["Status counters and resolution bar on the map","Current step tracker with step pipeline","Sessions with live timers","Activity log with time and source columns","Out-of-scope quarantine zone on the map"]},{version:"0.4.0",date:"2026-10-31",items:["Missions: switcher with progress and waiting count, New mission in the switcher","Inbox collects questions from every mission","Elapsed time and progress per mission","Responsive layout with progressive disclosure (wide, laptop, phone)","Map graph pans and zooms by drag, pinch and wheel","Changelog"]},{version:"0.3.0",date:"2026-10-31",items:["Fixed-zone layout","Plan + execute and plan-only mission modes","Execute tickets"]},{version:"0.2.0",date:"2026-10-31",items:["Local markdown tracker (default)","Onboarding","HITL transcript: summary or full","Settings with tracker connectors"]},{version:"0.1.0",date:"2026-10-31",items:["Live map graph","HITL vs AFK tickets","In-window HITL conversations","Demo tracker with simulated sessions"]}],FC=[{version:"0.25.0",date:"2026-11-10",items:["Agents on other machines or in cloud sandboxes can join your trails: `teamtrail mcp --http` serves the same tools over HTTP","One token per remote agent, created and revoked in Settings → Remote agents; without a token nothing is reachable","`teamtrail connect claude|codex --url` points an agent at a remote Teamtrail"]},{version:"0.24.2",date:"2026-11-10",items:["A ticket’s description no longer repeats which trail it is part of"]},{version:"0.24.1",date:"2026-11-10",items:["Buttons in the same row are always the same size"]},{version:"0.24.0",date:"2026-11-10",items:["Focus in the header: see at a glance whether it is on, and start or end it in one click","Sign in with GitHub, and pick your repo or Linear team from a searchable list","Write your own guides with `teamtrail guides new`, approve them in Settings and share them with the catalog","Settings is its own page, and the trail map has a cleaner, flatter look","Smaller polish: one colour for work in progress everywhere, a calmer first run and clearer Slack setup"]},{version:"0.23.0",date:"2026-11-08",items:["Match work to models: switch it on for a trail in Settings and each agent gets the tickets that fit the model it runs on, research on fast models and junctions on the strongest. You set the tier per ticket type; Teamtrail never switches a model, and a ticket no connected agent is strong enough for waits in your queue","Guides: a ticket can ask for a reviewer, QA, security, docs or architect, and the agent that claims it gets that guide’s instructions and a checklist it must answer before the work counts as done. Pick a trail’s team and each ticket’s guide in the Lookout, and add more guides from a moderated catalog in Settings → Guides. A guide can add checks but never remove one, its commands only run after you approve them, and a guide file edited after you approved it is switched off until you look at it again","Records has a new Trail stats view: delivery across every trail, by vendor, agent and ticket type, with plain observations from your own numbers. Teamtrail doesn't route work from them","MILOOPS is now Teamtrail. Missions are trails, the command center is the Lookout, MILO is Scout, and `/milo` is `/scout`","More room for the map: the summary of counts now slides up from a tab when you want it","A new day and night look, starting in night, with an Appearance setting to switch to day or follow your system","The map is now a landscape: tickets are trail signs, the trail shows what is walked and what is ahead, and an X marks the destination","A new greeting when you start `teamtrail` in a terminal","A new logo, a t whose stem runs along a trail to a node, and a new look for Scout: the original CRT head with ear cups and a baseball cap, with a lamp on the cap at night. No more pixel art, and new fonts too","All projects: every repo you supervise in one view, with one list of what needs you across them and what changed while you were away. Answer an agent's question in any repo from there, and switch projects from the header. Agents add their repo when they connect (`--no-register` opts out), or add one with `teamtrail projects add`"]},{version:"0.22.0",date:"2026-11-05",items:["A calmer, clearer command center: every list now reads the same way, what it is first, then one quiet line of context, and details when you want them","Red now only means something needs you now; other states show as a thin edge instead of colored text everywhere","The open question in a conversation can no longer be hidden by its suggested answers, and the phone header no longer runs off the side"]},{version:"0.21.0",date:"2026-11-05",items:["New plans can now edit a ticket, remove a dependency and reopen finished work, instead of working around it","Slack digests follow the team's digest setting (digestMinutes in attention.json); 0 turns them off, and everything still waits in Waiting on you","Remove a finished task's workspace from Settings → Workspaces or the ticket; the branch stays, and MILOOPS asks before discarding uncommitted changes"]},{version:"0.20.0",date:"2026-11-04",items:["Separate workspaces: switch on Settings → Workspaces and each ticket an agent claims gets its own copy of the repo on its own branch, so agents working at the same time don’t step on each other. When the work is done you get the branch to review; MILOOPS never merges or pushes for you","Warnings before a clash: agents say which files they expect to change. When two of them plan to change the same files, the second one is warned, and you see it in Waiting on you; open it to release either claim","When two agents’ branches did change the same files, Waiting on you suggests a ticket to bring the work together. One click adds it, waiting on both tickets, with the files listed","The ticket inspector shows which files an agent expects to change and the branch it works on","Fix: an execute ticket marked as needing you keeps that mark when saved to local files, GitHub Issues or Linear"]},{version:"0.19.0",date:"2026-11-04",items:["Risk policy: you decide what always needs you, such as database changes, logins and permissions, billing, deleting data or new dependencies (Settings → Risk policy). Agents can no longer make those calls on their own; they ask you. Their other decisions are labelled by risk in the briefing, and work that touched risky files without asking comes to you to check","One ranked list of everything that needs you in Waiting on you: questions, approvals, blocked work, briefs, knowledge and new plans, most important first, each with the reason (for example “blocks 3 tickets” or “claude-02 is waiting”). Related items are grouped so you answer them together; snooze what can wait","Fewer interruptions: agents say how urgent a question is, and only urgent items notify you (browser or Slack). Focus for an hour from the header, set quiet hours in Settings → Attention, and the rest waits in the list and the digest","Plans that adapt: missions list the assumptions they rely on, starting with the ones in the discovery brief. When an agent finds one is wrong, it shows the evidence and proposes a new plan; the tickets it would change are paused, the map previews the change, and nothing happens until you approve","Challenge the destination: an agent can tell you the work already exists, the mission targets the wrong problem, or it should be rescoped, with evidence and a suggested new goal","Assumptions on the Plan tab (confirm the ones you know are true) and an assumptions field when you create a mission","Fix: when an agent asks two questions at once, your answer goes to the one you opened; the inbox stats line no longer gets covered by the list"]},{version:"0.18.0",date:"2026-11-04",items:["Acceptance criteria: agents write down what done means before they start (required on missions with a discovery brief). When they finish, each point needs proof: one of your checks, a named test, the pull request, or your sign-off","Work whose criteria lack proof goes back with the reason; points only you can confirm come to your inbox to sign off","Business rules from your project knowledge are suggested as criteria, and the ticket shows any rule no criterion covers yet. Confirm a ticket’s criteria in the inspector","Cross-vendor review: when Claude and Codex agents both run, each reviews the other’s work first","Fix: answers from the command center could hang when too many live updates were open; all updates now share one connection"]},{version:"0.17.0",date:"2026-11-03",items:["Discovery brief: new missions start with an agent mapping the existing system (files, conventions, data and API impact, risks, assumptions, product context). Implementation tickets wait until you accept the brief or ask for changes, from the banner over the map or the card in Communication","Create mission: start a mission from the New mission dialog without a terminal; any agent picks it up with /milo resume","Knowledge: what agents need to know about your codebase and product (architecture, conventions, gotchas, dead ends, business rules, personas, UX principles, pricing). Agents propose, you confirm, keep as an assumption or retire. Confirmed entries reach agents with every claim, picked for the ticket with the reason, and the inspector shows what an agent gets","Knowledge about specific files is flagged for re-confirmation when those files change","Save decisions, cancelled tickets (as dead ends) and brief sections as knowledge in one click; seed it from a document with miloops knowledge import <file.md>"]},{version:"0.16.0",date:"2026-11-03",items:["Mission report (Mission plan → Report): tickets done, mission and median ticket lead time, your interventions, rework, review results and cost per verified ticket. Hover any number to see how it is computed; export it as markdown","Agents report the same numbers in one line from the status tool","Agents use missions for big work only, and decide routine calls themselves, keeping each one as a decision record you can review or reverse; they ask you when the call changes product behaviour, data, security, billing, a public API or the schema","Decisions: filter by who made the call, agents on their own or people. The briefing now counts only the calls agents made themselves, not your answers they recorded"]},{version:"0.15.0",date:"2026-10-31",items:["Verification in the ticket inspector: the level that applies and where it comes from, every attempt newest first with the git evidence (base → head, files changed, flags), its checks, exit codes, durations and the failing output, and the full log on demand","Verifying, Rework and Blocked on the map, in the legend and as status counters on missions that verify completions","Operator calls on a verifying or blocked ticket: Approve, Re-run checks, Send to rework with a note, Accept anyway and Unblock. Overrides need a reason, and each call is kept as a verdict next to the attempts and in the mission history. Approve asks for a re-run when the code changed since the checks passed","Set the verification level of a mission (Settings → Verification) or of one ticket (inspector). Only you can change it; agents cannot","The inspector updates live while checks run","Independent review: at Checks + review, a passing completion gets a review ticket that another agent takes and answers with PASS, FAIL (with findings) or NEEDS_HUMAN. The agent that did the work is never given its own review","Waiting on you lists reviewed work to approve (Checks + review + you) and held tickets, and Slack posts them with Approve and Rework… buttons","Agents can name their pull request in `report_completion` (`pr`); PR and CI tracking then follows that PR first"]},{version:"0.14.0",date:"2026-10-31",items:["Ticket lifecycle in plain words: Ready, Backlog, Working, Done and Cancelled (with Verifying, Rework and Blocked to come with verification)","Every claim, release, return to queue, resolution and rule-out goes through one lifecycle engine that records who, why and when in `.miloops/.events/<mission>.jsonl` (local history, never committed)","Settings → Verification shows the checks in `.miloops/verification.json`: argv commands with timeouts, run without a shell, secrets kept out of their environment. Read-only","Completion is a claim: on missions started with `verification.json` present, an execute or task ticket is only done once its checks pass. A failed check sends it back for Rework with the failing output (agents see it in close_ticket, next_ticket and claim_ticket, and rework comes first in the queue); after 3 failed attempts, or when the checks cannot run, it waits on you as Blocked","New MCP tools `report_completion` and `verification_status`; missions started before verification, and research, grilling and prototype tickets, close exactly as before","Git evidence, no GitHub needed: each claim records HEAD and the uncommitted state, and each completion lists the files changed since then. It flags no changes, overlap with another active ticket, a branch switch or reset, and edits to `verification.json` (which send the ticket to you as Blocked). A pass on code that changed while its checks ran is re-run","Pull request and CI evidence: with `verification.json` and a GitHub token (Settings, `GITHUB_TOKEN` or `gh auth login`), the command center finds each ticket’s PR (its branch `miloops-<mission>-<ticket>`, a `miloops:<mission>#<ticket>` line in the PR body, or a link you set) and flags mismatches: done with the PR still open, PR merged while the ticket is in progress, PR closed unmerged, required checks failing or unknown, PR head not the verified commit. Flags never change a ticket. A CI chip in the header shows sync health and never shows synced after a failed sync"]},{version:"0.13.0",date:"2026-10-31",items:["Crash recovery for claims: an agent’s claim is a lease (15 min by default) that every tool call renews, including waits on your answer","When an agent crashes or goes silent, its ticket goes back to the queue on its own, and the activity log says so; the next agent picks it up from next_ticket or claim_ticket","The returned ticket keeps a handoff comment with the previous agent’s progress notes and decisions, so the next agent resumes instead of starting over","Stalled state on the map, in sessions and in the ticket inspector when a lease is about to run out, with a Release to queue action","Works with GitHub and Linear: the return is an ordinary comment + unassign, queued in the offline outbox like any other write","Set the lease with `miloops mcp --lease-minutes <n>` or `MILOOPS_LEASE_MINUTES`"]},{version:"0.12.0",date:"2026-10-31",items:["Slack: your own MILO app, created from a manifest and connected from your machine over Socket Mode in five guided steps (Settings → Slack or `miloops connect slack`)","Tokens stay in your local credential store next to the GitHub and Linear ones; nothing passes through MILOOPS servers","Agent questions arrive as a Slack DM with answer buttons and a Reply… box; answering there resolves the item in Waiting on you, and answering in the command center closes the DM","Save as decision on any message, or `/milo decide`: the form is prefilled with a summary of the thread, and the decision is recorded with a permalink, resolving the related ticket by default","`/milo status` and `/milo inbox` for the mission at a glance; DMs when a ticket is blocked or a mission is done","Allowed users, notification target and events in Settings → Slack","Slack setup without Paste clicks: press ⌘V / Ctrl+V anywhere, or in Chrome just come back to the tab after copying; pasting the app token opens the install page; MILO recognises you by your git email, so there is nothing to claim in Slack"]},{version:"0.11.0",date:"2026-10-31",items:["GitHub Issues tracker: missions are labelled issues, tickets are sub-issues, blocking uses native issue dependencies",'Linear tracker: missions are labelled issues in a team (optionally one project), tickets are sub-issues, blocking uses "blocks" relations',"Two-way sync: tickets, status, claims, comments, blockers and decisions written from MILOOPS land in the tracker; changes made there show up within seconds","Decisions are posted as comments on their ticket and listed in the mission","Connect from Settings with Test connection; GitHub reuses your gh login or GITHUB_TOKEN, Linear takes a personal API key","Tokens stay on your machine: kept by the local server, never sent to the browser or anywhere else","Offline and rate limits: changes queue and send in order when the tracker answers again; the connector shows status, queue and remaining requests","Connected agents (MCP) work on the active tracker: with GitHub or Linear connected, their missions, claims and decisions land there, and their sessions show live in the command center"]},...BC],UC=[{area:"Teamtrail Cloud",items:["The Lookout as an app on your phone, with a nudge only for the calls that need you"]}],WC=[{version:"0.52.0",date:"2026-11-16",items:["Scope check: files an agent changed beyond the ones it said it would are listed first for whoever reviews","Choose in Settings → Verification whether they are only shown, sent back for rework, or left for you to decide","Proofs on pull requests say whether every change stayed inside the declared files"]},{version:"0.51.0",date:"2026-11-16",items:["Review limit: set how much finished work may wait for your review, and agents start no new work past it","Agents finish rework and keep researching meanwhile, and Waiting on you shows what to review first","Set it in Settings → Attention; in Teamtrail Cloud, workspace owners set it there too"]},{version:"0.50.0",date:"2026-11-16",items:["On the map, a done ticket’s check is green when its work is verified, grey when it isn’t","Cards say “checks running” while a completion is checked, and a Legend explains the dots"]},{version:"0.49.0",date:"2026-11-16",items:["In Teamtrail Cloud, Start the trail right after New trail, or from the trail’s header: agents start in place","A trail started in the Lookout gets your project’s default verification level, as one an agent starts does"]},{version:"0.48.1",date:"2026-11-16",items:["Scout’s Get started sits in the bottom-right corner; adding your own check shows examples"]},{version:"0.48.0",date:"2026-11-16",items:["In Teamtrail Cloud, Scout keeps Get started in the corner until your workspace is set up"]},{version:"0.47.0",date:"2026-11-16",items:["Set the checks every finished ticket must pass in Settings → Verification, no file to edit"]},{version:"0.46.0",date:"2026-11-16",items:["In Teamtrail Cloud, Approve and merge on a verified ticket merges its pull request at the commit that was checked"]},{version:"0.45.0",date:"2026-11-16",items:["In Teamtrail Cloud, Run agents on the trail takes you straight to its agents"]},{version:"0.44.2",date:"2026-11-16",items:["The middle of the Lookout gets the same margin at the top as at its sides"]},{version:"0.44.1",date:"2026-11-16",items:["Text you type in forms is full size (14px) again, not the small caps of the label above it"]},{version:"0.44.0",date:"2026-11-16",items:["In a hosted Lookout, the theme toggle and Settings → Appearance change your theme on the server too"]},{version:"0.43.1",date:"2026-11-15",items:["In a hosted Lookout that keeps your trails itself, Settings → Tracker says so instead of offering trackers"]},{version:"0.43.0",date:"2026-11-15",items:["Where the server runs your agents, the Lookout says to turn them on for a trail there, instead of offering /scout commands for an agent of your own"]},{version:"0.42.0",date:"2026-11-15",items:["A hosted Lookout has your menu in its header: back to all your workspaces, the server’s own pages, and Sign out","Where the server keeps your trails itself, the Lookout asks no tracker questions on its first run"]},{version:"0.41.0",date:"2026-11-15",items:["In a hosted Lookout, someone who may not make high-risk calls sees who can answer or approve one, instead of a box that would turn their answer away"]},{version:"0.40.0",date:"2026-11-15",items:["Decisions now say who made the call: your name from git on this machine, or the person signed in to a hosted Lookout, in the Logbook and in Verified by Teamtrail proofs","A hosted Lookout opens in the theme you picked in your account there"]},{version:"0.39.0",date:"2026-11-15",items:["A server that hosts Teamtrail can run a remote agent's checks on its pushed work, so that work is verified and its proof counts, like work done on your machine"]},{version:"0.38.0",date:"2026-11-15",items:["Decision memory: before an agent asks you something you already decided, Teamtrail hands it your earlier decision instead, and shows it next to the question if the agent asks anyway","Waiting on you flags finished work that changes files one of your decisions covers, so a later change never quietly undoes it","The Logbook groups decisions by area, the most cited first; share a project's decisions with your other projects in Settings → Projects"]},{version:"0.37.0",date:"2026-11-15",items:["Trail stats has a Scorecard: how each model, agent and vendor does on your own tickets, verified first time, rework and cost per verified ticket, with small samples marked too few","Settings → Model matching suggests a tier per ticket type when one model clearly does better on your repo, with the numbers; nothing changes until you take it","Copy the scorecard as Markdown to share it with your team"]},{version:"0.36.0",date:"2026-11-15",items:["Proof reports are signed with your machine's key: commit the key file Teamtrail writes in .teamtrail/proof-keys, and anyone can check a report with `teamtrail proof verify`","A GitHub Action, Verified by Teamtrail, checks every proof on a pull request and can be made a required check, so a PR without a valid proof can't merge","The ticket inspector shows the proof, with Copy for PR and a link to the comment once it is posted"]},{version:"0.35.0",date:"2026-11-15",items:["Settings → Project → Proof on pull requests: switch it on and Teamtrail posts each done ticket's report on its open pull request, updating the same comment as things change","A Teamtrail proof check sits next to CI on the pull request and passes only when the ticket is verified at its latest commit"]},{version:"0.34.0",date:"2026-11-15",items:["Verified by Teamtrail: `teamtrail proof <ticket>` prints what Teamtrail recorded about a ticket's completion (the checks it ran, criteria verified or only claimed, the review and the decisions it relies on), ready for a pull request","Agents get the same report from the new `proof_report` tool and put it in their pull requests","The report opens with a Teamtrail verified or not verified badge"]},{version:"0.33.1",date:"2026-11-14",items:["Teamtrail is now MIT licensed"]},{version:"0.33.0",date:"2026-11-14",items:["`teamtrail connect claude` offers to turn on Claude Code's sandbox, so the agent's shell commands can't reach Teamtrail's config folder either"]},...zC,...FC];function HC(){return i.jsxs("div",{className:"changelog",children:[i.jsxs("div",{className:"about",children:[i.jsx(xa,{className:"about-name"}),i.jsx("span",{className:"mono-label",children:Z.category}),i.jsx("p",{className:"onb-tagline",children:Z.tagline}),i.jsx(V,{parts:[Z.assistant.name]})]}),i.jsx(Ee,{title:"Next",children:UC.map(e=>i.jsxs("div",{className:"cl-row",children:[i.jsx("span",{className:"mono-label",children:e.area}),i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})]},e.area))}),WC.map(e=>i.jsx(Ee,{title:`${e.version} · ${e.date}`,children:i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})},e.version))]})}const ep={checks:"Completions run these commands on this machine",catalogs:"Guides can then be searched for and added from these addresses",policy:"Agents may then decide these alone",brief:"Implementation tickets of the trail open up",criteria:"These criteria define done for the ticket",knowledge:"Agents get it as trusted context with their claims",level:"Completions on it are checked this much",type:"The trail's level applies to a ticket by its type",state:"Accepting signs it as yours on this machine: gates then read the file as it is",discovery:"Agents may claim its implementation tickets without a discovery brief, and criteria are no longer required"},tp={checks:"Approval covers these commands, not what they run: npm run check runs package.json scripts, and an agent can edit those.",catalogs:"Approval covers where guides come from, not the guides: each one is still shown whole and approved on its own."};function Nv(e){return e.kind==="state"?KC(e):e.committed===!1?"Not committed, so shown whole":e.standing==="elsewhere"?"Came with the repo, never approved on this machine":"Changed since you approved it here"}function KC(e){const t="Changed by a teammate or an agent outside Teamtrail";return e.standing==="elsewhere"?`${t}, or came with the repo · never signed on this machine`:e.committed===!1?`${t} · not committed`:t}const VC="Until you decide, Teamtrail uses the values it signed: a changed ticket is held for you, and a decision nobody signed here does not count. Accept signs the change as yours on this machine; Revert writes the signed values back into the file.";function GC(e){return`${e} committed ${e===1?"thing":"things"} in this repo say they were approved, or record a trail's state, but nothing on this machine signed them: a fresh clone, a teammate's push, or an upgrade from before they were kept per machine. Look them over, then approve them in one step. After that, only what Teamtrail writes here, and what you approve one at a time, counts.`}const qC=["Kept in your config folder, never in the repo","A repo moved to another folder is asked again","This stops an agent that can only write files in the repo, and a teammate's push. An agent that can read your home folder can read the key, and any local agent can answer questions with answer_question","An agent whose sandbox can write your config folder can approve for itself (teamtrail approve --hash, or approvals.json); where the sandbox blocks that folder, Teamtrail fails closed","A trail's state (ticket types, states, claims, blockers, levels, the trail's mode, decisions, assumptions) counts only as Teamtrail wrote it here, so a teammate's push shows as changed outside Teamtrail until you accept it on this machine. An agent that can write your config folder can forge that record too"];function QC(e){const{queue:t}=e;return i.jsx(be,{as:"li",className:"ap-row",edge:"attention",title:`${t.writes} tracker writes queued before the upgrade`,context:i.jsx(V,{parts:[`For ${t.targets.join(", ")}`]}),below:i.jsxs("div",{className:"ap-below",children:[i.jsx("pre",{className:"ap-lines t-code",children:t.labels.join(`
|
|
143
|
+
`),trailing:hn(e.now-t.since),onOpen:e.onOpen,actions:i.jsx(Qb,{title:t.title,canDismiss:Jj(t),onSnooze:e.onSnooze,onDismiss:e.onDismiss}),below:i.jsx(Bb,{item:t})})}function Xb(e){const t=[];for(const s of e){const o=t.at(-1);(o==null?void 0:o.key)===s.batchKey?o.items.push(s):t.push({key:s.batchKey,kind:s.kind,mapId:s.mapId,items:[s]})}return t}const Zb={question:"inbox-list",approval:"inbox-list approvals"};function e$(e){const{batch:t}=e,s=t.items.length>1,o=t.kind==="question"?"answer together":"review together",a=[`${t.items.length} ${Wb[t.kind]}`,e.trail,o].filter(Boolean);return i.jsxs("div",{className:`att-batch ${s?"many":""}`,children:[s&&i.jsx("span",{className:"batch-head t-label",children:a.join(" · ")}),i.jsx("ul",{className:`att-list ${Zb[t.kind]??""}`,children:e.children})]})}function Hm(e,t){e.ticketId?t.openTicket(e.mapId,e.ticketId):t.selectTrail(e.mapId)}const t$=new Set(["approval","blocked","policy","precedent","flag","stalled","hitl-ready","overlap","integration","model","tracker-settings"]);function dv(e,t){if(t$.has(e.kind))return Hm(e,t);switch(e.kind){case"question":return t.openQuestion(e.ref);case"knowledge":return t.openKnowledge();case"brief":return t.openBrief(e.mapId);case"reroute":case"reroute-suggested":return t.openReroute(e);case"guide":case"guide-checks":return t.openGuides();case"delivery":return t.openConnector(e.ref);case"trust":return t.openApprovals();default:return Hm(e,t)}}function n$(e){const t=Xt(1e3),{view:s}=e;if(!s.items.length)return i.jsx(Sn,{title:"Nothing waiting on you",hint:s.hidden?`${s.hidden} snoozed or set aside. They come back when the snooze ends.`:"When an agent needs your call, it lands here, most important first."});const o=Object.keys(e.snaps).length>1,a=h=>o&&h!==e.currentMapId,l=new Set(s.interrupting),d=h=>{var f;return(f=e.pending.find(p=>p.id===h))==null?void 0:f.sessionId};return i.jsx("div",{className:"attention-queue",children:Xb(s.items).map(h=>{var f;return i.jsx(e$,{batch:h,trail:a(h.mapId)?(f=e.snaps[h.mapId])==null?void 0:f.map.title:void 0,children:h.items.map(p=>i.jsx(Jb,{item:p,snap:e.snaps[p.mapId],otherTrail:a(p.mapId)&&h.items.length<2,selected:p.kind==="question"&&d(p.ref)===e.selected,interrupting:l.has(p.id),now:t,onOpen:()=>dv(p,e.handlers),onSnooze:v=>e.onSnooze(p.id,v),onDismiss:()=>e.onDismiss(p.id)},p.id))},h.key)})})}const Km={label:"Focus for 1 hour",change:{kind:"for",minutes:60}};function s$(e){switch(e.kind){case"manual":case"hours":return[{label:"End focus now",change:{kind:"end"},primary:!0}];case"paused":return[{label:"Resume quiet hours",change:{kind:"resume"},primary:!0},Km];case"off":return[{...Km,primary:!0},{label:"Focus for 3 hours",change:{kind:"for",minutes:180}}];default:return e}}const Vm=e=>ha(e).slice(0,5),i$=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function r$(e){const t=`${e.items.length} waiting on you`;return e.heldBack===0?`Nothing held back · ${t}`:`${i$(e.heldBack,"item")} would interrupt you · ${t}`}function _c(e){const t=e.prefs.focus;return t?`Quiet hours ${t.from}–${t.to}`:"No quiet hours set"}const Gm=e=>`Items scoring ${e.policy.value.interrupt} or more interrupt you · ${e.items.length} waiting on you`;function o$(e){const t=e.focus;switch(t.kind){case"manual":case"hours":{const s=Vm(t.until),o=t.kind==="manual"?"Switched on here":_c(e);return{word:"on",until:s,on:!0,title:`Focus is on until ${s}`,reason:o,detail:r$(e)}}case"paused":{const s=Vm(t.until),o=`Quiet hours paused until ${s}`;return{word:"paused",until:s,on:!1,title:o,reason:_c(e),detail:Gm(e)}}case"off":return{word:"off",until:"",on:!1,title:"Focus is off",reason:_c(e),detail:Gm(e)};default:return t}}const a$="Focus holds back interruptions: no browser notifications or Slack messages, even for urgent items. Nothing is answered or dropped: everything still waits in Waiting on you and the Slack digest. Quiet hours turn it on every day; you can also focus for a while or end it early. This stays on this machine.";function l$(e){const{view:t}=e,s=o$(t),o=t.focus.kind,a=i.jsxs("span",{className:Ge("focus-state",`focus-${o}`),children:[i.jsx("i",{className:"focus-dot","aria-hidden":"true"}),i.jsxs("span",{className:"focus-label",children:["Focus",i.jsxs("span",{className:"focus-word",children:[" ",s.word]})]}),s.until&&i.jsxs("span",{className:"focus-until",children:[i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:"focus-until-word",children:"until "}),s.until]})]});return i.jsx(Fd,{className:"focus-menu",label:a,role:"dialog",tip:s.title,ariaLabel:s.title,children:l=>i.jsxs("div",{className:"focus-panel","aria-label":"Focus",children:[i.jsxs("div",{className:"focus-panel-head",children:[i.jsx("span",{className:"t-row-title",children:s.title}),i.jsx(ii,{text:a$})]}),i.jsx(V,{parts:[s.reason]}),i.jsx(V,{className:"focus-held",parts:[s.detail]}),i.jsxs("div",{className:"focus-panel-actions",children:[s$(t.focus).map(d=>i.jsx(M,{size:"sm",variant:d.primary?"primary":"default",onClick:()=>{l(),e.onChange(d.change)},children:d.label},d.label)),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>{l(),e.onSettings()},children:"Quiet hours"})]})]})})}function c$(e){const{view:t}=e,s=t.interrupting.length;return i.jsxs("span",{className:"attention-head",children:[i.jsx(l$,{view:t,onChange:e.onFocus,onSettings:e.onSettings}),s>0&&i.jsxs("span",{className:"waiting-chip interrupting",title:`${s} need you now`,children:[i.jsx(oi,{variant:"alert",size:14}),i.jsx("b",{children:s}),i.jsx("span",{className:"wl",children:" need you now"})]})]})}const uv=`${pe()}/attention`,d$=250;async function Dc(e,t,s){var l;const o=await fetch(`${uv}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),a=await o.json().catch(()=>({}));if(!o.ok)throw new Error(((l=a.errors)==null?void 0:l.join("; "))??a.error??`HTTP ${o.status}`);return a}function hv(e){const[t,s]=y.useState(),[o,a]=y.useState(),[l]=y.useState(ni),d=y.useCallback(()=>{const p=l.start();fetch(uv).then(v=>v.ok?v.json():void 0).then(v=>v&&p()&&s(v)).catch(()=>{})},[l]);y.useEffect(()=>si("attention",p=>{l.pushed(),s(JSON.parse(p))}),[l]),y.useEffect(()=>vs(d),[d]),y.useEffect(()=>{const p=setTimeout(d,d$);return()=>clearTimeout(p)},[d,e]);const h=p=>p.then(()=>(a(void 0),d(),!0),v=>(a(v.message),!1)),f=(p,v)=>void Dc(p,"POST",v).then(()=>(a(void 0),d()),k=>a(k.message));return{view:t,error:o,snooze:(p,v)=>f("/snooze",{id:p,minutes:v}),dismiss:p=>f("/dismiss",{id:p}),savePrefs:p=>h(Dc("/prefs","PUT",p)),saveReviewLimit:p=>h(Dc("/review-limit","PUT",{limit:p}))}}function u$(e){return e.prefs.channel!=="browser"?!1:typeof Notification<"u"&&Notification.permission==="granted"}function h$(e){const t=new Notification(`${Z.name} · needs you`,{body:e.title,tag:e.id});t.onclick=()=>{window.focus(),t.close()}}function f$(e){const t=y.useRef();y.useEffect(()=>{if(!e)return;const s=new Set(e.interrupting),o=t.current;if(t.current=s,!(!o||!u$(e)))for(const a of e.items)s.has(a.id)&&!o.has(a.id)&&h$(a)},[e])}function m$(e){const t=Xt(1e3);return e.items.length?i.jsx("ul",{className:"inbox-list approvals",children:e.items.map(s=>{var l;const o=s.kind!=="approve",a=s.mapId!==e.currentMapId?(l=e.snaps[s.mapId])==null?void 0:l.map.title:void 0;return i.jsx(be,{as:"li",edge:o?"attention":"neutral",title:`${o?"Decide":"Approve"}: ${s.title}`,context:i.jsx(V,{parts:[o?"Held":"Verified",{text:s.ticketKey,code:!0},a]}),detail:s.reason,detailText:s.reason,trailing:hn(t-s.at),onOpen:()=>e.onOpen(s.mapId,s.ticketId)},`${s.mapId}/${s.ticketId}`)})}):null}function qm({activity:e}){const t=Xt(1e3),s=ej(e);return i.jsxs("div",{className:"hitl-readout",children:[i.jsx(ln,{layout:"inline",label:"Oldest",value:s.oldestAt?Jt(t-s.oldestAt):"—",urgent:!!s.oldestAt&&t-s.oldestAt>6e4,title:"Oldest open question"}),i.jsx(ln,{layout:"inline",label:"Avg wait",value:s.avgWaitMs!==void 0?Jt(s.avgWaitMs):"—",title:`Average wait over ${s.answered} answered questions`}),i.jsx(ln,{layout:"inline",label:"Answered",value:s.answered})]})}function p$(e){const t=Xt(1e3);return e.items.length?i.jsx("ul",{className:"inbox-list",children:e.items.map(s=>{const o=e.snaps[s.mapId],a=o==null?void 0:o.tickets.find(h=>h.id===s.ticketId),l=s.mapId!==e.currentMapId?o==null?void 0:o.map.title:void 0,d=s.text.split(`
|
|
144
|
+
`)[0];return i.jsx(be,{as:"li",className:s.sessionId===e.selected?"sel":void 0,edge:s.urgency==="blocking"?"urgent":"neutral",selected:s.sessionId===e.selected,title:d,titleText:s.text,context:i.jsx(V,{parts:[s.urgency==="blocking"&&{text:"Blocking",urgent:!0},`${s.agent} asks`,a&&{text:a.key,code:!0},a==null?void 0:a.title,l]}),trailing:hn(t-s.at),onOpen:()=>e.onOpen(s.sessionId,s.ticketId)},s.id)})}):i.jsx(Sn,{title:"Nothing waiting on you",hint:"When an agent needs your call, its question lands here."})}const g$={pass:"Passed",fail:"Failed",error:"Could not run",interrupted:"Interrupted"},ar={off:"Off",checks:"Checks","checks+review":"Checks + review","checks+review+human":"Checks + review + you"},fv={off:"The agent saying “done” closes the ticket right away.",checks:"Your checks (tests, lint, typecheck…) run in the repo first. A failure goes back to the agent with the output.","checks+review":"After the checks pass, a different agent reviews the change. It is never the agent that did the work.","checks+review+human":"After checks and review, you approve it in the inbox before the ticket closes."},v$=e=>e.exitCode===0&&!e.timedOut&&!e.error;async function Qm(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`HTTP ${e.status}`);return t}const Ro=`${pe()}/verification`,fr={ticket:(e,t)=>fetch(`${Ro}/ticket?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`).then(s=>s.ok?s.json():void 0,()=>{}),inbox:()=>fetch(`${Ro}/inbox`).then(e=>e.ok?e.json().then(t=>t.items):[],()=>[]),log:e=>fetch(`${Ro}/log?path=${encodeURIComponent(e)}`).then(t=>Qm(t)),act:e=>fetch(`${Ro}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>Qm(t))};function k$(e){const[t,s]=y.useState([]),o=Object.values(e).map(l=>l.tickets.map(d=>`${d.id}:${d.state}:${d.status??""}`).join()).join("|"),{reload:a}=Ye({version:o,load:fr.inbox,show:s});return y.useEffect(()=>ei.onEvidence(a),[a]),t}function y$(e,t){return{...e,items:e.items.filter(s=>!(s.kind==="brief"&&s.mapId===t))}}function w$(e){var h;const t=[...e.activity.pending].sort((f,p)=>f.at-p.at),s=k$(e.snaps),o=(h=e.attention)==null?void 0:h.view,a=o&&e.briefShown?y$(o,e.currentMapId):o,l=a?a.items.length:t.length+s.length,d=i.jsx(Et,{hot:l>0,title:i.jsxs(i.Fragment,{children:[l>0&&i.jsx(oi,{variant:"alert",size:12}),"Waiting on you"]}),count:i.jsx(fs,{n:l,urgent:l>0,pop:!0},l)});return a&&e.attention&&e.handlers?i.jsxs("div",{className:"inbox-part",children:[d,i.jsx(qm,{activity:e.activity}),i.jsx(n$,{view:a,snaps:e.snaps,pending:e.activity.pending,currentMapId:e.currentMapId,selected:e.sessionId,handlers:e.handlers,onSnooze:e.attention.snooze,onDismiss:e.attention.dismiss})]}):i.jsxs("div",{className:"inbox-part",children:[d,i.jsx(qm,{activity:e.activity}),i.jsx(m$,{items:s,snaps:e.snaps,currentMapId:e.currentMapId,onOpen:e.onOpenTicket}),(t.length>0||!s.length)&&i.jsx(p$,{items:t,snaps:e.snaps,currentMapId:e.currentMapId,selected:e.sessionId,onOpen:e.onOpenQuestion})]})}function x$(e){const[t,s]=y.useState("list"),[o,a]=y.useState();y.useEffect(()=>{e.convRequest&&s("conv")},[e.convRequest]);const l=(v,k)=>{e.onOpen(v,k),s("conv")},d=v=>{const k=e.activity.pending.find(w=>w.id===v);k&&(a(k.id),l(k.sessionId,k.ticketId))},h=i.jsx(w$,{activity:e.activity,snaps:e.snaps,currentMapId:e.currentMapId,sessionId:e.sessionId,attention:e.attention,handlers:e.handlers&&{...e.handlers,openQuestion:d},briefShown:!!e.above,onOpenQuestion:l,onOpenTicket:e.onOpenTicket}),f=i.jsx(Lb,{activity:e.activity,snaps:e.snaps,sessionId:e.sessionId,questionId:o,onAnswer:e.onAnswer,onBack:e.layout==="stack"?()=>s("list"):void 0});if(e.layout==="stack")return i.jsx(Be,{className:"zone inbox stack",children:t==="conv"&&e.sessionId?f:i.jsxs("div",{className:"stack-scroll",children:[e.above,h,e.below]})});const p=!!e.activity.sessions.find(v=>v.id===e.sessionId);return i.jsxs(Be,{className:`zone inbox split ${p?"has-conv":""}`,style:{gridArea:"inbox"},children:[i.jsx(Et,{className:"zone-title",icon:"mailbox",title:"Communication",info:"Where your agents reach you: everything waiting on you, ranked with the reasons why, the conversation with the agent that asked, and the tickets coming up next."}),e.above,h,p&&f,e.below]})}function j$(e){var h;const{snap:t}=e,s=t?ti(t.tickets,t.map.mode):new Map,o={claimed:0,frontier:1},a=((t==null?void 0:t.tickets)??[]).filter(f=>o[s.get(f.id)]!==void 0).sort((f,p)=>o[s.get(f.id)]-o[s.get(p.id)]),l=new Set(e.sessions.filter(Gg).map(f=>f.ticketId)),d=((h=e.selection)==null?void 0:h.kind)==="ticket"?e.selection.id:void 0;return i.jsxs("div",{className:"upnext",children:[i.jsx(Et,{title:"Up next",count:i.jsx("span",{className:"n mono-label",children:a.length})}),!t&&i.jsx(Ie,{children:"Ready tickets show here"}),t&&!a.length&&i.jsx(Ie,{children:"Nothing ready"}),t&&a.length>0&&i.jsx("ul",{className:"ticket-list",children:a.map(f=>{const v={state:s.get(f.id),waiting:l.has(f.id),assignee:f.assignee,hitl:cr(f)==="hitl"},k=S$(v);return i.jsx("li",{className:`${d===f.id?"sel":""} st-${N$(v)}`,children:i.jsxs("button",{onClick:()=>e.onSelect({kind:"ticket",id:f.id}),children:[i.jsx("i",{className:"dot"}),i.jsx("span",{className:"key t-code",children:f.key}),i.jsx("span",{className:"ttl t-body",children:f.title}),i.jsx("span",{className:"st-text t-meta",children:k})]})},f.id)})})]})}function S$(e){if(e.waiting)return"waiting on you";if(e.state==="claimed")return e.assignee??"claimed";const t=Dg[e.state].toLowerCase();return e.hitl?`${t}, needs you`:t}function N$(e){return e.waiting?"waiting":e.state==="frontier"&&e.hitl?"attention":e.state}function b$(e){const{api:t,nav:s}=e;return i.jsx(x$,{activity:t.activity,snaps:t.allSnaps,currentMapId:t.mapId,sessionId:t.chatSession,layout:e.bp==="mobile"?"stack":"split",convRequest:s.convRequest,onOpen:s.openChat,onAnswer:t.actions.answer,onOpenTicket:s.openTicket,attention:e.attn.attention,handlers:e.attn.handlers,below:i.jsx(j$,{snap:t.snap,sessions:e.scoped.sessions,selection:t.selection,onSelect:s.select}),above:e.above})}function Na({command:e,label:t="Copy"}){const[s,o]=y.useState(!1);return i.jsxs("span",{className:"agent-cmd",children:[i.jsx("code",{children:e}),i.jsx("button",{type:"button",className:"btn sm","data-tip":"Copy, then paste it in Claude Code or Codex",onClick:()=>void navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)}),children:s?"Copied":t})]})}const Mo=[{text:"Agents pick up ready work from their chat",command:"/scout resume"},{text:"Answer what is waiting on you from the chat",command:"/scout inbox"},{text:"Ask Scout where the trail stands",command:"/scout status"},{text:"Start the next trail from your agent",command:'/scout new "your idea"'},{text:"Click a ticket to zoom in. Scroll or pinch to zoom, drag to pan, Fit to see it all"}],$$=9e3;function C$(){const[e,t]=y.useState(0),[s,o]=y.useState(!1);y.useEffect(()=>{if(s)return;const l=setInterval(()=>t(d=>(d+1)%Mo.length),$$);return()=>clearInterval(l)},[s]);const a=Mo[e];return i.jsxs("div",{className:"command-bar real",children:[i.jsx(Xg,{name:"map"}),i.jsx(ze,{as:"h2",className:"zone-title-label",children:"Trail map"}),i.jsx(ii,{text:"Every decision ticket in this trail and what blocks what. Click a ticket to see it in Trail step. The strip below sums up progress."}),i.jsxs("div",{className:"hint",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocus:()=>o(!0),onBlur:()=>o(!1),children:[i.jsx("span",{className:"dim",children:a.text}),a.command&&i.jsx(Na,{command:a.command})]},e),i.jsxs("button",{type:"button",className:"link hint-next","data-tip":"Next hint","aria-label":"Next hint",onClick:()=>t(l=>(l+1)%Mo.length),children:[e+1,"/",Mo.length," ›"]})]})}function T$(e){const t=[{v:"plan+execute",title:"Plan + execute"},{v:"plan-only",title:"Plan only"}];return i.jsx("div",{className:"choice-row",children:t.map(s=>i.jsx(ot,{on:e.value===s.v,title:s.title,onClick:()=>e.onChange(s.v)},s.v))})}function E$({created:e,mapId:t,onStarted:s}){if(ja())return i.jsxs("div",{className:"agent-draft created",children:[i.jsxs("span",{children:["Trail ",e," is on the map, starting with discovery."]}),i.jsx(nv,{mapId:t,onStarted:s})]});const o=zt();return o?i.jsxs("div",{className:"agent-draft created",children:[i.jsxs("span",{children:["Trail ",e," is on the map, starting with discovery. Turn your agents on for it to get it moving."]}),i.jsx(M,{onClick:ev,children:o.label})]}):i.jsxs("div",{className:"agent-draft created",children:[i.jsxs("span",{children:["Trail ",e," is on the map, starting with discovery. To get it moving, run this in Claude Code or Codex:"]}),i.jsx(Na,{command:"/scout resume",label:"Copy command"})]})}function A$({seed:e,onClose:t,tracker:s,onCreate:o}){const[a,l]=y.useState(),[d,h]=y.useState(!1),[f,p]=y.useState(),[v,k]=y.useState((e==null?void 0:e.title)??""),[w,j]=y.useState((e==null?void 0:e.destination)??""),[N,S]=y.useState((e==null?void 0:e.notes)??""),[I,$]=y.useState((e==null?void 0:e.assumptions.join(`
|
|
145
|
+
`))??""),_=[v.trim(),w.trim(),N.trim()].filter(Boolean).join(". ").replace(/"/g,"'");return y.useEffect(()=>{const O=D=>D.key==="Escape"&&t();return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[t]),i.jsx("div",{className:"scrim",onClick:t,children:i.jsxs(Be,{as:"div",className:"dialog",onClick:O=>O.stopPropagation(),children:[i.jsx("header",{children:i.jsx("h2",{className:"t-heading caps",children:e?"Start over":"New trail"})}),i.jsx(Ze,{label:"Title",children:i.jsx("input",{value:v,onChange:O=>k(O.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Destination",children:i.jsx("textarea",{rows:3,value:w,onChange:O=>j(O.target.value),placeholder:"What is true when this trail is done?"})}),i.jsx(Ze,{label:"Notes",children:i.jsx("textarea",{rows:2,value:N,onChange:O=>S(O.target.value)})}),i.jsx(Ze,{label:"Assumptions (optional, one per line)",children:i.jsx("textarea",{className:"new-trail-assumptions",rows:2,value:I,onChange:O=>$(O.target.value),placeholder:"What the plan takes for granted, e.g. The v2 API supports batch writes"})}),!zt()&&i.jsxs("div",{className:"agent-draft",children:[i.jsxs("span",{className:"dim",children:["Paste this in Claude Code or Codex. Scout frames the trail with you there, then charts it here in"," ",s,"."]}),i.jsx(Na,{command:`/scout new "${_||"your idea"}"`,label:"Copy command"})]}),a?i.jsx(E$,{created:a.key,mapId:a.id,onStarted:t}):f&&i.jsx("p",{className:"vf-err",children:f}),i.jsxs("footer",{children:[i.jsx(M,{variant:"ghost",onClick:t,children:"Close"}),!a&&i.jsx(M,{variant:"primary",disabled:d||!v.trim()||!w.trim(),"data-tip":zt()?"Put the trail on the map now, then turn your agents on for it":"Put the trail on the map now; any agent picks it up with /scout resume",onClick:()=>{h(!0);const O=I.split(`
|
|
146
|
+
`).map(D=>D.trim());o({title:v.trim(),destination:w.trim(),notes:N.trim(),assumptions:O.filter(Boolean)}).then(D=>l({key:D.key,id:D.id})).catch(D=>p(D.message)).finally(()=>h(!1))},children:"Create trail"})]})]})})}const I$=e=>({title:e.title,destination:e.sections.destination,notes:e.sections.notes,assumptions:(e.sections.assumptions??[]).filter(t=>t.status!=="invalidated").map(t=>t.text)});function R$(e){return i.jsx(A$,{seed:e.seed,onClose:e.onClose,tracker:e.rt.adapter.label,onCreate:async t=>{const s=await m1(e.rt.adapter,t);return e.onCreated(s.id),s}})}function M$(e,t){const[s,o]=y.useState(!1);return{open:()=>o(!0),startOver:d=>void t.actions.setArchived(!0).then(()=>o(I$(d))),dialog:s&&i.jsx(R$,{rt:e,seed:typeof s=="object"?s:void 0,onClose:()=>o(!1),onCreated:d=>t.actions.selectMap(d)})}}const L$={gh:"your gh login",GITHUB_TOKEN:"GITHUB_TOKEN",GH_TOKEN:"GH_TOKEN",stored:"a saved token","signed-in":"your GitHub sign-in",LINEAR_API_KEY:"LINEAR_API_KEY"},Hd=e=>L$[e];function Kd(e){var t;return((t=e.account)==null?void 0:t.kind)==="user"?e.account.login:void 0}const zc=e=>!!e.auth&&!!Kd(e);function mv(e,t){const s=Kd(e);return!e.auth||!s?void 0:`Will use ${t||"the repo you pick"} as ${s} (${Hd(e.auth)})`}function O$(e){if(!e.repo)return;const t=Kd(e),s=t?` as ${t}`:"",o=e.auth?`, using ${Hd(e.auth)}`:"";return`Connected to ${e.repo}${s}${o}`}function P$(e,t){if(!e.pushedAt)return;const s=Math.floor((t-Date.parse(e.pushedAt))/864e5);return s<1?"Pushed today":s<60?`Pushed ${s}d ago`:`Pushed ${Math.floor(s/30)}mo ago`}function _$(e){const{gh:t}=e;if(!t.auth)return null;const s=mv(t,e.repo);return i.jsxs("div",{className:"gh-identity",children:[s&&i.jsx("span",{className:"t-body",children:s}),i.jsxs("span",{className:"gh-identity-actions",children:[i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another token"}),t.auth==="signed-in"&&i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onSignOut,title:"Forgets the token on this machine. To revoke it, remove Teamtrail under GitHub → Settings → Applications.",children:"Sign out"})]})]})}const D$=/^[\w.-]+\/[\w.-]+$/;function z$(e){const t=e.query.trim().toLowerCase(),o=!!e.detected&&e.repos.every(f=>f.fullName!==e.detected)?[{fullName:e.detected,private:!1},...e.repos]:e.repos,a=[...o.filter(f=>f.fullName===e.detected),...o.filter(f=>f.fullName!==e.detected)],l=t?a.filter(f=>f.fullName.toLowerCase().includes(t)):a,h=D$.test(e.query.trim())&&l.every(f=>f.fullName.toLowerCase()!==t)?e.query.trim():void 0;return{shown:l.slice(0,e.limit),matches:l.length,typed:h}}function Ym(e){const{repo:t,listed:s}=e,o=t.private?"Private":"Public";return i.jsx(be,{as:"li",className:"repo-row",selected:e.selected,title:i.jsx("span",{className:"t-code",children:t.fullName}),context:i.jsx(V,{parts:[e.detected&&{text:"This project's repo",strong:!0},s&&o,s&&P$(t,e.now),!s&&"Checked when you connect"]}),onOpen:e.onPick})}const B$=40;function Jm(e){const[t,s]=y.useState(""),o=y.useMemo(()=>Date.now(),[]),a=y.useMemo(()=>new Set(e.repos.map(v=>v.fullName)),[e.repos]),{shown:l,matches:d,typed:h}=z$({repos:e.repos,detected:e.detected,query:t,limit:B$}),f=d>l.length?`${d-l.length} more: type to narrow`:"",p=e.truncated?`Your ${e.repos.length} most recently pushed repos`:"";return i.jsxs("div",{className:"repo-picker",children:[i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:t,placeholder:"Search your repos, or type owner/name",spellCheck:!1,"aria-label":"Search repositories",onChange:v=>s(v.target.value)})]}),i.jsxs("ul",{className:"repo-list","aria-label":"Repositories",children:[h&&i.jsx(Ym,{repo:{fullName:h,private:!1},detected:h===e.detected,listed:!1,selected:h===e.value,now:o,onPick:()=>e.onChange(h)}),l.map(v=>i.jsx(Ym,{repo:v,detected:v.fullName===e.detected,listed:a.has(v.fullName),selected:v.fullName===e.value,now:o,onPick:()=>e.onChange(v.fullName)},v.fullName))]}),i.jsx(V,{parts:[!d&&!h&&"No repo matches",f,p]})]})}function F$(e){const{list:t}=e;if(!t)return i.jsx(ri,{label:"Loading your repos…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(Jm,{repos:t.repos,truncated:t.truncated,detected:t.detectedRepo??e.detected,value:e.value,onChange:e.onChange});case"no-token":return i.jsx(V,{parts:["No GitHub token found"]});case"error":return i.jsxs(i.Fragment,{children:[i.jsx(zd,{what:"Couldn't list your repos",reason:t.error,onRetry:e.onRetry}),i.jsx(Jm,{repos:[],truncated:!1,detected:e.detected,value:e.value,onChange:e.onChange})]});default:return t}}const U$={stored:"Saved token",gh:"gh CLI",GITHUB_TOKEN:"$GITHUB_TOKEN",GH_TOKEN:"$GH_TOKEN","signed-in":"Signed in with GitHub",LINEAR_API_KEY:"$LINEAR_API_KEY"},nr=e=>e==="github"||e==="linear";function pv(e){const[t,s]=y.useState(!e.source);return e.source&&!t?i.jsxs("div",{className:"ts-auth",children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("span",{className:"pill on",children:U$[e.source]}),i.jsx("button",{type:"button",className:"btn ghost sm",onClick:()=>s(!0),children:"Use another"})]}):i.jsxs("label",{className:"field",children:[i.jsxs("span",{className:"ts-label",children:[e.label,e.link&&i.jsx("a",{href:e.link.href,target:"_blank",rel:"noreferrer",children:e.link.text})]}),i.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:e.value,placeholder:e.placeholder,onChange:o=>e.onChange(o.target.value)})]})}function W$(e){const[t,s]=y.useState(!1),o=()=>{var a;return void((a=navigator.clipboard)==null?void 0:a.writeText(e.code).then(()=>s(!0),()=>{}))};return i.jsxs("div",{className:"gh-device",children:[i.jsx("span",{className:"t-label",children:"Enter this code on GitHub"}),i.jsxs("div",{className:"gh-device-row",children:[i.jsx("code",{className:"gh-device-code t-code","aria-label":"Your code",children:e.code}),i.jsx(M,{size:"sm",variant:"ghost",onClick:o,children:t?"Copied":"Copy"})]}),i.jsxs("div",{className:"gh-device-row",children:[i.jsx("a",{className:"btn primary",href:Nn(e.href),target:"_blank",rel:"noreferrer",onClick:o,children:"Open GitHub"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]}),i.jsx(ri,{label:"Waiting for you to approve on GitHub…"})]})}function H$(e){switch(e.kind){case"code":return{kind:"code",userCode:e.userCode,verificationUri:e.verificationUri,interval:e.interval,asked:0};case"unavailable":return{kind:"ended",reason:"Sign in with GitHub isn’t set up in this build"};case"error":return{kind:"ended",reason:e.error};default:return e}}function K$(e,t){switch(t.kind){case"waiting":return{...e,interval:t.interval,asked:e.asked+1};case"signed-in":return{kind:"idle"};case"expired":return{kind:"ended",reason:"The code expired before it was approved"};case"denied":return{kind:"ended",reason:"The sign-in was declined on GitHub"};case"none":return{kind:"ended",reason:"The sign-in was stopped"};case"error":return{kind:"ended",reason:t.error};default:return t}}const Bt=A0(pe());function sr(e,t){e({tracker:t});const s=new URL(location.href);s.searchParams.delete("tracker"),location.href=s.toString()}function V$(e){const[t,s]=y.useState({kind:"idle"}),o=y.useRef(e);o.current=e;const a=t.kind==="code";return y.useEffect(()=>{if(t.kind!=="code")return;let l=!0;const d=setTimeout(()=>void Bt.githubSignIn.poll().then(async h=>{l&&(h.kind==="signed-in"&&await o.current(),l&&s(K$(t,h)))},h=>l&&s({kind:"ended",reason:h.message})),Math.max(t.interval,1)*1e3);return()=>{l=!1,clearTimeout(d)}},[t]),y.useEffect(()=>{if(a)return()=>void Bt.githubSignIn.cancel().catch(()=>{})},[a]),{state:t,start(){s({kind:"starting"}),Bt.githubSignIn.start().then(l=>s(H$(l)),l=>s({kind:"ended",reason:l.message}))},cancel(){s({kind:"idle"})}}}function G$(e){const{state:t,start:s,cancel:o}=V$(e.onSignedIn);switch(t.kind){case"idle":return i.jsxs("div",{className:"gh-sign-in",children:[i.jsx(M,{variant:"primary",onClick:s,children:"Sign in with GitHub"}),i.jsx(V,{parts:["No gh login or token needed","the token stays on this machine"]}),i.jsx(V,{parts:["GitHub asks for access to your repos: it has no narrower scope for issues in private repos"]})]});case"starting":return i.jsx(ri,{label:"Asking GitHub for a code…"});case"code":return i.jsx(W$,{code:t.userCode,href:t.verificationUri,onCancel:o});case"ended":return i.jsxs("div",{className:"gh-sign-in",children:[i.jsx(M,{onClick:s,children:"Try again"}),i.jsx(V,{parts:["Didn't sign in",t.reason]})]});default:return t}}function q$(e){var d,h;const{gh:t}=e,s=t.auth&&((d=t.account)==null?void 0:d.kind)==="unknown"?`Found ${Hd(t.auth)}, but GitHub didn't accept it`:"",o=((h=t.account)==null?void 0:h.kind)==="unknown"?t.account.error:"",a=t.auth==="GITHUB_TOKEN"||t.auth==="GH_TOKEN",l=t.signIn.available&&!a;return i.jsxs(i.Fragment,{children:[s&&i.jsx(V,{parts:[s,o]}),l&&i.jsx(G$,{onSignedIn:e.onSignedIn}),l&&i.jsx("span",{className:"t-label gh-or",children:"Or paste a token"}),i.jsx(pv,{source:null,value:e.token,onChange:e.onToken,label:"Token",placeholder:"ghp_… or github_pat_…",link:{href:"https://github.com/settings/personal-access-tokens/new",text:"New token"}}),i.jsxs("span",{className:"t-meta",children:["Or run ",i.jsx("code",{className:"t-code",children:"gh auth login"})," in a terminal; this finds it in a few seconds."]}),i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:e.repo,placeholder:"owner/name",spellCheck:!1,onChange:f=>e.onRepo(f.target.value.trim())})]})]})}function gv({r:e}){var o,a;if(!e)return null;if(!e.ok)return i.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]});const t=(o=e.rate)!=null&&o.limit?`${(a=e.rate.remaining)==null?void 0:a.toLocaleString()}/${e.rate.limit.toLocaleString()} req`:"";let s="";return e.canWrite===!1?s="read-only":e.canWrite&&(s="read/write"),i.jsxs("div",{className:"test-line ok",children:["✓ ",[e.account,e.target,s,t].filter(Boolean).join(" · ")]})}function Vd(e){const[t,s]=y.useState(),[o,a]=y.useState(0);y.useEffect(()=>{if(s(void 0),!e.enabled)return;let d=!0;return e.load().then(h=>d&&s(h),h=>d&&s(e.failed(h.message))),()=>{d=!1}},[e.enabled,e.key,o]);const l=y.useCallback(()=>a(d=>d+1),[]);return{value:t,retry:l}}function Q$(e){const{value:t,retry:s}=Vd({enabled:e.enabled,key:e.auth??"",load:()=>Bt.githubRepos(),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function vv(e){const t=e.s.github,s=zc(t),[o,a]=y.useState(!s),[l,d]=y.useState(t.repo??t.detectedRepo??""),[h,f]=y.useState(""),[p,v]=y.useState(),[k,w]=y.useState(!1),{list:j,retry:N}=Q$({enabled:!o,auth:t.auth});y.useEffect(()=>{s&&!h&&a(!1)},[s]);const S=async()=>{w(!0),v(void 0);try{await Bt.connect({active:"github",github:{repo:l,token:o?h:void 0}}),e.onConnected()}catch(D){v({ok:!1,error:D.message}),w(!1)}},I=async()=>{const D=await e.reload();D&&zc(D.github)&&a(!1)},$=async()=>{await Bt.githubSignIn.signOut().catch(()=>{});const D=await e.reload();a(!D||!zc(D.github))},O=!!l&&!(!o&&!j)&&(!o||!!h||s);return i.jsxs("div",{className:"card inset tracker-setup",children:[o?i.jsx(q$,{gh:t,token:h,onToken:f,repo:l,onRepo:d,onSignedIn:I}):i.jsxs(i.Fragment,{children:[i.jsx(_$,{gh:t,repo:l,onUseAnother:()=>a(!0),onSignOut:()=>void $()}),i.jsx(F$,{list:j,detected:t.detectedRepo,value:l,onChange:d,onRetry:N})]}),i.jsx(gv,{r:p}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:k||!O,onClick:()=>void S(),children:k?"Connecting…":"Connect"})})]})}function Y$(e){return e.line?i.jsxs("div",{className:"gh-identity",children:[i.jsxs("div",{className:"ln-who",children:[i.jsx("span",{className:"t-body",children:e.line}),e.email&&i.jsx(V,{parts:[e.email]})]}),e.onUseAnother&&i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another key"})]}):null}const J$={LINEAR_API_KEY:"LINEAR_API_KEY",stored:"a saved key"},Gd=e=>J$[e]??e;function ba(e){return(e==null?void 0:e.kind)==="user"?e:void 0}const X$=e=>!!e.auth&&!!ba(e.viewer);function kv(e,t){if(e)return t?`${e} / ${t}`:e}function yv(e){const t=ba(e.viewer);if(!t)return;const s=kv(e.team,e.project)??"the team you pick",o=e.source?` (${Gd(e.source)})`:"";return`Will use ${s} in ${t.orgName} as ${t.name}${o}`}function Z$(e){const t=kv(e.teamName??e.teamKey,e.projectName);if(!e.teamId||!t)return;const s=ba(e.viewer),o=e.orgName??(s==null?void 0:s.orgName),a=o?` in ${o}`:"",l=s?` as ${s.name}`:"",d=e.auth?`, using ${Gd(e.auth)}`:"";return`Connected to ${t}${a}${l}${d}`}function eC(e,t){if(!e.activeAt)return"No issues yet";const s=Math.floor((t-Date.parse(e.activeAt))/864e5);return s<1?"Active today":s<60?`Active ${s}d ago`:`Active ${Math.floor(s/30)}mo ago`}function tC(e){var a,l;const{ln:t}=e,s=t.auth&&((a=t.viewer)==null?void 0:a.kind)==="unknown"?`Found ${Gd(t.auth)}, but Linear didn't accept it`:"",o=((l=t.viewer)==null?void 0:l.kind)==="unknown"?t.viewer.error:"";return i.jsxs(i.Fragment,{children:[s&&i.jsx(V,{parts:[s,o]}),i.jsx(pv,{source:null,value:e.apiKey,onChange:e.onKey,label:"API key",placeholder:"lin_api_…",link:{href:"https://linear.app/settings/account/security",text:"New key"}}),i.jsxs("span",{className:"t-meta",children:["Or set ",i.jsx("code",{className:"t-code",children:"LINEAR_API_KEY"})," before starting Teamtrail."]})]})}function nC(e){const{list:t}=e;if(!t)return i.jsx(ri,{label:"Loading projects…"});if(t.kind==="error")return i.jsx(zd,{what:"Couldn't list the team's projects",reason:t.error,onRetry:e.onRetry});if(t.kind!=="ok"||!t.projects.length)return null;const s=[{value:"",label:"All projects"},...t.projects.map(o=>({value:o.id,label:o.state?`${o.name} · ${o.state}`:o.name}))];return i.jsxs("label",{className:"field",children:["Project (optional)",i.jsx(at,{"aria-label":"Project",value:e.value,onChange:e.onChange,options:s})]})}function sC(e){const t=e.query.trim().toLowerCase(),s=t?e.teams.filter(o=>o.key.toLowerCase().includes(t)||o.name.toLowerCase().includes(t)):e.teams;return{shown:s.slice(0,e.limit),matches:s.length}}function iC(e,t){return t&&e.some(s=>s.id===t)?t:e.length===1?e[0].id:void 0}function rC(e){const{team:t}=e;return i.jsx(be,{as:"li",className:"repo-row team-row",selected:e.selected,title:t.name,context:i.jsx(V,{parts:[{text:t.key,code:!0},eC(t,e.now)]}),onOpen:e.onPick})}const oC=40;function aC(e){const[t,s]=y.useState(""),o=y.useMemo(()=>Date.now(),[]),{shown:a,matches:l}=sC({teams:e.teams,query:t,limit:oC}),d=l>a.length?`${l-a.length} more: type to narrow`:"",h=e.truncated?`The first ${e.teams.length} teams`:"",f=e.value?"":"Pick the team your trails go in";return i.jsxs("div",{className:"repo-picker",children:[i.jsxs("label",{className:"field",children:["Team",i.jsx("input",{value:t,placeholder:"Search your teams by key or name",spellCheck:!1,"aria-label":"Search teams",onChange:p=>s(p.target.value)})]}),i.jsx("ul",{className:"repo-list","aria-label":"Teams",children:a.map(p=>i.jsx(rC,{team:p,selected:p.id===e.value,now:o,onPick:()=>e.onChange(p.id)},p.id))}),i.jsx(V,{parts:[!l&&"No team matches",f,d,h]})]})}function lC(e){const{list:t}=e;if(!t)return i.jsx(ri,{label:"Loading teams…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(aC,{teams:t.teams,truncated:t.truncated,value:e.value,onChange:e.onChange});case"no-key":return i.jsx(V,{parts:["Paste a Linear API key to list your teams"]});case"error":return i.jsx(zd,{what:"Couldn't list your teams",reason:t.error,onRetry:e.onRetry});default:return t}}function cC(e,t){const[s,o]=y.useState(e);return y.useEffect(()=>{const a=setTimeout(()=>o(e),t);return()=>clearTimeout(a)},[e,t]),s}function dC(e){const{value:t,retry:s}=Vd({enabled:e.enabled&&!!e.teamId,key:`${e.teamId}
|
|
147
|
+
${e.apiKey??""}`,load:()=>Bt.linearProjects(e.teamId,e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function uC(e){const{value:t,retry:s}=Vd({enabled:e.enabled,key:e.apiKey??"",load:()=>Bt.linearTeams(e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function hC(e){const t=cC(e.apiKey.trim(),400),s=e.paste&&t?t:void 0,o=e.paste?!!t:!!e.ln.auth,a=uC({enabled:o,apiKey:s}),l=dC({teamId:e.teamId,apiKey:s,enabled:o}),d=a.list,h=l.list,f=(d==null?void 0:d.kind)==="ok"?d.teams:[],p=o&&!d,v=o&&!!e.teamId&&!h;return{enabled:o,list:d,teams:f,projects:h,loading:p||v,retryTeams:a.retry,retryProjects:l.retry}}function wv(e){var ne;const t=e.s.linear,s=X$(t),[o,a]=y.useState(!s),[l,d]=y.useState(""),[h,f]=y.useState(t.teamId??""),[p,v]=y.useState(t.projectId??""),[k,w]=y.useState(),[j,N]=y.useState(!1),{enabled:S,list:I,teams:$,projects:_,loading:O,retryTeams:D,retryProjects:q}=hC({ln:t,paste:o,apiKey:l,teamId:h});y.useEffect(()=>{s&&!l&&a(!1)},[s]),y.useEffect(()=>{(I==null?void 0:I.kind)==="ok"&&f(iC(I.teams,t.teamId)??"")},[I]);const H=$.find(ce=>ce.id===h),G=(_==null?void 0:_.kind)==="ok"?_.projects.find(ce=>ce.id===p):void 0,oe=(I==null?void 0:I.kind)==="ok"?I.viewer:t.viewer,Q=o?null:t.auth,ke=yv({viewer:oe,team:H==null?void 0:H.name,project:G==null?void 0:G.name,source:Q}),Oe=async()=>{if(H){N(!0),w(void 0);try{await Bt.connect({active:"linear",linear:{teamId:H.id,teamKey:H.key,teamName:H.name,projectId:G==null?void 0:G.id,projectName:G==null?void 0:G.name,apiKey:o?l.trim():void 0}}),e.onConnected()}catch(ce){w({ok:!1,error:ce.message}),N(!1)}}},Te=ce=>{f(ce),v("")};return i.jsxs("div",{className:"card inset tracker-setup linear-setup",children:[o&&i.jsx(tC,{ln:t,apiKey:l,onKey:d}),i.jsx(Y$,{line:ke,email:(ne=ba(oe))==null?void 0:ne.email,onUseAnother:o?void 0:()=>a(!0)}),S&&i.jsx(lC,{list:I,value:h,onChange:Te,onRetry:D}),H&&i.jsx(nC,{list:_,value:p,onChange:v,onRetry:q}),i.jsx(gv,{r:k}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:j||O||!H,onClick:()=>void Oe(),children:j?"Connecting…":"Connect"})})]})}function fC(e){return i.jsxs("div",{className:"c-actions",children:[e.canSwitch&&i.jsx("button",{className:"btn sm",disabled:!e.usable,onClick:e.onSwitch,children:"Switch"}),e.remote&&i.jsx("button",{className:`btn sm ${e.open?"on":""}`,disabled:!e.usable,onClick:e.onToggle,children:e.configured?"Edit":"Connect"})]})}function mC(e){return["Anything this account writes counts as you, including agents signed in as you",`${e==="github"?"people with write access":"members (not guests)"} can claim, move and close tickets; their decisions show under their name`,"settings they change wait for you in the queue, to accept or keep stricter"]}function pC(e){const{id:t,active:s,s:o}=e,a=nr(t),l=s&&o?gC(t,o):void 0;return l&&a?i.jsxs(i.Fragment,{children:[i.jsx(V,{className:"c-who",parts:[l]}),i.jsx(V,{className:"c-trust",parts:mC(t)})]}):l?i.jsx(V,{className:"c-who",parts:[l]}):s&&(t==="markdown"||a)?i.jsx("div",{className:"c-loc",children:e.location}):a&&e.configured&&o?i.jsx("div",{className:"c-loc",children:vC(t,o)}):null}function gC(e,t){if(e==="github")return O$(t.github);if(e==="linear")return Z$(t.linear)}function vC(e,t){return e==="github"?t.github.repo:[t.linear.teamKey,t.linear.projectName].filter(Boolean).join(" · ")}function kC({status:e}){var l,d;if(!e)return null;const t=(l=e.rate)!=null&&l.limit?`${((d=e.rate.remaining)==null?void 0:d.toLocaleString())??"?"}/${e.rate.limit.toLocaleString()} req`:"",s=e.queued?` · ${e.queued} queued`:"",[o,a]=yC(e,s);return i.jsxs("div",{className:`sync-line ${o}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:a}),t&&i.jsx("span",{className:"rate",children:t})]})}function yC(e,t){switch(e.state){case"online":return["ok",`Online · synced ${_g(e.lastSyncAt)}${t}`];case"offline":return["warn",`Offline${t}`];case"rate-limited":return["warn",`Rate limited · resumes ${hr(e.resetAt)}${t}`];case"auth-error":return["alert",`Credentials rejected${t}`];default:return["",`Connecting${t}`]}}function wC(e){const{id:t,active:s,configured:o,s:a}=e,l=nr(t),d=!l||!!a,h=["card connector",s?"active":"",d?"":"disabled",e.open?"open":""];return i.jsxs("div",{className:h.join(" "),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:e.name}),s&&i.jsx("span",{className:"pill on",children:"Active"})]}),i.jsx(pC,{id:t,active:s,configured:o,location:e.location,s:a}),l&&s&&i.jsx(kC,{status:a==null?void 0:a[t].status}),i.jsx(fC,{canSwitch:!s&&(!l||o),remote:l,usable:d,configured:o,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function xv(e=0){const[t,s]=y.useState(),o=y.useCallback(()=>Bt.get().then(a=>(s(a),a),()=>(s(null),void 0)),[]);return y.useEffect(()=>{if(o(),!e)return;const a=setInterval(()=>void o(),e);return()=>clearInterval(a)},[o,e]),[t,s,o]}function xC(e){const[t,,s]=xv(5e3),[o,a]=y.useState(null),l=async h=>{t&&(h==="markdown"||nr(h))&&await Bt.connect({active:h==="markdown"?"markdown":h,...h==="github"&&t.github.repo?{github:{repo:t.github.repo}}:{},...h==="linear"&&t.linear.teamId?{linear:{teamId:t.linear.teamId,teamKey:t.linear.teamKey,teamName:t.linear.teamName,projectId:t.linear.projectId,projectName:t.linear.projectName}}:{}}).catch(()=>{}),sr(e.update,h)},d=y.useMemo(()=>({github:!!(t!=null&&t.github.repo),linear:!!(t!=null&&t.linear.teamId)}),[t]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"connectors",children:I0.map(h=>{const f=h.id;return i.jsx(wC,{id:f,name:h.name,active:f===e.activeTracker,configured:nr(f)&&d[f],open:o===f,location:e.location,s:t,onSwitch:()=>void l(f),onToggle:()=>nr(f)&&a(o===f?null:f)},h.id)})}),t&&o==="github"&&i.jsx(vv,{s:t,reload:s,onConnected:()=>sr(e.update,"github")}),t&&o==="linear"&&i.jsx(wv,{s:t,onConnected:()=>sr(e.update,"linear")})]})}function jC(e,t){const s=e==null?void 0:e.github,o=e==null?void 0:e.linear,a=s&&t!=="github"?mv(s,s.repo??s.detectedRepo):void 0,l=o&&t!=="linear"?yv({viewer:o.viewer,team:o.teamName,project:o.projectName,source:o.auth}):void 0;return[{id:"markdown",title:"Local markdown",sub:"Files in .teamtrail/ in this repo"},{id:"github",title:"GitHub Issues",sub:a??"Trails as labelled issues in your repo"},{id:"linear",title:"Linear",sub:l??"Trails and tickets in your Linear team"}]}function Ee(e){return i.jsxs("section",{className:"set-sec",children:[i.jsx(ze,{as:"h4",children:e.title}),e.children]})}function jv(e){const t=[{v:"summary",title:"Summary"},{v:"full",title:"Full transcript"}];return i.jsx("div",{className:"choice-row",children:t.map(s=>i.jsx(ot,{on:e.value===s.v,title:s.title,onClick:()=>e.onChange(s.v)},s.v))})}const SC={github:"Checking for a GitHub login…",linear:"Checking for a Linear key…"};function NC(e){var I;const{prefs:t,update:s}=e,[o,,a]=xv(5e3),[l,d]=y.useState(!1),h=(I=o==null?void 0:o.pending)==null?void 0:I.target.split(":")[0],[f,p]=y.useState(!1);y.useEffect(()=>{h&&!f&&t.tracker!==h&&s({tracker:h})},[h,f,t.tracker,s]);const v=jC(o??void 0,t.tracker),k=t.tracker==="github"||t.tracker==="linear",w=k&&(o==null?void 0:o.active)===t.tracker,j=k&&!w,N=$=>{s({onboarded:!0}),sr(s,$)},S=async()=>{d(!0);const $=o&&!o.pending;t.tracker==="markdown"&&$&&await Bt.connect({active:"markdown"}).catch(()=>{}),s({onboarded:!0}),t.tracker!==e.activeTracker&&sr(s,t.tracker)};return i.jsx("div",{className:"scrim",children:i.jsxs(Be,{as:"div",className:"dialog onboarding",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(xa,{className:"onb-title"})}),i.jsxs("h2",{className:"onb-question t-heading",children:[i.jsx(kN,{className:"voice-badge",size:22}),"Where should your trails live?"]}),i.jsxs(Ee,{title:"Tracker",children:[i.jsx("div",{className:"choice-row",children:v.map($=>i.jsx(ot,{on:t.tracker===$.id,title:$.title,sub:$.sub,onClick:()=>(p(!0),s({tracker:$.id}))},$.id))}),(o==null?void 0:o.pending)&&i.jsxs("p",{className:"t-meta onb-repo-tracker",children:["This repo keeps its trails in ",o.pending.label,". Connect it here, or keep local files on this machine; the team's choice in the repo isn't changed either way."]}),o===void 0&&k&&i.jsx(ri,{label:SC[t.tracker]??"Checking…"}),o&&t.tracker==="github"&&!w&&i.jsx(vv,{s:o,reload:a,onConnected:()=>N("github")}),o&&t.tracker==="linear"&&!w&&i.jsx(wv,{s:o,onConnected:()=>N("linear")})]}),i.jsx(Ee,{title:"HITL transcript",children:i.jsx(jv,{value:t.hitlTranscript,onChange:$=>s({hitlTranscript:$})})}),i.jsx("footer",{children:i.jsx(M,{variant:"primary",disabled:l||j,onClick:()=>void S(),children:"Get started"})})]})})}function bC(e){var t;return(t=ft())!=null&&t.tracker?null:i.jsx(NC,{...e})}const lr=[{id:"trail",label:"This trail",intro:"How agents work on the trail on screen: its mode, the checks that prove work done, models and guides.",sections:[{id:"mode",title:"Trail mode"},{id:"verification",title:"Verification"},{id:"models",title:"Model matching"},{id:"team",title:"Team"}]},{id:"project",label:"Project",intro:"Where this repo keeps its trails, and the rules every agent working in it follows.",sections:[{id:"approvals",title:"Approvals"},{id:"tracker",title:"Tracker"},{id:"workspaces",title:"Workspaces"},{id:"proof",title:"Proof on pull requests"},{id:"remote-agents",title:"Remote agents"},{id:"policy",title:"Risk policy"},{id:"guides",title:"Guides"},{id:"labels",title:"Labels"}]},{id:"alerts",label:"Attention & alerts",intro:"What interrupts you, where questions reach you, and what Scout tells you when you come back.",sections:[{id:"attention",title:"Attention"},{id:"slack",title:"Slack"},{id:"trip-report",title:"Trip report"}]},{id:"you",label:"You",intro:"How the Lookout looks and reads for you, and the browsers and devices signed in to it.",sections:[{id:"appearance",title:"Appearance"},{id:"transcript",title:"HITL transcript"},{id:"agent",title:"Agent"},{id:"devices",title:"Browsers & devices"}]},{id:"projects",label:"All projects",intro:"Every repo this Lookout knows, so you can switch between them from the header.",sections:[{id:"projects",title:"Projects"}]},{id:"about",label:"About",intro:"What Teamtrail is, and what changed in each release.",sections:[{id:"changelog",title:"Changelog"}]}];function Sv(e){if(e===null)return null;const t=lr.find(a=>a.id===e);if(t)return{group:t.id};const s=lr.find(a=>a.sections.some(l=>l.id===e));if(!s)return{};const o=s.sections.find(a=>a.id===e);return{group:s.id,section:o==null?void 0:o.id}}function $C(){return i.jsxs("p",{className:"sp-elsewhere t-meta",role:"note",children:["You're looking at this Lookout from another device. You can read, answer and approve from here. What changes what runs on the machine ",Z.name," runs on, or whom it trusts, is set there: the approvals of what the repo asks it to trust, the tracker connection, Slack, the risk policy, verification levels, workspaces, guides, remote agents, your attention settings and the projects list. Paths on that machine and its tracker account are not shown here."]})}const Xm={from:"18:00",to:"09:00"};function CC(e){const t=e.focus!==void 0,s=e.focus??Xm;return i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Quiet hours"}),i.jsx(M,{size:"sm",on:t,"aria-pressed":t,onClick:()=>e.onChange(t?void 0:Xm),children:t?"On":"Off"}),t&&i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"time","aria-label":"Quiet from",value:s.from,onChange:o=>o.target.value&&e.onChange({...s,from:o.target.value})}),i.jsx("span",{className:"t-meta",children:"to"}),i.jsx("input",{type:"time","aria-label":"Quiet until",value:s.to,onChange:o=>o.target.value&&e.onChange({...s,to:o.target.value})})]})]})}const Bc=[3,5,8,12];function TC(e){const t=e&&!Bc.includes(e)?[...Bc,e].sort((s,o)=>s-o):Bc;return[{value:"off",label:"Off"},...t.map(s=>({value:String(s),label:`${s} waiting`}))]}const Zm=e=>`${e} finished ticket${e===1?"":"s"}`;function EC(e,t){const s=(e==null?void 0:e.waiting.length)??0;return t?e!=null&&e.full?`${Zm(s)} wait: agents start no new implementation work until you review some.`:`${s} of ${t} waiting: agents start new work.`:s?`${Zm(s)} wait for your review now.`:"Nothing waits for your review now."}function AC(e){const{limit:t,review:s}=e;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Review limit"}),i.jsx(at,{compact:!0,"aria-label":"Review limit",value:t?String(t):"off",options:TC(t),disabled:e.local===!1,onChange:o=>e.onChange(o==="off"?null:Number(o))})]}),i.jsxs("span",{className:"set-hint t-meta",children:["Agents finish rework and keep researching, but start no new implementation work while this many tickets wait for your review. ",EC(s,t)]})]})}function $a(){const[e,t]=y.useState();return y.useEffect(()=>{fetch(`${pe()}/machine`).then(s=>s.ok?s.json():void 0).then(s=>t(s==null?void 0:s.local),()=>t(void 0))},[]),e}const IC=[{value:"browser",label:"Browser notification"},{value:"slack-dm",label:"Slack DM"},{value:"slack-channel",label:"Slack channel"},{value:"none",label:"Nothing, I check the queue"}];function RC(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function MC(){const{view:e,error:t,savePrefs:s,saveReviewLimit:o}=hv(0),a=$a();if(!e)return null;const l=e.policy.value,d=`${Z.dataDir}/attention.json`,h=p=>void s({...e.prefs,...p}),f=typeof Notification<"u"&&Notification.permission==="denied";return i.jsxs(Ee,{title:"Attention",children:[i.jsxs("p",{className:"vf-intro",children:["Everything that needs you is ranked in Waiting on you. Only items scoring ",l.interrupt," or more interrupt you; the rest wait in the queue, and Slack gets them in a digest."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Interrupt me by"}),i.jsx(at,{compact:!0,"aria-label":"Interrupt me by",value:e.prefs.channel,options:IC,onChange:p=>{p==="browser"&&RC(),h({channel:p})}})]}),e.prefs.channel==="browser"&&f&&i.jsx("span",{className:"vf-err",children:"The browser blocks notifications for this page. Allow them in its site settings."}),i.jsx(CC,{focus:e.prefs.focus,onChange:p=>h({focus:p})}),i.jsx("span",{className:"set-hint t-meta",children:"Your channel and quiet hours stay on this machine."}),i.jsx(AC,{limit:l.reviewLimit,review:e.review,local:a,onChange:p=>void o(p)}),e.policy.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:e.policy.errors.map(p=>i.jsxs("li",{children:[d,": ",p]},p))}),i.jsx(V,{className:"set-hint",parts:[e.policy.exists?{text:d,code:!0}:"Team defaults",`interrupt at ${l.interrupt}`,l.digestMinutes?`Slack digest every ${l.digestMinutes} min`:"Slack digest off",l.reviewLimit?`review limit ${l.reviewLimit}`:"review limit off"]}),t&&i.jsx("span",{className:"vf-err",children:t})]})}const LC=[5,15,30,60];function OC(e){const{value:t}=e;return i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ot,{on:!t.enabled,title:"Off",onClick:()=>e.onChange({...t,enabled:!1})}),LC.map(s=>i.jsx(ot,{on:t.enabled&&t.awayMinutes===s,title:`Away ${s} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:s})},s))]})}const PC={repo:"Committed to the repo",machine:"Only on this machine",browser:"Only in this browser"};function Ke(e){const t=e.storage&&PC[e.storage];return i.jsxs("div",{className:"sp-slot",id:`settings-${e.id}`,children:[e.children,t&&i.jsx(V,{className:"sp-where",parts:[t]})]})}function _C(e){const[t]=Wd();return t?i.jsx(Ee,{title:"Slack",children:i.jsx(Sb,{focus:e.focus})}):null}function DC({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(Ke,{id:"attention",storage:"repo",children:i.jsx(MC,{})}),i.jsx(Ke,{id:"slack",storage:"machine",children:i.jsx(_C,{focus:t.section==="slack"})}),i.jsx(Ke,{id:"trip-report",storage:"browser",children:i.jsx(Ee,{title:"Trip report",children:i.jsx(OC,{value:e.prefs.briefing,onChange:s=>e.update({briefing:s})})})})]})}const zC=[{version:"0.32.0",date:"2026-11-13",items:["Scout has a new look: a scout companion with a cap, a headset and an antenna, looking out along the trail"]},{version:"0.31.1",date:"2026-11-13",items:["An archived trail’s held work and changes waiting for your approval stay in your queue"]},{version:"0.31.0",date:"2026-11-13",items:["Start a trail over: the trail menu archives the map that went wrong and opens New trail with its idea filled in","Archive a trail you are done with, or restore it: it stays as history, and no agent takes work from it","The empty map looks like every other empty zone, with New trail and the agent command under it"]},{version:"0.30.0",date:"2026-11-12",items:["Ask Scout more in Slack: “what's blocking #12?”, “what did we decide about retention?”, “who's working?”, as @Scout, a DM or /scout ticket, decisions and who","In a channel, the answers are seen only by you"]},{version:"0.29.3",date:"2026-11-12",items:["@Scout inbox and status in a channel now show up right away, seen only by you"]},{version:"0.29.2",date:"2026-11-12",items:["The Activity log reads in one style: a coloured bar marks what needs you (red), what went well (green) and what is held up (amber), and Slack answers show who gave them"]},{version:"0.29.1",date:"2026-11-12",items:["Scout says in Slack that it needs Teamtrail running on your computer, and how to start it, when it can’t reach yours","Ask Scout in your own words: “@Scout what’s in my inbox?” or “status of Slack live test” work, in a channel or a DM"]},{version:"0.29.0",date:"2026-11-12",items:["Ask Scout in Slack: @Scout inbox or @Scout status in a channel answers only you, or DM Scout; if you added Scout before, Settings asks you to reconnect once","A question your agent waits on gets its own Slack message with answer buttons, even right after it asked another one","Scout can be installed straight from Slack (scout.teamtrail.app/install-slack); each person then connects in Settings → Slack"]},{version:"0.28.0",date:"2026-11-12",items:["Scout is now one Slack app: Settings → Slack → Add Scout to Slack, no app to create and no tokens to paste","You confirm which Slack account becomes Scout’s owner before it connects; if you made your own Slack app before, add Scout again","High-risk calls are answered in the Lookout only, and so is approving an agent’s request to change your settings: Slack shows Open in Lookout, and Decline still works there"]},{version:"0.27.3",date:"2026-11-11",items:["On Linux, the Lookout sees every change an agent makes to a ticket again, not only the first: a claimed ticket no longer stays in the queue as waiting"]},{version:"0.27.2",date:"2026-11-11",items:["Settings, briefs, criteria, guides, reroutes and the other panels stay current through reconnects, and a GitHub or Linear map updates live again"]},{version:"0.27.1",date:"2026-11-11",items:["The map and the queue no longer miss a change made while the Lookout was loading or reconnecting"]},{version:"0.27.0",date:"2026-11-11",items:["Teamtrail opens your browser ready to sign in with one click; `teamtrail pair` does the same for another tab"]},{version:"0.26.2",date:"2026-11-11",items:["The Lookout shows the new teamtrail. wordmark"]},{version:"0.26.1",date:"2026-11-11",items:["A refreshed logo: the trail’s destination is larger, and there are light and dark versions that follow your theme"]},{version:"0.26.0",date:"2026-11-11",items:["The Lookout asks you to sign in: open the link `teamtrail` prints, and pair your phone with a QR code (again after each restart)","Your answers count only when you give them in the Lookout or Slack, and skipping discovery or changing a trail’s mode or destination waits for your Approve","Check commands, briefs, criteria and other trusted settings run only once you approve them on this machine, in Settings → Approvals","Changes made to trail files outside Teamtrail have no effect until you accept them"]}],BC=[{version:"0.10.0",date:"2026-10-31",items:["MCP server in the miloops package: `claude mcp add miloops -- npx -y miloops-cli mcp`, or the same for Codex","Connected agents start and resume missions, claim ready tickets, report steps, tokens and spend, close tickets and record decisions, live in the command center","Agent questions land in Waiting on you and the agent waits for your answer; answer in the command center or in the agent chat","/milo new, resume, status and inbox commands for Claude Code (and as a Codex prompt); `miloops connect claude|codex` sets them up","The command center follows a mission an agent just charted; sessions of agents that quit show as disconnected"]},{version:"0.9.0",date:"2026-10-31",items:["While you were away: MILO briefs you when you open the app or come back after being away: tickets done, now blocked, decisions waiting on you, agent decisions, spend and tokens since, active sessions","Briefing shows on return after 15 minutes hidden or idle; change the threshold or turn it off in Settings; reopen it from the header","Last seen per mission and usage over time are kept locally, so the briefing survives a reload","Mission title shows in full at laptop width; header readouts collapse to glyph and count","Prototype reviews link a real preview build and ask about the spike results"]},{version:"0.8.0",date:"2026-10-31",items:["Decisions: every decision across missions, newest first, with question, decision, alternatives, rationale, who decided and the full transcript","Filter decisions by mission, source, who decided and status; search; export to markdown","Supersede a decision; the chain stays visible on every record and in the mission","Decision records stored as markdown next to each mission and served by the local API with a live event stream","Resolve form: rationale and alternatives considered"]},{version:"0.7.0",date:"2026-10-31",items:["New type: Chakra Petch, Share Tech Mono and Barlow","Calmer palette; bright colour only for warnings and waiting on you","MILO mark, also used for status, action and alert glyphs","Dot-matrix signals for new decision requests and mission launches","Separate type voices for operators and agents","One-command install: npm i -g miloops-cli, then miloops in any repo","Packages renamed to @miloops-hq/core and @miloops-hq/command-center"]},{version:"0.6.0",date:"2026-10-31",items:["Named MILOOPS; MILO speaks for the platform in the activity log and onboarding","Tracker sync status, last-write latency and event pulse","Inbox: oldest question age and average wait","Critical path, decided per hour with burndown, type mix","Per-session tokens and cost, mission totals, claims per agent"]},{version:"0.5.0",date:"2026-10-31",items:["Status counters and resolution bar on the map","Current step tracker with step pipeline","Sessions with live timers","Activity log with time and source columns","Out-of-scope quarantine zone on the map"]},{version:"0.4.0",date:"2026-10-31",items:["Missions: switcher with progress and waiting count, New mission in the switcher","Inbox collects questions from every mission","Elapsed time and progress per mission","Responsive layout with progressive disclosure (wide, laptop, phone)","Map graph pans and zooms by drag, pinch and wheel","Changelog"]},{version:"0.3.0",date:"2026-10-31",items:["Fixed-zone layout","Plan + execute and plan-only mission modes","Execute tickets"]},{version:"0.2.0",date:"2026-10-31",items:["Local markdown tracker (default)","Onboarding","HITL transcript: summary or full","Settings with tracker connectors"]},{version:"0.1.0",date:"2026-10-31",items:["Live map graph","HITL vs AFK tickets","In-window HITL conversations","Demo tracker with simulated sessions"]}],FC=[{version:"0.25.0",date:"2026-11-10",items:["Agents on other machines or in cloud sandboxes can join your trails: `teamtrail mcp --http` serves the same tools over HTTP","One token per remote agent, created and revoked in Settings → Remote agents; without a token nothing is reachable","`teamtrail connect claude|codex --url` points an agent at a remote Teamtrail"]},{version:"0.24.2",date:"2026-11-10",items:["A ticket’s description no longer repeats which trail it is part of"]},{version:"0.24.1",date:"2026-11-10",items:["Buttons in the same row are always the same size"]},{version:"0.24.0",date:"2026-11-10",items:["Focus in the header: see at a glance whether it is on, and start or end it in one click","Sign in with GitHub, and pick your repo or Linear team from a searchable list","Write your own guides with `teamtrail guides new`, approve them in Settings and share them with the catalog","Settings is its own page, and the trail map has a cleaner, flatter look","Smaller polish: one colour for work in progress everywhere, a calmer first run and clearer Slack setup"]},{version:"0.23.0",date:"2026-11-08",items:["Match work to models: switch it on for a trail in Settings and each agent gets the tickets that fit the model it runs on, research on fast models and junctions on the strongest. You set the tier per ticket type; Teamtrail never switches a model, and a ticket no connected agent is strong enough for waits in your queue","Guides: a ticket can ask for a reviewer, QA, security, docs or architect, and the agent that claims it gets that guide’s instructions and a checklist it must answer before the work counts as done. Pick a trail’s team and each ticket’s guide in the Lookout, and add more guides from a moderated catalog in Settings → Guides. A guide can add checks but never remove one, its commands only run after you approve them, and a guide file edited after you approved it is switched off until you look at it again","Records has a new Trail stats view: delivery across every trail, by vendor, agent and ticket type, with plain observations from your own numbers. Teamtrail doesn't route work from them","MILOOPS is now Teamtrail. Missions are trails, the command center is the Lookout, MILO is Scout, and `/milo` is `/scout`","More room for the map: the summary of counts now slides up from a tab when you want it","A new day and night look, starting in night, with an Appearance setting to switch to day or follow your system","The map is now a landscape: tickets are trail signs, the trail shows what is walked and what is ahead, and an X marks the destination","A new greeting when you start `teamtrail` in a terminal","A new logo, a t whose stem runs along a trail to a node, and a new look for Scout: the original CRT head with ear cups and a baseball cap, with a lamp on the cap at night. No more pixel art, and new fonts too","All projects: every repo you supervise in one view, with one list of what needs you across them and what changed while you were away. Answer an agent's question in any repo from there, and switch projects from the header. Agents add their repo when they connect (`--no-register` opts out), or add one with `teamtrail projects add`"]},{version:"0.22.0",date:"2026-11-05",items:["A calmer, clearer command center: every list now reads the same way, what it is first, then one quiet line of context, and details when you want them","Red now only means something needs you now; other states show as a thin edge instead of colored text everywhere","The open question in a conversation can no longer be hidden by its suggested answers, and the phone header no longer runs off the side"]},{version:"0.21.0",date:"2026-11-05",items:["New plans can now edit a ticket, remove a dependency and reopen finished work, instead of working around it","Slack digests follow the team's digest setting (digestMinutes in attention.json); 0 turns them off, and everything still waits in Waiting on you","Remove a finished task's workspace from Settings → Workspaces or the ticket; the branch stays, and MILOOPS asks before discarding uncommitted changes"]},{version:"0.20.0",date:"2026-11-04",items:["Separate workspaces: switch on Settings → Workspaces and each ticket an agent claims gets its own copy of the repo on its own branch, so agents working at the same time don’t step on each other. When the work is done you get the branch to review; MILOOPS never merges or pushes for you","Warnings before a clash: agents say which files they expect to change. When two of them plan to change the same files, the second one is warned, and you see it in Waiting on you; open it to release either claim","When two agents’ branches did change the same files, Waiting on you suggests a ticket to bring the work together. One click adds it, waiting on both tickets, with the files listed","The ticket inspector shows which files an agent expects to change and the branch it works on","Fix: an execute ticket marked as needing you keeps that mark when saved to local files, GitHub Issues or Linear"]},{version:"0.19.0",date:"2026-11-04",items:["Risk policy: you decide what always needs you, such as database changes, logins and permissions, billing, deleting data or new dependencies (Settings → Risk policy). Agents can no longer make those calls on their own; they ask you. Their other decisions are labelled by risk in the briefing, and work that touched risky files without asking comes to you to check","One ranked list of everything that needs you in Waiting on you: questions, approvals, blocked work, briefs, knowledge and new plans, most important first, each with the reason (for example “blocks 3 tickets” or “claude-02 is waiting”). Related items are grouped so you answer them together; snooze what can wait","Fewer interruptions: agents say how urgent a question is, and only urgent items notify you (browser or Slack). Focus for an hour from the header, set quiet hours in Settings → Attention, and the rest waits in the list and the digest","Plans that adapt: missions list the assumptions they rely on, starting with the ones in the discovery brief. When an agent finds one is wrong, it shows the evidence and proposes a new plan; the tickets it would change are paused, the map previews the change, and nothing happens until you approve","Challenge the destination: an agent can tell you the work already exists, the mission targets the wrong problem, or it should be rescoped, with evidence and a suggested new goal","Assumptions on the Plan tab (confirm the ones you know are true) and an assumptions field when you create a mission","Fix: when an agent asks two questions at once, your answer goes to the one you opened; the inbox stats line no longer gets covered by the list"]},{version:"0.18.0",date:"2026-11-04",items:["Acceptance criteria: agents write down what done means before they start (required on missions with a discovery brief). When they finish, each point needs proof: one of your checks, a named test, the pull request, or your sign-off","Work whose criteria lack proof goes back with the reason; points only you can confirm come to your inbox to sign off","Business rules from your project knowledge are suggested as criteria, and the ticket shows any rule no criterion covers yet. Confirm a ticket’s criteria in the inspector","Cross-vendor review: when Claude and Codex agents both run, each reviews the other’s work first","Fix: answers from the command center could hang when too many live updates were open; all updates now share one connection"]},{version:"0.17.0",date:"2026-11-03",items:["Discovery brief: new missions start with an agent mapping the existing system (files, conventions, data and API impact, risks, assumptions, product context). Implementation tickets wait until you accept the brief or ask for changes, from the banner over the map or the card in Communication","Create mission: start a mission from the New mission dialog without a terminal; any agent picks it up with /milo resume","Knowledge: what agents need to know about your codebase and product (architecture, conventions, gotchas, dead ends, business rules, personas, UX principles, pricing). Agents propose, you confirm, keep as an assumption or retire. Confirmed entries reach agents with every claim, picked for the ticket with the reason, and the inspector shows what an agent gets","Knowledge about specific files is flagged for re-confirmation when those files change","Save decisions, cancelled tickets (as dead ends) and brief sections as knowledge in one click; seed it from a document with miloops knowledge import <file.md>"]},{version:"0.16.0",date:"2026-11-03",items:["Mission report (Mission plan → Report): tickets done, mission and median ticket lead time, your interventions, rework, review results and cost per verified ticket. Hover any number to see how it is computed; export it as markdown","Agents report the same numbers in one line from the status tool","Agents use missions for big work only, and decide routine calls themselves, keeping each one as a decision record you can review or reverse; they ask you when the call changes product behaviour, data, security, billing, a public API or the schema","Decisions: filter by who made the call, agents on their own or people. The briefing now counts only the calls agents made themselves, not your answers they recorded"]},{version:"0.15.0",date:"2026-10-31",items:["Verification in the ticket inspector: the level that applies and where it comes from, every attempt newest first with the git evidence (base → head, files changed, flags), its checks, exit codes, durations and the failing output, and the full log on demand","Verifying, Rework and Blocked on the map, in the legend and as status counters on missions that verify completions","Operator calls on a verifying or blocked ticket: Approve, Re-run checks, Send to rework with a note, Accept anyway and Unblock. Overrides need a reason, and each call is kept as a verdict next to the attempts and in the mission history. Approve asks for a re-run when the code changed since the checks passed","Set the verification level of a mission (Settings → Verification) or of one ticket (inspector). Only you can change it; agents cannot","The inspector updates live while checks run","Independent review: at Checks + review, a passing completion gets a review ticket that another agent takes and answers with PASS, FAIL (with findings) or NEEDS_HUMAN. The agent that did the work is never given its own review","Waiting on you lists reviewed work to approve (Checks + review + you) and held tickets, and Slack posts them with Approve and Rework… buttons","Agents can name their pull request in `report_completion` (`pr`); PR and CI tracking then follows that PR first"]},{version:"0.14.0",date:"2026-10-31",items:["Ticket lifecycle in plain words: Ready, Backlog, Working, Done and Cancelled (with Verifying, Rework and Blocked to come with verification)","Every claim, release, return to queue, resolution and rule-out goes through one lifecycle engine that records who, why and when in `.miloops/.events/<mission>.jsonl` (local history, never committed)","Settings → Verification shows the checks in `.miloops/verification.json`: argv commands with timeouts, run without a shell, secrets kept out of their environment. Read-only","Completion is a claim: on missions started with `verification.json` present, an execute or task ticket is only done once its checks pass. A failed check sends it back for Rework with the failing output (agents see it in close_ticket, next_ticket and claim_ticket, and rework comes first in the queue); after 3 failed attempts, or when the checks cannot run, it waits on you as Blocked","New MCP tools `report_completion` and `verification_status`; missions started before verification, and research, grilling and prototype tickets, close exactly as before","Git evidence, no GitHub needed: each claim records HEAD and the uncommitted state, and each completion lists the files changed since then. It flags no changes, overlap with another active ticket, a branch switch or reset, and edits to `verification.json` (which send the ticket to you as Blocked). A pass on code that changed while its checks ran is re-run","Pull request and CI evidence: with `verification.json` and a GitHub token (Settings, `GITHUB_TOKEN` or `gh auth login`), the command center finds each ticket’s PR (its branch `miloops-<mission>-<ticket>`, a `miloops:<mission>#<ticket>` line in the PR body, or a link you set) and flags mismatches: done with the PR still open, PR merged while the ticket is in progress, PR closed unmerged, required checks failing or unknown, PR head not the verified commit. Flags never change a ticket. A CI chip in the header shows sync health and never shows synced after a failed sync"]},{version:"0.13.0",date:"2026-10-31",items:["Crash recovery for claims: an agent’s claim is a lease (15 min by default) that every tool call renews, including waits on your answer","When an agent crashes or goes silent, its ticket goes back to the queue on its own, and the activity log says so; the next agent picks it up from next_ticket or claim_ticket","The returned ticket keeps a handoff comment with the previous agent’s progress notes and decisions, so the next agent resumes instead of starting over","Stalled state on the map, in sessions and in the ticket inspector when a lease is about to run out, with a Release to queue action","Works with GitHub and Linear: the return is an ordinary comment + unassign, queued in the offline outbox like any other write","Set the lease with `miloops mcp --lease-minutes <n>` or `MILOOPS_LEASE_MINUTES`"]},{version:"0.12.0",date:"2026-10-31",items:["Slack: your own MILO app, created from a manifest and connected from your machine over Socket Mode in five guided steps (Settings → Slack or `miloops connect slack`)","Tokens stay in your local credential store next to the GitHub and Linear ones; nothing passes through MILOOPS servers","Agent questions arrive as a Slack DM with answer buttons and a Reply… box; answering there resolves the item in Waiting on you, and answering in the command center closes the DM","Save as decision on any message, or `/milo decide`: the form is prefilled with a summary of the thread, and the decision is recorded with a permalink, resolving the related ticket by default","`/milo status` and `/milo inbox` for the mission at a glance; DMs when a ticket is blocked or a mission is done","Allowed users, notification target and events in Settings → Slack","Slack setup without Paste clicks: press ⌘V / Ctrl+V anywhere, or in Chrome just come back to the tab after copying; pasting the app token opens the install page; MILO recognises you by your git email, so there is nothing to claim in Slack"]},{version:"0.11.0",date:"2026-10-31",items:["GitHub Issues tracker: missions are labelled issues, tickets are sub-issues, blocking uses native issue dependencies",'Linear tracker: missions are labelled issues in a team (optionally one project), tickets are sub-issues, blocking uses "blocks" relations',"Two-way sync: tickets, status, claims, comments, blockers and decisions written from MILOOPS land in the tracker; changes made there show up within seconds","Decisions are posted as comments on their ticket and listed in the mission","Connect from Settings with Test connection; GitHub reuses your gh login or GITHUB_TOKEN, Linear takes a personal API key","Tokens stay on your machine: kept by the local server, never sent to the browser or anywhere else","Offline and rate limits: changes queue and send in order when the tracker answers again; the connector shows status, queue and remaining requests","Connected agents (MCP) work on the active tracker: with GitHub or Linear connected, their missions, claims and decisions land there, and their sessions show live in the command center"]},...BC],UC=[{area:"Teamtrail Cloud",items:["The Lookout as an app on your phone, with a nudge only for the calls that need you"]}],WC=[{version:"0.52.1",date:"2026-11-16",items:["Start the trail is a full-size button, like Create trail, and closes New trail once your agents are on"]},{version:"0.52.0",date:"2026-11-16",items:["Scope check: files an agent changed beyond the ones it said it would are listed first for whoever reviews","Choose in Settings → Verification whether they are only shown, sent back for rework, or left for you to decide","Proofs on pull requests say whether every change stayed inside the declared files"]},{version:"0.51.0",date:"2026-11-16",items:["Review limit: set how much finished work may wait for your review, and agents start no new work past it","Agents finish rework and keep researching meanwhile, and Waiting on you shows what to review first","Set it in Settings → Attention; in Teamtrail Cloud, workspace owners set it there too"]},{version:"0.50.0",date:"2026-11-16",items:["On the map, a done ticket’s check is green when its work is verified, grey when it isn’t","Cards say “checks running” while a completion is checked, and a Legend explains the dots"]},{version:"0.49.0",date:"2026-11-16",items:["In Teamtrail Cloud, Start the trail right after New trail, or from the trail’s header: agents start in place","A trail started in the Lookout gets your project’s default verification level, as one an agent starts does"]},{version:"0.48.1",date:"2026-11-16",items:["Scout’s Get started sits in the bottom-right corner; adding your own check shows examples"]},{version:"0.48.0",date:"2026-11-16",items:["In Teamtrail Cloud, Scout keeps Get started in the corner until your workspace is set up"]},{version:"0.47.0",date:"2026-11-16",items:["Set the checks every finished ticket must pass in Settings → Verification, no file to edit"]},{version:"0.46.0",date:"2026-11-16",items:["In Teamtrail Cloud, Approve and merge on a verified ticket merges its pull request at the commit that was checked"]},{version:"0.45.0",date:"2026-11-16",items:["In Teamtrail Cloud, Run agents on the trail takes you straight to its agents"]},{version:"0.44.2",date:"2026-11-16",items:["The middle of the Lookout gets the same margin at the top as at its sides"]},{version:"0.44.1",date:"2026-11-16",items:["Text you type in forms is full size (14px) again, not the small caps of the label above it"]},{version:"0.44.0",date:"2026-11-16",items:["In a hosted Lookout, the theme toggle and Settings → Appearance change your theme on the server too"]},{version:"0.43.1",date:"2026-11-15",items:["In a hosted Lookout that keeps your trails itself, Settings → Tracker says so instead of offering trackers"]},{version:"0.43.0",date:"2026-11-15",items:["Where the server runs your agents, the Lookout says to turn them on for a trail there, instead of offering /scout commands for an agent of your own"]},{version:"0.42.0",date:"2026-11-15",items:["A hosted Lookout has your menu in its header: back to all your workspaces, the server’s own pages, and Sign out","Where the server keeps your trails itself, the Lookout asks no tracker questions on its first run"]},{version:"0.41.0",date:"2026-11-15",items:["In a hosted Lookout, someone who may not make high-risk calls sees who can answer or approve one, instead of a box that would turn their answer away"]},{version:"0.40.0",date:"2026-11-15",items:["Decisions now say who made the call: your name from git on this machine, or the person signed in to a hosted Lookout, in the Logbook and in Verified by Teamtrail proofs","A hosted Lookout opens in the theme you picked in your account there"]},{version:"0.39.0",date:"2026-11-15",items:["A server that hosts Teamtrail can run a remote agent's checks on its pushed work, so that work is verified and its proof counts, like work done on your machine"]},{version:"0.38.0",date:"2026-11-15",items:["Decision memory: before an agent asks you something you already decided, Teamtrail hands it your earlier decision instead, and shows it next to the question if the agent asks anyway","Waiting on you flags finished work that changes files one of your decisions covers, so a later change never quietly undoes it","The Logbook groups decisions by area, the most cited first; share a project's decisions with your other projects in Settings → Projects"]},{version:"0.37.0",date:"2026-11-15",items:["Trail stats has a Scorecard: how each model, agent and vendor does on your own tickets, verified first time, rework and cost per verified ticket, with small samples marked too few","Settings → Model matching suggests a tier per ticket type when one model clearly does better on your repo, with the numbers; nothing changes until you take it","Copy the scorecard as Markdown to share it with your team"]},{version:"0.36.0",date:"2026-11-15",items:["Proof reports are signed with your machine's key: commit the key file Teamtrail writes in .teamtrail/proof-keys, and anyone can check a report with `teamtrail proof verify`","A GitHub Action, Verified by Teamtrail, checks every proof on a pull request and can be made a required check, so a PR without a valid proof can't merge","The ticket inspector shows the proof, with Copy for PR and a link to the comment once it is posted"]},{version:"0.35.0",date:"2026-11-15",items:["Settings → Project → Proof on pull requests: switch it on and Teamtrail posts each done ticket's report on its open pull request, updating the same comment as things change","A Teamtrail proof check sits next to CI on the pull request and passes only when the ticket is verified at its latest commit"]},{version:"0.34.0",date:"2026-11-15",items:["Verified by Teamtrail: `teamtrail proof <ticket>` prints what Teamtrail recorded about a ticket's completion (the checks it ran, criteria verified or only claimed, the review and the decisions it relies on), ready for a pull request","Agents get the same report from the new `proof_report` tool and put it in their pull requests","The report opens with a Teamtrail verified or not verified badge"]},{version:"0.33.1",date:"2026-11-14",items:["Teamtrail is now MIT licensed"]},{version:"0.33.0",date:"2026-11-14",items:["`teamtrail connect claude` offers to turn on Claude Code's sandbox, so the agent's shell commands can't reach Teamtrail's config folder either"]},...zC,...FC];function HC(){return i.jsxs("div",{className:"changelog",children:[i.jsxs("div",{className:"about",children:[i.jsx(xa,{className:"about-name"}),i.jsx("span",{className:"mono-label",children:Z.category}),i.jsx("p",{className:"onb-tagline",children:Z.tagline}),i.jsx(V,{parts:[Z.assistant.name]})]}),i.jsx(Ee,{title:"Next",children:UC.map(e=>i.jsxs("div",{className:"cl-row",children:[i.jsx("span",{className:"mono-label",children:e.area}),i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})]},e.area))}),WC.map(e=>i.jsx(Ee,{title:`${e.version} · ${e.date}`,children:i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})},e.version))]})}const ep={checks:"Completions run these commands on this machine",catalogs:"Guides can then be searched for and added from these addresses",policy:"Agents may then decide these alone",brief:"Implementation tickets of the trail open up",criteria:"These criteria define done for the ticket",knowledge:"Agents get it as trusted context with their claims",level:"Completions on it are checked this much",type:"The trail's level applies to a ticket by its type",state:"Accepting signs it as yours on this machine: gates then read the file as it is",discovery:"Agents may claim its implementation tickets without a discovery brief, and criteria are no longer required"},tp={checks:"Approval covers these commands, not what they run: npm run check runs package.json scripts, and an agent can edit those.",catalogs:"Approval covers where guides come from, not the guides: each one is still shown whole and approved on its own."};function Nv(e){return e.kind==="state"?KC(e):e.committed===!1?"Not committed, so shown whole":e.standing==="elsewhere"?"Came with the repo, never approved on this machine":"Changed since you approved it here"}function KC(e){const t="Changed by a teammate or an agent outside Teamtrail";return e.standing==="elsewhere"?`${t}, or came with the repo · never signed on this machine`:e.committed===!1?`${t} · not committed`:t}const VC="Until you decide, Teamtrail uses the values it signed: a changed ticket is held for you, and a decision nobody signed here does not count. Accept signs the change as yours on this machine; Revert writes the signed values back into the file.";function GC(e){return`${e} committed ${e===1?"thing":"things"} in this repo say they were approved, or record a trail's state, but nothing on this machine signed them: a fresh clone, a teammate's push, or an upgrade from before they were kept per machine. Look them over, then approve them in one step. After that, only what Teamtrail writes here, and what you approve one at a time, counts.`}const qC=["Kept in your config folder, never in the repo","A repo moved to another folder is asked again","This stops an agent that can only write files in the repo, and a teammate's push. An agent that can read your home folder can read the key, and any local agent can answer questions with answer_question","An agent whose sandbox can write your config folder can approve for itself (teamtrail approve --hash, or approvals.json); where the sandbox blocks that folder, Teamtrail fails closed","A trail's state (ticket types, states, claims, blockers, levels, the trail's mode, decisions, assumptions) counts only as Teamtrail wrote it here, so a teammate's push shows as changed outside Teamtrail until you accept it on this machine. An agent that can write your config folder can forge that record too"];function QC(e){const{queue:t}=e;return i.jsx(be,{as:"li",className:"ap-row",edge:"attention",title:`${t.writes} tracker writes queued before the upgrade`,context:i.jsx(V,{parts:[`For ${t.targets.join(", ")}`]}),below:i.jsxs("div",{className:"ap-below",children:[i.jsx("pre",{className:"ap-lines t-code",children:t.labels.join(`
|
|
148
148
|
`)}),i.jsx("p",{className:"ap-note t-meta",children:"An older version kept this queue in the repo, where anyone who could write it could add to it. Send them only if you recognise them; nothing is sent until you do."}),e.local&&i.jsxs("div",{className:"ap-actions",children:[i.jsx(M,{size:"sm",disabled:e.busy,onClick:()=>e.onDecide(!0),children:"Send them"}),i.jsx(M,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onDecide(!1),children:"Discard"})]})]})})}function YC(e){return i.jsxs("div",{className:"ap-below",children:[i.jsxs("p",{className:"t-meta",children:["Delete ",e.files.join(", "),"? Nobody signed them on this machine; git still has them."]}),i.jsxs("div",{className:"ap-actions",children:[i.jsxs(M,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onDelete,children:["Delete ",e.files.length===1?"it":`all ${e.files.length}`]}),i.jsx(M,{size:"sm",disabled:e.busy,onClick:e.onCancel,children:"Keep"})]})]})}const JC=e=>e.files??(e.file?[e.file]:[]);function XC(e){const{item:t}=e,[s,o]=y.useState(!1),a=JC(t),l=t.revert??"restore";return i.jsx(be,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:i.jsx(V,{parts:[Nv(t)]}),detail:a.join(", ")||void 0,detailText:a.join(", ")||void 0,below:i.jsxs("div",{className:"ap-below",children:[i.jsx("pre",{className:"ap-lines t-code",children:t.lines.join(`
|
|
149
149
|
`)}),e.local&&!s&&i.jsxs("div",{className:"ap-below ap-actions",children:[i.jsx(M,{size:"sm",disabled:e.busy,onClick:e.onAccept,children:"Accept this change"}),l!=="none"&&i.jsx(M,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>l==="delete"?o(!0):e.onRevert(),children:l==="delete"?"Delete…":"Revert"})]}),e.local&&s&&i.jsx(YC,{files:a,busy:e.busy,onDelete:()=>(o(!1),e.onRevert(a)),onCancel:()=>o(!1)})]})})}function ZC(e){const{tracker:t}=e;return i.jsx(be,{as:"li",className:"ap-row",edge:"attention",title:`trackers.json now points at ${t.label}`,context:i.jsx(V,{parts:["Nothing is read from or sent there yet"]}),detail:`This machine keeps using ${t.approved}`,below:e.local&&i.jsxs("div",{className:"ap-below ap-actions",children:[i.jsxs(M,{size:"sm",disabled:e.busy,onClick:()=>e.onDecide(!0),children:["Use ",t.label]}),i.jsxs(M,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onDecide(!1),children:["Keep ",t.approved]})]})})}function eT(e){const{item:t}=e,s=t.committed===!1,o=t.kind==="catalogs"?[...t.lines,""]:[],a=s?[...o,...t.content.split(`
|
|
150
150
|
`)]:t.lines;return i.jsx(be,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:i.jsx(V,{parts:[Nv(t)]}),detail:ep[t.kind],detailText:ep[t.kind],below:i.jsxs("div",{className:"ap-below",children:[i.jsx("pre",{className:"ap-lines t-code",children:a.join(`
|
|
151
|
-
`)}),tp[t.kind]&&i.jsx("p",{className:"ap-note t-meta",children:tp[t.kind]}),t.warnings.length>0&&i.jsx("ul",{className:"ap-warnings t-meta",children:t.warnings.map(l=>i.jsxs("li",{children:["Worth a look: ",l]},l))}),e.local&&i.jsx(M,{size:"sm",disabled:e.busy,onClick:e.onApprove,children:"Approve"})]})})}async function np(e,t){const s=await fetch(`${pe()}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await s.json().catch(()=>({}));if(!s.ok)throw new Error(o.error??`Request failed (${s.status})`);return o}const Fc=async e=>e.ok?await e.json():void 0;async function sp(){var p;const[e,t,s]=await Promise.all(["/trust","/trackers","/trackers/legacy-outbox"].map(k=>fetch(`${pe()}${k}`))),o=await Fc(e);if(!o)return null;const{items:a}=o,l=(p=await Fc(t))==null?void 0:p.pending,d=await Fc(s),h=o.firstRun===!0,f=o.stateFirstRun===!0;return{items:a,firstRun:h,stateFirstRun:f,...l?{tracker:l}:{},...d!=null&&d.writes?{oldQueue:d}:{}}}const tT=(e,t)=>{var s,o,a,l;return JSON.stringify([e.items.map(d=>d.hash),(s=e.tracker)==null?void 0:s.target,(o=e.oldQueue)==null?void 0:o.writes])===JSON.stringify([t.items.map(d=>d.hash),(a=t.tracker)==null?void 0:a.target,(l=t.oldQueue)==null?void 0:l.writes])};function nT(e){var s,o;const t=[(s=e.changed)!=null&&s.length?`${e.changed.length} changed while you looked, so they wait; look again`:"",(o=e.refused)!=null&&o.length?`${e.refused.length} not committed, so they need their own look`:""].filter(Boolean);return t.length?`${t.join(". ")}.`:void 0}function sT(){const[e,t]=y.useState(),[s,o]=y.useState(!1),a=y.useRef();y.useEffect(()=>void(a.current=e),[e]);const l=y.useRef(0),[d]=y.useState(ni),h=y.useRef(0),f=y.useCallback(()=>{h.current++;const j=d.start(),N=S=>{j()&&(a.current=S,t(S),o(!1))};return sp().then(N,()=>N(null))},[d]),p=y.useCallback(async()=>{if(l.current)return;const j=h.current,N=await sp().catch(()=>null),S=a.current;h.current!==j||S===void 0||(!N||!S||!tT(N,S))&&o(!0)},[]);y.useEffect(()=>void f(),[f]),y.useEffect(()=>Pd(j=>void(j.startsWith(".")||p())),[p]),y.useEffect(()=>vs(()=>void p()),[p]);const k=y.useCallback(async j=>{l.current++;try{const N=await j();return await f(),N}finally{l.current--}},[f]),v=y.useCallback(async j=>nT(await k(()=>np("/trust/approve",{items:j.map(N=>({key:N.key,hash:N.hash}))}))),[k]),w=y.useCallback(async(j,N)=>{await k(()=>np(j,N))},[k]);return{view:e,changed:s,load:f,approve:v,act:w}}function iT(){const{view:e,changed:t,load:s,approve:o,act:a}=sT(),l=$a()!==!1,[d,h]=y.useState(!1),[f,p]=y.useState();if(!e)return null;const k=$=>{h(!0),p(void 0),$.then(_=>(h(!1),p(_??void 0)),_=>(h(!1),p(_.message)))},{items:v,tracker:w,oldQueue:j}=e,N=$=>!$.alone&&($.kind==="state"?e.stateFirstRun&&$.standing==="elsewhere":e.firstRun),S=v.filter($=>$.committed!==!1&&N($)),I=v.length+(w?1:0)+(j?1:0);return i.jsxs(Ee,{title:"Approvals",children:[i.jsxs("p",{className:"vf-intro",children:["Some files in the repo tell ",Z.name," what to trust: the commands checks run, where trails are kept, what needs you, how much each trail is checked, and briefs, criteria and knowledge marked accepted. Agents can edit those files and teammates push them, so nothing in them takes effect on this machine until you approve it here, exactly as it is. The same goes for a trail's state: a ticket closed, retyped, claimed or unblocked, a level or mode changed, or a decision written by editing files instead of through ",Z.name," shows here as changed outside ",Z.name,", and counts only once you accept it."]}),t&&i.jsxs("div",{className:"sync-line alert ap-changed",role:"status",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:"Files changed while you were here. What's below is what you saw."}),i.jsx(M,{size:"sm",onClick:s,children:"Review again"})]}),I===0&&i.jsx("p",{className:"ap-none t-meta",children:"Nothing waiting. Everything the repo asks for is approved here."}),S.length>1&&i.jsx("p",{className:"ap-adopt",children:GC(S.length)}),v.some($=>$.kind==="state")&&i.jsx("p",{className:"ap-note t-meta",children:VC}),I>0&&i.jsxs("ul",{className:"ap-list",children:[w&&i.jsx(ZC,{tracker:w,busy:d,local:l,onDecide:$=>k(a("/trackers/approval",{use:$,target:w.target}))}),j&&i.jsx(QC,{queue:j,busy:d,local:l,onDecide:$=>k(a("/trackers/legacy-outbox",{action:$?"send":"discard",writes:j.writes}))}),v.map($=>$.kind==="state"?i.jsx(XC,{item:$,busy:d,local:l,onAccept:()=>k(o([$])),onRevert:_=>k(a("/trust/revert",{key:$.key,hash:$.hash,remove:_}))},$.key):i.jsx(eT,{item:$,busy:d,local:l,onApprove:()=>k(o([$]))},$.key))]}),l&&S.length>1&&i.jsxs(M,{disabled:d||t,onClick:()=>k(o(S)),children:["Approve all ",S.length," committed"]}),!l&&I>0&&i.jsxs("p",{className:"t-meta",children:["Approve these on the machine ",Z.name," runs on."]}),f&&i.jsx("span",{className:"vf-err",children:f}),i.jsx(V,{className:"set-hint",parts:qC})]})}function bv(e){return i.jsx("ul",{className:"checklist-answers",children:e.answers.map(t=>i.jsxs("li",{className:t.done?"done":"not-done",children:[i.jsx("span",{className:"mark","aria-label":t.done?"Done":"Not done",children:t.done?"✓":"–"}),i.jsx("span",{className:"t-body",children:t.item}),t.note&&i.jsx("span",{className:"t-meta note",children:t.note})]},t.item))})}const $v=`${Z.apiPrefix}`;async function Cv(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`Request failed (${e.status})`);return t}const qo=async e=>Cv(await fetch(`${$v}${e}`)),Tv=async(e,t)=>Cv(await fetch(`${$v}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}));let Ev;const Po=new Set;let Yn;function hd(e){Ev=e;for(const t of Po)t()}function Av(e){Yn==null||Yn.pushed(),hd(e)}const rT=()=>Ev;function oT(e){return Po.add(e),Yn??(Yn=iv({load:()=>qo("/guides"),show:hd,failed:()=>hd(null),changed:t=>t.includes("guides")})),()=>{Po.delete(e),!Po.size&&(Yn==null||Yn.stop(),Yn=void 0)}}function $n(){const e=y.useSyncExternalStore(oT,rT),t=y.useCallback(async(o,a)=>{try{Av(await Tv(o,a));return}catch(l){return l.message}},[]),s=y.useCallback(o=>o?e==null?void 0:e.guides.find(a=>a.id===o):void 0,[e]);return{view:e,act:t,find:s}}function aT(e){var h;const{view:t,find:s}=$n(),o=s(e.id),a=t!=null&&(o==null?void 0:o.status)!=="active",l=((h=o==null?void 0:o.guide)==null?void 0:h.name)??e.id,d=a?`${l}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${l}`;return i.jsx("span",{className:Ge("guide-chip",a&&"off"),"data-guide-id":e.id,title:d,children:l})}const lT={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"},cT={active:"Approved",unapproved:"Not approved yet",tampered:"Changed since you approved it",invalid:"Can't be used"},fd=e=>{var t;return e.origin==="local"&&(!((t=e.lock)!=null&&t.source)||e.lock.source==="local")};function dT(e){return fd(e)?{text:cT[e.status],strong:e.status==="active"}:e.status==="active"?void 0:lT[e.status]}function Qo(e){try{return new URL(e).host}catch{return e}}function uT(e){var s;if(e.origin==="builtin")return"Built in";const t=(s=e.lock)==null?void 0:s.source;return!t||t==="local"?e.overridesBuiltin?"Local, replaces the built-in":"Local":`From ${Qo(t.registry)}`}const qd=e=>e.map(t=>/\s/.test(t)?JSON.stringify(t):t).join(" "),ip=3;function hT(e,t){return e.length<=Math.max(t,ip+1)?e:`${e.slice(0,Math.max(t-1,ip)).trimEnd()}…`}function Iv(e){return e===L0?"Verified":`Verified by ${Qo(e)}'s catalog`}function Rv(e,t){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:Iv(t),strong:!0}:"Not reviewed"}function fT(e){var l,d;const t=(l=e.lock)==null?void 0:l.review;if(!t||e.status!=="active")return;if(!t.verified)return"Not reviewed";const s=t.reviewedBy.length>0?`Reviewed by ${t.reviewedBy.join(", ")}`:void 0,o=(d=e.lock)==null?void 0:d.source;return{text:o&&o!=="local"?Iv(o.registry):"Verified",strong:!0,tip:s}}var Mv=_p();function Lv(e){return yS(e.spec)?i.jsxs("span",{className:"guide-unknown",children:[i.jsx("span",{className:"t-body",children:"Unknown program: Teamtrail can't tell what this runs. Approve it only if you know what it does."}),i.jsxs(M,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(e.name,!0),children:["I know what it runs: approve check ",e.name]})]}):i.jsxs(M,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(e.name,!1),children:["Approve check ",e.name]})}function mT(e){var w;const{preview:t}=e,{act:s,find:o}=$n(),[a,l]=y.useState({kind:"ready"}),[d,h]=y.useState(),f=t.entry.id,p=async()=>{h(void 0),l({kind:"adding"});try{l({kind:"added",pending:(await e.add(f,t.entry.sha256)).pendingChecks})}catch(j){h(j.message),l({kind:"ready"})}};if(t.entry.builtin)return i.jsxs("span",{className:"t-meta",children:["Built into ",Z.name,": already available to every trail, nothing to add."]});if(a.kind!=="added"){const j=e.installed===t.entry.version,N=e.installed?"Update guide":"Add guide";return i.jsxs("div",{className:"add-guide",children:[!t.ok&&i.jsx("span",{className:"t-meta",children:"The lint found errors, so this guide can't be added."}),i.jsx(M,{variant:"primary",disabled:!t.ok||j||a.kind==="adding",onClick:()=>void p(),children:j?"Added":N}),d&&i.jsx("span",{className:"vf-err",children:d})]})}const k=((w=o(f))==null?void 0:w.pendingChecks)??a.pending,v=async(j,N)=>h(await s("/guides/checks/approve",{id:f,name:j,acknowledged:N}));return i.jsxs("div",{className:"add-guide",children:[i.jsx("p",{className:"t-body",children:k.length?`Added ${f} ${t.entry.version}. Approve each command it proposes; none runs until you do.`:`Added ${f} ${t.entry.version}. Agents get its instructions on tickets that ask for ${f}.`}),k.map(j=>{var N,S,I;return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[j,": ",qd(((S=(N=t.guide)==null?void 0:N.proposedChecks[j])==null?void 0:S.run)??[])]}),i.jsx(Lv,{name:j,spec:((I=t.guide)==null?void 0:I.proposedChecks[j])??{run:[]},onApprove:($,_)=>void v($,_)})]},j)}),d&&i.jsx("span",{className:"vf-err",children:d})]})}function pT(e){const t=i.jsx("p",{className:"t-meta",children:"The lint looks for common problems; it isn't a review. Read the guide before you approve it."});return e.findings.length?i.jsxs(i.Fragment,{children:[i.jsx("ul",{className:"vf-findings guide-findings",children:e.findings.map((s,o)=>i.jsxs("li",{className:`sev-${s.level}`,children:[i.jsxs("code",{className:"t-code",children:["line ",s.line]})," ",s.message," ",i.jsxs("span",{className:"t-meta",children:["(",s.rule,")"]})]},o))}),t]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"t-meta",children:"The lint found none of the problems it looks for."}),t]})}function Ov(e){var o,a;const{p:t}=e,s=Object.entries(((o=t.guide)==null?void 0:o.proposedChecks)??{});return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"t-label",children:"Lint"}),i.jsx(pT,{findings:t.findings}),t.guide&&t.guide.checklist.length>0&&i.jsx("span",{className:"t-label",children:"Checklist"}),t.guide&&i.jsx("ul",{className:"catalog-checklist t-body",children:t.guide.checklist.map(l=>i.jsx("li",{children:l},l))}),s.length>0&&i.jsx("span",{className:"t-label",children:"Commands it proposes"}),s.map(([l,d])=>i.jsxs("code",{className:"t-code guide-check",children:[l,": ",qd(d.run),d.cwd&&` (in ${d.cwd})`]},l)),i.jsx("span",{className:"t-label",children:"Instructions"}),i.jsx("pre",{className:"guide-preview",children:((a=t.guide)==null?void 0:a.instructions)??t.text})]})}function gT(e){const t=Nn(e.repo);if(!t)return null;const s=encodeURIComponent(`Report: ${e.id} ${e.version}`),o=`${t.replace(/\/+$/,"")}/issues/new?template=report-guide.yml&title=${s}`;return i.jsx("a",{className:"report-link t-meta",href:o,target:"_blank",rel:"noreferrer",children:"Report this guide"})}function vT(e){const t=e.entry,[s,o]=y.useState(),[a,l]=y.useState();return y.useEffect(()=>{e.preview(t.id).then(o,d=>l(d.message))},[t.id]),i.jsxs("div",{className:"catalog-entry",children:[i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onBack,children:"← All guides"}),i.jsx("h3",{className:"t-title",children:t.name??t.id}),i.jsx(V,{parts:[{text:t.id,code:!0},t.version,`by ${t.author}`,Rv(t,e.catalogUrl),t.reviewedBy.length>0&&`reviewed by ${t.reviewedBy.join(", ")}`]}),i.jsx("p",{className:"t-body",children:t.summary}),t.history.length>0&&i.jsx("ul",{className:"catalog-history",children:t.history.map(d=>i.jsxs("li",{className:"t-meta",children:[d.version," · ",i.jsx("code",{className:"t-code",children:d.commit.slice(0,8)})," · ",d.at.slice(0,10)]},`${d.version}-${d.commit}`))}),a&&i.jsx("span",{className:"vf-err",children:a}),s&&i.jsx(Ov,{p:s}),s&&i.jsx(gT,{repo:s.repo,id:t.id,version:t.version}),s&&i.jsx(mT,{preview:s,installed:e.installed,add:e.add})]})}function kT(e){const t=e.entry;return i.jsx("li",{className:"catalog-row","data-guide-id":t.id,children:i.jsx(be,{title:t.name??t.id,context:i.jsx(V,{parts:[{text:t.id,code:!0},t.version,t.author,Rv(t,e.catalogUrl),t.reported&&"Reported"]}),detail:t.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}const rp=e=>e?`registry=${encodeURIComponent(e)}`:"";function yT(e){const[t,s]=y.useState(),[o,a]=y.useState();y.useEffect(()=>{let h=!0;return s(void 0),a(void 0),qo(`/guides/catalog?${rp(e)}`).then(f=>h&&s(f),f=>h&&a(f.message)),()=>{h=!1}},[e]);const l=y.useCallback(h=>qo(`/guides/catalog/preview?${rp(e)}&id=${encodeURIComponent(h)}`),[e]),d=y.useCallback(async(h,f)=>{const p=await Tv("/guides/catalog/add",{registry:e,id:h,sha256:f});return Av(p),p.installed},[e]);return{index:t,error:o,preview:l,add:d}}function wT(e){var S,I;const[t,s]=y.useState(((S=e.registries[0])==null?void 0:S.name)??""),o=yT(t||void 0),{find:a}=$n(),[l,d]=y.useState(""),[h,f]=y.useState(!0),[p,k]=y.useState(),v=o.index?wS({guides:o.index.guides},{query:l,verifiedOnly:h}):[],w=(I=o.index)==null?void 0:I.guides.find($=>$.id===p),j=$=>{var _,O,D;return((_=a($))==null?void 0:_.origin)==="local"?(D=(O=a($))==null?void 0:O.guide)==null?void 0:D.version:void 0},N=e.registries.find($=>$.name===t);return Mv.createPortal(i.jsx("div",{className:"scrim catalog-scrim",onClick:$=>{$.stopPropagation(),e.onClose()},children:i.jsxs(Be,{as:"div",className:"dialog catalog-dialog",onClick:$=>$.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h3",{className:"t-title",children:"Guide catalog"}),e.registries.length>1&&i.jsx(at,{compact:!0,"aria-label":"Catalog",value:t,options:e.registries.map($=>({value:$.name,label:`${$.name} · ${Qo($.url)}`,hint:$.url})),onChange:s}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]}),N&&e.registries.length===1&&i.jsx(V,{parts:[`Catalog ${N.name}`,{text:Qo(N.url),code:!0}]}),w?i.jsx(vT,{entry:w,catalogUrl:(N==null?void 0:N.url)??"",installed:j(w.id),preview:o.preview,add:o.add,onBack:()=>k(void 0)}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"catalog-filters",children:[i.jsx("input",{className:"catalog-search",placeholder:"Search guides","aria-label":"Search guides",value:l,onChange:$=>d($.target.value)}),i.jsx(M,{size:"sm",on:h,"aria-pressed":h,onClick:()=>f($=>!$),children:"Verified only"})]}),o.error&&i.jsx("span",{className:"vf-err",children:o.error}),!o.index&&!o.error&&i.jsx(Ie,{children:"Reading the catalog…"}),o.index&&!v.length&&i.jsx(Ie,{children:"No guides match."}),i.jsx("ul",{className:"catalog-list",children:v.map($=>i.jsx(kT,{entry:$,catalogUrl:(N==null?void 0:N.url)??"",installed:j($.id),onOpen:()=>k($.id)},$.id))})]})]})}),document.body)}function xT(e){const t=e.r.guide;if(!t)return null;const s=Object.entries(t.proposedChecks);if(!t.requiresChecks.length&&!s.length)return null;const o=e.r.status==="active";return i.jsxs("div",{className:"guide-checks",children:[t.requiresChecks.length>0&&i.jsxs("span",{className:"t-meta",children:["Adds checks ",i.jsx("code",{className:"t-code",children:t.requiresChecks.join(", ")})," to its tickets"]}),s.map(([a,l])=>{const d=e.r.pendingChecks.includes(a);return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[a,": ",qd(l.run)]}),d&&o&&i.jsx(Lv,{name:a,spec:l,busy:e.busy,onApprove:e.onApprove}),d&&!o&&i.jsx("span",{className:"t-meta",children:"approve the guide first"}),!d&&i.jsx("span",{className:"t-meta",children:"approved"})]},a)})]})}function jT(e){const{r:t}=e;if(!t.guide||!t.sha256)return null;const s=t.sha256;return i.jsxs("div",{className:"guide-review",children:[i.jsx(Ov,{p:{findings:t.findings,guide:t.guide}}),i.jsx(M,{size:"sm","aria-label":`Approve guide ${t.id}`,disabled:e.busy,onClick:()=>e.onApprove(s),children:"Approve"})]})}const ST="A file in guides/ replaces this built-in once you approve it; until then the built-in is used";function NT(e){var t,s;return e.override?ST:e.status==="unapproved"?(t=e.guide)==null?void 0:t.summary:e.reason??((s=e.guide)==null?void 0:s.summary)}function Pv(e){const{r:t}=e,s=t.id,o=t.override??t,a=(o.status==="unapproved"||o.status==="tampered")&&!!o.guide,l=t.status!=="active"||t.pendingChecks.length>0||a,d=t.guide?`${t.guide.name} ${t.guide.version}`:s;return i.jsx("li",{className:"guide-row","data-guide-id":s,children:i.jsx(be,{edge:l?"attention":"neutral",title:d,context:i.jsx(V,{parts:[{text:s,code:!0},uT(t),fT(t),dT(t),t.guide&&bT(t.guide.checklist.length)]}),detail:NT(t),actions:t.origin==="local"&&i.jsxs(M,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onAct("/guides/remove",{id:s}),children:["Remove guide ",s]}),below:i.jsxs(i.Fragment,{children:[a&&i.jsx(jT,{r:o,busy:e.busy,onApprove:h=>e.onAct("/guides/approve",{id:s,sha256:h})}),i.jsx(xT,{r:t,busy:e.busy,onApprove:(h,f)=>e.onAct("/guides/checks/approve",{id:s,name:h,acknowledged:f})})]})})})}const bT=e=>e===1?"1 checklist item":`${e} checklist items`;function $T(e){return i.jsxs(Ee,{title:"Write your own",children:[i.jsxs("p",{className:"vf-intro",children:["Write a guide for your team in your repo with ",i.jsxs("code",{className:"t-code",children:[Z.slug," guides new <id>"]}),". It starts from a template in ",i.jsxs("code",{className:"t-code",children:[Z.dataDir,"/guides/"]})," that passes the lint. Fill in the instructions and checklist, then approve it here: agents can only use it once you have, and again after every edit."]}),e.guides.length>0?i.jsx("ul",{className:"guides-list own-guides",children:e.guides.map(t=>i.jsx(Pv,{r:t,busy:e.busy,onAct:e.onAct},t.id))}):i.jsx(Ie,{children:"No guides of your own yet."}),e.error&&i.jsx("span",{className:"vf-err",children:e.error}),i.jsxs("p",{className:"t-meta guides-share",children:["Useful beyond your team? Check it with ",i.jsxs("code",{className:"t-code",children:[Z.slug," guides lint"]})," and"," ",i.jsx("a",{href:O0,target:"_blank",rel:"noreferrer",children:"share it in the public catalog"}),"."]})]})}function CT(e){const{view:t,act:s}=$n(),[o,a]=y.useState(),[l,d]=y.useState(!1),[h,f]=y.useState(!1),p=y.useRef(null);if(y.useEffect(()=>{var w;e.focus&&t&&((w=p.current)==null||w.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const k=w=>(j,N)=>{d(!0),s(j,N).then(S=>{a(S?{own:w,message:S}:void 0),d(!1)})},v=w=>o&&o.own===w?o.message:void 0;return i.jsxs("div",{className:"guides-section",ref:p,children:[i.jsxs(Ee,{title:"Guides",children:[i.jsx("p",{className:"vf-intro",children:"Guides give an agent instructions and a checklist for the tickets that ask for them. A guide can add checks, never remove them, and its commands only run once you approve them."}),i.jsx("ul",{className:"guides-list",children:t.guides.filter(w=>!fd(w)).map(w=>i.jsx(Pv,{r:w,busy:l,onAct:k(!1)},w.id))}),i.jsxs("div",{className:"guides-foot",children:[i.jsx(M,{size:"sm",onClick:()=>f(!0),children:"Browse guides"}),i.jsx(V,{parts:[{text:`${Z.dataDir}/guides/`,code:!0},{text:"guides.lock.json",code:!0}]})]}),t.configErrors.length>0&&i.jsx("ul",{className:"vf-errors",children:t.configErrors.map(w=>i.jsx("li",{children:w},w))}),v(!1)&&i.jsx("span",{className:"vf-err",children:v(!1)})]}),i.jsx($T,{guides:t.guides.filter(fd),busy:l,onAct:k(!0),error:v(!0)}),h&&i.jsx(wT,{registries:t.registries,onClose:()=>f(!1)})]})}function TT(e){const{view:t,act:s}=$n(),[o,a]=y.useState();if(!t)return null;const l=e.map.guides??[],d=t.guides.filter(f=>f.status==="active"&&f.guide),h=f=>{const p=l.includes(f)?l.filter(k=>k!==f):[...l,f];a(void 0),s("/guides/team",{mapId:e.map.id,guides:p}).then(a)};return i.jsxs(Ee,{title:`Team of ${e.map.key}`,children:[i.jsx("p",{className:"vf-intro",children:"The guides this trail works with. With Reviewer on the team, review tickets come with the reviewer's instructions and checklist."}),i.jsx("div",{className:"team-guides",children:d.map(f=>{const p=l.includes(f.id);return i.jsx(M,{size:"sm",on:p,"aria-pressed":p,title:f.guide.summary,onClick:()=>h(f.id),children:f.guide.name},f.id)})}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function ET(e,t){const[s,o]=y.useState(),a=`/guides/checklist?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`;return Ye({view:a,load:()=>qo(a),show:l=>o(l.checklist),failed:()=>o(null),changed:l=>l.endsWith("checklist.json")}),s}function AT(e){const t=ET(e.mapId,e.ticketId);if(!t)return null;const s=t.answers.filter(o=>!o.done).length;return i.jsxs("div",{className:"checklist-panel",children:[i.jsx(V,{parts:[`${t.guide.id} ${t.guide.version} checklist`,t.by,hr(t.at),s?`${s} not done`:"all done"]}),i.jsx(bv,{answers:t.answers})]})}const op="";function IT(e){const{view:t,act:s}=$n(),[o,a]=y.useState();if(!t)return null;const l=e.ticket,d=t.guides.filter(p=>{var k;return p.status==="active"&&((k=p.guide)==null?void 0:k.handles.types.includes(l.type))}),h=[{value:op,label:"No guide"},...d.map(p=>({value:p.id,label:p.guide.name,hint:p.guide.summary}))];l.guide&&!d.some(p=>p.id===l.guide)&&h.push({value:l.guide,label:l.guide});const f=p=>{a(void 0),s("/guides/ticket",{mapId:e.mapId,ticketId:l.id,guide:p||null}).then(a)};return i.jsxs("span",{className:"guide-picker",children:[i.jsx(at,{compact:!0,"aria-label":"Ticket guide",value:l.guide??op,options:h,onChange:f}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function RT(e){const{view:t,find:s}=$n();if(!t)return null;const o=s(e.id);if((o==null?void 0:o.status)==="active")return null;const a=o?o.reason??o.status:"it is not installed";return i.jsxs("p",{className:"guide-warning t-meta",children:["Guide ",e.id," can't be used: ",a,". Claims get no guide instructions until you approve it in Settings → Guides."]})}function MT(e){const{view:t}=$n(),s=e.ticket;return!t||s.state!=="open"&&!s.guide?null:i.jsxs("section",{className:"ticket-guide d-section",children:[i.jsxs("span",{className:"guide-head",children:[i.jsx("span",{className:"t-label",children:"Guide"}),s.state==="open"?i.jsx(IT,{mapId:e.mapId,ticket:s}):s.guide&&i.jsx(aT,{id:s.guide})]}),s.guide&&i.jsx(RT,{id:s.guide}),i.jsx(AT,{mapId:e.mapId,ticketId:s.id})]})}function LT(e){var f;const{view:t,find:s}=$n();if(!e)return;const o=s(e),a=t!=null&&(o==null?void 0:o.status)!=="active",l=((f=o==null?void 0:o.guide)==null?void 0:f.name)??e,d=o!=null&&o.guide?`${l} ${o.guide.version}`:l,h=a?`Guide ${d}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${d}`;return{id:e,name:l,tip:h,off:a}}const _v=()=>`${pe()}/proof/settings`;async function OT(){const e=await fetch(_v());return e.ok?await e.json():null}function PT(){const[e,t]=y.useState(),{pushed:s}=Ye({load:OT,show:a=>t((a==null?void 0:a.enabled)??null),failed:()=>t(null),events:{proof:()=>!0}}),o=y.useCallback(async a=>{const l=await fetch(_v(),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:a})}),d=await l.json();if(!l.ok)return d.error??`Saving failed (${l.status})`;s(),t(d.enabled===!0)},[s]);return{enabled:e,set:o}}function _T(){const{enabled:e,set:t}=PT(),[s,o]=y.useState();if(e==null)return null;const a=()=>{o(void 0),t(!e).then(o,l=>o(l.message))};return i.jsxs(Ee,{title:"Proof on pull requests",children:[i.jsxs("p",{className:"vf-intro",children:["When a ticket is done and its pull request is open, post its Verified by Teamtrail report as one comment on the PR, with a ",i.jsx("b",{children:"Teamtrail proof"})," check next to CI. The comment is updated, never repeated, when the proof or the PR changes."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Post proofs from this machine"}),i.jsx(M,{size:"sm",on:e,"aria-pressed":e,className:"proof-post-toggle",onClick:a,children:e?"On":"Off"})]}),i.jsxs("span",{className:"set-hint t-meta",children:["Posted with your GitHub token, to the repo Teamtrail syncs pull requests with (",i.jsx("code",{children:"github"})," in verification.json). Only this machine posts: a teammate switches it on in their own Lookout. The check passes only when the ticket is verified at the PR's latest commit."]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}function DT(e){var l;const[t,s]=y.useState({kind:"idle"}),o=(l=ft())==null?void 0:l.merge;if(!o||!e.verified)return null;const a=async()=>{s({kind:"working"});try{const d=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trail:e.mapId,ticket:e.ticketId})}),h=await d.json().catch(()=>({}));if(d.ok&&h.merged)return s({kind:"merged",url:h.url?Nn(h.url):void 0});s({kind:"error",text:String(h.error??`The server answered ${d.status}.`).slice(0,300)})}catch{s({kind:"error",text:"The server didn't answer. Try again."})}};return t.kind==="merged"?i.jsxs("span",{className:"t-meta merge-note",children:["Approved and merged at the verified commit."," ",t.url&&i.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",children:"See the pull request"})]}):t.kind==="confirm"?i.jsxs("div",{className:"merge-confirm",children:[i.jsx("span",{className:"t-meta",children:"Merge its pull request, at exactly the commit Teamtrail verified?"}),i.jsx(M,{size:"sm",onClick:()=>void a(),children:"Merge"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>s({kind:"idle"}),children:"Cancel"})]}):i.jsxs("div",{className:"merge-confirm",children:[i.jsx(M,{size:"sm",disabled:t.kind==="working",onClick:()=>s({kind:"confirm"}),children:t.kind==="working"?"Merging…":"Approve and merge"}),t.kind==="error"&&i.jsx("span",{className:"t-meta",children:t.text})]})}function zT(e,t){const[s,o]=y.useState();return Ye({load:async()=>{const a=new URLSearchParams({mapId:e,ticketId:t}),l=await fetch(`${pe()}/proof/ticket?${a}`);return l.ok?await l.json():null},show:o,failed:()=>o(null),view:`${e}/${t}`,changed:a=>a.includes(`tickets/${t}.md`),events:{verification:()=>!0,proof:()=>!0}}),s}function BT(e){const t=zT(e.mapId,e.ticket.id),[s,o]=y.useState(!1);if(!t)return null;const{proof:a,post:l}=t,d=e.ticket.state==="closed"&&e.ticket.closeReason==="completed";if(!d&&!a.attempt.id)return null;const h=a.status==="verified",f=()=>void navigator.clipboard.writeText(t.markdown).then(()=>{o(!0),setTimeout(()=>o(!1),1500)}),p=l!=null&&l.commentUrl?Nn(l.commentUrl):void 0;return i.jsxs("section",{className:"d-section ticket-proof",children:[i.jsx("span",{className:"t-label",children:"Proof"}),i.jsxs("div",{className:"proof-head",children:[i.jsx(bn,{tone:h?"fill":"amber",children:h?"Verified by Teamtrail":"Not verified"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:f,children:s?"Copied":"Copy for PR"})]}),a.gaps.length>0&&i.jsx("ul",{className:"proof-gaps t-meta",children:a.gaps.map(k=>i.jsx("li",{children:k},k))}),i.jsx(V,{className:"t-meta",parts:[a.checks.length>0&&`${a.checks.filter(k=>k.passed).length}/${a.checks.length} checks passed`,a.criteria.lines.length>0&&`${a.criteria.verified} criteria verified, ${a.criteria.claimed} claimed`,a.reviews.length>0&&`${a.reviews.length} review${a.reviews.length>1?"s":""}`,{text:a.digest.slice(0,19),code:!0}]}),d&&i.jsx(DT,{mapId:e.mapId,ticketId:e.ticket.id,verified:h}),p&&i.jsxs("a",{className:"t-meta",href:p,target:"_blank",rel:"noreferrer",children:["Posted on pull request #",l.pr]}),(l==null?void 0:l.error)&&i.jsxs("span",{className:"t-meta",children:["Posting failed, trying again: ",l.error]}),t.keyFile&&i.jsxs("span",{className:"t-meta",children:["Signed with this machine's key. Commit ",i.jsx("code",{children:`${Z.dataDir}/${t.keyFile}`})," so others can check it."]})]})}const Dv="0.52.0",md="<endpoint>",Qd=zp(Dv,["mcp","--http"]);function FT(e,t){const s=zp(Dv,["connect",e,"--url"]),o=t===md?t:Dp(t);return`read -rs ${Z.tokenEnv} && export ${Z.tokenEnv}
|
|
152
|
-
${s} ${o}`}function UT(e){return e.kind==="lookout"?["the Lookout","this machine only"]:["for remote agents",e.network?"open to your network":"this machine only, until a tunnel or proxy shares it"]}function WT({endpoints:e}){const t=e.some(s=>s.kind==="standalone");return i.jsxs("ul",{className:"ra-endpoints",children:[e.map(s=>i.jsx("li",{children:i.jsx(V,{className:"set-hint",parts:[{text:s.url,code:!0},...UT(s)]})},s.url)),!t&&i.jsx("li",{children:i.jsx(V,{className:"set-hint",parts:["For agents on other machines, start their server",{text:Qd,code:!0}]})})]})}function HT(e){const[t,s]=y.useState(""),[o,a]=y.useState(!1),[l,d]=y.useState(),h=async f=>{if(!f.trim()||o)return;a(!0);const p=await e.onCreate(f).catch(k=>k.message);a(!1),d(p),p||s("")};return i.jsxs("div",{className:"ra-new",children:[i.jsx(wa,{value:t,onValueChange:s,onSubmit:h,action:"Create token",actionDisabled:o||!t.trim(),placeholder:"Name the agent, e.g. cloud sandbox 1","aria-label":"Agent name",maxLength:60}),l&&i.jsx("span",{className:"vf-err",children:l})]})}function KT(){return i.jsx(Ee,{title:"Remote agents",children:i.jsxs("p",{className:"vf-intro",children:["Tokens for remote agents are created and revoked on the machine ",Z.name," runs on. Open the Lookout there to manage them."]})})}function VT(e){const[t,s]=y.useState(!1),[o,a]=y.useState(!1),[l,d]=y.useState(),h=async()=>{a(!0),d(await e.onRevoke().catch(f=>f.message)),a(!1),s(!1)};return t?i.jsxs("span",{className:"ra-revoke ask",children:[i.jsx("span",{className:"t-meta",children:"Its sessions end now."}),i.jsxs(M,{size:"sm",disabled:o,onClick:h,children:["Revoke ",e.name]}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]}):i.jsxs("span",{className:"ra-revoke",children:[i.jsx(M,{size:"sm","aria-label":`Revoke ${e.name}`,onClick:()=>s(!0),children:"Revoke"}),l&&i.jsx("span",{className:"vf-err",children:l})]})}function GT(e){if(!e.tokens.length)return null;const t=Date.now();return i.jsx("ul",{className:"ra-list",children:e.tokens.map(s=>i.jsx(be,{as:"li",className:"ra-row",title:s.name,titleText:s.name,context:i.jsx(V,{parts:[`Created ${Go(s.createdAt,t)}`,s.lastUsedAt?`Last used ${Go(s.lastUsedAt,t)}`:"Never used"]}),below:i.jsx(VT,{name:s.name,onRevoke:()=>e.onRevoke(s.id)})},s.id))})}function Uc(e){const[t,s]=y.useState(!1),o=()=>{var a;return void((a=navigator.clipboard)==null?void 0:a.writeText(e.value).then(()=>{s(!0),setTimeout(()=>s(!1),1500)},()=>s(!1)))};return i.jsxs("div",{className:"ra-copy",children:[i.jsx("code",{className:"ra-copy-value t-code","aria-label":e.label,children:e.value}),i.jsx(M,{size:"sm",className:"ra-copy-btn",onClick:o,children:t?"Copied":e.copyLabel??"Copy"})]})}const qT=[{id:"claude",label:"Claude Code"},{id:"codex",label:"Codex"}];function QT(e){const[t,s]=y.useState("claude");return i.jsxs("div",{className:"ra-reveal",role:"status",children:[i.jsxs("p",{className:"ra-reveal-title t-row-title",children:["Token for ",e.created.name]}),i.jsxs("p",{className:"t-body ra-note",children:["Copy it now. ",Z.name," keeps only a fingerprint, so it can't show it again."]}),i.jsx(Uc,{label:"Token",value:e.created.token,copyLabel:"Copy token"}),!e.endpoint&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"ra-reveal-head",children:i.jsx(ze,{children:"Start the server for remote agents"})}),i.jsx(Uc,{label:"Start command",value:Qd,copyLabel:"Copy command"})]}),i.jsxs("div",{className:"ra-reveal-head",children:[i.jsx(ze,{children:"Run on the agent's machine"}),i.jsx("span",{className:"ra-clients",children:qT.map(o=>i.jsx(M,{size:"sm",on:t===o.id,"aria-pressed":t===o.id,onClick:()=>s(o.id),children:o.label},o.id))})]}),i.jsx(Uc,{label:"Connect command",value:FT(t,e.endpoint??md),copyLabel:"Copy command"}),i.jsxs("p",{className:"t-meta ra-note",children:["The first line waits for the token: paste it and press Enter. It isn't shown, and it stays out of your shell history."," ",e.endpoint?"From another machine, use the address that machine reaches this one by.":`Put the address the server prints in place of ${md}.`,t==="codex"&&` Start Codex from the same shell: it reads $${Z.tokenEnv} each time.`]}),i.jsx("span",{children:i.jsx(M,{variant:"primary",size:"sm",onClick:e.onDone,children:"I've copied it"})})]})}const zv=`${pe()}/remote-agents`;async function ap(e,t){const s=await fetch(`${zv}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:s.ok,reply:await s.json()}}async function YT(){const e=await fetch(zv);return e.ok?await e.json():(await e.json().catch(()=>({}))).elsewhere?"elsewhere":null}function JT(){const[e,t]=y.useState(),[s,o]=y.useState(),{pushed:a}=Ye({load:YT,show:t,failed:()=>t(null),events:{"remote-agents":()=>!0}}),l=y.useCallback(f=>{a(),t({tokens:f.tokens,endpoints:f.endpoints})},[a]),d=y.useCallback(async f=>{const{ok:p,reply:k}=await ap("/tokens",{name:f});if(!p||!k.token||!k.created)return k.error??"The token could not be created.";l(k),o({token:k.token,name:k.created.name})},[l]),h=y.useCallback(async f=>{const{ok:p,reply:k}=await ap("/tokens/revoke",{id:f});return k.tokens&&l(k),p?void 0:k.error??"The token could not be revoked."},[l]);return{view:e,created:s,dismissCreated:()=>o(void 0),create:d,revoke:h}}function XT(){var d;const{view:e,created:t,dismissCreated:s,create:o,revoke:a}=JT();if(!e)return null;if(e==="elsewhere")return i.jsx(KT,{});const l=(d=e.endpoints.find(h=>h.kind==="standalone"))==null?void 0:d.url;return i.jsxs(Ee,{title:"Remote agents",children:[i.jsx("p",{className:"vf-intro",children:"Agents on another machine or in a cloud sandbox can work this repo's trails too. They connect over HTTP with a token and share the tickets, claims and inbox of the agents here. One token per agent; revoke it and that agent is out within about a second."}),i.jsx(WT,{endpoints:e.endpoints}),t&&i.jsx(QT,{created:t,endpoint:l,onDone:s}),i.jsx(GT,{tokens:e.tokens,onRevoke:a}),e.tokens.length===0&&i.jsx("p",{className:"t-meta ra-note",children:"No tokens, so the endpoint is closed: every request is refused."}),i.jsx(HT,{onCreate:o}),i.jsxs("div",{className:"ra-notes",children:[i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"Before you open it to other machines."})," The connection is plain HTTP. Run ",i.jsx("code",{children:Qd}),", which serves the agent tools and nothing else, and put that port behind HTTPS with a reverse proxy or a tunnel. The Lookout's own port is not for sharing: its agent endpoint answers this machine only. A token only ever opens the agent tools, never the Lookout, which signs in browsers, not agents."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What a remote agent can't do."})," Speak for you: it can't answer a question, skip discovery, change the trail's mode or destination, or close a ticket that needs you before you've answered here or in Slack. And its files aren't on this machine, so it gets no worktree, and on trails with verification its finished work comes to you to review instead of running the checks here."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"How far to trust one."})," The risk policy only sees what an agent declares: a call is held for you when the agent names a high-risk category or touches files your path rules cover. An agent that declares nothing isn't caught. Give an agent you don't fully trust only trails with verification on, where its finished work comes to you."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it does as you."})," With GitHub Issues or Linear as the tracker, everything a remote agent writes (tickets, comments, closing) goes to the tracker with your credentials, like the agents here."]})]})]})}const lp={schema:"Database schema","breaking-api":"Breaking API changes","auth-permissions":"Auth and permissions",billing:"Billing","data-deletion":"Deleting data","product-behaviour":"Product behaviour",dependencies:"Dependencies"},ZT={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},e2=e=>e[0].toUpperCase()+e.slice(1),pd=cg.map(e=>({value:e,label:e2(e),hint:ZT[e]}));function t2(e){const[t,s]=y.useState(""),[o,a]=y.useState("high"),{rules:l,onChange:d}=e,h=()=>{const f=t.trim();!f||l.some(p=>p.glob===f)||(d([...l,{glob:f,level:o}]),s(""))};return i.jsxs("div",{className:"risk-paths",children:[i.jsx("span",{className:"mono-label",children:"Files"}),l.map((f,p)=>i.jsxs("div",{className:"risk-row",children:[i.jsx("code",{children:f.glob}),i.jsx(at,{compact:!0,"aria-label":`${f.glob} risk`,value:f.level,options:pd,onChange:k=>d(l.map((v,w)=>w===p?{...v,level:k}:v))}),i.jsx("button",{className:"icon-btn","aria-label":`Remove ${f.glob}`,onClick:()=>d(l.filter((k,v)=>v!==p)),children:"×"})]},f.glob)),i.jsxs("div",{className:"risk-row",children:[i.jsx("input",{value:t,placeholder:"src/payments/**","aria-label":"New file pattern",onChange:f=>s(f.target.value),onKeyDown:f=>f.key==="Enter"&&h()}),i.jsx(at,{compact:!0,"aria-label":"New pattern risk",value:o,options:pd,onChange:a}),i.jsx(M,{onClick:h,disabled:!t.trim(),children:"Add"})]})]})}const Bv=`${pe()}/policy`;async function n2(){const e=await fetch(Bv);return e.ok?await e.json():null}function s2(){const[e,t]=y.useState(),{pushed:s}=Ye({load:n2,show:t,failed:()=>t(null),changed:a=>a.endsWith("policy.json")}),o=y.useCallback(async a=>{const l=await fetch(Bv,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),d=await l.json();if(!l.ok)return d.error??`Saving failed (${l.status})`;s(),t(d)},[s]);return{view:e,save:o}}function i2(){const{view:e,save:t}=s2(),[s,o]=y.useState();if(!e)return null;const a=`${Z.dataDir}/policy.json`,l=d=>{o(void 0),t(d).then(o,h=>o(h.message))};return i.jsxs(Ee,{title:"Risk policy",children:[i.jsx("p",{className:"vf-intro",children:"What agents may decide on their own. High: they must ask you. Medium: they decide, follow your conventions and record it for you to review. Low: they just decide."}),i.jsx("div",{className:"risk-grid",children:lg.map(d=>i.jsxs("label",{className:"risk-row",children:[i.jsx("span",{children:lp[d]}),i.jsx(at,{compact:!0,"aria-label":`${lp[d]} risk`,value:e.policy.categories[d],options:pd,onChange:h=>l({...e.policy,categories:{...e.policy.categories,[d]:h}})})]},d))}),i.jsx(t2,{rules:e.policy.paths,onChange:d=>l({...e.policy,paths:d})}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[a," has errors, so the defaults apply until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(d=>i.jsx("li",{children:d},d))})]}),e.defaults&&e.errors.length===0&&i.jsxs("span",{className:"set-hint t-meta",children:["Defaults. Changing anything saves ",a,", so your team shares it."]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}const gd=`${pe()}/workspaces`;async function r2(){const e=await fetch(gd);return e.ok?await e.json():null}function Fv(){const[e,t]=y.useState(),{pushed:s}=Ye({load:r2,show:t,failed:()=>t(null),changed:d=>d.endsWith("workspaces.json")||d.includes("workspaces/")||d.includes("leases/")}),o=y.useCallback(d=>{s(),t(d)},[s]),a=y.useCallback(async d=>{const h=await fetch(gd,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)}),f=await h.json();if(!h.ok)return f.error??`Saving failed (${h.status})`;o(f)},[o]),l=y.useCallback(async(d,h,f=!1)=>{const p=await fetch(`${gd}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:d,ticketId:h,force:f})}),k=await p.json();return p.ok?(o(k),{}):{error:k.error??`Removing failed (${p.status})`,dirty:k.dirty??!1}},[o]);return{view:e,save:a,remove:l}}function Uv(e){const[t,s]=y.useState(!1),[o,a]=y.useState(),[l,d]=y.useState(!1),h=async f=>{d(!0),a(void 0);const p=await e.onRemove(f).catch(k=>({error:k.message,dirty:!1}));d(!1),s(!!p.dirty&&!f),p.dirty||a(p.error)};return t?i.jsxs("span",{className:"ws-remove ask",children:[i.jsx("span",{className:"vf-err",children:"Uncommitted changes in this workspace will be lost."}),i.jsx(M,{size:"sm",disabled:l,onClick:()=>h(!0),children:"Remove anyway"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]}):i.jsxs("span",{className:"ws-remove",children:[i.jsx(M,{size:"sm",disabled:l,onClick:()=>h(!1),children:e.label??"Remove"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function o2(e){return e.rows.length?i.jsx("ul",{className:"ws-list",children:e.rows.map(t=>i.jsx(be,{as:"li",className:`ws-row ${t.active?"active":"finished"}`,title:i.jsx("span",{className:"t-code",children:t.branch}),titleText:t.branch,context:i.jsx(V,{parts:[{text:t.ticketKey,code:!0},t.active?`Active · ${t.agent}`:"Finished"]}),detail:i.jsx("span",{className:"t-code",children:t.path}),detailText:t.path,below:t.active?void 0:i.jsx(Uv,{onRemove:s=>e.onRemove(t.mapId,t.ticketId,s)})},`${t.mapId}/${t.ticketId}`))}):null}function a2(e){const{view:t,remove:s}=Fv(),o=t==null?void 0:t.workspaces.find(a=>a.mapId===e.mapId&&a.ticketId===e.ticketId);return!o||o.active?null:i.jsxs("section",{className:"ticket-workspace d-section",children:[i.jsx("span",{className:"t-label",children:"Workspace"}),i.jsxs("p",{className:"t-meta",children:["Branch ",i.jsx("code",{className:"t-code",children:o.branch})," in"," ",i.jsx("code",{className:"t-code",title:o.path,children:o.path})]}),i.jsx(Uv,{label:"Remove workspace",onRemove:a=>s(e.mapId,e.ticketId,a)})]})}function l2(){const{view:e,save:t,remove:s}=Fv(),[o,a]=y.useState();if(!e)return null;const l=e.settings.worktrees,d=()=>{a(void 0),t({...e.settings,worktrees:!l}).then(a,h=>a(h.message))};return i.jsxs(Ee,{title:"Workspaces",children:[i.jsxs("p",{className:"vf-intro",children:["Give each agent its own copy of the repo for every ticket it claims, on its own branch, so agents working at the same time don't step on each other. You review and merge the branches; ",Z.name," never merges or pushes."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"A worktree per ticket"}),i.jsx(M,{size:"sm",on:l,"aria-pressed":l,className:"worktrees-toggle",onClick:d,children:l?"On":"Off"})]}),i.jsx(V,{className:"set-hint",parts:[{text:`${Z.dataDir}/workspaces.json`,code:!0},cp(e.workspaces.filter(h=>h.active).length,"active"),cp(e.workspaces.filter(h=>!h.active).length,"finished")]}),i.jsx(o2,{rows:e.workspaces,onRemove:s}),e.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:e.errors.map(h=>i.jsx("li",{children:h},h))}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const cp=(e,t)=>`${e} ${t}`;function c2({data:e,route:t}){var s;return i.jsxs(i.Fragment,{children:[i.jsx(Ke,{id:"approvals",storage:"machine",children:i.jsx(iT,{})}),i.jsx(Ke,{id:"tracker",children:i.jsx(Ee,{title:"Tracker",children:(s=ft())!=null&&s.tracker?i.jsx("p",{className:"vf-intro",children:"Trails are kept by the server this Lookout runs on, in its own storage."}):i.jsx(xC,{activeTracker:e.activeTracker,location:e.location,update:e.update})})}),i.jsx(Ke,{id:"workspaces",storage:"repo",children:i.jsx(l2,{})}),i.jsx(Ke,{id:"proof",storage:"machine",children:i.jsx(_T,{})}),i.jsx(Ke,{id:"remote-agents",storage:"machine",children:i.jsx(XT,{})}),i.jsx(Ke,{id:"policy",storage:"repo",children:i.jsx(i2,{})}),i.jsx(Ke,{id:"guides",storage:"repo",children:i.jsx(CT,{focus:t.section==="guides"})}),i.jsx(Ke,{id:"labels",children:i.jsx(Ee,{title:"Labels",children:i.jsxs("div",{className:"label-codes",children:[i.jsx("code",{children:xd}),i.jsxs("code",{children:[Z.labelPrefix,":<type>"]}),i.jsx("code",{children:jd}),i.jsx("code",{children:Sd})]})})})]})}const vd=`${Z.apiPrefix}/projects`;async function Xi(e,t,s){const o=await fetch(`${vd}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:s===void 0?void 0:JSON.stringify(s)}),a=await o.json().catch(()=>({}));if(!o.ok)throw new Error(a.error??`HTTP ${o.status}`);return a}const ms={url:vd,add:e=>Xi("","POST",{path:e}),remove:e=>Xi(`/${e}`,"DELETE"),setAutoRegister:e=>Xi("/settings","PUT",{autoRegister:e}),setShare:(e,t)=>Xi(`/${e}/share`,"PUT",{share:t}),answer:(e,t)=>Xi(`/${e}/answer`,"POST",t),async briefing(e){const t=await fetch(`${vd}/briefing?since=${e}`);return t.ok?await t.json():void 0}};function Wv(e){const[t,s]=y.useState(""),[o,a]=y.useState(),l=d=>{d.trim()&&(a(void 0),ms.add(d.trim()).then(()=>(s(""),e.onAdded()),h=>a(h.message)))};return i.jsxs("div",{className:"pj-add",children:[i.jsx(wa,{value:t,onValueChange:s,onSubmit:l,action:"Add project",placeholder:`/path/to/repo (a ${Z.dataDir} folder is created if missing)`,"aria-label":"Repo path",className:"t-code"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Ks=(e,t)=>e>0&&`${e} ${t}`;function d2(e){var s;const t=((s=e.briefing)==null?void 0:s.projects)??[];return!e.briefing||!t.length?null:i.jsxs("section",{className:"pj-section pj-briefing",children:[i.jsx(Et,{title:"While you were away",count:t.length,info:`What changed in each project since ${hn(e.now-e.briefing.since)} ago`}),i.jsx("ul",{className:"pj-list",children:t.map(({projectId:o,project:a,briefing:l})=>i.jsx(be,{as:"li",edge:l.totals.waiting>0?"attention":"neutral",title:a,context:i.jsx(V,{parts:[Ks(l.totals.done,"done"),Ks(l.trails.reduce((d,h)=>d+h.opened.length,0),"new tickets"),Ks(l.totals.agentDecisions,"agent decisions"),Ks(l.totals.waiting,"waiting on you"),Ks(l.totals.ruledOut,"ruled out"),Ks(l.totals.active,"agents active")]}),onOpen:()=>e.onOpen(o)},o))})]})}function u2(e){const[t,s]=y.useState(""),[o,a]=y.useState(!1),[l,d]=y.useState(),h=f=>{!f.trim()||o||(a(!0),d(void 0),e.onAnswer(f.trim()).then(()=>s(""),p=>d(p.message)).finally(()=>a(!1)))};return i.jsxs("div",{className:"pj-answer",children:[i.jsx(wa,{value:t,onValueChange:s,onSubmit:h,action:"Answer",disabled:o,placeholder:"Your answer","aria-label":"Your answer"}),l&&i.jsx("span",{className:"vf-err",children:l})]})}function h2(e){const{item:t}=e,s=cv(t),o=t.kind==="question"&&t.agent?`${t.agent} asks`:av[t.kind],a=t.urgency==="blocking"&&{text:"Blocking",urgent:!0,className:"urgency-tag"};return i.jsx(be,{as:"li",className:`att-item pj-item k-${t.kind}`,edge:lv(t,t.interrupting),title:t.title.split(`
|
|
151
|
+
`)}),tp[t.kind]&&i.jsx("p",{className:"ap-note t-meta",children:tp[t.kind]}),t.warnings.length>0&&i.jsx("ul",{className:"ap-warnings t-meta",children:t.warnings.map(l=>i.jsxs("li",{children:["Worth a look: ",l]},l))}),e.local&&i.jsx(M,{size:"sm",disabled:e.busy,onClick:e.onApprove,children:"Approve"})]})})}async function np(e,t){const s=await fetch(`${pe()}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await s.json().catch(()=>({}));if(!s.ok)throw new Error(o.error??`Request failed (${s.status})`);return o}const Fc=async e=>e.ok?await e.json():void 0;async function sp(){var p;const[e,t,s]=await Promise.all(["/trust","/trackers","/trackers/legacy-outbox"].map(v=>fetch(`${pe()}${v}`))),o=await Fc(e);if(!o)return null;const{items:a}=o,l=(p=await Fc(t))==null?void 0:p.pending,d=await Fc(s),h=o.firstRun===!0,f=o.stateFirstRun===!0;return{items:a,firstRun:h,stateFirstRun:f,...l?{tracker:l}:{},...d!=null&&d.writes?{oldQueue:d}:{}}}const tT=(e,t)=>{var s,o,a,l;return JSON.stringify([e.items.map(d=>d.hash),(s=e.tracker)==null?void 0:s.target,(o=e.oldQueue)==null?void 0:o.writes])===JSON.stringify([t.items.map(d=>d.hash),(a=t.tracker)==null?void 0:a.target,(l=t.oldQueue)==null?void 0:l.writes])};function nT(e){var s,o;const t=[(s=e.changed)!=null&&s.length?`${e.changed.length} changed while you looked, so they wait; look again`:"",(o=e.refused)!=null&&o.length?`${e.refused.length} not committed, so they need their own look`:""].filter(Boolean);return t.length?`${t.join(". ")}.`:void 0}function sT(){const[e,t]=y.useState(),[s,o]=y.useState(!1),a=y.useRef();y.useEffect(()=>void(a.current=e),[e]);const l=y.useRef(0),[d]=y.useState(ni),h=y.useRef(0),f=y.useCallback(()=>{h.current++;const j=d.start(),N=S=>{j()&&(a.current=S,t(S),o(!1))};return sp().then(N,()=>N(null))},[d]),p=y.useCallback(async()=>{if(l.current)return;const j=h.current,N=await sp().catch(()=>null),S=a.current;h.current!==j||S===void 0||(!N||!S||!tT(N,S))&&o(!0)},[]);y.useEffect(()=>void f(),[f]),y.useEffect(()=>Pd(j=>void(j.startsWith(".")||p())),[p]),y.useEffect(()=>vs(()=>void p()),[p]);const v=y.useCallback(async j=>{l.current++;try{const N=await j();return await f(),N}finally{l.current--}},[f]),k=y.useCallback(async j=>nT(await v(()=>np("/trust/approve",{items:j.map(N=>({key:N.key,hash:N.hash}))}))),[v]),w=y.useCallback(async(j,N)=>{await v(()=>np(j,N))},[v]);return{view:e,changed:s,load:f,approve:k,act:w}}function iT(){const{view:e,changed:t,load:s,approve:o,act:a}=sT(),l=$a()!==!1,[d,h]=y.useState(!1),[f,p]=y.useState();if(!e)return null;const v=$=>{h(!0),p(void 0),$.then(_=>(h(!1),p(_??void 0)),_=>(h(!1),p(_.message)))},{items:k,tracker:w,oldQueue:j}=e,N=$=>!$.alone&&($.kind==="state"?e.stateFirstRun&&$.standing==="elsewhere":e.firstRun),S=k.filter($=>$.committed!==!1&&N($)),I=k.length+(w?1:0)+(j?1:0);return i.jsxs(Ee,{title:"Approvals",children:[i.jsxs("p",{className:"vf-intro",children:["Some files in the repo tell ",Z.name," what to trust: the commands checks run, where trails are kept, what needs you, how much each trail is checked, and briefs, criteria and knowledge marked accepted. Agents can edit those files and teammates push them, so nothing in them takes effect on this machine until you approve it here, exactly as it is. The same goes for a trail's state: a ticket closed, retyped, claimed or unblocked, a level or mode changed, or a decision written by editing files instead of through ",Z.name," shows here as changed outside ",Z.name,", and counts only once you accept it."]}),t&&i.jsxs("div",{className:"sync-line alert ap-changed",role:"status",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:"Files changed while you were here. What's below is what you saw."}),i.jsx(M,{size:"sm",onClick:s,children:"Review again"})]}),I===0&&i.jsx("p",{className:"ap-none t-meta",children:"Nothing waiting. Everything the repo asks for is approved here."}),S.length>1&&i.jsx("p",{className:"ap-adopt",children:GC(S.length)}),k.some($=>$.kind==="state")&&i.jsx("p",{className:"ap-note t-meta",children:VC}),I>0&&i.jsxs("ul",{className:"ap-list",children:[w&&i.jsx(ZC,{tracker:w,busy:d,local:l,onDecide:$=>v(a("/trackers/approval",{use:$,target:w.target}))}),j&&i.jsx(QC,{queue:j,busy:d,local:l,onDecide:$=>v(a("/trackers/legacy-outbox",{action:$?"send":"discard",writes:j.writes}))}),k.map($=>$.kind==="state"?i.jsx(XC,{item:$,busy:d,local:l,onAccept:()=>v(o([$])),onRevert:_=>v(a("/trust/revert",{key:$.key,hash:$.hash,remove:_}))},$.key):i.jsx(eT,{item:$,busy:d,local:l,onApprove:()=>v(o([$]))},$.key))]}),l&&S.length>1&&i.jsxs(M,{disabled:d||t,onClick:()=>v(o(S)),children:["Approve all ",S.length," committed"]}),!l&&I>0&&i.jsxs("p",{className:"t-meta",children:["Approve these on the machine ",Z.name," runs on."]}),f&&i.jsx("span",{className:"vf-err",children:f}),i.jsx(V,{className:"set-hint",parts:qC})]})}function bv(e){return i.jsx("ul",{className:"checklist-answers",children:e.answers.map(t=>i.jsxs("li",{className:t.done?"done":"not-done",children:[i.jsx("span",{className:"mark","aria-label":t.done?"Done":"Not done",children:t.done?"✓":"–"}),i.jsx("span",{className:"t-body",children:t.item}),t.note&&i.jsx("span",{className:"t-meta note",children:t.note})]},t.item))})}const $v=`${Z.apiPrefix}`;async function Cv(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`Request failed (${e.status})`);return t}const qo=async e=>Cv(await fetch(`${$v}${e}`)),Tv=async(e,t)=>Cv(await fetch(`${$v}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}));let Ev;const Po=new Set;let Yn;function hd(e){Ev=e;for(const t of Po)t()}function Av(e){Yn==null||Yn.pushed(),hd(e)}const rT=()=>Ev;function oT(e){return Po.add(e),Yn??(Yn=iv({load:()=>qo("/guides"),show:hd,failed:()=>hd(null),changed:t=>t.includes("guides")})),()=>{Po.delete(e),!Po.size&&(Yn==null||Yn.stop(),Yn=void 0)}}function $n(){const e=y.useSyncExternalStore(oT,rT),t=y.useCallback(async(o,a)=>{try{Av(await Tv(o,a));return}catch(l){return l.message}},[]),s=y.useCallback(o=>o?e==null?void 0:e.guides.find(a=>a.id===o):void 0,[e]);return{view:e,act:t,find:s}}function aT(e){var h;const{view:t,find:s}=$n(),o=s(e.id),a=t!=null&&(o==null?void 0:o.status)!=="active",l=((h=o==null?void 0:o.guide)==null?void 0:h.name)??e.id,d=a?`${l}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${l}`;return i.jsx("span",{className:Ge("guide-chip",a&&"off"),"data-guide-id":e.id,title:d,children:l})}const lT={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"},cT={active:"Approved",unapproved:"Not approved yet",tampered:"Changed since you approved it",invalid:"Can't be used"},fd=e=>{var t;return e.origin==="local"&&(!((t=e.lock)!=null&&t.source)||e.lock.source==="local")};function dT(e){return fd(e)?{text:cT[e.status],strong:e.status==="active"}:e.status==="active"?void 0:lT[e.status]}function Qo(e){try{return new URL(e).host}catch{return e}}function uT(e){var s;if(e.origin==="builtin")return"Built in";const t=(s=e.lock)==null?void 0:s.source;return!t||t==="local"?e.overridesBuiltin?"Local, replaces the built-in":"Local":`From ${Qo(t.registry)}`}const qd=e=>e.map(t=>/\s/.test(t)?JSON.stringify(t):t).join(" "),ip=3;function hT(e,t){return e.length<=Math.max(t,ip+1)?e:`${e.slice(0,Math.max(t-1,ip)).trimEnd()}…`}function Iv(e){return e===L0?"Verified":`Verified by ${Qo(e)}'s catalog`}function Rv(e,t){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:Iv(t),strong:!0}:"Not reviewed"}function fT(e){var l,d;const t=(l=e.lock)==null?void 0:l.review;if(!t||e.status!=="active")return;if(!t.verified)return"Not reviewed";const s=t.reviewedBy.length>0?`Reviewed by ${t.reviewedBy.join(", ")}`:void 0,o=(d=e.lock)==null?void 0:d.source;return{text:o&&o!=="local"?Iv(o.registry):"Verified",strong:!0,tip:s}}var Mv=_p();function Lv(e){return yS(e.spec)?i.jsxs("span",{className:"guide-unknown",children:[i.jsx("span",{className:"t-body",children:"Unknown program: Teamtrail can't tell what this runs. Approve it only if you know what it does."}),i.jsxs(M,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(e.name,!0),children:["I know what it runs: approve check ",e.name]})]}):i.jsxs(M,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(e.name,!1),children:["Approve check ",e.name]})}function mT(e){var w;const{preview:t}=e,{act:s,find:o}=$n(),[a,l]=y.useState({kind:"ready"}),[d,h]=y.useState(),f=t.entry.id,p=async()=>{h(void 0),l({kind:"adding"});try{l({kind:"added",pending:(await e.add(f,t.entry.sha256)).pendingChecks})}catch(j){h(j.message),l({kind:"ready"})}};if(t.entry.builtin)return i.jsxs("span",{className:"t-meta",children:["Built into ",Z.name,": already available to every trail, nothing to add."]});if(a.kind!=="added"){const j=e.installed===t.entry.version,N=e.installed?"Update guide":"Add guide";return i.jsxs("div",{className:"add-guide",children:[!t.ok&&i.jsx("span",{className:"t-meta",children:"The lint found errors, so this guide can't be added."}),i.jsx(M,{variant:"primary",disabled:!t.ok||j||a.kind==="adding",onClick:()=>void p(),children:j?"Added":N}),d&&i.jsx("span",{className:"vf-err",children:d})]})}const v=((w=o(f))==null?void 0:w.pendingChecks)??a.pending,k=async(j,N)=>h(await s("/guides/checks/approve",{id:f,name:j,acknowledged:N}));return i.jsxs("div",{className:"add-guide",children:[i.jsx("p",{className:"t-body",children:v.length?`Added ${f} ${t.entry.version}. Approve each command it proposes; none runs until you do.`:`Added ${f} ${t.entry.version}. Agents get its instructions on tickets that ask for ${f}.`}),v.map(j=>{var N,S,I;return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[j,": ",qd(((S=(N=t.guide)==null?void 0:N.proposedChecks[j])==null?void 0:S.run)??[])]}),i.jsx(Lv,{name:j,spec:((I=t.guide)==null?void 0:I.proposedChecks[j])??{run:[]},onApprove:($,_)=>void k($,_)})]},j)}),d&&i.jsx("span",{className:"vf-err",children:d})]})}function pT(e){const t=i.jsx("p",{className:"t-meta",children:"The lint looks for common problems; it isn't a review. Read the guide before you approve it."});return e.findings.length?i.jsxs(i.Fragment,{children:[i.jsx("ul",{className:"vf-findings guide-findings",children:e.findings.map((s,o)=>i.jsxs("li",{className:`sev-${s.level}`,children:[i.jsxs("code",{className:"t-code",children:["line ",s.line]})," ",s.message," ",i.jsxs("span",{className:"t-meta",children:["(",s.rule,")"]})]},o))}),t]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"t-meta",children:"The lint found none of the problems it looks for."}),t]})}function Ov(e){var o,a;const{p:t}=e,s=Object.entries(((o=t.guide)==null?void 0:o.proposedChecks)??{});return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"t-label",children:"Lint"}),i.jsx(pT,{findings:t.findings}),t.guide&&t.guide.checklist.length>0&&i.jsx("span",{className:"t-label",children:"Checklist"}),t.guide&&i.jsx("ul",{className:"catalog-checklist t-body",children:t.guide.checklist.map(l=>i.jsx("li",{children:l},l))}),s.length>0&&i.jsx("span",{className:"t-label",children:"Commands it proposes"}),s.map(([l,d])=>i.jsxs("code",{className:"t-code guide-check",children:[l,": ",qd(d.run),d.cwd&&` (in ${d.cwd})`]},l)),i.jsx("span",{className:"t-label",children:"Instructions"}),i.jsx("pre",{className:"guide-preview",children:((a=t.guide)==null?void 0:a.instructions)??t.text})]})}function gT(e){const t=Nn(e.repo);if(!t)return null;const s=encodeURIComponent(`Report: ${e.id} ${e.version}`),o=`${t.replace(/\/+$/,"")}/issues/new?template=report-guide.yml&title=${s}`;return i.jsx("a",{className:"report-link t-meta",href:o,target:"_blank",rel:"noreferrer",children:"Report this guide"})}function vT(e){const t=e.entry,[s,o]=y.useState(),[a,l]=y.useState();return y.useEffect(()=>{e.preview(t.id).then(o,d=>l(d.message))},[t.id]),i.jsxs("div",{className:"catalog-entry",children:[i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onBack,children:"← All guides"}),i.jsx("h3",{className:"t-title",children:t.name??t.id}),i.jsx(V,{parts:[{text:t.id,code:!0},t.version,`by ${t.author}`,Rv(t,e.catalogUrl),t.reviewedBy.length>0&&`reviewed by ${t.reviewedBy.join(", ")}`]}),i.jsx("p",{className:"t-body",children:t.summary}),t.history.length>0&&i.jsx("ul",{className:"catalog-history",children:t.history.map(d=>i.jsxs("li",{className:"t-meta",children:[d.version," · ",i.jsx("code",{className:"t-code",children:d.commit.slice(0,8)})," · ",d.at.slice(0,10)]},`${d.version}-${d.commit}`))}),a&&i.jsx("span",{className:"vf-err",children:a}),s&&i.jsx(Ov,{p:s}),s&&i.jsx(gT,{repo:s.repo,id:t.id,version:t.version}),s&&i.jsx(mT,{preview:s,installed:e.installed,add:e.add})]})}function kT(e){const t=e.entry;return i.jsx("li",{className:"catalog-row","data-guide-id":t.id,children:i.jsx(be,{title:t.name??t.id,context:i.jsx(V,{parts:[{text:t.id,code:!0},t.version,t.author,Rv(t,e.catalogUrl),t.reported&&"Reported"]}),detail:t.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}const rp=e=>e?`registry=${encodeURIComponent(e)}`:"";function yT(e){const[t,s]=y.useState(),[o,a]=y.useState();y.useEffect(()=>{let h=!0;return s(void 0),a(void 0),qo(`/guides/catalog?${rp(e)}`).then(f=>h&&s(f),f=>h&&a(f.message)),()=>{h=!1}},[e]);const l=y.useCallback(h=>qo(`/guides/catalog/preview?${rp(e)}&id=${encodeURIComponent(h)}`),[e]),d=y.useCallback(async(h,f)=>{const p=await Tv("/guides/catalog/add",{registry:e,id:h,sha256:f});return Av(p),p.installed},[e]);return{index:t,error:o,preview:l,add:d}}function wT(e){var S,I;const[t,s]=y.useState(((S=e.registries[0])==null?void 0:S.name)??""),o=yT(t||void 0),{find:a}=$n(),[l,d]=y.useState(""),[h,f]=y.useState(!0),[p,v]=y.useState(),k=o.index?wS({guides:o.index.guides},{query:l,verifiedOnly:h}):[],w=(I=o.index)==null?void 0:I.guides.find($=>$.id===p),j=$=>{var _,O,D;return((_=a($))==null?void 0:_.origin)==="local"?(D=(O=a($))==null?void 0:O.guide)==null?void 0:D.version:void 0},N=e.registries.find($=>$.name===t);return Mv.createPortal(i.jsx("div",{className:"scrim catalog-scrim",onClick:$=>{$.stopPropagation(),e.onClose()},children:i.jsxs(Be,{as:"div",className:"dialog catalog-dialog",onClick:$=>$.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h3",{className:"t-title",children:"Guide catalog"}),e.registries.length>1&&i.jsx(at,{compact:!0,"aria-label":"Catalog",value:t,options:e.registries.map($=>({value:$.name,label:`${$.name} · ${Qo($.url)}`,hint:$.url})),onChange:s}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]}),N&&e.registries.length===1&&i.jsx(V,{parts:[`Catalog ${N.name}`,{text:Qo(N.url),code:!0}]}),w?i.jsx(vT,{entry:w,catalogUrl:(N==null?void 0:N.url)??"",installed:j(w.id),preview:o.preview,add:o.add,onBack:()=>v(void 0)}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"catalog-filters",children:[i.jsx("input",{className:"catalog-search",placeholder:"Search guides","aria-label":"Search guides",value:l,onChange:$=>d($.target.value)}),i.jsx(M,{size:"sm",on:h,"aria-pressed":h,onClick:()=>f($=>!$),children:"Verified only"})]}),o.error&&i.jsx("span",{className:"vf-err",children:o.error}),!o.index&&!o.error&&i.jsx(Ie,{children:"Reading the catalog…"}),o.index&&!k.length&&i.jsx(Ie,{children:"No guides match."}),i.jsx("ul",{className:"catalog-list",children:k.map($=>i.jsx(kT,{entry:$,catalogUrl:(N==null?void 0:N.url)??"",installed:j($.id),onOpen:()=>v($.id)},$.id))})]})]})}),document.body)}function xT(e){const t=e.r.guide;if(!t)return null;const s=Object.entries(t.proposedChecks);if(!t.requiresChecks.length&&!s.length)return null;const o=e.r.status==="active";return i.jsxs("div",{className:"guide-checks",children:[t.requiresChecks.length>0&&i.jsxs("span",{className:"t-meta",children:["Adds checks ",i.jsx("code",{className:"t-code",children:t.requiresChecks.join(", ")})," to its tickets"]}),s.map(([a,l])=>{const d=e.r.pendingChecks.includes(a);return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[a,": ",qd(l.run)]}),d&&o&&i.jsx(Lv,{name:a,spec:l,busy:e.busy,onApprove:e.onApprove}),d&&!o&&i.jsx("span",{className:"t-meta",children:"approve the guide first"}),!d&&i.jsx("span",{className:"t-meta",children:"approved"})]},a)})]})}function jT(e){const{r:t}=e;if(!t.guide||!t.sha256)return null;const s=t.sha256;return i.jsxs("div",{className:"guide-review",children:[i.jsx(Ov,{p:{findings:t.findings,guide:t.guide}}),i.jsx(M,{size:"sm","aria-label":`Approve guide ${t.id}`,disabled:e.busy,onClick:()=>e.onApprove(s),children:"Approve"})]})}const ST="A file in guides/ replaces this built-in once you approve it; until then the built-in is used";function NT(e){var t,s;return e.override?ST:e.status==="unapproved"?(t=e.guide)==null?void 0:t.summary:e.reason??((s=e.guide)==null?void 0:s.summary)}function Pv(e){const{r:t}=e,s=t.id,o=t.override??t,a=(o.status==="unapproved"||o.status==="tampered")&&!!o.guide,l=t.status!=="active"||t.pendingChecks.length>0||a,d=t.guide?`${t.guide.name} ${t.guide.version}`:s;return i.jsx("li",{className:"guide-row","data-guide-id":s,children:i.jsx(be,{edge:l?"attention":"neutral",title:d,context:i.jsx(V,{parts:[{text:s,code:!0},uT(t),fT(t),dT(t),t.guide&&bT(t.guide.checklist.length)]}),detail:NT(t),actions:t.origin==="local"&&i.jsxs(M,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onAct("/guides/remove",{id:s}),children:["Remove guide ",s]}),below:i.jsxs(i.Fragment,{children:[a&&i.jsx(jT,{r:o,busy:e.busy,onApprove:h=>e.onAct("/guides/approve",{id:s,sha256:h})}),i.jsx(xT,{r:t,busy:e.busy,onApprove:(h,f)=>e.onAct("/guides/checks/approve",{id:s,name:h,acknowledged:f})})]})})})}const bT=e=>e===1?"1 checklist item":`${e} checklist items`;function $T(e){return i.jsxs(Ee,{title:"Write your own",children:[i.jsxs("p",{className:"vf-intro",children:["Write a guide for your team in your repo with ",i.jsxs("code",{className:"t-code",children:[Z.slug," guides new <id>"]}),". It starts from a template in ",i.jsxs("code",{className:"t-code",children:[Z.dataDir,"/guides/"]})," that passes the lint. Fill in the instructions and checklist, then approve it here: agents can only use it once you have, and again after every edit."]}),e.guides.length>0?i.jsx("ul",{className:"guides-list own-guides",children:e.guides.map(t=>i.jsx(Pv,{r:t,busy:e.busy,onAct:e.onAct},t.id))}):i.jsx(Ie,{children:"No guides of your own yet."}),e.error&&i.jsx("span",{className:"vf-err",children:e.error}),i.jsxs("p",{className:"t-meta guides-share",children:["Useful beyond your team? Check it with ",i.jsxs("code",{className:"t-code",children:[Z.slug," guides lint"]})," and"," ",i.jsx("a",{href:O0,target:"_blank",rel:"noreferrer",children:"share it in the public catalog"}),"."]})]})}function CT(e){const{view:t,act:s}=$n(),[o,a]=y.useState(),[l,d]=y.useState(!1),[h,f]=y.useState(!1),p=y.useRef(null);if(y.useEffect(()=>{var w;e.focus&&t&&((w=p.current)==null||w.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const v=w=>(j,N)=>{d(!0),s(j,N).then(S=>{a(S?{own:w,message:S}:void 0),d(!1)})},k=w=>o&&o.own===w?o.message:void 0;return i.jsxs("div",{className:"guides-section",ref:p,children:[i.jsxs(Ee,{title:"Guides",children:[i.jsx("p",{className:"vf-intro",children:"Guides give an agent instructions and a checklist for the tickets that ask for them. A guide can add checks, never remove them, and its commands only run once you approve them."}),i.jsx("ul",{className:"guides-list",children:t.guides.filter(w=>!fd(w)).map(w=>i.jsx(Pv,{r:w,busy:l,onAct:v(!1)},w.id))}),i.jsxs("div",{className:"guides-foot",children:[i.jsx(M,{size:"sm",onClick:()=>f(!0),children:"Browse guides"}),i.jsx(V,{parts:[{text:`${Z.dataDir}/guides/`,code:!0},{text:"guides.lock.json",code:!0}]})]}),t.configErrors.length>0&&i.jsx("ul",{className:"vf-errors",children:t.configErrors.map(w=>i.jsx("li",{children:w},w))}),k(!1)&&i.jsx("span",{className:"vf-err",children:k(!1)})]}),i.jsx($T,{guides:t.guides.filter(fd),busy:l,onAct:v(!0),error:k(!0)}),h&&i.jsx(wT,{registries:t.registries,onClose:()=>f(!1)})]})}function TT(e){const{view:t,act:s}=$n(),[o,a]=y.useState();if(!t)return null;const l=e.map.guides??[],d=t.guides.filter(f=>f.status==="active"&&f.guide),h=f=>{const p=l.includes(f)?l.filter(v=>v!==f):[...l,f];a(void 0),s("/guides/team",{mapId:e.map.id,guides:p}).then(a)};return i.jsxs(Ee,{title:`Team of ${e.map.key}`,children:[i.jsx("p",{className:"vf-intro",children:"The guides this trail works with. With Reviewer on the team, review tickets come with the reviewer's instructions and checklist."}),i.jsx("div",{className:"team-guides",children:d.map(f=>{const p=l.includes(f.id);return i.jsx(M,{size:"sm",on:p,"aria-pressed":p,title:f.guide.summary,onClick:()=>h(f.id),children:f.guide.name},f.id)})}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function ET(e,t){const[s,o]=y.useState(),a=`/guides/checklist?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`;return Ye({view:a,load:()=>qo(a),show:l=>o(l.checklist),failed:()=>o(null),changed:l=>l.endsWith("checklist.json")}),s}function AT(e){const t=ET(e.mapId,e.ticketId);if(!t)return null;const s=t.answers.filter(o=>!o.done).length;return i.jsxs("div",{className:"checklist-panel",children:[i.jsx(V,{parts:[`${t.guide.id} ${t.guide.version} checklist`,t.by,hr(t.at),s?`${s} not done`:"all done"]}),i.jsx(bv,{answers:t.answers})]})}const op="";function IT(e){const{view:t,act:s}=$n(),[o,a]=y.useState();if(!t)return null;const l=e.ticket,d=t.guides.filter(p=>{var v;return p.status==="active"&&((v=p.guide)==null?void 0:v.handles.types.includes(l.type))}),h=[{value:op,label:"No guide"},...d.map(p=>({value:p.id,label:p.guide.name,hint:p.guide.summary}))];l.guide&&!d.some(p=>p.id===l.guide)&&h.push({value:l.guide,label:l.guide});const f=p=>{a(void 0),s("/guides/ticket",{mapId:e.mapId,ticketId:l.id,guide:p||null}).then(a)};return i.jsxs("span",{className:"guide-picker",children:[i.jsx(at,{compact:!0,"aria-label":"Ticket guide",value:l.guide??op,options:h,onChange:f}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function RT(e){const{view:t,find:s}=$n();if(!t)return null;const o=s(e.id);if((o==null?void 0:o.status)==="active")return null;const a=o?o.reason??o.status:"it is not installed";return i.jsxs("p",{className:"guide-warning t-meta",children:["Guide ",e.id," can't be used: ",a,". Claims get no guide instructions until you approve it in Settings → Guides."]})}function MT(e){const{view:t}=$n(),s=e.ticket;return!t||s.state!=="open"&&!s.guide?null:i.jsxs("section",{className:"ticket-guide d-section",children:[i.jsxs("span",{className:"guide-head",children:[i.jsx("span",{className:"t-label",children:"Guide"}),s.state==="open"?i.jsx(IT,{mapId:e.mapId,ticket:s}):s.guide&&i.jsx(aT,{id:s.guide})]}),s.guide&&i.jsx(RT,{id:s.guide}),i.jsx(AT,{mapId:e.mapId,ticketId:s.id})]})}function LT(e){var f;const{view:t,find:s}=$n();if(!e)return;const o=s(e),a=t!=null&&(o==null?void 0:o.status)!=="active",l=((f=o==null?void 0:o.guide)==null?void 0:f.name)??e,d=o!=null&&o.guide?`${l} ${o.guide.version}`:l,h=a?`Guide ${d}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${d}`;return{id:e,name:l,tip:h,off:a}}const _v=()=>`${pe()}/proof/settings`;async function OT(){const e=await fetch(_v());return e.ok?await e.json():null}function PT(){const[e,t]=y.useState(),{pushed:s}=Ye({load:OT,show:a=>t((a==null?void 0:a.enabled)??null),failed:()=>t(null),events:{proof:()=>!0}}),o=y.useCallback(async a=>{const l=await fetch(_v(),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:a})}),d=await l.json();if(!l.ok)return d.error??`Saving failed (${l.status})`;s(),t(d.enabled===!0)},[s]);return{enabled:e,set:o}}function _T(){const{enabled:e,set:t}=PT(),[s,o]=y.useState();if(e==null)return null;const a=()=>{o(void 0),t(!e).then(o,l=>o(l.message))};return i.jsxs(Ee,{title:"Proof on pull requests",children:[i.jsxs("p",{className:"vf-intro",children:["When a ticket is done and its pull request is open, post its Verified by Teamtrail report as one comment on the PR, with a ",i.jsx("b",{children:"Teamtrail proof"})," check next to CI. The comment is updated, never repeated, when the proof or the PR changes."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Post proofs from this machine"}),i.jsx(M,{size:"sm",on:e,"aria-pressed":e,className:"proof-post-toggle",onClick:a,children:e?"On":"Off"})]}),i.jsxs("span",{className:"set-hint t-meta",children:["Posted with your GitHub token, to the repo Teamtrail syncs pull requests with (",i.jsx("code",{children:"github"})," in verification.json). Only this machine posts: a teammate switches it on in their own Lookout. The check passes only when the ticket is verified at the PR's latest commit."]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}function DT(e){var l;const[t,s]=y.useState({kind:"idle"}),o=(l=ft())==null?void 0:l.merge;if(!o||!e.verified)return null;const a=async()=>{s({kind:"working"});try{const d=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trail:e.mapId,ticket:e.ticketId})}),h=await d.json().catch(()=>({}));if(d.ok&&h.merged)return s({kind:"merged",url:h.url?Nn(h.url):void 0});s({kind:"error",text:String(h.error??`The server answered ${d.status}.`).slice(0,300)})}catch{s({kind:"error",text:"The server didn't answer. Try again."})}};return t.kind==="merged"?i.jsxs("span",{className:"t-meta merge-note",children:["Approved and merged at the verified commit."," ",t.url&&i.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",children:"See the pull request"})]}):t.kind==="confirm"?i.jsxs("div",{className:"merge-confirm",children:[i.jsx("span",{className:"t-meta",children:"Merge its pull request, at exactly the commit Teamtrail verified?"}),i.jsx(M,{size:"sm",onClick:()=>void a(),children:"Merge"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>s({kind:"idle"}),children:"Cancel"})]}):i.jsxs("div",{className:"merge-confirm",children:[i.jsx(M,{size:"sm",disabled:t.kind==="working",onClick:()=>s({kind:"confirm"}),children:t.kind==="working"?"Merging…":"Approve and merge"}),t.kind==="error"&&i.jsx("span",{className:"t-meta",children:t.text})]})}function zT(e,t){const[s,o]=y.useState();return Ye({load:async()=>{const a=new URLSearchParams({mapId:e,ticketId:t}),l=await fetch(`${pe()}/proof/ticket?${a}`);return l.ok?await l.json():null},show:o,failed:()=>o(null),view:`${e}/${t}`,changed:a=>a.includes(`tickets/${t}.md`),events:{verification:()=>!0,proof:()=>!0}}),s}function BT(e){const t=zT(e.mapId,e.ticket.id),[s,o]=y.useState(!1);if(!t)return null;const{proof:a,post:l}=t,d=e.ticket.state==="closed"&&e.ticket.closeReason==="completed";if(!d&&!a.attempt.id)return null;const h=a.status==="verified",f=()=>void navigator.clipboard.writeText(t.markdown).then(()=>{o(!0),setTimeout(()=>o(!1),1500)}),p=l!=null&&l.commentUrl?Nn(l.commentUrl):void 0;return i.jsxs("section",{className:"d-section ticket-proof",children:[i.jsx("span",{className:"t-label",children:"Proof"}),i.jsxs("div",{className:"proof-head",children:[i.jsx(bn,{tone:h?"fill":"amber",children:h?"Verified by Teamtrail":"Not verified"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:f,children:s?"Copied":"Copy for PR"})]}),a.gaps.length>0&&i.jsx("ul",{className:"proof-gaps t-meta",children:a.gaps.map(v=>i.jsx("li",{children:v},v))}),i.jsx(V,{className:"t-meta",parts:[a.checks.length>0&&`${a.checks.filter(v=>v.passed).length}/${a.checks.length} checks passed`,a.criteria.lines.length>0&&`${a.criteria.verified} criteria verified, ${a.criteria.claimed} claimed`,a.reviews.length>0&&`${a.reviews.length} review${a.reviews.length>1?"s":""}`,{text:a.digest.slice(0,19),code:!0}]}),d&&i.jsx(DT,{mapId:e.mapId,ticketId:e.ticket.id,verified:h}),p&&i.jsxs("a",{className:"t-meta",href:p,target:"_blank",rel:"noreferrer",children:["Posted on pull request #",l.pr]}),(l==null?void 0:l.error)&&i.jsxs("span",{className:"t-meta",children:["Posting failed, trying again: ",l.error]}),t.keyFile&&i.jsxs("span",{className:"t-meta",children:["Signed with this machine's key. Commit ",i.jsx("code",{children:`${Z.dataDir}/${t.keyFile}`})," so others can check it."]})]})}const Dv="0.52.1",md="<endpoint>",Qd=zp(Dv,["mcp","--http"]);function FT(e,t){const s=zp(Dv,["connect",e,"--url"]),o=t===md?t:Dp(t);return`read -rs ${Z.tokenEnv} && export ${Z.tokenEnv}
|
|
152
|
+
${s} ${o}`}function UT(e){return e.kind==="lookout"?["the Lookout","this machine only"]:["for remote agents",e.network?"open to your network":"this machine only, until a tunnel or proxy shares it"]}function WT({endpoints:e}){const t=e.some(s=>s.kind==="standalone");return i.jsxs("ul",{className:"ra-endpoints",children:[e.map(s=>i.jsx("li",{children:i.jsx(V,{className:"set-hint",parts:[{text:s.url,code:!0},...UT(s)]})},s.url)),!t&&i.jsx("li",{children:i.jsx(V,{className:"set-hint",parts:["For agents on other machines, start their server",{text:Qd,code:!0}]})})]})}function HT(e){const[t,s]=y.useState(""),[o,a]=y.useState(!1),[l,d]=y.useState(),h=async f=>{if(!f.trim()||o)return;a(!0);const p=await e.onCreate(f).catch(v=>v.message);a(!1),d(p),p||s("")};return i.jsxs("div",{className:"ra-new",children:[i.jsx(wa,{value:t,onValueChange:s,onSubmit:h,action:"Create token",actionDisabled:o||!t.trim(),placeholder:"Name the agent, e.g. cloud sandbox 1","aria-label":"Agent name",maxLength:60}),l&&i.jsx("span",{className:"vf-err",children:l})]})}function KT(){return i.jsx(Ee,{title:"Remote agents",children:i.jsxs("p",{className:"vf-intro",children:["Tokens for remote agents are created and revoked on the machine ",Z.name," runs on. Open the Lookout there to manage them."]})})}function VT(e){const[t,s]=y.useState(!1),[o,a]=y.useState(!1),[l,d]=y.useState(),h=async()=>{a(!0),d(await e.onRevoke().catch(f=>f.message)),a(!1),s(!1)};return t?i.jsxs("span",{className:"ra-revoke ask",children:[i.jsx("span",{className:"t-meta",children:"Its sessions end now."}),i.jsxs(M,{size:"sm",disabled:o,onClick:h,children:["Revoke ",e.name]}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]}):i.jsxs("span",{className:"ra-revoke",children:[i.jsx(M,{size:"sm","aria-label":`Revoke ${e.name}`,onClick:()=>s(!0),children:"Revoke"}),l&&i.jsx("span",{className:"vf-err",children:l})]})}function GT(e){if(!e.tokens.length)return null;const t=Date.now();return i.jsx("ul",{className:"ra-list",children:e.tokens.map(s=>i.jsx(be,{as:"li",className:"ra-row",title:s.name,titleText:s.name,context:i.jsx(V,{parts:[`Created ${Go(s.createdAt,t)}`,s.lastUsedAt?`Last used ${Go(s.lastUsedAt,t)}`:"Never used"]}),below:i.jsx(VT,{name:s.name,onRevoke:()=>e.onRevoke(s.id)})},s.id))})}function Uc(e){const[t,s]=y.useState(!1),o=()=>{var a;return void((a=navigator.clipboard)==null?void 0:a.writeText(e.value).then(()=>{s(!0),setTimeout(()=>s(!1),1500)},()=>s(!1)))};return i.jsxs("div",{className:"ra-copy",children:[i.jsx("code",{className:"ra-copy-value t-code","aria-label":e.label,children:e.value}),i.jsx(M,{size:"sm",className:"ra-copy-btn",onClick:o,children:t?"Copied":e.copyLabel??"Copy"})]})}const qT=[{id:"claude",label:"Claude Code"},{id:"codex",label:"Codex"}];function QT(e){const[t,s]=y.useState("claude");return i.jsxs("div",{className:"ra-reveal",role:"status",children:[i.jsxs("p",{className:"ra-reveal-title t-row-title",children:["Token for ",e.created.name]}),i.jsxs("p",{className:"t-body ra-note",children:["Copy it now. ",Z.name," keeps only a fingerprint, so it can't show it again."]}),i.jsx(Uc,{label:"Token",value:e.created.token,copyLabel:"Copy token"}),!e.endpoint&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"ra-reveal-head",children:i.jsx(ze,{children:"Start the server for remote agents"})}),i.jsx(Uc,{label:"Start command",value:Qd,copyLabel:"Copy command"})]}),i.jsxs("div",{className:"ra-reveal-head",children:[i.jsx(ze,{children:"Run on the agent's machine"}),i.jsx("span",{className:"ra-clients",children:qT.map(o=>i.jsx(M,{size:"sm",on:t===o.id,"aria-pressed":t===o.id,onClick:()=>s(o.id),children:o.label},o.id))})]}),i.jsx(Uc,{label:"Connect command",value:FT(t,e.endpoint??md),copyLabel:"Copy command"}),i.jsxs("p",{className:"t-meta ra-note",children:["The first line waits for the token: paste it and press Enter. It isn't shown, and it stays out of your shell history."," ",e.endpoint?"From another machine, use the address that machine reaches this one by.":`Put the address the server prints in place of ${md}.`,t==="codex"&&` Start Codex from the same shell: it reads $${Z.tokenEnv} each time.`]}),i.jsx("span",{children:i.jsx(M,{variant:"primary",size:"sm",onClick:e.onDone,children:"I've copied it"})})]})}const zv=`${pe()}/remote-agents`;async function ap(e,t){const s=await fetch(`${zv}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:s.ok,reply:await s.json()}}async function YT(){const e=await fetch(zv);return e.ok?await e.json():(await e.json().catch(()=>({}))).elsewhere?"elsewhere":null}function JT(){const[e,t]=y.useState(),[s,o]=y.useState(),{pushed:a}=Ye({load:YT,show:t,failed:()=>t(null),events:{"remote-agents":()=>!0}}),l=y.useCallback(f=>{a(),t({tokens:f.tokens,endpoints:f.endpoints})},[a]),d=y.useCallback(async f=>{const{ok:p,reply:v}=await ap("/tokens",{name:f});if(!p||!v.token||!v.created)return v.error??"The token could not be created.";l(v),o({token:v.token,name:v.created.name})},[l]),h=y.useCallback(async f=>{const{ok:p,reply:v}=await ap("/tokens/revoke",{id:f});return v.tokens&&l(v),p?void 0:v.error??"The token could not be revoked."},[l]);return{view:e,created:s,dismissCreated:()=>o(void 0),create:d,revoke:h}}function XT(){var d;const{view:e,created:t,dismissCreated:s,create:o,revoke:a}=JT();if(!e)return null;if(e==="elsewhere")return i.jsx(KT,{});const l=(d=e.endpoints.find(h=>h.kind==="standalone"))==null?void 0:d.url;return i.jsxs(Ee,{title:"Remote agents",children:[i.jsx("p",{className:"vf-intro",children:"Agents on another machine or in a cloud sandbox can work this repo's trails too. They connect over HTTP with a token and share the tickets, claims and inbox of the agents here. One token per agent; revoke it and that agent is out within about a second."}),i.jsx(WT,{endpoints:e.endpoints}),t&&i.jsx(QT,{created:t,endpoint:l,onDone:s}),i.jsx(GT,{tokens:e.tokens,onRevoke:a}),e.tokens.length===0&&i.jsx("p",{className:"t-meta ra-note",children:"No tokens, so the endpoint is closed: every request is refused."}),i.jsx(HT,{onCreate:o}),i.jsxs("div",{className:"ra-notes",children:[i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"Before you open it to other machines."})," The connection is plain HTTP. Run ",i.jsx("code",{children:Qd}),", which serves the agent tools and nothing else, and put that port behind HTTPS with a reverse proxy or a tunnel. The Lookout's own port is not for sharing: its agent endpoint answers this machine only. A token only ever opens the agent tools, never the Lookout, which signs in browsers, not agents."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What a remote agent can't do."})," Speak for you: it can't answer a question, skip discovery, change the trail's mode or destination, or close a ticket that needs you before you've answered here or in Slack. And its files aren't on this machine, so it gets no worktree, and on trails with verification its finished work comes to you to review instead of running the checks here."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"How far to trust one."})," The risk policy only sees what an agent declares: a call is held for you when the agent names a high-risk category or touches files your path rules cover. An agent that declares nothing isn't caught. Give an agent you don't fully trust only trails with verification on, where its finished work comes to you."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it does as you."})," With GitHub Issues or Linear as the tracker, everything a remote agent writes (tickets, comments, closing) goes to the tracker with your credentials, like the agents here."]})]})]})}const lp={schema:"Database schema","breaking-api":"Breaking API changes","auth-permissions":"Auth and permissions",billing:"Billing","data-deletion":"Deleting data","product-behaviour":"Product behaviour",dependencies:"Dependencies"},ZT={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},e2=e=>e[0].toUpperCase()+e.slice(1),pd=cg.map(e=>({value:e,label:e2(e),hint:ZT[e]}));function t2(e){const[t,s]=y.useState(""),[o,a]=y.useState("high"),{rules:l,onChange:d}=e,h=()=>{const f=t.trim();!f||l.some(p=>p.glob===f)||(d([...l,{glob:f,level:o}]),s(""))};return i.jsxs("div",{className:"risk-paths",children:[i.jsx("span",{className:"mono-label",children:"Files"}),l.map((f,p)=>i.jsxs("div",{className:"risk-row",children:[i.jsx("code",{children:f.glob}),i.jsx(at,{compact:!0,"aria-label":`${f.glob} risk`,value:f.level,options:pd,onChange:v=>d(l.map((k,w)=>w===p?{...k,level:v}:k))}),i.jsx("button",{className:"icon-btn","aria-label":`Remove ${f.glob}`,onClick:()=>d(l.filter((v,k)=>k!==p)),children:"×"})]},f.glob)),i.jsxs("div",{className:"risk-row",children:[i.jsx("input",{value:t,placeholder:"src/payments/**","aria-label":"New file pattern",onChange:f=>s(f.target.value),onKeyDown:f=>f.key==="Enter"&&h()}),i.jsx(at,{compact:!0,"aria-label":"New pattern risk",value:o,options:pd,onChange:a}),i.jsx(M,{onClick:h,disabled:!t.trim(),children:"Add"})]})]})}const Bv=`${pe()}/policy`;async function n2(){const e=await fetch(Bv);return e.ok?await e.json():null}function s2(){const[e,t]=y.useState(),{pushed:s}=Ye({load:n2,show:t,failed:()=>t(null),changed:a=>a.endsWith("policy.json")}),o=y.useCallback(async a=>{const l=await fetch(Bv,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),d=await l.json();if(!l.ok)return d.error??`Saving failed (${l.status})`;s(),t(d)},[s]);return{view:e,save:o}}function i2(){const{view:e,save:t}=s2(),[s,o]=y.useState();if(!e)return null;const a=`${Z.dataDir}/policy.json`,l=d=>{o(void 0),t(d).then(o,h=>o(h.message))};return i.jsxs(Ee,{title:"Risk policy",children:[i.jsx("p",{className:"vf-intro",children:"What agents may decide on their own. High: they must ask you. Medium: they decide, follow your conventions and record it for you to review. Low: they just decide."}),i.jsx("div",{className:"risk-grid",children:lg.map(d=>i.jsxs("label",{className:"risk-row",children:[i.jsx("span",{children:lp[d]}),i.jsx(at,{compact:!0,"aria-label":`${lp[d]} risk`,value:e.policy.categories[d],options:pd,onChange:h=>l({...e.policy,categories:{...e.policy.categories,[d]:h}})})]},d))}),i.jsx(t2,{rules:e.policy.paths,onChange:d=>l({...e.policy,paths:d})}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[a," has errors, so the defaults apply until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(d=>i.jsx("li",{children:d},d))})]}),e.defaults&&e.errors.length===0&&i.jsxs("span",{className:"set-hint t-meta",children:["Defaults. Changing anything saves ",a,", so your team shares it."]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}const gd=`${pe()}/workspaces`;async function r2(){const e=await fetch(gd);return e.ok?await e.json():null}function Fv(){const[e,t]=y.useState(),{pushed:s}=Ye({load:r2,show:t,failed:()=>t(null),changed:d=>d.endsWith("workspaces.json")||d.includes("workspaces/")||d.includes("leases/")}),o=y.useCallback(d=>{s(),t(d)},[s]),a=y.useCallback(async d=>{const h=await fetch(gd,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)}),f=await h.json();if(!h.ok)return f.error??`Saving failed (${h.status})`;o(f)},[o]),l=y.useCallback(async(d,h,f=!1)=>{const p=await fetch(`${gd}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:d,ticketId:h,force:f})}),v=await p.json();return p.ok?(o(v),{}):{error:v.error??`Removing failed (${p.status})`,dirty:v.dirty??!1}},[o]);return{view:e,save:a,remove:l}}function Uv(e){const[t,s]=y.useState(!1),[o,a]=y.useState(),[l,d]=y.useState(!1),h=async f=>{d(!0),a(void 0);const p=await e.onRemove(f).catch(v=>({error:v.message,dirty:!1}));d(!1),s(!!p.dirty&&!f),p.dirty||a(p.error)};return t?i.jsxs("span",{className:"ws-remove ask",children:[i.jsx("span",{className:"vf-err",children:"Uncommitted changes in this workspace will be lost."}),i.jsx(M,{size:"sm",disabled:l,onClick:()=>h(!0),children:"Remove anyway"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]}):i.jsxs("span",{className:"ws-remove",children:[i.jsx(M,{size:"sm",disabled:l,onClick:()=>h(!1),children:e.label??"Remove"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function o2(e){return e.rows.length?i.jsx("ul",{className:"ws-list",children:e.rows.map(t=>i.jsx(be,{as:"li",className:`ws-row ${t.active?"active":"finished"}`,title:i.jsx("span",{className:"t-code",children:t.branch}),titleText:t.branch,context:i.jsx(V,{parts:[{text:t.ticketKey,code:!0},t.active?`Active · ${t.agent}`:"Finished"]}),detail:i.jsx("span",{className:"t-code",children:t.path}),detailText:t.path,below:t.active?void 0:i.jsx(Uv,{onRemove:s=>e.onRemove(t.mapId,t.ticketId,s)})},`${t.mapId}/${t.ticketId}`))}):null}function a2(e){const{view:t,remove:s}=Fv(),o=t==null?void 0:t.workspaces.find(a=>a.mapId===e.mapId&&a.ticketId===e.ticketId);return!o||o.active?null:i.jsxs("section",{className:"ticket-workspace d-section",children:[i.jsx("span",{className:"t-label",children:"Workspace"}),i.jsxs("p",{className:"t-meta",children:["Branch ",i.jsx("code",{className:"t-code",children:o.branch})," in"," ",i.jsx("code",{className:"t-code",title:o.path,children:o.path})]}),i.jsx(Uv,{label:"Remove workspace",onRemove:a=>s(e.mapId,e.ticketId,a)})]})}function l2(){const{view:e,save:t,remove:s}=Fv(),[o,a]=y.useState();if(!e)return null;const l=e.settings.worktrees,d=()=>{a(void 0),t({...e.settings,worktrees:!l}).then(a,h=>a(h.message))};return i.jsxs(Ee,{title:"Workspaces",children:[i.jsxs("p",{className:"vf-intro",children:["Give each agent its own copy of the repo for every ticket it claims, on its own branch, so agents working at the same time don't step on each other. You review and merge the branches; ",Z.name," never merges or pushes."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"A worktree per ticket"}),i.jsx(M,{size:"sm",on:l,"aria-pressed":l,className:"worktrees-toggle",onClick:d,children:l?"On":"Off"})]}),i.jsx(V,{className:"set-hint",parts:[{text:`${Z.dataDir}/workspaces.json`,code:!0},cp(e.workspaces.filter(h=>h.active).length,"active"),cp(e.workspaces.filter(h=>!h.active).length,"finished")]}),i.jsx(o2,{rows:e.workspaces,onRemove:s}),e.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:e.errors.map(h=>i.jsx("li",{children:h},h))}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const cp=(e,t)=>`${e} ${t}`;function c2({data:e,route:t}){var s;return i.jsxs(i.Fragment,{children:[i.jsx(Ke,{id:"approvals",storage:"machine",children:i.jsx(iT,{})}),i.jsx(Ke,{id:"tracker",children:i.jsx(Ee,{title:"Tracker",children:(s=ft())!=null&&s.tracker?i.jsx("p",{className:"vf-intro",children:"Trails are kept by the server this Lookout runs on, in its own storage."}):i.jsx(xC,{activeTracker:e.activeTracker,location:e.location,update:e.update})})}),i.jsx(Ke,{id:"workspaces",storage:"repo",children:i.jsx(l2,{})}),i.jsx(Ke,{id:"proof",storage:"machine",children:i.jsx(_T,{})}),i.jsx(Ke,{id:"remote-agents",storage:"machine",children:i.jsx(XT,{})}),i.jsx(Ke,{id:"policy",storage:"repo",children:i.jsx(i2,{})}),i.jsx(Ke,{id:"guides",storage:"repo",children:i.jsx(CT,{focus:t.section==="guides"})}),i.jsx(Ke,{id:"labels",children:i.jsx(Ee,{title:"Labels",children:i.jsxs("div",{className:"label-codes",children:[i.jsx("code",{children:xd}),i.jsxs("code",{children:[Z.labelPrefix,":<type>"]}),i.jsx("code",{children:jd}),i.jsx("code",{children:Sd})]})})})]})}const vd=`${Z.apiPrefix}/projects`;async function Xi(e,t,s){const o=await fetch(`${vd}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:s===void 0?void 0:JSON.stringify(s)}),a=await o.json().catch(()=>({}));if(!o.ok)throw new Error(a.error??`HTTP ${o.status}`);return a}const ms={url:vd,add:e=>Xi("","POST",{path:e}),remove:e=>Xi(`/${e}`,"DELETE"),setAutoRegister:e=>Xi("/settings","PUT",{autoRegister:e}),setShare:(e,t)=>Xi(`/${e}/share`,"PUT",{share:t}),answer:(e,t)=>Xi(`/${e}/answer`,"POST",t),async briefing(e){const t=await fetch(`${vd}/briefing?since=${e}`);return t.ok?await t.json():void 0}};function Wv(e){const[t,s]=y.useState(""),[o,a]=y.useState(),l=d=>{d.trim()&&(a(void 0),ms.add(d.trim()).then(()=>(s(""),e.onAdded()),h=>a(h.message)))};return i.jsxs("div",{className:"pj-add",children:[i.jsx(wa,{value:t,onValueChange:s,onSubmit:l,action:"Add project",placeholder:`/path/to/repo (a ${Z.dataDir} folder is created if missing)`,"aria-label":"Repo path",className:"t-code"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Ks=(e,t)=>e>0&&`${e} ${t}`;function d2(e){var s;const t=((s=e.briefing)==null?void 0:s.projects)??[];return!e.briefing||!t.length?null:i.jsxs("section",{className:"pj-section pj-briefing",children:[i.jsx(Et,{title:"While you were away",count:t.length,info:`What changed in each project since ${hn(e.now-e.briefing.since)} ago`}),i.jsx("ul",{className:"pj-list",children:t.map(({projectId:o,project:a,briefing:l})=>i.jsx(be,{as:"li",edge:l.totals.waiting>0?"attention":"neutral",title:a,context:i.jsx(V,{parts:[Ks(l.totals.done,"done"),Ks(l.trails.reduce((d,h)=>d+h.opened.length,0),"new tickets"),Ks(l.totals.agentDecisions,"agent decisions"),Ks(l.totals.waiting,"waiting on you"),Ks(l.totals.ruledOut,"ruled out"),Ks(l.totals.active,"agents active")]}),onOpen:()=>e.onOpen(o)},o))})]})}function u2(e){const[t,s]=y.useState(""),[o,a]=y.useState(!1),[l,d]=y.useState(),h=f=>{!f.trim()||o||(a(!0),d(void 0),e.onAnswer(f.trim()).then(()=>s(""),p=>d(p.message)).finally(()=>a(!1)))};return i.jsxs("div",{className:"pj-answer",children:[i.jsx(wa,{value:t,onValueChange:s,onSubmit:h,action:"Answer",disabled:o,placeholder:"Your answer","aria-label":"Your answer"}),l&&i.jsx("span",{className:"vf-err",children:l})]})}function h2(e){const{item:t}=e,s=cv(t),o=t.kind==="question"&&t.agent?`${t.agent} asks`:av[t.kind],a=t.urgency==="blocking"&&{text:"Blocking",urgent:!0,className:"urgency-tag"};return i.jsx(be,{as:"li",className:`att-item pj-item k-${t.kind}`,edge:lv(t,t.interrupting),title:t.title.split(`
|
|
153
153
|
`)[0],titleText:t.title,context:i.jsx(V,{parts:[a,{text:t.project,strong:!0},o]}),detail:s.length>0&&s.join(" · "),detailText:s.join(`
|
|
154
|
-
`),trailing:hn(e.now-t.since),onOpen:e.onOpen,below:e.onAnswer&&i.jsx(u2,{onAnswer:e.onAnswer})})}function f2(e){const t=e.view.attention,s=o=>{var a;return((a=e.view.projects.find(l=>l.id===o))==null?void 0:a.state.kind)!=="missing"};return i.jsxs("section",{className:"pj-section pj-attention",children:[i.jsx(Et,{title:"Needs you",count:t.length,hot:t.some(o=>o.interrupting),info:"One queue across projects, ranked the way each project ranks its own. Answer questions here; the agent in that repo gets the answer."}),t.length===0&&i.jsx(Sn,{title:"Nothing needs you",hint:"Agents in every project can keep going."}),i.jsx("ul",{className:"pj-list",children:t.map(o=>i.jsx(h2,{item:o,now:e.now,onOpen:()=>e.onOpen(o.projectId,o.id),onAnswer:o.kind==="question"&&s(o.projectId)?a=>ms.answer(o.projectId,{questionId:o.ref,text:a}).then(e.onAnswered):void 0},`${o.projectId}/${o.id}`))})]})}const Wc=(e,t,s=`${t}s`)=>`${e} ${e===1?t:s}`;function m2(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function p2(e){if(e.state.kind==="missing")return[{text:"Missing",strong:!0},{text:e.path,code:!0}];const t=[];e.needsYou&&t.push({text:`${e.needsYou} ${e.needsYou===1?"needs":"need"} you`,strong:!0,urgent:e.interrupting>0}),e.agents&&t.push(Wc(e.agents,"agent"));const{working:s,verifying:o,rework:a,blocked:l}=e.phases;s&&t.push(`${s} working`),o&&t.push(`${o} verifying`),a&&t.push(`${a} rework`),l&&t.push(`${l} blocked`),e.flags&&t.push(Wc(e.flags,"PR flag")),e.stalled&&t.push(Wc(e.stalled,"stalled claim")),t.length||t.push(e.trails?"Nothing waiting":"No trails yet");const d=g2(e.tracker);return d&&t.push(d),t}function g2(e){if(e.kind==="github"&&e.repo)return`Issues in ${e.repo}`;if(!(e.kind!=="linear"||!e.team))return e.org?`Linear: ${e.team} in ${e.org}`:`Linear: ${e.team}`}function v2(e){var t;return e.state.kind==="elsewhere"?e.state.url?`Served by another Lookout · ${e.state.url}`:"Served by another Teamtrail on this machine":((t=e.top)==null?void 0:t.title)??e.note??e.path}function Yo(e,t,s){if(e.state.kind!=="missing"){if(e.state.kind==="elsewhere"){const o=e.state.url?Nn(e.state.url):void 0;if(!o)return;const a=new URL(o);s&&a.searchParams.set(Ys,s),window.open(a.toString(),"_blank","noopener");return}location.href=h1({id:e.id,home:t,tracker:e.tracker.kind,item:s})}}function Hv(e){const{p:t}=e,s=v2(t);return i.jsx(be,{as:"li",className:`project-card st-${t.state.kind}`,edge:m2(t),selected:e.current,title:t.name,titleText:t.path,context:i.jsx(V,{parts:p2(t)}),detail:s,detailText:s,trailing:t.lastActivity?hn(e.now-t.lastActivity):void 0,onOpen:e.onOpen})}const Kv=`${ea}:projects:seen`,dp=24*36e5;function k2(e){try{const t=Number(localStorage.getItem(Kv));return t>0?t:e-dp}catch{return e-dp}}function y2(e){try{localStorage.setItem(Kv,String(e))}catch{}}function w2(){const[e,t]=y.useState();return y.useEffect(()=>{const s=Date.now();return ms.briefing(k2(s)).then(t).catch(()=>{}),()=>y2(s)},[]),e}function x2(e){const{view:t,reload:s}=e.projects,o=Xt(15e3),a=w2();if(y.useEffect(()=>{const f=p=>p.key==="Escape"&&e.onClose();return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[e]),!t)return null;const l=ur()??t.home,d=f=>{const p=t.projects.find(k=>k.id===f);(p==null?void 0:p.id)===l?e.onClose():p&&Yo(p,t.home)},h=(f,p)=>{const k=t.projects.find(v=>v.id===f);if(k){if(k.id!==l)return Yo(k,t.home,p);e.onClose(),e.onItemHere(p)}};return i.jsxs(Be,{className:`zone decisions-view projects-view dv-${e.bp}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(ze,{as:"h2",children:"All projects"}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"pj-body",children:[i.jsx(f2,{view:t,now:o,onOpen:h,onAnswered:s}),i.jsxs("section",{className:"pj-section pj-projects",children:[i.jsx(Et,{title:"Projects",count:t.projects.length,info:"Each repo registered on this machine, read from its own files. Nothing leaves your machine."}),i.jsx("ul",{className:"pj-list",children:t.projects.map(f=>i.jsx(Hv,{p:f,current:f.id===l,now:o,onOpen:f.state.kind==="missing"?void 0:()=>d(f.id)},f.id))}),i.jsx(Wv,{onAdded:s})]}),i.jsx(d2,{briefing:a,now:o,onOpen:d})]})]})}function j2(e){const[t,s]=y.useState(!1),o=y.useRef(null);y.useEffect(()=>{if(!t)return;const h=f=>{var p;(f instanceof KeyboardEvent?f.key==="Escape":!((p=o.current)!=null&&p.contains(f.target)))&&s(!1)};return window.addEventListener("mousedown",h),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",h)}},[t]);const{view:a}=e.projects;if(!a||!e.projects.many)return i.jsx("span",{className:"repo",children:e.repo});const l=ur()??a.home,d=a.projects.filter(h=>h.id!==l).reduce((h,f)=>h+f.interrupting,0);return i.jsxs("div",{className:"project-switcher",ref:o,children:[i.jsxs("button",{className:"project-btn repo",onClick:()=>s(h=>!h),"aria-haspopup":"menu","aria-expanded":t,"data-tip":"Switch project, or see all of them",children:[i.jsx("span",{className:"project-name",children:e.repo}),d>0&&i.jsx(fs,{n:d,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),t&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsxs("button",{role:"menuitem",className:"trail-item all-projects",onClick:()=>{s(!1),e.onOverview()},children:[i.jsx("span",{className:"mi-title",children:"All projects"}),i.jsx(fs,{n:a.attention.length,urgent:a.attention.some(h=>h.interrupting),hideZero:!0})]}),i.jsx(ze,{variant:"plain",className:"menu-h",children:"Projects"}),a.projects.map(h=>i.jsxs("button",{role:"menuitem",className:`trail-item ${h.id===l?"on":""} st-${h.state.kind}`,disabled:h.state.kind==="missing",onClick:()=>{s(!1),h.id!==l&&Yo(h,a.home)},children:[i.jsx("span",{className:"mi-title",children:h.name}),i.jsx("span",{className:"mi-progress",children:S2(h.state.kind)}),i.jsx(fs,{n:h.needsYou,urgent:h.interrupting>0,hideZero:!0})]},h.id))]})]})}function S2(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function N2(e){const t=Xt(15e3),{view:s}=e.projects;if(!s||!e.projects.many)return null;const o=ur()??s.home;return i.jsxs("section",{className:"phone-projects",children:[i.jsx(Et,{title:"Projects",count:s.projects.length,right:i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onOverview,children:"All projects"})}),i.jsx("ul",{className:"pj-list",children:s.projects.filter(a=>a.id!==o).map(a=>i.jsx(Hv,{p:a,current:!1,now:t,onOpen:a.state.kind==="missing"?void 0:()=>Yo(a,s.home)},a.id))})]})}async function b2(){const e=await fetch(ms.url);return e.ok?await e.json():void 0}function Vv(){const[e,t]=y.useState(),{reload:s,pushed:o}=Ye({load:b2,show:a=>a&&t(a)});return y.useEffect(()=>si("projects",a=>{o(),t(JSON.parse(a))}),[o]),{view:e,many:((e==null?void 0:e.projects.length)??0)>1,reload:s}}const $2=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function C2(){const{view:e,reload:t}=Vv(),[s,o]=y.useState();if(!e)return null;const a=l=>{o(void 0),l.then(t,d=>o(d.message))};return i.jsxs(Ee,{title:"Projects",children:[i.jsx("p",{className:"vf-intro",children:"Supervise several repos from this Lookout: All projects shows what needs you in each of them. The list lives in your config folder on this machine, never in a repo, and agents only ever work in their own repo. A project that shares its decisions offers them to agents in your other projects as suggestions, never as answers."}),i.jsx("ul",{className:"pj-list set-projects",children:e.projects.map(l=>i.jsx(be,{as:"li",edge:l.state.kind==="missing"?"attention":"neutral",title:l.name,context:i.jsx(V,{parts:$2(l)}),actions:i.jsxs(i.Fragment,{children:[i.jsx(M,{size:"sm",variant:"ghost",on:l.sharePrecedents,"aria-pressed":l.sharePrecedents,className:"share-precedents-toggle",title:"Offer this project's decisions as suggestions when agents look for precedents in your other projects",onClick:()=>a(ms.setShare(l.id,!l.sharePrecedents)),children:l.sharePrecedents?"Shares decisions":"Share decisions"}),!l.home&&i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>a(ms.remove(l.id)),children:"Remove"})]})},l.id))}),i.jsx(Wv,{onAdded:t}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Agents add their repo when they connect"}),i.jsx(M,{size:"sm",on:e.autoRegister,"aria-pressed":e.autoRegister,className:"auto-register-toggle",onClick:()=>a(ms.setAutoRegister(!e.autoRegister)),children:e.autoRegister?"On":"Off"})]}),i.jsx(V,{className:"set-hint",parts:[{text:`${Z.slug} projects add <path>`,code:!0},`--no-register or ${Z.noRegisterEnv} opts one agent out`]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}const T2=`${Z.apiPrefix}/models`;async function E2(){const e=await fetch(T2);return e.ok?await e.json():null}function Yd(){const[e,t]=y.useState();return Ye({load:E2,show:t,failed:()=>t(null),changed:s=>s.endsWith("models.json")||s.endsWith("map.md")||s.includes("/tickets/"),events:{attention:()=>!0}}),e}function A2({mapId:e,ticketId:t}){const s=Yd(),o=s==null?void 0:s.waiting.find(a=>a.mapId===e&&a.ticketId===t);return o?i.jsx(be,{className:"model-wait d-section",edge:"attention",title:`Needs a ${o.tier} model`,context:i.jsx(V,{parts:[`Connected agents run ${o.best} at most`]}),detail:`Connect an agent on a ${o.tier} model, or have one claim ${o.ticketKey} by key.`}):null}function I2({view:e}){if(!e)return null;const t=`${Z.dataDir}/${e.file}`,s=Object.keys(e.models).length,o=e.agents.map(a=>`${a.agent} ${a.tier}`).join(", ");return i.jsxs(i.Fragment,{children:[i.jsx(V,{className:"set-hint",parts:[{text:t,code:!0},e.exists?`${s} of your own models`:"add new or custom models here","unknown models count as balanced"]}),o&&i.jsx(V,{className:"set-hint models-connected",parts:[`Connected now: ${o}`]}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[t," has errors, so only the built-in models count until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(a=>i.jsx("li",{children:a},a))})]})]})}const ir={fast:"Fast",balanced:"Balanced",strongest:"Strongest"},R2={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},M2=Do.map(e=>({value:e,label:ir[e],hint:R2[e]}));function L2(e){return i.jsx("div",{className:"tier-grid",children:na.map(t=>{const s=e.tiers[t],o=bd[t];return i.jsxs("div",{className:"tier-row",children:[i.jsx("span",{children:Zs[t]}),i.jsx(at,{compact:!0,"aria-label":`${Zs[t]} tickets' model`,className:`tier-select tier-${t}`,value:s,options:M2,onChange:a=>e.onChange(t,a)}),i.jsx(V,{className:"tier-hint",parts:[s!==o&&`default ${ir[o].toLowerCase()}`,e.hints[t]]})]},t)})})}const Lo=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function O2({rows:e}){return e.length?i.jsx("ul",{className:"perf-rows",children:e.map(t=>i.jsx(be,{as:"li",className:"perf-row",title:t.key,trailing:i.jsx("span",{title:"Median time from first claim to done",children:Qt(t.medianLeadMs)}),context:i.jsx(V,{parts:[`${t.done} of ${Lo(t.tickets,"ticket")} done`,t.cancelled>0&&`${t.cancelled} cancelled`,Lo(t.reworkCycles,"rework"),`reviews ${t.reviews.passed} passed, ${t.reviews.failed} failed`,t.answers>0&&Lo(t.answers,"question")]}),detail:t.findings.raised>0?`As reviewer: ${t.findings.upheld} of ${Lo(t.findings.raised,"finding")} upheld`:void 0},t.key))}):i.jsx(Ie,{children:"No claimed tickets yet"})}const up=e=>`${Math.round(e*100)}%`,P2=e=>e===void 0?void 0:`$${e.toFixed(2)} per verified`;function _2({r:e,minSample:t}){return i.jsx(be,{as:"li",className:"perf-row score-row",title:e.key,trailing:e.enough?i.jsxs("span",{title:"Verified on the first attempt",children:[up(e.firstTimeRate)," first time"]}):i.jsx("span",{className:"t-meta",title:`Compared from ${t} tickets`,children:"too few"}),context:i.jsx(V,{parts:[`${e.verified} of ${e.tickets} verified`,`${up(e.reworkRate)} rework`,e.attemptsPerVerified!==void 0&&`${e.attemptsPerVerified} attempts each`,P2(e.costPerVerifiedUsd),e.medianLeadMs!==void 0&&Qt(e.medianLeadMs)]}),detail:e.findings.error+e.findings.warn>0?`Review findings: ${e.findings.error} errors, ${e.findings.warn} warnings`:void 0})}async function D2(){const e=await fetch(`${pe()}/scorecard`);return e.ok?await e.json():null}function Gv(){const[e,t]=y.useState();return Ye({load:D2,show:t,failed:()=>t(null),events:{verification:()=>!0},changed:s=>s.includes("/tickets/")}),e}const z2=[{id:"byTypeAndModel",title:"Type × model"},{id:"byModel",title:"By model"},{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"}];function B2(){const e=Gv(),[t,s]=y.useState("byTypeAndModel"),[o,a]=y.useState(!1);if(e==null)return null;const l=()=>void navigator.clipboard.writeText($S(e)).then(()=>{a(!0),setTimeout(()=>a(!1),1500)});return i.jsxs("section",{className:"perf-section scorecard",children:[i.jsxs("div",{className:"score-head",children:[i.jsx(ze,{as:"h3",children:"Scorecard"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:l,disabled:!e.tickets,children:o?"Copied":"Copy as Markdown"})]}),i.jsxs("p",{className:"perf-note t-meta",children:["How each model and agent does on your own tickets, from the checks Teamtrail ran. A ticket counts for whoever made its first completion. Groups under ",e.minSample," tickets show as too few and aren't compared."]}),i.jsx("div",{className:"choice-row compact",children:z2.map(d=>i.jsx(ot,{on:t===d.id,title:d.title,onClick:()=>s(d.id)},d.id))}),e[t].length?i.jsx("ul",{className:"perf-rows",children:e[t].map(d=>i.jsx(_2,{r:d,minSample:e.minSample},d.key))}):i.jsx(Ie,{children:"No completions yet. The scorecard fills in as agents finish verified tickets."})]})}function qv(e){const[t,s]=y.useState({}),o=e.map(a=>`${a.map.id}:${a.tickets.reduce((l,d)=>Math.max(l,d.updatedAt),0)}`).join();return y.useEffect(()=>{let a=!0;return Promise.all(e.map(async l=>{const d=await fetch(`${pe()}/journal?mapId=${encodeURIComponent(l.map.id)}`).catch(()=>{}),h=d!=null&&d.ok?await d.json():{entries:[]};return[l.map.id,h.entries]})).then(l=>{a&&s(Object.fromEntries(l))}),()=>{a=!1}},[o]),t}const F2=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function U2({api:e,bp:t,onClose:s}){const[o,a]=y.useState("byVendor"),l=y.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),d=qv(l),h=e.activity.answered,f=y.useMemo(()=>vg(l.map(p=>({snap:p,journal:d[p.map.id]??[],answered:h}))),[l,d,h]);return y.useEffect(()=>{const p=k=>k.key==="Escape"&&s();return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[s]),i.jsxs(Be,{className:`zone decisions-view perf-view dv-${t}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(ze,{as:"h2",children:"Trail stats"}),i.jsx(V,{parts:[`${f.trails} trails`,`${f.tickets} tickets`]}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:s,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"perf-body",children:[i.jsxs("section",{className:"perf-section",children:[i.jsx(ze,{as:"h3",children:"What stands out"}),i.jsx("p",{className:"perf-note t-meta",children:"From your own numbers, for you to act on or ignore. Teamtrail doesn't route work from these."}),f.recommendations.length?i.jsx("ul",{className:"perf-recs",children:f.recommendations.map(p=>i.jsxs("li",{title:p.because,children:[i.jsx("span",{children:p.text}),i.jsx("span",{className:"t-meta",children:p.because})]},p.id))}):i.jsx(Ie,{children:"Nothing yet. This needs at least 5 results from two vendors to compare."})]}),i.jsx(B2,{}),i.jsxs("section",{className:"perf-section",children:[i.jsx("div",{className:"choice-row compact",children:F2.map(p=>i.jsx(ot,{on:o===p.id,title:p.title,onClick:()=>a(p.id)},p.id))}),i.jsx(O2,{rows:f[o]}),i.jsx("p",{className:"perf-note t-meta",children:"Spend is tracked per trail, so it isn't split by agent here."})]})]})]})}function W2(e){const t=Gv();if(!t)return null;const s=NS({scorecard:t,tiers:e.tiers,models:e.models});return s.length?i.jsx("ul",{className:"tier-suggestions",children:s.map(o=>i.jsxs("li",{children:[i.jsxs("span",{children:[Zs[o.type],": ",ir[o.tier].toLowerCase()," instead of ",ir[o.current].toLowerCase()]}),i.jsx("span",{className:"t-meta",children:o.because}),i.jsxs(M,{size:"sm",variant:"ghost",onClick:()=>e.onTake(o.type,o.tier),children:["Use ",ir[o.tier].toLowerCase()]})]},o.type))}):null}function H2(e,t){const s=qv(e);return y.useMemo(()=>{var l;const o=vg(e.map(d=>({snap:d,journal:s[d.map.id]??[],answered:t}))),a={};for(const d of o.byType){if(!d.done)continue;const h=(l=o.recommendations.find(p=>p.id===`speed-${d.key}`))==null?void 0:l.text,f=[`Trail stats: ${d.done} done`,d.medianLeadMs!==void 0&&`median ${Qt(d.medianLeadMs)}`,d.reworkCycles>0&&`${d.reworkCycles} back to rework`,h];a[d.key]=f.filter(Boolean).join(" · ")}return a},[e,s,t])}function K2(e){var h,f;const t=Yd(),s=H2(e.snaps,e.answered),o=e.map;if(!o)return null;const a=!!((h=o.modelMatching)!=null&&h.enabled),l=((f=o.modelMatching)==null?void 0:f.tiers)??{},d=(p,k)=>{const v={...l,[p]:k};k===bd[p]&&delete v[p],e.onChange({enabled:!0,tiers:v})};return i.jsxs(Ee,{title:"Model matching",children:[i.jsx("p",{className:"vf-intro",children:"Give each agent the tickets that fit the model it runs on: research to fast models, junctions, prototypes and reviews to the strongest. Teamtrail reads the model from the agent's log and never switches it. An agent can still claim any ticket by name, and tells you when it does."}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsxs("span",{className:"set-field-label",children:["Match work to models on trail ",o.key]}),i.jsx(M,{size:"sm",on:a,"aria-pressed":a,className:"model-matching-toggle",onClick:()=>e.onChange({...o.modelMatching,enabled:!a}),children:a?"On":"Off"})]}),a&&i.jsx(L2,{tiers:im(o),hints:s,onChange:d}),a&&i.jsx(W2,{tiers:im(o),models:t==null?void 0:t.models,onTake:d}),a&&i.jsx("span",{className:"set-hint t-meta",children:"Changes apply to the next claim; nothing running is interrupted."}),i.jsx(I2,{view:t})]})}function tr(e,t){const s=new URL(e);return s.searchParams.delete("settings"),t&&s.searchParams.set("settings",t.section??t.group??""),s.toString()}async function V2(){const e=await fetch(`${pe()}/verification/config`);return e.ok?await e.json():null}function G2(){const[e,t]=y.useState();return Ye({load:V2,show:t,failed:()=>t(null),changed:s=>s.endsWith("verification.json"),events:{attention:()=>!0}}),e}const hp=[{name:"test",command:"npm test"},{name:"lint",command:"npm run lint"},{name:"typecheck",command:"npm run typecheck"}];function q2(e){const t=e.config;return t?t.run.filter(s=>t.checks[s]).map(s=>({name:s,command:t.checks[s].run.join(" ")})):[]}const Q2=e=>e.trim().split(/\s+/).filter(Boolean);function Y2({view:e}){const[t,s]=y.useState(()=>q2(e)),[o,a]=y.useState(!1),[l,d]=y.useState({kind:"idle"}),h=(k,v)=>s(t.map((w,j)=>j===k?{...w,...v}:w)),f=hp.filter(k=>!t.some(v=>v.name===k.name)),p=async()=>{var j;d({kind:"saving"});const k=t.filter(N=>N.name.trim()&&N.command.trim()).map(N=>({name:N.name.trim(),run:Q2(N.command)})),v=await fetch(`${pe()}/verification/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({checks:k,base:((j=e.approval)==null?void 0:j.base)??"none",acknowledged:!0})}).catch(()=>{}),w=await(v==null?void 0:v.json().catch(()=>({})));if(v!=null&&v.ok)return d({kind:"saved"});d({kind:"error",text:(w==null?void 0:w.error)??"The server didn't answer."})};return i.jsxs("div",{className:"vf-editor",children:[t.map((k,v)=>i.jsxs("div",{className:"vf-edit-row",children:[i.jsx("input",{"aria-label":"Name",value:k.name,placeholder:"name",onChange:w=>h(v,{name:w.target.value})}),i.jsx("input",{"aria-label":"Command",className:"t-code",value:k.command,placeholder:"npm test",onChange:w=>h(v,{command:w.target.value})}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>s(t.filter((w,j)=>j!==v)),children:"Remove"})]},v)),i.jsxs("div",{className:"vf-edit-add",children:[f.map(k=>i.jsxs(M,{size:"sm",variant:"ghost",onClick:()=>s([...t,k]),children:["+ ",k.command]},k.name)),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>s([...t,{name:"",command:""}]),children:"+ Another"})]}),t.some(k=>!hp.some(v=>v.name===k.name))&&i.jsxs("p",{className:"vf-edit-hint t-meta",children:["Run from the repository's root, as words (no pipes or ",i.jsx("code",{children:"&&"}),"): the script must already be in the repo. For example ",i.jsx("code",{children:"npm run e2e"}),", ",i.jsx("code",{children:"make test"}),", ",i.jsx("code",{children:"./scripts/check.sh"})," ","or ",i.jsx("code",{children:"pytest -q"}),"."]}),i.jsxs("label",{className:"vf-edit-sure",children:[i.jsx("input",{type:"checkbox",checked:o,onChange:k=>a(k.target.checked)}),i.jsx("span",{children:"I know what these commands run, and approve them"})]}),i.jsxs("div",{className:"vf-edit-save",children:[i.jsx(M,{size:"sm",disabled:!o||l.kind==="saving",onClick:()=>void p(),children:l.kind==="saving"?"Saving…":"Save checks"}),l.kind==="saved"&&i.jsx("span",{className:"t-meta",children:"Saved and approved."}),l.kind==="error"&&i.jsx("span",{className:"vf-err",children:l.text})]})]})}function J2({config:e,file:t,hash:s}){return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line ok",title:s,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[i.jsx("span",{className:"t-code",children:t})," · ",e.run.length," checks run on every completion"]})]}),i.jsx(V,{className:"set-hint",parts:[`New trails start at ${ar[e.default]}`,`${e.maxAttempts} attempts before it waits for you`,e.failFast&&"Stops at the first failure"]}),i.jsx("div",{className:"vf-checks",children:Object.entries(e.checks).map(([o,a])=>i.jsxs("div",{className:"vf-check",children:[i.jsx("span",{className:"t-code",children:e.run.includes(o)?o:`${o} (on request)`}),i.jsx("code",{children:a.run.join(" ")}),i.jsxs("span",{className:"dim",children:[a.timeoutSec," s",a.cwd&&a.cwd!=="."?` · in ${a.cwd}`:""]})]},o))})]})}const X2=[{value:"flag",title:"Show the reviewer",sub:"The proof and the review list them first"},{value:"fail",title:"Send back",sub:"The agent reverts them or says why it needs them"},{value:"human",title:"Ask me",sub:"The ticket waits for you to decide"}];function Z2({view:e,local:t}){var h,f;const[s,o]=y.useState(),a=((h=e.config)==null?void 0:h.scope)??"flag",l=(f=e.approval)!=null&&f.waiting?"Approve the checks first.":void 0,d=async p=>{var w;o(void 0);const k=await fetch(`${pe()}/verification/scope`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:p,base:((w=e.approval)==null?void 0:w.base)??"none"})}).catch(()=>{});if(k!=null&&k.ok)return;const v=await(k==null?void 0:k.json().catch(()=>({})));o((v==null?void 0:v.error)??"The server didn't answer.")};return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"set-field-label",children:"Changes outside the files an agent declared"}),i.jsx("div",{className:"choice-row vf-levels",children:X2.map(p=>i.jsx(ot,{on:a===p.value,title:p.title,sub:p.sub,disabled:!t||!!l,onClick:()=>void d(p.value)},p.value))}),i.jsxs("span",{className:"set-hint t-meta",children:["Agents say which files they'll change when they claim a ticket. Anything they change beyond that is code nobody asked for.",l?` ${l}`:"",t===!1?" Set on the machine Teamtrail runs on.":""]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}function eE(e){var l;const{view:t,local:s,file:o}=e,a=t.config;return i.jsxs(i.Fragment,{children:[s&&i.jsx(Y2,{view:t},((l=t.approval)==null?void 0:l.base)??"none"),!s&&!t.exists&&i.jsx("span",{className:"set-hint t-meta",children:"No checks yet. They're set on the machine Teamtrail runs on."}),!s&&a&&t.exists&&i.jsx(J2,{config:a,file:o,hash:t.hash}),a&&t.exists&&i.jsx(Z2,{view:t,local:s})]})}function tE(e){var k;const t=G2(),s=$a(),[o,a]=y.useState();if(!t)return null;const l=e.map,d=t.config,h=`${Z.dataDir}/${t.file}`,f=(l==null?void 0:l.verification)??"off",p=(d??tg).appliesTo.join(" and ");return i.jsxs(Ee,{title:"Verification",children:[i.jsxs("p",{className:"vf-intro",children:["When an agent says a ticket is done, Teamtrail can check the work before the ticket closes. This applies to"," ",p," tickets. Research, junction and prototype tickets close as soon as they are answered."]}),l&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"set-field-label",children:["How much checking for trail ",l.key]}),i.jsx("div",{className:"choice-row vf-levels",children:Nd.map(v=>i.jsx(ot,{on:f===v,title:ar[v],sub:fv[v],onClick:()=>{a(void 0),fr.act({action:"level",mapId:l.id,level:v,by:St}).catch(w=>a(w.message))}},v))}),f!=="off"&&!d&&i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:"No working checks yet, so completions at this level stop and wait for you."})]}),o&&i.jsx("span",{className:"vf-err",children:o})]}),t.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",title:t.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[h," has errors. Completions that need checks wait for you until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:t.errors.map(v=>i.jsx("li",{children:v},v))})]}),((k=t.approval)==null?void 0:k.waiting)&&i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Its commands don't run on this machine until you approve them."," ",i.jsx("a",{href:tr(location.href,{group:"project",section:"approvals"}),children:"Review the commands"})]})]}),i.jsx(eE,{view:t,local:s,file:h}),i.jsxs("span",{className:"set-hint t-meta",children:["Saved here, checks are approved as you save them. A change to ",h," made in the repo, by an agent or a teammate, runs nothing until you approve it."]}),i.jsxs("span",{className:"set-hint t-meta",children:["Checks run on this machine as you, with no sandbox. Teamtrail passes them only the environment variables they need (more go in ",i.jsx("code",{children:"TEAMTRAIL_CHECK_ENV"}),"), but a check can still read your files (~/.aws, ~/.npmrc, ~/.ssh, ~/.kube, ~/.docker, the GitHub CLI's login, Teamtrail's own credentials) and use your SSH agent. That's why a changed check command needs your approval: you approve the command line, so read what it runs."]})]})}function nE({data:e}){const{map:t}=e;return i.jsxs(i.Fragment,{children:[t?i.jsx(Ke,{id:"mode",children:i.jsx(Ee,{title:`Trail ${t.key}`,children:i.jsx(T$,{value:t.mode,onChange:e.onMapMode})})}):i.jsx(Ie,{children:"Chart or pick a trail to set its mode, model matching and team."}),i.jsx(Ke,{id:"verification",storage:"repo",children:i.jsx(tE,{map:t})}),i.jsx(Ke,{id:"models",children:i.jsx(K2,{map:t,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching})}),t&&i.jsx(Ke,{id:"team",children:i.jsx(TT,{map:t})})]})}const fp=10,Qv=[0,10,16,26,18,24,16,18,22,22,26],Yv=[0,1,1,1,2,2,4,4,4,5,5];function Jv(e){let t=(16*e+128)*e+64;if(e<2)return t;const s=Math.floor(e/7)+2;return t-=(25*s-10)*s-55,e>=7?t-36:t}const sE=e=>Qv[e],iE=e=>Yv[e],Xv=e=>Math.floor(Jv(e)/8)-Qv[e]*Yv[e],Zv=e=>e<10?8:16;function rE(e){if(e===1)return[];const t=Math.floor(e/7)+2,s=e*4+17,o=Math.ceil((e*4+4)/(t*2-2))*2,a=[6];for(let l=s-7;a.length<t;l-=o)a.splice(1,0,l);return a}function kd(e,t){let s=0;for(let o=7;o>=0;o--)s=s<<1^(s>>>7)*285,s^=(t>>>o&1)*e;return s}function oE(e){const t=new Array(e).fill(0);t[e-1]=1;let s=1;for(let o=0;o<e;o++){for(let a=0;a<t.length;a++)t[a]=kd(t[a],s),a+1<t.length&&(t[a]^=t[a+1]);s=kd(s,2)}return t}function aE(e,t){const s=t.map(()=>0);for(const o of e){const a=o^s.shift();s.push(0),t.forEach((l,d)=>s[d]^=kd(l,a))}return s}function lE(e,t){const s=[],o=(d,h)=>{for(let f=h-1;f>=0;f--)s.push(d>>>f&1)};o(4,4),o(e.length,Zv(t));for(const d of e)o(d,8);const a=Xv(t)*8;o(0,Math.min(4,a-s.length)),o(0,(8-s.length%8)%8);for(let d=236;s.length<a;d^=253)o(d,8);const l=[];for(let d=0;d<s.length;d+=8)l.push(s.slice(d,d+8).reduce((h,f)=>h<<1|f,0));return l}function cE(e,t){const s=lE(e,t),o=iE(t),a=sE(t),l=Math.floor(Jv(t)/8),d=o-l%o,h=Math.floor(l/o),f=oE(a),p=[];for(let v=0,w=0;v<o;v++){const j=s.slice(w,w+h-a+(v<d?0:1));w+=j.length;const N=aE(j,f);v<d&&j.push(0),p.push([...j,...N])}const k=[];for(let v=0;v<p[0].length;v++)for(let w=0;w<p.length;w++)(v!==h-a||w>=d)&&k.push(p[w][v]);return k}const dE=[(e,t)=>(e+t)%2===0,(e,t)=>t%2===0,e=>e%3===0,(e,t)=>(e+t)%3===0,(e,t)=>(Math.floor(e/3)+Math.floor(t/2))%2===0,(e,t)=>e*t%2+e*t%3===0,(e,t)=>(e*t%2+e*t%3)%2===0,(e,t)=>((e+t)%2+e*t%3)%2===0];function Hc(e,t){const s=dE[t];for(let o=0;o<e.size;o++)for(let a=0;a<e.size;a++)!e.fixed[o][a]&&s(a,o)&&(e.dark[o][a]=!e.dark[o][a])}function mp(e){let t=0,s=1;for(let a=1;a<=e.length;a++)a<e.length&&e[a]===e[a-1]?s++:(s>=5&&(t+=s-2),s=1);const o=e.map(a=>a?"1":"0").join("");for(const a of["00001011101","10111010000"])for(let l=o.indexOf(a);l>=0;l=o.indexOf(a,l+1))t+=40;return t}function uE(e){let t=0,s=0;for(let a=0;a<e.size;a++)t+=mp(e.dark[a]),t+=mp(e.dark.map(l=>l[a]));for(let a=0;a<e.size;a++)for(let l=0;l<e.size;l++){if(e.dark[a][l]&&s++,l===e.size-1||a===e.size-1)continue;const d=e.dark[a][l];d===e.dark[a][l+1]&&d===e.dark[a+1][l]&&d===e.dark[a+1][l+1]&&(t+=3)}const o=e.size*e.size;return t+Math.floor(Math.abs(s*20-o*10)/o)*10}const an=(e,t)=>(e>>>t&1)!==0;function Nt(e,t,s,o){e.dark[s][t]=o,e.fixed[s][t]=!0}function Kc(e,t,s){for(let o=-4;o<=4;o++)for(let a=-4;a<=4;a++){const l=t+a,d=s+o,h=Math.max(Math.abs(a),Math.abs(o));l>=0&&l<e.size&&d>=0&&d<e.size&&Nt(e,l,d,h!==2&&h!==4)}}function hE(e,t,s){for(let o=-2;o<=2;o++)for(let a=-2;a<=2;a++)Nt(e,t+a,s+o,Math.max(Math.abs(a),Math.abs(o))!==1)}function yd(e,t){const s=0|t;let o=s;for(let l=0;l<10;l++)o=o<<1^(o>>>9)*1335;const a=(s<<10|o)^21522;for(let l=0;l<=5;l++)Nt(e,8,l,an(a,l));Nt(e,8,7,an(a,6)),Nt(e,8,8,an(a,7)),Nt(e,7,8,an(a,8));for(let l=9;l<15;l++)Nt(e,14-l,8,an(a,l));for(let l=0;l<8;l++)Nt(e,e.size-1-l,8,an(a,l));for(let l=8;l<15;l++)Nt(e,8,e.size-15+l,an(a,l));Nt(e,8,e.size-8,!0)}function fE(e,t){if(t<7)return;let s=t;for(let a=0;a<12;a++)s=s<<1^(s>>>11)*7973;const o=t<<12|s;for(let a=0;a<18;a++){const l=e.size-11+a%3,d=Math.floor(a/3);Nt(e,l,d,an(o,a)),Nt(e,d,l,an(o,a))}}function mE(e){const t=e*4+17,s=()=>Array.from({length:t},()=>new Array(t).fill(!1)),o={size:t,dark:s(),fixed:s()};for(let d=0;d<t;d++)Nt(o,6,d,d%2===0),Nt(o,d,6,d%2===0);Kc(o,3,3),Kc(o,t-4,3),Kc(o,3,t-4);const a=rE(e),l=a.length-1;for(let d=0;d<=l;d++)for(let h=0;h<=l;h++)d===0&&h===0||d===0&&h===l||d===l&&h===0||hE(o,a[d],a[h]);return yd(o,0),fE(o,e),o}function pE(e){const t=[];for(let s=e-1;s>=1;s-=2){const o=s<=6?s-1:s,a=(o+1&2)===0;for(let l=0;l<e;l++){const d=a?e-1-l:l;t.push([o,d],[o-1,d])}}return t}function gE(e,t){let s=0;for(const[o,a]of pE(e.size))e.fixed[a][o]||s>=t.length*8||(e.dark[a][o]=an(t[s>>>3],7-(s&7)),s++)}function vE(e){const t=new TextEncoder().encode(e);let s=1;for(;s<=fp&&4+Zv(s)+t.length*8>Xv(s)*8;)s++;if(s>fp)return;const o=mE(s);gE(o,cE(t,s));let a=0,l=1/0;for(let d=0;d<8;d++){Hc(o,d),yd(o,d);const h=uE(o);h<l&&([a,l]=[d,h]),Hc(o,d)}return Hc(o,a),yd(o,a),o.dark}const Vc=4;function kE(e){const t=vE(e.text);if(!t)return null;const s=t.length+Vc*2,o=t.flatMap((a,l)=>a.map((d,h)=>d?`M${h+Vc} ${l+Vc}h1v1h-1z`:"")).join("");return i.jsxs("svg",{className:"si-qr",viewBox:`0 0 ${s} ${s}`,role:"img","aria-label":e.label,shapeRendering:"crispEdges",children:[i.jsx("rect",{width:s,height:s,fill:"#fff"}),i.jsx("path",{d:o,fill:"#000"})]})}function yE(e){const t=Xt(1e3),s=Math.max(0,Math.ceil((e.device.expiresAt-t)/6e4)),o=e.device.links[0];return e.device.expiresAt<=t?i.jsxs("div",{className:"si-code",children:[i.jsx("p",{className:"t-meta",children:"That code expired. Make a new one when the device is ready."}),i.jsx(M,{size:"sm",onClick:e.onDone,children:"Done"})]}):i.jsxs("div",{className:"si-code",children:[o&&i.jsx(kE,{text:o,label:"QR code that pairs another device"}),i.jsxs("div",{className:"si-code-words",children:[i.jsx("span",{className:"si-code-value t-code","aria-label":"Pairing code",children:e.device.code}),i.jsx(V,{parts:["Works once",`expires in ${s} min`]}),i.jsxs("p",{className:"t-meta si-note",children:["Scan it with the device’s camera, or open"," ",o?i.jsx("code",{className:"t-code",children:o.split("#")[0]}):"the Lookout"," there and type the code."]}),i.jsx(M,{size:"sm",onClick:e.onDone,children:"Done"})]})]})}function wE(e){const[t,s]=y.useState();return e.device?i.jsx(yE,{device:e.device,onDone:e.onDone}):e.lan.length?i.jsxs("div",{className:"si-pair",children:[i.jsx(M,{onClick:async()=>s(await e.onPair()),children:"Pair a device"}),t&&i.jsx("span",{className:"vf-err",children:t})]}):i.jsxs("p",{className:"t-meta si-note",children:["This Lookout listens on this machine only, so no other device can reach it. To pair a phone or another computer, start it with ",i.jsxs("code",{className:"t-code",children:[Z.slug," --host 0.0.0.0"]})," on a network you trust. Another browser on this machine: run ",i.jsxs("code",{className:"t-code",children:[Z.slug," pair"]}),"."]})}function xE(e){const[t,s]=y.useState(!1),[o,a]=y.useState(!1),[l,d]=y.useState(),h=async()=>{a(!0),d(await e.onRevoke().catch(f=>f.message)),a(!1),s(!1)};return t?i.jsxs("span",{className:"ra-revoke ask",children:[i.jsx("span",{className:"t-meta",children:"It’s signed out now."}),i.jsxs(M,{size:"sm",disabled:o,onClick:h,children:["Revoke ",e.name]}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]}):i.jsxs("span",{className:"ra-revoke",children:[i.jsx(M,{size:"sm","aria-label":`Revoke ${e.name}`,onClick:()=>s(!0),children:"Revoke"}),l&&i.jsx("span",{className:"vf-err",children:l})]})}const jE={machine:"This machine",device:"Another device"};function SE(e){const t=Date.now();return i.jsx("ul",{className:"ra-list si-list",children:e.sessions.map(s=>i.jsx(be,{as:"li",className:"ra-row",title:s.current?`${s.name} · this browser`:s.name,titleText:s.name,context:i.jsx(V,{parts:[jE[s.kind],s.via==="opened-page"?`From the page ${Z.name} opened`:void 0,s.via==="opened-page"?{text:P0(s.id),code:!0}:void 0,`Paired ${Go(s.pairedAt,t)}`,`Last used ${Go(s.lastUsedAt,t)}`]}),below:s.current?void 0:i.jsx(xE,{name:s.name,onRevoke:()=>e.onRevoke(s.id)})},s.id))})}function NE(){return i.jsxs("div",{className:"ra-notes",children:[i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it stops."})," A program on this machine, or a device on your network, that isn’t a paired browser: an agent with ",i.jsx("code",{children:"curl"})," can’t approve its own work, answer its own questions or change your settings through the Lookout. The session lives only in this page’s own storage and is sent only by this page, never as a cookie, so another server on this machine (an agent’s dev server on another port) gets nothing from your browser; and it goes only to a server that first proves it is this Lookout, so one that takes its port while the Lookout is stopped gets nothing either. A device paired here can read, answer and approve, but never change what runs on this machine or whom it trusts."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it can’t stop."})," A program that can read ",Z.name,"’s config folder can make a pairing code, and one that can read your browser’s profile on disk can copy a session. Keep agents out of both:"," ",i.jsxs("code",{children:[Z.slug," connect"]})," sets that up for the agents it registers."]})]})}const ek=`${Z.apiPrefix}/sign-in`;async function Gc(e,t={}){const s=await fetch(`${ek}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:s.ok,reply:await s.json().catch(()=>({}))}}function bE(){const[e,t]=y.useState(),[s,o]=y.useState(),a=y.useCallback(()=>{fetch(`${ek}/sessions`).then(async f=>f.ok?await f.json():(await f.json().catch(()=>({}))).elsewhere?"elsewhere":null).then(t,()=>t(null))},[]);y.useEffect(a,[a]);const l=y.useCallback(async()=>{const{ok:f,reply:p}=await Gc("/codes");if(!f)return p.error??"No code could be made.";o(p)},[]),d=y.useCallback(async f=>{const{ok:p,reply:k}=await Gc("/revoke",{id:f});return a(),p?void 0:k.error??"That browser could not be revoked."},[a]),h=y.useCallback(async()=>{await Gc("/sign-out"),Fg(),location.reload()},[]);return{view:e,device:s,closeDevice:()=>(o(void 0),a()),pairDevice:l,revoke:d,signOut:h}}function $E(){const{view:e,device:t,closeDevice:s,pairDevice:o,revoke:a,signOut:l}=bE();if(!e)return null;const d=i.jsx("div",{className:"si-signout",children:i.jsx(M,{size:"sm",variant:"ghost",onClick:l,children:"Sign out of this browser"})});return e==="elsewhere"?i.jsxs(Ee,{title:"Browsers & devices",children:[i.jsx("p",{className:"vf-intro",children:"This device is paired with the Lookout. Browsers and devices are paired and revoked on the machine it runs on."}),d]}):i.jsxs(Ee,{title:"Browsers & devices",children:[i.jsx("p",{className:"vf-intro",children:"Every browser that opens this Lookout is paired, and stays signed in while it runs (up to 30 days after it was last used). Revoke one and it’s signed out at once. When the Lookout restarts, browsers and devices pair again: the link is in the terminal where it starts."}),i.jsx(SE,{sessions:e.sessions,onRevoke:a}),i.jsx(wE,{lan:e.lan,device:t,onPair:o,onDone:s}),d,i.jsx(NE,{})]})}function CE({managed:e}){const{signOut:t,pages:s}=e;return i.jsxs(Ee,{title:"Signed in",children:[i.jsxs("p",{className:"vf-intro",children:["Signed in as ",e.name,". Sign-in is managed by the server this Lookout runs on."]}),s.length||e.home?i.jsxs("div",{className:"choice-row",children:[e.home&&i.jsxs(M,{size:"sm",onClick:()=>location.assign(e.home.href),children:["← ",e.home.label]}),s.map(o=>i.jsx(M,{size:"sm",onClick:()=>location.assign(o.href),children:o.label},o.href))]}):null,t?i.jsx("div",{className:"si-signout",children:i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>location.assign(t),children:"Sign out"})}):null]})}function TE(){return y.useEffect(()=>{const e=setInterval(()=>void ga().then(t=>t!=="failed"&&location.reload()),3e3);return()=>clearInterval(e)},[]),i.jsx("div",{className:"pair-page",children:i.jsxs(Be,{as:"main",className:"pair-card",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(xa,{className:"onb-title"})}),i.jsxs("h1",{className:"t-heading pair-title",children:[Z.name," isn’t running here"]}),i.jsxs("p",{className:"t-body pair-step",children:["Start it with ",i.jsx("code",{className:"t-code",children:Z.slug})," on the machine it runs on. This page reconnects once the Lookout answers as itself; until then it sends nothing to this address."]})]})})}async function Jd(e){const t=await fetch(`${Z.apiPrefix}/pair`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e})}).catch(()=>{});if(!t)return"The Lookout didn’t answer. Try again.";const s=await t.json().catch(()=>({}));if(!t.ok)return s.error??"That code didn’t work. Get a new one.";s.id&&s.session&&s.verifier&&L1({id:s.id,secret:s.session,verifier:s.verifier})}function EE(e){const[t,s]=y.useState(!1),o=async()=>{s(!0);const a=await Jd(e.code);if(!a)return location.reload();s(!1),e.onFailed(a)};return i.jsxs("div",{className:"pair-confirm",children:[i.jsxs("p",{className:"t-body pair-step",children:["This link signs this browser in to the Lookout. Use it only if it came to you from"," ",i.jsx("code",{className:"t-code",children:Z.slug}),", ",i.jsxs("code",{className:"t-code",children:[Z.slug," pair"]})," or Pair a device in the Lookout’s Settings."]}),i.jsx("div",{children:i.jsx(M,{variant:"primary",disabled:t,onClick:o,children:"Sign in this browser"})})]})}function pp(){const[e,t]=y.useState(""),[s,o]=y.useState(!1),[a,l]=y.useState(),d=async()=>{if(!e.trim()||s)return;o(!0);const h=await Jd(e);o(!1),l(h),h||location.reload()};return i.jsxs("form",{className:"pair-device",onSubmit:h=>{h.preventDefault(),d()},children:[i.jsxs("p",{className:"t-body pair-step",children:["On a phone or another computer: in the Lookout on the machine ",Z.name," runs on, open Settings → You → Browsers & devices → Pair a device. Then type the code here, or scan it with this device’s camera."]}),i.jsxs("div",{className:"pair-code-row",children:[i.jsx("input",{className:"pair-code-input t-code",value:e,onChange:h=>t(h.target.value),placeholder:"ABCD-EFGH","aria-label":"Pairing code",autoComplete:"one-time-code",autoCapitalize:"characters",spellCheck:!1,maxLength:20}),i.jsx(M,{type:"submit",variant:"primary",disabled:s||!e.trim(),children:"Pair"})]}),a&&i.jsx("p",{className:"vf-err",role:"alert",children:a})]})}function gp(){return i.jsxs("p",{className:"t-body pair-step pair-here",children:["On the machine ",Z.name," runs on, run ",i.jsxs("code",{className:"t-code",children:[Z.slug," pair"]}),": it opens a tab ready to sign in, with one click. Or open the Sign in link ",i.jsx("code",{className:"t-code",children:Z.slug})," printed in its terminal."]})}function AE(e){return i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"t-body pair-step",children:"The Lookout opens only in browsers you’ve paired."}),e.local?i.jsx(gp,{}):i.jsx(pp,{}),e.local?i.jsx(pp,{}):i.jsx(gp,{})]})}function IE(e){const[t,s]=y.useState(),[o,a]=y.useState(e.code),[l,d]=y.useState(e.code);e.code!==l&&(d(e.code),a(e.code));const h=f=>(s(f),a(void 0));return i.jsx("div",{className:"pair-page",children:i.jsxs(Be,{as:"main",className:"pair-card",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(xa,{className:"onb-title"})}),i.jsx("h1",{className:"t-heading pair-title",children:"Pair this browser"}),t&&i.jsx("p",{className:"pair-problem t-body",role:"alert",children:t}),o?i.jsx(EE,{code:o,onFailed:h}):i.jsx(AE,{local:e.local})]})})}function vp(){const e=/(?:^#|&)pair=([A-Za-z0-9_-]{1,64})/.exec(location.hash);if(e)return history.replaceState(null,"",`${location.pathname}${location.search}`),e[1]}async function kp(){try{const e=await fetch(`${Z.apiPrefix}/session`,{cache:"no-store"});if(!e.ok)return{kind:"no-server"};const t=await e.json();return typeof t.signedIn!="boolean"?{kind:"no-server"}:t.signedIn&&C1(t)?{kind:"signed-in"}:{kind:"signed-out",local:t.local===!0}}catch{return{kind:"no-server"}}}async function RE(){if(!Ld())return kp();const e=await ga();return e==="proven"?{kind:"signed-in"}:e==="unknown"?kp():{kind:"not-running"}}function ME(){const[e,t]=y.useState({kind:"checking"});return y.useEffect(()=>void RE().then(t),[]),y.useEffect(()=>O1(s=>s==="failed"&&t({kind:"not-running"})),[]),e}function LE({children:e}){const t=ME(),[s,o]=y.useState(vp);return y.useEffect(()=>{const a=()=>o(l=>vp()??l);return window.addEventListener("hashchange",a),()=>window.removeEventListener("hashchange",a)},[]),y.useEffect(()=>{t.kind==="signed-in"&&s&&Jd(s)},[t.kind,s]),t.kind==="checking"?null:t.kind==="signed-out"?i.jsx(IE,{local:t.local,code:s}):t.kind==="not-running"?i.jsx(TE,{}):i.jsx(i.Fragment,{children:e})}function OE(){const e=ft();return e?i.jsx(CE,{managed:e}):i.jsx(Ke,{id:"devices",storage:"machine",children:i.jsx($E,{})})}const PE=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function _E(e){return i.jsx("div",{className:"choice-row compact",children:PE.map(t=>i.jsx(ot,{on:e.value===t.value,title:t.title,onClick:()=>e.onChange(t.value)},t.value))})}function DE({data:e}){var o;const{prefs:t,update:s}=e;return i.jsxs(i.Fragment,{children:[i.jsx(Ke,{id:"appearance",storage:"browser",children:i.jsxs(Ee,{title:"Appearance",children:[Yg()?i.jsx("p",{className:"vf-intro",children:"Follows the theme you picked in your account on the server. Change it from your name in its menu."}):i.jsx(_E,{value:Jg(t.theme),onChange:a=>s({theme:a})}),((o=ft())==null?void 0:o.themeSave)&&i.jsx("p",{className:"vf-intro",children:"Saved to your account, so the server's pages follow it."})]})}),i.jsx(Ke,{id:"transcript",storage:"browser",children:i.jsx(Ee,{title:"HITL transcript",children:i.jsx(jv,{value:t.hitlTranscript,onChange:a=>s({hitlTranscript:a})})})}),i.jsx(Ke,{id:"agent",children:i.jsx(Ee,{title:"Agent",children:i.jsx("div",{className:"choice-row",children:Tg.map(a=>i.jsx(ot,{on:a.status==="primary",disabled:a.status!=="primary",title:a.name},a.id))})})}),i.jsx(OE,{})]})}function zE(e){const{data:t,route:s}=e;switch(e.group){case"trail":return i.jsx(nE,{data:t});case"project":return i.jsx(c2,{data:t,route:s});case"alerts":return i.jsx(DC,{data:t,route:s});case"you":return i.jsx(DE,{data:t});case"projects":return i.jsx(Ke,{id:"projects",storage:"machine",children:i.jsx(C2,{})});case"about":return i.jsx(Ke,{id:"changelog",children:i.jsx(HC,{})});default:return e.group}}function BE(e){const{group:t,route:s}=e,o=y.useRef(null),a=y.useRef(null);return y.useEffect(()=>{var d,h;(d=o.current)==null||d.focus({preventScroll:!0});const l=s.section&&document.getElementById(`settings-${s.section}`);l?l.scrollIntoView({block:"start"}):(h=a.current)==null||h.scrollTo({top:0})},[t.id,s.section]),i.jsx("div",{className:"sp-pane",ref:a,children:i.jsxs("div",{className:"sp-pane-in",children:[i.jsxs("header",{className:"sp-pane-head",children:[i.jsx("h2",{className:"sp-title t-title",ref:o,tabIndex:-1,children:t.label}),i.jsx("p",{className:"sp-intro t-meta",children:t.intro})]}),i.jsx(zE,{group:t.id,data:e.data,route:s})]})})}function FE(e){return i.jsx("nav",{className:"sp-nav","aria-label":"Settings groups",children:i.jsx("ul",{children:lr.map(t=>{const s=t.id===e.current;return i.jsx(be,{as:"li",className:"sp-nav-row",selected:s,current:s?"page":void 0,title:t.label,context:i.jsx(V,{parts:t.sections.map(o=>o.title)}),trailing:e.drill&&"›",onOpen:()=>e.onPick(t.id)},t.id)})})})}function UE(e,t){return e.group?lr.find(s=>s.id===e.group):t==="mobile"?void 0:lr[0]}const WE={page:"Back to the Lookout",list:"Lookout",group:"Settings"},HE=(e,t)=>e?t?"group":"list":"page";function KE(e){const{bp:t,route:s}=e,o=t==="mobile",a=UE(s,t),l=HE(o,!!a),d=$a()===!1,h=()=>l==="group"?e.onShow({}):e.onClose();y.useEffect(()=>{const k=v=>{v.key!=="Escape"||v.defaultPrevented||document.querySelector(".scrim")||(l==="group"?e.onShow({}):e.onClose())};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[l,e]);const f=k=>e.onShow({group:k}),p=l!=="group"&&i.jsx(FE,{current:a==null?void 0:a.id,onPick:f,drill:o});return i.jsxs(Be,{className:`zone decisions-view settings-page sp-${t}`,"aria-label":"Settings",children:[i.jsxs("header",{className:"dv-head",children:[i.jsxs("button",{className:"back",onClick:h,children:["‹ ",WE[l]]}),l!=="group"&&i.jsx(ze,{as:"h2",children:"Settings"}),!o&&i.jsx("span",{className:"dv-head-right t-meta",children:"Esc"})]}),d&&i.jsx($C,{}),i.jsxs("div",{className:"sp-body",children:[p,a&&i.jsx(BE,{group:a,data:e.data,route:s})]})]})}function VE(e){var a;const{rt:t,api:s,settings:o}=e;return o.route?i.jsx(KE,{bp:e.bp,route:o.route,onShow:o.show,onClose:o.close,data:{prefs:e.prefs,update:e.update,activeTracker:t.kind,location:t.adapter.location,map:(a=s.snap)==null?void 0:a.map,onMapMode:s.actions.setMode,snaps:Object.values(s.allSnaps),answered:s.activity.answered,onModelMatching:s.actions.setModelMatching}}):null}function GE(e){return i.jsxs(Be,{className:"zone side",style:{gridArea:"inspector"},children:[i.jsx(wN,{className:"zone-tabs",value:e.tab,onChange:e.onTab,items:[{id:"ticket",label:"Ticket"},{id:"activity",label:"Activity"},{id:"plan",label:"Plan",n:e.unspecified}]}),{ticket:e.ticket,activity:e.activity,plan:e.plan}[e.tab]]})}function tk(e){return e.filter(t=>t.state!=="out-of-scope").map(t=>({x:t.x,y:t.y,w:Ve,h:Qe}))}function qE(e){const{obstacles:t,from:s,to:o,clear:a}=e,l=t.flatMap(h=>[h.y-28,h.y+h.h+28]).filter(a),d=h=>Math.abs(h-s)+Math.abs(h-o);return l.reduce((h,f)=>d(f)<d(h)?f:h,l[0]??s)}const QE=6;function YE(e){const t=e.filter((a,l)=>l===0||a.x!==e[l-1].x||a.y!==e[l-1].y);let s=`M${t[0].x} ${t[0].y}`;for(let a=1;a<t.length-1;a++){const[l,d,h]=[t[a-1],t[a],t[a+1]],f=Math.min(QE,yp(l,d)/2,yp(d,h)/2),p=wp(d,l,f),k=wp(d,h,f);s+=`L${p.x} ${p.y}Q${d.x} ${d.y} ${k.x} ${k.y}`}const o=t[t.length-1];return`${s}L${o.x} ${o.y}`}function yp(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function wp(e,t,s){return{x:e.x+Math.sign(t.x-e.x)*s,y:e.y+Math.sign(t.y-e.y)*s}}function Jo(e){const t=e.direction==="TB",s=d=>t?{x:d.y,y:d.x}:d,o=s(e.a),a=s(e.b),l=e.obstacles.map(d=>t?{x:d.y,y:d.x,w:d.h,h:d.w}:d);return YE(JE({a:o,b:a,obstacles:l,gap:e.gap}).map(s))}function JE({a:e,b:t,obstacles:s,gap:o}){const a=s.filter(p=>p.x+p.w>e.x+1&&p.x<t.x-1),l=p=>!a.some(k=>p>k.y-8&&p<k.y+k.h+8),d=Math.min(e.x+o/2,(e.x+t.x)/2),h=Math.max(t.x-o/2,(e.x+t.x)/2);if(l(e.y))return[e,{x:h,y:e.y},{x:h,y:t.y},t];if(l(t.y))return[e,{x:d,y:e.y},{x:d,y:t.y},t];const f=qE({obstacles:a,from:e.y,to:t.y,clear:l});return[e,{x:d,y:e.y},{x:d,y:f},{x:h,y:f},{x:h,y:t.y},t]}function XE(e){if(e.direction==="LR"){const s=e.width+96;return{x:s,y:e.graphH/2,right:s+34,bottom:e.height}}const t=e.graphH+76;return{x:e.width/2,y:t,right:e.width,bottom:Math.max(e.height,t+40)}}function ZE(e,t){const s=new Set(e.edges.map(l=>l.from)),o=e.nodes.filter(l=>l.state!=="out-of-scope"&&!s.has(l)),a=tk(e.nodes);return o.map(l=>{if(e.direction==="LR"){const f={x:l.x+Ve,y:l.y+Qe/2},p={x:t.x-30,y:t.y};return Jo({direction:"LR",a:f,b:p,obstacles:a,gap:96})}const d={x:l.x+Ve/2,y:l.y+Qe},h={x:t.x,y:t.y-30};return Jo({direction:"TB",a:d,b:h,obstacles:a,gap:48})})}function eA({x:e,y:t,text:s}){const o=s!=null&&s.trim()?`Destination
|
|
154
|
+
`),trailing:hn(e.now-t.since),onOpen:e.onOpen,below:e.onAnswer&&i.jsx(u2,{onAnswer:e.onAnswer})})}function f2(e){const t=e.view.attention,s=o=>{var a;return((a=e.view.projects.find(l=>l.id===o))==null?void 0:a.state.kind)!=="missing"};return i.jsxs("section",{className:"pj-section pj-attention",children:[i.jsx(Et,{title:"Needs you",count:t.length,hot:t.some(o=>o.interrupting),info:"One queue across projects, ranked the way each project ranks its own. Answer questions here; the agent in that repo gets the answer."}),t.length===0&&i.jsx(Sn,{title:"Nothing needs you",hint:"Agents in every project can keep going."}),i.jsx("ul",{className:"pj-list",children:t.map(o=>i.jsx(h2,{item:o,now:e.now,onOpen:()=>e.onOpen(o.projectId,o.id),onAnswer:o.kind==="question"&&s(o.projectId)?a=>ms.answer(o.projectId,{questionId:o.ref,text:a}).then(e.onAnswered):void 0},`${o.projectId}/${o.id}`))})]})}const Wc=(e,t,s=`${t}s`)=>`${e} ${e===1?t:s}`;function m2(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function p2(e){if(e.state.kind==="missing")return[{text:"Missing",strong:!0},{text:e.path,code:!0}];const t=[];e.needsYou&&t.push({text:`${e.needsYou} ${e.needsYou===1?"needs":"need"} you`,strong:!0,urgent:e.interrupting>0}),e.agents&&t.push(Wc(e.agents,"agent"));const{working:s,verifying:o,rework:a,blocked:l}=e.phases;s&&t.push(`${s} working`),o&&t.push(`${o} verifying`),a&&t.push(`${a} rework`),l&&t.push(`${l} blocked`),e.flags&&t.push(Wc(e.flags,"PR flag")),e.stalled&&t.push(Wc(e.stalled,"stalled claim")),t.length||t.push(e.trails?"Nothing waiting":"No trails yet");const d=g2(e.tracker);return d&&t.push(d),t}function g2(e){if(e.kind==="github"&&e.repo)return`Issues in ${e.repo}`;if(!(e.kind!=="linear"||!e.team))return e.org?`Linear: ${e.team} in ${e.org}`:`Linear: ${e.team}`}function v2(e){var t;return e.state.kind==="elsewhere"?e.state.url?`Served by another Lookout · ${e.state.url}`:"Served by another Teamtrail on this machine":((t=e.top)==null?void 0:t.title)??e.note??e.path}function Yo(e,t,s){if(e.state.kind!=="missing"){if(e.state.kind==="elsewhere"){const o=e.state.url?Nn(e.state.url):void 0;if(!o)return;const a=new URL(o);s&&a.searchParams.set(Ys,s),window.open(a.toString(),"_blank","noopener");return}location.href=h1({id:e.id,home:t,tracker:e.tracker.kind,item:s})}}function Hv(e){const{p:t}=e,s=v2(t);return i.jsx(be,{as:"li",className:`project-card st-${t.state.kind}`,edge:m2(t),selected:e.current,title:t.name,titleText:t.path,context:i.jsx(V,{parts:p2(t)}),detail:s,detailText:s,trailing:t.lastActivity?hn(e.now-t.lastActivity):void 0,onOpen:e.onOpen})}const Kv=`${ea}:projects:seen`,dp=24*36e5;function k2(e){try{const t=Number(localStorage.getItem(Kv));return t>0?t:e-dp}catch{return e-dp}}function y2(e){try{localStorage.setItem(Kv,String(e))}catch{}}function w2(){const[e,t]=y.useState();return y.useEffect(()=>{const s=Date.now();return ms.briefing(k2(s)).then(t).catch(()=>{}),()=>y2(s)},[]),e}function x2(e){const{view:t,reload:s}=e.projects,o=Xt(15e3),a=w2();if(y.useEffect(()=>{const f=p=>p.key==="Escape"&&e.onClose();return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[e]),!t)return null;const l=ur()??t.home,d=f=>{const p=t.projects.find(v=>v.id===f);(p==null?void 0:p.id)===l?e.onClose():p&&Yo(p,t.home)},h=(f,p)=>{const v=t.projects.find(k=>k.id===f);if(v){if(v.id!==l)return Yo(v,t.home,p);e.onClose(),e.onItemHere(p)}};return i.jsxs(Be,{className:`zone decisions-view projects-view dv-${e.bp}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(ze,{as:"h2",children:"All projects"}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"pj-body",children:[i.jsx(f2,{view:t,now:o,onOpen:h,onAnswered:s}),i.jsxs("section",{className:"pj-section pj-projects",children:[i.jsx(Et,{title:"Projects",count:t.projects.length,info:"Each repo registered on this machine, read from its own files. Nothing leaves your machine."}),i.jsx("ul",{className:"pj-list",children:t.projects.map(f=>i.jsx(Hv,{p:f,current:f.id===l,now:o,onOpen:f.state.kind==="missing"?void 0:()=>d(f.id)},f.id))}),i.jsx(Wv,{onAdded:s})]}),i.jsx(d2,{briefing:a,now:o,onOpen:d})]})]})}function j2(e){const[t,s]=y.useState(!1),o=y.useRef(null);y.useEffect(()=>{if(!t)return;const h=f=>{var p;(f instanceof KeyboardEvent?f.key==="Escape":!((p=o.current)!=null&&p.contains(f.target)))&&s(!1)};return window.addEventListener("mousedown",h),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",h)}},[t]);const{view:a}=e.projects;if(!a||!e.projects.many)return i.jsx("span",{className:"repo",children:e.repo});const l=ur()??a.home,d=a.projects.filter(h=>h.id!==l).reduce((h,f)=>h+f.interrupting,0);return i.jsxs("div",{className:"project-switcher",ref:o,children:[i.jsxs("button",{className:"project-btn repo",onClick:()=>s(h=>!h),"aria-haspopup":"menu","aria-expanded":t,"data-tip":"Switch project, or see all of them",children:[i.jsx("span",{className:"project-name",children:e.repo}),d>0&&i.jsx(fs,{n:d,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),t&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsxs("button",{role:"menuitem",className:"trail-item all-projects",onClick:()=>{s(!1),e.onOverview()},children:[i.jsx("span",{className:"mi-title",children:"All projects"}),i.jsx(fs,{n:a.attention.length,urgent:a.attention.some(h=>h.interrupting),hideZero:!0})]}),i.jsx(ze,{variant:"plain",className:"menu-h",children:"Projects"}),a.projects.map(h=>i.jsxs("button",{role:"menuitem",className:`trail-item ${h.id===l?"on":""} st-${h.state.kind}`,disabled:h.state.kind==="missing",onClick:()=>{s(!1),h.id!==l&&Yo(h,a.home)},children:[i.jsx("span",{className:"mi-title",children:h.name}),i.jsx("span",{className:"mi-progress",children:S2(h.state.kind)}),i.jsx(fs,{n:h.needsYou,urgent:h.interrupting>0,hideZero:!0})]},h.id))]})]})}function S2(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function N2(e){const t=Xt(15e3),{view:s}=e.projects;if(!s||!e.projects.many)return null;const o=ur()??s.home;return i.jsxs("section",{className:"phone-projects",children:[i.jsx(Et,{title:"Projects",count:s.projects.length,right:i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onOverview,children:"All projects"})}),i.jsx("ul",{className:"pj-list",children:s.projects.filter(a=>a.id!==o).map(a=>i.jsx(Hv,{p:a,current:!1,now:t,onOpen:a.state.kind==="missing"?void 0:()=>Yo(a,s.home)},a.id))})]})}async function b2(){const e=await fetch(ms.url);return e.ok?await e.json():void 0}function Vv(){const[e,t]=y.useState(),{reload:s,pushed:o}=Ye({load:b2,show:a=>a&&t(a)});return y.useEffect(()=>si("projects",a=>{o(),t(JSON.parse(a))}),[o]),{view:e,many:((e==null?void 0:e.projects.length)??0)>1,reload:s}}const $2=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function C2(){const{view:e,reload:t}=Vv(),[s,o]=y.useState();if(!e)return null;const a=l=>{o(void 0),l.then(t,d=>o(d.message))};return i.jsxs(Ee,{title:"Projects",children:[i.jsx("p",{className:"vf-intro",children:"Supervise several repos from this Lookout: All projects shows what needs you in each of them. The list lives in your config folder on this machine, never in a repo, and agents only ever work in their own repo. A project that shares its decisions offers them to agents in your other projects as suggestions, never as answers."}),i.jsx("ul",{className:"pj-list set-projects",children:e.projects.map(l=>i.jsx(be,{as:"li",edge:l.state.kind==="missing"?"attention":"neutral",title:l.name,context:i.jsx(V,{parts:$2(l)}),actions:i.jsxs(i.Fragment,{children:[i.jsx(M,{size:"sm",variant:"ghost",on:l.sharePrecedents,"aria-pressed":l.sharePrecedents,className:"share-precedents-toggle",title:"Offer this project's decisions as suggestions when agents look for precedents in your other projects",onClick:()=>a(ms.setShare(l.id,!l.sharePrecedents)),children:l.sharePrecedents?"Shares decisions":"Share decisions"}),!l.home&&i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>a(ms.remove(l.id)),children:"Remove"})]})},l.id))}),i.jsx(Wv,{onAdded:t}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Agents add their repo when they connect"}),i.jsx(M,{size:"sm",on:e.autoRegister,"aria-pressed":e.autoRegister,className:"auto-register-toggle",onClick:()=>a(ms.setAutoRegister(!e.autoRegister)),children:e.autoRegister?"On":"Off"})]}),i.jsx(V,{className:"set-hint",parts:[{text:`${Z.slug} projects add <path>`,code:!0},`--no-register or ${Z.noRegisterEnv} opts one agent out`]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}const T2=`${Z.apiPrefix}/models`;async function E2(){const e=await fetch(T2);return e.ok?await e.json():null}function Yd(){const[e,t]=y.useState();return Ye({load:E2,show:t,failed:()=>t(null),changed:s=>s.endsWith("models.json")||s.endsWith("map.md")||s.includes("/tickets/"),events:{attention:()=>!0}}),e}function A2({mapId:e,ticketId:t}){const s=Yd(),o=s==null?void 0:s.waiting.find(a=>a.mapId===e&&a.ticketId===t);return o?i.jsx(be,{className:"model-wait d-section",edge:"attention",title:`Needs a ${o.tier} model`,context:i.jsx(V,{parts:[`Connected agents run ${o.best} at most`]}),detail:`Connect an agent on a ${o.tier} model, or have one claim ${o.ticketKey} by key.`}):null}function I2({view:e}){if(!e)return null;const t=`${Z.dataDir}/${e.file}`,s=Object.keys(e.models).length,o=e.agents.map(a=>`${a.agent} ${a.tier}`).join(", ");return i.jsxs(i.Fragment,{children:[i.jsx(V,{className:"set-hint",parts:[{text:t,code:!0},e.exists?`${s} of your own models`:"add new or custom models here","unknown models count as balanced"]}),o&&i.jsx(V,{className:"set-hint models-connected",parts:[`Connected now: ${o}`]}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[t," has errors, so only the built-in models count until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(a=>i.jsx("li",{children:a},a))})]})]})}const ir={fast:"Fast",balanced:"Balanced",strongest:"Strongest"},R2={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},M2=Do.map(e=>({value:e,label:ir[e],hint:R2[e]}));function L2(e){return i.jsx("div",{className:"tier-grid",children:na.map(t=>{const s=e.tiers[t],o=bd[t];return i.jsxs("div",{className:"tier-row",children:[i.jsx("span",{children:Zs[t]}),i.jsx(at,{compact:!0,"aria-label":`${Zs[t]} tickets' model`,className:`tier-select tier-${t}`,value:s,options:M2,onChange:a=>e.onChange(t,a)}),i.jsx(V,{className:"tier-hint",parts:[s!==o&&`default ${ir[o].toLowerCase()}`,e.hints[t]]})]},t)})})}const Lo=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function O2({rows:e}){return e.length?i.jsx("ul",{className:"perf-rows",children:e.map(t=>i.jsx(be,{as:"li",className:"perf-row",title:t.key,trailing:i.jsx("span",{title:"Median time from first claim to done",children:Qt(t.medianLeadMs)}),context:i.jsx(V,{parts:[`${t.done} of ${Lo(t.tickets,"ticket")} done`,t.cancelled>0&&`${t.cancelled} cancelled`,Lo(t.reworkCycles,"rework"),`reviews ${t.reviews.passed} passed, ${t.reviews.failed} failed`,t.answers>0&&Lo(t.answers,"question")]}),detail:t.findings.raised>0?`As reviewer: ${t.findings.upheld} of ${Lo(t.findings.raised,"finding")} upheld`:void 0},t.key))}):i.jsx(Ie,{children:"No claimed tickets yet"})}const up=e=>`${Math.round(e*100)}%`,P2=e=>e===void 0?void 0:`$${e.toFixed(2)} per verified`;function _2({r:e,minSample:t}){return i.jsx(be,{as:"li",className:"perf-row score-row",title:e.key,trailing:e.enough?i.jsxs("span",{title:"Verified on the first attempt",children:[up(e.firstTimeRate)," first time"]}):i.jsx("span",{className:"t-meta",title:`Compared from ${t} tickets`,children:"too few"}),context:i.jsx(V,{parts:[`${e.verified} of ${e.tickets} verified`,`${up(e.reworkRate)} rework`,e.attemptsPerVerified!==void 0&&`${e.attemptsPerVerified} attempts each`,P2(e.costPerVerifiedUsd),e.medianLeadMs!==void 0&&Qt(e.medianLeadMs)]}),detail:e.findings.error+e.findings.warn>0?`Review findings: ${e.findings.error} errors, ${e.findings.warn} warnings`:void 0})}async function D2(){const e=await fetch(`${pe()}/scorecard`);return e.ok?await e.json():null}function Gv(){const[e,t]=y.useState();return Ye({load:D2,show:t,failed:()=>t(null),events:{verification:()=>!0},changed:s=>s.includes("/tickets/")}),e}const z2=[{id:"byTypeAndModel",title:"Type × model"},{id:"byModel",title:"By model"},{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"}];function B2(){const e=Gv(),[t,s]=y.useState("byTypeAndModel"),[o,a]=y.useState(!1);if(e==null)return null;const l=()=>void navigator.clipboard.writeText($S(e)).then(()=>{a(!0),setTimeout(()=>a(!1),1500)});return i.jsxs("section",{className:"perf-section scorecard",children:[i.jsxs("div",{className:"score-head",children:[i.jsx(ze,{as:"h3",children:"Scorecard"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:l,disabled:!e.tickets,children:o?"Copied":"Copy as Markdown"})]}),i.jsxs("p",{className:"perf-note t-meta",children:["How each model and agent does on your own tickets, from the checks Teamtrail ran. A ticket counts for whoever made its first completion. Groups under ",e.minSample," tickets show as too few and aren't compared."]}),i.jsx("div",{className:"choice-row compact",children:z2.map(d=>i.jsx(ot,{on:t===d.id,title:d.title,onClick:()=>s(d.id)},d.id))}),e[t].length?i.jsx("ul",{className:"perf-rows",children:e[t].map(d=>i.jsx(_2,{r:d,minSample:e.minSample},d.key))}):i.jsx(Ie,{children:"No completions yet. The scorecard fills in as agents finish verified tickets."})]})}function qv(e){const[t,s]=y.useState({}),o=e.map(a=>`${a.map.id}:${a.tickets.reduce((l,d)=>Math.max(l,d.updatedAt),0)}`).join();return y.useEffect(()=>{let a=!0;return Promise.all(e.map(async l=>{const d=await fetch(`${pe()}/journal?mapId=${encodeURIComponent(l.map.id)}`).catch(()=>{}),h=d!=null&&d.ok?await d.json():{entries:[]};return[l.map.id,h.entries]})).then(l=>{a&&s(Object.fromEntries(l))}),()=>{a=!1}},[o]),t}const F2=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function U2({api:e,bp:t,onClose:s}){const[o,a]=y.useState("byVendor"),l=y.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),d=qv(l),h=e.activity.answered,f=y.useMemo(()=>vg(l.map(p=>({snap:p,journal:d[p.map.id]??[],answered:h}))),[l,d,h]);return y.useEffect(()=>{const p=v=>v.key==="Escape"&&s();return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[s]),i.jsxs(Be,{className:`zone decisions-view perf-view dv-${t}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(ze,{as:"h2",children:"Trail stats"}),i.jsx(V,{parts:[`${f.trails} trails`,`${f.tickets} tickets`]}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:s,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"perf-body",children:[i.jsxs("section",{className:"perf-section",children:[i.jsx(ze,{as:"h3",children:"What stands out"}),i.jsx("p",{className:"perf-note t-meta",children:"From your own numbers, for you to act on or ignore. Teamtrail doesn't route work from these."}),f.recommendations.length?i.jsx("ul",{className:"perf-recs",children:f.recommendations.map(p=>i.jsxs("li",{title:p.because,children:[i.jsx("span",{children:p.text}),i.jsx("span",{className:"t-meta",children:p.because})]},p.id))}):i.jsx(Ie,{children:"Nothing yet. This needs at least 5 results from two vendors to compare."})]}),i.jsx(B2,{}),i.jsxs("section",{className:"perf-section",children:[i.jsx("div",{className:"choice-row compact",children:F2.map(p=>i.jsx(ot,{on:o===p.id,title:p.title,onClick:()=>a(p.id)},p.id))}),i.jsx(O2,{rows:f[o]}),i.jsx("p",{className:"perf-note t-meta",children:"Spend is tracked per trail, so it isn't split by agent here."})]})]})]})}function W2(e){const t=Gv();if(!t)return null;const s=NS({scorecard:t,tiers:e.tiers,models:e.models});return s.length?i.jsx("ul",{className:"tier-suggestions",children:s.map(o=>i.jsxs("li",{children:[i.jsxs("span",{children:[Zs[o.type],": ",ir[o.tier].toLowerCase()," instead of ",ir[o.current].toLowerCase()]}),i.jsx("span",{className:"t-meta",children:o.because}),i.jsxs(M,{size:"sm",variant:"ghost",onClick:()=>e.onTake(o.type,o.tier),children:["Use ",ir[o.tier].toLowerCase()]})]},o.type))}):null}function H2(e,t){const s=qv(e);return y.useMemo(()=>{var l;const o=vg(e.map(d=>({snap:d,journal:s[d.map.id]??[],answered:t}))),a={};for(const d of o.byType){if(!d.done)continue;const h=(l=o.recommendations.find(p=>p.id===`speed-${d.key}`))==null?void 0:l.text,f=[`Trail stats: ${d.done} done`,d.medianLeadMs!==void 0&&`median ${Qt(d.medianLeadMs)}`,d.reworkCycles>0&&`${d.reworkCycles} back to rework`,h];a[d.key]=f.filter(Boolean).join(" · ")}return a},[e,s,t])}function K2(e){var h,f;const t=Yd(),s=H2(e.snaps,e.answered),o=e.map;if(!o)return null;const a=!!((h=o.modelMatching)!=null&&h.enabled),l=((f=o.modelMatching)==null?void 0:f.tiers)??{},d=(p,v)=>{const k={...l,[p]:v};v===bd[p]&&delete k[p],e.onChange({enabled:!0,tiers:k})};return i.jsxs(Ee,{title:"Model matching",children:[i.jsx("p",{className:"vf-intro",children:"Give each agent the tickets that fit the model it runs on: research to fast models, junctions, prototypes and reviews to the strongest. Teamtrail reads the model from the agent's log and never switches it. An agent can still claim any ticket by name, and tells you when it does."}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsxs("span",{className:"set-field-label",children:["Match work to models on trail ",o.key]}),i.jsx(M,{size:"sm",on:a,"aria-pressed":a,className:"model-matching-toggle",onClick:()=>e.onChange({...o.modelMatching,enabled:!a}),children:a?"On":"Off"})]}),a&&i.jsx(L2,{tiers:im(o),hints:s,onChange:d}),a&&i.jsx(W2,{tiers:im(o),models:t==null?void 0:t.models,onTake:d}),a&&i.jsx("span",{className:"set-hint t-meta",children:"Changes apply to the next claim; nothing running is interrupted."}),i.jsx(I2,{view:t})]})}function tr(e,t){const s=new URL(e);return s.searchParams.delete("settings"),t&&s.searchParams.set("settings",t.section??t.group??""),s.toString()}async function V2(){const e=await fetch(`${pe()}/verification/config`);return e.ok?await e.json():null}function G2(){const[e,t]=y.useState();return Ye({load:V2,show:t,failed:()=>t(null),changed:s=>s.endsWith("verification.json"),events:{attention:()=>!0}}),e}const hp=[{name:"test",command:"npm test"},{name:"lint",command:"npm run lint"},{name:"typecheck",command:"npm run typecheck"}];function q2(e){const t=e.config;return t?t.run.filter(s=>t.checks[s]).map(s=>({name:s,command:t.checks[s].run.join(" ")})):[]}const Q2=e=>e.trim().split(/\s+/).filter(Boolean);function Y2({view:e}){const[t,s]=y.useState(()=>q2(e)),[o,a]=y.useState(!1),[l,d]=y.useState({kind:"idle"}),h=(v,k)=>s(t.map((w,j)=>j===v?{...w,...k}:w)),f=hp.filter(v=>!t.some(k=>k.name===v.name)),p=async()=>{var j;d({kind:"saving"});const v=t.filter(N=>N.name.trim()&&N.command.trim()).map(N=>({name:N.name.trim(),run:Q2(N.command)})),k=await fetch(`${pe()}/verification/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({checks:v,base:((j=e.approval)==null?void 0:j.base)??"none",acknowledged:!0})}).catch(()=>{}),w=await(k==null?void 0:k.json().catch(()=>({})));if(k!=null&&k.ok)return d({kind:"saved"});d({kind:"error",text:(w==null?void 0:w.error)??"The server didn't answer."})};return i.jsxs("div",{className:"vf-editor",children:[t.map((v,k)=>i.jsxs("div",{className:"vf-edit-row",children:[i.jsx("input",{"aria-label":"Name",value:v.name,placeholder:"name",onChange:w=>h(k,{name:w.target.value})}),i.jsx("input",{"aria-label":"Command",className:"t-code",value:v.command,placeholder:"npm test",onChange:w=>h(k,{command:w.target.value})}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>s(t.filter((w,j)=>j!==k)),children:"Remove"})]},k)),i.jsxs("div",{className:"vf-edit-add",children:[f.map(v=>i.jsxs(M,{size:"sm",variant:"ghost",onClick:()=>s([...t,v]),children:["+ ",v.command]},v.name)),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>s([...t,{name:"",command:""}]),children:"+ Another"})]}),t.some(v=>!hp.some(k=>k.name===v.name))&&i.jsxs("p",{className:"vf-edit-hint t-meta",children:["Run from the repository's root, as words (no pipes or ",i.jsx("code",{children:"&&"}),"): the script must already be in the repo. For example ",i.jsx("code",{children:"npm run e2e"}),", ",i.jsx("code",{children:"make test"}),", ",i.jsx("code",{children:"./scripts/check.sh"})," ","or ",i.jsx("code",{children:"pytest -q"}),"."]}),i.jsxs("label",{className:"vf-edit-sure",children:[i.jsx("input",{type:"checkbox",checked:o,onChange:v=>a(v.target.checked)}),i.jsx("span",{children:"I know what these commands run, and approve them"})]}),i.jsxs("div",{className:"vf-edit-save",children:[i.jsx(M,{size:"sm",disabled:!o||l.kind==="saving",onClick:()=>void p(),children:l.kind==="saving"?"Saving…":"Save checks"}),l.kind==="saved"&&i.jsx("span",{className:"t-meta",children:"Saved and approved."}),l.kind==="error"&&i.jsx("span",{className:"vf-err",children:l.text})]})]})}function J2({config:e,file:t,hash:s}){return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line ok",title:s,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[i.jsx("span",{className:"t-code",children:t})," · ",e.run.length," checks run on every completion"]})]}),i.jsx(V,{className:"set-hint",parts:[`New trails start at ${ar[e.default]}`,`${e.maxAttempts} attempts before it waits for you`,e.failFast&&"Stops at the first failure"]}),i.jsx("div",{className:"vf-checks",children:Object.entries(e.checks).map(([o,a])=>i.jsxs("div",{className:"vf-check",children:[i.jsx("span",{className:"t-code",children:e.run.includes(o)?o:`${o} (on request)`}),i.jsx("code",{children:a.run.join(" ")}),i.jsxs("span",{className:"dim",children:[a.timeoutSec," s",a.cwd&&a.cwd!=="."?` · in ${a.cwd}`:""]})]},o))})]})}const X2=[{value:"flag",title:"Show the reviewer",sub:"The proof and the review list them first"},{value:"fail",title:"Send back",sub:"The agent reverts them or says why it needs them"},{value:"human",title:"Ask me",sub:"The ticket waits for you to decide"}];function Z2({view:e,local:t}){var h,f;const[s,o]=y.useState(),a=((h=e.config)==null?void 0:h.scope)??"flag",l=(f=e.approval)!=null&&f.waiting?"Approve the checks first.":void 0,d=async p=>{var w;o(void 0);const v=await fetch(`${pe()}/verification/scope`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:p,base:((w=e.approval)==null?void 0:w.base)??"none"})}).catch(()=>{});if(v!=null&&v.ok)return;const k=await(v==null?void 0:v.json().catch(()=>({})));o((k==null?void 0:k.error)??"The server didn't answer.")};return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"set-field-label",children:"Changes outside the files an agent declared"}),i.jsx("div",{className:"choice-row vf-levels",children:X2.map(p=>i.jsx(ot,{on:a===p.value,title:p.title,sub:p.sub,disabled:!t||!!l,onClick:()=>void d(p.value)},p.value))}),i.jsxs("span",{className:"set-hint t-meta",children:["Agents say which files they'll change when they claim a ticket. Anything they change beyond that is code nobody asked for.",l?` ${l}`:"",t===!1?" Set on the machine Teamtrail runs on.":""]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}function eE(e){var l;const{view:t,local:s,file:o}=e,a=t.config;return i.jsxs(i.Fragment,{children:[s&&i.jsx(Y2,{view:t},((l=t.approval)==null?void 0:l.base)??"none"),!s&&!t.exists&&i.jsx("span",{className:"set-hint t-meta",children:"No checks yet. They're set on the machine Teamtrail runs on."}),!s&&a&&t.exists&&i.jsx(J2,{config:a,file:o,hash:t.hash}),a&&t.exists&&i.jsx(Z2,{view:t,local:s})]})}function tE(e){var v;const t=G2(),s=$a(),[o,a]=y.useState();if(!t)return null;const l=e.map,d=t.config,h=`${Z.dataDir}/${t.file}`,f=(l==null?void 0:l.verification)??"off",p=(d??tg).appliesTo.join(" and ");return i.jsxs(Ee,{title:"Verification",children:[i.jsxs("p",{className:"vf-intro",children:["When an agent says a ticket is done, Teamtrail can check the work before the ticket closes. This applies to"," ",p," tickets. Research, junction and prototype tickets close as soon as they are answered."]}),l&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"set-field-label",children:["How much checking for trail ",l.key]}),i.jsx("div",{className:"choice-row vf-levels",children:Nd.map(k=>i.jsx(ot,{on:f===k,title:ar[k],sub:fv[k],onClick:()=>{a(void 0),fr.act({action:"level",mapId:l.id,level:k,by:St}).catch(w=>a(w.message))}},k))}),f!=="off"&&!d&&i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:"No working checks yet, so completions at this level stop and wait for you."})]}),o&&i.jsx("span",{className:"vf-err",children:o})]}),t.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",title:t.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[h," has errors. Completions that need checks wait for you until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:t.errors.map(k=>i.jsx("li",{children:k},k))})]}),((v=t.approval)==null?void 0:v.waiting)&&i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Its commands don't run on this machine until you approve them."," ",i.jsx("a",{href:tr(location.href,{group:"project",section:"approvals"}),children:"Review the commands"})]})]}),i.jsx(eE,{view:t,local:s,file:h}),i.jsxs("span",{className:"set-hint t-meta",children:["Saved here, checks are approved as you save them. A change to ",h," made in the repo, by an agent or a teammate, runs nothing until you approve it."]}),i.jsxs("span",{className:"set-hint t-meta",children:["Checks run on this machine as you, with no sandbox. Teamtrail passes them only the environment variables they need (more go in ",i.jsx("code",{children:"TEAMTRAIL_CHECK_ENV"}),"), but a check can still read your files (~/.aws, ~/.npmrc, ~/.ssh, ~/.kube, ~/.docker, the GitHub CLI's login, Teamtrail's own credentials) and use your SSH agent. That's why a changed check command needs your approval: you approve the command line, so read what it runs."]})]})}function nE({data:e}){const{map:t}=e;return i.jsxs(i.Fragment,{children:[t?i.jsx(Ke,{id:"mode",children:i.jsx(Ee,{title:`Trail ${t.key}`,children:i.jsx(T$,{value:t.mode,onChange:e.onMapMode})})}):i.jsx(Ie,{children:"Chart or pick a trail to set its mode, model matching and team."}),i.jsx(Ke,{id:"verification",storage:"repo",children:i.jsx(tE,{map:t})}),i.jsx(Ke,{id:"models",children:i.jsx(K2,{map:t,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching})}),t&&i.jsx(Ke,{id:"team",children:i.jsx(TT,{map:t})})]})}const fp=10,Qv=[0,10,16,26,18,24,16,18,22,22,26],Yv=[0,1,1,1,2,2,4,4,4,5,5];function Jv(e){let t=(16*e+128)*e+64;if(e<2)return t;const s=Math.floor(e/7)+2;return t-=(25*s-10)*s-55,e>=7?t-36:t}const sE=e=>Qv[e],iE=e=>Yv[e],Xv=e=>Math.floor(Jv(e)/8)-Qv[e]*Yv[e],Zv=e=>e<10?8:16;function rE(e){if(e===1)return[];const t=Math.floor(e/7)+2,s=e*4+17,o=Math.ceil((e*4+4)/(t*2-2))*2,a=[6];for(let l=s-7;a.length<t;l-=o)a.splice(1,0,l);return a}function kd(e,t){let s=0;for(let o=7;o>=0;o--)s=s<<1^(s>>>7)*285,s^=(t>>>o&1)*e;return s}function oE(e){const t=new Array(e).fill(0);t[e-1]=1;let s=1;for(let o=0;o<e;o++){for(let a=0;a<t.length;a++)t[a]=kd(t[a],s),a+1<t.length&&(t[a]^=t[a+1]);s=kd(s,2)}return t}function aE(e,t){const s=t.map(()=>0);for(const o of e){const a=o^s.shift();s.push(0),t.forEach((l,d)=>s[d]^=kd(l,a))}return s}function lE(e,t){const s=[],o=(d,h)=>{for(let f=h-1;f>=0;f--)s.push(d>>>f&1)};o(4,4),o(e.length,Zv(t));for(const d of e)o(d,8);const a=Xv(t)*8;o(0,Math.min(4,a-s.length)),o(0,(8-s.length%8)%8);for(let d=236;s.length<a;d^=253)o(d,8);const l=[];for(let d=0;d<s.length;d+=8)l.push(s.slice(d,d+8).reduce((h,f)=>h<<1|f,0));return l}function cE(e,t){const s=lE(e,t),o=iE(t),a=sE(t),l=Math.floor(Jv(t)/8),d=o-l%o,h=Math.floor(l/o),f=oE(a),p=[];for(let k=0,w=0;k<o;k++){const j=s.slice(w,w+h-a+(k<d?0:1));w+=j.length;const N=aE(j,f);k<d&&j.push(0),p.push([...j,...N])}const v=[];for(let k=0;k<p[0].length;k++)for(let w=0;w<p.length;w++)(k!==h-a||w>=d)&&v.push(p[w][k]);return v}const dE=[(e,t)=>(e+t)%2===0,(e,t)=>t%2===0,e=>e%3===0,(e,t)=>(e+t)%3===0,(e,t)=>(Math.floor(e/3)+Math.floor(t/2))%2===0,(e,t)=>e*t%2+e*t%3===0,(e,t)=>(e*t%2+e*t%3)%2===0,(e,t)=>((e+t)%2+e*t%3)%2===0];function Hc(e,t){const s=dE[t];for(let o=0;o<e.size;o++)for(let a=0;a<e.size;a++)!e.fixed[o][a]&&s(a,o)&&(e.dark[o][a]=!e.dark[o][a])}function mp(e){let t=0,s=1;for(let a=1;a<=e.length;a++)a<e.length&&e[a]===e[a-1]?s++:(s>=5&&(t+=s-2),s=1);const o=e.map(a=>a?"1":"0").join("");for(const a of["00001011101","10111010000"])for(let l=o.indexOf(a);l>=0;l=o.indexOf(a,l+1))t+=40;return t}function uE(e){let t=0,s=0;for(let a=0;a<e.size;a++)t+=mp(e.dark[a]),t+=mp(e.dark.map(l=>l[a]));for(let a=0;a<e.size;a++)for(let l=0;l<e.size;l++){if(e.dark[a][l]&&s++,l===e.size-1||a===e.size-1)continue;const d=e.dark[a][l];d===e.dark[a][l+1]&&d===e.dark[a+1][l]&&d===e.dark[a+1][l+1]&&(t+=3)}const o=e.size*e.size;return t+Math.floor(Math.abs(s*20-o*10)/o)*10}const an=(e,t)=>(e>>>t&1)!==0;function Nt(e,t,s,o){e.dark[s][t]=o,e.fixed[s][t]=!0}function Kc(e,t,s){for(let o=-4;o<=4;o++)for(let a=-4;a<=4;a++){const l=t+a,d=s+o,h=Math.max(Math.abs(a),Math.abs(o));l>=0&&l<e.size&&d>=0&&d<e.size&&Nt(e,l,d,h!==2&&h!==4)}}function hE(e,t,s){for(let o=-2;o<=2;o++)for(let a=-2;a<=2;a++)Nt(e,t+a,s+o,Math.max(Math.abs(a),Math.abs(o))!==1)}function yd(e,t){const s=0|t;let o=s;for(let l=0;l<10;l++)o=o<<1^(o>>>9)*1335;const a=(s<<10|o)^21522;for(let l=0;l<=5;l++)Nt(e,8,l,an(a,l));Nt(e,8,7,an(a,6)),Nt(e,8,8,an(a,7)),Nt(e,7,8,an(a,8));for(let l=9;l<15;l++)Nt(e,14-l,8,an(a,l));for(let l=0;l<8;l++)Nt(e,e.size-1-l,8,an(a,l));for(let l=8;l<15;l++)Nt(e,8,e.size-15+l,an(a,l));Nt(e,8,e.size-8,!0)}function fE(e,t){if(t<7)return;let s=t;for(let a=0;a<12;a++)s=s<<1^(s>>>11)*7973;const o=t<<12|s;for(let a=0;a<18;a++){const l=e.size-11+a%3,d=Math.floor(a/3);Nt(e,l,d,an(o,a)),Nt(e,d,l,an(o,a))}}function mE(e){const t=e*4+17,s=()=>Array.from({length:t},()=>new Array(t).fill(!1)),o={size:t,dark:s(),fixed:s()};for(let d=0;d<t;d++)Nt(o,6,d,d%2===0),Nt(o,d,6,d%2===0);Kc(o,3,3),Kc(o,t-4,3),Kc(o,3,t-4);const a=rE(e),l=a.length-1;for(let d=0;d<=l;d++)for(let h=0;h<=l;h++)d===0&&h===0||d===0&&h===l||d===l&&h===0||hE(o,a[d],a[h]);return yd(o,0),fE(o,e),o}function pE(e){const t=[];for(let s=e-1;s>=1;s-=2){const o=s<=6?s-1:s,a=(o+1&2)===0;for(let l=0;l<e;l++){const d=a?e-1-l:l;t.push([o,d],[o-1,d])}}return t}function gE(e,t){let s=0;for(const[o,a]of pE(e.size))e.fixed[a][o]||s>=t.length*8||(e.dark[a][o]=an(t[s>>>3],7-(s&7)),s++)}function vE(e){const t=new TextEncoder().encode(e);let s=1;for(;s<=fp&&4+Zv(s)+t.length*8>Xv(s)*8;)s++;if(s>fp)return;const o=mE(s);gE(o,cE(t,s));let a=0,l=1/0;for(let d=0;d<8;d++){Hc(o,d),yd(o,d);const h=uE(o);h<l&&([a,l]=[d,h]),Hc(o,d)}return Hc(o,a),yd(o,a),o.dark}const Vc=4;function kE(e){const t=vE(e.text);if(!t)return null;const s=t.length+Vc*2,o=t.flatMap((a,l)=>a.map((d,h)=>d?`M${h+Vc} ${l+Vc}h1v1h-1z`:"")).join("");return i.jsxs("svg",{className:"si-qr",viewBox:`0 0 ${s} ${s}`,role:"img","aria-label":e.label,shapeRendering:"crispEdges",children:[i.jsx("rect",{width:s,height:s,fill:"#fff"}),i.jsx("path",{d:o,fill:"#000"})]})}function yE(e){const t=Xt(1e3),s=Math.max(0,Math.ceil((e.device.expiresAt-t)/6e4)),o=e.device.links[0];return e.device.expiresAt<=t?i.jsxs("div",{className:"si-code",children:[i.jsx("p",{className:"t-meta",children:"That code expired. Make a new one when the device is ready."}),i.jsx(M,{size:"sm",onClick:e.onDone,children:"Done"})]}):i.jsxs("div",{className:"si-code",children:[o&&i.jsx(kE,{text:o,label:"QR code that pairs another device"}),i.jsxs("div",{className:"si-code-words",children:[i.jsx("span",{className:"si-code-value t-code","aria-label":"Pairing code",children:e.device.code}),i.jsx(V,{parts:["Works once",`expires in ${s} min`]}),i.jsxs("p",{className:"t-meta si-note",children:["Scan it with the device’s camera, or open"," ",o?i.jsx("code",{className:"t-code",children:o.split("#")[0]}):"the Lookout"," there and type the code."]}),i.jsx(M,{size:"sm",onClick:e.onDone,children:"Done"})]})]})}function wE(e){const[t,s]=y.useState();return e.device?i.jsx(yE,{device:e.device,onDone:e.onDone}):e.lan.length?i.jsxs("div",{className:"si-pair",children:[i.jsx(M,{onClick:async()=>s(await e.onPair()),children:"Pair a device"}),t&&i.jsx("span",{className:"vf-err",children:t})]}):i.jsxs("p",{className:"t-meta si-note",children:["This Lookout listens on this machine only, so no other device can reach it. To pair a phone or another computer, start it with ",i.jsxs("code",{className:"t-code",children:[Z.slug," --host 0.0.0.0"]})," on a network you trust. Another browser on this machine: run ",i.jsxs("code",{className:"t-code",children:[Z.slug," pair"]}),"."]})}function xE(e){const[t,s]=y.useState(!1),[o,a]=y.useState(!1),[l,d]=y.useState(),h=async()=>{a(!0),d(await e.onRevoke().catch(f=>f.message)),a(!1),s(!1)};return t?i.jsxs("span",{className:"ra-revoke ask",children:[i.jsx("span",{className:"t-meta",children:"It’s signed out now."}),i.jsxs(M,{size:"sm",disabled:o,onClick:h,children:["Revoke ",e.name]}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]}):i.jsxs("span",{className:"ra-revoke",children:[i.jsx(M,{size:"sm","aria-label":`Revoke ${e.name}`,onClick:()=>s(!0),children:"Revoke"}),l&&i.jsx("span",{className:"vf-err",children:l})]})}const jE={machine:"This machine",device:"Another device"};function SE(e){const t=Date.now();return i.jsx("ul",{className:"ra-list si-list",children:e.sessions.map(s=>i.jsx(be,{as:"li",className:"ra-row",title:s.current?`${s.name} · this browser`:s.name,titleText:s.name,context:i.jsx(V,{parts:[jE[s.kind],s.via==="opened-page"?`From the page ${Z.name} opened`:void 0,s.via==="opened-page"?{text:P0(s.id),code:!0}:void 0,`Paired ${Go(s.pairedAt,t)}`,`Last used ${Go(s.lastUsedAt,t)}`]}),below:s.current?void 0:i.jsx(xE,{name:s.name,onRevoke:()=>e.onRevoke(s.id)})},s.id))})}function NE(){return i.jsxs("div",{className:"ra-notes",children:[i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it stops."})," A program on this machine, or a device on your network, that isn’t a paired browser: an agent with ",i.jsx("code",{children:"curl"})," can’t approve its own work, answer its own questions or change your settings through the Lookout. The session lives only in this page’s own storage and is sent only by this page, never as a cookie, so another server on this machine (an agent’s dev server on another port) gets nothing from your browser; and it goes only to a server that first proves it is this Lookout, so one that takes its port while the Lookout is stopped gets nothing either. A device paired here can read, answer and approve, but never change what runs on this machine or whom it trusts."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it can’t stop."})," A program that can read ",Z.name,"’s config folder can make a pairing code, and one that can read your browser’s profile on disk can copy a session. Keep agents out of both:"," ",i.jsxs("code",{children:[Z.slug," connect"]})," sets that up for the agents it registers."]})]})}const ek=`${Z.apiPrefix}/sign-in`;async function Gc(e,t={}){const s=await fetch(`${ek}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:s.ok,reply:await s.json().catch(()=>({}))}}function bE(){const[e,t]=y.useState(),[s,o]=y.useState(),a=y.useCallback(()=>{fetch(`${ek}/sessions`).then(async f=>f.ok?await f.json():(await f.json().catch(()=>({}))).elsewhere?"elsewhere":null).then(t,()=>t(null))},[]);y.useEffect(a,[a]);const l=y.useCallback(async()=>{const{ok:f,reply:p}=await Gc("/codes");if(!f)return p.error??"No code could be made.";o(p)},[]),d=y.useCallback(async f=>{const{ok:p,reply:v}=await Gc("/revoke",{id:f});return a(),p?void 0:v.error??"That browser could not be revoked."},[a]),h=y.useCallback(async()=>{await Gc("/sign-out"),Fg(),location.reload()},[]);return{view:e,device:s,closeDevice:()=>(o(void 0),a()),pairDevice:l,revoke:d,signOut:h}}function $E(){const{view:e,device:t,closeDevice:s,pairDevice:o,revoke:a,signOut:l}=bE();if(!e)return null;const d=i.jsx("div",{className:"si-signout",children:i.jsx(M,{size:"sm",variant:"ghost",onClick:l,children:"Sign out of this browser"})});return e==="elsewhere"?i.jsxs(Ee,{title:"Browsers & devices",children:[i.jsx("p",{className:"vf-intro",children:"This device is paired with the Lookout. Browsers and devices are paired and revoked on the machine it runs on."}),d]}):i.jsxs(Ee,{title:"Browsers & devices",children:[i.jsx("p",{className:"vf-intro",children:"Every browser that opens this Lookout is paired, and stays signed in while it runs (up to 30 days after it was last used). Revoke one and it’s signed out at once. When the Lookout restarts, browsers and devices pair again: the link is in the terminal where it starts."}),i.jsx(SE,{sessions:e.sessions,onRevoke:a}),i.jsx(wE,{lan:e.lan,device:t,onPair:o,onDone:s}),d,i.jsx(NE,{})]})}function CE({managed:e}){const{signOut:t,pages:s}=e;return i.jsxs(Ee,{title:"Signed in",children:[i.jsxs("p",{className:"vf-intro",children:["Signed in as ",e.name,". Sign-in is managed by the server this Lookout runs on."]}),s.length||e.home?i.jsxs("div",{className:"choice-row",children:[e.home&&i.jsxs(M,{size:"sm",onClick:()=>location.assign(e.home.href),children:["← ",e.home.label]}),s.map(o=>i.jsx(M,{size:"sm",onClick:()=>location.assign(o.href),children:o.label},o.href))]}):null,t?i.jsx("div",{className:"si-signout",children:i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>location.assign(t),children:"Sign out"})}):null]})}function TE(){return y.useEffect(()=>{const e=setInterval(()=>void ga().then(t=>t!=="failed"&&location.reload()),3e3);return()=>clearInterval(e)},[]),i.jsx("div",{className:"pair-page",children:i.jsxs(Be,{as:"main",className:"pair-card",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(xa,{className:"onb-title"})}),i.jsxs("h1",{className:"t-heading pair-title",children:[Z.name," isn’t running here"]}),i.jsxs("p",{className:"t-body pair-step",children:["Start it with ",i.jsx("code",{className:"t-code",children:Z.slug})," on the machine it runs on. This page reconnects once the Lookout answers as itself; until then it sends nothing to this address."]})]})})}async function Jd(e){const t=await fetch(`${Z.apiPrefix}/pair`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e})}).catch(()=>{});if(!t)return"The Lookout didn’t answer. Try again.";const s=await t.json().catch(()=>({}));if(!t.ok)return s.error??"That code didn’t work. Get a new one.";s.id&&s.session&&s.verifier&&L1({id:s.id,secret:s.session,verifier:s.verifier})}function EE(e){const[t,s]=y.useState(!1),o=async()=>{s(!0);const a=await Jd(e.code);if(!a)return location.reload();s(!1),e.onFailed(a)};return i.jsxs("div",{className:"pair-confirm",children:[i.jsxs("p",{className:"t-body pair-step",children:["This link signs this browser in to the Lookout. Use it only if it came to you from"," ",i.jsx("code",{className:"t-code",children:Z.slug}),", ",i.jsxs("code",{className:"t-code",children:[Z.slug," pair"]})," or Pair a device in the Lookout’s Settings."]}),i.jsx("div",{children:i.jsx(M,{variant:"primary",disabled:t,onClick:o,children:"Sign in this browser"})})]})}function pp(){const[e,t]=y.useState(""),[s,o]=y.useState(!1),[a,l]=y.useState(),d=async()=>{if(!e.trim()||s)return;o(!0);const h=await Jd(e);o(!1),l(h),h||location.reload()};return i.jsxs("form",{className:"pair-device",onSubmit:h=>{h.preventDefault(),d()},children:[i.jsxs("p",{className:"t-body pair-step",children:["On a phone or another computer: in the Lookout on the machine ",Z.name," runs on, open Settings → You → Browsers & devices → Pair a device. Then type the code here, or scan it with this device’s camera."]}),i.jsxs("div",{className:"pair-code-row",children:[i.jsx("input",{className:"pair-code-input t-code",value:e,onChange:h=>t(h.target.value),placeholder:"ABCD-EFGH","aria-label":"Pairing code",autoComplete:"one-time-code",autoCapitalize:"characters",spellCheck:!1,maxLength:20}),i.jsx(M,{type:"submit",variant:"primary",disabled:s||!e.trim(),children:"Pair"})]}),a&&i.jsx("p",{className:"vf-err",role:"alert",children:a})]})}function gp(){return i.jsxs("p",{className:"t-body pair-step pair-here",children:["On the machine ",Z.name," runs on, run ",i.jsxs("code",{className:"t-code",children:[Z.slug," pair"]}),": it opens a tab ready to sign in, with one click. Or open the Sign in link ",i.jsx("code",{className:"t-code",children:Z.slug})," printed in its terminal."]})}function AE(e){return i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"t-body pair-step",children:"The Lookout opens only in browsers you’ve paired."}),e.local?i.jsx(gp,{}):i.jsx(pp,{}),e.local?i.jsx(pp,{}):i.jsx(gp,{})]})}function IE(e){const[t,s]=y.useState(),[o,a]=y.useState(e.code),[l,d]=y.useState(e.code);e.code!==l&&(d(e.code),a(e.code));const h=f=>(s(f),a(void 0));return i.jsx("div",{className:"pair-page",children:i.jsxs(Be,{as:"main",className:"pair-card",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(xa,{className:"onb-title"})}),i.jsx("h1",{className:"t-heading pair-title",children:"Pair this browser"}),t&&i.jsx("p",{className:"pair-problem t-body",role:"alert",children:t}),o?i.jsx(EE,{code:o,onFailed:h}):i.jsx(AE,{local:e.local})]})})}function vp(){const e=/(?:^#|&)pair=([A-Za-z0-9_-]{1,64})/.exec(location.hash);if(e)return history.replaceState(null,"",`${location.pathname}${location.search}`),e[1]}async function kp(){try{const e=await fetch(`${Z.apiPrefix}/session`,{cache:"no-store"});if(!e.ok)return{kind:"no-server"};const t=await e.json();return typeof t.signedIn!="boolean"?{kind:"no-server"}:t.signedIn&&C1(t)?{kind:"signed-in"}:{kind:"signed-out",local:t.local===!0}}catch{return{kind:"no-server"}}}async function RE(){if(!Ld())return kp();const e=await ga();return e==="proven"?{kind:"signed-in"}:e==="unknown"?kp():{kind:"not-running"}}function ME(){const[e,t]=y.useState({kind:"checking"});return y.useEffect(()=>void RE().then(t),[]),y.useEffect(()=>O1(s=>s==="failed"&&t({kind:"not-running"})),[]),e}function LE({children:e}){const t=ME(),[s,o]=y.useState(vp);return y.useEffect(()=>{const a=()=>o(l=>vp()??l);return window.addEventListener("hashchange",a),()=>window.removeEventListener("hashchange",a)},[]),y.useEffect(()=>{t.kind==="signed-in"&&s&&Jd(s)},[t.kind,s]),t.kind==="checking"?null:t.kind==="signed-out"?i.jsx(IE,{local:t.local,code:s}):t.kind==="not-running"?i.jsx(TE,{}):i.jsx(i.Fragment,{children:e})}function OE(){const e=ft();return e?i.jsx(CE,{managed:e}):i.jsx(Ke,{id:"devices",storage:"machine",children:i.jsx($E,{})})}const PE=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function _E(e){return i.jsx("div",{className:"choice-row compact",children:PE.map(t=>i.jsx(ot,{on:e.value===t.value,title:t.title,onClick:()=>e.onChange(t.value)},t.value))})}function DE({data:e}){var o;const{prefs:t,update:s}=e;return i.jsxs(i.Fragment,{children:[i.jsx(Ke,{id:"appearance",storage:"browser",children:i.jsxs(Ee,{title:"Appearance",children:[Yg()?i.jsx("p",{className:"vf-intro",children:"Follows the theme you picked in your account on the server. Change it from your name in its menu."}):i.jsx(_E,{value:Jg(t.theme),onChange:a=>s({theme:a})}),((o=ft())==null?void 0:o.themeSave)&&i.jsx("p",{className:"vf-intro",children:"Saved to your account, so the server's pages follow it."})]})}),i.jsx(Ke,{id:"transcript",storage:"browser",children:i.jsx(Ee,{title:"HITL transcript",children:i.jsx(jv,{value:t.hitlTranscript,onChange:a=>s({hitlTranscript:a})})})}),i.jsx(Ke,{id:"agent",children:i.jsx(Ee,{title:"Agent",children:i.jsx("div",{className:"choice-row",children:Tg.map(a=>i.jsx(ot,{on:a.status==="primary",disabled:a.status!=="primary",title:a.name},a.id))})})}),i.jsx(OE,{})]})}function zE(e){const{data:t,route:s}=e;switch(e.group){case"trail":return i.jsx(nE,{data:t});case"project":return i.jsx(c2,{data:t,route:s});case"alerts":return i.jsx(DC,{data:t,route:s});case"you":return i.jsx(DE,{data:t});case"projects":return i.jsx(Ke,{id:"projects",storage:"machine",children:i.jsx(C2,{})});case"about":return i.jsx(Ke,{id:"changelog",children:i.jsx(HC,{})});default:return e.group}}function BE(e){const{group:t,route:s}=e,o=y.useRef(null),a=y.useRef(null);return y.useEffect(()=>{var d,h;(d=o.current)==null||d.focus({preventScroll:!0});const l=s.section&&document.getElementById(`settings-${s.section}`);l?l.scrollIntoView({block:"start"}):(h=a.current)==null||h.scrollTo({top:0})},[t.id,s.section]),i.jsx("div",{className:"sp-pane",ref:a,children:i.jsxs("div",{className:"sp-pane-in",children:[i.jsxs("header",{className:"sp-pane-head",children:[i.jsx("h2",{className:"sp-title t-title",ref:o,tabIndex:-1,children:t.label}),i.jsx("p",{className:"sp-intro t-meta",children:t.intro})]}),i.jsx(zE,{group:t.id,data:e.data,route:s})]})})}function FE(e){return i.jsx("nav",{className:"sp-nav","aria-label":"Settings groups",children:i.jsx("ul",{children:lr.map(t=>{const s=t.id===e.current;return i.jsx(be,{as:"li",className:"sp-nav-row",selected:s,current:s?"page":void 0,title:t.label,context:i.jsx(V,{parts:t.sections.map(o=>o.title)}),trailing:e.drill&&"›",onOpen:()=>e.onPick(t.id)},t.id)})})})}function UE(e,t){return e.group?lr.find(s=>s.id===e.group):t==="mobile"?void 0:lr[0]}const WE={page:"Back to the Lookout",list:"Lookout",group:"Settings"},HE=(e,t)=>e?t?"group":"list":"page";function KE(e){const{bp:t,route:s}=e,o=t==="mobile",a=UE(s,t),l=HE(o,!!a),d=$a()===!1,h=()=>l==="group"?e.onShow({}):e.onClose();y.useEffect(()=>{const v=k=>{k.key!=="Escape"||k.defaultPrevented||document.querySelector(".scrim")||(l==="group"?e.onShow({}):e.onClose())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[l,e]);const f=v=>e.onShow({group:v}),p=l!=="group"&&i.jsx(FE,{current:a==null?void 0:a.id,onPick:f,drill:o});return i.jsxs(Be,{className:`zone decisions-view settings-page sp-${t}`,"aria-label":"Settings",children:[i.jsxs("header",{className:"dv-head",children:[i.jsxs("button",{className:"back",onClick:h,children:["‹ ",WE[l]]}),l!=="group"&&i.jsx(ze,{as:"h2",children:"Settings"}),!o&&i.jsx("span",{className:"dv-head-right t-meta",children:"Esc"})]}),d&&i.jsx($C,{}),i.jsxs("div",{className:"sp-body",children:[p,a&&i.jsx(BE,{group:a,data:e.data,route:s})]})]})}function VE(e){var a;const{rt:t,api:s,settings:o}=e;return o.route?i.jsx(KE,{bp:e.bp,route:o.route,onShow:o.show,onClose:o.close,data:{prefs:e.prefs,update:e.update,activeTracker:t.kind,location:t.adapter.location,map:(a=s.snap)==null?void 0:a.map,onMapMode:s.actions.setMode,snaps:Object.values(s.allSnaps),answered:s.activity.answered,onModelMatching:s.actions.setModelMatching}}):null}function GE(e){return i.jsxs(Be,{className:"zone side",style:{gridArea:"inspector"},children:[i.jsx(wN,{className:"zone-tabs",value:e.tab,onChange:e.onTab,items:[{id:"ticket",label:"Ticket"},{id:"activity",label:"Activity"},{id:"plan",label:"Plan",n:e.unspecified}]}),{ticket:e.ticket,activity:e.activity,plan:e.plan}[e.tab]]})}function tk(e){return e.filter(t=>t.state!=="out-of-scope").map(t=>({x:t.x,y:t.y,w:Ve,h:Qe}))}function qE(e){const{obstacles:t,from:s,to:o,clear:a}=e,l=t.flatMap(h=>[h.y-28,h.y+h.h+28]).filter(a),d=h=>Math.abs(h-s)+Math.abs(h-o);return l.reduce((h,f)=>d(f)<d(h)?f:h,l[0]??s)}const QE=6;function YE(e){const t=e.filter((a,l)=>l===0||a.x!==e[l-1].x||a.y!==e[l-1].y);let s=`M${t[0].x} ${t[0].y}`;for(let a=1;a<t.length-1;a++){const[l,d,h]=[t[a-1],t[a],t[a+1]],f=Math.min(QE,yp(l,d)/2,yp(d,h)/2),p=wp(d,l,f),v=wp(d,h,f);s+=`L${p.x} ${p.y}Q${d.x} ${d.y} ${v.x} ${v.y}`}const o=t[t.length-1];return`${s}L${o.x} ${o.y}`}function yp(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function wp(e,t,s){return{x:e.x+Math.sign(t.x-e.x)*s,y:e.y+Math.sign(t.y-e.y)*s}}function Jo(e){const t=e.direction==="TB",s=d=>t?{x:d.y,y:d.x}:d,o=s(e.a),a=s(e.b),l=e.obstacles.map(d=>t?{x:d.y,y:d.x,w:d.h,h:d.w}:d);return YE(JE({a:o,b:a,obstacles:l,gap:e.gap}).map(s))}function JE({a:e,b:t,obstacles:s,gap:o}){const a=s.filter(p=>p.x+p.w>e.x+1&&p.x<t.x-1),l=p=>!a.some(v=>p>v.y-8&&p<v.y+v.h+8),d=Math.min(e.x+o/2,(e.x+t.x)/2),h=Math.max(t.x-o/2,(e.x+t.x)/2);if(l(e.y))return[e,{x:h,y:e.y},{x:h,y:t.y},t];if(l(t.y))return[e,{x:d,y:e.y},{x:d,y:t.y},t];const f=qE({obstacles:a,from:e.y,to:t.y,clear:l});return[e,{x:d,y:e.y},{x:d,y:f},{x:h,y:f},{x:h,y:t.y},t]}function XE(e){if(e.direction==="LR"){const s=e.width+96;return{x:s,y:e.graphH/2,right:s+34,bottom:e.height}}const t=e.graphH+76;return{x:e.width/2,y:t,right:e.width,bottom:Math.max(e.height,t+40)}}function ZE(e,t){const s=new Set(e.edges.map(l=>l.from)),o=e.nodes.filter(l=>l.state!=="out-of-scope"&&!s.has(l)),a=tk(e.nodes);return o.map(l=>{if(e.direction==="LR"){const f={x:l.x+Ve,y:l.y+Qe/2},p={x:t.x-30,y:t.y};return Jo({direction:"LR",a:f,b:p,obstacles:a,gap:96})}const d={x:l.x+Ve/2,y:l.y+Qe},h={x:t.x,y:t.y-30};return Jo({direction:"TB",a:d,b:h,obstacles:a,gap:48})})}function eA({x:e,y:t,text:s}){const o=s!=null&&s.trim()?`Destination
|
|
155
155
|
${s.trim()}`:`Destination
|
|
156
|
-
Where this trail ends`;return i.jsxs("g",{className:"destination",transform:`translate(${e} ${t})`,"aria-label":o,"data-tip":o,tabIndex:0,children:[i.jsx("rect",{className:"x-hit",x:-24,y:-24,width:48,height:48}),i.jsx("path",{className:"x-stroke",d:"M-15 -16 C-9 -10 2 4 16 17"}),i.jsx("path",{className:"x-stroke",d:"M17 -15 C8 -8 -6 5 -16 17"})]})}function tA({trails:e}){return e.map(t=>i.jsx("path",{className:"edge edge-open edge-destination",d:t},t))}function nA(){return i.jsxs("defs",{children:[i.jsx("pattern",{id:"map-grid",width:"40",height:"40",patternUnits:"userSpaceOnUse",children:i.jsx("path",{d:"M40 0H0V40",fill:"none",stroke:"var(--map-grid)",strokeWidth:"1"})}),i.jsx("pattern",{id:"hatch-oos",width:"10",height:"10",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:i.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"10",stroke:"var(--line2)",strokeWidth:"1"})})]})}const Xo=(e,t)=>`${e}>${t}`;function sA(e,t,s=[]){const o=new Map(e.tickets.map(l=>[l.id,l]));return{tickets:t.nodes.map(l=>{const d=o.get(l.id);return d?{...d,blockedBy:[...l.blockedBy,...l.removedEdges??[]]}:{id:l.id,key:"+",title:l.title,type:l.type,body:"",state:"open",blockedBy:l.blockedBy,comments:[],createdAt:e.map.updatedAt,updatedAt:e.map.updatedAt}}),marks:new Map(t.nodes.map(l=>[l.id,l.mark])),newEdges:new Set(t.nodes.flatMap(l=>l.newEdges.map(d=>Xo(d,l.id)))),removedEdges:new Set(t.nodes.flatMap(l=>(l.removedEdges??[]).map(d=>Xo(d,l.id)))),frozen:new Set(s)}}function iA(e,t){const s=Xx({...e,tickets:t}),o=new Set;for(let a=1;a<s.length;a++)o.add(Xo(s[a-1].id,s[a].id));return o}const xp={LR:130,TB:68};function rA(e){const{direction:t,from:s,to:o,cards:a}=e;if(t==="LR"){const h={x:s.x+Ve,y:s.y+Qe/2},f={x:o.x,y:o.y+Qe/2};return Jo({direction:t,a:h,b:f,obstacles:a,gap:xp.LR})}const l={x:s.x+Ve/2,y:s.y+Qe},d={x:o.x+Ve/2,y:o.y};return Jo({direction:t,a:l,b:d,obstacles:a,gap:xp.TB})}function oA(e){const{from:t,to:s,direction:o}=e,l=["edge",t.ticket.state!=="open"?"edge-done":"edge-open"];return e.critical&&l.push("edge-critical"),e.added&&l.push("edge-added"),e.removed&&l.push("edge-removed"),i.jsx("path",{className:l.join(" "),d:rA({direction:o,from:t,to:s,cards:e.cards})})}function aA(e){const{snap:t,tickets:s,direction:o,preview:a}=e,l=y.useMemo(()=>iA(t,s),[t,s]),d=y.useMemo(()=>tk(e.nodes),[e.nodes]);return e.edges.map(({from:h,to:f})=>{const p=Xo(h.ticket.id,f.ticket.id);return i.jsx(oA,{from:h,to:f,direction:o,cards:d,critical:l.has(p),added:a==null?void 0:a.newEdges.has(p),removed:a==null?void 0:a.removedEdges.has(p)},p)})}const Xd=24,lA=13,cA=9.5;function dA(e){const t=e.guide;return i.jsx("g",{className:"meta",transform:`translate(${Xd} ${e.y})`,children:e.chips.map((s,o)=>{const a=s.kind==="guide"?t:void 0;return i.jsxs("g",{className:Ge("card-chip",s.kind,s.kind==="state"&&e.tone,(a==null?void 0:a.off)&&"off"),"data-guide-id":a==null?void 0:a.id,transform:`translate(${s.x} 0)`,children:[a&&i.jsx("title",{children:a.tip}),i.jsx("rect",{width:s.w,height:lA,rx:3}),i.jsx("text",{x:(s.w-s.textW)/2,y:cA,textLength:s.textW,lengthAdjust:"spacingAndGlyphs",children:s.text})]},o)})})}const nk=5,uA={sans:"9.5px 'Figtree Variable', system-ui, sans-serif",mono:"8.55px 'JetBrains Mono Variable', ui-monospace, monospace"};let Zi;function hA(){if(Zi!==void 0)return Zi;try{Zi=typeof document>"u"?null:document.createElement("canvas").getContext("2d")}catch{Zi=null}return Zi}function fA(e,t="sans"){const s=hA();return s?(s.font=uA[t],s.measureText(e).width*1.04):e.length*nk}const jp=4,Sp=3,mA=6;function pA(e){var v;const t=Ve-Xd-8-(e.reserve??0),s=((v=e.state)==null?void 0:v.split(" · "))??[],o=[{kind:"key",text:e.key},{kind:"type",text:e.type},...e.guide===void 0?[]:[{kind:"guide",text:e.guide}],...s.map(w=>({kind:"state",text:w})),...e.needsYou?[{kind:"needs",text:"needs you"}]:[]],a=t-o.length*2*jp-(o.length-1)*Sp,l=w=>fA(w.text,w.kind==="key"?"mono":"sans"),d=o.filter(w=>w.kind!=="guide").reduce((w,j)=>w+l(j),0),h=Math.max(mA,Math.floor((a-d)/nk)),f=o.map(w=>w.kind==="guide"?{...w,text:hT(w.text,h)}:w),p=Math.min(1,a/f.reduce((w,j)=>w+l(j),0));let k=0;return f.map(w=>{const j=l(w)*p,N={...w,x:k,w:j+2*jp,textW:j};return k+=N.w+Sp,N})}function gA(e,t,s){const o=e.state==="frontier"||e.state==="rework";if(!(!t||s||e.ticket.assignee||!o))return t}function vA(e){const t=["node",`st-${e.n.state}`,`tone-${e.tone}`,e.hitl?"hitl":"afk"];return e.selected&&t.push("sel"),e.live&&t.push("live"),e.waiting&&t.push("waiting"),e.stalled&&!e.waiting&&t.push("stalled"),e.mark&&t.push(`mark-${e.mark}`),e.frozen&&t.push("frozen"),t.join(" ")}function kA({wait:e,session:t}){return e?i.jsx("title",{children:`Needs a ${e} model: no connected agent runs one`}):t?i.jsx("title",{children:`${t.agent} · step ${t.step}/${t.total} · ${t.stepLabel.toLowerCase()}`}):null}const yA={claimed:"working",verifying:"working",frontier:"ready",blocked:"backlog",parked:"backlog",decided:"done","out-of-scope":"cancelled",rework:"attention",held:"attention"};function wA(e){const t=yA[e.state];return t==="done"||t==="cancelled"?t:e.attention?"attention":e.live?"working":t}function xA({mark:e,frozen:t}){const s=e&&e!=="unchanged"&&e!=="cancelled"?e:void 0;return i.jsxs(i.Fragment,{children:[e==="cancelled"&&i.jsx("line",{className:"strike",x1:8,y1:Qe/2,x2:Ve-8,y2:Qe/2}),s&&i.jsx("text",{className:"reroute-tag",x:Ve-8,y:Qe-7,textAnchor:"end",children:s}),t&&i.jsx("text",{className:"freeze",x:Ve-(s?58:8),y:Qe-7,textAnchor:"end",children:"❄"})]})}function jA(e){const{n:t,session:s}=e,o=t.ticket.assignee;return e.waiting?{text:"waiting on you",tone:"urgent"}:e.stalled?{text:`stalled · ${o}`,tone:"warn"}:e.wait?{text:`needs ${e.wait}`,tone:"warn"}:s&&e.step?{text:`${s.agent} · step ${s.step}/${s.total}`,tone:"agent"}:s?{text:s.agent,tone:"agent"}:t.state==="claimed"?{text:o??"working",tone:"agent"}:t.state==="verifying"?{text:"checks running",tone:"agent"}:t.state==="decided"&&e.verified?{text:"verified",tone:"verified"}:{text:g1[t.state],tone:""}}function sk({tone:e,cy:t,verified:s}){return e==="done"?i.jsx("path",{className:`dot dot-done${s?" dot-verified":""}`,d:`M10 ${t}l2.5 2.5 4.5 -5`}):i.jsx("circle",{className:`dot dot-${e}`,cx:13,cy:t,r:e==="backlog"?3:3.5})}function SA(e,t,s=2){const o=e.split(/\s+/),a=[];let l="";for(const d of o)(l+" "+d).trim().length>t?(a.push(l.trim()),l=d):l+=" "+d;if(a.push(l.trim()),a.length>s){const d=a.slice(0,s);return d[s-1]=d[s-1].slice(0,t-1)+"…",d}return a}const NA=26;function bA({n:e,session:t,stalled:s,flag:o,selected:a,onSelect:l,mark:d,frozen:h,needs:f,verified:p}){const k=e.ticket,v=SA(k.title,NA),w=cr(k)==="hitl",j=!!(t!=null&&t.waitingOn),N=!!d&&d!=="unchanged",S=gA(e,f,!!t),I=LT(k.guide),$=N?void 0:jA({n:e,session:t,waiting:j,stalled:s,wait:S,step:!I,verified:p}),_=w&&!N&&(k.type==="task"||k.type==="execute"),O=j||!!s||!!S||_&&e.state==="frontier",D=wA({state:e.state,live:!!t,attention:O}),q=Zs[k.type],H=(N&&d!=="cancelled"?44:0)+(h?12:0),G=pA({key:k.key,type:q,guide:I==null?void 0:I.name,state:$==null?void 0:$.text,needsYou:_,reserve:H}),oe=v.length>1?19:24;return i.jsxs("g",{className:vA({n:e,tone:D,hitl:w,selected:a,live:!!t,waiting:j,stalled:s,mark:d,frozen:h}),style:{transform:`translate(${e.x}px, ${e.y}px)`},onClick:Q=>{Q.stopPropagation(),l({kind:"ticket",id:k.id})},children:[i.jsx(kA,{wait:S,session:t}),i.jsx("rect",{className:"ring",x:-3.5,y:-3.5,width:Ve+7,height:Qe+7,rx:9}),i.jsx("rect",{className:"card",x:.5,y:.5,width:Ve-1,height:Qe-1,rx:6}),i.jsx(sk,{tone:D,cy:oe-4,verified:p}),v.map((Q,ke)=>i.jsx("text",{className:"title",x:Xd,y:oe+ke*14,children:Q},ke)),i.jsx(dA,{chips:G,y:oe+v.length*14-8,tone:$==null?void 0:$.tone,guide:I}),o&&i.jsx("circle",{className:`pr-flag-dot ${o}`,cx:Ve-2,cy:2,r:4}),i.jsx(xA,{mark:d,frozen:h})]})}const $A=[{tone:"working",text:"An agent is on it"},{tone:"attention",text:"Waits on you, or held up"},{tone:"ready",text:"Ready for an agent"},{tone:"backlog",text:"Not ready yet"},{tone:"done",verified:!0,text:"Done and verified"},{tone:"done",text:"Done, not verified"},{tone:"cancelled",text:"Ruled out"}];function CA(){const[e,t]=y.useState(!1);return i.jsxs("div",{className:"map-legend",onPointerDown:s=>s.stopPropagation(),onClick:s=>s.stopPropagation(),children:[e&&i.jsx("ul",{className:"map-legend-list",children:$A.map(s=>i.jsxs("li",{children:[i.jsx("svg",{className:"node",width:"22",height:"16",viewBox:"4 0 18 16","aria-hidden":"true",children:i.jsx(sk,{tone:s.tone,cy:8,verified:s.verified})}),s.text]},s.text))}),i.jsx("button",{type:"button",className:"btn sm","aria-expanded":e,onClick:()=>t(!e),children:e?"Hide legend":"Legend"})]})}const Np=.72;function TA(e){const{fit:t,nodes:s,size:o,pad:a}=e;if(t.k>=Np)return t;const l=s.find(h=>h.state==="claimed")??s.find(h=>h.state==="frontier")??s[0];if(!l)return t;const d=Np;return{k:d,x:o.w/2-(l.x+a+Ve/2)*d,y:o.h/2-(l.y+a+Qe/2)*d}}function EA(e){const{y:t,width:s,height:o}=e,a=e.nodes.filter(l=>l.state==="out-of-scope").length;return a?i.jsxs("g",{className:"quarantine",children:[i.jsx("rect",{x:-20,y:t-30,width:s+40,height:o+18,fill:"url(#hatch-oos)"}),i.jsx("line",{x1:-20,y1:t-30,x2:s+20,y2:t-30}),i.jsxs("text",{x:-12,y:t-12,children:["Out of scope · ",a]})]}):null}const st=280,bp=4,AA=220,Vs=e=>Math.round(e/bp)*bp;function IA(e){let t=2166136261;for(const s of e)t=Math.imul(t^s.charCodeAt(0),16777619);return()=>{t=t+1831565813|0;let s=Math.imul(t^t>>>15,1|t);return s=s+Math.imul(s^s>>>7,61|s)^s,((s^s>>>14)>>>0)/4294967296}}function qc(e,t,s,o){return Array.from({length:6},()=>{const a=o*(.5+e()*.7),l=o*(.3+e()*.4);return{x:Vs(t+(e()-.5)*o*.8-a/2),y:Vs(s+(e()-.5)*o*.5-l/2),w:Vs(a),h:Vs(l)}})}function RA(e){const{width:t,height:s,nodes:o}=e,a=IA(e.seed),l=(w,j)=>w+a()*(j-w),d=(w,j)=>!o.some(N=>w>N.x-52&&w<N.x+Ve+28&&j>N.y-52&&j<N.y+Qe+28),h=(t+st*2)*(s+st*2),f=Array.from({length:Math.round(h/9e4)},()=>qc(a,l(-st,t+st),l(-st,s+st),l(160,360))).flat(),p=[...qc(a,t+st*.55,s+st*.55,300),...qc(a,-st*.5,-st*.45,220)],k=[],v=(w,j,N)=>{k.length<AA&&d(j,N)&&k.push({sprite:w,x:Vs(j),y:Vs(N)})};for(let w=0;w<Math.round(h/3e4);w++){const j=l(-st,t+st),N=l(-st,s+st),S=3+Math.floor(a()*5);for(let I=0;I<S;I++)v(a()<.65?"pine":"oak",j+l(-70,70),N+l(-44,44))}for(let w=0;w<Math.round(h/45e3);w++)v(a()<.4?"rock":"tuft",l(-st,t+st),l(-st,s+st));return k.sort((w,j)=>w.y-j.y),{grass:f,water:p,items:k}}const ik={pine:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"16",y:"30",width:"4",height:"10",fill:"var(--map-trunk)"}),i.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H0l9-11H5l8-10H9z",fill:"var(--map-pine)"}),i.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H18z",fill:"var(--map-pine2)"})]}),oak:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"16",y:"24",width:"4",height:"12",fill:"var(--map-trunk)"}),i.jsx("circle",{cx:"18",cy:"14",r:"14",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"10",cy:"17",r:"8",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"26",cy:"17",r:"8",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"22",cy:"10",r:"6",fill:"var(--map-oak2)"})]}),rock:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M1 16Q2 6 10 3Q18-1 23 6Q28 11 27 16z",fill:"var(--map-rock)"}),i.jsx("path",{d:"M15 16Q15 8 19 4Q25 8 27 16z",fill:"var(--map-rock2)"})]}),tuft:i.jsx("path",{d:"M4 8Q3 4 1 1M14 8Q14 3 14 0M24 8Q25 4 27 1",fill:"none",stroke:"var(--map-pine2)",strokeWidth:"2.5",strokeLinecap:"round"})};function MA({name:e}){return i.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:ik[e]})}const LA=Object.keys(ik),OA=y.memo(function(t){const{seed:s,width:o,height:a,nodes:l}=t,d=y.useMemo(()=>RA({seed:s,width:o,height:a,nodes:l}),[s,o,a,l]);return i.jsxs("g",{className:"terrain","aria-hidden":"true",children:[i.jsx("defs",{children:LA.map(h=>i.jsx(MA,{name:h},h))}),d.grass.map((h,f)=>i.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-grass)"},f)),d.water.map((h,f)=>i.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-water)"},f)),i.jsx("rect",{x:-4e3,y:-4e3,width:o+8e3,height:a+8e3,fill:"url(#map-grid)"}),d.items.map((h,f)=>i.jsx("use",{href:`#terrain-${h.sprite}`,x:h.x,y:h.y},f))]})}),PA=380;function _A(e){const{selId:t,size:s}=e,o=y.useRef(e);o.current=e;const a=y.useRef(!0);y.useEffect(()=>{if(a.current){a.current=!1;return}const{nodes:l,pad:d,view:h,setView:f,onFocus:p}=o.current,k=t?l.find($=>$.ticket.id===t):void 0;if(!k||!s.w)return;p();const v=Math.min(1.4,Math.max(h.k,1.05)),w={k:v,x:s.w/2-(d+k.x+Ve/2)*v,y:s.h/2-(d+k.y+Qe/2)*v};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return f(w);const j=h,N=performance.now();let S=0;const I=$=>{const _=Math.min(1,($-N)/PA),O=1-(1-_)**3;f({k:j.k+(w.k-j.k)*O,x:j.x+(w.x-j.x)*O,y:j.y+(w.y-j.y)*O}),_<1&&(S=requestAnimationFrame(I))};return S=requestAnimationFrame(I),()=>cancelAnimationFrame(S)},[t])}function DA(e,t){const[s,o]=y.useState({});return Ye({view:e,version:t,load:async()=>{const a=await fetch(`${pe()}/proof/trail?mapId=${encodeURIComponent(e)}`);return a.ok?(await a.json()).statuses??{}:{}},show:o,failed:()=>o({}),changed:a=>a.includes(".evidence")||a.includes(e)}),s}function zA(e,t){const s=y.useRef(t);s.current=t,y.useEffect(()=>{const o=e.current;if(!o)return;const a=p=>{const k=o.getBoundingClientRect();return{x:p.clientX-k.left,y:p.clientY-k.top}},l=p=>{p.preventDefault();const k=p.ctrlKey?.01:.0015;s.current(Math.exp(-p.deltaY*k),a(p))};let d=1;const h=p=>{p.preventDefault(),d=1},f=p=>{p.preventDefault();const k=p;s.current(k.scale/d,a(k)),d=k.scale};return o.addEventListener("wheel",l,{passive:!1}),o.addEventListener("gesturestart",h,{passive:!1}),o.addEventListener("gesturechange",f,{passive:!1}),()=>{o.removeEventListener("wheel",l),o.removeEventListener("gesturestart",h),o.removeEventListener("gesturechange",f)}},[e])}function $p(e,t,s){const o=Math.min(3,Math.max(.2,t));return{k:o,x:s.x-(s.x-e.x)*o/e.k,y:s.y-(s.y-e.y)*o/e.k}}const on=32,BA=1.8;function FA(e){var ce;const{snap:t,selection:s,onSelect:o,preview:a}=e,l=DA(t.map.id,t.tickets),d=(a==null?void 0:a.tickets)??t.tickets,h=y.useRef(null),[f,p]=y.useState({w:0,h:0});y.useEffect(()=>{const F=h.current;if(!F)return;const J=new ResizeObserver(([ie])=>p({w:ie.contentRect.width,h:ie.contentRect.height}));return J.observe(F),()=>J.disconnect()},[]);const k=y.useMemo(()=>{const F=nm(d,"LR",t.map.mode),J=nm(d,"TB",t.map.mode),ie=W=>Math.min(f.w/(W.width+on*2),f.h/(W.height+on*2+16));return ie(F)*BA>=ie(J)?F:J},[d,t.map.mode,f.w,f.h]),v=(F,J)=>Math.min(1.25,Math.max(e.minFit??0,Math.min(f.w/F,f.h/J))),w=y.useMemo(()=>{const F=k.width+on*2,J=k.height+on*2+16,W=k.nodes.some(z=>z.state==="out-of-scope")&&f.h?Math.max(0,f.h/v(F,J)-J):0;if(!W)return{...k,slack:W};const X=new Map(k.nodes.map(z=>[z,{...z,y:z.y+(z.state==="out-of-scope"?W:W/2)}]));return{...k,slack:W,nodes:[...X.values()],edges:k.edges.map(z=>({from:X.get(z.from),to:X.get(z.to)})),quarantineY:k.quarantineY+W,height:k.height+W}},[k,f.w,f.h,e.minFit]),j=XE(w),N=j.right+on*2,S=j.bottom+on*2+16,I=()=>{const F=v(N,S);return{k:F,x:Math.max(0,(f.w-N*F)/2),y:Math.max(0,(f.h-S*F)/2)}},[$,_]=y.useState({k:1,x:0,y:0}),O=y.useRef(!1);y.useEffect(()=>{O.current=!1},[t.map.id]),y.useEffect(()=>{!O.current&&f.w&&_(TA({fit:I(),nodes:w.nodes,size:f,pad:on}))},[f.w,f.h,N,S,t.map.id]);const D=y.useRef(new Map),q=y.useRef(null),H=F=>{const J=h.current.getBoundingClientRect();return{x:F.clientX-J.left,y:F.clientY-J.top}},G=()=>{var W;const F=[...D.current.values()],J=F.length>1?{x:(F[0].x+F[1].x)/2,y:(F[0].y+F[1].y)/2}:F[0],ie=F.length>1?Math.hypot(F[0].x-F[1].x,F[0].y-F[1].y):0;q.current={view:$,dist:ie,mid:J,moved:((W=q.current)==null?void 0:W.moved)??!1}};zA(h,(F,J)=>{O.current=!0,_(ie=>$p(ie,ie.k*F,J))});const oe=Xt(5e3),Q=Rd(e.leases,t.map.id),ke=Bd(),Oe=(ce=Yd())==null?void 0:ce.waiting,Te=new Map(e.sessions.filter(F=>dn(F)&&F.ticketId).map(F=>[F.ticketId,F])),ne=(s==null?void 0:s.kind)==="ticket"?s.id:void 0;return _A({selId:ne,nodes:w.nodes,size:f,pad:on,view:$,setView:_,onFocus:()=>O.current=!0}),i.jsxs("div",{className:"graph-box",ref:h,onPointerDown:F=>{D.current.set(F.pointerId,H(F)),D.current.size===1&&(q.current=null),G()},onPointerMove:F=>{var W;if(!D.current.has(F.pointerId)||!q.current)return;D.current.set(F.pointerId,H(F));const J=q.current,ie=[...D.current.values()];if(ie.length>1){const X={x:(ie[0].x+ie[1].x)/2,y:(ie[0].y+ie[1].y)/2},z=Math.hypot(ie[0].x-ie[1].x,ie[0].y-ie[1].y),T=$p(J.view,J.view.k*z/(J.dist||z),J.mid);_({...T,x:T.x+X.x-J.mid.x,y:T.y+X.y-J.mid.y}),J.moved=!0}else{const X=ie[0].x-J.mid.x,z=ie[0].y-J.mid.y;if(!J.moved&&Math.hypot(X,z)<5)return;J.moved||(W=h.current)==null||W.setPointerCapture(F.pointerId),J.moved=!0,_({...J.view,x:J.view.x+X,y:J.view.y+z})}O.current=!0},onPointerUp:F=>{D.current.delete(F.pointerId),D.current.size&&G()},onPointerCancel:F=>D.current.delete(F.pointerId),onClickCapture:F=>{var J;(J=q.current)!=null&&J.moved&&(F.stopPropagation(),q.current=null)},children:[i.jsxs("svg",{className:"graph",width:f.w,height:f.h,onClick:()=>o(null),children:[i.jsx(nA,{}),i.jsx("g",{transform:`translate(${$.x} ${$.y}) scale(${$.k})`,children:i.jsxs("g",{transform:`translate(${on} ${on})`,children:[i.jsx(OA,{seed:t.map.id,width:N,height:S,nodes:w.nodes}),i.jsx(EA,{y:w.quarantineY,width:w.width,height:w.quarantineH,nodes:w.nodes}),i.jsx(aA,{snap:t,tickets:d,direction:w.direction,nodes:w.nodes,edges:w.edges,preview:a}),i.jsx(tA,{trails:ZE(w,j)}),w.nodes.length>0&&i.jsx(eA,{x:j.x,y:j.y,text:t.map.sections.destination}),w.nodes.map(F=>{var J;return i.jsx(bA,{n:F,session:Te.get(F.ticket.id),stalled:!!Q.get(F.ticket.id)&&ca(Q.get(F.ticket.id),oe)!=="live",flag:V1(ei.ticket(ke,t.map.id,F.ticket.id)),selected:ne===F.ticket.id,onSelect:o,mark:a==null?void 0:a.marks.get(F.ticket.id),frozen:a==null?void 0:a.frozen.has(F.ticket.id),needs:(J=Oe==null?void 0:Oe.find(ie=>ie.mapId===t.map.id&&ie.ticketId===F.ticket.id))==null?void 0:J.tier,verified:l[F.ticket.id]===void 0?void 0:l[F.ticket.id]==="verified"},F.ticket.id)})]})})]}),i.jsx(CA,{}),i.jsx("button",{className:"btn sm fit-btn","data-tip":"Fit the whole trail in view",onPointerDown:F=>F.stopPropagation(),onClick:F=>{F.stopPropagation(),O.current=!0,_(I())},children:"Fit"})]})}const Qc=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],Cp=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function UA({snap:e,sessions:t}){const s=sg(e),o=p=>s[p],a=t.filter(Gg).length,l=Zx(e),d=Math.max(1,...l.map(p=>p.open+p.closed)),f=(e.map.verification??"off")!=="off"||Cp.some(([p])=>o(p))?[...Qc.slice(0,2),...Cp,...Qc.slice(2)]:Qc;return i.jsxs("div",{className:"status-panel",children:[i.jsxs("div",{className:"sp-col sp-status",children:[i.jsxs("div",{className:"sp-head",children:[i.jsx(ze,{as:"h3",children:"Status"}),i.jsxs("span",{className:"t-meta",children:[s.total," tickets"]})]}),i.jsxs("ul",{children:[f.map(([p,k])=>i.jsxs("li",{className:`st-${p} ${o(p)?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:k}),i.jsx("b",{children:o(p)})]},p)),i.jsxs("li",{className:`st-waiting ${a?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:"Waiting on you"}),i.jsx("b",{children:a})]})]})]}),i.jsxs("div",{className:"sp-block sp-col",children:[i.jsx("span",{className:"t-label",children:"Type mix"}),i.jsx("ul",{className:"mix",children:l.map(p=>i.jsxs("li",{title:`${p.type}: ${p.closed} closed, ${p.open} open`,children:[i.jsx("span",{className:"t-meta",children:Zs[p.type]}),i.jsxs("span",{className:"mix-bar",children:[i.jsx("i",{className:"closed",style:{width:`${p.closed/d*100}%`}}),i.jsx("i",{className:"open",style:{width:`${p.open/d*100}%`}})]}),i.jsx("b",{children:p.open+p.closed})]},p.type))})]})]})}function WA(e){const[t,s]=y.useState(!1);return i.jsxs("div",{className:t?"status-drawer open":"status-drawer",children:[i.jsxs("button",{type:"button",className:"status-toggle","aria-expanded":t,onPointerDown:o=>o.stopPropagation(),onClick:()=>s(!t),children:["Summary ",i.jsx("span",{className:"caret",children:t?"▾":"▴"})]}),i.jsx(UA,{snap:e.snap,sessions:e.sessions})]})}function HA(){const e=zt();return e?`Describe your idea here, then turn your agents on for it in ${e.label}. Scout frames it with you here, then they get to work.`:"Describe your idea here, or start it in Claude Code or Codex. Scout frames it with you, then your agents get to work."}function KA({planOnly:e,verifies:t}){const s=[["frontier","Ready"],["claimed","Working"],...t?[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]]:[],["stalled","Stalled"],["blocked","Backlog"],["decided","Done"],...e?[["parked","Parked"]]:[],["out-of-scope","Cancelled"],["waiting","Waiting on you"]];return i.jsxs("div",{className:"legend",children:[s.map(([o,a])=>i.jsxs("span",{className:`lg st-${o}`,children:[i.jsx("i",{}),a]},o)),i.jsx("span",{className:"lg hitl",children:"● needs human"})]})}function VA(e){var o,a,l;const{snap:t,selection:s}=e.api;return i.jsxs(Be,{as:"main",className:"zone map-zone",style:{gridArea:"map"},children:[t&&!zt()&&i.jsx(C$,{}),(o=e.trail)==null?void 0:o.banner,i.jsxs("div",{className:"map-area",children:[t&&!e.compact&&i.jsx(WA,{snap:t,sessions:e.sessions}),t?i.jsx(FA,{snap:t,sessions:e.sessions,leases:e.api.leases,selection:s,onSelect:e.onSelect,minFit:e.minFit,preview:(a=e.trail)==null?void 0:a.preview}):i.jsxs("div",{className:"nomap",children:[i.jsx(Sn,{title:"No trail yet",hint:HA()}),i.jsx("div",{className:"actions",children:i.jsx(M,{variant:"primary",onClick:e.onNewTrail,"data-tip":"Describe the idea and create the trail",children:"New trail…"})}),zt()?i.jsx(M,{onClick:ev,children:(l=zt())==null?void 0:l.label}):i.jsx(Na,{command:'/scout new "your idea"'})]}),t&&e.compact&&i.jsx(KA,{planOnly:t.map.mode==="plan-only",verifies:(t.map.verification??"off")!=="off"})]})]})}const GA=[["home","Inbox"],["map","Map"],["ticket","Ticket"],["activity","Activity"],["plan","Plan"]];function qA(e){const{tab:t,covered:s,pending:o}=e;return i.jsx("nav",{className:"tabbar",children:GA.map(([a,l])=>i.jsxs("button",{className:t===a&&!s?"on":"",onClick:()=>e.onPick(a),children:[l,a==="home"&&o>0&&i.jsx(fs,{n:o,urgent:!0,pop:!0},o)]},a))})}function QA(e){const t={home:e.projects?i.jsxs("div",{className:"phone-home",children:[e.projects,e.inbox]}):e.inbox,map:e.map,ticket:i.jsx(Be,{className:"zone",children:e.ticket}),activity:i.jsx(Be,{className:"zone",children:e.activity}),plan:e.plan};return i.jsx("main",{className:"phone-view",children:e.decisions||t[e.tab]})}const Tp={settingsPage:!0},Ep=()=>Sv(new URLSearchParams(location.search).get("settings")),Ap=()=>{var e;return!!((e=history.state)!=null&&e.settingsPage)};function YA(){const[e,t]=y.useState(Ep);y.useEffect(()=>{e&&!Ap()&&(history.replaceState(null,"",tr(location.href,null)),history.pushState(Tp,"",tr(location.href,e)));const l=()=>t(Ep());return window.addEventListener("popstate",l),()=>window.removeEventListener("popstate",l)},[]);const s=l=>{const d=tr(location.href,l);e?history.replaceState(history.state,"",d):history.pushState(Tp,"",d),t(l)},o=()=>{e&&(t(null),Ap()?history.back():history.replaceState(null,"",tr(location.href,null)))},a=l=>s(Sv(l??"")??{});return{route:e,open:a,show:s,close:o,toggle:()=>e?o():a()}}function JA(e,t){const{activity:s,selection:o,setSelection:a,actions:l}=e,[d,h]=y.useState("ticket"),[f,p]=y.useState("home"),[k,v]=y.useState(0),[w,j]=y.useState(null),[N,S]=y.useState(!1),I=H=>{S(!1),j({focus:H})},$=()=>{j(null),S(H=>!H)};y.useEffect(()=>{const H=s.sessions.find(G=>G.id===e.chatSession);!o&&(H!=null&&H.ticketId)&&H.mapId===e.mapId&&a({kind:"ticket",id:H.ticketId})},[e.chatSession,e.mapId]);const _=H=>{a(H),H&&(t==="laptop"&&h("ticket"),t==="mobile"&&p("ticket"))},O=(H,G,oe)=>{oe&&oe!==e.mapId&&l.selectMap(oe),l.openChat(H);const Q=s.sessions.find(ke=>ke.id===H);G&&(Q==null?void 0:Q.mapId)===(oe??e.mapId)&&a({kind:"ticket",id:G}),t==="mobile"&&(p("home"),v(ke=>ke+1))};return{sideTab:d,setSideTab:h,phoneTab:f,setPhoneTab:p,convRequest:k,decisionsView:w,setDecisionsView:j,openDecisions:I,statsOpen:N,setStatsOpen:S,toggleStats:$,select:_,openChat:O,showChat:(H,G,oe)=>{O(H,G,oe),v(Q=>Q+1)},openTicket:(H,G)=>{H!==e.mapId&&l.selectMap(H),a({kind:"ticket",id:G}),j(null),t==="laptop"&&h("ticket"),t==="mobile"&&p("ticket")}}}function XA(e,t){y.useEffect(()=>{document.title=`${Z.name}: ${e?`(${e}) `:""}${t??"No trail"}`},[e,t])}function ZA(e){const[t,s]=y.useState("…");return y.useEffect(()=>{fetch(`${pe()}/list`).then(o=>o.json()).then(o=>{var l;const a=o.root.split("/").filter(Boolean);s((l=a[a.length-1])!=null&&l.startsWith(".")?a[a.length-2]??"repo":a[a.length-1]??"repo")}).catch(()=>s("repo"))},[e]),t}function eI(e,t){return y.useMemo(()=>{const s=e.sessions.filter(a=>a.mapId===t),o=new Set(e.sessions.filter(a=>a.mapId!==t).map(a=>a.id));return{...e,sessions:s,feed:e.feed.filter(a=>!a.sessionId||!o.has(a.sessionId))}},[e,t])}function tI({text:e}){return e.trim()?i.jsx("div",{className:"brief-prose",children:e.split(`
|
|
157
|
-
`).map((t,s)=>i.jsx("p",{children:t.split(/(`[^`]+`|\/?\b[\w.-]+\/[\w./-]+\b)/g).map((o,a)=>a%2===1?i.jsx("code",{children:o.replace(/`/g,"")},a):o)},s))}):i.jsx(Ie,{children:"Not covered"})}const Ip=["summary","productContext","existing","conventions","dataModel","api","risks"];function nI(e){const{brief:t}=e,[s,o]=y.useState(!1),[a,l]=y.useState("");y.useEffect(()=>{const p=
|
|
156
|
+
Where this trail ends`;return i.jsxs("g",{className:"destination",transform:`translate(${e} ${t})`,"aria-label":o,"data-tip":o,tabIndex:0,children:[i.jsx("rect",{className:"x-hit",x:-24,y:-24,width:48,height:48}),i.jsx("path",{className:"x-stroke",d:"M-15 -16 C-9 -10 2 4 16 17"}),i.jsx("path",{className:"x-stroke",d:"M17 -15 C8 -8 -6 5 -16 17"})]})}function tA({trails:e}){return e.map(t=>i.jsx("path",{className:"edge edge-open edge-destination",d:t},t))}function nA(){return i.jsxs("defs",{children:[i.jsx("pattern",{id:"map-grid",width:"40",height:"40",patternUnits:"userSpaceOnUse",children:i.jsx("path",{d:"M40 0H0V40",fill:"none",stroke:"var(--map-grid)",strokeWidth:"1"})}),i.jsx("pattern",{id:"hatch-oos",width:"10",height:"10",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:i.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"10",stroke:"var(--line2)",strokeWidth:"1"})})]})}const Xo=(e,t)=>`${e}>${t}`;function sA(e,t,s=[]){const o=new Map(e.tickets.map(l=>[l.id,l]));return{tickets:t.nodes.map(l=>{const d=o.get(l.id);return d?{...d,blockedBy:[...l.blockedBy,...l.removedEdges??[]]}:{id:l.id,key:"+",title:l.title,type:l.type,body:"",state:"open",blockedBy:l.blockedBy,comments:[],createdAt:e.map.updatedAt,updatedAt:e.map.updatedAt}}),marks:new Map(t.nodes.map(l=>[l.id,l.mark])),newEdges:new Set(t.nodes.flatMap(l=>l.newEdges.map(d=>Xo(d,l.id)))),removedEdges:new Set(t.nodes.flatMap(l=>(l.removedEdges??[]).map(d=>Xo(d,l.id)))),frozen:new Set(s)}}function iA(e,t){const s=Xx({...e,tickets:t}),o=new Set;for(let a=1;a<s.length;a++)o.add(Xo(s[a-1].id,s[a].id));return o}const xp={LR:130,TB:68};function rA(e){const{direction:t,from:s,to:o,cards:a}=e;if(t==="LR"){const h={x:s.x+Ve,y:s.y+Qe/2},f={x:o.x,y:o.y+Qe/2};return Jo({direction:t,a:h,b:f,obstacles:a,gap:xp.LR})}const l={x:s.x+Ve/2,y:s.y+Qe},d={x:o.x+Ve/2,y:o.y};return Jo({direction:t,a:l,b:d,obstacles:a,gap:xp.TB})}function oA(e){const{from:t,to:s,direction:o}=e,l=["edge",t.ticket.state!=="open"?"edge-done":"edge-open"];return e.critical&&l.push("edge-critical"),e.added&&l.push("edge-added"),e.removed&&l.push("edge-removed"),i.jsx("path",{className:l.join(" "),d:rA({direction:o,from:t,to:s,cards:e.cards})})}function aA(e){const{snap:t,tickets:s,direction:o,preview:a}=e,l=y.useMemo(()=>iA(t,s),[t,s]),d=y.useMemo(()=>tk(e.nodes),[e.nodes]);return e.edges.map(({from:h,to:f})=>{const p=Xo(h.ticket.id,f.ticket.id);return i.jsx(oA,{from:h,to:f,direction:o,cards:d,critical:l.has(p),added:a==null?void 0:a.newEdges.has(p),removed:a==null?void 0:a.removedEdges.has(p)},p)})}const Xd=24,lA=13,cA=9.5;function dA(e){const t=e.guide;return i.jsx("g",{className:"meta",transform:`translate(${Xd} ${e.y})`,children:e.chips.map((s,o)=>{const a=s.kind==="guide"?t:void 0;return i.jsxs("g",{className:Ge("card-chip",s.kind,s.kind==="state"&&e.tone,(a==null?void 0:a.off)&&"off"),"data-guide-id":a==null?void 0:a.id,transform:`translate(${s.x} 0)`,children:[a&&i.jsx("title",{children:a.tip}),i.jsx("rect",{width:s.w,height:lA,rx:3}),i.jsx("text",{x:(s.w-s.textW)/2,y:cA,textLength:s.textW,lengthAdjust:"spacingAndGlyphs",children:s.text})]},o)})})}const nk=5,uA={sans:"9.5px 'Figtree Variable', system-ui, sans-serif",mono:"8.55px 'JetBrains Mono Variable', ui-monospace, monospace"};let Zi;function hA(){if(Zi!==void 0)return Zi;try{Zi=typeof document>"u"?null:document.createElement("canvas").getContext("2d")}catch{Zi=null}return Zi}function fA(e,t="sans"){const s=hA();return s?(s.font=uA[t],s.measureText(e).width*1.04):e.length*nk}const jp=4,Sp=3,mA=6;function pA(e){var k;const t=Ve-Xd-8-(e.reserve??0),s=((k=e.state)==null?void 0:k.split(" · "))??[],o=[{kind:"key",text:e.key},{kind:"type",text:e.type},...e.guide===void 0?[]:[{kind:"guide",text:e.guide}],...s.map(w=>({kind:"state",text:w})),...e.needsYou?[{kind:"needs",text:"needs you"}]:[]],a=t-o.length*2*jp-(o.length-1)*Sp,l=w=>fA(w.text,w.kind==="key"?"mono":"sans"),d=o.filter(w=>w.kind!=="guide").reduce((w,j)=>w+l(j),0),h=Math.max(mA,Math.floor((a-d)/nk)),f=o.map(w=>w.kind==="guide"?{...w,text:hT(w.text,h)}:w),p=Math.min(1,a/f.reduce((w,j)=>w+l(j),0));let v=0;return f.map(w=>{const j=l(w)*p,N={...w,x:v,w:j+2*jp,textW:j};return v+=N.w+Sp,N})}function gA(e,t,s){const o=e.state==="frontier"||e.state==="rework";if(!(!t||s||e.ticket.assignee||!o))return t}function vA(e){const t=["node",`st-${e.n.state}`,`tone-${e.tone}`,e.hitl?"hitl":"afk"];return e.selected&&t.push("sel"),e.live&&t.push("live"),e.waiting&&t.push("waiting"),e.stalled&&!e.waiting&&t.push("stalled"),e.mark&&t.push(`mark-${e.mark}`),e.frozen&&t.push("frozen"),t.join(" ")}function kA({wait:e,session:t}){return e?i.jsx("title",{children:`Needs a ${e} model: no connected agent runs one`}):t?i.jsx("title",{children:`${t.agent} · step ${t.step}/${t.total} · ${t.stepLabel.toLowerCase()}`}):null}const yA={claimed:"working",verifying:"working",frontier:"ready",blocked:"backlog",parked:"backlog",decided:"done","out-of-scope":"cancelled",rework:"attention",held:"attention"};function wA(e){const t=yA[e.state];return t==="done"||t==="cancelled"?t:e.attention?"attention":e.live?"working":t}function xA({mark:e,frozen:t}){const s=e&&e!=="unchanged"&&e!=="cancelled"?e:void 0;return i.jsxs(i.Fragment,{children:[e==="cancelled"&&i.jsx("line",{className:"strike",x1:8,y1:Qe/2,x2:Ve-8,y2:Qe/2}),s&&i.jsx("text",{className:"reroute-tag",x:Ve-8,y:Qe-7,textAnchor:"end",children:s}),t&&i.jsx("text",{className:"freeze",x:Ve-(s?58:8),y:Qe-7,textAnchor:"end",children:"❄"})]})}function jA(e){const{n:t,session:s}=e,o=t.ticket.assignee;return e.waiting?{text:"waiting on you",tone:"urgent"}:e.stalled?{text:`stalled · ${o}`,tone:"warn"}:e.wait?{text:`needs ${e.wait}`,tone:"warn"}:s&&e.step?{text:`${s.agent} · step ${s.step}/${s.total}`,tone:"agent"}:s?{text:s.agent,tone:"agent"}:t.state==="claimed"?{text:o??"working",tone:"agent"}:t.state==="verifying"?{text:"checks running",tone:"agent"}:t.state==="decided"&&e.verified?{text:"verified",tone:"verified"}:{text:g1[t.state],tone:""}}function sk({tone:e,cy:t,verified:s}){return e==="done"?i.jsx("path",{className:`dot dot-done${s?" dot-verified":""}`,d:`M10 ${t}l2.5 2.5 4.5 -5`}):i.jsx("circle",{className:`dot dot-${e}`,cx:13,cy:t,r:e==="backlog"?3:3.5})}function SA(e,t,s=2){const o=e.split(/\s+/),a=[];let l="";for(const d of o)(l+" "+d).trim().length>t?(a.push(l.trim()),l=d):l+=" "+d;if(a.push(l.trim()),a.length>s){const d=a.slice(0,s);return d[s-1]=d[s-1].slice(0,t-1)+"…",d}return a}const NA=26;function bA({n:e,session:t,stalled:s,flag:o,selected:a,onSelect:l,mark:d,frozen:h,needs:f,verified:p}){const v=e.ticket,k=SA(v.title,NA),w=cr(v)==="hitl",j=!!(t!=null&&t.waitingOn),N=!!d&&d!=="unchanged",S=gA(e,f,!!t),I=LT(v.guide),$=N?void 0:jA({n:e,session:t,waiting:j,stalled:s,wait:S,step:!I,verified:p}),_=w&&!N&&(v.type==="task"||v.type==="execute"),O=j||!!s||!!S||_&&e.state==="frontier",D=wA({state:e.state,live:!!t,attention:O}),q=Zs[v.type],H=(N&&d!=="cancelled"?44:0)+(h?12:0),G=pA({key:v.key,type:q,guide:I==null?void 0:I.name,state:$==null?void 0:$.text,needsYou:_,reserve:H}),oe=k.length>1?19:24;return i.jsxs("g",{className:vA({n:e,tone:D,hitl:w,selected:a,live:!!t,waiting:j,stalled:s,mark:d,frozen:h}),style:{transform:`translate(${e.x}px, ${e.y}px)`},onClick:Q=>{Q.stopPropagation(),l({kind:"ticket",id:v.id})},children:[i.jsx(kA,{wait:S,session:t}),i.jsx("rect",{className:"ring",x:-3.5,y:-3.5,width:Ve+7,height:Qe+7,rx:9}),i.jsx("rect",{className:"card",x:.5,y:.5,width:Ve-1,height:Qe-1,rx:6}),i.jsx(sk,{tone:D,cy:oe-4,verified:p}),k.map((Q,ke)=>i.jsx("text",{className:"title",x:Xd,y:oe+ke*14,children:Q},ke)),i.jsx(dA,{chips:G,y:oe+k.length*14-8,tone:$==null?void 0:$.tone,guide:I}),o&&i.jsx("circle",{className:`pr-flag-dot ${o}`,cx:Ve-2,cy:2,r:4}),i.jsx(xA,{mark:d,frozen:h})]})}const $A=[{tone:"working",text:"An agent is on it"},{tone:"attention",text:"Waits on you, or held up"},{tone:"ready",text:"Ready for an agent"},{tone:"backlog",text:"Not ready yet"},{tone:"done",verified:!0,text:"Done and verified"},{tone:"done",text:"Done, not verified"},{tone:"cancelled",text:"Ruled out"}];function CA(){const[e,t]=y.useState(!1);return i.jsxs("div",{className:"map-legend",onPointerDown:s=>s.stopPropagation(),onClick:s=>s.stopPropagation(),children:[e&&i.jsx("ul",{className:"map-legend-list",children:$A.map(s=>i.jsxs("li",{children:[i.jsx("svg",{className:"node",width:"22",height:"16",viewBox:"4 0 18 16","aria-hidden":"true",children:i.jsx(sk,{tone:s.tone,cy:8,verified:s.verified})}),s.text]},s.text))}),i.jsx("button",{type:"button",className:"btn sm","aria-expanded":e,onClick:()=>t(!e),children:e?"Hide legend":"Legend"})]})}const Np=.72;function TA(e){const{fit:t,nodes:s,size:o,pad:a}=e;if(t.k>=Np)return t;const l=s.find(h=>h.state==="claimed")??s.find(h=>h.state==="frontier")??s[0];if(!l)return t;const d=Np;return{k:d,x:o.w/2-(l.x+a+Ve/2)*d,y:o.h/2-(l.y+a+Qe/2)*d}}function EA(e){const{y:t,width:s,height:o}=e,a=e.nodes.filter(l=>l.state==="out-of-scope").length;return a?i.jsxs("g",{className:"quarantine",children:[i.jsx("rect",{x:-20,y:t-30,width:s+40,height:o+18,fill:"url(#hatch-oos)"}),i.jsx("line",{x1:-20,y1:t-30,x2:s+20,y2:t-30}),i.jsxs("text",{x:-12,y:t-12,children:["Out of scope · ",a]})]}):null}const st=280,bp=4,AA=220,Vs=e=>Math.round(e/bp)*bp;function IA(e){let t=2166136261;for(const s of e)t=Math.imul(t^s.charCodeAt(0),16777619);return()=>{t=t+1831565813|0;let s=Math.imul(t^t>>>15,1|t);return s=s+Math.imul(s^s>>>7,61|s)^s,((s^s>>>14)>>>0)/4294967296}}function qc(e,t,s,o){return Array.from({length:6},()=>{const a=o*(.5+e()*.7),l=o*(.3+e()*.4);return{x:Vs(t+(e()-.5)*o*.8-a/2),y:Vs(s+(e()-.5)*o*.5-l/2),w:Vs(a),h:Vs(l)}})}function RA(e){const{width:t,height:s,nodes:o}=e,a=IA(e.seed),l=(w,j)=>w+a()*(j-w),d=(w,j)=>!o.some(N=>w>N.x-52&&w<N.x+Ve+28&&j>N.y-52&&j<N.y+Qe+28),h=(t+st*2)*(s+st*2),f=Array.from({length:Math.round(h/9e4)},()=>qc(a,l(-st,t+st),l(-st,s+st),l(160,360))).flat(),p=[...qc(a,t+st*.55,s+st*.55,300),...qc(a,-st*.5,-st*.45,220)],v=[],k=(w,j,N)=>{v.length<AA&&d(j,N)&&v.push({sprite:w,x:Vs(j),y:Vs(N)})};for(let w=0;w<Math.round(h/3e4);w++){const j=l(-st,t+st),N=l(-st,s+st),S=3+Math.floor(a()*5);for(let I=0;I<S;I++)k(a()<.65?"pine":"oak",j+l(-70,70),N+l(-44,44))}for(let w=0;w<Math.round(h/45e3);w++)k(a()<.4?"rock":"tuft",l(-st,t+st),l(-st,s+st));return v.sort((w,j)=>w.y-j.y),{grass:f,water:p,items:v}}const ik={pine:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"16",y:"30",width:"4",height:"10",fill:"var(--map-trunk)"}),i.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H0l9-11H5l8-10H9z",fill:"var(--map-pine)"}),i.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H18z",fill:"var(--map-pine2)"})]}),oak:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"16",y:"24",width:"4",height:"12",fill:"var(--map-trunk)"}),i.jsx("circle",{cx:"18",cy:"14",r:"14",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"10",cy:"17",r:"8",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"26",cy:"17",r:"8",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"22",cy:"10",r:"6",fill:"var(--map-oak2)"})]}),rock:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M1 16Q2 6 10 3Q18-1 23 6Q28 11 27 16z",fill:"var(--map-rock)"}),i.jsx("path",{d:"M15 16Q15 8 19 4Q25 8 27 16z",fill:"var(--map-rock2)"})]}),tuft:i.jsx("path",{d:"M4 8Q3 4 1 1M14 8Q14 3 14 0M24 8Q25 4 27 1",fill:"none",stroke:"var(--map-pine2)",strokeWidth:"2.5",strokeLinecap:"round"})};function MA({name:e}){return i.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:ik[e]})}const LA=Object.keys(ik),OA=y.memo(function(t){const{seed:s,width:o,height:a,nodes:l}=t,d=y.useMemo(()=>RA({seed:s,width:o,height:a,nodes:l}),[s,o,a,l]);return i.jsxs("g",{className:"terrain","aria-hidden":"true",children:[i.jsx("defs",{children:LA.map(h=>i.jsx(MA,{name:h},h))}),d.grass.map((h,f)=>i.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-grass)"},f)),d.water.map((h,f)=>i.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-water)"},f)),i.jsx("rect",{x:-4e3,y:-4e3,width:o+8e3,height:a+8e3,fill:"url(#map-grid)"}),d.items.map((h,f)=>i.jsx("use",{href:`#terrain-${h.sprite}`,x:h.x,y:h.y},f))]})}),PA=380;function _A(e){const{selId:t,size:s}=e,o=y.useRef(e);o.current=e;const a=y.useRef(!0);y.useEffect(()=>{if(a.current){a.current=!1;return}const{nodes:l,pad:d,view:h,setView:f,onFocus:p}=o.current,v=t?l.find($=>$.ticket.id===t):void 0;if(!v||!s.w)return;p();const k=Math.min(1.4,Math.max(h.k,1.05)),w={k,x:s.w/2-(d+v.x+Ve/2)*k,y:s.h/2-(d+v.y+Qe/2)*k};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return f(w);const j=h,N=performance.now();let S=0;const I=$=>{const _=Math.min(1,($-N)/PA),O=1-(1-_)**3;f({k:j.k+(w.k-j.k)*O,x:j.x+(w.x-j.x)*O,y:j.y+(w.y-j.y)*O}),_<1&&(S=requestAnimationFrame(I))};return S=requestAnimationFrame(I),()=>cancelAnimationFrame(S)},[t])}function DA(e,t){const[s,o]=y.useState({});return Ye({view:e,version:t,load:async()=>{const a=await fetch(`${pe()}/proof/trail?mapId=${encodeURIComponent(e)}`);return a.ok?(await a.json()).statuses??{}:{}},show:o,failed:()=>o({}),changed:a=>a.includes(".evidence")||a.includes(e)}),s}function zA(e,t){const s=y.useRef(t);s.current=t,y.useEffect(()=>{const o=e.current;if(!o)return;const a=p=>{const v=o.getBoundingClientRect();return{x:p.clientX-v.left,y:p.clientY-v.top}},l=p=>{p.preventDefault();const v=p.ctrlKey?.01:.0015;s.current(Math.exp(-p.deltaY*v),a(p))};let d=1;const h=p=>{p.preventDefault(),d=1},f=p=>{p.preventDefault();const v=p;s.current(v.scale/d,a(v)),d=v.scale};return o.addEventListener("wheel",l,{passive:!1}),o.addEventListener("gesturestart",h,{passive:!1}),o.addEventListener("gesturechange",f,{passive:!1}),()=>{o.removeEventListener("wheel",l),o.removeEventListener("gesturestart",h),o.removeEventListener("gesturechange",f)}},[e])}function $p(e,t,s){const o=Math.min(3,Math.max(.2,t));return{k:o,x:s.x-(s.x-e.x)*o/e.k,y:s.y-(s.y-e.y)*o/e.k}}const on=32,BA=1.8;function FA(e){var ce;const{snap:t,selection:s,onSelect:o,preview:a}=e,l=DA(t.map.id,t.tickets),d=(a==null?void 0:a.tickets)??t.tickets,h=y.useRef(null),[f,p]=y.useState({w:0,h:0});y.useEffect(()=>{const F=h.current;if(!F)return;const J=new ResizeObserver(([ie])=>p({w:ie.contentRect.width,h:ie.contentRect.height}));return J.observe(F),()=>J.disconnect()},[]);const v=y.useMemo(()=>{const F=nm(d,"LR",t.map.mode),J=nm(d,"TB",t.map.mode),ie=W=>Math.min(f.w/(W.width+on*2),f.h/(W.height+on*2+16));return ie(F)*BA>=ie(J)?F:J},[d,t.map.mode,f.w,f.h]),k=(F,J)=>Math.min(1.25,Math.max(e.minFit??0,Math.min(f.w/F,f.h/J))),w=y.useMemo(()=>{const F=v.width+on*2,J=v.height+on*2+16,W=v.nodes.some(z=>z.state==="out-of-scope")&&f.h?Math.max(0,f.h/k(F,J)-J):0;if(!W)return{...v,slack:W};const X=new Map(v.nodes.map(z=>[z,{...z,y:z.y+(z.state==="out-of-scope"?W:W/2)}]));return{...v,slack:W,nodes:[...X.values()],edges:v.edges.map(z=>({from:X.get(z.from),to:X.get(z.to)})),quarantineY:v.quarantineY+W,height:v.height+W}},[v,f.w,f.h,e.minFit]),j=XE(w),N=j.right+on*2,S=j.bottom+on*2+16,I=()=>{const F=k(N,S);return{k:F,x:Math.max(0,(f.w-N*F)/2),y:Math.max(0,(f.h-S*F)/2)}},[$,_]=y.useState({k:1,x:0,y:0}),O=y.useRef(!1);y.useEffect(()=>{O.current=!1},[t.map.id]),y.useEffect(()=>{!O.current&&f.w&&_(TA({fit:I(),nodes:w.nodes,size:f,pad:on}))},[f.w,f.h,N,S,t.map.id]);const D=y.useRef(new Map),q=y.useRef(null),H=F=>{const J=h.current.getBoundingClientRect();return{x:F.clientX-J.left,y:F.clientY-J.top}},G=()=>{var W;const F=[...D.current.values()],J=F.length>1?{x:(F[0].x+F[1].x)/2,y:(F[0].y+F[1].y)/2}:F[0],ie=F.length>1?Math.hypot(F[0].x-F[1].x,F[0].y-F[1].y):0;q.current={view:$,dist:ie,mid:J,moved:((W=q.current)==null?void 0:W.moved)??!1}};zA(h,(F,J)=>{O.current=!0,_(ie=>$p(ie,ie.k*F,J))});const oe=Xt(5e3),Q=Rd(e.leases,t.map.id),ke=Bd(),Oe=(ce=Yd())==null?void 0:ce.waiting,Te=new Map(e.sessions.filter(F=>dn(F)&&F.ticketId).map(F=>[F.ticketId,F])),ne=(s==null?void 0:s.kind)==="ticket"?s.id:void 0;return _A({selId:ne,nodes:w.nodes,size:f,pad:on,view:$,setView:_,onFocus:()=>O.current=!0}),i.jsxs("div",{className:"graph-box",ref:h,onPointerDown:F=>{D.current.set(F.pointerId,H(F)),D.current.size===1&&(q.current=null),G()},onPointerMove:F=>{var W;if(!D.current.has(F.pointerId)||!q.current)return;D.current.set(F.pointerId,H(F));const J=q.current,ie=[...D.current.values()];if(ie.length>1){const X={x:(ie[0].x+ie[1].x)/2,y:(ie[0].y+ie[1].y)/2},z=Math.hypot(ie[0].x-ie[1].x,ie[0].y-ie[1].y),T=$p(J.view,J.view.k*z/(J.dist||z),J.mid);_({...T,x:T.x+X.x-J.mid.x,y:T.y+X.y-J.mid.y}),J.moved=!0}else{const X=ie[0].x-J.mid.x,z=ie[0].y-J.mid.y;if(!J.moved&&Math.hypot(X,z)<5)return;J.moved||(W=h.current)==null||W.setPointerCapture(F.pointerId),J.moved=!0,_({...J.view,x:J.view.x+X,y:J.view.y+z})}O.current=!0},onPointerUp:F=>{D.current.delete(F.pointerId),D.current.size&&G()},onPointerCancel:F=>D.current.delete(F.pointerId),onClickCapture:F=>{var J;(J=q.current)!=null&&J.moved&&(F.stopPropagation(),q.current=null)},children:[i.jsxs("svg",{className:"graph",width:f.w,height:f.h,onClick:()=>o(null),children:[i.jsx(nA,{}),i.jsx("g",{transform:`translate(${$.x} ${$.y}) scale(${$.k})`,children:i.jsxs("g",{transform:`translate(${on} ${on})`,children:[i.jsx(OA,{seed:t.map.id,width:N,height:S,nodes:w.nodes}),i.jsx(EA,{y:w.quarantineY,width:w.width,height:w.quarantineH,nodes:w.nodes}),i.jsx(aA,{snap:t,tickets:d,direction:w.direction,nodes:w.nodes,edges:w.edges,preview:a}),i.jsx(tA,{trails:ZE(w,j)}),w.nodes.length>0&&i.jsx(eA,{x:j.x,y:j.y,text:t.map.sections.destination}),w.nodes.map(F=>{var J;return i.jsx(bA,{n:F,session:Te.get(F.ticket.id),stalled:!!Q.get(F.ticket.id)&&ca(Q.get(F.ticket.id),oe)!=="live",flag:V1(ei.ticket(ke,t.map.id,F.ticket.id)),selected:ne===F.ticket.id,onSelect:o,mark:a==null?void 0:a.marks.get(F.ticket.id),frozen:a==null?void 0:a.frozen.has(F.ticket.id),needs:(J=Oe==null?void 0:Oe.find(ie=>ie.mapId===t.map.id&&ie.ticketId===F.ticket.id))==null?void 0:J.tier,verified:l[F.ticket.id]===void 0?void 0:l[F.ticket.id]==="verified"},F.ticket.id)})]})})]}),i.jsx(CA,{}),i.jsx("button",{className:"btn sm fit-btn","data-tip":"Fit the whole trail in view",onPointerDown:F=>F.stopPropagation(),onClick:F=>{F.stopPropagation(),O.current=!0,_(I())},children:"Fit"})]})}const Qc=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],Cp=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function UA({snap:e,sessions:t}){const s=sg(e),o=p=>s[p],a=t.filter(Gg).length,l=Zx(e),d=Math.max(1,...l.map(p=>p.open+p.closed)),f=(e.map.verification??"off")!=="off"||Cp.some(([p])=>o(p))?[...Qc.slice(0,2),...Cp,...Qc.slice(2)]:Qc;return i.jsxs("div",{className:"status-panel",children:[i.jsxs("div",{className:"sp-col sp-status",children:[i.jsxs("div",{className:"sp-head",children:[i.jsx(ze,{as:"h3",children:"Status"}),i.jsxs("span",{className:"t-meta",children:[s.total," tickets"]})]}),i.jsxs("ul",{children:[f.map(([p,v])=>i.jsxs("li",{className:`st-${p} ${o(p)?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:v}),i.jsx("b",{children:o(p)})]},p)),i.jsxs("li",{className:`st-waiting ${a?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:"Waiting on you"}),i.jsx("b",{children:a})]})]})]}),i.jsxs("div",{className:"sp-block sp-col",children:[i.jsx("span",{className:"t-label",children:"Type mix"}),i.jsx("ul",{className:"mix",children:l.map(p=>i.jsxs("li",{title:`${p.type}: ${p.closed} closed, ${p.open} open`,children:[i.jsx("span",{className:"t-meta",children:Zs[p.type]}),i.jsxs("span",{className:"mix-bar",children:[i.jsx("i",{className:"closed",style:{width:`${p.closed/d*100}%`}}),i.jsx("i",{className:"open",style:{width:`${p.open/d*100}%`}})]}),i.jsx("b",{children:p.open+p.closed})]},p.type))})]})]})}function WA(e){const[t,s]=y.useState(!1);return i.jsxs("div",{className:t?"status-drawer open":"status-drawer",children:[i.jsxs("button",{type:"button",className:"status-toggle","aria-expanded":t,onPointerDown:o=>o.stopPropagation(),onClick:()=>s(!t),children:["Summary ",i.jsx("span",{className:"caret",children:t?"▾":"▴"})]}),i.jsx(UA,{snap:e.snap,sessions:e.sessions})]})}function HA(){const e=zt();return e?`Describe your idea here, then turn your agents on for it in ${e.label}. Scout frames it with you here, then they get to work.`:"Describe your idea here, or start it in Claude Code or Codex. Scout frames it with you, then your agents get to work."}function KA({planOnly:e,verifies:t}){const s=[["frontier","Ready"],["claimed","Working"],...t?[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]]:[],["stalled","Stalled"],["blocked","Backlog"],["decided","Done"],...e?[["parked","Parked"]]:[],["out-of-scope","Cancelled"],["waiting","Waiting on you"]];return i.jsxs("div",{className:"legend",children:[s.map(([o,a])=>i.jsxs("span",{className:`lg st-${o}`,children:[i.jsx("i",{}),a]},o)),i.jsx("span",{className:"lg hitl",children:"● needs human"})]})}function VA(e){var o,a,l;const{snap:t,selection:s}=e.api;return i.jsxs(Be,{as:"main",className:"zone map-zone",style:{gridArea:"map"},children:[t&&!zt()&&i.jsx(C$,{}),(o=e.trail)==null?void 0:o.banner,i.jsxs("div",{className:"map-area",children:[t&&!e.compact&&i.jsx(WA,{snap:t,sessions:e.sessions}),t?i.jsx(FA,{snap:t,sessions:e.sessions,leases:e.api.leases,selection:s,onSelect:e.onSelect,minFit:e.minFit,preview:(a=e.trail)==null?void 0:a.preview}):i.jsxs("div",{className:"nomap",children:[i.jsx(Sn,{title:"No trail yet",hint:HA()}),i.jsx("div",{className:"actions",children:i.jsx(M,{variant:"primary",onClick:e.onNewTrail,"data-tip":"Describe the idea and create the trail",children:"New trail…"})}),zt()?i.jsx(M,{onClick:ev,children:(l=zt())==null?void 0:l.label}):i.jsx(Na,{command:'/scout new "your idea"'})]}),t&&e.compact&&i.jsx(KA,{planOnly:t.map.mode==="plan-only",verifies:(t.map.verification??"off")!=="off"})]})]})}const GA=[["home","Inbox"],["map","Map"],["ticket","Ticket"],["activity","Activity"],["plan","Plan"]];function qA(e){const{tab:t,covered:s,pending:o}=e;return i.jsx("nav",{className:"tabbar",children:GA.map(([a,l])=>i.jsxs("button",{className:t===a&&!s?"on":"",onClick:()=>e.onPick(a),children:[l,a==="home"&&o>0&&i.jsx(fs,{n:o,urgent:!0,pop:!0},o)]},a))})}function QA(e){const t={home:e.projects?i.jsxs("div",{className:"phone-home",children:[e.projects,e.inbox]}):e.inbox,map:e.map,ticket:i.jsx(Be,{className:"zone",children:e.ticket}),activity:i.jsx(Be,{className:"zone",children:e.activity}),plan:e.plan};return i.jsx("main",{className:"phone-view",children:e.decisions||t[e.tab]})}const Tp={settingsPage:!0},Ep=()=>Sv(new URLSearchParams(location.search).get("settings")),Ap=()=>{var e;return!!((e=history.state)!=null&&e.settingsPage)};function YA(){const[e,t]=y.useState(Ep);y.useEffect(()=>{e&&!Ap()&&(history.replaceState(null,"",tr(location.href,null)),history.pushState(Tp,"",tr(location.href,e)));const l=()=>t(Ep());return window.addEventListener("popstate",l),()=>window.removeEventListener("popstate",l)},[]);const s=l=>{const d=tr(location.href,l);e?history.replaceState(history.state,"",d):history.pushState(Tp,"",d),t(l)},o=()=>{e&&(t(null),Ap()?history.back():history.replaceState(null,"",tr(location.href,null)))},a=l=>s(Sv(l??"")??{});return{route:e,open:a,show:s,close:o,toggle:()=>e?o():a()}}function JA(e,t){const{activity:s,selection:o,setSelection:a,actions:l}=e,[d,h]=y.useState("ticket"),[f,p]=y.useState("home"),[v,k]=y.useState(0),[w,j]=y.useState(null),[N,S]=y.useState(!1),I=H=>{S(!1),j({focus:H})},$=()=>{j(null),S(H=>!H)};y.useEffect(()=>{const H=s.sessions.find(G=>G.id===e.chatSession);!o&&(H!=null&&H.ticketId)&&H.mapId===e.mapId&&a({kind:"ticket",id:H.ticketId})},[e.chatSession,e.mapId]);const _=H=>{a(H),H&&(t==="laptop"&&h("ticket"),t==="mobile"&&p("ticket"))},O=(H,G,oe)=>{oe&&oe!==e.mapId&&l.selectMap(oe),l.openChat(H);const Q=s.sessions.find(ke=>ke.id===H);G&&(Q==null?void 0:Q.mapId)===(oe??e.mapId)&&a({kind:"ticket",id:G}),t==="mobile"&&(p("home"),k(ke=>ke+1))};return{sideTab:d,setSideTab:h,phoneTab:f,setPhoneTab:p,convRequest:v,decisionsView:w,setDecisionsView:j,openDecisions:I,statsOpen:N,setStatsOpen:S,toggleStats:$,select:_,openChat:O,showChat:(H,G,oe)=>{O(H,G,oe),k(Q=>Q+1)},openTicket:(H,G)=>{H!==e.mapId&&l.selectMap(H),a({kind:"ticket",id:G}),j(null),t==="laptop"&&h("ticket"),t==="mobile"&&p("ticket")}}}function XA(e,t){y.useEffect(()=>{document.title=`${Z.name}: ${e?`(${e}) `:""}${t??"No trail"}`},[e,t])}function ZA(e){const[t,s]=y.useState("…");return y.useEffect(()=>{fetch(`${pe()}/list`).then(o=>o.json()).then(o=>{var l;const a=o.root.split("/").filter(Boolean);s((l=a[a.length-1])!=null&&l.startsWith(".")?a[a.length-2]??"repo":a[a.length-1]??"repo")}).catch(()=>s("repo"))},[e]),t}function eI(e,t){return y.useMemo(()=>{const s=e.sessions.filter(a=>a.mapId===t),o=new Set(e.sessions.filter(a=>a.mapId!==t).map(a=>a.id));return{...e,sessions:s,feed:e.feed.filter(a=>!a.sessionId||!o.has(a.sessionId))}},[e,t])}function tI({text:e}){return e.trim()?i.jsx("div",{className:"brief-prose",children:e.split(`
|
|
157
|
+
`).map((t,s)=>i.jsx("p",{children:t.split(/(`[^`]+`|\/?\b[\w.-]+\/[\w./-]+\b)/g).map((o,a)=>a%2===1?i.jsx("code",{children:o.replace(/`/g,"")},a):o)},s))}):i.jsx(Ie,{children:"Not covered"})}const Ip=["summary","productContext","existing","conventions","dataModel","api","risks"];function nI(e){const{brief:t}=e,[s,o]=y.useState(!1),[a,l]=y.useState("");y.useEffect(()=>{const p=v=>v.key==="Escape"&&e.onClose();return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[e]);const d=t.sections,h=Ip.filter(p=>d[p].trim()),f=Ip.filter(p=>!d[p].trim());return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(Be,{as:"div",className:"dialog brief-dialog",onClick:p=>p.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Discovery brief"}),i.jsx("span",{className:"t-meta",children:sI(t)})]}),i.jsxs("div",{className:"brief-body",children:[h.map(p=>i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Yi[p]}),i.jsx(tI,{text:d[p]}),(p==="conventions"||p==="productContext")&&d[p].trim()&&i.jsx(Ud,{draft:()=>({title:`${Yi[p]}: ${d[p].split(`
|
|
158
158
|
`)[0].slice(0,80)}`,body:d[p],kind:p==="conventions"?"convention":"business-rule",sources:[`brief:${t.mapId}`]})})]},p)),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Yi.assumptions}),d.assumptions.length?i.jsx("ul",{className:"item-list",children:d.assumptions.map(p=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:p.text}),i.jsx(V,{parts:[{text:p.id,code:!0}]})]},p.id))}):i.jsx(Ie,{children:"None listed"})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Yi.openQuestions}),d.openQuestions.length?i.jsx("ul",{className:"brief-list",children:d.openQuestions.map(p=>i.jsx("li",{children:p},p))}):i.jsx(Ie,{children:"None"})]}),f.length>0&&i.jsxs("p",{className:"t-meta brief-empty",children:["Nothing noted on ",f.map(p=>Yi[p].toLowerCase()).join(", "),"."]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your last request"}),i.jsx("p",{children:t.note})]})]}),s&&i.jsx(Ze,{label:"What should change?",children:i.jsx("textarea",{rows:3,value:a,onChange:p=>l(p.target.value),autoFocus:!0})}),e.changed&&e.onReviewAgain&&i.jsx(ya,{what:"The brief",onReviewAgain:e.onReviewAgain}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[t.status==="submitted"&&!s&&i.jsxs(i.Fragment,{children:[i.jsx(M,{onClick:()=>o(!0),children:"Request changes"}),i.jsx(M,{variant:"primary",disabled:e.changed,onClick:e.onAccept,children:"Accept brief"})]}),s&&i.jsxs(i.Fragment,{children:[i.jsx(M,{variant:"ghost",onClick:()=>o(!1),children:"Back"}),i.jsx(M,{variant:"primary",disabled:!a.trim(),onClick:()=>e.onRequestChanges(a.trim()),children:"Send to the agent"})]}),i.jsx(M,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}function sI(e){if(e.status==="draft")return"Not submitted yet";const t=[e.status.replace("-"," ")];return e.author&&t.push(`by ${e.author}`),e.submittedAt&&t.push(`${hn(Date.now()-e.submittedAt)} ago`),t.join(" · ")}function iI({brief:e,onReview:t}){return e.status!=="submitted"?null:i.jsx("div",{className:"brief-card",children:i.jsx(be,{edge:"attention",title:"Discovery brief ready for your review",context:i.jsx(V,{parts:["Discovery brief",e.author&&`by ${e.author}`]}),detail:e.sections.summary.split(`
|
|
159
|
-
`)[0],detailText:e.sections.summary,onOpen:t})})}const rI={draft:["Discovery in progress","An agent maps the existing system before anything is built."],submitted:["Discovery brief ready for your review","Implementation starts once you accept it."],"changes-requested":["You asked for changes","Waiting for the revised discovery brief."],accepted:["Discovery brief accepted",""]};function oI({brief:e,onReview:t}){if(e.status==="accepted")return null;const[s,o]=rI[e.status],a=e.status==="submitted"?"edge-attention":"edge-neutral";return i.jsxs("div",{className:`discovery-banner map-banner ${a} st-${e.status}`,role:"status",children:[i.jsxs("span",{className:"mb-text",children:[i.jsx("span",{className:"mb-lead",children:s}),i.jsx("span",{className:"t-meta",children:o})]}),i.jsx(ii,{text:"Before implementation, an agent maps the existing system: the files involved, conventions, data and API impact, risks and assumptions. You accept the brief or ask for changes; task, execute and prototype tickets can't be claimed until you accept it."}),i.jsx(M,{size:"sm",variant:e.status==="submitted"?"primary":"ghost",onClick:t,children:e.status==="submitted"?"Review brief":"Open brief"})]})}const rk=`${pe()}/briefs`;async function aI(e){if(!e)return{brief:null};const t=await fetch(`${rk}?mapId=${encodeURIComponent(e)}`);return t.ok?await t.json():{brief:null}}function lI(e){const t=e==null?void 0:e.map.id,[s,o]=y.useState(null),[a,l]=y.useState(),[d,h]=y.useState(),{reload:f,pushed:p}=Ye({view:t,version:e==null?void 0:e.tickets.reduce((w,j)=>Math.max(w,j.updatedAt),e.map.updatedAt),load:()=>aI(t),show:w=>{o(w.brief),h(w.hash)},failed:()=>o(null),changed:w=>w.startsWith("briefs/")}),
|
|
160
|
-
`):"",banner:l&&i.jsx(oI,{brief:l,onReview:a}),inboxCard:l&&i.jsx(iI,{brief:l,onReview:a}),dialog:l&&s&&i.jsx(nI,{brief:l,error:t.error,changed:d.changed,onReviewAgain:d.reviewAgain,onAccept:()=>void t.accept(d.hash).then(f=>f&&o(!1)),onRequestChanges:f=>void t.requestChanges(f).then(p=>p&&o(!1)),onClose:()=>o(!1)})}}function dI(e){var p;const{reroute:t,onReview:s}=e,o=t.kind==="challenge-destination",a=((p=t.frozen)==null?void 0:p.length)??0,l=o?"wrong mountain?":"proposes a new plan",d=a?` ${a} ticket${a===1?" is":"s are"} closed until you decide.`:"",h=t.wide?" It touches most of the open tickets, so nothing is frozen.":"",f=`${t.reason.replace(/\.$/,"")}.${d}${h}`;return i.jsxs("div",{className:"reroute-banner map-banner edge-attention",role:"status",title:f,children:[i.jsxs("span",{className:"mb-text",children:[i.jsxs("span",{className:"mb-lead",children:[t.by," ",l]}),i.jsx("span",{className:"t-meta",children:f})]}),i.jsx(ii,{text:"An agent found that an assumption or the plan no longer holds and proposes changes. The map shows them: dashed outlines are tickets it adds, struck ones it cancels, ❄ marks tickets frozen until you approve or reject. Nothing changes until you decide."}),i.jsx(M,{size:"sm",variant:"ghost",className:"reroute-dismiss",onClick:e.onDismiss,children:"Dismiss"}),i.jsx(M,{size:"sm",variant:"primary",onClick:s,children:"Review"})]})}const uI=e=>e.changes.flatMap(t=>"ticket"in t?[t.ticket]:[]);function hI(e,t){const s=new Set(uI(t));return e.tickets.filter(o=>s.has(o.id)&&o.updatedAt>t.at).map(o=>({key:o.key,title:o.title,what:fI(o)}))}function fI(e){return e.state==="closed"?"closed":e.assignee?`claimed by ${e.assignee}`:"changed"}function mI({parts:e}){return i.jsx("dl",{className:"reroute-parts",children:e.map(t=>i.jsxs("div",{children:[i.jsx("dt",{className:"t-label",children:t.label}),i.jsx("dd",{className:"t-body",children:t.text})]},t.label))})}const pI={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"},ok="Dismissed by the trail lead. Carry on with the current plan.",gI="Declined by the trail lead.";function vI(e,t){var s,o,a;switch(e.op){case"edit_ticket":return[...(s=e.title)!=null&&s.trim()?[{label:"New title",text:e.title.trim()}]:[],...(o=e.body)!=null&&o.trim()?[{label:"New description (replaces the old one)",text:e.body.trim()}]:[]];case"add_ticket":return[...(a=e.body)!=null&&a.trim()?[{label:"Description",text:e.body.trim()}]:[],{label:"Who decides",text:e.hitl?"You (HITL)":"Agents, without you"}];case"supersede_decision":return[{label:`New answer to ${e.decision}`,text:e.answer},{label:"Rationale",text:e.rationale},{label:"Recorded as",text:`Proposed by ${t}, approved by you; the words stay ${t}'s.`}];default:return[]}}function kI(e,t){var s;switch(e.op){case"add_ticket":{const o=(s=e.blockedBy)!=null&&s.length?`after ${e.blockedBy.map(t).join(", ")}`:void 0;return{verb:"Add",text:e.title,detail:[`new ${e.type} ticket`,o].filter(Boolean).join(" · ")}}case"cancel_ticket":return{verb:"Cancel",text:t(e.ticket),detail:e.reason};case"edit_ticket":return{verb:"Revise",text:t(e.ticket),detail:yI(e)};case"rewire":return{verb:"Rewire",text:t(e.ticket),detail:wI(e,t)};case"supersede_decision":return{verb:"Supersede",text:e.decision,detail:"Replaced by the answer below"};case"update_destination":return{verb:"Destination",text:e.text};case"add_unspecified":return{verb:"Not yet specified",text:e.text};case"add_out_of_scope":return{verb:"Out of scope",text:e.text};case"reopen":return{verb:"Reopen",text:t(e.ticket),detail:`Back in the queue: ${e.reason}`};case"skip_discovery":return{verb:"Skip discovery",text:"Implementation stops waiting for a discovery brief",detail:"The discovery ticket is ruled out"};case"set_mode":return{verb:"Mode",text:e.mode,detail:e.mode==="plan-only"?"Execute tickets wait":"Execute tickets can be worked"};default:return e}}function yI(e){var s,o;return[((s=e.title)==null?void 0:s.trim())&&"New title",((o=e.body)==null?void 0:o.trim())&&"new description"].filter(Boolean).join(" and ").replace(/^new/,"New")}function wI(e,t){var o,a;return[...(o=e.addBlockedBy)!=null&&o.length?[`now also after ${e.addBlockedBy.map(t).join(", ")}`]:[],...(a=e.removeBlockedBy)!=null&&a.length?[`no longer after ${e.removeBlockedBy.map(t).join(", ")}`]:[]].join(" · ")}const xI=new Set(["cancel_ticket","update_destination"]);function jI(e){const{change:t,name:s}=e,o=kI(t,s),a=vI(t,e.by);return i.jsx(be,{as:"li",className:`reroute-change op-${t.op}`,edge:xI.has(t.op)?"attention":"neutral",title:o.text,titleText:o.text,context:i.jsx(V,{parts:[{text:o.verb,strong:!0}]}),detail:o.detail,detailText:o.detail,below:a.length?i.jsx(mI,{parts:a}):void 0})}function SI(e){const{reason:t,destination:s}=e;return i.jsxs("section",{className:"reroute-destination",children:[t&&i.jsx("p",{className:"reroute-destination-why",children:pI[t]}),s&&i.jsxs("div",{className:"reroute-destination-diff",children:[i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Destination now"}),i.jsx("p",{className:"before",children:s.before||"—"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Suggested destination"}),i.jsx("p",{className:"after",children:s.after})]})]})]})}function NI(e){return i.jsxs("section",{className:"reroute-drift edge-note edge-attention",children:[i.jsx("h3",{className:"mono-label",children:"Changed since it was proposed"}),i.jsx("ul",{className:"item-list",children:e.changed.map(t=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:t.title}),i.jsx(V,{parts:[{text:t.key,code:!0},t.what]})]},t.key))}),i.jsxs("label",{className:"reroute-seen t-body",children:[i.jsx("input",{type:"checkbox",checked:e.seen,onChange:t=>e.onSeen(t.target.checked)})," I’ve seen what changed: apply the proposal to the trail as it is now"]})]})}function bI(e,t){const s=new Map(e.tickets.map(a=>[a.id,a.key])),o=new Map(t.flatMap(a=>a.op==="add_ticket"?[[a.ref,a.title]]:[]));return a=>{const l=s.get(a);if(l)return l;const d=o.get(a);return d?`new: ${d}`:a}}function $I(e){var _,O;const{reroute:t,snap:s}=e,[o,a]=y.useState(""),[l,d]=y.useState(!1);y.useEffect(()=>{const D=q=>q.key==="Escape"&&e.onClose();return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[e]);const h=bI(s,t.changes),f=new Map(s.tickets.map(D=>[D.id,`${D.key} ${D.title}`])),p=D=>f.get(D)??h(D),k=s.map.sections.assumptions??[],v=t.invalidates.map(D=>k.find(q=>q.id===D)??{id:D,text:""}),w=t.status==="pending",j=w?hI(s,t):[],N=!j.length||l,S=t.kind==="challenge-destination",I=t.lane==="setting",$=I?`${t.by} asks to change your setting`:"Reroute proposal";return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(Be,{as:"div",className:"dialog reroute-dialog",onClick:D=>D.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:S?"Destination challenged":$}),i.jsx(V,{parts:[{text:t.id,code:!0},t.status,`by ${t.by}`,`${hn(Date.now()-t.at)} ago`]})]}),i.jsxs("div",{className:"reroute-body",children:[e.replaced&&i.jsxs("p",{className:"reroute-replaced t-meta edge-note edge-attention",children:[t.by," replaced ",e.replaced," with this proposal while you were reading: review it again."]}),S&&i.jsx(SI,{reason:t.destinationReason,destination:(_=t.diff)==null?void 0:_.destination}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Why"}),i.jsx("p",{children:t.reason})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Evidence"}),i.jsx("p",{className:"reroute-evidence",children:t.evidence})]}),v.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Assumptions it invalidates"}),i.jsx("ul",{className:"item-list",children:v.map(D=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:D.text}),i.jsx(V,{parts:[{text:D.id,code:!0}]})]},D.id))})]}),i.jsxs("section",{children:[i.jsxs("h3",{className:"mono-label",children:["Changes · ",t.changes.length]}),i.jsx("ul",{className:"reroute-changes row-list",children:t.changes.map((D,q)=>i.jsx(jI,{change:D,by:t.by,name:p},q))})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Closed until you decide"}),t.wide&&i.jsxs("p",{className:"t-meta",children:["It touches ",t.wide.touched," of ",t.wide.open," open tickets, so it freezes none: the current plan stands until you decide."]}),(O=t.frozen)!=null&&O.length?i.jsx("ul",{className:"item-list",children:t.frozen.map(D=>i.jsx("li",{className:"item-text",children:p(D)},D))}):i.jsx(Ie,{children:"No tickets closed"})]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your note"}),i.jsx("p",{children:t.note})]})]}),j.length>0&&i.jsx(NI,{changed:j,seen:l,onSeen:d}),w&&i.jsx(Ze,{label:"Note for the agent (required to reject)",children:i.jsx("textarea",{rows:2,value:o,onChange:D=>a(D.target.value)})}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[w&&i.jsxs(i.Fragment,{children:[i.jsx(M,{className:"reroute-dismiss",variant:"ghost","data-tip":"Reject it without a note of your own",onClick:()=>e.onReject(I?gI:ok),children:I?"Decline":"Dismiss"}),i.jsx(M,{className:"reroute-reject",disabled:!o.trim(),onClick:()=>e.onReject(o.trim()),children:"Reject"}),ov()?i.jsx("span",{className:"vf-intro",children:"Only an owner, or someone they allowed to make high-risk calls, can approve it."}):i.jsx(M,{className:"reroute-approve",variant:"primary",disabled:!N,onClick:()=>e.onApprove(o.trim()),children:"Approve and apply"})]}),i.jsx(M,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}const ak=`${pe()}/reroutes`;async function CI(e){if(!e)return[];const t=await fetch(`${ak}?map=${encodeURIComponent(e)}`);return t.ok?(await t.json()).reroutes:[]}function TI(e){const t=e==null?void 0:e.map.id,[s,o]=y.useState([]),[a,l]=y.useState(),{reload:d}=Ye({view:t,version:e==null?void 0:e.tickets.reduce((f,p)=>Math.max(f,p.updatedAt),e.map.updatedAt),load:()=>CI(t),show:o,failed:()=>o([]),events:{reroute:f=>(f==null?void 0:f.mapId)===t}}),h=async(f,p,k)=>{var N,S;const v=await fetch(`${ak}/${f}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,id:p,note:k,hash:(N=s.find(I=>I.id===p))==null?void 0:N.hash})}),w=await v.json().catch(()=>({}));if(v.ok)return l(void 0),d(),!0;const j=(S=w.errors)==null?void 0:S.map(I=>I.message).join("; ");return l([w.error??`HTTP ${v.status}`,j].filter(Boolean).join(": ")),!1};return{reroutes:s,pending:s.find(f=>f.status==="pending"),error:a,clearError:()=>l(void 0),approve:(f,p)=>h("approve",f,p),reject:(f,p)=>h("reject",f,p)}}function EI(e,t){let s=t;for(let o=0;s&&o<e.length;o++){const a=e.find(l=>l.id===s);if((a==null?void 0:a.status)!=="superseded"||!a.supersededBy)break;s=a.supersededBy}return s!==t?{id:s,replaced:t}:{id:t}}function AI(e,t){const s=TI(e),[o,a]=y.useState(),l=EI(s.reroutes,o),d=s.reroutes.find(v=>v.id===l.id),h=d!=null&&d.diff?d:s.pending,f=()=>{a(void 0),s.clearError()},p=v=>v&&f(),k=s.pending;return{banner:k&&i.jsx(dI,{reroute:k,onReview:()=>a(k.id),onDismiss:()=>void s.reject(k.id,ok)}),preview:e&&(h!=null&&h.diff)?sA(e,h.diff,h.frozen):void 0,openReroute:(v,w)=>{v!==(e==null?void 0:e.map.id)&&(t==null||t(v)),a(w)},dialog:e&&d&&i.jsx($I,{reroute:d,replaced:l.replaced,snap:e,error:s.error,onApprove:v=>void s.approve(d.id,v||void 0).then(p),onReject:v=>void s.reject(d.id,v).then(p),onClose:f},d.id)}}function II(e,t){const s=cI(e),o=AI(e,t);return{briefText:s.briefText,inboxCard:s.inboxCard,review:s.review,banner:i.jsxs(i.Fragment,{children:[s.banner,o.banner]}),preview:o.preview,openReroute:o.openReroute,dialog:i.jsxs(i.Fragment,{children:[s.dialog,o.dialog]})}}function RI(){const e=new URL(location.href);e.searchParams.has(Ys)&&(e.searchParams.delete(Ys),history.replaceState(history.state,"",e))}function MI(e,t){return e.kind!=="question"||t.pending.some(s=>s.id===e.ref)}function LI(e){const[t,s]=y.useState(()=>new URLSearchParams(location.search).get(Ys)??void 0),{loaded:o,view:a,activity:l,handlers:d,showChat:h}=e;return y.useEffect(()=>{if(!t||!o||!a)return;const f=a.items.find(k=>k.id===t);if(f&&!MI(f,l)||(s(void 0),RI(),!f))return;dv(f,{...d,openQuestion:k=>{const v=l.pending.find(w=>w.id===k);v&&h(v.sessionId,v.ticketId)}})},[t,o,a,l,d,h]),{request:y.useCallback(f=>s(f),[])}}function OI(e){const{api:t,nav:s}=e,o=hv(t.allSnaps);f$(o.view);const a=p=>p&&t.actions.selectMap(p),l={openTicket:s.openTicket,openKnowledge:()=>e.knowledge.setOpen(!0),openBrief:p=>p===t.mapId?e.reviewBrief():a(p),openReroute:e.openReroute??(p=>p.ticketId?s.openTicket(p.mapId,p.ticketId):a(p.mapId)),selectTrail:a,openGuides:e.openGuides,openConnector:e.openConnector,openApprovals:e.openApprovals},d=o.view,h=LI({loaded:t.loaded,view:d,activity:t.activity,handlers:l,showChat:s.showChat}),f=d&&i.jsx(c$,{view:d,onFocus:p=>void o.savePrefs(n0(d.prefs,p,Date.now())),onSettings:e.openFocusSettings});return{attention:o,handlers:l,header:f,link:h}}async function PI(){const e=await fetch(`${pe()}/signed-state`);return e.ok?await e.json():null}function _I(){const[e,t]=y.useState();return Ye({load:PI,show:t,failed:()=>t(null),changed:s=>s.endsWith("map.md")||s.includes("/tickets/")||s.includes("/decisions/")}),e}const DI={ticket:"held until you accept or revert it",decision:"what you see is what was signed here, until you accept or revert it"};function zI(e){return e[0]==="added"?"added outside Teamtrail":e.map(t=>t==="words"?"its words":t).join(", ")}function lk({mapId:e,kind:t,id:s}){const o=_I(),a=d=>d.mapId===e&&d.kind===t&&d.id===s,l=o==null?void 0:o.changes.find(a);return l?i.jsx(be,{className:"d-section",edge:"attention",title:"Changed outside Teamtrail",context:i.jsx(V,{parts:[`${zI(l.fields)} · ${DI[t]}`]}),detail:"By a teammate or an agent editing the file. Settings → Approvals shows what changed."}):o!=null&&o.textEdits.some(a)?i.jsx(V,{className:"d-section",parts:["Text edited outside Teamtrail"]}):null}function BI({d:e}){return e.derived?i.jsx(V,{className:"d-section",parts:["Unverified · read from text anyone who can edit the tracker wrote, not a decision Teamtrail recorded"]}):null}function FI(e){const{d:t,snap:s}=e,o=li(),[a,l]=y.useState(!1),[d,h]=y.useState(""),[f,p]=y.useState("");y.useEffect(()=>{l(!1),h(""),p("")},[t.id,t.mapId]);const k=Mx(e.all.filter(S=>S.mapId===t.mapId),t.id),v=dr(t),w=t.ticketId?s==null?void 0:s.tickets.find(S=>S.id===t.ticketId):void 0,j=Date.now(),N=Nn(t.source.url);return i.jsxs("div",{className:"detail dv-d",children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key",children:t.id}),i.jsx(bn,{tone:"state",className:`dv-st-${v}`,children:v}),i.jsx(V,{parts:[p1(t.decidedAt),`${hn(j-t.decidedAt)} ago`]})]}),i.jsx("h3",{className:"t-heading",children:t.question}),i.jsx(lk,{mapId:t.mapId,kind:"decision",id:t.id}),i.jsx(BI,{d:t}),i.jsxs("div",{className:"resolution",children:[i.jsx(dd,{parts:["Decision"]}),i.jsx("p",{children:t.answer})]}),i.jsxs("dl",{className:"facts",children:[i.jsx("dt",{children:"Trail"}),i.jsx("dd",{children:s?`${s.map.key} ${s.map.title}`:t.mapId}),i.jsx("dt",{children:"Ticket"}),i.jsx("dd",{children:t.ticketId?i.jsxs("button",{className:"link",onClick:()=>e.onOpenTicket(t.mapId,t.ticketId),children:[t.ticketKey," ",(w==null?void 0:w.title)??""," · open in trail ›"]}):"—"}),i.jsx("dt",{children:"Decided by"}),i.jsx("dd",{children:[qg(t,o),eg(t)].filter(Boolean).join(", ")}),t.participants.length>1&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Participants"}),i.jsx("dd",{children:t.participants.map(S=>S.name??S.id).join(", ")})]}),i.jsx("dt",{children:"Source"}),i.jsxs("dd",{children:[Jn[t.source.kind].label,N&&i.jsxs(i.Fragment,{children:[" · ",i.jsx("a",{href:N,target:"_blank",rel:"noreferrer",children:t.source.label??"link"})]}),!N&&t.source.label&&` · ${t.source.label}`,t.source.ref&&i.jsxs("span",{className:"ref",children:[" ",t.source.ref]})]})]}),t.alternatives.length>0&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Alternatives"}),i.jsx("ul",{className:"dv-alts",children:t.alternatives.map(S=>i.jsx("li",{children:S},S))})]}),t.rationale&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Rationale"}),i.jsx("p",{children:t.rationale})]}),k.length>1&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Supersession"}),i.jsx("ol",{className:"dv-chain",children:k.map(S=>i.jsx("li",{className:`${S.id===t.id?"cur":""} ${S.supersededBy?"old":"live"}`,children:i.jsxs("button",{onClick:()=>e.onSelect(S.id),children:[i.jsx("i",{}),i.jsx("span",{className:"id",children:S.id}),i.jsx("span",{className:"a",children:S.summary}),i.jsx(V,{parts:[ps(S.decidedBy,o),Xs(S.decidedAt)]})]})},S.id))})]}),i.jsxs("div",{className:"actions",children:[i.jsx(Ud,{draft:()=>({title:t.summary||t.question,body:[t.answer,t.rationale&&`Why: ${t.rationale}`].filter(Boolean).join(`
|
|
159
|
+
`)[0],detailText:e.sections.summary,onOpen:t})})}const rI={draft:["Discovery in progress","An agent maps the existing system before anything is built."],submitted:["Discovery brief ready for your review","Implementation starts once you accept it."],"changes-requested":["You asked for changes","Waiting for the revised discovery brief."],accepted:["Discovery brief accepted",""]};function oI({brief:e,onReview:t}){if(e.status==="accepted")return null;const[s,o]=rI[e.status],a=e.status==="submitted"?"edge-attention":"edge-neutral";return i.jsxs("div",{className:`discovery-banner map-banner ${a} st-${e.status}`,role:"status",children:[i.jsxs("span",{className:"mb-text",children:[i.jsx("span",{className:"mb-lead",children:s}),i.jsx("span",{className:"t-meta",children:o})]}),i.jsx(ii,{text:"Before implementation, an agent maps the existing system: the files involved, conventions, data and API impact, risks and assumptions. You accept the brief or ask for changes; task, execute and prototype tickets can't be claimed until you accept it."}),i.jsx(M,{size:"sm",variant:e.status==="submitted"?"primary":"ghost",onClick:t,children:e.status==="submitted"?"Review brief":"Open brief"})]})}const rk=`${pe()}/briefs`;async function aI(e){if(!e)return{brief:null};const t=await fetch(`${rk}?mapId=${encodeURIComponent(e)}`);return t.ok?await t.json():{brief:null}}function lI(e){const t=e==null?void 0:e.map.id,[s,o]=y.useState(null),[a,l]=y.useState(),[d,h]=y.useState(),{reload:f,pushed:p}=Ye({view:t,version:e==null?void 0:e.tickets.reduce((w,j)=>Math.max(w,j.updatedAt),e.map.updatedAt),load:()=>aI(t),show:w=>{o(w.brief),h(w.hash)},failed:()=>o(null),changed:w=>w.startsWith("briefs/")}),v=(w,j,N)=>fetch(`${rk}/${w}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,note:j,hash:N})}).then(async S=>{const I=await S.json().catch(()=>({}));if(!S.ok||!I.brief)throw new Error(I.error??`HTTP ${S.status}`);l(void 0),p(),o(I.brief)}),k=(w,j,N)=>v(w,j,N).then(()=>!0,S=>(l(S.message),f(),!1));return{brief:s,error:a,hash:d,accept:w=>k("accept",void 0,w),requestChanges:w=>k("request-changes",w)}}function cI(e){const t=lI(e),[s,o]=y.useState(!1),a=()=>o(!0),l=t.brief,d=Sa(s?l==null?void 0:l.mapId:void 0,t.hash),h=l==null?void 0:l.sections;return{review:a,briefText:h?[h.existing,h.conventions,h.dataModel,h.api].join(`
|
|
160
|
+
`):"",banner:l&&i.jsx(oI,{brief:l,onReview:a}),inboxCard:l&&i.jsx(iI,{brief:l,onReview:a}),dialog:l&&s&&i.jsx(nI,{brief:l,error:t.error,changed:d.changed,onReviewAgain:d.reviewAgain,onAccept:()=>void t.accept(d.hash).then(f=>f&&o(!1)),onRequestChanges:f=>void t.requestChanges(f).then(p=>p&&o(!1)),onClose:()=>o(!1)})}}function dI(e){var p;const{reroute:t,onReview:s}=e,o=t.kind==="challenge-destination",a=((p=t.frozen)==null?void 0:p.length)??0,l=o?"wrong mountain?":"proposes a new plan",d=a?` ${a} ticket${a===1?" is":"s are"} closed until you decide.`:"",h=t.wide?" It touches most of the open tickets, so nothing is frozen.":"",f=`${t.reason.replace(/\.$/,"")}.${d}${h}`;return i.jsxs("div",{className:"reroute-banner map-banner edge-attention",role:"status",title:f,children:[i.jsxs("span",{className:"mb-text",children:[i.jsxs("span",{className:"mb-lead",children:[t.by," ",l]}),i.jsx("span",{className:"t-meta",children:f})]}),i.jsx(ii,{text:"An agent found that an assumption or the plan no longer holds and proposes changes. The map shows them: dashed outlines are tickets it adds, struck ones it cancels, ❄ marks tickets frozen until you approve or reject. Nothing changes until you decide."}),i.jsx(M,{size:"sm",variant:"ghost",className:"reroute-dismiss",onClick:e.onDismiss,children:"Dismiss"}),i.jsx(M,{size:"sm",variant:"primary",onClick:s,children:"Review"})]})}const uI=e=>e.changes.flatMap(t=>"ticket"in t?[t.ticket]:[]);function hI(e,t){const s=new Set(uI(t));return e.tickets.filter(o=>s.has(o.id)&&o.updatedAt>t.at).map(o=>({key:o.key,title:o.title,what:fI(o)}))}function fI(e){return e.state==="closed"?"closed":e.assignee?`claimed by ${e.assignee}`:"changed"}function mI({parts:e}){return i.jsx("dl",{className:"reroute-parts",children:e.map(t=>i.jsxs("div",{children:[i.jsx("dt",{className:"t-label",children:t.label}),i.jsx("dd",{className:"t-body",children:t.text})]},t.label))})}const pI={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"},ok="Dismissed by the trail lead. Carry on with the current plan.",gI="Declined by the trail lead.";function vI(e,t){var s,o,a;switch(e.op){case"edit_ticket":return[...(s=e.title)!=null&&s.trim()?[{label:"New title",text:e.title.trim()}]:[],...(o=e.body)!=null&&o.trim()?[{label:"New description (replaces the old one)",text:e.body.trim()}]:[]];case"add_ticket":return[...(a=e.body)!=null&&a.trim()?[{label:"Description",text:e.body.trim()}]:[],{label:"Who decides",text:e.hitl?"You (HITL)":"Agents, without you"}];case"supersede_decision":return[{label:`New answer to ${e.decision}`,text:e.answer},{label:"Rationale",text:e.rationale},{label:"Recorded as",text:`Proposed by ${t}, approved by you; the words stay ${t}'s.`}];default:return[]}}function kI(e,t){var s;switch(e.op){case"add_ticket":{const o=(s=e.blockedBy)!=null&&s.length?`after ${e.blockedBy.map(t).join(", ")}`:void 0;return{verb:"Add",text:e.title,detail:[`new ${e.type} ticket`,o].filter(Boolean).join(" · ")}}case"cancel_ticket":return{verb:"Cancel",text:t(e.ticket),detail:e.reason};case"edit_ticket":return{verb:"Revise",text:t(e.ticket),detail:yI(e)};case"rewire":return{verb:"Rewire",text:t(e.ticket),detail:wI(e,t)};case"supersede_decision":return{verb:"Supersede",text:e.decision,detail:"Replaced by the answer below"};case"update_destination":return{verb:"Destination",text:e.text};case"add_unspecified":return{verb:"Not yet specified",text:e.text};case"add_out_of_scope":return{verb:"Out of scope",text:e.text};case"reopen":return{verb:"Reopen",text:t(e.ticket),detail:`Back in the queue: ${e.reason}`};case"skip_discovery":return{verb:"Skip discovery",text:"Implementation stops waiting for a discovery brief",detail:"The discovery ticket is ruled out"};case"set_mode":return{verb:"Mode",text:e.mode,detail:e.mode==="plan-only"?"Execute tickets wait":"Execute tickets can be worked"};default:return e}}function yI(e){var s,o;return[((s=e.title)==null?void 0:s.trim())&&"New title",((o=e.body)==null?void 0:o.trim())&&"new description"].filter(Boolean).join(" and ").replace(/^new/,"New")}function wI(e,t){var o,a;return[...(o=e.addBlockedBy)!=null&&o.length?[`now also after ${e.addBlockedBy.map(t).join(", ")}`]:[],...(a=e.removeBlockedBy)!=null&&a.length?[`no longer after ${e.removeBlockedBy.map(t).join(", ")}`]:[]].join(" · ")}const xI=new Set(["cancel_ticket","update_destination"]);function jI(e){const{change:t,name:s}=e,o=kI(t,s),a=vI(t,e.by);return i.jsx(be,{as:"li",className:`reroute-change op-${t.op}`,edge:xI.has(t.op)?"attention":"neutral",title:o.text,titleText:o.text,context:i.jsx(V,{parts:[{text:o.verb,strong:!0}]}),detail:o.detail,detailText:o.detail,below:a.length?i.jsx(mI,{parts:a}):void 0})}function SI(e){const{reason:t,destination:s}=e;return i.jsxs("section",{className:"reroute-destination",children:[t&&i.jsx("p",{className:"reroute-destination-why",children:pI[t]}),s&&i.jsxs("div",{className:"reroute-destination-diff",children:[i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Destination now"}),i.jsx("p",{className:"before",children:s.before||"—"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Suggested destination"}),i.jsx("p",{className:"after",children:s.after})]})]})]})}function NI(e){return i.jsxs("section",{className:"reroute-drift edge-note edge-attention",children:[i.jsx("h3",{className:"mono-label",children:"Changed since it was proposed"}),i.jsx("ul",{className:"item-list",children:e.changed.map(t=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:t.title}),i.jsx(V,{parts:[{text:t.key,code:!0},t.what]})]},t.key))}),i.jsxs("label",{className:"reroute-seen t-body",children:[i.jsx("input",{type:"checkbox",checked:e.seen,onChange:t=>e.onSeen(t.target.checked)})," I’ve seen what changed: apply the proposal to the trail as it is now"]})]})}function bI(e,t){const s=new Map(e.tickets.map(a=>[a.id,a.key])),o=new Map(t.flatMap(a=>a.op==="add_ticket"?[[a.ref,a.title]]:[]));return a=>{const l=s.get(a);if(l)return l;const d=o.get(a);return d?`new: ${d}`:a}}function $I(e){var _,O;const{reroute:t,snap:s}=e,[o,a]=y.useState(""),[l,d]=y.useState(!1);y.useEffect(()=>{const D=q=>q.key==="Escape"&&e.onClose();return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[e]);const h=bI(s,t.changes),f=new Map(s.tickets.map(D=>[D.id,`${D.key} ${D.title}`])),p=D=>f.get(D)??h(D),v=s.map.sections.assumptions??[],k=t.invalidates.map(D=>v.find(q=>q.id===D)??{id:D,text:""}),w=t.status==="pending",j=w?hI(s,t):[],N=!j.length||l,S=t.kind==="challenge-destination",I=t.lane==="setting",$=I?`${t.by} asks to change your setting`:"Reroute proposal";return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(Be,{as:"div",className:"dialog reroute-dialog",onClick:D=>D.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:S?"Destination challenged":$}),i.jsx(V,{parts:[{text:t.id,code:!0},t.status,`by ${t.by}`,`${hn(Date.now()-t.at)} ago`]})]}),i.jsxs("div",{className:"reroute-body",children:[e.replaced&&i.jsxs("p",{className:"reroute-replaced t-meta edge-note edge-attention",children:[t.by," replaced ",e.replaced," with this proposal while you were reading: review it again."]}),S&&i.jsx(SI,{reason:t.destinationReason,destination:(_=t.diff)==null?void 0:_.destination}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Why"}),i.jsx("p",{children:t.reason})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Evidence"}),i.jsx("p",{className:"reroute-evidence",children:t.evidence})]}),k.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Assumptions it invalidates"}),i.jsx("ul",{className:"item-list",children:k.map(D=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:D.text}),i.jsx(V,{parts:[{text:D.id,code:!0}]})]},D.id))})]}),i.jsxs("section",{children:[i.jsxs("h3",{className:"mono-label",children:["Changes · ",t.changes.length]}),i.jsx("ul",{className:"reroute-changes row-list",children:t.changes.map((D,q)=>i.jsx(jI,{change:D,by:t.by,name:p},q))})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Closed until you decide"}),t.wide&&i.jsxs("p",{className:"t-meta",children:["It touches ",t.wide.touched," of ",t.wide.open," open tickets, so it freezes none: the current plan stands until you decide."]}),(O=t.frozen)!=null&&O.length?i.jsx("ul",{className:"item-list",children:t.frozen.map(D=>i.jsx("li",{className:"item-text",children:p(D)},D))}):i.jsx(Ie,{children:"No tickets closed"})]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your note"}),i.jsx("p",{children:t.note})]})]}),j.length>0&&i.jsx(NI,{changed:j,seen:l,onSeen:d}),w&&i.jsx(Ze,{label:"Note for the agent (required to reject)",children:i.jsx("textarea",{rows:2,value:o,onChange:D=>a(D.target.value)})}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[w&&i.jsxs(i.Fragment,{children:[i.jsx(M,{className:"reroute-dismiss",variant:"ghost","data-tip":"Reject it without a note of your own",onClick:()=>e.onReject(I?gI:ok),children:I?"Decline":"Dismiss"}),i.jsx(M,{className:"reroute-reject",disabled:!o.trim(),onClick:()=>e.onReject(o.trim()),children:"Reject"}),ov()?i.jsx("span",{className:"vf-intro",children:"Only an owner, or someone they allowed to make high-risk calls, can approve it."}):i.jsx(M,{className:"reroute-approve",variant:"primary",disabled:!N,onClick:()=>e.onApprove(o.trim()),children:"Approve and apply"})]}),i.jsx(M,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}const ak=`${pe()}/reroutes`;async function CI(e){if(!e)return[];const t=await fetch(`${ak}?map=${encodeURIComponent(e)}`);return t.ok?(await t.json()).reroutes:[]}function TI(e){const t=e==null?void 0:e.map.id,[s,o]=y.useState([]),[a,l]=y.useState(),{reload:d}=Ye({view:t,version:e==null?void 0:e.tickets.reduce((f,p)=>Math.max(f,p.updatedAt),e.map.updatedAt),load:()=>CI(t),show:o,failed:()=>o([]),events:{reroute:f=>(f==null?void 0:f.mapId)===t}}),h=async(f,p,v)=>{var N,S;const k=await fetch(`${ak}/${f}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,id:p,note:v,hash:(N=s.find(I=>I.id===p))==null?void 0:N.hash})}),w=await k.json().catch(()=>({}));if(k.ok)return l(void 0),d(),!0;const j=(S=w.errors)==null?void 0:S.map(I=>I.message).join("; ");return l([w.error??`HTTP ${k.status}`,j].filter(Boolean).join(": ")),!1};return{reroutes:s,pending:s.find(f=>f.status==="pending"),error:a,clearError:()=>l(void 0),approve:(f,p)=>h("approve",f,p),reject:(f,p)=>h("reject",f,p)}}function EI(e,t){let s=t;for(let o=0;s&&o<e.length;o++){const a=e.find(l=>l.id===s);if((a==null?void 0:a.status)!=="superseded"||!a.supersededBy)break;s=a.supersededBy}return s!==t?{id:s,replaced:t}:{id:t}}function AI(e,t){const s=TI(e),[o,a]=y.useState(),l=EI(s.reroutes,o),d=s.reroutes.find(k=>k.id===l.id),h=d!=null&&d.diff?d:s.pending,f=()=>{a(void 0),s.clearError()},p=k=>k&&f(),v=s.pending;return{banner:v&&i.jsx(dI,{reroute:v,onReview:()=>a(v.id),onDismiss:()=>void s.reject(v.id,ok)}),preview:e&&(h!=null&&h.diff)?sA(e,h.diff,h.frozen):void 0,openReroute:(k,w)=>{k!==(e==null?void 0:e.map.id)&&(t==null||t(k)),a(w)},dialog:e&&d&&i.jsx($I,{reroute:d,replaced:l.replaced,snap:e,error:s.error,onApprove:k=>void s.approve(d.id,k||void 0).then(p),onReject:k=>void s.reject(d.id,k).then(p),onClose:f},d.id)}}function II(e,t){const s=cI(e),o=AI(e,t);return{briefText:s.briefText,inboxCard:s.inboxCard,review:s.review,banner:i.jsxs(i.Fragment,{children:[s.banner,o.banner]}),preview:o.preview,openReroute:o.openReroute,dialog:i.jsxs(i.Fragment,{children:[s.dialog,o.dialog]})}}function RI(){const e=new URL(location.href);e.searchParams.has(Ys)&&(e.searchParams.delete(Ys),history.replaceState(history.state,"",e))}function MI(e,t){return e.kind!=="question"||t.pending.some(s=>s.id===e.ref)}function LI(e){const[t,s]=y.useState(()=>new URLSearchParams(location.search).get(Ys)??void 0),{loaded:o,view:a,activity:l,handlers:d,showChat:h}=e;return y.useEffect(()=>{if(!t||!o||!a)return;const f=a.items.find(v=>v.id===t);if(f&&!MI(f,l)||(s(void 0),RI(),!f))return;dv(f,{...d,openQuestion:v=>{const k=l.pending.find(w=>w.id===v);k&&h(k.sessionId,k.ticketId)}})},[t,o,a,l,d,h]),{request:y.useCallback(f=>s(f),[])}}function OI(e){const{api:t,nav:s}=e,o=hv(t.allSnaps);f$(o.view);const a=p=>p&&t.actions.selectMap(p),l={openTicket:s.openTicket,openKnowledge:()=>e.knowledge.setOpen(!0),openBrief:p=>p===t.mapId?e.reviewBrief():a(p),openReroute:e.openReroute??(p=>p.ticketId?s.openTicket(p.mapId,p.ticketId):a(p.mapId)),selectTrail:a,openGuides:e.openGuides,openConnector:e.openConnector,openApprovals:e.openApprovals},d=o.view,h=LI({loaded:t.loaded,view:d,activity:t.activity,handlers:l,showChat:s.showChat}),f=d&&i.jsx(c$,{view:d,onFocus:p=>void o.savePrefs(n0(d.prefs,p,Date.now())),onSettings:e.openFocusSettings});return{attention:o,handlers:l,header:f,link:h}}async function PI(){const e=await fetch(`${pe()}/signed-state`);return e.ok?await e.json():null}function _I(){const[e,t]=y.useState();return Ye({load:PI,show:t,failed:()=>t(null),changed:s=>s.endsWith("map.md")||s.includes("/tickets/")||s.includes("/decisions/")}),e}const DI={ticket:"held until you accept or revert it",decision:"what you see is what was signed here, until you accept or revert it"};function zI(e){return e[0]==="added"?"added outside Teamtrail":e.map(t=>t==="words"?"its words":t).join(", ")}function lk({mapId:e,kind:t,id:s}){const o=_I(),a=d=>d.mapId===e&&d.kind===t&&d.id===s,l=o==null?void 0:o.changes.find(a);return l?i.jsx(be,{className:"d-section",edge:"attention",title:"Changed outside Teamtrail",context:i.jsx(V,{parts:[`${zI(l.fields)} · ${DI[t]}`]}),detail:"By a teammate or an agent editing the file. Settings → Approvals shows what changed."}):o!=null&&o.textEdits.some(a)?i.jsx(V,{className:"d-section",parts:["Text edited outside Teamtrail"]}):null}function BI({d:e}){return e.derived?i.jsx(V,{className:"d-section",parts:["Unverified · read from text anyone who can edit the tracker wrote, not a decision Teamtrail recorded"]}):null}function FI(e){const{d:t,snap:s}=e,o=li(),[a,l]=y.useState(!1),[d,h]=y.useState(""),[f,p]=y.useState("");y.useEffect(()=>{l(!1),h(""),p("")},[t.id,t.mapId]);const v=Mx(e.all.filter(S=>S.mapId===t.mapId),t.id),k=dr(t),w=t.ticketId?s==null?void 0:s.tickets.find(S=>S.id===t.ticketId):void 0,j=Date.now(),N=Nn(t.source.url);return i.jsxs("div",{className:"detail dv-d",children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key",children:t.id}),i.jsx(bn,{tone:"state",className:`dv-st-${k}`,children:k}),i.jsx(V,{parts:[p1(t.decidedAt),`${hn(j-t.decidedAt)} ago`]})]}),i.jsx("h3",{className:"t-heading",children:t.question}),i.jsx(lk,{mapId:t.mapId,kind:"decision",id:t.id}),i.jsx(BI,{d:t}),i.jsxs("div",{className:"resolution",children:[i.jsx(dd,{parts:["Decision"]}),i.jsx("p",{children:t.answer})]}),i.jsxs("dl",{className:"facts",children:[i.jsx("dt",{children:"Trail"}),i.jsx("dd",{children:s?`${s.map.key} ${s.map.title}`:t.mapId}),i.jsx("dt",{children:"Ticket"}),i.jsx("dd",{children:t.ticketId?i.jsxs("button",{className:"link",onClick:()=>e.onOpenTicket(t.mapId,t.ticketId),children:[t.ticketKey," ",(w==null?void 0:w.title)??""," · open in trail ›"]}):"—"}),i.jsx("dt",{children:"Decided by"}),i.jsx("dd",{children:[qg(t,o),eg(t)].filter(Boolean).join(", ")}),t.participants.length>1&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Participants"}),i.jsx("dd",{children:t.participants.map(S=>S.name??S.id).join(", ")})]}),i.jsx("dt",{children:"Source"}),i.jsxs("dd",{children:[Jn[t.source.kind].label,N&&i.jsxs(i.Fragment,{children:[" · ",i.jsx("a",{href:N,target:"_blank",rel:"noreferrer",children:t.source.label??"link"})]}),!N&&t.source.label&&` · ${t.source.label}`,t.source.ref&&i.jsxs("span",{className:"ref",children:[" ",t.source.ref]})]})]}),t.alternatives.length>0&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Alternatives"}),i.jsx("ul",{className:"dv-alts",children:t.alternatives.map(S=>i.jsx("li",{children:S},S))})]}),t.rationale&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Rationale"}),i.jsx("p",{children:t.rationale})]}),v.length>1&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Supersession"}),i.jsx("ol",{className:"dv-chain",children:v.map(S=>i.jsx("li",{className:`${S.id===t.id?"cur":""} ${S.supersededBy?"old":"live"}`,children:i.jsxs("button",{onClick:()=>e.onSelect(S.id),children:[i.jsx("i",{}),i.jsx("span",{className:"id",children:S.id}),i.jsx("span",{className:"a",children:S.summary}),i.jsx(V,{parts:[ps(S.decidedBy,o),Xs(S.decidedAt)]})]})},S.id))})]}),i.jsxs("div",{className:"actions",children:[i.jsx(Ud,{draft:()=>({title:t.summary||t.question,body:[t.answer,t.rationale&&`Why: ${t.rationale}`].filter(Boolean).join(`
|
|
161
161
|
|
|
162
|
-
`),kind:"product-decision",sources:[`decision:${t.id}`,...t.ticketKey?[`ticket:${t.ticketKey}`]:[]]})}),v==="active"&&!t.postedBy&&i.jsx(M,{on:a,onClick:()=>l(S=>!S),"data-tip":"Replace this decision with a new answer. Both stay on record",children:"Supersede…"})]}),a&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),d.trim()&&(e.onSupersede(t,{answer:d.trim(),rationale:f.trim(),alternatives:[t.summary]}),l(!1))},children:[i.jsx(Ze,{label:"New decision",children:i.jsx("textarea",{rows:3,value:d,onChange:S=>h(S.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Rationale",children:i.jsx("input",{value:f,onChange:S=>p(S.target.value)})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(M,{variant:"ghost",onClick:()=>l(!1),children:"Cancel"}),i.jsx(M,{type:"submit",variant:"primary",disabled:!d.trim(),children:"Supersede"})]})]}),i.jsxs("div",{className:"dv-sec",children:[i.jsxs("h4",{className:"mono-label",children:["Transcript ",i.jsx("span",{className:"n",children:t.transcript.length})]}),t.transcript.length?i.jsx("div",{className:"dv-transcript comms-log",children:t.transcript.map((S,I)=>i.jsxs("div",{className:`msg from-${S.from} voice-${S.from==="human"?"human":"agent"}`,children:[i.jsx(dd,{parts:[ps(S.author,o),Id(S.at)]}),i.jsx("div",{className:"msg-text",children:S.text})]},I))}):i.jsx(Ie,{children:"None recorded"})]})]})}function _t(e){return i.jsx("li",{children:i.jsxs("button",{className:`dv-opt ${e.on?"on":""} ${e.cls??""}`,onClick:e.onClick,children:[i.jsx("span",{className:"ttl",children:e.label}),i.jsx("b",{children:e.n})]})})}function UI(e){const{filter:t,set:s,all:o}=e,a=l=>o.filter(l).length;return e.compact?i.jsxs("div",{className:"dv-filters compact",children:[i.jsx(at,{compact:!0,"aria-label":"Trail",value:t.mapId??"",onChange:l=>s({mapId:l||void 0}),options:[{value:"",label:"All trails"},...e.trails.map(l=>({value:l.map.id,label:`${l.map.key} ${l.map.title}`}))]}),i.jsx(at,{compact:!0,"aria-label":"Source",value:t.source??"",onChange:l=>s({source:l||void 0}),options:[{value:"",label:"All sources"},...Fo.map(l=>({value:l,label:Jn[l].label}))]}),i.jsx(at,{compact:!0,"aria-label":"Decided by",value:t.decidedBy??"",onChange:l=>s({decidedBy:l||void 0}),options:[{value:"",label:"Anyone"},...e.people.map(l=>({value:l,label:l}))]}),i.jsx(at,{compact:!0,"aria-label":"Status",value:t.status??"",onChange:l=>s({status:l||void 0}),options:[{value:"",label:"Any status"},{value:"active",label:"Active"},{value:"superseded",label:"Superseded"}]})]}):i.jsxs("aside",{className:"dv-filters",children:[i.jsx("h3",{className:"mono-label",children:"Trail"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.mapId,label:"All trails",n:o.length,onClick:()=>s({mapId:void 0})}),e.trails.map(l=>i.jsx(_t,{on:t.mapId===l.map.id,label:`${l.map.key} ${l.map.title}`,n:a(d=>d.mapId===l.map.id),onClick:()=>s({mapId:l.map.id})},l.map.id))]}),i.jsx("h3",{className:"mono-label",children:"Source"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.source,label:"All",n:o.length,onClick:()=>s({source:void 0})}),Fo.map(l=>i.jsx(_t,{cls:`src-${l}`,on:t.source===l,label:Jn[l].label,n:a(d=>d.source.kind===l),onClick:()=>s({source:t.source===l?void 0:l})},l))]}),i.jsx("h3",{className:"mono-label",children:"Made by"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.madeBy,label:"Anyone",n:o.length,onClick:()=>s({madeBy:void 0})}),i.jsx(_t,{on:t.madeBy==="agent",label:"Agents, on their own",n:a(l=>rr(l)==="agent"),onClick:()=>s({madeBy:t.madeBy==="agent"?void 0:"agent"})}),i.jsx(_t,{on:t.madeBy==="human",label:"People",n:a(l=>rr(l)==="human"),onClick:()=>s({madeBy:t.madeBy==="human"?void 0:"human"})})]}),i.jsx("h3",{className:"mono-label",children:"Decided by"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.decidedBy,label:"Anyone",n:o.length,onClick:()=>s({decidedBy:void 0})}),e.people.map(l=>i.jsx(_t,{on:t.decidedBy===l,label:l,n:a(d=>d.decidedBy===l),onClick:()=>s({decidedBy:t.decidedBy===l?void 0:l})},l))]}),i.jsx("h3",{className:"mono-label",children:"Status"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.status,label:"Any",n:o.length,onClick:()=>s({status:void 0})}),i.jsx(_t,{on:t.status==="active",label:"Active",n:a(l=>!l.supersededBy),onClick:()=>s({status:t.status==="active"?void 0:"active"})}),i.jsx(_t,{on:t.status==="superseded",label:"Superseded",n:a(l=>!!l.supersededBy),onClick:()=>s({status:t.status==="superseded"?void 0:"superseded"})})]})]})}const Rp=e=>`${e.mapId}/${e.id}`;function WI(e,t){var a;const s=new Map;for(const l of e){const d=((a=t[Rp(l)])==null?void 0:a.area)??Tc;s.set(d,[...s.get(d)??[],l])}const o=l=>{var d;return((d=t[Rp(l)])==null?void 0:d.citedBy.length)??0};return[...s].map(([l,d])=>({area:l,rows:[...d].sort((h,f)=>o(f)-o(h)||f.decidedAt-h.decidedAt)})).sort((l,d)=>+(l.area===Tc)-+(d.area===Tc)||d.rows.length-l.rows.length||l.area.localeCompare(d.area))}function HI(e){if(dr(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function KI(e){const{d:t}=e,s=li(),o=dr(t);return i.jsxs(i.Fragment,{children:[e.newDay&&i.jsx("li",{className:"dv-day t-label",children:e.group??Xs(t.decidedAt)}),i.jsx(be,{as:"li",className:`dv-row ${o}`,selected:e.on,onOpen:e.onClick,title:t.question,titleText:t.question,trailing:Id(t.decidedAt),context:i.jsx(V,{parts:[{text:t.id,code:!0},t.ticketKey&&{text:t.ticketKey,code:!0},e.showTrail&&e.trail,qg(t,s),eg(t)??Jn[t.source.kind].label,HI(t),!!e.cited&&`cited ${e.cited}×`]}),detail:t.summary,detailText:t.summary})]})}function VI(e){const{rows:t,current:s,memory:o}=e,a=(l,d,h)=>{var f,p;return i.jsx(KI,{d:l,newDay:d,group:h,cited:(f=o==null?void 0:o[`${l.mapId}/${l.id}`])==null?void 0:f.citedBy.length,trail:(p=e.snaps[l.mapId])==null?void 0:p.map.key,on:(s==null?void 0:s.id)===l.id&&s.mapId===l.mapId,showTrail:e.showTrail,onClick:()=>e.onSelect(l.id)},`${l.mapId}:${l.id}`)};return o&&t.length?i.jsx("ol",{className:"dv-list","aria-label":"Logbook by area",children:WI(t,o).flatMap(l=>l.rows.map((d,h)=>a(d,h===0,`${l.area} · ${l.rows.length}`)))}):i.jsx("ol",{className:"dv-list","aria-label":"Logbook",children:t.length?t.map((l,d)=>a(l,d===0||Xs(t[d-1].decidedAt)!==Xs(l.decidedAt))):i.jsx(Ie,{children:"No decisions"})})}function GI({stats:e}){return i.jsxs("span",{className:"dv-readouts",children:[i.jsx(ln,{layout:"start",label:"Active",value:e.active}),i.jsx(ln,{layout:"start",label:"Superseded",value:e.superseded}),i.jsx(ln,{layout:"start",label:"Last 24h",value:e.last24h}),i.jsx(ln,{layout:"start",label:"Human",value:`${e.total?Math.round(e.human/e.total*100):0}%`}),i.jsx(V,{className:"dv-src-mix",parts:Fo.filter(t=>e.bySource[t]).map(t=>`${Jn[t].label} ${e.bySource[t]}`)})]})}function qI(e){const{filter:t}=e,o=Object.values(t).filter(Boolean).length-(t.query?1:0),a=e.filtersOpen||o>0;return i.jsxs("div",{className:"dv-search",children:[i.jsx("input",{type:"search",placeholder:"Search decisions",value:t.query??"",onChange:l=>e.set({query:l.target.value})}),e.showToggle&&i.jsxs("button",{className:`chip ${a?"on":""}`,onClick:e.onToggle,children:["Filters",o>0?` · ${o}`:""]})]})}async function QI(){const e=await fetch(`${pe()}/decision-memory`);return e.ok?(await e.json()).entries:null}function YI(){const[e,t]=y.useState();return Ye({load:QI,show:t,failed:()=>t(null),changed:s=>s.includes("/decisions/")||s.endsWith("map.md")}),e}function JI(e){const{api:t,bp:s}=e,o=t.decisions,[a,l]=y.useState({}),[d,h]=y.useState(e.focus),[f,p]=y.useState(!1),[k,v]=y.useState(!1),w=YI();y.useEffect(()=>h(e.focus),[e.focus]),y.useEffect(()=>{const q=H=>{H.key==="Escape"&&(s==="mobile"&&d?h(void 0):e.onClose())};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[s,d,e]);const j=y.useMemo(()=>ij(o,a),[o,a]),N=y.useMemo(()=>rj(o),[o]),S=o.find(q=>q.id===d&&(!a.mapId||q.mapId===a.mapId))??(s==="mobile"?void 0:j[0]),I=y.useMemo(()=>Object.values(t.allSnaps).sort((q,H)=>H.map.createdAt-q.map.createdAt),[t.allSnaps]),$=y.useMemo(()=>[...new Set(o.map(q=>q.decidedBy))].sort(),[o]),_=q=>l(H=>({...H,...q})),O=()=>{const q=Object.fromEntries(I.map(H=>[H.map.id,{key:H.map.key,title:H.map.title}]));Og(`${Z.slug}-decisions-${Xs(Date.now())}.md`,vj(j,q,{title:`${Z.name} decisions`}))},D=s==="mobile"&&!!S;return i.jsxs(Be,{className:`zone decisions-view dv-${s}`,children:[i.jsxs("header",{className:"dv-head",children:[D?i.jsx("button",{className:"back",onClick:()=>h(void 0),children:"‹ Decisions"}):i.jsxs(ze,{as:"h2",children:["Decisions ",j.length!==o.length&&i.jsx("span",{className:"n",children:`${j.length}/${o.length}`})]}),s!=="mobile"&&i.jsx(GI,{stats:N}),i.jsxs("span",{className:"dv-head-right",children:[!D&&w&&i.jsx(M,{on:k,"aria-pressed":k,onClick:()=>v(q=>!q),title:"Group by the area each decision is about, the most cited first",children:"By area"}),!D&&i.jsx(M,{onClick:O,disabled:!j.length,title:"Export the filtered list as markdown",children:"Export .md"}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]})]}),!D&&i.jsx(qI,{filter:a,set:_,showToggle:s!=="wide",filtersOpen:f,onToggle:()=>p(q=>!q)}),i.jsxs("div",{className:"dv-body",children:[(s==="wide"||f&&!D)&&i.jsx(UI,{filter:a,set:_,all:o,trails:I,people:$,compact:s!=="wide"}),!D&&i.jsx(VI,{rows:j,current:S,snaps:t.allSnaps,showTrail:s==="wide",onSelect:h,memory:k&&w?w:void 0}),(s!=="mobile"||S)&&i.jsx("div",{className:"dv-detail",children:S?i.jsx(FI,{d:S,all:o,snap:t.allSnaps[S.mapId],onSelect:h,onOpenTicket:e.onOpenTicket,onSupersede:t.actions.supersede}):i.jsx(Ie,{children:"No decision selected"})})]})]})}function XI({api:e,bp:t,nav:s}){return s.statsOpen?i.jsx(U2,{api:e,bp:t,onClose:()=>s.setStatsOpen(!1)}):s.decisionsView?i.jsx(JI,{api:e,bp:t,focus:s.decisionsView.focus,onClose:()=>s.setDecisionsView(null),onOpenTicket:s.openTicket}):null}function ZI(e,t,s){const o=Vv(),[a,l]=y.useState(()=>new URLSearchParams(location.search).has("projects")),d=a&&o.many&&i.jsx(x2,{projects:o,bp:e,onClose:()=>l(!1),onItemHere:s});return{projects:o,overview:d,openOverview:()=>{t.setDecisionsView(null),t.setStatsOpen(!1),l(!0)}}}const eR={"asks-you":"urgent",answered:"good",launched:"good",done:"good",verified:"good","checks-failed":"attention",stalled:"attention",disconnected:"attention",problem:"attention"};function tR(e){if(e.kind)return eR[e.kind];if(e.signal){if(e.level==="alert")return"urgent";if(e.level==="ok")return"good"}}function ck({activity:e,onTicket:t}){const s=li(),o=e.feed.slice(-120).reverse();return o.length?i.jsx("div",{className:"log",children:o.map(a=>i.jsxs("div",{className:`log-row src-${a.source.replace(" ","-")} edge-${tR(a)??"none"}`,onClick:()=>a.ticketId&&t(a.ticketId),children:[i.jsx("span",{className:"t t-meta",children:ha(a.at)}),i.jsx("span",{className:"src t-meta",children:ps(a.agent??a.source,s)}),i.jsxs("span",{className:"msg",title:a.tag?`${a.tag} · ${a.text}`:a.text,children:[a.tag&&i.jsxs("span",{className:"tag t-meta",children:[a.tag," · "]}),a.text]})]},a.id))}):i.jsx(Sn,{title:"Nothing has happened yet",hint:"Claims, steps, questions and decisions appear here as agents work."})}function Mp({lease:e,now:t}){if(!e)return null;const s=ca(e,t);if(s==="live")return null;const o=e.expiresAt-t;return i.jsxs(bn,{tone:"amber",className:"stalled",title:`No activity from ${e.agent}; the ticket returns to the queue when the lease runs out`,children:["stalled · ",s==="expired"?"returning":Jt(o)]})}function nR({total:e,step:t}){return i.jsx("span",{className:"segs","aria-label":`Step ${t} of ${e}`,children:Array.from({length:e},(s,o)=>i.jsx("i",{className:sR(o+1,t)},o))})}function sR(e,t){return e<t?"done":e===t?"cur":""}function dk({snap:e,activity:t,leases:s,onSelect:o,onOpenChat:a}){var w;const l=Xt(1e3),d=t.sessions.filter(dn),h=new Set(d.map(j=>j.ticketId)),f=Rd(s,e==null?void 0:e.map.id),p=(e==null?void 0:e.tickets.filter(j=>j.state==="open"&&j.assignee&&!h.has(j.id)))??[];if(!d.length&&!p.length)return i.jsx(Ie,{children:"No agent on a ticket"});const k=j=>!!j&&ca(j,l)!=="live",v=!!((w=e==null?void 0:e.map.modelMatching)!=null&&w.enabled);return i.jsxs("ul",{className:"sessions-list",children:[d.map(j=>{const N=e==null?void 0:e.tickets.find($=>$.id===j.ticketId),S=N?cr(N)==="hitl":!1,I=N&&f.get(N.id);return i.jsx(be,{as:"li",className:j.waitingOn?"waiting":void 0,edge:iR(j,k(I)),title:aR(N,j.mode)||j.agent,context:i.jsx(V,{parts:[{text:j.agent,strong:!0},v&&rR(j),j.waitingOn?{text:"Waiting on you",urgent:!0}:`${j.mode} · ${j.stepLabel.toLowerCase()}`,S&&!j.waitingOn&&"with you",oR(j)],children:i.jsx(Mp,{lease:I,now:l})}),trailing:Pg(l-j.startedAt),below:i.jsx(nR,{total:j.total,step:j.step}),onOpen:()=>{N&&o({kind:"ticket",id:N.id}),S&&a(j.id)}},j.id)}),p.map(j=>i.jsx(be,{as:"li",className:"claim",edge:k(f.get(j.id))?"attention":"neutral",title:`${j.key} ${j.title}`,context:i.jsx(V,{parts:[{text:j.assignee??"",strong:!0},"claimed, no live session"],children:i.jsx(Mp,{lease:f.get(j.id),now:l})}),onOpen:()=>o({kind:"ticket",id:j.id})},j.id))]})}function iR(e,t){return e.waitingOn?"urgent":t?"attention":"neutral"}function rR(e){const t=e.model?`Runs ${e.model}`:"No model reported, so it counts as balanced";return{text:e.tier??"balanced",tip:t,className:"session-tier"}}function oR(e){if(e.usage)return`${fa(tj(e))} tok · ${Js(e.usage.costUsd)}`}function aR(e,t){return e?`${e.key} ${e.title}`:t==="chart"?"Charting trail":""}function uk({activity:e,snap:t,running:s,usage:o=!0}){const a=rg(e,t==null?void 0:t.map.id),l=ag(e,t==null?void 0:t.map.id),d=new Set(e.sessions.filter(dn).map(f=>f.ticketId)),h=(t==null?void 0:t.tickets.filter(f=>f.state==="open"&&f.assignee&&!d.has(f.id)).length)??0;return i.jsx(Et,{sub:!0,className:"sessions-head",title:i.jsxs(i.Fragment,{children:["Agents on tickets ",i.jsx("span",{className:"n",children:s+h})]}),right:o?i.jsxs("span",{className:"usage",title:["Model usage for this trail, all sessions",...l.map(f=>og[f].text)].join(`
|
|
163
|
-
`),children:[i.jsx("span",{className:"mono-label",children:"Trail"})," ",fa(a.inputTokens+a.outputTokens)," tok · ",Js(a.costUsd)]}):void 0})}function lR(e){const t=[...e.feed].reverse().find(s=>s.level==="step"&&s.sessionId);return t?e.sessions.find(s=>s.id===t.sessionId):void 0}const cR={running:"Working",done:"Done",failed:"Stopped"};function hk({activity:e,snap:t}){var d;const s=lR(e);if(!s)return i.jsx(Sn,{title:"No agent working yet",hint:zt()?`Turn your agents on for this trail in ${(d=zt())==null?void 0:d.label}. Each step they report shows here.`:"Run /scout resume in Claude Code or Codex. Each step an agent reports shows here."});const o=s.ticketId?t==null?void 0:t.tickets.find(h=>h.id===s.ticketId):void 0,a=ra[s.mode],l=s.waitingOn?"Waiting on you":cR[s.status];return i.jsxs("div",{className:`step-tracker ${s.waitingOn?"waiting":""}`,children:[i.jsxs("div",{className:"st-meta",children:[i.jsx(V,{parts:[{text:s.agent,strong:!0},`${s.mode}, step ${s.step} of ${s.total}`]}),i.jsx("span",{className:`t-label st-status ${s.waitingOn?"urgent":""}`,children:l})]}),i.jsxs("div",{className:"st-big",children:[s.stepLabel,o&&i.jsxs("span",{className:"st-key",children:[" ",o.key]})]}),o&&i.jsx("div",{className:"st-ticket t-meta",children:o.title}),i.jsx("ol",{className:"pipeline",children:a.map((h,f)=>{const p=f+1,
|
|
164
|
-
${d.briefText}`)}).filter(
|
|
162
|
+
`),kind:"product-decision",sources:[`decision:${t.id}`,...t.ticketKey?[`ticket:${t.ticketKey}`]:[]]})}),k==="active"&&!t.postedBy&&i.jsx(M,{on:a,onClick:()=>l(S=>!S),"data-tip":"Replace this decision with a new answer. Both stay on record",children:"Supersede…"})]}),a&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),d.trim()&&(e.onSupersede(t,{answer:d.trim(),rationale:f.trim(),alternatives:[t.summary]}),l(!1))},children:[i.jsx(Ze,{label:"New decision",children:i.jsx("textarea",{rows:3,value:d,onChange:S=>h(S.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Rationale",children:i.jsx("input",{value:f,onChange:S=>p(S.target.value)})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(M,{variant:"ghost",onClick:()=>l(!1),children:"Cancel"}),i.jsx(M,{type:"submit",variant:"primary",disabled:!d.trim(),children:"Supersede"})]})]}),i.jsxs("div",{className:"dv-sec",children:[i.jsxs("h4",{className:"mono-label",children:["Transcript ",i.jsx("span",{className:"n",children:t.transcript.length})]}),t.transcript.length?i.jsx("div",{className:"dv-transcript comms-log",children:t.transcript.map((S,I)=>i.jsxs("div",{className:`msg from-${S.from} voice-${S.from==="human"?"human":"agent"}`,children:[i.jsx(dd,{parts:[ps(S.author,o),Id(S.at)]}),i.jsx("div",{className:"msg-text",children:S.text})]},I))}):i.jsx(Ie,{children:"None recorded"})]})]})}function _t(e){return i.jsx("li",{children:i.jsxs("button",{className:`dv-opt ${e.on?"on":""} ${e.cls??""}`,onClick:e.onClick,children:[i.jsx("span",{className:"ttl",children:e.label}),i.jsx("b",{children:e.n})]})})}function UI(e){const{filter:t,set:s,all:o}=e,a=l=>o.filter(l).length;return e.compact?i.jsxs("div",{className:"dv-filters compact",children:[i.jsx(at,{compact:!0,"aria-label":"Trail",value:t.mapId??"",onChange:l=>s({mapId:l||void 0}),options:[{value:"",label:"All trails"},...e.trails.map(l=>({value:l.map.id,label:`${l.map.key} ${l.map.title}`}))]}),i.jsx(at,{compact:!0,"aria-label":"Source",value:t.source??"",onChange:l=>s({source:l||void 0}),options:[{value:"",label:"All sources"},...Fo.map(l=>({value:l,label:Jn[l].label}))]}),i.jsx(at,{compact:!0,"aria-label":"Decided by",value:t.decidedBy??"",onChange:l=>s({decidedBy:l||void 0}),options:[{value:"",label:"Anyone"},...e.people.map(l=>({value:l,label:l}))]}),i.jsx(at,{compact:!0,"aria-label":"Status",value:t.status??"",onChange:l=>s({status:l||void 0}),options:[{value:"",label:"Any status"},{value:"active",label:"Active"},{value:"superseded",label:"Superseded"}]})]}):i.jsxs("aside",{className:"dv-filters",children:[i.jsx("h3",{className:"mono-label",children:"Trail"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.mapId,label:"All trails",n:o.length,onClick:()=>s({mapId:void 0})}),e.trails.map(l=>i.jsx(_t,{on:t.mapId===l.map.id,label:`${l.map.key} ${l.map.title}`,n:a(d=>d.mapId===l.map.id),onClick:()=>s({mapId:l.map.id})},l.map.id))]}),i.jsx("h3",{className:"mono-label",children:"Source"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.source,label:"All",n:o.length,onClick:()=>s({source:void 0})}),Fo.map(l=>i.jsx(_t,{cls:`src-${l}`,on:t.source===l,label:Jn[l].label,n:a(d=>d.source.kind===l),onClick:()=>s({source:t.source===l?void 0:l})},l))]}),i.jsx("h3",{className:"mono-label",children:"Made by"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.madeBy,label:"Anyone",n:o.length,onClick:()=>s({madeBy:void 0})}),i.jsx(_t,{on:t.madeBy==="agent",label:"Agents, on their own",n:a(l=>rr(l)==="agent"),onClick:()=>s({madeBy:t.madeBy==="agent"?void 0:"agent"})}),i.jsx(_t,{on:t.madeBy==="human",label:"People",n:a(l=>rr(l)==="human"),onClick:()=>s({madeBy:t.madeBy==="human"?void 0:"human"})})]}),i.jsx("h3",{className:"mono-label",children:"Decided by"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.decidedBy,label:"Anyone",n:o.length,onClick:()=>s({decidedBy:void 0})}),e.people.map(l=>i.jsx(_t,{on:t.decidedBy===l,label:l,n:a(d=>d.decidedBy===l),onClick:()=>s({decidedBy:t.decidedBy===l?void 0:l})},l))]}),i.jsx("h3",{className:"mono-label",children:"Status"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.status,label:"Any",n:o.length,onClick:()=>s({status:void 0})}),i.jsx(_t,{on:t.status==="active",label:"Active",n:a(l=>!l.supersededBy),onClick:()=>s({status:t.status==="active"?void 0:"active"})}),i.jsx(_t,{on:t.status==="superseded",label:"Superseded",n:a(l=>!!l.supersededBy),onClick:()=>s({status:t.status==="superseded"?void 0:"superseded"})})]})]})}const Rp=e=>`${e.mapId}/${e.id}`;function WI(e,t){var a;const s=new Map;for(const l of e){const d=((a=t[Rp(l)])==null?void 0:a.area)??Tc;s.set(d,[...s.get(d)??[],l])}const o=l=>{var d;return((d=t[Rp(l)])==null?void 0:d.citedBy.length)??0};return[...s].map(([l,d])=>({area:l,rows:[...d].sort((h,f)=>o(f)-o(h)||f.decidedAt-h.decidedAt)})).sort((l,d)=>+(l.area===Tc)-+(d.area===Tc)||d.rows.length-l.rows.length||l.area.localeCompare(d.area))}function HI(e){if(dr(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function KI(e){const{d:t}=e,s=li(),o=dr(t);return i.jsxs(i.Fragment,{children:[e.newDay&&i.jsx("li",{className:"dv-day t-label",children:e.group??Xs(t.decidedAt)}),i.jsx(be,{as:"li",className:`dv-row ${o}`,selected:e.on,onOpen:e.onClick,title:t.question,titleText:t.question,trailing:Id(t.decidedAt),context:i.jsx(V,{parts:[{text:t.id,code:!0},t.ticketKey&&{text:t.ticketKey,code:!0},e.showTrail&&e.trail,qg(t,s),eg(t)??Jn[t.source.kind].label,HI(t),!!e.cited&&`cited ${e.cited}×`]}),detail:t.summary,detailText:t.summary})]})}function VI(e){const{rows:t,current:s,memory:o}=e,a=(l,d,h)=>{var f,p;return i.jsx(KI,{d:l,newDay:d,group:h,cited:(f=o==null?void 0:o[`${l.mapId}/${l.id}`])==null?void 0:f.citedBy.length,trail:(p=e.snaps[l.mapId])==null?void 0:p.map.key,on:(s==null?void 0:s.id)===l.id&&s.mapId===l.mapId,showTrail:e.showTrail,onClick:()=>e.onSelect(l.id)},`${l.mapId}:${l.id}`)};return o&&t.length?i.jsx("ol",{className:"dv-list","aria-label":"Logbook by area",children:WI(t,o).flatMap(l=>l.rows.map((d,h)=>a(d,h===0,`${l.area} · ${l.rows.length}`)))}):i.jsx("ol",{className:"dv-list","aria-label":"Logbook",children:t.length?t.map((l,d)=>a(l,d===0||Xs(t[d-1].decidedAt)!==Xs(l.decidedAt))):i.jsx(Ie,{children:"No decisions"})})}function GI({stats:e}){return i.jsxs("span",{className:"dv-readouts",children:[i.jsx(ln,{layout:"start",label:"Active",value:e.active}),i.jsx(ln,{layout:"start",label:"Superseded",value:e.superseded}),i.jsx(ln,{layout:"start",label:"Last 24h",value:e.last24h}),i.jsx(ln,{layout:"start",label:"Human",value:`${e.total?Math.round(e.human/e.total*100):0}%`}),i.jsx(V,{className:"dv-src-mix",parts:Fo.filter(t=>e.bySource[t]).map(t=>`${Jn[t].label} ${e.bySource[t]}`)})]})}function qI(e){const{filter:t}=e,o=Object.values(t).filter(Boolean).length-(t.query?1:0),a=e.filtersOpen||o>0;return i.jsxs("div",{className:"dv-search",children:[i.jsx("input",{type:"search",placeholder:"Search decisions",value:t.query??"",onChange:l=>e.set({query:l.target.value})}),e.showToggle&&i.jsxs("button",{className:`chip ${a?"on":""}`,onClick:e.onToggle,children:["Filters",o>0?` · ${o}`:""]})]})}async function QI(){const e=await fetch(`${pe()}/decision-memory`);return e.ok?(await e.json()).entries:null}function YI(){const[e,t]=y.useState();return Ye({load:QI,show:t,failed:()=>t(null),changed:s=>s.includes("/decisions/")||s.endsWith("map.md")}),e}function JI(e){const{api:t,bp:s}=e,o=t.decisions,[a,l]=y.useState({}),[d,h]=y.useState(e.focus),[f,p]=y.useState(!1),[v,k]=y.useState(!1),w=YI();y.useEffect(()=>h(e.focus),[e.focus]),y.useEffect(()=>{const q=H=>{H.key==="Escape"&&(s==="mobile"&&d?h(void 0):e.onClose())};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[s,d,e]);const j=y.useMemo(()=>ij(o,a),[o,a]),N=y.useMemo(()=>rj(o),[o]),S=o.find(q=>q.id===d&&(!a.mapId||q.mapId===a.mapId))??(s==="mobile"?void 0:j[0]),I=y.useMemo(()=>Object.values(t.allSnaps).sort((q,H)=>H.map.createdAt-q.map.createdAt),[t.allSnaps]),$=y.useMemo(()=>[...new Set(o.map(q=>q.decidedBy))].sort(),[o]),_=q=>l(H=>({...H,...q})),O=()=>{const q=Object.fromEntries(I.map(H=>[H.map.id,{key:H.map.key,title:H.map.title}]));Og(`${Z.slug}-decisions-${Xs(Date.now())}.md`,vj(j,q,{title:`${Z.name} decisions`}))},D=s==="mobile"&&!!S;return i.jsxs(Be,{className:`zone decisions-view dv-${s}`,children:[i.jsxs("header",{className:"dv-head",children:[D?i.jsx("button",{className:"back",onClick:()=>h(void 0),children:"‹ Decisions"}):i.jsxs(ze,{as:"h2",children:["Decisions ",j.length!==o.length&&i.jsx("span",{className:"n",children:`${j.length}/${o.length}`})]}),s!=="mobile"&&i.jsx(GI,{stats:N}),i.jsxs("span",{className:"dv-head-right",children:[!D&&w&&i.jsx(M,{on:v,"aria-pressed":v,onClick:()=>k(q=>!q),title:"Group by the area each decision is about, the most cited first",children:"By area"}),!D&&i.jsx(M,{onClick:O,disabled:!j.length,title:"Export the filtered list as markdown",children:"Export .md"}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]})]}),!D&&i.jsx(qI,{filter:a,set:_,showToggle:s!=="wide",filtersOpen:f,onToggle:()=>p(q=>!q)}),i.jsxs("div",{className:"dv-body",children:[(s==="wide"||f&&!D)&&i.jsx(UI,{filter:a,set:_,all:o,trails:I,people:$,compact:s!=="wide"}),!D&&i.jsx(VI,{rows:j,current:S,snaps:t.allSnaps,showTrail:s==="wide",onSelect:h,memory:v&&w?w:void 0}),(s!=="mobile"||S)&&i.jsx("div",{className:"dv-detail",children:S?i.jsx(FI,{d:S,all:o,snap:t.allSnaps[S.mapId],onSelect:h,onOpenTicket:e.onOpenTicket,onSupersede:t.actions.supersede}):i.jsx(Ie,{children:"No decision selected"})})]})]})}function XI({api:e,bp:t,nav:s}){return s.statsOpen?i.jsx(U2,{api:e,bp:t,onClose:()=>s.setStatsOpen(!1)}):s.decisionsView?i.jsx(JI,{api:e,bp:t,focus:s.decisionsView.focus,onClose:()=>s.setDecisionsView(null),onOpenTicket:s.openTicket}):null}function ZI(e,t,s){const o=Vv(),[a,l]=y.useState(()=>new URLSearchParams(location.search).has("projects")),d=a&&o.many&&i.jsx(x2,{projects:o,bp:e,onClose:()=>l(!1),onItemHere:s});return{projects:o,overview:d,openOverview:()=>{t.setDecisionsView(null),t.setStatsOpen(!1),l(!0)}}}const eR={"asks-you":"urgent",answered:"good",launched:"good",done:"good",verified:"good","checks-failed":"attention",stalled:"attention",disconnected:"attention",problem:"attention"};function tR(e){if(e.kind)return eR[e.kind];if(e.signal){if(e.level==="alert")return"urgent";if(e.level==="ok")return"good"}}function ck({activity:e,onTicket:t}){const s=li(),o=e.feed.slice(-120).reverse();return o.length?i.jsx("div",{className:"log",children:o.map(a=>i.jsxs("div",{className:`log-row src-${a.source.replace(" ","-")} edge-${tR(a)??"none"}`,onClick:()=>a.ticketId&&t(a.ticketId),children:[i.jsx("span",{className:"t t-meta",children:ha(a.at)}),i.jsx("span",{className:"src t-meta",children:ps(a.agent??a.source,s)}),i.jsxs("span",{className:"msg",title:a.tag?`${a.tag} · ${a.text}`:a.text,children:[a.tag&&i.jsxs("span",{className:"tag t-meta",children:[a.tag," · "]}),a.text]})]},a.id))}):i.jsx(Sn,{title:"Nothing has happened yet",hint:"Claims, steps, questions and decisions appear here as agents work."})}function Mp({lease:e,now:t}){if(!e)return null;const s=ca(e,t);if(s==="live")return null;const o=e.expiresAt-t;return i.jsxs(bn,{tone:"amber",className:"stalled",title:`No activity from ${e.agent}; the ticket returns to the queue when the lease runs out`,children:["stalled · ",s==="expired"?"returning":Jt(o)]})}function nR({total:e,step:t}){return i.jsx("span",{className:"segs","aria-label":`Step ${t} of ${e}`,children:Array.from({length:e},(s,o)=>i.jsx("i",{className:sR(o+1,t)},o))})}function sR(e,t){return e<t?"done":e===t?"cur":""}function dk({snap:e,activity:t,leases:s,onSelect:o,onOpenChat:a}){var w;const l=Xt(1e3),d=t.sessions.filter(dn),h=new Set(d.map(j=>j.ticketId)),f=Rd(s,e==null?void 0:e.map.id),p=(e==null?void 0:e.tickets.filter(j=>j.state==="open"&&j.assignee&&!h.has(j.id)))??[];if(!d.length&&!p.length)return i.jsx(Ie,{children:"No agent on a ticket"});const v=j=>!!j&&ca(j,l)!=="live",k=!!((w=e==null?void 0:e.map.modelMatching)!=null&&w.enabled);return i.jsxs("ul",{className:"sessions-list",children:[d.map(j=>{const N=e==null?void 0:e.tickets.find($=>$.id===j.ticketId),S=N?cr(N)==="hitl":!1,I=N&&f.get(N.id);return i.jsx(be,{as:"li",className:j.waitingOn?"waiting":void 0,edge:iR(j,v(I)),title:aR(N,j.mode)||j.agent,context:i.jsx(V,{parts:[{text:j.agent,strong:!0},k&&rR(j),j.waitingOn?{text:"Waiting on you",urgent:!0}:`${j.mode} · ${j.stepLabel.toLowerCase()}`,S&&!j.waitingOn&&"with you",oR(j)],children:i.jsx(Mp,{lease:I,now:l})}),trailing:Pg(l-j.startedAt),below:i.jsx(nR,{total:j.total,step:j.step}),onOpen:()=>{N&&o({kind:"ticket",id:N.id}),S&&a(j.id)}},j.id)}),p.map(j=>i.jsx(be,{as:"li",className:"claim",edge:v(f.get(j.id))?"attention":"neutral",title:`${j.key} ${j.title}`,context:i.jsx(V,{parts:[{text:j.assignee??"",strong:!0},"claimed, no live session"],children:i.jsx(Mp,{lease:f.get(j.id),now:l})}),onOpen:()=>o({kind:"ticket",id:j.id})},j.id))]})}function iR(e,t){return e.waitingOn?"urgent":t?"attention":"neutral"}function rR(e){const t=e.model?`Runs ${e.model}`:"No model reported, so it counts as balanced";return{text:e.tier??"balanced",tip:t,className:"session-tier"}}function oR(e){if(e.usage)return`${fa(tj(e))} tok · ${Js(e.usage.costUsd)}`}function aR(e,t){return e?`${e.key} ${e.title}`:t==="chart"?"Charting trail":""}function uk({activity:e,snap:t,running:s,usage:o=!0}){const a=rg(e,t==null?void 0:t.map.id),l=ag(e,t==null?void 0:t.map.id),d=new Set(e.sessions.filter(dn).map(f=>f.ticketId)),h=(t==null?void 0:t.tickets.filter(f=>f.state==="open"&&f.assignee&&!d.has(f.id)).length)??0;return i.jsx(Et,{sub:!0,className:"sessions-head",title:i.jsxs(i.Fragment,{children:["Agents on tickets ",i.jsx("span",{className:"n",children:s+h})]}),right:o?i.jsxs("span",{className:"usage",title:["Model usage for this trail, all sessions",...l.map(f=>og[f].text)].join(`
|
|
163
|
+
`),children:[i.jsx("span",{className:"mono-label",children:"Trail"})," ",fa(a.inputTokens+a.outputTokens)," tok · ",Js(a.costUsd)]}):void 0})}function lR(e){const t=[...e.feed].reverse().find(s=>s.level==="step"&&s.sessionId);return t?e.sessions.find(s=>s.id===t.sessionId):void 0}const cR={running:"Working",done:"Done",failed:"Stopped"};function hk({activity:e,snap:t}){var d;const s=lR(e);if(!s)return i.jsx(Sn,{title:"No agent working yet",hint:zt()?`Turn your agents on for this trail in ${(d=zt())==null?void 0:d.label}. Each step they report shows here.`:"Run /scout resume in Claude Code or Codex. Each step an agent reports shows here."});const o=s.ticketId?t==null?void 0:t.tickets.find(h=>h.id===s.ticketId):void 0,a=ra[s.mode],l=s.waitingOn?"Waiting on you":cR[s.status];return i.jsxs("div",{className:`step-tracker ${s.waitingOn?"waiting":""}`,children:[i.jsxs("div",{className:"st-meta",children:[i.jsx(V,{parts:[{text:s.agent,strong:!0},`${s.mode}, step ${s.step} of ${s.total}`]}),i.jsx("span",{className:`t-label st-status ${s.waitingOn?"urgent":""}`,children:l})]}),i.jsxs("div",{className:"st-big",children:[s.stepLabel,o&&i.jsxs("span",{className:"st-key",children:[" ",o.key]})]}),o&&i.jsx("div",{className:"st-ticket t-meta",children:o.title}),i.jsx("ol",{className:"pipeline",children:a.map((h,f)=>{const p=f+1,v=p<s.step||p===s.step&&s.status==="done";let k="";return v?k="done":p===s.step&&(k="cur"),i.jsxs("li",{className:k,children:[i.jsx("i",{}),i.jsxs("span",{children:[String(p).padStart(2,"0")," ",h]})]},h)})})]})}function Lp(e){return i.jsxs("div",{className:"zone-b activity-stack",children:[i.jsx(hk,{activity:e.activity,snap:e.snap}),i.jsx(uk,{activity:e.activity,snap:e.snap,running:e.activity.sessions.filter(dn).length}),i.jsx(dk,{snap:e.snap,activity:e.activity,leases:e.leases,onSelect:t=>(t==null?void 0:t.kind)==="ticket"&&e.onTicket(t.id),onOpenChat:e.onOpenChat}),i.jsx(Et,{sub:!0,title:"Activity log"}),i.jsx(ck,{activity:e.activity,onTicket:e.onTicket})]})}function dR(e){return i.jsx(Zg,{area:"log",className:"log-zone",icon:"book",title:"Activity log",info:"Everything that happened in this trail, newest first: claims, steps, questions, decisions and errors.",right:i.jsxs("span",{className:"mono-label dim",children:[e.activity.feed.length," events"]}),children:i.jsx(ck,{activity:e.activity,onTicket:e.onTicket})})}function uR(e){var o;const t=e.activity.sessions.filter(dn).length,s=!e.activity.sessions.length&&!((o=e.snap)!=null&&o.tickets.some(a=>a.state==="open"&&a.assignee));return i.jsxs(Be,{className:"zone step-zone",style:{gridArea:"step"},children:[i.jsx(Et,{className:"zone-title",icon:"tent",title:"Current trail step",info:"What your agents are doing right now. The top shows the latest step an agent reported; below is every agent holding a ticket."}),i.jsxs("div",{className:"zone-b",children:[i.jsx(hk,{activity:e.activity,snap:e.snap}),!s&&i.jsxs(i.Fragment,{children:[i.jsx(uk,{activity:e.activity,snap:e.snap,running:t,usage:!1}),i.jsx(dk,{snap:e.snap,activity:e.activity,leases:e.leases,onSelect:a=>(a==null?void 0:a.kind)==="ticket"&&e.onTicket(a.id),onOpenChat:e.onOpenChat})]})]})]})}const hR=e=>typeof e=="string"&&/^\/(?!\/)[\w/?=&#.-]{0,200}$/.test(e)?e:void 0;function fR(e){const t=e;if(!Number.isInteger(t==null?void 0:t.done)||!Number.isInteger(t==null?void 0:t.total)||!Array.isArray(t==null?void 0:t.steps))return;const s=t.steps.slice(0,10).flatMap(o=>{const a=hR(o==null?void 0:o.href);return typeof(o==null?void 0:o.title)!="string"||!a?[]:[{title:o.title.slice(0,80),href:a,done:o.done===!0,next:o.next===!0,optional:o.optional===!0}]});return{done:t.done,total:t.total,complete:t.complete===!0,steps:s}}function mR(){var o;const e=(o=ft())==null?void 0:o.setup,[t,s]=y.useState();return y.useEffect(()=>{if(!e)return;const a=()=>void fetch(e).then(d=>d.ok?d.json():void 0).then(d=>s(fR(d))).catch(()=>{});a();const l=()=>document.visibilityState==="visible"&&a();return document.addEventListener("visibilitychange",l),()=>document.removeEventListener("visibilitychange",l)},[e]),t}const fk="teamtrail.guide.open";function pR(){try{return localStorage.getItem(fk)!=="no"}catch{return!0}}function gR(e){try{localStorage.setItem(fk,e?"yes":"no")}catch{}}function vR(){const e=mR(),[t,s]=y.useState(pR);if(!e||e.complete)return null;const o=l=>{s(l),gR(l)},a=`${e.done} of ${e.total}`;return Mv.createPortal(i.jsxs("aside",{className:`setup-guide${t?" open":""}`,"aria-label":"Get started",children:[t&&i.jsxs("div",{className:"setup-bubble",children:[i.jsxs("header",{children:[i.jsx("b",{children:"Get started"}),i.jsx("span",{className:"t-meta",children:a}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>o(!1),"aria-label":"Minimize",children:"–"})]}),i.jsx("ol",{children:e.steps.map((l,d)=>i.jsxs("li",{className:[l.done&&"done",l.next&&"next"].filter(Boolean).join(" "),children:[i.jsx("span",{className:"setup-mark","aria-hidden":"true",children:l.done?"✓":d+1}),i.jsx("a",{href:l.href,children:l.title}),l.optional&&i.jsx("span",{className:"t-meta",children:"optional"})]},l.href+l.title))})]}),i.jsxs("button",{type:"button",className:"setup-scout",onClick:()=>o(!t),"aria-expanded":t,children:[i.jsx(ua,{size:1,framed:!1,state:"idle"}),!t&&i.jsxs("span",{className:"setup-chip",children:["Get started · ",a]})]})]}),document.body)}function kR(e){const t=Sa(e.ticketId,e.hash),[s,o]=y.useState(),a=e.confirmed?"Unconfirm":"Confirm criteria",l=e.confirmed?"Take your confirmation back":"Agree that these criteria define done for this ticket",d=t.changed&&!e.confirmed;return i.jsxs(i.Fragment,{children:[t.changed&&i.jsx(ya,{what:"These criteria",onReviewAgain:t.reviewAgain}),i.jsx(M,{size:"sm",variant:e.confirmed?"ghost":"default",disabled:d,"data-tip":l,onClick:()=>void e.confirm(!e.confirmed,t.hash).then(o),children:a}),s&&i.jsx("p",{className:"vf-err",children:s})]})}function yR(e){const{proposal:t}=e;return i.jsxs("div",{className:"crit-proposal edge-note edge-attention",children:[i.jsxs("p",{className:"t-meta",children:[t.by," proposes new criteria. Yours stay in force until you take these."]}),i.jsx("ul",{className:"item-list",children:t.criteria.map(s=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:s.text}),i.jsx(V,{parts:[{text:s.id,code:!0},s.kind.replace("-"," "),s.source&&`from ${s.source}`]})]},s.id))}),i.jsxs("div",{className:"actions",children:[i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onDismiss,children:"Keep mine"}),i.jsx(M,{size:"sm",disabled:!e.canAccept,onClick:e.onAccept,children:"Take these"})]})]})}function wR(e){const{proposal:t}=e,s=Sa(`${t.ticketId}@${t.at}`,t.hash),[o,a]=y.useState(),l=d=>void e.decide(d,s.hash).then(a);return i.jsxs(i.Fragment,{children:[s.changed&&i.jsx(ya,{what:"The proposal",onReviewAgain:s.reviewAgain}),i.jsx(yR,{proposal:t,canAccept:!s.changed,onAccept:()=>l("accept"),onDismiss:()=>l("dismiss")}),o&&i.jsx("p",{className:"vf-err",children:o})]})}async function mk(e){return e?e.ok?void 0:(await e.json().catch(()=>({}))).error??`HTTP ${e.status}`:"Could not reach the Lookout"}const pk=`${pe()}/criteria`;async function xR(e){if(!e)return[];const t=await fetch(`${pk}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).tickets:[]}function jR(e){const[t,s]=y.useState([]),{reload:o}=Ye({view:e,load:()=>xR(e),show:s,failed:()=>s([]),changed:l=>l.startsWith("criteria/")});return{tickets:t,confirm:l=>fetch(`${pk}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...l})}).catch(()=>{}).then(async d=>{const h=await mk(d);return o(),h})}}const gk=`${pe()}/criteria-proposals`;async function SR(e){if(!e)return[];const t=await fetch(`${gk}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).proposals:[]}function NR(e){const[t,s]=y.useState([]),{reload:o}=Ye({view:e,load:()=>SR(e),show:s,failed:()=>s([]),events:{"criteria-proposals":l=>(l==null?void 0:l.mapId)===e}});return{proposals:t,decide:(l,d)=>fetch(`${gk}/${l}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...d})}).catch(()=>{}).then(async h=>{const f=await mk(h);return o(),f})}}function bR({snap:e,t}){const{tickets:s,confirm:o}=jR(e.map.id),a=NR(e.map.id),l=a.proposals.find(k=>k.ticketId===t.id),d=ai(),h=s.find(k=>k.ticketId===t.id),f=(h==null?void 0:h.criteria)??[],v=yg(d.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:wg(`${t.body}
|
|
164
|
+
${d.briefText}`)}).filter(k=>k.kind==="business-rule").filter(k=>_j(f,[k.id]).length);return!f.length&&!v.length&&!l?null:i.jsxs("div",{className:"criteria-section d-section",children:[i.jsxs("span",{className:"t-label","data-tip":"Agreed before the work starts; each needs evidence before the ticket counts as done",children:["Acceptance criteria · ",f.length,(h==null?void 0:h.confirmed)&&i.jsx("span",{className:"ok-text",children:" · confirmed by you"})]}),f.length>0&&i.jsx("ul",{className:"criteria-list item-list",children:f.map(k=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:k.text}),i.jsx(V,{parts:[{text:k.id,code:!0},k.kind.replace("-"," "),k.source&&`from ${k.source}`]})]},k.id))}),l&&i.jsx(wR,{proposal:l,decide:(k,w)=>a.decide(k,{title:e.map.title,ticketId:t.id,hash:w})}),v.length>0&&i.jsxs("div",{className:"crit-uncovered edge-note edge-attention",children:[i.jsx("p",{className:"t-meta",children:"No criterion covers these rules yet:"}),i.jsx("ul",{className:"item-list",children:v.map(k=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:k.title}),i.jsx(V,{parts:[{text:k.id,code:!0},"business rule"]})]},k.id))})]}),f.length>0&&t.state==="open"&&i.jsx(kR,{ticketId:t.id,hash:h==null?void 0:h.hash,confirmed:!!(h!=null&&h.confirmed),confirm:(k,w)=>o({title:e.map.title,ticketId:t.id,ticketKey:t.key,confirmed:k,hash:w})})]})}const Zo="";function $R(e){const t=Nd.map(o=>({value:o,label:ar[o],hint:fv[o]})),s=[...CR(e),...t];return i.jsx(at,{compact:!0,className:"vf-level","aria-label":"Verification level",value:e.value??Zo,options:s,onChange:o=>e.onChange(o===Zo?null:o)})}function CR(e){return e.inherit!==void 0?[{value:Zo,label:e.inherit,hint:"Use the trail’s level for this ticket."}]:e.value===void 0?[{value:Zo,label:"Off (not set)"}]:[]}function TR({check:e}){const t=v$(e),[s,o]=y.useState(),[a,l]=y.useState(),d=ER(e);return i.jsxs("details",{className:`vf-row ${t?"ok":"bad"}`,open:!t,children:[i.jsxs("summary",{children:[i.jsx("span",{className:"vf-mark",children:t?"✓":"✕"}),i.jsx("span",{className:"t-code vf-name",children:e.name}),i.jsx("span",{className:"t-meta",children:d}),i.jsx("span",{className:"t-meta vf-dur",children:Jt(e.durationMs)})]}),i.jsx("code",{className:"vf-argv",children:e.argv.join(" ")}),e.error&&i.jsx("p",{className:"vf-note",children:e.error}),i.jsx("pre",{className:"vf-tail",children:s??(e.tail||"No output.")}),i.jsxs("div",{className:"vf-log-line",children:[s===void 0&&i.jsx("button",{className:"link",onClick:()=>fr.log(e.log).then(h=>o(h.clipped?`[earlier output not shown]
|
|
165
165
|
${h.text}`:h.text),h=>l(h.message)),children:"Full log ›"}),e.truncated&&i.jsx("span",{className:"dim",children:"log capped at 1 MB"}),a&&i.jsx("span",{className:"vf-err",children:a})]})]})}function ER(e){return e.error?"did not start":e.timedOut?"timed out":`exit ${e.exitCode??e.signal??"?"}`}const Op=e=>(e==null?void 0:e.slice(0,8))??"none",Pp=e=>e===null?"·":String(e);function AR({attempt:e}){var d;const t=e.git;if(!t)return null;const{files:s,add:o,del:a}=t.stats,l=new Set(((d=t.flags.find(h=>h.kind==="outside-scope"))==null?void 0:d.files)??[]);return i.jsxs("div",{className:"vf-git",children:[i.jsx(V,{parts:[t.tree?{text:`${t.base?`${Op(t.base.head)} → `:""}${Op(t.tree.head)}`,code:!0}:"not a git repo",t.tree&&{text:t.tree.branch??"detached HEAD",code:!!t.tree.branch},t.tree&&`${s} file${s===1?"":"s"} +${o} −${a}`]}),t.flags.filter(h=>h.kind!=="no-git").map(h=>{var f;return i.jsxs("p",{className:`vf-flag lv-${h.level}`,title:(f=h.files)==null?void 0:f.join(`
|
|
166
|
-
`),children:[i.jsx("span",{className:"t-code",children:h.kind})," ",h.message]},h.kind)}),t.changed.length>0&&i.jsxs("details",{className:"vf-files",children:[i.jsx("summary",{className:"t-label",children:"Changed files"}),i.jsx("ul",{children:t.changed.map(h=>i.jsxs("li",{children:[i.jsx("code",{children:h.path}),i.jsxs("span",{className:"dim",children:[h.untracked?"new":`+${Pp(h.add)} −${Pp(h.del)}`,h.dirtyAtClaim?" · dirty at claim":"",l.has(h.path)?" · outside the declared files":""]})]},h.path))})]})]})}function IR({attempt:e,latest:t}){return i.jsxs("details",{className:`vf-attempt r-${e.result}`,open:t,children:[i.jsxs("summary",{children:[i.jsx(bn,{tone:"state",className:`r-${e.result}`,children:g$[e.result]}),i.jsx(V,{parts:[{text:e.id,code:!0},e.agent,hr(e.submittedAt),Jt(e.finishedAt-e.submittedAt)]})]}),i.jsx("p",{className:"vf-claim",children:e.summary??e.resolution}),e.note&&i.jsx("p",{className:"vf-note",children:e.note}),e.criteria&&i.jsx("ul",{className:"vf-criteria",children:e.criteria.lines.map(s=>i.jsx("li",{className:RR(s),children:s},s))}),i.jsx(AR,{attempt:e}),e.checks.map(s=>i.jsx(TR,{check:s},s.name))]})}function RR(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":e.includes(" ? ")?"claimed":"wait"}const MR={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function LR({verdict:e}){const{guide:t,checklist:s}=e;return i.jsxs("div",{className:`vf-verdict v-${e.verdict.toLowerCase()}`,children:[i.jsx(V,{parts:[{text:e.byKind==="trail lead"&&e.verdict==="PASS"?"Approved":MR[e.verdict],strong:!0},{text:e.id,code:!0},e.byKind==="trail lead"?e.by:`review ${e.by}`,e.sessionId&&`session ${e.sessionId.slice(0,8)}`,t&&`as ${t.id} ${t.version}`,`on ${e.attemptId}`,hr(e.at)]}),i.jsx("p",{children:e.summary}),e.findings.length>0&&i.jsx("ul",{className:"vf-findings",children:e.findings.map((o,a)=>i.jsxs("li",{className:`sev-${o.severity}`,children:[o.path&&i.jsx("code",{children:o.line?`${o.path}:${o.line}`:o.path})," ",o.text]},a))}),s&&s.length>0&&i.jsx(bv,{answers:s})]})}function OR(e,t,s){const[o,a]=y.useState(),l=`${e}/${t}`;y.useEffect(()=>a(void 0),[l]);const{reload:d}=Ye({view:l,version:s,load:()=>fr.ticket(e,t),show:a});return y.useEffect(()=>ei.onEvidence(d),[d]),{data:o,reload:d}}const Yc={rework:{label:"What to fix",submit:"Send to rework",hint:"Posted on the ticket for the next agent."},accept:{label:"Why accept",submit:"Accept anyway",hint:"Closes the ticket as done despite the checks."},unblock:{label:"Why",submit:"Unblock",hint:"Back to the queue without running checks."}};function PR(e){const[t,s]=y.useState(),[o,a]=y.useState(""),[l,d]=y.useState("rework"),{state:h,submitted:f,running:p,act:k}=e;if(p||h!=="verifying"&&h!=="held")return null;const v=j=>{s(t===j?void 0:j),a("")},w=j=>{j.preventDefault(),!(!t||!o.trim())&&(k({action:t,reason:o.trim(),...t==="unblock"?{to:l}:{}}),s(void 0))};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"actions vf-actions",children:[h==="verifying"&&f&&i.jsx(M,{variant:"primary",onClick:()=>void k({action:"approve"}),"data-tip":"Checks passed: approve and close the ticket",children:"Approve"}),f&&i.jsx(M,{onClick:()=>void k({action:"rerun"}),"data-tip":"Run the repo's checks again on the current code",children:"Re-run checks"}),i.jsx(M,{on:t==="rework",onClick:()=>v("rework"),"data-tip":"Send it back to an agent with what to fix",children:"Rework…"}),h==="held"&&i.jsxs(i.Fragment,{children:[i.jsx(M,{on:t==="accept",onClick:()=>v("accept"),"data-tip":"Close it as done despite the failing checks",children:"Accept anyway…"}),i.jsx(M,{on:t==="unblock",onClick:()=>v("unblock"),"data-tip":"Put it back in the queue without running checks",children:"Unblock…"})]})]}),t&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:w,children:[i.jsx(Ze,{label:Yc[t].label,children:i.jsx("textarea",{rows:2,value:o,onChange:j=>a(j.target.value),autoFocus:!0})}),t==="unblock"&&i.jsx(Ze,{label:"Back to",children:i.jsx(at,{"aria-label":"Back to",value:l,onChange:d,options:[{value:"rework",label:"Rework",hint:"Keeps the feedback for the next agent."},{value:"ready",label:"Ready",hint:"Back in the queue as a fresh ticket."}]})}),i.jsx("span",{className:"dim vf-hint",children:Yc[t].hint}),i.jsxs("div",{className:"form-actions",children:[i.jsx(M,{variant:"ghost",onClick:()=>s(void 0),children:"Cancel"}),i.jsx(M,{type:"submit",variant:t==="accept"?"danger":"primary",disabled:!o.trim(),children:Yc[t].submit})]})]})]})}const _R={ticket:"set on this ticket",trail:"from the trail",none:"not set"},DR=new Set(["verifying","rework","held"]);function zR(e){const{mapId:t,ticket:s,state:o}=e,{data:a,reload:l}=OR(t,s.id,s.updatedAt),[d,h]=y.useState();if(!a||a.level.level==="off"&&!a.attempts.length&&!DR.has(o))return null;const f=k=>(h(void 0),fr.act({...k,mapId:t,ticketId:s.id,by:St}).then(l,v=>h(v.message))),p=a.running;return i.jsxs("section",{className:"vf-panel",children:[i.jsxs("div",{className:"vf-head",children:[i.jsx(ze,{as:"h4",children:"Verification"}),i.jsx(V,{parts:[ar[a.level.level],_R[a.level.source]]}),s.state==="open"&&i.jsx($R,{value:s.verification,inherit:`Trail (${ar[e.trail??"off"]})`,onChange:k=>void f({action:"level",level:k})})]}),p&&i.jsxs("div",{className:"sync-line vf-running",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Checking ",p.id," for ",p.agent," · since ",hr(p.startedAt)]})]}),i.jsx(PR,{state:o,submitted:a.attempts.length>0,running:!!p,act:f}),d&&i.jsx("p",{className:"vf-err",children:d}),a.verdicts.map(k=>i.jsx(LR,{verdict:k},k.id)),a.attempts.map((k,v)=>i.jsx(IR,{attempt:k,latest:v===0},k.id)),!a.attempts.length&&!p&&i.jsx(V,{parts:[`Checks: ${a.level.checks.join(", ")||"none"}`,"run when the ticket is submitted"]})]})}function BR({lease:e,onRelease:t}){const s=Xt(1e3),o=ca(e,s),a=o==="live";return i.jsxs("div",{className:`lease lease-${o} edge-note ${a?"":"edge-attention"}`,children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(V,{parts:[{text:`Claimed by ${e.agent}`,strong:!0},`active ${hn(s-e.renewedAt)} ago`]}),!a&&i.jsx(bn,{tone:"amber",children:"Stalled"})]}),i.jsx("p",{className:"t-meta lease-line",children:FR(o,UR(e.expiresAt-s))}),e.workspace&&i.jsxs("p",{className:"t-meta lease-branch",children:["Works on ",i.jsx("code",{className:"t-code",children:e.workspace.branch})," in its own worktree"]}),e.touches&&e.touches.length>0&&i.jsxs("p",{className:"t-meta lease-touches",children:["Expects to change"," ",e.touches.map((l,d)=>i.jsxs("span",{children:[d>0&&", ",i.jsx("code",{className:"t-code",children:l})]},l))]}),e.notes.length>0&&i.jsx("ul",{className:"lease-notes t-meta",children:e.notes.slice(-3).map((l,d)=>i.jsx("li",{children:l},d))}),i.jsx("div",{className:"actions",children:i.jsx(M,{variant:a?"default":"urgent",onClick:t,children:"Release to queue"})})]})}function FR(e,t){return e==="expired"?"Lease expired, going back to the queue":e==="stalled"?`The agent went quiet. Back in the queue in ${t}.`:`Back in the queue after ${t} without activity.`}function UR(e){const t=e/864e5;return t>=2?`${Math.round(t)} days`:Jt(Math.max(0,e))}function WR({comments:e}){const t=li();if(!e.length)return null;const s=e.length>1?"s":"";return i.jsxs("details",{className:"comments",children:[i.jsxs("summary",{className:"t-label",children:[e.length," other comment",s]}),e.map(o=>i.jsxs("div",{className:"comment",children:[i.jsx(V,{parts:[{text:ps(o.author,t),strong:!0}]}),i.jsx("div",{className:"c-body",children:o.body.replace(/\*\*/g,"")})]},o.id))]})}function HR({resolution:e,decisions:t,onOpenDecision:s}){const o=li(),a=t.find(h=>!h.supersededBy)??t[0],l=e.body.startsWith("**Ruled")?"ruled out":"resolution",d=t.length>1?` · ${t.length} in chain`:"";return i.jsxs("div",{className:"resolution edge-note edge-done",children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(V,{parts:[{text:ps(e.author,o),strong:!0},l]}),a&&s&&i.jsxs("button",{className:"link t-meta",onClick:()=>s(a.id),children:[a.id,d," ›"]})]}),i.jsx("p",{children:e.body.replace(/^\*\*[^*]+\*\*\s*/,"")})]})}function KR(e){const{t,state:s,session:o,mine:a,form:l,setForm:d,actions:h,onOpenChat:f}=e;return i.jsxs("div",{className:"actions",children:[o&&i.jsx(M,{variant:o.waitingOn?"urgent":"default",onClick:()=>f(o.id),"data-tip":o.waitingOn?"The agent is waiting for your answer":"Open the conversation with this agent",children:o.waitingOn?"Answer":"Conversation"}),s==="frontier"&&i.jsx(M,{onClick:()=>h.claim(t.id),"data-tip":"Take this ticket yourself, so no agent picks it up",children:"Claim"}),(s==="frontier"||s==="claimed"&&a)&&i.jsx(M,{on:l==="resolve",onClick:()=>d(l==="resolve"?null:"resolve"),"data-tip":"Answer it yourself and close the ticket, with a decision record",children:"Resolve…"}),a&&s==="claimed"&&i.jsx(M,{onClick:()=>h.release(t.id),"data-tip":"Give the ticket back to the queue",children:"Release"}),(s==="frontier"||s==="blocked"||s==="parked")&&i.jsx(M,{variant:"danger",on:l==="rule",onClick:()=>d(l==="rule"?null:"rule"),"data-tip":"Move it out of scope. It's set aside with your reason, not deleted",children:"Rule out…"})]})}function VR(e){return e.replace(/\s*Part of trail \S+\.\s*$/,"").trim()}function GR({t:e,state:t,tickets:s}){const o=new Map(s.map(p=>[p.id,p])),a=p=>{var k;return((k=o.get(p))==null?void 0:k.key)??p},l=e.blockedBy.map(p=>{var k;return`${a(p)}${((k=o.get(p))==null?void 0:k.state)==="closed"?" ✓":""}`}).join(", "),d=s.filter(p=>p.blockedBy.includes(e.id)).map(p=>p.key).join(", "),h=[["Type",Zs[e.type]],["Assignee",e.assignee],["Blocked by",l],["Blocks",d],["Reviews",e.reviewOf&&a(e.reviewOf)]],f=cr(e)==="hitl";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key t-code",children:e.key}),i.jsx(bn,{tone:"state",className:`st-${t}`,children:Dg[t]}),i.jsx("span",{className:"d-att t-meta","data-tip":f?"A person takes this one":"An agent takes this alone",children:f?"Needs a person":"Agent work"})]}),i.jsx("h3",{className:"t-heading",children:e.title}),i.jsx("dl",{className:"facts",children:h.filter(([,p])=>p).flatMap(([p,k])=>[i.jsx("dt",{className:"t-label",children:p},`${p}-k`),i.jsx("dd",{children:k},`${p}-v`)])})]})}function qR(e){const{snap:t,api:s,form:o,setForm:a}=e,{actions:l}=s,[d,h]=y.useState(""),[f,p]=y.useState(""),[k,v]=y.useState(""),[w,j]=y.useState("Not needed to reach the destination."),N=t.tickets.find(G=>G.id===e.id);if(!N)return i.jsx(Ie,{children:"Ticket not found."});const S=ti(t.tickets,t.map.mode).get(N.id),I=e.sessions.find(G=>G.ticketId===N.id&&dn(G)),$=N.assignee===St,_=N.state==="open"?Rd(s.leases,t.map.id).get(N.id):void 0,O=[...N.comments].reverse().find(G=>/^\*\*(Resolution|Ruled out of scope)\*\*/.test(G.body)),D=N.comments.filter(G=>G!==O),q=VR(N.body),H=s.decisions.filter(G=>G.mapId===t.map.id&&G.ticketId===N.id);return i.jsxs("div",{className:"detail",children:[i.jsx(GR,{t:N,state:S,tickets:t.tickets}),i.jsx(lk,{mapId:t.map.id,kind:"ticket",id:N.id}),q&&i.jsxs("section",{className:"d-section ticket-body",children:[i.jsx("span",{className:"t-label",children:"Description"}),i.jsx("p",{className:"body",children:q})]}),i.jsx(A2,{mapId:t.map.id,ticketId:N.id}),i.jsx(EN,{mapId:t.map.id,ticketId:N.id}),i.jsx(MT,{mapId:t.map.id,ticket:N}),i.jsx(bR,{snap:t,t:N}),i.jsx(QN,{snap:t,t:N}),N.closeReason==="not_planned"&&i.jsx(Ud,{label:"Save as dead end",draft:()=>{var G;return{title:`Ruled out: ${N.title}`,body:((G=N.comments.at(-1))==null?void 0:G.body)??N.body,kind:"dead-end",sources:[`trail:${t.map.key}`,`ticket:${N.key}`]}}}),_&&i.jsx(BR,{lease:_,onRelease:()=>l.releaseLease(N.id)}),!_&&i.jsx(a2,{mapId:t.map.id,ticketId:N.id}),i.jsx(zR,{mapId:t.map.id,trail:t.map.verification,ticket:N,state:S}),i.jsx(BT,{mapId:t.map.id,ticket:N}),i.jsx(KR,{t:N,state:S,session:I,mine:$,form:o,setForm:a,actions:l,onOpenChat:e.onOpenChat}),o==="resolve"&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:G=>{G.preventDefault(),d.trim()&&(l.resolve(N.id,d.trim(),{rationale:f.trim(),alternatives:k.split(`
|
|
167
|
-
`).map(oe=>oe.trim()).filter(Boolean)}),a(null),h(""),p(""),v(""))},children:[i.jsx(Ze,{label:"Resolution",children:i.jsx("textarea",{rows:3,value:d,onChange:G=>h(G.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Rationale",children:i.jsx("input",{value:f,onChange:G=>p(G.target.value)})}),i.jsx(Ze,{label:"Alternatives considered",children:i.jsx("textarea",{rows:2,value:k,onChange:G=>v(G.target.value),placeholder:"One per line"})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(M,{variant:"ghost",onClick:()=>a(null),children:"Cancel"}),i.jsx(M,{type:"submit",variant:"primary",disabled:!d.trim(),children:"Resolve"})]})]}),o==="rule"&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:G=>{G.preventDefault(),l.ruleOut({ticketId:N.id},w),a(null)},children:[i.jsx(Ze,{label:"Reason",children:i.jsx("input",{value:w,onChange:G=>j(G.target.value),autoFocus:!0})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(M,{variant:"ghost",onClick:()=>a(null),children:"Cancel"}),i.jsx(M,{type:"submit",variant:"danger",children:"Rule out"})]})]}),O&&i.jsx(HR,{resolution:O,decisions:H,onOpenDecision:e.onOpenDecision}),i.jsx(WR,{comments:D})]})}function QR({snap:e,item:t,api:s}){const o=Xp(e.map.mode),[a,l]=y.useState("research"),[d,h]=y.useState(t),[f,p]=y.useState(!1),[k,v]=y.useState([]),[w,j]=y.useState("Not needed to reach the destination.");y.useEffect(()=>h(t),[t]);const N=e.tickets.filter(S=>S.state==="open");return i.jsxs("div",{className:"detail",children:[i.jsx("div",{className:"d-head",children:i.jsx(bn,{tone:"state",className:"st-unspecified",children:"Not yet specified"})}),i.jsx("h3",{className:"t-heading",children:t}),i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),s.actions.graduate({unspecified:t,type:a,title:d,blockedBy:k,hitl:f})},children:[i.jsx(Ze,{label:"Title",children:i.jsx("input",{value:d,onChange:S=>h(S.target.value)})}),i.jsxs("div",{className:"chips",children:[o.map(S=>i.jsx("button",{type:"button",className:`chip ${a===S?"on":""}`,onClick:()=>l(S),children:S},S)),Ew.includes(a)&&i.jsx("button",{type:"button",className:`chip ${f?"on":""}`,onClick:()=>p(S=>!S),children:"needs human"})]}),i.jsx("span",{className:"field",children:"Blocked by"}),i.jsx("div",{className:"chips",children:N.map(S=>i.jsx("button",{type:"button",className:`chip ${k.includes(S.id)?"on":""}`,onClick:()=>v(I=>I.includes(S.id)?I.filter($=>$!==S.id):[...I,S.id]),children:S.key},S.id))}),i.jsx("div",{className:"form-actions",children:i.jsx(M,{type:"submit",variant:"primary",children:"Promote to ticket"})})]}),i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),s.actions.ruleOut({unspecified:t},w)},children:[i.jsx(Ze,{label:"Reason",children:i.jsx("input",{value:w,onChange:S=>j(S.target.value)})}),i.jsx("div",{className:"form-actions",children:i.jsx(M,{type:"submit",variant:"danger",children:"Rule out"})})]})]})}function YR({api:e,sessions:t,bare:s,onOpenChat:o,onOpenDecision:a}){const{snap:l,selection:d,actions:h}=e,[f,p]=y.useState(null),k=JR(d);y.useEffect(()=>p(null),[k]);let v;return l?d?d.kind==="unspecified"?v=i.jsx(QR,{snap:l,item:d.item,api:e}):v=i.jsx(qR,{snap:l,id:d.id,api:e,sessions:t,form:f,setForm:p,onOpenChat:o??h.openChat,onOpenDecision:a}):v=i.jsx(Sn,{title:"No ticket selected",hint:"Pick a ticket on the map: what it is, who has it, what blocks it, and its decision."}):v=i.jsx(Sn,{title:"No trail yet",hint:"Once there's a trail, pick a ticket on the map to see it here."}),i.jsx(Zg,{area:"inspector",icon:"note",title:"Trail step",info:"The ticket you selected on the map: what it is, who has it, what blocks it, and its decision once it's made.",className:"inspector",bare:s,children:v})}function JR(e){return(e==null?void 0:e.kind)==="ticket"?e.id:(e==null?void 0:e.kind)==="unspecified"?e.item:""}const XR={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function ZR(e){if(e.decidedBy)return e.status==="invalidated"?`invalidated by ${e.decidedBy}`:e.status==="confirmed"?`confirmed by ${e.decidedBy==="trail lead"?"you":e.decidedBy}`:`kept by ${e.decidedBy}`}function eM(e){const{a:t,snap:s}=e,o=t.tickets.flatMap(l=>s.tickets.filter(d=>d.id===l)),a=t.challenge&&`${t.challenge.by}: ${t.challenge.evidence}`;return i.jsx(be,{as:"li",className:`assumption st-${t.status}`,edge:t.status==="challenged"?"attention":"neutral",title:t.text,titleText:t.text,context:i.jsx(V,{parts:[{text:t.id,code:!0},XR[t.status],ZR(t)],children:o.length>0&&i.jsxs("span",{className:"assumption-tickets",children:[i.jsx("span",{className:"sep",children:" · "}),"relied on by",o.map(l=>i.jsx("button",{className:"link t-code",onClick:()=>e.onSelect({kind:"ticket",id:l.id}),children:l.key},l.id))]})}),detail:a,detailText:a,actions:e.onConfirm&&i.jsx(M,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onConfirm,children:"Confirm"})})}function tM(e){const[t,s]=y.useState(),[o,a]=y.useState();return{confirm:async(d,h)=>{a(d);const f=await fetch(`${pe()}/assumptions/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,id:d,text:h})}).catch(()=>{});if(a(void 0),f!=null&&f.ok)return s(void 0);const p=await(f==null?void 0:f.json().catch(()=>({})));s((p==null?void 0:p.error)??"Could not confirm it; is the Lookout connected?")},busy:o,error:t}}function nM({snap:e,onSelect:t}){const{confirm:s,busy:o,error:a}=tM(e.map.id),l=e.map.sections.assumptions??[];return l.length?i.jsxs(i.Fragment,{children:[a&&i.jsx("p",{className:"urgent-text",children:a}),i.jsx("ul",{className:"assumptions row-list",children:l.map(d=>{const h=d.status==="holding"||d.status==="challenged";return i.jsx(eM,{a:d,snap:e,onSelect:t,onConfirm:h?()=>void s(d.id,d.text):void 0,busy:o===d.id},d.id)})})]}):i.jsx(Ie,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function sM(e){const[,t,s=e]=/^(#\d+)\s+(.+)$/.exec(e)??[],[o=s,...a]=s.split(/\s+[—–]\s+/);return{key:t,title:o,reason:a.join(" — ")||void 0}}function iM(e){const[t,s]=y.useState([]),o=e==null?void 0:e.map.id,a=(e==null?void 0:e.tickets.reduce((l,d)=>Math.max(l,d.updatedAt),e.map.updatedAt))??0;return y.useEffect(()=>{if(!o)return;let l=!0;return fetch(`${pe()}/journal?mapId=${encodeURIComponent(o)}`).then(d=>d.ok?d.json():{entries:[]}).then(d=>l&&s(d.entries)).catch(()=>l&&s([])),()=>{l=!1}},[o,a]),t}function rM({snap:e,activity:t,onTicket:s}){const o=iM(e),a=t.usageByMap[e.map.id],l=y.useMemo(()=>fg({snap:e,journal:o,answered:t.answered,usage:a}),[e,o,t.answered,a]),d=l.interventions,h=[["Done",`${l.done}`,`${l.done} done · ${l.cancelled} cancelled · ${l.open} open`],["Lead time",Qt(l.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",Qt(l.medianLeadMs),"Median time from a ticket's first claim to done"],["Interventions",`${d.total}`,`${d.answers} agent questions you answered + ${d.operatorActions} lifecycle calls you made (approve, send back, accept, unblock, cancel, release), of which ${d.reworkRequested} sent work back. Answers count while their sessions are on record.`],["Rework",`${l.rework.cycles}`,`Times work went back to rework, on ${l.rework.tickets} tickets`],["Reviews",`${l.reviews.passed}/${l.reviews.failed}`,`${l.reviews.passed} passed, ${l.reviews.failed} failed, ${l.reviews.needsHuman} needed you`],["Cost / ticket",l.spend.perVerifiedTicketUsd===void 0?"—":Js(l.spend.perVerifiedTicketUsd),`Cost per verified ticket: trail spend ${Js(l.spend.costUsd)} ÷ ${l.done} done tickets`]];return i.jsxs("div",{className:"report",children:[i.jsx("ul",{className:"report-stats",children:h.map(([f,p,k])=>i.jsxs("li",{"data-tip":k,children:[i.jsx("span",{className:"mono-label",children:f}),i.jsx("b",{children:p})]},f))}),i.jsxs("div",{className:"report-bar",children:[i.jsx("span",{className:"mono-label",children:"Tickets"}),i.jsx(M,{size:"sm",variant:"ghost","data-tip":"Download this report as markdown",onClick:()=>Og(`${e.map.key.replace("#","trail-")}-report.md`,$j(l,e.map.title)),children:"Export markdown"})]}),l.tickets.length?i.jsx("ul",{className:"list report-tickets",children:l.tickets.map(f=>i.jsx("li",{className:`out-${f.outcome}`,children:i.jsxs("button",{onClick:()=>s(f.id),"data-tip":`${f.outcome} · rework ${f.reworks} · reviews ${f.reviews.passed}/${f.reviews.failed} · your calls ${f.operatorActions}`,children:[i.jsx("span",{className:"key",children:f.key}),i.jsx("span",{className:"ttl",children:f.title}),i.jsx("span",{className:"lead",children:f.outcome==="done"?Qt(f.leadMs):f.outcome})]})},f.id))}):i.jsx(Ie,{children:"No tickets yet"})]})}function oM({tab:e,snap:t,selection:s,onSelect:o,activity:a}){const l=t.map.sections;switch(e){case"report":return a?i.jsx(rM,{snap:t,activity:a,onTicket:d=>o({kind:"ticket",id:d})}):i.jsx(Ie,{children:"No activity yet"});case"assumptions":return i.jsx(nM,{snap:t,onSelect:o});case"decisions":return l.decisions.length?i.jsx("ol",{className:"row-list decisions",children:[...l.decisions].reverse().map((d,h)=>i.jsx(be,{as:"li",title:d.text,titleText:d.text,context:d.ticketKey&&i.jsx(V,{parts:[{text:d.ticketKey,code:!0}]}),onOpen:d.ticketId?()=>o({kind:"ticket",id:d.ticketId}):void 0},`${d.ticketKey}-${h}`))}):i.jsx(Ie,{children:"None"});case"unspecified":return l.unspecified.length?i.jsx("ul",{className:"row-list unspecified",children:l.unspecified.map(d=>i.jsx(be,{as:"li",title:d,titleText:d,selected:(s==null?void 0:s.kind)==="unspecified"&&s.item===d,onOpen:()=>o({kind:"unspecified",item:d})},d))}):i.jsx(Ie,{children:"None"});case"oos":return l.outOfScope.length?i.jsx("ul",{className:"row-list oos",children:l.outOfScope.map(d=>{const h=sM(d);return i.jsx(be,{as:"li",title:h.title,titleText:d,context:i.jsx(V,{parts:[h.key&&{text:h.key,code:!0},h.reason]})},d)})}):i.jsx(Ie,{children:"None"});case"notes":return i.jsx("p",{className:"notes t-body",children:l.notes||"No notes yet."});default:return e}}function aM({snap:e,selection:t,onSelect:s,bare:o,onAudit:a,activity:l}){var v;const[d,h]=y.useState("unspecified"),f=e==null?void 0:e.map.sections,p=[{id:"unspecified",label:"Not yet specified",n:f==null?void 0:f.unspecified.length},{id:"assumptions",label:"Assumptions",n:(v=f==null?void 0:f.assumptions)==null?void 0:v.length},{id:"decisions",label:"Decisions",n:f==null?void 0:f.decisions.length},{id:"oos",label:"Out of scope",n:f==null?void 0:f.outOfScope.length},{id:"notes",label:"Notes"},{id:"report",label:"Report"}],k=e?i.jsx(oM,{tab:d,snap:e,selection:t,onSelect:s,activity:l}):i.jsx(Sn,{title:"No plan yet",hint:"Open questions, decisions, what's ruled out, notes and the trail report collect here."});return i.jsxs(Be,{className:`zone sections ${o?"bare":""}`,style:o?void 0:{gridArea:"plan"},children:[!o&&i.jsx(Et,{className:"zone-title",icon:"flag",title:"Trail plan",info:"The parts of the plan that aren't tickets yet: open questions still to specify, the assumptions the plan relies on, decisions already made, what's ruled out, and notes. Report shows how the trail is going: lead times, your interventions, rework, reviews and cost per verified ticket."}),i.jsxs("div",{className:"sections-tabs",children:[i.jsx(at,{compact:!0,"aria-label":"Plan section",value:d,onChange:h,options:p.map(w=>({value:w.id,label:w.n===void 0?w.label:`${w.label} · ${w.n}`}))}),d==="decisions"&&a&&i.jsx("button",{className:"link",onClick:a,children:"Audit ›"})]}),i.jsx("div",{className:"zone-b",children:k})]})}function lM(){var F;const e=y.useMemo(()=>tN(eN()),[]),t=mN(e),{snap:s,activity:o,selection:a,actions:l}=t,[d,h]=vN(),f=YA(),p=M$(e,t),k=ZA(e.kind),v=cN(),w=o.pending.length,j=eI(o,t.mapId);XA(w,s==null?void 0:s.map.title);const N=JA(t,v),S=II(s,l.selectMap),I=nb(S.briefText),$=OI({api:t,nav:N,knowledge:I,reviewBrief:S.review,openReroute:J=>S.openReroute(J.mapId,J.ref),openGuides:()=>f.open("guides"),openConnector:J=>f.open(J),openApprovals:()=>f.open("approvals"),openFocusSettings:()=>f.open("attention")}),_=uN(e,t,d.briefing,(F=$.attention.view)==null?void 0:F.items),O=i.jsx(b$,{api:t,nav:N,bp:v,scoped:j,attn:$,above:S.inboxCard}),D=i.jsx(VA,{api:t,sessions:j.sessions,onSelect:N.select,onNewTrail:p.open,compact:v==="mobile",minFit:v==="mobile"?.7:0,trail:S}),q=J=>i.jsx(YR,{api:t,sessions:j.sessions,bare:J,onOpenChat:ie=>N.openChat(ie),onOpenDecision:N.openDecisions}),H={activity:j,snap:s,leases:t.leases,onTicket:J=>N.select({kind:"ticket",id:J}),onOpenChat:J=>N.openChat(J)},G=J=>i.jsx(aM,{snap:s,selection:a,onSelect:N.select,bare:J,onAudit:()=>N.openDecisions(),activity:j}),{projects:oe,overview:Q,openOverview:ke}=ZI(v,N,$.link.request),Oe=f.route&&i.jsx(VE,{rt:e,api:t,bp:v,prefs:d,update:h,settings:f}),Te=(N.statsOpen||N.decisionsView)&&i.jsx(XI,{api:t,bp:v,nav:N}),ne=Oe||Q||Te,ce=_.shown&&i.jsx(CN,{brief:_,snaps:t.allSnaps,bp:v,openTicket:N.openTicket,openChat:N.openChat,openDecisions:N.openDecisions,closeDecisions:()=>N.setDecisionsView(null),showPhoneHome:()=>N.setPhoneTab("home")});return i.jsx(sv.Provider,{value:I,children:i.jsxs("div",{className:`app bp-${v}`,children:[i.jsx($b,{api:t,rt:e,repo:i.jsx(j2,{repo:k,projects:oe,onOverview:ke}),brief:_,attention:$.header,decisionsOpen:!!N.decisionsView,onDecisions:()=>{f.close(),N.decisionsView?N.setDecisionsView(null):N.openDecisions()},onStats:()=>{f.close(),N.toggleStats()},onNewTrail:p.open,onStartOver:()=>s&&p.startOver(s.map),onSettings:f.toggle,onSlack:()=>f.open("slack"),onToggleTheme:J=>h({theme:J?"night":"day"})}),v==="wide"&&i.jsxs(i.Fragment,{children:[O,D,q(!1),i.jsx(uR,{...H}),i.jsx(dR,{...H}),G(!1),ne]}),v==="laptop"&&i.jsxs(i.Fragment,{children:[O,D,i.jsx(GE,{tab:N.sideTab,onTab:N.setSideTab,unspecified:s==null?void 0:s.map.sections.unspecified.length,ticket:q(!0),activity:i.jsx(Lp,{...H}),plan:G(!0)}),ne]}),v==="mobile"&&i.jsxs(i.Fragment,{children:[i.jsx(QA,{tab:N.phoneTab,decisions:ne,inbox:O,projects:oe.many&&i.jsx(N2,{projects:oe,onOverview:ke}),map:D,ticket:q(!0),activity:i.jsx(Lp,{...H}),plan:G(!0)}),i.jsx(qA,{tab:N.phoneTab,covered:!!ne,pending:w,onPick:J=>{f.close(),N.setPhoneTab(J),N.setDecisionsView(null)}})]}),ce,S.dialog,t.error&&i.jsx("div",{className:"error-toast",children:t.error}),p.dialog,!d.onboarded&&i.jsx(bC,{prefs:d,update:h,activeTracker:e.kind}),i.jsx(ZN,{}),i.jsx(vR,{})]})})}const cM="X-Teamtrail-Session";function dM(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url}function uM(e){const t=new URL(dM(e),location.href),s=Z.apiPrefix;return t.origin===location.origin&&(t.pathname===s||t.pathname.startsWith(`${s}/`))}function hM(){const e=window.fetch.bind(window);window.fetch=(t,s)=>{const o=P1()?Ld():void 0;if(!o||!uM(t))return e(t,s);const a=new Headers((s==null?void 0:s.headers)??(t instanceof Request?t.headers:void 0));return a.set(cM,o.secret),e(t,{...s,headers:a})}}ma(Dd().theme);hM();jw.createRoot(document.getElementById("root")).render(i.jsxs(LE,{children:[i.jsx(lM,{}),i.jsx(jN,{})]}));
|
|
166
|
+
`),children:[i.jsx("span",{className:"t-code",children:h.kind})," ",h.message]},h.kind)}),t.changed.length>0&&i.jsxs("details",{className:"vf-files",children:[i.jsx("summary",{className:"t-label",children:"Changed files"}),i.jsx("ul",{children:t.changed.map(h=>i.jsxs("li",{children:[i.jsx("code",{children:h.path}),i.jsxs("span",{className:"dim",children:[h.untracked?"new":`+${Pp(h.add)} −${Pp(h.del)}`,h.dirtyAtClaim?" · dirty at claim":"",l.has(h.path)?" · outside the declared files":""]})]},h.path))})]})]})}function IR({attempt:e,latest:t}){return i.jsxs("details",{className:`vf-attempt r-${e.result}`,open:t,children:[i.jsxs("summary",{children:[i.jsx(bn,{tone:"state",className:`r-${e.result}`,children:g$[e.result]}),i.jsx(V,{parts:[{text:e.id,code:!0},e.agent,hr(e.submittedAt),Jt(e.finishedAt-e.submittedAt)]})]}),i.jsx("p",{className:"vf-claim",children:e.summary??e.resolution}),e.note&&i.jsx("p",{className:"vf-note",children:e.note}),e.criteria&&i.jsx("ul",{className:"vf-criteria",children:e.criteria.lines.map(s=>i.jsx("li",{className:RR(s),children:s},s))}),i.jsx(AR,{attempt:e}),e.checks.map(s=>i.jsx(TR,{check:s},s.name))]})}function RR(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":e.includes(" ? ")?"claimed":"wait"}const MR={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function LR({verdict:e}){const{guide:t,checklist:s}=e;return i.jsxs("div",{className:`vf-verdict v-${e.verdict.toLowerCase()}`,children:[i.jsx(V,{parts:[{text:e.byKind==="trail lead"&&e.verdict==="PASS"?"Approved":MR[e.verdict],strong:!0},{text:e.id,code:!0},e.byKind==="trail lead"?e.by:`review ${e.by}`,e.sessionId&&`session ${e.sessionId.slice(0,8)}`,t&&`as ${t.id} ${t.version}`,`on ${e.attemptId}`,hr(e.at)]}),i.jsx("p",{children:e.summary}),e.findings.length>0&&i.jsx("ul",{className:"vf-findings",children:e.findings.map((o,a)=>i.jsxs("li",{className:`sev-${o.severity}`,children:[o.path&&i.jsx("code",{children:o.line?`${o.path}:${o.line}`:o.path})," ",o.text]},a))}),s&&s.length>0&&i.jsx(bv,{answers:s})]})}function OR(e,t,s){const[o,a]=y.useState(),l=`${e}/${t}`;y.useEffect(()=>a(void 0),[l]);const{reload:d}=Ye({view:l,version:s,load:()=>fr.ticket(e,t),show:a});return y.useEffect(()=>ei.onEvidence(d),[d]),{data:o,reload:d}}const Yc={rework:{label:"What to fix",submit:"Send to rework",hint:"Posted on the ticket for the next agent."},accept:{label:"Why accept",submit:"Accept anyway",hint:"Closes the ticket as done despite the checks."},unblock:{label:"Why",submit:"Unblock",hint:"Back to the queue without running checks."}};function PR(e){const[t,s]=y.useState(),[o,a]=y.useState(""),[l,d]=y.useState("rework"),{state:h,submitted:f,running:p,act:v}=e;if(p||h!=="verifying"&&h!=="held")return null;const k=j=>{s(t===j?void 0:j),a("")},w=j=>{j.preventDefault(),!(!t||!o.trim())&&(v({action:t,reason:o.trim(),...t==="unblock"?{to:l}:{}}),s(void 0))};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"actions vf-actions",children:[h==="verifying"&&f&&i.jsx(M,{variant:"primary",onClick:()=>void v({action:"approve"}),"data-tip":"Checks passed: approve and close the ticket",children:"Approve"}),f&&i.jsx(M,{onClick:()=>void v({action:"rerun"}),"data-tip":"Run the repo's checks again on the current code",children:"Re-run checks"}),i.jsx(M,{on:t==="rework",onClick:()=>k("rework"),"data-tip":"Send it back to an agent with what to fix",children:"Rework…"}),h==="held"&&i.jsxs(i.Fragment,{children:[i.jsx(M,{on:t==="accept",onClick:()=>k("accept"),"data-tip":"Close it as done despite the failing checks",children:"Accept anyway…"}),i.jsx(M,{on:t==="unblock",onClick:()=>k("unblock"),"data-tip":"Put it back in the queue without running checks",children:"Unblock…"})]})]}),t&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:w,children:[i.jsx(Ze,{label:Yc[t].label,children:i.jsx("textarea",{rows:2,value:o,onChange:j=>a(j.target.value),autoFocus:!0})}),t==="unblock"&&i.jsx(Ze,{label:"Back to",children:i.jsx(at,{"aria-label":"Back to",value:l,onChange:d,options:[{value:"rework",label:"Rework",hint:"Keeps the feedback for the next agent."},{value:"ready",label:"Ready",hint:"Back in the queue as a fresh ticket."}]})}),i.jsx("span",{className:"dim vf-hint",children:Yc[t].hint}),i.jsxs("div",{className:"form-actions",children:[i.jsx(M,{variant:"ghost",onClick:()=>s(void 0),children:"Cancel"}),i.jsx(M,{type:"submit",variant:t==="accept"?"danger":"primary",disabled:!o.trim(),children:Yc[t].submit})]})]})]})}const _R={ticket:"set on this ticket",trail:"from the trail",none:"not set"},DR=new Set(["verifying","rework","held"]);function zR(e){const{mapId:t,ticket:s,state:o}=e,{data:a,reload:l}=OR(t,s.id,s.updatedAt),[d,h]=y.useState();if(!a||a.level.level==="off"&&!a.attempts.length&&!DR.has(o))return null;const f=v=>(h(void 0),fr.act({...v,mapId:t,ticketId:s.id,by:St}).then(l,k=>h(k.message))),p=a.running;return i.jsxs("section",{className:"vf-panel",children:[i.jsxs("div",{className:"vf-head",children:[i.jsx(ze,{as:"h4",children:"Verification"}),i.jsx(V,{parts:[ar[a.level.level],_R[a.level.source]]}),s.state==="open"&&i.jsx($R,{value:s.verification,inherit:`Trail (${ar[e.trail??"off"]})`,onChange:v=>void f({action:"level",level:v})})]}),p&&i.jsxs("div",{className:"sync-line vf-running",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Checking ",p.id," for ",p.agent," · since ",hr(p.startedAt)]})]}),i.jsx(PR,{state:o,submitted:a.attempts.length>0,running:!!p,act:f}),d&&i.jsx("p",{className:"vf-err",children:d}),a.verdicts.map(v=>i.jsx(LR,{verdict:v},v.id)),a.attempts.map((v,k)=>i.jsx(IR,{attempt:v,latest:k===0},v.id)),!a.attempts.length&&!p&&i.jsx(V,{parts:[`Checks: ${a.level.checks.join(", ")||"none"}`,"run when the ticket is submitted"]})]})}function BR({lease:e,onRelease:t}){const s=Xt(1e3),o=ca(e,s),a=o==="live";return i.jsxs("div",{className:`lease lease-${o} edge-note ${a?"":"edge-attention"}`,children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(V,{parts:[{text:`Claimed by ${e.agent}`,strong:!0},`active ${hn(s-e.renewedAt)} ago`]}),!a&&i.jsx(bn,{tone:"amber",children:"Stalled"})]}),i.jsx("p",{className:"t-meta lease-line",children:FR(o,UR(e.expiresAt-s))}),e.workspace&&i.jsxs("p",{className:"t-meta lease-branch",children:["Works on ",i.jsx("code",{className:"t-code",children:e.workspace.branch})," in its own worktree"]}),e.touches&&e.touches.length>0&&i.jsxs("p",{className:"t-meta lease-touches",children:["Expects to change"," ",e.touches.map((l,d)=>i.jsxs("span",{children:[d>0&&", ",i.jsx("code",{className:"t-code",children:l})]},l))]}),e.notes.length>0&&i.jsx("ul",{className:"lease-notes t-meta",children:e.notes.slice(-3).map((l,d)=>i.jsx("li",{children:l},d))}),i.jsx("div",{className:"actions",children:i.jsx(M,{variant:a?"default":"urgent",onClick:t,children:"Release to queue"})})]})}function FR(e,t){return e==="expired"?"Lease expired, going back to the queue":e==="stalled"?`The agent went quiet. Back in the queue in ${t}.`:`Back in the queue after ${t} without activity.`}function UR(e){const t=e/864e5;return t>=2?`${Math.round(t)} days`:Jt(Math.max(0,e))}function WR({comments:e}){const t=li();if(!e.length)return null;const s=e.length>1?"s":"";return i.jsxs("details",{className:"comments",children:[i.jsxs("summary",{className:"t-label",children:[e.length," other comment",s]}),e.map(o=>i.jsxs("div",{className:"comment",children:[i.jsx(V,{parts:[{text:ps(o.author,t),strong:!0}]}),i.jsx("div",{className:"c-body",children:o.body.replace(/\*\*/g,"")})]},o.id))]})}function HR({resolution:e,decisions:t,onOpenDecision:s}){const o=li(),a=t.find(h=>!h.supersededBy)??t[0],l=e.body.startsWith("**Ruled")?"ruled out":"resolution",d=t.length>1?` · ${t.length} in chain`:"";return i.jsxs("div",{className:"resolution edge-note edge-done",children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(V,{parts:[{text:ps(e.author,o),strong:!0},l]}),a&&s&&i.jsxs("button",{className:"link t-meta",onClick:()=>s(a.id),children:[a.id,d," ›"]})]}),i.jsx("p",{children:e.body.replace(/^\*\*[^*]+\*\*\s*/,"")})]})}function KR(e){const{t,state:s,session:o,mine:a,form:l,setForm:d,actions:h,onOpenChat:f}=e;return i.jsxs("div",{className:"actions",children:[o&&i.jsx(M,{variant:o.waitingOn?"urgent":"default",onClick:()=>f(o.id),"data-tip":o.waitingOn?"The agent is waiting for your answer":"Open the conversation with this agent",children:o.waitingOn?"Answer":"Conversation"}),s==="frontier"&&i.jsx(M,{onClick:()=>h.claim(t.id),"data-tip":"Take this ticket yourself, so no agent picks it up",children:"Claim"}),(s==="frontier"||s==="claimed"&&a)&&i.jsx(M,{on:l==="resolve",onClick:()=>d(l==="resolve"?null:"resolve"),"data-tip":"Answer it yourself and close the ticket, with a decision record",children:"Resolve…"}),a&&s==="claimed"&&i.jsx(M,{onClick:()=>h.release(t.id),"data-tip":"Give the ticket back to the queue",children:"Release"}),(s==="frontier"||s==="blocked"||s==="parked")&&i.jsx(M,{variant:"danger",on:l==="rule",onClick:()=>d(l==="rule"?null:"rule"),"data-tip":"Move it out of scope. It's set aside with your reason, not deleted",children:"Rule out…"})]})}function VR(e){return e.replace(/\s*Part of trail \S+\.\s*$/,"").trim()}function GR({t:e,state:t,tickets:s}){const o=new Map(s.map(p=>[p.id,p])),a=p=>{var v;return((v=o.get(p))==null?void 0:v.key)??p},l=e.blockedBy.map(p=>{var v;return`${a(p)}${((v=o.get(p))==null?void 0:v.state)==="closed"?" ✓":""}`}).join(", "),d=s.filter(p=>p.blockedBy.includes(e.id)).map(p=>p.key).join(", "),h=[["Type",Zs[e.type]],["Assignee",e.assignee],["Blocked by",l],["Blocks",d],["Reviews",e.reviewOf&&a(e.reviewOf)]],f=cr(e)==="hitl";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key t-code",children:e.key}),i.jsx(bn,{tone:"state",className:`st-${t}`,children:Dg[t]}),i.jsx("span",{className:"d-att t-meta","data-tip":f?"A person takes this one":"An agent takes this alone",children:f?"Needs a person":"Agent work"})]}),i.jsx("h3",{className:"t-heading",children:e.title}),i.jsx("dl",{className:"facts",children:h.filter(([,p])=>p).flatMap(([p,v])=>[i.jsx("dt",{className:"t-label",children:p},`${p}-k`),i.jsx("dd",{children:v},`${p}-v`)])})]})}function qR(e){const{snap:t,api:s,form:o,setForm:a}=e,{actions:l}=s,[d,h]=y.useState(""),[f,p]=y.useState(""),[v,k]=y.useState(""),[w,j]=y.useState("Not needed to reach the destination."),N=t.tickets.find(G=>G.id===e.id);if(!N)return i.jsx(Ie,{children:"Ticket not found."});const S=ti(t.tickets,t.map.mode).get(N.id),I=e.sessions.find(G=>G.ticketId===N.id&&dn(G)),$=N.assignee===St,_=N.state==="open"?Rd(s.leases,t.map.id).get(N.id):void 0,O=[...N.comments].reverse().find(G=>/^\*\*(Resolution|Ruled out of scope)\*\*/.test(G.body)),D=N.comments.filter(G=>G!==O),q=VR(N.body),H=s.decisions.filter(G=>G.mapId===t.map.id&&G.ticketId===N.id);return i.jsxs("div",{className:"detail",children:[i.jsx(GR,{t:N,state:S,tickets:t.tickets}),i.jsx(lk,{mapId:t.map.id,kind:"ticket",id:N.id}),q&&i.jsxs("section",{className:"d-section ticket-body",children:[i.jsx("span",{className:"t-label",children:"Description"}),i.jsx("p",{className:"body",children:q})]}),i.jsx(A2,{mapId:t.map.id,ticketId:N.id}),i.jsx(EN,{mapId:t.map.id,ticketId:N.id}),i.jsx(MT,{mapId:t.map.id,ticket:N}),i.jsx(bR,{snap:t,t:N}),i.jsx(QN,{snap:t,t:N}),N.closeReason==="not_planned"&&i.jsx(Ud,{label:"Save as dead end",draft:()=>{var G;return{title:`Ruled out: ${N.title}`,body:((G=N.comments.at(-1))==null?void 0:G.body)??N.body,kind:"dead-end",sources:[`trail:${t.map.key}`,`ticket:${N.key}`]}}}),_&&i.jsx(BR,{lease:_,onRelease:()=>l.releaseLease(N.id)}),!_&&i.jsx(a2,{mapId:t.map.id,ticketId:N.id}),i.jsx(zR,{mapId:t.map.id,trail:t.map.verification,ticket:N,state:S}),i.jsx(BT,{mapId:t.map.id,ticket:N}),i.jsx(KR,{t:N,state:S,session:I,mine:$,form:o,setForm:a,actions:l,onOpenChat:e.onOpenChat}),o==="resolve"&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:G=>{G.preventDefault(),d.trim()&&(l.resolve(N.id,d.trim(),{rationale:f.trim(),alternatives:v.split(`
|
|
167
|
+
`).map(oe=>oe.trim()).filter(Boolean)}),a(null),h(""),p(""),k(""))},children:[i.jsx(Ze,{label:"Resolution",children:i.jsx("textarea",{rows:3,value:d,onChange:G=>h(G.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Rationale",children:i.jsx("input",{value:f,onChange:G=>p(G.target.value)})}),i.jsx(Ze,{label:"Alternatives considered",children:i.jsx("textarea",{rows:2,value:v,onChange:G=>k(G.target.value),placeholder:"One per line"})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(M,{variant:"ghost",onClick:()=>a(null),children:"Cancel"}),i.jsx(M,{type:"submit",variant:"primary",disabled:!d.trim(),children:"Resolve"})]})]}),o==="rule"&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:G=>{G.preventDefault(),l.ruleOut({ticketId:N.id},w),a(null)},children:[i.jsx(Ze,{label:"Reason",children:i.jsx("input",{value:w,onChange:G=>j(G.target.value),autoFocus:!0})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(M,{variant:"ghost",onClick:()=>a(null),children:"Cancel"}),i.jsx(M,{type:"submit",variant:"danger",children:"Rule out"})]})]}),O&&i.jsx(HR,{resolution:O,decisions:H,onOpenDecision:e.onOpenDecision}),i.jsx(WR,{comments:D})]})}function QR({snap:e,item:t,api:s}){const o=Xp(e.map.mode),[a,l]=y.useState("research"),[d,h]=y.useState(t),[f,p]=y.useState(!1),[v,k]=y.useState([]),[w,j]=y.useState("Not needed to reach the destination.");y.useEffect(()=>h(t),[t]);const N=e.tickets.filter(S=>S.state==="open");return i.jsxs("div",{className:"detail",children:[i.jsx("div",{className:"d-head",children:i.jsx(bn,{tone:"state",className:"st-unspecified",children:"Not yet specified"})}),i.jsx("h3",{className:"t-heading",children:t}),i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),s.actions.graduate({unspecified:t,type:a,title:d,blockedBy:v,hitl:f})},children:[i.jsx(Ze,{label:"Title",children:i.jsx("input",{value:d,onChange:S=>h(S.target.value)})}),i.jsxs("div",{className:"chips",children:[o.map(S=>i.jsx("button",{type:"button",className:`chip ${a===S?"on":""}`,onClick:()=>l(S),children:S},S)),Ew.includes(a)&&i.jsx("button",{type:"button",className:`chip ${f?"on":""}`,onClick:()=>p(S=>!S),children:"needs human"})]}),i.jsx("span",{className:"field",children:"Blocked by"}),i.jsx("div",{className:"chips",children:N.map(S=>i.jsx("button",{type:"button",className:`chip ${v.includes(S.id)?"on":""}`,onClick:()=>k(I=>I.includes(S.id)?I.filter($=>$!==S.id):[...I,S.id]),children:S.key},S.id))}),i.jsx("div",{className:"form-actions",children:i.jsx(M,{type:"submit",variant:"primary",children:"Promote to ticket"})})]}),i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),s.actions.ruleOut({unspecified:t},w)},children:[i.jsx(Ze,{label:"Reason",children:i.jsx("input",{value:w,onChange:S=>j(S.target.value)})}),i.jsx("div",{className:"form-actions",children:i.jsx(M,{type:"submit",variant:"danger",children:"Rule out"})})]})]})}function YR({api:e,sessions:t,bare:s,onOpenChat:o,onOpenDecision:a}){const{snap:l,selection:d,actions:h}=e,[f,p]=y.useState(null),v=JR(d);y.useEffect(()=>p(null),[v]);let k;return l?d?d.kind==="unspecified"?k=i.jsx(QR,{snap:l,item:d.item,api:e}):k=i.jsx(qR,{snap:l,id:d.id,api:e,sessions:t,form:f,setForm:p,onOpenChat:o??h.openChat,onOpenDecision:a}):k=i.jsx(Sn,{title:"No ticket selected",hint:"Pick a ticket on the map: what it is, who has it, what blocks it, and its decision."}):k=i.jsx(Sn,{title:"No trail yet",hint:"Once there's a trail, pick a ticket on the map to see it here."}),i.jsx(Zg,{area:"inspector",icon:"note",title:"Trail step",info:"The ticket you selected on the map: what it is, who has it, what blocks it, and its decision once it's made.",className:"inspector",bare:s,children:k})}function JR(e){return(e==null?void 0:e.kind)==="ticket"?e.id:(e==null?void 0:e.kind)==="unspecified"?e.item:""}const XR={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function ZR(e){if(e.decidedBy)return e.status==="invalidated"?`invalidated by ${e.decidedBy}`:e.status==="confirmed"?`confirmed by ${e.decidedBy==="trail lead"?"you":e.decidedBy}`:`kept by ${e.decidedBy}`}function eM(e){const{a:t,snap:s}=e,o=t.tickets.flatMap(l=>s.tickets.filter(d=>d.id===l)),a=t.challenge&&`${t.challenge.by}: ${t.challenge.evidence}`;return i.jsx(be,{as:"li",className:`assumption st-${t.status}`,edge:t.status==="challenged"?"attention":"neutral",title:t.text,titleText:t.text,context:i.jsx(V,{parts:[{text:t.id,code:!0},XR[t.status],ZR(t)],children:o.length>0&&i.jsxs("span",{className:"assumption-tickets",children:[i.jsx("span",{className:"sep",children:" · "}),"relied on by",o.map(l=>i.jsx("button",{className:"link t-code",onClick:()=>e.onSelect({kind:"ticket",id:l.id}),children:l.key},l.id))]})}),detail:a,detailText:a,actions:e.onConfirm&&i.jsx(M,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onConfirm,children:"Confirm"})})}function tM(e){const[t,s]=y.useState(),[o,a]=y.useState();return{confirm:async(d,h)=>{a(d);const f=await fetch(`${pe()}/assumptions/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,id:d,text:h})}).catch(()=>{});if(a(void 0),f!=null&&f.ok)return s(void 0);const p=await(f==null?void 0:f.json().catch(()=>({})));s((p==null?void 0:p.error)??"Could not confirm it; is the Lookout connected?")},busy:o,error:t}}function nM({snap:e,onSelect:t}){const{confirm:s,busy:o,error:a}=tM(e.map.id),l=e.map.sections.assumptions??[];return l.length?i.jsxs(i.Fragment,{children:[a&&i.jsx("p",{className:"urgent-text",children:a}),i.jsx("ul",{className:"assumptions row-list",children:l.map(d=>{const h=d.status==="holding"||d.status==="challenged";return i.jsx(eM,{a:d,snap:e,onSelect:t,onConfirm:h?()=>void s(d.id,d.text):void 0,busy:o===d.id},d.id)})})]}):i.jsx(Ie,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function sM(e){const[,t,s=e]=/^(#\d+)\s+(.+)$/.exec(e)??[],[o=s,...a]=s.split(/\s+[—–]\s+/);return{key:t,title:o,reason:a.join(" — ")||void 0}}function iM(e){const[t,s]=y.useState([]),o=e==null?void 0:e.map.id,a=(e==null?void 0:e.tickets.reduce((l,d)=>Math.max(l,d.updatedAt),e.map.updatedAt))??0;return y.useEffect(()=>{if(!o)return;let l=!0;return fetch(`${pe()}/journal?mapId=${encodeURIComponent(o)}`).then(d=>d.ok?d.json():{entries:[]}).then(d=>l&&s(d.entries)).catch(()=>l&&s([])),()=>{l=!1}},[o,a]),t}function rM({snap:e,activity:t,onTicket:s}){const o=iM(e),a=t.usageByMap[e.map.id],l=y.useMemo(()=>fg({snap:e,journal:o,answered:t.answered,usage:a}),[e,o,t.answered,a]),d=l.interventions,h=[["Done",`${l.done}`,`${l.done} done · ${l.cancelled} cancelled · ${l.open} open`],["Lead time",Qt(l.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",Qt(l.medianLeadMs),"Median time from a ticket's first claim to done"],["Interventions",`${d.total}`,`${d.answers} agent questions you answered + ${d.operatorActions} lifecycle calls you made (approve, send back, accept, unblock, cancel, release), of which ${d.reworkRequested} sent work back. Answers count while their sessions are on record.`],["Rework",`${l.rework.cycles}`,`Times work went back to rework, on ${l.rework.tickets} tickets`],["Reviews",`${l.reviews.passed}/${l.reviews.failed}`,`${l.reviews.passed} passed, ${l.reviews.failed} failed, ${l.reviews.needsHuman} needed you`],["Cost / ticket",l.spend.perVerifiedTicketUsd===void 0?"—":Js(l.spend.perVerifiedTicketUsd),`Cost per verified ticket: trail spend ${Js(l.spend.costUsd)} ÷ ${l.done} done tickets`]];return i.jsxs("div",{className:"report",children:[i.jsx("ul",{className:"report-stats",children:h.map(([f,p,v])=>i.jsxs("li",{"data-tip":v,children:[i.jsx("span",{className:"mono-label",children:f}),i.jsx("b",{children:p})]},f))}),i.jsxs("div",{className:"report-bar",children:[i.jsx("span",{className:"mono-label",children:"Tickets"}),i.jsx(M,{size:"sm",variant:"ghost","data-tip":"Download this report as markdown",onClick:()=>Og(`${e.map.key.replace("#","trail-")}-report.md`,$j(l,e.map.title)),children:"Export markdown"})]}),l.tickets.length?i.jsx("ul",{className:"list report-tickets",children:l.tickets.map(f=>i.jsx("li",{className:`out-${f.outcome}`,children:i.jsxs("button",{onClick:()=>s(f.id),"data-tip":`${f.outcome} · rework ${f.reworks} · reviews ${f.reviews.passed}/${f.reviews.failed} · your calls ${f.operatorActions}`,children:[i.jsx("span",{className:"key",children:f.key}),i.jsx("span",{className:"ttl",children:f.title}),i.jsx("span",{className:"lead",children:f.outcome==="done"?Qt(f.leadMs):f.outcome})]})},f.id))}):i.jsx(Ie,{children:"No tickets yet"})]})}function oM({tab:e,snap:t,selection:s,onSelect:o,activity:a}){const l=t.map.sections;switch(e){case"report":return a?i.jsx(rM,{snap:t,activity:a,onTicket:d=>o({kind:"ticket",id:d})}):i.jsx(Ie,{children:"No activity yet"});case"assumptions":return i.jsx(nM,{snap:t,onSelect:o});case"decisions":return l.decisions.length?i.jsx("ol",{className:"row-list decisions",children:[...l.decisions].reverse().map((d,h)=>i.jsx(be,{as:"li",title:d.text,titleText:d.text,context:d.ticketKey&&i.jsx(V,{parts:[{text:d.ticketKey,code:!0}]}),onOpen:d.ticketId?()=>o({kind:"ticket",id:d.ticketId}):void 0},`${d.ticketKey}-${h}`))}):i.jsx(Ie,{children:"None"});case"unspecified":return l.unspecified.length?i.jsx("ul",{className:"row-list unspecified",children:l.unspecified.map(d=>i.jsx(be,{as:"li",title:d,titleText:d,selected:(s==null?void 0:s.kind)==="unspecified"&&s.item===d,onOpen:()=>o({kind:"unspecified",item:d})},d))}):i.jsx(Ie,{children:"None"});case"oos":return l.outOfScope.length?i.jsx("ul",{className:"row-list oos",children:l.outOfScope.map(d=>{const h=sM(d);return i.jsx(be,{as:"li",title:h.title,titleText:d,context:i.jsx(V,{parts:[h.key&&{text:h.key,code:!0},h.reason]})},d)})}):i.jsx(Ie,{children:"None"});case"notes":return i.jsx("p",{className:"notes t-body",children:l.notes||"No notes yet."});default:return e}}function aM({snap:e,selection:t,onSelect:s,bare:o,onAudit:a,activity:l}){var k;const[d,h]=y.useState("unspecified"),f=e==null?void 0:e.map.sections,p=[{id:"unspecified",label:"Not yet specified",n:f==null?void 0:f.unspecified.length},{id:"assumptions",label:"Assumptions",n:(k=f==null?void 0:f.assumptions)==null?void 0:k.length},{id:"decisions",label:"Decisions",n:f==null?void 0:f.decisions.length},{id:"oos",label:"Out of scope",n:f==null?void 0:f.outOfScope.length},{id:"notes",label:"Notes"},{id:"report",label:"Report"}],v=e?i.jsx(oM,{tab:d,snap:e,selection:t,onSelect:s,activity:l}):i.jsx(Sn,{title:"No plan yet",hint:"Open questions, decisions, what's ruled out, notes and the trail report collect here."});return i.jsxs(Be,{className:`zone sections ${o?"bare":""}`,style:o?void 0:{gridArea:"plan"},children:[!o&&i.jsx(Et,{className:"zone-title",icon:"flag",title:"Trail plan",info:"The parts of the plan that aren't tickets yet: open questions still to specify, the assumptions the plan relies on, decisions already made, what's ruled out, and notes. Report shows how the trail is going: lead times, your interventions, rework, reviews and cost per verified ticket."}),i.jsxs("div",{className:"sections-tabs",children:[i.jsx(at,{compact:!0,"aria-label":"Plan section",value:d,onChange:h,options:p.map(w=>({value:w.id,label:w.n===void 0?w.label:`${w.label} · ${w.n}`}))}),d==="decisions"&&a&&i.jsx("button",{className:"link",onClick:a,children:"Audit ›"})]}),i.jsx("div",{className:"zone-b",children:v})]})}function lM(){var F;const e=y.useMemo(()=>tN(eN()),[]),t=mN(e),{snap:s,activity:o,selection:a,actions:l}=t,[d,h]=vN(),f=YA(),p=M$(e,t),v=ZA(e.kind),k=cN(),w=o.pending.length,j=eI(o,t.mapId);XA(w,s==null?void 0:s.map.title);const N=JA(t,k),S=II(s,l.selectMap),I=nb(S.briefText),$=OI({api:t,nav:N,knowledge:I,reviewBrief:S.review,openReroute:J=>S.openReroute(J.mapId,J.ref),openGuides:()=>f.open("guides"),openConnector:J=>f.open(J),openApprovals:()=>f.open("approvals"),openFocusSettings:()=>f.open("attention")}),_=uN(e,t,d.briefing,(F=$.attention.view)==null?void 0:F.items),O=i.jsx(b$,{api:t,nav:N,bp:k,scoped:j,attn:$,above:S.inboxCard}),D=i.jsx(VA,{api:t,sessions:j.sessions,onSelect:N.select,onNewTrail:p.open,compact:k==="mobile",minFit:k==="mobile"?.7:0,trail:S}),q=J=>i.jsx(YR,{api:t,sessions:j.sessions,bare:J,onOpenChat:ie=>N.openChat(ie),onOpenDecision:N.openDecisions}),H={activity:j,snap:s,leases:t.leases,onTicket:J=>N.select({kind:"ticket",id:J}),onOpenChat:J=>N.openChat(J)},G=J=>i.jsx(aM,{snap:s,selection:a,onSelect:N.select,bare:J,onAudit:()=>N.openDecisions(),activity:j}),{projects:oe,overview:Q,openOverview:ke}=ZI(k,N,$.link.request),Oe=f.route&&i.jsx(VE,{rt:e,api:t,bp:k,prefs:d,update:h,settings:f}),Te=(N.statsOpen||N.decisionsView)&&i.jsx(XI,{api:t,bp:k,nav:N}),ne=Oe||Q||Te,ce=_.shown&&i.jsx(CN,{brief:_,snaps:t.allSnaps,bp:k,openTicket:N.openTicket,openChat:N.openChat,openDecisions:N.openDecisions,closeDecisions:()=>N.setDecisionsView(null),showPhoneHome:()=>N.setPhoneTab("home")});return i.jsx(sv.Provider,{value:I,children:i.jsxs("div",{className:`app bp-${k}`,children:[i.jsx($b,{api:t,rt:e,repo:i.jsx(j2,{repo:v,projects:oe,onOverview:ke}),brief:_,attention:$.header,decisionsOpen:!!N.decisionsView,onDecisions:()=>{f.close(),N.decisionsView?N.setDecisionsView(null):N.openDecisions()},onStats:()=>{f.close(),N.toggleStats()},onNewTrail:p.open,onStartOver:()=>s&&p.startOver(s.map),onSettings:f.toggle,onSlack:()=>f.open("slack"),onToggleTheme:J=>h({theme:J?"night":"day"})}),k==="wide"&&i.jsxs(i.Fragment,{children:[O,D,q(!1),i.jsx(uR,{...H}),i.jsx(dR,{...H}),G(!1),ne]}),k==="laptop"&&i.jsxs(i.Fragment,{children:[O,D,i.jsx(GE,{tab:N.sideTab,onTab:N.setSideTab,unspecified:s==null?void 0:s.map.sections.unspecified.length,ticket:q(!0),activity:i.jsx(Lp,{...H}),plan:G(!0)}),ne]}),k==="mobile"&&i.jsxs(i.Fragment,{children:[i.jsx(QA,{tab:N.phoneTab,decisions:ne,inbox:O,projects:oe.many&&i.jsx(N2,{projects:oe,onOverview:ke}),map:D,ticket:q(!0),activity:i.jsx(Lp,{...H}),plan:G(!0)}),i.jsx(qA,{tab:N.phoneTab,covered:!!ne,pending:w,onPick:J=>{f.close(),N.setPhoneTab(J),N.setDecisionsView(null)}})]}),ce,S.dialog,t.error&&i.jsx("div",{className:"error-toast",children:t.error}),p.dialog,!d.onboarded&&i.jsx(bC,{prefs:d,update:h,activeTracker:e.kind}),i.jsx(ZN,{}),i.jsx(vR,{})]})})}const cM="X-Teamtrail-Session";function dM(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url}function uM(e){const t=new URL(dM(e),location.href),s=Z.apiPrefix;return t.origin===location.origin&&(t.pathname===s||t.pathname.startsWith(`${s}/`))}function hM(){const e=window.fetch.bind(window);window.fetch=(t,s)=>{const o=P1()?Ld():void 0;if(!o||!uM(t))return e(t,s);const a=new Headers((s==null?void 0:s.headers)??(t instanceof Request?t.headers:void 0));return a.set(cM,o.secret),e(t,{...s,headers:a})}}ma(Dd().theme);hM();jw.createRoot(document.getElementById("root")).render(i.jsxs(LE,{children:[i.jsx(lM,{}),i.jsx(jN,{})]}));
|