teamtrail 0.61.0 → 0.61.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
var sj=Object.defineProperty;var ij=(e,t,n)=>t in e?sj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var oe=(e,t,n)=>ij(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const c of a)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function n(a){const c={};return a.integrity&&(c.integrity=a.integrity),a.referrerPolicy&&(c.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?c.credentials="include":a.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(a){if(a.ep)return;a.ep=!0;const c=n(a);fetch(a.href,c)}})();var Wl={exports:{}},ar={},Hl={exports:{}},xe={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Bm;function rj(){if(Bm)return xe;Bm=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),d=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),k=Symbol.iterator;function w(E){return E===null||typeof E!="object"?null:(E=k&&E[k]||E["@@iterator"],typeof E=="function"?E:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,x={};function C(E,F,ae){this.props=E,this.context=F,this.refs=x,this.updater=ae||b}C.prototype.isReactComponent={},C.prototype.setState=function(E,F){if(typeof E!="object"&&typeof E!="function"&&E!=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,E,F,"setState")},C.prototype.forceUpdate=function(E){this.updater.enqueueForceUpdate(this,E,"forceUpdate")};function N(){}N.prototype=C.prototype;function P(E,F,ae){this.props=E,this.context=F,this.refs=x,this.updater=ae||b}var D=P.prototype=new N;D.constructor=P,S(D,C.prototype),D.isPureReactComponent=!0;var M=Array.isArray,H=Object.prototype.hasOwnProperty,_={current:null},Y={key:!0,ref:!0,__self:!0,__source:!0};function re(E,F,ae){var fe,we={},je=null,ge=null;if(F!=null)for(fe in F.ref!==void 0&&(ge=F.ref),F.key!==void 0&&(je=""+F.key),F)H.call(F,fe)&&!Y.hasOwnProperty(fe)&&(we[fe]=F[fe]);var Ne=arguments.length-2;if(Ne===1)we.children=ae;else if(1<Ne){for(var ve=Array(Ne),Ge=0;Ge<Ne;Ge++)ve[Ge]=arguments[Ge+2];we.children=ve}if(E&&E.defaultProps)for(fe in Ne=E.defaultProps,Ne)we[fe]===void 0&&(we[fe]=Ne[fe]);return{$$typeof:e,type:E,key:je,ref:ge,props:we,_owner:_.current}}function q(E,F){return{$$typeof:e,type:E.type,key:F,ref:E.ref,props:E.props,_owner:E._owner}}function Z(E){return typeof E=="object"&&E!==null&&E.$$typeof===e}function Ae(E){var F={"=":"=0",":":"=2"};return"$"+E.replace(/[=:]/g,function(ae){return F[ae]})}var ye=/\/+/g;function be(E,F){return typeof E=="object"&&E!==null&&E.key!=null?Ae(""+E.key):F.toString(36)}function de(E,F,ae,fe,we){var je=typeof E;(je==="undefined"||je==="boolean")&&(E=null);var ge=!1;if(E===null)ge=!0;else switch(je){case"string":case"number":ge=!0;break;case"object":switch(E.$$typeof){case e:case t:ge=!0}}if(ge)return ge=E,we=we(ge),E=fe===""?"."+be(ge,0):fe,M(we)?(ae="",E!=null&&(ae=E.replace(ye,"$&/")+"/"),de(we,F,ae,"",function(Ge){return Ge})):we!=null&&(Z(we)&&(we=q(we,ae+(!we.key||ge&&ge.key===we.key?"":(""+we.key).replace(ye,"$&/")+"/")+E)),F.push(we)),1;if(ge=0,fe=fe===""?".":fe+":",M(E))for(var Ne=0;Ne<E.length;Ne++){je=E[Ne];var ve=fe+be(je,Ne);ge+=de(je,F,ae,ve,we)}else if(ve=w(E),typeof ve=="function")for(E=ve.call(E),Ne=0;!(je=E.next()).done;)je=je.value,ve=fe+be(je,Ne++),ge+=de(je,F,ae,ve,we);else if(je==="object")throw F=String(E),Error("Objects are not valid as a React child (found: "+(F==="[object Object]"?"object with keys {"+Object.keys(E).join(", ")+"}":F)+"). If you meant to render a collection of children, use an array instead.");return ge}function Re(E,F,ae){if(E==null)return E;var fe=[],we=0;return de(E,fe,"","",function(je){return F.call(ae,je,we++)}),fe}function me(E){if(E._status===-1){var F=E._result;F=F(),F.then(function(ae){(E._status===0||E._status===-1)&&(E._status=1,E._result=ae)},function(ae){(E._status===0||E._status===-1)&&(E._status=2,E._result=ae)}),E._status===-1&&(E._status=0,E._result=F)}if(E._status===1)return E._result.default;throw E._result}var Se={current:null},z={transition:null},Q={ReactCurrentDispatcher:Se,ReactCurrentBatchConfig:z,ReactCurrentOwner:_};function U(){throw Error("act(...) is not supported in production builds of React.")}return xe.Children={map:Re,forEach:function(E,F,ae){Re(E,function(){F.apply(this,arguments)},ae)},count:function(E){var F=0;return Re(E,function(){F++}),F},toArray:function(E){return Re(E,function(F){return F})||[]},only:function(E){if(!Z(E))throw Error("React.Children.only expected to receive a single React element child.");return E}},xe.Component=C,xe.Fragment=n,xe.Profiler=a,xe.PureComponent=P,xe.StrictMode=i,xe.Suspense=f,xe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Q,xe.act=U,xe.cloneElement=function(E,F,ae){if(E==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+E+".");var fe=S({},E.props),we=E.key,je=E.ref,ge=E._owner;if(F!=null){if(F.ref!==void 0&&(je=F.ref,ge=_.current),F.key!==void 0&&(we=""+F.key),E.type&&E.type.defaultProps)var Ne=E.type.defaultProps;for(ve in F)H.call(F,ve)&&!Y.hasOwnProperty(ve)&&(fe[ve]=F[ve]===void 0&&Ne!==void 0?Ne[ve]:F[ve])}var ve=arguments.length-2;if(ve===1)fe.children=ae;else if(1<ve){Ne=Array(ve);for(var Ge=0;Ge<ve;Ge++)Ne[Ge]=arguments[Ge+2];fe.children=Ne}return{$$typeof:e,type:E.type,key:we,ref:je,props:fe,_owner:ge}},xe.createContext=function(E){return E={$$typeof:d,_currentValue:E,_currentValue2:E,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},E.Provider={$$typeof:c,_context:E},E.Consumer=E},xe.createElement=re,xe.createFactory=function(E){var F=re.bind(null,E);return F.type=E,F},xe.createRef=function(){return{current:null}},xe.forwardRef=function(E){return{$$typeof:u,render:E}},xe.isValidElement=Z,xe.lazy=function(E){return{$$typeof:g,_payload:{_status:-1,_result:E},_init:me}},xe.memo=function(E,F){return{$$typeof:m,type:E,compare:F===void 0?null:F}},xe.startTransition=function(E){var F=z.transition;z.transition={};try{E()}finally{z.transition=F}},xe.unstable_act=U,xe.useCallback=function(E,F){return Se.current.useCallback(E,F)},xe.useContext=function(E){return Se.current.useContext(E)},xe.useDebugValue=function(){},xe.useDeferredValue=function(E){return Se.current.useDeferredValue(E)},xe.useEffect=function(E,F){return Se.current.useEffect(E,F)},xe.useId=function(){return Se.current.useId()},xe.useImperativeHandle=function(E,F,ae){return Se.current.useImperativeHandle(E,F,ae)},xe.useInsertionEffect=function(E,F){return Se.current.useInsertionEffect(E,F)},xe.useLayoutEffect=function(E,F){return Se.current.useLayoutEffect(E,F)},xe.useMemo=function(E,F){return Se.current.useMemo(E,F)},xe.useReducer=function(E,F,ae){return Se.current.useReducer(E,F,ae)},xe.useRef=function(E){return Se.current.useRef(E)},xe.useState=function(E){return Se.current.useState(E)},xe.useSyncExternalStore=function(E,F,ae){return Se.current.useSyncExternalStore(E,F,ae)},xe.useTransition=function(){return Se.current.useTransition()},xe.version="18.3.1",xe}var Fm;function su(){return Fm||(Fm=1,Hl.exports=rj()),Hl.exports}/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.production.min.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var zm;function oj(){if(zm)return ar;zm=1;var e=su(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function d(u,f,m){var g,k={},w=null,b=null;m!==void 0&&(w=""+m),f.key!==void 0&&(w=""+f.key),f.ref!==void 0&&(b=f.ref);for(g in f)i.call(f,g)&&!c.hasOwnProperty(g)&&(k[g]=f[g]);if(u&&u.defaultProps)for(g in f=u.defaultProps,f)k[g]===void 0&&(k[g]=f[g]);return{$$typeof:t,type:u,key:w,ref:b,props:k,_owner:a.current}}return ar.Fragment=n,ar.jsx=d,ar.jsxs=d,ar}var Um;function aj(){return Um||(Um=1,Wl.exports=oj()),Wl.exports}var s=aj(),Fo={},Kl={exports:{}},Nt={},Gl={exports:{}},Vl={};/**
|
|
18
|
+
* @license React
|
|
19
|
+
* scheduler.production.min.js
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/var Wm;function cj(){return Wm||(Wm=1,(function(e){function t(z,Q){var U=z.length;z.push(Q);e:for(;0<U;){var E=U-1>>>1,F=z[E];if(0<a(F,Q))z[E]=Q,z[U]=F,U=E;else break e}}function n(z){return z.length===0?null:z[0]}function i(z){if(z.length===0)return null;var Q=z[0],U=z.pop();if(U!==Q){z[0]=U;e:for(var E=0,F=z.length,ae=F>>>1;E<ae;){var fe=2*(E+1)-1,we=z[fe],je=fe+1,ge=z[je];if(0>a(we,U))je<F&&0>a(ge,we)?(z[E]=ge,z[je]=U,E=je):(z[E]=we,z[fe]=U,E=fe);else if(je<F&&0>a(ge,U))z[E]=ge,z[je]=U,E=je;else break e}}return Q}function a(z,Q){var U=z.sortIndex-Q.sortIndex;return U!==0?U:z.id-Q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var d=Date,u=d.now();e.unstable_now=function(){return d.now()-u}}var f=[],m=[],g=1,k=null,w=3,b=!1,S=!1,x=!1,C=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function D(z){for(var Q=n(m);Q!==null;){if(Q.callback===null)i(m);else if(Q.startTime<=z)i(m),Q.sortIndex=Q.expirationTime,t(f,Q);else break;Q=n(m)}}function M(z){if(x=!1,D(z),!S)if(n(f)!==null)S=!0,me(H);else{var Q=n(m);Q!==null&&Se(M,Q.startTime-z)}}function H(z,Q){S=!1,x&&(x=!1,N(re),re=-1),b=!0;var U=w;try{for(D(Q),k=n(f);k!==null&&(!(k.expirationTime>Q)||z&&!Ae());){var E=k.callback;if(typeof E=="function"){k.callback=null,w=k.priorityLevel;var F=E(k.expirationTime<=Q);Q=e.unstable_now(),typeof F=="function"?k.callback=F:k===n(f)&&i(f),D(Q)}else i(f);k=n(f)}if(k!==null)var ae=!0;else{var fe=n(m);fe!==null&&Se(M,fe.startTime-Q),ae=!1}return ae}finally{k=null,w=U,b=!1}}var _=!1,Y=null,re=-1,q=5,Z=-1;function Ae(){return!(e.unstable_now()-Z<q)}function ye(){if(Y!==null){var z=e.unstable_now();Z=z;var Q=!0;try{Q=Y(!0,z)}finally{Q?be():(_=!1,Y=null)}}else _=!1}var be;if(typeof P=="function")be=function(){P(ye)};else if(typeof MessageChannel<"u"){var de=new MessageChannel,Re=de.port2;de.port1.onmessage=ye,be=function(){Re.postMessage(null)}}else be=function(){C(ye,0)};function me(z){Y=z,_||(_=!0,be())}function Se(z,Q){re=C(function(){z(e.unstable_now())},Q)}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(z){z.callback=null},e.unstable_continueExecution=function(){S||b||(S=!0,me(H))},e.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):q=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_getFirstCallbackNode=function(){return n(f)},e.unstable_next=function(z){switch(w){case 1:case 2:case 3:var Q=3;break;default:Q=w}var U=w;w=Q;try{return z()}finally{w=U}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(z,Q){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var U=w;w=z;try{return Q()}finally{w=U}},e.unstable_scheduleCallback=function(z,Q,U){var E=e.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?E+U:E):U=E,z){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=U+F,z={id:g++,callback:Q,priorityLevel:z,startTime:U,expirationTime:F,sortIndex:-1},U>E?(z.sortIndex=U,t(m,z),n(f)===null&&z===n(m)&&(x?(N(re),re=-1):x=!0,Se(M,U-E))):(z.sortIndex=F,t(f,z),S||b||(S=!0,me(H))),z},e.unstable_shouldYield=Ae,e.unstable_wrapCallback=function(z){var Q=w;return function(){var U=w;w=Q;try{return z.apply(this,arguments)}finally{w=U}}}})(Vl)),Vl}var Hm;function lj(){return Hm||(Hm=1,Gl.exports=cj()),Gl.exports}/**
|
|
26
|
+
* @license React
|
|
27
|
+
* react-dom.production.min.js
|
|
28
|
+
*
|
|
29
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/var Km;function dj(){if(Km)return Nt;Km=1;var e=su(),t=lj();function n(r){for(var o="https://reactjs.org/docs/error-decoder.html?invariant="+r,l=1;l<arguments.length;l++)o+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+r+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var i=new Set,a={};function c(r,o){d(r,o),d(r+"Capture",o)}function d(r,o){for(a[r]=o,r=0;r<o.length;r++)i.add(o[r])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),f=Object.prototype.hasOwnProperty,m=/^[: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]*$/,g={},k={};function w(r){return f.call(k,r)?!0:f.call(g,r)?!1:m.test(r)?k[r]=!0:(g[r]=!0,!1)}function b(r,o,l,h){if(l!==null&&l.type===0)return!1;switch(typeof o){case"function":case"symbol":return!0;case"boolean":return h?!1:l!==null?!l.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function S(r,o,l,h){if(o===null||typeof o>"u"||b(r,o,l,h))return!0;if(h)return!1;if(l!==null)switch(l.type){case 3:return!o;case 4:return o===!1;case 5:return isNaN(o);case 6:return isNaN(o)||1>o}return!1}function x(r,o,l,h,p,v,j){this.acceptsBooleans=o===2||o===3||o===4,this.attributeName=h,this.attributeNamespace=p,this.mustUseProperty=l,this.propertyName=r,this.type=o,this.sanitizeURL=v,this.removeEmptyString=j}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){C[r]=new x(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var o=r[0];C[o]=new x(o,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){C[r]=new x(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){C[r]=new x(r,2,!1,r,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(r){C[r]=new x(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){C[r]=new x(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){C[r]=new x(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){C[r]=new x(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){C[r]=new x(r,5,!1,r.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function P(r){return r[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(r){var o=r.replace(N,P);C[o]=new x(o,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var o=r.replace(N,P);C[o]=new x(o,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var o=r.replace(N,P);C[o]=new x(o,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){C[r]=new x(r,1,!1,r.toLowerCase(),null,!1,!1)}),C.xlinkHref=new x("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){C[r]=new x(r,1,!1,r.toLowerCase(),null,!0,!0)});function D(r,o,l,h){var p=C.hasOwnProperty(o)?C[o]:null;(p!==null?p.type!==0:h||!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(S(o,l,p,h)&&(l=null),h||p===null?w(o)&&(l===null?r.removeAttribute(o):r.setAttribute(o,""+l)):p.mustUseProperty?r[p.propertyName]=l===null?p.type===3?!1:"":l:(o=p.attributeName,h=p.attributeNamespace,l===null?r.removeAttribute(o):(p=p.type,l=p===3||p===4&&l===!0?"":""+l,h?r.setAttributeNS(h,o,l):r.setAttribute(o,l))))}var M=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,H=Symbol.for("react.element"),_=Symbol.for("react.portal"),Y=Symbol.for("react.fragment"),re=Symbol.for("react.strict_mode"),q=Symbol.for("react.profiler"),Z=Symbol.for("react.provider"),Ae=Symbol.for("react.context"),ye=Symbol.for("react.forward_ref"),be=Symbol.for("react.suspense"),de=Symbol.for("react.suspense_list"),Re=Symbol.for("react.memo"),me=Symbol.for("react.lazy"),Se=Symbol.for("react.offscreen"),z=Symbol.iterator;function Q(r){return r===null||typeof r!="object"?null:(r=z&&r[z]||r["@@iterator"],typeof r=="function"?r:null)}var U=Object.assign,E;function F(r){if(E===void 0)try{throw Error()}catch(l){var o=l.stack.trim().match(/\n( *(at )?)/);E=o&&o[1]||""}return`
|
|
34
|
+
`+E+r}var ae=!1;function fe(r,o){if(!r||ae)return"";ae=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(o)if(o=function(){throw Error()},Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(L){var h=L}Reflect.construct(r,[],o)}else{try{o.call()}catch(L){h=L}r.call(o.prototype)}else{try{throw Error()}catch(L){h=L}r()}}catch(L){if(L&&h&&typeof L.stack=="string"){for(var p=L.stack.split(`
|
|
35
|
+
`),v=h.stack.split(`
|
|
36
|
+
`),j=p.length-1,$=v.length-1;1<=j&&0<=$&&p[j]!==v[$];)$--;for(;1<=j&&0<=$;j--,$--)if(p[j]!==v[$]){if(j!==1||$!==1)do if(j--,$--,0>$||p[j]!==v[$]){var T=`
|
|
37
|
+
`+p[j].replace(" at new "," at ");return r.displayName&&T.includes("<anonymous>")&&(T=T.replace("<anonymous>",r.displayName)),T}while(1<=j&&0<=$);break}}}finally{ae=!1,Error.prepareStackTrace=l}return(r=r?r.displayName||r.name:"")?F(r):""}function we(r){switch(r.tag){case 5:return F(r.type);case 16:return F("Lazy");case 13:return F("Suspense");case 19:return F("SuspenseList");case 0:case 2:case 15:return r=fe(r.type,!1),r;case 11:return r=fe(r.type.render,!1),r;case 1:return r=fe(r.type,!0),r;default:return""}}function je(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case Y:return"Fragment";case _:return"Portal";case q:return"Profiler";case re:return"StrictMode";case be:return"Suspense";case de:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case Ae:return(r.displayName||"Context")+".Consumer";case Z:return(r._context.displayName||"Context")+".Provider";case ye:var o=r.render;return r=r.displayName,r||(r=o.displayName||o.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case Re:return o=r.displayName||null,o!==null?o:je(r.type)||"Memo";case me:o=r._payload,r=r._init;try{return je(r(o))}catch{}}return null}function ge(r){var o=r.type;switch(r.tag){case 24:return"Cache";case 9:return(o.displayName||"Context")+".Consumer";case 10:return(o._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=o.render,r=r.displayName||r.name||"",o.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return o;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return je(o);case 8:return o===re?"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 o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o}return null}function Ne(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function ve(r){var o=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function Ge(r){var o=ve(r)?"checked":"value",l=Object.getOwnPropertyDescriptor(r.constructor.prototype,o),h=""+r[o];if(!r.hasOwnProperty(o)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var p=l.get,v=l.set;return Object.defineProperty(r,o,{configurable:!0,get:function(){return p.call(this)},set:function(j){h=""+j,v.call(this,j)}}),Object.defineProperty(r,o,{enumerable:l.enumerable}),{getValue:function(){return h},setValue:function(j){h=""+j},stopTracking:function(){r._valueTracker=null,delete r[o]}}}}function Rn(r){r._valueTracker||(r._valueTracker=Ge(r))}function Ar(r){if(!r)return!1;var o=r._valueTracker;if(!o)return!0;var l=o.getValue(),h="";return r&&(h=ve(r)?r.checked?"true":"false":r.value),r=h,r!==l?(o.setValue(r),!0):!1}function As(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function Ya(r,o){var l=o.checked;return U({},o,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??r._wrapperState.initialChecked})}function Ku(r,o){var l=o.defaultValue==null?"":o.defaultValue,h=o.checked!=null?o.checked:o.defaultChecked;l=Ne(o.value!=null?o.value:l),r._wrapperState={initialChecked:h,initialValue:l,controlled:o.type==="checkbox"||o.type==="radio"?o.checked!=null:o.value!=null}}function Gu(r,o){o=o.checked,o!=null&&D(r,"checked",o,!1)}function Ja(r,o){Gu(r,o);var l=Ne(o.value),h=o.type;if(l!=null)h==="number"?(l===0&&r.value===""||r.value!=l)&&(r.value=""+l):r.value!==""+l&&(r.value=""+l);else if(h==="submit"||h==="reset"){r.removeAttribute("value");return}o.hasOwnProperty("value")?Xa(r,o.type,l):o.hasOwnProperty("defaultValue")&&Xa(r,o.type,Ne(o.defaultValue)),o.checked==null&&o.defaultChecked!=null&&(r.defaultChecked=!!o.defaultChecked)}function Vu(r,o,l){if(o.hasOwnProperty("value")||o.hasOwnProperty("defaultValue")){var h=o.type;if(!(h!=="submit"&&h!=="reset"||o.value!==void 0&&o.value!==null))return;o=""+r._wrapperState.initialValue,l||o===r.value||(r.value=o),r.defaultValue=o}l=r.name,l!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,l!==""&&(r.name=l)}function Xa(r,o,l){(o!=="number"||As(r.ownerDocument)!==r)&&(l==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+l&&(r.defaultValue=""+l))}var ji=Array.isArray;function Rs(r,o,l,h){if(r=r.options,o){o={};for(var p=0;p<l.length;p++)o["$"+l[p]]=!0;for(l=0;l<r.length;l++)p=o.hasOwnProperty("$"+r[l].value),r[l].selected!==p&&(r[l].selected=p),p&&h&&(r[l].defaultSelected=!0)}else{for(l=""+Ne(l),o=null,p=0;p<r.length;p++){if(r[p].value===l){r[p].selected=!0,h&&(r[p].defaultSelected=!0);return}o!==null||r[p].disabled||(o=r[p])}o!==null&&(o.selected=!0)}}function Za(r,o){if(o.dangerouslySetInnerHTML!=null)throw Error(n(91));return U({},o,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function qu(r,o){var l=o.value;if(l==null){if(l=o.children,o=o.defaultValue,l!=null){if(o!=null)throw Error(n(92));if(ji(l)){if(1<l.length)throw Error(n(93));l=l[0]}o=l}o==null&&(o=""),l=o}r._wrapperState={initialValue:Ne(l)}}function Qu(r,o){var l=Ne(o.value),h=Ne(o.defaultValue);l!=null&&(l=""+l,l!==r.value&&(r.value=l),o.defaultValue==null&&r.defaultValue!==l&&(r.defaultValue=l)),h!=null&&(r.defaultValue=""+h)}function Yu(r){var o=r.textContent;o===r._wrapperState.initialValue&&o!==""&&o!==null&&(r.value=o)}function Ju(r){switch(r){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 ec(r,o){return r==null||r==="http://www.w3.org/1999/xhtml"?Ju(o):r==="http://www.w3.org/2000/svg"&&o==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var Rr,Xu=(function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(o,l,h,p){MSApp.execUnsafeLocalFunction(function(){return r(o,l,h,p)})}:r})(function(r,o){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=o;else{for(Rr=Rr||document.createElement("div"),Rr.innerHTML="<svg>"+o.valueOf().toString()+"</svg>",o=Rr.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;o.firstChild;)r.appendChild(o.firstChild)}});function bi(r,o){if(o){var l=r.firstChild;if(l&&l===r.lastChild&&l.nodeType===3){l.nodeValue=o;return}}r.textContent=o}var Si={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},aw=["Webkit","ms","Moz","O"];Object.keys(Si).forEach(function(r){aw.forEach(function(o){o=o+r.charAt(0).toUpperCase()+r.substring(1),Si[o]=Si[r]})});function Zu(r,o,l){return o==null||typeof o=="boolean"||o===""?"":l||typeof o!="number"||o===0||Si.hasOwnProperty(r)&&Si[r]?(""+o).trim():o+"px"}function eh(r,o){r=r.style;for(var l in o)if(o.hasOwnProperty(l)){var h=l.indexOf("--")===0,p=Zu(l,o[l],h);l==="float"&&(l="cssFloat"),h?r.setProperty(l,p):r[l]=p}}var cw=U({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 tc(r,o){if(o){if(cw[r]&&(o.children!=null||o.dangerouslySetInnerHTML!=null))throw Error(n(137,r));if(o.dangerouslySetInnerHTML!=null){if(o.children!=null)throw Error(n(60));if(typeof o.dangerouslySetInnerHTML!="object"||!("__html"in o.dangerouslySetInnerHTML))throw Error(n(61))}if(o.style!=null&&typeof o.style!="object")throw Error(n(62))}}function nc(r,o){if(r.indexOf("-")===-1)return typeof o.is=="string";switch(r){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 sc=null;function ic(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var rc=null,Is=null,Ms=null;function th(r){if(r=Gi(r)){if(typeof rc!="function")throw Error(n(280));var o=r.stateNode;o&&(o=eo(o),rc(r.stateNode,r.type,o))}}function nh(r){Is?Ms?Ms.push(r):Ms=[r]:Is=r}function sh(){if(Is){var r=Is,o=Ms;if(Ms=Is=null,th(r),o)for(r=0;r<o.length;r++)th(o[r])}}function ih(r,o){return r(o)}function rh(){}var oc=!1;function oh(r,o,l){if(oc)return r(o,l);oc=!0;try{return ih(r,o,l)}finally{oc=!1,(Is!==null||Ms!==null)&&(rh(),sh())}}function Ni(r,o){var l=r.stateNode;if(l===null)return null;var h=eo(l);if(h===null)return null;l=h[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(h=!h.disabled)||(r=r.type,h=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!h;break e;default:r=!1}if(r)return null;if(l&&typeof l!="function")throw Error(n(231,o,typeof l));return l}var ac=!1;if(u)try{var $i={};Object.defineProperty($i,"passive",{get:function(){ac=!0}}),window.addEventListener("test",$i,$i),window.removeEventListener("test",$i,$i)}catch{ac=!1}function lw(r,o,l,h,p,v,j,$,T){var L=Array.prototype.slice.call(arguments,3);try{o.apply(l,L)}catch(K){this.onError(K)}}var Ci=!1,Ir=null,Mr=!1,cc=null,dw={onError:function(r){Ci=!0,Ir=r}};function uw(r,o,l,h,p,v,j,$,T){Ci=!1,Ir=null,lw.apply(dw,arguments)}function hw(r,o,l,h,p,v,j,$,T){if(uw.apply(this,arguments),Ci){if(Ci){var L=Ir;Ci=!1,Ir=null}else throw Error(n(198));Mr||(Mr=!0,cc=L)}}function as(r){var o=r,l=r;if(r.alternate)for(;o.return;)o=o.return;else{r=o;do o=r,(o.flags&4098)!==0&&(l=o.return),r=o.return;while(r)}return o.tag===3?l:null}function ah(r){if(r.tag===13){var o=r.memoizedState;if(o===null&&(r=r.alternate,r!==null&&(o=r.memoizedState)),o!==null)return o.dehydrated}return null}function ch(r){if(as(r)!==r)throw Error(n(188))}function fw(r){var o=r.alternate;if(!o){if(o=as(r),o===null)throw Error(n(188));return o!==r?null:r}for(var l=r,h=o;;){var p=l.return;if(p===null)break;var v=p.alternate;if(v===null){if(h=p.return,h!==null){l=h;continue}break}if(p.child===v.child){for(v=p.child;v;){if(v===l)return ch(p),r;if(v===h)return ch(p),o;v=v.sibling}throw Error(n(188))}if(l.return!==h.return)l=p,h=v;else{for(var j=!1,$=p.child;$;){if($===l){j=!0,l=p,h=v;break}if($===h){j=!0,h=p,l=v;break}$=$.sibling}if(!j){for($=v.child;$;){if($===l){j=!0,l=v,h=p;break}if($===h){j=!0,h=v,l=p;break}$=$.sibling}if(!j)throw Error(n(189))}}if(l.alternate!==h)throw Error(n(190))}if(l.tag!==3)throw Error(n(188));return l.stateNode.current===l?r:o}function lh(r){return r=fw(r),r!==null?dh(r):null}function dh(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var o=dh(r);if(o!==null)return o;r=r.sibling}return null}var uh=t.unstable_scheduleCallback,hh=t.unstable_cancelCallback,mw=t.unstable_shouldYield,pw=t.unstable_requestPaint,qe=t.unstable_now,gw=t.unstable_getCurrentPriorityLevel,lc=t.unstable_ImmediatePriority,fh=t.unstable_UserBlockingPriority,Or=t.unstable_NormalPriority,vw=t.unstable_LowPriority,mh=t.unstable_IdlePriority,Lr=null,on=null;function kw(r){if(on&&typeof on.onCommitFiberRoot=="function")try{on.onCommitFiberRoot(Lr,r,void 0,(r.current.flags&128)===128)}catch{}}var qt=Math.clz32?Math.clz32:xw,yw=Math.log,ww=Math.LN2;function xw(r){return r>>>=0,r===0?32:31-(yw(r)/ww|0)|0}var Pr=64,Dr=4194304;function Ti(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function _r(r,o){var l=r.pendingLanes;if(l===0)return 0;var h=0,p=r.suspendedLanes,v=r.pingedLanes,j=l&268435455;if(j!==0){var $=j&~p;$!==0?h=Ti($):(v&=j,v!==0&&(h=Ti(v)))}else j=l&~p,j!==0?h=Ti(j):v!==0&&(h=Ti(v));if(h===0)return 0;if(o!==0&&o!==h&&(o&p)===0&&(p=h&-h,v=o&-o,p>=v||p===16&&(v&4194240)!==0))return o;if((h&4)!==0&&(h|=l&16),o=r.entangledLanes,o!==0)for(r=r.entanglements,o&=h;0<o;)l=31-qt(o),p=1<<l,h|=r[l],o&=~p;return h}function jw(r,o){switch(r){case 1:case 2:case 4:return o+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 o+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 bw(r,o){for(var l=r.suspendedLanes,h=r.pingedLanes,p=r.expirationTimes,v=r.pendingLanes;0<v;){var j=31-qt(v),$=1<<j,T=p[j];T===-1?(($&l)===0||($&h)!==0)&&(p[j]=jw($,o)):T<=o&&(r.expiredLanes|=$),v&=~$}}function dc(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function ph(){var r=Pr;return Pr<<=1,(Pr&4194240)===0&&(Pr=64),r}function uc(r){for(var o=[],l=0;31>l;l++)o.push(r);return o}function Ei(r,o,l){r.pendingLanes|=o,o!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,o=31-qt(o),r[o]=l}function Sw(r,o){var l=r.pendingLanes&~o;r.pendingLanes=o,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=o,r.mutableReadLanes&=o,r.entangledLanes&=o,o=r.entanglements;var h=r.eventTimes;for(r=r.expirationTimes;0<l;){var p=31-qt(l),v=1<<p;o[p]=0,h[p]=-1,r[p]=-1,l&=~v}}function hc(r,o){var l=r.entangledLanes|=o;for(r=r.entanglements;l;){var h=31-qt(l),p=1<<h;p&o|r[h]&o&&(r[h]|=o),l&=~p}}var Ie=0;function gh(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var vh,fc,kh,yh,wh,mc=!1,Br=[],In=null,Mn=null,On=null,Ai=new Map,Ri=new Map,Ln=[],Nw="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 xh(r,o){switch(r){case"focusin":case"focusout":In=null;break;case"dragenter":case"dragleave":Mn=null;break;case"mouseover":case"mouseout":On=null;break;case"pointerover":case"pointerout":Ai.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ri.delete(o.pointerId)}}function Ii(r,o,l,h,p,v){return r===null||r.nativeEvent!==v?(r={blockedOn:o,domEventName:l,eventSystemFlags:h,nativeEvent:v,targetContainers:[p]},o!==null&&(o=Gi(o),o!==null&&fc(o)),r):(r.eventSystemFlags|=h,o=r.targetContainers,p!==null&&o.indexOf(p)===-1&&o.push(p),r)}function $w(r,o,l,h,p){switch(o){case"focusin":return In=Ii(In,r,o,l,h,p),!0;case"dragenter":return Mn=Ii(Mn,r,o,l,h,p),!0;case"mouseover":return On=Ii(On,r,o,l,h,p),!0;case"pointerover":var v=p.pointerId;return Ai.set(v,Ii(Ai.get(v)||null,r,o,l,h,p)),!0;case"gotpointercapture":return v=p.pointerId,Ri.set(v,Ii(Ri.get(v)||null,r,o,l,h,p)),!0}return!1}function jh(r){var o=cs(r.target);if(o!==null){var l=as(o);if(l!==null){if(o=l.tag,o===13){if(o=ah(l),o!==null){r.blockedOn=o,wh(r.priority,function(){kh(l)});return}}else if(o===3&&l.stateNode.current.memoizedState.isDehydrated){r.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}r.blockedOn=null}function Fr(r){if(r.blockedOn!==null)return!1;for(var o=r.targetContainers;0<o.length;){var l=gc(r.domEventName,r.eventSystemFlags,o[0],r.nativeEvent);if(l===null){l=r.nativeEvent;var h=new l.constructor(l.type,l);sc=h,l.target.dispatchEvent(h),sc=null}else return o=Gi(l),o!==null&&fc(o),r.blockedOn=l,!1;o.shift()}return!0}function bh(r,o,l){Fr(r)&&l.delete(o)}function Cw(){mc=!1,In!==null&&Fr(In)&&(In=null),Mn!==null&&Fr(Mn)&&(Mn=null),On!==null&&Fr(On)&&(On=null),Ai.forEach(bh),Ri.forEach(bh)}function Mi(r,o){r.blockedOn===o&&(r.blockedOn=null,mc||(mc=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Cw)))}function Oi(r){function o(p){return Mi(p,r)}if(0<Br.length){Mi(Br[0],r);for(var l=1;l<Br.length;l++){var h=Br[l];h.blockedOn===r&&(h.blockedOn=null)}}for(In!==null&&Mi(In,r),Mn!==null&&Mi(Mn,r),On!==null&&Mi(On,r),Ai.forEach(o),Ri.forEach(o),l=0;l<Ln.length;l++)h=Ln[l],h.blockedOn===r&&(h.blockedOn=null);for(;0<Ln.length&&(l=Ln[0],l.blockedOn===null);)jh(l),l.blockedOn===null&&Ln.shift()}var Os=M.ReactCurrentBatchConfig,zr=!0;function Tw(r,o,l,h){var p=Ie,v=Os.transition;Os.transition=null;try{Ie=1,pc(r,o,l,h)}finally{Ie=p,Os.transition=v}}function Ew(r,o,l,h){var p=Ie,v=Os.transition;Os.transition=null;try{Ie=4,pc(r,o,l,h)}finally{Ie=p,Os.transition=v}}function pc(r,o,l,h){if(zr){var p=gc(r,o,l,h);if(p===null)Mc(r,o,h,Ur,l),xh(r,h);else if($w(p,r,o,l,h))h.stopPropagation();else if(xh(r,h),o&4&&-1<Nw.indexOf(r)){for(;p!==null;){var v=Gi(p);if(v!==null&&vh(v),v=gc(r,o,l,h),v===null&&Mc(r,o,h,Ur,l),v===p)break;p=v}p!==null&&h.stopPropagation()}else Mc(r,o,h,null,l)}}var Ur=null;function gc(r,o,l,h){if(Ur=null,r=ic(h),r=cs(r),r!==null)if(o=as(r),o===null)r=null;else if(l=o.tag,l===13){if(r=ah(o),r!==null)return r;r=null}else if(l===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;r=null}else o!==r&&(r=null);return Ur=r,null}function Sh(r){switch(r){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(gw()){case lc:return 1;case fh:return 4;case Or:case vw:return 16;case mh:return 536870912;default:return 16}default:return 16}}var Pn=null,vc=null,Wr=null;function Nh(){if(Wr)return Wr;var r,o=vc,l=o.length,h,p="value"in Pn?Pn.value:Pn.textContent,v=p.length;for(r=0;r<l&&o[r]===p[r];r++);var j=l-r;for(h=1;h<=j&&o[l-h]===p[v-h];h++);return Wr=p.slice(r,1<h?1-h:void 0)}function Hr(r){var o=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&o===13&&(r=13)):r=o,r===10&&(r=13),32<=r||r===13?r:0}function Kr(){return!0}function $h(){return!1}function At(r){function o(l,h,p,v,j){this._reactName=l,this._targetInst=p,this.type=h,this.nativeEvent=v,this.target=j,this.currentTarget=null;for(var $ in r)r.hasOwnProperty($)&&(l=r[$],this[$]=l?l(v):v[$]);return this.isDefaultPrevented=(v.defaultPrevented!=null?v.defaultPrevented:v.returnValue===!1)?Kr:$h,this.isPropagationStopped=$h,this}return U(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Kr)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Kr)},persist:function(){},isPersistent:Kr}),o}var Ls={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},kc=At(Ls),Li=U({},Ls,{view:0,detail:0}),Aw=At(Li),yc,wc,Pi,Gr=U({},Li,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:jc,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==Pi&&(Pi&&r.type==="mousemove"?(yc=r.screenX-Pi.screenX,wc=r.screenY-Pi.screenY):wc=yc=0,Pi=r),yc)},movementY:function(r){return"movementY"in r?r.movementY:wc}}),Ch=At(Gr),Rw=U({},Gr,{dataTransfer:0}),Iw=At(Rw),Mw=U({},Li,{relatedTarget:0}),xc=At(Mw),Ow=U({},Ls,{animationName:0,elapsedTime:0,pseudoElement:0}),Lw=At(Ow),Pw=U({},Ls,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),Dw=At(Pw),_w=U({},Ls,{data:0}),Th=At(_w),Bw={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Fw={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"},zw={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Uw(r){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(r):(r=zw[r])?!!o[r]:!1}function jc(){return Uw}var Ww=U({},Li,{key:function(r){if(r.key){var o=Bw[r.key]||r.key;if(o!=="Unidentified")return o}return r.type==="keypress"?(r=Hr(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?Fw[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:jc,charCode:function(r){return r.type==="keypress"?Hr(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?Hr(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),Hw=At(Ww),Kw=U({},Gr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Eh=At(Kw),Gw=U({},Li,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:jc}),Vw=At(Gw),qw=U({},Ls,{propertyName:0,elapsedTime:0,pseudoElement:0}),Qw=At(qw),Yw=U({},Gr,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),Jw=At(Yw),Xw=[9,13,27,32],bc=u&&"CompositionEvent"in window,Di=null;u&&"documentMode"in document&&(Di=document.documentMode);var Zw=u&&"TextEvent"in window&&!Di,Ah=u&&(!bc||Di&&8<Di&&11>=Di),Rh=" ",Ih=!1;function Mh(r,o){switch(r){case"keyup":return Xw.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Oh(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Ps=!1;function ex(r,o){switch(r){case"compositionend":return Oh(o);case"keypress":return o.which!==32?null:(Ih=!0,Rh);case"textInput":return r=o.data,r===Rh&&Ih?null:r;default:return null}}function tx(r,o){if(Ps)return r==="compositionend"||!bc&&Mh(r,o)?(r=Nh(),Wr=vc=Pn=null,Ps=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return Ah&&o.locale!=="ko"?null:o.data;default:return null}}var nx={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 Lh(r){var o=r&&r.nodeName&&r.nodeName.toLowerCase();return o==="input"?!!nx[r.type]:o==="textarea"}function Ph(r,o,l,h){nh(h),o=Jr(o,"onChange"),0<o.length&&(l=new kc("onChange","change",null,l,h),r.push({event:l,listeners:o}))}var _i=null,Bi=null;function sx(r){ef(r,0)}function Vr(r){var o=zs(r);if(Ar(o))return r}function ix(r,o){if(r==="change")return o}var Dh=!1;if(u){var Sc;if(u){var Nc="oninput"in document;if(!Nc){var _h=document.createElement("div");_h.setAttribute("oninput","return;"),Nc=typeof _h.oninput=="function"}Sc=Nc}else Sc=!1;Dh=Sc&&(!document.documentMode||9<document.documentMode)}function Bh(){_i&&(_i.detachEvent("onpropertychange",Fh),Bi=_i=null)}function Fh(r){if(r.propertyName==="value"&&Vr(Bi)){var o=[];Ph(o,Bi,r,ic(r)),oh(sx,o)}}function rx(r,o,l){r==="focusin"?(Bh(),_i=o,Bi=l,_i.attachEvent("onpropertychange",Fh)):r==="focusout"&&Bh()}function ox(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return Vr(Bi)}function ax(r,o){if(r==="click")return Vr(o)}function cx(r,o){if(r==="input"||r==="change")return Vr(o)}function lx(r,o){return r===o&&(r!==0||1/r===1/o)||r!==r&&o!==o}var Qt=typeof Object.is=="function"?Object.is:lx;function Fi(r,o){if(Qt(r,o))return!0;if(typeof r!="object"||r===null||typeof o!="object"||o===null)return!1;var l=Object.keys(r),h=Object.keys(o);if(l.length!==h.length)return!1;for(h=0;h<l.length;h++){var p=l[h];if(!f.call(o,p)||!Qt(r[p],o[p]))return!1}return!0}function zh(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function Uh(r,o){var l=zh(r);r=0;for(var h;l;){if(l.nodeType===3){if(h=r+l.textContent.length,r<=o&&h>=o)return{node:l,offset:o-r};r=h}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=zh(l)}}function Wh(r,o){return r&&o?r===o?!0:r&&r.nodeType===3?!1:o&&o.nodeType===3?Wh(r,o.parentNode):"contains"in r?r.contains(o):r.compareDocumentPosition?!!(r.compareDocumentPosition(o)&16):!1:!1}function Hh(){for(var r=window,o=As();o instanceof r.HTMLIFrameElement;){try{var l=typeof o.contentWindow.location.href=="string"}catch{l=!1}if(l)r=o.contentWindow;else break;o=As(r.document)}return o}function $c(r){var o=r&&r.nodeName&&r.nodeName.toLowerCase();return o&&(o==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||o==="textarea"||r.contentEditable==="true")}function dx(r){var o=Hh(),l=r.focusedElem,h=r.selectionRange;if(o!==l&&l&&l.ownerDocument&&Wh(l.ownerDocument.documentElement,l)){if(h!==null&&$c(l)){if(o=h.start,r=h.end,r===void 0&&(r=o),"selectionStart"in l)l.selectionStart=o,l.selectionEnd=Math.min(r,l.value.length);else if(r=(o=l.ownerDocument||document)&&o.defaultView||window,r.getSelection){r=r.getSelection();var p=l.textContent.length,v=Math.min(h.start,p);h=h.end===void 0?v:Math.min(h.end,p),!r.extend&&v>h&&(p=h,h=v,v=p),p=Uh(l,v);var j=Uh(l,h);p&&j&&(r.rangeCount!==1||r.anchorNode!==p.node||r.anchorOffset!==p.offset||r.focusNode!==j.node||r.focusOffset!==j.offset)&&(o=o.createRange(),o.setStart(p.node,p.offset),r.removeAllRanges(),v>h?(r.addRange(o),r.extend(j.node,j.offset)):(o.setEnd(j.node,j.offset),r.addRange(o)))}}for(o=[],r=l;r=r.parentNode;)r.nodeType===1&&o.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<o.length;l++)r=o[l],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var ux=u&&"documentMode"in document&&11>=document.documentMode,Ds=null,Cc=null,zi=null,Tc=!1;function Kh(r,o,l){var h=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Tc||Ds==null||Ds!==As(h)||(h=Ds,"selectionStart"in h&&$c(h)?h={start:h.selectionStart,end:h.selectionEnd}:(h=(h.ownerDocument&&h.ownerDocument.defaultView||window).getSelection(),h={anchorNode:h.anchorNode,anchorOffset:h.anchorOffset,focusNode:h.focusNode,focusOffset:h.focusOffset}),zi&&Fi(zi,h)||(zi=h,h=Jr(Cc,"onSelect"),0<h.length&&(o=new kc("onSelect","select",null,o,l),r.push({event:o,listeners:h}),o.target=Ds)))}function qr(r,o){var l={};return l[r.toLowerCase()]=o.toLowerCase(),l["Webkit"+r]="webkit"+o,l["Moz"+r]="moz"+o,l}var _s={animationend:qr("Animation","AnimationEnd"),animationiteration:qr("Animation","AnimationIteration"),animationstart:qr("Animation","AnimationStart"),transitionend:qr("Transition","TransitionEnd")},Ec={},Gh={};u&&(Gh=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 Qr(r){if(Ec[r])return Ec[r];if(!_s[r])return r;var o=_s[r],l;for(l in o)if(o.hasOwnProperty(l)&&l in Gh)return Ec[r]=o[l];return r}var Vh=Qr("animationend"),qh=Qr("animationiteration"),Qh=Qr("animationstart"),Yh=Qr("transitionend"),Jh=new Map,Xh="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 Dn(r,o){Jh.set(r,o),c(o,[r])}for(var Ac=0;Ac<Xh.length;Ac++){var Rc=Xh[Ac],hx=Rc.toLowerCase(),fx=Rc[0].toUpperCase()+Rc.slice(1);Dn(hx,"on"+fx)}Dn(Vh,"onAnimationEnd"),Dn(qh,"onAnimationIteration"),Dn(Qh,"onAnimationStart"),Dn("dblclick","onDoubleClick"),Dn("focusin","onFocus"),Dn("focusout","onBlur"),Dn(Yh,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),c("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),c("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),c("onBeforeInput",["compositionend","keypress","textInput","paste"]),c("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),c("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),c("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ui="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(" "),mx=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ui));function Zh(r,o,l){var h=r.type||"unknown-event";r.currentTarget=l,hw(h,o,void 0,r),r.currentTarget=null}function ef(r,o){o=(o&4)!==0;for(var l=0;l<r.length;l++){var h=r[l],p=h.event;h=h.listeners;e:{var v=void 0;if(o)for(var j=h.length-1;0<=j;j--){var $=h[j],T=$.instance,L=$.currentTarget;if($=$.listener,T!==v&&p.isPropagationStopped())break e;Zh(p,$,L),v=T}else for(j=0;j<h.length;j++){if($=h[j],T=$.instance,L=$.currentTarget,$=$.listener,T!==v&&p.isPropagationStopped())break e;Zh(p,$,L),v=T}}}if(Mr)throw r=cc,Mr=!1,cc=null,r}function Pe(r,o){var l=o[Bc];l===void 0&&(l=o[Bc]=new Set);var h=r+"__bubble";l.has(h)||(tf(o,r,2,!1),l.add(h))}function Ic(r,o,l){var h=0;o&&(h|=4),tf(l,r,h,o)}var Yr="_reactListening"+Math.random().toString(36).slice(2);function Wi(r){if(!r[Yr]){r[Yr]=!0,i.forEach(function(l){l!=="selectionchange"&&(mx.has(l)||Ic(l,!1,r),Ic(l,!0,r))});var o=r.nodeType===9?r:r.ownerDocument;o===null||o[Yr]||(o[Yr]=!0,Ic("selectionchange",!1,o))}}function tf(r,o,l,h){switch(Sh(o)){case 1:var p=Tw;break;case 4:p=Ew;break;default:p=pc}l=p.bind(null,o,l,r),p=void 0,!ac||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(p=!0),h?p!==void 0?r.addEventListener(o,l,{capture:!0,passive:p}):r.addEventListener(o,l,!0):p!==void 0?r.addEventListener(o,l,{passive:p}):r.addEventListener(o,l,!1)}function Mc(r,o,l,h,p){var v=h;if((o&1)===0&&(o&2)===0&&h!==null)e:for(;;){if(h===null)return;var j=h.tag;if(j===3||j===4){var $=h.stateNode.containerInfo;if($===p||$.nodeType===8&&$.parentNode===p)break;if(j===4)for(j=h.return;j!==null;){var T=j.tag;if((T===3||T===4)&&(T=j.stateNode.containerInfo,T===p||T.nodeType===8&&T.parentNode===p))return;j=j.return}for(;$!==null;){if(j=cs($),j===null)return;if(T=j.tag,T===5||T===6){h=v=j;continue e}$=$.parentNode}}h=h.return}oh(function(){var L=v,K=ic(l),G=[];e:{var W=Jh.get(r);if(W!==void 0){var X=kc,te=r;switch(r){case"keypress":if(Hr(l)===0)break e;case"keydown":case"keyup":X=Hw;break;case"focusin":te="focus",X=xc;break;case"focusout":te="blur",X=xc;break;case"beforeblur":case"afterblur":X=xc;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":X=Ch;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":X=Iw;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":X=Vw;break;case Vh:case qh:case Qh:X=Lw;break;case Yh:X=Qw;break;case"scroll":X=Aw;break;case"wheel":X=Jw;break;case"copy":case"cut":case"paste":X=Dw;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":X=Eh}var ne=(o&4)!==0,Qe=!ne&&r==="scroll",R=ne?W!==null?W+"Capture":null:W;ne=[];for(var A=L,O;A!==null;){O=A;var V=O.stateNode;if(O.tag===5&&V!==null&&(O=V,R!==null&&(V=Ni(A,R),V!=null&&ne.push(Hi(A,V,O)))),Qe)break;A=A.return}0<ne.length&&(W=new X(W,te,null,l,K),G.push({event:W,listeners:ne}))}}if((o&7)===0){e:{if(W=r==="mouseover"||r==="pointerover",X=r==="mouseout"||r==="pointerout",W&&l!==sc&&(te=l.relatedTarget||l.fromElement)&&(cs(te)||te[vn]))break e;if((X||W)&&(W=K.window===K?K:(W=K.ownerDocument)?W.defaultView||W.parentWindow:window,X?(te=l.relatedTarget||l.toElement,X=L,te=te?cs(te):null,te!==null&&(Qe=as(te),te!==Qe||te.tag!==5&&te.tag!==6)&&(te=null)):(X=null,te=L),X!==te)){if(ne=Ch,V="onMouseLeave",R="onMouseEnter",A="mouse",(r==="pointerout"||r==="pointerover")&&(ne=Eh,V="onPointerLeave",R="onPointerEnter",A="pointer"),Qe=X==null?W:zs(X),O=te==null?W:zs(te),W=new ne(V,A+"leave",X,l,K),W.target=Qe,W.relatedTarget=O,V=null,cs(K)===L&&(ne=new ne(R,A+"enter",te,l,K),ne.target=O,ne.relatedTarget=Qe,V=ne),Qe=V,X&&te)t:{for(ne=X,R=te,A=0,O=ne;O;O=Bs(O))A++;for(O=0,V=R;V;V=Bs(V))O++;for(;0<A-O;)ne=Bs(ne),A--;for(;0<O-A;)R=Bs(R),O--;for(;A--;){if(ne===R||R!==null&&ne===R.alternate)break t;ne=Bs(ne),R=Bs(R)}ne=null}else ne=null;X!==null&&nf(G,W,X,ne,!1),te!==null&&Qe!==null&&nf(G,Qe,te,ne,!0)}}e:{if(W=L?zs(L):window,X=W.nodeName&&W.nodeName.toLowerCase(),X==="select"||X==="input"&&W.type==="file")var se=ix;else if(Lh(W))if(Dh)se=cx;else{se=ox;var ce=rx}else(X=W.nodeName)&&X.toLowerCase()==="input"&&(W.type==="checkbox"||W.type==="radio")&&(se=ax);if(se&&(se=se(r,L))){Ph(G,se,l,K);break e}ce&&ce(r,W,L),r==="focusout"&&(ce=W._wrapperState)&&ce.controlled&&W.type==="number"&&Xa(W,"number",W.value)}switch(ce=L?zs(L):window,r){case"focusin":(Lh(ce)||ce.contentEditable==="true")&&(Ds=ce,Cc=L,zi=null);break;case"focusout":zi=Cc=Ds=null;break;case"mousedown":Tc=!0;break;case"contextmenu":case"mouseup":case"dragend":Tc=!1,Kh(G,l,K);break;case"selectionchange":if(ux)break;case"keydown":case"keyup":Kh(G,l,K)}var le;if(bc)e:{switch(r){case"compositionstart":var ue="onCompositionStart";break e;case"compositionend":ue="onCompositionEnd";break e;case"compositionupdate":ue="onCompositionUpdate";break e}ue=void 0}else Ps?Mh(r,l)&&(ue="onCompositionEnd"):r==="keydown"&&l.keyCode===229&&(ue="onCompositionStart");ue&&(Ah&&l.locale!=="ko"&&(Ps||ue!=="onCompositionStart"?ue==="onCompositionEnd"&&Ps&&(le=Nh()):(Pn=K,vc="value"in Pn?Pn.value:Pn.textContent,Ps=!0)),ce=Jr(L,ue),0<ce.length&&(ue=new Th(ue,r,null,l,K),G.push({event:ue,listeners:ce}),le?ue.data=le:(le=Oh(l),le!==null&&(ue.data=le)))),(le=Zw?ex(r,l):tx(r,l))&&(L=Jr(L,"onBeforeInput"),0<L.length&&(K=new Th("onBeforeInput","beforeinput",null,l,K),G.push({event:K,listeners:L}),K.data=le))}ef(G,o)})}function Hi(r,o,l){return{instance:r,listener:o,currentTarget:l}}function Jr(r,o){for(var l=o+"Capture",h=[];r!==null;){var p=r,v=p.stateNode;p.tag===5&&v!==null&&(p=v,v=Ni(r,l),v!=null&&h.unshift(Hi(r,v,p)),v=Ni(r,o),v!=null&&h.push(Hi(r,v,p))),r=r.return}return h}function Bs(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function nf(r,o,l,h,p){for(var v=o._reactName,j=[];l!==null&&l!==h;){var $=l,T=$.alternate,L=$.stateNode;if(T!==null&&T===h)break;$.tag===5&&L!==null&&($=L,p?(T=Ni(l,v),T!=null&&j.unshift(Hi(l,T,$))):p||(T=Ni(l,v),T!=null&&j.push(Hi(l,T,$)))),l=l.return}j.length!==0&&r.push({event:o,listeners:j})}var px=/\r\n?/g,gx=/\u0000|\uFFFD/g;function sf(r){return(typeof r=="string"?r:""+r).replace(px,`
|
|
38
|
+
`).replace(gx,"")}function Xr(r,o,l){if(o=sf(o),sf(r)!==o&&l)throw Error(n(425))}function Zr(){}var Oc=null,Lc=null;function Pc(r,o){return r==="textarea"||r==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var Dc=typeof setTimeout=="function"?setTimeout:void 0,vx=typeof clearTimeout=="function"?clearTimeout:void 0,rf=typeof Promise=="function"?Promise:void 0,kx=typeof queueMicrotask=="function"?queueMicrotask:typeof rf<"u"?function(r){return rf.resolve(null).then(r).catch(yx)}:Dc;function yx(r){setTimeout(function(){throw r})}function _c(r,o){var l=o,h=0;do{var p=l.nextSibling;if(r.removeChild(l),p&&p.nodeType===8)if(l=p.data,l==="/$"){if(h===0){r.removeChild(p),Oi(o);return}h--}else l!=="$"&&l!=="$?"&&l!=="$!"||h++;l=p}while(l);Oi(o)}function _n(r){for(;r!=null;r=r.nextSibling){var o=r.nodeType;if(o===1||o===3)break;if(o===8){if(o=r.data,o==="$"||o==="$!"||o==="$?")break;if(o==="/$")return null}}return r}function of(r){r=r.previousSibling;for(var o=0;r;){if(r.nodeType===8){var l=r.data;if(l==="$"||l==="$!"||l==="$?"){if(o===0)return r;o--}else l==="/$"&&o++}r=r.previousSibling}return null}var Fs=Math.random().toString(36).slice(2),an="__reactFiber$"+Fs,Ki="__reactProps$"+Fs,vn="__reactContainer$"+Fs,Bc="__reactEvents$"+Fs,wx="__reactListeners$"+Fs,xx="__reactHandles$"+Fs;function cs(r){var o=r[an];if(o)return o;for(var l=r.parentNode;l;){if(o=l[vn]||l[an]){if(l=o.alternate,o.child!==null||l!==null&&l.child!==null)for(r=of(r);r!==null;){if(l=r[an])return l;r=of(r)}return o}r=l,l=r.parentNode}return null}function Gi(r){return r=r[an]||r[vn],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function zs(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(n(33))}function eo(r){return r[Ki]||null}var Fc=[],Us=-1;function Bn(r){return{current:r}}function De(r){0>Us||(r.current=Fc[Us],Fc[Us]=null,Us--)}function Oe(r,o){Us++,Fc[Us]=r.current,r.current=o}var Fn={},lt=Bn(Fn),wt=Bn(!1),ls=Fn;function Ws(r,o){var l=r.type.contextTypes;if(!l)return Fn;var h=r.stateNode;if(h&&h.__reactInternalMemoizedUnmaskedChildContext===o)return h.__reactInternalMemoizedMaskedChildContext;var p={},v;for(v in l)p[v]=o[v];return h&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=o,r.__reactInternalMemoizedMaskedChildContext=p),p}function xt(r){return r=r.childContextTypes,r!=null}function to(){De(wt),De(lt)}function af(r,o,l){if(lt.current!==Fn)throw Error(n(168));Oe(lt,o),Oe(wt,l)}function cf(r,o,l){var h=r.stateNode;if(o=o.childContextTypes,typeof h.getChildContext!="function")return l;h=h.getChildContext();for(var p in h)if(!(p in o))throw Error(n(108,ge(r)||"Unknown",p));return U({},l,h)}function no(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Fn,ls=lt.current,Oe(lt,r),Oe(wt,wt.current),!0}function lf(r,o,l){var h=r.stateNode;if(!h)throw Error(n(169));l?(r=cf(r,o,ls),h.__reactInternalMemoizedMergedChildContext=r,De(wt),De(lt),Oe(lt,r)):De(wt),Oe(wt,l)}var kn=null,so=!1,zc=!1;function df(r){kn===null?kn=[r]:kn.push(r)}function jx(r){so=!0,df(r)}function zn(){if(!zc&&kn!==null){zc=!0;var r=0,o=Ie;try{var l=kn;for(Ie=1;r<l.length;r++){var h=l[r];do h=h(!0);while(h!==null)}kn=null,so=!1}catch(p){throw kn!==null&&(kn=kn.slice(r+1)),uh(lc,zn),p}finally{Ie=o,zc=!1}}return null}var Hs=[],Ks=0,io=null,ro=0,Lt=[],Pt=0,ds=null,yn=1,wn="";function us(r,o){Hs[Ks++]=ro,Hs[Ks++]=io,io=r,ro=o}function uf(r,o,l){Lt[Pt++]=yn,Lt[Pt++]=wn,Lt[Pt++]=ds,ds=r;var h=yn;r=wn;var p=32-qt(h)-1;h&=~(1<<p),l+=1;var v=32-qt(o)+p;if(30<v){var j=p-p%5;v=(h&(1<<j)-1).toString(32),h>>=j,p-=j,yn=1<<32-qt(o)+p|l<<p|h,wn=v+r}else yn=1<<v|l<<p|h,wn=r}function Uc(r){r.return!==null&&(us(r,1),uf(r,1,0))}function Wc(r){for(;r===io;)io=Hs[--Ks],Hs[Ks]=null,ro=Hs[--Ks],Hs[Ks]=null;for(;r===ds;)ds=Lt[--Pt],Lt[Pt]=null,wn=Lt[--Pt],Lt[Pt]=null,yn=Lt[--Pt],Lt[Pt]=null}var Rt=null,It=null,Be=!1,Yt=null;function hf(r,o){var l=Ft(5,null,null,0);l.elementType="DELETED",l.stateNode=o,l.return=r,o=r.deletions,o===null?(r.deletions=[l],r.flags|=16):o.push(l)}function ff(r,o){switch(r.tag){case 5:var l=r.type;return o=o.nodeType!==1||l.toLowerCase()!==o.nodeName.toLowerCase()?null:o,o!==null?(r.stateNode=o,Rt=r,It=_n(o.firstChild),!0):!1;case 6:return o=r.pendingProps===""||o.nodeType!==3?null:o,o!==null?(r.stateNode=o,Rt=r,It=null,!0):!1;case 13:return o=o.nodeType!==8?null:o,o!==null?(l=ds!==null?{id:yn,overflow:wn}:null,r.memoizedState={dehydrated:o,treeContext:l,retryLane:1073741824},l=Ft(18,null,null,0),l.stateNode=o,l.return=r,r.child=l,Rt=r,It=null,!0):!1;default:return!1}}function Hc(r){return(r.mode&1)!==0&&(r.flags&128)===0}function Kc(r){if(Be){var o=It;if(o){var l=o;if(!ff(r,o)){if(Hc(r))throw Error(n(418));o=_n(l.nextSibling);var h=Rt;o&&ff(r,o)?hf(h,l):(r.flags=r.flags&-4097|2,Be=!1,Rt=r)}}else{if(Hc(r))throw Error(n(418));r.flags=r.flags&-4097|2,Be=!1,Rt=r}}}function mf(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;Rt=r}function oo(r){if(r!==Rt)return!1;if(!Be)return mf(r),Be=!0,!1;var o;if((o=r.tag!==3)&&!(o=r.tag!==5)&&(o=r.type,o=o!=="head"&&o!=="body"&&!Pc(r.type,r.memoizedProps)),o&&(o=It)){if(Hc(r))throw pf(),Error(n(418));for(;o;)hf(r,o),o=_n(o.nextSibling)}if(mf(r),r.tag===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(317));e:{for(r=r.nextSibling,o=0;r;){if(r.nodeType===8){var l=r.data;if(l==="/$"){if(o===0){It=_n(r.nextSibling);break e}o--}else l!=="$"&&l!=="$!"&&l!=="$?"||o++}r=r.nextSibling}It=null}}else It=Rt?_n(r.stateNode.nextSibling):null;return!0}function pf(){for(var r=It;r;)r=_n(r.nextSibling)}function Gs(){It=Rt=null,Be=!1}function Gc(r){Yt===null?Yt=[r]:Yt.push(r)}var bx=M.ReactCurrentBatchConfig;function Vi(r,o,l){if(r=l.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(n(309));var h=l.stateNode}if(!h)throw Error(n(147,r));var p=h,v=""+r;return o!==null&&o.ref!==null&&typeof o.ref=="function"&&o.ref._stringRef===v?o.ref:(o=function(j){var $=p.refs;j===null?delete $[v]:$[v]=j},o._stringRef=v,o)}if(typeof r!="string")throw Error(n(284));if(!l._owner)throw Error(n(290,r))}return r}function ao(r,o){throw r=Object.prototype.toString.call(o),Error(n(31,r==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":r))}function gf(r){var o=r._init;return o(r._payload)}function vf(r){function o(R,A){if(r){var O=R.deletions;O===null?(R.deletions=[A],R.flags|=16):O.push(A)}}function l(R,A){if(!r)return null;for(;A!==null;)o(R,A),A=A.sibling;return null}function h(R,A){for(R=new Map;A!==null;)A.key!==null?R.set(A.key,A):R.set(A.index,A),A=A.sibling;return R}function p(R,A){return R=Qn(R,A),R.index=0,R.sibling=null,R}function v(R,A,O){return R.index=O,r?(O=R.alternate,O!==null?(O=O.index,O<A?(R.flags|=2,A):O):(R.flags|=2,A)):(R.flags|=1048576,A)}function j(R){return r&&R.alternate===null&&(R.flags|=2),R}function $(R,A,O,V){return A===null||A.tag!==6?(A=Dl(O,R.mode,V),A.return=R,A):(A=p(A,O),A.return=R,A)}function T(R,A,O,V){var se=O.type;return se===Y?K(R,A,O.props.children,V,O.key):A!==null&&(A.elementType===se||typeof se=="object"&&se!==null&&se.$$typeof===me&&gf(se)===A.type)?(V=p(A,O.props),V.ref=Vi(R,A,O),V.return=R,V):(V=Io(O.type,O.key,O.props,null,R.mode,V),V.ref=Vi(R,A,O),V.return=R,V)}function L(R,A,O,V){return A===null||A.tag!==4||A.stateNode.containerInfo!==O.containerInfo||A.stateNode.implementation!==O.implementation?(A=_l(O,R.mode,V),A.return=R,A):(A=p(A,O.children||[]),A.return=R,A)}function K(R,A,O,V,se){return A===null||A.tag!==7?(A=ys(O,R.mode,V,se),A.return=R,A):(A=p(A,O),A.return=R,A)}function G(R,A,O){if(typeof A=="string"&&A!==""||typeof A=="number")return A=Dl(""+A,R.mode,O),A.return=R,A;if(typeof A=="object"&&A!==null){switch(A.$$typeof){case H:return O=Io(A.type,A.key,A.props,null,R.mode,O),O.ref=Vi(R,null,A),O.return=R,O;case _:return A=_l(A,R.mode,O),A.return=R,A;case me:var V=A._init;return G(R,V(A._payload),O)}if(ji(A)||Q(A))return A=ys(A,R.mode,O,null),A.return=R,A;ao(R,A)}return null}function W(R,A,O,V){var se=A!==null?A.key:null;if(typeof O=="string"&&O!==""||typeof O=="number")return se!==null?null:$(R,A,""+O,V);if(typeof O=="object"&&O!==null){switch(O.$$typeof){case H:return O.key===se?T(R,A,O,V):null;case _:return O.key===se?L(R,A,O,V):null;case me:return se=O._init,W(R,A,se(O._payload),V)}if(ji(O)||Q(O))return se!==null?null:K(R,A,O,V,null);ao(R,O)}return null}function X(R,A,O,V,se){if(typeof V=="string"&&V!==""||typeof V=="number")return R=R.get(O)||null,$(A,R,""+V,se);if(typeof V=="object"&&V!==null){switch(V.$$typeof){case H:return R=R.get(V.key===null?O:V.key)||null,T(A,R,V,se);case _:return R=R.get(V.key===null?O:V.key)||null,L(A,R,V,se);case me:var ce=V._init;return X(R,A,O,ce(V._payload),se)}if(ji(V)||Q(V))return R=R.get(O)||null,K(A,R,V,se,null);ao(A,V)}return null}function te(R,A,O,V){for(var se=null,ce=null,le=A,ue=A=0,st=null;le!==null&&ue<O.length;ue++){le.index>ue?(st=le,le=null):st=le.sibling;var Ce=W(R,le,O[ue],V);if(Ce===null){le===null&&(le=st);break}r&&le&&Ce.alternate===null&&o(R,le),A=v(Ce,A,ue),ce===null?se=Ce:ce.sibling=Ce,ce=Ce,le=st}if(ue===O.length)return l(R,le),Be&&us(R,ue),se;if(le===null){for(;ue<O.length;ue++)le=G(R,O[ue],V),le!==null&&(A=v(le,A,ue),ce===null?se=le:ce.sibling=le,ce=le);return Be&&us(R,ue),se}for(le=h(R,le);ue<O.length;ue++)st=X(le,R,ue,O[ue],V),st!==null&&(r&&st.alternate!==null&&le.delete(st.key===null?ue:st.key),A=v(st,A,ue),ce===null?se=st:ce.sibling=st,ce=st);return r&&le.forEach(function(Yn){return o(R,Yn)}),Be&&us(R,ue),se}function ne(R,A,O,V){var se=Q(O);if(typeof se!="function")throw Error(n(150));if(O=se.call(O),O==null)throw Error(n(151));for(var ce=se=null,le=A,ue=A=0,st=null,Ce=O.next();le!==null&&!Ce.done;ue++,Ce=O.next()){le.index>ue?(st=le,le=null):st=le.sibling;var Yn=W(R,le,Ce.value,V);if(Yn===null){le===null&&(le=st);break}r&&le&&Yn.alternate===null&&o(R,le),A=v(Yn,A,ue),ce===null?se=Yn:ce.sibling=Yn,ce=Yn,le=st}if(Ce.done)return l(R,le),Be&&us(R,ue),se;if(le===null){for(;!Ce.done;ue++,Ce=O.next())Ce=G(R,Ce.value,V),Ce!==null&&(A=v(Ce,A,ue),ce===null?se=Ce:ce.sibling=Ce,ce=Ce);return Be&&us(R,ue),se}for(le=h(R,le);!Ce.done;ue++,Ce=O.next())Ce=X(le,R,ue,Ce.value,V),Ce!==null&&(r&&Ce.alternate!==null&&le.delete(Ce.key===null?ue:Ce.key),A=v(Ce,A,ue),ce===null?se=Ce:ce.sibling=Ce,ce=Ce);return r&&le.forEach(function(nj){return o(R,nj)}),Be&&us(R,ue),se}function Qe(R,A,O,V){if(typeof O=="object"&&O!==null&&O.type===Y&&O.key===null&&(O=O.props.children),typeof O=="object"&&O!==null){switch(O.$$typeof){case H:e:{for(var se=O.key,ce=A;ce!==null;){if(ce.key===se){if(se=O.type,se===Y){if(ce.tag===7){l(R,ce.sibling),A=p(ce,O.props.children),A.return=R,R=A;break e}}else if(ce.elementType===se||typeof se=="object"&&se!==null&&se.$$typeof===me&&gf(se)===ce.type){l(R,ce.sibling),A=p(ce,O.props),A.ref=Vi(R,ce,O),A.return=R,R=A;break e}l(R,ce);break}else o(R,ce);ce=ce.sibling}O.type===Y?(A=ys(O.props.children,R.mode,V,O.key),A.return=R,R=A):(V=Io(O.type,O.key,O.props,null,R.mode,V),V.ref=Vi(R,A,O),V.return=R,R=V)}return j(R);case _:e:{for(ce=O.key;A!==null;){if(A.key===ce)if(A.tag===4&&A.stateNode.containerInfo===O.containerInfo&&A.stateNode.implementation===O.implementation){l(R,A.sibling),A=p(A,O.children||[]),A.return=R,R=A;break e}else{l(R,A);break}else o(R,A);A=A.sibling}A=_l(O,R.mode,V),A.return=R,R=A}return j(R);case me:return ce=O._init,Qe(R,A,ce(O._payload),V)}if(ji(O))return te(R,A,O,V);if(Q(O))return ne(R,A,O,V);ao(R,O)}return typeof O=="string"&&O!==""||typeof O=="number"?(O=""+O,A!==null&&A.tag===6?(l(R,A.sibling),A=p(A,O),A.return=R,R=A):(l(R,A),A=Dl(O,R.mode,V),A.return=R,R=A),j(R)):l(R,A)}return Qe}var Vs=vf(!0),kf=vf(!1),co=Bn(null),lo=null,qs=null,Vc=null;function qc(){Vc=qs=lo=null}function Qc(r){var o=co.current;De(co),r._currentValue=o}function Yc(r,o,l){for(;r!==null;){var h=r.alternate;if((r.childLanes&o)!==o?(r.childLanes|=o,h!==null&&(h.childLanes|=o)):h!==null&&(h.childLanes&o)!==o&&(h.childLanes|=o),r===l)break;r=r.return}}function Qs(r,o){lo=r,Vc=qs=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&o)!==0&&(jt=!0),r.firstContext=null)}function Dt(r){var o=r._currentValue;if(Vc!==r)if(r={context:r,memoizedValue:o,next:null},qs===null){if(lo===null)throw Error(n(308));qs=r,lo.dependencies={lanes:0,firstContext:r}}else qs=qs.next=r;return o}var hs=null;function Jc(r){hs===null?hs=[r]:hs.push(r)}function yf(r,o,l,h){var p=o.interleaved;return p===null?(l.next=l,Jc(o)):(l.next=p.next,p.next=l),o.interleaved=l,xn(r,h)}function xn(r,o){r.lanes|=o;var l=r.alternate;for(l!==null&&(l.lanes|=o),l=r,r=r.return;r!==null;)r.childLanes|=o,l=r.alternate,l!==null&&(l.childLanes|=o),l=r,r=r.return;return l.tag===3?l.stateNode:null}var Un=!1;function Xc(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function wf(r,o){r=r.updateQueue,o.updateQueue===r&&(o.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function jn(r,o){return{eventTime:r,lane:o,tag:0,payload:null,callback:null,next:null}}function Wn(r,o,l){var h=r.updateQueue;if(h===null)return null;if(h=h.shared,($e&2)!==0){var p=h.pending;return p===null?o.next=o:(o.next=p.next,p.next=o),h.pending=o,xn(r,l)}return p=h.interleaved,p===null?(o.next=o,Jc(h)):(o.next=p.next,p.next=o),h.interleaved=o,xn(r,l)}function uo(r,o,l){if(o=o.updateQueue,o!==null&&(o=o.shared,(l&4194240)!==0)){var h=o.lanes;h&=r.pendingLanes,l|=h,o.lanes=l,hc(r,l)}}function xf(r,o){var l=r.updateQueue,h=r.alternate;if(h!==null&&(h=h.updateQueue,l===h)){var p=null,v=null;if(l=l.firstBaseUpdate,l!==null){do{var j={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};v===null?p=v=j:v=v.next=j,l=l.next}while(l!==null);v===null?p=v=o:v=v.next=o}else p=v=o;l={baseState:h.baseState,firstBaseUpdate:p,lastBaseUpdate:v,shared:h.shared,effects:h.effects},r.updateQueue=l;return}r=l.lastBaseUpdate,r===null?l.firstBaseUpdate=o:r.next=o,l.lastBaseUpdate=o}function ho(r,o,l,h){var p=r.updateQueue;Un=!1;var v=p.firstBaseUpdate,j=p.lastBaseUpdate,$=p.shared.pending;if($!==null){p.shared.pending=null;var T=$,L=T.next;T.next=null,j===null?v=L:j.next=L,j=T;var K=r.alternate;K!==null&&(K=K.updateQueue,$=K.lastBaseUpdate,$!==j&&($===null?K.firstBaseUpdate=L:$.next=L,K.lastBaseUpdate=T))}if(v!==null){var G=p.baseState;j=0,K=L=T=null,$=v;do{var W=$.lane,X=$.eventTime;if((h&W)===W){K!==null&&(K=K.next={eventTime:X,lane:0,tag:$.tag,payload:$.payload,callback:$.callback,next:null});e:{var te=r,ne=$;switch(W=o,X=l,ne.tag){case 1:if(te=ne.payload,typeof te=="function"){G=te.call(X,G,W);break e}G=te;break e;case 3:te.flags=te.flags&-65537|128;case 0:if(te=ne.payload,W=typeof te=="function"?te.call(X,G,W):te,W==null)break e;G=U({},G,W);break e;case 2:Un=!0}}$.callback!==null&&$.lane!==0&&(r.flags|=64,W=p.effects,W===null?p.effects=[$]:W.push($))}else X={eventTime:X,lane:W,tag:$.tag,payload:$.payload,callback:$.callback,next:null},K===null?(L=K=X,T=G):K=K.next=X,j|=W;if($=$.next,$===null){if($=p.shared.pending,$===null)break;W=$,$=W.next,W.next=null,p.lastBaseUpdate=W,p.shared.pending=null}}while(!0);if(K===null&&(T=G),p.baseState=T,p.firstBaseUpdate=L,p.lastBaseUpdate=K,o=p.shared.interleaved,o!==null){p=o;do j|=p.lane,p=p.next;while(p!==o)}else v===null&&(p.shared.lanes=0);ps|=j,r.lanes=j,r.memoizedState=G}}function jf(r,o,l){if(r=o.effects,o.effects=null,r!==null)for(o=0;o<r.length;o++){var h=r[o],p=h.callback;if(p!==null){if(h.callback=null,h=l,typeof p!="function")throw Error(n(191,p));p.call(h)}}}var qi={},cn=Bn(qi),Qi=Bn(qi),Yi=Bn(qi);function fs(r){if(r===qi)throw Error(n(174));return r}function Zc(r,o){switch(Oe(Yi,o),Oe(Qi,r),Oe(cn,qi),r=o.nodeType,r){case 9:case 11:o=(o=o.documentElement)?o.namespaceURI:ec(null,"");break;default:r=r===8?o.parentNode:o,o=r.namespaceURI||null,r=r.tagName,o=ec(o,r)}De(cn),Oe(cn,o)}function Ys(){De(cn),De(Qi),De(Yi)}function bf(r){fs(Yi.current);var o=fs(cn.current),l=ec(o,r.type);o!==l&&(Oe(Qi,r),Oe(cn,l))}function el(r){Qi.current===r&&(De(cn),De(Qi))}var ze=Bn(0);function fo(r){for(var o=r;o!==null;){if(o.tag===13){var l=o.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return o}else if(o.tag===19&&o.memoizedProps.revealOrder!==void 0){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===r)break;for(;o.sibling===null;){if(o.return===null||o.return===r)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var tl=[];function nl(){for(var r=0;r<tl.length;r++)tl[r]._workInProgressVersionPrimary=null;tl.length=0}var mo=M.ReactCurrentDispatcher,sl=M.ReactCurrentBatchConfig,ms=0,Ue=null,Ze=null,tt=null,po=!1,Ji=!1,Xi=0,Sx=0;function dt(){throw Error(n(321))}function il(r,o){if(o===null)return!1;for(var l=0;l<o.length&&l<r.length;l++)if(!Qt(r[l],o[l]))return!1;return!0}function rl(r,o,l,h,p,v){if(ms=v,Ue=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,mo.current=r===null||r.memoizedState===null?Tx:Ex,r=l(h,p),Ji){v=0;do{if(Ji=!1,Xi=0,25<=v)throw Error(n(301));v+=1,tt=Ze=null,o.updateQueue=null,mo.current=Ax,r=l(h,p)}while(Ji)}if(mo.current=ko,o=Ze!==null&&Ze.next!==null,ms=0,tt=Ze=Ue=null,po=!1,o)throw Error(n(300));return r}function ol(){var r=Xi!==0;return Xi=0,r}function ln(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return tt===null?Ue.memoizedState=tt=r:tt=tt.next=r,tt}function _t(){if(Ze===null){var r=Ue.alternate;r=r!==null?r.memoizedState:null}else r=Ze.next;var o=tt===null?Ue.memoizedState:tt.next;if(o!==null)tt=o,Ze=r;else{if(r===null)throw Error(n(310));Ze=r,r={memoizedState:Ze.memoizedState,baseState:Ze.baseState,baseQueue:Ze.baseQueue,queue:Ze.queue,next:null},tt===null?Ue.memoizedState=tt=r:tt=tt.next=r}return tt}function Zi(r,o){return typeof o=="function"?o(r):o}function al(r){var o=_t(),l=o.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=r;var h=Ze,p=h.baseQueue,v=l.pending;if(v!==null){if(p!==null){var j=p.next;p.next=v.next,v.next=j}h.baseQueue=p=v,l.pending=null}if(p!==null){v=p.next,h=h.baseState;var $=j=null,T=null,L=v;do{var K=L.lane;if((ms&K)===K)T!==null&&(T=T.next={lane:0,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null}),h=L.hasEagerState?L.eagerState:r(h,L.action);else{var G={lane:K,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null};T===null?($=T=G,j=h):T=T.next=G,Ue.lanes|=K,ps|=K}L=L.next}while(L!==null&&L!==v);T===null?j=h:T.next=$,Qt(h,o.memoizedState)||(jt=!0),o.memoizedState=h,o.baseState=j,o.baseQueue=T,l.lastRenderedState=h}if(r=l.interleaved,r!==null){p=r;do v=p.lane,Ue.lanes|=v,ps|=v,p=p.next;while(p!==r)}else p===null&&(l.lanes=0);return[o.memoizedState,l.dispatch]}function cl(r){var o=_t(),l=o.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=r;var h=l.dispatch,p=l.pending,v=o.memoizedState;if(p!==null){l.pending=null;var j=p=p.next;do v=r(v,j.action),j=j.next;while(j!==p);Qt(v,o.memoizedState)||(jt=!0),o.memoizedState=v,o.baseQueue===null&&(o.baseState=v),l.lastRenderedState=v}return[v,h]}function Sf(){}function Nf(r,o){var l=Ue,h=_t(),p=o(),v=!Qt(h.memoizedState,p);if(v&&(h.memoizedState=p,jt=!0),h=h.queue,ll(Tf.bind(null,l,h,r),[r]),h.getSnapshot!==o||v||tt!==null&&tt.memoizedState.tag&1){if(l.flags|=2048,er(9,Cf.bind(null,l,h,p,o),void 0,null),nt===null)throw Error(n(349));(ms&30)!==0||$f(l,o,p)}return p}function $f(r,o,l){r.flags|=16384,r={getSnapshot:o,value:l},o=Ue.updateQueue,o===null?(o={lastEffect:null,stores:null},Ue.updateQueue=o,o.stores=[r]):(l=o.stores,l===null?o.stores=[r]:l.push(r))}function Cf(r,o,l,h){o.value=l,o.getSnapshot=h,Ef(o)&&Af(r)}function Tf(r,o,l){return l(function(){Ef(o)&&Af(r)})}function Ef(r){var o=r.getSnapshot;r=r.value;try{var l=o();return!Qt(r,l)}catch{return!0}}function Af(r){var o=xn(r,1);o!==null&&en(o,r,1,-1)}function Rf(r){var o=ln();return typeof r=="function"&&(r=r()),o.memoizedState=o.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Zi,lastRenderedState:r},o.queue=r,r=r.dispatch=Cx.bind(null,Ue,r),[o.memoizedState,r]}function er(r,o,l,h){return r={tag:r,create:o,destroy:l,deps:h,next:null},o=Ue.updateQueue,o===null?(o={lastEffect:null,stores:null},Ue.updateQueue=o,o.lastEffect=r.next=r):(l=o.lastEffect,l===null?o.lastEffect=r.next=r:(h=l.next,l.next=r,r.next=h,o.lastEffect=r)),r}function If(){return _t().memoizedState}function go(r,o,l,h){var p=ln();Ue.flags|=r,p.memoizedState=er(1|o,l,void 0,h===void 0?null:h)}function vo(r,o,l,h){var p=_t();h=h===void 0?null:h;var v=void 0;if(Ze!==null){var j=Ze.memoizedState;if(v=j.destroy,h!==null&&il(h,j.deps)){p.memoizedState=er(o,l,v,h);return}}Ue.flags|=r,p.memoizedState=er(1|o,l,v,h)}function Mf(r,o){return go(8390656,8,r,o)}function ll(r,o){return vo(2048,8,r,o)}function Of(r,o){return vo(4,2,r,o)}function Lf(r,o){return vo(4,4,r,o)}function Pf(r,o){if(typeof o=="function")return r=r(),o(r),function(){o(null)};if(o!=null)return r=r(),o.current=r,function(){o.current=null}}function Df(r,o,l){return l=l!=null?l.concat([r]):null,vo(4,4,Pf.bind(null,o,r),l)}function dl(){}function _f(r,o){var l=_t();o=o===void 0?null:o;var h=l.memoizedState;return h!==null&&o!==null&&il(o,h[1])?h[0]:(l.memoizedState=[r,o],r)}function Bf(r,o){var l=_t();o=o===void 0?null:o;var h=l.memoizedState;return h!==null&&o!==null&&il(o,h[1])?h[0]:(r=r(),l.memoizedState=[r,o],r)}function Ff(r,o,l){return(ms&21)===0?(r.baseState&&(r.baseState=!1,jt=!0),r.memoizedState=l):(Qt(l,o)||(l=ph(),Ue.lanes|=l,ps|=l,r.baseState=!0),o)}function Nx(r,o){var l=Ie;Ie=l!==0&&4>l?l:4,r(!0);var h=sl.transition;sl.transition={};try{r(!1),o()}finally{Ie=l,sl.transition=h}}function zf(){return _t().memoizedState}function $x(r,o,l){var h=Vn(r);if(l={lane:h,action:l,hasEagerState:!1,eagerState:null,next:null},Uf(r))Wf(o,l);else if(l=yf(r,o,l,h),l!==null){var p=kt();en(l,r,h,p),Hf(l,o,h)}}function Cx(r,o,l){var h=Vn(r),p={lane:h,action:l,hasEagerState:!1,eagerState:null,next:null};if(Uf(r))Wf(o,p);else{var v=r.alternate;if(r.lanes===0&&(v===null||v.lanes===0)&&(v=o.lastRenderedReducer,v!==null))try{var j=o.lastRenderedState,$=v(j,l);if(p.hasEagerState=!0,p.eagerState=$,Qt($,j)){var T=o.interleaved;T===null?(p.next=p,Jc(o)):(p.next=T.next,T.next=p),o.interleaved=p;return}}catch{}finally{}l=yf(r,o,p,h),l!==null&&(p=kt(),en(l,r,h,p),Hf(l,o,h))}}function Uf(r){var o=r.alternate;return r===Ue||o!==null&&o===Ue}function Wf(r,o){Ji=po=!0;var l=r.pending;l===null?o.next=o:(o.next=l.next,l.next=o),r.pending=o}function Hf(r,o,l){if((l&4194240)!==0){var h=o.lanes;h&=r.pendingLanes,l|=h,o.lanes=l,hc(r,l)}}var ko={readContext:Dt,useCallback:dt,useContext:dt,useEffect:dt,useImperativeHandle:dt,useInsertionEffect:dt,useLayoutEffect:dt,useMemo:dt,useReducer:dt,useRef:dt,useState:dt,useDebugValue:dt,useDeferredValue:dt,useTransition:dt,useMutableSource:dt,useSyncExternalStore:dt,useId:dt,unstable_isNewReconciler:!1},Tx={readContext:Dt,useCallback:function(r,o){return ln().memoizedState=[r,o===void 0?null:o],r},useContext:Dt,useEffect:Mf,useImperativeHandle:function(r,o,l){return l=l!=null?l.concat([r]):null,go(4194308,4,Pf.bind(null,o,r),l)},useLayoutEffect:function(r,o){return go(4194308,4,r,o)},useInsertionEffect:function(r,o){return go(4,2,r,o)},useMemo:function(r,o){var l=ln();return o=o===void 0?null:o,r=r(),l.memoizedState=[r,o],r},useReducer:function(r,o,l){var h=ln();return o=l!==void 0?l(o):o,h.memoizedState=h.baseState=o,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:o},h.queue=r,r=r.dispatch=$x.bind(null,Ue,r),[h.memoizedState,r]},useRef:function(r){var o=ln();return r={current:r},o.memoizedState=r},useState:Rf,useDebugValue:dl,useDeferredValue:function(r){return ln().memoizedState=r},useTransition:function(){var r=Rf(!1),o=r[0];return r=Nx.bind(null,r[1]),ln().memoizedState=r,[o,r]},useMutableSource:function(){},useSyncExternalStore:function(r,o,l){var h=Ue,p=ln();if(Be){if(l===void 0)throw Error(n(407));l=l()}else{if(l=o(),nt===null)throw Error(n(349));(ms&30)!==0||$f(h,o,l)}p.memoizedState=l;var v={value:l,getSnapshot:o};return p.queue=v,Mf(Tf.bind(null,h,v,r),[r]),h.flags|=2048,er(9,Cf.bind(null,h,v,l,o),void 0,null),l},useId:function(){var r=ln(),o=nt.identifierPrefix;if(Be){var l=wn,h=yn;l=(h&~(1<<32-qt(h)-1)).toString(32)+l,o=":"+o+"R"+l,l=Xi++,0<l&&(o+="H"+l.toString(32)),o+=":"}else l=Sx++,o=":"+o+"r"+l.toString(32)+":";return r.memoizedState=o},unstable_isNewReconciler:!1},Ex={readContext:Dt,useCallback:_f,useContext:Dt,useEffect:ll,useImperativeHandle:Df,useInsertionEffect:Of,useLayoutEffect:Lf,useMemo:Bf,useReducer:al,useRef:If,useState:function(){return al(Zi)},useDebugValue:dl,useDeferredValue:function(r){var o=_t();return Ff(o,Ze.memoizedState,r)},useTransition:function(){var r=al(Zi)[0],o=_t().memoizedState;return[r,o]},useMutableSource:Sf,useSyncExternalStore:Nf,useId:zf,unstable_isNewReconciler:!1},Ax={readContext:Dt,useCallback:_f,useContext:Dt,useEffect:ll,useImperativeHandle:Df,useInsertionEffect:Of,useLayoutEffect:Lf,useMemo:Bf,useReducer:cl,useRef:If,useState:function(){return cl(Zi)},useDebugValue:dl,useDeferredValue:function(r){var o=_t();return Ze===null?o.memoizedState=r:Ff(o,Ze.memoizedState,r)},useTransition:function(){var r=cl(Zi)[0],o=_t().memoizedState;return[r,o]},useMutableSource:Sf,useSyncExternalStore:Nf,useId:zf,unstable_isNewReconciler:!1};function Jt(r,o){if(r&&r.defaultProps){o=U({},o),r=r.defaultProps;for(var l in r)o[l]===void 0&&(o[l]=r[l]);return o}return o}function ul(r,o,l,h){o=r.memoizedState,l=l(h,o),l=l==null?o:U({},o,l),r.memoizedState=l,r.lanes===0&&(r.updateQueue.baseState=l)}var yo={isMounted:function(r){return(r=r._reactInternals)?as(r)===r:!1},enqueueSetState:function(r,o,l){r=r._reactInternals;var h=kt(),p=Vn(r),v=jn(h,p);v.payload=o,l!=null&&(v.callback=l),o=Wn(r,v,p),o!==null&&(en(o,r,p,h),uo(o,r,p))},enqueueReplaceState:function(r,o,l){r=r._reactInternals;var h=kt(),p=Vn(r),v=jn(h,p);v.tag=1,v.payload=o,l!=null&&(v.callback=l),o=Wn(r,v,p),o!==null&&(en(o,r,p,h),uo(o,r,p))},enqueueForceUpdate:function(r,o){r=r._reactInternals;var l=kt(),h=Vn(r),p=jn(l,h);p.tag=2,o!=null&&(p.callback=o),o=Wn(r,p,h),o!==null&&(en(o,r,h,l),uo(o,r,h))}};function Kf(r,o,l,h,p,v,j){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(h,v,j):o.prototype&&o.prototype.isPureReactComponent?!Fi(l,h)||!Fi(p,v):!0}function Gf(r,o,l){var h=!1,p=Fn,v=o.contextType;return typeof v=="object"&&v!==null?v=Dt(v):(p=xt(o)?ls:lt.current,h=o.contextTypes,v=(h=h!=null)?Ws(r,p):Fn),o=new o(l,v),r.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=yo,r.stateNode=o,o._reactInternals=r,h&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=p,r.__reactInternalMemoizedMaskedChildContext=v),o}function Vf(r,o,l,h){r=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(l,h),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(l,h),o.state!==r&&yo.enqueueReplaceState(o,o.state,null)}function hl(r,o,l,h){var p=r.stateNode;p.props=l,p.state=r.memoizedState,p.refs={},Xc(r);var v=o.contextType;typeof v=="object"&&v!==null?p.context=Dt(v):(v=xt(o)?ls:lt.current,p.context=Ws(r,v)),p.state=r.memoizedState,v=o.getDerivedStateFromProps,typeof v=="function"&&(ul(r,o,v,l),p.state=r.memoizedState),typeof o.getDerivedStateFromProps=="function"||typeof p.getSnapshotBeforeUpdate=="function"||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(o=p.state,typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount(),o!==p.state&&yo.enqueueReplaceState(p,p.state,null),ho(r,l,p,h),p.state=r.memoizedState),typeof p.componentDidMount=="function"&&(r.flags|=4194308)}function Js(r,o){try{var l="",h=o;do l+=we(h),h=h.return;while(h);var p=l}catch(v){p=`
|
|
39
|
+
Error generating stack: `+v.message+`
|
|
40
|
+
`+v.stack}return{value:r,source:o,stack:p,digest:null}}function fl(r,o,l){return{value:r,source:null,stack:l??null,digest:o??null}}function ml(r,o){try{console.error(o.value)}catch(l){setTimeout(function(){throw l})}}var Rx=typeof WeakMap=="function"?WeakMap:Map;function qf(r,o,l){l=jn(-1,l),l.tag=3,l.payload={element:null};var h=o.value;return l.callback=function(){$o||($o=!0,El=h),ml(r,o)},l}function Qf(r,o,l){l=jn(-1,l),l.tag=3;var h=r.type.getDerivedStateFromError;if(typeof h=="function"){var p=o.value;l.payload=function(){return h(p)},l.callback=function(){ml(r,o)}}var v=r.stateNode;return v!==null&&typeof v.componentDidCatch=="function"&&(l.callback=function(){ml(r,o),typeof h!="function"&&(Kn===null?Kn=new Set([this]):Kn.add(this));var j=o.stack;this.componentDidCatch(o.value,{componentStack:j!==null?j:""})}),l}function Yf(r,o,l){var h=r.pingCache;if(h===null){h=r.pingCache=new Rx;var p=new Set;h.set(o,p)}else p=h.get(o),p===void 0&&(p=new Set,h.set(o,p));p.has(l)||(p.add(l),r=Kx.bind(null,r,o,l),o.then(r,r))}function Jf(r){do{var o;if((o=r.tag===13)&&(o=r.memoizedState,o=o!==null?o.dehydrated!==null:!0),o)return r;r=r.return}while(r!==null);return null}function Xf(r,o,l,h,p){return(r.mode&1)===0?(r===o?r.flags|=65536:(r.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(o=jn(-1,1),o.tag=2,Wn(l,o,1))),l.lanes|=1),r):(r.flags|=65536,r.lanes=p,r)}var Ix=M.ReactCurrentOwner,jt=!1;function vt(r,o,l,h){o.child=r===null?kf(o,null,l,h):Vs(o,r.child,l,h)}function Zf(r,o,l,h,p){l=l.render;var v=o.ref;return Qs(o,p),h=rl(r,o,l,h,v,p),l=ol(),r!==null&&!jt?(o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~p,bn(r,o,p)):(Be&&l&&Uc(o),o.flags|=1,vt(r,o,h,p),o.child)}function em(r,o,l,h,p){if(r===null){var v=l.type;return typeof v=="function"&&!Pl(v)&&v.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(o.tag=15,o.type=v,tm(r,o,v,h,p)):(r=Io(l.type,null,h,o,o.mode,p),r.ref=o.ref,r.return=o,o.child=r)}if(v=r.child,(r.lanes&p)===0){var j=v.memoizedProps;if(l=l.compare,l=l!==null?l:Fi,l(j,h)&&r.ref===o.ref)return bn(r,o,p)}return o.flags|=1,r=Qn(v,h),r.ref=o.ref,r.return=o,o.child=r}function tm(r,o,l,h,p){if(r!==null){var v=r.memoizedProps;if(Fi(v,h)&&r.ref===o.ref)if(jt=!1,o.pendingProps=h=v,(r.lanes&p)!==0)(r.flags&131072)!==0&&(jt=!0);else return o.lanes=r.lanes,bn(r,o,p)}return pl(r,o,l,h,p)}function nm(r,o,l){var h=o.pendingProps,p=h.children,v=r!==null?r.memoizedState:null;if(h.mode==="hidden")if((o.mode&1)===0)o.memoizedState={baseLanes:0,cachePool:null,transitions:null},Oe(Zs,Mt),Mt|=l;else{if((l&1073741824)===0)return r=v!==null?v.baseLanes|l:l,o.lanes=o.childLanes=1073741824,o.memoizedState={baseLanes:r,cachePool:null,transitions:null},o.updateQueue=null,Oe(Zs,Mt),Mt|=r,null;o.memoizedState={baseLanes:0,cachePool:null,transitions:null},h=v!==null?v.baseLanes:l,Oe(Zs,Mt),Mt|=h}else v!==null?(h=v.baseLanes|l,o.memoizedState=null):h=l,Oe(Zs,Mt),Mt|=h;return vt(r,o,p,l),o.child}function sm(r,o){var l=o.ref;(r===null&&l!==null||r!==null&&r.ref!==l)&&(o.flags|=512,o.flags|=2097152)}function pl(r,o,l,h,p){var v=xt(l)?ls:lt.current;return v=Ws(o,v),Qs(o,p),l=rl(r,o,l,h,v,p),h=ol(),r!==null&&!jt?(o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~p,bn(r,o,p)):(Be&&h&&Uc(o),o.flags|=1,vt(r,o,l,p),o.child)}function im(r,o,l,h,p){if(xt(l)){var v=!0;no(o)}else v=!1;if(Qs(o,p),o.stateNode===null)xo(r,o),Gf(o,l,h),hl(o,l,h,p),h=!0;else if(r===null){var j=o.stateNode,$=o.memoizedProps;j.props=$;var T=j.context,L=l.contextType;typeof L=="object"&&L!==null?L=Dt(L):(L=xt(l)?ls:lt.current,L=Ws(o,L));var K=l.getDerivedStateFromProps,G=typeof K=="function"||typeof j.getSnapshotBeforeUpdate=="function";G||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||($!==h||T!==L)&&Vf(o,j,h,L),Un=!1;var W=o.memoizedState;j.state=W,ho(o,h,j,p),T=o.memoizedState,$!==h||W!==T||wt.current||Un?(typeof K=="function"&&(ul(o,l,K,h),T=o.memoizedState),($=Un||Kf(o,l,$,h,W,T,L))?(G||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(o.flags|=4194308)):(typeof j.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=h,o.memoizedState=T),j.props=h,j.state=T,j.context=L,h=$):(typeof j.componentDidMount=="function"&&(o.flags|=4194308),h=!1)}else{j=o.stateNode,wf(r,o),$=o.memoizedProps,L=o.type===o.elementType?$:Jt(o.type,$),j.props=L,G=o.pendingProps,W=j.context,T=l.contextType,typeof T=="object"&&T!==null?T=Dt(T):(T=xt(l)?ls:lt.current,T=Ws(o,T));var X=l.getDerivedStateFromProps;(K=typeof X=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||($!==G||W!==T)&&Vf(o,j,h,T),Un=!1,W=o.memoizedState,j.state=W,ho(o,h,j,p);var te=o.memoizedState;$!==G||W!==te||wt.current||Un?(typeof X=="function"&&(ul(o,l,X,h),te=o.memoizedState),(L=Un||Kf(o,l,L,h,W,te,T)||!1)?(K||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(h,te,T),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(h,te,T)),typeof j.componentDidUpdate=="function"&&(o.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof j.componentDidUpdate!="function"||$===r.memoizedProps&&W===r.memoizedState||(o.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||$===r.memoizedProps&&W===r.memoizedState||(o.flags|=1024),o.memoizedProps=h,o.memoizedState=te),j.props=h,j.state=te,j.context=T,h=L):(typeof j.componentDidUpdate!="function"||$===r.memoizedProps&&W===r.memoizedState||(o.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||$===r.memoizedProps&&W===r.memoizedState||(o.flags|=1024),h=!1)}return gl(r,o,l,h,v,p)}function gl(r,o,l,h,p,v){sm(r,o);var j=(o.flags&128)!==0;if(!h&&!j)return p&&lf(o,l,!1),bn(r,o,v);h=o.stateNode,Ix.current=o;var $=j&&typeof l.getDerivedStateFromError!="function"?null:h.render();return o.flags|=1,r!==null&&j?(o.child=Vs(o,r.child,null,v),o.child=Vs(o,null,$,v)):vt(r,o,$,v),o.memoizedState=h.state,p&&lf(o,l,!0),o.child}function rm(r){var o=r.stateNode;o.pendingContext?af(r,o.pendingContext,o.pendingContext!==o.context):o.context&&af(r,o.context,!1),Zc(r,o.containerInfo)}function om(r,o,l,h,p){return Gs(),Gc(p),o.flags|=256,vt(r,o,l,h),o.child}var vl={dehydrated:null,treeContext:null,retryLane:0};function kl(r){return{baseLanes:r,cachePool:null,transitions:null}}function am(r,o,l){var h=o.pendingProps,p=ze.current,v=!1,j=(o.flags&128)!==0,$;if(($=j)||($=r!==null&&r.memoizedState===null?!1:(p&2)!==0),$?(v=!0,o.flags&=-129):(r===null||r.memoizedState!==null)&&(p|=1),Oe(ze,p&1),r===null)return Kc(o),r=o.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((o.mode&1)===0?o.lanes=1:r.data==="$!"?o.lanes=8:o.lanes=1073741824,null):(j=h.children,r=h.fallback,v?(h=o.mode,v=o.child,j={mode:"hidden",children:j},(h&1)===0&&v!==null?(v.childLanes=0,v.pendingProps=j):v=Mo(j,h,0,null),r=ys(r,h,l,null),v.return=o,r.return=o,v.sibling=r,o.child=v,o.child.memoizedState=kl(l),o.memoizedState=vl,r):yl(o,j));if(p=r.memoizedState,p!==null&&($=p.dehydrated,$!==null))return Mx(r,o,j,h,$,p,l);if(v){v=h.fallback,j=o.mode,p=r.child,$=p.sibling;var T={mode:"hidden",children:h.children};return(j&1)===0&&o.child!==p?(h=o.child,h.childLanes=0,h.pendingProps=T,o.deletions=null):(h=Qn(p,T),h.subtreeFlags=p.subtreeFlags&14680064),$!==null?v=Qn($,v):(v=ys(v,j,l,null),v.flags|=2),v.return=o,h.return=o,h.sibling=v,o.child=h,h=v,v=o.child,j=r.child.memoizedState,j=j===null?kl(l):{baseLanes:j.baseLanes|l,cachePool:null,transitions:j.transitions},v.memoizedState=j,v.childLanes=r.childLanes&~l,o.memoizedState=vl,h}return v=r.child,r=v.sibling,h=Qn(v,{mode:"visible",children:h.children}),(o.mode&1)===0&&(h.lanes=l),h.return=o,h.sibling=null,r!==null&&(l=o.deletions,l===null?(o.deletions=[r],o.flags|=16):l.push(r)),o.child=h,o.memoizedState=null,h}function yl(r,o){return o=Mo({mode:"visible",children:o},r.mode,0,null),o.return=r,r.child=o}function wo(r,o,l,h){return h!==null&&Gc(h),Vs(o,r.child,null,l),r=yl(o,o.pendingProps.children),r.flags|=2,o.memoizedState=null,r}function Mx(r,o,l,h,p,v,j){if(l)return o.flags&256?(o.flags&=-257,h=fl(Error(n(422))),wo(r,o,j,h)):o.memoizedState!==null?(o.child=r.child,o.flags|=128,null):(v=h.fallback,p=o.mode,h=Mo({mode:"visible",children:h.children},p,0,null),v=ys(v,p,j,null),v.flags|=2,h.return=o,v.return=o,h.sibling=v,o.child=h,(o.mode&1)!==0&&Vs(o,r.child,null,j),o.child.memoizedState=kl(j),o.memoizedState=vl,v);if((o.mode&1)===0)return wo(r,o,j,null);if(p.data==="$!"){if(h=p.nextSibling&&p.nextSibling.dataset,h)var $=h.dgst;return h=$,v=Error(n(419)),h=fl(v,h,void 0),wo(r,o,j,h)}if($=(j&r.childLanes)!==0,jt||$){if(h=nt,h!==null){switch(j&-j){case 4:p=2;break;case 16:p=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:p=32;break;case 536870912:p=268435456;break;default:p=0}p=(p&(h.suspendedLanes|j))!==0?0:p,p!==0&&p!==v.retryLane&&(v.retryLane=p,xn(r,p),en(h,r,p,-1))}return Ll(),h=fl(Error(n(421))),wo(r,o,j,h)}return p.data==="$?"?(o.flags|=128,o.child=r.child,o=Gx.bind(null,r),p._reactRetry=o,null):(r=v.treeContext,It=_n(p.nextSibling),Rt=o,Be=!0,Yt=null,r!==null&&(Lt[Pt++]=yn,Lt[Pt++]=wn,Lt[Pt++]=ds,yn=r.id,wn=r.overflow,ds=o),o=yl(o,h.children),o.flags|=4096,o)}function cm(r,o,l){r.lanes|=o;var h=r.alternate;h!==null&&(h.lanes|=o),Yc(r.return,o,l)}function wl(r,o,l,h,p){var v=r.memoizedState;v===null?r.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:h,tail:l,tailMode:p}:(v.isBackwards=o,v.rendering=null,v.renderingStartTime=0,v.last=h,v.tail=l,v.tailMode=p)}function lm(r,o,l){var h=o.pendingProps,p=h.revealOrder,v=h.tail;if(vt(r,o,h.children,l),h=ze.current,(h&2)!==0)h=h&1|2,o.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=o.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&cm(r,l,o);else if(r.tag===19)cm(r,l,o);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===o)break e;for(;r.sibling===null;){if(r.return===null||r.return===o)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}h&=1}if(Oe(ze,h),(o.mode&1)===0)o.memoizedState=null;else switch(p){case"forwards":for(l=o.child,p=null;l!==null;)r=l.alternate,r!==null&&fo(r)===null&&(p=l),l=l.sibling;l=p,l===null?(p=o.child,o.child=null):(p=l.sibling,l.sibling=null),wl(o,!1,p,l,v);break;case"backwards":for(l=null,p=o.child,o.child=null;p!==null;){if(r=p.alternate,r!==null&&fo(r)===null){o.child=p;break}r=p.sibling,p.sibling=l,l=p,p=r}wl(o,!0,l,null,v);break;case"together":wl(o,!1,null,null,void 0);break;default:o.memoizedState=null}return o.child}function xo(r,o){(o.mode&1)===0&&r!==null&&(r.alternate=null,o.alternate=null,o.flags|=2)}function bn(r,o,l){if(r!==null&&(o.dependencies=r.dependencies),ps|=o.lanes,(l&o.childLanes)===0)return null;if(r!==null&&o.child!==r.child)throw Error(n(153));if(o.child!==null){for(r=o.child,l=Qn(r,r.pendingProps),o.child=l,l.return=o;r.sibling!==null;)r=r.sibling,l=l.sibling=Qn(r,r.pendingProps),l.return=o;l.sibling=null}return o.child}function Ox(r,o,l){switch(o.tag){case 3:rm(o),Gs();break;case 5:bf(o);break;case 1:xt(o.type)&&no(o);break;case 4:Zc(o,o.stateNode.containerInfo);break;case 10:var h=o.type._context,p=o.memoizedProps.value;Oe(co,h._currentValue),h._currentValue=p;break;case 13:if(h=o.memoizedState,h!==null)return h.dehydrated!==null?(Oe(ze,ze.current&1),o.flags|=128,null):(l&o.child.childLanes)!==0?am(r,o,l):(Oe(ze,ze.current&1),r=bn(r,o,l),r!==null?r.sibling:null);Oe(ze,ze.current&1);break;case 19:if(h=(l&o.childLanes)!==0,(r.flags&128)!==0){if(h)return lm(r,o,l);o.flags|=128}if(p=o.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),Oe(ze,ze.current),h)break;return null;case 22:case 23:return o.lanes=0,nm(r,o,l)}return bn(r,o,l)}var dm,xl,um,hm;dm=function(r,o){for(var l=o.child;l!==null;){if(l.tag===5||l.tag===6)r.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===o)break;for(;l.sibling===null;){if(l.return===null||l.return===o)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},xl=function(){},um=function(r,o,l,h){var p=r.memoizedProps;if(p!==h){r=o.stateNode,fs(cn.current);var v=null;switch(l){case"input":p=Ya(r,p),h=Ya(r,h),v=[];break;case"select":p=U({},p,{value:void 0}),h=U({},h,{value:void 0}),v=[];break;case"textarea":p=Za(r,p),h=Za(r,h),v=[];break;default:typeof p.onClick!="function"&&typeof h.onClick=="function"&&(r.onclick=Zr)}tc(l,h);var j;l=null;for(L in p)if(!h.hasOwnProperty(L)&&p.hasOwnProperty(L)&&p[L]!=null)if(L==="style"){var $=p[L];for(j in $)$.hasOwnProperty(j)&&(l||(l={}),l[j]="")}else L!=="dangerouslySetInnerHTML"&&L!=="children"&&L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&L!=="autoFocus"&&(a.hasOwnProperty(L)?v||(v=[]):(v=v||[]).push(L,null));for(L in h){var T=h[L];if($=p!=null?p[L]:void 0,h.hasOwnProperty(L)&&T!==$&&(T!=null||$!=null))if(L==="style")if($){for(j in $)!$.hasOwnProperty(j)||T&&T.hasOwnProperty(j)||(l||(l={}),l[j]="");for(j in T)T.hasOwnProperty(j)&&$[j]!==T[j]&&(l||(l={}),l[j]=T[j])}else l||(v||(v=[]),v.push(L,l)),l=T;else L==="dangerouslySetInnerHTML"?(T=T?T.__html:void 0,$=$?$.__html:void 0,T!=null&&$!==T&&(v=v||[]).push(L,T)):L==="children"?typeof T!="string"&&typeof T!="number"||(v=v||[]).push(L,""+T):L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&(a.hasOwnProperty(L)?(T!=null&&L==="onScroll"&&Pe("scroll",r),v||$===T||(v=[])):(v=v||[]).push(L,T))}l&&(v=v||[]).push("style",l);var L=v;(o.updateQueue=L)&&(o.flags|=4)}},hm=function(r,o,l,h){l!==h&&(o.flags|=4)};function tr(r,o){if(!Be)switch(r.tailMode){case"hidden":o=r.tail;for(var l=null;o!==null;)o.alternate!==null&&(l=o),o=o.sibling;l===null?r.tail=null:l.sibling=null;break;case"collapsed":l=r.tail;for(var h=null;l!==null;)l.alternate!==null&&(h=l),l=l.sibling;h===null?o||r.tail===null?r.tail=null:r.tail.sibling=null:h.sibling=null}}function ut(r){var o=r.alternate!==null&&r.alternate.child===r.child,l=0,h=0;if(o)for(var p=r.child;p!==null;)l|=p.lanes|p.childLanes,h|=p.subtreeFlags&14680064,h|=p.flags&14680064,p.return=r,p=p.sibling;else for(p=r.child;p!==null;)l|=p.lanes|p.childLanes,h|=p.subtreeFlags,h|=p.flags,p.return=r,p=p.sibling;return r.subtreeFlags|=h,r.childLanes=l,o}function Lx(r,o,l){var h=o.pendingProps;switch(Wc(o),o.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ut(o),null;case 1:return xt(o.type)&&to(),ut(o),null;case 3:return h=o.stateNode,Ys(),De(wt),De(lt),nl(),h.pendingContext&&(h.context=h.pendingContext,h.pendingContext=null),(r===null||r.child===null)&&(oo(o)?o.flags|=4:r===null||r.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,Yt!==null&&(Il(Yt),Yt=null))),xl(r,o),ut(o),null;case 5:el(o);var p=fs(Yi.current);if(l=o.type,r!==null&&o.stateNode!=null)um(r,o,l,h,p),r.ref!==o.ref&&(o.flags|=512,o.flags|=2097152);else{if(!h){if(o.stateNode===null)throw Error(n(166));return ut(o),null}if(r=fs(cn.current),oo(o)){h=o.stateNode,l=o.type;var v=o.memoizedProps;switch(h[an]=o,h[Ki]=v,r=(o.mode&1)!==0,l){case"dialog":Pe("cancel",h),Pe("close",h);break;case"iframe":case"object":case"embed":Pe("load",h);break;case"video":case"audio":for(p=0;p<Ui.length;p++)Pe(Ui[p],h);break;case"source":Pe("error",h);break;case"img":case"image":case"link":Pe("error",h),Pe("load",h);break;case"details":Pe("toggle",h);break;case"input":Ku(h,v),Pe("invalid",h);break;case"select":h._wrapperState={wasMultiple:!!v.multiple},Pe("invalid",h);break;case"textarea":qu(h,v),Pe("invalid",h)}tc(l,v),p=null;for(var j in v)if(v.hasOwnProperty(j)){var $=v[j];j==="children"?typeof $=="string"?h.textContent!==$&&(v.suppressHydrationWarning!==!0&&Xr(h.textContent,$,r),p=["children",$]):typeof $=="number"&&h.textContent!==""+$&&(v.suppressHydrationWarning!==!0&&Xr(h.textContent,$,r),p=["children",""+$]):a.hasOwnProperty(j)&&$!=null&&j==="onScroll"&&Pe("scroll",h)}switch(l){case"input":Rn(h),Vu(h,v,!0);break;case"textarea":Rn(h),Yu(h);break;case"select":case"option":break;default:typeof v.onClick=="function"&&(h.onclick=Zr)}h=p,o.updateQueue=h,h!==null&&(o.flags|=4)}else{j=p.nodeType===9?p:p.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=Ju(l)),r==="http://www.w3.org/1999/xhtml"?l==="script"?(r=j.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof h.is=="string"?r=j.createElement(l,{is:h.is}):(r=j.createElement(l),l==="select"&&(j=r,h.multiple?j.multiple=!0:h.size&&(j.size=h.size))):r=j.createElementNS(r,l),r[an]=o,r[Ki]=h,dm(r,o,!1,!1),o.stateNode=r;e:{switch(j=nc(l,h),l){case"dialog":Pe("cancel",r),Pe("close",r),p=h;break;case"iframe":case"object":case"embed":Pe("load",r),p=h;break;case"video":case"audio":for(p=0;p<Ui.length;p++)Pe(Ui[p],r);p=h;break;case"source":Pe("error",r),p=h;break;case"img":case"image":case"link":Pe("error",r),Pe("load",r),p=h;break;case"details":Pe("toggle",r),p=h;break;case"input":Ku(r,h),p=Ya(r,h),Pe("invalid",r);break;case"option":p=h;break;case"select":r._wrapperState={wasMultiple:!!h.multiple},p=U({},h,{value:void 0}),Pe("invalid",r);break;case"textarea":qu(r,h),p=Za(r,h),Pe("invalid",r);break;default:p=h}tc(l,p),$=p;for(v in $)if($.hasOwnProperty(v)){var T=$[v];v==="style"?eh(r,T):v==="dangerouslySetInnerHTML"?(T=T?T.__html:void 0,T!=null&&Xu(r,T)):v==="children"?typeof T=="string"?(l!=="textarea"||T!=="")&&bi(r,T):typeof T=="number"&&bi(r,""+T):v!=="suppressContentEditableWarning"&&v!=="suppressHydrationWarning"&&v!=="autoFocus"&&(a.hasOwnProperty(v)?T!=null&&v==="onScroll"&&Pe("scroll",r):T!=null&&D(r,v,T,j))}switch(l){case"input":Rn(r),Vu(r,h,!1);break;case"textarea":Rn(r),Yu(r);break;case"option":h.value!=null&&r.setAttribute("value",""+Ne(h.value));break;case"select":r.multiple=!!h.multiple,v=h.value,v!=null?Rs(r,!!h.multiple,v,!1):h.defaultValue!=null&&Rs(r,!!h.multiple,h.defaultValue,!0);break;default:typeof p.onClick=="function"&&(r.onclick=Zr)}switch(l){case"button":case"input":case"select":case"textarea":h=!!h.autoFocus;break e;case"img":h=!0;break e;default:h=!1}}h&&(o.flags|=4)}o.ref!==null&&(o.flags|=512,o.flags|=2097152)}return ut(o),null;case 6:if(r&&o.stateNode!=null)hm(r,o,r.memoizedProps,h);else{if(typeof h!="string"&&o.stateNode===null)throw Error(n(166));if(l=fs(Yi.current),fs(cn.current),oo(o)){if(h=o.stateNode,l=o.memoizedProps,h[an]=o,(v=h.nodeValue!==l)&&(r=Rt,r!==null))switch(r.tag){case 3:Xr(h.nodeValue,l,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&Xr(h.nodeValue,l,(r.mode&1)!==0)}v&&(o.flags|=4)}else h=(l.nodeType===9?l:l.ownerDocument).createTextNode(h),h[an]=o,o.stateNode=h}return ut(o),null;case 13:if(De(ze),h=o.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(Be&&It!==null&&(o.mode&1)!==0&&(o.flags&128)===0)pf(),Gs(),o.flags|=98560,v=!1;else if(v=oo(o),h!==null&&h.dehydrated!==null){if(r===null){if(!v)throw Error(n(318));if(v=o.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(n(317));v[an]=o}else Gs(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;ut(o),v=!1}else Yt!==null&&(Il(Yt),Yt=null),v=!0;if(!v)return o.flags&65536?o:null}return(o.flags&128)!==0?(o.lanes=l,o):(h=h!==null,h!==(r!==null&&r.memoizedState!==null)&&h&&(o.child.flags|=8192,(o.mode&1)!==0&&(r===null||(ze.current&1)!==0?et===0&&(et=3):Ll())),o.updateQueue!==null&&(o.flags|=4),ut(o),null);case 4:return Ys(),xl(r,o),r===null&&Wi(o.stateNode.containerInfo),ut(o),null;case 10:return Qc(o.type._context),ut(o),null;case 17:return xt(o.type)&&to(),ut(o),null;case 19:if(De(ze),v=o.memoizedState,v===null)return ut(o),null;if(h=(o.flags&128)!==0,j=v.rendering,j===null)if(h)tr(v,!1);else{if(et!==0||r!==null&&(r.flags&128)!==0)for(r=o.child;r!==null;){if(j=fo(r),j!==null){for(o.flags|=128,tr(v,!1),h=j.updateQueue,h!==null&&(o.updateQueue=h,o.flags|=4),o.subtreeFlags=0,h=l,l=o.child;l!==null;)v=l,r=h,v.flags&=14680066,j=v.alternate,j===null?(v.childLanes=0,v.lanes=r,v.child=null,v.subtreeFlags=0,v.memoizedProps=null,v.memoizedState=null,v.updateQueue=null,v.dependencies=null,v.stateNode=null):(v.childLanes=j.childLanes,v.lanes=j.lanes,v.child=j.child,v.subtreeFlags=0,v.deletions=null,v.memoizedProps=j.memoizedProps,v.memoizedState=j.memoizedState,v.updateQueue=j.updateQueue,v.type=j.type,r=j.dependencies,v.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),l=l.sibling;return Oe(ze,ze.current&1|2),o.child}r=r.sibling}v.tail!==null&&qe()>ei&&(o.flags|=128,h=!0,tr(v,!1),o.lanes=4194304)}else{if(!h)if(r=fo(j),r!==null){if(o.flags|=128,h=!0,l=r.updateQueue,l!==null&&(o.updateQueue=l,o.flags|=4),tr(v,!0),v.tail===null&&v.tailMode==="hidden"&&!j.alternate&&!Be)return ut(o),null}else 2*qe()-v.renderingStartTime>ei&&l!==1073741824&&(o.flags|=128,h=!0,tr(v,!1),o.lanes=4194304);v.isBackwards?(j.sibling=o.child,o.child=j):(l=v.last,l!==null?l.sibling=j:o.child=j,v.last=j)}return v.tail!==null?(o=v.tail,v.rendering=o,v.tail=o.sibling,v.renderingStartTime=qe(),o.sibling=null,l=ze.current,Oe(ze,h?l&1|2:l&1),o):(ut(o),null);case 22:case 23:return Ol(),h=o.memoizedState!==null,r!==null&&r.memoizedState!==null!==h&&(o.flags|=8192),h&&(o.mode&1)!==0?(Mt&1073741824)!==0&&(ut(o),o.subtreeFlags&6&&(o.flags|=8192)):ut(o),null;case 24:return null;case 25:return null}throw Error(n(156,o.tag))}function Px(r,o){switch(Wc(o),o.tag){case 1:return xt(o.type)&&to(),r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 3:return Ys(),De(wt),De(lt),nl(),r=o.flags,(r&65536)!==0&&(r&128)===0?(o.flags=r&-65537|128,o):null;case 5:return el(o),null;case 13:if(De(ze),r=o.memoizedState,r!==null&&r.dehydrated!==null){if(o.alternate===null)throw Error(n(340));Gs()}return r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 19:return De(ze),null;case 4:return Ys(),null;case 10:return Qc(o.type._context),null;case 22:case 23:return Ol(),null;case 24:return null;default:return null}}var jo=!1,ht=!1,Dx=typeof WeakSet=="function"?WeakSet:Set,ee=null;function Xs(r,o){var l=r.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(h){Ve(r,o,h)}else l.current=null}function jl(r,o,l){try{l()}catch(h){Ve(r,o,h)}}var fm=!1;function _x(r,o){if(Oc=zr,r=Hh(),$c(r)){if("selectionStart"in r)var l={start:r.selectionStart,end:r.selectionEnd};else e:{l=(l=r.ownerDocument)&&l.defaultView||window;var h=l.getSelection&&l.getSelection();if(h&&h.rangeCount!==0){l=h.anchorNode;var p=h.anchorOffset,v=h.focusNode;h=h.focusOffset;try{l.nodeType,v.nodeType}catch{l=null;break e}var j=0,$=-1,T=-1,L=0,K=0,G=r,W=null;t:for(;;){for(var X;G!==l||p!==0&&G.nodeType!==3||($=j+p),G!==v||h!==0&&G.nodeType!==3||(T=j+h),G.nodeType===3&&(j+=G.nodeValue.length),(X=G.firstChild)!==null;)W=G,G=X;for(;;){if(G===r)break t;if(W===l&&++L===p&&($=j),W===v&&++K===h&&(T=j),(X=G.nextSibling)!==null)break;G=W,W=G.parentNode}G=X}l=$===-1||T===-1?null:{start:$,end:T}}else l=null}l=l||{start:0,end:0}}else l=null;for(Lc={focusedElem:r,selectionRange:l},zr=!1,ee=o;ee!==null;)if(o=ee,r=o.child,(o.subtreeFlags&1028)!==0&&r!==null)r.return=o,ee=r;else for(;ee!==null;){o=ee;try{var te=o.alternate;if((o.flags&1024)!==0)switch(o.tag){case 0:case 11:case 15:break;case 1:if(te!==null){var ne=te.memoizedProps,Qe=te.memoizedState,R=o.stateNode,A=R.getSnapshotBeforeUpdate(o.elementType===o.type?ne:Jt(o.type,ne),Qe);R.__reactInternalSnapshotBeforeUpdate=A}break;case 3:var O=o.stateNode.containerInfo;O.nodeType===1?O.textContent="":O.nodeType===9&&O.documentElement&&O.removeChild(O.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(V){Ve(o,o.return,V)}if(r=o.sibling,r!==null){r.return=o.return,ee=r;break}ee=o.return}return te=fm,fm=!1,te}function nr(r,o,l){var h=o.updateQueue;if(h=h!==null?h.lastEffect:null,h!==null){var p=h=h.next;do{if((p.tag&r)===r){var v=p.destroy;p.destroy=void 0,v!==void 0&&jl(o,l,v)}p=p.next}while(p!==h)}}function bo(r,o){if(o=o.updateQueue,o=o!==null?o.lastEffect:null,o!==null){var l=o=o.next;do{if((l.tag&r)===r){var h=l.create;l.destroy=h()}l=l.next}while(l!==o)}}function bl(r){var o=r.ref;if(o!==null){var l=r.stateNode;switch(r.tag){case 5:r=l;break;default:r=l}typeof o=="function"?o(r):o.current=r}}function mm(r){var o=r.alternate;o!==null&&(r.alternate=null,mm(o)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(o=r.stateNode,o!==null&&(delete o[an],delete o[Ki],delete o[Bc],delete o[wx],delete o[xx])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function pm(r){return r.tag===5||r.tag===3||r.tag===4}function gm(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||pm(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Sl(r,o,l){var h=r.tag;if(h===5||h===6)r=r.stateNode,o?l.nodeType===8?l.parentNode.insertBefore(r,o):l.insertBefore(r,o):(l.nodeType===8?(o=l.parentNode,o.insertBefore(r,l)):(o=l,o.appendChild(r)),l=l._reactRootContainer,l!=null||o.onclick!==null||(o.onclick=Zr));else if(h!==4&&(r=r.child,r!==null))for(Sl(r,o,l),r=r.sibling;r!==null;)Sl(r,o,l),r=r.sibling}function Nl(r,o,l){var h=r.tag;if(h===5||h===6)r=r.stateNode,o?l.insertBefore(r,o):l.appendChild(r);else if(h!==4&&(r=r.child,r!==null))for(Nl(r,o,l),r=r.sibling;r!==null;)Nl(r,o,l),r=r.sibling}var ot=null,Xt=!1;function Hn(r,o,l){for(l=l.child;l!==null;)vm(r,o,l),l=l.sibling}function vm(r,o,l){if(on&&typeof on.onCommitFiberUnmount=="function")try{on.onCommitFiberUnmount(Lr,l)}catch{}switch(l.tag){case 5:ht||Xs(l,o);case 6:var h=ot,p=Xt;ot=null,Hn(r,o,l),ot=h,Xt=p,ot!==null&&(Xt?(r=ot,l=l.stateNode,r.nodeType===8?r.parentNode.removeChild(l):r.removeChild(l)):ot.removeChild(l.stateNode));break;case 18:ot!==null&&(Xt?(r=ot,l=l.stateNode,r.nodeType===8?_c(r.parentNode,l):r.nodeType===1&&_c(r,l),Oi(r)):_c(ot,l.stateNode));break;case 4:h=ot,p=Xt,ot=l.stateNode.containerInfo,Xt=!0,Hn(r,o,l),ot=h,Xt=p;break;case 0:case 11:case 14:case 15:if(!ht&&(h=l.updateQueue,h!==null&&(h=h.lastEffect,h!==null))){p=h=h.next;do{var v=p,j=v.destroy;v=v.tag,j!==void 0&&((v&2)!==0||(v&4)!==0)&&jl(l,o,j),p=p.next}while(p!==h)}Hn(r,o,l);break;case 1:if(!ht&&(Xs(l,o),h=l.stateNode,typeof h.componentWillUnmount=="function"))try{h.props=l.memoizedProps,h.state=l.memoizedState,h.componentWillUnmount()}catch($){Ve(l,o,$)}Hn(r,o,l);break;case 21:Hn(r,o,l);break;case 22:l.mode&1?(ht=(h=ht)||l.memoizedState!==null,Hn(r,o,l),ht=h):Hn(r,o,l);break;default:Hn(r,o,l)}}function km(r){var o=r.updateQueue;if(o!==null){r.updateQueue=null;var l=r.stateNode;l===null&&(l=r.stateNode=new Dx),o.forEach(function(h){var p=Vx.bind(null,r,h);l.has(h)||(l.add(h),h.then(p,p))})}}function Zt(r,o){var l=o.deletions;if(l!==null)for(var h=0;h<l.length;h++){var p=l[h];try{var v=r,j=o,$=j;e:for(;$!==null;){switch($.tag){case 5:ot=$.stateNode,Xt=!1;break e;case 3:ot=$.stateNode.containerInfo,Xt=!0;break e;case 4:ot=$.stateNode.containerInfo,Xt=!0;break e}$=$.return}if(ot===null)throw Error(n(160));vm(v,j,p),ot=null,Xt=!1;var T=p.alternate;T!==null&&(T.return=null),p.return=null}catch(L){Ve(p,o,L)}}if(o.subtreeFlags&12854)for(o=o.child;o!==null;)ym(o,r),o=o.sibling}function ym(r,o){var l=r.alternate,h=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(Zt(o,r),dn(r),h&4){try{nr(3,r,r.return),bo(3,r)}catch(ne){Ve(r,r.return,ne)}try{nr(5,r,r.return)}catch(ne){Ve(r,r.return,ne)}}break;case 1:Zt(o,r),dn(r),h&512&&l!==null&&Xs(l,l.return);break;case 5:if(Zt(o,r),dn(r),h&512&&l!==null&&Xs(l,l.return),r.flags&32){var p=r.stateNode;try{bi(p,"")}catch(ne){Ve(r,r.return,ne)}}if(h&4&&(p=r.stateNode,p!=null)){var v=r.memoizedProps,j=l!==null?l.memoizedProps:v,$=r.type,T=r.updateQueue;if(r.updateQueue=null,T!==null)try{$==="input"&&v.type==="radio"&&v.name!=null&&Gu(p,v),nc($,j);var L=nc($,v);for(j=0;j<T.length;j+=2){var K=T[j],G=T[j+1];K==="style"?eh(p,G):K==="dangerouslySetInnerHTML"?Xu(p,G):K==="children"?bi(p,G):D(p,K,G,L)}switch($){case"input":Ja(p,v);break;case"textarea":Qu(p,v);break;case"select":var W=p._wrapperState.wasMultiple;p._wrapperState.wasMultiple=!!v.multiple;var X=v.value;X!=null?Rs(p,!!v.multiple,X,!1):W!==!!v.multiple&&(v.defaultValue!=null?Rs(p,!!v.multiple,v.defaultValue,!0):Rs(p,!!v.multiple,v.multiple?[]:"",!1))}p[Ki]=v}catch(ne){Ve(r,r.return,ne)}}break;case 6:if(Zt(o,r),dn(r),h&4){if(r.stateNode===null)throw Error(n(162));p=r.stateNode,v=r.memoizedProps;try{p.nodeValue=v}catch(ne){Ve(r,r.return,ne)}}break;case 3:if(Zt(o,r),dn(r),h&4&&l!==null&&l.memoizedState.isDehydrated)try{Oi(o.containerInfo)}catch(ne){Ve(r,r.return,ne)}break;case 4:Zt(o,r),dn(r);break;case 13:Zt(o,r),dn(r),p=r.child,p.flags&8192&&(v=p.memoizedState!==null,p.stateNode.isHidden=v,!v||p.alternate!==null&&p.alternate.memoizedState!==null||(Tl=qe())),h&4&&km(r);break;case 22:if(K=l!==null&&l.memoizedState!==null,r.mode&1?(ht=(L=ht)||K,Zt(o,r),ht=L):Zt(o,r),dn(r),h&8192){if(L=r.memoizedState!==null,(r.stateNode.isHidden=L)&&!K&&(r.mode&1)!==0)for(ee=r,K=r.child;K!==null;){for(G=ee=K;ee!==null;){switch(W=ee,X=W.child,W.tag){case 0:case 11:case 14:case 15:nr(4,W,W.return);break;case 1:Xs(W,W.return);var te=W.stateNode;if(typeof te.componentWillUnmount=="function"){h=W,l=W.return;try{o=h,te.props=o.memoizedProps,te.state=o.memoizedState,te.componentWillUnmount()}catch(ne){Ve(h,l,ne)}}break;case 5:Xs(W,W.return);break;case 22:if(W.memoizedState!==null){jm(G);continue}}X!==null?(X.return=W,ee=X):jm(G)}K=K.sibling}e:for(K=null,G=r;;){if(G.tag===5){if(K===null){K=G;try{p=G.stateNode,L?(v=p.style,typeof v.setProperty=="function"?v.setProperty("display","none","important"):v.display="none"):($=G.stateNode,T=G.memoizedProps.style,j=T!=null&&T.hasOwnProperty("display")?T.display:null,$.style.display=Zu("display",j))}catch(ne){Ve(r,r.return,ne)}}}else if(G.tag===6){if(K===null)try{G.stateNode.nodeValue=L?"":G.memoizedProps}catch(ne){Ve(r,r.return,ne)}}else if((G.tag!==22&&G.tag!==23||G.memoizedState===null||G===r)&&G.child!==null){G.child.return=G,G=G.child;continue}if(G===r)break e;for(;G.sibling===null;){if(G.return===null||G.return===r)break e;K===G&&(K=null),G=G.return}K===G&&(K=null),G.sibling.return=G.return,G=G.sibling}}break;case 19:Zt(o,r),dn(r),h&4&&km(r);break;case 21:break;default:Zt(o,r),dn(r)}}function dn(r){var o=r.flags;if(o&2){try{e:{for(var l=r.return;l!==null;){if(pm(l)){var h=l;break e}l=l.return}throw Error(n(160))}switch(h.tag){case 5:var p=h.stateNode;h.flags&32&&(bi(p,""),h.flags&=-33);var v=gm(r);Nl(r,v,p);break;case 3:case 4:var j=h.stateNode.containerInfo,$=gm(r);Sl(r,$,j);break;default:throw Error(n(161))}}catch(T){Ve(r,r.return,T)}r.flags&=-3}o&4096&&(r.flags&=-4097)}function Bx(r,o,l){ee=r,wm(r)}function wm(r,o,l){for(var h=(r.mode&1)!==0;ee!==null;){var p=ee,v=p.child;if(p.tag===22&&h){var j=p.memoizedState!==null||jo;if(!j){var $=p.alternate,T=$!==null&&$.memoizedState!==null||ht;$=jo;var L=ht;if(jo=j,(ht=T)&&!L)for(ee=p;ee!==null;)j=ee,T=j.child,j.tag===22&&j.memoizedState!==null?bm(p):T!==null?(T.return=j,ee=T):bm(p);for(;v!==null;)ee=v,wm(v),v=v.sibling;ee=p,jo=$,ht=L}xm(r)}else(p.subtreeFlags&8772)!==0&&v!==null?(v.return=p,ee=v):xm(r)}}function xm(r){for(;ee!==null;){var o=ee;if((o.flags&8772)!==0){var l=o.alternate;try{if((o.flags&8772)!==0)switch(o.tag){case 0:case 11:case 15:ht||bo(5,o);break;case 1:var h=o.stateNode;if(o.flags&4&&!ht)if(l===null)h.componentDidMount();else{var p=o.elementType===o.type?l.memoizedProps:Jt(o.type,l.memoizedProps);h.componentDidUpdate(p,l.memoizedState,h.__reactInternalSnapshotBeforeUpdate)}var v=o.updateQueue;v!==null&&jf(o,v,h);break;case 3:var j=o.updateQueue;if(j!==null){if(l=null,o.child!==null)switch(o.child.tag){case 5:l=o.child.stateNode;break;case 1:l=o.child.stateNode}jf(o,j,l)}break;case 5:var $=o.stateNode;if(l===null&&o.flags&4){l=$;var T=o.memoizedProps;switch(o.type){case"button":case"input":case"select":case"textarea":T.autoFocus&&l.focus();break;case"img":T.src&&(l.src=T.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(o.memoizedState===null){var L=o.alternate;if(L!==null){var K=L.memoizedState;if(K!==null){var G=K.dehydrated;G!==null&&Oi(G)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}ht||o.flags&512&&bl(o)}catch(W){Ve(o,o.return,W)}}if(o===r){ee=null;break}if(l=o.sibling,l!==null){l.return=o.return,ee=l;break}ee=o.return}}function jm(r){for(;ee!==null;){var o=ee;if(o===r){ee=null;break}var l=o.sibling;if(l!==null){l.return=o.return,ee=l;break}ee=o.return}}function bm(r){for(;ee!==null;){var o=ee;try{switch(o.tag){case 0:case 11:case 15:var l=o.return;try{bo(4,o)}catch(T){Ve(o,l,T)}break;case 1:var h=o.stateNode;if(typeof h.componentDidMount=="function"){var p=o.return;try{h.componentDidMount()}catch(T){Ve(o,p,T)}}var v=o.return;try{bl(o)}catch(T){Ve(o,v,T)}break;case 5:var j=o.return;try{bl(o)}catch(T){Ve(o,j,T)}}}catch(T){Ve(o,o.return,T)}if(o===r){ee=null;break}var $=o.sibling;if($!==null){$.return=o.return,ee=$;break}ee=o.return}}var Fx=Math.ceil,So=M.ReactCurrentDispatcher,$l=M.ReactCurrentOwner,Bt=M.ReactCurrentBatchConfig,$e=0,nt=null,Ye=null,at=0,Mt=0,Zs=Bn(0),et=0,sr=null,ps=0,No=0,Cl=0,ir=null,bt=null,Tl=0,ei=1/0,Sn=null,$o=!1,El=null,Kn=null,Co=!1,Gn=null,To=0,rr=0,Al=null,Eo=-1,Ao=0;function kt(){return($e&6)!==0?qe():Eo!==-1?Eo:Eo=qe()}function Vn(r){return(r.mode&1)===0?1:($e&2)!==0&&at!==0?at&-at:bx.transition!==null?(Ao===0&&(Ao=ph()),Ao):(r=Ie,r!==0||(r=window.event,r=r===void 0?16:Sh(r.type)),r)}function en(r,o,l,h){if(50<rr)throw rr=0,Al=null,Error(n(185));Ei(r,l,h),(($e&2)===0||r!==nt)&&(r===nt&&(($e&2)===0&&(No|=l),et===4&&qn(r,at)),St(r,h),l===1&&$e===0&&(o.mode&1)===0&&(ei=qe()+500,so&&zn()))}function St(r,o){var l=r.callbackNode;bw(r,o);var h=_r(r,r===nt?at:0);if(h===0)l!==null&&hh(l),r.callbackNode=null,r.callbackPriority=0;else if(o=h&-h,r.callbackPriority!==o){if(l!=null&&hh(l),o===1)r.tag===0?jx(Nm.bind(null,r)):df(Nm.bind(null,r)),kx(function(){($e&6)===0&&zn()}),l=null;else{switch(gh(h)){case 1:l=lc;break;case 4:l=fh;break;case 16:l=Or;break;case 536870912:l=mh;break;default:l=Or}l=Mm(l,Sm.bind(null,r))}r.callbackPriority=o,r.callbackNode=l}}function Sm(r,o){if(Eo=-1,Ao=0,($e&6)!==0)throw Error(n(327));var l=r.callbackNode;if(ti()&&r.callbackNode!==l)return null;var h=_r(r,r===nt?at:0);if(h===0)return null;if((h&30)!==0||(h&r.expiredLanes)!==0||o)o=Ro(r,h);else{o=h;var p=$e;$e|=2;var v=Cm();(nt!==r||at!==o)&&(Sn=null,ei=qe()+500,vs(r,o));do try{Wx();break}catch($){$m(r,$)}while(!0);qc(),So.current=v,$e=p,Ye!==null?o=0:(nt=null,at=0,o=et)}if(o!==0){if(o===2&&(p=dc(r),p!==0&&(h=p,o=Rl(r,p))),o===1)throw l=sr,vs(r,0),qn(r,h),St(r,qe()),l;if(o===6)qn(r,h);else{if(p=r.current.alternate,(h&30)===0&&!zx(p)&&(o=Ro(r,h),o===2&&(v=dc(r),v!==0&&(h=v,o=Rl(r,v))),o===1))throw l=sr,vs(r,0),qn(r,h),St(r,qe()),l;switch(r.finishedWork=p,r.finishedLanes=h,o){case 0:case 1:throw Error(n(345));case 2:ks(r,bt,Sn);break;case 3:if(qn(r,h),(h&130023424)===h&&(o=Tl+500-qe(),10<o)){if(_r(r,0)!==0)break;if(p=r.suspendedLanes,(p&h)!==h){kt(),r.pingedLanes|=r.suspendedLanes&p;break}r.timeoutHandle=Dc(ks.bind(null,r,bt,Sn),o);break}ks(r,bt,Sn);break;case 4:if(qn(r,h),(h&4194240)===h)break;for(o=r.eventTimes,p=-1;0<h;){var j=31-qt(h);v=1<<j,j=o[j],j>p&&(p=j),h&=~v}if(h=p,h=qe()-h,h=(120>h?120:480>h?480:1080>h?1080:1920>h?1920:3e3>h?3e3:4320>h?4320:1960*Fx(h/1960))-h,10<h){r.timeoutHandle=Dc(ks.bind(null,r,bt,Sn),h);break}ks(r,bt,Sn);break;case 5:ks(r,bt,Sn);break;default:throw Error(n(329))}}}return St(r,qe()),r.callbackNode===l?Sm.bind(null,r):null}function Rl(r,o){var l=ir;return r.current.memoizedState.isDehydrated&&(vs(r,o).flags|=256),r=Ro(r,o),r!==2&&(o=bt,bt=l,o!==null&&Il(o)),r}function Il(r){bt===null?bt=r:bt.push.apply(bt,r)}function zx(r){for(var o=r;;){if(o.flags&16384){var l=o.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var h=0;h<l.length;h++){var p=l[h],v=p.getSnapshot;p=p.value;try{if(!Qt(v(),p))return!1}catch{return!1}}}if(l=o.child,o.subtreeFlags&16384&&l!==null)l.return=o,o=l;else{if(o===r)break;for(;o.sibling===null;){if(o.return===null||o.return===r)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function qn(r,o){for(o&=~Cl,o&=~No,r.suspendedLanes|=o,r.pingedLanes&=~o,r=r.expirationTimes;0<o;){var l=31-qt(o),h=1<<l;r[l]=-1,o&=~h}}function Nm(r){if(($e&6)!==0)throw Error(n(327));ti();var o=_r(r,0);if((o&1)===0)return St(r,qe()),null;var l=Ro(r,o);if(r.tag!==0&&l===2){var h=dc(r);h!==0&&(o=h,l=Rl(r,h))}if(l===1)throw l=sr,vs(r,0),qn(r,o),St(r,qe()),l;if(l===6)throw Error(n(345));return r.finishedWork=r.current.alternate,r.finishedLanes=o,ks(r,bt,Sn),St(r,qe()),null}function Ml(r,o){var l=$e;$e|=1;try{return r(o)}finally{$e=l,$e===0&&(ei=qe()+500,so&&zn())}}function gs(r){Gn!==null&&Gn.tag===0&&($e&6)===0&&ti();var o=$e;$e|=1;var l=Bt.transition,h=Ie;try{if(Bt.transition=null,Ie=1,r)return r()}finally{Ie=h,Bt.transition=l,$e=o,($e&6)===0&&zn()}}function Ol(){Mt=Zs.current,De(Zs)}function vs(r,o){r.finishedWork=null,r.finishedLanes=0;var l=r.timeoutHandle;if(l!==-1&&(r.timeoutHandle=-1,vx(l)),Ye!==null)for(l=Ye.return;l!==null;){var h=l;switch(Wc(h),h.tag){case 1:h=h.type.childContextTypes,h!=null&&to();break;case 3:Ys(),De(wt),De(lt),nl();break;case 5:el(h);break;case 4:Ys();break;case 13:De(ze);break;case 19:De(ze);break;case 10:Qc(h.type._context);break;case 22:case 23:Ol()}l=l.return}if(nt=r,Ye=r=Qn(r.current,null),at=Mt=o,et=0,sr=null,Cl=No=ps=0,bt=ir=null,hs!==null){for(o=0;o<hs.length;o++)if(l=hs[o],h=l.interleaved,h!==null){l.interleaved=null;var p=h.next,v=l.pending;if(v!==null){var j=v.next;v.next=p,h.next=j}l.pending=h}hs=null}return r}function $m(r,o){do{var l=Ye;try{if(qc(),mo.current=ko,po){for(var h=Ue.memoizedState;h!==null;){var p=h.queue;p!==null&&(p.pending=null),h=h.next}po=!1}if(ms=0,tt=Ze=Ue=null,Ji=!1,Xi=0,$l.current=null,l===null||l.return===null){et=1,sr=o,Ye=null;break}e:{var v=r,j=l.return,$=l,T=o;if(o=at,$.flags|=32768,T!==null&&typeof T=="object"&&typeof T.then=="function"){var L=T,K=$,G=K.tag;if((K.mode&1)===0&&(G===0||G===11||G===15)){var W=K.alternate;W?(K.updateQueue=W.updateQueue,K.memoizedState=W.memoizedState,K.lanes=W.lanes):(K.updateQueue=null,K.memoizedState=null)}var X=Jf(j);if(X!==null){X.flags&=-257,Xf(X,j,$,v,o),X.mode&1&&Yf(v,L,o),o=X,T=L;var te=o.updateQueue;if(te===null){var ne=new Set;ne.add(T),o.updateQueue=ne}else te.add(T);break e}else{if((o&1)===0){Yf(v,L,o),Ll();break e}T=Error(n(426))}}else if(Be&&$.mode&1){var Qe=Jf(j);if(Qe!==null){(Qe.flags&65536)===0&&(Qe.flags|=256),Xf(Qe,j,$,v,o),Gc(Js(T,$));break e}}v=T=Js(T,$),et!==4&&(et=2),ir===null?ir=[v]:ir.push(v),v=j;do{switch(v.tag){case 3:v.flags|=65536,o&=-o,v.lanes|=o;var R=qf(v,T,o);xf(v,R);break e;case 1:$=T;var A=v.type,O=v.stateNode;if((v.flags&128)===0&&(typeof A.getDerivedStateFromError=="function"||O!==null&&typeof O.componentDidCatch=="function"&&(Kn===null||!Kn.has(O)))){v.flags|=65536,o&=-o,v.lanes|=o;var V=Qf(v,$,o);xf(v,V);break e}}v=v.return}while(v!==null)}Em(l)}catch(se){o=se,Ye===l&&l!==null&&(Ye=l=l.return);continue}break}while(!0)}function Cm(){var r=So.current;return So.current=ko,r===null?ko:r}function Ll(){(et===0||et===3||et===2)&&(et=4),nt===null||(ps&268435455)===0&&(No&268435455)===0||qn(nt,at)}function Ro(r,o){var l=$e;$e|=2;var h=Cm();(nt!==r||at!==o)&&(Sn=null,vs(r,o));do try{Ux();break}catch(p){$m(r,p)}while(!0);if(qc(),$e=l,So.current=h,Ye!==null)throw Error(n(261));return nt=null,at=0,et}function Ux(){for(;Ye!==null;)Tm(Ye)}function Wx(){for(;Ye!==null&&!mw();)Tm(Ye)}function Tm(r){var o=Im(r.alternate,r,Mt);r.memoizedProps=r.pendingProps,o===null?Em(r):Ye=o,$l.current=null}function Em(r){var o=r;do{var l=o.alternate;if(r=o.return,(o.flags&32768)===0){if(l=Lx(l,o,Mt),l!==null){Ye=l;return}}else{if(l=Px(l,o),l!==null){l.flags&=32767,Ye=l;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{et=6,Ye=null;return}}if(o=o.sibling,o!==null){Ye=o;return}Ye=o=r}while(o!==null);et===0&&(et=5)}function ks(r,o,l){var h=Ie,p=Bt.transition;try{Bt.transition=null,Ie=1,Hx(r,o,l,h)}finally{Bt.transition=p,Ie=h}return null}function Hx(r,o,l,h){do ti();while(Gn!==null);if(($e&6)!==0)throw Error(n(327));l=r.finishedWork;var p=r.finishedLanes;if(l===null)return null;if(r.finishedWork=null,r.finishedLanes=0,l===r.current)throw Error(n(177));r.callbackNode=null,r.callbackPriority=0;var v=l.lanes|l.childLanes;if(Sw(r,v),r===nt&&(Ye=nt=null,at=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||Co||(Co=!0,Mm(Or,function(){return ti(),null})),v=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||v){v=Bt.transition,Bt.transition=null;var j=Ie;Ie=1;var $=$e;$e|=4,$l.current=null,_x(r,l),ym(l,r),dx(Lc),zr=!!Oc,Lc=Oc=null,r.current=l,Bx(l),pw(),$e=$,Ie=j,Bt.transition=v}else r.current=l;if(Co&&(Co=!1,Gn=r,To=p),v=r.pendingLanes,v===0&&(Kn=null),kw(l.stateNode),St(r,qe()),o!==null)for(h=r.onRecoverableError,l=0;l<o.length;l++)p=o[l],h(p.value,{componentStack:p.stack,digest:p.digest});if($o)throw $o=!1,r=El,El=null,r;return(To&1)!==0&&r.tag!==0&&ti(),v=r.pendingLanes,(v&1)!==0?r===Al?rr++:(rr=0,Al=r):rr=0,zn(),null}function ti(){if(Gn!==null){var r=gh(To),o=Bt.transition,l=Ie;try{if(Bt.transition=null,Ie=16>r?16:r,Gn===null)var h=!1;else{if(r=Gn,Gn=null,To=0,($e&6)!==0)throw Error(n(331));var p=$e;for($e|=4,ee=r.current;ee!==null;){var v=ee,j=v.child;if((ee.flags&16)!==0){var $=v.deletions;if($!==null){for(var T=0;T<$.length;T++){var L=$[T];for(ee=L;ee!==null;){var K=ee;switch(K.tag){case 0:case 11:case 15:nr(8,K,v)}var G=K.child;if(G!==null)G.return=K,ee=G;else for(;ee!==null;){K=ee;var W=K.sibling,X=K.return;if(mm(K),K===L){ee=null;break}if(W!==null){W.return=X,ee=W;break}ee=X}}}var te=v.alternate;if(te!==null){var ne=te.child;if(ne!==null){te.child=null;do{var Qe=ne.sibling;ne.sibling=null,ne=Qe}while(ne!==null)}}ee=v}}if((v.subtreeFlags&2064)!==0&&j!==null)j.return=v,ee=j;else e:for(;ee!==null;){if(v=ee,(v.flags&2048)!==0)switch(v.tag){case 0:case 11:case 15:nr(9,v,v.return)}var R=v.sibling;if(R!==null){R.return=v.return,ee=R;break e}ee=v.return}}var A=r.current;for(ee=A;ee!==null;){j=ee;var O=j.child;if((j.subtreeFlags&2064)!==0&&O!==null)O.return=j,ee=O;else e:for(j=A;ee!==null;){if($=ee,($.flags&2048)!==0)try{switch($.tag){case 0:case 11:case 15:bo(9,$)}}catch(se){Ve($,$.return,se)}if($===j){ee=null;break e}var V=$.sibling;if(V!==null){V.return=$.return,ee=V;break e}ee=$.return}}if($e=p,zn(),on&&typeof on.onPostCommitFiberRoot=="function")try{on.onPostCommitFiberRoot(Lr,r)}catch{}h=!0}return h}finally{Ie=l,Bt.transition=o}}return!1}function Am(r,o,l){o=Js(l,o),o=qf(r,o,1),r=Wn(r,o,1),o=kt(),r!==null&&(Ei(r,1,o),St(r,o))}function Ve(r,o,l){if(r.tag===3)Am(r,r,l);else for(;o!==null;){if(o.tag===3){Am(o,r,l);break}else if(o.tag===1){var h=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof h.componentDidCatch=="function"&&(Kn===null||!Kn.has(h))){r=Js(l,r),r=Qf(o,r,1),o=Wn(o,r,1),r=kt(),o!==null&&(Ei(o,1,r),St(o,r));break}}o=o.return}}function Kx(r,o,l){var h=r.pingCache;h!==null&&h.delete(o),o=kt(),r.pingedLanes|=r.suspendedLanes&l,nt===r&&(at&l)===l&&(et===4||et===3&&(at&130023424)===at&&500>qe()-Tl?vs(r,0):Cl|=l),St(r,o)}function Rm(r,o){o===0&&((r.mode&1)===0?o=1:(o=Dr,Dr<<=1,(Dr&130023424)===0&&(Dr=4194304)));var l=kt();r=xn(r,o),r!==null&&(Ei(r,o,l),St(r,l))}function Gx(r){var o=r.memoizedState,l=0;o!==null&&(l=o.retryLane),Rm(r,l)}function Vx(r,o){var l=0;switch(r.tag){case 13:var h=r.stateNode,p=r.memoizedState;p!==null&&(l=p.retryLane);break;case 19:h=r.stateNode;break;default:throw Error(n(314))}h!==null&&h.delete(o),Rm(r,l)}var Im;Im=function(r,o,l){if(r!==null)if(r.memoizedProps!==o.pendingProps||wt.current)jt=!0;else{if((r.lanes&l)===0&&(o.flags&128)===0)return jt=!1,Ox(r,o,l);jt=(r.flags&131072)!==0}else jt=!1,Be&&(o.flags&1048576)!==0&&uf(o,ro,o.index);switch(o.lanes=0,o.tag){case 2:var h=o.type;xo(r,o),r=o.pendingProps;var p=Ws(o,lt.current);Qs(o,l),p=rl(null,o,h,r,p,l);var v=ol();return o.flags|=1,typeof p=="object"&&p!==null&&typeof p.render=="function"&&p.$$typeof===void 0?(o.tag=1,o.memoizedState=null,o.updateQueue=null,xt(h)?(v=!0,no(o)):v=!1,o.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,Xc(o),p.updater=yo,o.stateNode=p,p._reactInternals=o,hl(o,h,r,l),o=gl(null,o,h,!0,v,l)):(o.tag=0,Be&&v&&Uc(o),vt(null,o,p,l),o=o.child),o;case 16:h=o.elementType;e:{switch(xo(r,o),r=o.pendingProps,p=h._init,h=p(h._payload),o.type=h,p=o.tag=Qx(h),r=Jt(h,r),p){case 0:o=pl(null,o,h,r,l);break e;case 1:o=im(null,o,h,r,l);break e;case 11:o=Zf(null,o,h,r,l);break e;case 14:o=em(null,o,h,Jt(h.type,r),l);break e}throw Error(n(306,h,""))}return o;case 0:return h=o.type,p=o.pendingProps,p=o.elementType===h?p:Jt(h,p),pl(r,o,h,p,l);case 1:return h=o.type,p=o.pendingProps,p=o.elementType===h?p:Jt(h,p),im(r,o,h,p,l);case 3:e:{if(rm(o),r===null)throw Error(n(387));h=o.pendingProps,v=o.memoizedState,p=v.element,wf(r,o),ho(o,h,null,l);var j=o.memoizedState;if(h=j.element,v.isDehydrated)if(v={element:h,isDehydrated:!1,cache:j.cache,pendingSuspenseBoundaries:j.pendingSuspenseBoundaries,transitions:j.transitions},o.updateQueue.baseState=v,o.memoizedState=v,o.flags&256){p=Js(Error(n(423)),o),o=om(r,o,h,l,p);break e}else if(h!==p){p=Js(Error(n(424)),o),o=om(r,o,h,l,p);break e}else for(It=_n(o.stateNode.containerInfo.firstChild),Rt=o,Be=!0,Yt=null,l=kf(o,null,h,l),o.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Gs(),h===p){o=bn(r,o,l);break e}vt(r,o,h,l)}o=o.child}return o;case 5:return bf(o),r===null&&Kc(o),h=o.type,p=o.pendingProps,v=r!==null?r.memoizedProps:null,j=p.children,Pc(h,p)?j=null:v!==null&&Pc(h,v)&&(o.flags|=32),sm(r,o),vt(r,o,j,l),o.child;case 6:return r===null&&Kc(o),null;case 13:return am(r,o,l);case 4:return Zc(o,o.stateNode.containerInfo),h=o.pendingProps,r===null?o.child=Vs(o,null,h,l):vt(r,o,h,l),o.child;case 11:return h=o.type,p=o.pendingProps,p=o.elementType===h?p:Jt(h,p),Zf(r,o,h,p,l);case 7:return vt(r,o,o.pendingProps,l),o.child;case 8:return vt(r,o,o.pendingProps.children,l),o.child;case 12:return vt(r,o,o.pendingProps.children,l),o.child;case 10:e:{if(h=o.type._context,p=o.pendingProps,v=o.memoizedProps,j=p.value,Oe(co,h._currentValue),h._currentValue=j,v!==null)if(Qt(v.value,j)){if(v.children===p.children&&!wt.current){o=bn(r,o,l);break e}}else for(v=o.child,v!==null&&(v.return=o);v!==null;){var $=v.dependencies;if($!==null){j=v.child;for(var T=$.firstContext;T!==null;){if(T.context===h){if(v.tag===1){T=jn(-1,l&-l),T.tag=2;var L=v.updateQueue;if(L!==null){L=L.shared;var K=L.pending;K===null?T.next=T:(T.next=K.next,K.next=T),L.pending=T}}v.lanes|=l,T=v.alternate,T!==null&&(T.lanes|=l),Yc(v.return,l,o),$.lanes|=l;break}T=T.next}}else if(v.tag===10)j=v.type===o.type?null:v.child;else if(v.tag===18){if(j=v.return,j===null)throw Error(n(341));j.lanes|=l,$=j.alternate,$!==null&&($.lanes|=l),Yc(j,l,o),j=v.sibling}else j=v.child;if(j!==null)j.return=v;else for(j=v;j!==null;){if(j===o){j=null;break}if(v=j.sibling,v!==null){v.return=j.return,j=v;break}j=j.return}v=j}vt(r,o,p.children,l),o=o.child}return o;case 9:return p=o.type,h=o.pendingProps.children,Qs(o,l),p=Dt(p),h=h(p),o.flags|=1,vt(r,o,h,l),o.child;case 14:return h=o.type,p=Jt(h,o.pendingProps),p=Jt(h.type,p),em(r,o,h,p,l);case 15:return tm(r,o,o.type,o.pendingProps,l);case 17:return h=o.type,p=o.pendingProps,p=o.elementType===h?p:Jt(h,p),xo(r,o),o.tag=1,xt(h)?(r=!0,no(o)):r=!1,Qs(o,l),Gf(o,h,p),hl(o,h,p,l),gl(null,o,h,!0,r,l);case 19:return lm(r,o,l);case 22:return nm(r,o,l)}throw Error(n(156,o.tag))};function Mm(r,o){return uh(r,o)}function qx(r,o,l,h){this.tag=r,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=h,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ft(r,o,l,h){return new qx(r,o,l,h)}function Pl(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Qx(r){if(typeof r=="function")return Pl(r)?1:0;if(r!=null){if(r=r.$$typeof,r===ye)return 11;if(r===Re)return 14}return 2}function Qn(r,o){var l=r.alternate;return l===null?(l=Ft(r.tag,o,r.key,r.mode),l.elementType=r.elementType,l.type=r.type,l.stateNode=r.stateNode,l.alternate=r,r.alternate=l):(l.pendingProps=o,l.type=r.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=r.flags&14680064,l.childLanes=r.childLanes,l.lanes=r.lanes,l.child=r.child,l.memoizedProps=r.memoizedProps,l.memoizedState=r.memoizedState,l.updateQueue=r.updateQueue,o=r.dependencies,l.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},l.sibling=r.sibling,l.index=r.index,l.ref=r.ref,l}function Io(r,o,l,h,p,v){var j=2;if(h=r,typeof r=="function")Pl(r)&&(j=1);else if(typeof r=="string")j=5;else e:switch(r){case Y:return ys(l.children,p,v,o);case re:j=8,p|=8;break;case q:return r=Ft(12,l,o,p|2),r.elementType=q,r.lanes=v,r;case be:return r=Ft(13,l,o,p),r.elementType=be,r.lanes=v,r;case de:return r=Ft(19,l,o,p),r.elementType=de,r.lanes=v,r;case Se:return Mo(l,p,v,o);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case Z:j=10;break e;case Ae:j=9;break e;case ye:j=11;break e;case Re:j=14;break e;case me:j=16,h=null;break e}throw Error(n(130,r==null?r:typeof r,""))}return o=Ft(j,l,o,p),o.elementType=r,o.type=h,o.lanes=v,o}function ys(r,o,l,h){return r=Ft(7,r,h,o),r.lanes=l,r}function Mo(r,o,l,h){return r=Ft(22,r,h,o),r.elementType=Se,r.lanes=l,r.stateNode={isHidden:!1},r}function Dl(r,o,l){return r=Ft(6,r,null,o),r.lanes=l,r}function _l(r,o,l){return o=Ft(4,r.children!==null?r.children:[],r.key,o),o.lanes=l,o.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},o}function Yx(r,o,l,h,p){this.tag=o,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=uc(0),this.expirationTimes=uc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=uc(0),this.identifierPrefix=h,this.onRecoverableError=p,this.mutableSourceEagerHydrationData=null}function Bl(r,o,l,h,p,v,j,$,T){return r=new Yx(r,o,l,$,T),o===1?(o=1,v===!0&&(o|=8)):o=0,v=Ft(3,null,null,o),r.current=v,v.stateNode=r,v.memoizedState={element:h,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},Xc(v),r}function Jx(r,o,l){var h=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:_,key:h==null?null:""+h,children:r,containerInfo:o,implementation:l}}function Om(r){if(!r)return Fn;r=r._reactInternals;e:{if(as(r)!==r||r.tag!==1)throw Error(n(170));var o=r;do{switch(o.tag){case 3:o=o.stateNode.context;break e;case 1:if(xt(o.type)){o=o.stateNode.__reactInternalMemoizedMergedChildContext;break e}}o=o.return}while(o!==null);throw Error(n(171))}if(r.tag===1){var l=r.type;if(xt(l))return cf(r,l,o)}return o}function Lm(r,o,l,h,p,v,j,$,T){return r=Bl(l,h,!0,r,p,v,j,$,T),r.context=Om(null),l=r.current,h=kt(),p=Vn(l),v=jn(h,p),v.callback=o??null,Wn(l,v,p),r.current.lanes=p,Ei(r,p,h),St(r,h),r}function Oo(r,o,l,h){var p=o.current,v=kt(),j=Vn(p);return l=Om(l),o.context===null?o.context=l:o.pendingContext=l,o=jn(v,j),o.payload={element:r},h=h===void 0?null:h,h!==null&&(o.callback=h),r=Wn(p,o,j),r!==null&&(en(r,p,j,v),uo(r,p,j)),j}function Lo(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 5:return r.child.stateNode;default:return r.child.stateNode}}function Pm(r,o){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var l=r.retryLane;r.retryLane=l!==0&&l<o?l:o}}function Fl(r,o){Pm(r,o),(r=r.alternate)&&Pm(r,o)}function Xx(){return null}var Dm=typeof reportError=="function"?reportError:function(r){console.error(r)};function zl(r){this._internalRoot=r}Po.prototype.render=zl.prototype.render=function(r){var o=this._internalRoot;if(o===null)throw Error(n(409));Oo(r,o,null,null)},Po.prototype.unmount=zl.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var o=r.containerInfo;gs(function(){Oo(null,r,null,null)}),o[vn]=null}};function Po(r){this._internalRoot=r}Po.prototype.unstable_scheduleHydration=function(r){if(r){var o=yh();r={blockedOn:null,target:r,priority:o};for(var l=0;l<Ln.length&&o!==0&&o<Ln[l].priority;l++);Ln.splice(l,0,r),l===0&&jh(r)}};function Ul(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function Do(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function _m(){}function Zx(r,o,l,h,p){if(p){if(typeof h=="function"){var v=h;h=function(){var L=Lo(j);v.call(L)}}var j=Lm(o,h,r,0,null,!1,!1,"",_m);return r._reactRootContainer=j,r[vn]=j.current,Wi(r.nodeType===8?r.parentNode:r),gs(),j}for(;p=r.lastChild;)r.removeChild(p);if(typeof h=="function"){var $=h;h=function(){var L=Lo(T);$.call(L)}}var T=Bl(r,0,!1,null,null,!1,!1,"",_m);return r._reactRootContainer=T,r[vn]=T.current,Wi(r.nodeType===8?r.parentNode:r),gs(function(){Oo(o,T,l,h)}),T}function _o(r,o,l,h,p){var v=l._reactRootContainer;if(v){var j=v;if(typeof p=="function"){var $=p;p=function(){var T=Lo(j);$.call(T)}}Oo(o,j,r,p)}else j=Zx(l,o,r,p,h);return Lo(j)}vh=function(r){switch(r.tag){case 3:var o=r.stateNode;if(o.current.memoizedState.isDehydrated){var l=Ti(o.pendingLanes);l!==0&&(hc(o,l|1),St(o,qe()),($e&6)===0&&(ei=qe()+500,zn()))}break;case 13:gs(function(){var h=xn(r,1);if(h!==null){var p=kt();en(h,r,1,p)}}),Fl(r,1)}},fc=function(r){if(r.tag===13){var o=xn(r,134217728);if(o!==null){var l=kt();en(o,r,134217728,l)}Fl(r,134217728)}},kh=function(r){if(r.tag===13){var o=Vn(r),l=xn(r,o);if(l!==null){var h=kt();en(l,r,o,h)}Fl(r,o)}},yh=function(){return Ie},wh=function(r,o){var l=Ie;try{return Ie=r,o()}finally{Ie=l}},rc=function(r,o,l){switch(o){case"input":if(Ja(r,l),o=l.name,l.type==="radio"&&o!=null){for(l=r;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+o)+'][type="radio"]'),o=0;o<l.length;o++){var h=l[o];if(h!==r&&h.form===r.form){var p=eo(h);if(!p)throw Error(n(90));Ar(h),Ja(h,p)}}}break;case"textarea":Qu(r,l);break;case"select":o=l.value,o!=null&&Rs(r,!!l.multiple,o,!1)}},ih=Ml,rh=gs;var ej={usingClientEntryPoint:!1,Events:[Gi,zs,eo,nh,sh,Ml]},or={findFiberByHostInstance:cs,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},tj={bundleType:or.bundleType,version:or.version,rendererPackageName:or.rendererPackageName,rendererConfig:or.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:M.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=lh(r),r===null?null:r.stateNode},findFiberByHostInstance:or.findFiberByHostInstance||Xx,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 Bo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Bo.isDisabled&&Bo.supportsFiber)try{Lr=Bo.inject(tj),on=Bo}catch{}}return Nt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ej,Nt.createPortal=function(r,o){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ul(o))throw Error(n(200));return Jx(r,o,null,l)},Nt.createRoot=function(r,o){if(!Ul(r))throw Error(n(299));var l=!1,h="",p=Dm;return o!=null&&(o.unstable_strictMode===!0&&(l=!0),o.identifierPrefix!==void 0&&(h=o.identifierPrefix),o.onRecoverableError!==void 0&&(p=o.onRecoverableError)),o=Bl(r,1,!1,null,null,l,!1,h,p),r[vn]=o.current,Wi(r.nodeType===8?r.parentNode:r),new zl(o)},Nt.findDOMNode=function(r){if(r==null)return null;if(r.nodeType===1)return r;var o=r._reactInternals;if(o===void 0)throw typeof r.render=="function"?Error(n(188)):(r=Object.keys(r).join(","),Error(n(268,r)));return r=lh(o),r=r===null?null:r.stateNode,r},Nt.flushSync=function(r){return gs(r)},Nt.hydrate=function(r,o,l){if(!Do(o))throw Error(n(200));return _o(null,r,o,!0,l)},Nt.hydrateRoot=function(r,o,l){if(!Ul(r))throw Error(n(405));var h=l!=null&&l.hydratedSources||null,p=!1,v="",j=Dm;if(l!=null&&(l.unstable_strictMode===!0&&(p=!0),l.identifierPrefix!==void 0&&(v=l.identifierPrefix),l.onRecoverableError!==void 0&&(j=l.onRecoverableError)),o=Lm(o,null,r,1,l??null,p,!1,v,j),r[vn]=o.current,Wi(r),h)for(r=0;r<h.length;r++)l=h[r],p=l._getVersion,p=p(l._source),o.mutableSourceEagerHydrationData==null?o.mutableSourceEagerHydrationData=[l,p]:o.mutableSourceEagerHydrationData.push(l,p);return new Po(o)},Nt.render=function(r,o,l){if(!Do(o))throw Error(n(200));return _o(null,r,o,!1,l)},Nt.unmountComponentAtNode=function(r){if(!Do(r))throw Error(n(40));return r._reactRootContainer?(gs(function(){_o(null,null,r,!1,function(){r._reactRootContainer=null,r[vn]=null})}),!0):!1},Nt.unstable_batchedUpdates=Ml,Nt.unstable_renderSubtreeIntoContainer=function(r,o,l,h){if(!Do(l))throw Error(n(200));if(r==null||r._reactInternals===void 0)throw Error(n(38));return _o(r,o,l,!1,h)},Nt.version="18.3.1-next-f1338f8080-20240426",Nt}var Gm;function Vg(){if(Gm)return Kl.exports;Gm=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(),Kl.exports=dj(),Kl.exports}var Vm;function uj(){if(Vm)return Fo;Vm=1;var e=Vg();return Fo.createRoot=e.createRoot,Fo.hydrateRoot=e.hydrateRoot,Fo}var hj=uj(),y=su();const Zn="teamtrail",J={slug:Zn,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:Zn,dataDir:`.${Zn}`,apiPrefix:`/__${Zn}`,dataDirEnv:`${Zn.toUpperCase()}_DIR`,noRegisterEnv:`${Zn.toUpperCase()}_NO_REGISTER`,tokenEnv:`${Zn.toUpperCase()}_TOKEN`},xa=`${Zn}.prefs`,ja=e=>`${J.labelPrefix}:${e}`,iu=ja("map"),ru=ja("hitl"),fj=e=>e==="task"||e==="execute",ou=ja("plan-only");function qg(e){return/^[A-Za-z0-9_@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}const mj=e=>e.map(qg).join(" "),pj=/^\d+\.\d+\.\d+(-[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function gj(e){return pj.test(e)?`${J.npm}@${e}`:J.npm}function Qg(e,t){return mj(["npx","-y",gj(e),...t])}const na=["research","prototype","junction","task","execute"],is=[...na,"review"],$s="plan+execute",vj=e=>e.filter(t=>!t.archived),kj=["verifying","rework","blocked"],au=["off","checks","checks+review","checks+review+human"],Yg=e=>au.find(t=>t===e);function pi(e){return e.type==="junction"||e.type==="prototype"?"hitl":e.type==="research"?"afk":e.hitl?"hitl":"afk"}const yj=["task","execute"];function Jg(e,t,n=$s){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":n==="plan-only"&&e.type==="execute"?"parked":e.blockedBy.some(a=>{var c;return((c=t.get(a))==null?void 0:c.state)==="open"})?"blocked":"frontier"}function Cs(e,t=$s){const n=new Map(e.map(i=>[i.id,i]));return new Map(e.map(i=>[i.id,Jg(i,n,t)]))}const qm=e=>{var t;return Number(((t=/(\d+)\D*$/.exec(e.key))==null?void 0:t[1])??NaN)};function wj(e,t){const n=qm(e),i=qm(t);return n!==i&&!Number.isNaN(n)&&!Number.isNaN(i)?n-i:e.key.localeCompare(t.key)||e.id.localeCompare(t.id)}function xj(e){const t=new Map(e.map(c=>[c.id,c])),n=new Map,i=new Set,a=c=>{var m;const d=n.get(c);if(d!==void 0)return d;if(i.has(c))return 0;i.add(c);const u=((m=t.get(c))==null?void 0:m.blockedBy.filter(g=>t.has(g)))??[],f=u.length?1+Math.max(...u.map(a)):0;return i.delete(c),n.set(c,f),f};return a}const _e=200,He=56,ba={LR:{layer:330,lane:112,sub:260,along:_e,across:He,aspect:1.6},TB:{layer:124,lane:262,sub:100,along:He,across:_e,aspect:4/3}},jj=6;function bj(e){const{sizes:t}=e,n=ba[e.direction],i=t.map(()=>1),a=c=>Math.ceil(t[c]/i[c]);for(;;){const c=Math.max(1,...t.map((m,g)=>a(g))),d=t.reduce((m,g,k)=>m+(i[k]-1)*n.sub+n.layer,0)-(n.layer-n.along),u=c*n.lane-(n.lane-n.across);if(d>=n.aspect*u||c<=1)return i;const f=t.findIndex((m,g)=>a(g)===c);if(t[f]<=jj)return i;i[f]=Math.ceil(t[f]/(c-1))}}function Qm(e,t="LR",n=$s){var q;const i=ba[t],a=Cs(e,n),c=e.filter(Z=>a.get(Z.id)!=="out-of-scope"),d=e.filter(Z=>a.get(Z.id)==="out-of-scope"),u=xj(e),f=[];for(const Z of c)(f[q=u(Z.id)]??(f[q]=[])).push(Z);const m=Sj(Array.from(f,Z=>Z??[]),t),g=Math.max(1,...m.map(Z=>Z.lanes)),k=[],w=[];let b=0;m.forEach((Z,Ae)=>{const ye=(g-Z.lanes)*i.lane/2,be=(Re,me)=>t==="LR"?{x:Re,y:me}:{x:me,y:Re},de=Z.subs>1;if(Z.tickets.forEach((Re,me)=>{const Se=Math.floor(me/Z.lanes),z=de?{wrap:{group:w.length,sub:Se,subs:Z.subs}}:{},Q=be(b+Se*i.sub,ye+me%Z.lanes*i.lane);k.push({ticket:Re,state:a.get(Re.id),layer:Ae,...Q,...z})}),de){const Re=be(b,ye),me=be((Z.subs-1)*i.sub+i.along,(Z.lanes-1)*i.lane+i.across);w.push({layer:Ae,...Re,w:me.x,h:me.y,subs:Z.subs,lanes:Z.lanes})}b+=(Z.subs-1)*i.sub+i.layer});const S=Math.max(b,i.layer)-(i.layer-i.along),x=g*i.lane-(i.lane-i.across),C=t==="LR"?S:x,N=t==="LR"?x:S,P=Nj({ruled:d,graphW:C,graphH:N});k.push(...P.nodes);const D=[],M=new Map(k.map(Z=>[Z.ticket.id,Z]));for(const Z of k)for(const Ae of Z.ticket.blockedBy){const ye=M.get(Ae);ye&&D.push({from:ye,to:Z})}const{width:H,height:_,quarantineY:Y,quarantineH:re}=P;return{direction:t,nodes:k,edges:D,groups:w,width:H,graphH:N,quarantineY:Y,height:_,quarantineH:re}}function Sj(e,t){const n=bj({sizes:e.map(c=>c.length),direction:t}),i=new Map,a=c=>{const d=c.blockedBy.map(u=>i.get(u)).filter(u=>u!==void 0);return d.length?d.reduce((u,f)=>u+f,0)/d.length:c.createdAt/1e12};return e.map((c,d)=>{const u=Math.ceil(c.length/n[d]),m=n[d]>1?[...c].sort(wj):[...c].sort((g,k)=>a(g)-a(k)||g.createdAt-k.createdAt);return m.forEach((g,k)=>i.set(g.id,k%Math.max(u,1))),{tickets:m,lanes:u,subs:u?Math.ceil(c.length/u):1}})}function Nj(e){const{ruled:t,graphW:n,graphH:i}=e,a=i+54,c=Math.max(1,Math.floor((n+24)/(_e+24))),d=t.map((g,k)=>({ticket:g,state:"out-of-scope",layer:-1,x:k%c*(_e+24),y:a+Math.floor(k/c)*(He+16)})),u=Math.ceil(t.length/c),f=Math.max(n,Math.min(t.length,c)*(_e+24)-24),m=t.length?a+u*(He+16)-16:i;return{nodes:d,width:f,height:m,quarantineY:a,quarantineH:u*(He+16)+24}}const sa=["fast","balanced","strongest"],Ym="balanced",$j=[["*-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"]],Xg=e=>sa.includes(e),cu={research:"fast",task:"balanced",execute:"balanced",junction:"strongest",prototype:"strongest",review:"strongest"};function Cj(e,t){var a,c;const n=(c=(a=t.modelMatching)==null?void 0:a.tiers)==null?void 0:c[e.type],i=cu[e.type];return t.settingsUnconfirmed&&n?sa.indexOf(n)>=sa.indexOf(i)?n:i:n??i}function Jm(e){return Object.fromEntries(is.map(t=>[t,Cj({type:t},e)]))}const Tj=e=>e!=="__proto__"&&e!=="constructor"&&e!=="prototype",Ej=64;function Aj(e,t){const n=[];for(let i=0;i<e.length;i++){const a=e[i];if(a!=="*"&&!(a==="?"&&t))n.push({kind:"char",c:a});else if(a==="?")n.push({kind:"one"});else if(!t||e[i+1]!=="*")n.push({kind:t?"star":"deep"});else{const c=e[i+2]==="/";i+=c?2:1,n.push({kind:c?"dirs":"deep"})}}return Rj(n)}function Rj(e){const t=[];for(const n of e){const i=t.at(-1);(i==null?void 0:i.kind)==="dirs"&&n.kind==="dirs"||(i==null?void 0:i.kind)==="deep"&&(n.kind==="deep"||n.kind==="dirs")||((i==null?void 0:i.kind)==="dirs"&&n.kind==="deep"?t[t.length-1]=n:t.push(n))}return t}function Ij({t:e,c:t,inText:n,next:i,cur:a,j:c}){switch(e.kind){case"char":return n&&t===e.c?i[c+1]:0;case"one":return n&&t!=="/"?i[c+1]:0;case"star":return i[c]||(n&&t!=="/"?a[c+1]:0);case"deep":return i[c]||(n?a[c+1]:0);case"dirs":return 0;default:return e}}function Mj(e,t,n){const i=n.length,a=new Uint8Array(i+1);let c=0;for(let d=i;d>=0;d--){const u=d<i,f=u?n[d]:"";if(e.kind!=="dirs"){a[d]=Ij({t:e,c:f,inText:u,next:t,cur:a,j:d});continue}f==="/"&&t[d+1]&&(c=1),a[d]=t[d]||c}return a}function Zg(e,t,n){const i=Aj(e,n.segments);if(i.filter(c=>c.kind!=="char").length>Ej)return!1;let a=new Uint8Array(t.length+1);a[t.length]=1;for(let c=i.length-1;c>=0;c--)a=Mj(i[c],a,t);return a[0]===1}function Xm(e,t){return Zg(e.trim().toLowerCase(),t.trim().toLowerCase(),{segments:!1})}function Oj(e,t={}){const n=e==null?void 0:e.trim();if(!n)return{tier:Ym,source:"unknown",reason:"no model reported, so it counts as balanced"};const a=Object.entries(t).find(([d])=>d.trim().toLowerCase()===n.toLowerCase())??Object.entries(t).find(([d])=>Xm(d,n));if(a)return{tier:a[1],model:n,source:"project",reason:`${n} is ${a[1]} in models.json`};const c=$j.find(([d])=>Xm(d,n));return c?{tier:c[1],model:n,source:"built-in",reason:`${n} is a ${c[1]} model`}:{tier:Ym,model:n,source:"unknown",reason:`${n} is not a known model, so it counts as balanced`}}const Lj=["holding","challenged","invalidated","confirmed"],Pj=e=>Lj.includes(e),Dj=J.labelPrefix,Cd=" -->",_j=7e4,ev=e=>`<!-- ${Dj}:${e} `,Bj=e=>JSON.stringify(e).replace(/--/g,"-\\u002d"),Fj=(e,t)=>`${ev(e)}${t}${Cd}`;function zj(e,t){const n=e.trimEnd();if(!n.endsWith(Cd))return;const i=ev(t),a=n.lastIndexOf(i);if(!(a===-1||n.length-a>_j))return{before:n.slice(0,a),payload:n.slice(a+i.length,-Cd.length)}}const Uj=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/,Wj=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]+/g,Hj=/\r\n|[\r\u0085\u2028\u2029]/g,Kj=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/g,Gj=e=>Uj.test(e),xs=e=>e.replace(Wj," ").trim(),Vj=e=>e.replace(Hj,`
|
|
41
|
+
`).replace(Kj,"");function Sa(e,t){const n=new RegExp(`^\\\\*(?:${t})`);return Vj(e).trim().split(`
|
|
42
|
+
`).map(i=>n.test(i)?`\\${i}`:i).join(`
|
|
43
|
+
`)}function ia(e,t){const n=new RegExp(`^\\\\+(?:${t})`);return e.split(`
|
|
44
|
+
`).map(i=>n.test(i)?i.slice(1):i).join(`
|
|
45
|
+
`)}const tv=J.labelPrefix,qj=new RegExp(`<(\\\\*)!--(?=\\s*${tv}:)`,"g"),Qj=new RegExp(`<\\\\(\\\\*)!--(?=\\s*${tv}:)`,"g"),Na=e=>e.replace(qj,"<\\$1!--"),oi=e=>e.replace(Qj,"<$1!--"),nv="asm",Yj=/^-\s+(?:\[([a-z]+)\]\s+)?/,Jj=1e3;function Xj(e){const t={id:e.id,tickets:e.tickets,...e.source?{source:e.source}:{},...e.challenge?{challenge:{...e.challenge,evidence:e.challenge.evidence.slice(0,Jj)}}:{},...e.decidedBy?{decidedBy:e.decidedBy}:{}};return`- [${e.status}] ${Na(xs(e.text))} ${Fj(nv,Bj(t))}`}function Zj(e){const t=e.map(e0);let n=Math.max(0,...t.map(i=>n0(i.id)))+1;return t.map(i=>i.id?i:{...i,id:`S-${n++}`})}function e0(e){const t=zj(e,nv),n=t?t.before:e,i=n.match(Yj),a=i==null?void 0:i[1],c=oi(n.slice(i?i[0].length:0).trim()),d=t0(t==null?void 0:t.payload);return{id:d.id??"",text:c,status:Pj(a)?a:"holding",tickets:Array.isArray(d.tickets)?d.tickets.map(String):[],...d.source?{source:d.source}:{},...d.challenge?{challenge:d.challenge}:{},...d.decidedBy?{decidedBy:d.decidedBy}:{}}}function t0(e){if(!e)return{};try{const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function n0(e){const t=e==null?void 0:e.match(/^S-(\d+)$/);return t?Number(t[1]):0}const sv=[["destination","Destination"],["notes","Notes"],["assumptions","Assumptions"],["decisions","Decisions so far"],["unspecified","Not yet specified"],["outOfScope","Out of scope"]],s0=Object.fromEntries(sv),iv="##\\s",Zm=e=>Na(Sa(e.trim(),iv)),ep=e=>ia(oi(e),iv),tp=e=>Na(xs(e)),i0=/^-\s+(?:\[?([#A-Z0-9-]+)\]?:?\s+)?(.*)$/;function r0(e){var i;const t=a=>a.length?a.map(c=>`- ${tp(c)}`).join(`
|
|
46
|
+
`):"_None yet._",n=a=>a.length?a.map(c=>`- ${c.ticketKey?`${xs(c.ticketKey)}: `:""}${tp(c.text)}`).join(`
|
|
47
|
+
`):"_None yet._";return[`## Destination
|
|
48
|
+
|
|
49
|
+
${Zm(e.destination)}`,`## Notes
|
|
50
|
+
|
|
51
|
+
${Zm(e.notes)||"_None yet._"}`,...(i=e.assumptions)!=null&&i.length?[`## Assumptions
|
|
52
|
+
|
|
53
|
+
${e.assumptions.map(Xj).join(`
|
|
54
|
+
`)}`]:[],`## Decisions so far
|
|
55
|
+
|
|
56
|
+
${n(e.decisions)}`,`## Not yet specified
|
|
57
|
+
|
|
58
|
+
${t(e.unspecified)}`,`## Out of scope
|
|
59
|
+
|
|
60
|
+
${t(e.outOfScope)}`].join(`
|
|
61
|
+
|
|
62
|
+
`)+`
|
|
63
|
+
`}function o0(e){var i;const t={destination:"",notes:"",decisions:[],unspecified:[],outOfScope:[]},n=e.split(/^##\s+/m).slice(1);for(const a of n){const c=a.indexOf(`
|
|
64
|
+
`),d=a.slice(0,c===-1?void 0:c).trim().toLowerCase(),u=(c===-1?"":a.slice(c+1)).trim(),f=(i=sv.find(([,k])=>k.toLowerCase()===d))==null?void 0:i[0];if(!f)continue;const m=/^_none yet\._$/i.test(u),g=m?[]:u.split(`
|
|
65
|
+
`).map(k=>k.trim()).filter(k=>k.startsWith("- "));f==="destination"?t.destination=ep(u):f==="notes"?t.notes=m?"":ep(u):f==="assumptions"?t.assumptions=Zj(g):f==="decisions"?t.decisions=g.map(k=>{const w=k.match(i0);return w&&w[1]&&/\d/.test(w[1])?{ticketKey:w[1],text:oi(w[2])}:{text:oi(k.slice(2))}}):t[f]=g.map(k=>oi(k.slice(2)))}return t}const $a={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"]},a0=(e,t)=>`${e[0].toUpperCase()}${e.slice(1)} ${t}/${$a[e].length}`;async function c0(e,t,n={}){var d,u,f;const i=l0(t,t.mode??$s),a=await e.createMap({title:i.title,mode:i.mode,sections:i.sections,...i.verification?{verification:i.verification}:{}});await((d=n.onMapCreated)==null?void 0:d.call(n,a));const c=new Map;for(const m of i.tickets){const g=await e.createTicket(a.id,{title:m.title,type:m.type,hitl:m.hitl,body:`${m.body}
|
|
66
|
+
|
|
67
|
+
Part of trail ${a.key}.`});c.set(m.ref,g),await((u=n.onTicketCreated)==null?void 0:u.call(n,g,m.ref))}for(const m of i.tickets)for(const g of m.blockedBy??[]){const k=c.get(g),w=c.get(m.ref);k&&(await e.addBlocking(a.id,k.id,w.id),await((f=n.onEdgeWired)==null?void 0:f.call(n,k,w)))}return{map:a,tickets:[...c.values()]}}function l0(e,t){if(t==="plan+execute")return{...e,mode:t};const n=new Map(e.tickets.filter(a=>a.type==="execute").map(a=>[a.ref,a.blockedBy??[]])),i=a=>a.flatMap(c=>n.has(c)?i(n.get(c)):[c]);return{...e,mode:t,tickets:e.tickets.filter(a=>!n.has(a.ref)).map(a=>({...a,blockedBy:[...new Set(i(a.blockedBy??[]))]}))}}class Me extends Error{}function rv(e){if(e.archived)throw new Me(`Trail ${e.key} "${e.title}" is archived: no work is taken from it. Only the trail lead can restore it in the Lookout.`)}class d0{constructor(){oe(this,"tails",new Map)}run(t,n){const a=(this.tails.get(t)??Promise.resolve()).catch(()=>{}).then(n);return this.tails.set(t,a),a.finally(()=>this.tails.get(t)===a&&this.tails.delete(t)).catch(()=>{}),a}}const u0={frontier:"ready",blocked:"backlog",parked:"backlog",claimed:"working",verifying:"verifying",rework:"rework",held:"blocked",decided:"done","out-of-scope":"cancelled"};function h0(e,t,n=$s){return u0[Jg(e,t,n)]}const f0=["backlog","ready","working","verifying","rework","blocked"],cr=["agent","trail lead"],m0=[{event:"claim",from:["ready","rework"],to:["working"],actors:cr},{event:"release",from:["working"],to:["ready","rework"],actors:cr},{event:"expire",from:["working"],to:["ready","rework"],actors:["engine","trail lead"]},{event:"complete",from:["backlog","ready","working","rework"],to:["done"],actors:cr},{event:"submit",from:["working"],to:["verifying"],actors:cr},{event:"checks.pass",from:["verifying"],to:["verifying","done","blocked"],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:f0,to:["cancelled"],actors:[...cr,"engine"]},{event:"reopen",from:["done","cancelled"],to:["ready"],actors:["trail lead"]},{event:"waive",from:["rework","blocked"],to:["verifying"],actors:["trail lead"]}],p0=e=>m0.find(t=>t.event===e),g0=new d0;function v0(e,t,n){if(n){if(!e.to.includes(n))throw new Me(`${e.event} cannot lead to ${n}`);return n}if(e.to.length===1)return e.to[0];if(e.event==="release"||e.event==="expire")return t.status==="rework"?"rework":"ready";throw new Me(`${e.event} needs a target: ${e.to.join(" or ")}`)}async function k0(e,t,n,i){const{to:a,actor:c}=i,d=async u=>{(n.status??null)!==u&&await e.setMeta(t,n.id,{status:u})};switch(a){case"working":n.assignee!==c&&await e.assign(t,n.id,c);return;case"ready":case"rework":n.state==="closed"&&await e.reopen(t,n.id),await d(a==="rework"?"rework":null),n.assignee&&await e.assign(t,n.id,null);return;case"verifying":case"blocked":await d(a);return;case"done":case"cancelled":await d(null),await e.close(t,n.id,a==="done"?"completed":"not_planned");return;case"backlog":throw new Me("backlog follows from blockers; no transition leads there")}}function Ca(e,t,n,i){return g0.run(`${t}/${n}`,async()=>{var m;const a=await e.loadMap(t),c=a.tickets.find(g=>g.id===n);if(!c)throw new Me(`ticket ${n} not found`);const d=h0(c,new Map(a.tickets.map(g=>[g.id,g])),a.map.mode);if(i.expect&&d!==i.expect)throw new Me(`${c.key} changed: it is ${d} now`);const u=p0(i.event);if(!u.from.includes(d))throw new Me(`${c.key} is ${d}; ${i.event} needs ${u.from.join(" or ")}`);if(!u.actors.includes(i.actorKind))throw new Me(`${i.event} is not for ${i.actorKind}s`);const f=v0(u,c,i.to);await k0(e,t,c,{to:f,actor:i.actor});try{await((m=i.journal)==null?void 0:m.append({v:1,kind:"transition",at:Date.now(),mapId:t,ticketId:n,ticketKey:c.key,event:i.event,from:d,to:f,actor:i.actor,actorKind:i.actorKind,...i.reason?{reason:i.reason}:{},...i.sessionId?{sessionId:i.sessionId}:{}}))}catch{}return{ticket:c,from:d,to:f}})}async function np(e,t,n,i){const{assignee:a}=i,c=await e.loadMap(t),d=c.tickets.find(g=>g.id===n);if(!d)throw new Me(`ticket ${n} not found`);rv(c.map);const u=Cs(c.tickets,c.map.mode).get(n);if(u!=="frontier"&&u!=="rework")throw new Me(`${d.key} is ${u}, not on the frontier`);await Ca(e,t,n,{event:"claim",actor:a,actorKind:i.actorKind??"agent",reason:i.reason,sessionId:i.sessionId,journal:i.journal});const m=(await e.loadMap(t)).tickets.find(g=>g.id===n);if(m.assignee!==a)throw new Me(`${d.key} was claimed by ${m.assignee}`);return m}async function y0(e,t,n,i={}){const c=(await e.loadMap(t)).tickets.find(d=>d.id===n);if(!c)throw new Me(`ticket ${n} not found`);await Ca(e,t,n,{event:"release",actor:i.actor??c.assignee??"trail lead",actorKind:i.actorKind??"agent",reason:i.reason,sessionId:i.sessionId,journal:i.journal})}const ov=e=>e==="lookout",w0=e=>e.via==="chat"?`in ${e.chatOf??"an agent"}'s chat`:void 0;function x0(e){return e.via?e.via==="chat"&&e.chatOf?{via:e.via,chatOf:e.chatOf}:{via:e.via}:{}}function av(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 ra(e,t){const n=e.via??(e.sourceKind==="slack"?"slack":void 0);if(!n||ov(n)||!t.ticketId)return;const i=t.key??t.ticketId,a=n==="lookout-limited"?"ask someone allowed to make high-risk calls":"decide it in the Lookout";if(!e.highRisk)throw new Me(`Can't tell whether ${i} is high risk: ${a}.`);if(await e.highRisk(t.mapId,t.ticketId))throw new Me(av(i,n))}async function j0(e,t){var d;const{mapId:n,old:i,next:a}=t;await ra(e,{mapId:n,ticketId:i.ticketId,key:i.ticketKey??i.id}),a.ticketId&&a.ticketId!==i.ticketId&&await ra(e,{mapId:n,ticketId:a.ticketId,key:a.ticketKey});const c=e.via??(e.sourceKind==="slack"?"slack":void 0);if(c&&!ov(c)&&((d=i.risk)==null?void 0:d.level)==="high")throw new Me(av(i.id,c))}async function lu(e,t,n,i={}){if(await ra({...i.guard,sourceKind:n.source.kind},{mapId:t,ticketId:n.ticketId,key:n.ticketKey}),n.source.ref){const c=(await e.listDecisions(t)).find(d=>!d.postedBy&&d.source.kind===n.source.kind&&d.source.ref===n.source.ref);if(c)return c}const a=await e.createDecision(t,n);if(i.appendToTrail??!0){const c=await e.loadMap(t);await e.updateMapSections(t,{decisions:[...c.map.sections.decisions,{ticketId:a.ticketId,ticketKey:a.ticketKey,text:i.trailLine??a.summary}]})}return a}async function b0(e,t,n,{guard:i,...a}){const d=(await e.listDecisions(t)).find(b=>b.id===n);if(!d)throw new Me(`decision ${n} not found`);if(d.postedBy)throw new Me(`${d.id} is ${d.postedBy}'s decision; record your own instead`);if(d.supersededBy)throw new Me(`${d.id} is already superseded by ${d.supersededBy}`);const u={ticketId:d.ticketId,ticketKey:d.ticketKey,...a,question:a.question??d.question,supersedes:d.id};await j0({...i,sourceKind:a.source.kind},{mapId:t,old:d,next:u});const f=await e.createDecision(t,u);await e.markSuperseded(t,d.id,f.id);const g=(await e.loadMap(t)).map.sections.decisions,k=g.findIndex(b=>b.text===d.summary||!!d.ticketId&&b.ticketId===d.ticketId||!!d.ticketKey&&b.ticketKey===d.ticketKey),w={ticketId:f.ticketId,ticketKey:f.ticketKey,text:f.summary};return await e.updateMapSections(t,{decisions:k<0?[...g,w]:g.map((b,S)=>S===k?w:b)}),f}async function S0(e,t,n){await e.setMapMode(t,n)}function cv(e){return e==="plan-only"?na.filter(t=>t!=="execute"):na}function N0(e,t){if(!cv(e).includes(t))throw new Me(`${t} tickets are disabled on plan-only maps`)}const ts={lookout:{label:"Lookout",code:"CMD"},agent:{label:"Agent",code:"AGT"},slack:{label:"Slack",code:"SLK"},tracker:{label:"Tracker",code:"TRK"}},oa=Object.keys(ts),$0=e=>e in ts,lv=" (unverified, from text)";function yr(e){return e.derived||e.decidedBy.endsWith(lv)?"unverified":e.postedBy?"teammate":e.source.kind==="agent"&&e.decidedBy!=="trail lead"&&!e.decidedBy.startsWith("slack:")?"agent":"human"}const dv=e=>e.postedBy?`posted by ${e.postedBy} in ${e.postedIn??"the tracker"}`:void 0,br=e=>e.supersededBy?"superseded":"active";function Ta(e){const t=e.replace(/\s+/g," ").trim(),n=t.match(/^(.{20,180}?[.!?])(\s|$)/);return n?n[1]:t.slice(0,180)}function C0(e,t,n){var i;return{...n,id:e,mapId:t,decidedAt:n.decidedAt??Date.now(),summary:((i=n.summary)==null?void 0:i.trim())||Ta(n.answer),alternatives:n.alternatives??[],rationale:n.rationale??"",participants:n.participants??[{id:n.decidedBy}],transcript:n.transcript??[]}}const T0=e=>Number(e.replace(/\D/g,""))||0;function E0(e,t){const n=new Map(e.map(d=>[d.id,d])),i=new Set;let a=n.get(t);for(;a!=null&&a.supersedes&&n.has(a.supersedes)&&!i.has(a.id);)i.add(a.id),a=n.get(a.supersedes);const c=[];i.clear();for(let d=a;d&&!i.has(d.id);d=d.supersededBy?n.get(d.supersededBy):void 0)i.add(d.id),c.push(d);return c}async function A0(e,t,n,i){var d,u;const c=(await e.loadMap(t)).tickets.find(f=>f.id===n);if(!c)throw new Me(`ticket ${n} not found`);if(c.state==="closed")throw new Me(`${c.key} is already closed`);return await ra({...i.guard,sourceKind:(u=(d=i.decision)==null?void 0:d.source)==null?void 0:u.kind},{mapId:t,ticketId:c.id,key:c.key}),i.transcript&&await e.comment(t,n,i.author,`**HITL transcript**
|
|
68
|
+
|
|
69
|
+
${i.transcript}`),await e.comment(t,n,i.author,`**Resolution**
|
|
70
|
+
|
|
71
|
+
${i.answer}`),await Ca(e,t,n,{event:i.event??"complete",actor:i.actor??i.author,actorKind:i.actorKind??"agent",sessionId:i.sessionId,reason:i.reason,journal:i.journal,...i.event&&i.event!=="complete"?{to:"done"}:{}}),await lu(e,t,R0(c,i),{trailLine:i.trailLine,guard:i.guard}),c}function R0(e,t){var i;const n=t.decision??{};return{ticketId:e.id,ticketKey:e.key,question:n.question??e.title,answer:n.answer??t.answer,summary:n.summary??t.summary??Ta(t.answer),alternatives:n.alternatives,rationale:n.rationale,decidedBy:n.decidedBy??t.author,...n.decidedByName?{decidedByName:n.decidedByName}:{},participants:n.participants,source:n.source??{kind:"agent",label:t.author},transcript:n.transcript,...n.risk?{risk:n.risk}:{},...(i=n.assumes)!=null&&i.length?{assumes:n.assumes}:{}}}async function I0(e,t,n,i){const a=await e.loadMap(t);if(rv(a.map),!a.map.sections.unspecified.includes(n))throw new Me(`"${n}" is not in Not yet specified`);N0(a.map.mode,i.type);const c=await e.createTicket(t,{title:i.title??n,type:i.type,hitl:i.hitl,body:`${i.body??`Promoted from Not yet specified: ${n}`}
|
|
72
|
+
|
|
73
|
+
Part of trail ${a.map.key}.`});for(const u of i.blockedBy??[])await e.addBlocking(t,u,c.id);const d=await e.loadMap(t);return await e.updateMapSections(t,{unspecified:d.map.sections.unspecified.filter(u=>u!==n)}),c}async function M0(e,t,n,i){const a=await e.loadMap(t),{unspecified:c,outOfScope:d}=a.map.sections;if("unspecified"in n){if(!c.includes(n.unspecified))throw new Me(`"${n.unspecified}" is not in Not yet specified`);await e.updateMapSections(t,{unspecified:c.filter(m=>m!==n.unspecified),outOfScope:[...d,`${n.unspecified} — ${i.reason}`]});return}const u=a.tickets.find(m=>m.id===n.ticketId);if(!u)throw new Me(`ticket ${n.ticketId} not found`);await e.comment(t,u.id,i.author,`**Ruled out of scope**
|
|
74
|
+
|
|
75
|
+
${i.reason}`),await Ca(e,t,u.id,{event:"cancel",actor:i.author,actorKind:i.actorKind??"agent",reason:i.reason,sessionId:i.sessionId,journal:i.journal}),await lu(e,t,{ticketId:u.id,ticketKey:u.key,question:u.title,answer:`Out of scope: ${i.reason}`,decidedBy:i.author,source:i.source??{kind:"agent",label:i.author}},{appendToTrail:!1});const f=await e.loadMap(t);await e.updateMapSections(t,{outOfScope:[...f.map.sections.outOfScope,`${u.key} ${u.title} — ${i.reason}`]})}async function O0(e,t,n,i){n&&L0(n),await e.setMapMeta(t,{modelMatching:n&&P0(n),confirm:!0})}function L0(e){if(typeof e.enabled!="boolean")throw new Me('"enabled" must be true or false');for(const[t,n]of Object.entries(e.tiers??{})){if(!is.includes(t))throw new Me(`unknown ticket type "${t}"`);if(!Xg(n))throw new Me(`"${t}" must be fast, balanced or strongest`)}}function P0(e){const t=Object.fromEntries(Object.entries(e.tiers??{}).filter(([,n])=>n));return Object.keys(t).length?{enabled:e.enabled,tiers:t}:{enabled:e.enabled}}async function D0(e,t,n,i){await e.setMapArchived(t,n)}const uv=Object.freeze({research:["architect"],junction:["architect"],prototype:["architect"],task:["qa","security"],execute:["qa","security"],review:["reviewer"]}),_0=(e,t)=>e.guidesByType?"trail":t?"team":"defaults";function du(e){var c;const t=(c=e.guides)!=null&&c.length?new Set(e.guides):void 0,n=e.guidesByType??uv,i=d=>!!e.guidesByType||!t||t.has(d);return{byType:Object.fromEntries(is.map(d=>[d,[...new Set((n[d]??[]).filter(i))]])),source:_0(e,!!t)}}const hv=e=>[...new Set([...e.guide?[e.guide]:[],...e.guidesAdded??[]])];function B0(e,t){const n=new Set(t.guidesRemoved??[]),i=du(e).byType[t.type]??[],a=i.map(c=>({id:c,via:"type"}));for(const c of hv(t))i.includes(c)||a.push({id:c,via:"ticket"});return a.filter(c=>!n.has(c.id))}function F0(e){return{async append(t){await fetch(`${e}/journal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}}}const z0=["off","observe","enforce"],fv=["check-guard","independent-review","diff-rules","flaky"],mv={"check-guard":"enforce","independent-review":"observe","diff-rules":"enforce",flaky:"enforce"},pv={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",gates:{...mv},rules:[],github:{enabled:"auto",requiredChecks:[],pollSec:60}};new Set(Object.keys(pv));function U0(e,t){var n;return e?((n=e.gates)==null?void 0:n[t])??mv[t]:"off"}const W0=e=>e?`on ${e.slice(0,7)}`:"on the same code",H0=e=>`${e.name}${e.test?` (${e.test})`:""} ${e.failure==="timed out"?"timed out":"failed"} in ${e.failedIn}, then passed ${W0(e.head)} with no change`,K0=e=>e.map(H0).join("; "),uu=e=>{var t;return(e==null?void 0:e.result)==="pass"&&((t=e.flaky)==null?void 0:t.mode)==="enforce"},G0=3;function V0(e){const t=e.slice(0,G0).map(i=>i.text),n=e.length-t.length;return`${t.join("; ")}${n>0?`; and ${n} more`:""}`}const q0=2*6e4,ql=e=>e<6e4?`${Math.round(e/1e3)}s`:`${Math.round(e/6e4)}m`;function Q0(e,t){if(!e)return{tone:"unknown",label:"PR sync ?",title:"PR/CI sync state unavailable"};const n=e.repo?` · ${e.repo}`:"",i=e.lastOkAt?`last ok ${ql(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"}${n}
|
|
76
|
+
${i}`}:e.state==="rate-limited"?{tone:"failed",label:"PR sync paused",title:`Rate limited${n}; retrying ${e.nextAt?`in ${ql(Math.max(0,e.nextAt-t))}`:"later"}
|
|
77
|
+
${i}`}:!e.lastOkAt||e.lastOkAt!==e.lastAttemptAt||e.nextAt!==void 0&&t>e.nextAt+q0?{tone:"stale",label:"PR sync stale",title:`No recent sync${n}
|
|
78
|
+
${i}`}:{tone:"ok",label:`PR sync ${ql(t-e.lastOkAt)}`,title:`PR/CI synced${n}, ${i}`}}class di{constructor(){oe(this,"listeners",new Set)}on(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t){for(const n of[...this.listeners])n(t)}}let Y0=0;const Xo=(e="id")=>`${e}_${Date.now().toString(36)}${(Y0++).toString(36)}`,Td=(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)}:{}}),gv=(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 J0(e,t,n){const i=()=>e.find(t.id)??t,a=c=>e.push({source:"session",sessionId:t.id,agent:t.agent,...c});return{id:t.id,get info(){return i()},step(c,d,u){const f=$a[n][c-1];e.patchSession(t.id,{step:c,stepLabel:f,...u?{ticketId:u}:{}}),a({tag:a0(n,c),level:"step",text:d?`${f}: ${d}`:f,ticketId:u??i().ticketId})},log(c,d="info",u){a({level:d,text:c,ticketId:i().ticketId,...u?{kind:u}:{}})},say(c){e.chat({sessionId:t.id,ticketId:i().ticketId,from:"agent",author:t.agent,text:c})},ask(c,d,u){var m;const f={id:Xo("q"),sessionId:t.id,mapId:t.mapId,ticketId:i().ticketId,agent:t.agent,text:c,suggestions:d,at:Date.now(),...u!=null&&u.urgency?{urgency:u.urgency}:{},...(m=u==null?void 0:u.blocks)!=null&&m.length?{blocks:u.blocks}:{}};return e.chat({sessionId:t.id,ticketId:f.ticketId,from:"agent",author:t.agent,text:c,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(c=!0,d,u){e.patchSession(t.id,{status:c?"done":"failed",endedAt:Date.now(),waitingOn:void 0}),e.dropPending(t.id),a({level:c?"ok":"alert",text:d??(c?"Session closed":"Session aborted"),signal:u==null?void 0:u.signal,...u!=null&&u.kind?{kind:u.kind}:{}})},bindMap(c){var u;const d=i().usage;d&&(e.addMapUsage(c,d),(u=e.ledger())==null||u.add(c,d,t.id)),e.patchSession(t.id,{mapId:c})},usage(c){var f;const d=i().mapId;(f=e.ledger())==null||f.add(d,c,t.id),e.addMapUsage(d,c);const u=i().usage;e.patchSession(t.id,{usage:{...Td(u,c),source:c.source??(u==null?void 0:u.source)}})},setUsage(c){var g;const d=i().usage,u=gv(c,d);if(!u.inputTokens&&!u.outputTokens&&!u.costUsd&&!u.cachedInputTokens&&(d==null?void 0:d.source)===c.source&&`${d==null?void 0:d.models}`==`${c.models}`)return;const m=i().mapId;(u.inputTokens>0||u.outputTokens>0||u.costUsd>0)&&((g=e.ledger())==null||g.add(m,u,t.id)),e.addMapUsage(m,u),e.patchSession(t.id,{usage:c})},setModel(c,d){const u=i();u.model===c&&u.tier===d||e.patchSession(t.id,{model:c,tier:d})}}}class X0{constructor(t=400,n){oe(this,"state",{sessions:[],feed:[],chats:[],pending:[],answered:[],usageByMap:{}});oe(this,"changes",new di);oe(this,"resolvers",new Map);oe(this,"remote",new Map);oe(this,"remoteAnswer");oe(this,"host",{find:t=>this.state.sessions.find(n=>n.id===t),patchSession:(t,n)=>this.patchSession(t,n),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(i=>i.sessionId===t).length&&this.set({pending:this.state.pending.filter(i=>i.sessionId!==t)})},awaitAnswer:t=>new Promise(n=>this.resolvers.set(t,n)),addMapUsage:(t,n)=>{this.state={...this.state,usageByMap:{...this.state.usageByMap,[t]:Td(this.state.usageByMap[t],n)}}},ledger:()=>this.ledger});this.maxFeed=t,this.ledger=n}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 n={id:Xo("f"),at:t.at??Date.now(),...t};return n.source==="system"&&!n.agent&&(n.agent=J.assistant.name),this.set({feed:[...this.state.feed,n].slice(-this.maxFeed)}),n}patchSession(t,n){this.set({sessions:this.state.sessions.map(i=>i.id===t?{...i,...n}:i)})}chat(t){this.set({chats:[...this.state.chats,{id:Xo("m"),at:Date.now(),...t}].slice(-600)})}answer(t,n,i,a){var g;const c=this.state.pending.find(k=>k.id===t),d=this.resolvers.get(t),u=!!c&&this.remote.has(c.sessionId)&&!!this.remoteAnswer;if(!c||!d&&!u)return!1;this.resolvers.delete(t);const f=x0(a),m=a.by?{by:a.by}:{};return this.chat({sessionId:c.sessionId,ticketId:c.ticketId,from:"human",author:i,text:n,...f,...m}),this.set({pending:this.state.pending.filter(k=>k.id!==t),answered:[...this.state.answered,{id:c.id,mapId:c.mapId,sessionId:c.sessionId,agent:c.agent,askedAt:c.at,answeredAt:Date.now(),...c.ticketId?{ticketId:c.ticketId}:{},...c.category?{category:c.category}:{},...(g=c.categories)!=null&&g.length?{categories:c.categories}:{},...c.urgency?{urgency:c.urgency}:{},...f,...m}].slice(-200)}),this.patchSession(c.sessionId,{waitingOn:void 0}),this.push({source:"trail lead",agent:i,level:"ok",kind:"answered",ticketId:c.ticketId,sessionId:c.sessionId,text:`Answered ${c.agent}`}),d?d(n):this.remoteAnswer(c,n,i),!0}syncRemote(t){var m;const{session:n}=t,i=n.id;if(!this.remote.has(i)&&this.state.sessions.some(g=>g.id===i))return;const a=this.remote.get(i);this.remote.set(i,n.mapId?n.usage:a);let c=this.state.usageByMap;if(n.usage&&n.mapId){const g=gv(n.usage,a);(g.inputTokens||g.outputTokens||g.costUsd)&&(c={...c,[n.mapId]:Td(c[n.mapId],g)}),(m=this.ledger)==null||m.addTotal(n.mapId,i,n.usage)}const d=g=>g.filter(k=>k.sessionId!==i),u=new Set(this.state.answered.map(g=>g.id)),f=this.state.sessions.some(g=>g.id===i)?this.state.sessions.map(g=>g.id===i?n:g):[...this.state.sessions,n].slice(-24);this.set({sessions:f,chats:[...d(this.state.chats),...t.chats].sort((g,k)=>g.at-k.at).slice(-600),pending:[...d(this.state.pending),...t.pending],answered:[...this.state.answered,...t.answered.filter(g=>!u.has(g.id))].sort((g,k)=>g.answeredAt-k.answeredAt).slice(-200),feed:[...this.state.feed.filter(g=>g.sessionId!==i),...t.feed].sort((g,k)=>g.at-k.at).slice(-this.maxFeed),usageByMap:c})}isRemote(t){return this.remote.has(t)}startSession(t){const n={...t,id:t.id??Xo("s"),step:0,total:$a[t.mode].length,stepLabel:"BOOT",status:"running",startedAt:Date.now()};this.set({sessions:[...this.state.sessions,n].slice(-24)});const i=J0(this.host,n,t.mode);return this.push({source:"session",sessionId:n.id,agent:n.agent,level:"info",text:`Session opened · ${t.mode}`}),i}}function Z0(e,t){const n=i=>{var a;return((a=t(i))==null?void 0:a.key)??i};switch(e.kind){case"map.created":return{source:"tracker",level:"ok",text:`Trail created · label ${iu}`};case"map.updated":return{source:"tracker",level:"info",text:`Trail updated${e.section?` · ${s0[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 ${n(e.ticketId)}`};case"ticket.claimed":return{source:"tracker",level:"warn",ticketId:e.ticketId,text:`Assigned ${n(e.ticketId)} to ${e.assignee}`};case"ticket.released":return{source:"tracker",level:"info",ticketId:e.ticketId,text:`Unassigned ${n(e.ticketId)}`};case"ticket.closed":return{source:"tracker",level:e.reason==="completed"?"ok":"alert",...e.reason==="completed"?{kind:"done"}:{},ticketId:e.ticketId,text:`Closed ${n(e.ticketId)} · ${e.reason==="completed"?"completed":"not planned"}`};case"ticket.commented":return{source:"tracker",level:"info",ticketId:e.ticketId,text:`Comment on ${n(e.ticketId)}`};case"edge.added":return{source:"tracker",level:"info",ticketId:e.blockedId,text:`${n(e.blockerId)} blocks ${n(e.blockedId)}`};case"edge.removed":return{source:"tracker",level:"info",ticketId:e.blockedId,text:`${n(e.blockerId)} no longer blocks ${n(e.blockedId)}`};case"decision.recorded":return{source:"tracker",level:"ok",ticketId:e.ticketId,text:`Decision ${e.decisionId} recorded${e.ticketId?` · ${n(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 eb=new Set(["createMap","setMapMode","setMapArchived","setMapMeta","updateMapSections","createTicket","addBlocking","removeBlocking","editTicket","reopen","assign","comment","close","setMeta","createDecision","markSuperseded"]),tb=5*6e4;function nb(e){let t={status:"idle",inflight:0,writes:0,errors:0,events:[]};const n=new di,i=c=>{t={...t,...c},n.emit(t)};return e.subscribe(c=>{const d=c.at-tb;i({events:[...t.events.filter(u=>u.at>=d),{at:c.at,external:c.kind==="external.changed"||"external"in c&&!!c.external}]})}),{adapter:new Proxy(e,{get(c,d,u){const f=Reflect.get(c,d,u);return typeof f!="function"?f:eb.has(d)?async(...m)=>{const g=Date.now();i({inflight:t.inflight+1,status:"syncing"});try{const k=await f.apply(c,m),w=t.inflight-1;return i({inflight:w,writes:t.writes+1,lastWriteMs:Date.now()-g,lastWriteAt:Date.now(),status:w?"syncing":"ok",lastError:void 0}),k}catch(k){const w=t.inflight-1;throw i({inflight:w,errors:t.errors+1,status:"error",lastError:String(k.message??k)}),k}}:f.bind(c)}}),get health(){return t},subscribe:c=>n.on(c)}}function vv(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 n of Cs(e.tickets,e.map.mode).values())t[n]++;return t.resolvedPct=t.total?Math.round((t.decided+t["out-of-scope"])/t.total*100):0,t}function sb(e){const t=vv(e);return{decided:t.decided,total:t.total-t["out-of-scope"]}}function ib(e){const t=new Map(e.tickets.filter(d=>d.state==="open").map(d=>[d.id,d])),n=new Map,i=new Set,a=d=>{if(n.has(d))return n.get(d);if(i.has(d))return[];i.add(d);const u=t.get(d);let f=[];for(const g of u.blockedBy)if(t.has(g)){const k=a(g);k.length>f.length&&(f=k)}i.delete(d);const m=[...f,u];return n.set(d,m),m};let c=[];for(const d of t.keys()){const u=a(d);u.length>c.length&&(c=u)}return c}function rb(e){return na.map(t=>{const n=e.tickets.filter(i=>i.type===t);return{type:t,open:n.filter(i=>i.state==="open").length,closed:n.filter(i=>i.state==="closed").length}}).filter(t=>t.open+t.closed>0)}function ob(e,t){const n=e.pending.filter(a=>!0),i=e.answered.filter(a=>!0);return{open:n.length,oldestAt:n.length?Math.min(...n.map(a=>a.at)):void 0,answered:i.length,avgWaitMs:i.length?i.reduce((a,c)=>a+(c.answeredAt-c.askedAt),0)/i.length:void 0}}function kv(e,t){return t&&e.usageByMap[t]||{inputTokens:0,outputTokens:0,costUsd:0}}const ab=e=>e.usage?e.usage.inputTokens+e.usage.outputTokens:0,yv={"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 wv(e,t){var i;const n=new Set;for(const a of e.sessions)t&&a.mapId===t&&((i=a.usage)!=null&&i.source)&&n.add(a.usage.source);return[...n].sort()}const Ql=e=>e===1?"1 ticket":`${e} tickets`,cb=e=>e.charAt(0).toLowerCase()+e.slice(1);function sp(e){return e.kind==="passed"?`verified together on ${e.branch??"main"} at ${e.commit.slice(0,7)}`:cb(e.reason)}function lb(e){const t=e.tickets.filter(f=>!(f.state==="closed"&&f.closeReason==="not_planned")),n=t.filter(f=>f.state==="open").length;if(n)return{kind:"not-done",reason:`${Ql(n)} still open`};if(!t.length)return{kind:"not-done",reason:"No tickets in scope"};if(e.pendingReroutes)return{kind:"not-done",reason:"A reroute waits for your review"};const i=t.length,{together:a}=e,c=t.filter(f=>e.proofs[f.id]!=="verified").map(f=>f.id);if(!c.length&&a.kind==="passed")return{kind:"verified",done:i,together:a,reason:`All ${Ql(i)} verified · ${sp(a)}`};const d=c.length===i?"none verified":`${c.length} not verified`,u=[`${Ql(i)} done`,...c.length?[d]:[],sp(a)];return{kind:"unverified",done:i,unverified:c,together:a,reason:u.join(" · ")}}function db(e,t){return e.replace(/^\*\*HITL transcript\*\*\s*/,"").split(/\n\n(?=\*\*[^*]+:\*\* )/).map(n=>n.match(/^\*\*([^*]+):\*\* ([\s\S]*)$/)).filter(n=>!!n).map(n=>({from:"agent",author:n[1],text:n[2].trim(),at:t}))}function ub(e,t){const n=new Set(t.map(a=>a.ticketId).filter(Boolean)),i=e.tickets.filter(a=>a.state==="closed"&&a.closeReason==="completed"&&!n.has(a.id)).map(a=>{var g;const c=[...a.comments].reverse().find(k=>k.body.startsWith("**Resolution**")),d=c?c.body.replace(/^\*\*Resolution\*\*\s*/,""):((g=e.map.sections.decisions.find(k=>k.ticketId===a.id||k.ticketKey===a.key))==null?void 0:g.text)??"",u=(c==null?void 0:c.author)??a.assignee??"unknown",f=a.comments.find(k=>k.body.startsWith("**HITL transcript**")),m=f?db(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:Ta(d),alternatives:[],rationale:"",decidedBy:`${u}${lv}`,decidedAt:a.closedAt??(c==null?void 0:c.createdAt)??a.updatedAt,participants:[...new Set([u,...m.map(k=>k.author)])].map(k=>({id:k})),source:{kind:"tracker",ref:`${e.map.id}/tickets/${a.id}`,label:`unverified, from text: ${c?`${a.key} resolution comment`:"the map’s Decisions so far"}`},transcript:m,derived:!0}});return[...t,...i].sort((a,c)=>c.decidedAt-a.decidedAt)}function hb(e,t){var i;const n=(i=t.query)==null?void 0:i.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||yr(a)===t.madeBy)&&(!t.status||br(a)===t.status)&&(!n||[a.id,a.ticketKey,a.question,a.answer,a.summary,a.rationale,a.decidedBy,...a.alternatives,...a.transcript.map(c=>c.text)].join(`
|
|
79
|
+
`).toLowerCase().includes(n)))}function fb(e,t=Date.now()){const n=Object.fromEntries(oa.map(d=>[d,0]));let i=0,a=0,c=0;for(const d of e){n[d.source.kind]++,d.supersededBy&&i++,t-d.decidedAt<864e5&&a++;const u=yr(d);(u==="human"||u==="agent"&&d.transcript.some(f=>f.from==="human"))&&c++}return{total:e.length,active:e.length-i,superseded:i,last24h:a,human:c,bySource:n}}function Ea(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!t)return{front:{},body:e};const n={};for(const i of t[1].split(`
|
|
80
|
+
`)){const a=i.indexOf(":");if(a<0)continue;const c=i.slice(0,a).trim(),d=i.slice(a+1).trim();Tj(c)&&(n[c]=d.startsWith("[")?gb(d.slice(1,-1)).map(rp).filter(Boolean):rp(d))}return{front:n,body:t[2]}}const mb=e=>e===""||/^[\s#&*!|>'"%@`[\]{},?:-]|[:#]\s|\s$|,|["\\[\]]/.test(e)||Gj(e)||/^(true|false|null|~|\d[\d.e+-]*)$/i.test(e),pb=e=>JSON.stringify(e).replace(/[\u007f\u0085\u2028\u2029]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),ip=e=>mb(e)?pb(e):e;function rp(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 gb(e){const t=[];let n="",i=!1,a=!1;for(const c of e)c==='"'&&!a&&(i=!i),a=i&&c==="\\"&&!a,c===","&&!i?(t.push(n.trim()),n=""):n+=c;return n.trim()&&t.push(n.trim()),t}function vb(e){if(!/^[\w-]+$/.test(e))throw new Error(`invalid frontmatter key: ${JSON.stringify(e)}`);return e}function hu(e,t){return`---
|
|
81
|
+
${Object.entries(e).map(([i,a])=>`${vb(i)}: ${Array.isArray(a)?`[${a.map(ip).join(", ")}]`:ip(a)}`).join(`
|
|
82
|
+
`)}
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
${t.trim()}
|
|
86
|
+
`}const ke=e=>Array.isArray(e)?e.join(","):e??"";function mt(e){return Array.isArray(e)?e:e?[e]:[]}const ai=e=>Date.parse(ke(e))||0,fn=e=>new Date(e).toISOString(),xv=["schema","breaking-api","auth-permissions","billing","data-deletion","product-behaviour","dependencies"],jv=["low","medium","high"],kb=e=>xv.includes(e),yb=e=>jv.includes(e);function wb(e){return e?{risk:e.level,...e.category?{risk_category:e.category}:{},risk_reason:e.reason}:{}}function xb(e){const t=ke(e.risk);if(!yb(t))return{};const n=ke(e.risk_category);return{risk:{level:t,...kb(n)?{category:n}:{},reason:ke(e.risk_reason)}}}const bv=["Question","Decision","Summary","Alternatives","Rationale","Transcript"],fu=`## (?:${bv.join("|")})\\s*$`,Sv=`${fu}|### `,zo=e=>Sa(e.trim(),fu),jb=e=>e.name?`${e.id}|${e.name}`:e.id,bb=e=>{const t=e.indexOf("|");return t<0?{id:e}:{id:e.slice(0,t),name:e.slice(t+1)}};function Nv(e){var c;const t={id:e.id,trail:e.mapId,...e.ticketId?{ticket:e.ticketId,ticket_key:e.ticketKey??""}:{},decided_by:e.decidedBy,...e.decidedByName?{decided_by_name:xs(e.decidedByName).slice(0,100)}:{},decided_at:fn(e.decidedAt),participants:e.participants.map(jb),source:e.source.kind,...e.source.ref?{source_ref:e.source.ref}:{},...e.source.url?{source_url:e.source.url}:{},...e.source.label?{source_label:e.source.label}:{},...e.source.meta?{source_meta:Object.entries(e.source.meta).map(([d,u])=>`${d}=${u}`)}:{},...e.supersedes?{supersedes:e.supersedes}:{},...e.supersededBy?{superseded_by:e.supersededBy}:{},...wb(e.risk),...(c=e.assumes)!=null&&c.length?{assumes:e.assumes}:{}},n=d=>d.length?d.map(u=>`- ${xs(u)}`).join(`
|
|
87
|
+
`):"_None._",i=e.transcript.length?e.transcript.map(d=>`### ${xs(d.author)} · ${d.from} @ ${fn(d.at)}
|
|
88
|
+
|
|
89
|
+
${Sa(d.text.trim(),Sv)}`).join(`
|
|
90
|
+
|
|
91
|
+
`):"_None._",a=[`## Question
|
|
92
|
+
|
|
93
|
+
${zo(e.question)}`,`## Decision
|
|
94
|
+
|
|
95
|
+
${zo(e.answer)}`,`## Summary
|
|
96
|
+
|
|
97
|
+
${zo(e.summary)}`,`## Alternatives
|
|
98
|
+
|
|
99
|
+
${n(e.alternatives)}`,`## Rationale
|
|
100
|
+
|
|
101
|
+
${zo(e.rationale)||"_None._"}`,`## Transcript
|
|
102
|
+
|
|
103
|
+
${i}`].join(`
|
|
104
|
+
|
|
105
|
+
`);return hu(t,a)}function Ed(e){const{front:t,body:n}=Ea(e),i={},a=new RegExp(`^## (${bv.join("|")})\\s*$`,"gm"),c=[...n.matchAll(a)];c.forEach((k,w)=>{var C;const b=n.slice(k.index+k[0].length,((C=c[w+1])==null?void 0:C.index)??n.length).trim(),S=k[1],x=S==="Transcript"?b:ia(b,fu);i[S]=/^_none\._$/i.test(b)?"":x});const d=(i.Transcript??"").split(/^### /m).slice(1).map(k=>{const w=k.indexOf(`
|
|
106
|
+
`),b=w<0?k:k.slice(0,w),S=b.lastIndexOf(" @ "),x=S<0?b:b.slice(0,S),C=S<0?"":b.slice(S+3),N=x.lastIndexOf(" · "),P=N<0?x:x.slice(0,N),D=N<0?"agent":x.slice(N+3);return{author:P.trim(),from:["agent","human","system"].includes(D.trim())?D.trim():"agent",at:Date.parse(C)||0,text:w<0?"":ia(k.slice(w+1).trim(),Sv)}}),u=ke(t.source),f=mt(t.source_meta),m={kind:$0(u)?u:"tracker",...ke(t.source_ref)?{ref:ke(t.source_ref)}:{},...ke(t.source_url)?{url:ke(t.source_url)}:{},...ke(t.source_label)?{label:ke(t.source_label)}:{},...f.length?{meta:Object.fromEntries(f.map(k=>[k.slice(0,k.indexOf("=")),k.slice(k.indexOf("=")+1)]))}:{}},g=i.Decision??"";return{id:ke(t.id),mapId:ke(t.trail),ticketId:ke(t.ticket)||void 0,ticketKey:ke(t.ticket_key)||void 0,question:i.Question??"",answer:g,summary:i.Summary||Ta(g),alternatives:(i.Alternatives??"").split(`
|
|
107
|
+
`).map(k=>k.trim()).filter(k=>k.startsWith("- ")).map(k=>k.slice(2)),rationale:i.Rationale??"",decidedBy:ke(t.decided_by),...ke(t.decided_by_name)?{decidedByName:ke(t.decided_by_name)}:{},decidedAt:ai(t.decided_at),participants:mt(t.participants).map(bb),source:m,supersedes:ke(t.supersedes)||void 0,supersededBy:ke(t.superseded_by)||void 0,...mt(t.assumes).length?{assumes:mt(t.assumes)}:{},transcript:d,...xb(t)}}function Sb(e){return e.url?` · [${e.label??"link"}](${e.url})`:e.label?` · ${e.label}`:""}function Nb(e,t,n={}){const i=[`# ${n.title??"Decisions"}`,"",`Exported ${fn(n.now??Date.now())} · ${e.length} decisions`],a=new Map;for(const c of e)a.set(c.mapId,[...a.get(c.mapId)??[],c]);for(const[c,d]of a){const u=t[c];i.push("",`## Trail ${u?`${u.key} ${u.title}`:c}`);for(const f of d){const m=ts[f.source.kind].label;i.push("",`### ${f.id}${f.ticketKey?` · ${f.ticketKey}`:""} · ${f.question}`,"",`- **Status:** ${br(f)}${f.supersededBy?` (superseded by ${f.supersededBy})`:""}${f.supersedes?` · supersedes ${f.supersedes}`:""}`,`- **Decided by:** ${f.decidedBy} · ${fn(f.decidedAt)}`,`- **Source:** ${m}${Sb(f.source)}`,...f.participants.length?[`- **Participants:** ${f.participants.map(g=>g.name??g.id).join(", ")}`]:[],"",`**Decision:** ${f.answer}`,...f.alternatives.length?["","**Alternatives:**",...f.alternatives.map(g=>`- ${g}`)]:[],...f.rationale?["",`**Rationale:** ${f.rationale}`]:[],...f.transcript.length?["","<details><summary>Transcript</summary>","",...f.transcript.map(g=>`> **${g.author}:** ${g.text.replace(/\n/g,`
|
|
108
|
+
> `)}
|
|
109
|
+
>`),"","</details>"]:[])}}return i.join(`
|
|
110
|
+
`)+`
|
|
111
|
+
`}function Ad(e,t,n){try{const i=e.get(t);return i?JSON.parse(i):n}catch{return n}}class op{constructor(t,n="presence"){oe(this,"seen");this.store=t,this.key=n,this.seen=Ad(t,n,{})}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,n=Date.now()){let i=!1;for(const a of t)(this.seen[a]??0)>=n||(this.seen[a]=n,i=!0);i&&this.store.set(this.key,JSON.stringify(this.seen))}}const Yl=5*6e4,$b=14*864e5;class ap{constructor(t,n="usage"){oe(this,"buckets");oe(this,"dirty",!1);oe(this,"timer");oe(this,"totals");this.store=t,this.key=n,this.buckets=Ad(t,n,{}),this.totals=Ad(t,`${n}.totals`,{})}addTotal(t,n,i,a=Date.now()){const c=this.totals[n],d={inputTokens:i.inputTokens-((c==null?void 0:c.inputTokens)??0),outputTokens:i.outputTokens-((c==null?void 0:c.outputTokens)??0),costUsd:i.costUsd-((c==null?void 0:c.costUsd)??0)};this.totals[n]={...i,at:a},d.inputTokens>0||d.outputTokens>0||d.costUsd>0?this.add(t,d,n,a):this.save()}add(t,n,i,a=Date.now()){var f;if(!t)return;const c=Math.floor(a/Yl)*Yl,d=(f=this.buckets)[t]??(f[t]=[]);let u=d.find(m=>m.at===c);u||(u={at:c,i:0,o:0,c:0,s:[]},d.push(u),d.sort((m,g)=>m.at-g.at)),u.i+=n.inputTokens,u.o+=n.outputTokens,u.c+=n.costUsd,u.s.includes(i)||u.s.push(i),this.save()}since(t,n){const i={inputTokens:0,outputTokens:0,costUsd:0,sessions:0},a=new Set;for(const c of this.buckets[t]??[])c.at+Yl<=n||(i.inputTokens+=c.i,i.outputTokens+=c.o,i.costUsd+=c.c,c.s.forEach(d=>a.add(d)));return i.sessions=a.size,i}save(){this.dirty=!0,!this.timer&&(this.timer=setTimeout(()=>{if(this.timer=void 0,!this.dirty)return;this.dirty=!1;const t=Date.now()-$b;for(const n of Object.keys(this.buckets))this.buckets[n]=this.buckets[n].filter(i=>i.at>=t);for(const[n,i]of Object.entries(this.totals))i.at<t&&delete this.totals[n];this.store.set(this.key,JSON.stringify(this.buckets)),this.store.set(`${this.key}.totals`,JSON.stringify(this.totals))},2e3))}}function Cb(e){const t=e.now??Date.now(),n=e.snaps.map(d=>{var re;const u=d.map.id,f=e.since(u),m=q=>!!q&&q>=f,g=Cs(d.tickets,d.map.mode),k=new Map(d.tickets.map(q=>[q.id,q])),w=(e.attention??[]).filter(q=>q.mapId===u),b=Tb(e.activity.pending.filter(q=>q.mapId===u),w),S=new Set(b.map(q=>q.ticketId)),x=q=>q.state==="open"&&(S.has(q.id)||pi(q)==="hitl"),C=d.tickets.filter(q=>g.get(q.id)==="blocked").map(q=>({ticket:q,on:q.blockedBy.map(Z=>k.get(Z)).filter(Z=>!!Z&&x(Z))})).filter(q=>q.on.length),N=e.decisions.filter(q=>q.mapId===u&&m(q.decidedAt)).sort((q,Z)=>Z.decidedAt-q.decidedAt),P=d.tickets.filter(q=>q.state==="closed"&&m(q.closedAt)).sort((q,Z)=>(q.closedAt??0)-(Z.closedAt??0)),D=P.filter(q=>q.closeReason==="completed"),M=P.filter(q=>q.closeReason==="not_planned"),H=d.tickets.filter(q=>m(q.createdAt)),_=((re=e.ledger)==null?void 0:re.since(u,f))??{inputTokens:0,outputTokens:0,costUsd:0,sessions:0},Y=e.activity.sessions.filter(q=>q.mapId===u&&q.status==="running");return{mapId:u,key:d.map.key,title:d.map.title,since:f,done:D,ruledOut:M,opened:H,blocked:C,waiting:b,needsYou:w,decisions:N,agentDecisions:N.filter(q=>yr(q)==="agent"),usage:_,active:Y,changed:!!(P.length||H.length||N.length||b.some(q=>m(q.at))||_.costUsd>0)}}),i=n.filter(d=>d.changed||d.waiting.length).sort((d,u)=>+(u.mapId===e.currentMapId)-+(d.mapId===e.currentMapId)),a=d=>i.reduce((u,f)=>u+f[d].length,0),c=i.flatMap(d=>d.waiting).reduce((d,u)=>d===void 0||u.at<d?u.at:d,void 0);return{since:i.length?Math.min(...i.map(d=>d.since)):t,now:t,trails:i,totals:{done:a("done"),ruledOut:a("ruledOut"),blocked:a("blocked"),waiting:a("waiting"),oldestWaitMs:c===void 0?void 0:t-c,agentDecisions:a("agentDecisions"),usage:i.reduce((d,u)=>({inputTokens:d.inputTokens+u.usage.inputTokens,outputTokens:d.outputTokens+u.usage.outputTokens,costUsd:d.costUsd+u.usage.costUsd,sessions:d.sessions+u.usage.sessions}),{inputTokens:0,outputTokens:0,costUsd:0,sessions:0}),active:a("active")},changed:n.some(d=>d.changed)}}function Tb(e,t){const n=new Map(t.filter(a=>a.kind==="question").map((a,c)=>[a.ref,c])),i=a=>n.get(a.id)??Number.MAX_SAFE_INTEGER;return[...e].sort((a,c)=>i(a)-i(c)||a.at-c.at)}const fr=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function Eb(e){return e.trails.flatMap(t=>{const n=new Set(t.waiting.map(i=>i.ticketId));return t.blocked.filter(i=>i.on.some(a=>n.has(a.id)))})}function Ab(e){return e.length===1?`, and it holds up ${e[0].ticket.title.replace(/^./,t=>t.toLowerCase())}`:e.length>1?`, holding up ${fr(e.length,"ticket")}`:""}function Rb(e,t=new Date(e.now).getHours()){const n=e.totals,a=e.now-e.since>=6*36e5&&t>=5&&t<12?"Good morning.":"Welcome back.",c=[];if(n.done&&c.push(`${fr(n.done,"ticket")} ${n.done===1?"is":"are"} done.`),n.agentDecisions&&c.push(`Agents made ${fr(n.agentDecisions,"decision")}.`),n.waiting){const d=Ab(Eb(e));c.push(`${fr(n.waiting,"decision")} ${n.waiting===1?"is":"are"} waiting on you${d}.`)}else c.push("Nothing is waiting on you.");return!n.done&&!n.agentDecisions&&n.ruledOut&&c.unshift(`${fr(n.ruledOut,"ticket")} ruled out of scope.`),[a,...c].join(" ")}const Ib=e=>{if(!e.length)return;const t=[...e].sort((i,a)=>i-a),n=Math.floor(t.length/2);return t.length%2?t[n]:Math.round((t[n-1]+t[n])/2)};function Mb(e){return e.state==="open"?"open":e.closeReason==="not_planned"?"cancelled":"done"}function $v({snap:e,journal:t,answered:n,usage:i}){const a=e.map.id,c=t.filter(x=>x.mapId===a).sort((x,C)=>x.at-C.at),d=new Map;for(const x of c)d.set(x.ticketId,[...d.get(x.ticketId)??[],x]);const u=e.tickets.filter(x=>x.type!=="review").map(x=>{var M;const C=d.get(x.id)??[],N=Mb(x),P=(M=C.find(H=>H.event==="claim"))==null?void 0:M.at,D=N==="done"?x.closedAt:void 0;return{id:x.id,key:x.key,title:x.title,type:x.type,outcome:N,claimedAt:P,doneAt:D,leadMs:D&&P&&D>=P?D-P:void 0,reworks:C.filter(H=>H.to==="rework").length,reviews:{passed:C.filter(H=>H.event==="review.pass").length,failed:C.filter(H=>H.event==="review.fail").length,needsHuman:C.filter(H=>H.event==="review.needs_human").length},operatorActions:C.filter(H=>H.actorKind==="trail lead").length}}),f=u.filter(x=>x.outcome==="done"),m=Math.max(0,...f.map(x=>x.doneAt??0)),g=c.filter(x=>x.actorKind==="trail lead"),k=new Set(n.filter(x=>x.mapId===a).map(x=>x.id)).size,w=g.length,b=x=>u.reduce((C,N)=>C+x(N),0),S=(i==null?void 0:i.costUsd)??0;return{mapId:a,tickets:u,done:f.length,cancelled:u.filter(x=>x.outcome==="cancelled").length,open:u.filter(x=>x.outcome==="open").length,trailLeadMs:m&&m>=e.map.createdAt?m-e.map.createdAt:void 0,medianLeadMs:Ib(f.flatMap(x=>x.leadMs===void 0?[]:[x.leadMs])),interventions:{answers:k,operatorActions:w,reworkRequested:g.filter(x=>x.event==="reject").length,total:k+w},rework:{tickets:u.filter(x=>x.reworks>0).length,cycles:b(x=>x.reworks)},reviews:{passed:b(x=>x.reviews.passed),failed:b(x=>x.reviews.failed),needsHuman:b(x=>x.reviews.needsHuman)},spend:{costUsd:Math.round(S*1e4)/1e4,tokens:((i==null?void 0:i.inputTokens)??0)+((i==null?void 0:i.outputTokens)??0),perVerifiedTicketUsd:f.length&&S?Math.round(S/f.length*1e4)/1e4:void 0}}}const Jl=e=>e.split("-")[0];function tn(e){if(e===void 0)return"—";const t=Math.round(e/6e4);if(t<90)return`${t} min`;const n=e/36e5;return n<48?`${Math.round(n*10)/10} h`:`${Math.round(n/24*10)/10} d`}const cp=e=>e===void 0?"—":`$${e.toFixed(e<1?4:2)}`;function Ob(e,t,n=Date.now()){const i=e.interventions;return[`# Trail report: ${t}`,"",`_Generated ${new Date(n).toISOString()} by Teamtrail._`,"","| Measure | Value |","| --- | --- |",`| Tickets done / cancelled / open | ${e.done} / ${e.cancelled} / ${e.open} |`,`| Trail lead time (created → last done) | ${tn(e.trailLeadMs)} |`,`| Median ticket lead time (claim → done) | ${tn(e.medianLeadMs)} |`,`| Human interventions | ${i.total} (${i.answers} answers, ${i.operatorActions} operator actions, ${i.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 | ${cp(e.spend.costUsd)} · ${e.spend.tokens.toLocaleString("en-US")} tokens |`,`| Cost per verified ticket | ${cp(e.spend.perVerifiedTicketUsd)} |`,"","## Tickets","","| Ticket | Type | Outcome | Lead time | Rework | Reviews (pass/fail) | Operator actions |","| --- | --- | --- | --- | --- | --- | --- |",...e.tickets.map(c=>`| ${c.key} ${c.title.replace(/\|/g,"\\|")} | ${c.type} | ${c.outcome} | ${tn(c.leadMs)} | ${c.reworks} | ${c.reviews.passed}/${c.reviews.failed} | ${c.operatorActions} |`),""].join(`
|
|
112
|
+
`)}const mu=5,Cv=1.5,Lb=15,Uo=e=>Math.round(e*100);function Pb(e){const t=e.filter(d=>d.findings.raised>=mu).sort((d,u)=>u.findings.upheld/u.findings.raised-d.findings.upheld/d.findings.raised||d.key.localeCompare(u.key));if(t.length<2)return[];const[n,i]=[t[0],t[t.length-1]],[a,c]=[n.findings.upheld/n.findings.raised,i.findings.upheld/i.findings.raised];return Uo(a)-Uo(c)<Lb?[]:[{id:"review-findings",text:`${n.key} review findings upheld ${Uo(a)}% vs ${i.key} ${Uo(c)}%`,because:`${n.findings.upheld} of ${n.findings.raised} and ${i.findings.upheld} of ${i.findings.raised} failed reviews stood; a finding is overruled when you accept the work anyway`}]}function Db(e){const t=c=>c.reworkCycles/c.tickets,n=e.filter(c=>c.tickets>=mu).sort((c,d)=>t(c)-t(d)||c.key.localeCompare(d.key));if(n.length<2)return[];const[i,a]=[n[0],n[n.length-1]];return t(a)-t(i)<.2||t(a)<t(i)*Cv?[]:[{id:"rework",text:`${a.key} work goes back to rework more: ${t(a).toFixed(1)} times per ticket vs ${i.key} ${t(i).toFixed(1)}`,because:`${a.reworkCycles} cycles on ${a.tickets} tickets, and ${i.reworkCycles} on ${i.tickets}`}]}function _b(e,t){const n=d=>d.medianLeadMs??0,i=t.filter(d=>d.done>=mu&&d.medianLeadMs!==void 0).sort((d,u)=>n(d)-n(u)||d.key.localeCompare(u.key));if(i.length<2)return[];const[a,c]=[i[0],i[i.length-1]];return n(c)<n(a)*Cv?[]:[{id:`speed-${e}`,text:`${e} tickets: ${a.key} is faster, ${tn(a.medianLeadMs)} vs ${c.key} ${tn(c.medianLeadMs)}`,because:`Median first claim to done, over ${a.done} and ${c.done} done tickets`}]}function Bb(e){const t=Object.keys(e.byTypeAndVendor).sort();return[...Pb(e.byVendor),...Db(e.byVendor),...t.flatMap(n=>_b(n,e.byTypeAndVendor[n]))]}const Fb=e=>{if(!e.length)return;const t=[...e].sort((i,a)=>i-a),n=Math.floor(t.length/2);return t.length%2?t[n]:Math.round((t[n-1]+t[n])/2)},Tv=e=>{var t;return(t=e.filter(n=>n.event==="claim"&&n.actorKind==="agent").at(-1))==null?void 0:t.actor},Rd=(e,t,n)=>e.filter(i=>i.mapId===t&&i.ticketId===n).sort((i,a)=>i.at-a.at);function zb(e,t){return e.tickets.flatMap(n=>{var k;if(n.type!=="review"||!n.reviewOf)return[];const i=Rd(t,e.map.id,n.id),a=Tv(i);if(!a)return[];const c=((k=i.filter(w=>w.event==="claim").at(-1))==null?void 0:k.at)??0,d=Rd(t,e.map.id,n.reviewOf),u=d.findIndex(w=>w.at>=c&&w.event.startsWith("review."));if(u<0||d[u].event!=="review.fail")return[];const f=d.slice(u+1),m=f.findIndex(w=>w.event.startsWith("review.")),g=m<0?f:f.slice(0,m);return[{reviewer:a,upheld:!g.some(w=>w.event==="accept"&&w.actorKind==="trail lead")}]})}function Ub(e,t){var i;const n=(i=e.tickets.find(a=>a.id===t))==null?void 0:i.assignee;return n&&/^[a-z]+-\d+$/.test(n)?n:void 0}function Ev(e,t){const n=a=>t.reduce((c,{ticket:d})=>c+a(d),0),i=a=>t.filter(c=>c.ticket.outcome===a).length;return{key:e,tickets:t.length,done:i("done"),cancelled:i("cancelled"),open:i("open"),medianLeadMs:Fb(t.flatMap(({ticket:a})=>a.leadMs===void 0?[]:[a.leadMs])),reworkCycles:n(a=>a.reworks),reviews:{passed:n(a=>a.reviews.passed),failed:n(a=>a.reviews.failed),needsHuman:n(a=>a.reviews.needsHuman)},answers:0,findings:{raised:0,upheld:0}}}function Wo(e,t){const n=new Map;for(const i of e){const a=t(i);a&&n.set(a,[...n.get(a)??[],i])}return new Map([...n].map(([i,a])=>[i,Ev(i,a)]))}const Id=(e,t)=>{const n=e.get(t)??Ev(t,[]);return e.set(t,n),n};function lp(e,t,n){const i=Id(e,t);i.findings.raised+=1,n&&(i.findings.upheld+=1)}const Ho=e=>[...e.values()].sort((t,n)=>n.tickets-t.tickets||t.key.localeCompare(n.key));function Av(e){const t=e.flatMap(({snap:m,journal:g,answered:k,usage:w})=>$v({snap:m,journal:g,answered:k,usage:w}).tickets.map(b=>({ticket:b,agent:Tv(Rd(g,m.map.id,b.id))??Ub(m,b.id)}))),n=m=>m.agent?Jl(m.agent):void 0,i=Wo(t,m=>m.agent),a=Wo(t,n),c=Wo(t,m=>m.ticket.type),d=new Set;for(const{snap:m,journal:g,answered:k}of e){for(const w of k){const b=`${w.mapId}/${w.id}`;w.mapId!==m.map.id||d.has(b)||(d.add(b),Id(i,w.agent).answers+=1,Id(a,Jl(w.agent)).answers+=1)}for(const w of zb(m,g))lp(i,w.reviewer,w.upheld),lp(a,Jl(w.reviewer),w.upheld)}const u=Object.fromEntries([...c.keys()].map(m=>[m,Ho(Wo(t.filter(g=>g.ticket.type===m),n))])),f={trails:e.length,tickets:t.length,byAgent:Ho(i),byVendor:Ho(a),byType:Ho(c),byTypeAndVendor:u};return{...f,recommendations:Bb(f)}}const Rv=["research","junction","review"],Wb={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
|
+
`)},Hb=[["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"]],lr=Object.fromEntries(Hb);function Kb(e,t){const n=new Set(e.map(i=>i.source).filter(Boolean));return t.filter(i=>!n.has(i))}const Gb=["architecture","convention","gotcha","dead-end","glossary","fact"],Iv=["business-rule","product-decision","persona","ux-principle","pricing"],Vb=[...Gb,...Iv],qb=e=>e.status==="confirmed"||e.status==="assumption";function Qb(e,t){return Zg(e,t.replace(/^\.\//,""),{segments:!0})}const Yb={"business-rule":3,convention:3,"product-decision":2,architecture:2,gotcha:2,"dead-end":2,"ux-principle":2},Jb=["business-rule","ux-principle","convention"],dp=600,Xb=e=>`flagged as possibly outdated by ${e}; the human is reviewing it`,Zb=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(" ")),up=e=>new Set((e.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(t=>!Zb.has(t)));function Mv(e,t,n=4e3,i=()=>[]){const a=t.ticket?up(`${t.ticket.title} ${t.ticket.body}`):new Set,c=new Set((t.tags??[]).map(m=>m.toLowerCase())),d=e.filter(qb).map(m=>{const g=[];let k=Yb[m.kind]??1;for(const S of m.scope){const x=t.paths.find(C=>Qb(S,C));if(x){k+=6,g.push(`path match ${S} (${x})`);break}}const w=m.tags.filter(S=>c.has(S.toLowerCase())||a.has(S.toLowerCase()));w.length&&(k+=3*w.length,g.push(`tag ${w.join(", ")}`));const b=[...up(m.title)].filter(S=>a.has(S));return b.length&&(k+=b.length,g.push(`mentions ${b.slice(0,3).join(", ")}`)),t.trailKey&&m.sources.includes(`trail:${t.trailKey}`)&&(k+=3,g.push("same trail")),t.discovery&&Iv.includes(m.kind)&&(k+=8,g.push("product context for discovery")),!g.length&&Jb.includes(m.kind)&&!m.scope.length&&g.push(`${m.kind.replace("-"," ")} for the whole project`),{e:m,score:k,why:g}}).filter(m=>m.why.length>0).sort((m,g)=>g.score-m.score||m.e.id.localeCompare(g.e.id,void 0,{numeric:!0})),u=[];let f=0;for(const{e:m,why:g}of d){const k=m.body.length>dp?`${m.body.slice(0,dp)}…`:m.body;if(f+k.length>n&&u.length)break;f+=k.length;const w=i(m);u.push({id:m.id,title:m.title,kind:m.kind,status:m.status,body:k,why:g,...w.length?{mayBeOutdated:w}:{},...m.flag?{flagged:Xb(m.flag.by)}:{}})}return u}const eS=new RegExp("`([^`\\s]+/[^`\\s]+)`|(?:^|[\\s(])/?((?:[\\w.-]+/)+[\\w.-]+)","gm");function Ov(e){const t=new Set;for(const n of e.matchAll(eS))t.add((n[1]??n[2]).replace(/^\.?\//,"").replace(/[.,;:]+$/,""));return[...t]}const tS=[{level:"high",label:"High risk"},{level:"medium",label:"Medium risk"},{level:"low",label:"Low risk"},{level:"none",label:"No category"}];function nS(e){return tS.map(t=>({...t,decisions:e.filter(n=>{var i;return(((i=n.risk)==null?void 0:i.level)??"none")===t.level})})).filter(t=>t.decisions.length)}const sS=1/3;function Ts(e,t=Date.now()){const n=e.expiresAt-t;return n<=0?"expired":n<=e.ttlMs*sS?"stalled":"live"}function iS(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 rS=e=>e.urgency==="fyi"||e.kind==="policy"||e.kind==="escape";function oS(e){const t=e.filter(([n,i])=>is.includes(n)&&Xg(i));return Object.fromEntries(t)}const hp=e=>Number(e.slice(0,2))*60+Number(e.slice(3,5));function aS(e,t){const n=new Date(t),i=n.getHours()*60+n.getMinutes(),a=hp(e.from),c=hp(e.to),d=c<=a;if(!(d?i>=a||i<c:i>=a&&i<c))return!1;if(!e.days)return!0;const f=d&&i<c,m=(n.getDay()+(f?6:0))%7;return e.days.includes(m)}function cS(e,t){const n=new Date(t);return n.setHours(Number(e.to.slice(0,2)),Number(e.to.slice(3,5)),0,0),n.getTime()<=t&&n.setDate(n.getDate()+1),n.getTime()}function lS(e,t){const n=e.focusUntil??0;if(n>t)return{kind:"manual",until:n};if(!e.focus||!aS(e.focus,t))return{kind:"off"};const i=cS(e.focus,t);return(e.focusOffUntil??0)>t?{kind:"paused",until:i}:{kind:"hours",until:i}}function dS(e,t,n){const i={...e};switch(delete i.focusUntil,delete i.focusOffUntil,t.kind){case"for":return{...i,focusUntil:n+t.minutes*6e4};case"resume":return i;case"end":{const a=lS(i,n);return a.kind==="hours"?{...i,focusOffUntil:a.until}:i}default:return t}}const uS=e=>({id:e.id,key:e.key,title:e.title,...e.archived?{archived:!0}:{}});function hS(e,t){var i;const n={...e};return t.verification===null?delete n.verification:t.verification&&(n.verification=t.verification),t.guides===null||((i=t.guides)==null?void 0:i.length)===0?delete n.guides:t.guides&&(n.guides=t.guides),t.guidesByType===null?delete n.guidesByType:t.guidesByType&&(n.guidesByType=t.guidesByType),t.modelMatching===null?delete n.modelMatching:t.modelMatching&&(n.modelMatching=t.modelMatching),t.confirm&&delete n.settingsUnconfirmed,n}function fS(e,t,n){const i=Date.now();return{id:e,key:t,...n,state:"open",blockedBy:[],comments:[],createdAt:i,updatedAt:i}}const mS=(e,t)=>({...e,blockedBy:e.blockedBy.filter(n=>n!==t)}),pS=(e,t)=>{var n;return{...e,...(n=t.title)!=null&&n.trim()?{title:t.title.trim()}:{},...t.body!==void 0?{body:t.body}:{}}};function gS(e){const{closeReason:t,closedAt:n,...i}=e;return{...i,state:"open"}}const vS=["status","verification","checks","reviewOf","guide","guidesAdded","guidesRemoved"];function kS(e,t){const n={...e};for(const i of vS)t[i]!==void 0&&(t[i]===null?delete n[i]:n[i]=t[i]);return t.confirm&&delete n.settingsUnconfirmed,n}function yS(e,t){const n={...e};return t?n.archived=!0:delete n.archived,n}async function Lv(e){const t=await e.list(),n=t.filter(a=>!a.includes("/decisions/")).map(a=>{var c;return Number(((c=a.match(/(\d+)\.md$/))==null?void 0:c[1])??0)}),i=await Promise.all(t.filter(a=>a.endsWith("/map.md")).map(async a=>Number(ke(Ea(await e.read(a)).front.key).replace(/\D/g,""))||0));return Math.max(0,...n,...i)+1}const Pv="### [^\\n]* @ \\d{4}-\\d\\d-\\d\\dT",Dv=`## Comments\\s*$|${Pv}`,_v=`<!-- ${J.labelPrefix}:comments -->`,wS=new RegExp(`^## Comments[ \\t]*\\n${_v}[ \\t]*$`,"m"),xS=new RegExp(`^(?=${Pv})### `,"m"),pu=2,Bv=e=>Na(Sa(e,Dv)),fp=e=>ia(oi(e),Dv);function jS(e,t){const n=(t>=pu?wS:/^## Comments\s*$/m).exec(e);return n?[e.slice(0,n.index),e.slice(n.index+n[0].length)]:[e,""]}function mp(e){const{front:t,body:n}=Ea(e),i=Number(ke(t.format))||1,[a,c]=jS(n,i),d=c.split(i>=pu?xS:/^### /m).slice(1).map((g,k)=>{const w=g.indexOf(`
|
|
114
|
+
`),b=g.slice(0,w),S=b.lastIndexOf(" @ ");return{id:`c${k}`,author:b.slice(0,S<0?void 0:S).trim(),createdAt:S>=0&&Date.parse(b.slice(S+3))||0,body:fp(g.slice(w+1).trim())}}),u=ke(t.close_reason),f=kj.find(g=>g===ke(t.status)),m=Yg(ke(t.verification));return{id:ke(t.id),key:`#${ke(t.id)}`,title:ke(t.title),type:ke(t.type)||"task",hitl:mt(t.labels).includes(ru)||void 0,state:ke(t.state)==="closed"?"closed":"open",closeReason:u==="completed"||u==="not_planned"?u:void 0,assignee:ke(t.assignee)||void 0,...f?{status:f}:{},...m?{verification:m}:{},...t.checks!==void 0?{checks:mt(t.checks)}:{},...ke(t.review_of)?{reviewOf:ke(t.review_of)}:{},...ke(t.guide)?{guide:ke(t.guide)}:{},...mt(t.guides_added).length?{guidesAdded:mt(t.guides_added)}:{},...mt(t.guides_removed).length?{guidesRemoved:mt(t.guides_removed)}:{},blockedBy:mt(t.blocked_by),body:fp(a.trim()),comments:d,createdAt:ai(t.created),updatedAt:ai(t.updated),closedAt:ai(t.closed)||void 0}}function Fv(e){var i,a;const t={id:e.id,format:String(pu),title:e.title,type:e.type,labels:[ja(e.type),...fj(e.type)&&e.hitl?[ru]:[]],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}:{},...(i=e.guidesAdded)!=null&&i.length?{guides_added:e.guidesAdded}:{},...(a=e.guidesRemoved)!=null&&a.length?{guides_removed:e.guidesRemoved}:{},blocked_by:e.blockedBy,created:fn(e.createdAt),updated:fn(e.updatedAt),...e.closedAt?{closed:fn(e.closedAt)}:{}},n=e.comments.length?`
|
|
115
|
+
|
|
116
|
+
## Comments
|
|
117
|
+
${_v}
|
|
118
|
+
|
|
119
|
+
${e.comments.map(bS).join(`
|
|
120
|
+
|
|
121
|
+
`)}`:"";return hu(t,Bv(e.body)+n)}function bS(e){return`### ${xs(e.author)} @ ${fn(e.createdAt)}
|
|
122
|
+
|
|
123
|
+
${Bv(e.body)}`}async function SS(e,t,n){for(let i=0;;i++){const a=await t();if(n(a.path),!e.create)return await e.write(a.path,a.text),a.value;if(await e.create(a.path,a.text))return a.value;if(i>=50)throw new Error(`could not allocate ${a.path}`)}}async function NS(e,t,n){const i=await Lv(e),a=fS(String(i),`#${i}`,n);return{path:`${t}/tickets/${a.id}.md`,text:Fv({...a,updatedAt:Date.now()}),value:a}}async function $S(e,t,n){const i=(await e.list()).filter(d=>d.includes("/decisions/")),a=Math.max(0,...i.map(d=>T0(d.split("/").pop())))+1,c=C0(`D-${a}`,t,n);return{path:`${t}/decisions/${c.id}.md`,text:Nv(c),value:c}}const CS=/^([^/]+)\/decisions\/([^/]+)\.md$/,TS=(e,t)=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40)||`map-${t}`,zv=/^[A-Za-z0-9][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)*$/;function ws(e){if(typeof e!="string"||e.length>128||!zv.test(e))throw new Error(`not a valid id: ${JSON.stringify(e)}`);return e}const ES=e=>{const t=e.match(/^[^/]+\/tickets\/([^/]+)\.md$/);return!!t&&zv.test(t[1])};class AS{constructor(t,n){oe(this,"seen",new Map);oe(this,"pending",new Map);this.read=t,this.emit=n}knows(t){return this.seen.has(t)}remember(t,n,i){this.seen.set(t,{text:n,supersededBy:i})}queue(t){const n=t.split("/")[0],i=this.pending.get(n)??{paths:new Set,timer:setTimeout(()=>void this.flush(n),250)};i.paths.add(t),this.pending.set(n,i)}async flush(t){const n=this.pending.get(t);if(this.pending.delete(t),!n)return;const i=[...n.paths].filter(d=>CS.test(d)),a=[];for(const d of i){const u=await this.read(d).catch(()=>""),f=this.seen.get(d);if(!u||(f==null?void 0:f.text)===u)continue;const m=Ed(u);this.seen.set(d,{text:u,supersededBy:m.supersededBy}),f?m.supersededBy&&m.supersededBy!==f.supersededBy&&a.push({kind:"decision.superseded",mapId:t,decisionId:m.id,supersededBy:m.supersededBy,external:!0,at:Date.now()}):a.push({kind:"decision.recorded",mapId:t,decisionId:m.id,ticketId:m.ticketId,external:!0,at:Date.now()})}i.length?!a.length&&i.length<n.paths.size&&a.push({kind:"external.changed",mapId:t,at:Date.now()}):a.push({kind:"external.changed",mapId:t,at:Date.now()});const c=d=>d.kind==="decision.recorded"?0:1;a.sort((d,u)=>c(d)-c(u));for(const d of a)this.emit(d)}}const Md="guides-by-type";function RS(e){if(e[Md]===void 0)return;const t={};for(const n of mt(e[Md])){const[i,a]=n.split("=").map(d=>d.trim());if(!a||!is.includes(i))continue;const c=t[i]??[];c.includes(a)||(t[i]=[...c,a])}return t}function IS(e){if(!e)return{};const t=is.flatMap(n=>(e[n]??[]).map(i=>`${n}=${i}`));return{[Md]:t}}function MS(e){const t=ke(e["model-matching"]);if(t!=="on"&&t!=="off")return;const n=oS(mt(e["model-tiers"]).map(i=>i.split("=").map(a=>a.trim())));return Object.keys(n).length?{enabled:t==="on",tiers:n}:{enabled:t==="on"}}function OS(e){if(!e)return{};const t=Object.entries(e.tiers??{}).map(([n,i])=>`${n}=${i}`);return{"model-matching":e.enabled?"on":"off",...t.length?{"model-tiers":t}:{}}}function pp(e,t){const{front:n,body:i}=Ea(t),a=Yg(ke(n.verification)),c=MS(n),d=RS(n);return{id:e,key:ke(n.key)||e,title:ke(n.title)||e,mode:ke(n.mode)==="plan-only"||mt(n.labels).includes(ou)?"plan-only":$s,...a?{verification:a}:{},...mt(n.guides).length?{guides:mt(n.guides)}:{},...d?{guidesByType:d}:{},...c?{modelMatching:c}:{},...ke(n.archived)==="true"?{archived:!0}:{},sections:o0(i),createdAt:ai(n.created),updatedAt:ai(n.updated)}}function LS(e){var t;return hu({key:e.key,title:e.title,mode:e.mode,...e.verification?{verification:e.verification}:{},...(t=e.guides)!=null&&t.length?{guides:e.guides}:{},...IS(e.guidesByType),...OS(e.modelMatching),...e.archived?{archived:"true"}:{},labels:[iu,...e.mode==="plan-only"?[ou]:[]],created:fn(e.createdAt),updated:fn(e.updatedAt)},r0(e.sections))}function PS(e,t){t.code!=="ENOENT"&&console.warn(`Teamtrail: decision ${e} can't be read: ${t.message}`)}class DS{constructor(t,n=`./${J.dataDir}`){oe(this,"kind","markdown");oe(this,"label","Local markdown");oe(this,"events",new di);oe(this,"selfWrites",new Map);oe(this,"external",new AS(t=>this.fs.read(t),t=>this.events.emit(t)));oe(this,"ticketPath",(t,n)=>`${ws(t)}/tickets/${ws(n)}.md`);oe(this,"setMapArchived",(t,n)=>this.editMap(t,i=>yS(i,n),{kind:"map.updated",mapId:t,at:Date.now()}));var i;this.fs=t,this.location=n,(i=t.watch)==null||i.call(t,a=>{const c=this.selfWrites.get(a);c&&Date.now()-c<1500||this.external.queue(a)})}async put(t,n,i){this.selfWrites.set(t,Date.now()),await this.fs.write(t,n,i===void 0?void 0:{base:i})}putNew(t){return SS(this.fs,t,n=>this.selfWrites.set(n,Date.now()))}async readMap(t){return pp(t,await this.fs.read(`${ws(t)}/map.md`))}async writeMap(t,n){await this.put(`${ws(t.id)}/map.md`,LS(t),n)}async listMaps(){const n=(await this.fs.list()).filter(i=>/^[^/]+\/map\.md$/.test(i)).map(i=>i.split("/")[0]);return Promise.all(n.map(async i=>uS(await this.readMap(i))))}async loadMap(t){const n=await this.fs.list(),i=await this.readMap(t),a=n.filter(d=>d.startsWith(`${t}/tickets/`)&&ES(d)),c=await Promise.all(a.map(async d=>mp(await this.fs.read(d))));return{map:i,tickets:c.sort((d,u)=>d.createdAt-u.createdAt)}}async createMap(t){const n=await Lv(this.fs),i=TS(t.title,n),a={id:i,key:`#${n}`,title:t.title,mode:t.mode??$s,...t.verification?{verification:t.verification}:{},sections:t.sections,createdAt:Date.now(),updatedAt:Date.now()};return await this.writeMap(a),this.events.emit({kind:"map.created",mapId:i,at:Date.now()}),a}async editMap(t,n,i){const a=await this.fs.read(`${ws(t)}/map.md`);await this.writeMap({...n(pp(t,a)),updatedAt:Date.now()},a),this.events.emit(i)}setMapMode(t,n){return this.editMap(t,i=>({...i,mode:n}),{kind:"map.mode",mapId:t,mode:n,at:Date.now()})}setMapMeta(t,n){return this.editMap(t,i=>hS(i,n),{kind:"map.updated",mapId:t,at:Date.now()})}updateMapSections(t,n){const i=Object.keys(n)[0];return this.editMap(t,a=>({...a,sections:{...a.sections,...n}}),{kind:"map.updated",mapId:t,section:i,at:Date.now()})}async createTicket(t,n){const i=await this.putNew(()=>NS(this.fs,t,n));return this.events.emit({kind:"ticket.created",mapId:t,ticketId:i.id,at:Date.now()}),i}async addBlocking(t,n,i){await this.update(t,i,a=>a.blockedBy.includes(n)?a:{...a,blockedBy:[...a.blockedBy,n]}),this.events.emit({kind:"edge.added",mapId:t,blockerId:n,blockedId:i,at:Date.now()})}async update(t,n,i){const a=await this.fs.read(this.ticketPath(t,n)),c=mp(a),d=i(c);d!==c&&await this.put(this.ticketPath(t,c.id),Fv({...d,updatedAt:Date.now()}),a)}async removeBlocking(t,n,i){await this.update(t,i,a=>mS(a,n)),this.events.emit({kind:"edge.removed",mapId:t,blockerId:n,blockedId:i,at:Date.now()})}async editTicket(t,n,i){await this.update(t,n,a=>pS(a,i)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:n,at:Date.now()})}async reopen(t,n){await this.update(t,n,gS),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:n,at:Date.now()})}async assign(t,n,i){await this.update(t,n,a=>({...a,assignee:i??void 0})),this.events.emit(i?{kind:"ticket.claimed",mapId:t,ticketId:n,assignee:i,at:Date.now()}:{kind:"ticket.released",mapId:t,ticketId:n,at:Date.now()})}async comment(t,n,i,a){await this.update(t,n,c=>({...c,comments:[...c.comments,{id:`c${c.comments.length}`,author:i,body:a,createdAt:Date.now()}]})),this.events.emit({kind:"ticket.commented",mapId:t,ticketId:n,at:Date.now()})}async close(t,n,i){await this.update(t,n,a=>({...a,state:"closed",closeReason:i,closedAt:Date.now()})),this.events.emit({kind:"ticket.closed",mapId:t,ticketId:n,reason:i,at:Date.now()})}async setMeta(t,n,i){await this.update(t,n,a=>kS(a,i)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:n,at:Date.now()})}async listDecisions(t){const i=(await this.fs.list()).filter(a=>a.startsWith(`${t}/decisions/`)).map(async a=>{const c=await this.fs.read(a).catch(u=>PS(a,u));if(!c)return;const d={...Ed(c),mapId:t};return this.external.knows(a)||this.external.remember(a,c,d.supersededBy),d});return(await Promise.all(i)).filter(a=>!!a)}async createDecision(t,n){const i=await this.putNew(async()=>{const a=await $S(this.fs,t,n);return this.external.remember(a.path,a.text),a});return this.events.emit({kind:"decision.recorded",mapId:t,decisionId:i.id,ticketId:i.ticketId,at:Date.now()}),i}async markSuperseded(t,n,i){const a=`${ws(t)}/decisions/${ws(n)}.md`,c=await this.fs.read(a),d=Nv({...Ed(c),mapId:t,supersededBy:i});this.external.remember(a,d,i),await this.put(a,d,c),this.events.emit({kind:"decision.superseded",mapId:t,decisionId:n,supersededBy:i,at:Date.now()})}subscribe(t){return this.events.on(t)}}function pn(e,t=[]){if(e)try{const{protocol:n}=new URL(e);return["http:","https:",...t].includes(n)?e:void 0}catch{return}}class gp extends Error{constructor(t,n,i,a){super(n),this.code=t,this.status=i,this.resetAt=a,this.name="TrackerError"}}const _S={github:"GitHub Issues",linear:"Linear"};async function $t(e,t,n){let i;try{i=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:n===void 0?void 0:JSON.stringify(n)})}catch{throw new gp("offline","Lookout server unreachable; is `teamtrail` still running?")}const a=await i.json().catch(()=>({}));if(!i.ok)throw new gp(a.code??"http",a.error??`request failed (${i.status})`,i.status,a.resetAt);return a}class BS{constructor(t,n,i=""){oe(this,"label");oe(this,"location");oe(this,"status",{state:"connecting",queued:0});oe(this,"events",new di);oe(this,"statusEvents",new di);oe(this,"source");oe(this,"listeners",0);oe(this,"openEvents",t=>new EventSource(`${this.base}${t}`));oe(this,"listMaps",()=>this.call("listMaps"));oe(this,"loadMap",t=>this.call("loadMap",t));oe(this,"createMap",t=>this.call("createMap",t));oe(this,"setMapMode",(t,n)=>this.call("setMapMode",t,n));oe(this,"setMapArchived",(t,n)=>this.call("setMapArchived",t,n));oe(this,"setMapMeta",(t,n)=>this.call("setMapMeta",t,n));oe(this,"updateMapSections",(t,n)=>this.call("updateMapSections",t,n));oe(this,"createTicket",(t,n)=>this.call("createTicket",t,n));oe(this,"addBlocking",(t,n,i)=>this.call("addBlocking",t,n,i));oe(this,"removeBlocking",(t,n,i)=>this.call("removeBlocking",t,n,i));oe(this,"editTicket",(t,n,i)=>this.call("editTicket",t,n,i));oe(this,"reopen",(t,n)=>this.call("reopen",t,n));oe(this,"assign",(t,n,i)=>this.call("assign",t,n,i));oe(this,"comment",(t,n,i,a)=>this.call("comment",t,n,i,a));oe(this,"close",(t,n,i)=>this.call("close",t,n,i));oe(this,"setMeta",(t,n,i)=>this.call("setMeta",t,n,i));oe(this,"listDecisions",t=>this.call("listDecisions",t));oe(this,"createDecision",(t,n)=>this.call("createDecision",t,n));oe(this,"markSuperseded",(t,n,i)=>this.call("markSuperseded",t,n,i));this.kind=t,this.base=n,this.label=_S[t],this.location=i}async call(t,...n){return(await $t(`${this.base}/tracker/${this.kind}/call`,"POST",{method:t,args:n})).result}open(){const t=this.openEvents(`/tracker/${this.kind}/events`);t.addEventListener("message",n=>this.events.emit(JSON.parse(n.data))),t.addEventListener("status",n=>{const i=JSON.parse(n.data);i.location&&(this.location=i.location),this.status=i,this.statusEvents.emit(i)}),t.addEventListener("error",()=>{this.status.state!=="offline"&&(this.status={...this.status,state:"offline",error:"Lookout server unreachable"},this.statusEvents.emit(this.status))}),this.source=t}subscribe(t){const n=this.events.on(t);return++this.listeners===1&&this.open(),()=>{var i;n(),--this.listeners===0&&((i=this.source)==null||i.close(),this.source=void 0)}}onStatus(t){return this.statusEvents.on(t)}}function FS(e){return{get:()=>$t(`${e}/trackers`,"GET"),test:t=>$t(`${e}/trackers/test`,"POST",t),connect:t=>$t(`${e}/trackers`,"PUT",t),forget:t=>$t(`${e}/trackers/credentials/${t}`,"DELETE"),githubRepos:()=>$t(`${e}/trackers/github/repos`,"GET"),githubSignIn:{start:()=>$t(`${e}/trackers/github/sign-in/start`,"POST"),poll:()=>$t(`${e}/trackers/github/sign-in/poll`,"POST"),cancel:()=>$t(`${e}/trackers/github/sign-in/cancel`,"POST"),signOut:()=>$t(`${e}/trackers/github/sign-in`,"DELETE")},linearTeams:t=>t?$t(`${e}/trackers/linear/teams`,"POST",{apiKey:t}):$t(`${e}/trackers/linear/teams`,"GET"),linearProjects:(t,n)=>n?$t(`${e}/trackers/linear/projects`,"POST",{apiKey:n,teamId:t}):$t(`${e}/trackers/linear/projects?team=${encodeURIComponent(t)}`,"GET")}}const zS=[{id:"markdown",name:"Local markdown",status:"available"},{id:"github",name:"GitHub Issues",status:"available"},{id:"linear",name:"Linear",status:"available"}],Uv=[{id:"claude-code",name:"Claude Code",status:"primary",trailName:"claude"},{id:"codex",name:"Codex",status:"primary",trailName:"codex"},{id:"cursor",name:"Cursor",status:"planned",trailName:"cursor"}],US=Uv[0],WS="https://github.com/teamtrailhq/teamtrail-guides",HS="https://raw.githubusercontent.com/teamtrailhq/teamtrail-guides/main",KS=`${WS}/blob/main/CONTRIBUTING.md`,GS=e=>e.slice(0,9),VS=/[a-z][\w+.-]*:\/\/(?!(localhost|127\.0\.0\.1)(:\d+)?(\/|$|\s))/i,qS=/^[\w.-]+@[\w.-]+:/,QS=/^(@[\w.-]+\/)?[\w./-]+@[\w^~<>=*.-]+$/,YS=/(^|=)(npm|jsr|github|gitlab|bitbucket|git\+[a-z]+|https?):/i,JS=/^--?(node-options|script-shell|shell|exec|toolexec|vettool|overlay)(=|$)|^--(to-command|checkpoint-action|use-compress-program|info-script|new-volume-script|unzip-command|open-files-in-pager|upload-pack|receive-pack|exec|ext-diff|eval|eval-command)(=|$)/i,XS={tar:/^-[A-Za-z]*[IF]/,zip:/^-TT|^--unzip-command/,make:/^-E|^--eval/,perl:/^-[A-Za-z]*M/};function ZS(e,t){var n;if(VS.test(t)||qS.test(t))return"names a remote address, so it reaches the network";if(QS.test(t)&&!t.startsWith("-"))return`names a package to download (${t})`;if(YS.test(t))return`names a package from a registry (${t})`;if(JS.test(t))return`runs a command it's given (${t.split("=")[0]})`;if((n=XS[e])!=null&&n.test(t))return`runs a command or code it's given (${t})`;if(/^(SHELL|\.SHELLFLAGS|MAKESHELL|MAKEFLAGS|MFLAGS|MAKE|GNUMAKEFLAGS)=/.test(t))return`sets what make runs (${t.split("=")[0]})`;if(eN.test(t))return"carries a shell command (a pipe to a shell, $(…), backticks, ; or &&)";if(e==="git"&&/^(--output(=|$)|-o)/.test(t))return"writes git output to a file it names"}const eN=/\|\s*(sh|bash|zsh|dash|ksh|fish|pwsh|node|python\d*|perl|ruby)\b|\$\(|`|;|&&|\|\||\b(curl|wget)\s/;function tN(e,t){var n;if(e==="cargo")for(let i=0;i<t.length;i++){const a=t[i]==="--config"?t[i+1]:(n=/^--config=(.*)$/s.exec(t[i]))==null?void 0:n[1];if(a!==void 0&&!/^[\w./-]+\.toml$/.test(a))return"sets cargo configuration inline (--config)"}}function nN(e,t){const n=tN(e,t);if(n)return n;for(const i of t){const a=ZS(e,i);if(a)return a}}const sN=/^(-c|-e|-E|-ex|-x|-r|-command|-Command|-EncodedCommand)$|^--(eval|exec|command|expr|execute|run)(=|$)/,iN=/(^|[\s|'"=])[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}(:\d+)?\/\S*/i;function rN(e,t){const n=e.find(i=>{var a;return sN.test(i)&&!((a=t==null?void 0:t.exempt)!=null&&a.includes(i.split("=")[0]))});if(n)return`passes ${n.split("=")[0]}, which usually means "run this code"; point at a script in the repo`;if(!t&&e.some(i=>iN.test(i)))return"names an address, so it may reach the network"}const oN=new Set(["push","fetch","pull","clone","remote","submodule","config","ls-remote","send-email","request-pull","daemon","http-fetch","http-push","credential","archive","bundle","svn","p4","lfs","filter-branch","bisect","difftool","mergetool","upload-pack","upload-archive","fetch-pack","send-pack","receive-pack","instaweb","rebase","http-backend","shell","web--browse","imap-send"]),aN=new Set(["-C","--git-dir","--work-tree","--namespace","--super-prefix"]);function cN(e){for(let t=0;t<e.length;t++){const n=e[t],i=n.split("=")[0];if(i==="-c"||i.startsWith("-c")||i==="--config-env"||i==="--exec-path")return`sets git's configuration or programs inline (${i})`;if(aN.has(i)){n.includes("=")||t++;continue}if(n.startsWith("-"))continue;const a=n.toLowerCase();return oN.has(a)||a.startsWith("remote-")?`runs git ${a}, which reaches a remote, runs commands or changes git's configuration`:a==="grep"&&e.slice(t+1).some(c=>/^-[A-Za-z]*O|^--open-files-in-pager/.test(c))?"runs git grep with a pager command (-O)":void 0}}const lN=["--require","--import","--loader","--experimental-loader","--env-file","--input-type"],vp={inline:"ep",value:"rC",long:["--eval","--print"],longValue:lN},dN={node:vp,nodejs:vp,bun:{inline:"e",value:"r",long:["--eval","--print"]},python:{inline:"c",value:"mWXQ",long:["--command"],stop:"-m"},pypy:{inline:"c",value:"mWXQ",long:[],stop:"-m"},ruby:{inline:"e",value:"rICEx",long:[]},perl:{inline:"eEMm",value:"IxCd",long:[]},php:{inline:"rBRFE",value:"dcfz",long:[]},lua:{inline:"e",value:"l",long:[]},luajit:{inline:"e",value:"lbj",long:[]},rscript:{inline:"e",value:"",long:["--expr"]},osascript:{inline:"e",value:"sl",long:[]}};function uN(e,t){const n=e.slice(1);for(let i=0;i<n.length;i++){if(t.inline.includes(n[i]))return"code";if(t.value.includes(n[i]))return i===n.length-1?"takes-next":"plain"}return"plain"}function hN(e,t){var a;if(/^data:|=data:/i.test(e))return"code";if(!e.startsWith("--"))return uN(e,t);const[n,i]=e.toLowerCase().split(/=(.*)/s,2);return t.long.includes(n)?"code":i===void 0&&((a=t.longValue)!=null&&a.includes(n))?"takes-next":"plain"}function fN(e,t){const n=dN[e];if(n)for(let i=0;i<t.length;i++){const a=t[i];if(a==="--"||!a.startsWith("-")||a===n.stop)return;const c=hN(a,n);if(c==="code")return"runs code given inline; point at a script in the repo instead";if(c==="takes-next"&&/^data:/i.test(t[i+1]??""))return"runs code given inline";c==="takes-next"&&i++}}const kp=e=>new RegExp(`^(?![-/~\\\\])(?!.*\\.\\.)(?![a-zA-Z]:)[\\w./-]+\\.(${e})$`),zt={},ft=e=>e.split(/\s+/).filter(Boolean),mN={npm:{sub:ft("test t run run-script")},pnpm:{sub:ft("test t run")},yarn:{sub:ft("test run")},bun:{sub:ft("test run")},make:zt,cargo:{sub:ft("test check clippy build fmt")},go:{sub:ft("test vet build")},deno:{sub:ft("test lint check")},node:{script:kp("[cm]?[jt]s"),sub:["--test"]},python:{script:kp("py"),modules:ft("pytest unittest mypy ruff black flake8 pylint"),exempt:["-c"]},pytest:{exempt:["-c"]},ruff:{sub:ft("check format")},mypy:zt,pyright:zt,black:{needs:["--check"]},flake8:zt,pylint:zt,tsc:zt,eslint:{exempt:["-c"]},"pa11y-ci":zt,prettier:{needs:ft("--check -c --list-different -l")},biome:{sub:ft("check lint ci")},jest:{exempt:["-c"]},vitest:zt,mocha:zt,playwright:{sub:["test"]},rubocop:zt,rspec:{exempt:["-e"]},phpunit:zt,phpstan:zt,"golangci-lint":{sub:["run"]},swift:{sub:ft("test build")},dotnet:{sub:ft("test build")},mvn:{sub:ft("test verify compile")},gradle:{sub:ft("test check build")},gradlew:{sub:ft("test check build")},git:{sub:["diff"]}},pN=/^(\.\/)?node_modules\/\.bin\/([\w.-]+)$/;function gN(e,t){var i;const n=t[0]??"";return e.needs&&!t.some(a=>e.needs.includes(a))?!1:(i=e.script)!=null&&i.test(n)?!0:e.modules?n==="-m"&&e.modules.includes(t[1]??""):e.sub?e.sub.includes(n):!0}function Wv(e){var i;const t=(i=pN.exec(e.argv0))==null?void 0:i[2],n=mN[t??e.program];return n&&gN(n,e.args)?n:void 0}const vN=e=>!!Wv(e),Aa=e=>new Set(e.split(/\s+/).filter(Boolean)),kN=Aa(`
|
|
124
|
+
sh bash zsh fish dash ksh mksh pdksh csh tcsh ash yash nu nushell xonsh elvish osh oil rc es ion
|
|
125
|
+
cmd powershell pwsh
|
|
126
|
+
`),yN=Aa(`
|
|
127
|
+
curl wget nc ncat netcat socat telnet scp sftp ssh ssh-keyscan rsync ftp tftp aria2c websocat
|
|
128
|
+
openssl dig nslookup host ping ping6 traceroute whois nmap gh aws gcloud az kubectl
|
|
129
|
+
`),wN=Aa("npx pnpx bunx uvx uv pipx docker podman nix nix-shell nix-env flatpak snap"),xN=Aa(`
|
|
130
|
+
env xargs sudo doas su nohup nice ionice time timeout watch stdbuf chroot setsid caffeinate arch flock unbuffer
|
|
131
|
+
chronic firejail systemd-run strace ltrace gdb lldb exec eval command busybox toybox parallel script
|
|
132
|
+
awk gawk mawk nawk sed gsed vim nvim vi ex emacs expect
|
|
133
|
+
`),Ko=["exec","x","dlx","install","i","add","ci","create","init","update","upgrade"],jN={npm:new Set(Ko),pnpm:new Set(Ko),yarn:new Set(Ko),bun:new Set(Ko),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 bN(e){const t=(e.split(/[\\/]/).pop()??"").toLowerCase().replace(/\.(exe|cmd|bat|com)$/,"");return t.replace(new RegExp("(?<=[a-z])[\\d.-]+$"),"")||t}const SN=e=>{var t;return((t=e.find(n=>!n.startsWith("-")))==null?void 0:t.toLowerCase())??""};function yp(e){const t=e.findIndex(n=>n.startsWith("-m"));if(!(t<0))return e[t]==="-m"?e[t+1]:e[t].slice(2)}const NN=new Set(["pip","ensurepip","pipx","uv","venv","http.server","webbrowser"]);function $N(e,t){var i;if(kN.has(e))return`runs a shell (${e}); name the program and its arguments instead`;if(yN.has(e))return`runs ${e}, which reaches the network`;if(wN.has(e))return`runs ${e}, which downloads and runs a package; use one installed in the repo`;if(xN.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 n=SN(t);if((i=jN[e])!=null&&i.has(n))return`runs ${e} ${n}, which downloads packages; use one installed in the repo`;if(e==="python"&&NN.has(yp(t)??""))return`runs python -m ${yp(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 Hv(e){const t=e.run[0]??"";return{argv0:t,program:bN(t),args:e.run.slice(1)}}function CN(e){const{argv0:t,program:n,args:i}=Hv(e),a=Wv({argv0:t,program:n,args:i}),c=[$N(n,i),fN(n,i),n==="git"?cN(i):void 0,nN(n,i),rN(i,a)].filter(d=>!!d);return e.cwd&&(e.cwd.startsWith("/")||e.cwd.split(/[\\/]/).includes(".."))&&c.push("cwd must stay inside the repo"),c}const TN="unknown program: Teamtrail can't tell what this runs";function EN(e){if(CN(e).length)return;const{argv0:t,program:n,args:i}=Hv(e);return vN({argv0:t,program:n,args:i})?void 0:TN}function AN(e,t={}){const n=(t.query??"").toLowerCase().split(/\s+/).filter(Boolean);return e.guides.filter(i=>{if(t.verifiedOnly&&!i.verified&&!i.builtin)return!1;const a=[i.id,i.name??"",i.summary,i.author].join(" ").toLowerCase();return n.every(c=>a.includes(c))})}const RN="unknown model",IN=e=>`${Math.round(e.firstTimeRate*100)}%`,wp=(e,t)=>`${e.model} passes ${IN(e)} of your ${t} tickets first time (${e.tickets} tickets)`;function MN(e,t){return t.firstTimeRate-e.firstTimeRate||(e.costPerVerifiedUsd??1/0)-(t.costPerVerifiedUsd??1/0)||e.key.localeCompare(t.key)}function ON(e){return[...new Set(e.scorecard.byTypeAndModel.map(n=>n.type??""))].filter(Boolean).sort().flatMap(n=>{const i=e.scorecard.byTypeAndModel.filter(f=>f.type===n&&f.enough&&f.model!==RN).sort(MN);if(i.length<2||i[0].firstTimeRate===i[1].firstTimeRate)return[];const a=i[0],c=Oj(a.model,e.models).tier,d=e.tiers[n];if(!d||c===d)return[];const u=`${wp(a,n)}; ${wp(i[1],n)}`;return[{type:n,current:d,tier:c,model:a.model??"",because:u}]})}const Zo=e=>`${Math.round(e*100)}%`,LN=e=>e===void 0?"–":`$${e.toFixed(2)}`,gu=e=>e.replace(/[^\w .@/·-]/g,"").slice(0,60);function Xl(e,t){return[`| ${t} | Tickets | Verified first time | Rework | Came back | Attempts per verified | Cost per verified |`,"| --- | ---: | ---: | ---: | ---: | ---: | ---: |",...e.map(n=>[`| ${gu(n.key)}${n.enough?"":" (too few)"}`,n.tickets,Zo(n.firstTimeRate),Zo(n.reworkRate),n.escapeRate===void 0?"–":`${Zo(n.escapeRate)} (${n.escaped??0})`,n.attemptsPerVerified??"–",`${LN(n.costPerVerifiedUsd)} |`].join(" | "))]}function PN(e){return["| Check | Verified tickets it passed | Came back |","| --- | ---: | ---: |",...e.map(t=>`| ${gu(t.key)}${t.enough?"":" (too few)"} | ${t.verified} | ${Zo(t.escapeRate)} (${t.escaped}) |`)]}function DN(e,t="Agent scorecard"){var n,i;return[`## ${gu(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.`,"",...Xl(e.byTypeAndModel,"Ticket type · model"),"",...Xl(e.byVendor,"Vendor"),...(n=e.byGuide)!=null&&n.length?["",...Xl(e.byGuide,"Guide")]:[],...(i=e.byCheck)!=null&&i.some(a=>a.escaped)?["",...PN(e.byCheck)]:[]].join(`
|
|
134
|
+
`)}const Zl="No area yet";function _N(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 ed={x:112,w:15},td={x:136,w:10};function xp({x:e,w:t},n,i,a){const c=e+n;return[`<rect x="${c}" y="${94+i}" width="${t}" height="12" rx="${t>12?5:4}" fill="${a.glowLight}"/>`,`<rect x="${c}" y="${100+i}" width="${t}" height="6" rx="3" fill="${a.glow}"/>`,`<rect x="${c+t-6}" y="${96+i}" width="${t>12?3.5:2.5}" height="3.5" rx="1" fill="#fff"/>`].join("")}function jp({x:e,w:t},n){const i=t+3,a=t>12?6:5;return`<rect x="${e-2}" y="90" width="${i}" height="18" rx="${i/2.6}" fill="${n.glowLight}"/><rect x="${e-2+(i-a)/2}" y="96" width="${a}" height="6" rx="2" fill="${n.glass}"/>`}function BN(e,t){if(e==="closed")return[ed,td].map(({x:a,w:c})=>`<rect x="${a}" y="100" width="${c}" height="4" rx="2" fill="${t.glow}"/>`).join("");if(e==="wide")return jp(ed,t)+jp(td,t);const[n,i]=e==="aside"?[4,-5]:[0,0];return xp(ed,n,i,t)+xp(td,n,i,t)}function FN(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(n=>`<circle cx="${124+n*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 zN({eyes:e,mouth:t},n){return BN(e,n)+FN(t,n)}function UN(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 WN(e,t,n,i){return[`<path d="M86 34L80 16" stroke="${i.band}" stroke-width="${n?6:4}" stroke-linecap="round"/>`,t?`<circle cx="79" cy="14" r="11" fill="${e}" opacity=".3"/>`:"",`<circle cx="79" cy="14" r="${n?8:6}" fill="${e}"/>`,t?'<circle cx="77" cy="12" r="2" fill="#fff3c4"/>':""].join("")}function HN({face:e,lamp:t,lit:n,simple:i,c:a}){const c=UN(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}"/>`,i?"":c.shine,e,i?"":c.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}"/>`,WN(t,n,i,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}"/>`,i?"":c.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 KN={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"},Kv={on:"#ffb347",dim:"#a8501c",alert:"#ff5a48"},GN={on:"#ffd166",dim:"#a8501c",alert:"#ff5a48"},VN={circle:100,rounded:46,square:0},qN=.94;let QN=0;function YN(e,{lamp:t=Kv,simple:n=!1,shape:i="circle",colors:a=KN}={}){const c=a,d=e.light??"on",u=i==="circle"?qN:1,f=100*(1-u),m=`scout-clip-${++QN}`,g=HN({face:zN(e,c),lamp:t[d],lit:d!=="dim",simple:n,c});return[`<defs><clipPath id="${m}"><rect width="200" height="200" rx="${VN[i]}"/></clipPath></defs>`,`<g clip-path="url(#${m})">`,`<rect width="200" height="200" fill="${c.ground}"/>`,`<circle cx="120" cy="88" r="74" fill="${c.groundLight}"/>`,`<g transform="translate(${f} ${f}) scale(${u})">${_N(c)}${g}</g>`,"</g>"].join("")}const Gv={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:Kv,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:GN,wave:{bar:"#66828d",lead:"#e8833a"}}},JN="crt",XN={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"}},ZN={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},$n={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function e1(e){return e?/[aeiouy]/i.test(e)?"open":/[a-z0-9]/i.test(e)?"mid":"rest":"rest"}function t1(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 n1(e,t,n){return Array.from({length:n},(i,a)=>{const c=t-(n-1-a);return c>=0&&c<e.length?t1(e[c],c):0})}function Vv({face:e={eyes:"open",mouth:"rest"},variant:t="crt",size:n,simple:i,shape:a="circle",className:c}){const{eyes:d,mouth:u,light:f}=e,m=y.useMemo(()=>YN({eyes:d,mouth:u,light:f},{lamp:Gv[t].lamp,simple:i??n<40,shape:a}),[d,u,f,t,i,n,a]);return s.jsx("svg",{className:c,width:n,height:n,viewBox:"0 0 200 200","aria-hidden":"true",dangerouslySetInnerHTML:{__html:m}})}function s1(e){const[t,n]=y.useState(!1);return y.useEffect(()=>{if(!e){n(!1);return}let i;const a=setInterval(()=>{n(!0),i=setTimeout(()=>n(!1),$n.blinkMs)},$n.blinkEveryMs);return()=>{clearInterval(a),i&&clearTimeout(i)}},[e]),t}const i1={xs:.8,sm:2,md:4,lg:6},r1=40,bp=20,Sp="(prefers-reduced-motion: reduce)",o1=40,a1=350;function c1(e,t){var u;const n=e.size??"md",i=e.state??"idle",a=((u=e.speaking)==null?void 0:u.trim())??"",c=a&&(i==="idle"||i==="speaking")?"speaking":i,d=n==="xs";return{size:n,text:a,effective:c,talking:c==="speaking"&&a.length>0,mini:d,framed:e.framed??!d,reduced:t||d}}const l1=e=>e.length*$n.msPerChar,d1=(e,t)=>t&&(e.effective==="idle"||e.effective==="speaking"||e.effective==="alert");function u1(e,t,n,i){const a=XN[e.effective],c=n?"closed":a.eyes;let d=a.mouth,u=e.text.length-1;if(i)if(e.reduced)d="open";else{u=Math.min(e.text.length-1,Math.floor(t/$n.msPerChar));const m=Math.floor(t/$n.mouthHoldMs)*Math.round($n.mouthHoldMs/$n.msPerChar);d=e1(e.text[Math.min(e.text.length-1,m)])}let f=a.light;return e.effective==="thinking"&&!e.reduced&&Math.floor(t/$n.thinkingStepMs)%2===1&&(f="on"),{eyes:c,mouth:d,light:f,cursor:u}}function h1(e,t){const n=typeof e.size=="number"?e.size:i1[e.size],i=e.reduced?Math.min(e.text.length-1,bp-1):t;return{base:n,px:r1*n,bars:bp,waveCursor:i}}function f1(e,{label:t,speechDone:n,cursor:i,caption:a}){const c=e.talking&&n?"idle":e.effective,d=ZN[c],u=e.size==="md"||e.size==="lg"||typeof e.size=="number"&&e.size>=4;return{shownState:c,status:d,ariaLabel:`${t}, ${d.toLowerCase()}`,showCaption:a??u,shown:m1(e,n,i)}}function m1(e,t,n){return e.talking?e.reduced||t?e.text:e.text.slice(0,n+1):""}function p1(){const[e,t]=y.useState(()=>{var n;return typeof window<"u"&&!!((n=window.matchMedia)!=null&&n.call(window,Sp).matches)});return y.useEffect(()=>{var a;const n=(a=window.matchMedia)==null?void 0:a.call(window,Sp);if(!n)return;const i=()=>t(n.matches);return i(),n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[]),e}function g1(e,t,n){const[i,a]=y.useState(0);return y.useEffect(()=>{if(a(0),!t)return;const c=performance.now(),d=setInterval(()=>a(performance.now()-c),n);return()=>clearInterval(d)},[e,t,n]),i}function v1(e){const{key:t,talking:n,at:i}=e,a=i!==void 0,c=l1(e.text),[d,u]=y.useState(""),f=y.useRef(e.onSpeakEnd);f.current=e.onSpeakEnd,y.useEffect(()=>{if(!n||a)return;const b=setTimeout(()=>{var S;u(t),(S=f.current)==null||S.call(f)},c+a1);return()=>clearTimeout(b)},[n,t,c,a]);const m=n&&d!==t,g=g1(t,e.animate&&(m||e.thinking),m?o1:$n.thinkingStepMs),k=i??g,w=n&&(a?k>=c:d===t);return{t:k,speechDone:w}}const k1=e=>e*2,Od=3.5;function y1(e,t,n){return(e??[]).map((i,a)=>{const c=(1+2*i)*.5;return{x:a*2,y:(Od-c)/2,width:1,height:c,fill:a>=t-2&&i>0?n.lead:n.bar}})}function w1({heights:e,bars:t,unit:n,colors:i}){const a=k1(t);return s.jsx("svg",{className:`scout-wave${e?" on":""}`,width:a*n,height:Od*n,viewBox:`0 0 ${a} ${Od}`,"aria-hidden":"true",children:y1(e,t,i).map((c,d)=>s.jsx("rect",{...c},d))})}function Ra({state:e="idle",size:t="md",speaking:n,variant:i=JN,framed:a,caption:c,label:d="Scout",onSpeakEnd:u,at:f,className:m,style:g}){const k=c1({state:e,size:t,speaking:n,framed:a},p1()),{text:w,effective:b,talking:S,reduced:x}=k,C=Gv[i],P=!x&&!(f!==void 0),D=`${b}|${i}|${w}`,{t:M,speechDone:H}=v1({key:D,text:w,talking:S,thinking:b==="thinking",animate:P,at:f,onSpeakEnd:u}),_=s1(d1(k,P)),Y=S&&!H,{eyes:re,mouth:q,light:Z,cursor:Ae}=u1(k,M,_,Y),{base:ye,px:be,bars:de,waveCursor:Re}=h1(k,Ae),me=y.useMemo(()=>Y?n1(w,Re,de):null,[Y,w,Re,de]),{shownState:Se,status:z,ariaLabel:Q,showCaption:U,shown:E}=f1(k,{label:d,speechDone:H,cursor:Ae,caption:c}),F={...g,"--scout-u":`${ye}px`},ae=s.jsx("span",{className:"scout-sprite",children:s.jsx(Vv,{face:{eyes:re,mouth:q,light:Z},variant:i,size:be,simple:k.mini})});return k.framed?s.jsxs("figure",{className:`scout scout-panel scout-${Se} scout-v-${i} ${m??""}`,style:F,"data-state":Se,children:[s.jsxs("figcaption",{className:"scout-head",children:[s.jsx("span",{className:"scout-name",children:d}),s.jsx("span",{className:"scout-sep",children:"//"}),s.jsx("span",{className:"scout-status",children:z})]}),s.jsxs("div",{className:"scout-feed",role:"img","aria-label":Q,children:[ae,s.jsx(w1,{heights:me,bars:de,unit:ye,colors:C.wave})]}),U&&s.jsxs("p",{className:"scout-caption","aria-hidden":"true",children:[E,S&&!H&&!x&&s.jsx("span",{className:"scout-caret",children:"_"})]}),w&&s.jsx("span",{className:"scout-sr","aria-live":"polite",children:w})]}):s.jsx("span",{className:`scout scout-bare scout-${Se} ${m??""}`,style:F,role:"img","aria-label":Q,children:ae})}const Ct="trail lead";function x1({rt:e,guard:t,setMapId:n,mapIdRef:i,snapRef:a,setChatSession:c,setSelection:d}){const u={actorKind:"trail lead",journal:e.journal};return{selectMap:f=>n(f),openChat:f=>c(f),answer:(f,m)=>e.activity.answer(f,m,Ct,{via:"lookout"}),claim:f=>t("Claim",()=>np(e.adapter,i.current,f,{...u,assignee:Ct})),release:f=>t("Release claim",()=>y0(e.adapter,i.current,f,{...u,actor:Ct})),releaseLease:f=>t("Release to queue",()=>e.leases.release(i.current,f,Ct)),resolve:(f,m,g={})=>t("Resolve · record answer",async()=>{var w;const k=(w=a.current)==null?void 0:w.tickets.find(b=>b.id===f);k&&!k.assignee&&await np(e.adapter,i.current,f,{...u,assignee:Ct}),await A0(e.adapter,i.current,f,{...u,answer:m,author:Ct,decision:{...g,source:{kind:"lookout",label:"Ticket inspector"}}})}),supersede:(f,m)=>t(`Supersede ${f.id}`,async()=>{let g=f.id;if(f.derived){const{id:k,mapId:w,derived:b,supersededBy:S,...x}=f;g=(await lu(e.adapter,f.mapId,x,{appendToTrail:!1})).id}await b0(e.adapter,f.mapId,g,{...m,decidedBy:Ct,participants:[{id:Ct}],source:{kind:"lookout",label:"Logbook"}})}),graduate:({unspecified:f,...m})=>t(`Promote to ticket · ${f}`,async()=>{const g=await I0(e.adapter,i.current,f,m);d({kind:"ticket",id:g.id})}),ruleOut:(f,m)=>t("Rule out of scope",async()=>{await M0(e.adapter,i.current,f,{...u,reason:m,author:Ct,source:{kind:"lookout",label:"Ticket inspector"}}),d(null)}),setArchived:f=>t(f?"Archive trail":"Restore trail",async()=>{await D0(e.adapter,i.current,f),f&&n(void 0)}),setMode:f=>t(`Trail mode · ${f}`,()=>S0(e.adapter,i.current,f)),setModelMatching:f=>t(`Model matching · ${f.enabled?"on":"off"}`,()=>O0(e.adapter,i.current,f))}}const pe=(...e)=>e.filter(Boolean).join(" "),Ns="item",j1=/^[0-9a-f]{6,64}$/;function Sr(){const e=new URLSearchParams(location.search).get("project")??void 0;return e&&j1.test(e)?e:void 0}function ie(e=Sr()){return e?`${J.apiPrefix}/p/${e}`:J.apiPrefix}function b1(e){const t=new URLSearchParams(location.search);for(const i of["projects","project","tracker",Ns])t.delete(i);e.item&&t.set(Ns,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 n=t.toString();return`${location.pathname}${n?`?${n}`:""}`}async function S1(){var n,i;const e=await fetch(`${ie()}/verification/config`).then(a=>a.ok?a.json():void 0).catch(()=>{}),t=((n=e==null?void 0:e.approval)==null?void 0:n.state)==="approved"?(i=e.config)==null?void 0:i.default:void 0;return t&&t!=="off"?t:void 0}async function N1(e,t){var d;const n=(t.assumptions??[]).map((u,f)=>({id:`S-${f+1}`,text:u,status:"holding",tickets:[]})),i=await S1(),{map:a,tickets:c}=await c0(e,{title:t.title,...i?{verification:i}:{},sections:{destination:t.destination,notes:t.notes,decisions:[],unspecified:[],outOfScope:[],...n.length?{assumptions:n}:{}},tickets:[{ref:"discovery",...Wb}]});return await fetch(`${ie()}/briefs/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:a.id,ticketId:(d=c[0])==null?void 0:d.id})}),a}function qv(e,t){const n=URL.createObjectURL(new Blob([t],{type:"text/markdown;charset=utf-8"}));Object.assign(document.createElement("a"),{href:n,download:e}).click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}function Xe(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 Qv(e){const t=Math.max(0,Math.floor(e/1e3)),n=i=>String(i).padStart(2,"0");return`${n(Math.floor(t/3600))}:${n(Math.floor(t%3600/60))}:${n(t%60)}`}const Ia=e=>new Date(e).toTimeString().slice(0,8);function Gt(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 Ma(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const ui=e=>`$${e<10?e.toFixed(2):e.toFixed(1)}`,hi=e=>new Date(e).toISOString().slice(0,10),vu=e=>new Date(e).toTimeString().slice(0,5),$1=e=>`${hi(e)} ${vu(e)}`,Yv=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`},rs=e=>e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",En={research:"Research",prototype:"Prototype",junction:"Junction",task:"Task",execute:"Execute",review:"Review"},C1={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function ku(e,t){return new Map((e??[]).filter(n=>n.mapId===t&&!n.returned).map(n=>[n.ticketId,n]))}function gi(){let e=0,t=0;return{start(){const n=++e;return()=>n<=t?!1:(t=n,!0)},pushed(){t=++e}}}const T1=8,E1=40;function A1(e,t){try{return new URL(e,t).origin===t}catch{return!1}}function Jv(e,t){if(!Array.isArray(e))return[];const n=[];for(const i of e.slice(0,T1)){const{label:a,href:c}=i??{};if(typeof a!="string"||typeof c!="string")continue;const d=a.trim();!d||d.length>E1||!A1(c,t)||n.push({label:d,href:c})}return n}function Oa(e){e==="auto"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}const R1=["auto","day","night"];function I1(e){const[t]=Jv(e?[e]:[],location.origin);return t?{agents:t}:{}}const La=e=>typeof e=="string"&&/^\/[\w/-]{1,100}$/.test(e)?e:void 0;function M1(e){const t=La(e);return t?{themeSave:t}:{}}function O1(e){const t=La(e);return t?{trailAgents:t}:{}}function L1(e){const t=La(e);return t?{setup:t}:{}}function P1(e){const t=La(e);return t?{merge:t}:{}}function D1(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 n=pn(t.href);return n?{home:{label:t.label.trim(),href:n}}:{}}let Ld;const pt=()=>Ld;function _1(e){const t=e.managed;if(!t||typeof t.name!="string")return;const n=typeof t.signOut=="string"&&new URL(t.signOut,location.href).origin===location.origin,i=Jv(t.pages,location.origin),a=R1.find(c=>c===t.theme);return Ld={name:t.name,pages:i,...n?{signOut:t.signOut}:{},...a?{theme:a}:{},...M1(t.themeSave),...P1(t.merge),...L1(t.setup),...O1(t.trailAgents),...t.highRisk===!1?{highRisk:!1}:{},...D1(t.home),...t.tracker==="markdown"?{tracker:"markdown"}:{},...I1(t.agents)},a&&Oa(a),Ld}const B1=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]),un=(e,t)=>e>>>t|e<<32-t;function F1(e){const t=Math.ceil((e.length+9)/64)*64,n=new Uint8Array(t);n.set(e),n[e.length]=128;const i=new DataView(n.buffer);return i.setUint32(t-8,Math.floor(e.length*8/2**32)),i.setUint32(t-4,e.length*8>>>0),n}function z1(e,t,n,i){for(let w=0;w<16;w++)i[w]=t.getUint32(n+w*4);for(let w=16;w<64;w++){const b=un(i[w-15],7)^un(i[w-15],18)^i[w-15]>>>3,S=un(i[w-2],17)^un(i[w-2],19)^i[w-2]>>>10;i[w]=i[w-16]+b+i[w-7]+S>>>0}let[a,c,d,u,f,m,g,k]=e;for(let w=0;w<64;w++){const b=k+(un(f,6)^un(f,11)^un(f,25))+(f&m^~f&g)+B1[w]+i[w]>>>0,S=(un(a,2)^un(a,13)^un(a,22))+(a&c^a&d^c&d)>>>0;[k,g,m,f,u,d,c,a]=[g,m,f,u+b>>>0,d,c,a,b+S>>>0]}[a,c,d,u,f,m,g,k].forEach((w,b)=>e[b]=e[b]+w>>>0)}function nd(e){const t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),n=F1(e),i=new DataView(n.buffer),a=new Uint32Array(64);for(let u=0;u<n.length;u+=64)z1(t,i,u,a);const c=new Uint8Array(32),d=new DataView(c.buffer);return t.forEach((u,f)=>d.setUint32(f*4,u)),c}function U1(e,t){const n=new Uint8Array(64);n.set(e.length>64?nd(e):e);const i=new Uint8Array(64+t.length),a=new Uint8Array(96);for(let c=0;c<64;c++)i[c]=n[c]^54,a[c]=n[c]^92;return i.set(t,64),a.set(nd(i),64),nd(a)}const Xv=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join(""),W1=e=>new Uint8Array((e.match(/../g)??[]).map(t=>parseInt(t,16))),yu=`${J.slug}.session`;let aa;const H1=e=>{const t=e;return!!t&&typeof t.id=="string"&&typeof t.secret=="string"&&typeof t.verifier=="string"};function wu(){try{const e=JSON.parse(localStorage.getItem(yu)??"null");return H1(e)?e:aa}catch{return aa}}function K1(e){aa=e;try{localStorage.setItem(yu,JSON.stringify(e))}catch{}}function Zv(){aa=void 0;try{localStorage.removeItem(yu)}catch{}}let xu="unproven",sd;const Pd=new Set,ek=e=>{xu=e;for(const t of Pd)t(e)};function G1(e){return Pd.add(e),()=>void Pd.delete(e)}const V1=()=>xu==="proven",q1=()=>xu==="proven"&&ek("unproven");function Q1(){const e=new Uint8Array(16);return crypto.getRandomValues(e),Xv(e)}async function Y1(){const e=wu();if(!e)return"unknown";const t=Q1(),n=await fetch(`${J.apiPrefix}/session/prove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id,nonce:t})}).catch(()=>{});if((n==null?void 0:n.status)===404)return Zv(),"unknown";const i=n!=null&&n.ok?(await n.json().catch(()=>({}))).proof:void 0,a=Xv(U1(W1(e.verifier),new TextEncoder().encode(`${t}
|
|
135
|
+
${location.origin}`)));return i===a?"proven":"failed"}function Pa(){return sd??(sd=Y1().then(e=>(sd=void 0,ek(e),e))),sd}const J1=1e4;class tk{constructor(t=ie(),n="/events"){oe(this,"inner");oe(this,"listeners",[]);oe(this,"closed",!1);oe(this,"retryMs",1e3);this.base=t,this.path=n,this.connect()}addEventListener(t,n){var i;this.listeners.push([t,n]),(i=this.inner)==null||i.addEventListener(t,n)}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(pt())return this.open(`${this.base}${this.path}`);if(await Pa()!=="proven")return this.failed();const t=await fetch(`${J.apiPrefix}/sign-in/stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}).then(n=>n.ok?n.json():void 0).then(n=>n==null?void 0:n.ticket).catch(()=>{});if(!this.closed){if(!t)return this.failed();this.open(`${this.base}${this.path}?ticket=${encodeURIComponent(t)}`)}}open(t){const n=new EventSource(t);this.inner=n;for(const[i,a]of this.listeners)n.addEventListener(i,a);n.addEventListener("open",()=>this.retryMs=1e3),n.addEventListener("error",()=>{n.close(),q1(),this.retry()})}failed(){for(const[t,n]of this.listeners)t==="error"&&n(new Event("error"));this.retry()}retry(){this.closed||(setTimeout(()=>void this.connect(),this.retryMs),this.retryMs=Math.min(this.retryMs*2,J1))}}function X1(){if(pt())return void fetch(`${J.apiPrefix}/session`,{cache:"no-store"}).then(e=>e.status===401&&location.reload());Pa().then(e=>e==="unknown"&&location.reload())}let Ht;const ca=new Set,wr=new Map,la=new Set,da=new Set;function nk(e){Ht==null||Ht.addEventListener(e,t=>{for(const n of wr.get(e)??[])n(t.data)})}function Da(){if(!Ht){Ht=new tk,Ht.onerror=()=>{for(const e of da)e();X1()},Ht.addEventListener("open",()=>{for(const e of la)e()}),Ht.onmessage=e=>{const t=JSON.parse(e.data).path;if(typeof t=="string")for(const n of ca)n(t)};for(const e of wr.keys())nk(e)}}function _a(){const e=[...wr.values()].some(t=>t.size>0);ca.size||e||la.size||da.size||(Ht==null||Ht.close(),Ht=void 0)}function Ba(e){return ca.add(e),Da(),()=>{ca.delete(e),_a()}}function vi(e,t){let n=wr.get(e);return n||(n=new Set,wr.set(e,n),nk(e)),n.add(t),Da(),()=>{n.delete(t),_a()}}function os(e){return la.add(e),Da(),()=>{la.delete(e),_a()}}function Z1(e){return da.add(e),Da(),()=>{da.delete(e),_a()}}const ju=(e,t)=>`${e}/${t}`;let nn={reached:!1,live:!1,tickets:{}},Dd=!1;const _d=new Set,Bd=new Set,e$=gi();let Fd=0;const sk=new Map;let ik=0;function ua(e){nn=e;for(const t of _d)t()}function t$(e,t){const n=Object.fromEntries(e.map(i=>[ju(i.mapId,i.ticketId),i]));for(const[i,a]of sk)a>t&&nn.tickets[i]&&(n[i]=nn.tickets[i]);return n}function Np(){const e=e$.start(),t=Fd;fetch(`${ie()}/verification/sync`).then(n=>n.ok?n.json():Promise.reject()).then(n=>e()&&ua({reached:!0,live:!0,status:ik>t?nn.status:n.status,tickets:t$(n.tickets,t)}),()=>nn.reached&&ua({...nn,live:!1}))}function n$(e){const t=JSON.parse(e);if(t.kind==="evidence")for(const a of Bd)a();if(t.kind!=="sync")return;const n=t;ik=++Fd;const i={...nn.tickets};for(const a of n.tickets){const c=ju(a.mapId,a.ticketId);i[c]=a,sk.set(c,Fd)}ua({reached:!0,live:!0,status:n.status,tickets:i})}function $p(){Dd=!0,vi("verification",n$),Z1(()=>nn.reached&&nn.live&&ua({...nn,live:!1})),os(Np),Np()}const ns={subscribe(e){return Dd||$p(),_d.add(e),()=>void _d.delete(e)},get:()=>nn,onEvidence(e){return Dd||$p(),Bd.add(e),()=>void Bd.delete(e)},ticket:(e,t,n)=>e.tickets[ju(t,n)]};function s$(e){if(e!=null&&e.flags.length)return e.flags.some(t=>t.severity==="alert")?"alert":"warn"}const Cp={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:US.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function bu(){try{const e={...Cp,...JSON.parse(localStorage.getItem(xa)??"{}")};return["markdown","github","linear"].includes(e.tracker)||(e.tracker="markdown"),e}catch{return Cp}}const id=new Map,rd=e=>`${ie()}/file?path=${encodeURIComponent(e)}`;async function od(e,t){const n=await e.json().catch(()=>({})),i=new Error(n.error??`${t}: ${e.status}`);return e.status===409?Object.assign(i,{stale:!0}):e.status===404?Object.assign(i,{code:"ENOENT"}):i}const i$={async list(){return(await(await fetch(`${ie()}/list`)).json()).files},async read(e){const t=await fetch(rd(e));if(!t.ok)throw await od(t,`read ${e}`);const n=await t.text(),i=t.headers.get("ETag");return i&&id.set(e,{text:n,etag:i}),n},async write(e,t,n){const i=(n==null?void 0:n.base)===void 0?void 0:id.get(e),a=i&&i.text===(n==null?void 0:n.base)?{"If-Match":i.etag}:{},c=await fetch(rd(e),{method:"PUT",body:t,headers:a});if(!c.ok)throw await od(c,`write ${e}`);id.delete(e)},async create(e,t){const n=await fetch(rd(e),{method:"PUT",body:t,headers:{"If-None-Match":"*"}});if(n.status===412)return!1;if(!n.ok)throw await od(n,`create ${e}`);return!0},watch(e){return Ba(e)}},r$=15*6e4;class o${constructor(t){oe(this,"leases",[]);oe(this,"changes",new di);oe(this,"logged",new Set);oe(this,"since",Date.now()-r$);this.activity=t}subscribe(t){return this.changes.on(t)}set(t){var n;this.leases=t;for(const i of t){const a=`${i.mapId}/${i.ticketId}/${(n=i.returned)==null?void 0:n.at}`;!i.returned||i.returned.at<this.since||this.logged.has(a)||(this.logged.add(a),this.activity.push({source:"system",level:"warn",ticketId:i.ticketId,text:iS(i)}))}this.changes.emit(t)}async release(t,n,i){const a=await fetch(`${ie()}/agents/leases/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,ticketId:n,by:i})});if(!a.ok)throw new Error((await a.json().catch(()=>({}))).error??`HTTP ${a.status}`)}}function a$(e){e.remoteAnswer=(t,n,i)=>{fetch(`${ie()}/agents/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t.sessionId,questionId:t.id,text:n,author:i})}).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 c$(e){const t=gi(),n=()=>{const i=t.start();fetch(`${ie()}/agents/leases`).then(a=>a.ok?a.json():{leases:[]}).then(({leases:a})=>i()&&e.set(a)).catch(()=>{})};vi("leases",i=>{t.pushed(),e.set(JSON.parse(i).leases)}),os(n),n()}function l$(e){let t=0;const n=new Map,i=()=>{const a=t;fetch(`${ie()}/agents`).then(c=>c.ok?c.json():{sessions:[]}).then(({sessions:c})=>[...c].reverse().filter(d=>(n.get(d.session.id)??0)<=a).forEach(d=>e.syncRemote(d))).catch(()=>{})};vi("agent",a=>{const c=JSON.parse(a);n.set(c.session.id,++t),e.syncRemote(c)}),os(i),i()}function Tp(e,t){a$(e),c$(t),l$(e)}function Ep(e){const t=n=>`${xa}:${e}:${n}`;return{get:n=>localStorage.getItem(t(n)),set:(n,i)=>{try{localStorage.setItem(t(n),i)}catch{}}}}const d$=["markdown","github","linear"];function u$(){const e=new URLSearchParams(location.search).get("tracker");return e&&d$.includes(e)?e:bu().tracker}function h$(e){let t,n;const i=new X0,a=new o$(i),c={},d=F0(ie());if(e==="github"||e==="linear"){const m=new BS(e,ie());m.openEvents=g=>new tk(ie(),g),t=m,n=fetch(`${ie()}/trackers`).then(g=>g.json()).catch(()=>{}).then(g=>{m.location=(e==="github"?g==null?void 0:g.github.repo:[g==null?void 0:g.linear.teamKey,g==null?void 0:g.linear.projectName].filter(Boolean).join(" · "))||m.location;const k=Ep(`${e}:${m.location}`);c.presence=new op(k),i.ledger=new ap(k),Tp(i,a)})}else t=new DS(i$,`./${J.dataDir}`),n=fetch(`${ie()}/list`).then(m=>m.json()).catch(()=>({root:"default"})).then(({root:m})=>{const g=Ep(m);c.presence=new op(g),i.ledger=new ap(g),Tp(i,a)});const u=nb(t),f=u.adapter;return{kind:e,ready:n,get presence(){return c.presence},adapter:f,journal:d,monitor:u,activity:i,leases:a}}const mn=e=>e.status==="running",f$=e=>mn(e)&&!!e.waitingOn,m$={blocking:0,soon:1,fyi:2};function p$(e,t,n){const i=e.filter(d=>d.sessionId===t),a=i.find(d=>d.id===n);if(a)return a;const c=d=>m$[d.urgency??"soon"];return[...i].sort((d,u)=>c(d)-c(u)||d.at-u.at)[0]}function ss(e,t=Date.now()){const n=Math.floor(Math.max(0,t-e)/6e4);if(n<1)return"just now";if(n<60)return`${n} min ago`;const i=Math.floor(n/60);if(i<24)return`${i} h ago`;const a=Math.floor(i/24);return a<30?a===1?"yesterday":`${a} days ago`:`on ${new Date(e).toISOString().slice(0,10)}`}const ea={opus:"Opus",sonnet:"Sonnet",haiku:"Haiku",fable:"Fable",codex:"Codex",mini:"mini",nano:"nano"},g$=e=>/^\d{8}$/.test(e)||e==="latest",v$=e=>/^\d{1,2}$/.test(e);function k$(e){const t=e.find(i=>ea[i]);if(!t)return;const n=e.filter(v$).join(".");return n?`${ea[t]} ${n}`:ea[t]}function y$(e){const[,t,...n]=e,i=n.filter(a=>!g$(a)).map(a=>ea[a]??a);return[`GPT-${t??""}`,...i].join(" ").trim()}function Fa(e){const t=e==null?void 0:e.trim();if(!t)return;const n=t.toLowerCase().split(/[-_/]/).filter(Boolean);return n.includes("claude")?k$(n)??t:n[0]==="gpt"?y$(n):t.replace(/[-_](\d{8}|latest)$/,"")}const w$=/^slack:([A-Z0-9]+)$/i;function fi(e,t){var c;const n=(c=w$.exec(e))==null?void 0:c[1];if(!n)return e;if(t!=null&&t.owners.some(d=>d.id===n))return"you (Slack)";const i=t==null?void 0:t.allow.find(d=>d.id===n),a=(i==null?void 0:i.realName)||(i==null?void 0:i.name);return a?`${a} (Slack)`:"Slack user"}function Su(e,t){const n=fi(e.decidedBy,t);return e.decidedByName?`${e.decidedByName} (${n})`:n}function js({n:e,urgent:t,pop:n,hideZero:i}){return s.jsx("span",{className:pe("badge",t&&"urgent",n&&t&&"pop",i&&!e&&"zero"),children:i&&!e?"":e})}function I({variant:e="default",size:t="md",on:n,className:i,type:a,...c}){return s.jsx("button",{type:a??"button",className:pe("btn",e!=="default"&&e,t==="sm"&&"sm",n&&"on",i),...c})}function Vt({as:e="div",tone:t,on:n,className:i,children:a,...c}){return s.jsx(e,{className:pe("card",t,n&&"on",i),...c,children:a})}function Nu({what:e,onReviewAgain:t}){return s.jsxs("div",{className:"changed-notice edge-note edge-attention",children:[s.jsxs("p",{className:"t-meta",children:[e," changed since you opened it: read it again before you approve it."]}),s.jsx(I,{size:"sm",onClick:t,children:"Review again"})]})}function rk({text:e,className:t}){const n=y.useRef(null),[i,a]=y.useState(!1),[c,d]=y.useState(!1);return y.useLayoutEffect(()=>{const u=n.current;u&&!i&&d(u.scrollHeight>u.clientHeight+1)},[e,i]),s.jsxs("div",{className:"clamp",children:[s.jsx("p",{ref:n,className:pe("t-body clamp-text",!i&&"cut",t),children:e}),(c||i)&&s.jsx("button",{type:"button",className:"d-more","aria-expanded":i,onClick:()=>a(!i),children:i?"Show less":"Read more"})]})}function ct({on:e,title:t,sub:n,disabled:i,onClick:a}){return s.jsxs(Vt,{as:"button",type:"button",className:"choice",on:e,disabled:i,onClick:a,children:[s.jsx("b",{className:"choice-title t-row-title",children:t}),n&&s.jsx("span",{className:"c-sub",children:n})]})}function sn(e){return s.jsxs("section",{className:pe("d-section",e.className),children:[s.jsxs("header",{className:"d-section-head",children:[s.jsx("span",{className:"t-label",children:e.label}),e.onEdit&&s.jsx("button",{type:"button",className:"d-edit",onClick:e.onEdit,children:e.editLabel??"Edit"})]}),e.children]})}function rn(e){const[t,n]=y.useState(!1),i=e.label??"Details";return s.jsxs("div",{className:"disclosure",children:[s.jsx("button",{type:"button",className:"d-more","aria-expanded":t,onClick:()=>n(!t),children:t?`Hide ${i.toLowerCase()}`:i}),t&&s.jsx("div",{className:"disclosure-body",children:e.children})]})}function Te({children:e}){return s.jsx("div",{className:"empty",children:e})}function Et({label:e,children:t}){return s.jsxs("div",{className:"fact",children:[s.jsx("dt",{className:"t-label",children:e}),s.jsx("dd",{children:t})]})}function An({title:e,hint:t,art:n}){return s.jsxs("div",{className:n?"empty-state has-art":"empty-state",children:[n,s.jsxs("div",{className:"es-words",children:[s.jsx("span",{className:"es-title",children:e}),t&&s.jsx("span",{className:"es-hint",children:t})]})]})}function Je({label:e,children:t,className:n}){return s.jsxs("label",{className:pe("field",n),children:[e,t]})}const za=y.forwardRef(function({value:t,onValueChange:n,onSubmit:i,action:a="Send",actionDisabled:c,className:d,...u},f){return s.jsxs("form",{className:pe("input-row",d),onSubmit:m=>{m.preventDefault(),i(t)},children:[s.jsx("textarea",{ref:f,rows:1,value:t,onChange:m=>n(m.target.value),onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),i(t))},...u}),s.jsx(I,{type:"submit",variant:"primary",disabled:c??(u.disabled||!t.trim()),children:a})]})});function ki({text:e}){return s.jsx("span",{className:"info-tip","data-tip":e,"data-tip-scout":!0,tabIndex:0,role:"img","aria-label":e,children:s.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[s.jsx("circle",{cx:"7",cy:"3.7",r:"1.3"}),s.jsx("path",{d:"M5.6 6.300H8v4.200h1v1.200H5v-1.200h1.200V7.500h-.6z"})]})})}function Ke({as:e="span",variant:t="chip",hot:n,size:i,className:a,children:c,title:d}){return s.jsx(e,{className:pe(t==="chip"?"chip-label":"mono-label",n&&"hot",i==="sm"&&(t==="chip"?"sm":"xs"),a),title:d,children:c})}const x$=e=>typeof e=="string"?{text:e}:e,j$=e=>pe(e.code&&"t-code",e.strong&&"strong",e.urgent&&"urgent",e.className);function B(e){const t=e.parts.filter(n=>!!n&&(typeof n=="string"||!!n.text)).map(x$);return!t.length&&!e.children?null:s.jsxs("span",{className:pe("meta-line t-meta",e.className),children:[t.map((n,i)=>s.jsxs("span",{children:[i>0&&s.jsx("span",{className:"sep",children:" · "}),s.jsx("span",{className:j$(n)||void 0,title:n.tip,children:n.text})]},i)),e.children]})}function $u(e){return s.jsxs("div",{className:"ds-load-failed",role:"alert",children:[s.jsx(B,{parts:[e.what,e.reason]}),s.jsx(I,{size:"sm",variant:"ghost",onClick:e.onRetry,children:"Retry"})]})}function yi(e){const t=Array.from({length:e.rows??0},(n,i)=>i);return s.jsxs("div",{className:pe("ds-loading",e.className),role:"status","aria-live":"polite",children:[s.jsxs("span",{className:"ds-loading-line t-meta",children:[s.jsx("span",{className:"ds-spinner","aria-hidden":"true"}),e.label]}),t.length>0&&s.jsx("ul",{className:"ds-skeleton-list","aria-hidden":"true",children:t.map(n=>s.jsxs("li",{className:"ds-skeleton-row",children:[s.jsx("span",{className:"ds-skeleton-bar title"}),s.jsx("span",{className:"ds-skeleton-bar meta"})]},n))})]})}const b$="M25.53 10.5 A11 11 0 1 1 16 5",S$="M20 5 L14.6 1.6 L14.6 8.4 Z";function Nr({variant:e="mark",state:t="ok",size:n=20,className:i="",title:a}){const c=n<=14?3:2.4;return s.jsxs("svg",{className:`scout-mark mm-${e} mm-${t} ${i}`,viewBox:"0 0 32 32",width:n,height:n,role:a?"img":void 0,"aria-label":a,"aria-hidden":a?void 0:!0,children:[e==="status"||e==="alert"?s.jsx("circle",{cx:"16",cy:"16",r:"11",fill:"none",stroke:"currentColor",strokeWidth:c,strokeDasharray:t==="syncing"?"5 3.6":void 0}):s.jsx("path",{d:b$,fill:"none",stroke:"currentColor",strokeWidth:c,strokeLinecap:"butt"}),(e==="mark"||e==="action")&&s.jsx("path",{d:S$,fill:"currentColor"}),e==="action"&&s.jsx("path",{d:"M13 11 L21.5 16 L13 21 Z",fill:"currentColor"}),(e==="mark"||e==="voice")&&s.jsx("circle",{cx:"16",cy:"16",r:e==="voice"?4:3.4,fill:"currentColor"}),e==="status"&&(t==="idle"?s.jsx("circle",{cx:"16",cy:"16",r:"3.4",fill:"none",stroke:"currentColor",strokeWidth:"1.6"}):s.jsx("circle",{cx:"16",cy:"16",r:"4.2",fill:"currentColor"})),e==="alert"&&s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"14.4",y:"8.5",width:"3.2",height:"9.5",fill:"currentColor"}),s.jsx("rect",{x:"14.4",y:"20.5",width:"3.2",height:"3.2",fill:"currentColor"})]})]})}function zd({parts:e,className:t,as:n="div"}){const i=e.filter(a=>a!=null&&a!==!1&&a!=="");return s.jsx(n,{className:pe("meta",t),children:i.map((a,c)=>s.jsxs("span",{children:[c>0&&" · ",a]},c))})}function ok({items:e,label:t="More actions"}){const[n,i]=y.useState(!1),a=y.useRef(null);return y.useEffect(()=>{if(!n)return;const c=u=>{var f;(f=a.current)!=null&&f.contains(u.target)||i(!1)},d=u=>{u.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",c),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",d)}},[n]),e.length?s.jsxs("span",{className:"more-menu",ref:a,children:[s.jsx("button",{type:"button",className:pe("btn more-btn",n&&"on"),"aria-label":t,"aria-haspopup":"menu","aria-expanded":n,onClick:()=>i(!n),children:"⋯"}),n&&s.jsx("span",{className:"more-list",role:"menu",children:e.map(c=>s.jsx("button",{type:"button",role:"menuitem",className:pe("more-item",c.danger&&"danger"),"data-tip":c.tip,onClick:()=>{i(!1),c.onSelect()},children:c.label},c.id))})]}):null}const Ap=()=>{const e=document.documentElement.dataset.theme;return e?e==="night":matchMedia("(prefers-color-scheme: dark)").matches};function ak(){const[e,t]=y.useState(Ap);return y.useEffect(()=>{const n=()=>t(Ap()),i=matchMedia("(prefers-color-scheme: dark)");i.addEventListener("change",n);const a=new MutationObserver(n);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{i.removeEventListener("change",n),a.disconnect()}},[]),e}function N$(){const e=()=>window.innerWidth>=1440?"wide":window.innerWidth>=1024?"laptop":"mobile",[t,n]=y.useState(e);return y.useEffect(()=>{const i=()=>n(e());return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]),t}const $$=15e3,Rp=["pointerdown","pointermove","keydown","wheel","touchstart"];function C$(e,t,n,i){const[a,c]=y.useState(null),[d,u]=y.useState(!1),[f,m]=y.useState(!1),g=y.useRef(),k=y.useRef(Date.now()),w=y.useRef(!1),b=n.awayMinutes*6e4,S=y.useRef(t);S.current=t;const x=y.useRef(i);x.current=i;const C=y.useCallback((_,Y)=>{const re=S.current;return Cb({snaps:Object.values(re.allSnaps),decisions:re.decisions,activity:re.activity,ledger:e.activity.ledger,since:q=>{var Z;return _[q]??Y??((Z=re.allSnaps[q])==null?void 0:Z.map.createdAt)??Date.now()},currentMapId:re.mapId,attention:x.current})},[e]),N=y.useCallback((_=Date.now())=>{var Y;return(Y=e.presence)==null?void 0:Y.markSeen(S.current.maps.map(re=>re.id),_)},[e]),P=y.useCallback(()=>{const _=e.presence;if(!_)return;const Y=_.lastSeenAny();if(Y!==void 0&&Date.now()-Y>=b){const re=_.snapshot();C(re,Y).changed&&(g.current={seen:re,any:Y},u(!0),n.enabled?c(re):m(!0))}N()},[e,b,n.enabled,C,N]);y.useEffect(()=>{!t.loaded||w.current||!e.presence||(w.current=!0,P())},[t.loaded,e,P]),y.useEffect(()=>{const _=()=>{const q=Date.now()-k.current>=b;k.current=Date.now(),q&&w.current&&document.visibilityState==="visible"&&P()},Y=()=>{if(document.visibilityState!=="visible"){w.current&&N(Date.now()-k.current<b?Date.now():k.current);return}k.current=Date.now(),w.current&&P()};for(const q of Rp)window.addEventListener(q,_,{passive:!0});document.addEventListener("visibilitychange",Y);const re=setInterval(()=>{w.current&&document.visibilityState==="visible"&&N(k.current)},$$);return()=>{for(const q of Rp)window.removeEventListener(q,_);document.removeEventListener("visibilitychange",Y),clearInterval(re)}},[b,P,N]);const D=y.useMemo(()=>{var _;return a?C(a,(_=g.current)==null?void 0:_.any):void 0},[a,C,t.allSnaps,t.decisions,t.activity,i]),M=y.useMemo(()=>D?Rb(D):"",[D]);y.useEffect(()=>{a&&m(!1)},[a]);let H="none";return f?H="new":d&&(H="seen"),{shown:a!==null,status:H,briefing:D,line:M,open:()=>{const _=g.current;_&&c(_.seen)},dismiss:()=>c(null)}}function T$(e){const[t,n]=y.useState(e.leases.leases);return y.useEffect(()=>e.leases.subscribe(n),[e]),t}const E$="That changed while you were on it, so nothing was written. It is reloaded now: look again, then redo the change.";function A$(e){var Q;const[t,n]=y.useState([]),[i,a]=y.useState(),[c,d]=y.useState(),[u,f]=y.useState({}),[m,g]=y.useState({}),[k,w]=y.useState(!1),[b,S]=y.useState(e.activity.snapshot),[x,C]=y.useState(e.monitor.health),N=T$(e);y.useEffect(()=>e.monitor.subscribe(C),[e]);const[P,D]=y.useState(null),[M,H]=y.useState(),[_,Y]=y.useState(),re=y.useRef(),q=y.useRef(),Z=y.useRef(new Set),Ae=y.useRef();Ae.current=c;const ye=y.useCallback(U=>{re.current=U,a(U),D(null)},[]),[be]=y.useState(gi),de=y.useCallback(async()=>{var je;const U=be.start(),E=await e.adapter.listMaps();let F=re.current;const ae=q.current;ae&&E.some(ge=>ge.id===ae)?(q.current=void 0,F=ae,F!==re.current&&ye(F)):(!F||!E.some(ge=>ge.id===F))&&(F=(je=vj(E)[0])==null?void 0:je.id,F!==re.current&&ye(F));const[fe,we]=await Promise.all([Promise.all(E.map(ge=>e.adapter.loadMap(ge.id))),Promise.all(E.map(ge=>e.adapter.listDecisions(ge.id)))]);U()&&(n(E),f(Object.fromEntries(fe.map(ge=>[ge.map.id,ge]))),g(Object.fromEntries(E.map((ge,Ne)=>[ge.id,we[Ne]]))),w(!0),d(fe.find(ge=>ge.map.id===F)))},[e,ye,be]);y.useEffect(()=>{let U,E=()=>{},F=()=>{},ae=!0;const fe=()=>{clearTimeout(U),U=setTimeout(()=>void de().catch(ve=>H(String(ve))),40)},we=os(fe),je=(ve,Ge)=>mn(ve)&&e.activity.isRemote(ve.id)&&(!Ge||!ve.mapId||ve.mapId===Ge),ge=ve=>{var Ge;return(Ge=Ae.current)==null?void 0:Ge.tickets.find(Rn=>Rn.id===ve)},Ne=ve=>{const Ge=Z0(ve,ge),Rn=ve.kind==="external.changed"&&e.activity.snapshot.sessions.some(As=>je(As,ve.mapId)),Ar=!("mapId"in ve)||!ve.mapId||ve.mapId===re.current||ve.kind==="map.created";Ge&&!Rn&&Ar&&e.activity.push(Ge),fe()};return e.ready.then(()=>{ae&&(E=e.adapter.subscribe(Ne),F=e.activity.subscribe(S),e.activity.push({source:"system",level:"ok",text:`Online · tracker ${e.adapter.label.toLowerCase()} · ${e.adapter.location}`}),de().catch(ve=>H(String(ve))))}),()=>{ae=!1,E(),F(),we(),clearTimeout(U)}},[e,de]),y.useEffect(()=>{i&&de().catch(U=>H(String(U)))},[i,de]),y.useEffect(()=>{for(const U of b.sessions)U.mode!=="chart"||!U.mapId||!e.activity.isRemote(U.id)||Z.current.has(U.id)||(Z.current.add(U.id),!(U.status!=="running"&&Date.now()-(U.endedAt??0)>6e4)&&(q.current=U.mapId,de().catch(E=>H(String(E)))))},[b.sessions,e,de]);const Re=(Q=b.pending[0])==null?void 0:Q.sessionId;y.useEffect(()=>{if(!Re)return;const U=E=>e.activity.snapshot.sessions.some(F=>F.id===E&&mn(F));Y(E=>U(E)?E:Re)},[Re,e]);const me=y.useCallback(async(U,E)=>{e.activity.push({source:"trail lead",agent:Ct,level:"warn",text:U});try{H(void 0),await E()}catch(F){const ae=F.stale===!0,fe=ae?E$:F.message??String(F);H(fe),e.activity.push({source:"trail lead",agent:Ct,level:"alert",text:`Rejected · ${fe}`}),ae&&de().catch(we=>H(String(we)))}},[e,de]),Se=y.useMemo(()=>x1({rt:e,guard:me,setMapId:ye,mapIdRef:re,snapRef:Ae,setChatSession:Y,setSelection:D}),[me,e,ye]),z=y.useMemo(()=>Object.values(u).flatMap(U=>ub(U,m[U.map.id]??[])).sort((U,E)=>E.decidedAt-U.decidedAt),[u,m]);return{maps:t,allSnaps:u,mapId:i,snap:c,activity:b,health:x,selection:P,setSelection:D,error:M,chatSession:_,decisions:z,leases:N,loaded:k,actions:Se}}function gt(e=1e3){const[t,n]=y.useState(Date.now());return y.useEffect(()=>{const i=setInterval(()=>n(Date.now()),e);return()=>clearInterval(i)},[e]),t}function R$(){const[e,t]=y.useState(bu),n=y.useCallback(i=>{t(a=>{const c={...a,...i};return localStorage.setItem(xa,JSON.stringify(c)),c})},[]);return[e,n]}const ck=()=>{var e,t;return!!((e=pt())!=null&&e.theme)&&!((t=pt())!=null&&t.themeSave)},lk=e=>{var t;return((t=pt())==null?void 0:t.theme)??e};function I$(e){const t=pt();t!=null&&t.themeSave&&(t.theme=e,Oa(e),fetch(t.themeSave,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({theme:e})}).catch(()=>{}))}function M$(){const[e,t]=R$(),[n,i]=y.useReducer(c=>c+1,0);y.useEffect(()=>Oa(lk(e.theme)),[e.theme,n]);const a=y.useCallback(c=>{c.theme&&(I$(c.theme),i()),t(c)},[t]);return[e,a]}function $r(){return y.useSyncExternalStore(ns.subscribe,ns.get)}function O$({className:e,size:t=18}){return s.jsx("span",{className:e,"aria-hidden":"true",children:s.jsx(Vv,{size:t,variant:ak()?"night":"crt"})})}function Fe({as:e="section",className:t,style:n,frameless:i,children:a,...c}){return s.jsx(e,{className:pe("panel",i&&"frameless",t),style:n,...c,children:a})}function wi({tone:e,className:t,children:n,title:i}){return s.jsx("span",{className:pe("pill",e,t),title:i,children:n})}function Cn({label:e,value:t,layout:n="stack",urgent:i,title:a,className:c}){return s.jsxs("span",{className:pe("readout",n!=="stack"&&n,i&&"urgent",c),title:a,children:[s.jsx("span",{className:"mono-label",children:e}),n==="inline"&&" ",s.jsx("b",{children:t})]})}function he(e){const{as:t="div",edge:n="neutral"}=e,i=e.onOpen?"button":"div";return s.jsxs(t,{className:pe("ds-row",`edge-${n}`,e.selected&&"on",e.className),children:[s.jsxs(i,{className:"ds-row-main",...e.onOpen?{type:"button",onClick:e.onOpen}:{},title:e.titleText,"aria-current":e.current,children:[s.jsxs("span",{className:"ds-row-top",children:[s.jsx("span",{className:"ds-row-title t-row-title",children:e.title}),e.trailing&&s.jsx("span",{className:"ds-row-trail t-meta",children:e.trailing})]}),e.context&&s.jsx("span",{className:"ds-row-context",children:e.context}),e.detail&&s.jsx("span",{className:"ds-row-detail t-meta",title:e.detailText,children:e.detail})]}),e.actions&&s.jsx("span",{className:"ds-row-actions",children:e.actions}),e.below&&s.jsx("div",{className:"ds-row-below",children:e.below})]})}const Jn="#c8581e",L$={map:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3 6l6-2.5 6 2.5 6-2.5v14.5L15 20.5 9 18l-6 2.5z"}),s.jsx("path",{d:"M9 3.5V18M15 6v14.5"}),s.jsx("path",{d:"M5.5 15c2-1 3-3 5-3.5s3-3 5-4",stroke:Jn,strokeDasharray:"2 2.2"})]}),note:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 3.5h14v13.5l-4 3.5H5z"}),s.jsx("path",{d:"M15 21v-4h4"}),s.jsx("path",{d:"M8.5 8h7M8.5 12h7",stroke:Jn})]}),book:s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("path",{d:"M12 6.5v14"}),s.jsx("path",{d:"M15 9.5l3-.5M15 13l3-.5",stroke:Jn})]}),flag:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M6 21.5V3"}),s.jsx("path",{d:"M6 4c4-1.5 7 1.5 12 0v9c-5 1.5-8-1.5-12 0z",fill:Jn,stroke:Jn})]}),tent:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 4L2.5 20h19z"}),s.jsx("path",{d:"M12 11l-4 9h8z",fill:Jn,stroke:Jn}),s.jsx("path",{d:"M12 4l-1.5-2M12 4l1.5-2"})]}),mailbox:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 21.500V14"}),s.jsx("path",{d:"M4 14V9.500A4.5 4.5 0 0 1 8.5 5h7A4.5 4.5 0 0 1 20 9.500V14z"}),s.jsx("path",{d:"M8.5 5A4.5 4.5 0 0 1 13 9.500V14"}),s.jsx("path",{d:"M16 10V6.500M16 6.500h3v2.500h-3",stroke:Jn})]})};function dk({name:e}){return s.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:L$[e]})}function yt({title:e,count:t,right:n,hot:i,sub:a,children:c,className:d,info:u,icon:f}){return s.jsxs("header",{className:pe("sec-h",a&&"sub",d),children:[c,f&&s.jsx(dk,{name:f}),e!==void 0&&s.jsx(Ke,{as:a?"h3":"h2",hot:i,children:e}),u&&s.jsx(ki,{text:u}),t,n!==void 0&&s.jsx("span",{className:"sec-h-right",children:n})]})}function rt(e){const{value:t,options:n,onChange:i}=e,[a,c]=y.useState(!1),[d,u]=y.useState(0),[f,m]=y.useState(),g=y.useRef(null),k=y.useRef(null),w=y.useId(),b=n.find(N=>N.value===t);y.useLayoutEffect(()=>{if(!a||!g.current)return;const N=g.current.getBoundingClientRect();m({left:N.left,top:N.bottom+4,minWidth:N.width})},[a]),y.useEffect(()=>{if(!a)return;const N=D=>{var M,H;D.target instanceof Node&&((M=k.current)!=null&&M.contains(D.target)||(H=g.current)!=null&&H.contains(D.target))||c(!1)},P=()=>c(!1);return document.addEventListener("mousedown",N),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0),()=>{document.removeEventListener("mousedown",N),window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}},[a]),y.useEffect(()=>{var N,P;a&&((P=(N=k.current)==null?void 0:N.querySelector(`[data-i="${d}"]`))==null||P.scrollIntoView({block:"nearest"}))},[a,d]);const S=()=>{u(Math.max(0,n.findIndex(N=>N.value===t))),c(!0)},x=N=>{var D;const P=n[N];c(!1),(D=g.current)==null||D.focus(),P&&P.value!==t&&i(P.value)},C=N=>{if(!a){["ArrowDown","ArrowUp","Enter"," "].includes(N.key)&&(N.preventDefault(),S());return}const P=D=>u(M=>(M+D+n.length)%n.length);if(N.key==="ArrowDown")P(1);else if(N.key==="ArrowUp")P(-1);else if(N.key==="Home")u(0);else if(N.key==="End")u(n.length-1);else if(N.key==="Enter"||N.key===" ")x(d);else{if(N.key==="Escape"||N.key==="Tab")return c(!1);if(N.key.length===1){const D=n.findIndex(M=>M.label.toLowerCase().startsWith(N.key.toLowerCase()));D>=0&&u(D);return}else return}N.preventDefault()};return s.jsxs(s.Fragment,{children:[s.jsxs("button",{ref:g,type:"button",className:pe("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?c(!1):S(),onKeyDown:C,children:[s.jsx("span",{className:"select-value",children:(b==null?void 0:b.label)??"—"}),s.jsx("span",{className:"select-caret","aria-hidden":"true"})]}),a&&f&&s.jsx("ul",{ref:k,id:w,className:"select-menu",role:"listbox",style:f,children:n.map((N,P)=>s.jsxs("li",{id:`${w}-${P}`,"data-i":P,role:"option","aria-selected":N.value===t,className:pe(P===d&&"active"),onMouseEnter:()=>u(P),onMouseDown:D=>D.preventDefault(),onClick:()=>x(P),children:[s.jsx("span",{className:"select-label",children:N.label}),N.hint&&s.jsx("span",{className:"select-hint",children:N.hint})]},N.value))})]})}const P$=350;function D$(){const[e,t]=y.useState(null);if(y.useEffect(()=>{let i=0,a=null;const c=()=>{window.clearTimeout(i),a=null,t(null)},d=g=>{const k=g.getAttribute("data-tip");if(!k)return;const w=g.getBoundingClientRect(),b=w.bottom+60>window.innerHeight;t({text:k,x:w.left+w.width/2,y:b?w.top-8:w.bottom+8,above:b,scout:g.hasAttribute("data-tip-scout")})},u=g=>{var b,S;const k=(S=(b=g.target)==null?void 0:b.closest)==null?void 0:S.call(b,"[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=g=>{if(g.pointerType==="touch")return;const k=u(g);k!==a&&(c(),k&&(a=k,i=window.setTimeout(()=>a===k&&d(k),g.type==="focusin"?0:P$)))},m=g=>{a&&!a.contains(g.relatedTarget)&&c()};return document.addEventListener("pointerover",f),document.addEventListener("pointerout",m),document.addEventListener("focusin",f),document.addEventListener("focusout",c),document.addEventListener("pointerdown",c),window.addEventListener("scroll",c,!0),window.addEventListener("keydown",c),()=>{c(),document.removeEventListener("pointerover",f),document.removeEventListener("pointerout",m),document.removeEventListener("focusin",f),document.removeEventListener("focusout",c),document.removeEventListener("pointerdown",c),window.removeEventListener("scroll",c,!0),window.removeEventListener("keydown",c)}},[]),!e)return null;const n=Math.min(Math.max(e.x,140),window.innerWidth-140);if(e.scout){const i=Math.min(Math.max(e.x-24,8),window.innerWidth-340);return s.jsxs("div",{className:`scout-tip ${e.above?"above":""}`,role:"tooltip",style:{left:i,top:e.y,transform:e.above?"translateY(-100%)":void 0},children:[s.jsx(Ra,{size:1,framed:!1,speaking:e.text,className:"scout-tip-face"}),s.jsx("p",{className:"scout-tip-bubble",children:e.text})]})}return s.jsx("div",{className:`tooltip ${e.above?"above":""}`,role:"tooltip",style:{left:n,top:e.y,transform:`translate(-50%, ${e.above?"-100%":"0"})`},children:e.text})}function Ua({as:e="span",className:t}){return s.jsxs(e,{className:t?`tt-wordmark ${t}`:"tt-wordmark",role:"img","aria-label":J.name,children:[J.name.toLowerCase(),s.jsx("span",{className:"tt-wordmark-dot","aria-hidden":"true"})]})}function _$(e){return e.bare?s.jsx("div",{className:`zone-b ${e.className??""}`,children:e.children}):s.jsxs(Fe,{className:`zone ${e.className??""}`,style:e.area?{gridArea:e.area}:void 0,children:[s.jsx(yt,{className:"zone-title",icon:e.icon,title:e.title,info:e.info,count:e.count,right:e.right??null}),s.jsx("div",{className:"zone-b",children:e.children})]})}function ni(e){return e.children.length?s.jsxs("div",{className:`bf-list ${e.urgent?"urgent":""}`,children:[s.jsx("span",{className:"mono-label",children:e.title}),s.jsx("ul",{children:e.children})]}):null}function Go(e){return s.jsx("li",{children:s.jsxs("button",{className:"bf-row",onClick:e.onClick,title:e.title,children:[s.jsx("span",{className:"key t-code",children:e.k}),s.jsx("span",{className:"t",children:e.text}),e.meta&&s.jsx("span",{className:"t-meta",children:e.meta})]})})}function dr(e){return s.jsxs(Vt,{tone:e.urgent?"urgent":void 0,className:`bf-tile ${e.className??""}`,children:[s.jsx("span",{className:"mono-label",children:e.label}),s.jsx("b",{children:e.value}),e.sub&&s.jsx(B,{parts:[],children:e.sub})]})}const B$=864e5;function F$(e,t){const n=new Date(e),i=n.toTimeString().slice(0,5),a=new Date(t).toDateString(),c=new Date(t-B$).toDateString();let d=` ${n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`;return n.toDateString()===a?d="":n.toDateString()===c&&(d=" yesterday"),`Since ${i}${d} · ${Gt(t-e)}`}function z$(e){const{briefing:t,bp:n,onClose:i}=e;y.useEffect(()=>{const k=w=>w.key==="Escape"&&i();return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[i]);const a=t==null?void 0:t.trails.flatMap(k=>k.waiting).sort((k,w)=>k.at-w.at)[0],c=t==null?void 0:t.totals,d=((t==null?void 0:t.trails.length)??0)>1,u=n==="mobile",f=k=>{var w,b;return k.ticketId&&((b=(w=e.snaps[k.mapId])==null?void 0:w.tickets.find(S=>S.id===k.ticketId))==null?void 0:b.title)||k.text},m=k=>{var w,b;return k.ticketId&&((b=(w=e.snaps[k.mapId])==null?void 0:w.tickets.find(S=>S.id===k.ticketId))==null?void 0:b.key)||k.agent},g=k=>{const w=(N,P)=>s.jsx(Go,{k:N.key,text:N.title,meta:P,onClick:()=>e.onTicket(k.mapId,N.id)},N.id),b=(N,P)=>s.jsx(Go,{k:N.id,text:N.summary||N.answer,title:N.risk?`${N.question}
|
|
136
|
+
|
|
137
|
+
${N.risk.reason}`:N.question,meta:P,onClick:()=>e.onDecision(N.id)},N.id),S=nS(k.agentDecisions).flatMap(N=>N.decisions.map(P=>b(P,N.label))),x=[s.jsx(ni,{title:"Done",children:k.done.map(N=>w(N))},"done"),s.jsx(ni,{title:"Ruled out",children:u?[]:k.ruledOut.map(N=>w(N))},"oos"),s.jsx(ni,{title:"Blocked",children:k.blocked.map(N=>w(N.ticket,`needs ${N.on.map(P=>P.key).join(", ")}`))},"blocked")],C=[s.jsx(ni,{title:"Waiting on you",urgent:!0,children:k.waiting.map(N=>s.jsx(Go,{k:m(N),text:f(N),meta:t.now-N.at<6e4?"now":Gt(t.now-N.at),title:N.text,onClick:()=>e.onAnswer(N)},N.id))},"waiting"),s.jsx(ni,{title:"Agent decisions",children:u?[]:S},"agent"),s.jsx(ni,{title:"Active sessions",children:u?[]:k.active.map(N=>{var D;const P=N.ticketId?(D=e.snaps[k.mapId])==null?void 0:D.tickets.find(M=>M.id===N.ticketId):void 0;return s.jsx(Go,{k:(P==null?void 0:P.key)??N.agent,text:P?`${P.title} · ${N.stepLabel}`:N.stepLabel,meta:`${N.step}/${N.total}`,onClick:()=>e.onSession(N)},N.id)})},"active")];return s.jsxs("section",{className:"bf-trail",children:[d&&s.jsxs("div",{className:"bf-trail-h",children:[s.jsx("span",{className:"key",children:k.key})," ",k.title]}),s.jsxs("div",{className:"bf-cols",children:[s.jsx("div",{children:x}),s.jsx("div",{children:C})]})]},k.mapId)};return s.jsx("div",{className:"scrim",onClick:i,children:s.jsxs(Fe,{as:"div",className:"dialog briefing",role:"dialog","aria-label":"While you were away",onClick:k=>k.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("h2",{className:"t-heading caps",children:"While you were away"}),t&&t.trails.length>0&&s.jsx(Ke,{className:"bf-since",children:F$(t.since,t.now)}),s.jsx("button",{className:"icon-btn",onClick:i,"aria-label":"Close",children:"×"})]}),s.jsxs(Vt,{className:"bf-scout",children:[s.jsx(Ra,{size:u?1.1:1.3,speaking:e.line||"Nothing new since you were last here.",caption:!1,framed:!1}),s.jsxs("div",{children:[s.jsx("span",{className:"mono-label",children:"Scout"}),s.jsx("p",{children:e.line||"Nothing new since you were last here."})]})]}),t&&c&&t.trails.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"bf-tiles",children:[s.jsx(dr,{label:"Done",value:c.done,sub:c.ruledOut?`${c.ruledOut} ruled out`:void 0}),s.jsx(dr,{label:"Blocked",value:c.blocked,sub:c.blocked?"Needs your answer":void 0}),s.jsx(dr,{label:"Waiting on you",value:c.waiting,sub:U$(c.oldestWaitMs),urgent:c.waiting>0}),s.jsx(dr,{label:"Agent decisions",value:c.agentDecisions,className:"opt"}),s.jsx(dr,{label:"Spend",value:ui(c.usage.costUsd),sub:`${Ma(c.usage.inputTokens+c.usage.outputTokens)} tokens · ${c.usage.sessions} sessions${c.active?` · ${c.active} active`:""}`})]}),s.jsx("div",{className:"bf-body",children:t.trails.map(g)})]}),s.jsxs("footer",{children:[s.jsx(I,{onClick:i,children:"Dismiss"}),a?s.jsxs(I,{variant:"urgent",onClick:()=>e.onAnswer(a),children:[s.jsx(Nr,{variant:"alert",size:13}),"Answer first decision"]}):s.jsx(I,{variant:"primary",onClick:e.onResume,children:"Resume trail"})]})]})})}function U$(e){if(e!==void 0)return e<6e4?"Just asked":`Oldest ${Gt(e)}`}function W$(e){const{brief:t,bp:n}=e;return t.shown?s.jsx(z$,{briefing:t.briefing,line:t.line,snaps:e.snaps,bp:n,onClose:t.dismiss,onTicket:(i,a)=>{t.dismiss(),e.openTicket(i,a)},onAnswer:i=>{t.dismiss(),e.openQuestion(i.id)},onSession:i=>{t.dismiss(),e.openChat(i.id,i.ticketId,i.mapId)},onDecision:i=>{t.dismiss(),e.openDecisions(i)},onResume:()=>{t.dismiss(),e.toMap()}}):null}function uk(e){return s.jsx(rn,{label:"Output",children:e.checks.map(t=>s.jsxs("figure",{className:"main-check-output",children:[s.jsxs("figcaption",{className:"t-meta",children:[s.jsx("span",{className:"t-code",children:t.argv.join(" ")})," · exit ",t.exitCode??"none"]}),s.jsx("pre",{className:"t-code",children:t.tail})]},t.name))})}function hk(e){const{buttons:t,menu:n}=e.actions;return!t.length&&!n.length&&!e.error?null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"actions main-checks-bar",children:[t.map(i=>s.jsx(I,{size:"sm","data-tip":i.tip,disabled:e.busy,onClick:i.onSelect,children:i.label},i.id)),s.jsx(ok,{items:n,label:"More about checks on main"})]}),e.error&&s.jsx("p",{className:"vf-err",children:e.error})]})}const pr=(e,t="Run checks on main again")=>({id:"run",label:t,tip:"Run the approved checks on the default branch's head now",onSelect:e.run});function H$(e,t){const n=e.map(c=>({id:`drop-${c}`,label:`Drop ${c} for this trail`,tip:`Completions on this trail stop running ${c}; you can restore it`,onSelect:()=>t.choose({kind:"drop",check:c})})),i={id:"fix-main",label:"Fix main first",tip:"Implementation keeps waiting; run the checks again once main is fixed",onSelect:()=>t.choose({kind:"fix-main"})},a={id:"proceed",label:"Start anyway",tip:"Known failures: a completion that fails only in these, the same way, isn't sent back",onSelect:()=>t.choose({kind:"proceed"})};return{buttons:[i,...n.slice(0,1),a],menu:[...n.slice(1),pr(t)]}}function K$(e,t){const n=e.choices.dropped.map(a=>({id:`restore-${a.name}`,label:`Restore ${a.name} for this trail`,onSelect:()=>t.choose({kind:"restore",check:a.name})})),i=e.choices.proceed?[{id:"unmark",label:"Unmark known failures",onSelect:()=>t.choose({kind:"undo-proceed"})}]:[];return[pr(t),...n,...i]}function G$(e,t){const{state:n}=e;switch(n.kind){case"off":case"not-run":return{buttons:[],menu:[]};case"running":{const i={id:"wait",label:"Wait for them",onSelect:()=>t.choose({kind:"undo-proceed"})},a={id:"proceed",label:"Start without waiting",tip:"Agents start building now; what fails on main is a known failure",onSelect:()=>t.choose({kind:"proceed"})};return n.proceeding?{buttons:[],menu:[i]}:{buttons:[a],menu:[]}}case"passed":return{buttons:[],menu:[pr(t)]};case"unavailable":return{buttons:[pr(t,"Run again")],menu:[]};case"failed":{if(!n.fixing)return H$(n.failing,t);const i={id:"choose",label:"Choose again",onSelect:()=>t.choose({kind:"undo-fix-main"})};return{buttons:[pr(t,"Run again")],menu:[i]}}case"accepted":return{buttons:[],menu:K$(e,t)};default:return n}}const Ud=e=>e.join(", "),V$=e=>`${Ud(e)} ${e.length===1?"fails":"fail"} on main`;function q$(e,t){if(!e)return[];const n=e.finishedAt??e.startedAt;return[e.branch??"main",...e.commit?[{text:e.commit.slice(0,8),code:!0}]:[],...e.runner?[`by ${e.runner}`]:[],Xe(t-n)]}function Q$(e,t){switch(e.kind){case"off":return{edge:"neutral",title:"Checks on main are off",why:e.reason};case"not-run":return{edge:"neutral",title:"Checks on main run before building starts"};case"running":return{edge:"neutral",title:"Running checks on main",why:e.proceeding?"Agents start without waiting":"Implementation waits for them"};case"passed":return{edge:"neutral",title:"Checks pass on main"};case"unavailable":return{edge:"attention",title:"Checks on main couldn't run",detail:e.reason};case"failed":return{edge:e.fixing?"attention":"urgent",title:V$(e.failing),why:Y$(e.fixing,t)};case"accepted":return{edge:"attention",title:J$(e.known,e.dropped)};default:return e}}function Y$(e,t){return e?"Waiting for main to be fixed":t?"Implementation waits for you":void 0}function J$(e,t){return[e.length?`Known failures on main: ${Ud(e)}`:"",t.length?`Dropped for this trail: ${Ud(t)}`:""].filter(Boolean).join(" · ")}function X$(e){const t=e==null?void 0:e.checks.find(i=>!i.passed),n=t==null?void 0:t.tail.split(`
|
|
138
|
+
`).filter(i=>i.trim());return n==null?void 0:n.at(-1)}function fk(e,t){const n=Q$(e.state,e.holds),i=n.detail??(e.state.kind==="failed"?X$(e.run):void 0);return{edge:n.edge,title:n.title,context:[...n.why?[n.why]:[],...q$(e.run,t)],...i?{detail:i}:{}}}const Z$=e=>{try{return JSON.parse(e)}catch{return}};function mk(e){const t=gi();let n=!1;const i=()=>{const u=t.start();e.load().then(f=>!n&&u()&&e.show(f),()=>{var f;return!n&&u()&&((f=e.failed)==null?void 0:f.call(e))})},{changed:a,events:c={}}=e,d=[os(i),...a?[Ba(u=>a(u)&&i())]:[],...Object.entries(c).map(([u,f])=>vi(u,m=>f(Z$(m))&&i()))];return i(),{reload:i,pushed:()=>t.pushed(),stop:()=>{n=!0;for(const u of d)u()}}}function Le(e){const t=y.useRef(e);t.current=e;const n=y.useRef(),i=y.useRef(e.version),{view:a,version:c}=e;y.useEffect(()=>{const f=t.current;i.current=f.version;const m=Object.keys(f.events??{}),g=mk({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,b;return((b=(w=t.current).changed)==null?void 0:b.call(w,k))===!0}}:{},events:Object.fromEntries(m.map(k=>[k,w=>{var b,S;return((S=(b=t.current.events)==null?void 0:b[k])==null?void 0:S.call(b,w))===!0}]))});return n.current=g,()=>{g.stop(),n.current=void 0}},[a]),y.useEffect(()=>{var f;Object.is(i.current,c)||(i.current=c,(f=n.current)==null||f.reload())},[c]);const d=y.useCallback(()=>{var f;return(f=n.current)==null?void 0:f.reload()},[]),u=y.useCallback(()=>{var f;return(f=n.current)==null?void 0:f.pushed()},[]);return{reload:d,pushed:u}}async function Wa(e){return e?e.ok?void 0:(await e.json().catch(()=>({}))).error??`HTTP ${e.status}`:"Could not reach the Lookout"}const pk=()=>`${ie()}/main-checks`,eC=(e,t)=>fetch(`${pk()}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).catch(()=>{});function Cu(e){const[t,n]=y.useState(),[i,a]=y.useState(),[c,d]=y.useState(!1),{reload:u,pushed:f}=Le({view:e,load:async()=>{if(!e)return;const g=await fetch(`${pk()}?mapId=${encodeURIComponent(e)}`);return g.ok?await g.json():void 0},show:n,events:{"main-checks":()=>!0}}),m=async(g,k)=>{d(!0);const w=await eC(g,k);d(!1);const b=await Wa(w);if(a(b),b)return u();g==="/choose"?(f(),n(await w.json())):u()};return{view:t,error:i,busy:c,choose:g=>m("/choose",{mapId:e,choice:g}),run:()=>m("/run",{mapId:e})}}function gk(e){var d;const t=Cu(e.mapId),n=t.view;if(!n||n.state.kind==="off")return null;const i=fk(n,e.now),a=G$(n,{choose:u=>void t.choose(u),run:()=>void t.run()}),c=((d=n.run)==null?void 0:d.checks.filter(u=>!u.passed))??[];return s.jsxs(sn,{label:"Checks on main",className:"main-checks",children:[s.jsx(he,{edge:i.edge,title:i.title,context:s.jsx(B,{parts:i.context}),detail:i.detail,detailText:i.detail,below:s.jsx(hk,{actions:a,busy:t.busy,error:t.error})}),c.length>0&&s.jsx(uk,{checks:c})]})}function tC(e){const t=Cu(e.mapId),n=gt(3e4),i=t.view;if(!i)return null;const a=fk(i,n),c=i.state.kind==="off";return s.jsxs("div",{className:"main-checks-setting",children:[s.jsx("span",{className:"set-field-label",children:"Checks on main"}),s.jsx("p",{className:"t-body",children:a.title}),s.jsx(B,{parts:a.context}),s.jsx("div",{className:"actions",children:s.jsx(I,{size:"sm",disabled:c||t.busy||i.state.kind==="running",onClick:()=>void t.run(),children:"Run checks on main"})}),t.error&&s.jsx("p",{className:"vf-err",children:t.error}),s.jsx("span",{className:"set-hint t-meta",children:"Before agents build, the approved checks run once on the default branch, in a worktree next to the repo. A check that already fails there is yours to decide on: fix main first, drop it for the trail, or start anyway."})]})}function nC(e,t){if(!(!e||e.state.kind==="off")){if(t)return"needs";switch(e.state.kind){case"failed":return e.state.fixing?"attention":"needs";case"unavailable":case"accepted":return"attention";case"passed":return"passed";case"running":return"running";case"not-run":return"neutral";default:return e.state}}}const ad=e=>({id:"run",label:"Run again",tip:"Run the approved checks on the default branch with every merge now",onSelect:e.run}),sC=e=>({id:"run-now",label:"Run now on main as it is",tip:"Before everything is merged: shows what fails on main today. It doesn't verify the trail",onSelect:e.run});function iC(e,t){const{state:n,run:i}=e;switch(n.kind){case"off":case"due":case"running":return{buttons:[],menu:[]};case"failed":return{buttons:[{id:"fix-ticket",label:"Add a fix ticket",tip:"A task on this trail with the failing checks and their output, for agents to pick up",onSelect:()=>i&&t.fixTicket(i.id)},ad(t)],menu:[]};case"unavailable":return{buttons:[ad(t)],menu:[]};case"passed":return{buttons:[],menu:[ad(t)]};case"waiting":return{buttons:[],menu:[sC(t)]};default:return n}}function Ip(e,t,n=!1){return[...n?[]:[e.branch??"main"],...e.commit&&!n?[{text:e.commit.slice(0,7),code:!0}]:[],...e.runner?[`by ${e.runner}`]:[],Xe(t-(e.finishedAt??e.startedAt))]}function rC(e,t){var n;switch(e.kind){case"off":return{edge:"neutral",title:"Checks on main together are off",detail:e.reason};case"waiting":return{edge:"neutral",title:"Checks on main run once everything is merged",detail:e.reason};case"due":case"running":return{edge:"neutral",title:"Running the checks on main with every merge"};case"passed":return{edge:"neutral",title:`Verified together on ${(t==null?void 0:t.branch)??"main"} at ${(n=t==null?void 0:t.commit)==null?void 0:n.slice(0,7)}`};case"failed":{const i=e.failing.length===1?"fails":"fail";return{edge:"urgent",title:`${e.failing.join(", ")} ${i} on main with every merge`}}case"unavailable":return{edge:"attention",title:"Checks on main together couldn't run",detail:e.reason};default:return e}}const oC=["passed","failed","running","unavailable"],aC={pass:"passed",fail:"failed",running:"running",unavailable:"couldn't run"};function cC(e,t){const n=e.run;if(!n)return[];if(oC.includes(e.state.kind))return Ip(n,t,e.state.kind==="passed");const i=n.complete?"":", before everything was merged";return[`Last run ${aC[n.result]}${i}`,...Ip(n,t)]}function lC(e,t){const n=rC(e.state,e.run);return{edge:n.edge,title:n.title,context:cC(e,t),...n.detail?{detail:n.detail}:{}}}const vk=()=>`${ie()}/trail-checks`,dC=(e,t)=>fetch(`${vk()}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).catch(()=>{});function kk(e){const[t,n]=y.useState(),[i,a]=y.useState(),[c,d]=y.useState(!1),{reload:u}=Le({view:e,load:async()=>{if(!e)return;const m=await fetch(`${vk()}?mapId=${encodeURIComponent(e)}`);return m.ok?await m.json():void 0},show:n,events:{"trail-checks":()=>!0}}),f=async(m,g)=>{d(!0);const k=await dC(m,g);d(!1),a(await Wa(k)),u()};return{view:t,error:i,busy:c,run:()=>f("/run",{mapId:e}),fixTicket:m=>f("/fix-ticket",{mapId:e,runId:m})}}function yk(e){var f;const t=kk(e.mapId),n=t.view,i=(n==null?void 0:n.state.kind)==="failed",{onUrgent:a}=e;if(y.useEffect(()=>a==null?void 0:a(i),[a,i]),!n||n.state.kind==="off")return null;const c=lC(n,e.now),d=iC(n,{run:()=>void t.run(),fixTicket:m=>void t.fixTicket(m)}),u=n.state.kind==="running"?[]:((f=n.run)==null?void 0:f.checks.filter(m=>!m.passed))??[];return s.jsxs(sn,{label:"Checks on main, together",className:"trail-checks",children:[s.jsx(he,{edge:c.edge,title:c.title,context:s.jsx(B,{parts:c.context}),detail:c.detail,detailText:c.detail,below:s.jsx(hk,{actions:d,busy:t.busy,error:t.error})}),u.length>0&&s.jsx(uk,{checks:u})]})}const uC="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.",wk=()=>{var e;return((e=pt())==null?void 0:e.highRisk)===!1};function hC(e){var t;return(t=e.options)!=null&&t.length?s.jsx("div",{className:"suggest",children:e.options.map(n=>s.jsx("button",{className:"chip",onClick:()=>e.onPick(n),children:n},n))}):null}function xk(e){const{pending:t}=e;return t!=null&&t.lookoutOnly&&wk()?s.jsx("p",{className:"vf-intro",children:uC}):s.jsxs(s.Fragment,{children:[s.jsx(hC,{options:t==null?void 0:t.suggestions,onPick:e.onSend}),s.jsx(za,{ref:e.inputRef,className:"comms-input",value:e.draft,onValueChange:e.onDraft,onSubmit:e.onSend,disabled:!t,placeholder:t?"Answer":""})]})}const fC=["awaiting","blocked","trail.done","resolved"];async function Xn(e,t="GET",n){const i=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:n===void 0?void 0:JSON.stringify(n)}),a=await i.json().catch(()=>({}));if(!i.ok&&!a.status)throw new Error(a.error??`request failed (${i.status})`);return a}function mC(e){const t=`${e}/slack`;return{get:()=>Xn(t),connectStart:n=>Xn(`${t}/connect/start`,"POST",{project:n}),connectPreview:n=>Xn(`${t}/connect/preview`,"POST",{code:n}),connectFinish:n=>Xn(`${t}/connect/finish`,"POST",{code:n}),connectCancel:()=>Xn(`${t}/connect/cancel`,"POST",{}),disconnect:()=>Xn(`${t}/connect`,"DELETE"),update:n=>Xn(`${t}/settings`,"PUT",n),members:()=>Xn(`${t}/members`).then(n=>n.members)}}const Tn=mC(ie());function pC(e){const{who:t}=e;return s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"sl-lead",children:["Connect as ",s.jsxs("b",{children:["@",t.user.name??t.user.id]})," in ",s.jsx("b",{children:t.workspace.name}),"? That Slack account becomes Scout's owner for this Teamtrail: questions and approvals reach it."]}),s.jsxs("div",{className:"c-actions",children:[s.jsx(I,{size:"sm",variant:"primary",onClick:e.onConnect,children:"Connect"}),s.jsx(I,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]})]})}const gC=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function vC({problem:e}){const t=e.failures===1?"A message was":`${e.failures} messages were`;return s.jsxs("div",{className:"test-line warn",title:e.code,children:[t," not delivered (last ",gC(e.at),"). ",e.message]})}function Wd(e){const[t,n]=y.useState(!1),i=()=>{n(!0),Tn.connectStart(Sr()).then(a=>location.assign(a.url),a=>{n(!1),e.onError(a.message)})};return s.jsx(I,{size:"sm",variant:"primary",disabled:t,onClick:i,children:e.again?"Add Scout to Slack again":"Add Scout to Slack"})}function kC(e){return s.jsxs("div",{className:"test-line mentions-hint",children:[s.jsx("span",{children:"Reconnect to allow @Scout mentions: Slack needs one more permission for them."}),s.jsx(Wd,{again:!0,onError:e.onError})]})}function yC({s:e,connecting:t}){return t?s.jsx("p",{className:"sl-lead",children:"Connecting Scout…"}):s.jsxs(s.Fragment,{children:[s.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&&s.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 wC(e){return s.jsx("a",{className:["btn",e.primary&&"primary",e.small&&"sm"].filter(Boolean).join(" "),href:pn(e.href,["slack:"]),target:"_blank",rel:"noreferrer",onClick:e.onClick,children:e.children})}function Mp({onRemoved:e}){const[t,n]=y.useState(!1);if(!t)return s.jsx(I,{size:"sm",variant:"ghost",onClick:()=>n(!0),children:"Disconnect"});const i=()=>void Tn.disconnect().then(a=>{n(!1),e(a)},()=>{});return s.jsxs(s.Fragment,{children:[s.jsx(I,{size:"sm",variant:"danger",onClick:i,children:"Disconnect and forget Slack settings"}),s.jsx(I,{size:"sm",variant:"ghost",onClick:()=>n(!1),children:"Keep"})]})}function xC(e){const{s:t}=e,n=t.state==="auth-error"||t.state==="other-service";return t.connected?s.jsxs("div",{className:"c-actions",children:[n?s.jsx(Wd,{again:!0,onError:e.onError}):s.jsx(I,{size:"sm",on:t.enabled,onClick:e.onToggle,children:t.enabled?"Turn off":"Turn on"}),t.links.homeWeb&&s.jsx(wC,{small:!0,href:t.links.homeWeb,children:"Open Scout in Slack"}),s.jsx(Mp,{onRemoved:e.onChanged})]}):s.jsxs("div",{className:"c-actions",children:[!e.busy&&s.jsx(Wd,{again:t.legacy,onError:e.onError}),t.legacy&&s.jsx(Mp,{onRemoved:e.onChanged})]})}const jC={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function bC({s:e}){const[t,n]=SC(e);return s.jsxs("div",{className:`sync-line ${t}`,title:e.error,children:[s.jsx("span",{className:"dot"}),s.jsx("span",{children:n})]})}function SC(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 ${J.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 NC(e){const{s:t,back:n}=e,i=!!n.confirm&&!t.connected;return s.jsxs(Vt,{className:CC(t),children:[s.jsxs("div",{className:"card-row",children:[s.jsx("b",{className:"choice-title t-row-title",children:"Scout in Slack"}),t.connected&&s.jsx(wi,{className:t.enabled?"on":"",children:t.enabled?"On":"Off"})]}),t.connected&&s.jsx("div",{className:"c-loc",children:$C(t)}),t.connected&&s.jsx(bC,{s:t}),t.connected&&s.jsx("div",{className:"t-meta",children:"Scout answers in Slack only while this Teamtrail is running."}),t.delivery&&s.jsx(vC,{problem:t.delivery}),t.connected&&t.mentions===!1&&!i&&s.jsx(kC,{onError:e.onError}),!t.connected&&!i&&s.jsx(yC,{s:t,connecting:n.busy}),i&&s.jsx(pC,{who:n.confirm,onConnect:n.connect,onCancel:n.cancel}),e.error&&s.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]}),!i&&s.jsx(xC,{s:t,busy:n.busy,onError:e.onError,onChanged:e.onChanged,onToggle:e.onToggle})]})}function $C(e){var n,i,a;const t=(i=(n=e.workspace)==null?void 0:n.url)==null?void 0:i.replace(/^https?:\/\/|\/$/g,"");return[(a=e.workspace)==null?void 0:a.name,t].filter(Boolean).join(" · ")}function CC(e){const t=e.connected&&e.enabled?"active":"",n=e.connected?"":"open";return`connector ${t} ${n}`}function TC(e){const[t,n]=y.useState(e.value==="dm"?"":e.value),i=/^[CG][A-Z0-9]{6,}$/.test(t.trim());return s.jsxs("form",{className:"sl-field",onSubmit:a=>{a.preventDefault(),i&&e.onSave(t.trim())},children:[s.jsx("input",{value:t,spellCheck:!1,placeholder:"Channel ID, e.g. C0123ABCD","aria-label":"Channel ID",onChange:a=>n(a.target.value)}),s.jsx(I,{type:"submit",disabled:!i||t.trim()===e.value,children:"Save"})]})}function EC(e){const[t,n]=y.useState(),[i,a]=y.useState();y.useEffect(()=>{Tn.members().then(n,u=>a(u.message))},[]);const c=new Set(e.owners.map(u=>u.id)),d=new Set(e.value.map(u=>u.id));return i?s.jsxs("div",{className:"test-line alert",children:["✕ ",i]}):t?s.jsx("div",{className:"choice-row compact sl-members",children:t.map(u=>s.jsx(ct,{on:c.has(u.id)||d.has(u.id),disabled:c.has(u.id),title:`@${u.name??u.id}`,sub:c.has(u.id)?"Owner":void 0,onClick:()=>e.onChange(d.has(u.id)?e.value.filter(f=>f.id!==u.id):[...e.value,u])},u.id))}):s.jsx("span",{className:"t-meta",children:"Loading members…"})}function AC(e){const{s:t,patch:n}=e,[i,a]=y.useState(!1),c=new Set(t.notify.events),d=i||t.notify.target!=="dm",u=t.owners[0],f=m=>{const g=c.has(m)?t.notify.events.filter(k=>k!==m):[...t.notify.events,m];n({notify:{events:g}})};return s.jsxs("div",{className:"sl-groups",children:[s.jsxs("div",{className:"sl-group",children:[s.jsx(Ke,{variant:"plain",size:"sm",children:"Owner"}),s.jsxs("div",{className:"sl-owner",children:[s.jsxs("b",{children:["@",(u==null?void 0:u.name)??(u==null?void 0:u.id)]}),s.jsx("span",{className:"t-meta",children:"Added Scout from this machine"})]})]}),s.jsxs("div",{className:"sl-group",children:[s.jsx(Ke,{variant:"plain",size:"sm",children:"Allowed users"}),s.jsx(EC,{value:t.allow,owners:t.owners,onChange:m=>n({allow:m})},t.state)]}),s.jsxs("div",{className:"sl-group",children:[s.jsx(Ke,{variant:"plain",size:"sm",children:"Notify"}),s.jsxs("div",{className:"choice-row compact",children:[s.jsx(ct,{on:!d,title:"DM to owner",onClick:()=>{a(!1),n({notify:{target:"dm",detail:"full"}})}}),s.jsx(ct,{on:d,title:"Channel",sub:t.notify.target!=="dm"?t.notify.target:void 0,onClick:()=>a(!0)})]}),d&&s.jsxs(s.Fragment,{children:[s.jsx(Je,{label:"Channel ID (invite @Scout there first)",children:s.jsx(TC,{value:t.notify.target,onSave:m=>n({notify:{target:m}})})}),s.jsxs("div",{className:"choice-row compact",children:[s.jsx(ct,{on:t.notify.detail==="full",title:"Full questions",onClick:()=>n({notify:{detail:"full"}})}),s.jsx(ct,{on:t.notify.detail==="titles-only",title:"Titles only",onClick:()=>n({notify:{detail:"titles-only"}})})]})]}),s.jsx("div",{className:"choice-row compact",children:fC.map(m=>s.jsx(ct,{on:c.has(m),title:jC[m],onClick:()=>f(m)},m))})]}),s.jsx(zd,{className:"dim",parts:[`${t.command} decide`,`${t.command} status`,`${t.command} inbox`,"Save as decision on any message"]})]})}function RC(){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 cd={code:RC()};function IC(e){const[t,n]=y.useState(),[i,a]=y.useState(),[c,d]=y.useState(),[u,f]=y.useState(!!cd.code),m=k=>d(k.message);y.useEffect(()=>{const k=cd.code;k&&(cd.code=void 0,n(k),Tn.connectPreview(k).then(a,m).finally(()=>f(!1)))},[]);const g=k=>{f(!0),a(void 0),k.then(e,m).finally(()=>f(!1))};return{busy:u,error:c,confirm:i,connect:()=>t&&g(Tn.connectFinish(t)),cancel:()=>g(Tn.connectCancel())}}function Tu(e=0){const[t,n]=y.useState(),i=y.useCallback(()=>Tn.get().then(n,()=>n(null)),[]);return y.useEffect(()=>{if(i(),!e)return;const a=setInterval(()=>void i(),e);return()=>clearInterval(a)},[i,e]),[t,n]}function MC(e){const[t,n]=Tu(3e3),i=IC(n),[a,c]=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 u=f=>Tn.update(f).then(n,()=>{});return s.jsxs("div",{ref:d,className:"slack-settings",children:[s.jsx(NC,{s:t,back:i,error:a??i.error,onError:c,onToggle:()=>void u({enabled:!t.enabled}),onChanged:f=>{c(void 0),n(f)}}),t.connected&&s.jsx(AC,{s:t,patch:f=>void u(f)})]})}function OC(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 Op;function LC(){return Op??(Op=Tn.get().then(e=>({owners:e.owners??[],allow:e.allow??[]}),()=>{})),Op}function Cr(){const[e,t]=y.useState();return y.useEffect(()=>{let n=!0;return LC().then(i=>n&&t(i)),()=>{n=!1}},[]),e}function PC(e){const{m:t}=e,n=Cr(),i=t.from==="human"?"human":"agent";return s.jsxs("div",{className:`msg from-${t.from} voice-${i}`,children:[s.jsx(B,{parts:[fi(t.author,n),w0(t),Ia(t.at)]}),s.jsx("div",{className:"msg-text",children:t.text}),e.stillOpen&&s.jsx("button",{className:"answer-this t-meta",onClick:e.onAnswerThis,children:"Answer this"})]})}function DC(e){const{ticket:t}=e;return s.jsxs("div",{className:"comms-ticket",children:[s.jsxs("div",{className:"t-title",title:t&&`${t.key} ${t.title}`,children:[s.jsx("span",{className:"key",children:t==null?void 0:t.key})," ",t==null?void 0:t.title]}),s.jsx(B,{parts:[e.trail,e.agent]})]})}function _C({id:e,text:t}){const[n,i]=y.useState(),a=n!==e;return s.jsx(Ra,{size:.6,framed:!1,state:a?"speaking":"alert",speaking:a?t.slice(0,60):void 0,onSpeakEnd:()=>i(e),className:"q-avatar"})}function BC(e){const{q:t}=e;return s.jsxs("div",{className:"msg open-q",children:[s.jsx(B,{parts:[t.agent,Ia(t.at)]}),s.jsx(_C,{id:e.chatId??t.id,text:t.text}),s.jsx("div",{className:"msg-text",children:t.text}),t.stakes&&s.jsx(B,{parts:[{text:t.stakes,strong:!0}]}),t.precedent&&s.jsx(B,{className:"open-q-precedent",parts:[t.precedent]})]})}function FC(e){const{activity:t,sessionId:n}=e,[i,a]=y.useState(""),[c,d]=y.useState(),u=y.useRef(null),f=y.useRef(null),m=t.sessions.find(D=>D.id===n),g=t.chats.filter(D=>D.sessionId===n),k=p$(t.pending,n,c??e.questionId),w=new Set(t.pending.filter(D=>D.sessionId===n).map(D=>D.id)),b=g.find(D=>!!k&&D.questionId===k.id),S=g.filter(D=>D!==b),x=m?e.snaps[m.mapId]:void 0,C=m!=null&&m.ticketId?x==null?void 0:x.tickets.find(D=>D.id===m.ticketId):void 0;y.useEffect(()=>{const D=u.current;D==null||D.scrollTo({top:D.scrollHeight,behavior:"smooth"})},[S.length,k==null?void 0:k.id]),y.useEffect(()=>{var D;k&&!e.onBack&&((D=f.current)==null||D.focus({preventScroll:!0}))},[k==null?void 0:k.id,e.onBack]);const N=D=>{!k||!D.trim()||(e.onAnswer(k.id,D.trim()),a(""))},P=zC(m,!!k);return s.jsxs("div",{className:`comms ${k?"asking":""}`,children:[s.jsx(yt,{title:"HITL line",right:m?s.jsx("span",{className:`status ${k?"urgent":""}`,children:P}):void 0,children:e.onBack&&s.jsx("button",{className:"back",onClick:e.onBack,"aria-label":"Back to inbox",children:"‹ Inbox"})}),m?s.jsxs(s.Fragment,{children:[s.jsx(DC,{ticket:C,trail:x==null?void 0:x.map.title,agent:m.agent}),s.jsx("div",{className:"comms-log",ref:u,children:S.map(D=>s.jsx(PC,{m:D,stillOpen:!!D.questionId&&w.has(D.questionId),onAnswerThis:()=>d(D.questionId)},D.id))}),k&&s.jsx(BC,{q:k,chatId:b==null?void 0:b.id}),s.jsx(xk,{pending:k,draft:i,onDraft:a,onSend:N,inputRef:f})]}):s.jsx(Te,{children:"No conversation"})]})}function zC(e,t){return e?t?"Your answer is needed":mn(e)?`${e.agent} is working…`:e.status==="done"?"Resolved · ticket closed":"Session ended":""}async function UC(e){const[t,n]=e.ref.split("+"),i=await fetch(`${ie()}/workspaces/integration`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,a:t,b:n})});return i.ok?void 0:(await i.json().catch(()=>({}))).error??`Adding failed (${i.status})`}function WC({item:e}){const[t,n]=y.useState(!1),[i,a]=y.useState(),c=()=>{n(!0),a(void 0),UC(e).then(a,d=>a(d.message)).finally(()=>n(!1))};return s.jsxs("div",{className:"att-action",children:[s.jsx(I,{size:"sm",className:"integration-add",disabled:t,onClick:c,children:t?"Adding…":"Add integration ticket"}),i&&s.jsx("span",{className:"vf-err",children:i})]})}async function HC(e,t){const n=e.ref.slice(0,e.ref.lastIndexOf(":")),i=await fetch(`${ie()}/trackers/settings/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,issueId:n,choice:t})});return i.ok?void 0:(await i.json().catch(()=>({}))).error??`Saving failed (${i.status})`}function KC({item:e}){const[t,n]=y.useState(!1),[i,a]=y.useState(),c=d=>{n(!0),a(void 0),HC(e,d).then(a,u=>a(u.message)).finally(()=>n(!1))};return s.jsxs("div",{className:"att-action",children:[s.jsx(I,{size:"sm",disabled:t,onClick:()=>c("stricter"),children:"Keep stricter"}),s.jsx(I,{size:"sm",disabled:t,onClick:()=>c("as-is"),children:"Accept as is"}),i&&s.jsx("span",{className:"vf-err",children:i})]})}function GC({item:e}){return e.kind==="integration"?s.jsx(WC,{item:e}):e.kind==="tracker-settings"&&e.ref.includes(":")?s.jsx(KC,{item:e}):null}const VC=/(\S*\/\S*|#\d+)/g;function qC({reasons:e}){return e.length?s.jsx("span",{className:"reason-line",children:e.map((t,n)=>s.jsxs("span",{children:[n>0&&s.jsx("span",{className:"sep",children:" · "}),t.split(VC).map((i,a)=>a%2===1?s.jsx("span",{className:"t-code",children:i},a):i)]},t))}):null}const Eu={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","main-checks":"Main","trail-checks":"Together",merge:"Merge",escape:"Came back"},QC={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","main-checks":"checks failing on main","trail-checks":"trails failing on main together",merge:"pull requests ready to merge",escape:"verified work that came back"},YC=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],JC=["blocked","flag","stalled","policy","reroute","overlap","integration","model"];function Tr(e,t){return t||e.urgency==="blocking"?"urgent":JC.includes(e.kind)?"attention":"neutral"}const XC=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function Au(e){return e.reasons.filter(t=>!XC.some(n=>n.test(t)))}function jk(e){const{item:t,snap:n}=e,i=n==null?void 0:n.tickets.find(u=>u.id===t.ticketId),a=t.kind==="question"&&t.agent?`${t.agent} asks`:Eu[t.kind],c=[];t.urgency==="blocking"&&c.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),c.push({text:a,strong:!0});const d=i&&ZC(t.title,i);return d&&c.push(d),e.otherTrail&&c.push((n==null?void 0:n.map.title)??t.mapId),c}function ZC(e,t){if(!e.includes(t.key))return e.includes(t.title)?{text:t.key,code:!0}:`${t.key} ${t.title}`}function eT(e){const[t,n]=y.useState(!1),i=a=>{n(!1),a()};return s.jsxs("span",{className:"snooze",children:[s.jsx("button",{type:"button",className:"snooze-btn","aria-expanded":t,"aria-label":`Later: ${e.title}`,onClick:()=>n(!t),children:"Later"}),t&&s.jsxs("span",{className:"snooze-menu",role:"menu",children:[YC.map(a=>s.jsx("button",{type:"button",role:"menuitem",onClick:()=>i(()=>e.onSnooze(a.minutes)),children:a.label},a.minutes)),e.canDismiss&&s.jsx("button",{type:"button",role:"menuitem",onClick:()=>i(e.onDismiss),children:"Set aside"})]})]})}const tT=15e3;function nT(e){const{item:t}=e,n=t.title.split(`
|
|
139
|
+
`)[0],i=Au(t),a=e.now-t.since<tT;return s.jsx(he,{as:"li",className:`att-item k-${t.kind} u-${t.urgency} ${e.selected?"sel":""} ${a?"incoming":""}`,edge:Tr(t,e.interrupting),selected:e.selected,title:n,titleText:t.title,context:s.jsx(B,{parts:jk({item:t,snap:e.snap,otherTrail:e.otherTrail})}),detail:i.length>0&&s.jsx(qC,{reasons:i}),detailText:i.join(`
|
|
140
|
+
`),trailing:Xe(e.now-t.since),onOpen:e.onOpen,actions:s.jsx(eT,{title:t.title,canDismiss:rS(t),onSnooze:e.onSnooze,onDismiss:e.onDismiss}),below:s.jsx(GC,{item:t})})}function sT(e){const t=[];for(const n of e){const i=t.at(-1);(i==null?void 0:i.key)===n.batchKey?i.items.push(n):t.push({key:n.batchKey,kind:n.kind,mapId:n.mapId,items:[n]})}return t}const iT={question:"inbox-list",approval:"inbox-list approvals"};function rT(e){const{batch:t}=e,n=t.items.length>1,i=t.kind==="question"?"answer together":"review together",a=[`${t.items.length} ${QC[t.kind]}`,e.trail,i].filter(Boolean);return s.jsxs("div",{className:`att-batch ${n?"many":""}`,children:[n&&s.jsx("span",{className:"batch-head t-label",children:a.join(" · ")}),s.jsx("ul",{className:`att-list ${iT[t.kind]??""}`,children:e.children})]})}function ld(e,t){e.ticketId?t.openTicket(e.mapId,e.ticketId):t.selectTrail(e.mapId)}const oT=new Set(["approval","blocked","policy","precedent","flag","stalled","hitl-ready","overlap","integration","model","tracker-settings"]);function Ru(e,t){if(oT.has(e.kind))return ld(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();case"main-checks":return t.openMainChecks(e.mapId);case"trail-checks":return t.openTrailChecks(e.mapId);case"escape":return e.rule?t.openRule(e.rule):ld(e,t);default:return ld(e,t)}}function bk(e){const t=gt(1e3),{view:n}=e;if(!n.items.length)return s.jsx(An,{title:"Nothing waiting on you",hint:n.hidden?`${n.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 i=Object.keys(e.snaps).length>1,a=u=>i&&u!==e.currentMapId,c=new Set(n.interrupting),d=u=>{var f;return(f=e.pending.find(m=>m.id===u))==null?void 0:f.sessionId};return s.jsx("div",{className:"attention-queue",children:sT(n.items).map(u=>{var f;return s.jsx(rT,{batch:u,trail:a(u.mapId)?(f=e.snaps[u.mapId])==null?void 0:f.map.title:void 0,children:u.items.map(m=>s.jsx(nT,{item:m,snap:e.snaps[m.mapId],otherTrail:a(m.mapId)&&u.items.length<2,selected:m.kind==="question"&&d(m.ref)===e.selected,interrupting:c.has(m.id),now:t,onOpen:()=>Ru(m,e.handlers),onSnooze:g=>e.onSnooze(m.id,g),onDismiss:()=>e.onDismiss(m.id)},m.id))},u.key)})})}const aT={passed:"checks passed",failing:"checks failing",pending:"checks pending",unknown:"checks unknown",none:"no checks"};function cT({mapId:e,ticketId:t}){const n=ns.ticket($r(),e,t);if(!n)return null;const i=n.pr;return s.jsx("div",{className:"pr-flags",children:s.jsxs("span",{className:`pr-chip pr-${(i==null?void 0:i.state)??"unread"}`,title:i?`${i.title}
|
|
141
|
+
${i.headRef}`:void 0,children:[i?s.jsxs("a",{href:pn(i.url),target:"_blank",rel:"noreferrer noopener",children:["PR #",i.number," · ",i.state,i.draft?" · draft":""]}):`PR #${n.link.number}`,s.jsx("span",{className:`ci ci-${n.checksSummary}`,children:aT[n.checksSummary]}),s.jsx("span",{className:"when",children:lT(n)})]})})}function lT(e){return e.error?"sync failed":e.syncedAt?Yv(e.syncedAt):"not synced yet"}const dT={ok:"ok",failed:"error",stale:"syncing",unknown:"idle",off:"idle"};function uT({now:e}){const t=$r();if(!t.reached)return null;const n=Q0(t.live?t.status:null,e);return n.tone!=="failed"&&n.tone!=="stale"?null:s.jsxs("span",{className:`tracker-chip pr-sync tone-${n.tone}`,title:n.title,children:[s.jsx(Ke,{size:"sm",children:"CI"}),s.jsx(Nr,{variant:"status",state:dT[n.tone],size:13,className:"sync-glyph"}),s.jsx("span",{className:"tl",children:n.label})]})}function Ha(e){const t=e.role??"menu",[n,i]=y.useState(!1),a=y.useRef(null);return y.useEffect(()=>{if(!n)return;const c=d=>{var f;(d instanceof KeyboardEvent?d.key==="Escape":!((f=a.current)!=null&&f.contains(d.target)))&&i(!1)};return window.addEventListener("mousedown",c),window.addEventListener("keydown",c),()=>{window.removeEventListener("mousedown",c),window.removeEventListener("keydown",c)}},[n]),s.jsxs("div",{className:pe("header-menu",e.className),ref:a,children:[s.jsxs(I,{variant:"ghost","aria-haspopup":t,"aria-label":e.ariaLabel,"aria-expanded":n,on:n,"data-tip":n?void 0:e.tip,onClick:()=>i(!n),children:[e.label," ",e.badge," ",s.jsx("span",{className:"caret",children:"▾"})]}),n&&s.jsx("div",{className:"header-menu-list",role:t,children:e.children(()=>i(!1))})]})}function hT(){const e=pt();if(!e)return null;const t=(n,i)=>{i(),location.assign(n)};return s.jsx(Ha,{label:e.name,tip:"Your account on the server this Lookout runs on",children:n=>s.jsxs(s.Fragment,{children:[e.home&&s.jsxs("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(e.home.href,n),children:["← ",e.home.label]}),e.pages.map(i=>s.jsx("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(i.href,n),children:i.label},i.href)),e.signOut&&s.jsx("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(e.signOut,n),children:"Sign out"})]})})}const fT={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 mT(e){const t=e.briefingStatus==="new";return s.jsx(Ha,{label:"Records",badge:s.jsxs(s.Fragment,{children:[e.knowledge>0&&s.jsx("span",{className:"n hot",children:e.knowledge}),t&&s.jsx("span",{className:"new-dot","aria-label":"new trip report"})]}),children:n=>s.jsxs(s.Fragment,{children:[s.jsxs("button",{role:"menuitem",className:"header-menu-item",disabled:e.briefingStatus==="none"&&!e.briefingOpen,title:fT[e.briefingStatus],onClick:()=>{n(),e.onBriefing()},children:[s.jsx("span",{children:"Trip report"}),t&&s.jsx("span",{className:"new-dot","aria-label":"new"})]}),s.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:()=>{n(),e.onKnowledge()},children:[s.jsx("span",{children:"Field guide"}),e.knowledge>0&&s.jsx("span",{className:"n hot",children:e.knowledge})]}),s.jsx("button",{role:"menuitem",className:"header-menu-item stats-btn",title:"How your agents deliver across trails, by vendor, agent and ticket type.",onClick:()=>{n(),e.onStats()},children:s.jsx("span",{children:"Trail stats"})})]})})}const Ot=()=>{var e;return(e=pt())==null?void 0:e.agents},Sk=()=>{const e=Ot();e&&location.assign(e.href)},Nk=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(n=>typeof n=="string").slice(0,200),on:t.on,...typeof t.repo=="string"?{repo:t.repo}:{},running:Number.isInteger(t.running)?t.running:0,...typeof t.model=="string"&&t.model.trim()?{model:t.model.trim().slice(0,80)}:{},...typeof t.note=="string"?{note:t.note.slice(0,200)}:{}}},Ka=()=>{var e;return(e=pt())==null?void 0:e.trailAgents};async function pT(e){const t=Ka();if(!t)return;const n=await fetch(`${t}?trail=${encodeURIComponent(e)}`).catch(()=>{});return n!=null&&n.ok?Nk(await n.json().catch(()=>{})):void 0}const Hd="teamtrail:trail-agents";async function gT(e,t){const n=Ka();if(!n)return{error:"This Lookout doesn't run agents."};const i=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trail:e,...t})}).catch(()=>{}),a=await(i==null?void 0:i.json().catch(()=>{})),c=i!=null&&i.ok?Nk(a):void 0;return c&&window.dispatchEvent(new Event(Hd)),c??{error:typeof(a==null?void 0:a.error)=="string"?a.error.slice(0,200):"The server didn't answer."}}function Ga({command:e,label:t="Copy"}){const[n,i]=y.useState(!1);return s.jsxs("span",{className:"agent-cmd",children:[s.jsx("code",{children:e}),s.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(()=>{i(!0),setTimeout(()=>i(!1),1500)}),children:n?"Copied":t})]})}const Vo=[{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"}],vT=9e3;function kT(){const[e,t]=y.useState(0),[n,i]=y.useState(!1);y.useEffect(()=>{if(n)return;const c=setInterval(()=>t(d=>(d+1)%Vo.length),vT);return()=>clearInterval(c)},[n]);const a=Vo[e];return s.jsxs("div",{className:"command-bar real",children:[s.jsx(dk,{name:"map"}),s.jsx(Ke,{as:"h2",className:"zone-title-label",children:"Trail map"}),s.jsx(ki,{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."}),s.jsxs("div",{className:"hint",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onFocus:()=>i(!0),onBlur:()=>i(!1),children:[s.jsx("span",{className:"dim",children:a.text}),a.command&&s.jsx(Ga,{command:a.command})]},e),s.jsxs("button",{type:"button",className:"link hint-next","data-tip":"Next hint","aria-label":"Next hint",onClick:()=>t(c=>(c+1)%Vo.length),children:[e+1,"/",Vo.length," ›"]})]})}function yT(e){const t=[{v:"plan+execute",title:"Plan + execute"},{v:"plan-only",title:"Plan only"}];return s.jsx("div",{className:"choice-row",children:t.map(n=>s.jsx(ct,{on:e.value===n.v,title:n.title,onClick:()=>e.onChange(n.v)},n.v))})}function $k(e){return e.running?e.model?`Agents · ${e.running} working · ${e.model}`:`Agents · ${e.running} working`:e.note?`Agents · ${e.note}`:"Agents · starting soon"}function Ck({agents:e,onStarted:t}){const{state:n,busy:i,error:a,repo:c}=e;if(!n||!n.canRun)return null;const d=()=>void e.act(!0).then(f=>f&&(t==null?void 0:t())),u=Ot();return n.on?s.jsxs("span",{className:"start-trail",children:[s.jsx("span",{className:"start-trail-status",children:$k(n)}),s.jsx(I,{size:"sm",variant:"ghost",disabled:i,onClick:()=>void e.act(!1),children:"Pause"}),u&&s.jsx("a",{className:"t-meta",href:`${u.href}#trail-${encodeURIComponent(e.mapId)}`,children:"Runs"}),a&&s.jsx("span",{className:"vf-err",children:a})]}):s.jsxs("span",{className:"start-trail",children:[n.repos.length>1&&s.jsxs("select",{"aria-label":"Repository",value:c??"",onChange:f=>e.setRepo(f.target.value||void 0),children:[s.jsx("option",{value:"",children:"Repository…"}),n.repos.map(f=>s.jsx("option",{value:f,children:f},f))]}),s.jsx(I,{variant:"primary",disabled:i||n.repos.length>1&&!c,onClick:d,children:"Start the trail"}),!n.repos.length&&s.jsx("span",{className:"t-meta",children:"Connect a repository first."}),a&&s.jsx("span",{className:"vf-err",children:a})]})}function Tk(e){const[t,n]=y.useState(),[i,a]=y.useState(),[c,d]=y.useState(!1),[u,f]=y.useState();return y.useEffect(()=>{let g=!0;const k=()=>void pT(e).then(b=>g&&b&&n(b));k();const w=setInterval(k,15e3);return()=>{g=!1,clearInterval(w)}},[e]),{mapId:e,state:t,busy:c,error:u,repo:i,setRepo:a,act:async g=>{d(!0),f(void 0);const k=await gT(e,{on:g,...g&&i?{repo:i}:{}});return d(!1),"error"in k?(f(k.error),!1):(n(k),g)}}}function wT({mapId:e,onStarted:t}){return s.jsx(Ck,{agents:Tk(e),onStarted:t})}function xT({created:e,mapId:t,onStarted:n}){if(Ka())return s.jsxs("div",{className:"agent-draft created",children:[s.jsxs("span",{children:["Trail ",e," is on the map, starting with discovery."]}),s.jsx(wT,{mapId:t,onStarted:n})]});const i=Ot();return i?s.jsxs("div",{className:"agent-draft created",children:[s.jsxs("span",{children:["Trail ",e," is on the map, starting with discovery. Turn your agents on for it to get it moving."]}),s.jsx(I,{onClick:Sk,children:i.label})]}):s.jsxs("div",{className:"agent-draft created",children:[s.jsxs("span",{children:["Trail ",e," is on the map, starting with discovery. To get it moving, run this in Claude Code or Codex:"]}),s.jsx(Ga,{command:"/scout resume",label:"Copy command"})]})}function jT({seed:e,onClose:t,tracker:n,onCreate:i}){const[a,c]=y.useState(),[d,u]=y.useState(!1),[f,m]=y.useState(),[g,k]=y.useState((e==null?void 0:e.title)??""),[w,b]=y.useState((e==null?void 0:e.destination)??""),[S,x]=y.useState((e==null?void 0:e.notes)??""),[C,N]=y.useState((e==null?void 0:e.assumptions.join(`
|
|
142
|
+
`))??""),P=[g.trim(),w.trim(),S.trim()].filter(Boolean).join(". ").replace(/"/g,"'");return y.useEffect(()=>{const D=M=>M.key==="Escape"&&t();return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[t]),s.jsx("div",{className:"scrim",onClick:t,children:s.jsxs(Fe,{as:"div",className:"dialog",onClick:D=>D.stopPropagation(),children:[s.jsx("header",{children:s.jsx("h2",{className:"t-heading caps",children:e?"Start over":"New trail"})}),s.jsx(Je,{label:"Title",children:s.jsx("input",{value:g,onChange:D=>k(D.target.value),autoFocus:!0})}),s.jsx(Je,{label:"Destination",children:s.jsx("textarea",{rows:3,value:w,onChange:D=>b(D.target.value),placeholder:"What is true when this trail is done?"})}),s.jsx(Je,{label:"Notes",children:s.jsx("textarea",{rows:2,value:S,onChange:D=>x(D.target.value)})}),s.jsx(Je,{label:"Assumptions (optional, one per line)",children:s.jsx("textarea",{className:"new-trail-assumptions",rows:2,value:C,onChange:D=>N(D.target.value),placeholder:"What the plan takes for granted, e.g. The v2 API supports batch writes"})}),!Ot()&&s.jsxs("div",{className:"agent-draft",children:[s.jsxs("span",{className:"dim",children:["Paste this in Claude Code or Codex. Scout frames the trail with you there, then charts it here in"," ",n,"."]}),s.jsx(Ga,{command:`/scout new "${P||"your idea"}"`,label:"Copy command"})]}),a?s.jsx(xT,{created:a.key,mapId:a.id,onStarted:t}):f&&s.jsx("p",{className:"vf-err",children:f}),s.jsxs("footer",{children:[s.jsx(I,{variant:"ghost",onClick:t,children:"Close"}),!a&&s.jsx(I,{variant:"primary",disabled:d||!g.trim()||!w.trim(),"data-tip":Ot()?"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:()=>{u(!0);const D=C.split(`
|
|
143
|
+
`).map(M=>M.trim());i({title:g.trim(),destination:w.trim(),notes:S.trim(),assumptions:D.filter(Boolean)}).then(M=>c({key:M.key,id:M.id})).catch(M=>m(M.message)).finally(()=>u(!1))},children:"Create trail"})]})]})})}const bT=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 ST({mapId:e}){const t=Tk(e),{state:n}=t;if(!(n!=null&&n.on))return s.jsx(Ck,{agents:t});const i=Ot();return s.jsxs(s.Fragment,{children:[s.jsx(Ha,{className:"agents-menu",label:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:n.running?"agents-dot on":"agents-dot","aria-hidden":"true"}),$k(n)]}),children:a=>s.jsxs(s.Fragment,{children:[s.jsx("button",{role:"menuitem",className:"header-menu-item",disabled:t.busy,onClick:()=>{a(),t.act(!1)},children:"Pause agents"}),i&&s.jsx("a",{role:"menuitem",className:"header-menu-item",href:`${i.href}#trail-${encodeURIComponent(e)}`,children:"Runs"})]})}),t.error&&s.jsx("span",{className:"vf-err",children:t.error})]})}function NT({mapId:e}){if(Ka())return s.jsx(ST,{mapId:e});const t=Ot();if(!t)return null;const n=()=>location.assign(`${t.href}#trail-${encodeURIComponent(e)}`);return s.jsx(I,{size:"sm",onClick:n,"data-tip":"Turn your agents on for this trail, or see them at work",children:"Run agents"})}const $T=s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9",cy:"9",r:"3.6",fill:"currentColor"}),s.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"})]}),CT=s.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 TT({onToggle:e}){const t=ak(),n=t?"Switch to the day theme":"Switch to the night theme";return s.jsx(I,{variant:"ghost",className:"icon-only","aria-label":n,"data-tip":n,onClick:()=>e(!t),children:s.jsx("svg",{viewBox:"0 0 18 18",width:"16",height:"16","aria-hidden":"true",children:t?$T:CT})})}const ET={idle:"Idle",syncing:"Syncing",ok:"Synced",error:"Sync error"};function AT({label:e,health:t,now:n}){if(t.status!=="error")return null;const i=[`${ET[t.status]} · ${t.writes} writes · ${t.errors} errors`,t.lastWriteAt?`Last write ${Gt(t.lastWriteMs??0)}, ${Gt(n-t.lastWriteAt)} ago`:"No writes yet",t.lastError].filter(Boolean).join(`
|
|
144
|
+
`);return s.jsxs("span",{className:`tracker-chip sync-${t.status}`,title:i,children:[s.jsx(Ke,{size:"sm",children:"Tracker"}),s.jsx(Nr,{variant:"status",state:t.status,size:13,className:"sync-glyph"}),s.jsx("span",{className:"tl",children:e})]})}const Lp={"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 RT(e){const{map:t}=e,[n,i]=y.useState();if(t.archived)return s.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]});if(n)return s.jsxs("div",{className:"trail-confirm",role:"group",children:[s.jsx("p",{className:"t-meta",children:Lp[n].text(t)}),s.jsxs("div",{className:"actions",children:[s.jsx(I,{variant:"primary",onClick:()=>{n==="start-over"?e.onStartOver():e.onArchive(!0),e.onDone()},children:Lp[n].confirm}),s.jsx(I,{onClick:()=>i(void 0),children:"Cancel"})]})]});const a=t.mode==="plan-only";return s.jsxs(s.Fragment,{children:[e.onToggleMode&&s.jsx("button",{role:"menuitem",className:"trail-item act","data-tip":a?"Agents decide, then build what was decided":"Agents research and decide; execute tickets wait",onClick:()=>{var c;return(c=e.onToggleMode)==null||c.call(e),e.onDone()},children:a?"Switch to Plan + execute":"Switch to Plan only"}),s.jsxs("button",{role:"menuitem",className:"trail-item act","data-tip":"The map went wrong? Archive it and describe the idea again",onClick:()=>i("start-over"),children:["Start ",t.key," over…"]}),s.jsxs("button",{role:"menuitem",className:"trail-item act","data-tip":"Put the trail away as history",onClick:()=>i("archive"),children:["Archive ",t.key,"…"]})]})}function IT(e){const{map:t}=e.snap,n=sb(e.snap);return s.jsxs("button",{role:"menuitem",className:`trail-item ${e.on?"on":""} ${t.archived?"archived":""}`,onClick:e.onSelect,children:[s.jsx("span",{className:"key",children:t.key}),s.jsx("span",{className:"mi-title",children:t.title}),s.jsxs("span",{className:"mi-progress",children:[n.decided,"/",n.total]}),s.jsx(js,{n:e.waiting,urgent:!!e.waiting,hideZero:!0})]})}function MT(e){var g;const[t,n]=y.useState(!1),i=y.useRef(null);y.useEffect(()=>{if(!t)return;const k=w=>{var b;(w instanceof KeyboardEvent?w.key==="Escape":!((b=i.current)!=null&&b.contains(w.target)))&&n(!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),c=a.filter(k=>!k.map.archived),d=a.filter(k=>k.map.archived),u=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,m=k=>{var w;return s.jsx(IT,{snap:k,on:k.map.id===((w=e.map)==null?void 0:w.id),waiting:u(k.map.id),onSelect:()=>{e.onSelectMap(k.map.id),n(!1)}},k.map.id)};return s.jsxs("div",{className:"trail-switcher",ref:i,children:[s.jsxs("button",{className:"trail-btn",onClick:()=>n(k=>!k),"aria-haspopup":"menu","aria-expanded":t,"data-tip":"Switch trail, or start a new one",children:[s.jsx("span",{className:"trail-title",children:e.map?`${e.map.key} ${e.map.title}`:"No trail"}),((g=e.map)==null?void 0:g.archived)&&s.jsx("span",{className:"trail-archived",children:"archived"}),f>0&&s.jsx(js,{n:f,urgent:!0}),s.jsx("span",{className:"caret",children:"▾"})]}),t&&s.jsxs("div",{className:"trail-menu",role:"menu",children:[s.jsx(Ke,{variant:"plain",className:"menu-h",children:"Trails"}),c.map(m),s.jsx("button",{role:"menuitem",className:"trail-item new",onClick:()=>{n(!1),e.onNewTrail()},children:"+ New trail"}),d.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(Ke,{variant:"plain",className:"menu-h",children:"Archived"}),d.map(m)]}),e.map&&e.onStartOver&&e.onArchive&&s.jsx("div",{className:"trail-acts",children:s.jsx(RT,{map:e.map,onStartOver:e.onStartOver,onArchive:e.onArchive,onToggleMode:e.onToggleMode,onDone:()=>n(!1)})})]})]})}function OT(e){const{map:t}=e,n=gt(1e3),i=e.activity.pending.length,a=t&&e.snaps[t.id],c=t&&kv(e.activity,t.id);return s.jsxs(Fe,{as:"header",className:"header",children:[s.jsxs("div",{className:"h-title",children:[s.jsxs("div",{className:"h-line1",children:[e.repo,s.jsx("span",{className:"sep",children:"/"}),s.jsx(MT,{...e})]}),s.jsxs("div",{className:"h-dest",title:t==null?void 0:t.sections.destination,children:[s.jsx(Ke,{size:"sm",children:"Destination"}),(t==null?void 0:t.sections.destination)??"—"]})]}),s.jsxs("div",{className:"h-right",children:[s.jsx(AT,{label:e.trackerLabel,health:e.health,now:n}),s.jsx(uT,{now:n}),t&&a&&s.jsxs("span",{className:"trail-meta",children:[s.jsx(Cn,{label:"Trail T+",value:Qv(n-t.createdAt),title:"Trail elapsed time, since it was charted"}),c&&c.costUsd+c.inputTokens+c.outputTokens>0&&s.jsx(Cn,{className:"spend",label:"Spent",value:`${ui(c.costUsd)} · ${Ma(c.inputTokens+c.outputTokens)} tok`,title:["Model spend and tokens for this trail, across every session",...wv(e.activity,t.id).map(d=>yv[d].text)].join(`
|
|
145
|
+
`)})]}),e.views,e.attention,e.needs,!e.attention&&!e.needs&&i>0&&s.jsxs("span",{className:"waiting-chip",title:`${i} waiting on you`,children:[s.jsx(Nr,{variant:"alert",size:14}),s.jsx("b",{children:i}),s.jsx("span",{className:"wl",children:" waiting on you"})]}),e.slackAlert&&s.jsx(I,{size:"sm",variant:"urgent",onClick:e.onSlack,title:e.slackAlert.why,children:e.slackAlert.label}),(t==null?void 0:t.mode)==="plan-only"&&s.jsx(I,{variant:"ghost",className:"mode-chip",onClick:e.onToggleMode,"data-tip":"Plan only: agents research and decide, but no execute tickets run. Click to switch to Plan + execute.",children:"Plan only"}),t&&s.jsx(NT,{mapId:t.id}),s.jsx(mT,{onStats:e.onStats,knowledge:e.knowledge,onKnowledge:e.onKnowledge,briefingOpen:e.briefingOpen,briefingStatus:e.briefingStatus,onBriefing:e.onBriefing}),s.jsx(I,{variant:"ghost",onClick:e.onSettings,"data-tip":"Tracker, verification, appearance and integrations",children:"Settings"}),ck()?null:s.jsx(TT,{onToggle:e.onToggleTheme}),s.jsx(hT,{})]})]})}function LT(e){const{count:t,elsewhere:n}=e,i=n>0?`${n} more on other trails`:"";if(!t&&!n)return null;if(!t)return s.jsx(I,{className:"needs-btn elsewhere","data-tip":`Nothing here · ${i}`,onClick:e.onOpen,children:"On other trails"});const a=`${t} need${t===1?"s":""} you`,c=[e.top&&`Most urgent: ${e.top}`,i].filter(Boolean).join(" · ");return s.jsx(I,{variant:"urgent",className:"needs-btn","data-tip":c,"aria-label":i?`${a} on this trail, ${i}`:a,onClick:e.onOpen,children:a})}function PT(e){return s.jsx("nav",{className:"view-tabs","aria-label":"Views",children:e.tabs.map(t=>s.jsx("button",{type:"button",className:pe("view-tab",e.value===t.id&&"on"),"aria-current":e.value===t.id?"page":void 0,onClick:()=>e.onChange(t.id),children:t.label},t.id))})}const Pp={label:"Focus for 1 hour",change:{kind:"for",minutes:60}};function DT(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},Pp];case"off":return[{...Pp,primary:!0},{label:"Focus for 3 hours",change:{kind:"for",minutes:180}}];default:return e}}const Dp=e=>Ia(e).slice(0,5),_T=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function BT(e){const t=`${e.items.length} waiting on you`;return e.heldBack===0?`Nothing held back · ${t}`:`${_T(e.heldBack,"item")} would interrupt you · ${t}`}function dd(e){const t=e.prefs.focus;return t?`Quiet hours ${t.from}–${t.to}`:"No quiet hours set"}const _p=e=>`Items scoring ${e.policy.value.interrupt} or more interrupt you · ${e.items.length} waiting on you`;function FT(e){const t=e.focus;switch(t.kind){case"manual":case"hours":{const n=Dp(t.until),i=t.kind==="manual"?"Switched on here":dd(e);return{word:"on",until:n,on:!0,title:`Focus is on until ${n}`,reason:i,detail:BT(e)}}case"paused":{const n=Dp(t.until),i=`Quiet hours paused until ${n}`;return{word:"paused",until:n,on:!1,title:i,reason:dd(e),detail:_p(e)}}case"off":return{word:"off",until:"",on:!1,title:"Focus is off",reason:dd(e),detail:_p(e)};default:return t}}const zT="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 UT(e){const{view:t}=e,n=FT(t),i=t.focus.kind,a=s.jsxs("span",{className:pe("focus-state",`focus-${i}`),children:[s.jsx("i",{className:"focus-dot","aria-hidden":"true"}),s.jsxs("span",{className:"focus-label",children:["Focus",s.jsxs("span",{className:"focus-word",children:[" ",n.word]})]}),n.until&&s.jsxs("span",{className:"focus-until",children:[s.jsx("span",{className:"sep",children:" · "}),s.jsx("span",{className:"focus-until-word",children:"until "}),n.until]})]});return s.jsx(Ha,{className:"focus-menu",label:a,role:"dialog",tip:n.title,ariaLabel:n.title,children:c=>s.jsxs("div",{className:"focus-panel","aria-label":"Focus",children:[s.jsxs("div",{className:"focus-panel-head",children:[s.jsx("span",{className:"t-row-title",children:n.title}),s.jsx(ki,{text:zT})]}),s.jsx(B,{parts:[n.reason]}),s.jsx(B,{className:"focus-held",parts:[n.detail]}),s.jsxs("div",{className:"focus-panel-actions",children:[DT(t.focus).map(d=>s.jsx(I,{size:"sm",variant:d.primary?"primary":"default",onClick:()=>{c(),e.onChange(d.change)},children:d.label},d.label)),s.jsx(I,{size:"sm",variant:"ghost",onClick:()=>{c(),e.onSettings()},children:"Quiet hours"})]})]})})}function WT(e){return s.jsx("span",{className:"attention-head",children:s.jsx(UT,{view:e.view,onChange:e.onFocus,onSettings:e.onSettings})})}const Ek=`${ie()}/attention`,HT=250;async function ud(e,t,n){var c;const i=await fetch(`${Ek}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),a=await i.json().catch(()=>({}));if(!i.ok)throw new Error(((c=a.errors)==null?void 0:c.join("; "))??a.error??`HTTP ${i.status}`);return a}function Ak(e){const[t,n]=y.useState(),[i,a]=y.useState(),[c]=y.useState(gi),d=y.useCallback(()=>{const m=c.start();fetch(Ek).then(g=>g.ok?g.json():void 0).then(g=>g&&m()&&n(g)).catch(()=>{})},[c]);y.useEffect(()=>vi("attention",m=>{c.pushed(),n(JSON.parse(m))}),[c]),y.useEffect(()=>os(d),[d]),y.useEffect(()=>{const m=setTimeout(d,HT);return()=>clearTimeout(m)},[d,e]);const u=m=>m.then(()=>(a(void 0),d(),!0),g=>(a(g.message),!1)),f=(m,g)=>void ud(m,"POST",g).then(()=>(a(void 0),d()),k=>a(k.message));return{view:t,error:i,snooze:(m,g)=>f("/snooze",{id:m,minutes:g}),dismiss:m=>f("/dismiss",{id:m}),savePrefs:m=>u(ud("/prefs","PUT",m)),saveReviewLimit:m=>u(ud("/review-limit","PUT",{limit:m}))}}function KT(e){return e.prefs.channel!=="browser"?!1:typeof Notification<"u"&&Notification.permission==="granted"}function GT(e){const t=new Notification(`${J.name} · needs you`,{body:e.title,tag:e.id});t.onclick=()=>{window.focus(),t.close()}}function VT(e){const t=y.useRef();y.useEffect(()=>{if(!e)return;const n=new Set(e.interrupting),i=t.current;if(t.current=n,!(!i||!KT(e)))for(const a of e.items)n.has(a.id)&&!i.has(a.id)&>(a)},[e])}const qT={question:"waiting on you",approval:"approve it",merge:"ready to merge",blocked:"blocked",stalled:"went quiet","hitl-ready":"yours to decide",model:"needs a model",policy:"risky change",flag:"PR or CI",overlap:"same files",integration:"branches clash",precedent:"your decision","tracker-settings":"settings changed","review-limit":"review waits",escape:"came back"},QT={"trail-checks":"Fails on main together","hitl-ready":"Decide",approval:"Approve",blocked:"Unblock",stalled:"Went quiet",model:"Needs a model",policy:"Risky change",brief:"Brief",reroute:"Reroute","reroute-suggested":"Reroute?",trust:"Approve on this machine",guide:"Approve a guide","guide-checks":"Approve guide checks",knowledge:"Field guide",overlap:"Same files",integration:"Branches clash",precedent:"Your decision",flag:"PR or CI","tracker-settings":"Settings changed","review-limit":"Review waits",escape:"Came back"};function YT(e){return qT[e.kind]??"needs you"}function hd(e){var t;return e.kind==="question"?e.agent?`Answer ${e.agent}`:"Answer":e.kind==="merge"?((t=e.title.match(/PR #\d+/))==null?void 0:t[0].replace("PR","Merge PR"))??"Merge":e.kind==="main-checks"?e.title.split(":")[0].replace(" already","").replace(/ on main$/,""):QT[e.kind]??Eu[e.kind]}function JT(e,t){const n=e.ticketId?t(e.ticketId):void 0;return e.kind==="main-checks"?`main: ${hd(e)}`:n?`${n} ${hd(e)}`:hd(e)}function XT(e){const t=gt(1e3);return e.items.length?s.jsx("ul",{className:"inbox-list approvals",children:e.items.map(n=>{var c;const i=n.kind!=="approve",a=n.mapId!==e.currentMapId?(c=e.snaps[n.mapId])==null?void 0:c.map.title:void 0;return s.jsx(he,{as:"li",edge:i?"attention":"neutral",title:`${i?"Decide":"Approve"}: ${n.title}`,context:s.jsx(B,{parts:[i?"Held":"Verified",{text:n.ticketKey,code:!0},a]}),detail:n.reason,detailText:n.reason,trailing:Xe(t-n.at),onOpen:()=>e.onOpen(n.mapId,n.ticketId)},`${n.mapId}/${n.ticketId}`)})}):null}function Bp({activity:e}){const t=gt(1e3),n=ob(e);return s.jsxs("div",{className:"hitl-readout",children:[s.jsx(Cn,{layout:"inline",label:"Oldest",value:n.oldestAt?Gt(t-n.oldestAt):"—",urgent:!!n.oldestAt&&t-n.oldestAt>6e4,title:"Oldest open question"}),s.jsx(Cn,{layout:"inline",label:"Avg wait",value:n.avgWaitMs!==void 0?Gt(n.avgWaitMs):"—",title:`Average wait over ${n.answered} answered questions`}),s.jsx(Cn,{layout:"inline",label:"Answered",value:n.answered})]})}function ZT(e){const t=gt(1e3);return e.items.length?s.jsx("ul",{className:"inbox-list",children:e.items.map(n=>{const i=e.snaps[n.mapId],a=i==null?void 0:i.tickets.find(u=>u.id===n.ticketId),c=n.mapId!==e.currentMapId?i==null?void 0:i.map.title:void 0,d=n.text.split(`
|
|
146
|
+
`)[0];return s.jsx(he,{as:"li",className:n.sessionId===e.selected?"sel":void 0,edge:n.urgency==="blocking"?"urgent":"neutral",selected:n.sessionId===e.selected,title:d,titleText:n.text,context:s.jsx(B,{parts:[n.urgency==="blocking"&&{text:"Blocking",urgent:!0},`${n.agent} asks`,a&&{text:a.key,code:!0},a==null?void 0:a.title,c]}),trailing:Xe(t-n.at),onOpen:()=>e.onOpen(n.sessionId,n.ticketId)},n.id)})}):s.jsx(An,{title:"Nothing waiting on you",hint:"When an agent needs your call, its question lands here."})}const Rk={pass:"Passed",fail:"Failed",error:"Could not run",interrupted:"Interrupted"},Er={off:"Off",checks:"Checks","checks+review":"Checks + review","checks+review+human":"Checks + review + you"},Iu={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."},Ik=e=>e.exitCode===0&&!e.timedOut&&!e.error;async function qo(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`HTTP ${e.status}`);return t}const si=`${ie()}/verification`,bs={ticket:(e,t)=>fetch(`${si}/ticket?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`).then(n=>n.ok?n.json():void 0,()=>{}),inbox:()=>fetch(`${si}/inbox`).then(e=>e.ok?e.json().then(t=>t.items):[],()=>[]),log:e=>fetch(`${si}/log?path=${encodeURIComponent(e)}`).then(t=>qo(t)),waive:e=>fetch(`${si}/waive`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>qo(t)),undoWaiver:e=>fetch(`${si}/waive/undo`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>qo(t)),act:e=>fetch(`${si}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>qo(t))};function e2(e){const[t,n]=y.useState([]),i=Object.values(e).map(c=>c.tickets.map(d=>`${d.id}:${d.state}:${d.status??""}`).join()).join("|"),{reload:a}=Le({version:i,load:bs.inbox,show:n});return y.useEffect(()=>ns.onEvidence(a),[a]),t}function t2(e){var u;const t=[...e.activity.pending].sort((f,m)=>f.at-m.at),n=e2(e.snaps),i=(u=e.attention)==null?void 0:u.view,a=e.brief?1:0,c=i?i.items.length:t.length+n.length+a,d=s.jsx(yt,{hot:c>0,title:s.jsxs(s.Fragment,{children:[c>0&&s.jsx(Nr,{variant:"alert",size:12}),"Waiting on you"]}),count:s.jsx(js,{n:c,urgent:c>0,pop:!0},c)});return i&&e.attention&&e.handlers?s.jsxs("div",{className:"inbox-part",children:[d,s.jsx(Bp,{activity:e.activity}),s.jsx(bk,{view:i,snaps:e.snaps,pending:e.activity.pending,currentMapId:e.currentMapId,selected:e.sessionId,handlers:e.handlers,onSnooze:e.attention.snooze,onDismiss:e.attention.dismiss})]}):s.jsxs("div",{className:"inbox-part",children:[d,s.jsx(Bp,{activity:e.activity}),e.brief,s.jsx(XT,{items:n,snaps:e.snaps,currentMapId:e.currentMapId,onOpen:e.onOpenTicket}),(t.length>0||!(n.length+a))&&s.jsx(ZT,{items:t,snaps:e.snaps,currentMapId:e.currentMapId,selected:e.sessionId,onOpen:e.onOpenQuestion})]})}function Mk(e){const{q:t}=e,[n,i]=y.useState(""),a=y.useRef(null),c=(t.blocks??[]).map(e.keyOf).filter(Boolean),d=u=>{u.trim()&&(e.onAnswer(t.id,u.trim()),i(""))};return s.jsxs("div",{className:"bubble-need open-q",children:[s.jsx("span",{className:"t-label urgent",children:"Waiting on you"}),s.jsx("h3",{className:"bubble-title",children:t.text}),s.jsx(B,{parts:[`${t.agent} asks`,c.length>0&&`blocks ${c.join(" and ")}`,Xe(e.now-t.at)]}),t.stakes&&s.jsx(B,{parts:[{text:t.stakes,strong:!0}]}),t.precedent&&s.jsx(B,{className:"open-q-precedent",parts:[t.precedent]}),s.jsx("div",{className:"bubble-answer",children:s.jsx(xk,{pending:t,draft:n,onDraft:i,onSend:d,inputRef:a})}),s.jsx("button",{type:"button",className:"link",onClick:()=>e.onOpenChat(t.sessionId),children:"The whole conversation"})]})}function n2(e){const[t,n]=y.useState(""),[i,a]=y.useState(),[c,d]=y.useState(!1),u=async()=>{d(!0),a(void 0);const f=await fetch(`${ie()}/verification/rules/waive`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,ticketId:e.ticketId,rule:e.rule,reason:t})}).catch(()=>{});if(d(!1),f!=null&&f.ok)return e.onDone();const m=await(f==null?void 0:f.json().catch(()=>({})));a((m==null?void 0:m.error)??"The server didn't answer.")};return s.jsxs("form",{className:"dr-waive",onSubmit:f=>{f.preventDefault(),u()},children:[s.jsx("input",{"aria-label":`Why ${e.rule} can go unanswered`,value:t,placeholder:"Why it can go unanswered",autoFocus:!0,onChange:f=>n(f.target.value)}),s.jsxs(I,{type:"submit",disabled:c||!t.trim(),children:["Go without ",e.rule]}),i&&s.jsx("span",{className:"vf-err",children:i})]})}function s2(e){const[t,n]=y.useState();return s.jsxs("div",{className:"dr-held",children:[s.jsxs("p",{className:"t-meta",children:[e.held.agent,"'s completion waits for these answers."]}),s.jsx("ul",{className:"dr-list",children:e.held.rules.map(i=>s.jsx(he,{as:"li",edge:"attention",title:i.ask,context:s.jsx(B,{parts:[{text:i.id,code:!0},`Why: ${i.why}`]}),detail:i.files.join(", "),actions:s.jsx(I,{size:"sm",onClick:()=>n(i.id),children:"Go without"}),below:t===i.id&&s.jsx(n2,{mapId:e.mapId,ticketId:e.ticketId,rule:i.id,onDone:()=>{n(void 0),e.onWaived()}})},i.id))})]})}function i2(e,t){const[n,i]=y.useState({waived:[]}),a=async()=>{const d=new URLSearchParams({mapId:e,ticketId:t}),u=await fetch(`${ie()}/verification/rules/held?${d}`);if(!u.ok)return{waived:[]};const f=await u.json();return{held:f.held,waived:f.waived??[]}},c=Le({view:`${e}/${t}`,load:a,show:i,events:{verification:()=>!0,leases:()=>!0,attention:()=>!0}});return{...n,reload:c.reload}}function r2(e){const[t,n]=y.useState(),[i,a]=y.useState(!1),c=async()=>{a(!0),n(void 0);const d=await fetch(`${ie()}/verification/rules/waive/undo`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,ticketId:e.ticketId,rule:e.rule})}).catch(()=>{});if(a(!1),d!=null&&d.ok)return e.onDone();const u=await(d==null?void 0:d.json().catch(()=>({})));n((u==null?void 0:u.error)??"The server didn't answer.")};return s.jsxs(s.Fragment,{children:[s.jsx(I,{size:"sm",variant:"ghost",disabled:i,"aria-label":`Undo going without ${e.rule}`,"data-tip":"The rule asks again on the next completion",onClick:()=>void c(),children:"Undo"}),t&&s.jsx("span",{className:"vf-err",children:t})]})}function o2(e){return e.waived.length?s.jsx("ul",{className:"dr-list dr-waived",children:e.waived.map(t=>s.jsx(he,{as:"li",title:`Went without ${t.rule}`,context:s.jsx(B,{parts:[t.by,ss(t.at)]}),detail:t.reason,actions:s.jsx(r2,{mapId:e.mapId,ticketId:e.ticketId,rule:t.rule,onDone:e.onUndone})},t.rule))}):null}function a2(e){const{held:t,waived:n,reload:i}=i2(e.mapId,e.ticketId),a=t&&t.rules.length>0;return!a&&!n.length?null:s.jsxs(sn,{label:"Diff rules",className:"dr-rules",children:[a&&s.jsx(s2,{mapId:e.mapId,ticketId:e.ticketId,held:t,onWaived:i}),s.jsx(o2,{mapId:e.mapId,ticketId:e.ticketId,waived:n,onUndone:i})]})}function Ee(e){return s.jsxs("section",{className:"set-sec",children:[s.jsx(Ke,{as:"h4",children:e.title}),e.children]})}function xi(){const[e,t]=y.useState();return y.useEffect(()=>{fetch(`${ie()}/machine`).then(n=>n.ok?n.json():void 0).then(n=>t(n==null?void 0:n.local),()=>t(void 0))},[]),e}async function c2(){const e=await fetch(`${ie()}/verification/config`);return e.ok?await e.json():null}function Mu(){const[e,t]=y.useState();return Le({load:c2,show:t,failed:()=>t(null),changed:n=>n.endsWith("verification.json"),events:{attention:()=>!0}}),e}function l2(e){const{rule:t,onChange:n}=e,i=t.id?`Remove ${t.id}`:"Remove rule",a=[{value:"",label:"No check"},...e.checks.map(d=>({value:d,label:`Run ${d}`}))],c=e.lastMatched?`Last matched ${ss(e.lastMatched)}`:"Not matched yet";return s.jsxs("li",{className:"dr-edit-rule",children:[s.jsxs("div",{className:"dr-edit-head",children:[s.jsx("span",{className:"t-code dr-id",children:t.id??"New"}),s.jsx("input",{"aria-label":"When these files change",className:"t-code",value:t.when,placeholder:"src/session/**, src/store.ts",autoFocus:e.focus,onChange:d=>n({when:d.target.value})}),s.jsx("button",{type:"button",className:"icon-btn vf-edit-remove","aria-label":i,"data-tip":i,onClick:e.onRemove,children:"×"})]}),s.jsxs("div",{className:"dr-edit-body",children:[s.jsx(rt,{"aria-label":"Check",value:t.check,options:a,onChange:d=>n({check:d})}),s.jsx("input",{"aria-label":"Question",value:t.ask,placeholder:"Question the agent answers (optional)",onChange:d=>n({ask:d.target.value})}),s.jsx("input",{"aria-label":"Why",value:t.why,placeholder:"Why: the incident behind it",onChange:d=>n({why:d.target.value})}),t.id&&s.jsx("span",{className:"t-meta",children:c})]})]})}const d2=e=>((e==null?void 0:e.rules)??[]).map(t=>({id:t.id,when:t.when.join(", "),check:t.check??"",ask:t.ask??"",why:t.why})),Kd=e=>({...e.id?{id:e.id}:{},when:e.when.split(",").map(t=>t.trim()).filter(Boolean),...e.check?{check:e.check}:{},...e.ask.trim()?{ask:e.ask.trim()}:{},why:e.why.trim()});function u2(e,t){var c;const n=new URLSearchParams(e),i=(c=n.get("when"))==null?void 0:c.trim().slice(0,1e3);if(n.get("settings")!=="rules"||!i)return;const a=Kd({when:i,check:"",ask:"",why:""}).when.join(",");if(!t.some(d=>Kd(d).when.join(",")===a))return{when:i,check:"",ask:"",why:(n.get("why")??"").slice(0,300)}}const h2={when:"",check:"",ask:"",why:""};function f2(e){var b;const{view:t,lastMatched:n}=e,[i,a]=y.useState(()=>{const S=d2(t.config),x=u2(location.search,S);return[...S,...x?[x]:[]]}),[c,d]=y.useState(!1),[u,f]=y.useState({kind:"idle"}),m=Object.keys(((b=t.config)==null?void 0:b.checks)??{}),g=(S,x)=>a(i.map((C,N)=>N===S?{...C,...x}:C)),k=async()=>{var N;f({kind:"saving"});const S=i.filter(P=>P.when.trim()).map(Kd),x=await fetch(`${ie()}/verification/rules`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({rules:S,base:((N=t.approval)==null?void 0:N.base)??"none"})}).catch(()=>{}),C=await(x==null?void 0:x.json().catch(()=>({})));if(x!=null&&x.ok)return f({kind:"idle"}),e.onSaved();f({kind:"error",text:(C==null?void 0:C.error)??"The server didn't answer."})},w=u.kind==="saving";return s.jsxs("div",{className:"vf-editor dr-editor",children:[i.length>0&&s.jsx("ul",{className:"vf-edit-list",children:i.map((S,x)=>s.jsx(l2,{rule:S,checks:m,lastMatched:S.id?n[S.id]:void 0,focus:c&&x===i.length-1,onChange:C=>g(x,C),onRemove:()=>a(i.filter((C,N)=>N!==x))},S.id??`new-${x}`))}),s.jsx("div",{className:"vf-edit-add",children:s.jsx(I,{onClick:()=>{d(!0),a([...i,h2])},children:"Add rule"})}),s.jsxs("div",{className:"vf-edit-foot",children:[s.jsx("span",{className:"t-meta",children:"Saving approves them on this machine."}),s.jsxs("div",{className:"vf-edit-save",children:[e.saved&&u.kind==="idle"&&s.jsx("span",{className:"t-meta",children:"Saved and approved."}),u.kind==="error"&&s.jsx("span",{className:"vf-err",children:u.text}),s.jsx(I,{variant:"primary",disabled:w,onClick:()=>void k(),children:w?"Saving…":"Save rules"})]})]})]})}function m2({rules:e,lastMatched:t}){return s.jsx("ul",{className:"dr-list",children:e.map(n=>s.jsx(he,{as:"li",title:s.jsx("span",{className:"t-code",children:n.when.join(", ")}),context:s.jsx(B,{parts:[{text:n.id,code:!0},n.check&&`Runs ${n.check}`,n.ask&&`Asks: ${n.ask}`]}),detail:`Why: ${n.why}`,trailing:t[n.id]?ss(t[n.id]):"Not matched yet"},n.id))})}async function p2(){const e=await fetch(`${ie()}/verification/rules`);return e.ok?(await e.json()).lastMatched??{}:{}}function g2(){const[e,t]=y.useState({});return Le({load:p2,show:t,events:{verification:()=>!0}}),e}function v2(e){var t;if(!e.exists)return"Set the checks first: without them nothing is verified.";if((t=e.approval)!=null&&t.waiting)return"Approve the checks first."}function k2(){var u,f;const e=Mu(),t=xi(),n=g2(),[i,a]=y.useState(!1);if(!e)return null;const c=((u=e.config)==null?void 0:u.rules)??[],d=v2(e);return s.jsxs(Ee,{title:"Diff rules",children:[s.jsx("p",{className:"vf-intro",children:"When a change touches certain files, run a check or ask the agent a question it must answer before the ticket completes. Each rule says why it exists."}),t&&!d&&s.jsx(f2,{view:e,lastMatched:n,saved:i,onSaved:()=>a(!0)},((f=e.approval)==null?void 0:f.base)??"none"),(!t||d)&&c.length>0&&s.jsx(m2,{rules:c,lastMatched:n}),d&&s.jsx("span",{className:"set-hint t-meta",children:d}),t===!1&&s.jsx("span",{className:"set-hint t-meta",children:"Set on the machine Teamtrail runs on."})]})}const Ok=()=>`${ie()}/proof/settings`;async function y2(){const e=await fetch(Ok());return e.ok?await e.json():null}function w2(){const[e,t]=y.useState(),{pushed:n}=Le({load:y2,show:a=>t((a==null?void 0:a.enabled)??null),failed:()=>t(null),events:{proof:()=>!0}}),i=y.useCallback(async a=>{const c=await fetch(Ok(),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:a})}),d=await c.json();if(!c.ok)return d.error??`Saving failed (${c.status})`;n(),t(d.enabled===!0)},[n]);return{enabled:e,set:i}}function x2(){const{enabled:e,set:t}=w2(),[n,i]=y.useState();if(e==null)return null;const a=()=>{i(void 0),t(!e).then(i,c=>i(c.message))};return s.jsxs(Ee,{title:"Proof on pull requests",children:[s.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 ",s.jsx("b",{children:"Teamtrail proof"})," check next to CI. The comment is updated, never repeated, when the proof or the PR changes."]}),s.jsxs("div",{className:"att-settings-row set-field",children:[s.jsx("span",{className:"set-field-label",children:"Post proofs from this machine"}),s.jsx(I,{size:"sm",on:e,"aria-pressed":e,className:"proof-post-toggle",onClick:a,children:e?"On":"Off"})]}),s.jsxs("span",{className:"set-hint t-meta",children:["Posted with your GitHub token, to the repo Teamtrail syncs pull requests with (",s.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."]}),n&&s.jsx("span",{className:"vf-err",children:n})]})}function j2(e){const t=e.guard;return t?t.accepted?`changed what its checks run, accepted by ${t.accepted.by}`:t.mode==="observe"&&"changed what its checks run (observed)":!1}function b2(e){var i,a,c;const t=e.checks.filter(d=>d.passed).length,n=e.reviews.length;return[e.checks.length>0&&`${t}/${e.checks.length} checks passed`,!!((i=e.waived)!=null&&i.length)&&`${e.waived.map(d=>d.name).join(", ")} skipped`,!!((a=e.retried)!=null&&a.length)&&`${e.retried.map(d=>d.name).join(", ")} passed on retry`,j2(e),e.criteria.lines.length>0&&`${e.criteria.verified} criteria verified, ${e.criteria.claimed} claimed`,n>0&&`${n} review${n>1?"s":""}`,!!((c=e.guides)!=null&&c.length)&&`guides ${e.guides.map(d=>d.id).join(", ")}`,{text:e.digest.slice(0,19),code:!0}]}const S2=(e,t)=>e?"the same model as the author":t?`author on ${t}`:"author model unknown";function N2(e){const t=e.attempt.model;return e.reviews.filter(n=>n.byKind==="agent"&&n.model).map(n=>[`Reviewed by ${n.by} on ${n.model}`,S2(n.sameModel,t)])}function $2(e){const{view:t}=e;if(!t)return null;const{proof:n,post:i}=t;if(!(e.ticket.state==="closed"&&e.ticket.closeReason==="completed")&&!n.attempt.id)return null;const c=n.status==="verified",d=i!=null&&i.commentUrl?pn(i.commentUrl):void 0,u=b2(n);return s.jsxs(sn,{label:"Proof",className:"ticket-proof",children:[s.jsxs("div",{className:"proof-head",children:[s.jsx(wi,{tone:c?"fill":"amber",children:c?"Verified by Teamtrail":"Not verified"}),s.jsx(B,{parts:u.slice(0,-1)})]}),N2(n).map((f,m)=>s.jsx("div",{className:"proof-review-model",children:s.jsx(B,{parts:f})},m)),n.gaps.length>0&&s.jsx("ul",{className:"proof-gaps t-meta",children:n.gaps.map(f=>s.jsx("li",{children:f},f))}),s.jsxs(rn,{children:[s.jsx(B,{parts:["Digest",...u.slice(-1)]}),d&&s.jsxs("a",{className:"t-meta",href:d,target:"_blank",rel:"noreferrer",children:["Posted on pull request #",i.pr]}),(i==null?void 0:i.error)&&s.jsxs("p",{className:"t-meta",children:["Posting failed, trying again: ",i.error]}),t.keyFile&&s.jsxs("p",{className:"t-meta",children:["Signed with this machine's key. Commit ",s.jsx("code",{children:`${J.dataDir}/${t.keyFile}`})," so others can check it."]})]})]})}function C2(e,t){const[n,i]=y.useState();return Le({load:async()=>{const a=new URLSearchParams({mapId:e,ticketId:t}),c=await fetch(`${ie()}/proof/ticket?${a}`);return c.ok?await c.json():null},show:i,failed:()=>i(null),view:`${e}/${t}`,changed:a=>a.includes(`tickets/${t}.md`),events:{verification:()=>!0,proof:()=>!0}}),n}function Lk(e){const t=e.anyway?"Merged at the commit its proof covers.":"Approved and merged at the verified commit.";return s.jsxs("span",{className:"t-meta merge-note",children:[t," ",e.url&&s.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer",children:"See the pull request"})]})}const Fp="The server didn't answer. Try again.",Pk=(e,t)=>String(e.error??`The server answered ${t}.`).slice(0,300);async function Dk(e,t){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i=await n.json().catch(()=>({}));return{ok:n.ok,status:n.status,json:i}}async function T2(e){const t=await Dk(`${ie()}/proof/merge-anyway`,e),n=t.json.gapsHash;return t.ok&&typeof n=="string"?{hash:n}:{error:Pk(t.json,t.status)}}async function E2(e){try{const t=e.gaps?await T2({mapId:e.mapId,ticketId:e.ticketId,gaps:e.gaps}):void 0;if(t&&"error"in t)return{kind:"error",text:t.error??Fp};const n=t?{anyway:!0,gaps:t.hash}:{},i=await Dk(e.path,{trail:e.mapId,ticket:e.ticketId,...n}),a=typeof i.json.url=="string"?pn(i.json.url):void 0;return i.ok&&i.json.merged?{kind:"merged",url:a}:{kind:"error",text:Pk(i.json,i.status)}}catch{return{kind:"error",text:Fp}}}function _k(e){const[t,n]=y.useState({kind:"idle"});return{state:t,ask:()=>n({kind:"confirm"}),cancel:()=>n({kind:"idle"}),merge:async a=>{n({kind:"working"}),n(await E2({...e,gaps:a}))}}}function A2(e){const t=_k(e),{state:n}=t;return n.kind==="merged"?s.jsx(Lk,{url:n.url}):n.kind==="confirm"?s.jsxs("div",{className:"merge-confirm",children:[s.jsx("span",{className:"t-meta",children:"Merge its pull request, at exactly the commit Teamtrail verified?"}),s.jsx(I,{size:"sm",onClick:()=>void t.merge(),children:"Merge"}),s.jsx(I,{size:"sm",variant:"ghost",onClick:t.cancel,children:"Cancel"})]}):s.jsxs("div",{className:"merge-confirm",children:[s.jsx(I,{size:"sm",disabled:n.kind==="working",onClick:t.ask,children:n.kind==="working"?"Merging…":"Approve and merge"}),n.kind==="error"&&s.jsx("span",{className:"t-meta",children:n.text})]})}function zp(e){const[t,...n]=e.gaps;return s.jsxs("div",{className:"merge-gaps",children:[s.jsxs("span",{className:"t-meta",children:["Not verified: ",t??"no passing completion."]}),n.length>0&&s.jsx(rn,{label:`${n.length} more`,children:s.jsx("ul",{className:"proof-gaps t-meta",children:n.map(i=>s.jsx("li",{children:i},i))})})]})}function R2(e){const t=_k(e),{state:n}=t;return n.kind==="merged"?s.jsx(Lk,{url:n.url,anyway:!0}):n.kind==="confirm"?s.jsxs("div",{className:"merge-confirm",children:[s.jsx("span",{className:"t-meta",children:"Merge without a verified proof? It is recorded as your decision, accepting what isn't verified."}),s.jsx(I,{size:"sm",onClick:()=>void t.merge(e.gaps),children:"Merge anyway"}),s.jsx(I,{size:"sm",variant:"ghost",onClick:t.cancel,children:"Cancel"}),s.jsx(zp,{gaps:e.gaps})]}):s.jsxs("div",{className:"merge-confirm",children:[s.jsx(I,{size:"sm",disabled:n.kind==="working",onClick:t.ask,children:n.kind==="working"?"Merging…":"Merge anyway"}),n.kind==="error"&&s.jsx("span",{className:"t-meta",children:n.text}),s.jsx(zp,{gaps:e.gaps})]})}function I2(e){var a,c;const t=(a=pt())==null?void 0:a.merge,n=(c=e.proof)==null?void 0:c.proof;if(!t||!n)return null;const i={path:t,mapId:e.mapId,ticketId:e.ticketId};return n.status==="verified"?s.jsx(A2,{...i}):s.jsx(R2,{...i,gaps:n.gaps})}function Bk(e){const{v:t,bar:n}=e,{primary:i}=n,a=t.session,c=a&&(i==null?void 0:i.id)!=="answer",d=t.t.state==="closed"&&t.t.closeReason==="completed";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"actions action-bar",children:[i&&s.jsx(I,{variant:n.variant,"data-tip":i.tip,onClick:i.onSelect,children:i.label}),d&&s.jsx(I2,{mapId:t.snap.map.id,ticketId:t.t.id,proof:t.proof}),c&&s.jsx(I,{onClick:()=>e.onOpenChat(a.id),"data-tip":`The conversation with ${a.agent}`,children:"Open chat"}),s.jsx(ok,{items:n.menu,label:"More ticket actions"})]}),n.error&&s.jsx("p",{className:"vf-err",children:n.error}),n.note&&s.jsx("p",{className:"t-meta bar-note",children:n.note})]})}const Fk=/^\*\*([^*]+)\*\*\s*/;function M2(e){var n;const t=(n=e.match(Fk))==null?void 0:n[1];return t?t.replace(/:$/,"").toLowerCase():"comment"}function O2(e){const t=e.decisions.map(i=>({id:i.id,at:i.decidedAt,who:Su(i,e.people),kind:i.supersededBy?`decision, superseded by ${i.supersededBy}`:"decision",text:i.summary||i.answer,decision:i.id})),n=e.comments.filter(i=>!(t.length&&i.body.startsWith("**Resolution**"))).map(i=>({id:i.id,at:i.createdAt,who:fi(i.author,e.people),kind:M2(i.body),text:i.body.replace(Fk,"").replace(/\*\*/g,"")}));return[...t,...n].sort((i,a)=>a.at-i.at)}function L2(e){const t=e.entry,n=t.decision&&e.onOpenDecision;return s.jsxs("li",{className:"history-item",children:[s.jsx(B,{parts:[{text:t.who,strong:!0},t.kind,rs(t.at)],children:n&&s.jsxs("button",{type:"button",className:"d-more",onClick:()=>{var i;return(i=e.onOpenDecision)==null?void 0:i.call(e,t.decision)},children:[t.decision," ›"]})}),s.jsx(rk,{text:t.text})]})}function P2(e){const t=Cr(),[n,i]=y.useState(!1),a=O2({comments:e.t.comments,decisions:e.decisions,people:t});if(!a.length)return null;const c=n?a:a.slice(0,1);return s.jsxs(sn,{label:"History",className:"ticket-history",children:[s.jsx("ul",{className:"history",children:c.map(d=>s.jsx(L2,{entry:d,onOpenDecision:e.onOpenDecision},d.id))}),a.length>1&&s.jsx("button",{type:"button",className:"d-more","aria-expanded":n,onClick:()=>i(!n),children:n?"Show the latest only":`Show all ${a.length}`})]})}function zk(e){return s.jsx("ul",{className:"checklist-answers",children:e.answers.map(t=>s.jsxs("li",{className:t.done?"done":"not-done",children:[s.jsx("span",{className:"mark","aria-label":t.done?"Done":"Not done",children:t.done?"✓":"–"}),s.jsx("span",{className:"t-body",children:t.item}),t.note&&s.jsx("span",{className:"t-meta note",children:t.note})]},t.item))})}const Uk=`${J.apiPrefix}`;async function Wk(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`Request failed (${e.status})`);return t}const ha=async e=>Wk(await fetch(`${Uk}${e}`)),Hk=async(e,t)=>Wk(await fetch(`${Uk}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}));function D2(e,t){const[n,i]=y.useState(),a=`/guides/checklist?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`;return Le({view:a,load:()=>ha(a),show:c=>i(c.checklist),failed:()=>i(null),changed:c=>c.endsWith("checklist.json")}),n}function _2(e){const t=D2(e.mapId,e.ticketId);if(!t)return null;const n=t.guides.map(i=>`${i.guide.id} ${i.answers.filter(a=>a.done).length}/${i.answers.length}`);return s.jsxs(Et,{label:"Checklists",children:[s.jsx("span",{className:"t-body",children:n.join(" · ")}),s.jsx(rn,{children:t.guides.map(i=>s.jsxs("div",{className:"checklist-panel",children:[s.jsx(B,{parts:[`${i.guide.id} ${i.guide.version}`,t.by,rs(t.at)]}),s.jsx(zk,{answers:i.answers})]},i.guide.id))})]})}let Kk;const ta=new Set;let es;function Gd(e){Kk=e;for(const t of ta)t()}function Gk(e){es==null||es.pushed(),Gd(e)}const B2=()=>Kk;function F2(e){return ta.add(e),es??(es=mk({load:()=>ha("/guides"),show:Gd,failed:()=>Gd(null),changed:t=>t.includes("guides")})),()=>{ta.delete(e),!ta.size&&(es==null||es.stop(),es=void 0)}}function gn(){const e=y.useSyncExternalStore(F2,B2),t=y.useCallback(async(i,a)=>{try{Gk(await Hk(i,a));return}catch(c){return c.message}},[]),n=y.useCallback(i=>i?e==null?void 0:e.guides.find(a=>a.id===i):void 0,[e]);return{view:e,act:t,find:n}}const z2={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"},U2={active:"Approved",unapproved:"Not approved yet",tampered:"Changed since you approved it",invalid:"Can't be used"},Vd=e=>{var t;return e.origin==="local"&&(!((t=e.lock)!=null&&t.source)||e.lock.source==="local")};function W2(e){return Vd(e)?{text:U2[e.status],strong:e.status==="active"}:e.status==="active"?void 0:z2[e.status]}function fa(e){try{return new URL(e).host}catch{return e}}function H2(e){var n;if(e.origin==="builtin")return"Built in";const t=(n=e.lock)==null?void 0:n.source;return!t||t==="local"?e.overridesBuiltin?"Local, replaces the built-in":"Local":`From ${fa(t.registry)}`}const Ou=e=>e.map(t=>/\s/.test(t)?JSON.stringify(t):t).join(" "),Up=3;function K2(e,t){return e.length<=Math.max(t,Up+1)?e:`${e.slice(0,Math.max(t-1,Up)).trimEnd()}…`}function Vk(e){return e===HS?"Verified":`Verified by ${fa(e)}'s catalog`}function qk(e,t){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:Vk(t),strong:!0}:"Not reviewed"}function G2(e){var c,d;const t=(c=e.lock)==null?void 0:c.review;if(!t||e.status!=="active")return;if(!t.verified)return"Not reviewed";const n=t.reviewedBy.length>0?`Reviewed by ${t.reviewedBy.join(", ")}`:void 0,i=(d=e.lock)==null?void 0:d.source;return{text:i&&i!=="local"?Vk(i.registry):"Verified",strong:!0,tip:n}}var Qk=Vg();function Yk(e){return EN(e.spec)?s.jsxs("span",{className:"guide-unknown",children:[s.jsx("span",{className:"t-body",children:"Unknown program: Teamtrail can't tell what this runs. Approve it only if you know what it does."}),s.jsxs(I,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(e.name,!0),children:["I know what it runs: approve check ",e.name]})]}):s.jsxs(I,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(e.name,!1),children:["Approve check ",e.name]})}function V2(e){var w;const{preview:t}=e,{act:n,find:i}=gn(),[a,c]=y.useState({kind:"ready"}),[d,u]=y.useState(),f=t.entry.id,m=async()=>{u(void 0),c({kind:"adding"});try{c({kind:"added",pending:(await e.add(f,t.entry.sha256)).pendingChecks})}catch(b){u(b.message),c({kind:"ready"})}};if(t.entry.builtin)return s.jsxs("span",{className:"t-meta",children:["Built into ",J.name,": already available to every trail, nothing to add."]});if(a.kind!=="added"){const b=e.installed===t.entry.version,S=e.installed?"Update guide":"Add guide";return s.jsxs("div",{className:"add-guide",children:[!t.ok&&s.jsx("span",{className:"t-meta",children:"The lint found errors, so this guide can't be added."}),s.jsx(I,{variant:"primary",disabled:!t.ok||b||a.kind==="adding",onClick:()=>void m(),children:b?"Added":S}),d&&s.jsx("span",{className:"vf-err",children:d})]})}const g=((w=i(f))==null?void 0:w.pendingChecks)??a.pending,k=async(b,S)=>u(await n("/guides/checks/approve",{id:f,name:b,acknowledged:S}));return s.jsxs("div",{className:"add-guide",children:[s.jsx("p",{className:"t-body",children:g.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}.`}),g.map(b=>{var S,x,C;return s.jsxs("span",{className:"guide-check",children:[s.jsxs("code",{className:"t-code",children:[b,": ",Ou(((x=(S=t.guide)==null?void 0:S.proposedChecks[b])==null?void 0:x.run)??[])]}),s.jsx(Yk,{name:b,spec:((C=t.guide)==null?void 0:C.proposedChecks[b])??{run:[]},onApprove:(N,P)=>void k(N,P)})]},b)}),d&&s.jsx("span",{className:"vf-err",children:d})]})}function q2(e){const t=s.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?s.jsxs(s.Fragment,{children:[s.jsx("ul",{className:"vf-findings guide-findings",children:e.findings.map((n,i)=>s.jsxs("li",{className:`sev-${n.level}`,children:[s.jsxs("code",{className:"t-code",children:["line ",n.line]})," ",n.message," ",s.jsxs("span",{className:"t-meta",children:["(",n.rule,")"]})]},i))}),t]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"t-meta",children:"The lint found none of the problems it looks for."}),t]})}function Jk(e){var i,a;const{p:t}=e,n=Object.entries(((i=t.guide)==null?void 0:i.proposedChecks)??{});return s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"t-label",children:"Lint"}),s.jsx(q2,{findings:t.findings}),t.guide&&t.guide.checklist.length>0&&s.jsx("span",{className:"t-label",children:"Checklist"}),t.guide&&s.jsx("ul",{className:"catalog-checklist t-body",children:t.guide.checklist.map(c=>s.jsx("li",{children:c},c))}),n.length>0&&s.jsx("span",{className:"t-label",children:"Commands it proposes"}),n.map(([c,d])=>s.jsxs("code",{className:"t-code guide-check",children:[c,": ",Ou(d.run),d.cwd&&` (in ${d.cwd})`]},c)),s.jsx("span",{className:"t-label",children:"Instructions"}),s.jsx("pre",{className:"guide-preview",children:((a=t.guide)==null?void 0:a.instructions)??t.text})]})}function Q2(e){const t=pn(e.repo);if(!t)return null;const n=encodeURIComponent(`Report: ${e.id} ${e.version}`),i=`${t.replace(/\/+$/,"")}/issues/new?template=report-guide.yml&title=${n}`;return s.jsx("a",{className:"report-link t-meta",href:i,target:"_blank",rel:"noreferrer",children:"Report this guide"})}function Y2(e){const t=e.entry,[n,i]=y.useState(),[a,c]=y.useState();return y.useEffect(()=>{e.preview(t.id).then(i,d=>c(d.message))},[t.id]),s.jsxs("div",{className:"catalog-entry",children:[s.jsx(I,{size:"sm",variant:"ghost",onClick:e.onBack,children:"← All guides"}),s.jsx("h3",{className:"t-title",children:t.name??t.id}),s.jsx(B,{parts:[{text:t.id,code:!0},t.version,`by ${t.author}`,qk(t,e.catalogUrl),t.reviewedBy.length>0&&`reviewed by ${t.reviewedBy.join(", ")}`]}),s.jsx("p",{className:"t-body",children:t.summary}),t.history.length>0&&s.jsx("ul",{className:"catalog-history",children:t.history.map(d=>s.jsxs("li",{className:"t-meta",children:[d.version," · ",s.jsx("code",{className:"t-code",children:d.commit.slice(0,8)})," · ",d.at.slice(0,10)]},`${d.version}-${d.commit}`))}),a&&s.jsx("span",{className:"vf-err",children:a}),n&&s.jsx(Jk,{p:n}),n&&s.jsx(Q2,{repo:n.repo,id:t.id,version:t.version}),n&&s.jsx(V2,{preview:n,installed:e.installed,add:e.add})]})}function J2(e){const t=e.entry;return s.jsx("li",{className:"catalog-row","data-guide-id":t.id,children:s.jsx(he,{title:t.name??t.id,context:s.jsx(B,{parts:[{text:t.id,code:!0},t.version,t.author,qk(t,e.catalogUrl),t.reported&&"Reported"]}),detail:t.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}const Wp=e=>e?`registry=${encodeURIComponent(e)}`:"";function X2(e){const[t,n]=y.useState(),[i,a]=y.useState();y.useEffect(()=>{let u=!0;return n(void 0),a(void 0),ha(`/guides/catalog?${Wp(e)}`).then(f=>u&&n(f),f=>u&&a(f.message)),()=>{u=!1}},[e]);const c=y.useCallback(u=>ha(`/guides/catalog/preview?${Wp(e)}&id=${encodeURIComponent(u)}`),[e]),d=y.useCallback(async(u,f)=>{const m=await Hk("/guides/catalog/add",{registry:e,id:u,sha256:f});return Gk(m),m.installed},[e]);return{index:t,error:i,preview:c,add:d}}function Z2(e){var x,C;const[t,n]=y.useState(((x=e.registries[0])==null?void 0:x.name)??""),i=X2(t||void 0),{find:a}=gn(),[c,d]=y.useState(""),[u,f]=y.useState(!0),[m,g]=y.useState(),k=i.index?AN({guides:i.index.guides},{query:c,verifiedOnly:u}):[],w=(C=i.index)==null?void 0:C.guides.find(N=>N.id===m),b=N=>{var P,D,M;return((P=a(N))==null?void 0:P.origin)==="local"?(M=(D=a(N))==null?void 0:D.guide)==null?void 0:M.version:void 0},S=e.registries.find(N=>N.name===t);return Qk.createPortal(s.jsx("div",{className:"scrim catalog-scrim",onClick:N=>{N.stopPropagation(),e.onClose()},children:s.jsxs(Fe,{as:"div",className:"dialog catalog-dialog",onClick:N=>N.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("h3",{className:"t-title",children:"Guide catalog"}),e.registries.length>1&&s.jsx(rt,{compact:!0,"aria-label":"Catalog",value:t,options:e.registries.map(N=>({value:N.name,label:`${N.name} · ${fa(N.url)}`,hint:N.url})),onChange:n}),s.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]}),S&&e.registries.length===1&&s.jsx(B,{parts:[`Catalog ${S.name}`,{text:fa(S.url),code:!0}]}),w?s.jsx(Y2,{entry:w,catalogUrl:(S==null?void 0:S.url)??"",installed:b(w.id),preview:i.preview,add:i.add,onBack:()=>g(void 0)}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"catalog-filters",children:[s.jsx("input",{className:"catalog-search",placeholder:"Search guides","aria-label":"Search guides",value:c,onChange:N=>d(N.target.value)}),s.jsx(I,{size:"sm",on:u,"aria-pressed":u,onClick:()=>f(N=>!N),children:"Verified only"})]}),i.error&&s.jsx("span",{className:"vf-err",children:i.error}),!i.index&&!i.error&&s.jsx(Te,{children:"Reading the catalog…"}),i.index&&!k.length&&s.jsx(Te,{children:"No guides match."}),s.jsx("ul",{className:"catalog-list",children:k.map(N=>s.jsx(J2,{entry:N,catalogUrl:(S==null?void 0:S.url)??"",installed:b(N.id),onOpen:()=>g(N.id)},N.id))})]})]})}),document.body)}async function eE(e,t){const n=await fetch(`${ie()}/verification/screen`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({checks:e}),signal:t}).catch(()=>{});return n!=null&&n.ok?(await n.json().catch(()=>({}))).findings:void 0}const tE=400;function Xk(e){const[t,n]=y.useState([]),i=JSON.stringify(e);return y.useEffect(()=>{const a=new AbortController,c=setTimeout(()=>{const d=JSON.parse(i);eE(d,a.signal).then((u=[])=>{const f=m=>{var g;return((g=d[Number(m)])==null?void 0:g.run.join(" "))??""};a.signal.aborted||n(u.map(m=>({...m,command:f(m.check)})))})},tE);return()=>{clearTimeout(c),a.abort()}},[i]),t}function nE({text:e}){const t=e.split("`");return s.jsx(s.Fragment,{children:t.map((n,i)=>i%2?s.jsx("code",{className:"t-code",children:n},i):n)})}const sE={"wont-run":"Won't run",unsure:"May not run"},fd=s.jsx("span",{className:"sep",children:" · "});function iE(e){const{finding:t,onFix:n}=e,i=n&&t.fix;return s.jsxs("li",{className:`cs-finding cs-finding-${t.severity} t-meta`,children:[s.jsx("span",{className:"cs-dot","aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("span",{className:"cs-severity",children:sE[t.severity]}),e.named&&s.jsxs(s.Fragment,{children:[fd,s.jsx("code",{className:"t-code",children:t.check})]}),fd,s.jsx(nE,{text:i?i.problem:t.text}),i&&s.jsxs(s.Fragment,{children:[fd,s.jsxs("button",{type:"button",className:"d-more",onClick:()=>n(i.run),children:["Use ",s.jsx("code",{className:"t-code",children:i.run.join(" ")})]})]})]})]})}function Va(e){return e.findings.length?s.jsxs("div",{className:"cs-findings",children:[s.jsx("ul",{children:e.findings.map(t=>s.jsx(iE,{finding:t,named:e.named,onFix:e.onFix},`${t.check} ${t.text}`))}),e.action]}):null}function rE({spec:e}){const t=Xk([{name:"0",run:e.run,...e.cwd?{cwd:e.cwd}:{}}]);return s.jsx(Va,{findings:t})}function oE(e){const t=e.r.guide;if(!t)return null;const n=Object.entries(t.proposedChecks);if(!t.requiresChecks.length&&!n.length)return null;const i=e.r.status==="active";return s.jsxs("div",{className:"guide-checks",children:[t.requiresChecks.length>0&&s.jsxs("span",{className:"t-meta",children:["Adds checks ",s.jsx("code",{className:"t-code",children:t.requiresChecks.join(", ")})," to its tickets"]}),n.map(([a,c])=>{const d=e.r.pendingChecks.includes(a);return s.jsxs("span",{className:"guide-check",children:[s.jsxs("code",{className:"t-code",children:[a,": ",Ou(c.run)]}),d&&i&&s.jsx(rE,{spec:c}),d&&i&&s.jsx(Yk,{name:a,spec:c,busy:e.busy,onApprove:e.onApprove}),d&&!i&&s.jsx("span",{className:"t-meta",children:"approve the guide first"}),!d&&s.jsx("span",{className:"t-meta",children:"approved"})]},a)})]})}function aE(e){const{r:t}=e;if(!t.guide||!t.sha256)return null;const n=t.sha256;return s.jsxs("div",{className:"guide-review",children:[s.jsx(Jk,{p:{findings:t.findings,guide:t.guide}}),s.jsx(I,{size:"sm","aria-label":`Approve guide ${t.id}`,disabled:e.busy,onClick:()=>e.onApprove(n),children:"Approve"})]})}const cE="A file in guides/ replaces this built-in once you approve it; until then the built-in is used";function lE(e){var t,n;return e.override?cE:e.status==="unapproved"?(t=e.guide)==null?void 0:t.summary:e.reason??((n=e.guide)==null?void 0:n.summary)}function Zk(e){const{r:t}=e,n=t.id,i=t.override??t,a=(i.status==="unapproved"||i.status==="tampered")&&!!i.guide,c=t.status!=="active"||t.pendingChecks.length>0||a,d=t.guide?`${t.guide.name} ${t.guide.version}`:n;return s.jsx("li",{className:"guide-row","data-guide-id":n,children:s.jsx(he,{edge:c?"attention":"neutral",title:d,context:s.jsx(B,{parts:[{text:n,code:!0},H2(t),G2(t),W2(t),t.guide&&dE(t.guide.checklist.length)]}),detail:lE(t),actions:t.origin==="local"&&s.jsxs(I,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onAct("/guides/remove",{id:n}),children:["Remove guide ",n]}),below:s.jsxs(s.Fragment,{children:[a&&s.jsx(aE,{r:i,busy:e.busy,onApprove:u=>e.onAct("/guides/approve",{id:n,sha256:u})}),s.jsx(oE,{r:t,busy:e.busy,onApprove:(u,f)=>e.onAct("/guides/checks/approve",{id:n,name:u,acknowledged:f})})]})})})}const dE=e=>e===1?"1 checklist item":`${e} checklist items`;function uE(e){return s.jsxs(Ee,{title:"Write your own",children:[s.jsxs("p",{className:"vf-intro",children:["Write a guide for your team in your repo with ",s.jsxs("code",{className:"t-code",children:[J.slug," guides new <id>"]}),". It starts from a template in ",s.jsxs("code",{className:"t-code",children:[J.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?s.jsx("ul",{className:"guides-list own-guides",children:e.guides.map(t=>s.jsx(Zk,{r:t,busy:e.busy,onAct:e.onAct},t.id))}):s.jsx(Te,{children:"No guides of your own yet."}),e.error&&s.jsx("span",{className:"vf-err",children:e.error}),s.jsxs("p",{className:"t-meta guides-share",children:["Useful beyond your team? Check it with ",s.jsxs("code",{className:"t-code",children:[J.slug," guides lint"]})," and"," ",s.jsx("a",{href:KS,target:"_blank",rel:"noreferrer",children:"share it in the public catalog"}),"."]})]})}function hE(e){const{view:t,act:n}=gn(),[i,a]=y.useState(),[c,d]=y.useState(!1),[u,f]=y.useState(!1),m=y.useRef(null);if(y.useEffect(()=>{var w;e.focus&&t&&((w=m.current)==null||w.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const g=w=>(b,S)=>{d(!0),n(b,S).then(x=>{a(x?{own:w,message:x}:void 0),d(!1)})},k=w=>i&&i.own===w?i.message:void 0;return s.jsxs("div",{className:"guides-section",ref:m,children:[s.jsxs(Ee,{title:"Guides",children:[s.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."}),s.jsx("ul",{className:"guides-list",children:t.guides.filter(w=>!Vd(w)).map(w=>s.jsx(Zk,{r:w,busy:c,onAct:g(!1)},w.id))}),s.jsxs("div",{className:"guides-foot",children:[s.jsx(I,{size:"sm",onClick:()=>f(!0),children:"Browse guides"}),s.jsx(B,{parts:[{text:`${J.dataDir}/guides/`,code:!0},{text:"guides.lock.json",code:!0}]})]}),t.configErrors.length>0&&s.jsx("ul",{className:"vf-errors",children:t.configErrors.map(w=>s.jsx("li",{children:w},w))}),k(!1)&&s.jsx("span",{className:"vf-err",children:k(!1)})]}),s.jsx(uE,{guides:t.guides.filter(Vd),busy:c,onAct:g(!0),error:k(!0)}),u&&s.jsx(Z2,{registries:t.registries,onClose:()=>f(!1)})]})}function fE(e){const{view:t,find:n}=gn();if(!t)return null;const i=n(e.id);if((i==null?void 0:i.status)==="active")return null;const a=i?i.reason??i.status:"it is not installed";return s.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."]})}const mE={type:"by type",ticket:"added",removed:"removed"},pE=(e,t)=>e.removed?{change:{add:e.id},label:`Put back ${t}`,mark:"+"}:{change:{remove:e.id},label:`Remove ${t}`,mark:"×"};function ey(e){var w,b;const{view:t,find:n}=gn(),{row:i}=e,a=n(i.id),c=!!t&&(a==null?void 0:a.status)!=="active",d=((w=a==null?void 0:a.guide)==null?void 0:w.name)??i.id,u=i.removed?"removed":i.via,f=c?`${d}: ${(a==null?void 0:a.reason)??"not installed"}`:((b=a==null?void 0:a.guide)==null?void 0:b.summary)??d,{change:m,label:g,mark:k}=pE(i,d);return s.jsxs("span",{className:pe("ticket-guide-chip",i.removed&&"removed",c&&"off"),"data-guide-id":i.id,"data-via":u,title:f,children:[s.jsx("span",{className:"name",children:d}),s.jsx("span",{className:"how t-meta",children:mE[u]}),e.editable&&s.jsx("button",{type:"button",className:"chip-act","aria-label":g,title:g,onClick:()=>e.onChange(m),children:k})]})}function ty(e,t){const n=B0(e,t).map(c=>({...c,removed:!1})),a=(du(e).byType[t.type]??[]).filter(c=>{var d;return(d=t.guidesRemoved)==null?void 0:d.includes(c)});return[...n,...a.map(c=>({id:c,via:"type",removed:!0}))]}function gE(e){const{view:t}=gn();if(!t)return null;const n=ty(e.map,e.ticket).filter(i=>!i.removed);return n.length?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ticket-guides plain",children:n.map(i=>s.jsx(ey,{row:i,editable:!1,onChange:()=>{}},i.id))}),n.map(i=>s.jsx(fE,{id:i.id},i.id))]}):s.jsx("span",{className:"t-meta",children:"None"})}const Hp="";function vE(e){const{view:t}=gn();if(!t)return null;const n=t.guides.filter(a=>a.status==="active"&&a.guide&&!e.taken.includes(a.id));if(!n.length)return null;const i=[{value:Hp,label:"Add a guide"},...n.map(a=>({value:a.id,label:a.guide.name,hint:a.guide.summary}))];return s.jsx(rt,{compact:!0,className:"add-ticket-guide","aria-label":"Add a guide to this ticket",value:Hp,options:i,onChange:a=>a&&e.onAdd(a)})}function kE(e){const{view:t,act:n}=gn(),[i,a]=y.useState();if(!t)return null;const c=e.ticket,d=ty(e.map,c),u=d.filter(m=>!m.removed),f=m=>{a(void 0),n("/guides/ticket",{mapId:e.map.id,ticketId:c.id,...m}).then(a)};return s.jsxs("div",{className:"ticket-guides",children:[s.jsxs("span",{className:"guide-head",children:[d.map(m=>s.jsx(ey,{row:m,editable:!0,onChange:f},m.id)),s.jsx(vE,{taken:u.map(m=>m.id),onAdd:m=>f({add:m})})]}),i&&s.jsx("span",{className:"vf-err",children:i})]})}function yE(e){const{type:t,ids:n,usable:i}=e,a=n.filter(m=>!i.some(g=>g.id===m)),c=uv[t]??[],d=c.length!==n.length||c.some(m=>!n.includes(m)),u=m=>{var g,k;return((k=(g=i.find(w=>w.id===m))==null?void 0:g.guide)==null?void 0:k.name)??m},f=d?`default ${c.map(u).join(", ")||"none"}`:void 0;return s.jsxs("div",{className:"type-guides-row","data-type":t,children:[s.jsx("span",{className:"type-name",children:En[t]}),s.jsxs("span",{className:"type-toggles",children:[i.map(m=>{const g=n.includes(m.id);return s.jsx(I,{size:"sm",on:g,"aria-pressed":g,title:m.guide.summary,"data-guide-id":m.id,onClick:()=>e.onToggle(m.id),children:m.guide.name},m.id)}),a.map(m=>s.jsx(I,{size:"sm",on:!0,"aria-pressed":!0,className:"off",title:`${m} can't be used now`,onClick:()=>e.onToggle(m),children:m},m))]}),s.jsx(B,{className:"type-hint",parts:[f]})]})}const wE={defaults:"Defaults",team:"Defaults, kept within the trail's earlier team"};function xE(e){var g;const{view:t,act:n}=gn(),[i,a]=y.useState();if(!t)return null;const{byType:c,source:d}=du(e.map),u=t.guides.filter(k=>k.status==="active"&&k.guide),f=k=>{a(void 0),n("/guides/trail",{mapId:e.map.id,byType:k}).then(a)},m=(k,w)=>{const b=c[k]??[],S=b.includes(w)?b.filter(x=>x!==w):[...b,w];f({...c,[k]:S})};return s.jsxs(Ee,{title:"Guides by type",children:[s.jsx("div",{className:"type-guides-head",children:d==="trail"?s.jsx(I,{size:"sm",variant:"ghost",onClick:()=>f(null),children:"Back to defaults"}):s.jsx(B,{parts:[wE[d],d==="team"&&((g=e.map.guides)==null?void 0:g.join(", "))]})}),s.jsx("div",{className:"type-guides",children:is.map(k=>s.jsx(yE,{type:k,ids:c[k]??[],usable:u,onToggle:w=>m(k,w)},k))}),i&&s.jsx("span",{className:"vf-err",children:i})]})}function jE(e){var f;const{view:t,find:n}=gn();if(!e)return;const i=n(e),a=t!=null&&(i==null?void 0:i.status)!=="active",c=((f=i==null?void 0:i.guide)==null?void 0:f.name)??e,d=i!=null&&i.guide?`${c} ${i.guide.version}`:c,u=a?`Guide ${d}: ${(i==null?void 0:i.reason)??"not installed"}`:`Guide: ${d}`;return{id:e,name:c,tip:u,off:a}}function bE({check:e}){const t=Ik(e),[n,i]=y.useState(),[a,c]=y.useState(),d=SE(e);return s.jsxs("details",{className:`vf-row ${t?"ok":"bad"}`,open:!t,children:[s.jsxs("summary",{children:[s.jsx("span",{className:"vf-mark",children:t?"✓":"✕"}),s.jsx("span",{className:"t-code vf-name",children:e.name}),s.jsx("span",{className:"t-meta",children:d}),s.jsx("span",{className:"t-meta vf-dur",children:Gt(e.durationMs)})]}),s.jsx("code",{className:"vf-argv",children:e.argv.join(" ")}),e.error&&s.jsx("p",{className:"vf-note",children:e.error}),s.jsx("pre",{className:"vf-tail",children:n??(e.tail||"No output.")}),s.jsxs("div",{className:"vf-log-line",children:[n===void 0&&s.jsx("button",{className:"link",onClick:()=>bs.log(e.log).then(u=>i(u.clipped?`[earlier output not shown]
|
|
147
|
+
${u.text}`:u.text),u=>c(u.message)),children:"Full log ›"}),e.truncated&&s.jsx("span",{className:"dim",children:"log capped at 1 MB"}),a&&s.jsx("span",{className:"vf-err",children:a})]})]})}function SE(e){return e.error?"did not start":e.timedOut?"timed out":`exit ${e.exitCode??e.signal??"?"}`}const Kp=e=>(e==null?void 0:e.slice(0,8))??"none",Gp=e=>e===null?"·":String(e);function NE({attempt:e}){var d;const t=e.git;if(!t)return null;const{files:n,add:i,del:a}=t.stats,c=new Set(((d=t.flags.find(u=>u.kind==="outside-scope"))==null?void 0:d.files)??[]);return s.jsxs("div",{className:"vf-git",children:[s.jsx(B,{parts:[t.tree?{text:`${t.base?`${Kp(t.base.head)} → `:""}${Kp(t.tree.head)}`,code:!0}:"not a git repo",t.tree&&{text:t.tree.branch??"detached HEAD",code:!!t.tree.branch},t.tree&&`${n} file${n===1?"":"s"} +${i} −${a}`]}),t.flags.filter(u=>u.kind!=="no-git"&&u.kind!=="check-guard").map(u=>{var f;return s.jsxs("p",{className:`vf-flag lv-${u.level}`,title:(f=u.files)==null?void 0:f.join(`
|
|
148
|
+
`),children:[s.jsx("span",{className:"t-code",children:u.kind})," ",u.message]},u.kind)}),t.changed.length>0&&s.jsxs("details",{className:"vf-files",children:[s.jsx("summary",{className:"t-label",children:"Changed files"}),s.jsx("ul",{children:t.changed.map(u=>s.jsxs("li",{children:[s.jsx("code",{children:u.path}),s.jsxs("span",{className:"dim",children:[u.untracked?"new":`+${Gp(u.add)} −${Gp(u.del)}`,u.dirtyAtClaim?" · dirty at claim":"",c.has(u.path)?" · outside the declared files":""]})]},u.path))})]})]})}function $E({attempt:e}){const t=e.guard;if(!(t!=null&&t.findings.length))return null;const n=t.mode==="enforce"&&e.result==="pass";return s.jsxs("div",{className:`vf-guard${n?" held":""}`,children:[s.jsx("p",{className:"vf-guard-head",children:n?"Checks passed, but the work changed what they run":"The work changed what its checks run"}),s.jsx("ul",{children:t.findings.map(i=>s.jsxs("li",{children:[i.text,i.check&&s.jsxs("span",{className:"dim",children:[" · ",i.check]})]},`${i.file}\0${i.text}`))}),n&&s.jsx("p",{className:"t-meta",children:"The pass counts once you accept it."})]})}function CE({attempt:e,latest:t}){return s.jsxs("details",{className:`vf-attempt r-${e.result}`,open:t,children:[s.jsxs("summary",{children:[s.jsx(wi,{tone:"state",className:`r-${e.result}`,children:Rk[e.result]}),s.jsx(B,{parts:[{text:e.id,code:!0},e.agent,rs(e.submittedAt),Gt(e.finishedAt-e.submittedAt)]})]}),s.jsx("p",{className:"vf-claim",children:e.summary??e.resolution}),e.note&&!(e.result==="pass"&&e.guard)&&s.jsx("p",{className:"vf-note",children:e.note}),s.jsx($E,{attempt:e}),e.criteria&&s.jsx("ul",{className:"vf-criteria",children:e.criteria.lines.map(n=>s.jsx("li",{className:TE(n),children:n},n))}),s.jsx(NE,{attempt:e}),e.checks.map(n=>s.jsx(bE,{check:n},n.name))]})}function TE(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":e.includes(" ? ")?"claimed":"wait"}const EE={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function AE(e){var t;return(t=e.guides)!=null&&t.length?e.guides:e.guide?[{guide:e.guide,answers:e.checklist??[]}]:[]}function RE({verdict:e}){const t=AE(e);return s.jsxs("div",{className:`vf-verdict v-${e.verdict.toLowerCase()}`,children:[s.jsx(B,{parts:[{text:e.byKind==="trail lead"&&e.verdict==="PASS"?"Approved":EE[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.length>0&&`as ${t.map(n=>`${n.guide.id} ${n.guide.version}`).join(", ")}`,`on ${e.attemptId}`,rs(e.at)]}),s.jsx("p",{children:e.summary}),e.findings.length>0&&s.jsx("ul",{className:"vf-findings",children:e.findings.map((n,i)=>s.jsxs("li",{className:`sev-${n.severity}`,children:[n.path&&s.jsx("code",{children:n.line?`${n.path}:${n.line}`:n.path})," ",n.text]},i))}),t.map(n=>n.answers.length>0&&s.jsx(zk,{answers:n.answers},n.guide.id))]})}const IE={PASS:"review passed",FAIL:"review sent it back",NEEDS_HUMAN:"reviewer asked for you"};function ME({data:e}){const t=e.attempts[0];if(!t)return null;const n=e.attempts.length,i=e.verdicts.find(a=>a.attemptId===t.id);return s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"t-body",children:[n," ",n===1?"attempt":"attempts"," · latest ",Rk[t.result].toLowerCase()]}),s.jsx(B,{parts:[{text:t.id,code:!0},t.agent,rs(t.submittedAt),i&&IE[i.verdict]]}),s.jsx(rn,{children:s.jsxs("div",{className:"vf-panel",children:[e.verdicts.map(a=>s.jsx(RE,{verdict:a},a.id)),e.attempts.map((a,c)=>s.jsx(CE,{attempt:a,latest:c===0},a.id))]})})]})}const ma="";function OE(e){const t=au.map(i=>({value:i,label:Er[i],hint:Iu[i]})),n=[...LE(e),...t];return s.jsx(rt,{compact:!0,className:"vf-level","aria-label":"Verification level",value:e.value??ma,options:n,onChange:i=>e.onChange(i===ma?null:i)})}function LE(e){return e.inherit!==void 0?[{value:ma,label:e.inherit,hint:"Use the trail’s level for this ticket."}]:e.value===void 0?[{value:ma,label:"Off (not set)"}]:[]}const PE={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."}},DE={rework:{label:"What to fix",submit:"Send to rework",hint:"The agent is told to find the root cause: no sleeps, retries or skipped tests."},accept:{label:"Why the pass counts",submit:"Accept the pass",hint:"Closes it as done. The proof says it passed on retry."}},Vp="The pass counts although the work changed what its checks run. The proof says you accepted it.";function _E(e){return e.kind!=="accept"||!e.guarded?e.hint:e.retried?`${Vp} It also passed only on retry.`:Vp}function BE(e){const{kind:t}=e,n=e.retried&&DE[t]||PE[t],[i,a]=y.useState(""),[c,d]=y.useState("rework"),u=f=>{f.preventDefault(),i.trim()&&e.onSubmit({action:t,reason:i.trim(),...t==="unblock"?{to:c}:{}})};return s.jsxs(Vt,{as:"form",tone:"inset",className:"inline-form",onSubmit:u,children:[s.jsx(Je,{label:n.label,children:s.jsx("textarea",{rows:2,value:i,onChange:f=>a(f.target.value),autoFocus:!0})}),t==="unblock"&&s.jsx(Je,{label:"Back to",children:s.jsx(rt,{"aria-label":"Back to",value:c,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."}]})}),s.jsx("span",{className:"t-meta",children:_E({kind:t,guarded:e.guarded,retried:e.retried,hint:n.hint})}),s.jsxs("div",{className:"form-actions",children:[s.jsx(I,{variant:"ghost",onClick:e.onCancel,children:"Cancel"}),s.jsx(I,{type:"submit",variant:t==="accept"?"danger":"primary",disabled:!i.trim(),children:n.submit})]})]})}function FE(e,t,n){const[i,a]=y.useState(),c=`${e}/${t}`;y.useEffect(()=>a(void 0),[c]);const{reload:d}=Le({view:c,version:n,load:()=>bs.ticket(e,t),show:a});return y.useEffect(()=>ns.onEvidence(d),[d]),{data:i,reload:d}}const zE={ticket:"set on this ticket",trail:"from the trail",none:"not set"};function UE({level:e}){return e.level==="off"?"Off":e.checks.join(", ")||"No checks"}function WE({data:e}){const{level:t}=e;return s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"t-body",children:UE(e)}),s.jsx(B,{parts:[t.level!=="off"&&Er[t.level],zE[t.source]]}),s.jsx(rn,{children:s.jsx("p",{className:"t-meta",children:Iu[t.level]})})]})}function HE(e){return e.waivers.length?s.jsxs(Et,{label:"Skipped",children:[e.waivers.map(t=>s.jsx(B,{parts:[{text:t.checks.map(n=>n.name).join(", "),code:!0},t.by,t.reason]},t.id)),s.jsx(I,{size:"sm",variant:"ghost","data-tip":"The checks run again on the next completion",onClick:e.onUndo,children:"Undo"})]}):null}function KE(e){if(e)return e.timedOut?"timed out":e.error?`couldn't run: ${e.error}`:`exited ${e.exitCode??e.signal}`}function GE(e){const[t,n]=y.useState(()=>new Set(e.waivable.map(g=>g.name))),[i,a]=y.useState(""),c=e.waivable.filter(g=>t.has(g.name)),d=c.map(g=>g.name).join(", "),u=c.length>0&&!!i.trim(),f=(g,k)=>{const w=new Set(t);k?w.add(g):w.delete(g),n(w)},m=g=>{g.preventDefault(),u&&e.onSubmit({checks:c,reason:i.trim()})};return s.jsxs(Vt,{as:"form",tone:"inset",className:"inline-form waive-form",onSubmit:m,children:[e.waivable.length>1&&s.jsx("fieldset",{className:"waive-checks",children:e.waivable.map(g=>s.jsxs("label",{className:"waive-check t-body",children:[s.jsx("input",{type:"checkbox",checked:t.has(g.name),onChange:k=>f(g.name,k.target.checked)}),s.jsx("code",{className:"t-code",children:g.name})]},g.name))}),s.jsx(Je,{label:`Why it can go without ${d||"them"}`,children:s.jsx("textarea",{rows:2,value:i,onChange:g=>a(g.target.value),autoFocus:!0})}),s.jsx("span",{className:"t-meta",children:"The other checks run again. The proof shows what was skipped, by you, and why."}),s.jsx(rn,{label:"What failed",children:e.waivable.map(g=>s.jsx(B,{parts:[{text:g.name,code:!0},{text:g.argv.join(" "),code:!0},KE(e.results.find(k=>k.name===g.name))]},g.name))}),s.jsxs("div",{className:"form-actions",children:[s.jsx(I,{variant:"ghost",onClick:e.onCancel,children:"Cancel"}),s.jsx(I,{type:"submit",variant:"primary",disabled:!u,children:c.length?`Accept without ${d}`:"Pick a check"})]})]})}function VE({v:e,act:t}){return s.jsxs("dl",{className:"facts how-editor",children:[s.jsx(Et,{label:"Guides",children:s.jsx(kE,{map:e.snap.map,ticket:e.t})}),s.jsx(Et,{label:"Verification",children:s.jsx(OE,{value:e.t.verification,inherit:`Trail (${Er[e.snap.map.verification??"off"]})`,onChange:n=>void t({action:"level",level:n})})})]})}const ny=y.createContext(null);function Es(){const e=y.useContext(ny);if(!e)throw new Error("useKnowledge needs a KnowledgeContext provider");return e}function qE({snap:e,t}){const n=Es();if(!n.entries.length||t.state==="closed")return null;const i=Mv(n.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:Ov(`${t.body}
|
|
149
|
+
${n.briefText}`)},4e3,c=>n.stale[c.id]??[]),a=i.length===1?"entry":"entries";return s.jsxs(Et,{label:"Knowledge",children:[s.jsx("span",{className:"t-body",children:i.length?`${i.length} ${a}`:"None picked"}),i.length>0&&s.jsx(rn,{children:s.jsx("ul",{className:"item-list",children:i.map(c=>s.jsxs("li",{children:[s.jsx("button",{className:"item-text kn-open",onClick:()=>n.setOpen(!0),"data-tip":c.why.join(" · "),children:c.title}),s.jsx(B,{parts:[{text:c.id,code:!0},c.status==="assumption"&&"assumption",c.mayBeOutdated&&{text:"may be outdated",className:"warn"}]})]},c.id))})})]})}function Qo(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 pa(e,t){const[n,i]=y.useState({key:e,shown:Qo(void 0,t)});let a=n;return n.key!==e?a={key:e,shown:Qo(void 0,t)}:n.shown.latest!==t&&(a={key:e,shown:Qo(n.shown,t)}),a!==n&&i(a),{hash:a.shown.hash,changed:a.shown.hash!==a.shown.latest,reviewAgain:()=>i({key:e,shown:Qo(void 0,t)})}}const QE={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 YE({e}){const t=Es(),[n,i]=y.useState(!1),[a,c]=y.useState(e.title),[d,u]=y.useState(e.body);y.useEffect(()=>{i(!1),c(e.title),u(e.body)},[e.id,e.title,e.body]);const f=t.stale[e.id],m=pa(e.id,t.hashes[e.id]);return s.jsxs("div",{className:"kn-detail",children:[s.jsx(B,{parts:[{text:e.id,code:!0},e.kind.replace("-"," "),e.status]}),n?s.jsxs(s.Fragment,{children:[s.jsx(Je,{label:"Title",children:s.jsx("input",{value:a,onChange:g=>c(g.target.value)})}),s.jsx(Je,{label:"Body",children:s.jsx("textarea",{rows:8,value:d,onChange:g=>u(g.target.value)})})]}):s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"t-title",children:e.title}),s.jsx("p",{className:"kn-body",children:e.body})]}),s.jsx("p",{className:"dim",children:QE[e.status]}),e.flag&&s.jsxs("p",{className:"kn-warn",children:["Flagged by ",e.flag.by,": ",e.flag.reason]}),f&&e.status!=="outdated"&&s.jsxs("p",{className:"kn-warn",children:["May be outdated: ",f.join(", ")," changed since it was confirmed. Re-confirm or edit it."]}),s.jsxs("dl",{className:"facts",children:[e.scope.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Applies to"}),s.jsx("dd",{children:e.scope.join(", ")})]}),e.tags.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Tags"}),s.jsx("dd",{children:e.tags.join(", ")})]}),s.jsx("dt",{children:"From"}),s.jsx("dd",{children:[e.createdBy,...e.sources].join(" · ")}),e.anchors.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"About files"}),s.jsx("dd",{children:e.anchors.map(g=>g.path).join(", ")})]})]}),m.changed&&s.jsx(Nu,{what:"This entry",onReviewAgain:m.reviewAgain}),t.error&&s.jsx("p",{className:"vf-err",children:t.error}),s.jsx("div",{className:"actions",children:n?s.jsxs(s.Fragment,{children:[s.jsx(I,{variant:"ghost",onClick:()=>i(!1),children:"Cancel"}),s.jsx(I,{variant:"primary",disabled:!a.trim(),onClick:()=>void t.call(e.id,{kind:"edit",title:a,body:d}).then(g=>g&&i(!1)),children:"Save"})]}):s.jsxs(s.Fragment,{children:[(e.status!=="confirmed"||f)&&s.jsx(I,{variant:"primary",disabled:m.changed,onClick:()=>void t.call(e.id,{kind:"confirm"},m.hash),children:e.status==="confirmed"?"Re-confirm":"Confirm"}),e.status!=="assumption"&&e.status!=="outdated"&&s.jsx(I,{disabled:m.changed,onClick:()=>void t.call(e.id,{kind:"assumption"},m.hash),children:"Keep as assumption"}),e.flag&&s.jsx(I,{onClick:()=>void t.call(e.id,{kind:"resolve-flag"}),children:"Resolve flag"}),s.jsx(I,{variant:"ghost",onClick:()=>i(!0),children:"Edit"}),e.status!=="outdated"&&s.jsx(I,{variant:"ghost",onClick:()=>void t.call(e.id,{kind:"outdated"}),children:"Mark outdated"})]})})]})}const JE={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function XE(){const e=Es(),[t,n]=y.useState("review"),[i,a]=y.useState(""),[c,d]=y.useState(""),[u,f]=y.useState();y.useEffect(()=>{if(!e.open)return;const x=C=>C.key==="Escape"&&e.setOpen(!1);return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[e]);const m=x=>x.status==="suggested"||!!x.flag||!!e.stale[x.id]&&x.status!=="outdated",g=(x,C)=>C==="all"?!0:C==="review"?m(x):x.status===C,k=y.useMemo(()=>{const x=c.trim().toLowerCase();return e.entries.filter(C=>g(C,t)&&(!i||C.kind===i)&&(!x||`${C.id} ${C.title} ${C.body} ${C.tags.join(" ")}`.toLowerCase().includes(x)))},[e.entries,e.stale,t,i,c]);if(!e.open)return null;const w=k.find(x=>x.id===u)??k[0],b=x=>e.entries.filter(C=>g(C,x)).length,S=[["review","Needs you"],["confirmed","Confirmed"],["assumption","Assumptions"],["outdated","Outdated"],["all","All"]];return s.jsx("div",{className:"scrim",onClick:()=>e.setOpen(!1),children:s.jsxs(Fe,{as:"div",className:"dialog knowledge-view",onClick:x=>x.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("h2",{className:"t-heading caps",children:"Field guide"}),s.jsx(ki,{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>"})]}),s.jsxs("div",{className:"kn-filters",children:[S.map(([x,C])=>s.jsxs("button",{className:`chip ${t===x?"on":""}`,onClick:()=>n(x),children:[C," ",s.jsx("span",{className:"n",children:b(x)})]},x)),s.jsx(rt,{compact:!0,"aria-label":"Kind",value:i,onChange:a,options:[{value:"",label:"Any kind"},...Vb.map(x=>({value:x,label:x.replace("-"," ")}))]}),s.jsx("input",{className:"kn-search",placeholder:"Search",value:c,onChange:x=>d(x.target.value)})]}),s.jsxs("div",{className:"kn-body-grid",children:[s.jsx("ul",{className:"kn-list",children:k.length?k.map(x=>s.jsx(he,{as:"li",className:`kn-row st-${x.status}`,edge:m(x)?"attention":"neutral",selected:x===w,onOpen:()=>f(x.id),title:x.title,titleText:x.title,context:s.jsx(B,{parts:[{text:x.id,code:!0},x.kind.replace("-"," "),m(x)&&x.status!=="suggested"?"Needs a check":JE[x.status]]})},x.id)):s.jsx(Te,{children:t==="review"?"Nothing needs you":"No entries"})}),w?s.jsx(YE,{e:w}):s.jsx(Te,{children:"Pick an entry"})]})]})})}function sy({draft:e,label:t="Save as knowledge"}){const n=Es(),[i,a]=y.useState();return i?s.jsxs(I,{size:"sm",variant:"ghost",onClick:()=>n.setOpen(!0),"data-tip":"Open it in the field guide to confirm it",children:["Saved as ",i]}):s.jsx(I,{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 n.propose(e()).then(c=>c&&a(c.id)),children:t})}const iy=`${ie()}/knowledge`;async function qp(e,t){const n=await fetch(`${iy}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i=await n.json().catch(()=>({}));if(!n.ok)throw new Error(i.error??`HTTP ${n.status}`);return i}async function ZE(){const e=await fetch(iy);return e.ok?await e.json():null}function eA(e){const[t,n]=y.useState([]),[i,a]=y.useState({}),[c,d]=y.useState({}),[u,f]=y.useState(!1),[m,g]=y.useState(),{reload:k}=Le({load:ZE,show:b=>{b&&(n(b.entries),a(b.stale),d(b.hashes??{}))},changed:b=>b.startsWith("knowledge/")}),w=y.useMemo(()=>t.filter(b=>b.status==="suggested"||b.flag||i[b.id]&&b.status!=="outdated").length,[t,i]);return{entries:t,stale:i,briefText:e,attention:w,open:u,setOpen:f,error:m,hashes:c,call:(b,S,x)=>qp("/call",{id:b,call:S,hash:x??c[b]}).then(()=>(g(void 0),k(),!0),C=>(g(C.message),k(),!1)),propose:b=>qp("/propose",b).then(S=>(k(),S.entry),S=>(g(S.message),void 0))}}function tA({v:e}){return s.jsxs("dl",{className:"facts",children:[s.jsx(Et,{label:"Guides",children:s.jsx(gE,{map:e.snap.map,ticket:e.t})}),e.verification&&s.jsx(Et,{label:"Checks",children:s.jsx(WE,{data:e.verification})}),s.jsx(qE,{snap:e.snap,t:e.t})]})}function nA(e){const{v:t}=e,n=e.editing&&t.t.state==="open",i=t.t.state==="open"?()=>e.setEditing(!n):void 0;return s.jsx(sn,{label:"How",className:"ticket-how",onEdit:i,editLabel:n?"Done":"Edit",children:n?s.jsx(VE,{v:t,act:e.act}):s.jsx(tA,{v:t})})}function sA({lease:e,now:t}){var a;const n=Ts(e,t),i=e.notes.at(-1);return s.jsxs(s.Fragment,{children:[s.jsxs(Et,{label:"Claim",children:[s.jsxs("span",{className:"t-body",children:[e.agent," since ",rs(e.claimedAt)]}),s.jsx(B,{parts:[`active ${Xe(t-e.renewedAt)} ago`,n==="live"&&iA(rA(e.expiresAt-t))]})]}),e.workspace&&s.jsxs(Et,{label:"Branch",children:[s.jsx("code",{className:"t-code",children:e.workspace.branch}),s.jsx(B,{parts:["its own worktree"]})]}),!!((a=e.touches)!=null&&a.length)&&s.jsx(Et,{label:"Changes",children:s.jsx("span",{className:"t-code",children:e.touches.join(", ")})}),i&&s.jsxs(Et,{label:"Latest note",children:[s.jsx("span",{className:"t-body",children:i}),e.notes.length>1&&s.jsx(rn,{label:"Earlier notes",children:s.jsx("ul",{className:"lease-notes t-meta",children:e.notes.slice(0,-1).map((c,d)=>s.jsx("li",{children:c},d))})})]})]})}function iA(e){return`back in the queue after ${e} without activity`}function rA(e){const t=e/864e5;return t>=2?`${Math.round(t)} days`:Gt(Math.max(0,e))}function oA({v:e,onUndoWaiver:t}){var a,c;const n=((a=e.verification)==null?void 0:a.attempts.length)??0;if(!e.lease&&!e.workspace&&!n&&!e.pr)return null;const i=e.snap.map.id;return s.jsx(sn,{label:"Progress",className:"ticket-progress",children:s.jsxs("dl",{className:"facts",children:[e.lease&&s.jsx(sA,{lease:e.lease,now:e.now}),e.workspace&&s.jsxs(Et,{label:"Workspace",children:[s.jsx("code",{className:"t-code",children:e.workspace.branch}),s.jsx("span",{className:"t-meta ws-path",title:e.workspace.path,children:e.workspace.path})]}),e.pr&&s.jsx(Et,{label:"Pull request",children:s.jsx(cT,{mapId:i,ticketId:e.t.id})}),n>0&&e.verification&&s.jsx(Et,{label:"Attempts",children:s.jsx(ME,{data:e.verification})}),n>0&&s.jsx(_2,{mapId:i,ticketId:e.t.id}),s.jsx(HE,{waivers:((c=e.verification)==null?void 0:c.waivers)??[],onUndo:t})]})})}function aA({v:e}){const t=e.standing,n=e.lease&&Ts(e.lease,e.now),i=e.criteria.changed??e.criteria.proposalChanged;return s.jsxs("div",{className:pe("standing edge-note",`edge-${t.edge}`,`st-${e.state}`,n&&`lease-${n}`,e.modelWait&&"model-wait"),children:[s.jsx("span",{className:"t-row-title standing-title",children:t.title}),s.jsx(B,{parts:t.parts}),e.notices.map(a=>s.jsx("span",{className:"t-meta standing-notice",children:a.text},a.text)),i&&s.jsx(Nu,{what:"The criteria",onReviewAgain:i.reviewAgain})]})}const qd=`${ie()}/workspaces`;async function cA(){const e=await fetch(qd);return e.ok?await e.json():null}function ry(){const[e,t]=y.useState(),{pushed:n}=Le({load:cA,show:t,failed:()=>t(null),changed:d=>d.endsWith("workspaces.json")||d.includes("workspaces/")||d.includes("leases/")}),i=y.useCallback(d=>{n(),t(d)},[n]),a=y.useCallback(async d=>{const u=await fetch(qd,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)}),f=await u.json();if(!u.ok)return f.error??`Saving failed (${u.status})`;i(f)},[i]),c=y.useCallback(async(d,u,f=!1)=>{const m=await fetch(`${qd}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:d,ticketId:u,force:f})}),g=await m.json();return m.ok?(i(g),{}):{error:g.error??`Removing failed (${m.status})`,dirty:g.dirty??!1}},[i]);return{view:e,save:a,remove:c}}function oy(e){const[t,n]=y.useState(!1),[i,a]=y.useState(),[c,d]=y.useState(!1),u=async f=>{d(!0),a(void 0);const m=await e.onRemove(f).catch(g=>({error:g.message,dirty:!1}));d(!1),n(!!m.dirty&&!f),m.dirty||a(m.error)};return t?s.jsxs("span",{className:"ws-remove ask",children:[s.jsx("span",{className:"vf-err",children:"Uncommitted changes in this workspace will be lost."}),s.jsx(I,{size:"sm",disabled:c,onClick:()=>u(!0),children:"Remove anyway"}),s.jsx(I,{size:"sm",variant:"ghost",onClick:()=>n(!1),children:"Keep"})]}):s.jsxs("span",{className:"ws-remove",children:[s.jsx(I,{size:"sm",disabled:c,onClick:()=>u(!1),children:e.label??"Remove"}),i&&s.jsx("span",{className:"vf-err",children:i})]})}function lA(e){return e.rows.length?s.jsx("ul",{className:"ws-list",children:e.rows.map(t=>s.jsx(he,{as:"li",className:`ws-row ${t.active?"active":"finished"}`,title:s.jsx("span",{className:"t-code",children:t.branch}),titleText:t.branch,context:s.jsx(B,{parts:[{text:t.ticketKey,code:!0},t.active?`Active · ${t.agent}`:"Finished"]}),detail:s.jsx("span",{className:"t-code",children:t.path}),detailText:t.path,below:t.active?void 0:s.jsx(oy,{onRemove:n=>e.onRemove(t.mapId,t.ticketId,n)})},`${t.mapId}/${t.ticketId}`))}):null}function dA(e){const t=e.workspace;return s.jsxs(Vt,{tone:"inset",className:"inline-form",children:[s.jsxs("p",{className:"t-body",children:["Delete the worktree at"," ",s.jsx("code",{className:"t-code",title:t.path,children:t.path}),"? Branch ",s.jsx("code",{className:"t-code",children:t.branch})," stays."]}),s.jsxs("div",{className:"form-actions",children:[s.jsx(I,{variant:"ghost",onClick:e.onCancel,children:"Cancel"}),s.jsx(oy,{label:"Remove workspace",onRemove:e.onRemove})]})]})}function uA(e){const[t,n]=y.useState(""),[i,a]=y.useState(""),[c,d]=y.useState(""),u=f=>{if(f.preventDefault(),!t.trim())return;const m=c.split(`
|
|
150
|
+
`).map(g=>g.trim()).filter(Boolean);e.onResolve(t.trim(),{rationale:i.trim(),alternatives:m})};return s.jsxs(Vt,{as:"form",tone:"inset",className:"inline-form",onSubmit:u,children:[s.jsx(Je,{label:"Resolution",children:s.jsx("textarea",{rows:3,value:t,onChange:f=>n(f.target.value),autoFocus:!0})}),s.jsx(Je,{label:"Rationale",children:s.jsx("input",{value:i,onChange:f=>a(f.target.value)})}),s.jsx(Je,{label:"Alternatives considered",children:s.jsx("textarea",{rows:2,value:c,onChange:f=>d(f.target.value),placeholder:"One per line"})}),s.jsxs("div",{className:"form-actions",children:[s.jsx(I,{variant:"ghost",onClick:e.onCancel,children:"Cancel"}),s.jsx(I,{type:"submit",variant:"primary",disabled:!t.trim(),children:"Resolve"})]})]})}function hA(e){const[t,n]=y.useState("Not needed to reach the destination."),i=a=>{a.preventDefault(),e.onRuleOut(t)};return s.jsxs(Vt,{as:"form",tone:"inset",className:"inline-form",onSubmit:i,children:[s.jsx(Je,{label:"Reason",children:s.jsx("input",{value:t,onChange:a=>n(a.target.value),autoFocus:!0})}),s.jsxs("div",{className:"form-actions",children:[s.jsx(I,{variant:"ghost",onClick:e.onCancel,children:"Cancel"}),s.jsx(I,{type:"submit",variant:"danger",children:"Rule out"})]})]})}const fA=e=>{var n,i;const t=(n=e.verification)==null?void 0:n.attempts[0];return(t==null?void 0:t.result)==="pass"&&((i=t.guard)==null?void 0:i.mode)==="enforce"};function ay(e){var c,d,u,f;const{form:t,v:n,actions:i}=e,a=()=>e.setForm(null);switch(t){case"resolve":return s.jsx(uA,{onResolve:(m,g)=>{i.resolve(n.t.id,m,g),a()},onCancel:a});case"rule":return s.jsx(hA,{onRuleOut:m=>{i.ruleOut({ticketId:n.t.id},m),a()},onCancel:a});case"rework":case"accept":case"unblock":return s.jsx(BE,{kind:t,retried:n.state==="held"&&uu((c=n.verification)==null?void 0:c.attempts[0]),guarded:fA(n),onSubmit:m=>{e.act(m),a()},onCancel:a});case"waive":return s.jsx(GE,{waivable:((d=n.verification)==null?void 0:d.waivable)??[],results:((f=(u=n.verification)==null?void 0:u.attempts[0])==null?void 0:f.checks)??[],onSubmit:m=>{e.waive(m),a()},onCancel:a});case"workspace":return n.workspace?s.jsx(dA,{workspace:n.workspace,onRemove:n.removeWorkspace,onCancel:a}):null;case null:return null;default:return t}}function mA({t:e,tickets:t}){const n=a=>{var c;return((c=t.find(d=>d.id===a))==null?void 0:c.key)??a},i=t.filter(a=>a.blockedBy.includes(e.id)).map(a=>a.key);return s.jsxs("header",{className:"ticket-head",children:[s.jsx("h3",{className:"t-title",children:e.title}),s.jsx(B,{parts:[{text:e.key,code:!0},En[e.type],pi(e)==="hitl"?"needs a person":"agent work",e.reviewOf&&`reviews ${n(e.reviewOf)}`,i.length>0&&`blocks ${i.join(", ")}`]})]})}function pA(e,t){return[...gA(e,t),...vA(e,t),...xA(e,t),...jA(e,t),...bA(e,t)].filter(n=>!!n)}function gA(e,t){const{state:n,mine:i}=e,a=n==="frontier";return[a&&{id:"claim",label:"Claim",tip:"Take it yourself, so no agent picks it up",onSelect:t.claim},(a||n==="claimed"&&i)&&{id:"resolve",label:"Resolve myself…",tip:"Answer it yourself and close the ticket, with a decision record",onSelect:()=>t.form("resolve")},i&&n==="claimed"&&{id:"release",label:"Give back to the queue",onSelect:t.release},!!e.lease&&{id:"release-lease",label:"Release to queue",tip:"Take the claim back from the agent; its notes go to the next one",onSelect:t.releaseLease}]}function vA(e,t){var u,f,m;if(!(e.state==="verifying"||e.state==="held")||(u=e.verification)!=null&&u.running)return[];const i=!!((f=e.verification)!=null&&f.attempts.length)||e.items.some(g=>g.kind==="approval"),a=e.state==="held",c=(m=e.verification)==null?void 0:m.attempts[0],d=kA(c);return a&&!d&&uu(c)?yA(t):[e.state==="verifying"&&i&&{id:"approve",label:"Approve",tip:"Approve the work and close the ticket",onSelect:t.approve},i&&{id:"rerun",label:"Re-run checks",tip:"Run the repo's checks again on the current code",onSelect:t.rerun},{id:"rework",label:"Send to rework…",tip:"Back to an agent with what to fix",onSelect:()=>t.form("rework")},a&&{id:"unblock",label:"Unblock…",tip:"Back to the queue without running checks",onSelect:()=>t.form("unblock")},a&&{id:"accept",label:d?"Accept the pass…":"Accept anyway…",tip:d?"Count the checks although the work changed what they run; the proof says you accepted it":"Close it as done despite the checks",onSelect:()=>t.form("accept")}]}const kA=e=>{var t;return(e==null?void 0:e.result)==="pass"&&((t=e.guard)==null?void 0:t.mode)==="enforce"};function yA(e){return[{id:"rework",label:"Send to rework…",tip:"The agent finds why the test is flaky and fixes it: no sleeps, retries or skipped tests",onSelect:()=>e.form("rework")},{id:"accept",label:"Accept the pass…",tip:"Count the pass on retry and close it as done; the proof says it passed on retry",onSelect:()=>e.form("accept")}]}const wA=new Set(["rework","held","claimed"]);function xA(e,t){var c,d,u;const n=((c=e.verification)==null?void 0:c.waivable)??[],i=[...new Set((((d=e.verification)==null?void 0:d.waivers)??[]).flatMap(f=>f.checks.map(m=>m.name)))],a=n.length===1?`Accept without ${n[0].name}…`:"Accept without failing checks…";return[n.length>0&&wA.has(e.state)&&!((u=e.verification)!=null&&u.running)&&{id:"waive",label:a,tip:"When a check can't pass in this repo: the ticket completes without it, with your reason",onSelect:()=>t.form("waive")},i.length>0&&{id:"undo-waiver",label:`Run ${i.join(", ")} again`,tip:"Undo accepting it without them",onSelect:t.undoWaiver}]}function jA(e,t){const n=e.criteria,a=e.t.state==="open"&&n.criteria.length>0&&!(n.changed&&!n.confirmed),c=!!n.proposal&&!n.proposalChanged;return[a&&!n.confirmed&&{id:"confirm-criteria",label:"Confirm criteria",tip:"Agree that these criteria define done for this ticket",onSelect:()=>t.criteria(!0)},a&&n.confirmed&&{id:"unconfirm-criteria",label:"Unconfirm criteria",onSelect:()=>t.criteria(!1)},c&&{id:"take-criteria",label:"Take the new criteria",tip:"Replace yours with the proposed ones",onSelect:t.take},c&&{id:"keep-criteria",label:"Keep my criteria",tip:"Drop the proposal",onSelect:t.keep}]}function bA(e,t){var a;const{state:n,t:i}=e;return[i.state==="open"&&{id:"edit-how",label:"Change guides or verification",tip:"The guides and the verification level for this ticket alone",onSelect:t.editHow},!!e.change&&{id:"review-change",label:"Review the change",tip:"Accept or revert it in Approvals",onSelect:t.reviewChange},((a=e.brief)==null?void 0:a.status)==="submitted"&&{id:"review-brief",label:"Review the brief",onSelect:t.reviewBrief},!!e.proof&&{id:"copy-proof",label:"Copy proof for PR",tip:"The signed report, as Markdown",onSelect:t.copyProof},!!e.workspace&&{id:"remove-workspace",label:"Remove workspace…",tip:"Delete its worktree folder; the branch stays",onSelect:()=>t.form("workspace")},i.closeReason==="not_planned"&&{id:"dead-end",label:"Save as dead end",tip:"Add it to the field guide as a suggestion, so agents learn from it",onSelect:t.deadEnd},(n==="frontier"||n==="blocked"||n==="parked")&&{id:"rule",label:"Rule out…",tip:"Move it out of scope. It's set aside with your reason, not deleted",danger:!0,onSelect:()=>t.form("rule")}]}const SA={answer:"answer",approve:"approve",accept:"accept",waive:"waive",unblock:"unblock",rework:"rework",release:"release-lease",resolve:"resolve","review-brief":"review-brief","review-change":"review-change","confirm-criteria":"confirm-criteria","take-criteria":"take-criteria"};function cy(e){const{v:t,api:n}=e,[i,a]=y.useState(),[c,d]=y.useState(),u=Es(),f=M=>{d(M),setTimeout(()=>d(void 0),2500)},m=M=>a(M),g=M=>(a(void 0),bs.act({...M,mapId:t.snap.map.id,ticketId:t.t.id,by:Ct}).then(t.reloadVerification,H=>a(H.message))),k=M=>{var Y,re;const H=((re=(Y=t.verification)==null?void 0:Y.attempts[0])==null?void 0:re.id)??"",_=M.checks.map(q=>({name:q.name,hash:q.hash}));return a(void 0),bs.waive({mapId:t.snap.map.id,ticketId:t.t.id,attemptId:H,checks:_,reason:M.reason}).then(t.reloadVerification,q=>a(q.message))},w={form:M=>e.setForm(M),claim:()=>void n.actions.claim(t.t.id),release:()=>void n.actions.release(t.t.id),releaseLease:()=>void n.actions.releaseLease(t.t.id),approve:()=>void g({action:"approve"}),rerun:()=>void g({action:"rerun"}),undoWaiver:()=>void bs.undoWaiver({mapId:t.snap.map.id,ticketId:t.t.id}).then(t.reloadVerification,M=>a(M.message)),criteria:M=>void t.criteria.setConfirmed(M).then(m),take:()=>void t.criteria.take().then(m),keep:()=>void t.criteria.keep().then(m),editHow:e.onEditHow,reviewChange:()=>{var M;return(M=e.onReviewChange)==null?void 0:M.call(e)},reviewBrief:()=>{var M;return(M=e.onReviewBrief)==null?void 0:M.call(e,t.snap.map.id)},copyProof:()=>{var M;return void navigator.clipboard.writeText(((M=t.proof)==null?void 0:M.markdown)??"").then(()=>f("Copied for PR"))},deadEnd:()=>{var M;return void u.propose({title:`Ruled out: ${t.t.title}`,body:((M=t.t.comments.at(-1))==null?void 0:M.body)??t.t.body,kind:"dead-end",sources:[`trail:${t.snap.map.key}`,`ticket:${t.t.key}`]}).then(H=>H&&f(`Saved as ${H.id} in the field guide`))}},b=pA(t,w),S=NA(t,e.onOpenChat),x=t.standing.primary,C=b.find(M=>M.id==="take-criteria")??b.find(M=>M.id==="confirm-criteria"),N=S??b.find(M=>x&&M.id===SA[x])??C,P=$A({urgent:t.standing.edge==="urgent",named:!!x&&N!==C}),D=b.filter(M=>M!==N);return{primary:N,variant:P,menu:D,error:i,note:c,act:g,waive:k,undoWaiver:w.undoWaiver}}function NA(e,t){const n=e.question;if(!(e.standing.primary!=="answer"||!n))return{id:"answer",label:"Answer",tip:`${n.agent} is waiting for your answer`,onSelect:()=>t(n.sessionId)}}function $A(e){return e.urgent?"urgent":e.named?"primary":"default"}function Qp({criteria:e}){return s.jsx("ul",{className:"criteria-list item-list",children:e.map(t=>s.jsxs("li",{children:[s.jsx("span",{className:"item-text",children:t.text}),s.jsx(B,{parts:[{text:t.id,code:!0},t.kind.replace("-"," "),t.source&&`from ${t.source}`]})]},t.id))})}function CA({c:e}){const{criteria:t,proposal:n,uncovered:i}=e;if(!t.length&&!i.length&&!n)return null;const a=t.length?`Acceptance criteria · ${t.length}`:"No acceptance criteria yet";return s.jsxs("div",{className:"criteria-section",children:[s.jsx(B,{parts:[{text:a,strong:!0},e.confirmed&&"confirmed by you"]}),t.length>0&&s.jsx(Qp,{criteria:t}),n&&s.jsxs("div",{className:"crit-proposal",children:[s.jsx(B,{parts:[`${n.by} proposes new criteria`,"yours stay in force until you take these"]}),s.jsx(Qp,{criteria:n.criteria})]}),i.length>0&&s.jsx(B,{parts:[`No criterion covers ${i.map(c=>`${c.title} (${c.id})`).join(", ")} yet`]})]})}const ly=`${ie()}/criteria`;async function TA(e){if(!e)return[];const t=await fetch(`${ly}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).tickets:[]}function EA(e){const[t,n]=y.useState([]),{reload:i}=Le({view:e,load:()=>TA(e),show:n,failed:()=>n([]),changed:c=>c.startsWith("criteria/")});return{tickets:t,confirm:c=>fetch(`${ly}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...c})}).catch(()=>{}).then(async d=>{const u=await Wa(d);return i(),u})}}const dy=`${ie()}/criteria-proposals`;async function AA(e){if(!e)return[];const t=await fetch(`${dy}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).proposals:[]}function RA(e){const[t,n]=y.useState([]),{reload:i}=Le({view:e,load:()=>AA(e),show:n,failed:()=>n([]),events:{"criteria-proposals":c=>(c==null?void 0:c.mapId)===e}});return{proposals:t,decide:(c,d)=>fetch(`${dy}/${c}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...d})}).catch(()=>{}).then(async u=>{const f=await Wa(u);return i(),f})}}function IA(e,t){const{tickets:n,confirm:i}=EA(e.map.id),a=RA(e.map.id),c=a.proposals.find(S=>S.ticketId===t.id),d=Es(),u=n.find(S=>S.ticketId===t.id),f=(u==null?void 0:u.criteria)??[],m=pa(t.id,u==null?void 0:u.hash),g=pa(c&&`${c.ticketId}@${c.at}`,c==null?void 0:c.hash),w=Mv(d.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:Ov(`${t.body}
|
|
151
|
+
${d.briefText}`)}).filter(S=>S.kind==="business-rule").filter(S=>Kb(f,[S.id]).length),b=S=>a.decide(S,{title:e.map.title,ticketId:t.id,hash:g.hash});return{criteria:f,confirmed:!!(u!=null&&u.confirmed),proposal:c,uncovered:w,changed:m.changed?m:void 0,proposalChanged:c&&g.changed?g:void 0,setConfirmed:S=>i({title:e.map.title,ticketId:t.id,ticketKey:t.key,confirmed:S,hash:m.hash}),take:()=>b("accept"),keep:()=>b("dismiss")}}function MA({text:e}){return e.trim()?s.jsx("div",{className:"brief-prose",children:e.split(`
|
|
152
|
+
`).map((t,n)=>s.jsx("p",{children:t.split(/(`[^`]+`|\/?\b[\w.-]+\/[\w./-]+\b)/g).map((i,a)=>a%2===1?s.jsx("code",{children:i.replace(/`/g,"")},a):i)},n))}):s.jsx(Te,{children:"Not covered"})}const Yp=["summary","productContext","existing","conventions","dataModel","api","risks"];function OA(e){const{brief:t}=e,[n,i]=y.useState(!1),[a,c]=y.useState("");y.useEffect(()=>{const m=g=>g.key==="Escape"&&e.onClose();return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[e]);const d=t.sections,u=Yp.filter(m=>d[m].trim()),f=Yp.filter(m=>!d[m].trim());return s.jsx("div",{className:"scrim",onClick:e.onClose,children:s.jsxs(Fe,{as:"div",className:"dialog brief-dialog",onClick:m=>m.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("h2",{className:"t-heading caps",children:"Discovery brief"}),s.jsx("span",{className:"t-meta",children:LA(t)})]}),s.jsxs("div",{className:"brief-body",children:[u.map(m=>s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:lr[m]}),s.jsx(MA,{text:d[m]}),(m==="conventions"||m==="productContext")&&d[m].trim()&&s.jsx(sy,{draft:()=>({title:`${lr[m]}: ${d[m].split(`
|
|
153
|
+
`)[0].slice(0,80)}`,body:d[m],kind:m==="conventions"?"convention":"business-rule",sources:[`brief:${t.mapId}`]})})]},m)),s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:lr.assumptions}),d.assumptions.length?s.jsx("ul",{className:"item-list",children:d.assumptions.map(m=>s.jsxs("li",{children:[s.jsx("span",{className:"item-text",children:m.text}),s.jsx(B,{parts:[{text:m.id,code:!0}]})]},m.id))}):s.jsx(Te,{children:"None listed"})]}),s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:lr.openQuestions}),d.openQuestions.length?s.jsx("ul",{className:"brief-list",children:d.openQuestions.map(m=>s.jsx("li",{children:m},m))}):s.jsx(Te,{children:"None"})]}),f.length>0&&s.jsxs("p",{className:"t-meta brief-empty",children:["Nothing noted on ",f.map(m=>lr[m].toLowerCase()).join(", "),"."]}),t.note&&s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:"Your last request"}),s.jsx("p",{children:t.note})]})]}),n&&s.jsx(Je,{label:"What should change?",children:s.jsx("textarea",{rows:3,value:a,onChange:m=>c(m.target.value),autoFocus:!0})}),e.changed&&e.onReviewAgain&&s.jsx(Nu,{what:"The brief",onReviewAgain:e.onReviewAgain}),e.error&&s.jsx("p",{className:"urgent-text",children:e.error}),s.jsxs("div",{className:"actions",children:[t.status==="submitted"&&!n&&s.jsxs(s.Fragment,{children:[s.jsx(I,{onClick:()=>i(!0),children:"Request changes"}),s.jsx(I,{variant:"primary",disabled:e.changed,onClick:e.onAccept,children:"Accept brief"})]}),n&&s.jsxs(s.Fragment,{children:[s.jsx(I,{variant:"ghost",onClick:()=>i(!1),children:"Back"}),s.jsx(I,{variant:"primary",disabled:!a.trim(),onClick:()=>e.onRequestChanges(a.trim()),children:"Send to the agent"})]}),s.jsx(I,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}function LA(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(`${Xe(Date.now()-e.submittedAt)} ago`),t.join(" · ")}function PA({brief:e,onReview:t}){return e.status!=="submitted"?null:s.jsx("div",{className:"brief-card",children:s.jsx(he,{edge:"attention",title:"Discovery brief ready for your review",context:s.jsx(B,{parts:["Discovery brief",e.author&&`by ${e.author}`]}),detail:e.sections.summary.split(`
|
|
154
|
+
`)[0],detailText:e.sections.summary,onOpen:t})})}function DA({onReview:e,onClose:t}){return y.useEffect(()=>{const n=i=>i.key==="Escape"&&t();return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t]),s.jsx("div",{className:"scrim",onClick:t,children:s.jsxs(Fe,{as:"div",className:"dialog brief-ready",role:"dialog","aria-label":"Research is done",onClick:n=>n.stopPropagation(),children:[s.jsx("header",{children:s.jsx("h2",{className:"t-heading caps",children:"Research is done"})}),s.jsx("p",{className:"t-body",children:"The discovery brief needs your review. Implementation starts once you accept it."}),s.jsxs("footer",{children:[s.jsx(I,{variant:"ghost",onClick:t,children:"Later"}),s.jsx(I,{variant:"primary",autoFocus:!0,onClick:e,children:"Review brief"})]})]})})}const _A={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 BA({brief:e,onReview:t}){if(e.status==="accepted")return null;const[n,i]=_A[e.status],a=e.status==="submitted"?"edge-attention":"edge-neutral";return s.jsxs("div",{className:`discovery-banner map-banner ${a} st-${e.status}`,role:"status",children:[s.jsxs("span",{className:"mb-text",children:[s.jsx("span",{className:"mb-lead",children:n}),s.jsx("span",{className:"t-meta",children:i})]}),s.jsx(ki,{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."}),s.jsx(I,{size:"sm",variant:e.status==="submitted"?"primary":"ghost",onClick:t,children:e.status==="submitted"?"Review brief":"Open brief"})]})}const uy=`${ie()}/briefs`;async function FA(e){if(!e)return{brief:null};const t=await fetch(`${uy}?mapId=${encodeURIComponent(e)}`);return t.ok?await t.json():{brief:null}}function qa(e){const t=e==null?void 0:e.map.id,[n,i]=y.useState(null),[a,c]=y.useState(),[d,u]=y.useState(),[f,m]=y.useState(!1),{reload:g,pushed:k}=Le({view:t,version:e==null?void 0:e.tickets.reduce((S,x)=>Math.max(S,x.updatedAt),e.map.updatedAt),load:()=>FA(t),show:S=>{i(S.brief),u(S.hash),m(!!S.gated)},failed:()=>(i(null),m(!1)),changed:S=>S.startsWith("briefs/")}),w=(S,x,C)=>fetch(`${uy}/${S}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,note:x,hash:C})}).then(async N=>{const P=await N.json().catch(()=>({}));if(!N.ok||!P.brief)throw new Error(P.error??`HTTP ${N.status}`);c(void 0),k(),i(P.brief),P.brief.status==="accepted"&&m(!1)}),b=(S,x,C)=>w(S,x,C).then(()=>!0,N=>(c(N.message),g(),!1));return{brief:n,error:a,hash:d,gated:f,accept:S=>b("accept",void 0,S),requestChanges:S=>b("request-changes",S)}}const Jp=new Set,Xp=e=>`teamtrail.brief-ready:${ie()}:${e.mapId}:${e.submittedAt??""}`,Zp={has(e){const t=Xp(e);if(Jp.has(t))return!0;try{return localStorage.getItem(t)==="1"}catch{return!1}},add(e){const t=Xp(e);Jp.add(t);try{localStorage.setItem(t,"1")}catch{}}};function zA(e){const[,t]=y.useState(0);return{show:(e==null?void 0:e.status)==="submitted"&&!Zp.has(e),close:()=>{e&&Zp.add(e),t(a=>a+1)}}}function UA(e,t){return e&&t.state==="open"&&!Rv.includes(t.type)}function WA(e){const{gated:t}=qa(e);return n=>UA(t,n)}const HA=`${J.apiPrefix}/models`;async function KA(){const e=await fetch(HA);return e.ok?await e.json():null}function Lu(){const[e,t]=y.useState();return Le({load:KA,show:t,failed:()=>t(null),changed:n=>n.endsWith("models.json")||n.endsWith("map.md")||n.includes("/tickets/"),events:{attention:()=>!0}}),e}async function GA(){const e=await fetch(`${ie()}/signed-state`);return e.ok?await e.json():null}function hy(){const[e,t]=y.useState();return Le({load:GA,show:t,failed:()=>t(null),changed:n=>n.endsWith("map.md")||n.includes("/tickets/")||n.includes("/decisions/")}),e}const VA={ticket:"held until you accept or revert it",decision:"what you see is what was signed here, until you accept or revert it"};function qA(e){return e[0]==="added"?"added outside Teamtrail":e.map(t=>t==="words"?"its words":t).join(", ")}function QA({mapId:e,kind:t,id:n}){const i=hy(),a=d=>d.mapId===e&&d.kind===t&&d.id===n,c=i==null?void 0:i.changes.find(a);return c?s.jsx(he,{className:"d-section",edge:"attention",title:"Changed outside Teamtrail",context:s.jsx(B,{parts:[`${qA(c.fields)} · ${VA[t]}`]}),detail:"By a teammate or an agent editing the file. Settings → Approvals shows what changed."}):i!=null&&i.textEdits.some(a)?s.jsx(B,{className:"d-section",parts:["Text edited outside Teamtrail"]}):null}const YA=e=>e[0]==="added"?"added outside Teamtrail":e.map(t=>t==="words"?"its words":t).join(", ");function JA(e){var u,f,m;const{t,snap:n}=e,i=e.items[0],a=new Map(n.tickets.map(g=>[g.id,g])),c=(u=e.verification)==null?void 0:u.attempts[0],d=e.lease&&{agent:e.lease.agent,renewedAt:e.lease.renewedAt,expiresAt:e.lease.expiresAt,health:Ts(e.lease,e.now)};return{state:e.state,now:e.now,question:e.question&&{agent:e.question.agent,at:e.question.at},item:i&&{kind:i.kind,edge:Tr(i,e.interrupting.includes(i.id))},outsideChange:e.change&&`${YA(e.change.fields)} · held until you accept or revert it`,lease:d,assignee:t.assignee,mine:e.mine,hitl:pi(t)==="hitl",briefHeld:XA(e),modelWait:e.modelWait&&{tier:e.modelWait.tier,best:e.modelWait.best},running:(f=e.verification)==null?void 0:f.running,latest:c&&ZA(c),sentBack:tR(e.verification),reviewWaits:nR(e.verification),verified:e.proof&&e.proof.proof.status==="verified",pr:((m=e.pr)==null?void 0:m.pr)&&{number:e.pr.pr.number,state:e.pr.pr.state},openBlockers:t.blockedBy.filter(g=>{var k;return((k=a.get(g))==null?void 0:k.state)==="open"}).map(g=>{var k;return((k=a.get(g))==null?void 0:k.key)??g}),closedAt:t.closedAt}}function XA(e){if(!(!e.brief||e.state!=="frontier"||Rv.includes(e.t.type)))return e.brief.status==="submitted"?"submitted":"writing"}function ZA(e){var a;const t=e.checks.filter(c=>!Ik(c)).map(c=>c.name),n=e.flaky&&uu(e)?K0(e.flaky.checks):void 0,i=e.result==="pass"&&((a=e.guard)==null?void 0:a.mode)==="enforce"?e.guard:void 0;return{result:e.result,agent:e.agent,failed:t,...i?{guarded:V0(i.findings)}:{},...n?{retried:n}:{}}}const eR={FAIL:"the review sent it back",NEEDS_HUMAN:"the reviewer asked for you"};function tR(e){const t=e==null?void 0:e.attempts[0],n=t&&e.verdicts.find(i=>i.attemptId===t.id);return n&&eR[n.verdict]}function nR(e){const t=e==null?void 0:e.attempts[0];return!t||t.result!=="pass"||!e.level.level.includes("review")?!1:!e.verdicts.some(n=>n.attemptId===t.id)}const sR=new Set(["question","approval","blocked","hitl-ready","stalled","model"]);function iR(e){var a;const t=((a=e.pr)==null?void 0:a.flags.map(c=>({text:c.text,risk:!0})))??[],n=e.items.filter(c=>!sR.has(c.kind)).map(c=>({text:c.title,risk:!0})),i=e.textEdited&&!e.change?[{text:"Text edited outside Teamtrail",risk:!1}]:[];return[...t,...n,...i]}function rR(e){const t=oR(e),n=t.edge==="neutral"||t.edge==="done";return e.atRisk&&n?{...t,edge:"attention"}:t}function oR(e){if(e.question)return cR(e,e.question);if(e.outsideChange)return{edge:"attention",title:"Held: changed outside Teamtrail",parts:[e.outsideChange],primary:"review-change"};if(e.running&&e.state!=="decided"&&e.state!=="out-of-scope")return{edge:"neutral",title:`Checking ${e.running.agent}'s work`,parts:[`since ${rs(e.running.startedAt)}`]};switch(e.state){case"decided":return lR(e);case"out-of-scope":return{edge:"neutral",title:"Ruled out",parts:fy(e)};case"verifying":return uR(e);case"held":return aR(e);case"claimed":return hR(e);case"rework":return{edge:"attention",title:`Rework: ${my(e)}`,parts:["waits for an agent"]};case"frontier":return fR(e);case"blocked":return{edge:"neutral",title:`Waits on ${e.openBlockers.join(", ")}`,parts:[]};case"parked":return{edge:"neutral",title:"Parked",parts:["a plan-only trail builds nothing"]};default:return e.state}}function aR(e){var i,a,c,d;const t=((i=e.item)==null?void 0:i.edge)??"attention",n=(a=e.latest)==null?void 0:a.retried;return(c=e.latest)!=null&&c.guarded?{edge:t,title:"Held: the work changed what its checks run",parts:[e.latest.guarded,...n?[`only on retry: ${n}`]:[],"waits on you"],primary:"accept"}:n?{edge:t,title:"Held: passed only on retry",parts:[n],primary:"rework"}:{edge:t,title:`Blocked: ${my(e)}`,parts:["waits on you"],primary:(d=e.latest)!=null&&d.failed.length?"waive":"unblock"}}function cR(e,t){var i;return{edge:((i=e.item)==null?void 0:i.kind)==="question"?e.item.edge:"urgent",title:`Waiting on you: answer ${t.agent}'s question`,parts:[ga(e.now,t.at)],primary:"answer"}}function lR(e){const t=dR(e.verified),n=e.pr&&`PR #${e.pr.number} ${e.pr.state}`;return{edge:"done",title:"Done",parts:[t,n,...fy(e)].filter(i=>!!i)}}function dR(e){if(e!==void 0)return e?"verified":"not verified"}function fy(e){return e.closedAt?[ga(e.now,e.closedAt)]:[]}function uR(e){var t;return((t=e.item)==null?void 0:t.kind)==="approval"?{edge:e.item.edge,title:"Waiting on you: approve it",parts:eg(e),primary:"approve"}:e.reviewWaits?{edge:"neutral",title:"Waiting for a review agent",parts:eg(e)}:{edge:"neutral",title:"Verifying",parts:[]}}function eg(e){var t;return((t=e.latest)==null?void 0:t.result)==="pass"?["checks passed"]:[]}function my(e){var n,i,a,c;const t=(n=e.latest)!=null&&n.failed.length?` (${e.latest.failed.join(", ")})`:"";return((i=e.latest)==null?void 0:i.result)==="fail"?`checks failed${t}`:((a=e.latest)==null?void 0:a.result)==="error"?`checks could not run${t}`:((c=e.latest)==null?void 0:c.result)==="interrupted"?"checks were interrupted":e.sentBack??"sent back"}function hR(e){const t=e.lease;if(t&&t.health!=="live"){const i=t.health==="expired"?"going back to the queue":`back in the queue in ${Gt(t.expiresAt-e.now)}`,a=[`active ${ga(e.now,t.renewedAt)}`,i];return{edge:"attention",title:`${t.agent} went quiet`,parts:a,primary:"release"}}return e.mine?{edge:"neutral",title:"You have it",parts:[],primary:"resolve"}:{edge:"neutral",title:`${(t==null?void 0:t.agent)??e.assignee??"An agent"} is working on it`,parts:t?[`active ${ga(e.now,t.renewedAt)}`]:[]}}function fR(e){var t;if(e.briefHeld==="submitted")return{edge:"attention",title:"Held: waits on the brief",parts:["the brief waits on you"],primary:"review-brief"};if(e.briefHeld)return{edge:"attention",title:"Held: waits on the brief",parts:["research is still writing it"]};if(e.hitl){const i=["decide it yourself, or let an agent ask you",e.modelWait&&`agents need a ${e.modelWait.tier} model`].filter(a=>!!a);return{edge:((t=e.item)==null?void 0:t.edge)??"neutral",title:"Ready: needs a person",parts:i,primary:"resolve"}}return e.modelWait?{edge:"attention",title:`Waits for a ${e.modelWait.tier} model`,parts:[`connected agents run ${e.modelWait.best} at most`]}:{edge:"neutral",title:"Ready",parts:["the next agent takes it"]}}const ga=(e,t)=>`${Xe(e-t)} ago`;function py(e){var D,M,H;const{snap:t,t:n,api:i}=e,a=t.map.id,c=gt(1e3),d=Cs(t.tickets,t.map.mode).get(n.id),u=FE(a,n.id,n.updatedAt),f=C2(a,n.id),m=IA(t,n),g=hy(),k=Lu(),w=ns.ticket($r(),a,n.id),b=qa(t),S=ry(),x=_=>_.mapId===a&&_.kind==="ticket"&&_.id===n.id,C={t:n,snap:t,state:d,now:c,mine:n.assignee===Ct,lease:n.state==="open"?ku(i.leases,a).get(n.id):void 0,session:e.sessions.find(_=>_.ticketId===n.id&&mn(_)),question:i.activity.pending.find(_=>_.mapId===a&&_.ticketId===n.id),items:(((D=e.attention)==null?void 0:D.items)??[]).filter(_=>_.mapId===a&&_.ticketId===n.id),interrupting:((M=e.attention)==null?void 0:M.interrupting)??[],verification:u.data,proof:f??void 0,pr:w,change:g==null?void 0:g.changes.find(x),textEdited:!!(g!=null&&g.textEdits.some(x)),brief:b.gated?b.brief:null,modelWait:k==null?void 0:k.waiting.find(_=>_.mapId===a&&_.ticketId===n.id),workspace:(H=S.view)==null?void 0:H.workspaces.find(_=>_.mapId===a&&_.ticketId===n.id&&!_.active)},N=iR(C),P=rR({...JA(C),atRisk:N.some(_=>_.risk)});return{...C,reloadVerification:u.reload,criteria:m,removeWorkspace:_=>S.remove(a,n.id,_),standing:P,notices:N}}function mR(e){return e.replace(/\s*Part of trail \S+\.\s*$/,"").trim()}function gy({v:e}){const t=mR(e.t.body),n=e.criteria;return!t&&!n.criteria.length&&!n.proposal&&!n.uncovered.length?null:s.jsxs(sn,{label:"What",className:"ticket-body",children:[t&&s.jsx(rk,{text:t}),s.jsx(CA,{c:n})]})}function pR(e){const{snap:t,t:n,api:i}=e,a=py({snap:t,t:n,api:i,sessions:e.sessions,attention:e.attention}),[c,d]=y.useState(!1),u=cy({v:a,api:i,setForm:e.setForm,onEditHow:()=>d(!0),onOpenChat:e.onOpenChat,onReviewChange:e.onReviewChange,onReviewBrief:e.onReviewBrief}),f=i.decisions.filter(m=>m.mapId===t.map.id&&m.ticketId===n.id);return s.jsxs("div",{className:"detail ticket-panel",children:[s.jsx(mA,{t:n,tickets:t.tickets}),s.jsx(aA,{v:a}),s.jsx(Bk,{v:a,bar:u,onOpenChat:e.onOpenChat}),s.jsx(ay,{form:e.form,setForm:e.setForm,v:a,actions:i.actions,act:u.act,waive:u.waive}),s.jsx(gy,{v:a}),s.jsx(nA,{v:a,editing:c,setEditing:d,act:u.act}),s.jsx(oA,{v:a,onUndoWaiver:u.undoWaiver}),s.jsx(a2,{mapId:t.map.id,ticketId:n.id}),s.jsx($2,{ticket:n,view:a.proof}),s.jsx(P2,{t:n,decisions:f,onOpenDecision:e.onOpenDecision})]})}function gR(e){const t=e.snap.tickets.find(n=>n.id===e.id);return t?s.jsx(pR,{...e,t},t.id):s.jsx(Te,{children:"Ticket not found."})}const tg=[{phase:"discovery",label:"Discovery"},{phase:"brief",label:"Brief"},{phase:"building",label:"Building"},{phase:"review",label:"Review"},{phase:"done",label:"Done"}],vR=new Set(["decided","out-of-scope"]),kR=new Set(["verifying","held"]);function yR(e){if(e.done)return"done";if(e.gated)return e.briefStatus==="submitted"?"brief":"discovery";const t=e.states.filter(n=>!vR.has(n));return t.length&&t.every(n=>kR.has(n))?"review":"building"}function wR(e,t){switch(e){case"discovery":return"Research maps the existing system for the brief; implementation waits for it";case"brief":return"The brief waits on you: implementation starts once you accept it";case"building":return`${t.done} of ${t.total} tickets done`;case"review":return"All the work is in and waits for verification";case"done":return t.reason??"Every ticket in scope is done";default:return e}}function xR(e){const t=tg.findIndex(a=>a.phase===e.phase),n=e.snap.tickets.filter(a=>e.states.get(a.id)!=="out-of-scope"),i=n.filter(a=>e.states.get(a.id)==="decided").length;return s.jsxs("header",{className:"glance-head",children:[s.jsx("ol",{className:"phase-steps","aria-label":"Trail phase",children:tg.map((a,c)=>s.jsx("li",{className:pe(c<t&&"past",c===t&&"now"),"aria-current":c===t?"step":void 0,children:a.label},a.phase))}),s.jsx("p",{className:"t-body",children:wR(e.phase,{done:i,total:n.length,reason:e.reason})})]})}function vy(e){var w,b,S;const{snap:t}=e,{brief:n,gated:i}=qa(t),a=Cs(t.tickets,t.map.mode),c=!!e.done&&e.done.kind!=="not-done",d=yR({done:c,gated:i,briefStatus:n==null?void 0:n.status,states:[...a.values()]}),u=(((w=e.attention)==null?void 0:w.items)??[]).filter(x=>x.mapId===t.map.id),f=u[0],m=e.sessions.filter(x=>mn(x)&&x.mapId===t.map.id&&x.ticketId),g=t.tickets.filter(x=>a.get(x.id)==="frontier"),k=new Map(t.tickets.map(x=>[x.id,x]));return s.jsxs("div",{className:"detail trail-glance",children:[s.jsx(xR,{phase:d,snap:t,states:a,reason:c?(b=e.done)==null?void 0:b.reason:void 0}),c?s.jsx(yk,{mapId:t.map.id,now:e.now}):s.jsx(gk,{mapId:t.map.id,now:e.now}),f&&s.jsx(sn,{label:`Waits on you · ${u.length}`,children:s.jsx(he,{edge:Tr(f,((S=e.attention)==null?void 0:S.interrupting.includes(f.id))??!1),title:f.title.split(`
|
|
155
|
+
`)[0],context:s.jsx(B,{parts:jk({item:f,snap:t,otherTrail:!1})}),trailing:Xe(e.now-f.since),onOpen:()=>e.onItem(f)})}),m.length>0&&s.jsx(sn,{label:`Agents now · ${m.length}`,children:m.map(x=>{var C;return s.jsx(he,{edge:x.waitingOn?"urgent":"neutral",title:((C=k.get(x.ticketId))==null?void 0:C.title)??x.stepLabel,context:s.jsx(B,{parts:[{text:x.agent,strong:!0},`${x.stepLabel}, step ${x.step} of ${x.total}`]}),onOpen:()=>e.onTicket(x.ticketId)},x.id)})}),g.length>0&&s.jsx(sn,{label:`Ready next · ${g.length}`,children:g.slice(0,3).map(x=>s.jsx(he,{title:x.title,context:s.jsx(B,{parts:[{text:x.key,code:!0},En[x.type]]}),onOpen:()=>e.onTicket(x.id)},x.id))}),s.jsx("p",{className:"t-meta glance-hint",children:"A ticket opens in its bubble on the map."})]})}function ky({snap:e,item:t,api:n}){const i=cv(e.map.mode),[a,c]=y.useState("research"),[d,u]=y.useState(t),[f,m]=y.useState(!1),[g,k]=y.useState([]),[w,b]=y.useState("Not needed to reach the destination.");y.useEffect(()=>u(t),[t]);const S=e.tickets.filter(x=>x.state==="open");return s.jsxs("div",{className:"detail",children:[s.jsx("div",{className:"d-head",children:s.jsx(wi,{tone:"state",className:"st-unspecified",children:"Not yet specified"})}),s.jsx("h3",{className:"t-heading",children:t}),s.jsxs(Vt,{as:"form",tone:"inset",className:"inline-form",onSubmit:x=>{x.preventDefault(),n.actions.graduate({unspecified:t,type:a,title:d,blockedBy:g,hitl:f})},children:[s.jsx(Je,{label:"Title",children:s.jsx("input",{value:d,onChange:x=>u(x.target.value)})}),s.jsxs("div",{className:"chips",children:[i.map(x=>s.jsx("button",{type:"button",className:`chip ${a===x?"on":""}`,onClick:()=>c(x),children:x},x)),yj.includes(a)&&s.jsx("button",{type:"button",className:`chip ${f?"on":""}`,onClick:()=>m(x=>!x),children:"needs human"})]}),s.jsx("span",{className:"field",children:"Blocked by"}),s.jsx("div",{className:"chips",children:S.map(x=>s.jsx("button",{type:"button",className:`chip ${g.includes(x.id)?"on":""}`,onClick:()=>k(C=>C.includes(x.id)?C.filter(N=>N!==x.id):[...C,x.id]),children:x.key},x.id))}),s.jsx("div",{className:"form-actions",children:s.jsx(I,{type:"submit",variant:"primary",children:"Promote to ticket"})})]}),s.jsxs(Vt,{as:"form",tone:"inset",className:"inline-form",onSubmit:x=>{x.preventDefault(),n.actions.ruleOut({unspecified:t},w)},children:[s.jsx(Je,{label:"Reason",children:s.jsx("input",{value:w,onChange:x=>b(x.target.value)})}),s.jsx("div",{className:"form-actions",children:s.jsx(I,{type:"submit",variant:"danger",children:"Rule out"})})]})]})}function jR(e){const{api:t}=e,{snap:n,selection:i,actions:a}=t,[c,d]=y.useState(null),u=gt(5e3),f=bR(i);y.useEffect(()=>d(null),[f]);const m=e.onOpenChat??a.openChat;let g;return n?(i==null?void 0:i.kind)!=="ticket"&&(i==null?void 0:i.kind)!=="unspecified"?g=s.jsx(vy,{snap:n,sessions:e.sessions,attention:e.attention,done:e.done,now:u,onTicket:k=>t.setSelection({kind:"ticket",id:k}),onItem:k=>{var w;return(w=e.onItem)==null?void 0:w.call(e,k)}}):i.kind==="unspecified"?g=s.jsx(ky,{snap:n,item:i.item,api:t}):g=s.jsx(gR,{snap:n,id:i.id,api:t,sessions:e.sessions,attention:e.attention,form:c,setForm:d,onOpenChat:m,onOpenDecision:e.onOpenDecision,onReviewChange:e.onReviewChange,onReviewBrief:e.onReviewBrief}):g=s.jsx(An,{title:"No trail yet",hint:"Once there's a trail, pick a ticket on the map to see it here."}),s.jsx(_$,{area:"inspector",icon:"note",title:"Trail step",info:"The ticket you selected on the map: where it stands, what you can do, and what it is. With none selected, the trail at a glance.",className:"inspector",bare:e.bare,children:g})}function bR(e){return(e==null?void 0:e.kind)==="ticket"?e.id:(e==null?void 0:e.kind)==="unspecified"?e.item:(e==null?void 0:e.kind)??""}function yy(e){const t=Array.from({length:Math.max(1,e.total)},(n,i)=>i+1);return s.jsx("span",{className:pe("step-segments",e.mini&&"mini"),role:"img","aria-label":`Step ${e.step} of ${e.total}`,children:t.map(n=>s.jsx("span",{className:pe(n<e.step&&"done",n===e.step&&"now")},n))})}function SR({session:e}){const t=Fa(e.model);return s.jsxs("div",{className:"bubble-agent",children:[s.jsx(B,{parts:[{text:e.agent,strong:!0},t&&{text:t,tip:e.model,className:"agent-model"},`step ${e.step} of ${e.total}`,e.stepLabel.toLowerCase()]}),s.jsx(yy,{step:e.step,total:e.total})]})}function NR(e){const{v:t,need:n}=e,i=t.standing,a=t.lease&&Ts(t.lease,t.now),c=!!n&&n.text.toLowerCase().includes(t.t.title.toLowerCase()),d=!!n&&!!i.primary;return s.jsxs("div",{className:pe("bubble-ticket",n&&"under",a&&`lease-${a}`,t.modelWait&&"model-wait"),children:[s.jsxs("span",{className:"t-label",children:[s.jsx("span",{className:"t-code",children:t.t.key})," · ",En[t.t.type]]}),!c&&s.jsx("h3",{className:pe("bubble-title",n&&"small"),children:t.t.title}),!d&&s.jsxs("div",{className:pe("bubble-state",`edge-${i.edge}`),children:[s.jsx("span",{className:"state-title",children:i.title}),s.jsx(B,{parts:i.parts})]}),t.notices.filter(u=>u.text!==(n==null?void 0:n.item)).map(u=>s.jsx("span",{className:"t-meta bubble-notice",children:u.text},u.text)),t.session&&s.jsx(SR,{session:t.session}),s.jsx(gy,{v:t}),s.jsx("button",{type:"button",className:"link full-ticket",onClick:e.onFullTicket,children:"Full ticket"})]})}function $R(e){const{need:t,pr:n}=e,i=Au(t.item),a=n&&pn(n.url);return s.jsxs("div",{className:"bubble-need",children:[s.jsx("span",{className:pe("t-label",t.urgent&&"urgent"),children:t.label}),s.jsx("h3",{className:"bubble-title",children:t.title}),s.jsx(B,{parts:[...i,Xe(e.now-t.item.since)]}),e.actions,t.item.kind==="merge"&&n&&a&&s.jsxs("a",{className:"link",href:a,target:"_blank",rel:"noreferrer",children:["Open PR #",n.number]})]})}const CR={merge:"Ready to merge",approval:"Approve it",blocked:"Blocked",stalled:"Went quiet","hitl-ready":"Yours to decide",policy:"Check a risky change",overlap:"Two agents, same files",integration:"Branches clash",model:"Waits for a model",precedent:"Touches your decision",flag:"PR or CI","tracker-settings":"Settings changed","review-limit":"Review waits",escape:"Verified, then came back"},TR=e=>e.split(`
|
|
156
|
+
`)[0].replace(/^[^\s:]+: /,"");function ER(e){if(e.questionId)return{kind:"question",questionId:e.questionId};const t=e.items.find(i=>i.kind!=="question");return t?{kind:"item",label:CR[t.kind]??"Needs you",title:TR(t.title),urgent:e.urgentOf(t),item:t}:{kind:"none"}}function AR(e){var x,C,N,P;const{api:t,t:n}=e,i=py({snap:e.snap,t:n,api:t,sessions:e.sessions,attention:e.attention}),[a,c]=y.useState(null),d=cy({v:i,api:t,setForm:c,onEditHow:e.onFullTicket,onOpenChat:e.onOpenChat,onReviewChange:e.onReviewChange,onReviewBrief:e.onReviewBrief}),u=ER({questionId:(x=i.question)==null?void 0:x.id,items:i.items,urgentOf:D=>Tr(D,i.interrupting.includes(D.id))==="urgent"}),f=u.kind==="question"||u.kind==="item"&&u.urgent,{onUrgent:m}=e;y.useEffect(()=>m(f),[f,m]);const g=u.kind==="question",k=g&&((C=d.primary)==null?void 0:C.id)==="answer"?{...d,primary:void 0}:d,w=s.jsxs(s.Fragment,{children:[s.jsx(Bk,{v:i,bar:k,onOpenChat:e.onOpenChat}),s.jsx(ay,{form:a,setForm:c,v:i,actions:t.actions,act:d.act,waive:d.waive})]}),b=D=>{var M;return(M=e.snap.tickets.find(H=>H.id===D))==null?void 0:M.key},S=((N=i.pr)==null?void 0:N.pr)&&{number:i.pr.pr.number,url:i.pr.pr.url};return s.jsxs(s.Fragment,{children:[g&&i.question&&s.jsx(Mk,{q:i.question,now:i.now,keyOf:b,onAnswer:t.actions.answer,onOpenChat:e.onOpenChat}),u.kind==="item"&&s.jsx($R,{need:u,now:i.now,pr:S,actions:w}),s.jsx(NR,{v:i,need:RR(u,(P=i.question)==null?void 0:P.text),onFullTicket:e.onFullTicket}),u.kind!=="item"&&w]})}function RR(e,t){if(e.kind==="item")return{text:e.title,item:e.item.title};if(e.kind==="question")return{text:t??""}}function IR(e){const{selection:t,snap:n,api:i}=e,a=gt(5e3);switch(t.kind){case"ticket":{const c=n==null?void 0:n.tickets.find(d=>d.id===t.id);return c?s.jsx(AR,{...e,snap:n,t:c},c.id):s.jsx(Te,{children:"Ticket not found."})}case"main":return n?s.jsx(gk,{mapId:n.map.id,now:a}):null;case"together":return n?s.jsx(yk,{mapId:n.map.id,now:a,onUrgent:e.onUrgent}):null;case"question":{const c=i.activity.pending.find(u=>u.id===t.id);if(!c)return s.jsx(Te,{children:"Answered."});const d=u=>{var f;return(f=n==null?void 0:n.tickets.find(m=>m.id===u))==null?void 0:f.key};return s.jsx(Mk,{q:c,now:a,keyOf:d,onAnswer:i.actions.answer,onOpenChat:e.onOpenChat})}case"unspecified":return null;default:return t}}const ng=14,Nn=8;function MR(e){const{anchor:t,box:n,bubble:i}=e,a=Math.max(Nn,n.w-i.w-Nn),c=Math.max(Nn,n.h-i.h-Nn);if(!t)return{left:a,top:Nn,side:"corner"};const d=(t.top+t.bottom)/2,u=Math.min(c,Math.max(Nn,d-i.h/2)),f=t.right+ng,m=t.left-ng-i.w;if(f+i.w<=n.w-Nn)return{left:f,top:u,side:"right"};if(m>=Nn)return{left:m,top:u,side:"left"};const g=n.w-t.right,k=t.left;return g>=k?{left:Math.min(f,a),top:u,side:"right"}:{left:Math.max(Nn,m),top:u,side:"left"}}function OR(e){const t=y.useRef(null),[n,i]=y.useState({w:0,h:0});y.useLayoutEffect(()=>{const u=t.current;if(!u||e.docked)return;const f=new ResizeObserver(()=>i({w:u.offsetWidth,h:u.offsetHeight}));return f.observe(u),()=>f.disconnect()},[e.docked]);const{onClose:a}=e;y.useEffect(()=>{const u=f=>f.key==="Escape"&&!f.defaultPrevented&&a();return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[a]);const c=MR({anchor:e.anchor,box:e.box,bubble:n}),d=e.docked?void 0:{left:c.left,top:c.top,maxHeight:e.box.h-16};return s.jsxs("section",{ref:t,className:pe("bubble",e.docked&&"docked",`side-${c.side}`,e.urgent&&"urgent"),style:d,"aria-label":e.label,children:[s.jsx("button",{type:"button",className:"bubble-close","aria-label":"Close",onClick:a,children:"×"}),e.children]})}const LR={ticket:"Ticket",main:"Checks on main",together:"Destination",question:"Question"};function PR(e){if(e.kind==="ticket")return e.id;if(e.kind==="main")return"main";if(e.kind==="together")return"destination"}function DR(e){var g,k;const{api:t,nav:n,attn:i}=e,a=t.selection,[c,d]=y.useState(!1),u=y.useCallback(w=>d(w),[]);if(!a||a.kind==="unspecified"||n.fullTicket||!t.snap&&a.kind!=="question")return null;const f=PR(a),m=a.kind==="main"?e.mainNeeds:a.kind==="question"||c;return s.jsx(OR,{anchor:f?(g=e.place)==null?void 0:g.anchorOf(f):void 0,box:((k=e.place)==null?void 0:k.box)??{w:0,h:0},docked:!e.place,urgent:m,label:LR[a.kind],onClose:()=>n.select(null),children:s.jsx(IR,{selection:a,snap:t.snap,api:t,sessions:e.sessions,attention:i.attention.view,onUrgent:u,onFullTicket:()=>n.setFullTicket(!0),onOpenChat:w=>n.openChat(w),onReviewChange:i.handlers.openApprovals,onReviewBrief:i.handlers.openBrief})})}const _R=["plan","activity","logbook"],wy=[{id:"map",label:"Map"},{id:"plan",label:"Plan"},{id:"activity",label:"Activity"},{id:"logbook",label:"Logbook"}];function BR(e){var m;const{api:t,rt:n,brief:i}=e,{snap:a,actions:c}=t,[d]=Tu(15e3),u=Es(),f=d?OC(d):void 0;return s.jsx(OT,{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:c.setArchived,trackerLabel:n.adapter.label.toLowerCase(),onSelectMap:c.selectMap,onToggleMode:()=>a&&c.setMode(a.map.mode==="plan-only"?"plan+execute":"plan-only"),onSettings:e.onSettings,onToggleTheme:e.onToggleTheme,attention:e.attention,views:!e.phone&&s.jsx(PT,{tabs:wy,value:e.view,onChange:e.onView}),needs:s.jsx(LT,{count:e.needs.length,elsewhere:e.elsewhere.length,top:(m=e.needs[0])==null?void 0:m.title,onOpen:()=>{const g=e.needs[0]??e.elsewhere[0];g&&e.onNeed(g)}}),slackAlert:f,onSlack:e.onSlack,onStats:e.onStats,knowledge:u.attention,knowledgeOpen:u.open,onKnowledge:()=>u.setOpen(!u.open),briefingOpen:i.shown,briefingStatus:i.status,onBriefing:()=>i.shown?i.dismiss():i.open()})}function FR(e){return s.jsx(jT,{seed:e.seed,onClose:e.onClose,tracker:e.rt.adapter.label,onCreate:async t=>{const n=await N1(e.rt.adapter,t);return e.onCreated(n.id),n}})}const zR={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"},Pu=e=>zR[e];function Du(e){var t;return((t=e.account)==null?void 0:t.kind)==="user"?e.account.login:void 0}const md=e=>!!e.auth&&!!Du(e);function xy(e,t){const n=Du(e);return!e.auth||!n?void 0:`Will use ${t||"the repo you pick"} as ${n} (${Pu(e.auth)})`}function UR(e){if(!e.repo)return;const t=Du(e),n=t?` as ${t}`:"",i=e.auth?`, using ${Pu(e.auth)}`:"";return`Connected to ${e.repo}${n}${i}`}function WR(e,t){if(!e.pushedAt)return;const n=Math.floor((t-Date.parse(e.pushedAt))/864e5);return n<1?"Pushed today":n<60?`Pushed ${n}d ago`:`Pushed ${Math.floor(n/30)}mo ago`}function HR(e){const{gh:t}=e;if(!t.auth)return null;const n=xy(t,e.repo);return s.jsxs("div",{className:"gh-identity",children:[n&&s.jsx("span",{className:"t-body",children:n}),s.jsxs("span",{className:"gh-identity-actions",children:[s.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another token"}),t.auth==="signed-in"&&s.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 KR=/^[\w.-]+\/[\w.-]+$/;function GR(e){const t=e.query.trim().toLowerCase(),i=!!e.detected&&e.repos.every(f=>f.fullName!==e.detected)?[{fullName:e.detected,private:!1},...e.repos]:e.repos,a=[...i.filter(f=>f.fullName===e.detected),...i.filter(f=>f.fullName!==e.detected)],c=t?a.filter(f=>f.fullName.toLowerCase().includes(t)):a,u=KR.test(e.query.trim())&&c.every(f=>f.fullName.toLowerCase()!==t)?e.query.trim():void 0;return{shown:c.slice(0,e.limit),matches:c.length,typed:u}}function sg(e){const{repo:t,listed:n}=e,i=t.private?"Private":"Public";return s.jsx(he,{as:"li",className:"repo-row",selected:e.selected,title:s.jsx("span",{className:"t-code",children:t.fullName}),context:s.jsx(B,{parts:[e.detected&&{text:"This project's repo",strong:!0},n&&i,n&&WR(t,e.now),!n&&"Checked when you connect"]}),onOpen:e.onPick})}const VR=40;function ig(e){const[t,n]=y.useState(""),i=y.useMemo(()=>Date.now(),[]),a=y.useMemo(()=>new Set(e.repos.map(g=>g.fullName)),[e.repos]),{shown:c,matches:d,typed:u}=GR({repos:e.repos,detected:e.detected,query:t,limit:VR}),f=d>c.length?`${d-c.length} more: type to narrow`:"",m=e.truncated?`Your ${e.repos.length} most recently pushed repos`:"";return s.jsxs("div",{className:"repo-picker",children:[s.jsxs("label",{className:"field",children:["Repository",s.jsx("input",{value:t,placeholder:"Search your repos, or type owner/name",spellCheck:!1,"aria-label":"Search repositories",onChange:g=>n(g.target.value)})]}),s.jsxs("ul",{className:"repo-list","aria-label":"Repositories",children:[u&&s.jsx(sg,{repo:{fullName:u,private:!1},detected:u===e.detected,listed:!1,selected:u===e.value,now:i,onPick:()=>e.onChange(u)}),c.map(g=>s.jsx(sg,{repo:g,detected:g.fullName===e.detected,listed:a.has(g.fullName),selected:g.fullName===e.value,now:i,onPick:()=>e.onChange(g.fullName)},g.fullName))]}),s.jsx(B,{parts:[!d&&!u&&"No repo matches",f,m]})]})}function qR(e){const{list:t}=e;if(!t)return s.jsx(yi,{label:"Loading your repos…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return s.jsx(ig,{repos:t.repos,truncated:t.truncated,detected:t.detectedRepo??e.detected,value:e.value,onChange:e.onChange});case"no-token":return s.jsx(B,{parts:["No GitHub token found"]});case"error":return s.jsxs(s.Fragment,{children:[s.jsx($u,{what:"Couldn't list your repos",reason:t.error,onRetry:e.onRetry}),s.jsx(ig,{repos:[],truncated:!1,detected:e.detected,value:e.value,onChange:e.onChange})]});default:return t}}const QR={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"},gr=e=>e==="github"||e==="linear";function jy(e){const[t,n]=y.useState(!e.source);return e.source&&!t?s.jsxs("div",{className:"ts-auth",children:[s.jsx("span",{className:"mono-label",children:e.label}),s.jsx("span",{className:"pill on",children:QR[e.source]}),s.jsx("button",{type:"button",className:"btn ghost sm",onClick:()=>n(!0),children:"Use another"})]}):s.jsxs("label",{className:"field",children:[s.jsxs("span",{className:"ts-label",children:[e.label,e.link&&s.jsx("a",{href:e.link.href,target:"_blank",rel:"noreferrer",children:e.link.text})]}),s.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:e.value,placeholder:e.placeholder,onChange:i=>e.onChange(i.target.value)})]})}function YR(e){const[t,n]=y.useState(!1),i=()=>{var a;return void((a=navigator.clipboard)==null?void 0:a.writeText(e.code).then(()=>n(!0),()=>{}))};return s.jsxs("div",{className:"gh-device",children:[s.jsx("span",{className:"t-label",children:"Enter this code on GitHub"}),s.jsxs("div",{className:"gh-device-row",children:[s.jsx("code",{className:"gh-device-code t-code","aria-label":"Your code",children:e.code}),s.jsx(I,{size:"sm",variant:"ghost",onClick:i,children:t?"Copied":"Copy"})]}),s.jsxs("div",{className:"gh-device-row",children:[s.jsx("a",{className:"btn primary",href:pn(e.href),target:"_blank",rel:"noreferrer",onClick:i,children:"Open GitHub"}),s.jsx(I,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]}),s.jsx(yi,{label:"Waiting for you to approve on GitHub…"})]})}function JR(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 XR(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 Kt=FS(ie());function vr(e,t){e({tracker:t});const n=new URL(location.href);n.searchParams.delete("tracker"),location.href=n.toString()}function ZR(e){const[t,n]=y.useState({kind:"idle"}),i=y.useRef(e);i.current=e;const a=t.kind==="code";return y.useEffect(()=>{if(t.kind!=="code")return;let c=!0;const d=setTimeout(()=>void Kt.githubSignIn.poll().then(async u=>{c&&(u.kind==="signed-in"&&await i.current(),c&&n(XR(t,u)))},u=>c&&n({kind:"ended",reason:u.message})),Math.max(t.interval,1)*1e3);return()=>{c=!1,clearTimeout(d)}},[t]),y.useEffect(()=>{if(a)return()=>void Kt.githubSignIn.cancel().catch(()=>{})},[a]),{state:t,start(){n({kind:"starting"}),Kt.githubSignIn.start().then(c=>n(JR(c)),c=>n({kind:"ended",reason:c.message}))},cancel(){n({kind:"idle"})}}}function eI(e){const{state:t,start:n,cancel:i}=ZR(e.onSignedIn);switch(t.kind){case"idle":return s.jsxs("div",{className:"gh-sign-in",children:[s.jsx(I,{variant:"primary",onClick:n,children:"Sign in with GitHub"}),s.jsx(B,{parts:["No gh login or token needed","the token stays on this machine"]}),s.jsx(B,{parts:["GitHub asks for access to your repos: it has no narrower scope for issues in private repos"]})]});case"starting":return s.jsx(yi,{label:"Asking GitHub for a code…"});case"code":return s.jsx(YR,{code:t.userCode,href:t.verificationUri,onCancel:i});case"ended":return s.jsxs("div",{className:"gh-sign-in",children:[s.jsx(I,{onClick:n,children:"Try again"}),s.jsx(B,{parts:["Didn't sign in",t.reason]})]});default:return t}}function tI(e){var d,u;const{gh:t}=e,n=t.auth&&((d=t.account)==null?void 0:d.kind)==="unknown"?`Found ${Pu(t.auth)}, but GitHub didn't accept it`:"",i=((u=t.account)==null?void 0:u.kind)==="unknown"?t.account.error:"",a=t.auth==="GITHUB_TOKEN"||t.auth==="GH_TOKEN",c=t.signIn.available&&!a;return s.jsxs(s.Fragment,{children:[n&&s.jsx(B,{parts:[n,i]}),c&&s.jsx(eI,{onSignedIn:e.onSignedIn}),c&&s.jsx("span",{className:"t-label gh-or",children:"Or paste a token"}),s.jsx(jy,{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"}}),s.jsxs("span",{className:"t-meta",children:["Or run ",s.jsx("code",{className:"t-code",children:"gh auth login"})," in a terminal; this finds it in a few seconds."]}),s.jsxs("label",{className:"field",children:["Repository",s.jsx("input",{value:e.repo,placeholder:"owner/name",spellCheck:!1,onChange:f=>e.onRepo(f.target.value.trim())})]})]})}function by({r:e}){var i,a;if(!e)return null;if(!e.ok)return s.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]});const t=(i=e.rate)!=null&&i.limit?`${(a=e.rate.remaining)==null?void 0:a.toLocaleString()}/${e.rate.limit.toLocaleString()} req`:"";let n="";return e.canWrite===!1?n="read-only":e.canWrite&&(n="read/write"),s.jsxs("div",{className:"test-line ok",children:["✓ ",[e.account,e.target,n,t].filter(Boolean).join(" · ")]})}function _u(e){const[t,n]=y.useState(),[i,a]=y.useState(0);y.useEffect(()=>{if(n(void 0),!e.enabled)return;let d=!0;return e.load().then(u=>d&&n(u),u=>d&&n(e.failed(u.message))),()=>{d=!1}},[e.enabled,e.key,i]);const c=y.useCallback(()=>a(d=>d+1),[]);return{value:t,retry:c}}function nI(e){const{value:t,retry:n}=_u({enabled:e.enabled,key:e.auth??"",load:()=>Kt.githubRepos(),failed:i=>({kind:"error",error:i})});return{list:t,retry:n}}function Sy(e){const t=e.s.github,n=md(t),[i,a]=y.useState(!n),[c,d]=y.useState(t.repo??t.detectedRepo??""),[u,f]=y.useState(""),[m,g]=y.useState(),[k,w]=y.useState(!1),{list:b,retry:S}=nI({enabled:!i,auth:t.auth});y.useEffect(()=>{n&&!u&&a(!1)},[n]);const x=async()=>{w(!0),g(void 0);try{await Kt.connect({active:"github",github:{repo:c,token:i?u:void 0}}),e.onConnected()}catch(M){g({ok:!1,error:M.message}),w(!1)}},C=async()=>{const M=await e.reload();M&&md(M.github)&&a(!1)},N=async()=>{await Kt.githubSignIn.signOut().catch(()=>{});const M=await e.reload();a(!M||!md(M.github))},D=!!c&&!(!i&&!b)&&(!i||!!u||n);return s.jsxs("div",{className:"card inset tracker-setup",children:[i?s.jsx(tI,{gh:t,token:u,onToken:f,repo:c,onRepo:d,onSignedIn:C}):s.jsxs(s.Fragment,{children:[s.jsx(HR,{gh:t,repo:c,onUseAnother:()=>a(!0),onSignOut:()=>void N()}),s.jsx(qR,{list:b,detected:t.detectedRepo,value:c,onChange:d,onRetry:S})]}),s.jsx(by,{r:m}),s.jsx("footer",{children:s.jsx("button",{type:"button",className:"btn primary",disabled:k||!D,onClick:()=>void x(),children:k?"Connecting…":"Connect"})})]})}function sI(e){return e.line?s.jsxs("div",{className:"gh-identity",children:[s.jsxs("div",{className:"ln-who",children:[s.jsx("span",{className:"t-body",children:e.line}),e.email&&s.jsx(B,{parts:[e.email]})]}),e.onUseAnother&&s.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another key"})]}):null}const iI={LINEAR_API_KEY:"LINEAR_API_KEY",stored:"a saved key"},Bu=e=>iI[e]??e;function Qa(e){return(e==null?void 0:e.kind)==="user"?e:void 0}const rI=e=>!!e.auth&&!!Qa(e.viewer);function Ny(e,t){if(e)return t?`${e} / ${t}`:e}function $y(e){const t=Qa(e.viewer);if(!t)return;const n=Ny(e.team,e.project)??"the team you pick",i=e.source?` (${Bu(e.source)})`:"";return`Will use ${n} in ${t.orgName} as ${t.name}${i}`}function oI(e){const t=Ny(e.teamName??e.teamKey,e.projectName);if(!e.teamId||!t)return;const n=Qa(e.viewer),i=e.orgName??(n==null?void 0:n.orgName),a=i?` in ${i}`:"",c=n?` as ${n.name}`:"",d=e.auth?`, using ${Bu(e.auth)}`:"";return`Connected to ${t}${a}${c}${d}`}function aI(e,t){if(!e.activeAt)return"No issues yet";const n=Math.floor((t-Date.parse(e.activeAt))/864e5);return n<1?"Active today":n<60?`Active ${n}d ago`:`Active ${Math.floor(n/30)}mo ago`}function cI(e){var a,c;const{ln:t}=e,n=t.auth&&((a=t.viewer)==null?void 0:a.kind)==="unknown"?`Found ${Bu(t.auth)}, but Linear didn't accept it`:"",i=((c=t.viewer)==null?void 0:c.kind)==="unknown"?t.viewer.error:"";return s.jsxs(s.Fragment,{children:[n&&s.jsx(B,{parts:[n,i]}),s.jsx(jy,{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"}}),s.jsxs("span",{className:"t-meta",children:["Or set ",s.jsx("code",{className:"t-code",children:"LINEAR_API_KEY"})," before starting Teamtrail."]})]})}function lI(e){const{list:t}=e;if(!t)return s.jsx(yi,{label:"Loading projects…"});if(t.kind==="error")return s.jsx($u,{what:"Couldn't list the team's projects",reason:t.error,onRetry:e.onRetry});if(t.kind!=="ok"||!t.projects.length)return null;const n=[{value:"",label:"All projects"},...t.projects.map(i=>({value:i.id,label:i.state?`${i.name} · ${i.state}`:i.name}))];return s.jsxs("label",{className:"field",children:["Project (optional)",s.jsx(rt,{"aria-label":"Project",value:e.value,onChange:e.onChange,options:n})]})}function dI(e){const t=e.query.trim().toLowerCase(),n=t?e.teams.filter(i=>i.key.toLowerCase().includes(t)||i.name.toLowerCase().includes(t)):e.teams;return{shown:n.slice(0,e.limit),matches:n.length}}function uI(e,t){return t&&e.some(n=>n.id===t)?t:e.length===1?e[0].id:void 0}function hI(e){const{team:t}=e;return s.jsx(he,{as:"li",className:"repo-row team-row",selected:e.selected,title:t.name,context:s.jsx(B,{parts:[{text:t.key,code:!0},aI(t,e.now)]}),onOpen:e.onPick})}const fI=40;function mI(e){const[t,n]=y.useState(""),i=y.useMemo(()=>Date.now(),[]),{shown:a,matches:c}=dI({teams:e.teams,query:t,limit:fI}),d=c>a.length?`${c-a.length} more: type to narrow`:"",u=e.truncated?`The first ${e.teams.length} teams`:"",f=e.value?"":"Pick the team your trails go in";return s.jsxs("div",{className:"repo-picker",children:[s.jsxs("label",{className:"field",children:["Team",s.jsx("input",{value:t,placeholder:"Search your teams by key or name",spellCheck:!1,"aria-label":"Search teams",onChange:m=>n(m.target.value)})]}),s.jsx("ul",{className:"repo-list","aria-label":"Teams",children:a.map(m=>s.jsx(hI,{team:m,selected:m.id===e.value,now:i,onPick:()=>e.onChange(m.id)},m.id))}),s.jsx(B,{parts:[!c&&"No team matches",f,d,u]})]})}function pI(e){const{list:t}=e;if(!t)return s.jsx(yi,{label:"Loading teams…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return s.jsx(mI,{teams:t.teams,truncated:t.truncated,value:e.value,onChange:e.onChange});case"no-key":return s.jsx(B,{parts:["Paste a Linear API key to list your teams"]});case"error":return s.jsx($u,{what:"Couldn't list your teams",reason:t.error,onRetry:e.onRetry});default:return t}}function gI(e,t){const[n,i]=y.useState(e);return y.useEffect(()=>{const a=setTimeout(()=>i(e),t);return()=>clearTimeout(a)},[e,t]),n}function vI(e){const{value:t,retry:n}=_u({enabled:e.enabled&&!!e.teamId,key:`${e.teamId}
|
|
157
|
+
${e.apiKey??""}`,load:()=>Kt.linearProjects(e.teamId,e.apiKey),failed:i=>({kind:"error",error:i})});return{list:t,retry:n}}function kI(e){const{value:t,retry:n}=_u({enabled:e.enabled,key:e.apiKey??"",load:()=>Kt.linearTeams(e.apiKey),failed:i=>({kind:"error",error:i})});return{list:t,retry:n}}function yI(e){const t=gI(e.apiKey.trim(),400),n=e.paste&&t?t:void 0,i=e.paste?!!t:!!e.ln.auth,a=kI({enabled:i,apiKey:n}),c=vI({teamId:e.teamId,apiKey:n,enabled:i}),d=a.list,u=c.list,f=(d==null?void 0:d.kind)==="ok"?d.teams:[],m=i&&!d,g=i&&!!e.teamId&&!u;return{enabled:i,list:d,teams:f,projects:u,loading:m||g,retryTeams:a.retry,retryProjects:c.retry}}function Cy(e){var be;const t=e.s.linear,n=rI(t),[i,a]=y.useState(!n),[c,d]=y.useState(""),[u,f]=y.useState(t.teamId??""),[m,g]=y.useState(t.projectId??""),[k,w]=y.useState(),[b,S]=y.useState(!1),{enabled:x,list:C,teams:N,projects:P,loading:D,retryTeams:M,retryProjects:H}=yI({ln:t,paste:i,apiKey:c,teamId:u});y.useEffect(()=>{n&&!c&&a(!1)},[n]),y.useEffect(()=>{(C==null?void 0:C.kind)==="ok"&&f(uI(C.teams,t.teamId)??"")},[C]);const _=N.find(de=>de.id===u),Y=(P==null?void 0:P.kind)==="ok"?P.projects.find(de=>de.id===m):void 0,re=(C==null?void 0:C.kind)==="ok"?C.viewer:t.viewer,q=i?null:t.auth,Z=$y({viewer:re,team:_==null?void 0:_.name,project:Y==null?void 0:Y.name,source:q}),Ae=async()=>{if(_){S(!0),w(void 0);try{await Kt.connect({active:"linear",linear:{teamId:_.id,teamKey:_.key,teamName:_.name,projectId:Y==null?void 0:Y.id,projectName:Y==null?void 0:Y.name,apiKey:i?c.trim():void 0}}),e.onConnected()}catch(de){w({ok:!1,error:de.message}),S(!1)}}},ye=de=>{f(de),g("")};return s.jsxs("div",{className:"card inset tracker-setup linear-setup",children:[i&&s.jsx(cI,{ln:t,apiKey:c,onKey:d}),s.jsx(sI,{line:Z,email:(be=Qa(re))==null?void 0:be.email,onUseAnother:i?void 0:()=>a(!0)}),x&&s.jsx(pI,{list:C,value:u,onChange:ye,onRetry:M}),_&&s.jsx(lI,{list:P,value:m,onChange:g,onRetry:H}),s.jsx(by,{r:k}),s.jsx("footer",{children:s.jsx("button",{type:"button",className:"btn primary",disabled:b||D||!_,onClick:()=>void Ae(),children:b?"Connecting…":"Connect"})})]})}function wI(e){return s.jsxs("div",{className:"c-actions",children:[e.canSwitch&&s.jsx("button",{className:"btn sm",disabled:!e.usable,onClick:e.onSwitch,children:"Switch"}),e.remote&&s.jsx("button",{className:`btn sm ${e.open?"on":""}`,disabled:!e.usable,onClick:e.onToggle,children:e.configured?"Edit":"Connect"})]})}function xI(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 jI(e){const{id:t,active:n,s:i}=e,a=gr(t),c=n&&i?bI(t,i):void 0;return c&&a?s.jsxs(s.Fragment,{children:[s.jsx(B,{className:"c-who",parts:[c]}),s.jsx(B,{className:"c-trust",parts:xI(t)})]}):c?s.jsx(B,{className:"c-who",parts:[c]}):n&&(t==="markdown"||a)?s.jsx("div",{className:"c-loc",children:e.location}):a&&e.configured&&i?s.jsx("div",{className:"c-loc",children:SI(t,i)}):null}function bI(e,t){if(e==="github")return UR(t.github);if(e==="linear")return oI(t.linear)}function SI(e,t){return e==="github"?t.github.repo:[t.linear.teamKey,t.linear.projectName].filter(Boolean).join(" · ")}function NI({status:e}){var c,d;if(!e)return null;const t=(c=e.rate)!=null&&c.limit?`${((d=e.rate.remaining)==null?void 0:d.toLocaleString())??"?"}/${e.rate.limit.toLocaleString()} req`:"",n=e.queued?` · ${e.queued} queued`:"",[i,a]=$I(e,n);return s.jsxs("div",{className:`sync-line ${i}`,title:e.error,children:[s.jsx("span",{className:"dot"}),s.jsx("span",{children:a}),t&&s.jsx("span",{className:"rate",children:t})]})}function $I(e,t){switch(e.state){case"online":return["ok",`Online · synced ${Yv(e.lastSyncAt)}${t}`];case"offline":return["warn",`Offline${t}`];case"rate-limited":return["warn",`Rate limited · resumes ${rs(e.resetAt)}${t}`];case"auth-error":return["alert",`Credentials rejected${t}`];default:return["",`Connecting${t}`]}}function CI(e){const{id:t,active:n,configured:i,s:a}=e,c=gr(t),d=!c||!!a,u=["card connector",n?"active":"",d?"":"disabled",e.open?"open":""];return s.jsxs("div",{className:u.join(" "),children:[s.jsxs("div",{className:"card-row",children:[s.jsx("b",{className:"choice-title t-row-title",children:e.name}),n&&s.jsx("span",{className:"pill on",children:"Active"})]}),s.jsx(jI,{id:t,active:n,configured:i,location:e.location,s:a}),c&&n&&s.jsx(NI,{status:a==null?void 0:a[t].status}),s.jsx(wI,{canSwitch:!n&&(!c||i),remote:c,usable:d,configured:i,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function Ty(e=0){const[t,n]=y.useState(),i=y.useCallback(()=>Kt.get().then(a=>(n(a),a),()=>(n(null),void 0)),[]);return y.useEffect(()=>{if(i(),!e)return;const a=setInterval(()=>void i(),e);return()=>clearInterval(a)},[i,e]),[t,n,i]}function TI(e){const[t,,n]=Ty(5e3),[i,a]=y.useState(null),c=async u=>{t&&(u==="markdown"||gr(u))&&await Kt.connect({active:u==="markdown"?"markdown":u,...u==="github"&&t.github.repo?{github:{repo:t.github.repo}}:{},...u==="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(()=>{}),vr(e.update,u)},d=y.useMemo(()=>({github:!!(t!=null&&t.github.repo),linear:!!(t!=null&&t.linear.teamId)}),[t]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"connectors",children:zS.map(u=>{const f=u.id;return s.jsx(CI,{id:f,name:u.name,active:f===e.activeTracker,configured:gr(f)&&d[f],open:i===f,location:e.location,s:t,onSwitch:()=>void c(f),onToggle:()=>gr(f)&&a(i===f?null:f)},u.id)})}),t&&i==="github"&&s.jsx(Sy,{s:t,reload:n,onConnected:()=>vr(e.update,"github")}),t&&i==="linear"&&s.jsx(Cy,{s:t,onConnected:()=>vr(e.update,"linear")})]})}function EI(e,t){const n=e==null?void 0:e.github,i=e==null?void 0:e.linear,a=n&&t!=="github"?xy(n,n.repo??n.detectedRepo):void 0,c=i&&t!=="linear"?$y({viewer:i.viewer,team:i.teamName,project:i.projectName,source:i.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:c??"Trails and tickets in your Linear team"}]}function Ey(e){const t=[{v:"summary",title:"Summary"},{v:"full",title:"Full transcript"}];return s.jsx("div",{className:"choice-row",children:t.map(n=>s.jsx(ct,{on:e.value===n.v,title:n.title,onClick:()=>e.onChange(n.v)},n.v))})}const AI={github:"Checking for a GitHub login…",linear:"Checking for a Linear key…"};function RI(e){var C;const{prefs:t,update:n}=e,[i,,a]=Ty(5e3),[c,d]=y.useState(!1),u=(C=i==null?void 0:i.pending)==null?void 0:C.target.split(":")[0],[f,m]=y.useState(!1);y.useEffect(()=>{u&&!f&&t.tracker!==u&&n({tracker:u})},[u,f,t.tracker,n]);const g=EI(i??void 0,t.tracker),k=t.tracker==="github"||t.tracker==="linear",w=k&&(i==null?void 0:i.active)===t.tracker,b=k&&!w,S=N=>{n({onboarded:!0}),vr(n,N)},x=async()=>{d(!0);const N=i&&!i.pending;t.tracker==="markdown"&&N&&await Kt.connect({active:"markdown"}).catch(()=>{}),n({onboarded:!0}),t.tracker!==e.activeTracker&&vr(n,t.tracker)};return s.jsx("div",{className:"scrim",children:s.jsxs(Fe,{as:"div",className:"dialog onboarding",children:[s.jsx("div",{className:"onb-brand",children:s.jsx(Ua,{className:"onb-title"})}),s.jsxs("h2",{className:"onb-question t-heading",children:[s.jsx(O$,{className:"voice-badge",size:22}),"Where should your trails live?"]}),s.jsxs(Ee,{title:"Tracker",children:[s.jsx("div",{className:"choice-row",children:g.map(N=>s.jsx(ct,{on:t.tracker===N.id,title:N.title,sub:N.sub,onClick:()=>(m(!0),n({tracker:N.id}))},N.id))}),(i==null?void 0:i.pending)&&s.jsxs("p",{className:"t-meta onb-repo-tracker",children:["This repo keeps its trails in ",i.pending.label,". Connect it here, or keep local files on this machine; the team's choice in the repo isn't changed either way."]}),i===void 0&&k&&s.jsx(yi,{label:AI[t.tracker]??"Checking…"}),i&&t.tracker==="github"&&!w&&s.jsx(Sy,{s:i,reload:a,onConnected:()=>S("github")}),i&&t.tracker==="linear"&&!w&&s.jsx(Cy,{s:i,onConnected:()=>S("linear")})]}),s.jsx(Ee,{title:"HITL transcript",children:s.jsx(Ey,{value:t.hitlTranscript,onChange:N=>n({hitlTranscript:N})})}),s.jsx("footer",{children:s.jsx(I,{variant:"primary",disabled:c||b,onClick:()=>void x(),children:"Get started"})})]})})}function II(e){var t;return(t=pt())!=null&&t.tracker?null:s.jsx(RI,{...e})}const xr=[{id:"trail",label:"This trail",intro:"How agents work on the trail on screen: its mode, the checks that prove work done, the gates, diff rules, models and guides.",sections:[{id:"mode",title:"Trail mode"},{id:"verification",title:"Verification"},{id:"gates",title:"Gates"},{id:"rules",title:"Diff rules"},{id:"models",title:"Model matching"},{id:"trail-guides",title:"Guides by type"}]},{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 Fu(e){if(e===null)return null;const t=xr.find(a=>a.id===e);if(t)return{group:t.id};const n=xr.find(a=>a.sections.some(c=>c.id===e));if(!n)return{};const i=n.sections.find(a=>a.id===e);return{group:n.id,section:i==null?void 0:i.id}}function MI(e,t){const n=new URL(e);return n.searchParams.set("when",t.when.join(",")),n.searchParams.set("why",t.why),n.toString()}function OI(e,t){var i;const n=String((i=Fu("rules"))==null?void 0:i.section)==="rules";e(n?"rules":"verification"),history.replaceState(history.state,"",MI(location.href,t))}function LI(){return s.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 ",J.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 rg={from:"18:00",to:"09:00"};function PI(e){const t=e.focus!==void 0,n=e.focus??rg;return s.jsxs("div",{className:"att-settings-row set-field",children:[s.jsx("span",{className:"set-field-label",children:"Quiet hours"}),s.jsx(I,{size:"sm",on:t,"aria-pressed":t,onClick:()=>e.onChange(t?void 0:rg),children:t?"On":"Off"}),t&&s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"time","aria-label":"Quiet from",value:n.from,onChange:i=>i.target.value&&e.onChange({...n,from:i.target.value})}),s.jsx("span",{className:"t-meta",children:"to"}),s.jsx("input",{type:"time","aria-label":"Quiet until",value:n.to,onChange:i=>i.target.value&&e.onChange({...n,to:i.target.value})})]})]})}const pd=[3,5,8,12];function DI(e){const t=e&&!pd.includes(e)?[...pd,e].sort((n,i)=>n-i):pd;return[{value:"off",label:"Off"},...t.map(n=>({value:String(n),label:`${n} waiting`}))]}const og=e=>`${e} finished ticket${e===1?"":"s"}`;function _I(e,t){const n=(e==null?void 0:e.waiting.length)??0;return t?e!=null&&e.full?`${og(n)} wait: agents start no new implementation work until you review some.`:`${n} of ${t} waiting: agents start new work.`:n?`${og(n)} wait for your review now.`:"Nothing waits for your review now."}function BI(e){const{limit:t,review:n}=e;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"att-settings-row set-field",children:[s.jsx("span",{className:"set-field-label",children:"Review limit"}),s.jsx(rt,{compact:!0,"aria-label":"Review limit",value:t?String(t):"off",options:DI(t),disabled:e.local===!1,onChange:i=>e.onChange(i==="off"?null:Number(i))})]}),s.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. ",_I(n,t)]})]})}const FI=[{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 zI(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function UI(){const{view:e,error:t,savePrefs:n,saveReviewLimit:i}=Ak(0),a=xi();if(!e)return null;const c=e.policy.value,d=`${J.dataDir}/attention.json`,u=m=>void n({...e.prefs,...m}),f=typeof Notification<"u"&&Notification.permission==="denied";return s.jsxs(Ee,{title:"Attention",children:[s.jsxs("p",{className:"vf-intro",children:["Everything that needs you is ranked in Waiting on you. Only items scoring ",c.interrupt," or more interrupt you; the rest wait in the queue, and Slack gets them in a digest."]}),s.jsxs("div",{className:"att-settings-row set-field",children:[s.jsx("span",{className:"set-field-label",children:"Interrupt me by"}),s.jsx(rt,{compact:!0,"aria-label":"Interrupt me by",value:e.prefs.channel,options:FI,onChange:m=>{m==="browser"&&zI(),u({channel:m})}})]}),e.prefs.channel==="browser"&&f&&s.jsx("span",{className:"vf-err",children:"The browser blocks notifications for this page. Allow them in its site settings."}),s.jsx(PI,{focus:e.prefs.focus,onChange:m=>u({focus:m})}),s.jsx("span",{className:"set-hint t-meta",children:"Your channel and quiet hours stay on this machine."}),s.jsx(BI,{limit:c.reviewLimit,review:e.review,local:a,onChange:m=>void i(m)}),e.policy.errors.length>0&&s.jsx("ul",{className:"vf-errors",children:e.policy.errors.map(m=>s.jsxs("li",{children:[d,": ",m]},m))}),s.jsx(B,{className:"set-hint",parts:[e.policy.exists?{text:d,code:!0}:"Team defaults",`interrupt at ${c.interrupt}`,c.digestMinutes?`Slack digest every ${c.digestMinutes} min`:"Slack digest off",c.reviewLimit?`review limit ${c.reviewLimit}`:"review limit off"]}),t&&s.jsx("span",{className:"vf-err",children:t})]})}const WI=[5,15,30,60];function HI(e){const{value:t}=e;return s.jsxs("div",{className:"choice-row compact",children:[s.jsx(ct,{on:!t.enabled,title:"Off",onClick:()=>e.onChange({...t,enabled:!1})}),WI.map(n=>s.jsx(ct,{on:t.enabled&&t.awayMinutes===n,title:`Away ${n} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:n})},n))]})}const KI={repo:"Committed to the repo",machine:"Only on this machine",browser:"Only in this browser"};function We(e){const t=e.storage&&KI[e.storage];return s.jsxs("div",{className:"sp-slot",id:`settings-${e.id}`,children:[e.children,t&&s.jsx(B,{className:"sp-where",parts:[t]})]})}function GI(e){const[t]=Tu();return t?s.jsx(Ee,{title:"Slack",children:s.jsx(MC,{focus:e.focus})}):null}function VI({data:e,route:t}){return s.jsxs(s.Fragment,{children:[s.jsx(We,{id:"attention",storage:"repo",children:s.jsx(UI,{})}),s.jsx(We,{id:"slack",storage:"machine",children:s.jsx(GI,{focus:t.section==="slack"})}),s.jsx(We,{id:"trip-report",storage:"browser",children:s.jsx(Ee,{title:"Trip report",children:s.jsx(HI,{value:e.prefs.briefing,onChange:n=>e.update({briefing:n})})})})]})}const qI=[{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"]}],QI=[{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"]},{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"]}],YI=[{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"]},{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"]}],JI=[{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"]},{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"]},...YI],XI=[{area:"Teamtrail Cloud",items:["The Lookout as an app on your phone, with a nudge only for the calls that need you"]}],ZI=[{version:"0.61.2",date:"2026-11-18",items:["Went without a diff rule by mistake? Undo it in the ticket, and the rule asks again on the next completion","Where a ticket's work started is kept on your machine, not in the repo, so an agent can't move it to slip a change past the check guard","In Teamtrail Cloud, a trail is checked on exactly the commit Teamtrail names on main"]},{version:"0.61.1",date:"2026-11-18",items:["A trail with many tickets side by side lays them out in a grid, in order of number, instead of one tall column"]},{version:"0.61.0",date:"2026-11-18",items:["A pass counts only when the work didn't change what the check runs, skip or delete tests, or pass only on a retry","A trail is verified only when your checks pass again on main with every ticket merged","Reviews go first to an agent on another model, and rules you write ask agents about the files they touch","Settings → This trail → Gates: try each gate in Observe first; the scorecard shows verified work that came back"]},{version:"0.60.0",date:"2026-11-17",items:["The map takes the page: click a ticket and a bubble opens beside it, with what it needs from you first, then the ticket","Under the map, the trail bar: every ticket at a glance, what needs you, and More for agents at work and what is next","Cards move while something happens: waiting for an agent, an agent at work with its model and step, a halo when it needs you","Plan, Activity and the Logbook are pages of their own, from the tabs in the header"]},{version:"0.59.4",date:"2026-11-17",items:["A check that fails only as it already does on main no longer sends the first completion back for rework when an acceptance criterion names it","Where Teamtrail merges pull requests, a done ticket that isn't verified offers Merge anyway: why in one line, one question, and it's kept as your decision","A done ticket whose pull request is still open shows in your queue as ready to merge"]},{version:"0.59.3",date:"2026-11-17",items:["Checks on main find the dependencies of a package folder with its own install, like apps/web/node_modules","An agent held by checks failing on main tells you to choose in the Lookout, instead of asking you a question"]},{version:"0.59.2",date:"2026-11-17",items:["Settings → Verification reads calmer: one line per check, a warning under its command with the fix one click away, and Save apart"]},{version:"0.59.1",date:"2026-11-17",items:["A check like `npm web:lint`, a command npm doesn't have, is now flagged, with `npm run web:lint` suggested"]},{version:"0.59.0",date:"2026-11-17",items:["A check that can't pass in your repo no longer strands a ticket: Accept without it, with your reason. The other checks run again, the proof shows who skipped it and why, and Undo puts it back","Setting or approving checks now says which ones can't run as your repo is (a missing script, no go.mod, a missing make target), with Remove check or Keep anyway"]},{version:"0.58.0",date:"2026-11-17",items:["Before agents build, the approved checks run once on the default branch, so a check already failing on main is known before any agent is blamed for it","When one fails, the trail waits for your call: fix main first, drop that check for the trail, or start anyway. Each can be undone","After Start anyway, a completion that fails only in those checks, the same way, isn’t sent back, and its proof marks them as known failures, not verified","Run checks on main again any time, from the trail at a glance or Settings → Verification"]},{version:"0.57.0",date:"2026-11-17",items:["A ticket says where it stands first: who has it, or what it waits on, with the one thing to do next as a button","Every ticket action sits in one bar under it; the rest of the ticket reads as What, How, Progress, Proof and History, with details a click away","With no ticket selected, Trail step shows the trail at a glance: its phase, what waits on you, what each agent is on, and what is ready next"]},{version:"0.56.0",date:"2026-11-17",items:["Guides come with the ticket type: the architect on research, junctions and prototypes, QA and security on tasks, the reviewer on reviews. Change them per trail in Settings → Guides by type, your own guides included","A ticket can take several guides: add or remove one for that ticket alone in the inspector","A guide you add while an agent works reaches it at its next report, and its checklist counts at completion"]},{version:"0.55.2",date:"2026-11-16",items:["Teamtrail Cloud: the agents menu says which model your agents are working on"]},{version:"0.55.1",date:"2026-11-16",items:["Teamtrail Cloud: Get started ticks off your trail and your agents as soon as you start them"]},{version:"0.55.0",date:"2026-11-16",items:["A finished trail looks finished: the stretches you walked turn solid green, and a flag stands where the X was","Destination reached, once per trail, with a way to the pull requests still waiting to be merged","Done but not verified stays honest: a grey flag, and how many tickets were closed without a verified proof"]},{version:"0.54.0",date:"2026-11-16",items:["When discovery ends, the Lookout tells you research is done and opens the brief for your review","A brief waiting for your review counts in Waiting on you","Tickets held until you accept the brief show as waiting on it, on the map and in Up next, not as ready"]},{version:"0.53.1",date:"2026-11-16",items:["A quieter header: tracker and CI show only when they fail, spend once there is any, and Plan only / Plan + execute moves into the trail menu"]},{version:"0.53.0",date:"2026-11-16",items:["Your trail's agents are one header menu: what they're doing, with Pause and Runs inside","Legend sits next to Summary under the map, no longer behind it"]},{version:"0.52.2",date:"2026-11-16",items:["Teamtrail Cloud: Scout and Get started show in the corner of the Lookout again"]},{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"]},...qI,...QI,...JI];function eM(){return s.jsxs("div",{className:"changelog",children:[s.jsxs("div",{className:"about",children:[s.jsx(Ua,{className:"about-name"}),s.jsx("span",{className:"mono-label",children:J.category}),s.jsx("p",{className:"onb-tagline",children:J.tagline}),s.jsx(B,{parts:[J.assistant.name]})]}),s.jsx(Ee,{title:"Next",children:XI.map(e=>s.jsxs("div",{className:"cl-row",children:[s.jsx("span",{className:"mono-label",children:e.area}),s.jsx("ul",{children:e.items.map(t=>s.jsx("li",{children:t},t))})]},e.area))}),ZI.map(e=>s.jsx(Ee,{title:`${e.version} · ${e.date}`,children:s.jsx("ul",{children:e.items.map(t=>s.jsx("li",{children:t},t))})},e.version))]})}const ag={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"},cg={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 Ay(e){return e.kind==="state"?tM(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 tM(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 nM="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 sM(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 iM=["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 rM(e){const{queue:t}=e;return s.jsx(he,{as:"li",className:"ap-row",edge:"attention",title:`${t.writes} tracker writes queued before the upgrade`,context:s.jsx(B,{parts:[`For ${t.targets.join(", ")}`]}),below:s.jsxs("div",{className:"ap-below",children:[s.jsx("pre",{className:"ap-lines t-code",children:t.labels.join(`
|
|
158
|
+
`)}),s.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&&s.jsxs("div",{className:"ap-actions",children:[s.jsx(I,{size:"sm",disabled:e.busy,onClick:()=>e.onDecide(!0),children:"Send them"}),s.jsx(I,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onDecide(!1),children:"Discard"})]})]})})}function oM(e){return s.jsxs("div",{className:"ap-below",children:[s.jsxs("p",{className:"t-meta",children:["Delete ",e.files.join(", "),"? Nobody signed them on this machine; git still has them."]}),s.jsxs("div",{className:"ap-actions",children:[s.jsxs(I,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onDelete,children:["Delete ",e.files.length===1?"it":`all ${e.files.length}`]}),s.jsx(I,{size:"sm",disabled:e.busy,onClick:e.onCancel,children:"Keep"})]})]})}const aM=e=>e.files??(e.file?[e.file]:[]);function cM(e){const{item:t}=e,[n,i]=y.useState(!1),a=aM(t),c=t.revert??"restore";return s.jsx(he,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:s.jsx(B,{parts:[Ay(t)]}),detail:a.join(", ")||void 0,detailText:a.join(", ")||void 0,below:s.jsxs("div",{className:"ap-below",children:[s.jsx("pre",{className:"ap-lines t-code",children:t.lines.join(`
|
|
159
|
+
`)}),e.local&&!n&&s.jsxs("div",{className:"ap-below ap-actions",children:[s.jsx(I,{size:"sm",disabled:e.busy,onClick:e.onAccept,children:"Accept this change"}),c!=="none"&&s.jsx(I,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>c==="delete"?i(!0):e.onRevert(),children:c==="delete"?"Delete…":"Revert"})]}),e.local&&n&&s.jsx(oM,{files:a,busy:e.busy,onDelete:()=>(i(!1),e.onRevert(a)),onCancel:()=>i(!1)})]})})}function lM(e){const{tracker:t}=e;return s.jsx(he,{as:"li",className:"ap-row",edge:"attention",title:`trackers.json now points at ${t.label}`,context:s.jsx(B,{parts:["Nothing is read from or sent there yet"]}),detail:`This machine keeps using ${t.approved}`,below:e.local&&s.jsxs("div",{className:"ap-below ap-actions",children:[s.jsxs(I,{size:"sm",disabled:e.busy,onClick:()=>e.onDecide(!0),children:["Use ",t.label]}),s.jsxs(I,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onDecide(!1),children:["Keep ",t.approved]})]})})}function dM(e){const t=new URL(location.href);return t.searchParams.set("settings",e),{href:t.toString(),onClick:n=>{n.preventDefault(),history.replaceState(history.state,"",t.toString()),window.dispatchEvent(new PopStateEvent("popstate"))}}}function uM(e){const{item:t}=e,n=t.committed===!1,i=t.kind==="catalogs"?[...t.lines,""]:[],a=n?[...i,...t.content.split(`
|
|
160
|
+
`)]:t.lines;return s.jsx(he,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:s.jsx(B,{parts:[Ay(t)]}),detail:ag[t.kind],detailText:ag[t.kind],below:s.jsxs("div",{className:"ap-below",children:[s.jsx("pre",{className:"ap-lines t-code",children:a.join(`
|
|
161
|
+
`)}),cg[t.kind]&&s.jsx("p",{className:"ap-note t-meta",children:cg[t.kind]}),t.warnings.length>0&&s.jsx("ul",{className:"ap-warnings t-meta",children:t.warnings.map(c=>s.jsxs("li",{children:["Worth a look: ",c]},c))}),s.jsx(Va,{findings:t.screening??[],named:!0,action:e.local&&s.jsx("a",{...dM("verification"),children:"Edit checks"})}),e.local&&s.jsx(I,{size:"sm",disabled:e.busy,onClick:e.onApprove,children:"Approve"})]})})}async function lg(e,t){const n=await fetch(`${ie()}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i=await n.json().catch(()=>({}));if(!n.ok)throw new Error(i.error??`Request failed (${n.status})`);return i}const gd=async e=>e.ok?await e.json():void 0;async function dg(){var m;const[e,t,n]=await Promise.all(["/trust","/trackers","/trackers/legacy-outbox"].map(g=>fetch(`${ie()}${g}`))),i=await gd(e);if(!i)return null;const{items:a}=i,c=(m=await gd(t))==null?void 0:m.pending,d=await gd(n),u=i.firstRun===!0,f=i.stateFirstRun===!0;return{items:a,firstRun:u,stateFirstRun:f,...c?{tracker:c}:{},...d!=null&&d.writes?{oldQueue:d}:{}}}const hM=(e,t)=>{var n,i,a,c;return JSON.stringify([e.items.map(d=>d.hash),(n=e.tracker)==null?void 0:n.target,(i=e.oldQueue)==null?void 0:i.writes])===JSON.stringify([t.items.map(d=>d.hash),(a=t.tracker)==null?void 0:a.target,(c=t.oldQueue)==null?void 0:c.writes])};function fM(e){var n,i;const t=[(n=e.changed)!=null&&n.length?`${e.changed.length} changed while you looked, so they wait; look again`:"",(i=e.refused)!=null&&i.length?`${e.refused.length} not committed, so they need their own look`:""].filter(Boolean);return t.length?`${t.join(". ")}.`:void 0}function mM(){const[e,t]=y.useState(),[n,i]=y.useState(!1),a=y.useRef();y.useEffect(()=>void(a.current=e),[e]);const c=y.useRef(0),[d]=y.useState(gi),u=y.useRef(0),f=y.useCallback(()=>{u.current++;const b=d.start(),S=x=>{b()&&(a.current=x,t(x),i(!1))};return dg().then(S,()=>S(null))},[d]),m=y.useCallback(async()=>{if(c.current)return;const b=u.current,S=await dg().catch(()=>null),x=a.current;u.current!==b||x===void 0||(!S||!x||!hM(S,x))&&i(!0)},[]);y.useEffect(()=>void f(),[f]),y.useEffect(()=>Ba(b=>void(b.startsWith(".")||m())),[m]),y.useEffect(()=>os(()=>void m()),[m]);const g=y.useCallback(async b=>{c.current++;try{const S=await b();return await f(),S}finally{c.current--}},[f]),k=y.useCallback(async b=>fM(await g(()=>lg("/trust/approve",{items:b.map(S=>({key:S.key,hash:S.hash}))}))),[g]),w=y.useCallback(async(b,S)=>{await g(()=>lg(b,S))},[g]);return{view:e,changed:n,load:f,approve:k,act:w}}function pM(){const{view:e,changed:t,load:n,approve:i,act:a}=mM(),c=xi()!==!1,[d,u]=y.useState(!1),[f,m]=y.useState();if(!e)return null;const g=N=>{u(!0),m(void 0),N.then(P=>(u(!1),m(P??void 0)),P=>(u(!1),m(P.message)))},{items:k,tracker:w,oldQueue:b}=e,S=N=>!N.alone&&(N.kind==="state"?e.stateFirstRun&&N.standing==="elsewhere":e.firstRun),x=k.filter(N=>N.committed!==!1&&S(N)),C=k.length+(w?1:0)+(b?1:0);return s.jsxs(Ee,{title:"Approvals",children:[s.jsxs("p",{className:"vf-intro",children:["Some files in the repo tell ",J.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 ",J.name," shows here as changed outside ",J.name,", and counts only once you accept it."]}),t&&s.jsxs("div",{className:"sync-line alert ap-changed",role:"status",children:[s.jsx("span",{className:"dot"}),s.jsx("span",{children:"Files changed while you were here. What's below is what you saw."}),s.jsx(I,{size:"sm",onClick:n,children:"Review again"})]}),C===0&&s.jsx("p",{className:"ap-none t-meta",children:"Nothing waiting. Everything the repo asks for is approved here."}),x.length>1&&s.jsx("p",{className:"ap-adopt",children:sM(x.length)}),k.some(N=>N.kind==="state")&&s.jsx("p",{className:"ap-note t-meta",children:nM}),C>0&&s.jsxs("ul",{className:"ap-list",children:[w&&s.jsx(lM,{tracker:w,busy:d,local:c,onDecide:N=>g(a("/trackers/approval",{use:N,target:w.target}))}),b&&s.jsx(rM,{queue:b,busy:d,local:c,onDecide:N=>g(a("/trackers/legacy-outbox",{action:N?"send":"discard",writes:b.writes}))}),k.map(N=>N.kind==="state"?s.jsx(cM,{item:N,busy:d,local:c,onAccept:()=>g(i([N])),onRevert:P=>g(a("/trust/revert",{key:N.key,hash:N.hash,remove:P}))},N.key):s.jsx(uM,{item:N,busy:d,local:c,onApprove:()=>g(i([N]))},N.key))]}),c&&x.length>1&&s.jsxs(I,{disabled:d||t,onClick:()=>g(i(x)),children:["Approve all ",x.length," committed"]}),!c&&C>0&&s.jsxs("p",{className:"t-meta",children:["Approve these on the machine ",J.name," runs on."]}),f&&s.jsx("span",{className:"vf-err",children:f}),s.jsx(B,{className:"set-hint",parts:iM})]})}const Ry="0.61.2",Qd="<endpoint>",zu=Qg(Ry,["mcp","--http"]);function gM(e,t){const n=Qg(Ry,["connect",e,"--url"]),i=t===Qd?t:qg(t);return`read -rs ${J.tokenEnv} && export ${J.tokenEnv}
|
|
162
|
+
${n} ${i}`}function vM(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 kM({endpoints:e}){const t=e.some(n=>n.kind==="standalone");return s.jsxs("ul",{className:"ra-endpoints",children:[e.map(n=>s.jsx("li",{children:s.jsx(B,{className:"set-hint",parts:[{text:n.url,code:!0},...vM(n)]})},n.url)),!t&&s.jsx("li",{children:s.jsx(B,{className:"set-hint",parts:["For agents on other machines, start their server",{text:zu,code:!0}]})})]})}function yM(e){const[t,n]=y.useState(""),[i,a]=y.useState(!1),[c,d]=y.useState(),u=async f=>{if(!f.trim()||i)return;a(!0);const m=await e.onCreate(f).catch(g=>g.message);a(!1),d(m),m||n("")};return s.jsxs("div",{className:"ra-new",children:[s.jsx(za,{value:t,onValueChange:n,onSubmit:u,action:"Create token",actionDisabled:i||!t.trim(),placeholder:"Name the agent, e.g. cloud sandbox 1","aria-label":"Agent name",maxLength:60}),c&&s.jsx("span",{className:"vf-err",children:c})]})}function wM(){return s.jsx(Ee,{title:"Remote agents",children:s.jsxs("p",{className:"vf-intro",children:["Tokens for remote agents are created and revoked on the machine ",J.name," runs on. Open the Lookout there to manage them."]})})}function xM(e){const[t,n]=y.useState(!1),[i,a]=y.useState(!1),[c,d]=y.useState(),u=async()=>{a(!0),d(await e.onRevoke().catch(f=>f.message)),a(!1),n(!1)};return t?s.jsxs("span",{className:"ra-revoke ask",children:[s.jsx("span",{className:"t-meta",children:"Its sessions end now."}),s.jsxs(I,{size:"sm",disabled:i,onClick:u,children:["Revoke ",e.name]}),s.jsx(I,{size:"sm",variant:"ghost",onClick:()=>n(!1),children:"Keep"})]}):s.jsxs("span",{className:"ra-revoke",children:[s.jsx(I,{size:"sm","aria-label":`Revoke ${e.name}`,onClick:()=>n(!0),children:"Revoke"}),c&&s.jsx("span",{className:"vf-err",children:c})]})}function jM(e){if(!e.tokens.length)return null;const t=Date.now();return s.jsx("ul",{className:"ra-list",children:e.tokens.map(n=>s.jsx(he,{as:"li",className:"ra-row",title:n.name,titleText:n.name,context:s.jsx(B,{parts:[`Created ${ss(n.createdAt,t)}`,n.lastUsedAt?`Last used ${ss(n.lastUsedAt,t)}`:"Never used"]}),below:s.jsx(xM,{name:n.name,onRevoke:()=>e.onRevoke(n.id)})},n.id))})}function vd(e){const[t,n]=y.useState(!1),i=()=>{var a;return void((a=navigator.clipboard)==null?void 0:a.writeText(e.value).then(()=>{n(!0),setTimeout(()=>n(!1),1500)},()=>n(!1)))};return s.jsxs("div",{className:"ra-copy",children:[s.jsx("code",{className:"ra-copy-value t-code","aria-label":e.label,children:e.value}),s.jsx(I,{size:"sm",className:"ra-copy-btn",onClick:i,children:t?"Copied":e.copyLabel??"Copy"})]})}const bM=[{id:"claude",label:"Claude Code"},{id:"codex",label:"Codex"}];function SM(e){const[t,n]=y.useState("claude");return s.jsxs("div",{className:"ra-reveal",role:"status",children:[s.jsxs("p",{className:"ra-reveal-title t-row-title",children:["Token for ",e.created.name]}),s.jsxs("p",{className:"t-body ra-note",children:["Copy it now. ",J.name," keeps only a fingerprint, so it can't show it again."]}),s.jsx(vd,{label:"Token",value:e.created.token,copyLabel:"Copy token"}),!e.endpoint&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"ra-reveal-head",children:s.jsx(Ke,{children:"Start the server for remote agents"})}),s.jsx(vd,{label:"Start command",value:zu,copyLabel:"Copy command"})]}),s.jsxs("div",{className:"ra-reveal-head",children:[s.jsx(Ke,{children:"Run on the agent's machine"}),s.jsx("span",{className:"ra-clients",children:bM.map(i=>s.jsx(I,{size:"sm",on:t===i.id,"aria-pressed":t===i.id,onClick:()=>n(i.id),children:i.label},i.id))})]}),s.jsx(vd,{label:"Connect command",value:gM(t,e.endpoint??Qd),copyLabel:"Copy command"}),s.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 ${Qd}.`,t==="codex"&&` Start Codex from the same shell: it reads $${J.tokenEnv} each time.`]}),s.jsx("span",{children:s.jsx(I,{variant:"primary",size:"sm",onClick:e.onDone,children:"I've copied it"})})]})}const Iy=`${ie()}/remote-agents`;async function ug(e,t){const n=await fetch(`${Iy}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:n.ok,reply:await n.json()}}async function NM(){const e=await fetch(Iy);return e.ok?await e.json():(await e.json().catch(()=>({}))).elsewhere?"elsewhere":null}function $M(){const[e,t]=y.useState(),[n,i]=y.useState(),{pushed:a}=Le({load:NM,show:t,failed:()=>t(null),events:{"remote-agents":()=>!0}}),c=y.useCallback(f=>{a(),t({tokens:f.tokens,endpoints:f.endpoints})},[a]),d=y.useCallback(async f=>{const{ok:m,reply:g}=await ug("/tokens",{name:f});if(!m||!g.token||!g.created)return g.error??"The token could not be created.";c(g),i({token:g.token,name:g.created.name})},[c]),u=y.useCallback(async f=>{const{ok:m,reply:g}=await ug("/tokens/revoke",{id:f});return g.tokens&&c(g),m?void 0:g.error??"The token could not be revoked."},[c]);return{view:e,created:n,dismissCreated:()=>i(void 0),create:d,revoke:u}}function CM(){var d;const{view:e,created:t,dismissCreated:n,create:i,revoke:a}=$M();if(!e)return null;if(e==="elsewhere")return s.jsx(wM,{});const c=(d=e.endpoints.find(u=>u.kind==="standalone"))==null?void 0:d.url;return s.jsxs(Ee,{title:"Remote agents",children:[s.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."}),s.jsx(kM,{endpoints:e.endpoints}),t&&s.jsx(SM,{created:t,endpoint:c,onDone:n}),s.jsx(jM,{tokens:e.tokens,onRevoke:a}),e.tokens.length===0&&s.jsx("p",{className:"t-meta ra-note",children:"No tokens, so the endpoint is closed: every request is refused."}),s.jsx(yM,{onCreate:i}),s.jsxs("div",{className:"ra-notes",children:[s.jsxs("p",{className:"t-meta ra-note",children:[s.jsx("b",{children:"Before you open it to other machines."})," The connection is plain HTTP. Run ",s.jsx("code",{children:zu}),", 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."]}),s.jsxs("p",{className:"t-meta ra-note",children:[s.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."]}),s.jsxs("p",{className:"t-meta ra-note",children:[s.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."]}),s.jsxs("p",{className:"t-meta ra-note",children:[s.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 hg={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"},TM={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},EM=e=>e[0].toUpperCase()+e.slice(1),Yd=jv.map(e=>({value:e,label:EM(e),hint:TM[e]}));function AM(e){const[t,n]=y.useState(""),[i,a]=y.useState("high"),{rules:c,onChange:d}=e,u=()=>{const f=t.trim();!f||c.some(m=>m.glob===f)||(d([...c,{glob:f,level:i}]),n(""))};return s.jsxs("div",{className:"risk-paths",children:[s.jsx("span",{className:"mono-label",children:"Files"}),c.map((f,m)=>s.jsxs("div",{className:"risk-row",children:[s.jsx("code",{children:f.glob}),s.jsx(rt,{compact:!0,"aria-label":`${f.glob} risk`,value:f.level,options:Yd,onChange:g=>d(c.map((k,w)=>w===m?{...k,level:g}:k))}),s.jsx("button",{className:"icon-btn","aria-label":`Remove ${f.glob}`,onClick:()=>d(c.filter((g,k)=>k!==m)),children:"×"})]},f.glob)),s.jsxs("div",{className:"risk-row",children:[s.jsx("input",{value:t,placeholder:"src/payments/**","aria-label":"New file pattern",onChange:f=>n(f.target.value),onKeyDown:f=>f.key==="Enter"&&u()}),s.jsx(rt,{compact:!0,"aria-label":"New pattern risk",value:i,options:Yd,onChange:a}),s.jsx(I,{onClick:u,disabled:!t.trim(),children:"Add"})]})]})}const My=`${ie()}/policy`;async function RM(){const e=await fetch(My);return e.ok?await e.json():null}function IM(){const[e,t]=y.useState(),{pushed:n}=Le({load:RM,show:t,failed:()=>t(null),changed:a=>a.endsWith("policy.json")}),i=y.useCallback(async a=>{const c=await fetch(My,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),d=await c.json();if(!c.ok)return d.error??`Saving failed (${c.status})`;n(),t(d)},[n]);return{view:e,save:i}}function MM(){const{view:e,save:t}=IM(),[n,i]=y.useState();if(!e)return null;const a=`${J.dataDir}/policy.json`,c=d=>{i(void 0),t(d).then(i,u=>i(u.message))};return s.jsxs(Ee,{title:"Risk policy",children:[s.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."}),s.jsx("div",{className:"risk-grid",children:xv.map(d=>s.jsxs("label",{className:"risk-row",children:[s.jsx("span",{children:hg[d]}),s.jsx(rt,{compact:!0,"aria-label":`${hg[d]} risk`,value:e.policy.categories[d],options:Yd,onChange:u=>c({...e.policy,categories:{...e.policy.categories,[d]:u}})})]},d))}),s.jsx(AM,{rules:e.policy.paths,onChange:d=>c({...e.policy,paths:d})}),e.errors.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"sync-line alert",children:[s.jsx("span",{className:"dot"}),s.jsxs("span",{children:[a," has errors, so the defaults apply until it is fixed."]})]}),s.jsx("ul",{className:"vf-errors",children:e.errors.map(d=>s.jsx("li",{children:d},d))})]}),e.defaults&&e.errors.length===0&&s.jsxs("span",{className:"set-hint t-meta",children:["Defaults. Changing anything saves ",a,", so your team shares it."]}),n&&s.jsx("span",{className:"vf-err",children:n})]})}function OM(){const{view:e,save:t,remove:n}=ry(),[i,a]=y.useState();if(!e)return null;const c=e.settings.worktrees,d=()=>{a(void 0),t({...e.settings,worktrees:!c}).then(a,u=>a(u.message))};return s.jsxs(Ee,{title:"Workspaces",children:[s.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; ",J.name," never merges or pushes."]}),s.jsxs("div",{className:"att-settings-row set-field",children:[s.jsx("span",{className:"set-field-label",children:"A worktree per ticket"}),s.jsx(I,{size:"sm",on:c,"aria-pressed":c,className:"worktrees-toggle",onClick:d,children:c?"On":"Off"})]}),s.jsx(B,{className:"set-hint",parts:[{text:`${J.dataDir}/workspaces.json`,code:!0},fg(e.workspaces.filter(u=>u.active).length,"active"),fg(e.workspaces.filter(u=>!u.active).length,"finished")]}),s.jsx(lA,{rows:e.workspaces,onRemove:n}),e.errors.length>0&&s.jsx("ul",{className:"vf-errors",children:e.errors.map(u=>s.jsx("li",{children:u},u))}),i&&s.jsx("span",{className:"vf-err",children:i})]})}const fg=(e,t)=>`${e} ${t}`;function LM({data:e,route:t}){var n;return s.jsxs(s.Fragment,{children:[s.jsx(We,{id:"approvals",storage:"machine",children:s.jsx(pM,{})}),s.jsx(We,{id:"tracker",children:s.jsx(Ee,{title:"Tracker",children:(n=pt())!=null&&n.tracker?s.jsx("p",{className:"vf-intro",children:"Trails are kept by the server this Lookout runs on, in its own storage."}):s.jsx(TI,{activeTracker:e.activeTracker,location:e.location,update:e.update})})}),s.jsx(We,{id:"workspaces",storage:"repo",children:s.jsx(OM,{})}),s.jsx(We,{id:"proof",storage:"machine",children:s.jsx(x2,{})}),s.jsx(We,{id:"remote-agents",storage:"machine",children:s.jsx(CM,{})}),s.jsx(We,{id:"policy",storage:"repo",children:s.jsx(MM,{})}),s.jsx(We,{id:"guides",storage:"repo",children:s.jsx(hE,{focus:t.section==="guides"})}),s.jsx(We,{id:"labels",children:s.jsx(Ee,{title:"Labels",children:s.jsxs("div",{className:"label-codes",children:[s.jsx("code",{children:iu}),s.jsxs("code",{children:[J.labelPrefix,":<type>"]}),s.jsx("code",{children:ru}),s.jsx("code",{children:ou})]})})})]})}const Jd=`${J.apiPrefix}/projects`;async function ur(e,t,n){const i=await fetch(`${Jd}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:n===void 0?void 0:JSON.stringify(n)}),a=await i.json().catch(()=>({}));if(!i.ok)throw new Error(a.error??`HTTP ${i.status}`);return a}const Ss={url:Jd,add:e=>ur("","POST",{path:e}),remove:e=>ur(`/${e}`,"DELETE"),setAutoRegister:e=>ur("/settings","PUT",{autoRegister:e}),setShare:(e,t)=>ur(`/${e}/share`,"PUT",{share:t}),answer:(e,t)=>ur(`/${e}/answer`,"POST",t),async briefing(e){const t=await fetch(`${Jd}/briefing?since=${e}`);return t.ok?await t.json():void 0}};function Oy(e){const[t,n]=y.useState(""),[i,a]=y.useState(),c=d=>{d.trim()&&(a(void 0),Ss.add(d.trim()).then(()=>(n(""),e.onAdded()),u=>a(u.message)))};return s.jsxs("div",{className:"pj-add",children:[s.jsx(za,{value:t,onValueChange:n,onSubmit:c,action:"Add project",placeholder:`/path/to/repo (a ${J.dataDir} folder is created if missing)`,"aria-label":"Repo path",className:"t-code"}),i&&s.jsx("span",{className:"vf-err",children:i})]})}const ii=(e,t)=>e>0&&`${e} ${t}`;function PM(e){var n;const t=((n=e.briefing)==null?void 0:n.projects)??[];return!e.briefing||!t.length?null:s.jsxs("section",{className:"pj-section pj-briefing",children:[s.jsx(yt,{title:"While you were away",count:t.length,info:`What changed in each project since ${Xe(e.now-e.briefing.since)} ago`}),s.jsx("ul",{className:"pj-list",children:t.map(({projectId:i,project:a,briefing:c})=>s.jsx(he,{as:"li",edge:c.totals.waiting>0?"attention":"neutral",title:a,context:s.jsx(B,{parts:[ii(c.totals.done,"done"),ii(c.trails.reduce((d,u)=>d+u.opened.length,0),"new tickets"),ii(c.totals.agentDecisions,"agent decisions"),ii(c.totals.waiting,"waiting on you"),ii(c.totals.ruledOut,"ruled out"),ii(c.totals.active,"agents active")]}),onOpen:()=>e.onOpen(i)},i))})]})}function DM(e){const[t,n]=y.useState(""),[i,a]=y.useState(!1),[c,d]=y.useState(),u=f=>{!f.trim()||i||(a(!0),d(void 0),e.onAnswer(f.trim()).then(()=>n(""),m=>d(m.message)).finally(()=>a(!1)))};return s.jsxs("div",{className:"pj-answer",children:[s.jsx(za,{value:t,onValueChange:n,onSubmit:u,action:"Answer",disabled:i,placeholder:"Your answer","aria-label":"Your answer"}),c&&s.jsx("span",{className:"vf-err",children:c})]})}function _M(e){const{item:t}=e,n=Au(t),i=t.kind==="question"&&t.agent?`${t.agent} asks`:Eu[t.kind],a=t.urgency==="blocking"&&{text:"Blocking",urgent:!0,className:"urgency-tag"};return s.jsx(he,{as:"li",className:`att-item pj-item k-${t.kind}`,edge:Tr(t,t.interrupting),title:t.title.split(`
|
|
163
|
+
`)[0],titleText:t.title,context:s.jsx(B,{parts:[a,{text:t.project,strong:!0},i]}),detail:n.length>0&&n.join(" · "),detailText:n.join(`
|
|
164
|
+
`),trailing:Xe(e.now-t.since),onOpen:e.onOpen,below:e.onAnswer&&s.jsx(DM,{onAnswer:e.onAnswer})})}function BM(e){const t=e.view.attention,n=i=>{var a;return((a=e.view.projects.find(c=>c.id===i))==null?void 0:a.state.kind)!=="missing"};return s.jsxs("section",{className:"pj-section pj-attention",children:[s.jsx(yt,{title:"Needs you",count:t.length,hot:t.some(i=>i.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&&s.jsx(An,{title:"Nothing needs you",hint:"Agents in every project can keep going."}),s.jsx("ul",{className:"pj-list",children:t.map(i=>s.jsx(_M,{item:i,now:e.now,onOpen:()=>e.onOpen(i.projectId,i.id),onAnswer:i.kind==="question"&&n(i.projectId)?a=>Ss.answer(i.projectId,{questionId:i.ref,text:a}).then(e.onAnswered):void 0},`${i.projectId}/${i.id}`))})]})}const kd=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function FM(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function zM(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(kd(e.agents,"agent"));const{working:n,verifying:i,rework:a,blocked:c}=e.phases;n&&t.push(`${n} working`),i&&t.push(`${i} verifying`),a&&t.push(`${a} rework`),c&&t.push(`${c} blocked`),e.flags&&t.push(kd(e.flags,"PR flag")),e.stalled&&t.push(kd(e.stalled,"stalled claim")),t.length||t.push(e.trails?"Nothing waiting":"No trails yet");const d=UM(e.tracker);return d&&t.push(d),t}function UM(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 WM(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 va(e,t,n){if(e.state.kind!=="missing"){if(e.state.kind==="elsewhere"){const i=e.state.url?pn(e.state.url):void 0;if(!i)return;const a=new URL(i);n&&a.searchParams.set(Ns,n),window.open(a.toString(),"_blank","noopener");return}location.href=b1({id:e.id,home:t,tracker:e.tracker.kind,item:n})}}function Ly(e){const{p:t}=e,n=WM(t);return s.jsx(he,{as:"li",className:`project-card st-${t.state.kind}`,edge:FM(t),selected:e.current,title:t.name,titleText:t.path,context:s.jsx(B,{parts:zM(t)}),detail:n,detailText:n,trailing:t.lastActivity?Xe(e.now-t.lastActivity):void 0,onOpen:e.onOpen})}const Py=`${xa}:projects:seen`,mg=24*36e5;function HM(e){try{const t=Number(localStorage.getItem(Py));return t>0?t:e-mg}catch{return e-mg}}function KM(e){try{localStorage.setItem(Py,String(e))}catch{}}function GM(){const[e,t]=y.useState();return y.useEffect(()=>{const n=Date.now();return Ss.briefing(HM(n)).then(t).catch(()=>{}),()=>KM(n)},[]),e}function VM(e){const{view:t,reload:n}=e.projects,i=gt(15e3),a=GM();if(y.useEffect(()=>{const f=m=>m.key==="Escape"&&e.onClose();return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[e]),!t)return null;const c=Sr()??t.home,d=f=>{const m=t.projects.find(g=>g.id===f);(m==null?void 0:m.id)===c?e.onClose():m&&va(m,t.home)},u=(f,m)=>{const g=t.projects.find(k=>k.id===f);if(g){if(g.id!==c)return va(g,t.home,m);e.onClose(),e.onItemHere(m)}};return s.jsxs(Fe,{className:`zone decisions-view projects-view dv-${e.bp}`,children:[s.jsxs("header",{className:"dv-head",children:[s.jsx(Ke,{as:"h2",children:"All projects"}),s.jsx("span",{className:"dv-head-right",children:s.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})})]}),s.jsxs("div",{className:"pj-body",children:[s.jsx(BM,{view:t,now:i,onOpen:u,onAnswered:n}),s.jsxs("section",{className:"pj-section pj-projects",children:[s.jsx(yt,{title:"Projects",count:t.projects.length,info:"Each repo registered on this machine, read from its own files. Nothing leaves your machine."}),s.jsx("ul",{className:"pj-list",children:t.projects.map(f=>s.jsx(Ly,{p:f,current:f.id===c,now:i,onOpen:f.state.kind==="missing"?void 0:()=>d(f.id)},f.id))}),s.jsx(Oy,{onAdded:n})]}),s.jsx(PM,{briefing:a,now:i,onOpen:d})]})]})}function qM(e){const[t,n]=y.useState(!1),i=y.useRef(null);y.useEffect(()=>{if(!t)return;const u=f=>{var m;(f instanceof KeyboardEvent?f.key==="Escape":!((m=i.current)!=null&&m.contains(f.target)))&&n(!1)};return window.addEventListener("mousedown",u),window.addEventListener("keydown",u),()=>{window.removeEventListener("mousedown",u),window.removeEventListener("keydown",u)}},[t]);const{view:a}=e.projects;if(!a||!e.projects.many)return s.jsx("span",{className:"repo",children:e.repo});const c=Sr()??a.home,d=a.projects.filter(u=>u.id!==c).reduce((u,f)=>u+f.interrupting,0);return s.jsxs("div",{className:"project-switcher",ref:i,children:[s.jsxs("button",{className:"project-btn repo",onClick:()=>n(u=>!u),"aria-haspopup":"menu","aria-expanded":t,"data-tip":"Switch project, or see all of them",children:[s.jsx("span",{className:"project-name",children:e.repo}),d>0&&s.jsx(js,{n:d,urgent:!0}),s.jsx("span",{className:"caret",children:"▾"})]}),t&&s.jsxs("div",{className:"trail-menu",role:"menu",children:[s.jsxs("button",{role:"menuitem",className:"trail-item all-projects",onClick:()=>{n(!1),e.onOverview()},children:[s.jsx("span",{className:"mi-title",children:"All projects"}),s.jsx(js,{n:a.attention.length,urgent:a.attention.some(u=>u.interrupting),hideZero:!0})]}),s.jsx(Ke,{variant:"plain",className:"menu-h",children:"Projects"}),a.projects.map(u=>s.jsxs("button",{role:"menuitem",className:`trail-item ${u.id===c?"on":""} st-${u.state.kind}`,disabled:u.state.kind==="missing",onClick:()=>{n(!1),u.id!==c&&va(u,a.home)},children:[s.jsx("span",{className:"mi-title",children:u.name}),s.jsx("span",{className:"mi-progress",children:QM(u.state.kind)}),s.jsx(js,{n:u.needsYou,urgent:u.interrupting>0,hideZero:!0})]},u.id))]})]})}function QM(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function YM(e){const t=gt(15e3),{view:n}=e.projects;if(!n||!e.projects.many)return null;const i=Sr()??n.home;return s.jsxs("section",{className:"phone-projects",children:[s.jsx(yt,{title:"Projects",count:n.projects.length,right:s.jsx(I,{size:"sm",variant:"ghost",onClick:e.onOverview,children:"All projects"})}),s.jsx("ul",{className:"pj-list",children:n.projects.filter(a=>a.id!==i).map(a=>s.jsx(Ly,{p:a,current:!1,now:t,onOpen:a.state.kind==="missing"?void 0:()=>va(a,n.home)},a.id))})]})}async function JM(){const e=await fetch(Ss.url);return e.ok?await e.json():void 0}function Dy(){const[e,t]=y.useState(),{reload:n,pushed:i}=Le({load:JM,show:a=>a&&t(a)});return y.useEffect(()=>vi("projects",a=>{i(),t(JSON.parse(a))}),[i]),{view:e,many:((e==null?void 0:e.projects.length)??0)>1,reload:n}}const XM=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function ZM(){const{view:e,reload:t}=Dy(),[n,i]=y.useState();if(!e)return null;const a=c=>{i(void 0),c.then(t,d=>i(d.message))};return s.jsxs(Ee,{title:"Projects",children:[s.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."}),s.jsx("ul",{className:"pj-list set-projects",children:e.projects.map(c=>s.jsx(he,{as:"li",edge:c.state.kind==="missing"?"attention":"neutral",title:c.name,context:s.jsx(B,{parts:XM(c)}),actions:s.jsxs(s.Fragment,{children:[s.jsx(I,{size:"sm",variant:"ghost",on:c.sharePrecedents,"aria-pressed":c.sharePrecedents,className:"share-precedents-toggle",title:"Offer this project's decisions as suggestions when agents look for precedents in your other projects",onClick:()=>a(Ss.setShare(c.id,!c.sharePrecedents)),children:c.sharePrecedents?"Shares decisions":"Share decisions"}),!c.home&&s.jsx(I,{size:"sm",variant:"ghost",onClick:()=>a(Ss.remove(c.id)),children:"Remove"})]})},c.id))}),s.jsx(Oy,{onAdded:t}),s.jsxs("div",{className:"att-settings-row set-field",children:[s.jsx("span",{className:"set-field-label",children:"Agents add their repo when they connect"}),s.jsx(I,{size:"sm",on:e.autoRegister,"aria-pressed":e.autoRegister,className:"auto-register-toggle",onClick:()=>a(Ss.setAutoRegister(!e.autoRegister)),children:e.autoRegister?"On":"Off"})]}),s.jsx(B,{className:"set-hint",parts:[{text:`${J.slug} projects add <path>`,code:!0},`--no-register or ${J.noRegisterEnv} opts one agent out`]}),n&&s.jsx("span",{className:"vf-err",children:n})]})}function eO(e){return e.local===!1?{kind:"locked",reason:"Set on the machine Teamtrail runs on."}:e.exists?e.valid?e.waiting?{kind:"locked",reason:"Approve the checks first."}:e.local===void 0?{kind:"locked"}:{kind:"open"}:{kind:"locked",reason:"Fix verification.json first."}:{kind:"locked",reason:"Set the checks first: without them nothing is verified."}}const pg=e=>`${e} ticket${e===1?"":"s"}`;function tO(e,t){const n=`in the last ${t} days`,i=e.held?`Held ${pg(e.held)}`:"",a=e.wouldHold?`would have held ${pg(e.wouldHold)}`:"";return i&&a?`${i}, ${a} ${n}`:i?`${i} ${n}`:a?`W${a.slice(1)} ${n}`:`Nothing held ${n}`}const nO={enforce:"Held",observe:"Would have held"};function sO(e){if(!e.entries.length)return null;const t=Date.now();return s.jsx(rn,{label:`Tickets (${e.entries.length})`,children:s.jsx("ul",{className:"gate-entries",children:e.entries.map((n,i)=>{const a=n.ticketId;return s.jsx(he,{as:"li",className:"gate-entry",edge:n.mode==="enforce"?"attention":"neutral",title:n.reason,titleText:n.reason,context:s.jsx(B,{parts:[n.ticketKey&&{text:n.ticketKey,code:!0},nO[n.mode]]}),trailing:ss(n.at,t),onOpen:a?()=>e.onOpenTicket(n.mapId,a):void 0},`${n.at}-${i}`)})})})}const _y={"check-guard":{title:"Check guard",about:"A pass counts only if the work left what the checks run, and its tests, alone."},"independent-review":{title:"Independent review",about:"A review by an agent on the same model as the author doesn’t count as independent."},"diff-rules":{title:"Diff rules",about:"A change to files a rule covers waits until the rule’s check runs or its question is answered."},flaky:{title:"Flaky checks",about:"A check that failed, then passed on the same commit, needs you before the pass counts."}},jr=e=>fv.includes(e);function iO(e){return jr(e)?_y[e].title:e}function rO(e){return jr(e)?_y[e].about:void 0}const gg={off:{label:"Off",tip:"Does nothing"},observe:{label:"Observe",tip:"Notes what it would hold and lets the work through"},enforce:{label:"Enforce",tip:"Holds the work for you, with a way past it"}};function oO(e){return s.jsx("div",{className:"gate-modes",role:"radiogroup","aria-label":`${e.label} mode`,"data-gate":e.gate,children:z0.map(t=>s.jsx("button",{type:"button",role:"radio","aria-checked":e.value===t,className:pe("gate-mode",e.value===t&&"on"),title:gg[t].tip,disabled:e.disabled,onClick:()=>e.value!==t&&e.onChange(t),children:gg[t].label},t))})}function aO(e){const{summary:t}=e,n=iO(t.gate),i=jr(t.gate);return s.jsx(he,{as:"li",className:"gate-row",edge:t.held?"attention":"neutral",title:i?n:s.jsx("span",{className:"t-code",children:n}),context:s.jsx(B,{parts:[rO(t.gate)]}),detail:e.days?tO(t,e.days):void 0,below:s.jsxs(s.Fragment,{children:[i&&s.jsx(oO,{gate:t.gate,label:n,value:e.mode,disabled:e.locked,onChange:e.onMode}),s.jsx(sO,{entries:t.entries,onOpenTicket:e.onOpenTicket})]})})}function vg(e){return new Set(e.map((t,n)=>t.ticketId?`${t.mapId}/${t.ticketId}`:`#${n}`)).size}function cO(e){const t=[...e].sort((i,a)=>a.at-i.at),n=[...fv];for(const i of t)n.includes(i.gate)||n.push(i.gate);return n.map(i=>{const a=t.filter(c=>c.gate===i);return{gate:i,held:vg(a.filter(c=>c.mode==="enforce")),wouldHold:vg(a.filter(c=>c.mode==="observe")),entries:a}})}async function lO(){const e=await fetch(`${ie()}/verification/gates`);return e.ok?await e.json():null}function dO(){const[e,t]=y.useState();return Le({load:lO,show:t,failed:()=>t(null),changed:n=>n.endsWith("verification.json"),events:{verification:()=>!0,attention:()=>!0}}),e}async function uO(e){const t=await fetch(`${ie()}/verification/gates`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{});if(t!=null&&t.ok)return;const n=await(t==null?void 0:t.json().catch(()=>({})));return(n==null?void 0:n.error)??"The server didn't answer."}function hO(e){var b,S;const t=Mu(),n=dO(),i=xi(),[a,c]=y.useState(),[d,u]=y.useState();if(!t)return null;const f=((b=t.approval)==null?void 0:b.base)??"none",m=eO({local:i,exists:t.exists,valid:!!t.config,waiting:(S=t.approval)==null?void 0:S.waiting}),g=(a==null?void 0:a.base)===f?a:void 0,k=x=>jr(x)?(g==null?void 0:g.gate)===x?g.mode:U0(t.exists?t.config:void 0,x):"off",w=async(x,C)=>{if(!jr(x))return;const N={gate:x,mode:C,base:f};u(void 0),c(N);const P=await uO(N);P&&(c(void 0),u(P))};return s.jsxs(Ee,{title:"Gates",children:[s.jsx("p",{className:"vf-intro",children:"Gates catch work that passed its checks but shouldn't count yet. Observe a gate first to see what it would hold, then enforce it: held work waits for you, with a way past it."}),s.jsx("ul",{className:"gate-list",children:cO((n==null?void 0:n.entries)??[]).map(x=>s.jsx(aO,{summary:x,days:n==null?void 0:n.days,mode:k(x.gate),locked:m.kind==="locked",onMode:C=>void w(x.gate,C),onOpenTicket:e.onOpenTicket},x.gate))}),m.kind==="locked"&&m.reason&&s.jsx("span",{className:"set-hint t-meta",children:m.reason}),n===null&&s.jsx("span",{className:"set-hint t-meta",children:"What the gates did couldn't be loaded."}),d&&s.jsx("span",{className:"vf-err",children:d})]})}function fO({view:e}){if(!e)return null;const t=`${J.dataDir}/${e.file}`,n=Object.keys(e.models).length,i=e.agents.map(a=>`${a.agent} ${a.tier}`).join(", ");return s.jsxs(s.Fragment,{children:[s.jsx(B,{className:"set-hint",parts:[{text:t,code:!0},e.exists?`${n} of your own models`:"add new or custom models here","unknown models count as balanced"]}),i&&s.jsx(B,{className:"set-hint models-connected",parts:[`Connected now: ${i}`]}),e.errors.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"sync-line alert",children:[s.jsx("span",{className:"dot"}),s.jsxs("span",{children:[t," has errors, so only the built-in models count until it is fixed."]})]}),s.jsx("ul",{className:"vf-errors",children:e.errors.map(a=>s.jsx("li",{children:a},a))})]})]})}const kr={fast:"Fast",balanced:"Balanced",strongest:"Strongest"},mO={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},pO=sa.map(e=>({value:e,label:kr[e],hint:mO[e]}));function gO(e){return s.jsx("div",{className:"tier-grid",children:is.map(t=>{const n=e.tiers[t],i=cu[t];return s.jsxs("div",{className:"tier-row",children:[s.jsx("span",{children:En[t]}),s.jsx(rt,{compact:!0,"aria-label":`${En[t]} tickets' model`,className:`tier-select tier-${t}`,value:n,options:pO,onChange:a=>e.onChange(t,a)}),s.jsx(B,{className:"tier-hint",parts:[n!==i&&`default ${kr[i].toLowerCase()}`,e.hints[t]]})]},t)})})}async function vO(){const e=await fetch(`${ie()}/flaky-checks`);return e.ok?await e.json():null}function kO(){const[e,t]=y.useState();return Le({load:vO,show:t,failed:()=>t(null),events:{verification:()=>!0},changed:n=>n.includes("/tickets/")}),e}const yO={enforce:"A pass on retry waits for you.",observe:"A pass on retry goes through, flagged.",off:"The flaky gate is off: passes on retry count."};function wO(){const e=kO();if(!e)return null;const t=Date.now();return s.jsxs("section",{className:"perf-section flaky-checks",children:[s.jsx(Ke,{as:"h3",children:"Flaky checks"}),s.jsxs("p",{className:"perf-note t-meta",children:["Checks that failed, then passed on the same code with no change. ",yO[e.mode]]}),e.rows.length?s.jsx("ul",{className:"perf-rows",children:e.rows.map(n=>s.jsx(he,{as:"li",className:"perf-row",title:n.test?`${n.name} · ${n.test}`:n.name,trailing:s.jsx("span",{children:n.count===1?"once":`${n.count} times`}),context:s.jsx(B,{parts:[n.tickets.join(", "),`last seen ${Xe(t-n.lastSeen)} ago`]})},`${n.name}
|
|
165
|
+
${n.test??""}`))}):s.jsx(Te,{children:"No flaky checks seen."})]})}const Yo=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function xO({rows:e}){return e.length?s.jsx("ul",{className:"perf-rows",children:e.map(t=>s.jsx(he,{as:"li",className:"perf-row",title:t.key,trailing:s.jsx("span",{title:"Median time from first claim to done",children:tn(t.medianLeadMs)}),context:s.jsx(B,{parts:[`${t.done} of ${Yo(t.tickets,"ticket")} done`,t.cancelled>0&&`${t.cancelled} cancelled`,Yo(t.reworkCycles,"rework"),`reviews ${t.reviews.passed} passed, ${t.reviews.failed} failed`,t.answers>0&&Yo(t.answers,"question")]}),detail:t.findings.raised>0?`As reviewer: ${t.findings.upheld} of ${Yo(t.findings.raised,"finding")} upheld`:void 0},t.key))}):s.jsx(Te,{children:"No claimed tickets yet"})}const jO=e=>`${Math.round(e*100)}%`;function bO({r:e,minSample:t}){return s.jsx(he,{as:"li",className:"perf-row score-row",title:e.key,trailing:e.enough?s.jsxs("span",{title:"Verified work it passed that was reopened or reverted",children:[jO(e.escapeRate)," came back"]}):s.jsx("span",{className:"t-meta",title:`Compared from ${t} verified tickets`,children:"too few"}),context:s.jsx(B,{parts:[`passed ${e.verified} verified`,`${e.escaped} came back`]})})}function SO({e}){return s.jsx(he,{as:"li",className:"perf-row score-row",title:`${e.ticketKey} ${e.kind}`,trailing:s.jsx("span",{className:"t-meta",children:new Date(e.at).toLocaleDateString()}),context:s.jsx(B,{parts:[e.agent,e.checks.length?`passed ${e.checks.join(", ")}`:"no check ran"]}),detail:e.evidence})}function NO(e){return e.escapes.length?s.jsxs("ul",{className:"perf-rows",children:[e.checks.map(t=>s.jsx(bO,{r:t,minSample:e.minSample},t.key)),e.escapes.map(t=>s.jsx(SO,{e:t},`${t.mapId}/${t.ticketId}/${t.attemptId}`))]}):s.jsx(Te,{children:"Nothing verified has come back: no reopens, no reverts on main."})}const kg=e=>`${Math.round(e*100)}%`,$O=e=>e===void 0?void 0:`$${e.toFixed(2)} per verified`;function CO({r:e,minSample:t}){return s.jsx(he,{as:"li",className:"perf-row score-row",title:e.key,trailing:e.enough?s.jsxs("span",{title:"Verified on the first attempt",children:[kg(e.firstTimeRate)," first time"]}):s.jsx("span",{className:"t-meta",title:`Compared from ${t} tickets`,children:"too few"}),context:s.jsx(B,{parts:[`${e.verified} of ${e.tickets} verified`,`${kg(e.reworkRate)} rework`,e.attemptsPerVerified!==void 0&&`${e.attemptsPerVerified} attempts each`,$O(e.costPerVerifiedUsd),e.medianLeadMs!==void 0&&tn(e.medianLeadMs),!!e.escaped&&`${e.escaped} came back`]}),detail:e.findings.error+e.findings.warn>0?`Review findings: ${e.findings.error} errors, ${e.findings.warn} warnings`:void 0})}function TO({rows:e,minSample:t}){return e.length?s.jsx("ul",{className:"perf-rows",children:e.map(n=>s.jsx(CO,{r:n,minSample:t},n.key))}):s.jsx(Te,{children:"No completions yet. The scorecard fills in as agents finish verified tickets."})}async function EO(){const e=await fetch(`${ie()}/scorecard`);return e.ok?await e.json():null}function By(){const[e,t]=y.useState();return Le({load:EO,show:t,failed:()=>t(null),events:{verification:()=>!0},changed:n=>n.includes("/tickets/")}),e}const AO=[{id:"byTypeAndModel",title:"Type × model"},{id:"byType",title:"By type"},{id:"byModel",title:"By model"},{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byGuide",title:"By guide"},{id:"cameBack",title:"Came back"}];function RO(){const e=By(),[t,n]=y.useState("byTypeAndModel"),[i,a]=y.useState(!1);if(e==null)return null;const c=()=>void navigator.clipboard.writeText(DN(e)).then(()=>{a(!0),setTimeout(()=>a(!1),1500)});return s.jsxs("section",{className:"perf-section scorecard",children:[s.jsxs("div",{className:"score-head",children:[s.jsx(Ke,{as:"h3",children:"Scorecard"}),s.jsx(I,{size:"sm",variant:"ghost",onClick:c,disabled:!e.tickets,children:i?"Copied":"Copy as Markdown"})]}),s.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. Came back: verified, then reopened or reverted on main."]}),s.jsx("div",{className:"choice-row compact",children:AO.map(d=>s.jsx(ct,{on:t===d.id,title:d.title,onClick:()=>n(d.id)},d.id))}),t==="cameBack"?s.jsx(NO,{checks:e.byCheck??[],escapes:e.escapes??[],minSample:e.minSample}):s.jsx(TO,{rows:e[t]??[],minSample:e.minSample})]})}function Fy(e){const[t,n]=y.useState({}),i=e.map(a=>`${a.map.id}:${a.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),0)}`).join();return y.useEffect(()=>{let a=!0;return Promise.all(e.map(async c=>{const d=await fetch(`${ie()}/journal?mapId=${encodeURIComponent(c.map.id)}`).catch(()=>{}),u=d!=null&&d.ok?await d.json():{entries:[]};return[c.map.id,u.entries]})).then(c=>{a&&n(Object.fromEntries(c))}),()=>{a=!1}},[i]),t}const IO=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function MO({api:e,bp:t,onClose:n}){const[i,a]=y.useState("byVendor"),c=y.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),d=Fy(c),u=e.activity.answered,f=y.useMemo(()=>Av(c.map(m=>({snap:m,journal:d[m.map.id]??[],answered:u}))),[c,d,u]);return y.useEffect(()=>{const m=g=>g.key==="Escape"&&n();return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[n]),s.jsxs(Fe,{className:`zone decisions-view perf-view dv-${t}`,children:[s.jsxs("header",{className:"dv-head",children:[s.jsx(Ke,{as:"h2",children:"Trail stats"}),s.jsx(B,{parts:[`${f.trails} trails`,`${f.tickets} tickets`]}),s.jsx("span",{className:"dv-head-right",children:s.jsx("button",{className:"icon-btn",onClick:n,"aria-label":"Close",children:"×"})})]}),s.jsxs("div",{className:"perf-body",children:[s.jsxs("section",{className:"perf-section",children:[s.jsx(Ke,{as:"h3",children:"What stands out"}),s.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?s.jsx("ul",{className:"perf-recs",children:f.recommendations.map(m=>s.jsxs("li",{title:m.because,children:[s.jsx("span",{children:m.text}),s.jsx("span",{className:"t-meta",children:m.because})]},m.id))}):s.jsx(Te,{children:"Nothing yet. This needs at least 5 results from two vendors to compare."})]}),s.jsx(RO,{}),s.jsx(wO,{}),s.jsxs("section",{className:"perf-section",children:[s.jsx("div",{className:"choice-row compact",children:IO.map(m=>s.jsx(ct,{on:i===m.id,title:m.title,onClick:()=>a(m.id)},m.id))}),s.jsx(xO,{rows:f[i]}),s.jsx("p",{className:"perf-note t-meta",children:"Spend is tracked per trail, so it isn't split by agent here."})]})]})]})}function OO(e){const t=By();if(!t)return null;const n=ON({scorecard:t,tiers:e.tiers,models:e.models});return n.length?s.jsx("ul",{className:"tier-suggestions",children:n.map(i=>s.jsxs("li",{children:[s.jsxs("span",{children:[En[i.type],": ",kr[i.tier].toLowerCase()," instead of ",kr[i.current].toLowerCase()]}),s.jsx("span",{className:"t-meta",children:i.because}),s.jsxs(I,{size:"sm",variant:"ghost",onClick:()=>e.onTake(i.type,i.tier),children:["Use ",kr[i.tier].toLowerCase()]})]},i.type))}):null}function LO(e,t){const n=Fy(e);return y.useMemo(()=>{var c;const i=Av(e.map(d=>({snap:d,journal:n[d.map.id]??[],answered:t}))),a={};for(const d of i.byType){if(!d.done)continue;const u=(c=i.recommendations.find(m=>m.id===`speed-${d.key}`))==null?void 0:c.text,f=[`Trail stats: ${d.done} done`,d.medianLeadMs!==void 0&&`median ${tn(d.medianLeadMs)}`,d.reworkCycles>0&&`${d.reworkCycles} back to rework`,u];a[d.key]=f.filter(Boolean).join(" · ")}return a},[e,n,t])}function PO(e){var u,f;const t=Lu(),n=LO(e.snaps,e.answered),i=e.map;if(!i)return null;const a=!!((u=i.modelMatching)!=null&&u.enabled),c=((f=i.modelMatching)==null?void 0:f.tiers)??{},d=(m,g)=>{const k={...c,[m]:g};g===cu[m]&&delete k[m],e.onChange({enabled:!0,tiers:k})};return s.jsxs(Ee,{title:"Model matching",children:[s.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."}),s.jsxs("div",{className:"att-settings-row set-field",children:[s.jsxs("span",{className:"set-field-label",children:["Match work to models on trail ",i.key]}),s.jsx(I,{size:"sm",on:a,"aria-pressed":a,className:"model-matching-toggle",onClick:()=>e.onChange({...i.modelMatching,enabled:!a}),children:a?"On":"Off"})]}),a&&s.jsx(gO,{tiers:Jm(i),hints:n,onChange:d}),a&&s.jsx(OO,{tiers:Jm(i),models:t==null?void 0:t.models,onTake:d}),a&&s.jsx("span",{className:"set-hint t-meta",children:"Changes apply to the next claim; nothing running is interrupted."}),s.jsx(fO,{view:t})]})}function mr(e,t){const n=new URL(e);return n.searchParams.delete("settings"),t&&n.searchParams.set("settings",t.section??t.group??""),n.toString()}const Xd=e=>e.trim().split(/\s+/).filter(Boolean);function DO(e){return e.rows.map((t,n)=>{const i=Xd(t.command).join(" ");return e.findings.filter(a=>a.check===String(n)&&a.command===i)})}function _O(e){const{check:t,onChange:n}=e,i=t.name.trim()?`Remove ${t.name.trim()}`:"Remove check";return s.jsx("li",{className:"vf-edit-check",children:s.jsxs("div",{className:"vf-edit-row",children:[s.jsx("input",{"aria-label":"Name",value:t.name,placeholder:"name",autoFocus:e.focus,onChange:a=>n({name:a.target.value})}),s.jsx("input",{"aria-label":"Command",className:"t-code",value:t.command,placeholder:"npm test",onChange:a=>n({command:a.target.value})}),s.jsx("button",{type:"button",className:"icon-btn vf-edit-remove","aria-label":i,"data-tip":i,onClick:e.onRemove,children:"×"}),s.jsx(Va,{findings:e.findings,onFix:a=>n({command:a.join(" ")})})]})})}const BO=[{name:"test",command:"npm test"},{name:"lint",command:"npm run lint"},{name:"typecheck",command:"npm run typecheck"}];function FO(e){return s.jsxs("div",{className:"vf-edit-add",children:[s.jsx(I,{onClick:()=>e.onAdd({name:"",command:""}),children:"Add check"}),e.empty&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"t-meta",children:"or start with"}),BO.map(t=>s.jsx("button",{type:"button",className:"chip t-code",onClick:()=>e.onAdd(t),children:t.command},t.name))]})]})}function zO(e){const{state:t}=e,n=t.kind==="saving";return s.jsxs("div",{className:"vf-edit-foot",children:[s.jsxs("label",{className:"vf-edit-sure",children:[s.jsx("input",{type:"checkbox",checked:e.sure,onChange:i=>e.onSure(i.target.checked)}),s.jsx("span",{children:"I know what these commands run, and approve them"})]}),s.jsxs("div",{className:"vf-edit-save",children:[t.kind==="saved"&&s.jsx("span",{className:"t-meta",children:"Saved and approved."}),t.kind==="error"&&s.jsx("span",{className:"vf-err",children:t.text}),s.jsx(I,{variant:"primary",disabled:!e.sure||n,onClick:e.onSave,children:n?"Saving…":"Save checks"})]})]})}function UO(e){const t=e.config;return t?t.run.filter(n=>t.checks[n]).map(n=>({name:n,command:t.checks[n].run.join(" ")})):[]}function WO({view:e}){const[t,n]=y.useState(()=>UO(e)),[i,a]=y.useState(!1),[c,d]=y.useState(!1),[u,f]=y.useState({kind:"idle"}),m=(S,x)=>n(t.map((C,N)=>N===S?{...C,...x}:C)),g=t.map((S,x)=>{var C,N;return{name:String(x),run:Xd(S.command),cwd:(N=(C=e.config)==null?void 0:C.checks[S.name])==null?void 0:N.cwd}}),k=Xk(g),w=DO({findings:k,rows:t}),b=async()=>{var N;f({kind:"saving"});const S=t.filter(P=>P.name.trim()&&P.command.trim()).map(P=>({name:P.name.trim(),run:Xd(P.command)})),x=await fetch(`${ie()}/verification/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({checks:S,base:((N=e.approval)==null?void 0:N.base)??"none",acknowledged:!0})}).catch(()=>{}),C=await(x==null?void 0:x.json().catch(()=>({})));if(x!=null&&x.ok)return f({kind:"saved"});f({kind:"error",text:(C==null?void 0:C.error)??"The server didn't answer."})};return s.jsxs("div",{className:"vf-editor",children:[t.length>0&&s.jsx("ul",{className:"vf-edit-list",children:t.map((S,x)=>s.jsx(_O,{check:S,findings:w[x],focus:i&&x===t.length-1,onChange:C=>m(x,C),onRemove:()=>n(t.filter((C,N)=>N!==x))},x))}),s.jsx(FO,{empty:t.length===0,onAdd:S=>{a(!0),n([...t,S])}}),s.jsx(rn,{label:"How checks run",children:s.jsxs("p",{className:"t-meta",children:["Each command runs from the repository's root as words, never through a shell: no pipes or"," ",s.jsx("code",{className:"t-code",children:"&&"}),", and what it runs must already be in the repo. For example"," ",s.jsx("code",{className:"t-code",children:"npm run e2e"}),", ",s.jsx("code",{className:"t-code",children:"make test"}),","," ",s.jsx("code",{className:"t-code",children:"./scripts/check.sh"})," or ",s.jsx("code",{className:"t-code",children:"pytest -q"}),"."]})}),s.jsx(zO,{sure:c,onSure:d,state:u,onSave:()=>void b()})]})}function HO({config:e,file:t,hash:n}){return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"sync-line ok",title:n,children:[s.jsx("span",{className:"dot"}),s.jsxs("span",{children:[s.jsx("span",{className:"t-code",children:t})," · ",e.run.length," checks run on every completion"]})]}),s.jsx(B,{className:"set-hint",parts:[`New trails start at ${Er[e.default]}`,`${e.maxAttempts} attempts before it waits for you`,e.failFast&&"Stops at the first failure"]}),s.jsx("div",{className:"vf-checks",children:Object.entries(e.checks).map(([i,a])=>s.jsxs("div",{className:"vf-check",children:[s.jsx("span",{className:"t-code",children:e.run.includes(i)?i:`${i} (on request)`}),s.jsx("code",{children:a.run.join(" ")}),s.jsxs("span",{className:"dim",children:[a.timeoutSec," s",a.cwd&&a.cwd!=="."?` · in ${a.cwd}`:""]})]},i))})]})}const KO=[{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 GO({view:e,local:t}){var u,f;const[n,i]=y.useState(),a=((u=e.config)==null?void 0:u.scope)??"flag",c=(f=e.approval)!=null&&f.waiting?"Approve the checks first.":void 0,d=async m=>{var w;i(void 0);const g=await fetch(`${ie()}/verification/scope`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:m,base:((w=e.approval)==null?void 0:w.base)??"none"})}).catch(()=>{});if(g!=null&&g.ok)return;const k=await(g==null?void 0:g.json().catch(()=>({})));i((k==null?void 0:k.error)??"The server didn't answer.")};return s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"set-field-label",children:"Changes outside the files an agent declared"}),s.jsx("div",{className:"choice-row vf-levels",children:KO.map(m=>s.jsx(ct,{on:a===m.value,title:m.title,sub:m.sub,disabled:!t||!!c,onClick:()=>void d(m.value)},m.value))}),s.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.",c?` ${c}`:"",t===!1?" Set on the machine Teamtrail runs on.":""]}),n&&s.jsx("span",{className:"vf-err",children:n})]})}function VO(e){var c;const{view:t,local:n,file:i}=e,a=t.config;return s.jsxs(s.Fragment,{children:[n&&s.jsx(WO,{view:t},((c=t.approval)==null?void 0:c.base)??"none"),!n&&!t.exists&&s.jsx("span",{className:"set-hint t-meta",children:"No checks yet. They're set on the machine Teamtrail runs on."}),!n&&a&&t.exists&&s.jsx(HO,{config:a,file:i,hash:t.hash}),!n&&s.jsx(Va,{findings:t.screening??[],named:!0}),a&&t.exists&&s.jsx(GO,{view:t,local:n})]})}function qO(e){var g;const t=Mu(),n=xi(),[i,a]=y.useState();if(!t)return null;const c=e.map,d=t.config,u=`${J.dataDir}/${t.file}`,f=(c==null?void 0:c.verification)??"off",m=(d??pv).appliesTo.join(" and ");return s.jsxs(Ee,{title:"Verification",children:[s.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"," ",m," tickets. Research, junction and prototype tickets close as soon as they are answered."]}),c&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"set-field-label",children:["How much checking for trail ",c.key]}),s.jsx("div",{className:"choice-row vf-levels",children:au.map(k=>s.jsx(ct,{on:f===k,title:Er[k],sub:Iu[k],onClick:()=>{a(void 0),bs.act({action:"level",mapId:c.id,level:k,by:Ct}).catch(w=>a(w.message))}},k))}),f!=="off"&&!d&&s.jsxs("div",{className:"sync-line alert",children:[s.jsx("span",{className:"dot"}),s.jsx("span",{children:"No working checks yet, so completions at this level stop and wait for you."})]}),i&&s.jsx("span",{className:"vf-err",children:i})]}),t.errors.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"sync-line alert",title:t.hash,children:[s.jsx("span",{className:"dot"}),s.jsxs("span",{children:[u," has errors. Completions that need checks wait for you until it is fixed."]})]}),s.jsx("ul",{className:"vf-errors",children:t.errors.map(k=>s.jsx("li",{children:k},k))})]}),((g=t.approval)==null?void 0:g.waiting)&&s.jsxs("div",{className:"sync-line alert",children:[s.jsx("span",{className:"dot"}),s.jsxs("span",{children:["Its commands don't run on this machine until you approve them."," ",s.jsx("a",{href:mr(location.href,{group:"project",section:"approvals"}),children:"Review the commands"})]})]}),s.jsx(VO,{view:t,local:n,file:u}),c&&s.jsx(tC,{mapId:c.id}),s.jsxs("span",{className:"set-hint t-meta",children:["Saved here, checks are approved as you save them. A change to ",u," made in the repo, by an agent or a teammate, runs nothing until you approve it."]}),s.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 ",s.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 QO({data:e}){const{map:t}=e;return s.jsxs(s.Fragment,{children:[t?s.jsx(We,{id:"mode",children:s.jsx(Ee,{title:`Trail ${t.key}`,children:s.jsx(yT,{value:t.mode,onChange:e.onMapMode})})}):s.jsx(Te,{children:"Chart or pick a trail to set its mode, model matching and guides."}),s.jsx(We,{id:"verification",storage:"repo",children:s.jsx(qO,{map:t})}),s.jsx(We,{id:"gates",storage:"repo",children:s.jsx(hO,{onOpenTicket:e.onOpenTicket})}),s.jsx(We,{id:"rules",storage:"repo",children:s.jsx(k2,{})}),s.jsx(We,{id:"models",children:s.jsx(PO,{map:t,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching})}),t&&s.jsx(We,{id:"trail-guides",children:s.jsx(xE,{map:t})})]})}const yg=10,zy=[0,10,16,26,18,24,16,18,22,22,26],Uy=[0,1,1,1,2,2,4,4,4,5,5];function Wy(e){let t=(16*e+128)*e+64;if(e<2)return t;const n=Math.floor(e/7)+2;return t-=(25*n-10)*n-55,e>=7?t-36:t}const YO=e=>zy[e],JO=e=>Uy[e],Hy=e=>Math.floor(Wy(e)/8)-zy[e]*Uy[e],Ky=e=>e<10?8:16;function XO(e){if(e===1)return[];const t=Math.floor(e/7)+2,n=e*4+17,i=Math.ceil((e*4+4)/(t*2-2))*2,a=[6];for(let c=n-7;a.length<t;c-=i)a.splice(1,0,c);return a}function Zd(e,t){let n=0;for(let i=7;i>=0;i--)n=n<<1^(n>>>7)*285,n^=(t>>>i&1)*e;return n}function ZO(e){const t=new Array(e).fill(0);t[e-1]=1;let n=1;for(let i=0;i<e;i++){for(let a=0;a<t.length;a++)t[a]=Zd(t[a],n),a+1<t.length&&(t[a]^=t[a+1]);n=Zd(n,2)}return t}function eL(e,t){const n=t.map(()=>0);for(const i of e){const a=i^n.shift();n.push(0),t.forEach((c,d)=>n[d]^=Zd(c,a))}return n}function tL(e,t){const n=[],i=(d,u)=>{for(let f=u-1;f>=0;f--)n.push(d>>>f&1)};i(4,4),i(e.length,Ky(t));for(const d of e)i(d,8);const a=Hy(t)*8;i(0,Math.min(4,a-n.length)),i(0,(8-n.length%8)%8);for(let d=236;n.length<a;d^=253)i(d,8);const c=[];for(let d=0;d<n.length;d+=8)c.push(n.slice(d,d+8).reduce((u,f)=>u<<1|f,0));return c}function nL(e,t){const n=tL(e,t),i=JO(t),a=YO(t),c=Math.floor(Wy(t)/8),d=i-c%i,u=Math.floor(c/i),f=ZO(a),m=[];for(let k=0,w=0;k<i;k++){const b=n.slice(w,w+u-a+(k<d?0:1));w+=b.length;const S=eL(b,f);k<d&&b.push(0),m.push([...b,...S])}const g=[];for(let k=0;k<m[0].length;k++)for(let w=0;w<m.length;w++)(k!==u-a||w>=d)&&g.push(m[w][k]);return g}const sL=[(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 yd(e,t){const n=sL[t];for(let i=0;i<e.size;i++)for(let a=0;a<e.size;a++)!e.fixed[i][a]&&n(a,i)&&(e.dark[i][a]=!e.dark[i][a])}function wg(e){let t=0,n=1;for(let a=1;a<=e.length;a++)a<e.length&&e[a]===e[a-1]?n++:(n>=5&&(t+=n-2),n=1);const i=e.map(a=>a?"1":"0").join("");for(const a of["00001011101","10111010000"])for(let c=i.indexOf(a);c>=0;c=i.indexOf(a,c+1))t+=40;return t}function iL(e){let t=0,n=0;for(let a=0;a<e.size;a++)t+=wg(e.dark[a]),t+=wg(e.dark.map(c=>c[a]));for(let a=0;a<e.size;a++)for(let c=0;c<e.size;c++){if(e.dark[a][c]&&n++,c===e.size-1||a===e.size-1)continue;const d=e.dark[a][c];d===e.dark[a][c+1]&&d===e.dark[a+1][c]&&d===e.dark[a+1][c+1]&&(t+=3)}const i=e.size*e.size;return t+Math.floor(Math.abs(n*20-i*10)/i)*10}const hn=(e,t)=>(e>>>t&1)!==0;function Tt(e,t,n,i){e.dark[n][t]=i,e.fixed[n][t]=!0}function wd(e,t,n){for(let i=-4;i<=4;i++)for(let a=-4;a<=4;a++){const c=t+a,d=n+i,u=Math.max(Math.abs(a),Math.abs(i));c>=0&&c<e.size&&d>=0&&d<e.size&&Tt(e,c,d,u!==2&&u!==4)}}function rL(e,t,n){for(let i=-2;i<=2;i++)for(let a=-2;a<=2;a++)Tt(e,t+a,n+i,Math.max(Math.abs(a),Math.abs(i))!==1)}function eu(e,t){const n=0|t;let i=n;for(let c=0;c<10;c++)i=i<<1^(i>>>9)*1335;const a=(n<<10|i)^21522;for(let c=0;c<=5;c++)Tt(e,8,c,hn(a,c));Tt(e,8,7,hn(a,6)),Tt(e,8,8,hn(a,7)),Tt(e,7,8,hn(a,8));for(let c=9;c<15;c++)Tt(e,14-c,8,hn(a,c));for(let c=0;c<8;c++)Tt(e,e.size-1-c,8,hn(a,c));for(let c=8;c<15;c++)Tt(e,8,e.size-15+c,hn(a,c));Tt(e,8,e.size-8,!0)}function oL(e,t){if(t<7)return;let n=t;for(let a=0;a<12;a++)n=n<<1^(n>>>11)*7973;const i=t<<12|n;for(let a=0;a<18;a++){const c=e.size-11+a%3,d=Math.floor(a/3);Tt(e,c,d,hn(i,a)),Tt(e,d,c,hn(i,a))}}function aL(e){const t=e*4+17,n=()=>Array.from({length:t},()=>new Array(t).fill(!1)),i={size:t,dark:n(),fixed:n()};for(let d=0;d<t;d++)Tt(i,6,d,d%2===0),Tt(i,d,6,d%2===0);wd(i,3,3),wd(i,t-4,3),wd(i,3,t-4);const a=XO(e),c=a.length-1;for(let d=0;d<=c;d++)for(let u=0;u<=c;u++)d===0&&u===0||d===0&&u===c||d===c&&u===0||rL(i,a[d],a[u]);return eu(i,0),oL(i,e),i}function cL(e){const t=[];for(let n=e-1;n>=1;n-=2){const i=n<=6?n-1:n,a=(i+1&2)===0;for(let c=0;c<e;c++){const d=a?e-1-c:c;t.push([i,d],[i-1,d])}}return t}function lL(e,t){let n=0;for(const[i,a]of cL(e.size))e.fixed[a][i]||n>=t.length*8||(e.dark[a][i]=hn(t[n>>>3],7-(n&7)),n++)}function dL(e){const t=new TextEncoder().encode(e);let n=1;for(;n<=yg&&4+Ky(n)+t.length*8>Hy(n)*8;)n++;if(n>yg)return;const i=aL(n);lL(i,nL(t,n));let a=0,c=1/0;for(let d=0;d<8;d++){yd(i,d),eu(i,d);const u=iL(i);u<c&&([a,c]=[d,u]),yd(i,d)}return yd(i,a),eu(i,a),i.dark}const xd=4;function uL(e){const t=dL(e.text);if(!t)return null;const n=t.length+xd*2,i=t.flatMap((a,c)=>a.map((d,u)=>d?`M${u+xd} ${c+xd}h1v1h-1z`:"")).join("");return s.jsxs("svg",{className:"si-qr",viewBox:`0 0 ${n} ${n}`,role:"img","aria-label":e.label,shapeRendering:"crispEdges",children:[s.jsx("rect",{width:n,height:n,fill:"#fff"}),s.jsx("path",{d:i,fill:"#000"})]})}function hL(e){const t=gt(1e3),n=Math.max(0,Math.ceil((e.device.expiresAt-t)/6e4)),i=e.device.links[0];return e.device.expiresAt<=t?s.jsxs("div",{className:"si-code",children:[s.jsx("p",{className:"t-meta",children:"That code expired. Make a new one when the device is ready."}),s.jsx(I,{size:"sm",onClick:e.onDone,children:"Done"})]}):s.jsxs("div",{className:"si-code",children:[i&&s.jsx(uL,{text:i,label:"QR code that pairs another device"}),s.jsxs("div",{className:"si-code-words",children:[s.jsx("span",{className:"si-code-value t-code","aria-label":"Pairing code",children:e.device.code}),s.jsx(B,{parts:["Works once",`expires in ${n} min`]}),s.jsxs("p",{className:"t-meta si-note",children:["Scan it with the device’s camera, or open"," ",i?s.jsx("code",{className:"t-code",children:i.split("#")[0]}):"the Lookout"," there and type the code."]}),s.jsx(I,{size:"sm",onClick:e.onDone,children:"Done"})]})]})}function fL(e){const[t,n]=y.useState();return e.device?s.jsx(hL,{device:e.device,onDone:e.onDone}):e.lan.length?s.jsxs("div",{className:"si-pair",children:[s.jsx(I,{onClick:async()=>n(await e.onPair()),children:"Pair a device"}),t&&s.jsx("span",{className:"vf-err",children:t})]}):s.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 ",s.jsxs("code",{className:"t-code",children:[J.slug," --host 0.0.0.0"]})," on a network you trust. Another browser on this machine: run ",s.jsxs("code",{className:"t-code",children:[J.slug," pair"]}),"."]})}function mL(e){const[t,n]=y.useState(!1),[i,a]=y.useState(!1),[c,d]=y.useState(),u=async()=>{a(!0),d(await e.onRevoke().catch(f=>f.message)),a(!1),n(!1)};return t?s.jsxs("span",{className:"ra-revoke ask",children:[s.jsx("span",{className:"t-meta",children:"It’s signed out now."}),s.jsxs(I,{size:"sm",disabled:i,onClick:u,children:["Revoke ",e.name]}),s.jsx(I,{size:"sm",variant:"ghost",onClick:()=>n(!1),children:"Keep"})]}):s.jsxs("span",{className:"ra-revoke",children:[s.jsx(I,{size:"sm","aria-label":`Revoke ${e.name}`,onClick:()=>n(!0),children:"Revoke"}),c&&s.jsx("span",{className:"vf-err",children:c})]})}const pL={machine:"This machine",device:"Another device"};function gL(e){const t=Date.now();return s.jsx("ul",{className:"ra-list si-list",children:e.sessions.map(n=>s.jsx(he,{as:"li",className:"ra-row",title:n.current?`${n.name} · this browser`:n.name,titleText:n.name,context:s.jsx(B,{parts:[pL[n.kind],n.via==="opened-page"?`From the page ${J.name} opened`:void 0,n.via==="opened-page"?{text:GS(n.id),code:!0}:void 0,`Paired ${ss(n.pairedAt,t)}`,`Last used ${ss(n.lastUsedAt,t)}`]}),below:n.current?void 0:s.jsx(mL,{name:n.name,onRevoke:()=>e.onRevoke(n.id)})},n.id))})}function vL(){return s.jsxs("div",{className:"ra-notes",children:[s.jsxs("p",{className:"t-meta ra-note",children:[s.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 ",s.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."]}),s.jsxs("p",{className:"t-meta ra-note",children:[s.jsx("b",{children:"What it can’t stop."})," A program that can read ",J.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:"," ",s.jsxs("code",{children:[J.slug," connect"]})," sets that up for the agents it registers."]})]})}const Gy=`${J.apiPrefix}/sign-in`;async function jd(e,t={}){const n=await fetch(`${Gy}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:n.ok,reply:await n.json().catch(()=>({}))}}function kL(){const[e,t]=y.useState(),[n,i]=y.useState(),a=y.useCallback(()=>{fetch(`${Gy}/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 c=y.useCallback(async()=>{const{ok:f,reply:m}=await jd("/codes");if(!f)return m.error??"No code could be made.";i(m)},[]),d=y.useCallback(async f=>{const{ok:m,reply:g}=await jd("/revoke",{id:f});return a(),m?void 0:g.error??"That browser could not be revoked."},[a]),u=y.useCallback(async()=>{await jd("/sign-out"),Zv(),location.reload()},[]);return{view:e,device:n,closeDevice:()=>(i(void 0),a()),pairDevice:c,revoke:d,signOut:u}}function yL(){const{view:e,device:t,closeDevice:n,pairDevice:i,revoke:a,signOut:c}=kL();if(!e)return null;const d=s.jsx("div",{className:"si-signout",children:s.jsx(I,{size:"sm",variant:"ghost",onClick:c,children:"Sign out of this browser"})});return e==="elsewhere"?s.jsxs(Ee,{title:"Browsers & devices",children:[s.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]}):s.jsxs(Ee,{title:"Browsers & devices",children:[s.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."}),s.jsx(gL,{sessions:e.sessions,onRevoke:a}),s.jsx(fL,{lan:e.lan,device:t,onPair:i,onDone:n}),d,s.jsx(vL,{})]})}function wL({managed:e}){const{signOut:t,pages:n}=e;return s.jsxs(Ee,{title:"Signed in",children:[s.jsxs("p",{className:"vf-intro",children:["Signed in as ",e.name,". Sign-in is managed by the server this Lookout runs on."]}),n.length||e.home?s.jsxs("div",{className:"choice-row",children:[e.home&&s.jsxs(I,{size:"sm",onClick:()=>location.assign(e.home.href),children:["← ",e.home.label]}),n.map(i=>s.jsx(I,{size:"sm",onClick:()=>location.assign(i.href),children:i.label},i.href))]}):null,t?s.jsx("div",{className:"si-signout",children:s.jsx(I,{size:"sm",variant:"ghost",onClick:()=>location.assign(t),children:"Sign out"})}):null]})}function xL(){return y.useEffect(()=>{const e=setInterval(()=>void Pa().then(t=>t!=="failed"&&location.reload()),3e3);return()=>clearInterval(e)},[]),s.jsx("div",{className:"pair-page",children:s.jsxs(Fe,{as:"main",className:"pair-card",children:[s.jsx("div",{className:"onb-brand",children:s.jsx(Ua,{className:"onb-title"})}),s.jsxs("h1",{className:"t-heading pair-title",children:[J.name," isn’t running here"]}),s.jsxs("p",{className:"t-body pair-step",children:["Start it with ",s.jsx("code",{className:"t-code",children:J.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 Uu(e){const t=await fetch(`${J.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 n=await t.json().catch(()=>({}));if(!t.ok)return n.error??"That code didn’t work. Get a new one.";n.id&&n.session&&n.verifier&&K1({id:n.id,secret:n.session,verifier:n.verifier})}function jL(e){const[t,n]=y.useState(!1),i=async()=>{n(!0);const a=await Uu(e.code);if(!a)return location.reload();n(!1),e.onFailed(a)};return s.jsxs("div",{className:"pair-confirm",children:[s.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"," ",s.jsx("code",{className:"t-code",children:J.slug}),", ",s.jsxs("code",{className:"t-code",children:[J.slug," pair"]})," or Pair a device in the Lookout’s Settings."]}),s.jsx("div",{children:s.jsx(I,{variant:"primary",disabled:t,onClick:i,children:"Sign in this browser"})})]})}function xg(){const[e,t]=y.useState(""),[n,i]=y.useState(!1),[a,c]=y.useState(),d=async()=>{if(!e.trim()||n)return;i(!0);const u=await Uu(e);i(!1),c(u),u||location.reload()};return s.jsxs("form",{className:"pair-device",onSubmit:u=>{u.preventDefault(),d()},children:[s.jsxs("p",{className:"t-body pair-step",children:["On a phone or another computer: in the Lookout on the machine ",J.name," runs on, open Settings → You → Browsers & devices → Pair a device. Then type the code here, or scan it with this device’s camera."]}),s.jsxs("div",{className:"pair-code-row",children:[s.jsx("input",{className:"pair-code-input t-code",value:e,onChange:u=>t(u.target.value),placeholder:"ABCD-EFGH","aria-label":"Pairing code",autoComplete:"one-time-code",autoCapitalize:"characters",spellCheck:!1,maxLength:20}),s.jsx(I,{type:"submit",variant:"primary",disabled:n||!e.trim(),children:"Pair"})]}),a&&s.jsx("p",{className:"vf-err",role:"alert",children:a})]})}function jg(){return s.jsxs("p",{className:"t-body pair-step pair-here",children:["On the machine ",J.name," runs on, run ",s.jsxs("code",{className:"t-code",children:[J.slug," pair"]}),": it opens a tab ready to sign in, with one click. Or open the Sign in link ",s.jsx("code",{className:"t-code",children:J.slug})," printed in its terminal."]})}function bL(e){return s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"t-body pair-step",children:"The Lookout opens only in browsers you’ve paired."}),e.local?s.jsx(jg,{}):s.jsx(xg,{}),e.local?s.jsx(xg,{}):s.jsx(jg,{})]})}function SL(e){const[t,n]=y.useState(),[i,a]=y.useState(e.code),[c,d]=y.useState(e.code);e.code!==c&&(d(e.code),a(e.code));const u=f=>(n(f),a(void 0));return s.jsx("div",{className:"pair-page",children:s.jsxs(Fe,{as:"main",className:"pair-card",children:[s.jsx("div",{className:"onb-brand",children:s.jsx(Ua,{className:"onb-title"})}),s.jsx("h1",{className:"t-heading pair-title",children:"Pair this browser"}),t&&s.jsx("p",{className:"pair-problem t-body",role:"alert",children:t}),i?s.jsx(jL,{code:i,onFailed:u}):s.jsx(bL,{local:e.local})]})})}function bg(){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 Sg(){try{const e=await fetch(`${J.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&&_1(t)?{kind:"signed-in"}:{kind:"signed-out",local:t.local===!0}}catch{return{kind:"no-server"}}}async function NL(){if(!wu())return Sg();const e=await Pa();return e==="proven"?{kind:"signed-in"}:e==="unknown"?Sg():{kind:"not-running"}}function $L(){const[e,t]=y.useState({kind:"checking"});return y.useEffect(()=>void NL().then(t),[]),y.useEffect(()=>G1(n=>n==="failed"&&t({kind:"not-running"})),[]),e}function CL({children:e}){const t=$L(),[n,i]=y.useState(bg);return y.useEffect(()=>{const a=()=>i(c=>bg()??c);return window.addEventListener("hashchange",a),()=>window.removeEventListener("hashchange",a)},[]),y.useEffect(()=>{t.kind==="signed-in"&&n&&Uu(n)},[t.kind,n]),t.kind==="checking"?null:t.kind==="signed-out"?s.jsx(SL,{local:t.local,code:n}):t.kind==="not-running"?s.jsx(xL,{}):s.jsx(s.Fragment,{children:e})}function TL(){const e=pt();return e?s.jsx(wL,{managed:e}):s.jsx(We,{id:"devices",storage:"machine",children:s.jsx(yL,{})})}const EL=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function AL(e){return s.jsx("div",{className:"choice-row compact",children:EL.map(t=>s.jsx(ct,{on:e.value===t.value,title:t.title,onClick:()=>e.onChange(t.value)},t.value))})}function RL({data:e}){var i;const{prefs:t,update:n}=e;return s.jsxs(s.Fragment,{children:[s.jsx(We,{id:"appearance",storage:"browser",children:s.jsxs(Ee,{title:"Appearance",children:[ck()?s.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."}):s.jsx(AL,{value:lk(t.theme),onChange:a=>n({theme:a})}),((i=pt())==null?void 0:i.themeSave)&&s.jsx("p",{className:"vf-intro",children:"Saved to your account, so the server's pages follow it."})]})}),s.jsx(We,{id:"transcript",storage:"browser",children:s.jsx(Ee,{title:"HITL transcript",children:s.jsx(Ey,{value:t.hitlTranscript,onChange:a=>n({hitlTranscript:a})})})}),s.jsx(We,{id:"agent",children:s.jsx(Ee,{title:"Agent",children:s.jsx("div",{className:"choice-row",children:Uv.map(a=>s.jsx(ct,{on:a.status==="primary",disabled:a.status!=="primary",title:a.name},a.id))})})}),s.jsx(TL,{})]})}function IL(e){const{data:t,route:n}=e;switch(e.group){case"trail":return s.jsx(QO,{data:t});case"project":return s.jsx(LM,{data:t,route:n});case"alerts":return s.jsx(VI,{data:t,route:n});case"you":return s.jsx(RL,{data:t});case"projects":return s.jsx(We,{id:"projects",storage:"machine",children:s.jsx(ZM,{})});case"about":return s.jsx(We,{id:"changelog",children:s.jsx(eM,{})});default:return e.group}}function ML(e){const{group:t,route:n}=e,i=y.useRef(null),a=y.useRef(null);return y.useEffect(()=>{var d,u;(d=i.current)==null||d.focus({preventScroll:!0});const c=n.section&&document.getElementById(`settings-${n.section}`);c?c.scrollIntoView({block:"start"}):(u=a.current)==null||u.scrollTo({top:0})},[t.id,n.section]),s.jsx("div",{className:"sp-pane",ref:a,children:s.jsxs("div",{className:"sp-pane-in",children:[s.jsxs("header",{className:"sp-pane-head",children:[s.jsx("h2",{className:"sp-title t-title",ref:i,tabIndex:-1,children:t.label}),s.jsx("p",{className:"sp-intro t-meta",children:t.intro})]}),s.jsx(IL,{group:t.id,data:e.data,route:n})]})})}function OL(e){return s.jsx("nav",{className:"sp-nav","aria-label":"Settings groups",children:s.jsx("ul",{children:xr.map(t=>{const n=t.id===e.current;return s.jsx(he,{as:"li",className:"sp-nav-row",selected:n,current:n?"page":void 0,title:t.label,context:s.jsx(B,{parts:t.sections.map(i=>i.title)}),trailing:e.drill&&"›",onOpen:()=>e.onPick(t.id)},t.id)})})})}function LL(e,t){return e.group?xr.find(n=>n.id===e.group):t==="mobile"?void 0:xr[0]}const PL={page:"Back to the Lookout",list:"Lookout",group:"Settings"},DL=(e,t)=>e?t?"group":"list":"page";function _L(e){const{bp:t,route:n}=e,i=t==="mobile",a=LL(n,t),c=DL(i,!!a),d=xi()===!1,u=()=>c==="group"?e.onShow({}):e.onClose();y.useEffect(()=>{const g=k=>{k.key!=="Escape"||k.defaultPrevented||document.querySelector(".scrim")||(c==="group"?e.onShow({}):e.onClose())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[c,e]);const f=g=>e.onShow({group:g}),m=c!=="group"&&s.jsx(OL,{current:a==null?void 0:a.id,onPick:f,drill:i});return s.jsxs(Fe,{className:`zone decisions-view settings-page sp-${t}`,"aria-label":"Settings",children:[s.jsxs("header",{className:"dv-head",children:[s.jsxs("button",{className:"back",onClick:u,children:["‹ ",PL[c]]}),c!=="group"&&s.jsx(Ke,{as:"h2",children:"Settings"}),!i&&s.jsx("span",{className:"dv-head-right t-meta",children:"Esc"})]}),d&&s.jsx(LI,{}),s.jsxs("div",{className:"sp-body",children:[m,a&&s.jsx(ML,{group:a,data:e.data,route:n})]})]})}function BL(e){var a;const{rt:t,api:n,settings:i}=e;return i.route?s.jsx(_L,{bp:e.bp,route:i.route,onShow:i.show,onClose:i.close,data:{prefs:e.prefs,update:e.update,activeTracker:t.kind,location:t.adapter.location,map:(a=n.snap)==null?void 0:a.map,onMapMode:n.actions.setMode,snaps:Object.values(n.allSnaps),answered:n.activity.answered,onModelMatching:n.actions.setModelMatching,onOpenTicket:(c,d)=>{i.dismiss(),e.openTicket(c,d)}}}):null}function FL(e){var d;const{api:t,nav:n,attn:i}=e,a=n.fullTicket&&((d=t.selection)==null?void 0:d.kind)==="ticket",c=()=>n.setFullTicket(!1);return y.useEffect(()=>{if(!a)return;const u=f=>f.key==="Escape"&&!f.defaultPrevented&&n.setFullTicket(!1);return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[a,n]),a?s.jsxs(Fe,{className:"ticket-drawer","aria-label":"Full ticket",children:[s.jsx("button",{type:"button",className:"bubble-close","aria-label":"Close the full ticket",onClick:c,children:"×"}),s.jsx(jR,{api:t,sessions:e.sessions,bare:!0,attention:i.attention.view,done:e.done,onOpenChat:u=>n.openChat(u),onOpenDecision:n.openDecisions,onItem:u=>i.open(u),onReviewChange:i.handlers.openApprovals,onReviewBrief:i.handlers.openBrief})]}):null}function zL(e){return s.jsxs("section",{className:"panel trail-list agents-list",children:[s.jsx(yt,{title:"Agents at work",count:s.jsx("span",{className:"n mono-label",children:e.working.length})}),e.working.length===0&&s.jsx(Te,{children:"No agent is on this trail now"}),s.jsx("ul",{className:"trail-list-rows",children:e.working.map(t=>{const n=t.session,i=Fa(n==null?void 0:n.model),a=n?[{text:n.agent,strong:!0},i&&{text:i,tip:n.model},`step ${n.step} of ${n.total}`,n.stepLabel.toLowerCase(),Xe(e.now-n.startedAt)]:[{text:t.ticket.assignee??"An agent",strong:!0},"claimed, no live session"];return s.jsx(he,{as:"li",className:"agent-row",title:`${t.ticket.key} ${t.ticket.title}`,context:s.jsx(B,{parts:a}),trailing:n&&s.jsx(yy,{step:n.step,total:n.total,mini:!0}),onOpen:()=>e.onTicket(t.ticket.id),actions:n&&s.jsx(I,{size:"sm",onClick:()=>e.onOpenChat(n.id),children:"Chat"})},t.ticket.id)})})]})}function UL(e){return e.items.length?s.jsxs("div",{className:"other-trails",children:[s.jsx(yt,{title:"Other trails",count:s.jsx("span",{className:"n mono-label",children:e.items.length})}),s.jsx(bk,{view:{...e.view,items:e.items},snaps:e.snaps,pending:e.pending,currentMapId:e.currentMapId,handlers:e.handlers,onSnooze:e.onSnooze,onDismiss:e.onDismiss})]}):null}function WL(e){const t=e.items.slice(0,e.max),n=e.items.length-t.length;return t.length?s.jsxs("span",{className:"need-chips",children:[t.map(i=>s.jsx("button",{type:"button",className:pe("need-chip",e.selected===i.id&&"on"),title:i.title,onClick:()=>e.onOpen(i),children:JT(i,e.keyOf)},i.id)),n>0&&s.jsxs("button",{type:"button",className:"need-chip more",onClick:e.onMore,children:["+",n]})]}):null}function HL(e){const t=new Map(e.map(a=>[a.id,a])),n=new Map,i=(a,c)=>{var m;const d=n.get(a);if(d!==void 0)return d;if(c.has(a))return 0;c.add(a);const u=((m=t.get(a))==null?void 0:m.blockedBy.filter(g=>t.has(g)))??[],f=u.length?1+Math.max(...u.map(g=>i(g,c))):0;return n.set(a,f),f};return new Map(e.map(a=>[a.id,i(a.id,new Set)]))}function KL(e){const t=[...e.values()].filter(i=>i.tone!=="cancelled"),n=HL(t.map(i=>i.ticket));return t.map((i,a)=>({l:i,i:a,d:n.get(i.ticket.id)??0})).sort((i,a)=>i.d-a.d||i.i-a.i).map(({l:i})=>({id:i.ticket.id,key:i.ticket.key,title:i.ticket.title,tone:i.tone}))}function GL(e,t){const n=i=>e.filter(a=>a.tone===i).length;return{done:n("done"),total:e.length,working:n("working"),needs:t.length,waiting:n("waiting-agent"),notStarted:n("not-started")}}function VL(e){const t=[{n:e.working,text:`${e.working} working`},{n:e.needs,text:`${e.needs} need${e.needs===1?"s":""} you`,urgent:!0},{n:e.waiting,text:`${e.waiting} waiting for an agent`},{n:e.notStarted,text:`${e.notStarted} not started`}];return[{text:`${e.done} of ${e.total} done`},...t.filter(n=>n.n>0).map(({text:n,urgent:i})=>({text:n,urgent:i}))]}const Ng={done:"done",working:"an agent is on it",needs:"needs you","waiting-agent":"waiting for an agent","not-started":"not started"};function qL(e){return s.jsx("div",{className:"trail-segments",role:"list","aria-label":"Tickets on the trail",children:e.segments.map(t=>s.jsx("button",{type:"button",role:"listitem",className:pe("seg",`seg-${t.tone}`,e.selected===t.id&&"on"),title:`${t.key} ${t.title} · ${Ng[t.tone]}`,"aria-label":`${t.key} ${t.title}: ${Ng[t.tone]}`,onClick:()=>e.onSelect(t.id)},t.id))})}function QL(e){const t=e.more||e.fixed;return s.jsxs("div",{className:pe("trail-bar-zone",t&&"extended"),children:[s.jsxs(Fe,{className:"trail-bar",children:[s.jsx("span",{className:"t-label",children:"Trail"}),s.jsx(qL,{segments:e.segments,selected:e.selected,onSelect:e.onTicket}),s.jsx("span",{className:"trail-counts",children:VL(e.counts).map((n,i)=>s.jsxs("span",{className:pe(i===0&&"strong",n.urgent&&"urgent"),children:[i>0&&s.jsx("span",{className:"sep",children:" · "}),n.text]},n.text))}),!t&&s.jsx(WL,{items:e.needs,keyOf:e.keyOf,onOpen:e.onNeed,onMore:()=>e.onMore(!0),max:e.chips}),!e.fixed&&s.jsx(I,{size:"sm","aria-expanded":e.more,onClick:()=>e.onMore(!e.more),children:e.more?"Less":"More"})]}),t&&s.jsx("div",{className:"trail-lists",children:e.lists})]})}const YL=6;function JL(e,t){const n=e.filter(a=>a.tone==="waiting-agent").sort((a,c)=>(a.readySince??0)-(c.readySince??0)).map(a=>({ticket:a.ticket,context:`Waiting for an agent to pick it up · ${Xe(Math.max(0,t-(a.readySince??t)))}`})),i=e.filter(a=>a.waitsOnYours.length>0).map(a=>({ticket:a.ticket,context:`Waits on your ${a.waitsOnYours.join(", ")}`}));return[...n,...i].slice(0,YL)}function XL(e){const t=JL(e.live,e.now);return s.jsxs("section",{className:"panel trail-list upnext-list",children:[s.jsx(yt,{title:"Up next",count:s.jsx("span",{className:"n mono-label",children:t.length})}),t.length===0&&s.jsx(Te,{children:"Nothing ready"}),s.jsx("ul",{className:"trail-list-rows",children:t.map(n=>s.jsx(he,{as:"li",title:`${n.ticket.key} ${n.ticket.title}`,context:s.jsx(B,{parts:[n.context]}),onOpen:()=>e.onTicket(n.ticket.id)},n.ticket.id))})]})}const Vy="teamtrail.trail-bar.more";function ZL(){try{return localStorage.getItem(Vy)==="yes"}catch{return!1}}function eP(){const[e,t]=y.useState(ZL);return[e,i=>{t(i);try{localStorage.setItem(Vy,i?"yes":"no")}catch{}}]}function tP(e){const{api:t,nav:n,attn:i,trail:a}=e,[c,d]=eP(),u=gt(5e3),f=t.selection,m=[...a.live.values()],g=m.filter(S=>S.tone==="working"||S.tone==="needs"&&S.session),k=S=>n.select({kind:"ticket",id:S}),w=i.attention.view,b={...i.attention,view:w&&{...w,items:a.items}};return t.snap?s.jsx(QL,{segments:a.segments,counts:a.counts,needs:a.items,keyOf:a.keyOf,selected:(f==null?void 0:f.kind)==="ticket"?f.id:void 0,more:c,fixed:e.bp==="mobile",chips:e.bp==="wide"?3:2,onMore:d,onTicket:k,onNeed:i.open,lists:s.jsxs(s.Fragment,{children:[s.jsxs(Fe,{className:"trail-list needs-list",children:[s.jsx(t2,{activity:t.activity,snaps:t.allSnaps,currentMapId:t.mapId,attention:b,handlers:i.handlers,onOpenQuestion:S=>{const x=t.activity.pending.find(C=>C.sessionId===S);x&&n.openQuestion(x.id)},onOpenTicket:n.openTicket,brief:e.brief}),w&&s.jsx(UL,{view:w,items:a.elsewhere,snaps:t.allSnaps,pending:t.activity.pending,currentMapId:t.mapId,handlers:i.handlers,onSnooze:i.attention.snooze,onDismiss:i.attention.dismiss})]}),s.jsx(zL,{working:g,now:u,onTicket:k,onOpenChat:S=>n.openChat(S)}),s.jsx(XL,{live:m,now:u,onTicket:k})]})}):null}function nP(e,t){const[n,i]=y.useState(!1);return{open:()=>i(!0),startOver:d=>void t.actions.setArchived(!0).then(()=>i(bT(d))),dialog:n&&s.jsx(FR,{rt:e,seed:typeof n=="object"?n:void 0,onClose:()=>i(!1),onCreated:d=>t.actions.selectMap(d)})}}const sP=390;function $g(e){return e>900?sP:0}function iP(){return s.jsxs("defs",{children:[s.jsx("pattern",{id:"map-grid",width:"40",height:"40",patternUnits:"userSpaceOnUse",children:s.jsx("path",{d:"M40 0H0V40",fill:"none",stroke:"var(--map-grid)",strokeWidth:"1"})}),s.jsx("pattern",{id:"hatch-oos",width:"10",height:"10",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:s.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"10",stroke:"var(--line2)",strokeWidth:"1"})})]})}function Wu(e){return e.filter(t=>t.state!=="out-of-scope").map(t=>({x:t.x,y:t.y,w:_e,h:He}))}const ka=(e,t)=>`${e}>${t}`;function rP(e,t,n=[]){const i=new Map(e.tickets.map(c=>[c.id,c]));return{tickets:t.nodes.map(c=>{const d=i.get(c.id);return d?{...d,blockedBy:[...c.blockedBy,...c.removedEdges??[]]}:{id:c.id,key:"+",title:c.title,type:c.type,body:"",state:"open",blockedBy:c.blockedBy,comments:[],createdAt:e.map.updatedAt,updatedAt:e.map.updatedAt}}),marks:new Map(t.nodes.map(c=>[c.id,c.mark])),newEdges:new Set(t.nodes.flatMap(c=>c.newEdges.map(d=>ka(d,c.id)))),removedEdges:new Set(t.nodes.flatMap(c=>(c.removedEdges??[]).map(d=>ka(d,c.id)))),frozen:new Set(n)}}function oP(e,t){const n=ib({...e,tickets:t}),i=new Set;for(let a=1;a<n.length;a++)i.add(ka(n[a-1].id,n[a].id));return i}function ya(e){const t=ba[e.direction],n=t.sub-t.along,i=e.node.wrap,a=i&&i.sub>0?n:e.outer,c=i&&i.sub<i.subs-1?n:e.outer;return{before:a,after:c}}function aP(e){const{obstacles:t,from:n,to:i,clear:a}=e,c=t.flatMap(u=>[u.y-28,u.y+u.h+28]).filter(a),d=u=>Math.abs(u-n)+Math.abs(u-i);return c.reduce((u,f)=>d(f)<d(u)?f:u,c[0]??n)}const cP=6;function qy(e){const t=e.filter((a,c)=>c===0||a.x!==e[c-1].x||a.y!==e[c-1].y);let n=`M${t[0].x} ${t[0].y}`;for(let a=1;a<t.length-1;a++){const[c,d,u]=[t[a-1],t[a],t[a+1]],f=Math.min(cP,Cg(c,d)/2,Cg(d,u)/2),m=Tg(d,c,f),g=Tg(d,u,f);n+=`L${m.x} ${m.y}Q${d.x} ${d.y} ${g.x} ${g.y}`}const i=t[t.length-1];return`${n}L${i.x} ${i.y}`}function Cg(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function Tg(e,t,n){return{x:e.x+Math.sign(t.x-e.x)*n,y:e.y+Math.sign(t.y-e.y)*n}}function mi(e){const t=e.direction==="TB",n=d=>t?{x:d.y,y:d.x}:d,i=n(e.a),a=n(e.b),c=e.obstacles.map(d=>t?{x:d.y,y:d.x,w:d.h,h:d.w}:d);return qy(lP({a:i,b:a,obstacles:c,gap:e.gap,gapIn:e.gapIn??e.gap}).map(n))}function lP(e){const{a:t,b:n,obstacles:i,gap:a,gapIn:c}=e,d=i.filter(k=>k.x+k.w>t.x+1&&k.x<n.x-1),u=k=>!d.some(w=>k>w.y-8&&k<w.y+w.h+8),f=Math.min(t.x+a/2,(t.x+n.x)/2),m=Math.max(n.x-c/2,(t.x+n.x)/2);if(u(t.y))return[t,{x:m,y:t.y},{x:m,y:n.y},n];if(u(n.y))return[t,{x:f,y:t.y},{x:f,y:n.y},n];const g=aP({obstacles:d,from:t.y,to:n.y,clear:u});return[t,{x:f,y:t.y},{x:f,y:g},{x:m,y:g},{x:m,y:n.y},n]}function dP(e){const{direction:t,from:n,to:i,cards:a}=e,c=ba[t],d=c.layer-c.along,u=ya({direction:t,node:n,outer:d}).after,f=ya({direction:t,node:i,outer:d}).before;if(t==="LR"){const k={x:n.x+_e,y:n.y+He/2},w={x:i.x,y:i.y+He/2};return mi({direction:t,a:k,b:w,obstacles:a,gap:u,gapIn:f})}const m={x:n.x+_e/2,y:n.y+He},g={x:i.x+_e/2,y:i.y};return mi({direction:t,a:m,b:g,obstacles:a,gap:u,gapIn:f})}const Eg=e=>e.ticket.state==="closed"&&e.ticket.closeReason==="completed";function uP(e){const{from:t,to:n,direction:i}=e,c=["edge",t.ticket.state!=="open"?"edge-done":"edge-open"];return Eg(t)&&Eg(n)&&c.push("edge-travelled"),e.critical&&c.push("edge-critical"),e.added&&c.push("edge-added"),e.removed&&c.push("edge-removed"),s.jsx("path",{className:c.join(" "),d:dP({direction:i,from:t,to:n,cards:e.cards})})}function hP(e){const{snap:t,tickets:n,direction:i,preview:a}=e,c=y.useMemo(()=>oP(t,n),[t,n]),d=y.useMemo(()=>Wu(e.nodes),[e.nodes]);return e.edges.map(({from:u,to:f})=>{const m=ka(u.ticket.id,f.ticket.id);return s.jsx(uP,{from:u,to:f,direction:i,cards:d,critical:c.has(m),added:a==null?void 0:a.newEdges.has(m),removed:a==null?void 0:a.removedEdges.has(m)},m)})}function fP(e,t,n){return!!t&&e.state==="frontier"&&!n}const Hu=24,mP=13,pP=9.5;function gP(e){const t=e.guide;return s.jsx("g",{className:"meta",transform:`translate(${Hu} ${e.y})`,children:e.chips.map((n,i)=>{const a=n.kind==="guide"?t:void 0;return s.jsxs("g",{className:pe("card-chip",n.kind,n.kind==="state"&&e.tone,(a==null?void 0:a.off)&&"off"),"data-guide-id":a==null?void 0:a.id,transform:`translate(${n.x} 0)`,children:[a&&s.jsx("title",{children:a.tip}),s.jsx("rect",{width:n.w,height:mP,rx:3}),s.jsx("text",{x:(n.w-n.textW)/2,y:pP,textLength:n.textW,lengthAdjust:"spacingAndGlyphs",children:n.text})]},i)})})}function vP(e,t){return e.length?e.length>2?`waits on ${e.length} tickets`:`waits on ${e.map(i=>t.includes(i)?`your ${i}`:i).join(", ")}`:void 0}const Qy=5,kP={sans:"9.5px 'Figtree Variable', system-ui, sans-serif",mono:"8.55px 'JetBrains Mono Variable', ui-monospace, monospace"};let hr;function yP(){if(hr!==void 0)return hr;try{hr=typeof document>"u"?null:document.createElement("canvas").getContext("2d")}catch{hr=null}return hr}function wP(e,t="sans"){const n=yP();return n?(n.font=kP[t],n.measureText(e).width*1.04):e.length*Qy}const Ag=4,Rg=3,xP=6;function jP(e){var k;const t=_e-Hu-8-(e.reserve??0),n=((k=e.state)==null?void 0:k.split(" · "))??[],i=[{kind:"key",text:e.key},...e.type?[{kind:"type",text:e.type}]:[],...e.guide===void 0?[]:[{kind:"guide",text:e.guide}],...n.map(w=>({kind:"state",text:w})),...e.needsYou?[{kind:"needs",text:"needs you"}]:[]],a=t-i.length*2*Ag-(i.length-1)*Rg,c=w=>wP(w.text,w.kind==="key"?"mono":"sans"),d=i.filter(w=>w.kind!=="guide").reduce((w,b)=>w+c(b),0),u=Math.max(xP,Math.floor((a-d)/Qy)),f=i.map(w=>w.kind==="guide"?{...w,text:K2(w.text,u)}:w),m=Math.min(1,a/f.reduce((w,b)=>w+c(b),0));e.onScale&&e.onScale(m);let g=0;return f.map(w=>{const b=c(w)*m,S={...w,x:g,w:b+2*Ag,textW:b};return g+=S.w+Rg,S})}function bP(e,t,n){return{text:[e.agent,n,t?`${e.step}/${e.total}`:void 0].filter(Boolean).join(" · "),tone:"agent"}}function SP(e){const{n:t,session:n}=e,i=t.ticket.assignee;return e.waiting?{text:"waiting on you",tone:"urgent"}:e.need?{text:e.need,tone:"urgent"}:e.stalled?{text:`stalled · ${i}`,tone:"warn"}:e.brief?{text:"waits on brief",tone:"warn"}:e.wait?{text:`needs ${e.wait}`,tone:"warn"}:n?bP(n,e.step,e.model):t.state==="claimed"?{text:i??"working",tone:"agent"}:t.state==="verifying"?{text:"checks running",tone:"agent"}:e.readyFor!==void 0?{text:`waiting for an agent · ${e.readyFor}`,tone:"wait"}:e.waitsOn?{text:e.waitsOn,tone:"waits"}:t.state==="decided"&&e.verified?{text:"verified",tone:"verified"}:{text:C1[t.state],tone:""}}function NP(e){var b;const{n:t,live:n,marked:i}=e,a=t.ticket,c=n==null?void 0:n.items[0],d=t.state==="frontier"?n==null?void 0:n.readySince:void 0,u=d===void 0?void 0:Xe(Math.max(0,e.now-d)),f=n&&vP(n.waitsOn,n.waitsOnYours),m=S=>i?void 0:SP({n:t,session:n==null?void 0:n.session,waiting:e.waiting,need:c&&YT(c),stalled:e.stalled,brief:e.brief,wait:e.wait,step:!e.guide,model:S,readyFor:u,waitsOn:f,verified:e.verified}),g=S=>{let x=1;const C=m(S);return{chips:jP({key:a.key,type:(C==null?void 0:C.tone)==="wait"||(C==null?void 0:C.tone)==="waits"?void 0:En[a.type],guide:e.guide,state:C==null?void 0:C.text,needsYou:e.needsYou&&!c,reserve:e.reserve,onScale:P=>x=P}),tone:C==null?void 0:C.tone,scale:x}},k=Fa((b=n==null?void 0:n.session)==null?void 0:b.model),w=k?g(k):void 0;return w&&w.scale>=1?w:g()}function $P(e,t,n){const i=e.state==="frontier"||e.state==="rework";if(!(!t||n||e.ticket.assignee||!i))return t}function CP(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&&t.push("stalled"),e.mark&&t.push(`mark-${e.mark}`),e.frozen&&t.push("frozen"),e.pickUp&&t.push("pick-up"),t.join(" ")}function TP({wait:e,session:t}){return e?s.jsx("title",{children:`Needs a ${e} model: no connected agent runs one`}):t?s.jsx("title",{children:`${t.agent} · step ${t.step}/${t.total} · ${t.stepLabel.toLowerCase()}`}):null}const EP={claimed:"working",verifying:"working",frontier:"ready",blocked:"backlog",parked:"backlog",decided:"done","out-of-scope":"cancelled",rework:"attention",held:"attention"};function AP(e){const t=EP[e.state];return t==="done"||t==="cancelled"?t:e.attention?"attention":e.live?"working":t}function RP({mark:e,frozen:t}){const n=e&&e!=="unchanged"&&e!=="cancelled"?e:void 0;return s.jsxs(s.Fragment,{children:[e==="cancelled"&&s.jsx("line",{className:"strike",x1:8,y1:He/2,x2:_e-8,y2:He/2}),n&&s.jsx("text",{className:"reroute-tag",x:_e-8,y:He-7,textAnchor:"end",children:n}),t&&s.jsx("text",{className:"freeze",x:_e-(n?58:8),y:He-7,textAnchor:"end",children:"❄"})]})}function Yy(e){const{tone:t,cy:n}=e;if(t==="done")return s.jsx("path",{className:`dot dot-done${e.verified?" dot-verified":""}`,d:`M10 ${n}l2.5 2.5 4.5 -5`});if(e.spin)return s.jsx("circle",{className:"dot dot-spin",cx:13,cy:n,r:4.5});const i=s.jsx("circle",{className:`dot dot-${t}`,cx:13,cy:n,r:t==="backlog"?3:3.5});return e.pulse?s.jsxs(s.Fragment,{children:[s.jsx("circle",{className:"dot-pulse",cx:13,cy:n,r:3.5}),i]}):i}const bd=8;function IP({step:e,total:t}){const n=_e-bd*2,i=t>0?Math.max(0,Math.min(1,(e-.5)/t)):0;return s.jsxs("g",{className:"step-bar","aria-hidden":"true",children:[s.jsx("rect",{className:"step-track",x:bd,y:3,width:n,height:2.5,rx:1}),s.jsx("rect",{className:"step-fill",x:bd,y:3,width:n*i,height:2.5,rx:1})]})}function MP(e,t,n=2){const i=e.split(/\s+/),a=[];let c="";for(const d of i)(c+" "+d).trim().length>t?(a.push(c.trim()),c=d):c+=" "+d;if(a.push(c.trim()),a.length>n){const d=a.slice(0,n);return d[n-1]=d[n-1].slice(0,t-1)+"…",d}return a}const OP=26;function LP({n:e,live:t,now:n,stalled:i,flag:a,selected:c,onSelect:d,mark:u,frozen:f,needs:m,verified:g,briefHeld:k}){const w=e.ticket,b=t==null?void 0:t.session,S=MP(w.title,OP),x=pi(w)==="hitl",C=!!(b!=null&&b.waitingOn),N=!!u&&u!=="unchanged",P=$P(e,m,!!b),D=fP(e,k,!!b),M=jE(hv(w).find(be=>{var de;return!((de=w.guidesRemoved)!=null&&de.includes(be))})),H=x&&!N&&(w.type==="task"||w.type==="execute"),_=PP(u,f),Y=NP({n:e,live:t,now:n,marked:N,waiting:C,stalled:i,brief:D,wait:P,verified:g,needsYou:H,reserve:_,guide:M==null?void 0:M.name}),re=C||(t==null?void 0:t.tone)==="needs",q=[re,i,D,P,H&&e.state==="frontier"].some(Boolean),Z=AP({state:e.state,live:!!b,attention:q}),Ae=(t==null?void 0:t.tone)==="waiting-agent"&&!N&&!f,ye=S.length>1?19:24;return s.jsxs("g",{className:CP({n:e,tone:Z,hitl:x,selected:c,live:!!b,waiting:re,stalled:i,mark:u,frozen:f,pickUp:Ae}),style:{transform:`translate(${e.x}px, ${e.y}px)`},"data-ticket":w.key,onClick:be=>{be.stopPropagation(),d({kind:"ticket",id:w.id})},children:[s.jsx(TP,{wait:P,session:b}),s.jsx("rect",{className:"ring",x:-3.5,y:-3.5,width:_e+7,height:He+7,rx:9}),s.jsx("rect",{className:"card",x:.5,y:.5,width:_e-1,height:He-1,rx:6}),b&&s.jsx(IP,{step:b.step,total:b.total}),s.jsx(Yy,{tone:Z,cy:ye-4,verified:g,spin:Ae,pulse:!!b&&!C}),S.map((be,de)=>s.jsx("text",{className:"title",x:Hu,y:ye+de*14,children:be},de)),s.jsx(gP,{chips:Y.chips,y:ye+S.length*14-8,tone:Y.tone,guide:M}),a&&s.jsx("circle",{className:`pr-flag-dot ${a}`,cx:_e-2,cy:2,r:4}),s.jsx(RP,{mark:u,frozen:f})]})}function PP(e,t){return(e&&e!=="unchanged"&&e!=="cancelled"?44:0)+(t?12:0)}function Jy(e){const{groups:t,nodes:n,ends:i}=e,a=t.filter((u,f)=>{const m=n.filter(g=>{var k;return((k=g.wrap)==null?void 0:k.group)===f});return m.length>0&&m.every(g=>i.includes(g))}),c=new Set(a.map(u=>t.indexOf(u))),d=i.filter(u=>u.wrap===void 0||!c.has(u.wrap.group));return{whole:a,single:d}}const Ig=16,Mg=8;function Xy(e){const{group:t,side:n}=e,i=e.direction==="TB",a=i?{x:t.y,y:t.x,w:t.h,h:t.w}:t,c=n==="before"?a.x-Ig:a.x+a.w+Ig,d=n==="before"?c+Mg:c-Mg,u=m=>i?{x:m.y,y:m.x}:m,f=[{x:d,y:a.y},{x:c,y:a.y},{x:c,y:a.y+a.h},{x:d,y:a.y+a.h}].map(u);return{d:qy(f),at:u({x:c,y:a.y+a.h/2})}}const ci=62,li=26,tu={LR:{x:130,y:0},TB:{x:0,y:84}},DP={LR:96,TB:48};function _P(e,t){return t?tu[e]:{x:0,y:0}}function BP(e){const{direction:t,nodes:n,groups:i}=e,a=n.filter(S=>S.state!=="out-of-scope"&&!S.ticket.blockedBy.some(x=>n.some(C=>C.ticket.id===x))),{whole:c,single:d}=Jy({groups:i,nodes:n,ends:a}),u=Wu(n),f=DP[t],m=t==="LR"?{x:-tu.LR.x+20,y:e.graphH/2-li/2}:{x:e.width/2-ci/2,y:-tu.TB.y+16},g=t==="LR"?{x:m.x+ci,y:m.y+li/2}:{x:m.x+ci/2,y:m.y+li},k=S=>t==="LR"?{x:S.x,y:S.y+He/2}:{x:S.x+_e/2,y:S.y},w=d.map(S=>{const x=ya({direction:t,node:S,outer:f}).before;return mi({direction:t,a:g,b:k(S),obstacles:u,gap:f,gapIn:x})}),b=c.flatMap(S=>{const x=Xy({direction:t,group:S,side:"before"});return[mi({direction:t,a:g,b:x.at,obstacles:u,gap:f,gapIn:f-32}),x.d]});return{...m,edges:[...w,...b]}}function FP(e){const{tone:t}=e,n=t==="passed";return s.jsxs(s.Fragment,{children:[e.edges.map(i=>s.jsx("path",{className:pe("edge",n?"edge-done":"edge-open"),d:i},i)),s.jsxs("g",{className:pe("node main-mark",`main-${t}`,t==="needs"&&"waiting",e.selected&&"sel"),transform:`translate(${e.x} ${e.y})`,role:"button",tabIndex:0,"aria-label":"Checks on main",onClick:i=>{i.stopPropagation(),e.onSelect()},onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&e.onSelect()},children:[s.jsx("rect",{className:"ring",x:-3.5,y:-3.5,width:ci+7,height:li+7,rx:8}),s.jsx("rect",{className:"card",x:.5,y:.5,width:ci-1,height:li-1,rx:5}),n?s.jsx("path",{className:"dot dot-done dot-verified",d:"M8 13l2.5 2.5 4.5 -5"}):s.jsx("circle",{className:pe("dot",`main-dot-${t}`),cx:11,cy:13,r:3.5}),s.jsx("text",{className:"main-label",x:20,y:17,children:"main"})]})]})}const zP={LR:96,TB:48};function UP(e){if(e.direction==="LR"){const n=e.width+96;return{x:n,y:e.graphH/2,right:n+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 WP(e,t){const{direction:n}=e,i=new Set(e.edges.map(b=>b.from)),a=e.nodes.filter(b=>b.state!=="out-of-scope"&&!i.has(b)),{whole:c,single:d}=Jy({groups:e.groups,nodes:e.nodes,ends:a}),u=Wu(e.nodes),f=zP[n],m=n==="LR"?{x:t.x-30,y:t.y}:{x:t.x,y:t.y-30},g=b=>n==="LR"?{x:b.x+_e,y:b.y+He/2}:{x:b.x+_e/2,y:b.y+He},k=d.map(b=>{const S=ya({direction:n,node:b,outer:f}).after;return mi({direction:n,a:g(b),b:m,obstacles:u,gap:S,gapIn:f})}),w=c.flatMap(b=>{const S=Xy({direction:n,group:b,side:"after"});return[S.d,mi({direction:n,a:S.at,b:m,obstacles:u,gap:f-32,gapIn:f})]});return[...k,...w]}function Zy(){return s.jsxs(s.Fragment,{children:[s.jsx("path",{className:"flag-ground",d:"M-17 18 C-12 17 -5 17 1 18"}),s.jsx("path",{className:"flag-pole",d:"M-8 18 C-8.6 6 -7.6 -6 -8 -18"}),s.jsx("path",{className:"flag-cloth",d:"M-8 -18 C-1 -16 6 -13 15 -10 C6 -7.5 -1 -5.5 -8 -3 Z"})]})}function HP(e){const{x:t,y:n,text:i,done:a,onSelect:c}=e,d=(i==null?void 0:i.trim())||"Where this trail ends",u=a&&a.kind!=="not-done",f=u?`Destination reached · ${a.reason}
|
|
166
|
+
${d}`:`Destination
|
|
167
|
+
${d}`,m=(a==null?void 0:a.kind)==="unverified"&&a.together.kind==="failed",g=pe("destination",u&&`reached ${a.kind}`,m&&"failing",e.selected&&"sel");return s.jsxs("g",{className:g,transform:`translate(${t} ${n})`,"aria-label":f,"data-tip":f,tabIndex:0,role:c?"button":void 0,onClick:k=>{c&&(k.stopPropagation(),c())},onKeyDown:k=>{c&&(k.key==="Enter"||k.key===" ")&&c()},children:[s.jsx("rect",{className:"x-hit",x:-24,y:-24,width:48,height:48}),u?s.jsx(Zy,{}):s.jsxs(s.Fragment,{children:[s.jsx("path",{className:"x-stroke",d:"M-15 -16 C-9 -10 2 4 16 17"}),s.jsx("path",{className:"x-stroke",d:"M17 -15 C8 -8 -6 5 -16 17"})]})]})}function KP({trails:e,travelled:t}){const n=t?"edge edge-done edge-travelled edge-destination":"edge edge-open edge-destination";return e.map(i=>s.jsx("path",{className:n,d:i},i))}function GP(e){const{laid:t,spot:n,done:i}=e,a=!!i&&i.kind!=="not-done";return s.jsxs(s.Fragment,{children:[s.jsx(KP,{trails:WP(t,n),travelled:a}),t.nodes.length>0&&s.jsx(HP,{x:n.x,y:n.y,text:e.text,done:i,selected:e.selected,onSelect:e.onSelect})]})}const wa=.95;function VP(e,t){const n=new Map(e.map(u=>[u.ticket.id,u])),i=t.map(u=>n.get(u)).filter(u=>!!u),a=e.filter(u=>u.state==="claimed"||u.state==="verifying"),c=[...i,...a.filter(u=>!i.includes(u))];if(c.length)return c;const d=e.find(u=>u.state==="frontier")??e[0];return d?[d]:[]}function Og(e,t){return{left:Math.min(...e.map(n=>n.x))+t,top:Math.min(...e.map(n=>n.y))+t,right:Math.max(...e.map(n=>n.x+_e))+t,bottom:Math.max(...e.map(n=>n.y+He))+t}}function qP(e){const{fit:t,nodes:n,size:i,pad:a}=e;if(t.k>=wa)return t;const c=VP(n,e.focus??[]);if(!c.length)return t;const d=wa,u=Math.max(i.w/2,i.w-(e.room??0)),f=Og(c,a),g=(f.right-f.left)*d<=u-32&&(f.bottom-f.top)*d<=i.h-32?f:Og(c.slice(0,1),a);return{k:d,x:u/2-(g.left+g.right)/2*d,y:i.h/2-(g.top+g.bottom)/2*d}}function QP(e){const{y:t,width:n,height:i}=e,a=e.nodes.filter(c=>c.state==="out-of-scope").length;return a?s.jsxs("g",{className:"quarantine",children:[s.jsx("rect",{x:-20,y:t-30,width:n+40,height:i+18,fill:"url(#hatch-oos)"}),s.jsx("line",{x1:-20,y1:t-30,x2:n+20,y2:t-30}),s.jsxs("text",{x:-12,y:t-12,children:["Out of scope · ",a]})]}):null}const it=280,Lg=4,YP=220,ri=e=>Math.round(e/Lg)*Lg;function JP(e){let t=2166136261;for(const n of e)t=Math.imul(t^n.charCodeAt(0),16777619);return()=>{t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}function Sd(e,t,n,i){return Array.from({length:6},()=>{const a=i*(.5+e()*.7),c=i*(.3+e()*.4);return{x:ri(t+(e()-.5)*i*.8-a/2),y:ri(n+(e()-.5)*i*.5-c/2),w:ri(a),h:ri(c)}})}function XP(e){const{width:t,height:n,nodes:i}=e,a=JP(e.seed),c=(w,b)=>w+a()*(b-w),d=(w,b)=>!i.some(S=>w>S.x-52&&w<S.x+_e+28&&b>S.y-52&&b<S.y+He+28),u=(t+it*2)*(n+it*2),f=Array.from({length:Math.round(u/9e4)},()=>Sd(a,c(-it,t+it),c(-it,n+it),c(160,360))).flat(),m=[...Sd(a,t+it*.55,n+it*.55,300),...Sd(a,-it*.5,-it*.45,220)],g=[],k=(w,b,S)=>{g.length<YP&&d(b,S)&&g.push({sprite:w,x:ri(b),y:ri(S)})};for(let w=0;w<Math.round(u/3e4);w++){const b=c(-it,t+it),S=c(-it,n+it),x=3+Math.floor(a()*5);for(let C=0;C<x;C++)k(a()<.65?"pine":"oak",b+c(-70,70),S+c(-44,44))}for(let w=0;w<Math.round(u/45e3);w++)k(a()<.4?"rock":"tuft",c(-it,t+it),c(-it,n+it));return g.sort((w,b)=>w.y-b.y),{grass:f,water:m,items:g}}const ew={pine:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"16",y:"30",width:"4",height:"10",fill:"var(--map-trunk)"}),s.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H0l9-11H5l8-10H9z",fill:"var(--map-pine)"}),s.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H18z",fill:"var(--map-pine2)"})]}),oak:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"16",y:"24",width:"4",height:"12",fill:"var(--map-trunk)"}),s.jsx("circle",{cx:"18",cy:"14",r:"14",fill:"var(--map-oak)"}),s.jsx("circle",{cx:"10",cy:"17",r:"8",fill:"var(--map-oak)"}),s.jsx("circle",{cx:"26",cy:"17",r:"8",fill:"var(--map-oak)"}),s.jsx("circle",{cx:"22",cy:"10",r:"6",fill:"var(--map-oak2)"})]}),rock:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M1 16Q2 6 10 3Q18-1 23 6Q28 11 27 16z",fill:"var(--map-rock)"}),s.jsx("path",{d:"M15 16Q15 8 19 4Q25 8 27 16z",fill:"var(--map-rock2)"})]}),tuft:s.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 ZP({name:e}){return s.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:ew[e]})}const e3=Object.keys(ew),t3=y.memo(function(t){const{seed:n,width:i,height:a,nodes:c}=t,d=y.useMemo(()=>XP({seed:n,width:i,height:a,nodes:c}),[n,i,a,c]);return s.jsxs("g",{className:"terrain","aria-hidden":"true",children:[s.jsx("defs",{children:e3.map(u=>s.jsx(ZP,{name:u},u))}),d.grass.map((u,f)=>s.jsx("rect",{x:u.x,y:u.y,width:u.w,height:u.h,fill:"var(--map-grass)"},f)),d.water.map((u,f)=>s.jsx("rect",{x:u.x,y:u.y,width:u.w,height:u.h,fill:"var(--map-water)"},f)),s.jsx("rect",{x:-4e3,y:-4e3,width:i+8e3,height:a+8e3,fill:"url(#map-grid)"}),d.items.map((u,f)=>s.jsx("use",{href:`#terrain-${u.sprite}`,x:u.x,y:u.y},f))]})});function tw(e){var i;const t=(i=Lu())==null?void 0:i.waiting,n=WA(e);return a=>{var c;return{needs:(c=t==null?void 0:t.find(d=>d.mapId===(e==null?void 0:e.map.id)&&d.ticketId===a.id))==null?void 0:c.tier,briefHeld:n(a)}}}const n3=380;function s3(e){const{selId:t,size:n}=e,i=y.useRef(e);i.current=e;const a=y.useRef(),c=n.w>0;y.useEffect(()=>{t||(a.current=void 0);const{nodes:d,pad:u,view:f,setView:m,onFocus:g,room:k}=i.current,w=t?d.find(M=>M.ticket.id===t):void 0;if(!w||!c||a.current===t||(a.current=t,i3({n:w,pad:u,view:f,size:{w:n.w-k,h:n.h}})))return;g();const b=Math.min(1.4,Math.max(f.k,wa)),S=(n.w-k)/2,x={k:b,x:S-(u+w.x+_e/2)*b,y:n.h/2-(u+w.y+He/2)*b};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return m(x);const C=f,N=performance.now();let P=0;const D=M=>{const H=Math.min(1,(M-N)/n3),_=1-(1-H)**3;m({k:C.k+(x.k-C.k)*_,x:C.x+(x.x-C.x)*_,y:C.y+(x.y-C.y)*_}),H<1&&(P=requestAnimationFrame(D))};return P=requestAnimationFrame(D),()=>cancelAnimationFrame(P)},[t,c])}function i3(e){const{n:t,pad:n,view:i,size:a}=e,c=i.x+(n+t.x)*i.k,d=i.y+(n+t.y)*i.k,u=c+_e*i.k,f=d+He*i.k;return i.k>=wa&&c>=16&&d>=16&&u<=a.w-16&&f<=a.h-16}function nw(e,t,n){const i=Math.min(3,Math.max(.2,t));return{k:i,x:n.x-(n.x-e.x)*i/e.k,y:n.y-(n.y-e.y)*i/e.k}}function r3(e){const{box:t,view:n,setView:i}=e,a=y.useRef(new Map),c=y.useRef(null),d=g=>{const k=t.current.getBoundingClientRect();return{x:g.clientX-k.left,y:g.clientY-k.top}},u=()=>{var b;const g=[...a.current.values()],k=g.length>1?{x:(g[0].x+g[1].x)/2,y:(g[0].y+g[1].y)/2}:g[0],w=g.length>1?Math.hypot(g[0].x-g[1].x,g[0].y-g[1].y):0;c.current={view:n,dist:w,mid:k,moved:((b=c.current)==null?void 0:b.moved)??!1}},f=(g,k)=>{const w={x:(k[0].x+k[1].x)/2,y:(k[0].y+k[1].y)/2},b=Math.hypot(k[0].x-k[1].x,k[0].y-k[1].y),S=nw(g.view,g.view.k*b/(g.dist||b),g.mid);i({...S,x:S.x+w.x-g.mid.x,y:S.y+w.y-g.mid.y}),g.moved=!0},m=(g,k,w)=>{var x;const b=w.x-k.mid.x,S=w.y-k.mid.y;return!k.moved&&Math.hypot(b,S)<5?!1:(k.moved||(x=t.current)==null||x.setPointerCapture(g.pointerId),k.moved=!0,i({...k.view,x:k.view.x+b,y:k.view.y+S}),!0)};return{onPointerDown:g=>{a.current.set(g.pointerId,d(g)),a.current.size===1&&(c.current=null),u()},onPointerMove:g=>{const k=c.current;if(!a.current.has(g.pointerId)||!k)return;a.current.set(g.pointerId,d(g));const w=[...a.current.values()];if(w.length>1)f(k,w);else if(!m(g,k,w[0]))return;e.onTouch()},onPointerUp:g=>{a.current.delete(g.pointerId),a.current.size&&u()},onPointerCancel:g=>void a.current.delete(g.pointerId),onClickCapture:g=>{var k;(k=c.current)!=null&&k.moved&&(g.stopPropagation(),c.current=null)}}}const Wt=32,o3=1.8;function a3(e){const{tickets:t,mode:n,size:i}=e,a=y.useMemo(()=>{const k=Qm(t,"LR",n),w=Qm(t,"TB",n),b=S=>Math.min(i.w/(S.width+Wt*2),i.h/(S.height+Wt*2+16));return b(k)*o3>=b(w)?k:w},[t,n,i.w,i.h]),c=(k,w)=>Math.min(1.25,Math.max(e.minFit??0,Math.min(i.w/k,i.h/w))),d=y.useMemo(()=>{const k=a.width+Wt*2,w=a.height+Wt*2+16,S=a.nodes.some(C=>C.state==="out-of-scope")&&i.h?Math.max(0,i.h/c(k,w)-w):0;if(!S)return{...a,slack:S};const x=new Map(a.nodes.map(C=>[C,{...C,y:C.y+(C.state==="out-of-scope"?S:S/2)}]));return{...a,slack:S,nodes:[...x.values()],edges:a.edges.map(C=>({from:x.get(C.from),to:x.get(C.to)})),groups:a.groups.map(C=>({...C,y:C.y+S/2})),quarantineY:a.quarantineY+S,height:a.height+S}},[a,i.w,i.h,e.minFit]),u=UP(d),f=_P(d.direction,e.main),m=u.right+Wt*2+f.x,g=u.bottom+Wt*2+16+f.y;return{L:d,destination:u,room:f,W:m,H:g,fitK:c}}function c3(e,t){const n=y.useRef(t);n.current=t,y.useEffect(()=>{const i=e.current;if(!i)return;const a=m=>{const g=i.getBoundingClientRect();return{x:m.clientX-g.left,y:m.clientY-g.top}},c=m=>{m.preventDefault();const g=m.ctrlKey?.01:.0015;n.current(Math.exp(-m.deltaY*g),a(m))};let d=1;const u=m=>{m.preventDefault(),d=1},f=m=>{m.preventDefault();const g=m;n.current(g.scale/d,a(g)),d=g.scale};return i.addEventListener("wheel",c,{passive:!1}),i.addEventListener("gesturestart",u,{passive:!1}),i.addEventListener("gesturechange",f,{passive:!1}),()=>{i.removeEventListener("wheel",c),i.removeEventListener("gesturestart",u),i.removeEventListener("gesturechange",f)}},[e])}function l3(e){var me,Se;const{snap:t,selection:n,onSelect:i,preview:a}=e,c=e.proofs??{},d=(a==null?void 0:a.tickets)??t.tickets,u=y.useRef(null),[f,m]=y.useState({w:0,h:0});y.useEffect(()=>{const z=u.current;if(!z)return;const Q=new ResizeObserver(([U])=>m({w:U.contentRect.width,h:U.contentRect.height}));return Q.observe(z),()=>Q.disconnect()},[]);const{L:g,destination:k,room:w,W:b,H:S,fitK:x}=a3({tickets:d,mode:t.map.mode,size:f,minFit:e.minFit,main:!!e.main}),C=y.useMemo(()=>e.main?BP({direction:g.direction,nodes:g.nodes,groups:g.groups,graphH:g.graphH,width:g.width}):null,[e.main,g]),N=y.useMemo(()=>g.nodes.map(z=>({...z,x:z.x+w.x,y:z.y+w.y})),[g.nodes,w]),P={x:Wt+w.x,y:Wt+w.y},D=()=>{const z=x(b,S);return{k:z,x:Math.max(0,(f.w-b*z)/2),y:Math.max(0,(f.h-S*z)/2)}},[M,H]=y.useState({k:1,x:0,y:0}),_=y.useRef(!1);y.useEffect(()=>{_.current=!1},[t.map.id]),y.useEffect(()=>{!_.current&&f.w&&H(qP({fit:D(),nodes:N,size:f,pad:Wt,focus:e.focus,room:$g(f.w)}))},[f.w,f.h,b,S,t.map.id,(me=e.focus)==null?void 0:me[0]]);const Y=r3({box:u,view:M,setView:H,onTouch:()=>_.current=!0});c3(u,(z,Q)=>{_.current=!0,H(U=>nw(U,U.k*z,Q))});const re=gt(5e3),q=ku(e.leases,t.map.id),Z=$r(),Ae=tw(t),ye=(n==null?void 0:n.kind)==="ticket"?n.id:void 0;s3({selId:ye,nodes:N,size:f,pad:Wt,view:M,setView:H,room:$g(f.w),onFocus:()=>_.current=!0});const be=z=>{const Q=z==="main"?C&&{x:C.x,y:C.y,w:ci,h:li}:de(z)??Re(z);if(!Q)return;const U=M.x+(P.x+Q.x)*M.k,E=M.y+(P.y+Q.y)*M.k;return{left:U,top:E,right:U+Q.w*M.k,bottom:E+Q.h*M.k}},de=z=>z==="destination"?{x:k.x-24,y:k.y-24,w:48,h:48}:void 0,Re=z=>{const Q=g.nodes.find(U=>U.ticket.id===z);return Q&&{x:Q.x,y:Q.y,w:_e,h:He}};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"graph-box",ref:u,...Y,children:[s.jsxs("svg",{className:"graph",width:f.w,height:f.h,onClick:()=>i(null),children:[s.jsx(iP,{}),s.jsxs("g",{transform:`translate(${M.x} ${M.y}) scale(${M.k})`,children:[s.jsx("g",{transform:`translate(${Wt} ${Wt})`,children:s.jsx(t3,{seed:t.map.id,width:b,height:S,nodes:N})}),s.jsxs("g",{transform:`translate(${P.x} ${P.y})`,children:[s.jsx(QP,{y:g.quarantineY,width:g.width,height:g.quarantineH,nodes:g.nodes}),s.jsx(hP,{snap:t,tickets:d,direction:g.direction,nodes:g.nodes,edges:g.edges,preview:a}),s.jsx(GP,{laid:g,spot:k,text:t.map.sections.destination,done:e.done,selected:(n==null?void 0:n.kind)==="together",onSelect:()=>i({kind:"together"})}),C&&e.main&&s.jsx(FP,{...C,tone:e.main,selected:(n==null?void 0:n.kind)==="main",onSelect:()=>i({kind:"main"})}),g.nodes.map(z=>{const Q=q.get(z.ticket.id);return s.jsx(LP,{n:z,live:e.live.get(z.ticket.id),now:re,stalled:!!Q&&Ts(Q,re)!=="live",flag:s$(ns.ticket(Z,t.map.id,z.ticket.id)),selected:ye===z.ticket.id,onSelect:i,mark:a==null?void 0:a.marks.get(z.ticket.id),frozen:a==null?void 0:a.frozen.has(z.ticket.id),...Ae(z.ticket),verified:c[z.ticket.id]===void 0?void 0:c[z.ticket.id]==="verified"},z.ticket.id)})]})]})]}),s.jsx("button",{className:"btn sm fit-btn","data-tip":"Fit the whole trail in view",onPointerDown:z=>z.stopPropagation(),onClick:z=>{z.stopPropagation(),_.current=!0,H(D())},children:"Fit"})]}),(Se=e.overlay)==null?void 0:Se.call(e,be,f)]})}const d3=[{tone:"working",text:"An agent is on it"},{tone:"attention",urgent:!0,text:"Needs you"},{tone:"attention",text:"Held up"},{tone:"ready",spin:!0,text:"Waiting for an agent"},{tone:"backlog",text:"Not started yet"},{tone:"done",verified:!0,text:"Done and verified"},{tone:"done",text:"Done, not verified"},{tone:"cancelled",text:"Ruled out"}];function u3(){const[e,t]=y.useState(!1);return s.jsxs("div",{className:"map-legend",onPointerDown:n=>n.stopPropagation(),onClick:n=>n.stopPropagation(),children:[e&&s.jsx("ul",{className:"map-legend-list",children:d3.map(n=>s.jsxs("li",{children:[s.jsx("svg",{className:n.urgent?"node waiting":"node",width:"22",height:"16",viewBox:"4 0 18 16","aria-hidden":"true",children:s.jsx(Yy,{tone:n.tone,cy:8,verified:n.verified,spin:n.spin})}),n.text]},n.text))}),s.jsx("button",{type:"button",className:"btn sm","aria-expanded":e,onClick:()=>t(!e),children:e?"Hide legend":"Legend"})]})}function h3(e,t){const[n,i]=y.useState({statuses:{}});return Le({view:e,version:t,load:async()=>{if(!e)return{mapId:e,statuses:{}};const a=await fetch(`${ie()}/proof/trail?mapId=${encodeURIComponent(e)}`),c=a.ok?(await a.json()).statuses??{}:{};return{mapId:e,statuses:c}},show:i,failed:()=>i({mapId:e,statuses:{}}),changed:a=>a.includes(".evidence")||!!e&&a.includes(e)}),e&&n.mapId===e?n.statuses:void 0}function f3(){const e=Ot();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 m3(e){var i,a,c,d,u;const{snap:t,selection:n}=e.api;return s.jsxs(Fe,{as:"main",className:"zone map-zone",style:{gridArea:"map"},children:[t&&!Ot()&&s.jsx(kT,{}),(i=e.trail)==null?void 0:i.banner,s.jsxs("div",{className:"map-area",children:[t?s.jsx(l3,{snap:t,live:e.live,leases:e.api.leases,selection:n,onSelect:e.onSelect,minFit:e.minFit,preview:(a=e.trail)==null?void 0:a.preview,proofs:(c=e.trail)==null?void 0:c.proofs,done:(d=e.trail)==null?void 0:d.done,main:e.main,focus:e.focus,overlay:e.docked?void 0:(f,m)=>e.bubble({anchorOf:f,box:m})}):s.jsxs("div",{className:"nomap",children:[s.jsx(An,{title:"No trail yet",hint:f3()}),s.jsx("div",{className:"actions",children:s.jsx(I,{variant:"primary",onClick:e.onNewTrail,"data-tip":"Describe the idea and create the trail",children:"New trail…"})}),Ot()?s.jsx(I,{onClick:Sk,children:(u=Ot())==null?void 0:u.label}):s.jsx(Ga,{command:'/scout new "your idea"'})]}),!t&&!e.docked&&e.bubble({anchorOf:()=>{},box:{w:0,h:0}}),t&&s.jsx(u3,{})]}),e.docked&&e.bubble()]})}function p3(e){const{view:t,covered:n,needs:i}=e;return s.jsx("nav",{className:"tabbar",children:wy.map(({id:a,label:c})=>s.jsxs("button",{className:t===a&&!n?"on":"",onClick:()=>e.onPick(a),children:[c,a==="map"&&i>0&&s.jsx(js,{n:i,urgent:!0,pop:!0},i)]},a))})}function g3(e){return e.covered?s.jsx("main",{className:"phone-view",children:e.covered}):s.jsxs("main",{className:"phone-view phone-map",children:[e.map,e.trailBar,e.projects]})}const Pg={settingsPage:!0},Dg=()=>Fu(new URLSearchParams(location.search).get("settings")),_g=()=>{var e;return!!((e=history.state)!=null&&e.settingsPage)};function v3(){const[e,t]=y.useState(Dg);y.useEffect(()=>{e&&!_g()&&(history.replaceState(null,"",mr(location.href,null)),history.pushState(Pg,"",mr(location.href,e)));const d=()=>t(Dg());return window.addEventListener("popstate",d),()=>window.removeEventListener("popstate",d)},[]);const n=d=>{const u=mr(location.href,d);e?history.replaceState(history.state,"",u):history.pushState(Pg,"",u),t(d)},i=()=>{e&&(t(null),_g()?history.back():history.replaceState(null,"",mr(location.href,null)))},a=d=>n(Fu(d??"")??{});return{route:e,open:a,show:n,close:i,dismiss:()=>t(null),toggle:()=>e?i():a()}}const nu="view",Nd={lookoutPage:!0},Bg=()=>{const e=new URLSearchParams(location.search).get(nu);return _R.includes(e)?e:null},Fg=()=>{const e=history.state;return!!(e!=null&&e.lookoutPage||e!=null&&e.settingsPage)};function Jo(e){const t=new URL(location.href);return t.searchParams.delete(nu),t.searchParams.delete("settings"),e&&t.searchParams.set(nu,e),t.toString()}function k3(){const[e,t]=y.useState(Bg);return y.useEffect(()=>{e&&!Fg()&&(history.replaceState(null,"",Jo(null)),history.pushState(Nd,"",Jo(e)));const a=()=>t(Bg());return window.addEventListener("popstate",a),()=>window.removeEventListener("popstate",a)},[]),{page:e,open:a=>{const c=Jo(a);Fg()?history.replaceState(Nd,"",c):history.pushState(Nd,"",c),t(a)},close:()=>{var a;!e&&!new URLSearchParams(location.search).has("settings")||(t(null),(a=history.state)!=null&&a.lookoutPage?history.back():history.replaceState(null,"",Jo(null)))}}}function y3(e){const{activity:t,selection:n,setSelection:i,actions:a}=e,c=k3(),[d,u]=y.useState(!1),[f,m]=y.useState(),[g,k]=y.useState(!1);y.useEffect(()=>{const _=t.sessions.find(Y=>Y.id===e.chatSession);!n&&(_!=null&&_.ticketId)&&_.mapId===e.mapId&&i({kind:"ticket",id:_.ticketId})},[e.chatSession,e.mapId]);const w=()=>{k(!1),c.close()},b=_=>{k(!1),c.open(_)},S=_=>{i(_),_||u(!1)},x=_=>{_&&_!==e.mapId&&a.selectMap(_)},C=(_,Y)=>{x(_),i({kind:"ticket",id:Y}),w()},N=_=>{const Y=t.pending.find(re=>re.id===_);Y&&(x(Y.mapId),i(Y.ticketId?{kind:"ticket",id:Y.ticketId}:{kind:"question",id:Y.id}),w())},P=_=>{x(_),i({kind:"main"}),w()},D=_=>{x(_),i({kind:"together"}),w()},M=(_,Y,re)=>{x(re),a.openChat(_),b("activity")},H=_=>{m(_),b("logbook")};return{page:c.page,openPage:b,toMap:w,fullTicket:d,setFullTicket:u,logbookFocus:f,openDecisions:H,statsOpen:g,setStatsOpen:k,toggleStats:()=>k(_=>!_),select:S,openTicket:C,openQuestion:N,openMainChecks:P,openTrailChecks:D,openChat:M}}function w3(e,t){y.useEffect(()=>{document.title=`${J.name}: ${e?`(${e}) `:""}${t??"No trail"}`},[e,t])}function x3(e,t){const n=e.blockedBy.map(i=>{var a;return((a=t.get(i))==null?void 0:a.closedAt)??0});return Math.max(e.createdAt,...n)}function j3(e){const{t,state:n,session:i,items:a}=e;return n==="out-of-scope"?"cancelled":a.length||i!=null&&i.waitingOn?"needs":n==="decided"?"done":i||n==="claimed"||n==="verifying"?"working":(n==="frontier"||n==="rework")&&!t.assignee&&pi(t)!=="hitl"&&!e.held?"waiting-agent":"not-started"}function b3(e){const{snap:t}=e,n=Cs(t.tickets,t.map.mode),i=new Map(t.tickets.map(u=>[u.id,u])),a=e.items.filter(u=>u.mapId===t.map.id&&u.ticketId),c=t.tickets.map(u=>{var w;const f=a.filter(b=>b.ticketId===u.id),m=e.sessions.find(b=>b.ticketId===u.id&&b.mapId===t.map.id),g=((w=e.heldBack)==null?void 0:w.call(e,u))??!1,k=j3({t:u,state:n.get(u.id),session:m,items:f,held:g});return{ticket:u,tone:k,session:m,items:f}}),d=new Map(c.map(u=>[u.ticket.id,u.tone]));return new Map(c.map(u=>{const f=u.ticket.blockedBy.filter(k=>{var w;return((w=i.get(k))==null?void 0:w.state)==="open"}),m=f.filter(k=>d.get(k)==="needs"),g={...u,readySince:u.tone==="waiting-agent"?x3(u.ticket,i):void 0,waitsOn:u.tone==="not-started"?f.map(k=>i.get(k).key):[],waitsOnYours:u.tone==="not-started"?m.map(k=>i.get(k).key):[]};return[u.ticket.id,g]}))}function S3(e){const{snap:t,sessions:n,view:i}=e,a=tw(t),c=t==null?void 0:t.map.id,[d,u]=y.useMemo(()=>{const x=(i==null?void 0:i.items)??[],C=N=>!N.mapId||N.mapId===c;return[x.filter(C),x.filter(N=>!C(N))]},[i,c]),f=y.useMemo(()=>[...new Set(d.flatMap(x=>x.ticketId?[x.ticketId]:[]))],[d]),m=y.useMemo(()=>n.filter(mn),[n]),k=t?b3({snap:t,sessions:m,items:d,heldBack:x=>{const C=a(x);return!!C.needs||C.briefHeld}}):new Map,w=KL(k),b=GL(w,d);return{live:k,items:d,elsewhere:u,focus:f,segments:w,counts:b,keyOf:x=>{var C;return(C=t==null?void 0:t.tickets.find(N=>N.id===x))==null?void 0:C.key}}}function N3(e,t){const n=Cu(e),i=t.some(c=>c.kind==="main-checks"),a=nC(n.view,i);return{tone:a,needs:a==="needs"}}const $3=new Set(["question","main-checks","trail-checks"]),C3=e=>!!e.ticketId||$3.has(e.kind);function T3(e){const t=y.useRef(new URLSearchParams(location.search).has(Ns)),{loaded:n,view:i,activity:a,mapId:c,busy:d,open:u}=e;y.useEffect(()=>{if(t.current||!n||!i||!c)return;const f=i.items.find(m=>m.mapId===c&&C3(m));(f==null?void 0:f.kind)==="question"&&!a.pending.some(m=>m.id===f.ref)||(t.current=!0,f&&!d&&u(f))},[n,i,a,c,d,u])}function E3(e){const[t,n]=y.useState("…");return y.useEffect(()=>{fetch(`${ie()}/list`).then(i=>i.json()).then(i=>{var c;const a=i.root.split("/").filter(Boolean);n((c=a[a.length-1])!=null&&c.startsWith(".")?a[a.length-2]??"repo":a[a.length-1]??"repo")}).catch(()=>n("repo"))},[e]),t}function A3(e,t){return y.useMemo(()=>{const n=e.sessions.filter(a=>a.mapId===t),i=new Set(e.sessions.filter(a=>a.mapId!==t).map(a=>a.id));return{...e,sessions:n,feed:e.feed.filter(a=>!a.sessionId||!i.has(a.sessionId))}},[e,t])}function R3(e){const t=qa(e),[n,i]=y.useState(!1),a=()=>i(!0),c=t.brief,d=zA(c),u=pa(n?c==null?void 0:c.mapId:void 0,t.hash),f=c==null?void 0:c.sections,m=c&&n&&s.jsx(OA,{brief:c,error:t.error,changed:u.changed,onReviewAgain:u.reviewAgain,onAccept:()=>void t.accept(u.hash).then(k=>k&&i(!1)),onRequestChanges:k=>void t.requestChanges(k).then(w=>w&&i(!1)),onClose:()=>i(!1)}),g=d.show&&!n&&s.jsx(DA,{onReview:()=>{d.close(),a()},onClose:d.close});return{review:a,briefText:f?[f.existing,f.conventions,f.dataModel,f.api].join(`
|
|
168
|
+
`):"",banner:c&&s.jsx(BA,{brief:c,onReview:a}),inboxCard:(c==null?void 0:c.status)==="submitted"&&s.jsx(PA,{brief:c,onReview:a}),dialog:s.jsxs(s.Fragment,{children:[m,g]})}}function I3(e){var m;const{reroute:t,onReview:n}=e,i=t.kind==="challenge-destination",a=((m=t.frozen)==null?void 0:m.length)??0,c=i?"wrong mountain?":"proposes a new plan",d=a?` ${a} ticket${a===1?" is":"s are"} closed until you decide.`:"",u=t.wide?" It touches most of the open tickets, so nothing is frozen.":"",f=`${t.reason.replace(/\.$/,"")}.${d}${u}`;return s.jsxs("div",{className:"reroute-banner map-banner edge-attention",role:"status",title:f,children:[s.jsxs("span",{className:"mb-text",children:[s.jsxs("span",{className:"mb-lead",children:[t.by," ",c]}),s.jsx("span",{className:"t-meta",children:f})]}),s.jsx(ki,{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."}),s.jsx(I,{size:"sm",variant:"ghost",className:"reroute-dismiss",onClick:e.onDismiss,children:"Dismiss"}),s.jsx(I,{size:"sm",variant:"primary",onClick:n,children:"Review"})]})}const M3=e=>e.changes.flatMap(t=>"ticket"in t?[t.ticket]:[]);function O3(e,t){const n=new Set(M3(t));return e.tickets.filter(i=>n.has(i.id)&&i.updatedAt>t.at).map(i=>({key:i.key,title:i.title,what:L3(i)}))}function L3(e){return e.state==="closed"?"closed":e.assignee?`claimed by ${e.assignee}`:"changed"}function P3({parts:e}){return s.jsx("dl",{className:"reroute-parts",children:e.map(t=>s.jsxs("div",{children:[s.jsx("dt",{className:"t-label",children:t.label}),s.jsx("dd",{className:"t-body",children:t.text})]},t.label))})}const D3={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"},sw="Dismissed by the trail lead. Carry on with the current plan.",_3="Declined by the trail lead.";function B3(e,t){var n,i,a;switch(e.op){case"edit_ticket":return[...(n=e.title)!=null&&n.trim()?[{label:"New title",text:e.title.trim()}]:[],...(i=e.body)!=null&&i.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 F3(e,t){var n;switch(e.op){case"add_ticket":{const i=(n=e.blockedBy)!=null&&n.length?`after ${e.blockedBy.map(t).join(", ")}`:void 0;return{verb:"Add",text:e.title,detail:[`new ${e.type} ticket`,i].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:z3(e)};case"rewire":return{verb:"Rewire",text:t(e.ticket),detail:U3(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 z3(e){var n,i;return[((n=e.title)==null?void 0:n.trim())&&"New title",((i=e.body)==null?void 0:i.trim())&&"new description"].filter(Boolean).join(" and ").replace(/^new/,"New")}function U3(e,t){var i,a;return[...(i=e.addBlockedBy)!=null&&i.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 W3=new Set(["cancel_ticket","update_destination"]);function H3(e){const{change:t,name:n}=e,i=F3(t,n),a=B3(t,e.by);return s.jsx(he,{as:"li",className:`reroute-change op-${t.op}`,edge:W3.has(t.op)?"attention":"neutral",title:i.text,titleText:i.text,context:s.jsx(B,{parts:[{text:i.verb,strong:!0}]}),detail:i.detail,detailText:i.detail,below:a.length?s.jsx(P3,{parts:a}):void 0})}function K3(e){const{reason:t,destination:n}=e;return s.jsxs("section",{className:"reroute-destination",children:[t&&s.jsx("p",{className:"reroute-destination-why",children:D3[t]}),n&&s.jsxs("div",{className:"reroute-destination-diff",children:[s.jsxs("div",{children:[s.jsx("span",{className:"mono-label",children:"Destination now"}),s.jsx("p",{className:"before",children:n.before||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"mono-label",children:"Suggested destination"}),s.jsx("p",{className:"after",children:n.after})]})]})]})}function G3(e){return s.jsxs("section",{className:"reroute-drift edge-note edge-attention",children:[s.jsx("h3",{className:"mono-label",children:"Changed since it was proposed"}),s.jsx("ul",{className:"item-list",children:e.changed.map(t=>s.jsxs("li",{children:[s.jsx("span",{className:"item-text",children:t.title}),s.jsx(B,{parts:[{text:t.key,code:!0},t.what]})]},t.key))}),s.jsxs("label",{className:"reroute-seen t-body",children:[s.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 V3(e,t){const n=new Map(e.tickets.map(a=>[a.id,a.key])),i=new Map(t.flatMap(a=>a.op==="add_ticket"?[[a.ref,a.title]]:[]));return a=>{const c=n.get(a);if(c)return c;const d=i.get(a);return d?`new: ${d}`:a}}function q3(e){var P,D;const{reroute:t,snap:n}=e,[i,a]=y.useState(""),[c,d]=y.useState(!1);y.useEffect(()=>{const M=H=>H.key==="Escape"&&e.onClose();return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[e]);const u=V3(n,t.changes),f=new Map(n.tickets.map(M=>[M.id,`${M.key} ${M.title}`])),m=M=>f.get(M)??u(M),g=n.map.sections.assumptions??[],k=t.invalidates.map(M=>g.find(H=>H.id===M)??{id:M,text:""}),w=t.status==="pending",b=w?O3(n,t):[],S=!b.length||c,x=t.kind==="challenge-destination",C=t.lane==="setting",N=C?`${t.by} asks to change your setting`:"Reroute proposal";return s.jsx("div",{className:"scrim",onClick:e.onClose,children:s.jsxs(Fe,{as:"div",className:"dialog reroute-dialog",onClick:M=>M.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("h2",{className:"t-heading caps",children:x?"Destination challenged":N}),s.jsx(B,{parts:[{text:t.id,code:!0},t.status,`by ${t.by}`,`${Xe(Date.now()-t.at)} ago`]})]}),s.jsxs("div",{className:"reroute-body",children:[e.replaced&&s.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."]}),x&&s.jsx(K3,{reason:t.destinationReason,destination:(P=t.diff)==null?void 0:P.destination}),s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:"Why"}),s.jsx("p",{children:t.reason})]}),s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:"Evidence"}),s.jsx("p",{className:"reroute-evidence",children:t.evidence})]}),k.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:"Assumptions it invalidates"}),s.jsx("ul",{className:"item-list",children:k.map(M=>s.jsxs("li",{children:[s.jsx("span",{className:"item-text",children:M.text}),s.jsx(B,{parts:[{text:M.id,code:!0}]})]},M.id))})]}),s.jsxs("section",{children:[s.jsxs("h3",{className:"mono-label",children:["Changes · ",t.changes.length]}),s.jsx("ul",{className:"reroute-changes row-list",children:t.changes.map((M,H)=>s.jsx(H3,{change:M,by:t.by,name:m},H))})]}),s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:"Closed until you decide"}),t.wide&&s.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."]}),(D=t.frozen)!=null&&D.length?s.jsx("ul",{className:"item-list",children:t.frozen.map(M=>s.jsx("li",{className:"item-text",children:m(M)},M))}):s.jsx(Te,{children:"No tickets closed"})]}),t.note&&s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:"Your note"}),s.jsx("p",{children:t.note})]})]}),b.length>0&&s.jsx(G3,{changed:b,seen:c,onSeen:d}),w&&s.jsx(Je,{label:"Note for the agent (required to reject)",children:s.jsx("textarea",{rows:2,value:i,onChange:M=>a(M.target.value)})}),e.error&&s.jsx("p",{className:"urgent-text",children:e.error}),s.jsxs("div",{className:"actions",children:[w&&s.jsxs(s.Fragment,{children:[s.jsx(I,{className:"reroute-dismiss",variant:"ghost","data-tip":"Reject it without a note of your own",onClick:()=>e.onReject(C?_3:sw),children:C?"Decline":"Dismiss"}),s.jsx(I,{className:"reroute-reject",disabled:!i.trim(),onClick:()=>e.onReject(i.trim()),children:"Reject"}),wk()?s.jsx("span",{className:"vf-intro",children:"Only an owner, or someone they allowed to make high-risk calls, can approve it."}):s.jsx(I,{className:"reroute-approve",variant:"primary",disabled:!S,onClick:()=>e.onApprove(i.trim()),children:"Approve and apply"})]}),s.jsx(I,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}const iw=`${ie()}/reroutes`;async function Q3(e){if(!e)return[];const t=await fetch(`${iw}?map=${encodeURIComponent(e)}`);return t.ok?(await t.json()).reroutes:[]}function Y3(e){const t=e==null?void 0:e.map.id,[n,i]=y.useState([]),[a,c]=y.useState(),{reload:d}=Le({view:t,version:e==null?void 0:e.tickets.reduce((f,m)=>Math.max(f,m.updatedAt),e.map.updatedAt),load:()=>Q3(t),show:i,failed:()=>i([]),events:{reroute:f=>(f==null?void 0:f.mapId)===t}}),u=async(f,m,g)=>{var S,x;const k=await fetch(`${iw}/${f}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,id:m,note:g,hash:(S=n.find(C=>C.id===m))==null?void 0:S.hash})}),w=await k.json().catch(()=>({}));if(k.ok)return c(void 0),d(),!0;const b=(x=w.errors)==null?void 0:x.map(C=>C.message).join("; ");return c([w.error??`HTTP ${k.status}`,b].filter(Boolean).join(": ")),!1};return{reroutes:n,pending:n.find(f=>f.status==="pending"),error:a,clearError:()=>c(void 0),approve:(f,m)=>u("approve",f,m),reject:(f,m)=>u("reject",f,m)}}function J3(e,t){let n=t;for(let i=0;n&&i<e.length;i++){const a=e.find(c=>c.id===n);if((a==null?void 0:a.status)!=="superseded"||!a.supersededBy)break;n=a.supersededBy}return n!==t?{id:n,replaced:t}:{id:t}}function X3(e,t){const n=Y3(e),[i,a]=y.useState(),c=J3(n.reroutes,i),d=n.reroutes.find(k=>k.id===c.id),u=d!=null&&d.diff?d:n.pending,f=()=>{a(void 0),n.clearError()},m=k=>k&&f(),g=n.pending;return{banner:g&&s.jsx(I3,{reroute:g,onReview:()=>a(g.id),onDismiss:()=>void n.reject(g.id,sw)}),pending:n.reroutes.filter(k=>k.status==="pending").length,preview:e&&(u!=null&&u.diff)?rP(e,u.diff,u.frozen):void 0,openReroute:(k,w)=>{k!==(e==null?void 0:e.map.id)&&(t==null||t(k)),a(w)},dialog:e&&d&&s.jsx(q3,{reroute:d,replaced:c.replaced,snap:e,error:n.error,onApprove:k=>void n.approve(d.id,k||void 0).then(m),onReject:k=>void n.reject(d.id,k).then(m),onClose:f},d.id)}}function Z3(e,t){return t.tickets.filter(i=>i.state==="closed"&&i.closeReason==="completed").filter(i=>{var a;return(a=ns.ticket(e,t.map.id,i.id))==null?void 0:a.flags.some(c=>c.kind==="done-pr-open")}).map(i=>i.id)}const e4=20;function rw(e=e4){const t=document.querySelector(".ticket-proof");if(t)return t.scrollIntoView({block:"start",behavior:"smooth"});e>0&&setTimeout(()=>rw(e-1),100)}function t4(e){return s.jsxs(s.Fragment,{children:[s.jsx(I,{variant:"ghost",onClick:e.onClose,children:"Later"}),s.jsx(I,{variant:"primary",autoFocus:!0,onClick:e.onChecks,children:"See what fails"})]})}function n4({onClose:e}){return s.jsx(I,{variant:"primary",autoFocus:!0,onClick:e,children:"Close"})}function s4(e){const t=e.pulls===1?"Review pull request":"Review pull requests";return s.jsxs(s.Fragment,{children:[s.jsx(I,{variant:"ghost",onClick:e.onClose,children:"Later"}),s.jsx(I,{variant:"primary",autoFocus:!0,onClick:e.onReview,children:t})]})}function i4(e){return e.done.kind==="unverified"&&e.done.together.kind==="failed"?s.jsx(t4,{onChecks:e.onChecks,onClose:e.onClose}):e.pulls>0?s.jsx(s4,{pulls:e.pulls,onReview:e.onReview,onClose:e.onClose}):s.jsx(n4,{onClose:e.onClose})}const r4=e=>e===1?"1 pull request to merge.":`${e} pull requests to merge.`;function o4(e){const{done:t,pulls:n,onClose:i}=e;return y.useEffect(()=>{const a=c=>c.key==="Escape"&&i();return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[i]),s.jsx("div",{className:"scrim",onClick:i,children:s.jsxs(Fe,{as:"div",className:`dialog trail-done ${t.kind}`,role:"dialog","aria-label":"Destination reached",onClick:a=>a.stopPropagation(),children:[s.jsx("header",{children:s.jsx("h2",{className:"t-heading caps",children:"Destination reached"})}),s.jsxs("p",{className:"t-body",children:[t.reason,".",n>0&&` ${r4(n)}`]}),s.jsx("footer",{children:s.jsx(i4,{...e})})]})})}function a4({done:e}){const t=s.jsx("svg",{className:`destination reached ${e.kind}`,width:"34",height:"34",viewBox:"-20 -21 40 42","aria-hidden":"true",children:s.jsx(Zy,{})});return s.jsx(An,{title:"Destination reached",hint:e.reason,art:t})}function c4(e,t){return e.every(n=>n.state!=="closed"||n.closeReason!=="completed"||t[n.id]!==void 0)}function l4(e,t){const n=h3(e==null?void 0:e.map.id,e==null?void 0:e.tickets),i=kk(e==null?void 0:e.map.id).view,a=i&&i.mapId===(e==null?void 0:e.map.id)?i.together:void 0,c=y.useMemo(()=>{if(!(!e||!n||!a||!c4(e.tickets,n)))return lb({tickets:e.tickets,proofs:n,pendingReroutes:t,together:a})},[e,n,t,a]);return{proofs:n,done:c}}const zg=new Set,Ug=e=>`teamtrail.trail-done:${ie()}:${e}`,Wg={has(e){const t=Ug(e);if(zg.has(t))return!0;try{return localStorage.getItem(t)==="1"}catch{return!1}},add(e){const t=Ug(e);zg.add(t);try{localStorage.setItem(t,"1")}catch{}}};function d4(e,t){return t.kind==="verified"?`${e}:verified`:t.together.kind==="failed"?`${e}:failed:${t.together.runId}`:e}function u4(e,t){const[,n]=y.useState(0),i=e==null?void 0:e.map.id,a=i&&t&&t.kind!=="not-done"?d4(i,t):void 0;return{show:!!a&&!(e!=null&&e.map.archived)&&!Wg.has(a),close:()=>{a&&Wg.add(a),n(u=>u+1)}}}function h4(e){const{snap:t}=e,{proofs:n,done:i}=l4(t,e.pendingReroutes),a=u4(t,i),c=$r(),d=t?Z3(c,t):[],u=()=>{a.close(),!(!t||!d.length)&&(e.openTicket(t.map.id,d[0]),rw())},f=()=>{a.close(),t&&e.openTrailChecks(t.map.id)},m=a.show&&i&&i.kind!=="not-done"&&s.jsx(o4,{done:i,pulls:d.length,onReview:u,onChecks:f,onClose:a.close});return{proofs:n,done:i,dialog:m}}function f4(e){const{snap:t}=e,n=R3(t),i=X3(t,e.selectMap),a=h4({snap:t,pendingReroutes:i.pending,...e});return{briefText:n.briefText,inboxCard:n.inboxCard,review:n.review,banner:s.jsxs(s.Fragment,{children:[n.banner,i.banner]}),preview:i.preview,proofs:a.proofs,done:a.done,openReroute:i.openReroute,dialog:s.jsxs(s.Fragment,{children:[n.dialog,i.dialog,a.dialog]})}}function m4(){const e=new URL(location.href);e.searchParams.has(Ns)&&(e.searchParams.delete(Ns),history.replaceState(history.state,"",e))}function p4(e,t){return e.kind!=="question"||t.pending.some(n=>n.id===e.ref)}function g4(e){const[t,n]=y.useState(()=>new URLSearchParams(location.search).get(Ns)??void 0),{loaded:i,view:a,activity:c,handlers:d}=e;return y.useEffect(()=>{if(!t||!i||!a)return;const u=a.items.find(f=>f.id===t);u&&!p4(u,c)||(n(void 0),m4(),u&&Ru(u,d))},[t,i,a,c,d]),{request:y.useCallback(u=>n(u),[])}}function v4(e){const{api:t,nav:n}=e,i=Ak(t.allSnaps);VT(i.view);const a=m=>m&&t.actions.selectMap(m),c={openQuestion:n.openQuestion,openTicket:n.openTicket,openKnowledge:()=>e.knowledge.setOpen(!0),openBrief:m=>m===t.mapId?e.reviewBrief():a(m),openReroute:e.openReroute??(m=>m.ticketId?n.openTicket(m.mapId,m.ticketId):a(m.mapId)),selectTrail:a,openGuides:e.openGuides,openConnector:e.openConnector,openApprovals:e.openApprovals,openMainChecks:n.openMainChecks,openTrailChecks:n.openTrailChecks,openRule:e.openRule},d=i.view,u=g4({loaded:t.loaded,view:d,activity:t.activity,handlers:c}),f=d&&s.jsx(WT,{view:d,onFocus:m=>void i.savePrefs(dS(d.prefs,m,Date.now())),onSettings:e.openFocusSettings});return{attention:i,handlers:c,header:f,link:u,open:m=>Ru(m,c)}}function k4({d:e}){return e.derived?s.jsx(B,{className:"d-section",parts:["Unverified · read from text anyone who can edit the tracker wrote, not a decision Teamtrail recorded"]}):null}function y4(e){const{d:t,snap:n}=e,i=Cr(),[a,c]=y.useState(!1),[d,u]=y.useState(""),[f,m]=y.useState("");y.useEffect(()=>{c(!1),u(""),m("")},[t.id,t.mapId]);const g=E0(e.all.filter(x=>x.mapId===t.mapId),t.id),k=br(t),w=t.ticketId?n==null?void 0:n.tickets.find(x=>x.id===t.ticketId):void 0,b=Date.now(),S=pn(t.source.url);return s.jsxs("div",{className:"detail dv-d",children:[s.jsxs("div",{className:"d-head",children:[s.jsx("span",{className:"key",children:t.id}),s.jsx(wi,{tone:"state",className:`dv-st-${k}`,children:k}),s.jsx(B,{parts:[$1(t.decidedAt),`${Xe(b-t.decidedAt)} ago`]})]}),s.jsx("h3",{className:"t-heading",children:t.question}),s.jsx(QA,{mapId:t.mapId,kind:"decision",id:t.id}),s.jsx(k4,{d:t}),s.jsxs("div",{className:"resolution",children:[s.jsx(zd,{parts:["Decision"]}),s.jsx("p",{children:t.answer})]}),s.jsxs("dl",{className:"facts",children:[s.jsx("dt",{children:"Trail"}),s.jsx("dd",{children:n?`${n.map.key} ${n.map.title}`:t.mapId}),s.jsx("dt",{children:"Ticket"}),s.jsx("dd",{children:t.ticketId?s.jsxs("button",{className:"link",onClick:()=>e.onOpenTicket(t.mapId,t.ticketId),children:[t.ticketKey," ",(w==null?void 0:w.title)??""," · open in trail ›"]}):"—"}),s.jsx("dt",{children:"Decided by"}),s.jsx("dd",{children:[Su(t,i),dv(t)].filter(Boolean).join(", ")}),t.participants.length>1&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Participants"}),s.jsx("dd",{children:t.participants.map(x=>x.name??x.id).join(", ")})]}),s.jsx("dt",{children:"Source"}),s.jsxs("dd",{children:[ts[t.source.kind].label,S&&s.jsxs(s.Fragment,{children:[" · ",s.jsx("a",{href:S,target:"_blank",rel:"noreferrer",children:t.source.label??"link"})]}),!S&&t.source.label&&` · ${t.source.label}`,t.source.ref&&s.jsxs("span",{className:"ref",children:[" ",t.source.ref]})]})]}),t.alternatives.length>0&&s.jsxs("div",{className:"dv-sec",children:[s.jsx("h4",{className:"mono-label",children:"Alternatives"}),s.jsx("ul",{className:"dv-alts",children:t.alternatives.map(x=>s.jsx("li",{children:x},x))})]}),t.rationale&&s.jsxs("div",{className:"dv-sec",children:[s.jsx("h4",{className:"mono-label",children:"Rationale"}),s.jsx("p",{children:t.rationale})]}),g.length>1&&s.jsxs("div",{className:"dv-sec",children:[s.jsx("h4",{className:"mono-label",children:"Supersession"}),s.jsx("ol",{className:"dv-chain",children:g.map(x=>s.jsx("li",{className:`${x.id===t.id?"cur":""} ${x.supersededBy?"old":"live"}`,children:s.jsxs("button",{onClick:()=>e.onSelect(x.id),children:[s.jsx("i",{}),s.jsx("span",{className:"id",children:x.id}),s.jsx("span",{className:"a",children:x.summary}),s.jsx(B,{parts:[fi(x.decidedBy,i),hi(x.decidedAt)]})]})},x.id))})]}),s.jsxs("div",{className:"actions",children:[s.jsx(sy,{draft:()=>({title:t.summary||t.question,body:[t.answer,t.rationale&&`Why: ${t.rationale}`].filter(Boolean).join(`
|
|
169
|
+
|
|
170
|
+
`),kind:"product-decision",sources:[`decision:${t.id}`,...t.ticketKey?[`ticket:${t.ticketKey}`]:[]]})}),k==="active"&&!t.postedBy&&s.jsx(I,{on:a,onClick:()=>c(x=>!x),"data-tip":"Replace this decision with a new answer. Both stay on record",children:"Supersede…"})]}),a&&s.jsxs(Vt,{as:"form",tone:"inset",className:"inline-form",onSubmit:x=>{x.preventDefault(),d.trim()&&(e.onSupersede(t,{answer:d.trim(),rationale:f.trim(),alternatives:[t.summary]}),c(!1))},children:[s.jsx(Je,{label:"New decision",children:s.jsx("textarea",{rows:3,value:d,onChange:x=>u(x.target.value),autoFocus:!0})}),s.jsx(Je,{label:"Rationale",children:s.jsx("input",{value:f,onChange:x=>m(x.target.value)})}),s.jsxs("div",{className:"form-actions",children:[s.jsx(I,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),s.jsx(I,{type:"submit",variant:"primary",disabled:!d.trim(),children:"Supersede"})]})]}),s.jsxs("div",{className:"dv-sec",children:[s.jsxs("h4",{className:"mono-label",children:["Transcript ",s.jsx("span",{className:"n",children:t.transcript.length})]}),t.transcript.length?s.jsx("div",{className:"dv-transcript comms-log",children:t.transcript.map((x,C)=>s.jsxs("div",{className:`msg from-${x.from} voice-${x.from==="human"?"human":"agent"}`,children:[s.jsx(zd,{parts:[fi(x.author,i),vu(x.at)]}),s.jsx("div",{className:"msg-text",children:x.text})]},C))}):s.jsx(Te,{children:"None recorded"})]})]})}function Ut(e){return s.jsx("li",{children:s.jsxs("button",{className:`dv-opt ${e.on?"on":""} ${e.cls??""}`,onClick:e.onClick,children:[s.jsx("span",{className:"ttl",children:e.label}),s.jsx("b",{children:e.n})]})})}function w4(e){const{filter:t,set:n,all:i}=e,a=c=>i.filter(c).length;return e.compact?s.jsxs("div",{className:"dv-filters compact",children:[s.jsx(rt,{compact:!0,"aria-label":"Trail",value:t.mapId??"",onChange:c=>n({mapId:c||void 0}),options:[{value:"",label:"All trails"},...e.trails.map(c=>({value:c.map.id,label:`${c.map.key} ${c.map.title}`}))]}),s.jsx(rt,{compact:!0,"aria-label":"Source",value:t.source??"",onChange:c=>n({source:c||void 0}),options:[{value:"",label:"All sources"},...oa.map(c=>({value:c,label:ts[c].label}))]}),s.jsx(rt,{compact:!0,"aria-label":"Decided by",value:t.decidedBy??"",onChange:c=>n({decidedBy:c||void 0}),options:[{value:"",label:"Anyone"},...e.people.map(c=>({value:c,label:c}))]}),s.jsx(rt,{compact:!0,"aria-label":"Status",value:t.status??"",onChange:c=>n({status:c||void 0}),options:[{value:"",label:"Any status"},{value:"active",label:"Active"},{value:"superseded",label:"Superseded"}]})]}):s.jsxs("aside",{className:"dv-filters",children:[s.jsx("h3",{className:"mono-label",children:"Trail"}),s.jsxs("ul",{children:[s.jsx(Ut,{on:!t.mapId,label:"All trails",n:i.length,onClick:()=>n({mapId:void 0})}),e.trails.map(c=>s.jsx(Ut,{on:t.mapId===c.map.id,label:`${c.map.key} ${c.map.title}`,n:a(d=>d.mapId===c.map.id),onClick:()=>n({mapId:c.map.id})},c.map.id))]}),s.jsx("h3",{className:"mono-label",children:"Source"}),s.jsxs("ul",{children:[s.jsx(Ut,{on:!t.source,label:"All",n:i.length,onClick:()=>n({source:void 0})}),oa.map(c=>s.jsx(Ut,{cls:`src-${c}`,on:t.source===c,label:ts[c].label,n:a(d=>d.source.kind===c),onClick:()=>n({source:t.source===c?void 0:c})},c))]}),s.jsx("h3",{className:"mono-label",children:"Made by"}),s.jsxs("ul",{children:[s.jsx(Ut,{on:!t.madeBy,label:"Anyone",n:i.length,onClick:()=>n({madeBy:void 0})}),s.jsx(Ut,{on:t.madeBy==="agent",label:"Agents, on their own",n:a(c=>yr(c)==="agent"),onClick:()=>n({madeBy:t.madeBy==="agent"?void 0:"agent"})}),s.jsx(Ut,{on:t.madeBy==="human",label:"People",n:a(c=>yr(c)==="human"),onClick:()=>n({madeBy:t.madeBy==="human"?void 0:"human"})})]}),s.jsx("h3",{className:"mono-label",children:"Decided by"}),s.jsxs("ul",{children:[s.jsx(Ut,{on:!t.decidedBy,label:"Anyone",n:i.length,onClick:()=>n({decidedBy:void 0})}),e.people.map(c=>s.jsx(Ut,{on:t.decidedBy===c,label:c,n:a(d=>d.decidedBy===c),onClick:()=>n({decidedBy:t.decidedBy===c?void 0:c})},c))]}),s.jsx("h3",{className:"mono-label",children:"Status"}),s.jsxs("ul",{children:[s.jsx(Ut,{on:!t.status,label:"Any",n:i.length,onClick:()=>n({status:void 0})}),s.jsx(Ut,{on:t.status==="active",label:"Active",n:a(c=>!c.supersededBy),onClick:()=>n({status:t.status==="active"?void 0:"active"})}),s.jsx(Ut,{on:t.status==="superseded",label:"Superseded",n:a(c=>!!c.supersededBy),onClick:()=>n({status:t.status==="superseded"?void 0:"superseded"})})]})]})}const Hg=e=>`${e.mapId}/${e.id}`;function x4(e,t){var a;const n=new Map;for(const c of e){const d=((a=t[Hg(c)])==null?void 0:a.area)??Zl;n.set(d,[...n.get(d)??[],c])}const i=c=>{var d;return((d=t[Hg(c)])==null?void 0:d.citedBy.length)??0};return[...n].map(([c,d])=>({area:c,rows:[...d].sort((u,f)=>i(f)-i(u)||f.decidedAt-u.decidedAt)})).sort((c,d)=>+(c.area===Zl)-+(d.area===Zl)||d.rows.length-c.rows.length||c.area.localeCompare(d.area))}function j4(e){if(br(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function b4(e){const{d:t}=e,n=Cr(),i=br(t);return s.jsxs(s.Fragment,{children:[e.newDay&&s.jsx("li",{className:"dv-day t-label",children:e.group??hi(t.decidedAt)}),s.jsx(he,{as:"li",className:`dv-row ${i}`,selected:e.on,onOpen:e.onClick,title:t.question,titleText:t.question,trailing:vu(t.decidedAt),context:s.jsx(B,{parts:[{text:t.id,code:!0},t.ticketKey&&{text:t.ticketKey,code:!0},e.showTrail&&e.trail,Su(t,n),dv(t)??ts[t.source.kind].label,j4(t),!!e.cited&&`cited ${e.cited}×`]}),detail:t.summary,detailText:t.summary})]})}function S4(e){const{rows:t,current:n,memory:i}=e,a=(c,d,u)=>{var f,m;return s.jsx(b4,{d:c,newDay:d,group:u,cited:(f=i==null?void 0:i[`${c.mapId}/${c.id}`])==null?void 0:f.citedBy.length,trail:(m=e.snaps[c.mapId])==null?void 0:m.map.key,on:(n==null?void 0:n.id)===c.id&&n.mapId===c.mapId,showTrail:e.showTrail,onClick:()=>e.onSelect(c.id)},`${c.mapId}:${c.id}`)};return i&&t.length?s.jsx("ol",{className:"dv-list","aria-label":"Logbook by area",children:x4(t,i).flatMap(c=>c.rows.map((d,u)=>a(d,u===0,`${c.area} · ${c.rows.length}`)))}):s.jsx("ol",{className:"dv-list","aria-label":"Logbook",children:t.length?t.map((c,d)=>a(c,d===0||hi(t[d-1].decidedAt)!==hi(c.decidedAt))):s.jsx(Te,{children:"No decisions"})})}function N4({stats:e}){return s.jsxs("span",{className:"dv-readouts",children:[s.jsx(Cn,{layout:"start",label:"Active",value:e.active}),s.jsx(Cn,{layout:"start",label:"Superseded",value:e.superseded}),s.jsx(Cn,{layout:"start",label:"Last 24h",value:e.last24h}),s.jsx(Cn,{layout:"start",label:"Human",value:`${e.total?Math.round(e.human/e.total*100):0}%`}),s.jsx(B,{className:"dv-src-mix",parts:oa.filter(t=>e.bySource[t]).map(t=>`${ts[t].label} ${e.bySource[t]}`)})]})}function $4(e){const{filter:t}=e,i=Object.values(t).filter(Boolean).length-(t.query?1:0),a=e.filtersOpen||i>0;return s.jsxs("div",{className:"dv-search",children:[s.jsx("input",{type:"search",placeholder:"Search decisions",value:t.query??"",onChange:c=>e.set({query:c.target.value})}),e.showToggle&&s.jsxs("button",{className:`chip ${a?"on":""}`,onClick:e.onToggle,children:["Filters",i>0?` · ${i}`:""]})]})}async function C4(){const e=await fetch(`${ie()}/decision-memory`);return e.ok?(await e.json()).entries:null}function T4(){const[e,t]=y.useState();return Le({load:C4,show:t,failed:()=>t(null),changed:n=>n.includes("/decisions/")||n.endsWith("map.md")}),e}function E4(e){const{api:t,bp:n}=e,i=t.decisions,[a,c]=y.useState({}),[d,u]=y.useState(e.focus),[f,m]=y.useState(!1),[g,k]=y.useState(!1),w=T4();y.useEffect(()=>u(e.focus),[e.focus]),y.useEffect(()=>{const H=_=>{_.key==="Escape"&&(n==="mobile"&&d?u(void 0):e.onClose())};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[n,d,e]);const b=y.useMemo(()=>hb(i,a),[i,a]),S=y.useMemo(()=>fb(i),[i]),x=i.find(H=>H.id===d&&(!a.mapId||H.mapId===a.mapId))??(n==="mobile"?void 0:b[0]),C=y.useMemo(()=>Object.values(t.allSnaps).sort((H,_)=>_.map.createdAt-H.map.createdAt),[t.allSnaps]),N=y.useMemo(()=>[...new Set(i.map(H=>H.decidedBy))].sort(),[i]),P=H=>c(_=>({..._,...H})),D=()=>{const H=Object.fromEntries(C.map(_=>[_.map.id,{key:_.map.key,title:_.map.title}]));qv(`${J.slug}-decisions-${hi(Date.now())}.md`,Nb(b,H,{title:`${J.name} decisions`}))},M=n==="mobile"&&!!x;return s.jsxs(Fe,{className:`zone decisions-view dv-${n}`,children:[s.jsxs("header",{className:"dv-head",children:[M?s.jsx("button",{className:"back",onClick:()=>u(void 0),children:"‹ Decisions"}):s.jsxs(Ke,{as:"h2",children:["Decisions ",b.length!==i.length&&s.jsx("span",{className:"n",children:`${b.length}/${i.length}`})]}),n!=="mobile"&&s.jsx(N4,{stats:S}),s.jsxs("span",{className:"dv-head-right",children:[!M&&w&&s.jsx(I,{on:g,"aria-pressed":g,onClick:()=>k(H=>!H),title:"Group by the area each decision is about, the most cited first",children:"By area"}),!M&&s.jsx(I,{onClick:D,disabled:!b.length,title:"Export the filtered list as markdown",children:"Export .md"}),s.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]})]}),!M&&s.jsx($4,{filter:a,set:P,showToggle:n!=="wide",filtersOpen:f,onToggle:()=>m(H=>!H)}),s.jsxs("div",{className:"dv-body",children:[(n==="wide"||f&&!M)&&s.jsx(w4,{filter:a,set:P,all:i,trails:C,people:N,compact:n!=="wide"}),!M&&s.jsx(S4,{rows:b,current:x,snaps:t.allSnaps,showTrail:n==="wide",onSelect:u,memory:g&&w?w:void 0}),(n!=="mobile"||x)&&s.jsx("div",{className:"dv-detail",children:x?s.jsx(y4,{d:x,all:i,snap:t.allSnaps[x.mapId],onSelect:u,onOpenTicket:e.onOpenTicket,onSupersede:t.actions.supersede}):s.jsx(Te,{children:"No decision selected"})})]})]})}const A4={"asks-you":"urgent",answered:"good",launched:"good",done:"good",verified:"good","checks-failed":"attention",stalled:"attention",disconnected:"attention",problem:"attention"};function R4(e){if(e.kind)return A4[e.kind];if(e.signal){if(e.level==="alert")return"urgent";if(e.level==="ok")return"good"}}function I4({activity:e,onTicket:t}){const n=Cr(),i=e.feed.slice(-120).reverse();return i.length?s.jsx("div",{className:"log",children:i.map(a=>s.jsxs("div",{className:`log-row src-${a.source.replace(" ","-")} edge-${R4(a)??"none"}`,onClick:()=>a.ticketId&&t(a.ticketId),children:[s.jsx("span",{className:"t t-meta",children:Ia(a.at)}),s.jsx("span",{className:"src t-meta",children:fi(a.agent??a.source,n)}),s.jsxs("span",{className:"msg",title:a.tag?`${a.tag} · ${a.text}`:a.text,children:[a.tag&&s.jsxs("span",{className:"tag t-meta",children:[a.tag," · "]}),a.text]})]},a.id))}):s.jsx(An,{title:"Nothing has happened yet",hint:"Claims, steps, questions and decisions appear here as agents work."})}function Kg({lease:e,now:t}){if(!e)return null;const n=Ts(e,t);if(n==="live")return null;const i=e.expiresAt-t;return s.jsxs(wi,{tone:"amber",className:"stalled",title:`No activity from ${e.agent}; the ticket returns to the queue when the lease runs out`,children:["stalled · ",n==="expired"?"returning":Gt(i)]})}function M4({total:e,step:t}){return s.jsx("span",{className:"segs","aria-label":`Step ${t} of ${e}`,children:Array.from({length:e},(n,i)=>s.jsx("i",{className:O4(i+1,t)},i))})}function O4(e,t){return e<t?"done":e===t?"cur":""}function L4({snap:e,activity:t,leases:n,onSelect:i,onOpenChat:a}){var w;const c=gt(1e3),d=t.sessions.filter(mn),u=new Set(d.map(b=>b.ticketId)),f=ku(n,e==null?void 0:e.map.id),m=(e==null?void 0:e.tickets.filter(b=>b.state==="open"&&b.assignee&&!u.has(b.id)))??[];if(!d.length&&!m.length)return s.jsx(Te,{children:"No agent on a ticket"});const g=b=>!!b&&Ts(b,c)!=="live",k=!!((w=e==null?void 0:e.map.modelMatching)!=null&&w.enabled);return s.jsxs("ul",{className:"sessions-list",children:[d.map(b=>{const S=e==null?void 0:e.tickets.find(N=>N.id===b.ticketId),x=S?pi(S)==="hitl":!1,C=S&&f.get(S.id);return s.jsx(he,{as:"li",className:b.waitingOn?"waiting":void 0,edge:P4(b,g(C)),title:F4(S,b.mode)||b.agent,context:s.jsx(B,{parts:[{text:b.agent,strong:!0},_4(b),k&&D4(b),b.waitingOn?{text:"Waiting on you",urgent:!0}:`${b.mode} · ${b.stepLabel.toLowerCase()}`,x&&!b.waitingOn&&"with you",B4(b)],children:s.jsx(Kg,{lease:C,now:c})}),trailing:Qv(c-b.startedAt),below:s.jsx(M4,{total:b.total,step:b.step}),onOpen:()=>{S&&i({kind:"ticket",id:S.id}),x&&a(b.id)}},b.id)}),m.map(b=>s.jsx(he,{as:"li",className:"claim",edge:g(f.get(b.id))?"attention":"neutral",title:`${b.key} ${b.title}`,context:s.jsx(B,{parts:[{text:b.assignee??"",strong:!0},"claimed, no live session"],children:s.jsx(Kg,{lease:f.get(b.id),now:c})}),onOpen:()=>i({kind:"ticket",id:b.id})},b.id))]})}function P4(e,t){return e.waitingOn?"urgent":t?"attention":"neutral"}function D4(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 _4(e){const t=Fa(e.model);return t&&{text:t,tip:e.model,className:"agent-model"}}function B4(e){if(e.usage)return`${Ma(ab(e))} tok · ${ui(e.usage.costUsd)}`}function F4(e,t){return e?`${e.key} ${e.title}`:t==="chart"?"Charting trail":""}function z4({activity:e,snap:t,running:n,usage:i=!0}){const a=kv(e,t==null?void 0:t.map.id),c=wv(e,t==null?void 0:t.map.id),d=new Set(e.sessions.filter(mn).map(f=>f.ticketId)),u=(t==null?void 0:t.tickets.filter(f=>f.state==="open"&&f.assignee&&!d.has(f.id)).length)??0;return s.jsx(yt,{sub:!0,className:"sessions-head",title:s.jsxs(s.Fragment,{children:["Agents on tickets ",s.jsx("span",{className:"n",children:n+u})]}),right:i?s.jsxs("span",{className:"usage",title:["Model usage for this trail, all sessions",...c.map(f=>yv[f].text)].join(`
|
|
171
|
+
`),children:[s.jsx("span",{className:"mono-label",children:"Trail"})," ",Ma(a.inputTokens+a.outputTokens)," tok · ",ui(a.costUsd)]}):void 0})}function U4(e){const t=[...e.feed].reverse().find(n=>n.level==="step"&&n.sessionId);return t?e.sessions.find(n=>n.id===t.sessionId):void 0}const W4={running:"Working",done:"Done",failed:"Stopped"};function H4({activity:e,snap:t,done:n}){var u;if(n&&n.kind!=="not-done")return s.jsx(a4,{done:n});const i=U4(e);if(!i)return s.jsx(An,{title:"No agent working yet",hint:Ot()?`Turn your agents on for this trail in ${(u=Ot())==null?void 0:u.label}. Each step they report shows here.`:"Run /scout resume in Claude Code or Codex. Each step an agent reports shows here."});const a=i.ticketId?t==null?void 0:t.tickets.find(f=>f.id===i.ticketId):void 0,c=$a[i.mode],d=i.waitingOn?"Waiting on you":W4[i.status];return s.jsxs("div",{className:`step-tracker ${i.waitingOn?"waiting":""}`,children:[s.jsxs("div",{className:"st-meta",children:[s.jsx(B,{parts:[{text:i.agent,strong:!0},`${i.mode}, step ${i.step} of ${i.total}`]}),s.jsx("span",{className:`t-label st-status ${i.waitingOn?"urgent":""}`,children:d})]}),s.jsxs("div",{className:"st-big",children:[i.stepLabel,a&&s.jsxs("span",{className:"st-key",children:[" ",a.key]})]}),a&&s.jsx("div",{className:"st-ticket t-meta",children:a.title}),s.jsx("ol",{className:"pipeline",children:c.map((f,m)=>{const g=m+1,k=g<i.step||g===i.step&&i.status==="done";let w="";return k?w="done":g===i.step&&(w="cur"),s.jsxs("li",{className:w,children:[s.jsx("i",{}),s.jsxs("span",{children:[String(g).padStart(2,"0")," ",f]})]},f)})})]})}function K4(e){const{activity:t}=e;return s.jsxs(Fe,{className:"zone page activity-page",children:[s.jsxs("section",{className:"page-col",children:[s.jsx(yt,{title:"Agents"}),s.jsxs("div",{className:"zone-b",children:[s.jsx(H4,{activity:t,snap:e.snap,done:e.done}),s.jsx(z4,{activity:t,snap:e.snap,running:t.sessions.filter(mn).length}),s.jsx(L4,{snap:e.snap,activity:t,leases:e.leases,onSelect:n=>(n==null?void 0:n.kind)==="ticket"&&e.onTicket(n.id),onOpenChat:e.onOpenChat})]})]}),s.jsxs("section",{className:"page-col",children:[s.jsx(yt,{title:"Activity log",right:s.jsxs("span",{className:"mono-label dim",children:[t.feed.length," events"]})}),s.jsx("div",{className:"zone-b",children:s.jsx(I4,{activity:t,onTicket:e.onTicket})})]}),s.jsx("section",{className:"page-col conversation-col",children:s.jsx(FC,{activity:e.allActivity,snaps:e.snaps,sessionId:e.chatSession,onAnswer:e.onAnswer})})]})}const G4={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function V4(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 q4(e){const{a:t,snap:n}=e,i=t.tickets.flatMap(c=>n.tickets.filter(d=>d.id===c)),a=t.challenge&&`${t.challenge.by}: ${t.challenge.evidence}`;return s.jsx(he,{as:"li",className:`assumption st-${t.status}`,edge:t.status==="challenged"?"attention":"neutral",title:t.text,titleText:t.text,context:s.jsx(B,{parts:[{text:t.id,code:!0},G4[t.status],V4(t)],children:i.length>0&&s.jsxs("span",{className:"assumption-tickets",children:[s.jsx("span",{className:"sep",children:" · "}),"relied on by",i.map(c=>s.jsx("button",{className:"link t-code",onClick:()=>e.onSelect({kind:"ticket",id:c.id}),children:c.key},c.id))]})}),detail:a,detailText:a,actions:e.onConfirm&&s.jsx(I,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onConfirm,children:"Confirm"})})}function Q4(e){const[t,n]=y.useState(),[i,a]=y.useState();return{confirm:async(d,u)=>{a(d);const f=await fetch(`${ie()}/assumptions/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,id:d,text:u})}).catch(()=>{});if(a(void 0),f!=null&&f.ok)return n(void 0);const m=await(f==null?void 0:f.json().catch(()=>({})));n((m==null?void 0:m.error)??"Could not confirm it; is the Lookout connected?")},busy:i,error:t}}function Y4({snap:e,onSelect:t}){const{confirm:n,busy:i,error:a}=Q4(e.map.id),c=e.map.sections.assumptions??[];return c.length?s.jsxs(s.Fragment,{children:[a&&s.jsx("p",{className:"urgent-text",children:a}),s.jsx("ul",{className:"assumptions row-list",children:c.map(d=>{const u=d.status==="holding"||d.status==="challenged";return s.jsx(q4,{a:d,snap:e,onSelect:t,onConfirm:u?()=>void n(d.id,d.text):void 0,busy:i===d.id},d.id)})})]}):s.jsx(Te,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function J4(e){const[,t,n=e]=/^(#\d+)\s+(.+)$/.exec(e)??[],[i=n,...a]=n.split(/\s+[—–]\s+/);return{key:t,title:i,reason:a.join(" — ")||void 0}}function X4(e){const[t,n]=y.useState([]),i=e==null?void 0:e.map.id,a=(e==null?void 0:e.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),e.map.updatedAt))??0;return y.useEffect(()=>{if(!i)return;let c=!0;return fetch(`${ie()}/journal?mapId=${encodeURIComponent(i)}`).then(d=>d.ok?d.json():{entries:[]}).then(d=>c&&n(d.entries)).catch(()=>c&&n([])),()=>{c=!1}},[i,a]),t}function Z4({snap:e,activity:t,onTicket:n}){const i=X4(e),a=t.usageByMap[e.map.id],c=y.useMemo(()=>$v({snap:e,journal:i,answered:t.answered,usage:a}),[e,i,t.answered,a]),d=c.interventions,u=[["Done",`${c.done}`,`${c.done} done · ${c.cancelled} cancelled · ${c.open} open`],["Lead time",tn(c.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",tn(c.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",`${c.rework.cycles}`,`Times work went back to rework, on ${c.rework.tickets} tickets`],["Reviews",`${c.reviews.passed}/${c.reviews.failed}`,`${c.reviews.passed} passed, ${c.reviews.failed} failed, ${c.reviews.needsHuman} needed you`],["Cost / ticket",c.spend.perVerifiedTicketUsd===void 0?"—":ui(c.spend.perVerifiedTicketUsd),`Cost per verified ticket: trail spend ${ui(c.spend.costUsd)} ÷ ${c.done} done tickets`]];return s.jsxs("div",{className:"report",children:[s.jsx("ul",{className:"report-stats",children:u.map(([f,m,g])=>s.jsxs("li",{"data-tip":g,children:[s.jsx("span",{className:"mono-label",children:f}),s.jsx("b",{children:m})]},f))}),s.jsxs("div",{className:"report-bar",children:[s.jsx("span",{className:"mono-label",children:"Tickets"}),s.jsx(I,{size:"sm",variant:"ghost","data-tip":"Download this report as markdown",onClick:()=>qv(`${e.map.key.replace("#","trail-")}-report.md`,Ob(c,e.map.title)),children:"Export markdown"})]}),c.tickets.length?s.jsx("ul",{className:"list report-tickets",children:c.tickets.map(f=>s.jsx("li",{className:`out-${f.outcome}`,children:s.jsxs("button",{onClick:()=>n(f.id),"data-tip":`${f.outcome} · rework ${f.reworks} · reviews ${f.reviews.passed}/${f.reviews.failed} · your calls ${f.operatorActions}`,children:[s.jsx("span",{className:"key",children:f.key}),s.jsx("span",{className:"ttl",children:f.title}),s.jsx("span",{className:"lead",children:f.outcome==="done"?tn(f.leadMs):f.outcome})]})},f.id))}):s.jsx(Te,{children:"No tickets yet"})]})}function eD({tab:e,snap:t,selection:n,onSelect:i,activity:a}){const c=t.map.sections;switch(e){case"report":return a?s.jsx(Z4,{snap:t,activity:a,onTicket:d=>i({kind:"ticket",id:d})}):s.jsx(Te,{children:"No activity yet"});case"assumptions":return s.jsx(Y4,{snap:t,onSelect:i});case"decisions":return c.decisions.length?s.jsx("ol",{className:"row-list decisions",children:[...c.decisions].reverse().map((d,u)=>s.jsx(he,{as:"li",title:d.text,titleText:d.text,context:d.ticketKey&&s.jsx(B,{parts:[{text:d.ticketKey,code:!0}]}),onOpen:d.ticketId?()=>i({kind:"ticket",id:d.ticketId}):void 0},`${d.ticketKey}-${u}`))}):s.jsx(Te,{children:"None"});case"unspecified":return c.unspecified.length?s.jsx("ul",{className:"row-list unspecified",children:c.unspecified.map(d=>s.jsx(he,{as:"li",title:d,titleText:d,selected:(n==null?void 0:n.kind)==="unspecified"&&n.item===d,onOpen:()=>i({kind:"unspecified",item:d})},d))}):s.jsx(Te,{children:"None"});case"oos":return c.outOfScope.length?s.jsx("ul",{className:"row-list oos",children:c.outOfScope.map(d=>{const u=J4(d);return s.jsx(he,{as:"li",title:u.title,titleText:d,context:s.jsx(B,{parts:[u.key&&{text:u.key,code:!0},u.reason]})},d)})}):s.jsx(Te,{children:"None"});case"notes":return s.jsx("p",{className:"notes t-body",children:c.notes||"No notes yet."});default:return e}}function tD({snap:e,selection:t,onSelect:n,bare:i,onAudit:a,activity:c}){var k;const[d,u]=y.useState("unspecified"),f=e==null?void 0:e.map.sections,m=[{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"}],g=e?s.jsx(eD,{tab:d,snap:e,selection:t,onSelect:n,activity:c}):s.jsx(An,{title:"No plan yet",hint:"Open questions, decisions, what's ruled out, notes and the trail report collect here."});return s.jsxs(Fe,{className:`zone sections ${i?"bare":""}`,style:i?void 0:{gridArea:"plan"},children:[!i&&s.jsx(yt,{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."}),s.jsxs("div",{className:"sections-tabs",children:[s.jsx(rt,{compact:!0,"aria-label":"Plan section",value:d,onChange:u,options:m.map(w=>({value:w.id,label:w.n===void 0?w.label:`${w.label} · ${w.n}`}))}),d==="decisions"&&a&&s.jsx("button",{className:"link",onClick:a,children:"Audit ›"})]}),s.jsx("div",{className:"zone-b",children:g})]})}const $d=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],Gg=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function nD({snap:e,sessions:t}){const n=vv(e),i=m=>n[m],a=t.filter(f$).length,c=rb(e),d=Math.max(1,...c.map(m=>m.open+m.closed)),f=(e.map.verification??"off")!=="off"||Gg.some(([m])=>i(m))?[...$d.slice(0,2),...Gg,...$d.slice(2)]:$d;return s.jsxs("div",{className:"status-panel",children:[s.jsxs("div",{className:"sp-col sp-status",children:[s.jsxs("div",{className:"sp-head",children:[s.jsx(Ke,{as:"h3",children:"Status"}),s.jsxs("span",{className:"t-meta",children:[n.total," tickets"]})]}),s.jsxs("ul",{children:[f.map(([m,g])=>s.jsxs("li",{className:`st-${m} ${i(m)?"":"zero"}`,children:[s.jsx("i",{}),s.jsx("span",{children:g}),s.jsx("b",{children:i(m)})]},m)),s.jsxs("li",{className:`st-waiting ${a?"":"zero"}`,children:[s.jsx("i",{}),s.jsx("span",{children:"Waiting on you"}),s.jsx("b",{children:a})]})]})]}),s.jsxs("div",{className:"sp-block sp-col",children:[s.jsx("span",{className:"t-label",children:"Type mix"}),s.jsx("ul",{className:"mix",children:c.map(m=>s.jsxs("li",{title:`${m.type}: ${m.closed} closed, ${m.open} open`,children:[s.jsx("span",{className:"t-meta",children:En[m.type]}),s.jsxs("span",{className:"mix-bar",children:[s.jsx("i",{className:"closed",style:{width:`${m.closed/d*100}%`}}),s.jsx("i",{className:"open",style:{width:`${m.open/d*100}%`}})]}),s.jsx("b",{children:m.open+m.closed})]},m.type))})]})]})}function sD(e){const{snap:t,selection:n}=e,i=(n==null?void 0:n.kind)==="unspecified"?n.item:void 0;return s.jsxs(Fe,{className:"zone page plan-page",children:[s.jsx("section",{className:"page-col",children:s.jsx(tD,{snap:t,selection:n,onSelect:e.onSelect,bare:!0,onAudit:e.onAudit,activity:e.activity})}),s.jsxs("section",{className:"page-col",children:[i&&s.jsx(yt,{title:"Open question"}),s.jsxs("div",{className:"zone-b",children:[t&&i&&s.jsx(ky,{snap:t,item:i,api:e.api}),t&&!i&&s.jsxs(s.Fragment,{children:[e.glance,s.jsx(nD,{snap:t,sessions:e.activity.sessions})]})]})]})]})}function iD({api:e,bp:t,nav:n,scoped:i,done:a,attn:c}){const d=gt(5e3),u=f=>e.mapId&&n.openTicket(e.mapId,f);if(n.statsOpen)return s.jsx(MO,{api:e,bp:t,onClose:()=>n.setStatsOpen(!1)});switch(n.page){case"logbook":return s.jsx(E4,{api:e,bp:t,focus:n.logbookFocus,onClose:n.toMap,onOpenTicket:n.openTicket});case"plan":return s.jsx(sD,{api:e,snap:e.snap,activity:i,selection:e.selection,onSelect:n.select,onAudit:()=>n.openDecisions(),glance:e.snap&&s.jsx(vy,{snap:e.snap,sessions:i.sessions,attention:c.attention.view,done:a,now:d,onTicket:u,onItem:c.open})});case"activity":return s.jsx(K4,{activity:i,allActivity:e.activity,snaps:e.allSnaps,snap:e.snap,leases:e.leases,done:a,chatSession:e.chatSession,onTicket:u,onOpenChat:f=>n.openChat(f),onAnswer:e.actions.answer});default:return null}}function rD(e,t,n){const i=Dy(),[a,c]=y.useState(()=>new URLSearchParams(location.search).has("projects")),d=a&&i.many&&s.jsx(VM,{projects:i,bp:e,onClose:()=>c(!1),onItemHere:n});return{projects:i,overview:d,closeOverview:()=>c(!1),openOverview:()=>{t.toMap(),c(!0)}}}const oD=e=>typeof e=="string"&&/^\/(?!\/)[\w/?=&#.-]{0,200}$/.test(e)?e:void 0;function aD(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 n=t.steps.slice(0,10).flatMap(i=>{const a=oD(i==null?void 0:i.href);return typeof(i==null?void 0:i.title)!="string"||!a?[]:[{title:i.title.slice(0,80),href:a,done:i.done===!0,next:i.next===!0,optional:i.optional===!0}]});return{done:t.done,total:t.total,complete:t.complete===!0,steps:n}}function cD(){var i;const e=(i=pt())==null?void 0:i.setup,[t,n]=y.useState();return y.useEffect(()=>{if(!e)return;let a=!1;const c=()=>void fetch(e).then(k=>k.ok?k.json():void 0).then(k=>{const w=aD(k);a=(w==null?void 0:w.complete)===!0,n(w)}).catch(()=>{});c();const d=()=>document.visibilityState==="visible"&&c();let u;const f=()=>{a||(clearTimeout(u),u=setTimeout(c,500))};document.addEventListener("visibilitychange",d),window.addEventListener(Hd,f);const m=Ba(f),g=os(f);return()=>{clearTimeout(u),document.removeEventListener("visibilitychange",d),window.removeEventListener(Hd,f),m(),g()}},[e]),t}const ow="teamtrail.guide.open";function lD(){try{return localStorage.getItem(ow)!=="no"}catch{return!0}}function dD(e){try{localStorage.setItem(ow,e?"yes":"no")}catch{}}function uD(){const e=cD(),[t,n]=y.useState(lD);if(!e||e.complete)return null;const i=c=>{n(c),dD(c)},a=`${e.done} of ${e.total}`;return Qk.createPortal(s.jsxs("aside",{className:`setup-guide${t?" open":""}`,"aria-label":"Get started",children:[t&&s.jsxs("div",{className:"setup-bubble",children:[s.jsxs("header",{children:[s.jsx("b",{children:"Get started"}),s.jsx("span",{className:"t-meta",children:a}),s.jsx(I,{size:"sm",variant:"ghost",onClick:()=>i(!1),"aria-label":"Minimize",children:"–"})]}),s.jsx("ol",{children:e.steps.map((c,d)=>s.jsxs("li",{className:[c.done&&"done",c.next&&"next"].filter(Boolean).join(" "),children:[s.jsx("span",{className:"setup-mark","aria-hidden":"true",children:c.done?"✓":d+1}),s.jsx("a",{href:c.href,children:c.title}),c.optional&&s.jsx("span",{className:"t-meta",children:"optional"})]},c.href+c.title))})]}),s.jsxs("button",{type:"button",className:"setup-scout",onClick:()=>i(!t),"aria-expanded":t,children:[s.jsx(Ra,{size:1,framed:!1,state:"idle"}),!t&&s.jsxs("span",{className:"setup-chip",children:["Get started · ",a]})]})]}),document.body)}function hD(){const e=y.useMemo(()=>h$(u$()),[]),t=A$(e),{snap:n,activity:i}=t,[a,c]=M$(),d=v3(),u=nP(e,t),f=E3(e.kind),m=N$(),g=A3(i,t.mapId);w3(i.pending.length,n==null?void 0:n.map.title);const k=y3(t),w=f4({snap:n,selectMap:t.actions.selectMap,openTicket:k.openTicket,openTrailChecks:k.openTrailChecks}),b=eA(w.briefText),S=v4({api:t,nav:k,knowledge:b,reviewBrief:w.review,openReroute:me=>w.openReroute(me.mapId,me.ref),openGuides:()=>d.open("guides"),openConnector:me=>d.open(me),openApprovals:()=>d.open("approvals"),openRule:me=>OI(d.open,me),openFocusSettings:()=>d.open("attention")}),x=S.attention.view,C=C$(e,t,a.briefing,x==null?void 0:x.items),N=S3({snap:n,sessions:g.sessions,view:x}),P=N3(t.mapId,N.items),{projects:D,overview:M,openOverview:H,closeOverview:_}=rD(m,k,S.link.request),Y=d.route&&s.jsx(BL,{rt:e,api:t,bp:m,prefs:a,update:c,settings:d,openTicket:k.openTicket}),re=(k.statsOpen||k.page)&&s.jsx(iD,{api:t,bp:m,nav:k,scoped:g,done:w.done,attn:S}),q=Y||M||re;T3({...t,view:x,busy:!!q||!!t.selection,open:S.open});const Z=k.page??"map",Ae=me=>{d.dismiss(),_(),me==="map"?k.toMap():k.openPage(me)},ye=m==="mobile",be=s.jsx(m3,{api:t,live:N.live,main:P.tone,focus:N.focus,onSelect:k.select,onNewTrail:u.open,minFit:ye?.7:0,docked:ye,trail:w,bubble:me=>s.jsx(DR,{api:t,nav:k,attn:S,sessions:g.sessions,mainNeeds:P.needs,place:me})}),de=s.jsx(tP,{api:t,nav:k,attn:S,trail:N,bp:m,brief:w.inboxCard}),Re=s.jsx(W$,{brief:C,snaps:t.allSnaps,bp:m,openTicket:k.openTicket,openChat:k.openChat,openDecisions:k.openDecisions,openQuestion:k.openQuestion,toMap:k.toMap});return s.jsx(ny.Provider,{value:b,children:s.jsxs("div",{className:`app bp-${m} view-${Z}`,children:[s.jsx(BR,{api:t,rt:e,repo:s.jsx(qM,{repo:f,projects:D,onOverview:H}),brief:C,attention:S.header,view:Y||M?void 0:Z,onView:Ae,phone:ye,needs:N.items,elsewhere:N.elsewhere,onNeed:S.open,onStats:()=>{d.dismiss(),k.toggleStats()},onNewTrail:u.open,onStartOver:()=>n&&u.startOver(n.map),onSettings:d.toggle,onSlack:()=>d.open("slack"),onToggleTheme:me=>c({theme:me?"night":"day"})}),ye?s.jsxs(s.Fragment,{children:[s.jsx(g3,{covered:q,map:be,trailBar:de,projects:D.many&&s.jsx(YM,{projects:D,onOverview:H})}),s.jsx(p3,{view:Z,covered:!!Y||!!M,needs:N.items.length,onPick:Ae})]}):s.jsxs(s.Fragment,{children:[be,de,q]}),s.jsx(FL,{api:t,nav:k,attn:S,sessions:g.sessions,done:w.done}),Re,w.dialog,t.error&&s.jsx("div",{className:"error-toast",children:t.error}),u.dialog,!a.onboarded&&s.jsx(II,{prefs:a,update:c,activeTracker:e.kind}),s.jsx(XE,{}),s.jsx(uD,{})]})})}const fD="X-Teamtrail-Session";function mD(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url}function pD(e){const t=new URL(mD(e),location.href),n=J.apiPrefix;return t.origin===location.origin&&(t.pathname===n||t.pathname.startsWith(`${n}/`))}function gD(){const e=window.fetch.bind(window);window.fetch=(t,n)=>{const i=V1()?wu():void 0;if(!i||!pD(t))return e(t,n);const a=new Headers((n==null?void 0:n.headers)??(t instanceof Request?t.headers:void 0));return a.set(fD,i.secret),e(t,{...n,headers:a})}}Oa(bu().theme);gD();hj.createRoot(document.getElementById("root")).render(s.jsxs(CL,{children:[s.jsx(hD,{}),s.jsx(D$,{})]}));
|