teamtrail 0.52.1 → 0.61.0

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 Yx=Object.defineProperty;var Jx=(e,t,n)=>t in e?Yx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var oe=(e,t,n)=>Jx(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"]'))r(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"&&r(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 r(a){if(a.ep)return;a.ep=!0;const c=n(a);fetch(a.href,c)}})();var zl={exports:{}},ar={},Ul={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 Dm;function Xx(){if(Dm)return xe;Dm=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),d=Symbol.for("react.context"),h=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,ce){this.props=E,this.context=F,this.refs=x,this.updater=ce||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,ce){this.props=E,this.context=F,this.refs=x,this.updater=ce||b}var D=P.prototype=new N;D.constructor=P,S(D,C.prototype),D.isPureReactComponent=!0;var M=Array.isArray,W=Object.prototype.hasOwnProperty,_={current:null},Y={key:!0,ref:!0,__self:!0,__source:!0};function re(E,F,ce){var he,we={},je=null,ge=null;if(F!=null)for(he in F.ref!==void 0&&(ge=F.ref),F.key!==void 0&&(je=""+F.key),F)W.call(F,he)&&!Y.hasOwnProperty(he)&&(we[he]=F[he]);var $e=arguments.length-2;if($e===1)we.children=ce;else if(1<$e){for(var ve=Array($e),Ge=0;Ge<$e;Ge++)ve[Ge]=arguments[Ge+2];we.children=ve}if(E&&E.defaultProps)for(he in $e=E.defaultProps,$e)we[he]===void 0&&(we[he]=$e[he]);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 ye(E){return typeof E=="object"&&E!==null&&E.$$typeof===e}function Ie(E){var F={"=":"=0",":":"=2"};return"$"+E.replace(/[=:]/g,function(ce){return F[ce]})}var be=/\/+/g;function Z(E,F){return typeof E=="object"&&E!==null&&E.key!=null?Ie(""+E.key):F.toString(36)}function se(E,F,ce,he,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=he===""?"."+Z(ge,0):he,M(we)?(ce="",E!=null&&(ce=E.replace(be,"$&/")+"/"),se(we,F,ce,"",function(Ge){return Ge})):we!=null&&(ye(we)&&(we=q(we,ce+(!we.key||ge&&ge.key===we.key?"":(""+we.key).replace(be,"$&/")+"/")+E)),F.push(we)),1;if(ge=0,he=he===""?".":he+":",M(E))for(var $e=0;$e<E.length;$e++){je=E[$e];var ve=he+Z(je,$e);ge+=se(je,F,ce,ve,we)}else if(ve=w(E),typeof ve=="function")for(E=ve.call(E),$e=0;!(je=E.next()).done;)je=je.value,ve=he+Z(je,$e++),ge+=se(je,F,ce,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 Ne(E,F,ce){if(E==null)return E;var he=[],we=0;return se(E,he,"","",function(je){return F.call(ce,je,we++)}),he}function me(E){if(E._status===-1){var F=E._result;F=F(),F.then(function(ce){(E._status===0||E._status===-1)&&(E._status=1,E._result=ce)},function(ce){(E._status===0||E._status===-1)&&(E._status=2,E._result=ce)}),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:Ne,forEach:function(E,F,ce){Ne(E,function(){F.apply(this,arguments)},ce)},count:function(E){var F=0;return Ne(E,function(){F++}),F},toArray:function(E){return Ne(E,function(F){return F})||[]},only:function(E){if(!ye(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=r,xe.Suspense=f,xe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Q,xe.act=U,xe.cloneElement=function(E,F,ce){if(E==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+E+".");var he=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 $e=E.type.defaultProps;for(ve in F)W.call(F,ve)&&!Y.hasOwnProperty(ve)&&(he[ve]=F[ve]===void 0&&$e!==void 0?$e[ve]:F[ve])}var ve=arguments.length-2;if(ve===1)he.children=ce;else if(1<ve){$e=Array(ve);for(var Ge=0;Ge<ve;Ge++)$e[Ge]=arguments[Ge+2];he.children=$e}return{$$typeof:e,type:E.type,key:we,ref:je,props:he,_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:h,render:E}},xe.isValidElement=ye,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,ce){return Se.current.useImperativeHandle(E,F,ce)},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,ce){return Se.current.useReducer(E,F,ce)},xe.useRef=function(E){return Se.current.useRef(E)},xe.useState=function(E){return Se.current.useState(E)},xe.useSyncExternalStore=function(E,F,ce){return Se.current.useSyncExternalStore(E,F,ce)},xe.useTransition=function(){return Se.current.useTransition()},xe.version="18.3.1",xe}var _m;function tu(){return _m||(_m=1,Ul.exports=Xx()),Ul.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 Bm;function Zx(){if(Bm)return ar;Bm=1;var e=tu(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=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(h,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)r.call(f,g)&&!c.hasOwnProperty(g)&&(k[g]=f[g]);if(h&&h.defaultProps)for(g in f=h.defaultProps,f)k[g]===void 0&&(k[g]=f[g]);return{$$typeof:t,type:h,key:w,ref:b,props:k,_owner:a.current}}return ar.Fragment=n,ar.jsx=d,ar.jsxs=d,ar}var Fm;function ej(){return Fm||(Fm=1,zl.exports=Zx()),zl.exports}var s=ej(),Fo={},Wl={exports:{}},Nt={},Hl={exports:{}},Kl={};/**
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 zm;function tj(){return zm||(zm=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 r(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,ce=F>>>1;E<ce;){var he=2*(E+1)-1,we=z[he],je=he+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[he]=U,E=he);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,h=d.now();e.unstable_now=function(){return d.now()-h}}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)r(m);else if(Q.startTime<=z)r(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(W);else{var Q=n(m);Q!==null&&Se(M,Q.startTime-z)}}function W(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&&!Ie());){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)&&r(f),D(Q)}else r(f);k=n(f)}if(k!==null)var ce=!0;else{var he=n(m);he!==null&&Se(M,he.startTime-Q),ce=!1}return ce}finally{k=null,w=U,b=!1}}var _=!1,Y=null,re=-1,q=5,ye=-1;function Ie(){return!(e.unstable_now()-ye<q)}function be(){if(Y!==null){var z=e.unstable_now();ye=z;var Q=!0;try{Q=Y(!0,z)}finally{Q?Z():(_=!1,Y=null)}}else _=!1}var Z;if(typeof P=="function")Z=function(){P(be)};else if(typeof MessageChannel<"u"){var se=new MessageChannel,Ne=se.port2;se.port1.onmessage=be,Z=function(){Ne.postMessage(null)}}else Z=function(){C(be,0)};function me(z){Y=z,_||(_=!0,Z())}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(W))},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(W))),z},e.unstable_shouldYield=Ie,e.unstable_wrapCallback=function(z){var Q=w;return function(){var U=w;w=Q;try{return z.apply(this,arguments)}finally{w=U}}}})(Kl)),Kl}var Um;function nj(){return Um||(Um=1,Hl.exports=tj()),Hl.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 Wm;function sj(){if(Wm)return Nt;Wm=1;var e=tu(),t=nj();function n(i){for(var o="https://reactjs.org/docs/error-decoder.html?invariant="+i,l=1;l<arguments.length;l++)o+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+i+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,a={};function c(i,o){d(i,o),d(i+"Capture",o)}function d(i,o){for(a[i]=o,i=0;i<o.length;i++)r.add(o[i])}var h=!(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(i){return f.call(k,i)?!0:f.call(g,i)?!1:m.test(i)?k[i]=!0:(g[i]=!0,!1)}function b(i,o,l,u){if(l!==null&&l.type===0)return!1;switch(typeof o){case"function":case"symbol":return!0;case"boolean":return u?!1:l!==null?!l.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function S(i,o,l,u){if(o===null||typeof o>"u"||b(i,o,l,u))return!0;if(u)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(i,o,l,u,p,v,j){this.acceptsBooleans=o===2||o===3||o===4,this.attributeName=u,this.attributeNamespace=p,this.mustUseProperty=l,this.propertyName=i,this.type=o,this.sanitizeURL=v,this.removeEmptyString=j}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){C[i]=new x(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var o=i[0];C[o]=new x(o,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){C[i]=new x(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){C[i]=new x(i,2,!1,i,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(i){C[i]=new x(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){C[i]=new x(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){C[i]=new x(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){C[i]=new x(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){C[i]=new x(i,5,!1,i.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function P(i){return i[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(i){var o=i.replace(N,P);C[o]=new x(o,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var o=i.replace(N,P);C[o]=new x(o,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var o=i.replace(N,P);C[o]=new x(o,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){C[i]=new x(i,1,!1,i.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(i){C[i]=new x(i,1,!1,i.toLowerCase(),null,!0,!0)});function D(i,o,l,u){var p=C.hasOwnProperty(o)?C[o]:null;(p!==null?p.type!==0:u||!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(S(o,l,p,u)&&(l=null),u||p===null?w(o)&&(l===null?i.removeAttribute(o):i.setAttribute(o,""+l)):p.mustUseProperty?i[p.propertyName]=l===null?p.type===3?!1:"":l:(o=p.attributeName,u=p.attributeNamespace,l===null?i.removeAttribute(o):(p=p.type,l=p===3||p===4&&l===!0?"":""+l,u?i.setAttributeNS(u,o,l):i.setAttribute(o,l))))}var M=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,W=Symbol.for("react.element"),_=Symbol.for("react.portal"),Y=Symbol.for("react.fragment"),re=Symbol.for("react.strict_mode"),q=Symbol.for("react.profiler"),ye=Symbol.for("react.provider"),Ie=Symbol.for("react.context"),be=Symbol.for("react.forward_ref"),Z=Symbol.for("react.suspense"),se=Symbol.for("react.suspense_list"),Ne=Symbol.for("react.memo"),me=Symbol.for("react.lazy"),Se=Symbol.for("react.offscreen"),z=Symbol.iterator;function Q(i){return i===null||typeof i!="object"?null:(i=z&&i[z]||i["@@iterator"],typeof i=="function"?i:null)}var U=Object.assign,E;function F(i){if(E===void 0)try{throw Error()}catch(l){var o=l.stack.trim().match(/\n( *(at )?)/);E=o&&o[1]||""}return`
34
+ `+E+i}var ce=!1;function he(i,o){if(!i||ce)return"";ce=!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 u=L}Reflect.construct(i,[],o)}else{try{o.call()}catch(L){u=L}i.call(o.prototype)}else{try{throw Error()}catch(L){u=L}i()}}catch(L){if(L&&u&&typeof L.stack=="string"){for(var p=L.stack.split(`
35
+ `),v=u.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 i.displayName&&T.includes("<anonymous>")&&(T=T.replace("<anonymous>",i.displayName)),T}while(1<=j&&0<=$);break}}}finally{ce=!1,Error.prepareStackTrace=l}return(i=i?i.displayName||i.name:"")?F(i):""}function we(i){switch(i.tag){case 5:return F(i.type);case 16:return F("Lazy");case 13:return F("Suspense");case 19:return F("SuspenseList");case 0:case 2:case 15:return i=he(i.type,!1),i;case 11:return i=he(i.type.render,!1),i;case 1:return i=he(i.type,!0),i;default:return""}}function je(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case Y:return"Fragment";case _:return"Portal";case q:return"Profiler";case re:return"StrictMode";case Z:return"Suspense";case se:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case Ie:return(i.displayName||"Context")+".Consumer";case ye:return(i._context.displayName||"Context")+".Provider";case be:var o=i.render;return i=i.displayName,i||(i=o.displayName||o.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case Ne:return o=i.displayName||null,o!==null?o:je(i.type)||"Memo";case me:o=i._payload,i=i._init;try{return je(i(o))}catch{}}return null}function ge(i){var o=i.type;switch(i.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 i=o.render,i=i.displayName||i.name||"",o.displayName||(i!==""?"ForwardRef("+i+")":"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 $e(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function ve(i){var o=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function Ge(i){var o=ve(i)?"checked":"value",l=Object.getOwnPropertyDescriptor(i.constructor.prototype,o),u=""+i[o];if(!i.hasOwnProperty(o)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var p=l.get,v=l.set;return Object.defineProperty(i,o,{configurable:!0,get:function(){return p.call(this)},set:function(j){u=""+j,v.call(this,j)}}),Object.defineProperty(i,o,{enumerable:l.enumerable}),{getValue:function(){return u},setValue:function(j){u=""+j},stopTracking:function(){i._valueTracker=null,delete i[o]}}}}function Rn(i){i._valueTracker||(i._valueTracker=Ge(i))}function Ar(i){if(!i)return!1;var o=i._valueTracker;if(!o)return!0;var l=o.getValue(),u="";return i&&(u=ve(i)?i.checked?"true":"false":i.value),i=u,i!==l?(o.setValue(i),!0):!1}function As(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}function qa(i,o){var l=o.checked;return U({},o,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??i._wrapperState.initialChecked})}function Wu(i,o){var l=o.defaultValue==null?"":o.defaultValue,u=o.checked!=null?o.checked:o.defaultChecked;l=$e(o.value!=null?o.value:l),i._wrapperState={initialChecked:u,initialValue:l,controlled:o.type==="checkbox"||o.type==="radio"?o.checked!=null:o.value!=null}}function Hu(i,o){o=o.checked,o!=null&&D(i,"checked",o,!1)}function Qa(i,o){Hu(i,o);var l=$e(o.value),u=o.type;if(l!=null)u==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+l):i.value!==""+l&&(i.value=""+l);else if(u==="submit"||u==="reset"){i.removeAttribute("value");return}o.hasOwnProperty("value")?Ya(i,o.type,l):o.hasOwnProperty("defaultValue")&&Ya(i,o.type,$e(o.defaultValue)),o.checked==null&&o.defaultChecked!=null&&(i.defaultChecked=!!o.defaultChecked)}function Ku(i,o,l){if(o.hasOwnProperty("value")||o.hasOwnProperty("defaultValue")){var u=o.type;if(!(u!=="submit"&&u!=="reset"||o.value!==void 0&&o.value!==null))return;o=""+i._wrapperState.initialValue,l||o===i.value||(i.value=o),i.defaultValue=o}l=i.name,l!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,l!==""&&(i.name=l)}function Ya(i,o,l){(o!=="number"||As(i.ownerDocument)!==i)&&(l==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+l&&(i.defaultValue=""+l))}var ji=Array.isArray;function Rs(i,o,l,u){if(i=i.options,o){o={};for(var p=0;p<l.length;p++)o["$"+l[p]]=!0;for(l=0;l<i.length;l++)p=o.hasOwnProperty("$"+i[l].value),i[l].selected!==p&&(i[l].selected=p),p&&u&&(i[l].defaultSelected=!0)}else{for(l=""+$e(l),o=null,p=0;p<i.length;p++){if(i[p].value===l){i[p].selected=!0,u&&(i[p].defaultSelected=!0);return}o!==null||i[p].disabled||(o=i[p])}o!==null&&(o.selected=!0)}}function Ja(i,o){if(o.dangerouslySetInnerHTML!=null)throw Error(n(91));return U({},o,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function Gu(i,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}i._wrapperState={initialValue:$e(l)}}function Vu(i,o){var l=$e(o.value),u=$e(o.defaultValue);l!=null&&(l=""+l,l!==i.value&&(i.value=l),o.defaultValue==null&&i.defaultValue!==l&&(i.defaultValue=l)),u!=null&&(i.defaultValue=""+u)}function qu(i){var o=i.textContent;o===i._wrapperState.initialValue&&o!==""&&o!==null&&(i.value=o)}function Qu(i){switch(i){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 Xa(i,o){return i==null||i==="http://www.w3.org/1999/xhtml"?Qu(o):i==="http://www.w3.org/2000/svg"&&o==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var Rr,Yu=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(o,l,u,p){MSApp.execUnsafeLocalFunction(function(){return i(o,l,u,p)})}:i})(function(i,o){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=o;else{for(Rr=Rr||document.createElement("div"),Rr.innerHTML="<svg>"+o.valueOf().toString()+"</svg>",o=Rr.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;o.firstChild;)i.appendChild(o.firstChild)}});function bi(i,o){if(o){var l=i.firstChild;if(l&&l===i.lastChild&&l.nodeType===3){l.nodeValue=o;return}}i.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},ew=["Webkit","ms","Moz","O"];Object.keys(Si).forEach(function(i){ew.forEach(function(o){o=o+i.charAt(0).toUpperCase()+i.substring(1),Si[o]=Si[i]})});function Ju(i,o,l){return o==null||typeof o=="boolean"||o===""?"":l||typeof o!="number"||o===0||Si.hasOwnProperty(i)&&Si[i]?(""+o).trim():o+"px"}function Xu(i,o){i=i.style;for(var l in o)if(o.hasOwnProperty(l)){var u=l.indexOf("--")===0,p=Ju(l,o[l],u);l==="float"&&(l="cssFloat"),u?i.setProperty(l,p):i[l]=p}}var tw=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 Za(i,o){if(o){if(tw[i]&&(o.children!=null||o.dangerouslySetInnerHTML!=null))throw Error(n(137,i));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 ec(i,o){if(i.indexOf("-")===-1)return typeof o.is=="string";switch(i){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 tc=null;function nc(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var sc=null,Ms=null,Is=null;function Zu(i){if(i=Gi(i)){if(typeof sc!="function")throw Error(n(280));var o=i.stateNode;o&&(o=eo(o),sc(i.stateNode,i.type,o))}}function eh(i){Ms?Is?Is.push(i):Is=[i]:Ms=i}function th(){if(Ms){var i=Ms,o=Is;if(Is=Ms=null,Zu(i),o)for(i=0;i<o.length;i++)Zu(o[i])}}function nh(i,o){return i(o)}function sh(){}var ic=!1;function ih(i,o,l){if(ic)return i(o,l);ic=!0;try{return nh(i,o,l)}finally{ic=!1,(Ms!==null||Is!==null)&&(sh(),th())}}function Ni(i,o){var l=i.stateNode;if(l===null)return null;var u=eo(l);if(u===null)return null;l=u[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":(u=!u.disabled)||(i=i.type,u=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!u;break e;default:i=!1}if(i)return null;if(l&&typeof l!="function")throw Error(n(231,o,typeof l));return l}var rc=!1;if(h)try{var $i={};Object.defineProperty($i,"passive",{get:function(){rc=!0}}),window.addEventListener("test",$i,$i),window.removeEventListener("test",$i,$i)}catch{rc=!1}function nw(i,o,l,u,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,Mr=null,Ir=!1,oc=null,sw={onError:function(i){Ci=!0,Mr=i}};function iw(i,o,l,u,p,v,j,$,T){Ci=!1,Mr=null,nw.apply(sw,arguments)}function rw(i,o,l,u,p,v,j,$,T){if(iw.apply(this,arguments),Ci){if(Ci){var L=Mr;Ci=!1,Mr=null}else throw Error(n(198));Ir||(Ir=!0,oc=L)}}function os(i){var o=i,l=i;if(i.alternate)for(;o.return;)o=o.return;else{i=o;do o=i,(o.flags&4098)!==0&&(l=o.return),i=o.return;while(i)}return o.tag===3?l:null}function rh(i){if(i.tag===13){var o=i.memoizedState;if(o===null&&(i=i.alternate,i!==null&&(o=i.memoizedState)),o!==null)return o.dehydrated}return null}function oh(i){if(os(i)!==i)throw Error(n(188))}function ow(i){var o=i.alternate;if(!o){if(o=os(i),o===null)throw Error(n(188));return o!==i?null:i}for(var l=i,u=o;;){var p=l.return;if(p===null)break;var v=p.alternate;if(v===null){if(u=p.return,u!==null){l=u;continue}break}if(p.child===v.child){for(v=p.child;v;){if(v===l)return oh(p),i;if(v===u)return oh(p),o;v=v.sibling}throw Error(n(188))}if(l.return!==u.return)l=p,u=v;else{for(var j=!1,$=p.child;$;){if($===l){j=!0,l=p,u=v;break}if($===u){j=!0,u=p,l=v;break}$=$.sibling}if(!j){for($=v.child;$;){if($===l){j=!0,l=v,u=p;break}if($===u){j=!0,u=v,l=p;break}$=$.sibling}if(!j)throw Error(n(189))}}if(l.alternate!==u)throw Error(n(190))}if(l.tag!==3)throw Error(n(188));return l.stateNode.current===l?i:o}function ah(i){return i=ow(i),i!==null?ch(i):null}function ch(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var o=ch(i);if(o!==null)return o;i=i.sibling}return null}var lh=t.unstable_scheduleCallback,dh=t.unstable_cancelCallback,aw=t.unstable_shouldYield,cw=t.unstable_requestPaint,qe=t.unstable_now,lw=t.unstable_getCurrentPriorityLevel,ac=t.unstable_ImmediatePriority,uh=t.unstable_UserBlockingPriority,Or=t.unstable_NormalPriority,dw=t.unstable_LowPriority,hh=t.unstable_IdlePriority,Lr=null,on=null;function uw(i){if(on&&typeof on.onCommitFiberRoot=="function")try{on.onCommitFiberRoot(Lr,i,void 0,(i.current.flags&128)===128)}catch{}}var qt=Math.clz32?Math.clz32:mw,hw=Math.log,fw=Math.LN2;function mw(i){return i>>>=0,i===0?32:31-(hw(i)/fw|0)|0}var Pr=64,Dr=4194304;function Ti(i){switch(i&-i){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 i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function _r(i,o){var l=i.pendingLanes;if(l===0)return 0;var u=0,p=i.suspendedLanes,v=i.pingedLanes,j=l&268435455;if(j!==0){var $=j&~p;$!==0?u=Ti($):(v&=j,v!==0&&(u=Ti(v)))}else j=l&~p,j!==0?u=Ti(j):v!==0&&(u=Ti(v));if(u===0)return 0;if(o!==0&&o!==u&&(o&p)===0&&(p=u&-u,v=o&-o,p>=v||p===16&&(v&4194240)!==0))return o;if((u&4)!==0&&(u|=l&16),o=i.entangledLanes,o!==0)for(i=i.entanglements,o&=u;0<o;)l=31-qt(o),p=1<<l,u|=i[l],o&=~p;return u}function pw(i,o){switch(i){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 gw(i,o){for(var l=i.suspendedLanes,u=i.pingedLanes,p=i.expirationTimes,v=i.pendingLanes;0<v;){var j=31-qt(v),$=1<<j,T=p[j];T===-1?(($&l)===0||($&u)!==0)&&(p[j]=pw($,o)):T<=o&&(i.expiredLanes|=$),v&=~$}}function cc(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function fh(){var i=Pr;return Pr<<=1,(Pr&4194240)===0&&(Pr=64),i}function lc(i){for(var o=[],l=0;31>l;l++)o.push(i);return o}function Ei(i,o,l){i.pendingLanes|=o,o!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,o=31-qt(o),i[o]=l}function vw(i,o){var l=i.pendingLanes&~o;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=o,i.mutableReadLanes&=o,i.entangledLanes&=o,o=i.entanglements;var u=i.eventTimes;for(i=i.expirationTimes;0<l;){var p=31-qt(l),v=1<<p;o[p]=0,u[p]=-1,i[p]=-1,l&=~v}}function dc(i,o){var l=i.entangledLanes|=o;for(i=i.entanglements;l;){var u=31-qt(l),p=1<<u;p&o|i[u]&o&&(i[u]|=o),l&=~p}}var Re=0;function mh(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var ph,uc,gh,vh,kh,hc=!1,Br=[],Mn=null,In=null,On=null,Ai=new Map,Ri=new Map,Ln=[],kw="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 yh(i,o){switch(i){case"focusin":case"focusout":Mn=null;break;case"dragenter":case"dragleave":In=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 Mi(i,o,l,u,p,v){return i===null||i.nativeEvent!==v?(i={blockedOn:o,domEventName:l,eventSystemFlags:u,nativeEvent:v,targetContainers:[p]},o!==null&&(o=Gi(o),o!==null&&uc(o)),i):(i.eventSystemFlags|=u,o=i.targetContainers,p!==null&&o.indexOf(p)===-1&&o.push(p),i)}function yw(i,o,l,u,p){switch(o){case"focusin":return Mn=Mi(Mn,i,o,l,u,p),!0;case"dragenter":return In=Mi(In,i,o,l,u,p),!0;case"mouseover":return On=Mi(On,i,o,l,u,p),!0;case"pointerover":var v=p.pointerId;return Ai.set(v,Mi(Ai.get(v)||null,i,o,l,u,p)),!0;case"gotpointercapture":return v=p.pointerId,Ri.set(v,Mi(Ri.get(v)||null,i,o,l,u,p)),!0}return!1}function wh(i){var o=as(i.target);if(o!==null){var l=os(o);if(l!==null){if(o=l.tag,o===13){if(o=rh(l),o!==null){i.blockedOn=o,kh(i.priority,function(){gh(l)});return}}else if(o===3&&l.stateNode.current.memoizedState.isDehydrated){i.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Fr(i){if(i.blockedOn!==null)return!1;for(var o=i.targetContainers;0<o.length;){var l=mc(i.domEventName,i.eventSystemFlags,o[0],i.nativeEvent);if(l===null){l=i.nativeEvent;var u=new l.constructor(l.type,l);tc=u,l.target.dispatchEvent(u),tc=null}else return o=Gi(l),o!==null&&uc(o),i.blockedOn=l,!1;o.shift()}return!0}function xh(i,o,l){Fr(i)&&l.delete(o)}function ww(){hc=!1,Mn!==null&&Fr(Mn)&&(Mn=null),In!==null&&Fr(In)&&(In=null),On!==null&&Fr(On)&&(On=null),Ai.forEach(xh),Ri.forEach(xh)}function Ii(i,o){i.blockedOn===o&&(i.blockedOn=null,hc||(hc=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,ww)))}function Oi(i){function o(p){return Ii(p,i)}if(0<Br.length){Ii(Br[0],i);for(var l=1;l<Br.length;l++){var u=Br[l];u.blockedOn===i&&(u.blockedOn=null)}}for(Mn!==null&&Ii(Mn,i),In!==null&&Ii(In,i),On!==null&&Ii(On,i),Ai.forEach(o),Ri.forEach(o),l=0;l<Ln.length;l++)u=Ln[l],u.blockedOn===i&&(u.blockedOn=null);for(;0<Ln.length&&(l=Ln[0],l.blockedOn===null);)wh(l),l.blockedOn===null&&Ln.shift()}var Os=M.ReactCurrentBatchConfig,zr=!0;function xw(i,o,l,u){var p=Re,v=Os.transition;Os.transition=null;try{Re=1,fc(i,o,l,u)}finally{Re=p,Os.transition=v}}function jw(i,o,l,u){var p=Re,v=Os.transition;Os.transition=null;try{Re=4,fc(i,o,l,u)}finally{Re=p,Os.transition=v}}function fc(i,o,l,u){if(zr){var p=mc(i,o,l,u);if(p===null)Rc(i,o,u,Ur,l),yh(i,u);else if(yw(p,i,o,l,u))u.stopPropagation();else if(yh(i,u),o&4&&-1<kw.indexOf(i)){for(;p!==null;){var v=Gi(p);if(v!==null&&ph(v),v=mc(i,o,l,u),v===null&&Rc(i,o,u,Ur,l),v===p)break;p=v}p!==null&&u.stopPropagation()}else Rc(i,o,u,null,l)}}var Ur=null;function mc(i,o,l,u){if(Ur=null,i=nc(u),i=as(i),i!==null)if(o=os(i),o===null)i=null;else if(l=o.tag,l===13){if(i=rh(o),i!==null)return i;i=null}else if(l===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;i=null}else o!==i&&(i=null);return Ur=i,null}function jh(i){switch(i){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(lw()){case ac:return 1;case uh:return 4;case Or:case dw:return 16;case hh:return 536870912;default:return 16}default:return 16}}var Pn=null,pc=null,Wr=null;function bh(){if(Wr)return Wr;var i,o=pc,l=o.length,u,p="value"in Pn?Pn.value:Pn.textContent,v=p.length;for(i=0;i<l&&o[i]===p[i];i++);var j=l-i;for(u=1;u<=j&&o[l-u]===p[v-u];u++);return Wr=p.slice(i,1<u?1-u:void 0)}function Hr(i){var o=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&o===13&&(i=13)):i=o,i===10&&(i=13),32<=i||i===13?i:0}function Kr(){return!0}function Sh(){return!1}function At(i){function o(l,u,p,v,j){this._reactName=l,this._targetInst=p,this.type=u,this.nativeEvent=v,this.target=j,this.currentTarget=null;for(var $ in i)i.hasOwnProperty($)&&(l=i[$],this[$]=l?l(v):v[$]);return this.isDefaultPrevented=(v.defaultPrevented!=null?v.defaultPrevented:v.returnValue===!1)?Kr:Sh,this.isPropagationStopped=Sh,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(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},gc=At(Ls),Li=U({},Ls,{view:0,detail:0}),bw=At(Li),vc,kc,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:wc,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==Pi&&(Pi&&i.type==="mousemove"?(vc=i.screenX-Pi.screenX,kc=i.screenY-Pi.screenY):kc=vc=0,Pi=i),vc)},movementY:function(i){return"movementY"in i?i.movementY:kc}}),Nh=At(Gr),Sw=U({},Gr,{dataTransfer:0}),Nw=At(Sw),$w=U({},Li,{relatedTarget:0}),yc=At($w),Cw=U({},Ls,{animationName:0,elapsedTime:0,pseudoElement:0}),Tw=At(Cw),Ew=U({},Ls,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Aw=At(Ew),Rw=U({},Ls,{data:0}),$h=At(Rw),Mw={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Iw={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"},Ow={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Lw(i){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(i):(i=Ow[i])?!!o[i]:!1}function wc(){return Lw}var Pw=U({},Li,{key:function(i){if(i.key){var o=Mw[i.key]||i.key;if(o!=="Unidentified")return o}return i.type==="keypress"?(i=Hr(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Iw[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:wc,charCode:function(i){return i.type==="keypress"?Hr(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Hr(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Dw=At(Pw),_w=U({},Gr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ch=At(_w),Bw=U({},Li,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:wc}),Fw=At(Bw),zw=U({},Ls,{propertyName:0,elapsedTime:0,pseudoElement:0}),Uw=At(zw),Ww=U({},Gr,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),Hw=At(Ww),Kw=[9,13,27,32],xc=h&&"CompositionEvent"in window,Di=null;h&&"documentMode"in document&&(Di=document.documentMode);var Gw=h&&"TextEvent"in window&&!Di,Th=h&&(!xc||Di&&8<Di&&11>=Di),Eh=" ",Ah=!1;function Rh(i,o){switch(i){case"keyup":return Kw.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Mh(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ps=!1;function Vw(i,o){switch(i){case"compositionend":return Mh(o);case"keypress":return o.which!==32?null:(Ah=!0,Eh);case"textInput":return i=o.data,i===Eh&&Ah?null:i;default:return null}}function qw(i,o){if(Ps)return i==="compositionend"||!xc&&Rh(i,o)?(i=bh(),Wr=pc=Pn=null,Ps=!1,i):null;switch(i){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 Th&&o.locale!=="ko"?null:o.data;default:return null}}var Qw={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 Ih(i){var o=i&&i.nodeName&&i.nodeName.toLowerCase();return o==="input"?!!Qw[i.type]:o==="textarea"}function Oh(i,o,l,u){eh(u),o=Jr(o,"onChange"),0<o.length&&(l=new gc("onChange","change",null,l,u),i.push({event:l,listeners:o}))}var _i=null,Bi=null;function Yw(i){Xh(i,0)}function Vr(i){var o=zs(i);if(Ar(o))return i}function Jw(i,o){if(i==="change")return o}var Lh=!1;if(h){var jc;if(h){var bc="oninput"in document;if(!bc){var Ph=document.createElement("div");Ph.setAttribute("oninput","return;"),bc=typeof Ph.oninput=="function"}jc=bc}else jc=!1;Lh=jc&&(!document.documentMode||9<document.documentMode)}function Dh(){_i&&(_i.detachEvent("onpropertychange",_h),Bi=_i=null)}function _h(i){if(i.propertyName==="value"&&Vr(Bi)){var o=[];Oh(o,Bi,i,nc(i)),ih(Yw,o)}}function Xw(i,o,l){i==="focusin"?(Dh(),_i=o,Bi=l,_i.attachEvent("onpropertychange",_h)):i==="focusout"&&Dh()}function Zw(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Vr(Bi)}function ex(i,o){if(i==="click")return Vr(o)}function tx(i,o){if(i==="input"||i==="change")return Vr(o)}function nx(i,o){return i===o&&(i!==0||1/i===1/o)||i!==i&&o!==o}var Qt=typeof Object.is=="function"?Object.is:nx;function Fi(i,o){if(Qt(i,o))return!0;if(typeof i!="object"||i===null||typeof o!="object"||o===null)return!1;var l=Object.keys(i),u=Object.keys(o);if(l.length!==u.length)return!1;for(u=0;u<l.length;u++){var p=l[u];if(!f.call(o,p)||!Qt(i[p],o[p]))return!1}return!0}function Bh(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Fh(i,o){var l=Bh(i);i=0;for(var u;l;){if(l.nodeType===3){if(u=i+l.textContent.length,i<=o&&u>=o)return{node:l,offset:o-i};i=u}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Bh(l)}}function zh(i,o){return i&&o?i===o?!0:i&&i.nodeType===3?!1:o&&o.nodeType===3?zh(i,o.parentNode):"contains"in i?i.contains(o):i.compareDocumentPosition?!!(i.compareDocumentPosition(o)&16):!1:!1}function Uh(){for(var i=window,o=As();o instanceof i.HTMLIFrameElement;){try{var l=typeof o.contentWindow.location.href=="string"}catch{l=!1}if(l)i=o.contentWindow;else break;o=As(i.document)}return o}function Sc(i){var o=i&&i.nodeName&&i.nodeName.toLowerCase();return o&&(o==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||o==="textarea"||i.contentEditable==="true")}function sx(i){var o=Uh(),l=i.focusedElem,u=i.selectionRange;if(o!==l&&l&&l.ownerDocument&&zh(l.ownerDocument.documentElement,l)){if(u!==null&&Sc(l)){if(o=u.start,i=u.end,i===void 0&&(i=o),"selectionStart"in l)l.selectionStart=o,l.selectionEnd=Math.min(i,l.value.length);else if(i=(o=l.ownerDocument||document)&&o.defaultView||window,i.getSelection){i=i.getSelection();var p=l.textContent.length,v=Math.min(u.start,p);u=u.end===void 0?v:Math.min(u.end,p),!i.extend&&v>u&&(p=u,u=v,v=p),p=Fh(l,v);var j=Fh(l,u);p&&j&&(i.rangeCount!==1||i.anchorNode!==p.node||i.anchorOffset!==p.offset||i.focusNode!==j.node||i.focusOffset!==j.offset)&&(o=o.createRange(),o.setStart(p.node,p.offset),i.removeAllRanges(),v>u?(i.addRange(o),i.extend(j.node,j.offset)):(o.setEnd(j.node,j.offset),i.addRange(o)))}}for(o=[],i=l;i=i.parentNode;)i.nodeType===1&&o.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<o.length;l++)i=o[l],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var ix=h&&"documentMode"in document&&11>=document.documentMode,Ds=null,Nc=null,zi=null,$c=!1;function Wh(i,o,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;$c||Ds==null||Ds!==As(u)||(u=Ds,"selectionStart"in u&&Sc(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),zi&&Fi(zi,u)||(zi=u,u=Jr(Nc,"onSelect"),0<u.length&&(o=new gc("onSelect","select",null,o,l),i.push({event:o,listeners:u}),o.target=Ds)))}function qr(i,o){var l={};return l[i.toLowerCase()]=o.toLowerCase(),l["Webkit"+i]="webkit"+o,l["Moz"+i]="moz"+o,l}var _s={animationend:qr("Animation","AnimationEnd"),animationiteration:qr("Animation","AnimationIteration"),animationstart:qr("Animation","AnimationStart"),transitionend:qr("Transition","TransitionEnd")},Cc={},Hh={};h&&(Hh=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(i){if(Cc[i])return Cc[i];if(!_s[i])return i;var o=_s[i],l;for(l in o)if(o.hasOwnProperty(l)&&l in Hh)return Cc[i]=o[l];return i}var Kh=Qr("animationend"),Gh=Qr("animationiteration"),Vh=Qr("animationstart"),qh=Qr("transitionend"),Qh=new Map,Yh="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(i,o){Qh.set(i,o),c(o,[i])}for(var Tc=0;Tc<Yh.length;Tc++){var Ec=Yh[Tc],rx=Ec.toLowerCase(),ox=Ec[0].toUpperCase()+Ec.slice(1);Dn(rx,"on"+ox)}Dn(Kh,"onAnimationEnd"),Dn(Gh,"onAnimationIteration"),Dn(Vh,"onAnimationStart"),Dn("dblclick","onDoubleClick"),Dn("focusin","onFocus"),Dn("focusout","onBlur"),Dn(qh,"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(" "),ax=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ui));function Jh(i,o,l){var u=i.type||"unknown-event";i.currentTarget=l,rw(u,o,void 0,i),i.currentTarget=null}function Xh(i,o){o=(o&4)!==0;for(var l=0;l<i.length;l++){var u=i[l],p=u.event;u=u.listeners;e:{var v=void 0;if(o)for(var j=u.length-1;0<=j;j--){var $=u[j],T=$.instance,L=$.currentTarget;if($=$.listener,T!==v&&p.isPropagationStopped())break e;Jh(p,$,L),v=T}else for(j=0;j<u.length;j++){if($=u[j],T=$.instance,L=$.currentTarget,$=$.listener,T!==v&&p.isPropagationStopped())break e;Jh(p,$,L),v=T}}}if(Ir)throw i=oc,Ir=!1,oc=null,i}function Pe(i,o){var l=o[Dc];l===void 0&&(l=o[Dc]=new Set);var u=i+"__bubble";l.has(u)||(Zh(o,i,2,!1),l.add(u))}function Ac(i,o,l){var u=0;o&&(u|=4),Zh(l,i,u,o)}var Yr="_reactListening"+Math.random().toString(36).slice(2);function Wi(i){if(!i[Yr]){i[Yr]=!0,r.forEach(function(l){l!=="selectionchange"&&(ax.has(l)||Ac(l,!1,i),Ac(l,!0,i))});var o=i.nodeType===9?i:i.ownerDocument;o===null||o[Yr]||(o[Yr]=!0,Ac("selectionchange",!1,o))}}function Zh(i,o,l,u){switch(jh(o)){case 1:var p=xw;break;case 4:p=jw;break;default:p=fc}l=p.bind(null,o,l,i),p=void 0,!rc||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(p=!0),u?p!==void 0?i.addEventListener(o,l,{capture:!0,passive:p}):i.addEventListener(o,l,!0):p!==void 0?i.addEventListener(o,l,{passive:p}):i.addEventListener(o,l,!1)}function Rc(i,o,l,u,p){var v=u;if((o&1)===0&&(o&2)===0&&u!==null)e:for(;;){if(u===null)return;var j=u.tag;if(j===3||j===4){var $=u.stateNode.containerInfo;if($===p||$.nodeType===8&&$.parentNode===p)break;if(j===4)for(j=u.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=as($),j===null)return;if(T=j.tag,T===5||T===6){u=v=j;continue e}$=$.parentNode}}u=u.return}ih(function(){var L=v,K=nc(l),G=[];e:{var H=Qh.get(i);if(H!==void 0){var X=gc,te=i;switch(i){case"keypress":if(Hr(l)===0)break e;case"keydown":case"keyup":X=Dw;break;case"focusin":te="focus",X=yc;break;case"focusout":te="blur",X=yc;break;case"beforeblur":case"afterblur":X=yc;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=Nh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":X=Nw;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":X=Fw;break;case Kh:case Gh:case Vh:X=Tw;break;case qh:X=Uw;break;case"scroll":X=bw;break;case"wheel":X=Hw;break;case"copy":case"cut":case"paste":X=Aw;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":X=Ch}var ne=(o&4)!==0,Qe=!ne&&i==="scroll",R=ne?H!==null?H+"Capture":null:H;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&&(H=new X(H,te,null,l,K),G.push({event:H,listeners:ne}))}}if((o&7)===0){e:{if(H=i==="mouseover"||i==="pointerover",X=i==="mouseout"||i==="pointerout",H&&l!==tc&&(te=l.relatedTarget||l.fromElement)&&(as(te)||te[vn]))break e;if((X||H)&&(H=K.window===K?K:(H=K.ownerDocument)?H.defaultView||H.parentWindow:window,X?(te=l.relatedTarget||l.toElement,X=L,te=te?as(te):null,te!==null&&(Qe=os(te),te!==Qe||te.tag!==5&&te.tag!==6)&&(te=null)):(X=null,te=L),X!==te)){if(ne=Nh,V="onMouseLeave",R="onMouseEnter",A="mouse",(i==="pointerout"||i==="pointerover")&&(ne=Ch,V="onPointerLeave",R="onPointerEnter",A="pointer"),Qe=X==null?H:zs(X),O=te==null?H:zs(te),H=new ne(V,A+"leave",X,l,K),H.target=Qe,H.relatedTarget=O,V=null,as(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&&ef(G,H,X,ne,!1),te!==null&&Qe!==null&&ef(G,Qe,te,ne,!0)}}e:{if(H=L?zs(L):window,X=H.nodeName&&H.nodeName.toLowerCase(),X==="select"||X==="input"&&H.type==="file")var ie=Jw;else if(Ih(H))if(Lh)ie=tx;else{ie=Zw;var le=Xw}else(X=H.nodeName)&&X.toLowerCase()==="input"&&(H.type==="checkbox"||H.type==="radio")&&(ie=ex);if(ie&&(ie=ie(i,L))){Oh(G,ie,l,K);break e}le&&le(i,H,L),i==="focusout"&&(le=H._wrapperState)&&le.controlled&&H.type==="number"&&Ya(H,"number",H.value)}switch(le=L?zs(L):window,i){case"focusin":(Ih(le)||le.contentEditable==="true")&&(Ds=le,Nc=L,zi=null);break;case"focusout":zi=Nc=Ds=null;break;case"mousedown":$c=!0;break;case"contextmenu":case"mouseup":case"dragend":$c=!1,Wh(G,l,K);break;case"selectionchange":if(ix)break;case"keydown":case"keyup":Wh(G,l,K)}var de;if(xc)e:{switch(i){case"compositionstart":var ue="onCompositionStart";break e;case"compositionend":ue="onCompositionEnd";break e;case"compositionupdate":ue="onCompositionUpdate";break e}ue=void 0}else Ps?Rh(i,l)&&(ue="onCompositionEnd"):i==="keydown"&&l.keyCode===229&&(ue="onCompositionStart");ue&&(Th&&l.locale!=="ko"&&(Ps||ue!=="onCompositionStart"?ue==="onCompositionEnd"&&Ps&&(de=bh()):(Pn=K,pc="value"in Pn?Pn.value:Pn.textContent,Ps=!0)),le=Jr(L,ue),0<le.length&&(ue=new $h(ue,i,null,l,K),G.push({event:ue,listeners:le}),de?ue.data=de:(de=Mh(l),de!==null&&(ue.data=de)))),(de=Gw?Vw(i,l):qw(i,l))&&(L=Jr(L,"onBeforeInput"),0<L.length&&(K=new $h("onBeforeInput","beforeinput",null,l,K),G.push({event:K,listeners:L}),K.data=de))}Xh(G,o)})}function Hi(i,o,l){return{instance:i,listener:o,currentTarget:l}}function Jr(i,o){for(var l=o+"Capture",u=[];i!==null;){var p=i,v=p.stateNode;p.tag===5&&v!==null&&(p=v,v=Ni(i,l),v!=null&&u.unshift(Hi(i,v,p)),v=Ni(i,o),v!=null&&u.push(Hi(i,v,p))),i=i.return}return u}function Bs(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function ef(i,o,l,u,p){for(var v=o._reactName,j=[];l!==null&&l!==u;){var $=l,T=$.alternate,L=$.stateNode;if(T!==null&&T===u)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&&i.push({event:o,listeners:j})}var cx=/\r\n?/g,lx=/\u0000|\uFFFD/g;function tf(i){return(typeof i=="string"?i:""+i).replace(cx,`
38
+ `).replace(lx,"")}function Xr(i,o,l){if(o=tf(o),tf(i)!==o&&l)throw Error(n(425))}function Zr(){}var Mc=null,Ic=null;function Oc(i,o){return i==="textarea"||i==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var Lc=typeof setTimeout=="function"?setTimeout:void 0,dx=typeof clearTimeout=="function"?clearTimeout:void 0,nf=typeof Promise=="function"?Promise:void 0,ux=typeof queueMicrotask=="function"?queueMicrotask:typeof nf<"u"?function(i){return nf.resolve(null).then(i).catch(hx)}:Lc;function hx(i){setTimeout(function(){throw i})}function Pc(i,o){var l=o,u=0;do{var p=l.nextSibling;if(i.removeChild(l),p&&p.nodeType===8)if(l=p.data,l==="/$"){if(u===0){i.removeChild(p),Oi(o);return}u--}else l!=="$"&&l!=="$?"&&l!=="$!"||u++;l=p}while(l);Oi(o)}function _n(i){for(;i!=null;i=i.nextSibling){var o=i.nodeType;if(o===1||o===3)break;if(o===8){if(o=i.data,o==="$"||o==="$!"||o==="$?")break;if(o==="/$")return null}}return i}function sf(i){i=i.previousSibling;for(var o=0;i;){if(i.nodeType===8){var l=i.data;if(l==="$"||l==="$!"||l==="$?"){if(o===0)return i;o--}else l==="/$"&&o++}i=i.previousSibling}return null}var Fs=Math.random().toString(36).slice(2),an="__reactFiber$"+Fs,Ki="__reactProps$"+Fs,vn="__reactContainer$"+Fs,Dc="__reactEvents$"+Fs,fx="__reactListeners$"+Fs,mx="__reactHandles$"+Fs;function as(i){var o=i[an];if(o)return o;for(var l=i.parentNode;l;){if(o=l[vn]||l[an]){if(l=o.alternate,o.child!==null||l!==null&&l.child!==null)for(i=sf(i);i!==null;){if(l=i[an])return l;i=sf(i)}return o}i=l,l=i.parentNode}return null}function Gi(i){return i=i[an]||i[vn],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function zs(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function eo(i){return i[Ki]||null}var _c=[],Us=-1;function Bn(i){return{current:i}}function De(i){0>Us||(i.current=_c[Us],_c[Us]=null,Us--)}function Oe(i,o){Us++,_c[Us]=i.current,i.current=o}var Fn={},lt=Bn(Fn),wt=Bn(!1),cs=Fn;function Ws(i,o){var l=i.type.contextTypes;if(!l)return Fn;var u=i.stateNode;if(u&&u.__reactInternalMemoizedUnmaskedChildContext===o)return u.__reactInternalMemoizedMaskedChildContext;var p={},v;for(v in l)p[v]=o[v];return u&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=o,i.__reactInternalMemoizedMaskedChildContext=p),p}function xt(i){return i=i.childContextTypes,i!=null}function to(){De(wt),De(lt)}function rf(i,o,l){if(lt.current!==Fn)throw Error(n(168));Oe(lt,o),Oe(wt,l)}function of(i,o,l){var u=i.stateNode;if(o=o.childContextTypes,typeof u.getChildContext!="function")return l;u=u.getChildContext();for(var p in u)if(!(p in o))throw Error(n(108,ge(i)||"Unknown",p));return U({},l,u)}function no(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||Fn,cs=lt.current,Oe(lt,i),Oe(wt,wt.current),!0}function af(i,o,l){var u=i.stateNode;if(!u)throw Error(n(169));l?(i=of(i,o,cs),u.__reactInternalMemoizedMergedChildContext=i,De(wt),De(lt),Oe(lt,i)):De(wt),Oe(wt,l)}var kn=null,so=!1,Bc=!1;function cf(i){kn===null?kn=[i]:kn.push(i)}function px(i){so=!0,cf(i)}function zn(){if(!Bc&&kn!==null){Bc=!0;var i=0,o=Re;try{var l=kn;for(Re=1;i<l.length;i++){var u=l[i];do u=u(!0);while(u!==null)}kn=null,so=!1}catch(p){throw kn!==null&&(kn=kn.slice(i+1)),lh(ac,zn),p}finally{Re=o,Bc=!1}}return null}var Hs=[],Ks=0,io=null,ro=0,Lt=[],Pt=0,ls=null,yn=1,wn="";function ds(i,o){Hs[Ks++]=ro,Hs[Ks++]=io,io=i,ro=o}function lf(i,o,l){Lt[Pt++]=yn,Lt[Pt++]=wn,Lt[Pt++]=ls,ls=i;var u=yn;i=wn;var p=32-qt(u)-1;u&=~(1<<p),l+=1;var v=32-qt(o)+p;if(30<v){var j=p-p%5;v=(u&(1<<j)-1).toString(32),u>>=j,p-=j,yn=1<<32-qt(o)+p|l<<p|u,wn=v+i}else yn=1<<v|l<<p|u,wn=i}function Fc(i){i.return!==null&&(ds(i,1),lf(i,1,0))}function zc(i){for(;i===io;)io=Hs[--Ks],Hs[Ks]=null,ro=Hs[--Ks],Hs[Ks]=null;for(;i===ls;)ls=Lt[--Pt],Lt[Pt]=null,wn=Lt[--Pt],Lt[Pt]=null,yn=Lt[--Pt],Lt[Pt]=null}var Rt=null,Mt=null,Be=!1,Yt=null;function df(i,o){var l=Ft(5,null,null,0);l.elementType="DELETED",l.stateNode=o,l.return=i,o=i.deletions,o===null?(i.deletions=[l],i.flags|=16):o.push(l)}function uf(i,o){switch(i.tag){case 5:var l=i.type;return o=o.nodeType!==1||l.toLowerCase()!==o.nodeName.toLowerCase()?null:o,o!==null?(i.stateNode=o,Rt=i,Mt=_n(o.firstChild),!0):!1;case 6:return o=i.pendingProps===""||o.nodeType!==3?null:o,o!==null?(i.stateNode=o,Rt=i,Mt=null,!0):!1;case 13:return o=o.nodeType!==8?null:o,o!==null?(l=ls!==null?{id:yn,overflow:wn}:null,i.memoizedState={dehydrated:o,treeContext:l,retryLane:1073741824},l=Ft(18,null,null,0),l.stateNode=o,l.return=i,i.child=l,Rt=i,Mt=null,!0):!1;default:return!1}}function Uc(i){return(i.mode&1)!==0&&(i.flags&128)===0}function Wc(i){if(Be){var o=Mt;if(o){var l=o;if(!uf(i,o)){if(Uc(i))throw Error(n(418));o=_n(l.nextSibling);var u=Rt;o&&uf(i,o)?df(u,l):(i.flags=i.flags&-4097|2,Be=!1,Rt=i)}}else{if(Uc(i))throw Error(n(418));i.flags=i.flags&-4097|2,Be=!1,Rt=i}}}function hf(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;Rt=i}function oo(i){if(i!==Rt)return!1;if(!Be)return hf(i),Be=!0,!1;var o;if((o=i.tag!==3)&&!(o=i.tag!==5)&&(o=i.type,o=o!=="head"&&o!=="body"&&!Oc(i.type,i.memoizedProps)),o&&(o=Mt)){if(Uc(i))throw ff(),Error(n(418));for(;o;)df(i,o),o=_n(o.nextSibling)}if(hf(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,o=0;i;){if(i.nodeType===8){var l=i.data;if(l==="/$"){if(o===0){Mt=_n(i.nextSibling);break e}o--}else l!=="$"&&l!=="$!"&&l!=="$?"||o++}i=i.nextSibling}Mt=null}}else Mt=Rt?_n(i.stateNode.nextSibling):null;return!0}function ff(){for(var i=Mt;i;)i=_n(i.nextSibling)}function Gs(){Mt=Rt=null,Be=!1}function Hc(i){Yt===null?Yt=[i]:Yt.push(i)}var gx=M.ReactCurrentBatchConfig;function Vi(i,o,l){if(i=l.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(n(309));var u=l.stateNode}if(!u)throw Error(n(147,i));var p=u,v=""+i;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 i!="string")throw Error(n(284));if(!l._owner)throw Error(n(290,i))}return i}function ao(i,o){throw i=Object.prototype.toString.call(o),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":i))}function mf(i){var o=i._init;return o(i._payload)}function pf(i){function o(R,A){if(i){var O=R.deletions;O===null?(R.deletions=[A],R.flags|=16):O.push(A)}}function l(R,A){if(!i)return null;for(;A!==null;)o(R,A),A=A.sibling;return null}function u(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,i?(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 i&&R.alternate===null&&(R.flags|=2),R}function $(R,A,O,V){return A===null||A.tag!==6?(A=Ll(O,R.mode,V),A.return=R,A):(A=p(A,O),A.return=R,A)}function T(R,A,O,V){var ie=O.type;return ie===Y?K(R,A,O.props.children,V,O.key):A!==null&&(A.elementType===ie||typeof ie=="object"&&ie!==null&&ie.$$typeof===me&&mf(ie)===A.type)?(V=p(A,O.props),V.ref=Vi(R,A,O),V.return=R,V):(V=Mo(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=Pl(O,R.mode,V),A.return=R,A):(A=p(A,O.children||[]),A.return=R,A)}function K(R,A,O,V,ie){return A===null||A.tag!==7?(A=ks(O,R.mode,V,ie),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=Ll(""+A,R.mode,O),A.return=R,A;if(typeof A=="object"&&A!==null){switch(A.$$typeof){case W:return O=Mo(A.type,A.key,A.props,null,R.mode,O),O.ref=Vi(R,null,A),O.return=R,O;case _:return A=Pl(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=ks(A,R.mode,O,null),A.return=R,A;ao(R,A)}return null}function H(R,A,O,V){var ie=A!==null?A.key:null;if(typeof O=="string"&&O!==""||typeof O=="number")return ie!==null?null:$(R,A,""+O,V);if(typeof O=="object"&&O!==null){switch(O.$$typeof){case W:return O.key===ie?T(R,A,O,V):null;case _:return O.key===ie?L(R,A,O,V):null;case me:return ie=O._init,H(R,A,ie(O._payload),V)}if(ji(O)||Q(O))return ie!==null?null:K(R,A,O,V,null);ao(R,O)}return null}function X(R,A,O,V,ie){if(typeof V=="string"&&V!==""||typeof V=="number")return R=R.get(O)||null,$(A,R,""+V,ie);if(typeof V=="object"&&V!==null){switch(V.$$typeof){case W:return R=R.get(V.key===null?O:V.key)||null,T(A,R,V,ie);case _:return R=R.get(V.key===null?O:V.key)||null,L(A,R,V,ie);case me:var le=V._init;return X(R,A,O,le(V._payload),ie)}if(ji(V)||Q(V))return R=R.get(O)||null,K(A,R,V,ie,null);ao(A,V)}return null}function te(R,A,O,V){for(var ie=null,le=null,de=A,ue=A=0,st=null;de!==null&&ue<O.length;ue++){de.index>ue?(st=de,de=null):st=de.sibling;var Te=H(R,de,O[ue],V);if(Te===null){de===null&&(de=st);break}i&&de&&Te.alternate===null&&o(R,de),A=v(Te,A,ue),le===null?ie=Te:le.sibling=Te,le=Te,de=st}if(ue===O.length)return l(R,de),Be&&ds(R,ue),ie;if(de===null){for(;ue<O.length;ue++)de=G(R,O[ue],V),de!==null&&(A=v(de,A,ue),le===null?ie=de:le.sibling=de,le=de);return Be&&ds(R,ue),ie}for(de=u(R,de);ue<O.length;ue++)st=X(de,R,ue,O[ue],V),st!==null&&(i&&st.alternate!==null&&de.delete(st.key===null?ue:st.key),A=v(st,A,ue),le===null?ie=st:le.sibling=st,le=st);return i&&de.forEach(function(Yn){return o(R,Yn)}),Be&&ds(R,ue),ie}function ne(R,A,O,V){var ie=Q(O);if(typeof ie!="function")throw Error(n(150));if(O=ie.call(O),O==null)throw Error(n(151));for(var le=ie=null,de=A,ue=A=0,st=null,Te=O.next();de!==null&&!Te.done;ue++,Te=O.next()){de.index>ue?(st=de,de=null):st=de.sibling;var Yn=H(R,de,Te.value,V);if(Yn===null){de===null&&(de=st);break}i&&de&&Yn.alternate===null&&o(R,de),A=v(Yn,A,ue),le===null?ie=Yn:le.sibling=Yn,le=Yn,de=st}if(Te.done)return l(R,de),Be&&ds(R,ue),ie;if(de===null){for(;!Te.done;ue++,Te=O.next())Te=G(R,Te.value,V),Te!==null&&(A=v(Te,A,ue),le===null?ie=Te:le.sibling=Te,le=Te);return Be&&ds(R,ue),ie}for(de=u(R,de);!Te.done;ue++,Te=O.next())Te=X(de,R,ue,Te.value,V),Te!==null&&(i&&Te.alternate!==null&&de.delete(Te.key===null?ue:Te.key),A=v(Te,A,ue),le===null?ie=Te:le.sibling=Te,le=Te);return i&&de.forEach(function(Qx){return o(R,Qx)}),Be&&ds(R,ue),ie}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 W:e:{for(var ie=O.key,le=A;le!==null;){if(le.key===ie){if(ie=O.type,ie===Y){if(le.tag===7){l(R,le.sibling),A=p(le,O.props.children),A.return=R,R=A;break e}}else if(le.elementType===ie||typeof ie=="object"&&ie!==null&&ie.$$typeof===me&&mf(ie)===le.type){l(R,le.sibling),A=p(le,O.props),A.ref=Vi(R,le,O),A.return=R,R=A;break e}l(R,le);break}else o(R,le);le=le.sibling}O.type===Y?(A=ks(O.props.children,R.mode,V,O.key),A.return=R,R=A):(V=Mo(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(le=O.key;A!==null;){if(A.key===le)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=Pl(O,R.mode,V),A.return=R,R=A}return j(R);case me:return le=O._init,Qe(R,A,le(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=Ll(O,R.mode,V),A.return=R,R=A),j(R)):l(R,A)}return Qe}var Vs=pf(!0),gf=pf(!1),co=Bn(null),lo=null,qs=null,Kc=null;function Gc(){Kc=qs=lo=null}function Vc(i){var o=co.current;De(co),i._currentValue=o}function qc(i,o,l){for(;i!==null;){var u=i.alternate;if((i.childLanes&o)!==o?(i.childLanes|=o,u!==null&&(u.childLanes|=o)):u!==null&&(u.childLanes&o)!==o&&(u.childLanes|=o),i===l)break;i=i.return}}function Qs(i,o){lo=i,Kc=qs=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&o)!==0&&(jt=!0),i.firstContext=null)}function Dt(i){var o=i._currentValue;if(Kc!==i)if(i={context:i,memoizedValue:o,next:null},qs===null){if(lo===null)throw Error(n(308));qs=i,lo.dependencies={lanes:0,firstContext:i}}else qs=qs.next=i;return o}var us=null;function Qc(i){us===null?us=[i]:us.push(i)}function vf(i,o,l,u){var p=o.interleaved;return p===null?(l.next=l,Qc(o)):(l.next=p.next,p.next=l),o.interleaved=l,xn(i,u)}function xn(i,o){i.lanes|=o;var l=i.alternate;for(l!==null&&(l.lanes|=o),l=i,i=i.return;i!==null;)i.childLanes|=o,l=i.alternate,l!==null&&(l.childLanes|=o),l=i,i=i.return;return l.tag===3?l.stateNode:null}var Un=!1;function Yc(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function kf(i,o){i=i.updateQueue,o.updateQueue===i&&(o.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function jn(i,o){return{eventTime:i,lane:o,tag:0,payload:null,callback:null,next:null}}function Wn(i,o,l){var u=i.updateQueue;if(u===null)return null;if(u=u.shared,(Ce&2)!==0){var p=u.pending;return p===null?o.next=o:(o.next=p.next,p.next=o),u.pending=o,xn(i,l)}return p=u.interleaved,p===null?(o.next=o,Qc(u)):(o.next=p.next,p.next=o),u.interleaved=o,xn(i,l)}function uo(i,o,l){if(o=o.updateQueue,o!==null&&(o=o.shared,(l&4194240)!==0)){var u=o.lanes;u&=i.pendingLanes,l|=u,o.lanes=l,dc(i,l)}}function yf(i,o){var l=i.updateQueue,u=i.alternate;if(u!==null&&(u=u.updateQueue,l===u)){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:u.baseState,firstBaseUpdate:p,lastBaseUpdate:v,shared:u.shared,effects:u.effects},i.updateQueue=l;return}i=l.lastBaseUpdate,i===null?l.firstBaseUpdate=o:i.next=o,l.lastBaseUpdate=o}function ho(i,o,l,u){var p=i.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=i.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 H=$.lane,X=$.eventTime;if((u&H)===H){K!==null&&(K=K.next={eventTime:X,lane:0,tag:$.tag,payload:$.payload,callback:$.callback,next:null});e:{var te=i,ne=$;switch(H=o,X=l,ne.tag){case 1:if(te=ne.payload,typeof te=="function"){G=te.call(X,G,H);break e}G=te;break e;case 3:te.flags=te.flags&-65537|128;case 0:if(te=ne.payload,H=typeof te=="function"?te.call(X,G,H):te,H==null)break e;G=U({},G,H);break e;case 2:Un=!0}}$.callback!==null&&$.lane!==0&&(i.flags|=64,H=p.effects,H===null?p.effects=[$]:H.push($))}else X={eventTime:X,lane:H,tag:$.tag,payload:$.payload,callback:$.callback,next:null},K===null?(L=K=X,T=G):K=K.next=X,j|=H;if($=$.next,$===null){if($=p.shared.pending,$===null)break;H=$,$=H.next,H.next=null,p.lastBaseUpdate=H,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);ms|=j,i.lanes=j,i.memoizedState=G}}function wf(i,o,l){if(i=o.effects,o.effects=null,i!==null)for(o=0;o<i.length;o++){var u=i[o],p=u.callback;if(p!==null){if(u.callback=null,u=l,typeof p!="function")throw Error(n(191,p));p.call(u)}}}var qi={},cn=Bn(qi),Qi=Bn(qi),Yi=Bn(qi);function hs(i){if(i===qi)throw Error(n(174));return i}function Jc(i,o){switch(Oe(Yi,o),Oe(Qi,i),Oe(cn,qi),i=o.nodeType,i){case 9:case 11:o=(o=o.documentElement)?o.namespaceURI:Xa(null,"");break;default:i=i===8?o.parentNode:o,o=i.namespaceURI||null,i=i.tagName,o=Xa(o,i)}De(cn),Oe(cn,o)}function Ys(){De(cn),De(Qi),De(Yi)}function xf(i){hs(Yi.current);var o=hs(cn.current),l=Xa(o,i.type);o!==l&&(Oe(Qi,i),Oe(cn,l))}function Xc(i){Qi.current===i&&(De(cn),De(Qi))}var ze=Bn(0);function fo(i){for(var o=i;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===i)break;for(;o.sibling===null;){if(o.return===null||o.return===i)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var Zc=[];function el(){for(var i=0;i<Zc.length;i++)Zc[i]._workInProgressVersionPrimary=null;Zc.length=0}var mo=M.ReactCurrentDispatcher,tl=M.ReactCurrentBatchConfig,fs=0,Ue=null,Ze=null,tt=null,po=!1,Ji=!1,Xi=0,vx=0;function dt(){throw Error(n(321))}function nl(i,o){if(o===null)return!1;for(var l=0;l<o.length&&l<i.length;l++)if(!Qt(i[l],o[l]))return!1;return!0}function sl(i,o,l,u,p,v){if(fs=v,Ue=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,mo.current=i===null||i.memoizedState===null?xx:jx,i=l(u,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=bx,i=l(u,p)}while(Ji)}if(mo.current=ko,o=Ze!==null&&Ze.next!==null,fs=0,tt=Ze=Ue=null,po=!1,o)throw Error(n(300));return i}function il(){var i=Xi!==0;return Xi=0,i}function ln(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return tt===null?Ue.memoizedState=tt=i:tt=tt.next=i,tt}function _t(){if(Ze===null){var i=Ue.alternate;i=i!==null?i.memoizedState:null}else i=Ze.next;var o=tt===null?Ue.memoizedState:tt.next;if(o!==null)tt=o,Ze=i;else{if(i===null)throw Error(n(310));Ze=i,i={memoizedState:Ze.memoizedState,baseState:Ze.baseState,baseQueue:Ze.baseQueue,queue:Ze.queue,next:null},tt===null?Ue.memoizedState=tt=i:tt=tt.next=i}return tt}function Zi(i,o){return typeof o=="function"?o(i):o}function rl(i){var o=_t(),l=o.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=i;var u=Ze,p=u.baseQueue,v=l.pending;if(v!==null){if(p!==null){var j=p.next;p.next=v.next,v.next=j}u.baseQueue=p=v,l.pending=null}if(p!==null){v=p.next,u=u.baseState;var $=j=null,T=null,L=v;do{var K=L.lane;if((fs&K)===K)T!==null&&(T=T.next={lane:0,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null}),u=L.hasEagerState?L.eagerState:i(u,L.action);else{var G={lane:K,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null};T===null?($=T=G,j=u):T=T.next=G,Ue.lanes|=K,ms|=K}L=L.next}while(L!==null&&L!==v);T===null?j=u:T.next=$,Qt(u,o.memoizedState)||(jt=!0),o.memoizedState=u,o.baseState=j,o.baseQueue=T,l.lastRenderedState=u}if(i=l.interleaved,i!==null){p=i;do v=p.lane,Ue.lanes|=v,ms|=v,p=p.next;while(p!==i)}else p===null&&(l.lanes=0);return[o.memoizedState,l.dispatch]}function ol(i){var o=_t(),l=o.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=i;var u=l.dispatch,p=l.pending,v=o.memoizedState;if(p!==null){l.pending=null;var j=p=p.next;do v=i(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,u]}function jf(){}function bf(i,o){var l=Ue,u=_t(),p=o(),v=!Qt(u.memoizedState,p);if(v&&(u.memoizedState=p,jt=!0),u=u.queue,al($f.bind(null,l,u,i),[i]),u.getSnapshot!==o||v||tt!==null&&tt.memoizedState.tag&1){if(l.flags|=2048,er(9,Nf.bind(null,l,u,p,o),void 0,null),nt===null)throw Error(n(349));(fs&30)!==0||Sf(l,o,p)}return p}function Sf(i,o,l){i.flags|=16384,i={getSnapshot:o,value:l},o=Ue.updateQueue,o===null?(o={lastEffect:null,stores:null},Ue.updateQueue=o,o.stores=[i]):(l=o.stores,l===null?o.stores=[i]:l.push(i))}function Nf(i,o,l,u){o.value=l,o.getSnapshot=u,Cf(o)&&Tf(i)}function $f(i,o,l){return l(function(){Cf(o)&&Tf(i)})}function Cf(i){var o=i.getSnapshot;i=i.value;try{var l=o();return!Qt(i,l)}catch{return!0}}function Tf(i){var o=xn(i,1);o!==null&&en(o,i,1,-1)}function Ef(i){var o=ln();return typeof i=="function"&&(i=i()),o.memoizedState=o.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Zi,lastRenderedState:i},o.queue=i,i=i.dispatch=wx.bind(null,Ue,i),[o.memoizedState,i]}function er(i,o,l,u){return i={tag:i,create:o,destroy:l,deps:u,next:null},o=Ue.updateQueue,o===null?(o={lastEffect:null,stores:null},Ue.updateQueue=o,o.lastEffect=i.next=i):(l=o.lastEffect,l===null?o.lastEffect=i.next=i:(u=l.next,l.next=i,i.next=u,o.lastEffect=i)),i}function Af(){return _t().memoizedState}function go(i,o,l,u){var p=ln();Ue.flags|=i,p.memoizedState=er(1|o,l,void 0,u===void 0?null:u)}function vo(i,o,l,u){var p=_t();u=u===void 0?null:u;var v=void 0;if(Ze!==null){var j=Ze.memoizedState;if(v=j.destroy,u!==null&&nl(u,j.deps)){p.memoizedState=er(o,l,v,u);return}}Ue.flags|=i,p.memoizedState=er(1|o,l,v,u)}function Rf(i,o){return go(8390656,8,i,o)}function al(i,o){return vo(2048,8,i,o)}function Mf(i,o){return vo(4,2,i,o)}function If(i,o){return vo(4,4,i,o)}function Of(i,o){if(typeof o=="function")return i=i(),o(i),function(){o(null)};if(o!=null)return i=i(),o.current=i,function(){o.current=null}}function Lf(i,o,l){return l=l!=null?l.concat([i]):null,vo(4,4,Of.bind(null,o,i),l)}function cl(){}function Pf(i,o){var l=_t();o=o===void 0?null:o;var u=l.memoizedState;return u!==null&&o!==null&&nl(o,u[1])?u[0]:(l.memoizedState=[i,o],i)}function Df(i,o){var l=_t();o=o===void 0?null:o;var u=l.memoizedState;return u!==null&&o!==null&&nl(o,u[1])?u[0]:(i=i(),l.memoizedState=[i,o],i)}function _f(i,o,l){return(fs&21)===0?(i.baseState&&(i.baseState=!1,jt=!0),i.memoizedState=l):(Qt(l,o)||(l=fh(),Ue.lanes|=l,ms|=l,i.baseState=!0),o)}function kx(i,o){var l=Re;Re=l!==0&&4>l?l:4,i(!0);var u=tl.transition;tl.transition={};try{i(!1),o()}finally{Re=l,tl.transition=u}}function Bf(){return _t().memoizedState}function yx(i,o,l){var u=Vn(i);if(l={lane:u,action:l,hasEagerState:!1,eagerState:null,next:null},Ff(i))zf(o,l);else if(l=vf(i,o,l,u),l!==null){var p=kt();en(l,i,u,p),Uf(l,o,u)}}function wx(i,o,l){var u=Vn(i),p={lane:u,action:l,hasEagerState:!1,eagerState:null,next:null};if(Ff(i))zf(o,p);else{var v=i.alternate;if(i.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,Qc(o)):(p.next=T.next,T.next=p),o.interleaved=p;return}}catch{}finally{}l=vf(i,o,p,u),l!==null&&(p=kt(),en(l,i,u,p),Uf(l,o,u))}}function Ff(i){var o=i.alternate;return i===Ue||o!==null&&o===Ue}function zf(i,o){Ji=po=!0;var l=i.pending;l===null?o.next=o:(o.next=l.next,l.next=o),i.pending=o}function Uf(i,o,l){if((l&4194240)!==0){var u=o.lanes;u&=i.pendingLanes,l|=u,o.lanes=l,dc(i,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},xx={readContext:Dt,useCallback:function(i,o){return ln().memoizedState=[i,o===void 0?null:o],i},useContext:Dt,useEffect:Rf,useImperativeHandle:function(i,o,l){return l=l!=null?l.concat([i]):null,go(4194308,4,Of.bind(null,o,i),l)},useLayoutEffect:function(i,o){return go(4194308,4,i,o)},useInsertionEffect:function(i,o){return go(4,2,i,o)},useMemo:function(i,o){var l=ln();return o=o===void 0?null:o,i=i(),l.memoizedState=[i,o],i},useReducer:function(i,o,l){var u=ln();return o=l!==void 0?l(o):o,u.memoizedState=u.baseState=o,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:o},u.queue=i,i=i.dispatch=yx.bind(null,Ue,i),[u.memoizedState,i]},useRef:function(i){var o=ln();return i={current:i},o.memoizedState=i},useState:Ef,useDebugValue:cl,useDeferredValue:function(i){return ln().memoizedState=i},useTransition:function(){var i=Ef(!1),o=i[0];return i=kx.bind(null,i[1]),ln().memoizedState=i,[o,i]},useMutableSource:function(){},useSyncExternalStore:function(i,o,l){var u=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));(fs&30)!==0||Sf(u,o,l)}p.memoizedState=l;var v={value:l,getSnapshot:o};return p.queue=v,Rf($f.bind(null,u,v,i),[i]),u.flags|=2048,er(9,Nf.bind(null,u,v,l,o),void 0,null),l},useId:function(){var i=ln(),o=nt.identifierPrefix;if(Be){var l=wn,u=yn;l=(u&~(1<<32-qt(u)-1)).toString(32)+l,o=":"+o+"R"+l,l=Xi++,0<l&&(o+="H"+l.toString(32)),o+=":"}else l=vx++,o=":"+o+"r"+l.toString(32)+":";return i.memoizedState=o},unstable_isNewReconciler:!1},jx={readContext:Dt,useCallback:Pf,useContext:Dt,useEffect:al,useImperativeHandle:Lf,useInsertionEffect:Mf,useLayoutEffect:If,useMemo:Df,useReducer:rl,useRef:Af,useState:function(){return rl(Zi)},useDebugValue:cl,useDeferredValue:function(i){var o=_t();return _f(o,Ze.memoizedState,i)},useTransition:function(){var i=rl(Zi)[0],o=_t().memoizedState;return[i,o]},useMutableSource:jf,useSyncExternalStore:bf,useId:Bf,unstable_isNewReconciler:!1},bx={readContext:Dt,useCallback:Pf,useContext:Dt,useEffect:al,useImperativeHandle:Lf,useInsertionEffect:Mf,useLayoutEffect:If,useMemo:Df,useReducer:ol,useRef:Af,useState:function(){return ol(Zi)},useDebugValue:cl,useDeferredValue:function(i){var o=_t();return Ze===null?o.memoizedState=i:_f(o,Ze.memoizedState,i)},useTransition:function(){var i=ol(Zi)[0],o=_t().memoizedState;return[i,o]},useMutableSource:jf,useSyncExternalStore:bf,useId:Bf,unstable_isNewReconciler:!1};function Jt(i,o){if(i&&i.defaultProps){o=U({},o),i=i.defaultProps;for(var l in i)o[l]===void 0&&(o[l]=i[l]);return o}return o}function ll(i,o,l,u){o=i.memoizedState,l=l(u,o),l=l==null?o:U({},o,l),i.memoizedState=l,i.lanes===0&&(i.updateQueue.baseState=l)}var yo={isMounted:function(i){return(i=i._reactInternals)?os(i)===i:!1},enqueueSetState:function(i,o,l){i=i._reactInternals;var u=kt(),p=Vn(i),v=jn(u,p);v.payload=o,l!=null&&(v.callback=l),o=Wn(i,v,p),o!==null&&(en(o,i,p,u),uo(o,i,p))},enqueueReplaceState:function(i,o,l){i=i._reactInternals;var u=kt(),p=Vn(i),v=jn(u,p);v.tag=1,v.payload=o,l!=null&&(v.callback=l),o=Wn(i,v,p),o!==null&&(en(o,i,p,u),uo(o,i,p))},enqueueForceUpdate:function(i,o){i=i._reactInternals;var l=kt(),u=Vn(i),p=jn(l,u);p.tag=2,o!=null&&(p.callback=o),o=Wn(i,p,u),o!==null&&(en(o,i,u,l),uo(o,i,u))}};function Wf(i,o,l,u,p,v,j){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(u,v,j):o.prototype&&o.prototype.isPureReactComponent?!Fi(l,u)||!Fi(p,v):!0}function Hf(i,o,l){var u=!1,p=Fn,v=o.contextType;return typeof v=="object"&&v!==null?v=Dt(v):(p=xt(o)?cs:lt.current,u=o.contextTypes,v=(u=u!=null)?Ws(i,p):Fn),o=new o(l,v),i.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=yo,i.stateNode=o,o._reactInternals=i,u&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=p,i.__reactInternalMemoizedMaskedChildContext=v),o}function Kf(i,o,l,u){i=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(l,u),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(l,u),o.state!==i&&yo.enqueueReplaceState(o,o.state,null)}function dl(i,o,l,u){var p=i.stateNode;p.props=l,p.state=i.memoizedState,p.refs={},Yc(i);var v=o.contextType;typeof v=="object"&&v!==null?p.context=Dt(v):(v=xt(o)?cs:lt.current,p.context=Ws(i,v)),p.state=i.memoizedState,v=o.getDerivedStateFromProps,typeof v=="function"&&(ll(i,o,v,l),p.state=i.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(i,l,p,u),p.state=i.memoizedState),typeof p.componentDidMount=="function"&&(i.flags|=4194308)}function Js(i,o){try{var l="",u=o;do l+=we(u),u=u.return;while(u);var p=l}catch(v){p=`
39
+ Error generating stack: `+v.message+`
40
+ `+v.stack}return{value:i,source:o,stack:p,digest:null}}function ul(i,o,l){return{value:i,source:null,stack:l??null,digest:o??null}}function hl(i,o){try{console.error(o.value)}catch(l){setTimeout(function(){throw l})}}var Sx=typeof WeakMap=="function"?WeakMap:Map;function Gf(i,o,l){l=jn(-1,l),l.tag=3,l.payload={element:null};var u=o.value;return l.callback=function(){$o||($o=!0,Cl=u),hl(i,o)},l}function Vf(i,o,l){l=jn(-1,l),l.tag=3;var u=i.type.getDerivedStateFromError;if(typeof u=="function"){var p=o.value;l.payload=function(){return u(p)},l.callback=function(){hl(i,o)}}var v=i.stateNode;return v!==null&&typeof v.componentDidCatch=="function"&&(l.callback=function(){hl(i,o),typeof u!="function"&&(Kn===null?Kn=new Set([this]):Kn.add(this));var j=o.stack;this.componentDidCatch(o.value,{componentStack:j!==null?j:""})}),l}function qf(i,o,l){var u=i.pingCache;if(u===null){u=i.pingCache=new Sx;var p=new Set;u.set(o,p)}else p=u.get(o),p===void 0&&(p=new Set,u.set(o,p));p.has(l)||(p.add(l),i=_x.bind(null,i,o,l),o.then(i,i))}function Qf(i){do{var o;if((o=i.tag===13)&&(o=i.memoizedState,o=o!==null?o.dehydrated!==null:!0),o)return i;i=i.return}while(i!==null);return null}function Yf(i,o,l,u,p){return(i.mode&1)===0?(i===o?i.flags|=65536:(i.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),i):(i.flags|=65536,i.lanes=p,i)}var Nx=M.ReactCurrentOwner,jt=!1;function vt(i,o,l,u){o.child=i===null?gf(o,null,l,u):Vs(o,i.child,l,u)}function Jf(i,o,l,u,p){l=l.render;var v=o.ref;return Qs(o,p),u=sl(i,o,l,u,v,p),l=il(),i!==null&&!jt?(o.updateQueue=i.updateQueue,o.flags&=-2053,i.lanes&=~p,bn(i,o,p)):(Be&&l&&Fc(o),o.flags|=1,vt(i,o,u,p),o.child)}function Xf(i,o,l,u,p){if(i===null){var v=l.type;return typeof v=="function"&&!Ol(v)&&v.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(o.tag=15,o.type=v,Zf(i,o,v,u,p)):(i=Mo(l.type,null,u,o,o.mode,p),i.ref=o.ref,i.return=o,o.child=i)}if(v=i.child,(i.lanes&p)===0){var j=v.memoizedProps;if(l=l.compare,l=l!==null?l:Fi,l(j,u)&&i.ref===o.ref)return bn(i,o,p)}return o.flags|=1,i=Qn(v,u),i.ref=o.ref,i.return=o,o.child=i}function Zf(i,o,l,u,p){if(i!==null){var v=i.memoizedProps;if(Fi(v,u)&&i.ref===o.ref)if(jt=!1,o.pendingProps=u=v,(i.lanes&p)!==0)(i.flags&131072)!==0&&(jt=!0);else return o.lanes=i.lanes,bn(i,o,p)}return fl(i,o,l,u,p)}function em(i,o,l){var u=o.pendingProps,p=u.children,v=i!==null?i.memoizedState:null;if(u.mode==="hidden")if((o.mode&1)===0)o.memoizedState={baseLanes:0,cachePool:null,transitions:null},Oe(Zs,It),It|=l;else{if((l&1073741824)===0)return i=v!==null?v.baseLanes|l:l,o.lanes=o.childLanes=1073741824,o.memoizedState={baseLanes:i,cachePool:null,transitions:null},o.updateQueue=null,Oe(Zs,It),It|=i,null;o.memoizedState={baseLanes:0,cachePool:null,transitions:null},u=v!==null?v.baseLanes:l,Oe(Zs,It),It|=u}else v!==null?(u=v.baseLanes|l,o.memoizedState=null):u=l,Oe(Zs,It),It|=u;return vt(i,o,p,l),o.child}function tm(i,o){var l=o.ref;(i===null&&l!==null||i!==null&&i.ref!==l)&&(o.flags|=512,o.flags|=2097152)}function fl(i,o,l,u,p){var v=xt(l)?cs:lt.current;return v=Ws(o,v),Qs(o,p),l=sl(i,o,l,u,v,p),u=il(),i!==null&&!jt?(o.updateQueue=i.updateQueue,o.flags&=-2053,i.lanes&=~p,bn(i,o,p)):(Be&&u&&Fc(o),o.flags|=1,vt(i,o,l,p),o.child)}function nm(i,o,l,u,p){if(xt(l)){var v=!0;no(o)}else v=!1;if(Qs(o,p),o.stateNode===null)xo(i,o),Hf(o,l,u),dl(o,l,u,p),u=!0;else if(i===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)?cs: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"||($!==u||T!==L)&&Kf(o,j,u,L),Un=!1;var H=o.memoizedState;j.state=H,ho(o,u,j,p),T=o.memoizedState,$!==u||H!==T||wt.current||Un?(typeof K=="function"&&(ll(o,l,K,u),T=o.memoizedState),($=Un||Wf(o,l,$,u,H,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=u,o.memoizedState=T),j.props=u,j.state=T,j.context=L,u=$):(typeof j.componentDidMount=="function"&&(o.flags|=4194308),u=!1)}else{j=o.stateNode,kf(i,o),$=o.memoizedProps,L=o.type===o.elementType?$:Jt(o.type,$),j.props=L,G=o.pendingProps,H=j.context,T=l.contextType,typeof T=="object"&&T!==null?T=Dt(T):(T=xt(l)?cs: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||H!==T)&&Kf(o,j,u,T),Un=!1,H=o.memoizedState,j.state=H,ho(o,u,j,p);var te=o.memoizedState;$!==G||H!==te||wt.current||Un?(typeof X=="function"&&(ll(o,l,X,u),te=o.memoizedState),(L=Un||Wf(o,l,L,u,H,te,T)||!1)?(K||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(u,te,T),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(u,te,T)),typeof j.componentDidUpdate=="function"&&(o.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof j.componentDidUpdate!="function"||$===i.memoizedProps&&H===i.memoizedState||(o.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||$===i.memoizedProps&&H===i.memoizedState||(o.flags|=1024),o.memoizedProps=u,o.memoizedState=te),j.props=u,j.state=te,j.context=T,u=L):(typeof j.componentDidUpdate!="function"||$===i.memoizedProps&&H===i.memoizedState||(o.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||$===i.memoizedProps&&H===i.memoizedState||(o.flags|=1024),u=!1)}return ml(i,o,l,u,v,p)}function ml(i,o,l,u,p,v){tm(i,o);var j=(o.flags&128)!==0;if(!u&&!j)return p&&af(o,l,!1),bn(i,o,v);u=o.stateNode,Nx.current=o;var $=j&&typeof l.getDerivedStateFromError!="function"?null:u.render();return o.flags|=1,i!==null&&j?(o.child=Vs(o,i.child,null,v),o.child=Vs(o,null,$,v)):vt(i,o,$,v),o.memoizedState=u.state,p&&af(o,l,!0),o.child}function sm(i){var o=i.stateNode;o.pendingContext?rf(i,o.pendingContext,o.pendingContext!==o.context):o.context&&rf(i,o.context,!1),Jc(i,o.containerInfo)}function im(i,o,l,u,p){return Gs(),Hc(p),o.flags|=256,vt(i,o,l,u),o.child}var pl={dehydrated:null,treeContext:null,retryLane:0};function gl(i){return{baseLanes:i,cachePool:null,transitions:null}}function rm(i,o,l){var u=o.pendingProps,p=ze.current,v=!1,j=(o.flags&128)!==0,$;if(($=j)||($=i!==null&&i.memoizedState===null?!1:(p&2)!==0),$?(v=!0,o.flags&=-129):(i===null||i.memoizedState!==null)&&(p|=1),Oe(ze,p&1),i===null)return Wc(o),i=o.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((o.mode&1)===0?o.lanes=1:i.data==="$!"?o.lanes=8:o.lanes=1073741824,null):(j=u.children,i=u.fallback,v?(u=o.mode,v=o.child,j={mode:"hidden",children:j},(u&1)===0&&v!==null?(v.childLanes=0,v.pendingProps=j):v=Io(j,u,0,null),i=ks(i,u,l,null),v.return=o,i.return=o,v.sibling=i,o.child=v,o.child.memoizedState=gl(l),o.memoizedState=pl,i):vl(o,j));if(p=i.memoizedState,p!==null&&($=p.dehydrated,$!==null))return $x(i,o,j,u,$,p,l);if(v){v=u.fallback,j=o.mode,p=i.child,$=p.sibling;var T={mode:"hidden",children:u.children};return(j&1)===0&&o.child!==p?(u=o.child,u.childLanes=0,u.pendingProps=T,o.deletions=null):(u=Qn(p,T),u.subtreeFlags=p.subtreeFlags&14680064),$!==null?v=Qn($,v):(v=ks(v,j,l,null),v.flags|=2),v.return=o,u.return=o,u.sibling=v,o.child=u,u=v,v=o.child,j=i.child.memoizedState,j=j===null?gl(l):{baseLanes:j.baseLanes|l,cachePool:null,transitions:j.transitions},v.memoizedState=j,v.childLanes=i.childLanes&~l,o.memoizedState=pl,u}return v=i.child,i=v.sibling,u=Qn(v,{mode:"visible",children:u.children}),(o.mode&1)===0&&(u.lanes=l),u.return=o,u.sibling=null,i!==null&&(l=o.deletions,l===null?(o.deletions=[i],o.flags|=16):l.push(i)),o.child=u,o.memoizedState=null,u}function vl(i,o){return o=Io({mode:"visible",children:o},i.mode,0,null),o.return=i,i.child=o}function wo(i,o,l,u){return u!==null&&Hc(u),Vs(o,i.child,null,l),i=vl(o,o.pendingProps.children),i.flags|=2,o.memoizedState=null,i}function $x(i,o,l,u,p,v,j){if(l)return o.flags&256?(o.flags&=-257,u=ul(Error(n(422))),wo(i,o,j,u)):o.memoizedState!==null?(o.child=i.child,o.flags|=128,null):(v=u.fallback,p=o.mode,u=Io({mode:"visible",children:u.children},p,0,null),v=ks(v,p,j,null),v.flags|=2,u.return=o,v.return=o,u.sibling=v,o.child=u,(o.mode&1)!==0&&Vs(o,i.child,null,j),o.child.memoizedState=gl(j),o.memoizedState=pl,v);if((o.mode&1)===0)return wo(i,o,j,null);if(p.data==="$!"){if(u=p.nextSibling&&p.nextSibling.dataset,u)var $=u.dgst;return u=$,v=Error(n(419)),u=ul(v,u,void 0),wo(i,o,j,u)}if($=(j&i.childLanes)!==0,jt||$){if(u=nt,u!==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&(u.suspendedLanes|j))!==0?0:p,p!==0&&p!==v.retryLane&&(v.retryLane=p,xn(i,p),en(u,i,p,-1))}return Il(),u=ul(Error(n(421))),wo(i,o,j,u)}return p.data==="$?"?(o.flags|=128,o.child=i.child,o=Bx.bind(null,i),p._reactRetry=o,null):(i=v.treeContext,Mt=_n(p.nextSibling),Rt=o,Be=!0,Yt=null,i!==null&&(Lt[Pt++]=yn,Lt[Pt++]=wn,Lt[Pt++]=ls,yn=i.id,wn=i.overflow,ls=o),o=vl(o,u.children),o.flags|=4096,o)}function om(i,o,l){i.lanes|=o;var u=i.alternate;u!==null&&(u.lanes|=o),qc(i.return,o,l)}function kl(i,o,l,u,p){var v=i.memoizedState;v===null?i.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:u,tail:l,tailMode:p}:(v.isBackwards=o,v.rendering=null,v.renderingStartTime=0,v.last=u,v.tail=l,v.tailMode=p)}function am(i,o,l){var u=o.pendingProps,p=u.revealOrder,v=u.tail;if(vt(i,o,u.children,l),u=ze.current,(u&2)!==0)u=u&1|2,o.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=o.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&om(i,l,o);else if(i.tag===19)om(i,l,o);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===o)break e;for(;i.sibling===null;){if(i.return===null||i.return===o)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}u&=1}if(Oe(ze,u),(o.mode&1)===0)o.memoizedState=null;else switch(p){case"forwards":for(l=o.child,p=null;l!==null;)i=l.alternate,i!==null&&fo(i)===null&&(p=l),l=l.sibling;l=p,l===null?(p=o.child,o.child=null):(p=l.sibling,l.sibling=null),kl(o,!1,p,l,v);break;case"backwards":for(l=null,p=o.child,o.child=null;p!==null;){if(i=p.alternate,i!==null&&fo(i)===null){o.child=p;break}i=p.sibling,p.sibling=l,l=p,p=i}kl(o,!0,l,null,v);break;case"together":kl(o,!1,null,null,void 0);break;default:o.memoizedState=null}return o.child}function xo(i,o){(o.mode&1)===0&&i!==null&&(i.alternate=null,o.alternate=null,o.flags|=2)}function bn(i,o,l){if(i!==null&&(o.dependencies=i.dependencies),ms|=o.lanes,(l&o.childLanes)===0)return null;if(i!==null&&o.child!==i.child)throw Error(n(153));if(o.child!==null){for(i=o.child,l=Qn(i,i.pendingProps),o.child=l,l.return=o;i.sibling!==null;)i=i.sibling,l=l.sibling=Qn(i,i.pendingProps),l.return=o;l.sibling=null}return o.child}function Cx(i,o,l){switch(o.tag){case 3:sm(o),Gs();break;case 5:xf(o);break;case 1:xt(o.type)&&no(o);break;case 4:Jc(o,o.stateNode.containerInfo);break;case 10:var u=o.type._context,p=o.memoizedProps.value;Oe(co,u._currentValue),u._currentValue=p;break;case 13:if(u=o.memoizedState,u!==null)return u.dehydrated!==null?(Oe(ze,ze.current&1),o.flags|=128,null):(l&o.child.childLanes)!==0?rm(i,o,l):(Oe(ze,ze.current&1),i=bn(i,o,l),i!==null?i.sibling:null);Oe(ze,ze.current&1);break;case 19:if(u=(l&o.childLanes)!==0,(i.flags&128)!==0){if(u)return am(i,o,l);o.flags|=128}if(p=o.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),Oe(ze,ze.current),u)break;return null;case 22:case 23:return o.lanes=0,em(i,o,l)}return bn(i,o,l)}var cm,yl,lm,dm;cm=function(i,o){for(var l=o.child;l!==null;){if(l.tag===5||l.tag===6)i.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}},yl=function(){},lm=function(i,o,l,u){var p=i.memoizedProps;if(p!==u){i=o.stateNode,hs(cn.current);var v=null;switch(l){case"input":p=qa(i,p),u=qa(i,u),v=[];break;case"select":p=U({},p,{value:void 0}),u=U({},u,{value:void 0}),v=[];break;case"textarea":p=Ja(i,p),u=Ja(i,u),v=[];break;default:typeof p.onClick!="function"&&typeof u.onClick=="function"&&(i.onclick=Zr)}Za(l,u);var j;l=null;for(L in p)if(!u.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 u){var T=u[L];if($=p!=null?p[L]:void 0,u.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",i),v||$===T||(v=[])):(v=v||[]).push(L,T))}l&&(v=v||[]).push("style",l);var L=v;(o.updateQueue=L)&&(o.flags|=4)}},dm=function(i,o,l,u){l!==u&&(o.flags|=4)};function tr(i,o){if(!Be)switch(i.tailMode){case"hidden":o=i.tail;for(var l=null;o!==null;)o.alternate!==null&&(l=o),o=o.sibling;l===null?i.tail=null:l.sibling=null;break;case"collapsed":l=i.tail;for(var u=null;l!==null;)l.alternate!==null&&(u=l),l=l.sibling;u===null?o||i.tail===null?i.tail=null:i.tail.sibling=null:u.sibling=null}}function ut(i){var o=i.alternate!==null&&i.alternate.child===i.child,l=0,u=0;if(o)for(var p=i.child;p!==null;)l|=p.lanes|p.childLanes,u|=p.subtreeFlags&14680064,u|=p.flags&14680064,p.return=i,p=p.sibling;else for(p=i.child;p!==null;)l|=p.lanes|p.childLanes,u|=p.subtreeFlags,u|=p.flags,p.return=i,p=p.sibling;return i.subtreeFlags|=u,i.childLanes=l,o}function Tx(i,o,l){var u=o.pendingProps;switch(zc(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 u=o.stateNode,Ys(),De(wt),De(lt),el(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(i===null||i.child===null)&&(oo(o)?o.flags|=4:i===null||i.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,Yt!==null&&(Al(Yt),Yt=null))),yl(i,o),ut(o),null;case 5:Xc(o);var p=hs(Yi.current);if(l=o.type,i!==null&&o.stateNode!=null)lm(i,o,l,u,p),i.ref!==o.ref&&(o.flags|=512,o.flags|=2097152);else{if(!u){if(o.stateNode===null)throw Error(n(166));return ut(o),null}if(i=hs(cn.current),oo(o)){u=o.stateNode,l=o.type;var v=o.memoizedProps;switch(u[an]=o,u[Ki]=v,i=(o.mode&1)!==0,l){case"dialog":Pe("cancel",u),Pe("close",u);break;case"iframe":case"object":case"embed":Pe("load",u);break;case"video":case"audio":for(p=0;p<Ui.length;p++)Pe(Ui[p],u);break;case"source":Pe("error",u);break;case"img":case"image":case"link":Pe("error",u),Pe("load",u);break;case"details":Pe("toggle",u);break;case"input":Wu(u,v),Pe("invalid",u);break;case"select":u._wrapperState={wasMultiple:!!v.multiple},Pe("invalid",u);break;case"textarea":Gu(u,v),Pe("invalid",u)}Za(l,v),p=null;for(var j in v)if(v.hasOwnProperty(j)){var $=v[j];j==="children"?typeof $=="string"?u.textContent!==$&&(v.suppressHydrationWarning!==!0&&Xr(u.textContent,$,i),p=["children",$]):typeof $=="number"&&u.textContent!==""+$&&(v.suppressHydrationWarning!==!0&&Xr(u.textContent,$,i),p=["children",""+$]):a.hasOwnProperty(j)&&$!=null&&j==="onScroll"&&Pe("scroll",u)}switch(l){case"input":Rn(u),Ku(u,v,!0);break;case"textarea":Rn(u),qu(u);break;case"select":case"option":break;default:typeof v.onClick=="function"&&(u.onclick=Zr)}u=p,o.updateQueue=u,u!==null&&(o.flags|=4)}else{j=p.nodeType===9?p:p.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=Qu(l)),i==="http://www.w3.org/1999/xhtml"?l==="script"?(i=j.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof u.is=="string"?i=j.createElement(l,{is:u.is}):(i=j.createElement(l),l==="select"&&(j=i,u.multiple?j.multiple=!0:u.size&&(j.size=u.size))):i=j.createElementNS(i,l),i[an]=o,i[Ki]=u,cm(i,o,!1,!1),o.stateNode=i;e:{switch(j=ec(l,u),l){case"dialog":Pe("cancel",i),Pe("close",i),p=u;break;case"iframe":case"object":case"embed":Pe("load",i),p=u;break;case"video":case"audio":for(p=0;p<Ui.length;p++)Pe(Ui[p],i);p=u;break;case"source":Pe("error",i),p=u;break;case"img":case"image":case"link":Pe("error",i),Pe("load",i),p=u;break;case"details":Pe("toggle",i),p=u;break;case"input":Wu(i,u),p=qa(i,u),Pe("invalid",i);break;case"option":p=u;break;case"select":i._wrapperState={wasMultiple:!!u.multiple},p=U({},u,{value:void 0}),Pe("invalid",i);break;case"textarea":Gu(i,u),p=Ja(i,u),Pe("invalid",i);break;default:p=u}Za(l,p),$=p;for(v in $)if($.hasOwnProperty(v)){var T=$[v];v==="style"?Xu(i,T):v==="dangerouslySetInnerHTML"?(T=T?T.__html:void 0,T!=null&&Yu(i,T)):v==="children"?typeof T=="string"?(l!=="textarea"||T!=="")&&bi(i,T):typeof T=="number"&&bi(i,""+T):v!=="suppressContentEditableWarning"&&v!=="suppressHydrationWarning"&&v!=="autoFocus"&&(a.hasOwnProperty(v)?T!=null&&v==="onScroll"&&Pe("scroll",i):T!=null&&D(i,v,T,j))}switch(l){case"input":Rn(i),Ku(i,u,!1);break;case"textarea":Rn(i),qu(i);break;case"option":u.value!=null&&i.setAttribute("value",""+$e(u.value));break;case"select":i.multiple=!!u.multiple,v=u.value,v!=null?Rs(i,!!u.multiple,v,!1):u.defaultValue!=null&&Rs(i,!!u.multiple,u.defaultValue,!0);break;default:typeof p.onClick=="function"&&(i.onclick=Zr)}switch(l){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}}u&&(o.flags|=4)}o.ref!==null&&(o.flags|=512,o.flags|=2097152)}return ut(o),null;case 6:if(i&&o.stateNode!=null)dm(i,o,i.memoizedProps,u);else{if(typeof u!="string"&&o.stateNode===null)throw Error(n(166));if(l=hs(Yi.current),hs(cn.current),oo(o)){if(u=o.stateNode,l=o.memoizedProps,u[an]=o,(v=u.nodeValue!==l)&&(i=Rt,i!==null))switch(i.tag){case 3:Xr(u.nodeValue,l,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&Xr(u.nodeValue,l,(i.mode&1)!==0)}v&&(o.flags|=4)}else u=(l.nodeType===9?l:l.ownerDocument).createTextNode(u),u[an]=o,o.stateNode=u}return ut(o),null;case 13:if(De(ze),u=o.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(Be&&Mt!==null&&(o.mode&1)!==0&&(o.flags&128)===0)ff(),Gs(),o.flags|=98560,v=!1;else if(v=oo(o),u!==null&&u.dehydrated!==null){if(i===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&&(Al(Yt),Yt=null),v=!0;if(!v)return o.flags&65536?o:null}return(o.flags&128)!==0?(o.lanes=l,o):(u=u!==null,u!==(i!==null&&i.memoizedState!==null)&&u&&(o.child.flags|=8192,(o.mode&1)!==0&&(i===null||(ze.current&1)!==0?et===0&&(et=3):Il())),o.updateQueue!==null&&(o.flags|=4),ut(o),null);case 4:return Ys(),yl(i,o),i===null&&Wi(o.stateNode.containerInfo),ut(o),null;case 10:return Vc(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(u=(o.flags&128)!==0,j=v.rendering,j===null)if(u)tr(v,!1);else{if(et!==0||i!==null&&(i.flags&128)!==0)for(i=o.child;i!==null;){if(j=fo(i),j!==null){for(o.flags|=128,tr(v,!1),u=j.updateQueue,u!==null&&(o.updateQueue=u,o.flags|=4),o.subtreeFlags=0,u=l,l=o.child;l!==null;)v=l,i=u,v.flags&=14680066,j=v.alternate,j===null?(v.childLanes=0,v.lanes=i,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,i=j.dependencies,v.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),l=l.sibling;return Oe(ze,ze.current&1|2),o.child}i=i.sibling}v.tail!==null&&qe()>ei&&(o.flags|=128,u=!0,tr(v,!1),o.lanes=4194304)}else{if(!u)if(i=fo(j),i!==null){if(o.flags|=128,u=!0,l=i.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,u=!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,u?l&1|2:l&1),o):(ut(o),null);case 22:case 23:return Ml(),u=o.memoizedState!==null,i!==null&&i.memoizedState!==null!==u&&(o.flags|=8192),u&&(o.mode&1)!==0?(It&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 Ex(i,o){switch(zc(o),o.tag){case 1:return xt(o.type)&&to(),i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 3:return Ys(),De(wt),De(lt),el(),i=o.flags,(i&65536)!==0&&(i&128)===0?(o.flags=i&-65537|128,o):null;case 5:return Xc(o),null;case 13:if(De(ze),i=o.memoizedState,i!==null&&i.dehydrated!==null){if(o.alternate===null)throw Error(n(340));Gs()}return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 19:return De(ze),null;case 4:return Ys(),null;case 10:return Vc(o.type._context),null;case 22:case 23:return Ml(),null;case 24:return null;default:return null}}var jo=!1,ht=!1,Ax=typeof WeakSet=="function"?WeakSet:Set,ee=null;function Xs(i,o){var l=i.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(u){Ve(i,o,u)}else l.current=null}function wl(i,o,l){try{l()}catch(u){Ve(i,o,u)}}var um=!1;function Rx(i,o){if(Mc=zr,i=Uh(),Sc(i)){if("selectionStart"in i)var l={start:i.selectionStart,end:i.selectionEnd};else e:{l=(l=i.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var p=u.anchorOffset,v=u.focusNode;u=u.focusOffset;try{l.nodeType,v.nodeType}catch{l=null;break e}var j=0,$=-1,T=-1,L=0,K=0,G=i,H=null;t:for(;;){for(var X;G!==l||p!==0&&G.nodeType!==3||($=j+p),G!==v||u!==0&&G.nodeType!==3||(T=j+u),G.nodeType===3&&(j+=G.nodeValue.length),(X=G.firstChild)!==null;)H=G,G=X;for(;;){if(G===i)break t;if(H===l&&++L===p&&($=j),H===v&&++K===u&&(T=j),(X=G.nextSibling)!==null)break;G=H,H=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(Ic={focusedElem:i,selectionRange:l},zr=!1,ee=o;ee!==null;)if(o=ee,i=o.child,(o.subtreeFlags&1028)!==0&&i!==null)i.return=o,ee=i;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(i=o.sibling,i!==null){i.return=o.return,ee=i;break}ee=o.return}return te=um,um=!1,te}function nr(i,o,l){var u=o.updateQueue;if(u=u!==null?u.lastEffect:null,u!==null){var p=u=u.next;do{if((p.tag&i)===i){var v=p.destroy;p.destroy=void 0,v!==void 0&&wl(o,l,v)}p=p.next}while(p!==u)}}function bo(i,o){if(o=o.updateQueue,o=o!==null?o.lastEffect:null,o!==null){var l=o=o.next;do{if((l.tag&i)===i){var u=l.create;l.destroy=u()}l=l.next}while(l!==o)}}function xl(i){var o=i.ref;if(o!==null){var l=i.stateNode;switch(i.tag){case 5:i=l;break;default:i=l}typeof o=="function"?o(i):o.current=i}}function hm(i){var o=i.alternate;o!==null&&(i.alternate=null,hm(o)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(o=i.stateNode,o!==null&&(delete o[an],delete o[Ki],delete o[Dc],delete o[fx],delete o[mx])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function fm(i){return i.tag===5||i.tag===3||i.tag===4}function mm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||fm(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function jl(i,o,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,o?l.nodeType===8?l.parentNode.insertBefore(i,o):l.insertBefore(i,o):(l.nodeType===8?(o=l.parentNode,o.insertBefore(i,l)):(o=l,o.appendChild(i)),l=l._reactRootContainer,l!=null||o.onclick!==null||(o.onclick=Zr));else if(u!==4&&(i=i.child,i!==null))for(jl(i,o,l),i=i.sibling;i!==null;)jl(i,o,l),i=i.sibling}function bl(i,o,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,o?l.insertBefore(i,o):l.appendChild(i);else if(u!==4&&(i=i.child,i!==null))for(bl(i,o,l),i=i.sibling;i!==null;)bl(i,o,l),i=i.sibling}var ot=null,Xt=!1;function Hn(i,o,l){for(l=l.child;l!==null;)pm(i,o,l),l=l.sibling}function pm(i,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 u=ot,p=Xt;ot=null,Hn(i,o,l),ot=u,Xt=p,ot!==null&&(Xt?(i=ot,l=l.stateNode,i.nodeType===8?i.parentNode.removeChild(l):i.removeChild(l)):ot.removeChild(l.stateNode));break;case 18:ot!==null&&(Xt?(i=ot,l=l.stateNode,i.nodeType===8?Pc(i.parentNode,l):i.nodeType===1&&Pc(i,l),Oi(i)):Pc(ot,l.stateNode));break;case 4:u=ot,p=Xt,ot=l.stateNode.containerInfo,Xt=!0,Hn(i,o,l),ot=u,Xt=p;break;case 0:case 11:case 14:case 15:if(!ht&&(u=l.updateQueue,u!==null&&(u=u.lastEffect,u!==null))){p=u=u.next;do{var v=p,j=v.destroy;v=v.tag,j!==void 0&&((v&2)!==0||(v&4)!==0)&&wl(l,o,j),p=p.next}while(p!==u)}Hn(i,o,l);break;case 1:if(!ht&&(Xs(l,o),u=l.stateNode,typeof u.componentWillUnmount=="function"))try{u.props=l.memoizedProps,u.state=l.memoizedState,u.componentWillUnmount()}catch($){Ve(l,o,$)}Hn(i,o,l);break;case 21:Hn(i,o,l);break;case 22:l.mode&1?(ht=(u=ht)||l.memoizedState!==null,Hn(i,o,l),ht=u):Hn(i,o,l);break;default:Hn(i,o,l)}}function gm(i){var o=i.updateQueue;if(o!==null){i.updateQueue=null;var l=i.stateNode;l===null&&(l=i.stateNode=new Ax),o.forEach(function(u){var p=Fx.bind(null,i,u);l.has(u)||(l.add(u),u.then(p,p))})}}function Zt(i,o){var l=o.deletions;if(l!==null)for(var u=0;u<l.length;u++){var p=l[u];try{var v=i,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));pm(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;)vm(o,i),o=o.sibling}function vm(i,o){var l=i.alternate,u=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(Zt(o,i),dn(i),u&4){try{nr(3,i,i.return),bo(3,i)}catch(ne){Ve(i,i.return,ne)}try{nr(5,i,i.return)}catch(ne){Ve(i,i.return,ne)}}break;case 1:Zt(o,i),dn(i),u&512&&l!==null&&Xs(l,l.return);break;case 5:if(Zt(o,i),dn(i),u&512&&l!==null&&Xs(l,l.return),i.flags&32){var p=i.stateNode;try{bi(p,"")}catch(ne){Ve(i,i.return,ne)}}if(u&4&&(p=i.stateNode,p!=null)){var v=i.memoizedProps,j=l!==null?l.memoizedProps:v,$=i.type,T=i.updateQueue;if(i.updateQueue=null,T!==null)try{$==="input"&&v.type==="radio"&&v.name!=null&&Hu(p,v),ec($,j);var L=ec($,v);for(j=0;j<T.length;j+=2){var K=T[j],G=T[j+1];K==="style"?Xu(p,G):K==="dangerouslySetInnerHTML"?Yu(p,G):K==="children"?bi(p,G):D(p,K,G,L)}switch($){case"input":Qa(p,v);break;case"textarea":Vu(p,v);break;case"select":var H=p._wrapperState.wasMultiple;p._wrapperState.wasMultiple=!!v.multiple;var X=v.value;X!=null?Rs(p,!!v.multiple,X,!1):H!==!!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(i,i.return,ne)}}break;case 6:if(Zt(o,i),dn(i),u&4){if(i.stateNode===null)throw Error(n(162));p=i.stateNode,v=i.memoizedProps;try{p.nodeValue=v}catch(ne){Ve(i,i.return,ne)}}break;case 3:if(Zt(o,i),dn(i),u&4&&l!==null&&l.memoizedState.isDehydrated)try{Oi(o.containerInfo)}catch(ne){Ve(i,i.return,ne)}break;case 4:Zt(o,i),dn(i);break;case 13:Zt(o,i),dn(i),p=i.child,p.flags&8192&&(v=p.memoizedState!==null,p.stateNode.isHidden=v,!v||p.alternate!==null&&p.alternate.memoizedState!==null||($l=qe())),u&4&&gm(i);break;case 22:if(K=l!==null&&l.memoizedState!==null,i.mode&1?(ht=(L=ht)||K,Zt(o,i),ht=L):Zt(o,i),dn(i),u&8192){if(L=i.memoizedState!==null,(i.stateNode.isHidden=L)&&!K&&(i.mode&1)!==0)for(ee=i,K=i.child;K!==null;){for(G=ee=K;ee!==null;){switch(H=ee,X=H.child,H.tag){case 0:case 11:case 14:case 15:nr(4,H,H.return);break;case 1:Xs(H,H.return);var te=H.stateNode;if(typeof te.componentWillUnmount=="function"){u=H,l=H.return;try{o=u,te.props=o.memoizedProps,te.state=o.memoizedState,te.componentWillUnmount()}catch(ne){Ve(u,l,ne)}}break;case 5:Xs(H,H.return);break;case 22:if(H.memoizedState!==null){wm(G);continue}}X!==null?(X.return=H,ee=X):wm(G)}K=K.sibling}e:for(K=null,G=i;;){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=Ju("display",j))}catch(ne){Ve(i,i.return,ne)}}}else if(G.tag===6){if(K===null)try{G.stateNode.nodeValue=L?"":G.memoizedProps}catch(ne){Ve(i,i.return,ne)}}else if((G.tag!==22&&G.tag!==23||G.memoizedState===null||G===i)&&G.child!==null){G.child.return=G,G=G.child;continue}if(G===i)break e;for(;G.sibling===null;){if(G.return===null||G.return===i)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,i),dn(i),u&4&&gm(i);break;case 21:break;default:Zt(o,i),dn(i)}}function dn(i){var o=i.flags;if(o&2){try{e:{for(var l=i.return;l!==null;){if(fm(l)){var u=l;break e}l=l.return}throw Error(n(160))}switch(u.tag){case 5:var p=u.stateNode;u.flags&32&&(bi(p,""),u.flags&=-33);var v=mm(i);bl(i,v,p);break;case 3:case 4:var j=u.stateNode.containerInfo,$=mm(i);jl(i,$,j);break;default:throw Error(n(161))}}catch(T){Ve(i,i.return,T)}i.flags&=-3}o&4096&&(i.flags&=-4097)}function Mx(i,o,l){ee=i,km(i)}function km(i,o,l){for(var u=(i.mode&1)!==0;ee!==null;){var p=ee,v=p.child;if(p.tag===22&&u){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?xm(p):T!==null?(T.return=j,ee=T):xm(p);for(;v!==null;)ee=v,km(v),v=v.sibling;ee=p,jo=$,ht=L}ym(i)}else(p.subtreeFlags&8772)!==0&&v!==null?(v.return=p,ee=v):ym(i)}}function ym(i){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 u=o.stateNode;if(o.flags&4&&!ht)if(l===null)u.componentDidMount();else{var p=o.elementType===o.type?l.memoizedProps:Jt(o.type,l.memoizedProps);u.componentDidUpdate(p,l.memoizedState,u.__reactInternalSnapshotBeforeUpdate)}var v=o.updateQueue;v!==null&&wf(o,v,u);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}wf(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&&xl(o)}catch(H){Ve(o,o.return,H)}}if(o===i){ee=null;break}if(l=o.sibling,l!==null){l.return=o.return,ee=l;break}ee=o.return}}function wm(i){for(;ee!==null;){var o=ee;if(o===i){ee=null;break}var l=o.sibling;if(l!==null){l.return=o.return,ee=l;break}ee=o.return}}function xm(i){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 u=o.stateNode;if(typeof u.componentDidMount=="function"){var p=o.return;try{u.componentDidMount()}catch(T){Ve(o,p,T)}}var v=o.return;try{xl(o)}catch(T){Ve(o,v,T)}break;case 5:var j=o.return;try{xl(o)}catch(T){Ve(o,j,T)}}}catch(T){Ve(o,o.return,T)}if(o===i){ee=null;break}var $=o.sibling;if($!==null){$.return=o.return,ee=$;break}ee=o.return}}var Ix=Math.ceil,So=M.ReactCurrentDispatcher,Sl=M.ReactCurrentOwner,Bt=M.ReactCurrentBatchConfig,Ce=0,nt=null,Ye=null,at=0,It=0,Zs=Bn(0),et=0,sr=null,ms=0,No=0,Nl=0,ir=null,bt=null,$l=0,ei=1/0,Sn=null,$o=!1,Cl=null,Kn=null,Co=!1,Gn=null,To=0,rr=0,Tl=null,Eo=-1,Ao=0;function kt(){return(Ce&6)!==0?qe():Eo!==-1?Eo:Eo=qe()}function Vn(i){return(i.mode&1)===0?1:(Ce&2)!==0&&at!==0?at&-at:gx.transition!==null?(Ao===0&&(Ao=fh()),Ao):(i=Re,i!==0||(i=window.event,i=i===void 0?16:jh(i.type)),i)}function en(i,o,l,u){if(50<rr)throw rr=0,Tl=null,Error(n(185));Ei(i,l,u),((Ce&2)===0||i!==nt)&&(i===nt&&((Ce&2)===0&&(No|=l),et===4&&qn(i,at)),St(i,u),l===1&&Ce===0&&(o.mode&1)===0&&(ei=qe()+500,so&&zn()))}function St(i,o){var l=i.callbackNode;gw(i,o);var u=_r(i,i===nt?at:0);if(u===0)l!==null&&dh(l),i.callbackNode=null,i.callbackPriority=0;else if(o=u&-u,i.callbackPriority!==o){if(l!=null&&dh(l),o===1)i.tag===0?px(bm.bind(null,i)):cf(bm.bind(null,i)),ux(function(){(Ce&6)===0&&zn()}),l=null;else{switch(mh(u)){case 1:l=ac;break;case 4:l=uh;break;case 16:l=Or;break;case 536870912:l=hh;break;default:l=Or}l=Rm(l,jm.bind(null,i))}i.callbackPriority=o,i.callbackNode=l}}function jm(i,o){if(Eo=-1,Ao=0,(Ce&6)!==0)throw Error(n(327));var l=i.callbackNode;if(ti()&&i.callbackNode!==l)return null;var u=_r(i,i===nt?at:0);if(u===0)return null;if((u&30)!==0||(u&i.expiredLanes)!==0||o)o=Ro(i,u);else{o=u;var p=Ce;Ce|=2;var v=Nm();(nt!==i||at!==o)&&(Sn=null,ei=qe()+500,gs(i,o));do try{Px();break}catch($){Sm(i,$)}while(!0);Gc(),So.current=v,Ce=p,Ye!==null?o=0:(nt=null,at=0,o=et)}if(o!==0){if(o===2&&(p=cc(i),p!==0&&(u=p,o=El(i,p))),o===1)throw l=sr,gs(i,0),qn(i,u),St(i,qe()),l;if(o===6)qn(i,u);else{if(p=i.current.alternate,(u&30)===0&&!Ox(p)&&(o=Ro(i,u),o===2&&(v=cc(i),v!==0&&(u=v,o=El(i,v))),o===1))throw l=sr,gs(i,0),qn(i,u),St(i,qe()),l;switch(i.finishedWork=p,i.finishedLanes=u,o){case 0:case 1:throw Error(n(345));case 2:vs(i,bt,Sn);break;case 3:if(qn(i,u),(u&130023424)===u&&(o=$l+500-qe(),10<o)){if(_r(i,0)!==0)break;if(p=i.suspendedLanes,(p&u)!==u){kt(),i.pingedLanes|=i.suspendedLanes&p;break}i.timeoutHandle=Lc(vs.bind(null,i,bt,Sn),o);break}vs(i,bt,Sn);break;case 4:if(qn(i,u),(u&4194240)===u)break;for(o=i.eventTimes,p=-1;0<u;){var j=31-qt(u);v=1<<j,j=o[j],j>p&&(p=j),u&=~v}if(u=p,u=qe()-u,u=(120>u?120:480>u?480:1080>u?1080:1920>u?1920:3e3>u?3e3:4320>u?4320:1960*Ix(u/1960))-u,10<u){i.timeoutHandle=Lc(vs.bind(null,i,bt,Sn),u);break}vs(i,bt,Sn);break;case 5:vs(i,bt,Sn);break;default:throw Error(n(329))}}}return St(i,qe()),i.callbackNode===l?jm.bind(null,i):null}function El(i,o){var l=ir;return i.current.memoizedState.isDehydrated&&(gs(i,o).flags|=256),i=Ro(i,o),i!==2&&(o=bt,bt=l,o!==null&&Al(o)),i}function Al(i){bt===null?bt=i:bt.push.apply(bt,i)}function Ox(i){for(var o=i;;){if(o.flags&16384){var l=o.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var u=0;u<l.length;u++){var p=l[u],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===i)break;for(;o.sibling===null;){if(o.return===null||o.return===i)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function qn(i,o){for(o&=~Nl,o&=~No,i.suspendedLanes|=o,i.pingedLanes&=~o,i=i.expirationTimes;0<o;){var l=31-qt(o),u=1<<l;i[l]=-1,o&=~u}}function bm(i){if((Ce&6)!==0)throw Error(n(327));ti();var o=_r(i,0);if((o&1)===0)return St(i,qe()),null;var l=Ro(i,o);if(i.tag!==0&&l===2){var u=cc(i);u!==0&&(o=u,l=El(i,u))}if(l===1)throw l=sr,gs(i,0),qn(i,o),St(i,qe()),l;if(l===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=o,vs(i,bt,Sn),St(i,qe()),null}function Rl(i,o){var l=Ce;Ce|=1;try{return i(o)}finally{Ce=l,Ce===0&&(ei=qe()+500,so&&zn())}}function ps(i){Gn!==null&&Gn.tag===0&&(Ce&6)===0&&ti();var o=Ce;Ce|=1;var l=Bt.transition,u=Re;try{if(Bt.transition=null,Re=1,i)return i()}finally{Re=u,Bt.transition=l,Ce=o,(Ce&6)===0&&zn()}}function Ml(){It=Zs.current,De(Zs)}function gs(i,o){i.finishedWork=null,i.finishedLanes=0;var l=i.timeoutHandle;if(l!==-1&&(i.timeoutHandle=-1,dx(l)),Ye!==null)for(l=Ye.return;l!==null;){var u=l;switch(zc(u),u.tag){case 1:u=u.type.childContextTypes,u!=null&&to();break;case 3:Ys(),De(wt),De(lt),el();break;case 5:Xc(u);break;case 4:Ys();break;case 13:De(ze);break;case 19:De(ze);break;case 10:Vc(u.type._context);break;case 22:case 23:Ml()}l=l.return}if(nt=i,Ye=i=Qn(i.current,null),at=It=o,et=0,sr=null,Nl=No=ms=0,bt=ir=null,us!==null){for(o=0;o<us.length;o++)if(l=us[o],u=l.interleaved,u!==null){l.interleaved=null;var p=u.next,v=l.pending;if(v!==null){var j=v.next;v.next=p,u.next=j}l.pending=u}us=null}return i}function Sm(i,o){do{var l=Ye;try{if(Gc(),mo.current=ko,po){for(var u=Ue.memoizedState;u!==null;){var p=u.queue;p!==null&&(p.pending=null),u=u.next}po=!1}if(fs=0,tt=Ze=Ue=null,Ji=!1,Xi=0,Sl.current=null,l===null||l.return===null){et=1,sr=o,Ye=null;break}e:{var v=i,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 H=K.alternate;H?(K.updateQueue=H.updateQueue,K.memoizedState=H.memoizedState,K.lanes=H.lanes):(K.updateQueue=null,K.memoizedState=null)}var X=Qf(j);if(X!==null){X.flags&=-257,Yf(X,j,$,v,o),X.mode&1&&qf(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){qf(v,L,o),Il();break e}T=Error(n(426))}}else if(Be&&$.mode&1){var Qe=Qf(j);if(Qe!==null){(Qe.flags&65536)===0&&(Qe.flags|=256),Yf(Qe,j,$,v,o),Hc(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=Gf(v,T,o);yf(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=Vf(v,$,o);yf(v,V);break e}}v=v.return}while(v!==null)}Cm(l)}catch(ie){o=ie,Ye===l&&l!==null&&(Ye=l=l.return);continue}break}while(!0)}function Nm(){var i=So.current;return So.current=ko,i===null?ko:i}function Il(){(et===0||et===3||et===2)&&(et=4),nt===null||(ms&268435455)===0&&(No&268435455)===0||qn(nt,at)}function Ro(i,o){var l=Ce;Ce|=2;var u=Nm();(nt!==i||at!==o)&&(Sn=null,gs(i,o));do try{Lx();break}catch(p){Sm(i,p)}while(!0);if(Gc(),Ce=l,So.current=u,Ye!==null)throw Error(n(261));return nt=null,at=0,et}function Lx(){for(;Ye!==null;)$m(Ye)}function Px(){for(;Ye!==null&&!aw();)$m(Ye)}function $m(i){var o=Am(i.alternate,i,It);i.memoizedProps=i.pendingProps,o===null?Cm(i):Ye=o,Sl.current=null}function Cm(i){var o=i;do{var l=o.alternate;if(i=o.return,(o.flags&32768)===0){if(l=Tx(l,o,It),l!==null){Ye=l;return}}else{if(l=Ex(l,o),l!==null){l.flags&=32767,Ye=l;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{et=6,Ye=null;return}}if(o=o.sibling,o!==null){Ye=o;return}Ye=o=i}while(o!==null);et===0&&(et=5)}function vs(i,o,l){var u=Re,p=Bt.transition;try{Bt.transition=null,Re=1,Dx(i,o,l,u)}finally{Bt.transition=p,Re=u}return null}function Dx(i,o,l,u){do ti();while(Gn!==null);if((Ce&6)!==0)throw Error(n(327));l=i.finishedWork;var p=i.finishedLanes;if(l===null)return null;if(i.finishedWork=null,i.finishedLanes=0,l===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var v=l.lanes|l.childLanes;if(vw(i,v),i===nt&&(Ye=nt=null,at=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||Co||(Co=!0,Rm(Or,function(){return ti(),null})),v=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||v){v=Bt.transition,Bt.transition=null;var j=Re;Re=1;var $=Ce;Ce|=4,Sl.current=null,Rx(i,l),vm(l,i),sx(Ic),zr=!!Mc,Ic=Mc=null,i.current=l,Mx(l),cw(),Ce=$,Re=j,Bt.transition=v}else i.current=l;if(Co&&(Co=!1,Gn=i,To=p),v=i.pendingLanes,v===0&&(Kn=null),uw(l.stateNode),St(i,qe()),o!==null)for(u=i.onRecoverableError,l=0;l<o.length;l++)p=o[l],u(p.value,{componentStack:p.stack,digest:p.digest});if($o)throw $o=!1,i=Cl,Cl=null,i;return(To&1)!==0&&i.tag!==0&&ti(),v=i.pendingLanes,(v&1)!==0?i===Tl?rr++:(rr=0,Tl=i):rr=0,zn(),null}function ti(){if(Gn!==null){var i=mh(To),o=Bt.transition,l=Re;try{if(Bt.transition=null,Re=16>i?16:i,Gn===null)var u=!1;else{if(i=Gn,Gn=null,To=0,(Ce&6)!==0)throw Error(n(331));var p=Ce;for(Ce|=4,ee=i.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 H=K.sibling,X=K.return;if(hm(K),K===L){ee=null;break}if(H!==null){H.return=X,ee=H;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=i.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(ie){Ve($,$.return,ie)}if($===j){ee=null;break e}var V=$.sibling;if(V!==null){V.return=$.return,ee=V;break e}ee=$.return}}if(Ce=p,zn(),on&&typeof on.onPostCommitFiberRoot=="function")try{on.onPostCommitFiberRoot(Lr,i)}catch{}u=!0}return u}finally{Re=l,Bt.transition=o}}return!1}function Tm(i,o,l){o=Js(l,o),o=Gf(i,o,1),i=Wn(i,o,1),o=kt(),i!==null&&(Ei(i,1,o),St(i,o))}function Ve(i,o,l){if(i.tag===3)Tm(i,i,l);else for(;o!==null;){if(o.tag===3){Tm(o,i,l);break}else if(o.tag===1){var u=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Kn===null||!Kn.has(u))){i=Js(l,i),i=Vf(o,i,1),o=Wn(o,i,1),i=kt(),o!==null&&(Ei(o,1,i),St(o,i));break}}o=o.return}}function _x(i,o,l){var u=i.pingCache;u!==null&&u.delete(o),o=kt(),i.pingedLanes|=i.suspendedLanes&l,nt===i&&(at&l)===l&&(et===4||et===3&&(at&130023424)===at&&500>qe()-$l?gs(i,0):Nl|=l),St(i,o)}function Em(i,o){o===0&&((i.mode&1)===0?o=1:(o=Dr,Dr<<=1,(Dr&130023424)===0&&(Dr=4194304)));var l=kt();i=xn(i,o),i!==null&&(Ei(i,o,l),St(i,l))}function Bx(i){var o=i.memoizedState,l=0;o!==null&&(l=o.retryLane),Em(i,l)}function Fx(i,o){var l=0;switch(i.tag){case 13:var u=i.stateNode,p=i.memoizedState;p!==null&&(l=p.retryLane);break;case 19:u=i.stateNode;break;default:throw Error(n(314))}u!==null&&u.delete(o),Em(i,l)}var Am;Am=function(i,o,l){if(i!==null)if(i.memoizedProps!==o.pendingProps||wt.current)jt=!0;else{if((i.lanes&l)===0&&(o.flags&128)===0)return jt=!1,Cx(i,o,l);jt=(i.flags&131072)!==0}else jt=!1,Be&&(o.flags&1048576)!==0&&lf(o,ro,o.index);switch(o.lanes=0,o.tag){case 2:var u=o.type;xo(i,o),i=o.pendingProps;var p=Ws(o,lt.current);Qs(o,l),p=sl(null,o,u,i,p,l);var v=il();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(u)?(v=!0,no(o)):v=!1,o.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,Yc(o),p.updater=yo,o.stateNode=p,p._reactInternals=o,dl(o,u,i,l),o=ml(null,o,u,!0,v,l)):(o.tag=0,Be&&v&&Fc(o),vt(null,o,p,l),o=o.child),o;case 16:u=o.elementType;e:{switch(xo(i,o),i=o.pendingProps,p=u._init,u=p(u._payload),o.type=u,p=o.tag=Ux(u),i=Jt(u,i),p){case 0:o=fl(null,o,u,i,l);break e;case 1:o=nm(null,o,u,i,l);break e;case 11:o=Jf(null,o,u,i,l);break e;case 14:o=Xf(null,o,u,Jt(u.type,i),l);break e}throw Error(n(306,u,""))}return o;case 0:return u=o.type,p=o.pendingProps,p=o.elementType===u?p:Jt(u,p),fl(i,o,u,p,l);case 1:return u=o.type,p=o.pendingProps,p=o.elementType===u?p:Jt(u,p),nm(i,o,u,p,l);case 3:e:{if(sm(o),i===null)throw Error(n(387));u=o.pendingProps,v=o.memoizedState,p=v.element,kf(i,o),ho(o,u,null,l);var j=o.memoizedState;if(u=j.element,v.isDehydrated)if(v={element:u,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=im(i,o,u,l,p);break e}else if(u!==p){p=Js(Error(n(424)),o),o=im(i,o,u,l,p);break e}else for(Mt=_n(o.stateNode.containerInfo.firstChild),Rt=o,Be=!0,Yt=null,l=gf(o,null,u,l),o.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Gs(),u===p){o=bn(i,o,l);break e}vt(i,o,u,l)}o=o.child}return o;case 5:return xf(o),i===null&&Wc(o),u=o.type,p=o.pendingProps,v=i!==null?i.memoizedProps:null,j=p.children,Oc(u,p)?j=null:v!==null&&Oc(u,v)&&(o.flags|=32),tm(i,o),vt(i,o,j,l),o.child;case 6:return i===null&&Wc(o),null;case 13:return rm(i,o,l);case 4:return Jc(o,o.stateNode.containerInfo),u=o.pendingProps,i===null?o.child=Vs(o,null,u,l):vt(i,o,u,l),o.child;case 11:return u=o.type,p=o.pendingProps,p=o.elementType===u?p:Jt(u,p),Jf(i,o,u,p,l);case 7:return vt(i,o,o.pendingProps,l),o.child;case 8:return vt(i,o,o.pendingProps.children,l),o.child;case 12:return vt(i,o,o.pendingProps.children,l),o.child;case 10:e:{if(u=o.type._context,p=o.pendingProps,v=o.memoizedProps,j=p.value,Oe(co,u._currentValue),u._currentValue=j,v!==null)if(Qt(v.value,j)){if(v.children===p.children&&!wt.current){o=bn(i,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===u){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),qc(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),qc(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(i,o,p.children,l),o=o.child}return o;case 9:return p=o.type,u=o.pendingProps.children,Qs(o,l),p=Dt(p),u=u(p),o.flags|=1,vt(i,o,u,l),o.child;case 14:return u=o.type,p=Jt(u,o.pendingProps),p=Jt(u.type,p),Xf(i,o,u,p,l);case 15:return Zf(i,o,o.type,o.pendingProps,l);case 17:return u=o.type,p=o.pendingProps,p=o.elementType===u?p:Jt(u,p),xo(i,o),o.tag=1,xt(u)?(i=!0,no(o)):i=!1,Qs(o,l),Hf(o,u,p),dl(o,u,p,l),ml(null,o,u,!0,i,l);case 19:return am(i,o,l);case 22:return em(i,o,l)}throw Error(n(156,o.tag))};function Rm(i,o){return lh(i,o)}function zx(i,o,l,u){this.tag=i,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=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ft(i,o,l,u){return new zx(i,o,l,u)}function Ol(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Ux(i){if(typeof i=="function")return Ol(i)?1:0;if(i!=null){if(i=i.$$typeof,i===be)return 11;if(i===Ne)return 14}return 2}function Qn(i,o){var l=i.alternate;return l===null?(l=Ft(i.tag,o,i.key,i.mode),l.elementType=i.elementType,l.type=i.type,l.stateNode=i.stateNode,l.alternate=i,i.alternate=l):(l.pendingProps=o,l.type=i.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=i.flags&14680064,l.childLanes=i.childLanes,l.lanes=i.lanes,l.child=i.child,l.memoizedProps=i.memoizedProps,l.memoizedState=i.memoizedState,l.updateQueue=i.updateQueue,o=i.dependencies,l.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},l.sibling=i.sibling,l.index=i.index,l.ref=i.ref,l}function Mo(i,o,l,u,p,v){var j=2;if(u=i,typeof i=="function")Ol(i)&&(j=1);else if(typeof i=="string")j=5;else e:switch(i){case Y:return ks(l.children,p,v,o);case re:j=8,p|=8;break;case q:return i=Ft(12,l,o,p|2),i.elementType=q,i.lanes=v,i;case Z:return i=Ft(13,l,o,p),i.elementType=Z,i.lanes=v,i;case se:return i=Ft(19,l,o,p),i.elementType=se,i.lanes=v,i;case Se:return Io(l,p,v,o);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case ye:j=10;break e;case Ie:j=9;break e;case be:j=11;break e;case Ne:j=14;break e;case me:j=16,u=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return o=Ft(j,l,o,p),o.elementType=i,o.type=u,o.lanes=v,o}function ks(i,o,l,u){return i=Ft(7,i,u,o),i.lanes=l,i}function Io(i,o,l,u){return i=Ft(22,i,u,o),i.elementType=Se,i.lanes=l,i.stateNode={isHidden:!1},i}function Ll(i,o,l){return i=Ft(6,i,null,o),i.lanes=l,i}function Pl(i,o,l){return o=Ft(4,i.children!==null?i.children:[],i.key,o),o.lanes=l,o.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},o}function Wx(i,o,l,u,p){this.tag=o,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=lc(0),this.expirationTimes=lc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=lc(0),this.identifierPrefix=u,this.onRecoverableError=p,this.mutableSourceEagerHydrationData=null}function Dl(i,o,l,u,p,v,j,$,T){return i=new Wx(i,o,l,$,T),o===1?(o=1,v===!0&&(o|=8)):o=0,v=Ft(3,null,null,o),i.current=v,v.stateNode=i,v.memoizedState={element:u,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},Yc(v),i}function Hx(i,o,l){var u=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:_,key:u==null?null:""+u,children:i,containerInfo:o,implementation:l}}function Mm(i){if(!i)return Fn;i=i._reactInternals;e:{if(os(i)!==i||i.tag!==1)throw Error(n(170));var o=i;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(i.tag===1){var l=i.type;if(xt(l))return of(i,l,o)}return o}function Im(i,o,l,u,p,v,j,$,T){return i=Dl(l,u,!0,i,p,v,j,$,T),i.context=Mm(null),l=i.current,u=kt(),p=Vn(l),v=jn(u,p),v.callback=o??null,Wn(l,v,p),i.current.lanes=p,Ei(i,p,u),St(i,u),i}function Oo(i,o,l,u){var p=o.current,v=kt(),j=Vn(p);return l=Mm(l),o.context===null?o.context=l:o.pendingContext=l,o=jn(v,j),o.payload={element:i},u=u===void 0?null:u,u!==null&&(o.callback=u),i=Wn(p,o,j),i!==null&&(en(i,p,j,v),uo(i,p,j)),j}function Lo(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function Om(i,o){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var l=i.retryLane;i.retryLane=l!==0&&l<o?l:o}}function _l(i,o){Om(i,o),(i=i.alternate)&&Om(i,o)}function Kx(){return null}var Lm=typeof reportError=="function"?reportError:function(i){console.error(i)};function Bl(i){this._internalRoot=i}Po.prototype.render=Bl.prototype.render=function(i){var o=this._internalRoot;if(o===null)throw Error(n(409));Oo(i,o,null,null)},Po.prototype.unmount=Bl.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var o=i.containerInfo;ps(function(){Oo(null,i,null,null)}),o[vn]=null}};function Po(i){this._internalRoot=i}Po.prototype.unstable_scheduleHydration=function(i){if(i){var o=vh();i={blockedOn:null,target:i,priority:o};for(var l=0;l<Ln.length&&o!==0&&o<Ln[l].priority;l++);Ln.splice(l,0,i),l===0&&wh(i)}};function Fl(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function Do(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function Pm(){}function Gx(i,o,l,u,p){if(p){if(typeof u=="function"){var v=u;u=function(){var L=Lo(j);v.call(L)}}var j=Im(o,u,i,0,null,!1,!1,"",Pm);return i._reactRootContainer=j,i[vn]=j.current,Wi(i.nodeType===8?i.parentNode:i),ps(),j}for(;p=i.lastChild;)i.removeChild(p);if(typeof u=="function"){var $=u;u=function(){var L=Lo(T);$.call(L)}}var T=Dl(i,0,!1,null,null,!1,!1,"",Pm);return i._reactRootContainer=T,i[vn]=T.current,Wi(i.nodeType===8?i.parentNode:i),ps(function(){Oo(o,T,l,u)}),T}function _o(i,o,l,u,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,i,p)}else j=Gx(l,o,i,p,u);return Lo(j)}ph=function(i){switch(i.tag){case 3:var o=i.stateNode;if(o.current.memoizedState.isDehydrated){var l=Ti(o.pendingLanes);l!==0&&(dc(o,l|1),St(o,qe()),(Ce&6)===0&&(ei=qe()+500,zn()))}break;case 13:ps(function(){var u=xn(i,1);if(u!==null){var p=kt();en(u,i,1,p)}}),_l(i,1)}},uc=function(i){if(i.tag===13){var o=xn(i,134217728);if(o!==null){var l=kt();en(o,i,134217728,l)}_l(i,134217728)}},gh=function(i){if(i.tag===13){var o=Vn(i),l=xn(i,o);if(l!==null){var u=kt();en(l,i,o,u)}_l(i,o)}},vh=function(){return Re},kh=function(i,o){var l=Re;try{return Re=i,o()}finally{Re=l}},sc=function(i,o,l){switch(o){case"input":if(Qa(i,l),o=l.name,l.type==="radio"&&o!=null){for(l=i;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+o)+'][type="radio"]'),o=0;o<l.length;o++){var u=l[o];if(u!==i&&u.form===i.form){var p=eo(u);if(!p)throw Error(n(90));Ar(u),Qa(u,p)}}}break;case"textarea":Vu(i,l);break;case"select":o=l.value,o!=null&&Rs(i,!!l.multiple,o,!1)}},nh=Rl,sh=ps;var Vx={usingClientEntryPoint:!1,Events:[Gi,zs,eo,eh,th,Rl]},or={findFiberByHostInstance:as,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},qx={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(i){return i=ah(i),i===null?null:i.stateNode},findFiberByHostInstance:or.findFiberByHostInstance||Kx,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(qx),on=Bo}catch{}}return Nt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Vx,Nt.createPortal=function(i,o){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Fl(o))throw Error(n(200));return Hx(i,o,null,l)},Nt.createRoot=function(i,o){if(!Fl(i))throw Error(n(299));var l=!1,u="",p=Lm;return o!=null&&(o.unstable_strictMode===!0&&(l=!0),o.identifierPrefix!==void 0&&(u=o.identifierPrefix),o.onRecoverableError!==void 0&&(p=o.onRecoverableError)),o=Dl(i,1,!1,null,null,l,!1,u,p),i[vn]=o.current,Wi(i.nodeType===8?i.parentNode:i),new Bl(o)},Nt.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var o=i._reactInternals;if(o===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=ah(o),i=i===null?null:i.stateNode,i},Nt.flushSync=function(i){return ps(i)},Nt.hydrate=function(i,o,l){if(!Do(o))throw Error(n(200));return _o(null,i,o,!0,l)},Nt.hydrateRoot=function(i,o,l){if(!Fl(i))throw Error(n(405));var u=l!=null&&l.hydratedSources||null,p=!1,v="",j=Lm;if(l!=null&&(l.unstable_strictMode===!0&&(p=!0),l.identifierPrefix!==void 0&&(v=l.identifierPrefix),l.onRecoverableError!==void 0&&(j=l.onRecoverableError)),o=Im(o,null,i,1,l??null,p,!1,v,j),i[vn]=o.current,Wi(i),u)for(i=0;i<u.length;i++)l=u[i],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(i,o,l){if(!Do(o))throw Error(n(200));return _o(null,i,o,!1,l)},Nt.unmountComponentAtNode=function(i){if(!Do(i))throw Error(n(40));return i._reactRootContainer?(ps(function(){_o(null,null,i,!1,function(){i._reactRootContainer=null,i[vn]=null})}),!0):!1},Nt.unstable_batchedUpdates=Rl,Nt.unstable_renderSubtreeIntoContainer=function(i,o,l,u){if(!Do(l))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return _o(i,o,l,!1,u)},Nt.version="18.3.1-next-f1338f8080-20240426",Nt}var Hm;function Wg(){if(Hm)return Wl.exports;Hm=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(),Wl.exports=sj(),Wl.exports}var Km;function ij(){if(Km)return Fo;Km=1;var e=Wg();return Fo.createRoot=e.createRoot,Fo.hydrateRoot=e.hydrateRoot,Fo}var rj=ij(),y=tu();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`},wa=`${Zn}.prefs`,xa=e=>`${J.labelPrefix}:${e}`,nu=xa("map"),su=xa("hitl"),oj=e=>e==="task"||e==="execute",iu=xa("plan-only");function Hg(e){return/^[A-Za-z0-9_@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}const aj=e=>e.map(Hg).join(" "),cj=/^\d+\.\d+\.\d+(-[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function lj(e){return cj.test(e)?`${J.npm}@${e}`:J.npm}function Kg(e,t){return aj(["npx","-y",lj(e),...t])}const na=["research","prototype","junction","task","execute"],ss=[...na,"review"],$s="plan+execute",dj=e=>e.filter(t=>!t.archived),uj=["verifying","rework","blocked"],ru=["off","checks","checks+review","checks+review+human"],Gg=e=>ru.find(t=>t===e);function pi(e){return e.type==="junction"||e.type==="prototype"?"hitl":e.type==="research"?"afk":e.hitl?"hitl":"afk"}const hj=["task","execute"];function Vg(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(r=>[r.id,r]));return new Map(e.map(r=>[r.id,Vg(r,n,t)]))}const _e=200,He=56;function Gm(e,t="LR",n=$s){var be;const r=t==="LR"?330:124,a=t==="LR"?112:262,c=Cs(e,n),d=new Map(e.map(Z=>[Z.id,Z])),h=new Map,f=new Set,m=Z=>{if(h.has(Z))return h.get(Z);if(f.has(Z))return 0;f.add(Z);const se=d.get(Z),Ne=se&&se.blockedBy.length?1+Math.max(...se.blockedBy.filter(me=>d.has(me)).map(m),-1):0;return f.delete(Z),h.set(Z,Ne),Ne},g=e.filter(Z=>c.get(Z.id)!=="out-of-scope"),k=e.filter(Z=>c.get(Z.id)==="out-of-scope"),w=[];for(const Z of g)(w[be=m(Z.id)]??(w[be]=[])).push(Z);const b=[],S=new Map;let x=0;w.forEach(Z=>{Z&&(Z.sort((se,Ne)=>{const me=Se=>{const z=Se.blockedBy.map(Q=>S.get(Q)).filter(Q=>Q!==void 0);return z.length?z.reduce((Q,U)=>Q+U,0)/z.length:Se.createdAt/1e12};return me(se)-me(Ne)||se.createdAt-Ne.createdAt}),x=Math.max(x,Z.length),Z.forEach((se,Ne)=>S.set(se.id,Ne)))}),w.forEach((Z,se)=>{if(!Z)return;const Ne=(x-Z.length)*a/2;Z.forEach((me,Se)=>{const z=se*r,Q=Ne+Se*a;b.push({ticket:me,state:c.get(me.id),layer:se,x:t==="LR"?z:Q,y:t==="LR"?Q:z})})});const N=Math.max(w.length,1)*r-(r-(t==="LR"?_e:He)),P=Math.max(x,1)*a-(a-(t==="LR"?He:_e)),D=t==="LR"?N:P,M=t==="LR"?P:N,W=M+54,_=Math.max(1,Math.floor((D+24)/(_e+24)));k.forEach((Z,se)=>{b.push({ticket:Z,state:"out-of-scope",layer:-1,x:se%_*(_e+24),y:W+Math.floor(se/_)*(He+16)})});const Y=[],re=new Map(b.map(Z=>[Z.ticket.id,Z]));for(const Z of b)for(const se of Z.ticket.blockedBy){const Ne=re.get(se);Ne&&Y.push({from:Ne,to:Z})}const q=Math.ceil(k.length/_),ye=Math.max(D,Math.min(k.length,_)*(_e+24)-24),Ie=k.length?W+q*(He+16)-16:M;return{direction:t,nodes:b,edges:Y,width:ye,graphH:M,quarantineY:W,height:Ie,quarantineH:q*(He+16)+24}}const sa=["fast","balanced","strongest"],Vm="balanced",fj=[["*-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"]],qg=e=>sa.includes(e),ou={research:"fast",task:"balanced",execute:"balanced",junction:"strongest",prototype:"strongest",review:"strongest"};function mj(e,t){var a,c;const n=(c=(a=t.modelMatching)==null?void 0:a.tiers)==null?void 0:c[e.type],r=ou[e.type];return t.settingsUnconfirmed&&n?sa.indexOf(n)>=sa.indexOf(r)?n:r:n??r}function qm(e){return Object.fromEntries(ss.map(t=>[t,mj({type:t},e)]))}const pj=e=>e!=="__proto__"&&e!=="constructor"&&e!=="prototype",gj=64;function vj(e,t){const n=[];for(let r=0;r<e.length;r++){const a=e[r];if(a!=="*"&&!(a==="?"&&t))n.push({kind:"char",c:a});else if(a==="?")n.push({kind:"one"});else if(!t||e[r+1]!=="*")n.push({kind:t?"star":"deep"});else{const c=e[r+2]==="/";r+=c?2:1,n.push({kind:c?"dirs":"deep"})}}return kj(n)}function kj(e){const t=[];for(const n of e){const r=t.at(-1);(r==null?void 0:r.kind)==="dirs"&&n.kind==="dirs"||(r==null?void 0:r.kind)==="deep"&&(n.kind==="deep"||n.kind==="dirs")||((r==null?void 0:r.kind)==="dirs"&&n.kind==="deep"?t[t.length-1]=n:t.push(n))}return t}function yj({t:e,c:t,inText:n,next:r,cur:a,j:c}){switch(e.kind){case"char":return n&&t===e.c?r[c+1]:0;case"one":return n&&t!=="/"?r[c+1]:0;case"star":return r[c]||(n&&t!=="/"?a[c+1]:0);case"deep":return r[c]||(n?a[c+1]:0);case"dirs":return 0;default:return e}}function wj(e,t,n){const r=n.length,a=new Uint8Array(r+1);let c=0;for(let d=r;d>=0;d--){const h=d<r,f=h?n[d]:"";if(e.kind!=="dirs"){a[d]=yj({t:e,c:f,inText:h,next:t,cur:a,j:d});continue}f==="/"&&t[d+1]&&(c=1),a[d]=t[d]||c}return a}function Qg(e,t,n){const r=vj(e,n.segments);if(r.filter(c=>c.kind!=="char").length>gj)return!1;let a=new Uint8Array(t.length+1);a[t.length]=1;for(let c=r.length-1;c>=0;c--)a=wj(r[c],a,t);return a[0]===1}function Qm(e,t){return Qg(e.trim().toLowerCase(),t.trim().toLowerCase(),{segments:!1})}function xj(e,t={}){const n=e==null?void 0:e.trim();if(!n)return{tier:Vm,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])=>Qm(d,n));if(a)return{tier:a[1],model:n,source:"project",reason:`${n} is ${a[1]} in models.json`};const c=fj.find(([d])=>Qm(d,n));return c?{tier:c[1],model:n,source:"built-in",reason:`${n} is a ${c[1]} model`}:{tier:Vm,model:n,source:"unknown",reason:`${n} is not a known model, so it counts as balanced`}}const jj=["holding","challenged","invalidated","confirmed"],bj=e=>jj.includes(e),Sj=J.labelPrefix,Nd=" -->",Nj=7e4,Yg=e=>`<!-- ${Sj}:${e} `,$j=e=>JSON.stringify(e).replace(/--/g,"-\\u002d"),Cj=(e,t)=>`${Yg(e)}${t}${Nd}`;function Tj(e,t){const n=e.trimEnd();if(!n.endsWith(Nd))return;const r=Yg(t),a=n.lastIndexOf(r);if(!(a===-1||n.length-a>Nj))return{before:n.slice(0,a),payload:n.slice(a+r.length,-Nd.length)}}const Ej=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/,Aj=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]+/g,Rj=/\r\n|[\r\u0085\u2028\u2029]/g,Mj=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/g,Ij=e=>Ej.test(e),ws=e=>e.replace(Aj," ").trim(),Oj=e=>e.replace(Rj,`
41
+ `).replace(Mj,"");function ja(e,t){const n=new RegExp(`^\\\\*(?:${t})`);return Oj(e).trim().split(`
42
+ `).map(r=>n.test(r)?`\\${r}`:r).join(`
43
+ `)}function ia(e,t){const n=new RegExp(`^\\\\+(?:${t})`);return e.split(`
44
+ `).map(r=>n.test(r)?r.slice(1):r).join(`
45
+ `)}const Jg=J.labelPrefix,Lj=new RegExp(`<(\\\\*)!--(?=\\s*${Jg}:)`,"g"),Pj=new RegExp(`<\\\\(\\\\*)!--(?=\\s*${Jg}:)`,"g"),ba=e=>e.replace(Lj,"<\\$1!--"),oi=e=>e.replace(Pj,"<$1!--"),Xg="asm",Dj=/^-\s+(?:\[([a-z]+)\]\s+)?/,_j=1e3;function Bj(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,_j)}}:{},...e.decidedBy?{decidedBy:e.decidedBy}:{}};return`- [${e.status}] ${ba(ws(e.text))} ${Cj(Xg,$j(t))}`}function Fj(e){const t=e.map(zj);let n=Math.max(0,...t.map(r=>Wj(r.id)))+1;return t.map(r=>r.id?r:{...r,id:`S-${n++}`})}function zj(e){const t=Tj(e,Xg),n=t?t.before:e,r=n.match(Dj),a=r==null?void 0:r[1],c=oi(n.slice(r?r[0].length:0).trim()),d=Uj(t==null?void 0:t.payload);return{id:d.id??"",text:c,status:bj(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 Uj(e){if(!e)return{};try{const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function Wj(e){const t=e==null?void 0:e.match(/^S-(\d+)$/);return t?Number(t[1]):0}const Zg=[["destination","Destination"],["notes","Notes"],["assumptions","Assumptions"],["decisions","Decisions so far"],["unspecified","Not yet specified"],["outOfScope","Out of scope"]],Hj=Object.fromEntries(Zg),ev="##\\s",Ym=e=>ba(ja(e.trim(),ev)),Jm=e=>ia(oi(e),ev),Xm=e=>ba(ws(e)),Kj=/^-\s+(?:\[?([#A-Z0-9-]+)\]?:?\s+)?(.*)$/;function Gj(e){var r;const t=a=>a.length?a.map(c=>`- ${Xm(c)}`).join(`
46
+ `):"_None yet._",n=a=>a.length?a.map(c=>`- ${c.ticketKey?`${ws(c.ticketKey)}: `:""}${Xm(c.text)}`).join(`
47
+ `):"_None yet._";return[`## Destination
48
+
49
+ ${Ym(e.destination)}`,`## Notes
50
+
51
+ ${Ym(e.notes)||"_None yet._"}`,...(r=e.assumptions)!=null&&r.length?[`## Assumptions
52
+
53
+ ${e.assumptions.map(Bj).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 Vj(e){var r;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(),h=(c===-1?"":a.slice(c+1)).trim(),f=(r=Zg.find(([,k])=>k.toLowerCase()===d))==null?void 0:r[0];if(!f)continue;const m=/^_none yet\._$/i.test(h),g=m?[]:h.split(`
65
+ `).map(k=>k.trim()).filter(k=>k.startsWith("- "));f==="destination"?t.destination=Jm(h):f==="notes"?t.notes=m?"":Jm(h):f==="assumptions"?t.assumptions=Fj(g):f==="decisions"?t.decisions=g.map(k=>{const w=k.match(Kj);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 Sa={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"]},qj=(e,t)=>`${e[0].toUpperCase()}${e.slice(1)} ${t}/${Sa[e].length}`;async function Qj(e,t,n={}){var d,h,f;const r=Yj(t,t.mode??$s),a=await e.createMap({title:r.title,mode:r.mode,sections:r.sections,...r.verification?{verification:r.verification}:{}});await((d=n.onMapCreated)==null?void 0:d.call(n,a));const c=new Map;for(const m of r.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((h=n.onTicketCreated)==null?void 0:h.call(n,g,m.ref))}for(const m of r.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 Yj(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??[]])),r=a=>a.flatMap(c=>n.has(c)?r(n.get(c)):[c]);return{...e,mode:t,tickets:e.tickets.filter(a=>!n.has(a.ref)).map(a=>({...a,blockedBy:[...new Set(r(a.blockedBy??[]))]}))}}class Me extends Error{}function tv(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 Jj{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 Xj={frontier:"ready",blocked:"backlog",parked:"backlog",claimed:"working",verifying:"verifying",rework:"rework",held:"blocked",decided:"done","out-of-scope":"cancelled"};function Zj(e,t,n=$s){return Xj[Vg(e,t,n)]}const e0=["backlog","ready","working","verifying","rework","blocked"],cr=["agent","trail lead"],t0=[{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:e0,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"]}],n0=e=>t0.find(t=>t.event===e),s0=new Jj;function i0(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 r0(e,t,n,r){const{to:a,actor:c}=r,d=async h=>{(n.status??null)!==h&&await e.setMeta(t,n.id,{status:h})};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 Na(e,t,n,r){return s0.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=Zj(c,new Map(a.tickets.map(g=>[g.id,g])),a.map.mode);if(r.expect&&d!==r.expect)throw new Me(`${c.key} changed: it is ${d} now`);const h=n0(r.event);if(!h.from.includes(d))throw new Me(`${c.key} is ${d}; ${r.event} needs ${h.from.join(" or ")}`);if(!h.actors.includes(r.actorKind))throw new Me(`${r.event} is not for ${r.actorKind}s`);const f=i0(h,c,r.to);await r0(e,t,c,{to:f,actor:r.actor});try{await((m=r.journal)==null?void 0:m.append({v:1,kind:"transition",at:Date.now(),mapId:t,ticketId:n,ticketKey:c.key,event:r.event,from:d,to:f,actor:r.actor,actorKind:r.actorKind,...r.reason?{reason:r.reason}:{},...r.sessionId?{sessionId:r.sessionId}:{}}))}catch{}return{ticket:c,from:d,to:f}})}async function Zm(e,t,n,r){const{assignee:a}=r,c=await e.loadMap(t),d=c.tickets.find(g=>g.id===n);if(!d)throw new Me(`ticket ${n} not found`);tv(c.map);const h=Cs(c.tickets,c.map.mode).get(n);if(h!=="frontier"&&h!=="rework")throw new Me(`${d.key} is ${h}, not on the frontier`);await Na(e,t,n,{event:"claim",actor:a,actorKind:r.actorKind??"agent",reason:r.reason,sessionId:r.sessionId,journal:r.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 o0(e,t,n,r={}){const c=(await e.loadMap(t)).tickets.find(d=>d.id===n);if(!c)throw new Me(`ticket ${n} not found`);await Na(e,t,n,{event:"release",actor:r.actor??c.assignee??"trail lead",actorKind:r.actorKind??"agent",reason:r.reason,sessionId:r.sessionId,journal:r.journal})}const nv=e=>e==="lookout",a0=e=>e.via==="chat"?`in ${e.chatOf??"an agent"}'s chat`:void 0;function c0(e){return e.via?e.via==="chat"&&e.chatOf?{via:e.via,chatOf:e.chatOf}:{via:e.via}:{}}function sv(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||nv(n)||!t.ticketId)return;const r=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 ${r} is high risk: ${a}.`);if(await e.highRisk(t.mapId,t.ticketId))throw new Me(sv(r,n))}async function l0(e,t){var d;const{mapId:n,old:r,next:a}=t;await ra(e,{mapId:n,ticketId:r.ticketId,key:r.ticketKey??r.id}),a.ticketId&&a.ticketId!==r.ticketId&&await ra(e,{mapId:n,ticketId:a.ticketId,key:a.ticketKey});const c=e.via??(e.sourceKind==="slack"?"slack":void 0);if(c&&!nv(c)&&((d=r.risk)==null?void 0:d.level)==="high")throw new Me(sv(r.id,c))}async function au(e,t,n,r={}){if(await ra({...r.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(r.appendToTrail??!0){const c=await e.loadMap(t);await e.updateMapSections(t,{decisions:[...c.map.sections.decisions,{ticketId:a.ticketId,ticketKey:a.ticketKey,text:r.trailLine??a.summary}]})}return a}async function d0(e,t,n,{guard:r,...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 h={ticketId:d.ticketId,ticketKey:d.ticketKey,...a,question:a.question??d.question,supersedes:d.id};await l0({...r,sourceKind:a.source.kind},{mapId:t,old:d,next:h});const f=await e.createDecision(t,h);await e.markSuperseded(t,d.id,f.id);const 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 u0(e,t,n){await e.setMapMode(t,n)}function iv(e){return e==="plan-only"?na.filter(t=>t!=="execute"):na}function h0(e,t){if(!iv(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),f0=e=>e in ts,rv=" (unverified, from text)";function yr(e){return e.derived||e.decidedBy.endsWith(rv)?"unverified":e.postedBy?"teammate":e.source.kind==="agent"&&e.decidedBy!=="trail lead"&&!e.decidedBy.startsWith("slack:")?"agent":"human"}const ov=e=>e.postedBy?`posted by ${e.postedBy} in ${e.postedIn??"the tracker"}`:void 0,br=e=>e.supersededBy?"superseded":"active";function $a(e){const t=e.replace(/\s+/g," ").trim(),n=t.match(/^(.{20,180}?[.!?])(\s|$)/);return n?n[1]:t.slice(0,180)}function m0(e,t,n){var r;return{...n,id:e,mapId:t,decidedAt:n.decidedAt??Date.now(),summary:((r=n.summary)==null?void 0:r.trim())||$a(n.answer),alternatives:n.alternatives??[],rationale:n.rationale??"",participants:n.participants??[{id:n.decidedBy}],transcript:n.transcript??[]}}const p0=e=>Number(e.replace(/\D/g,""))||0;function g0(e,t){const n=new Map(e.map(d=>[d.id,d])),r=new Set;let a=n.get(t);for(;a!=null&&a.supersedes&&n.has(a.supersedes)&&!r.has(a.id);)r.add(a.id),a=n.get(a.supersedes);const c=[];r.clear();for(let d=a;d&&!r.has(d.id);d=d.supersededBy?n.get(d.supersededBy):void 0)r.add(d.id),c.push(d);return c}async function v0(e,t,n,r){var d,h;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({...r.guard,sourceKind:(h=(d=r.decision)==null?void 0:d.source)==null?void 0:h.kind},{mapId:t,ticketId:c.id,key:c.key}),r.transcript&&await e.comment(t,n,r.author,`**HITL transcript**
68
+
69
+ ${r.transcript}`),await e.comment(t,n,r.author,`**Resolution**
70
+
71
+ ${r.answer}`),await Na(e,t,n,{event:r.event??"complete",actor:r.actor??r.author,actorKind:r.actorKind??"agent",sessionId:r.sessionId,reason:r.reason,journal:r.journal,...r.event&&r.event!=="complete"?{to:"done"}:{}}),await au(e,t,k0(c,r),{trailLine:r.trailLine,guard:r.guard}),c}function k0(e,t){var r;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??$a(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}:{},...(r=n.assumes)!=null&&r.length?{assumes:n.assumes}:{}}}async function y0(e,t,n,r){const a=await e.loadMap(t);if(tv(a.map),!a.map.sections.unspecified.includes(n))throw new Me(`"${n}" is not in Not yet specified`);h0(a.map.mode,r.type);const c=await e.createTicket(t,{title:r.title??n,type:r.type,hitl:r.hitl,body:`${r.body??`Promoted from Not yet specified: ${n}`}
72
+
73
+ Part of trail ${a.map.key}.`});for(const h of r.blockedBy??[])await e.addBlocking(t,h,c.id);const d=await e.loadMap(t);return await e.updateMapSections(t,{unspecified:d.map.sections.unspecified.filter(h=>h!==n)}),c}async function w0(e,t,n,r){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} — ${r.reason}`]});return}const h=a.tickets.find(m=>m.id===n.ticketId);if(!h)throw new Me(`ticket ${n.ticketId} not found`);await e.comment(t,h.id,r.author,`**Ruled out of scope**
74
+
75
+ ${r.reason}`),await Na(e,t,h.id,{event:"cancel",actor:r.author,actorKind:r.actorKind??"agent",reason:r.reason,sessionId:r.sessionId,journal:r.journal}),await au(e,t,{ticketId:h.id,ticketKey:h.key,question:h.title,answer:`Out of scope: ${r.reason}`,decidedBy:r.author,source:r.source??{kind:"agent",label:r.author}},{appendToTrail:!1});const f=await e.loadMap(t);await e.updateMapSections(t,{outOfScope:[...f.map.sections.outOfScope,`${h.key} ${h.title} — ${r.reason}`]})}async function x0(e,t,n,r){n&&j0(n),await e.setMapMeta(t,{modelMatching:n&&b0(n),confirm:!0})}function j0(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(!ss.includes(t))throw new Me(`unknown ticket type "${t}"`);if(!qg(n))throw new Me(`"${t}" must be fast, balanced or strongest`)}}function b0(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 S0(e,t,n,r){await e.setMapArchived(t,n)}const av=Object.freeze({research:["architect"],junction:["architect"],prototype:["architect"],task:["qa","security"],execute:["qa","security"],review:["reviewer"]}),N0=(e,t)=>e.guidesByType?"trail":t?"team":"defaults";function cu(e){var c;const t=(c=e.guides)!=null&&c.length?new Set(e.guides):void 0,n=e.guidesByType??av,r=d=>!!e.guidesByType||!t||t.has(d);return{byType:Object.fromEntries(ss.map(d=>[d,[...new Set((n[d]??[]).filter(r))]])),source:N0(e,!!t)}}const cv=e=>[...new Set([...e.guide?[e.guide]:[],...e.guidesAdded??[]])];function $0(e,t){const n=new Set(t.guidesRemoved??[]),r=cu(e).byType[t.type]??[],a=r.map(c=>({id:c,via:"type"}));for(const c of cv(t))r.includes(c)||a.push({id:c,via:"ticket"});return a.filter(c=>!n.has(c.id))}function C0(e){return{async append(t){await fetch(`${e}/journal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}}}const T0=["off","observe","enforce"],lv=["check-guard","independent-review","diff-rules","flaky"],dv={"check-guard":"enforce","independent-review":"observe","diff-rules":"enforce",flaky:"enforce"},uv={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:{...dv},rules:[],github:{enabled:"auto",requiredChecks:[],pollSec:60}};new Set(Object.keys(uv));function E0(e,t){var n;return e?((n=e.gates)==null?void 0:n[t])??dv[t]:"off"}const A0=e=>e?`on ${e.slice(0,7)}`:"on the same code",R0=e=>`${e.name}${e.test?` (${e.test})`:""} ${e.failure==="timed out"?"timed out":"failed"} in ${e.failedIn}, then passed ${A0(e.head)} with no change`,M0=e=>e.map(R0).join("; "),lu=e=>{var t;return(e==null?void 0:e.result)==="pass"&&((t=e.flaky)==null?void 0:t.mode)==="enforce"},I0=3;function O0(e){const t=e.slice(0,I0).map(r=>r.text),n=e.length-t.length;return`${t.join("; ")}${n>0?`; and ${n} more`:""}`}const L0=2*6e4,Gl=e=>e<6e4?`${Math.round(e/1e3)}s`:`${Math.round(e/6e4)}m`;function P0(e,t){if(!e)return{tone:"unknown",label:"PR sync ?",title:"PR/CI sync state unavailable"};const n=e.repo?` · ${e.repo}`:"",r=e.lastOkAt?`last ok ${Gl(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
+ ${r}`}:e.state==="rate-limited"?{tone:"failed",label:"PR sync paused",title:`Rate limited${n}; retrying ${e.nextAt?`in ${Gl(Math.max(0,e.nextAt-t))}`:"later"}
77
+ ${r}`}:!e.lastOkAt||e.lastOkAt!==e.lastAttemptAt||e.nextAt!==void 0&&t>e.nextAt+L0?{tone:"stale",label:"PR sync stale",title:`No recent sync${n}
78
+ ${r}`}:{tone:"ok",label:`PR sync ${Gl(t-e.lastOkAt)}`,title:`PR/CI synced${n}, ${r}`}}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 D0=0;const Xo=(e="id")=>`${e}_${Date.now().toString(36)}${(D0++).toString(36)}`,$d=(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)}:{}}),hv=(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 _0(e,t,n){const r=()=>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 r()},step(c,d,h){const f=Sa[n][c-1];e.patchSession(t.id,{step:c,stepLabel:f,...h?{ticketId:h}:{}}),a({tag:qj(n,c),level:"step",text:d?`${f}: ${d}`:f,ticketId:h??r().ticketId})},log(c,d="info",h){a({level:d,text:c,ticketId:r().ticketId,...h?{kind:h}:{}})},say(c){e.chat({sessionId:t.id,ticketId:r().ticketId,from:"agent",author:t.agent,text:c})},ask(c,d,h){var m;const f={id:Xo("q"),sessionId:t.id,mapId:t.mapId,ticketId:r().ticketId,agent:t.agent,text:c,suggestions:d,at:Date.now(),...h!=null&&h.urgency?{urgency:h.urgency}:{},...(m=h==null?void 0:h.blocks)!=null&&m.length?{blocks:h.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,h){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:h==null?void 0:h.signal,...h!=null&&h.kind?{kind:h.kind}:{}})},bindMap(c){var h;const d=r().usage;d&&(e.addMapUsage(c,d),(h=e.ledger())==null||h.add(c,d,t.id)),e.patchSession(t.id,{mapId:c})},usage(c){var f;const d=r().mapId;(f=e.ledger())==null||f.add(d,c,t.id),e.addMapUsage(d,c);const h=r().usage;e.patchSession(t.id,{usage:{...$d(h,c),source:c.source??(h==null?void 0:h.source)}})},setUsage(c){var g;const d=r().usage,h=hv(c,d);if(!h.inputTokens&&!h.outputTokens&&!h.costUsd&&!h.cachedInputTokens&&(d==null?void 0:d.source)===c.source&&`${d==null?void 0:d.models}`==`${c.models}`)return;const m=r().mapId;(h.inputTokens>0||h.outputTokens>0||h.costUsd>0)&&((g=e.ledger())==null||g.add(m,h,t.id)),e.addMapUsage(m,h),e.patchSession(t.id,{usage:c})},setModel(c,d){const h=r();h.model===c&&h.tier===d||e.patchSession(t.id,{model:c,tier:d})}}}class B0{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(r=>r.sessionId===t).length&&this.set({pending:this.state.pending.filter(r=>r.sessionId!==t)})},awaitAnswer:t=>new Promise(n=>this.resolvers.set(t,n)),addMapUsage:(t,n)=>{this.state={...this.state,usageByMap:{...this.state.usageByMap,[t]:$d(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(r=>r.id===t?{...r,...n}:r)})}chat(t){this.set({chats:[...this.state.chats,{id:Xo("m"),at:Date.now(),...t}].slice(-600)})}answer(t,n,r,a){var g;const c=this.state.pending.find(k=>k.id===t),d=this.resolvers.get(t),h=!!c&&this.remote.has(c.sessionId)&&!!this.remoteAnswer;if(!c||!d&&!h)return!1;this.resolvers.delete(t);const f=c0(a),m=a.by?{by:a.by}:{};return this.chat({sessionId:c.sessionId,ticketId:c.ticketId,from:"human",author:r,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:r,level:"ok",kind:"answered",ticketId:c.ticketId,sessionId:c.sessionId,text:`Answered ${c.agent}`}),d?d(n):this.remoteAnswer(c,n,r),!0}syncRemote(t){var m;const{session:n}=t,r=n.id;if(!this.remote.has(r)&&this.state.sessions.some(g=>g.id===r))return;const a=this.remote.get(r);this.remote.set(r,n.mapId?n.usage:a);let c=this.state.usageByMap;if(n.usage&&n.mapId){const g=hv(n.usage,a);(g.inputTokens||g.outputTokens||g.costUsd)&&(c={...c,[n.mapId]:$d(c[n.mapId],g)}),(m=this.ledger)==null||m.addTotal(n.mapId,r,n.usage)}const d=g=>g.filter(k=>k.sessionId!==r),h=new Set(this.state.answered.map(g=>g.id)),f=this.state.sessions.some(g=>g.id===r)?this.state.sessions.map(g=>g.id===r?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=>!h.has(g.id))].sort((g,k)=>g.answeredAt-k.answeredAt).slice(-200),feed:[...this.state.feed.filter(g=>g.sessionId!==r),...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:Sa[t.mode].length,stepLabel:"BOOT",status:"running",startedAt:Date.now()};this.set({sessions:[...this.state.sessions,n].slice(-24)});const r=_0(this.host,n,t.mode);return this.push({source:"session",sessionId:n.id,agent:n.agent,level:"info",text:`Session opened · ${t.mode}`}),r}}function F0(e,t){const n=r=>{var a;return((a=t(r))==null?void 0:a.key)??r};switch(e.kind){case"map.created":return{source:"tracker",level:"ok",text:`Trail created · label ${nu}`};case"map.updated":return{source:"tracker",level:"info",text:`Trail updated${e.section?` · ${Hj[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 z0=new Set(["createMap","setMapMode","setMapArchived","setMapMeta","updateMapSections","createTicket","addBlocking","removeBlocking","editTicket","reopen","assign","comment","close","setMeta","createDecision","markSuperseded"]),U0=5*6e4;function W0(e){let t={status:"idle",inflight:0,writes:0,errors:0,events:[]};const n=new di,r=c=>{t={...t,...c},n.emit(t)};return e.subscribe(c=>{const d=c.at-U0;r({events:[...t.events.filter(h=>h.at>=d),{at:c.at,external:c.kind==="external.changed"||"external"in c&&!!c.external}]})}),{adapter:new Proxy(e,{get(c,d,h){const f=Reflect.get(c,d,h);return typeof f!="function"?f:z0.has(d)?async(...m)=>{const g=Date.now();r({inflight:t.inflight+1,status:"syncing"});try{const k=await f.apply(c,m),w=t.inflight-1;return r({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 r({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 fv(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 H0(e){const t=fv(e);return{decided:t.decided,total:t.total-t["out-of-scope"]}}function K0(e){const t=new Map(e.tickets.filter(d=>d.state==="open").map(d=>[d.id,d])),n=new Map,r=new Set,a=d=>{if(n.has(d))return n.get(d);if(r.has(d))return[];r.add(d);const h=t.get(d);let f=[];for(const g of h.blockedBy)if(t.has(g)){const k=a(g);k.length>f.length&&(f=k)}r.delete(d);const m=[...f,h];return n.set(d,m),m};let c=[];for(const d of t.keys()){const h=a(d);h.length>c.length&&(c=h)}return c}function G0(e){return na.map(t=>{const n=e.tickets.filter(r=>r.type===t);return{type:t,open:n.filter(r=>r.state==="open").length,closed:n.filter(r=>r.state==="closed").length}}).filter(t=>t.open+t.closed>0)}function V0(e,t){const n=e.pending.filter(a=>!0),r=e.answered.filter(a=>!0);return{open:n.length,oldestAt:n.length?Math.min(...n.map(a=>a.at)):void 0,answered:r.length,avgWaitMs:r.length?r.reduce((a,c)=>a+(c.answeredAt-c.askedAt),0)/r.length:void 0}}function mv(e,t){return t&&e.usageByMap[t]||{inputTokens:0,outputTokens:0,costUsd:0}}const q0=e=>e.usage?e.usage.inputTokens+e.usage.outputTokens:0,pv={"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 gv(e,t){var r;const n=new Set;for(const a of e.sessions)t&&a.mapId===t&&((r=a.usage)!=null&&r.source)&&n.add(a.usage.source);return[...n].sort()}const Vl=e=>e===1?"1 ticket":`${e} tickets`,Q0=e=>e.charAt(0).toLowerCase()+e.slice(1);function ep(e){return e.kind==="passed"?`verified together on ${e.branch??"main"} at ${e.commit.slice(0,7)}`:Q0(e.reason)}function Y0(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:`${Vl(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 r=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:r,together:a,reason:`All ${Vl(r)} verified · ${ep(a)}`};const d=c.length===r?"none verified":`${c.length} not verified`,h=[`${Vl(r)} done`,...c.length?[d]:[],ep(a)];return{kind:"unverified",done:r,unverified:c,together:a,reason:h.join(" · ")}}function J0(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 X0(e,t){const n=new Set(t.map(a=>a.ticketId).filter(Boolean)),r=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)??"",h=(c==null?void 0:c.author)??a.assignee??"unknown",f=a.comments.find(k=>k.body.startsWith("**HITL transcript**")),m=f?J0(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:$a(d),alternatives:[],rationale:"",decidedBy:`${h}${rv}`,decidedAt:a.closedAt??(c==null?void 0:c.createdAt)??a.updatedAt,participants:[...new Set([h,...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,...r].sort((a,c)=>c.decidedAt-a.decidedAt)}function Z0(e,t){var r;const n=(r=t.query)==null?void 0:r.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 eb(e,t=Date.now()){const n=Object.fromEntries(oa.map(d=>[d,0]));let r=0,a=0,c=0;for(const d of e){n[d.source.kind]++,d.supersededBy&&r++,t-d.decidedAt<864e5&&a++;const h=yr(d);(h==="human"||h==="agent"&&d.transcript.some(f=>f.from==="human"))&&c++}return{total:e.length,active:e.length-r,superseded:r,last24h:a,human:c,bySource:n}}function Ca(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!t)return{front:{},body:e};const n={};for(const r of t[1].split(`
80
+ `)){const a=r.indexOf(":");if(a<0)continue;const c=r.slice(0,a).trim(),d=r.slice(a+1).trim();pj(c)&&(n[c]=d.startsWith("[")?sb(d.slice(1,-1)).map(np).filter(Boolean):np(d))}return{front:n,body:t[2]}}const tb=e=>e===""||/^[\s#&*!|>'"%@`[\]{},?:-]|[:#]\s|\s$|,|["\\[\]]/.test(e)||Ij(e)||/^(true|false|null|~|\d[\d.e+-]*)$/i.test(e),nb=e=>JSON.stringify(e).replace(/[\u007f\u0085\u2028\u2029]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),tp=e=>tb(e)?nb(e):e;function np(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 sb(e){const t=[];let n="",r=!1,a=!1;for(const c of e)c==='"'&&!a&&(r=!r),a=r&&c==="\\"&&!a,c===","&&!r?(t.push(n.trim()),n=""):n+=c;return n.trim()&&t.push(n.trim()),t}function ib(e){if(!/^[\w-]+$/.test(e))throw new Error(`invalid frontmatter key: ${JSON.stringify(e)}`);return e}function du(e,t){return`---
81
+ ${Object.entries(e).map(([r,a])=>`${ib(r)}: ${Array.isArray(a)?`[${a.map(tp).join(", ")}]`:tp(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(),vv=["schema","breaking-api","auth-permissions","billing","data-deletion","product-behaviour","dependencies"],kv=["low","medium","high"],rb=e=>vv.includes(e),ob=e=>kv.includes(e);function ab(e){return e?{risk:e.level,...e.category?{risk_category:e.category}:{},risk_reason:e.reason}:{}}function cb(e){const t=ke(e.risk);if(!ob(t))return{};const n=ke(e.risk_category);return{risk:{level:t,...rb(n)?{category:n}:{},reason:ke(e.risk_reason)}}}const yv=["Question","Decision","Summary","Alternatives","Rationale","Transcript"],uu=`## (?:${yv.join("|")})\\s*$`,wv=`${uu}|### `,zo=e=>ja(e.trim(),uu),lb=e=>e.name?`${e.id}|${e.name}`:e.id,db=e=>{const t=e.indexOf("|");return t<0?{id:e}:{id:e.slice(0,t),name:e.slice(t+1)}};function xv(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:ws(e.decidedByName).slice(0,100)}:{},decided_at:fn(e.decidedAt),participants:e.participants.map(lb),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,h])=>`${d}=${h}`)}:{},...e.supersedes?{supersedes:e.supersedes}:{},...e.supersededBy?{superseded_by:e.supersededBy}:{},...ab(e.risk),...(c=e.assumes)!=null&&c.length?{assumes:e.assumes}:{}},n=d=>d.length?d.map(h=>`- ${ws(h)}`).join(`
87
+ `):"_None._",r=e.transcript.length?e.transcript.map(d=>`### ${ws(d.author)} · ${d.from} @ ${fn(d.at)}
88
+
89
+ ${ja(d.text.trim(),wv)}`).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
+ ${r}`].join(`
104
+
105
+ `);return du(t,a)}function Cd(e){const{front:t,body:n}=Ca(e),r={},a=new RegExp(`^## (${yv.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,uu);r[S]=/^_none\._$/i.test(b)?"":x});const d=(r.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(),wv)}}),h=ke(t.source),f=mt(t.source_meta),m={kind:f0(h)?h:"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=r.Decision??"";return{id:ke(t.id),mapId:ke(t.trail),ticketId:ke(t.ticket)||void 0,ticketKey:ke(t.ticket_key)||void 0,question:r.Question??"",answer:g,summary:r.Summary||$a(g),alternatives:(r.Alternatives??"").split(`
107
+ `).map(k=>k.trim()).filter(k=>k.startsWith("- ")).map(k=>k.slice(2)),rationale:r.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(db),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,...cb(t)}}function ub(e){return e.url?` · [${e.label??"link"}](${e.url})`:e.label?` · ${e.label}`:""}function hb(e,t,n={}){const r=[`# ${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 h=t[c];r.push("",`## Trail ${h?`${h.key} ${h.title}`:c}`);for(const f of d){const m=ts[f.source.kind].label;r.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}${ub(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 r.join(`
110
+ `)+`
111
+ `}function Td(e,t,n){try{const r=e.get(t);return r?JSON.parse(r):n}catch{return n}}class sp{constructor(t,n="presence"){oe(this,"seen");this.store=t,this.key=n,this.seen=Td(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 r=!1;for(const a of t)(this.seen[a]??0)>=n||(this.seen[a]=n,r=!0);r&&this.store.set(this.key,JSON.stringify(this.seen))}}const ql=5*6e4,fb=14*864e5;class ip{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=Td(t,n,{}),this.totals=Td(t,`${n}.totals`,{})}addTotal(t,n,r,a=Date.now()){const c=this.totals[n],d={inputTokens:r.inputTokens-((c==null?void 0:c.inputTokens)??0),outputTokens:r.outputTokens-((c==null?void 0:c.outputTokens)??0),costUsd:r.costUsd-((c==null?void 0:c.costUsd)??0)};this.totals[n]={...r,at:a},d.inputTokens>0||d.outputTokens>0||d.costUsd>0?this.add(t,d,n,a):this.save()}add(t,n,r,a=Date.now()){var f;if(!t)return;const c=Math.floor(a/ql)*ql,d=(f=this.buckets)[t]??(f[t]=[]);let h=d.find(m=>m.at===c);h||(h={at:c,i:0,o:0,c:0,s:[]},d.push(h),d.sort((m,g)=>m.at-g.at)),h.i+=n.inputTokens,h.o+=n.outputTokens,h.c+=n.costUsd,h.s.includes(r)||h.s.push(r),this.save()}since(t,n){const r={inputTokens:0,outputTokens:0,costUsd:0,sessions:0},a=new Set;for(const c of this.buckets[t]??[])c.at+ql<=n||(r.inputTokens+=c.i,r.outputTokens+=c.o,r.costUsd+=c.c,c.s.forEach(d=>a.add(d)));return r.sessions=a.size,r}save(){this.dirty=!0,!this.timer&&(this.timer=setTimeout(()=>{if(this.timer=void 0,!this.dirty)return;this.dirty=!1;const t=Date.now()-fb;for(const n of Object.keys(this.buckets))this.buckets[n]=this.buckets[n].filter(r=>r.at>=t);for(const[n,r]of Object.entries(this.totals))r.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 mb(e){const t=e.now??Date.now(),n=e.snaps.map(d=>{var re;const h=d.map.id,f=e.since(h),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===h),b=pb(e.activity.pending.filter(q=>q.mapId===h),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(ye=>k.get(ye)).filter(ye=>!!ye&&x(ye))})).filter(q=>q.on.length),N=e.decisions.filter(q=>q.mapId===h&&m(q.decidedAt)).sort((q,ye)=>ye.decidedAt-q.decidedAt),P=d.tickets.filter(q=>q.state==="closed"&&m(q.closedAt)).sort((q,ye)=>(q.closedAt??0)-(ye.closedAt??0)),D=P.filter(q=>q.closeReason==="completed"),M=P.filter(q=>q.closeReason==="not_planned"),W=d.tickets.filter(q=>m(q.createdAt)),_=((re=e.ledger)==null?void 0:re.since(h,f))??{inputTokens:0,outputTokens:0,costUsd:0,sessions:0},Y=e.activity.sessions.filter(q=>q.mapId===h&&q.status==="running");return{mapId:h,key:d.map.key,title:d.map.title,since:f,done:D,ruledOut:M,opened:W,blocked:C,waiting:b,needsYou:w,decisions:N,agentDecisions:N.filter(q=>yr(q)==="agent"),usage:_,active:Y,changed:!!(P.length||W.length||N.length||b.some(q=>m(q.at))||_.costUsd>0)}}),r=n.filter(d=>d.changed||d.waiting.length).sort((d,h)=>+(h.mapId===e.currentMapId)-+(d.mapId===e.currentMapId)),a=d=>r.reduce((h,f)=>h+f[d].length,0),c=r.flatMap(d=>d.waiting).reduce((d,h)=>d===void 0||h.at<d?h.at:d,void 0);return{since:r.length?Math.min(...r.map(d=>d.since)):t,now:t,trails:r,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:r.reduce((d,h)=>({inputTokens:d.inputTokens+h.usage.inputTokens,outputTokens:d.outputTokens+h.usage.outputTokens,costUsd:d.costUsd+h.usage.costUsd,sessions:d.sessions+h.usage.sessions}),{inputTokens:0,outputTokens:0,costUsd:0,sessions:0}),active:a("active")},changed:n.some(d=>d.changed)}}function pb(e,t){const n=new Map(t.filter(a=>a.kind==="question").map((a,c)=>[a.ref,c])),r=a=>n.get(a.id)??Number.MAX_SAFE_INTEGER;return[...e].sort((a,c)=>r(a)-r(c)||a.at-c.at)}const fr=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function gb(e){return e.trails.flatMap(t=>{const n=new Set(t.waiting.map(r=>r.ticketId));return t.blocked.filter(r=>r.on.some(a=>n.has(a.id)))})}function vb(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 kb(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=vb(gb(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 yb=e=>{if(!e.length)return;const t=[...e].sort((r,a)=>r-a),n=Math.floor(t.length/2);return t.length%2?t[n]:Math.round((t[n-1]+t[n])/2)};function wb(e){return e.state==="open"?"open":e.closeReason==="not_planned"?"cancelled":"done"}function jv({snap:e,journal:t,answered:n,usage:r}){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 h=e.tickets.filter(x=>x.type!=="review").map(x=>{var M;const C=d.get(x.id)??[],N=wb(x),P=(M=C.find(W=>W.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(W=>W.to==="rework").length,reviews:{passed:C.filter(W=>W.event==="review.pass").length,failed:C.filter(W=>W.event==="review.fail").length,needsHuman:C.filter(W=>W.event==="review.needs_human").length},operatorActions:C.filter(W=>W.actorKind==="trail lead").length}}),f=h.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=>h.reduce((C,N)=>C+x(N),0),S=(r==null?void 0:r.costUsd)??0;return{mapId:a,tickets:h,done:f.length,cancelled:h.filter(x=>x.outcome==="cancelled").length,open:h.filter(x=>x.outcome==="open").length,trailLeadMs:m&&m>=e.map.createdAt?m-e.map.createdAt:void 0,medianLeadMs:yb(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:h.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:((r==null?void 0:r.inputTokens)??0)+((r==null?void 0:r.outputTokens)??0),perVerifiedTicketUsd:f.length&&S?Math.round(S/f.length*1e4)/1e4:void 0}}}const Ql=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 rp=e=>e===void 0?"—":`$${e.toFixed(e<1?4:2)}`;function xb(e,t,n=Date.now()){const r=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 | ${r.total} (${r.answers} answers, ${r.operatorActions} operator actions, ${r.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 | ${rp(e.spend.costUsd)} · ${e.spend.tokens.toLocaleString("en-US")} tokens |`,`| Cost per verified ticket | ${rp(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 hu=5,bv=1.5,jb=15,Uo=e=>Math.round(e*100);function bb(e){const t=e.filter(d=>d.findings.raised>=hu).sort((d,h)=>h.findings.upheld/h.findings.raised-d.findings.upheld/d.findings.raised||d.key.localeCompare(h.key));if(t.length<2)return[];const[n,r]=[t[0],t[t.length-1]],[a,c]=[n.findings.upheld/n.findings.raised,r.findings.upheld/r.findings.raised];return Uo(a)-Uo(c)<jb?[]:[{id:"review-findings",text:`${n.key} review findings upheld ${Uo(a)}% vs ${r.key} ${Uo(c)}%`,because:`${n.findings.upheld} of ${n.findings.raised} and ${r.findings.upheld} of ${r.findings.raised} failed reviews stood; a finding is overruled when you accept the work anyway`}]}function Sb(e){const t=c=>c.reworkCycles/c.tickets,n=e.filter(c=>c.tickets>=hu).sort((c,d)=>t(c)-t(d)||c.key.localeCompare(d.key));if(n.length<2)return[];const[r,a]=[n[0],n[n.length-1]];return t(a)-t(r)<.2||t(a)<t(r)*bv?[]:[{id:"rework",text:`${a.key} work goes back to rework more: ${t(a).toFixed(1)} times per ticket vs ${r.key} ${t(r).toFixed(1)}`,because:`${a.reworkCycles} cycles on ${a.tickets} tickets, and ${r.reworkCycles} on ${r.tickets}`}]}function Nb(e,t){const n=d=>d.medianLeadMs??0,r=t.filter(d=>d.done>=hu&&d.medianLeadMs!==void 0).sort((d,h)=>n(d)-n(h)||d.key.localeCompare(h.key));if(r.length<2)return[];const[a,c]=[r[0],r[r.length-1]];return n(c)<n(a)*bv?[]:[{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 $b(e){const t=Object.keys(e.byTypeAndVendor).sort();return[...bb(e.byVendor),...Sb(e.byVendor),...t.flatMap(n=>Nb(n,e.byTypeAndVendor[n]))]}const Cb=e=>{if(!e.length)return;const t=[...e].sort((r,a)=>r-a),n=Math.floor(t.length/2);return t.length%2?t[n]:Math.round((t[n-1]+t[n])/2)},Sv=e=>{var t;return(t=e.filter(n=>n.event==="claim"&&n.actorKind==="agent").at(-1))==null?void 0:t.actor},Ed=(e,t,n)=>e.filter(r=>r.mapId===t&&r.ticketId===n).sort((r,a)=>r.at-a.at);function Tb(e,t){return e.tickets.flatMap(n=>{var k;if(n.type!=="review"||!n.reviewOf)return[];const r=Ed(t,e.map.id,n.id),a=Sv(r);if(!a)return[];const c=((k=r.filter(w=>w.event==="claim").at(-1))==null?void 0:k.at)??0,d=Ed(t,e.map.id,n.reviewOf),h=d.findIndex(w=>w.at>=c&&w.event.startsWith("review."));if(h<0||d[h].event!=="review.fail")return[];const f=d.slice(h+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 Eb(e,t){var r;const n=(r=e.tickets.find(a=>a.id===t))==null?void 0:r.assignee;return n&&/^[a-z]+-\d+$/.test(n)?n:void 0}function Nv(e,t){const n=a=>t.reduce((c,{ticket:d})=>c+a(d),0),r=a=>t.filter(c=>c.ticket.outcome===a).length;return{key:e,tickets:t.length,done:r("done"),cancelled:r("cancelled"),open:r("open"),medianLeadMs:Cb(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 r of e){const a=t(r);a&&n.set(a,[...n.get(a)??[],r])}return new Map([...n].map(([r,a])=>[r,Nv(r,a)]))}const Ad=(e,t)=>{const n=e.get(t)??Nv(t,[]);return e.set(t,n),n};function op(e,t,n){const r=Ad(e,t);r.findings.raised+=1,n&&(r.findings.upheld+=1)}const Ho=e=>[...e.values()].sort((t,n)=>n.tickets-t.tickets||t.key.localeCompare(n.key));function $v(e){const t=e.flatMap(({snap:m,journal:g,answered:k,usage:w})=>jv({snap:m,journal:g,answered:k,usage:w}).tickets.map(b=>({ticket:b,agent:Sv(Ed(g,m.map.id,b.id))??Eb(m,b.id)}))),n=m=>m.agent?Ql(m.agent):void 0,r=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),Ad(r,w.agent).answers+=1,Ad(a,Ql(w.agent)).answers+=1)}for(const w of Tb(m,g))op(r,w.reviewer,w.upheld),op(a,Ql(w.reviewer),w.upheld)}const h=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(r),byVendor:Ho(a),byType:Ho(c),byTypeAndVendor:h};return{...f,recommendations:$b(f)}}const Cv=["research","junction","review"],Ab={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
+ `)},Rb=[["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(Rb);function Mb(e,t){const n=new Set(e.map(r=>r.source).filter(Boolean));return t.filter(r=>!n.has(r))}const Ib=["architecture","convention","gotcha","dead-end","glossary","fact"],Tv=["business-rule","product-decision","persona","ux-principle","pricing"],Ob=[...Ib,...Tv],Lb=e=>e.status==="confirmed"||e.status==="assumption";function Pb(e,t){return Qg(e,t.replace(/^\.\//,""),{segments:!0})}const Db={"business-rule":3,convention:3,"product-decision":2,architecture:2,gotcha:2,"dead-end":2,"ux-principle":2},_b=["business-rule","ux-principle","convention"],ap=600,Bb=e=>`flagged as possibly outdated by ${e}; the human is reviewing it`,Fb=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(" ")),cp=e=>new Set((e.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(t=>!Fb.has(t)));function Ev(e,t,n=4e3,r=()=>[]){const a=t.ticket?cp(`${t.ticket.title} ${t.ticket.body}`):new Set,c=new Set((t.tags??[]).map(m=>m.toLowerCase())),d=e.filter(Lb).map(m=>{const g=[];let k=Db[m.kind]??1;for(const S of m.scope){const x=t.paths.find(C=>Pb(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=[...cp(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&&Tv.includes(m.kind)&&(k+=8,g.push("product context for discovery")),!g.length&&_b.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})),h=[];let f=0;for(const{e:m,why:g}of d){const k=m.body.length>ap?`${m.body.slice(0,ap)}…`:m.body;if(f+k.length>n&&h.length)break;f+=k.length;const w=r(m);h.push({id:m.id,title:m.title,kind:m.kind,status:m.status,body:k,why:g,...w.length?{mayBeOutdated:w}:{},...m.flag?{flagged:Bb(m.flag.by)}:{}})}return h}const zb=new RegExp("`([^`\\s]+/[^`\\s]+)`|(?:^|[\\s(])/?((?:[\\w.-]+/)+[\\w.-]+)","gm");function Av(e){const t=new Set;for(const n of e.matchAll(zb))t.add((n[1]??n[2]).replace(/^\.?\//,"").replace(/[.,;:]+$/,""));return[...t]}const Ub=[{level:"high",label:"High risk"},{level:"medium",label:"Medium risk"},{level:"low",label:"Low risk"},{level:"none",label:"No category"}];function Wb(e){return Ub.map(t=>({...t,decisions:e.filter(n=>{var r;return(((r=n.risk)==null?void 0:r.level)??"none")===t.level})})).filter(t=>t.decisions.length)}const Hb=1/3;function Ts(e,t=Date.now()){const n=e.expiresAt-t;return n<=0?"expired":n<=e.ttlMs*Hb?"stalled":"live"}function Kb(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 Gb=e=>e.urgency==="fyi"||e.kind==="policy"||e.kind==="escape";function Vb(e){const t=e.filter(([n,r])=>ss.includes(n)&&qg(r));return Object.fromEntries(t)}const lp=e=>Number(e.slice(0,2))*60+Number(e.slice(3,5));function qb(e,t){const n=new Date(t),r=n.getHours()*60+n.getMinutes(),a=lp(e.from),c=lp(e.to),d=c<=a;if(!(d?r>=a||r<c:r>=a&&r<c))return!1;if(!e.days)return!0;const f=d&&r<c,m=(n.getDay()+(f?6:0))%7;return e.days.includes(m)}function Qb(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 Yb(e,t){const n=e.focusUntil??0;if(n>t)return{kind:"manual",until:n};if(!e.focus||!qb(e.focus,t))return{kind:"off"};const r=Qb(e.focus,t);return(e.focusOffUntil??0)>t?{kind:"paused",until:r}:{kind:"hours",until:r}}function Jb(e,t,n){const r={...e};switch(delete r.focusUntil,delete r.focusOffUntil,t.kind){case"for":return{...r,focusUntil:n+t.minutes*6e4};case"resume":return r;case"end":{const a=Yb(r,n);return a.kind==="hours"?{...r,focusOffUntil:a.until}:r}default:return t}}const Xb=e=>({id:e.id,key:e.key,title:e.title,...e.archived?{archived:!0}:{}});function Zb(e,t){var r;const n={...e};return t.verification===null?delete n.verification:t.verification&&(n.verification=t.verification),t.guides===null||((r=t.guides)==null?void 0:r.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 eS(e,t,n){const r=Date.now();return{id:e,key:t,...n,state:"open",blockedBy:[],comments:[],createdAt:r,updatedAt:r}}const tS=(e,t)=>({...e,blockedBy:e.blockedBy.filter(n=>n!==t)}),nS=(e,t)=>{var n;return{...e,...(n=t.title)!=null&&n.trim()?{title:t.title.trim()}:{},...t.body!==void 0?{body:t.body}:{}}};function sS(e){const{closeReason:t,closedAt:n,...r}=e;return{...r,state:"open"}}const iS=["status","verification","checks","reviewOf","guide","guidesAdded","guidesRemoved"];function rS(e,t){const n={...e};for(const r of iS)t[r]!==void 0&&(t[r]===null?delete n[r]:n[r]=t[r]);return t.confirm&&delete n.settingsUnconfirmed,n}function oS(e,t){const n={...e};return t?n.archived=!0:delete n.archived,n}async function Rv(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)}),r=await Promise.all(t.filter(a=>a.endsWith("/map.md")).map(async a=>Number(ke(Ca(await e.read(a)).front.key).replace(/\D/g,""))||0));return Math.max(0,...n,...r)+1}const Mv="### [^\\n]* @ \\d{4}-\\d\\d-\\d\\dT",Iv=`## Comments\\s*$|${Mv}`,Ov=`<!-- ${J.labelPrefix}:comments -->`,aS=new RegExp(`^## Comments[ \\t]*\\n${Ov}[ \\t]*$`,"m"),cS=new RegExp(`^(?=${Mv})### `,"m"),fu=2,Lv=e=>ba(ja(e,Iv)),dp=e=>ia(oi(e),Iv);function lS(e,t){const n=(t>=fu?aS:/^## Comments\s*$/m).exec(e);return n?[e.slice(0,n.index),e.slice(n.index+n[0].length)]:[e,""]}function up(e){const{front:t,body:n}=Ca(e),r=Number(ke(t.format))||1,[a,c]=lS(n,r),d=c.split(r>=fu?cS:/^### /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:dp(g.slice(w+1).trim())}}),h=ke(t.close_reason),f=uj.find(g=>g===ke(t.status)),m=Gg(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(su)||void 0,state:ke(t.state)==="closed"?"closed":"open",closeReason:h==="completed"||h==="not_planned"?h: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:dp(a.trim()),comments:d,createdAt:ai(t.created),updatedAt:ai(t.updated),closedAt:ai(t.closed)||void 0}}function Pv(e){var r,a;const t={id:e.id,format:String(fu),title:e.title,type:e.type,labels:[xa(e.type),...oj(e.type)&&e.hitl?[su]:[]],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}:{},...(r=e.guidesAdded)!=null&&r.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
+ ${Ov}
118
+
119
+ ${e.comments.map(dS).join(`
120
+
121
+ `)}`:"";return du(t,Lv(e.body)+n)}function dS(e){return`### ${ws(e.author)} @ ${fn(e.createdAt)}
122
+
123
+ ${Lv(e.body)}`}async function uS(e,t,n){for(let r=0;;r++){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(r>=50)throw new Error(`could not allocate ${a.path}`)}}async function hS(e,t,n){const r=await Rv(e),a=eS(String(r),`#${r}`,n);return{path:`${t}/tickets/${a.id}.md`,text:Pv({...a,updatedAt:Date.now()}),value:a}}async function fS(e,t,n){const r=(await e.list()).filter(d=>d.includes("/decisions/")),a=Math.max(0,...r.map(d=>p0(d.split("/").pop())))+1,c=m0(`D-${a}`,t,n);return{path:`${t}/decisions/${c.id}.md`,text:xv(c),value:c}}const mS=/^([^/]+)\/decisions\/([^/]+)\.md$/,pS=(e,t)=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40)||`map-${t}`,Dv=/^[A-Za-z0-9][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)*$/;function ys(e){if(typeof e!="string"||e.length>128||!Dv.test(e))throw new Error(`not a valid id: ${JSON.stringify(e)}`);return e}const gS=e=>{const t=e.match(/^[^/]+\/tickets\/([^/]+)\.md$/);return!!t&&Dv.test(t[1])};class vS{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,r){this.seen.set(t,{text:n,supersededBy:r})}queue(t){const n=t.split("/")[0],r=this.pending.get(n)??{paths:new Set,timer:setTimeout(()=>void this.flush(n),250)};r.paths.add(t),this.pending.set(n,r)}async flush(t){const n=this.pending.get(t);if(this.pending.delete(t),!n)return;const r=[...n.paths].filter(d=>mS.test(d)),a=[];for(const d of r){const h=await this.read(d).catch(()=>""),f=this.seen.get(d);if(!h||(f==null?void 0:f.text)===h)continue;const m=Cd(h);this.seen.set(d,{text:h,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()})}r.length?!a.length&&r.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,h)=>c(d)-c(h));for(const d of a)this.emit(d)}}const Rd="guides-by-type";function kS(e){if(e[Rd]===void 0)return;const t={};for(const n of mt(e[Rd])){const[r,a]=n.split("=").map(d=>d.trim());if(!a||!ss.includes(r))continue;const c=t[r]??[];c.includes(a)||(t[r]=[...c,a])}return t}function yS(e){if(!e)return{};const t=ss.flatMap(n=>(e[n]??[]).map(r=>`${n}=${r}`));return{[Rd]:t}}function wS(e){const t=ke(e["model-matching"]);if(t!=="on"&&t!=="off")return;const n=Vb(mt(e["model-tiers"]).map(r=>r.split("=").map(a=>a.trim())));return Object.keys(n).length?{enabled:t==="on",tiers:n}:{enabled:t==="on"}}function xS(e){if(!e)return{};const t=Object.entries(e.tiers??{}).map(([n,r])=>`${n}=${r}`);return{"model-matching":e.enabled?"on":"off",...t.length?{"model-tiers":t}:{}}}function hp(e,t){const{front:n,body:r}=Ca(t),a=Gg(ke(n.verification)),c=wS(n),d=kS(n);return{id:e,key:ke(n.key)||e,title:ke(n.title)||e,mode:ke(n.mode)==="plan-only"||mt(n.labels).includes(iu)?"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:Vj(r),createdAt:ai(n.created),updatedAt:ai(n.updated)}}function jS(e){var t;return du({key:e.key,title:e.title,mode:e.mode,...e.verification?{verification:e.verification}:{},...(t=e.guides)!=null&&t.length?{guides:e.guides}:{},...yS(e.guidesByType),...xS(e.modelMatching),...e.archived?{archived:"true"}:{},labels:[nu,...e.mode==="plan-only"?[iu]:[]],created:fn(e.createdAt),updated:fn(e.updatedAt)},Gj(e.sections))}function bS(e,t){t.code!=="ENOENT"&&console.warn(`Teamtrail: decision ${e} can't be read: ${t.message}`)}class SS{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 vS(t=>this.fs.read(t),t=>this.events.emit(t)));oe(this,"ticketPath",(t,n)=>`${ys(t)}/tickets/${ys(n)}.md`);oe(this,"setMapArchived",(t,n)=>this.editMap(t,r=>oS(r,n),{kind:"map.updated",mapId:t,at:Date.now()}));var r;this.fs=t,this.location=n,(r=t.watch)==null||r.call(t,a=>{const c=this.selfWrites.get(a);c&&Date.now()-c<1500||this.external.queue(a)})}async put(t,n,r){this.selfWrites.set(t,Date.now()),await this.fs.write(t,n,r===void 0?void 0:{base:r})}putNew(t){return uS(this.fs,t,n=>this.selfWrites.set(n,Date.now()))}async readMap(t){return hp(t,await this.fs.read(`${ys(t)}/map.md`))}async writeMap(t,n){await this.put(`${ys(t.id)}/map.md`,jS(t),n)}async listMaps(){const n=(await this.fs.list()).filter(r=>/^[^/]+\/map\.md$/.test(r)).map(r=>r.split("/")[0]);return Promise.all(n.map(async r=>Xb(await this.readMap(r))))}async loadMap(t){const n=await this.fs.list(),r=await this.readMap(t),a=n.filter(d=>d.startsWith(`${t}/tickets/`)&&gS(d)),c=await Promise.all(a.map(async d=>up(await this.fs.read(d))));return{map:r,tickets:c.sort((d,h)=>d.createdAt-h.createdAt)}}async createMap(t){const n=await Rv(this.fs),r=pS(t.title,n),a={id:r,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:r,at:Date.now()}),a}async editMap(t,n,r){const a=await this.fs.read(`${ys(t)}/map.md`);await this.writeMap({...n(hp(t,a)),updatedAt:Date.now()},a),this.events.emit(r)}setMapMode(t,n){return this.editMap(t,r=>({...r,mode:n}),{kind:"map.mode",mapId:t,mode:n,at:Date.now()})}setMapMeta(t,n){return this.editMap(t,r=>Zb(r,n),{kind:"map.updated",mapId:t,at:Date.now()})}updateMapSections(t,n){const r=Object.keys(n)[0];return this.editMap(t,a=>({...a,sections:{...a.sections,...n}}),{kind:"map.updated",mapId:t,section:r,at:Date.now()})}async createTicket(t,n){const r=await this.putNew(()=>hS(this.fs,t,n));return this.events.emit({kind:"ticket.created",mapId:t,ticketId:r.id,at:Date.now()}),r}async addBlocking(t,n,r){await this.update(t,r,a=>a.blockedBy.includes(n)?a:{...a,blockedBy:[...a.blockedBy,n]}),this.events.emit({kind:"edge.added",mapId:t,blockerId:n,blockedId:r,at:Date.now()})}async update(t,n,r){const a=await this.fs.read(this.ticketPath(t,n)),c=up(a),d=r(c);d!==c&&await this.put(this.ticketPath(t,c.id),Pv({...d,updatedAt:Date.now()}),a)}async removeBlocking(t,n,r){await this.update(t,r,a=>tS(a,n)),this.events.emit({kind:"edge.removed",mapId:t,blockerId:n,blockedId:r,at:Date.now()})}async editTicket(t,n,r){await this.update(t,n,a=>nS(a,r)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:n,at:Date.now()})}async reopen(t,n){await this.update(t,n,sS),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:n,at:Date.now()})}async assign(t,n,r){await this.update(t,n,a=>({...a,assignee:r??void 0})),this.events.emit(r?{kind:"ticket.claimed",mapId:t,ticketId:n,assignee:r,at:Date.now()}:{kind:"ticket.released",mapId:t,ticketId:n,at:Date.now()})}async comment(t,n,r,a){await this.update(t,n,c=>({...c,comments:[...c.comments,{id:`c${c.comments.length}`,author:r,body:a,createdAt:Date.now()}]})),this.events.emit({kind:"ticket.commented",mapId:t,ticketId:n,at:Date.now()})}async close(t,n,r){await this.update(t,n,a=>({...a,state:"closed",closeReason:r,closedAt:Date.now()})),this.events.emit({kind:"ticket.closed",mapId:t,ticketId:n,reason:r,at:Date.now()})}async setMeta(t,n,r){await this.update(t,n,a=>rS(a,r)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:n,at:Date.now()})}async listDecisions(t){const r=(await this.fs.list()).filter(a=>a.startsWith(`${t}/decisions/`)).map(async a=>{const c=await this.fs.read(a).catch(h=>bS(a,h));if(!c)return;const d={...Cd(c),mapId:t};return this.external.knows(a)||this.external.remember(a,c,d.supersededBy),d});return(await Promise.all(r)).filter(a=>!!a)}async createDecision(t,n){const r=await this.putNew(async()=>{const a=await fS(this.fs,t,n);return this.external.remember(a.path,a.text),a});return this.events.emit({kind:"decision.recorded",mapId:t,decisionId:r.id,ticketId:r.ticketId,at:Date.now()}),r}async markSuperseded(t,n,r){const a=`${ys(t)}/decisions/${ys(n)}.md`,c=await this.fs.read(a),d=xv({...Cd(c),mapId:t,supersededBy:r});this.external.remember(a,d,r),await this.put(a,d,c),this.events.emit({kind:"decision.superseded",mapId:t,decisionId:n,supersededBy:r,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 fp extends Error{constructor(t,n,r,a){super(n),this.code=t,this.status=r,this.resetAt=a,this.name="TrackerError"}}const NS={github:"GitHub Issues",linear:"Linear"};async function $t(e,t,n){let r;try{r=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:n===void 0?void 0:JSON.stringify(n)})}catch{throw new fp("offline","Lookout server unreachable; is `teamtrail` still running?")}const a=await r.json().catch(()=>({}));if(!r.ok)throw new fp(a.code??"http",a.error??`request failed (${r.status})`,r.status,a.resetAt);return a}class $S{constructor(t,n,r=""){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,r)=>this.call("addBlocking",t,n,r));oe(this,"removeBlocking",(t,n,r)=>this.call("removeBlocking",t,n,r));oe(this,"editTicket",(t,n,r)=>this.call("editTicket",t,n,r));oe(this,"reopen",(t,n)=>this.call("reopen",t,n));oe(this,"assign",(t,n,r)=>this.call("assign",t,n,r));oe(this,"comment",(t,n,r,a)=>this.call("comment",t,n,r,a));oe(this,"close",(t,n,r)=>this.call("close",t,n,r));oe(this,"setMeta",(t,n,r)=>this.call("setMeta",t,n,r));oe(this,"listDecisions",t=>this.call("listDecisions",t));oe(this,"createDecision",(t,n)=>this.call("createDecision",t,n));oe(this,"markSuperseded",(t,n,r)=>this.call("markSuperseded",t,n,r));this.kind=t,this.base=n,this.label=NS[t],this.location=r}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 r=JSON.parse(n.data);r.location&&(this.location=r.location),this.status=r,this.statusEvents.emit(r)}),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 r;n(),--this.listeners===0&&((r=this.source)==null||r.close(),this.source=void 0)}}onStatus(t){return this.statusEvents.on(t)}}function CS(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 TS=[{id:"markdown",name:"Local markdown",status:"available"},{id:"github",name:"GitHub Issues",status:"available"},{id:"linear",name:"Linear",status:"available"}],_v=[{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"}],ES=_v[0],AS="https://github.com/teamtrailhq/teamtrail-guides",RS="https://raw.githubusercontent.com/teamtrailhq/teamtrail-guides/main",MS=`${AS}/blob/main/CONTRIBUTING.md`,IS=e=>e.slice(0,9),OS=/[a-z][\w+.-]*:\/\/(?!(localhost|127\.0\.0\.1)(:\d+)?(\/|$|\s))/i,LS=/^[\w.-]+@[\w.-]+:/,PS=/^(@[\w.-]+\/)?[\w./-]+@[\w^~<>=*.-]+$/,DS=/(^|=)(npm|jsr|github|gitlab|bitbucket|git\+[a-z]+|https?):/i,_S=/^--?(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,BS={tar:/^-[A-Za-z]*[IF]/,zip:/^-TT|^--unzip-command/,make:/^-E|^--eval/,perl:/^-[A-Za-z]*M/};function FS(e,t){var n;if(OS.test(t)||LS.test(t))return"names a remote address, so it reaches the network";if(PS.test(t)&&!t.startsWith("-"))return`names a package to download (${t})`;if(DS.test(t))return`names a package from a registry (${t})`;if(_S.test(t))return`runs a command it's given (${t.split("=")[0]})`;if((n=BS[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(zS.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 zS=/\|\s*(sh|bash|zsh|dash|ksh|fish|pwsh|node|python\d*|perl|ruby)\b|\$\(|`|;|&&|\|\||\b(curl|wget)\s/;function US(e,t){var n;if(e==="cargo")for(let r=0;r<t.length;r++){const a=t[r]==="--config"?t[r+1]:(n=/^--config=(.*)$/s.exec(t[r]))==null?void 0:n[1];if(a!==void 0&&!/^[\w./-]+\.toml$/.test(a))return"sets cargo configuration inline (--config)"}}function WS(e,t){const n=US(e,t);if(n)return n;for(const r of t){const a=FS(e,r);if(a)return a}}const HS=/^(-c|-e|-E|-ex|-x|-r|-command|-Command|-EncodedCommand)$|^--(eval|exec|command|expr|execute|run)(=|$)/,KS=/(^|[\s|'"=])[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}(:\d+)?\/\S*/i;function GS(e,t){const n=e.find(r=>{var a;return HS.test(r)&&!((a=t==null?void 0:t.exempt)!=null&&a.includes(r.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(r=>KS.test(r)))return"names an address, so it may reach the network"}const VS=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"]),qS=new Set(["-C","--git-dir","--work-tree","--namespace","--super-prefix"]);function QS(e){for(let t=0;t<e.length;t++){const n=e[t],r=n.split("=")[0];if(r==="-c"||r.startsWith("-c")||r==="--config-env"||r==="--exec-path")return`sets git's configuration or programs inline (${r})`;if(qS.has(r)){n.includes("=")||t++;continue}if(n.startsWith("-"))continue;const a=n.toLowerCase();return VS.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 YS=["--require","--import","--loader","--experimental-loader","--env-file","--input-type"],mp={inline:"ep",value:"rC",long:["--eval","--print"],longValue:YS},JS={node:mp,nodejs:mp,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 XS(e,t){const n=e.slice(1);for(let r=0;r<n.length;r++){if(t.inline.includes(n[r]))return"code";if(t.value.includes(n[r]))return r===n.length-1?"takes-next":"plain"}return"plain"}function ZS(e,t){var a;if(/^data:|=data:/i.test(e))return"code";if(!e.startsWith("--"))return XS(e,t);const[n,r]=e.toLowerCase().split(/=(.*)/s,2);return t.long.includes(n)?"code":r===void 0&&((a=t.longValue)!=null&&a.includes(n))?"takes-next":"plain"}function eN(e,t){const n=JS[e];if(n)for(let r=0;r<t.length;r++){const a=t[r];if(a==="--"||!a.startsWith("-")||a===n.stop)return;const c=ZS(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[r+1]??""))return"runs code given inline";c==="takes-next"&&r++}}const pp=e=>new RegExp(`^(?![-/~\\\\])(?!.*\\.\\.)(?![a-zA-Z]:)[\\w./-]+\\.(${e})$`),zt={},ft=e=>e.split(/\s+/).filter(Boolean),tN={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:pp("[cm]?[jt]s"),sub:["--test"]},python:{script:pp("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"]}},nN=/^(\.\/)?node_modules\/\.bin\/([\w.-]+)$/;function sN(e,t){var r;const n=t[0]??"";return e.needs&&!t.some(a=>e.needs.includes(a))?!1:(r=e.script)!=null&&r.test(n)?!0:e.modules?n==="-m"&&e.modules.includes(t[1]??""):e.sub?e.sub.includes(n):!0}function Bv(e){var r;const t=(r=nN.exec(e.argv0))==null?void 0:r[2],n=tN[t??e.program];return n&&sN(n,e.args)?n:void 0}const iN=e=>!!Bv(e),Ta=e=>new Set(e.split(/\s+/).filter(Boolean)),rN=Ta(`
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
+ `),oN=Ta(`
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
+ `),aN=Ta("npx pnpx bunx uvx uv pipx docker podman nix nix-shell nix-env flatpak snap"),cN=Ta(`
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"],lN={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 dN(e){const t=(e.split(/[\\/]/).pop()??"").toLowerCase().replace(/\.(exe|cmd|bat|com)$/,"");return t.replace(new RegExp("(?<=[a-z])[\\d.-]+$"),"")||t}const uN=e=>{var t;return((t=e.find(n=>!n.startsWith("-")))==null?void 0:t.toLowerCase())??""};function gp(e){const t=e.findIndex(n=>n.startsWith("-m"));if(!(t<0))return e[t]==="-m"?e[t+1]:e[t].slice(2)}const hN=new Set(["pip","ensurepip","pipx","uv","venv","http.server","webbrowser"]);function fN(e,t){var r;if(rN.has(e))return`runs a shell (${e}); name the program and its arguments instead`;if(oN.has(e))return`runs ${e}, which reaches the network`;if(aN.has(e))return`runs ${e}, which downloads and runs a package; use one installed in the repo`;if(cN.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=uN(t);if((r=lN[e])!=null&&r.has(n))return`runs ${e} ${n}, which downloads packages; use one installed in the repo`;if(e==="python"&&hN.has(gp(t)??""))return`runs python -m ${gp(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 Fv(e){const t=e.run[0]??"";return{argv0:t,program:dN(t),args:e.run.slice(1)}}function mN(e){const{argv0:t,program:n,args:r}=Fv(e),a=Bv({argv0:t,program:n,args:r}),c=[fN(n,r),eN(n,r),n==="git"?QS(r):void 0,WS(n,r),GS(r,a)].filter(d=>!!d);return e.cwd&&(e.cwd.startsWith("/")||e.cwd.split(/[\\/]/).includes(".."))&&c.push("cwd must stay inside the repo"),c}const pN="unknown program: Teamtrail can't tell what this runs";function gN(e){if(mN(e).length)return;const{argv0:t,program:n,args:r}=Fv(e);return iN({argv0:t,program:n,args:r})?void 0:pN}function vN(e,t={}){const n=(t.query??"").toLowerCase().split(/\s+/).filter(Boolean);return e.guides.filter(r=>{if(t.verifiedOnly&&!r.verified&&!r.builtin)return!1;const a=[r.id,r.name??"",r.summary,r.author].join(" ").toLowerCase();return n.every(c=>a.includes(c))})}const kN="unknown model",yN=e=>`${Math.round(e.firstTimeRate*100)}%`,vp=(e,t)=>`${e.model} passes ${yN(e)} of your ${t} tickets first time (${e.tickets} tickets)`;function wN(e,t){return t.firstTimeRate-e.firstTimeRate||(e.costPerVerifiedUsd??1/0)-(t.costPerVerifiedUsd??1/0)||e.key.localeCompare(t.key)}function xN(e){return[...new Set(e.scorecard.byTypeAndModel.map(n=>n.type??""))].filter(Boolean).sort().flatMap(n=>{const r=e.scorecard.byTypeAndModel.filter(f=>f.type===n&&f.enough&&f.model!==kN).sort(wN);if(r.length<2||r[0].firstTimeRate===r[1].firstTimeRate)return[];const a=r[0],c=xj(a.model,e.models).tier,d=e.tiers[n];if(!d||c===d)return[];const h=`${vp(a,n)}; ${vp(r[1],n)}`;return[{type:n,current:d,tier:c,model:a.model??"",because:h}]})}const Zo=e=>`${Math.round(e*100)}%`,jN=e=>e===void 0?"–":`$${e.toFixed(2)}`,mu=e=>e.replace(/[^\w .@/·-]/g,"").slice(0,60);function Yl(e,t){return[`| ${t} | Tickets | Verified first time | Rework | Came back | Attempts per verified | Cost per verified |`,"| --- | ---: | ---: | ---: | ---: | ---: | ---: |",...e.map(n=>[`| ${mu(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??"–",`${jN(n.costPerVerifiedUsd)} |`].join(" | "))]}function bN(e){return["| Check | Verified tickets it passed | Came back |","| --- | ---: | ---: |",...e.map(t=>`| ${mu(t.key)}${t.enough?"":" (too few)"} | ${t.verified} | ${Zo(t.escapeRate)} (${t.escaped}) |`)]}function SN(e,t="Agent scorecard"){var n,r;return[`## ${mu(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.`,"",...Yl(e.byTypeAndModel,"Ticket type · model"),"",...Yl(e.byVendor,"Vendor"),...(n=e.byGuide)!=null&&n.length?["",...Yl(e.byGuide,"Guide")]:[],...(r=e.byCheck)!=null&&r.some(a=>a.escaped)?["",...bN(e.byCheck)]:[]].join(`
134
+ `)}const Jl="No area yet";function NN(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 Xl={x:112,w:15},Zl={x:136,w:10};function kp({x:e,w:t},n,r,a){const c=e+n;return[`<rect x="${c}" y="${94+r}" width="${t}" height="12" rx="${t>12?5:4}" fill="${a.glowLight}"/>`,`<rect x="${c}" y="${100+r}" width="${t}" height="6" rx="3" fill="${a.glow}"/>`,`<rect x="${c+t-6}" y="${96+r}" width="${t>12?3.5:2.5}" height="3.5" rx="1" fill="#fff"/>`].join("")}function yp({x:e,w:t},n){const r=t+3,a=t>12?6:5;return`<rect x="${e-2}" y="90" width="${r}" height="18" rx="${r/2.6}" fill="${n.glowLight}"/><rect x="${e-2+(r-a)/2}" y="96" width="${a}" height="6" rx="2" fill="${n.glass}"/>`}function $N(e,t){if(e==="closed")return[Xl,Zl].map(({x:a,w:c})=>`<rect x="${a}" y="100" width="${c}" height="4" rx="2" fill="${t.glow}"/>`).join("");if(e==="wide")return yp(Xl,t)+yp(Zl,t);const[n,r]=e==="aside"?[4,-5]:[0,0];return kp(Xl,n,r,t)+kp(Zl,n,r,t)}function CN(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 TN({eyes:e,mouth:t},n){return $N(e,n)+CN(t,n)}function EN(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 AN(e,t,n,r){return[`<path d="M86 34L80 16" stroke="${r.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 RN({face:e,lamp:t,lit:n,simple:r,c:a}){const c=EN(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}"/>`,r?"":c.shine,e,r?"":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}"/>`,AN(t,n,r,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}"/>`,r?"":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 MN={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"},zv={on:"#ffb347",dim:"#a8501c",alert:"#ff5a48"},IN={on:"#ffd166",dim:"#a8501c",alert:"#ff5a48"},ON={circle:100,rounded:46,square:0},LN=.94;let PN=0;function DN(e,{lamp:t=zv,simple:n=!1,shape:r="circle",colors:a=MN}={}){const c=a,d=e.light??"on",h=r==="circle"?LN:1,f=100*(1-h),m=`scout-clip-${++PN}`,g=RN({face:TN(e,c),lamp:t[d],lit:d!=="dim",simple:n,c});return[`<defs><clipPath id="${m}"><rect width="200" height="200" rx="${ON[r]}"/></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(${h})">${NN(c)}${g}</g>`,"</g>"].join("")}const Uv={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:zv,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:IN,wave:{bar:"#66828d",lead:"#e8833a"}}},_N="crt",BN={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"}},FN={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},$n={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function zN(e){return e?/[aeiouy]/i.test(e)?"open":/[a-z0-9]/i.test(e)?"mid":"rest":"rest"}function UN(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 WN(e,t,n){return Array.from({length:n},(r,a)=>{const c=t-(n-1-a);return c>=0&&c<e.length?UN(e[c],c):0})}function Wv({face:e={eyes:"open",mouth:"rest"},variant:t="crt",size:n,simple:r,shape:a="circle",className:c}){const{eyes:d,mouth:h,light:f}=e,m=y.useMemo(()=>DN({eyes:d,mouth:h,light:f},{lamp:Uv[t].lamp,simple:r??n<40,shape:a}),[d,h,f,t,r,n,a]);return s.jsx("svg",{className:c,width:n,height:n,viewBox:"0 0 200 200","aria-hidden":"true",dangerouslySetInnerHTML:{__html:m}})}function HN(e){const[t,n]=y.useState(!1);return y.useEffect(()=>{if(!e){n(!1);return}let r;const a=setInterval(()=>{n(!0),r=setTimeout(()=>n(!1),$n.blinkMs)},$n.blinkEveryMs);return()=>{clearInterval(a),r&&clearTimeout(r)}},[e]),t}const KN={xs:.8,sm:2,md:4,lg:6},GN=40,wp=20,xp="(prefers-reduced-motion: reduce)",VN=40,qN=350;function QN(e,t){var h;const n=e.size??"md",r=e.state??"idle",a=((h=e.speaking)==null?void 0:h.trim())??"",c=a&&(r==="idle"||r==="speaking")?"speaking":r,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 YN=e=>e.length*$n.msPerChar,JN=(e,t)=>t&&(e.effective==="idle"||e.effective==="speaking"||e.effective==="alert");function XN(e,t,n,r){const a=BN[e.effective],c=n?"closed":a.eyes;let d=a.mouth,h=e.text.length-1;if(r)if(e.reduced)d="open";else{h=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=zN(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:h}}function ZN(e,t){const n=typeof e.size=="number"?e.size:KN[e.size],r=e.reduced?Math.min(e.text.length-1,wp-1):t;return{base:n,px:GN*n,bars:wp,waveCursor:r}}function e1(e,{label:t,speechDone:n,cursor:r,caption:a}){const c=e.talking&&n?"idle":e.effective,d=FN[c],h=e.size==="md"||e.size==="lg"||typeof e.size=="number"&&e.size>=4;return{shownState:c,status:d,ariaLabel:`${t}, ${d.toLowerCase()}`,showCaption:a??h,shown:t1(e,n,r)}}function t1(e,t,n){return e.talking?e.reduced||t?e.text:e.text.slice(0,n+1):""}function n1(){const[e,t]=y.useState(()=>{var n;return typeof window<"u"&&!!((n=window.matchMedia)!=null&&n.call(window,xp).matches)});return y.useEffect(()=>{var a;const n=(a=window.matchMedia)==null?void 0:a.call(window,xp);if(!n)return;const r=()=>t(n.matches);return r(),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function s1(e,t,n){const[r,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]),r}function i1(e){const{key:t,talking:n,at:r}=e,a=r!==void 0,c=YN(e.text),[d,h]=y.useState(""),f=y.useRef(e.onSpeakEnd);f.current=e.onSpeakEnd,y.useEffect(()=>{if(!n||a)return;const b=setTimeout(()=>{var S;h(t),(S=f.current)==null||S.call(f)},c+qN);return()=>clearTimeout(b)},[n,t,c,a]);const m=n&&d!==t,g=s1(t,e.animate&&(m||e.thinking),m?VN:$n.thinkingStepMs),k=r??g,w=n&&(a?k>=c:d===t);return{t:k,speechDone:w}}const r1=e=>e*2,Md=3.5;function o1(e,t,n){return(e??[]).map((r,a)=>{const c=(1+2*r)*.5;return{x:a*2,y:(Md-c)/2,width:1,height:c,fill:a>=t-2&&r>0?n.lead:n.bar}})}function a1({heights:e,bars:t,unit:n,colors:r}){const a=r1(t);return s.jsx("svg",{className:`scout-wave${e?" on":""}`,width:a*n,height:Md*n,viewBox:`0 0 ${a} ${Md}`,"aria-hidden":"true",children:o1(e,t,r).map((c,d)=>s.jsx("rect",{...c},d))})}function Ea({state:e="idle",size:t="md",speaking:n,variant:r=_N,framed:a,caption:c,label:d="Scout",onSpeakEnd:h,at:f,className:m,style:g}){const k=QN({state:e,size:t,speaking:n,framed:a},n1()),{text:w,effective:b,talking:S,reduced:x}=k,C=Uv[r],P=!x&&!(f!==void 0),D=`${b}|${r}|${w}`,{t:M,speechDone:W}=i1({key:D,text:w,talking:S,thinking:b==="thinking",animate:P,at:f,onSpeakEnd:h}),_=HN(JN(k,P)),Y=S&&!W,{eyes:re,mouth:q,light:ye,cursor:Ie}=XN(k,M,_,Y),{base:be,px:Z,bars:se,waveCursor:Ne}=ZN(k,Ie),me=y.useMemo(()=>Y?WN(w,Ne,se):null,[Y,w,Ne,se]),{shownState:Se,status:z,ariaLabel:Q,showCaption:U,shown:E}=e1(k,{label:d,speechDone:W,cursor:Ie,caption:c}),F={...g,"--scout-u":`${be}px`},ce=s.jsx("span",{className:"scout-sprite",children:s.jsx(Wv,{face:{eyes:re,mouth:q,light:ye},variant:r,size:Z,simple:k.mini})});return k.framed?s.jsxs("figure",{className:`scout scout-panel scout-${Se} scout-v-${r} ${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:[ce,s.jsx(a1,{heights:me,bars:se,unit:be,colors:C.wave})]}),U&&s.jsxs("p",{className:"scout-caption","aria-hidden":"true",children:[E,S&&!W&&!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:ce})}const Ct="trail lead";function c1({rt:e,guard:t,setMapId:n,mapIdRef:r,snapRef:a,setChatSession:c,setSelection:d}){const h={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",()=>Zm(e.adapter,r.current,f,{...h,assignee:Ct})),release:f=>t("Release claim",()=>o0(e.adapter,r.current,f,{...h,actor:Ct})),releaseLease:f=>t("Release to queue",()=>e.leases.release(r.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 Zm(e.adapter,r.current,f,{...h,assignee:Ct}),await v0(e.adapter,r.current,f,{...h,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 au(e.adapter,f.mapId,x,{appendToTrail:!1})).id}await d0(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 y0(e.adapter,r.current,f,m);d({kind:"ticket",id:g.id})}),ruleOut:(f,m)=>t("Rule out of scope",async()=>{await w0(e.adapter,r.current,f,{...h,reason:m,author:Ct,source:{kind:"lookout",label:"Ticket inspector"}}),d(null)}),setArchived:f=>t(f?"Archive trail":"Restore trail",async()=>{await S0(e.adapter,r.current,f),f&&n(void 0)}),setMode:f=>t(`Trail mode · ${f}`,()=>u0(e.adapter,r.current,f)),setModelMatching:f=>t(`Model matching · ${f.enabled?"on":"off"}`,()=>x0(e.adapter,r.current,f))}}const pe=(...e)=>e.filter(Boolean).join(" "),Ss="item",l1=/^[0-9a-f]{6,64}$/;function Sr(){const e=new URLSearchParams(location.search).get("project")??void 0;return e&&l1.test(e)?e:void 0}function ae(e=Sr()){return e?`${J.apiPrefix}/p/${e}`:J.apiPrefix}function d1(e){const t=new URLSearchParams(location.search);for(const r of["projects","project","tracker",Ss])t.delete(r);e.item&&t.set(Ss,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 u1(){var n,r;const e=await fetch(`${ae()}/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"?(r=e.config)==null?void 0:r.default:void 0;return t&&t!=="off"?t:void 0}async function h1(e,t){var d;const n=(t.assumptions??[]).map((h,f)=>({id:`S-${f+1}`,text:h,status:"holding",tickets:[]})),r=await u1(),{map:a,tickets:c}=await Qj(e,{title:t.title,...r?{verification:r}:{},sections:{destination:t.destination,notes:t.notes,decisions:[],unspecified:[],outOfScope:[],...n.length?{assumptions:n}:{}},tickets:[{ref:"discovery",...Ab}]});return await fetch(`${ae()}/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 Hv(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 Kv(e){const t=Math.max(0,Math.floor(e/1e3)),n=r=>String(r).padStart(2,"0");return`${n(Math.floor(t/3600))}:${n(Math.floor(t%3600/60))}:${n(t%60)}`}const Aa=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 Ra(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),pu=e=>new Date(e).toTimeString().slice(0,5),f1=e=>`${hi(e)} ${pu(e)}`,Gv=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`},is=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"},m1={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function gu(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 p1=8,g1=40;function v1(e,t){try{return new URL(e,t).origin===t}catch{return!1}}function Vv(e,t){if(!Array.isArray(e))return[];const n=[];for(const r of e.slice(0,p1)){const{label:a,href:c}=r??{};if(typeof a!="string"||typeof c!="string")continue;const d=a.trim();!d||d.length>g1||!v1(c,t)||n.push({label:d,href:c})}return n}function Ma(e){e==="auto"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}const k1=["auto","day","night"];function y1(e){const[t]=Vv(e?[e]:[],location.origin);return t?{agents:t}:{}}const Ia=e=>typeof e=="string"&&/^\/[\w/-]{1,100}$/.test(e)?e:void 0;function w1(e){const t=Ia(e);return t?{themeSave:t}:{}}function x1(e){const t=Ia(e);return t?{trailAgents:t}:{}}function j1(e){const t=Ia(e);return t?{setup:t}:{}}function b1(e){const t=Ia(e);return t?{merge:t}:{}}function S1(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 Id;const pt=()=>Id;function N1(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,r=Vv(t.pages,location.origin),a=k1.find(c=>c===t.theme);return Id={name:t.name,pages:r,...n?{signOut:t.signOut}:{},...a?{theme:a}:{},...w1(t.themeSave),...b1(t.merge),...j1(t.setup),...x1(t.trailAgents),...t.highRisk===!1?{highRisk:!1}:{},...S1(t.home),...t.tracker==="markdown"?{tracker:"markdown"}:{},...y1(t.agents)},a&&Ma(a),Id}const $1=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 C1(e){const t=Math.ceil((e.length+9)/64)*64,n=new Uint8Array(t);n.set(e),n[e.length]=128;const r=new DataView(n.buffer);return r.setUint32(t-8,Math.floor(e.length*8/2**32)),r.setUint32(t-4,e.length*8>>>0),n}function T1(e,t,n,r){for(let w=0;w<16;w++)r[w]=t.getUint32(n+w*4);for(let w=16;w<64;w++){const b=un(r[w-15],7)^un(r[w-15],18)^r[w-15]>>>3,S=un(r[w-2],17)^un(r[w-2],19)^r[w-2]>>>10;r[w]=r[w-16]+b+r[w-7]+S>>>0}let[a,c,d,h,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)+$1[w]+r[w]>>>0,S=(un(a,2)^un(a,13)^un(a,22))+(a&c^a&d^c&d)>>>0;[k,g,m,f,h,d,c,a]=[g,m,f,h+b>>>0,d,c,a,b+S>>>0]}[a,c,d,h,f,m,g,k].forEach((w,b)=>e[b]=e[b]+w>>>0)}function ed(e){const t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),n=C1(e),r=new DataView(n.buffer),a=new Uint32Array(64);for(let h=0;h<n.length;h+=64)T1(t,r,h,a);const c=new Uint8Array(32),d=new DataView(c.buffer);return t.forEach((h,f)=>d.setUint32(f*4,h)),c}function E1(e,t){const n=new Uint8Array(64);n.set(e.length>64?ed(e):e);const r=new Uint8Array(64+t.length),a=new Uint8Array(96);for(let c=0;c<64;c++)r[c]=n[c]^54,a[c]=n[c]^92;return r.set(t,64),a.set(ed(r),64),ed(a)}const qv=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join(""),A1=e=>new Uint8Array((e.match(/../g)??[]).map(t=>parseInt(t,16))),vu=`${J.slug}.session`;let aa;const R1=e=>{const t=e;return!!t&&typeof t.id=="string"&&typeof t.secret=="string"&&typeof t.verifier=="string"};function ku(){try{const e=JSON.parse(localStorage.getItem(vu)??"null");return R1(e)?e:aa}catch{return aa}}function M1(e){aa=e;try{localStorage.setItem(vu,JSON.stringify(e))}catch{}}function Qv(){aa=void 0;try{localStorage.removeItem(vu)}catch{}}let yu="unproven",td;const Od=new Set,Yv=e=>{yu=e;for(const t of Od)t(e)};function I1(e){return Od.add(e),()=>void Od.delete(e)}const O1=()=>yu==="proven",L1=()=>yu==="proven"&&Yv("unproven");function P1(){const e=new Uint8Array(16);return crypto.getRandomValues(e),qv(e)}async function D1(){const e=ku();if(!e)return"unknown";const t=P1(),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 Qv(),"unknown";const r=n!=null&&n.ok?(await n.json().catch(()=>({}))).proof:void 0,a=qv(E1(A1(e.verifier),new TextEncoder().encode(`${t}
135
+ ${location.origin}`)));return r===a?"proven":"failed"}function Oa(){return td??(td=D1().then(e=>(td=void 0,Yv(e),e))),td}const _1=1e4;class Jv{constructor(t=ae(),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 r;this.listeners.push([t,n]),(r=this.inner)==null||r.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 Oa()!=="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[r,a]of this.listeners)n.addEventListener(r,a);n.addEventListener("open",()=>this.retryMs=1e3),n.addEventListener("error",()=>{n.close(),L1(),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,_1))}}function B1(){if(pt())return void fetch(`${J.apiPrefix}/session`,{cache:"no-store"}).then(e=>e.status===401&&location.reload());Oa().then(e=>e==="unknown"&&location.reload())}let Ht;const ca=new Set,wr=new Map,la=new Set,da=new Set;function Xv(e){Ht==null||Ht.addEventListener(e,t=>{for(const n of wr.get(e)??[])n(t.data)})}function La(){if(!Ht){Ht=new Jv,Ht.onerror=()=>{for(const e of da)e();B1()},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())Xv(e)}}function Pa(){const e=[...wr.values()].some(t=>t.size>0);ca.size||e||la.size||da.size||(Ht==null||Ht.close(),Ht=void 0)}function Da(e){return ca.add(e),La(),()=>{ca.delete(e),Pa()}}function vi(e,t){let n=wr.get(e);return n||(n=new Set,wr.set(e,n),Xv(e)),n.add(t),La(),()=>{n.delete(t),Pa()}}function rs(e){return la.add(e),La(),()=>{la.delete(e),Pa()}}function F1(e){return da.add(e),La(),()=>{da.delete(e),Pa()}}const wu=(e,t)=>`${e}/${t}`;let nn={reached:!1,live:!1,tickets:{}},Ld=!1;const Pd=new Set,Dd=new Set,z1=gi();let _d=0;const Zv=new Map;let ek=0;function ua(e){nn=e;for(const t of Pd)t()}function U1(e,t){const n=Object.fromEntries(e.map(r=>[wu(r.mapId,r.ticketId),r]));for(const[r,a]of Zv)a>t&&nn.tickets[r]&&(n[r]=nn.tickets[r]);return n}function jp(){const e=z1.start(),t=_d;fetch(`${ae()}/verification/sync`).then(n=>n.ok?n.json():Promise.reject()).then(n=>e()&&ua({reached:!0,live:!0,status:ek>t?nn.status:n.status,tickets:U1(n.tickets,t)}),()=>nn.reached&&ua({...nn,live:!1}))}function W1(e){const t=JSON.parse(e);if(t.kind==="evidence")for(const a of Dd)a();if(t.kind!=="sync")return;const n=t;ek=++_d;const r={...nn.tickets};for(const a of n.tickets){const c=wu(a.mapId,a.ticketId);r[c]=a,Zv.set(c,_d)}ua({reached:!0,live:!0,status:n.status,tickets:r})}function bp(){Ld=!0,vi("verification",W1),F1(()=>nn.reached&&nn.live&&ua({...nn,live:!1})),rs(jp),jp()}const ns={subscribe(e){return Ld||bp(),Pd.add(e),()=>void Pd.delete(e)},get:()=>nn,onEvidence(e){return Ld||bp(),Dd.add(e),()=>void Dd.delete(e)},ticket:(e,t,n)=>e.tickets[wu(t,n)]};function H1(e){if(e!=null&&e.flags.length)return e.flags.some(t=>t.severity==="alert")?"alert":"warn"}const Sp={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:ES.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function xu(){try{const e={...Sp,...JSON.parse(localStorage.getItem(wa)??"{}")};return["markdown","github","linear"].includes(e.tracker)||(e.tracker="markdown"),e}catch{return Sp}}const nd=new Map,sd=e=>`${ae()}/file?path=${encodeURIComponent(e)}`;async function id(e,t){const n=await e.json().catch(()=>({})),r=new Error(n.error??`${t}: ${e.status}`);return e.status===409?Object.assign(r,{stale:!0}):e.status===404?Object.assign(r,{code:"ENOENT"}):r}const K1={async list(){return(await(await fetch(`${ae()}/list`)).json()).files},async read(e){const t=await fetch(sd(e));if(!t.ok)throw await id(t,`read ${e}`);const n=await t.text(),r=t.headers.get("ETag");return r&&nd.set(e,{text:n,etag:r}),n},async write(e,t,n){const r=(n==null?void 0:n.base)===void 0?void 0:nd.get(e),a=r&&r.text===(n==null?void 0:n.base)?{"If-Match":r.etag}:{},c=await fetch(sd(e),{method:"PUT",body:t,headers:a});if(!c.ok)throw await id(c,`write ${e}`);nd.delete(e)},async create(e,t){const n=await fetch(sd(e),{method:"PUT",body:t,headers:{"If-None-Match":"*"}});if(n.status===412)return!1;if(!n.ok)throw await id(n,`create ${e}`);return!0},watch(e){return Da(e)}},G1=15*6e4;class V1{constructor(t){oe(this,"leases",[]);oe(this,"changes",new di);oe(this,"logged",new Set);oe(this,"since",Date.now()-G1);this.activity=t}subscribe(t){return this.changes.on(t)}set(t){var n;this.leases=t;for(const r of t){const a=`${r.mapId}/${r.ticketId}/${(n=r.returned)==null?void 0:n.at}`;!r.returned||r.returned.at<this.since||this.logged.has(a)||(this.logged.add(a),this.activity.push({source:"system",level:"warn",ticketId:r.ticketId,text:Kb(r)}))}this.changes.emit(t)}async release(t,n,r){const a=await fetch(`${ae()}/agents/leases/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,ticketId:n,by:r})});if(!a.ok)throw new Error((await a.json().catch(()=>({}))).error??`HTTP ${a.status}`)}}function q1(e){e.remoteAnswer=(t,n,r)=>{fetch(`${ae()}/agents/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t.sessionId,questionId:t.id,text:n,author:r})}).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 Q1(e){const t=gi(),n=()=>{const r=t.start();fetch(`${ae()}/agents/leases`).then(a=>a.ok?a.json():{leases:[]}).then(({leases:a})=>r()&&e.set(a)).catch(()=>{})};vi("leases",r=>{t.pushed(),e.set(JSON.parse(r).leases)}),rs(n),n()}function Y1(e){let t=0;const n=new Map,r=()=>{const a=t;fetch(`${ae()}/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)}),rs(r),r()}function Np(e,t){q1(e),Q1(t),Y1(e)}function $p(e){const t=n=>`${wa}:${e}:${n}`;return{get:n=>localStorage.getItem(t(n)),set:(n,r)=>{try{localStorage.setItem(t(n),r)}catch{}}}}const J1=["markdown","github","linear"];function X1(){const e=new URLSearchParams(location.search).get("tracker");return e&&J1.includes(e)?e:xu().tracker}function Z1(e){let t,n;const r=new B0,a=new V1(r),c={},d=C0(ae());if(e==="github"||e==="linear"){const m=new $S(e,ae());m.openEvents=g=>new Jv(ae(),g),t=m,n=fetch(`${ae()}/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=$p(`${e}:${m.location}`);c.presence=new sp(k),r.ledger=new ip(k),Np(r,a)})}else t=new SS(K1,`./${J.dataDir}`),n=fetch(`${ae()}/list`).then(m=>m.json()).catch(()=>({root:"default"})).then(({root:m})=>{const g=$p(m);c.presence=new sp(g),r.ledger=new ip(g),Np(r,a)});const h=W0(t),f=h.adapter;return{kind:e,ready:n,get presence(){return c.presence},adapter:f,journal:d,monitor:h,activity:r,leases:a}}const mn=e=>e.status==="running",e$=e=>mn(e)&&!!e.waitingOn,t$={blocking:0,soon:1,fyi:2};function n$(e,t,n){const r=e.filter(d=>d.sessionId===t),a=r.find(d=>d.id===n);if(a)return a;const c=d=>t$[d.urgency??"soon"];return[...r].sort((d,h)=>c(d)-c(h)||d.at-h.at)[0]}function Ns(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 r=Math.floor(n/60);if(r<24)return`${r} h ago`;const a=Math.floor(r/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"},s$=e=>/^\d{8}$/.test(e)||e==="latest",i$=e=>/^\d{1,2}$/.test(e);function r$(e){const t=e.find(r=>ea[r]);if(!t)return;const n=e.filter(i$).join(".");return n?`${ea[t]} ${n}`:ea[t]}function o$(e){const[,t,...n]=e,r=n.filter(a=>!s$(a)).map(a=>ea[a]??a);return[`GPT-${t??""}`,...r].join(" ").trim()}function _a(e){const t=e==null?void 0:e.trim();if(!t)return;const n=t.toLowerCase().split(/[-_/]/).filter(Boolean);return n.includes("claude")?r$(n)??t:n[0]==="gpt"?o$(n):t.replace(/[-_](\d{8}|latest)$/,"")}const a$=/^slack:([A-Z0-9]+)$/i;function fi(e,t){var c;const n=(c=a$.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 r=t==null?void 0:t.allow.find(d=>d.id===n),a=(r==null?void 0:r.realName)||(r==null?void 0:r.name);return a?`${a} (Slack)`:"Slack user"}function ju(e,t){const n=fi(e.decidedBy,t);return e.decidedByName?`${e.decidedByName} (${n})`:n}function xs({n:e,urgent:t,pop:n,hideZero:r}){return s.jsx("span",{className:pe("badge",t&&"urgent",n&&t&&"pop",r&&!e&&"zero"),children:r&&!e?"":e})}function I({variant:e="default",size:t="md",on:n,className:r,type:a,...c}){return s.jsx("button",{type:a??"button",className:pe("btn",e!=="default"&&e,t==="sm"&&"sm",n&&"on",r),...c})}function Vt({as:e="div",tone:t,on:n,className:r,children:a,...c}){return s.jsx(e,{className:pe("card",t,n&&"on",r),...c,children:a})}function bu({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 tk({text:e,className:t}){const n=y.useRef(null),[r,a]=y.useState(!1),[c,d]=y.useState(!1);return y.useLayoutEffect(()=>{const h=n.current;h&&!r&&d(h.scrollHeight>h.clientHeight+1)},[e,r]),s.jsxs("div",{className:"clamp",children:[s.jsx("p",{ref:n,className:pe("t-body clamp-text",!r&&"cut",t),children:e}),(c||r)&&s.jsx("button",{type:"button",className:"d-more","aria-expanded":r,onClick:()=>a(!r),children:r?"Show less":"Read more"})]})}function ct({on:e,title:t,sub:n,disabled:r,onClick:a}){return s.jsxs(Vt,{as:"button",type:"button",className:"choice",on:e,disabled:r,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),r=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 ${r.toLowerCase()}`:r}),t&&s.jsx("div",{className:"disclosure-body",children:e.children})]})}function Ee({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 Ba=y.forwardRef(function({value:t,onValueChange:n,onSubmit:r,action:a="Send",actionDisabled:c,className:d,...h},f){return s.jsxs("form",{className:pe("input-row",d),onSubmit:m=>{m.preventDefault(),r(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(),r(t))},...h}),s.jsx(I,{type:"submit",variant:"primary",disabled:c??(h.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:r,className:a,children:c,title:d}){return s.jsx(e,{className:pe(t==="chip"?"chip-label":"mono-label",n&&"hot",r==="sm"&&(t==="chip"?"sm":"xs"),a),title:d,children:c})}const c$=e=>typeof e=="string"?{text:e}:e,l$=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(c$);return!t.length&&!e.children?null:s.jsxs("span",{className:pe("meta-line t-meta",e.className),children:[t.map((n,r)=>s.jsxs("span",{children:[r>0&&s.jsx("span",{className:"sep",children:" · "}),s.jsx("span",{className:l$(n)||void 0,title:n.tip,children:n.text})]},r)),e.children]})}function Su(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,r)=>r);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 d$="M25.53 10.5 A11 11 0 1 1 16 5",u$="M20 5 L14.6 1.6 L14.6 8.4 Z";function Nr({variant:e="mark",state:t="ok",size:n=20,className:r="",title:a}){const c=n<=14?3:2.4;return s.jsxs("svg",{className:`scout-mark mm-${e} mm-${t} ${r}`,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:d$,fill:"none",stroke:"currentColor",strokeWidth:c,strokeLinecap:"butt"}),(e==="mark"||e==="action")&&s.jsx("path",{d:u$,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 Bd({parts:e,className:t,as:n="div"}){const r=e.filter(a=>a!=null&&a!==!1&&a!=="");return s.jsx(n,{className:pe("meta",t),children:r.map((a,c)=>s.jsxs("span",{children:[c>0&&" · ",a]},c))})}function nk({items:e,label:t="More actions"}){const[n,r]=y.useState(!1),a=y.useRef(null);return y.useEffect(()=>{if(!n)return;const c=h=>{var f;(f=a.current)!=null&&f.contains(h.target)||r(!1)},d=h=>{h.key==="Escape"&&r(!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:()=>r(!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:()=>{r(!1),c.onSelect()},children:c.label},c.id))})]}):null}const Cp=()=>{const e=document.documentElement.dataset.theme;return e?e==="night":matchMedia("(prefers-color-scheme: dark)").matches};function sk(){const[e,t]=y.useState(Cp);return y.useEffect(()=>{const n=()=>t(Cp()),r=matchMedia("(prefers-color-scheme: dark)");r.addEventListener("change",n);const a=new MutationObserver(n);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{r.removeEventListener("change",n),a.disconnect()}},[]),e}function h$(){const e=()=>window.innerWidth>=1440?"wide":window.innerWidth>=1024?"laptop":"mobile",[t,n]=y.useState(e);return y.useEffect(()=>{const r=()=>n(e());return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),t}const f$=15e3,Tp=["pointerdown","pointermove","keydown","wheel","touchstart"];function m$(e,t,n,r){const[a,c]=y.useState(null),[d,h]=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(r);x.current=r;const C=y.useCallback((_,Y)=>{const re=S.current;return mb({snaps:Object.values(re.allSnaps),decisions:re.decisions,activity:re.activity,ledger:e.activity.ledger,since:q=>{var ye;return _[q]??Y??((ye=re.allSnaps[q])==null?void 0:ye.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},h(!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 Tp)window.addEventListener(q,_,{passive:!0});document.addEventListener("visibilitychange",Y);const re=setInterval(()=>{w.current&&document.visibilityState==="visible"&&N(k.current)},f$);return()=>{for(const q of Tp)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,r]),M=y.useMemo(()=>D?kb(D):"",[D]);y.useEffect(()=>{a&&m(!1)},[a]);let W="none";return f?W="new":d&&(W="seen"),{shown:a!==null,status:W,briefing:D,line:M,open:()=>{const _=g.current;_&&c(_.seen)},dismiss:()=>c(null)}}function p$(e){const[t,n]=y.useState(e.leases.leases);return y.useEffect(()=>e.leases.subscribe(n),[e]),t}const g$="That changed while you were on it, so nothing was written. It is reloaded now: look again, then redo the change.";function v$(e){var Q;const[t,n]=y.useState([]),[r,a]=y.useState(),[c,d]=y.useState(),[h,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=p$(e);y.useEffect(()=>e.monitor.subscribe(C),[e]);const[P,D]=y.useState(null),[M,W]=y.useState(),[_,Y]=y.useState(),re=y.useRef(),q=y.useRef(),ye=y.useRef(new Set),Ie=y.useRef();Ie.current=c;const be=y.useCallback(U=>{re.current=U,a(U),D(null)},[]),[Z]=y.useState(gi),se=y.useCallback(async()=>{var je;const U=Z.start(),E=await e.adapter.listMaps();let F=re.current;const ce=q.current;ce&&E.some(ge=>ge.id===ce)?(q.current=void 0,F=ce,F!==re.current&&be(F)):(!F||!E.some(ge=>ge.id===F))&&(F=(je=dj(E)[0])==null?void 0:je.id,F!==re.current&&be(F));const[he,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(he.map(ge=>[ge.map.id,ge]))),g(Object.fromEntries(E.map((ge,$e)=>[ge.id,we[$e]]))),w(!0),d(he.find(ge=>ge.map.id===F)))},[e,be,Z]);y.useEffect(()=>{let U,E=()=>{},F=()=>{},ce=!0;const he=()=>{clearTimeout(U),U=setTimeout(()=>void se().catch(ve=>W(String(ve))),40)},we=rs(he),je=(ve,Ge)=>mn(ve)&&e.activity.isRemote(ve.id)&&(!Ge||!ve.mapId||ve.mapId===Ge),ge=ve=>{var Ge;return(Ge=Ie.current)==null?void 0:Ge.tickets.find(Rn=>Rn.id===ve)},$e=ve=>{const Ge=F0(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),he()};return e.ready.then(()=>{ce&&(E=e.adapter.subscribe($e),F=e.activity.subscribe(S),e.activity.push({source:"system",level:"ok",text:`Online · tracker ${e.adapter.label.toLowerCase()} · ${e.adapter.location}`}),se().catch(ve=>W(String(ve))))}),()=>{ce=!1,E(),F(),we(),clearTimeout(U)}},[e,se]),y.useEffect(()=>{r&&se().catch(U=>W(String(U)))},[r,se]),y.useEffect(()=>{for(const U of b.sessions)U.mode!=="chart"||!U.mapId||!e.activity.isRemote(U.id)||ye.current.has(U.id)||(ye.current.add(U.id),!(U.status!=="running"&&Date.now()-(U.endedAt??0)>6e4)&&(q.current=U.mapId,se().catch(E=>W(String(E)))))},[b.sessions,e,se]);const Ne=(Q=b.pending[0])==null?void 0:Q.sessionId;y.useEffect(()=>{if(!Ne)return;const U=E=>e.activity.snapshot.sessions.some(F=>F.id===E&&mn(F));Y(E=>U(E)?E:Ne)},[Ne,e]);const me=y.useCallback(async(U,E)=>{e.activity.push({source:"trail lead",agent:Ct,level:"warn",text:U});try{W(void 0),await E()}catch(F){const ce=F.stale===!0,he=ce?g$:F.message??String(F);W(he),e.activity.push({source:"trail lead",agent:Ct,level:"alert",text:`Rejected · ${he}`}),ce&&se().catch(we=>W(String(we)))}},[e,se]),Se=y.useMemo(()=>c1({rt:e,guard:me,setMapId:be,mapIdRef:re,snapRef:Ie,setChatSession:Y,setSelection:D}),[me,e,be]),z=y.useMemo(()=>Object.values(h).flatMap(U=>X0(U,m[U.map.id]??[])).sort((U,E)=>E.decidedAt-U.decidedAt),[h,m]);return{maps:t,allSnaps:h,mapId:r,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 r=setInterval(()=>n(Date.now()),e);return()=>clearInterval(r)},[e]),t}function k$(){const[e,t]=y.useState(xu),n=y.useCallback(r=>{t(a=>{const c={...a,...r};return localStorage.setItem(wa,JSON.stringify(c)),c})},[]);return[e,n]}const ik=()=>{var e,t;return!!((e=pt())!=null&&e.theme)&&!((t=pt())!=null&&t.themeSave)},rk=e=>{var t;return((t=pt())==null?void 0:t.theme)??e};function y$(e){const t=pt();t!=null&&t.themeSave&&(t.theme=e,Ma(e),fetch(t.themeSave,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({theme:e})}).catch(()=>{}))}function w$(){const[e,t]=k$(),[n,r]=y.useReducer(c=>c+1,0);y.useEffect(()=>Ma(rk(e.theme)),[e.theme,n]);const a=y.useCallback(c=>{c.theme&&(y$(c.theme),r()),t(c)},[t]);return[e,a]}function $r(){return y.useSyncExternalStore(ns.subscribe,ns.get)}function x$({className:e,size:t=18}){return s.jsx("span",{className:e,"aria-hidden":"true",children:s.jsx(Wv,{size:t,variant:sk()?"night":"crt"})})}function Fe({as:e="section",className:t,style:n,frameless:r,children:a,...c}){return s.jsx(e,{className:pe("panel",r&&"frameless",t),style:n,...c,children:a})}function wi({tone:e,className:t,children:n,title:r}){return s.jsx("span",{className:pe("pill",e,t),title:r,children:n})}function Cn({label:e,value:t,layout:n="stack",urgent:r,title:a,className:c}){return s.jsxs("span",{className:pe("readout",n!=="stack"&&n,r&&"urgent",c),title:a,children:[s.jsx("span",{className:"mono-label",children:e}),n==="inline"&&" ",s.jsx("b",{children:t})]})}function fe(e){const{as:t="div",edge:n="neutral"}=e,r=e.onOpen?"button":"div";return s.jsxs(t,{className:pe("ds-row",`edge-${n}`,e.selected&&"on",e.className),children:[s.jsxs(r,{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",j$={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 ok({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:j$[e]})}function yt({title:e,count:t,right:n,hot:r,sub:a,children:c,className:d,info:h,icon:f}){return s.jsxs("header",{className:pe("sec-h",a&&"sub",d),children:[c,f&&s.jsx(ok,{name:f}),e!==void 0&&s.jsx(Ke,{as:a?"h3":"h2",hot:r,children:e}),h&&s.jsx(ki,{text:h}),t,n!==void 0&&s.jsx("span",{className:"sec-h-right",children:n})]})}function rt(e){const{value:t,options:n,onChange:r}=e,[a,c]=y.useState(!1),[d,h]=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,W;D.target instanceof Node&&((M=k.current)!=null&&M.contains(D.target)||(W=g.current)!=null&&W.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=()=>{h(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&&r(P.value)},C=N=>{if(!a){["ArrowDown","ArrowUp","Enter"," "].includes(N.key)&&(N.preventDefault(),S());return}const P=D=>h(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")h(0);else if(N.key==="End")h(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&&h(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:()=>h(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 b$=350;function S$(){const[e,t]=y.useState(null);if(y.useEffect(()=>{let r=0,a=null;const c=()=>{window.clearTimeout(r),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")})},h=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=h(g);k!==a&&(c(),k&&(a=k,r=window.setTimeout(()=>a===k&&d(k),g.type==="focusin"?0:b$)))},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 r=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:r,top:e.y,transform:e.above?"translateY(-100%)":void 0},children:[s.jsx(Ea,{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 Fa({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 N$(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 $$=864e5;function C$(e,t){const n=new Date(e),r=n.toTimeString().slice(0,5),a=new Date(t).toDateString(),c=new Date(t-$$).toDateString();let d=` ${n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`;return n.toDateString()===a?d="":n.toDateString()===c&&(d=" yesterday"),`Since ${r}${d} · ${Gt(t-e)}`}function T$(e){const{briefing:t,bp:n,onClose:r}=e;y.useEffect(()=>{const k=w=>w.key==="Escape"&&r();return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[r]);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,h=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=Wb(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:h?[]: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:h?[]:S},"agent"),s.jsx(ni,{title:"Active sessions",children:h?[]: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:r,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:C$(t.since,t.now)}),s.jsx("button",{className:"icon-btn",onClick:r,"aria-label":"Close",children:"×"})]}),s.jsxs(Vt,{className:"bf-scout",children:[s.jsx(Ea,{size:h?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:E$(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:`${Ra(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:r,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 E$(e){if(e!==void 0)return e<6e4?"Just asked":`Oldest ${Gt(e)}`}function A$(e){const{brief:t,bp:n}=e;return t.shown?s.jsx(T$,{briefing:t.briefing,line:t.line,snaps:e.snaps,bp:n,onClose:t.dismiss,onTicket:(r,a)=>{t.dismiss(),e.openTicket(r,a)},onAnswer:r=>{t.dismiss(),e.openQuestion(r.id)},onSession:r=>{t.dismiss(),e.openChat(r.id,r.ticketId,r.mapId)},onDecision:r=>{t.dismiss(),e.openDecisions(r)},onResume:()=>{t.dismiss(),e.toMap()}}):null}function ak(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 ck(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(r=>s.jsx(I,{size:"sm","data-tip":r.tip,disabled:e.busy,onClick:r.onSelect,children:r.label},r.id)),s.jsx(nk,{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 R$(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})})),r={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:[r,...n.slice(0,1),a],menu:[...n.slice(1),pr(t)]}}function M$(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})})),r=e.choices.proceed?[{id:"unmark",label:"Unmark known failures",onSelect:()=>t.choose({kind:"undo-proceed"})}]:[];return[pr(t),...n,...r]}function I$(e,t){const{state:n}=e;switch(n.kind){case"off":case"not-run":return{buttons:[],menu:[]};case"running":{const r={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:[r]}:{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 R$(n.failing,t);const r={id:"choose",label:"Choose again",onSelect:()=>t.choose({kind:"undo-fix-main"})};return{buttons:[pr(t,"Run again")],menu:[r]}}case"accepted":return{buttons:[],menu:M$(e,t)};default:return n}}const Fd=e=>e.join(", "),O$=e=>`${Fd(e)} ${e.length===1?"fails":"fail"} on main`;function L$(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 P$(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:O$(e.failing),why:D$(e.fixing,t)};case"accepted":return{edge:"attention",title:_$(e.known,e.dropped)};default:return e}}function D$(e,t){return e?"Waiting for main to be fixed":t?"Implementation waits for you":void 0}function _$(e,t){return[e.length?`Known failures on main: ${Fd(e)}`:"",t.length?`Dropped for this trail: ${Fd(t)}`:""].filter(Boolean).join(" · ")}function B$(e){const t=e==null?void 0:e.checks.find(r=>!r.passed),n=t==null?void 0:t.tail.split(`
138
+ `).filter(r=>r.trim());return n==null?void 0:n.at(-1)}function lk(e,t){const n=P$(e.state,e.holds),r=n.detail??(e.state.kind==="failed"?B$(e.run):void 0);return{edge:n.edge,title:n.title,context:[...n.why?[n.why]:[],...L$(e.run,t)],...r?{detail:r}:{}}}const F$=e=>{try{return JSON.parse(e)}catch{return}};function dk(e){const t=gi();let n=!1;const r=()=>{const h=t.start();e.load().then(f=>!n&&h()&&e.show(f),()=>{var f;return!n&&h()&&((f=e.failed)==null?void 0:f.call(e))})},{changed:a,events:c={}}=e,d=[rs(r),...a?[Da(h=>a(h)&&r())]:[],...Object.entries(c).map(([h,f])=>vi(h,m=>f(F$(m))&&r()))];return r(),{reload:r,pushed:()=>t.pushed(),stop:()=>{n=!0;for(const h of d)h()}}}function Le(e){const t=y.useRef(e);t.current=e;const n=y.useRef(),r=y.useRef(e.version),{view:a,version:c}=e;y.useEffect(()=>{const f=t.current;r.current=f.version;const m=Object.keys(f.events??{}),g=dk({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(r.current,c)||(r.current=c,(f=n.current)==null||f.reload())},[c]);const d=y.useCallback(()=>{var f;return(f=n.current)==null?void 0:f.reload()},[]),h=y.useCallback(()=>{var f;return(f=n.current)==null?void 0:f.pushed()},[]);return{reload:d,pushed:h}}async function za(e){return e?e.ok?void 0:(await e.json().catch(()=>({}))).error??`HTTP ${e.status}`:"Could not reach the Lookout"}const uk=()=>`${ae()}/main-checks`,z$=(e,t)=>fetch(`${uk()}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).catch(()=>{});function Nu(e){const[t,n]=y.useState(),[r,a]=y.useState(),[c,d]=y.useState(!1),{reload:h,pushed:f}=Le({view:e,load:async()=>{if(!e)return;const g=await fetch(`${uk()}?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 z$(g,k);d(!1);const b=await za(w);if(a(b),b)return h();g==="/choose"?(f(),n(await w.json())):h()};return{view:t,error:r,busy:c,choose:g=>m("/choose",{mapId:e,choice:g}),run:()=>m("/run",{mapId:e})}}function hk(e){var d;const t=Nu(e.mapId),n=t.view;if(!n||n.state.kind==="off")return null;const r=lk(n,e.now),a=I$(n,{choose:h=>void t.choose(h),run:()=>void t.run()}),c=((d=n.run)==null?void 0:d.checks.filter(h=>!h.passed))??[];return s.jsxs(sn,{label:"Checks on main",className:"main-checks",children:[s.jsx(fe,{edge:r.edge,title:r.title,context:s.jsx(B,{parts:r.context}),detail:r.detail,detailText:r.detail,below:s.jsx(ck,{actions:a,busy:t.busy,error:t.error})}),c.length>0&&s.jsx(ak,{checks:c})]})}function U$(e){const t=Nu(e.mapId),n=gt(3e4),r=t.view;if(!r)return null;const a=lk(r,n),c=r.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||r.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 W$(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 rd=e=>({id:"run",label:"Run again",tip:"Run the approved checks on the default branch with every merge now",onSelect:e.run}),H$=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 K$(e,t){const{state:n,run:r}=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:()=>r&&t.fixTicket(r.id)},rd(t)],menu:[]};case"unavailable":return{buttons:[rd(t)],menu:[]};case"passed":return{buttons:[],menu:[rd(t)]};case"waiting":return{buttons:[],menu:[H$(t)]};default:return n}}function Ep(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 G$(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 r=e.failing.length===1?"fails":"fail";return{edge:"urgent",title:`${e.failing.join(", ")} ${r} 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 V$=["passed","failed","running","unavailable"],q$={pass:"passed",fail:"failed",running:"running",unavailable:"couldn't run"};function Q$(e,t){const n=e.run;if(!n)return[];if(V$.includes(e.state.kind))return Ep(n,t,e.state.kind==="passed");const r=n.complete?"":", before everything was merged";return[`Last run ${q$[n.result]}${r}`,...Ep(n,t)]}function Y$(e,t){const n=G$(e.state,e.run);return{edge:n.edge,title:n.title,context:Q$(e,t),...n.detail?{detail:n.detail}:{}}}const fk=()=>`${ae()}/trail-checks`,J$=(e,t)=>fetch(`${fk()}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).catch(()=>{});function mk(e){const[t,n]=y.useState(),[r,a]=y.useState(),[c,d]=y.useState(!1),{reload:h}=Le({view:e,load:async()=>{if(!e)return;const m=await fetch(`${fk()}?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 J$(m,g);d(!1),a(await za(k)),h()};return{view:t,error:r,busy:c,run:()=>f("/run",{mapId:e}),fixTicket:m=>f("/fix-ticket",{mapId:e,runId:m})}}function pk(e){var f;const t=mk(e.mapId),n=t.view,r=(n==null?void 0:n.state.kind)==="failed",{onUrgent:a}=e;if(y.useEffect(()=>a==null?void 0:a(r),[a,r]),!n||n.state.kind==="off")return null;const c=Y$(n,e.now),d=K$(n,{run:()=>void t.run(),fixTicket:m=>void t.fixTicket(m)}),h=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(fe,{edge:c.edge,title:c.title,context:s.jsx(B,{parts:c.context}),detail:c.detail,detailText:c.detail,below:s.jsx(ck,{actions:d,busy:t.busy,error:t.error})}),h.length>0&&s.jsx(ak,{checks:h})]})}const X$="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.",gk=()=>{var e;return((e=pt())==null?void 0:e.highRisk)===!1};function Z$(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 vk(e){const{pending:t}=e;return t!=null&&t.lookoutOnly&&gk()?s.jsx("p",{className:"vf-intro",children:X$}):s.jsxs(s.Fragment,{children:[s.jsx(Z$,{options:t==null?void 0:t.suggestions,onPick:e.onSend}),s.jsx(Ba,{ref:e.inputRef,className:"comms-input",value:e.draft,onValueChange:e.onDraft,onSubmit:e.onSend,disabled:!t,placeholder:t?"Answer":""})]})}const eC=["awaiting","blocked","trail.done","resolved"];async function Xn(e,t="GET",n){const r=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:n===void 0?void 0:JSON.stringify(n)}),a=await r.json().catch(()=>({}));if(!r.ok&&!a.status)throw new Error(a.error??`request failed (${r.status})`);return a}function tC(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=tC(ae());function nC(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 sC=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function iC({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 ",sC(e.at),"). ",e.message]})}function zd(e){const[t,n]=y.useState(!1),r=()=>{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:r,children:e.again?"Add Scout to Slack again":"Add Scout to Slack"})}function rC(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(zd,{again:!0,onError:e.onError})]})}function oC({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 aC(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 Ap({onRemoved:e}){const[t,n]=y.useState(!1);if(!t)return s.jsx(I,{size:"sm",variant:"ghost",onClick:()=>n(!0),children:"Disconnect"});const r=()=>void Tn.disconnect().then(a=>{n(!1),e(a)},()=>{});return s.jsxs(s.Fragment,{children:[s.jsx(I,{size:"sm",variant:"danger",onClick:r,children:"Disconnect and forget Slack settings"}),s.jsx(I,{size:"sm",variant:"ghost",onClick:()=>n(!1),children:"Keep"})]})}function cC(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(zd,{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(aC,{small:!0,href:t.links.homeWeb,children:"Open Scout in Slack"}),s.jsx(Ap,{onRemoved:e.onChanged})]}):s.jsxs("div",{className:"c-actions",children:[!e.busy&&s.jsx(zd,{again:t.legacy,onError:e.onError}),t.legacy&&s.jsx(Ap,{onRemoved:e.onChanged})]})}const lC={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function dC({s:e}){const[t,n]=uC(e);return s.jsxs("div",{className:`sync-line ${t}`,title:e.error,children:[s.jsx("span",{className:"dot"}),s.jsx("span",{children:n})]})}function uC(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 hC(e){const{s:t,back:n}=e,r=!!n.confirm&&!t.connected;return s.jsxs(Vt,{className:mC(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:fC(t)}),t.connected&&s.jsx(dC,{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(iC,{problem:t.delivery}),t.connected&&t.mentions===!1&&!r&&s.jsx(rC,{onError:e.onError}),!t.connected&&!r&&s.jsx(oC,{s:t,connecting:n.busy}),r&&s.jsx(nC,{who:n.confirm,onConnect:n.connect,onCancel:n.cancel}),e.error&&s.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]}),!r&&s.jsx(cC,{s:t,busy:n.busy,onError:e.onError,onChanged:e.onChanged,onToggle:e.onToggle})]})}function fC(e){var n,r,a;const t=(r=(n=e.workspace)==null?void 0:n.url)==null?void 0:r.replace(/^https?:\/\/|\/$/g,"");return[(a=e.workspace)==null?void 0:a.name,t].filter(Boolean).join(" · ")}function mC(e){const t=e.connected&&e.enabled?"active":"",n=e.connected?"":"open";return`connector ${t} ${n}`}function pC(e){const[t,n]=y.useState(e.value==="dm"?"":e.value),r=/^[CG][A-Z0-9]{6,}$/.test(t.trim());return s.jsxs("form",{className:"sl-field",onSubmit:a=>{a.preventDefault(),r&&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:!r||t.trim()===e.value,children:"Save"})]})}function gC(e){const[t,n]=y.useState(),[r,a]=y.useState();y.useEffect(()=>{Tn.members().then(n,h=>a(h.message))},[]);const c=new Set(e.owners.map(h=>h.id)),d=new Set(e.value.map(h=>h.id));return r?s.jsxs("div",{className:"test-line alert",children:["✕ ",r]}):t?s.jsx("div",{className:"choice-row compact sl-members",children:t.map(h=>s.jsx(ct,{on:c.has(h.id)||d.has(h.id),disabled:c.has(h.id),title:`@${h.name??h.id}`,sub:c.has(h.id)?"Owner":void 0,onClick:()=>e.onChange(d.has(h.id)?e.value.filter(f=>f.id!==h.id):[...e.value,h])},h.id))}):s.jsx("span",{className:"t-meta",children:"Loading members…"})}function vC(e){const{s:t,patch:n}=e,[r,a]=y.useState(!1),c=new Set(t.notify.events),d=r||t.notify.target!=="dm",h=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:["@",(h==null?void 0:h.name)??(h==null?void 0:h.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(gC,{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(pC,{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:eC.map(m=>s.jsx(ct,{on:c.has(m),title:lC[m],onClick:()=>f(m)},m))})]}),s.jsx(Bd,{className:"dim",parts:[`${t.command} decide`,`${t.command} status`,`${t.command} inbox`,"Save as decision on any message"]})]})}function kC(){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 od={code:kC()};function yC(e){const[t,n]=y.useState(),[r,a]=y.useState(),[c,d]=y.useState(),[h,f]=y.useState(!!od.code),m=k=>d(k.message);y.useEffect(()=>{const k=od.code;k&&(od.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:h,error:c,confirm:r,connect:()=>t&&g(Tn.connectFinish(t)),cancel:()=>g(Tn.connectCancel())}}function $u(e=0){const[t,n]=y.useState(),r=y.useCallback(()=>Tn.get().then(n,()=>n(null)),[]);return y.useEffect(()=>{if(r(),!e)return;const a=setInterval(()=>void r(),e);return()=>clearInterval(a)},[r,e]),[t,n]}function wC(e){const[t,n]=$u(3e3),r=yC(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 h=f=>Tn.update(f).then(n,()=>{});return s.jsxs("div",{ref:d,className:"slack-settings",children:[s.jsx(hC,{s:t,back:r,error:a??r.error,onError:c,onToggle:()=>void h({enabled:!t.enabled}),onChanged:f=>{c(void 0),n(f)}}),t.connected&&s.jsx(vC,{s:t,patch:f=>void h(f)})]})}function xC(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 Rp;function jC(){return Rp??(Rp=Tn.get().then(e=>({owners:e.owners??[],allow:e.allow??[]}),()=>{})),Rp}function Cr(){const[e,t]=y.useState();return y.useEffect(()=>{let n=!0;return jC().then(r=>n&&t(r)),()=>{n=!1}},[]),e}function bC(e){const{m:t}=e,n=Cr(),r=t.from==="human"?"human":"agent";return s.jsxs("div",{className:`msg from-${t.from} voice-${r}`,children:[s.jsx(B,{parts:[fi(t.author,n),a0(t),Aa(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 SC(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 NC({id:e,text:t}){const[n,r]=y.useState(),a=n!==e;return s.jsx(Ea,{size:.6,framed:!1,state:a?"speaking":"alert",speaking:a?t.slice(0,60):void 0,onSpeakEnd:()=>r(e),className:"q-avatar"})}function $C(e){const{q:t}=e;return s.jsxs("div",{className:"msg open-q",children:[s.jsx(B,{parts:[t.agent,Aa(t.at)]}),s.jsx(NC,{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 CC(e){const{activity:t,sessionId:n}=e,[r,a]=y.useState(""),[c,d]=y.useState(),h=y.useRef(null),f=y.useRef(null),m=t.sessions.find(D=>D.id===n),g=t.chats.filter(D=>D.sessionId===n),k=n$(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=h.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=TC(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(SC,{ticket:C,trail:x==null?void 0:x.map.title,agent:m.agent}),s.jsx("div",{className:"comms-log",ref:h,children:S.map(D=>s.jsx(bC,{m:D,stillOpen:!!D.questionId&&w.has(D.questionId),onAnswerThis:()=>d(D.questionId)},D.id))}),k&&s.jsx($C,{q:k,chatId:b==null?void 0:b.id}),s.jsx(vk,{pending:k,draft:r,onDraft:a,onSend:N,inputRef:f})]}):s.jsx(Ee,{children:"No conversation"})]})}function TC(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 EC(e){const[t,n]=e.ref.split("+"),r=await fetch(`${ae()}/workspaces/integration`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,a:t,b:n})});return r.ok?void 0:(await r.json().catch(()=>({}))).error??`Adding failed (${r.status})`}function AC({item:e}){const[t,n]=y.useState(!1),[r,a]=y.useState(),c=()=>{n(!0),a(void 0),EC(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"}),r&&s.jsx("span",{className:"vf-err",children:r})]})}async function RC(e,t){const n=e.ref.slice(0,e.ref.lastIndexOf(":")),r=await fetch(`${ae()}/trackers/settings/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,issueId:n,choice:t})});return r.ok?void 0:(await r.json().catch(()=>({}))).error??`Saving failed (${r.status})`}function MC({item:e}){const[t,n]=y.useState(!1),[r,a]=y.useState(),c=d=>{n(!0),a(void 0),RC(e,d).then(a,h=>a(h.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"}),r&&s.jsx("span",{className:"vf-err",children:r})]})}function IC({item:e}){return e.kind==="integration"?s.jsx(AC,{item:e}):e.kind==="tracker-settings"&&e.ref.includes(":")?s.jsx(MC,{item:e}):null}const OC=/(\S*\/\S*|#\d+)/g;function LC({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(OC).map((r,a)=>a%2===1?s.jsx("span",{className:"t-code",children:r},a):r)]},t))}):null}const Cu={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"},PC={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"},DC=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],_C=["blocked","flag","stalled","policy","reroute","overlap","integration","model"];function Tr(e,t){return t||e.urgency==="blocking"?"urgent":_C.includes(e.kind)?"attention":"neutral"}const BC=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function Tu(e){return e.reasons.filter(t=>!BC.some(n=>n.test(t)))}function kk(e){const{item:t,snap:n}=e,r=n==null?void 0:n.tickets.find(h=>h.id===t.ticketId),a=t.kind==="question"&&t.agent?`${t.agent} asks`:Cu[t.kind],c=[];t.urgency==="blocking"&&c.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),c.push({text:a,strong:!0});const d=r&&FC(t.title,r);return d&&c.push(d),e.otherTrail&&c.push((n==null?void 0:n.map.title)??t.mapId),c}function FC(e,t){if(!e.includes(t.key))return e.includes(t.title)?{text:t.key,code:!0}:`${t.key} ${t.title}`}function zC(e){const[t,n]=y.useState(!1),r=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:[DC.map(a=>s.jsx("button",{type:"button",role:"menuitem",onClick:()=>r(()=>e.onSnooze(a.minutes)),children:a.label},a.minutes)),e.canDismiss&&s.jsx("button",{type:"button",role:"menuitem",onClick:()=>r(e.onDismiss),children:"Set aside"})]})]})}const UC=15e3;function WC(e){const{item:t}=e,n=t.title.split(`
139
+ `)[0],r=Tu(t),a=e.now-t.since<UC;return s.jsx(fe,{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:kk({item:t,snap:e.snap,otherTrail:e.otherTrail})}),detail:r.length>0&&s.jsx(LC,{reasons:r}),detailText:r.join(`
140
+ `),trailing:Xe(e.now-t.since),onOpen:e.onOpen,actions:s.jsx(zC,{title:t.title,canDismiss:Gb(t),onSnooze:e.onSnooze,onDismiss:e.onDismiss}),below:s.jsx(IC,{item:t})})}function HC(e){const t=[];for(const n of e){const r=t.at(-1);(r==null?void 0:r.key)===n.batchKey?r.items.push(n):t.push({key:n.batchKey,kind:n.kind,mapId:n.mapId,items:[n]})}return t}const KC={question:"inbox-list",approval:"inbox-list approvals"};function GC(e){const{batch:t}=e,n=t.items.length>1,r=t.kind==="question"?"answer together":"review together",a=[`${t.items.length} ${PC[t.kind]}`,e.trail,r].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 ${KC[t.kind]??""}`,children:e.children})]})}function ad(e,t){e.ticketId?t.openTicket(e.mapId,e.ticketId):t.selectTrail(e.mapId)}const VC=new Set(["approval","blocked","policy","precedent","flag","stalled","hitl-ready","overlap","integration","model","tracker-settings"]);function Eu(e,t){if(VC.has(e.kind))return ad(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):ad(e,t);default:return ad(e,t)}}function yk(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 r=Object.keys(e.snaps).length>1,a=h=>r&&h!==e.currentMapId,c=new Set(n.interrupting),d=h=>{var f;return(f=e.pending.find(m=>m.id===h))==null?void 0:f.sessionId};return s.jsx("div",{className:"attention-queue",children:HC(n.items).map(h=>{var f;return s.jsx(GC,{batch:h,trail:a(h.mapId)?(f=e.snaps[h.mapId])==null?void 0:f.map.title:void 0,children:h.items.map(m=>s.jsx(WC,{item:m,snap:e.snaps[m.mapId],otherTrail:a(m.mapId)&&h.items.length<2,selected:m.kind==="question"&&d(m.ref)===e.selected,interrupting:c.has(m.id),now:t,onOpen:()=>Eu(m,e.handlers),onSnooze:g=>e.onSnooze(m.id,g),onDismiss:()=>e.onDismiss(m.id)},m.id))},h.key)})})}const qC={passed:"checks passed",failing:"checks failing",pending:"checks pending",unknown:"checks unknown",none:"no checks"};function QC({mapId:e,ticketId:t}){const n=ns.ticket($r(),e,t);if(!n)return null;const r=n.pr;return s.jsx("div",{className:"pr-flags",children:s.jsxs("span",{className:`pr-chip pr-${(r==null?void 0:r.state)??"unread"}`,title:r?`${r.title}
141
+ ${r.headRef}`:void 0,children:[r?s.jsxs("a",{href:pn(r.url),target:"_blank",rel:"noreferrer noopener",children:["PR #",r.number," · ",r.state,r.draft?" · draft":""]}):`PR #${n.link.number}`,s.jsx("span",{className:`ci ci-${n.checksSummary}`,children:qC[n.checksSummary]}),s.jsx("span",{className:"when",children:YC(n)})]})})}function YC(e){return e.error?"sync failed":e.syncedAt?Gv(e.syncedAt):"not synced yet"}const JC={ok:"ok",failed:"error",stale:"syncing",unknown:"idle",off:"idle"};function XC({now:e}){const t=$r();if(!t.reached)return null;const n=P0(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:JC[n.tone],size:13,className:"sync-glyph"}),s.jsx("span",{className:"tl",children:n.label})]})}function Ua(e){const t=e.role??"menu",[n,r]=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)))&&r(!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:()=>r(!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(()=>r(!1))})]})}function ZC(){const e=pt();if(!e)return null;const t=(n,r)=>{r(),location.assign(n)};return s.jsx(Ua,{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(r=>s.jsx("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(r.href,n),children:r.label},r.href)),e.signOut&&s.jsx("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(e.signOut,n),children:"Sign out"})]})})}const eT={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 tT(e){const t=e.briefingStatus==="new";return s.jsx(Ua,{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:eT[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},wk=()=>{const e=Ot();e&&location.assign(e.href)},xk=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)}:{}}},Wa=()=>{var e;return(e=pt())==null?void 0:e.trailAgents};async function nT(e){const t=Wa();if(!t)return;const n=await fetch(`${t}?trail=${encodeURIComponent(e)}`).catch(()=>{});return n!=null&&n.ok?xk(await n.json().catch(()=>{})):void 0}const Ud="teamtrail:trail-agents";async function sT(e,t){const n=Wa();if(!n)return{error:"This Lookout doesn't run agents."};const r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trail:e,...t})}).catch(()=>{}),a=await(r==null?void 0:r.json().catch(()=>{})),c=r!=null&&r.ok?xk(a):void 0;return c&&window.dispatchEvent(new Event(Ud)),c??{error:typeof(a==null?void 0:a.error)=="string"?a.error.slice(0,200):"The server didn't answer."}}function Ha({command:e,label:t="Copy"}){const[n,r]=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(()=>{r(!0),setTimeout(()=>r(!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"}],iT=9e3;function rT(){const[e,t]=y.useState(0),[n,r]=y.useState(!1);y.useEffect(()=>{if(n)return;const c=setInterval(()=>t(d=>(d+1)%Vo.length),iT);return()=>clearInterval(c)},[n]);const a=Vo[e];return s.jsxs("div",{className:"command-bar real",children:[s.jsx(ok,{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:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>r(!0),onBlur:()=>r(!1),children:[s.jsx("span",{className:"dim",children:a.text}),a.command&&s.jsx(Ha,{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 oT(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 jk(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 bk({agents:e,onStarted:t}){const{state:n,busy:r,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())),h=Ot();return n.on?s.jsxs("span",{className:"start-trail",children:[s.jsx("span",{className:"start-trail-status",children:jk(n)}),s.jsx(I,{size:"sm",variant:"ghost",disabled:r,onClick:()=>void e.act(!1),children:"Pause"}),h&&s.jsx("a",{className:"t-meta",href:`${h.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:r||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 Sk(e){const[t,n]=y.useState(),[r,a]=y.useState(),[c,d]=y.useState(!1),[h,f]=y.useState();return y.useEffect(()=>{let g=!0;const k=()=>void nT(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:h,repo:r,setRepo:a,act:async g=>{d(!0),f(void 0);const k=await sT(e,{on:g,...g&&r?{repo:r}:{}});return d(!1),"error"in k?(f(k.error),!1):(n(k),g)}}}function aT({mapId:e,onStarted:t}){return s.jsx(bk,{agents:Sk(e),onStarted:t})}function cT({created:e,mapId:t,onStarted:n}){if(Wa())return s.jsxs("div",{className:"agent-draft created",children:[s.jsxs("span",{children:["Trail ",e," is on the map, starting with discovery."]}),s.jsx(aT,{mapId:t,onStarted:n})]});const r=Ot();return r?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:wk,children:r.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(Ha,{command:"/scout resume",label:"Copy command"})]})}function lT({seed:e,onClose:t,tracker:n,onCreate:r}){const[a,c]=y.useState(),[d,h]=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(Ha,{command:`/scout new "${P||"your idea"}"`,label:"Copy command"})]}),a?s.jsx(cT,{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:()=>{h(!0);const D=C.split(`
143
+ `).map(M=>M.trim());r({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(()=>h(!1))},children:"Create trail"})]})]})})}const dT=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 uT({mapId:e}){const t=Sk(e),{state:n}=t;if(!(n!=null&&n.on))return s.jsx(bk,{agents:t});const r=Ot();return s.jsxs(s.Fragment,{children:[s.jsx(Ua,{className:"agents-menu",label:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:n.running?"agents-dot on":"agents-dot","aria-hidden":"true"}),jk(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"}),r&&s.jsx("a",{role:"menuitem",className:"header-menu-item",href:`${r.href}#trail-${encodeURIComponent(e)}`,children:"Runs"})]})}),t.error&&s.jsx("span",{className:"vf-err",children:t.error})]})}function hT({mapId:e}){if(Wa())return s.jsx(uT,{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 fT=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"})]}),mT=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 pT({onToggle:e}){const t=sk(),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?fT:mT})})}const gT={idle:"Idle",syncing:"Syncing",ok:"Synced",error:"Sync error"};function vT({label:e,health:t,now:n}){if(t.status!=="error")return null;const r=[`${gT[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:r,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 Mp={"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 kT(e){const{map:t}=e,[n,r]=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:Mp[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:Mp[n].confirm}),s.jsx(I,{onClick:()=>r(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:()=>r("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:()=>r("archive"),children:["Archive ",t.key,"…"]})]})}function yT(e){const{map:t}=e.snap,n=H0(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(xs,{n:e.waiting,urgent:!!e.waiting,hideZero:!0})]})}function wT(e){var g;const[t,n]=y.useState(!1),r=y.useRef(null);y.useEffect(()=>{if(!t)return;const k=w=>{var b;(w instanceof KeyboardEvent?w.key==="Escape":!((b=r.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),h=k=>e.activity.pending.filter(w=>w.mapId===k).length,f=e.activity.pending.filter(k=>{var w;return k.mapId!==((w=e.map)==null?void 0:w.id)}).length,m=k=>{var w;return s.jsx(yT,{snap:k,on:k.map.id===((w=e.map)==null?void 0:w.id),waiting:h(k.map.id),onSelect:()=>{e.onSelectMap(k.map.id),n(!1)}},k.map.id)};return s.jsxs("div",{className:"trail-switcher",ref:r,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(xs,{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(kT,{map:e.map,onStartOver:e.onStartOver,onArchive:e.onArchive,onToggleMode:e.onToggleMode,onDone:()=>n(!1)})})]})]})}function xT(e){const{map:t}=e,n=gt(1e3),r=e.activity.pending.length,a=t&&e.snaps[t.id],c=t&&mv(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(wT,{...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(vT,{label:e.trackerLabel,health:e.health,now:n}),s.jsx(XC,{now:n}),t&&a&&s.jsxs("span",{className:"trail-meta",children:[s.jsx(Cn,{label:"Trail T+",value:Kv(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)} · ${Ra(c.inputTokens+c.outputTokens)} tok`,title:["Model spend and tokens for this trail, across every session",...gv(e.activity,t.id).map(d=>pv[d].text)].join(`
145
+ `)})]}),e.views,e.attention,e.needs,!e.attention&&!e.needs&&r>0&&s.jsxs("span",{className:"waiting-chip",title:`${r} waiting on you`,children:[s.jsx(Nr,{variant:"alert",size:14}),s.jsx("b",{children:r}),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(hT,{mapId:t.id}),s.jsx(tT,{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"}),ik()?null:s.jsx(pT,{onToggle:e.onToggleTheme}),s.jsx(ZC,{})]})]})}function jT(e){const{count:t,elsewhere:n}=e,r=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 · ${r}`,onClick:e.onOpen,children:"On other trails"});const a=`${t} need${t===1?"s":""} you`,c=[e.top&&`Most urgent: ${e.top}`,r].filter(Boolean).join(" · ");return s.jsx(I,{variant:"urgent",className:"needs-btn","data-tip":c,"aria-label":r?`${a} on this trail, ${r}`:a,onClick:e.onOpen,children:a})}function bT(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 Ip={label:"Focus for 1 hour",change:{kind:"for",minutes:60}};function ST(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},Ip];case"off":return[{...Ip,primary:!0},{label:"Focus for 3 hours",change:{kind:"for",minutes:180}}];default:return e}}const Op=e=>Aa(e).slice(0,5),NT=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function $T(e){const t=`${e.items.length} waiting on you`;return e.heldBack===0?`Nothing held back · ${t}`:`${NT(e.heldBack,"item")} would interrupt you · ${t}`}function cd(e){const t=e.prefs.focus;return t?`Quiet hours ${t.from}–${t.to}`:"No quiet hours set"}const Lp=e=>`Items scoring ${e.policy.value.interrupt} or more interrupt you · ${e.items.length} waiting on you`;function CT(e){const t=e.focus;switch(t.kind){case"manual":case"hours":{const n=Op(t.until),r=t.kind==="manual"?"Switched on here":cd(e);return{word:"on",until:n,on:!0,title:`Focus is on until ${n}`,reason:r,detail:$T(e)}}case"paused":{const n=Op(t.until),r=`Quiet hours paused until ${n}`;return{word:"paused",until:n,on:!1,title:r,reason:cd(e),detail:Lp(e)}}case"off":return{word:"off",until:"",on:!1,title:"Focus is off",reason:cd(e),detail:Lp(e)};default:return t}}const TT="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 ET(e){const{view:t}=e,n=CT(t),r=t.focus.kind,a=s.jsxs("span",{className:pe("focus-state",`focus-${r}`),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(Ua,{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:TT})]}),s.jsx(B,{parts:[n.reason]}),s.jsx(B,{className:"focus-held",parts:[n.detail]}),s.jsxs("div",{className:"focus-panel-actions",children:[ST(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 AT(e){return s.jsx("span",{className:"attention-head",children:s.jsx(ET,{view:e.view,onChange:e.onFocus,onSettings:e.onSettings})})}const Nk=`${ae()}/attention`,RT=250;async function ld(e,t,n){var c;const r=await fetch(`${Nk}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),a=await r.json().catch(()=>({}));if(!r.ok)throw new Error(((c=a.errors)==null?void 0:c.join("; "))??a.error??`HTTP ${r.status}`);return a}function $k(e){const[t,n]=y.useState(),[r,a]=y.useState(),[c]=y.useState(gi),d=y.useCallback(()=>{const m=c.start();fetch(Nk).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(()=>rs(d),[d]),y.useEffect(()=>{const m=setTimeout(d,RT);return()=>clearTimeout(m)},[d,e]);const h=m=>m.then(()=>(a(void 0),d(),!0),g=>(a(g.message),!1)),f=(m,g)=>void ld(m,"POST",g).then(()=>(a(void 0),d()),k=>a(k.message));return{view:t,error:r,snooze:(m,g)=>f("/snooze",{id:m,minutes:g}),dismiss:m=>f("/dismiss",{id:m}),savePrefs:m=>h(ld("/prefs","PUT",m)),saveReviewLimit:m=>h(ld("/review-limit","PUT",{limit:m}))}}function MT(e){return e.prefs.channel!=="browser"?!1:typeof Notification<"u"&&Notification.permission==="granted"}function IT(e){const t=new Notification(`${J.name} · needs you`,{body:e.title,tag:e.id});t.onclick=()=>{window.focus(),t.close()}}function OT(e){const t=y.useRef();y.useEffect(()=>{if(!e)return;const n=new Set(e.interrupting),r=t.current;if(t.current=n,!(!r||!MT(e)))for(const a of e.items)n.has(a.id)&&!r.has(a.id)&&IT(a)},[e])}const LT={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"},PT={"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 DT(e){return LT[e.kind]??"needs you"}function dd(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$/,""):PT[e.kind]??Cu[e.kind]}function _T(e,t){const n=e.ticketId?t(e.ticketId):void 0;return e.kind==="main-checks"?`main: ${dd(e)}`:n?`${n} ${dd(e)}`:dd(e)}function BT(e){const t=gt(1e3);return e.items.length?s.jsx("ul",{className:"inbox-list approvals",children:e.items.map(n=>{var c;const r=n.kind!=="approve",a=n.mapId!==e.currentMapId?(c=e.snaps[n.mapId])==null?void 0:c.map.title:void 0;return s.jsx(fe,{as:"li",edge:r?"attention":"neutral",title:`${r?"Decide":"Approve"}: ${n.title}`,context:s.jsx(B,{parts:[r?"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 Pp({activity:e}){const t=gt(1e3),n=V0(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 FT(e){const t=gt(1e3);return e.items.length?s.jsx("ul",{className:"inbox-list",children:e.items.map(n=>{const r=e.snaps[n.mapId],a=r==null?void 0:r.tickets.find(h=>h.id===n.ticketId),c=n.mapId!==e.currentMapId?r==null?void 0:r.map.title:void 0,d=n.text.split(`
146
+ `)[0];return s.jsx(fe,{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 Ck={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"},Au={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."},Tk=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=`${ae()}/verification`,js={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 zT(e){const[t,n]=y.useState([]),r=Object.values(e).map(c=>c.tickets.map(d=>`${d.id}:${d.state}:${d.status??""}`).join()).join("|"),{reload:a}=Le({version:r,load:js.inbox,show:n});return y.useEffect(()=>ns.onEvidence(a),[a]),t}function UT(e){var h;const t=[...e.activity.pending].sort((f,m)=>f.at-m.at),n=zT(e.snaps),r=(h=e.attention)==null?void 0:h.view,a=e.brief?1:0,c=r?r.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(xs,{n:c,urgent:c>0,pop:!0},c)});return r&&e.attention&&e.handlers?s.jsxs("div",{className:"inbox-part",children:[d,s.jsx(Pp,{activity:e.activity}),s.jsx(yk,{view:r,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(Pp,{activity:e.activity}),e.brief,s.jsx(BT,{items:n,snaps:e.snaps,currentMapId:e.currentMapId,onOpen:e.onOpenTicket}),(t.length>0||!(n.length+a))&&s.jsx(FT,{items:t,snaps:e.snaps,currentMapId:e.currentMapId,selected:e.sessionId,onOpen:e.onOpenQuestion})]})}function Ek(e){const{q:t}=e,[n,r]=y.useState(""),a=y.useRef(null),c=(t.blocks??[]).map(e.keyOf).filter(Boolean),d=h=>{h.trim()&&(e.onAnswer(t.id,h.trim()),r(""))};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(vk,{pending:t,draft:n,onDraft:r,onSend:d,inputRef:a})}),s.jsx("button",{type:"button",className:"link",onClick:()=>e.onOpenChat(t.sessionId),children:"The whole conversation"})]})}function WT(e,t){const[n,r]=y.useState(),a=async()=>{const d=new URLSearchParams({mapId:e,ticketId:t}),h=await fetch(`${ae()}/verification/rules/held?${d}`);return h.ok?(await h.json()).held:void 0},c=Le({view:`${e}/${t}`,load:a,show:r,events:{verification:()=>!0,leases:()=>!0,attention:()=>!0}});return{held:n,reload:c.reload}}function HT(e){const[t,n]=y.useState(""),[r,a]=y.useState(),[c,d]=y.useState(!1),h=async()=>{d(!0),a(void 0);const f=await fetch(`${ae()}/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(),h()},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]}),r&&s.jsx("span",{className:"vf-err",children:r})]})}function KT(e){const{held:t,reload:n}=WT(e.mapId,e.ticketId),[r,a]=y.useState();return t!=null&&t.rules.length?s.jsxs(sn,{label:"Diff rules",className:"dr-held",children:[s.jsxs("p",{className:"t-meta",children:[t.agent,"'s completion waits for these answers."]}),s.jsx("ul",{className:"dr-list",children:t.rules.map(c=>s.jsx(fe,{as:"li",edge:"attention",title:c.ask,context:s.jsx(B,{parts:[{text:c.id,code:!0},`Why: ${c.why}`]}),detail:c.files.join(", "),actions:s.jsx(I,{size:"sm",onClick:()=>a(c.id),children:"Go without"}),below:r===c.id&&s.jsx(HT,{mapId:e.mapId,ticketId:e.ticketId,rule:c.id,onDone:()=>{a(void 0),n()}})},c.id))})]}):null}function Ae(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(`${ae()}/machine`).then(n=>n.ok?n.json():void 0).then(n=>t(n==null?void 0:n.local),()=>t(void 0))},[]),e}async function GT(){const e=await fetch(`${ae()}/verification/config`);return e.ok?await e.json():null}function Ru(){const[e,t]=y.useState();return Le({load:GT,show:t,failed:()=>t(null),changed:n=>n.endsWith("verification.json"),events:{attention:()=>!0}}),e}function VT(e){const{rule:t,onChange:n}=e,r=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 ${Ns(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":r,"data-tip":r,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 qT=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})),Wd=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 QT(e,t){var c;const n=new URLSearchParams(e),r=(c=n.get("when"))==null?void 0:c.trim().slice(0,1e3);if(n.get("settings")!=="rules"||!r)return;const a=Wd({when:r,check:"",ask:"",why:""}).when.join(",");if(!t.some(d=>Wd(d).when.join(",")===a))return{when:r,check:"",ask:"",why:(n.get("why")??"").slice(0,300)}}const YT={when:"",check:"",ask:"",why:""};function JT(e){var b;const{view:t,lastMatched:n}=e,[r,a]=y.useState(()=>{const S=qT(t.config),x=QT(location.search,S);return[...S,...x?[x]:[]]}),[c,d]=y.useState(!1),[h,f]=y.useState({kind:"idle"}),m=Object.keys(((b=t.config)==null?void 0:b.checks)??{}),g=(S,x)=>a(r.map((C,N)=>N===S?{...C,...x}:C)),k=async()=>{var N;f({kind:"saving"});const S=r.filter(P=>P.when.trim()).map(Wd),x=await fetch(`${ae()}/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=h.kind==="saving";return s.jsxs("div",{className:"vf-editor dr-editor",children:[r.length>0&&s.jsx("ul",{className:"vf-edit-list",children:r.map((S,x)=>s.jsx(VT,{rule:S,checks:m,lastMatched:S.id?n[S.id]:void 0,focus:c&&x===r.length-1,onChange:C=>g(x,C),onRemove:()=>a(r.filter((C,N)=>N!==x))},S.id??`new-${x}`))}),s.jsx("div",{className:"vf-edit-add",children:s.jsx(I,{onClick:()=>{d(!0),a([...r,YT])},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&&h.kind==="idle"&&s.jsx("span",{className:"t-meta",children:"Saved and approved."}),h.kind==="error"&&s.jsx("span",{className:"vf-err",children:h.text}),s.jsx(I,{variant:"primary",disabled:w,onClick:()=>void k(),children:w?"Saving…":"Save rules"})]})]})]})}function XT({rules:e,lastMatched:t}){return s.jsx("ul",{className:"dr-list",children:e.map(n=>s.jsx(fe,{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]?Ns(t[n.id]):"Not matched yet"},n.id))})}async function ZT(){const e=await fetch(`${ae()}/verification/rules`);return e.ok?(await e.json()).lastMatched??{}:{}}function e2(){const[e,t]=y.useState({});return Le({load:ZT,show:t,events:{verification:()=>!0}}),e}function t2(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 n2(){var h,f;const e=Ru(),t=xi(),n=e2(),[r,a]=y.useState(!1);if(!e)return null;const c=((h=e.config)==null?void 0:h.rules)??[],d=t2(e);return s.jsxs(Ae,{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(JT,{view:e,lastMatched:n,saved:r,onSaved:()=>a(!0)},((f=e.approval)==null?void 0:f.base)??"none"),(!t||d)&&c.length>0&&s.jsx(XT,{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 Ak=()=>`${ae()}/proof/settings`;async function s2(){const e=await fetch(Ak());return e.ok?await e.json():null}function i2(){const[e,t]=y.useState(),{pushed:n}=Le({load:s2,show:a=>t((a==null?void 0:a.enabled)??null),failed:()=>t(null),events:{proof:()=>!0}}),r=y.useCallback(async a=>{const c=await fetch(Ak(),{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:r}}function r2(){const{enabled:e,set:t}=i2(),[n,r]=y.useState();if(e==null)return null;const a=()=>{r(void 0),t(!e).then(r,c=>r(c.message))};return s.jsxs(Ae,{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 o2(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 a2(e){var r,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`,!!((r=e.waived)!=null&&r.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`,o2(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 c2=(e,t)=>e?"the same model as the author":t?`author on ${t}`:"author model unknown";function l2(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}`,c2(n.sameModel,t)])}function d2(e){const{view:t}=e;if(!t)return null;const{proof:n,post:r}=t;if(!(e.ticket.state==="closed"&&e.ticket.closeReason==="completed")&&!n.attempt.id)return null;const c=n.status==="verified",d=r!=null&&r.commentUrl?pn(r.commentUrl):void 0,h=a2(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:h.slice(0,-1)})]}),l2(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",...h.slice(-1)]}),d&&s.jsxs("a",{className:"t-meta",href:d,target:"_blank",rel:"noreferrer",children:["Posted on pull request #",r.pr]}),(r==null?void 0:r.error)&&s.jsxs("p",{className:"t-meta",children:["Posting failed, trying again: ",r.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 u2(e,t){const[n,r]=y.useState();return Le({load:async()=>{const a=new URLSearchParams({mapId:e,ticketId:t}),c=await fetch(`${ae()}/proof/ticket?${a}`);return c.ok?await c.json():null},show:r,failed:()=>r(null),view:`${e}/${t}`,changed:a=>a.includes(`tickets/${t}.md`),events:{verification:()=>!0,proof:()=>!0}}),n}function Rk(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 Dp="The server didn't answer. Try again.",Mk=(e,t)=>String(e.error??`The server answered ${t}.`).slice(0,300);async function Ik(e,t){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));return{ok:n.ok,status:n.status,json:r}}async function h2(e){const t=await Ik(`${ae()}/proof/merge-anyway`,e),n=t.json.gapsHash;return t.ok&&typeof n=="string"?{hash:n}:{error:Mk(t.json,t.status)}}async function f2(e){try{const t=e.gaps?await h2({mapId:e.mapId,ticketId:e.ticketId,gaps:e.gaps}):void 0;if(t&&"error"in t)return{kind:"error",text:t.error??Dp};const n=t?{anyway:!0,gaps:t.hash}:{},r=await Ik(e.path,{trail:e.mapId,ticket:e.ticketId,...n}),a=typeof r.json.url=="string"?pn(r.json.url):void 0;return r.ok&&r.json.merged?{kind:"merged",url:a}:{kind:"error",text:Mk(r.json,r.status)}}catch{return{kind:"error",text:Dp}}}function Ok(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 f2({...e,gaps:a}))}}}function m2(e){const t=Ok(e),{state:n}=t;return n.kind==="merged"?s.jsx(Rk,{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 _p(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(r=>s.jsx("li",{children:r},r))})})]})}function p2(e){const t=Ok(e),{state:n}=t;return n.kind==="merged"?s.jsx(Rk,{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(_p,{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(_p,{gaps:e.gaps})]})}function g2(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 r={path:t,mapId:e.mapId,ticketId:e.ticketId};return n.status==="verified"?s.jsx(m2,{...r}):s.jsx(p2,{...r,gaps:n.gaps})}function Lk(e){const{v:t,bar:n}=e,{primary:r}=n,a=t.session,c=a&&(r==null?void 0:r.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:[r&&s.jsx(I,{variant:n.variant,"data-tip":r.tip,onClick:r.onSelect,children:r.label}),d&&s.jsx(g2,{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(nk,{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 Pk=/^\*\*([^*]+)\*\*\s*/;function v2(e){var n;const t=(n=e.match(Pk))==null?void 0:n[1];return t?t.replace(/:$/,"").toLowerCase():"comment"}function k2(e){const t=e.decisions.map(r=>({id:r.id,at:r.decidedAt,who:ju(r,e.people),kind:r.supersededBy?`decision, superseded by ${r.supersededBy}`:"decision",text:r.summary||r.answer,decision:r.id})),n=e.comments.filter(r=>!(t.length&&r.body.startsWith("**Resolution**"))).map(r=>({id:r.id,at:r.createdAt,who:fi(r.author,e.people),kind:v2(r.body),text:r.body.replace(Pk,"").replace(/\*\*/g,"")}));return[...t,...n].sort((r,a)=>a.at-r.at)}function y2(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,is(t.at)],children:n&&s.jsxs("button",{type:"button",className:"d-more",onClick:()=>{var r;return(r=e.onOpenDecision)==null?void 0:r.call(e,t.decision)},children:[t.decision," ›"]})}),s.jsx(tk,{text:t.text})]})}function w2(e){const t=Cr(),[n,r]=y.useState(!1),a=k2({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(y2,{entry:d,onOpenDecision:e.onOpenDecision},d.id))}),a.length>1&&s.jsx("button",{type:"button",className:"d-more","aria-expanded":n,onClick:()=>r(!n),children:n?"Show the latest only":`Show all ${a.length}`})]})}function Dk(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 _k=`${J.apiPrefix}`;async function Bk(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=>Bk(await fetch(`${_k}${e}`)),Fk=async(e,t)=>Bk(await fetch(`${_k}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}));function x2(e,t){const[n,r]=y.useState(),a=`/guides/checklist?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`;return Le({view:a,load:()=>ha(a),show:c=>r(c.checklist),failed:()=>r(null),changed:c=>c.endsWith("checklist.json")}),n}function j2(e){const t=x2(e.mapId,e.ticketId);if(!t)return null;const n=t.guides.map(r=>`${r.guide.id} ${r.answers.filter(a=>a.done).length}/${r.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(r=>s.jsxs("div",{className:"checklist-panel",children:[s.jsx(B,{parts:[`${r.guide.id} ${r.guide.version}`,t.by,is(t.at)]}),s.jsx(Dk,{answers:r.answers})]},r.guide.id))})]})}let zk;const ta=new Set;let es;function Hd(e){zk=e;for(const t of ta)t()}function Uk(e){es==null||es.pushed(),Hd(e)}const b2=()=>zk;function S2(e){return ta.add(e),es??(es=dk({load:()=>ha("/guides"),show:Hd,failed:()=>Hd(null),changed:t=>t.includes("guides")})),()=>{ta.delete(e),!ta.size&&(es==null||es.stop(),es=void 0)}}function gn(){const e=y.useSyncExternalStore(S2,b2),t=y.useCallback(async(r,a)=>{try{Uk(await Fk(r,a));return}catch(c){return c.message}},[]),n=y.useCallback(r=>r?e==null?void 0:e.guides.find(a=>a.id===r):void 0,[e]);return{view:e,act:t,find:n}}const N2={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"},$2={active:"Approved",unapproved:"Not approved yet",tampered:"Changed since you approved it",invalid:"Can't be used"},Kd=e=>{var t;return e.origin==="local"&&(!((t=e.lock)!=null&&t.source)||e.lock.source==="local")};function C2(e){return Kd(e)?{text:$2[e.status],strong:e.status==="active"}:e.status==="active"?void 0:N2[e.status]}function fa(e){try{return new URL(e).host}catch{return e}}function T2(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 Mu=e=>e.map(t=>/\s/.test(t)?JSON.stringify(t):t).join(" "),Bp=3;function E2(e,t){return e.length<=Math.max(t,Bp+1)?e:`${e.slice(0,Math.max(t-1,Bp)).trimEnd()}…`}function Wk(e){return e===RS?"Verified":`Verified by ${fa(e)}'s catalog`}function Hk(e,t){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:Wk(t),strong:!0}:"Not reviewed"}function A2(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,r=(d=e.lock)==null?void 0:d.source;return{text:r&&r!=="local"?Wk(r.registry):"Verified",strong:!0,tip:n}}var Kk=Wg();function Gk(e){return gN(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 R2(e){var w;const{preview:t}=e,{act:n,find:r}=gn(),[a,c]=y.useState({kind:"ready"}),[d,h]=y.useState(),f=t.entry.id,m=async()=>{h(void 0),c({kind:"adding"});try{c({kind:"added",pending:(await e.add(f,t.entry.sha256)).pendingChecks})}catch(b){h(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=r(f))==null?void 0:w.pendingChecks)??a.pending,k=async(b,S)=>h(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,": ",Mu(((x=(S=t.guide)==null?void 0:S.proposedChecks[b])==null?void 0:x.run)??[])]}),s.jsx(Gk,{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 M2(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,r)=>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,")"]})]},r))}),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 Vk(e){var r,a;const{p:t}=e,n=Object.entries(((r=t.guide)==null?void 0:r.proposedChecks)??{});return s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"t-label",children:"Lint"}),s.jsx(M2,{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,": ",Mu(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 I2(e){const t=pn(e.repo);if(!t)return null;const n=encodeURIComponent(`Report: ${e.id} ${e.version}`),r=`${t.replace(/\/+$/,"")}/issues/new?template=report-guide.yml&title=${n}`;return s.jsx("a",{className:"report-link t-meta",href:r,target:"_blank",rel:"noreferrer",children:"Report this guide"})}function O2(e){const t=e.entry,[n,r]=y.useState(),[a,c]=y.useState();return y.useEffect(()=>{e.preview(t.id).then(r,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}`,Hk(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(Vk,{p:n}),n&&s.jsx(I2,{repo:n.repo,id:t.id,version:t.version}),n&&s.jsx(R2,{preview:n,installed:e.installed,add:e.add})]})}function L2(e){const t=e.entry;return s.jsx("li",{className:"catalog-row","data-guide-id":t.id,children:s.jsx(fe,{title:t.name??t.id,context:s.jsx(B,{parts:[{text:t.id,code:!0},t.version,t.author,Hk(t,e.catalogUrl),t.reported&&"Reported"]}),detail:t.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}const Fp=e=>e?`registry=${encodeURIComponent(e)}`:"";function P2(e){const[t,n]=y.useState(),[r,a]=y.useState();y.useEffect(()=>{let h=!0;return n(void 0),a(void 0),ha(`/guides/catalog?${Fp(e)}`).then(f=>h&&n(f),f=>h&&a(f.message)),()=>{h=!1}},[e]);const c=y.useCallback(h=>ha(`/guides/catalog/preview?${Fp(e)}&id=${encodeURIComponent(h)}`),[e]),d=y.useCallback(async(h,f)=>{const m=await Fk("/guides/catalog/add",{registry:e,id:h,sha256:f});return Uk(m),m.installed},[e]);return{index:t,error:r,preview:c,add:d}}function D2(e){var x,C;const[t,n]=y.useState(((x=e.registries[0])==null?void 0:x.name)??""),r=P2(t||void 0),{find:a}=gn(),[c,d]=y.useState(""),[h,f]=y.useState(!0),[m,g]=y.useState(),k=r.index?vN({guides:r.index.guides},{query:c,verifiedOnly:h}):[],w=(C=r.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 Kk.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(O2,{entry:w,catalogUrl:(S==null?void 0:S.url)??"",installed:b(w.id),preview:r.preview,add:r.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:h,"aria-pressed":h,onClick:()=>f(N=>!N),children:"Verified only"})]}),r.error&&s.jsx("span",{className:"vf-err",children:r.error}),!r.index&&!r.error&&s.jsx(Ee,{children:"Reading the catalog…"}),r.index&&!k.length&&s.jsx(Ee,{children:"No guides match."}),s.jsx("ul",{className:"catalog-list",children:k.map(N=>s.jsx(L2,{entry:N,catalogUrl:(S==null?void 0:S.url)??"",installed:b(N.id),onOpen:()=>g(N.id)},N.id))})]})]})}),document.body)}async function _2(e,t){const n=await fetch(`${ae()}/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 B2=400;function qk(e){const[t,n]=y.useState([]),r=JSON.stringify(e);return y.useEffect(()=>{const a=new AbortController,c=setTimeout(()=>{const d=JSON.parse(r);_2(d,a.signal).then((h=[])=>{const f=m=>{var g;return((g=d[Number(m)])==null?void 0:g.run.join(" "))??""};a.signal.aborted||n(h.map(m=>({...m,command:f(m.check)})))})},B2);return()=>{clearTimeout(c),a.abort()}},[r]),t}function F2({text:e}){const t=e.split("`");return s.jsx(s.Fragment,{children:t.map((n,r)=>r%2?s.jsx("code",{className:"t-code",children:n},r):n)})}const z2={"wont-run":"Won't run",unsure:"May not run"},ud=s.jsx("span",{className:"sep",children:" · "});function U2(e){const{finding:t,onFix:n}=e,r=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:z2[t.severity]}),e.named&&s.jsxs(s.Fragment,{children:[ud,s.jsx("code",{className:"t-code",children:t.check})]}),ud,s.jsx(F2,{text:r?r.problem:t.text}),r&&s.jsxs(s.Fragment,{children:[ud,s.jsxs("button",{type:"button",className:"d-more",onClick:()=>n(r.run),children:["Use ",s.jsx("code",{className:"t-code",children:r.run.join(" ")})]})]})]})]})}function Ka(e){return e.findings.length?s.jsxs("div",{className:"cs-findings",children:[s.jsx("ul",{children:e.findings.map(t=>s.jsx(U2,{finding:t,named:e.named,onFix:e.onFix},`${t.check} ${t.text}`))}),e.action]}):null}function W2({spec:e}){const t=qk([{name:"0",run:e.run,...e.cwd?{cwd:e.cwd}:{}}]);return s.jsx(Ka,{findings:t})}function H2(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 r=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,": ",Mu(c.run)]}),d&&r&&s.jsx(W2,{spec:c}),d&&r&&s.jsx(Gk,{name:a,spec:c,busy:e.busy,onApprove:e.onApprove}),d&&!r&&s.jsx("span",{className:"t-meta",children:"approve the guide first"}),!d&&s.jsx("span",{className:"t-meta",children:"approved"})]},a)})]})}function K2(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(Vk,{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 G2="A file in guides/ replaces this built-in once you approve it; until then the built-in is used";function V2(e){var t,n;return e.override?G2:e.status==="unapproved"?(t=e.guide)==null?void 0:t.summary:e.reason??((n=e.guide)==null?void 0:n.summary)}function Qk(e){const{r:t}=e,n=t.id,r=t.override??t,a=(r.status==="unapproved"||r.status==="tampered")&&!!r.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(fe,{edge:c?"attention":"neutral",title:d,context:s.jsx(B,{parts:[{text:n,code:!0},T2(t),A2(t),C2(t),t.guide&&q2(t.guide.checklist.length)]}),detail:V2(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(K2,{r,busy:e.busy,onApprove:h=>e.onAct("/guides/approve",{id:n,sha256:h})}),s.jsx(H2,{r:t,busy:e.busy,onApprove:(h,f)=>e.onAct("/guides/checks/approve",{id:n,name:h,acknowledged:f})})]})})})}const q2=e=>e===1?"1 checklist item":`${e} checklist items`;function Q2(e){return s.jsxs(Ae,{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(Qk,{r:t,busy:e.busy,onAct:e.onAct},t.id))}):s.jsx(Ee,{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:MS,target:"_blank",rel:"noreferrer",children:"share it in the public catalog"}),"."]})]})}function Y2(e){const{view:t,act:n}=gn(),[r,a]=y.useState(),[c,d]=y.useState(!1),[h,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=>r&&r.own===w?r.message:void 0;return s.jsxs("div",{className:"guides-section",ref:m,children:[s.jsxs(Ae,{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=>!Kd(w)).map(w=>s.jsx(Qk,{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(Q2,{guides:t.guides.filter(Kd),busy:c,onAct:g(!0),error:k(!0)}),h&&s.jsx(D2,{registries:t.registries,onClose:()=>f(!1)})]})}function J2(e){const{view:t,find:n}=gn();if(!t)return null;const r=n(e.id);if((r==null?void 0:r.status)==="active")return null;const a=r?r.reason??r.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 X2={type:"by type",ticket:"added",removed:"removed"},Z2=(e,t)=>e.removed?{change:{add:e.id},label:`Put back ${t}`,mark:"+"}:{change:{remove:e.id},label:`Remove ${t}`,mark:"×"};function Yk(e){var w,b;const{view:t,find:n}=gn(),{row:r}=e,a=n(r.id),c=!!t&&(a==null?void 0:a.status)!=="active",d=((w=a==null?void 0:a.guide)==null?void 0:w.name)??r.id,h=r.removed?"removed":r.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}=Z2(r,d);return s.jsxs("span",{className:pe("ticket-guide-chip",r.removed&&"removed",c&&"off"),"data-guide-id":r.id,"data-via":h,title:f,children:[s.jsx("span",{className:"name",children:d}),s.jsx("span",{className:"how t-meta",children:X2[h]}),e.editable&&s.jsx("button",{type:"button",className:"chip-act","aria-label":g,title:g,onClick:()=>e.onChange(m),children:k})]})}function Jk(e,t){const n=$0(e,t).map(c=>({...c,removed:!1})),a=(cu(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 eE(e){const{view:t}=gn();if(!t)return null;const n=Jk(e.map,e.ticket).filter(r=>!r.removed);return n.length?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ticket-guides plain",children:n.map(r=>s.jsx(Yk,{row:r,editable:!1,onChange:()=>{}},r.id))}),n.map(r=>s.jsx(J2,{id:r.id},r.id))]}):s.jsx("span",{className:"t-meta",children:"None"})}const zp="";function tE(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 r=[{value:zp,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:zp,options:r,onChange:a=>a&&e.onAdd(a)})}function nE(e){const{view:t,act:n}=gn(),[r,a]=y.useState();if(!t)return null;const c=e.ticket,d=Jk(e.map,c),h=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(Yk,{row:m,editable:!0,onChange:f},m.id)),s.jsx(tE,{taken:h.map(m=>m.id),onAdd:m=>f({add:m})})]}),r&&s.jsx("span",{className:"vf-err",children:r})]})}function sE(e){const{type:t,ids:n,usable:r}=e,a=n.filter(m=>!r.some(g=>g.id===m)),c=av[t]??[],d=c.length!==n.length||c.some(m=>!n.includes(m)),h=m=>{var g,k;return((k=(g=r.find(w=>w.id===m))==null?void 0:g.guide)==null?void 0:k.name)??m},f=d?`default ${c.map(h).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:[r.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 iE={defaults:"Defaults",team:"Defaults, kept within the trail's earlier team"};function rE(e){var g;const{view:t,act:n}=gn(),[r,a]=y.useState();if(!t)return null;const{byType:c,source:d}=cu(e.map),h=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(Ae,{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:[iE[d],d==="team"&&((g=e.map.guides)==null?void 0:g.join(", "))]})}),s.jsx("div",{className:"type-guides",children:ss.map(k=>s.jsx(sE,{type:k,ids:c[k]??[],usable:h,onToggle:w=>m(k,w)},k))}),r&&s.jsx("span",{className:"vf-err",children:r})]})}function oE(e){var f;const{view:t,find:n}=gn();if(!e)return;const r=n(e),a=t!=null&&(r==null?void 0:r.status)!=="active",c=((f=r==null?void 0:r.guide)==null?void 0:f.name)??e,d=r!=null&&r.guide?`${c} ${r.guide.version}`:c,h=a?`Guide ${d}: ${(r==null?void 0:r.reason)??"not installed"}`:`Guide: ${d}`;return{id:e,name:c,tip:h,off:a}}function aE({check:e}){const t=Tk(e),[n,r]=y.useState(),[a,c]=y.useState(),d=cE(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:()=>js.log(e.log).then(h=>r(h.clipped?`[earlier output not shown]
147
+ ${h.text}`:h.text),h=>c(h.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 cE(e){return e.error?"did not start":e.timedOut?"timed out":`exit ${e.exitCode??e.signal??"?"}`}const Up=e=>(e==null?void 0:e.slice(0,8))??"none",Wp=e=>e===null?"·":String(e);function lE({attempt:e}){var d;const t=e.git;if(!t)return null;const{files:n,add:r,del:a}=t.stats,c=new Set(((d=t.flags.find(h=>h.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?`${Up(t.base.head)} → `:""}${Up(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"} +${r} −${a}`]}),t.flags.filter(h=>h.kind!=="no-git"&&h.kind!=="check-guard").map(h=>{var f;return s.jsxs("p",{className:`vf-flag lv-${h.level}`,title:(f=h.files)==null?void 0:f.join(`
148
+ `),children:[s.jsx("span",{className:"t-code",children:h.kind})," ",h.message]},h.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(h=>s.jsxs("li",{children:[s.jsx("code",{children:h.path}),s.jsxs("span",{className:"dim",children:[h.untracked?"new":`+${Wp(h.add)} −${Wp(h.del)}`,h.dirtyAtClaim?" · dirty at claim":"",c.has(h.path)?" · outside the declared files":""]})]},h.path))})]})]})}function dE({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(r=>s.jsxs("li",{children:[r.text,r.check&&s.jsxs("span",{className:"dim",children:[" · ",r.check]})]},`${r.file}\0${r.text}`))}),n&&s.jsx("p",{className:"t-meta",children:"The pass counts once you accept it."})]})}function uE({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:Ck[e.result]}),s.jsx(B,{parts:[{text:e.id,code:!0},e.agent,is(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(dE,{attempt:e}),e.criteria&&s.jsx("ul",{className:"vf-criteria",children:e.criteria.lines.map(n=>s.jsx("li",{className:hE(n),children:n},n))}),s.jsx(lE,{attempt:e}),e.checks.map(n=>s.jsx(aE,{check:n},n.name))]})}function hE(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":e.includes(" ? ")?"claimed":"wait"}const fE={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function mE(e){var t;return(t=e.guides)!=null&&t.length?e.guides:e.guide?[{guide:e.guide,answers:e.checklist??[]}]:[]}function pE({verdict:e}){const t=mE(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":fE[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}`,is(e.at)]}),s.jsx("p",{children:e.summary}),e.findings.length>0&&s.jsx("ul",{className:"vf-findings",children:e.findings.map((n,r)=>s.jsxs("li",{className:`sev-${n.severity}`,children:[n.path&&s.jsx("code",{children:n.line?`${n.path}:${n.line}`:n.path})," ",n.text]},r))}),t.map(n=>n.answers.length>0&&s.jsx(Dk,{answers:n.answers},n.guide.id))]})}const gE={PASS:"review passed",FAIL:"review sent it back",NEEDS_HUMAN:"reviewer asked for you"};function vE({data:e}){const t=e.attempts[0];if(!t)return null;const n=e.attempts.length,r=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 ",Ck[t.result].toLowerCase()]}),s.jsx(B,{parts:[{text:t.id,code:!0},t.agent,is(t.submittedAt),r&&gE[r.verdict]]}),s.jsx(rn,{children:s.jsxs("div",{className:"vf-panel",children:[e.verdicts.map(a=>s.jsx(pE,{verdict:a},a.id)),e.attempts.map((a,c)=>s.jsx(uE,{attempt:a,latest:c===0},a.id))]})})]})}const ma="";function kE(e){const t=ru.map(r=>({value:r,label:Er[r],hint:Au[r]})),n=[...yE(e),...t];return s.jsx(rt,{compact:!0,className:"vf-level","aria-label":"Verification level",value:e.value??ma,options:n,onChange:r=>e.onChange(r===ma?null:r)})}function yE(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 wE={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."}},xE={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."}},Hp="The pass counts although the work changed what its checks run. The proof says you accepted it.";function jE(e){return e.kind!=="accept"||!e.guarded?e.hint:e.retried?`${Hp} It also passed only on retry.`:Hp}function bE(e){const{kind:t}=e,n=e.retried&&xE[t]||wE[t],[r,a]=y.useState(""),[c,d]=y.useState("rework"),h=f=>{f.preventDefault(),r.trim()&&e.onSubmit({action:t,reason:r.trim(),...t==="unblock"?{to:c}:{}})};return s.jsxs(Vt,{as:"form",tone:"inset",className:"inline-form",onSubmit:h,children:[s.jsx(Je,{label:n.label,children:s.jsx("textarea",{rows:2,value:r,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:jE({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:!r.trim(),children:n.submit})]})]})}function SE(e,t,n){const[r,a]=y.useState(),c=`${e}/${t}`;y.useEffect(()=>a(void 0),[c]);const{reload:d}=Le({view:c,version:n,load:()=>js.ticket(e,t),show:a});return y.useEffect(()=>ns.onEvidence(d),[d]),{data:r,reload:d}}const NE={ticket:"set on this ticket",trail:"from the trail",none:"not set"};function $E({level:e}){return e.level==="off"?"Off":e.checks.join(", ")||"No checks"}function CE({data:e}){const{level:t}=e;return s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"t-body",children:$E(e)}),s.jsx(B,{parts:[t.level!=="off"&&Er[t.level],NE[t.source]]}),s.jsx(rn,{children:s.jsx("p",{className:"t-meta",children:Au[t.level]})})]})}function TE(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 EE(e){if(e)return e.timedOut?"timed out":e.error?`couldn't run: ${e.error}`:`exited ${e.exitCode??e.signal}`}function AE(e){const[t,n]=y.useState(()=>new Set(e.waivable.map(g=>g.name))),[r,a]=y.useState(""),c=e.waivable.filter(g=>t.has(g.name)),d=c.map(g=>g.name).join(", "),h=c.length>0&&!!r.trim(),f=(g,k)=>{const w=new Set(t);k?w.add(g):w.delete(g),n(w)},m=g=>{g.preventDefault(),h&&e.onSubmit({checks:c,reason:r.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:r,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},EE(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:!h,children:c.length?`Accept without ${d}`:"Pick a check"})]})]})}function RE({v:e,act:t}){return s.jsxs("dl",{className:"facts how-editor",children:[s.jsx(Et,{label:"Guides",children:s.jsx(nE,{map:e.snap.map,ticket:e.t})}),s.jsx(Et,{label:"Verification",children:s.jsx(kE,{value:e.t.verification,inherit:`Trail (${Er[e.snap.map.verification??"off"]})`,onChange:n=>void t({action:"level",level:n})})})]})}const Xk=y.createContext(null);function Es(){const e=y.useContext(Xk);if(!e)throw new Error("useKnowledge needs a KnowledgeContext provider");return e}function ME({snap:e,t}){const n=Es();if(!n.entries.length||t.state==="closed")return null;const r=Ev(n.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:Av(`${t.body}
149
+ ${n.briefText}`)},4e3,c=>n.stale[c.id]??[]),a=r.length===1?"entry":"entries";return s.jsxs(Et,{label:"Knowledge",children:[s.jsx("span",{className:"t-body",children:r.length?`${r.length} ${a}`:"None picked"}),r.length>0&&s.jsx(rn,{children:s.jsx("ul",{className:"item-list",children:r.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,r]=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&&r(a),{hash:a.shown.hash,changed:a.shown.hash!==a.shown.latest,reviewAgain:()=>r({key:e,shown:Qo(void 0,t)})}}const IE={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 OE({e}){const t=Es(),[n,r]=y.useState(!1),[a,c]=y.useState(e.title),[d,h]=y.useState(e.body);y.useEffect(()=>{r(!1),c(e.title),h(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=>h(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:IE[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(bu,{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:()=>r(!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&&r(!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:()=>r(!0),children:"Edit"}),e.status!=="outdated"&&s.jsx(I,{variant:"ghost",onClick:()=>void t.call(e.id,{kind:"outdated"}),children:"Mark outdated"})]})})]})}const LE={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function PE(){const e=Es(),[t,n]=y.useState("review"),[r,a]=y.useState(""),[c,d]=y.useState(""),[h,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)&&(!r||C.kind===r)&&(!x||`${C.id} ${C.title} ${C.body} ${C.tags.join(" ")}`.toLowerCase().includes(x)))},[e.entries,e.stale,t,r,c]);if(!e.open)return null;const w=k.find(x=>x.id===h)??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:r,onChange:a,options:[{value:"",label:"Any kind"},...Ob.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(fe,{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":LE[x.status]]})},x.id)):s.jsx(Ee,{children:t==="review"?"Nothing needs you":"No entries"})}),w?s.jsx(OE,{e:w}):s.jsx(Ee,{children:"Pick an entry"})]})]})})}function Zk({draft:e,label:t="Save as knowledge"}){const n=Es(),[r,a]=y.useState();return r?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 ",r]}):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 ey=`${ae()}/knowledge`;async function Kp(e,t){const n=await fetch(`${ey}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Error(r.error??`HTTP ${n.status}`);return r}async function DE(){const e=await fetch(ey);return e.ok?await e.json():null}function _E(e){const[t,n]=y.useState([]),[r,a]=y.useState({}),[c,d]=y.useState({}),[h,f]=y.useState(!1),[m,g]=y.useState(),{reload:k}=Le({load:DE,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||r[b.id]&&b.status!=="outdated").length,[t,r]);return{entries:t,stale:r,briefText:e,attention:w,open:h,setOpen:f,error:m,hashes:c,call:(b,S,x)=>Kp("/call",{id:b,call:S,hash:x??c[b]}).then(()=>(g(void 0),k(),!0),C=>(g(C.message),k(),!1)),propose:b=>Kp("/propose",b).then(S=>(k(),S.entry),S=>(g(S.message),void 0))}}function BE({v:e}){return s.jsxs("dl",{className:"facts",children:[s.jsx(Et,{label:"Guides",children:s.jsx(eE,{map:e.snap.map,ticket:e.t})}),e.verification&&s.jsx(Et,{label:"Checks",children:s.jsx(CE,{data:e.verification})}),s.jsx(ME,{snap:e.snap,t:e.t})]})}function FE(e){const{v:t}=e,n=e.editing&&t.t.state==="open",r=t.t.state==="open"?()=>e.setEditing(!n):void 0;return s.jsx(sn,{label:"How",className:"ticket-how",onEdit:r,editLabel:n?"Done":"Edit",children:n?s.jsx(RE,{v:t,act:e.act}):s.jsx(BE,{v:t})})}function zE({lease:e,now:t}){var a;const n=Ts(e,t),r=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 ",is(e.claimedAt)]}),s.jsx(B,{parts:[`active ${Xe(t-e.renewedAt)} ago`,n==="live"&&UE(WE(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(", ")})}),r&&s.jsxs(Et,{label:"Latest note",children:[s.jsx("span",{className:"t-body",children:r}),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 UE(e){return`back in the queue after ${e} without activity`}function WE(e){const t=e/864e5;return t>=2?`${Math.round(t)} days`:Gt(Math.max(0,e))}function HE({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 r=e.snap.map.id;return s.jsx(sn,{label:"Progress",className:"ticket-progress",children:s.jsxs("dl",{className:"facts",children:[e.lease&&s.jsx(zE,{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(QC,{mapId:r,ticketId:e.t.id})}),n>0&&e.verification&&s.jsx(Et,{label:"Attempts",children:s.jsx(vE,{data:e.verification})}),n>0&&s.jsx(j2,{mapId:r,ticketId:e.t.id}),s.jsx(TE,{waivers:((c=e.verification)==null?void 0:c.waivers)??[],onUndo:t})]})})}function KE({v:e}){const t=e.standing,n=e.lease&&Ts(e.lease,e.now),r=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)),r&&s.jsx(bu,{what:"The criteria",onReviewAgain:r.reviewAgain})]})}const Gd=`${ae()}/workspaces`;async function GE(){const e=await fetch(Gd);return e.ok?await e.json():null}function ty(){const[e,t]=y.useState(),{pushed:n}=Le({load:GE,show:t,failed:()=>t(null),changed:d=>d.endsWith("workspaces.json")||d.includes("workspaces/")||d.includes("leases/")}),r=y.useCallback(d=>{n(),t(d)},[n]),a=y.useCallback(async d=>{const h=await fetch(Gd,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)}),f=await h.json();if(!h.ok)return f.error??`Saving failed (${h.status})`;r(f)},[r]),c=y.useCallback(async(d,h,f=!1)=>{const m=await fetch(`${Gd}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:d,ticketId:h,force:f})}),g=await m.json();return m.ok?(r(g),{}):{error:g.error??`Removing failed (${m.status})`,dirty:g.dirty??!1}},[r]);return{view:e,save:a,remove:c}}function ny(e){const[t,n]=y.useState(!1),[r,a]=y.useState(),[c,d]=y.useState(!1),h=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:()=>h(!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:()=>h(!1),children:e.label??"Remove"}),r&&s.jsx("span",{className:"vf-err",children:r})]})}function VE(e){return e.rows.length?s.jsx("ul",{className:"ws-list",children:e.rows.map(t=>s.jsx(fe,{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(ny,{onRemove:n=>e.onRemove(t.mapId,t.ticketId,n)})},`${t.mapId}/${t.ticketId}`))}):null}function qE(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(ny,{label:"Remove workspace",onRemove:e.onRemove})]})]})}function QE(e){const[t,n]=y.useState(""),[r,a]=y.useState(""),[c,d]=y.useState(""),h=f=>{if(f.preventDefault(),!t.trim())return;const m=c.split(`
150
+ `).map(g=>g.trim()).filter(Boolean);e.onResolve(t.trim(),{rationale:r.trim(),alternatives:m})};return s.jsxs(Vt,{as:"form",tone:"inset",className:"inline-form",onSubmit:h,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:r,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 YE(e){const[t,n]=y.useState("Not needed to reach the destination."),r=a=>{a.preventDefault(),e.onRuleOut(t)};return s.jsxs(Vt,{as:"form",tone:"inset",className:"inline-form",onSubmit:r,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 JE=e=>{var n,r;const t=(n=e.verification)==null?void 0:n.attempts[0];return(t==null?void 0:t.result)==="pass"&&((r=t.guard)==null?void 0:r.mode)==="enforce"};function sy(e){var c,d,h,f;const{form:t,v:n,actions:r}=e,a=()=>e.setForm(null);switch(t){case"resolve":return s.jsx(QE,{onResolve:(m,g)=>{r.resolve(n.t.id,m,g),a()},onCancel:a});case"rule":return s.jsx(YE,{onRuleOut:m=>{r.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"&&lu((c=n.verification)==null?void 0:c.attempts[0]),guarded:JE(n),onSubmit:m=>{e.act(m),a()},onCancel:a});case"waive":return s.jsx(AE,{waivable:((d=n.verification)==null?void 0:d.waivable)??[],results:((f=(h=n.verification)==null?void 0:h.attempts[0])==null?void 0:f.checks)??[],onSubmit:m=>{e.waive(m),a()},onCancel:a});case"workspace":return n.workspace?s.jsx(qE,{workspace:n.workspace,onRemove:n.removeWorkspace,onCancel:a}):null;case null:return null;default:return t}}function XE({t:e,tickets:t}){const n=a=>{var c;return((c=t.find(d=>d.id===a))==null?void 0:c.key)??a},r=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)}`,r.length>0&&`blocks ${r.join(", ")}`]})]})}function ZE(e,t){return[...eA(e,t),...tA(e,t),...rA(e,t),...oA(e,t),...aA(e,t)].filter(n=>!!n)}function eA(e,t){const{state:n,mine:r}=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"&&r)&&{id:"resolve",label:"Resolve myself…",tip:"Answer it yourself and close the ticket, with a decision record",onSelect:()=>t.form("resolve")},r&&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 tA(e,t){var h,f,m;if(!(e.state==="verifying"||e.state==="held")||(h=e.verification)!=null&&h.running)return[];const r=!!((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=nA(c);return a&&!d&&lu(c)?sA(t):[e.state==="verifying"&&r&&{id:"approve",label:"Approve",tip:"Approve the work and close the ticket",onSelect:t.approve},r&&{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 nA=e=>{var t;return(e==null?void 0:e.result)==="pass"&&((t=e.guard)==null?void 0:t.mode)==="enforce"};function sA(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 iA=new Set(["rework","held","claimed"]);function rA(e,t){var c,d,h;const n=((c=e.verification)==null?void 0:c.waivable)??[],r=[...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&&iA.has(e.state)&&!((h=e.verification)!=null&&h.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")},r.length>0&&{id:"undo-waiver",label:`Run ${r.join(", ")} again`,tip:"Undo accepting it without them",onSelect:t.undoWaiver}]}function oA(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 aA(e,t){var a;const{state:n,t:r}=e;return[r.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")},r.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 cA={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 iy(e){const{v:t,api:n}=e,[r,a]=y.useState(),[c,d]=y.useState(),h=Es(),f=M=>{d(M),setTimeout(()=>d(void 0),2500)},m=M=>a(M),g=M=>(a(void 0),js.act({...M,mapId:t.snap.map.id,ticketId:t.t.id,by:Ct}).then(t.reloadVerification,W=>a(W.message))),k=M=>{var Y,re;const W=((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),js.waive({mapId:t.snap.map.id,ticketId:t.t.id,attemptId:W,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 js.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 h.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(W=>W&&f(`Saved as ${W.id} in the field guide`))}},b=ZE(t,w),S=lA(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===cA[x])??C,P=dA({urgent:t.standing.edge==="urgent",named:!!x&&N!==C}),D=b.filter(M=>M!==N);return{primary:N,variant:P,menu:D,error:r,note:c,act:g,waive:k,undoWaiver:w.undoWaiver}}function lA(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 dA(e){return e.urgent?"urgent":e.named?"primary":"default"}function Gp({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 uA({c:e}){const{criteria:t,proposal:n,uncovered:r}=e;if(!t.length&&!r.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(Gp,{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(Gp,{criteria:n.criteria})]}),r.length>0&&s.jsx(B,{parts:[`No criterion covers ${r.map(c=>`${c.title} (${c.id})`).join(", ")} yet`]})]})}const ry=`${ae()}/criteria`;async function hA(e){if(!e)return[];const t=await fetch(`${ry}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).tickets:[]}function fA(e){const[t,n]=y.useState([]),{reload:r}=Le({view:e,load:()=>hA(e),show:n,failed:()=>n([]),changed:c=>c.startsWith("criteria/")});return{tickets:t,confirm:c=>fetch(`${ry}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...c})}).catch(()=>{}).then(async d=>{const h=await za(d);return r(),h})}}const oy=`${ae()}/criteria-proposals`;async function mA(e){if(!e)return[];const t=await fetch(`${oy}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).proposals:[]}function pA(e){const[t,n]=y.useState([]),{reload:r}=Le({view:e,load:()=>mA(e),show:n,failed:()=>n([]),events:{"criteria-proposals":c=>(c==null?void 0:c.mapId)===e}});return{proposals:t,decide:(c,d)=>fetch(`${oy}/${c}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...d})}).catch(()=>{}).then(async h=>{const f=await za(h);return r(),f})}}function gA(e,t){const{tickets:n,confirm:r}=fA(e.map.id),a=pA(e.map.id),c=a.proposals.find(S=>S.ticketId===t.id),d=Es(),h=n.find(S=>S.ticketId===t.id),f=(h==null?void 0:h.criteria)??[],m=pa(t.id,h==null?void 0:h.hash),g=pa(c&&`${c.ticketId}@${c.at}`,c==null?void 0:c.hash),w=Ev(d.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:Av(`${t.body}
151
+ ${d.briefText}`)}).filter(S=>S.kind==="business-rule").filter(S=>Mb(f,[S.id]).length),b=S=>a.decide(S,{title:e.map.title,ticketId:t.id,hash:g.hash});return{criteria:f,confirmed:!!(h!=null&&h.confirmed),proposal:c,uncovered:w,changed:m.changed?m:void 0,proposalChanged:c&&g.changed?g:void 0,setConfirmed:S=>r({title:e.map.title,ticketId:t.id,ticketKey:t.key,confirmed:S,hash:m.hash}),take:()=>b("accept"),keep:()=>b("dismiss")}}function vA({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((r,a)=>a%2===1?s.jsx("code",{children:r.replace(/`/g,"")},a):r)},n))}):s.jsx(Ee,{children:"Not covered"})}const Vp=["summary","productContext","existing","conventions","dataModel","api","risks"];function kA(e){const{brief:t}=e,[n,r]=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,h=Vp.filter(m=>d[m].trim()),f=Vp.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:yA(t)})]}),s.jsxs("div",{className:"brief-body",children:[h.map(m=>s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:lr[m]}),s.jsx(vA,{text:d[m]}),(m==="conventions"||m==="productContext")&&d[m].trim()&&s.jsx(Zk,{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(Ee,{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(Ee,{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(bu,{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:()=>r(!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:()=>r(!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 yA(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 wA({brief:e,onReview:t}){return e.status!=="submitted"?null:s.jsx("div",{className:"brief-card",children:s.jsx(fe,{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 xA({onReview:e,onClose:t}){return y.useEffect(()=>{const n=r=>r.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 jA={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,r]=jA[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:r})]}),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 ay=`${ae()}/briefs`;async function SA(e){if(!e)return{brief:null};const t=await fetch(`${ay}?mapId=${encodeURIComponent(e)}`);return t.ok?await t.json():{brief:null}}function Ga(e){const t=e==null?void 0:e.map.id,[n,r]=y.useState(null),[a,c]=y.useState(),[d,h]=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:()=>SA(t),show:S=>{r(S.brief),h(S.hash),m(!!S.gated)},failed:()=>(r(null),m(!1)),changed:S=>S.startsWith("briefs/")}),w=(S,x,C)=>fetch(`${ay}/${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(),r(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 qp=new Set,Qp=e=>`teamtrail.brief-ready:${ae()}:${e.mapId}:${e.submittedAt??""}`,Yp={has(e){const t=Qp(e);if(qp.has(t))return!0;try{return localStorage.getItem(t)==="1"}catch{return!1}},add(e){const t=Qp(e);qp.add(t);try{localStorage.setItem(t,"1")}catch{}}};function NA(e){const[,t]=y.useState(0);return{show:(e==null?void 0:e.status)==="submitted"&&!Yp.has(e),close:()=>{e&&Yp.add(e),t(a=>a+1)}}}function $A(e,t){return e&&t.state==="open"&&!Cv.includes(t.type)}function CA(e){const{gated:t}=Ga(e);return n=>$A(t,n)}const TA=`${J.apiPrefix}/models`;async function EA(){const e=await fetch(TA);return e.ok?await e.json():null}function Iu(){const[e,t]=y.useState();return Le({load:EA,show:t,failed:()=>t(null),changed:n=>n.endsWith("models.json")||n.endsWith("map.md")||n.includes("/tickets/"),events:{attention:()=>!0}}),e}async function AA(){const e=await fetch(`${ae()}/signed-state`);return e.ok?await e.json():null}function cy(){const[e,t]=y.useState();return Le({load:AA,show:t,failed:()=>t(null),changed:n=>n.endsWith("map.md")||n.includes("/tickets/")||n.includes("/decisions/")}),e}const RA={ticket:"held until you accept or revert it",decision:"what you see is what was signed here, until you accept or revert it"};function MA(e){return e[0]==="added"?"added outside Teamtrail":e.map(t=>t==="words"?"its words":t).join(", ")}function IA({mapId:e,kind:t,id:n}){const r=cy(),a=d=>d.mapId===e&&d.kind===t&&d.id===n,c=r==null?void 0:r.changes.find(a);return c?s.jsx(fe,{className:"d-section",edge:"attention",title:"Changed outside Teamtrail",context:s.jsx(B,{parts:[`${MA(c.fields)} · ${RA[t]}`]}),detail:"By a teammate or an agent editing the file. Settings → Approvals shows what changed."}):r!=null&&r.textEdits.some(a)?s.jsx(B,{className:"d-section",parts:["Text edited outside Teamtrail"]}):null}const OA=e=>e[0]==="added"?"added outside Teamtrail":e.map(t=>t==="words"?"its words":t).join(", ");function LA(e){var h,f,m;const{t,snap:n}=e,r=e.items[0],a=new Map(n.tickets.map(g=>[g.id,g])),c=(h=e.verification)==null?void 0:h.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:r&&{kind:r.kind,edge:Tr(r,e.interrupting.includes(r.id))},outsideChange:e.change&&`${OA(e.change.fields)} · held until you accept or revert it`,lease:d,assignee:t.assignee,mine:e.mine,hitl:pi(t)==="hitl",briefHeld:PA(e),modelWait:e.modelWait&&{tier:e.modelWait.tier,best:e.modelWait.best},running:(f=e.verification)==null?void 0:f.running,latest:c&&DA(c),sentBack:BA(e.verification),reviewWaits:FA(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 PA(e){if(!(!e.brief||e.state!=="frontier"||Cv.includes(e.t.type)))return e.brief.status==="submitted"?"submitted":"writing"}function DA(e){var a;const t=e.checks.filter(c=>!Tk(c)).map(c=>c.name),n=e.flaky&&lu(e)?M0(e.flaky.checks):void 0,r=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,...r?{guarded:O0(r.findings)}:{},...n?{retried:n}:{}}}const _A={FAIL:"the review sent it back",NEEDS_HUMAN:"the reviewer asked for you"};function BA(e){const t=e==null?void 0:e.attempts[0],n=t&&e.verdicts.find(r=>r.attemptId===t.id);return n&&_A[n.verdict]}function FA(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 zA=new Set(["question","approval","blocked","hitl-ready","stalled","model"]);function UA(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=>!zA.has(c.kind)).map(c=>({text:c.title,risk:!0})),r=e.textEdited&&!e.change?[{text:"Text edited outside Teamtrail",risk:!1}]:[];return[...t,...n,...r]}function WA(e){const t=HA(e),n=t.edge==="neutral"||t.edge==="done";return e.atRisk&&n?{...t,edge:"attention"}:t}function HA(e){if(e.question)return GA(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 ${is(e.running.startedAt)}`]};switch(e.state){case"decided":return VA(e);case"out-of-scope":return{edge:"neutral",title:"Ruled out",parts:ly(e)};case"verifying":return QA(e);case"held":return KA(e);case"claimed":return YA(e);case"rework":return{edge:"attention",title:`Rework: ${dy(e)}`,parts:["waits for an agent"]};case"frontier":return JA(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 KA(e){var r,a,c,d;const t=((r=e.item)==null?void 0:r.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: ${dy(e)}`,parts:["waits on you"],primary:(d=e.latest)!=null&&d.failed.length?"waive":"unblock"}}function GA(e,t){var r;return{edge:((r=e.item)==null?void 0:r.kind)==="question"?e.item.edge:"urgent",title:`Waiting on you: answer ${t.agent}'s question`,parts:[ga(e.now,t.at)],primary:"answer"}}function VA(e){const t=qA(e.verified),n=e.pr&&`PR #${e.pr.number} ${e.pr.state}`;return{edge:"done",title:"Done",parts:[t,n,...ly(e)].filter(r=>!!r)}}function qA(e){if(e!==void 0)return e?"verified":"not verified"}function ly(e){return e.closedAt?[ga(e.now,e.closedAt)]:[]}function QA(e){var t;return((t=e.item)==null?void 0:t.kind)==="approval"?{edge:e.item.edge,title:"Waiting on you: approve it",parts:Jp(e),primary:"approve"}:e.reviewWaits?{edge:"neutral",title:"Waiting for a review agent",parts:Jp(e)}:{edge:"neutral",title:"Verifying",parts:[]}}function Jp(e){var t;return((t=e.latest)==null?void 0:t.result)==="pass"?["checks passed"]:[]}function dy(e){var n,r,a,c;const t=(n=e.latest)!=null&&n.failed.length?` (${e.latest.failed.join(", ")})`:"";return((r=e.latest)==null?void 0:r.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 YA(e){const t=e.lease;if(t&&t.health!=="live"){const r=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)}`,r];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 JA(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 r=["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:r,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 uy(e){var D,M,W;const{snap:t,t:n,api:r}=e,a=t.map.id,c=gt(1e3),d=Cs(t.tickets,t.map.mode).get(n.id),h=SE(a,n.id,n.updatedAt),f=u2(a,n.id),m=gA(t,n),g=cy(),k=Iu(),w=ns.ticket($r(),a,n.id),b=Ga(t),S=ty(),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"?gu(r.leases,a).get(n.id):void 0,session:e.sessions.find(_=>_.ticketId===n.id&&mn(_)),question:r.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:h.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:(W=S.view)==null?void 0:W.workspaces.find(_=>_.mapId===a&&_.ticketId===n.id&&!_.active)},N=UA(C),P=WA({...LA(C),atRisk:N.some(_=>_.risk)});return{...C,reloadVerification:h.reload,criteria:m,removeWorkspace:_=>S.remove(a,n.id,_),standing:P,notices:N}}function XA(e){return e.replace(/\s*Part of trail \S+\.\s*$/,"").trim()}function hy({v:e}){const t=XA(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(tk,{text:t}),s.jsx(uA,{c:n})]})}function ZA(e){const{snap:t,t:n,api:r}=e,a=uy({snap:t,t:n,api:r,sessions:e.sessions,attention:e.attention}),[c,d]=y.useState(!1),h=iy({v:a,api:r,setForm:e.setForm,onEditHow:()=>d(!0),onOpenChat:e.onOpenChat,onReviewChange:e.onReviewChange,onReviewBrief:e.onReviewBrief}),f=r.decisions.filter(m=>m.mapId===t.map.id&&m.ticketId===n.id);return s.jsxs("div",{className:"detail ticket-panel",children:[s.jsx(XE,{t:n,tickets:t.tickets}),s.jsx(KE,{v:a}),s.jsx(Lk,{v:a,bar:h,onOpenChat:e.onOpenChat}),s.jsx(sy,{form:e.form,setForm:e.setForm,v:a,actions:r.actions,act:h.act,waive:h.waive}),s.jsx(hy,{v:a}),s.jsx(FE,{v:a,editing:c,setEditing:d,act:h.act}),s.jsx(HE,{v:a,onUndoWaiver:h.undoWaiver}),s.jsx(KT,{mapId:t.map.id,ticketId:n.id}),s.jsx(d2,{ticket:n,view:a.proof}),s.jsx(w2,{t:n,decisions:f,onOpenDecision:e.onOpenDecision})]})}function eR(e){const t=e.snap.tickets.find(n=>n.id===e.id);return t?s.jsx(ZA,{...e,t},t.id):s.jsx(Ee,{children:"Ticket not found."})}const Xp=[{phase:"discovery",label:"Discovery"},{phase:"brief",label:"Brief"},{phase:"building",label:"Building"},{phase:"review",label:"Review"},{phase:"done",label:"Done"}],tR=new Set(["decided","out-of-scope"]),nR=new Set(["verifying","held"]);function sR(e){if(e.done)return"done";if(e.gated)return e.briefStatus==="submitted"?"brief":"discovery";const t=e.states.filter(n=>!tR.has(n));return t.length&&t.every(n=>nR.has(n))?"review":"building"}function iR(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 rR(e){const t=Xp.findIndex(a=>a.phase===e.phase),n=e.snap.tickets.filter(a=>e.states.get(a.id)!=="out-of-scope"),r=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:Xp.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:iR(e.phase,{done:r,total:n.length,reason:e.reason})})]})}function fy(e){var w,b,S;const{snap:t}=e,{brief:n,gated:r}=Ga(t),a=Cs(t.tickets,t.map.mode),c=!!e.done&&e.done.kind!=="not-done",d=sR({done:c,gated:r,briefStatus:n==null?void 0:n.status,states:[...a.values()]}),h=(((w=e.attention)==null?void 0:w.items)??[]).filter(x=>x.mapId===t.map.id),f=h[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(rR,{phase:d,snap:t,states:a,reason:c?(b=e.done)==null?void 0:b.reason:void 0}),c?s.jsx(pk,{mapId:t.map.id,now:e.now}):s.jsx(hk,{mapId:t.map.id,now:e.now}),f&&s.jsx(sn,{label:`Waits on you · ${h.length}`,children:s.jsx(fe,{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:kk({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(fe,{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(fe,{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 my({snap:e,item:t,api:n}){const r=iv(e.map.mode),[a,c]=y.useState("research"),[d,h]=y.useState(t),[f,m]=y.useState(!1),[g,k]=y.useState([]),[w,b]=y.useState("Not needed to reach the destination.");y.useEffect(()=>h(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=>h(x.target.value)})}),s.jsxs("div",{className:"chips",children:[r.map(x=>s.jsx("button",{type:"button",className:`chip ${a===x?"on":""}`,onClick:()=>c(x),children:x},x)),hj.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 oR(e){const{api:t}=e,{snap:n,selection:r,actions:a}=t,[c,d]=y.useState(null),h=gt(5e3),f=aR(r);y.useEffect(()=>d(null),[f]);const m=e.onOpenChat??a.openChat;let g;return n?(r==null?void 0:r.kind)!=="ticket"&&(r==null?void 0:r.kind)!=="unspecified"?g=s.jsx(fy,{snap:n,sessions:e.sessions,attention:e.attention,done:e.done,now:h,onTicket:k=>t.setSelection({kind:"ticket",id:k}),onItem:k=>{var w;return(w=e.onItem)==null?void 0:w.call(e,k)}}):r.kind==="unspecified"?g=s.jsx(my,{snap:n,item:r.item,api:t}):g=s.jsx(eR,{snap:n,id:r.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(N$,{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 aR(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 py(e){const t=Array.from({length:Math.max(1,e.total)},(n,r)=>r+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 cR({session:e}){const t=_a(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(py,{step:e.step,total:e.total})]})}function lR(e){const{v:t,need:n}=e,r=t.standing,a=t.lease&&Ts(t.lease,t.now),c=!!n&&n.text.toLowerCase().includes(t.t.title.toLowerCase()),d=!!n&&!!r.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-${r.edge}`),children:[s.jsx("span",{className:"state-title",children:r.title}),s.jsx(B,{parts:r.parts})]}),t.notices.filter(h=>h.text!==(n==null?void 0:n.item)).map(h=>s.jsx("span",{className:"t-meta bubble-notice",children:h.text},h.text)),t.session&&s.jsx(cR,{session:t.session}),s.jsx(hy,{v:t}),s.jsx("button",{type:"button",className:"link full-ticket",onClick:e.onFullTicket,children:"Full ticket"})]})}function dR(e){const{need:t,pr:n}=e,r=Tu(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:[...r,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 uR={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"},hR=e=>e.split(`
156
+ `)[0].replace(/^[^\s:]+: /,"");function fR(e){if(e.questionId)return{kind:"question",questionId:e.questionId};const t=e.items.find(r=>r.kind!=="question");return t?{kind:"item",label:uR[t.kind]??"Needs you",title:hR(t.title),urgent:e.urgentOf(t),item:t}:{kind:"none"}}function mR(e){var x,C,N,P;const{api:t,t:n}=e,r=uy({snap:e.snap,t:n,api:t,sessions:e.sessions,attention:e.attention}),[a,c]=y.useState(null),d=iy({v:r,api:t,setForm:c,onEditHow:e.onFullTicket,onOpenChat:e.onOpenChat,onReviewChange:e.onReviewChange,onReviewBrief:e.onReviewBrief}),h=fR({questionId:(x=r.question)==null?void 0:x.id,items:r.items,urgentOf:D=>Tr(D,r.interrupting.includes(D.id))==="urgent"}),f=h.kind==="question"||h.kind==="item"&&h.urgent,{onUrgent:m}=e;y.useEffect(()=>m(f),[f,m]);const g=h.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(Lk,{v:r,bar:k,onOpenChat:e.onOpenChat}),s.jsx(sy,{form:a,setForm:c,v:r,actions:t.actions,act:d.act,waive:d.waive})]}),b=D=>{var M;return(M=e.snap.tickets.find(W=>W.id===D))==null?void 0:M.key},S=((N=r.pr)==null?void 0:N.pr)&&{number:r.pr.pr.number,url:r.pr.pr.url};return s.jsxs(s.Fragment,{children:[g&&r.question&&s.jsx(Ek,{q:r.question,now:r.now,keyOf:b,onAnswer:t.actions.answer,onOpenChat:e.onOpenChat}),h.kind==="item"&&s.jsx(dR,{need:h,now:r.now,pr:S,actions:w}),s.jsx(lR,{v:r,need:pR(h,(P=r.question)==null?void 0:P.text),onFullTicket:e.onFullTicket}),h.kind!=="item"&&w]})}function pR(e,t){if(e.kind==="item")return{text:e.title,item:e.item.title};if(e.kind==="question")return{text:t??""}}function gR(e){const{selection:t,snap:n,api:r}=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(mR,{...e,snap:n,t:c},c.id):s.jsx(Ee,{children:"Ticket not found."})}case"main":return n?s.jsx(hk,{mapId:n.map.id,now:a}):null;case"together":return n?s.jsx(pk,{mapId:n.map.id,now:a,onUrgent:e.onUrgent}):null;case"question":{const c=r.activity.pending.find(h=>h.id===t.id);if(!c)return s.jsx(Ee,{children:"Answered."});const d=h=>{var f;return(f=n==null?void 0:n.tickets.find(m=>m.id===h))==null?void 0:f.key};return s.jsx(Ek,{q:c,now:a,keyOf:d,onAnswer:r.actions.answer,onOpenChat:e.onOpenChat})}case"unspecified":return null;default:return t}}const Zp=14,Nn=8;function vR(e){const{anchor:t,box:n,bubble:r}=e,a=Math.max(Nn,n.w-r.w-Nn),c=Math.max(Nn,n.h-r.h-Nn);if(!t)return{left:a,top:Nn,side:"corner"};const d=(t.top+t.bottom)/2,h=Math.min(c,Math.max(Nn,d-r.h/2)),f=t.right+Zp,m=t.left-Zp-r.w;if(f+r.w<=n.w-Nn)return{left:f,top:h,side:"right"};if(m>=Nn)return{left:m,top:h,side:"left"};const g=n.w-t.right,k=t.left;return g>=k?{left:Math.min(f,a),top:h,side:"right"}:{left:Math.max(Nn,m),top:h,side:"left"}}function kR(e){const t=y.useRef(null),[n,r]=y.useState({w:0,h:0});y.useLayoutEffect(()=>{const h=t.current;if(!h||e.docked)return;const f=new ResizeObserver(()=>r({w:h.offsetWidth,h:h.offsetHeight}));return f.observe(h),()=>f.disconnect()},[e.docked]);const{onClose:a}=e;y.useEffect(()=>{const h=f=>f.key==="Escape"&&!f.defaultPrevented&&a();return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[a]);const c=vR({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 yR={ticket:"Ticket",main:"Checks on main",together:"Destination",question:"Question"};function wR(e){if(e.kind==="ticket")return e.id;if(e.kind==="main")return"main";if(e.kind==="together")return"destination"}function xR(e){var g,k;const{api:t,nav:n,attn:r}=e,a=t.selection,[c,d]=y.useState(!1),h=y.useCallback(w=>d(w),[]);if(!a||a.kind==="unspecified"||n.fullTicket||!t.snap&&a.kind!=="question")return null;const f=wR(a),m=a.kind==="main"?e.mainNeeds:a.kind==="question"||c;return s.jsx(kR,{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:yR[a.kind],onClose:()=>n.select(null),children:s.jsx(gR,{selection:a,snap:t.snap,api:t,sessions:e.sessions,attention:r.attention.view,onUrgent:h,onFullTicket:()=>n.setFullTicket(!0),onOpenChat:w=>n.openChat(w),onReviewChange:r.handlers.openApprovals,onReviewBrief:r.handlers.openBrief})})}const jR=["plan","activity","logbook"],gy=[{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:r}=e,{snap:a,actions:c}=t,[d]=$u(15e3),h=Es(),f=d?xC(d):void 0;return s.jsx(xT,{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(bT,{tabs:gy,value:e.view,onChange:e.onView}),needs:s.jsx(jT,{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:h.attention,knowledgeOpen:h.open,onKnowledge:()=>h.setOpen(!h.open),briefingOpen:r.shown,briefingStatus:r.status,onBriefing:()=>r.shown?r.dismiss():r.open()})}function SR(e){return s.jsx(lT,{seed:e.seed,onClose:e.onClose,tracker:e.rt.adapter.label,onCreate:async t=>{const n=await h1(e.rt.adapter,t);return e.onCreated(n.id),n}})}const NR={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"},Ou=e=>NR[e];function Lu(e){var t;return((t=e.account)==null?void 0:t.kind)==="user"?e.account.login:void 0}const hd=e=>!!e.auth&&!!Lu(e);function vy(e,t){const n=Lu(e);return!e.auth||!n?void 0:`Will use ${t||"the repo you pick"} as ${n} (${Ou(e.auth)})`}function $R(e){if(!e.repo)return;const t=Lu(e),n=t?` as ${t}`:"",r=e.auth?`, using ${Ou(e.auth)}`:"";return`Connected to ${e.repo}${n}${r}`}function CR(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 TR(e){const{gh:t}=e;if(!t.auth)return null;const n=vy(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 ER=/^[\w.-]+\/[\w.-]+$/;function AR(e){const t=e.query.trim().toLowerCase(),r=!!e.detected&&e.repos.every(f=>f.fullName!==e.detected)?[{fullName:e.detected,private:!1},...e.repos]:e.repos,a=[...r.filter(f=>f.fullName===e.detected),...r.filter(f=>f.fullName!==e.detected)],c=t?a.filter(f=>f.fullName.toLowerCase().includes(t)):a,h=ER.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:h}}function eg(e){const{repo:t,listed:n}=e,r=t.private?"Private":"Public";return s.jsx(fe,{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&&r,n&&CR(t,e.now),!n&&"Checked when you connect"]}),onOpen:e.onPick})}const RR=40;function tg(e){const[t,n]=y.useState(""),r=y.useMemo(()=>Date.now(),[]),a=y.useMemo(()=>new Set(e.repos.map(g=>g.fullName)),[e.repos]),{shown:c,matches:d,typed:h}=AR({repos:e.repos,detected:e.detected,query:t,limit:RR}),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:[h&&s.jsx(eg,{repo:{fullName:h,private:!1},detected:h===e.detected,listed:!1,selected:h===e.value,now:r,onPick:()=>e.onChange(h)}),c.map(g=>s.jsx(eg,{repo:g,detected:g.fullName===e.detected,listed:a.has(g.fullName),selected:g.fullName===e.value,now:r,onPick:()=>e.onChange(g.fullName)},g.fullName))]}),s.jsx(B,{parts:[!d&&!h&&"No repo matches",f,m]})]})}function MR(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(tg,{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(Su,{what:"Couldn't list your repos",reason:t.error,onRetry:e.onRetry}),s.jsx(tg,{repos:[],truncated:!1,detected:e.detected,value:e.value,onChange:e.onChange})]});default:return t}}const IR={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 ky(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:IR[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:r=>e.onChange(r.target.value)})]})}function OR(e){const[t,n]=y.useState(!1),r=()=>{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:r,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:r,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 LR(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 PR(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=CS(ae());function vr(e,t){e({tracker:t});const n=new URL(location.href);n.searchParams.delete("tracker"),location.href=n.toString()}function DR(e){const[t,n]=y.useState({kind:"idle"}),r=y.useRef(e);r.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 h=>{c&&(h.kind==="signed-in"&&await r.current(),c&&n(PR(t,h)))},h=>c&&n({kind:"ended",reason:h.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(LR(c)),c=>n({kind:"ended",reason:c.message}))},cancel(){n({kind:"idle"})}}}function _R(e){const{state:t,start:n,cancel:r}=DR(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(OR,{code:t.userCode,href:t.verificationUri,onCancel:r});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 BR(e){var d,h;const{gh:t}=e,n=t.auth&&((d=t.account)==null?void 0:d.kind)==="unknown"?`Found ${Ou(t.auth)}, but GitHub didn't accept it`:"",r=((h=t.account)==null?void 0:h.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,r]}),c&&s.jsx(_R,{onSignedIn:e.onSignedIn}),c&&s.jsx("span",{className:"t-label gh-or",children:"Or paste a token"}),s.jsx(ky,{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 yy({r:e}){var r,a;if(!e)return null;if(!e.ok)return s.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]});const t=(r=e.rate)!=null&&r.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 Pu(e){const[t,n]=y.useState(),[r,a]=y.useState(0);y.useEffect(()=>{if(n(void 0),!e.enabled)return;let d=!0;return e.load().then(h=>d&&n(h),h=>d&&n(e.failed(h.message))),()=>{d=!1}},[e.enabled,e.key,r]);const c=y.useCallback(()=>a(d=>d+1),[]);return{value:t,retry:c}}function FR(e){const{value:t,retry:n}=Pu({enabled:e.enabled,key:e.auth??"",load:()=>Kt.githubRepos(),failed:r=>({kind:"error",error:r})});return{list:t,retry:n}}function wy(e){const t=e.s.github,n=hd(t),[r,a]=y.useState(!n),[c,d]=y.useState(t.repo??t.detectedRepo??""),[h,f]=y.useState(""),[m,g]=y.useState(),[k,w]=y.useState(!1),{list:b,retry:S}=FR({enabled:!r,auth:t.auth});y.useEffect(()=>{n&&!h&&a(!1)},[n]);const x=async()=>{w(!0),g(void 0);try{await Kt.connect({active:"github",github:{repo:c,token:r?h:void 0}}),e.onConnected()}catch(M){g({ok:!1,error:M.message}),w(!1)}},C=async()=>{const M=await e.reload();M&&hd(M.github)&&a(!1)},N=async()=>{await Kt.githubSignIn.signOut().catch(()=>{});const M=await e.reload();a(!M||!hd(M.github))},D=!!c&&!(!r&&!b)&&(!r||!!h||n);return s.jsxs("div",{className:"card inset tracker-setup",children:[r?s.jsx(BR,{gh:t,token:h,onToken:f,repo:c,onRepo:d,onSignedIn:C}):s.jsxs(s.Fragment,{children:[s.jsx(TR,{gh:t,repo:c,onUseAnother:()=>a(!0),onSignOut:()=>void N()}),s.jsx(MR,{list:b,detected:t.detectedRepo,value:c,onChange:d,onRetry:S})]}),s.jsx(yy,{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 zR(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 UR={LINEAR_API_KEY:"LINEAR_API_KEY",stored:"a saved key"},Du=e=>UR[e]??e;function Va(e){return(e==null?void 0:e.kind)==="user"?e:void 0}const WR=e=>!!e.auth&&!!Va(e.viewer);function xy(e,t){if(e)return t?`${e} / ${t}`:e}function jy(e){const t=Va(e.viewer);if(!t)return;const n=xy(e.team,e.project)??"the team you pick",r=e.source?` (${Du(e.source)})`:"";return`Will use ${n} in ${t.orgName} as ${t.name}${r}`}function HR(e){const t=xy(e.teamName??e.teamKey,e.projectName);if(!e.teamId||!t)return;const n=Va(e.viewer),r=e.orgName??(n==null?void 0:n.orgName),a=r?` in ${r}`:"",c=n?` as ${n.name}`:"",d=e.auth?`, using ${Du(e.auth)}`:"";return`Connected to ${t}${a}${c}${d}`}function KR(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 GR(e){var a,c;const{ln:t}=e,n=t.auth&&((a=t.viewer)==null?void 0:a.kind)==="unknown"?`Found ${Du(t.auth)}, but Linear didn't accept it`:"",r=((c=t.viewer)==null?void 0:c.kind)==="unknown"?t.viewer.error:"";return s.jsxs(s.Fragment,{children:[n&&s.jsx(B,{parts:[n,r]}),s.jsx(ky,{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 VR(e){const{list:t}=e;if(!t)return s.jsx(yi,{label:"Loading projects…"});if(t.kind==="error")return s.jsx(Su,{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(r=>({value:r.id,label:r.state?`${r.name} · ${r.state}`:r.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 qR(e){const t=e.query.trim().toLowerCase(),n=t?e.teams.filter(r=>r.key.toLowerCase().includes(t)||r.name.toLowerCase().includes(t)):e.teams;return{shown:n.slice(0,e.limit),matches:n.length}}function QR(e,t){return t&&e.some(n=>n.id===t)?t:e.length===1?e[0].id:void 0}function YR(e){const{team:t}=e;return s.jsx(fe,{as:"li",className:"repo-row team-row",selected:e.selected,title:t.name,context:s.jsx(B,{parts:[{text:t.key,code:!0},KR(t,e.now)]}),onOpen:e.onPick})}const JR=40;function XR(e){const[t,n]=y.useState(""),r=y.useMemo(()=>Date.now(),[]),{shown:a,matches:c}=qR({teams:e.teams,query:t,limit:JR}),d=c>a.length?`${c-a.length} more: type to narrow`:"",h=e.truncated?`The first ${e.teams.length} teams`:"",f=e.value?"":"Pick the team your trails go in";return 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(YR,{team:m,selected:m.id===e.value,now:r,onPick:()=>e.onChange(m.id)},m.id))}),s.jsx(B,{parts:[!c&&"No team matches",f,d,h]})]})}function ZR(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(XR,{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(Su,{what:"Couldn't list your teams",reason:t.error,onRetry:e.onRetry});default:return t}}function eM(e,t){const[n,r]=y.useState(e);return y.useEffect(()=>{const a=setTimeout(()=>r(e),t);return()=>clearTimeout(a)},[e,t]),n}function tM(e){const{value:t,retry:n}=Pu({enabled:e.enabled&&!!e.teamId,key:`${e.teamId}
157
+ ${e.apiKey??""}`,load:()=>Kt.linearProjects(e.teamId,e.apiKey),failed:r=>({kind:"error",error:r})});return{list:t,retry:n}}function nM(e){const{value:t,retry:n}=Pu({enabled:e.enabled,key:e.apiKey??"",load:()=>Kt.linearTeams(e.apiKey),failed:r=>({kind:"error",error:r})});return{list:t,retry:n}}function sM(e){const t=eM(e.apiKey.trim(),400),n=e.paste&&t?t:void 0,r=e.paste?!!t:!!e.ln.auth,a=nM({enabled:r,apiKey:n}),c=tM({teamId:e.teamId,apiKey:n,enabled:r}),d=a.list,h=c.list,f=(d==null?void 0:d.kind)==="ok"?d.teams:[],m=r&&!d,g=r&&!!e.teamId&&!h;return{enabled:r,list:d,teams:f,projects:h,loading:m||g,retryTeams:a.retry,retryProjects:c.retry}}function by(e){var Z;const t=e.s.linear,n=WR(t),[r,a]=y.useState(!n),[c,d]=y.useState(""),[h,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:W}=sM({ln:t,paste:r,apiKey:c,teamId:h});y.useEffect(()=>{n&&!c&&a(!1)},[n]),y.useEffect(()=>{(C==null?void 0:C.kind)==="ok"&&f(QR(C.teams,t.teamId)??"")},[C]);const _=N.find(se=>se.id===h),Y=(P==null?void 0:P.kind)==="ok"?P.projects.find(se=>se.id===m):void 0,re=(C==null?void 0:C.kind)==="ok"?C.viewer:t.viewer,q=r?null:t.auth,ye=jy({viewer:re,team:_==null?void 0:_.name,project:Y==null?void 0:Y.name,source:q}),Ie=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:r?c.trim():void 0}}),e.onConnected()}catch(se){w({ok:!1,error:se.message}),S(!1)}}},be=se=>{f(se),g("")};return s.jsxs("div",{className:"card inset tracker-setup linear-setup",children:[r&&s.jsx(GR,{ln:t,apiKey:c,onKey:d}),s.jsx(zR,{line:ye,email:(Z=Va(re))==null?void 0:Z.email,onUseAnother:r?void 0:()=>a(!0)}),x&&s.jsx(ZR,{list:C,value:h,onChange:be,onRetry:M}),_&&s.jsx(VR,{list:P,value:m,onChange:g,onRetry:W}),s.jsx(yy,{r:k}),s.jsx("footer",{children:s.jsx("button",{type:"button",className:"btn primary",disabled:b||D||!_,onClick:()=>void Ie(),children:b?"Connecting…":"Connect"})})]})}function iM(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 rM(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 oM(e){const{id:t,active:n,s:r}=e,a=gr(t),c=n&&r?aM(t,r):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:rM(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&&r?s.jsx("div",{className:"c-loc",children:cM(t,r)}):null}function aM(e,t){if(e==="github")return $R(t.github);if(e==="linear")return HR(t.linear)}function cM(e,t){return e==="github"?t.github.repo:[t.linear.teamKey,t.linear.projectName].filter(Boolean).join(" · ")}function lM({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`:"",[r,a]=dM(e,n);return s.jsxs("div",{className:`sync-line ${r}`,title:e.error,children:[s.jsx("span",{className:"dot"}),s.jsx("span",{children:a}),t&&s.jsx("span",{className:"rate",children:t})]})}function dM(e,t){switch(e.state){case"online":return["ok",`Online · synced ${Gv(e.lastSyncAt)}${t}`];case"offline":return["warn",`Offline${t}`];case"rate-limited":return["warn",`Rate limited · resumes ${is(e.resetAt)}${t}`];case"auth-error":return["alert",`Credentials rejected${t}`];default:return["",`Connecting${t}`]}}function uM(e){const{id:t,active:n,configured:r,s:a}=e,c=gr(t),d=!c||!!a,h=["card connector",n?"active":"",d?"":"disabled",e.open?"open":""];return s.jsxs("div",{className:h.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(oM,{id:t,active:n,configured:r,location:e.location,s:a}),c&&n&&s.jsx(lM,{status:a==null?void 0:a[t].status}),s.jsx(iM,{canSwitch:!n&&(!c||r),remote:c,usable:d,configured:r,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function Sy(e=0){const[t,n]=y.useState(),r=y.useCallback(()=>Kt.get().then(a=>(n(a),a),()=>(n(null),void 0)),[]);return y.useEffect(()=>{if(r(),!e)return;const a=setInterval(()=>void r(),e);return()=>clearInterval(a)},[r,e]),[t,n,r]}function hM(e){const[t,,n]=Sy(5e3),[r,a]=y.useState(null),c=async h=>{t&&(h==="markdown"||gr(h))&&await Kt.connect({active:h==="markdown"?"markdown":h,...h==="github"&&t.github.repo?{github:{repo:t.github.repo}}:{},...h==="linear"&&t.linear.teamId?{linear:{teamId:t.linear.teamId,teamKey:t.linear.teamKey,teamName:t.linear.teamName,projectId:t.linear.projectId,projectName:t.linear.projectName}}:{}}).catch(()=>{}),vr(e.update,h)},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:TS.map(h=>{const f=h.id;return s.jsx(uM,{id:f,name:h.name,active:f===e.activeTracker,configured:gr(f)&&d[f],open:r===f,location:e.location,s:t,onSwitch:()=>void c(f),onToggle:()=>gr(f)&&a(r===f?null:f)},h.id)})}),t&&r==="github"&&s.jsx(wy,{s:t,reload:n,onConnected:()=>vr(e.update,"github")}),t&&r==="linear"&&s.jsx(by,{s:t,onConnected:()=>vr(e.update,"linear")})]})}function fM(e,t){const n=e==null?void 0:e.github,r=e==null?void 0:e.linear,a=n&&t!=="github"?vy(n,n.repo??n.detectedRepo):void 0,c=r&&t!=="linear"?jy({viewer:r.viewer,team:r.teamName,project:r.projectName,source:r.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 Ny(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 mM={github:"Checking for a GitHub login…",linear:"Checking for a Linear key…"};function pM(e){var C;const{prefs:t,update:n}=e,[r,,a]=Sy(5e3),[c,d]=y.useState(!1),h=(C=r==null?void 0:r.pending)==null?void 0:C.target.split(":")[0],[f,m]=y.useState(!1);y.useEffect(()=>{h&&!f&&t.tracker!==h&&n({tracker:h})},[h,f,t.tracker,n]);const g=fM(r??void 0,t.tracker),k=t.tracker==="github"||t.tracker==="linear",w=k&&(r==null?void 0:r.active)===t.tracker,b=k&&!w,S=N=>{n({onboarded:!0}),vr(n,N)},x=async()=>{d(!0);const N=r&&!r.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(Fa,{className:"onb-title"})}),s.jsxs("h2",{className:"onb-question t-heading",children:[s.jsx(x$,{className:"voice-badge",size:22}),"Where should your trails live?"]}),s.jsxs(Ae,{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))}),(r==null?void 0:r.pending)&&s.jsxs("p",{className:"t-meta onb-repo-tracker",children:["This repo keeps its trails in ",r.pending.label,". Connect it here, or keep local files on this machine; the team's choice in the repo isn't changed either way."]}),r===void 0&&k&&s.jsx(yi,{label:mM[t.tracker]??"Checking…"}),r&&t.tracker==="github"&&!w&&s.jsx(wy,{s:r,reload:a,onConnected:()=>S("github")}),r&&t.tracker==="linear"&&!w&&s.jsx(by,{s:r,onConnected:()=>S("linear")})]}),s.jsx(Ae,{title:"HITL transcript",children:s.jsx(Ny,{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 gM(e){var t;return(t=pt())!=null&&t.tracker?null:s.jsx(pM,{...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 _u(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 r=n.sections.find(a=>a.id===e);return{group:n.id,section:r==null?void 0:r.id}}function vM(e,t){const n=new URL(e);return n.searchParams.set("when",t.when.join(",")),n.searchParams.set("why",t.why),n.toString()}function kM(e,t){var r;const n=String((r=_u("rules"))==null?void 0:r.section)==="rules";e(n?"rules":"verification"),history.replaceState(history.state,"",vM(location.href,t))}function yM(){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 ng={from:"18:00",to:"09:00"};function wM(e){const t=e.focus!==void 0,n=e.focus??ng;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:ng),children:t?"On":"Off"}),t&&s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"time","aria-label":"Quiet from",value:n.from,onChange:r=>r.target.value&&e.onChange({...n,from:r.target.value})}),s.jsx("span",{className:"t-meta",children:"to"}),s.jsx("input",{type:"time","aria-label":"Quiet until",value:n.to,onChange:r=>r.target.value&&e.onChange({...n,to:r.target.value})})]})]})}const fd=[3,5,8,12];function xM(e){const t=e&&!fd.includes(e)?[...fd,e].sort((n,r)=>n-r):fd;return[{value:"off",label:"Off"},...t.map(n=>({value:String(n),label:`${n} waiting`}))]}const sg=e=>`${e} finished ticket${e===1?"":"s"}`;function jM(e,t){const n=(e==null?void 0:e.waiting.length)??0;return t?e!=null&&e.full?`${sg(n)} wait: agents start no new implementation work until you review some.`:`${n} of ${t} waiting: agents start new work.`:n?`${sg(n)} wait for your review now.`:"Nothing waits for your review now."}function bM(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:xM(t),disabled:e.local===!1,onChange:r=>e.onChange(r==="off"?null:Number(r))})]}),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. ",jM(n,t)]})]})}const SM=[{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 NM(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function $M(){const{view:e,error:t,savePrefs:n,saveReviewLimit:r}=$k(0),a=xi();if(!e)return null;const c=e.policy.value,d=`${J.dataDir}/attention.json`,h=m=>void n({...e.prefs,...m}),f=typeof Notification<"u"&&Notification.permission==="denied";return s.jsxs(Ae,{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:SM,onChange:m=>{m==="browser"&&NM(),h({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(wM,{focus:e.prefs.focus,onChange:m=>h({focus:m})}),s.jsx("span",{className:"set-hint t-meta",children:"Your channel and quiet hours stay on this machine."}),s.jsx(bM,{limit:c.reviewLimit,review:e.review,local:a,onChange:m=>void r(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 CM=[5,15,30,60];function TM(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})}),CM.map(n=>s.jsx(ct,{on:t.enabled&&t.awayMinutes===n,title:`Away ${n} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:n})},n))]})}const EM={repo:"Committed to the repo",machine:"Only on this machine",browser:"Only in this browser"};function We(e){const t=e.storage&&EM[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 AM(e){const[t]=$u();return t?s.jsx(Ae,{title:"Slack",children:s.jsx(wC,{focus:e.focus})}):null}function RM({data:e,route:t}){return s.jsxs(s.Fragment,{children:[s.jsx(We,{id:"attention",storage:"repo",children:s.jsx($M,{})}),s.jsx(We,{id:"slack",storage:"machine",children:s.jsx(AM,{focus:t.section==="slack"})}),s.jsx(We,{id:"trip-report",storage:"browser",children:s.jsx(Ae,{title:"Trip report",children:s.jsx(TM,{value:e.prefs.briefing,onChange:n=>e.update({briefing:n})})})})]})}const MM=[{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"]}],IM=[{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"]}],OM=[{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"]}],LM=[{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"]},...OM],PM=[{area:"Teamtrail Cloud",items:["The Lookout as an app on your phone, with a nudge only for the calls that need you"]}],DM=[{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"]},{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"]},...MM,...IM,...LM];function _M(){return s.jsxs("div",{className:"changelog",children:[s.jsxs("div",{className:"about",children:[s.jsx(Fa,{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(Ae,{title:"Next",children:PM.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))}),DM.map(e=>s.jsx(Ae,{title:`${e.version} · ${e.date}`,children:s.jsx("ul",{children:e.items.map(t=>s.jsx("li",{children:t},t))})},e.version))]})}const ig={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"},rg={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 $y(e){return e.kind==="state"?BM(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 BM(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 FM="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 zM(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 UM=["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 WM(e){const{queue:t}=e;return s.jsx(fe,{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 HM(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 KM=e=>e.files??(e.file?[e.file]:[]);function GM(e){const{item:t}=e,[n,r]=y.useState(!1),a=KM(t),c=t.revert??"restore";return s.jsx(fe,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:s.jsx(B,{parts:[$y(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"?r(!0):e.onRevert(),children:c==="delete"?"Delete…":"Revert"})]}),e.local&&n&&s.jsx(HM,{files:a,busy:e.busy,onDelete:()=>(r(!1),e.onRevert(a)),onCancel:()=>r(!1)})]})})}function VM(e){const{tracker:t}=e;return s.jsx(fe,{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 qM(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 QM(e){const{item:t}=e,n=t.committed===!1,r=t.kind==="catalogs"?[...t.lines,""]:[],a=n?[...r,...t.content.split(`
160
+ `)]:t.lines;return s.jsx(fe,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:s.jsx(B,{parts:[$y(t)]}),detail:ig[t.kind],detailText:ig[t.kind],below:s.jsxs("div",{className:"ap-below",children:[s.jsx("pre",{className:"ap-lines t-code",children:a.join(`
161
+ `)}),rg[t.kind]&&s.jsx("p",{className:"ap-note t-meta",children:rg[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(Ka,{findings:t.screening??[],named:!0,action:e.local&&s.jsx("a",{...qM("verification"),children:"Edit checks"})}),e.local&&s.jsx(I,{size:"sm",disabled:e.busy,onClick:e.onApprove,children:"Approve"})]})})}async function og(e,t){const n=await fetch(`${ae()}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Error(r.error??`Request failed (${n.status})`);return r}const md=async e=>e.ok?await e.json():void 0;async function ag(){var m;const[e,t,n]=await Promise.all(["/trust","/trackers","/trackers/legacy-outbox"].map(g=>fetch(`${ae()}${g}`))),r=await md(e);if(!r)return null;const{items:a}=r,c=(m=await md(t))==null?void 0:m.pending,d=await md(n),h=r.firstRun===!0,f=r.stateFirstRun===!0;return{items:a,firstRun:h,stateFirstRun:f,...c?{tracker:c}:{},...d!=null&&d.writes?{oldQueue:d}:{}}}const YM=(e,t)=>{var n,r,a,c;return JSON.stringify([e.items.map(d=>d.hash),(n=e.tracker)==null?void 0:n.target,(r=e.oldQueue)==null?void 0:r.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 JM(e){var n,r;const t=[(n=e.changed)!=null&&n.length?`${e.changed.length} changed while you looked, so they wait; look again`:"",(r=e.refused)!=null&&r.length?`${e.refused.length} not committed, so they need their own look`:""].filter(Boolean);return t.length?`${t.join(". ")}.`:void 0}function XM(){const[e,t]=y.useState(),[n,r]=y.useState(!1),a=y.useRef();y.useEffect(()=>void(a.current=e),[e]);const c=y.useRef(0),[d]=y.useState(gi),h=y.useRef(0),f=y.useCallback(()=>{h.current++;const b=d.start(),S=x=>{b()&&(a.current=x,t(x),r(!1))};return ag().then(S,()=>S(null))},[d]),m=y.useCallback(async()=>{if(c.current)return;const b=h.current,S=await ag().catch(()=>null),x=a.current;h.current!==b||x===void 0||(!S||!x||!YM(S,x))&&r(!0)},[]);y.useEffect(()=>void f(),[f]),y.useEffect(()=>Da(b=>void(b.startsWith(".")||m())),[m]),y.useEffect(()=>rs(()=>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=>JM(await g(()=>og("/trust/approve",{items:b.map(S=>({key:S.key,hash:S.hash}))}))),[g]),w=y.useCallback(async(b,S)=>{await g(()=>og(b,S))},[g]);return{view:e,changed:n,load:f,approve:k,act:w}}function ZM(){const{view:e,changed:t,load:n,approve:r,act:a}=XM(),c=xi()!==!1,[d,h]=y.useState(!1),[f,m]=y.useState();if(!e)return null;const g=N=>{h(!0),m(void 0),N.then(P=>(h(!1),m(P??void 0)),P=>(h(!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(Ae,{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:zM(x.length)}),k.some(N=>N.kind==="state")&&s.jsx("p",{className:"ap-note t-meta",children:FM}),C>0&&s.jsxs("ul",{className:"ap-list",children:[w&&s.jsx(VM,{tracker:w,busy:d,local:c,onDecide:N=>g(a("/trackers/approval",{use:N,target:w.target}))}),b&&s.jsx(WM,{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(GM,{item:N,busy:d,local:c,onAccept:()=>g(r([N])),onRevert:P=>g(a("/trust/revert",{key:N.key,hash:N.hash,remove:P}))},N.key):s.jsx(QM,{item:N,busy:d,local:c,onApprove:()=>g(r([N]))},N.key))]}),c&&x.length>1&&s.jsxs(I,{disabled:d||t,onClick:()=>g(r(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:UM})]})}const Cy="0.61.0",Vd="<endpoint>",Bu=Kg(Cy,["mcp","--http"]);function eI(e,t){const n=Kg(Cy,["connect",e,"--url"]),r=t===Vd?t:Hg(t);return`read -rs ${J.tokenEnv} && export ${J.tokenEnv}
162
+ ${n} ${r}`}function tI(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 nI({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},...tI(n)]})},n.url)),!t&&s.jsx("li",{children:s.jsx(B,{className:"set-hint",parts:["For agents on other machines, start their server",{text:Bu,code:!0}]})})]})}function sI(e){const[t,n]=y.useState(""),[r,a]=y.useState(!1),[c,d]=y.useState(),h=async f=>{if(!f.trim()||r)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(Ba,{value:t,onValueChange:n,onSubmit:h,action:"Create token",actionDisabled:r||!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 iI(){return s.jsx(Ae,{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 rI(e){const[t,n]=y.useState(!1),[r,a]=y.useState(!1),[c,d]=y.useState(),h=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:r,onClick:h,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 oI(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(fe,{as:"li",className:"ra-row",title:n.name,titleText:n.name,context:s.jsx(B,{parts:[`Created ${Ns(n.createdAt,t)}`,n.lastUsedAt?`Last used ${Ns(n.lastUsedAt,t)}`:"Never used"]}),below:s.jsx(rI,{name:n.name,onRevoke:()=>e.onRevoke(n.id)})},n.id))})}function pd(e){const[t,n]=y.useState(!1),r=()=>{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:r,children:t?"Copied":e.copyLabel??"Copy"})]})}const aI=[{id:"claude",label:"Claude Code"},{id:"codex",label:"Codex"}];function cI(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(pd,{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(pd,{label:"Start command",value:Bu,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:aI.map(r=>s.jsx(I,{size:"sm",on:t===r.id,"aria-pressed":t===r.id,onClick:()=>n(r.id),children:r.label},r.id))})]}),s.jsx(pd,{label:"Connect command",value:eI(t,e.endpoint??Vd),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 ${Vd}.`,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 Ty=`${ae()}/remote-agents`;async function cg(e,t){const n=await fetch(`${Ty}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:n.ok,reply:await n.json()}}async function lI(){const e=await fetch(Ty);return e.ok?await e.json():(await e.json().catch(()=>({}))).elsewhere?"elsewhere":null}function dI(){const[e,t]=y.useState(),[n,r]=y.useState(),{pushed:a}=Le({load:lI,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 cg("/tokens",{name:f});if(!m||!g.token||!g.created)return g.error??"The token could not be created.";c(g),r({token:g.token,name:g.created.name})},[c]),h=y.useCallback(async f=>{const{ok:m,reply:g}=await cg("/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:()=>r(void 0),create:d,revoke:h}}function uI(){var d;const{view:e,created:t,dismissCreated:n,create:r,revoke:a}=dI();if(!e)return null;if(e==="elsewhere")return s.jsx(iI,{});const c=(d=e.endpoints.find(h=>h.kind==="standalone"))==null?void 0:d.url;return s.jsxs(Ae,{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(nI,{endpoints:e.endpoints}),t&&s.jsx(cI,{created:t,endpoint:c,onDone:n}),s.jsx(oI,{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(sI,{onCreate:r}),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:Bu}),", 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 lg={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"},hI={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},fI=e=>e[0].toUpperCase()+e.slice(1),qd=kv.map(e=>({value:e,label:fI(e),hint:hI[e]}));function mI(e){const[t,n]=y.useState(""),[r,a]=y.useState("high"),{rules:c,onChange:d}=e,h=()=>{const f=t.trim();!f||c.some(m=>m.glob===f)||(d([...c,{glob:f,level:r}]),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:qd,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"&&h()}),s.jsx(rt,{compact:!0,"aria-label":"New pattern risk",value:r,options:qd,onChange:a}),s.jsx(I,{onClick:h,disabled:!t.trim(),children:"Add"})]})]})}const Ey=`${ae()}/policy`;async function pI(){const e=await fetch(Ey);return e.ok?await e.json():null}function gI(){const[e,t]=y.useState(),{pushed:n}=Le({load:pI,show:t,failed:()=>t(null),changed:a=>a.endsWith("policy.json")}),r=y.useCallback(async a=>{const c=await fetch(Ey,{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:r}}function vI(){const{view:e,save:t}=gI(),[n,r]=y.useState();if(!e)return null;const a=`${J.dataDir}/policy.json`,c=d=>{r(void 0),t(d).then(r,h=>r(h.message))};return s.jsxs(Ae,{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:vv.map(d=>s.jsxs("label",{className:"risk-row",children:[s.jsx("span",{children:lg[d]}),s.jsx(rt,{compact:!0,"aria-label":`${lg[d]} risk`,value:e.policy.categories[d],options:qd,onChange:h=>c({...e.policy,categories:{...e.policy.categories,[d]:h}})})]},d))}),s.jsx(mI,{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 kI(){const{view:e,save:t,remove:n}=ty(),[r,a]=y.useState();if(!e)return null;const c=e.settings.worktrees,d=()=>{a(void 0),t({...e.settings,worktrees:!c}).then(a,h=>a(h.message))};return s.jsxs(Ae,{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},dg(e.workspaces.filter(h=>h.active).length,"active"),dg(e.workspaces.filter(h=>!h.active).length,"finished")]}),s.jsx(VE,{rows:e.workspaces,onRemove:n}),e.errors.length>0&&s.jsx("ul",{className:"vf-errors",children:e.errors.map(h=>s.jsx("li",{children:h},h))}),r&&s.jsx("span",{className:"vf-err",children:r})]})}const dg=(e,t)=>`${e} ${t}`;function yI({data:e,route:t}){var n;return s.jsxs(s.Fragment,{children:[s.jsx(We,{id:"approvals",storage:"machine",children:s.jsx(ZM,{})}),s.jsx(We,{id:"tracker",children:s.jsx(Ae,{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(hM,{activeTracker:e.activeTracker,location:e.location,update:e.update})})}),s.jsx(We,{id:"workspaces",storage:"repo",children:s.jsx(kI,{})}),s.jsx(We,{id:"proof",storage:"machine",children:s.jsx(r2,{})}),s.jsx(We,{id:"remote-agents",storage:"machine",children:s.jsx(uI,{})}),s.jsx(We,{id:"policy",storage:"repo",children:s.jsx(vI,{})}),s.jsx(We,{id:"guides",storage:"repo",children:s.jsx(Y2,{focus:t.section==="guides"})}),s.jsx(We,{id:"labels",children:s.jsx(Ae,{title:"Labels",children:s.jsxs("div",{className:"label-codes",children:[s.jsx("code",{children:nu}),s.jsxs("code",{children:[J.labelPrefix,":<type>"]}),s.jsx("code",{children:su}),s.jsx("code",{children:iu})]})})})]})}const Qd=`${J.apiPrefix}/projects`;async function ur(e,t,n){const r=await fetch(`${Qd}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:n===void 0?void 0:JSON.stringify(n)}),a=await r.json().catch(()=>({}));if(!r.ok)throw new Error(a.error??`HTTP ${r.status}`);return a}const bs={url:Qd,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(`${Qd}/briefing?since=${e}`);return t.ok?await t.json():void 0}};function Ay(e){const[t,n]=y.useState(""),[r,a]=y.useState(),c=d=>{d.trim()&&(a(void 0),bs.add(d.trim()).then(()=>(n(""),e.onAdded()),h=>a(h.message)))};return s.jsxs("div",{className:"pj-add",children:[s.jsx(Ba,{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"}),r&&s.jsx("span",{className:"vf-err",children:r})]})}const ii=(e,t)=>e>0&&`${e} ${t}`;function wI(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:r,project:a,briefing:c})=>s.jsx(fe,{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,h)=>d+h.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(r)},r))})]})}function xI(e){const[t,n]=y.useState(""),[r,a]=y.useState(!1),[c,d]=y.useState(),h=f=>{!f.trim()||r||(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(Ba,{value:t,onValueChange:n,onSubmit:h,action:"Answer",disabled:r,placeholder:"Your answer","aria-label":"Your answer"}),c&&s.jsx("span",{className:"vf-err",children:c})]})}function jI(e){const{item:t}=e,n=Tu(t),r=t.kind==="question"&&t.agent?`${t.agent} asks`:Cu[t.kind],a=t.urgency==="blocking"&&{text:"Blocking",urgent:!0,className:"urgency-tag"};return s.jsx(fe,{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},r]}),detail:n.length>0&&n.join(" · "),detailText:n.join(`
164
+ `),trailing:Xe(e.now-t.since),onOpen:e.onOpen,below:e.onAnswer&&s.jsx(xI,{onAnswer:e.onAnswer})})}function bI(e){const t=e.view.attention,n=r=>{var a;return((a=e.view.projects.find(c=>c.id===r))==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(r=>r.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(r=>s.jsx(jI,{item:r,now:e.now,onOpen:()=>e.onOpen(r.projectId,r.id),onAnswer:r.kind==="question"&&n(r.projectId)?a=>bs.answer(r.projectId,{questionId:r.ref,text:a}).then(e.onAnswered):void 0},`${r.projectId}/${r.id}`))})]})}const gd=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function SI(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function NI(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(gd(e.agents,"agent"));const{working:n,verifying:r,rework:a,blocked:c}=e.phases;n&&t.push(`${n} working`),r&&t.push(`${r} verifying`),a&&t.push(`${a} rework`),c&&t.push(`${c} blocked`),e.flags&&t.push(gd(e.flags,"PR flag")),e.stalled&&t.push(gd(e.stalled,"stalled claim")),t.length||t.push(e.trails?"Nothing waiting":"No trails yet");const d=$I(e.tracker);return d&&t.push(d),t}function $I(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 CI(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 r=e.state.url?pn(e.state.url):void 0;if(!r)return;const a=new URL(r);n&&a.searchParams.set(Ss,n),window.open(a.toString(),"_blank","noopener");return}location.href=d1({id:e.id,home:t,tracker:e.tracker.kind,item:n})}}function Ry(e){const{p:t}=e,n=CI(t);return s.jsx(fe,{as:"li",className:`project-card st-${t.state.kind}`,edge:SI(t),selected:e.current,title:t.name,titleText:t.path,context:s.jsx(B,{parts:NI(t)}),detail:n,detailText:n,trailing:t.lastActivity?Xe(e.now-t.lastActivity):void 0,onOpen:e.onOpen})}const My=`${wa}:projects:seen`,ug=24*36e5;function TI(e){try{const t=Number(localStorage.getItem(My));return t>0?t:e-ug}catch{return e-ug}}function EI(e){try{localStorage.setItem(My,String(e))}catch{}}function AI(){const[e,t]=y.useState();return y.useEffect(()=>{const n=Date.now();return bs.briefing(TI(n)).then(t).catch(()=>{}),()=>EI(n)},[]),e}function RI(e){const{view:t,reload:n}=e.projects,r=gt(15e3),a=AI();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)},h=(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(bI,{view:t,now:r,onOpen:h,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(Ry,{p:f,current:f.id===c,now:r,onOpen:f.state.kind==="missing"?void 0:()=>d(f.id)},f.id))}),s.jsx(Ay,{onAdded:n})]}),s.jsx(wI,{briefing:a,now:r,onOpen:d})]})]})}function MI(e){const[t,n]=y.useState(!1),r=y.useRef(null);y.useEffect(()=>{if(!t)return;const h=f=>{var m;(f instanceof KeyboardEvent?f.key==="Escape":!((m=r.current)!=null&&m.contains(f.target)))&&n(!1)};return window.addEventListener("mousedown",h),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",h)}},[t]);const{view:a}=e.projects;if(!a||!e.projects.many)return s.jsx("span",{className:"repo",children:e.repo});const c=Sr()??a.home,d=a.projects.filter(h=>h.id!==c).reduce((h,f)=>h+f.interrupting,0);return s.jsxs("div",{className:"project-switcher",ref:r,children:[s.jsxs("button",{className:"project-btn repo",onClick:()=>n(h=>!h),"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(xs,{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(xs,{n:a.attention.length,urgent:a.attention.some(h=>h.interrupting),hideZero:!0})]}),s.jsx(Ke,{variant:"plain",className:"menu-h",children:"Projects"}),a.projects.map(h=>s.jsxs("button",{role:"menuitem",className:`trail-item ${h.id===c?"on":""} st-${h.state.kind}`,disabled:h.state.kind==="missing",onClick:()=>{n(!1),h.id!==c&&va(h,a.home)},children:[s.jsx("span",{className:"mi-title",children:h.name}),s.jsx("span",{className:"mi-progress",children:II(h.state.kind)}),s.jsx(xs,{n:h.needsYou,urgent:h.interrupting>0,hideZero:!0})]},h.id))]})]})}function II(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function OI(e){const t=gt(15e3),{view:n}=e.projects;if(!n||!e.projects.many)return null;const r=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!==r).map(a=>s.jsx(Ry,{p:a,current:!1,now:t,onOpen:a.state.kind==="missing"?void 0:()=>va(a,n.home)},a.id))})]})}async function LI(){const e=await fetch(bs.url);return e.ok?await e.json():void 0}function Iy(){const[e,t]=y.useState(),{reload:n,pushed:r}=Le({load:LI,show:a=>a&&t(a)});return y.useEffect(()=>vi("projects",a=>{r(),t(JSON.parse(a))}),[r]),{view:e,many:((e==null?void 0:e.projects.length)??0)>1,reload:n}}const PI=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function DI(){const{view:e,reload:t}=Iy(),[n,r]=y.useState();if(!e)return null;const a=c=>{r(void 0),c.then(t,d=>r(d.message))};return s.jsxs(Ae,{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(fe,{as:"li",edge:c.state.kind==="missing"?"attention":"neutral",title:c.name,context:s.jsx(B,{parts:PI(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(bs.setShare(c.id,!c.sharePrecedents)),children:c.sharePrecedents?"Shares decisions":"Share decisions"}),!c.home&&s.jsx(I,{size:"sm",variant:"ghost",onClick:()=>a(bs.remove(c.id)),children:"Remove"})]})},c.id))}),s.jsx(Ay,{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(bs.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 _I(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 hg=e=>`${e} ticket${e===1?"":"s"}`;function BI(e,t){const n=`in the last ${t} days`,r=e.held?`Held ${hg(e.held)}`:"",a=e.wouldHold?`would have held ${hg(e.wouldHold)}`:"";return r&&a?`${r}, ${a} ${n}`:r?`${r} ${n}`:a?`W${a.slice(1)} ${n}`:`Nothing held ${n}`}const FI={enforce:"Held",observe:"Would have held"};function zI(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,r)=>{const a=n.ticketId;return s.jsx(fe,{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},FI[n.mode]]}),trailing:Ns(n.at,t),onOpen:a?()=>e.onOpenTicket(n.mapId,a):void 0},`${n.at}-${r}`)})})})}const Oy={"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=>lv.includes(e);function UI(e){return jr(e)?Oy[e].title:e}function WI(e){return jr(e)?Oy[e].about:void 0}const fg={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 HI(e){return s.jsx("div",{className:"gate-modes",role:"radiogroup","aria-label":`${e.label} mode`,"data-gate":e.gate,children:T0.map(t=>s.jsx("button",{type:"button",role:"radio","aria-checked":e.value===t,className:pe("gate-mode",e.value===t&&"on"),title:fg[t].tip,disabled:e.disabled,onClick:()=>e.value!==t&&e.onChange(t),children:fg[t].label},t))})}function KI(e){const{summary:t}=e,n=UI(t.gate),r=jr(t.gate);return s.jsx(fe,{as:"li",className:"gate-row",edge:t.held?"attention":"neutral",title:r?n:s.jsx("span",{className:"t-code",children:n}),context:s.jsx(B,{parts:[WI(t.gate)]}),detail:e.days?BI(t,e.days):void 0,below:s.jsxs(s.Fragment,{children:[r&&s.jsx(HI,{gate:t.gate,label:n,value:e.mode,disabled:e.locked,onChange:e.onMode}),s.jsx(zI,{entries:t.entries,onOpenTicket:e.onOpenTicket})]})})}function mg(e){return new Set(e.map((t,n)=>t.ticketId?`${t.mapId}/${t.ticketId}`:`#${n}`)).size}function GI(e){const t=[...e].sort((r,a)=>a.at-r.at),n=[...lv];for(const r of t)n.includes(r.gate)||n.push(r.gate);return n.map(r=>{const a=t.filter(c=>c.gate===r);return{gate:r,held:mg(a.filter(c=>c.mode==="enforce")),wouldHold:mg(a.filter(c=>c.mode==="observe")),entries:a}})}async function VI(){const e=await fetch(`${ae()}/verification/gates`);return e.ok?await e.json():null}function qI(){const[e,t]=y.useState();return Le({load:VI,show:t,failed:()=>t(null),changed:n=>n.endsWith("verification.json"),events:{verification:()=>!0,attention:()=>!0}}),e}async function QI(e){const t=await fetch(`${ae()}/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 YI(e){var b,S;const t=Ru(),n=qI(),r=xi(),[a,c]=y.useState(),[d,h]=y.useState();if(!t)return null;const f=((b=t.approval)==null?void 0:b.base)??"none",m=_I({local:r,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:E0(t.exists?t.config:void 0,x):"off",w=async(x,C)=>{if(!jr(x))return;const N={gate:x,mode:C,base:f};h(void 0),c(N);const P=await QI(N);P&&(c(void 0),h(P))};return s.jsxs(Ae,{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:GI((n==null?void 0:n.entries)??[]).map(x=>s.jsx(KI,{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 JI({view:e}){if(!e)return null;const t=`${J.dataDir}/${e.file}`,n=Object.keys(e.models).length,r=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"]}),r&&s.jsx(B,{className:"set-hint models-connected",parts:[`Connected now: ${r}`]}),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"},XI={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},ZI=sa.map(e=>({value:e,label:kr[e],hint:XI[e]}));function eO(e){return s.jsx("div",{className:"tier-grid",children:ss.map(t=>{const n=e.tiers[t],r=ou[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:ZI,onChange:a=>e.onChange(t,a)}),s.jsx(B,{className:"tier-hint",parts:[n!==r&&`default ${kr[r].toLowerCase()}`,e.hints[t]]})]},t)})})}async function tO(){const e=await fetch(`${ae()}/flaky-checks`);return e.ok?await e.json():null}function nO(){const[e,t]=y.useState();return Le({load:tO,show:t,failed:()=>t(null),events:{verification:()=>!0},changed:n=>n.includes("/tickets/")}),e}const sO={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 iO(){const e=nO();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. ",sO[e.mode]]}),e.rows.length?s.jsx("ul",{className:"perf-rows",children:e.rows.map(n=>s.jsx(fe,{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(Ee,{children:"No flaky checks seen."})]})}const Yo=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function rO({rows:e}){return e.length?s.jsx("ul",{className:"perf-rows",children:e.map(t=>s.jsx(fe,{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(Ee,{children:"No claimed tickets yet"})}const oO=e=>`${Math.round(e*100)}%`;function aO({r:e,minSample:t}){return s.jsx(fe,{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:[oO(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 cO({e}){return s.jsx(fe,{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 lO(e){return e.escapes.length?s.jsxs("ul",{className:"perf-rows",children:[e.checks.map(t=>s.jsx(aO,{r:t,minSample:e.minSample},t.key)),e.escapes.map(t=>s.jsx(cO,{e:t},`${t.mapId}/${t.ticketId}/${t.attemptId}`))]}):s.jsx(Ee,{children:"Nothing verified has come back: no reopens, no reverts on main."})}const pg=e=>`${Math.round(e*100)}%`,dO=e=>e===void 0?void 0:`$${e.toFixed(2)} per verified`;function uO({r:e,minSample:t}){return s.jsx(fe,{as:"li",className:"perf-row score-row",title:e.key,trailing:e.enough?s.jsxs("span",{title:"Verified on the first attempt",children:[pg(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`,`${pg(e.reworkRate)} rework`,e.attemptsPerVerified!==void 0&&`${e.attemptsPerVerified} attempts each`,dO(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 hO({rows:e,minSample:t}){return e.length?s.jsx("ul",{className:"perf-rows",children:e.map(n=>s.jsx(uO,{r:n,minSample:t},n.key))}):s.jsx(Ee,{children:"No completions yet. The scorecard fills in as agents finish verified tickets."})}async function fO(){const e=await fetch(`${ae()}/scorecard`);return e.ok?await e.json():null}function Ly(){const[e,t]=y.useState();return Le({load:fO,show:t,failed:()=>t(null),events:{verification:()=>!0},changed:n=>n.includes("/tickets/")}),e}const mO=[{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 pO(){const e=Ly(),[t,n]=y.useState("byTypeAndModel"),[r,a]=y.useState(!1);if(e==null)return null;const c=()=>void navigator.clipboard.writeText(SN(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:r?"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:mO.map(d=>s.jsx(ct,{on:t===d.id,title:d.title,onClick:()=>n(d.id)},d.id))}),t==="cameBack"?s.jsx(lO,{checks:e.byCheck??[],escapes:e.escapes??[],minSample:e.minSample}):s.jsx(hO,{rows:e[t]??[],minSample:e.minSample})]})}function Py(e){const[t,n]=y.useState({}),r=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(`${ae()}/journal?mapId=${encodeURIComponent(c.map.id)}`).catch(()=>{}),h=d!=null&&d.ok?await d.json():{entries:[]};return[c.map.id,h.entries]})).then(c=>{a&&n(Object.fromEntries(c))}),()=>{a=!1}},[r]),t}const gO=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function vO({api:e,bp:t,onClose:n}){const[r,a]=y.useState("byVendor"),c=y.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),d=Py(c),h=e.activity.answered,f=y.useMemo(()=>$v(c.map(m=>({snap:m,journal:d[m.map.id]??[],answered:h}))),[c,d,h]);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(Ee,{children:"Nothing yet. This needs at least 5 results from two vendors to compare."})]}),s.jsx(pO,{}),s.jsx(iO,{}),s.jsxs("section",{className:"perf-section",children:[s.jsx("div",{className:"choice-row compact",children:gO.map(m=>s.jsx(ct,{on:r===m.id,title:m.title,onClick:()=>a(m.id)},m.id))}),s.jsx(rO,{rows:f[r]}),s.jsx("p",{className:"perf-note t-meta",children:"Spend is tracked per trail, so it isn't split by agent here."})]})]})]})}function kO(e){const t=Ly();if(!t)return null;const n=xN({scorecard:t,tiers:e.tiers,models:e.models});return n.length?s.jsx("ul",{className:"tier-suggestions",children:n.map(r=>s.jsxs("li",{children:[s.jsxs("span",{children:[En[r.type],": ",kr[r.tier].toLowerCase()," instead of ",kr[r.current].toLowerCase()]}),s.jsx("span",{className:"t-meta",children:r.because}),s.jsxs(I,{size:"sm",variant:"ghost",onClick:()=>e.onTake(r.type,r.tier),children:["Use ",kr[r.tier].toLowerCase()]})]},r.type))}):null}function yO(e,t){const n=Py(e);return y.useMemo(()=>{var c;const r=$v(e.map(d=>({snap:d,journal:n[d.map.id]??[],answered:t}))),a={};for(const d of r.byType){if(!d.done)continue;const h=(c=r.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`,h];a[d.key]=f.filter(Boolean).join(" · ")}return a},[e,n,t])}function wO(e){var h,f;const t=Iu(),n=yO(e.snaps,e.answered),r=e.map;if(!r)return null;const a=!!((h=r.modelMatching)!=null&&h.enabled),c=((f=r.modelMatching)==null?void 0:f.tiers)??{},d=(m,g)=>{const k={...c,[m]:g};g===ou[m]&&delete k[m],e.onChange({enabled:!0,tiers:k})};return s.jsxs(Ae,{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 ",r.key]}),s.jsx(I,{size:"sm",on:a,"aria-pressed":a,className:"model-matching-toggle",onClick:()=>e.onChange({...r.modelMatching,enabled:!a}),children:a?"On":"Off"})]}),a&&s.jsx(eO,{tiers:qm(r),hints:n,onChange:d}),a&&s.jsx(kO,{tiers:qm(r),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(JI,{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 Yd=e=>e.trim().split(/\s+/).filter(Boolean);function xO(e){return e.rows.map((t,n)=>{const r=Yd(t.command).join(" ");return e.findings.filter(a=>a.check===String(n)&&a.command===r)})}function jO(e){const{check:t,onChange:n}=e,r=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":r,"data-tip":r,onClick:e.onRemove,children:"×"}),s.jsx(Ka,{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 SO(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 NO(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:r=>e.onSure(r.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 $O(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 CO({view:e}){const[t,n]=y.useState(()=>$O(e)),[r,a]=y.useState(!1),[c,d]=y.useState(!1),[h,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:Yd(S.command),cwd:(N=(C=e.config)==null?void 0:C.checks[S.name])==null?void 0:N.cwd}}),k=qk(g),w=xO({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:Yd(P.command)})),x=await fetch(`${ae()}/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(jO,{check:S,findings:w[x],focus:r&&x===t.length-1,onChange:C=>m(x,C),onRemove:()=>n(t.filter((C,N)=>N!==x))},x))}),s.jsx(SO,{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(NO,{sure:c,onSure:d,state:h,onSave:()=>void b()})]})}function TO({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(([r,a])=>s.jsxs("div",{className:"vf-check",children:[s.jsx("span",{className:"t-code",children:e.run.includes(r)?r:`${r} (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}`:""]})]},r))})]})}const EO=[{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 AO({view:e,local:t}){var h,f;const[n,r]=y.useState(),a=((h=e.config)==null?void 0:h.scope)??"flag",c=(f=e.approval)!=null&&f.waiting?"Approve the checks first.":void 0,d=async m=>{var w;r(void 0);const g=await fetch(`${ae()}/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(()=>({})));r((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:EO.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 RO(e){var c;const{view:t,local:n,file:r}=e,a=t.config;return s.jsxs(s.Fragment,{children:[n&&s.jsx(CO,{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(TO,{config:a,file:r,hash:t.hash}),!n&&s.jsx(Ka,{findings:t.screening??[],named:!0}),a&&t.exists&&s.jsx(AO,{view:t,local:n})]})}function MO(e){var g;const t=Ru(),n=xi(),[r,a]=y.useState();if(!t)return null;const c=e.map,d=t.config,h=`${J.dataDir}/${t.file}`,f=(c==null?void 0:c.verification)??"off",m=(d??uv).appliesTo.join(" and ");return s.jsxs(Ae,{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:ru.map(k=>s.jsx(ct,{on:f===k,title:Er[k],sub:Au[k],onClick:()=>{a(void 0),js.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."})]}),r&&s.jsx("span",{className:"vf-err",children:r})]}),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:[h," 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(RO,{view:t,local:n,file:h}),c&&s.jsx(U$,{mapId:c.id}),s.jsxs("span",{className:"set-hint t-meta",children:["Saved here, checks are approved as you save them. A change to ",h," made in the repo, by an agent or a teammate, runs nothing until you approve it."]}),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 IO({data:e}){const{map:t}=e;return s.jsxs(s.Fragment,{children:[t?s.jsx(We,{id:"mode",children:s.jsx(Ae,{title:`Trail ${t.key}`,children:s.jsx(oT,{value:t.mode,onChange:e.onMapMode})})}):s.jsx(Ee,{children:"Chart or pick a trail to set its mode, model matching and guides."}),s.jsx(We,{id:"verification",storage:"repo",children:s.jsx(MO,{map:t})}),s.jsx(We,{id:"gates",storage:"repo",children:s.jsx(YI,{onOpenTicket:e.onOpenTicket})}),s.jsx(We,{id:"rules",storage:"repo",children:s.jsx(n2,{})}),s.jsx(We,{id:"models",children:s.jsx(wO,{map:t,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching})}),t&&s.jsx(We,{id:"trail-guides",children:s.jsx(rE,{map:t})})]})}const gg=10,Dy=[0,10,16,26,18,24,16,18,22,22,26],_y=[0,1,1,1,2,2,4,4,4,5,5];function By(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 OO=e=>Dy[e],LO=e=>_y[e],Fy=e=>Math.floor(By(e)/8)-Dy[e]*_y[e],zy=e=>e<10?8:16;function PO(e){if(e===1)return[];const t=Math.floor(e/7)+2,n=e*4+17,r=Math.ceil((e*4+4)/(t*2-2))*2,a=[6];for(let c=n-7;a.length<t;c-=r)a.splice(1,0,c);return a}function Jd(e,t){let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function DO(e){const t=new Array(e).fill(0);t[e-1]=1;let n=1;for(let r=0;r<e;r++){for(let a=0;a<t.length;a++)t[a]=Jd(t[a],n),a+1<t.length&&(t[a]^=t[a+1]);n=Jd(n,2)}return t}function _O(e,t){const n=t.map(()=>0);for(const r of e){const a=r^n.shift();n.push(0),t.forEach((c,d)=>n[d]^=Jd(c,a))}return n}function BO(e,t){const n=[],r=(d,h)=>{for(let f=h-1;f>=0;f--)n.push(d>>>f&1)};r(4,4),r(e.length,zy(t));for(const d of e)r(d,8);const a=Fy(t)*8;r(0,Math.min(4,a-n.length)),r(0,(8-n.length%8)%8);for(let d=236;n.length<a;d^=253)r(d,8);const c=[];for(let d=0;d<n.length;d+=8)c.push(n.slice(d,d+8).reduce((h,f)=>h<<1|f,0));return c}function FO(e,t){const n=BO(e,t),r=LO(t),a=OO(t),c=Math.floor(By(t)/8),d=r-c%r,h=Math.floor(c/r),f=DO(a),m=[];for(let k=0,w=0;k<r;k++){const b=n.slice(w,w+h-a+(k<d?0:1));w+=b.length;const S=_O(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!==h-a||w>=d)&&g.push(m[w][k]);return g}const zO=[(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 vd(e,t){const n=zO[t];for(let r=0;r<e.size;r++)for(let a=0;a<e.size;a++)!e.fixed[r][a]&&n(a,r)&&(e.dark[r][a]=!e.dark[r][a])}function vg(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 r=e.map(a=>a?"1":"0").join("");for(const a of["00001011101","10111010000"])for(let c=r.indexOf(a);c>=0;c=r.indexOf(a,c+1))t+=40;return t}function UO(e){let t=0,n=0;for(let a=0;a<e.size;a++)t+=vg(e.dark[a]),t+=vg(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 r=e.size*e.size;return t+Math.floor(Math.abs(n*20-r*10)/r)*10}const hn=(e,t)=>(e>>>t&1)!==0;function Tt(e,t,n,r){e.dark[n][t]=r,e.fixed[n][t]=!0}function kd(e,t,n){for(let r=-4;r<=4;r++)for(let a=-4;a<=4;a++){const c=t+a,d=n+r,h=Math.max(Math.abs(a),Math.abs(r));c>=0&&c<e.size&&d>=0&&d<e.size&&Tt(e,c,d,h!==2&&h!==4)}}function WO(e,t,n){for(let r=-2;r<=2;r++)for(let a=-2;a<=2;a++)Tt(e,t+a,n+r,Math.max(Math.abs(a),Math.abs(r))!==1)}function Xd(e,t){const n=0|t;let r=n;for(let c=0;c<10;c++)r=r<<1^(r>>>9)*1335;const a=(n<<10|r)^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 HO(e,t){if(t<7)return;let n=t;for(let a=0;a<12;a++)n=n<<1^(n>>>11)*7973;const r=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(r,a)),Tt(e,d,c,hn(r,a))}}function KO(e){const t=e*4+17,n=()=>Array.from({length:t},()=>new Array(t).fill(!1)),r={size:t,dark:n(),fixed:n()};for(let d=0;d<t;d++)Tt(r,6,d,d%2===0),Tt(r,d,6,d%2===0);kd(r,3,3),kd(r,t-4,3),kd(r,3,t-4);const a=PO(e),c=a.length-1;for(let d=0;d<=c;d++)for(let h=0;h<=c;h++)d===0&&h===0||d===0&&h===c||d===c&&h===0||WO(r,a[d],a[h]);return Xd(r,0),HO(r,e),r}function GO(e){const t=[];for(let n=e-1;n>=1;n-=2){const r=n<=6?n-1:n,a=(r+1&2)===0;for(let c=0;c<e;c++){const d=a?e-1-c:c;t.push([r,d],[r-1,d])}}return t}function VO(e,t){let n=0;for(const[r,a]of GO(e.size))e.fixed[a][r]||n>=t.length*8||(e.dark[a][r]=hn(t[n>>>3],7-(n&7)),n++)}function qO(e){const t=new TextEncoder().encode(e);let n=1;for(;n<=gg&&4+zy(n)+t.length*8>Fy(n)*8;)n++;if(n>gg)return;const r=KO(n);VO(r,FO(t,n));let a=0,c=1/0;for(let d=0;d<8;d++){vd(r,d),Xd(r,d);const h=UO(r);h<c&&([a,c]=[d,h]),vd(r,d)}return vd(r,a),Xd(r,a),r.dark}const yd=4;function QO(e){const t=qO(e.text);if(!t)return null;const n=t.length+yd*2,r=t.flatMap((a,c)=>a.map((d,h)=>d?`M${h+yd} ${c+yd}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:r,fill:"#000"})]})}function YO(e){const t=gt(1e3),n=Math.max(0,Math.ceil((e.device.expiresAt-t)/6e4)),r=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:[r&&s.jsx(QO,{text:r,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"," ",r?s.jsx("code",{className:"t-code",children:r.split("#")[0]}):"the Lookout"," there and type the code."]}),s.jsx(I,{size:"sm",onClick:e.onDone,children:"Done"})]})]})}function JO(e){const[t,n]=y.useState();return e.device?s.jsx(YO,{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 XO(e){const[t,n]=y.useState(!1),[r,a]=y.useState(!1),[c,d]=y.useState(),h=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:r,onClick:h,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 ZO={machine:"This machine",device:"Another device"};function eL(e){const t=Date.now();return s.jsx("ul",{className:"ra-list si-list",children:e.sessions.map(n=>s.jsx(fe,{as:"li",className:"ra-row",title:n.current?`${n.name} · this browser`:n.name,titleText:n.name,context:s.jsx(B,{parts:[ZO[n.kind],n.via==="opened-page"?`From the page ${J.name} opened`:void 0,n.via==="opened-page"?{text:IS(n.id),code:!0}:void 0,`Paired ${Ns(n.pairedAt,t)}`,`Last used ${Ns(n.lastUsedAt,t)}`]}),below:n.current?void 0:s.jsx(XO,{name:n.name,onRevoke:()=>e.onRevoke(n.id)})},n.id))})}function tL(){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 Uy=`${J.apiPrefix}/sign-in`;async function wd(e,t={}){const n=await fetch(`${Uy}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:n.ok,reply:await n.json().catch(()=>({}))}}function nL(){const[e,t]=y.useState(),[n,r]=y.useState(),a=y.useCallback(()=>{fetch(`${Uy}/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 wd("/codes");if(!f)return m.error??"No code could be made.";r(m)},[]),d=y.useCallback(async f=>{const{ok:m,reply:g}=await wd("/revoke",{id:f});return a(),m?void 0:g.error??"That browser could not be revoked."},[a]),h=y.useCallback(async()=>{await wd("/sign-out"),Qv(),location.reload()},[]);return{view:e,device:n,closeDevice:()=>(r(void 0),a()),pairDevice:c,revoke:d,signOut:h}}function sL(){const{view:e,device:t,closeDevice:n,pairDevice:r,revoke:a,signOut:c}=nL();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(Ae,{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(Ae,{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(eL,{sessions:e.sessions,onRevoke:a}),s.jsx(JO,{lan:e.lan,device:t,onPair:r,onDone:n}),d,s.jsx(tL,{})]})}function iL({managed:e}){const{signOut:t,pages:n}=e;return s.jsxs(Ae,{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(r=>s.jsx(I,{size:"sm",onClick:()=>location.assign(r.href),children:r.label},r.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 rL(){return y.useEffect(()=>{const e=setInterval(()=>void Oa().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(Fa,{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 Fu(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&&M1({id:n.id,secret:n.session,verifier:n.verifier})}function oL(e){const[t,n]=y.useState(!1),r=async()=>{n(!0);const a=await Fu(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:r,children:"Sign in this browser"})})]})}function kg(){const[e,t]=y.useState(""),[n,r]=y.useState(!1),[a,c]=y.useState(),d=async()=>{if(!e.trim()||n)return;r(!0);const h=await Fu(e);r(!1),c(h),h||location.reload()};return s.jsxs("form",{className:"pair-device",onSubmit:h=>{h.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:h=>t(h.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 yg(){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 aL(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(yg,{}):s.jsx(kg,{}),e.local?s.jsx(kg,{}):s.jsx(yg,{})]})}function cL(e){const[t,n]=y.useState(),[r,a]=y.useState(e.code),[c,d]=y.useState(e.code);e.code!==c&&(d(e.code),a(e.code));const h=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(Fa,{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}),r?s.jsx(oL,{code:r,onFailed:h}):s.jsx(aL,{local:e.local})]})})}function wg(){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 xg(){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&&N1(t)?{kind:"signed-in"}:{kind:"signed-out",local:t.local===!0}}catch{return{kind:"no-server"}}}async function lL(){if(!ku())return xg();const e=await Oa();return e==="proven"?{kind:"signed-in"}:e==="unknown"?xg():{kind:"not-running"}}function dL(){const[e,t]=y.useState({kind:"checking"});return y.useEffect(()=>void lL().then(t),[]),y.useEffect(()=>I1(n=>n==="failed"&&t({kind:"not-running"})),[]),e}function uL({children:e}){const t=dL(),[n,r]=y.useState(wg);return y.useEffect(()=>{const a=()=>r(c=>wg()??c);return window.addEventListener("hashchange",a),()=>window.removeEventListener("hashchange",a)},[]),y.useEffect(()=>{t.kind==="signed-in"&&n&&Fu(n)},[t.kind,n]),t.kind==="checking"?null:t.kind==="signed-out"?s.jsx(cL,{local:t.local,code:n}):t.kind==="not-running"?s.jsx(rL,{}):s.jsx(s.Fragment,{children:e})}function hL(){const e=pt();return e?s.jsx(iL,{managed:e}):s.jsx(We,{id:"devices",storage:"machine",children:s.jsx(sL,{})})}const fL=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function mL(e){return s.jsx("div",{className:"choice-row compact",children:fL.map(t=>s.jsx(ct,{on:e.value===t.value,title:t.title,onClick:()=>e.onChange(t.value)},t.value))})}function pL({data:e}){var r;const{prefs:t,update:n}=e;return s.jsxs(s.Fragment,{children:[s.jsx(We,{id:"appearance",storage:"browser",children:s.jsxs(Ae,{title:"Appearance",children:[ik()?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(mL,{value:rk(t.theme),onChange:a=>n({theme:a})}),((r=pt())==null?void 0:r.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(Ae,{title:"HITL transcript",children:s.jsx(Ny,{value:t.hitlTranscript,onChange:a=>n({hitlTranscript:a})})})}),s.jsx(We,{id:"agent",children:s.jsx(Ae,{title:"Agent",children:s.jsx("div",{className:"choice-row",children:_v.map(a=>s.jsx(ct,{on:a.status==="primary",disabled:a.status!=="primary",title:a.name},a.id))})})}),s.jsx(hL,{})]})}function gL(e){const{data:t,route:n}=e;switch(e.group){case"trail":return s.jsx(IO,{data:t});case"project":return s.jsx(yI,{data:t,route:n});case"alerts":return s.jsx(RM,{data:t,route:n});case"you":return s.jsx(pL,{data:t});case"projects":return s.jsx(We,{id:"projects",storage:"machine",children:s.jsx(DI,{})});case"about":return s.jsx(We,{id:"changelog",children:s.jsx(_M,{})});default:return e.group}}function vL(e){const{group:t,route:n}=e,r=y.useRef(null),a=y.useRef(null);return y.useEffect(()=>{var d,h;(d=r.current)==null||d.focus({preventScroll:!0});const c=n.section&&document.getElementById(`settings-${n.section}`);c?c.scrollIntoView({block:"start"}):(h=a.current)==null||h.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:r,tabIndex:-1,children:t.label}),s.jsx("p",{className:"sp-intro t-meta",children:t.intro})]}),s.jsx(gL,{group:t.id,data:e.data,route:n})]})})}function kL(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(fe,{as:"li",className:"sp-nav-row",selected:n,current:n?"page":void 0,title:t.label,context:s.jsx(B,{parts:t.sections.map(r=>r.title)}),trailing:e.drill&&"›",onOpen:()=>e.onPick(t.id)},t.id)})})})}function yL(e,t){return e.group?xr.find(n=>n.id===e.group):t==="mobile"?void 0:xr[0]}const wL={page:"Back to the Lookout",list:"Lookout",group:"Settings"},xL=(e,t)=>e?t?"group":"list":"page";function jL(e){const{bp:t,route:n}=e,r=t==="mobile",a=yL(n,t),c=xL(r,!!a),d=xi()===!1,h=()=>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(kL,{current:a==null?void 0:a.id,onPick:f,drill:r});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:h,children:["‹ ",wL[c]]}),c!=="group"&&s.jsx(Ke,{as:"h2",children:"Settings"}),!r&&s.jsx("span",{className:"dv-head-right t-meta",children:"Esc"})]}),d&&s.jsx(yM,{}),s.jsxs("div",{className:"sp-body",children:[m,a&&s.jsx(vL,{group:a,data:e.data,route:n})]})]})}function bL(e){var a;const{rt:t,api:n,settings:r}=e;return r.route?s.jsx(jL,{bp:e.bp,route:r.route,onShow:r.show,onClose:r.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)=>{r.dismiss(),e.openTicket(c,d)}}}):null}function SL(e){var d;const{api:t,nav:n,attn:r}=e,a=n.fullTicket&&((d=t.selection)==null?void 0:d.kind)==="ticket",c=()=>n.setFullTicket(!1);return y.useEffect(()=>{if(!a)return;const h=f=>f.key==="Escape"&&!f.defaultPrevented&&n.setFullTicket(!1);return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[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(oR,{api:t,sessions:e.sessions,bare:!0,attention:r.attention.view,done:e.done,onOpenChat:h=>n.openChat(h),onOpenDecision:n.openDecisions,onItem:h=>r.open(h),onReviewChange:r.handlers.openApprovals,onReviewBrief:r.handlers.openBrief})]}):null}function NL(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(Ee,{children:"No agent is on this trail now"}),s.jsx("ul",{className:"trail-list-rows",children:e.working.map(t=>{const n=t.session,r=_a(n==null?void 0:n.model),a=n?[{text:n.agent,strong:!0},r&&{text:r,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(fe,{as:"li",className:"agent-row",title:`${t.ticket.key} ${t.ticket.title}`,context:s.jsx(B,{parts:a}),trailing:n&&s.jsx(py,{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 $L(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(yk,{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 CL(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(r=>s.jsx("button",{type:"button",className:pe("need-chip",e.selected===r.id&&"on"),title:r.title,onClick:()=>e.onOpen(r),children:_T(r,e.keyOf)},r.id)),n>0&&s.jsxs("button",{type:"button",className:"need-chip more",onClick:e.onMore,children:["+",n]})]}):null}function TL(e){const t=new Map(e.map(a=>[a.id,a])),n=new Map,r=(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 h=((m=t.get(a))==null?void 0:m.blockedBy.filter(g=>t.has(g)))??[],f=h.length?1+Math.max(...h.map(g=>r(g,c))):0;return n.set(a,f),f};return new Map(e.map(a=>[a.id,r(a.id,new Set)]))}function EL(e){const t=[...e.values()].filter(r=>r.tone!=="cancelled"),n=TL(t.map(r=>r.ticket));return t.map((r,a)=>({l:r,i:a,d:n.get(r.ticket.id)??0})).sort((r,a)=>r.d-a.d||r.i-a.i).map(({l:r})=>({id:r.ticket.id,key:r.ticket.key,title:r.ticket.title,tone:r.tone}))}function AL(e,t){const n=r=>e.filter(a=>a.tone===r).length;return{done:n("done"),total:e.length,working:n("working"),needs:t.length,waiting:n("waiting-agent"),notStarted:n("not-started")}}function RL(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:r})=>({text:n,urgent:r}))]}const jg={done:"done",working:"an agent is on it",needs:"needs you","waiting-agent":"waiting for an agent","not-started":"not started"};function ML(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} · ${jg[t.tone]}`,"aria-label":`${t.key} ${t.title}: ${jg[t.tone]}`,onClick:()=>e.onSelect(t.id)},t.id))})}function IL(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(ML,{segments:e.segments,selected:e.selected,onSelect:e.onTicket}),s.jsx("span",{className:"trail-counts",children:RL(e.counts).map((n,r)=>s.jsxs("span",{className:pe(r===0&&"strong",n.urgent&&"urgent"),children:[r>0&&s.jsx("span",{className:"sep",children:" · "}),n.text]},n.text))}),!t&&s.jsx(CL,{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 OL=6;function LL(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)))}`})),r=e.filter(a=>a.waitsOnYours.length>0).map(a=>({ticket:a.ticket,context:`Waits on your ${a.waitsOnYours.join(", ")}`}));return[...n,...r].slice(0,OL)}function PL(e){const t=LL(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(Ee,{children:"Nothing ready"}),s.jsx("ul",{className:"trail-list-rows",children:t.map(n=>s.jsx(fe,{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 Wy="teamtrail.trail-bar.more";function DL(){try{return localStorage.getItem(Wy)==="yes"}catch{return!1}}function _L(){const[e,t]=y.useState(DL);return[e,r=>{t(r);try{localStorage.setItem(Wy,r?"yes":"no")}catch{}}]}function BL(e){const{api:t,nav:n,attn:r,trail:a}=e,[c,d]=_L(),h=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=r.attention.view,b={...r.attention,view:w&&{...w,items:a.items}};return t.snap?s.jsx(IL,{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:r.open,lists:s.jsxs(s.Fragment,{children:[s.jsxs(Fe,{className:"trail-list needs-list",children:[s.jsx(UT,{activity:t.activity,snaps:t.allSnaps,currentMapId:t.mapId,attention:b,handlers:r.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($L,{view:w,items:a.elsewhere,snaps:t.allSnaps,pending:t.activity.pending,currentMapId:t.mapId,handlers:r.handlers,onSnooze:r.attention.snooze,onDismiss:r.attention.dismiss})]}),s.jsx(NL,{working:g,now:h,onTicket:k,onOpenChat:S=>n.openChat(S)}),s.jsx(PL,{live:m,now:h,onTicket:k})]})}):null}function FL(e,t){const[n,r]=y.useState(!1);return{open:()=>r(!0),startOver:d=>void t.actions.setArchived(!0).then(()=>r(dT(d))),dialog:n&&s.jsx(SR,{rt:e,seed:typeof n=="object"?n:void 0,onClose:()=>r(!1),onCreated:d=>t.actions.selectMap(d)})}}const zL=390;function bg(e){return e>900?zL:0}function UL(){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 zu(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 WL(e,t,n=[]){const r=new Map(e.tickets.map(c=>[c.id,c]));return{tickets:t.nodes.map(c=>{const d=r.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 HL(e,t){const n=K0({...e,tickets:t}),r=new Set;for(let a=1;a<n.length;a++)r.add(ka(n[a-1].id,n[a].id));return r}function KL(e){const{obstacles:t,from:n,to:r,clear:a}=e,c=t.flatMap(h=>[h.y-28,h.y+h.h+28]).filter(a),d=h=>Math.abs(h-n)+Math.abs(h-r);return c.reduce((h,f)=>d(f)<d(h)?f:h,c[0]??n)}const GL=6;function VL(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,h]=[t[a-1],t[a],t[a+1]],f=Math.min(GL,Sg(c,d)/2,Sg(d,h)/2),m=Ng(d,c,f),g=Ng(d,h,f);n+=`L${m.x} ${m.y}Q${d.x} ${d.y} ${g.x} ${g.y}`}const r=t[t.length-1];return`${n}L${r.x} ${r.y}`}function Sg(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function Ng(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,r=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 VL(qL({a:r,b:a,obstacles:c,gap:e.gap}).map(n))}function qL({a:e,b:t,obstacles:n,gap:r}){const a=n.filter(m=>m.x+m.w>e.x+1&&m.x<t.x-1),c=m=>!a.some(g=>m>g.y-8&&m<g.y+g.h+8),d=Math.min(e.x+r/2,(e.x+t.x)/2),h=Math.max(t.x-r/2,(e.x+t.x)/2);if(c(e.y))return[e,{x:h,y:e.y},{x:h,y:t.y},t];if(c(t.y))return[e,{x:d,y:e.y},{x:d,y:t.y},t];const f=KL({obstacles:a,from:e.y,to:t.y,clear:c});return[e,{x:d,y:e.y},{x:d,y:f},{x:h,y:f},{x:h,y:t.y},t]}const $g={LR:130,TB:68};function QL(e){const{direction:t,from:n,to:r,cards:a}=e;if(t==="LR"){const h={x:n.x+_e,y:n.y+He/2},f={x:r.x,y:r.y+He/2};return mi({direction:t,a:h,b:f,obstacles:a,gap:$g.LR})}const c={x:n.x+_e/2,y:n.y+He},d={x:r.x+_e/2,y:r.y};return mi({direction:t,a:c,b:d,obstacles:a,gap:$g.TB})}const Cg=e=>e.ticket.state==="closed"&&e.ticket.closeReason==="completed";function YL(e){const{from:t,to:n,direction:r}=e,c=["edge",t.ticket.state!=="open"?"edge-done":"edge-open"];return Cg(t)&&Cg(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:QL({direction:r,from:t,to:n,cards:e.cards})})}function JL(e){const{snap:t,tickets:n,direction:r,preview:a}=e,c=y.useMemo(()=>HL(t,n),[t,n]),d=y.useMemo(()=>zu(e.nodes),[e.nodes]);return e.edges.map(({from:h,to:f})=>{const m=ka(h.ticket.id,f.ticket.id);return s.jsx(YL,{from:h,to:f,direction:r,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 XL(e,t,n){return!!t&&e.state==="frontier"&&!n}const Uu=24,ZL=13,eP=9.5;function tP(e){const t=e.guide;return s.jsx("g",{className:"meta",transform:`translate(${Uu} ${e.y})`,children:e.chips.map((n,r)=>{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:ZL,rx:3}),s.jsx("text",{x:(n.w-n.textW)/2,y:eP,textLength:n.textW,lengthAdjust:"spacingAndGlyphs",children:n.text})]},r)})})}function nP(e,t){return e.length?e.length>2?`waits on ${e.length} tickets`:`waits on ${e.map(r=>t.includes(r)?`your ${r}`:r).join(", ")}`:void 0}const Hy=5,sP={sans:"9.5px 'Figtree Variable', system-ui, sans-serif",mono:"8.55px 'JetBrains Mono Variable', ui-monospace, monospace"};let hr;function iP(){if(hr!==void 0)return hr;try{hr=typeof document>"u"?null:document.createElement("canvas").getContext("2d")}catch{hr=null}return hr}function rP(e,t="sans"){const n=iP();return n?(n.font=sP[t],n.measureText(e).width*1.04):e.length*Hy}const Tg=4,Eg=3,oP=6;function aP(e){var k;const t=_e-Uu-8-(e.reserve??0),n=((k=e.state)==null?void 0:k.split(" · "))??[],r=[{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-r.length*2*Tg-(r.length-1)*Eg,c=w=>rP(w.text,w.kind==="key"?"mono":"sans"),d=r.filter(w=>w.kind!=="guide").reduce((w,b)=>w+c(b),0),h=Math.max(oP,Math.floor((a-d)/Hy)),f=r.map(w=>w.kind==="guide"?{...w,text:E2(w.text,h)}: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*Tg,textW:b};return g+=S.w+Eg,S})}function cP(e,t,n){return{text:[e.agent,n,t?`${e.step}/${e.total}`:void 0].filter(Boolean).join(" · "),tone:"agent"}}function lP(e){const{n:t,session:n}=e,r=t.ticket.assignee;return e.waiting?{text:"waiting on you",tone:"urgent"}:e.need?{text:e.need,tone:"urgent"}:e.stalled?{text:`stalled · ${r}`,tone:"warn"}:e.brief?{text:"waits on brief",tone:"warn"}:e.wait?{text:`needs ${e.wait}`,tone:"warn"}:n?cP(n,e.step,e.model):t.state==="claimed"?{text:r??"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:m1[t.state],tone:""}}function dP(e){var b;const{n:t,live:n,marked:r}=e,a=t.ticket,c=n==null?void 0:n.items[0],d=t.state==="frontier"?n==null?void 0:n.readySince:void 0,h=d===void 0?void 0:Xe(Math.max(0,e.now-d)),f=n&&nP(n.waitsOn,n.waitsOnYours),m=S=>r?void 0:lP({n:t,session:n==null?void 0:n.session,waiting:e.waiting,need:c&&DT(c),stalled:e.stalled,brief:e.brief,wait:e.wait,step:!e.guide,model:S,readyFor:h,waitsOn:f,verified:e.verified}),g=S=>{let x=1;const C=m(S);return{chips:aP({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=_a((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 uP(e,t,n){const r=e.state==="frontier"||e.state==="rework";if(!(!t||n||e.ticket.assignee||!r))return t}function hP(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 fP({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 mP={claimed:"working",verifying:"working",frontier:"ready",blocked:"backlog",parked:"backlog",decided:"done","out-of-scope":"cancelled",rework:"attention",held:"attention"};function pP(e){const t=mP[e.state];return t==="done"||t==="cancelled"?t:e.attention?"attention":e.live?"working":t}function gP({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 Ky(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 r=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}),r]}):r}const xd=8;function vP({step:e,total:t}){const n=_e-xd*2,r=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:xd,y:3,width:n,height:2.5,rx:1}),s.jsx("rect",{className:"step-fill",x:xd,y:3,width:n*r,height:2.5,rx:1})]})}function kP(e,t,n=2){const r=e.split(/\s+/),a=[];let c="";for(const d of r)(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 yP=26;function wP({n:e,live:t,now:n,stalled:r,flag:a,selected:c,onSelect:d,mark:h,frozen:f,needs:m,verified:g,briefHeld:k}){const w=e.ticket,b=t==null?void 0:t.session,S=kP(w.title,yP),x=pi(w)==="hitl",C=!!(b!=null&&b.waitingOn),N=!!h&&h!=="unchanged",P=uP(e,m,!!b),D=XL(e,k,!!b),M=oE(cv(w).find(Z=>{var se;return!((se=w.guidesRemoved)!=null&&se.includes(Z))})),W=x&&!N&&(w.type==="task"||w.type==="execute"),_=xP(h,f),Y=dP({n:e,live:t,now:n,marked:N,waiting:C,stalled:r,brief:D,wait:P,verified:g,needsYou:W,reserve:_,guide:M==null?void 0:M.name}),re=C||(t==null?void 0:t.tone)==="needs",q=[re,r,D,P,W&&e.state==="frontier"].some(Boolean),ye=pP({state:e.state,live:!!b,attention:q}),Ie=(t==null?void 0:t.tone)==="waiting-agent"&&!N&&!f,be=S.length>1?19:24;return s.jsxs("g",{className:hP({n:e,tone:ye,hitl:x,selected:c,live:!!b,waiting:re,stalled:r,mark:h,frozen:f,pickUp:Ie}),style:{transform:`translate(${e.x}px, ${e.y}px)`},"data-ticket":w.key,onClick:Z=>{Z.stopPropagation(),d({kind:"ticket",id:w.id})},children:[s.jsx(fP,{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(vP,{step:b.step,total:b.total}),s.jsx(Ky,{tone:ye,cy:be-4,verified:g,spin:Ie,pulse:!!b&&!C}),S.map((Z,se)=>s.jsx("text",{className:"title",x:Uu,y:be+se*14,children:Z},se)),s.jsx(tP,{chips:Y.chips,y:be+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(gP,{mark:h,frozen:f})]})}function xP(e,t){return(e&&e!=="unchanged"&&e!=="cancelled"?44:0)+(t?12:0)}const ci=62,li=26,Zd={LR:{x:130,y:0},TB:{x:0,y:84}};function jP(e,t){return t?Zd[e]:{x:0,y:0}}function bP(e){const{direction:t,nodes:n}=e,r=n.filter(m=>m.state!=="out-of-scope"&&!m.ticket.blockedBy.some(g=>n.some(k=>k.ticket.id===g))),a=zu(n);if(t==="LR"){const m=-Zd.LR.x+20,g=e.graphH/2-li/2,k={x:m+ci,y:g+li/2},w=r.map(b=>mi({direction:t,a:k,b:{x:b.x,y:b.y+He/2},obstacles:a,gap:96}));return{x:m,y:g,edges:w}}const c=e.width/2-ci/2,d=-Zd.TB.y+16,h={x:c+ci/2,y:d+li},f=r.map(m=>mi({direction:t,a:h,b:{x:m.x+_e/2,y:m.y},obstacles:a,gap:48}));return{x:c,y:d,edges:f}}function SP(e){const{tone:t}=e,n=t==="passed";return s.jsxs(s.Fragment,{children:[e.edges.map(r=>s.jsx("path",{className:pe("edge",n?"edge-done":"edge-open"),d:r},r)),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:r=>{r.stopPropagation(),e.onSelect()},onKeyDown:r=>{(r.key==="Enter"||r.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"})]})]})}function NP(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 $P(e,t){const n=new Set(e.edges.map(c=>c.from)),r=e.nodes.filter(c=>c.state!=="out-of-scope"&&!n.has(c)),a=zu(e.nodes);return r.map(c=>{if(e.direction==="LR"){const f={x:c.x+_e,y:c.y+He/2},m={x:t.x-30,y:t.y};return mi({direction:"LR",a:f,b:m,obstacles:a,gap:96})}const d={x:c.x+_e/2,y:c.y+He},h={x:t.x,y:t.y-30};return mi({direction:"TB",a:d,b:h,obstacles:a,gap:48})})}function Gy(){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 CP(e){const{x:t,y:n,text:r,done:a,onSelect:c}=e,d=(r==null?void 0:r.trim())||"Where this trail ends",h=a&&a.kind!=="not-done",f=h?`Destination reached · ${a.reason}
166
+ ${d}`:`Destination
167
+ ${d}`,m=(a==null?void 0:a.kind)==="unverified"&&a.together.kind==="failed",g=pe("destination",h&&`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}),h?s.jsx(Gy,{}):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 TP({trails:e,travelled:t}){const n=t?"edge edge-done edge-travelled edge-destination":"edge edge-open edge-destination";return e.map(r=>s.jsx("path",{className:n,d:r},r))}function EP(e){const{laid:t,spot:n,done:r}=e,a=!!r&&r.kind!=="not-done";return s.jsxs(s.Fragment,{children:[s.jsx(TP,{trails:$P(t,n),travelled:a}),t.nodes.length>0&&s.jsx(CP,{x:n.x,y:n.y,text:e.text,done:r,selected:e.selected,onSelect:e.onSelect})]})}const ya=.95;function AP(e,t){const n=new Map(e.map(h=>[h.ticket.id,h])),r=t.map(h=>n.get(h)).filter(h=>!!h),a=e.filter(h=>h.state==="claimed"||h.state==="verifying"),c=[...r,...a.filter(h=>!r.includes(h))];if(c.length)return c;const d=e.find(h=>h.state==="frontier")??e[0];return d?[d]:[]}function Ag(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 RP(e){const{fit:t,nodes:n,size:r,pad:a}=e;if(t.k>=ya)return t;const c=AP(n,e.focus??[]);if(!c.length)return t;const d=ya,h=Math.max(r.w/2,r.w-(e.room??0)),f=Ag(c,a),g=(f.right-f.left)*d<=h-32&&(f.bottom-f.top)*d<=r.h-32?f:Ag(c.slice(0,1),a);return{k:d,x:h/2-(g.left+g.right)/2*d,y:r.h/2-(g.top+g.bottom)/2*d}}function MP(e){const{y:t,width:n,height:r}=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:r+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,Rg=4,IP=220,ri=e=>Math.round(e/Rg)*Rg;function OP(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 jd(e,t,n,r){return Array.from({length:6},()=>{const a=r*(.5+e()*.7),c=r*(.3+e()*.4);return{x:ri(t+(e()-.5)*r*.8-a/2),y:ri(n+(e()-.5)*r*.5-c/2),w:ri(a),h:ri(c)}})}function LP(e){const{width:t,height:n,nodes:r}=e,a=OP(e.seed),c=(w,b)=>w+a()*(b-w),d=(w,b)=>!r.some(S=>w>S.x-52&&w<S.x+_e+28&&b>S.y-52&&b<S.y+He+28),h=(t+it*2)*(n+it*2),f=Array.from({length:Math.round(h/9e4)},()=>jd(a,c(-it,t+it),c(-it,n+it),c(160,360))).flat(),m=[...jd(a,t+it*.55,n+it*.55,300),...jd(a,-it*.5,-it*.45,220)],g=[],k=(w,b,S)=>{g.length<IP&&d(b,S)&&g.push({sprite:w,x:ri(b),y:ri(S)})};for(let w=0;w<Math.round(h/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(h/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 Vy={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 PP({name:e}){return s.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:Vy[e]})}const DP=Object.keys(Vy),_P=y.memo(function(t){const{seed:n,width:r,height:a,nodes:c}=t,d=y.useMemo(()=>LP({seed:n,width:r,height:a,nodes:c}),[n,r,a,c]);return s.jsxs("g",{className:"terrain","aria-hidden":"true",children:[s.jsx("defs",{children:DP.map(h=>s.jsx(PP,{name:h},h))}),d.grass.map((h,f)=>s.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-grass)"},f)),d.water.map((h,f)=>s.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-water)"},f)),s.jsx("rect",{x:-4e3,y:-4e3,width:r+8e3,height:a+8e3,fill:"url(#map-grid)"}),d.items.map((h,f)=>s.jsx("use",{href:`#terrain-${h.sprite}`,x:h.x,y:h.y},f))]})});function qy(e){var r;const t=(r=Iu())==null?void 0:r.waiting,n=CA(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 BP=380;function FP(e){const{selId:t,size:n}=e,r=y.useRef(e);r.current=e;const a=y.useRef(),c=n.w>0;y.useEffect(()=>{t||(a.current=void 0);const{nodes:d,pad:h,view:f,setView:m,onFocus:g,room:k}=r.current,w=t?d.find(M=>M.ticket.id===t):void 0;if(!w||!c||a.current===t||(a.current=t,zP({n:w,pad:h,view:f,size:{w:n.w-k,h:n.h}})))return;g();const b=Math.min(1.4,Math.max(f.k,ya)),S=(n.w-k)/2,x={k:b,x:S-(h+w.x+_e/2)*b,y:n.h/2-(h+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 W=Math.min(1,(M-N)/BP),_=1-(1-W)**3;m({k:C.k+(x.k-C.k)*_,x:C.x+(x.x-C.x)*_,y:C.y+(x.y-C.y)*_}),W<1&&(P=requestAnimationFrame(D))};return P=requestAnimationFrame(D),()=>cancelAnimationFrame(P)},[t,c])}function zP(e){const{n:t,pad:n,view:r,size:a}=e,c=r.x+(n+t.x)*r.k,d=r.y+(n+t.y)*r.k,h=c+_e*r.k,f=d+He*r.k;return r.k>=ya&&c>=16&&d>=16&&h<=a.w-16&&f<=a.h-16}function Qy(e,t,n){const r=Math.min(3,Math.max(.2,t));return{k:r,x:n.x-(n.x-e.x)*r/e.k,y:n.y-(n.y-e.y)*r/e.k}}function UP(e){const{box:t,view:n,setView:r}=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}},h=()=>{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=Qy(g.view,g.view.k*b/(g.dist||b),g.mid);r({...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,r({...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),h()},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&&h()},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,WP=1.8;function HP(e){const{tickets:t,mode:n,size:r}=e,a=y.useMemo(()=>{const k=Gm(t,"LR",n),w=Gm(t,"TB",n),b=S=>Math.min(r.w/(S.width+Wt*2),r.h/(S.height+Wt*2+16));return b(k)*WP>=b(w)?k:w},[t,n,r.w,r.h]),c=(k,w)=>Math.min(1.25,Math.max(e.minFit??0,Math.min(r.w/k,r.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")&&r.h?Math.max(0,r.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)})),quarantineY:a.quarantineY+S,height:a.height+S}},[a,r.w,r.h,e.minFit]),h=NP(d),f=jP(d.direction,e.main),m=h.right+Wt*2+f.x,g=h.bottom+Wt*2+16+f.y;return{L:d,destination:h,room:f,W:m,H:g,fitK:c}}function KP(e,t){const n=y.useRef(t);n.current=t,y.useEffect(()=>{const r=e.current;if(!r)return;const a=m=>{const g=r.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 h=m=>{m.preventDefault(),d=1},f=m=>{m.preventDefault();const g=m;n.current(g.scale/d,a(g)),d=g.scale};return r.addEventListener("wheel",c,{passive:!1}),r.addEventListener("gesturestart",h,{passive:!1}),r.addEventListener("gesturechange",f,{passive:!1}),()=>{r.removeEventListener("wheel",c),r.removeEventListener("gesturestart",h),r.removeEventListener("gesturechange",f)}},[e])}function GP(e){var me,Se;const{snap:t,selection:n,onSelect:r,preview:a}=e,c=e.proofs??{},d=(a==null?void 0:a.tickets)??t.tickets,h=y.useRef(null),[f,m]=y.useState({w:0,h:0});y.useEffect(()=>{const z=h.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}=HP({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,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,W]=y.useState({k:1,x:0,y:0}),_=y.useRef(!1);y.useEffect(()=>{_.current=!1},[t.map.id]),y.useEffect(()=>{!_.current&&f.w&&W(RP({fit:D(),nodes:N,size:f,pad:Wt,focus:e.focus,room:bg(f.w)}))},[f.w,f.h,b,S,t.map.id,(me=e.focus)==null?void 0:me[0]]);const Y=UP({box:h,view:M,setView:W,onTouch:()=>_.current=!0});KP(h,(z,Q)=>{_.current=!0,W(U=>Qy(U,U.k*z,Q))});const re=gt(5e3),q=gu(e.leases,t.map.id),ye=$r(),Ie=qy(t),be=(n==null?void 0:n.kind)==="ticket"?n.id:void 0;FP({selId:be,nodes:N,size:f,pad:Wt,view:M,setView:W,room:bg(f.w),onFocus:()=>_.current=!0});const Z=z=>{const Q=z==="main"?C&&{x:C.x,y:C.y,w:ci,h:li}:se(z)??Ne(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}},se=z=>z==="destination"?{x:k.x-24,y:k.y-24,w:48,h:48}:void 0,Ne=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:h,...Y,children:[s.jsxs("svg",{className:"graph",width:f.w,height:f.h,onClick:()=>r(null),children:[s.jsx(UL,{}),s.jsxs("g",{transform:`translate(${M.x} ${M.y}) scale(${M.k})`,children:[s.jsx("g",{transform:`translate(${Wt} ${Wt})`,children:s.jsx(_P,{seed:t.map.id,width:b,height:S,nodes:N})}),s.jsxs("g",{transform:`translate(${P.x} ${P.y})`,children:[s.jsx(MP,{y:g.quarantineY,width:g.width,height:g.quarantineH,nodes:g.nodes}),s.jsx(JL,{snap:t,tickets:d,direction:g.direction,nodes:g.nodes,edges:g.edges,preview:a}),s.jsx(EP,{laid:g,spot:k,text:t.map.sections.destination,done:e.done,selected:(n==null?void 0:n.kind)==="together",onSelect:()=>r({kind:"together"})}),C&&e.main&&s.jsx(SP,{...C,tone:e.main,selected:(n==null?void 0:n.kind)==="main",onSelect:()=>r({kind:"main"})}),g.nodes.map(z=>{const Q=q.get(z.ticket.id);return s.jsx(wP,{n:z,live:e.live.get(z.ticket.id),now:re,stalled:!!Q&&Ts(Q,re)!=="live",flag:H1(ns.ticket(ye,t.map.id,z.ticket.id)),selected:be===z.ticket.id,onSelect:r,mark:a==null?void 0:a.marks.get(z.ticket.id),frozen:a==null?void 0:a.frozen.has(z.ticket.id),...Ie(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,W(D())},children:"Fit"})]}),(Se=e.overlay)==null?void 0:Se.call(e,Z,f)]})}const VP=[{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 qP(){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:VP.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(Ky,{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 QP(e,t){const[n,r]=y.useState({statuses:{}});return Le({view:e,version:t,load:async()=>{if(!e)return{mapId:e,statuses:{}};const a=await fetch(`${ae()}/proof/trail?mapId=${encodeURIComponent(e)}`),c=a.ok?(await a.json()).statuses??{}:{};return{mapId:e,statuses:c}},show:r,failed:()=>r({mapId:e,statuses:{}}),changed:a=>a.includes(".evidence")||!!e&&a.includes(e)}),e&&n.mapId===e?n.statuses:void 0}function YP(){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 JP(e){var r,a,c,d,h;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(rT,{}),(r=e.trail)==null?void 0:r.banner,s.jsxs("div",{className:"map-area",children:[t?s.jsx(GP,{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:YP()}),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:wk,children:(h=Ot())==null?void 0:h.label}):s.jsx(Ha,{command:'/scout new "your idea"'})]}),!t&&!e.docked&&e.bubble({anchorOf:()=>{},box:{w:0,h:0}}),t&&s.jsx(qP,{})]}),e.docked&&e.bubble()]})}function XP(e){const{view:t,covered:n,needs:r}=e;return s.jsx("nav",{className:"tabbar",children:gy.map(({id:a,label:c})=>s.jsxs("button",{className:t===a&&!n?"on":"",onClick:()=>e.onPick(a),children:[c,a==="map"&&r>0&&s.jsx(xs,{n:r,urgent:!0,pop:!0},r)]},a))})}function ZP(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 Mg={settingsPage:!0},Ig=()=>_u(new URLSearchParams(location.search).get("settings")),Og=()=>{var e;return!!((e=history.state)!=null&&e.settingsPage)};function e3(){const[e,t]=y.useState(Ig);y.useEffect(()=>{e&&!Og()&&(history.replaceState(null,"",mr(location.href,null)),history.pushState(Mg,"",mr(location.href,e)));const d=()=>t(Ig());return window.addEventListener("popstate",d),()=>window.removeEventListener("popstate",d)},[]);const n=d=>{const h=mr(location.href,d);e?history.replaceState(history.state,"",h):history.pushState(Mg,"",h),t(d)},r=()=>{e&&(t(null),Og()?history.back():history.replaceState(null,"",mr(location.href,null)))},a=d=>n(_u(d??"")??{});return{route:e,open:a,show:n,close:r,dismiss:()=>t(null),toggle:()=>e?r():a()}}const eu="view",bd={lookoutPage:!0},Lg=()=>{const e=new URLSearchParams(location.search).get(eu);return jR.includes(e)?e:null},Pg=()=>{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(eu),t.searchParams.delete("settings"),e&&t.searchParams.set(eu,e),t.toString()}function t3(){const[e,t]=y.useState(Lg);return y.useEffect(()=>{e&&!Pg()&&(history.replaceState(null,"",Jo(null)),history.pushState(bd,"",Jo(e)));const a=()=>t(Lg());return window.addEventListener("popstate",a),()=>window.removeEventListener("popstate",a)},[]),{page:e,open:a=>{const c=Jo(a);Pg()?history.replaceState(bd,"",c):history.pushState(bd,"",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 n3(e){const{activity:t,selection:n,setSelection:r,actions:a}=e,c=t3(),[d,h]=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&&r({kind:"ticket",id:_.ticketId})},[e.chatSession,e.mapId]);const w=()=>{k(!1),c.close()},b=_=>{k(!1),c.open(_)},S=_=>{r(_),_||h(!1)},x=_=>{_&&_!==e.mapId&&a.selectMap(_)},C=(_,Y)=>{x(_),r({kind:"ticket",id:Y}),w()},N=_=>{const Y=t.pending.find(re=>re.id===_);Y&&(x(Y.mapId),r(Y.ticketId?{kind:"ticket",id:Y.ticketId}:{kind:"question",id:Y.id}),w())},P=_=>{x(_),r({kind:"main"}),w()},D=_=>{x(_),r({kind:"together"}),w()},M=(_,Y,re)=>{x(re),a.openChat(_),b("activity")},W=_=>{m(_),b("logbook")};return{page:c.page,openPage:b,toMap:w,fullTicket:d,setFullTicket:h,logbookFocus:f,openDecisions:W,statsOpen:g,setStatsOpen:k,toggleStats:()=>k(_=>!_),select:S,openTicket:C,openQuestion:N,openMainChecks:P,openTrailChecks:D,openChat:M}}function s3(e,t){y.useEffect(()=>{document.title=`${J.name}: ${e?`(${e}) `:""}${t??"No trail"}`},[e,t])}function i3(e,t){const n=e.blockedBy.map(r=>{var a;return((a=t.get(r))==null?void 0:a.closedAt)??0});return Math.max(e.createdAt,...n)}function r3(e){const{t,state:n,session:r,items:a}=e;return n==="out-of-scope"?"cancelled":a.length||r!=null&&r.waitingOn?"needs":n==="decided"?"done":r||n==="claimed"||n==="verifying"?"working":(n==="frontier"||n==="rework")&&!t.assignee&&pi(t)!=="hitl"&&!e.held?"waiting-agent":"not-started"}function o3(e){const{snap:t}=e,n=Cs(t.tickets,t.map.mode),r=new Map(t.tickets.map(h=>[h.id,h])),a=e.items.filter(h=>h.mapId===t.map.id&&h.ticketId),c=t.tickets.map(h=>{var w;const f=a.filter(b=>b.ticketId===h.id),m=e.sessions.find(b=>b.ticketId===h.id&&b.mapId===t.map.id),g=((w=e.heldBack)==null?void 0:w.call(e,h))??!1,k=r3({t:h,state:n.get(h.id),session:m,items:f,held:g});return{ticket:h,tone:k,session:m,items:f}}),d=new Map(c.map(h=>[h.ticket.id,h.tone]));return new Map(c.map(h=>{const f=h.ticket.blockedBy.filter(k=>{var w;return((w=r.get(k))==null?void 0:w.state)==="open"}),m=f.filter(k=>d.get(k)==="needs"),g={...h,readySince:h.tone==="waiting-agent"?i3(h.ticket,r):void 0,waitsOn:h.tone==="not-started"?f.map(k=>r.get(k).key):[],waitsOnYours:h.tone==="not-started"?m.map(k=>r.get(k).key):[]};return[h.ticket.id,g]}))}function a3(e){const{snap:t,sessions:n,view:r}=e,a=qy(t),c=t==null?void 0:t.map.id,[d,h]=y.useMemo(()=>{const x=(r==null?void 0:r.items)??[],C=N=>!N.mapId||N.mapId===c;return[x.filter(C),x.filter(N=>!C(N))]},[r,c]),f=y.useMemo(()=>[...new Set(d.flatMap(x=>x.ticketId?[x.ticketId]:[]))],[d]),m=y.useMemo(()=>n.filter(mn),[n]),k=t?o3({snap:t,sessions:m,items:d,heldBack:x=>{const C=a(x);return!!C.needs||C.briefHeld}}):new Map,w=EL(k),b=AL(w,d);return{live:k,items:d,elsewhere:h,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 c3(e,t){const n=Nu(e),r=t.some(c=>c.kind==="main-checks"),a=W$(n.view,r);return{tone:a,needs:a==="needs"}}const l3=new Set(["question","main-checks","trail-checks"]),d3=e=>!!e.ticketId||l3.has(e.kind);function u3(e){const t=y.useRef(new URLSearchParams(location.search).has(Ss)),{loaded:n,view:r,activity:a,mapId:c,busy:d,open:h}=e;y.useEffect(()=>{if(t.current||!n||!r||!c)return;const f=r.items.find(m=>m.mapId===c&&d3(m));(f==null?void 0:f.kind)==="question"&&!a.pending.some(m=>m.id===f.ref)||(t.current=!0,f&&!d&&h(f))},[n,r,a,c,d,h])}function h3(e){const[t,n]=y.useState("…");return y.useEffect(()=>{fetch(`${ae()}/list`).then(r=>r.json()).then(r=>{var c;const a=r.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 f3(e,t){return y.useMemo(()=>{const n=e.sessions.filter(a=>a.mapId===t),r=new Set(e.sessions.filter(a=>a.mapId!==t).map(a=>a.id));return{...e,sessions:n,feed:e.feed.filter(a=>!a.sessionId||!r.has(a.sessionId))}},[e,t])}function m3(e){const t=Ga(e),[n,r]=y.useState(!1),a=()=>r(!0),c=t.brief,d=NA(c),h=pa(n?c==null?void 0:c.mapId:void 0,t.hash),f=c==null?void 0:c.sections,m=c&&n&&s.jsx(kA,{brief:c,error:t.error,changed:h.changed,onReviewAgain:h.reviewAgain,onAccept:()=>void t.accept(h.hash).then(k=>k&&r(!1)),onRequestChanges:k=>void t.requestChanges(k).then(w=>w&&r(!1)),onClose:()=>r(!1)}),g=d.show&&!n&&s.jsx(xA,{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(wA,{brief:c,onReview:a}),dialog:s.jsxs(s.Fragment,{children:[m,g]})}}function p3(e){var m;const{reroute:t,onReview:n}=e,r=t.kind==="challenge-destination",a=((m=t.frozen)==null?void 0:m.length)??0,c=r?"wrong mountain?":"proposes a new plan",d=a?` ${a} ticket${a===1?" is":"s are"} closed until you decide.`:"",h=t.wide?" It touches most of the open tickets, so nothing is frozen.":"",f=`${t.reason.replace(/\.$/,"")}.${d}${h}`;return 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 g3=e=>e.changes.flatMap(t=>"ticket"in t?[t.ticket]:[]);function v3(e,t){const n=new Set(g3(t));return e.tickets.filter(r=>n.has(r.id)&&r.updatedAt>t.at).map(r=>({key:r.key,title:r.title,what:k3(r)}))}function k3(e){return e.state==="closed"?"closed":e.assignee?`claimed by ${e.assignee}`:"changed"}function y3({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 w3={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"},Yy="Dismissed by the trail lead. Carry on with the current plan.",x3="Declined by the trail lead.";function j3(e,t){var n,r,a;switch(e.op){case"edit_ticket":return[...(n=e.title)!=null&&n.trim()?[{label:"New title",text:e.title.trim()}]:[],...(r=e.body)!=null&&r.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 b3(e,t){var n;switch(e.op){case"add_ticket":{const r=(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`,r].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:S3(e)};case"rewire":return{verb:"Rewire",text:t(e.ticket),detail:N3(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 S3(e){var n,r;return[((n=e.title)==null?void 0:n.trim())&&"New title",((r=e.body)==null?void 0:r.trim())&&"new description"].filter(Boolean).join(" and ").replace(/^new/,"New")}function N3(e,t){var r,a;return[...(r=e.addBlockedBy)!=null&&r.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 $3=new Set(["cancel_ticket","update_destination"]);function C3(e){const{change:t,name:n}=e,r=b3(t,n),a=j3(t,e.by);return s.jsx(fe,{as:"li",className:`reroute-change op-${t.op}`,edge:$3.has(t.op)?"attention":"neutral",title:r.text,titleText:r.text,context:s.jsx(B,{parts:[{text:r.verb,strong:!0}]}),detail:r.detail,detailText:r.detail,below:a.length?s.jsx(y3,{parts:a}):void 0})}function T3(e){const{reason:t,destination:n}=e;return s.jsxs("section",{className:"reroute-destination",children:[t&&s.jsx("p",{className:"reroute-destination-why",children:w3[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 E3(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 A3(e,t){const n=new Map(e.tickets.map(a=>[a.id,a.key])),r=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=r.get(a);return d?`new: ${d}`:a}}function R3(e){var P,D;const{reroute:t,snap:n}=e,[r,a]=y.useState(""),[c,d]=y.useState(!1);y.useEffect(()=>{const M=W=>W.key==="Escape"&&e.onClose();return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[e]);const h=A3(n,t.changes),f=new Map(n.tickets.map(M=>[M.id,`${M.key} ${M.title}`])),m=M=>f.get(M)??h(M),g=n.map.sections.assumptions??[],k=t.invalidates.map(M=>g.find(W=>W.id===M)??{id:M,text:""}),w=t.status==="pending",b=w?v3(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(T3,{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,W)=>s.jsx(C3,{change:M,by:t.by,name:m},W))})]}),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(Ee,{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(E3,{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:r,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?x3:Yy),children:C?"Decline":"Dismiss"}),s.jsx(I,{className:"reroute-reject",disabled:!r.trim(),onClick:()=>e.onReject(r.trim()),children:"Reject"}),gk()?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(r.trim()),children:"Approve and apply"})]}),s.jsx(I,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}const Jy=`${ae()}/reroutes`;async function M3(e){if(!e)return[];const t=await fetch(`${Jy}?map=${encodeURIComponent(e)}`);return t.ok?(await t.json()).reroutes:[]}function I3(e){const t=e==null?void 0:e.map.id,[n,r]=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:()=>M3(t),show:r,failed:()=>r([]),events:{reroute:f=>(f==null?void 0:f.mapId)===t}}),h=async(f,m,g)=>{var S,x;const k=await fetch(`${Jy}/${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)=>h("approve",f,m),reject:(f,m)=>h("reject",f,m)}}function O3(e,t){let n=t;for(let r=0;n&&r<e.length;r++){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 L3(e,t){const n=I3(e),[r,a]=y.useState(),c=O3(n.reroutes,r),d=n.reroutes.find(k=>k.id===c.id),h=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(p3,{reroute:g,onReview:()=>a(g.id),onDismiss:()=>void n.reject(g.id,Yy)}),pending:n.reroutes.filter(k=>k.status==="pending").length,preview:e&&(h!=null&&h.diff)?WL(e,h.diff,h.frozen):void 0,openReroute:(k,w)=>{k!==(e==null?void 0:e.map.id)&&(t==null||t(k)),a(w)},dialog:e&&d&&s.jsx(R3,{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 P3(e,t){return t.tickets.filter(r=>r.state==="closed"&&r.closeReason==="completed").filter(r=>{var a;return(a=ns.ticket(e,t.map.id,r.id))==null?void 0:a.flags.some(c=>c.kind==="done-pr-open")}).map(r=>r.id)}const D3=20;function Xy(e=D3){const t=document.querySelector(".ticket-proof");if(t)return t.scrollIntoView({block:"start",behavior:"smooth"});e>0&&setTimeout(()=>Xy(e-1),100)}function _3(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 B3({onClose:e}){return s.jsx(I,{variant:"primary",autoFocus:!0,onClick:e,children:"Close"})}function F3(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 z3(e){return e.done.kind==="unverified"&&e.done.together.kind==="failed"?s.jsx(_3,{onChecks:e.onChecks,onClose:e.onClose}):e.pulls>0?s.jsx(F3,{pulls:e.pulls,onReview:e.onReview,onClose:e.onClose}):s.jsx(B3,{onClose:e.onClose})}const U3=e=>e===1?"1 pull request to merge.":`${e} pull requests to merge.`;function W3(e){const{done:t,pulls:n,onClose:r}=e;return y.useEffect(()=>{const a=c=>c.key==="Escape"&&r();return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[r]),s.jsx("div",{className:"scrim",onClick:r,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&&` ${U3(n)}`]}),s.jsx("footer",{children:s.jsx(z3,{...e})})]})})}function H3({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(Gy,{})});return s.jsx(An,{title:"Destination reached",hint:e.reason,art:t})}function K3(e,t){return e.every(n=>n.state!=="closed"||n.closeReason!=="completed"||t[n.id]!==void 0)}function G3(e,t){const n=QP(e==null?void 0:e.map.id,e==null?void 0:e.tickets),r=mk(e==null?void 0:e.map.id).view,a=r&&r.mapId===(e==null?void 0:e.map.id)?r.together:void 0,c=y.useMemo(()=>{if(!(!e||!n||!a||!K3(e.tickets,n)))return Y0({tickets:e.tickets,proofs:n,pendingReroutes:t,together:a})},[e,n,t,a]);return{proofs:n,done:c}}const Dg=new Set,_g=e=>`teamtrail.trail-done:${ae()}:${e}`,Bg={has(e){const t=_g(e);if(Dg.has(t))return!0;try{return localStorage.getItem(t)==="1"}catch{return!1}},add(e){const t=_g(e);Dg.add(t);try{localStorage.setItem(t,"1")}catch{}}};function V3(e,t){return t.kind==="verified"?`${e}:verified`:t.together.kind==="failed"?`${e}:failed:${t.together.runId}`:e}function q3(e,t){const[,n]=y.useState(0),r=e==null?void 0:e.map.id,a=r&&t&&t.kind!=="not-done"?V3(r,t):void 0;return{show:!!a&&!(e!=null&&e.map.archived)&&!Bg.has(a),close:()=>{a&&Bg.add(a),n(h=>h+1)}}}function Q3(e){const{snap:t}=e,{proofs:n,done:r}=G3(t,e.pendingReroutes),a=q3(t,r),c=$r(),d=t?P3(c,t):[],h=()=>{a.close(),!(!t||!d.length)&&(e.openTicket(t.map.id,d[0]),Xy())},f=()=>{a.close(),t&&e.openTrailChecks(t.map.id)},m=a.show&&r&&r.kind!=="not-done"&&s.jsx(W3,{done:r,pulls:d.length,onReview:h,onChecks:f,onClose:a.close});return{proofs:n,done:r,dialog:m}}function Y3(e){const{snap:t}=e,n=m3(t),r=L3(t,e.selectMap),a=Q3({snap:t,pendingReroutes:r.pending,...e});return{briefText:n.briefText,inboxCard:n.inboxCard,review:n.review,banner:s.jsxs(s.Fragment,{children:[n.banner,r.banner]}),preview:r.preview,proofs:a.proofs,done:a.done,openReroute:r.openReroute,dialog:s.jsxs(s.Fragment,{children:[n.dialog,r.dialog,a.dialog]})}}function J3(){const e=new URL(location.href);e.searchParams.has(Ss)&&(e.searchParams.delete(Ss),history.replaceState(history.state,"",e))}function X3(e,t){return e.kind!=="question"||t.pending.some(n=>n.id===e.ref)}function Z3(e){const[t,n]=y.useState(()=>new URLSearchParams(location.search).get(Ss)??void 0),{loaded:r,view:a,activity:c,handlers:d}=e;return y.useEffect(()=>{if(!t||!r||!a)return;const h=a.items.find(f=>f.id===t);h&&!X3(h,c)||(n(void 0),J3(),h&&Eu(h,d))},[t,r,a,c,d]),{request:y.useCallback(h=>n(h),[])}}function e4(e){const{api:t,nav:n}=e,r=$k(t.allSnaps);OT(r.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=r.view,h=Z3({loaded:t.loaded,view:d,activity:t.activity,handlers:c}),f=d&&s.jsx(AT,{view:d,onFocus:m=>void r.savePrefs(Jb(d.prefs,m,Date.now())),onSettings:e.openFocusSettings});return{attention:r,handlers:c,header:f,link:h,open:m=>Eu(m,c)}}function t4({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 n4(e){const{d:t,snap:n}=e,r=Cr(),[a,c]=y.useState(!1),[d,h]=y.useState(""),[f,m]=y.useState("");y.useEffect(()=>{c(!1),h(""),m("")},[t.id,t.mapId]);const g=g0(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:[f1(t.decidedAt),`${Xe(b-t.decidedAt)} ago`]})]}),s.jsx("h3",{className:"t-heading",children:t.question}),s.jsx(IA,{mapId:t.mapId,kind:"decision",id:t.id}),s.jsx(t4,{d:t}),s.jsxs("div",{className:"resolution",children:[s.jsx(Bd,{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:[ju(t,r),ov(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,r),hi(x.decidedAt)]})]})},x.id))})]}),s.jsxs("div",{className:"actions",children:[s.jsx(Zk,{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=>h(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(Bd,{parts:[fi(x.author,r),pu(x.at)]}),s.jsx("div",{className:"msg-text",children:x.text})]},C))}):s.jsx(Ee,{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 s4(e){const{filter:t,set:n,all:r}=e,a=c=>r.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:r.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:r.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:r.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:r.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:r.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 Fg=e=>`${e.mapId}/${e.id}`;function i4(e,t){var a;const n=new Map;for(const c of e){const d=((a=t[Fg(c)])==null?void 0:a.area)??Jl;n.set(d,[...n.get(d)??[],c])}const r=c=>{var d;return((d=t[Fg(c)])==null?void 0:d.citedBy.length)??0};return[...n].map(([c,d])=>({area:c,rows:[...d].sort((h,f)=>r(f)-r(h)||f.decidedAt-h.decidedAt)})).sort((c,d)=>+(c.area===Jl)-+(d.area===Jl)||d.rows.length-c.rows.length||c.area.localeCompare(d.area))}function r4(e){if(br(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function o4(e){const{d:t}=e,n=Cr(),r=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(fe,{as:"li",className:`dv-row ${r}`,selected:e.on,onOpen:e.onClick,title:t.question,titleText:t.question,trailing:pu(t.decidedAt),context:s.jsx(B,{parts:[{text:t.id,code:!0},t.ticketKey&&{text:t.ticketKey,code:!0},e.showTrail&&e.trail,ju(t,n),ov(t)??ts[t.source.kind].label,r4(t),!!e.cited&&`cited ${e.cited}×`]}),detail:t.summary,detailText:t.summary})]})}function a4(e){const{rows:t,current:n,memory:r}=e,a=(c,d,h)=>{var f,m;return s.jsx(o4,{d:c,newDay:d,group:h,cited:(f=r==null?void 0:r[`${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 r&&t.length?s.jsx("ol",{className:"dv-list","aria-label":"Logbook by area",children:i4(t,r).flatMap(c=>c.rows.map((d,h)=>a(d,h===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(Ee,{children:"No decisions"})})}function c4({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 l4(e){const{filter:t}=e,r=Object.values(t).filter(Boolean).length-(t.query?1:0),a=e.filtersOpen||r>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",r>0?` · ${r}`:""]})]})}async function d4(){const e=await fetch(`${ae()}/decision-memory`);return e.ok?(await e.json()).entries:null}function u4(){const[e,t]=y.useState();return Le({load:d4,show:t,failed:()=>t(null),changed:n=>n.includes("/decisions/")||n.endsWith("map.md")}),e}function h4(e){const{api:t,bp:n}=e,r=t.decisions,[a,c]=y.useState({}),[d,h]=y.useState(e.focus),[f,m]=y.useState(!1),[g,k]=y.useState(!1),w=u4();y.useEffect(()=>h(e.focus),[e.focus]),y.useEffect(()=>{const W=_=>{_.key==="Escape"&&(n==="mobile"&&d?h(void 0):e.onClose())};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[n,d,e]);const b=y.useMemo(()=>Z0(r,a),[r,a]),S=y.useMemo(()=>eb(r),[r]),x=r.find(W=>W.id===d&&(!a.mapId||W.mapId===a.mapId))??(n==="mobile"?void 0:b[0]),C=y.useMemo(()=>Object.values(t.allSnaps).sort((W,_)=>_.map.createdAt-W.map.createdAt),[t.allSnaps]),N=y.useMemo(()=>[...new Set(r.map(W=>W.decidedBy))].sort(),[r]),P=W=>c(_=>({..._,...W})),D=()=>{const W=Object.fromEntries(C.map(_=>[_.map.id,{key:_.map.key,title:_.map.title}]));Hv(`${J.slug}-decisions-${hi(Date.now())}.md`,hb(b,W,{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:()=>h(void 0),children:"‹ Decisions"}):s.jsxs(Ke,{as:"h2",children:["Decisions ",b.length!==r.length&&s.jsx("span",{className:"n",children:`${b.length}/${r.length}`})]}),n!=="mobile"&&s.jsx(c4,{stats:S}),s.jsxs("span",{className:"dv-head-right",children:[!M&&w&&s.jsx(I,{on:g,"aria-pressed":g,onClick:()=>k(W=>!W),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(l4,{filter:a,set:P,showToggle:n!=="wide",filtersOpen:f,onToggle:()=>m(W=>!W)}),s.jsxs("div",{className:"dv-body",children:[(n==="wide"||f&&!M)&&s.jsx(s4,{filter:a,set:P,all:r,trails:C,people:N,compact:n!=="wide"}),!M&&s.jsx(a4,{rows:b,current:x,snaps:t.allSnaps,showTrail:n==="wide",onSelect:h,memory:g&&w?w:void 0}),(n!=="mobile"||x)&&s.jsx("div",{className:"dv-detail",children:x?s.jsx(n4,{d:x,all:r,snap:t.allSnaps[x.mapId],onSelect:h,onOpenTicket:e.onOpenTicket,onSupersede:t.actions.supersede}):s.jsx(Ee,{children:"No decision selected"})})]})]})}const f4={"asks-you":"urgent",answered:"good",launched:"good",done:"good",verified:"good","checks-failed":"attention",stalled:"attention",disconnected:"attention",problem:"attention"};function m4(e){if(e.kind)return f4[e.kind];if(e.signal){if(e.level==="alert")return"urgent";if(e.level==="ok")return"good"}}function p4({activity:e,onTicket:t}){const n=Cr(),r=e.feed.slice(-120).reverse();return r.length?s.jsx("div",{className:"log",children:r.map(a=>s.jsxs("div",{className:`log-row src-${a.source.replace(" ","-")} edge-${m4(a)??"none"}`,onClick:()=>a.ticketId&&t(a.ticketId),children:[s.jsx("span",{className:"t t-meta",children:Aa(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 zg({lease:e,now:t}){if(!e)return null;const n=Ts(e,t);if(n==="live")return null;const r=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(r)]})}function g4({total:e,step:t}){return s.jsx("span",{className:"segs","aria-label":`Step ${t} of ${e}`,children:Array.from({length:e},(n,r)=>s.jsx("i",{className:v4(r+1,t)},r))})}function v4(e,t){return e<t?"done":e===t?"cur":""}function k4({snap:e,activity:t,leases:n,onSelect:r,onOpenChat:a}){var w;const c=gt(1e3),d=t.sessions.filter(mn),h=new Set(d.map(b=>b.ticketId)),f=gu(n,e==null?void 0:e.map.id),m=(e==null?void 0:e.tickets.filter(b=>b.state==="open"&&b.assignee&&!h.has(b.id)))??[];if(!d.length&&!m.length)return s.jsx(Ee,{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(fe,{as:"li",className:b.waitingOn?"waiting":void 0,edge:y4(b,g(C)),title:b4(S,b.mode)||b.agent,context:s.jsx(B,{parts:[{text:b.agent,strong:!0},x4(b),k&&w4(b),b.waitingOn?{text:"Waiting on you",urgent:!0}:`${b.mode} · ${b.stepLabel.toLowerCase()}`,x&&!b.waitingOn&&"with you",j4(b)],children:s.jsx(zg,{lease:C,now:c})}),trailing:Kv(c-b.startedAt),below:s.jsx(g4,{total:b.total,step:b.step}),onOpen:()=>{S&&r({kind:"ticket",id:S.id}),x&&a(b.id)}},b.id)}),m.map(b=>s.jsx(fe,{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(zg,{lease:f.get(b.id),now:c})}),onOpen:()=>r({kind:"ticket",id:b.id})},b.id))]})}function y4(e,t){return e.waitingOn?"urgent":t?"attention":"neutral"}function w4(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 x4(e){const t=_a(e.model);return t&&{text:t,tip:e.model,className:"agent-model"}}function j4(e){if(e.usage)return`${Ra(q0(e))} tok · ${ui(e.usage.costUsd)}`}function b4(e,t){return e?`${e.key} ${e.title}`:t==="chart"?"Charting trail":""}function S4({activity:e,snap:t,running:n,usage:r=!0}){const a=mv(e,t==null?void 0:t.map.id),c=gv(e,t==null?void 0:t.map.id),d=new Set(e.sessions.filter(mn).map(f=>f.ticketId)),h=(t==null?void 0:t.tickets.filter(f=>f.state==="open"&&f.assignee&&!d.has(f.id)).length)??0;return s.jsx(yt,{sub:!0,className:"sessions-head",title:s.jsxs(s.Fragment,{children:["Agents on tickets ",s.jsx("span",{className:"n",children:n+h})]}),right:r?s.jsxs("span",{className:"usage",title:["Model usage for this trail, all sessions",...c.map(f=>pv[f].text)].join(`
171
+ `),children:[s.jsx("span",{className:"mono-label",children:"Trail"})," ",Ra(a.inputTokens+a.outputTokens)," tok · ",ui(a.costUsd)]}):void 0})}function N4(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 $4={running:"Working",done:"Done",failed:"Stopped"};function C4({activity:e,snap:t,done:n}){var h;if(n&&n.kind!=="not-done")return s.jsx(H3,{done:n});const r=N4(e);if(!r)return s.jsx(An,{title:"No agent working yet",hint:Ot()?`Turn your agents on for this trail in ${(h=Ot())==null?void 0:h.label}. Each step they report shows here.`:"Run /scout resume in Claude Code or Codex. Each step an agent reports shows here."});const a=r.ticketId?t==null?void 0:t.tickets.find(f=>f.id===r.ticketId):void 0,c=Sa[r.mode],d=r.waitingOn?"Waiting on you":$4[r.status];return s.jsxs("div",{className:`step-tracker ${r.waitingOn?"waiting":""}`,children:[s.jsxs("div",{className:"st-meta",children:[s.jsx(B,{parts:[{text:r.agent,strong:!0},`${r.mode}, step ${r.step} of ${r.total}`]}),s.jsx("span",{className:`t-label st-status ${r.waitingOn?"urgent":""}`,children:d})]}),s.jsxs("div",{className:"st-big",children:[r.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<r.step||g===r.step&&r.status==="done";let w="";return k?w="done":g===r.step&&(w="cur"),s.jsxs("li",{className:w,children:[s.jsx("i",{}),s.jsxs("span",{children:[String(g).padStart(2,"0")," ",f]})]},f)})})]})}function T4(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(C4,{activity:t,snap:e.snap,done:e.done}),s.jsx(S4,{activity:t,snap:e.snap,running:t.sessions.filter(mn).length}),s.jsx(k4,{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(p4,{activity:t,onTicket:e.onTicket})})]}),s.jsx("section",{className:"page-col conversation-col",children:s.jsx(CC,{activity:e.allActivity,snaps:e.snaps,sessionId:e.chatSession,onAnswer:e.onAnswer})})]})}const E4={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function A4(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 R4(e){const{a:t,snap:n}=e,r=t.tickets.flatMap(c=>n.tickets.filter(d=>d.id===c)),a=t.challenge&&`${t.challenge.by}: ${t.challenge.evidence}`;return s.jsx(fe,{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},E4[t.status],A4(t)],children:r.length>0&&s.jsxs("span",{className:"assumption-tickets",children:[s.jsx("span",{className:"sep",children:" · "}),"relied on by",r.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 M4(e){const[t,n]=y.useState(),[r,a]=y.useState();return{confirm:async(d,h)=>{a(d);const f=await fetch(`${ae()}/assumptions/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,id:d,text:h})}).catch(()=>{});if(a(void 0),f!=null&&f.ok)return 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:r,error:t}}function I4({snap:e,onSelect:t}){const{confirm:n,busy:r,error:a}=M4(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 h=d.status==="holding"||d.status==="challenged";return s.jsx(R4,{a:d,snap:e,onSelect:t,onConfirm:h?()=>void n(d.id,d.text):void 0,busy:r===d.id},d.id)})})]}):s.jsx(Ee,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function O4(e){const[,t,n=e]=/^(#\d+)\s+(.+)$/.exec(e)??[],[r=n,...a]=n.split(/\s+[—–]\s+/);return{key:t,title:r,reason:a.join(" — ")||void 0}}function L4(e){const[t,n]=y.useState([]),r=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(!r)return;let c=!0;return fetch(`${ae()}/journal?mapId=${encodeURIComponent(r)}`).then(d=>d.ok?d.json():{entries:[]}).then(d=>c&&n(d.entries)).catch(()=>c&&n([])),()=>{c=!1}},[r,a]),t}function P4({snap:e,activity:t,onTicket:n}){const r=L4(e),a=t.usageByMap[e.map.id],c=y.useMemo(()=>jv({snap:e,journal:r,answered:t.answered,usage:a}),[e,r,t.answered,a]),d=c.interventions,h=[["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:h.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:()=>Hv(`${e.map.key.replace("#","trail-")}-report.md`,xb(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(Ee,{children:"No tickets yet"})]})}function D4({tab:e,snap:t,selection:n,onSelect:r,activity:a}){const c=t.map.sections;switch(e){case"report":return a?s.jsx(P4,{snap:t,activity:a,onTicket:d=>r({kind:"ticket",id:d})}):s.jsx(Ee,{children:"No activity yet"});case"assumptions":return s.jsx(I4,{snap:t,onSelect:r});case"decisions":return c.decisions.length?s.jsx("ol",{className:"row-list decisions",children:[...c.decisions].reverse().map((d,h)=>s.jsx(fe,{as:"li",title:d.text,titleText:d.text,context:d.ticketKey&&s.jsx(B,{parts:[{text:d.ticketKey,code:!0}]}),onOpen:d.ticketId?()=>r({kind:"ticket",id:d.ticketId}):void 0},`${d.ticketKey}-${h}`))}):s.jsx(Ee,{children:"None"});case"unspecified":return c.unspecified.length?s.jsx("ul",{className:"row-list unspecified",children:c.unspecified.map(d=>s.jsx(fe,{as:"li",title:d,titleText:d,selected:(n==null?void 0:n.kind)==="unspecified"&&n.item===d,onOpen:()=>r({kind:"unspecified",item:d})},d))}):s.jsx(Ee,{children:"None"});case"oos":return c.outOfScope.length?s.jsx("ul",{className:"row-list oos",children:c.outOfScope.map(d=>{const h=O4(d);return s.jsx(fe,{as:"li",title:h.title,titleText:d,context:s.jsx(B,{parts:[h.key&&{text:h.key,code:!0},h.reason]})},d)})}):s.jsx(Ee,{children:"None"});case"notes":return s.jsx("p",{className:"notes t-body",children:c.notes||"No notes yet."});default:return e}}function _4({snap:e,selection:t,onSelect:n,bare:r,onAudit:a,activity:c}){var k;const[d,h]=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(D4,{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 ${r?"bare":""}`,style:r?void 0:{gridArea:"plan"},children:[!r&&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:h,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 Sd=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],Ug=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function B4({snap:e,sessions:t}){const n=fv(e),r=m=>n[m],a=t.filter(e$).length,c=G0(e),d=Math.max(1,...c.map(m=>m.open+m.closed)),f=(e.map.verification??"off")!=="off"||Ug.some(([m])=>r(m))?[...Sd.slice(0,2),...Ug,...Sd.slice(2)]:Sd;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} ${r(m)?"":"zero"}`,children:[s.jsx("i",{}),s.jsx("span",{children:g}),s.jsx("b",{children:r(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 F4(e){const{snap:t,selection:n}=e,r=(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(_4,{snap:t,selection:n,onSelect:e.onSelect,bare:!0,onAudit:e.onAudit,activity:e.activity})}),s.jsxs("section",{className:"page-col",children:[r&&s.jsx(yt,{title:"Open question"}),s.jsxs("div",{className:"zone-b",children:[t&&r&&s.jsx(my,{snap:t,item:r,api:e.api}),t&&!r&&s.jsxs(s.Fragment,{children:[e.glance,s.jsx(B4,{snap:t,sessions:e.activity.sessions})]})]})]})]})}function z4({api:e,bp:t,nav:n,scoped:r,done:a,attn:c}){const d=gt(5e3),h=f=>e.mapId&&n.openTicket(e.mapId,f);if(n.statsOpen)return s.jsx(vO,{api:e,bp:t,onClose:()=>n.setStatsOpen(!1)});switch(n.page){case"logbook":return s.jsx(h4,{api:e,bp:t,focus:n.logbookFocus,onClose:n.toMap,onOpenTicket:n.openTicket});case"plan":return s.jsx(F4,{api:e,snap:e.snap,activity:r,selection:e.selection,onSelect:n.select,onAudit:()=>n.openDecisions(),glance:e.snap&&s.jsx(fy,{snap:e.snap,sessions:r.sessions,attention:c.attention.view,done:a,now:d,onTicket:h,onItem:c.open})});case"activity":return s.jsx(T4,{activity:r,allActivity:e.activity,snaps:e.allSnaps,snap:e.snap,leases:e.leases,done:a,chatSession:e.chatSession,onTicket:h,onOpenChat:f=>n.openChat(f),onAnswer:e.actions.answer});default:return null}}function U4(e,t,n){const r=Iy(),[a,c]=y.useState(()=>new URLSearchParams(location.search).has("projects")),d=a&&r.many&&s.jsx(RI,{projects:r,bp:e,onClose:()=>c(!1),onItemHere:n});return{projects:r,overview:d,closeOverview:()=>c(!1),openOverview:()=>{t.toMap(),c(!0)}}}const W4=e=>typeof e=="string"&&/^\/(?!\/)[\w/?=&#.-]{0,200}$/.test(e)?e:void 0;function H4(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(r=>{const a=W4(r==null?void 0:r.href);return typeof(r==null?void 0:r.title)!="string"||!a?[]:[{title:r.title.slice(0,80),href:a,done:r.done===!0,next:r.next===!0,optional:r.optional===!0}]});return{done:t.done,total:t.total,complete:t.complete===!0,steps:n}}function K4(){var r;const e=(r=pt())==null?void 0:r.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=H4(k);a=(w==null?void 0:w.complete)===!0,n(w)}).catch(()=>{});c();const d=()=>document.visibilityState==="visible"&&c();let h;const f=()=>{a||(clearTimeout(h),h=setTimeout(c,500))};document.addEventListener("visibilitychange",d),window.addEventListener(Ud,f);const m=Da(f),g=rs(f);return()=>{clearTimeout(h),document.removeEventListener("visibilitychange",d),window.removeEventListener(Ud,f),m(),g()}},[e]),t}const Zy="teamtrail.guide.open";function G4(){try{return localStorage.getItem(Zy)!=="no"}catch{return!0}}function V4(e){try{localStorage.setItem(Zy,e?"yes":"no")}catch{}}function q4(){const e=K4(),[t,n]=y.useState(G4);if(!e||e.complete)return null;const r=c=>{n(c),V4(c)},a=`${e.done} of ${e.total}`;return Kk.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:()=>r(!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:()=>r(!t),"aria-expanded":t,children:[s.jsx(Ea,{size:1,framed:!1,state:"idle"}),!t&&s.jsxs("span",{className:"setup-chip",children:["Get started · ",a]})]})]}),document.body)}function Q4(){const e=y.useMemo(()=>Z1(X1()),[]),t=v$(e),{snap:n,activity:r}=t,[a,c]=w$(),d=e3(),h=FL(e,t),f=h3(e.kind),m=h$(),g=f3(r,t.mapId);s3(r.pending.length,n==null?void 0:n.map.title);const k=n3(t),w=Y3({snap:n,selectMap:t.actions.selectMap,openTicket:k.openTicket,openTrailChecks:k.openTrailChecks}),b=_E(w.briefText),S=e4({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=>kM(d.open,me),openFocusSettings:()=>d.open("attention")}),x=S.attention.view,C=m$(e,t,a.briefing,x==null?void 0:x.items),N=a3({snap:n,sessions:g.sessions,view:x}),P=c3(t.mapId,N.items),{projects:D,overview:M,openOverview:W,closeOverview:_}=U4(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(z4,{api:t,bp:m,nav:k,scoped:g,done:w.done,attn:S}),q=Y||M||re;u3({...t,view:x,busy:!!q||!!t.selection,open:S.open});const ye=k.page??"map",Ie=me=>{d.dismiss(),_(),me==="map"?k.toMap():k.openPage(me)},be=m==="mobile",Z=s.jsx(JP,{api:t,live:N.live,main:P.tone,focus:N.focus,onSelect:k.select,onNewTrail:h.open,minFit:be?.7:0,docked:be,trail:w,bubble:me=>s.jsx(xR,{api:t,nav:k,attn:S,sessions:g.sessions,mainNeeds:P.needs,place:me})}),se=s.jsx(BL,{api:t,nav:k,attn:S,trail:N,bp:m,brief:w.inboxCard}),Ne=s.jsx(A$,{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(Xk.Provider,{value:b,children:s.jsxs("div",{className:`app bp-${m} view-${ye}`,children:[s.jsx(bR,{api:t,rt:e,repo:s.jsx(MI,{repo:f,projects:D,onOverview:W}),brief:C,attention:S.header,view:Y||M?void 0:ye,onView:Ie,phone:be,needs:N.items,elsewhere:N.elsewhere,onNeed:S.open,onStats:()=>{d.dismiss(),k.toggleStats()},onNewTrail:h.open,onStartOver:()=>n&&h.startOver(n.map),onSettings:d.toggle,onSlack:()=>d.open("slack"),onToggleTheme:me=>c({theme:me?"night":"day"})}),be?s.jsxs(s.Fragment,{children:[s.jsx(ZP,{covered:q,map:Z,trailBar:se,projects:D.many&&s.jsx(OI,{projects:D,onOverview:W})}),s.jsx(XP,{view:ye,covered:!!Y||!!M,needs:N.items.length,onPick:Ie})]}):s.jsxs(s.Fragment,{children:[Z,se,q]}),s.jsx(SL,{api:t,nav:k,attn:S,sessions:g.sessions,done:w.done}),Ne,w.dialog,t.error&&s.jsx("div",{className:"error-toast",children:t.error}),h.dialog,!a.onboarded&&s.jsx(gM,{prefs:a,update:c,activeTracker:e.kind}),s.jsx(PE,{}),s.jsx(q4,{})]})})}const Y4="X-Teamtrail-Session";function J4(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url}function X4(e){const t=new URL(J4(e),location.href),n=J.apiPrefix;return t.origin===location.origin&&(t.pathname===n||t.pathname.startsWith(`${n}/`))}function Z4(){const e=window.fetch.bind(window);window.fetch=(t,n)=>{const r=O1()?ku():void 0;if(!r||!X4(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(Y4,r.secret),e(t,{...n,headers:a})}}Ma(xu().theme);Z4();rj.createRoot(document.getElementById("root")).render(s.jsxs(uL,{children:[s.jsx(Q4,{}),s.jsx(S$,{})]}));